From 7508830ca54bbfe2b3df542472dfe41776b4cb0a Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 15 Apr 2024 19:28:43 +0700 Subject: [PATCH 1/2] use w3ux vault accounts provider --- package.json | 2 +- src/Providers.tsx | 11 +- .../Connect/ImportedAccounts/index.tsx | 10 +- src/contexts/Connect/OtherAccounts/index.tsx | 6 +- src/contexts/Hardware/Utils.tsx | 59 ------ src/contexts/Hardware/Vault/VaultAccounts.tsx | 168 ------------------ src/contexts/Hardware/Vault/defaults.ts | 14 -- src/contexts/Hardware/Vault/types.ts | 20 --- src/modals/ImportVault/Reader.tsx | 2 +- src/modals/ImportVault/index.tsx | 2 +- yarn.lock | 10 +- 11 files changed, 23 insertions(+), 281 deletions(-) delete mode 100644 src/contexts/Hardware/Vault/VaultAccounts.tsx delete mode 100644 src/contexts/Hardware/Vault/defaults.ts delete mode 100644 src/contexts/Hardware/Vault/types.ts diff --git a/package.json b/package.json index 35e9db8dc3..8e7f98d18b 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@substrate/connect": "0.7.35", "@w3ux/extension-assets": "0.2.6", "@w3ux/hooks": "^0.0.3", - "@w3ux/react-connect-kit": "0.1.8", + "@w3ux/react-connect-kit": "^0.1.12", "@w3ux/react-odometer": "^0.0.3", "@w3ux/react-polkicon": "^0.0.2", "@w3ux/utils": "^0.0.2", diff --git a/src/Providers.tsx b/src/Providers.tsx index a0c4ba4150..385aebaeb4 100644 --- a/src/Providers.tsx +++ b/src/Providers.tsx @@ -7,11 +7,11 @@ import { ExtensionsProvider, ExtensionAccountsProvider, LedgerAccountsProvider, + VaultAccountsProvider, } from '@w3ux/react-connect-kit'; import { FastUnstakeProvider } from 'contexts/FastUnstake'; import { FiltersProvider } from 'contexts/Filters'; import { LedgerHardwareProvider } from 'contexts/Hardware/Ledger/LedgerHardware'; -import { VaultAccountsProvider } from 'contexts/Hardware/Vault/VaultAccounts'; import { HelpProvider } from 'contexts/Help'; import { MenuProvider } from 'contexts/Menu'; import { MigrateProvider } from 'contexts/Migrate'; @@ -47,17 +47,13 @@ import { OverlayProvider } from 'kits/Overlay/Provider'; import { JoinPoolsProvider } from 'contexts/Pools/JoinPools'; export const Providers = () => { - const { - network, - networkData: { ss58 }, - } = useNetwork(); + const { network } = useNetwork(); const { activeAccount, setActiveAccount } = useActiveAccounts(); // !! Provider order matters. const providers: Provider[] = [ UIProvider, [APIProvider, { network }], - VaultAccountsProvider, LedgerHardwareProvider, [ ExtensionsProvider, @@ -65,8 +61,9 @@ export const Providers = () => { ], [ ExtensionAccountsProvider, - { dappName: DappName, network, ss58, activeAccount, setActiveAccount }, + { dappName: DappName, network, activeAccount, setActiveAccount }, ], + [VaultAccountsProvider, { network }], [LedgerAccountsProvider, { network }], ExternalAccountsProvider, OtherAccountsProvider, diff --git a/src/contexts/Connect/ImportedAccounts/index.tsx b/src/contexts/Connect/ImportedAccounts/index.tsx index 2e2e6d4031..7e18e01e0f 100644 --- a/src/contexts/Connect/ImportedAccounts/index.tsx +++ b/src/contexts/Connect/ImportedAccounts/index.tsx @@ -16,6 +16,7 @@ import type { ImportedAccountsContextInterface } from './types'; import { useOtherAccounts } from '../OtherAccounts'; import { BalancesController } from 'controllers/BalancesController'; import { useApi } from 'contexts/Api'; +import { useNetwork } from 'contexts/Network'; export const ImportedAccountsContext = createContext( @@ -30,8 +31,15 @@ export const ImportedAccountsProvider = ({ children: ReactNode; }) => { const { isReady, api } = useApi(); + const { + networkData: { ss58 }, + } = useNetwork(); const { otherAccounts } = useOtherAccounts(); - const { extensionAccounts } = useExtensionAccounts(); + const { getExtensionAccounts } = useExtensionAccounts(); + + // Get the imported extension accounts formatted with the current network's ss58 prefix. + const extensionAccounts = getExtensionAccounts(ss58); + const allAccounts = extensionAccounts.concat(otherAccounts); // Stringify account addresses and account names to determine if they have changed. Ignore other properties including `signer` and `source`. diff --git a/src/contexts/Connect/OtherAccounts/index.tsx b/src/contexts/Connect/OtherAccounts/index.tsx index 5a48f72b3d..09777d8159 100644 --- a/src/contexts/Connect/OtherAccounts/index.tsx +++ b/src/contexts/Connect/OtherAccounts/index.tsx @@ -3,10 +3,6 @@ import type { ReactNode } from 'react'; import { createContext, useContext, useEffect, useRef, useState } from 'react'; -import { - getLocalLedgerAccounts, - getLocalVaultAccounts, -} from 'contexts/Hardware/Utils'; import type { MaybeAddress, NetworkName } from 'types'; import { setStateWithRef } from '@w3ux/utils'; import { useNetwork } from 'contexts/Network'; @@ -22,6 +18,8 @@ import { useEventListener } from 'usehooks-ts'; import { useExtensionAccounts, useExtensions } from '@w3ux/react-connect-kit'; import type { ImportedAccount } from '@w3ux/react-connect-kit/types'; import { useEffectIgnoreInitial } from '@w3ux/hooks'; +import { getLocalVaultAccounts } from '@w3ux/react-connect-kit/VaultAccountsProvider/utils'; +import { getLocalLedgerAccounts } from '@w3ux/react-connect-kit/LedgerAccountsProvider/utils'; export const OtherAccountsContext = createContext(defaultOtherAccountsContext); diff --git a/src/contexts/Hardware/Utils.tsx b/src/contexts/Hardware/Utils.tsx index d564ed465a..19fdaa673a 100644 --- a/src/contexts/Hardware/Utils.tsx +++ b/src/contexts/Hardware/Utils.tsx @@ -3,11 +3,6 @@ import { localStorageOrDefault } from '@w3ux/utils'; import { LedgerApps } from 'config/ledger'; -import type { MaybeString } from 'types'; -import type { - LedgerAccount, - VaultAccount, -} from '@w3ux/react-connect-kit/types'; import type { LedgerAddress } from './Ledger/types'; // Ledger error keyed by type of error. @@ -61,57 +56,3 @@ export const getLocalLedgerAddresses = (network?: string) => { ? localAddresses.filter((a) => a.network === network) : localAddresses; }; - -// Gets imported Ledger accounts from local storage. -export const getLocalLedgerAccounts = (network?: string): LedgerAccount[] => { - const localAddresses = localStorageOrDefault( - 'ledger_accounts', - [], - true - ) as LedgerAccount[]; - - return network - ? localAddresses.filter((a) => a.network === network) - : localAddresses; -}; - -// Renames a record from local ledger addresses. -export const renameLocalLedgerAddress = ( - address: string, - name: string, - network: string -) => { - const localLedger = ( - localStorageOrDefault('ledger_addresses', [], true) as LedgerAddress[] - )?.map((i) => - !(i.address === address && i.network === network) - ? i - : { - ...i, - name, - } - ); - if (localLedger) { - localStorage.setItem('ledger_addresses', JSON.stringify(localLedger)); - } -}; - -// Gets imported Vault accounts from local storage. -export const getLocalVaultAccounts = (network?: string) => { - const localAddresses = localStorageOrDefault( - 'polkadot_vault_accounts', - [], - true - ) as VaultAccount[]; - - return network - ? localAddresses.filter((a) => a.network === network) - : localAddresses; -}; - -// Gets whether an address is a local network address. -export const isLocalNetworkAddress = ( - chain: string, - a: { address: MaybeString; network: string }, - address: string -) => a.address === address && a.network === chain; diff --git a/src/contexts/Hardware/Vault/VaultAccounts.tsx b/src/contexts/Hardware/Vault/VaultAccounts.tsx deleted file mode 100644 index de3842ff51..0000000000 --- a/src/contexts/Hardware/Vault/VaultAccounts.tsx +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors -// SPDX-License-Identifier: GPL-3.0-only - -import { ellipsisFn, setStateWithRef } from '@w3ux/utils'; -import type { ReactNode } from 'react'; -import { createContext, useContext, useEffect, useRef, useState } from 'react'; -import type { VaultAccount } from '@w3ux/react-connect-kit/types'; -import { useNetwork } from 'contexts/Network'; -import { getLocalVaultAccounts, isLocalNetworkAddress } from '../Utils'; -import type { VaultAccountsContextInterface } from './types'; -import { defaultVaultAccountsContext } from './defaults'; - -export const VaultAccountsContext = - createContext(defaultVaultAccountsContext); - -export const useVaultAccounts = () => useContext(VaultAccountsContext); - -export const VaultAccountsProvider = ({ - children, -}: { - children: ReactNode; -}) => { - const { network } = useNetwork(); - - const [vaultAccounts, seVaultAccountsState] = useState( - getLocalVaultAccounts(network) - ); - const vaultAccountsRef = useRef(vaultAccounts); - - // Check if a Vault address exists in imported addresses. - const vaultAccountExists = (address: string) => - !!getLocalVaultAccounts().find((a) => - isLocalNetworkAddress(network, a, address) - ); - - // Adds a vault account to state and local storage. - const addVaultAccount = ( - address: string, - index: number, - callback?: () => void - ) => { - let newVaultAccounts = getLocalVaultAccounts(); - - if ( - !newVaultAccounts.find((a) => isLocalNetworkAddress(network, a, address)) - ) { - const account = { - address, - network, - name: ellipsisFn(address), - source: 'vault', - index, - }; - - newVaultAccounts = [...newVaultAccounts].concat(account); - localStorage.setItem( - 'polkadot_vault_accounts', - JSON.stringify(newVaultAccounts) - ); - - // store only those accounts on the current network in state. - setStateWithRef( - newVaultAccounts.filter((a) => a.network === network), - seVaultAccountsState, - vaultAccountsRef - ); - - // Handle optional callback function. - if (typeof callback === 'function') { - callback(); - } - - return account; - } - return null; - }; - - const removeVaultAccount = (address: string, callback?: () => void) => { - let newVaultAccounts = getLocalVaultAccounts(); - - newVaultAccounts = newVaultAccounts.filter((a) => { - if (a.address !== address) { - return true; - } - if (a.network !== network) { - return true; - } - return false; - }); - - if (!newVaultAccounts.length) { - localStorage.removeItem('polkadot_vault_accounts'); - } else { - localStorage.setItem( - 'polkadot_vault_accounts', - JSON.stringify(newVaultAccounts) - ); - } - setStateWithRef( - newVaultAccounts.filter((a) => a.network === network), - seVaultAccountsState, - vaultAccountsRef - ); - - // Handle optional callback function. - if (typeof callback === 'function') { - callback(); - } - }; - - const getVaultAccount = (address: string) => { - const localVaultAccounts = getLocalVaultAccounts(); - if (!localVaultAccounts) { - return null; - } - return ( - localVaultAccounts.find((a) => - isLocalNetworkAddress(network, a, address) - ) ?? null - ); - }; - - const renameVaultAccount = (address: string, newName: string) => { - let newVaultAccounts = getLocalVaultAccounts(); - - newVaultAccounts = newVaultAccounts.map((a) => - isLocalNetworkAddress(network, a, address) - ? { - ...a, - name: newName, - } - : a - ); - localStorage.setItem( - 'polkadot_vault_accounts', - JSON.stringify(newVaultAccounts) - ); - setStateWithRef( - newVaultAccounts.filter((a) => a.network === network), - seVaultAccountsState, - vaultAccountsRef - ); - }; - - // Refresh imported vault accounts on network change. - useEffect(() => { - setStateWithRef( - getLocalVaultAccounts(network), - seVaultAccountsState, - vaultAccountsRef - ); - }, [network]); - - return ( - - {children} - - ); -}; diff --git a/src/contexts/Hardware/Vault/defaults.ts b/src/contexts/Hardware/Vault/defaults.ts deleted file mode 100644 index aab24615ba..0000000000 --- a/src/contexts/Hardware/Vault/defaults.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors -// SPDX-License-Identifier: GPL-3.0-only -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */ - -import type { VaultAccountsContextInterface } from './types'; - -export const defaultVaultAccountsContext: VaultAccountsContextInterface = { - vaultAccountExists: (address) => false, - addVaultAccount: (address, index, callback) => null, - removeVaultAccount: (address, callback) => {}, - renameVaultAccount: (address, newName) => {}, - getVaultAccount: (address) => null, - vaultAccounts: [], -}; diff --git a/src/contexts/Hardware/Vault/types.ts b/src/contexts/Hardware/Vault/types.ts deleted file mode 100644 index 01add5b199..0000000000 --- a/src/contexts/Hardware/Vault/types.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors -// SPDX-License-Identifier: GPL-3.0-only - -import type { - LedgerAccount, - VaultAccount, -} from '@w3ux/react-connect-kit/types'; - -export interface VaultAccountsContextInterface { - vaultAccountExists: (address: string) => boolean; - addVaultAccount: ( - address: string, - index: number, - callback?: () => void - ) => LedgerAccount | null; - removeVaultAccount: (address: string, callback?: () => void) => void; - renameVaultAccount: (address: string, newName: string) => void; - getVaultAccount: (address: string) => LedgerAccount | null; - vaultAccounts: VaultAccount[]; -} diff --git a/src/modals/ImportVault/Reader.tsx b/src/modals/ImportVault/Reader.tsx index cc3f2a09a0..157af4bf8d 100644 --- a/src/modals/ImportVault/Reader.tsx +++ b/src/modals/ImportVault/Reader.tsx @@ -4,7 +4,6 @@ import { isValidAddress } from '@w3ux/utils'; import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { useVaultAccounts } from 'contexts/Hardware/Vault/VaultAccounts'; import { usePrompt } from 'contexts/Prompt'; import { QRViewerWrapper } from 'library/Import/Wrappers'; import { QrScanSignature } from 'library/QRCode/ScanSignature'; @@ -13,6 +12,7 @@ import { formatAccountSs58 } from 'contexts/Connect/Utils'; import { useOtherAccounts } from 'contexts/Connect/OtherAccounts'; import type { AnyJson } from 'types'; import { ButtonSecondary } from 'kits/Buttons/ButtonSecondary'; +import { useVaultAccounts } from '@w3ux/react-connect-kit'; export const Reader = () => { const { t } = useTranslation('modals'); diff --git a/src/modals/ImportVault/index.tsx b/src/modals/ImportVault/index.tsx index 888aac9264..94ef953d4e 100644 --- a/src/modals/ImportVault/index.tsx +++ b/src/modals/ImportVault/index.tsx @@ -5,7 +5,6 @@ import { faQrcode } from '@fortawesome/free-solid-svg-icons'; import { Polkicon } from '@w3ux/react-polkicon'; import { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { useVaultAccounts } from 'contexts/Hardware/Vault/VaultAccounts'; import { usePrompt } from 'contexts/Prompt'; import PolkadotVaultSVG from '@w3ux/extension-assets/PolkadotVault.svg?react'; import { Confirm } from 'library/Import/Confirm'; @@ -21,6 +20,7 @@ import { ButtonPrimary } from 'kits/Buttons/ButtonPrimary'; import { ButtonText } from 'kits/Buttons/ButtonText'; import { HardwareAddress } from 'library/Hardware/HardwareAddress'; import { HardwareStatusBar } from 'library/Hardware/HardwareStatusBar'; +import { useVaultAccounts } from '@w3ux/react-connect-kit'; export const ImportVault = () => { const { t } = useTranslation(); diff --git a/yarn.lock b/yarn.lock index 32acedb245..37052a1eb0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2675,9 +2675,9 @@ __metadata: languageName: node linkType: hard -"@w3ux/react-connect-kit@npm:0.1.8": - version: 0.1.8 - resolution: "@w3ux/react-connect-kit@npm:0.1.8" +"@w3ux/react-connect-kit@npm:^0.1.12": + version: 0.1.12 + resolution: "@w3ux/react-connect-kit@npm:0.1.12" dependencies: "@chainsafe/metamask-polkadot-adapter": "npm:^0.6.0" "@polkadot/util": "npm:^12.6.2" @@ -2685,7 +2685,7 @@ __metadata: "@w3ux/extension-assets": "npm:^0.2.3" "@w3ux/hooks": "npm:^0.0.3" "@w3ux/utils": "npm:^0.0.2" - checksum: 10c0/aabfedb3736f4a17a2afcf4f49f22cbcb2fd01157e384ceae545fdec2d668318ea5d1e966db738a01ea35beefa54c5e094c5bfdcd807de59cdfd0085191efe93 + checksum: 10c0/244f3f14e50c301fb4df9df8447be8e4c2ba1340866e583a65c95ecdb8c41a4abf66b28c62abd7da5f30c4bb9a40470f2d93f1cd486318eac54d0913f898c83a languageName: node linkType: hard @@ -6629,7 +6629,7 @@ __metadata: "@vitejs/plugin-react-swc": "npm:^3.6.0" "@w3ux/extension-assets": "npm:0.2.6" "@w3ux/hooks": "npm:^0.0.3" - "@w3ux/react-connect-kit": "npm:0.1.8" + "@w3ux/react-connect-kit": "npm:^0.1.12" "@w3ux/react-odometer": "npm:^0.0.3" "@w3ux/react-polkicon": "npm:^0.0.2" "@w3ux/utils": "npm:^0.0.2" From a787af41013b83259eb35819a022cab56f64daba Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 15 Apr 2024 19:31:16 +0700 Subject: [PATCH 2/2] flatten Hardware/Ledger --- src/Providers.tsx | 2 +- src/config/ledger.ts | 2 +- src/contexts/{Hardware => LedgerHardware}/Utils.tsx | 2 +- .../{Hardware/Ledger => LedgerHardware}/defaults.ts | 0 .../LedgerHardware.tsx => LedgerHardware/index.tsx} | 2 +- .../{Hardware/Ledger => LedgerHardware}/static/ledger.ts | 0 .../{Hardware/Ledger => LedgerHardware}/types.ts | 0 src/hooks/useSubmitExtrinsic/index.tsx | 2 +- src/library/SubmitTx/ManualSign/Ledger/Submit.tsx | 4 ++-- src/library/SubmitTx/ManualSign/Ledger/index.tsx | 6 +++--- src/modals/ImportLedger/Addresses.tsx | 4 ++-- src/modals/ImportLedger/Manage.tsx | 4 ++-- src/modals/ImportLedger/Reset.tsx | 4 ++-- src/modals/ImportLedger/Splash.tsx | 2 +- src/modals/ImportLedger/index.tsx | 9 ++++++--- src/modals/ManagePool/index.tsx | 2 +- src/modals/UnlockChunks/index.tsx | 2 +- 17 files changed, 25 insertions(+), 22 deletions(-) rename src/contexts/{Hardware => LedgerHardware}/Utils.tsx (97%) rename src/contexts/{Hardware/Ledger => LedgerHardware}/defaults.ts (100%) rename src/contexts/{Hardware/Ledger/LedgerHardware.tsx => LedgerHardware/index.tsx} (99%) rename src/contexts/{Hardware/Ledger => LedgerHardware}/static/ledger.ts (100%) rename src/contexts/{Hardware/Ledger => LedgerHardware}/types.ts (100%) diff --git a/src/Providers.tsx b/src/Providers.tsx index 385aebaeb4..80e9005171 100644 --- a/src/Providers.tsx +++ b/src/Providers.tsx @@ -11,7 +11,7 @@ import { } from '@w3ux/react-connect-kit'; import { FastUnstakeProvider } from 'contexts/FastUnstake'; import { FiltersProvider } from 'contexts/Filters'; -import { LedgerHardwareProvider } from 'contexts/Hardware/Ledger/LedgerHardware'; +import { LedgerHardwareProvider } from 'contexts/LedgerHardware'; import { HelpProvider } from 'contexts/Help'; import { MenuProvider } from 'contexts/Menu'; import { MigrateProvider } from 'contexts/Migrate'; diff --git a/src/config/ledger.ts b/src/config/ledger.ts index 01692b9d59..6f16327e24 100644 --- a/src/config/ledger.ts +++ b/src/config/ledger.ts @@ -1,7 +1,7 @@ // Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { LedgerApp } from 'contexts/Hardware/Ledger/types'; +import type { LedgerApp } from 'contexts/LedgerHardware/types'; import KusamaSVG from 'img/appIcons/kusama.svg?react'; import PolkadotSVG from 'img/appIcons/polkadot.svg?react'; diff --git a/src/contexts/Hardware/Utils.tsx b/src/contexts/LedgerHardware/Utils.tsx similarity index 97% rename from src/contexts/Hardware/Utils.tsx rename to src/contexts/LedgerHardware/Utils.tsx index 19fdaa673a..c2f3a84d7d 100644 --- a/src/contexts/Hardware/Utils.tsx +++ b/src/contexts/LedgerHardware/Utils.tsx @@ -3,7 +3,7 @@ import { localStorageOrDefault } from '@w3ux/utils'; import { LedgerApps } from 'config/ledger'; -import type { LedgerAddress } from './Ledger/types'; +import type { LedgerAddress } from './types'; // Ledger error keyed by type of error. const LedgerErrorsByType = { diff --git a/src/contexts/Hardware/Ledger/defaults.ts b/src/contexts/LedgerHardware/defaults.ts similarity index 100% rename from src/contexts/Hardware/Ledger/defaults.ts rename to src/contexts/LedgerHardware/defaults.ts diff --git a/src/contexts/Hardware/Ledger/LedgerHardware.tsx b/src/contexts/LedgerHardware/index.tsx similarity index 99% rename from src/contexts/Hardware/Ledger/LedgerHardware.tsx rename to src/contexts/LedgerHardware/index.tsx index 4e27017821..c8669c361f 100644 --- a/src/contexts/Hardware/Ledger/LedgerHardware.tsx +++ b/src/contexts/LedgerHardware/index.tsx @@ -7,7 +7,7 @@ import { createContext, useContext, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import type { AnyJson, MaybeString } from 'types'; import { useApi } from 'contexts/Api'; -import { getLedgerErrorType } from '../Utils'; +import { getLedgerErrorType } from './Utils'; import { defaultFeedback, defaultLedgerHardwareContext } from './defaults'; import type { FeedbackMessage, diff --git a/src/contexts/Hardware/Ledger/static/ledger.ts b/src/contexts/LedgerHardware/static/ledger.ts similarity index 100% rename from src/contexts/Hardware/Ledger/static/ledger.ts rename to src/contexts/LedgerHardware/static/ledger.ts diff --git a/src/contexts/Hardware/Ledger/types.ts b/src/contexts/LedgerHardware/types.ts similarity index 100% rename from src/contexts/Hardware/Ledger/types.ts rename to src/contexts/LedgerHardware/types.ts diff --git a/src/hooks/useSubmitExtrinsic/index.tsx b/src/hooks/useSubmitExtrinsic/index.tsx index 5ca982aed9..7f67d67013 100644 --- a/src/hooks/useSubmitExtrinsic/index.tsx +++ b/src/hooks/useSubmitExtrinsic/index.tsx @@ -6,7 +6,7 @@ import { useEffect, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { DappName, ManualSigners } from 'consts'; import { useApi } from 'contexts/Api'; -import { useLedgerHardware } from 'contexts/Hardware/Ledger/LedgerHardware'; +import { useLedgerHardware } from 'contexts/LedgerHardware'; import { useTxMeta } from 'contexts/TxMeta'; import type { AnyApi, AnyJson } from 'types'; import { useActiveAccounts } from 'contexts/ActiveAccounts'; diff --git a/src/library/SubmitTx/ManualSign/Ledger/Submit.tsx b/src/library/SubmitTx/ManualSign/Ledger/Submit.tsx index 4f95c80416..9c82197d4e 100644 --- a/src/library/SubmitTx/ManualSign/Ledger/Submit.tsx +++ b/src/library/SubmitTx/ManualSign/Ledger/Submit.tsx @@ -6,8 +6,8 @@ import { faSquarePen } from '@fortawesome/free-solid-svg-icons'; import type { LedgerAccount } from '@w3ux/react-connect-kit/types'; import { useActiveAccounts } from 'contexts/ActiveAccounts'; import { useImportedAccounts } from 'contexts/Connect/ImportedAccounts'; -import { useLedgerHardware } from 'contexts/Hardware/Ledger/LedgerHardware'; -import { getLedgerApp } from 'contexts/Hardware/Utils'; +import { useLedgerHardware } from 'contexts/LedgerHardware'; +import { getLedgerApp } from 'contexts/LedgerHardware/Utils'; import { useNetwork } from 'contexts/Network'; import { useTxMeta } from 'contexts/TxMeta'; import { ButtonSubmit } from 'kits/Buttons/ButtonSubmit'; diff --git a/src/library/SubmitTx/ManualSign/Ledger/index.tsx b/src/library/SubmitTx/ManualSign/Ledger/index.tsx index 1b2701cb0f..2c4172fce3 100644 --- a/src/library/SubmitTx/ManualSign/Ledger/index.tsx +++ b/src/library/SubmitTx/ManualSign/Ledger/index.tsx @@ -5,8 +5,8 @@ import { useEffectIgnoreInitial } from '@w3ux/hooks'; import type { ReactNode } from 'react'; import { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { useLedgerHardware } from 'contexts/Hardware/Ledger/LedgerHardware'; -import type { LedgerResponse } from 'contexts/Hardware/Ledger/types'; +import { useLedgerHardware } from 'contexts/LedgerHardware'; +import type { LedgerResponse } from 'contexts/LedgerHardware/types'; import { useHelp } from 'contexts/Help'; import { useTxMeta } from 'contexts/TxMeta'; import { EstimatedTxFee } from 'library/EstimatedTxFee'; @@ -15,7 +15,7 @@ import { useImportedAccounts } from 'contexts/Connect/ImportedAccounts'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCircleExclamation } from '@fortawesome/free-solid-svg-icons'; import { useNetwork } from 'contexts/Network'; -import { getLedgerApp } from 'contexts/Hardware/Utils'; +import { getLedgerApp } from 'contexts/LedgerHardware/Utils'; import type { SubmitProps } from '../../types'; import { Submit } from './Submit'; import { ButtonHelp } from 'kits/Buttons/ButtonHelp'; diff --git a/src/modals/ImportLedger/Addresses.tsx b/src/modals/ImportLedger/Addresses.tsx index 1b4f9f0abb..abf4e5f3cc 100644 --- a/src/modals/ImportLedger/Addresses.tsx +++ b/src/modals/ImportLedger/Addresses.tsx @@ -5,8 +5,8 @@ import { faArrowDown } from '@fortawesome/free-solid-svg-icons'; import { Polkicon } from '@w3ux/react-polkicon'; import { ellipsisFn, unescape } from '@w3ux/utils'; import { useTranslation } from 'react-i18next'; -import { useLedgerHardware } from 'contexts/Hardware/Ledger/LedgerHardware'; -import { getLocalLedgerAddresses } from 'contexts/Hardware/Utils'; +import { useLedgerHardware } from 'contexts/LedgerHardware'; +import { getLocalLedgerAddresses } from 'contexts/LedgerHardware/Utils'; import { usePrompt } from 'contexts/Prompt'; import { Confirm } from 'library/Import/Confirm'; import { Remove } from 'library/Import/Remove'; diff --git a/src/modals/ImportLedger/Manage.tsx b/src/modals/ImportLedger/Manage.tsx index 9cd881e452..e550f07cde 100644 --- a/src/modals/ImportLedger/Manage.tsx +++ b/src/modals/ImportLedger/Manage.tsx @@ -2,8 +2,8 @@ // SPDX-License-Identifier: GPL-3.0-only import { useTranslation } from 'react-i18next'; -import { useLedgerHardware } from 'contexts/Hardware/Ledger/LedgerHardware'; -import { getLedgerApp } from 'contexts/Hardware/Utils'; +import { useLedgerHardware } from 'contexts/LedgerHardware'; +import { getLedgerApp } from 'contexts/LedgerHardware/Utils'; import { useHelp } from 'contexts/Help'; import { usePrompt } from 'contexts/Prompt'; import LedgerSVG from '@w3ux/extension-assets/LedgerSquare.svg?react'; diff --git a/src/modals/ImportLedger/Reset.tsx b/src/modals/ImportLedger/Reset.tsx index 2c52d71bf7..f55c31ee42 100644 --- a/src/modals/ImportLedger/Reset.tsx +++ b/src/modals/ImportLedger/Reset.tsx @@ -2,8 +2,8 @@ // SPDX-License-Identifier: GPL-3.0-only import { useTranslation } from 'react-i18next'; -import { getLocalLedgerAddresses } from 'contexts/Hardware/Utils'; -import type { LedgerAddress } from 'contexts/Hardware/Ledger/types'; +import { getLocalLedgerAddresses } from 'contexts/LedgerHardware/Utils'; +import type { LedgerAddress } from 'contexts/LedgerHardware/types'; import { usePrompt } from 'contexts/Prompt'; import { ConfirmWrapper } from 'library/Import/Wrappers'; import type { AnyJson } from 'types'; diff --git a/src/modals/ImportLedger/Splash.tsx b/src/modals/ImportLedger/Splash.tsx index 253e3afd1a..2c249b80d4 100644 --- a/src/modals/ImportLedger/Splash.tsx +++ b/src/modals/ImportLedger/Splash.tsx @@ -4,7 +4,7 @@ import { faChevronLeft } from '@fortawesome/free-solid-svg-icons'; import { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { useLedgerHardware } from 'contexts/Hardware/Ledger/LedgerHardware'; +import { useLedgerHardware } from 'contexts/LedgerHardware'; import { useHelp } from 'contexts/Help'; import { useTheme } from 'contexts/Themes'; import LedgerLogoSvg from '@w3ux/extension-assets/Ledger.svg?react'; diff --git a/src/modals/ImportLedger/index.tsx b/src/modals/ImportLedger/index.tsx index 7c4b05e3e0..d747346347 100644 --- a/src/modals/ImportLedger/index.tsx +++ b/src/modals/ImportLedger/index.tsx @@ -4,12 +4,15 @@ import { ellipsisFn, setStateWithRef } from '@w3ux/utils'; import type { FC } from 'react'; import { useEffect, useRef, useState } from 'react'; -import { useLedgerHardware } from 'contexts/Hardware/Ledger/LedgerHardware'; -import { getLedgerApp, getLocalLedgerAddresses } from 'contexts/Hardware/Utils'; +import { useLedgerHardware } from 'contexts/LedgerHardware'; +import { + getLedgerApp, + getLocalLedgerAddresses, +} from 'contexts/LedgerHardware/Utils'; import type { LedgerAddress, LedgerResponse, -} from 'contexts/Hardware/Ledger/types'; +} from 'contexts/LedgerHardware/types'; import type { AnyJson } from 'types'; import { useEffectIgnoreInitial } from '@w3ux/hooks'; import { useNetwork } from 'contexts/Network'; diff --git a/src/modals/ManagePool/index.tsx b/src/modals/ManagePool/index.tsx index 3d36771cd1..fc447ef30b 100644 --- a/src/modals/ManagePool/index.tsx +++ b/src/modals/ManagePool/index.tsx @@ -7,7 +7,7 @@ import { useActivePool } from 'contexts/Pools/ActivePool'; import { Title } from 'library/Modal/Title'; import { useTxMeta } from 'contexts/TxMeta'; import { useOverlay } from 'kits/Overlay/Provider'; -import { useLedgerHardware } from 'contexts/Hardware/Ledger/LedgerHardware'; +import { useLedgerHardware } from 'contexts/LedgerHardware'; import { Forms } from './Forms'; import { Tasks } from './Tasks'; import { ModalSection } from 'kits/Overlay/structure/ModalSection'; diff --git a/src/modals/UnlockChunks/index.tsx b/src/modals/UnlockChunks/index.tsx index 29c29167b3..d4c46823df 100644 --- a/src/modals/UnlockChunks/index.tsx +++ b/src/modals/UnlockChunks/index.tsx @@ -10,7 +10,7 @@ import { Title } from 'library/Modal/Title'; import { useTxMeta } from 'contexts/TxMeta'; import { useOverlay } from 'kits/Overlay/Provider'; import { useActiveAccounts } from 'contexts/ActiveAccounts'; -import { useLedgerHardware } from 'contexts/Hardware/Ledger/LedgerHardware'; +import { useLedgerHardware } from 'contexts/LedgerHardware'; import { Forms } from './Forms'; import { Overview } from './Overview'; import type { UnlockChunk } from 'contexts/Balances/types';