@enclave-hq/wallet-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # @enclave-hq/wallet-sdk
2
+
3
+ > Multi-chain wallet adapter for Enclave - supports EVM and Tron ecosystems
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ ## 📋 Overview
8
+
9
+ **@enclave-hq/wallet-sdk** is a powerful, extensible wallet adapter library that provides a unified interface for connecting to multiple blockchain wallets across different ecosystems (EVM and Tron).
10
+
11
+ ### Key Features
12
+
13
+ - **🔗 Multi-Chain Support**: Unified interface for EVM (Ethereum, BSC, Polygon, etc.) and Tron
14
+ - **🔌 Multiple Wallets**: MetaMask, TronLink, WalletConnect, and private key support
15
+ - **⚡️ Easy Integration**: Simple API with React hooks
16
+ - **🎯 Type-Safe**: Full TypeScript support with comprehensive type definitions
17
+ - **🔐 Secure**: Standard-compliant signing (EIP-191, TIP-191, EIP-712)
18
+ - **📦 Tree-Shakeable**: Modern build system with ESM and CJS support
19
+ - **🎨 Extensible**: Plugin-based architecture for adding new wallets and chains
20
+
21
+ ## 📦 Installation
22
+
23
+ ```bash
24
+ npm install @enclave-hq/wallet-sdk
25
+ # or
26
+ yarn add @enclave-hq/wallet-sdk
27
+ # or
28
+ pnpm add @enclave-hq/wallet-sdk
29
+ ```
30
+
31
+ ## 🚀 Quick Start
32
+
33
+ ### Basic Usage (Vanilla JS/TS)
34
+
35
+ ```typescript
36
+ import { WalletManager, WalletType } from '@enclave-hq/wallet-sdk'
37
+
38
+ // Create wallet manager
39
+ const walletManager = new WalletManager()
40
+
41
+ // Connect to MetaMask
42
+ const account = await walletManager.connect(WalletType.METAMASK, 1) // Ethereum Mainnet
43
+
44
+ console.log('Connected:', account.universalAddress)
45
+ // Output: "1:0x1234567890123456789012345678901234567890"
46
+
47
+ // Sign a message
48
+ const signature = await walletManager.signMessage('Hello World')
49
+
50
+ // Disconnect
51
+ await walletManager.disconnect()
52
+ ```
53
+
54
+ ### React Integration
55
+
56
+ ```tsx
57
+ import React from 'react'
58
+ import { WalletProvider, useWallet, useAccount, useConnect } from '@enclave-hq/wallet-sdk/react'
59
+ import { WalletType } from '@enclave-hq/wallet-sdk'
60
+
61
+ // 1. Wrap your app with WalletProvider
62
+ function App() {
63
+ return (
64
+ <WalletProvider>
65
+ <YourApp />
66
+ </WalletProvider>
67
+ )
68
+ }
69
+
70
+ // 2. Use wallet hooks in your components
71
+ function YourApp() {
72
+ const { account, isConnected } = useAccount()
73
+ const { connect, isConnecting } = useConnect()
74
+ const { disconnect } = useWallet()
75
+
76
+ const handleConnect = async () => {
77
+ try {
78
+ await connect(WalletType.METAMASK)
79
+ } catch (error) {
80
+ console.error('Connection failed:', error)
81
+ }
82
+ }
83
+
84
+ if (!isConnected) {
85
+ return (
86
+ <button onClick={handleConnect} disabled={isConnecting}>
87
+ {isConnecting ? 'Connecting...' : 'Connect MetaMask'}
88
+ </button>
89
+ )
90
+ }
91
+
92
+ return (
93
+ <div>
94
+ <p>Connected: {account?.nativeAddress}</p>
95
+ <button onClick={disconnect}>Disconnect</button>
96
+ </div>
97
+ )
98
+ }
99
+ ```
100
+
101
+ ## 🎯 Core Concepts
102
+
103
+ ### Universal Address
104
+
105
+ A chain-agnostic address format: `chainId:address`
106
+
107
+ ```typescript
108
+ // Example:
109
+ "1:0x1234..." // Ethereum Mainnet
110
+ "56:0x5678..." // BSC Mainnet
111
+ "195:TJmm..." // Tron Mainnet
112
+ ```
113
+
114
+ ### Primary Wallet + Connected Wallets Pool
115
+
116
+ The SDK uses a hybrid architecture where you can:
117
+ - Connect multiple wallets simultaneously (EVM + Tron)
118
+ - Designate one as the "primary wallet" for default operations
119
+ - Switch the primary wallet dynamically
120
+
121
+ ```typescript
122
+ // Connect MetaMask as primary wallet
123
+ await walletManager.connect(WalletType.METAMASK)
124
+
125
+ // Connect TronLink as additional wallet
126
+ await walletManager.connectAdditional(WalletType.TRONLINK)
127
+
128
+ // Switch primary wallet to TronLink
129
+ await walletManager.switchPrimaryWallet(ChainType.TRON)
130
+
131
+ // Get all connected wallets
132
+ const wallets = walletManager.getConnectedWallets()
133
+ ```
134
+
135
+ ## 📚 Supported Wallets
136
+
137
+ | Wallet | Chain Type | Status |
138
+ |--------|------------|--------|
139
+ | MetaMask | EVM | ✅ Supported |
140
+ | TronLink | Tron | ✅ Supported |
141
+ | WalletConnect | EVM | 🚧 Coming Soon |
142
+ | Coinbase Wallet | EVM | 🚧 Coming Soon |
143
+ | Private Key | EVM/Tron | ✅ Dev Only |
144
+
145
+ ## 📖 Documentation
146
+
147
+ Full documentation is available in the `/docs` folder:
148
+
149
+ - [Architecture Design](../docs/wallet-sdk/ARCHITECTURE.md)
150
+ - [Design Goals](../docs/wallet-sdk/DESIGN.md)
151
+ - [API Reference](../docs/wallet-sdk/API接口.md)
152
+ - [Integration Guide](../docs/wallet-sdk/INTEGRATION.md)
153
+ - [State Management](../docs/wallet-sdk/STATE_AND_ACCOUNT.md)
154
+ - [Standards & Signing](../docs/wallet-sdk/STANDARDS.md)
155
+
156
+ ## 🧪 Running the Example
157
+
158
+ A fully functional example application is included:
159
+
160
+ ```bash
161
+ cd example
162
+ npm install
163
+ npm run dev
164
+ ```
165
+
166
+ Open [http://localhost:3000](http://localhost:3000) to see the demo.
167
+
168
+ ## 🛠️ Development
169
+
170
+ ```bash
171
+ # Install dependencies
172
+ npm install
173
+
174
+ # Build the SDK
175
+ npm run build
176
+
177
+ # Watch mode (for development)
178
+ npm run dev
179
+
180
+ # Run linter
181
+ npm run lint
182
+
183
+ # Type check
184
+ npm run type-check
185
+ ```
186
+
187
+ ## 📄 License
188
+
189
+ MIT © Enclave Team
190
+
191
+ ## 🤝 Contributing
192
+
193
+ Contributions are welcome! Please read our [Contributing Guide](../CONTRIBUTING.md) for details.
194
+
195
+ ## 🔗 Links
196
+
197
+ - [Enclave Documentation](../README.md)
198
+ - [GitHub Repository](https://github.com/enclave-hq/enclave)
199
+ - [Report Issues](https://github.com/enclave-hq/enclave/issues)
200
+
201
+ ---
202
+
203
+ **Built with ❤️ by the Enclave Team**
@@ -0,0 +1,441 @@
1
+ import EventEmitter from 'eventemitter3';
2
+ import { WalletClient } from 'viem';
3
+
4
+ declare class TypedEventEmitter<TEvents extends Record<string, (...args: any[]) => void>> {
5
+ private emitter;
6
+ on<K extends keyof TEvents>(event: K, handler: TEvents[K]): this;
7
+ once<K extends keyof TEvents>(event: K, handler: TEvents[K]): this;
8
+ off<K extends keyof TEvents>(event: K, handler: TEvents[K]): this;
9
+ emit<K extends keyof TEvents>(event: K, ...args: Parameters<TEvents[K]>): boolean;
10
+ removeAllListeners<K extends keyof TEvents>(event?: K): this;
11
+ }
12
+
13
+ declare enum ChainType {
14
+ EVM = "evm",
15
+ TRON = "tron",
16
+ SOLANA = "solana",
17
+ COSMOS = "cosmos"
18
+ }
19
+ declare enum WalletType {
20
+ METAMASK = "metamask",
21
+ WALLETCONNECT = "walletconnect",
22
+ COINBASE_WALLET = "coinbase-wallet",
23
+ TRONLINK = "tronlink",
24
+ WALLETCONNECT_TRON = "walletconnect-tron",
25
+ PRIVATE_KEY = "private-key"
26
+ }
27
+ declare enum WalletState {
28
+ DISCONNECTED = "disconnected",
29
+ CONNECTING = "connecting",
30
+ CONNECTED = "connected",
31
+ ERROR = "error"
32
+ }
33
+ type UniversalAddress = string;
34
+ interface Account {
35
+ universalAddress: UniversalAddress;
36
+ nativeAddress: string;
37
+ chainId: number;
38
+ chainType: ChainType;
39
+ isActive: boolean;
40
+ balance?: string;
41
+ name?: string;
42
+ }
43
+ interface IWalletAdapter {
44
+ readonly type: WalletType;
45
+ readonly chainType: ChainType;
46
+ readonly name: string;
47
+ readonly icon?: string;
48
+ state: WalletState;
49
+ currentAccount: Account | null;
50
+ connect(chainId?: number): Promise<Account>;
51
+ disconnect(): Promise<void>;
52
+ isAvailable(): Promise<boolean>;
53
+ signMessage(message: string): Promise<string>;
54
+ signTransaction?(transaction: any): Promise<string>;
55
+ signTypedData?(typedData: any): Promise<string>;
56
+ switchChain?(chainId: number): Promise<void>;
57
+ addChain?(chainConfig: AddChainParams): Promise<void>;
58
+ readContract?<T = any>(params: ContractReadParams): Promise<T>;
59
+ writeContract?(params: ContractWriteParams): Promise<string>;
60
+ estimateGas?(params: ContractWriteParams): Promise<bigint>;
61
+ waitForTransaction?(txHash: string, confirmations?: number): Promise<TransactionReceipt>;
62
+ getProvider(): any;
63
+ getSigner?(): any;
64
+ on(event: string, handler: (...args: any[]) => void): void;
65
+ off(event: string, handler: (...args: any[]) => void): void;
66
+ removeAllListeners(event?: string): void;
67
+ }
68
+ interface ContractReadParams {
69
+ address: string;
70
+ abi: any[];
71
+ functionName: string;
72
+ args?: any[];
73
+ }
74
+ interface ContractWriteParams extends ContractReadParams {
75
+ value?: string;
76
+ gas?: number;
77
+ gasPrice?: string;
78
+ }
79
+ interface TransactionReceipt {
80
+ transactionHash: string;
81
+ blockNumber: number;
82
+ blockHash: string;
83
+ from: string;
84
+ to?: string;
85
+ status: 'success' | 'failed';
86
+ gasUsed: string;
87
+ effectiveGasPrice?: string;
88
+ logs?: any[];
89
+ }
90
+ interface AddChainParams {
91
+ chainId: number;
92
+ chainName: string;
93
+ nativeCurrency: {
94
+ name: string;
95
+ symbol: string;
96
+ decimals: number;
97
+ };
98
+ rpcUrls: string[];
99
+ blockExplorerUrls?: string[];
100
+ iconUrls?: string[];
101
+ }
102
+ interface WalletManagerConfig {
103
+ enableStorage?: boolean;
104
+ storagePrefix?: string;
105
+ defaultChainId?: number;
106
+ defaultTronChainId?: number;
107
+ walletConnectProjectId?: string;
108
+ }
109
+ interface ConnectedWallet {
110
+ account: Account;
111
+ walletType: WalletType;
112
+ chainType: ChainType;
113
+ isPrimary: boolean;
114
+ canSwitchChain: boolean;
115
+ adapter: IWalletAdapter;
116
+ }
117
+ interface WalletManagerEvents extends Record<string, (...args: any[]) => void> {
118
+ accountChanged: (account: Account | null) => void;
119
+ chainChanged: (chainId: number, account: Account) => void;
120
+ disconnected: () => void;
121
+ walletAccountChanged: (chainType: ChainType, account: Account | null, isPrimary: boolean) => void;
122
+ walletChainChanged: (chainType: ChainType, chainId: number, account: Account, isPrimary: boolean) => void;
123
+ walletDisconnected: (chainType: ChainType, isPrimary: boolean) => void;
124
+ primaryWalletSwitched: (newPrimary: Account, oldPrimary: Account | null, chainType: ChainType) => void;
125
+ error: (error: Error) => void;
126
+ }
127
+ interface WalletHistoryRecord {
128
+ universalAddress: UniversalAddress;
129
+ nativeAddress: string;
130
+ chainId: number;
131
+ chainType: ChainType;
132
+ walletType: WalletType;
133
+ lastConnected: number;
134
+ name?: string;
135
+ }
136
+ interface StorageData {
137
+ current: UniversalAddress | null;
138
+ history: WalletHistoryRecord[];
139
+ }
140
+ interface WalletAvailability {
141
+ walletType: WalletType;
142
+ chainType: ChainType;
143
+ isAvailable: boolean;
144
+ downloadUrl?: string;
145
+ detected: boolean;
146
+ }
147
+
148
+ declare class WalletManager extends TypedEventEmitter<WalletManagerEvents> {
149
+ private config;
150
+ private registry;
151
+ private primaryWallet;
152
+ private connectedWallets;
153
+ constructor(config?: WalletManagerConfig);
154
+ connect(type: WalletType, chainId?: number): Promise<Account>;
155
+ connectAdditional(type: WalletType, chainId?: number): Promise<Account>;
156
+ connectWithPrivateKey(privateKey: string, chainId?: number): Promise<Account>;
157
+ disconnect(): Promise<void>;
158
+ disconnectAll(): Promise<void>;
159
+ switchPrimaryWallet(chainType: ChainType): Promise<Account>;
160
+ getPrimaryAccount(): Account | null;
161
+ getConnectedWallets(): ConnectedWallet[];
162
+ getWalletByChainType(chainType: ChainType): IWalletAdapter | null;
163
+ signMessage(message: string): Promise<string>;
164
+ signMessageWithChainType(message: string, chainType?: ChainType): Promise<string>;
165
+ signTypedData(typedData: any, chainType?: ChainType): Promise<string>;
166
+ requestSwitchChain(chainId: number, options?: {
167
+ addChainIfNotExists?: boolean;
168
+ chainConfig?: AddChainParams;
169
+ }): Promise<Account>;
170
+ readContract<T = any>(address: string, abi: any[], functionName: string, args?: any[], chainType?: ChainType): Promise<T>;
171
+ writeContract(address: string, abi: any[], functionName: string, args?: any[], options?: {
172
+ value?: string;
173
+ gas?: number;
174
+ gasPrice?: string;
175
+ }, chainType?: ChainType): Promise<string>;
176
+ estimateGas(address: string, abi: any[], functionName: string, args?: any[], chainType?: ChainType): Promise<bigint>;
177
+ waitForTransaction(txHash: string, confirmations?: number, chainType?: ChainType): Promise<TransactionReceipt>;
178
+ getProvider(): any;
179
+ getProviderByChainType(chainType: ChainType): any;
180
+ private setPrimaryWallet;
181
+ private canSwitchChain;
182
+ private setupAdapterListeners;
183
+ private removeAdapterListeners;
184
+ private saveToStorage;
185
+ private restoreFromStorage;
186
+ private clearStorage;
187
+ private getHistoryRecords;
188
+ }
189
+
190
+ declare class AdapterRegistry {
191
+ private adapters;
192
+ constructor();
193
+ private registerDefaultAdapters;
194
+ register(type: WalletType, factory: () => IWalletAdapter): void;
195
+ getAdapter(type: WalletType): IWalletAdapter | null;
196
+ has(type: WalletType): boolean;
197
+ getRegisteredTypes(): WalletType[];
198
+ getAdapterTypesByChainType(chainType: ChainType): WalletType[];
199
+ }
200
+
201
+ declare class WalletSDKError extends Error {
202
+ readonly code: string;
203
+ readonly details?: any | undefined;
204
+ constructor(message: string, code: string, details?: any | undefined);
205
+ }
206
+ declare class WalletNotConnectedError extends WalletSDKError {
207
+ constructor(walletType?: string);
208
+ }
209
+ declare class WalletNotAvailableError extends WalletSDKError {
210
+ constructor(walletType: string, downloadUrl?: string);
211
+ }
212
+ declare class ConnectionRejectedError extends WalletSDKError {
213
+ constructor(walletType: string);
214
+ }
215
+ declare class ChainNotSupportedError extends WalletSDKError {
216
+ constructor(chainId: number, walletType: string);
217
+ }
218
+ declare class SignatureRejectedError extends WalletSDKError {
219
+ constructor(message?: string);
220
+ }
221
+ declare class TransactionFailedError extends WalletSDKError {
222
+ constructor(txHash: string, reason?: string);
223
+ }
224
+ declare class MethodNotSupportedError extends WalletSDKError {
225
+ constructor(method: string, walletType: string);
226
+ }
227
+ declare class ConfigurationError extends WalletSDKError {
228
+ constructor(message: string, details?: any);
229
+ }
230
+ declare class NetworkError extends WalletSDKError {
231
+ constructor(message: string, details?: any);
232
+ }
233
+
234
+ declare abstract class WalletAdapter extends EventEmitter implements IWalletAdapter {
235
+ abstract readonly type: WalletType;
236
+ abstract readonly chainType: ChainType;
237
+ abstract readonly name: string;
238
+ readonly icon?: string;
239
+ state: WalletState;
240
+ currentAccount: Account | null;
241
+ abstract connect(chainId?: number): Promise<Account>;
242
+ abstract disconnect(): Promise<void>;
243
+ abstract isAvailable(): Promise<boolean>;
244
+ abstract signMessage(message: string): Promise<string>;
245
+ signTransaction?(_transaction: any): Promise<string>;
246
+ signTypedData?(_typedData: any): Promise<string>;
247
+ switchChain?(_chainId: number): Promise<void>;
248
+ addChain?(_chainConfig: any): Promise<void>;
249
+ readContract<T = any>(_params: ContractReadParams): Promise<T>;
250
+ writeContract(_params: ContractWriteParams): Promise<string>;
251
+ estimateGas(_params: ContractWriteParams): Promise<bigint>;
252
+ waitForTransaction(_txHash: string, _confirmations?: number): Promise<TransactionReceipt>;
253
+ abstract getProvider(): any;
254
+ getSigner?(): any;
255
+ protected ensureConnected(): void;
256
+ protected setState(state: WalletState): void;
257
+ protected setAccount(account: Account | null): void;
258
+ protected emitAccountChanged(account: Account | null): void;
259
+ protected emitChainChanged(chainId: number): void;
260
+ protected emitDisconnected(): void;
261
+ protected emitError(error: Error): void;
262
+ }
263
+
264
+ declare abstract class BrowserWalletAdapter extends WalletAdapter {
265
+ protected abstract getBrowserProvider(): any | undefined;
266
+ isAvailable(): Promise<boolean>;
267
+ protected ensureAvailable(): Promise<void>;
268
+ protected abstract getDownloadUrl(): string;
269
+ protected abstract setupEventListeners(): void;
270
+ protected abstract removeEventListeners(): void;
271
+ disconnect(): Promise<void>;
272
+ }
273
+
274
+ declare class MetaMaskAdapter extends BrowserWalletAdapter {
275
+ readonly type = WalletType.METAMASK;
276
+ readonly chainType = ChainType.EVM;
277
+ readonly name = "MetaMask";
278
+ readonly icon = "https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Fox.svg";
279
+ private walletClient;
280
+ private publicClient;
281
+ connect(chainId?: number): Promise<Account>;
282
+ signMessage(message: string): Promise<string>;
283
+ signTypedData(typedData: any): Promise<string>;
284
+ switchChain(chainId: number): Promise<void>;
285
+ addChain(chainConfig: AddChainParams): Promise<void>;
286
+ readContract<T = any>(params: ContractReadParams): Promise<T>;
287
+ writeContract(params: ContractWriteParams): Promise<string>;
288
+ estimateGas(params: ContractWriteParams): Promise<bigint>;
289
+ waitForTransaction(txHash: string, confirmations?: number): Promise<TransactionReceipt>;
290
+ getProvider(): any;
291
+ getSigner(): WalletClient | null;
292
+ protected getBrowserProvider(): any | undefined;
293
+ protected getDownloadUrl(): string;
294
+ protected setupEventListeners(): void;
295
+ protected removeEventListeners(): void;
296
+ private handleAccountsChanged;
297
+ private handleChainChanged;
298
+ private handleDisconnect;
299
+ private getViemChain;
300
+ }
301
+
302
+ declare class TronLinkAdapter extends BrowserWalletAdapter {
303
+ readonly type = WalletType.TRONLINK;
304
+ readonly chainType = ChainType.TRON;
305
+ readonly name = "TronLink";
306
+ readonly icon = "https://www.tronlink.org/static/logoIcon.svg";
307
+ private static readonly TRON_MAINNET_CHAIN_ID;
308
+ connect(chainId?: number): Promise<Account>;
309
+ signMessage(message: string): Promise<string>;
310
+ getProvider(): any;
311
+ protected getBrowserProvider(): any | undefined;
312
+ private getTronWeb;
313
+ protected getDownloadUrl(): string;
314
+ protected setupEventListeners(): void;
315
+ protected removeEventListeners(): void;
316
+ private handleAccountsChanged;
317
+ private handleDisconnect;
318
+ }
319
+
320
+ declare class EVMPrivateKeyAdapter extends WalletAdapter {
321
+ readonly type = WalletType.PRIVATE_KEY;
322
+ readonly chainType = ChainType.EVM;
323
+ readonly name = "Private Key (EVM)";
324
+ private privateKey;
325
+ private walletClient;
326
+ private publicClient;
327
+ connect(chainId?: number): Promise<Account>;
328
+ disconnect(): Promise<void>;
329
+ isAvailable(): Promise<boolean>;
330
+ setPrivateKey(privateKey: string): void;
331
+ signMessage(message: string): Promise<string>;
332
+ signTypedData(typedData: any): Promise<string>;
333
+ switchChain(chainId: number): Promise<void>;
334
+ readContract<T = any>(params: ContractReadParams): Promise<T>;
335
+ writeContract(params: ContractWriteParams): Promise<string>;
336
+ estimateGas(params: ContractWriteParams): Promise<bigint>;
337
+ waitForTransaction(txHash: string, confirmations?: number): Promise<TransactionReceipt>;
338
+ getProvider(): any;
339
+ getSigner(): WalletClient | null;
340
+ private getViemChain;
341
+ }
342
+
343
+ interface AuthMessageParams {
344
+ domain: string;
345
+ nonce: string;
346
+ chainId: number;
347
+ timestamp: number;
348
+ statement?: string;
349
+ }
350
+ declare class AuthMessageGenerator {
351
+ private readonly domain;
352
+ constructor(domain: string);
353
+ generateAuthMessage(chainType: ChainType, nonce: string, chainId: number, timestamp?: number, statement?: string): string;
354
+ private generateEIP191Message;
355
+ private generateTIP191Message;
356
+ static generateNonce(): string;
357
+ }
358
+
359
+ declare class SignatureVerifier {
360
+ verifySignature(message: string, signature: string, expectedAddress: string, chainType: ChainType): Promise<boolean>;
361
+ private verifyEIP191Signature;
362
+ private verifyTIP191Signature;
363
+ }
364
+
365
+ declare class WalletDetector {
366
+ detectAllWallets(): Promise<WalletAvailability[]>;
367
+ detectWallet(walletType: WalletType): Promise<WalletAvailability>;
368
+ private isWalletAvailable;
369
+ private isMetaMaskAvailable;
370
+ private isTronLinkAvailable;
371
+ private isCoinbaseWalletAvailable;
372
+ waitForWallet(walletType: WalletType, timeout?: number): Promise<boolean>;
373
+ }
374
+
375
+ interface WalletMetadata {
376
+ type: WalletType;
377
+ name: string;
378
+ chainType: ChainType;
379
+ icon?: string;
380
+ downloadUrl?: string;
381
+ description?: string;
382
+ }
383
+ declare const SUPPORTED_WALLETS: Record<WalletType, WalletMetadata>;
384
+ declare function getWalletMetadata(type: WalletType): WalletMetadata | undefined;
385
+ declare function getEVMWallets(): WalletMetadata[];
386
+ declare function getTronWallets(): WalletMetadata[];
387
+
388
+ declare function createUniversalAddress(chainId: number, address: string): UniversalAddress;
389
+ declare function parseUniversalAddress(universalAddress: UniversalAddress): {
390
+ chainId: number;
391
+ address: string;
392
+ } | null;
393
+ declare function isValidUniversalAddress(universalAddress: string): boolean;
394
+ declare function getChainIdFromUniversalAddress(universalAddress: UniversalAddress): number | null;
395
+ declare function getAddressFromUniversalAddress(universalAddress: UniversalAddress): string | null;
396
+ declare function compareUniversalAddresses(a: UniversalAddress, b: UniversalAddress): boolean;
397
+
398
+ declare function isValidEVMAddress(address: string): boolean;
399
+ declare function formatEVMAddress(address: string): string;
400
+ declare function compareEVMAddresses(a: string, b: string): boolean;
401
+ declare function shortenAddress(address: string, chars?: number): string;
402
+
403
+ declare function isValidTronAddress(address: string): boolean;
404
+ declare function isValidTronHexAddress(address: string): boolean;
405
+ declare function compareTronAddresses(a: string, b: string): boolean;
406
+ declare function shortenTronAddress(address: string, chars?: number): string;
407
+
408
+ interface ChainInfo {
409
+ id: number;
410
+ name: string;
411
+ chainType: ChainType;
412
+ nativeCurrency: {
413
+ name: string;
414
+ symbol: string;
415
+ decimals: number;
416
+ };
417
+ rpcUrls: string[];
418
+ blockExplorerUrls?: string[];
419
+ iconUrls?: string[];
420
+ }
421
+ declare const CHAIN_INFO: Record<number, ChainInfo>;
422
+ declare function getChainInfo(chainId: number): ChainInfo | undefined;
423
+ declare function getChainType(chainId: number): ChainType | undefined;
424
+ declare function isEVMChain(chainId: number): boolean;
425
+ declare function isTronChain(chainId: number): boolean;
426
+
427
+ declare function validateAddress(address: string, chainType: ChainType): boolean;
428
+ declare function validateAddressForChain(address: string, chainId: number): boolean;
429
+ declare function isValidChainId(chainId: number): boolean;
430
+ declare function isValidSignature(signature: string): boolean;
431
+ declare function isValidTransactionHash(txHash: string, chainType: ChainType): boolean;
432
+
433
+ declare function isHex(value: string): boolean;
434
+ declare function toHex(value: string): string;
435
+ declare function fromHex(hex: string): string;
436
+ declare function numberToHex(value: number | bigint): string;
437
+ declare function hexToNumber(hex: string): number;
438
+ declare function ensureHexPrefix(value: string): string;
439
+ declare function removeHexPrefix(value: string): string;
440
+
441
+ export { type Account, AdapterRegistry, type AddChainParams, AuthMessageGenerator, type AuthMessageParams, BrowserWalletAdapter, CHAIN_INFO, type ChainInfo, ChainNotSupportedError, ChainType, ConfigurationError, type ConnectedWallet, ConnectionRejectedError, type ContractReadParams, type ContractWriteParams, EVMPrivateKeyAdapter, type IWalletAdapter, MetaMaskAdapter, MethodNotSupportedError, NetworkError, SUPPORTED_WALLETS, SignatureRejectedError, SignatureVerifier, type StorageData, TransactionFailedError, type TransactionReceipt, TronLinkAdapter, type UniversalAddress, WalletAdapter, type WalletAvailability, WalletDetector, type WalletHistoryRecord, WalletManager, type WalletManagerConfig, type WalletManagerEvents, type WalletMetadata, WalletNotAvailableError, WalletNotConnectedError, WalletSDKError, WalletState, WalletType, compareEVMAddresses, compareTronAddresses, compareUniversalAddresses, createUniversalAddress, WalletManager as default, ensureHexPrefix, formatEVMAddress, fromHex, getAddressFromUniversalAddress, getChainIdFromUniversalAddress, getChainInfo, getChainType, getEVMWallets, getTronWallets, getWalletMetadata, hexToNumber, isEVMChain, isHex, isTronChain, isValidChainId, isValidEVMAddress, isValidSignature, isValidTransactionHash, isValidTronAddress, isValidTronHexAddress, isValidUniversalAddress, numberToHex, parseUniversalAddress, removeHexPrefix, shortenAddress, shortenTronAddress, toHex, validateAddress, validateAddressForChain };