-
Notifications
You must be signed in to change notification settings - Fork 120
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
Failure for instantiate
and call
on String
argument
#780
Comments
The reason behind the bug is strange behaviour of The tests are also somehow "misleading" they assume that strings are provided in r#""Foo""# format? |
@cmichi you can actually parse a correct value without modifying any code: |
So there are 3 possible solutions to this problem:
|
@SkymanOne Sidenote: Shell substitution removes the quotes Ideally we would auto-detect that the argument for the contract at this position is a |
It was late night, apologies for confusion 😁 Auto-detecting the contract args is actually partially related to #750 and is more involved that it seems. My speculated guess would that we need to parse the metadata during the parsing stage and accept/reject args based on the specified grammar (e.g. string arg is indeed in I have to play around and see how to approach this the best. |
The original idea was to allow input in Rust like object initializer syntax e.g. For passing strings from the command line without escaped quotation marks...I don't know what the solution will be. I do think though that some delimiters are required since strings can also contain spaces. I think in order to stick with the Rust like syntax, we should continue to interpret e.g |
While it makes sense. We might introduce an additional flag |
I'm not sure about this: what benefits would this give over the existing solution? To solve for the problem of avoiding having to escape double quotation marks, we could consider allowing e.g. single quotation marks e.g. Then you can always enhance the error message Dealing with quotation marks on a CLI is tricky and also needs testing across OSs. |
It would be possible, at the moment my guess is that So you could allow it that a "unit tuple" (and any other scon literal) can be cooerced into a string where a String is expected. Although the parser is only valid if it is a valid SCON literal (falling back to a valid Rust identifier) so would not parse for other strings. Also it does slightly reduce the type checking, imagine if you have So we are looking at a tradeoff between ease of use "I don't want to have to specify that I am supplying a String, escaping, argghh!", and strictness "If it expects a string as an argument, you must supply a delimited string, sorry". If javascript has taught us anything, it is better to be strict? |
Just experienced this. As a user, it would have been nice to be told to explicitly wrap my string between escaped quotes |
Minimal reproducer contract
Execute
cargo contract new bug
and then replacelib.rs
with:Provoke bug
Run
substrate-contracts-node
and execute:Same thing happens for
cargo contract call
.The text was updated successfully, but these errors were encountered: