diff --git a/CHANGELOG.md b/CHANGELOG.md index f5e7b9d89..ff78f1388 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes will be documented in this file. Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. ## Unreleased - - TBD + - [Define Transaction Factory and Gas Estimator](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/203) ## 10.1.2 - [Fix ABI endpoint definition: attribute "mutability"](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/200) diff --git a/package-lock.json b/package-lock.json index dd4a93f93..205631e56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,12 +40,13 @@ } }, "node_modules/@ampproject/remapping": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.1.2.tgz", - "integrity": "sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", + "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", "dev": true, "dependencies": { - "@jridgewell/trace-mapping": "^0.3.0" + "@jridgewell/gen-mapping": "^0.1.0", + "@jridgewell/trace-mapping": "^0.3.9" }, "engines": { "node": ">=6.0.0" @@ -518,10 +519,32 @@ "integrity": "sha512-5TXltWJGc+RdnabUGzhRae1TRq6m4gr+3K2wQX0is5/F2yS6MJXJvLyI3ErAnsAXuJoGqvfVD5icRgim07DrxQ==", "dev": true }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", + "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.6.tgz", + "integrity": "sha512-R7xHtBSNm+9SyvpJkdQl+qrM3Hm2fea3Ef197M3mUug+v+yR+Rhfbs7PBtcBUVnIWJ4JcAdjvij+c8hXS9p5aw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.0.tgz", + "integrity": "sha512-SfJxIxNVYLTsKwzB3MoOQ1yxf4w/E6MdkvTgrgAt1bfxjSrLUoHMKrDOykwN14q65waezZIdqDneUIPh4/sKxg==", "dev": true, "engines": { "node": ">=6.0.0" @@ -534,9 +557,9 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", @@ -610,9 +633,9 @@ "dev": true }, "node_modules/@types/long": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", - "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", + "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" }, "node_modules/@types/mocha": { "version": "9.1.0", @@ -1395,9 +1418,9 @@ "dev": true }, "node_modules/browserslist": { - "version": "4.20.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.2.tgz", - "integrity": "sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA==", + "version": "4.20.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.3.tgz", + "integrity": "sha512-NBhymBQl1zM0Y5dQT/O+xiLP9/rzOIQdKM/eMJBAq7yBgaB6krIYLGejrwVYnSHZdqjscB1SPuAjHwxjvN6Wdg==", "dev": true, "funding": [ { @@ -1410,10 +1433,10 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001317", - "electron-to-chromium": "^1.4.84", + "caniuse-lite": "^1.0.30001332", + "electron-to-chromium": "^1.4.118", "escalade": "^3.1.1", - "node-releases": "^2.0.2", + "node-releases": "^2.0.3", "picocolors": "^1.0.0" }, "bin": { @@ -1533,9 +1556,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001332", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001332.tgz", - "integrity": "sha512-10T30NYOEQtN6C11YGg411yebhvpnC6Z102+B95eAsN0oB6KUs01ivE8u+G6FMIRtIrVlYXhL+LUwQ3/hXwDWw==", + "version": "1.0.30001334", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001334.tgz", + "integrity": "sha512-kbaCEBRRVSoeNs74sCuq92MJyGrMtjWVfhltoHUCW4t4pXFvGjUBrfo47weBRViHkiV3eBYyIsfl956NtHGazw==", "dev": true, "funding": [ { @@ -2069,9 +2092,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.113", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.113.tgz", - "integrity": "sha512-s30WKxp27F3bBH6fA07FYL2Xm/FYnYrKpMjHr3XVCTUb9anAyZn/BeZfPWgTZGAbJeT4NxNwISSbLcYZvggPMA==", + "version": "1.4.127", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.127.tgz", + "integrity": "sha512-nhD6S8nKI0O2MueC6blNOEZio+/PWppE/pevnf3LOlQA/fKPCrDp2Ao4wx4LFwmIkJpVdFdn2763YWLy9ENIZg==", "dev": true }, "node_modules/elliptic": { @@ -2162,9 +2185,9 @@ } }, "node_modules/es5-ext": { - "version": "0.10.60", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.60.tgz", - "integrity": "sha512-jpKNXIt60htYG59/9FGf2PYT3pwMpnEbNKysU+k/4FGwyGtMotOvcZOuW+EmXXYASRqYSXQfGL5cVIthOTgbkg==", + "version": "0.10.61", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.61.tgz", + "integrity": "sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -2606,9 +2629,9 @@ "dev": true }, "node_modules/functions-have-names": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.2.tgz", - "integrity": "sha512-bLgc3asbWdwPbx2mNk2S49kmJCuQeu0nfmaOgbs8WIyzzkw3r4htszdIi9Q9EMezDPTYuJx2wvjZ/EwgAthpnA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -2761,9 +2784,9 @@ } }, "node_modules/has-bigints": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", - "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -3053,9 +3076,9 @@ } }, "node_modules/is-core-module": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", "dev": true, "dependencies": { "has": "^1.0.3" @@ -4036,9 +4059,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.3.tgz", - "integrity": "sha512-maHFz6OLqYxz+VQyCAtA3PTX4UP/53pa05fyDNc9CwjvJ0yEh6+xBwKsgCxMNhS8taUKBFYxfuiaD9U/55iFaw==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.4.tgz", + "integrity": "sha512-gbMzqQtTtDz/00jQzZ21PQzdI9PyLYqUSvD0p3naOhX4odFji0ZxYdnVwPTxmSwkmxhcFImpozceidSG+AgoPQ==", "dev": true }, "node_modules/normalize-path": { @@ -5384,14 +5407,14 @@ } }, "node_modules/unbox-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", - "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "dev": true, "dependencies": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", "which-boxed-primitive": "^1.0.2" }, "funding": { @@ -5689,12 +5712,13 @@ }, "dependencies": { "@ampproject/remapping": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.1.2.tgz", - "integrity": "sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", + "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", "dev": true, "requires": { - "@jridgewell/trace-mapping": "^0.3.0" + "@jridgewell/gen-mapping": "^0.1.0", + "@jridgewell/trace-mapping": "^0.3.9" } }, "@babel/code-frame": { @@ -6078,10 +6102,26 @@ } } }, + "@jridgewell/gen-mapping": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", + "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.6.tgz", + "integrity": "sha512-R7xHtBSNm+9SyvpJkdQl+qrM3Hm2fea3Ef197M3mUug+v+yR+Rhfbs7PBtcBUVnIWJ4JcAdjvij+c8hXS9p5aw==", + "dev": true + }, + "@jridgewell/set-array": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.0.tgz", + "integrity": "sha512-SfJxIxNVYLTsKwzB3MoOQ1yxf4w/E6MdkvTgrgAt1bfxjSrLUoHMKrDOykwN14q65waezZIdqDneUIPh4/sKxg==", "dev": true }, "@jridgewell/sourcemap-codec": { @@ -6091,9 +6131,9 @@ "dev": true }, "@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", "dev": true, "requires": { "@jridgewell/resolve-uri": "^3.0.3", @@ -6167,9 +6207,9 @@ "dev": true }, "@types/long": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", - "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", + "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" }, "@types/mocha": { "version": "9.1.0", @@ -6871,15 +6911,15 @@ } }, "browserslist": { - "version": "4.20.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.2.tgz", - "integrity": "sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA==", + "version": "4.20.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.3.tgz", + "integrity": "sha512-NBhymBQl1zM0Y5dQT/O+xiLP9/rzOIQdKM/eMJBAq7yBgaB6krIYLGejrwVYnSHZdqjscB1SPuAjHwxjvN6Wdg==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001317", - "electron-to-chromium": "^1.4.84", + "caniuse-lite": "^1.0.30001332", + "electron-to-chromium": "^1.4.118", "escalade": "^3.1.1", - "node-releases": "^2.0.2", + "node-releases": "^2.0.3", "picocolors": "^1.0.0" } }, @@ -6964,9 +7004,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001332", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001332.tgz", - "integrity": "sha512-10T30NYOEQtN6C11YGg411yebhvpnC6Z102+B95eAsN0oB6KUs01ivE8u+G6FMIRtIrVlYXhL+LUwQ3/hXwDWw==", + "version": "1.0.30001334", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001334.tgz", + "integrity": "sha512-kbaCEBRRVSoeNs74sCuq92MJyGrMtjWVfhltoHUCW4t4pXFvGjUBrfo47weBRViHkiV3eBYyIsfl956NtHGazw==", "dev": true }, "chai": { @@ -7422,9 +7462,9 @@ } }, "electron-to-chromium": { - "version": "1.4.113", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.113.tgz", - "integrity": "sha512-s30WKxp27F3bBH6fA07FYL2Xm/FYnYrKpMjHr3XVCTUb9anAyZn/BeZfPWgTZGAbJeT4NxNwISSbLcYZvggPMA==", + "version": "1.4.127", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.127.tgz", + "integrity": "sha512-nhD6S8nKI0O2MueC6blNOEZio+/PWppE/pevnf3LOlQA/fKPCrDp2Ao4wx4LFwmIkJpVdFdn2763YWLy9ENIZg==", "dev": true }, "elliptic": { @@ -7505,9 +7545,9 @@ } }, "es5-ext": { - "version": "0.10.60", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.60.tgz", - "integrity": "sha512-jpKNXIt60htYG59/9FGf2PYT3pwMpnEbNKysU+k/4FGwyGtMotOvcZOuW+EmXXYASRqYSXQfGL5cVIthOTgbkg==", + "version": "0.10.61", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.61.tgz", + "integrity": "sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==", "dev": true, "requires": { "es6-iterator": "^2.0.3", @@ -7876,9 +7916,9 @@ "dev": true }, "functions-have-names": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.2.tgz", - "integrity": "sha512-bLgc3asbWdwPbx2mNk2S49kmJCuQeu0nfmaOgbs8WIyzzkw3r4htszdIi9Q9EMezDPTYuJx2wvjZ/EwgAthpnA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", "dev": true }, "gensync": { @@ -7988,9 +8028,9 @@ } }, "has-bigints": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", - "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", "dev": true }, "has-flag": { @@ -8205,9 +8245,9 @@ "dev": true }, "is-core-module": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", "dev": true, "requires": { "has": "^1.0.3" @@ -8951,9 +8991,9 @@ "integrity": "sha512-amJnQCcgtRVw9SvoebO3BKGESClrfXGCUTX9hSn1OuGQTQBOZmVd0Z0OlecpuRksKvbsUqALE8jls/ErClAPuQ==" }, "node-releases": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.3.tgz", - "integrity": "sha512-maHFz6OLqYxz+VQyCAtA3PTX4UP/53pa05fyDNc9CwjvJ0yEh6+xBwKsgCxMNhS8taUKBFYxfuiaD9U/55iFaw==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.4.tgz", + "integrity": "sha512-gbMzqQtTtDz/00jQzZ21PQzdI9PyLYqUSvD0p3naOhX4odFji0ZxYdnVwPTxmSwkmxhcFImpozceidSG+AgoPQ==", "dev": true }, "normalize-path": { @@ -10037,14 +10077,14 @@ } }, "unbox-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", - "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "dev": true, "requires": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", "which-boxed-primitive": "^1.0.2" } }, diff --git a/src/gasEstimator.spec.ts b/src/gasEstimator.spec.ts new file mode 100644 index 000000000..740ed4ef2 --- /dev/null +++ b/src/gasEstimator.spec.ts @@ -0,0 +1,42 @@ +import { assert } from "chai"; +import { GasEstimator } from "./gasEstimator"; + +describe("test gas estimator", () => { + it("should estimate gas limit (default gas configuration)", () => { + const estimator = new GasEstimator(); + + assert.equal(estimator.forEGLDTransfer(0), 50000); + assert.equal(estimator.forEGLDTransfer(3), 50000 + 3 * 1500); + + assert.equal(estimator.forESDTTransfer(80), 50000 + 80 * 1500 + 200000 + 100000); + assert.equal(estimator.forESDTTransfer(100), 50000 + 100 * 1500 + 200000 + 100000); + + assert.equal(estimator.forESDTNFTTransfer(80), 50000 + 80 * 1500 + 200000 + 800000); + assert.equal(estimator.forESDTNFTTransfer(100), 50000 + 100 * 1500 + 200000 + 800000); + + assert.equal(estimator.forMultiESDTNFTTransfer(80, 1), 50000 + 80 * 1500 + (200000 + 800000) * 1); + assert.equal(estimator.forMultiESDTNFTTransfer(80, 3), 50000 + 80 * 1500 + (200000 + 800000) * 3); + }); + + it("should estimate gas limit (custom gas configuration)", () => { + const estimator = new GasEstimator({ + minGasLimit: 10000, + gasPerDataByte: 3000, + gasCostESDTTransfer: 200000, + gasCostESDTNFTTransfer: 300000, + gasCostESDTNFTMultiTransfer: 400000 + }); + + assert.equal(estimator.forEGLDTransfer(0), 10000); + assert.equal(estimator.forEGLDTransfer(3), 10000 + 3 * 3000); + + assert.equal(estimator.forESDTTransfer(80), 10000 + 80 * 3000 + 200000 + 100000); + assert.equal(estimator.forESDTTransfer(100), 10000 + 100 * 3000 + 200000 + 100000); + + assert.equal(estimator.forESDTNFTTransfer(80), 10000 + 80 * 3000 + 300000 + 800000); + assert.equal(estimator.forESDTNFTTransfer(100), 10000 + 100 * 3000 + 300000 + 800000); + + assert.equal(estimator.forMultiESDTNFTTransfer(80, 1), 10000 + 80 * 3000 + (400000 + 800000) * 1); + assert.equal(estimator.forMultiESDTNFTTransfer(80, 3), 10000 + 80 * 3000 + (400000 + 800000) * 3); + }); +}); diff --git a/src/gasEstimator.ts b/src/gasEstimator.ts new file mode 100644 index 000000000..ad43ad80f --- /dev/null +++ b/src/gasEstimator.ts @@ -0,0 +1,73 @@ +interface IGasConfiguration { + readonly minGasLimit: number; + readonly gasPerDataByte: number; + readonly gasCostESDTTransfer: number; + readonly gasCostESDTNFTTransfer: number; + readonly gasCostESDTNFTMultiTransfer: number; +} + +/** + * This is mirroring (on a best efforts basis) the network's gas configuration & gas schedule: + * - https://gateway.elrond.com/network/config + * - https://github.com/ElrondNetwork/elrond-config-mainnet/tree/master/gasSchedules + * - https://github.com/ElrondNetwork/elrond-config-mainnet/blob/master/enableEpochs.toml#L200 + */ +export const DefaultGasConfiguration: IGasConfiguration = { + minGasLimit: 50000, + gasPerDataByte: 1500, + gasCostESDTTransfer: 200000, + gasCostESDTNFTTransfer: 200000, + gasCostESDTNFTMultiTransfer: 200000 +}; + +// Additional gas to account for eventual increases in gas requirements (thus avoid fast-breaking changes in clients of erdjs). +const ADDITIONAL_GAS_FOR_ESDT_TRANSFER = 100000; + +// Additional gas to account for extra blockchain operations (e.g. data movement (between accounts) for NFTs), +// and for eventual increases in gas requirements (thus avoid fast-breaking changes in clients of erdjs). +const ADDITIONAL_GAS_FOR_ESDT_NFT_TRANSFER = 800000; + +export class GasEstimator { + private readonly gasConfiguration: IGasConfiguration; + + constructor(gasConfiguration?: IGasConfiguration) { + this.gasConfiguration = gasConfiguration || DefaultGasConfiguration; + } + + forEGLDTransfer(dataLength: number) { + const gasLimit = + this.gasConfiguration.minGasLimit + + this.gasConfiguration.gasPerDataByte * dataLength; + + return gasLimit; + } + + forESDTTransfer(dataLength: number) { + const gasLimit = + this.gasConfiguration.minGasLimit + + this.gasConfiguration.gasCostESDTTransfer + + this.gasConfiguration.gasPerDataByte * dataLength + + ADDITIONAL_GAS_FOR_ESDT_TRANSFER; + + return gasLimit; + } + + forESDTNFTTransfer(dataLength: number) { + const gasLimit = + this.gasConfiguration.minGasLimit + + this.gasConfiguration.gasCostESDTNFTTransfer + + this.gasConfiguration.gasPerDataByte * dataLength + + ADDITIONAL_GAS_FOR_ESDT_NFT_TRANSFER; + + return gasLimit; + } + + forMultiESDTNFTTransfer(dataLength: number, numTransfers: number) { + const gasLimit = + this.gasConfiguration.minGasLimit + + (this.gasConfiguration.gasCostESDTNFTMultiTransfer + ADDITIONAL_GAS_FOR_ESDT_NFT_TRANSFER) * numTransfers + + this.gasConfiguration.gasPerDataByte * dataLength; + + return gasLimit; + } +} diff --git a/src/index.ts b/src/index.ts index f68c1ee17..6fe6acdc6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,9 @@ export * from "./errors"; export * from "./account"; export * from "./address"; export * from "./asyncTimer"; +export * from "./gasEstimator"; export * from "./transaction"; +export * from "./transactionFactory"; export * from "./transactionPayload"; export * from "./transactionWatcher"; export * from "./logger"; diff --git a/src/interface.ts b/src/interface.ts index 1d368143b..aa0becbd8 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -17,8 +17,16 @@ export interface IChainID { valueOf(): string; } export interface IGasLimit { valueOf(): number; } export interface IGasPrice { valueOf(): number; } +export interface ITransactionPayload { + length(): number; + encoded(): string; + toString(): string; + valueOf(): Buffer; +} + export interface ITokenPayment { readonly tokenIdentifier: string; readonly nonce: number; readonly amountAsBigInteger: BigNumber; + valueOf(): BigNumber; } diff --git a/src/proto/serializer.ts b/src/proto/serializer.ts index b83685c93..33b9c763a 100644 --- a/src/proto/serializer.ts +++ b/src/proto/serializer.ts @@ -30,7 +30,7 @@ export class ProtoSerializer { SndUserName: null, GasPrice: transaction.getGasPrice().valueOf(), GasLimit: transaction.getGasLimit().valueOf(), - Data: transaction.getData().isEmpty() ? null : transaction.getData().valueOf(), + Data: transaction.getData().length() == 0 ? null : transaction.getData().valueOf(), ChainID: Buffer.from(transaction.getChainID().valueOf()), Version: transaction.getVersion().valueOf(), Signature: Buffer.from(transaction.getSignature().hex(), "hex") diff --git a/src/tokenTransferBuilders.ts b/src/tokenTransferBuilders.ts index e4260a9a2..53d444612 100644 --- a/src/tokenTransferBuilders.ts +++ b/src/tokenTransferBuilders.ts @@ -1,14 +1,14 @@ import { Address } from "./address"; -import { IAddress } from "./interface"; +import { IAddress, ITokenPayment } from "./interface"; import { ArgSerializer } from "./smartcontracts/argSerializer"; import { AddressValue, BigUIntValue, BytesValue, TypedValue, U16Value, U64Value } from "./smartcontracts/typesystem"; import { TokenPayment } from "./tokenPayment"; import { TransactionPayload } from "./transactionPayload"; export class ESDTTransferPayloadBuilder { - payment = TokenPayment.fungibleFromAmount("", "0", 0); + payment: ITokenPayment = TokenPayment.fungibleFromAmount("", "0", 0); - setPayment(payment: TokenPayment): ESDTTransferPayloadBuilder { + setPayment(payment: ITokenPayment): ESDTTransferPayloadBuilder { this.payment = payment; return this; } @@ -28,10 +28,10 @@ export class ESDTTransferPayloadBuilder { } export class ESDTNFTTransferPayloadBuilder { - payment: TokenPayment = TokenPayment.nonFungible("", 0); + payment: ITokenPayment = TokenPayment.nonFungible("", 0); destination: IAddress = new Address(""); - setPayment(payment: TokenPayment): ESDTNFTTransferPayloadBuilder { + setPayment(payment: ITokenPayment): ESDTNFTTransferPayloadBuilder { this.payment = payment; return this; } @@ -60,10 +60,10 @@ export class ESDTNFTTransferPayloadBuilder { } export class MultiESDTNFTTransferPayloadBuilder { - payments: TokenPayment[] = []; + payments: ITokenPayment[] = []; destination: IAddress = new Address(""); - setPayments(payments: TokenPayment[]): MultiESDTNFTTransferPayloadBuilder { + setPayments(payments: ITokenPayment[]): MultiESDTNFTTransferPayloadBuilder { this.payments = payments; return this; } diff --git a/src/transaction.ts b/src/transaction.ts index 864c38bcd..7f35fc28b 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -1,5 +1,5 @@ import { BigNumber } from "bignumber.js"; -import { IAddress, IChainID, IGasLimit, IGasPrice, INonce, ISignature, ITransactionValue } from "./interface"; +import { IAddress, IChainID, IGasLimit, IGasPrice, INonce, ISignature, ITransactionPayload, ITransactionValue } from "./interface"; import { Address } from "./address"; import { TransactionOptions, @@ -54,7 +54,7 @@ export class Transaction { /** * The payload of the transaction. */ - private readonly data: TransactionPayload; + private readonly data: ITransactionPayload; /** * The chain ID of the Network (e.g. "1" for Mainnet). @@ -102,7 +102,7 @@ export class Transaction { sender?: IAddress; gasPrice?: IGasPrice; gasLimit: IGasLimit; - data?: TransactionPayload; + data?: ITransactionPayload; chainID: IChainID; version?: TransactionVersion; options?: TransactionOptions; @@ -165,7 +165,7 @@ export class Transaction { this.gasLimit = gasLimit; } - getData(): TransactionPayload { + getData(): ITransactionPayload { return this.data; } @@ -226,7 +226,7 @@ export class Transaction { sender: sender ? sender.bech32() : this.sender.bech32(), gasPrice: this.gasPrice.valueOf(), gasLimit: this.gasLimit.valueOf(), - data: this.data.isEmpty() ? undefined : this.data.encoded(), + data: this.data.length() == 0 ? undefined : this.data.encoded(), chainID: this.chainID.valueOf(), version: this.version.valueOf(), options: this.options.valueOf() == 0 ? undefined : this.options.valueOf(), diff --git a/src/transactionFactory.spec.ts b/src/transactionFactory.spec.ts new file mode 100644 index 000000000..80d8ee7dc --- /dev/null +++ b/src/transactionFactory.spec.ts @@ -0,0 +1,86 @@ +import { assert } from "chai"; +import { Address } from "./address"; +import { GasEstimator } from "./gasEstimator"; +import { TokenPayment } from "./tokenPayment"; +import { TransactionFactory } from "./transactionFactory"; +import { TransactionPayload } from "./transactionPayload"; + +describe("test transaction factory", () => { + const factory = new TransactionFactory(new GasEstimator()); + + it("should create EGLD transfers", () => { + const transactionWithData = factory.createEGLDTransfer({ + value: TokenPayment.egldFromAmount(10.5), + receiver: new Address("erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"), + data: new TransactionPayload("hello"), + chainID: "D" + }) + + assert.equal(transactionWithData.getReceiver().bech32(), "erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"); + assert.equal(transactionWithData.getValue(), "10500000000000000000"); + assert.equal(transactionWithData.getGasLimit(), 50000 + 5 * 1500); + assert.equal(transactionWithData.getData().toString(), "hello"); + assert.equal(transactionWithData.getChainID(), "D"); + + const transactionWithoutData = factory.createEGLDTransfer({ + value: TokenPayment.egldFromAmount(10.5), + receiver: new Address("erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"), + chainID: "D" + }) + + assert.equal(transactionWithoutData.getReceiver().bech32(), "erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"); + assert.equal(transactionWithoutData.getValue(), "10500000000000000000"); + assert.equal(transactionWithoutData.getGasLimit(), 50000); + assert.equal(transactionWithoutData.getData().toString(), ""); + assert.equal(transactionWithoutData.getChainID(), "D"); + }); + + it("should create ESDT transfers", () => { + const transaction = factory.createESDTTransfer({ + payment: TokenPayment.fungibleFromAmount("COUNTER-8b028f", "100.00", 0), + receiver: new Address("erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"), + chainID: "D" + }) + + assert.equal(transaction.getReceiver().bech32(), "erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"); + assert.equal(transaction.getValue(), ""); + assert.equal(transaction.getGasLimit(), 50000 + 44 * 1500 + 200000 + 100000); + assert.equal(transaction.getData().toString(), "ESDTTransfer@434f554e5445522d386230323866@64"); + assert.equal(transaction.getChainID(), "D"); + }); + + it("should create ESDTNFT transfers", () => { + const transaction = factory.createESDTNFTTransfer({ + payment: TokenPayment.nonFungible("ERDJS-38f249", 1), + destination: new Address("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"), + sender: new Address("erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"), + chainID: "D" + }) + + assert.equal(transaction.getSender().bech32(), "erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"); + assert.equal(transaction.getReceiver().bech32(), "erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"); + assert.equal(transaction.getValue(), ""); + assert.equal(transaction.getGasLimit(), 50000 + 111 * 1500 + 200000 + 800000); + assert.equal(transaction.getData().toString(), "ESDTNFTTransfer@4552444a532d333866323439@01@01@8049d639e5a6980d1cd2392abcce41029cda74a1563523a202f09641cc2618f8"); + assert.equal(transaction.getChainID(), "D"); + }); + + it("should create Multi ESDTNFT transfers", () => { + const transaction = factory.createMultiESDTNFTTransfer({ + payments: [ + TokenPayment.nonFungible("ERDJS-38f249", 1), + TokenPayment.fungibleFromAmount("BAR-c80d29", "10.00", 18) + ], + destination: new Address("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"), + sender: new Address("erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"), + chainID: "D" + }) + + assert.equal(transaction.getSender().bech32(), "erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"); + assert.equal(transaction.getReceiver().bech32(), "erd1dc3yzxxeq69wvf583gw0h67td226gu2ahpk3k50qdgzzym8npltq7ndgha"); + assert.equal(transaction.getValue(), ""); + assert.equal(transaction.getGasLimit(), 50000 + 158 * 1500 + (200000 + 800000) * 2); + assert.equal(transaction.getData().toString(), "MultiESDTNFTTransfer@0139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e1@02@4552444a532d333866323439@01@01@4241522d633830643239@@8ac7230489e80000"); + assert.equal(transaction.getChainID(), "D"); + }); +}); diff --git a/src/transactionFactory.ts b/src/transactionFactory.ts new file mode 100644 index 000000000..592aa5749 --- /dev/null +++ b/src/transactionFactory.ts @@ -0,0 +1,126 @@ +import { IAddress, IChainID, IGasLimit, IGasPrice, INonce, ITokenPayment, ITransactionPayload, ITransactionValue } from "./interface"; +import { ESDTNFTTransferPayloadBuilder, ESDTTransferPayloadBuilder, MultiESDTNFTTransferPayloadBuilder } from "./tokenTransferBuilders"; +import { Transaction } from "./transaction"; + +interface IGasEstimator { + forEGLDTransfer(dataLength: number): number; + forESDTTransfer(dataLength: number): number; + forESDTNFTTransfer(dataLength: number): number; + forMultiESDTNFTTransfer(dataLength: number, numTransfers: number): number; +} + +export class TransactionFactory { + private readonly gasEstimator; + + constructor(gasEstimator: IGasEstimator) { + this.gasEstimator = gasEstimator; + } + + createEGLDTransfer(args: { + nonce?: INonce; + value: ITransactionValue; + receiver: IAddress; + sender?: IAddress; + gasPrice?: IGasPrice; + gasLimit?: IGasLimit; + data?: ITransactionPayload; + chainID: IChainID; + }) { + const dataLength = args.data?.length() || 0; + const estimatedGasLimit = this.gasEstimator.forEGLDTransfer(dataLength); + + return new Transaction({ + nonce: args.nonce, + value: args.value, + receiver: args.receiver, + sender: args.sender, + gasPrice: args.gasPrice, + gasLimit: args.gasLimit || estimatedGasLimit, + data: args.data, + chainID: args.chainID + }); + } + + createESDTTransfer(args: { + payment: ITokenPayment, + nonce?: INonce; + receiver: IAddress; + sender?: IAddress; + gasPrice?: IGasPrice; + gasLimit?: IGasLimit; + chainID: IChainID; + }) { + const transactionPayload = new ESDTTransferPayloadBuilder() + .setPayment(args.payment) + .build(); + + const dataLength = transactionPayload.length() || 0; + const estimatedGasLimit = this.gasEstimator.forESDTTransfer(dataLength); + + return new Transaction({ + nonce: args.nonce, + receiver: args.receiver, + sender: args.sender, + gasPrice: args.gasPrice, + gasLimit: args.gasLimit || estimatedGasLimit, + data: transactionPayload, + chainID: args.chainID + }); + } + + createESDTNFTTransfer(args: { + payment: ITokenPayment, + nonce?: INonce; + destination: IAddress; + sender: IAddress; + gasPrice?: IGasPrice; + gasLimit?: IGasLimit; + chainID: IChainID; + }) { + const transactionPayload = new ESDTNFTTransferPayloadBuilder() + .setPayment(args.payment) + .setDestination(args.destination) + .build(); + + const dataLength = transactionPayload.length() || 0; + const estimatedGasLimit = this.gasEstimator.forESDTNFTTransfer(dataLength); + + return new Transaction({ + nonce: args.nonce, + receiver: args.sender, + sender: args.sender, + gasPrice: args.gasPrice, + gasLimit: args.gasLimit || estimatedGasLimit, + data: transactionPayload, + chainID: args.chainID + }); + } + + createMultiESDTNFTTransfer(args: { + payments: ITokenPayment[], + nonce?: INonce; + destination: IAddress; + sender: IAddress; + gasPrice?: IGasPrice; + gasLimit?: IGasLimit; + chainID: IChainID; + }) { + const transactionPayload = new MultiESDTNFTTransferPayloadBuilder() + .setPayments(args.payments) + .setDestination(args.destination) + .build(); + + const dataLength = transactionPayload.length() || 0; + const estimatedGasLimit = this.gasEstimator.forMultiESDTNFTTransfer(dataLength, args.payments.length); + + return new Transaction({ + nonce: args.nonce, + receiver: args.sender, + sender: args.sender, + gasPrice: args.gasPrice, + gasLimit: args.gasLimit || estimatedGasLimit, + data: transactionPayload, + chainID: args.chainID + }); + } +}