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