diff --git a/package-lock.json b/package-lock.json index 13ae75c..2a1db5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,26 +1,26 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "2.4.1", + "version": "2.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@itheum/sdk-mx-data-nft", - "version": "2.4.1", + "version": "2.5.0", "license": "GPL-3.0-only", "dependencies": { - "@multiversx/sdk-core": "12.11.0", - "@multiversx/sdk-network-providers": "2.0.0", + "@multiversx/sdk-core": "12.17.0", + "@multiversx/sdk-network-providers": "2.2.0", "bignumber.js": "9.1.2", "nft.storage": "7.1.1" }, "devDependencies": { - "@types/jest": "29.5.4", + "@types/jest": "29.5.11", "jest": "29.7.0", "ts-jest": "29.1.1", "tslint": "6.1.3", - "typedoc": "0.25.1", - "typescript": "5.2.2" + "typedoc": "0.25.4", + "typescript": "5.3.3" } }, "node_modules/@ampproject/remapping": { @@ -1042,9 +1042,9 @@ } }, "node_modules/@multiversx/sdk-core": { - "version": "12.11.0", - "resolved": "https://registry.npmjs.org/@multiversx/sdk-core/-/sdk-core-12.11.0.tgz", - "integrity": "sha512-rQRvjx6f1AE8TK5LObxthP7hCUCf6bc9QBAmiOJJ1Na5VS1iPhm5jDqnlCa7oieMb1HYdHQAEkoWNSsPKe/8vA==", + "version": "12.17.0", + "resolved": "https://registry.npmjs.org/@multiversx/sdk-core/-/sdk-core-12.17.0.tgz", + "integrity": "sha512-SdIdUMT4hVgcmNF2uNOZusrxwEJXFtllJ9YOQMJ4V0f1Ajq4fYGWv88OfNGGNaH/I0BAvMZKFsfVL4zgtVekmQ==", "dependencies": { "@multiversx/sdk-transaction-decoder": "1.0.2", "bech32": "1.1.4", @@ -1093,25 +1093,17 @@ } }, "node_modules/@multiversx/sdk-network-providers": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@multiversx/sdk-network-providers/-/sdk-network-providers-2.0.0.tgz", - "integrity": "sha512-87QlwC2kaNtywDv2IVX/cavRfR4D5N7XgqOvsZTyMXRVbfWOUlDocrRr5BdvmC1gDdSOQH++nFEDHiMfnKmRng==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@multiversx/sdk-network-providers/-/sdk-network-providers-2.2.0.tgz", + "integrity": "sha512-2n/+7Ap6S9rJGTiX38GCZ2TmY9zQ1U7o1DwnWpHNRJRxArSN/xzLrbcSKy8InMyc+4A+VHf5pV0Pk8NdPV6++w==", "dependencies": { - "axios": "0.24.0", + "axios": "1.6.1", "bech32": "1.1.4", "bignumber.js": "9.0.1", "buffer": "6.0.3", "json-bigint": "1.0.0" } }, - "node_modules/@multiversx/sdk-network-providers/node_modules/axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", - "dependencies": { - "follow-redirects": "^1.14.4" - } - }, "node_modules/@multiversx/sdk-network-providers/node_modules/bignumber.js": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz", @@ -1286,9 +1278,9 @@ } }, "node_modules/@types/jest": { - "version": "29.5.4", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.4.tgz", - "integrity": "sha512-PhglGmhWeD46FYOVLt3X7TiWjzwuVGW9wG/4qocPevXMjCmrIc5b6db9WjeGE4QYVpUAWMDv3v0IiBwObY289A==", + "version": "29.5.11", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.11.tgz", + "integrity": "sha512-S2mHmYIVe13vrm6q4kN6fLYYAka15ALQki/vgDC3mIukEOx8WJlv0kQPM+d4w8Gp6u0uSdKND04IlTXBv0rwnQ==", "dev": true, "dependencies": { "expect": "^29.0.0", @@ -1509,6 +1501,11 @@ "node": ">=0.10.0" } }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "node_modules/available-typed-arrays": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", @@ -1520,6 +1517,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/axios": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.1.tgz", + "integrity": "sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -1994,6 +2001,17 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", @@ -2124,6 +2142,14 @@ "node": ">=0.10.0" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -2349,9 +2375,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", "funding": [ { "type": "individual", @@ -2375,6 +2401,19 @@ "is-callable": "^1.1.3" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -4090,6 +4129,25 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -4654,6 +4712,11 @@ "pbts": "bin/pbts" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/pure-rand": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.3.tgz", @@ -5472,9 +5535,9 @@ } }, "node_modules/typedoc": { - "version": "0.25.1", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.1.tgz", - "integrity": "sha512-c2ye3YUtGIadxN2O6YwPEXgrZcvhlZ6HlhWZ8jQRNzwLPn2ylhdGqdR8HbyDRyALP8J6lmSANILCkkIdNPFxqA==", + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.4.tgz", + "integrity": "sha512-Du9ImmpBCw54bX275yJrxPVnjdIyJO/84co0/L9mwe0R3G4FSR6rQ09AlXVRvZEGMUg09+z/usc8mgygQ1aidA==", "dev": true, "dependencies": { "lunr": "^2.3.9", @@ -5489,7 +5552,7 @@ "node": ">= 16" }, "peerDependencies": { - "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x" + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x" } }, "node_modules/typedoc/node_modules/brace-expansion": { @@ -5517,9 +5580,9 @@ } }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 84c100b..330929e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "2.4.1", + "version": "2.5.0", "description": "SDK for Itheum's Data NFT Technology on MultiversX Blockchain", "main": "out/index.js", "types": "out/index.d.js", @@ -16,18 +16,18 @@ "author": "Itheum Protocol", "license": "GPL-3.0-only", "dependencies": { - "@multiversx/sdk-core": "12.11.0", - "@multiversx/sdk-network-providers": "2.0.0", + "@multiversx/sdk-core": "12.17.0", + "@multiversx/sdk-network-providers": "2.2.0", "bignumber.js": "9.1.2", "nft.storage": "7.1.1" }, "devDependencies": { - "@types/jest": "29.5.4", + "@types/jest": "29.5.11", "jest": "29.7.0", "ts-jest": "29.1.1", "tslint": "6.1.3", - "typedoc": "0.25.1", - "typescript": "5.2.2" + "typedoc": "0.25.4", + "typescript": "5.3.3" }, "repository": { "type": "git", diff --git a/src/common/mint-utils.ts b/src/common/mint-utils.ts index 5cd7da2..32f6c44 100644 --- a/src/common/mint-utils.ts +++ b/src/common/mint-utils.ts @@ -1,4 +1,4 @@ -import { NFTStorage, File } from 'nft.storage'; +import { File, NFTStorage } from 'nft.storage'; export async function dataNFTDataStreamAdvertise( dataNFTStreamUrl: string, diff --git a/src/common/utils.ts b/src/common/utils.ts index aaa3ec9..4c3cc83 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -1,7 +1,7 @@ import BigNumber from 'bignumber.js'; import { DataNft } from '../datanft'; -import { NftEnumType, NftType, Offer } from '../interfaces'; import { ErrFetch, ErrMissingTrait, ErrMissingValueForTrait } from '../errors'; +import { NftEnumType, NftType, Offer } from '../interfaces'; export function numberToPaddedHex(value: BigNumber.Value) { let hex = new BigNumber(value).toString(16); @@ -56,6 +56,7 @@ export function parseDataNft(value: NftType): DataNft { nonce: value.nonce, collection: value.collection, balance: value.balance ? Number(value.balance) : 0, + owner: value.owner ? value.owner : '', ...DataNft.decodeAttributes(value.attributes) }); } @@ -362,7 +363,7 @@ export function validateSpecificParamsMint(params: { datasetDescription?: string | undefined; royalties?: number | undefined; supply?: number | undefined; - antiSpamTax?: number | undefined; + antiSpamTax?: BigNumber.Value | undefined; _mandatoryParamsList: string[]; // a pure JS fallback way to validate mandatory params, as typescript rules for mandatory can be bypassed by client app }): { allPassed: boolean; diff --git a/src/datanft.ts b/src/datanft.ts index 85f46de..e01ef6d 100644 --- a/src/datanft.ts +++ b/src/datanft.ts @@ -3,6 +3,14 @@ import { BinaryCodec, SignableMessage } from '@multiversx/sdk-core/out'; +import minterAbi from './abis/datanftmint.abi.json'; +import { + checkStatus, + createNftIdentifier, + numberToPaddedHex, + parseDataNft, + validateSpecificParamsViewData +} from './common/utils'; import { Config, EnvironmentsEnum, @@ -10,22 +18,14 @@ import { dataNftTokenIdentifier, networkConfiguration } from './config'; -import { - createNftIdentifier, - numberToPaddedHex, - parseDataNft, - validateSpecificParamsViewData, - checkStatus -} from './common/utils'; -import minterAbi from './abis/datanftmint.abi.json'; -import { NftType, ViewDataReturnType } from './interfaces'; import { ErrAttributeNotSet, ErrDataNftCreate, ErrDecodeAttributes, - ErrFetch, ErrNetworkConfig } from './errors'; +import { NftType, ViewDataReturnType } from './interfaces'; +import BigNumber from 'bignumber.js'; export class DataNft { readonly tokenIdentifier: string = ''; @@ -36,13 +36,14 @@ export class DataNft { readonly tokenName: string = ''; readonly creator: string = ''; readonly creationTime: Date = new Date(); - readonly supply: number = 0; + readonly supply: BigNumber.Value = 0; readonly description: string = ''; readonly title: string = ''; readonly royalties: number = 0; readonly nonce: number = 0; readonly collection: string = ''; - readonly balance: number = 0; + readonly balance: BigNumber.Value = 0; + readonly owner: string = ''; // works if tokenIdentifier is an NFT static networkConfiguration: Config; static apiConfiguration: string; @@ -227,6 +228,26 @@ export class DataNft { return dataNfts; } + /** + * Returns an array of `{address:string,balance:number}` representing the addresses that own the token + */ + async getOwners(): Promise<{ address: string; balance: number }[]> { + if (!this.tokenIdentifier && !this.nonce) { + throw new ErrAttributeNotSet('tokenIdentifier, nonce'); + } + const identifier = createNftIdentifier(this.tokenIdentifier, this.nonce); + + const response = await fetch( + `${DataNft.apiConfiguration}/nfts/${identifier}/accounts` + ); + + checkStatus(response); + + const data = await response.json(); + + return data; + } + /** * Gets the message to sign from the data marshal of the DataNft */ diff --git a/src/index.ts b/src/index.ts index 0159174..e42e430 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ -export * from './marketplace'; export * from './config'; -export * from './interfaces'; export * from './datanft'; +export * from './interfaces'; +export * from './marketplace'; export * from './minter'; export * from './nft-minter'; export * from './sft-minter'; diff --git a/src/marketplace.ts b/src/marketplace.ts index 84d24e8..2de0ebf 100644 --- a/src/marketplace.ts +++ b/src/marketplace.ts @@ -17,16 +17,17 @@ import { VariadicValue } from '@multiversx/sdk-core/out'; import { ApiNetworkProvider } from '@multiversx/sdk-network-providers/out'; +import dataMarketAbi from './abis/data_market.abi.json'; +import { parseOffer } from './common/utils'; import { EnvironmentsEnum, - networkConfiguration, + itheumTokenIdentifier, marketPlaceContractAddress, - itheumTokenIdentifier + networkConfiguration } from './config'; -import dataMarketAbi from './abis/data_market.abi.json'; -import { MarketplaceRequirements, Offer } from './interfaces'; -import { parseOffer } from './common/utils'; import { ErrContractQuery, ErrNetworkConfig } from './errors'; +import { MarketplaceRequirements, Offer } from './interfaces'; +import BigNumber from 'bignumber.js'; // import { ErrContractQuery } from './errors'; export class DataNftMarket { @@ -380,10 +381,10 @@ export class DataNftMarket { senderAddress: IAddress, dataNftIdentifier: string, dataNftNonce: number, - dataNftAmount: number, + dataNftAmount: BigNumber.Value, paymentTokenIdentifier: string, paymentTokenNonce: number, - paymentTokenAmount: number, + paymentTokenAmount: BigNumber.Value, minimumPaymentTokenAmount = 0 ): Transaction { const addOfferTx = new Transaction({ @@ -421,8 +422,8 @@ export class DataNftMarket { acceptOfferWithESDT( senderAddress: IAddress, offerId: number, - amount: number, - price: string, + amount: BigNumber.Value, + price: BigNumber.Value, paymentTokenIdentifier = itheumTokenIdentifier[this.env as EnvironmentsEnum] ): Transaction { const data = new ContractCallPayloadBuilder() @@ -456,8 +457,8 @@ export class DataNftMarket { acceptOfferWithEGLD( senderAddress: IAddress, offerId: number, - amount: number, - price: string + amount: BigNumber.Value, + price: BigNumber.Value ): Transaction { const data = new ContractCallPayloadBuilder() .setFunction(new ContractFunction('acceptOffer')) @@ -486,7 +487,7 @@ export class DataNftMarket { acceptOfferWithNoPayment( senderAddress: IAddress, offerId: number, - amount: number + amount: BigNumber.Value ): Transaction { const data = new ContractCallPayloadBuilder() .setFunction(new ContractFunction('acceptOffer')) @@ -543,7 +544,7 @@ export class DataNftMarket { changeOfferPrice( senderAddress: IAddress, offerId: number, - newPrice: number, + newPrice: BigNumber.Value, newMinimumPaymentTokenAmount = 0 ): Transaction { const changePriceTx = new Transaction({ diff --git a/src/minter.ts b/src/minter.ts index cbc57c9..4150596 100644 --- a/src/minter.ts +++ b/src/minter.ts @@ -1,29 +1,28 @@ import { - SmartContract, - Address, AbiRegistry, - IAddress, - TokenIdentifierValue, + Address, AddressValue, - ResultsParser, - Transaction, + BigUIntValue, + BooleanValue, ContractCallPayloadBuilder, ContractFunction, - U64Value, - BigUIntValue, + IAddress, + ResultsParser, + SmartContract, StringValue, - BooleanValue + TokenIdentifierValue, + Transaction, + U64Value } from '@multiversx/sdk-core/out'; import { ApiNetworkProvider } from '@multiversx/sdk-network-providers/out'; import { EnvironmentsEnum, dataNftTokenIdentifier, imageService, - itheumTokenIdentifier, networkConfiguration } from './config'; -import { SftMinterRequirements } from './interfaces'; import { ErrContractQuery, ErrNetworkConfig } from './errors'; +import BigNumber from 'bignumber.js'; export abstract class Minter { readonly contract: SmartContract; @@ -177,7 +176,7 @@ export abstract class Minter { burn( senderAddress: IAddress, dataNftNonce: number, - quantityToBurn: number, + quantityToBurn: BigNumber.Value, dataNftIdentifier = dataNftTokenIdentifier[this.env as EnvironmentsEnum] ): Transaction { const burnTx = new Transaction({ @@ -262,7 +261,7 @@ export abstract class Minter { setMintTax( senderAddress: IAddress, tokenIdentifier: string, - tax: number + tax: BigNumber.Value ): Transaction { const setMintTaxTx = new Transaction({ value: 0, @@ -289,8 +288,8 @@ export abstract class Minter { */ setRoyaltiesLimits( senderAddress: IAddress, - minRoyalties: number, - maxRoyalties: number + minRoyalties: BigNumber.Value, + maxRoyalties: BigNumber.Value ): Transaction { const setRoyaltiesLimitsTx = new Transaction({ value: 0, @@ -332,6 +331,7 @@ export abstract class Minter { /** Creates a whitelist transaction for the contract * @param senderAddress The address of the sender, must be the admin of the contract * @param addresses The addresses to whitelist + * @param extraGas The extra gas to add to the transaction */ whitelist( @@ -358,6 +358,7 @@ export abstract class Minter { /** Creates a remove whitelist transaction for the contract * @param senderAddress The address of the sender, must be the admin of the contract * @param addresses The addresses to remove from the whitelist + * @param extraGas The extra gas to add to the transaction */ removeWhitelist( senderAddress: IAddress, diff --git a/src/nft-minter.ts b/src/nft-minter.ts index edd8444..a02f122 100644 --- a/src/nft-minter.ts +++ b/src/nft-minter.ts @@ -1,5 +1,4 @@ import { - Address, AddressValue, BigUIntValue, BooleanValue, @@ -12,29 +11,22 @@ import { Transaction, U64Value } from '@multiversx/sdk-core/out'; -import { Minter } from './minter'; import dataNftLeaseAbi from './abis/data-nft-lease.abi.json'; -import { - checkTraitsUrl, - checkUrlIsUp, - validateSpecificParamsMint -} from './common/utils'; import { createFileFromUrl, dataNFTDataStreamAdvertise, storeToIpfs } from './common/mint-utils'; import { - ContractConfiguration, - NftMinterRequirements, - SftMinterRequirements -} from './interfaces'; -import { - ErrArgumentNotSet, - ErrAttributeNotSet, - ErrContractQuery -} from './errors'; + checkTraitsUrl, + checkUrlIsUp, + validateSpecificParamsMint +} from './common/utils'; import { EnvironmentsEnum, itheumTokenIdentifier } from './config'; +import { ErrArgumentNotSet, ErrContractQuery } from './errors'; +import { ContractConfiguration, NftMinterRequirements } from './interfaces'; +import { Minter } from './minter'; +import BigNumber from 'bignumber.js'; export class NftMinter extends Minter { /** @@ -65,7 +57,7 @@ export class NftMinter extends Minter { claimsAddress: IAddress, options?: { taxTokenIdentifier: string; - taxTokenAmount: number; + taxTokenAmount: BigNumber.Value; } ): Transaction { let data; @@ -186,7 +178,7 @@ export class NftMinter extends Minter { traitsUrl?: string; nftStorageToken?: string; antiSpamTokenIdentifier?: string; - antiSpamTax?: number; + antiSpamTax?: BigNumber.Value; } ): Promise { const { @@ -278,7 +270,7 @@ export class NftMinter extends Minter { antiSpamTax && antiSpamTokenIdentifier && antiSpamTokenIdentifier != 'EGLD' && - antiSpamTax > 0 + antiSpamTax > BigNumber(0) ) { data = new ContractCallPayloadBuilder() .setFunction(new ContractFunction('ESDTTransfer')) diff --git a/src/sft-minter.ts b/src/sft-minter.ts index 17e60e2..0711a7d 100644 --- a/src/sft-minter.ts +++ b/src/sft-minter.ts @@ -11,25 +11,26 @@ import { Transaction, U64Value } from '@multiversx/sdk-core/out'; -import { Minter } from './minter'; -import { - EnvironmentsEnum, - itheumTokenIdentifier, - minterContractAddress -} from './config'; import dataNftMinterAbi from './abis/datanftmint.abi.json'; +import { + createFileFromUrl, + dataNFTDataStreamAdvertise, + storeToIpfs +} from './common/mint-utils'; import { checkTraitsUrl, checkUrlIsUp, validateSpecificParamsMint } from './common/utils'; import { - createFileFromUrl, - dataNFTDataStreamAdvertise, - storeToIpfs -} from './common/mint-utils'; + EnvironmentsEnum, + itheumTokenIdentifier, + minterContractAddress +} from './config'; import { ErrArgumentNotSet, ErrContractQuery } from './errors'; import { SftMinterRequirements } from './interfaces'; +import { Minter } from './minter'; +import BigNumber from 'bignumber.js'; export class SftMinter extends Minter { /** @@ -107,7 +108,7 @@ export class SftMinter extends Minter { collectionName: string, tokenTicker: string, antiSpamTaxTokenIdentifier: string, - antiSpamTaxTokenAmount: number, + antiSpamTaxTokenAmount: BigNumber.Value, mintLimit: number, treasury_address: IAddress ): Transaction { @@ -158,7 +159,10 @@ export class SftMinter extends Minter { * @param senderAddress The address of the sender, must be the admin of the contract * @param maxSupply The maximum supply that can be minted */ - setMaxSupply(senderAddress: IAddress, maxSupply: number): Transaction { + setMaxSupply( + senderAddress: IAddress, + maxSupply: BigNumber.Value + ): Transaction { const setMaxSupplyTx = new Transaction({ value: 0, data: new ContractCallPayloadBuilder() @@ -209,7 +213,7 @@ export class SftMinter extends Minter { supply: number, datasetTitle: string, datasetDescription: string, - antiSpamTax: number, + antiSpamTax: BigNumber.Value, options?: { imageUrl?: string; traitsUrl?: string; @@ -307,7 +311,7 @@ export class SftMinter extends Minter { } let data; - if (antiSpamTax > 0) { + if (antiSpamTax > BigNumber(0)) { data = new ContractCallPayloadBuilder() .setFunction(new ContractFunction('ESDTTransfer')) .addArg(new TokenIdentifierValue(antiSpamTokenIdentifier)) diff --git a/tests/datanft.test.ts b/tests/datanft.test.ts index f37f037..bddcebf 100644 --- a/tests/datanft.test.ts +++ b/tests/datanft.test.ts @@ -71,13 +71,24 @@ describe('Data NFT test', () => { DataNft.setNetworkConfig('devnet'); const dataNfts = await DataNft.createManyFromApi([ - { nonce: 62, tokenIdentifier: 'DATANFTFT4-3ba099' }, - { nonce: 2, tokenIdentifier: 'INSP-a65b3b' }, - { nonce: 80 } + { nonce: 1, tokenIdentifier: 'DATANFTFT-e0b917' }, + { nonce: 2, tokenIdentifier: 'DATANFTFT-e0b917' }, + { nonce: 3 } ]); for (const item of dataNfts) { expect(item).toBeInstanceOf(Object as unknown as DataNft); } }, 12000); + + test('#get owners of data Nft', async () => { + DataNft.setNetworkConfig('devnet'); + + let dataNft = new DataNft({ + nonce: 2, + tokenIdentifier: 'DATANFTFT-e0b917' + }); + + const owners = await dataNft.getOwners(); + }); }); diff --git a/tests/marketplace.test.ts b/tests/marketplace.test.ts index d2e01ca..8d3561b 100644 --- a/tests/marketplace.test.ts +++ b/tests/marketplace.test.ts @@ -1,4 +1,4 @@ -import { Address, BigUIntValue, Transaction } from '@multiversx/sdk-core/out'; +import { Address, Transaction } from '@multiversx/sdk-core/out'; import { DataNftMarket, MarketplaceRequirements, Offer } from '../src'; describe('Marketplace Sdk test', () => {