mirror of
https://github.com/stjet/bns.git
synced 2025-12-29 11:19:25 +00:00
ipfs
This commit is contained in:
8
README.md
Normal file
8
README.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
See the [docs](https://bns.prussia.dev) or [demo](https://bns.prussia.dev/browser_test)
|
||||||
|
|
||||||
|
## Installing
|
||||||
|
|
||||||
|
```js
|
||||||
|
npm i banani-bns
|
||||||
|
```
|
||||||
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -77,7 +77,7 @@ To convey metadata associated with a block. Can only be sent by Domain Accounts
|
|||||||
- Subtype: change
|
- Subtype: change
|
||||||
- Representative: Hash of the metadata
|
- Representative: Hash of the metadata
|
||||||
|
|
||||||
> Perhaps an encoded IPFS hash would be best?
|
> Currently, it is recommended that this metadata hash be a translated IPFS v0 Cid, so metadata files should be hosted on IPFS. IPFS is not mandated by the protocol, and it is perfectly acceptable to use something that is not IPFS to store metadata and use a regular SHA-256 hash of the file. However, clients will likely only support finding IPFS metadata.
|
||||||
|
|
||||||
## Domain Resolver block
|
## Domain Resolver block
|
||||||
|
|
||||||
@@ -102,6 +102,7 @@ Domain metadata can be anything. However, in order for domain metadata to be eas
|
|||||||
{
|
{
|
||||||
"domain": {
|
"domain": {
|
||||||
//any arbitrary keys and values can be put here; the following are some examples
|
//any arbitrary keys and values can be put here; the following are some examples
|
||||||
|
"description": "I love Banano?",
|
||||||
"www": "https://example.com",
|
"www": "https://example.com",
|
||||||
"tor": "http://asdsadif23ifjskfjls9030dskfblahblah.onion",
|
"tor": "http://asdsadif23ifjskfjls9030dskfblahblah.onion",
|
||||||
"eth": "0xbl8ahb8lah10blahblahblahblahblahblahblah5",
|
"eth": "0xbl8ahb8lah10blahblahblahblahblahblahblah5",
|
||||||
@@ -132,9 +133,21 @@ A TLD operator can use whatever system it wants for issuing domain names. Some i
|
|||||||
|
|
||||||
Also, for the convenience of the user (so they can do a Domain Resovler and Domain Transfer without needing to deposit more), TLDs are recommended to send 0.00120703011 Banano instead of the minimum 0.0012070301.
|
Also, for the convenience of the user (so they can do a Domain Resovler and Domain Transfer without needing to deposit more), TLDs are recommended to send 0.00120703011 Banano instead of the minimum 0.0012070301.
|
||||||
|
|
||||||
## Domain owners
|
## Domain owners / BNS wallets
|
||||||
|
|
||||||
Domain owners will need some specialised software to manage domains. Generating/storing Domain Accounts, transferring domains, and setting/changing their resolved address are all simple. Changing domain metadata is a bit more complicated and probably involves IPFS. Possibly integrate into Bananostand?
|
Domain owners will need some specialised software to manage domains. Generating/storing Domain Accounts, transferring domains, and setting/changing their resolved address are all simple. Changing domain metadata is a bit more complicated and involves uploading the metadata file to IPFS. The demo client supports converting IPFS Cid v0 into metadata hashes, and then declaring that metadata hash.
|
||||||
|
|
||||||
|
## Non-BNS wallets
|
||||||
|
|
||||||
|
Non-BNS wallets are regular Banano wallets like Kalium, Dagchat, Bananostand, etc, that will likely not add support for minting and managing BNS domains.
|
||||||
|
|
||||||
|
However, they can still integrate BNS by keeping a user-editable mapping of TLDs to addresses, and then supporting domain -> address translation for sending Banano or changing representatives.
|
||||||
|
|
||||||
|
## Metadata displayers
|
||||||
|
|
||||||
|
A browser extension or website could be made to fetch the metadata of a domain from IPFS, and then display it (hopefully nicely).
|
||||||
|
|
||||||
|
More advanced browser extensions can do things like displaying decentralised websites in the domain's metadata (eg, websites hosted on IPFS or Reticulum) when someone types in that domain in the address bar. They might also redirect to a regular (clearnet) website or a tor hidden service if the metadata requests.
|
||||||
|
|
||||||
## Buying/selling domains
|
## Buying/selling domains
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,21 @@
|
|||||||
#main {
|
#main {
|
||||||
grid-template-columns: auto auto;
|
grid-template-columns: auto auto;
|
||||||
}
|
}
|
||||||
|
#main div {
|
||||||
|
max-width: 50vw;
|
||||||
|
}
|
||||||
@media only screen and (max-width: 900px) {
|
@media only screen and (max-width: 900px) {
|
||||||
#main {
|
#main {
|
||||||
grid-template-columns: auto;
|
grid-template-columns: auto;
|
||||||
}
|
}
|
||||||
|
#main div {
|
||||||
|
max-width: 100vw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>Intended to be purely a demo. Tested only on firefox.</p>
|
<a id="address" target="_blank"></a>
|
||||||
<span id="address"></span>
|
|
||||||
<div id="start">
|
<div id="start">
|
||||||
<p>Click 'Create TLD Account' if you want to issue domain names, and click 'Create Domain Account' if you want to own a domain.</p>
|
<p>Click 'Create TLD Account' if you want to issue domain names, and click 'Create Domain Account' if you want to own a domain.</p>
|
||||||
<button onclick="create('tld')">Create TLD Account</button>
|
<button onclick="create('tld')">Create TLD Account</button>
|
||||||
@@ -33,7 +38,7 @@
|
|||||||
<li>In the second tab (TLD tab), click "Create TLD Account". Note down the seed and address.</li>
|
<li>In the second tab (TLD tab), click "Create TLD Account". Note down the seed and address.</li>
|
||||||
<li>Send a Banano to your TLD Account's address</li>
|
<li>Send a Banano to your TLD Account's address</li>
|
||||||
<li>On TLD tab, click "Receive"</li>
|
<li>On TLD tab, click "Receive"</li>
|
||||||
<li>On TLD tab, fill in the "Name (no '.', '"', max 32 chars [32 bytes])" field with "helloworld", fill in the Domain tab's address in the "Send to address:" field and click "Issue domain"</li>
|
<li>On TLD tab, fill in the "Name (no '.', '"', max 32 chars [32 bytes]):" field with "helloworld", fill in the Domain tab's address in the "Send to address:" field and click "Issue domain"</li>
|
||||||
<li>Wait until it sends, and open the block explorer link in a new tab, noting the block hash</li>
|
<li>Wait until it sends, and open the block explorer link in a new tab, noting the block hash</li>
|
||||||
<li>Back to the Domain tab, fill in that block hash into the "Block hash of Domain Transfer:" input</li>
|
<li>Back to the Domain tab, fill in that block hash into the "Block hash of Domain Transfer:" input</li>
|
||||||
<li>Then, in the right hand "Domain Resolver" panel add the TLD tab's address to the "TLD Mapping". Call it "demo"</li>
|
<li>Then, in the right hand "Domain Resolver" panel add the TLD tab's address to the "TLD Mapping". Call it "demo"</li>
|
||||||
@@ -41,6 +46,7 @@
|
|||||||
<li>It should now say "Name: helloworld" right below "Domain Account Manager". Congratulations! You own a Banano domain name now</li>
|
<li>It should now say "Name: helloworld" right below "Domain Account Manager". Congratulations! You own a Banano domain name now</li>
|
||||||
<li>Fill in your actual main Banano address in "Resolve to address:", and click "Declare address to resolve to", and anyone using your TLD can now turn "helloworld.demo" (or whatever they name your TLD) into your address</li>
|
<li>Fill in your actual main Banano address in "Resolve to address:", and click "Declare address to resolve to", and anyone using your TLD can now turn "helloworld.demo" (or whatever they name your TLD) into your address</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
<p>Special thanks to airtune and yusuf. <a href="https://github.com/stjet/bns/blob/master/bns_protocol.md">Protocol Specification</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div id="start-2" style="display: none;">
|
<div id="start-2" style="display: none;">
|
||||||
<p id="seed-display"></p>
|
<p id="seed-display"></p>
|
||||||
@@ -65,13 +71,13 @@
|
|||||||
<div id="domain">
|
<div id="domain">
|
||||||
<h2>Domain Account Manager</h2>
|
<h2>Domain Account Manager</h2>
|
||||||
<div id="domain-start">
|
<div id="domain-start">
|
||||||
<label for="r-d">Block hash of Domain Transfer:</label>
|
<label for="rc-d">Block hash of Domain Transfer:</label>
|
||||||
<input id="r-d" type="text"/>
|
<input id="rc-d" type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="domain_account.receive_domain(d.g('r-d').value)">Receive domain</button>
|
<button onclick="domain_account.receive_domain(d.g('rc-d').value)">Receive domain</button>
|
||||||
<br>
|
<br>
|
||||||
<label for="r-tld">TLD name (no dot):</label>
|
<label for="rc-tld">TLD name (no dot):</label>
|
||||||
<input id="r-tld" type="text"/>
|
<input id="rc-tld" type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="get_domain_account_domain()">Detect held domain name</button>
|
<button onclick="get_domain_account_domain()">Detect held domain name</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -83,27 +89,29 @@
|
|||||||
<br>
|
<br>
|
||||||
Metadata hash: <span id="found-metadata"></span>
|
Metadata hash: <span id="found-metadata"></span>
|
||||||
</p>
|
</p>
|
||||||
<label for="r-mh">Metadata hash:</label>
|
<label for="d-mh">IPFS Cid v0:</label>
|
||||||
<input id="r-mh" type="text"/>
|
<input id="d-mh" type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="domain_account.declare_domain_metadata(d.g('r-mh').value)">Declare metadata hash</button>
|
<button onclick="declare_metadata_hash()">Declare metadata hash</button>
|
||||||
<br>
|
<br>
|
||||||
<label for="r-a">Resolve to address:</label>
|
<label for="d-a">Resolve to address:</label>
|
||||||
<input id="r-a" type="text"/>
|
<input id="d-a" type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="domain_account.declare_domain_resolve_to(d.g('r-a').value)">Declare address to resolved to</button>
|
<button onclick="domain_account.declare_domain_resolve_to(d.g('d-a').value)">Declare address to resolved to</button>
|
||||||
<br>
|
<br>
|
||||||
<label for="transfer-to">Transfer domain to:</label>
|
<label for="transfer-to">Transfer domain to:</label>
|
||||||
<input id="transfer-to" placeholder="ban_abc..." type="text"/>
|
<input id="transfer-to" placeholder="ban_abc..." type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="transfer()">Transfer domain</button>
|
<button onclick="transfer()">Transfer domain</button>
|
||||||
<a id="transfer-link"></a>
|
<a id="transfer-link"></a>
|
||||||
|
<h3>Upload metadata to IPFS</h3>
|
||||||
|
//
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="resolver">
|
<div id="resolver">
|
||||||
<h2>Domain Resolver</h2>
|
<h2>Domain Resolver</h2>
|
||||||
<label for="resolve">Name:</label>
|
<label for="resolve">Name:</label>
|
||||||
<input id="resolve" type="text" placeholder="nishina.test"/>
|
<input id="resolve" type="text" placeholder="nishina247.mictest"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="resolve()">Resolve domain</button>
|
<button onclick="resolve()">Resolve domain</button>
|
||||||
<br>
|
<br>
|
||||||
@@ -189,20 +197,22 @@
|
|||||||
const alt_seed = d.g("alt-seed").value;
|
const alt_seed = d.g("alt-seed").value;
|
||||||
if (alt_seed) {
|
if (alt_seed) {
|
||||||
wallet = new bns.banani.Wallet(rpc, alt_seed);
|
wallet = new bns.banani.Wallet(rpc, alt_seed);
|
||||||
d.g("address").textContent = wallet.address;
|
|
||||||
}
|
}
|
||||||
d.g("seed-display").textContent = wallet.seed;
|
d.g("seed-display").textContent = wallet.seed;
|
||||||
if (type === "tld") {
|
if (type === "tld") {
|
||||||
|
document.title = "TLD Account - BNS demo";
|
||||||
tld_account = new bns.TLDAccountManager(rpc, wallet);
|
tld_account = new bns.TLDAccountManager(rpc, wallet);
|
||||||
mode = true;
|
mode = true;
|
||||||
d.g("domain").style.display = "none";
|
d.g("domain").style.display = "none";
|
||||||
} else {
|
} else {
|
||||||
|
document.title = "Domain Account - BNS demo";
|
||||||
domain_account = new bns.DomainAccountManager(rpc, wallet);
|
domain_account = new bns.DomainAccountManager(rpc, wallet);
|
||||||
d.g("tld").style.display = "none";
|
d.g("tld").style.display = "none";
|
||||||
}
|
}
|
||||||
d.g("start").style.display = "none";
|
d.g("start").style.display = "none";
|
||||||
d.g("start-2").style.display = "block";
|
d.g("start-2").style.display = "block";
|
||||||
d.g("address").textContent = wallet.address;
|
d.g("address").textContent = wallet.address;
|
||||||
|
d.g("address").href = `https://creeper.banano.cc/account/${d.g("address").textContent}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_tld() {
|
function add_tld() {
|
||||||
@@ -223,6 +233,10 @@
|
|||||||
gen_tld_mapping_list();
|
gen_tld_mapping_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_cid_v0_from_public_key(public_key) {
|
||||||
|
return bns.address_to_cid_v0(bns.banani.get_address_from_public_key(public_key));
|
||||||
|
}
|
||||||
|
|
||||||
async function resolve() {
|
async function resolve() {
|
||||||
let parts = d.g("resolve").value.split(".");
|
let parts = d.g("resolve").value.split(".");
|
||||||
if (parts.length !== 2) return;
|
if (parts.length !== 2) return;
|
||||||
@@ -232,10 +246,12 @@
|
|||||||
const resolver = new bns.Resolver(rpc2, tld_mapping);
|
const resolver = new bns.Resolver(rpc2, tld_mapping);
|
||||||
const resolved = await resolver.resolve(name, tld);
|
const resolved = await resolver.resolve(name, tld);
|
||||||
d.g("r-name").textContent = resolved.name;
|
d.g("r-name").textContent = resolved.name;
|
||||||
|
console.log(resolved.tld)
|
||||||
d.g("r-tld").textContent = `${resolved.tld} (.${tld})`;
|
d.g("r-tld").textContent = `${resolved.tld} (.${tld})`;
|
||||||
d.g("r-burned").textContent = resolved.burned;
|
d.g("r-burned").textContent = resolved.burned;
|
||||||
d.g("r-addr").textContent = resolved.resolved_address;
|
d.g("r-addr").textContent = resolved.resolved_address;
|
||||||
d.g("r-meta").textContent = resolved.metadata_hash;
|
const cid_v0 = resolved.metadata_hash ? get_cid_v0_from_public_key(resolved.metadata_hash) : "none";
|
||||||
|
d.g("r-meta").innerHTML = `${resolved.metadata_hash} (IPFS translation: <a href="https://ipfs.oversas.org/ipfs/${cid_v0}" target="_blank">${cid_v0}</a>)`;
|
||||||
d.g("r-hist").value = JSON.stringify(resolved.history, null, 2);
|
d.g("r-hist").value = JSON.stringify(resolved.history, null, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,17 +279,27 @@
|
|||||||
|
|
||||||
async function get_domain_account_domain() {
|
async function get_domain_account_domain() {
|
||||||
const resolver = new bns.Resolver(rpc2, tld_mapping);
|
const resolver = new bns.Resolver(rpc2, tld_mapping);
|
||||||
domain_account_domain = resolver.resolve_backwards_ish(wallet.address, d.g("r-tld").value);
|
domain_account_domain = resolver.resolve_backwards_ish(wallet.address, d.g("rc-tld").value);
|
||||||
domain_account_domain = await domain_account_domain;
|
domain_account_domain = await domain_account_domain;
|
||||||
const { name, resolved_address, metadata_hash } = domain_account_domain;
|
const { name, resolved_address, metadata_hash } = domain_account_domain;
|
||||||
console.log(domain_account_domain);
|
console.log(domain_account_domain);
|
||||||
d.g("found-name").textContent = name
|
d.g("found-name").textContent = name
|
||||||
d.g("found-address").textContent = resolved_address;
|
d.g("found-address").textContent = resolved_address;
|
||||||
d.g("found-metadata").textContent = metadata_hash;
|
const cid_v0 = metadata_hash ? get_cid_v0_from_public_key(metadata_hash) : "none";
|
||||||
|
d.g("found-metadata").innerHTML = `${metadata_hash} (IPFS translation: <a href="https://ipfs.oversas.org/ipfs/${cid_v0}" target="_blank">${cid_v0}</a>)`;
|
||||||
d.g("domain-start").style.display = "none";
|
d.g("domain-start").style.display = "none";
|
||||||
d.g("domain-actions").style.display = "block";
|
d.g("domain-actions").style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function declare_metadata_hash() {
|
||||||
|
const cid_v0 = d.g('d-mh').value.trim();
|
||||||
|
const cid_address = bns.cid_v0_to_address(cid_v0);
|
||||||
|
console.log(cid_v0, cid_address);
|
||||||
|
console.log(bns.address_to_cid_v0(cid_address))
|
||||||
|
const metadata_hash = bns.banani.get_public_key_from_address(cid_address);
|
||||||
|
await domain_account.declare_domain_metadata(metadata_hash);
|
||||||
|
}
|
||||||
|
|
||||||
async function transfer() {
|
async function transfer() {
|
||||||
if (!domain_account_domain) return;
|
if (!domain_account_domain) return;
|
||||||
console.log(domain_account_domain.name, d.g("transfer-to").value.trim())
|
console.log(domain_account_domain.name, d.g("transfer-to").value.trim())
|
||||||
|
|||||||
@@ -1,22 +1,36 @@
|
|||||||
:root {
|
:root {
|
||||||
|
--light-hl-0: #001080;
|
||||||
|
--dark-hl-0: #9CDCFE;
|
||||||
|
--light-hl-1: #000000;
|
||||||
|
--dark-hl-1: #D4D4D4;
|
||||||
--light-code-background: #FFFFFF;
|
--light-code-background: #FFFFFF;
|
||||||
--dark-code-background: #1E1E1E;
|
--dark-code-background: #1E1E1E;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: light) { :root {
|
@media (prefers-color-scheme: light) { :root {
|
||||||
|
--hl-0: var(--light-hl-0);
|
||||||
|
--hl-1: var(--light-hl-1);
|
||||||
--code-background: var(--light-code-background);
|
--code-background: var(--light-code-background);
|
||||||
} }
|
} }
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { :root {
|
@media (prefers-color-scheme: dark) { :root {
|
||||||
|
--hl-0: var(--dark-hl-0);
|
||||||
|
--hl-1: var(--dark-hl-1);
|
||||||
--code-background: var(--dark-code-background);
|
--code-background: var(--dark-code-background);
|
||||||
} }
|
} }
|
||||||
|
|
||||||
:root[data-theme='light'] {
|
:root[data-theme='light'] {
|
||||||
|
--hl-0: var(--light-hl-0);
|
||||||
|
--hl-1: var(--light-hl-1);
|
||||||
--code-background: var(--light-code-background);
|
--code-background: var(--light-code-background);
|
||||||
}
|
}
|
||||||
|
|
||||||
:root[data-theme='dark'] {
|
:root[data-theme='dark'] {
|
||||||
|
--hl-0: var(--dark-hl-0);
|
||||||
|
--hl-1: var(--dark-hl-1);
|
||||||
--code-background: var(--dark-code-background);
|
--code-background: var(--dark-code-background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hl-0 { color: var(--hl-0); }
|
||||||
|
.hl-1 { color: var(--hl-1); }
|
||||||
pre, code { background: var(--code-background); }
|
pre, code { background: var(--code-background); }
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA62ZXU/bMBSG/0uvYQwYjHHHhzbQYCBA4gKh6DQ5baymTmU7hWraf5/TtI1TO45r57I973mfY8c+qd23vwOBn2JwPhgCBUoGe4MZiFR+nuZJkSE/qL7/koppJoMTQpPB+be9QZwB51ImeLJP+L70QEahlMQpyRKGdHD+tjF/ZGQOAn/j4iKO84KKmrM0qjmaskk+PDprZ//b2wCfHq9aETLmbfpKRHoJ8aSY2exrlT8oZ5NHls9JgsyKUnR+sFfIMmx/IFXYz3r1CC8hAxpj45kQKuUjiGuQJm4yj05Od2HeEC5ytrjM8njiQFXlfXDdxlqLe2HCx47DXWf0RN9t0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|||||||
#main {
|
#main {
|
||||||
grid-template-columns: auto auto;
|
grid-template-columns: auto auto;
|
||||||
}
|
}
|
||||||
|
#main div {
|
||||||
|
max-width: 50vw;
|
||||||
|
}
|
||||||
@media only screen and (max-width: 900px) {
|
@media only screen and (max-width: 900px) {
|
||||||
#main {
|
#main {
|
||||||
grid-template-columns: auto;
|
grid-template-columns: auto;
|
||||||
}
|
}
|
||||||
|
#main div {
|
||||||
|
max-width: 100vw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>Intended to be purely a demo. Tested only on firefox.</p>
|
<a id="address" target="_blank"></a>
|
||||||
<span id="address"></span>
|
|
||||||
<div id="start">
|
<div id="start">
|
||||||
<p>Click 'Create TLD Account' if you want to issue domain names, and click 'Create Domain Account' if you want to own a domain.</p>
|
<p>Click 'Create TLD Account' if you want to issue domain names, and click 'Create Domain Account' if you want to own a domain.</p>
|
||||||
<button onclick="create('tld')">Create TLD Account</button>
|
<button onclick="create('tld')">Create TLD Account</button>
|
||||||
@@ -33,7 +38,7 @@
|
|||||||
<li>In the second tab (TLD tab), click "Create TLD Account". Note down the seed and address.</li>
|
<li>In the second tab (TLD tab), click "Create TLD Account". Note down the seed and address.</li>
|
||||||
<li>Send a Banano to your TLD Account's address</li>
|
<li>Send a Banano to your TLD Account's address</li>
|
||||||
<li>On TLD tab, click "Receive"</li>
|
<li>On TLD tab, click "Receive"</li>
|
||||||
<li>On TLD tab, fill in the "Name (no '.', '"', max 32 chars [32 bytes])" field with "helloworld", fill in the Domain tab's address in the "Send to address:" field and click "Issue domain"</li>
|
<li>On TLD tab, fill in the "Name (no '.', '"', max 32 chars [32 bytes]):" field with "helloworld", fill in the Domain tab's address in the "Send to address:" field and click "Issue domain"</li>
|
||||||
<li>Wait until it sends, and open the block explorer link in a new tab, noting the block hash</li>
|
<li>Wait until it sends, and open the block explorer link in a new tab, noting the block hash</li>
|
||||||
<li>Back to the Domain tab, fill in that block hash into the "Block hash of Domain Transfer:" input</li>
|
<li>Back to the Domain tab, fill in that block hash into the "Block hash of Domain Transfer:" input</li>
|
||||||
<li>Then, in the right hand "Domain Resolver" panel add the TLD tab's address to the "TLD Mapping". Call it "demo"</li>
|
<li>Then, in the right hand "Domain Resolver" panel add the TLD tab's address to the "TLD Mapping". Call it "demo"</li>
|
||||||
@@ -41,6 +46,7 @@
|
|||||||
<li>It should now say "Name: helloworld" right below "Domain Account Manager". Congratulations! You own a Banano domain name now</li>
|
<li>It should now say "Name: helloworld" right below "Domain Account Manager". Congratulations! You own a Banano domain name now</li>
|
||||||
<li>Fill in your actual main Banano address in "Resolve to address:", and click "Declare address to resolve to", and anyone using your TLD can now turn "helloworld.demo" (or whatever they name your TLD) into your address</li>
|
<li>Fill in your actual main Banano address in "Resolve to address:", and click "Declare address to resolve to", and anyone using your TLD can now turn "helloworld.demo" (or whatever they name your TLD) into your address</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
<p>Special thanks to airtune and yusuf. <a href="https://github.com/stjet/bns/blob/master/bns_protocol.md">Protocol Specification</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div id="start-2" style="display: none;">
|
<div id="start-2" style="display: none;">
|
||||||
<p id="seed-display"></p>
|
<p id="seed-display"></p>
|
||||||
@@ -65,13 +71,13 @@
|
|||||||
<div id="domain">
|
<div id="domain">
|
||||||
<h2>Domain Account Manager</h2>
|
<h2>Domain Account Manager</h2>
|
||||||
<div id="domain-start">
|
<div id="domain-start">
|
||||||
<label for="r-d">Block hash of Domain Transfer:</label>
|
<label for="rc-d">Block hash of Domain Transfer:</label>
|
||||||
<input id="r-d" type="text"/>
|
<input id="rc-d" type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="domain_account.receive_domain(d.g('r-d').value)">Receive domain</button>
|
<button onclick="domain_account.receive_domain(d.g('rc-d').value)">Receive domain</button>
|
||||||
<br>
|
<br>
|
||||||
<label for="r-tld">TLD name (no dot):</label>
|
<label for="rc-tld">TLD name (no dot):</label>
|
||||||
<input id="r-tld" type="text"/>
|
<input id="rc-tld" type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="get_domain_account_domain()">Detect held domain name</button>
|
<button onclick="get_domain_account_domain()">Detect held domain name</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -83,27 +89,29 @@
|
|||||||
<br>
|
<br>
|
||||||
Metadata hash: <span id="found-metadata"></span>
|
Metadata hash: <span id="found-metadata"></span>
|
||||||
</p>
|
</p>
|
||||||
<label for="r-mh">Metadata hash:</label>
|
<label for="d-mh">IPFS Cid v0:</label>
|
||||||
<input id="r-mh" type="text"/>
|
<input id="d-mh" type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="domain_account.declare_domain_metadata(d.g('r-mh').value)">Declare metadata hash</button>
|
<button onclick="declare_metadata_hash()">Declare metadata hash</button>
|
||||||
<br>
|
<br>
|
||||||
<label for="r-a">Resolve to address:</label>
|
<label for="d-a">Resolve to address:</label>
|
||||||
<input id="r-a" type="text"/>
|
<input id="d-a" type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="domain_account.declare_domain_resolve_to(d.g('r-a').value)">Declare address to resolved to</button>
|
<button onclick="domain_account.declare_domain_resolve_to(d.g('d-a').value)">Declare address to resolved to</button>
|
||||||
<br>
|
<br>
|
||||||
<label for="transfer-to">Transfer domain to:</label>
|
<label for="transfer-to">Transfer domain to:</label>
|
||||||
<input id="transfer-to" placeholder="ban_abc..." type="text"/>
|
<input id="transfer-to" placeholder="ban_abc..." type="text"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="transfer()">Transfer domain</button>
|
<button onclick="transfer()">Transfer domain</button>
|
||||||
<a id="transfer-link"></a>
|
<a id="transfer-link"></a>
|
||||||
|
<h3>Upload metadata to IPFS</h3>
|
||||||
|
//
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="resolver">
|
<div id="resolver">
|
||||||
<h2>Domain Resolver</h2>
|
<h2>Domain Resolver</h2>
|
||||||
<label for="resolve">Name:</label>
|
<label for="resolve">Name:</label>
|
||||||
<input id="resolve" type="text" placeholder="nishina.test"/>
|
<input id="resolve" type="text" placeholder="nishina247.mictest"/>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="resolve()">Resolve domain</button>
|
<button onclick="resolve()">Resolve domain</button>
|
||||||
<br>
|
<br>
|
||||||
@@ -189,20 +197,22 @@
|
|||||||
const alt_seed = d.g("alt-seed").value;
|
const alt_seed = d.g("alt-seed").value;
|
||||||
if (alt_seed) {
|
if (alt_seed) {
|
||||||
wallet = new bns.banani.Wallet(rpc, alt_seed);
|
wallet = new bns.banani.Wallet(rpc, alt_seed);
|
||||||
d.g("address").textContent = wallet.address;
|
|
||||||
}
|
}
|
||||||
d.g("seed-display").textContent = wallet.seed;
|
d.g("seed-display").textContent = wallet.seed;
|
||||||
if (type === "tld") {
|
if (type === "tld") {
|
||||||
|
document.title = "TLD Account - BNS demo";
|
||||||
tld_account = new bns.TLDAccountManager(rpc, wallet);
|
tld_account = new bns.TLDAccountManager(rpc, wallet);
|
||||||
mode = true;
|
mode = true;
|
||||||
d.g("domain").style.display = "none";
|
d.g("domain").style.display = "none";
|
||||||
} else {
|
} else {
|
||||||
|
document.title = "Domain Account - BNS demo";
|
||||||
domain_account = new bns.DomainAccountManager(rpc, wallet);
|
domain_account = new bns.DomainAccountManager(rpc, wallet);
|
||||||
d.g("tld").style.display = "none";
|
d.g("tld").style.display = "none";
|
||||||
}
|
}
|
||||||
d.g("start").style.display = "none";
|
d.g("start").style.display = "none";
|
||||||
d.g("start-2").style.display = "block";
|
d.g("start-2").style.display = "block";
|
||||||
d.g("address").textContent = wallet.address;
|
d.g("address").textContent = wallet.address;
|
||||||
|
d.g("address").href = `https://creeper.banano.cc/account/${d.g("address").textContent}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_tld() {
|
function add_tld() {
|
||||||
@@ -223,6 +233,10 @@
|
|||||||
gen_tld_mapping_list();
|
gen_tld_mapping_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_cid_v0_from_public_key(public_key) {
|
||||||
|
return bns.address_to_cid_v0(bns.banani.get_address_from_public_key(public_key));
|
||||||
|
}
|
||||||
|
|
||||||
async function resolve() {
|
async function resolve() {
|
||||||
let parts = d.g("resolve").value.split(".");
|
let parts = d.g("resolve").value.split(".");
|
||||||
if (parts.length !== 2) return;
|
if (parts.length !== 2) return;
|
||||||
@@ -232,10 +246,12 @@
|
|||||||
const resolver = new bns.Resolver(rpc2, tld_mapping);
|
const resolver = new bns.Resolver(rpc2, tld_mapping);
|
||||||
const resolved = await resolver.resolve(name, tld);
|
const resolved = await resolver.resolve(name, tld);
|
||||||
d.g("r-name").textContent = resolved.name;
|
d.g("r-name").textContent = resolved.name;
|
||||||
|
console.log(resolved.tld)
|
||||||
d.g("r-tld").textContent = `${resolved.tld} (.${tld})`;
|
d.g("r-tld").textContent = `${resolved.tld} (.${tld})`;
|
||||||
d.g("r-burned").textContent = resolved.burned;
|
d.g("r-burned").textContent = resolved.burned;
|
||||||
d.g("r-addr").textContent = resolved.resolved_address;
|
d.g("r-addr").textContent = resolved.resolved_address;
|
||||||
d.g("r-meta").textContent = resolved.metadata_hash;
|
const cid_v0 = resolved.metadata_hash ? get_cid_v0_from_public_key(resolved.metadata_hash) : "none";
|
||||||
|
d.g("r-meta").innerHTML = `${resolved.metadata_hash} (IPFS translation: <a href="https://ipfs.oversas.org/ipfs/${cid_v0}" target="_blank">${cid_v0}</a>)`;
|
||||||
d.g("r-hist").value = JSON.stringify(resolved.history, null, 2);
|
d.g("r-hist").value = JSON.stringify(resolved.history, null, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,17 +279,27 @@
|
|||||||
|
|
||||||
async function get_domain_account_domain() {
|
async function get_domain_account_domain() {
|
||||||
const resolver = new bns.Resolver(rpc2, tld_mapping);
|
const resolver = new bns.Resolver(rpc2, tld_mapping);
|
||||||
domain_account_domain = resolver.resolve_backwards_ish(wallet.address, d.g("r-tld").value);
|
domain_account_domain = resolver.resolve_backwards_ish(wallet.address, d.g("rc-tld").value);
|
||||||
domain_account_domain = await domain_account_domain;
|
domain_account_domain = await domain_account_domain;
|
||||||
const { name, resolved_address, metadata_hash } = domain_account_domain;
|
const { name, resolved_address, metadata_hash } = domain_account_domain;
|
||||||
console.log(domain_account_domain);
|
console.log(domain_account_domain);
|
||||||
d.g("found-name").textContent = name
|
d.g("found-name").textContent = name
|
||||||
d.g("found-address").textContent = resolved_address;
|
d.g("found-address").textContent = resolved_address;
|
||||||
d.g("found-metadata").textContent = metadata_hash;
|
const cid_v0 = metadata_hash ? get_cid_v0_from_public_key(metadata_hash) : "none";
|
||||||
|
d.g("found-metadata").innerHTML = `${metadata_hash} (IPFS translation: <a href="https://ipfs.oversas.org/ipfs/${cid_v0}" target="_blank">${cid_v0}</a>)`;
|
||||||
d.g("domain-start").style.display = "none";
|
d.g("domain-start").style.display = "none";
|
||||||
d.g("domain-actions").style.display = "block";
|
d.g("domain-actions").style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function declare_metadata_hash() {
|
||||||
|
const cid_v0 = d.g('d-mh').value.trim();
|
||||||
|
const cid_address = bns.cid_v0_to_address(cid_v0);
|
||||||
|
console.log(cid_v0, cid_address);
|
||||||
|
console.log(bns.address_to_cid_v0(cid_address))
|
||||||
|
const metadata_hash = bns.banani.get_public_key_from_address(cid_address);
|
||||||
|
await domain_account.declare_domain_metadata(metadata_hash);
|
||||||
|
}
|
||||||
|
|
||||||
async function transfer() {
|
async function transfer() {
|
||||||
if (!domain_account_domain) return;
|
if (!domain_account_domain) return;
|
||||||
console.log(domain_account_domain.name, d.g("transfer-to").value.trim())
|
console.log(domain_account_domain.name, d.g("transfer-to").value.trim())
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
docs/functions/address_to_cid_v0.html
Normal file
1
docs/functions/address_to_cid_v0.html
Normal file
File diff suppressed because one or more lines are too long
1
docs/functions/base58_to_hex.html
Normal file
1
docs/functions/base58_to_hex.html
Normal file
File diff suppressed because one or more lines are too long
1
docs/functions/bigint_to_uint8array.html
Normal file
1
docs/functions/bigint_to_uint8array.html
Normal file
File diff suppressed because one or more lines are too long
1
docs/functions/cid_v0_to_address.html
Normal file
1
docs/functions/cid_v0_to_address.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
docs/functions/hex_to_base58.html
Normal file
1
docs/functions/hex_to_base58.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -12,6 +12,11 @@
|
|||||||
<a href="interfaces/DomainTransfer.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-256"></use></svg><span>Domain<wbr/>Transfer</span></a>
|
<a href="interfaces/DomainTransfer.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-256"></use></svg><span>Domain<wbr/>Transfer</span></a>
|
||||||
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Type Aliases</h3><div class="tsd-index-list"><a href="types/DomainBlocks.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-2097152"></use></svg><span>Domain<wbr/>Blocks</span></a>
|
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Type Aliases</h3><div class="tsd-index-list"><a href="types/DomainBlocks.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-2097152"></use></svg><span>Domain<wbr/>Blocks</span></a>
|
||||||
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Variables</h3><div class="tsd-index-list"><a href="variables/LOG.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-32"></use></svg><span>LOG</span></a>
|
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Variables</h3><div class="tsd-index-list"><a href="variables/LOG.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-32"></use></svg><span>LOG</span></a>
|
||||||
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Functions</h3><div class="tsd-index-list"><a href="functions/decode_domain_name.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-64"></use></svg><span>decode_<wbr/>domain_<wbr/>name</span></a>
|
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Functions</h3><div class="tsd-index-list"><a href="functions/address_to_cid_v0.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-64"></use></svg><span>address_<wbr/>to_<wbr/>cid_<wbr/>v0</span></a>
|
||||||
|
<a href="functions/base58_to_hex.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-64"></use></svg><span>base58_<wbr/>to_<wbr/>hex</span></a>
|
||||||
|
<a href="functions/bigint_to_uint8array.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-64"></use></svg><span>bigint_<wbr/>to_<wbr/>uint8array</span></a>
|
||||||
|
<a href="functions/cid_v0_to_address.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-64"></use></svg><span>cid_<wbr/>v0_<wbr/>to_<wbr/>address</span></a>
|
||||||
|
<a href="functions/decode_domain_name.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-64"></use></svg><span>decode_<wbr/>domain_<wbr/>name</span></a>
|
||||||
<a href="functions/encode_domain_name.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-64"></use></svg><span>encode_<wbr/>domain_<wbr/>name</span></a>
|
<a href="functions/encode_domain_name.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-64"></use></svg><span>encode_<wbr/>domain_<wbr/>name</span></a>
|
||||||
|
<a href="functions/hex_to_base58.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-64"></use></svg><span>hex_<wbr/>to_<wbr/>base58</span></a>
|
||||||
</div></section></section></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-index-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><h4 class="uppercase">Member Visibility</h4><form><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div><div class="tsd-theme-toggle"><h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="modules.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-1"></use></svg><span>bns</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base="."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
</div></section></section></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-index-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><h4 class="uppercase">Member Visibility</h4><form><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div><div class="tsd-theme-toggle"><h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="modules.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-1"></use></svg><span>bns</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base="."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -3,6 +3,9 @@ import * as fs from "fs";
|
|||||||
import * as crypto from "crypto";
|
import * as crypto from "crypto";
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
console.log("cid v0 to address", bns.cid_v0_to_address("QmbzTMo42KADUbLwc43KR9Se6aV3N6wfKqFbSr2qN1gJqR") === "ban_3kpq7d4kp9hd45jf8jh6zjztcewwfqaxafcr3b45whrxhce1sfinai3pk6w3");
|
||||||
|
console.log("address to cidv0", bns.address_to_cid_v0("ban_3kpq7d4kp9hd45jf8jh6zjztcewwfqaxafcr3b45whrxhce1sfinai3pk6w3") === "QmbzTMo42KADUbLwc43KR9Se6aV3N6wfKqFbSr2qN1gJqR");
|
||||||
|
|
||||||
const test_seed = fs.readFileSync("./.secret", "utf-8").trim();
|
const test_seed = fs.readFileSync("./.secret", "utf-8").trim();
|
||||||
|
|
||||||
let rpc = new bns.banani.RPC("https://kaliumapi.appditto.com/api"); //for sending cause it does work
|
let rpc = new bns.banani.RPC("https://kaliumapi.appditto.com/api"); //for sending cause it does work
|
||||||
|
|||||||
3
package-lock.json
generated
3
package-lock.json
generated
@@ -1,9 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "bns",
|
"name": "bns",
|
||||||
|
"version": "0.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "bns",
|
||||||
|
"version": "0.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"banani": "^1.0.2"
|
"banani": "^1.0.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bns",
|
"name": "banani-bns",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"description": "JS/TS library for the Banano cryptocurrency's currently unofficial Banano Name System (BNS)",
|
"description": "JS/TS library for the Banano cryptocurrency's currently unofficial Banano Name System (BNS)",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ export class DomainAccount extends Account {
|
|||||||
return this.domain;
|
return this.domain;
|
||||||
}
|
}
|
||||||
} else if (block.subtype === "change") {
|
} else if (block.subtype === "change") {
|
||||||
this.domain.metadata_hash = block.representative;
|
this.domain.metadata_hash = get_public_key_from_address(block.representative);
|
||||||
this.domain.history.push({
|
this.domain.history.push({
|
||||||
type: "metadata",
|
type: "metadata",
|
||||||
block,
|
block,
|
||||||
|
|||||||
45
util.ts
45
util.ts
@@ -1,4 +1,5 @@
|
|||||||
import { uint8array_to_hex, hex_to_uint8array } from "banani";
|
import type { Address } from "banani";
|
||||||
|
import { uint8array_to_hex, hex_to_uint8array, get_address_from_public_key, get_public_key_from_address } from "banani";
|
||||||
|
|
||||||
export const LOG: boolean = true;
|
export const LOG: boolean = true;
|
||||||
|
|
||||||
@@ -17,3 +18,45 @@ export function decode_domain_name(encoded_domain_name: string): string {
|
|||||||
return (new TextDecoder()).decode(hex_to_uint8array(encoded_domain_name)).replaceAll("\u0000", "");
|
return (new TextDecoder()).decode(hex_to_uint8array(encoded_domain_name)).replaceAll("\u0000", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const BASE58_CHARS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
export function hex_to_base58(hex: string): string {
|
||||||
|
let num = BigInt(`0x${hex}`);
|
||||||
|
let base58 = "";
|
||||||
|
while (true) {
|
||||||
|
base58 += BASE58_CHARS[Number(num % BigInt(58))];
|
||||||
|
num = num / BigInt(58); //automatically rounds down
|
||||||
|
if (num === 0n) break;
|
||||||
|
}
|
||||||
|
//it's backwards, so reverse it. why? Idgaf right now. it works
|
||||||
|
return base58.split("").reverse().join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
//lmao
|
||||||
|
export function bigint_to_uint8array(bint: bigint, len: number): Uint8Array {
|
||||||
|
let uint8array: Uint8Array = new Uint8Array(len);
|
||||||
|
let subbed_bint = bint;
|
||||||
|
for (let i = 1; i <= len; i++) {
|
||||||
|
uint8array[len - i] = Number(subbed_bint % 256n);
|
||||||
|
subbed_bint /= 256n;
|
||||||
|
}
|
||||||
|
return uint8array;
|
||||||
|
}
|
||||||
|
|
||||||
|
//too lazy to bother doing anything proper
|
||||||
|
export function base58_to_hex(base58: string): string {
|
||||||
|
let bint = 0n;
|
||||||
|
for (let i = 0; i < base58.length; i++) {
|
||||||
|
bint += BigInt(BASE58_CHARS.indexOf(base58[base58.length - i - 1])) * (BigInt(58) ** BigInt(i));
|
||||||
|
}
|
||||||
|
return uint8array_to_hex(bigint_to_uint8array(bint, 34));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function cid_v0_to_address(cid_v0: string): Address {
|
||||||
|
return get_address_from_public_key(base58_to_hex(cid_v0).slice(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function address_to_cid_v0(address: Address): string {
|
||||||
|
return hex_to_base58("1220" + get_public_key_from_address(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user