From 1e86fb745c5ff1484dccd5070fa377618afa6207 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 31 Jan 2019 21:19:36 +0100 Subject: [PATCH] Bump API for hash-value signatures (#665) * Bump API for hash-value signatures * Imports, hide tabs, not apps * Update with derive-fixed API * Remove unused type import --- packages/app-123code/src/TxButton.tsx | 2 +- packages/app-democracy/src/Voting.tsx | 17 +++- packages/app-staking/src/index.tsx | 21 ++++- packages/app-toolbox/src/index.tsx | 4 +- packages/apps/src/routing/democracy.ts | 1 - packages/apps/src/routing/staking.ts | 1 - packages/ui-api/package.json | 4 +- packages/ui-app/package.json | 6 +- packages/ui-app/src/Status/Queue.tsx | 6 +- packages/ui-reactive/package.json | 4 +- packages/ui-signer/src/Modal.tsx | 4 +- yarn.lock | 104 ++++++++++++------------- 12 files changed, 99 insertions(+), 75 deletions(-) diff --git a/packages/app-123code/src/TxButton.tsx b/packages/app-123code/src/TxButton.tsx index ee219618b0..5b1bf84755 100644 --- a/packages/app-123code/src/TxButton.tsx +++ b/packages/app-123code/src/TxButton.tsx @@ -45,7 +45,7 @@ class TxButtonInner extends React.PureComponent { queueExtrinsic({ accountId, - extrinsic: api.tx[section][method](...params) + extrinsic: api.tx[section][method](...params) as any // ??? }); } } diff --git a/packages/app-democracy/src/Voting.tsx b/packages/app-democracy/src/Voting.tsx index 906c8f9aba..6103cef699 100644 --- a/packages/app-democracy/src/Voting.tsx +++ b/packages/app-democracy/src/Voting.tsx @@ -4,16 +4,20 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { QueueProps } from '@polkadot/ui-app/Status/types'; +import { SubjectInfo } from '@polkadot/ui-keyring/observable/types'; import BN from 'bn.js'; import React from 'react'; import { InputAddress } from '@polkadot/ui-app/index'; import { QueueConsumer } from '@polkadot/ui-app/Status/Context'; +import accountObservable from '@polkadot/ui-keyring/observable/accounts'; +import { withMulti, withObservable } from '@polkadot/ui-api/index'; import VotingButtons from './VotingButtons'; import translate from './translate'; type Props = I18nProps & { + allAccounts?: SubjectInfo, referendumId: BN | number }; @@ -25,7 +29,12 @@ class Voting extends React.PureComponent { state: State = {}; render () { - const { t } = this.props; + const { allAccounts, t } = this.props; + const hasAccounts = allAccounts && Object.keys(allAccounts).length !== 0; + + if (!hasAccounts) { + return null; + } return (
@@ -67,4 +76,8 @@ class Voting extends React.PureComponent { } } -export default translate(Voting); +export default withMulti( + Voting, + translate, + withObservable(accountObservable.subject, { propName: 'allAccounts' }) +); diff --git a/packages/app-staking/src/index.tsx b/packages/app-staking/src/index.tsx index 1587a47dd2..5e7d696a7a 100644 --- a/packages/app-staking/src/index.tsx +++ b/packages/app-staking/src/index.tsx @@ -5,13 +5,15 @@ import { DerivedBalancesMap } from '@polkadot/api-derive/types'; import { AppProps, I18nProps } from '@polkadot/ui-app/types'; import { ApiProps } from '@polkadot/ui-api/types'; +import { SubjectInfo } from '@polkadot/ui-keyring/observable/types'; import { ComponentProps } from './types'; import React from 'react'; import { Route, Switch } from 'react-router'; import { AccountId, Balance } from '@polkadot/types'; import Tabs, { TabItem } from '@polkadot/ui-app/Tabs'; -import { withCalls } from '@polkadot/ui-api/index'; +import accountObservable from '@polkadot/ui-keyring/observable/accounts'; +import { withCalls, withMulti, withObservable } from '@polkadot/ui-api/index'; import './index.css'; @@ -20,6 +22,7 @@ import Overview from './Overview'; import translate from './translate'; type Props = AppProps & ApiProps & I18nProps & { + allAccounts?: SubjectInfo, balances?: DerivedBalancesMap, intentions?: Array, session_validators?: Array @@ -67,15 +70,22 @@ class App extends React.PureComponent { } render () { + const { allAccounts } = this.props; const { tabs } = this.state; const { basePath } = this.props; + const hasAccounts = allAccounts && Object.keys(allAccounts).length !== 0; + const filteredTabs = hasAccounts + ? tabs + : tabs.filter(({ name }) => + !['actions'].includes(name) + ); return (
@@ -120,10 +130,13 @@ class App extends React.PureComponent { } } -export default translate( +export default withMulti( + App, + translate, + withObservable(accountObservable.subject, { propName: 'allAccounts' }), withCalls( 'query.session.validators', ['query.staking.intentions', { propName: 'intentions' }], ['derive.staking.intentionsBalances', { propName: 'balances' }] - )(App) + ) ); diff --git a/packages/app-toolbox/src/index.tsx b/packages/app-toolbox/src/index.tsx index 0557bf7bbd..e4f65e3496 100644 --- a/packages/app-toolbox/src/index.tsx +++ b/packages/app-toolbox/src/index.tsx @@ -55,9 +55,9 @@ class ToolboxApp extends React.PureComponent { }; } render () { - const { allAccounts = {}, basePath } = this.props; + const { allAccounts, basePath } = this.props; const { tabs } = this.state; - const hasAccounts = Object.keys(allAccounts).length !== 0; + const hasAccounts = allAccounts && Object.keys(allAccounts).length !== 0; const filteredTabs = hasAccounts ? tabs : tabs.filter(({ name }) => diff --git a/packages/apps/src/routing/democracy.ts b/packages/apps/src/routing/democracy.ts index 9e26d71f91..ce2abd7731 100644 --- a/packages/apps/src/routing/democracy.ts +++ b/packages/apps/src/routing/democracy.ts @@ -10,7 +10,6 @@ export default ([ { Component: Democracy, display: { - needsAccounts: true, needsApi: [ 'query.democracy.nextTally' ] diff --git a/packages/apps/src/routing/staking.ts b/packages/apps/src/routing/staking.ts index 71ddf7771c..373232953c 100644 --- a/packages/apps/src/routing/staking.ts +++ b/packages/apps/src/routing/staking.ts @@ -10,7 +10,6 @@ export default ([ { Component: Staking, display: { - needsAccounts: true, needsApi: [ 'tx.staking.stake' ] diff --git a/packages/ui-api/package.json b/packages/ui-api/package.json index f13c87cb6e..061dd9ac67 100644 --- a/packages/ui-api/package.json +++ b/packages/ui-api/package.json @@ -31,8 +31,8 @@ "homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme", "dependencies": { "@babel/runtime": "^7.2.0", - "@polkadot/api": "^0.41.11", - "@polkadot/types": "^0.41.11", + "@polkadot/api": "^0.42.2", + "@polkadot/types": "^0.42.2", "rxjs-compat": "^6.3.2" } } diff --git a/packages/ui-app/package.json b/packages/ui-app/package.json index 7366c958ce..d71dd1f6d6 100644 --- a/packages/ui-app/package.json +++ b/packages/ui-app/package.json @@ -11,10 +11,10 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.2.0", - "@polkadot/extrinsics": "^0.41.11", + "@polkadot/extrinsics": "^0.42.2", "@polkadot/keyring": "^0.33.36", - "@polkadot/storage": "^0.41.11", - "@polkadot/types": "^0.41.11", + "@polkadot/storage": "^0.42.2", + "@polkadot/types": "^0.42.2", "@polkadot/ui-api": "^0.22.58", "@polkadot/ui-identicon": "^0.25.8", "@polkadot/ui-keyring": "^0.25.8", diff --git a/packages/ui-app/src/Status/Queue.tsx b/packages/ui-app/src/Status/Queue.tsx index 3e047d14b7..e0c03e30a6 100644 --- a/packages/ui-app/src/Status/Queue.tsx +++ b/packages/ui-app/src/Status/Queue.tsx @@ -10,7 +10,7 @@ import React from 'react'; import jsonrpc from '@polkadot/jsonrpc'; import { QueueProvider } from './Context'; -import { SubmittableSendResult } from '@polkadot/api/types'; +import { SubmittableResult } from '@polkadot/api/SubmittableExtrinsic'; export type Props = BareProps & { children: React.ReactNode @@ -82,7 +82,7 @@ export default class Queue extends React.Component { return id; } - queueSetTxStatus = (id: number, status: QueueTx$Status, result?: SubmittableSendResult, error?: Error): void => { + queueSetTxStatus = (id: number, status: QueueTx$Status, result?: SubmittableResult, error?: Error): void => { this.setState( (prevState: State): State => ({ txqueue: prevState.txqueue.map((item) => @@ -121,7 +121,7 @@ export default class Queue extends React.Component { } } - private addResultEvents ({ events = [] }: Partial = {}) { + private addResultEvents ({ events = [] }: Partial = {}) { events.filter((record) => record.event).forEach(({ event: { method, section } }) => { // filter events handled globally, or those we are not interested in // NOTE We are not splitting balances, since we want to see the transfer - even if diff --git a/packages/ui-reactive/package.json b/packages/ui-reactive/package.json index 9b0e6d40f3..ea35c2f5c9 100644 --- a/packages/ui-reactive/package.json +++ b/packages/ui-reactive/package.json @@ -31,8 +31,8 @@ "homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme", "dependencies": { "@babel/runtime": "^7.2.0", - "@polkadot/api": "^0.41.11", - "@polkadot/types": "^0.41.11", + "@polkadot/api": "^0.42.2", + "@polkadot/types": "^0.42.2", "rxjs-compat": "^6.3.2" } } diff --git a/packages/ui-signer/src/Modal.tsx b/packages/ui-signer/src/Modal.tsx index a6bc6cea82..7358f851e1 100644 --- a/packages/ui-signer/src/Modal.tsx +++ b/packages/ui-signer/src/Modal.tsx @@ -2,7 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { SubmittableSendResult } from '@polkadot/api/types'; +import { SubmittableResult } from '@polkadot/api/SubmittableExtrinsic'; import { SubmittableExtrinsic } from '@polkadot/api/promise/types'; import { ApiProps } from '@polkadot/ui-api/types'; import { I18nProps, BareProps } from '@polkadot/ui-app/types'; @@ -296,7 +296,7 @@ class Signer extends React.PureComponent { console.log('makeExtrinsicCall: extrinsic ::', extrinsic.toHex()); try { - const unsubscribe = await extrinsicCall.apply(extrinsic, [..._params, async (result: SubmittableSendResult) => { + const unsubscribe = await extrinsicCall.apply(extrinsic, [..._params, async (result: SubmittableResult) => { if (!result || !result.type || !result.status) { return; } diff --git a/yarn.lock b/yarn.lock index 61746ae1c2..e7abd03d6b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1385,31 +1385,31 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== -"@polkadot/api-derive@^0.41.11": - version "0.41.11" - resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.41.11.tgz#5304a5a8bf5caf3aa99f71fb79992820f7021cdc" - integrity sha512-31PUN2Yegk0vI9LlqlY+otFjRkD+/b9+AQg+GabqcjBy6MpRCB+X8pj7QilMiEbdBseR5w50q14RZSuCh9ikOQ== +"@polkadot/api-derive@^0.42.2": + version "0.42.2" + resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.42.2.tgz#f9170ac454b42bfcb5cb0d1ea02f6f6783183f63" + integrity sha512-iLZGPAkA6owVPg8NBXgaYaBZ8w91HNJQEfx3u4MJHNcqc9ZibX0sK8eJB53QAGEOWsjY851lr9S988/ZU8ruWw== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/api" "^0.41.11" - "@polkadot/types" "^0.41.11" + "@polkadot/api" "^0.42.2" + "@polkadot/types" "^0.42.2" "@types/memoizee" "^0.4.2" "@types/rx" "^4.1.1" memoizee "^0.4.14" rxjs "^6.3.3" -"@polkadot/api@^0.41.11": - version "0.41.11" - resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.41.11.tgz#2d2b45055dad0cca09ffd408a99127c98b7ba198" - integrity sha512-NJ8mCHEbnuA3Ml5Z3yLoXW2lnA3z+8IRdapu1xOhNOCFXvHKRsQ0qp7YRUW64jZ4Oz7bUR4KzYInyBjdt5khcQ== +"@polkadot/api@^0.42.2": + version "0.42.2" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.42.2.tgz#122f6efb4aa7b47ecfd3186342fbc8726abb9b53" + integrity sha512-wEvX7tC24ln7Yh3+hwmIkevCYrK6ai5ho1JG5r0LgmkcxgOeyNhxoRzpYXoJKDUWc/pn/EPUgRBq0KCn6yGOxA== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/api-derive" "^0.41.11" - "@polkadot/extrinsics" "^0.41.11" - "@polkadot/rpc-provider" "^0.41.11" - "@polkadot/rpc-rx" "^0.41.11" - "@polkadot/storage" "^0.41.11" - "@polkadot/types" "^0.41.11" + "@polkadot/api-derive" "^0.42.2" + "@polkadot/extrinsics" "^0.42.2" + "@polkadot/rpc-provider" "^0.42.2" + "@polkadot/rpc-rx" "^0.42.2" + "@polkadot/storage" "^0.42.2" + "@polkadot/types" "^0.42.2" "@types/rx" "^4.1.1" rxjs "^6.3.3" @@ -1489,19 +1489,19 @@ typedoc-plugin-no-inherit "^1.1.2" typescript "^3.2.2" -"@polkadot/extrinsics@^0.41.11": - version "0.41.11" - resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.41.11.tgz#ff613bbf15fe7e3d0b6d5a14288f795776b0f41f" - integrity sha512-RRAT/WSTnB+CgN4r9AV/2ltDVmJ/e2T8TQU0tn9hARuGq157wAZRO/GFPqBl4AjzU2eDRTDU0safbgpUe5O/hw== +"@polkadot/extrinsics@^0.42.2": + version "0.42.2" + resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.42.2.tgz#ea77c3d2769172ce66adb07f37ed3e95122f791e" + integrity sha512-gVGdiWfpFrF7mgNgtYdArGVzAkAIhv2CImAlW50W7cXBjk3SSvFLZSQzggCSDUq5dS6nzecIxyamKlFXZESOtA== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/types" "^0.41.11" + "@polkadot/types" "^0.42.2" "@polkadot/util" "^0.33.36" -"@polkadot/jsonrpc@^0.41.11": - version "0.41.11" - resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.41.11.tgz#6ccd1472afaf9dcf3209e4eba095cec849dd87a9" - integrity sha512-rQ1msTHujTbCa5sptdA8iZa+lRA/9shs1b2gukP2mbgksuebZauoRlk7swCB7+ylY/Y6iF5B82cqrVCNEg/Zgg== +"@polkadot/jsonrpc@^0.42.2": + version "0.42.2" + resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.42.2.tgz#4ef4ef56202d7cbfeb4929fc0a4160824bcad61e" + integrity sha512-RCDaI2KESAtwkBIMDJFPZNRTGpo84s0jFTG5mqr9Z+FXGKK8ezAr/nYBZS3nPSYnHC+IQfJpzjFzmnE4fb9AVw== dependencies: "@babel/runtime" "^7.2.0" @@ -1516,25 +1516,25 @@ "@types/bs58" "^4.0.0" bs58 "^4.0.1" -"@polkadot/rpc-core@^0.41.11": - version "0.41.11" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.41.11.tgz#ab52acbe4e948951e7b2f76c935dbf79a950d750" - integrity sha512-eX8xVjLJiz3kNF8JtHGOnkw7Q5nN7qvU5LeFNI8cz+7UjPcYplVOfXU2Rjd6X4X2a2jOJ7bg9vPkGTSYjfeH3g== +"@polkadot/rpc-core@^0.42.2": + version "0.42.2" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.42.2.tgz#42a35cf2f689d96baba9ec328af343fd6a4e8ec8" + integrity sha512-h4oJeOW8F89uqzIA6nN3kMRvGRfOP11KswJoOnDL/NCn1Grmwzl7juMjoSW8y2dg0hWnCEPkTq1FtInGEamDQg== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/jsonrpc" "^0.41.11" - "@polkadot/rpc-provider" "^0.41.11" - "@polkadot/types" "^0.41.11" + "@polkadot/jsonrpc" "^0.42.2" + "@polkadot/rpc-provider" "^0.42.2" + "@polkadot/types" "^0.42.2" "@polkadot/util" "^0.33.36" -"@polkadot/rpc-provider@^0.41.11": - version "0.41.11" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.41.11.tgz#7a5678d53a09655c022c73d907f74b13f22db8e8" - integrity sha512-HqGwKGCI3v1PpTbG92auXLeXSNtHQQMBzKmgUFjmHp3kg4rSK5yT/bLSU9u6B1KkOUWdY9+24gjFyHNX/eLrWQ== +"@polkadot/rpc-provider@^0.42.2": + version "0.42.2" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.42.2.tgz#6928d975d63013b2da1833bec7248972d336617e" + integrity sha512-RGJSqpbVSN2VuJn8IoxmSWeHgXWXdnzqDuVgU5basnbrn3P0US0VVPVlq1hl1meJf8RIVKHm58icflehD8lhNQ== dependencies: "@babel/runtime" "^7.2.0" "@polkadot/keyring" "^0.33.36" - "@polkadot/storage" "^0.41.11" + "@polkadot/storage" "^0.42.2" "@polkadot/util" "^0.33.36" "@polkadot/util-crypto" "^0.33.36" "@types/nock" "^9.3.0" @@ -1542,27 +1542,27 @@ isomorphic-fetch "^2.2.1" websocket "^1.0.28" -"@polkadot/rpc-rx@^0.41.11": - version "0.41.11" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-rx/-/rpc-rx-0.41.11.tgz#4a4d041e20d5d120fb6def485581a8f14fc016c6" - integrity sha512-RGoXZf/ZIgZGMyVgtt/lh8y0DFusqpouq4R0wq0m7YK6CcCOcqKYpXln4UZshbEWc5MHE/vY2EVTJ1NSV8OSsQ== +"@polkadot/rpc-rx@^0.42.2": + version "0.42.2" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-rx/-/rpc-rx-0.42.2.tgz#162a6446d5c279e2571aa559d601e6f215b5bdcf" + integrity sha512-S05pATaLmYJRzb6ArlafMXjEqZZlXDOux66tvljNWKIQeGQ7qKk9lZHmrp5Dho6+zAW4JGlj4RgjxPoDobOEIA== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/rpc-core" "^0.41.11" - "@polkadot/rpc-provider" "^0.41.11" + "@polkadot/rpc-core" "^0.42.2" + "@polkadot/rpc-provider" "^0.42.2" "@types/memoizee" "^0.4.2" "@types/rx" "^4.1.1" memoizee "^0.4.14" rxjs "^6.3.3" -"@polkadot/storage@^0.41.11": - version "0.41.11" - resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.41.11.tgz#86dab4a1e13a05b5a4d7278acae2eb0431279c23" - integrity sha512-MIrntyF4xClw0PgIksJFCH2LPSgv1zez/VzUMHP2JSl4CJTlrdab/ZxzJ/1vv7c2uR33FNMGK7ZjxaMFeWbY6w== +"@polkadot/storage@^0.42.2": + version "0.42.2" + resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.42.2.tgz#4661027c8cf782f38e7d71977075380949e301c4" + integrity sha512-Q6ZM6fKLP1/3SrbEByD3dvahN/Wr6xsWQYTeyPaa/S0ad/899yKir6OdR4wyKmC76N3wigOfhQQpotBngCnFlQ== dependencies: "@babel/runtime" "^7.2.0" "@polkadot/keyring" "^0.33.36" - "@polkadot/types" "^0.41.11" + "@polkadot/types" "^0.42.2" "@polkadot/util" "^0.33.36" "@polkadot/util-crypto" "^0.33.36" @@ -1571,10 +1571,10 @@ resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.52.tgz#6fb09e494d244dad4b3a9ca581bfe13beec66565" integrity sha512-sij1O0x4CY51A394RYD4/aQwDPwIxIeTOpYI4AZgdF/vq5nvF14b4XFq9vAcSnblaIosf0sYKoz1f3dkN3QqLw== -"@polkadot/types@^0.41.11": - version "0.41.11" - resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.41.11.tgz#ef9c5e7d16c2a5beb40dd1e8344a4fcb33f6627d" - integrity sha512-uhKHze2NqZFesDi+iR+5bTtEX2gm20PzrDBcGQjR2qiMEolt4O/0PMbLVL5stjDiXv5AZcZrKcpmaFujDJISbA== +"@polkadot/types@^0.42.2": + version "0.42.2" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.42.2.tgz#1cf2ce7108b490bebbb389412d36433bade93053" + integrity sha512-h4O9/wpiWKeZ4DNLuBjloMFxUatJSGNw34hYoq/QkRMeZswXCUI1l91xqYElXkhcZmfMzhjlekdaF7+RIQatMg== dependencies: "@babel/runtime" "^7.2.0" "@polkadot/keyring" "^0.33.36"