1.4.0 • Published 5 years ago
nft-resolver v1.4.0
nft.resolver
Resolver for non-fungible tokens issued by oasis.asset.
NFT Resolver is a SDK for NFT developer:
NFT generate and sign following
oasis.asset
standard.Customized and generate extended meta data from a NFT.
Check out the API
Installation
Install with npm:
npm install nft-resolver -S
or with yarn:
yarn add nft-resolver -S
Usage
NFT Meta
check out docs.
NFT resolve
import { NFT } from "nft-resolver";
// Initialize with uuid.
const uuid = "123456";
const symbol = "SWORD";
const uri = "oasis://rogeman/OTHER/antsword?subtypes=type1,type2&types1=1&types2=2";
const nft = new NFT(uri, symbol, uuid);
// or initialize without uuid
const nft = new NFT(uri, symbol);
// Get nft uri and meta data decoded from uri
nft.uri // "oasis://rogeman/ARMOR/antsword/other1/other2?subtypes=type1,type2&types1=1&types2=2"
nft.world // "rogeman"
nft.type // "OTHER"
nft.category // "antsword"
nft.params // { subtypes:"type1,type2", type1: "1", types2: "2"}
nft.fragments // ["other1","other2"]
// Set extended meta data
nft.setExtMetaData({
"name": "Asset Name",
"description": "Lorem ipsum...",
"image": "...",
"properties": {
// An example
"simple_property": "example value",
"rich_property": {...}
}
})
nft.extendedMetaData; // the same with above
// Sign nft
const signature = nft.sign('5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3');
// Verify signature
nft.verifySign('EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV');
URI resolve
URI resolver provided a low-level uri assemble or disassemble.
import { NftURI } from "nft-resolver";
const uriString =
"oasis://rogeman/ARMOR/antsword?subtypes=type1,type2&type1=1&type2=2";
const game = "rogeman";
const type = "ARMOR";
const category = "antsword";
const nftUri = new NftURI(game, type, category, {
subtypes: "type1,type2",
type1: "1",
type2: "2",
});
nftUri.raw == uriString; // true
// Sub types manages
nftUri.getParam("type1"); // "1"
nftUri.addParam("type3", "3");
nftUri.rmParam("type3");
// Return all query params
nftUri.allParams(); // Object{"subtypes":"type1,type2","type1":"1","type2":"2"}
Extended Meta data class is provided:
import {NftExtMeta} from 'nft-resolver';
const name = "Asset Name";
const desp = "Simple description";
const image = "https://www.google.com/image/1.jpg";
const properties: Properties = {
simpleProperty: "Simple property",
richProperty:{...} // json object
};
const extMeta = new NftExtMeta(name,desp,image,properties);
// Set new property
extMeta.setProps(newProps);
extMeta.toString();
// {
// "name": "Asset Name",
// "description": "Simple description",
// "image": "https://www.google.com/image/1.jpg",
// "properties": {
// "simple_property": "Simple property",
// "rich_property": {...}
// }
// }
1.4.0
5 years ago
1.3.1
5 years ago
1.3.0
5 years ago
1.2.6
5 years ago
1.2.5
5 years ago
1.2.4
5 years ago
1.2.3
5 years ago
1.2.2
5 years ago
1.2.1
5 years ago
1.2.0
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago