How can I send a transaction with a vector of tuples like Option<Vec<(T::AccountId, u8)>> from frontend (react)? What about None and other types js don't have? Is there any site I can look for?
1 Answer
There are 2 questions here -
None
as found in anOption
Tuple
types
In the JS world you can do the following -
// signature of this extrinsic is value: Option<(T::AccountId, u8)>
// send None through - mapped from null
await api.tx.someWhere.something(null)
// send a Tuple value through
await api.tx.someWhere.something(['1Test...', 5])
So Tuple
values appear is a JS array with the correct number of elements.
To expand this into your signature type posted above, i.e. an Option
of a Vec
of Tuples
-
// signature of this extrinsic is value: Option<Vec<(T::AccountId, u8)>>
// send None through - mapped from null
await api.tx.someWhere.something(null)
// send a Vec<Tuple> value through (2 values)
await api.tx.someWhere.something([['1Test...', 5], ['1Test...', 6]])
The same would apply to eg. .query.*
if you need to specify a Tuple
.