use-ink / contracts-ui

Web application for deploying wasm smart contracts on Substrate chains that include the FRAME contracts pallet
https://contracts-ui.substrate.io/
GNU General Public License v3.0
62 stars 48 forks source link

Polkadot.js fails to decode dry run error with `contracts-node v0.12.0` #282

Closed statictype closed 2 years ago

statictype commented 2 years ago

Polkadot.js fails to decode dry run error with contracts-node v0.12.0

To Reproduce

  1. run the latest contracts-node in --dev mode (v0.12.0)
  2. try to deploy a multisig
  3. predicted outcome panel shows no values and I can move to the next step even though the dry run fails.
  4. there is a console error
    InstantiateContext.tsx:79 Error: createType(ContractInstantiateResult):: Struct: failed on result: {"_enum":{"Ok":"InstantiateReturnValueOk","Err":"DispatchError"}}:: Enum(Err):: Enum(Module):: Struct: failed on error: u8:: u8: Input too large. Found input with 28 bits, expected 8
    at createTypeUnsafe (type.js:56:1)
    at TypeRegistry.createTypeUnsafe (registry.js:288:28)
    at RpcCore._formatOutput (bundle.js:355:1)
    at RpcCore._formatResult (bundle.js:184:1)
    at callWithRegistry (bundle.js:209:1)

Expected behavior the Predicted Outcome panel shows a ContractTrapped error because of the requirement being too low. Next button is disabled.

Additional context Dry run works fine with contracts-node v0.11.0

athei commented 2 years ago

I think this is because the DispatchError type was changed by this PR.

The Module variant was changed. The error field is no longer an index (u8) but a 4 byte array that encodes the error using SCALE instead of relying on a lookup.

/// Old type
Module {
    index: u8,
    error: u8,
    message: Option<&'static str>,
}

/// New type
Module {
    index: u8,
    error: [u8; 4],
    message: Option<&'static str>,
}