From ff3d58b7c9f6649d7eb55a38846921af2ef6d072 Mon Sep 17 00:00:00 2001 From: Wayne Cheng <677680+welps@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:07:37 -0400 Subject: [PATCH] introduce new field for approvals --- sdk/src/quotes.ts | 10 +++------- sdk/src/types/index.ts | 4 +++- sdk/src/utils/constants.ts | 3 +++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sdk/src/quotes.ts b/sdk/src/quotes.ts index 44a240d..b0ebcaf 100644 --- a/sdk/src/quotes.ts +++ b/sdk/src/quotes.ts @@ -383,21 +383,19 @@ const fetchAndSanityCheckCrosschainQuote = async ( return quote as QuoteError; } - const quoteWithRestrictedAllowanceTarget = quote as CrosschainQuote; try { - sanityCheckAddress(quoteWithRestrictedAllowanceTarget?.to); - sanityCheckAddress(quoteWithRestrictedAllowanceTarget?.allowanceTarget); + sanityCheckAddress(quote?.to); } catch (e) { return { error: true, message: e instanceof Error ? e.message - : `unexpected error happened while checking crosschain quote's address: ${quoteWithRestrictedAllowanceTarget.allowanceTarget}`, + : `unexpected error happened while checking crosschain quote's address: ${quote?.to}`, } as QuoteError; } - return quoteWithRestrictedAllowanceTarget; + return quote; }; const calculateDeadline = async (wallet: Wallet) => { @@ -569,7 +567,6 @@ export const fillCrosschainQuote = async ( const { data, from, value } = quote; sanityCheckAddress(quote?.to); - sanityCheckAddress(quote?.allowanceTarget); let txData = data; if (referrer) { @@ -670,7 +667,6 @@ export const getCrosschainQuoteExecutionDetails = ( const { from, data, value } = quote; sanityCheckAddress(quote?.to); - sanityCheckAddress(quote?.allowanceTarget); return { method: provider.estimateGas({ diff --git a/sdk/src/types/index.ts b/sdk/src/types/index.ts index c758c17..766000a 100644 --- a/sdk/src/types/index.ts +++ b/sdk/src/types/index.ts @@ -102,6 +102,8 @@ export interface Quote { tradeFeeAmountUSD: number; rewards?: Reward[]; chainId: number; + allowanceTarget: string; + allowanceNeeded: boolean; } export interface TokenAsset { @@ -263,9 +265,9 @@ export interface SocketChainsData { // CrosschainQuote holds additional fields relevant for crosschain swaps export interface CrosschainQuote extends Quote { - allowanceTarget?: string; routes: SocketRoute[]; refuel: SocketRefuelData | null; + // @deprecated: use allowanceNeeded instead on parent Quote type no_approval: boolean | undefined; } diff --git a/sdk/src/utils/constants.ts b/sdk/src/utils/constants.ts index 9da60d1..d88a4a1 100644 --- a/sdk/src/utils/constants.ts +++ b/sdk/src/utils/constants.ts @@ -12,6 +12,9 @@ export type MultiChainAsset = { [key: string]: EthereumAddress; }; +/** + * @deprecated: Should not use this anymore to reduce friction for new network support + */ export const WRAPPED_ASSET: MultiChainAsset = { [`${ChainId.mainnet}`]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [`${ChainId.optimism}`]: '0x4200000000000000000000000000000000000006',