soroban-cli icon indicating copy to clipboard operation
soroban-cli copied to clipboard

Cannot use Bytes type properly

Open aristidesstaffieri opened this issue 2 years ago • 6 comments
trafficstars

What version are you using?

0.6.0

What did you do?

I have deployed an instance of the token interface on futurenet, and I'm trying to call initialize with this fn sig. The last two args are Bytes that I believe are supposed to be the hex string representation of the value. I am trying the following and am wondering why it wouldn't be able to parse the --symbol arg but had no problem with the --name arg, both are hex strings of the value that I want to pass for name and symbol.

$ soroban contract invoke \
    --id 6885ed6b904a6cead909c99cdc482ffa4a74c181803f678cacbfbe831e9efac6 \
    --secret-key S... \
    --rpc-url http://localhost:8000/soroban/rpc \
    --network-passphrase 'Test SDF Future Network ; October 2022' \
    --fn initialize \
    -- \
    --admin GCGORBD5DB4JDIKVIA536CJE3EWMWZ6KBUBWZWRQM7Y3NHFRCLOKYVAL \
    --decimal 7 \
    --name 467265696768746572205465737420546f6b656e \
    --symbol 465454
error: parsing argument symbol: invalid type: integer `465454`, expected string or map

What did you expect to see?

A successful transaction for initializing this contract

What did you see instead?

cli cannot parse the hex string provided for the bytes arg called symbol, it seems to be fine with the hex string for bytes for the arg called name.

aristidesstaffieri avatar Feb 17 '23 18:02 aristidesstaffieri

Hmm interesting. Does it still happen if you change symbol to symbol_b? We do have a test for bytes. But I'll add one with an arg named symbol.

willemneal avatar Feb 17 '23 20:02 willemneal

Hmm interesting. Does it still happen if you change symbol to symbol_b? We do have a test for bytes. But I'll add one with an arg named symbol.

Not sure I understand, do you mean change the arg name to symbol_b, just to clarify this is the symbol used to identify the token in this instance, not a Symbol type but a Bytes type.

aristidesstaffieri avatar Feb 17 '23 22:02 aristidesstaffieri

Just ran into this on RPCiege day 3, which required sending in a Symbol of which the hash included a certain pattern. I was unable to pass any symbols on the CLI that consisted of just numbers, likely because they were being parsed as integers and then failed a type check later on when invoking the contract's function:

$ soroban contract invoke --id a9f195600907c6204a55831ce0347b03a3409c7194e3c944c604cf7c16f495de --source ... --rpc-url https://rpc-futurenet.fastcheapandoutofcontrol.com:443 --network-passphrase 'Test SDF Future Network ; October 2022' -- game_3 --symbol 123 --_nft_dest ...
error: parsing argument symbol: invalid type: integer `123`, expected string or map

Versions:

soroban 0.8.0 (6bdd01a190e30805955fba11c60eed4aa452387c)
soroban-env 0.0.16 (0c0cae6fa22b751e7fd95d7ce7556ac6d7b7010e)
soroban-env interface version 85899345957
stellar-xdr 0.0.16 (53e1a9cf2335aff29305c72deb6f075e78915dad)
xdr next (2f16687fdf6f4bcfb56805e2035f69997f4b34c4)

bjorn avatar May 31 '23 13:05 bjorn

Did you try the symbol in quotes? "123"?

willemneal avatar Jun 01 '23 11:06 willemneal

Did you try the symbol in quotes? "123"?

Yes, but that didn't make a difference because the shell would strip them. I had not tried the '"123"' variant though.

bjorn avatar Jun 01 '23 16:06 bjorn

This issue is stale because it has been assigned for 30 days with no activity. It will be closed in 30 days unless the stale label is removed, and the assignee is removed or updated.

github-actions[bot] avatar Dec 22 '24 18:12 github-actions[bot]