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 <> +