dfinity / rosetta-client

Apache License 2.0
44 stars 11 forks source link

Error when decoding unsigned transaction #50

Closed neeboo closed 3 years ago

neeboo commented 3 years ago
  1. On mainnet, use https://rosetta-api.internetcomputer.org as baseUrl.
  2. In the combine function

https://github.com/dfinity/rosetta-client/blob/e24bd52a862fa56c9bc9812707762c6efb561b1e/lib/construction_combine.js#L49

  assert(unsigned_transaction.updates.length === 1);

actually after using cbor_decode, the result would be like :

{
  "update":{ 
    canister_id: <Buffer 00 00 00 00 00 00 00 02 01 01>,
    ...
  },
 "ingress_expiries":[..., ..., ...,]
}

which there is no such updates key/value exist, causing the assert fail.

  1. should change to
    assert((unsigned_transaction.update !== undefined || unsigned_transaction.update !== null) );

after that, should change the for(const update of ...) loop. It would be like:

const envelopes = [];
const { update } = unsigned_transaction;
const request_envelopes = [];
...
neeboo commented 3 years ago

Close due to latest docker release