Skip to content

Commit

Permalink
fix: remove custom data when calling original signer
Browse files Browse the repository at this point in the history
  • Loading branch information
aramalipoor committed Dec 25, 2022
1 parent fbad803 commit ff831d4
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
CurrentBalance,
RequiredBalance,
} from '../types';
import { min, openModalWithData } from '../utils';
import { min } from '../utils';

export class BalanceRampClient {
private iframe!: HTMLIFrameElement;
Expand Down Expand Up @@ -45,7 +45,9 @@ export class BalanceRampClient {
(this.config.enabledChainIds === undefined ||
!this.config.enabledChainIds.includes(chainId))
) {
return originalSigner.sendTransaction(transactionRequest);
const cleanReq = { ...transactionRequest };
delete cleanReq.customData;
return originalSigner.sendTransaction(cleanReq);
}

const estimatedGasLimit = await this.handleEstimateGasLimit(
Expand Down Expand Up @@ -149,10 +151,10 @@ export class BalanceRampClient {
!this.config.maxGasLimit ||
BigNumber.from(estimatedGasLimit).gte(this.config.maxGasLimit)
) {
const cleanReq = { ...transactionRequest };
delete cleanReq.customData;
// re estimate gas if current gas estimate is maximum configured
const newGasListEstimate = await originalSigner.estimateGas(
transactionRequest,
);
const newGasListEstimate = await originalSigner.estimateGas(cleanReq);
// const newFees = await this.estimateGasFees(originalSigner);
this.applyGasParameters(
txWithGasData,
Expand Down Expand Up @@ -193,7 +195,9 @@ export class BalanceRampClient {
let estimatedGasLimit: BigNumber = BigNumber.from(0);

try {
estimatedGasLimit = await originalSigner.estimateGas(transactionRequest);
const cleanReq = { ...transactionRequest };
delete cleanReq.customData;
estimatedGasLimit = await originalSigner.estimateGas(cleanReq);
} catch (e: any) {
const message =
e?.data?.message?.toString() +
Expand All @@ -206,7 +210,8 @@ export class BalanceRampClient {
if (
!message.toLowerCase().includes('insufficient funds') &&
!message.toLowerCase().includes('exceeds allowance') &&
!message.toLowerCase().includes('exceeds balance')
!message.toLowerCase().includes('exceeds balance') &&
!message.toLowerCase().includes('zero balance')
) {
throw e;
}
Expand Down

0 comments on commit ff831d4

Please sign in to comment.