Skip to content

Commit

Permalink
pass a hex string to BigInt so it parses correctly (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin authored Aug 8, 2023
1 parent 1593683 commit d6592b5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/sdk-core/src/utils/vaa/tokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ export function parseTokenTransferPayload(payload: Buffer): TokenTransfer {
) {
throw new Error('not token bridge transfer VAA');
}
const amount = BigInt(payload.subarray(1, 33).toString());
const amount = BigInt(`0x${payload.subarray(1, 33).toString('hex')}`);
const tokenAddress = payload.subarray(33, 65);
const tokenChain = payload.readUInt16BE(65);
const to = payload.subarray(67, 99);
const toChain = payload.readUInt16BE(99);
const fee =
payloadType == 1 ? BigInt(payload.subarray(101, 133).toString()) : null;
payloadType == 1
? BigInt(`0x${payload.subarray(101, 133).toString('hex')}`)
: null;
const fromAddress = payloadType == 3 ? payload.subarray(101, 133) : null;
const tokenTransferPayload = payload.subarray(133);
return {
Expand Down

0 comments on commit d6592b5

Please sign in to comment.