diff --git a/apps/frontend/src/pages/Setup/NewVault/index.tsx b/apps/frontend/src/pages/Setup/NewVault/index.tsx index 913e9c09..42400100 100644 --- a/apps/frontend/src/pages/Setup/NewVault/index.tsx +++ b/apps/frontend/src/pages/Setup/NewVault/index.tsx @@ -1,4 +1,5 @@ -import React, { useState, useRef, useContext } from 'react'; +import React, { useState, useRef, useContext, useEffect } from 'react'; +import { useLocation } from 'react-router-dom'; import styled from 'styled-components'; import { decode } from 'bs58check'; import BarcodeScannerComponent from 'react-webcam-barcode-scanner'; @@ -54,6 +55,20 @@ const NewVaultScreen = ({ setStep, newAccount, setNewAccount }: Props) => { const [importedDevices, setImportedDevices] = useState( newAccount.extendedPublicKeys ); + const location = useLocation(); + + useEffect(() => { + const paramObject = new URLSearchParams(location.search); + const fingerprint = paramObject.get('fingerprint'); + if (fingerprint) { + const configCopy = { ...newAccount }; + configCopy.extendedPublicKeys = newAccount.extendedPublicKeys.filter( + (item) => item.parentFingerprint !== fingerprint + ); + setImportedDevices(configCopy.extendedPublicKeys); + setNewAccount(configCopy); + } + }, [location.search]); const { platform } = useContext(PlatformContext); const { currentBitcoinNetwork } = useContext(ConfigContext); diff --git a/apps/frontend/src/pages/Setup/index.tsx b/apps/frontend/src/pages/Setup/index.tsx index 3dc02a77..265e8b23 100644 --- a/apps/frontend/src/pages/Setup/index.tsx +++ b/apps/frontend/src/pages/Setup/index.tsx @@ -1,6 +1,6 @@ -import React, { useState, useEffect } from 'react'; +import React, { useContext, useState, useEffect } from 'react'; import { Transition } from '@headlessui/react'; -import { Network } from 'bitcoinjs-lib'; +import { useLocation } from 'react-router-dom'; import TransitionSlideLeft from './TransitionSlideLeft'; @@ -13,12 +13,15 @@ import NewHardwareWalletScreen from './NewHardwareWalletScreen'; import NewLightningScreen from './NewLightningScreen'; import StepGroups from './Steps'; +import { AccountMapContext } from 'src/context'; + import { VaultConfig, AddressType, OnChainConfig, OnChainConfigWithoutId, - LightningConfig + LightningConfig, + LilyOnchainAccount } from '@lily/types'; import { ChannelBalanceResponse, GetInfoResponse } from '@lily-technologies/lnrpc'; @@ -45,6 +48,8 @@ const Setup = ({ currentBlockHeight }: Props) => { const [tempLightningState, setTempLightningState] = useState< GetInfoResponse & ChannelBalanceResponse >(); + const { currentAccount } = useContext(AccountMapContext); + const location = useLocation(); const [newAccount, setNewAccount] = useState( EMPTY_NEW_VAULT @@ -57,6 +62,14 @@ const Setup = ({ currentBlockHeight }: Props) => { } }, [step]); + useEffect(() => { + if (location.search) { + setSetupOption(1); + setNewAccount(currentAccount.config); + setStep(2); + } + }, [location.search]); + const importAccountFromFile = (vaultConfig: VaultConfig) => { if (vaultConfig.type === 'onchain' && vaultConfig.quorum.totalSigners > 1) { try { @@ -75,7 +88,7 @@ const Setup = ({ currentBlockHeight }: Props) => { return (
-
+
{ + const history = useHistory(); return (
@@ -59,6 +60,12 @@ const DeviceDetailsHeader = ({ extendedPublicKey, hideActionButtons }: Props) =>