From e5aeb37335ad28c4f0e442c3628336914757e54f Mon Sep 17 00:00:00 2001 From: serh11p Date: Mon, 21 Jun 2021 12:32:05 +0300 Subject: [PATCH] Upgrade taquito; fix fee, limits passing --- package-lock.json | 140 +++++++++++++++++++++++------------------- package.json | 6 +- src/taquito-wallet.ts | 55 +++++++++++++++-- tsconfig.json | 3 +- 4 files changed, 133 insertions(+), 71 deletions(-) diff --git a/package-lock.json b/package-lock.json index 37108bc..8ac22de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1079,9 +1079,9 @@ } }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -1196,71 +1196,71 @@ } }, "@taquito/http-utils": { - "version": "8.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@taquito/http-utils/-/http-utils-8.0.0-beta.2.tgz", - "integrity": "sha512-tL0JMvHFSaR3vpX8CjjhYt3EzT9nsTDtFj6BReehybQA6nFkKBLyhtYmH4oA58dTo0OS6tunKYXBNE6l2D/0+Q==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@taquito/http-utils/-/http-utils-9.1.1.tgz", + "integrity": "sha512-d/E3eSk+OI+esybHaFhY3M13XHSf/SAgdQS62WQZuaDBvMSwLV7fnwVJryMmrXeIA9jc/arI5dJQ0egEMaR16A==", "dev": true, "requires": { "xhr2-cookies": "^1.1.0" } }, "@taquito/michel-codec": { - "version": "8.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@taquito/michel-codec/-/michel-codec-8.0.0-beta.2.tgz", - "integrity": "sha512-d1aj2syBPTA79oGShMolNnwIapzdiBc+qw3nGp1uao5ZfaU6ragtrtTT77nJBXEkURW+Txaykd098c53va8mEA==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@taquito/michel-codec/-/michel-codec-9.1.1.tgz", + "integrity": "sha512-aeXl5LORcEapoRH+3CzCIruo8P38uvyj/+/ApzkOX0ogh0sRuYxMKkNMUgcgAatduHCrNBwh665By/pYQ5BxzQ==", "dev": true }, "@taquito/michelson-encoder": { - "version": "8.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@taquito/michelson-encoder/-/michelson-encoder-8.0.0-beta.2.tgz", - "integrity": "sha512-xtndd4okv8RTbfOsptQJHspZe8l124Nb2yQtNv8fOxOPt4VXyB0G6La/gJMHLOTcWgmRL7xQhv7eW+eZoKiT9A==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@taquito/michelson-encoder/-/michelson-encoder-9.1.1.tgz", + "integrity": "sha512-Y7vRgNyyqR6caq3jGbNdhr6ZhOBLxLxpesTQk5an/axNk8HJplNM64e2wbU9syNjjYI63xMyIi+gu2danwbHMQ==", "dev": true, "requires": { - "@taquito/rpc": "^8.0.0-beta.2", - "@taquito/utils": "^8.0.0-beta.2", + "@taquito/rpc": "^9.1.1", + "@taquito/utils": "^9.1.1", "bignumber.js": "^9.0.1", "fast-json-stable-stringify": "^2.1.0" } }, "@taquito/rpc": { - "version": "8.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@taquito/rpc/-/rpc-8.0.0-beta.2.tgz", - "integrity": "sha512-cxNSeZ7mXamLbiOUjzl8kP7uXyt2h8XoLKaVc0PVGHhi3TzFSkmbrWjKmWFvy+CAMSg+b87WaGFxL/lMAqZuyQ==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@taquito/rpc/-/rpc-9.1.1.tgz", + "integrity": "sha512-fjHirJNuuHMjSef/1iFrIbRjCAihJbliR0kK5RZXikBqlIzSTVHYNBbzJ+AgyEdOFQasDNVLGR1vcDkEr49gyg==", "dev": true, "requires": { - "@taquito/http-utils": "^8.0.0-beta.2", + "@taquito/http-utils": "^9.1.1", "bignumber.js": "^9.0.1", "lodash": "^4.17.20" }, "dependencies": { "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true } } }, "@taquito/taquito": { - "version": "8.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@taquito/taquito/-/taquito-8.0.0-beta.2.tgz", - "integrity": "sha512-FBoWKnRsojXD5Xam9SQs43uqOtIOqazMJDWsdfFw30ncP69PfZMVbpleLxV0IqGZrkEo3po5zWC4Y+Kj7DZ3VA==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@taquito/taquito/-/taquito-9.1.1.tgz", + "integrity": "sha512-A89bXRPgYKYNMXa6PBxMrkmdtkxjM0bnBpW62Dz0gHVKdxj1fXLD/rPZFCwkm9soOVSfzIqJoKWDZ37NBTzc2g==", "dev": true, "requires": { - "@taquito/http-utils": "^8.0.0-beta.2", - "@taquito/michel-codec": "^8.0.0-beta.2", - "@taquito/michelson-encoder": "^8.0.0-beta.2", - "@taquito/rpc": "^8.0.0-beta.2", - "@taquito/utils": "^8.0.0-beta.2", + "@taquito/http-utils": "^9.1.1", + "@taquito/michel-codec": "^9.1.1", + "@taquito/michelson-encoder": "^9.1.1", + "@taquito/rpc": "^9.1.1", + "@taquito/utils": "^9.1.1", "bignumber.js": "^9.0.1", "rx-sandbox": "^1.0.3", "rxjs": "^6.6.3" } }, "@taquito/utils": { - "version": "8.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@taquito/utils/-/utils-8.0.0-beta.2.tgz", - "integrity": "sha512-+D7/3hcn1XZVvPEy4VNvoUR4eIoesPU6+yH+902ZlBKGe1nuiGf977hLp2rdzj6nQRDPWiSEmG07n+ce4HWvqg==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@taquito/utils/-/utils-9.1.1.tgz", + "integrity": "sha512-gScwhOEbgiQfTS9UibIzmWoGirb1dwBoqjgNIjvbPHc/k/uXu2ftVj3HTZPLe280j7VBxgbSRGz+fECjDkWNJA==", "dev": true, "requires": { "blakejs": "^1.1.0", @@ -1296,9 +1296,9 @@ } }, "@types/istanbul-reports": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.0.tgz", - "integrity": "sha512-nwKNbvnwJ2/mndE9ItP/zc2TCzw6uuodnF4EHYWD+gCQDVBuRQL5UzbZD0/ezy1iKsFU2ZQiDqg4M9dN4+wZgA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", + "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", "dev": true, "requires": { "@types/istanbul-lib-report": "*" @@ -1338,9 +1338,9 @@ "dev": true }, "@types/yargs": { - "version": "15.0.12", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.12.tgz", - "integrity": "sha512-f+fD/fQAo3BCbCDlrUpznF1A5Zp9rB0noS5vnoormHSIPFKL0Z2DcUJ3Gxp5ytH4uLRNxy7AwYUC9exZzqGMAw==", + "version": "15.0.13", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.13.tgz", + "integrity": "sha512-kQ5JNTrbDv3Rp5X2n/iUu37IJBDU2gsZ5R/g1/KHOOEc5IKfUFjXT6DENPGduh08I/pamwtEq4oul7gUqKTQDQ==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -1628,9 +1628,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001093", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001093.tgz", - "integrity": "sha512-0+ODNoOjtWD5eS9aaIpf4K0gQqZfILNY4WSNuYzeT1sXni+lMrrVjc0odEobJt6wrODofDZUX8XYi/5y7+xl8g==", + "version": "1.0.30001239", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001239.tgz", + "integrity": "sha512-cyBkXJDMeI4wthy8xJ2FvDU6+0dtcZSJW3voUF8+e9f1bBeuvyZfc3PNbkOETyhbR+dGCPzn9E7MA3iwzusOhQ==", "dev": true }, "chalk": { @@ -2769,9 +2769,9 @@ } }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -2838,9 +2838,9 @@ } }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -2906,9 +2906,9 @@ } }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -3289,17 +3289,31 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true + }, + "typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "dev": true } } }, "micromatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", - "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", + "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", "dev": true, "requires": { "braces": "^3.0.1", - "picomatch": "^2.0.5" + "picomatch": "^2.2.3" + }, + "dependencies": { + "picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "dev": true + } } }, "minimatch": { @@ -4337,9 +4351,9 @@ "dev": true }, "react-is": { - "version": "17.0.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.1.tgz", - "integrity": "sha512-NAnt2iGDXohE5LI7uBnLnqvLQMtzhkiAOLXTmv+qnF9Ky7xAPcX8Up/xWIhxvLVGJvuLiNc4xQLtuqDRzb4fSA==", + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", "dev": true }, "readable-stream": { @@ -4700,9 +4714,9 @@ } }, "rxjs": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.3.tgz", - "integrity": "sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==", + "version": "6.6.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", + "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", "dev": true, "requires": { "tslib": "^1.9.0" @@ -5086,9 +5100,9 @@ } }, "typescript": { - "version": "3.9.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.6.tgz", - "integrity": "sha512-Pspx3oKAPJtjNwE92YS05HQoY7z2SFyOpHo9MqJor3BXAGNaPUs83CuVp9VISFkSjyRfiTpmKuAYGJB7S7hOxw==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.4.tgz", + "integrity": "sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index 9d293b9..f7e5ebb 100644 --- a/package.json +++ b/package.json @@ -31,14 +31,14 @@ "nanoid": "^3.1.10" }, "devDependencies": { - "@taquito/taquito": "^8.0.0-beta.2", + "@taquito/taquito": "^9.1.1", "microbundle": "^0.12.2", "typedoc": "^0.17.8", "typedoc-plugin-markdown": "^2.3.1", - "typescript": "^3.9.6" + "typescript": "^4.3.4" }, "peerDependencies": { - "@taquito/taquito": "^7.0.0 || ^7.0.0-beta || ^8.0.0-beta" + "@taquito/taquito": "^9.0.0" }, "publishConfig": { "access": "public" diff --git a/src/taquito-wallet.ts b/src/taquito-wallet.ts index 3de3368..b8b24e3 100644 --- a/src/taquito-wallet.ts +++ b/src/taquito-wallet.ts @@ -5,8 +5,8 @@ import { createSetDelegateOperation, createTransferOperation, WalletDelegateParams, - WalletOriginateParams, WalletTransferParams, + WalletOriginateParams, } from "@taquito/taquito"; import { @@ -70,15 +70,24 @@ export class TempleWallet implements WalletProvider { } async mapTransferParamsToWalletParams(params: WalletTransferParams) { - return createTransferOperation(params); + return this.removeDefaultParams( + params, + await createTransferOperation(this.formatParameters(params)) + ); } async mapOriginateParamsToWalletParams(params: WalletOriginateParams) { - return createOriginationOperation(params as any); + return this.removeDefaultParams( + params, + await createOriginationOperation(this.formatParameters(params)) + ); } async mapDelegateParamsToWalletParams(params: WalletDelegateParams) { - return createSetDelegateOperation(params as any); + return this.removeDefaultParams( + params, + await createSetDelegateOperation(this.formatParameters(params)) + ); } async sendOperations(opParams: any[]) { @@ -95,6 +104,38 @@ export class TempleWallet implements WalletProvider { assertConnected(this.permission); return requestBroadcast(signedOpBytes); } + + private formatParameters(params: any) { + if (params.fee) { + params.fee = params.fee.toString(); + } + if (params.storageLimit) { + params.storageLimit = params.storageLimit.toString(); + } + if (params.gasLimit) { + params.gasLimit = params.gasLimit.toString(); + } + return params; + } + + private removeDefaultParams( + params: WalletTransferParams | WalletOriginateParams | WalletDelegateParams, + operatedParams: any + ) { + // If fee, storageLimit or gasLimit is undefined by user + // in case of beacon wallet, dont override it by + // defaults. + if (!params.fee) { + delete operatedParams.fee; + } + if (!params.storageLimit) { + delete operatedParams.storage_limit; + } + if (!params.gasLimit) { + delete operatedParams.gas_limit; + } + return operatedParams; + } } export class NotConnectedTempleWalletError extends TempleWalletError { @@ -117,6 +158,8 @@ function formatOpParams(op: any) { return { ...rest, mutez: true, // The balance was already converted from Tez (ꜩ) to Mutez (uꜩ) + fee, + gasLimit: gas_limit, storageLimit: storage_limit, }; @@ -128,12 +171,16 @@ function formatOpParams(op: any) { amount: +amount, mutez: true, parameter: parameters, + fee, + gasLimit: gas_limit, storageLimit: storage_limit, }; default: return { ...rest, + fee, + gasLimit: gas_limit, storageLimit: storage_limit, }; } diff --git a/tsconfig.json b/tsconfig.json index 7e08e2e..e665c11 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -64,7 +64,8 @@ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ /* Advanced Options */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ + "skipLibCheck": true }, "include": ["src"] }