@enclave-hq/wallet-sdk 1.2.2 → 1.2.4

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.
@@ -18,7 +18,9 @@ declare enum WalletType {
18
18
  COINBASE_WALLET = "coinbase-wallet",
19
19
  TRONLINK = "tronlink",
20
20
  WALLETCONNECT_TRON = "walletconnect-tron",
21
- PRIVATE_KEY = "private-key"
21
+ PRIVATE_KEY = "private-key",
22
+ DEEP_LINK_EVM = "deep-link-evm",
23
+ DEEP_LINK_TRON = "deep-link-tron"
22
24
  }
23
25
  declare enum WalletState {
24
26
  DISCONNECTED = "disconnected",
@@ -47,9 +49,10 @@ interface IWalletAdapter extends ISigner {
47
49
  readonly icon?: string;
48
50
  state: WalletState;
49
51
  currentAccount: Account | null;
50
- connect(chainId?: number): Promise<Account>;
52
+ connect(chainId?: number | number[]): Promise<Account>;
51
53
  disconnect(): Promise<void>;
52
54
  isAvailable(): Promise<boolean>;
55
+ isConnected(): boolean;
53
56
  signMessage(message: string): Promise<string>;
54
57
  signTransaction?(transaction: Transaction): Promise<string>;
55
58
  signTypedData?(typedData: any): Promise<string>;
@@ -145,14 +148,63 @@ interface WalletManagerEvents extends Record<string, (...args: any[]) => void> {
145
148
  error: (error: Error) => void;
146
149
  }
147
150
 
151
+ interface QRCodeSignerConfig {
152
+ requestId: string;
153
+ requestUrl: string;
154
+ pollUrl?: string;
155
+ pollInterval?: number;
156
+ timeout?: number;
157
+ pollFn?: (requestId: string) => Promise<QRCodeSignResult | null>;
158
+ }
159
+ interface QRCodeSignResult {
160
+ completed: boolean;
161
+ signature?: string;
162
+ error?: string;
163
+ signer?: string;
164
+ }
165
+ declare enum QRCodeSignStatus {
166
+ WAITING = "waiting",
167
+ PENDING = "pending",
168
+ SUCCESS = "success",
169
+ FAILED = "failed",
170
+ TIMEOUT = "timeout",
171
+ CANCELLED = "cancelled"
172
+ }
173
+ declare class QRCodeSigner {
174
+ private config;
175
+ private pollTimer;
176
+ private timeoutTimer;
177
+ private status;
178
+ private qrCodeDataUrl;
179
+ private result;
180
+ constructor(config: QRCodeSignerConfig);
181
+ generateQRCode(options?: {
182
+ width?: number;
183
+ margin?: number;
184
+ color?: {
185
+ dark?: string;
186
+ light?: string;
187
+ };
188
+ }): Promise<string>;
189
+ startPolling(onStatusChange?: (status: QRCodeSignStatus) => void, onResult?: (result: QRCodeSignResult) => void): Promise<string>;
190
+ private defaultPoll;
191
+ stopPolling(): void;
192
+ cancel(): void;
193
+ getStatus(): QRCodeSignStatus;
194
+ getQRCodeUrl(): string;
195
+ getResult(): QRCodeSignResult | null;
196
+ cleanup(): void;
197
+ }
198
+
148
199
  declare class WalletManager extends TypedEventEmitter<WalletManagerEvents> {
149
200
  private config;
150
201
  private registry;
151
202
  private primaryWallet;
152
203
  private connectedWallets;
153
204
  constructor(config?: WalletManagerConfig);
154
- connect(type: WalletType, chainId?: number): Promise<Account>;
155
- connectAdditional(type: WalletType, chainId?: number): Promise<Account>;
205
+ hasAdapter(type: WalletType): boolean;
206
+ connect(type: WalletType, chainId?: number | number[]): Promise<Account>;
207
+ connectAdditional(type: WalletType, chainId?: number | number[]): Promise<Account>;
156
208
  connectWithPrivateKey(privateKey: string, chainId?: number): Promise<Account>;
157
209
  disconnect(): Promise<void>;
158
210
  disconnectAll(): Promise<void>;
@@ -162,6 +214,10 @@ declare class WalletManager extends TypedEventEmitter<WalletManagerEvents> {
162
214
  getWalletByChainType(chainType: ChainType): IWalletAdapter | null;
163
215
  signMessage(message: string): Promise<string>;
164
216
  signMessageWithChainType(message: string, chainType?: ChainType): Promise<string>;
217
+ createQRCodeSigner(message: string, config: Omit<QRCodeSignerConfig, 'requestId' | 'requestUrl'> & {
218
+ requestId: string;
219
+ requestUrl: string;
220
+ }): QRCodeSigner;
165
221
  signTypedData(typedData: any, chainType?: ChainType): Promise<string>;
166
222
  signTransaction(transaction: any): Promise<string>;
167
223
  signTransactionWithChainType(transaction: any, chainType?: ChainType): Promise<string>;
@@ -197,8 +253,8 @@ interface WalletContextValue {
197
253
  isConnected: boolean;
198
254
  connectedWallets: ConnectedWallet[];
199
255
  isRestoring: boolean;
200
- connect: (type: WalletType, chainId?: number) => Promise<Account>;
201
- connectAdditional: (type: WalletType, chainId?: number) => Promise<Account>;
256
+ connect: (type: WalletType, chainId?: number | number[]) => Promise<Account>;
257
+ connectAdditional: (type: WalletType, chainId?: number | number[]) => Promise<Account>;
202
258
  disconnect: () => Promise<void>;
203
259
  switchPrimaryWallet: (chainType: ChainType) => Promise<Account>;
204
260
  signMessage: (message: string) => Promise<string>;
@@ -221,8 +277,8 @@ interface UseAccountResult {
221
277
  declare function useAccount(): UseAccountResult;
222
278
 
223
279
  interface UseConnectResult {
224
- connect: (type: WalletType, chainId?: number) => Promise<Account>;
225
- connectAdditional: (type: WalletType, chainId?: number) => Promise<Account>;
280
+ connect: (type: WalletType, chainId?: number | number[]) => Promise<Account>;
281
+ connectAdditional: (type: WalletType, chainId?: number | number[]) => Promise<Account>;
226
282
  isConnecting: boolean;
227
283
  error: Error | null;
228
284
  }
@@ -249,4 +305,27 @@ interface UseSignTransactionResult {
249
305
  }
250
306
  declare function useSignTransaction(): UseSignTransactionResult;
251
307
 
252
- export { type UseAccountResult, type UseConnectResult, type UseDisconnectResult, type UseSignMessageResult, type UseSignTransactionResult, type WalletContextValue, WalletProvider, type WalletProviderProps, useAccount, useConnect, useDisconnect, useSignMessage, useSignTransaction, useWallet };
308
+ interface UseQRCodeSignerResult {
309
+ qrCodeDataUrl: string | null;
310
+ status: QRCodeSignStatus;
311
+ result: QRCodeSignResult | null;
312
+ isPolling: boolean;
313
+ startSign: () => Promise<string>;
314
+ stopPolling: () => void;
315
+ cancel: () => void;
316
+ error: Error | null;
317
+ }
318
+ declare function useQRCodeSigner(config: QRCodeSignerConfig): UseQRCodeSignerResult;
319
+
320
+ interface QRCodeModalProps {
321
+ isOpen: boolean;
322
+ onClose: () => void;
323
+ qrCodeDataUrl: string | null;
324
+ status: QRCodeSignStatus;
325
+ error?: Error | null;
326
+ title?: string;
327
+ description?: string;
328
+ }
329
+ declare function QRCodeModal({ isOpen, onClose, qrCodeDataUrl, status, error, title, description, }: QRCodeModalProps): React.JSX.Element | null;
330
+
331
+ export { QRCodeModal, type QRCodeModalProps, type UseAccountResult, type UseConnectResult, type UseDisconnectResult, type UseQRCodeSignerResult, type UseSignMessageResult, type UseSignTransactionResult, type WalletContextValue, WalletProvider, type WalletProviderProps, useAccount, useConnect, useDisconnect, useQRCodeSigner, useSignMessage, useSignTransaction, useWallet };
@@ -18,7 +18,9 @@ declare enum WalletType {
18
18
  COINBASE_WALLET = "coinbase-wallet",
19
19
  TRONLINK = "tronlink",
20
20
  WALLETCONNECT_TRON = "walletconnect-tron",
21
- PRIVATE_KEY = "private-key"
21
+ PRIVATE_KEY = "private-key",
22
+ DEEP_LINK_EVM = "deep-link-evm",
23
+ DEEP_LINK_TRON = "deep-link-tron"
22
24
  }
23
25
  declare enum WalletState {
24
26
  DISCONNECTED = "disconnected",
@@ -47,9 +49,10 @@ interface IWalletAdapter extends ISigner {
47
49
  readonly icon?: string;
48
50
  state: WalletState;
49
51
  currentAccount: Account | null;
50
- connect(chainId?: number): Promise<Account>;
52
+ connect(chainId?: number | number[]): Promise<Account>;
51
53
  disconnect(): Promise<void>;
52
54
  isAvailable(): Promise<boolean>;
55
+ isConnected(): boolean;
53
56
  signMessage(message: string): Promise<string>;
54
57
  signTransaction?(transaction: Transaction): Promise<string>;
55
58
  signTypedData?(typedData: any): Promise<string>;
@@ -145,14 +148,63 @@ interface WalletManagerEvents extends Record<string, (...args: any[]) => void> {
145
148
  error: (error: Error) => void;
146
149
  }
147
150
 
151
+ interface QRCodeSignerConfig {
152
+ requestId: string;
153
+ requestUrl: string;
154
+ pollUrl?: string;
155
+ pollInterval?: number;
156
+ timeout?: number;
157
+ pollFn?: (requestId: string) => Promise<QRCodeSignResult | null>;
158
+ }
159
+ interface QRCodeSignResult {
160
+ completed: boolean;
161
+ signature?: string;
162
+ error?: string;
163
+ signer?: string;
164
+ }
165
+ declare enum QRCodeSignStatus {
166
+ WAITING = "waiting",
167
+ PENDING = "pending",
168
+ SUCCESS = "success",
169
+ FAILED = "failed",
170
+ TIMEOUT = "timeout",
171
+ CANCELLED = "cancelled"
172
+ }
173
+ declare class QRCodeSigner {
174
+ private config;
175
+ private pollTimer;
176
+ private timeoutTimer;
177
+ private status;
178
+ private qrCodeDataUrl;
179
+ private result;
180
+ constructor(config: QRCodeSignerConfig);
181
+ generateQRCode(options?: {
182
+ width?: number;
183
+ margin?: number;
184
+ color?: {
185
+ dark?: string;
186
+ light?: string;
187
+ };
188
+ }): Promise<string>;
189
+ startPolling(onStatusChange?: (status: QRCodeSignStatus) => void, onResult?: (result: QRCodeSignResult) => void): Promise<string>;
190
+ private defaultPoll;
191
+ stopPolling(): void;
192
+ cancel(): void;
193
+ getStatus(): QRCodeSignStatus;
194
+ getQRCodeUrl(): string;
195
+ getResult(): QRCodeSignResult | null;
196
+ cleanup(): void;
197
+ }
198
+
148
199
  declare class WalletManager extends TypedEventEmitter<WalletManagerEvents> {
149
200
  private config;
150
201
  private registry;
151
202
  private primaryWallet;
152
203
  private connectedWallets;
153
204
  constructor(config?: WalletManagerConfig);
154
- connect(type: WalletType, chainId?: number): Promise<Account>;
155
- connectAdditional(type: WalletType, chainId?: number): Promise<Account>;
205
+ hasAdapter(type: WalletType): boolean;
206
+ connect(type: WalletType, chainId?: number | number[]): Promise<Account>;
207
+ connectAdditional(type: WalletType, chainId?: number | number[]): Promise<Account>;
156
208
  connectWithPrivateKey(privateKey: string, chainId?: number): Promise<Account>;
157
209
  disconnect(): Promise<void>;
158
210
  disconnectAll(): Promise<void>;
@@ -162,6 +214,10 @@ declare class WalletManager extends TypedEventEmitter<WalletManagerEvents> {
162
214
  getWalletByChainType(chainType: ChainType): IWalletAdapter | null;
163
215
  signMessage(message: string): Promise<string>;
164
216
  signMessageWithChainType(message: string, chainType?: ChainType): Promise<string>;
217
+ createQRCodeSigner(message: string, config: Omit<QRCodeSignerConfig, 'requestId' | 'requestUrl'> & {
218
+ requestId: string;
219
+ requestUrl: string;
220
+ }): QRCodeSigner;
165
221
  signTypedData(typedData: any, chainType?: ChainType): Promise<string>;
166
222
  signTransaction(transaction: any): Promise<string>;
167
223
  signTransactionWithChainType(transaction: any, chainType?: ChainType): Promise<string>;
@@ -197,8 +253,8 @@ interface WalletContextValue {
197
253
  isConnected: boolean;
198
254
  connectedWallets: ConnectedWallet[];
199
255
  isRestoring: boolean;
200
- connect: (type: WalletType, chainId?: number) => Promise<Account>;
201
- connectAdditional: (type: WalletType, chainId?: number) => Promise<Account>;
256
+ connect: (type: WalletType, chainId?: number | number[]) => Promise<Account>;
257
+ connectAdditional: (type: WalletType, chainId?: number | number[]) => Promise<Account>;
202
258
  disconnect: () => Promise<void>;
203
259
  switchPrimaryWallet: (chainType: ChainType) => Promise<Account>;
204
260
  signMessage: (message: string) => Promise<string>;
@@ -221,8 +277,8 @@ interface UseAccountResult {
221
277
  declare function useAccount(): UseAccountResult;
222
278
 
223
279
  interface UseConnectResult {
224
- connect: (type: WalletType, chainId?: number) => Promise<Account>;
225
- connectAdditional: (type: WalletType, chainId?: number) => Promise<Account>;
280
+ connect: (type: WalletType, chainId?: number | number[]) => Promise<Account>;
281
+ connectAdditional: (type: WalletType, chainId?: number | number[]) => Promise<Account>;
226
282
  isConnecting: boolean;
227
283
  error: Error | null;
228
284
  }
@@ -249,4 +305,27 @@ interface UseSignTransactionResult {
249
305
  }
250
306
  declare function useSignTransaction(): UseSignTransactionResult;
251
307
 
252
- export { type UseAccountResult, type UseConnectResult, type UseDisconnectResult, type UseSignMessageResult, type UseSignTransactionResult, type WalletContextValue, WalletProvider, type WalletProviderProps, useAccount, useConnect, useDisconnect, useSignMessage, useSignTransaction, useWallet };
308
+ interface UseQRCodeSignerResult {
309
+ qrCodeDataUrl: string | null;
310
+ status: QRCodeSignStatus;
311
+ result: QRCodeSignResult | null;
312
+ isPolling: boolean;
313
+ startSign: () => Promise<string>;
314
+ stopPolling: () => void;
315
+ cancel: () => void;
316
+ error: Error | null;
317
+ }
318
+ declare function useQRCodeSigner(config: QRCodeSignerConfig): UseQRCodeSignerResult;
319
+
320
+ interface QRCodeModalProps {
321
+ isOpen: boolean;
322
+ onClose: () => void;
323
+ qrCodeDataUrl: string | null;
324
+ status: QRCodeSignStatus;
325
+ error?: Error | null;
326
+ title?: string;
327
+ description?: string;
328
+ }
329
+ declare function QRCodeModal({ isOpen, onClose, qrCodeDataUrl, status, error, title, description, }: QRCodeModalProps): React.JSX.Element | null;
330
+
331
+ export { QRCodeModal, type QRCodeModalProps, type UseAccountResult, type UseConnectResult, type UseDisconnectResult, type UseQRCodeSignerResult, type UseSignMessageResult, type UseSignTransactionResult, type WalletContextValue, WalletProvider, type WalletProviderProps, useAccount, useConnect, useDisconnect, useQRCodeSigner, useSignMessage, useSignTransaction, useWallet };