diff --git a/package.json b/package.json
index 6d0cdbd14e39..b50ea4248921 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,8 @@
"@polkadot/wasm-crypto": "^4.2.1",
"babel-core": "^7.0.0-bridge.0",
"styled-components": "^5.2.0",
- "typescript": "^4.4.3"
+ "typescript": "^4.4.3",
+ "multihashes": "^4.0.2"
},
"scripts": {
"analyze": "yarn clean && BUILD_ANALYZE=1 yarn run build:code && yarn source-map-explorer packages/apps/build/main.*.js",
diff --git a/packages/apps-routing/src/alliance.ts b/packages/apps-routing/src/alliance.ts
new file mode 100644
index 000000000000..798eff36a0c8
--- /dev/null
+++ b/packages/apps-routing/src/alliance.ts
@@ -0,0 +1,23 @@
+// Copyright 2017-2021 @polkadot/apps-routing authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { TFunction } from 'i18next';
+import type { Route } from './types';
+
+import Component, { useCounter } from '@polkadot/app-alliance';
+
+export default function create (t: TFunction): Route {
+ return {
+ Component,
+ display: {
+ needsApi: []
+ },
+ group: 'governance',
+ icon: 'atom',
+ name: 'alliance',
+ text: t('nav.alliance', 'Alliance', {
+ ns: 'apps-routing'
+ }),
+ useCounter
+ };
+}
diff --git a/packages/apps-routing/src/index.ts b/packages/apps-routing/src/index.ts
index 64f65a2e391d..938f8f8deae0 100644
--- a/packages/apps-routing/src/index.ts
+++ b/packages/apps-routing/src/index.ts
@@ -6,6 +6,7 @@ import type { Routes } from './types';
import accounts from './accounts';
import addresses from './addresses';
+import alliance from './alliance';
import assets from './assets';
import bounties from './bounties';
import calendar from './calendar';
@@ -46,6 +47,7 @@ export default function create (t: TFunction): Routes {
council(t),
treasury(t),
bounties(t),
+ alliance(t),
techcomm(t),
membership(t),
parachains(t),
diff --git a/packages/apps/public/locales/en/app-alliance.json b/packages/apps/public/locales/en/app-alliance.json
new file mode 100644
index 000000000000..b6bb2ff7b400
--- /dev/null
+++ b/packages/apps/public/locales/en/app-alliance.json
@@ -0,0 +1,100 @@
+{
+ "Acceptance proposal": "Acceptance proposal",
+ "Account blacklist empty": "Account blacklist empty",
+ "Accounts": "Accounts",
+ "Add blacklist": "Add blacklist",
+ "Add item": "Add item",
+ "Alliance rule": "Alliance rule",
+ "Allies": "Allies",
+ "Announcements": "Announcements",
+ "Announcements ({{count}})": "Announcements ({{count}})",
+ "Aye {{count}}": "Aye {{count}}",
+ "Blacklist ({{count}})": "Blacklist ({{count}})",
+ "Candidates": "Candidates",
+ "Candidates ({{count}})": "Candidates ({{count}})",
+ "Close": "Close",
+ "Close proposal": "Close proposal",
+ "Deposit": "Deposit",
+ "Elevate to fellow": "Elevate to fellow",
+ "Fellows": "Fellows",
+ "Founders": "Founders",
+ "IPFS Hash": "IPFS Hash",
+ "IPFS hash": "IPFS hash",
+ "Ipfs Hash": "Ipfs Hash",
+ "Ipfs hash": "Ipfs hash",
+ "Members ({{count}})": "Members ({{count}})",
+ "Motions": "Motions",
+ "Nay {{count}}": "Nay {{count}}",
+ "No allies": "No allies",
+ "No announcements": "No announcements",
+ "No blacklist.": "No blacklist.",
+ "No candidates": "No candidates",
+ "No fellows": "No fellows",
+ "No founders": "No founders",
+ "No motions": "No motions",
+ "No rule": "No rule",
+ "Nominate account": "Nominate account",
+ "Nominate candidacy": "Nominate candidacy",
+ "Nominator": "Nominator",
+ "Propose": "Propose",
+ "Propose Announcement": "Propose Announcement",
+ "Propose an alliance motion": "Propose an alliance motion",
+ "Propose an nominate candidacy": "Propose an nominate candidacy",
+ "Propose blacklist": "Propose blacklist",
+ "Propose elevate to fellow": "Propose elevate to fellow",
+ "Propose kicking out": "Propose kicking out",
+ "Propose setting rule": "Propose setting rule",
+ "Rejection proposal": "Rejection proposal",
+ "Remove blacklist": "Remove blacklist",
+ "Remove item": "Remove item",
+ "Retire": "Retire",
+ "Select the account you wish close the proposal with.": "Select the account you wish close the proposal with.",
+ "Select the account you wish to submit the proposal from.": "Select the account you wish to submit the proposal from.",
+ "Select type": "Select type",
+ "Set Rule": "Set Rule",
+ "Set rule": "Set rule",
+ "Submit": "Submit",
+ "Submit candidacy": "Submit candidacy",
+ "Submit kicking proposal": "Submit kicking proposal",
+ "Submit proposal": "Submit proposal",
+ "The account will be kick out.": "The account will be kick out.",
+ "The account will elevate to fellow.": "The account will elevate to fellow.",
+ "The alliance member account for this vote. The selection is filtered by the current members.": "The alliance member account for this vote. The selection is filtered by the current members.",
+ "The alliance member account that will apply the close for the current round.": "The alliance member account that will apply the close for the current round.",
+ "The bond that is reserved": "The bond that is reserved",
+ "The bond will be reserved for the duration of your candidacy and membership.": "The bond will be reserved for the duration of your candidacy and membership.",
+ "The proposal that is being voted on. It will pass when the threshold is reached.": "The proposal that is being voted on. It will pass when the threshold is reached.",
+ "The proposal that will be affected. Once closed for the current voting round, it would need to be re-submitted to alliance for a subsequent voting round.": "The proposal that will be affected. Once closed for the current voting round, it would need to be re-submitted to alliance for a subsequent voting round.",
+ "The type of alliance proposal to submit.": "The type of alliance proposal to submit.",
+ "The vote will be recorded for the selected account.": "The vote will be recorded for the selected account.",
+ "This account will be use to nominate candidacy.": "This account will be use to nominate candidacy.",
+ "This account will be use to propose announce.": "This account will be use to propose announce.",
+ "This account will be use to propose candidacy.": "This account will be use to propose candidacy.",
+ "This account will be use to propose set rule.": "This account will be use to propose set rule.",
+ "This account will be use to submit candidacy.": "This account will be use to submit candidacy.",
+ "This account will make the proposal and be responsible for the bond.": "This account will make the proposal and be responsible for the bond.",
+ "Vote": "Vote",
+ "Vote Aye": "Vote Aye",
+ "Vote Nay": "Vote Nay",
+ "Vote on proposal": "Vote on proposal",
+ "Website": "Website",
+ "Website blacklist empty": "Website blacklist empty",
+ "Websites": "Websites",
+ "account blacklist": "account blacklist",
+ "address {{index}}": "address {{index}}",
+ "alliance proposal type": "alliance proposal type",
+ "candidacy bond": "candidacy bond",
+ "filter by address or identity": "filter by address or identity",
+ "filter by website or index": "filter by website or index",
+ "motions": "motions",
+ "propose account": "propose account",
+ "selected": "selected",
+ "sending account": "sending account",
+ "submit account": "submit account",
+ "submit with account": "submit with account",
+ "threshold": "threshold",
+ "voting end": "voting end",
+ "website blacklist": "website blacklist",
+ "website {{index}}": "website {{index}}",
+ "xxx": "xxx"
+}
\ No newline at end of file
diff --git a/packages/apps/public/locales/en/apps-routing.json b/packages/apps/public/locales/en/apps-routing.json
index b732df766713..980c13dbdcd7 100644
--- a/packages/apps/public/locales/en/apps-routing.json
+++ b/packages/apps/public/locales/en/apps-routing.json
@@ -1,6 +1,7 @@
{
"nav.accounts": "Accounts",
"nav.addresses": "Address book",
+ "nav.alliance": "Alliance",
"nav.assets": "Assets",
"nav.bounties": "Bounties",
"nav.calendar": "Event calendar",
diff --git a/packages/apps/public/locales/en/index.json b/packages/apps/public/locales/en/index.json
index 457ed460d427..260d5516e327 100644
--- a/packages/apps/public/locales/en/index.json
+++ b/packages/apps/public/locales/en/index.json
@@ -1,6 +1,7 @@
[
"app-accounts.json",
"app-addresses.json",
+ "app-alliance.json",
"app-assets.json",
"app-bounties.json",
"app-calendar.json",
diff --git a/packages/apps/public/locales/en/react-components.json b/packages/apps/public/locales/en/react-components.json
index d88c13175853..e240bb0b1e06 100644
--- a/packages/apps/public/locales/en/react-components.json
+++ b/packages/apps/public/locales/en/react-components.json
@@ -41,6 +41,7 @@
"everything": "everything",
"extrinsic hash": "extrinsic hash",
"filter by name, address, or account index": "filter by name, address, or account index",
+ "filter by name, text, or text index": "filter by name, text, or text index",
"lifetime": "lifetime",
"lock expired": "lock expired",
"locked": "locked",
diff --git a/packages/apps/public/locales/en/translation.json b/packages/apps/public/locales/en/translation.json
index f2cd00187920..e5afb415dcaf 100644
--- a/packages/apps/public/locales/en/translation.json
+++ b/packages/apps/public/locales/en/translation.json
@@ -12,7 +12,10 @@
"After a bounty was proposed the council decides whether to fund it or not.": "",
"All stashes": "",
"All voters may alter their votes any number of times prior to the close of the poll.": "",
+ "Allies": "",
"An account that is to receive the rewards": "",
+ "Announcements": "",
+ "Announcements ({{count}})": "",
"Any combination of the four options may be approved of by the voter. There is no need to select only one option!": "",
"Approving of all or none of the options is equivalent and will not affect the outcome of the poll.": "",
"Authorize transaction": "",
@@ -27,6 +30,8 @@
"Cancel all": "",
"Cancel selected": "",
"Candidate": "",
+ "Candidates": "",
+ "Candidates ({{count}})": "",
"Change democracy delegation": "",
"Change this account's password": "",
"Claim": "",
@@ -54,9 +59,11 @@
"Evaluated {{count}} keys in {{elapsed}}s ({{avg}} keys/s)": "",
"Execute": "",
"Extensions": "",
+ "Fellows": "",
"For approvals outstanding approvers will be shown, for hashes that should be cancelled the first approver is required.": "",
"For final approvals, the actual full call data is required to execute the transaction": "",
"Forget this account": "",
+ "Founders": "",
"Full Legal Name": "",
"Governance": "",
"Identity": "",
@@ -78,6 +85,7 @@
"Network": "",
"Never execute JS snippets from untrusted sources.": "",
"Next session": "",
+ "No blacklist.": "",
"No change": "",
"No change from the original 2017 sale definitions; will mean a total of 10 million DOT from genesis.": "",
"No discretionary lock-voting is in place; all DOT used to vote counts the same.": "",
@@ -96,12 +104,15 @@
"Please read these terms and conditions carefully. By submitting this statement, you are deemed to have accepted these Terms and Conditions. If you do not agree to these terms, please refrain from accessing or proceeding. You can also find them at:": "",
"Prior locked voting": "",
"Produced blocks": "",
+ "Propose elevate to fellow": "",
+ "Propose kicking out": "",
"Proposer": "",
"Recovery": "",
"Retrieving data": "",
"Retrieving nominators": "",
"Retrieving validators": "",
"Save": "",
+ "Set Rule": "",
"Set on-chain identity": "",
"Set on-chain sub-identities": "",
"Settings": "",
@@ -181,6 +192,7 @@
"Voting costs nothing other than the transaction fee and can be done from all accounts with a non-zero spendable balance.": "",
"Voting is made on a per-account basis; a single account must all vote the same way and cannot split its vote.": "",
"Warning: we did not find any attest statement for {{chain}}": "",
+ "Website": "",
"With the keep-alive option set, the account is protected against removal due to low balances.": "",
"Yes, allow nominations": "",
"You need to sign an attestation for the following account:": "",
@@ -335,4 +347,4 @@
"{{count}} key/value pairs encoded for submission": "",
"{{days}} days": "",
"{{percentage}}% turnout": ""
-}
\ No newline at end of file
+}
diff --git a/packages/page-alliance/.skip-build b/packages/page-alliance/.skip-build
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/packages/page-alliance/.skip-npm b/packages/page-alliance/.skip-npm
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/packages/page-alliance/LICENSE b/packages/page-alliance/LICENSE
new file mode 100644
index 000000000000..0d381b2e97dc
--- /dev/null
+++ b/packages/page-alliance/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/page-alliance/README.md b/packages/page-alliance/README.md
new file mode 100644
index 000000000000..413ea7d55cc8
--- /dev/null
+++ b/packages/page-alliance/README.md
@@ -0,0 +1 @@
+# @polkadot/app-alliance
diff --git a/packages/page-alliance/package.json b/packages/page-alliance/package.json
new file mode 100644
index 000000000000..c961acb4fc75
--- /dev/null
+++ b/packages/page-alliance/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "@polkadot/app-alliance",
+ "private": true,
+ "type": "module",
+ "version": "0.95.2-149",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@babel/runtime": "^7.14.0",
+ "@polkadot/react-components": "^0.95.2-149",
+ "@polkadot/react-query": "^0.95.2-149",
+ "cids": "^1.1.6"
+ }
+}
diff --git a/packages/page-alliance/src/Announcements/Announcement.tsx b/packages/page-alliance/src/Announcements/Announcement.tsx
new file mode 100644
index 000000000000..eef85a11cd7f
--- /dev/null
+++ b/packages/page-alliance/src/Announcements/Announcement.tsx
@@ -0,0 +1,57 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { Cid } from '@polkadot/types/interfaces';
+
+import React from 'react';
+import styled from 'styled-components';
+
+import { ExpanderMarkdown, Spinner } from '@polkadot/react-components';
+
+import { IPFS_GATEWAY } from '../constants';
+import { useCidEncode } from '../useCid';
+import { useContent } from '../useContent';
+
+interface Props {
+ className?: string
+ announcement: Cid;
+ index: number;
+}
+
+function Announcement ({ announcement, className }: Props): React.ReactElement {
+ const hash = useCidEncode(announcement);
+ const { content, fetching } = useContent(hash);
+
+ return
+
+
+ /ipfs/{hash}
+
+
+
+ {fetching
+ ?
+ : content
+ ?
+ : '-'}
+
+ ;
+}
+
+export default React.memo(styled(Announcement)`
+ .item {
+ height: 26px;
+ line-height: 26px;
+ }
+`);
diff --git a/packages/page-alliance/src/Announcements/Propose.tsx b/packages/page-alliance/src/Announcements/Propose.tsx
new file mode 100644
index 000000000000..db8d2311f19d
--- /dev/null
+++ b/packages/page-alliance/src/Announcements/Propose.tsx
@@ -0,0 +1,83 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo, useState } from 'react';
+
+import { Button, Input, InputAddress, Modal, TxButton } from '@polkadot/react-components';
+import { useApi, useToggle } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+import { useCidDecode } from '../useCid';
+
+interface Props {
+ className?: string;
+ isMember: boolean;
+ members: string[];
+}
+
+function Propose ({ className = '', isMember, members }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const [isVisible, toggleVisible] = useToggle();
+ const [accountId, setAccountId] = useState(null);
+ const [hash, setHash] = useState(null);
+ const { api } = useApi();
+
+ const hashEncode = useCidDecode(hash);
+
+ const propose = useMemo(() => {
+ if (!hashEncode || !accountId) {
+ return null;
+ }
+
+ return api.tx.alliance.announce(hashEncode);
+ }, [accountId, api.tx.alliance, hashEncode]);
+
+ return <>
+ ('Propose Announcement')}
+ onClick={toggleVisible}
+ />
+ {isVisible && (
+ ('propose an announcement')}
+ onClose={toggleVisible}
+ size='large'
+ >
+
+ ('The alliance founder or fellow accounts for the proposal. The selection is filtered by the current accounts with proposing rights.')}>
+ ('This account will be use to propose announce.')}
+ label={t('Propose from account')}
+ onChange={setAccountId}
+ type='account'
+ />
+
+ ('The IPFS hash of the announcement, better be formatted in a single Markdown document.')}>
+ ('IPFS hash')}
+ isError={!hashEncode}
+ label={t('IPFS hash')}
+ onChange={setHash}
+ />
+
+
+
+ ('Propose')}
+ onStart={toggleVisible}
+ params={[propose]}
+ tx={api.tx.alliance.propose}
+ />
+
+
+ )}
+ >;
+}
+
+export default React.memo(Propose);
diff --git a/packages/page-alliance/src/Announcements/index.tsx b/packages/page-alliance/src/Announcements/index.tsx
new file mode 100644
index 000000000000..e5062fe02160
--- /dev/null
+++ b/packages/page-alliance/src/Announcements/index.tsx
@@ -0,0 +1,50 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { Cid } from '@polkadot/types/interfaces';
+
+import React, { useMemo } from 'react';
+
+import { Button, Table } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+import Announcement from './Announcement';
+import Propose from './Propose';
+
+interface Props {
+ className?: string;
+ announcements: Cid[];
+ isMember: boolean;
+ members: string[];
+}
+
+function Announcements ({ announcements: announcementsSource, isMember, members }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const announcements = useMemo(() => [...(announcementsSource || [])].reverse(), [announcementsSource]);
+
+ const header = useMemo(() => [
+ [t('Announcements'), 'start'],
+ [t('Content'), 'start']
+ ], [t]);
+
+ return <>
+
+
+
+ ('No announcements')}
+ header={header}
+ >
+ {announcements.map((announcement, index) => )}
+
+ >;
+}
+
+export default React.memo(Announcements);
diff --git a/packages/page-alliance/src/Blacklist/Account.tsx b/packages/page-alliance/src/Blacklist/Account.tsx
new file mode 100644
index 000000000000..c957e2c7e152
--- /dev/null
+++ b/packages/page-alliance/src/Blacklist/Account.tsx
@@ -0,0 +1,40 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo } from 'react';
+
+import { AddressSmall } from '@polkadot/react-components';
+import { useAccountInfo } from '@polkadot/react-hooks';
+
+interface Props {
+ account: string;
+ filter: string;
+ index: number;
+}
+
+function Account ({ account, filter, index }: Props): React.ReactElement | null {
+ const { identity, name } = useAccountInfo(account);
+
+ const visible = useMemo(() =>
+ !filter ||
+ filter === `${index}` ||
+ name.toLowerCase().includes(filter.toLowerCase()) ||
+ account.toLowerCase().includes(filter.toLowerCase()) ||
+ (identity && identity.display?.toLocaleLowerCase().includes(filter.toLocaleLowerCase())),
+ [account, filter, index, identity, name]
+ );
+
+ if (!visible) {
+ return null;
+ }
+
+ return (
+
+
+
+
+
+ );
+}
+
+export default React.memo(Account);
diff --git a/packages/page-alliance/src/Blacklist/Add.tsx b/packages/page-alliance/src/Blacklist/Add.tsx
new file mode 100644
index 000000000000..1f86fce10633
--- /dev/null
+++ b/packages/page-alliance/src/Blacklist/Add.tsx
@@ -0,0 +1,202 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useCallback, useMemo, useState } from 'react';
+
+import { Button, Columar, Dropdown, Input, InputAddress, Modal, TxButton } from '@polkadot/react-components';
+import { DropdownOptions } from '@polkadot/react-components/util/types';
+import { useApi, useToggle } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+type BlackListType = 'Website' | 'AccountId';
+
+interface Props {
+ className?: string;
+ isMember: boolean;
+ members: string[];
+}
+
+interface ItemProps {
+ index: number;
+ value: BlackListValue;
+ onChange: (value: BlackListValue) => void;
+}
+
+interface BlackListValue {
+ value: string;
+ type: BlackListType;
+ valid: boolean;
+}
+
+function AddItem ({ index, onChange, value }: ItemProps): React.ReactElement {
+ const { t } = useTranslation();
+
+ const options: DropdownOptions = useMemo(() => [{
+ key: 'Website',
+ text: 'Website',
+ value: 'Website'
+ }, {
+ key: 'AccountId',
+ text: 'AccountId',
+ value: 'AccountId'
+ }], []);
+
+ const onValueChange = useCallback((newValue: string | null) => {
+ const valid = value.type === 'Website'
+ ? !!(['https://', 'http://'].find((prefix) => newValue?.startsWith(prefix)))
+ : true;
+
+ onChange({
+ type: value.type,
+ valid,
+ value: newValue || ''
+ });
+ }, [onChange, value.type]);
+
+ const onTypeChange = useCallback((type: BlackListType) => {
+ if (type !== value.type) {
+ onChange({
+ type,
+ valid: false,
+ value: ''
+ });
+ }
+ }, [onChange, value.type]);
+
+ return
+
+ ('Blacklist type')}
+ onChange={onTypeChange}
+ options={options}
+ value={value.type}
+ withLabel
+ />
+
+
+ {
+ value.type === 'Website'
+ ? ('website {{index}}', { replace: { index: index + 1 } })}
+ maxLength={32}
+ onChange={onValueChange}
+ placeholder={t('https://example.com')}
+ />
+ : ('address {{index}}', { replace: { index: index + 1 } })}
+ onChange={onValueChange}
+ />
+ }
+
+ ;
+}
+
+const InitialValue: BlackListValue = { type: 'Website', valid: false, value: '' };
+
+function Add ({ className, isMember, members }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const [isVisible, toggleVisible] = useToggle();
+ const [accountId, setAccountId] = useState(null);
+ const [blacklists, setBlacklists] = useState([InitialValue]);
+
+ const _rowAdd = useCallback(
+ () => setBlacklists((_blacklists) => _blacklists.concat([InitialValue])),
+ []
+ );
+
+ const _rowRemove = useCallback(
+ () => setBlacklists((_blacklists) => _blacklists && _blacklists.slice(0, _blacklists.length - 1)),
+ []
+ );
+
+ const propose = useMemo(() => api.tx.alliance.addBlacklist(blacklists.map((blacklist) => {
+ if (blacklist.type === 'Website') {
+ return {
+ Website: api.registry.createType('Bytes', blacklist.value)
+ };
+ } else {
+ return {
+ AccountId: blacklist.value
+ };
+ }
+ })), [api.registry, api.tx.alliance, blacklists]);
+
+ const isValid = useMemo(
+ () => blacklists.every((item) => item.valid) &&
+ (new Set(blacklists.map((item) => item.value))).size === blacklists.length,
+ [blacklists]
+ );
+
+ return <>
+ ('Propose adding')}
+ onClick={toggleVisible}
+ />
+ {isVisible && (
+ ('propose adding blacklist items')}
+ onClose={toggleVisible}
+ size='large'
+ >
+
+ ('The alliance founder or fellow accounts for the proposal. The selection is filtered by the current accounts with proposing rights.')}>
+ ('Select the account you wish to submit the proposal from.')}
+ label={t('propose from account')}
+ onChange={setAccountId}
+ type='account'
+ />
+
+ {!blacklists.length
+ ? {t('No blacklist.')}
+ : blacklists.map((blacklist, index) =>
+ setBlacklists((_blacklists) => _blacklists.map((_blacklist, i) => i === index ? value : _blacklist))}
+ value={blacklist}
+ />
+ )
+ }
+
+ ('Add item')}
+ onClick={_rowAdd}
+ />
+ ('Remove item')}
+ onClick={_rowRemove}
+ />
+
+
+
+ ('Submit proposal')}
+ onStart={toggleVisible}
+ params={[propose]}
+ tx={api.tx.alliance.propose}
+ />
+
+
+ )}
+ >;
+}
+
+export default React.memo(Add);
diff --git a/packages/page-alliance/src/Blacklist/Remove.tsx b/packages/page-alliance/src/Blacklist/Remove.tsx
new file mode 100644
index 000000000000..b7309d5eb4a4
--- /dev/null
+++ b/packages/page-alliance/src/Blacklist/Remove.tsx
@@ -0,0 +1,99 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo, useState } from 'react';
+
+import { Button, InputAddress, InputAddressMulti, InputTextMulti, Modal, TxButton } from '@polkadot/react-components';
+import { useApi, useToggle } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ className?: string;
+ accountBlacklist: string[];
+ websiteBlacklist: string[];
+ isMember: boolean;
+ members: string[];
+}
+
+function Remove ({ accountBlacklist, className, isMember, members, websiteBlacklist }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const [isVisible, toggleVisible] = useToggle();
+ const [accountId, setAccountId] = useState(null);
+ const [accounts, setAccounts] = useState([]);
+ const [websites, setWebsites] = useState([]);
+
+ const proposal = useMemo(() => api.tx.alliance.removeBlacklist(
+ accounts.map((account) => ({ AccountId: account })).concat(
+ websites.map((website) => ({ Website: website }))
+ )
+ ), [accounts, api.tx.alliance, websites]);
+
+ return <>
+ ('Propose removing')}
+ onClick={toggleVisible}
+ />
+ {isVisible && (
+ ('propose removing blacklist items')}
+ onClose={toggleVisible}
+ size='large'
+ >
+
+ ('The alliance founder or fellow accounts for the proposal. The selection is filtered by the current accounts with proposing rights.')}>
+ ('Select the account you wish to submit the proposal from.')}
+ label={t('propose from account')}
+ onChange={setAccountId}
+ type='account'
+ />
+
+ {t('Accounts can be selected manually from the list of all current accounts.')}
+ }
+ >
+ ('account blacklist items')}
+ help={t('All accounts selected will be removed from blacklist, no priority.')}
+ maxCount={10}
+ onChange={setAccounts}
+ valueLabel={t('selected')}
+ />
+
+ {t('Websites can be selected manually from the list of all current websites.')}
+ }
+ >
+ ('website blacklist items')}
+ help={t('All websites selected will be removed from blacklist, no priority. ')}
+ maxCount={10}
+ onChange={setWebsites}
+ valueLabel={t('selected')}
+ />
+
+
+
+ ('Submit proposal')}
+ onStart={toggleVisible}
+ params={[proposal]}
+ tx={api.tx.alliance.propose}
+ />
+
+
+ )}
+ >;
+}
+
+export default React.memo(Remove);
diff --git a/packages/page-alliance/src/Blacklist/Summary.tsx b/packages/page-alliance/src/Blacklist/Summary.tsx
new file mode 100644
index 000000000000..b19d3104bd6c
--- /dev/null
+++ b/packages/page-alliance/src/Blacklist/Summary.tsx
@@ -0,0 +1,49 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React from 'react';
+import styled from 'styled-components';
+
+import { CardSummary, SummaryBox } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ className?: string;
+ accountBlacklist: string[];
+ websiteBlacklist: string[];
+}
+
+function Summary ({ accountBlacklist, className = '', websiteBlacklist }: Props): React.ReactElement {
+ const { t } = useTranslation();
+
+ return (
+
+
+ ('Accounts')}
+ >
+ {accountBlacklist.length}
+
+ ('Websites')}
+ >
+ {websiteBlacklist.length}
+
+
+
+ );
+}
+
+export default React.memo(styled(Summary)`
+ & section {
+ width: 100%;
+
+ .summary-card {
+ min-width: 50%;
+ justify-content: flex-start;
+ }
+ }
+`);
diff --git a/packages/page-alliance/src/Blacklist/index.tsx b/packages/page-alliance/src/Blacklist/index.tsx
new file mode 100644
index 000000000000..4e780a697eae
--- /dev/null
+++ b/packages/page-alliance/src/Blacklist/index.tsx
@@ -0,0 +1,124 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo, useState } from 'react';
+import styled from 'styled-components';
+
+import { Button, Columar, Input, Table } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+import Account from './Account';
+import Add from './Add';
+import Remove from './Remove';
+
+interface Props {
+ className?: string;
+ accountBlacklist: string[];
+ websiteBlacklist: string[];
+ isMember: boolean;
+ members: string[];
+}
+
+function getFiltered (list: string[], filter: string): string[] {
+ if (!filter) {
+ return list;
+ }
+
+ return list.filter((item) => {
+ if (item.includes(filter)) {
+ return true;
+ }
+
+ return false;
+ });
+}
+
+function Blacklist ({ accountBlacklist, className = '', isMember, members, websiteBlacklist }: Props): React.ReactElement {
+ const { t } = useTranslation();
+
+ const [accountFilter, setAccountFilter] = useState('');
+ const [websiteFilter, setWebsiteFilter] = useState('');
+
+ const accountHeader = useMemo(() => [
+ [t('Accounts')]
+ ], [t]);
+ const websiteHeader = useMemo(() => [
+ [t('Websites')]
+ ], [t]);
+
+ const _websiteBlacklist = useMemo(() => getFiltered(websiteBlacklist, websiteFilter), [websiteBlacklist, websiteFilter]);
+
+ return
+
+
+
+
+
+
+
+
+
+
+
+
+
+
;
+}
+
+export default React.memo(styled(Blacklist)`
+ tr td .website-item {
+ height: 26px;
+ line-height: 26px;
+ }
+`);
diff --git a/packages/page-alliance/src/Candidates/Candidate.tsx b/packages/page-alliance/src/Candidates/Candidate.tsx
new file mode 100644
index 000000000000..219f5d01b5e5
--- /dev/null
+++ b/packages/page-alliance/src/Candidates/Candidate.tsx
@@ -0,0 +1,56 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React from 'react';
+
+import { AddressSmall } from '@polkadot/react-components';
+import { FormatBalance } from '@polkadot/react-query';
+
+import { useDeposit } from '../useDeposit';
+import { useWebsite } from '../useWebsite';
+import Propose from './Propose';
+
+interface Props {
+ className?: string;
+ candidate: string;
+ isFavorite: boolean;
+ isMember: boolean;
+ members: string[];
+ toggleFavorite: (address: string) => void;
+}
+
+function Candidate ({ candidate, className, isMember, members }: Props): React.ReactElement {
+ const website = useWebsite(candidate);
+ const deposite = useDeposit(candidate);
+
+ return
+
+
+
+
+
+ {website}
+
+
+
+ {
+ deposite
+ ?
+ : '-'
+ }
+
+
+
+
+ ;
+}
+
+export default React.memo(Candidate);
diff --git a/packages/page-alliance/src/Candidates/Nominate.tsx b/packages/page-alliance/src/Candidates/Nominate.tsx
new file mode 100644
index 000000000000..3bb8b7d3a23b
--- /dev/null
+++ b/packages/page-alliance/src/Candidates/Nominate.tsx
@@ -0,0 +1,72 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useState } from 'react';
+
+import { Button, InputAddress, Modal, TxButton } from '@polkadot/react-components';
+import { useApi, useToggle } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ className?: string;
+ isMember: boolean;
+ members: string[];
+}
+
+function Nominate ({ className, isMember, members }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const [isVisible, toggleVisible] = useToggle();
+ const [accountId, setAccountId] = useState(null);
+ const [nominator, setNominator] = useState(null);
+
+ return <>
+ ('Nominate candidacy')}
+ onClick={toggleVisible}
+ />
+ {isVisible && (
+ ('nominate an alliance candidacy')}
+ onClose={toggleVisible}
+ size='large'
+ >
+
+ ('The alliance founder or fellow accounts for the proposal. The selection is filtered by the current accounts with proposing rights.')}>
+ ('Select the account you wish to submit the nomination from.')}
+ label={t('submit with account')}
+ onChange={setAccountId}
+ type='account'
+ />
+
+ ('This account will be nominated as a candidate without the need of deposit compared with submitting candidacy by itself.')}>
+ ('The account you wish to be nominated to candidate.')}
+ label={t('candidate account')}
+ onChange={setNominator}
+ type='account'
+ />
+
+
+
+ ('Submit proposal')}
+ onStart={toggleVisible}
+ params={[nominator]}
+ tx={api.tx.alliance.nominateCandidacy}
+ />
+
+
+ )}
+ >;
+}
+
+export default React.memo(Nominate);
diff --git a/packages/page-alliance/src/Candidates/Propose.tsx b/packages/page-alliance/src/Candidates/Propose.tsx
new file mode 100644
index 000000000000..c64f992700a9
--- /dev/null
+++ b/packages/page-alliance/src/Candidates/Propose.tsx
@@ -0,0 +1,84 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo, useState } from 'react';
+
+import { Button, Dropdown, InputAddress, Modal, TxButton } from '@polkadot/react-components';
+import { useApi, useToggle } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ className?: string;
+ candidate: string;
+ isMember: boolean;
+ members: string[];
+}
+
+function Propose ({ candidate, isMember, members }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const [isVisible, toggleVisible] = useToggle();
+ const [accountId, setAccountId] = useState(null);
+ const [allianceType, setAllianceType] = useState('accept');
+
+ const allianceTypeOpt = useMemo(() => [
+ { text: t('Acceptance proposal to alliance'), value: 'accept' },
+ { text: t('Rejection proposal to alliance'), value: 'reject' }
+ ], [t]);
+
+ const proposal = useMemo(() => {
+ return allianceType === 'reject'
+ ? api.tx.alliance.rejectCandidate(candidate)
+ : api.tx.alliance.approveCandidate(candidate);
+ }, [allianceType, api.tx.alliance, candidate]);
+
+ return <>
+ ('Propose')}
+ onClick={toggleVisible}
+ />
+ {isVisible && (
+ ('propose accepting or rejecting a candidate')}
+ onClose={toggleVisible}
+ size='large'
+ >
+
+ ('The alliance founder or fellow accounts for the proposal. The selection is filtered by the current accounts with proposing rights.')}>
+ ('Select the account you wish to submit the proposal from.')}
+ label={t('propose from account')}
+ onChange={setAccountId}
+ type='account'
+ />
+
+ ('Proposal can either be to approve or reject this candidacy. Once approved, the candidate will become an ally with a deposit remaining. Once rejected, the candidate will be removed with deposit slashed.')}>
+ ('the type of alliance proposal to submit')}
+ label={t('alliance proposal type')}
+ onChange={setAllianceType}
+ options={allianceTypeOpt}
+ value={allianceType}
+ />
+
+
+
+ ('Propose')}
+ onStart={toggleVisible}
+ params={[proposal]}
+ tx={api.tx.alliance.propose}
+ />
+
+
+ )}
+ >;
+}
+
+export default React.memo(Propose);
diff --git a/packages/page-alliance/src/Candidates/Submit.tsx b/packages/page-alliance/src/Candidates/Submit.tsx
new file mode 100644
index 000000000000..546da59be2e0
--- /dev/null
+++ b/packages/page-alliance/src/Candidates/Submit.tsx
@@ -0,0 +1,78 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useEffect, useState } from 'react';
+
+import { Button, InputAddress, InputBalance, Modal, TxButton } from '@polkadot/react-components';
+import { useAccounts, useApi, useToggle } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ className?: string;
+}
+
+function Submit ({ className }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const [isVisible, toggleVisible] = useToggle();
+ const [accountId, setAccountId] = useState(null);
+ const { allAccounts } = useAccounts();
+ const [accounts, setAccounts] = useState([]);
+
+ useEffect(() => {
+ Promise.all(allAccounts.map((account) => api.derive.accounts.info(account)))
+ .then((accountInfos) => {
+ setAccounts(allAccounts.filter((_, index) => (accountInfos[index].identity.web && accountInfos[index].identity.judgements.length > 0)));
+ })
+ .catch(console.error);
+ }, [allAccounts, api]);
+
+ return <>
+ ('Submit candidacy')}
+ onClick={toggleVisible}
+ />
+ {isVisible && (
+ ('submit your alliance candidacy')}
+ onClose={toggleVisible}
+ size='large'
+ >
+
+ ('This account will become a candidate and be responsible for the deposit. This account shouldn\'t already be a member or in the blacklist.')}>
+ ('Select the account you wish to submit for the candidate.')}
+ label={t('submit with account')}
+ onChange={setAccountId}
+ type='account'
+ />
+
+ ('The deposit will be reserved for the duration of your candidacy and membership. If the candidate is rejected or kicked out from the members in the future, the deposit will be slashed. ')}>
+ ('The bond that is reserved')}
+ isDisabled
+ label={t('candidacy deposit')}
+ />
+
+
+
+ ('Submit')}
+ onStart={toggleVisible}
+ tx={api.tx.alliance.submitCandidacy}
+ />
+
+
+ )}
+ >;
+}
+
+export default React.memo(Submit);
diff --git a/packages/page-alliance/src/Candidates/index.tsx b/packages/page-alliance/src/Candidates/index.tsx
new file mode 100644
index 000000000000..1f7c01323761
--- /dev/null
+++ b/packages/page-alliance/src/Candidates/index.tsx
@@ -0,0 +1,69 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo } from 'react';
+import styled from 'styled-components';
+
+import { Button, Table } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+import Candidate from './Candidate';
+import Nominate from './Nominate';
+import Submit from './Submit';
+
+interface Props {
+ className?: string;
+ candidates: string[];
+ favorites: string[];
+ isMember: boolean;
+ members: string[];
+ toggleFavorite: (address: string) => void;
+}
+
+function Candidates ({ candidates, className = '', favorites, isMember, members, toggleFavorite }: Props): React.ReactElement {
+ const { t } = useTranslation();
+
+ const header = useMemo(() => [
+ [t('Candidates'), 'start account'],
+ [t('Website'), 'start website'],
+ [t('Deposit'), 'start deposite'],
+ [undefined, undefined]
+ ], [t]);
+
+ return
+
+
+
+
+
('No candidates')}
+ header={header}
+ >
+ {candidates.map((candidate) => )}
+
+
;
+}
+
+export default React.memo(styled(Candidates)`
+ tr .account {
+ width: 35%;
+ }
+
+ tr .website {
+ width: 30%;
+ }
+
+ tr .deposite {
+ width: 17%;
+ }
+`);
diff --git a/packages/page-alliance/src/Members/Allies.tsx b/packages/page-alliance/src/Members/Allies.tsx
new file mode 100644
index 000000000000..6982d8ac89aa
--- /dev/null
+++ b/packages/page-alliance/src/Members/Allies.tsx
@@ -0,0 +1,61 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo } from 'react';
+import styled from 'styled-components';
+
+import { Table } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+import Ally from './Ally';
+
+interface Props {
+ className?: string
+ allies: string[]
+ favorites: string[];
+ isMember: boolean;
+ members: string[];
+ onRetire: (address: string) => void;
+ toggleFavorite: (address: string) => void;
+}
+
+function Allies ({ allies, className = '', favorites, isMember, members, onRetire, toggleFavorite }: Props): React.ReactElement {
+ const { t } = useTranslation();
+
+ const header = useMemo(() => [
+ [t('Allies'), 'start account'],
+ [t('Website'), 'start website', undefined],
+ [t('Deposit'), 'start deposit'],
+ [undefined, undefined, undefined]
+ ], [t]);
+
+ return ('No allies')}
+ header={header}
+ >
+ {allies.map((ally) => )}
+
;
+}
+
+export default React.memo(styled(Allies)`
+ tr .account {
+ width: 35%;
+ }
+
+ tr .website {
+ width: 30%;
+ }
+
+ tr .deposit {
+ width: 17%;
+ }
+`);
diff --git a/packages/page-alliance/src/Members/Ally.tsx b/packages/page-alliance/src/Members/Ally.tsx
new file mode 100644
index 000000000000..e691974f9cdd
--- /dev/null
+++ b/packages/page-alliance/src/Members/Ally.tsx
@@ -0,0 +1,125 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useCallback, useMemo } from 'react';
+
+import { AddressSmall, Menu, Popup } from '@polkadot/react-components';
+import { useAccounts, useToggle } from '@polkadot/react-hooks';
+import { FormatBalance } from '@polkadot/react-query';
+
+import { useTranslation } from '../translate';
+import { useDeposit } from '../useDeposit';
+import { useWebsite } from '../useWebsite';
+import Elevate from './Elevate';
+import Kick from './Kick';
+
+interface Props {
+ className?: string;
+ ally: string;
+ isFavorite: boolean;
+ isMember: boolean;
+ members: string[];
+ onRetire: (address: string) => void;
+ toggleFavorite: (address: string) => void;
+}
+
+function Ally ({ ally, className, isMember, members, onRetire }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const website = useWebsite(ally);
+ const [isMenuOpen, toggleMenu] = useToggle();
+ const [isKickOpen, toggleKick] = useToggle();
+ const [isElevateOpen, toggleElevate] = useToggle();
+ const { allAccounts } = useAccounts();
+ const deposite = useDeposit(ally);
+
+ const _onRetire = useCallback(() => onRetire(ally), [ally, onRetire]);
+
+ const menuItems = useMemo(() => {
+ const items = [];
+
+ if (allAccounts.includes(ally)) {
+ items.push(
+
+ {t('Retire')}
+
+ );
+ }
+
+ if (isMember) {
+ items.push(
+
+ {t('Propose kicking out')}
+ ,
+
+ {t('Propose elevating to fellow')}
+
+ );
+ }
+
+ return items;
+ }, [_onRetire, allAccounts, ally, isMember, t, toggleElevate, toggleKick]);
+
+ return <>
+
+
+
+
+ {website}
+
+
+
+ {
+ deposite
+ ?
+ : '-'
+ }
+
+
+ {
+ !!menuItems.length &&
+
+ {menuItems}
+ }
+ />
+ }
+
+
+ {
+ isKickOpen &&
+
+ }
+ {
+ isElevateOpen &&
+
+ }
+ >;
+}
+
+export default React.memo(Ally);
diff --git a/packages/page-alliance/src/Members/Elevate.tsx b/packages/page-alliance/src/Members/Elevate.tsx
new file mode 100644
index 000000000000..39aedbe61df7
--- /dev/null
+++ b/packages/page-alliance/src/Members/Elevate.tsx
@@ -0,0 +1,67 @@
+// Copyright 2017-2021 @polkadot/app-accounts authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo, useState } from 'react';
+
+import { InputAddress, Modal, TxButton } from '@polkadot/react-components';
+import { useApi } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ className?: string;
+ address: string;
+ members: string[];
+ onClose: () => void;
+}
+
+function Elevate ({ address, className, members, onClose }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const [accountId, setAccountId] = useState(null);
+
+ const proposal = useMemo(() => api.tx.alliance.elevateAlly(address), [address, api.tx.alliance]);
+
+ return (
+ ('propose elevating an ally to fellow')}
+ onClose={onClose}
+ size='large'
+ >
+
+ ('The alliance founder or fellow accounts for the proposal. The selection is filtered by the current accounts with proposing rights.')}>
+ ('Select the account you wish to submit the proposal from.')}
+ label={t('Propose from account')}
+ onChange={setAccountId}
+ type='account'
+ withLabel
+ />
+
+ ('If the motion is passed, this account will be elevated from ally to fellow, then it will have proposing and voting rights.')}>
+ ('The account you wish to be elevated to fellow')}
+ isDisabled
+ label={t('elevating account')}
+ type='allPlus'
+ />
+
+
+
+ ('Submit proposal')}
+ onStart={onClose}
+ params={[proposal]}
+ tx={api.tx.alliance.propose}
+ />
+
+ );
+}
+
+export default React.memo(Elevate);
diff --git a/packages/page-alliance/src/Members/Fellow.tsx b/packages/page-alliance/src/Members/Fellow.tsx
new file mode 100644
index 000000000000..222952e54a14
--- /dev/null
+++ b/packages/page-alliance/src/Members/Fellow.tsx
@@ -0,0 +1,106 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useCallback, useMemo } from 'react';
+
+import { AddressSmall, Menu, Popup } from '@polkadot/react-components';
+import { useAccounts, useToggle } from '@polkadot/react-hooks';
+import { FormatBalance } from '@polkadot/react-query';
+
+import { useTranslation } from '../translate';
+import { useDeposit } from '../useDeposit';
+import { useWebsite } from '../useWebsite';
+import Kick from './Kick';
+
+interface Props {
+ className?: string;
+ fellow: string;
+ isFavorite: boolean;
+ isMember: boolean;
+ members: string[];
+ onRetire: (address: string) => void;
+ toggleFavorite: (address: string) => void;
+}
+
+function Fellow ({ className, fellow, isMember, members, onRetire }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const website = useWebsite(fellow);
+ const [isMenuOpen, toggleMenu] = useToggle();
+ const [isKickOpen, toggleKick] = useToggle();
+ const { allAccounts } = useAccounts();
+ const deposite = useDeposit(fellow);
+
+ const _onRetire = useCallback(() => onRetire(fellow), [fellow, onRetire]);
+
+ const menuItems = useMemo(() => {
+ const items = [];
+
+ if (allAccounts.includes(fellow)) {
+ items.push(
+
+ {t('Retire')}
+
+ );
+ }
+
+ if (isMember) {
+ items.push(
+
+ {t('Propose kicking out')}
+
+ );
+ }
+
+ return items;
+ }, [_onRetire, allAccounts, fellow, isMember, t, toggleKick]);
+
+ return <>
+
+
+
+
+ {website}
+
+
+
+ {
+ deposite
+ ?
+ : '-'
+ }
+
+
+ {
+ !!menuItems.length &&
+
+ {menuItems}
+
+ }
+ />
+ }
+
+
+ {isKickOpen &&
+ }
+ >;
+}
+
+export default React.memo(Fellow);
diff --git a/packages/page-alliance/src/Members/Fellows.tsx b/packages/page-alliance/src/Members/Fellows.tsx
new file mode 100644
index 000000000000..861c5e8d66d8
--- /dev/null
+++ b/packages/page-alliance/src/Members/Fellows.tsx
@@ -0,0 +1,61 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo } from 'react';
+import styled from 'styled-components';
+
+import { Table } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+import Fellow from './Fellow';
+
+interface Props {
+ className?: string
+ fellows: string[]
+ favorites: string[];
+ isMember: boolean;
+ members: string[];
+ onRetire: (address: string) => void;
+ toggleFavorite: (address: string) => void;
+}
+
+function Fellows ({ className = '', favorites, fellows, isMember, members, onRetire, toggleFavorite }: Props): React.ReactElement {
+ const { t } = useTranslation();
+
+ const header = useMemo(() => [
+ [t('Fellows'), 'start account', 1],
+ [t('Website'), 'start website', undefined],
+ [t('Deposit'), 'start deposit'],
+ [undefined, undefined, undefined]
+ ], [t]);
+
+ return ('No fellows')}
+ header={header}
+ >
+ {fellows.map((fellow) => )}
+
;
+}
+
+export default React.memo(styled(Fellows)`
+ tr .account {
+ width: 35%;
+ }
+
+ tr .website {
+ width: 30%;
+ }
+
+ tr .deposit {
+ width: 17%;
+ }
+`);
diff --git a/packages/page-alliance/src/Members/Founder.tsx b/packages/page-alliance/src/Members/Founder.tsx
new file mode 100644
index 000000000000..0bcad85294ce
--- /dev/null
+++ b/packages/page-alliance/src/Members/Founder.tsx
@@ -0,0 +1,106 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useCallback, useMemo } from 'react';
+
+import { AddressSmall, Menu, Popup } from '@polkadot/react-components';
+import { useAccounts, useToggle } from '@polkadot/react-hooks';
+import { FormatBalance } from '@polkadot/react-query';
+
+import { useTranslation } from '../translate';
+import { useDeposit } from '../useDeposit';
+import { useWebsite } from '../useWebsite';
+import Kick from './Kick';
+
+interface Props {
+ className?: string;
+ founder: string;
+ isFavorite: boolean;
+ isMember: boolean;
+ members: string[];
+ onRetire: (address: string) => void;
+ toggleFavorite: (address: string) => void;
+}
+
+function Founder ({ className, founder, isMember, members, onRetire }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const website = useWebsite(founder);
+ const [isMenuOpen, toggleMenu] = useToggle();
+ const [isKickOpen, toggleKick] = useToggle();
+ const { allAccounts } = useAccounts();
+ const deposite = useDeposit(founder);
+
+ const _onRetire = useCallback(() => onRetire(founder), [founder, onRetire]);
+
+ const menuItems = useMemo(() => {
+ const items = [];
+
+ if (allAccounts.includes(founder)) {
+ items.push(
+
+ {t('Retire')}
+
+ );
+ }
+
+ if (isMember) {
+ items.push(
+
+ {t('Propose kicking out')}
+
+ );
+ }
+
+ return items;
+ }, [_onRetire, allAccounts, founder, isMember, t, toggleKick]);
+
+ return <>
+
+
+
+
+ {website}
+
+
+
+ {
+ deposite
+ ?
+ : '-'
+ }
+
+
+ {
+ !!menuItems.length &&
+
+ {menuItems}
+
+ }
+ />
+ }
+
+
+ {isKickOpen &&
+ }
+ >;
+}
+
+export default React.memo(Founder);
diff --git a/packages/page-alliance/src/Members/Founders.tsx b/packages/page-alliance/src/Members/Founders.tsx
new file mode 100644
index 000000000000..8d68830cb784
--- /dev/null
+++ b/packages/page-alliance/src/Members/Founders.tsx
@@ -0,0 +1,61 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo } from 'react';
+import styled from 'styled-components';
+
+import { Table } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+import Founder from './Founder';
+
+interface Props {
+ className?: string
+ founders: string[]
+ favorites: string[];
+ isMember: boolean;
+ members: string[];
+ onRetire: (address: string) => void;
+ toggleFavorite: (address: string) => void;
+}
+
+function Founders ({ className = '', favorites, founders, isMember, members, onRetire, toggleFavorite }: Props): React.ReactElement {
+ const { t } = useTranslation();
+
+ const header = useMemo(() => [
+ [t('Founders'), 'start account'],
+ [t('Website'), 'start website', undefined],
+ [t('Deposit'), 'start deposit'],
+ [undefined, undefined, undefined]
+ ], [t]);
+
+ return ('No founders')}
+ header={header}
+ >
+ {founders.map((founder) => )}
+
;
+}
+
+export default React.memo(styled(Founders)`
+ tr .account {
+ width: 35%;
+ }
+
+ tr .website {
+ width: 30%;
+ }
+
+ tr .deposit {
+ width: 17%;
+ }
+`);
diff --git a/packages/page-alliance/src/Members/Kick.tsx b/packages/page-alliance/src/Members/Kick.tsx
new file mode 100644
index 000000000000..d8d58391fbc9
--- /dev/null
+++ b/packages/page-alliance/src/Members/Kick.tsx
@@ -0,0 +1,67 @@
+// Copyright 2017-2021 @polkadot/app-accounts authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo, useState } from 'react';
+
+import { InputAddress, Modal, TxButton } from '@polkadot/react-components';
+import { useApi } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ className?: string;
+ address: string;
+ members: string[];
+ onClose: () => void;
+}
+
+function Kick ({ address, className, members, onClose }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const [accountId, setAccountId] = useState(null);
+
+ const proposal = useMemo(() => api.tx.alliance.kickMember(address), [address, api.tx.alliance]);
+
+ return (
+ ('propose kicking out a member')}
+ onClose={onClose}
+ size='large'
+ >
+
+ ('The alliance founder or fellow accounts for the proposal. The selection is filtered by the current accounts with proposing rights.')}>
+ ('Select the account you wish to submit the proposal from.')}
+ label={t('Propose from account')}
+ onChange={setAccountId}
+ type='account'
+ withLabel
+ />
+
+ ('If the motion is passed, this account will be kicked out and if it has deposit, the deposit will be slashed. During the motion, the account can\'t retire.')}>
+ ('The account whom you wish to kick out')}
+ isDisabled
+ label={t('kicking account')}
+ type='allPlus'
+ />
+
+
+
+ ('Submit proposal')}
+ onStart={onClose}
+ params={[proposal]}
+ tx={api.tx.alliance.propose}
+ />
+
+ );
+}
+
+export default React.memo(Kick);
diff --git a/packages/page-alliance/src/Members/Rule.tsx b/packages/page-alliance/src/Members/Rule.tsx
new file mode 100644
index 000000000000..2f44f610adfc
--- /dev/null
+++ b/packages/page-alliance/src/Members/Rule.tsx
@@ -0,0 +1,74 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo, useState } from 'react';
+
+import { Input, InputAddress, Modal, TxButton } from '@polkadot/react-components';
+import { useApi } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+import { useCidDecode } from '../useCid';
+
+interface Props {
+ className?: string
+ isMember: boolean;
+ members: string[];
+ onClose: () => void;
+}
+
+function Rule ({ members, onClose }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const [accountId, setAccountId] = useState(null);
+ const [rule, setRule] = useState(null);
+ const { api } = useApi();
+
+ const ruleEncode = useCidDecode(rule);
+
+ const propose = useMemo(() => {
+ if (!ruleEncode || !accountId) {
+ return null;
+ }
+
+ return api.tx.alliance.setRule(ruleEncode);
+ }, [accountId, api.tx.alliance, ruleEncode]);
+
+ return (
+ ('propose setting the Alliance rule')}
+ onClose={onClose}
+ size='large'
+ >
+
+ ('The alliance founder or fellow accounts for the proposal. The selection is filtered by the current accounts with proposing rights.')}>
+ ('Select the account you wish to submit the proposal from.')}
+ label={t('Propose from account')}
+ onChange={setAccountId}
+ type='account'
+ />
+
+ ('The IPFS hash of the new rule. better be formatted in a single Markdown document.')}>
+ ('IPFS hash')}
+ isError={!ruleEncode}
+ label={t('IPFS hash')}
+ onChange={setRule}
+ />
+
+
+
+ ('Submit proposal')}
+ onStart={onClose}
+ params={[propose]}
+ tx={api.tx.alliance.propose}
+ />
+
+
+ );
+}
+
+export default React.memo(Rule);
diff --git a/packages/page-alliance/src/Members/Rules.tsx b/packages/page-alliance/src/Members/Rules.tsx
new file mode 100644
index 000000000000..88287eba8347
--- /dev/null
+++ b/packages/page-alliance/src/Members/Rules.tsx
@@ -0,0 +1,103 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useMemo } from 'react';
+
+import { ExpanderMarkdown, Menu, Popup, Spinner, Table } from '@polkadot/react-components';
+import { useToggle } from '@polkadot/react-hooks';
+
+import { IPFS_GATEWAY } from '../constants';
+import { useTranslation } from '../translate';
+import { useContent } from '../useContent';
+import Rule from './Rule';
+
+interface Props {
+ className?: string;
+ rule: string | null;
+ isMember: boolean;
+ members: string[];
+}
+
+function Rules ({ className, isMember, members, rule }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const [isMenuOpen, toggleMenu] = useToggle();
+ const [isSetRuleOpen, toggleSetRule] = useToggle();
+
+ const { content, fetching } = useContent(rule);
+
+ const header = useMemo(() => [
+ [t('Alliance rule')],
+ [t('Content'), 'start'],
+ []
+ ], [t]);
+
+ const menuItems = useMemo(() => {
+ const items = [];
+
+ if (isMember) {
+ items.push(
+
+ {t('Propose setting rule')}
+
+ );
+ }
+
+ return items;
+ }, [isMember, t, toggleSetRule]);
+
+ return (
+ ('No rule')}
+ header={header}
+ >
+
+
+ {rule
+ ?
+ /ipfs/{rule}
+
+ : '-'}
+
+
+ {fetching
+ ?
+ : content
+ ?
+ : '-'}
+
+
+ {
+ !!menuItems.length &&
+
+ {menuItems}
+
+ }
+ />
+ }
+
+
+ {
+ isSetRuleOpen &&
+
+ }
+
+ );
+}
+
+export default React.memo(Rules);
diff --git a/packages/page-alliance/src/Members/Summary.tsx b/packages/page-alliance/src/Members/Summary.tsx
new file mode 100644
index 000000000000..77ca25d00fc6
--- /dev/null
+++ b/packages/page-alliance/src/Members/Summary.tsx
@@ -0,0 +1,44 @@
+// Copyright 2017-2021 @polkadot/app-explorer authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React from 'react';
+import styled from 'styled-components';
+
+import { CardSummary, SummaryBox } from '@polkadot/react-components';
+import { formatNumber } from '@polkadot/util';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ allies: number;
+ className?: string;
+ founders: number;
+ fellows: number;
+}
+
+function Summary ({ allies, className = '', fellows, founders }: Props): React.ReactElement | null {
+ const { t } = useTranslation();
+
+ return (
+
+
+ ('founders')}>
+ {formatNumber(founders)}
+
+ ('fellows')}>
+ {formatNumber(fellows)}
+
+ ('allies')}>
+ {formatNumber(allies)}
+
+
+
+ );
+}
+
+export default React.memo(styled(Summary)`
+ & > .section-main {
+ width: 58%;
+ justify-content: space-between;
+ }
+`);
diff --git a/packages/page-alliance/src/Members/index.tsx b/packages/page-alliance/src/Members/index.tsx
new file mode 100644
index 000000000000..3d96fcfbb496
--- /dev/null
+++ b/packages/page-alliance/src/Members/index.tsx
@@ -0,0 +1,93 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { SubmittableExtrinsic } from '@polkadot/api/types';
+
+import React, { useCallback, useContext } from 'react';
+import styled from 'styled-components';
+
+import { StatusContext } from '@polkadot/react-components';
+import { useApi } from '@polkadot/react-hooks';
+
+import Allies from './Allies';
+import Fellows from './Fellows';
+import Founders from './Founders';
+import Rules from './Rules';
+import Summary from './Summary';
+
+interface Props {
+ className?: string;
+ allies: string[];
+ fellows: string[];
+ founders: string[];
+ isMember: boolean;
+ members: string[];
+ rule: string | null;
+ favorites: string[]
+ toggleFavorite: (address: string) => void;
+}
+
+function Members ({ allies, className = '', favorites, fellows, founders, isMember, members, rule, toggleFavorite }: Props): React.ReactElement {
+ const { api } = useApi();
+ const { queueExtrinsic } = useContext(StatusContext);
+
+ const onRetire = useCallback((accountId: string) => {
+ const extrinsic: SubmittableExtrinsic<'promise'> = api.tx.alliance.retire();
+
+ queueExtrinsic({
+ accountId,
+ extrinsic
+ });
+ }, [api.tx.alliance, queueExtrinsic]);
+
+ return (
+
+ );
+}
+
+const StyledMembers: React.FC = styled(Members)`
+ .ui--AllianceMember-table table tr > td:nth-of-type(1) {
+ width: 35%;
+ }
+`;
+
+export default React.memo(StyledMembers);
diff --git a/packages/page-alliance/src/Motions/Close.tsx b/packages/page-alliance/src/Motions/Close.tsx
new file mode 100644
index 000000000000..6db674873895
--- /dev/null
+++ b/packages/page-alliance/src/Motions/Close.tsx
@@ -0,0 +1,76 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { Hash, Proposal, ProposalIndex } from '@polkadot/types/interfaces';
+
+import React, { useState } from 'react';
+
+import { Button, InputAddress, Modal, ProposedAction, TxButton } from '@polkadot/react-components';
+import { useApi, useToggle, useWeight } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ hash: Hash;
+ idNumber: ProposalIndex;
+ members: string[];
+ proposal: Proposal;
+}
+
+function Close ({ hash, idNumber, members, proposal }: Props): React.ReactElement | null {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const [isOpen, toggleOpen] = useToggle();
+ const [accountId, setAccountId] = useState(null);
+ const [proposalWeight, proposalLength] = useWeight(proposal);
+
+ // protect against older versions
+ if (!api.tx.alliance.close) {
+ return null;
+ }
+
+ return (
+ <>
+ {isOpen && (
+ ('close the proposal')}
+ onClose={toggleOpen}
+ size='large'
+ >
+
+ ('The proposal that will be affected. Once closed for the current voting round, it would need to be re-submitted to the alliance for a subsequent voting round.')}>
+
+
+ (' The alliance founder or fellow account that will apply the close for the current round.')}>
+ ('Select the account you wish to close the proposal with.')}
+ label={t('close with account')}
+ onChange={setAccountId}
+ type='account'
+ />
+
+
+
+
+
+
+ )}
+ ('Close')}
+ onClick={toggleOpen}
+ />
+ >
+ );
+}
+
+export default React.memo(Close);
diff --git a/packages/page-alliance/src/Motions/Motion.tsx b/packages/page-alliance/src/Motions/Motion.tsx
new file mode 100644
index 000000000000..9645851361ac
--- /dev/null
+++ b/packages/page-alliance/src/Motions/Motion.tsx
@@ -0,0 +1,191 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
+
+import React, { useMemo } from 'react';
+
+import ProposalCell from '@polkadot/app-democracy/Overview/ProposalCell';
+import { Icon, Menu, Popup, TxButton } from '@polkadot/react-components';
+import { useAccounts, useApi, useToggle, useVotingStatus, useWeight } from '@polkadot/react-hooks';
+import { BlockToTime } from '@polkadot/react-query';
+import { formatNumber } from '@polkadot/util';
+
+import { useTranslation } from '../translate';
+import Close from './Close';
+import Veto from './Veto';
+import Voters from './Voters';
+import Voting from './Voting';
+
+interface Props {
+ className?: string;
+ isMember: boolean;
+ isFounder: boolean;
+ founders: string[];
+ members: string[];
+ motion: DeriveCollectiveProposal;
+}
+
+interface VoterState {
+ hasVoted: boolean;
+ hasVotedAye: boolean;
+}
+
+function Motion ({ className = '', founders, isFounder, isMember, members, motion: { hash, proposal, votes } }: Props): React.ReactElement | null {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const { allAccounts } = useAccounts();
+ const [isMenuOpen, toggleMenu] = useToggle();
+ const [isVetoOpen, toggleVeto] = useToggle();
+ const { isCloseable, isVoteable, remainingBlocks } = useVotingStatus(votes, members.length, 'alliance');
+ const [proposalWeight, proposalLength] = useWeight(proposal);
+
+ const menuItems = useMemo(() => {
+ const items = [];
+
+ if (isFounder &&
+ proposal.section.toLowerCase() === 'alliance' &&
+ (proposal.method.toLowerCase() === 'elevateally' || proposal.method.toLowerCase() === 'setrule')
+ ) {
+ items.push(
+
+ {t('Veto')}
+
+ );
+ }
+
+ return items;
+ }, [isFounder, t, toggleVeto, proposal]);
+
+ const [memberId, isMultiMembers] = useMemo(
+ (): [string | null, boolean] => {
+ const memberIds = allAccounts.filter((accountId) => members.includes(accountId));
+
+ return [memberIds[0] || null, memberIds.length > 1];
+ },
+ [allAccounts, members]
+ );
+
+ const { hasVoted, hasVotedAye } = useMemo(
+ (): VoterState => {
+ if (votes) {
+ const hasVotedAye = allAccounts.some((address) => votes.ayes.some((accountId) => accountId.eq(address)));
+
+ return {
+ hasVoted: hasVotedAye || allAccounts.some((address) => votes.nays.some((accountId) => accountId.eq(address))),
+ hasVotedAye
+ };
+ }
+
+ return { hasVoted: false, hasVotedAye: false };
+ },
+ [allAccounts, votes]
+ );
+
+ if (!votes) {
+ return null;
+ }
+
+ const { ayes, end, index, nays, threshold } = votes;
+
+ return (
+
+ {formatNumber(index)}
+
+
+ {formatNumber(threshold)}
+
+
+ {remainingBlocks && end && (
+ <>
+
+ #{formatNumber(end)}
+ >
+ )}
+
+
+
+
+
+
+ {isVoteable && !isCloseable && (
+
+ )}
+ {isCloseable && (
+ isMultiMembers
+ ? (
+
+ )
+ : (
+ ('Close')}
+ params={[hash, index, proposalWeight, proposalLength]}
+ tx={api.tx.alliance.close}
+ />
+ )
+ )}
+
+
+ {isMember && (
+
+ )}
+
+
+ {
+ !!menuItems.length &&
+
+ {menuItems}
+
+ }
+ />
+ }
+
+ {
+ isVetoOpen &&
+
+ }
+
+ );
+}
+
+export default React.memo(Motion);
diff --git a/packages/page-alliance/src/Motions/Veto.tsx b/packages/page-alliance/src/Motions/Veto.tsx
new file mode 100644
index 000000000000..544a9b1d917b
--- /dev/null
+++ b/packages/page-alliance/src/Motions/Veto.tsx
@@ -0,0 +1,64 @@
+// Copyright 2017-2021 @polkadot/app-accounts authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { Proposal, ProposalIndex } from '@polkadot/types/interfaces';
+
+import React, { useState } from 'react';
+
+import { InputAddress, Modal, ProposedAction, TxButton } from '@polkadot/react-components';
+import { useApi } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ className?: string;
+ proposal: Proposal;
+ founders: string[];
+ idNumber: ProposalIndex;
+ onClose: () => void;
+}
+
+function Veto ({ className = '', founders, idNumber, onClose, proposal }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const [accountId, setAccountId] = useState(null);
+
+ return ('veto the proposal')}
+ onClose={onClose}
+ size='large'
+ >
+
+ ('The proposal that will be vetoed. Once vetoed for the current voting round, it would need to be re-submitted to the alliance for a subsequent voting round.')}>
+
+
+ ('The alliance founder account that will veto the proposal for the current round.')}>
+ ('Select the account you wish to veto the proposal with.')}
+ label={t('veto with account')}
+ onChange={setAccountId}
+ type='account'
+ withLabel
+ />
+
+
+
+ ('Veto')}
+ onStart={onClose}
+ params={[proposal.hash]}
+ tx={api.tx.alliance.veto}
+ />
+
+ ;
+}
+
+export default React.memo(Veto);
diff --git a/packages/page-alliance/src/Motions/Voters.tsx b/packages/page-alliance/src/Motions/Voters.tsx
new file mode 100644
index 000000000000..e54aa69661f1
--- /dev/null
+++ b/packages/page-alliance/src/Motions/Voters.tsx
@@ -0,0 +1,57 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { AccountId, MemberCount } from '@polkadot/types/interfaces';
+
+import React, { useMemo } from 'react';
+
+import { AddressMini, Expander } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ isAye?: boolean;
+ members: string[];
+ votes: AccountId[];
+ threshold: MemberCount;
+}
+
+function Voters ({ isAye, members, threshold, votes }: Props): React.ReactElement | null {
+ const { t } = useTranslation();
+
+ const count = useMemo(
+ (): string => {
+ const num = threshold.toNumber();
+ const max = isAye
+ ? num
+ : (members.length - num + 1);
+
+ return `${votes.length}${max ? `/${max}` : ''}`;
+ },
+ [isAye, members, threshold, votes]
+ );
+
+ if (!count || !votes.length) {
+ return null;
+ }
+
+ return (
+ ('Aye {{count}}', { replace: { count } })
+ : t('Nay {{count}}', { replace: { count } })
+ }
+ >
+ {votes.map((address): React.ReactNode => (
+
+ ))}
+
+ );
+}
+
+export default React.memo(Voters);
diff --git a/packages/page-alliance/src/Motions/Voting.tsx b/packages/page-alliance/src/Motions/Voting.tsx
new file mode 100644
index 000000000000..882a1782382a
--- /dev/null
+++ b/packages/page-alliance/src/Motions/Voting.tsx
@@ -0,0 +1,86 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { Hash, Proposal, ProposalIndex } from '@polkadot/types/interfaces';
+
+import React, { useState } from 'react';
+
+import { Button, Modal, ProposedAction, TxButton, VoteAccount } from '@polkadot/react-components';
+import { useAccounts, useApi, useToggle } from '@polkadot/react-hooks';
+
+import { useTranslation } from '../translate';
+
+interface Props {
+ hash: Hash;
+ idNumber: ProposalIndex;
+ isDisabled: boolean;
+ members: string[];
+ proposal: Proposal;
+}
+
+function Voting ({ hash, idNumber, isDisabled, members, proposal }: Props): React.ReactElement | null {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const { hasAccounts } = useAccounts();
+ const [isVotingOpen, toggleVoting] = useToggle();
+ const [accountId, setAccountId] = useState(null);
+
+ if (!hasAccounts) {
+ return null;
+ }
+
+ return (
+ <>
+ {isVotingOpen && (
+ ('vote on proposal')}
+ onClose={toggleVoting}
+ size='large'
+ >
+
+ ('The proposal that is being voted on. It will be passed when the threshold is reached.')}>
+
+
+ ('The alliance founder or fellow accounts for this vote. The selection is filtered by the current accounts with proposing rights.')}>
+
+
+
+
+ ('Vote Nay')}
+ onStart={toggleVoting}
+ params={[hash, idNumber, false]}
+ tx={api.tx.alliance.vote}
+ />
+ ('Vote Aye')}
+ onStart={toggleVoting}
+ params={[hash, idNumber, true]}
+ tx={api.tx.alliance.vote}
+ />
+
+
+ )}
+ ('Vote')}
+ onClick={toggleVoting}
+ />
+ >
+ );
+}
+
+export default React.memo(Voting);
diff --git a/packages/page-alliance/src/Motions/index.tsx b/packages/page-alliance/src/Motions/index.tsx
new file mode 100644
index 000000000000..79909af81493
--- /dev/null
+++ b/packages/page-alliance/src/Motions/index.tsx
@@ -0,0 +1,55 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
+
+import React, { useMemo } from 'react';
+
+import { Table } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+import { useMembers } from '../useMembers';
+import Motion from './Motion';
+
+interface Props {
+ className?: string;
+ isMember: boolean;
+ members: string[];
+ motions?: DeriveCollectiveProposal[];
+}
+
+function Motions ({ className, isMember, members, motions: motionsSource }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { founders, isFounder } = useMembers();
+
+ const motions = useMemo(() => [...(motionsSource || [])].reverse(), [motionsSource]);
+
+ const header = useMemo(() => [
+ [t('motions'), 'start', 2],
+ [t('threshold')],
+ [t('voting end')],
+ [t('votes')],
+ [undefined, undefined],
+ [],
+ [undefined, undefined, undefined]
+ ], [t]);
+
+ return ('No motions')}
+ header={header}
+ >
+ {motions?.map((motion: DeriveCollectiveProposal): React.ReactNode => (
+
+ ))}
+
;
+}
+
+export default React.memo(Motions);
diff --git a/packages/page-alliance/src/constants.ts b/packages/page-alliance/src/constants.ts
new file mode 100644
index 000000000000..845657d0cd62
--- /dev/null
+++ b/packages/page-alliance/src/constants.ts
@@ -0,0 +1,7 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+export const STORE_FAVS_BASE = 'alliance:favorites';
+
+// TODO ipfs gateway may be set in setting
+export const IPFS_GATEWAY = 'https://ipfs.io';
diff --git a/packages/page-alliance/src/index.tsx b/packages/page-alliance/src/index.tsx
new file mode 100644
index 000000000000..4a421c7327bd
--- /dev/null
+++ b/packages/page-alliance/src/index.tsx
@@ -0,0 +1,139 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
+import type { Option, Vec } from '@polkadot/types';
+import type { AccountId, Cid, Url } from '@polkadot/types/interfaces';
+
+import React, { useMemo } from 'react';
+import { Route, Switch } from 'react-router';
+
+import { Tabs } from '@polkadot/react-components';
+import { useApi, useCall, useFavorites } from '@polkadot/react-hooks';
+
+import Announcements from './Announcements';
+import Blacklist from './Blacklist';
+import Candidates from './Candidates';
+import { STORE_FAVS_BASE } from './constants';
+import Members from './Members';
+import Motions from './Motions';
+import { useTranslation } from './translate';
+import { useCidEncode } from './useCid';
+import useCounter from './useCounter';
+import { useMembers } from './useMembers';
+
+export { useCounter };
+
+interface Props {
+ basePath: string;
+ className?: string;
+}
+
+function AllianceApp ({ basePath, className }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const { api } = useApi();
+ const { allies, count: memberCount, fellows, founders, isMember } = useMembers();
+ const motions = useCall(api.derive.alliance.proposals);
+ const counter = useCounter();
+ const accountBlacklist = useCall>(api.query.alliance.accountBlacklist);
+ const websiteBlacklist = useCall>(api.query.alliance.websiteBlacklist);
+ const rule = useCall>(api.query.alliance.rule);
+ const ruleEncode = useCidEncode(rule?.unwrapOrDefault());
+ const candidates = useCall>(api.query.alliance.candidates);
+ const announcements = useCall>(api.query.alliance.announcements);
+ const members = useMemo((): string[] => {
+ return founders.concat(fellows);
+ }, [fellows, founders]);
+ const [favorites, toggleFavorite] = useFavorites(STORE_FAVS_BASE);
+
+ const items = useMemo(() => [{
+ isRoot: true,
+ name: 'members',
+ text: t('Members ({{count}})', {
+ replace: {
+ count: memberCount
+ }
+ })
+ }, {
+ count: counter,
+ name: 'motions',
+ text: t('Motions')
+ }, {
+ name: 'announcements',
+ text: t('Announcements ({{count}})', {
+ replace: {
+ count: announcements?.length || 0
+ }
+ })
+ }, {
+ name: 'candidates',
+ text: t('Candidates ({{count}})', {
+ replace: {
+ count: candidates?.length || 0
+ }
+ })
+ }, {
+ name: 'blacklist',
+ text: t('Blacklist ({{count}})', {
+ replace: {
+ count: (websiteBlacklist?.length || 0) + (accountBlacklist?.length || 0)
+ }
+ })
+ }], [accountBlacklist?.length, announcements?.length, candidates?.length, counter, memberCount, t, websiteBlacklist?.length]);
+
+ return (
+
+
+
+
+ account.toString()) || []}
+ isMember={isMember}
+ members={members}
+ websiteBlacklist={websiteBlacklist?.map((website) => website.toHuman() as string) || []}
+ />
+
+
+ candidate.toString()) || []}
+ favorites={favorites}
+ isMember={isMember}
+ members={members}
+ toggleFavorite={toggleFavorite}
+ />
+
+
+ announcement) || []}
+ isMember={isMember}
+ members={members}
+ />
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default React.memo(AllianceApp);
diff --git a/packages/page-alliance/src/translate.ts b/packages/page-alliance/src/translate.ts
new file mode 100644
index 000000000000..5b76773137d5
--- /dev/null
+++ b/packages/page-alliance/src/translate.ts
@@ -0,0 +1,10 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { UseTranslationResponse } from 'react-i18next';
+
+import { useTranslation as useTranslationBase } from 'react-i18next';
+
+export function useTranslation (): UseTranslationResponse<'app-alliance'> {
+ return useTranslationBase('app-alliance');
+}
diff --git a/packages/page-alliance/src/useCid.ts b/packages/page-alliance/src/useCid.ts
new file mode 100644
index 000000000000..d8dfa82015c5
--- /dev/null
+++ b/packages/page-alliance/src/useCid.ts
@@ -0,0 +1,58 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { Cid } from '@polkadot/types/interfaces';
+import type { Registry } from '@polkadot/types/types';
+
+import CID from 'cids';
+import { useMemo } from 'react';
+
+import { useApi } from '@polkadot/react-hooks';
+import { u8aConcat } from '@polkadot/util';
+
+function createCid (registry: Registry, cidStr: string): Cid | null {
+ try {
+ const _cid = new CID(cidStr);
+
+ return registry.createType('Cid', {
+ codec: registry.createType('u64', _cid.code),
+ multihash: registry.createType(
+ 'CidMultihash',
+ u8aConcat(
+ registry.createType('u64', _cid.multihash.slice(0, 1)).toU8a(),
+ registry.createType('u8', _cid.multihash.slice(1, 2)).toU8a(),
+ _cid.multihash.slice(2)
+ )
+ ),
+ version: registry.createType('CidVersion', _cid.version)
+ });
+ } catch (error: any) {
+ return null;
+ }
+}
+
+export function useCidEncode (cid?: Cid | null): string | null {
+ if (!cid || cid.isEmpty) {
+ return null;
+ }
+
+ const cidStr = new CID(
+ cid.version.isV0 ? 0 : 1,
+ cid.codec.toNumber(),
+ cid.multihash.toMultihash()
+ );
+
+ return cidStr.toString();
+}
+
+export function useCidDecode (cidStr?: string | null): Cid | null {
+ const { api } = useApi();
+
+ return useMemo((): Cid | null => {
+ if (!cidStr) {
+ return null;
+ }
+
+ return createCid(api.registry, cidStr);
+ }, [api.registry, cidStr]);
+}
diff --git a/packages/page-alliance/src/useContent.ts b/packages/page-alliance/src/useContent.ts
new file mode 100644
index 000000000000..59121d1eb743
--- /dev/null
+++ b/packages/page-alliance/src/useContent.ts
@@ -0,0 +1,46 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import { useEffect, useState } from 'react';
+
+import { IPFS_GATEWAY } from './constants';
+
+interface UseContent {
+ content: string | null;
+ fetching: boolean;
+}
+
+async function fetchData (url: string): Promise {
+ const text = await Promise.race([
+ fetch(url)
+ .then((response) => {
+ if (response.headers.get('content-type')?.includes('text')) {
+ return response.text();
+ } else {
+ return null;
+ }
+ })
+ .catch((e) => console.error(e)),
+ new Promise((resolve) => setTimeout(() => resolve(null), 10000))
+ ]);
+
+ return text ?? null;
+}
+
+export function useContent (cid: string | null): UseContent {
+ const [content, setContent] = useState(null);
+ const [fetching, setFetching] = useState(false);
+
+ useEffect((): void => {
+ if (cid) {
+ setFetching(true);
+
+ fetchData(`${IPFS_GATEWAY}/ipfs/${cid}`).then(setContent).catch(console.error).finally(() => setFetching(false));
+ }
+ }, [cid]);
+
+ return {
+ content,
+ fetching
+ };
+}
diff --git a/packages/page-alliance/src/useCounter.ts b/packages/page-alliance/src/useCounter.ts
new file mode 100644
index 000000000000..8b7dfa0fce6d
--- /dev/null
+++ b/packages/page-alliance/src/useCounter.ts
@@ -0,0 +1,18 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
+
+import { useAccounts, useApi, useCall } from '@polkadot/react-hooks';
+
+const transformCounter = {
+ transform: (motions: DeriveCollectiveProposal[]) => motions.filter(({ votes }): boolean => !!votes).length
+};
+
+export default function useCounter (): number {
+ const { hasAccounts } = useAccounts();
+ const { api, isApiReady } = useApi();
+ const counter = useCall(isApiReady && hasAccounts && api.derive.alliance?.proposals, undefined, transformCounter) || 0;
+
+ return counter;
+}
diff --git a/packages/page-alliance/src/useDeposit.ts b/packages/page-alliance/src/useDeposit.ts
new file mode 100644
index 000000000000..a58609b34015
--- /dev/null
+++ b/packages/page-alliance/src/useDeposit.ts
@@ -0,0 +1,19 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { Option } from '@polkadot/types/codec';
+import type { AccountId } from '@polkadot/types/interfaces';
+
+import { useApi, useCall } from '@polkadot/react-hooks';
+import { Balance } from '@polkadot/types/interfaces';
+
+export function useDeposit (accountId: AccountId | string): Balance | undefined {
+ const { api } = useApi();
+ const balance = useCall>(api.query.alliance.depositOf, [accountId]);
+
+ if (!balance || balance.isEmpty) {
+ return;
+ }
+
+ return balance.unwrap();
+}
diff --git a/packages/page-alliance/src/useMembers.ts b/packages/page-alliance/src/useMembers.ts
new file mode 100644
index 000000000000..ec5af8609e63
--- /dev/null
+++ b/packages/page-alliance/src/useMembers.ts
@@ -0,0 +1,40 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { AccountId } from '@polkadot/types/interfaces';
+
+import { useMemo } from 'react';
+
+import { useAccounts, useApi, useCall } from '@polkadot/react-hooks';
+
+interface Result {
+ allies: string[];
+ count: number;
+ fellows: string[];
+ founders: string[];
+ isMember: boolean;
+ isFellow: boolean;
+ isFounder: boolean;
+}
+
+const transformMembers = {
+ transform: (accounts: AccountId[]) => accounts.map((accountId) => accountId.toString())
+};
+
+export function useMembers (): Result {
+ const { api } = useApi();
+ const { allAccounts, hasAccounts } = useAccounts();
+ const founders = useCall(hasAccounts && api.query.alliance.members, ['Founder'], transformMembers);
+ const fellows = useCall(hasAccounts && api.query.alliance.members, ['Fellow'], transformMembers);
+ const allies = useCall(hasAccounts && api.query.alliance.members, ['Ally'], transformMembers);
+
+ return useMemo(() => ({
+ allies: allies || [],
+ count: (founders?.length || 0) + (fellows?.length || 0) + (allies?.length || 0),
+ fellows: fellows || [],
+ founders: founders || [],
+ isFellow: (fellows || []).some((accountId) => allAccounts.includes(accountId)),
+ isFounder: (founders || []).some((accountId) => allAccounts.includes(accountId)),
+ isMember: (founders || []).concat(fellows || []).some((accountId) => allAccounts.includes(accountId))
+ }), [allAccounts, allies, fellows, founders]);
+}
diff --git a/packages/page-alliance/src/useWebsite.ts b/packages/page-alliance/src/useWebsite.ts
new file mode 100644
index 000000000000..70bb270a05c8
--- /dev/null
+++ b/packages/page-alliance/src/useWebsite.ts
@@ -0,0 +1,14 @@
+// Copyright 2017-2021 @polkadot/app-alliance authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { DeriveAccountRegistration } from '@polkadot/api-derive/types';
+import type { AccountId } from '@polkadot/types/interfaces';
+
+import { useApi, useCall } from '@polkadot/react-hooks';
+
+export function useWebsite (accountId: AccountId | string): string {
+ const { api } = useApi();
+ const identity = useCall(api.derive.accounts.identity, [accountId]);
+
+ return identity?.web ?? '';
+}
diff --git a/packages/react-components/src/ExpanderMarkdown.tsx b/packages/react-components/src/ExpanderMarkdown.tsx
new file mode 100644
index 000000000000..353eece3bd68
--- /dev/null
+++ b/packages/react-components/src/ExpanderMarkdown.tsx
@@ -0,0 +1,33 @@
+// Copyright 2017-2021 @polkadot/react-components authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React from 'react';
+import Markdown from 'react-markdown';
+import styled from 'styled-components';
+
+import Expander from './Expander';
+
+export interface Props {
+ content: string;
+ className?: string;
+}
+
+function ExpanderMarkdown ({ className = '', content }: Props): React.ReactElement {
+ return (
+
+ {content}
+
+ );
+}
+
+export default React.memo(styled(ExpanderMarkdown)`
+ .ui--ExpanderMarkdown-content {
+ text-align: left;
+ h1 {
+ text-transform:none;
+ }
+ }
+`);
diff --git a/packages/react-components/src/InputAddressMulti/index.tsx b/packages/react-components/src/InputAddressMulti/index.tsx
index 543e82a9e08e..6c2ba12ddb79 100644
--- a/packages/react-components/src/InputAddressMulti/index.tsx
+++ b/packages/react-components/src/InputAddressMulti/index.tsx
@@ -67,7 +67,7 @@ function InputAddressMulti ({ available, availableLabel, className = '', default
className='ui--InputAddressMulti-Input'
isSmall
onChange={setFilter}
- placeholder={t('filter by name, address, or account index')}
+ placeholder={t('filter by name, address or index')}
value={_filter}
withLabel={false}
/>
diff --git a/packages/react-components/src/InputTextMulti/Available.tsx b/packages/react-components/src/InputTextMulti/Available.tsx
new file mode 100644
index 000000000000..d55ca51474f1
--- /dev/null
+++ b/packages/react-components/src/InputTextMulti/Available.tsx
@@ -0,0 +1,34 @@
+// Copyright 2017-2021 @polkadot/react-components authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useCallback } from 'react';
+
+interface Props {
+ text: string;
+ filter: string;
+ isHidden?: boolean;
+ onSelect: (text: string) => void;
+}
+
+function Available ({ filter, isHidden, onSelect, text }: Props): React.ReactElement | null {
+ const _onSelect = useCallback(
+ () => onSelect(text),
+ [text, onSelect]
+ );
+
+ if (filter && !text.includes(filter)) {
+ return null;
+ }
+
+ if (isHidden) {
+ return null;
+ }
+
+ return
+ {text}
+
;
+}
+
+export default React.memo(Available);
diff --git a/packages/react-components/src/InputTextMulti/Selected.tsx b/packages/react-components/src/InputTextMulti/Selected.tsx
new file mode 100644
index 000000000000..b7fa73659ed2
--- /dev/null
+++ b/packages/react-components/src/InputTextMulti/Selected.tsx
@@ -0,0 +1,34 @@
+// Copyright 2017-2021 @polkadot/react-components authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useCallback } from 'react';
+
+interface Props {
+ text: string;
+ filter?: string;
+ isHidden?: boolean;
+ onDeselect: (text: string) => void;
+}
+
+function Selected ({ filter, isHidden, onDeselect, text }: Props): React.ReactElement | null {
+ const _onDeselect = useCallback(
+ (): void => onDeselect(text),
+ [text, onDeselect]
+ );
+
+ if (filter && !text.includes(filter)) {
+ return null;
+ }
+
+ if (isHidden) {
+ return null;
+ }
+
+ return
+ {text}
+
;
+}
+
+export default React.memo(Selected);
diff --git a/packages/react-components/src/InputTextMulti/index.tsx b/packages/react-components/src/InputTextMulti/index.tsx
new file mode 100644
index 000000000000..e10792383f5d
--- /dev/null
+++ b/packages/react-components/src/InputTextMulti/index.tsx
@@ -0,0 +1,162 @@
+// Copyright 2017-2021 @polkadot/react-components authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import React, { useCallback, useEffect, useState } from 'react';
+import styled from 'styled-components';
+
+import { useDebounce, useLoadingDelay } from '@polkadot/react-hooks';
+
+import Input from '../Input';
+import Spinner from '../Spinner';
+import { useTranslation } from '../translate';
+import Available from './Available';
+import Selected from './Selected';
+
+interface Props {
+ available: string[];
+ availableLabel: React.ReactNode;
+ className?: string;
+ defaultValue?: string[];
+ help: React.ReactNode;
+ maxCount: number;
+ onChange: (values: string[]) => void;
+ valueLabel: React.ReactNode;
+}
+
+function InputTextMulti ({ available, availableLabel, className = '', defaultValue, maxCount, onChange, valueLabel }: Props): React.ReactElement {
+ const { t } = useTranslation();
+ const [_filter, setFilter] = useState('');
+ const [selected, setSelected] = useState([]);
+ const filter = useDebounce(_filter);
+ const isLoading = useLoadingDelay();
+
+ useEffect((): void => {
+ defaultValue && setSelected(defaultValue);
+ }, [defaultValue]);
+
+ useEffect((): void => {
+ selected && onChange(selected);
+ }, [onChange, selected]);
+
+ const _onSelect = useCallback(
+ (text: string): void =>
+ setSelected(
+ (selected: string[]) =>
+ !selected.includes(text) && (selected.length < maxCount)
+ ? selected.concat(text)
+ : selected
+ ),
+ [maxCount]
+ );
+
+ const _onDeselect = useCallback(
+ (text: string): void =>
+ setSelected(
+ (selected: string[]) =>
+ selected.includes(text)
+ ? selected.filter((a) => a !== text)
+ : selected
+ ),
+ []
+ );
+
+ return (
+
+
('filter by website')}
+ value={_filter}
+ withLabel={false}
+ />
+
+
+
{valueLabel}
+
+ {selected.map((text): React.ReactNode => (
+
+ ))}
+
+
+
+
{availableLabel}
+
+ {isLoading
+ ?
+ : (
+ available.map((text) => (
+
+ ))
+ )
+ }
+
+
+
+
+ );
+}
+
+export default React.memo(styled(InputTextMulti)`
+ border-top-width: 0px;
+ margin-left: 2rem;
+ width: calc(100% - 2rem);
+
+ .ui--InputTextMulti-Input {
+ .ui.input {
+ margin-bottom: 0.25rem;
+ opacity: 1 !important;
+ }
+ }
+
+ .ui--InputTextMulti-columns {
+ display: inline-flex;
+ flex-direction: row-reverse;
+ justify-content: space-between;
+ width: 100%;
+
+ .ui--InputTextMulti-column {
+ display: flex;
+ flex-direction: column;
+ min-height: 15rem;
+ max-height: 15rem;
+ width: 50%;
+ padding: 0.25rem 0.5rem;
+
+ .ui--InputTextMulti-items {
+ padding: 0.5rem 0;
+ background: var(--bg-input);
+ border: 1px solid rgba(34,36,38,0.15);
+ border-radius: 0.286rem 0.286rem;
+ flex: 1;
+ overflow-y: auto;
+ overflow-x: hidden;
+
+
+ > div {
+ padding: 0.5rem 0.75rem;
+ margin: 0.125rem;
+ border: 1px solid transparent;
+ border-radius: 0.25rem;
+
+ cursor: pointer;
+
+ &:hover {
+ border-color: #ccc;
+ }
+ }
+ }
+ }
+ }
+`);
diff --git a/packages/react-components/src/index.tsx b/packages/react-components/src/index.tsx
index 93ea643113f5..f2d3dcdc18aa 100644
--- a/packages/react-components/src/index.tsx
+++ b/packages/react-components/src/index.tsx
@@ -37,6 +37,7 @@ export { default as Editor } from './Editor';
export { default as ErrorBoundary } from './ErrorBoundary';
export { default as Event } from './Event';
export { default as Expander } from './Expander';
+export { default as ExpanderMarkdown } from './ExpanderMarkdown';
export { default as Extrinsic } from './Extrinsic';
export { default as FilterOverlay } from './FilterOverlay';
export { default as Flag } from './Flag';
@@ -58,6 +59,7 @@ export { default as InputNumber } from './InputNumber';
export { default as InputRpc } from './InputRpc';
export { default as InputStorage } from './InputStorage';
export { default as InputTags } from './InputTags';
+export { default as InputTextMulti } from './InputTextMulti';
export { default as InputWasm } from './InputWasm';
export { default as Inset } from './Inset';
export { default as Label } from './Label';
diff --git a/packages/react-hooks/src/useVotingStatus.ts b/packages/react-hooks/src/useVotingStatus.ts
index aa7ae5c3c53f..5742ef07692d 100644
--- a/packages/react-hooks/src/useVotingStatus.ts
+++ b/packages/react-hooks/src/useVotingStatus.ts
@@ -22,7 +22,7 @@ interface State {
const DEFAULT_STATUS = { hasFailed: false, hasPassed: false, isCloseable: false, isVoteable: false, remainingBlocks: null };
-function getStatus (api: ApiPromise, bestNumber: BlockNumber, votes: Votes, numMembers: number, section: 'council' | 'membership' | 'technicalCommittee'): State {
+function getStatus (api: ApiPromise, bestNumber: BlockNumber, votes: Votes, numMembers: number, section: 'council' | 'membership' | 'technicalCommittee' | 'alliance'): State {
const [instance] = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), section) || [section];
const modLocation = isFunction(api.tx[instance as 'technicalCommittee']?.close)
? instance
@@ -55,7 +55,7 @@ function getStatus (api: ApiPromise, bestNumber: BlockNumber, votes: Votes, numM
};
}
-export function useVotingStatus (votes: Votes | null | undefined, numMembers: number, section: 'council' | 'membership' | 'technicalCommittee'): State {
+export function useVotingStatus (votes: Votes | null | undefined, numMembers: number, section: 'council' | 'membership' | 'technicalCommittee' | 'alliance'): State {
const { api } = useApi();
const bestNumber = useBestNumber();
diff --git a/packages/react-params/src/Param/Cid.tsx b/packages/react-params/src/Param/Cid.tsx
new file mode 100644
index 000000000000..304c97542c26
--- /dev/null
+++ b/packages/react-params/src/Param/Cid.tsx
@@ -0,0 +1,35 @@
+// Copyright 2017-2021 @polkadot/react-params authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+import type { Cid } from '@polkadot/types/interfaces';
+import type { Props } from '../types';
+
+import React from 'react';
+
+import { useCidEncode } from '@polkadot/app-alliance/useCid';
+import { Static } from '@polkadot/react-components';
+
+import { useTranslation } from '../translate';
+import Bare from './Bare';
+
+function CidParam ({ className = '', defaultValue: { value }, isDisabled, isError, label, withLabel }: Props): React.ReactElement {
+ const { t } = useTranslation();
+
+ const cidStr = useCidEncode(value as Cid);
+
+ return (
+
+ ('')}
+ withCopy
+ withLabel={withLabel}
+ />
+
+ );
+}
+
+export default React.memo(CidParam);
diff --git a/packages/react-params/src/Param/findComponent.ts b/packages/react-params/src/Param/findComponent.ts
index bb3650e9f717..a7c724475178 100644
--- a/packages/react-params/src/Param/findComponent.ts
+++ b/packages/react-params/src/Param/findComponent.ts
@@ -14,6 +14,7 @@ import Balance from './Balance';
import Bool from './Bool';
import Bytes from './Bytes';
import Call from './Call';
+import Cid from './Cid';
import Code from './Code';
import DispatchError from './DispatchError';
import DispatchResult from './DispatchResult';
@@ -72,6 +73,7 @@ const componentDef: TypeToComponent[] = [
{ c: VectorFixed, t: ['VecFixed'] },
{ c: Vote, t: ['Vote'] },
{ c: VoteThreshold, t: ['VoteThreshold'] },
+ { c: Cid, t: ['Cid'] },
{ c: Unknown, t: ['Unknown'] }
];
diff --git a/tsconfig.json b/tsconfig.json
index 26f1bbe025fc..9067092bc22c 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -18,6 +18,8 @@
"@polkadot/app-accounts/*": [ "packages/page-accounts/src/*" ],
"@polkadot/app-addresses": [ "packages/page-addresses/src" ],
"@polkadot/app-addresses/*": [ "packages/page-addresses/src/*" ],
+ "@polkadot/app-alliance": [ "packages/page-alliance/src" ],
+ "@polkadot/app-alliance/*": [ "packages/page-alliance/src/*" ],
"@polkadot/app-assets": [ "packages/page-assets/src" ],
"@polkadot/app-assets/*": [ "packages/page-assets/src/*" ],
"@polkadot/app-bounties": [ "packages/page-bounties/src" ],
diff --git a/yarn.lock b/yarn.lock
index 8a1c71c919ce..a2f2b6551970 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1396,7 +1396,7 @@ __metadata:
languageName: node
linkType: hard
-"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.12.0, @babel/runtime@npm:^7.12.1, @babel/runtime@npm:^7.12.13, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.5, @babel/runtime@npm:^7.14.6, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.15.3, @babel/runtime@npm:^7.15.4, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.9.2, @babel/runtime@npm:^7.9.6":
+"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.12.0, @babel/runtime@npm:^7.12.1, @babel/runtime@npm:^7.12.13, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.0, @babel/runtime@npm:^7.14.5, @babel/runtime@npm:^7.14.6, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.15.3, @babel/runtime@npm:^7.15.4, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.9.2, @babel/runtime@npm:^7.9.6":
version: 7.15.4
resolution: "@babel/runtime@npm:7.15.4"
dependencies:
@@ -2287,6 +2287,13 @@ __metadata:
languageName: node
linkType: hard
+"@multiformats/base-x@npm:^4.0.1":
+ version: 4.0.1
+ resolution: "@multiformats/base-x@npm:4.0.1"
+ checksum: ecbf84bdd7613fd795e4a41f20f3e8cc7df8bbee84690b7feed383d45a638ed228a80ff6f5c930373cbf24539f64857b66023ee3c1e914f6bac9995c76414a87
+ languageName: node
+ linkType: hard
+
"@nicolo-ribaudo/chokidar-2@npm:2.1.8-no-fsevents.2":
version: 2.1.8-no-fsevents.2
resolution: "@nicolo-ribaudo/chokidar-2@npm:2.1.8-no-fsevents.2"
@@ -2586,6 +2593,17 @@ __metadata:
languageName: unknown
linkType: soft
+"@polkadot/app-alliance@workspace:packages/page-alliance":
+ version: 0.0.0-use.local
+ resolution: "@polkadot/app-alliance@workspace:packages/page-alliance"
+ dependencies:
+ "@babel/runtime": ^7.14.0
+ "@polkadot/react-components": ^0.95.2-149
+ "@polkadot/react-query": ^0.95.2-149
+ cids: ^1.1.6
+ languageName: unknown
+ linkType: soft
+
"@polkadot/app-assets@workspace:packages/page-assets":
version: 0.0.0-use.local
resolution: "@polkadot/app-assets@workspace:packages/page-assets"
@@ -7016,6 +7034,18 @@ __metadata:
languageName: node
linkType: hard
+"cids@npm:^1.1.6":
+ version: 1.1.7
+ resolution: "cids@npm:1.1.7"
+ dependencies:
+ multibase: ^4.0.1
+ multicodec: ^3.0.1
+ multihashes: ^4.0.1
+ uint8arrays: ^2.1.3
+ checksum: df2a14b32c101080d27b4b76b0d5c9cc3cd40ce293ca150c6bfaddfa8c5a6277669ab270665fec2e140cb8680380494a73052cdaa2838d3928d2b2bc483a118a
+ languageName: node
+ linkType: hard
+
"cids@npm:~0.8.0":
version: 0.8.3
resolution: "cids@npm:0.8.3"
@@ -8709,6 +8739,13 @@ __metadata:
languageName: node
linkType: hard
+"domelementtype@npm:^2.2.0":
+ version: 2.2.0
+ resolution: "domelementtype@npm:2.2.0"
+ checksum: 24cb386198640cd58aa36f8c987f2ea61859929106d06ffcc8f547e70cb2ed82a6dc56dcb8252b21fba1f1ea07df6e4356d60bfe57f77114ca1aed6828362629
+ languageName: node
+ linkType: hard
+
"domexception@npm:^2.0.1":
version: 2.0.1
resolution: "domexception@npm:2.0.1"
@@ -8745,6 +8782,15 @@ __metadata:
languageName: node
linkType: hard
+"domhandler@npm:^4.2.0":
+ version: 4.2.0
+ resolution: "domhandler@npm:4.2.0"
+ dependencies:
+ domelementtype: ^2.2.0
+ checksum: 7921ac317d6899525a4e6a6038137307271522175a73db58233e13c7860987e15e86654583b2c0fd02fc46a602f9bd86fd2671af13b9068b72e8b229f07b3d03
+ languageName: node
+ linkType: hard
+
"domutils@npm:1.5.1":
version: 1.5.1
resolution: "domutils@npm:1.5.1"
@@ -8765,7 +8811,7 @@ __metadata:
languageName: node
linkType: hard
-"domutils@npm:^2.0.0, domutils@npm:^2.4.2":
+"domutils@npm:^2.0.0":
version: 2.4.4
resolution: "domutils@npm:2.4.4"
dependencies:
@@ -8776,6 +8822,17 @@ __metadata:
languageName: node
linkType: hard
+"domutils@npm:^2.4.2":
+ version: 2.7.0
+ resolution: "domutils@npm:2.7.0"
+ dependencies:
+ dom-serializer: ^1.0.1
+ domelementtype: ^2.2.0
+ domhandler: ^4.2.0
+ checksum: a4da0fcc4c54f6b338111caa11c672e18968d6280e7a1ed5e01b8b09b7dc0829ab5e03821349f5b57e34811f7e96e89b8dddbe06bb8e395cf117342424667b7d
+ languageName: node
+ linkType: hard
+
"dot-case@npm:^3.0.4":
version: 3.0.4
resolution: "dot-case@npm:3.0.4"
@@ -15149,7 +15206,7 @@ __metadata:
languageName: node
linkType: hard
-"multibase@npm:^1.0.0, multibase@npm:^1.0.1":
+"multibase@npm:^1.0.0":
version: 1.0.1
resolution: "multibase@npm:1.0.1"
dependencies:
@@ -15159,6 +15216,15 @@ __metadata:
languageName: node
linkType: hard
+"multibase@npm:^4.0.1":
+ version: 4.0.4
+ resolution: "multibase@npm:4.0.4"
+ dependencies:
+ "@multiformats/base-x": ^4.0.1
+ checksum: 7d112ae9a12aeefda4dac0ae7e1f2e845a00e374ccb7bb3d521b8be17078dd86e2ae4f0f0f21d8ceb32ea5e8153b8b2cd611b884639a0ddba3c97f2b3217f47c
+ languageName: node
+ linkType: hard
+
"multibase@npm:~0.6.0":
version: 0.6.1
resolution: "multibase@npm:0.6.1"
@@ -15207,25 +15273,24 @@ __metadata:
languageName: node
linkType: hard
-"multihashes@npm:^0.4.15, multihashes@npm:~0.4.13, multihashes@npm:~0.4.15":
- version: 0.4.21
- resolution: "multihashes@npm:0.4.21"
+"multicodec@npm:^3.0.1":
+ version: 3.0.1
+ resolution: "multicodec@npm:3.0.1"
dependencies:
- buffer: ^5.5.0
- multibase: ^0.7.0
- varint: ^5.0.0
- checksum: 688731560cf7384e899dc75c0da51e426eb7d058c5ea5eb57b224720a1108deb8797f1cd7f45599344d512d2877de99dd6a7b7773a095812365dea4ffe6ebd4c
+ uint8arrays: ^2.1.3
+ varint: ^5.0.2
+ checksum: d65963d4065e829db3a6d1823fb4729c4c8881368e61fa0bca3b9722947c7162f2fef565e7e17b0e0b855df907dd88cc50a88fe36c44f00777b6da94af66bc62
languageName: node
linkType: hard
-"multihashes@npm:^1.0.1":
- version: 1.0.1
- resolution: "multihashes@npm:1.0.1"
+"multihashes@npm:^4.0.2":
+ version: 4.0.2
+ resolution: "multihashes@npm:4.0.2"
dependencies:
- buffer: ^5.6.0
- multibase: ^1.0.1
- varint: ^5.0.0
- checksum: 21e338dfb23900f7c038ac708fab598b33bc3d8d02f636ff753969c575b934f979dec76936ca142c6fd126a8bd030f7f391a44a3681c92cab28311c8b0b70589
+ multibase: ^4.0.1
+ uint8arrays: ^2.1.3
+ varint: ^5.0.2
+ checksum: 506fcbc3e59638e3509900beb34f490bfb5bf19bcce338f55e7c908d93d5358a6a0876a3275f8d07d9e5a7a5368e1d598a0d5359fa3d6003116977b4e1e306f8
languageName: node
linkType: hard
@@ -20453,6 +20518,15 @@ resolve@^2.0.0-next.3:
languageName: node
linkType: hard
+"uint8arrays@npm:^2.1.3":
+ version: 2.1.5
+ resolution: "uint8arrays@npm:2.1.5"
+ dependencies:
+ multibase: ^4.0.1
+ checksum: 521a120ad21250004a95330d0501c87344c5072376b5d5d9ef642721f7913cc1880b823715e5d8829307a9dda73c3064283cb3a7442f0e85fef781cfca4f0334
+ languageName: node
+ linkType: hard
+
"ultron@npm:~1.1.0":
version: 1.1.1
resolution: "ultron@npm:1.1.1"
@@ -20952,7 +21026,7 @@ resolve@^2.0.0-next.3:
languageName: node
linkType: hard
-"varint@npm:^5.0.0":
+"varint@npm:^5.0.0, varint@npm:^5.0.2":
version: 5.0.2
resolution: "varint@npm:5.0.2"
checksum: e1a66bf9a6cea96d1f13259170d4d41b845833acf3a9df990ea1e760d279bd70d5b1f4c002a50197efd2168a2fd43eb0b808444600fd4d23651e8d42fe90eb05