EOSIO / eosjs

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

TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined #810

Closed NatPDeveloper closed 3 years ago

NatPDeveloper commented 3 years ago

Version of EOSJS "eosjs": "^21.0.3",

Describe the bug Getting error pushing properly formatted serialized trx.

{"signatures":["SIG_K1_KiecgqQkjQSZMYJ3GuEXpQTJeaowdmcJvxwkf8mPEvhDRa1vMC2R2JrJqhnr6zc6FNRcqJxcGEKs9GmMTKMJPc3LAL3HFF"],"compression":0,"packed_context_free_data":"","packed_trx":"5023b45f200025d629eb00000000010000000000ea305500409e9a2264b89a010000000000ea305500000000a8ed3232660000000000ea3055a0d492e602ea3055010000000100021c000917ebd0ec30c32296214e4780079b2cb3b271b4b432e29fc86e7b4dc77e01000000010000000100021c000917ebd0ec30c32296214e4780079b2cb3b271b4b432e29fc86e7b4dc77e0100000000"}
{ Error: TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
    at PushGuarantee.<anonymous> (/home/ubuntu/environment/regression-tests/node_modules/eosio-push-guarantee/dist/src/index.js:219:35)
    at step (/home/ubuntu/environment/regression-tests/node_modules/eosio-push-guarantee/dist/src/index.js:32:23)
    at Object.throw (/home/ubuntu/environment/regression-tests/node_modules/eosio-push-guarantee/dist/src/index.js:13:53)
    at rejected (/home/ubuntu/environment/regression-tests/node_modules/eosio-push-guarantee/dist/src/index.js:5:65)
    at process._tickCallback (internal/process/next_tick.js:68:7) isFetchError: true }

const trxRes = await this.api.pushSignedTransaction(serializedTrx, trxOptions);
// same as rpc.push_transaction

To Reproduce Steps to reproduce the behavior: Try and push signed trx with 21.0.3 pushSignedTransaction on API or push_transaction on RPC.

Expected behavior Trx processes.

Desktop (please complete the following information):

Additional context Tried 20.0.2 beta as suggested in other issues, did not work either.

I'm integrating a push guarantee lib: https://github.com/liquidapps-io/eosio-push-guarantee/blob/main/src/index.ts#L31

This works with the example in the repo fine, but when using in production on our DSPs, things get weird.

Comparing the RPCs between my tests (kylin) and local tests: https://www.diffchecker.com/P3vAkKlQ

If I try and push manually I get


Error 3040005: Expired Transaction
Please increase the expiration time of your transaction!
Error Details:
expired transaction 374708fff7719dd5979ec875d56cd2286f6d3cf7ec317a3b25632aab28ec37bb, expiration 1970-01-01T00:00:00, block time 2020-11-18T03:08:14.500```
NatPDeveloper commented 3 years ago

Transaction was not being passed as desired Uint8Array.

What I was passing:

{ signatures:
   [ 'SIG_K1_K89u577E6LoGeiHYJEiisCfB4jmFkfhgCtGG1JEgUs9pekedT6sv16Ym8gckhHeRTDjjw39BGm4zBviayMEEoytFBaMFAs' ],
  compression: 0,
  packed_context_free_data: '',
  packed_trx:
   'b811b55f12000e4465a200000000010000000000ea305500409e9a2264b89a010000000000ea305500000000a8ed3232660000000000ea3055008037f500ea3055010000000100026d841bae7c1eb15f2ec2582cc2a95f295df117c9a5e0ae28099aed76df4af32b01000000010000000100026d841bae7c1eb15f2ec2582cc2a95f295df117c9a5e0ae28099aed76df4af32b0100000000' }

What it wants:

{ signatures:
   [ 'SIG_K1_KbEvTaa9j51UFTBJ23QU59xgpFpiREg58PjzyuTgXxB4BuS9zSsHyomEFa8RPkC2cBjJ5ppTNpSzPur6Lq842H82b9jPHB' ],
  serializedTransaction:
   Uint8Array [
     92,
     17,
...
  serializedContextFreeData: null }

To get there:

const { hexToUint8Array } = require("eosjs/dist/eosjs-serialize");
                body = {
                    signatures: body.signatures,
                    compression: body.compression || 0,
                    serializedTransaction: hexToUint8Array(body.packed_context_free_data),
                    serializedContextFreeData: hexToUint8Array(body.packed_context_free_data)
                }

Now getting

(node:10175) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:10175) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded

Unrelated for now closing.