Skip to content

Commit d6592b5

Browse files
authored
pass a hex string to BigInt so it parses correctly (#11)
1 parent 1593683 commit d6592b5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/sdk-core/src/utils/vaa/tokenBridge.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ export function parseTokenTransferPayload(payload: Buffer): TokenTransfer {
3434
) {
3535
throw new Error('not token bridge transfer VAA');
3636
}
37-
const amount = BigInt(payload.subarray(1, 33).toString());
37+
const amount = BigInt(`0x${payload.subarray(1, 33).toString('hex')}`);
3838
const tokenAddress = payload.subarray(33, 65);
3939
const tokenChain = payload.readUInt16BE(65);
4040
const to = payload.subarray(67, 99);
4141
const toChain = payload.readUInt16BE(99);
4242
const fee =
43-
payloadType == 1 ? BigInt(payload.subarray(101, 133).toString()) : null;
43+
payloadType == 1
44+
? BigInt(`0x${payload.subarray(101, 133).toString('hex')}`)
45+
: null;
4446
const fromAddress = payloadType == 3 ? payload.subarray(101, 133) : null;
4547
const tokenTransferPayload = payload.subarray(133);
4648
return {

0 commit comments

Comments
 (0)