Skip to content

chore: accept strings as arguments from command line without having to use Some() #319

@brunopgalvao

Description

@brunopgalvao

When instantiating a contract that expects String's as arguments, Pop CLI fails:

For example, instantiating the PSP22 contract:

#[ink(constructor)]
pub fn new(
    supply: u128,
    name: Option<String>,
    symbol: Option<String>,
    decimals: u8,
) -> Self {
    let (data, events) = PSP22Data::new(supply, Self::env().caller()); // (2)
    let contract = Self {
        data,
        name,
        symbol,
        decimals,
    };
    contract.emit_events(events);
    contract
}
pop up contract --constructor new --args 10000000, "AWESOME", "AWE", 10

The following error is emitted:

┌   Pop CLI : Deploy a smart contract
│
■  An error occurred instantiating the contract: No variant 'AWESOME' found

For it to work, I need to wrap the strings in Some() with '' around so that zsh does not complain:

pop up contract --constructor new --args 10000000, 'Some("AWESOME")', 'Some("AWE")', 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions