EOSIO / eosjs-api

Application programming interface to EOS blockchain nodes.
177 stars 93 forks source link

api object ? #17

Closed gaboesquivel closed 6 years ago

gaboesquivel commented 6 years ago

Hi @jcalfee

I'm working on the camel wrapper for eosjs-api (ref https://github.com/EOSIO/eosjs/issues/277) and noticed the following:


const EOSAPI = require('eosjs-api')
const eosApi = new EOSAPI()

Object.keys(eosApi).forEach(key => {
  console.log(`--> ${key} is ${typeof eosApi[key]}`)
})

console.log(eosApi.api)

output

--> getInfo is function
--> getAccount is function
--> getCode is function
--> getAbi is function
--> getRawCodeAndAbi is function
--> abiJsonToBin is function
--> abiBinToJson is function
--> getRequiredKeys is function
--> getBlock is function
--> getBlockHeaderState is function
--> getTableRows is function
--> getCurrencyBalance is function
--> getCurrencyStats is function
--> getProducers is function
--> getProducerSchedule is function
--> getScheduledTransactions is function
--> pushBlock is function
--> pushTransaction is function
--> pushTransactions is function
--> getActions is function
--> getTransaction is function
--> getKeyAccounts is function
--> getControlledAccounts is function
--> createTransaction is function
--> api is object
{ createTransaction: [Function: createTransaction] }

Why is there an api object with a createTransaction function ?

Is that a bug or does it have different utility ?

jcalfee commented 6 years ago

It has different utility .. That is light weight code to create a valid transaction header. It could be moved to eosjs but since it is very light weight and could be useful I included it in eosjs-api.

gaboesquivel commented 6 years ago

thanks.

It's still not clear to me the difference between eosApi.api.createTransaction and esoApi.createTransaction

it's also not included in the API docs https://github.com/EOSIO/eosjs-api/blob/master/docs/api.md I can help with docs now that I'm interacting with the whole eosjs-api API.

I want to understand better your intention here with this two functions with same name.

.. yeah, I haven't read all the code :).

jcalfee commented 6 years ago

I see .. It is a mistake .. I will stop exporting the static version eosApi.api.createTransaction and keep the instance (that is configured): eosApi.createTransaction.

gaboesquivel commented 6 years ago

cool tks

gaboesquivel commented 6 years ago

Here's the wrapper in case someone is interested in this functionality as well. https://github.com/eoscostarica/eosjs-camel-api. It is a WIP for, it needs more testing.