sui icon indicating copy to clipboard operation
sui copied to clipboard

Sui CLI able to BCS-serialize arguments?

Open PaulFidika opened this issue 2 years ago • 1 comments
trafficstars

When you do something like:

sui client call --package 0xc58218250eec94ee3241ac999dd564a6e267f107 --module schema --function define --args "[ \"name\", \"description\", \"image\", \"power_level\" ]" --gas-budget 1000

the arguments always end up getting encoded as vector<vector<u8>> (or vector<vector<String>> if the Sui module asks for it), but never vector<u8>. It might be useful to allow arguments to be bcs-encoded by the Sui CLI; right now this sort of transformation can only be done by the BCS Typescript library, I believe. That way you could encode an array of heterogenous types into a homogeneous array of bcs-encoded bytes.

I remember someone mentioning some new CLI syntax like [ "1000"u64, "1011"string ] (basically annotating your arguments with a type so that the sui-cli knows what type it should use for serialization), or something like that. Does that exist already or am I just imagining things?

PaulFidika avatar Jan 26 '23 20:01 PaulFidika

I'd really like to be able to serialize heterogeneous arrays of items right from within the CLI, something like this:

[ "15"u8, "256"u16, "hello there everyone"string, "199999999999"u256 ]

this would produce a vector<vector> encoded like:

[ [15], [0, 1], [...], [...] ]

this would be very useful and make CLI args much more flexible.

PaulFidika avatar Jan 28 '23 21:01 PaulFidika

Related to #13641

stefan-mysten avatar Nov 13 '23 14:11 stefan-mysten