Skip to content

Commit

Permalink
Merge pull request #5 from ElrondNetwork/development
Browse files Browse the repository at this point in the history
Add NFT Tokens
  • Loading branch information
claudiulataretu authored Jun 7, 2021
2 parents c8d7e8d + 82a11a6 commit bb926b0
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [5.0.1] - 07.06.2021

- [Feat/nft token #3](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/3)

## [5.0.0] - 19.05.2021

- [Remove event target and add callback #310](https://github.com/ElrondNetwork/elrond-sdk/pull/310)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elrondnetwork/erdjs",
"version": "5.0.0",
"version": "5.0.1",
"description": "Smart Contracts interaction framework",
"main": "out/index.js",
"types": "out/index.d.js",
Expand Down
5 changes: 5 additions & 0 deletions src/apiProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Stats } from "./stats";
import { TransactionHash } from "./transaction";
import { TransactionOnNetwork } from "./transactionOnNetwork";
import { ESDTToken } from "./esdtToken";
import { NFTToken } from "./nftToken";
const JSONbig = require("json-bigint");

/**
Expand Down Expand Up @@ -53,6 +54,10 @@ export class ApiProvider implements IApiProvider {
return this.doGetGeneric(`tokens/${tokenIdentifier}`, (response) => ESDTToken.fromHttpResponse(response));
}

async getNFTToken(tokenIdentifier: string): Promise<NFTToken> {
return this.doGetGeneric(`nfts/${tokenIdentifier}`, (response) => NFTToken.fromHttpResponse(response));
}

/**
* Get method that receives the resource url and on callback the method used to map the response.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/esdtToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
export class ESDTToken {
token: string = '';
name: string = '';
type: string = '';
owner: string = '';
minted: string = '';
burnt: string = '';
Expand All @@ -22,6 +23,7 @@ export class ESDTToken {
static fromHttpResponse(response: {
token: string,
name: string,
type: string,
owner: string,
minted: string,
burnt: string,
Expand All @@ -47,4 +49,4 @@ export class ESDTToken {
return this.token;
}

}
}
63 changes: 63 additions & 0 deletions src/nftToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

export class NFTToken {
token: string = '';
name: string = '';
type: string = '';
owner: string = '';
minted: string = '';
burnt: string = '';
decimals: number = 0;
isPaused: boolean = false;
canUpgrade: boolean = false;
canMint: boolean = false;
canBurn: boolean = false;
canChangeOwner: boolean = false;
canPause: boolean = false;
canFreeze: boolean = false;
canWipe: boolean = false;
canAddSpecialRoles: boolean = false;
canTransferNFTCreateRole: boolean = false;
NFTCreateStopped: boolean = false;
wiped: string = '0';

constructor(init?: Partial<NFTToken>) {
Object.assign(this, init);
}

static fromHttpResponse(response: {
token: string,
name: string,
type: string,
owner: string,
minted: string,
burnt: string,
decimals: number,
isPaused: boolean,
canUpgrade: boolean,
canMint: boolean,
canBurn: boolean,
canChangeOwner: boolean,
canPause: boolean,
canFreeze: boolean,
canWipe: boolean,
canAddSpecialRoles: boolean,
canTransferNFTCreateRole: boolean,
NFTCreateStopped: boolean,
wiped: string
}) {
let nftToken = new NFTToken(response);
return nftToken
}

getTokenName() {
return this.name;
}

getTokenIdentifier() {
return this.token;
}

getTokenType() {
return this.type;
}
}

0 comments on commit bb926b0

Please sign in to comment.