Skip to content

Commit

Permalink
support bns domains in explorer search
Browse files Browse the repository at this point in the history
  • Loading branch information
stjet committed Nov 13, 2024
1 parent 0f6c1b9 commit 4be4f7f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/lib/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ export const BANANO_PREFIX = 'ban_';
export const PER_PAGE = 8;

export const FOURTEEN_DAY_MS = 24*60*60*1000*14;

export const TLD_MAPPING = {
"mictest": "ban_1dzpfrgi8t4byzmdeidh57p14h5jwbursf1t3ztbmeqnqqdcbpgp9x8j3cw6",
"jtv": "ban_3gipeswotbnyemcc1dejyhy5a1zfgj35kw356dommbx4rdochiteajcsay56",
"ban": "ban_1fdo6b4bqm6pp1w55duuqw5ebz455975o4qcp8of85fjcdw9qhuzxsd3tjb9",
};

8 changes: 7 additions & 1 deletion src/routes/explorer/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
import { goto } from '$app/navigation';
import { validateBananoAddress, validateHexHash } from '$lib/utils/validate.js';
import { TLD_MAPPING } from '$lib/config/constants.js';
let searchQuery;
let filterType;
let searchError = false;
function explorerSearch() {
async function explorerSearch() {
//todo, error message is input is valid, or something
searchQuery = searchQuery.trim();
if (filterType === "address") {
if (searchQuery.includes(".")) {
const [name, tld] = searchQuery.split(".");
searchQuery = (await (new window.bns.Resolver(new window.bns.banani.RPC("https://kaliumapi.appditto.com/api"), TLD_MAPPING)).resolve(name, tld)).resolved_address;
}
if (validateBananoAddress(searchQuery)) {
return goto(`/explorer/addresses?address=${searchQuery}`);
}
Expand All @@ -33,6 +38,7 @@

<svelte:head>
<title>Explorer</title>
<script src="/bns-browser.js"></script>
</svelte:head>

<div class="flex flex-col w-full bg-base-300 rounded-box shadow p-4 my-4">
Expand Down
11 changes: 11 additions & 0 deletions static/bns-browser.js

Large diffs are not rendered by default.

0 comments on commit 4be4f7f

Please sign in to comment.