@worldcoin/minikit-js 1.9.9 → 1.9.10

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/build/index.d.ts CHANGED
@@ -1,83 +1,74 @@
1
- import { AppErrorCodes, IDKitConfig, VerificationLevel } from '@worldcoin/idkit-core';
1
+ import { TypedData, TypedDataDomain, Abi, AbiStateMutability, ExtractAbiFunctionNames, AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
2
+ import { IDKitConfig, VerificationLevel } from '@worldcoin/idkit-core';
2
3
  export { ISuccessResult, AppErrorCodes as VerificationErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
3
- import { Abi, AbiStateMutability, ExtractAbiFunctionNames, AbiParametersToPrimitiveTypes, ExtractAbiFunction, TypedData, TypedDataDomain } from 'abitype';
4
4
  export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
5
5
  import { Client } from 'viem';
6
6
 
7
- declare const VerificationErrorMessage: Record<AppErrorCodes, string>;
8
- declare enum PaymentErrorCodes {
9
- InputError = "input_error",
10
- UserRejected = "user_rejected",
11
- PaymentRejected = "payment_rejected",
12
- InvalidReceiver = "invalid_receiver",
13
- InsufficientBalance = "insufficient_balance",
14
- TransactionFailed = "transaction_failed",
15
- GenericError = "generic_error",
16
- UserBlocked = "user_blocked"
17
- }
18
- declare const PaymentErrorMessage: Record<PaymentErrorCodes, string>;
19
- declare enum PaymentValidationErrors {
20
- MalformedRequest = "There was a problem with this request. Please try again or contact the app owner.",
21
- InvalidTokenAddress = "The token address is invalid. Please contact the app owner.",
22
- InvalidAppId = "The app ID is invalid. Please contact the app owner.",
23
- DuplicateReference = "This reference ID already exists please generate a new one and try again."
24
- }
25
- declare enum WalletAuthErrorCodes {
26
- MalformedRequest = "malformed_request",
27
- UserRejected = "user_rejected",
28
- GenericError = "generic_error"
29
- }
30
- declare const WalletAuthErrorMessage: {
31
- malformed_request: string;
32
- user_rejected: string;
33
- generic_error: string;
7
+ type User = {
8
+ walletAddress?: string;
9
+ username?: string;
10
+ profilePictureUrl?: string;
11
+ permissions?: {
12
+ notifications: boolean;
13
+ contacts: boolean;
14
+ };
15
+ optedIntoOptionalAnalytics?: boolean;
16
+ /** @deprecated Moved to DeviceProperties */
17
+ worldAppVersion?: number;
18
+ /** @deprecated Moved to DeviceProperties */
19
+ deviceOS?: string;
34
20
  };
35
- declare enum SendTransactionErrorCodes {
36
- InvalidOperation = "invalid_operation",
37
- UserRejected = "user_rejected",
38
- InputError = "input_error",
39
- SimulationFailed = "simulation_failed",
40
- TransactionFailed = "transaction_failed",
41
- GenericError = "generic_error",
42
- DisallowedOperation = "disallowed_operation",
43
- ValidationError = "validation_error",
44
- InvalidContract = "invalid_contract",
45
- MaliciousOperation = "malicious_operation",
46
- DailyTxLimitReached = "daily_tx_limit_reached",
47
- PermittedAmountExceedsSlippage = "permitted_amount_exceeds_slippage",
48
- PermittedAmountNotFound = "permitted_amount_not_found"
21
+ type DeviceProperties = {
22
+ safeAreaInsets?: {
23
+ top: number;
24
+ right: number;
25
+ bottom: number;
26
+ left: number;
27
+ };
28
+ deviceOS?: string;
29
+ worldAppVersion?: number;
30
+ };
31
+ type UserNameService = {
32
+ walletAddress: string;
33
+ username?: string;
34
+ profilePictureUrl?: string;
35
+ };
36
+ type MiniAppLocation = {
37
+ countryCode?: string;
38
+ regionCode?: string;
39
+ };
40
+ declare enum MiniAppLaunchLocation {
41
+ Chat = "chat",
42
+ Home = "home",
43
+ AppStore = "app-store",
44
+ DeepLink = "deep-link",
45
+ WalletTab = "wallet-tab"
49
46
  }
50
- declare const SendTransactionErrorMessage: Record<SendTransactionErrorCodes, string>;
51
- declare enum SignMessageErrorCodes {
52
- InvalidMessage = "invalid_message",
53
- UserRejected = "user_rejected",
54
- GenericError = "generic_error"
47
+ declare const mapWorldAppLaunchLocation: (location: string | null | undefined) => MiniAppLaunchLocation | null;
48
+
49
+ type EventPayload<T extends ResponseEvent = ResponseEvent> = any;
50
+ type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
51
+ declare class EventManager {
52
+ private listeners;
53
+ subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
54
+ unsubscribe(event: ResponseEvent): void;
55
+ trigger(event: ResponseEvent, payload: EventPayload): void;
56
+ private processVerifyActionPayload;
57
+ private compressProofSafely;
55
58
  }
56
- declare const SignMessageErrorMessage: {
57
- invalid_message: string;
58
- user_rejected: string;
59
- generic_error: string;
60
- };
61
- declare enum SignTypedDataErrorCodes {
62
- InvalidOperation = "invalid_operation",
63
- UserRejected = "user_rejected",
64
- InputError = "input_error",
65
- SimulationFailed = "simulation_failed",
66
- GenericError = "generic_error",
67
- DisallowedOperation = "disallowed_operation",
68
- InvalidContract = "invalid_contract",
69
- MaliciousOperation = "malicious_operation"
59
+
60
+ declare class MiniKitState {
61
+ appId: string | null;
62
+ user: User;
63
+ deviceProperties: DeviceProperties;
64
+ location: MiniAppLaunchLocation | null;
65
+ isReady: boolean;
66
+ initFromWorldApp(worldApp: typeof window.WorldApp): void;
67
+ updateUserFromWalletAuth(address: string): Promise<void>;
68
+ getUserByAddress(address?: string): Promise<UserNameService>;
69
+ getUserByUsername(username: string): Promise<UserNameService>;
70
70
  }
71
- declare const SignTypedDataErrorMessage: {
72
- invalid_operation: string;
73
- user_rejected: string;
74
- input_error: string;
75
- simulation_failed: string;
76
- generic_error: string;
77
- disallowed_operation: string;
78
- invalid_contract: string;
79
- malicious_operation: string;
80
- };
71
+
81
72
  declare enum MiniKitInstallErrorCodes {
82
73
  Unknown = "unknown",
83
74
  AlreadyInstalled = "already_installed",
@@ -92,36 +83,141 @@ declare const MiniKitInstallErrorMessage: {
92
83
  not_on_client: string;
93
84
  app_out_of_date: string;
94
85
  };
95
- declare enum ShareContactsErrorCodes {
86
+
87
+ declare enum Command {
88
+ Verify = "verify",
89
+ Pay = "pay",
90
+ WalletAuth = "wallet-auth",
91
+ SendTransaction = "send-transaction",
92
+ SignMessage = "sign-message",
93
+ SignTypedData = "sign-typed-data",
94
+ ShareContacts = "share-contacts",
95
+ RequestPermission = "request-permission",
96
+ GetPermissions = "get-permissions",
97
+ SendHapticFeedback = "send-haptic-feedback",
98
+ Share = "share",
99
+ Chat = "chat"
100
+ }
101
+ declare enum ResponseEvent {
102
+ MiniAppVerifyAction = "miniapp-verify-action",
103
+ MiniAppPayment = "miniapp-payment",
104
+ MiniAppWalletAuth = "miniapp-wallet-auth",
105
+ MiniAppSendTransaction = "miniapp-send-transaction",
106
+ MiniAppSignMessage = "miniapp-sign-message",
107
+ MiniAppSignTypedData = "miniapp-sign-typed-data",
108
+ MiniAppShareContacts = "miniapp-share-contacts",
109
+ MiniAppRequestPermission = "miniapp-request-permission",
110
+ MiniAppGetPermissions = "miniapp-get-permissions",
111
+ MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
112
+ MiniAppShare = "miniapp-share",
113
+ MiniAppMicrophone = "miniapp-microphone",
114
+ MiniAppChat = "miniapp-chat"
115
+ }
116
+ declare const COMMAND_VERSIONS: Record<Command, number>;
117
+ declare function isCommandAvailable(command: Command): boolean;
118
+ declare function setCommandAvailable(command: Command, available: boolean): void;
119
+ declare function validateCommands(worldAppSupportedCommands: NonNullable<typeof window.WorldApp>['supported_commands']): boolean;
120
+ interface CommandContext {
121
+ events: EventManager;
122
+ state: MiniKitState;
123
+ }
124
+ type MiniAppBaseSuccessPayload = {
125
+ status: 'success';
126
+ version: number;
127
+ };
128
+ type MiniAppBaseErrorPayload<TErrorCode = string> = {
129
+ status: 'error';
130
+ error_code: TErrorCode;
131
+ version: number;
132
+ };
133
+ type AsyncHandlerReturn<CommandPayload, FinalPayload> = Promise<{
134
+ commandPayload: CommandPayload;
135
+ finalPayload: FinalPayload;
136
+ }>;
137
+ type WebViewBasePayload = {
138
+ command: Command;
139
+ version: number;
140
+ payload: Record<string, any>;
141
+ };
142
+
143
+ type MiniKitInstallReturnType = {
144
+ success: true;
145
+ } | {
146
+ success: false;
147
+ errorCode: MiniKitInstallErrorCodes;
148
+ errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCodes];
149
+ };
150
+ declare function sendMiniKitEvent<T extends WebViewBasePayload = WebViewBasePayload>(payload: T): void;
151
+
152
+ type ChatPayload = {
153
+ to?: string[];
154
+ message: string;
155
+ };
156
+ declare enum ChatErrorCodes {
96
157
  UserRejected = "user_rejected",
158
+ SendFailed = "send_failed",
97
159
  GenericError = "generic_error"
98
160
  }
99
- declare const ShareContactsErrorMessage: {
161
+ declare const ChatErrorMessage: {
100
162
  user_rejected: string;
163
+ send_failed: string;
101
164
  generic_error: string;
102
165
  };
103
- declare enum RequestPermissionErrorCodes {
166
+ type MiniAppChatSuccessPayload = MiniAppBaseSuccessPayload & {
167
+ count: number;
168
+ timestamp: string;
169
+ };
170
+ type MiniAppChatErrorPayload = MiniAppBaseErrorPayload<ChatErrorCodes>;
171
+ type MiniAppChatPayload = MiniAppChatSuccessPayload | MiniAppChatErrorPayload;
172
+ declare function createChatCommand(_ctx: CommandContext): (payload: ChatPayload) => ChatPayload | null;
173
+ declare function createChatAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createChatCommand>): (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
174
+
175
+ type ShareInput = {
176
+ files?: File[];
177
+ title?: string;
178
+ text?: string;
179
+ url?: string;
180
+ };
181
+ type SharePayload = {
182
+ files?: Array<{
183
+ name: string;
184
+ type: string;
185
+ data: string;
186
+ }>;
187
+ title?: string;
188
+ text?: string;
189
+ url?: string;
190
+ };
191
+ declare enum ShareFilesErrorCodes {
104
192
  UserRejected = "user_rejected",
105
193
  GenericError = "generic_error",
106
- AlreadyRequested = "already_requested",
107
- PermissionDisabled = "permission_disabled",
108
- AlreadyGranted = "already_granted",
109
- UnsupportedPermission = "unsupported_permission"
194
+ InvalidFileName = "invalid_file_name"
110
195
  }
111
- declare const RequestPermissionErrorMessage: {
196
+ declare const ShareFilesErrorMessage: {
112
197
  user_rejected: string;
113
198
  generic_error: string;
114
- already_requested: string;
115
- permission_disabled: string;
116
- already_granted: string;
117
- unsupported_permission: string;
199
+ invalid_file_name: string;
118
200
  };
119
- declare enum GetPermissionsErrorCodes {
120
- GenericError = "generic_error"
121
- }
122
- declare const GetPermissionsErrorMessage: {
123
- generic_error: string;
201
+ type MiniAppShareSuccessPayload = MiniAppBaseSuccessPayload & {
202
+ shared_files_count: number;
203
+ timestamp: string;
124
204
  };
205
+ type MiniAppShareErrorPayload = MiniAppBaseErrorPayload<ShareFilesErrorCodes>;
206
+ type MiniAppSharePayload = MiniAppShareSuccessPayload | MiniAppShareErrorPayload;
207
+ declare function createShareCommand(ctx: CommandContext): (payload: ShareInput) => ShareInput | null;
208
+ declare function createShareAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createShareCommand>): (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
209
+
210
+ type SendHapticFeedbackInput = {
211
+ hapticsType: 'notification';
212
+ style: 'error' | 'success' | 'warning';
213
+ } | {
214
+ hapticsType: 'selection-changed';
215
+ style?: never;
216
+ } | {
217
+ hapticsType: 'impact';
218
+ style: 'light' | 'medium' | 'heavy';
219
+ };
220
+ type SendHapticFeedbackPayload = SendHapticFeedbackInput;
125
221
  declare enum SendHapticFeedbackErrorCodes {
126
222
  GenericError = "generic_error",
127
223
  UserRejected = "user_rejected"
@@ -130,136 +226,101 @@ declare const SendHapticFeedbackErrorMessage: {
130
226
  generic_error: string;
131
227
  user_rejected: string;
132
228
  };
133
- declare enum ShareFilesErrorCodes {
134
- UserRejected = "user_rejected",
135
- GenericError = "generic_error",
136
- InvalidFileName = "invalid_file_name"
137
- }
138
- declare const ShareFilesErrorMessage: {
139
- user_rejected: string;
140
- generic_error: string;
141
- invalid_file_name: string;
229
+ type MiniAppSendHapticFeedbackSuccessPayload = MiniAppBaseSuccessPayload & {
230
+ timestamp: string;
142
231
  };
143
- declare enum MicrophoneErrorCodes {
144
- MiniAppPermissionNotEnabled = "mini_app_permission_not_enabled",
145
- WorldAppPermissionNotEnabled = "world_app_permission_not_enabled"
146
- }
147
- declare const MicrophoneErrorMessage: {
148
- mini_app_permission_not_enabled: string;
149
- world_app_permission_not_enabled: string;
232
+ type MiniAppSendHapticFeedbackErrorPayload = MiniAppBaseErrorPayload<SendHapticFeedbackErrorCodes>;
233
+ type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
234
+ declare function createSendHapticFeedbackCommand(_ctx: CommandContext): (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
235
+ declare function createSendHapticFeedbackAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createSendHapticFeedbackCommand>): (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
236
+
237
+ type GetPermissionsInput = {};
238
+ type GetPermissionsPayload = {
239
+ status?: string;
150
240
  };
151
- declare enum ChatErrorCodes {
152
- UserRejected = "user_rejected",
153
- SendFailed = "send_failed",
241
+ declare enum GetPermissionsErrorCodes {
154
242
  GenericError = "generic_error"
155
243
  }
156
- declare const ChatErrorMessage: {
157
- user_rejected: string;
158
- send_failed: string;
244
+ declare const GetPermissionsErrorMessage: {
159
245
  generic_error: string;
160
246
  };
161
-
162
- declare enum Tokens {
163
- USDC = "USDCE",
164
- WLD = "WLD"
247
+ declare enum Permission {
248
+ Notifications = "notifications",
249
+ Contacts = "contacts",
250
+ Microphone = "microphone"
165
251
  }
166
- declare const TokenDecimals: {
167
- [key in Tokens]: number;
252
+ type PermissionSettings = {
253
+ [K in Permission]?: any;
168
254
  };
169
- declare enum Network {
170
- Optimism = "optimism",
171
- WorldChain = "worldchain"
172
- }
173
-
174
- type Permit2 = {
175
- permitted: {
176
- token: string;
177
- amount: string | unknown;
178
- };
179
- spender: string;
180
- nonce: string | unknown;
181
- deadline: string | unknown;
255
+ type MiniAppGetPermissionsSuccessPayload = MiniAppBaseSuccessPayload & {
256
+ permissions: PermissionSettings;
257
+ timestamp: string;
182
258
  };
183
- type Transaction = {
184
- address: string;
185
- abi: Abi | readonly unknown[];
186
- functionName: ContractFunctionName<Abi | readonly unknown[], 'payable' | 'nonpayable'>;
187
- value?: string | undefined;
188
- args: ContractFunctionArgs<Abi | readonly unknown[], 'payable' | 'nonpayable', ContractFunctionName<Abi | readonly unknown[], 'payable' | 'nonpayable'>>;
259
+ type MiniAppGetPermissionsErrorPayload = MiniAppBaseErrorPayload<GetPermissionsErrorCodes> & {
260
+ details: string;
189
261
  };
190
- type ContractFunctionName<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability> = ExtractAbiFunctionNames<abi extends Abi ? abi : Abi, mutability> extends infer functionName extends string ? [functionName] extends [never] ? string : functionName : string;
191
- type ContractFunctionArgs<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability, functionName extends ContractFunctionName<abi, mutability> = ContractFunctionName<abi, mutability>> = AbiParametersToPrimitiveTypes<ExtractAbiFunction<abi extends Abi ? abi : Abi, functionName, mutability>['inputs'], 'inputs'> extends infer args ? [args] extends [never] ? readonly unknown[] : args : readonly unknown[];
262
+ type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
263
+ declare function createGetPermissionsCommand(_ctx: CommandContext): () => GetPermissionsPayload | null;
264
+ declare function createGetPermissionsAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createGetPermissionsCommand>): () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
192
265
 
193
- declare enum Command {
194
- Verify = "verify",
195
- Pay = "pay",
196
- WalletAuth = "wallet-auth",
197
- SendTransaction = "send-transaction",
198
- SignMessage = "sign-message",
199
- SignTypedData = "sign-typed-data",
200
- ShareContacts = "share-contacts",
201
- RequestPermission = "request-permission",
202
- GetPermissions = "get-permissions",
203
- SendHapticFeedback = "send-haptic-feedback",
204
- Share = "share",
205
- Chat = "chat"
206
- }
207
- type WebViewBasePayload = {
208
- command: Command;
209
- version: number;
210
- payload: Record<string, any>;
266
+ type RequestPermissionInput = {
267
+ permission: Permission;
211
268
  };
212
- type AsyncHandlerReturn<CommandPayload, FinalPayload> = Promise<{
213
- commandPayload: CommandPayload;
214
- finalPayload: FinalPayload;
215
- }>;
216
- type VerifyCommandInput = {
217
- action: IDKitConfig['action'];
218
- signal?: IDKitConfig['signal'];
219
- verification_level?: VerificationLevel;
269
+ type RequestPermissionPayload = RequestPermissionInput;
270
+ declare enum RequestPermissionErrorCodes {
271
+ UserRejected = "user_rejected",
272
+ GenericError = "generic_error",
273
+ AlreadyRequested = "already_requested",
274
+ PermissionDisabled = "permission_disabled",
275
+ AlreadyGranted = "already_granted",
276
+ UnsupportedPermission = "unsupported_permission"
277
+ }
278
+ declare const RequestPermissionErrorMessage: {
279
+ user_rejected: string;
280
+ generic_error: string;
281
+ already_requested: string;
282
+ permission_disabled: string;
283
+ already_granted: string;
284
+ unsupported_permission: string;
220
285
  };
221
- type VerifyCommandPayload = VerifyCommandInput & {
286
+ type MiniAppRequestPermissionSuccessPayload = MiniAppBaseSuccessPayload & {
287
+ permission: Permission;
222
288
  timestamp: string;
223
289
  };
224
- type TokensPayload = {
225
- symbol: Tokens;
226
- token_amount: string;
227
- };
228
- type PayCommandInput = {
229
- reference: string;
230
- to: `0x${string}` | string;
231
- tokens: TokensPayload[];
232
- network?: Network;
290
+ type MiniAppRequestPermissionErrorPayload = MiniAppBaseErrorPayload<RequestPermissionErrorCodes> & {
233
291
  description: string;
234
292
  };
235
- type PayCommandPayload = PayCommandInput;
236
- type WalletAuthInput = {
237
- nonce: string;
238
- statement?: string;
239
- requestId?: string;
240
- expirationTime?: Date;
241
- notBefore?: Date;
242
- };
243
- type WalletAuthPayload = {
244
- siweMessage: string;
293
+ type MiniAppRequestPermissionPayload = MiniAppRequestPermissionSuccessPayload | MiniAppRequestPermissionErrorPayload;
294
+ declare function createRequestPermissionCommand(_ctx: CommandContext): (payload: RequestPermissionInput) => RequestPermissionPayload | null;
295
+ declare function createRequestPermissionAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createRequestPermissionCommand>): (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
296
+
297
+ type ShareContactsInput = {
298
+ isMultiSelectEnabled: boolean;
299
+ inviteMessage?: string;
245
300
  };
246
- type MiniKitInstallReturnType = {
247
- success: true;
248
- } | {
249
- success: false;
250
- errorCode: MiniKitInstallErrorCodes;
251
- errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCodes];
301
+ type ShareContactsPayload = ShareContactsInput;
302
+ declare enum ShareContactsErrorCodes {
303
+ UserRejected = "user_rejected",
304
+ GenericError = "generic_error"
305
+ }
306
+ declare const ShareContactsErrorMessage: {
307
+ user_rejected: string;
308
+ generic_error: string;
252
309
  };
253
- type SendTransactionInput = {
254
- transaction: Transaction[];
255
- permit2?: Permit2[];
256
- formatPayload?: boolean;
310
+ type Contact = {
311
+ username: string;
312
+ walletAddress: string;
313
+ profilePictureUrl: string | null;
257
314
  };
258
- type SendTransactionPayload = SendTransactionInput;
259
- type SignMessageInput = {
260
- message: string;
315
+ type MiniAppShareContactsSuccessPayload = MiniAppBaseSuccessPayload & {
316
+ contacts: Contact[];
317
+ timestamp: string;
261
318
  };
262
- type SignMessagePayload = SignMessageInput;
319
+ type MiniAppShareContactsErrorPayload = MiniAppBaseErrorPayload<ShareContactsErrorCodes>;
320
+ type MiniAppShareContactsPayload = MiniAppShareContactsSuccessPayload | MiniAppShareContactsErrorPayload;
321
+ declare function createShareContactsCommand(_ctx: CommandContext): (payload: ShareContactsPayload) => ShareContactsPayload | null;
322
+ declare function createShareContactsAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createShareContactsCommand>): (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
323
+
263
324
  type SignTypedDataInput = {
264
325
  types: TypedData;
265
326
  primaryType: string;
@@ -268,387 +329,280 @@ type SignTypedDataInput = {
268
329
  chainId?: number;
269
330
  };
270
331
  type SignTypedDataPayload = SignTypedDataInput;
271
- type ShareContactsInput = {
272
- isMultiSelectEnabled: boolean;
273
- inviteMessage?: string;
274
- };
275
- type ShareContactsPayload = ShareContactsInput;
276
- declare enum Permission {
277
- Notifications = "notifications",
278
- Contacts = "contacts",
279
- Microphone = "microphone"
332
+ declare enum SignTypedDataErrorCodes {
333
+ InvalidOperation = "invalid_operation",
334
+ UserRejected = "user_rejected",
335
+ InputError = "input_error",
336
+ SimulationFailed = "simulation_failed",
337
+ GenericError = "generic_error",
338
+ DisallowedOperation = "disallowed_operation",
339
+ InvalidContract = "invalid_contract",
340
+ MaliciousOperation = "malicious_operation"
280
341
  }
281
- type RequestPermissionInput = {
282
- permission: Permission;
283
- };
284
- type RequestPermissionPayload = RequestPermissionInput;
285
- type GetPermissionsInput = {};
286
- type GetPermissionsPayload = GetPermissionsInput;
287
- type SendHapticFeedbackInput = {
288
- hapticsType: 'notification';
289
- style: 'error' | 'success' | 'warning';
290
- } | {
291
- hapticsType: 'selection-changed';
292
- style?: never;
293
- } | {
294
- hapticsType: 'impact';
295
- style: 'light' | 'medium' | 'heavy';
296
- };
297
- type SendHapticFeedbackPayload = SendHapticFeedbackInput;
298
- type ShareInput = {
299
- files?: File[];
300
- title?: string;
301
- text?: string;
302
- url?: string;
342
+ declare const SignTypedDataErrorMessage: {
343
+ invalid_operation: string;
344
+ user_rejected: string;
345
+ input_error: string;
346
+ simulation_failed: string;
347
+ generic_error: string;
348
+ disallowed_operation: string;
349
+ invalid_contract: string;
350
+ malicious_operation: string;
303
351
  };
304
- type SharePayload = {
305
- files?: Array<{
306
- name: string;
307
- type: string;
308
- data: string;
309
- }>;
310
- title?: string;
311
- text?: string;
312
- url?: string;
352
+ type MiniAppSignTypedDataSuccessPayload = MiniAppBaseSuccessPayload & {
353
+ signature: string;
354
+ address: string;
313
355
  };
314
- type ChatPayload = {
315
- to?: string[];
316
- message: string;
356
+ type MiniAppSignTypedDataErrorPayload = MiniAppBaseErrorPayload<SignTypedDataErrorCodes> & {
357
+ details?: Record<string, any>;
317
358
  };
318
- type CommandReturnPayloadMap = {
319
- [Command.Verify]: VerifyCommandPayload;
320
- [Command.Pay]: PayCommandPayload;
321
- [Command.WalletAuth]: WalletAuthPayload;
322
- [Command.SendTransaction]: SendTransactionPayload;
323
- [Command.SignMessage]: SignMessagePayload;
324
- [Command.SignTypedData]: SignTypedDataPayload;
325
- [Command.ShareContacts]: ShareContactsPayload;
326
- [Command.RequestPermission]: RequestPermissionPayload;
327
- [Command.GetPermissions]: GetPermissionsPayload;
328
- [Command.SendHapticFeedback]: SendHapticFeedbackPayload;
329
- [Command.Share]: SharePayload;
330
- [Command.Chat]: ChatPayload;
331
- };
332
- type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
359
+ type MiniAppSignTypedDataPayload = MiniAppSignTypedDataSuccessPayload | MiniAppSignTypedDataErrorPayload;
360
+ declare function createSignTypedDataCommand(_ctx: CommandContext): (payload: SignTypedDataInput) => SignTypedDataPayload | null;
361
+ declare function createSignTypedDataAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createSignTypedDataCommand>): (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
333
362
 
334
- type User = {
335
- walletAddress?: string;
336
- username?: string;
337
- profilePictureUrl?: string;
338
- permissions?: {
339
- notifications: boolean;
340
- contacts: boolean;
341
- };
342
- optedIntoOptionalAnalytics?: boolean;
343
- /** @deprecated Moved to DeviceProperties */
344
- worldAppVersion?: number;
345
- /** @deprecated Moved to DeviceProperties */
346
- deviceOS?: string;
363
+ type SignMessageInput = {
364
+ message: string;
347
365
  };
348
- type DeviceProperties = {
349
- safeAreaInsets?: {
350
- top: number;
351
- right: number;
352
- bottom: number;
353
- left: number;
354
- };
355
- deviceOS?: string;
356
- worldAppVersion?: number;
366
+ type SignMessagePayload = SignMessageInput;
367
+ declare enum SignMessageErrorCodes {
368
+ InvalidMessage = "invalid_message",
369
+ UserRejected = "user_rejected",
370
+ GenericError = "generic_error"
371
+ }
372
+ declare const SignMessageErrorMessage: {
373
+ invalid_message: string;
374
+ user_rejected: string;
375
+ generic_error: string;
357
376
  };
358
- type UserNameService = {
359
- walletAddress: string;
360
- username?: string;
361
- profilePictureUrl?: string;
377
+ type MiniAppSignMessageSuccessPayload = MiniAppBaseSuccessPayload & {
378
+ signature: string;
379
+ address: string;
362
380
  };
363
- type MiniAppLocation = {
364
- countryCode?: string;
365
- regionCode?: string;
381
+ type MiniAppSignMessageErrorPayload = MiniAppBaseErrorPayload<SignMessageErrorCodes> & {
382
+ details?: Record<string, any>;
366
383
  };
367
- declare enum MiniAppLaunchLocation {
368
- Chat = "chat",
369
- Home = "home",
370
- AppStore = "app-store",
371
- DeepLink = "deep-link",
372
- WalletTab = "wallet-tab"
373
- }
374
- declare const mapWorldAppLaunchLocation: (location: string | null | undefined) => MiniAppLaunchLocation | null;
384
+ type MiniAppSignMessagePayload = MiniAppSignMessageSuccessPayload | MiniAppSignMessageErrorPayload;
385
+ declare function createSignMessageCommand(_ctx: CommandContext): (payload: SignMessageInput) => SignMessagePayload | null;
386
+ declare function createSignMessageAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createSignMessageCommand>): (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
375
387
 
376
- declare enum ResponseEvent {
377
- MiniAppVerifyAction = "miniapp-verify-action",
378
- MiniAppPayment = "miniapp-payment",
379
- MiniAppWalletAuth = "miniapp-wallet-auth",
380
- MiniAppSendTransaction = "miniapp-send-transaction",
381
- MiniAppSignMessage = "miniapp-sign-message",
382
- MiniAppSignTypedData = "miniapp-sign-typed-data",
383
- MiniAppShareContacts = "miniapp-share-contacts",
384
- MiniAppRequestPermission = "miniapp-request-permission",
385
- MiniAppGetPermissions = "miniapp-get-permissions",
386
- MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
387
- MiniAppShare = "miniapp-share",
388
- MiniAppMicrophone = "miniapp-microphone",
389
- MiniAppChat = "miniapp-chat"
388
+ declare enum Tokens {
389
+ USDC = "USDCE",
390
+ WLD = "WLD"
390
391
  }
391
- type MiniAppVerifyActionSuccessPayload = {
392
- status: 'success';
393
- proof: string;
394
- merkle_root: string;
395
- nullifier_hash: string;
396
- verification_level: VerificationLevel;
397
- version: number;
398
- };
399
- type MiniAppVerifyActionErrorPayload = {
400
- status: 'error';
401
- error_code: AppErrorCodes;
402
- version: number;
403
- };
404
- type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionErrorPayload;
405
- type MiniAppPaymentSuccessPayload = {
406
- status: 'success';
407
- transaction_status: 'submitted';
408
- transaction_id: string;
409
- reference: string;
410
- from: string;
411
- chain: Network;
412
- timestamp: string;
413
- version: number;
392
+ declare const TokenDecimals: {
393
+ [key in Tokens]: number;
414
394
  };
415
- type MiniAppPaymentErrorPayload = {
416
- status: 'error';
417
- error_code: PaymentErrorCodes;
418
- version: number;
395
+ declare enum Network {
396
+ Optimism = "optimism",
397
+ WorldChain = "worldchain"
398
+ }
399
+
400
+ type Permit2 = {
401
+ permitted: {
402
+ token: string;
403
+ amount: string | unknown;
404
+ };
405
+ spender: string;
406
+ nonce: string | unknown;
407
+ deadline: string | unknown;
419
408
  };
420
- type MiniAppPaymentPayload = MiniAppPaymentSuccessPayload | MiniAppPaymentErrorPayload;
421
- type MiniAppWalletAuthSuccessPayload = {
422
- status: 'success';
423
- message: string;
424
- signature: string;
409
+ type Transaction = {
425
410
  address: string;
426
- version: number;
411
+ abi: Abi | readonly unknown[];
412
+ functionName: ContractFunctionName<Abi | readonly unknown[], 'payable' | 'nonpayable'>;
413
+ value?: string | undefined;
414
+ args: ContractFunctionArgs<Abi | readonly unknown[], 'payable' | 'nonpayable', ContractFunctionName<Abi | readonly unknown[], 'payable' | 'nonpayable'>>;
427
415
  };
428
- type MiniAppWalletAuthErrorPayload = {
429
- status: 'error';
430
- error_code: WalletAuthErrorCodes;
431
- details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
432
- version: number;
416
+ type ContractFunctionName<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability> = ExtractAbiFunctionNames<abi extends Abi ? abi : Abi, mutability> extends infer functionName extends string ? [functionName] extends [never] ? string : functionName : string;
417
+ type ContractFunctionArgs<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability, functionName extends ContractFunctionName<abi, mutability> = ContractFunctionName<abi, mutability>> = AbiParametersToPrimitiveTypes<ExtractAbiFunction<abi extends Abi ? abi : Abi, functionName, mutability>['inputs'], 'inputs'> extends infer args ? [args] extends [never] ? readonly unknown[] : args : readonly unknown[];
418
+
419
+ type SendTransactionInput = {
420
+ transaction: Transaction[];
421
+ permit2?: Permit2[];
422
+ formatPayload?: boolean;
433
423
  };
434
- type MiniAppWalletAuthPayload = MiniAppWalletAuthSuccessPayload | MiniAppWalletAuthErrorPayload;
435
- type MiniAppSendTransactionSuccessPayload = {
436
- status: 'success';
424
+ type SendTransactionPayload = SendTransactionInput;
425
+ declare enum SendTransactionErrorCodes {
426
+ InvalidOperation = "invalid_operation",
427
+ UserRejected = "user_rejected",
428
+ InputError = "input_error",
429
+ SimulationFailed = "simulation_failed",
430
+ TransactionFailed = "transaction_failed",
431
+ GenericError = "generic_error",
432
+ DisallowedOperation = "disallowed_operation",
433
+ ValidationError = "validation_error",
434
+ InvalidContract = "invalid_contract",
435
+ MaliciousOperation = "malicious_operation",
436
+ DailyTxLimitReached = "daily_tx_limit_reached",
437
+ PermittedAmountExceedsSlippage = "permitted_amount_exceeds_slippage",
438
+ PermittedAmountNotFound = "permitted_amount_not_found"
439
+ }
440
+ declare const SendTransactionErrorMessage: Record<SendTransactionErrorCodes, string>;
441
+ type MiniAppSendTransactionSuccessPayload = MiniAppBaseSuccessPayload & {
437
442
  transaction_status: 'submitted';
438
443
  transaction_id: string;
439
444
  reference: string;
440
445
  from: string;
441
446
  chain: Network;
442
447
  timestamp: string;
443
- version: number;
444
448
  mini_app_id?: string;
445
449
  };
446
- type MiniAppSendTransactionErrorPayload = {
447
- status: 'error';
448
- error_code: SendTransactionErrorCodes;
450
+ type MiniAppSendTransactionErrorPayload = MiniAppBaseErrorPayload<SendTransactionErrorCodes> & {
449
451
  details?: Record<string, any>;
450
- version: number;
451
452
  mini_app_id?: string;
452
453
  };
453
454
  type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
454
- type MiniAppSignMessageSuccessPayload = {
455
- status: 'success';
456
- signature: string;
457
- address: string;
458
- version: number;
455
+ declare function createSendTransactionCommand(_ctx: CommandContext): (payload: SendTransactionInput) => SendTransactionPayload | null;
456
+ declare function createSendTransactionAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createSendTransactionCommand>): (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
457
+
458
+ type WalletAuthInput = {
459
+ nonce: string;
460
+ statement?: string;
461
+ requestId?: string;
462
+ expirationTime?: Date;
463
+ notBefore?: Date;
459
464
  };
460
- type MiniAppSignMessageErrorPayload = {
461
- status: 'error';
462
- error_code: SignMessageErrorCodes;
463
- details?: Record<string, any>;
464
- version: number;
465
+ type WalletAuthPayload = {
466
+ siweMessage: string;
465
467
  };
466
- type MiniAppSignMessagePayload = MiniAppSignMessageSuccessPayload | MiniAppSignMessageErrorPayload;
467
- type MiniAppSignTypedDataSuccessPayload = {
468
- status: 'success';
468
+ declare enum WalletAuthErrorCodes {
469
+ MalformedRequest = "malformed_request",
470
+ UserRejected = "user_rejected",
471
+ GenericError = "generic_error"
472
+ }
473
+ declare const WalletAuthErrorMessage: {
474
+ malformed_request: string;
475
+ user_rejected: string;
476
+ generic_error: string;
477
+ };
478
+ type MiniAppWalletAuthSuccessPayload$1 = MiniAppBaseSuccessPayload & {
479
+ message: string;
469
480
  signature: string;
470
481
  address: string;
471
- version: number;
472
- };
473
- type MiniAppSignTypedDataErrorPayload = {
474
- status: 'error';
475
- error_code: SignTypedDataErrorCodes;
476
- details?: Record<string, any>;
477
- version: number;
478
- };
479
- type MiniAppSignTypedDataPayload = MiniAppSignTypedDataSuccessPayload | MiniAppSignTypedDataErrorPayload;
480
- type Contact = {
481
- username: string;
482
- walletAddress: string;
483
- profilePictureUrl: string | null;
484
- };
485
- type MiniAppShareContactsSuccessPayload = {
486
- status: 'success';
487
- contacts: Contact[];
488
- version: number;
489
- timestamp: string;
490
482
  };
491
- type MiniAppShareContactsErrorPayload = {
492
- status: 'error';
493
- error_code: ShareContactsErrorCodes;
494
- version: number;
483
+ type MiniAppWalletAuthErrorPayload = MiniAppBaseErrorPayload<WalletAuthErrorCodes> & {
484
+ details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
495
485
  };
496
- type MiniAppShareContactsPayload = MiniAppShareContactsSuccessPayload | MiniAppShareContactsErrorPayload;
497
- type MiniAppRequestPermissionSuccessPayload = {
498
- status: 'success';
499
- permission: Permission;
500
- timestamp: string;
501
- version: number;
486
+ type MiniAppWalletAuthPayload = MiniAppWalletAuthSuccessPayload$1 | MiniAppWalletAuthErrorPayload;
487
+ declare function createWalletAuthCommand(ctx: CommandContext): (payload: WalletAuthInput) => WalletAuthPayload | null;
488
+ declare function createWalletAuthAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createWalletAuthCommand>): (payload: WalletAuthInput) => AsyncHandlerReturn<WalletAuthPayload | null, MiniAppWalletAuthPayload>;
489
+
490
+ type TokensPayload = {
491
+ symbol: Tokens;
492
+ token_amount: string;
502
493
  };
503
- type MiniAppRequestPermissionErrorPayload = {
504
- status: 'error';
505
- error_code: RequestPermissionErrorCodes;
494
+ type PayCommandInput = {
495
+ reference: string;
496
+ to: `0x${string}` | string;
497
+ tokens: TokensPayload[];
498
+ network?: Network;
506
499
  description: string;
507
- version: number;
508
- };
509
- type MiniAppRequestPermissionPayload = MiniAppRequestPermissionSuccessPayload | MiniAppRequestPermissionErrorPayload;
510
- type PermissionSettings = {
511
- [K in Permission]?: any;
512
- };
513
- type MiniAppGetPermissionsSuccessPayload = {
514
- status: 'success';
515
- permissions: PermissionSettings;
516
- version: number;
517
- timestamp: string;
518
- };
519
- type MiniAppGetPermissionsErrorPayload = {
520
- status: 'error';
521
- error_code: GetPermissionsErrorCodes;
522
- details: string;
523
- version: number;
524
- };
525
- type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
526
- type MiniAppSendHapticFeedbackSuccessPayload = {
527
- status: 'success';
528
- version: number;
529
- timestamp: string;
530
- };
531
- type MiniAppSendHapticFeedbackErrorPayload = {
532
- status: 'error';
533
- error_code: SendHapticFeedbackErrorCodes;
534
- version: number;
535
500
  };
536
- type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
537
- type MiniAppShareSuccessPayload = {
538
- status: 'success';
539
- shared_files_count: number;
540
- version: number;
501
+ type PayCommandPayload = PayCommandInput;
502
+ declare enum PaymentErrorCodes {
503
+ InputError = "input_error",
504
+ UserRejected = "user_rejected",
505
+ PaymentRejected = "payment_rejected",
506
+ InvalidReceiver = "invalid_receiver",
507
+ InsufficientBalance = "insufficient_balance",
508
+ TransactionFailed = "transaction_failed",
509
+ GenericError = "generic_error",
510
+ UserBlocked = "user_blocked"
511
+ }
512
+ declare const PaymentErrorMessage: Record<PaymentErrorCodes, string>;
513
+ type MiniAppPaymentSuccessPayload = MiniAppBaseSuccessPayload & {
514
+ transaction_status: 'submitted';
515
+ transaction_id: string;
516
+ reference: string;
517
+ from: string;
518
+ chain: Network;
541
519
  timestamp: string;
542
520
  };
543
- type MiniAppShareErrorPayload = {
544
- status: 'error';
545
- error_code: ShareFilesErrorCodes;
546
- version: number;
521
+ type MiniAppPaymentErrorPayload = MiniAppBaseErrorPayload<PaymentErrorCodes>;
522
+ type MiniAppPaymentPayload = MiniAppPaymentSuccessPayload | MiniAppPaymentErrorPayload;
523
+ declare function createPayCommand(_ctx: CommandContext): (payload: PayCommandInput) => PayCommandPayload | null;
524
+ declare function createPayAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createPayCommand>): (payload: PayCommandInput) => AsyncHandlerReturn<PayCommandPayload | null, MiniAppPaymentPayload>;
525
+
526
+ type VerifyCommandInput = {
527
+ action: IDKitConfig['action'];
528
+ signal?: IDKitConfig['signal'];
529
+ verification_level?: VerificationLevel | [VerificationLevel, ...VerificationLevel[]];
547
530
  };
548
- type MiniAppSharePayload = MiniAppShareSuccessPayload | MiniAppShareErrorPayload;
549
- type MiniAppMicrophoneSuccessPayload = {
550
- status: 'success';
551
- version: number;
531
+ type VerifyCommandPayload = VerifyCommandInput & {
552
532
  timestamp: string;
553
533
  };
554
- type MiniAppMicrophoneErrorPayload = {
555
- status: 'error';
556
- error_code: MicrophoneErrorCodes;
557
- version: number;
558
- };
559
- type MiniAppMicrophonePayload = MiniAppMicrophoneSuccessPayload | MiniAppMicrophoneErrorPayload;
560
- type MiniAppChatSuccessPayload = {
561
- status: 'success';
562
- count: number;
563
- timestamp: string;
564
- version: number;
534
+
535
+ type MiniAppVerifyActionSuccessPayload = MiniAppBaseSuccessPayload & {
536
+ proof: string;
537
+ merkle_root: string;
538
+ nullifier_hash: string;
539
+ verification_level: VerificationLevel;
565
540
  };
566
- type MiniAppChatErrorPayload = {
567
- status: 'error';
568
- error_code: ChatErrorCodes;
569
- version: number;
541
+ type VerificationResult = Omit<MiniAppVerifyActionSuccessPayload, 'status' | 'version'>;
542
+ type MiniAppVerifyActionMultiSuccessPayload = MiniAppBaseSuccessPayload & {
543
+ verifications: VerificationResult[];
570
544
  };
571
- type MiniAppChatPayload = MiniAppChatSuccessPayload | MiniAppChatErrorPayload;
572
- type EventPayloadMap = {
573
- [ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
574
- [ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
575
- [ResponseEvent.MiniAppWalletAuth]: MiniAppWalletAuthPayload;
576
- [ResponseEvent.MiniAppSendTransaction]: MiniAppSendTransactionPayload;
577
- [ResponseEvent.MiniAppSignMessage]: MiniAppSignMessagePayload;
578
- [ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
579
- [ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
580
- [ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
581
- [ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
582
- [ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
583
- [ResponseEvent.MiniAppShare]: MiniAppSharePayload;
584
- [ResponseEvent.MiniAppMicrophone]: MiniAppMicrophonePayload;
585
- [ResponseEvent.MiniAppChat]: MiniAppChatPayload;
586
- };
587
- type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
588
- type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
545
+ type MiniAppVerifyActionErrorPayload = MiniAppBaseErrorPayload<string>;
546
+ type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionMultiSuccessPayload | MiniAppVerifyActionErrorPayload;
547
+ declare function createVerifyCommand(_ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
548
+ declare function createVerifyAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createVerifyCommand>): (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
549
+
550
+ declare function createCommands(ctx: CommandContext): {
551
+ verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
552
+ pay: (payload: PayCommandInput) => PayCommandPayload | null;
553
+ walletAuth: (payload: WalletAuthInput) => WalletAuthPayload | null;
554
+ sendTransaction: (payload: SendTransactionInput) => SendTransactionPayload | null;
555
+ signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
556
+ signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
557
+ shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
558
+ requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
559
+ getPermissions: () => GetPermissionsPayload | null;
560
+ sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
561
+ share: (payload: ShareInput) => ShareInput | null;
562
+ chat: (payload: ChatPayload) => ChatPayload | null;
563
+ };
564
+ type Commands = ReturnType<typeof createCommands>;
565
+ declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
566
+ verify: (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
567
+ pay: (payload: PayCommandInput) => AsyncHandlerReturn<PayCommandPayload | null, MiniAppPaymentPayload>;
568
+ walletAuth: (payload: WalletAuthInput) => AsyncHandlerReturn<WalletAuthPayload | null, MiniAppWalletAuthPayload>;
569
+ sendTransaction: (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
570
+ signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
571
+ signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
572
+ shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
573
+ requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
574
+ getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
575
+ sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
576
+ share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
577
+ chat: (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
578
+ };
579
+ type AsyncCommands = ReturnType<typeof createAsyncCommands>;
589
580
 
590
581
  declare class MiniKit {
591
- private static readonly MINIKIT_VERSION;
592
- private static readonly MINIKIT_MINOR_VERSION;
593
- private static readonly miniKitCommandVersion;
594
- private static isCommandAvailable;
595
- private static listeners;
596
- static appId: string | null;
597
- static user: User;
598
- static deviceProperties: DeviceProperties;
599
- static location: MiniAppLaunchLocation | null;
600
- private static isReady;
601
- private static sendInit;
602
- static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
582
+ private static eventManager;
583
+ private static stateManager;
584
+ private static commandsInstance;
585
+ private static asyncCommandsInstance;
586
+ static get appId(): string | null;
587
+ static set appId(value: string | null);
588
+ static get user(): typeof MiniKit.stateManager.user;
589
+ static set user(value: typeof MiniKit.stateManager.user);
590
+ static get deviceProperties(): DeviceProperties;
591
+ static get location(): MiniAppLaunchLocation | null;
592
+ static subscribe<E extends ResponseEvent>(event: E, handler: (payload: any) => void): void;
603
593
  static unsubscribe(event: ResponseEvent): void;
604
- static trigger(event: ResponseEvent, payload: EventPayload): void;
605
- private static awaitCommand;
606
- private static commandsValid;
594
+ static trigger(event: ResponseEvent, payload: any): void;
595
+ private static sendInit;
607
596
  static install(appId?: string): MiniKitInstallReturnType;
608
597
  static isInstalled(debug?: boolean): boolean;
598
+ private static getContext;
599
+ static get commands(): Commands;
600
+ static get commandsAsync(): AsyncCommands;
609
601
  static getUserByAddress: (address?: string) => Promise<UserNameService>;
610
602
  static getUserByUsername: (username: string) => Promise<UserNameService>;
603
+ static getUserInfo: (address?: string) => Promise<UserNameService>;
611
604
  static getMiniAppUrl: (appId: string, path?: string) => string;
612
605
  static showProfileCard: (username?: string, walletAddress?: string) => void;
613
- static getUserInfo: (address?: string) => Promise<UserNameService>;
614
- static commands: {
615
- verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
616
- pay: (payload: PayCommandInput) => PayCommandPayload | null;
617
- walletAuth: (payload: WalletAuthInput) => WalletAuthPayload | null;
618
- sendTransaction: (payload: SendTransactionInput) => SendTransactionPayload | null;
619
- signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
620
- signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
621
- shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
622
- requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
623
- getPermissions: () => GetPermissionsPayload | null;
624
- sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
625
- share: (payload: ShareInput) => ShareInput | null;
626
- chat: (payload: ChatPayload) => ChatPayload | null;
627
- };
628
- /**
629
- * This object contains async versions of all the commands.
630
- * Instead of using event listeners, you can just `await` these.
631
- *
632
- * They return a standardized object
633
- *
634
- * commandPayload - object returned by the command function
635
- *
636
- * finalPayload - object returned by the event listener, or in other words, WorldApp response
637
- */
638
- static commandsAsync: {
639
- verify: (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
640
- pay: (payload: PayCommandInput) => AsyncHandlerReturn<PayCommandPayload | null, MiniAppPaymentPayload>;
641
- walletAuth: (payload: WalletAuthInput) => AsyncHandlerReturn<WalletAuthPayload | null, MiniAppWalletAuthPayload>;
642
- sendTransaction: (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
643
- signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
644
- signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
645
- shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
646
- requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
647
- getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
648
- sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
649
- share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
650
- chat: (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
651
- };
652
606
  }
653
607
 
654
608
  type SiweMessage = {
@@ -668,6 +622,14 @@ type SiweMessage = {
668
622
 
669
623
  declare const tokenToDecimals: (amount: number, token: Tokens) => number;
670
624
 
625
+ type MiniAppWalletAuthSuccessPayload = {
626
+ status: 'success';
627
+ message: string;
628
+ signature: string;
629
+ address: string;
630
+ version: number;
631
+ };
632
+
671
633
  declare const parseSiweMessage: (inputString: string) => SiweMessage;
672
634
  declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonce: string, statement?: string, requestId?: string, userProvider?: Client) => Promise<{
673
635
  isValid: boolean;
@@ -676,4 +638,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
676
638
 
677
639
  declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
678
640
 
679
- export { type AsyncHandlerReturn, ChatErrorCodes, ChatErrorMessage, type ChatPayload, Command, type CommandReturnPayload, type Contact, type DeviceProperties, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, MicrophoneErrorCodes, MicrophoneErrorMessage, type MiniAppChatErrorPayload, type MiniAppChatPayload, type MiniAppChatSuccessPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, MiniAppLaunchLocation, type MiniAppLocation, type MiniAppMicrophoneErrorPayload, type MiniAppMicrophonePayload, type MiniAppMicrophoneSuccessPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendHapticFeedbackErrorPayload, type MiniAppSendHapticFeedbackPayload, type MiniAppSendHapticFeedbackSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppShareErrorPayload, type MiniAppSharePayload, type MiniAppShareSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, type PermissionSettings, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, ShareFilesErrorCodes, ShareFilesErrorMessage, type ShareInput, type SharePayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, type User, type UserNameService, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, mapWorldAppLaunchLocation, parseSiweMessage, tokenToDecimals, verifySiweMessage };
641
+ export { type AsyncCommands, type AsyncHandlerReturn, COMMAND_VERSIONS, ChatErrorCodes, ChatErrorMessage, type ChatPayload, Command, type CommandContext, type Commands, type Contact, type ContractFunctionArgs, type ContractFunctionName, type DeviceProperties, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppBaseErrorPayload, type MiniAppBaseSuccessPayload, type MiniAppChatErrorPayload, type MiniAppChatPayload, type MiniAppChatSuccessPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, MiniAppLaunchLocation, type MiniAppLocation, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendHapticFeedbackErrorPayload, type MiniAppSendHapticFeedbackPayload, type MiniAppSendHapticFeedbackSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppShareErrorPayload, type MiniAppSharePayload, type MiniAppShareSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionMultiSuccessPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload$1 as MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, Permission, type PermissionSettings, type Permit2, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, ShareFilesErrorCodes, ShareFilesErrorMessage, type ShareInput, type SharePayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, type Transaction, type User, type UserNameService, type VerificationResult, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, createAsyncCommands, createChatAsyncCommand, createChatCommand, createCommands, createGetPermissionsAsyncCommand, createGetPermissionsCommand, createPayAsyncCommand, createPayCommand, createRequestPermissionAsyncCommand, createRequestPermissionCommand, createSendHapticFeedbackAsyncCommand, createSendHapticFeedbackCommand, createSendTransactionAsyncCommand, createSendTransactionCommand, createShareAsyncCommand, createShareCommand, createShareContactsAsyncCommand, createShareContactsCommand, createSignMessageAsyncCommand, createSignMessageCommand, createSignTypedDataAsyncCommand, createSignTypedDataCommand, createVerifyAsyncCommand, createVerifyCommand, createWalletAuthAsyncCommand, createWalletAuthCommand, getIsUserVerified, isCommandAvailable, mapWorldAppLaunchLocation, parseSiweMessage, sendMiniKitEvent, setCommandAvailable, tokenToDecimals, validateCommands, verifySiweMessage };