Skip to content

Commit

Permalink
add invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
jonator committed Aug 5, 2024
1 parent d4c98a8 commit 2739531
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/web/server/api/routers/bridge-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export const bridgeTransferRouter = createTRPCRouter({
/** If the bridge takes longer than 10 seconds to respond, we should timeout that quote. */
const quote = await timeout(quoteFn, 10 * 1000)();

// Basic circuit breaker to validate some invariants
// from input + given quote
if (input.fromAsset.address !== quote.input.address) {
throw new Error(
`Invalid quote: Expected fromAsset address ${input.fromAsset.address} but got ${quote.input.address} in quote`
);
}

/**
* Since transfer fee is deducted from input amount,
* we overwrite the transfer fee asset to be the input
Expand Down

0 comments on commit 2739531

Please sign in to comment.