Skip to content

Commit

Permalink
introduce new field for approvals
Browse files Browse the repository at this point in the history
  • Loading branch information
welps committed Oct 2, 2024
1 parent 79913a3 commit ff3d58b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 3 additions & 7 deletions sdk/src/quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -569,7 +567,6 @@ export const fillCrosschainQuote = async (
const { data, from, value } = quote;

sanityCheckAddress(quote?.to);
sanityCheckAddress(quote?.allowanceTarget);

let txData = data;
if (referrer) {
Expand Down Expand Up @@ -670,7 +667,6 @@ export const getCrosschainQuoteExecutionDetails = (
const { from, data, value } = quote;

sanityCheckAddress(quote?.to);
sanityCheckAddress(quote?.allowanceTarget);

return {
method: provider.estimateGas({
Expand Down
4 changes: 3 additions & 1 deletion sdk/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export interface Quote {
tradeFeeAmountUSD: number;
rewards?: Reward[];
chainId: number;
allowanceTarget: string;
allowanceNeeded: boolean;
}

export interface TokenAsset {
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions sdk/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit ff3d58b

Please sign in to comment.