#u64 from the CLI?

22 messages · Page 1 of 1 (latest)

upper raptor
#

It seems that passing u64's is not possible with the CLI:

error: parsing argument {"object":{"vec":[{"u64":1800}]}}: parse error: unknown variant `u64`, expected one of `u63`, `u32`, `i32`, `static`, `object`, `symbol`, `bitset`, `status`

And using u63 will cause the VM to trap since it received an invalid type

ebon cargo
#

Maybe trying using U64 -> SCV_OBJECT ?

#

{"object":{"u64":0}}

#

{"object":{"vec":[{"object":{"u64": 1800}}]} ??

upper raptor
ebon cargo
#

so they are, actually different types 🙂

#

cc @dim vessel

dim vessel
#

Yes that's right when rendered in the JSON form the u64 type is inside an object because it is not a primitive type in the host types but rather a handle to a value stored on the host side.

#

However, I would have thought [0,1,2,...] would work fine for Vec<u64> because for some types the CLI will coerce simpler string values.

ebon cargo
queen forum
#

hence the warning atm lol

dim vessel
#

The u63 type is only usable with i64 parameters. That might be what you're seeing if you try and use it with a u64 you'll see an error.

ebon cargo
#

@dim vessel maybe I'm going into the rabbit hole more than I should but just what is a MeteredBigInt in the host?

#

https://github.com/stellar/rs-soroban-env/blob/main/soroban-env-host/src/host.rs#L663

ScObject::BigInt(sbi) => {
                let bi = match sbi {
                    ScBigInt::Zero => MeteredBigInt::new(self.0.budget.clone())?,
                    ScBigInt::Positive(bytes) => MeteredBigInt::from_bytes_be(
                        self.0.budget.clone(),
                        Sign::Plus,
                        bytes.as_ref(),
                    )?,
                    ScBigInt::Negative(bytes) => MeteredBigInt::from_bytes_be(
                        self.0.budget.clone(),
                        Sign::Minus,
                        bytes.as_ref(),
                    )?,
                };
dim vessel
ebon cargo
#

Just understand as much as I can about Soroban 🙂 I honestly just like getting to know as much as I can, it sure helps a lot down the road (specially when debugging)