1

if the type for extrinsic verification pub struct ChargeTransactionPayment<T: Config> has been changed on a chain, how do we update the polkadot.js API to use the new types? Suppose the type has been changed to

pub struct ChargeTransactionPayment<T: Config> {
    pub scheme: u8,
    pub asset_id: Option<ChargeAssetIdOf<T>>,
    pub tip: BalanceOf<T>,
}

How can I let the polkdot.js api know about this update and set them before executing an extrinsic? I tried adding it to the registry and calling the extrinsic as shown below. but it give me the error "createType(ChargeAssetTxPayment):: DoNotConstruct: Cannot construct unknown type ChargeAssetTxPayment"

api.registry.createType("ChargeAssetTxPayment", {
                    extrinsic: {
                        scheme:'2',
                        asset_id: 4,
                        tip: 10
                    },
                    payload: {}
                })

I am trying to do something similar to what statemint did, is it possible to set these custom parameters using the api directly?

1 Answer 1

2

Yes this is absolutely possible to inject types into polkadot-js api. When instantiating an ApiPromise, you may also pass in one of the following:

{
    types,
    typesAlias
    typesBundle,
    typesChain,
    typesSpec
}

Here is a quick example of the parameters being passed in.

These Types are present here for more information. It's good to search through each type the fields are set to, in order to understand which field best fits your situation.

I created a tool a while back to help users understand and how to generate a typesBundle specifically using polkadot-js/apps-config for specific chains. This tool can be found here: https://github.com/paritytech/generate-type-bundle

Additionally, if there has been a type updated in substrate or polkadot and it hasn't been properly mirrored in polkadot-js, the best approach is to file an issue.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .