diff --git a/packages/app-home/package.json b/packages/app-home/package.json index 3340df5eb8..0cb128f83a 100644 --- a/packages/app-home/package.json +++ b/packages/app-home/package.json @@ -14,7 +14,7 @@ }, "devDependencies": { "@polkadot/rx-react": "^0.2.8", - "@polkadot/util": "^0.18.6", + "@polkadot/util": "^0.19.1", "react": "^16.3.1", "react-dom": "^16.3.1", "semantic-ui-css": "^2.3.1", diff --git a/packages/app-testing/package.json b/packages/app-testing/package.json index c801859578..12d9df3a3c 100644 --- a/packages/app-testing/package.json +++ b/packages/app-testing/package.json @@ -15,8 +15,8 @@ "devDependencies": { "@polkadot/rx-react": "^0.2.8", "@polkadot/ui-react": "^0.9.10", - "@polkadot/util": "^0.18.6", - "@polkadot/util-keyring": "^0.18.6", + "@polkadot/util": "^0.19.1", + "@polkadot/util-keyring": "^0.19.1", "react": "^16.3.1", "react-dom": "^16.3.1", "semantic-ui-css": "^2.3.1", diff --git a/packages/app-testing/src/Account.js b/packages/app-testing/src/Account.js index 69b48285c5..98aaccbd7c 100644 --- a/packages/app-testing/src/Account.js +++ b/packages/app-testing/src/Account.js @@ -18,13 +18,7 @@ type Props = BaseProps & { }; export default function Account ({ className, label, subject, style }: Props) { - const AccountBalance = withObservableParams(Balance, subject, (pair: KeyringPair) => { - if (!pair) { - return new Uint8Array([]); - } - - return pair.publicKey(); - }); + const AccountBalance = withObservableParams(Balance, subject); return (
{ - encode(senderAddr.getValue(), senderIndex.getValue(), value, Component.getValues()); + const extrinsic = extrinsics[value]; + const sender = keyring.getPair(senderAddr.getValue()); + + encode(extrinsic, sender, senderIndex.getValue(), Component.getValues()); }; return ( diff --git a/packages/app-testing/src/InputAddress/PairDisplay.js b/packages/app-testing/src/InputAddress/PairDisplay.js index 6f077c0319..3220551fc6 100644 --- a/packages/app-testing/src/InputAddress/PairDisplay.js +++ b/packages/app-testing/src/InputAddress/PairDisplay.js @@ -16,8 +16,9 @@ type Props = BaseProps & { pair: KeyringPair }; -export default function PairDisplay ({ className, name, pair, style }: Props): React$Node { +export default function PairDisplay ({ className, pair, style }: Props): React$Node { const publicKey = pair.publicKey(); + const { name } = pair.getMeta(); return (
({ - text: ( - - ), - value: name -})); +const testOptions = keyring.getPairs().map((pair) => { + const publicKey = pair.publicKey(); + + return { + text: ( + + ), + value: publicKey + }; +}); export default function InputAddress (props: Props): React$Node { const onChange = (event, { value }) => { if (props.subject) { - props.subject.next(keyring[value]); + props.subject.next(value); } }; diff --git a/packages/app-testing/src/Nonce.js b/packages/app-testing/src/Nonce.js index d682bd6210..d45ab62faf 100644 --- a/packages/app-testing/src/Nonce.js +++ b/packages/app-testing/src/Nonce.js @@ -15,13 +15,7 @@ import { senderAddr, senderIndex } from './subjects'; type Props = BaseProps & {}; -const SenderNonce = withObservableParams(RxNonce, senderAddr, (pair: KeyringPair) => { - if (!pair) { - return new Uint8Array([]); - } - - return pair.publicKey(); -}); +const SenderNonce = withObservableParams(RxNonce, senderAddr); const onNonceChange = (value: Uint8Array) => { if (!value || value.length !== 8) { return; diff --git a/packages/app-testing/src/StakingTransfer/getValues.js b/packages/app-testing/src/StakingTransfer/getValues.js index dc4a52467e..849b0f4d11 100644 --- a/packages/app-testing/src/StakingTransfer/getValues.js +++ b/packages/app-testing/src/StakingTransfer/getValues.js @@ -3,12 +3,12 @@ // of the ISC license. See the LICENSE file for details. // @flow -import { amount } from './subjects'; import { recipientAddr } from '../subjects'; +import { amount } from './subjects'; export default function getValues (): Array { return [ - recipientAddr.getValue().publicKey(), + recipientAddr.getValue(), amount.getValue() ]; } diff --git a/packages/app-testing/src/encode/index.js b/packages/app-testing/src/encode/index.js index 3ddb871cf2..58a1c383f7 100644 --- a/packages/app-testing/src/encode/index.js +++ b/packages/app-testing/src/encode/index.js @@ -6,16 +6,16 @@ // TODO: Move to API import type BN from 'bn.js'; +import type { Extrinsic } from '../extrinsics/types'; const bnToU8a = require('@polkadot/util/bn/toU8a'); const u8aConcat = require('@polkadot/util/u8a/concat'); +const u8aToHex = require('@polkadot/util/u8a/toHex'); -const extrinsics = require('../extrinsics'); const encodeParams = require('./params'); -// flowlint-next-line unclear-type:off -module.exports = function encode (sender: KeyringPair, nonce: number | BN, method: string, values: Array): Uint8Array { - const { index, params } = extrinsics[method]; +module.exports = function encode (extrinsic: Extrinsic, sender: KeyringPair, nonce: number | BN, values: Array): Uint8Array { + const { index, params } = extrinsic; const encodedParams = encodeParams(values, params); const message = u8aConcat( sender.publicKey(), @@ -25,5 +25,8 @@ module.exports = function encode (sender: KeyringPair, nonce: number | BN, metho ); const signature = sender.sign(message); + console.log('message =', u8aToHex(message)); + console.log('signature =', u8aToHex(signature)); + return u8aConcat(message, signature); }; diff --git a/yarn.lock b/yarn.lock index 4445ad8d7f..c0e2674c1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1358,6 +1358,16 @@ tweetnacl "^1.0.0" xxhashjs "^0.2.2" +"@polkadot/util-crypto@^0.19.1": + version "0.19.1" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.19.1.tgz#95927de2f8a4384f05b872132e00bfd34aa1ea77" + dependencies: + babel-runtime "^6.26.0" + blakejs "^1.1.0" + js-sha3 "^0.7.0" + tweetnacl "^1.0.0" + xxhashjs "^0.2.2" + "@polkadot/util-keyring@^0.18.4": version "0.18.4" resolved "https://registry.yarnpkg.com/@polkadot/util-keyring/-/util-keyring-0.18.4.tgz#0e2bdbb3700275025632f42171a3fecacde513e3" @@ -1374,6 +1384,14 @@ "@polkadot/util-crypto" "^0.18.6" babel-runtime "^6.26.0" +"@polkadot/util-keyring@^0.19.1": + version "0.19.1" + resolved "https://registry.yarnpkg.com/@polkadot/util-keyring/-/util-keyring-0.19.1.tgz#dbf6e9efbe1dd4de982367c279b3193584db414f" + dependencies: + "@polkadot/util" "^0.19.1" + "@polkadot/util-crypto" "^0.19.1" + babel-runtime "^6.26.0" + "@polkadot/util-rlp@^0.18.5": version "0.18.5" resolved "https://registry.yarnpkg.com/@polkadot/util-rlp/-/util-rlp-0.18.5.tgz#d06a165a1120f293056f81128f93f494ebe7b390" @@ -1417,6 +1435,15 @@ deasync "^0.1.12" ip-regex "^2.1.0" +"@polkadot/util@^0.19.1": + version "0.19.1" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.19.1.tgz#e19dc51b3d998b489ed26738a3a1e0cded65c020" + dependencies: + babel-runtime "^6.26.0" + bn.js "^4.11.8" + deasync "^0.1.12" + ip-regex "^2.1.0" + "@types/node@*": version "9.6.2" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.2.tgz#e49ac1adb458835e95ca6487bc20f916b37aff23"