Closed nsjames closed 6 years ago
Actually, this is happening with all transactions. Non transaction methods seem to work though ( getBlock, getInfo, etc )
A few things I noticed after trying to debug the issue.
I cloned the latest eosjs and wrote an integration test within the repository using the same code from the readme and it works fine within mocha. I then wrote a test within the the repo that I'm working on with the exact same procedure and it again works fine.
It seems to only be a problem when trying to use eosjs from within the browser itself.
One of the projects this is happening on is here https://github.com/EOSEssentials/Scatter-Demos
Here's a full console error log using {debug:true}
and trying to do a transfer
apigen.js:91 api > http://192.168.56.101:8888/v1/chain/get_info {}
(anonymous) @ apigen.js:91
createTransaction @ exported-helpers.js:48
api.(anonymous function) @ apigen.js:38
transaction @ write-api.js:496
(anonymous) @ write-api.js:179
(anonymous) @ write-api.js:320
(anonymous) @ GettingStarted.vue:251
Promise resolved (async)
createAccount @ GettingStarted.vue:236
boundFn @ vue.js:197
(anonymous) @ GettingStarted.vue:226
setTimeout (async)
generateAccount @ GettingStarted.vue:226
boundFn @ vue.js:196
invoker @ vue.js:2006
fn._withTask.fn._withTask @ vue.js:1804
apigen.js:106 api < {server_version: "0fb60ac1", head_block_num: 72032, last_irreversible_block_num: 72016, head_block_id: "00011960a03716f0c94f7168110471b960b81af4bab125b772c50597fe12e51f", head_block_time: "2018-02-11T20:19:06", …}
(anonymous) @ apigen.js:106
Promise resolved (async)
(anonymous) @ apigen.js:104
createTransaction @ exported-helpers.js:48
api.(anonymous function) @ apigen.js:38
transaction @ write-api.js:496
(anonymous) @ write-api.js:179
(anonymous) @ write-api.js:320
(anonymous) @ GettingStarted.vue:251
Promise resolved (async)
createAccount @ GettingStarted.vue:236
boundFn @ vue.js:197
(anonymous) @ GettingStarted.vue:226
setTimeout (async)
generateAccount @ GettingStarted.vue:226
boundFn @ vue.js:196
invoker @ vue.js:2006
fn._withTask.fn._withTask @ vue.js:1804
apigen.js:91 api > http://192.168.56.101:8888/v1/chain/get_block {"block_num_or_id":72029}
(anonymous) @ apigen.js:91
(anonymous) @ exported-helpers.js:54
(anonymous) @ exported-helpers.js:75
callback @ process-args.js:70
callback @ apigen.js:85
(anonymous) @ apigen.js:109
Promise resolved (async)
(anonymous) @ apigen.js:104
createTransaction @ exported-helpers.js:48
api.(anonymous function) @ apigen.js:38
transaction @ write-api.js:496
(anonymous) @ write-api.js:179
(anonymous) @ write-api.js:320
(anonymous) @ GettingStarted.vue:251
Promise resolved (async)
createAccount @ GettingStarted.vue:236
boundFn @ vue.js:197
(anonymous) @ GettingStarted.vue:226
setTimeout (async)
generateAccount @ GettingStarted.vue:226
boundFn @ vue.js:196
invoker @ vue.js:2006
fn._withTask.fn._withTask @ vue.js:1804
apigen.js:106 api < {previous: "0001195cd7e8a056caa5ea23c3e77c471251e56e2ed25a736ad214bd0948313b", timestamp: "2018-02-11T20:19:03", transaction_merkle_root: "0000000000000000000000000000000000000000000000000000000000000000", producer: "initb", producer_changes: Array(0), …}
(anonymous) @ apigen.js:106
Promise resolved (async)
(anonymous) @ apigen.js:104
(anonymous) @ exported-helpers.js:54
(anonymous) @ exported-helpers.js:75
callback @ process-args.js:70
callback @ apigen.js:85
(anonymous) @ apigen.js:109
Promise resolved (async)
(anonymous) @ apigen.js:104
createTransaction @ exported-helpers.js:48
api.(anonymous function) @ apigen.js:38
transaction @ write-api.js:496
(anonymous) @ write-api.js:179
(anonymous) @ write-api.js:320
(anonymous) @ GettingStarted.vue:251
Promise resolved (async)
createAccount @ GettingStarted.vue:236
boundFn @ vue.js:197
(anonymous) @ GettingStarted.vue:226
setTimeout (async)
generateAccount @ GettingStarted.vue:226
boundFn @ vue.js:196
invoker @ vue.js:2006
fn._withTask.fn._withTask @ vue.js:1804
types.js:282 0x2 (vector.appendByteBuffer length) (2) ["currency", "inita"]0: "currency"1: "inita"length: 2__proto__: Array(0)
types.js:282 0x0 (vector.appendByteBuffer length) []length: 0__proto__: Array(0)
types.js:282 0x1 (vector.appendByteBuffer length) [{…}]0: {code: "eos", type: "transfer", authorization: Array(1), data: {…}}length: 1__proto__: Array(0)
types.js:282 0x1 (vector.appendByteBuffer length) [{…}]0: {account: "inita", permission: "active"}length: 1__proto__: Array(0)
struct.js:79 Error reading transaction.ref_block_num in data:
fromByteBuffer @ struct.js:79
fromBuffer @ fcbuffer.js:276
(anonymous) @ write-api.js:520
(anonymous) @ write-api.js:660
(anonymous) @ exported-helpers.js:65
(anonymous) @ exported-helpers.js:75
callback @ process-args.js:70
callback @ apigen.js:85
(anonymous) @ apigen.js:109
Promise resolved (async)
(anonymous) @ apigen.js:104
(anonymous) @ exported-helpers.js:54
(anonymous) @ exported-helpers.js:75
callback @ process-args.js:70
callback @ apigen.js:85
(anonymous) @ apigen.js:109
Promise resolved (async)
(anonymous) @ apigen.js:104
createTransaction @ exported-helpers.js:48
api.(anonymous function) @ apigen.js:38
transaction @ write-api.js:496
(anonymous) @ write-api.js:179
(anonymous) @ write-api.js:320
(anonymous) @ GettingStarted.vue:251
Promise resolved (async)
createAccount @ GettingStarted.vue:236
boundFn @ vue.js:197
(anonymous) @ GettingStarted.vue:226
setTimeout (async)
generateAccount @ GettingStarted.vue:226
boundFn @ vue.js:196
invoker @ vue.js:2006
fn._withTask.fn._withTask @ vue.js:1804
bytebuffer.js:2795 ByteBufferAB(offset=2,markedOffset=-1,limit=88,capacity=88)
-------------------------------------------------------------------
5D 19<FE 0E 41 FD 76 A5 80 5A 02 00 00 00 1E 4D ]...A.v..Z.....M
75 AF 46 00 00 00 00 00 93 DD 74 00 01 00 00 00 u.F.......t.....
00 00 00 30 55 00 00 00 57 2D 3C CD CD 01 00 00 ...0U...W-<.....
00 00 00 93 DD 74 00 00 00 00 A8 ED 32 32 19 00 .....t......22..
00 00 00 00 93 DD 74 00 00 00 1E 4D 75 AF 46 0A ......t....Mu.F.
00 00 00 00 00 00 00 00> ........
apigen.js:111 Error: Assertion failed (transaction.ref_block_num) transaction.ref_block_num
at assert (bn.js:6)
at BN._initArray (bn.js:145)
at BN.init [as _init] (bn.js:82)
at new BN (bn.js:39)
at Object.fromByteBuffer (types.js:476)
at Object.fromByteBuffer (struct.js:66)
at Function.fromBuffer (fcbuffer.js:276)
at write-api.js:520
at write-api.js:660
at exported-helpers.js:65
This is a partial fix, unless you try to use a type that is greater than 64 bits .. The exchange contract has a type like this. For some reason I did something with BN.js that is not working under browserify and as you reported webpack.
published version 6.1.5
Thanks @jcalfee !
Very weird indeed that it doesn't work when bundled with browserify/webpack.
It's possible it has something to do with one of these:
https://github.com/indutny/bn.js/pull/168
https://github.com/indutny/bn.js/issues/160
which possibly insinuates that Buffer
might be overwritten when bundled, but when we use it in the test suite it's the only one present.
Node version: v8.9.4 NPM version: 5.6.0 OS: Win7 EOS OS: Ubuntu 16.10 ( VM )
Something seems to have changed since version
6.1.0
regarding account creation. Though I'm not sure if it's with eosjs itself, but perhaps a package it relies on as reverting to6.1.0
after updating does not fix the issue. ( I had an older repo that worked, then I updated and no longer works ).Other chain methods seem to work fine including transactions. In fact it doesn't seem to be hitting the EOS node at all when doing
newaccount
Code used to produce
Error: