Skip to content

Commit cbce48d

Browse files
committed
Improved interface
1 parent d62ecbf commit cbce48d

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

packages/wallet-adapter-core/src/new/AdaptedWallet.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
AptosSignTransactionInputV1_1,
99
AptosSignTransactionOutput,
1010
AptosSignTransactionOutputV1_1,
11+
WalletIcon,
1112
} from '@aptos-labs/wallet-standard';
1213
import { GA4 } from '../ga';
1314
import { WALLET_ADAPTER_CORE_VERSION } from '../version';
@@ -39,7 +40,7 @@ export interface AdaptedWalletConfig {
3940
export class AdaptedWallet {
4041
readonly name: string;
4142
readonly url: string;
42-
readonly icon: string;
43+
readonly icon: WalletIcon;
4344
readonly features: AptosFeatures;
4445

4546
readonly availableNetworks: Network[];

packages/wallet-adapter-react/src/new/Example.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function ActiveAccountNavItem({ wallet }: ActiveAccountNavItemProps) {
5757

5858
return (
5959
<button onClick={onToggle}>
60-
<div>{wallet.account.address.toString()}</div>
60+
<div>{wallet.activeAccount.address.toString()}</div>
6161
{isDropdownOpen ? (
6262
<ul>
6363
<li>Copy address</li>

packages/wallet-adapter-react/src/new/useActiveWallet.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { AdaptedWallet, NewNetwork as Network, StandardNetwork } from '@aptos-labs/wallet-adapter-core';
22
import {
33
AccountInfo,
4+
AptosFeatures,
45
AptosSignAndSubmitTransactionInput,
56
AptosSignMessageInput,
67
AptosSignTransactionInputV1_1,
8+
WalletIcon,
79
} from '@aptos-labs/wallet-standard';
810
import { useEffect, useMemo, useState } from 'react';
911
import { useActiveWalletId } from './useActiveWalletId';
@@ -12,25 +14,25 @@ import { useAvailableWallets } from './useAvailableWallets';
1214
export interface UseActiveWalletUninitializedResult {
1315
isInitialized: false;
1416
isConnected: false;
15-
account?: undefined;
16-
network?: undefined;
17-
wallet?: undefined;
17+
activeAccount?: undefined;
18+
activeNetwork?: undefined;
1819
}
1920

2021
export interface UseActiveWalletDisconnectedResult {
2122
isInitialized: true;
2223
isConnected: false;
23-
account?: undefined;
24-
network?: undefined;
25-
wallet?: undefined;
24+
activeAccount?: undefined;
25+
activeNetwork?: undefined;
2626
}
2727

2828
export interface UseActiveWalletConnectedResult {
2929
isInitialized: true;
3030
isConnected: true;
31-
account: AccountInfo;
32-
network: Network;
33-
// wallet: Wallet;
31+
activeAccount: AccountInfo;
32+
activeNetwork: Network;
33+
name: string;
34+
icon: WalletIcon;
35+
features: AptosFeatures;
3436
disconnect: () => Promise<void>;
3537
signMessage: (input: AptosSignMessageInput)
3638
=> ReturnType<AdaptedWallet['signMessage']>;
@@ -102,10 +104,11 @@ export function useActiveWallet(): UseActiveWalletResult {
102104
return {
103105
isInitialized: true,
104106
isConnected: true,
105-
// todo: pass other useful info
106-
// wallet: activeWallet,
107-
account: activeAccount,
108-
network: activeNetwork,
107+
activeAccount,
108+
activeNetwork,
109+
name: activeWallet.name,
110+
icon: activeWallet.icon,
111+
features: activeWallet.features,
109112
disconnect: async () => activeWallet.disconnect(),
110113
signMessage: async (input) => activeWallet.signMessage(input),
111114
signTransaction: async (input) => activeWallet.signTransaction(input),

0 commit comments

Comments
 (0)