Skip to content

Commit

Permalink
feat: return tx response in approveRoute handler
Browse files Browse the repository at this point in the history
  • Loading branch information
genaroibc committed Dec 23, 2024
1 parent fae743f commit 2453d5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/handlers/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class EvmHandler extends Utils {
}: {
data: ExecuteRoute;
params: RouteParamsPopulated;
}): Promise<boolean> {
}): Promise<TransactionResponse | null> {
const {
route: { transactionRequest },
executionSettings,
Expand All @@ -157,7 +157,7 @@ export class EvmHandler extends Utils {
const fromTokenContract = params.fromTokenContract as Contract;

if (fromIsNative) {
return true;
return null;
}

let amountToApprove = BigInt(uint256MaxValue);
Expand All @@ -175,15 +175,11 @@ export class EvmHandler extends Utils {
amountToApprove,
]);

const approveTx = await (data.signer as EvmWallet).sendTransaction({
return (data.signer as EvmWallet).sendTransaction({
to: params.preHook ? params.preHook.fundToken : params.fromToken.address,
data: approveData,
...overrides,
});

await approveTx.wait();

return true;
}

async isRouteApproved({
Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {
CosmosAddress,
CosmosBalance,
DepositAddressResponse,
Config,
ExecuteRoute,
GetStatus,
TransactionResponses,
EvmWallet,
OnChainExecutionData,
RouteRequest,
Expand All @@ -13,10 +17,10 @@ import {
StatusResponse,
Token,
TokenBalance,
TransactionResponse,
} from "./types";

import HttpAdapter from "./adapter/HttpAdapter";
import { Config, ExecuteRoute, GetStatus, TransactionResponses } from "./types";

import { CosmosHandler, EvmHandler, SolanaHandler } from "./handlers";
import { TokensChains } from "./utils/TokensChains";
Expand Down Expand Up @@ -225,7 +229,7 @@ export class Squid extends TokensChains {
}
}

async approveRoute(data: ExecuteRoute): Promise<boolean> {
async approveRoute(data: ExecuteRoute): Promise<TransactionResponse | null> {
this.validateInit();
this.validateTransactionRequest(data.route);

Expand Down
3 changes: 2 additions & 1 deletion src/types/ethers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TransactionResponse as TransactionResponseV5 } from "@ethersproject/abstract-provider";
import { Signer } from "@ethersproject/abstract-signer";
import { Wallet } from "@ethersproject/wallet";
import { ethers } from "ethers";
Expand All @@ -13,7 +14,7 @@ export type WalletV6 = ethers.Signer | ethers.Wallet;
export type EvmWallet = WalletV6 | WalletV5;

export type Transaction = ethers.Transaction;
export type TransactionResponse = ethers.TransactionResponse;
export type TransactionResponse = ethers.TransactionResponse | TransactionResponseV5;
export type TransactionRequest = ethers.TransactionRequest;

export type GasData = {
Expand Down

0 comments on commit 2453d5b

Please sign in to comment.