Skip to content

Commit

Permalink
chore: remove balance check before executing route (#347)
Browse files Browse the repository at this point in the history
* chore: remove balance check before executing route

* Revert "chore: remove balance check before executing route"

This reverts commit 39cf7bb.

* chore: introduce bypassBalanceChecks var for route execution

* chore: remove unused param
  • Loading branch information
odcey authored Dec 3, 2024
1 parent 1ae87bc commit 9334ea0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
20 changes: 11 additions & 9 deletions src/handlers/evm/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EthersAdapter } from "../../adapter/EthersAdapter";
import erc20Abi from "../../abi/erc20.json";
import { EthersAdapter } from "../../adapter/EthersAdapter";

import {
Contract,
Expand All @@ -20,8 +20,8 @@ import {
NATIVE_EVM_TOKEN_ADDRESS,
uint256MaxValue,
} from "../../constants";
import { Utils } from "./utils";
import { TokensChains } from "../../utils/TokensChains";
import { Utils } from "./utils";

const ethersAdapter = new EthersAdapter();

Expand All @@ -45,13 +45,15 @@ export class EvmHandler extends Utils {
overrides,
});

await this.validateBalanceAndApproval({
data: {
...data,
overrides: gasData,
},
params,
});
if (!data.bypassBalanceChecks) {
await this.validateBalanceAndApproval({
data: {
...data,
overrides: gasData,
},
params,
});
}

const tx = {
to: target,
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ export class Squid extends TokensChains {
data.signer as EvmWallet,
);

return this.handlers.evm.executeRoute({ data, params: evmParams });
return this.handlers.evm.executeRoute({
data,
params: evmParams,
});

case ChainType.COSMOS:
const cosmosParams = this.handlers.cosmos.populateRouteParams(this, data.route.params);
Expand Down
9 changes: 5 additions & 4 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
ChainData,
Token,
RouteRequest,
RouteResponse as _RouteResponse,
ChainData,
DepositAddressResponse,
RouteRequest,
Token,
} from "@0xsquid/squid-types";
import { SigningStargateClient } from "@cosmjs/stargate";

import { EvmWallet, TransactionResponse, RpcProvider, Contract, GasData } from "./ethers";
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { Contract, EvmWallet, GasData, RpcProvider, TransactionResponse } from "./ethers";

export * from "@0xsquid/squid-types";
export * from "./cosmos";
Expand Down Expand Up @@ -42,6 +42,7 @@ export type ExecuteRoute = {
route: _RouteResponse["route"];
executionSettings?: ExecutionSettings;
overrides?: OverrideParams;
bypassBalanceChecks?: boolean;
signerAddress?: string; // cosmos specific
};

Expand Down

0 comments on commit 9334ea0

Please sign in to comment.