@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 +203 -0
- package/dist/index.d.mts +441 -0
- package/dist/index.d.ts +441 -0
- package/dist/index.js +2130 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2064 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react/index.d.mts +218 -0
- package/dist/react/index.d.ts +218 -0
- package/dist/react/index.js +1782 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +1770 -0
- package/dist/react/index.mjs.map +1 -0
- package/package.json +76 -0
package/dist/index.d.ts
ADDED
|
@@ -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 };
|