19 lines
660 B
JavaScript
19 lines
660 B
JavaScript
|
|
// Usage: node src/resolve.js [name] — resolves one name, or lists all.
|
||
|
|
import { loadWallet } from "./lib/wallet.js";
|
||
|
|
import { buildIndex, resolveName } from "./lib/bns.js";
|
||
|
|
|
||
|
|
const [name] = process.argv.slice(2);
|
||
|
|
const wallet = await loadWallet();
|
||
|
|
|
||
|
|
if (name) {
|
||
|
|
const entry = await resolveName(wallet.provider, name);
|
||
|
|
console.log(entry ?? `NXDOMAIN: ${name}`);
|
||
|
|
} else {
|
||
|
|
const index = await buildIndex(wallet.provider);
|
||
|
|
if (index.size === 0) console.log("(no names registered yet)");
|
||
|
|
for (const e of index.values()) {
|
||
|
|
console.log(`${e.name}.bch -> ${JSON.stringify(e.records)} [category ${e.category.slice(0, 12)}…]`);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
process.exit(0);
|