eosjs
eosjs copied to clipboard
Allow struct serialization from array input
Change Description
eosio::chain::abi_serializer
in libchain allows serialization of struct from array, but eosjs only serializes object to struct.
When sending a transaction with transaction_extensions, the abi of transaction in eosjs defines transaction_extensions as extension[]
, and extension is a struct with two fields, type
(uint16) and data
(bytes). However, during calling transact()
, it calls /v1/chain/get_required_keys
RPC, but in libchain, transaction_extensions is defined by std::vector<std::pair<uint16_t,vector<char>>>
, so get_required_keys will be aborted, because libchain will fail to convert the parameters in json to eosio::chain::transaction
.
At this time, there is no way to send a transaction with transaction extensions by transact()
of eosjs-api. This PR will provide a way to serialize structs from array in the same manner as eosio::chain::abi_serializer
and user experience of cleos. Moreover, user can send a transaction with transaction_extensions by setting them in array like:
const tx = {
actions: [{
...
}],
transaction_extensions: [[1, [1]], [2, [1, 2, 3, 4]]]
};
API Changes
- [x] API Changes
User will be able to pass action parameters by array instead of object.
Documentation Additions
- [x] Documentation Additions
User can pass an array to transact()
of eosjs-api.