Skip to content

Commit

Permalink
feat: add fractional token option for mint
Browse files Browse the repository at this point in the history
  • Loading branch information
wkolod committed Apr 10, 2024
1 parent f0ee0cc commit 2da70c2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/__tests__/nft.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import faker from '@faker-js/faker';
import { initInstance, testDataPath } from './common';
import { email, password } from './data/test-credentials';
import { NodeJs } from "../types/file";
import { DEFAULT_FRACTION_PARTS } from "../core/nft";

let akord: Akord;

Expand Down Expand Up @@ -52,6 +53,7 @@ describe("Testing NFT functions", () => {
expect(nft.creator).toEqual(nftMetadata.creator);
expect(nft.collection).toEqual(nftMetadata.collection);
expect(nft.description).toEqual(nftMetadata.description);
expect(nft.balances[nft.owner]).toEqual(1);
expect(nft.asset.udl?.license).toEqual(UDL_LICENSE_TX_ID);
expect(nft.asset.udl?.licenseFee?.type).toEqual(udl.licenseFee?.type);
expect(nft.asset.udl?.licenseFee?.value).toEqual(udl.licenseFee?.value);
Expand All @@ -78,6 +80,7 @@ describe("Testing NFT functions", () => {
description: "Discover the enchanting world of Flora Fantasy, where nature meets fantasy in mesmerizing digital artworks",
topics: ["floral", "nature"],
types: ["image", "collection"],
fractional: true,
banner: file,
} as CollectionMetadata;

Expand Down Expand Up @@ -111,6 +114,7 @@ describe("Testing NFT functions", () => {
expect(nft.owner).toEqual(collectionMetadata.owner);
expect(nft.creator).toEqual(collectionMetadata.creator);
expect(nft.description).toEqual(collectionMetadata.description);
expect(nft.balances[nft.owner]).toEqual(DEFAULT_FRACTION_PARTS);
expect(nft.asset.udl?.license).toEqual(UDL_LICENSE_TX_ID);
expect(nft.asset.udl?.licenseFee?.type).toEqual(udl.licenseFee?.type);
expect(nft.asset.udl?.licenseFee?.value).toEqual(udl.licenseFee?.value);
Expand Down
3 changes: 2 additions & 1 deletion src/core/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { StackService } from "./stack";
import { isArweaveId } from "../arweave";

const DEFAULT_TICKER = "ATOMIC";
export const DEFAULT_FRACTION_PARTS = 100;

class NFTService extends NodeService<NFT> {
objectType = nodeType.NFT;
Expand Down Expand Up @@ -147,7 +148,7 @@ export const nftMetadataToTags = (metadata: NFTMetadata): Tags => {
owner: metadata.owner,
canEvolve: true,
balances: {
[metadata.owner]: 1,
[metadata.owner]: metadata.fractional ? (metadata.fractionParts || DEFAULT_FRACTION_PARTS) : 1,
},
claimable: []
} as any;
Expand Down
2 changes: 2 additions & 0 deletions src/types/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export type CollectionMetadata = {
contractTxId?: string, // default to "Of9pi--Gj7hCTawhgxOwbuWnFI1h24TTgO5pw8ENJNQ"
banner?: FileSource,
thumbnail?: FileSource,
fractional?: boolean, // allow multiple collectors to own fractions of the same Atomic NFT
fractionParts?: number // used when fractional option is set to true, default to 100
} & AssetMetadata

export type CollectionMintOptions = NFTMintOptions & Hooks
2 changes: 2 additions & 0 deletions src/types/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export type NFTMetadata = {
contractTxId?: string, // default to "Of9pi--Gj7hCTawhgxOwbuWnFI1h24TTgO5pw8ENJNQ"
ticker?: string, // default to "ATOMIC"
thumbnail?: FileSource,
fractional?: boolean, // allow multiple collectors to own fractions of the same Atomic NFT
fractionParts?: number // used when fractional option is set to true, default to 100
} & AssetMetadata

export type NFTMintOptions = {
Expand Down

0 comments on commit 2da70c2

Please sign in to comment.