EOSIO / eosjs

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

Base field in action abi type is ignored #18

Closed sim31 closed 6 years ago

sim31 commented 6 years ago

You can use inheritance in EOS abi, like so:

 structs: [
    {
      "name": "action1",
      "base": "",
      "fields": {
        "field1": "string",
        "field2": "string"
      }
    },{
       "name": "action2",
       "base": "action1",
       "fields": {
         "field3": "account_name",
       }
   ]
   "actions": [
    "action_name": "action1",
      "type": "action1"
    },{
      "action_name": "action2",
      "type": "action2"
    }
   ]

I would expect to be able to use contract with this abi like this:

eos.contract('contr').then( c => { c.action2("1", "2", "3" });

But then I get this error:

Uncaught TypeError: action2 is expecting 1 parameters but 3 where provided
jcalfee commented 6 years ago

Please test the upgrade with npm i eosjs@6.1.1 or npm i eosjs@prerelease .. I have not tagged it as latest yet..

sim31 commented 6 years ago

Now it complains that it's expecting 2 parameters instead of 3 (before it was expecting 1). Also shouldn't calling function with no parameters print usage information? I get unknown type error when I try to do that with contract actions.

jcalfee commented 6 years ago

Version eosjs@6.1.4 released..

NewETown commented 6 years ago

@jcalfee not sure if this is related, every time I try to access the "currency" contract I'm seeing this (previous 6.0.x did not give me this error)

Unhandled promise rejection (rejection id: 1): Error: [ "Expecting string in transfer.fields.0", "Expecting string in transfer.fields.1", "Expecting string in transfer.fields.2", "Expecting string in transfer.fields.3", "Expecting string in issue.fields.0", "Expecting string in issue.fields.1", "Expecting string in account.fields.0", "Expecting string in account.fields.1", "Expecting string in currency_stats.fields.0", "Expecting string in currency_stats.fields.1", "Missing [object Object] in transfer.fields.0", "Missing [object Object] in transfer.fields.1", "Missing [object Object] in transfer.fields.2", "Missing [object Object] in transfer.fields.3", "Missing [object Object] in issue.fields.0", "Missing [object Object] in issue.fields.1", "Missing [object Object] in account.fields.0", "Missing [object Object] in account.fields.1", "Missing [object Object] in currency_stats.fields.0", "Missing [object Object] in currency_stats.fields.1" ]

kesar commented 6 years ago

I am having the same issue than the previous post in my contracts with string type

jcalfee commented 6 years ago

Please try with the latest eosjs release and eosd dawn2.. I just tested the currency contract and it is working now.

NewETown commented 6 years ago

@jcalfee Is this only for 2.x? I've been running on 3 for a while, happy to test a future branch if you have one

jcalfee commented 6 years ago

It is for 2.x only .. I'll update https://github.com/EOSIO/eosjs/issues/25 as I get 3.x working..

jcalfee commented 6 years ago

Fixed in dawn3 .. it is being tested now, for now here are the directions:

https://github.com/EOSIO/eosjs/issues/25#issuecomment-371855546

Also be sure to view the README.md (for changes in syntax) from the dawn3 branch..