From aed8df37a3427cf49bf04a75ef24b829c15162bf Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 19 Jan 2020 23:05:02 +0100 Subject: [PATCH] Society app (#2148) * Society app * useCheck * Summary * Updates * Bump API with society * Bump API (fixed publish) --- i18next-scanner.config.js | 1 + package.json | 6 +- packages/app-claims/src/translate.ts | 2 +- packages/app-contracts/package.json | 2 +- packages/app-society/LICENSE | 201 ++++++++++++++++++ packages/app-society/README.md | 1 + packages/app-society/package.json | 13 ++ .../app-society/src/Overview/Candidate.tsx | 41 ++++ .../app-society/src/Overview/Candidates.tsx | 43 ++++ packages/app-society/src/Overview/Member.tsx | 34 +++ packages/app-society/src/Overview/Members.tsx | 43 ++++ packages/app-society/src/Overview/Summary.tsx | 92 ++++++++ packages/app-society/src/Overview/index.tsx | 30 +++ packages/app-society/src/index.tsx | 38 ++++ packages/app-society/src/translate.ts | 11 + packages/app-society/src/useCheck.ts | 21 ++ .../app-treasury/src/Overview/Summary.tsx | 5 +- packages/apps-routing/src/index.ts | 4 +- packages/apps-routing/src/society.ts | 24 +++ packages/apps-routing/src/types.ts | 1 + .../apps/public/locales/en/app-society.json | 1 + packages/apps/src/SideBar/Item.tsx | 8 +- packages/react-api/package.json | 2 +- packages/react-components/src/AccountName.tsx | 2 +- tsconfig.json | 2 + yarn.lock | 92 ++++---- 26 files changed, 659 insertions(+), 61 deletions(-) create mode 100644 packages/app-society/LICENSE create mode 100644 packages/app-society/README.md create mode 100644 packages/app-society/package.json create mode 100644 packages/app-society/src/Overview/Candidate.tsx create mode 100644 packages/app-society/src/Overview/Candidates.tsx create mode 100644 packages/app-society/src/Overview/Member.tsx create mode 100644 packages/app-society/src/Overview/Members.tsx create mode 100644 packages/app-society/src/Overview/Summary.tsx create mode 100644 packages/app-society/src/Overview/index.tsx create mode 100644 packages/app-society/src/index.tsx create mode 100644 packages/app-society/src/translate.ts create mode 100644 packages/app-society/src/useCheck.ts create mode 100644 packages/apps-routing/src/society.ts create mode 100644 packages/apps/public/locales/en/app-society.json diff --git a/i18next-scanner.config.js b/i18next-scanner.config.js index eea325d2bc..edf171fb32 100644 --- a/i18next-scanner.config.js +++ b/i18next-scanner.config.js @@ -37,6 +37,7 @@ module.exports = { 'app-js', 'app-parachains', 'app-settings', + 'app-society', 'app-staking', 'app-storage', 'app-sudo', diff --git a/package.json b/package.json index 0144a39cff..99837054ca 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "packages/*" ], "resolutions": { - "@polkadot/api": "^1.0.0-beta.10", - "@polkadot/api-contract": "^1.0.0-beta.10", + "@polkadot/api": "^1.0.0-beta.12", + "@polkadot/api-contract": "^1.0.0-beta.12", "@polkadot/keyring": "^2.0.0-beta.4", - "@polkadot/types": "^1.0.0-beta.10", + "@polkadot/types": "^1.0.0-beta.12", "@polkadot/util": "^2.0.0-beta.4", "@polkadot/util-crypto": "^2.0.0-beta.4", "babel-core": "^7.0.0-bridge.0", diff --git a/packages/app-claims/src/translate.ts b/packages/app-claims/src/translate.ts index 0f305e89ed..7fd3ffee73 100644 --- a/packages/app-claims/src/translate.ts +++ b/packages/app-claims/src/translate.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/app-123code authors & contributors +// Copyright 2017-2020 @polkadot/app-claims 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/app-contracts/package.json b/packages/app-contracts/package.json index 5114309624..2dedb8c2e3 100644 --- a/packages/app-contracts/package.json +++ b/packages/app-contracts/package.json @@ -11,6 +11,6 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.7.7", - "@polkadot/api-contract": "^1.0.0-beta.10" + "@polkadot/api-contract": "^1.0.0-beta.12" } } diff --git a/packages/app-society/LICENSE b/packages/app-society/LICENSE new file mode 100644 index 0000000000..0d381b2e97 --- /dev/null +++ b/packages/app-society/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/app-society/README.md b/packages/app-society/README.md new file mode 100644 index 0000000000..1b41088319 --- /dev/null +++ b/packages/app-society/README.md @@ -0,0 +1 @@ +# @polkadot/app-society diff --git a/packages/app-society/package.json b/packages/app-society/package.json new file mode 100644 index 0000000000..2e016eec72 --- /dev/null +++ b/packages/app-society/package.json @@ -0,0 +1,13 @@ +{ + "name": "@polkadot/app-society", + "version": "0.39.0-beta.65", + "description": "A society", + "main": "index.js", + "scripts": {}, + "author": "Jaco Greeff ", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.7.7", + "@polkadot/react-components": "^0.39.0-beta.69" + } +} diff --git a/packages/app-society/src/Overview/Candidate.tsx b/packages/app-society/src/Overview/Candidate.tsx new file mode 100644 index 0000000000..96d8c04d29 --- /dev/null +++ b/packages/app-society/src/Overview/Candidate.tsx @@ -0,0 +1,41 @@ +// Copyright 2017-2020 @polkadot/app-society 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 { DeriveSocietyCandidate } from '@polkadot/api-derive/types'; + +import React from 'react'; +import { AddressSmall } from '@polkadot/react-components'; +import { FormatBalance } from '@polkadot/react-query'; + +import { useTranslation } from '../translate'; + +interface Props { + value: DeriveSocietyCandidate; +} + +export default function Candidate ({ value: { accountId, isSuspended, kind, value } }: Props): React.ReactElement { + const { t } = useTranslation(); + + return ( + + + + + + + {kind.toString()} + + + + + + + {isSuspended ? t('Yes') : t('No')} + + + ); +} diff --git a/packages/app-society/src/Overview/Candidates.tsx b/packages/app-society/src/Overview/Candidates.tsx new file mode 100644 index 0000000000..e20112d68c --- /dev/null +++ b/packages/app-society/src/Overview/Candidates.tsx @@ -0,0 +1,43 @@ +// Copyright 2017-2020 @polkadot/app-society 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 { DeriveSocietyCandidate } from '@polkadot/api-derive/types'; + +import React from 'react'; +import { Table } from '@polkadot/react-components'; +import { useApi, useCall } from '@polkadot/react-hooks'; + +import { useTranslation } from '../translate'; +import Candidate from './Candidate'; + +interface Props { + className?: string; +} + +export default function Candidates ({ className }: Props): React.ReactElement { + const { t } = useTranslation(); + const { api } = useApi(); + const candidates = useCall(api.derive.society.candidates, []); + + return ( +
+

{t('candidates')}

+ {candidates?.length + ? ( + + + {candidates.map((candidate): React.ReactNode => ( + + ))} + +
+ ) + : t('No candidates') + } +
+ ); +} diff --git a/packages/app-society/src/Overview/Member.tsx b/packages/app-society/src/Overview/Member.tsx new file mode 100644 index 0000000000..64636f6ab3 --- /dev/null +++ b/packages/app-society/src/Overview/Member.tsx @@ -0,0 +1,34 @@ +// Copyright 2017-2020 @polkadot/app-society 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 { DeriveSocietyMember } from '@polkadot/api-derive/types'; + +import React from 'react'; +import { AddressSmall } from '@polkadot/react-components'; + +import { useTranslation } from '../translate'; + +interface Props { + value: DeriveSocietyMember; +} + +export default function Member ({ value: { accountId, isSuspended, strikes } }: Props): React.ReactElement { + const { t } = useTranslation(); + + return ( + + + + + + + {strikes.toString()} + + + + {isSuspended ? t('Yes') : t('No')} + + + ); +} diff --git a/packages/app-society/src/Overview/Members.tsx b/packages/app-society/src/Overview/Members.tsx new file mode 100644 index 0000000000..8d0875dfeb --- /dev/null +++ b/packages/app-society/src/Overview/Members.tsx @@ -0,0 +1,43 @@ +// Copyright 2017-2020 @polkadot/app-society 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 { DeriveSocietyMember } from '@polkadot/api-derive/types'; + +import React from 'react'; +import { Table } from '@polkadot/react-components'; +import { useApi, useCall } from '@polkadot/react-hooks'; + +import { useTranslation } from '../translate'; +import Member from './Member'; + +interface Props { + className?: string; +} + +export default function Members ({ className }: Props): React.ReactElement { + const { t } = useTranslation(); + const { api } = useApi(); + const members = useCall(api.derive.society.members, []); + + return ( +
+

