Skip to content

Commit

Permalink
check for dot ref
Browse files Browse the repository at this point in the history
  • Loading branch information
acdibble committed Dec 12, 2024
1 parent a702109 commit c2382d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/swap/src/routes/v2/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const channelIdRegex = /^(?<issuedBlock>\d+)-(?<srcChain>[a-z]+)-(?<channelId>\d
const swapRequestIdRegex = /^\d+$/i;
const hexRegex = /^(0x)?[a-f0-9]+$/i;
const base58Regex = new RegExp(`^[${CHARSET}]+$`);
const dotRegex = /^\d+-\d+$/;

const isTransactionRef = (id: string) =>
hexRegex.test(id) || base58Regex.test(id) || dotRegex.test(id);

export const getLatestSwapForId = async (id: string) => {
let swapRequest;
Expand Down Expand Up @@ -97,7 +101,7 @@ export const getLatestSwapForId = async (id: string) => {
where: { nativeId: BigInt(id) },
include: swapRequestInclude,
});
} else if (hexRegex.test(id) || base58Regex.test(id)) {
} else if (isTransactionRef(id)) {
swapRequest = await prisma.swapRequest.findFirst({
where: { depositTransactionRef: id },
include: swapRequestInclude,
Expand Down

0 comments on commit c2382d1

Please sign in to comment.