diff --git a/packages/page-accounts/src/modals/Ledger.tsx b/packages/page-accounts/src/modals/Ledger.tsx index a6cd12d637..c75e0c83da 100644 --- a/packages/page-accounts/src/modals/Ledger.tsx +++ b/packages/page-accounts/src/modals/Ledger.tsx @@ -1,12 +1,13 @@ // Copyright 2017-2021 @polkadot/app-accounts authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { ApiPromise } from '@polkadot/api'; import type { Ledger } from '@polkadot/ui-keyring'; import React, { useCallback, useRef, useState } from 'react'; import { Button, Dropdown, MarkError, Modal } from '@polkadot/react-components'; -import { useLedger } from '@polkadot/react-hooks'; +import { useApi, useLedger } from '@polkadot/react-hooks'; import { keyring } from '@polkadot/ui-keyring'; import { useTranslation } from '../translate'; @@ -24,14 +25,20 @@ interface Props { const AVAIL = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]; // query the ledger for the address, adding it to the keyring -async function queryLedger (getLedger: () => Ledger, accountOffset: number, addressOffset: number): Promise { +async function queryLedger (api: ApiPromise, getLedger: () => Ledger, accountOffset: number, addressOffset: number): Promise { const { address } = await getLedger().getAddress(false, accountOffset, addressOffset); - keyring.addHardware(address, 'ledger', { accountOffset, addressOffset, name: `ledger ${accountOffset}/${addressOffset}` }); + keyring.addHardware(address, 'ledger', { + accountOffset, + addressOffset, + genesisHash: api.genesisHash.toHex(), + name: `ledger ${accountOffset}/${addressOffset}` + }); } function LedgerModal ({ className, onClose }: Props): React.ReactElement { const { t } = useTranslation(); + const { api } = useApi(); const { getLedger } = useLedger(); const [accIndex, setAccIndex] = useState(0); const [addIndex, setAddIndex] = useState(0); @@ -53,7 +60,7 @@ function LedgerModal ({ className, onClose }: Props): React.ReactElement setError(null); setIsBusy(true); - queryLedger(getLedger, accIndex, addIndex) + queryLedger(api, getLedger, accIndex, addIndex) .then(() => onClose()) .catch((error): void => { console.error(error); @@ -62,7 +69,7 @@ function LedgerModal ({ className, onClose }: Props): React.ReactElement setError(error); }); }, - [accIndex, addIndex, getLedger, onClose] + [accIndex, addIndex, api, getLedger, onClose] ); return ( diff --git a/packages/page-accounts/src/modals/Transfer.tsx b/packages/page-accounts/src/modals/Transfer.tsx index 4184bc7107..9c92bc6ee3 100644 --- a/packages/page-accounts/src/modals/Transfer.tsx +++ b/packages/page-accounts/src/modals/Transfer.tsx @@ -27,11 +27,13 @@ function isRefcount (accountInfo: AccountInfoWithProviders | AccountInfoWithRefC return !!(accountInfo as AccountInfoWithRefCount).refcount; } -async function checkPhishing (senderId: string | null, recipientId: string | null): Promise<[string | null, string | null]> { +async function checkPhishing (_senderId: string | null, recipientId: string | null): Promise<[string | null, string | null]> { return [ - senderId - ? await checkAddress(senderId) - : null, + // not being checked atm + // senderId + // ? await checkAddress(senderId) + // : null, + null, recipientId ? await checkAddress(recipientId) : null @@ -48,7 +50,7 @@ function Transfer ({ className = '', onClose, recipientId: propRecipientId, send const [[maxTransfer, noFees], setMaxTransfer] = useState<[BN | null, boolean]>([null, false]); const [recipientId, setRecipientId] = useState(propRecipientId || null); const [senderId, setSenderId] = useState(propSenderId || null); - const [[senderPhish, recipientPhish], setPhishing] = useState<[string | null, string | null]>([null, null]); + const [[, recipientPhish], setPhishing] = useState<[string | null, string | null]>([null, null]); const balances = useCall(api.derive.balances.all, [senderId]); const accountInfo = useCall(api.query.system.account, [senderId]); @@ -115,9 +117,6 @@ function Transfer ({ className = '', onClose, recipientId: propRecipientId, send onChange={setSenderId} type='account' /> - {senderPhish && ( - ('The sender is associated with a known phishing site, {{url}}', { replace: { url: senderPhish } })} /> - )}

{t('The transferred balance will be subtracted (along with fees) from the sender account.')}

@@ -217,7 +216,7 @@ function Transfer ({ className = '', onClose, recipientId: propRecipientId, send ('Make Transfer')} onStart={onClose} params={