Skip to content

Commit

Permalink
feat: update src20 auto suggest about #594 issue & error handling to …
Browse files Browse the repository at this point in the history
…SRC20 Search about #593
  • Loading branch information
itttm127 authored and reinamora137 committed Jan 6, 2025
1 parent 5baad85 commit 67af8f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
22 changes: 10 additions & 12 deletions islands/stamp/StampSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function StampSearchClient(
const data = await response.json();
return data.n_tx > 0;
} catch (error) {
console.log("Stamp Search Error=========>", error);
console.log("Validate Bitcoin Address Error=========>", error);
return false;
}
};
Expand All @@ -67,7 +67,7 @@ export function StampSearchClient(
// Check if response has basic tx properties
return !!(data && data.hash && data.ver);
} catch (error) {
console.log("Stamp Search Error=========>", error);
console.log("Validate BitCoin Tx Error=========>", error);
return false;
}
};
Expand Down Expand Up @@ -141,12 +141,11 @@ export function StampSearchClient(
}
} catch (error) {
console.log("Stamp Search Error=========>", error);
setError(
`NO STAMP FOUND\n${query}\nThe CPID doesn't seem to be valid`,
);
return;
}

setError(
`NO STAMP FOUND\n${query}\nThe CPID doesn't seem to be valid`,
);
return;
}

// Check for stamp number
Expand All @@ -161,12 +160,11 @@ export function StampSearchClient(
}
} catch (error) {
console.log("Stamp Search Error=========>", error);
setError(
`NO STAMP FOUND\n#${query}\nThe stamp you are looking for doesn't exist`,
);
return;
}

setError(
`NO STAMP FOUND\n#${query}\nThe stamp you are looking for doesn't exist`,
);
return;
}

setError(
Expand Down
23 changes: 15 additions & 8 deletions server/database/src20Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,25 +625,32 @@ export class SRC20Repository {
const sanitizedQuery = query.replace(/[^\w-]/g, "");

const sqlQuery = `
SELECT DISTINCT
tick,
SELECT DISTINCT
tick,
(SELECT COUNT(*) FROM ${SRC20_TABLE} WHERE tick = dep.tick AND op = 'MINT') AS total_mints,
(SELECT COALESCE(SUM(amt), 0) FROM ${SRC20_BALANCE_TABLE} WHERE tick = dep.tick) AS total_minted,
dep.max AS max_supply,
dep.lim AS lim,
dep.max AS max_supply,
dep.lim AS lim,
dep.deci AS decimals
FROM ${SRC20_TABLE} dep
WHERE
FROM ${SRC20_TABLE} dep
WHERE
(tick LIKE ? OR
tx_hash LIKE ? OR
creator LIKE ? OR
destination LIKE ?)
AND dep.max IS NOT NULL
LIMIT 10;
ORDER BY
CASE
WHEN tick LIKE ? THEN 0
ELSE 1
END,
tick
LIMIT 10;
`;

const searchParam = `%${sanitizedQuery}%`;
const queryParams = [searchParam, searchParam, searchParam, searchParam];
const startSearchParam = `${sanitizedQuery}%`;
const queryParams = [searchParam, searchParam, searchParam, searchParam, startSearchParam];

try {
const result = await dbManager.executeQueryWithCache(
Expand Down

0 comments on commit 67af8f0

Please sign in to comment.