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

Error decoding type #516

Closed PierreOssun closed 7 months ago

PierreOssun commented 1 year ago

Describe the bug When I want to interact with my contract (query dry-run or message functions) I got Decoding Error. In the console I can see it come from an err in createType() PS: It works fine in polakdotjsUI > Contracts

To Reproduce Steps to reproduce the behavior:

  1. Go to contracts UI
  2. Click on Shibuya or run master branch of Astar)
  3. Deploy the contract
  4. See error

Expected behavior No decoding error

Screenshots Screenshot from 2023-09-12 15-37-42

Desktop (please complete the following information):

Environment (please complete the following information where it makes sense): See contract metadata Contract code: https://github.com/AstarNetwork/ink-xvm-sdk/tree/feat/upgrade/ink/contracts/erc20

Additional context Contract metadata:

{
  "source": {
    "hash": "0x55603ca7a536a982d38d4440045dbfc7fd1b017e3e5bd7976e7d3140c9d1e25c",
    "language": "ink! 4.3.0",
    "compiler": "rustc 1.69.0",
    "build_info": {
      "build_mode": "Debug",
      "cargo_contract_version": "2.1.0",
      "rust_toolchain": "stable-x86_64-unknown-linux-gnu",
      "wasm_opt_settings": {
        "keep_debug_symbols": false,
        "optimization_passes": "Z"
      }
    }
  },
  "contract": {
    "name": "xvm-sdk-erc20",
    "version": "0.1.0",
    "authors": [
      "Astar Network"
    ]
  },
  "spec": {
    "constructors": [
      {
        "args": [
          {
            "label": "evm_address",
            "type": {
              "displayName": [],
              "type": 1
            }
          }
        ],
        "default": false,
        "docs": [
          "Create new ERC20 abstraction from given contract address."
        ],
        "label": "new",
        "payable": false,
        "returnType": {
          "displayName": [
            "ink_primitives",
            "ConstructorResult"
          ],
          "type": 2
        },
        "selector": "0x9bae9d5e"
      }
    ],
    "docs": [
      " The EVM ERC20 delegation contract."
    ],
    "environment": {
      "accountId": {
        "displayName": [
          "AccountId"
        ],
        "type": 9
      },
      "balance": {
        "displayName": [
          "Balance"
        ],
        "type": 6
      },
      "blockNumber": {
        "displayName": [
          "BlockNumber"
        ],
        "type": 13
      },
      "chainExtension": {
        "displayName": [
          "ChainExtension"
        ],
        "type": 14
      },
      "hash": {
        "displayName": [
          "Hash"
        ],
        "type": 11
      },
      "maxEventTopics": 4,
      "timestamp": {
        "displayName": [
          "Timestamp"
        ],
        "type": 12
      }
    },
    "events": [],
    "lang_error": {
      "displayName": [
        "ink",
        "LangError"
      ],
      "type": 4
    },
    "messages": [
      {
        "args": [],
        "default": false,
        "docs": [
          " Get `totalSupply` from an ERC20 contract."
        ],
        "label": "total_supply",
        "mutates": false,
        "payable": false,
        "returnType": {
          "displayName": [
            "ink",
            "MessageResult"
          ],
          "type": 5
        },
        "selector": "0xdb6375a8"
      },
      {
        "args": [
          {
            "label": "to",
            "type": {
              "displayName": [],
              "type": 1
            }
          },
          {
            "label": "value",
            "type": {
              "displayName": [
                "u128"
              ],
              "type": 6
            }
          }
        ],
        "default": false,
        "docs": [
          " Send `approve` call to ERC20 contract."
        ],
        "label": "approve",
        "mutates": true,
        "payable": false,
        "returnType": {
          "displayName": [
            "ink",
            "MessageResult"
          ],
          "type": 7
        },
        "selector": "0x681266a0"
      },
      {
        "args": [
          {
            "label": "to",
            "type": {
              "displayName": [],
              "type": 1
            }
          },
          {
            "label": "value",
            "type": {
              "displayName": [
                "u128"
              ],
              "type": 6
            }
          }
        ],
        "default": false,
        "docs": [
          " Send `transfer` call to ERC20 contract."
        ],
        "label": "transfer",
        "mutates": true,
        "payable": false,
        "returnType": {
          "displayName": [
            "ink",
            "MessageResult"
          ],
          "type": 7
        },
        "selector": "0x84a15da1"
      },
      {
        "args": [
          {
            "label": "from",
            "type": {
              "displayName": [],
              "type": 1
            }
          },
          {
            "label": "to",
            "type": {
              "displayName": [],
              "type": 1
            }
          },
          {
            "label": "value",
            "type": {
              "displayName": [
                "u128"
              ],
              "type": 6
            }
          }
        ],
        "default": false,
        "docs": [
          " Send `transfer_from` call to ERC20 contract."
        ],
        "label": "transfer_from",
        "mutates": true,
        "payable": false,
        "returnType": {
          "displayName": [
            "ink",
            "MessageResult"
          ],
          "type": 7
        },
        "selector": "0x0b396f18"
      }
    ]
  },
  "storage": {
    "root": {
      "layout": {
        "struct": {
          "fields": [
            {
              "layout": {
                "array": {
                  "layout": {
                    "leaf": {
                      "key": "0x00000000",
                      "ty": 0
                    }
                  },
                  "len": 20,
                  "offset": "0x00000000"
                }
              },
              "name": "evm_address"
            }
          ],
          "name": "Erc20"
        }
      },
      "root_key": "0x00000000"
    }
  },
  "types": [
    {
      "id": 0,
      "type": {
        "def": {
          "primitive": "u8"
        }
      }
    },
    {
      "id": 1,
      "type": {
        "def": {
          "array": {
            "len": 20,
            "type": 0
          }
        }
      }
    },
    {
      "id": 2,
      "type": {
        "def": {
          "variant": {
            "variants": [
              {
                "fields": [
                  {
                    "type": 3
                  }
                ],
                "index": 0,
                "name": "Ok"
              },
              {
                "fields": [
                  {
                    "type": 4
                  }
                ],
                "index": 1,
                "name": "Err"
              }
            ]
          }
        },
        "params": [
          {
            "name": "T",
            "type": 3
          },
          {
            "name": "E",
            "type": 4
          }
        ],
        "path": [
          "Result"
        ]
      }
    },
    {
      "id": 3,
      "type": {
        "def": {
          "tuple": []
        }
      }
    },
    {
      "id": 4,
      "type": {
        "def": {
          "variant": {
            "variants": [
              {
                "index": 1,
                "name": "CouldNotReadInput"
              }
            ]
          }
        },
        "path": [
          "ink_primitives",
          "LangError"
        ]
      }
    },
    {
      "id": 5,
      "type": {
        "def": {
          "variant": {
            "variants": [
              {
                "fields": [
                  {
                    "type": 6
                  }
                ],
                "index": 0,
                "name": "Ok"
              },
              {
                "fields": [
                  {
                    "type": 4
                  }
                ],
                "index": 1,
                "name": "Err"
              }
            ]
          }
        },
        "params": [
          {
            "name": "T",
            "type": 6
          },
          {
            "name": "E",
            "type": 4
          }
        ],
        "path": [
          "Result"
        ]
      }
    },
    {
      "id": 6,
      "type": {
        "def": {
          "primitive": "u128"
        }
      }
    },
    {
      "id": 7,
      "type": {
        "def": {
          "variant": {
            "variants": [
              {
                "fields": [
                  {
                    "type": 8
                  }
                ],
                "index": 0,
                "name": "Ok"
              },
              {
                "fields": [
                  {
                    "type": 4
                  }
                ],
                "index": 1,
                "name": "Err"
              }
            ]
          }
        },
        "params": [
          {
            "name": "T",
            "type": 8
          },
          {
            "name": "E",
            "type": 4
          }
        ],
        "path": [
          "Result"
        ]
      }
    },
    {
      "id": 8,
      "type": {
        "def": {
          "primitive": "bool"
        }
      }
    },
    {
      "id": 9,
      "type": {
        "def": {
          "composite": {
            "fields": [
              {
                "type": 10,
                "typeName": "[u8; 32]"
              }
            ]
          }
        },
        "path": [
          "ink_primitives",
          "types",
          "AccountId"
        ]
      }
    },
    {
      "id": 10,
      "type": {
        "def": {
          "array": {
            "len": 32,
            "type": 0
          }
        }
      }
    },
    {
      "id": 11,
      "type": {
        "def": {
          "composite": {
            "fields": [
              {
                "type": 10,
                "typeName": "[u8; 32]"
              }
            ]
          }
        },
        "path": [
          "ink_primitives",
          "types",
          "Hash"
        ]
      }
    },
    {
      "id": 12,
      "type": {
        "def": {
          "primitive": "u64"
        }
      }
    },
    {
      "id": 13,
      "type": {
        "def": {
          "primitive": "u32"
        }
      }
    },
    {
      "id": 14,
      "type": {
        "def": {
          "variant": {}
        },
        "path": [
          "xvm_environment",
          "XvmExtension"
        ]
      }
    }
  ],
  "version": "4"
}
statictype commented 1 year ago

i am unable to build your contract due to several errors. could you please provide a compiled contract? are you able to use it in polkadot js apps?

peetzweg commented 10 months ago

Was able to reproduce this. Quite interesting. Not sure what might be going wrong here.

Screenshot 2023-11-20 at 18 05 23

PS: It works fine in polakdotjsUI > Contracts

@PierreOssun Is this still the case for you? I get the exact same error response in pjs contracts ui. However, I only tested totalSupply().

Screenshot 2023-11-20 at 18 03 57

peetzweg commented 7 months ago

Looked into it today. Contract is not available and all other contracts I've tried work fine. Same behaviour on pjs apps and contracts ui. Feel free to open another issue and provide the contract again.