Skip to content

Commit

Permalink
feaT: CP-9487 CP-9473 ledger flow (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvava authored Dec 5, 2024
1 parent 47956b7 commit 801b537
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/background/runtime/BackgroundRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import { ConnectionService } from '@src/background/connections/ConnectionService
import { singleton } from 'tsyringe';
import { LockService } from '@src/background/services/lock/LockService';
import { OnboardingService } from '@src/background/services/onboarding/OnboardingService';
import { BridgeService } from '@src/background/services/bridge/BridgeService';
import { ModuleManager } from '../vmModules/ModuleManager';
import { BridgeService } from '../services/bridge/BridgeService';

@singleton()
export class BackgroundRuntime {
constructor(
private connectionService: ConnectionService,
private lockService: LockService,
private onboardingService: OnboardingService,
// we try to fetch the bridge configs as soon as possible
private bridgeService: BridgeService,
private moduleManager: ModuleManager
) {}
Expand Down
5 changes: 1 addition & 4 deletions src/components/ledger/LedgerConnector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,7 @@ export function LedgerConnector({
}}
>
<Divider flexItem />
<DerivedAddresses
addresses={addresses}
hideLoadinSkeleton={pathSpec === DerivationPath.BIP44}
/>
<DerivedAddresses addresses={addresses} />
</Stack>
)}
</Stack>
Expand Down
1 change: 1 addition & 0 deletions src/localization/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
"Click close below.": "Click close below.",
"Click on the 'Get Signature' button after signing the transaction with your Keystone device.": "Click on the 'Get Signature' button after signing the transaction with your Keystone device.",
"Click on the “Scan” button at the bottom to scan the QR code displayed on the Keystone device.": "Click on the “Scan” button at the bottom to scan the QR code displayed on the Keystone device.",
"Clicking the cancel button will close the tab and open the extension for you. If the extension doesn’t open automatically, please open it manually.": "Clicking the cancel button will close the tab and open the extension for you. If the extension doesn’t open automatically, please open it manually.",
"Close": "Close",
"Closing the settings menu will require you to restart the 2 day waiting period.": "Closing the settings menu will require you to restart the 2 day waiting period.",
"Code": "Code",
Expand Down
44 changes: 37 additions & 7 deletions src/pages/Accounts/AddWalletWithLedger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ExternalLinkIcon,
Grid,
Stack,
Tooltip,
Typography,
toast,
useTheme,
Expand Down Expand Up @@ -34,6 +35,7 @@ import { useErrorMessage } from '@src/hooks/useErrorMessage';
import { useLedgerContext } from '@src/contexts/LedgerProvider';
import { Overlay } from '@src/components/common/Overlay';
import { AppBackground } from '@src/components/common/AppBackground';
import browser from 'webextension-polyfill';

enum Step {
Import,
Expand Down Expand Up @@ -221,7 +223,13 @@ export function AddWalletWithLedger() {
'Please close this tab and open the Core Browser Extension to see the newly imported wallet.'
)}
</Typography>
<Button onClick={window.close} sx={{ width: '50%' }}>
<Button
onClick={() => {
browser.action.openPopup();
window.close();
}}
sx={{ width: '50%' }}
>
{t('Close')}
</Button>
</Stack>
Expand Down Expand Up @@ -310,12 +318,34 @@ export function AddWalletWithLedger() {
/>
</Stack>
<Stack sx={{ p: 2, mb: 2, rowGap: 1 }}>
<Button
disabled={!hasPublicKeys}
onClick={() => setStep(Step.Name)}
>
{t('Next')}
</Button>
<Stack sx={{ flexDirection: 'row', columnGap: 2 }}>
<Stack sx={{ width: '50%' }}>
<Tooltip
title={t(
'Clicking the cancel button will close the tab and open the extension for you. If the extension doesn’t open automatically, please open it manually.'
)}
>
<Button
color="secondary"
onClick={() => {
browser.action.openPopup();
window.close();
}}
fullWidth
>
{t('Cancel')}
</Button>
</Tooltip>
</Stack>
<Button
disabled={!hasPublicKeys}
onClick={() => setStep(Step.Name)}
sx={{ width: '50%' }}
fullWidth
>
{t('Next')}
</Button>
</Stack>
<LedgerLiveSupportButton />
</Stack>
</Stack>
Expand Down
2 changes: 0 additions & 2 deletions src/pages/Accounts/components/AccountsActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ export const AccountsActionButton = ({
browser.tabs.create({
url: `/fullscreen.html#/accounts/add-wallet/ledger`,
});

// history.push('/accounts/add-wallet/ledger');
}, [capture]);

const goToWalletConnectScreen = useCallback(() => {
Expand Down
8 changes: 7 additions & 1 deletion src/pages/Onboarding/components/DerivedAddresses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ import {
useTheme,
Tooltip,
} from '@avalabs/core-k2-components';
import { useMemo } from 'react';

interface DerivedAddressesProps {
addresses: AddressType[];
hideLoadinSkeleton?: boolean;
}
export function DerivedAddresses({ addresses }: DerivedAddressesProps) {
const theme = useTheme();
const { t } = useTranslation();
const hasBalance = useMemo(() => {
return addresses.find((address) => address.balance !== '0');
}, [addresses]);

return (
<Card
Expand All @@ -37,6 +40,9 @@ export function DerivedAddresses({ addresses }: DerivedAddressesProps) {
</Typography>
<Stack alignItems="space-between" divider={<Divider flexItem />}>
{addresses.map((addressData, index) => {
if (hasBalance && addressData.balance === '0') {
return;
}
const explorerLink = getAvalancheAddressLink(addressData.address);

return (
Expand Down

0 comments on commit 801b537

Please sign in to comment.