diff --git a/packages/page-parachains/src/Crowdloan/Fund.tsx b/packages/page-parachains/src/Crowdloan/Fund.tsx index 17865cf16c..fcf23de976 100644 --- a/packages/page-parachains/src/Crowdloan/Fund.tsx +++ b/packages/page-parachains/src/Crowdloan/Fund.tsx @@ -27,19 +27,18 @@ interface Props { } interface Contributions { - uniqueKeys: string[]; + contributors: string[]; myAccounts: string[]; } -const NO_CONTRIB: Contributions = { myAccounts: [], uniqueKeys: [] }; +const NO_CONTRIB: Contributions = { contributors: [], myAccounts: [] }; function extractContributors (allAccounts: string[], keys: StorageKey[]): Contributions { - const uniqueKeys = keys.map((k) => k.toHex()); const contributors = keys.map((k) => encodeAddress(k)); return { - myAccounts: contributors.filter((c) => allAccounts.includes(c)), - uniqueKeys + contributors, + myAccounts: contributors.filter((c) => allAccounts.includes(c)) }; } @@ -47,7 +46,7 @@ function Fund ({ bestNumber, className, isOngoing, leasePeriod, value: { childKe const { t } = useTranslation(); const { api } = useApi(); const { allAccounts, isAccount } = useAccounts(); - const [{ myAccounts, uniqueKeys }, setContributors] = useState(NO_CONTRIB); + const [{ contributors, myAccounts }, setContributors] = useState(NO_CONTRIB); const trigger = useEventTrigger([api.events.crowdloan.Contributed, api.events.crowdloan.Withdrew, api.events.crowdloan.AllRefunded, api.events.crowdloan.PartiallyRefunded], useCallback( ({ event: { data } }: EventRecord) => ((data.length === 1 @@ -134,8 +133,8 @@ function Fund ({ bestNumber, className, isOngoing, leasePeriod, value: { childKe
{percentage}
- {uniqueKeys.length !== 0 && ( - formatNumber(uniqueKeys.length) + {contributors.length !== 0 && ( + formatNumber(contributors.length) )} @@ -145,12 +144,8 @@ function Fund ({ bestNumber, className, isOngoing, leasePeriod, value: { childKe /> - {canWithdraw && uniqueKeys.length !== 0 && ( - + {canWithdraw && contributors.length !== 0 && ( + )} {canDissolve && ( { +function Refund ({ className, paraId }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const { hasAccounts } = useAccounts(); const [isOpen, toggleOpen] = useToggle(); const [accountId, setAccountId] = useState(null); - const [txs, setTxs] = useState[] | null>(null); - const [withdrawType, setWithdrawType] = useState(0); - const extrinsics = useTxBatch(txs, optTxs); - - const typeOptions = useMemo( - () => [ - { - text: t('Withdraw for all contributed accounts'), - value: 0 - }, - myAccounts.length && { - text: t('Withdraw only for my accounts'), - value: 1 - } - ].filter((o) => !!o), - [myAccounts, t] - ); - - useEffect((): void => { - const addresses = withdrawType === 0 - ? allAccounts - : myAccounts; - - setTxs(() => - addresses.length - ? addresses.map((a) => api.tx.crowdloan.withdraw(a, paraId)) - : null - ); - }, [api, allAccounts, myAccounts, paraId, withdrawType]); return ( <> @@ -79,38 +45,16 @@ function Refund ({ allAccounts, className, myAccounts, paraId }: Props): React.R value={accountId} /> - {!api.tx.crowdloan.refund && ( - ('The type of withdrawal, all accounts or only own accounts (if available)')}> - ('withdrawal type')} - onChange={setWithdrawType} - options={typeOptions} - value={withdrawType} - /> - - )} - {api.tx.crowdloan.refund - ? ( - ('Refund')} - onStart={toggleOpen} - tx={api.tx.crowdloan.refund} - /> - ) - : ( - ('Refund')} - onStart={toggleOpen} - /> - )} + ('Refund')} + onStart={toggleOpen} + params={[paraId]} + tx={api.tx.crowdloan.refund} + /> )} diff --git a/packages/page-parachains/src/useFunds.ts b/packages/page-parachains/src/useFunds.ts index ba64904c53..24a21639d1 100644 --- a/packages/page-parachains/src/useFunds.ts +++ b/packages/page-parachains/src/useFunds.ts @@ -66,6 +66,22 @@ function isFundUpdated (bestNumber: BlockNumber, minContribution: BN, { info: { (!prev.isWinner && hasLease(paraId, leased)); } +function sortCampaigns (a: Campaign, b: Campaign): number { + return a.isWinner !== b.isWinner + ? a.isWinner + ? -1 + : 1 + : a.isCapped !== b.isCapped + ? a.isCapped + ? -1 + : 1 + : a.isEnded !== b.isEnded + ? a.isEnded + ? 1 + : -1 + : 0; +} + // compare the current campaigns against the previous, manually adding ending and calculating the new totals function createResult (bestNumber: BlockNumber, minContribution: BN, funds: Campaign[], leased: ParaId[], prev: Campaigns): Campaigns { const [activeRaised, activeCap, totalRaised, totalCap] = funds.reduce(([ar, ac, tr, tc], { info: { cap, end, raised } }) => [ @@ -96,21 +112,7 @@ function createResult (bestNumber: BlockNumber, minContribution: BN, funds: Camp : prev.activeRaised, funds: funds .map((c) => updateFund(bestNumber, minContribution, c, leased)) - .sort((a, b) => - a.isWinner !== b.isWinner - ? a.isWinner - ? -1 - : 1 - : a.isCapped !== b.isCapped - ? a.isCapped - ? -1 - : 1 - : a.isEnded !== b.isEnded - ? a.isEnded - ? 1 - : -1 - : 0 - ), + .sort(sortCampaigns), totalCap: hasNewTotalCap ? totalCap : prev.totalCap, diff --git a/packages/react-components/src/Table/index.tsx b/packages/react-components/src/Table/index.tsx index 617ab8cf43..7548127977 100644 --- a/packages/react-components/src/Table/index.tsx +++ b/packages/react-components/src/Table/index.tsx @@ -92,9 +92,12 @@ export default React.memo(styled(Table)` } &.all { - word-break: break-word; width: 100%; + &:not(.overflow) { + word-break: break-word; + } + summary { white-space: normal; } @@ -210,6 +213,7 @@ export default React.memo(styled(Table)` max-width: 0; overflow: hidden; text-overflow: ellipsis; + word-break: none; } &.start {