Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lw 9170 multi wallet integration #892

Merged
merged 27 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9448474
fix(ui): use correct derivation path for displaying accounts
mkazlauskas Jan 29, 2024
d1e5eff
feat(ui): disable account delete btn for active or the only account
mkazlauskas Jan 31, 2024
9688246
feat(ui): add onActivateClick handler for profile dropdown
mkazlauskas Feb 1, 2024
64e7742
fix(ui): do not fire onClick in profile dropdown when clicking on arrow
mkazlauskas Feb 14, 2024
44ca3ad
fix(core): start from account #0 in select account step
mkazlauskas Feb 14, 2024
04816ed
fix(extension): clear background page once finished with create walle…
mkazlauskas Feb 14, 2024
b08509c
feat(extension): wire up multi-account components
mkazlauskas Jan 29, 2024
4089f81
feat(extension): wire up add wallet components
mkazlauskas Feb 14, 2024
447bdd5
fix(extension): connect to hw device asap when adding account
mkazlauskas Feb 20, 2024
0796af4
fix: display correct wallet type icon
mkazlauskas Feb 21, 2024
6ffd3a0
feat(extension): do not copy address when clicking on active wallet
mkazlauskas Feb 22, 2024
d775933
feat(extension): close dropdown and show toast when activating wallet…
mkazlauskas Feb 22, 2024
938f9b7
feat: disable enabling hw accounts in popup mode
mkazlauskas Feb 22, 2024
ee1cbe3
feat(ui): add colorScheme option to ExtraSmall
mkazlauskas Feb 22, 2024
16ed3b9
feat: replace edit/delete buttons with a single Disable button
mkazlauskas Feb 22, 2024
8b43216
feat(extension): activate account automatically after enabling it
mkazlauskas Feb 22, 2024
9365312
fix(extension): align wallet sync status label
mkazlauskas Feb 22, 2024
669a6af
feat(extension): show toast when adding a duplicate wallet
mkazlauskas Feb 22, 2024
5a91006
fix(extension): show correct wallet name after activating wallet
mkazlauskas Feb 22, 2024
5948117
fix(extension): show loader when activating a wallet or account
mkazlauskas Feb 22, 2024
1b679e4
fix(extension): use cjs import for hardware-ledger
mkazlauskas Feb 23, 2024
b0c01b0
fix: remove all relative imports from cardano-sdk
mkazlauskas Feb 23, 2024
44d7ffb
fix(extension): connect trezor device before exporting xpub
mkazlauskas Feb 23, 2024
d899298
chore: bump sdk packages
mkazlauskas Feb 23, 2024
c22f8c2
chore: build service worker script in development mode
mkazlauskas Feb 23, 2024
e4ed066
fix(extension): display loader in popup view while switching wallet/a…
mkazlauskas Feb 23, 2024
bd11e2e
test(extension): mock initializeTrezorTransport method
pczeglik-iohk Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions apps/browser-extension-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
},
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@cardano-sdk/cardano-services-client": "0.17.6",
"@cardano-sdk/core": "0.28.2",
"@cardano-sdk/dapp-connector": "0.12.9",
"@cardano-sdk/input-selection": "0.12.20",
"@cardano-sdk/tx-construction": "0.17.10",
"@cardano-sdk/cardano-services-client": "0.17.7",
"@cardano-sdk/core": "0.28.3",
"@cardano-sdk/dapp-connector": "0.12.10",
"@cardano-sdk/input-selection": "0.12.21",
"@cardano-sdk/tx-construction": "0.17.11",
"@cardano-sdk/util": "0.15.0",
"@cardano-sdk/wallet": "0.34.2",
"@cardano-sdk/web-extension": "0.24.5",
"@cardano-sdk/wallet": "0.34.3",
"@cardano-sdk/web-extension": "0.24.6",
"@emurgo/cip14-js": "~3.0.1",
"@koralabs/handles-public-api-interfaces": "^1.6.6",
"@lace/cardano": "0.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React from 'react';
import cn from 'classnames';
import { Dropdown } from 'antd';
import { Button } from '@lace/common';
Expand All @@ -14,15 +14,20 @@ import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
import { ProfileDropdown } from '@lace/ui';
import { useGetHandles } from '@hooks';
import { getAssetImageUrl } from '@src/utils/get-asset-image-url';
import { getActiveWalletSubtitle } from '@src/utils/get-wallet-subtitle';
import { getUiWalletType } from '@src/utils/get-ui-wallet-type';

export interface DropdownMenuProps {
isPopup?: boolean;
}

export const DropdownMenu = ({ isPopup }: DropdownMenuProps): React.ReactElement => {
const analytics = useAnalyticsContext();
const { walletInfo } = useWalletStore();
const [open, setOpen] = useState(false);
const {
cardanoWallet,
walletUI: { isDropdownMenuOpen },
setIsDropdownMenuOpen
} = useWalletStore();
const [handle] = useGetHandles();
const handleImage = handle?.profilePic;
const Chevron = isPopup ? ChevronSmall : ChevronNormal;
Expand All @@ -32,34 +37,37 @@ export const DropdownMenu = ({ isPopup }: DropdownMenuProps): React.ReactElement
};

