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