Skip to content

Commit

Permalink
feat: support mulitple asset types
Browse files Browse the repository at this point in the history
  • Loading branch information
wkolod committed Dec 12, 2023
1 parent 4a89564 commit 832cbac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/core/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { StackService } from "./stack";
import { Logger } from "../logger";

const DEFAULT_TICKER = "ATOMIC";
const DEFAULT_TYPE = "image";
const DEFAULT_ASSET_TYPE = "image";
const DEFAULT_CONTRACT_SRC = "Of9pi--Gj7hCTawhgxOwbuWnFI1h24TTgO5pw8ENJNQ"; // Atomic asset contract source
const WARP_MANIFEST = '{"evaluationOptions":{"sourceType":"redstone-sequencer","allowBigInt":true,"internalWrites":true,"unsafeClient":"skip","useConstructor":true}}';

Expand Down Expand Up @@ -371,10 +371,17 @@ export const nftMetadataToTags = (metadata: NFTMetadata): Tags => {
new Tag(smartweaveTags.CONTRACT_SOURCE, metadata.contractTxId || DEFAULT_CONTRACT_SRC),
new Tag(smartweaveTags.INIT_STATE, JSON.stringify(initState)),
new Tag(assetTags.TITLE, metadata.name),
new Tag(assetTags.TYPE, metadata.type || DEFAULT_TYPE),
new Tag('Contract-Manifest', WARP_MANIFEST),
];

if (metadata.types && metadata.types.length > 0) {
for (let type of metadata.types) {
nftTags.push(new Tag(assetTags.TYPE, type));
}
} else {
nftTags.push(new Tag(assetTags.TYPE, DEFAULT_ASSET_TYPE));
}

if (metadata.creator) {
nftTags.push(new Tag('Creator', metadata.creator));
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export enum assetTags {

export type AssetMetadata = {
name?: string, // max 150 characters
type?: AssetType, // default to "image"
types?: AssetType[], // default to "image"
description?: string, // optional description, max 300 characters
topics?: string[],
}
Expand Down

0 comments on commit 832cbac

Please sign in to comment.