starknet.js
starknet.js copied to clipboard
Better way to parse Uint256 result of `Args` to BN
Currently,
export type Args = { [inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish }; };
The type of Args
does not include a type Uint256 which is a normal JS object with low
and high
properties. How should it be parsed on frontend?
For example,
Example ABI:
{ "inputs": [ { "name": "account", "type": "felt" } ], "name": "balanceOf", "outputs": [ { "name": "balance", "type": "Uint256" } ], "stateMutability": "view", "type": "function" }
The output of balanceOf
call will be of type Args
const result = contract.call(balanceOf, { account: address }) // returns result = { balance: Object }
Here, the type of balance
is neither string
, string[]
or struct
.
Type string | string[] | { type: 'struct'; [k: string]: BigNumberish
is also not compatible with arguement of uint256ToBN()
.
Currently, I am passing result as any
in uint256ToBN
which is not a good way to do this.
@dhruvkelawala hi! Is this issue still relevant?
What is the meaning of low and higt?How should it be parsed on frontend? @ivpavici