Skip to content

Commit

Permalink
Merge pull request #512 from connext/gas-limit-arbitrum
Browse files Browse the repository at this point in the history
Gas limit
  • Loading branch information
Rahul Sethuram authored Nov 10, 2021
2 parents 612e77a + d1fa95f commit dc8a10d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 4 additions & 3 deletions packages/sdk/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
CancelParams,
GetTransferQuote,
} from "./types";
import { signFulfillTransactionPayload, encodeAuctionBid, ethereumRequest } from "./utils";
import { signFulfillTransactionPayload, encodeAuctionBid, ethereumRequest, getGasLimit } from "./utils";
import { SubgraphEvent, SubgraphEvents } from "./subgraph/subgraph";
import { NxtpSdkBase } from "./sdkBase";

Expand Down Expand Up @@ -351,8 +351,9 @@ export class NxtpSdk {
}

const approveTxReq = await this.sdkBase.approveForPrepare(transferParams, infiniteApprove);
const gasLimit = getGasLimit(receivingChainId);
if (approveTxReq) {
const approveTx = await connectedSigner.sendTransaction(approveTxReq);
const approveTx = await connectedSigner.sendTransaction({ ...approveTxReq, gasLimit });
this.evts.SenderTokenApprovalSubmitted.post({
assetId: sendingAssetId,
chainId: sendingChainId,
Expand Down Expand Up @@ -387,7 +388,7 @@ export class NxtpSdk {
// Prepare sender side tx
const prepareReq = await this.sdkBase.prepareTransfer(transferParams);
this.logger.warn("Generated prepareReq", requestContext, methodContext, { prepareReq });
const prepareResponse = await connectedSigner.sendTransaction(prepareReq);
const prepareResponse = await connectedSigner.sendTransaction({ ...prepareReq, gasLimit });
this.evts.SenderTransactionPrepareSubmitted.post({
prepareParams: {
txData: {
Expand Down
12 changes: 12 additions & 0 deletions packages/sdk/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ import {
isChainSupportedByGelato as _isChainSupportedByGelato,
} from "@connext/nxtp-utils";

/**
* Get gas limit if it's hardcoded for some chains
* @param chainId
* @returns Gas Limit
*/
export const getGasLimit = (chainId: number): number | undefined => {
if (chainId === 42161) {
return 10_000_000;
}
return undefined;
};

/**
* Utility to convert the number of hours into seconds
*
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/test/unit/sdk.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ describe("NxtpSdk", () => {
bidSignature,
gasFeeInReceivingToken,
});
expect(signer.sendTransaction).to.be.calledOnceWithExactly(PrepareReq);
expect(signer.sendTransaction).to.be.calledOnceWithExactly({ ...PrepareReq, gasLimit: undefined });
expect(res.prepareResponse).to.be.deep.eq(TxResponse);
});

Expand All @@ -393,8 +393,8 @@ describe("NxtpSdk", () => {
gasFeeInReceivingToken,
});

expect(signer.sendTransaction).to.be.calledWithExactly(ApproveReq);
expect(signer.sendTransaction).to.be.calledWithExactly(PrepareReq);
expect(signer.sendTransaction).to.be.calledWithExactly({ ...ApproveReq, gasLimit: undefined });
expect(signer.sendTransaction).to.be.calledWithExactly({ ...PrepareReq, gasLimit: undefined });
expect(res.prepareResponse).to.be.deep.eq(TxResponse);
});
});
Expand Down

0 comments on commit dc8a10d

Please sign in to comment.