Skip to content

Failure for instantiate and call on String argument #780

@cmichi

Description

@cmichi

Minimal reproducer contract

Execute cargo contract new bug and then replace lib.rs with:

#![cfg_attr(not(feature = "std"), no_std)]

#[ink::contract]
mod bug {
    use ink::prelude::string::String;

    #[ink(storage)]
    pub struct Bug {}

    impl Bug {
        #[ink(constructor)]
        pub fn new(val: String) -> Self {
            Self {}
        }

        #[ink(message)]
        pub fn get(&self) -> () {
            ()
        }
    }
}

Provoke bug

Run substrate-contracts-node and execute:

$ cargo contract instantiate --manifest-path=./Cargo.toml --suri //Alice --args Foo
ERROR: Expected a String value
$ RUST_LOG=trace cargo contract instantiate --manifest-path=./Cargo.toml --suri //Alice --args Foo
2022-10-13T08:55:39.060960Z DEBUG cargo_contract::crate_metadata: Fetching cargo metadata for ./Cargo.toml
2022-10-13T08:55:39.104122Z DEBUG contract_transcode::transcoder: No matching type in registry for path PathKey(["ink_primitives", "types", "AccountId"]).
2022-10-13T08:55:39.104143Z DEBUG contract_transcode::transcoder: No matching type in registry for path PathKey(["ink_primitives", "types", "AccountId"]).
2022-10-13T08:55:39.104148Z DEBUG contract_transcode::transcoder: No matching type in registry for path PathKey(["ink_primitives", "types", "Hash"]).
2022-10-13T08:55:39.104160Z DEBUG contract_transcode::encode: Encoding value `Tuple(Tuple { ident: Some("Foo"), values: [] })` with type id `0` and definition `Primitive(Str)`
ERROR: Expected a String value

Same thing happens for cargo contract call.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions