Allow struct serialization from array input#806
Allow struct serialization from array input#806conr2d wants to merge 2 commits intoEOSIO:developfrom
Conversation
|
|
|
@tbfleming Interesting. Can you explain what the intended usage of transaction_extensions is? I can understand there can be a planned way to use transaction_extensions in EOS mainnet in the future, but what about EOSIO-variants, called sister chains? They might utilize transaction_extensions fields not to modify libchain too much, but implement their own special features by parsing transaction_extensions in wasm-side. Even if the emptiness of transaction_extensions is mandatory, this PR still has meaning, because this adopts the exisitng way to serialize struct like |
|
The intended use is to allow future hard forks to upgrade the transaction format. For now, the JSON representation requires either the field be absent or it be an empty array. The binary form requires a single If forks of eosio modify the transaction format, then we can't guarantee any compatibility with versions we maintain. Chances are high they'd conflict. We were once considering supporting array syntax for objects in eosjs. I thought we had implemented that, but I could be remembering wrong. |
|
@tbfleming Thank you. :) |
Change Description
eosio::chain::abi_serializerin 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) anddata(bytes). However, during callingtransact(), it calls/v1/chain/get_required_keysRPC, but in libchain, transaction_extensions is defined bystd::vector<std::pair<uint16_t,vector<char>>>, so get_required_keys will be aborted, because libchain will fail to convert the parameters in json toeosio::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 aseosio::chain::abi_serializerand user experience of cleos. Moreover, user can send a transaction with transaction_extensions by setting them in array like:API Changes
User will be able to pass action parameters by array instead of object.
Documentation Additions
User can pass an array to
transact()of eosjs-api.