Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I pass in Vec arguments to constructor? #517

Closed
HCastano opened this issue Apr 22, 2022 · 2 comments
Closed

How do I pass in Vec arguments to constructor? #517

HCastano opened this issue Apr 22, 2022 · 2 comments
Labels
bug Something isn't working question Further information is requested

Comments

@HCastano
Copy link
Contributor

My ink! constructor has the following signature:

pub fn new(requirement: u32, mut owners: Vec<AccountId>) -> Self

I've been trying to instantiate it but haven't been able to figure out how to pass in
Vec arguments. Some of my attempts include:

ink on  master [$] via 🦀 v1.62.0-nightly
❮ cargo contract instantiate \
       --constructor new \
       --args 1 [5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY] \
       --suri //Alice \
       --manifest-path ./examples/multisig/Cargo.toml
ERROR: Failed to read from [5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY]

Caused by:
    No such file or directory (os error 2)
...
       --args 1 "[5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY]" \
...
ERROR: Failed to read from [5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY]

Caused by:
    No such file or directory (os error 2)
...
       --args 1 \[5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY]\ \
...
ERROR: Failed to read from [5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY]

Caused by:
    No such file or directory (os error 2)
...
       --args 1 \"\[5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\]\" \
...
ERROR: Failed to read from "[5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY]"

Caused by:
    No such file or directory (os error 2)
@HCastano HCastano added bug Something isn't working question Further information is requested labels Apr 22, 2022
@ascjones
Copy link
Collaborator

ascjones commented Apr 25, 2022

I did a related fix in #519, but that is not exactly the issue you are having here.

It now "works on my machine", however I remember that you are using zsh which from cursory research interprets sqaure brackets as an array,

I've installed zsh on my machine, and the following two solutions work for me:

escaping: --args 2 \[5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\] \
quotation marks: --args 2 "[5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty]"

Can you try again with those two and see if it works now?

@cmichi
Copy link
Collaborator

cmichi commented Feb 6, 2024

I just tried both variants in my local zsh and they both worked.

@cmichi cmichi closed this as completed Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants