Skip to content

Commit

Permalink
fix: protect bigints in axios payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
RoboTeddy committed Nov 1, 2021
1 parent 08a2e31 commit 5db78ea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/starknet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -199,11 +199,15 @@ export function addTransaction(tx: Transaction): Promise<AddTransactionResponse>

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);
})
Expand Down

0 comments on commit 5db78ea

Please sign in to comment.