@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
|
@@ -1,19 +1,261 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
[AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
9
|
-
[AppErrorCodes.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
|
|
10
|
-
[AppErrorCodes.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
|
|
11
|
-
[AppErrorCodes.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
|
|
12
|
-
[AppErrorCodes.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
|
|
13
|
-
[AppErrorCodes.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
|
|
14
|
-
[AppErrorCodes.GenericError]: "Something unexpected went wrong. Please try again.",
|
|
15
|
-
[AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
1
|
+
// helpers/send-webview-event.ts
|
|
2
|
+
var sendWebviewEvent = (payload) => {
|
|
3
|
+
if (window.webkit) {
|
|
4
|
+
window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
|
|
5
|
+
} else if (window.Android) {
|
|
6
|
+
window.Android.postMessage?.(JSON.stringify(payload));
|
|
7
|
+
}
|
|
16
8
|
};
|
|
9
|
+
|
|
10
|
+
// commands/types.ts
|
|
11
|
+
var Command = /* @__PURE__ */ ((Command2) => {
|
|
12
|
+
Command2["Verify"] = "verify";
|
|
13
|
+
Command2["Pay"] = "pay";
|
|
14
|
+
Command2["WalletAuth"] = "wallet-auth";
|
|
15
|
+
Command2["SendTransaction"] = "send-transaction";
|
|
16
|
+
Command2["SignMessage"] = "sign-message";
|
|
17
|
+
Command2["SignTypedData"] = "sign-typed-data";
|
|
18
|
+
Command2["ShareContacts"] = "share-contacts";
|
|
19
|
+
Command2["RequestPermission"] = "request-permission";
|
|
20
|
+
Command2["GetPermissions"] = "get-permissions";
|
|
21
|
+
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
22
|
+
Command2["Share"] = "share";
|
|
23
|
+
Command2["Chat"] = "chat";
|
|
24
|
+
return Command2;
|
|
25
|
+
})(Command || {});
|
|
26
|
+
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent3) => {
|
|
27
|
+
ResponseEvent3["MiniAppVerifyAction"] = "miniapp-verify-action";
|
|
28
|
+
ResponseEvent3["MiniAppPayment"] = "miniapp-payment";
|
|
29
|
+
ResponseEvent3["MiniAppWalletAuth"] = "miniapp-wallet-auth";
|
|
30
|
+
ResponseEvent3["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
31
|
+
ResponseEvent3["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
32
|
+
ResponseEvent3["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
33
|
+
ResponseEvent3["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
34
|
+
ResponseEvent3["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
35
|
+
ResponseEvent3["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
36
|
+
ResponseEvent3["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
37
|
+
ResponseEvent3["MiniAppShare"] = "miniapp-share";
|
|
38
|
+
ResponseEvent3["MiniAppMicrophone"] = "miniapp-microphone";
|
|
39
|
+
ResponseEvent3["MiniAppChat"] = "miniapp-chat";
|
|
40
|
+
return ResponseEvent3;
|
|
41
|
+
})(ResponseEvent || {});
|
|
42
|
+
var COMMAND_VERSIONS = {
|
|
43
|
+
["verify" /* Verify */]: 1,
|
|
44
|
+
["pay" /* Pay */]: 1,
|
|
45
|
+
["wallet-auth" /* WalletAuth */]: 2,
|
|
46
|
+
["send-transaction" /* SendTransaction */]: 1,
|
|
47
|
+
["sign-message" /* SignMessage */]: 1,
|
|
48
|
+
["sign-typed-data" /* SignTypedData */]: 1,
|
|
49
|
+
["share-contacts" /* ShareContacts */]: 1,
|
|
50
|
+
["request-permission" /* RequestPermission */]: 1,
|
|
51
|
+
["get-permissions" /* GetPermissions */]: 1,
|
|
52
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
53
|
+
["share" /* Share */]: 1,
|
|
54
|
+
["chat" /* Chat */]: 1
|
|
55
|
+
};
|
|
56
|
+
var commandAvailability = {
|
|
57
|
+
["verify" /* Verify */]: false,
|
|
58
|
+
["pay" /* Pay */]: false,
|
|
59
|
+
["wallet-auth" /* WalletAuth */]: false,
|
|
60
|
+
["send-transaction" /* SendTransaction */]: false,
|
|
61
|
+
["sign-message" /* SignMessage */]: false,
|
|
62
|
+
["sign-typed-data" /* SignTypedData */]: false,
|
|
63
|
+
["share-contacts" /* ShareContacts */]: false,
|
|
64
|
+
["request-permission" /* RequestPermission */]: false,
|
|
65
|
+
["get-permissions" /* GetPermissions */]: false,
|
|
66
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
67
|
+
["share" /* Share */]: false,
|
|
68
|
+
["chat" /* Chat */]: false
|
|
69
|
+
};
|
|
70
|
+
function isCommandAvailable(command) {
|
|
71
|
+
return commandAvailability[command];
|
|
72
|
+
}
|
|
73
|
+
function setCommandAvailable(command, available) {
|
|
74
|
+
commandAvailability[command] = available;
|
|
75
|
+
}
|
|
76
|
+
function validateCommands(worldAppSupportedCommands) {
|
|
77
|
+
let allCommandsValid = true;
|
|
78
|
+
Object.entries(COMMAND_VERSIONS).forEach(([commandName, version]) => {
|
|
79
|
+
const commandInput = worldAppSupportedCommands.find(
|
|
80
|
+
(cmd) => cmd.name === commandName
|
|
81
|
+
);
|
|
82
|
+
let isCommandValid = false;
|
|
83
|
+
if (!commandInput) {
|
|
84
|
+
console.warn(
|
|
85
|
+
`Command ${commandName} is not supported by the app. Try updating the app version`
|
|
86
|
+
);
|
|
87
|
+
} else {
|
|
88
|
+
if (commandInput.supported_versions.includes(version)) {
|
|
89
|
+
setCommandAvailable(commandName, true);
|
|
90
|
+
isCommandValid = true;
|
|
91
|
+
} else {
|
|
92
|
+
isCommandValid = true;
|
|
93
|
+
console.warn(
|
|
94
|
+
`Command ${commandName} version ${version} is not supported by the app. Supported versions: ${commandInput.supported_versions.join(", ")}. This is not an error, but it is recommended to update the World App version.`
|
|
95
|
+
);
|
|
96
|
+
setCommandAvailable(commandName, true);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!isCommandValid) {
|
|
100
|
+
allCommandsValid = false;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return allCommandsValid;
|
|
104
|
+
}
|
|
105
|
+
function sendMiniKitEvent(payload) {
|
|
106
|
+
sendWebviewEvent(payload);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// commands/chat.ts
|
|
110
|
+
var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
|
|
111
|
+
ChatErrorCodes2["UserRejected"] = "user_rejected";
|
|
112
|
+
ChatErrorCodes2["SendFailed"] = "send_failed";
|
|
113
|
+
ChatErrorCodes2["GenericError"] = "generic_error";
|
|
114
|
+
return ChatErrorCodes2;
|
|
115
|
+
})(ChatErrorCodes || {});
|
|
116
|
+
var ChatErrorMessage = {
|
|
117
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
118
|
+
["send_failed" /* SendFailed */]: "Failed to send the message.",
|
|
119
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
120
|
+
};
|
|
121
|
+
function createChatCommand(_ctx) {
|
|
122
|
+
return (payload) => {
|
|
123
|
+
if (typeof window === "undefined" || !isCommandAvailable("chat" /* Chat */)) {
|
|
124
|
+
console.error(
|
|
125
|
+
"'chat' command is unavailable. Check MiniKit.install() or update the app version"
|
|
126
|
+
);
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (payload.message.length === 0) {
|
|
130
|
+
console.error("'chat' command requires a non-empty message");
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
sendMiniKitEvent({
|
|
134
|
+
command: "chat" /* Chat */,
|
|
135
|
+
version: COMMAND_VERSIONS["chat" /* Chat */],
|
|
136
|
+
payload
|
|
137
|
+
});
|
|
138
|
+
return payload;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function createChatAsyncCommand(ctx, syncCommand) {
|
|
142
|
+
return async (payload) => {
|
|
143
|
+
return new Promise((resolve, reject) => {
|
|
144
|
+
try {
|
|
145
|
+
let commandPayload = null;
|
|
146
|
+
const handleResponse = (response) => {
|
|
147
|
+
ctx.events.unsubscribe("miniapp-chat" /* MiniAppChat */);
|
|
148
|
+
resolve({ commandPayload, finalPayload: response });
|
|
149
|
+
};
|
|
150
|
+
ctx.events.subscribe("miniapp-chat" /* MiniAppChat */, handleResponse);
|
|
151
|
+
commandPayload = syncCommand(payload);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
reject(error);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// commands/get-permissions.ts
|
|
160
|
+
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
161
|
+
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
162
|
+
return GetPermissionsErrorCodes2;
|
|
163
|
+
})(GetPermissionsErrorCodes || {});
|
|
164
|
+
var GetPermissionsErrorMessage = {
|
|
165
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
166
|
+
};
|
|
167
|
+
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
168
|
+
Permission2["Notifications"] = "notifications";
|
|
169
|
+
Permission2["Contacts"] = "contacts";
|
|
170
|
+
Permission2["Microphone"] = "microphone";
|
|
171
|
+
return Permission2;
|
|
172
|
+
})(Permission || {});
|
|
173
|
+
function createGetPermissionsCommand(_ctx) {
|
|
174
|
+
return () => {
|
|
175
|
+
if (typeof window === "undefined" || !isCommandAvailable("get-permissions" /* GetPermissions */)) {
|
|
176
|
+
console.error(
|
|
177
|
+
"'getPermissions' command is unavailable. Check MiniKit.install() or update the app version"
|
|
178
|
+
);
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
sendMiniKitEvent({
|
|
182
|
+
command: "get-permissions" /* GetPermissions */,
|
|
183
|
+
version: COMMAND_VERSIONS["get-permissions" /* GetPermissions */],
|
|
184
|
+
payload: {}
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
status: "sent"
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function createGetPermissionsAsyncCommand(ctx, syncCommand) {
|
|
192
|
+
return async () => {
|
|
193
|
+
return new Promise((resolve, reject) => {
|
|
194
|
+
try {
|
|
195
|
+
let commandPayload = null;
|
|
196
|
+
const handleResponse = (payload) => {
|
|
197
|
+
ctx.events.unsubscribe("miniapp-get-permissions" /* MiniAppGetPermissions */);
|
|
198
|
+
resolve({ commandPayload, finalPayload: payload });
|
|
199
|
+
};
|
|
200
|
+
ctx.events.subscribe(
|
|
201
|
+
"miniapp-get-permissions" /* MiniAppGetPermissions */,
|
|
202
|
+
handleResponse
|
|
203
|
+
);
|
|
204
|
+
commandPayload = syncCommand();
|
|
205
|
+
} catch (error) {
|
|
206
|
+
reject(error);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// types/payment.ts
|
|
213
|
+
var Tokens = /* @__PURE__ */ ((Tokens3) => {
|
|
214
|
+
Tokens3["USDC"] = "USDCE";
|
|
215
|
+
Tokens3["WLD"] = "WLD";
|
|
216
|
+
return Tokens3;
|
|
217
|
+
})(Tokens || {});
|
|
218
|
+
var TokenDecimals = {
|
|
219
|
+
["USDCE" /* USDC */]: 6,
|
|
220
|
+
["WLD" /* WLD */]: 18
|
|
221
|
+
};
|
|
222
|
+
var Network = /* @__PURE__ */ ((Network2) => {
|
|
223
|
+
Network2["Optimism"] = "optimism";
|
|
224
|
+
Network2["WorldChain"] = "worldchain";
|
|
225
|
+
return Network2;
|
|
226
|
+
})(Network || {});
|
|
227
|
+
|
|
228
|
+
// helpers/payment/client.ts
|
|
229
|
+
var tokenToDecimals = (amount, token) => {
|
|
230
|
+
const decimals = TokenDecimals[token];
|
|
231
|
+
if (decimals === void 0) {
|
|
232
|
+
throw new Error(`Invalid token: ${token}`);
|
|
233
|
+
}
|
|
234
|
+
const factor = 10 ** decimals;
|
|
235
|
+
const result = amount * factor;
|
|
236
|
+
if (!Number.isInteger(result)) {
|
|
237
|
+
throw new Error(`The resulting amount is not a whole number: ${result}`);
|
|
238
|
+
}
|
|
239
|
+
return result;
|
|
240
|
+
};
|
|
241
|
+
var validatePaymentPayload = (payload) => {
|
|
242
|
+
if (payload.tokens.some(
|
|
243
|
+
(token) => token.symbol == "USDCE" /* USDC */ && parseFloat(token.token_amount) < 0.1
|
|
244
|
+
)) {
|
|
245
|
+
console.error("USDC amount should be greater than $0.1");
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
if (payload.reference.length > 36) {
|
|
249
|
+
console.error("Reference must not exceed 36 characters");
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
if (typeof payload.reference !== "string") {
|
|
253
|
+
throw new Error("Reference must be a string");
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// commands/pay.ts
|
|
17
259
|
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
18
260
|
PaymentErrorCodes2["InputError"] = "input_error";
|
|
19
261
|
PaymentErrorCodes2["UserRejected"] = "user_rejected";
|
|
@@ -35,24 +277,217 @@ var PaymentErrorMessage = {
|
|
|
35
277
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
36
278
|
["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
|
|
37
279
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
280
|
+
function createPayCommand(_ctx) {
|
|
281
|
+
return (payload) => {
|
|
282
|
+
if (typeof window === "undefined" || !isCommandAvailable("pay" /* Pay */)) {
|
|
283
|
+
console.error(
|
|
284
|
+
"'pay' command is unavailable. Check MiniKit.install() or update the app version"
|
|
285
|
+
);
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
if (!validatePaymentPayload(payload)) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
const eventPayload = {
|
|
292
|
+
...payload,
|
|
293
|
+
network: "worldchain" /* WorldChain */
|
|
294
|
+
};
|
|
295
|
+
sendMiniKitEvent({
|
|
296
|
+
command: "pay" /* Pay */,
|
|
297
|
+
version: COMMAND_VERSIONS["pay" /* Pay */],
|
|
298
|
+
payload: eventPayload
|
|
299
|
+
});
|
|
300
|
+
return eventPayload;
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function createPayAsyncCommand(ctx, syncCommand) {
|
|
304
|
+
return async (payload) => {
|
|
305
|
+
return new Promise((resolve, reject) => {
|
|
306
|
+
try {
|
|
307
|
+
let commandPayload = null;
|
|
308
|
+
const handleResponse = (response) => {
|
|
309
|
+
ctx.events.unsubscribe("miniapp-payment" /* MiniAppPayment */);
|
|
310
|
+
resolve({ commandPayload, finalPayload: response });
|
|
311
|
+
};
|
|
312
|
+
ctx.events.subscribe(
|
|
313
|
+
"miniapp-payment" /* MiniAppPayment */,
|
|
314
|
+
handleResponse
|
|
315
|
+
);
|
|
316
|
+
commandPayload = syncCommand(payload);
|
|
317
|
+
} catch (error) {
|
|
318
|
+
reject(error);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// commands/request-permission.ts
|
|
325
|
+
var RequestPermissionErrorCodes = /* @__PURE__ */ ((RequestPermissionErrorCodes2) => {
|
|
326
|
+
RequestPermissionErrorCodes2["UserRejected"] = "user_rejected";
|
|
327
|
+
RequestPermissionErrorCodes2["GenericError"] = "generic_error";
|
|
328
|
+
RequestPermissionErrorCodes2["AlreadyRequested"] = "already_requested";
|
|
329
|
+
RequestPermissionErrorCodes2["PermissionDisabled"] = "permission_disabled";
|
|
330
|
+
RequestPermissionErrorCodes2["AlreadyGranted"] = "already_granted";
|
|
331
|
+
RequestPermissionErrorCodes2["UnsupportedPermission"] = "unsupported_permission";
|
|
332
|
+
return RequestPermissionErrorCodes2;
|
|
333
|
+
})(RequestPermissionErrorCodes || {});
|
|
334
|
+
var RequestPermissionErrorMessage = {
|
|
335
|
+
["user_rejected" /* UserRejected */]: "User declined sharing contacts",
|
|
336
|
+
["generic_error" /* GenericError */]: "Request failed for unknown reason.",
|
|
337
|
+
["already_requested" /* AlreadyRequested */]: "User has already declined turning on notifications once",
|
|
338
|
+
["permission_disabled" /* PermissionDisabled */]: "User does not have this permission enabled in World App",
|
|
339
|
+
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
340
|
+
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
55
341
|
};
|
|
342
|
+
function createRequestPermissionCommand(_ctx) {
|
|
343
|
+
return (payload) => {
|
|
344
|
+
if (typeof window === "undefined" || !isCommandAvailable("request-permission" /* RequestPermission */)) {
|
|
345
|
+
console.error(
|
|
346
|
+
"'requestPermission' command is unavailable. Check MiniKit.install() or update the app version"
|
|
347
|
+
);
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
sendMiniKitEvent({
|
|
351
|
+
command: "request-permission" /* RequestPermission */,
|
|
352
|
+
version: COMMAND_VERSIONS["request-permission" /* RequestPermission */],
|
|
353
|
+
payload
|
|
354
|
+
});
|
|
355
|
+
return payload;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function createRequestPermissionAsyncCommand(ctx, syncCommand) {
|
|
359
|
+
return async (payload) => {
|
|
360
|
+
return new Promise((resolve, reject) => {
|
|
361
|
+
try {
|
|
362
|
+
let commandPayload = null;
|
|
363
|
+
const handleResponse = (response) => {
|
|
364
|
+
ctx.events.unsubscribe("miniapp-request-permission" /* MiniAppRequestPermission */);
|
|
365
|
+
resolve({ commandPayload, finalPayload: response });
|
|
366
|
+
};
|
|
367
|
+
ctx.events.subscribe(
|
|
368
|
+
"miniapp-request-permission" /* MiniAppRequestPermission */,
|
|
369
|
+
handleResponse
|
|
370
|
+
);
|
|
371
|
+
commandPayload = syncCommand(payload);
|
|
372
|
+
} catch (error) {
|
|
373
|
+
reject(error);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// commands/send-haptic-feedback.ts
|
|
380
|
+
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
381
|
+
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
382
|
+
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
383
|
+
return SendHapticFeedbackErrorCodes2;
|
|
384
|
+
})(SendHapticFeedbackErrorCodes || {});
|
|
385
|
+
var SendHapticFeedbackErrorMessage = {
|
|
386
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
387
|
+
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
388
|
+
};
|
|
389
|
+
function createSendHapticFeedbackCommand(_ctx) {
|
|
390
|
+
return (payload) => {
|
|
391
|
+
if (typeof window === "undefined" || !isCommandAvailable("send-haptic-feedback" /* SendHapticFeedback */)) {
|
|
392
|
+
console.error(
|
|
393
|
+
"'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
|
|
394
|
+
);
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
sendMiniKitEvent({
|
|
398
|
+
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
399
|
+
version: COMMAND_VERSIONS["send-haptic-feedback" /* SendHapticFeedback */],
|
|
400
|
+
payload
|
|
401
|
+
});
|
|
402
|
+
return payload;
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function createSendHapticFeedbackAsyncCommand(ctx, syncCommand) {
|
|
406
|
+
return async (payload) => {
|
|
407
|
+
return new Promise((resolve, reject) => {
|
|
408
|
+
try {
|
|
409
|
+
let commandPayload = null;
|
|
410
|
+
const handleResponse = (response) => {
|
|
411
|
+
ctx.events.unsubscribe("miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */);
|
|
412
|
+
resolve({ commandPayload, finalPayload: response });
|
|
413
|
+
};
|
|
414
|
+
ctx.events.subscribe(
|
|
415
|
+
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
416
|
+
handleResponse
|
|
417
|
+
);
|
|
418
|
+
commandPayload = syncCommand(payload);
|
|
419
|
+
} catch (error) {
|
|
420
|
+
reject(error);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// helpers/transaction/validate-payload.ts
|
|
427
|
+
var isValidHex = (str) => {
|
|
428
|
+
return /^0x[0-9A-Fa-f]+$/.test(str);
|
|
429
|
+
};
|
|
430
|
+
var objectValuesToArrayRecursive = (input) => {
|
|
431
|
+
if (input === null || typeof input !== "object") {
|
|
432
|
+
return input;
|
|
433
|
+
}
|
|
434
|
+
if (Array.isArray(input)) {
|
|
435
|
+
return input.map((item) => objectValuesToArrayRecursive(item));
|
|
436
|
+
}
|
|
437
|
+
const values = Object.values(input);
|
|
438
|
+
return values.map((value) => objectValuesToArrayRecursive(value));
|
|
439
|
+
};
|
|
440
|
+
var processPayload = (payload) => {
|
|
441
|
+
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
442
|
+
return payload;
|
|
443
|
+
}
|
|
444
|
+
if (typeof payload === "number" || typeof payload === "bigint") {
|
|
445
|
+
return String(payload);
|
|
446
|
+
}
|
|
447
|
+
if (Array.isArray(payload)) {
|
|
448
|
+
return payload.map((value) => processPayload(value));
|
|
449
|
+
}
|
|
450
|
+
if (typeof payload === "object") {
|
|
451
|
+
const result = { ...payload };
|
|
452
|
+
if ("value" in result && result.value !== void 0) {
|
|
453
|
+
if (typeof result.value !== "string") {
|
|
454
|
+
result.value = String(result.value);
|
|
455
|
+
}
|
|
456
|
+
if (!isValidHex(result.value)) {
|
|
457
|
+
console.error(
|
|
458
|
+
"Transaction value must be a valid hex string",
|
|
459
|
+
result.value
|
|
460
|
+
);
|
|
461
|
+
throw new Error(
|
|
462
|
+
`Transaction value must be a valid hex string: ${result.value}`
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
for (const key in result) {
|
|
467
|
+
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
468
|
+
result[key] = processPayload(result[key]);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return result;
|
|
472
|
+
}
|
|
473
|
+
return payload;
|
|
474
|
+
};
|
|
475
|
+
var validateSendTransactionPayload = (payload) => {
|
|
476
|
+
if (payload.formatPayload) {
|
|
477
|
+
const formattedPayload = processPayload(payload);
|
|
478
|
+
formattedPayload.transaction = formattedPayload.transaction.map((tx) => {
|
|
479
|
+
const args = objectValuesToArrayRecursive(tx.args);
|
|
480
|
+
return {
|
|
481
|
+
...tx,
|
|
482
|
+
args
|
|
483
|
+
};
|
|
484
|
+
});
|
|
485
|
+
return formattedPayload;
|
|
486
|
+
}
|
|
487
|
+
return payload;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// commands/send-transaction.ts
|
|
56
491
|
var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
|
|
57
492
|
SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
58
493
|
SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
|
|
@@ -84,6 +519,221 @@ var SendTransactionErrorMessage = {
|
|
|
84
519
|
["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
|
|
85
520
|
["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
|
|
86
521
|
};
|
|
522
|
+
function createSendTransactionCommand(_ctx) {
|
|
523
|
+
return (payload) => {
|
|
524
|
+
if (typeof window === "undefined" || !isCommandAvailable("send-transaction" /* SendTransaction */)) {
|
|
525
|
+
console.error(
|
|
526
|
+
"'sendTransaction' command is unavailable. Check MiniKit.install() or update the app version"
|
|
527
|
+
);
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
payload.formatPayload = payload.formatPayload !== false;
|
|
531
|
+
const validatedPayload = validateSendTransactionPayload(payload);
|
|
532
|
+
sendMiniKitEvent({
|
|
533
|
+
command: "send-transaction" /* SendTransaction */,
|
|
534
|
+
version: COMMAND_VERSIONS["send-transaction" /* SendTransaction */],
|
|
535
|
+
payload: validatedPayload
|
|
536
|
+
});
|
|
537
|
+
return validatedPayload;
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function createSendTransactionAsyncCommand(ctx, syncCommand) {
|
|
541
|
+
return async (payload) => {
|
|
542
|
+
return new Promise((resolve, reject) => {
|
|
543
|
+
try {
|
|
544
|
+
let commandPayload = null;
|
|
545
|
+
const handleResponse = (response) => {
|
|
546
|
+
ctx.events.unsubscribe("miniapp-send-transaction" /* MiniAppSendTransaction */);
|
|
547
|
+
resolve({ commandPayload, finalPayload: response });
|
|
548
|
+
};
|
|
549
|
+
ctx.events.subscribe(
|
|
550
|
+
"miniapp-send-transaction" /* MiniAppSendTransaction */,
|
|
551
|
+
handleResponse
|
|
552
|
+
);
|
|
553
|
+
commandPayload = syncCommand(payload);
|
|
554
|
+
} catch (error) {
|
|
555
|
+
reject(error);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// helpers/share/index.ts
|
|
562
|
+
var MAX_FILES = 10;
|
|
563
|
+
var MAX_TOTAL_SIZE_MB = 50;
|
|
564
|
+
var MAX_TOTAL_SIZE_BYTES = MAX_TOTAL_SIZE_MB * 1024 * 1024;
|
|
565
|
+
var processFile = async (file) => {
|
|
566
|
+
const buffer = await file.arrayBuffer();
|
|
567
|
+
const uint8Array = new Uint8Array(buffer);
|
|
568
|
+
let binaryString = "";
|
|
569
|
+
const K_CHUNK_SIZE = 32768;
|
|
570
|
+
for (let i = 0; i < uint8Array.length; i += K_CHUNK_SIZE) {
|
|
571
|
+
const chunk = uint8Array.subarray(
|
|
572
|
+
i,
|
|
573
|
+
Math.min(i + K_CHUNK_SIZE, uint8Array.length)
|
|
574
|
+
);
|
|
575
|
+
binaryString += String.fromCharCode.apply(
|
|
576
|
+
null,
|
|
577
|
+
Array.from(chunk)
|
|
578
|
+
// Convert Uint8Array chunk to number[]
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
const base64Data = btoa(binaryString);
|
|
582
|
+
return {
|
|
583
|
+
name: file.name,
|
|
584
|
+
type: file.type,
|
|
585
|
+
data: base64Data
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
var formatShareInput = async (input) => {
|
|
589
|
+
if (!input.files) {
|
|
590
|
+
return {
|
|
591
|
+
title: input.title,
|
|
592
|
+
text: input.text,
|
|
593
|
+
url: input.url
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
if (!Array.isArray(input.files)) {
|
|
597
|
+
throw new Error('The "files" property must be an array.');
|
|
598
|
+
}
|
|
599
|
+
if (input.files.length === 0) {
|
|
600
|
+
} else {
|
|
601
|
+
if (input.files.length > MAX_FILES) {
|
|
602
|
+
throw new Error(`Cannot share more than ${MAX_FILES} files.`);
|
|
603
|
+
}
|
|
604
|
+
let totalSize = 0;
|
|
605
|
+
for (const file of input.files) {
|
|
606
|
+
if (!(file instanceof File)) {
|
|
607
|
+
throw new Error(
|
|
608
|
+
`Each item in the 'files' array must be a File object. Received: ${typeof file}`
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
totalSize += file.size;
|
|
612
|
+
}
|
|
613
|
+
if (totalSize > MAX_TOTAL_SIZE_BYTES) {
|
|
614
|
+
throw new Error(`Total file size cannot exceed ${MAX_TOTAL_SIZE_MB}MB.`);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
const fileProcessingPromises = input.files.map((file) => processFile(file));
|
|
618
|
+
const processedFiles = await Promise.all(fileProcessingPromises);
|
|
619
|
+
return {
|
|
620
|
+
files: processedFiles,
|
|
621
|
+
title: input.title,
|
|
622
|
+
text: input.text,
|
|
623
|
+
url: input.url
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
// commands/share.ts
|
|
628
|
+
var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
|
|
629
|
+
ShareFilesErrorCodes2["UserRejected"] = "user_rejected";
|
|
630
|
+
ShareFilesErrorCodes2["GenericError"] = "generic_error";
|
|
631
|
+
ShareFilesErrorCodes2["InvalidFileName"] = "invalid_file_name";
|
|
632
|
+
return ShareFilesErrorCodes2;
|
|
633
|
+
})(ShareFilesErrorCodes || {});
|
|
634
|
+
var ShareFilesErrorMessage = {
|
|
635
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
636
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
637
|
+
["invalid_file_name" /* InvalidFileName */]: "Invalid file name. Make sure you include the extension"
|
|
638
|
+
};
|
|
639
|
+
function createShareCommand(ctx) {
|
|
640
|
+
return (payload) => {
|
|
641
|
+
if (typeof window === "undefined" || !isCommandAvailable("share" /* Share */)) {
|
|
642
|
+
console.error(
|
|
643
|
+
"'share' command is unavailable. Check MiniKit.install() or update the app version"
|
|
644
|
+
);
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
if (ctx.state.deviceProperties.deviceOS === "ios" && typeof navigator !== "undefined") {
|
|
648
|
+
sendMiniKitEvent({
|
|
649
|
+
command: "share" /* Share */,
|
|
650
|
+
version: COMMAND_VERSIONS["share" /* Share */],
|
|
651
|
+
payload
|
|
652
|
+
});
|
|
653
|
+
navigator.share(payload);
|
|
654
|
+
} else {
|
|
655
|
+
formatShareInput(payload).then((formattedResult) => {
|
|
656
|
+
sendMiniKitEvent({
|
|
657
|
+
command: "share" /* Share */,
|
|
658
|
+
version: COMMAND_VERSIONS["share" /* Share */],
|
|
659
|
+
payload: formattedResult
|
|
660
|
+
});
|
|
661
|
+
}).catch((error) => {
|
|
662
|
+
console.error("Failed to format share input", error);
|
|
663
|
+
});
|
|
664
|
+
ctx.events.subscribe("miniapp-share" /* MiniAppShare */, (response) => {
|
|
665
|
+
console.log("Share Response", response);
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
return payload;
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
function createShareAsyncCommand(ctx, syncCommand) {
|
|
672
|
+
return async (payload) => {
|
|
673
|
+
return new Promise((resolve, reject) => {
|
|
674
|
+
try {
|
|
675
|
+
let commandPayload = null;
|
|
676
|
+
const handleResponse = (response) => {
|
|
677
|
+
ctx.events.unsubscribe("miniapp-share" /* MiniAppShare */);
|
|
678
|
+
resolve({ commandPayload, finalPayload: response });
|
|
679
|
+
};
|
|
680
|
+
ctx.events.subscribe("miniapp-share" /* MiniAppShare */, handleResponse);
|
|
681
|
+
commandPayload = syncCommand(payload);
|
|
682
|
+
} catch (error) {
|
|
683
|
+
reject(error);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// commands/share-contacts.ts
|
|
690
|
+
var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
|
|
691
|
+
ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
|
|
692
|
+
ShareContactsErrorCodes2["GenericError"] = "generic_error";
|
|
693
|
+
return ShareContactsErrorCodes2;
|
|
694
|
+
})(ShareContactsErrorCodes || {});
|
|
695
|
+
var ShareContactsErrorMessage = {
|
|
696
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
697
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
698
|
+
};
|
|
699
|
+
function createShareContactsCommand(_ctx) {
|
|
700
|
+
return (payload) => {
|
|
701
|
+
if (typeof window === "undefined" || !isCommandAvailable("share-contacts" /* ShareContacts */)) {
|
|
702
|
+
console.error(
|
|
703
|
+
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
704
|
+
);
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
sendMiniKitEvent({
|
|
708
|
+
command: "share-contacts" /* ShareContacts */,
|
|
709
|
+
version: COMMAND_VERSIONS["share-contacts" /* ShareContacts */],
|
|
710
|
+
payload
|
|
711
|
+
});
|
|
712
|
+
return payload;
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
function createShareContactsAsyncCommand(ctx, syncCommand) {
|
|
716
|
+
return async (payload) => {
|
|
717
|
+
return new Promise((resolve, reject) => {
|
|
718
|
+
try {
|
|
719
|
+
let commandPayload = null;
|
|
720
|
+
const handleResponse = (response) => {
|
|
721
|
+
ctx.events.unsubscribe("miniapp-share-contacts" /* MiniAppShareContacts */);
|
|
722
|
+
resolve({ commandPayload, finalPayload: response });
|
|
723
|
+
};
|
|
724
|
+
ctx.events.subscribe(
|
|
725
|
+
"miniapp-share-contacts" /* MiniAppShareContacts */,
|
|
726
|
+
handleResponse
|
|
727
|
+
);
|
|
728
|
+
commandPayload = syncCommand(payload);
|
|
729
|
+
} catch (error) {
|
|
730
|
+
reject(error);
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// commands/sign-message.ts
|
|
87
737
|
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
88
738
|
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
89
739
|
SignMessageErrorCodes2["UserRejected"] = "user_rejected";
|
|
@@ -95,6 +745,44 @@ var SignMessageErrorMessage = {
|
|
|
95
745
|
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
96
746
|
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
97
747
|
};
|
|
748
|
+
function createSignMessageCommand(_ctx) {
|
|
749
|
+
return (payload) => {
|
|
750
|
+
if (typeof window === "undefined" || !isCommandAvailable("sign-message" /* SignMessage */)) {
|
|
751
|
+
console.error(
|
|
752
|
+
"'signMessage' command is unavailable. Check MiniKit.install() or update the app version"
|
|
753
|
+
);
|
|
754
|
+
return null;
|
|
755
|
+
}
|
|
756
|
+
sendMiniKitEvent({
|
|
757
|
+
command: "sign-message" /* SignMessage */,
|
|
758
|
+
version: COMMAND_VERSIONS["sign-message" /* SignMessage */],
|
|
759
|
+
payload
|
|
760
|
+
});
|
|
761
|
+
return payload;
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function createSignMessageAsyncCommand(ctx, syncCommand) {
|
|
765
|
+
return async (payload) => {
|
|
766
|
+
return new Promise((resolve, reject) => {
|
|
767
|
+
try {
|
|
768
|
+
let commandPayload = null;
|
|
769
|
+
const handleResponse = (response) => {
|
|
770
|
+
ctx.events.unsubscribe("miniapp-sign-message" /* MiniAppSignMessage */);
|
|
771
|
+
resolve({ commandPayload, finalPayload: response });
|
|
772
|
+
};
|
|
773
|
+
ctx.events.subscribe(
|
|
774
|
+
"miniapp-sign-message" /* MiniAppSignMessage */,
|
|
775
|
+
handleResponse
|
|
776
|
+
);
|
|
777
|
+
commandPayload = syncCommand(payload);
|
|
778
|
+
} catch (error) {
|
|
779
|
+
reject(error);
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// commands/sign-typed-data.ts
|
|
98
786
|
var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
99
787
|
SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
100
788
|
SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
|
|
@@ -116,158 +804,120 @@ var SignTypedDataErrorMessage = {
|
|
|
116
804
|
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
117
805
|
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
118
806
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
159
|
-
};
|
|
160
|
-
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
161
|
-
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
162
|
-
return GetPermissionsErrorCodes2;
|
|
163
|
-
})(GetPermissionsErrorCodes || {});
|
|
164
|
-
var GetPermissionsErrorMessage = {
|
|
165
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
166
|
-
};
|
|
167
|
-
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
168
|
-
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
169
|
-
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
170
|
-
return SendHapticFeedbackErrorCodes2;
|
|
171
|
-
})(SendHapticFeedbackErrorCodes || {});
|
|
172
|
-
var SendHapticFeedbackErrorMessage = {
|
|
173
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
174
|
-
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
175
|
-
};
|
|
176
|
-
var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
|
|
177
|
-
ShareFilesErrorCodes2["UserRejected"] = "user_rejected";
|
|
178
|
-
ShareFilesErrorCodes2["GenericError"] = "generic_error";
|
|
179
|
-
ShareFilesErrorCodes2["InvalidFileName"] = "invalid_file_name";
|
|
180
|
-
return ShareFilesErrorCodes2;
|
|
181
|
-
})(ShareFilesErrorCodes || {});
|
|
182
|
-
var ShareFilesErrorMessage = {
|
|
183
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
184
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
185
|
-
["invalid_file_name" /* InvalidFileName */]: "Invalid file name. Make sure you include the extension"
|
|
186
|
-
};
|
|
187
|
-
var MicrophoneErrorCodes = /* @__PURE__ */ ((MicrophoneErrorCodes2) => {
|
|
188
|
-
MicrophoneErrorCodes2["MiniAppPermissionNotEnabled"] = "mini_app_permission_not_enabled";
|
|
189
|
-
MicrophoneErrorCodes2["WorldAppPermissionNotEnabled"] = "world_app_permission_not_enabled";
|
|
190
|
-
return MicrophoneErrorCodes2;
|
|
191
|
-
})(MicrophoneErrorCodes || {});
|
|
192
|
-
var MicrophoneErrorMessage = {
|
|
193
|
-
["mini_app_permission_not_enabled" /* MiniAppPermissionNotEnabled */]: "Microphone permission not enabled for your Mini App",
|
|
194
|
-
["world_app_permission_not_enabled" /* WorldAppPermissionNotEnabled */]: "Microphone permission not enabled in World App"
|
|
195
|
-
};
|
|
196
|
-
var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
|
|
197
|
-
ChatErrorCodes2["UserRejected"] = "user_rejected";
|
|
198
|
-
ChatErrorCodes2["SendFailed"] = "send_failed";
|
|
199
|
-
ChatErrorCodes2["GenericError"] = "generic_error";
|
|
200
|
-
return ChatErrorCodes2;
|
|
201
|
-
})(ChatErrorCodes || {});
|
|
202
|
-
var ChatErrorMessage = {
|
|
203
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
204
|
-
["send_failed" /* SendFailed */]: "Failed to send the message.",
|
|
205
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
// types/responses.ts
|
|
209
|
-
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
210
|
-
ResponseEvent2["MiniAppVerifyAction"] = "miniapp-verify-action";
|
|
211
|
-
ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
|
|
212
|
-
ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
|
|
213
|
-
ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
214
|
-
ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
215
|
-
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
216
|
-
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
217
|
-
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
218
|
-
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
219
|
-
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
220
|
-
ResponseEvent2["MiniAppShare"] = "miniapp-share";
|
|
221
|
-
ResponseEvent2["MiniAppMicrophone"] = "miniapp-microphone";
|
|
222
|
-
ResponseEvent2["MiniAppChat"] = "miniapp-chat";
|
|
223
|
-
return ResponseEvent2;
|
|
224
|
-
})(ResponseEvent || {});
|
|
225
|
-
|
|
226
|
-
// types/payment.ts
|
|
227
|
-
var Tokens = /* @__PURE__ */ ((Tokens2) => {
|
|
228
|
-
Tokens2["USDC"] = "USDCE";
|
|
229
|
-
Tokens2["WLD"] = "WLD";
|
|
230
|
-
return Tokens2;
|
|
231
|
-
})(Tokens || {});
|
|
232
|
-
var TokenDecimals = {
|
|
233
|
-
["USDCE" /* USDC */]: 6,
|
|
234
|
-
["WLD" /* WLD */]: 18
|
|
235
|
-
};
|
|
236
|
-
var Network = /* @__PURE__ */ ((Network2) => {
|
|
237
|
-
Network2["Optimism"] = "optimism";
|
|
238
|
-
Network2["WorldChain"] = "worldchain";
|
|
239
|
-
return Network2;
|
|
240
|
-
})(Network || {});
|
|
807
|
+
function createSignTypedDataCommand(_ctx) {
|
|
808
|
+
return (payload) => {
|
|
809
|
+
if (typeof window === "undefined" || !isCommandAvailable("sign-typed-data" /* SignTypedData */)) {
|
|
810
|
+
console.error(
|
|
811
|
+
"'signTypedData' command is unavailable. Check MiniKit.install() or update the app version"
|
|
812
|
+
);
|
|
813
|
+
return null;
|
|
814
|
+
}
|
|
815
|
+
if (!payload.chainId) {
|
|
816
|
+
payload.chainId = 480;
|
|
817
|
+
}
|
|
818
|
+
sendMiniKitEvent({
|
|
819
|
+
command: "sign-typed-data" /* SignTypedData */,
|
|
820
|
+
version: COMMAND_VERSIONS["sign-typed-data" /* SignTypedData */],
|
|
821
|
+
payload
|
|
822
|
+
});
|
|
823
|
+
return payload;
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function createSignTypedDataAsyncCommand(ctx, syncCommand) {
|
|
827
|
+
return async (payload) => {
|
|
828
|
+
return new Promise((resolve, reject) => {
|
|
829
|
+
try {
|
|
830
|
+
let commandPayload = null;
|
|
831
|
+
const handleResponse = (response) => {
|
|
832
|
+
ctx.events.unsubscribe("miniapp-sign-typed-data" /* MiniAppSignTypedData */);
|
|
833
|
+
resolve({ commandPayload, finalPayload: response });
|
|
834
|
+
};
|
|
835
|
+
ctx.events.subscribe(
|
|
836
|
+
"miniapp-sign-typed-data" /* MiniAppSignTypedData */,
|
|
837
|
+
handleResponse
|
|
838
|
+
);
|
|
839
|
+
commandPayload = syncCommand(payload);
|
|
840
|
+
} catch (error) {
|
|
841
|
+
reject(error);
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
};
|
|
845
|
+
}
|
|
241
846
|
|
|
242
|
-
//
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
847
|
+
// commands/verify.ts
|
|
848
|
+
import { VerificationLevel } from "@worldcoin/idkit-core";
|
|
849
|
+
import { encodeAction, generateSignal } from "@worldcoin/idkit-core/hashing";
|
|
850
|
+
import { AppErrorCodes } from "@worldcoin/idkit-core";
|
|
851
|
+
function createVerifyCommand(ctx) {
|
|
852
|
+
return (payload) => {
|
|
853
|
+
if (typeof window === "undefined" || !isCommandAvailable("verify" /* Verify */)) {
|
|
854
|
+
console.error(
|
|
855
|
+
"'verify' command is unavailable. Check MiniKit.install() or update the app version"
|
|
856
|
+
);
|
|
857
|
+
return null;
|
|
858
|
+
}
|
|
859
|
+
if (Array.isArray(payload.verification_level) && payload.verification_level.length === 0) {
|
|
860
|
+
console.error("'verification_level' must not be an empty array");
|
|
861
|
+
return null;
|
|
862
|
+
}
|
|
863
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
864
|
+
const eventPayload = {
|
|
865
|
+
action: encodeAction(payload.action),
|
|
866
|
+
signal: generateSignal(payload.signal).digest,
|
|
867
|
+
verification_level: payload.verification_level || VerificationLevel.Orb,
|
|
868
|
+
timestamp
|
|
869
|
+
};
|
|
870
|
+
ctx.events.setVerifyActionProcessingOptions({
|
|
871
|
+
skip_proof_compression: payload.skip_proof_compression
|
|
872
|
+
});
|
|
873
|
+
sendMiniKitEvent({
|
|
874
|
+
command: "verify" /* Verify */,
|
|
875
|
+
version: COMMAND_VERSIONS["verify" /* Verify */],
|
|
876
|
+
payload: eventPayload
|
|
877
|
+
});
|
|
878
|
+
return eventPayload;
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
function createVerifyAsyncCommand(ctx, syncCommand) {
|
|
882
|
+
let hasInFlightVerifyRequest = false;
|
|
883
|
+
return async (payload) => {
|
|
884
|
+
if (hasInFlightVerifyRequest) {
|
|
885
|
+
return Promise.reject(
|
|
886
|
+
new Error(
|
|
887
|
+
"A verify request is already in flight. Wait for the current request to complete before sending another."
|
|
888
|
+
)
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
return new Promise((resolve, reject) => {
|
|
892
|
+
try {
|
|
893
|
+
hasInFlightVerifyRequest = true;
|
|
894
|
+
let commandPayload = null;
|
|
895
|
+
const handleResponse = (response) => {
|
|
896
|
+
ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
|
|
897
|
+
hasInFlightVerifyRequest = false;
|
|
898
|
+
resolve({ commandPayload, finalPayload: response });
|
|
899
|
+
};
|
|
900
|
+
ctx.events.subscribe(
|
|
901
|
+
"miniapp-verify-action" /* MiniAppVerifyAction */,
|
|
902
|
+
handleResponse
|
|
903
|
+
);
|
|
904
|
+
commandPayload = syncCommand(payload);
|
|
905
|
+
if (commandPayload === null) {
|
|
906
|
+
ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
|
|
907
|
+
hasInFlightVerifyRequest = false;
|
|
908
|
+
reject(
|
|
909
|
+
new Error(
|
|
910
|
+
"Failed to send verify command. Ensure MiniKit is installed and the verify command is available."
|
|
911
|
+
)
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
} catch (error) {
|
|
915
|
+
hasInFlightVerifyRequest = false;
|
|
916
|
+
reject(error);
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
};
|
|
920
|
+
}
|
|
271
921
|
|
|
272
922
|
// helpers/siwe/siwe.ts
|
|
273
923
|
import {
|
|
@@ -517,49 +1167,178 @@ var verifySiweMessageV2 = async (payload, nonce, statement, requestId, userProvi
|
|
|
517
1167
|
if (!validateMessage(siweMessageData, nonce, statement, requestId)) {
|
|
518
1168
|
throw new Error("Validation failed");
|
|
519
1169
|
}
|
|
520
|
-
try {
|
|
521
|
-
const walletContract = getContract({
|
|
522
|
-
address,
|
|
523
|
-
abi: SAFE_CONTRACT_ABI,
|
|
524
|
-
client: userProvider || createPublicClient({ chain: worldchain, transport: http() })
|
|
525
|
-
});
|
|
526
|
-
const hashedMessage = hashMessage(message);
|
|
527
|
-
const res = await walletContract.read.isValidSignature([
|
|
528
|
-
hashedMessage,
|
|
529
|
-
signature
|
|
530
|
-
]);
|
|
531
|
-
return {
|
|
532
|
-
isValid: res === EIP1271_MAGICVALUE,
|
|
533
|
-
siweMessageData
|
|
534
|
-
};
|
|
535
|
-
} catch (error) {
|
|
536
|
-
console.log(error);
|
|
537
|
-
throw new Error("Signature verification failed");
|
|
1170
|
+
try {
|
|
1171
|
+
const walletContract = getContract({
|
|
1172
|
+
address,
|
|
1173
|
+
abi: SAFE_CONTRACT_ABI,
|
|
1174
|
+
client: userProvider || createPublicClient({ chain: worldchain, transport: http() })
|
|
1175
|
+
});
|
|
1176
|
+
const hashedMessage = hashMessage(message);
|
|
1177
|
+
const res = await walletContract.read.isValidSignature([
|
|
1178
|
+
hashedMessage,
|
|
1179
|
+
signature
|
|
1180
|
+
]);
|
|
1181
|
+
return {
|
|
1182
|
+
isValid: res === EIP1271_MAGICVALUE,
|
|
1183
|
+
siweMessageData
|
|
1184
|
+
};
|
|
1185
|
+
} catch (error) {
|
|
1186
|
+
console.log(error);
|
|
1187
|
+
throw new Error("Signature verification failed");
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
// helpers/siwe/validate-wallet-auth-command-input.ts
|
|
1192
|
+
var validateWalletAuthCommandInput = (params) => {
|
|
1193
|
+
if (!params.nonce) {
|
|
1194
|
+
return { valid: false, message: "'nonce' is required" };
|
|
1195
|
+
}
|
|
1196
|
+
if (params.nonce.length < 8) {
|
|
1197
|
+
return { valid: false, message: "'nonce' must be at least 8 characters" };
|
|
1198
|
+
}
|
|
1199
|
+
if (params.statement && params.statement.includes("\n")) {
|
|
1200
|
+
return { valid: false, message: "'statement' must not contain newlines" };
|
|
1201
|
+
}
|
|
1202
|
+
if (params.expirationTime && new Date(params.expirationTime) < /* @__PURE__ */ new Date()) {
|
|
1203
|
+
return { valid: false, message: "'expirationTime' must be in the future" };
|
|
1204
|
+
}
|
|
1205
|
+
if (params.expirationTime && new Date(params.expirationTime) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
|
|
1206
|
+
return { valid: false, message: "'expirationTime' must be within 7 days" };
|
|
1207
|
+
}
|
|
1208
|
+
if (params.notBefore && new Date(params.notBefore) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
|
|
1209
|
+
return { valid: false, message: "'notBefore' must be within 7 days" };
|
|
538
1210
|
}
|
|
1211
|
+
return { valid: true };
|
|
539
1212
|
};
|
|
540
1213
|
|
|
541
|
-
//
|
|
542
|
-
var
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
1214
|
+
// commands/wallet-auth.ts
|
|
1215
|
+
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
1216
|
+
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
1217
|
+
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
1218
|
+
WalletAuthErrorCodes2["GenericError"] = "generic_error";
|
|
1219
|
+
return WalletAuthErrorCodes2;
|
|
1220
|
+
})(WalletAuthErrorCodes || {});
|
|
1221
|
+
var WalletAuthErrorMessage = {
|
|
1222
|
+
["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
|
|
1223
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
1224
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
1225
|
+
};
|
|
1226
|
+
function createWalletAuthCommand(ctx) {
|
|
1227
|
+
return (payload) => {
|
|
1228
|
+
if (typeof window === "undefined" || !isCommandAvailable("wallet-auth" /* WalletAuth */)) {
|
|
1229
|
+
console.error(
|
|
1230
|
+
"'walletAuth' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1231
|
+
);
|
|
1232
|
+
return null;
|
|
1233
|
+
}
|
|
1234
|
+
const validationResult = validateWalletAuthCommandInput(payload);
|
|
1235
|
+
if (!validationResult.valid) {
|
|
1236
|
+
console.error(
|
|
1237
|
+
"Failed to validate wallet auth input:\n\n -->",
|
|
1238
|
+
validationResult.message
|
|
1239
|
+
);
|
|
1240
|
+
return null;
|
|
1241
|
+
}
|
|
1242
|
+
let protocol = null;
|
|
1243
|
+
try {
|
|
1244
|
+
const currentUrl = new URL(window.location.href);
|
|
1245
|
+
protocol = currentUrl.protocol.split(":")[0];
|
|
1246
|
+
} catch (error) {
|
|
1247
|
+
console.error("Failed to get current URL", error);
|
|
1248
|
+
return null;
|
|
1249
|
+
}
|
|
1250
|
+
const siweMessage = generateSiweMessage({
|
|
1251
|
+
scheme: protocol,
|
|
1252
|
+
domain: window.location.host,
|
|
1253
|
+
statement: payload.statement ?? void 0,
|
|
1254
|
+
uri: window.location.href,
|
|
1255
|
+
version: "1",
|
|
1256
|
+
chain_id: 480,
|
|
1257
|
+
nonce: payload.nonce,
|
|
1258
|
+
issued_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1259
|
+
expiration_time: payload.expirationTime?.toISOString() ?? void 0,
|
|
1260
|
+
not_before: payload.notBefore?.toISOString() ?? void 0,
|
|
1261
|
+
request_id: payload.requestId ?? void 0
|
|
1262
|
+
});
|
|
1263
|
+
const walletAuthPayload = { siweMessage };
|
|
1264
|
+
const walletAuthVersion = ctx.state.user.worldAppVersion && ctx.state.user.worldAppVersion > 2087900 ? COMMAND_VERSIONS["wallet-auth" /* WalletAuth */] : 1;
|
|
1265
|
+
sendMiniKitEvent({
|
|
1266
|
+
command: "wallet-auth" /* WalletAuth */,
|
|
1267
|
+
version: walletAuthVersion,
|
|
1268
|
+
payload: walletAuthPayload
|
|
1269
|
+
});
|
|
1270
|
+
return walletAuthPayload;
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
function createWalletAuthAsyncCommand(ctx, syncCommand) {
|
|
1274
|
+
return async (payload) => {
|
|
1275
|
+
return new Promise((resolve, reject) => {
|
|
1276
|
+
try {
|
|
1277
|
+
let commandPayload = null;
|
|
1278
|
+
const handleResponse = async (response) => {
|
|
1279
|
+
ctx.events.unsubscribe("miniapp-wallet-auth" /* MiniAppWalletAuth */);
|
|
1280
|
+
if (response.status === "success") {
|
|
1281
|
+
await ctx.state.updateUserFromWalletAuth(response.address);
|
|
1282
|
+
}
|
|
1283
|
+
resolve({ commandPayload, finalPayload: response });
|
|
1284
|
+
};
|
|
1285
|
+
ctx.events.subscribe(
|
|
1286
|
+
"miniapp-wallet-auth" /* MiniAppWalletAuth */,
|
|
1287
|
+
handleResponse
|
|
1288
|
+
);
|
|
1289
|
+
commandPayload = syncCommand(payload);
|
|
1290
|
+
} catch (error) {
|
|
1291
|
+
reject(error);
|
|
1292
|
+
}
|
|
1293
|
+
});
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
// commands/index.ts
|
|
1298
|
+
function createCommands(ctx) {
|
|
1299
|
+
return {
|
|
1300
|
+
verify: createVerifyCommand(ctx),
|
|
1301
|
+
pay: createPayCommand(ctx),
|
|
1302
|
+
walletAuth: createWalletAuthCommand(ctx),
|
|
1303
|
+
sendTransaction: createSendTransactionCommand(ctx),
|
|
1304
|
+
signMessage: createSignMessageCommand(ctx),
|
|
1305
|
+
signTypedData: createSignTypedDataCommand(ctx),
|
|
1306
|
+
shareContacts: createShareContactsCommand(ctx),
|
|
1307
|
+
requestPermission: createRequestPermissionCommand(ctx),
|
|
1308
|
+
getPermissions: createGetPermissionsCommand(ctx),
|
|
1309
|
+
sendHapticFeedback: createSendHapticFeedbackCommand(ctx),
|
|
1310
|
+
share: createShareCommand(ctx),
|
|
1311
|
+
chat: createChatCommand(ctx)
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
function createAsyncCommands(ctx, commands) {
|
|
1315
|
+
return {
|
|
1316
|
+
verify: createVerifyAsyncCommand(ctx, commands.verify),
|
|
1317
|
+
pay: createPayAsyncCommand(ctx, commands.pay),
|
|
1318
|
+
walletAuth: createWalletAuthAsyncCommand(ctx, commands.walletAuth),
|
|
1319
|
+
sendTransaction: createSendTransactionAsyncCommand(
|
|
1320
|
+
ctx,
|
|
1321
|
+
commands.sendTransaction
|
|
1322
|
+
),
|
|
1323
|
+
signMessage: createSignMessageAsyncCommand(ctx, commands.signMessage),
|
|
1324
|
+
signTypedData: createSignTypedDataAsyncCommand(ctx, commands.signTypedData),
|
|
1325
|
+
shareContacts: createShareContactsAsyncCommand(ctx, commands.shareContacts),
|
|
1326
|
+
requestPermission: createRequestPermissionAsyncCommand(
|
|
1327
|
+
ctx,
|
|
1328
|
+
commands.requestPermission
|
|
1329
|
+
),
|
|
1330
|
+
getPermissions: createGetPermissionsAsyncCommand(
|
|
1331
|
+
ctx,
|
|
1332
|
+
commands.getPermissions
|
|
1333
|
+
),
|
|
1334
|
+
sendHapticFeedback: createSendHapticFeedbackAsyncCommand(
|
|
1335
|
+
ctx,
|
|
1336
|
+
commands.sendHapticFeedback
|
|
1337
|
+
),
|
|
1338
|
+
share: createShareAsyncCommand(ctx, commands.share),
|
|
1339
|
+
chat: createChatAsyncCommand(ctx, commands.chat)
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
563
1342
|
|
|
564
1343
|
// types/init.ts
|
|
565
1344
|
var MiniAppLaunchLocation = /* @__PURE__ */ ((MiniAppLaunchLocation3) => {
|
|
@@ -587,16 +1366,279 @@ var mapWorldAppLaunchLocation = (location) => {
|
|
|
587
1366
|
return WORLD_APP_LAUNCH_LOCATION_MAP[normalizedLocation] ?? null;
|
|
588
1367
|
};
|
|
589
1368
|
|
|
590
|
-
//
|
|
591
|
-
import {
|
|
592
|
-
import {
|
|
1369
|
+
// types/errors.ts
|
|
1370
|
+
import { AppErrorCodes as AppErrorCodes2 } from "@worldcoin/idkit-core";
|
|
1371
|
+
import { AppErrorCodes as AppErrorCodes3 } from "@worldcoin/idkit-core";
|
|
1372
|
+
var VerificationErrorMessage = {
|
|
1373
|
+
[AppErrorCodes2.VerificationRejected]: "You've cancelled the request in World App.",
|
|
1374
|
+
[AppErrorCodes2.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
1375
|
+
[AppErrorCodes2.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
1376
|
+
[AppErrorCodes2.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
1377
|
+
[AppErrorCodes2.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
|
|
1378
|
+
[AppErrorCodes2.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
|
|
1379
|
+
[AppErrorCodes2.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
|
|
1380
|
+
[AppErrorCodes2.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
|
|
1381
|
+
[AppErrorCodes2.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
|
|
1382
|
+
[AppErrorCodes2.GenericError]: "Something unexpected went wrong. Please try again.",
|
|
1383
|
+
[AppErrorCodes2.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
1384
|
+
};
|
|
1385
|
+
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
1386
|
+
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
1387
|
+
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
1388
|
+
MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
|
|
1389
|
+
MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
|
|
1390
|
+
MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
|
|
1391
|
+
return MiniKitInstallErrorCodes2;
|
|
1392
|
+
})(MiniKitInstallErrorCodes || {});
|
|
1393
|
+
var MiniKitInstallErrorMessage = {
|
|
1394
|
+
["unknown" /* Unknown */]: "Failed to install MiniKit.",
|
|
1395
|
+
["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
|
|
1396
|
+
["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
|
|
1397
|
+
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
1398
|
+
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
1399
|
+
};
|
|
593
1400
|
|
|
594
|
-
//
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
1401
|
+
// core/events.ts
|
|
1402
|
+
import { AppErrorCodes as AppErrorCodes4, VerificationLevel as VerificationLevel2 } from "@worldcoin/idkit-core";
|
|
1403
|
+
|
|
1404
|
+
// helpers/proof/index.ts
|
|
1405
|
+
import {
|
|
1406
|
+
createPublicClient as createPublicClient2,
|
|
1407
|
+
decodeAbiParameters,
|
|
1408
|
+
encodeAbiParameters,
|
|
1409
|
+
http as http2
|
|
1410
|
+
} from "viem";
|
|
1411
|
+
import { worldchain as worldchain2 } from "viem/chains";
|
|
1412
|
+
var semaphoreVerifierAddress = "0x79f46b94d134109EbcbbddBAeD0E88790409A0e4";
|
|
1413
|
+
var semaphoreVerifierAbi = [
|
|
1414
|
+
{
|
|
1415
|
+
inputs: [
|
|
1416
|
+
{
|
|
1417
|
+
internalType: "uint256[8]",
|
|
1418
|
+
name: "proof",
|
|
1419
|
+
type: "uint256[8]"
|
|
1420
|
+
}
|
|
1421
|
+
],
|
|
1422
|
+
name: "compressProof",
|
|
1423
|
+
outputs: [
|
|
1424
|
+
{
|
|
1425
|
+
internalType: "uint256[4]",
|
|
1426
|
+
name: "compressed",
|
|
1427
|
+
type: "uint256[4]"
|
|
1428
|
+
}
|
|
1429
|
+
],
|
|
1430
|
+
stateMutability: "view",
|
|
1431
|
+
type: "function"
|
|
1432
|
+
}
|
|
1433
|
+
];
|
|
1434
|
+
var compressAndPadProof = async (proof, rpcUrl) => {
|
|
1435
|
+
try {
|
|
1436
|
+
const publicClient = createPublicClient2({
|
|
1437
|
+
chain: worldchain2,
|
|
1438
|
+
transport: http2(
|
|
1439
|
+
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
1440
|
+
)
|
|
1441
|
+
});
|
|
1442
|
+
const decodedProof = decodeAbiParameters(
|
|
1443
|
+
[{ type: "uint256[8]" }],
|
|
1444
|
+
proof
|
|
1445
|
+
)[0];
|
|
1446
|
+
const compressedProof = await publicClient.readContract({
|
|
1447
|
+
address: semaphoreVerifierAddress,
|
|
1448
|
+
abi: semaphoreVerifierAbi,
|
|
1449
|
+
functionName: "compressProof",
|
|
1450
|
+
args: [decodedProof]
|
|
1451
|
+
});
|
|
1452
|
+
const paddedProof = [...compressedProof, 0n, 0n, 0n, 0n];
|
|
1453
|
+
return encodeAbiParameters([{ type: "uint256[8]" }], [paddedProof]);
|
|
1454
|
+
} catch (e) {
|
|
1455
|
+
return proof;
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1459
|
+
// core/events.ts
|
|
1460
|
+
var EventManager = class {
|
|
1461
|
+
constructor() {
|
|
1462
|
+
this.listeners = {
|
|
1463
|
+
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
1464
|
+
},
|
|
1465
|
+
["miniapp-payment" /* MiniAppPayment */]: () => {
|
|
1466
|
+
},
|
|
1467
|
+
["miniapp-wallet-auth" /* MiniAppWalletAuth */]: () => {
|
|
1468
|
+
},
|
|
1469
|
+
["miniapp-send-transaction" /* MiniAppSendTransaction */]: () => {
|
|
1470
|
+
},
|
|
1471
|
+
["miniapp-sign-message" /* MiniAppSignMessage */]: () => {
|
|
1472
|
+
},
|
|
1473
|
+
["miniapp-sign-typed-data" /* MiniAppSignTypedData */]: () => {
|
|
1474
|
+
},
|
|
1475
|
+
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
1476
|
+
},
|
|
1477
|
+
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
1478
|
+
},
|
|
1479
|
+
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
1480
|
+
},
|
|
1481
|
+
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
1482
|
+
},
|
|
1483
|
+
["miniapp-share" /* MiniAppShare */]: () => {
|
|
1484
|
+
},
|
|
1485
|
+
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
1486
|
+
},
|
|
1487
|
+
["miniapp-chat" /* MiniAppChat */]: () => {
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
this.verifyActionProcessingOptionsQueue = [];
|
|
1491
|
+
}
|
|
1492
|
+
subscribe(event, handler) {
|
|
1493
|
+
this.listeners[event] = handler;
|
|
1494
|
+
}
|
|
1495
|
+
unsubscribe(event) {
|
|
1496
|
+
delete this.listeners[event];
|
|
1497
|
+
}
|
|
1498
|
+
setVerifyActionProcessingOptions(options) {
|
|
1499
|
+
this.verifyActionProcessingOptionsQueue.push({
|
|
1500
|
+
skip_proof_compression: Boolean(options?.skip_proof_compression ?? false)
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
trigger(event, payload) {
|
|
1504
|
+
if (!this.listeners[event]) {
|
|
1505
|
+
console.error(
|
|
1506
|
+
`No handler for event ${event}, payload: ${JSON.stringify(payload)}`
|
|
1507
|
+
);
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
1511
|
+
const handler = this.listeners[event];
|
|
1512
|
+
const processingOptions = this.verifyActionProcessingOptionsQueue.shift() ?? {
|
|
1513
|
+
skip_proof_compression: false
|
|
1514
|
+
};
|
|
1515
|
+
this.processVerifyActionPayload(
|
|
1516
|
+
payload,
|
|
1517
|
+
handler,
|
|
1518
|
+
processingOptions
|
|
1519
|
+
);
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
this.listeners[event](payload);
|
|
1523
|
+
}
|
|
1524
|
+
async processVerifyActionPayload(payload, handler, processingOptions) {
|
|
1525
|
+
if (payload.status === "error" && payload.error_code === "user_rejected") {
|
|
1526
|
+
payload.error_code = AppErrorCodes4.VerificationRejected;
|
|
1527
|
+
}
|
|
1528
|
+
if (payload.status === "success" && !processingOptions.skip_proof_compression) {
|
|
1529
|
+
if ("verifications" in payload) {
|
|
1530
|
+
const orbVerification = payload.verifications.find(
|
|
1531
|
+
(v) => v.verification_level === VerificationLevel2.Orb
|
|
1532
|
+
);
|
|
1533
|
+
if (orbVerification) {
|
|
1534
|
+
orbVerification.proof = await this.compressProofSafely(
|
|
1535
|
+
orbVerification.proof,
|
|
1536
|
+
{
|
|
1537
|
+
mode: "multi",
|
|
1538
|
+
payloadVersion: payload.version,
|
|
1539
|
+
verificationsCount: payload.verifications.length,
|
|
1540
|
+
verificationLevel: orbVerification.verification_level
|
|
1541
|
+
}
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
} else if (payload.verification_level === VerificationLevel2.Orb) {
|
|
1545
|
+
payload.proof = await this.compressProofSafely(
|
|
1546
|
+
payload.proof,
|
|
1547
|
+
{
|
|
1548
|
+
mode: "single",
|
|
1549
|
+
payloadVersion: payload.version,
|
|
1550
|
+
verificationLevel: payload.verification_level
|
|
1551
|
+
}
|
|
1552
|
+
);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
handler(payload);
|
|
1556
|
+
}
|
|
1557
|
+
async compressProofSafely(proof, context) {
|
|
1558
|
+
try {
|
|
1559
|
+
return await compressAndPadProof(proof);
|
|
1560
|
+
} catch (error) {
|
|
1561
|
+
console.error(
|
|
1562
|
+
"Failed to compress verification proof. Delivering payload with uncompressed proof.",
|
|
1563
|
+
{
|
|
1564
|
+
...context,
|
|
1565
|
+
error
|
|
1566
|
+
}
|
|
1567
|
+
);
|
|
1568
|
+
return proof;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
};
|
|
1572
|
+
|
|
1573
|
+
// helpers/usernames/index.ts
|
|
1574
|
+
var getUserProfile = async (address) => {
|
|
1575
|
+
const res = await fetch("https://usernames.worldcoin.org/api/v1/query", {
|
|
1576
|
+
method: "POST",
|
|
1577
|
+
headers: {
|
|
1578
|
+
"Content-Type": "application/json"
|
|
1579
|
+
},
|
|
1580
|
+
body: JSON.stringify({
|
|
1581
|
+
addresses: [address]
|
|
1582
|
+
})
|
|
1583
|
+
});
|
|
1584
|
+
const usernames = await res.json();
|
|
1585
|
+
return usernames?.[0] ?? { username: null, profile_picture_url: null };
|
|
1586
|
+
};
|
|
1587
|
+
|
|
1588
|
+
// core/state.ts
|
|
1589
|
+
var MiniKitState = class {
|
|
1590
|
+
constructor() {
|
|
1591
|
+
this.appId = null;
|
|
1592
|
+
this.user = {};
|
|
1593
|
+
this.deviceProperties = {};
|
|
1594
|
+
this.location = null;
|
|
1595
|
+
this.isReady = false;
|
|
1596
|
+
}
|
|
1597
|
+
initFromWorldApp(worldApp) {
|
|
1598
|
+
if (!worldApp) return;
|
|
1599
|
+
this.user.optedIntoOptionalAnalytics = worldApp.is_optional_analytics;
|
|
1600
|
+
this.user.deviceOS = worldApp.device_os;
|
|
1601
|
+
this.user.worldAppVersion = worldApp.world_app_version;
|
|
1602
|
+
this.deviceProperties.safeAreaInsets = worldApp.safe_area_insets;
|
|
1603
|
+
this.deviceProperties.deviceOS = worldApp.device_os;
|
|
1604
|
+
this.deviceProperties.worldAppVersion = worldApp.world_app_version;
|
|
1605
|
+
this.location = mapWorldAppLaunchLocation(worldApp.location);
|
|
1606
|
+
}
|
|
1607
|
+
async updateUserFromWalletAuth(address) {
|
|
1608
|
+
this.user.walletAddress = address;
|
|
1609
|
+
try {
|
|
1610
|
+
const userProfile = await getUserProfile(address);
|
|
1611
|
+
this.user.username = userProfile.username;
|
|
1612
|
+
this.user.profilePictureUrl = userProfile.profile_picture_url;
|
|
1613
|
+
} catch (error) {
|
|
1614
|
+
console.error("Failed to fetch user profile:", error);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
async getUserByAddress(address) {
|
|
1618
|
+
const walletAddress = address ?? this.user.walletAddress;
|
|
1619
|
+
const userProfile = await getUserProfile(walletAddress);
|
|
1620
|
+
return {
|
|
1621
|
+
walletAddress,
|
|
1622
|
+
username: userProfile.username,
|
|
1623
|
+
profilePictureUrl: userProfile.profile_picture_url
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
async getUserByUsername(username) {
|
|
1627
|
+
const res = await fetch(
|
|
1628
|
+
`https://usernames.worldcoin.org/api/v1/${username}`,
|
|
1629
|
+
{
|
|
1630
|
+
method: "GET",
|
|
1631
|
+
headers: {
|
|
1632
|
+
"Content-Type": "application/json"
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
);
|
|
1636
|
+
const user = await res.json();
|
|
1637
|
+
return {
|
|
1638
|
+
walletAddress: user.address,
|
|
1639
|
+
username: user.username,
|
|
1640
|
+
profilePictureUrl: user.profile_picture_url
|
|
1641
|
+
};
|
|
600
1642
|
}
|
|
601
1643
|
};
|
|
602
1644
|
|
|
@@ -684,334 +1726,65 @@ var setupMicrophone = () => {
|
|
|
684
1726
|
microphoneSetupDone = true;
|
|
685
1727
|
};
|
|
686
1728
|
|
|
687
|
-
//
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
var semaphoreVerifierAbi = [
|
|
697
|
-
{
|
|
698
|
-
inputs: [
|
|
699
|
-
{
|
|
700
|
-
internalType: "uint256[8]",
|
|
701
|
-
name: "proof",
|
|
702
|
-
type: "uint256[8]"
|
|
703
|
-
}
|
|
704
|
-
],
|
|
705
|
-
name: "compressProof",
|
|
706
|
-
outputs: [
|
|
707
|
-
{
|
|
708
|
-
internalType: "uint256[4]",
|
|
709
|
-
name: "compressed",
|
|
710
|
-
type: "uint256[4]"
|
|
711
|
-
}
|
|
712
|
-
],
|
|
713
|
-
stateMutability: "view",
|
|
714
|
-
type: "function"
|
|
715
|
-
}
|
|
716
|
-
];
|
|
717
|
-
var compressAndPadProof = async (proof, rpcUrl) => {
|
|
718
|
-
try {
|
|
719
|
-
const publicClient = createPublicClient2({
|
|
720
|
-
chain: worldchain2,
|
|
721
|
-
transport: http2(
|
|
722
|
-
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
723
|
-
)
|
|
724
|
-
});
|
|
725
|
-
const decodedProof = decodeAbiParameters(
|
|
726
|
-
[{ type: "uint256[8]" }],
|
|
727
|
-
proof
|
|
728
|
-
)[0];
|
|
729
|
-
const compressedProof = await publicClient.readContract({
|
|
730
|
-
address: semaphoreVerifierAddress,
|
|
731
|
-
abi: semaphoreVerifierAbi,
|
|
732
|
-
functionName: "compressProof",
|
|
733
|
-
args: [decodedProof]
|
|
734
|
-
});
|
|
735
|
-
const paddedProof = [...compressedProof, 0n, 0n, 0n, 0n];
|
|
736
|
-
return encodeAbiParameters([{ type: "uint256[8]" }], [paddedProof]);
|
|
737
|
-
} catch (e) {
|
|
738
|
-
return proof;
|
|
739
|
-
}
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
// helpers/share/index.ts
|
|
743
|
-
var MAX_FILES = 10;
|
|
744
|
-
var MAX_TOTAL_SIZE_MB = 50;
|
|
745
|
-
var MAX_TOTAL_SIZE_BYTES = MAX_TOTAL_SIZE_MB * 1024 * 1024;
|
|
746
|
-
var processFile = async (file) => {
|
|
747
|
-
const buffer = await file.arrayBuffer();
|
|
748
|
-
const uint8Array = new Uint8Array(buffer);
|
|
749
|
-
let binaryString = "";
|
|
750
|
-
const K_CHUNK_SIZE = 32768;
|
|
751
|
-
for (let i = 0; i < uint8Array.length; i += K_CHUNK_SIZE) {
|
|
752
|
-
const chunk = uint8Array.subarray(
|
|
753
|
-
i,
|
|
754
|
-
Math.min(i + K_CHUNK_SIZE, uint8Array.length)
|
|
755
|
-
);
|
|
756
|
-
binaryString += String.fromCharCode.apply(
|
|
757
|
-
null,
|
|
758
|
-
Array.from(chunk)
|
|
759
|
-
// Convert Uint8Array chunk to number[]
|
|
760
|
-
);
|
|
761
|
-
}
|
|
762
|
-
const base64Data = btoa(binaryString);
|
|
763
|
-
return {
|
|
764
|
-
name: file.name,
|
|
765
|
-
type: file.type,
|
|
766
|
-
data: base64Data
|
|
767
|
-
};
|
|
768
|
-
};
|
|
769
|
-
var formatShareInput = async (input) => {
|
|
770
|
-
if (!input.files) {
|
|
771
|
-
return {
|
|
772
|
-
title: input.title,
|
|
773
|
-
text: input.text,
|
|
774
|
-
url: input.url
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
if (!Array.isArray(input.files)) {
|
|
778
|
-
throw new Error('The "files" property must be an array.');
|
|
779
|
-
}
|
|
780
|
-
if (input.files.length === 0) {
|
|
781
|
-
} else {
|
|
782
|
-
if (input.files.length > MAX_FILES) {
|
|
783
|
-
throw new Error(`Cannot share more than ${MAX_FILES} files.`);
|
|
784
|
-
}
|
|
785
|
-
let totalSize = 0;
|
|
786
|
-
for (const file of input.files) {
|
|
787
|
-
if (!(file instanceof File)) {
|
|
788
|
-
throw new Error(
|
|
789
|
-
`Each item in the 'files' array must be a File object. Received: ${typeof file}`
|
|
790
|
-
);
|
|
791
|
-
}
|
|
792
|
-
totalSize += file.size;
|
|
793
|
-
}
|
|
794
|
-
if (totalSize > MAX_TOTAL_SIZE_BYTES) {
|
|
795
|
-
throw new Error(`Total file size cannot exceed ${MAX_TOTAL_SIZE_MB}MB.`);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
const fileProcessingPromises = input.files.map((file) => processFile(file));
|
|
799
|
-
const processedFiles = await Promise.all(fileProcessingPromises);
|
|
800
|
-
return {
|
|
801
|
-
files: processedFiles,
|
|
802
|
-
title: input.title,
|
|
803
|
-
text: input.text,
|
|
804
|
-
url: input.url
|
|
805
|
-
};
|
|
806
|
-
};
|
|
807
|
-
|
|
808
|
-
// helpers/siwe/validate-wallet-auth-command-input.ts
|
|
809
|
-
var validateWalletAuthCommandInput = (params) => {
|
|
810
|
-
if (!params.nonce) {
|
|
811
|
-
return { valid: false, message: "'nonce' is required" };
|
|
812
|
-
}
|
|
813
|
-
if (params.nonce.length < 8) {
|
|
814
|
-
return { valid: false, message: "'nonce' must be at least 8 characters" };
|
|
815
|
-
}
|
|
816
|
-
if (params.statement && params.statement.includes("\n")) {
|
|
817
|
-
return { valid: false, message: "'statement' must not contain newlines" };
|
|
818
|
-
}
|
|
819
|
-
if (params.expirationTime && new Date(params.expirationTime) < /* @__PURE__ */ new Date()) {
|
|
820
|
-
return { valid: false, message: "'expirationTime' must be in the future" };
|
|
821
|
-
}
|
|
822
|
-
if (params.expirationTime && new Date(params.expirationTime) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
|
|
823
|
-
return { valid: false, message: "'expirationTime' must be within 7 days" };
|
|
824
|
-
}
|
|
825
|
-
if (params.notBefore && new Date(params.notBefore) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
|
|
826
|
-
return { valid: false, message: "'notBefore' must be within 7 days" };
|
|
827
|
-
}
|
|
828
|
-
return { valid: true };
|
|
829
|
-
};
|
|
830
|
-
|
|
831
|
-
// helpers/transaction/validate-payload.ts
|
|
832
|
-
var isValidHex = (str) => {
|
|
833
|
-
return /^0x[0-9A-Fa-f]+$/.test(str);
|
|
834
|
-
};
|
|
835
|
-
var objectValuesToArrayRecursive = (input) => {
|
|
836
|
-
if (input === null || typeof input !== "object") {
|
|
837
|
-
return input;
|
|
838
|
-
}
|
|
839
|
-
if (Array.isArray(input)) {
|
|
840
|
-
return input.map((item) => objectValuesToArrayRecursive(item));
|
|
841
|
-
}
|
|
842
|
-
const values = Object.values(input);
|
|
843
|
-
return values.map((value) => objectValuesToArrayRecursive(value));
|
|
844
|
-
};
|
|
845
|
-
var processPayload = (payload) => {
|
|
846
|
-
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
847
|
-
return payload;
|
|
1729
|
+
// minikit.ts
|
|
1730
|
+
var MINIKIT_VERSION = 1;
|
|
1731
|
+
var MINIKIT_MINOR_VERSION = 96;
|
|
1732
|
+
var _MiniKit = class _MiniKit {
|
|
1733
|
+
// ============================================================================
|
|
1734
|
+
// Public State Accessors
|
|
1735
|
+
// ============================================================================
|
|
1736
|
+
static get appId() {
|
|
1737
|
+
return this.stateManager.appId;
|
|
848
1738
|
}
|
|
849
|
-
|
|
850
|
-
|
|
1739
|
+
static set appId(value) {
|
|
1740
|
+
this.stateManager.appId = value;
|
|
851
1741
|
}
|
|
852
|
-
|
|
853
|
-
return
|
|
1742
|
+
static get user() {
|
|
1743
|
+
return this.stateManager.user;
|
|
854
1744
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
if ("value" in result && result.value !== void 0) {
|
|
858
|
-
if (typeof result.value !== "string") {
|
|
859
|
-
result.value = String(result.value);
|
|
860
|
-
}
|
|
861
|
-
if (!isValidHex(result.value)) {
|
|
862
|
-
console.error(
|
|
863
|
-
"Transaction value must be a valid hex string",
|
|
864
|
-
result.value
|
|
865
|
-
);
|
|
866
|
-
throw new Error(
|
|
867
|
-
`Transaction value must be a valid hex string: ${result.value}`
|
|
868
|
-
);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
for (const key in result) {
|
|
872
|
-
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
873
|
-
result[key] = processPayload(result[key]);
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
return result;
|
|
1745
|
+
static set user(value) {
|
|
1746
|
+
this.stateManager.user = value;
|
|
877
1747
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
var validateSendTransactionPayload = (payload) => {
|
|
881
|
-
if (payload.formatPayload) {
|
|
882
|
-
const formattedPayload = processPayload(payload);
|
|
883
|
-
formattedPayload.transaction = formattedPayload.transaction.map((tx) => {
|
|
884
|
-
const args = objectValuesToArrayRecursive(tx.args);
|
|
885
|
-
return {
|
|
886
|
-
...tx,
|
|
887
|
-
args
|
|
888
|
-
};
|
|
889
|
-
});
|
|
890
|
-
return formattedPayload;
|
|
1748
|
+
static get deviceProperties() {
|
|
1749
|
+
return this.stateManager.deviceProperties;
|
|
891
1750
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
// helpers/usernames/index.ts
|
|
896
|
-
var getUserProfile = async (address) => {
|
|
897
|
-
const res = await fetch("https://usernames.worldcoin.org/api/v1/query", {
|
|
898
|
-
method: "POST",
|
|
899
|
-
headers: {
|
|
900
|
-
"Content-Type": "application/json"
|
|
901
|
-
},
|
|
902
|
-
body: JSON.stringify({
|
|
903
|
-
addresses: [address]
|
|
904
|
-
})
|
|
905
|
-
});
|
|
906
|
-
const usernames = await res.json();
|
|
907
|
-
return usernames?.[0] ?? { username: null, profile_picture_url: null };
|
|
908
|
-
};
|
|
909
|
-
|
|
910
|
-
// minikit.ts
|
|
911
|
-
var sendMiniKitEvent = (payload) => {
|
|
912
|
-
sendWebviewEvent(payload);
|
|
913
|
-
};
|
|
914
|
-
var _MiniKit = class _MiniKit {
|
|
915
|
-
static sendInit() {
|
|
916
|
-
sendWebviewEvent({
|
|
917
|
-
command: "init",
|
|
918
|
-
payload: {
|
|
919
|
-
version: this.MINIKIT_VERSION,
|
|
920
|
-
minorVersion: this.MINIKIT_MINOR_VERSION
|
|
921
|
-
}
|
|
922
|
-
});
|
|
1751
|
+
static get location() {
|
|
1752
|
+
return this.stateManager.location;
|
|
923
1753
|
}
|
|
1754
|
+
// ============================================================================
|
|
1755
|
+
// Event System
|
|
1756
|
+
// ============================================================================
|
|
924
1757
|
static subscribe(event, handler) {
|
|
925
1758
|
if (event === "miniapp-wallet-auth" /* MiniAppWalletAuth */) {
|
|
926
1759
|
const originalHandler = handler;
|
|
927
1760
|
const wrappedHandler = async (payload) => {
|
|
928
1761
|
if (payload.status === "success") {
|
|
929
|
-
|
|
930
|
-
try {
|
|
931
|
-
const user = await _MiniKit.getUserByAddress(payload.address);
|
|
932
|
-
_MiniKit.user = { ..._MiniKit.user, ...user };
|
|
933
|
-
} catch (error) {
|
|
934
|
-
console.error("Failed to fetch user profile:", error);
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
originalHandler(payload);
|
|
938
|
-
};
|
|
939
|
-
this.listeners[event] = wrappedHandler;
|
|
940
|
-
} else if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
941
|
-
const originalHandler = handler;
|
|
942
|
-
const wrappedHandler = (payload) => {
|
|
943
|
-
if (payload.status === "error" && payload.error_code == "user_rejected") {
|
|
944
|
-
payload.error_code = AppErrorCodes2.VerificationRejected;
|
|
945
|
-
}
|
|
946
|
-
if (payload.status === "success" && payload.verification_level === VerificationLevel.Orb) {
|
|
947
|
-
compressAndPadProof(payload.proof).then(
|
|
948
|
-
(compressedProof) => {
|
|
949
|
-
payload.proof = compressedProof;
|
|
950
|
-
originalHandler(payload);
|
|
951
|
-
}
|
|
952
|
-
);
|
|
953
|
-
} else {
|
|
954
|
-
originalHandler(payload);
|
|
1762
|
+
await this.stateManager.updateUserFromWalletAuth(payload.address);
|
|
955
1763
|
}
|
|
1764
|
+
originalHandler(payload);
|
|
956
1765
|
};
|
|
957
|
-
this.
|
|
1766
|
+
this.eventManager.subscribe(event, wrappedHandler);
|
|
958
1767
|
} else {
|
|
959
|
-
this.
|
|
1768
|
+
this.eventManager.subscribe(event, handler);
|
|
960
1769
|
}
|
|
961
1770
|
}
|
|
962
1771
|
static unsubscribe(event) {
|
|
963
|
-
|
|
1772
|
+
this.eventManager.unsubscribe(event);
|
|
964
1773
|
}
|
|
965
1774
|
static trigger(event, payload) {
|
|
966
|
-
|
|
967
|
-
console.error(
|
|
968
|
-
`No handler for event ${event}, payload: ${JSON.stringify(payload)}`
|
|
969
|
-
);
|
|
970
|
-
return;
|
|
971
|
-
}
|
|
972
|
-
this.listeners[event](payload);
|
|
973
|
-
}
|
|
974
|
-
static async awaitCommand(event, command, executor) {
|
|
975
|
-
return new Promise((resolve) => {
|
|
976
|
-
let commandPayload = null;
|
|
977
|
-
const handleAndUnsubscribe = (payload) => {
|
|
978
|
-
this.unsubscribe(event);
|
|
979
|
-
resolve({ commandPayload, finalPayload: payload });
|
|
980
|
-
};
|
|
981
|
-
this.subscribe(event, handleAndUnsubscribe);
|
|
982
|
-
commandPayload = executor();
|
|
983
|
-
});
|
|
1775
|
+
this.eventManager.trigger(event, payload);
|
|
984
1776
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
console.warn(
|
|
995
|
-
`Command ${minikitCommandName} is not supported by the app. Try updating the app version`
|
|
996
|
-
);
|
|
997
|
-
} else {
|
|
998
|
-
if (commandInput.supported_versions.includes(version)) {
|
|
999
|
-
_MiniKit.isCommandAvailable[minikitCommandName] = true;
|
|
1000
|
-
isCommandValid = true;
|
|
1001
|
-
} else {
|
|
1002
|
-
isCommandValid = true;
|
|
1003
|
-
console.warn(
|
|
1004
|
-
`Command ${minikitCommandName} version ${version} is not supported by the app. Supported versions: ${commandInput.supported_versions.join(", ")}. This is not an error, but it is recommended to update the World App version.`
|
|
1005
|
-
);
|
|
1006
|
-
_MiniKit.isCommandAvailable[minikitCommandName] = isCommandValid;
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
if (!isCommandValid) {
|
|
1010
|
-
allCommandsValid = false;
|
|
1011
|
-
}
|
|
1777
|
+
// ============================================================================
|
|
1778
|
+
// Installation
|
|
1779
|
+
// ============================================================================
|
|
1780
|
+
static sendInit() {
|
|
1781
|
+
sendWebviewEvent({
|
|
1782
|
+
command: "init",
|
|
1783
|
+
payload: {
|
|
1784
|
+
version: MINIKIT_VERSION,
|
|
1785
|
+
minorVersion: MINIKIT_MINOR_VERSION
|
|
1012
1786
|
}
|
|
1013
|
-
);
|
|
1014
|
-
return allCommandsValid;
|
|
1787
|
+
});
|
|
1015
1788
|
}
|
|
1016
1789
|
static install(appId) {
|
|
1017
1790
|
if (typeof window === "undefined" || Boolean(window.MiniKit)) {
|
|
@@ -1024,7 +1797,7 @@ var _MiniKit = class _MiniKit {
|
|
|
1024
1797
|
if (!appId) {
|
|
1025
1798
|
console.warn("App ID not provided during install");
|
|
1026
1799
|
} else {
|
|
1027
|
-
|
|
1800
|
+
this.stateManager.appId = appId;
|
|
1028
1801
|
}
|
|
1029
1802
|
if (!window.WorldApp) {
|
|
1030
1803
|
return {
|
|
@@ -1033,645 +1806,178 @@ var _MiniKit = class _MiniKit {
|
|
|
1033
1806
|
errorMessage: MiniKitInstallErrorMessage["outside_of_worldapp" /* OutsideOfWorldApp */]
|
|
1034
1807
|
};
|
|
1035
1808
|
}
|
|
1036
|
-
|
|
1037
|
-
_MiniKit.user.deviceOS = window.WorldApp.device_os;
|
|
1038
|
-
_MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
|
|
1039
|
-
_MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
|
|
1040
|
-
_MiniKit.deviceProperties.deviceOS = window.WorldApp.device_os;
|
|
1041
|
-
_MiniKit.deviceProperties.worldAppVersion = window.WorldApp.world_app_version;
|
|
1042
|
-
_MiniKit.location = mapWorldAppLaunchLocation(window.WorldApp.location);
|
|
1809
|
+
this.stateManager.initFromWorldApp(window.WorldApp);
|
|
1043
1810
|
try {
|
|
1044
1811
|
window.MiniKit = _MiniKit;
|
|
1045
1812
|
this.sendInit();
|
|
1046
1813
|
} catch (error) {
|
|
1047
1814
|
console.error(
|
|
1048
|
-
MiniKitInstallErrorMessage["unknown" /* Unknown */],
|
|
1049
|
-
error
|
|
1050
|
-
);
|
|
1051
|
-
return {
|
|
1052
|
-
success: false,
|
|
1053
|
-
errorCode: "unknown" /* Unknown */,
|
|
1054
|
-
errorMessage: MiniKitInstallErrorMessage["unknown" /* Unknown */]
|
|
1055
|
-
};
|
|
1056
|
-
}
|
|
1057
|
-
_MiniKit.isReady = true;
|
|
1058
|
-
setupMicrophone();
|
|
1059
|
-
if (!this.commandsValid(window.WorldApp.supported_commands)) {
|
|
1060
|
-
return {
|
|
1061
|
-
success: false,
|
|
1062
|
-
errorCode: "app_out_of_date" /* AppOutOfDate */,
|
|
1063
|
-
errorMessage: MiniKitInstallErrorMessage["app_out_of_date" /* AppOutOfDate */]
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
return { success: true };
|
|
1067
|
-
}
|
|
1068
|
-
static isInstalled(debug) {
|
|
1069
|
-
const isInstalled = _MiniKit.isReady && Boolean(window.MiniKit);
|
|
1070
|
-
if (!isInstalled)
|
|
1071
|
-
console.error(
|
|
1072
|
-
"MiniKit is not installed. Make sure you're running the application inside of World App"
|
|
1073
|
-
);
|
|
1074
|
-
if (debug && isInstalled) console.log("MiniKit is alive!");
|
|
1075
|
-
return isInstalled;
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
_MiniKit.MINIKIT_VERSION = 1;
|
|
1079
|
-
_MiniKit.MINIKIT_MINOR_VERSION = 96;
|
|
1080
|
-
_MiniKit.miniKitCommandVersion = {
|
|
1081
|
-
["verify" /* Verify */]: 1,
|
|
1082
|
-
["pay" /* Pay */]: 1,
|
|
1083
|
-
["wallet-auth" /* WalletAuth */]: 2,
|
|
1084
|
-
["send-transaction" /* SendTransaction */]: 1,
|
|
1085
|
-
["sign-message" /* SignMessage */]: 1,
|
|
1086
|
-
["sign-typed-data" /* SignTypedData */]: 1,
|
|
1087
|
-
["share-contacts" /* ShareContacts */]: 1,
|
|
1088
|
-
["request-permission" /* RequestPermission */]: 1,
|
|
1089
|
-
["get-permissions" /* GetPermissions */]: 1,
|
|
1090
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
1091
|
-
["share" /* Share */]: 1,
|
|
1092
|
-
["chat" /* Chat */]: 1
|
|
1093
|
-
};
|
|
1094
|
-
_MiniKit.isCommandAvailable = {
|
|
1095
|
-
["verify" /* Verify */]: false,
|
|
1096
|
-
["pay" /* Pay */]: false,
|
|
1097
|
-
["wallet-auth" /* WalletAuth */]: false,
|
|
1098
|
-
["send-transaction" /* SendTransaction */]: false,
|
|
1099
|
-
["sign-message" /* SignMessage */]: false,
|
|
1100
|
-
["sign-typed-data" /* SignTypedData */]: false,
|
|
1101
|
-
["share-contacts" /* ShareContacts */]: false,
|
|
1102
|
-
["request-permission" /* RequestPermission */]: false,
|
|
1103
|
-
["get-permissions" /* GetPermissions */]: false,
|
|
1104
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
1105
|
-
["share" /* Share */]: false,
|
|
1106
|
-
["chat" /* Chat */]: false
|
|
1107
|
-
};
|
|
1108
|
-
_MiniKit.listeners = {
|
|
1109
|
-
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
1110
|
-
},
|
|
1111
|
-
["miniapp-payment" /* MiniAppPayment */]: () => {
|
|
1112
|
-
},
|
|
1113
|
-
["miniapp-wallet-auth" /* MiniAppWalletAuth */]: () => {
|
|
1114
|
-
},
|
|
1115
|
-
["miniapp-send-transaction" /* MiniAppSendTransaction */]: () => {
|
|
1116
|
-
},
|
|
1117
|
-
["miniapp-sign-message" /* MiniAppSignMessage */]: () => {
|
|
1118
|
-
},
|
|
1119
|
-
["miniapp-sign-typed-data" /* MiniAppSignTypedData */]: () => {
|
|
1120
|
-
},
|
|
1121
|
-
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
1122
|
-
},
|
|
1123
|
-
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
1124
|
-
},
|
|
1125
|
-
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
1126
|
-
},
|
|
1127
|
-
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
1128
|
-
},
|
|
1129
|
-
["miniapp-share" /* MiniAppShare */]: () => {
|
|
1130
|
-
},
|
|
1131
|
-
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
1132
|
-
},
|
|
1133
|
-
["miniapp-chat" /* MiniAppChat */]: () => {
|
|
1134
|
-
}
|
|
1135
|
-
};
|
|
1136
|
-
_MiniKit.appId = null;
|
|
1137
|
-
_MiniKit.user = {};
|
|
1138
|
-
_MiniKit.deviceProperties = {};
|
|
1139
|
-
_MiniKit.location = null;
|
|
1140
|
-
_MiniKit.isReady = false;
|
|
1141
|
-
_MiniKit.getUserByAddress = async (address) => {
|
|
1142
|
-
const userProfile = await getUserProfile(
|
|
1143
|
-
address ?? _MiniKit.user.walletAddress
|
|
1144
|
-
);
|
|
1145
|
-
return {
|
|
1146
|
-
walletAddress: address ?? _MiniKit.user.walletAddress,
|
|
1147
|
-
username: userProfile.username,
|
|
1148
|
-
profilePictureUrl: userProfile.profile_picture_url
|
|
1149
|
-
};
|
|
1150
|
-
};
|
|
1151
|
-
_MiniKit.getUserByUsername = async (username) => {
|
|
1152
|
-
const res = await fetch(
|
|
1153
|
-
`https://usernames.worldcoin.org/api/v1/${username}`,
|
|
1154
|
-
{
|
|
1155
|
-
method: "GET",
|
|
1156
|
-
headers: {
|
|
1157
|
-
"Content-Type": "application/json"
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
);
|
|
1161
|
-
const user = await res.json();
|
|
1162
|
-
return {
|
|
1163
|
-
walletAddress: user.address,
|
|
1164
|
-
username: user.username,
|
|
1165
|
-
profilePictureUrl: user.profile_picture_url
|
|
1166
|
-
};
|
|
1167
|
-
};
|
|
1168
|
-
// This is a helper function for developers to generate MiniApp URLs
|
|
1169
|
-
_MiniKit.getMiniAppUrl = (appId, path) => {
|
|
1170
|
-
const baseUrl = new URL("https://world.org/mini-app");
|
|
1171
|
-
baseUrl.searchParams.append("app_id", appId);
|
|
1172
|
-
if (path) {
|
|
1173
|
-
const fullPath = path.startsWith("/") ? path : `/${path}`;
|
|
1174
|
-
baseUrl.searchParams.append("path", encodeURIComponent(fullPath));
|
|
1175
|
-
}
|
|
1176
|
-
return baseUrl.toString();
|
|
1177
|
-
};
|
|
1178
|
-
// Opens the profile card for a given username or wallet address
|
|
1179
|
-
_MiniKit.showProfileCard = (username, walletAddress) => {
|
|
1180
|
-
if (!username && !walletAddress) {
|
|
1181
|
-
console.error(
|
|
1182
|
-
"Either username or walletAddress must be provided to show profile card"
|
|
1183
|
-
);
|
|
1184
|
-
return;
|
|
1185
|
-
}
|
|
1186
|
-
if (username) {
|
|
1187
|
-
window.open(
|
|
1188
|
-
`worldapp://profile?username=${encodeURIComponent(username)}`
|
|
1189
|
-
);
|
|
1190
|
-
return;
|
|
1191
|
-
} else {
|
|
1192
|
-
window.open(
|
|
1193
|
-
`worldapp://profile?address=${encodeURIComponent(walletAddress || "")}`
|
|
1194
|
-
);
|
|
1195
|
-
}
|
|
1196
|
-
};
|
|
1197
|
-
// Simply re-exporting the existing function
|
|
1198
|
-
_MiniKit.getUserInfo = _MiniKit.getUserByAddress;
|
|
1199
|
-
_MiniKit.commands = {
|
|
1200
|
-
verify: (payload) => {
|
|
1201
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["verify" /* Verify */]) {
|
|
1202
|
-
console.error(
|
|
1203
|
-
"'verify' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1204
|
-
);
|
|
1205
|
-
return null;
|
|
1206
|
-
}
|
|
1207
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
1208
|
-
const eventPayload = {
|
|
1209
|
-
action: encodeAction(payload.action),
|
|
1210
|
-
signal: generateSignal(payload.signal).digest,
|
|
1211
|
-
verification_level: payload.verification_level || VerificationLevel.Orb,
|
|
1212
|
-
timestamp
|
|
1213
|
-
};
|
|
1214
|
-
sendMiniKitEvent({
|
|
1215
|
-
command: "verify" /* Verify */,
|
|
1216
|
-
version: _MiniKit.miniKitCommandVersion["verify" /* Verify */],
|
|
1217
|
-
payload: eventPayload
|
|
1218
|
-
});
|
|
1219
|
-
return eventPayload;
|
|
1220
|
-
},
|
|
1221
|
-
pay: (payload) => {
|
|
1222
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["pay" /* Pay */]) {
|
|
1223
|
-
console.error(
|
|
1224
|
-
"'pay' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1225
|
-
);
|
|
1226
|
-
return null;
|
|
1227
|
-
}
|
|
1228
|
-
if (!validatePaymentPayload(payload)) {
|
|
1229
|
-
return null;
|
|
1230
|
-
}
|
|
1231
|
-
const eventPayload = {
|
|
1232
|
-
...payload,
|
|
1233
|
-
network: "worldchain" /* WorldChain */
|
|
1234
|
-
};
|
|
1235
|
-
sendMiniKitEvent({
|
|
1236
|
-
command: "pay" /* Pay */,
|
|
1237
|
-
version: _MiniKit.miniKitCommandVersion["pay" /* Pay */],
|
|
1238
|
-
payload: eventPayload
|
|
1239
|
-
});
|
|
1240
|
-
return eventPayload;
|
|
1241
|
-
},
|
|
1242
|
-
walletAuth: (payload) => {
|
|
1243
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["wallet-auth" /* WalletAuth */]) {
|
|
1244
|
-
console.error(
|
|
1245
|
-
"'walletAuth' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1246
|
-
);
|
|
1247
|
-
return null;
|
|
1248
|
-
}
|
|
1249
|
-
const validationResult = validateWalletAuthCommandInput(payload);
|
|
1250
|
-
if (!validationResult.valid) {
|
|
1251
|
-
console.error(
|
|
1252
|
-
"Failed to validate wallet auth input:\n\n -->",
|
|
1253
|
-
validationResult.message
|
|
1254
|
-
);
|
|
1255
|
-
return null;
|
|
1256
|
-
}
|
|
1257
|
-
let protocol = null;
|
|
1258
|
-
try {
|
|
1259
|
-
const currentUrl = new URL(window.location.href);
|
|
1260
|
-
protocol = currentUrl.protocol.split(":")[0];
|
|
1261
|
-
} catch (error) {
|
|
1262
|
-
console.error("Failed to get current URL", error);
|
|
1263
|
-
return null;
|
|
1264
|
-
}
|
|
1265
|
-
const siweMessage = generateSiweMessage({
|
|
1266
|
-
scheme: protocol,
|
|
1267
|
-
domain: window.location.host,
|
|
1268
|
-
statement: payload.statement ?? void 0,
|
|
1269
|
-
uri: window.location.href,
|
|
1270
|
-
version: "1",
|
|
1271
|
-
chain_id: 480,
|
|
1272
|
-
nonce: payload.nonce,
|
|
1273
|
-
issued_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1274
|
-
expiration_time: payload.expirationTime?.toISOString() ?? void 0,
|
|
1275
|
-
not_before: payload.notBefore?.toISOString() ?? void 0,
|
|
1276
|
-
request_id: payload.requestId ?? void 0
|
|
1277
|
-
});
|
|
1278
|
-
const walletAuthPayload = { siweMessage };
|
|
1279
|
-
const walletAuthVersion = _MiniKit.user.worldAppVersion && _MiniKit.user.worldAppVersion > 2087900 ? _MiniKit.miniKitCommandVersion["wallet-auth" /* WalletAuth */] : 1;
|
|
1280
|
-
sendMiniKitEvent({
|
|
1281
|
-
command: "wallet-auth" /* WalletAuth */,
|
|
1282
|
-
version: walletAuthVersion,
|
|
1283
|
-
payload: walletAuthPayload
|
|
1284
|
-
});
|
|
1285
|
-
return walletAuthPayload;
|
|
1286
|
-
},
|
|
1287
|
-
sendTransaction: (payload) => {
|
|
1288
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-transaction" /* SendTransaction */]) {
|
|
1289
|
-
console.error(
|
|
1290
|
-
"'sendTransaction' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1291
|
-
);
|
|
1292
|
-
return null;
|
|
1293
|
-
}
|
|
1294
|
-
payload.formatPayload = payload.formatPayload !== false;
|
|
1295
|
-
const validatedPayload = validateSendTransactionPayload(payload);
|
|
1296
|
-
sendMiniKitEvent({
|
|
1297
|
-
command: "send-transaction" /* SendTransaction */,
|
|
1298
|
-
version: _MiniKit.miniKitCommandVersion["send-transaction" /* SendTransaction */],
|
|
1299
|
-
payload: validatedPayload
|
|
1300
|
-
});
|
|
1301
|
-
return validatedPayload;
|
|
1302
|
-
},
|
|
1303
|
-
signMessage: (payload) => {
|
|
1304
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-message" /* SignMessage */]) {
|
|
1305
|
-
console.error(
|
|
1306
|
-
"'signMessage' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1307
|
-
);
|
|
1308
|
-
return null;
|
|
1309
|
-
}
|
|
1310
|
-
sendMiniKitEvent({
|
|
1311
|
-
command: "sign-message" /* SignMessage */,
|
|
1312
|
-
version: _MiniKit.miniKitCommandVersion["sign-message" /* SignMessage */],
|
|
1313
|
-
payload
|
|
1314
|
-
});
|
|
1315
|
-
return payload;
|
|
1316
|
-
},
|
|
1317
|
-
signTypedData: (payload) => {
|
|
1318
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-typed-data" /* SignTypedData */]) {
|
|
1319
|
-
console.error(
|
|
1320
|
-
"'signTypedData' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1321
|
-
);
|
|
1322
|
-
return null;
|
|
1323
|
-
}
|
|
1324
|
-
if (!payload.chainId) {
|
|
1325
|
-
payload.chainId = 480;
|
|
1326
|
-
}
|
|
1327
|
-
sendMiniKitEvent({
|
|
1328
|
-
command: "sign-typed-data" /* SignTypedData */,
|
|
1329
|
-
version: _MiniKit.miniKitCommandVersion["sign-typed-data" /* SignTypedData */],
|
|
1330
|
-
payload
|
|
1331
|
-
});
|
|
1332
|
-
return payload;
|
|
1333
|
-
},
|
|
1334
|
-
shareContacts: (payload) => {
|
|
1335
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share-contacts" /* ShareContacts */]) {
|
|
1336
|
-
console.error(
|
|
1337
|
-
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1338
|
-
);
|
|
1339
|
-
return null;
|
|
1340
|
-
}
|
|
1341
|
-
sendMiniKitEvent({
|
|
1342
|
-
command: "share-contacts" /* ShareContacts */,
|
|
1343
|
-
version: _MiniKit.miniKitCommandVersion["share-contacts" /* ShareContacts */],
|
|
1344
|
-
payload
|
|
1345
|
-
});
|
|
1346
|
-
return payload;
|
|
1347
|
-
},
|
|
1348
|
-
requestPermission: (payload) => {
|
|
1349
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["request-permission" /* RequestPermission */]) {
|
|
1350
|
-
console.error(
|
|
1351
|
-
"'requestPermission' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1815
|
+
MiniKitInstallErrorMessage["unknown" /* Unknown */],
|
|
1816
|
+
error
|
|
1352
1817
|
);
|
|
1353
|
-
return
|
|
1818
|
+
return {
|
|
1819
|
+
success: false,
|
|
1820
|
+
errorCode: "unknown" /* Unknown */,
|
|
1821
|
+
errorMessage: MiniKitInstallErrorMessage["unknown" /* Unknown */]
|
|
1822
|
+
};
|
|
1354
1823
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["get-permissions" /* GetPermissions */]) {
|
|
1364
|
-
console.error(
|
|
1365
|
-
"'getPermissions' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1366
|
-
);
|
|
1367
|
-
return null;
|
|
1824
|
+
this.stateManager.isReady = true;
|
|
1825
|
+
setupMicrophone();
|
|
1826
|
+
if (!validateCommands(window.WorldApp.supported_commands)) {
|
|
1827
|
+
return {
|
|
1828
|
+
success: false,
|
|
1829
|
+
errorCode: "app_out_of_date" /* AppOutOfDate */,
|
|
1830
|
+
errorMessage: MiniKitInstallErrorMessage["app_out_of_date" /* AppOutOfDate */]
|
|
1831
|
+
};
|
|
1368
1832
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
return {
|
|
1375
|
-
status: "sent"
|
|
1376
|
-
};
|
|
1377
|
-
},
|
|
1378
|
-
sendHapticFeedback: (payload) => {
|
|
1379
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-haptic-feedback" /* SendHapticFeedback */]) {
|
|
1833
|
+
return { success: true };
|
|
1834
|
+
}
|
|
1835
|
+
static isInstalled(debug) {
|
|
1836
|
+
const isInstalled = this.stateManager.isReady && Boolean(window.MiniKit);
|
|
1837
|
+
if (!isInstalled) {
|
|
1380
1838
|
console.error(
|
|
1381
|
-
"
|
|
1839
|
+
"MiniKit is not installed. Make sure you're running the application inside of World App"
|
|
1382
1840
|
);
|
|
1383
|
-
return null;
|
|
1384
1841
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
version: _MiniKit.miniKitCommandVersion["send-haptic-feedback" /* SendHapticFeedback */],
|
|
1388
|
-
payload
|
|
1389
|
-
});
|
|
1390
|
-
return payload;
|
|
1391
|
-
},
|
|
1392
|
-
// We return share input here because the payload is formatted asynchronously
|
|
1393
|
-
share: (payload) => {
|
|
1394
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share" /* Share */]) {
|
|
1395
|
-
console.error(
|
|
1396
|
-
"'share' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1397
|
-
);
|
|
1398
|
-
return null;
|
|
1842
|
+
if (debug && isInstalled) {
|
|
1843
|
+
console.log("MiniKit is alive!");
|
|
1399
1844
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
}).catch((error) => {
|
|
1415
|
-
console.error("Failed to format share input", error);
|
|
1416
|
-
});
|
|
1417
|
-
_MiniKit.subscribe("miniapp-share" /* MiniAppShare */, (payload2) => {
|
|
1418
|
-
console.log("Share Response", payload2);
|
|
1419
|
-
});
|
|
1845
|
+
return isInstalled;
|
|
1846
|
+
}
|
|
1847
|
+
// ============================================================================
|
|
1848
|
+
// Commands
|
|
1849
|
+
// ============================================================================
|
|
1850
|
+
static getContext() {
|
|
1851
|
+
return {
|
|
1852
|
+
events: this.eventManager,
|
|
1853
|
+
state: this.stateManager
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
static get commands() {
|
|
1857
|
+
if (!this.commandsInstance) {
|
|
1858
|
+
this.commandsInstance = createCommands(this.getContext());
|
|
1420
1859
|
}
|
|
1421
|
-
return
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
if (
|
|
1425
|
-
|
|
1426
|
-
|
|
1860
|
+
return this.commandsInstance;
|
|
1861
|
+
}
|
|
1862
|
+
static get commandsAsync() {
|
|
1863
|
+
if (!this.asyncCommandsInstance) {
|
|
1864
|
+
this.asyncCommandsInstance = createAsyncCommands(
|
|
1865
|
+
this.getContext(),
|
|
1866
|
+
this.commands
|
|
1427
1867
|
);
|
|
1428
|
-
return null;
|
|
1429
|
-
}
|
|
1430
|
-
if (payload.message.length === 0) {
|
|
1431
|
-
console.error("'chat' command requires a non-empty message");
|
|
1432
|
-
return null;
|
|
1433
1868
|
}
|
|
1434
|
-
|
|
1435
|
-
command: "chat" /* Chat */,
|
|
1436
|
-
version: _MiniKit.miniKitCommandVersion["chat" /* Chat */],
|
|
1437
|
-
payload
|
|
1438
|
-
});
|
|
1439
|
-
return payload;
|
|
1869
|
+
return this.asyncCommandsInstance;
|
|
1440
1870
|
}
|
|
1441
1871
|
};
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
_MiniKit.
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
resolve(response);
|
|
1481
|
-
} catch (error) {
|
|
1482
|
-
reject(error);
|
|
1483
|
-
}
|
|
1484
|
-
});
|
|
1485
|
-
},
|
|
1486
|
-
walletAuth: async (payload) => {
|
|
1487
|
-
return new Promise(async (resolve, reject) => {
|
|
1488
|
-
try {
|
|
1489
|
-
const response = await _MiniKit.awaitCommand(
|
|
1490
|
-
"miniapp-wallet-auth" /* MiniAppWalletAuth */,
|
|
1491
|
-
"wallet-auth" /* WalletAuth */,
|
|
1492
|
-
() => _MiniKit.commands.walletAuth(payload)
|
|
1493
|
-
);
|
|
1494
|
-
return resolve(response);
|
|
1495
|
-
} catch (error) {
|
|
1496
|
-
reject(error);
|
|
1497
|
-
}
|
|
1498
|
-
});
|
|
1499
|
-
},
|
|
1500
|
-
sendTransaction: async (payload) => {
|
|
1501
|
-
return new Promise(async (resolve, reject) => {
|
|
1502
|
-
try {
|
|
1503
|
-
const response = await _MiniKit.awaitCommand(
|
|
1504
|
-
"miniapp-send-transaction" /* MiniAppSendTransaction */,
|
|
1505
|
-
"send-transaction" /* SendTransaction */,
|
|
1506
|
-
() => _MiniKit.commands.sendTransaction(payload)
|
|
1507
|
-
);
|
|
1508
|
-
return resolve(response);
|
|
1509
|
-
} catch (error) {
|
|
1510
|
-
reject(error);
|
|
1511
|
-
}
|
|
1512
|
-
});
|
|
1513
|
-
},
|
|
1514
|
-
signMessage: async (payload) => {
|
|
1515
|
-
return new Promise(async (resolve, reject) => {
|
|
1516
|
-
try {
|
|
1517
|
-
const response = await _MiniKit.awaitCommand(
|
|
1518
|
-
"miniapp-sign-message" /* MiniAppSignMessage */,
|
|
1519
|
-
"sign-message" /* SignMessage */,
|
|
1520
|
-
() => _MiniKit.commands.signMessage(payload)
|
|
1521
|
-
);
|
|
1522
|
-
return resolve(response);
|
|
1523
|
-
} catch (error) {
|
|
1524
|
-
reject(error);
|
|
1525
|
-
}
|
|
1526
|
-
});
|
|
1527
|
-
},
|
|
1528
|
-
signTypedData: async (payload) => {
|
|
1529
|
-
return new Promise(async (resolve, reject) => {
|
|
1530
|
-
try {
|
|
1531
|
-
const response = await _MiniKit.awaitCommand(
|
|
1532
|
-
"miniapp-sign-typed-data" /* MiniAppSignTypedData */,
|
|
1533
|
-
"sign-typed-data" /* SignTypedData */,
|
|
1534
|
-
() => _MiniKit.commands.signTypedData(payload)
|
|
1535
|
-
);
|
|
1536
|
-
return resolve(response);
|
|
1537
|
-
} catch (error) {
|
|
1538
|
-
reject(error);
|
|
1539
|
-
}
|
|
1540
|
-
});
|
|
1541
|
-
},
|
|
1542
|
-
shareContacts: async (payload) => {
|
|
1543
|
-
return new Promise(async (resolve, reject) => {
|
|
1544
|
-
try {
|
|
1545
|
-
const response = await _MiniKit.awaitCommand(
|
|
1546
|
-
"miniapp-share-contacts" /* MiniAppShareContacts */,
|
|
1547
|
-
"share-contacts" /* ShareContacts */,
|
|
1548
|
-
() => _MiniKit.commands.shareContacts(payload)
|
|
1549
|
-
);
|
|
1550
|
-
return resolve(response);
|
|
1551
|
-
} catch (error) {
|
|
1552
|
-
reject(error);
|
|
1553
|
-
}
|
|
1554
|
-
});
|
|
1555
|
-
},
|
|
1556
|
-
requestPermission: async (payload) => {
|
|
1557
|
-
return new Promise(async (resolve, reject) => {
|
|
1558
|
-
try {
|
|
1559
|
-
const response = await _MiniKit.awaitCommand(
|
|
1560
|
-
"miniapp-request-permission" /* MiniAppRequestPermission */,
|
|
1561
|
-
"request-permission" /* RequestPermission */,
|
|
1562
|
-
() => _MiniKit.commands.requestPermission(payload)
|
|
1563
|
-
);
|
|
1564
|
-
resolve(response);
|
|
1565
|
-
} catch (error) {
|
|
1566
|
-
reject(error);
|
|
1567
|
-
}
|
|
1568
|
-
});
|
|
1569
|
-
},
|
|
1570
|
-
getPermissions: async () => {
|
|
1571
|
-
return new Promise(async (resolve, reject) => {
|
|
1572
|
-
try {
|
|
1573
|
-
const response = await _MiniKit.awaitCommand(
|
|
1574
|
-
"miniapp-get-permissions" /* MiniAppGetPermissions */,
|
|
1575
|
-
"get-permissions" /* GetPermissions */,
|
|
1576
|
-
() => _MiniKit.commands.getPermissions()
|
|
1577
|
-
);
|
|
1578
|
-
resolve(response);
|
|
1579
|
-
} catch (error) {
|
|
1580
|
-
reject(error);
|
|
1581
|
-
}
|
|
1582
|
-
});
|
|
1583
|
-
},
|
|
1584
|
-
sendHapticFeedback: async (payload) => {
|
|
1585
|
-
return new Promise(async (resolve, reject) => {
|
|
1586
|
-
try {
|
|
1587
|
-
const response = await _MiniKit.awaitCommand(
|
|
1588
|
-
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
1589
|
-
"send-haptic-feedback" /* SendHapticFeedback */,
|
|
1590
|
-
() => _MiniKit.commands.sendHapticFeedback(payload)
|
|
1591
|
-
);
|
|
1592
|
-
resolve(response);
|
|
1593
|
-
} catch (error) {
|
|
1594
|
-
reject(error);
|
|
1595
|
-
}
|
|
1596
|
-
});
|
|
1597
|
-
},
|
|
1598
|
-
share: async (payload) => {
|
|
1599
|
-
return new Promise(async (resolve, reject) => {
|
|
1600
|
-
try {
|
|
1601
|
-
const response = await _MiniKit.awaitCommand(
|
|
1602
|
-
"miniapp-share" /* MiniAppShare */,
|
|
1603
|
-
"share" /* Share */,
|
|
1604
|
-
() => _MiniKit.commands.share(payload)
|
|
1605
|
-
);
|
|
1606
|
-
resolve({
|
|
1607
|
-
commandPayload: response.commandPayload,
|
|
1608
|
-
finalPayload: response.finalPayload
|
|
1609
|
-
});
|
|
1610
|
-
} catch (error) {
|
|
1611
|
-
reject(error);
|
|
1612
|
-
}
|
|
1613
|
-
});
|
|
1614
|
-
},
|
|
1615
|
-
chat: async (payload) => {
|
|
1616
|
-
return new Promise(async (resolve, reject) => {
|
|
1617
|
-
try {
|
|
1618
|
-
const response = await _MiniKit.awaitCommand(
|
|
1619
|
-
"miniapp-chat" /* MiniAppChat */,
|
|
1620
|
-
"chat" /* Chat */,
|
|
1621
|
-
() => _MiniKit.commands.chat(payload)
|
|
1622
|
-
);
|
|
1623
|
-
resolve({
|
|
1624
|
-
commandPayload: response.commandPayload,
|
|
1625
|
-
finalPayload: response.finalPayload
|
|
1626
|
-
});
|
|
1627
|
-
} catch (error) {
|
|
1628
|
-
reject(error);
|
|
1629
|
-
}
|
|
1630
|
-
});
|
|
1872
|
+
_MiniKit.eventManager = new EventManager();
|
|
1873
|
+
_MiniKit.stateManager = new MiniKitState();
|
|
1874
|
+
_MiniKit.commandsInstance = null;
|
|
1875
|
+
_MiniKit.asyncCommandsInstance = null;
|
|
1876
|
+
// ============================================================================
|
|
1877
|
+
// Utility Methods
|
|
1878
|
+
// ============================================================================
|
|
1879
|
+
_MiniKit.getUserByAddress = async (address) => {
|
|
1880
|
+
return _MiniKit.stateManager.getUserByAddress(address);
|
|
1881
|
+
};
|
|
1882
|
+
_MiniKit.getUserByUsername = async (username) => {
|
|
1883
|
+
return _MiniKit.stateManager.getUserByUsername(username);
|
|
1884
|
+
};
|
|
1885
|
+
_MiniKit.getUserInfo = _MiniKit.getUserByAddress;
|
|
1886
|
+
_MiniKit.getMiniAppUrl = (appId, path) => {
|
|
1887
|
+
const baseUrl = new URL("https://world.org/mini-app");
|
|
1888
|
+
baseUrl.searchParams.append("app_id", appId);
|
|
1889
|
+
if (path) {
|
|
1890
|
+
const fullPath = path.startsWith("/") ? path : `/${path}`;
|
|
1891
|
+
baseUrl.searchParams.append("path", encodeURIComponent(fullPath));
|
|
1892
|
+
}
|
|
1893
|
+
return baseUrl.toString();
|
|
1894
|
+
};
|
|
1895
|
+
_MiniKit.showProfileCard = (username, walletAddress) => {
|
|
1896
|
+
if (!username && !walletAddress) {
|
|
1897
|
+
console.error(
|
|
1898
|
+
"Either username or walletAddress must be provided to show profile card"
|
|
1899
|
+
);
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
if (username) {
|
|
1903
|
+
window.open(
|
|
1904
|
+
`worldapp://profile?username=${encodeURIComponent(username)}`
|
|
1905
|
+
);
|
|
1906
|
+
} else {
|
|
1907
|
+
window.open(
|
|
1908
|
+
`worldapp://profile?address=${encodeURIComponent(walletAddress || "")}`
|
|
1909
|
+
);
|
|
1631
1910
|
}
|
|
1632
1911
|
};
|
|
1633
1912
|
var MiniKit = _MiniKit;
|
|
1634
1913
|
|
|
1635
1914
|
export {
|
|
1636
|
-
|
|
1915
|
+
Command,
|
|
1916
|
+
ResponseEvent,
|
|
1917
|
+
COMMAND_VERSIONS,
|
|
1918
|
+
isCommandAvailable,
|
|
1919
|
+
setCommandAvailable,
|
|
1920
|
+
validateCommands,
|
|
1921
|
+
sendMiniKitEvent,
|
|
1922
|
+
ChatErrorCodes,
|
|
1923
|
+
ChatErrorMessage,
|
|
1924
|
+
createChatCommand,
|
|
1925
|
+
createChatAsyncCommand,
|
|
1926
|
+
GetPermissionsErrorCodes,
|
|
1927
|
+
GetPermissionsErrorMessage,
|
|
1928
|
+
Permission,
|
|
1929
|
+
createGetPermissionsCommand,
|
|
1930
|
+
createGetPermissionsAsyncCommand,
|
|
1931
|
+
Tokens,
|
|
1932
|
+
TokenDecimals,
|
|
1933
|
+
Network,
|
|
1934
|
+
tokenToDecimals,
|
|
1637
1935
|
PaymentErrorCodes,
|
|
1638
1936
|
PaymentErrorMessage,
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
WalletAuthErrorMessage,
|
|
1642
|
-
SendTransactionErrorCodes,
|
|
1643
|
-
SendTransactionErrorMessage,
|
|
1644
|
-
SignMessageErrorCodes,
|
|
1645
|
-
SignMessageErrorMessage,
|
|
1646
|
-
SignTypedDataErrorCodes,
|
|
1647
|
-
SignTypedDataErrorMessage,
|
|
1648
|
-
MiniKitInstallErrorCodes,
|
|
1649
|
-
MiniKitInstallErrorMessage,
|
|
1650
|
-
ShareContactsErrorCodes,
|
|
1651
|
-
ShareContactsErrorMessage,
|
|
1937
|
+
createPayCommand,
|
|
1938
|
+
createPayAsyncCommand,
|
|
1652
1939
|
RequestPermissionErrorCodes,
|
|
1653
1940
|
RequestPermissionErrorMessage,
|
|
1654
|
-
|
|
1655
|
-
|
|
1941
|
+
createRequestPermissionCommand,
|
|
1942
|
+
createRequestPermissionAsyncCommand,
|
|
1656
1943
|
SendHapticFeedbackErrorCodes,
|
|
1657
1944
|
SendHapticFeedbackErrorMessage,
|
|
1945
|
+
createSendHapticFeedbackCommand,
|
|
1946
|
+
createSendHapticFeedbackAsyncCommand,
|
|
1947
|
+
SendTransactionErrorCodes,
|
|
1948
|
+
SendTransactionErrorMessage,
|
|
1949
|
+
createSendTransactionCommand,
|
|
1950
|
+
createSendTransactionAsyncCommand,
|
|
1658
1951
|
ShareFilesErrorCodes,
|
|
1659
1952
|
ShareFilesErrorMessage,
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1953
|
+
createShareCommand,
|
|
1954
|
+
createShareAsyncCommand,
|
|
1955
|
+
ShareContactsErrorCodes,
|
|
1956
|
+
ShareContactsErrorMessage,
|
|
1957
|
+
createShareContactsCommand,
|
|
1958
|
+
createShareContactsAsyncCommand,
|
|
1959
|
+
SignMessageErrorCodes,
|
|
1960
|
+
SignMessageErrorMessage,
|
|
1961
|
+
createSignMessageCommand,
|
|
1962
|
+
createSignMessageAsyncCommand,
|
|
1963
|
+
SignTypedDataErrorCodes,
|
|
1964
|
+
SignTypedDataErrorMessage,
|
|
1965
|
+
createSignTypedDataCommand,
|
|
1966
|
+
createSignTypedDataAsyncCommand,
|
|
1967
|
+
createVerifyCommand,
|
|
1968
|
+
createVerifyAsyncCommand,
|
|
1969
|
+
AppErrorCodes,
|
|
1670
1970
|
parseSiweMessage,
|
|
1671
1971
|
verifySiweMessage,
|
|
1672
|
-
|
|
1673
|
-
|
|
1972
|
+
WalletAuthErrorCodes,
|
|
1973
|
+
WalletAuthErrorMessage,
|
|
1974
|
+
createWalletAuthCommand,
|
|
1975
|
+
createWalletAuthAsyncCommand,
|
|
1976
|
+
createCommands,
|
|
1977
|
+
createAsyncCommands,
|
|
1674
1978
|
MiniAppLaunchLocation,
|
|
1675
1979
|
mapWorldAppLaunchLocation,
|
|
1980
|
+
MiniKitInstallErrorCodes,
|
|
1981
|
+
MiniKitInstallErrorMessage,
|
|
1676
1982
|
MiniKit
|
|
1677
1983
|
};
|