Skip to content

Commit

Permalink
feat: add opt forceOriginChain to executeQuote (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki authored Sep 20, 2024
1 parent c1ba18e commit 6be3c46
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/sdk/src/actions/executeQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export type ExecuteQuoteParams = {
infiniteApproval?: boolean;
skipAllowanceCheck?: boolean;
throwOnError?: boolean;
forceOriginChain?: boolean;
onProgress?: (progress: ExecutionProgress) => void;
};

Expand All @@ -69,6 +70,7 @@ export async function executeQuote(params: ExecuteQuoteParams) {
skipAllowanceCheck,
infiniteApproval,
throwOnError = true,
forceOriginChain,
onProgress,
logger,
} = params;
Expand All @@ -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:
Expand Down

0 comments on commit 6be3c46

Please sign in to comment.