-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init * Attest component * Add top notification bar * better english * back to 3 steps * clean up * in the middle of the refactoring * Make TS pass * Clea up some comments * isPreclaimed * isOldClaimProcess * Attest vs Claim (#2737) * Choose between Claim and Attest * fix lint * fix flow between claim and attest (#2738) * Jaco's comments + Fetch StatementKind (#2741) * Fix small bug in flow * Add condition for the warning banner (#2742) * prevent crash for older chains * with useEffect * should work * back to something simple * remove hoc * fix CI * Add ETH address field for non preclaimed addresses (#2746) * Eth field * fix * remove stray logs * Update packages/page-claims/src/index.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * Update packages/page-claims/src/index.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * Update packages/apps/src/overlays/Attest.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * Show the amount of token that will be claimed (#2747) * show amount in attest * fix isApiReady * fix lint * Use counter instead of overlay (#2750) * Use counter instead of overlay * Add warning to claim (#2752) * add warning * css cleanup * fix unused const Co-authored-by: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> * Update packages/page-claims/src/Warning.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * Update packages/page-claims/src/index.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * Update packages/page-claims/src/index.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * Update packages/page-claims/src/index.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * Update packages/page-claims/src/index.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * address comment shortcut * set Ethereum address outside transfor and fix typos * lint * extract claims.preclaims to a hook * address comments EthereumAddress type and avoid casting * Missing isUnsigned * use AddressMini in warning * use a proper step for eth address field * Add loading state * remove log * unwrapOrNull * Update packages/page-claims/src/Warning.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * fix for account plural translation * lint * Add getStatement function * nits * Fix lint * Update packages/page-claims/src/Warning.tsx Co-authored-by: Jaco Greeff <jacogr@gmail.com> * add statement * statement component * address comment unWrapOr * test styling with long md * add md to jest * Update packages/page-claims/src/Statement.tsx Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * copy text before * lint * Remove EthreumAddress type to avoid unexpected behaviors (#2796) * remove EthreumAddress type * createType when needed * revert * typo * Enhance UX for claim process (#2797) * update content * init * comment * Add HTML components for statements (#2798) * Add HTML components for statements * Update packages/page-claims/src/statements/saft.tsx * Update to final statements * More nits * Nits * OnSuccess * prevent display of empty statement when attested * Small fixmes * Update packages/page-claims/src/index.tsx * fix isError not being red as expected * remove word-break * statement text in black * attestation for -> accounc balance * Update packages/page-claims/src/Statement.tsx Co-authored-by: Logan Saether <x@logansaether.com> * margin left instead of space * I agree * Use iframe * update saft to QmXEkMahfhHJPzT3RjkXiZVFi77ZeVeuxtAjhojGRNYckz * remove hash and duplications (#2814) Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Jaco Greeff <jacogr@gmail.com> Co-authored-by: Logan Saether <x@logansaether.com>
- Loading branch information
1 parent
8e00005
commit 0091fc6
Showing
10 changed files
with
631 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright 2017-2020 @polkadot/app-claims authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the Apache-2.0 license. See the LICENSE file for details. | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { Button, Card, TxButton } from '@polkadot/react-components'; | ||
import { TxCallback } from '@polkadot/react-components/Status/types'; | ||
import { useApi } from '@polkadot/react-hooks'; | ||
import { FormatBalance } from '@polkadot/react-query'; | ||
import { Option } from '@polkadot/types'; | ||
import { BalanceOf, EthereumAddress, StatementKind } from '@polkadot/types/interfaces'; | ||
|
||
import { ClaimStyles } from './Claim'; | ||
import Statement from './Statement'; | ||
import { useTranslation } from './translate'; | ||
import { getStatement } from './util'; | ||
|
||
interface Props { | ||
accountId: string; | ||
className?: string; | ||
ethereumAddress: EthereumAddress | null; | ||
onSuccess?: TxCallback; | ||
statementKind?: StatementKind; | ||
systemChain: string; | ||
} | ||
|
||
function Attest ({ accountId, className, ethereumAddress, onSuccess, statementKind, systemChain }: Props): React.ReactElement<Props> | null { | ||
const { t } = useTranslation(); | ||
const { api } = useApi(); | ||
const [claimValue, setClaimValue] = useState<BalanceOf | null>(null); | ||
const [isBusy, setIsBusy] = useState(false); | ||
|
||
useEffect((): void => { | ||
if (!ethereumAddress) { | ||
return; | ||
} | ||
|
||
setIsBusy(true); | ||
|
||
api.query.claims | ||
.claims<Option<BalanceOf>>(ethereumAddress) | ||
.then((claim): void => { | ||
setClaimValue(claim.unwrapOr(null)); | ||
setIsBusy(false); | ||
}) | ||
.catch((): void => setIsBusy(false)); | ||
}, [api, ethereumAddress]); | ||
|
||
if (isBusy) { | ||
return null; | ||
} | ||
|
||
const hasClaim = claimValue && claimValue.gten(0); | ||
const statementSentence = getStatement(systemChain, statementKind)?.sentence; | ||
|
||
if (!hasClaim || !statementSentence) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Card isSuccess> | ||
<div className={className}> | ||
<Statement | ||
kind={statementKind} | ||
systemChain={systemChain} | ||
/> | ||
<h3><FormatBalance label={t<string>('Account balance:')} | ||
value={claimValue} /></h3> | ||
<Button.Group> | ||
<TxButton | ||
accountId={accountId} | ||
icon='send' | ||
isDisabled={!statementSentence} | ||
isPrimary | ||
label={t<string>('I agree')} | ||
onSuccess={onSuccess} | ||
params={[statementSentence]} | ||
tx='claims.attest' | ||
/> | ||
</Button.Group> | ||
</div> | ||
</Card> | ||
); | ||
} | ||
|
||
export default React.memo(styled(Attest)`${ClaimStyles}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2017-2020 @polkadot/app-claims authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the Apache-2.0 license. See the LICENSE file for details. | ||
|
||
import { StatementKind } from '@polkadot/types/interfaces'; | ||
|
||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { useTranslation } from './translate'; | ||
import { getStatement } from './util'; | ||
|
||
export interface Props { | ||
className?: string; | ||
kind?: StatementKind; | ||
systemChain: string; | ||
} | ||
|
||
// Get the full hardcoded text for a statement | ||
function StatementFullText ({ statementUrl, systemChain }: { statementUrl?: string; systemChain: string }): React.ReactElement | null { | ||
const { t } = useTranslation(); | ||
|
||
switch (systemChain) { | ||
case 'Polkadot CC1': { | ||
if (!statementUrl) { | ||
return null; | ||
} | ||
|
||
return <iframe src={statementUrl} />; | ||
} | ||
|
||
default: | ||
return <p>{t('Warning: we did not find any attest statement for {{chain}}', { replace: { chain: systemChain } })}</p>; | ||
} | ||
} | ||
|
||
function Statement ({ className, kind, systemChain }: Props): React.ReactElement<Props> | null { | ||
const { t } = useTranslation(); | ||
const statementUrl = getStatement(systemChain, kind)?.url; | ||
|
||
return ( | ||
<div className={className}> | ||
{t('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:')} | ||
<a className='statementUrl' | ||
href={statementUrl} | ||
rel='noopener noreferrer' | ||
target='_blank'>{statementUrl}</a> | ||
<div className='statement'> | ||
<StatementFullText | ||
statementUrl={statementUrl} | ||
systemChain={systemChain} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default React.memo(styled(Statement)` | ||
.statement{ | ||
border: 1px solid #c2c2c2; | ||
background: #f2f2f2; | ||
height: 15rem; | ||
padding: 1rem; | ||
width: 100%; | ||
margin: 1rem 0; | ||
white-space: normal; | ||
p { | ||
color: #4e4e4e !important; | ||
} | ||
iframe { | ||
border: 0; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
} | ||
.statementUrl{ | ||
margin-left: 0.3rem | ||
} | ||
`); |
Oops, something went wrong.