From 5db78ea87a0e6357a764cee385d16c63b03e8651 Mon Sep 17 00:00:00 2001 From: Ted Suzman Date: Mon, 1 Nov 2021 16:34:20 -0700 Subject: [PATCH] fix: protect bigints in axios payloads --- src/starknet.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/starknet.ts b/src/starknet.ts index 63bf406ce..759befacf 100644 --- a/src/starknet.ts +++ b/src/starknet.ts @@ -12,7 +12,7 @@ import type { GetTransactionStatusResponse, Transaction, } from './types'; -import { parse } from './utils/json'; +import { parse, stringify } from './utils/json'; import { BigNumberish, toBN, toHex } from './utils/number'; import { compressProgram, randomAddress } from './utils/starknet'; @@ -199,11 +199,15 @@ export function addTransaction(tx: Transaction): Promise return new Promise((resolve, reject) => { axios - .post(`${GATEWAY_URL}/add_transaction`, { - ...tx, - ...(Array.isArray(signature) && { signature }), // not needed on deploy tx - ...(contract_address_salt && { contract_address_salt }), // not needed on invoke tx - }) + .post( + `${GATEWAY_URL}/add_transaction`, + stringify({ + ...tx, // the tx can contain BigInts, so we use our own `stringify` + ...(Array.isArray(signature) && { signature }), // not needed on deploy tx + ...(contract_address_salt && { contract_address_salt }), // not needed on invoke tx + }), + { headers: { 'Content-Type': 'application/json' } } + ) .then((resp: any) => { resolve(resp.data); })