@enclave-hq/wallet-sdk 1.2.4 → 1.2.7
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/dist/index.d.mts +9 -227
- package/dist/index.js +336 -745
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +339 -54
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +5 -1
- package/dist/react/index.d.ts +5 -1
- package/dist/react/index.js +347 -54
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +348 -55
- package/dist/react/index.mjs.map +1 -1
- package/dist/tron.d.mts +36 -0
- package/dist/tron.js +852 -0
- package/dist/tron.js.map +1 -0
- package/dist/tron.mjs +846 -0
- package/dist/tron.mjs.map +1 -0
- package/dist/wallet-adapter-DRd0xm3N.d.mts +197 -0
- package/package.json +8 -3
- package/dist/index.d.ts +0 -880
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import EventEmitter from 'eventemitter3';
|
|
1
|
+
import { W as WalletManagerEvents, a as WalletManagerConfig, b as WalletType, A as Account, C as ChainType$1, c as ConnectedWallet, I as IWalletAdapter, d as AddChainParams, T as TransactionReceipt, e as WalletAdapter, f as ContractReadParams, g as ContractWriteParams, h as WalletAvailability, U as UniversalAddress } from './wallet-adapter-DRd0xm3N.mjs';
|
|
2
|
+
export { E as EVMTransaction, i as ISigner, S as StorageData, l as Transaction, k as TronTransaction, j as WalletHistoryRecord, m as WalletState } from './wallet-adapter-DRd0xm3N.mjs';
|
|
4
3
|
import { WalletClient } from 'viem';
|
|
5
|
-
import
|
|
4
|
+
import * as _enclave_hq_chain_utils from '@enclave-hq/chain-utils';
|
|
5
|
+
import { ChainInfo as ChainInfo$1, ChainType as ChainType$2 } from '@enclave-hq/chain-utils';
|
|
6
|
+
import 'eventemitter3';
|
|
6
7
|
|
|
7
8
|
declare class TypedEventEmitter<TEvents extends Record<string, (...args: any[]) => void>> {
|
|
8
9
|
private emitter;
|
|
@@ -13,166 +14,6 @@ declare class TypedEventEmitter<TEvents extends Record<string, (...args: any[])
|
|
|
13
14
|
removeAllListeners<K extends keyof TEvents>(event?: K): this;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
declare const ChainType$1: typeof ChainType$2;
|
|
17
|
-
type ChainType$1 = ChainType$2;
|
|
18
|
-
declare enum WalletType {
|
|
19
|
-
METAMASK = "metamask",
|
|
20
|
-
WALLETCONNECT = "walletconnect",
|
|
21
|
-
COINBASE_WALLET = "coinbase-wallet",
|
|
22
|
-
TRONLINK = "tronlink",
|
|
23
|
-
WALLETCONNECT_TRON = "walletconnect-tron",
|
|
24
|
-
PRIVATE_KEY = "private-key",
|
|
25
|
-
DEEP_LINK_EVM = "deep-link-evm",
|
|
26
|
-
DEEP_LINK_TRON = "deep-link-tron"
|
|
27
|
-
}
|
|
28
|
-
declare enum WalletState {
|
|
29
|
-
DISCONNECTED = "disconnected",
|
|
30
|
-
CONNECTING = "connecting",
|
|
31
|
-
CONNECTED = "connected",
|
|
32
|
-
ERROR = "error"
|
|
33
|
-
}
|
|
34
|
-
type UniversalAddress = string;
|
|
35
|
-
interface Account {
|
|
36
|
-
universalAddress: UniversalAddress;
|
|
37
|
-
nativeAddress: string;
|
|
38
|
-
chainId: number;
|
|
39
|
-
chainType: ChainType$1;
|
|
40
|
-
isActive: boolean;
|
|
41
|
-
balance?: string;
|
|
42
|
-
name?: string;
|
|
43
|
-
}
|
|
44
|
-
interface ISigner {
|
|
45
|
-
signMessage(message: string): Promise<string>;
|
|
46
|
-
getAddress(): Promise<string>;
|
|
47
|
-
}
|
|
48
|
-
interface IWalletAdapter extends ISigner {
|
|
49
|
-
readonly type: WalletType;
|
|
50
|
-
readonly chainType: ChainType$1;
|
|
51
|
-
readonly name: string;
|
|
52
|
-
readonly icon?: string;
|
|
53
|
-
state: WalletState;
|
|
54
|
-
currentAccount: Account | null;
|
|
55
|
-
connect(chainId?: number | number[]): Promise<Account>;
|
|
56
|
-
disconnect(): Promise<void>;
|
|
57
|
-
isAvailable(): Promise<boolean>;
|
|
58
|
-
isConnected(): boolean;
|
|
59
|
-
signMessage(message: string): Promise<string>;
|
|
60
|
-
signTransaction?(transaction: Transaction): Promise<string>;
|
|
61
|
-
signTypedData?(typedData: any): Promise<string>;
|
|
62
|
-
switchChain?(chainId: number): Promise<void>;
|
|
63
|
-
addChain?(chainConfig: AddChainParams): Promise<void>;
|
|
64
|
-
readContract?<T = any>(params: ContractReadParams): Promise<T>;
|
|
65
|
-
writeContract?(params: ContractWriteParams): Promise<string>;
|
|
66
|
-
estimateGas?(params: ContractWriteParams): Promise<bigint>;
|
|
67
|
-
waitForTransaction?(txHash: string, confirmations?: number): Promise<TransactionReceipt>;
|
|
68
|
-
getProvider(): any;
|
|
69
|
-
getSigner?(): any;
|
|
70
|
-
on(event: string, handler: (...args: any[]) => void): void;
|
|
71
|
-
off(event: string, handler: (...args: any[]) => void): void;
|
|
72
|
-
removeAllListeners(event?: string): void;
|
|
73
|
-
}
|
|
74
|
-
interface ContractReadParams {
|
|
75
|
-
address: string;
|
|
76
|
-
abi: any[];
|
|
77
|
-
functionName: string;
|
|
78
|
-
args?: any[];
|
|
79
|
-
}
|
|
80
|
-
interface ContractWriteParams extends ContractReadParams {
|
|
81
|
-
value?: string;
|
|
82
|
-
gas?: number;
|
|
83
|
-
gasPrice?: string;
|
|
84
|
-
maxFeePerGas?: string;
|
|
85
|
-
maxPriorityFeePerGas?: string;
|
|
86
|
-
}
|
|
87
|
-
interface EVMTransaction {
|
|
88
|
-
to: string;
|
|
89
|
-
value?: string | bigint;
|
|
90
|
-
data?: string;
|
|
91
|
-
gas?: string | bigint;
|
|
92
|
-
gasPrice?: string | bigint;
|
|
93
|
-
maxFeePerGas?: string | bigint;
|
|
94
|
-
maxPriorityFeePerGas?: string | bigint;
|
|
95
|
-
nonce?: number;
|
|
96
|
-
chainId?: number;
|
|
97
|
-
}
|
|
98
|
-
interface TronTransaction {
|
|
99
|
-
txID?: string;
|
|
100
|
-
raw_data?: any;
|
|
101
|
-
raw_data_hex?: string;
|
|
102
|
-
visible?: boolean;
|
|
103
|
-
}
|
|
104
|
-
type Transaction = EVMTransaction | TronTransaction;
|
|
105
|
-
interface TransactionReceipt {
|
|
106
|
-
transactionHash: string;
|
|
107
|
-
blockNumber: number;
|
|
108
|
-
blockHash: string;
|
|
109
|
-
from: string;
|
|
110
|
-
to?: string;
|
|
111
|
-
status: 'success' | 'failed';
|
|
112
|
-
gasUsed: string;
|
|
113
|
-
effectiveGasPrice?: string;
|
|
114
|
-
logs?: any[];
|
|
115
|
-
}
|
|
116
|
-
interface AddChainParams {
|
|
117
|
-
chainId: number;
|
|
118
|
-
chainName: string;
|
|
119
|
-
nativeCurrency: {
|
|
120
|
-
name: string;
|
|
121
|
-
symbol: string;
|
|
122
|
-
decimals: number;
|
|
123
|
-
};
|
|
124
|
-
rpcUrls: string[];
|
|
125
|
-
blockExplorerUrls?: string[];
|
|
126
|
-
iconUrls?: string[];
|
|
127
|
-
}
|
|
128
|
-
interface WalletManagerConfig {
|
|
129
|
-
enableStorage?: boolean;
|
|
130
|
-
storagePrefix?: string;
|
|
131
|
-
defaultChainId?: number;
|
|
132
|
-
defaultTronChainId?: number;
|
|
133
|
-
walletConnectProjectId?: string;
|
|
134
|
-
}
|
|
135
|
-
interface ConnectedWallet {
|
|
136
|
-
account: Account;
|
|
137
|
-
walletType: WalletType;
|
|
138
|
-
chainType: ChainType$1;
|
|
139
|
-
isPrimary: boolean;
|
|
140
|
-
canSwitchChain: boolean;
|
|
141
|
-
adapter: IWalletAdapter;
|
|
142
|
-
}
|
|
143
|
-
interface WalletManagerEvents extends Record<string, (...args: any[]) => void> {
|
|
144
|
-
accountChanged: (account: Account | null) => void;
|
|
145
|
-
chainChanged: (chainId: number, account: Account) => void;
|
|
146
|
-
disconnected: () => void;
|
|
147
|
-
walletAccountChanged: (chainType: ChainType$1, account: Account | null, isPrimary: boolean) => void;
|
|
148
|
-
walletChainChanged: (chainType: ChainType$1, chainId: number, account: Account, isPrimary: boolean) => void;
|
|
149
|
-
walletDisconnected: (chainType: ChainType$1, isPrimary: boolean) => void;
|
|
150
|
-
primaryWalletSwitched: (newPrimary: Account, oldPrimary: Account | null, chainType: ChainType$1) => void;
|
|
151
|
-
error: (error: Error) => void;
|
|
152
|
-
}
|
|
153
|
-
interface WalletHistoryRecord {
|
|
154
|
-
universalAddress: UniversalAddress;
|
|
155
|
-
nativeAddress: string;
|
|
156
|
-
chainId: number;
|
|
157
|
-
chainType: ChainType$1;
|
|
158
|
-
walletType: WalletType;
|
|
159
|
-
lastConnected: number;
|
|
160
|
-
name?: string;
|
|
161
|
-
}
|
|
162
|
-
interface StorageData {
|
|
163
|
-
current: UniversalAddress | null;
|
|
164
|
-
primaryWalletType?: WalletType;
|
|
165
|
-
primaryChainId?: number;
|
|
166
|
-
history: WalletHistoryRecord[];
|
|
167
|
-
}
|
|
168
|
-
interface WalletAvailability {
|
|
169
|
-
walletType: WalletType;
|
|
170
|
-
chainType: ChainType$1;
|
|
171
|
-
isAvailable: boolean;
|
|
172
|
-
downloadUrl?: string;
|
|
173
|
-
detected: boolean;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
17
|
interface QRCodeSignerConfig {
|
|
177
18
|
requestId: string;
|
|
178
19
|
requestUrl: string;
|
|
@@ -250,6 +91,8 @@ declare class WalletManager extends TypedEventEmitter<WalletManagerEvents> {
|
|
|
250
91
|
addChainIfNotExists?: boolean;
|
|
251
92
|
chainConfig?: AddChainParams;
|
|
252
93
|
}): Promise<Account>;
|
|
94
|
+
requestSwitchAccount(targetAddress?: string): Promise<Account>;
|
|
95
|
+
ensureAccount(targetAddress: string): Promise<Account>;
|
|
253
96
|
readContract<T = any>(address: string, abi: any[], functionName: string, args?: any[], chainType?: ChainType$1): Promise<T>;
|
|
254
97
|
writeContract(address: string, abi: any[], functionName: string, args?: any[], options?: {
|
|
255
98
|
value?: string;
|
|
@@ -317,38 +160,6 @@ declare class NetworkError extends WalletSDKError {
|
|
|
317
160
|
constructor(message: string, details?: any);
|
|
318
161
|
}
|
|
319
162
|
|
|
320
|
-
declare abstract class WalletAdapter extends EventEmitter implements IWalletAdapter {
|
|
321
|
-
abstract readonly type: WalletType;
|
|
322
|
-
abstract readonly chainType: ChainType$1;
|
|
323
|
-
abstract readonly name: string;
|
|
324
|
-
readonly icon?: string;
|
|
325
|
-
state: WalletState;
|
|
326
|
-
currentAccount: Account | null;
|
|
327
|
-
abstract connect(chainId?: number | number[]): Promise<Account>;
|
|
328
|
-
abstract disconnect(): Promise<void>;
|
|
329
|
-
abstract isAvailable(): Promise<boolean>;
|
|
330
|
-
isConnected(): boolean;
|
|
331
|
-
abstract signMessage(message: string): Promise<string>;
|
|
332
|
-
getAddress(): Promise<string>;
|
|
333
|
-
signTransaction?(_transaction: any): Promise<string>;
|
|
334
|
-
signTypedData?(_typedData: any): Promise<string>;
|
|
335
|
-
switchChain?(_chainId: number): Promise<void>;
|
|
336
|
-
addChain?(_chainConfig: any): Promise<void>;
|
|
337
|
-
readContract<T = any>(_params: ContractReadParams): Promise<T>;
|
|
338
|
-
writeContract(_params: ContractWriteParams): Promise<string>;
|
|
339
|
-
estimateGas(_params: ContractWriteParams): Promise<bigint>;
|
|
340
|
-
waitForTransaction(_txHash: string, _confirmations?: number): Promise<TransactionReceipt>;
|
|
341
|
-
abstract getProvider(): any;
|
|
342
|
-
getSigner?(): any;
|
|
343
|
-
protected ensureConnected(): void;
|
|
344
|
-
protected setState(state: WalletState): void;
|
|
345
|
-
protected setAccount(account: Account | null): void;
|
|
346
|
-
protected emitAccountChanged(account: Account | null): void;
|
|
347
|
-
protected emitChainChanged(chainId: number): void;
|
|
348
|
-
protected emitDisconnected(): void;
|
|
349
|
-
protected emitError(error: Error): void;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
163
|
declare abstract class BrowserWalletAdapter extends WalletAdapter {
|
|
353
164
|
protected abstract getBrowserProvider(): any | undefined;
|
|
354
165
|
isAvailable(): Promise<boolean>;
|
|
@@ -372,6 +183,7 @@ declare class MetaMaskAdapter extends BrowserWalletAdapter {
|
|
|
372
183
|
signTransaction(transaction: any): Promise<string>;
|
|
373
184
|
switchChain(chainId: number): Promise<void>;
|
|
374
185
|
addChain(chainConfig: AddChainParams): Promise<void>;
|
|
186
|
+
requestSwitchAccount(targetAddress?: string): Promise<Account>;
|
|
375
187
|
readContract<T = any>(params: ContractReadParams): Promise<T>;
|
|
376
188
|
writeContract(params: ContractWriteParams): Promise<string>;
|
|
377
189
|
estimateGas(params: ContractWriteParams): Promise<bigint>;
|
|
@@ -456,36 +268,6 @@ declare class TronLinkAdapter extends BrowserWalletAdapter {
|
|
|
456
268
|
private handleDisconnect;
|
|
457
269
|
}
|
|
458
270
|
|
|
459
|
-
declare class WalletConnectTronAdapter extends WalletAdapter {
|
|
460
|
-
readonly type = WalletType.WALLETCONNECT_TRON;
|
|
461
|
-
readonly chainType = ChainType.TRON;
|
|
462
|
-
readonly name = "WalletConnect (Tron)";
|
|
463
|
-
readonly icon = "https://avatars.githubusercontent.com/u/37784886";
|
|
464
|
-
private wallet;
|
|
465
|
-
private projectId;
|
|
466
|
-
private currentAddress;
|
|
467
|
-
private static readonly TRON_MAINNET_CHAIN_ID;
|
|
468
|
-
private static walletInstance;
|
|
469
|
-
private static walletProjectId;
|
|
470
|
-
constructor(projectId: string);
|
|
471
|
-
isAvailable(): Promise<boolean>;
|
|
472
|
-
private isTelegramMiniApp;
|
|
473
|
-
restoreSession(chainId?: number | number[]): Promise<Account | null>;
|
|
474
|
-
private initializeWallet;
|
|
475
|
-
connect(chainId?: number | number[]): Promise<Account>;
|
|
476
|
-
disconnect(): Promise<void>;
|
|
477
|
-
signMessage(message: string): Promise<string>;
|
|
478
|
-
signTransaction(transaction: any): Promise<string>;
|
|
479
|
-
readContract<T = any>(_params: ContractReadParams): Promise<T>;
|
|
480
|
-
writeContract(_params: ContractWriteParams): Promise<string>;
|
|
481
|
-
estimateGas(_params: ContractWriteParams): Promise<bigint>;
|
|
482
|
-
waitForTransaction(_txHash: string, _confirmations?: number): Promise<TransactionReceipt>;
|
|
483
|
-
private setupEventListeners;
|
|
484
|
-
private removeEventListeners;
|
|
485
|
-
getProvider(): WalletConnectWallet | null;
|
|
486
|
-
static clearWalletInstance(): void;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
271
|
declare class EVMPrivateKeyAdapter extends WalletAdapter {
|
|
490
272
|
readonly type = WalletType.PRIVATE_KEY;
|
|
491
273
|
readonly chainType = ChainType.EVM;
|
|
@@ -877,4 +659,4 @@ declare function hexToNumber(hex: string): number;
|
|
|
877
659
|
declare function ensureHexPrefix(value: string): string;
|
|
878
660
|
declare function removeHexPrefix(value: string): string;
|
|
879
661
|
|
|
880
|
-
export {
|
|
662
|
+
export { Account, AdapterRegistry, AddChainParams, AuthMessageGenerator, type AuthMessageParams, BrowserWalletAdapter, CHAIN_INFO, type ChainInfo, ChainNotSupportedError, ChainType$1 as ChainType, ConfigurationError, ConnectedWallet, ConnectionRejectedError, ContractReadParams, ContractWriteParams, DeepLinkAdapter, DeepLinkProviderType, DeepLinkWalletType, EVMPrivateKeyAdapter, type IDeepLinkProvider, IWalletAdapter, ImTokenDeepLinkProvider, MetaMaskAdapter, MetaMaskDeepLinkProvider, MethodNotSupportedError, NetworkError, OKXDeepLinkProvider, type QRCodeSignResult, QRCodeSignStatus, QRCodeSigner, type QRCodeSignerConfig, SUPPORTED_WALLETS, SignatureRejectedError, SignatureVerifier, TokenPocketDeepLinkProvider, TransactionFailedError, TransactionReceipt, TronDeepLinkAdapter, TronLinkAdapter, TronLinkDeepLinkProvider, UniversalAddress, WalletAdapter, WalletAvailability, WalletConnectAdapter, WalletDetector, WalletManager, WalletManagerConfig, WalletManagerEvents, type WalletMetadata, WalletNotAvailableError, WalletNotConnectedError, WalletSDKError, 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 };
|