use-ink/cargo-contract

cargo-contract doesn't support String arguments

Closed this issue · 1 comments

Describe the bug
cargo-contract (both CLI and lib) does not support passing String arguments to constructors/messages.

To Reproduce
With a contract:

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

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

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

    impl Repro {
        #[ink(constructor)]
        pub fn new(string: String) -> Self { Self {} }
        #[ink(message)]
        pub fn msg(&self) {}
    }
}

run

cargo contract call --contract 5E3YsTMiPcxDuVepQ6Z3Bf23QAZr1wDzdGVS6W5Mkgik8LFG --message new --args argument --skip-confirm --suri //Alice

The result is:

ERROR: Expected a String value

For reproduction you don't need a running chain. Error happens at the phase of encoding arguments for an extrinsic.

Expected behavior
Should support string arguments.

Environment (please complete the following information):

  • OS: Ubuntu 22.04
  • cargo-contract version: cargo-contract-contract 3.2.0-unknown-x86_64-unknown-linux-gnu
  • ink! version: 4.3.0
  • substrate-contracts-node version: not needed

Additional context
AFAIK the problem is that scon encoding maps any string value into Value::Literal. Value::String is used only for field/type names.

duplicates #780