From 014ae780e4870589f568100f978738457a6bbb2e Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sat, 12 Jan 2019 09:38:07 +0100 Subject: [PATCH] Split ui-api, update API version (#589) * Split ui-api, update API version * Update (awaiting API changes to go through) * Cleanup ui-api exports * Bump API (SubscriptionPromise support) * Linting fixes * Update renames * Do display balances.Transfer (shows for non-owned accounts) * Bump API --- jest.config.js | 2 +- packages/app-accounts/src/index.tsx | 2 +- packages/app-addresses/src/index.tsx | 2 +- packages/app-democracy/package.json | 2 +- packages/app-democracy/src/Item.tsx | 2 +- packages/app-democracy/src/Proposal.tsx | 4 +- packages/app-democracy/src/Proposals.tsx | 2 +- packages/app-democracy/src/Referendum.tsx | 6 +- packages/app-democracy/src/Referendums.tsx | 2 +- packages/app-democracy/src/Summary.tsx | 4 +- packages/app-democracy/src/VotingButtons.tsx | 4 +- packages/app-explorer/src/BestHash.tsx | 6 +- .../src/BlockByHash/BlockByHash.tsx | 6 +- .../src/BlockHeader/BlockHash.tsx | 2 +- .../src/BlockHeader/Extrinsics.tsx | 2 +- .../app-explorer/src/BlockHeader/index.tsx | 2 +- packages/app-explorer/src/BlockHeaders.tsx | 2 +- packages/app-explorer/src/Events.tsx | 2 +- packages/app-explorer/src/Summary.tsx | 2 +- packages/app-explorer/src/SummarySession.tsx | 2 +- packages/app-extrinsics/src/Account.tsx | 2 +- packages/app-extrinsics/src/Extrinsic.tsx | 4 +- packages/app-extrinsics/src/Nonce.tsx | 2 +- packages/app-extrinsics/src/Params/Call.tsx | 4 +- .../app-extrinsics/src/Params/Proposal.tsx | 4 +- packages/app-extrinsics/src/Selection.tsx | 4 +- packages/app-extrinsics/src/index.tsx | 2 +- packages/app-rpc/src/Account.tsx | 2 +- packages/app-settings/package.json | 2 +- packages/app-staking/package.json | 2 +- .../app-staking/src/Overview/CurrentList.tsx | 2 +- packages/app-staking/src/Overview/Summary.tsx | 6 +- packages/app-staking/src/Overview/index.tsx | 2 +- .../app-staking/src/StakeList/Account.tsx | 6 +- .../src/StakeList/UnnominateButton.tsx | 2 +- packages/app-staking/src/StakeList/index.tsx | 2 +- packages/app-staking/src/index.tsx | 4 +- packages/app-storage/src/Query.tsx | 4 +- .../app-storage/src/Selection/Modules.tsx | 4 +- packages/app-transfer/package.json | 2 +- packages/app-transfer/src/Fees.tsx | 6 +- packages/app-transfer/src/Submit.tsx | 2 +- packages/app-transfer/src/Transfer.tsx | 6 +- packages/app-transfer/src/index.tsx | 2 +- packages/apps/src/Connecting/index.tsx | 4 +- packages/apps/src/Content/index.tsx | 4 +- packages/apps/src/NodeInfo.tsx | 2 +- packages/apps/src/SideBar/Item.tsx | 4 +- packages/apps/src/Status.tsx | 2 +- packages/apps/webpack.config.js | 3 +- packages/{ui-react-rx => ui-api}/LICENSE | 0 packages/{ui-react-rx => ui-api}/README.md | 4 +- packages/ui-api/package.json | 38 ++++ .../src/Api/index.tsx => ui-api/src/Api.tsx} | 9 +- packages/ui-api/src/ApiContext.ts | 18 ++ .../src/derive/balances/accountIdAndIndex.tsx | 6 +- .../src/derive/balances/accountIdToIndex.ts | 6 +- .../src/derive/balances/accountIndexToId.ts | 6 +- .../src/derive/balances/accountIndexes.ts | 26 ++- .../src/derive/balances/fees.ts | 6 +- .../src/derive/balances/index.ts | 2 +- .../src/derive/balances/validatingBalance.tsx | 6 +- .../derive/balances/validatingBalances.tsx | 6 +- .../src/derive/balances/votingBalance.tsx | 24 ++- .../src/derive/balances/votingBalances.tsx | 6 +- .../balances/votingBalancesNominatorsFor.ts | 38 ++++ .../src/derive/chain/bestNumber.ts | 8 +- .../src/derive/chain/bestNumberFinalised.ts | 8 +- .../src/derive/chain/index.ts | 2 +- .../src/derive/democracy/index.ts | 2 +- .../src/derive/democracy/referendumInfos.tsx | 6 +- .../derive/democracy/referendumVotesFor.ts | 34 +-- .../src/derive/democracy/referendums.ts | 24 ++- .../src/derive/democracy/votes.tsx | 6 +- .../src/derive/index.ts | 2 +- .../src/derive/session/eraLength.ts | 6 +- .../src/derive/session/eraProgress.ts | 6 +- .../src/derive/session/index.ts | 2 +- .../src/derive/session/sessionProgress.ts | 6 +- .../src/derive/types.ts | 6 +- packages/ui-api/src/index.ts | 13 ++ .../src/with => ui-api/src}/transform/echo.ts | 2 +- packages/{ui-react-rx => ui-api}/src/types.ts | 2 +- .../src/util/balanceFormat.spec.js | 0 packages/ui-api/src/util/balanceFormat.ts | 95 +++++++++ packages/ui-api/src/util/decimalFormat.ts | 9 + .../{ui-react-rx => ui-api}/src/util/index.ts | 2 +- .../src/util/intervalObservable.ts | 2 +- .../src/util/intervalTimer.ts | 2 +- .../src/util/isEqual.ts | 2 +- .../src/util/isTestChain.spec.js | 2 +- .../src/util/isTestChain.ts | 2 +- packages/ui-api/src/util/numberFormat.ts | 21 ++ .../src/util/triggerChange.ts | 2 +- .../{ui-react-rx => ui-api}/src/with/api.tsx | 4 +- .../{ui-react-rx => ui-api}/src/with/call.tsx | 17 +- .../src/with/callDiv.tsx | 2 +- .../{ui-react-rx => ui-api}/src/with/index.ts | 2 +- .../{ui-react-rx => ui-api}/src/with/multi.ts | 2 +- .../src/with/observable.tsx | 4 +- .../{ui-react-rx => ui-api}/src/with/types.ts | 2 +- .../{ui-react-rx => ui-api}/test/enzyme.js | 2 +- .../test/observable.js | 2 +- .../{ui-react-rx => ui-api}/webpack.config.js | 2 +- packages/ui-app/package.json | 9 +- packages/ui-app/src/AddressMini.tsx | 2 +- packages/ui-app/src/AddressRow.tsx | 2 +- packages/ui-app/src/AddressSummary.tsx | 4 +- packages/ui-app/src/Balance.tsx | 4 +- packages/ui-app/src/InputAddress/index.tsx | 2 +- packages/ui-app/src/InputExtrinsic/index.tsx | 4 +- packages/ui-app/src/InputNumber.tsx | 2 +- .../ui-app/src/InputStorage/SelectKey.tsx | 4 +- packages/ui-app/src/InputStorage/index.tsx | 4 +- packages/ui-app/src/Status/Queue.tsx | 4 +- packages/ui-app/src/Status/index.tsx | 4 +- packages/ui-app/src/index.tsx | 2 +- packages/ui-params/src/Param/Amount.tsx | 2 +- packages/ui-params/src/valueToText.tsx | 2 +- packages/ui-react-rx/src/Api/Context.ts | 18 -- .../balances/votingBalancesNominatorsFor.ts | 32 --- packages/ui-reactive/LICENSE | 201 ++++++++++++++++++ packages/ui-reactive/README.md | 36 ++++ .../{ui-react-rx => ui-reactive}/index.html | 0 .../{ui-react-rx => ui-reactive}/package.json | 8 +- .../src/Balance.tsx | 6 +- .../src/BestFinalised.tsx | 6 +- .../src/BestNumber.tsx | 6 +- .../src/Chain.tsx | 7 +- .../src/Elapsed.tsx | 4 +- .../src/NodeName.tsx | 7 +- .../src/NodeVersion.tsx | 7 +- .../src/Nonce.tsx | 6 +- .../src/TimeNow.tsx | 5 +- .../src/TimePeriod.tsx | 6 +- .../{ui-react-rx => ui-reactive}/src/index.ts | 4 +- .../src/util/balanceFormat.spec.js | 83 ++++++++ .../src/util/balanceFormat.ts | 2 +- .../src/util/decimalFormat.ts | 2 +- packages/ui-reactive/src/util/index.ts | 14 ++ .../src/util/numberFormat.ts | 2 +- packages/ui-reactive/webpack.config.js | 33 +++ packages/ui-signer/src/Modal.tsx | 44 ++-- tsconfig.json | 3 +- yarn.lock | 104 ++++----- 145 files changed, 974 insertions(+), 392 deletions(-) rename packages/{ui-react-rx => ui-api}/LICENSE (100%) rename packages/{ui-react-rx => ui-api}/README.md (92%) create mode 100644 packages/ui-api/package.json rename packages/{ui-react-rx/src/Api/index.tsx => ui-api/src/Api.tsx} (94%) create mode 100644 packages/ui-api/src/ApiContext.ts rename packages/{ui-react-rx => ui-api}/src/derive/balances/accountIdAndIndex.tsx (83%) rename packages/{ui-react-rx => ui-api}/src/derive/balances/accountIdToIndex.ts (69%) rename packages/{ui-react-rx => ui-api}/src/derive/balances/accountIndexToId.ts (74%) rename packages/{ui-react-rx => ui-api}/src/derive/balances/accountIndexes.ts (65%) rename packages/{ui-react-rx => ui-api}/src/derive/balances/fees.ts (82%) rename packages/{ui-react-rx => ui-api}/src/derive/balances/index.ts (91%) rename packages/{ui-react-rx => ui-api}/src/derive/balances/validatingBalance.tsx (83%) rename packages/{ui-react-rx => ui-api}/src/derive/balances/validatingBalances.tsx (84%) rename packages/{ui-react-rx => ui-api}/src/derive/balances/votingBalance.tsx (68%) rename packages/{ui-react-rx => ui-api}/src/derive/balances/votingBalances.tsx (81%) create mode 100644 packages/ui-api/src/derive/balances/votingBalancesNominatorsFor.ts rename packages/{ui-react-rx => ui-api}/src/derive/chain/bestNumber.ts (68%) rename packages/{ui-react-rx => ui-api}/src/derive/chain/bestNumberFinalised.ts (68%) rename packages/{ui-react-rx => ui-api}/src/derive/chain/index.ts (79%) rename packages/{ui-react-rx => ui-api}/src/derive/democracy/index.ts (84%) rename packages/{ui-react-rx => ui-api}/src/derive/democracy/referendumInfos.tsx (82%) rename packages/{ui-react-rx => ui-api}/src/derive/democracy/referendumVotesFor.ts (59%) rename packages/{ui-react-rx => ui-api}/src/derive/democracy/referendums.ts (63%) rename packages/{ui-react-rx => ui-api}/src/derive/democracy/votes.tsx (77%) rename packages/{ui-react-rx => ui-api}/src/derive/index.ts (83%) rename packages/{ui-react-rx => ui-api}/src/derive/session/eraLength.ts (74%) rename packages/{ui-react-rx => ui-api}/src/derive/session/eraProgress.ts (83%) rename packages/{ui-react-rx => ui-api}/src/derive/session/index.ts (81%) rename packages/{ui-react-rx => ui-api}/src/derive/session/sessionProgress.ts (80%) rename packages/{ui-react-rx => ui-api}/src/derive/types.ts (82%) create mode 100644 packages/ui-api/src/index.ts rename packages/{ui-react-rx/src/with => ui-api/src}/transform/echo.ts (75%) rename packages/{ui-react-rx => ui-api}/src/types.ts (94%) rename packages/{ui-react-rx => ui-api}/src/util/balanceFormat.spec.js (100%) create mode 100644 packages/ui-api/src/util/balanceFormat.ts create mode 100644 packages/ui-api/src/util/decimalFormat.ts rename packages/{ui-react-rx => ui-api}/src/util/index.ts (90%) rename packages/{ui-react-rx => ui-api}/src/util/intervalObservable.ts (90%) rename packages/{ui-react-rx => ui-api}/src/util/intervalTimer.ts (89%) rename packages/{ui-react-rx => ui-api}/src/util/isEqual.ts (88%) rename packages/{ui-react-rx => ui-api}/src/util/isTestChain.spec.js (94%) rename packages/{ui-react-rx => ui-api}/src/util/isTestChain.ts (86%) create mode 100644 packages/ui-api/src/util/numberFormat.ts rename packages/{ui-react-rx => ui-api}/src/util/triggerChange.ts (89%) rename packages/{ui-react-rx => ui-api}/src/with/api.tsx (90%) rename packages/{ui-react-rx => ui-api}/src/with/call.tsx (91%) rename packages/{ui-react-rx => ui-api}/src/with/callDiv.tsx (94%) rename packages/{ui-react-rx => ui-api}/src/with/index.ts (84%) rename packages/{ui-react-rx => ui-api}/src/with/multi.ts (90%) rename packages/{ui-react-rx => ui-api}/src/with/observable.tsx (95%) rename packages/{ui-react-rx => ui-api}/src/with/types.ts (94%) rename packages/{ui-react-rx => ui-api}/test/enzyme.js (82%) rename packages/{ui-react-rx => ui-api}/test/observable.js (86%) rename packages/{ui-react-rx => ui-api}/webpack.config.js (91%) delete mode 100644 packages/ui-react-rx/src/Api/Context.ts delete mode 100644 packages/ui-react-rx/src/derive/balances/votingBalancesNominatorsFor.ts create mode 100644 packages/ui-reactive/LICENSE create mode 100644 packages/ui-reactive/README.md rename packages/{ui-react-rx => ui-reactive}/index.html (100%) rename packages/{ui-react-rx => ui-reactive}/package.json (85%) rename packages/{ui-react-rx => ui-reactive}/src/Balance.tsx (83%) rename packages/{ui-react-rx => ui-reactive}/src/BestFinalised.tsx (84%) rename packages/{ui-react-rx => ui-reactive}/src/BestNumber.tsx (83%) rename packages/{ui-react-rx => ui-reactive}/src/Chain.tsx (80%) rename packages/{ui-react-rx => ui-reactive}/src/Elapsed.tsx (93%) rename packages/{ui-react-rx => ui-reactive}/src/NodeName.tsx (80%) rename packages/{ui-react-rx => ui-reactive}/src/NodeVersion.tsx (80%) rename packages/{ui-react-rx => ui-reactive}/src/Nonce.tsx (83%) rename packages/{ui-react-rx => ui-reactive}/src/TimeNow.tsx (72%) rename packages/{ui-react-rx => ui-reactive}/src/TimePeriod.tsx (84%) rename packages/{ui-react-rx => ui-reactive}/src/index.ts (85%) create mode 100644 packages/ui-reactive/src/util/balanceFormat.spec.js rename packages/{ui-react-rx => ui-reactive}/src/util/balanceFormat.ts (97%) rename packages/{ui-react-rx => ui-reactive}/src/util/decimalFormat.ts (83%) create mode 100644 packages/ui-reactive/src/util/index.ts rename packages/{ui-react-rx => ui-reactive}/src/util/numberFormat.ts (89%) create mode 100644 packages/ui-reactive/webpack.config.js diff --git a/jest.config.js b/jest.config.js index aaf22b1194..fa33850189 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,7 +3,7 @@ const config = require('@polkadot/dev-react/config/jest'); module.exports = Object.assign({}, config, { moduleNameMapper: { '@polkadot/app-(accounts|addresses|democracy|explorer|extrinsics|rpc|settings|staking|storage|toolbox|transfer|vanitygen)(.*)$': '/packages/app-$1/src/$2', - '@polkadot/ui-(app|params|react-rx|signer)(.*)$': '/packages/ui-$1/src/$2', + '@polkadot/ui-(api|app|params|reactive|signer)(.*)$': '/packages/ui-$1/src/$2', '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': 'empty/object', '\\.(css|less)$': 'empty/object' } diff --git a/packages/app-accounts/src/index.tsx b/packages/app-accounts/src/index.tsx index fc019d93f1..986b94df7b 100644 --- a/packages/app-accounts/src/index.tsx +++ b/packages/app-accounts/src/index.tsx @@ -12,7 +12,7 @@ import './index.css'; import React from 'react'; import accountObservable from '@polkadot/ui-keyring/observable/accounts'; import { Tabs } from '@polkadot/ui-app/index'; -import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index'; +import { withMulti, withObservable } from '@polkadot/ui-api/index'; import Creator from './Creator'; import Editor from './Editor'; diff --git a/packages/app-addresses/src/index.tsx b/packages/app-addresses/src/index.tsx index 4968ff24d6..e4bb3f581d 100644 --- a/packages/app-addresses/src/index.tsx +++ b/packages/app-addresses/src/index.tsx @@ -12,7 +12,7 @@ import React from 'react'; import addressObservable from '@polkadot/ui-keyring/observable/addresses'; import Tabs, { TabItem } from '@polkadot/ui-app/Tabs'; -import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index'; +import { withMulti, withObservable } from '@polkadot/ui-api/index'; import Creator from './Creator'; import Editor from './Editor'; diff --git a/packages/app-democracy/package.json b/packages/app-democracy/package.json index f56c2074a1..1aaa0efef1 100644 --- a/packages/app-democracy/package.json +++ b/packages/app-democracy/package.json @@ -12,6 +12,6 @@ "dependencies": { "@babel/runtime": "^7.2.0", "@polkadot/ui-app": "^0.22.8", - "@polkadot/ui-react-rx": "^0.22.8" + "@polkadot/ui-reactive": "^0.22.8" } } diff --git a/packages/app-democracy/src/Item.tsx b/packages/app-democracy/src/Item.tsx index 0fa94e7841..78cc4394e3 100644 --- a/packages/app-democracy/src/Item.tsx +++ b/packages/app-democracy/src/Item.tsx @@ -8,7 +8,7 @@ import BN from 'bn.js'; import React from 'react'; import { Method, Proposal } from '@polkadot/types'; import { Call } from '@polkadot/ui-app/index'; -import numberFormat from '@polkadot/ui-react-rx/util/numberFormat'; +import numberFormat from '@polkadot/ui-reactive/util/numberFormat'; import translate from './translate'; diff --git a/packages/app-democracy/src/Proposal.tsx b/packages/app-democracy/src/Proposal.tsx index 0b6a0e22f3..2102bae44b 100644 --- a/packages/app-democracy/src/Proposal.tsx +++ b/packages/app-democracy/src/Proposal.tsx @@ -9,8 +9,8 @@ import React from 'react'; import { AccountId, Balance, Proposal } from '@polkadot/types'; import { Tuple, Vector } from '@polkadot/types/codec'; import { AddressMini, Labelled, Static } from '@polkadot/ui-app/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; -import { balanceFormat } from '@polkadot/ui-react-rx/util/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; +import { balanceFormat } from '@polkadot/ui-reactive/util/index'; import Item from './Item'; import translate from './translate'; diff --git a/packages/app-democracy/src/Proposals.tsx b/packages/app-democracy/src/Proposals.tsx index 3c35ced582..83e8f25fa4 100644 --- a/packages/app-democracy/src/Proposals.tsx +++ b/packages/app-democracy/src/Proposals.tsx @@ -6,7 +6,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { Tuple } from '@polkadot/types/codec'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import Proposal from './Proposal'; import translate from './translate'; diff --git a/packages/app-democracy/src/Referendum.tsx b/packages/app-democracy/src/Referendum.tsx index da5c858998..7789cabf28 100644 --- a/packages/app-democracy/src/Referendum.tsx +++ b/packages/app-democracy/src/Referendum.tsx @@ -4,15 +4,15 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { RawParam } from '@polkadot/ui-params/types'; -import { DerivedReferendumVote } from '@polkadot/ui-react-rx/derive/types'; +import { DerivedReferendumVote } from '@polkadot/ui-api/derive/types'; import BN from 'bn.js'; import React from 'react'; import { ReferendumInfo } from '@polkadot/types'; import { Chart, Static } from '@polkadot/ui-app/index'; import VoteThreshold from '@polkadot/ui-params/Param/VoteThreshold'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; -import { balanceFormat, numberFormat } from '@polkadot/ui-react-rx/util/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; +import { balanceFormat, numberFormat } from '@polkadot/ui-reactive/util/index'; import settings from '@polkadot/ui-settings'; import Item from './Item'; diff --git a/packages/app-democracy/src/Referendums.tsx b/packages/app-democracy/src/Referendums.tsx index f9cdddb467..964b9e48ff 100644 --- a/packages/app-democracy/src/Referendums.tsx +++ b/packages/app-democracy/src/Referendums.tsx @@ -7,7 +7,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import BN from 'bn.js'; import React from 'react'; import { ReferendumInfo } from '@polkadot/types'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import Referendum from './Referendum'; import translate from './translate'; diff --git a/packages/app-democracy/src/Summary.tsx b/packages/app-democracy/src/Summary.tsx index ba9a63f7f1..6fe7fd926f 100644 --- a/packages/app-democracy/src/Summary.tsx +++ b/packages/app-democracy/src/Summary.tsx @@ -7,8 +7,8 @@ import { I18nProps } from '@polkadot/ui-app/types'; import BN from 'bn.js'; import React from 'react'; import { CardSummary } from '@polkadot/ui-app/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; -import { numberFormat } from '@polkadot/ui-react-rx/util/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; +import { numberFormat } from '@polkadot/ui-reactive/util/index'; import translate from './translate'; diff --git a/packages/app-democracy/src/VotingButtons.tsx b/packages/app-democracy/src/VotingButtons.tsx index 072a5f74ac..fb07434f56 100644 --- a/packages/app-democracy/src/VotingButtons.tsx +++ b/packages/app-democracy/src/VotingButtons.tsx @@ -4,12 +4,12 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { QueueTx$ExtrinsicAdd } from '@polkadot/ui-app/Status/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import BN from 'bn.js'; import React from 'react'; import { Button } from '@polkadot/ui-app/index'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import translate from './translate'; diff --git a/packages/app-explorer/src/BestHash.tsx b/packages/app-explorer/src/BestHash.tsx index 541d281e5f..fe214415e1 100644 --- a/packages/app-explorer/src/BestHash.tsx +++ b/packages/app-explorer/src/BestHash.tsx @@ -1,12 +1,12 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from '@polkadot/ui-react-rx//types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { Header } from '@polkadot/types'; -import { withCall } from '@polkadot/ui-react-rx/with/index'; +import { withCall } from '@polkadot/ui-api/index'; type Props = BareProps & { label?: string, diff --git a/packages/app-explorer/src/BlockByHash/BlockByHash.tsx b/packages/app-explorer/src/BlockByHash/BlockByHash.tsx index 65649a27a8..0e51edc31d 100644 --- a/packages/app-explorer/src/BlockByHash/BlockByHash.tsx +++ b/packages/app-explorer/src/BlockByHash/BlockByHash.tsx @@ -3,13 +3,13 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/ui-app/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import React from 'react'; import { AddressMini, Call } from '@polkadot/ui-app/index'; import { Extrinsic, Method, SignedBlock } from '@polkadot/types'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; -import { numberFormat } from '@polkadot/ui-react-rx/util/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; +import { numberFormat } from '@polkadot/ui-reactive/util/index'; import BlockHeader from '../BlockHeader'; import translate from '../translate'; diff --git a/packages/app-explorer/src/BlockHeader/BlockHash.tsx b/packages/app-explorer/src/BlockHeader/BlockHash.tsx index 54d46806fd..3335932893 100644 --- a/packages/app-explorer/src/BlockHeader/BlockHash.tsx +++ b/packages/app-explorer/src/BlockHeader/BlockHash.tsx @@ -6,7 +6,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { Link } from 'react-router-dom'; -import { withCall } from '@polkadot/ui-react-rx/with/index'; +import { withCall } from '@polkadot/ui-api/index'; import { BlockNumber, Hash } from '@polkadot/types'; type Props = I18nProps & { diff --git a/packages/app-explorer/src/BlockHeader/Extrinsics.tsx b/packages/app-explorer/src/BlockHeader/Extrinsics.tsx index 27ed7e79b1..47d4b3ed8a 100644 --- a/packages/app-explorer/src/BlockHeader/Extrinsics.tsx +++ b/packages/app-explorer/src/BlockHeader/Extrinsics.tsx @@ -5,7 +5,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import translate from '../translate'; diff --git a/packages/app-explorer/src/BlockHeader/index.tsx b/packages/app-explorer/src/BlockHeader/index.tsx index f02b01eab0..e5db03fdbb 100644 --- a/packages/app-explorer/src/BlockHeader/index.tsx +++ b/packages/app-explorer/src/BlockHeader/index.tsx @@ -9,7 +9,7 @@ import './BlockHeader.css'; import React from 'react'; import { Link } from 'react-router-dom'; -import numberFormat from '@polkadot/ui-react-rx/util/numberFormat'; +import numberFormat from '@polkadot/ui-reactive/util/numberFormat'; // FIXME 7 Nov 2018 Due to mismatches with block hashes between Substrate and BBQ, // the hashes are retrieved and not calculated (go back to calculated once resolved) diff --git a/packages/app-explorer/src/BlockHeaders.tsx b/packages/app-explorer/src/BlockHeaders.tsx index b07d83b747..057fff13e3 100644 --- a/packages/app-explorer/src/BlockHeaders.tsx +++ b/packages/app-explorer/src/BlockHeaders.tsx @@ -5,7 +5,7 @@ import { Header } from '@polkadot/types'; import React from 'react'; -import { withCall } from '@polkadot/ui-react-rx/with/index'; +import { withCall } from '@polkadot/ui-api/index'; import BlockHeader from './BlockHeader'; diff --git a/packages/app-explorer/src/Events.tsx b/packages/app-explorer/src/Events.tsx index 513d2c8905..2c8a4bb218 100644 --- a/packages/app-explorer/src/Events.tsx +++ b/packages/app-explorer/src/Events.tsx @@ -11,7 +11,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { Event, EventRecord } from '@polkadot/types'; import { Event as EventDisplay } from '@polkadot/ui-app/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import { stringToU8a } from '@polkadot/util'; import { xxhashAsHex } from '@polkadot/util-crypto'; diff --git a/packages/app-explorer/src/Summary.tsx b/packages/app-explorer/src/Summary.tsx index a292e8d826..fa98fd8daa 100644 --- a/packages/app-explorer/src/Summary.tsx +++ b/packages/app-explorer/src/Summary.tsx @@ -6,7 +6,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { CardSummary } from '@polkadot/ui-app/index'; -import { BestFinalised, BestNumber, TimeNow, TimePeriod } from '@polkadot/ui-react-rx/index'; +import { BestFinalised, BestNumber, TimeNow, TimePeriod } from '@polkadot/ui-reactive/index'; import SummarySession from './SummarySession'; import translate from './translate'; diff --git a/packages/app-explorer/src/SummarySession.tsx b/packages/app-explorer/src/SummarySession.tsx index db79e807bd..21bedf7e56 100644 --- a/packages/app-explorer/src/SummarySession.tsx +++ b/packages/app-explorer/src/SummarySession.tsx @@ -8,7 +8,7 @@ import BN from 'bn.js'; import React from 'react'; import { BlockNumber } from '@polkadot/types'; import { CardSummary } from '@polkadot/ui-app/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import translate from './translate'; diff --git a/packages/app-extrinsics/src/Account.tsx b/packages/app-extrinsics/src/Account.tsx index 2388bd9f2a..c9f4f32c1e 100644 --- a/packages/app-extrinsics/src/Account.tsx +++ b/packages/app-extrinsics/src/Account.tsx @@ -7,7 +7,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { InputAddress, Labelled } from '@polkadot/ui-app/index'; -import { Balance } from '@polkadot/ui-react-rx/index'; +import { Balance } from '@polkadot/ui-reactive/index'; import translate from './translate'; diff --git a/packages/app-extrinsics/src/Extrinsic.tsx b/packages/app-extrinsics/src/Extrinsic.tsx index 718508355b..a7b200ccf2 100644 --- a/packages/app-extrinsics/src/Extrinsic.tsx +++ b/packages/app-extrinsics/src/Extrinsic.tsx @@ -4,7 +4,7 @@ import { MethodFunction } from '@polkadot/types/Method'; import { BareProps } from '@polkadot/ui-app/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import { RawParam } from '@polkadot/ui-params/types'; import React from 'react'; @@ -13,7 +13,7 @@ import { Method } from '@polkadot/types'; import { InputExtrinsic } from '@polkadot/ui-app/index'; import Params from '@polkadot/ui-params/index'; -import { withApi } from '@polkadot/ui-react-rx/with/index'; +import { withApi } from '@polkadot/ui-api/index'; import { isUndefined } from '@polkadot/util'; import paramComponents from './Params'; diff --git a/packages/app-extrinsics/src/Nonce.tsx b/packages/app-extrinsics/src/Nonce.tsx index ee53314f38..e207f191f6 100644 --- a/packages/app-extrinsics/src/Nonce.tsx +++ b/packages/app-extrinsics/src/Nonce.tsx @@ -7,7 +7,7 @@ import { BareProps } from '@polkadot/ui-app/types'; import React from 'react'; import { Labelled } from '@polkadot/ui-app/index'; -import RxNonce from '@polkadot/ui-react-rx/Nonce'; +import RxNonce from '@polkadot/ui-reactive/Nonce'; type Props = BareProps & { label: string, diff --git a/packages/app-extrinsics/src/Params/Call.tsx b/packages/app-extrinsics/src/Params/Call.tsx index 982ba7951a..046f181a35 100644 --- a/packages/app-extrinsics/src/Params/Call.tsx +++ b/packages/app-extrinsics/src/Params/Call.tsx @@ -3,10 +3,10 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { Props as BaseProps } from '@polkadot/ui-params/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import React from 'react'; -import { withApi } from '@polkadot/ui-react-rx/with'; +import { withApi } from '@polkadot/ui-api/index'; import Extrinsic from './Extrinsic'; diff --git a/packages/app-extrinsics/src/Params/Proposal.tsx b/packages/app-extrinsics/src/Params/Proposal.tsx index 328db0b539..dd0c715518 100644 --- a/packages/app-extrinsics/src/Params/Proposal.tsx +++ b/packages/app-extrinsics/src/Params/Proposal.tsx @@ -3,11 +3,11 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { Props as BaseProps, RawParam } from '@polkadot/ui-params/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import React from 'react'; import { Proposal } from '@polkadot/types'; -import { withApi } from '@polkadot/ui-react-rx/with'; +import { withApi } from '@polkadot/ui-api/index'; import ExtrinsicDisplay from './Extrinsic'; diff --git a/packages/app-extrinsics/src/Selection.tsx b/packages/app-extrinsics/src/Selection.tsx index 2e607168f8..59c3303929 100644 --- a/packages/app-extrinsics/src/Selection.tsx +++ b/packages/app-extrinsics/src/Selection.tsx @@ -5,13 +5,13 @@ import BN from 'bn.js'; import { I18nProps } from '@polkadot/ui-app/types'; import { QueueTx$ExtrinsicAdd } from '@polkadot/ui-app/Status/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import React from 'react'; import SubmittableExtrinsic from '@polkadot/api/promise/SubmittableExtrinsic'; import { Method } from '@polkadot/types'; import { Button } from '@polkadot/ui-app/index'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import Account from './Account'; import ExtrinsicDisplay from './Extrinsic'; diff --git a/packages/app-extrinsics/src/index.tsx b/packages/app-extrinsics/src/index.tsx index 1769e2e47e..140296ba5a 100644 --- a/packages/app-extrinsics/src/index.tsx +++ b/packages/app-extrinsics/src/index.tsx @@ -11,7 +11,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; import { QueueConsumer } from '@polkadot/ui-app/Status/Context'; import accountsObservable from '@polkadot/ui-keyring/observable/accounts'; -import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index'; +import { withMulti, withObservable } from '@polkadot/ui-api/index'; import translate from './translate'; import Selection from './Selection'; diff --git a/packages/app-rpc/src/Account.tsx b/packages/app-rpc/src/Account.tsx index 7296bc291c..1ec6f84227 100644 --- a/packages/app-rpc/src/Account.tsx +++ b/packages/app-rpc/src/Account.tsx @@ -7,7 +7,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import BN from 'bn.js'; import React from 'react'; import { InputAddress, Labelled } from '@polkadot/ui-app/index'; -import { Nonce } from '@polkadot/ui-react-rx/index'; +import { Nonce } from '@polkadot/ui-reactive/index'; import translate from './translate'; diff --git a/packages/app-settings/package.json b/packages/app-settings/package.json index 0349185c1f..7f8eb80c1a 100644 --- a/packages/app-settings/package.json +++ b/packages/app-settings/package.json @@ -12,6 +12,6 @@ "dependencies": { "@babel/runtime": "^7.2.0", "@polkadot/ui-app": "^0.22.8", - "@polkadot/ui-react-rx": "^0.22.8" + "@polkadot/ui-reactive": "^0.22.8" } } diff --git a/packages/app-staking/package.json b/packages/app-staking/package.json index 0c36a6b3d4..a33bff505c 100644 --- a/packages/app-staking/package.json +++ b/packages/app-staking/package.json @@ -13,6 +13,6 @@ "@babel/runtime": "^7.2.0", "@polkadot/app-explorer": "^0.22.8", "@polkadot/ui-app": "^0.22.8", - "@polkadot/ui-react-rx": "^0.22.8" + "@polkadot/ui-reactive": "^0.22.8" } } diff --git a/packages/app-staking/src/Overview/CurrentList.tsx b/packages/app-staking/src/Overview/CurrentList.tsx index 6cb57cd1ae..f70faa8c62 100644 --- a/packages/app-staking/src/Overview/CurrentList.tsx +++ b/packages/app-staking/src/Overview/CurrentList.tsx @@ -3,7 +3,7 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/ui-app/types'; -import { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types'; +import { DerivedBalancesMap } from '@polkadot/ui-api/derive/types'; import React from 'react'; import { AccountId, Balance } from '@polkadot/types'; diff --git a/packages/app-staking/src/Overview/Summary.tsx b/packages/app-staking/src/Overview/Summary.tsx index 643d3f30ec..4f9a4087de 100644 --- a/packages/app-staking/src/Overview/Summary.tsx +++ b/packages/app-staking/src/Overview/Summary.tsx @@ -3,14 +3,14 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/ui-app/types'; -import { DerivedBalances, DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types'; +import { DerivedBalances, DerivedBalancesMap } from '@polkadot/ui-api/derive/types'; import BN from 'bn.js'; import React from 'react'; import { CardSummary } from '@polkadot/ui-app/index'; import SummarySession from '@polkadot/app-explorer/SummarySession'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; -import { balanceFormat } from '@polkadot/ui-react-rx/util/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; +import { balanceFormat } from '@polkadot/ui-reactive/util/index'; import translate from '../translate'; diff --git a/packages/app-staking/src/Overview/index.tsx b/packages/app-staking/src/Overview/index.tsx index 293f1a9537..08b9dc2461 100644 --- a/packages/app-staking/src/Overview/index.tsx +++ b/packages/app-staking/src/Overview/index.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 { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types'; +import { DerivedBalancesMap } from '@polkadot/ui-api/derive/types'; import { I18nProps } from '@polkadot/ui-app/types'; import './index.css'; diff --git a/packages/app-staking/src/StakeList/Account.tsx b/packages/app-staking/src/StakeList/Account.tsx index 4e5f33a16a..68cde8f127 100644 --- a/packages/app-staking/src/StakeList/Account.tsx +++ b/packages/app-staking/src/StakeList/Account.tsx @@ -4,14 +4,14 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { QueueTx$ExtrinsicAdd } from '@polkadot/ui-app/Status/types'; -import { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { DerivedBalancesMap } from '@polkadot/ui-api/derive/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import React from 'react'; import SubmittableExtrinsic from '@polkadot/api/promise/SubmittableExtrinsic'; import { AccountId, Balance } from '@polkadot/types'; import { AddressMini, AddressSummary, Button } from '@polkadot/ui-app/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import Nominating from './Nominating'; import UnnominateButton from './UnnominateButton'; diff --git a/packages/app-staking/src/StakeList/UnnominateButton.tsx b/packages/app-staking/src/StakeList/UnnominateButton.tsx index fbba8de45b..d99b4bb161 100644 --- a/packages/app-staking/src/StakeList/UnnominateButton.tsx +++ b/packages/app-staking/src/StakeList/UnnominateButton.tsx @@ -6,7 +6,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { Button } from '@polkadot/ui-app/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import translate from '../translate'; diff --git a/packages/app-staking/src/StakeList/index.tsx b/packages/app-staking/src/StakeList/index.tsx index 3a89cbe84b..98693724d8 100644 --- a/packages/app-staking/src/StakeList/index.tsx +++ b/packages/app-staking/src/StakeList/index.tsx @@ -4,7 +4,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { QueueProps } from '@polkadot/ui-app/Status/types'; -import { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types'; +import { DerivedBalancesMap } from '@polkadot/ui-api/derive/types'; import { AccountId, Balance } from '@polkadot/types'; import React from 'react'; diff --git a/packages/app-staking/src/index.tsx b/packages/app-staking/src/index.tsx index 32c6edf2b9..3f88137b6b 100644 --- a/packages/app-staking/src/index.tsx +++ b/packages/app-staking/src/index.tsx @@ -4,12 +4,12 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { ActionStatus } from '@polkadot/ui-app/Status/types'; -import { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types'; +import { DerivedBalancesMap } from '@polkadot/ui-api/derive/types'; import React from 'react'; import { AccountId, Balance } from '@polkadot/types'; import { Tabs } from '@polkadot/ui-app/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import './index.css'; diff --git a/packages/app-storage/src/Query.tsx b/packages/app-storage/src/Query.tsx index 0422c3148e..1da8270e4c 100644 --- a/packages/app-storage/src/Query.tsx +++ b/packages/app-storage/src/Query.tsx @@ -10,11 +10,11 @@ import React from 'react'; import { Compact } from '@polkadot/types/codec'; import { Button, Labelled } from '@polkadot/ui-app/index'; import valueToText from '@polkadot/ui-params/valueToText'; -import { withCallDiv } from '@polkadot/ui-react-rx/with/index'; +import { withCallDiv } from '@polkadot/ui-api/index'; import { isU8a, u8aToHex, u8aToString } from '@polkadot/util'; import translate from './translate'; -import { RenderFn, DefaultProps, ComponentRenderer } from '@polkadot/ui-react-rx/with/types'; +import { RenderFn, DefaultProps, ComponentRenderer } from '@polkadot/ui-api/with/types'; type Props = I18nProps & { onRemove: (id: number) => void, diff --git a/packages/app-storage/src/Selection/Modules.tsx b/packages/app-storage/src/Selection/Modules.tsx index 9907db3c13..311ff7f4c4 100644 --- a/packages/app-storage/src/Selection/Modules.tsx +++ b/packages/app-storage/src/Selection/Modules.tsx @@ -6,13 +6,13 @@ import { TypeDef, getTypeDef } from '@polkadot/types/codec'; import { StorageFunction } from '@polkadot/types/StorageKey'; import { I18nProps } from '@polkadot/ui-app/types'; import { RawParams } from '@polkadot/ui-params/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import { PartialModuleQuery } from '../types'; import React from 'react'; import { Button, InputStorage, Labelled } from '@polkadot/ui-app/index'; import Params from '@polkadot/ui-params/index'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import { isUndefined } from '@polkadot/util'; import translate from '../translate'; diff --git a/packages/app-transfer/package.json b/packages/app-transfer/package.json index 45fc2e3b2f..dfbc77f860 100644 --- a/packages/app-transfer/package.json +++ b/packages/app-transfer/package.json @@ -12,6 +12,6 @@ "dependencies": { "@babel/runtime": "^7.2.0", "@polkadot/ui-app": "^0.22.8", - "@polkadot/ui-react-rx": "^0.22.8" + "@polkadot/ui-reactive": "^0.22.8" } } diff --git a/packages/app-transfer/src/Fees.tsx b/packages/app-transfer/src/Fees.tsx index fcf31817a6..02074a4251 100644 --- a/packages/app-transfer/src/Fees.tsx +++ b/packages/app-transfer/src/Fees.tsx @@ -3,15 +3,15 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/ui-app/types'; -import { DerivedBalancesFees, DerivedBalances } from '@polkadot/ui-react-rx/derive/types'; +import { DerivedBalancesFees, DerivedBalances } from '@polkadot/ui-api/derive/types'; import { Fees } from './types'; import BN from 'bn.js'; import React from 'react'; import { Balance, Extrinsic } from '@polkadot/types'; import { Static } from '@polkadot/ui-app/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; -import { balanceFormat } from '@polkadot/ui-react-rx/util/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; +import { balanceFormat } from '@polkadot/ui-reactive/util/index'; import translate from './translate'; diff --git a/packages/app-transfer/src/Submit.tsx b/packages/app-transfer/src/Submit.tsx index 6bffe40109..659176861b 100644 --- a/packages/app-transfer/src/Submit.tsx +++ b/packages/app-transfer/src/Submit.tsx @@ -9,7 +9,7 @@ import React from 'react'; import SubmittableExtrinsic from '@polkadot/api/promise/SubmittableExtrinsic'; import { Index } from '@polkadot/types'; import Button from '@polkadot/ui-app/Button'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import translate from './translate'; diff --git a/packages/app-transfer/src/Transfer.tsx b/packages/app-transfer/src/Transfer.tsx index c3fbe7b2b8..a641a1732e 100644 --- a/packages/app-transfer/src/Transfer.tsx +++ b/packages/app-transfer/src/Transfer.tsx @@ -4,8 +4,8 @@ import { BitLength, I18nProps } from '@polkadot/ui-app/types'; import { QueueProps } from '@polkadot/ui-app/Status/types'; -import { DerivedBalancesFees } from '@polkadot/ui-react-rx/derive/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { DerivedBalancesFees } from '@polkadot/ui-api/derive/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import { Fees } from './types'; import BN from 'bn.js'; @@ -14,7 +14,7 @@ import { decodeAddress } from '@polkadot/keyring'; import { Extrinsic } from '@polkadot/types'; import { BitLengthOption } from '@polkadot/ui-app/constants'; import { AddressSummary, InputAddress, InputNumber } from '@polkadot/ui-app/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import { QueueConsumer } from '@polkadot/ui-app/Status/Context'; import FeeDisplay from './Fees'; diff --git a/packages/app-transfer/src/index.tsx b/packages/app-transfer/src/index.tsx index 4396069f11..247d56e3fa 100644 --- a/packages/app-transfer/src/index.tsx +++ b/packages/app-transfer/src/index.tsx @@ -8,7 +8,7 @@ import { SubjectInfo } from '@polkadot/ui-keyring/observable/types'; import React from 'react'; import { Trans } from 'react-i18next'; import accountObservable from '@polkadot/ui-keyring/observable/accounts'; -import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index'; +import { withMulti, withObservable } from '@polkadot/ui-api/index'; import './index.css'; diff --git a/packages/apps/src/Connecting/index.tsx b/packages/apps/src/Connecting/index.tsx index 643c84ea73..28725d0790 100644 --- a/packages/apps/src/Connecting/index.tsx +++ b/packages/apps/src/Connecting/index.tsx @@ -3,12 +3,12 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/ui-app/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import './Connecting.css'; import React from 'react'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import settings from '@polkadot/ui-settings'; import translate from '../translate'; diff --git a/packages/apps/src/Content/index.tsx b/packages/apps/src/Content/index.tsx index 4b3ece5b22..0d7118fd28 100644 --- a/packages/apps/src/Content/index.tsx +++ b/packages/apps/src/Content/index.tsx @@ -3,14 +3,14 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/ui-app/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import { QueueProps } from '@polkadot/ui-app/Status/types'; import './Content.css'; import React from 'react'; import { withRouter } from 'react-router'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import { QueueConsumer } from '@polkadot/ui-app/Status/Context'; import Status from '../Status'; diff --git a/packages/apps/src/NodeInfo.tsx b/packages/apps/src/NodeInfo.tsx index 451b2a12fb..9abe2d226f 100644 --- a/packages/apps/src/NodeInfo.tsx +++ b/packages/apps/src/NodeInfo.tsx @@ -6,7 +6,7 @@ import { BareProps } from '@polkadot/ui-app/types'; import React from 'react'; -import { BestNumber, Chain, NodeName, NodeVersion } from '@polkadot/ui-react-rx/index'; +import { BestNumber, Chain, NodeName, NodeVersion } from '@polkadot/ui-reactive/index'; type Props = BareProps & {}; diff --git a/packages/apps/src/SideBar/Item.tsx b/packages/apps/src/SideBar/Item.tsx index 8325484a08..af0936229e 100644 --- a/packages/apps/src/SideBar/Item.tsx +++ b/packages/apps/src/SideBar/Item.tsx @@ -3,14 +3,14 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/ui-app/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import { Route } from '../types'; import React from 'react'; import { withRouter } from 'react-router'; import { NavLink } from 'react-router-dom'; import { Icon, Menu } from '@polkadot/ui-app/index'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import { isFunction } from '@polkadot/util'; type Props = I18nProps & ApiProps & { diff --git a/packages/apps/src/Status.tsx b/packages/apps/src/Status.tsx index 6d610610f2..fd5a6b5372 100644 --- a/packages/apps/src/Status.tsx +++ b/packages/apps/src/Status.tsx @@ -10,7 +10,7 @@ import React from 'react'; import keyringOption from '@polkadot/ui-keyring/options'; import { EventRecord } from '@polkadot/types'; import { Status as StatusDisplay } from '@polkadot/ui-app/index'; -import { withCall, withMulti, withObservable } from '@polkadot/ui-react-rx/with'; +import { withCall, withMulti, withObservable } from '@polkadot/ui-api/index'; import { stringToU8a } from '@polkadot/util'; import { xxhashAsHex } from '@polkadot/util-crypto'; diff --git a/packages/apps/webpack.config.js b/packages/apps/webpack.config.js index 15cd5bbc94..459596a22b 100644 --- a/packages/apps/webpack.config.js +++ b/packages/apps/webpack.config.js @@ -23,9 +23,10 @@ const packages = [ 'app-toolbox', 'app-transfer', 'app-vanitygen', + 'ui-api', 'ui-app', 'ui-params', - 'ui-react-rx', + 'ui-reactive', 'ui-signer' ]; diff --git a/packages/ui-react-rx/LICENSE b/packages/ui-api/LICENSE similarity index 100% rename from packages/ui-react-rx/LICENSE rename to packages/ui-api/LICENSE diff --git a/packages/ui-react-rx/README.md b/packages/ui-api/README.md similarity index 92% rename from packages/ui-react-rx/README.md rename to packages/ui-api/README.md index 16b92bea4a..bd125c2e06 100644 --- a/packages/ui-react-rx/README.md +++ b/packages/ui-api/README.md @@ -1,4 +1,4 @@ -# @polkadot/ui-react-rx +# @polkadot/ui-reactive A collection of RxJS enabled React components that operate with the [@polkadot/api-rx](https://github.com/polkadot-js/api) library. It automatically manages subscriptions on behalf of the developer, providing a number of unstyled components that can be used to construct UIs. @@ -10,7 +10,7 @@ Basic usage entails creating a `ContextProvider` and just using the components. import React from 'react'; import ReactDOM from 'react-dom'; -import { Api, NodeTime } from '@polkadot/ui-react-rx'; +import { Api, NodeTime } from '@polkadot/ui-reactive'; ... ReactDOM.render( diff --git a/packages/ui-api/package.json b/packages/ui-api/package.json new file mode 100644 index 0000000000..466b66bf4e --- /dev/null +++ b/packages/ui-api/package.json @@ -0,0 +1,38 @@ +{ + "name": "@polkadot/ui-api", + "version": "0.22.6", + "description": "A collection of RxJs React components the Polkadot JS API", + "main": "index.js", + "keywords": [ + "Polkadot", + "React", + "RxJs" + ], + "author": "Jaco Greeff ", + "maintainers": [ + "Jaco Greeff " + ], + "contributors": [], + "license": "Apache-2.0", + "engines": { + "node": ">=8.0" + }, + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/polkadot-js/ui.git" + }, + "bugs": { + "url": "https://github.com/polkadot-js/ui/issues" + }, + "homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme", + "dependencies": { + "@babel/runtime": "^7.2.0", + "@polkadot/api": "^0.39.6", + "@polkadot/types": "^0.39.6", + "rxjs-compat": "^6.3.2" + } +} diff --git a/packages/ui-react-rx/src/Api/index.tsx b/packages/ui-api/src/Api.tsx similarity index 94% rename from packages/ui-react-rx/src/Api/index.tsx rename to packages/ui-api/src/Api.tsx index d16b5d0a50..8942f76170 100644 --- a/packages/ui-react-rx/src/Api/index.tsx +++ b/packages/ui-api/src/Api.tsx @@ -1,9 +1,9 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { ProviderInterface } from '@polkadot/rpc-provider/types'; -import { ApiProps } from '../types'; +import { ApiProps } from './types'; import React from 'react'; import ApiPromise from '@polkadot/api/promise'; @@ -11,12 +11,11 @@ import defaults from '@polkadot/rpc-provider/defaults'; import WsProvider from '@polkadot/rpc-provider/ws'; import { InputNumber } from '@polkadot/ui-app/InputNumber'; import keyring from '@polkadot/ui-keyring'; -import { isTestChain } from '@polkadot/ui-react-rx/util'; import settings from '@polkadot/ui-settings'; import { ChainProperties } from '@polkadot/types'; -import { balanceFormat } from '../util'; -import ApiContext from './Context'; +import ApiContext from './ApiContext'; +import { balanceFormat, isTestChain } from './util'; type Props = { children: React.ReactNode, diff --git a/packages/ui-api/src/ApiContext.ts b/packages/ui-api/src/ApiContext.ts new file mode 100644 index 0000000000..f252fb431f --- /dev/null +++ b/packages/ui-api/src/ApiContext.ts @@ -0,0 +1,18 @@ +// Copyright 2017-2019 @polkadot/ui-api authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { ApiProps } from './types'; + +import React from 'react'; + +const ApiContext: React.Context = React.createContext({} as ApiProps); +const ApiConsumer: React.Consumer = ApiContext.Consumer; +const ApiProvider: React.Provider = ApiContext.Provider; + +export default ApiContext; + +export { + ApiConsumer, + ApiProvider +}; diff --git a/packages/ui-react-rx/src/derive/balances/accountIdAndIndex.tsx b/packages/ui-api/src/derive/balances/accountIdAndIndex.tsx similarity index 83% rename from packages/ui-react-rx/src/derive/balances/accountIdAndIndex.tsx rename to packages/ui-api/src/derive/balances/accountIdAndIndex.tsx index 3eabd5b402..97f2264fc4 100644 --- a/packages/ui-react-rx/src/derive/balances/accountIdAndIndex.tsx +++ b/packages/ui-api/src/derive/balances/accountIdAndIndex.tsx @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import { decodeAddress } from '@polkadot/keyring'; @@ -15,7 +15,7 @@ import accountIndexToId from './accountIndexToId'; export type IdAndIndex = [AccountId | undefined, AccountIndex | undefined]; export default function accountIdAndIndex (api: ApiPromise): DeriveSubscription { - return (address: AccountId | AccountIndex | string | null | undefined, cb: (idAndIndex: IdAndIndex) => any): UnsubFunction => { + return async (address: AccountId | AccountIndex | string | null | undefined, cb: (idAndIndex: IdAndIndex) => any): PromiseSubscription => { try { // yes, this can fail, don't care too much, catch will catch it const length = decodeAddress((address as any).toString()).length; diff --git a/packages/ui-react-rx/src/derive/balances/accountIdToIndex.ts b/packages/ui-api/src/derive/balances/accountIdToIndex.ts similarity index 69% rename from packages/ui-react-rx/src/derive/balances/accountIdToIndex.ts rename to packages/ui-api/src/derive/balances/accountIdToIndex.ts index 2c66033e2d..77f438e71d 100644 --- a/packages/ui-react-rx/src/derive/balances/accountIdToIndex.ts +++ b/packages/ui-api/src/derive/balances/accountIdToIndex.ts @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import ApiPromise from '@polkadot/api/promise'; @@ -11,7 +11,7 @@ import { AccountId, AccountIndex } from '@polkadot/types'; import accountIndexes, { AccountIndexes } from './accountIndexes'; export default function accountIdToIndex (api: ApiPromise): DeriveSubscription { - return (accountId: AccountId | string, cb: (index?: AccountIndex) => any): UnsubFunction => + return async (accountId: AccountId | string, cb: (index?: AccountIndex) => any): PromiseSubscription => accountIndexes(api)((indexes?: AccountIndexes) => cb((indexes || {})[accountId.toString()]) ); diff --git a/packages/ui-react-rx/src/derive/balances/accountIndexToId.ts b/packages/ui-api/src/derive/balances/accountIndexToId.ts similarity index 74% rename from packages/ui-react-rx/src/derive/balances/accountIndexToId.ts rename to packages/ui-api/src/derive/balances/accountIndexToId.ts index f155f4ff67..22bcbd537d 100644 --- a/packages/ui-react-rx/src/derive/balances/accountIndexToId.ts +++ b/packages/ui-api/src/derive/balances/accountIndexToId.ts @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import ApiPromise from '@polkadot/api/promise'; @@ -10,7 +10,7 @@ import { AccountId, AccountIndex } from '@polkadot/types'; import { ENUMSET_SIZE } from '@polkadot/types/AccountIndex'; export default function accountIndexToId (api: ApiPromise): DeriveSubscription { - return (_accountIndex: AccountIndex | string, cb: (accountId?: AccountId) => any): UnsubFunction => { + return async (_accountIndex: AccountIndex | string, cb: (accountId?: AccountId) => any): PromiseSubscription => { const accountIndex = _accountIndex instanceof AccountIndex ? _accountIndex : new AccountIndex(_accountIndex); diff --git a/packages/ui-react-rx/src/derive/balances/accountIndexes.ts b/packages/ui-api/src/derive/balances/accountIndexes.ts similarity index 65% rename from packages/ui-react-rx/src/derive/balances/accountIndexes.ts rename to packages/ui-api/src/derive/balances/accountIndexes.ts index 41a0b8184a..3b3e0b75ce 100644 --- a/packages/ui-react-rx/src/derive/balances/accountIndexes.ts +++ b/packages/ui-api/src/derive/balances/accountIndexes.ts @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { QueryableStorageFunction, UnsubFunction } from '@polkadot/api/promise/types'; +import { QueryableStorageFunction, PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import BN from 'bn.js'; @@ -13,16 +13,18 @@ import { ENUMSET_SIZE } from '@polkadot/types/AccountIndex'; export type AccountIndexes = { [index: string]: AccountIndex }; export default function accountIndexes (api: ApiPromise): DeriveSubscription { - return (cb: (indexes: AccountIndexes) => any): UnsubFunction => { - let combineDestroy: UnsubFunction | undefined; - const nextEnumSetDestory = api.query.balances.nextEnumSet((next: AccountIndex) => { + return async (cb: (indexes: AccountIndexes) => any): PromiseSubscription => { + let combineDestroy: PromiseSubscription | undefined; + const nextEnumSetDestory = api.query.balances.nextEnumSet(async (next: AccountIndex) => { const setSize = ENUMSET_SIZE.toNumber(); const enumRange = [...Array((next || new BN(0)).div(ENUMSET_SIZE).toNumber() + 1).keys()].map((index) => [api.query.balances.enumSet, index] as [QueryableStorageFunction, ...Array] ); if (combineDestroy) { - combineDestroy(); + const unsubscribe = await combineDestroy; + + unsubscribe(); } combineDestroy = api.combineLatest(enumRange, (all: Array | undefined>) => { @@ -38,13 +40,17 @@ export default function accountIndexes (api: ApiPromise): DeriveSubscription { }, {} as AccountIndexes) ); }); - }) as any as UnsubFunction; // FIXME? wtf? + }) as any as PromiseSubscription; // wtf??? - return (): void => { - nextEnumSetDestory(); + return async (): Promise => { + let unsubscribe = await nextEnumSetDestory; + + unsubscribe(); if (combineDestroy) { - combineDestroy(); + unsubscribe = await combineDestroy; + + unsubscribe(); } }; }; diff --git a/packages/ui-react-rx/src/derive/balances/fees.ts b/packages/ui-api/src/derive/balances/fees.ts similarity index 82% rename from packages/ui-react-rx/src/derive/balances/fees.ts rename to packages/ui-api/src/derive/balances/fees.ts index 31fe2d62ae..c77f2784e0 100644 --- a/packages/ui-react-rx/src/derive/balances/fees.ts +++ b/packages/ui-api/src/derive/balances/fees.ts @@ -1,15 +1,15 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription, DerivedBalancesFees } from '../types'; import BN from 'bn.js'; import ApiPromise from '@polkadot/api/promise'; export default function fees (api: ApiPromise): DeriveSubscription { - return (cb: (fees: DerivedBalancesFees) => any): UnsubFunction => + return async (cb: (fees: DerivedBalancesFees) => any): PromiseSubscription => api.combineLatest([ api.query.balances.creationFee, api.query.balances.existentialDeposit, diff --git a/packages/ui-react-rx/src/derive/balances/index.ts b/packages/ui-api/src/derive/balances/index.ts similarity index 91% rename from packages/ui-react-rx/src/derive/balances/index.ts rename to packages/ui-api/src/derive/balances/index.ts index fca300a737..5c8919b84d 100644 --- a/packages/ui-react-rx/src/derive/balances/index.ts +++ b/packages/ui-api/src/derive/balances/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/derive/balances/validatingBalance.tsx b/packages/ui-api/src/derive/balances/validatingBalance.tsx similarity index 83% rename from packages/ui-react-rx/src/derive/balances/validatingBalance.tsx rename to packages/ui-api/src/derive/balances/validatingBalance.tsx index 2d4cbe5b7a..34290c78ee 100644 --- a/packages/ui-react-rx/src/derive/balances/validatingBalance.tsx +++ b/packages/ui-api/src/derive/balances/validatingBalance.tsx @@ -1,9 +1,9 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { CombinatorFunction } from '@polkadot/api/promise/Combinator'; -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription, DerivedBalances } from '../types'; import BN from 'bn.js'; @@ -14,7 +14,7 @@ import votingBalance from './votingBalance'; import votingBalancesNominatorsFor from './votingBalancesNominatorsFor'; export default function validatingBalance (api: ApiPromise): DeriveSubscription { - return (accountId: AccountId | string, cb: (balance: DerivedBalances) => any): UnsubFunction => + return async (accountId: AccountId | string, cb: (balance: DerivedBalances) => any): PromiseSubscription => api.combineLatest([ [votingBalance(api), accountId] as [CombinatorFunction, ...Array], [votingBalancesNominatorsFor(api), accountId] as [CombinatorFunction, ...Array] diff --git a/packages/ui-react-rx/src/derive/balances/validatingBalances.tsx b/packages/ui-api/src/derive/balances/validatingBalances.tsx similarity index 84% rename from packages/ui-react-rx/src/derive/balances/validatingBalances.tsx rename to packages/ui-api/src/derive/balances/validatingBalances.tsx index 0b1d05897d..d4da9ed8ce 100644 --- a/packages/ui-react-rx/src/derive/balances/validatingBalances.tsx +++ b/packages/ui-api/src/derive/balances/validatingBalances.tsx @@ -1,9 +1,9 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { CombinatorFunction } from '@polkadot/api/promise/Combinator'; -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription, DerivedBalancesMap } from '../types'; import ApiPromise from '@polkadot/api/promise'; @@ -12,7 +12,7 @@ import { AccountId } from '@polkadot/types'; import validatingBalance from './validatingBalance'; export default function votingBalances (api: ApiPromise): DeriveSubscription { - return (...params: Array): UnsubFunction => { + return async (...params: Array): PromiseSubscription => { const accountIds: Array = params.slice(0, params.length - 1); const cb: (balanceMap: DerivedBalancesMap) => any = params[params.length - 1]; diff --git a/packages/ui-react-rx/src/derive/balances/votingBalance.tsx b/packages/ui-api/src/derive/balances/votingBalance.tsx similarity index 68% rename from packages/ui-react-rx/src/derive/balances/votingBalance.tsx rename to packages/ui-api/src/derive/balances/votingBalance.tsx index df3d221a28..013a3e67c9 100644 --- a/packages/ui-react-rx/src/derive/balances/votingBalance.tsx +++ b/packages/ui-api/src/derive/balances/votingBalance.tsx @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription, DerivedBalances } from '../types'; import ApiPromise from '@polkadot/api/promise'; @@ -13,9 +13,9 @@ import accountIdAndIndex from './accountIdAndIndex'; const EMPTY_ACCOUNT = new AccountId(new Uint8Array(32)); export default function votingBalance (api: ApiPromise): DeriveSubscription { - return (address: AccountIndex | AccountId | string, cb: (balance: DerivedBalances) => any): UnsubFunction => { - let combineDestroy: UnsubFunction | undefined; - const idDestory = accountIdAndIndex(api)(address, ([accountId]: [AccountId | undefined]) => { + return async (address: AccountIndex | AccountId | string, cb: (balance: DerivedBalances) => any): PromiseSubscription => { + let combineDestroy: PromiseSubscription | undefined; + const idDestory = accountIdAndIndex(api)(address, async ([accountId]: [AccountId | undefined]) => { const handler = (freeBalance?: Balance, reservedBalance?: Balance) => { cb({ accountId: accountId || EMPTY_ACCOUNT, @@ -30,7 +30,9 @@ export default function votingBalance (api: ApiPromise): DeriveSubscription { }; if (combineDestroy) { - combineDestroy(); + const unsubscribe = await combineDestroy; + + unsubscribe(); combineDestroy = undefined; } @@ -46,11 +48,15 @@ export default function votingBalance (api: ApiPromise): DeriveSubscription { ); }); - return (): void => { - idDestory(); + return async () => { + let unsubscribe = await idDestory; + + unsubscribe(); if (combineDestroy) { - combineDestroy(); + let unsubscribe = await combineDestroy; + + unsubscribe(); } }; }; diff --git a/packages/ui-react-rx/src/derive/balances/votingBalances.tsx b/packages/ui-api/src/derive/balances/votingBalances.tsx similarity index 81% rename from packages/ui-react-rx/src/derive/balances/votingBalances.tsx rename to packages/ui-api/src/derive/balances/votingBalances.tsx index 10d7cfd715..d04fa7cbed 100644 --- a/packages/ui-react-rx/src/derive/balances/votingBalances.tsx +++ b/packages/ui-api/src/derive/balances/votingBalances.tsx @@ -1,9 +1,9 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { CombinatorFunction } from '@polkadot/api/promise/Combinator'; -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription, DerivedBalances } from '../types'; import ApiPromise from '@polkadot/api/promise'; @@ -12,7 +12,7 @@ import { AccountId, AccountIndex } from '@polkadot/types'; import votingBalance from './votingBalance'; export default function votingBalances (api: ApiPromise): DeriveSubscription { - return (...params: Array): UnsubFunction => { + return async (...params: Array): PromiseSubscription => { const addresses: Array = params.slice(0, params.length - 1); const cb: (balance: Array) => any = params[params.length - 1]; diff --git a/packages/ui-api/src/derive/balances/votingBalancesNominatorsFor.ts b/packages/ui-api/src/derive/balances/votingBalancesNominatorsFor.ts new file mode 100644 index 0000000000..350395d08c --- /dev/null +++ b/packages/ui-api/src/derive/balances/votingBalancesNominatorsFor.ts @@ -0,0 +1,38 @@ +// Copyright 2017-2019 @polkadot/ui-api authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { PromiseSubscription } from '@polkadot/api/promise/types'; +import { DeriveSubscription, DerivedBalances } from '../types'; + +import ApiPromise from '@polkadot/api/promise'; +import { AccountId } from '@polkadot/types'; + +import votingBalances from './votingBalances'; + +export default function votingBalancesNominatorsFor (api: ApiPromise): DeriveSubscription { + return async (accountId: AccountId | string, cb: (balance: Array) => any): PromiseSubscription => { + let combineDestroy: PromiseSubscription | undefined; + const nominatorDestroy = api.query.staking.nominatorsFor(accountId, async (nominators?: Array) => { + if (combineDestroy) { + const unsubscribe = await combineDestroy; + + unsubscribe(); + } + + combineDestroy = votingBalances(api)(...(nominators || []), cb); + }); + + return async () => { + let unsubscribe = await nominatorDestroy; + + unsubscribe(); + + if (combineDestroy) { + unsubscribe = await combineDestroy; + + unsubscribe(); + } + }; + }; +} diff --git a/packages/ui-react-rx/src/derive/chain/bestNumber.ts b/packages/ui-api/src/derive/chain/bestNumber.ts similarity index 68% rename from packages/ui-react-rx/src/derive/chain/bestNumber.ts rename to packages/ui-api/src/derive/chain/bestNumber.ts index 20b1a7a44a..932b798155 100644 --- a/packages/ui-react-rx/src/derive/chain/bestNumber.ts +++ b/packages/ui-api/src/derive/chain/bestNumber.ts @@ -1,18 +1,18 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import ApiPromise from '@polkadot/api/promise'; import { BlockNumber, Header } from '@polkadot/types'; export default function bestNumber (api: ApiPromise): DeriveSubscription { - return (cb: (blockNumber: BlockNumber) => any): UnsubFunction => + return (cb: (blockNumber: BlockNumber) => any): PromiseSubscription => api.rpc.chain.subscribeNewHead((header?: Header) => { if (header && header.blockNumber) { cb(header.blockNumber); } - }) as UnsubFunction; + }) as PromiseSubscription; } diff --git a/packages/ui-react-rx/src/derive/chain/bestNumberFinalised.ts b/packages/ui-api/src/derive/chain/bestNumberFinalised.ts similarity index 68% rename from packages/ui-react-rx/src/derive/chain/bestNumberFinalised.ts rename to packages/ui-api/src/derive/chain/bestNumberFinalised.ts index dd1a2e124e..0507f0d28f 100644 --- a/packages/ui-react-rx/src/derive/chain/bestNumberFinalised.ts +++ b/packages/ui-api/src/derive/chain/bestNumberFinalised.ts @@ -1,18 +1,18 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import ApiPromise from '@polkadot/api/promise'; import { BlockNumber, Header } from '@polkadot/types'; export default function bestNumberFinalised (api: ApiPromise): DeriveSubscription { - return (cb: (blockNumber: BlockNumber) => any): UnsubFunction => + return (cb: (blockNumber: BlockNumber) => any): PromiseSubscription => api.rpc.chain.subscribeFinalisedHeads((header?: Header) => { if (header && header.blockNumber) { cb(header.blockNumber); } - }) as UnsubFunction; + }) as PromiseSubscription; } diff --git a/packages/ui-react-rx/src/derive/chain/index.ts b/packages/ui-api/src/derive/chain/index.ts similarity index 79% rename from packages/ui-react-rx/src/derive/chain/index.ts rename to packages/ui-api/src/derive/chain/index.ts index 3ac2510d45..08efa1ab73 100644 --- a/packages/ui-react-rx/src/derive/chain/index.ts +++ b/packages/ui-api/src/derive/chain/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/derive/democracy/index.ts b/packages/ui-api/src/derive/democracy/index.ts similarity index 84% rename from packages/ui-react-rx/src/derive/democracy/index.ts rename to packages/ui-api/src/derive/democracy/index.ts index af355ce40a..c3184be560 100644 --- a/packages/ui-react-rx/src/derive/democracy/index.ts +++ b/packages/ui-api/src/derive/democracy/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/derive/democracy/referendumInfos.tsx b/packages/ui-api/src/derive/democracy/referendumInfos.tsx similarity index 82% rename from packages/ui-react-rx/src/derive/democracy/referendumInfos.tsx rename to packages/ui-api/src/derive/democracy/referendumInfos.tsx index 6070ae0ccb..b18d859855 100644 --- a/packages/ui-react-rx/src/derive/democracy/referendumInfos.tsx +++ b/packages/ui-api/src/derive/democracy/referendumInfos.tsx @@ -1,9 +1,9 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { CombinatorFunction } from '@polkadot/api/promise/Combinator'; -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import BN from 'bn.js'; @@ -11,7 +11,7 @@ import ApiPromise from '@polkadot/api/promise'; import { ReferendumInfo } from '@polkadot/types'; export default function referendumInfos (api: ApiPromise): DeriveSubscription { - return (...params: Array): UnsubFunction => { + return async (...params: Array): PromiseSubscription => { const ids: Array = params.slice(0, params.length - 1); const cb: (infos: Array) => any = params[params.length - 1]; diff --git a/packages/ui-react-rx/src/derive/democracy/referendumVotesFor.ts b/packages/ui-api/src/derive/democracy/referendumVotesFor.ts similarity index 59% rename from packages/ui-react-rx/src/derive/democracy/referendumVotesFor.ts rename to packages/ui-api/src/derive/democracy/referendumVotesFor.ts index 2757d7a104..7d77ccc7dc 100644 --- a/packages/ui-react-rx/src/derive/democracy/referendumVotesFor.ts +++ b/packages/ui-api/src/derive/democracy/referendumVotesFor.ts @@ -1,9 +1,9 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { CombinatorFunction } from '@polkadot/api/promise/Combinator'; -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription, DerivedReferendumVote } from '../types'; import BN from 'bn.js'; @@ -14,19 +14,21 @@ import votingBalances from '../balances/votingBalances'; import votes from './votes'; export default function referendumVotesFor (api: ApiPromise): DeriveSubscription { - return (referendumId: BN | number, cb: (votes: Array) => any): UnsubFunction => { - let innerDestroy: UnsubFunction | undefined; - const outerDestroy = api.query.democracy.votersFor(referendumId, (votersFor: Array) => { - if (innerDestroy) { - innerDestroy(); - innerDestroy = undefined; + return async (referendumId: BN | number, cb: (votes: Array) => any): PromiseSubscription => { + let innerDispose: PromiseSubscription | undefined; + const outerDispose = api.query.democracy.votersFor(referendumId, async (votersFor: Array) => { + if (innerDispose) { + const unsubscribe = await innerDispose; + + unsubscribe(); + innerDispose = undefined; } if (!votersFor || !votersFor.length) { return cb([]); } - innerDestroy = api.combineLatest([ + innerDispose = api.combineLatest([ [votes(api), referendumId, ...votersFor] as [CombinatorFunction, ...Array], [votingBalances(api), ...votersFor] as [CombinatorFunction, ...Array] ], ([votes, balances]) => @@ -40,12 +42,16 @@ export default function referendumVotesFor (api: ApiPromise): DeriveSubscription ); }); - return (): void => { - if (innerDestroy) { - innerDestroy(); - } + return async () => { + let unsubscribe = await outerDispose; - outerDestroy(); + unsubscribe(); + + if (innerDispose) { + unsubscribe = await innerDispose; + + unsubscribe(); + } }; }; } diff --git a/packages/ui-react-rx/src/derive/democracy/referendums.ts b/packages/ui-api/src/derive/democracy/referendums.ts similarity index 63% rename from packages/ui-react-rx/src/derive/democracy/referendums.ts rename to packages/ui-api/src/derive/democracy/referendums.ts index 14e494a5fb..6bc6585f73 100644 --- a/packages/ui-react-rx/src/derive/democracy/referendums.ts +++ b/packages/ui-api/src/derive/democracy/referendums.ts @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import ApiPromise from '@polkadot/api/promise'; @@ -11,14 +11,16 @@ import { ReferendumInfo } from '@polkadot/types'; import referendumInfos from './referendumInfos'; export default function referendums (api: ApiPromise): DeriveSubscription { - return (cb: (referendums: Array) => any): UnsubFunction => { - let innerDispose: UnsubFunction | undefined; + return async (cb: (referendums: Array) => any): PromiseSubscription => { + let innerDispose: PromiseSubscription | undefined; const outerDispose = api.combineLatest([ api.query.democracy.nextTally, api.query.democracy.referendumCount - ], ([nextTally, referendumCount]) => { + ], async ([nextTally, referendumCount]) => { if (innerDispose) { - innerDispose(); + const unsubscribe = await innerDispose; + + unsubscribe(); innerDispose = undefined; } @@ -33,11 +35,15 @@ export default function referendums (api: ApiPromise): DeriveSubscription { } }); - return (): void => { - outerDispose(); + return async () => { + let unsubscribe = await outerDispose; + + unsubscribe(); if (innerDispose) { - innerDispose(); + unsubscribe = await innerDispose; + + unsubscribe(); } }; }; diff --git a/packages/ui-react-rx/src/derive/democracy/votes.tsx b/packages/ui-api/src/derive/democracy/votes.tsx similarity index 77% rename from packages/ui-react-rx/src/derive/democracy/votes.tsx rename to packages/ui-api/src/derive/democracy/votes.tsx index 29f90d5eb6..65e3272ebd 100644 --- a/packages/ui-react-rx/src/derive/democracy/votes.tsx +++ b/packages/ui-api/src/derive/democracy/votes.tsx @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { QueryableStorageFunction, UnsubFunction } from '@polkadot/api/promise/types'; +import { QueryableStorageFunction, PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import BN from 'bn.js'; @@ -10,7 +10,7 @@ import ApiPromise from '@polkadot/api/promise'; import { AccountId, bool as Bool } from '@polkadot/types'; export default function votes (api: ApiPromise): DeriveSubscription { - return (...params: Array): UnsubFunction => { + return async (...params: Array): PromiseSubscription => { const referendumId: BN = params[0]; const accountIds: Array = params.slice(1, params.length - 1); const cb: (infos: Array) => any = params[params.length - 1]; diff --git a/packages/ui-react-rx/src/derive/index.ts b/packages/ui-api/src/derive/index.ts similarity index 83% rename from packages/ui-react-rx/src/derive/index.ts rename to packages/ui-api/src/derive/index.ts index 0d751a70a8..e6cc49681b 100644 --- a/packages/ui-react-rx/src/derive/index.ts +++ b/packages/ui-api/src/derive/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/derive/session/eraLength.ts b/packages/ui-api/src/derive/session/eraLength.ts similarity index 74% rename from packages/ui-react-rx/src/derive/session/eraLength.ts rename to packages/ui-api/src/derive/session/eraLength.ts index 13f608b812..6a70261eaf 100644 --- a/packages/ui-react-rx/src/derive/session/eraLength.ts +++ b/packages/ui-api/src/derive/session/eraLength.ts @@ -1,15 +1,15 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import BN from 'bn.js'; import ApiPromise from '@polkadot/api/promise'; export default function eraLength (api: ApiPromise): DeriveSubscription { - return (cb: (count: BN) => any): UnsubFunction => + return (cb: (count: BN) => any): PromiseSubscription => api.combineLatest([ api.query.session.sessionLength, api.query.staking.sessionsPerEra diff --git a/packages/ui-react-rx/src/derive/session/eraProgress.ts b/packages/ui-api/src/derive/session/eraProgress.ts similarity index 83% rename from packages/ui-react-rx/src/derive/session/eraProgress.ts rename to packages/ui-api/src/derive/session/eraProgress.ts index 56c34a5cef..3c11120e4e 100644 --- a/packages/ui-react-rx/src/derive/session/eraProgress.ts +++ b/packages/ui-api/src/derive/session/eraProgress.ts @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import BN from 'bn.js'; @@ -11,7 +11,7 @@ import ApiPromise from '@polkadot/api/promise'; import sessionProgress from './sessionProgress'; export default function eraProgress (api: ApiPromise): DeriveSubscription { - return (cb: (count: BN) => any): UnsubFunction => + return (cb: (count: BN) => any): PromiseSubscription => api.combineLatest([ sessionProgress(api), api.query.session.currentIndex, diff --git a/packages/ui-react-rx/src/derive/session/index.ts b/packages/ui-api/src/derive/session/index.ts similarity index 81% rename from packages/ui-react-rx/src/derive/session/index.ts rename to packages/ui-api/src/derive/session/index.ts index 7386ce7450..a038a7a6c0 100644 --- a/packages/ui-react-rx/src/derive/session/index.ts +++ b/packages/ui-api/src/derive/session/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/derive/session/sessionProgress.ts b/packages/ui-api/src/derive/session/sessionProgress.ts similarity index 80% rename from packages/ui-react-rx/src/derive/session/sessionProgress.ts rename to packages/ui-api/src/derive/session/sessionProgress.ts index 37311a5da0..f0d337fa2b 100644 --- a/packages/ui-react-rx/src/derive/session/sessionProgress.ts +++ b/packages/ui-api/src/derive/session/sessionProgress.ts @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import { DeriveSubscription } from '../types'; import BN from 'bn.js'; @@ -11,7 +11,7 @@ import ApiPromise from '@polkadot/api/promise'; import bestNumber from '../chain/bestNumber'; export default function sessionProgress (api: ApiPromise): DeriveSubscription { - return (cb: (count: BN) => any): UnsubFunction => + return (cb: (count: BN) => any): PromiseSubscription => api.combineLatest([ bestNumber(api), api.query.session.sessionLength, diff --git a/packages/ui-react-rx/src/derive/types.ts b/packages/ui-api/src/derive/types.ts similarity index 82% rename from packages/ui-react-rx/src/derive/types.ts rename to packages/ui-api/src/derive/types.ts index d6461e3ce7..10f4e4e8ca 100644 --- a/packages/ui-react-rx/src/derive/types.ts +++ b/packages/ui-api/src/derive/types.ts @@ -1,14 +1,14 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { UnsubFunction } from '@polkadot/api/promise/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; import BN from 'bn.js'; import { AccountId, Balance, Vote } from '@polkadot/types'; export interface DeriveSubscription { - (...params: Array): UnsubFunction; + (...params: Array): PromiseSubscription; } export type DerivedBalancesFees = { diff --git a/packages/ui-api/src/index.ts b/packages/ui-api/src/index.ts new file mode 100644 index 0000000000..9437aea63f --- /dev/null +++ b/packages/ui-api/src/index.ts @@ -0,0 +1,13 @@ +// Copyright 2017-2019 @polkadot/ui-api authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import Api from './Api'; +import ApiContext from './ApiContext'; + +export * from './with'; + +export { + Api, + ApiContext +}; diff --git a/packages/ui-react-rx/src/with/transform/echo.ts b/packages/ui-api/src/transform/echo.ts similarity index 75% rename from packages/ui-react-rx/src/with/transform/echo.ts rename to packages/ui-api/src/transform/echo.ts index f480168db6..8765bf86b6 100644 --- a/packages/ui-react-rx/src/with/transform/echo.ts +++ b/packages/ui-api/src/transform/echo.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/types.ts b/packages/ui-api/src/types.ts similarity index 94% rename from packages/ui-react-rx/src/types.ts rename to packages/ui-api/src/types.ts index 4d89ab0edc..647bc898b2 100644 --- a/packages/ui-react-rx/src/types.ts +++ b/packages/ui-api/src/types.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/util/balanceFormat.spec.js b/packages/ui-api/src/util/balanceFormat.spec.js similarity index 100% rename from packages/ui-react-rx/src/util/balanceFormat.spec.js rename to packages/ui-api/src/util/balanceFormat.spec.js diff --git a/packages/ui-api/src/util/balanceFormat.ts b/packages/ui-api/src/util/balanceFormat.ts new file mode 100644 index 0000000000..af4a0ce1ac --- /dev/null +++ b/packages/ui-api/src/util/balanceFormat.ts @@ -0,0 +1,95 @@ +// Copyright 2017-2019 @polkadot/ui-api authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import BN from 'bn.js'; + +import decimalFormat from './decimalFormat'; + +type SiDef = { + power: number, + text: string, + value: string +}; + +interface BalanceFormatter { + (input: string | BN, withSi?: boolean, decimals?: number): string; + findSi (type: string): SiDef; + getDefaultDecimals (): number; + getOptions (decimals?: number): Array; + setDefaultDecimals (decimals: number): void; +} + +const SI: Array = [ + { power: -24, value: 'y', text: 'yocto' }, + { power: -21, value: 'z', text: 'zepto' }, + { power: -18, value: 'a', text: 'atto' }, + { power: -15, value: 'f', text: 'femto' }, + { power: -12, value: 'p', text: 'pico' }, + { power: -9, value: 'n', text: 'nano' }, + { power: -6, value: 'µ', text: 'micro' }, + { power: -3, value: 'm', text: 'milli' }, + { power: 0, value: '-', text: '----' }, // position 8 + { power: 3, value: 'k', text: 'Kilo' }, + { power: 6, value: 'M', text: 'Mega' }, + { power: 9, value: 'G', text: 'Giga' }, + { power: 12, value: 'T', text: 'Tera' }, + { power: 15, value: 'P', text: 'Peta' }, + { power: 18, value: 'E', text: 'Exa' }, + { power: 21, value: 'Z', text: 'Zeta' }, + { power: 24, value: 'Y', text: 'Yotta' } +]; + +const SI_MID = 8; + +let defaultDecimals = 0; + +export function calcSi (text: string, decimals: number = defaultDecimals): SiDef { + return SI[(SI_MID - 1) + Math.ceil((text.length - decimals) / 3)]; +} + +// Formats a string/number with . notation +function _balanceFormat (input: string | BN, withSi: boolean = true, decimals: number = defaultDecimals): string { + const text = (input || '').toString(); + + if (text.length === 0 || text === '0') { + return text; + } + + // NOTE We start at midpoint (8) minus 1 - this means that values display as + // 123.456 instead of 0.123k (so always 6 relevant). Additionally we us ceil + // so there are at most 3 decimal before the decimal seperator + const si = calcSi(text, decimals); + const mid = text.length - (decimals + si.power); + const prefix = text.substr(0, mid); + const postfix = `${text.substr(mid)}000`.substr(0, 3); + + return `${decimalFormat(prefix || '0')}.${postfix}${withSi ? (si.value === '-' ? '' : si.value) : ''}`; +} + +const balanceFormat = _balanceFormat as BalanceFormatter; + +// Given a SI type (e.g. k, m, Y) find the SI definition +balanceFormat.findSi = (type: string): SiDef => { + return SI.find(({ value }) => value === type) || SI[SI_MID]; +}; + +balanceFormat.getDefaultDecimals = (): number => { + return defaultDecimals; +}; + +// get allowable options to display in a dropdown +balanceFormat.getOptions = (decimals: number = defaultDecimals): Array => { + return SI.filter(({ power }) => + power < 0 + ? (decimals + power) >= 0 + : true + ); +}; + +// Sets the default decimals to use for formatting (chain-wide) +balanceFormat.setDefaultDecimals = (decimals: number = 0): void => { + defaultDecimals = decimals; +}; + +export default balanceFormat; diff --git a/packages/ui-api/src/util/decimalFormat.ts b/packages/ui-api/src/util/decimalFormat.ts new file mode 100644 index 0000000000..9ec6a40373 --- /dev/null +++ b/packages/ui-api/src/util/decimalFormat.ts @@ -0,0 +1,9 @@ +// Copyright 2017-2019 @polkadot/ui-api authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +const NUMBER_REGEX = new RegExp('(\\d+?)(?=(\\d{3})+(?!\\d)|$)', 'g'); + +export default function decimalFormat (value: string): string { + return (value.match(NUMBER_REGEX) || []).join(','); +} diff --git a/packages/ui-react-rx/src/util/index.ts b/packages/ui-api/src/util/index.ts similarity index 90% rename from packages/ui-react-rx/src/util/index.ts rename to packages/ui-api/src/util/index.ts index 507d07368e..88833102d3 100644 --- a/packages/ui-react-rx/src/util/index.ts +++ b/packages/ui-api/src/util/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/util/intervalObservable.ts b/packages/ui-api/src/util/intervalObservable.ts similarity index 90% rename from packages/ui-react-rx/src/util/intervalObservable.ts rename to packages/ui-api/src/util/intervalObservable.ts index efcccb28e3..950eecd7f3 100644 --- a/packages/ui-react-rx/src/util/intervalObservable.ts +++ b/packages/ui-api/src/util/intervalObservable.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/util/intervalTimer.ts b/packages/ui-api/src/util/intervalTimer.ts similarity index 89% rename from packages/ui-react-rx/src/util/intervalTimer.ts rename to packages/ui-api/src/util/intervalTimer.ts index 01b5d1efa5..927eaa0366 100644 --- a/packages/ui-react-rx/src/util/intervalTimer.ts +++ b/packages/ui-api/src/util/intervalTimer.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/util/isEqual.ts b/packages/ui-api/src/util/isEqual.ts similarity index 88% rename from packages/ui-react-rx/src/util/isEqual.ts rename to packages/ui-api/src/util/isEqual.ts index 27011d8bb5..7dd3a0b32b 100644 --- a/packages/ui-react-rx/src/util/isEqual.ts +++ b/packages/ui-api/src/util/isEqual.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/util/isTestChain.spec.js b/packages/ui-api/src/util/isTestChain.spec.js similarity index 94% rename from packages/ui-react-rx/src/util/isTestChain.spec.js rename to packages/ui-api/src/util/isTestChain.spec.js index 20a46fcb71..991b4eaa2c 100644 --- a/packages/ui-react-rx/src/util/isTestChain.spec.js +++ b/packages/ui-api/src/util/isTestChain.spec.js @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/util/isTestChain.ts b/packages/ui-api/src/util/isTestChain.ts similarity index 86% rename from packages/ui-react-rx/src/util/isTestChain.ts rename to packages/ui-api/src/util/isTestChain.ts index cbbe46dd08..33bc7d35ef 100644 --- a/packages/ui-react-rx/src/util/isTestChain.ts +++ b/packages/ui-api/src/util/isTestChain.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-api/src/util/numberFormat.ts b/packages/ui-api/src/util/numberFormat.ts new file mode 100644 index 0000000000..10fa31bbea --- /dev/null +++ b/packages/ui-api/src/util/numberFormat.ts @@ -0,0 +1,21 @@ +// Copyright 2017-2019 @polkadot/ui-api authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import BN from 'bn.js'; +import { Compact } from '@polkadot/types/codec'; +import { bnToBn } from '@polkadot/util'; + +import decimalFormat from './decimalFormat'; + +export default function numberFormat (_value?: Compact | BN | number | null): string { + if (!_value) { + return '0'; + } + + const value = _value instanceof Compact + ? _value.toBn() + : bnToBn(_value); + + return decimalFormat(value.toString()); +} diff --git a/packages/ui-react-rx/src/util/triggerChange.ts b/packages/ui-api/src/util/triggerChange.ts similarity index 89% rename from packages/ui-react-rx/src/util/triggerChange.ts rename to packages/ui-api/src/util/triggerChange.ts index b1863273a8..d89448f7c3 100644 --- a/packages/ui-react-rx/src/util/triggerChange.ts +++ b/packages/ui-api/src/util/triggerChange.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/with/api.tsx b/packages/ui-api/src/with/api.tsx similarity index 90% rename from packages/ui-react-rx/src/with/api.tsx rename to packages/ui-api/src/with/api.tsx index 59e86c5f82..b14a8df72e 100644 --- a/packages/ui-react-rx/src/with/api.tsx +++ b/packages/ui-api/src/with/api.tsx @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. @@ -8,7 +8,7 @@ import { DefaultProps } from './types'; import React from 'react'; import { assert } from '@polkadot/util'; -import { ApiConsumer } from '../Api/Context'; +import { ApiConsumer } from '../ApiContext'; export default function withApi (Inner: React.ComponentType

, defaultProps: DefaultProps = {}): React.ComponentType { return class WithApi extends React.PureComponent { diff --git a/packages/ui-react-rx/src/with/call.tsx b/packages/ui-api/src/with/call.tsx similarity index 91% rename from packages/ui-react-rx/src/with/call.tsx rename to packages/ui-api/src/with/call.tsx index 8cbe4f3206..0f905a6d86 100644 --- a/packages/ui-react-rx/src/with/call.tsx +++ b/packages/ui-api/src/with/call.tsx @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. @@ -12,7 +12,7 @@ import { assert, isUndefined } from '@polkadot/util'; import derive from '../derive/index'; import { intervalTimer, isEqual, triggerChange } from '../util/index'; -import echoTransform from './transform/echo'; +import echoTransform from '../transform/echo'; import withApi from './api'; type State = RxProps & { @@ -92,7 +92,7 @@ export default function withCall (endpoint: string, { rxChange, params = [ ); } - private getApiMethod (newParams: Array) { + private getApiMethod (newParams: Array): [(...params: Array) => Promise, Array, boolean] { const { apiPromise } = this.props; if (endpoint === 'subscribe') { @@ -144,17 +144,18 @@ export default function withCall (endpoint: string, { rxChange, params = [ this.unsubscribe(); if (isSubscription) { - this.setState({ - destroy: apiMethod(...params, (value?: T) => - this.triggerUpdate(this.props, value)) - }); + const destroy = await apiMethod(...params, (value?: T) => + this.triggerUpdate(this.props, value) + ); + + this.setState({ destroy }); } else { const value: T = await apiMethod(...params); this.triggerUpdate(this.props, value); } } catch (error) { - console.error(endpoint, '::', error); + // console.error(endpoint, '::', error); } } diff --git a/packages/ui-react-rx/src/with/callDiv.tsx b/packages/ui-api/src/with/callDiv.tsx similarity index 94% rename from packages/ui-react-rx/src/with/callDiv.tsx rename to packages/ui-api/src/with/callDiv.tsx index b23ae00d5a..b872c30fce 100644 --- a/packages/ui-react-rx/src/with/callDiv.tsx +++ b/packages/ui-api/src/with/callDiv.tsx @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/with/index.ts b/packages/ui-api/src/with/index.ts similarity index 84% rename from packages/ui-react-rx/src/with/index.ts rename to packages/ui-api/src/with/index.ts index e7544e4ed4..7566797493 100644 --- a/packages/ui-react-rx/src/with/index.ts +++ b/packages/ui-api/src/with/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/with/multi.ts b/packages/ui-api/src/with/multi.ts similarity index 90% rename from packages/ui-react-rx/src/with/multi.ts rename to packages/ui-api/src/with/multi.ts index 6f55c7349f..9497f6371c 100644 --- a/packages/ui-react-rx/src/with/multi.ts +++ b/packages/ui-api/src/with/multi.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/with/observable.tsx b/packages/ui-api/src/with/observable.tsx similarity index 95% rename from packages/ui-react-rx/src/with/observable.tsx rename to packages/ui-api/src/with/observable.tsx index 2fb46d7015..a86fb0501c 100644 --- a/packages/ui-react-rx/src/with/observable.tsx +++ b/packages/ui-api/src/with/observable.tsx @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. @@ -11,8 +11,8 @@ import React from 'react'; import { Observable, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; +import echoTransform from '../transform/echo'; import { intervalObservable, isEqual, triggerChange } from '../util/index'; -import echoTransform from './transform/echo'; type State = RxProps & { subscriptions: Array; // FIXME subscriptions diff --git a/packages/ui-react-rx/src/with/types.ts b/packages/ui-api/src/with/types.ts similarity index 94% rename from packages/ui-react-rx/src/with/types.ts rename to packages/ui-api/src/with/types.ts index 7df4b55f20..4cb13a7084 100644 --- a/packages/ui-react-rx/src/with/types.ts +++ b/packages/ui-api/src/with/types.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/test/enzyme.js b/packages/ui-api/test/enzyme.js similarity index 82% rename from packages/ui-react-rx/test/enzyme.js rename to packages/ui-api/test/enzyme.js index 5db9d7230a..b110d75efc 100644 --- a/packages/ui-react-rx/test/enzyme.js +++ b/packages/ui-api/test/enzyme.js @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/test/observable.js b/packages/ui-api/test/observable.js similarity index 86% rename from packages/ui-react-rx/test/observable.js rename to packages/ui-api/test/observable.js index 3f900d381c..488e4255c9 100644 --- a/packages/ui-react-rx/test/observable.js +++ b/packages/ui-api/test/observable.js @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/webpack.config.js b/packages/ui-api/webpack.config.js similarity index 91% rename from packages/ui-react-rx/webpack.config.js rename to packages/ui-api/webpack.config.js index cce86a72bc..95ffef034a 100644 --- a/packages/ui-react-rx/webpack.config.js +++ b/packages/ui-api/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-app/package.json b/packages/ui-app/package.json index 84b4d080d5..2d2e14e3d7 100644 --- a/packages/ui-app/package.json +++ b/packages/ui-app/package.json @@ -11,13 +11,14 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.2.0", - "@polkadot/extrinsics": "^0.38.16", + "@polkadot/extrinsics": "^0.39.6", "@polkadot/keyring": "^0.33.33", - "@polkadot/storage": "^0.38.16", - "@polkadot/types": "^0.38.16", + "@polkadot/storage": "^0.39.6", + "@polkadot/types": "^0.39.6", + "@polkadot/ui-api": "^0.22.6", "@polkadot/ui-identicon": "^0.25.2", "@polkadot/ui-keyring": "^0.25.2", - "@polkadot/ui-react-rx": "^0.22.8", + "@polkadot/ui-reactive": "^0.22.8", "@polkadot/ui-settings": "^0.25.2", "@polkadot/util": "^0.33.33", "@polkadot/util-crypto": "^0.33.33", diff --git a/packages/ui-app/src/AddressMini.tsx b/packages/ui-app/src/AddressMini.tsx index 2c2e1b2a17..eebe62c041 100644 --- a/packages/ui-app/src/AddressMini.tsx +++ b/packages/ui-app/src/AddressMini.tsx @@ -7,7 +7,7 @@ import { BareProps } from './types'; import BN from 'bn.js'; import React from 'react'; import { AccountId, AccountIndex, Address, Balance } from '@polkadot/types'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import classes from './util/classes'; import toShortAddress from './util/toShortAddress'; diff --git a/packages/ui-app/src/AddressRow.tsx b/packages/ui-app/src/AddressRow.tsx index 4a768e69e5..2abc4cff78 100644 --- a/packages/ui-app/src/AddressRow.tsx +++ b/packages/ui-app/src/AddressRow.tsx @@ -3,7 +3,7 @@ // of the Apache-2.0 license. See the LICENSE file for details. import React from 'react'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import classes from './util/classes'; import { AddressSummary } from './AddressSummary'; diff --git a/packages/ui-app/src/AddressSummary.tsx b/packages/ui-app/src/AddressSummary.tsx index e377675511..0fce39eb84 100644 --- a/packages/ui-app/src/AddressSummary.tsx +++ b/packages/ui-app/src/AddressSummary.tsx @@ -6,8 +6,8 @@ import { I18nProps } from './types'; import React from 'react'; import { AccountId, AccountIndex, Address, Balance } from '@polkadot/types'; -import { Nonce } from '@polkadot/ui-react-rx/index'; -import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { Nonce } from '@polkadot/ui-reactive/index'; +import { withCall, withMulti } from '@polkadot/ui-api/index'; import classes from './util/classes'; import toShortAddress from './util/toShortAddress'; diff --git a/packages/ui-app/src/Balance.tsx b/packages/ui-app/src/Balance.tsx index 110c97afa5..947b3f0e25 100644 --- a/packages/ui-app/src/Balance.tsx +++ b/packages/ui-app/src/Balance.tsx @@ -7,8 +7,8 @@ import { BareProps } from './types'; import BN from 'bn.js'; import React from 'react'; import { AccountId, AccountIndex, Address, Balance } from '@polkadot/types'; -import RxBalance from '@polkadot/ui-react-rx/Balance'; -import { balanceFormat } from '@polkadot/ui-react-rx/util/index'; +import RxBalance from '@polkadot/ui-reactive/Balance'; +import { balanceFormat } from '@polkadot/ui-reactive/util/index'; import classes from './util/classes'; diff --git a/packages/ui-app/src/InputAddress/index.tsx b/packages/ui-app/src/InputAddress/index.tsx index dda7e82f25..12d22c4719 100644 --- a/packages/ui-app/src/InputAddress/index.tsx +++ b/packages/ui-app/src/InputAddress/index.tsx @@ -12,7 +12,7 @@ import store from 'store'; import keyring from '@polkadot/ui-keyring'; import keyringOption from '@polkadot/ui-keyring/options'; import makeOption from '@polkadot/ui-keyring/options/item'; -import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index'; +import { withMulti, withObservable } from '@polkadot/ui-api/index'; import Dropdown from '../Dropdown'; import classes from '../util/classes'; diff --git a/packages/ui-app/src/InputExtrinsic/index.tsx b/packages/ui-app/src/InputExtrinsic/index.tsx index 6717220b59..c6ad32af8e 100644 --- a/packages/ui-app/src/InputExtrinsic/index.tsx +++ b/packages/ui-app/src/InputExtrinsic/index.tsx @@ -3,14 +3,14 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { MethodFunction } from '@polkadot/types/Method'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import { I18nProps } from '../types'; import { DropdownOptions } from '../util/types'; import './InputExtrinsic.css'; import React from 'react'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import classes from '../util/classes'; import translate from '../translate'; diff --git a/packages/ui-app/src/InputNumber.tsx b/packages/ui-app/src/InputNumber.tsx index 7ab711c447..b93d755336 100644 --- a/packages/ui-app/src/InputNumber.tsx +++ b/packages/ui-app/src/InputNumber.tsx @@ -6,7 +6,7 @@ import { BareProps, BitLength, I18nProps } from './types'; import BN from 'bn.js'; import React from 'react'; -import { balanceFormat, calcSi } from '@polkadot/ui-react-rx/util/index'; +import { balanceFormat, calcSi } from '@polkadot/ui-reactive/util/index'; import classes from './util/classes'; import { BitLengthOption } from './constants'; diff --git a/packages/ui-app/src/InputStorage/SelectKey.tsx b/packages/ui-app/src/InputStorage/SelectKey.tsx index fc02abc460..4dec118047 100644 --- a/packages/ui-app/src/InputStorage/SelectKey.tsx +++ b/packages/ui-app/src/InputStorage/SelectKey.tsx @@ -2,13 +2,13 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import { DropdownOptions } from '../util/types'; import { I18nProps } from '../types'; import React from 'react'; import { StorageFunction } from '@polkadot/types/StorageKey'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import Dropdown from '../Dropdown'; import classes from '../util/classes'; diff --git a/packages/ui-app/src/InputStorage/index.tsx b/packages/ui-app/src/InputStorage/index.tsx index aa28f01cc2..c5ba720274 100644 --- a/packages/ui-app/src/InputStorage/index.tsx +++ b/packages/ui-app/src/InputStorage/index.tsx @@ -5,14 +5,14 @@ // TODO: We have a lot shared between this and InputExtrinsic import { StorageFunction } from '@polkadot/types/StorageKey'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import { DropdownOptions } from '../util/types'; import { I18nProps } from '../types'; import '../InputExtrinsic/InputExtrinsic.css'; import React from 'react'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import classes from '../util/classes'; import translate from '../translate'; diff --git a/packages/ui-app/src/Status/Queue.tsx b/packages/ui-app/src/Status/Queue.tsx index ebba7cec07..56985c49e5 100644 --- a/packages/ui-app/src/Status/Queue.tsx +++ b/packages/ui-app/src/Status/Queue.tsx @@ -120,7 +120,9 @@ export default class Queue extends React.Component { private addResultEvents ({ events = [] }: Partial = {}) { events.forEach(({ event: { method, section } }) => { // filter events handled globally, or those we are not interested in - if ((section === 'democracy') || (section === 'system') || (section === 'balances' && method === 'Transfer')) { + // NOTE We are not splitting balances, since we want to see the transfer - even if + // it doubles-up for own accounts (one with id, one without) + if ((section === 'democracy') || (section === 'system')) { return; } diff --git a/packages/ui-app/src/Status/index.tsx b/packages/ui-app/src/Status/index.tsx index c2a29d94ca..6bc26f268f 100644 --- a/packages/ui-app/src/Status/index.tsx +++ b/packages/ui-app/src/Status/index.tsx @@ -68,7 +68,7 @@ class Status extends React.PureComponent { ); } - private renderItem = ({ id, extrinsic, rpc, status }: QueueTx) => { + private renderItem = ({ id, extrinsic, error, rpc, status }: QueueTx) => { let { method, section } = rpc; if (extrinsic) { @@ -94,7 +94,7 @@ class Status extends React.PureComponent { {section}.{method}

- {status} + {error ? error.message : status}
diff --git a/packages/ui-app/src/index.tsx b/packages/ui-app/src/index.tsx index d2b9216b13..d02a79f0b0 100644 --- a/packages/ui-app/src/index.tsx +++ b/packages/ui-app/src/index.tsx @@ -11,7 +11,7 @@ import { BareProps } from './types'; import React from 'react'; import ReactDOM from 'react-dom'; import { HashRouter } from 'react-router-dom'; -import { Api } from '@polkadot/ui-react-rx/index'; +import { Api } from '@polkadot/ui-api/index'; import AddressMini from './AddressMini'; import AddressRow from './AddressRow'; diff --git a/packages/ui-params/src/Param/Amount.tsx b/packages/ui-params/src/Param/Amount.tsx index c6b6021480..a1bf3cab2b 100644 --- a/packages/ui-params/src/Param/Amount.tsx +++ b/packages/ui-params/src/Param/Amount.tsx @@ -7,7 +7,7 @@ import { Props } from '../types'; import BN from 'bn.js'; import React from 'react'; import { Input } from '@polkadot/ui-app/index'; -import numberFormat from '@polkadot/ui-react-rx/util/numberFormat'; +import numberFormat from '@polkadot/ui-reactive/util/numberFormat'; import Bare from './Bare'; diff --git a/packages/ui-params/src/valueToText.tsx b/packages/ui-params/src/valueToText.tsx index cb8637a1b6..ef54e483c5 100644 --- a/packages/ui-params/src/valueToText.tsx +++ b/packages/ui-params/src/valueToText.tsx @@ -10,7 +10,7 @@ import { isNull, isUndefined, u8aToHex } from '@polkadot/util'; // import { decodeAddress } from '@polkadot/keyring'; // import IdentityIcon from '@polkadot/ui-react/IdentityIcon'; -// import numberFormat from '@polkadot/ui-react-rx/util/numberFormat'; +// import numberFormat from '@polkadot/ui-reactive/util/numberFormat'; // import u8aToHex from '@polkadot/util/u8a/toHex'; // import isBn from '@polkadot/util/is/bn'; // import isU8a from '@polkadot/util/is/u8a'; diff --git a/packages/ui-react-rx/src/Api/Context.ts b/packages/ui-react-rx/src/Api/Context.ts deleted file mode 100644 index ee23a0bbef..0000000000 --- a/packages/ui-react-rx/src/Api/Context.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. - -import { ApiProps } from '../types'; - -import React from 'react'; - -const Context: React.Context = React.createContext({} as ApiProps); -const ApiConsumer: React.Consumer = Context.Consumer; -const ApiProvider: React.Provider = Context.Provider; - -export default Context; - -export { - ApiConsumer, - ApiProvider -}; diff --git a/packages/ui-react-rx/src/derive/balances/votingBalancesNominatorsFor.ts b/packages/ui-react-rx/src/derive/balances/votingBalancesNominatorsFor.ts deleted file mode 100644 index c79db82ef6..0000000000 --- a/packages/ui-react-rx/src/derive/balances/votingBalancesNominatorsFor.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. - -import { UnsubFunction } from '@polkadot/api/promise/types'; -import { DeriveSubscription, DerivedBalances } from '../types'; - -import ApiPromise from '@polkadot/api/promise'; -import { AccountId } from '@polkadot/types'; - -import votingBalances from './votingBalances'; - -export default function votingBalancesNominatorsFor (api: ApiPromise): DeriveSubscription { - return (accountId: AccountId | string, cb: (balance: Array) => any): UnsubFunction => { - let combineDestroy: UnsubFunction | undefined; - const nominatorDestory = api.query.staking.nominatorsFor(accountId, (nominators?: Array) => { - if (combineDestroy) { - combineDestroy(); - } - - combineDestroy = votingBalances(api)(...(nominators || []), cb); - }); - - return (): void => { - nominatorDestory(); - - if (combineDestroy) { - combineDestroy(); - } - }; - }; -} diff --git a/packages/ui-reactive/LICENSE b/packages/ui-reactive/LICENSE new file mode 100644 index 0000000000..0d381b2e97 --- /dev/null +++ b/packages/ui-reactive/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/packages/ui-reactive/README.md b/packages/ui-reactive/README.md new file mode 100644 index 0000000000..bd125c2e06 --- /dev/null +++ b/packages/ui-reactive/README.md @@ -0,0 +1,36 @@ +# @polkadot/ui-reactive + +A collection of RxJS enabled React components that operate with the [@polkadot/api-rx](https://github.com/polkadot-js/api) library. It automatically manages subscriptions on behalf of the developer, providing a number of unstyled components that can be used to construct UIs. + +## usage + +Basic usage entails creating a `ContextProvider` and just using the components. For instance, to display the current node time, + +```js +import React from 'react'; +import ReactDOM from 'react-dom'; + +import { Api, NodeTime } from '@polkadot/ui-reactive'; + +... +ReactDOM.render( + + + , + document.querySelector('#container') +); +... +``` + +All components are provided unstyled making no assumptions on the actual use, however they all support (optionally) the `label`, `className` and `style` attributes, that can be used to style to component. + +```js +... +ReactDOM.render( + + + , + document.querySelector('#container') +); +... +``` diff --git a/packages/ui-react-rx/index.html b/packages/ui-reactive/index.html similarity index 100% rename from packages/ui-react-rx/index.html rename to packages/ui-reactive/index.html diff --git a/packages/ui-react-rx/package.json b/packages/ui-reactive/package.json similarity index 85% rename from packages/ui-react-rx/package.json rename to packages/ui-reactive/package.json index 947f1c2558..ed8cf0fa53 100644 --- a/packages/ui-react-rx/package.json +++ b/packages/ui-reactive/package.json @@ -1,5 +1,5 @@ { - "name": "@polkadot/ui-react-rx", + "name": "@polkadot/ui-reactive", "version": "0.22.8", "description": "A collection of RxJs React components the Polkadot JS API", "main": "index.js", @@ -28,11 +28,11 @@ "bugs": { "url": "https://github.com/polkadot-js/ui/issues" }, - "homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-react-rx#readme", + "homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme", "dependencies": { "@babel/runtime": "^7.2.0", - "@polkadot/api": "^0.38.16", - "@polkadot/types": "^0.38.16", + "@polkadot/api": "^0.39.6", + "@polkadot/types": "^0.39.6", "rxjs-compat": "^6.3.2" } } diff --git a/packages/ui-react-rx/src/Balance.tsx b/packages/ui-reactive/src/Balance.tsx similarity index 83% rename from packages/ui-react-rx/src/Balance.tsx rename to packages/ui-reactive/src/Balance.tsx index 447284bba3..d048c2c6e9 100644 --- a/packages/ui-react-rx/src/Balance.tsx +++ b/packages/ui-reactive/src/Balance.tsx @@ -1,14 +1,14 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from './types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { Balance } from '@polkadot/types'; +import { withCall } from '@polkadot/ui-api/index'; import { balanceFormat } from './util/index'; -import { withCall } from './with/index'; type Props = BareProps & { children?: React.ReactNode, diff --git a/packages/ui-react-rx/src/BestFinalised.tsx b/packages/ui-reactive/src/BestFinalised.tsx similarity index 84% rename from packages/ui-react-rx/src/BestFinalised.tsx rename to packages/ui-reactive/src/BestFinalised.tsx index b792a16964..ac27c83ab9 100644 --- a/packages/ui-react-rx/src/BestFinalised.tsx +++ b/packages/ui-reactive/src/BestFinalised.tsx @@ -1,14 +1,14 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from './types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { BlockNumber } from '@polkadot/types'; +import { withCall } from '@polkadot/ui-api/index'; import { numberFormat } from './util/index'; -import { withCall } from './with/index'; type Props = BareProps & { children?: React.ReactNode, diff --git a/packages/ui-react-rx/src/BestNumber.tsx b/packages/ui-reactive/src/BestNumber.tsx similarity index 83% rename from packages/ui-react-rx/src/BestNumber.tsx rename to packages/ui-reactive/src/BestNumber.tsx index 7bed51ffd8..90b84fe091 100644 --- a/packages/ui-react-rx/src/BestNumber.tsx +++ b/packages/ui-reactive/src/BestNumber.tsx @@ -1,14 +1,14 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from './types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { BlockNumber } from '@polkadot/types'; +import { withCall } from '@polkadot/ui-api/index'; import { numberFormat } from './util/index'; -import { withCall } from './with/index'; type Props = BareProps & { children?: React.ReactNode, diff --git a/packages/ui-react-rx/src/Chain.tsx b/packages/ui-reactive/src/Chain.tsx similarity index 80% rename from packages/ui-react-rx/src/Chain.tsx rename to packages/ui-reactive/src/Chain.tsx index 295ece9718..64cef694c2 100644 --- a/packages/ui-react-rx/src/Chain.tsx +++ b/packages/ui-reactive/src/Chain.tsx @@ -1,13 +1,12 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from './types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { Text } from '@polkadot/types'; - -import { withCall } from './with/index'; +import { withCall } from '@polkadot/ui-api/index'; type Props = BareProps & { children?: React.ReactNode, diff --git a/packages/ui-react-rx/src/Elapsed.tsx b/packages/ui-reactive/src/Elapsed.tsx similarity index 93% rename from packages/ui-react-rx/src/Elapsed.tsx rename to packages/ui-reactive/src/Elapsed.tsx index 119fe5011a..b478fbeaf7 100644 --- a/packages/ui-react-rx/src/Elapsed.tsx +++ b/packages/ui-reactive/src/Elapsed.tsx @@ -1,8 +1,8 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from './types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { Moment } from '@polkadot/types'; diff --git a/packages/ui-react-rx/src/NodeName.tsx b/packages/ui-reactive/src/NodeName.tsx similarity index 80% rename from packages/ui-react-rx/src/NodeName.tsx rename to packages/ui-reactive/src/NodeName.tsx index edd5514b1f..2a521326b3 100644 --- a/packages/ui-react-rx/src/NodeName.tsx +++ b/packages/ui-reactive/src/NodeName.tsx @@ -1,13 +1,12 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from './types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { Text } from '@polkadot/types'; - -import { withCall } from './with/index'; +import { withCall } from '@polkadot/ui-api/index'; type Props = BareProps & { children?: React.ReactNode, diff --git a/packages/ui-react-rx/src/NodeVersion.tsx b/packages/ui-reactive/src/NodeVersion.tsx similarity index 80% rename from packages/ui-react-rx/src/NodeVersion.tsx rename to packages/ui-reactive/src/NodeVersion.tsx index b77f0d0d11..bbbca2e4c5 100644 --- a/packages/ui-react-rx/src/NodeVersion.tsx +++ b/packages/ui-reactive/src/NodeVersion.tsx @@ -1,13 +1,12 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from './types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { Text } from '@polkadot/types'; - -import { withCall } from './with/index'; +import { withCall } from '@polkadot/ui-api/index'; type Props = BareProps & { children?: React.ReactNode, diff --git a/packages/ui-react-rx/src/Nonce.tsx b/packages/ui-reactive/src/Nonce.tsx similarity index 83% rename from packages/ui-react-rx/src/Nonce.tsx rename to packages/ui-reactive/src/Nonce.tsx index 696985fe2f..9a3ebc48f6 100644 --- a/packages/ui-react-rx/src/Nonce.tsx +++ b/packages/ui-reactive/src/Nonce.tsx @@ -1,14 +1,14 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from './types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { Index } from '@polkadot/types'; +import { withCall } from '@polkadot/ui-api/index'; import { numberFormat } from './util/index'; -import { withCall } from './with/index'; type Props = BareProps & { children?: React.ReactNode, diff --git a/packages/ui-react-rx/src/TimeNow.tsx b/packages/ui-reactive/src/TimeNow.tsx similarity index 72% rename from packages/ui-react-rx/src/TimeNow.tsx rename to packages/ui-reactive/src/TimeNow.tsx index 986abb7ec7..9164193e08 100644 --- a/packages/ui-react-rx/src/TimeNow.tsx +++ b/packages/ui-reactive/src/TimeNow.tsx @@ -1,8 +1,9 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { withCall } from './with/index'; +import { withCall } from '@polkadot/ui-api/index'; + import Elapsed from './Elapsed'; const Component: React.ComponentType = withCall('query.timestamp.now', { propName: 'value' })( diff --git a/packages/ui-react-rx/src/TimePeriod.tsx b/packages/ui-reactive/src/TimePeriod.tsx similarity index 84% rename from packages/ui-react-rx/src/TimePeriod.tsx rename to packages/ui-reactive/src/TimePeriod.tsx index b6bd368304..c5effe3197 100644 --- a/packages/ui-react-rx/src/TimePeriod.tsx +++ b/packages/ui-reactive/src/TimePeriod.tsx @@ -1,14 +1,14 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { BareProps } from './types'; +import { BareProps } from '@polkadot/ui-api/types'; import React from 'react'; import { Moment } from '@polkadot/types'; +import { withCall } from '@polkadot/ui-api/index'; import { numberFormat } from './util/index'; -import { withCall } from './with/index'; type Props = BareProps & { children?: React.ReactNode, diff --git a/packages/ui-react-rx/src/index.ts b/packages/ui-reactive/src/index.ts similarity index 85% rename from packages/ui-react-rx/src/index.ts rename to packages/ui-reactive/src/index.ts index 44b7c4a851..c037dffe88 100644 --- a/packages/ui-react-rx/src/index.ts +++ b/packages/ui-reactive/src/index.ts @@ -1,8 +1,7 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import Api from './Api'; import Balance from './Balance'; import BestFinalised from './BestFinalised'; import BestNumber from './BestNumber'; @@ -14,7 +13,6 @@ import TimeNow from './TimeNow'; import TimePeriod from './TimePeriod'; export { - Api, Balance, BestFinalised, BestNumber, diff --git a/packages/ui-reactive/src/util/balanceFormat.spec.js b/packages/ui-reactive/src/util/balanceFormat.spec.js new file mode 100644 index 0000000000..98b33ced84 --- /dev/null +++ b/packages/ui-reactive/src/util/balanceFormat.spec.js @@ -0,0 +1,83 @@ +// Copyright 2017-2019 @polkadot/ui-app authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import BN from 'bn.js'; + +import { balanceFormat } from './'; + +describe('balanceFormat', () => { + const TESTVAL = new BN('123456789000'); + + it('formats 123,456,789,000 (decimals=15)', () => { + expect( + balanceFormat(TESTVAL, true, 15) + ).toEqual('123.456µ'); + }); + + it('formats 123,456,789,000 (decimals=12)', () => { + expect( + balanceFormat(TESTVAL, true, 12) + ).toEqual('123.456m'); + }); + + it('formats 123,456,789,000 (decimals=12, no SI)', () => { + expect( + balanceFormat(TESTVAL, false, 12) + ).toEqual('123.456'); + }); + + it('formats 123,456,789,000 (decimals=9)', () => { + expect( + balanceFormat(TESTVAL, true, 9) + ).toEqual('123.456'); + }); + + it('formats 123,456,789,000 (decimals=6)', () => { + expect( + balanceFormat(TESTVAL, true, 6) + ).toEqual('123.456k'); + }); + + it('formats 123,456,789,000 * 10 (decimals=12)', () => { + expect( + balanceFormat(TESTVAL.muln(10), true, 12) + ).toEqual('1.234'); + }); + + it('formats 123,456,789,000 * 100 (decimals=12)', () => { + expect( + balanceFormat(TESTVAL.muln(100), true, 12) + ).toEqual('12.345'); + }); + + it('formats 123,456,789,000 * 1000 (decimals=12)', () => { + expect( + balanceFormat(TESTVAL.muln(1000), true, 12) + ).toEqual('123.456'); + }); + + describe('findSi', () => { + it('finds the SI value', () => { + expect( + balanceFormat.findSi('k') + ).toEqual({ power: 3, value: 'k', text: 'Kilo' }); + }); + + it('returns default on not found', () => { + expect( + balanceFormat.findSi('blah') + ).toEqual({ power: 0, value: '-', text: '----' }); + }); + }); + + describe('setDefaultDecimals', () => { + it('formats 123,456,789,000 (defaultDecimals=15)', () => { + balanceFormat.setDefaultDecimals(15); + + expect( + balanceFormat(TESTVAL) + ).toEqual('123.456µ'); + }); + }); +}); diff --git a/packages/ui-react-rx/src/util/balanceFormat.ts b/packages/ui-reactive/src/util/balanceFormat.ts similarity index 97% rename from packages/ui-react-rx/src/util/balanceFormat.ts rename to packages/ui-reactive/src/util/balanceFormat.ts index c874dfabc6..02183859a2 100644 --- a/packages/ui-react-rx/src/util/balanceFormat.ts +++ b/packages/ui-reactive/src/util/balanceFormat.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-react-rx/src/util/decimalFormat.ts b/packages/ui-reactive/src/util/decimalFormat.ts similarity index 83% rename from packages/ui-react-rx/src/util/decimalFormat.ts rename to packages/ui-reactive/src/util/decimalFormat.ts index 5eae450e29..671f667974 100644 --- a/packages/ui-react-rx/src/util/decimalFormat.ts +++ b/packages/ui-reactive/src/util/decimalFormat.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-reactive/src/util/index.ts b/packages/ui-reactive/src/util/index.ts new file mode 100644 index 0000000000..3dc64839b8 --- /dev/null +++ b/packages/ui-reactive/src/util/index.ts @@ -0,0 +1,14 @@ +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import balanceFormat, { calcSi } from './balanceFormat'; +import decimalFormat from './decimalFormat'; +import numberFormat from './numberFormat'; + +export { + balanceFormat, + calcSi, + decimalFormat, + numberFormat +}; diff --git a/packages/ui-react-rx/src/util/numberFormat.ts b/packages/ui-reactive/src/util/numberFormat.ts similarity index 89% rename from packages/ui-react-rx/src/util/numberFormat.ts rename to packages/ui-reactive/src/util/numberFormat.ts index c716cea473..ed098b5532 100644 --- a/packages/ui-react-rx/src/util/numberFormat.ts +++ b/packages/ui-reactive/src/util/numberFormat.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/ui-reactive/webpack.config.js b/packages/ui-reactive/webpack.config.js new file mode 100644 index 0000000000..95ffef034a --- /dev/null +++ b/packages/ui-reactive/webpack.config.js @@ -0,0 +1,33 @@ +// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +const ENV = process.env.NODE_ENV || 'development'; +const isProd = ENV === 'production'; + +module.exports = { + context: __dirname, + devtool: isProd ? 'source-map' : 'cheap-eval-source-map', + entry: './src/demo.tsx', + mode: ENV, + output: { + path: __dirname, + filename: './demo.js' + }, + resolve: { + alias: {}, + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }, + module: { + rules: [ + { + test: /\.(js|ts|tsx)$/, + exclude: /(node_modules)/, + use: { + loader: 'babel-loader' + } + } + ] + }, + plugins: [] +}; diff --git a/packages/ui-signer/src/Modal.tsx b/packages/ui-signer/src/Modal.tsx index 3e46dd6e61..d5191c4b89 100644 --- a/packages/ui-signer/src/Modal.tsx +++ b/packages/ui-signer/src/Modal.tsx @@ -3,8 +3,8 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { SubmittableSendResult } from '@polkadot/api/types'; -import { UnsubFunction } from '@polkadot/api/promise/types'; -import { ApiProps } from '@polkadot/ui-react-rx/types'; +import { PromiseSubscription } from '@polkadot/api/promise/types'; +import { ApiProps } from '@polkadot/ui-api/types'; import { I18nProps, BareProps } from '@polkadot/ui-app/types'; import { RpcMethod } from '@polkadot/jsonrpc/types'; import { QueueTx, QueueTx$MessageSetStatus, QueueTx$Result, QueueTx$Status } from '@polkadot/ui-app/Status/types'; @@ -14,7 +14,7 @@ import SubmittableExtrinsic from '@polkadot/api/promise/SubmittableExtrinsic'; import { decodeAddress } from '@polkadot/keyring'; import { Button, Modal } from '@polkadot/ui-app/index'; import keyring from '@polkadot/ui-keyring'; -import { withApi, withMulti } from '@polkadot/ui-react-rx/with/index'; +import { withApi, withMulti } from '@polkadot/ui-api/index'; import { assert } from '@polkadot/util'; import { format } from '@polkadot/util/logger'; @@ -213,9 +213,9 @@ class Signer extends React.PureComponent { }); } - private onKeyDown = (event: React.KeyboardEvent): void => { + private onKeyDown = async (event: React.KeyboardEvent) => { if (event.key === 'Enter') { - this.onSend(); + await this.onSend(); } } @@ -231,7 +231,7 @@ class Signer extends React.PureComponent { queueSetTxStatus(currentItem.id, 'cancelled'); } - private onSend = (): void => { + private onSend = async (): Promise => { const { currentItem, password } = this.state; // This should never be executed @@ -256,7 +256,7 @@ class Signer extends React.PureComponent { queueSetTxStatus(id, status, result, error); } - private sendExtrinsic = ({ accountId, extrinsic, id, isUnsigned }: QueueTx, password?: string) => { + private async sendExtrinsic ({ accountId, extrinsic, id, isUnsigned }: QueueTx, password?: string): Promise { assert(extrinsic, 'Expected an extrinsic to be supplied to sendExtrinsic'); if (!isUnsigned) { @@ -276,9 +276,9 @@ class Signer extends React.PureComponent { queueSetTxStatus(id, 'sending'); if (!isUnsigned) { - this.makeExtrinsicCall(submittable, id, submittable.signAndSend, keyring.getPair(accountId as string)); + return this.makeExtrinsicCall(submittable, id, submittable.signAndSend, keyring.getPair(accountId as string)); } else { - this.makeExtrinsicCall(submittable, id, submittable.send); + return this.makeExtrinsicCall(submittable, id, submittable.send); } } @@ -304,19 +304,27 @@ class Signer extends React.PureComponent { } } - private makeExtrinsicCall (extrinsic: SubmittableExtrinsic, id: number, extrinsicCall: (...params: Array) => any, ..._params: Array) { + private async makeExtrinsicCall (extrinsic: SubmittableExtrinsic, id: number, extrinsicCall: (...params: Array) => any, ..._params: Array): Promise { const { queueSetTxStatus } = this.props; - const unsubscribe = extrinsicCall.apply(extrinsic, [..._params, (result: SubmittableSendResult) => { - const status = result.type.toLowerCase() as QueueTx$Status; - console.log('submitAndWatchExtrinsic: updated status ::', result); + try { + const subscription = await extrinsicCall.apply(extrinsic, [..._params, async (result: SubmittableSendResult) => { + const status = result.type.toLowerCase() as QueueTx$Status; - queueSetTxStatus(id, status, result); + console.log('submitAndWatchExtrinsic: updated status ::', result); - if (status === 'finalised') { - unsubscribe(); - } - }]) as UnsubFunction; + queueSetTxStatus(id, status, result); + + if (status === 'finalised') { + const unsubscribe = await subscription; + + unsubscribe(); + } + }]) as PromiseSubscription; + } catch (error) { + console.error('error.message', error.message); + queueSetTxStatus(id, 'error', {}, error); + } } } diff --git a/tsconfig.json b/tsconfig.json index 67e01780ee..1d6a552934 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,9 +16,10 @@ "@polkadot/app-transfer/*": [ "packages/app-transfer/src/*" ], "@polkadot/app-vanitygen/*": [ "packages/app-vanitygen/src/*" ], "@polkadot/apps/*": [ "packages/apps/src/*" ], + "@polkadot/ui-api/*": [ "packages/ui-api/src/*" ], "@polkadot/ui-app/*": [ "packages/ui-app/src/*" ], "@polkadot/ui-params/*": [ "packages/ui-params/src/*" ], - "@polkadot/ui-react-rx/*": [ "packages/ui-react-rx/src/*" ], + "@polkadot/ui-reactive/*": [ "packages/ui-reactive/src/*" ], "@polkadot/ui-signer/*": [ "packages/ui-signer/src/*" ] }, "typeRoots": [ diff --git a/yarn.lock b/yarn.lock index afd2e5540c..02d0a765c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1369,31 +1369,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.38.16": - version "0.38.16" - resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.38.16.tgz#15e4b41f82c455d2dd289a5e984fc9ca6b931668" - integrity sha512-cTjUkpjSzzW94QmugqR6eoZ1Up/hScSqOdxWIiihPtx9owYqmD+0fPd0gQgf7Y4AKkrBEW/la5cW/tNNFEgRqA== +"@polkadot/api-derive@^0.39.6": + version "0.39.6" + resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.39.6.tgz#615214d90dc4fe4162df016faaf20d5540378e65" + integrity sha512-EooJlXHHDmdtueyWemiMn7/uNgDHkOg0Hw1BR+tWd+UouYVFNoM436dvzjmW/imJ2xw76oKBUyVVLvHxmmBlcQ== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/api" "^0.38.16" - "@polkadot/types" "^0.38.16" + "@polkadot/api" "^0.39.6" + "@polkadot/types" "^0.39.6" "@types/memoizee" "^0.4.2" "@types/rx" "^4.1.1" memoizee "^0.4.14" rxjs "^6.3.3" -"@polkadot/api@^0.38.16": - version "0.38.16" - resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.38.16.tgz#00fd750801edb7ba8f97fc1b548b45c1d6d9f9c3" - integrity sha512-G53NQLGJNJFwVPQljWTiSiC1WnOXB6Uh05JcYNe3kpW3H2dE/XSwRe9q5T9WrgdGGDX3zDxfYN0dgTyrZlFYGg== +"@polkadot/api@^0.39.6": + version "0.39.6" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.39.6.tgz#41fcd0660379bf5b6242af0d10cfed585592f7d5" + integrity sha512-nQD20DO4GdlrVCCmyRymXtzyB7A9huo0jGluG1XWysnVwkRJ+yT7oHWEyJokYzRkr3F+tUKjtazmMUqyMxGPog== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/api-derive" "^0.38.16" - "@polkadot/extrinsics" "^0.38.16" - "@polkadot/rpc-provider" "^0.38.16" - "@polkadot/rpc-rx" "^0.38.16" - "@polkadot/storage" "^0.38.16" - "@polkadot/types" "^0.38.16" + "@polkadot/api-derive" "^0.39.6" + "@polkadot/extrinsics" "^0.39.6" + "@polkadot/rpc-provider" "^0.39.6" + "@polkadot/rpc-rx" "^0.39.6" + "@polkadot/storage" "^0.39.6" + "@polkadot/types" "^0.39.6" "@types/rx" "^4.1.1" rxjs "^6.3.3" @@ -1472,19 +1472,19 @@ typedoc-plugin-no-inherit "^1.1.1" typescript "^3.2.2" -"@polkadot/extrinsics@^0.38.16": - version "0.38.16" - resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.38.16.tgz#49ce7e47529b912b17843e30717efb13f5f9f667" - integrity sha512-3Kcyoq+Dh/f5jIlkr6DIug3f9Ythf+p7sSp7ktrCD55ZYfvYzdXOCb5SIeVpXDhHlpDYXT/Aj/QLynCFD+I3Kw== +"@polkadot/extrinsics@^0.39.6": + version "0.39.6" + resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.39.6.tgz#1d8e2429f9759e26780940ca32d689d6cb1044bb" + integrity sha512-h7huIAgwC3OzX5reA8q0xLXviily5at6SCXvu/ylX/AN0biZXjoW1sq3SggL3ZcbrhRu3Bk79olCr7393P8l3A== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/types" "^0.38.16" + "@polkadot/types" "^0.39.6" "@polkadot/util" "^0.33.33" -"@polkadot/jsonrpc@^0.38.16": - version "0.38.16" - resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.38.16.tgz#456d8ce11f1dedb108d2debe974187c92a73bb13" - integrity sha512-G87JwRnp89AwTXiaQWeVefU8ykzw7y5/Az7FLKW3BmgH6eFbr8uxYD1LaSl1W+VArwCve5ibFvBIzfcqStbtIA== +"@polkadot/jsonrpc@^0.39.6": + version "0.39.6" + resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.39.6.tgz#02474017b0426c2baa27c412b02b4d0efb80bfa3" + integrity sha512-AfkeHxVPdHB9BQ8TF/6Dn8dUDy73xzl4Nqb/Cw1zMHZUFhsVDfPiobe6WO6p8ESF2x3Yd0whNJ8skhMDNxnD0w== dependencies: "@babel/runtime" "^7.2.0" @@ -1499,25 +1499,25 @@ "@types/bs58" "^4.0.0" bs58 "^4.0.1" -"@polkadot/rpc-core@^0.38.16": - version "0.38.16" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.38.16.tgz#332bd9134502c075a4a2dee478d818bf4bd17ec0" - integrity sha512-H/H6fnXj/tkArf8hfBFpvfI+EGw0uedKkwLca3tRSJ/4680oTD9JNKqWkp3BMfCjombsLkuw6mAqnOyBDO1Z9w== +"@polkadot/rpc-core@^0.39.6": + version "0.39.6" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.39.6.tgz#683c1d20cac3d2955e5fcb85fb72243fcd8e2a12" + integrity sha512-9fSdoXpXSoySBz9DywnXMBPHQoYOkxJEvaGkKmGnu49WNBM15g0mzJmZwHkToBNxMdnFK9qPtf0nDwM5OjT4Iw== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/jsonrpc" "^0.38.16" - "@polkadot/rpc-provider" "^0.38.16" - "@polkadot/types" "^0.38.16" + "@polkadot/jsonrpc" "^0.39.6" + "@polkadot/rpc-provider" "^0.39.6" + "@polkadot/types" "^0.39.6" "@polkadot/util" "^0.33.33" -"@polkadot/rpc-provider@^0.38.16": - version "0.38.16" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.38.16.tgz#9216e5629e06cf51b2f736113b9a1c178d0df1a8" - integrity sha512-oqh2p0FeroymdcJbPDYlNpGrZpahrcZN04EZYixnL0JrluD6nmz51yA0/k59YdHwBNZRAcF9eOGJfuQhEtTL0g== +"@polkadot/rpc-provider@^0.39.6": + version "0.39.6" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.39.6.tgz#9566c713afe3c4ebc0b1574969847555404464a6" + integrity sha512-sK4duFfEHKs18qRmqKOAszqSx1aC8k8iQa5f08E1VtpJrditp4xRuIaCX2HNXeMOwbiLJlGuVodobNYaP0VvJA== dependencies: "@babel/runtime" "^7.2.0" "@polkadot/keyring" "^0.33.33" - "@polkadot/storage" "^0.38.16" + "@polkadot/storage" "^0.39.6" "@polkadot/util" "^0.33.33" "@polkadot/util-crypto" "^0.33.33" "@types/nock" "^9.3.0" @@ -1525,25 +1525,25 @@ isomorphic-fetch "^2.2.1" websocket "^1.0.28" -"@polkadot/rpc-rx@^0.38.16": - version "0.38.16" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-rx/-/rpc-rx-0.38.16.tgz#7485afab25429095716e579cb456a7c25601c947" - integrity sha512-i/3E52TGYGO3sQWP8QRTEbUmrpTdMkV/+U+jUUvs0DyjbpnI1hw6roTI0lUdJoi3dPP8p29WctSGP6kXaIlkHQ== +"@polkadot/rpc-rx@^0.39.6": + version "0.39.6" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-rx/-/rpc-rx-0.39.6.tgz#d9e1c7f2e672fa20e646366c0d35df1e23d9cca4" + integrity sha512-VEbbdGXLshV+GcLu0O1a8QdXAaVDDKV8pq8nD/doZkcztw6GYbtPTqwAHwvlU238BEXXfMJ1yWQwKxlV4i7fzQ== dependencies: "@babel/runtime" "^7.2.0" - "@polkadot/rpc-core" "^0.38.16" - "@polkadot/rpc-provider" "^0.38.16" + "@polkadot/rpc-core" "^0.39.6" + "@polkadot/rpc-provider" "^0.39.6" "@types/rx" "^4.1.1" rxjs "^6.3.3" -"@polkadot/storage@^0.38.16": - version "0.38.16" - resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.38.16.tgz#dc53c7a6f35a1623be4f30575974b5e6c1158d92" - integrity sha512-DZT5++RvKu4C57s84mx55kA85R6EKZf4GBiaW06VeHTmq9q6cyoGCaB7tdLxlLmIndz779rFT25LeXN86Bxgpw== +"@polkadot/storage@^0.39.6": + version "0.39.6" + resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.39.6.tgz#4c16cc0c64b443be1b81918e0193573e75ed36a5" + integrity sha512-unOc3JFPQ179nJn805daw/UZYM5GQx4MVYVotW77edWPgfn8D3oIF50IKT0NxjqiQfzAFcNSVl2IQTlhdhGL4Q== dependencies: "@babel/runtime" "^7.2.0" "@polkadot/keyring" "^0.33.33" - "@polkadot/types" "^0.38.16" + "@polkadot/types" "^0.39.6" "@polkadot/util" "^0.33.33" "@polkadot/util-crypto" "^0.33.33" @@ -1552,10 +1552,10 @@ resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.49.tgz#9f4cf54540ca10bec64910bb3f5e094db609b63d" integrity sha512-0qtOAmT5DJcDjgnfx95ByljJYjMqgOA72SWsBfZq9myzzCrAvoVXMn7lzfKvpPgaZooTJ+vpp/YqXgx3507LKQ== -"@polkadot/types@^0.38.16": - version "0.38.16" - resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.38.16.tgz#06d898c3dea86601e4c53d4e7b46c6ecf2194376" - integrity sha512-totQOU3ZrxTGH9ZoDM168TD2aEk+vCrrw7TeBu5eeAhcCEPfksXAc3awAa0X09hWB9X+PfbryPOsrp3wHXuWJw== +"@polkadot/types@^0.39.6": + version "0.39.6" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.39.6.tgz#78493a2de924d3101d1e8d57169129aaf06043cb" + integrity sha512-/G0rGZj8XOJk4Vwv63Wno4aJ0ILiDrgNa44a5z9l1UR9q3UgvROnkk23SqymqGf7npVnqPYG8ZlI+cWGXz0MZQ== dependencies: "@babel/runtime" "^7.2.0" "@polkadot/keyring" "^0.33.33"