Skip to content

Commit 1cadbb8

Browse files
committed
Add fromConsolidated method on NFT
1 parent e27c4f0 commit 1cadbb8

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/rmrk1.0.0/classes/nft.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,37 @@ export class NFT {
4343
this.burned = "";
4444
}
4545

46+
public fromConsolidated(nft: NFT): NFT {
47+
const {
48+
block,
49+
collection,
50+
name,
51+
instance,
52+
transferable,
53+
sn,
54+
metadata,
55+
...rest
56+
} = nft;
57+
const nftClass = new NFT(
58+
block,
59+
collection,
60+
name,
61+
instance,
62+
transferable,
63+
sn,
64+
metadata
65+
);
66+
const { owner, forsale, reactions, changes, loadedMetadata, burned } = rest;
67+
nftClass.owner = owner;
68+
nftClass.forsale = forsale;
69+
nftClass.reactions = reactions;
70+
nftClass.changes = changes;
71+
nftClass.loadedMetadata = loadedMetadata;
72+
nftClass.burned = burned;
73+
74+
return nftClass;
75+
}
76+
4677
public getId(): string {
4778
if (!this.block)
4879
throw new Error("This token is not minted, so it cannot have an ID.");

src/tools/consolidator/interactions/list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const listForSaleInteraction = (
4242
caller: remark.caller,
4343
block: remark.block,
4444
} as Change);
45+
4546
nft.forsale = listEntity.price;
4647
}
4748
};

0 commit comments

Comments
 (0)