const handleDropdownState = (openDropdown: boolean) => {
setOpen(openDropdown);
setIsDropdownMenuOpen(openDropdown);
if (openDropdown) {
sendAnalyticsEvent(PostHogAction.UserWalletProfileIconClick);
}
};

const walletName = cardanoWallet.source.wallet.metadata.name;

return (
<Dropdown
destroyPopupOnHide
onOpenChange={handleDropdownState}
overlay={<DropdownMenuOverlay isPopup={isPopup} sendAnalyticsEvent={sendAnalyticsEvent} />}
placement="bottomRight"
open={isDropdownMenuOpen}
trigger={['click']}
>
{process.env.USE_MULTI_WALLET === 'true' ? (
<div className={styles.profileDropdownTrigger}>
<ProfileDropdown.Trigger
title={walletInfo.name}
subtitle="Account #0"
title={walletName}
subtitle={getActiveWalletSubtitle(cardanoWallet.source.account)}
profile={
handleImage
? {
fallback: walletInfo.name,
fallback: walletName,
imageSrc: getAssetImageUrl(handleImage)
}
: undefined
}
type={process.env.USE_SHARED_WALLET === 'true' ? 'shared' : 'cold'}
type={getUiWalletType(cardanoWallet.source.wallet.type)}
id="menu"
/>
</div>
Expand All @@ -71,7 +79,7 @@ export const DropdownMenu = ({ isPopup }: DropdownMenuProps): React.ReactElement
data-testid="header-menu-button"
>
<span className={cn(styles.content, { [styles.isPopup]: isPopup })}>
<UserAvatar walletName={walletInfo.name} isPopup={isPopup} />
<UserAvatar walletName={walletName} isPopup={isPopup} />
<Chevron
className={cn(styles.chevron, { [styles.open]: open })}
data-testid={`chevron-${open ? 'up' : 'down'}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
}

.walletStatusInfo {
margin-left: 8px;
cursor: default;
display: flex;
}
Expand All @@ -73,46 +74,51 @@
border-radius: 12px !important;
background-color: var(--bg-color-container, #ffffff) !important;
color: var(--text-color-primary);

&:hover {
background: var(--light-mode-light-grey, var(--dark-mode-mid-grey, #efefef)) !important;
}

&.cta {
cursor: pointer;
}
}

.menuItemTheme {
:global {
button.ant-switch {
height: size_unit(3);
width: size_unit(5.5);
}

.ant-switch > div.ant-switch-handle {
.ant-switch>div.ant-switch-handle {
height: size_unit(2.5);
width: size_unit(2.5);
}

.ant-switch > span.ant-switch-inner svg {
.ant-switch>span.ant-switch-inner svg {
margin-top: 1px;
}

.ant-switch.ant-switch-checked > span.ant-switch-inner {
.ant-switch.ant-switch-checked>span.ant-switch-inner {
margin: 0 size_unit(35) 0 size_unit(0.5);
}

.ant-switch.ant-switch-checked > div.ant-switch-handle {
.ant-switch.ant-switch-checked>div.ant-switch-handle {
left: calc(100% - 20px - 2px);
}
}

display: flex;
justify-content: space-between !important;

&:hover {
background: transparent !important;
}
}
}
}

.separator {
display: flex;
height: 1.5px;
Expand Down Expand Up @@ -141,12 +147,14 @@
display: flex;
align-items: center;
justify-content: center;

span {
color: var(--dark-mode-mid-black, var(--text-color-white, #ffffff));
font-size: var(--body);
text-transform: uppercase;
font-weight: 700;
}

.avatar {
font-size: size_unit(4);
cursor: pointer;
Expand All @@ -156,6 +164,7 @@
height: 26px;
width: 26px;
}

.userAvatarImage {
border-radius: 30px;
}
Expand All @@ -178,7 +187,8 @@
font-size: 16px;
}

.popUpContainer, .extendedContainer {
.popUpContainer,
.extendedContainer {
@include scroll-bar-style;
overflow-y: scroll;
margin: size_unit(1) size_unit(1) size_unit(1) 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { WalletAccounts } from './components/WalletAccounts';
import { AddSharedWalletLink } from '@components/MainMenu/DropdownMenuOverlay/components/AddSharedWalletLink';
import { useWalletStore } from '@stores';
import classNames from 'classnames';
import { AnyBip32Wallet } from '@cardano-sdk/web-extension';
import { Wallet } from '@lace/cardano';

interface Props extends MenuProps {
isPopup?: boolean;
Expand All @@ -35,9 +37,10 @@ export const DropdownMenuOverlay: VFC<Props> = ({
...props
}): React.ReactElement => {
const [currentSection, setCurrentSection] = useState<Sections>(Sections.Main);
const { environmentName } = useWalletStore();
const { environmentName, setManageAccountsWallet } = useWalletStore();

const openWalletAccounts = () => {
const openWalletAccounts = (wallet: AnyBip32Wallet<Wallet.WalletMetadata, Wallet.AccountMetadata>) => {
setManageAccountsWallet(wallet);
setCurrentSection(Sections.WalletAccounts);
};

Expand Down
Loading
Loading