diff --git a/packages/page-claims/src/Attest.tsx b/packages/page-claims/src/Attest.tsx index 48e09300beba..a728dbc6f8ce 100644 --- a/packages/page-claims/src/Attest.tsx +++ b/packages/page-claims/src/Attest.tsx @@ -2,101 +2,50 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { Signer } from '@polkadot/api/types'; -import { web3FromSource } from '@polkadot/extension-dapp'; -import { KeyringPair } from '@polkadot/keyring/types'; -import { Button, Card } from '@polkadot/react-components'; -import keyring from '@polkadot/ui-keyring'; -import { stringToHex, stringToU8a, u8aToHex } from '@polkadot/util'; - -import React, { useCallback, useEffect, useState } from 'react'; +import React from 'react'; import styled from 'styled-components'; +import { Button, Card, TxButton } from '@polkadot/react-components'; import { useTranslation } from './translate'; +import { addrToChecksum } from './util'; interface Props { accountId: string; className?: string; - data: string; - onNextStep: (signature: string) => void; } -function Attest ({ accountId, className, data, onNextStep }: Props): React.ReactElement | null { +function Attest ({ accountId, className }: Props): React.ReactElement | null { const { t } = useTranslation(); - // const [attestSignature, setAttestSignature] = useState(null); - const [currentPair, setCurrentPair] = useState(null); - const [signer, setSigner] = useState(null); - - useEffect((): void => { - const isInjected = currentPair?.meta.isInjected || false; - - // for injected, retrieve the signer - if (currentPair && isInjected) { - const { meta: { source } } = currentPair; - - web3FromSource(source) - .catch((): null => null) - .then((injected): void => setSigner( - injected?.signer || null - )); - } - }, [currentPair]); - - useEffect(() => { - setCurrentPair(keyring.getPair(accountId || '')); - }, [accountId]); - - const _signAttest = useCallback( - (): void => { - if (!currentPair) { - return; - } - - if (signer?.signRaw) { - signer - .signRaw({ - address: currentPair.address, - data: stringToHex(data), - type: 'bytes' - }) - .then(({ signature }): void => onNextStep(signature)); - } else { - onNextStep(u8aToHex( - currentPair.sign(stringToU8a(data)) - )); - } - }, - [currentPair, data, onNextStep, signer] - ); return ( - -

{t('3. Sign attestation')}

-
- {t('Clicking the following button will let you sign the hash of the attestation available at the following address: XXX')} - : + +
+ {t('By signing this transaction, you agree with attestation available at the following address: XXX')} +

{addrToChecksum(accountId)}

+ + +
- -