receive only once and correctly if registrar accidentally sends twice
also style fix
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -8,7 +8,7 @@
|
|||||||
"name": "test",
|
"name": "test",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"banani": "^1.0.5",
|
"banani": "^1.0.7",
|
||||||
"banani-bns": "^0.0.9",
|
"banani-bns": "^0.0.9",
|
||||||
"mongodb": "^6.10.0",
|
"mongodb": "^6.10.0",
|
||||||
"qrcode": "^1.5.4"
|
"qrcode": "^1.5.4"
|
||||||
@@ -1120,9 +1120,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/banani": {
|
"node_modules/banani": {
|
||||||
"version": "1.0.6",
|
"version": "1.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/banani/-/banani-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/banani/-/banani-1.0.8.tgz",
|
||||||
"integrity": "sha512-wB4nijscW0g18aojQqOm4Lqghg9TDHGQe+AnravbZoH37c3fJXSgQV+pKzBqpT3VIzcASfOjFyAqmUsTDWREHA==",
|
"integrity": "sha512-3yO8ywvWsEwI/r0Jvr9EhWN1pdLvw9D+W7gM4tBGnMs0mkug7jXsyCLX33F0jUOniAAJvDX8JXHe/WCq/RwwPA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"blake2b": "^2.1.4"
|
"blake2b": "^2.1.4"
|
||||||
|
|||||||
@@ -12,7 +12,22 @@
|
|||||||
if (browser && resolve_to.startsWith("ban_") && resolve_to.length === 64) {
|
if (browser && resolve_to.startsWith("ban_") && resolve_to.length === 64) {
|
||||||
const rpc = new window.bns.banani.RPC("https://kaliumapi.appditto.com/api");
|
const rpc = new window.bns.banani.RPC("https://kaliumapi.appditto.com/api");
|
||||||
const wallet = new window.bns.banani.Wallet(rpc, seed);
|
const wallet = new window.bns.banani.Wallet(rpc, seed);
|
||||||
await wallet.receive_all();
|
const hashes = (await wallet.get_account_receivable()).blocks;
|
||||||
|
const infos = (await rpc.get_blocks(hashes)).blocks;
|
||||||
|
//in case registrar accidentally sends the domain twice, only the first send (with lowest height) will be valid, so receive that
|
||||||
|
//BUT kalium rpc doesn't return height yet (augh) so we'll go for the one with the higher balance (since that was almost certainly sent first)
|
||||||
|
let to_receive;
|
||||||
|
for (const hash of hashes) {
|
||||||
|
const balance = BigInt(infos[hash].balance);
|
||||||
|
if (!to_receive || balance > to_receive?.balance) {
|
||||||
|
to_receive = {
|
||||||
|
hash,
|
||||||
|
balance,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
console.log(to_receive, balance);
|
||||||
|
}
|
||||||
|
await wallet.receive(to_receive.hash);
|
||||||
const domain_manager = new window.bns.DomainAccountManager(rpc, wallet);
|
const domain_manager = new window.bns.DomainAccountManager(rpc, wallet);
|
||||||
await domain_manager.declare_domain_resolve_to(resolve_to);
|
await domain_manager.declare_domain_resolve_to(resolve_to);
|
||||||
progress = Progress.Done;
|
progress = Progress.Done;
|
||||||
|
|||||||
@@ -59,7 +59,8 @@
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
#main {
|
#main {
|
||||||
height: 100vh;
|
min-height: 100vh;
|
||||||
|
height: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: var(--green);
|
background-color: var(--green);
|
||||||
|
|||||||
Reference in New Issue
Block a user