Skip to content

Commit

Permalink
fix(type-assertion): strickten MinAmountError type checker method
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarm22 committed Sep 17, 2024
1 parent 5c57c38 commit 61bb82c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion wormhole-connect/src/utils/sdkv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,17 @@ const parseNttReceipt = (
};
};

const isAmount = (amount: any): amount is amount.Amount => {
return (
typeof amount === 'object' &&
typeof amount.amount === 'string' &&
typeof amount.decimals === 'number'
);
};

export const isMinAmountError = (
error?: Error,
): error is routes.MinAmountError => {
return !!(error as routes.MinAmountError)?.min;
const unsafeCastError = error as routes.MinAmountError;
return isAmount(unsafeCastError?.min?.amount);
};

0 comments on commit 61bb82c

Please sign in to comment.