mirror of
https://github.com/EvernodeXRPL/sashimono.git
synced 2026-04-29 15:38:00 +00:00
NFT token burn modifications (#111)
This commit is contained in:
@@ -113,7 +113,7 @@ class MessageBoard {
|
||||
// Expire the current lease agreement (Burn the instance NFT) and re-minting and creating sell offer for the same lease index.
|
||||
const nft = (await (new evernode.XrplAccount(x.tenant)).getNfts())?.find(n => n.TokenID == x.containerName);
|
||||
const uriInfo = evernode.UtilHelpers.decodeLeaseNftUri(nft.URI);
|
||||
await this.destroyInstance(x.containerName, uriInfo.leaseIndex, this.cfg.xrpl.leaseAmount);
|
||||
await this.destroyInstance(x.containerName, x.tenant, uriInfo.leaseIndex, this.cfg.xrpl.leaseAmount);
|
||||
await this.updateLeaseStatus(x.txHash, LeaseStatus.EXPIRED);
|
||||
console.log(`Destroyed ${x.containerName}`);
|
||||
}
|
||||
@@ -129,9 +129,9 @@ class MessageBoard {
|
||||
this.hostClient.on(evernode.HostEvents.ExtendLease, r => this.handleExtendLease(r));
|
||||
}
|
||||
|
||||
async recreateLeaseOffer(nfTokenId, leaseIndex, leaseAmount) {
|
||||
async recreateLeaseOffer(nfTokenId, tenantAddress, leaseIndex, leaseAmount) {
|
||||
// Burn the NFTs and recreate the offer and send back the lease amount back to the tenant.
|
||||
await this.hostClient.expireLease(nfTokenId).catch(console.error);
|
||||
await this.hostClient.expireLease(nfTokenId, tenantAddress).catch(console.error);
|
||||
await this.hostClient.offerLease(leaseIndex, leaseAmount, appenv.TOS_HASH).catch(console.error);
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ class MessageBoard {
|
||||
console.error(`Sashimono busy timeout. Took: ${diff} ledgers. Threshold: ${threshold}`);
|
||||
// Update the lease status of the request to 'SashiTimeout'.
|
||||
await this.updateAcquireStatus(acquireRefId, LeaseStatus.SASHI_TIMEOUT);
|
||||
await this.recreateLeaseOffer(nfTokenId, leaseIndex, leaseAmount);
|
||||
await this.recreateLeaseOffer(nfTokenId, tenantAddress, leaseIndex, leaseAmount);
|
||||
}
|
||||
else {
|
||||
const instanceRequirements = r.payload;
|
||||
@@ -202,7 +202,7 @@ class MessageBoard {
|
||||
console.error(`Instance creation timeout. Took: ${diff} ledgers. Threshold: ${threshold}`);
|
||||
// Update the lease status of the request to 'SashiTimeout'.
|
||||
await this.updateLeaseStatus(acquireRefId, LeaseStatus.SASHI_TIMEOUT);
|
||||
await this.destroyInstance(createRes.content.name, leaseIndex, leaseAmount);
|
||||
await this.destroyInstance(createRes.content.name, tenantAddress, leaseIndex, leaseAmount);
|
||||
} else {
|
||||
console.log(`Instance created for ${tenantAddress}`);
|
||||
|
||||
@@ -229,7 +229,7 @@ class MessageBoard {
|
||||
|
||||
// Re-create the lease offer (Only if the nft belongs to this request has a lease index).
|
||||
if (leaseIndex >= 0)
|
||||
await this.recreateLeaseOffer(nfTokenId, leaseIndex, leaseAmount).catch(console.error);
|
||||
await this.recreateLeaseOffer(nfTokenId, tenantAddress, leaseIndex, leaseAmount).catch(console.error);
|
||||
|
||||
// Send error transaction with received leaseAmount.
|
||||
await this.hostClient.acquireError(acquireRefId, tenantAddress, leaseAmount, e.content || 'invalid_acquire_lease').catch(console.error);
|
||||
@@ -239,8 +239,8 @@ class MessageBoard {
|
||||
}
|
||||
}
|
||||
|
||||
async destroyInstance(containerName, leaseIndex, leaseAmount) {
|
||||
await this.recreateLeaseOffer(containerName, leaseIndex, leaseAmount).catch(console.error);
|
||||
async destroyInstance(containerName, tenantAddress, leaseIndex, leaseAmount) {
|
||||
await this.recreateLeaseOffer(containerName, tenantAddress, leaseIndex, leaseAmount).catch(console.error);
|
||||
// Destroy the instance.
|
||||
await this.sashiCli.destroyInstance(containerName);
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ class Setup {
|
||||
|
||||
for (const instance of instances) {
|
||||
const nfTokenId = instance.container_name;
|
||||
await xrplAcc.burnNft(nfTokenId);
|
||||
await xrplAcc.burnNft(nfTokenId, instance.tenant_xrp_address);
|
||||
console.log(`Burnt sold hosting NFT (${nfTokenId}) of ${instance.tenant_xrp_address} tenant account`);
|
||||
}
|
||||
}
|
||||
|
||||
6
mb-xrpl/package-lock.json
generated
6
mb-xrpl/package-lock.json
generated
@@ -772,9 +772,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"evernode-js-client": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/evernode-js-client/-/evernode-js-client-0.4.24.tgz",
|
||||
"integrity": "sha512-sRTr3bm94YyAU4R5+BpY1nwlHvXqpVgQIN0L3sjBv3XeP75IIwjshISWznvEZjUQV9DMbWIPjWlOUZit2X66ow==",
|
||||
"version": "0.4.25",
|
||||
"resolved": "https://registry.npmjs.org/evernode-js-client/-/evernode-js-client-0.4.25.tgz",
|
||||
"integrity": "sha512-jlYYwuCRnEUtZ6QVDsjt2ZqYohVRJ8jF+wa0vbU0ZMQdGPlQU/+8gSam9rmANiOlgPawQ+6CNrb7rRQDvLYQ9A==",
|
||||
"requires": {
|
||||
"elliptic": "6.5.4",
|
||||
"ripple-address-codec": "4.2.0",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"build": "npm run lint && ncc build app.js --minify -o dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"evernode-js-client": "0.4.24",
|
||||
"evernode-js-client": "0.4.25",
|
||||
"sqlite3": "5.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user