Skip to content

Commit f14569b

Browse files
committed
feat: add event send
1 parent 9510806 commit f14569b

File tree

3 files changed

+81
-80
lines changed

3 files changed

+81
-80
lines changed

features/ledger/connector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const ledgerConnector = () =>
7575
currentChainId = chainId;
7676
const chain = config.chains.find((c) => c.id === chainId);
7777
if (!chain) throw new Error('Chain not configured');
78+
config.emitter.emit('change', { chainId });
7879
return chain;
7980
},
8081
};

features/safe-sdk/services/ExtendedSafeApiKit.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export class ExtendedSafeApiKit {
4343
* Get Safe balances with fiat conversion
4444
*/
4545
async getSafeBalances(safeAddress: string): Promise<SafeBalanceResponse> {
46-
console.log('getSafeBalances', safeAddress, `${this.#txServiceBaseUrl}/v2/safes/${safeAddress}/balances/`);
4746
return this.#api({
4847
url: `${this.#txServiceBaseUrl}/v2/safes/${safeAddress}/balances/`,
4948
method: HttpMethod.Get,

features/wallet/components/WalletSidebarItem.tsx

Lines changed: 80 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useEffect, useState } from 'react';
22
import { useAccount, useDisconnect, useSwitchChain, useChainId } from 'wagmi';
33
import LedgerConnectDialog from '@/components/LedgerConnectDialog';
44

5-
type TokenSymbol = string;
65
import { EllipsisVertical, Wallet } from 'lucide-react';
76
import {
87
DropdownMenu,
@@ -19,7 +18,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
1918

2019
interface Account {
2120
address: string;
22-
balance: Record<TokenSymbol, string> | null;
21+
balance: Record<string, string> | null;
2322
ens: { name: string | undefined; avatar: string | undefined };
2423
}
2524

@@ -44,84 +43,86 @@ export default function WalletSidebarItem({ className }: { className?: string })
4443
}, [address]);
4544

