Skip to content

Commit

Permalink
Improved interface
Browse files Browse the repository at this point in the history
  • Loading branch information
hardsetting committed Feb 6, 2025
1 parent d62ecbf commit cbce48d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion packages/wallet-adapter-core/src/new/AdaptedWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
AptosSignTransactionInputV1_1,
AptosSignTransactionOutput,
AptosSignTransactionOutputV1_1,
WalletIcon,
} from '@aptos-labs/wallet-standard';
import { GA4 } from '../ga';
import { WALLET_ADAPTER_CORE_VERSION } from '../version';
Expand Down Expand Up @@ -39,7 +40,7 @@ export interface AdaptedWalletConfig {
export class AdaptedWallet {
readonly name: string;
readonly url: string;
readonly icon: string;
readonly icon: WalletIcon;
readonly features: AptosFeatures;

readonly availableNetworks: Network[];
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet-adapter-react/src/new/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function ActiveAccountNavItem({ wallet }: ActiveAccountNavItemProps) {

return (
<button onClick={onToggle}>
<div>{wallet.account.address.toString()}</div>
<div>{wallet.activeAccount.address.toString()}</div>
{isDropdownOpen ? (
<ul>
<li>Copy address</li>
Expand Down
29 changes: 16 additions & 13 deletions packages/wallet-adapter-react/src/new/useActiveWallet.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { AdaptedWallet, NewNetwork as Network, StandardNetwork } from '@aptos-labs/wallet-adapter-core';
import {
AccountInfo,
AptosFeatures,
AptosSignAndSubmitTransactionInput,
AptosSignMessageInput,
AptosSignTransactionInputV1_1,
WalletIcon,
} from '@aptos-labs/wallet-standard';
import { useEffect, useMemo, useState } from 'react';
import { useActiveWalletId } from './useActiveWalletId';
Expand All @@ -12,25 +14,25 @@ import { useAvailableWallets } from './useAvailableWallets';
export interface UseActiveWalletUninitializedResult {
isInitialized: false;
isConnected: false;
account?: undefined;
network?: undefined;
wallet?: undefined;
activeAccount?: undefined;
activeNetwork?: undefined;
}

export interface UseActiveWalletDisconnectedResult {
isInitialized: true;
isConnected: false;
account?: undefined;
network?: undefined;
wallet?: undefined;
activeAccount?: undefined;
activeNetwork?: undefined;
}

export interface UseActiveWalletConnectedResult {
isInitialized: true;
isConnected: true;
account: AccountInfo;
network: Network;
// wallet: Wallet;
activeAccount: AccountInfo;
activeNetwork: Network;
name: string;
icon: WalletIcon;
features: AptosFeatures;
disconnect: () => Promise<void>;
signMessage: (input: AptosSignMessageInput)
=> ReturnType<AdaptedWallet['signMessage']>;
Expand Down Expand Up @@ -102,10 +104,11 @@ export function useActiveWallet(): UseActiveWalletResult {
return {
isInitialized: true,
isConnected: true,
// todo: pass other useful info
// wallet: activeWallet,
account: activeAccount,
network: activeNetwork,
activeAccount,
activeNetwork,
name: activeWallet.name,
icon: activeWallet.icon,
features: activeWallet.features,
disconnect: async () => activeWallet.disconnect(),
signMessage: async (input) => activeWallet.signMessage(input),
signTransaction: async (input) => activeWallet.signTransaction(input),
Expand Down

0 comments on commit cbce48d

Please sign in to comment.