polkadot-js / apps

Basic Polkadot/Substrate UI for interacting with a Polkadot and Substrate node. This is the main user-facing application, allowing access to all features available on Substrate chains.
https://dotapps.io
Apache License 2.0
1.75k stars 1.54k forks source link

Types not fetched until going to Settings->Metadata #6562

Open sander2 opened 2 years ago

sander2 commented 2 years ago

When I try to run a javascript snippet, I get the error shown below. After visiting the the settings -> metadata page and going back to the javascript snipper, it suddenly works. I haven't looked at the code, but it's as if the types are not fetched until the metadata page is visited.

_checkError@https://polkadot.js.org/apps/polkadot.01.4c2752f8.js:1:112668
decodeResponse@https://polkadot.js.org/apps/polkadot.01.4c2752f8.js:1:112287
value@https://polkadot.js.org/apps/polkadot.01.4c2752f8.js:1:116363
value@https://polkadot.js.org/apps/polkadot.01.4c2752f8.js:1:116176
jacogr commented 2 years ago

Which snippet?

sander2 commented 2 years ago

This custom snippet:

const tx = api.tx.xcmPallet.reserveTransferAssets;

const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';

const dst = { X1: { ParaChain: '2000' }, parents: 0 };
const acc = { X1: {
    AccountId32: { id: ALICE, network: 'Any' }
} };
const ass = [{ ConcreteFungible: { amount: '1000000000000' } }]

const call = tx(
    { V0: dst },
    { V0: acc },
    { V0: ass },
    0
);

await call.signAndSend(ALICE, ({ events = [], status }) => {
  if (status.isInBlock) {
    console.log('Successful transfer of ' + randomAmount + ' with hash ' + status.asInBlock.toHex());
  } else {
    console.log('Status of transfer: ' + status.type);
  }

  events.forEach(({ phase, event: { data, method, section } }) => {
    console.log(phase.toString() + ' : ' + section + '.' + method + ' ' + data.toString());
  });
});
jacogr commented 2 years ago

That is weird. None of those are extended types. Probably something in the api.clone() method used in the JS console.

sander2 commented 2 years ago

Something similar is happening when I try to distpatch a sudo call (xcmPallet::forceDefaultXcmVersion), I get the error below, until I go to Settings->Metadata.

2021-11-17 12:44:47        RPC-CORE: submitAndWatchExtrinsic(extrinsic: Extrinsic): ExtrinsicStatus:: 1002: Verification Error: Runtime error: Execution failed: ApiError(FailedToConvertParameter { function: "validate_transaction", parameter: "tx", error: Error { cause: None, desc: "Could not decode `MultiAddress`, variant doesn't exist" } }): RuntimeApi, Execution failed: ApiError, FailedToConvertParameter { function: \"validate_transaction\", parameter: \"tx\", error: Error { cause: None, desc: \"Could not decode `MultiAddress`, variant doesn't exist\" } }
polkadot-js-bot commented 2 years ago

This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.