4645
return (
47-
<DropdownMenu>
48-
<DropdownMenuTrigger asChild>
49-
{address && account ? (
50-
<SidebarMenuButton className='h-12'>
51-
<Avatar className='rounded-lg'>
52-
<AvatarImage src='https://github.com/evilrabbit.png' alt='@evilrabbit' />
53-
<AvatarFallback>ER</AvatarFallback>
54-
</Avatar>
55-
<div>
56-
<p className='text-sm font-medium'>
57-
{account.ens?.name || `${address.slice(0, 6)}...${address.slice(-4)}`}
58-
</p>
59-
<p className='text-xs text-muted-foreground'>Login from · {connector?.name}</p>
60-
</div>
61-
<EllipsisVertical className='ml-auto' />
62-
</SidebarMenuButton>
63-
) : (
64-
<SidebarMenuButton
65-
className='h-10 bg-primary text-primary-foreground hover:bg-primary/80 hover:text-primary-foreground flex items-center justify-center'
66-
onClick={() => setDialogOpen(true)}
67-
>
68-
<Wallet /> Connect Wallet
69-
</SidebarMenuButton>
70-
)}
71-
</DropdownMenuTrigger>
72-
73-
{address && account && (
74-
<DropdownMenuContent side='right' className='w-[var(--radix-popper-anchor-width)] mb-2'>
75-
<DropdownMenuItem>
76-
<Avatar className='rounded-lg'>
77-
<AvatarImage src='https://github.com/evilrabbit.png' alt='@evilrabbit' />
78-
<AvatarFallback>ER</AvatarFallback>
79-
</Avatar>
80-
<div>
81-
<p className='text-sm font-medium'>
82-
{account.ens?.name || `${address.slice(0, 6)}...${address.slice(-4)}`}
83-
</p>
84-
<p className='text-xs text-muted-foreground'>Login from · {connector?.name}</p>
85-
</div>
86-
</DropdownMenuItem>
87-
<DropdownMenuSeparator />
88-
{chains && chains.length > 0 && (
89-
<>
90-
<DropdownMenuSub>
91-
<DropdownMenuSubTrigger>Switch Network</DropdownMenuSubTrigger>
92-
<DropdownMenuSubContent className='max-h-72 overflow-y-auto'>
93-
{chains.map((chain) => {
94-
const isActive = chainId === chain.id;
95-
return (
96-
<DropdownMenuItem
97-
key={chain.id}
98-
disabled={isActive}
99-
onClick={() => switchChain({ chainId: chain.id })}
100-
>
101-
<span className='flex-1'>{chain.label ?? `Chain ${chain.id}`}</span>
102-
{isActive ? <span className='text-xs text-muted-foreground'>Current</span> : null}
103-
</DropdownMenuItem>
104-
);
105-
})}
106-
</DropdownMenuSubContent>
107-
</DropdownMenuSub>
108-
<DropdownMenuSeparator />
109-
</>
46+
<>
47+
<DropdownMenu>
48+
<DropdownMenuTrigger asChild>
49+
{address && account ? (
50+
<SidebarMenuButton className='h-12'>
51+
<Avatar className='rounded-lg'>
52+
<AvatarImage src='https://github.com/evilrabbit.png' alt='@evilrabbit' />
53+
<AvatarFallback>ER</AvatarFallback>
54+
</Avatar>
55+
<div>
56+
<p className='text-sm font-medium'>
57+
{account.ens?.name || `${address.slice(0, 6)}...${address.slice(-4)}`}
58+
</p>
59+
<p className='text-xs text-muted-foreground'>Login from · {connector?.name}</p>
60+
</div>
61+
<EllipsisVertical className='ml-auto' />
62+
</SidebarMenuButton>
63+
) : (
64+
<SidebarMenuButton
65+
className='h-10 bg-primary text-primary-foreground hover:bg-primary/80 hover:text-primary-foreground flex items-center justify-center'
66+
onClick={() => setDialogOpen(true)}
67+
>
68+
<Wallet /> Connect Wallet
69+
</SidebarMenuButton>
11070
)}
111-
<DropdownMenuItem>
112-
<span>Account</span>
113-
</DropdownMenuItem>
114-
<DropdownMenuItem>
115-
<span>Billing</span>
116-
</DropdownMenuItem>
117-
<DropdownMenuSeparator />
71+
</DropdownMenuTrigger>
11872

119-
<DropdownMenuItem onClick={() => disconnect()}>
120-
<span>Disconnect</span>
121-
</DropdownMenuItem>
122-
</DropdownMenuContent>
123-
)}
124-
</DropdownMenu>
125-
<LedgerConnectDialog open={dialogOpen} onOpenChange={setDialogOpen} />
73+
{address && account && (
74+
<DropdownMenuContent side='right' className='w-[var(--radix-popper-anchor-width)] mb-2'>
75+
<DropdownMenuItem>
76+
<Avatar className='rounded-lg'>
77+
<AvatarImage src='https://github.com/evilrabbit.png' alt='@evilrabbit' />
78+
<AvatarFallback>ER</AvatarFallback>
79+
</Avatar>
80+
<div>
81+
<p className='text-sm font-medium'>
82+
{account.ens?.name || `${address.slice(0, 6)}...${address.slice(-4)}`}
83+
</p>
84+
<p className='text-xs text-muted-foreground'>Login from · {connector?.name}</p>
85+
</div>
86+
</DropdownMenuItem>
87+
<DropdownMenuSeparator />
88+
{chains && chains.length > 0 && (
89+
<>
90+
<DropdownMenuSub>
91+
<DropdownMenuSubTrigger>Switch Network</DropdownMenuSubTrigger>
92+
<DropdownMenuSubContent className='max-h-72 overflow-y-auto'>
93+
{chains.map((chain) => {
94+
const isActive = chainId === chain.id;
95+
return (
96+
<DropdownMenuItem
97+
key={chain.id}
98+
disabled={isActive}
99+
onClick={() => switchChain({ chainId: chain.id })}
100+
>
101+
<span className='flex-1'>{chain.name}</span>
102+
{isActive ? <span className='text-xs text-muted-foreground'>Current</span> : null}
103+
</DropdownMenuItem>
104+
);
105+
})}
106+
</DropdownMenuSubContent>
107+
</DropdownMenuSub>
108+
<DropdownMenuSeparator />
109+
</>
110+
)}
111+
<DropdownMenuItem>
112+
<span>Account</span>
113+
</DropdownMenuItem>
114+
<DropdownMenuItem>
115+
<span>Billing</span>
116+
</DropdownMenuItem>
117+
<DropdownMenuSeparator />
118+
119+
<DropdownMenuItem onClick={() => disconnect()}>
120+
<span>Disconnect</span>
121+
</DropdownMenuItem>
122+
</DropdownMenuContent>
123+
)}
124+
</DropdownMenu>
125+
<LedgerConnectDialog open={dialogOpen} onOpenChange={setDialogOpen} />
126+
</>
126127
);
127128
}

0 commit comments

Comments
 (0)