EOSIO / eosjs

General purpose library for the EOSIO blockchain.
http://eosio.github.io/eosjs
MIT License
1.43k stars 463 forks source link

Support case: action.name != action.type #297

Closed arc0035 closed 6 years ago

arc0035 commented 6 years ago

Hi,

I met some problem when serializing aciton.data in the case of action.name != action.type.

Suppose we have an abi def who has an action def meeting the condition action.name != action.type:

"actions": [{ "name": "recharge", "type": "dorecharge", "ricardian_contract": "" }]

In the abi, we also have a type named "recharge" whose structure is totally different from that of "dorecharge":

"name": "recharge", "base": "", "fields": [ //lots of field definition ..... ]

Now we have a action "recharge" whose data structure meets "dorecharge" and we put this action data to fcbuffer. In structs.js/actionDataFromObject, the structLookup will take "recharge" as param :

var fields = _ref5.fields, object = _ref5.object, result = _ref5.result; var data = object.data, name = object.name;

  var ser = (name || '') == '' ? fields.data : structLookup(name, object.account);

Then the ser will process action data(based on "dorecharge") based on a totally different structure ("recharge")

I believe that when an action arrives at fc, fc should choose struct based on action.type instead of action.name. The code should search for the abi to fetch the action type per name , then pass the type to structLookup.

jcalfee commented 6 years ago

Should be fixed in: https://github.com/EOSIO/eosjs/issues/308

jcalfee commented 6 years ago

fixed in eosjs@16.0.3