From c27f9194b71e89ad7f27582d5281535afa2d80ad Mon Sep 17 00:00:00 2001 From: Till <31419678+tifrel@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:36:41 +0100 Subject: [PATCH] FT minting (#500) Co-authored-by: Rui Santiago --- .eslintrc.json | 5 +- package-lock.json | 232 +++++++++++++----- package.json | 4 +- .../attributesByMetaId.test.ts | 4 +- .../src/api/keyActivity/keyActivity.test.ts | 1 - .../ownedNftsByStore/ownedNftsByStore.test.ts | 6 +- .../tokensByAttributes.test.ts | 16 -- .../tokensByAttributes/tokensByAttributes.ts | 6 +- .../api/tokensByStatus/tokensByStatus.test.ts | 1 - .../userMintedTokens/userMintedTokens.test.ts | 13 - .../userOwnedTokens/userOwnedTokens.test.ts | 12 - packages/data/src/graphql/fetch.test.ts | 4 +- packages/data/src/graphql/fetch.ts | 6 +- packages/data/src/types.ts | 2 +- packages/data/src/utils.ts | 3 +- packages/rpc/src/methods/balance.ts | 2 +- packages/rpc/src/methods/blockheight.test.ts | 2 - packages/rpc/src/methods/blockheight.ts | 2 +- packages/rpc/src/methods/getBlockHash.ts | 8 +- packages/rpc/src/methods/getGasPrice.ts | 2 +- packages/rpc/src/methods/getLatestGasPrice.ts | 6 +- packages/rpc/src/methods/keys.ts | 2 +- packages/rpc/src/methods/payouts.test.ts | 19 +- packages/rpc/src/methods/payouts.ts | 11 - packages/rpc/src/methods/txnstatus.test.ts | 4 +- packages/rpc/src/methods/txnstatus.ts | 12 +- packages/rpc/src/util.ts | 7 +- .../batchChangeCreators.test.ts | 1 - .../batchChangeMinters.test.ts | 1 - packages/sdk/src/buy/buy.ts | 1 - packages/sdk/src/createMetadata/README.md | 2 + .../src/createMetadata/createMetadata.test.ts | 38 +++ .../sdk/src/createMetadata/createMetadata.ts | 2 + .../src/deployContract/deployContract.test.ts | 1 - .../sdk/src/deployContract/deployContract.ts | 1 - .../sdk/src/depositStorage/depositStorage.ts | 4 +- packages/sdk/src/list/list.ts | 1 - .../sdk/src/lockMetadata/lockMetadata.test.ts | 2 - packages/sdk/src/lockMetadata/lockMetadata.ts | 3 +- packages/sdk/src/mintOnMetadata/README.md | 3 +- .../src/mintOnMetadata/mintOnMetadata.test.ts | 136 +++++++--- .../sdk/src/mintOnMetadata/mintOnMetadata.ts | 74 ++++-- .../sdk/src/setMintingCap/setMintingCap.ts | 4 +- packages/sdk/src/setSplits/setSplits.ts | 1 - .../transferContractOwnership.ts | 1 - packages/sdk/src/types.ts | 23 +- .../src/updateMetadata/updateMetadata.test.ts | 1 - .../sdk/src/updateMetadata/updateMetadata.ts | 2 +- packages/testing/src/utils.ts | 9 +- ...nsferContractOwnership.integration.test.ts | 5 +- .../mint.w.upload.integration.test.ts | 1 - 51 files changed, 470 insertions(+), 239 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index fea8b3f7d..0ccc511f5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,6 @@ ], "extends": [ "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:react/recommended" ], @@ -25,7 +24,7 @@ "rules": { "@typescript-eslint/explicit-function-return-type": "error", "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/camelcase": "off", + "@typescript-eslint/naming-convention": "off", "brace-style": [ "error", "1tbs", @@ -97,4 +96,4 @@ "browser": true, "es6": true } -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 6b0ba0e32..09f390e30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,8 +38,8 @@ "@types/node": "18.11.9", "@types/react": "18.0.25", "@types/react-dom": "18.0.9", - "@typescript-eslint/eslint-plugin": "^2.31.0", - "@typescript-eslint/parser": "^2.31.0", + "@typescript-eslint/eslint-plugin": "^4.1.1", + "@typescript-eslint/parser": "^4.1.1", "eslint": "^6.6.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-prettier": "^3.1.3", @@ -6764,12 +6764,6 @@ "@types/node": "*" } }, - "node_modules/@types/eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", - "dev": true - }, "node_modules/@types/glob": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", @@ -7113,26 +7107,30 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "2.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz", - "integrity": "sha512-4zY3Z88rEE99+CNvTbXSyovv2z9PNOVffTWD2W8QF5s2prBQtwN2zadqERcrHpcR7O/+KMI3fcTAmUUhK/iQcQ==", + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.33.0.tgz", + "integrity": "sha512-aINiAxGVdOl1eJyVjaWn/YcVAq4Gi/Yo35qHGCnqbWVz61g39D0h23veY/MA0rFFGfxK7TySg2uwDeNv+JgVpg==", "dev": true, "dependencies": { - "@typescript-eslint/experimental-utils": "2.34.0", + "@typescript-eslint/experimental-utils": "4.33.0", + "@typescript-eslint/scope-manager": "4.33.0", + "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", - "regexpp": "^3.0.0", - "tsutils": "^3.17.1" + "ignore": "^5.1.8", + "regexpp": "^3.1.0", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^10.12.0 || >=12.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^2.0.0", - "eslint": "^5.0.0 || ^6.0.0" + "@typescript-eslint/parser": "^4.0.0", + "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -7140,19 +7138,63 @@ } } }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, "node_modules/@typescript-eslint/experimental-utils": { - "version": "2.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz", - "integrity": "sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA==", + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.33.0.tgz", + "integrity": "sha512-zeQjOoES5JFjTnAhI5QY7ZviczMzDptls15GFsI6jyUOq0kOf9+WonkhtlIhh0RgHRnqj5gdNxW5j1EvAyYg6Q==", "dev": true, "dependencies": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.34.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^2.0.0" + "@types/json-schema": "^7.0.7", + "@typescript-eslint/scope-manager": "4.33.0", + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/typescript-estree": "4.33.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" }, "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^10.12.0 || >=12.0.0" }, "funding": { "type": "opencollective", @@ -7163,25 +7205,25 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "2.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.34.0.tgz", - "integrity": "sha512-03ilO0ucSD0EPTw2X4PntSIRFtDPWjrVq7C3/Z3VQHRC7+13YB55rcJI3Jt+YgeHbjUdJPcPa7b23rXCBokuyA==", + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.33.0.tgz", + "integrity": "sha512-ZohdsbXadjGBSK0/r+d87X0SBmKzOq4/S5nzK6SBgJspFo9/CUDJ7hjayuze+JK7CZQLDMroqytp7pOcFKTxZA==", "dev": true, "dependencies": { - "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.34.0", - "@typescript-eslint/typescript-estree": "2.34.0", - "eslint-visitor-keys": "^1.1.0" + "@typescript-eslint/scope-manager": "4.33.0", + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/typescript-estree": "4.33.0", + "debug": "^4.3.1" }, "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^10.12.0 || >=12.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^5.0.0 || ^6.0.0" + "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -7189,22 +7231,52 @@ } } }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.33.0.tgz", + "integrity": "sha512-5IfJHpgTsTZuONKbODctL4kKuQje/bzBRkwHE8UOZ4f89Zeddg+EGZs8PD8NcN4LdM3ygHWYB3ukPAYjvl/qbQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/visitor-keys": "4.33.0" + }, + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.33.0.tgz", + "integrity": "sha512-zKp7CjQzLQImXEpLt2BUw1tvOMPfNoTAfb8l51evhYbOEEzdWyQNmHWWGPR6hwKJDAi+1VXSBmnhL9kyVTTOuQ==", + "dev": true, + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "2.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz", - "integrity": "sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg==", + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz", + "integrity": "sha512-rkWRY1MPFzjwnEVHsxGemDzqqddw2QbTJlICPD9p9I9LfsO8fdmfQPOX3uKfUaGRDFJbfrtm/sXhVXN4E+bzCA==", "dev": true, "dependencies": { - "debug": "^4.1.1", - "eslint-visitor-keys": "^1.1.0", - "glob": "^7.1.6", + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/visitor-keys": "4.33.0", + "debug": "^4.3.1", + "globby": "^11.0.3", "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^7.3.2", - "tsutils": "^3.17.1" + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^10.12.0 || >=12.0.0" }, "funding": { "type": "opencollective", @@ -7229,9 +7301,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -7249,6 +7321,32 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz", + "integrity": "sha512-uqi/2aSz9g2ftcHWf8uLPJA70rUv6yuMW5Bohw+bwcuzaxQIHaKFZCKGoGXIrc9vkTJ3+0txM73K0Hq3d5wgIg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "4.33.0", + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/@walletconnect/core": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.11.0.tgz", @@ -11155,18 +11253,30 @@ } }, "node_modules/eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", "dev": true, "dependencies": { - "eslint-visitor-keys": "^1.1.0" + "eslint-visitor-keys": "^2.0.0" }, "engines": { - "node": ">=6" + "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" }, "funding": { "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=5" + } + }, + "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true, + "engines": { + "node": ">=10" } }, "node_modules/eslint-visitor-keys": { @@ -26791,7 +26901,7 @@ }, "packages/auth": { "name": "@mintbase-js/auth", - "version": "0.6.0-beta.4", + "version": "0.6.0-beta-prerelease.1", "license": "MIT", "dependencies": { "@mintbase-js/sdk": "0.5.2-beta.0", @@ -26850,7 +26960,7 @@ }, "packages/data": { "name": "@mintbase-js/data", - "version": "0.6.0-beta.4", + "version": "0.6.0-beta-prerelease.1", "license": "MIT", "dependencies": { "@mintbase-js/sdk": "^0.5.2-beta.0", @@ -26882,7 +26992,7 @@ }, "packages/react": { "name": "@mintbase-js/react", - "version": "0.6.0-beta.4", + "version": "0.6.0-beta-prerelease.1", "license": "MIT", "dependencies": { "@mintbase-js/wallet": "0.6.0-beta.3", @@ -26973,7 +27083,7 @@ }, "packages/rpc": { "name": "@mintbase-js/rpc", - "version": "0.6.0-beta.4", + "version": "0.6.0-beta-prerelease.1", "license": "MIT", "dependencies": { "@mintbase-js/sdk": "0.5.6-rpc-fix-1aec566.0", @@ -27004,7 +27114,7 @@ }, "packages/sdk": { "name": "@mintbase-js/sdk", - "version": "0.6.0-beta.4", + "version": "0.6.0-beta-prerelease.1", "license": "MIT", "dependencies": { "bn.js": "5.2.1", @@ -27031,7 +27141,7 @@ }, "packages/storage": { "name": "@mintbase-js/storage", - "version": "0.6.0-beta.4", + "version": "0.6.0-beta-prerelease.1", "license": "MIT", "dependencies": { "@mintbase-js/sdk": "0.5.2-beta.0", @@ -27066,12 +27176,12 @@ }, "packages/testing": { "name": "@mintbase-js/testing", - "version": "0.6.0-beta.4", + "version": "0.6.0-beta-prerelease.1", "license": "MIT", "dependencies": { "@google-cloud/firestore": "^6.8.0", "@google-cloud/secret-manager": "^4.2.2", - "@mintbase-js/auth": "^0.6.0-beta.4", + "@mintbase-js/auth": "^0.6.0-beta-prerelease.1", "@mintbase-js/sdk": "^0.3.2-upgrade-packages-3378beb.0", "graphql-request": "^5.2.0" }, @@ -27141,7 +27251,7 @@ }, "packages/wallet": { "name": "@mintbase-js/wallet", - "version": "0.6.0-beta.4", + "version": "0.6.0-beta-prerelease.1", "license": "MIT", "dependencies": { "@near-wallet-selector/core": "8.9.5", diff --git a/package.json b/package.json index e03858adf..7ccf64dba 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "@types/node": "18.11.9", "@types/react": "18.0.25", "@types/react-dom": "18.0.9", - "@typescript-eslint/eslint-plugin": "^2.31.0", - "@typescript-eslint/parser": "^2.31.0", + "@typescript-eslint/eslint-plugin": "^4.1.1", + "@typescript-eslint/parser": "^4.1.1", "eslint": "^6.6.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-prettier": "^3.1.3", diff --git a/packages/data/src/api/attributesByMetaId/attributesByMetaId.test.ts b/packages/data/src/api/attributesByMetaId/attributesByMetaId.test.ts index c788003ce..d6aa8ae27 100644 --- a/packages/data/src/api/attributesByMetaId/attributesByMetaId.test.ts +++ b/packages/data/src/api/attributesByMetaId/attributesByMetaId.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { GraphQLClient } from 'graphql-request'; import { Attribute, NftAttributesQueryResult } from '../../types'; import { attributesByMetaId } from './attributesByMetaId'; @@ -48,7 +47,7 @@ describe('attributesByMetaId', () => { 'attribute_type': 'BidAmount', }]; (GraphQLClient as jest.Mock).mockImplementationOnce(() => ({ - request: (env: 'testnet'): Promise => + request: (): Promise => Promise.resolve({ nft_attributes: attributes, }), @@ -58,4 +57,3 @@ describe('attributesByMetaId', () => { }); }); - diff --git a/packages/data/src/api/keyActivity/keyActivity.test.ts b/packages/data/src/api/keyActivity/keyActivity.test.ts index 48c57ae72..6b9e72751 100644 --- a/packages/data/src/api/keyActivity/keyActivity.test.ts +++ b/packages/data/src/api/keyActivity/keyActivity.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { GraphQLClient } from 'graphql-request'; import { keyActivity } from './keyActivity'; import { KEY_ACTIVITY_MOCK } from './keyActivity.mock'; diff --git a/packages/data/src/api/ownedNftsByStore/ownedNftsByStore.test.ts b/packages/data/src/api/ownedNftsByStore/ownedNftsByStore.test.ts index f4161461e..d54b58e50 100644 --- a/packages/data/src/api/ownedNftsByStore/ownedNftsByStore.test.ts +++ b/packages/data/src/api/ownedNftsByStore/ownedNftsByStore.test.ts @@ -57,7 +57,7 @@ describe('tokenById', () => { const errorMessage = 'Error fetching nfts from undefined, please check the arguments provided'; - // eslint-disable-next-line @typescript-eslint/ban-ts-ignore + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const call = await ownedNftsByStore({ ownerId: undefined }); @@ -73,7 +73,7 @@ describe('tokenById', () => { const errorMessage = 'Error fetching nfts from test1.mintbase.near, please check the arguments provided'; - // eslint-disable-next-line @typescript-eslint/ban-ts-ignore + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const call = await ownedNftsByStore({ ownerId: 'test1.mintbase.near', contractAddress: 'aaa' }); @@ -89,7 +89,7 @@ describe('tokenById', () => { const errorMessage = 'Error fetching nfts from test1.mintbase.near, please check the arguments provided'; - // eslint-disable-next-line @typescript-eslint/ban-ts-ignore + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const call = await ownedNftsByStore({ ownerId: 'test1.mintbase.near', pagination: { limit: 'xxx', offset: 0 }, contractAddress: 'aaa' }); diff --git a/packages/data/src/api/tokensByAttributes/tokensByAttributes.test.ts b/packages/data/src/api/tokensByAttributes/tokensByAttributes.test.ts index f58865388..b3bf01c10 100644 --- a/packages/data/src/api/tokensByAttributes/tokensByAttributes.test.ts +++ b/packages/data/src/api/tokensByAttributes/tokensByAttributes.test.ts @@ -34,14 +34,6 @@ describe('tokensByAttributes', () => { it('returns data and converts ', async () => { fetchMock.mock(`begin:${META_SERVICE_HOST_TESTNET}`, { body: { results: [{ token_id: '123' }] } }); - const query = { - filters: { - 'eyes': ['blue', 'green'], - 'face': ['busted'], - }, - limit: 10, - offset: 0, - }; const { data } = await tokensByAttributes(props) as ParsedDataReturn; expect(data).toBeDefined(); expect(data?.results[0].tokenId).toBeDefined(); @@ -49,14 +41,6 @@ describe('tokensByAttributes', () => { it('returns errors', async () => { fetchMock.mock(`begin:${META_SERVICE_HOST_TESTNET}`, 504, { overwriteRoutes: true }); - const query = { - filters: { - 'eyes': ['blue', 'green'], - 'face': ['busted'], - }, - limit: 10, - offset: 0, - }; const { error } = await tokensByAttributes(props); expect(error).toBeDefined(); }); diff --git a/packages/data/src/api/tokensByAttributes/tokensByAttributes.ts b/packages/data/src/api/tokensByAttributes/tokensByAttributes.ts index b627df80a..0cd137d0e 100644 --- a/packages/data/src/api/tokensByAttributes/tokensByAttributes.ts +++ b/packages/data/src/api/tokensByAttributes/tokensByAttributes.ts @@ -1,4 +1,4 @@ -import { Network, mbjs } from '@mintbase-js/sdk'; +import { mbjs } from '@mintbase-js/sdk'; import { META_SERVICE_HOST, META_SERVICE_HOST_TESTNET, MINTBASE_API_KEY_HEADER } from '../../constants'; import { ParsedDataReturn } from '../../types'; import { objectWithCamelKeys, parseData } from '../../utils'; @@ -13,7 +13,7 @@ export const tokensByAttributes = async ({ }: TokensByAttributesProps, ): Promise> => { - let data; + let data: { results: FilteredMetadataResult[], totalRecords: number }; let error: string; const networkFinal = network || mbjs.keys.network; @@ -40,7 +40,7 @@ export const tokensByAttributes = async ({ data = await res.json(); // transform results to camel case - data.results = data.results.map(objectWithCamelKeys); + data.results = data.results.map(objectWithCamelKeys) as FilteredMetadataResult[]; } catch (err) { error = `Error fetching filtered data, ${err}`; diff --git a/packages/data/src/api/tokensByStatus/tokensByStatus.test.ts b/packages/data/src/api/tokensByStatus/tokensByStatus.test.ts index e02ee5a1c..1d55ab5c6 100644 --- a/packages/data/src/api/tokensByStatus/tokensByStatus.test.ts +++ b/packages/data/src/api/tokensByStatus/tokensByStatus.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { GraphQLClient } from 'graphql-request'; import { tokensByStatus, tokensByStatusThrowOnError } from './tokensByStatus'; import { TOKEN_RESULT_MOCK } from './tokenByStatus.mock'; diff --git a/packages/data/src/api/userMintedTokens/userMintedTokens.test.ts b/packages/data/src/api/userMintedTokens/userMintedTokens.test.ts index cbf93bc48..efebaf286 100644 --- a/packages/data/src/api/userMintedTokens/userMintedTokens.test.ts +++ b/packages/data/src/api/userMintedTokens/userMintedTokens.test.ts @@ -30,27 +30,14 @@ describe('userMintedTokens', () => { it('owned user tokens', async () => { fetchMock.mock(`begin:${META_SERVICE_HOST_TESTNET}`, { body: { results: [{ token_id: '123' }] } }); - const filters: UserTokensFilter = { - orderBy: OWNED_MINTED_ORDER_BY.MINTED, - limit: 10, - offset: 0, - listedFilter: true, - }; const { data } = await getUserMintedTokens(props) as ParsedDataReturn; - console.log(data); expect(data?.results).toBeDefined(); }); it('returns errors', async () => { fetchMock.mock(`begin:${META_SERVICE_HOST_TESTNET}`, 504, { overwriteRoutes: true }); - const filters = { - orderBy: OWNED_MINTED_ORDER_BY.MINTED, - limit: 10, - offset: 0, - listedFilter: true, - }; const { error } = await getUserMintedTokens(props); expect(error).toBeDefined(); }); diff --git a/packages/data/src/api/userOwnedTokens/userOwnedTokens.test.ts b/packages/data/src/api/userOwnedTokens/userOwnedTokens.test.ts index 223e6a347..fb4bad15f 100644 --- a/packages/data/src/api/userOwnedTokens/userOwnedTokens.test.ts +++ b/packages/data/src/api/userOwnedTokens/userOwnedTokens.test.ts @@ -31,24 +31,12 @@ describe('userOwnedTokens', () => { it('owned user tokens', async () => { fetchMock.mock(`begin:${META_SERVICE_HOST_TESTNET}`, { body: { results: [{ token_id: '123' }] } }); - const filters: UserTokensFilter = { - orderBy: OWNED_MINTED_ORDER_BY.MINTED, - limit: 10, - offset: 0, - listedFilter: true, - }; const { data } = await getUserOwnedTokens(props) as ParsedDataReturn; expect(data?.results).toBeDefined(); }); it('returns errors', async () => { fetchMock.mock(`begin:${META_SERVICE_HOST_TESTNET}`, 504, { overwriteRoutes: true }); - const filters = { - orderBy: OWNED_MINTED_ORDER_BY.MINTED, - limit: 10, - offset: 0, - listedFilter: true, - }; const { error } = await getUserOwnedTokens(props); expect(error).toBeDefined(); }); diff --git a/packages/data/src/graphql/fetch.test.ts b/packages/data/src/graphql/fetch.test.ts index a370db05c..e87da2b3a 100644 --- a/packages/data/src/graphql/fetch.test.ts +++ b/packages/data/src/graphql/fetch.test.ts @@ -26,9 +26,9 @@ describe('graphql/fetch', () => { // }); it('should return invalid Network Error Message if network is wrong', async () => { - // eslint-disable-next-line @typescript-eslint/ban-ts-ignore + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - const { data, error } = await fetchGraphQl({ query: fakeQuery, network: 'aaaa' }); + const { error } = await fetchGraphQl({ query: fakeQuery, network: 'aaaa' }); expect(error).toBeDefined(); expect(error).toBe('Please add a valid Network'); }); diff --git a/packages/data/src/graphql/fetch.ts b/packages/data/src/graphql/fetch.ts index 9a80770de..89d7d0ec2 100644 --- a/packages/data/src/graphql/fetch.ts +++ b/packages/data/src/graphql/fetch.ts @@ -1,5 +1,5 @@ import { DocumentNode } from 'graphql'; -import { GraphQLClient } from 'graphql-request'; +import { GraphQLClient, Variables } from 'graphql-request'; import { getErrorMessage } from '../errorHandling'; import { GRAPHQL_ENDPOINTS, mbjs, NEAR_NETWORKS, Network } from '@mintbase-js/sdk'; @@ -17,7 +17,7 @@ export const fetchGraphQl = async >({ network, }: { query: DocumentNode | string; - variables?: any; + variables?: V; network?: Network | null | undefined; }): Promise> => { @@ -44,7 +44,7 @@ export const fetchGraphQl = async >({ try { const client = new GraphQLClient(graphqlEndpoint); return { - data: await client.request(query, variables), + data: await client.request(query, variables as Variables), }; } catch (error:unknown) { diff --git a/packages/data/src/types.ts b/packages/data/src/types.ts index be5bd6974..dbd9ae019 100644 --- a/packages/data/src/types.ts +++ b/packages/data/src/types.ts @@ -54,7 +54,7 @@ export type UserTokensQueryResult = { export interface ReferenceBlob { tags?: Array; type?: string; - extra?: Array<{ trait_type?: string; value?: any; display_type?: string }>; + extra?: Array<{ trait_type?: string; value?: unknown; display_type?: string }>; media?: string; store?: string; title?: string; diff --git a/packages/data/src/utils.ts b/packages/data/src/utils.ts index 49abd5927..673dece5e 100644 --- a/packages/data/src/utils.ts +++ b/packages/data/src/utils.ts @@ -8,7 +8,7 @@ const toCamel = (s: string): string => { }); }; -export const objectWithCamelKeys = (obj: object): object => Object +export const objectWithCamelKeys = (obj: Record): Record => Object .keys(obj) .map((key) => ({ snake: key, @@ -48,4 +48,3 @@ export const validTokenId = (tokenId: string | number): boolean => { ? /^\d+$/.test(tokenId) : /^\d+$/.test(tokenId.toString()); }; - diff --git a/packages/rpc/src/methods/balance.ts b/packages/rpc/src/methods/balance.ts index c8f73017c..bfce4de29 100644 --- a/packages/rpc/src/methods/balance.ts +++ b/packages/rpc/src/methods/balance.ts @@ -13,7 +13,7 @@ export const getBalance = async (accountId: string, network?: Network, rpc?: RPC account_id: accountId, }, }, network, rpc); - const balanceString = res?.result?.amount; + const balanceString = res?.result?.amount as string; if (!balanceString) { throw new Error(`Malformed response: ${JSON.stringify(res)}`); } diff --git a/packages/rpc/src/methods/blockheight.test.ts b/packages/rpc/src/methods/blockheight.test.ts index 495cc2bf2..608ca2334 100644 --- a/packages/rpc/src/methods/blockheight.test.ts +++ b/packages/rpc/src/methods/blockheight.test.ts @@ -8,9 +8,7 @@ describe('getBlockHeight', () => { (fetch as jest.Mock).mockResolvedValueOnce({ json: jest.fn().mockResolvedValueOnce({ result: { - // eslint-disable-next-line @typescript-eslint/camelcase sync_info: { - // eslint-disable-next-line @typescript-eslint/camelcase latest_block_height: 123, }, }, diff --git a/packages/rpc/src/methods/blockheight.ts b/packages/rpc/src/methods/blockheight.ts index 7e53d7c78..cf79a7dd7 100644 --- a/packages/rpc/src/methods/blockheight.ts +++ b/packages/rpc/src/methods/blockheight.ts @@ -8,7 +8,7 @@ export const getBlockHeight = async (network?: Network, rpc?: RPC_OPTIONS): Pro method: 'status', params: [], }, network, rpc); - const blockHeight = res?.result?.sync_info?.latest_block_height; + const blockHeight = (res?.result?.sync_info as {latest_block_height: number})?.latest_block_height; if (!blockHeight) { throw new Error(`Malformed response: ${JSON.stringify(res)}`); } diff --git a/packages/rpc/src/methods/getBlockHash.ts b/packages/rpc/src/methods/getBlockHash.ts index 3a73f953f..780235eab 100644 --- a/packages/rpc/src/methods/getBlockHash.ts +++ b/packages/rpc/src/methods/getBlockHash.ts @@ -1,16 +1,16 @@ import { Network } from '@mintbase-js/sdk'; import { RPC_OPTIONS, requestFromNearRpc } from '../util'; -export const getBlockHash = async (network?: Network, rpc?: RPC_OPTIONS): Promise => { +export const getBlockHash = async (network?: Network, rpc?: RPC_OPTIONS): Promise => { const res = await requestFromNearRpc({ jsonrpc: '2.0', id: 'dontcare', method: 'status', params: [], }, network, rpc); - const blockHeight = res?.result?.sync_info?.latest_block_hash; - if (!blockHeight) { + const blockHash = (res?.result?.sync_info as {latest_block_hash: string})?.latest_block_hash; + if (!blockHash) { throw new Error(`Malformed response: ${JSON.stringify(res)}`); } - return blockHeight; + return blockHash; }; diff --git a/packages/rpc/src/methods/getGasPrice.ts b/packages/rpc/src/methods/getGasPrice.ts index 89f5c1584..f55ad8d68 100644 --- a/packages/rpc/src/methods/getGasPrice.ts +++ b/packages/rpc/src/methods/getGasPrice.ts @@ -8,7 +8,7 @@ export const getGasPrice = async (hash?: string, network?: Network, rpc?: RPC_OP method: 'gas_price', params: [hash || null], }, network, rpc); - const gasPrice = res?.result?.gas_price; + const gasPrice = res?.result?.gas_price as number; if (!gasPrice) { throw new Error(`Malformed response: ${JSON.stringify(res)}`); } diff --git a/packages/rpc/src/methods/getLatestGasPrice.ts b/packages/rpc/src/methods/getLatestGasPrice.ts index 09912e250..cafdbcd20 100644 --- a/packages/rpc/src/methods/getLatestGasPrice.ts +++ b/packages/rpc/src/methods/getLatestGasPrice.ts @@ -8,9 +8,9 @@ export const getLatestGasPrice = async (network?: Network, rpc?: RPC_OPTIONS): P method: 'gas_price', params: [null], }, network, rpc); - const blockHeight = res?.result?.gas_price; - if (!blockHeight) { + const gasPrice = res?.result?.gas_price as string; + if (!gasPrice) { throw new Error(`Malformed response: ${JSON.stringify(res)}`); } - return blockHeight; + return gasPrice; }; diff --git a/packages/rpc/src/methods/keys.ts b/packages/rpc/src/methods/keys.ts index 09fd16ef5..91fe3538f 100644 --- a/packages/rpc/src/methods/keys.ts +++ b/packages/rpc/src/methods/keys.ts @@ -28,7 +28,7 @@ export const getAccessKeys = async (accountId: string, network?: Network, rpc?: }, }, network, rpc); - const accessKeys = res?.result?.keys; + const accessKeys = res?.result?.keys as AccessKey[]; if (res?.error) { throw res.error; diff --git a/packages/rpc/src/methods/payouts.test.ts b/packages/rpc/src/methods/payouts.test.ts index e0471f7d6..4979cc6aa 100644 --- a/packages/rpc/src/methods/payouts.test.ts +++ b/packages/rpc/src/methods/payouts.test.ts @@ -44,14 +44,25 @@ describe('payouts rpc call', () => { }); }); -const isPercentFloat = (x: any): boolean => { +const isPercentFloat = (x: unknown): boolean => { return typeof x === 'number' && x >= 0 && x <= 100; }; -const isAccountPercent = (x: any): boolean => { - return typeof x.account === 'string' && isPercentInt(x.percent); +type AccountPercent = { + account: string; + percent: number; +} + +const isAccountPercent = (x: unknown): x is AccountPercent => { + if (['undefined', 'null'].includes(typeof x)) { + return false; + } + return ( + typeof (x as AccountPercent).account === 'string' && + isPercentInt((x as AccountPercent).percent) + ); }; -const isPercentInt = (x: any): boolean => { +const isPercentInt = (x: unknown): boolean => { return typeof x === 'number' && x >= 0 && x <= 10000; }; diff --git a/packages/rpc/src/methods/payouts.ts b/packages/rpc/src/methods/payouts.ts index 66c2856e1..5731032fb 100644 --- a/packages/rpc/src/methods/payouts.ts +++ b/packages/rpc/src/methods/payouts.ts @@ -1,17 +1,6 @@ import { Network } from '@mintbase-js/sdk'; import { RPC_OPTIONS, callViewMethod } from '../util'; -type Numerator = { - numerator: number; -}; - -type Payouts = { - royalty: { - split_between: Record; - percentage: Numerator; - }; -}; - type NepPayout = { payout: Record; }; diff --git a/packages/rpc/src/methods/txnstatus.test.ts b/packages/rpc/src/methods/txnstatus.test.ts index 8371da315..2cfaff95e 100644 --- a/packages/rpc/src/methods/txnstatus.test.ts +++ b/packages/rpc/src/methods/txnstatus.test.ts @@ -6,12 +6,10 @@ jest.mock('cross-fetch'); describe('getTxnStatus', () => { - // eslint-disable-next-line @typescript-eslint/camelcase - const mockResponseWithReceipts = (receipts_outcome: object): void => { + const mockResponseWithReceipts = (receipts_outcome: unknown): void => { (fetch as jest.Mock).mockResolvedValueOnce({ json: jest.fn().mockResolvedValueOnce({ result: { - // eslint-disable-next-line @typescript-eslint/camelcase receipts_outcome, }, }), diff --git a/packages/rpc/src/methods/txnstatus.ts b/packages/rpc/src/methods/txnstatus.ts index 0214d2c07..6adf1f4c0 100644 --- a/packages/rpc/src/methods/txnstatus.ts +++ b/packages/rpc/src/methods/txnstatus.ts @@ -3,6 +3,16 @@ import { RPC_OPTIONS, requestFromNearRpc } from '../util'; export type TxnStatus = 'pending' | 'success' | 'failure'; +type ReceiptOutcome = { + outcome: { + status: { + Unknown: unknown; + Failure: unknown; + Success: unknown; + } + } +} + export const getTxnStatus = async ( txnHash: string, senderId: string, @@ -24,7 +34,7 @@ export const getTxnStatus = async ( if (!(res.result?.receipts_outcome instanceof Array)) { throw new Error(`Malformed response: ${JSON.stringify(res)}`); } - res.result?.receipts_outcome?.forEach((outcome: any) => { + res.result?.receipts_outcome?.forEach((outcome: ReceiptOutcome) => { if (!outcome?.outcome?.status) { throw new Error(`Malformed response: ${JSON.stringify(res)}`); } diff --git a/packages/rpc/src/util.ts b/packages/rpc/src/util.ts index 2ec5b9a69..6d592f687 100644 --- a/packages/rpc/src/util.ts +++ b/packages/rpc/src/util.ts @@ -6,10 +6,10 @@ export type RPC_OPTIONS = 'lava' | 'near' | 'beta' export const requestFromNearRpc = async ( - body: Record, + body: Record, network?: string, rpc?: RPC_OPTIONS, -): Promise | undefined> => { +): Promise<{ result: Record, error: unknown } | undefined> => { const fetchUrl = mbjs.keys.nearRpcUrl || RPC_ENDPOINTS[mbjs.keys.rpc][mbjs.keys.network] || NEAR_RPC_ENDPOINTS[mbjs.keys.network]; const rpcAddress = network && rpc ? RPC_ENDPOINTS[rpc][network] : fetchUrl; @@ -56,7 +56,8 @@ export const callViewMethod = async ({ if (res?.error) { throw res.error; } - + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore const parsed = JSON.parse(Buffer.from(res?.result?.result).toString()); return parsed as T; }; diff --git a/packages/sdk/src/batchChangeCreators/batchChangeCreators.test.ts b/packages/sdk/src/batchChangeCreators/batchChangeCreators.test.ts index fbe700512..98048f9dd 100644 --- a/packages/sdk/src/batchChangeCreators/batchChangeCreators.test.ts +++ b/packages/sdk/src/batchChangeCreators/batchChangeCreators.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { batchChangeCreators } from './batchChangeCreators'; import { GAS, ONE_YOCTO } from '../constants'; import { TOKEN_METHOD_NAMES } from '../types'; diff --git a/packages/sdk/src/batchChangeMinters/batchChangeMinters.test.ts b/packages/sdk/src/batchChangeMinters/batchChangeMinters.test.ts index 9c086655f..397f93e22 100644 --- a/packages/sdk/src/batchChangeMinters/batchChangeMinters.test.ts +++ b/packages/sdk/src/batchChangeMinters/batchChangeMinters.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { batchChangeMinters } from './batchChangeMinters'; import { GAS, ONE_YOCTO } from '../constants'; import { TOKEN_METHOD_NAMES } from '../types'; diff --git a/packages/sdk/src/buy/buy.ts b/packages/sdk/src/buy/buy.ts index ea54c9f90..79b20afd7 100644 --- a/packages/sdk/src/buy/buy.ts +++ b/packages/sdk/src/buy/buy.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { mbjs } from '../config/config'; import { MAX_GAS, ONE_YOCTO } from '../constants'; import { ERROR_MESSAGES } from '../errorMessages'; diff --git a/packages/sdk/src/createMetadata/README.md b/packages/sdk/src/createMetadata/README.md index d0927c2f1..43be724c4 100644 --- a/packages/sdk/src/createMetadata/README.md +++ b/packages/sdk/src/createMetadata/README.md @@ -8,6 +8,8 @@ The reference material is typically uploaded to IPFS or Arweave and can be easil Royalties can be configured to provide a customized flow of funds as explained below. +Using the `ftAddress` parameter, you can specify that you want the minting price for this token to be paid via the desired fungible token. + You can restrict minting via an allowlist of NEAR account IDs that are allowed to mint (`mintersAllowslist`), via a maximum supply that will be enforced by the smart contract (`maxSupply`), and via an expiry date (`lastPossibleMint`). You can opt-in to making an NFT dynamic (`isDynamic`) to allow [future updates](../updateMetadata/README.md), and [lock the metadata](../lockMetadata/README.md) at a later time. The `nftContactId` can be supplied as an argument or through the `TOKEN_CONTRACT` environment variable. diff --git a/packages/sdk/src/createMetadata/createMetadata.test.ts b/packages/sdk/src/createMetadata/createMetadata.test.ts index f1e497ff4..998236eb2 100644 --- a/packages/sdk/src/createMetadata/createMetadata.test.ts +++ b/packages/sdk/src/createMetadata/createMetadata.test.ts @@ -26,6 +26,7 @@ describe('createMetadata method tests', () => { media: media, }, price: `1${'0'.repeat(24)}`, + ft_contract_id: null, metadata_id: null, royalty_args: null, minters_allowlist: null, @@ -55,6 +56,7 @@ describe('createMetadata method tests', () => { media: media, }, price: `1${'0'.repeat(24)}`, + ft_contract_id: null, metadata_id: '1', royalty_args: null, minters_allowlist: null, @@ -84,6 +86,7 @@ describe('createMetadata method tests', () => { media: media, }, price: `1${'0'.repeat(24)}`, + ft_contract_id: null, metadata_id: null, royalty_args: null, minters_allowlist: ['foo', 'bar'], @@ -113,6 +116,7 @@ describe('createMetadata method tests', () => { media: media, }, price: `1${'0'.repeat(24)}`, + ft_contract_id: null, metadata_id: null, royalty_args: null, minters_allowlist: null, @@ -142,6 +146,7 @@ describe('createMetadata method tests', () => { media: media, }, price: `1${'0'.repeat(24)}`, + ft_contract_id: null, metadata_id: null, royalty_args: null, minters_allowlist: null, @@ -171,6 +176,7 @@ describe('createMetadata method tests', () => { media: media, }, price: `1${'0'.repeat(24)}`, + ft_contract_id: null, metadata_id: null, royalty_args: null, minters_allowlist: null, @@ -200,6 +206,7 @@ describe('createMetadata method tests', () => { media: media, }, price: `1${'0'.repeat(24)}`, + ft_contract_id: null, metadata_id: null, royalty_args: { percentage: 4008, @@ -219,6 +226,37 @@ describe('createMetadata method tests', () => { }); }); + test('createMetadata with FT payment', () => { + const wnearAddress = 'wnear.near'; + const args = createMetadata({ + contractAddress: contractAddress, + metadata: { reference, media }, + price: 1, + ftAddress: wnearAddress, + }); + + expect(args).toEqual({ + contractAddress: contractAddress, + methodName: TOKEN_METHOD_NAMES.CREATE_METADATA, + args: { + metadata: { + reference: reference, + media: media, + }, + price: `1${'0'.repeat(24)}`, + ft_contract_id: wnearAddress, + metadata_id: null, + royalty_args: null, + minters_allowlist: null, + max_supply: null, + last_possible_mint: null, + is_dynamic: null, + }, + deposit: '2950000000000000000000', + gas: GAS, + }); + }); + test('createMetadata with too many royalties', () => { expect(() => { createMetadata({ diff --git a/packages/sdk/src/createMetadata/createMetadata.ts b/packages/sdk/src/createMetadata/createMetadata.ts index ce1f3a003..ab47e0a74 100644 --- a/packages/sdk/src/createMetadata/createMetadata.ts +++ b/packages/sdk/src/createMetadata/createMetadata.ts @@ -25,6 +25,7 @@ export const createMetadata = ( isDynamic = null, noMedia = false, noReference = false, + ftAddress = null, } = args; if (!contractAddress) { @@ -61,6 +62,7 @@ export const createMetadata = ( last_possible_mint: lastPossibleMint ? (+lastPossibleMint * 1e6).toString() : null, is_dynamic: isDynamic, price: new BN(price * 1e6).mul(new BN(`1${'0'.repeat(18)}`)).toString(), + ft_contract_id: ftAddress, }, methodName: TOKEN_METHOD_NAMES.CREATE_METADATA, gas: GAS, diff --git a/packages/sdk/src/deployContract/deployContract.test.ts b/packages/sdk/src/deployContract/deployContract.test.ts index 0a830a586..aa87bcb57 100644 --- a/packages/sdk/src/deployContract/deployContract.test.ts +++ b/packages/sdk/src/deployContract/deployContract.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { mbjs } from '../config/config'; import { CONTRACT_DEPOSIT, DEFAULT_MB_LOGO, DEFAULT_MB_BASE_URI, GAS_CONSTANTS } from '../constants'; import { TOKEN_METHOD_NAMES } from '../types'; diff --git a/packages/sdk/src/deployContract/deployContract.ts b/packages/sdk/src/deployContract/deployContract.ts index f8a02771e..203bad77f 100644 --- a/packages/sdk/src/deployContract/deployContract.ts +++ b/packages/sdk/src/deployContract/deployContract.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { mbjs } from '../config/config'; import { CONTRACT_DEPOSIT, DEFAULT_MB_LOGO, GAS_CONSTANTS, TOKEN_CONTRACT_SPEC } from '../constants'; import { DeployContractArgs, DeployContractArgsResponse, NearContractCall, TOKEN_METHOD_NAMES } from '../types'; diff --git a/packages/sdk/src/depositStorage/depositStorage.ts b/packages/sdk/src/depositStorage/depositStorage.ts index 114f22fc4..86f4a2dc4 100644 --- a/packages/sdk/src/depositStorage/depositStorage.ts +++ b/packages/sdk/src/depositStorage/depositStorage.ts @@ -1,7 +1,7 @@ import { utils } from 'near-api-js'; import { mbjs } from '../config/config'; import { GAS } from '../constants'; -import { DepositStorageArgs, MARKET_METHOD_NAMES, NearContractCall } from '../types'; +import { DepositStorageArgs, EmptyObject, MARKET_METHOD_NAMES, NearContractCall } from '../types'; /** @@ -9,7 +9,7 @@ import { DepositStorageArgs, MARKET_METHOD_NAMES, NearContractCall } from '../ty * @param depositStorageArguments {@link DepositStorageArgs} * @returns contract call to be passed to @mintbase-js/sdk execute method */ -export const depositStorage = (args: DepositStorageArgs): NearContractCall<{}> => { +export const depositStorage = (args: DepositStorageArgs): NearContractCall => { const { marketAddress = mbjs.keys.marketAddress, listAmount = 1 } = args; diff --git a/packages/sdk/src/list/list.ts b/packages/sdk/src/list/list.ts index 95858cdbc..8788aa7ad 100644 --- a/packages/sdk/src/list/list.ts +++ b/packages/sdk/src/list/list.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { mbjs } from '../config/config'; import { GAS, LISTING_DEPOSIT } from '../constants'; import { ERROR_MESSAGES } from '../errorMessages'; diff --git a/packages/sdk/src/lockMetadata/lockMetadata.test.ts b/packages/sdk/src/lockMetadata/lockMetadata.test.ts index 8bceac141..7e2135aee 100644 --- a/packages/sdk/src/lockMetadata/lockMetadata.test.ts +++ b/packages/sdk/src/lockMetadata/lockMetadata.test.ts @@ -5,8 +5,6 @@ import { mbjs } from '../config/config'; describe('updateMetadata method tests', () => { const contractAddress = `test.${mbjs.keys.mbContractV2}`; - // const contractAddressV2 = 'test.mintbase2.near'; - const ownerId = 'test'; test('updateMetadata without options', () => { const args = lockMetadata({ diff --git a/packages/sdk/src/lockMetadata/lockMetadata.ts b/packages/sdk/src/lockMetadata/lockMetadata.ts index d82507609..7ec2061d3 100644 --- a/packages/sdk/src/lockMetadata/lockMetadata.ts +++ b/packages/sdk/src/lockMetadata/lockMetadata.ts @@ -1,6 +1,5 @@ -import BN from 'bn.js'; import { mbjs } from '../config/config'; -import { GAS, STORAGE_BYTES, STORAGE_PRICE_PER_BYTE_EXPONENT } from '../constants'; +import { GAS } from '../constants'; import { ERROR_MESSAGES } from '../errorMessages'; import { LockMetadataArgs, LockMetadataArgsResponse, NearContractCall, TOKEN_METHOD_NAMES } from '../types'; import { isIntString, isStoreV2 } from '../utils'; diff --git a/packages/sdk/src/mintOnMetadata/README.md b/packages/sdk/src/mintOnMetadata/README.md index d23b036dd..ed58e7da5 100644 --- a/packages/sdk/src/mintOnMetadata/README.md +++ b/packages/sdk/src/mintOnMetadata/README.md @@ -2,12 +2,13 @@ # Mint on Metadata (v2) -Mint on [previously created metadata](../createMetadata/README.md). Make sure to attach the required price! +Mint on [previously created metadata](../createMetadata/README.md). Make sure to attach the required price! If the metadata was created using the `ftAddress` parameter, you need to make sure to pass the same the `ftAddress` to this method. If you want specific token IDs, you can specify those via the `tokenIds` parameter. If your token IDs are already in use, this will cause a smart contract panic. You can also mint multiple tokens without specifying token IDs using the `amount` parameter. Make sure that there is no mismatch between your `tokenIds` and `amount` parameters. The `nftContactId` can be supplied as an argument or through the `TOKEN_CONTRACT` environment variable. + If you want to mint on a v1 smart contract, please use the [corresponding method](../mint/README.md). **As with all new SDK api methods, this call should be wrapped in [execute](../#execute) and passed a signing method. For a guide showing how to make a contract call with mintbase-js click [here](https://docs.mintbase.xyz/dev/getting-started/make-your-first-contract-call-deploycontract)** diff --git a/packages/sdk/src/mintOnMetadata/mintOnMetadata.test.ts b/packages/sdk/src/mintOnMetadata/mintOnMetadata.test.ts index 2b26c2615..0b5f30f66 100644 --- a/packages/sdk/src/mintOnMetadata/mintOnMetadata.test.ts +++ b/packages/sdk/src/mintOnMetadata/mintOnMetadata.test.ts @@ -1,6 +1,6 @@ -import { GAS } from '../constants'; +import { GAS, MAX_GAS } from '../constants'; import { ERROR_MESSAGES } from '../errorMessages'; -import { TOKEN_METHOD_NAMES } from '../types'; +import { FT_METHOD_NAMES, TOKEN_METHOD_NAMES } from '../types'; import { mintOnMetadata } from './mintOnMetadata'; import { mbjs } from '../config/config'; @@ -17,18 +17,27 @@ describe('mintOnMetadata method tests', () => { price: 1, }); - expect(args).toEqual({ - contractAddress: contractAddress, - methodName: TOKEN_METHOD_NAMES.MINT_ON_METADATA, - args: { - metadata_id: '1', - owner_id: ownerId, - num_to_mint: 1, - token_ids: null, + expect(args).toEqual([ + { + contractAddress: contractAddress, + methodName: TOKEN_METHOD_NAMES.DEPOSIT_STORAGE, + args: {}, + deposit: '7120000000000000000000', + gas: GAS, }, - deposit: '1007120000000000000000000', - gas: GAS, - }); + { + contractAddress: contractAddress, + methodName: TOKEN_METHOD_NAMES.MINT_ON_METADATA, + args: { + metadata_id: '1', + owner_id: ownerId, + num_to_mint: 1, + token_ids: null, + }, + deposit: '1000000000000000000000000', + gas: GAS, + }, + ]); }); test('mintOnMetadata with amount', () => { @@ -40,18 +49,27 @@ describe('mintOnMetadata method tests', () => { price: 1, }); - expect(args).toEqual({ - contractAddress: contractAddress, - methodName: TOKEN_METHOD_NAMES.MINT_ON_METADATA, - args: { - metadata_id: '1', - owner_id: ownerId, - num_to_mint: 5, - token_ids: null, + expect(args).toEqual([ + { + contractAddress: contractAddress, + methodName: TOKEN_METHOD_NAMES.DEPOSIT_STORAGE, + args: {}, + deposit: '27920000000000000000000', + gas: GAS, }, - deposit: '5027920000000000000000000', - gas: GAS, - }); + { + contractAddress: contractAddress, + methodName: TOKEN_METHOD_NAMES.MINT_ON_METADATA, + args: { + metadata_id: '1', + owner_id: ownerId, + num_to_mint: 5, + token_ids: null, + }, + deposit: '5000000000000000000000000', + gas: GAS, + }, + ]); }); test('mintOnMetadata with specified token IDs', () => { @@ -63,18 +81,27 @@ describe('mintOnMetadata method tests', () => { price: 1, }); - expect(args).toEqual({ - contractAddress: contractAddress, - methodName: TOKEN_METHOD_NAMES.MINT_ON_METADATA, - args: { - metadata_id: '1', - owner_id: ownerId, - num_to_mint: null, - token_ids: ['1', '2'], + expect(args).toEqual([ + { + contractAddress: contractAddress, + methodName: TOKEN_METHOD_NAMES.DEPOSIT_STORAGE, + args: {}, + deposit: '12320000000000000000000', + gas: GAS, }, - deposit: '2012320000000000000000000', - gas: GAS, - }); + { + contractAddress: contractAddress, + methodName: TOKEN_METHOD_NAMES.MINT_ON_METADATA, + args: { + metadata_id: '1', + owner_id: ownerId, + num_to_mint: null, + token_ids: ['1', '2'], + }, + deposit: '2000000000000000000000000', + gas: GAS, + }, + ]); }); test('mintOnMetadata with amount/token ID length mismatch', () => { @@ -101,4 +128,43 @@ describe('mintOnMetadata method tests', () => { }); }).toThrow(ERROR_MESSAGES.EMPTY_TOKEN_IDS); }); + + test('mintOnMetadata using FT', () => { + const wnearAddress = 'wnear.near'; + const args = mintOnMetadata({ + contractAddress: contractAddress, + metadataId: '1', + ownerId, + price: 1, + ftAddress: wnearAddress, + }); + + expect(args).toEqual([ + { + contractAddress: contractAddress, + methodName: TOKEN_METHOD_NAMES.DEPOSIT_STORAGE, + args: {}, + deposit: '7120000000000000000000', + gas: GAS, + }, + { + contractAddress: wnearAddress, + methodName: FT_METHOD_NAMES.FT_TRANSFER_CALL, + args: { + receiver_id: contractAddress, + amount: '1000000000000000000000000', + msg: JSON.stringify({ + metadata_id: '1', + owner_id: ownerId, + num_to_mint: 1, + token_ids: null, + }), + memo: null, + }, + deposit: '1', + gas: MAX_GAS, + }, + ]); + }); + }); diff --git a/packages/sdk/src/mintOnMetadata/mintOnMetadata.ts b/packages/sdk/src/mintOnMetadata/mintOnMetadata.ts index 38ccf21e5..02436578a 100644 --- a/packages/sdk/src/mintOnMetadata/mintOnMetadata.ts +++ b/packages/sdk/src/mintOnMetadata/mintOnMetadata.ts @@ -1,10 +1,12 @@ import BN from 'bn.js'; import { mbjs } from '../config/config'; -import { GAS, STORAGE_BYTES, STORAGE_PRICE_PER_BYTE_EXPONENT } from '../constants'; +import { GAS, MAX_GAS, ONE_YOCTO, STORAGE_BYTES, STORAGE_PRICE_PER_BYTE_EXPONENT } from '../constants'; import { ERROR_MESSAGES } from '../errorMessages'; -import { MintOnMetadataArgs, MintOnMetadataArgsResponse, NearContractCall, TOKEN_METHOD_NAMES } from '../types'; +import { EmptyObject, FT_METHOD_NAMES, FtTransferCallArgsResponse, MintOnMetadataArgs, MintOnMetadataArgsResponse, NearContractCall, TOKEN_METHOD_NAMES } from '../types'; import { isIntString, isStoreV2 } from '../utils'; +type DepositAndMintCalls = [NearContractCall, NearContractCall] + /** * Mint a token given via reference json on a given contract with a specified owner, amount of copies as well and royalties can be specified via options * @param mintArguments {@link MintArgs} @@ -12,7 +14,7 @@ import { isIntString, isStoreV2 } from '../utils'; */ export const mintOnMetadata = ( args: MintOnMetadataArgs, -): NearContractCall => { +): DepositAndMintCalls => { const { contractAddress = mbjs.keys.contractAddress, metadataId, @@ -20,6 +22,7 @@ export const mintOnMetadata = ( amount = null, tokenIds = null, price, + ftAddress, } = args; if (!contractAddress) { @@ -50,25 +53,62 @@ export const mintOnMetadata = ( throw new Error(ERROR_MESSAGES.TOKEN_ID_NOT_INT); } - return { - contractAddress: contractAddress || mbjs.keys.contractAddress, - args: { - metadata_id: metadataId, - owner_id: ownerId, - num_to_mint: tokenIds ? null : amountCalc, - token_ids: tokenIds, - }, - methodName: TOKEN_METHOD_NAMES.MINT_ON_METADATA, - gas: GAS, - deposit: mintOnMetadataDeposit(amountCalc, price), + const mintArgs = { + metadata_id: metadataId, + owner_id: ownerId, + num_to_mint: tokenIds ? null : amountCalc, + token_ids: tokenIds, }; + const storageDeposit = depositMintingStorage( + contractAddress, mintOnMetadataDeposit(amountCalc), + ); + const totalPrice = new BN(`1${'0'.repeat(24)}`).muln(price).muln(amountCalc).toString(); + + if (ftAddress) { + return [ + storageDeposit, + { + contractAddress: ftAddress, + args: { + receiver_id: contractAddress, + amount: totalPrice, + msg: JSON.stringify(mintArgs), + memo: null, + }, + methodName: FT_METHOD_NAMES.FT_TRANSFER_CALL, + deposit: ONE_YOCTO, + gas: MAX_GAS, + }, + ]; + } + + return [ + storageDeposit, + { + contractAddress: contractAddress || mbjs.keys.contractAddress, + args: mintArgs, + methodName: TOKEN_METHOD_NAMES.MINT_ON_METADATA, + gas: GAS, + deposit: totalPrice, + }, + ]; }; -export function mintOnMetadataDeposit(nTokens: number, price: number): string { +const depositMintingStorage = ( + contractAddress: string, amount: string, +): NearContractCall => ({ + contractAddress, + args: {}, + methodName: TOKEN_METHOD_NAMES.DEPOSIT_STORAGE, + gas: GAS, + deposit: amount, +}); + + +export function mintOnMetadataDeposit(nTokens: number): string { const totalBytes = STORAGE_BYTES.MINTING_BASE + STORAGE_BYTES.MINTING_FEE + (STORAGE_BYTES.TOKEN_BASE + STORAGE_BYTES.COMMON) * nTokens; const storageCost = new BN(`${Math.ceil(totalBytes)}${'0'.repeat(STORAGE_PRICE_PER_BYTE_EXPONENT)}`); - const priceCost = new BN(`1${'0'.repeat(24)}`).muln(price).muln(nTokens); - return storageCost.add(priceCost).toString(); + return storageCost.toString(); } diff --git a/packages/sdk/src/setMintingCap/setMintingCap.ts b/packages/sdk/src/setMintingCap/setMintingCap.ts index e15522ce0..ad438cd0a 100644 --- a/packages/sdk/src/setMintingCap/setMintingCap.ts +++ b/packages/sdk/src/setMintingCap/setMintingCap.ts @@ -1,6 +1,6 @@ import { mbjs } from '../config/config'; import { GAS, ONE_YOCTO } from '../constants'; -import { SetMintingCapArgs, NearContractCall, TOKEN_METHOD_NAMES } from '../types'; +import { SetMintingCapArgs, NearContractCall, TOKEN_METHOD_NAMES, SetMintingCapArgsResponse } from '../types'; import { isStoreV2 } from '../utils'; import { ERROR_MESSAGES } from '../errorMessages'; @@ -10,7 +10,7 @@ import { ERROR_MESSAGES } from '../errorMessages'; * @param args {@link SetMintingCapArgs} * @returns contract call to be passed to @mintbase-js/sdk execute method */ -export const setMintingCap = (args: SetMintingCapArgs): NearContractCall<{}> => { +export const setMintingCap = (args: SetMintingCapArgs): NearContractCall => { const { contractAddress = mbjs.keys.contractAddress, mintingCap } = args; diff --git a/packages/sdk/src/setSplits/setSplits.ts b/packages/sdk/src/setSplits/setSplits.ts index 098212a27..34c7a7684 100644 --- a/packages/sdk/src/setSplits/setSplits.ts +++ b/packages/sdk/src/setSplits/setSplits.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { mbjs } from '../config/config'; import { GAS, STORAGE_BYTES, STORAGE_PRICE_PER_BYTE_EXPONENT } from '../constants'; import { ERROR_MESSAGES } from '../errorMessages'; diff --git a/packages/sdk/src/transferContractOwnership/transferContractOwnership.ts b/packages/sdk/src/transferContractOwnership/transferContractOwnership.ts index b38f061cb..e1951fd90 100644 --- a/packages/sdk/src/transferContractOwnership/transferContractOwnership.ts +++ b/packages/sdk/src/transferContractOwnership/transferContractOwnership.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { mbjs } from '../config/config'; import { GAS, ONE_YOCTO } from '../constants'; import { NearContractCall, TOKEN_METHOD_NAMES, TransferContractOwnershipArgs, TransferContractOwnershipArgsResponse } from '../types'; diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index bbc841c36..24b6308b2 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -20,7 +20,8 @@ export enum TOKEN_METHOD_NAMES { TOKEN_ACCOUNT_REVOKE = 'nft_revoke', TOKEN_ACCOUNT_REVOKE_ALL = 'nft_revoke_all', SET_SPLITS = 'set_split_owners', - SET_MINTING_CAP = 'set_minting_cap' + SET_MINTING_CAP = 'set_minting_cap', + DEPOSIT_STORAGE = 'deposit_storage', } export enum MARKET_METHOD_NAMES { @@ -148,7 +149,7 @@ export enum TransactionSuccessEnum { } export type CallBackArgs = { - args: object; + args: Record; type: TransactionSuccessEnum; } @@ -253,6 +254,7 @@ export type CreateMetadataArgs = { lastPossibleMint?: Date; isDynamic?: boolean; price: number; + ftAddress?: string; noMedia?: boolean; // explicit opt-in to NFT without media, breaks wallets noReference?: boolean; // explicit opt-in to NFT without reference }; @@ -264,6 +266,7 @@ export type MintOnMetadataArgs = { amount?: number; tokenIds?: string[]; price: number; + ftAddress?: string; }; export type UpdateMetadataArgs = { @@ -432,6 +435,7 @@ export interface CreateMetadataArgsResponse { last_possible_mint?: string; is_dynamic?: boolean; price: string; + ft_contract_id?: string; } export interface MintOnMetadataArgsResponse { @@ -472,12 +476,23 @@ export interface SetSplitsArgsResponse { split_between: Record; } +export type SetMintingCapArgsResponse = { + minting_cap: number; +} + export interface FtTransferArgsResponse { receiver_id: string; amount: string; memo: string | null; } +export interface FtTransferCallArgsResponse { + receiver_id: string; + amount: string; + memo: string | null; + msg: string; +} + export interface FtDepositStorageArgsResponse { account_id: string; } @@ -502,3 +517,7 @@ export type ExecuteArgsResponse = TransferArgsResponse | Record; export type FinalExecutionOutcome = FEO; + +// utility types +export type EmptyObject = Record +export type AnyObject = Record diff --git a/packages/sdk/src/updateMetadata/updateMetadata.test.ts b/packages/sdk/src/updateMetadata/updateMetadata.test.ts index d1247dc94..1b4cd5177 100644 --- a/packages/sdk/src/updateMetadata/updateMetadata.test.ts +++ b/packages/sdk/src/updateMetadata/updateMetadata.test.ts @@ -7,7 +7,6 @@ import { mbjs } from '../config/config'; describe('updateMetadata method tests', () => { const contractAddress = `test.${mbjs.keys.mbContractV2}`; // const contractAddressV2 = 'test.mintbase2.near'; - const ownerId = 'test'; test('updateMetadata without options', () => { const args = updateMetadata({ diff --git a/packages/sdk/src/updateMetadata/updateMetadata.ts b/packages/sdk/src/updateMetadata/updateMetadata.ts index 69bd72076..e70457f8f 100644 --- a/packages/sdk/src/updateMetadata/updateMetadata.ts +++ b/packages/sdk/src/updateMetadata/updateMetadata.ts @@ -50,6 +50,6 @@ export const updateMetadata = ( }, methodName: TOKEN_METHOD_NAMES.UPDATE_METADATA, gas: GAS, - deposit: '1', + deposit: '1', // FIXME: should cover storage, not only 1 yocto. }; }; diff --git a/packages/testing/src/utils.ts b/packages/testing/src/utils.ts index 1c76ed57f..2d2f7b09d 100644 --- a/packages/testing/src/utils.ts +++ b/packages/testing/src/utils.ts @@ -36,8 +36,15 @@ const db = new Firestore({ projectId: GCP_PROJECT, }); +export type GasTelemetryDoc = { + gasBurnt: number; + mintedCount: number; + receipts: string[]; + lastUpdated: Date; +}; + export const writeGasTelemetryToFirestore = async( - data: object, + data: GasTelemetryDoc, ): Promise => { await db .collection(TELEMETRY_COLLECTION) diff --git a/packages/testing/tests/SDK/transferContractOwnership.integration.test.ts b/packages/testing/tests/SDK/transferContractOwnership.integration.test.ts index 2951806b7..ad5ba948c 100644 --- a/packages/testing/tests/SDK/transferContractOwnership.integration.test.ts +++ b/packages/testing/tests/SDK/transferContractOwnership.integration.test.ts @@ -15,7 +15,7 @@ test('transfer contract ownership', async () => { const bobAccount = await connect(bob, bobKey); // maybe move this into mb-data if this query provides further utility - const { data } = await fetchGraphQl({ + const { data } = await fetchGraphQl<{ nft_contracts: Array<{ owner_id: string }> }>({ query: gql`query MyQuery { nft_contracts(where: {id: {_eq: "qrq9m4sfaf.mintspace2.testnet"}}) { owner_id @@ -23,7 +23,7 @@ test('transfer contract ownership', async () => { }`, }); - if (data.nft_contracts[0].owner_id == 'mb_alice.testnet') { + if (data?.nft_contracts[0]?.owner_id === 'mb_alice.testnet') { const aliceToBob = (await execute( { account: aliceAccount }, transferContractOwnership({ @@ -45,4 +45,3 @@ test('transfer contract ownership', async () => { expect(bobToAlice.receipts_outcome).not.toBeUndefined(); } }); - diff --git a/packages/testing/tests/workflows/mint.w.upload.integration.test.ts b/packages/testing/tests/workflows/mint.w.upload.integration.test.ts index 78ecd1662..bcd2d0202 100644 --- a/packages/testing/tests/workflows/mint.w.upload.integration.test.ts +++ b/packages/testing/tests/workflows/mint.w.upload.integration.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { readFileSync } from 'fs'; import { resolve } from 'path'; import {