From eb8db08b40302c4abee1eef9033d3bade4af5889 Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Mon, 3 Dec 2018 19:17:39 +0100 Subject: [PATCH 1/2] :nail_care: Update lisk-elements version --- package-lock.json | 117 +++++++++++++----- package.json | 10 +- src/commands/account/create.js | 2 +- src/commands/account/get.js | 2 +- src/commands/account/show.js | 6 +- src/commands/block/get.js | 2 +- src/commands/config/set.js | 2 +- src/commands/delegate/get.js | 2 +- src/commands/delegate/voters.js | 2 +- src/commands/delegate/votes.js | 2 +- src/commands/message/decrypt.js | 6 +- src/commands/message/encrypt.js | 6 +- src/commands/message/sign.js | 6 +- src/commands/message/verify.js | 6 +- src/commands/node/forging.js | 8 +- src/commands/node/get.js | 2 +- src/commands/passphrase/decrypt.js | 7 +- src/commands/passphrase/encrypt.js | 6 +- src/commands/signature/broadcast.js | 2 +- src/commands/signature/create.js | 8 +- src/commands/transaction/broadcast.js | 4 +- src/commands/transaction/create.js | 2 +- src/commands/transaction/create/delegate.js | 6 +- .../transaction/create/multisignature.js | 6 +- .../transaction/create/second-passphrase.js | 6 +- src/commands/transaction/create/transfer.js | 6 +- src/commands/transaction/create/vote.js | 6 +- src/commands/transaction/get.js | 2 +- src/commands/transaction/sign.js | 8 +- src/commands/transaction/verify.js | 4 +- src/utils/query.ts | 6 +- test/utils/query.ts | 35 +++--- 32 files changed, 174 insertions(+), 121 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9a84094c..d0912fc9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,32 +5,44 @@ "requires": true, "dependencies": { "@liskhq/lisk-api-client": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@liskhq/lisk-api-client/-/lisk-api-client-1.1.1.tgz", - "integrity": "sha512-31qdMG55VCicQzKzk+2RAsIZwEt2o41VDOb1CnBChBvG8lKBAKBl7yrYlzRHAegvM6A3XQ0X9o8HmRha4Ah4qg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@liskhq/lisk-api-client/-/lisk-api-client-2.0.0.tgz", + "integrity": "sha512-HmIaV6tsEsedHGrgrn9vU6rTZ6pwpE5XylxkUPPRkeNVV3/vTfPWEzoKcyp9TrWBnsnpebmn56GsGzxQ8EA0EQ==", "requires": { - "@liskhq/lisk-constants": "1.1.1", - "axios": "0.18.0" + "@types/node": "10.10.1", + "@types/verror": "1.10.3", + "axios": "0.18.0", + "verror": "1.10.0" } }, "@liskhq/lisk-constants": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@liskhq/lisk-constants/-/lisk-constants-1.1.1.tgz", - "integrity": "sha512-XWnTk77cWMIsUyjK2GdpzLWU69qG0O0QaIbN4zL9Jp4l5vl0QLp/SSIBwxSb36pjQW6EBNLjuV++h5B4HoIoKg==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@liskhq/lisk-constants/-/lisk-constants-1.2.0.tgz", + "integrity": "sha512-B/1Si1eT4wOe7AaInklfT2SLenLm7U9CyfNnjaZs423Hi5Vw5xjP7KkM2nJTkqd6EUF/SJARKU/eK1R/qq0uDw==", + "requires": { + "@types/node": "10.10.1" + } }, "@liskhq/lisk-cryptography": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@liskhq/lisk-cryptography/-/lisk-cryptography-1.1.1.tgz", - "integrity": "sha512-uwChUS+Hzo56Ar1P8M+fXjBbdgZflbJoxZbJ7cp7U1IH/ZsTj53GlvcQWWc/fYSq0aN2INboW5wHOTtPObnOcw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@liskhq/lisk-cryptography/-/lisk-cryptography-2.0.0.tgz", + "integrity": "sha512-ytW7dLebHjnOr3jsCe8asoTGencsRVPncwh+JTn+rrEl3k0UVEx3WrPdKnAfU0mHnWc3CWBf9kh2huyYnHlcdw==", "requires": { - "@liskhq/lisk-constants": "1.1.1", + "@types/ed2curve": "0.2.2", + "@types/node": "10.12.0", "browserify-bignum": "1.3.0-2", "buffer-reverse": "1.0.1", "ed2curve": "0.2.1", + "sodium-native": "2.2.1", "tweetnacl": "1.0.0", "varuint-bitcoin": "1.1.0" }, "dependencies": { + "@types/node": { + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", + "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" + }, "tweetnacl": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz", @@ -39,20 +51,22 @@ } }, "@liskhq/lisk-passphrase": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@liskhq/lisk-passphrase/-/lisk-passphrase-1.1.1.tgz", - "integrity": "sha512-AcQDHHsNWtIyJ6TJ2IpDQ7K3ovv7RAx4/97pcCUP0oDfJ3kTlK74siF4bm+tIC3R0BHmZeqwf+EbU3dWzLNJrw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@liskhq/lisk-passphrase/-/lisk-passphrase-2.0.0.tgz", + "integrity": "sha512-2PKboQPq75fuP/9jlAU4GJFfbz4hD9vkwqmZfScMCu7mUdaTcLF77J+nvFkf5T/CApQZU125oCGY+9loo5FqLw==", "requires": { + "@types/bip39": "2.4.0", + "@types/node": "10.10.1", "bip39": "2.5.0" } }, "@liskhq/lisk-transactions": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@liskhq/lisk-transactions/-/lisk-transactions-1.1.1.tgz", - "integrity": "sha512-GwAw+1fbc+SsB4NMJOkztVCvPxtJ8X3FQTfz+QU1BWD+opYV/RlERZVNs6A3J8DZHHwTm29rOwkcbn+Jtc8Sew==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@liskhq/lisk-transactions/-/lisk-transactions-2.0.0.tgz", + "integrity": "sha512-usUn3PbDN9R8FjhAmhl8ZKX72vGYzurmXYn5Qa4ekH2QKlgIhysPDs4yFuvcPR8BwqRNeYR1zOwPFzaWeXH8Bg==", "requires": { - "@liskhq/lisk-constants": "1.1.1", - "@liskhq/lisk-cryptography": "1.1.1", + "@liskhq/lisk-cryptography": "2.0.0", + "@types/node": "10.10.1", "ajv": "6.5.3", "ajv-merge-patch": "4.1.0", "browserify-bignum": "1.3.0-2" @@ -274,7 +288,6 @@ "version": "2.4.0", "resolved": "https://registry.npmjs.org/@types/bip39/-/bip39-2.4.0.tgz", "integrity": "sha512-qxJBGh55SPbSGv+91D6H3WOR8vKdA/p8Oc58oK/DTbORgjO6Ebuo8MRzdy2OWi+dw/lxtX4VWJkkCUTSQvhAnw==", - "dev": true, "requires": { "@types/node": "*" } @@ -294,6 +307,21 @@ "@types/chai": "*" } }, + "@types/ed2curve": { + "version": "0.2.2", + "resolved": "http://registry.npmjs.org/@types/ed2curve/-/ed2curve-0.2.2.tgz", + "integrity": "sha512-G1sTX5xo91ydevQPINbL2nfgVAj/s1ZiqZxC8OCWduwu+edoNGUm5JXtTkg9F3LsBZbRI46/0HES4CPUE2wc9g==", + "requires": { + "tweetnacl": "^1.0.0" + }, + "dependencies": { + "tweetnacl": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz", + "integrity": "sha1-cT2LgY2kIGh0C/aDhtBHnmb8ins=" + } + } + }, "@types/expect": { "version": "1.20.3", "resolved": "http://registry.npmjs.org/@types/expect/-/expect-1.20.3.tgz", @@ -352,8 +380,7 @@ "@types/node": { "version": "10.10.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.10.1.tgz", - "integrity": "sha512-nzsx28VwfaIykfzMAG9TB3jxF5Nn+1/WMKnmVZc8TsB+LMIVvwUscVn7PAq+LFaY5ng5u4jp5mRROSswo76PPA==", - "dev": true + "integrity": "sha512-nzsx28VwfaIykfzMAG9TB3jxF5Nn+1/WMKnmVZc8TsB+LMIVvwUscVn7PAq+LFaY5ng5u4jp5mRROSswo76PPA==" }, "@types/rx": { "version": "4.1.1", @@ -518,6 +545,11 @@ "@types/node": "*" } }, + "@types/verror": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.3.tgz", + "integrity": "sha512-7Jz0MPsW2pWg5dJfEp9nJYI0RDCYfgjg2wIo5HfQ8vOJvUq0/BxT7Mv2wNQvkKBmV9uT++6KF3reMnLmh/0HrA==" + }, "ajv": { "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", @@ -1371,8 +1403,7 @@ "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cosmiconfig": { "version": "3.1.0", @@ -1748,8 +1779,7 @@ "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" }, "fancy-test": { "version": "1.4.0", @@ -2558,6 +2588,12 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "optional": true + }, "inquirer": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.0.tgz", @@ -3548,6 +3584,12 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" }, + "nan": { + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", + "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==", + "optional": true + }, "nanomatch": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", @@ -3607,6 +3649,12 @@ "text-encoding": "^0.6.4" } }, + "node-gyp-build": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.5.0.tgz", + "integrity": "sha512-qjEE8eIWVyqZhkAFUzytGpOGvLHeX5kXBB6MYyTOCPZBrBlsLyXAAzTsp/hWMbVlg8kVpzDJCZZowIrnKpwmqQ==", + "optional": true + }, "node-uuid": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", @@ -6238,6 +6286,17 @@ "hoek": "0.9.x" } }, + "sodium-native": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-2.2.1.tgz", + "integrity": "sha512-3CfftYV2ATXQFMIkLOvcNUk/Ma+lran0855j5Z/HEjUkSTzjLZi16CK362udOoNVrwn/TwGV8bKEt5OylsFrQA==", + "optional": true, + "requires": { + "ini": "^1.3.5", + "nan": "^2.4.0", + "node-gyp-build": "^3.0.0" + } + }, "sort-keys": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", @@ -6988,7 +7047,6 @@ "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "dev": true, "requires": { "assert-plus": "^1.0.0", "core-util-is": "1.0.2", @@ -6998,8 +7056,7 @@ "assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" } } }, diff --git a/package.json b/package.json index 9100fac5..31a4c853 100644 --- a/package.json +++ b/package.json @@ -104,11 +104,11 @@ "/default_config.json" ], "dependencies": { - "@liskhq/lisk-api-client": "1.1.1", - "@liskhq/lisk-constants": "1.1.1", - "@liskhq/lisk-cryptography": "1.1.1", - "@liskhq/lisk-passphrase": "1.1.1", - "@liskhq/lisk-transactions": "1.1.1", + "@liskhq/lisk-api-client": "2.0.0", + "@liskhq/lisk-constants": "1.2.0", + "@liskhq/lisk-cryptography": "2.0.0", + "@liskhq/lisk-passphrase": "2.0.0", + "@liskhq/lisk-transactions": "2.0.0", "@oclif/command": "1.5.0", "@oclif/config": "1.7.4", "@oclif/errors": "1.2.0", diff --git a/src/commands/account/create.js b/src/commands/account/create.js index 3d30c46c..a61f39bd 100644 --- a/src/commands/account/create.js +++ b/src/commands/account/create.js @@ -14,7 +14,7 @@ * */ import { flags as flagParser } from '@oclif/command'; -import cryptography from '@liskhq/lisk-cryptography'; +import * as cryptography from '@liskhq/lisk-cryptography'; import BaseCommand from '../../base'; import { createMnemonicPassphrase } from '../../utils/mnemonic'; diff --git a/src/commands/account/get.js b/src/commands/account/get.js index 40289e86..202555b6 100644 --- a/src/commands/account/get.js +++ b/src/commands/account/get.js @@ -14,7 +14,7 @@ * */ import BaseCommand from '../../base'; -import getAPIClient from '../../utils/api'; +import { getAPIClient } from '../../utils/api'; import { query } from '../../utils/query'; export default class GetCommand extends BaseCommand { diff --git a/src/commands/account/show.js b/src/commands/account/show.js index af5abf14..87d1f66a 100644 --- a/src/commands/account/show.js +++ b/src/commands/account/show.js @@ -13,11 +13,11 @@ * Removal or modification of this copyright notice is prohibited. * */ -import cryptography from '@liskhq/lisk-cryptography'; +import * as cryptography from '@liskhq/lisk-cryptography'; import { flags as flagParser } from '@oclif/command'; import BaseCommand from '../../base'; -import getInputsFromSources from '../../utils/input'; -import commonFlags from '../../utils/flags'; +import { getInputsFromSources } from '../../utils/input'; +import { flags as commonFlags } from '../../utils/flags'; const processInput = ({ passphrase }) => { const { privateKey, publicKey } = cryptography.getKeys(passphrase); diff --git a/src/commands/block/get.js b/src/commands/block/get.js index 1fe2d8b0..24064921 100644 --- a/src/commands/block/get.js +++ b/src/commands/block/get.js @@ -14,7 +14,7 @@ * */ import BaseCommand from '../../base'; -import getAPIClient from '../../utils/api'; +import { getAPIClient } from '../../utils/api'; import { query } from '../../utils/query'; export default class GetCommand extends BaseCommand { diff --git a/src/commands/config/set.js b/src/commands/config/set.js index 7147df8f..5e7ffad1 100644 --- a/src/commands/config/set.js +++ b/src/commands/config/set.js @@ -14,7 +14,7 @@ * */ import url from 'url'; -import cryptography from '@liskhq/lisk-cryptography'; +import * as cryptography from '@liskhq/lisk-cryptography'; import BaseCommand from '../../base'; import { CONFIG_VARIABLES, diff --git a/src/commands/delegate/get.js b/src/commands/delegate/get.js index 9e8a383a..100c5063 100644 --- a/src/commands/delegate/get.js +++ b/src/commands/delegate/get.js @@ -14,7 +14,7 @@ * */ import BaseCommand from '../../base'; -import getAPIClient from '../../utils/api'; +import { getAPIClient } from '../../utils/api'; import { query } from '../../utils/query'; export default class GetCommand extends BaseCommand { diff --git a/src/commands/delegate/voters.js b/src/commands/delegate/voters.js index c9754469..34029d66 100644 --- a/src/commands/delegate/voters.js +++ b/src/commands/delegate/voters.js @@ -15,7 +15,7 @@ */ import { flags as flagParser } from '@oclif/command'; import BaseCommand from '../../base'; -import getAPIClient from '../../utils/api'; +import { getAPIClient } from '../../utils/api'; import { query } from '../../utils/query'; import { SORT_FIELDS } from '../../utils/constants'; diff --git a/src/commands/delegate/votes.js b/src/commands/delegate/votes.js index 1a7d9944..65a7c572 100644 --- a/src/commands/delegate/votes.js +++ b/src/commands/delegate/votes.js @@ -15,7 +15,7 @@ */ import { flags as flagParser } from '@oclif/command'; import BaseCommand from '../../base'; -import getAPIClient from '../../utils/api'; +import { getAPIClient } from '../../utils/api'; import { query } from '../../utils/query'; import { SORT_FIELDS } from '../../utils/constants'; diff --git a/src/commands/message/decrypt.js b/src/commands/message/decrypt.js index 2a5b1715..075e1cc0 100644 --- a/src/commands/message/decrypt.js +++ b/src/commands/message/decrypt.js @@ -14,11 +14,11 @@ * */ import { flags as flagParser } from '@oclif/command'; -import cryptography from '@liskhq/lisk-cryptography'; +import * as cryptography from '@liskhq/lisk-cryptography'; import BaseCommand from '../../base'; import { ValidationError } from '../../utils/error'; -import getInputsFromSources from '../../utils/input'; -import commonFlags from '../../utils/flags'; +import { getInputsFromSources } from '../../utils/input'; +import { flags as commonFlags } from '../../utils/flags'; const processInputs = (nonce, senderPublicKey, message) => ({ passphrase, diff --git a/src/commands/message/encrypt.js b/src/commands/message/encrypt.js index b35d4671..a95afe04 100644 --- a/src/commands/message/encrypt.js +++ b/src/commands/message/encrypt.js @@ -14,11 +14,11 @@ * */ import { flags as flagParser } from '@oclif/command'; -import cryptography from '@liskhq/lisk-cryptography'; +import * as cryptography from '@liskhq/lisk-cryptography'; import BaseCommand from '../../base'; import { ValidationError } from '../../utils/error'; -import getInputsFromSources from '../../utils/input'; -import commonFlags from '../../utils/flags'; +import { getInputsFromSources } from '../../utils/input'; +import { flags as commonFlags } from '../../utils/flags'; const processInputs = (recipientPublicKey, message) => ({ passphrase, diff --git a/src/commands/message/sign.js b/src/commands/message/sign.js index 959738ed..13435c6d 100644 --- a/src/commands/message/sign.js +++ b/src/commands/message/sign.js @@ -14,11 +14,11 @@ * */ import { flags as flagParser } from '@oclif/command'; -import cryptography from '@liskhq/lisk-cryptography'; +import * as cryptography from '@liskhq/lisk-cryptography'; import BaseCommand from '../../base'; import { ValidationError } from '../../utils/error'; -import getInputsFromSources from '../../utils/input'; -import commonFlags from '../../utils/flags'; +import { getInputsFromSources } from '../../utils/input'; +import { flags as commonFlags } from '../../utils/flags'; const processInputs = message => ({ passphrase, data }) => cryptography.signMessageWithPassphrase(message || data, passphrase); diff --git a/src/commands/message/verify.js b/src/commands/message/verify.js index 339bed09..ed56ad44 100644 --- a/src/commands/message/verify.js +++ b/src/commands/message/verify.js @@ -14,11 +14,11 @@ * */ import { flags as flagParser } from '@oclif/command'; -import cryptography from '@liskhq/lisk-cryptography'; +import * as cryptography from '@liskhq/lisk-cryptography'; import BaseCommand from '../../base'; import { ValidationError } from '../../utils/error'; -import getInputsFromSources from '../../utils/input'; -import commonFlags from '../../utils/flags'; +import { getInputsFromSources } from '../../utils/input'; +import { flags as commonFlags } from '../../utils/flags'; const processInputs = (publicKey, signature, message) => ({ data }) => ({ verified: cryptography.verifyMessageWithPublicKey({ diff --git a/src/commands/node/forging.js b/src/commands/node/forging.js index 1e65860b..e814bde2 100644 --- a/src/commands/node/forging.js +++ b/src/commands/node/forging.js @@ -14,11 +14,11 @@ * */ import { flags as flagParser } from '@oclif/command'; -import transactions from '@liskhq/lisk-transactions'; +import * as transactions from '@liskhq/lisk-transactions'; import BaseCommand from '../../base'; -import commonFlags from '../../utils/flags'; -import getAPIClient from '../../utils/api'; -import getInputsFromSources from '../../utils/input'; +import { flags as commonFlags } from '../../utils/flags'; +import { getAPIClient } from '../../utils/api'; +import { getInputsFromSources } from '../../utils/input'; const STATUS_ENABLE = 'enable'; const STATUS_DISABLE = 'disable'; diff --git a/src/commands/node/get.js b/src/commands/node/get.js index 79d7680a..c7b60abd 100644 --- a/src/commands/node/get.js +++ b/src/commands/node/get.js @@ -15,7 +15,7 @@ */ import { flags as flagParser } from '@oclif/command'; import BaseCommand from '../../base'; -import getAPIClient from '../../utils/api'; +import { getAPIClient } from '../../utils/api'; export default class GetCommand extends BaseCommand { async run() { diff --git a/src/commands/passphrase/decrypt.js b/src/commands/passphrase/decrypt.js index 7ff086a5..de6ef7d2 100644 --- a/src/commands/passphrase/decrypt.js +++ b/src/commands/passphrase/decrypt.js @@ -14,11 +14,12 @@ * */ import { flags as flagParser } from '@oclif/command'; -import cryptography from '@liskhq/lisk-cryptography'; +import * as cryptography from '@liskhq/lisk-cryptography'; import BaseCommand from '../../base'; import { ValidationError } from '../../utils/error'; -import commonFlags from '../../utils/flags'; -import getInputsFromSources, { +import { flags as commonFlags } from '../../utils/flags'; +import { + getInputsFromSources, getFirstLineFromString, } from '../../utils/input'; diff --git a/src/commands/passphrase/encrypt.js b/src/commands/passphrase/encrypt.js index 2372bc80..d3cc375a 100644 --- a/src/commands/passphrase/encrypt.js +++ b/src/commands/passphrase/encrypt.js @@ -14,10 +14,10 @@ * */ import { flags as flagParser } from '@oclif/command'; -import cryptography from '@liskhq/lisk-cryptography'; +import * as cryptography from '@liskhq/lisk-cryptography'; import BaseCommand from '../../base'; -import commonFlags from '../../utils/flags'; -import getInputsFromSources from '../../utils/input'; +import { flags as commonFlags } from '../../utils/flags'; +import { getInputsFromSources } from '../../utils/input'; const outputPublicKeyOptionDescription = 'Includes the public key in the output. This option is provided for the convenience of node operators.'; diff --git a/src/commands/signature/broadcast.js b/src/commands/signature/broadcast.js index ad57d2a3..7b84b869 100644 --- a/src/commands/signature/broadcast.js +++ b/src/commands/signature/broadcast.js @@ -16,7 +16,7 @@ import BaseCommand from '../../base'; import { ValidationError } from '../../utils/error'; import { getStdIn } from '../../utils/input/utils'; -import getAPIClient from '../../utils/api'; +import { getAPIClient } from '../../utils/api'; const getSignatureInput = async () => { try { diff --git a/src/commands/signature/create.js b/src/commands/signature/create.js index b02997c0..14f1963c 100644 --- a/src/commands/signature/create.js +++ b/src/commands/signature/create.js @@ -13,14 +13,14 @@ * Removal or modification of this copyright notice is prohibited. * */ -import transactions from '@liskhq/lisk-transactions'; +import * as transactions from '@liskhq/lisk-transactions'; import { flags as flagParser } from '@oclif/command'; import BaseCommand from '../../base'; import { getStdIn } from '../../utils/input/utils'; import { ValidationError } from '../../utils/error'; -import parseTransactionString from '../../utils/transactions'; -import getInputsFromSources from '../../utils/input'; -import commonFlags from '../../utils/flags'; +import { parseTransactionString } from '../../utils/transactions'; +import { getInputsFromSources } from '../../utils/input'; +import { flags as commonFlags } from '../../utils/flags'; const getTransactionInput = async () => { try { diff --git a/src/commands/transaction/broadcast.js b/src/commands/transaction/broadcast.js index 5e18b2ec..055520be 100644 --- a/src/commands/transaction/broadcast.js +++ b/src/commands/transaction/broadcast.js @@ -14,10 +14,10 @@ * */ import BaseCommand from '../../base'; -import parseTransactionString from '../../utils/transactions'; +import { parseTransactionString } from '../../utils/transactions'; import { ValidationError } from '../../utils/error'; import { getStdIn } from '../../utils/input/utils'; -import getAPIClient from '../../utils/api'; +import { getAPIClient } from '../../utils/api'; const getTransactionInput = async () => { try { diff --git a/src/commands/transaction/create.js b/src/commands/transaction/create.js index 14366878..324b079a 100644 --- a/src/commands/transaction/create.js +++ b/src/commands/transaction/create.js @@ -15,7 +15,7 @@ */ import { flags as flagParser } from '@oclif/command'; import BaseCommand from '../../base'; -import commonFlags from '../../utils/flags'; +import { flags as commonFlags } from '../../utils/flags'; import TransferCommand from './create/transfer'; import SecondPassphraseCommand from './create/second-passphrase'; import VoteCommand from './create/vote'; diff --git a/src/commands/transaction/create/delegate.js b/src/commands/transaction/create/delegate.js index 728bef61..32d4edc2 100644 --- a/src/commands/transaction/create/delegate.js +++ b/src/commands/transaction/create/delegate.js @@ -14,10 +14,10 @@ * */ import { flags as flagParser } from '@oclif/command'; -import transactions from '@liskhq/lisk-transactions'; +import * as transactions from '@liskhq/lisk-transactions'; import BaseCommand from '../../../base'; -import commonFlags from '../../../utils/flags'; -import getInputsFromSources from '../../../utils/input'; +import { flags as commonFlags } from '../../../utils/flags'; +import { getInputsFromSources } from '../../../utils/input'; const processInputs = username => ({ passphrase, secondPassphrase }) => transactions.registerDelegate({ diff --git a/src/commands/transaction/create/multisignature.js b/src/commands/transaction/create/multisignature.js index cff1b6c9..ba23503a 100644 --- a/src/commands/transaction/create/multisignature.js +++ b/src/commands/transaction/create/multisignature.js @@ -14,10 +14,10 @@ * */ import { flags as flagParser } from '@oclif/command'; -import transactions from '@liskhq/lisk-transactions'; +import * as transactions from '@liskhq/lisk-transactions'; import BaseCommand from '../../../base'; -import commonFlags from '../../../utils/flags'; -import getInputsFromSources from '../../../utils/input'; +import { flags as commonFlags } from '../../../utils/flags'; +import { getInputsFromSources } from '../../../utils/input'; import { validateLifetime, validateMinimum } from '../../../utils/helpers'; const processInputs = (lifetime, minimum, keysgroup) => ({ diff --git a/src/commands/transaction/create/second-passphrase.js b/src/commands/transaction/create/second-passphrase.js index e29a2133..b9b25912 100644 --- a/src/commands/transaction/create/second-passphrase.js +++ b/src/commands/transaction/create/second-passphrase.js @@ -14,10 +14,10 @@ * */ import { flags as flagParser } from '@oclif/command'; -import transactions from '@liskhq/lisk-transactions'; +import * as transactions from '@liskhq/lisk-transactions'; import BaseCommand from '../../../base'; -import commonFlags from '../../../utils/flags'; -import getInputsFromSources from '../../../utils/input'; +import { flags as commonFlags } from '../../../utils/flags'; +import { getInputsFromSources } from '../../../utils/input'; export const processInputs = () => ({ passphrase, secondPassphrase }) => transactions.registerSecondPassphrase({ diff --git a/src/commands/transaction/create/transfer.js b/src/commands/transaction/create/transfer.js index d9d8501a..db392a87 100644 --- a/src/commands/transaction/create/transfer.js +++ b/src/commands/transaction/create/transfer.js @@ -14,10 +14,10 @@ * */ import { flags as flagParser } from '@oclif/command'; -import transactions from '@liskhq/lisk-transactions'; +import * as transactions from '@liskhq/lisk-transactions'; import BaseCommand from '../../../base'; -import commonFlags from '../../../utils/flags'; -import getInputsFromSources from '../../../utils/input'; +import { flags as commonFlags } from '../../../utils/flags'; +import { getInputsFromSources } from '../../../utils/input'; const dataFlag = { char: 'd', diff --git a/src/commands/transaction/create/vote.js b/src/commands/transaction/create/vote.js index 39d4afcc..9c966a70 100644 --- a/src/commands/transaction/create/vote.js +++ b/src/commands/transaction/create/vote.js @@ -14,10 +14,10 @@ * */ import { flags as flagParser } from '@oclif/command'; -import transactions from '@liskhq/lisk-transactions'; +import * as transactions from '@liskhq/lisk-transactions'; import BaseCommand from '../../../base'; -import commonFlags from '../../../utils/flags'; -import getInputsFromSources from '../../../utils/input'; +import { flags as commonFlags } from '../../../utils/flags'; +import { getInputsFromSources } from '../../../utils/input'; import { getData } from '../../../utils/input/utils'; import { ValidationError } from '../../../utils/error'; diff --git a/src/commands/transaction/get.js b/src/commands/transaction/get.js index 1dcfb4e9..cf5daf90 100644 --- a/src/commands/transaction/get.js +++ b/src/commands/transaction/get.js @@ -15,7 +15,7 @@ */ import { flags as flagParser } from '@oclif/command'; import BaseCommand from '../../base'; -import getAPIClient from '../../utils/api'; +import { getAPIClient } from '../../utils/api'; import { query, queryNodeTransaction } from '../../utils/query'; const TRANSACTION_STATES = ['unsigned', 'unprocessed']; diff --git a/src/commands/transaction/sign.js b/src/commands/transaction/sign.js index 0d6f989e..c584093b 100644 --- a/src/commands/transaction/sign.js +++ b/src/commands/transaction/sign.js @@ -13,14 +13,14 @@ * Removal or modification of this copyright notice is prohibited. * */ -import transactions from '@liskhq/lisk-transactions'; +import * as transactions from '@liskhq/lisk-transactions'; import { flags as flagParser } from '@oclif/command'; import BaseCommand from '../../base'; import { getStdIn } from '../../utils/input/utils'; import { ValidationError } from '../../utils/error'; -import parseTransactionString from '../../utils/transactions'; -import getInputsFromSources from '../../utils/input'; -import commonFlags from '../../utils/flags'; +import { parseTransactionString } from '../../utils/transactions'; +import { getInputsFromSources } from '../../utils/input'; +import { flags as commonFlags } from '../../utils/flags'; const getTransactionInput = async () => { try { diff --git a/src/commands/transaction/verify.js b/src/commands/transaction/verify.js index 736037c2..6cc17c1b 100644 --- a/src/commands/transaction/verify.js +++ b/src/commands/transaction/verify.js @@ -13,10 +13,10 @@ * Removal or modification of this copyright notice is prohibited. * */ -import transactions from '@liskhq/lisk-transactions'; +import * as transactions from '@liskhq/lisk-transactions'; import { flags as flagParser } from '@oclif/command'; import BaseCommand from '../../base'; -import parseTransactionString from '../../utils/transactions'; +import { parseTransactionString } from '../../utils/transactions'; import { getStdIn, getData } from '../../utils/input/utils'; import { ValidationError } from '../../utils/error'; diff --git a/src/utils/query.ts b/src/utils/query.ts index e9f1b98f..16e57e13 100644 --- a/src/utils/query.ts +++ b/src/utils/query.ts @@ -1,4 +1,6 @@ import { APIClient } from '@liskhq/lisk-api-client'; +// tslint:disable-next-line no-submodule-imports +import { NodeResource } from '@liskhq/lisk-api-client/dist-node/resources/node'; /* * LiskHQ/lisk-commander @@ -86,9 +88,9 @@ export const query = async ( ); export const queryNodeTransaction = - async (client: APIClient, txnState: string, parameters: QueryParameter | ReadonlyArray): Promise => + async (client: NodeResource, txnState: string, parameters: ReadonlyArray): Promise => Promise.all( - parameters.map(param => + parameters.map(async (param: QueryParameter) => client .getTransactions(txnState, param.query) .then(res => diff --git a/test/utils/query.ts b/test/utils/query.ts index 26feba45..5c21580b 100644 --- a/test/utils/query.ts +++ b/test/utils/query.ts @@ -16,7 +16,6 @@ import { expect } from 'chai'; import { query, queryNodeTransaction } from '../../src/utils/query'; import { APIClient } from '@liskhq/lisk-api-client'; -import { ApiResponse } from '@liskhq/lisk-api-client/dist-node/api_types'; describe('query utils', () => { const defaultEndpoint = 'accounts'; @@ -41,13 +40,7 @@ describe('query utils', () => { }, ]; - interface MockAPIClient { - readonly accounts: { - get: () => ApiResponse; - }; - } - - let apiClient: MockAPIClient; + let apiClient: APIClient; let response: { readonly data?: unknown; readonly no?: string; @@ -63,7 +56,7 @@ describe('query utils', () => { accounts: { get: sandbox.stub().resolves(response), }, - }; + } as any; queryResult = query( (apiClient as unknown) as APIClient, defaultEndpoint, @@ -93,13 +86,13 @@ describe('query utils', () => { accounts: { get: sandbox.stub().resolves(response), }, - }; + } as any; return Promise.resolve(); }); it('should call API client and should reject with an error', () => { queryResult = query( - (apiClient as unknown) as APIClient, + apiClient, defaultEndpoint, defaultParameters, ); @@ -122,7 +115,7 @@ describe('query utils', () => { placeholder, }; queryResult = query( - (apiClient as unknown) as APIClient, + apiClient, defaultEndpoint, paramWithPlaceholder, ); @@ -148,9 +141,9 @@ describe('query utils', () => { accounts: { get: sandbox.stub().resolves(response), }, - }; + } as any; queryResult = query( - (apiClient as unknown) as APIClient, + apiClient, defaultEndpoint, defaultParameters, ); @@ -184,7 +177,7 @@ describe('query utils', () => { accounts: { get: sandbox.stub().resolves(response), }, - }; + } as any; queryResult = query(apiClient, defaultEndpoint, defaultParameters); return Promise.resolve(); }); @@ -209,9 +202,9 @@ describe('query utils', () => { accounts: { get: sandbox.stub().resolves(response), }, - }; + } as any; queryResult = query( - (apiClient as unknown) as APIClient, + apiClient, defaultEndpoint, defaultParameters, ); @@ -239,9 +232,9 @@ describe('query utils', () => { accounts: { get: sandbox.stub().resolves(response), }, - }; + } as any; query( - (apiClient as unknown) as APIClient, + apiClient, defaultEndpoint, defaultArrayParameters, ); @@ -285,7 +278,7 @@ describe('query utils', () => { node: { getTransactions: sandbox.stub().resolves(response), }, - }; + } as any; queryResult = queryNodeTransaction( apiClient.node, txnState, @@ -335,7 +328,7 @@ describe('query utils', () => { node: { getTransactions: sandbox.stub().resolves(response), }, - }; + } as any; queryResult = queryNodeTransaction( apiClient.node, txnState, From 8651f87cf16f96bb368c8d8eb8a8d392763949b8 Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Wed, 5 Dec 2018 11:59:40 +0100 Subject: [PATCH 2/2] :recycle: Remove unneeded type conversion --- test/utils/query.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/query.ts b/test/utils/query.ts index 5c21580b..44d3eacb 100644 --- a/test/utils/query.ts +++ b/test/utils/query.ts @@ -58,7 +58,7 @@ describe('query utils', () => { }, } as any; queryResult = query( - (apiClient as unknown) as APIClient, + apiClient, defaultEndpoint, defaultParameters, );