@human.tech/waap-sdk 1.2.4 → 2.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/CHANGELOG.md +25 -1
- package/dist/index.d.mts +967 -0
- package/dist/index.d.ts +967 -15
- package/dist/index.js +2191 -2
- package/dist/index.mjs +2162 -0
- package/package.json +18 -36
- package/dist/hooks/useWaapTransaction.d.ts +0 -84
- package/dist/index.js.map +0 -1
- package/dist/index.modern.mjs +0 -2
- package/dist/index.modern.mjs.map +0 -1
- package/dist/index.module.js +0 -2
- package/dist/index.module.js.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/dist/lib/UIMessageManager.d.ts +0 -19
- package/dist/lib/WalletConnect.d.ts +0 -30
- package/dist/lib/WalletMessageManager.d.ts +0 -59
- package/dist/lib/provider/EthereumProvider.d.ts +0 -108
- package/dist/lib/provider/EthereumProviderExtension.d.ts +0 -26
- package/dist/lib/provider/requests.d.ts +0 -17
- package/dist/lib/provider/types.d.ts +0 -49
- package/dist/lib/provider/utils.d.ts +0 -4
- package/dist/lib/sui/SuiWallet.d.ts +0 -182
- package/dist/lib/sui/index.d.ts +0 -7
- package/dist/lib/sui/init.d.ts +0 -30
- package/dist/lib/sui/register.d.ts +0 -39
- package/dist/lib/sui/types.d.ts +0 -284
- package/dist/ui/WaapComponent.d.ts +0 -37
- package/dist/ui/index.d.ts +0 -11
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,967 @@
|
|
|
1
|
+
import { CredentialType, RequestPermissionTokenParams, ProjectConfig, CustomConfig, AuthenticationMethod, RequestPermissionTokenResult, SilkNotificationData, SILK_METHOD, SilkResponse, SilkRequest, AsyncTxConfirmedEvent, AsyncTxFailedEvent, AsyncSignCompleteEvent, AsyncTxPendingEvent } from '@human.tech/waap-interface-core';
|
|
2
|
+
export { Async2faRequiredEvent, AsyncEvent, AsyncEventType, AsyncSignCompleteEvent, AsyncSignFailedEvent, AsyncSignPendingEvent, AsyncTxConfirmedEvent, AsyncTxFailedEvent, AsyncTxPendingEvent, AsyncTxResponse, AuthenticationMethod, CredentialType, ProjectConfig, RequestPermissionTokenParams, RequestPermissionTokenResult, SILK_METHOD, SilkOptions, SocialProvider, StylesConfig, SILK_METHOD as WAAP_METHOD } from '@human.tech/waap-interface-core';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
export { rpcMethodRequiresUI } from '@human.tech/waap-constants';
|
|
5
|
+
|
|
6
|
+
interface RequestArguments {
|
|
7
|
+
method: string;
|
|
8
|
+
params?: unknown[] | object;
|
|
9
|
+
async?: boolean;
|
|
10
|
+
withPT?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface EthereumProviderInterface {
|
|
13
|
+
enable(): Promise<unknown>;
|
|
14
|
+
isConnected(): boolean;
|
|
15
|
+
request(args: RequestArguments): Promise<unknown>;
|
|
16
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
17
|
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
|
18
|
+
}
|
|
19
|
+
type LoginResponse = 'waap' | 'human' | 'injected' | 'walletconnect' | null;
|
|
20
|
+
interface SilkEthereumProviderInterface extends EthereumProviderInterface {
|
|
21
|
+
isSilk: boolean;
|
|
22
|
+
connected: boolean;
|
|
23
|
+
login(customProvider?: any): Promise<LoginResponse>;
|
|
24
|
+
logout(): Promise<unknown>;
|
|
25
|
+
getLoginMethod(): LoginResponse;
|
|
26
|
+
requestEmail(): Promise<unknown>;
|
|
27
|
+
requestSBT(type: CredentialType): Promise<unknown>;
|
|
28
|
+
requestPermissionToken(params: RequestPermissionTokenParams): Promise<unknown>;
|
|
29
|
+
toggleDarkMode(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
interface InitSilkOptions {
|
|
32
|
+
referralCode?: string;
|
|
33
|
+
project?: ProjectConfig;
|
|
34
|
+
config?: CustomConfig;
|
|
35
|
+
useStaging?: boolean;
|
|
36
|
+
walletConnectProjectId?: string;
|
|
37
|
+
/**
|
|
38
|
+
* When true, eth_sendTransaction resolves with the pre-calculated tx hash
|
|
39
|
+
* immediately after signing. Broadcasting and confirmation continue in the
|
|
40
|
+
* background with events (waap_sign_complete, waap_tx_pending, waap_tx_confirmed, waap_tx_failed).
|
|
41
|
+
* Other signing methods (personal_sign, eth_signTypedData_v4, eth_signTransaction)
|
|
42
|
+
* are unaffected — they always resolve with the signature directly.
|
|
43
|
+
* Applies to ALL eth_sendTransaction calls for this SDK instance.
|
|
44
|
+
* Default: false
|
|
45
|
+
*/
|
|
46
|
+
asyncTxs?: boolean;
|
|
47
|
+
/** @deprecated Use `asyncTxs` instead. */
|
|
48
|
+
asyncSigning?: boolean;
|
|
49
|
+
}
|
|
50
|
+
type SilkProvider = SilkEthereumProviderInterface;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param referralCode - WaaP points referral code
|
|
54
|
+
* @param customConfig - WaaP custom UI configuration
|
|
55
|
+
* @param project - WaaP project configuration
|
|
56
|
+
* @param useStaging - Whether to use the staging environment
|
|
57
|
+
* @param walletConnectProjectId - WalletConnect project ID (only required when passing `wallet` to `authenticationMethods`)
|
|
58
|
+
* @param walletConnectOptionalChains - Optional chains to use for WalletConnect
|
|
59
|
+
*/
|
|
60
|
+
declare const initWaaP: (params?: InitSilkOptions) => SilkEthereumProviderInterface;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* WaaP Component
|
|
64
|
+
*
|
|
65
|
+
* A custom HTML element that allows developers to control where the WaaP wallet
|
|
66
|
+
* renders in their UI. When present, the wallet will render inside this component
|
|
67
|
+
* instead of as a centered modal with backdrop.
|
|
68
|
+
*
|
|
69
|
+
* Usage in HTML:
|
|
70
|
+
* ```html
|
|
71
|
+
* <waap-wallet></waap-wallet>
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* Usage in React/JSX:
|
|
75
|
+
* ```tsx
|
|
76
|
+
* function App() {
|
|
77
|
+
* return <waap-wallet style={{ width: '400px', height: '600px' }} />
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* Custom HTML element for WaaP wallet
|
|
83
|
+
* Only defined in browser environments to avoid SSR issues
|
|
84
|
+
*/
|
|
85
|
+
declare let WaapWalletElement: any;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A Ethereum provder API (from EIP 1193) for Silk.
|
|
89
|
+
* https://eips.ethereum.org/EIPS/eip-1193
|
|
90
|
+
*/
|
|
91
|
+
/**
|
|
92
|
+
* Resources:
|
|
93
|
+
* - EIP-2255: Wallet Permissions System: https://eips.ethereum.org/EIPS/eip-2255
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
declare class EthereumProviderExtension extends EventEmitter implements EthereumProviderInterface {
|
|
97
|
+
readonly isSilk = true;
|
|
98
|
+
connected: boolean;
|
|
99
|
+
config: CustomConfig;
|
|
100
|
+
constructor(customConfig?: CustomConfig);
|
|
101
|
+
sendToExtension(args: RequestArguments): Promise<unknown>;
|
|
102
|
+
request(args: RequestArguments): Promise<unknown>;
|
|
103
|
+
enable(): Promise<unknown>;
|
|
104
|
+
isConnected(): boolean;
|
|
105
|
+
login(): Promise<unknown>;
|
|
106
|
+
requestSBT(type: CredentialType): Promise<unknown>;
|
|
107
|
+
toggleDarkMode(): Promise<void>;
|
|
108
|
+
safe(): Promise<unknown>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
declare class SilkWalletConnect {
|
|
112
|
+
private static instance;
|
|
113
|
+
private static projectId;
|
|
114
|
+
private static chains;
|
|
115
|
+
/**
|
|
116
|
+
* Set the WalletConnect project ID programmatically
|
|
117
|
+
* Use this if environment variables aren't working in your setup
|
|
118
|
+
*
|
|
119
|
+
* @param id - The WalletConnect project ID to use
|
|
120
|
+
*/
|
|
121
|
+
static setProjectId(id: string): void;
|
|
122
|
+
static getProjectIdFromEnv(): string | undefined;
|
|
123
|
+
static getInstance(): Promise<any>;
|
|
124
|
+
static listenToAccountChangeEvent(): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Wait for WalletConnect to be properly initialized and connected
|
|
127
|
+
* @returns Promise<boolean> - true if connected, false if timeout reached
|
|
128
|
+
*/
|
|
129
|
+
static waitForReadyAndCheckConnection(): Promise<boolean>;
|
|
130
|
+
/**
|
|
131
|
+
* Check if WalletConnect is currently connected (immediate check, no waiting)
|
|
132
|
+
* @returns boolean - true if connected, false otherwise
|
|
133
|
+
*/
|
|
134
|
+
static isConnected(): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Get the wallet provider from the WalletConnect instance
|
|
137
|
+
* @returns The wallet provider or null if not available
|
|
138
|
+
*/
|
|
139
|
+
static getWalletProvider(): any;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Type definitions for Sui Wallet Standard integration.
|
|
144
|
+
*
|
|
145
|
+
* @see https://docs.sui.io/standards/wallet-standard
|
|
146
|
+
*/
|
|
147
|
+
/**
|
|
148
|
+
* Sui chain identifiers.
|
|
149
|
+
*/
|
|
150
|
+
type SuiChain = 'sui:mainnet' | 'sui:testnet' | 'sui:devnet' | 'sui:localnet';
|
|
151
|
+
/**
|
|
152
|
+
* Sui account representation following Wallet Standard.
|
|
153
|
+
*/
|
|
154
|
+
interface SuiAccount {
|
|
155
|
+
/** Sui address (32 bytes, 0x-prefixed hex string) */
|
|
156
|
+
readonly address: string;
|
|
157
|
+
/** Compressed public key bytes (33 bytes for Secp256k1) */
|
|
158
|
+
readonly publicKey: Uint8Array;
|
|
159
|
+
/** Supported chains for this account */
|
|
160
|
+
readonly chains: readonly SuiChain[];
|
|
161
|
+
/** Supported features for this account */
|
|
162
|
+
readonly features: readonly string[];
|
|
163
|
+
/** Optional display label */
|
|
164
|
+
readonly label?: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Input for sui:signPersonalMessage feature.
|
|
168
|
+
*/
|
|
169
|
+
interface SuiSignPersonalMessageInput {
|
|
170
|
+
/** Message bytes to sign */
|
|
171
|
+
message: Uint8Array;
|
|
172
|
+
/** Account to sign with */
|
|
173
|
+
account: SuiAccount;
|
|
174
|
+
/** Optional chain identifier */
|
|
175
|
+
chain?: SuiChain;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Output from sui:signPersonalMessage feature.
|
|
179
|
+
*/
|
|
180
|
+
interface SuiSignPersonalMessageOutput {
|
|
181
|
+
/** Base64-encoded message bytes */
|
|
182
|
+
bytes: string;
|
|
183
|
+
/** Base64-encoded signature (98 bytes for Secp256k1) */
|
|
184
|
+
signature: string;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Input for sui:signTransaction feature.
|
|
188
|
+
*/
|
|
189
|
+
interface SuiSignTransactionInput {
|
|
190
|
+
/** BCS-serialized transaction bytes */
|
|
191
|
+
transaction: Uint8Array;
|
|
192
|
+
/** Account to sign with */
|
|
193
|
+
account: SuiAccount;
|
|
194
|
+
/** Optional chain identifier */
|
|
195
|
+
chain?: SuiChain;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Output from sui:signTransaction feature.
|
|
199
|
+
*/
|
|
200
|
+
interface SuiSignTransactionOutput {
|
|
201
|
+
/** Base64-encoded transaction bytes */
|
|
202
|
+
bytes: string;
|
|
203
|
+
/** Base64-encoded signature */
|
|
204
|
+
signature: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Input for sui:signAndExecuteTransaction feature.
|
|
208
|
+
*/
|
|
209
|
+
interface SuiSignAndExecuteTransactionInput {
|
|
210
|
+
/** BCS-serialized transaction bytes */
|
|
211
|
+
transaction: Uint8Array;
|
|
212
|
+
/** Account to sign with */
|
|
213
|
+
account: SuiAccount;
|
|
214
|
+
/** Optional chain identifier */
|
|
215
|
+
chain?: SuiChain;
|
|
216
|
+
/** Options for execution */
|
|
217
|
+
options?: unknown;
|
|
218
|
+
/** Request type */
|
|
219
|
+
requestType?: 'WaitForEffectsCert' | 'WaitForLocalExecution';
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Output from sui:signAndExecuteTransaction feature.
|
|
223
|
+
*/
|
|
224
|
+
interface SuiSignAndExecuteTransactionOutput {
|
|
225
|
+
digest: string;
|
|
226
|
+
effects?: unknown;
|
|
227
|
+
errors?: unknown[];
|
|
228
|
+
[key: string]: unknown;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Connect input options.
|
|
232
|
+
*/
|
|
233
|
+
interface SuiConnectInput {
|
|
234
|
+
/** If true, attempt silent connection without UI prompt */
|
|
235
|
+
silent?: boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Connect output with accounts.
|
|
239
|
+
*/
|
|
240
|
+
interface SuiConnectOutput {
|
|
241
|
+
/** Connected accounts */
|
|
242
|
+
accounts: readonly SuiAccount[];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Input for legacy sui:signTransactionBlock feature.
|
|
246
|
+
*/
|
|
247
|
+
interface SuiSignTransactionBlockInput {
|
|
248
|
+
/** BCS-serialized transaction block bytes */
|
|
249
|
+
transactionBlock: Uint8Array;
|
|
250
|
+
/** Account to sign with */
|
|
251
|
+
account: SuiAccount;
|
|
252
|
+
/** Optional chain identifier */
|
|
253
|
+
chain?: SuiChain;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Output for legacy sui:signTransactionBlock feature.
|
|
257
|
+
*/
|
|
258
|
+
interface SuiSignTransactionBlockOutput extends SuiSignTransactionOutput {
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Input for legacy sui:signAndExecuteTransactionBlock feature.
|
|
262
|
+
*/
|
|
263
|
+
interface SuiSignAndExecuteTransactionBlockInput {
|
|
264
|
+
/** BCS-serialized transaction block bytes */
|
|
265
|
+
transactionBlock: Uint8Array;
|
|
266
|
+
/** Account to sign with */
|
|
267
|
+
account: SuiAccount;
|
|
268
|
+
/** Optional chain identifier */
|
|
269
|
+
chain?: SuiChain;
|
|
270
|
+
/** Options for execution */
|
|
271
|
+
options?: unknown;
|
|
272
|
+
/** Request type */
|
|
273
|
+
requestType?: 'WaitForEffectsCert' | 'WaitForLocalExecution';
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Output for legacy sui:signAndExecuteTransactionBlock feature.
|
|
277
|
+
*/
|
|
278
|
+
interface SuiSignAndExecuteTransactionBlockOutput extends SuiSignAndExecuteTransactionOutput {
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Wallet change event properties.
|
|
282
|
+
*/
|
|
283
|
+
interface SuiWalletChangeProperties {
|
|
284
|
+
chains?: readonly SuiChain[];
|
|
285
|
+
accounts?: readonly SuiAccount[];
|
|
286
|
+
features?: Record<string, unknown>;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Event listener types.
|
|
290
|
+
*/
|
|
291
|
+
type SuiWalletEventListener = (properties: SuiWalletChangeProperties) => void;
|
|
292
|
+
/**
|
|
293
|
+
* Wallet icon type (data URL).
|
|
294
|
+
*/
|
|
295
|
+
type WalletIcon = `data:image/${'svg+xml' | 'webp' | 'png' | 'gif'};base64,${string}`;
|
|
296
|
+
/**
|
|
297
|
+
* Wallet Standard features object.
|
|
298
|
+
*/
|
|
299
|
+
interface WaaPSuiWalletFeatures {
|
|
300
|
+
'standard:connect': {
|
|
301
|
+
version: '1.0.0';
|
|
302
|
+
connect: (input?: SuiConnectInput) => Promise<SuiConnectOutput>;
|
|
303
|
+
};
|
|
304
|
+
'standard:disconnect': {
|
|
305
|
+
version: '1.0.0';
|
|
306
|
+
disconnect: () => Promise<void>;
|
|
307
|
+
};
|
|
308
|
+
'standard:events': {
|
|
309
|
+
version: '1.0.0';
|
|
310
|
+
on: (event: 'change', listener: SuiWalletEventListener) => () => void;
|
|
311
|
+
};
|
|
312
|
+
'sui:signPersonalMessage': {
|
|
313
|
+
version: '1.1.0';
|
|
314
|
+
signPersonalMessage: (input: SuiSignPersonalMessageInput) => Promise<SuiSignPersonalMessageOutput>;
|
|
315
|
+
};
|
|
316
|
+
'sui:signTransaction': {
|
|
317
|
+
version: '2.0.0';
|
|
318
|
+
signTransaction: (input: SuiSignTransactionInput) => Promise<SuiSignTransactionOutput>;
|
|
319
|
+
};
|
|
320
|
+
'sui:switchChain': {
|
|
321
|
+
version: '1.0.0';
|
|
322
|
+
switchChain: (input: {
|
|
323
|
+
chain: SuiChain;
|
|
324
|
+
}) => Promise<void>;
|
|
325
|
+
};
|
|
326
|
+
'sui:signAndExecuteTransaction': {
|
|
327
|
+
version: '1.0.0';
|
|
328
|
+
signAndExecuteTransaction: (input: SuiSignAndExecuteTransactionInput) => Promise<SuiSignAndExecuteTransactionOutput>;
|
|
329
|
+
};
|
|
330
|
+
'sui:signTransactionBlock': {
|
|
331
|
+
version: '2.0.0';
|
|
332
|
+
signTransactionBlock: (input: SuiSignTransactionBlockInput) => Promise<SuiSignTransactionBlockOutput>;
|
|
333
|
+
};
|
|
334
|
+
'sui:signAndExecuteTransactionBlock': {
|
|
335
|
+
version: '1.0.0';
|
|
336
|
+
signAndExecuteTransactionBlock: (input: SuiSignAndExecuteTransactionBlockInput) => Promise<SuiSignAndExecuteTransactionBlockOutput>;
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* WaaP Sui Wallet interface.
|
|
341
|
+
*/
|
|
342
|
+
interface WaaPSuiWalletInterface {
|
|
343
|
+
/** Wallet name */
|
|
344
|
+
readonly name: string;
|
|
345
|
+
/** Wallet version */
|
|
346
|
+
readonly version: string;
|
|
347
|
+
/** Wallet icon */
|
|
348
|
+
readonly icon: WalletIcon;
|
|
349
|
+
/** Supported chains */
|
|
350
|
+
readonly chains: readonly SuiChain[];
|
|
351
|
+
/** Connected accounts */
|
|
352
|
+
readonly accounts: readonly SuiAccount[];
|
|
353
|
+
/** Wallet Standard features */
|
|
354
|
+
readonly features: WaaPSuiWalletFeatures;
|
|
355
|
+
/**
|
|
356
|
+
* Connect to the wallet.
|
|
357
|
+
*/
|
|
358
|
+
connect(input?: SuiConnectInput): Promise<SuiConnectOutput>;
|
|
359
|
+
/**
|
|
360
|
+
* Disconnect from the wallet.
|
|
361
|
+
*/
|
|
362
|
+
disconnect(): Promise<void>;
|
|
363
|
+
/**
|
|
364
|
+
* Switch the active chain.
|
|
365
|
+
*/
|
|
366
|
+
switchChain(input: {
|
|
367
|
+
chain: SuiChain;
|
|
368
|
+
}): Promise<void>;
|
|
369
|
+
/**
|
|
370
|
+
* Sign a personal message.
|
|
371
|
+
*/
|
|
372
|
+
signPersonalMessage(input: SuiSignPersonalMessageInput): Promise<SuiSignPersonalMessageOutput>;
|
|
373
|
+
/**
|
|
374
|
+
* Sign and execute a transaction.
|
|
375
|
+
*/
|
|
376
|
+
signAndExecuteTransaction(input: SuiSignAndExecuteTransactionInput): Promise<SuiSignAndExecuteTransactionOutput>;
|
|
377
|
+
/**
|
|
378
|
+
* Sign a transaction block (Legacy).
|
|
379
|
+
*/
|
|
380
|
+
signTransactionBlock(input: SuiSignTransactionBlockInput): Promise<SuiSignTransactionBlockOutput>;
|
|
381
|
+
/**
|
|
382
|
+
* Sign and execute a transaction block (Legacy).
|
|
383
|
+
*/
|
|
384
|
+
signAndExecuteTransactionBlock(input: SuiSignAndExecuteTransactionBlockInput): Promise<SuiSignAndExecuteTransactionBlockOutput>;
|
|
385
|
+
/**
|
|
386
|
+
* Subscribe to wallet events.
|
|
387
|
+
* @returns Unsubscribe function
|
|
388
|
+
*/
|
|
389
|
+
on(event: 'change', listener: SuiWalletEventListener): () => void;
|
|
390
|
+
/** custom WaaP features */
|
|
391
|
+
/**
|
|
392
|
+
* Request the user's email address.
|
|
393
|
+
* @returns Promise resolving to the user's email address
|
|
394
|
+
*/
|
|
395
|
+
requestEmail(): Promise<string>;
|
|
396
|
+
/**
|
|
397
|
+
* Request a Permission Token from the user.
|
|
398
|
+
* Allows pre-authorised batches of Sui transactions without individual confirmations.
|
|
399
|
+
*
|
|
400
|
+
* @param params - Allowed addresses, chainId (e.g. "sui:mainnet"), spend limit, expiry
|
|
401
|
+
* @returns Promise resolving to a RequestPermissionTokenResult
|
|
402
|
+
*/
|
|
403
|
+
requestPermissionToken(params: RequestPermissionTokenParams): Promise<RequestPermissionTokenResult>;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Sui-supported authentication methods (no 'wallet/walletconnect' support yet)
|
|
408
|
+
* Also it is not necessary as @mysten/dapp-kit handles wallet choices
|
|
409
|
+
* todo: maybe add a modal to list out Sui wallets discovered as per Wallet Standard
|
|
410
|
+
*/
|
|
411
|
+
type SuiAuthenticationMethod = Exclude<AuthenticationMethod, 'wallet'>;
|
|
412
|
+
/**
|
|
413
|
+
* Sui-specific custom configuration
|
|
414
|
+
*/
|
|
415
|
+
interface SuiCustomConfig extends Omit<CustomConfig, 'authenticationMethods'> {
|
|
416
|
+
authenticationMethods?: SuiAuthenticationMethod[];
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Initialization options for WaaP Sui Wallet.
|
|
420
|
+
*/
|
|
421
|
+
interface InitWaaPSuiOptions {
|
|
422
|
+
/** Use staging environment */
|
|
423
|
+
useStaging?: boolean;
|
|
424
|
+
/** WaaP points referral code */
|
|
425
|
+
referralCode?: string;
|
|
426
|
+
/** WaaP project configuration */
|
|
427
|
+
project?: ProjectConfig;
|
|
428
|
+
/** WaaP custom UI configuration */
|
|
429
|
+
config?: SuiCustomConfig;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* UIMessageManager emits events whose intended recipient is the UI
|
|
434
|
+
* of the silk-wallet-sdk. It is used by EthereumProvider to
|
|
435
|
+
* communicate with the UI.
|
|
436
|
+
*
|
|
437
|
+
* Note that the UI part of silk-wallet-sdk is not the Silk
|
|
438
|
+
* website but rather the actual iframe tag that gets embedded
|
|
439
|
+
* in the host site.
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
declare enum UI_EVENT_NAMES {
|
|
443
|
+
show_modal = "show_modal",
|
|
444
|
+
hide_modal = "hide_modal"
|
|
445
|
+
}
|
|
446
|
+
declare class UIMessageManager extends EventEmitter {
|
|
447
|
+
constructor();
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* WaaP Sui Wallet implementation.
|
|
452
|
+
*
|
|
453
|
+
* Implements the Sui Wallet Standard to allow dApps to:
|
|
454
|
+
* - Connect/disconnect
|
|
455
|
+
* - Sign personal messages
|
|
456
|
+
* - (Future) Sign and execute transactions
|
|
457
|
+
*/
|
|
458
|
+
declare class WaaPSuiWallet implements WaaPSuiWalletInterface {
|
|
459
|
+
readonly name = "WaaP";
|
|
460
|
+
readonly version = "1.0.0";
|
|
461
|
+
readonly icon: WalletIcon;
|
|
462
|
+
private _accounts;
|
|
463
|
+
private _chains;
|
|
464
|
+
private walletMessageManager;
|
|
465
|
+
private uiMessageManager;
|
|
466
|
+
private internalEventEmitter;
|
|
467
|
+
private changeListeners;
|
|
468
|
+
/**
|
|
469
|
+
* Creates a new WaaPSuiWallet instance.
|
|
470
|
+
*
|
|
471
|
+
* @param iframeWindow - The contentWindow of the WaaP iframe
|
|
472
|
+
* @param options - Initialization options
|
|
473
|
+
*/
|
|
474
|
+
constructor(iframeWindow: Window, options?: InitWaaPSuiOptions);
|
|
475
|
+
/**
|
|
476
|
+
* Refresh accounts by making a silent connect request.
|
|
477
|
+
* Used internally when account changes are detected.
|
|
478
|
+
*/
|
|
479
|
+
private refreshAccounts;
|
|
480
|
+
/**
|
|
481
|
+
* Supported chains.
|
|
482
|
+
*/
|
|
483
|
+
get chains(): readonly SuiChain[];
|
|
484
|
+
/**
|
|
485
|
+
* Connected accounts.
|
|
486
|
+
*/
|
|
487
|
+
get accounts(): readonly SuiAccount[];
|
|
488
|
+
/**
|
|
489
|
+
* UI message manager for showing/hiding modal.
|
|
490
|
+
*/
|
|
491
|
+
get ui(): UIMessageManager;
|
|
492
|
+
/**
|
|
493
|
+
* Connect to the wallet.
|
|
494
|
+
*/
|
|
495
|
+
connect(input?: SuiConnectInput): Promise<SuiConnectOutput>;
|
|
496
|
+
/**
|
|
497
|
+
* Disconnect from the wallet.
|
|
498
|
+
*/
|
|
499
|
+
disconnect(): Promise<void>;
|
|
500
|
+
/**
|
|
501
|
+
* Sign a personal message.
|
|
502
|
+
*
|
|
503
|
+
* @param input - Sign personal message input
|
|
504
|
+
* @returns Signed message result with bytes and signature
|
|
505
|
+
*/
|
|
506
|
+
signPersonalMessage(input: SuiSignPersonalMessageInput): Promise<SuiSignPersonalMessageOutput>;
|
|
507
|
+
/**
|
|
508
|
+
* Extract the destination addresses from BCS-serialized Sui transaction bytes.
|
|
509
|
+
*
|
|
510
|
+
* Unlike EVM transactions where `to` is a top-level field, Sui transaction
|
|
511
|
+
* destinations are embedded in BCS-encoded programmable transaction blocks.
|
|
512
|
+
* We deserialize with Transaction.from() and inspect TransferObjects commands.
|
|
513
|
+
*
|
|
514
|
+
* Only TransferObjects destinations are extracted — MoveCall package addresses
|
|
515
|
+
* are not user-facing recipients and should not be validated against a PT's
|
|
516
|
+
* allowedAddresses list.
|
|
517
|
+
*
|
|
518
|
+
* Returns an empty array if no TransferObjects are found or deserialization fails.
|
|
519
|
+
*/
|
|
520
|
+
private extractTransferAddresses;
|
|
521
|
+
/**
|
|
522
|
+
* Helper to resolve transaction bytes from various input formats.
|
|
523
|
+
* If the input is a Transaction/TransactionBlock object, it builds it.
|
|
524
|
+
*/
|
|
525
|
+
private resolveTransactionBytes;
|
|
526
|
+
/**
|
|
527
|
+
* Sign a transaction.
|
|
528
|
+
*
|
|
529
|
+
* @param input - Sign transaction input with transaction
|
|
530
|
+
* @returns Signed transaction result with bytes and signature
|
|
531
|
+
*/
|
|
532
|
+
signTransaction(input: {
|
|
533
|
+
transaction: unknown;
|
|
534
|
+
account: SuiAccount;
|
|
535
|
+
chain?: SuiChain;
|
|
536
|
+
}): Promise<{
|
|
537
|
+
bytes: string;
|
|
538
|
+
signature: string;
|
|
539
|
+
}>;
|
|
540
|
+
/**
|
|
541
|
+
* Sign and execute a transaction.
|
|
542
|
+
*
|
|
543
|
+
* @param input - Sign and execute transaction input
|
|
544
|
+
*/
|
|
545
|
+
signAndExecuteTransaction(input: SuiSignAndExecuteTransactionInput): Promise<SuiSignAndExecuteTransactionOutput>;
|
|
546
|
+
/**
|
|
547
|
+
* Switch the active chain.
|
|
548
|
+
*/
|
|
549
|
+
switchChain(input: {
|
|
550
|
+
chain: SuiChain;
|
|
551
|
+
}): Promise<void>;
|
|
552
|
+
/**
|
|
553
|
+
* Subscribe to wallet change events.
|
|
554
|
+
*
|
|
555
|
+
* @param event - Event name (currently only 'change')
|
|
556
|
+
* @param listener - Event listener callback
|
|
557
|
+
* @returns Unsubscribe function
|
|
558
|
+
*/
|
|
559
|
+
on(event: 'change', listener: SuiWalletEventListener): () => void;
|
|
560
|
+
/**
|
|
561
|
+
* Wallet Standard features property.
|
|
562
|
+
* Required by @mysten/wallet-standard registerWallet.
|
|
563
|
+
*/
|
|
564
|
+
get features(): {
|
|
565
|
+
readonly 'standard:connect': {
|
|
566
|
+
readonly version: "1.0.0";
|
|
567
|
+
readonly connect: (input?: SuiConnectInput) => Promise<SuiConnectOutput>;
|
|
568
|
+
};
|
|
569
|
+
readonly 'standard:disconnect': {
|
|
570
|
+
readonly version: "1.0.0";
|
|
571
|
+
readonly disconnect: () => Promise<void>;
|
|
572
|
+
};
|
|
573
|
+
readonly 'standard:events': {
|
|
574
|
+
readonly version: "1.0.0";
|
|
575
|
+
readonly on: (event: "change", listener: SuiWalletEventListener) => () => void;
|
|
576
|
+
};
|
|
577
|
+
readonly 'sui:signPersonalMessage': {
|
|
578
|
+
readonly version: "1.1.0";
|
|
579
|
+
readonly signPersonalMessage: (input: SuiSignPersonalMessageInput) => Promise<SuiSignPersonalMessageOutput>;
|
|
580
|
+
};
|
|
581
|
+
readonly 'sui:signTransaction': {
|
|
582
|
+
readonly version: "2.0.0";
|
|
583
|
+
readonly signTransaction: (input: {
|
|
584
|
+
transaction: unknown;
|
|
585
|
+
account: SuiAccount;
|
|
586
|
+
chain?: SuiChain;
|
|
587
|
+
}) => Promise<{
|
|
588
|
+
bytes: string;
|
|
589
|
+
signature: string;
|
|
590
|
+
}>;
|
|
591
|
+
};
|
|
592
|
+
readonly 'sui:signAndExecuteTransaction': {
|
|
593
|
+
readonly version: "1.0.0";
|
|
594
|
+
readonly signAndExecuteTransaction: (input: SuiSignAndExecuteTransactionInput) => Promise<SuiSignAndExecuteTransactionOutput>;
|
|
595
|
+
};
|
|
596
|
+
readonly 'sui:signTransactionBlock': {
|
|
597
|
+
readonly version: "2.0.0";
|
|
598
|
+
readonly signTransactionBlock: (input: SuiSignTransactionBlockInput) => Promise<SuiSignTransactionBlockOutput>;
|
|
599
|
+
};
|
|
600
|
+
readonly 'sui:signAndExecuteTransactionBlock': {
|
|
601
|
+
readonly version: "1.0.0";
|
|
602
|
+
readonly signAndExecuteTransactionBlock: (input: SuiSignAndExecuteTransactionBlockInput) => Promise<SuiSignAndExecuteTransactionBlockOutput>;
|
|
603
|
+
};
|
|
604
|
+
readonly 'sui:switchChain': {
|
|
605
|
+
readonly version: "1.0.0";
|
|
606
|
+
readonly switchChain: (input: {
|
|
607
|
+
chain: SuiChain;
|
|
608
|
+
}) => Promise<void>;
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Legacy method for signing a transaction block.
|
|
613
|
+
* Maps to signTransaction.
|
|
614
|
+
*/
|
|
615
|
+
signTransactionBlock(input: SuiSignTransactionBlockInput): Promise<SuiSignTransactionBlockOutput>;
|
|
616
|
+
/**
|
|
617
|
+
* Legacy method for signing and executing a transaction block.
|
|
618
|
+
* Maps to signAndExecuteTransaction.
|
|
619
|
+
*/
|
|
620
|
+
signAndExecuteTransactionBlock(input: SuiSignAndExecuteTransactionBlockInput): Promise<SuiSignAndExecuteTransactionBlockOutput>;
|
|
621
|
+
/**
|
|
622
|
+
* Request a Permission Token from the user.
|
|
623
|
+
* Allows pre-authorised batches of Sui transactions without individual confirmations.
|
|
624
|
+
*
|
|
625
|
+
* @param params - Allowed addresses, chainId (e.g. "sui:mainnet"), spend limit, expiry
|
|
626
|
+
*/
|
|
627
|
+
requestPermissionToken(params: RequestPermissionTokenParams): Promise<RequestPermissionTokenResult>;
|
|
628
|
+
/**
|
|
629
|
+
* Request the user's email address.
|
|
630
|
+
*
|
|
631
|
+
* @returns Promise resolving to the user's email address
|
|
632
|
+
*/
|
|
633
|
+
requestEmail(): Promise<string>;
|
|
634
|
+
/**
|
|
635
|
+
* Post a request to the iframe and wait for response.
|
|
636
|
+
*/
|
|
637
|
+
private postRequestAndWait;
|
|
638
|
+
/**
|
|
639
|
+
* Notify all change listeners.
|
|
640
|
+
*/
|
|
641
|
+
private notifyChange;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Initialization function for WaaP Sui Wallet.
|
|
646
|
+
*/
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Initialize WaaP Sui Wallet.
|
|
650
|
+
*
|
|
651
|
+
* This creates the WaaP iframe (if needed) and returns a SuiWallet instance
|
|
652
|
+
* that implements the Sui Wallet Standard.
|
|
653
|
+
*
|
|
654
|
+
* @param options - Initialization options
|
|
655
|
+
* @returns WaaPSuiWallet instance
|
|
656
|
+
*
|
|
657
|
+
* @example
|
|
658
|
+
* ```typescript
|
|
659
|
+
* import { initWaaPSui } from '@silk-wallet/silk-wallet-sdk'
|
|
660
|
+
*
|
|
661
|
+
* const suiWallet = initWaaPSui()
|
|
662
|
+
*
|
|
663
|
+
* // Connect to get accounts
|
|
664
|
+
* const { accounts } = await suiWallet.connect()
|
|
665
|
+
*
|
|
666
|
+
* // Sign a message
|
|
667
|
+
* const result = await suiWallet.signPersonalMessage({
|
|
668
|
+
* message: new TextEncoder().encode('Hello, Sui!'),
|
|
669
|
+
* account: accounts[0]
|
|
670
|
+
* })
|
|
671
|
+
* ```
|
|
672
|
+
*/
|
|
673
|
+
declare function initWaaPSui(options?: InitWaaPSuiOptions): WaaPSuiWalletInterface;
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* WaaP Sui Wallet Registration
|
|
677
|
+
*
|
|
678
|
+
* Registers the WaaP Sui wallet with the Wallet Standard registry,
|
|
679
|
+
* making it discoverable by dApps using @mysten/dapp-kit.
|
|
680
|
+
*
|
|
681
|
+
* @see https://docs.sui.io/standards/wallet-standard
|
|
682
|
+
*/
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Register WaaP Sui Wallet with the Wallet Standard.
|
|
686
|
+
*
|
|
687
|
+
* This makes the wallet discoverable by dApps using @mysten/dapp-kit.
|
|
688
|
+
* The wallet will appear in the wallet selection UI of any dApp
|
|
689
|
+
* that uses the Sui Wallet Standard.
|
|
690
|
+
*
|
|
691
|
+
* @param iframeWindow - The contentWindow of the WaaP iframe
|
|
692
|
+
* @param options - Initialization options
|
|
693
|
+
* @returns The registered WaaPSuiWallet instance
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* ```typescript
|
|
697
|
+
* import { registerWaaPSuiWallet } from '@silk-wallet/silk-wallet-sdk'
|
|
698
|
+
*
|
|
699
|
+
* // Get the iframe element
|
|
700
|
+
* const iframe = document.getElementById('waap-wallet-iframe') as HTMLIFrameElement
|
|
701
|
+
*
|
|
702
|
+
* // Register the wallet (makes it discoverable by dApps)
|
|
703
|
+
* const wallet = registerWaaPSuiWallet(iframe.contentWindow!, { useStaging: false })
|
|
704
|
+
*
|
|
705
|
+
* // The wallet is now available in dapp-kit's wallet list
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
declare function registerWaaPSuiWallet(iframeWindow: Window, options?: InitWaaPSuiOptions): WaaPSuiWalletInterface;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* WalletMessageManager handles messages between the wallet (in the Silk iframe)
|
|
712
|
+
* and the wallet SDK (in the top frame). It is used by EthereumProvider
|
|
713
|
+
* to communicate with the wallet.
|
|
714
|
+
*/
|
|
715
|
+
|
|
716
|
+
type PostSilkRequestArgs = {
|
|
717
|
+
method: keyof typeof SILK_METHOD;
|
|
718
|
+
params: any[];
|
|
719
|
+
interactionRequired: boolean;
|
|
720
|
+
silkOptions?: {
|
|
721
|
+
async?: boolean;
|
|
722
|
+
};
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* Async transaction notification from iframe
|
|
726
|
+
*/
|
|
727
|
+
interface AsyncTxNotification {
|
|
728
|
+
type: string;
|
|
729
|
+
payload: any;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Listener interface for WalletMessageManager
|
|
733
|
+
*/
|
|
734
|
+
interface MessageListenerConfig {
|
|
735
|
+
handleResponse: (response: SilkResponse) => void;
|
|
736
|
+
handleRequest: (request: SilkRequest) => void;
|
|
737
|
+
onReceiveConnectNotif?: () => void;
|
|
738
|
+
onAccountChanged?: (newAccount: string) => void;
|
|
739
|
+
onAsyncTxNotification?: (notification: AsyncTxNotification) => void;
|
|
740
|
+
}
|
|
741
|
+
declare class WalletMessageManager {
|
|
742
|
+
private iframeWindow;
|
|
743
|
+
private walletOrigin;
|
|
744
|
+
constructor(iframeWindow: Window, useStaging: boolean);
|
|
745
|
+
/**
|
|
746
|
+
* Post a Silk notification to the given iframeWindow
|
|
747
|
+
*/
|
|
748
|
+
postSilkNotification(data: SilkNotificationData): void;
|
|
749
|
+
postReadyNotification(): void;
|
|
750
|
+
postConnectNotification(): void;
|
|
751
|
+
/**
|
|
752
|
+
* Post a 'ready' notification to the iframe, and wait
|
|
753
|
+
* for the iframe to respond with a 'ready' notification.
|
|
754
|
+
*/
|
|
755
|
+
pingIframe(): Promise<void>;
|
|
756
|
+
/**
|
|
757
|
+
* Post a SilkRequest to the iframeWindow. Don't wait for a response.
|
|
758
|
+
*/
|
|
759
|
+
postSilkRequest(req: PostSilkRequestArgs): Promise<string>;
|
|
760
|
+
/**
|
|
761
|
+
* Add a message listener to the window in which this is called (which should be the top frame).
|
|
762
|
+
* It handles all messages from the Silk iframe posted to the top frame.
|
|
763
|
+
* @param config - Configuration that includes callbacks for handling specific messages.
|
|
764
|
+
*/
|
|
765
|
+
addListener(config: MessageListenerConfig): void;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* A Ethereum provder API (from EIP 1193) for Silk.
|
|
770
|
+
* https://eips.ethereum.org/EIPS/eip-1193
|
|
771
|
+
*/
|
|
772
|
+
/**
|
|
773
|
+
* Resources:
|
|
774
|
+
* - EIP-2255: Wallet Permissions System: https://eips.ethereum.org/EIPS/eip-2255
|
|
775
|
+
*/
|
|
776
|
+
|
|
777
|
+
declare class EthereumProvider extends EventEmitter implements SilkEthereumProviderInterface {
|
|
778
|
+
readonly isSilk = true;
|
|
779
|
+
readonly isWaaP = true;
|
|
780
|
+
connected: boolean;
|
|
781
|
+
walletMessageManager: WalletMessageManager;
|
|
782
|
+
uiMessageManager: UIMessageManager;
|
|
783
|
+
config: CustomConfig;
|
|
784
|
+
private currentAccount;
|
|
785
|
+
private walletConnectProvider;
|
|
786
|
+
/**
|
|
787
|
+
* When true, eth_sendTransaction resolves with the pre-calculated tx hash
|
|
788
|
+
* after signing. Broadcasting continues in the background with events.
|
|
789
|
+
*/
|
|
790
|
+
private asyncTxs;
|
|
791
|
+
/**
|
|
792
|
+
* When true, sends `asyncSigning: true` in silkOptions instead of `async: true`.
|
|
793
|
+
* This mimics the v1 SDK protocol for backward compatibility testing.
|
|
794
|
+
* @internal
|
|
795
|
+
*/
|
|
796
|
+
private legacyAsyncSigning;
|
|
797
|
+
private persistedMethods;
|
|
798
|
+
/**
|
|
799
|
+
* We use the internalEventEmitter to emit as events
|
|
800
|
+
* Silk messages posted to the window.
|
|
801
|
+
*/
|
|
802
|
+
internalEventEmitter: EventEmitter;
|
|
803
|
+
/**
|
|
804
|
+
* @param iframeWindow - The contentWindow of the iframe of the Silk website.
|
|
805
|
+
* @param referralCode - Silk points referral code
|
|
806
|
+
* @param customConfig - Silk custom UI configuration
|
|
807
|
+
* @param project - Silk project configuration
|
|
808
|
+
* @param useStaging - Whether to use the staging environment
|
|
809
|
+
* @param asyncTxs - When true, eth_sendTransaction resolves with tx hash after signing
|
|
810
|
+
* @param legacyAsyncSigning - When true, sends asyncSigning in silkOptions (v1 compat)
|
|
811
|
+
*/
|
|
812
|
+
constructor(iframeWindow: Window, referralCode?: string, customConfig?: CustomConfig, project?: ProjectConfig, useStaging?: boolean, asyncTxs?: boolean, legacyAsyncSigning?: boolean);
|
|
813
|
+
private initializeWalletConnect;
|
|
814
|
+
enable(): Promise<unknown>;
|
|
815
|
+
isConnected(): boolean;
|
|
816
|
+
request(args: RequestArguments): Promise<unknown>;
|
|
817
|
+
login(customProvider?: EthereumProviderInterface): Promise<LoginResponse>;
|
|
818
|
+
logout(): Promise<unknown>;
|
|
819
|
+
private cleanupInvalidLoginState;
|
|
820
|
+
/**
|
|
821
|
+
* Helper method to set up window.waap for WaaP
|
|
822
|
+
*/
|
|
823
|
+
private setupWaaP;
|
|
824
|
+
/**
|
|
825
|
+
* Helper method to set up window.silk for injected wallets (e.g., MetaMask)
|
|
826
|
+
*/
|
|
827
|
+
private setupInjectedWallet;
|
|
828
|
+
/**
|
|
829
|
+
* Helper method to set up window.silk for WalletConnect
|
|
830
|
+
*/
|
|
831
|
+
private setupWalletConnect;
|
|
832
|
+
/**
|
|
833
|
+
* Helper method to set up window.silk for auto-connect with injected wallets
|
|
834
|
+
*/
|
|
835
|
+
private setupAutoConnectInjected;
|
|
836
|
+
/**
|
|
837
|
+
* Helper method to set up window.silk for auto-connect with WalletConnect
|
|
838
|
+
*/
|
|
839
|
+
private setupAutoConnectWalletConnect;
|
|
840
|
+
/**
|
|
841
|
+
* Attempts to auto-connect using previously stored login method
|
|
842
|
+
* @param method - The RPC method being called
|
|
843
|
+
* @returns Promise<unknown> if auto-connect succeeds, null if it should fall through to normal flow
|
|
844
|
+
*/
|
|
845
|
+
private attemptAutoConnect;
|
|
846
|
+
getLoginMethod(): LoginResponse;
|
|
847
|
+
toggleDarkMode(): Promise<void>;
|
|
848
|
+
safe(): Promise<void>;
|
|
849
|
+
orcid(): Promise<void>;
|
|
850
|
+
/**
|
|
851
|
+
* INTERNAL METHOD: Gas tank administration operations
|
|
852
|
+
* This method is ONLY accessible from the Dev Portal domain
|
|
853
|
+
* It's not included in the public typing to hide it from regular dApps
|
|
854
|
+
*/
|
|
855
|
+
portal(feature: 'gastank' | 'customization' | 'project', operation: 'get' | 'update' | 'topup' | 'init', payload?: any): Promise<unknown>;
|
|
856
|
+
requestEmail(): Promise<unknown>;
|
|
857
|
+
/**
|
|
858
|
+
* Request a Permission Token from the user.
|
|
859
|
+
* Allows pre-authorized transactions without individual confirmations.
|
|
860
|
+
* @param params - Permission token parameters (allowed addresses, chain, limits, expiry)
|
|
861
|
+
* @returns Promise<RequestPermissionTokenResult>
|
|
862
|
+
*/
|
|
863
|
+
requestPermissionToken(params: RequestPermissionTokenParams): Promise<unknown>;
|
|
864
|
+
/**
|
|
865
|
+
* Prompt the user to mint a Zeronym SBT.
|
|
866
|
+
* @returns string or null - The address of the owner of the SBT, or null
|
|
867
|
+
* if the user already minted the SBT.
|
|
868
|
+
*/
|
|
869
|
+
requestSBT(type: CredentialType): Promise<unknown>;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Options passed to iframe for transaction behavior
|
|
874
|
+
*/
|
|
875
|
+
interface SilkOptions {
|
|
876
|
+
async?: boolean;
|
|
877
|
+
withPT?: boolean;
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Send request to wallet in iframe, and upon receiving the wallet's response
|
|
881
|
+
* or error, hide modal and return wallet's response or throw wallet's error.
|
|
882
|
+
*/
|
|
883
|
+
declare function handleWalletRequestAndResponse(args: RequestArguments, interactionRequired: boolean, walletMessageManager: WalletMessageManager, internalProviderEventEmitter: EventEmitter, silkOptions?: SilkOptions): Promise<unknown>;
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Transaction state tracked by the hook.
|
|
887
|
+
* Keyed by txHash (pre-calculated from keccak256(serializedSignedTx)).
|
|
888
|
+
*/
|
|
889
|
+
interface TxState {
|
|
890
|
+
status: 'signed' | 'tx_pending' | 'confirmed' | 'failed';
|
|
891
|
+
txHash: string;
|
|
892
|
+
/** @deprecated Use `txHash` instead. */
|
|
893
|
+
pendingTxId?: string;
|
|
894
|
+
signature?: string;
|
|
895
|
+
serializedTx?: string;
|
|
896
|
+
receipt?: AsyncTxConfirmedEvent['receipt'];
|
|
897
|
+
error?: string;
|
|
898
|
+
stage?: AsyncTxFailedEvent['stage'];
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Options for useWaapTransaction hook
|
|
902
|
+
*/
|
|
903
|
+
interface UseWaapTransactionOptions {
|
|
904
|
+
onSigned?: (event: AsyncSignCompleteEvent) => void;
|
|
905
|
+
onTxPending?: (event: AsyncTxPendingEvent) => void;
|
|
906
|
+
onConfirmed?: (event: AsyncTxConfirmedEvent) => void;
|
|
907
|
+
onFailed?: (event: AsyncTxFailedEvent) => void;
|
|
908
|
+
/** @deprecated No longer emitted in v2. */
|
|
909
|
+
onPending?: (event: any) => void;
|
|
910
|
+
/** @deprecated No longer emitted in v2. */
|
|
911
|
+
on2faRequired?: (event: any) => void;
|
|
912
|
+
/** @deprecated Use `onFailed` instead. */
|
|
913
|
+
onSignFailed?: (event: any) => void;
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Return type for useWaapTransaction hook
|
|
917
|
+
*/
|
|
918
|
+
interface UseWaapTransactionReturn {
|
|
919
|
+
/**
|
|
920
|
+
* Send a transaction using eth_sendTransaction.
|
|
921
|
+
* When asyncTxs is enabled, resolves with the pre-calculated txHash
|
|
922
|
+
* after signing. Broadcasting continues in the background with events.
|
|
923
|
+
*/
|
|
924
|
+
sendTransaction: (txRequest: RequestArguments['params']) => Promise<string>;
|
|
925
|
+
/**
|
|
926
|
+
* Sign a transaction without broadcasting using eth_signTransaction.
|
|
927
|
+
* Always resolves with the signature directly.
|
|
928
|
+
*/
|
|
929
|
+
signTransaction: (txRequest: RequestArguments['params']) => Promise<string>;
|
|
930
|
+
/**
|
|
931
|
+
* Map of transaction hashes to their current state
|
|
932
|
+
*/
|
|
933
|
+
pendingTransactions: Map<string, TxState>;
|
|
934
|
+
/**
|
|
935
|
+
* Whether there are any pending transactions
|
|
936
|
+
*/
|
|
937
|
+
isAnyPending: boolean;
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* React hook for handling async transactions with WaaP SDK.
|
|
941
|
+
*
|
|
942
|
+
* When `asyncTxs` is enabled (via `initWaaP({ asyncTxs: true })` or per-request `{ async: true }`):
|
|
943
|
+
* - `eth_sendTransaction` resolves with the pre-calculated tx hash after signing
|
|
944
|
+
* - Broadcasting and confirmation happen in the background with events
|
|
945
|
+
* - Use the callbacks to track transaction lifecycle
|
|
946
|
+
*
|
|
947
|
+
* Other signing methods (`personal_sign`, `eth_signTypedData_v4`, `eth_signTransaction`)
|
|
948
|
+
* always resolve with the signature directly — no events needed.
|
|
949
|
+
*
|
|
950
|
+
* @example
|
|
951
|
+
* ```tsx
|
|
952
|
+
* const { sendTransaction, pendingTransactions, isAnyPending } = useWaapTransaction({
|
|
953
|
+
* onSigned: ({ txHash }) => console.log('Signed:', txHash),
|
|
954
|
+
* onTxPending: ({ txHash }) => console.log('Broadcasting:', txHash),
|
|
955
|
+
* onConfirmed: ({ txHash, receipt }) => console.log('Confirmed:', txHash),
|
|
956
|
+
* onFailed: ({ txHash, error }) => console.error('Failed:', txHash, error)
|
|
957
|
+
* });
|
|
958
|
+
*
|
|
959
|
+
* const handleSend = async () => {
|
|
960
|
+
* const txHash = await sendTransaction([{ to: '0x...', value: '0x...' }]);
|
|
961
|
+
* console.log('Got tx hash:', txHash);
|
|
962
|
+
* };
|
|
963
|
+
* ```
|
|
964
|
+
*/
|
|
965
|
+
declare function useWaapTransaction(options?: UseWaapTransactionOptions): UseWaapTransactionReturn;
|
|
966
|
+
|
|
967
|
+
export { EthereumProvider, EthereumProviderExtension, type InitSilkOptions, type InitSilkOptions as InitWaaPOptions, type InitWaaPSuiOptions, type PostSilkRequestArgs, type PostSilkRequestArgs as PostWaaPRequestArgs, type SilkEthereumProviderInterface, type SilkProvider, SilkWalletConnect, type SuiAccount, type SuiChain, type SuiConnectInput, type SuiConnectOutput, type SuiSignPersonalMessageInput, type SuiSignPersonalMessageOutput, type TxState, UIMessageManager, UI_EVENT_NAMES, type UseWaapTransactionOptions, type UseWaapTransactionReturn, WaapWalletElement as WaaP, type SilkEthereumProviderInterface as WaaPEthereumProviderInterface, type SilkProvider as WaaPProvider, WaaPSuiWallet, type WaaPSuiWalletFeatures, type WaaPSuiWalletInterface, SilkWalletConnect as WaaPWalletConnect, WalletMessageManager, handleWalletRequestAndResponse, initWaaP, initWaaPSui, registerWaaPSuiWallet, useWaapTransaction };
|