{t('members')}

+ {members?.length + ? ( + + + {members.map((member): React.ReactNode => ( + + ))} + +
+ ) + : t('No active members') + } +
+ ); +} diff --git a/packages/app-society/src/Overview/Summary.tsx b/packages/app-society/src/Overview/Summary.tsx new file mode 100644 index 0000000000..d6083894d6 --- /dev/null +++ b/packages/app-society/src/Overview/Summary.tsx @@ -0,0 +1,92 @@ +// Copyright 2017-2020 @polkadot/app-society 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 { DeriveSociety } from '@polkadot/api-derive/types'; +import { AccountId } from '@polkadot/types/interfaces'; + +import React from 'react'; +import styled from 'styled-components'; +import { AccountName, IdentityIcon, SummaryBox, CardSummary } from '@polkadot/react-components'; +import { useApi, useCall } from '@polkadot/react-hooks'; +import { formatBalance } from '@polkadot/util'; + +import { useTranslation } from '../translate'; + +interface Props { + className?: string; +} + +interface NameProps { + label: string; + value?: AccountId; +} + +function Name ({ label, value }: NameProps): React.ReactElement | null { + if (!value) { + return null; + } + + return ( + +
+ + +
+
+ ); +} + +function Summary ({ className }: Props): React.ReactElement { + const { t } = useTranslation(); + const { api } = useApi(); + const info = useCall(api.derive.society.info, []); + const members = useCall(api.derive.society.members, []); + + const pot = info?.pot.gtn(0) + ? info.pot.toString() + : null; + + return ( + +
+ +
+
+ {info && members && ( + + {members.length}/{info.maxMembers.toString()} + + )} +
+
+ {pot && ( + + {formatBalance(pot, false)}{formatBalance.calcSi(pot).value} + + )} +
+
+ ); +} + +export default styled(Summary)` + .society--header--account { + white-space: nowrap; + + .ui--AccountName, + .ui--IdentityIcon { + display: inline-block; + } + + .ui--IdentityIcon { + margin-right: 0.5rem; + } + } +`; diff --git a/packages/app-society/src/Overview/index.tsx b/packages/app-society/src/Overview/index.tsx new file mode 100644 index 0000000000..554379b0f9 --- /dev/null +++ b/packages/app-society/src/Overview/index.tsx @@ -0,0 +1,30 @@ +// Copyright 2017-2020 @polkadot/app-society 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 React from 'react'; +import styled from 'styled-components'; + +import Candidates from './Candidates'; +import Members from './Members'; +import Summary from './Summary'; + +interface Props { + className?: string; +} + +function Overview ({ className }: Props): React.ReactElement { + return ( +
+ + + +
+ ); +} + +export default styled(Overview)` + .overviewSection { + margin-bottom: 1.5rem; + } +`; diff --git a/packages/app-society/src/index.tsx b/packages/app-society/src/index.tsx new file mode 100644 index 0000000000..50fb4fbd25 --- /dev/null +++ b/packages/app-society/src/index.tsx @@ -0,0 +1,38 @@ +// Copyright 2017-2020 @polkadot/app-society 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 { AppProps, BareProps } from '@polkadot/react-components/types'; + +import React from 'react'; +import { Tabs } from '@polkadot/react-components'; + +import useCheck from './useCheck'; +import Overview from './Overview'; +import { useTranslation } from './translate'; + +export { useCheck }; + +interface Props extends AppProps, BareProps {} + +export default function SocietyApp ({ basePath, className }: Props): React.ReactElement { + const { t } = useTranslation(); + + return ( +
+
+ +
+ +
+ ); +} diff --git a/packages/app-society/src/translate.ts b/packages/app-society/src/translate.ts new file mode 100644 index 0000000000..e1216aa50f --- /dev/null +++ b/packages/app-society/src/translate.ts @@ -0,0 +1,11 @@ +// Copyright 2017-2020 @polkadot/app-society 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 { useTranslation as useTranslationBase, UseTranslationResponse, withTranslation } from 'react-i18next'; + +export function useTranslation (): UseTranslationResponse { + return useTranslationBase('app-society'); +} + +export default withTranslation(['app-society']); diff --git a/packages/app-society/src/useCheck.ts b/packages/app-society/src/useCheck.ts new file mode 100644 index 0000000000..492c87e726 --- /dev/null +++ b/packages/app-society/src/useCheck.ts @@ -0,0 +1,21 @@ +// Copyright 2017-2020 @polkadot/app-society 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 { AccountId } from '@polkadot/types/interfaces'; + +import { useState, useEffect } from 'react'; +import { useApi, useCall } from '@polkadot/react-hooks'; +import { Option } from '@polkadot/types'; + +export default function useCheck (): boolean { + const { api, isApiReady } = useApi(); + const founder = useCall>(isApiReady ? api.query.society?.founder : undefined, []); + const [check, setCheck] = useState(false); + + useEffect((): void => { + setCheck(founder?.isSome || false); + }, [founder]); + + return check; +} diff --git a/packages/app-treasury/src/Overview/Summary.tsx b/packages/app-treasury/src/Overview/Summary.tsx index 39d99049f5..3aabaec4c8 100644 --- a/packages/app-treasury/src/Overview/Summary.tsx +++ b/packages/app-treasury/src/Overview/Summary.tsx @@ -20,16 +20,13 @@ interface Props { export default function Summary ({ approvalCount, proposalCount }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); - const pot = useCall(api.query.treasury.pot, []); const bestNumber = useCall(api.derive.chain.bestNumber as any, []); const spendPeriod = api.consts.treasury.spendPeriod; const treasuryBalance = useCall(api.query.balances.freeBalance, [TREASURY_ACCOUNT]); const value = treasuryBalance?.gtn(0) ? treasuryBalance.toString() - : pot?.gtn(0) - ? pot.toString() - : null; + : null; return ( diff --git a/packages/apps-routing/src/index.ts b/packages/apps-routing/src/index.ts index adac7bcd0c..534f2e6843 100644 --- a/packages/apps-routing/src/index.ts +++ b/packages/apps-routing/src/index.ts @@ -20,6 +20,7 @@ import genericAsset from './generic-asset'; import js from './js'; import parachains from './parachains'; import settings from './settings'; +import society from './society'; import staking from './staking'; import storage from './storage'; import sudo from './sudo'; @@ -41,7 +42,7 @@ const routes: Routes = appSettings.uiMode === 'light' staking, democracy, council, - // TODO Not sure about the inclusion of treasury & parachains here + // TODO Not sure about the inclusion of treasury, parachains & society here null, settings ) @@ -60,6 +61,7 @@ const routes: Routes = appSettings.uiMode === 'light' treasury, techcomm, parachains, + society, null, contracts, storage, diff --git a/packages/apps-routing/src/society.ts b/packages/apps-routing/src/society.ts new file mode 100644 index 0000000000..364ab24b7f --- /dev/null +++ b/packages/apps-routing/src/society.ts @@ -0,0 +1,24 @@ +// Copyright 2017-2020 @polkadot/apps-routing 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 { Routes } from './types'; + +import Society, { useCheck } from '@polkadot/app-society'; + +export default ([ + { + Component: Society, + useCheck, + display: { + needsApi: [ + 'query.society.pot' + ] + }, + i18n: { + defaultValue: 'Society' + }, + icon: 'grab', + name: 'society' + } +] as Routes); diff --git a/packages/apps-routing/src/types.ts b/packages/apps-routing/src/types.ts index 2805af5def..7d58f57347 100644 --- a/packages/apps-routing/src/types.ts +++ b/packages/apps-routing/src/types.ts @@ -12,6 +12,7 @@ export interface RouteProps extends AppProps, BareProps { export interface Route { Component: React.ComponentType; Modal?: React.ComponentType; + useCheck?: () => boolean; useCounter?: () => number; display: { isHidden?: boolean; diff --git a/packages/apps/public/locales/en/app-society.json b/packages/apps/public/locales/en/app-society.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/packages/apps/public/locales/en/app-society.json @@ -0,0 +1 @@ +{} diff --git a/packages/apps/src/SideBar/Item.tsx b/packages/apps/src/SideBar/Item.tsx index 2c2cdd4ceb..3f1c204bac 100644 --- a/packages/apps/src/SideBar/Item.tsx +++ b/packages/apps/src/SideBar/Item.tsx @@ -15,6 +15,7 @@ import { isFunction } from '@polkadot/util'; import { useTranslation } from '../translate'; +const DUMMY_CHECK = (): boolean => true; const DUMMY_COUNTER = (): number => 0; interface Props { @@ -73,13 +74,14 @@ function checkVisible (name: string, { api, isApiReady, isApiConnected }: ApiPro return notFound.length === 0; } -export default function Item ({ route: { Modal, useCounter = DUMMY_COUNTER, display, i18n, icon, name }, isCollapsed, onClick }: Props): React.ReactElement | null { +export default function Item ({ route: { Modal, useCheck = DUMMY_CHECK, useCounter = DUMMY_COUNTER, display, i18n, icon, name }, isCollapsed, onClick }: Props): React.ReactElement | null { const { t } = useTranslation(); const { allAccounts, hasAccounts } = useAccounts(); const apiProps = useApi(); const sudoKey = useCall(apiProps.isApiReady ? apiProps.api.query.sudo?.key : undefined, []); const [hasSudo, setHasSudo] = useState(false); const [isVisible, setIsVisible] = useState(false); + const checkState = useCheck(); const count = useCounter(); useEffect((): void => { @@ -87,8 +89,8 @@ export default function Item ({ route: { Modal, useCounter = DUMMY_COUNTER, disp }, [allAccounts, sudoKey]); useEffect((): void => { - setIsVisible(checkVisible(name, apiProps, hasAccounts, hasSudo, display)); - }, [apiProps, hasAccounts, hasSudo]); + setIsVisible(checkState && checkVisible(name, apiProps, hasAccounts, hasSudo, display)); + }, [apiProps, checkState, hasAccounts, hasSudo]); if (!isVisible) { return null; diff --git a/packages/react-api/package.json b/packages/react-api/package.json index 08746208e8..4f5f308d85 100644 --- a/packages/react-api/package.json +++ b/packages/react-api/package.json @@ -31,7 +31,7 @@ "homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme", "dependencies": { "@babel/runtime": "^7.7.6", - "@polkadot/api": "^1.0.0-beta.10", + "@polkadot/api": "^1.0.0-beta.12", "@polkadot/extension-dapp": "^0.15.0-beta.1", "edgeware-node-types": "^1.0.10", "rxjs-compat": "^6.5.3" diff --git a/packages/react-components/src/AccountName.tsx b/packages/react-components/src/AccountName.tsx index 7477473f4b..8b700990fa 100644 --- a/packages/react-components/src/AccountName.tsx +++ b/packages/react-components/src/AccountName.tsx @@ -300,7 +300,7 @@ function AccountName ({ children, className, defaultName, label, onClick, overri )}
= 8" -"@polkadot/api-contract@^1.0.0-beta.10": - version "1.0.0-beta.10" - resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-1.0.0-beta.10.tgz#7b83cf51a080db174b061b50727aedca76399e82" - integrity sha512-zIt8DvD9sBcWgIu73XPP5MzerJ1+fc8V2bUpF/9x1BEQLFVP97RXAaAP3MIhh6m0y0cdBrJeoDK8f5guBQ0W1A== +"@polkadot/api-contract@^1.0.0-beta.12": + version "1.0.0-beta.12" + resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-1.0.0-beta.12.tgz#0611968e8b459f92c5d0f7d2d98eb1c97bce01f9" + integrity sha512-9hA5+VzLDVqQW00ewc7nFf+bS5hJEVittjvlJXWZoXSAAERFmsr5OEmESkz+Ku8j4W/yQn2XChRbv4WsX35Srg== dependencies: "@babel/runtime" "^7.7.7" - "@polkadot/types" "^1.0.0-beta.10" + "@polkadot/types" "^1.0.0-beta.12" -"@polkadot/api-derive@^1.0.0-beta.10": - version "1.0.0-beta.10" - resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-1.0.0-beta.10.tgz#9842a331c58f598dbd20825a7f945a0739674ed8" - integrity sha512-Df5xTTRbvj7Qhzj++xnxQEzwZvR9MgZsbDvk23TZkZ2biEckGskN5AxO65uc7lxvSVjVJzsJvGN+DtYXxe5aKQ== +"@polkadot/api-derive@^1.0.0-beta.12": + version "1.0.0-beta.12" + resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-1.0.0-beta.12.tgz#ee0bb0e0dc916a610c48aa5dbb975e2b9f6b0064" + integrity sha512-oxYMc+Rkg1FhHCHiF1PPLGxzWYt9/q2u/IzP7R2SOQI3CivbU8Io97+AQrlUHcxeOcvRnb8hofFvcKhvfytO/g== dependencies: "@babel/runtime" "^7.7.7" - "@polkadot/api" "^1.0.0-beta.10" - "@polkadot/types" "^1.0.0-beta.10" + "@polkadot/api" "^1.0.0-beta.12" + "@polkadot/types" "^1.0.0-beta.12" -"@polkadot/api@^1.0.0-beta.10": - version "1.0.0-beta.10" - resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-1.0.0-beta.10.tgz#a796cc48d843f0c74de953e4cf2e4dce07db4569" - integrity sha512-J/f326DvmBwZ5LmuD7F7FAUVYQXGm1wUjvClKBSv5h9JrRE/M5xyTnPFpCXzmZWC/RrsDOT62SFOtfsJHPp1YQ== +"@polkadot/api@^1.0.0-beta.12": + version "1.0.0-beta.12" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-1.0.0-beta.12.tgz#60985ab369389957f3e0fac0630c91e4d8b6aa53" + integrity sha512-bWZ34qW/SyhWDUFaK+VUMW2XAlamGx6A9En2nrdcrztxY9iHLUB6Dpa28lvfZKBw4rlm1fq2mcWlk6fKPkyqdw== dependencies: "@babel/runtime" "^7.7.7" - "@polkadot/api-derive" "^1.0.0-beta.10" + "@polkadot/api-derive" "^1.0.0-beta.12" "@polkadot/keyring" "^2.0.0-beta.4" - "@polkadot/metadata" "^1.0.0-beta.10" - "@polkadot/rpc-core" "^1.0.0-beta.10" - "@polkadot/rpc-provider" "^1.0.0-beta.10" - "@polkadot/types" "^1.0.0-beta.10" + "@polkadot/metadata" "^1.0.0-beta.12" + "@polkadot/rpc-core" "^1.0.0-beta.12" + "@polkadot/rpc-provider" "^1.0.0-beta.12" + "@polkadot/types" "^1.0.0-beta.12" "@polkadot/util-crypto" "^2.0.0-beta.4" "@polkadot/dev-react@^0.32.14": @@ -2226,10 +2226,10 @@ dependencies: "@babel/runtime" "^7.7.7" -"@polkadot/jsonrpc@^1.0.0-beta.10": - version "1.0.0-beta.10" - resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-1.0.0-beta.10.tgz#495b52c5b842cb7823fc4b68a44877b724abd9c1" - integrity sha512-xwgpVEQO7i2xVlTrM1NY/sC6C6B6fVgfA+rthllDqeRyCPXQW6tBlW9UW8N3xyjKHU6gGbynOvRJQ+UWjZo/7g== +"@polkadot/jsonrpc@^1.0.0-beta.12": + version "1.0.0-beta.12" + resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-1.0.0-beta.12.tgz#22219c7e210d5a4877db5a610299a556e8450027" + integrity sha512-ms+wUv2uRX59iLvx3K+ci6yBOsvb+Xl3ZjWNVjIKBmr8FjzxMkLNd8h3FCz6UxyiYPGs0Y3OLqZbV/K4d1vkLg== dependencies: "@babel/runtime" "^7.7.7" @@ -2242,13 +2242,13 @@ "@polkadot/util" "^2.0.0-beta.4" "@polkadot/util-crypto" "^2.0.0-beta.4" -"@polkadot/metadata@^1.0.0-beta.10": - version "1.0.0-beta.10" - resolved "https://registry.yarnpkg.com/@polkadot/metadata/-/metadata-1.0.0-beta.10.tgz#f6e56c0745088dce3f0e3e0b1e9f07c4d39c8389" - integrity sha512-bOpRxClUc6R47DmSL9aXoX1MdJJFppAPRNnbsM3E1RvNwN4Uc/Npkpe5FXbC3NBEc3L+dS0BsgAiGQQ1z7Hlaw== +"@polkadot/metadata@^1.0.0-beta.12": + version "1.0.0-beta.12" + resolved "https://registry.yarnpkg.com/@polkadot/metadata/-/metadata-1.0.0-beta.12.tgz#338e3ac7f323acf8c6d119c1bd91178767e71c36" + integrity sha512-86tE7uNX/6aaqgUMGr3ejQgEEdN4o0iYAB7ew3pMtXAdtYaAl2mGQkZWUNuXT7iT8XcwcUqVtPd48EWNuDm/PA== dependencies: "@babel/runtime" "^7.7.7" - "@polkadot/types" "^1.0.0-beta.10" + "@polkadot/types" "^1.0.0-beta.12" "@polkadot/util" "^2.0.0-beta.4" "@polkadot/util-crypto" "^2.0.0-beta.4" @@ -2276,25 +2276,25 @@ qrcode-generator "^1.4.4" react-qr-reader "^2.2.1" -"@polkadot/rpc-core@^1.0.0-beta.10": - version "1.0.0-beta.10" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-1.0.0-beta.10.tgz#7020f2aada7523741e281f2ce498498cfb22603d" - integrity sha512-WeP74u2T2Q4oBUku3LXigNWluwtBOW6smbjmEmHt9+7TZRRetekdo9lYA6HYZdb4+0UoBH3pQp2WdK4vAIrLyg== +"@polkadot/rpc-core@^1.0.0-beta.12": + version "1.0.0-beta.12" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-1.0.0-beta.12.tgz#81d5eca3e540d607fd66f16412e9d9ef7e9c2999" + integrity sha512-4OfZp+MZEdvw0wLeaKP5r4ZvWVkSFtWKyWK4lyRTqId0zmLHmBtITxGCkFlteSxn7d6+RO+FeoBbxAE94kqf0g== dependencies: "@babel/runtime" "^7.7.7" - "@polkadot/jsonrpc" "^1.0.0-beta.10" - "@polkadot/rpc-provider" "^1.0.0-beta.10" - "@polkadot/types" "^1.0.0-beta.10" + "@polkadot/jsonrpc" "^1.0.0-beta.12" + "@polkadot/rpc-provider" "^1.0.0-beta.12" + "@polkadot/types" "^1.0.0-beta.12" "@polkadot/util" "^2.0.0-beta.4" rxjs "^6.5.4" -"@polkadot/rpc-provider@^1.0.0-beta.10": - version "1.0.0-beta.10" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-1.0.0-beta.10.tgz#703326c7f07bd0e839149377917b85caefb95473" - integrity sha512-u3b0ROuZdFfPfXIVzdcqUQmJIbC+8/JJwIhXc9F8rw60SSnMmRHyE//jifDwNyOoZlKMBG1GoYp3kjgwxVYaNA== +"@polkadot/rpc-provider@^1.0.0-beta.12": + version "1.0.0-beta.12" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-1.0.0-beta.12.tgz#dfe15322e4abf2e12f7b9e9cad4710a79215fa33" + integrity sha512-0hFZnelNVZVvrM5MMTAOSjzXegDT4Zxi0Shdr268lacM85K270UGW1jjCL57qsUgGB9DhZE//7nnu8Osi9Pk7g== dependencies: "@babel/runtime" "^7.7.7" - "@polkadot/metadata" "^1.0.0-beta.10" + "@polkadot/metadata" "^1.0.0-beta.12" "@polkadot/util" "^2.0.0-beta.4" "@polkadot/util-crypto" "^2.0.0-beta.4" eventemitter3 "^4.0.0" @@ -2308,13 +2308,13 @@ dependencies: "@types/chrome" "^0.0.91" -"@polkadot/types@^1.0.0-beta.10": - version "1.0.0-beta.10" - resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-1.0.0-beta.10.tgz#5a1591ff668b0bf0911264bfac0a6af8e51a3345" - integrity sha512-QlW36LvEZ6igYm+P9bXFne++FrXidc1LiVpgjzTqWh5OK2RWQk/j7ZXsiATVIVCVyuJhgcKMBIf9ZkGGx14Z7w== +"@polkadot/types@^1.0.0-beta.12": + version "1.0.0-beta.12" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-1.0.0-beta.12.tgz#314015f5f4d42c118fcf8d8353902d9524bd7cca" + integrity sha512-zlKT+UFCfYmAbkqmSXloKumatIk1u5N3vgzHKir9rgG6eqsvRWkhxxjxvkARKvQUFWjY2dwvVy6g7263Rz35Ng== dependencies: "@babel/runtime" "^7.7.7" - "@polkadot/metadata" "^1.0.0-beta.10" + "@polkadot/metadata" "^1.0.0-beta.12" "@polkadot/util" "^2.0.0-beta.4" "@polkadot/util-crypto" "^2.0.0-beta.4" "@types/memoizee" "^0.4.3"