Closed TarikGul closed 1 month ago
This would actually replace decorateCalls
inside of the api base decoration.
@TarikGul Is there a way to manually add runtime API calls for now?
Unable to find hints in the docs, so I tried using the runtime
option during ApiPromise
creation like below. However, it's not even added to ApiPromise.call
(undefined is not an object
), so probably not the way how to do it in the first place. 🤔
import { DefinitionsCall } from "@polkadot/types/types";
import { ApiPromise, WsProvider } from "@polkadot/api";
const wsProvider = new WsProvider(`wss://...`);
export const api = await ApiPromise.create({
provider: wsProvider,
runtime: {
camelCasedPalletNameApi: [
{
version: 1,
methods: {
camelCasedRuntimeFn {
description: "This is my function",
params: [],
type: "Balance",
},
},
},
],
} as DefinitionsCall,
});
const result = await pjsApi.call.camelCasedPalletNameApi.camelCasedRuntimeFn();
console.log({result})
--- update
Never mind got it to work. Seems like it's important to use camel case for the api name key and an underscored runtime call function name.
Found out how to do it here: https://github.com/polkadot-js/api/blob/3b7b44f048ff515579dd233ea6964acec39c0589/packages/types/src/interfaces/system/runtime.ts#L6-L24
All in all looking forward for metadata v15 support. 👍 🚀
this should go in V16
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.
rel: https://github.com/polkadot-js/api/issues/5725
The next step in getting runtimeApis from the metadata is to have them decorated at runtime via the metadata. This can be seen as similar to
decorateExtrinsics
. This should only be available for V15.Once this issue is complete we can then add it to the static typegen.