diff --git a/packages/sdk/src/actions/executeQuote.ts b/packages/sdk/src/actions/executeQuote.ts index f2427b0..a45de75 100644 --- a/packages/sdk/src/actions/executeQuote.ts +++ b/packages/sdk/src/actions/executeQuote.ts @@ -56,6 +56,7 @@ export type ExecuteQuoteParams = { infiniteApproval?: boolean; skipAllowanceCheck?: boolean; throwOnError?: boolean; + forceOriginChain?: boolean; onProgress?: (progress: ExecutionProgress) => void; }; @@ -69,6 +70,7 @@ export async function executeQuote(params: ExecuteQuoteParams) { skipAllowanceCheck, infiniteApproval, throwOnError = true, + forceOriginChain, onProgress, logger, } = params; @@ -91,6 +93,19 @@ export async function executeQuote(params: ExecuteQuoteParams) { throw new Error("Wallet account has to be set"); } + if (forceOriginChain) { + await walletClient.switchChain({ + id: deposit.originChainId, + }); + } + + const connectedChainId = await walletClient.getChainId(); + if (connectedChainId !== deposit.originChainId) { + throw new Error( + `Connected chain ${connectedChainId} does not match 'originChainId' ${deposit.originChainId}`, + ); + } + const { inputToken, inputAmount, spokePoolAddress } = deposit; // Handle token approval if necessary. This will: