diff --git a/.gitignore b/.gitignore index 4f2b86e..d1d612e 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ dist .idea/workspace.xml .rpt2_cache .yalc -.husky out # misc diff --git a/.husky/commit_msg b/.husky/commit_msg new file mode 100644 index 0000000..0d30cdf --- /dev/null +++ b/.husky/commit_msg @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" +npx --no-install commitlint --edit $1 \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..ddc248a --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" +npm test \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7732c76..380d73d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@itheum/sdk-mx-data-nft", - "version": "2.7.0", + "version": "3.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@itheum/sdk-mx-data-nft", - "version": "2.7.0", + "version": "3.0.0", "license": "GPL-3.0-only", "dependencies": { "@multiversx/sdk-core": "12.18.0", @@ -7421,6 +7421,7 @@ "which", "write-file-atomic" ], + "dev": true, "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^7.2.1", @@ -7515,14 +7516,17 @@ }, "node_modules/npm/node_modules/@colors/colors": { "version": "1.5.0", + "dev": true, "inBundle": true, "license": "MIT", + "optional": true, "engines": { "node": ">=0.1.90" } }, "node_modules/npm/node_modules/@isaacs/cliui": { "version": "8.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7539,6 +7543,7 @@ }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/ansi-regex": { "version": "6.0.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -7550,11 +7555,13 @@ }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/emoji-regex": { "version": "9.2.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/string-width": { "version": "5.1.2", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -7571,6 +7578,7 @@ }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/strip-ansi": { "version": "7.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -7585,11 +7593,13 @@ }, "node_modules/npm/node_modules/@isaacs/string-locale-compare": { "version": "1.1.0", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/@npmcli/agent": { "version": "2.2.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7605,6 +7615,7 @@ }, "node_modules/npm/node_modules/@npmcli/arborist": { "version": "7.3.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7651,6 +7662,7 @@ }, "node_modules/npm/node_modules/@npmcli/config": { "version": "8.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7669,6 +7681,7 @@ }, "node_modules/npm/node_modules/@npmcli/disparity-colors": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7680,6 +7693,7 @@ }, "node_modules/npm/node_modules/@npmcli/disparity-colors/node_modules/ansi-styles": { "version": "4.3.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -7694,6 +7708,7 @@ }, "node_modules/npm/node_modules/@npmcli/fs": { "version": "3.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7705,6 +7720,7 @@ }, "node_modules/npm/node_modules/@npmcli/git": { "version": "5.0.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7723,6 +7739,7 @@ }, "node_modules/npm/node_modules/@npmcli/installed-package-contents": { "version": "2.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7738,6 +7755,7 @@ }, "node_modules/npm/node_modules/@npmcli/map-workspaces": { "version": "3.0.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7752,6 +7770,7 @@ }, "node_modules/npm/node_modules/@npmcli/metavuln-calculator": { "version": "7.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7766,6 +7785,7 @@ }, "node_modules/npm/node_modules/@npmcli/name-from-folder": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -7774,6 +7794,7 @@ }, "node_modules/npm/node_modules/@npmcli/node-gyp": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -7782,6 +7803,7 @@ }, "node_modules/npm/node_modules/@npmcli/package-json": { "version": "5.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7799,6 +7821,7 @@ }, "node_modules/npm/node_modules/@npmcli/promise-spawn": { "version": "7.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7810,6 +7833,7 @@ }, "node_modules/npm/node_modules/@npmcli/query": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7821,6 +7845,7 @@ }, "node_modules/npm/node_modules/@npmcli/run-script": { "version": "7.0.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -7836,14 +7861,17 @@ }, "node_modules/npm/node_modules/@pkgjs/parseargs": { "version": "0.11.0", + "dev": true, "inBundle": true, "license": "MIT", + "optional": true, "engines": { "node": ">=14" } }, "node_modules/npm/node_modules/@sigstore/bundle": { "version": "2.1.1", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -7855,6 +7883,7 @@ }, "node_modules/npm/node_modules/@sigstore/core": { "version": "0.2.0", + "dev": true, "inBundle": true, "license": "Apache-2.0", "engines": { @@ -7863,6 +7892,7 @@ }, "node_modules/npm/node_modules/@sigstore/protobuf-specs": { "version": "0.2.1", + "dev": true, "inBundle": true, "license": "Apache-2.0", "engines": { @@ -7871,6 +7901,7 @@ }, "node_modules/npm/node_modules/@sigstore/sign": { "version": "2.2.1", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -7885,6 +7916,7 @@ }, "node_modules/npm/node_modules/@sigstore/tuf": { "version": "2.3.0", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -7897,6 +7929,7 @@ }, "node_modules/npm/node_modules/@sigstore/verify": { "version": "0.1.0", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -7910,6 +7943,7 @@ }, "node_modules/npm/node_modules/@tufjs/canonical-json": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -7918,6 +7952,7 @@ }, "node_modules/npm/node_modules/@tufjs/models": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -7930,6 +7965,7 @@ }, "node_modules/npm/node_modules/abbrev": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -7938,6 +7974,7 @@ }, "node_modules/npm/node_modules/agent-base": { "version": "7.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -7949,6 +7986,7 @@ }, "node_modules/npm/node_modules/aggregate-error": { "version": "3.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -7961,6 +7999,7 @@ }, "node_modules/npm/node_modules/ansi-regex": { "version": "5.0.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -7969,6 +8008,7 @@ }, "node_modules/npm/node_modules/ansi-styles": { "version": "6.2.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -7980,16 +8020,19 @@ }, "node_modules/npm/node_modules/aproba": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/archy": { "version": "1.0.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/are-we-there-yet": { "version": "4.0.2", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -7998,11 +8041,13 @@ }, "node_modules/npm/node_modules/balanced-match": { "version": "1.0.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/bin-links": { "version": "4.0.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8017,6 +8062,7 @@ }, "node_modules/npm/node_modules/binary-extensions": { "version": "2.2.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8025,6 +8071,7 @@ }, "node_modules/npm/node_modules/brace-expansion": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8033,6 +8080,7 @@ }, "node_modules/npm/node_modules/builtins": { "version": "5.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8041,6 +8089,7 @@ }, "node_modules/npm/node_modules/cacache": { "version": "18.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8063,6 +8112,7 @@ }, "node_modules/npm/node_modules/chalk": { "version": "5.3.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8074,6 +8124,7 @@ }, "node_modules/npm/node_modules/chownr": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -8082,6 +8133,7 @@ }, "node_modules/npm/node_modules/ci-info": { "version": "4.0.0", + "dev": true, "funding": [ { "type": "github", @@ -8096,6 +8148,7 @@ }, "node_modules/npm/node_modules/cidr-regex": { "version": "4.0.3", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -8107,6 +8160,7 @@ }, "node_modules/npm/node_modules/clean-stack": { "version": "2.2.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8115,6 +8169,7 @@ }, "node_modules/npm/node_modules/cli-columns": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8127,6 +8182,7 @@ }, "node_modules/npm/node_modules/cli-table3": { "version": "0.6.3", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8141,6 +8197,7 @@ }, "node_modules/npm/node_modules/clone": { "version": "1.0.4", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8149,6 +8206,7 @@ }, "node_modules/npm/node_modules/cmd-shim": { "version": "6.0.2", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -8157,6 +8215,7 @@ }, "node_modules/npm/node_modules/color-convert": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8168,11 +8227,13 @@ }, "node_modules/npm/node_modules/color-name": { "version": "1.1.4", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/color-support": { "version": "1.1.3", + "dev": true, "inBundle": true, "license": "ISC", "bin": { @@ -8181,6 +8242,7 @@ }, "node_modules/npm/node_modules/columnify": { "version": "1.6.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8193,16 +8255,19 @@ }, "node_modules/npm/node_modules/common-ancestor-path": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/console-control-strings": { "version": "1.1.0", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/cross-spawn": { "version": "7.0.3", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8216,6 +8281,7 @@ }, "node_modules/npm/node_modules/cross-spawn/node_modules/which": { "version": "2.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8230,6 +8296,7 @@ }, "node_modules/npm/node_modules/cssesc": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "MIT", "bin": { @@ -8241,6 +8308,7 @@ }, "node_modules/npm/node_modules/debug": { "version": "4.3.4", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8257,11 +8325,13 @@ }, "node_modules/npm/node_modules/debug/node_modules/ms": { "version": "2.1.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/defaults": { "version": "1.0.4", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8273,6 +8343,7 @@ }, "node_modules/npm/node_modules/diff": { "version": "5.1.0", + "dev": true, "inBundle": true, "license": "BSD-3-Clause", "engines": { @@ -8281,24 +8352,29 @@ }, "node_modules/npm/node_modules/eastasianwidth": { "version": "0.2.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/emoji-regex": { "version": "8.0.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/encoding": { "version": "0.1.13", + "dev": true, "inBundle": true, "license": "MIT", + "optional": true, "dependencies": { "iconv-lite": "^0.6.2" } }, "node_modules/npm/node_modules/env-paths": { "version": "2.2.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8307,16 +8383,19 @@ }, "node_modules/npm/node_modules/err-code": { "version": "2.0.3", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/exponential-backoff": { "version": "3.1.1", + "dev": true, "inBundle": true, "license": "Apache-2.0" }, "node_modules/npm/node_modules/fastest-levenshtein": { "version": "1.0.16", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8325,6 +8404,7 @@ }, "node_modules/npm/node_modules/foreground-child": { "version": "3.1.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8340,6 +8420,7 @@ }, "node_modules/npm/node_modules/fs-minipass": { "version": "3.0.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8351,6 +8432,7 @@ }, "node_modules/npm/node_modules/function-bind": { "version": "1.1.2", + "dev": true, "inBundle": true, "license": "MIT", "funding": { @@ -8359,6 +8441,7 @@ }, "node_modules/npm/node_modules/gauge": { "version": "5.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8377,6 +8460,7 @@ }, "node_modules/npm/node_modules/glob": { "version": "10.3.10", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8398,16 +8482,19 @@ }, "node_modules/npm/node_modules/graceful-fs": { "version": "4.2.11", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/has-unicode": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/hasown": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8419,6 +8506,7 @@ }, "node_modules/npm/node_modules/hosted-git-info": { "version": "7.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8430,11 +8518,13 @@ }, "node_modules/npm/node_modules/http-cache-semantics": { "version": "4.1.1", + "dev": true, "inBundle": true, "license": "BSD-2-Clause" }, "node_modules/npm/node_modules/http-proxy-agent": { "version": "7.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8447,6 +8537,7 @@ }, "node_modules/npm/node_modules/https-proxy-agent": { "version": "7.0.2", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8459,8 +8550,10 @@ }, "node_modules/npm/node_modules/iconv-lite": { "version": "0.6.3", + "dev": true, "inBundle": true, "license": "MIT", + "optional": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" }, @@ -8470,6 +8563,7 @@ }, "node_modules/npm/node_modules/ignore-walk": { "version": "6.0.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8481,6 +8575,7 @@ }, "node_modules/npm/node_modules/imurmurhash": { "version": "0.1.4", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8489,6 +8584,7 @@ }, "node_modules/npm/node_modules/indent-string": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8497,6 +8593,7 @@ }, "node_modules/npm/node_modules/ini": { "version": "4.1.1", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -8505,6 +8602,7 @@ }, "node_modules/npm/node_modules/init-package-json": { "version": "6.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8522,11 +8620,13 @@ }, "node_modules/npm/node_modules/ip": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/ip-regex": { "version": "5.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8538,6 +8638,7 @@ }, "node_modules/npm/node_modules/is-cidr": { "version": "5.0.3", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -8549,6 +8650,7 @@ }, "node_modules/npm/node_modules/is-core-module": { "version": "2.13.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8560,6 +8662,7 @@ }, "node_modules/npm/node_modules/is-fullwidth-code-point": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8568,16 +8671,19 @@ }, "node_modules/npm/node_modules/is-lambda": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/isexe": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/jackspeak": { "version": "2.3.6", + "dev": true, "inBundle": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -8595,6 +8701,7 @@ }, "node_modules/npm/node_modules/json-parse-even-better-errors": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -8603,6 +8710,7 @@ }, "node_modules/npm/node_modules/json-stringify-nice": { "version": "1.1.4", + "dev": true, "inBundle": true, "license": "ISC", "funding": { @@ -8611,6 +8719,7 @@ }, "node_modules/npm/node_modules/jsonparse": { "version": "1.3.1", + "dev": true, "engines": [ "node >= 0.2.0" ], @@ -8619,16 +8728,19 @@ }, "node_modules/npm/node_modules/just-diff": { "version": "6.0.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/just-diff-apply": { "version": "5.5.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/libnpmaccess": { "version": "8.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8641,6 +8753,7 @@ }, "node_modules/npm/node_modules/libnpmdiff": { "version": "6.0.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8660,6 +8773,7 @@ }, "node_modules/npm/node_modules/libnpmexec": { "version": "7.0.7", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8681,6 +8795,7 @@ }, "node_modules/npm/node_modules/libnpmfund": { "version": "5.0.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8692,6 +8807,7 @@ }, "node_modules/npm/node_modules/libnpmhook": { "version": "10.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8704,6 +8820,7 @@ }, "node_modules/npm/node_modules/libnpmorg": { "version": "6.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8716,6 +8833,7 @@ }, "node_modules/npm/node_modules/libnpmpack": { "version": "6.0.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8730,6 +8848,7 @@ }, "node_modules/npm/node_modules/libnpmpublish": { "version": "9.0.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8748,6 +8867,7 @@ }, "node_modules/npm/node_modules/libnpmsearch": { "version": "7.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8759,6 +8879,7 @@ }, "node_modules/npm/node_modules/libnpmteam": { "version": "6.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8771,6 +8892,7 @@ }, "node_modules/npm/node_modules/libnpmversion": { "version": "5.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8786,6 +8908,7 @@ }, "node_modules/npm/node_modules/lru-cache": { "version": "10.1.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -8794,6 +8917,7 @@ }, "node_modules/npm/node_modules/make-fetch-happen": { "version": "13.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8815,6 +8939,7 @@ }, "node_modules/npm/node_modules/minimatch": { "version": "9.0.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8829,6 +8954,7 @@ }, "node_modules/npm/node_modules/minipass": { "version": "7.0.4", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -8837,6 +8963,7 @@ }, "node_modules/npm/node_modules/minipass-collect": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8848,6 +8975,7 @@ }, "node_modules/npm/node_modules/minipass-fetch": { "version": "3.0.4", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8864,6 +8992,7 @@ }, "node_modules/npm/node_modules/minipass-flush": { "version": "1.0.5", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8875,6 +9004,7 @@ }, "node_modules/npm/node_modules/minipass-flush/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8886,6 +9016,7 @@ }, "node_modules/npm/node_modules/minipass-json-stream": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8895,6 +9026,7 @@ }, "node_modules/npm/node_modules/minipass-json-stream/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8906,6 +9038,7 @@ }, "node_modules/npm/node_modules/minipass-pipeline": { "version": "1.2.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8917,6 +9050,7 @@ }, "node_modules/npm/node_modules/minipass-pipeline/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8928,6 +9062,7 @@ }, "node_modules/npm/node_modules/minipass-sized": { "version": "1.0.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8939,6 +9074,7 @@ }, "node_modules/npm/node_modules/minipass-sized/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8950,6 +9086,7 @@ }, "node_modules/npm/node_modules/minizlib": { "version": "2.1.2", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -8962,6 +9099,7 @@ }, "node_modules/npm/node_modules/minizlib/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -8973,6 +9111,7 @@ }, "node_modules/npm/node_modules/mkdirp": { "version": "1.0.4", + "dev": true, "inBundle": true, "license": "MIT", "bin": { @@ -8984,11 +9123,13 @@ }, "node_modules/npm/node_modules/ms": { "version": "2.1.3", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/mute-stream": { "version": "1.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -8997,6 +9138,7 @@ }, "node_modules/npm/node_modules/negotiator": { "version": "0.6.3", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -9005,6 +9147,7 @@ }, "node_modules/npm/node_modules/node-gyp": { "version": "10.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9028,6 +9171,7 @@ }, "node_modules/npm/node_modules/nopt": { "version": "7.2.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9042,6 +9186,7 @@ }, "node_modules/npm/node_modules/normalize-package-data": { "version": "6.0.0", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -9056,6 +9201,7 @@ }, "node_modules/npm/node_modules/npm-audit-report": { "version": "5.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -9064,6 +9210,7 @@ }, "node_modules/npm/node_modules/npm-bundled": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9075,6 +9222,7 @@ }, "node_modules/npm/node_modules/npm-install-checks": { "version": "6.3.0", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -9086,6 +9234,7 @@ }, "node_modules/npm/node_modules/npm-normalize-package-bin": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -9094,6 +9243,7 @@ }, "node_modules/npm/node_modules/npm-package-arg": { "version": "11.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9108,6 +9258,7 @@ }, "node_modules/npm/node_modules/npm-packlist": { "version": "8.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9119,6 +9270,7 @@ }, "node_modules/npm/node_modules/npm-pick-manifest": { "version": "9.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9133,6 +9285,7 @@ }, "node_modules/npm/node_modules/npm-profile": { "version": "9.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9145,6 +9298,7 @@ }, "node_modules/npm/node_modules/npm-registry-fetch": { "version": "16.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9162,6 +9316,7 @@ }, "node_modules/npm/node_modules/npm-user-validate": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "engines": { @@ -9170,6 +9325,7 @@ }, "node_modules/npm/node_modules/npmlog": { "version": "7.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9184,6 +9340,7 @@ }, "node_modules/npm/node_modules/p-map": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9198,6 +9355,7 @@ }, "node_modules/npm/node_modules/pacote": { "version": "17.0.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9229,6 +9387,7 @@ }, "node_modules/npm/node_modules/parse-conflict-json": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9242,6 +9401,7 @@ }, "node_modules/npm/node_modules/path-key": { "version": "3.1.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -9250,6 +9410,7 @@ }, "node_modules/npm/node_modules/path-scurry": { "version": "1.10.1", + "dev": true, "inBundle": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -9265,6 +9426,7 @@ }, "node_modules/npm/node_modules/postcss-selector-parser": { "version": "6.0.15", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9277,6 +9439,7 @@ }, "node_modules/npm/node_modules/proc-log": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -9285,6 +9448,7 @@ }, "node_modules/npm/node_modules/promise-all-reject-late": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "ISC", "funding": { @@ -9293,6 +9457,7 @@ }, "node_modules/npm/node_modules/promise-call-limit": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC", "funding": { @@ -9301,11 +9466,13 @@ }, "node_modules/npm/node_modules/promise-inflight": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/promise-retry": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9318,6 +9485,7 @@ }, "node_modules/npm/node_modules/promzard": { "version": "1.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9329,6 +9497,7 @@ }, "node_modules/npm/node_modules/qrcode-terminal": { "version": "0.12.0", + "dev": true, "inBundle": true, "bin": { "qrcode-terminal": "bin/qrcode-terminal.js" @@ -9336,6 +9505,7 @@ }, "node_modules/npm/node_modules/read": { "version": "2.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9347,6 +9517,7 @@ }, "node_modules/npm/node_modules/read-cmd-shim": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -9355,6 +9526,7 @@ }, "node_modules/npm/node_modules/read-package-json": { "version": "7.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9369,6 +9541,7 @@ }, "node_modules/npm/node_modules/read-package-json-fast": { "version": "3.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9381,6 +9554,7 @@ }, "node_modules/npm/node_modules/retry": { "version": "0.12.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -9389,11 +9563,14 @@ }, "node_modules/npm/node_modules/safer-buffer": { "version": "2.1.2", + "dev": true, "inBundle": true, - "license": "MIT" + "license": "MIT", + "optional": true }, "node_modules/npm/node_modules/semver": { "version": "7.5.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9408,6 +9585,7 @@ }, "node_modules/npm/node_modules/semver/node_modules/lru-cache": { "version": "6.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9419,11 +9597,13 @@ }, "node_modules/npm/node_modules/set-blocking": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/shebang-command": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9435,6 +9615,7 @@ }, "node_modules/npm/node_modules/shebang-regex": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -9443,6 +9624,7 @@ }, "node_modules/npm/node_modules/signal-exit": { "version": "4.1.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -9454,6 +9636,7 @@ }, "node_modules/npm/node_modules/sigstore": { "version": "2.2.0", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -9470,6 +9653,7 @@ }, "node_modules/npm/node_modules/smart-buffer": { "version": "4.2.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -9479,6 +9663,7 @@ }, "node_modules/npm/node_modules/socks": { "version": "2.7.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9492,6 +9677,7 @@ }, "node_modules/npm/node_modules/socks-proxy-agent": { "version": "8.0.2", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9505,6 +9691,7 @@ }, "node_modules/npm/node_modules/spdx-correct": { "version": "3.2.0", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -9514,11 +9701,13 @@ }, "node_modules/npm/node_modules/spdx-exceptions": { "version": "2.3.0", + "dev": true, "inBundle": true, "license": "CC-BY-3.0" }, "node_modules/npm/node_modules/spdx-expression-parse": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9528,11 +9717,13 @@ }, "node_modules/npm/node_modules/spdx-license-ids": { "version": "3.0.16", + "dev": true, "inBundle": true, "license": "CC0-1.0" }, "node_modules/npm/node_modules/ssri": { "version": "10.0.5", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9544,6 +9735,7 @@ }, "node_modules/npm/node_modules/string-width": { "version": "4.2.3", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9558,6 +9750,7 @@ "node_modules/npm/node_modules/string-width-cjs": { "name": "string-width", "version": "4.2.3", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9571,6 +9764,7 @@ }, "node_modules/npm/node_modules/strip-ansi": { "version": "6.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9583,6 +9777,7 @@ "node_modules/npm/node_modules/strip-ansi-cjs": { "name": "strip-ansi", "version": "6.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9594,6 +9789,7 @@ }, "node_modules/npm/node_modules/supports-color": { "version": "9.4.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -9605,6 +9801,7 @@ }, "node_modules/npm/node_modules/tar": { "version": "6.2.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9621,6 +9818,7 @@ }, "node_modules/npm/node_modules/tar/node_modules/fs-minipass": { "version": "2.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9632,6 +9830,7 @@ }, "node_modules/npm/node_modules/tar/node_modules/fs-minipass/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9643,6 +9842,7 @@ }, "node_modules/npm/node_modules/tar/node_modules/minipass": { "version": "5.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -9651,16 +9851,19 @@ }, "node_modules/npm/node_modules/text-table": { "version": "0.2.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/tiny-relative-date": { "version": "1.3.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/treeverse": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -9669,6 +9872,7 @@ }, "node_modules/npm/node_modules/tuf-js": { "version": "2.2.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9682,6 +9886,7 @@ }, "node_modules/npm/node_modules/unique-filename": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9693,6 +9898,7 @@ }, "node_modules/npm/node_modules/unique-slug": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9704,11 +9910,13 @@ }, "node_modules/npm/node_modules/util-deprecate": { "version": "1.0.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/validate-npm-package-license": { "version": "3.0.4", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -9718,6 +9926,7 @@ }, "node_modules/npm/node_modules/validate-npm-package-name": { "version": "5.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9729,11 +9938,13 @@ }, "node_modules/npm/node_modules/walk-up-path": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/wcwidth": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9742,6 +9953,7 @@ }, "node_modules/npm/node_modules/which": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9756,6 +9968,7 @@ }, "node_modules/npm/node_modules/which/node_modules/isexe": { "version": "3.1.1", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -9764,6 +9977,7 @@ }, "node_modules/npm/node_modules/wide-align": { "version": "1.1.5", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9772,6 +9986,7 @@ }, "node_modules/npm/node_modules/wrap-ansi": { "version": "8.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9789,6 +10004,7 @@ "node_modules/npm/node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9805,6 +10021,7 @@ }, "node_modules/npm/node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { "version": "4.3.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9819,6 +10036,7 @@ }, "node_modules/npm/node_modules/wrap-ansi/node_modules/ansi-regex": { "version": "6.0.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -9830,11 +10048,13 @@ }, "node_modules/npm/node_modules/wrap-ansi/node_modules/emoji-regex": { "version": "9.2.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/wrap-ansi/node_modules/string-width": { "version": "5.1.2", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9851,6 +10071,7 @@ }, "node_modules/npm/node_modules/wrap-ansi/node_modules/strip-ansi": { "version": "7.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -9865,6 +10086,7 @@ }, "node_modules/npm/node_modules/write-file-atomic": { "version": "5.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -9877,6 +10099,7 @@ }, "node_modules/npm/node_modules/yallist": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "ISC" }, diff --git a/src/bond.ts b/src/bond.ts index 97ff509..f5b0629 100644 --- a/src/bond.ts +++ b/src/bond.ts @@ -8,9 +8,14 @@ import { ResultsParser, TokenIdentifierValue, Transaction, + TypedValue, U64Value } from '@multiversx/sdk-core/out'; -import { EnvironmentsEnum, bondContractAddress } from './config'; +import { + EnvironmentsEnum, + bondContractAddress, + itheumTokenIdentifier +} from './config'; import { ErrContractQuery } from './errors'; import BigNumber from 'bignumber.js'; @@ -109,7 +114,6 @@ export class BondContract extends Contract { /** * Returns a list of addresses that are blacklisted from claiming compensations * @param compensationId compensaton id to query - * @returns */ async viewCompensationBlacklist(compensationId: number): Promise { const interaction = this.contract.methodsExplicit.getCompensationBlacklist([ @@ -193,7 +197,23 @@ export class BondContract extends Contract { * @param compensationId compensation id to query */ async viewCompensation(compensationId: number) { - throw new Error('Not implemented'); + const interaction = this.contract.methodsExplicit.getCompensation([ + new U64Value(compensationId) + ]); + const query = interaction.buildQuery(); + const queryResponse = await this.networkProvider.queryContract(query); + const endpointDefinition = interaction.getEndpoint(); + const { firstValue, returnCode } = new ResultsParser().parseQueryResponse( + queryResponse, + endpointDefinition + ); + if (returnCode.isSuccess()) { + const returnValue = firstValue?.valueOf(); + const compensation: Compensation = parseCompensation(returnValue); + return compensation; + } else { + throw new ErrContractQuery('viewCompensation', returnCode.toString()); + } } /** @@ -266,7 +286,29 @@ export class BondContract extends Contract { * @param end_index index to end */ async viewPagedCompensations(startIndex: number, endIndex: number) { - throw new Error('Not implemented'); + const interaction = this.contract.methodsExplicit.getPagedCompensations([ + new U64Value(startIndex), + new U64Value(endIndex) + ]); + const query = interaction.buildQuery(); + const queryResponse = await this.networkProvider.queryContract(query); + const endpointDefinition = interaction.getEndpoint(); + const { firstValue, returnCode } = new ResultsParser().parseQueryResponse( + queryResponse, + endpointDefinition + ); + if (returnCode.isSuccess()) { + const returnValue = firstValue?.valueOf(); + const compensations: Compensation[] = returnValue.map( + (compensation: Compensation) => parseCompensation(compensation) + ); + return compensations; + } else { + throw new ErrContractQuery( + 'viewPagedCompensations', + returnCode.toString() + ); + } } /** @@ -274,7 +316,23 @@ export class BondContract extends Contract { * @param bondId bond id to query */ async viewBond(bondId: number) { - throw new Error('Not implemented'); + const interaction = this.contract.methodsExplicit.getBond([ + new U64Value(bondId) + ]); + const query = interaction.buildQuery(); + const queryResponse = await this.networkProvider.queryContract(query); + const endpointDefinition = interaction.getEndpoint(); + const { firstValue, returnCode } = new ResultsParser().parseQueryResponse( + queryResponse, + endpointDefinition + ); + if (returnCode.isSuccess()) { + const returnValue = firstValue?.valueOf(); + const bond: Bond = parseBond(returnValue); + return bond; + } else { + throw new ErrContractQuery('viewBond', returnCode.toString()); + } } /** @@ -369,28 +427,46 @@ export class BondContract extends Contract { * @param end_index index to end */ async viewPagedBonds(startIndex: number, endIndex: number) { - throw new Error('Not implemented'); + const interaction = this.contract.methodsExplicit.getPagedBonds([ + new U64Value(startIndex), + new U64Value(endIndex) + ]); + const query = interaction.buildQuery(); + const queryResponse = await this.networkProvider.queryContract(query); + const endpointDefinition = interaction.getEndpoint(); + const { firstValue, returnCode } = new ResultsParser().parseQueryResponse( + queryResponse, + endpointDefinition + ); + if (returnCode.isSuccess()) { + const returnValue = firstValue?.valueOf(); + const bonds: Bond[] = returnValue.map((bond: any) => parseBond(bond)); + return bonds; + } else { + throw new ErrContractQuery('viewPagedBonds', returnCode.toString()); + } } /** - * Returns a `Bond` object array for the given bondIds. - * @param bondIds Bond ids to query. + * Returns a `Bond` object array for the given bondIds + * @param bondIds Bond ids to query */ async viewBonds(bondIds: number[]): Promise; /** - * Returns a `Bond` object array for the given full tokenIdentifier. - * @param fullTokenIdentifier Full tokenIdentifier to query. + * Returns a `Bond` object array for the given full tokenIdentifier + * @param fullTokenIdentifier Full tokenIdentifier to query */ async viewBonds(fullTokenIdentifiers: string[]): Promise; /** - * Returns a `Bond` object array for the given tokenIdentifiers and nonces. - * @param tokenIdentifier Token identifiers array to query. - * @param nonce Nonce array to query. + * Returns a `Bond` object array for the given tokenIdentifiers and nonces + * @param tokenIdentifier Token identifiers array to query + * @param nonce Nonce array to query */ async viewBonds( tokenIdentifiers: string[], nonces: number[] ): Promise; + async viewBonds(arg1: number[] | string[], arg2?: number[]): Promise { let interaction; @@ -568,57 +644,273 @@ export class BondContract extends Contract { return setContractStateTx; } + /** + *Builds a `setAcceptedCallers` transaction to add accepted callers for the `bond` endpoint + * @param senderAddress the address of the sender + * @param addresses an array of addresses to be added as accepted callers for `bond` endpoint + */ setAcceptedCallers(senderAddress: IAddress, addresses: IAddress[]) { - throw new Error('Not implemented'); + const inputAddresses = addresses.map( + (address) => new AddressValue(address) + ); + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('setAcceptedCallers') + .setArgs(inputAddresses) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; } - setBlacklist(senderAddress: IAddress, addresses: IAddress[]) { - throw new Error('Not implemented'); + /** + *Builds a `setBlacklist` transaction to blacklist addresses + * @param senderAddress the address of the sender + * @param compensationid the compensation id to add the blacklist + * @param addresses an array of addresses to be added to the blacklist + */ + setBlacklist( + senderAddress: IAddress, + compensationId: number, + addresses: IAddress[] + ) { + const inputAddresses = addresses.map( + (address) => new AddressValue(address) + ); + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('setBlacklist') + .addArg(new U64Value(compensationId)) + .setArgs(inputAddresses) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; } - removeBlacklist(senderAddress: IAddress, addresses: IAddress[]) { - throw new Error('Not implemented'); + /** + *Builds a `removeBlacklist` transaction to remove addresses from the blacklist + * @param senderAddress the address of the sender + * @param compensationId the compensation id to remove the blacklist from + * @param addresses an array of addresses to be removed from the blacklist + */ + removeBlacklist( + senderAddress: IAddress, + compensationId: number, + addresses: IAddress[] + ) { + const toBeRemovedAddresses = addresses.map( + (address) => new AddressValue(address) + ); + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('removeBlacklist') + .addArg(new U64Value(compensationId)) + .setArgs(toBeRemovedAddresses) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; } + /** + * Builds a `removeAcceptedCallers` transaction to remove the accepted callers + * @param senderAddress the address of the sender + * @param addresses the addresses to be removed + */ removeAcceptedCallers(senderAddress: IAddress, addresses: IAddress[]) { - throw new Error('Not implemented'); + const inputAddresses = addresses.map( + (address) => new AddressValue(address) + ); + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('removeAcceptedCallers') + .setArgs(inputAddresses) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; } - setBondToken(senderAddress: IAddress, tokenIdentifier: string) { - throw new Error('Not implemented'); + /** + * Builds a `setBondToken` transaction to set the bond token + * @param senderAddress the address of the sender + * @param tokenIdentifier the token identifier. If not provided, the default token identifier based on the {@link EnvironmentsEnum} + */ + setBondToken( + senderAddress: IAddress, + tokenIdentifier = itheumTokenIdentifier[this.env as EnvironmentsEnum] + ) { + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('setBondToken') + .addArg(new TokenIdentifierValue(tokenIdentifier)) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; } + /** + * Builds a `setPeriodsBonds` transaction to set the periods and bonds + * @param senderAddress the address of the sender + * @param periods an array of periods + * @param bonds an array of bond values + */ setPeriodsBonds( senderAddress: IAddress, periods: number[], bonds: BigNumber.Value[] ) { - throw new Error('Not implemented'); + let combinedArray: TypedValue[] = []; + periods.map((period, index) => { + combinedArray.push(new U64Value(period)); + combinedArray.push(new BigUIntValue(bonds[index])); + }); + + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('setPeriodsBonds') + .setArgs(combinedArray) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; } + /** + * Builds a `removePeriodsBonds` transaction to remove the bonds for each of the specified periods + * @param senderAddress the address of the sender + * @param periods an array of periods for which the bonds should be removed + */ removePeriodsBonds(senderAddress: IAddress, periods: number[]) { - throw new Error('Not implemented'); + const inputPeriods = periods.map((period) => new U64Value(period)); + + const removePeriodsBondsTx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('removePeriodsBonds') + .setArgs(inputPeriods) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return removePeriodsBondsTx; } + /** + Builds a `setMinimumPenalty` transaction to set the minimum penalty + * @param senderAddress the address of the sender + * @param penalty the minimum penalty value to be set + */ setMinimumPenalty(senderAddress: IAddress, penalty: number) { - throw new Error('Not implemented'); + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('setMinimumPenalty') + .addArg(new U64Value(penalty)) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; } + /** + * Builds a `setMaximumPenalty` transaction to set the maximum penalty + * @param senderAddress the address of the sender + * @param penalty the maximum penalty value to be set + */ setMaximumPenalty(senderAddress: IAddress, penalty: number) { - throw new Error('Not implemented'); + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('setMaximumPenalty') + .addArg(new U64Value(penalty)) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; } + /** + * Builds a `setWithdrawPenalty` transaction to set the withdraw penalty + * @param senderAddress the address of the sender + * @param penalty the withdraw penalty value to be set + */ setWithdrawPenalty(senderAddress: IAddress, penalty: number) { - throw new Error('Not implemented'); + const tx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('setWithdrawPenalty') + .addArg(new U64Value(penalty)) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return tx; } + /** + * Builds a `refund` transaction + * @param senderAddress the address of the sender + * @param tokenIdentifier the identifier of the NFT/SFT + * @param nonce the token identifier nonce + * @param timestamp the end timestamp for the proof period for a refund + */ initiateRefund( senderAddress: IAddress, tokenIdentifier: string, nonce: number, timestamp: number ) { - throw new Error('Not implemented'); + const refundTx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('initiateRefund') + .addArg(new TokenIdentifierValue(tokenIdentifier)) + .addArg(new U64Value(nonce)) + .addArg(new U64Value(timestamp)) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 20_000_000, + chainID: this.chainID + }); + return refundTx; } /** diff --git a/src/common/utils.ts b/src/common/utils.ts index 7f24965..c6f81db 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -103,7 +103,7 @@ export function parseCompensation(value: any): Compensation { compensationId: value.compensation_id.toNumber(), tokenIdentifier: value.token_identifier.toString(), nonce: value.nonce.toNumber(), - accumulatedAmount: value.accumulate_amount.toFixed(0), + accumulatedAmount: value.accumulated_amount.toFixed(0), proofAmount: value.proof_amount.toFixed(0), endDate: value.end_date.toNumber() }; diff --git a/tests/bond.test.ts b/tests/bond.test.ts index 8e8dd99..4ca96fe 100644 --- a/tests/bond.test.ts +++ b/tests/bond.test.ts @@ -1,8 +1,14 @@ -import { BondContract, Compensation, State } from '../src'; +import { + BondContract, + Compensation, + State, + createTokenIdentifier, + dataNftTokenIdentifier +} from '../src'; import { Bond } from '../src'; -import { ErrContractAddressNotSet } from '../src/errors'; describe('Bond test', () => { + const tokenIdentifier = dataNftTokenIdentifier.devnet; test('#test no deploy', () => { try { const bondContract = new BondContract('testnet'); @@ -14,42 +20,52 @@ describe('Bond test', () => { const bondContract = new BondContract('devnet'); const bondPaymentToken = await bondContract.viewBondPaymentToken(); - expect(typeof bondPaymentToken).toBe('string'); const lockPeriodsWithBonds = await bondContract.viewLockPeriodsWithBonds(); - expect(typeof lockPeriodsWithBonds).toBe('object'); const contractState = await bondContract.viewContractState(); - expect(Object.values(State).includes(contractState)).toBe(true); const acceptedCallers = await bondContract.viewAcceptedCallers(); - expect(typeof acceptedCallers).toBe('object'); - // const bond: Bond[] = await bondContract.viewBonds([1]); - - // expect(bond).toMatchObject; - - // const sameBond: Bond[] = await bondContract.viewBonds( - // ['NEWDNFT-3a8caa'], - // [8] - // ); - - // expect(sameBond).toMatchObject; - - // const sameBond2: Bond[] = await bondContract.viewBonds([ - // 'NEWDNFT-3a8caa-08' - // ]); - // expect(sameBond2).toMatchObject; - - // const compensation: Compensation = await bondContract.viewCompensation( - // 'NEWDNFT-3a8caa', - // 8 - // ); - - // expect(compensation).toMatchObject; + const bond: Bond[] = await bondContract.viewBonds([1]); + expect(bond).toMatchObject; + const sameBond: Bond[] = await bondContract.viewBonds( + [tokenIdentifier], + [76] + ); + expect(sameBond).toMatchObject; + const sameBond2: Bond[] = await bondContract.viewBonds([ + createTokenIdentifier(tokenIdentifier, 76) + ]); + expect(sameBond2).toMatchObject; + expect(sameBond).toStrictEqual(sameBond2); + + const singleBond: Bond = await bondContract.viewBond(1); + expect(singleBond).toMatchObject; + expect(singleBond).toStrictEqual(sameBond2[0]); + + const pagedBonds: Bond[] = await bondContract.viewPagedBonds(0, 2); + expect(pagedBonds).toMatchObject; + expect(pagedBonds.length).toBe(3); + expect(pagedBonds[0]).toStrictEqual(singleBond); + + const compensation: Compensation = await bondContract.viewCompensation(1); + expect(compensation).toMatchObject; + + const compensations: Compensation[] = await bondContract.viewCompensations([ + { tokenIdentifier: tokenIdentifier, nonce: 76 } + ]); + expect(compensations).toMatchObject; + expect(compensations[0]).toStrictEqual(compensation); + + const pagedCompensations: Compensation[] = + await bondContract.viewPagedCompensations(0, 2); + expect(pagedCompensations).toMatchObject; + expect(pagedCompensations.length).toBe(3); + expect(pagedCompensations[0]).toStrictEqual(compensation); }); });