Closed Joelone closed 6 years ago
@Joelone I check again and I see it is success 👍
Test code:
keyProvider: ['5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'], // WIF string or array of keys..
httpEndpoint: 'http://127.0.0.1:8888',
expireInSeconds: 60
};
const eos = Eos.Localnet(config);
console.log(eos.getBlock());
Result:
[nodemon] starting `node -r dotenv/config -r babel-register src/index.js`
[nodemon] restarting due to changes...
[nodemon] starting `node -r dotenv/config -r babel-register src/index.js`
USAGE
getBlock - Fetch a block from the blockchain.
PARAMETERS
{
"block_num_or_id": "string"
}
RETURNS
{
"previous": "uint32",
"timestamp": "time",
"transaction_merkle_root": "uint32",
"producer": "uint16",
"producer_changes": "map<account_name, account_name>[]",
"producer_signature": "signature",
"cycles": "thread[]",
"id": "fixed_bytes33",
"block_num": "uint32",
"ref_block_prefix": "uint32"
}```
Strange, I still see the same error with your code. Is it because of eosjs only support docker, and I built EOS 3.0 release from source?
app/test.js
Eos = require('../src') //Eos = require('eosjs')
config = {
keyProvider: ['5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'], // WIF string or array of keys..
httpEndpoint: 'http://127.0.0.1:8888',
expireInSeconds: 60
};
const eos = Eos.Localnet(config);
console.log(eos.getBlock());
cleos output
$ cleos get info
{
"server_version": "d9ad8eec",
"head_block_num": 59221,
"last_irreversible_block_num": 59220,
"head_block_id": "0000e755b775186a91e8db5926181c6584b0fcbed3100ca473e4597fac7b6b20",
"head_block_time": "2018-04-10T03:45:11",
"head_block_producer": "eosio"
}
result
$ node app/test.js
/home/joel/eosjs/src/structs.js:117
const staticVariant = baseTypes.static_variant([
^
TypeError: baseTypes.static_variant is not a function
at PublicKeyType (/home/joel/eosjs/src/structs.js:117:35)
at createType (/home/joel/eosjs/node_modules/fcbuffer/lib/types.js:161:14)
at customTypes.(anonymous function) (/home/joel/eosjs/node_modules/fcbuffer/lib/types.js:132:20)
at getTypeOrStruct (/home/joel/eosjs/node_modules/fcbuffer/lib/fcbuffer.js:160:13)
at create (/home/joel/eosjs/node_modules/fcbuffer/lib/fcbuffer.js:198:16)
at module.exports (/home/joel/eosjs/node_modules/fcbuffer/lib/index.js:51:17)
at module.exports (/home/joel/eosjs/src/structs.js:74:58)
at createEos (/home/joel/eosjs/src/index.js:76:50)
at Object.Localnet (/home/joel/eosjs/src/index.js:52:12)
at Object.<anonymous> (/home/joel/eosjs/app/test.js:9:17
@Joelone I am using build on MacOS 😄
@navcsdev I'm using ubuntu 16.04, but I think it shouldn't be matter for node.js
Is eosjs using the correct fcbuffer version like this:
npm ls fcbuffer
eosjs@7.1.5 /home/jcalfee/eosjs/eosjs
└── fcbuffer@2.1.4
My local repo messed up.It works now. Thanks @jcalfee
eosio version: dawn-v3.0.0 (d9ad8ee) eosjs version: 7.1.5 (a148dc8)
Test code:
Error message: