@worldcoin/minikit-js 1.6.1 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs +147 -29
- package/build/index.d.cts +76 -16
- package/build/index.d.ts +76 -16
- package/build/index.js +143 -29
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -21,6 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var core_exports = {};
|
|
22
22
|
__export(core_exports, {
|
|
23
23
|
Command: () => Command,
|
|
24
|
+
GetPermissionsErrorCodes: () => GetPermissionsErrorCodes,
|
|
25
|
+
GetPermissionsErrorMessage: () => GetPermissionsErrorMessage,
|
|
24
26
|
MiniKit: () => MiniKit,
|
|
25
27
|
MiniKitInstallErrorCodes: () => MiniKitInstallErrorCodes,
|
|
26
28
|
MiniKitInstallErrorMessage: () => MiniKitInstallErrorMessage,
|
|
@@ -33,6 +35,8 @@ __export(core_exports, {
|
|
|
33
35
|
RequestPermissionErrorMessage: () => RequestPermissionErrorMessage,
|
|
34
36
|
ResponseEvent: () => ResponseEvent,
|
|
35
37
|
SAFE_CONTRACT_ABI: () => SAFE_CONTRACT_ABI,
|
|
38
|
+
SendHapticFeedbackErrorCodes: () => SendHapticFeedbackErrorCodes,
|
|
39
|
+
SendHapticFeedbackErrorMessage: () => SendHapticFeedbackErrorMessage,
|
|
36
40
|
SendTransactionErrorCodes: () => SendTransactionErrorCodes,
|
|
37
41
|
SendTransactionErrorMessage: () => SendTransactionErrorMessage,
|
|
38
42
|
ShareContactsErrorCodes: () => ShareContactsErrorCodes,
|
|
@@ -319,30 +323,44 @@ var validateWalletAuthCommandInput = (params) => {
|
|
|
319
323
|
var isValidHex = (str) => {
|
|
320
324
|
return /^0x[0-9A-Fa-f]+$/.test(str);
|
|
321
325
|
};
|
|
322
|
-
var
|
|
323
|
-
if (typeof payload === "string"
|
|
326
|
+
var processPayload = (payload) => {
|
|
327
|
+
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
328
|
+
return payload;
|
|
329
|
+
}
|
|
330
|
+
if (typeof payload === "number") {
|
|
331
|
+
return String(payload);
|
|
332
|
+
}
|
|
324
333
|
if (Array.isArray(payload)) {
|
|
325
|
-
|
|
326
|
-
return { isValid };
|
|
334
|
+
return payload.map((value) => processPayload(value));
|
|
327
335
|
}
|
|
328
|
-
if (typeof payload === "object"
|
|
329
|
-
|
|
330
|
-
|
|
336
|
+
if (typeof payload === "object") {
|
|
337
|
+
const result = { ...payload };
|
|
338
|
+
if ("value" in result && result.value !== void 0) {
|
|
339
|
+
if (typeof result.value !== "string") {
|
|
340
|
+
result.value = String(result.value);
|
|
341
|
+
}
|
|
342
|
+
if (!isValidHex(result.value)) {
|
|
331
343
|
console.error(
|
|
332
344
|
"Transaction value must be a valid hex string",
|
|
333
|
-
|
|
345
|
+
result.value
|
|
346
|
+
);
|
|
347
|
+
throw new Error(
|
|
348
|
+
`Transaction value must be a valid hex string: ${result.value}`
|
|
334
349
|
);
|
|
335
|
-
return { isValid: false };
|
|
336
350
|
}
|
|
337
351
|
}
|
|
338
|
-
const
|
|
339
|
-
(
|
|
340
|
-
|
|
341
|
-
|
|
352
|
+
for (const key in result) {
|
|
353
|
+
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
354
|
+
result[key] = processPayload(result[key]);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return result;
|
|
342
358
|
}
|
|
343
|
-
return
|
|
359
|
+
return payload;
|
|
360
|
+
};
|
|
361
|
+
var validateSendTransactionPayload = (payload) => {
|
|
362
|
+
return processPayload(payload);
|
|
344
363
|
};
|
|
345
|
-
var validateSendTransactionPayload = (payload) => validate(payload);
|
|
346
364
|
|
|
347
365
|
// helpers/usernames/index.ts
|
|
348
366
|
var getUserProfile = async (address) => {
|
|
@@ -369,6 +387,8 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
369
387
|
Command2["SignTypedData"] = "sign-typed-data";
|
|
370
388
|
Command2["ShareContacts"] = "share-contacts";
|
|
371
389
|
Command2["RequestPermission"] = "request-permission";
|
|
390
|
+
Command2["GetPermissions"] = "get-permissions";
|
|
391
|
+
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
372
392
|
return Command2;
|
|
373
393
|
})(Command || {});
|
|
374
394
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
@@ -380,7 +400,7 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
|
380
400
|
var import_idkit_core = require("@worldcoin/idkit-core");
|
|
381
401
|
var import_idkit_core2 = require("@worldcoin/idkit-core");
|
|
382
402
|
var VerificationErrorMessage = {
|
|
383
|
-
[import_idkit_core.AppErrorCodes.VerificationRejected]: "You
|
|
403
|
+
[import_idkit_core.AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
|
|
384
404
|
[import_idkit_core.AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
385
405
|
[import_idkit_core.AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
386
406
|
[import_idkit_core.AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
@@ -404,7 +424,7 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
404
424
|
})(PaymentErrorCodes || {});
|
|
405
425
|
var PaymentErrorMessage = {
|
|
406
426
|
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
407
|
-
["payment_rejected" /* PaymentRejected */]: "You
|
|
427
|
+
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
408
428
|
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
409
429
|
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
410
430
|
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
@@ -439,6 +459,9 @@ var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) =>
|
|
|
439
459
|
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
440
460
|
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
441
461
|
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
462
|
+
SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
|
|
463
|
+
SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
|
|
464
|
+
SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
|
|
442
465
|
return SendTransactionErrorCodes2;
|
|
443
466
|
})(SendTransactionErrorCodes || {});
|
|
444
467
|
var SendTransactionErrorMessage = {
|
|
@@ -450,7 +473,10 @@ var SendTransactionErrorMessage = {
|
|
|
450
473
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
451
474
|
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
452
475
|
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
453
|
-
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
476
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
|
|
477
|
+
["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
|
|
478
|
+
["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
|
|
479
|
+
["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
|
|
454
480
|
};
|
|
455
481
|
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
456
482
|
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
@@ -474,7 +500,16 @@ var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
|
474
500
|
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
475
501
|
return SignTypedDataErrorCodes2;
|
|
476
502
|
})(SignTypedDataErrorCodes || {});
|
|
477
|
-
var SignTypedDataErrorMessage =
|
|
503
|
+
var SignTypedDataErrorMessage = {
|
|
504
|
+
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
505
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
506
|
+
["input_error" /* InputError */]: "Invalid payload.",
|
|
507
|
+
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
508
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
509
|
+
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
510
|
+
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
511
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
512
|
+
};
|
|
478
513
|
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
479
514
|
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
480
515
|
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
@@ -516,6 +551,22 @@ var RequestPermissionErrorMessage = {
|
|
|
516
551
|
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
517
552
|
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
518
553
|
};
|
|
554
|
+
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
555
|
+
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
556
|
+
return GetPermissionsErrorCodes2;
|
|
557
|
+
})(GetPermissionsErrorCodes || {});
|
|
558
|
+
var GetPermissionsErrorMessage = {
|
|
559
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
560
|
+
};
|
|
561
|
+
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
562
|
+
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
563
|
+
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
564
|
+
return SendHapticFeedbackErrorCodes2;
|
|
565
|
+
})(SendHapticFeedbackErrorCodes || {});
|
|
566
|
+
var SendHapticFeedbackErrorMessage = {
|
|
567
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
568
|
+
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
569
|
+
};
|
|
519
570
|
|
|
520
571
|
// helpers/send-webview-event.ts
|
|
521
572
|
var sendWebviewEvent = (payload) => {
|
|
@@ -536,6 +587,8 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
536
587
|
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
537
588
|
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
538
589
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
590
|
+
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
591
|
+
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
539
592
|
return ResponseEvent2;
|
|
540
593
|
})(ResponseEvent || {});
|
|
541
594
|
|
|
@@ -667,7 +720,9 @@ _MiniKit.commandVersion = {
|
|
|
667
720
|
["sign-message" /* SignMessage */]: 1,
|
|
668
721
|
["sign-typed-data" /* SignTypedData */]: 1,
|
|
669
722
|
["share-contacts" /* ShareContacts */]: 1,
|
|
670
|
-
["request-permission" /* RequestPermission */]: 1
|
|
723
|
+
["request-permission" /* RequestPermission */]: 1,
|
|
724
|
+
["get-permissions" /* GetPermissions */]: 1,
|
|
725
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
671
726
|
};
|
|
672
727
|
_MiniKit.isCommandAvailable = {
|
|
673
728
|
["verify" /* Verify */]: false,
|
|
@@ -677,7 +732,9 @@ _MiniKit.isCommandAvailable = {
|
|
|
677
732
|
["sign-message" /* SignMessage */]: false,
|
|
678
733
|
["sign-typed-data" /* SignTypedData */]: false,
|
|
679
734
|
["share-contacts" /* ShareContacts */]: false,
|
|
680
|
-
["request-permission" /* RequestPermission */]: false
|
|
735
|
+
["request-permission" /* RequestPermission */]: false,
|
|
736
|
+
["get-permissions" /* GetPermissions */]: false,
|
|
737
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
681
738
|
};
|
|
682
739
|
_MiniKit.listeners = {
|
|
683
740
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -695,6 +752,10 @@ _MiniKit.listeners = {
|
|
|
695
752
|
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
696
753
|
},
|
|
697
754
|
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
755
|
+
},
|
|
756
|
+
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
757
|
+
},
|
|
758
|
+
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
698
759
|
}
|
|
699
760
|
};
|
|
700
761
|
_MiniKit.appId = null;
|
|
@@ -806,18 +867,13 @@ _MiniKit.commands = {
|
|
|
806
867
|
);
|
|
807
868
|
return null;
|
|
808
869
|
}
|
|
809
|
-
|
|
810
|
-
console.error(
|
|
811
|
-
"Invalid sendTransaction payload - some object properties are not strings"
|
|
812
|
-
);
|
|
813
|
-
return null;
|
|
814
|
-
}
|
|
870
|
+
const validatedPayload = validateSendTransactionPayload(payload);
|
|
815
871
|
sendMiniKitEvent({
|
|
816
872
|
command: "send-transaction" /* SendTransaction */,
|
|
817
873
|
version: 1,
|
|
818
|
-
payload
|
|
874
|
+
payload: validatedPayload
|
|
819
875
|
});
|
|
820
|
-
return
|
|
876
|
+
return validatedPayload;
|
|
821
877
|
},
|
|
822
878
|
signMessage: (payload) => {
|
|
823
879
|
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-message" /* SignMessage */]) {
|
|
@@ -874,6 +930,36 @@ _MiniKit.commands = {
|
|
|
874
930
|
payload
|
|
875
931
|
});
|
|
876
932
|
return payload;
|
|
933
|
+
},
|
|
934
|
+
getPermissions: () => {
|
|
935
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["get-permissions" /* GetPermissions */]) {
|
|
936
|
+
console.error(
|
|
937
|
+
"'getPermissions' command is unavailable. Check MiniKit.install() or update the app version"
|
|
938
|
+
);
|
|
939
|
+
return null;
|
|
940
|
+
}
|
|
941
|
+
sendMiniKitEvent({
|
|
942
|
+
command: "get-permissions" /* GetPermissions */,
|
|
943
|
+
version: 1,
|
|
944
|
+
payload: {}
|
|
945
|
+
});
|
|
946
|
+
return {
|
|
947
|
+
status: "sent"
|
|
948
|
+
};
|
|
949
|
+
},
|
|
950
|
+
sendHapticFeedback: (payload) => {
|
|
951
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-haptic-feedback" /* SendHapticFeedback */]) {
|
|
952
|
+
console.error(
|
|
953
|
+
"'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
|
|
954
|
+
);
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
sendMiniKitEvent({
|
|
958
|
+
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
959
|
+
version: 1,
|
|
960
|
+
payload
|
|
961
|
+
});
|
|
962
|
+
return payload;
|
|
877
963
|
}
|
|
878
964
|
};
|
|
879
965
|
/**
|
|
@@ -998,6 +1084,34 @@ _MiniKit.commandsAsync = {
|
|
|
998
1084
|
reject(error);
|
|
999
1085
|
}
|
|
1000
1086
|
});
|
|
1087
|
+
},
|
|
1088
|
+
getPermissions: async () => {
|
|
1089
|
+
return new Promise(async (resolve, reject) => {
|
|
1090
|
+
try {
|
|
1091
|
+
const response = await _MiniKit.awaitCommand(
|
|
1092
|
+
"miniapp-get-permissions" /* MiniAppGetPermissions */,
|
|
1093
|
+
"get-permissions" /* GetPermissions */,
|
|
1094
|
+
() => _MiniKit.commands.getPermissions()
|
|
1095
|
+
);
|
|
1096
|
+
resolve(response);
|
|
1097
|
+
} catch (error) {
|
|
1098
|
+
reject(error);
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
},
|
|
1102
|
+
sendHapticFeedback: async (payload) => {
|
|
1103
|
+
return new Promise(async (resolve, reject) => {
|
|
1104
|
+
try {
|
|
1105
|
+
const response = await _MiniKit.awaitCommand(
|
|
1106
|
+
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
1107
|
+
"send-haptic-feedback" /* SendHapticFeedback */,
|
|
1108
|
+
() => _MiniKit.commands.sendHapticFeedback(payload)
|
|
1109
|
+
);
|
|
1110
|
+
resolve(response);
|
|
1111
|
+
} catch (error) {
|
|
1112
|
+
reject(error);
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1001
1115
|
}
|
|
1002
1116
|
};
|
|
1003
1117
|
var MiniKit = _MiniKit;
|
|
@@ -1060,6 +1174,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
1060
1174
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1061
1175
|
0 && (module.exports = {
|
|
1062
1176
|
Command,
|
|
1177
|
+
GetPermissionsErrorCodes,
|
|
1178
|
+
GetPermissionsErrorMessage,
|
|
1063
1179
|
MiniKit,
|
|
1064
1180
|
MiniKitInstallErrorCodes,
|
|
1065
1181
|
MiniKitInstallErrorMessage,
|
|
@@ -1072,6 +1188,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
1072
1188
|
RequestPermissionErrorMessage,
|
|
1073
1189
|
ResponseEvent,
|
|
1074
1190
|
SAFE_CONTRACT_ABI,
|
|
1191
|
+
SendHapticFeedbackErrorCodes,
|
|
1192
|
+
SendHapticFeedbackErrorMessage,
|
|
1075
1193
|
SendTransactionErrorCodes,
|
|
1076
1194
|
SendTransactionErrorMessage,
|
|
1077
1195
|
ShareContactsErrorCodes,
|
package/build/index.d.cts
CHANGED
|
@@ -40,19 +40,12 @@ declare enum SendTransactionErrorCodes {
|
|
|
40
40
|
GenericError = "generic_error",
|
|
41
41
|
DisallowedOperation = "disallowed_operation",
|
|
42
42
|
InvalidContract = "invalid_contract",
|
|
43
|
-
MaliciousOperation = "malicious_operation"
|
|
43
|
+
MaliciousOperation = "malicious_operation",
|
|
44
|
+
DailyTxLimitReached = "daily_tx_limit_reached",
|
|
45
|
+
PermittedAmountExceedsSlippage = "permitted_amount_exceeds_slippage",
|
|
46
|
+
PermittedAmountNotFound = "permitted_amount_not_found"
|
|
44
47
|
}
|
|
45
|
-
declare const SendTransactionErrorMessage:
|
|
46
|
-
invalid_operation: string;
|
|
47
|
-
user_rejected: string;
|
|
48
|
-
input_error: string;
|
|
49
|
-
simulation_failed: string;
|
|
50
|
-
transaction_failed: string;
|
|
51
|
-
generic_error: string;
|
|
52
|
-
disallowed_operation: string;
|
|
53
|
-
invalid_contract: string;
|
|
54
|
-
malicious_operation: string;
|
|
55
|
-
};
|
|
48
|
+
declare const SendTransactionErrorMessage: Record<SendTransactionErrorCodes, string>;
|
|
56
49
|
declare enum SignMessageErrorCodes {
|
|
57
50
|
InvalidMessage = "invalid_message",
|
|
58
51
|
UserRejected = "user_rejected",
|
|
@@ -78,7 +71,6 @@ declare const SignTypedDataErrorMessage: {
|
|
|
78
71
|
user_rejected: string;
|
|
79
72
|
input_error: string;
|
|
80
73
|
simulation_failed: string;
|
|
81
|
-
transaction_failed: string;
|
|
82
74
|
generic_error: string;
|
|
83
75
|
disallowed_operation: string;
|
|
84
76
|
invalid_contract: string;
|
|
@@ -122,6 +114,20 @@ declare const RequestPermissionErrorMessage: {
|
|
|
122
114
|
already_granted: string;
|
|
123
115
|
unsupported_permission: string;
|
|
124
116
|
};
|
|
117
|
+
declare enum GetPermissionsErrorCodes {
|
|
118
|
+
GenericError = "generic_error"
|
|
119
|
+
}
|
|
120
|
+
declare const GetPermissionsErrorMessage: {
|
|
121
|
+
generic_error: string;
|
|
122
|
+
};
|
|
123
|
+
declare enum SendHapticFeedbackErrorCodes {
|
|
124
|
+
GenericError = "generic_error",
|
|
125
|
+
UserRejected = "user_rejected"
|
|
126
|
+
}
|
|
127
|
+
declare const SendHapticFeedbackErrorMessage: {
|
|
128
|
+
generic_error: string;
|
|
129
|
+
user_rejected: string;
|
|
130
|
+
};
|
|
125
131
|
|
|
126
132
|
declare enum Tokens {
|
|
127
133
|
USDCE = "USDCE",
|
|
@@ -162,7 +168,9 @@ declare enum Command {
|
|
|
162
168
|
SignMessage = "sign-message",
|
|
163
169
|
SignTypedData = "sign-typed-data",
|
|
164
170
|
ShareContacts = "share-contacts",
|
|
165
|
-
RequestPermission = "request-permission"
|
|
171
|
+
RequestPermission = "request-permission",
|
|
172
|
+
GetPermissions = "get-permissions",
|
|
173
|
+
SendHapticFeedback = "send-haptic-feedback"
|
|
166
174
|
}
|
|
167
175
|
type WebViewBasePayload = {
|
|
168
176
|
command: Command;
|
|
@@ -238,6 +246,19 @@ type RequestPermissionInput = {
|
|
|
238
246
|
permission: Permission;
|
|
239
247
|
};
|
|
240
248
|
type RequestPermissionPayload = RequestPermissionInput;
|
|
249
|
+
type GetPermissionsInput = {};
|
|
250
|
+
type GetPermissionsPayload = GetPermissionsInput;
|
|
251
|
+
type SendHapticFeedbackInput = {
|
|
252
|
+
hapticsType: 'notification';
|
|
253
|
+
style: 'error' | 'success' | 'warning';
|
|
254
|
+
} | {
|
|
255
|
+
hapticsType: 'selection-changed';
|
|
256
|
+
style?: never;
|
|
257
|
+
} | {
|
|
258
|
+
hapticsType: 'impact';
|
|
259
|
+
style: 'light' | 'medium' | 'heavy';
|
|
260
|
+
};
|
|
261
|
+
type SendHapticFeedbackPayload = SendHapticFeedbackInput;
|
|
241
262
|
type CommandReturnPayloadMap = {
|
|
242
263
|
[Command.Verify]: VerifyCommandPayload;
|
|
243
264
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -247,6 +268,8 @@ type CommandReturnPayloadMap = {
|
|
|
247
268
|
[Command.SignTypedData]: SignTypedDataPayload;
|
|
248
269
|
[Command.ShareContacts]: ShareContactsPayload;
|
|
249
270
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
271
|
+
[Command.GetPermissions]: GetPermissionsPayload;
|
|
272
|
+
[Command.SendHapticFeedback]: SendHapticFeedbackPayload;
|
|
250
273
|
};
|
|
251
274
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
252
275
|
|
|
@@ -258,7 +281,9 @@ declare enum ResponseEvent {
|
|
|
258
281
|
MiniAppSignMessage = "miniapp-sign-message",
|
|
259
282
|
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
260
283
|
MiniAppShareContacts = "miniapp-share-contacts",
|
|
261
|
-
MiniAppRequestPermission = "miniapp-request-permission"
|
|
284
|
+
MiniAppRequestPermission = "miniapp-request-permission",
|
|
285
|
+
MiniAppGetPermissions = "miniapp-get-permissions",
|
|
286
|
+
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback"
|
|
262
287
|
}
|
|
263
288
|
type MiniAppVerifyActionSuccessPayload = {
|
|
264
289
|
status: 'success';
|
|
@@ -313,12 +338,14 @@ type MiniAppSendTransactionSuccessPayload = {
|
|
|
313
338
|
chain: Network;
|
|
314
339
|
timestamp: string;
|
|
315
340
|
version: number;
|
|
341
|
+
mini_app_id?: string;
|
|
316
342
|
};
|
|
317
343
|
type MiniAppSendTransactionErrorPayload = {
|
|
318
344
|
status: 'error';
|
|
319
345
|
error_code: SendTransactionErrorCodes;
|
|
320
346
|
details?: Record<string, any>;
|
|
321
347
|
version: number;
|
|
348
|
+
mini_app_id?: string;
|
|
322
349
|
};
|
|
323
350
|
type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
|
|
324
351
|
type MiniAppSignMessageSuccessPayload = {
|
|
@@ -377,6 +404,33 @@ type MiniAppRequestPermissionErrorPayload = {
|
|
|
377
404
|
version: number;
|
|
378
405
|
};
|
|
379
406
|
type MiniAppRequestPermissionPayload = MiniAppRequestPermissionSuccessPayload | MiniAppRequestPermissionErrorPayload;
|
|
407
|
+
type PermissionSettings = {
|
|
408
|
+
[K in Permission]?: any;
|
|
409
|
+
};
|
|
410
|
+
type MiniAppGetPermissionsSuccessPayload = {
|
|
411
|
+
status: 'success';
|
|
412
|
+
permissions: PermissionSettings;
|
|
413
|
+
version: number;
|
|
414
|
+
timestamp: string;
|
|
415
|
+
};
|
|
416
|
+
type MiniAppGetPermissionsErrorPayload = {
|
|
417
|
+
status: 'error';
|
|
418
|
+
error_code: GetPermissionsErrorCodes;
|
|
419
|
+
details: string;
|
|
420
|
+
version: number;
|
|
421
|
+
};
|
|
422
|
+
type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
|
|
423
|
+
type MiniAppSendHapticFeedbackSuccessPayload = {
|
|
424
|
+
status: 'success';
|
|
425
|
+
version: number;
|
|
426
|
+
timestamp: string;
|
|
427
|
+
};
|
|
428
|
+
type MiniAppSendHapticFeedbackErrorPayload = {
|
|
429
|
+
status: 'error';
|
|
430
|
+
error_code: SendHapticFeedbackErrorCodes;
|
|
431
|
+
version: number;
|
|
432
|
+
};
|
|
433
|
+
type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
|
|
380
434
|
type EventPayloadMap = {
|
|
381
435
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
382
436
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -386,6 +440,8 @@ type EventPayloadMap = {
|
|
|
386
440
|
[ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
|
|
387
441
|
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
388
442
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
443
|
+
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
444
|
+
[ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
|
|
389
445
|
};
|
|
390
446
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
391
447
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -425,6 +481,8 @@ declare class MiniKit {
|
|
|
425
481
|
signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
|
|
426
482
|
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
427
483
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
484
|
+
getPermissions: () => GetPermissionsPayload | null;
|
|
485
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
428
486
|
};
|
|
429
487
|
/**
|
|
430
488
|
* This object contains async versions of all the commands.
|
|
@@ -445,6 +503,8 @@ declare class MiniKit {
|
|
|
445
503
|
signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
|
|
446
504
|
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
447
505
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
506
|
+
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
507
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
448
508
|
};
|
|
449
509
|
}
|
|
450
510
|
|
|
@@ -488,4 +548,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
488
548
|
|
|
489
549
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
490
550
|
|
|
491
|
-
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
|
551
|
+
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendHapticFeedbackErrorPayload, type MiniAppSendHapticFeedbackPayload, type MiniAppSendHapticFeedbackSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, type PermissionSettings, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.d.ts
CHANGED
|
@@ -40,19 +40,12 @@ declare enum SendTransactionErrorCodes {
|
|
|
40
40
|
GenericError = "generic_error",
|
|
41
41
|
DisallowedOperation = "disallowed_operation",
|
|
42
42
|
InvalidContract = "invalid_contract",
|
|
43
|
-
MaliciousOperation = "malicious_operation"
|
|
43
|
+
MaliciousOperation = "malicious_operation",
|
|
44
|
+
DailyTxLimitReached = "daily_tx_limit_reached",
|
|
45
|
+
PermittedAmountExceedsSlippage = "permitted_amount_exceeds_slippage",
|
|
46
|
+
PermittedAmountNotFound = "permitted_amount_not_found"
|
|
44
47
|
}
|
|
45
|
-
declare const SendTransactionErrorMessage:
|
|
46
|
-
invalid_operation: string;
|
|
47
|
-
user_rejected: string;
|
|
48
|
-
input_error: string;
|
|
49
|
-
simulation_failed: string;
|
|
50
|
-
transaction_failed: string;
|
|
51
|
-
generic_error: string;
|
|
52
|
-
disallowed_operation: string;
|
|
53
|
-
invalid_contract: string;
|
|
54
|
-
malicious_operation: string;
|
|
55
|
-
};
|
|
48
|
+
declare const SendTransactionErrorMessage: Record<SendTransactionErrorCodes, string>;
|
|
56
49
|
declare enum SignMessageErrorCodes {
|
|
57
50
|
InvalidMessage = "invalid_message",
|
|
58
51
|
UserRejected = "user_rejected",
|
|
@@ -78,7 +71,6 @@ declare const SignTypedDataErrorMessage: {
|
|
|
78
71
|
user_rejected: string;
|
|
79
72
|
input_error: string;
|
|
80
73
|
simulation_failed: string;
|
|
81
|
-
transaction_failed: string;
|
|
82
74
|
generic_error: string;
|
|
83
75
|
disallowed_operation: string;
|
|
84
76
|
invalid_contract: string;
|
|
@@ -122,6 +114,20 @@ declare const RequestPermissionErrorMessage: {
|
|
|
122
114
|
already_granted: string;
|
|
123
115
|
unsupported_permission: string;
|
|
124
116
|
};
|
|
117
|
+
declare enum GetPermissionsErrorCodes {
|
|
118
|
+
GenericError = "generic_error"
|
|
119
|
+
}
|
|
120
|
+
declare const GetPermissionsErrorMessage: {
|
|
121
|
+
generic_error: string;
|
|
122
|
+
};
|
|
123
|
+
declare enum SendHapticFeedbackErrorCodes {
|
|
124
|
+
GenericError = "generic_error",
|
|
125
|
+
UserRejected = "user_rejected"
|
|
126
|
+
}
|
|
127
|
+
declare const SendHapticFeedbackErrorMessage: {
|
|
128
|
+
generic_error: string;
|
|
129
|
+
user_rejected: string;
|
|
130
|
+
};
|
|
125
131
|
|
|
126
132
|
declare enum Tokens {
|
|
127
133
|
USDCE = "USDCE",
|
|
@@ -162,7 +168,9 @@ declare enum Command {
|
|
|
162
168
|
SignMessage = "sign-message",
|
|
163
169
|
SignTypedData = "sign-typed-data",
|
|
164
170
|
ShareContacts = "share-contacts",
|
|
165
|
-
RequestPermission = "request-permission"
|
|
171
|
+
RequestPermission = "request-permission",
|
|
172
|
+
GetPermissions = "get-permissions",
|
|
173
|
+
SendHapticFeedback = "send-haptic-feedback"
|
|
166
174
|
}
|
|
167
175
|
type WebViewBasePayload = {
|
|
168
176
|
command: Command;
|
|
@@ -238,6 +246,19 @@ type RequestPermissionInput = {
|
|
|
238
246
|
permission: Permission;
|
|
239
247
|
};
|
|
240
248
|
type RequestPermissionPayload = RequestPermissionInput;
|
|
249
|
+
type GetPermissionsInput = {};
|
|
250
|
+
type GetPermissionsPayload = GetPermissionsInput;
|
|
251
|
+
type SendHapticFeedbackInput = {
|
|
252
|
+
hapticsType: 'notification';
|
|
253
|
+
style: 'error' | 'success' | 'warning';
|
|
254
|
+
} | {
|
|
255
|
+
hapticsType: 'selection-changed';
|
|
256
|
+
style?: never;
|
|
257
|
+
} | {
|
|
258
|
+
hapticsType: 'impact';
|
|
259
|
+
style: 'light' | 'medium' | 'heavy';
|
|
260
|
+
};
|
|
261
|
+
type SendHapticFeedbackPayload = SendHapticFeedbackInput;
|
|
241
262
|
type CommandReturnPayloadMap = {
|
|
242
263
|
[Command.Verify]: VerifyCommandPayload;
|
|
243
264
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -247,6 +268,8 @@ type CommandReturnPayloadMap = {
|
|
|
247
268
|
[Command.SignTypedData]: SignTypedDataPayload;
|
|
248
269
|
[Command.ShareContacts]: ShareContactsPayload;
|
|
249
270
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
271
|
+
[Command.GetPermissions]: GetPermissionsPayload;
|
|
272
|
+
[Command.SendHapticFeedback]: SendHapticFeedbackPayload;
|
|
250
273
|
};
|
|
251
274
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
252
275
|
|
|
@@ -258,7 +281,9 @@ declare enum ResponseEvent {
|
|
|
258
281
|
MiniAppSignMessage = "miniapp-sign-message",
|
|
259
282
|
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
260
283
|
MiniAppShareContacts = "miniapp-share-contacts",
|
|
261
|
-
MiniAppRequestPermission = "miniapp-request-permission"
|
|
284
|
+
MiniAppRequestPermission = "miniapp-request-permission",
|
|
285
|
+
MiniAppGetPermissions = "miniapp-get-permissions",
|
|
286
|
+
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback"
|
|
262
287
|
}
|
|
263
288
|
type MiniAppVerifyActionSuccessPayload = {
|
|
264
289
|
status: 'success';
|
|
@@ -313,12 +338,14 @@ type MiniAppSendTransactionSuccessPayload = {
|
|
|
313
338
|
chain: Network;
|
|
314
339
|
timestamp: string;
|
|
315
340
|
version: number;
|
|
341
|
+
mini_app_id?: string;
|
|
316
342
|
};
|
|
317
343
|
type MiniAppSendTransactionErrorPayload = {
|
|
318
344
|
status: 'error';
|
|
319
345
|
error_code: SendTransactionErrorCodes;
|
|
320
346
|
details?: Record<string, any>;
|
|
321
347
|
version: number;
|
|
348
|
+
mini_app_id?: string;
|
|
322
349
|
};
|
|
323
350
|
type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
|
|
324
351
|
type MiniAppSignMessageSuccessPayload = {
|
|
@@ -377,6 +404,33 @@ type MiniAppRequestPermissionErrorPayload = {
|
|
|
377
404
|
version: number;
|
|
378
405
|
};
|
|
379
406
|
type MiniAppRequestPermissionPayload = MiniAppRequestPermissionSuccessPayload | MiniAppRequestPermissionErrorPayload;
|
|
407
|
+
type PermissionSettings = {
|
|
408
|
+
[K in Permission]?: any;
|
|
409
|
+
};
|
|
410
|
+
type MiniAppGetPermissionsSuccessPayload = {
|
|
411
|
+
status: 'success';
|
|
412
|
+
permissions: PermissionSettings;
|
|
413
|
+
version: number;
|
|
414
|
+
timestamp: string;
|
|
415
|
+
};
|
|
416
|
+
type MiniAppGetPermissionsErrorPayload = {
|
|
417
|
+
status: 'error';
|
|
418
|
+
error_code: GetPermissionsErrorCodes;
|
|
419
|
+
details: string;
|
|
420
|
+
version: number;
|
|
421
|
+
};
|
|
422
|
+
type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
|
|
423
|
+
type MiniAppSendHapticFeedbackSuccessPayload = {
|
|
424
|
+
status: 'success';
|
|
425
|
+
version: number;
|
|
426
|
+
timestamp: string;
|
|
427
|
+
};
|
|
428
|
+
type MiniAppSendHapticFeedbackErrorPayload = {
|
|
429
|
+
status: 'error';
|
|
430
|
+
error_code: SendHapticFeedbackErrorCodes;
|
|
431
|
+
version: number;
|
|
432
|
+
};
|
|
433
|
+
type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
|
|
380
434
|
type EventPayloadMap = {
|
|
381
435
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
382
436
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -386,6 +440,8 @@ type EventPayloadMap = {
|
|
|
386
440
|
[ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
|
|
387
441
|
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
388
442
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
443
|
+
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
444
|
+
[ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
|
|
389
445
|
};
|
|
390
446
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
391
447
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -425,6 +481,8 @@ declare class MiniKit {
|
|
|
425
481
|
signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
|
|
426
482
|
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
427
483
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
484
|
+
getPermissions: () => GetPermissionsPayload | null;
|
|
485
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
428
486
|
};
|
|
429
487
|
/**
|
|
430
488
|
* This object contains async versions of all the commands.
|
|
@@ -445,6 +503,8 @@ declare class MiniKit {
|
|
|
445
503
|
signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
|
|
446
504
|
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
447
505
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
506
|
+
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
507
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
448
508
|
};
|
|
449
509
|
}
|
|
450
510
|
|
|
@@ -488,4 +548,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
488
548
|
|
|
489
549
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
490
550
|
|
|
491
|
-
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
|
551
|
+
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendHapticFeedbackErrorPayload, type MiniAppSendHapticFeedbackPayload, type MiniAppSendHapticFeedbackSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, type PermissionSettings, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.js
CHANGED
|
@@ -267,30 +267,44 @@ var validateWalletAuthCommandInput = (params) => {
|
|
|
267
267
|
var isValidHex = (str) => {
|
|
268
268
|
return /^0x[0-9A-Fa-f]+$/.test(str);
|
|
269
269
|
};
|
|
270
|
-
var
|
|
271
|
-
if (typeof payload === "string"
|
|
270
|
+
var processPayload = (payload) => {
|
|
271
|
+
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
272
|
+
return payload;
|
|
273
|
+
}
|
|
274
|
+
if (typeof payload === "number") {
|
|
275
|
+
return String(payload);
|
|
276
|
+
}
|
|
272
277
|
if (Array.isArray(payload)) {
|
|
273
|
-
|
|
274
|
-
return { isValid };
|
|
278
|
+
return payload.map((value) => processPayload(value));
|
|
275
279
|
}
|
|
276
|
-
if (typeof payload === "object"
|
|
277
|
-
|
|
278
|
-
|
|
280
|
+
if (typeof payload === "object") {
|
|
281
|
+
const result = { ...payload };
|
|
282
|
+
if ("value" in result && result.value !== void 0) {
|
|
283
|
+
if (typeof result.value !== "string") {
|
|
284
|
+
result.value = String(result.value);
|
|
285
|
+
}
|
|
286
|
+
if (!isValidHex(result.value)) {
|
|
279
287
|
console.error(
|
|
280
288
|
"Transaction value must be a valid hex string",
|
|
281
|
-
|
|
289
|
+
result.value
|
|
290
|
+
);
|
|
291
|
+
throw new Error(
|
|
292
|
+
`Transaction value must be a valid hex string: ${result.value}`
|
|
282
293
|
);
|
|
283
|
-
return { isValid: false };
|
|
284
294
|
}
|
|
285
295
|
}
|
|
286
|
-
const
|
|
287
|
-
(
|
|
288
|
-
|
|
289
|
-
|
|
296
|
+
for (const key in result) {
|
|
297
|
+
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
298
|
+
result[key] = processPayload(result[key]);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return result;
|
|
290
302
|
}
|
|
291
|
-
return
|
|
303
|
+
return payload;
|
|
304
|
+
};
|
|
305
|
+
var validateSendTransactionPayload = (payload) => {
|
|
306
|
+
return processPayload(payload);
|
|
292
307
|
};
|
|
293
|
-
var validateSendTransactionPayload = (payload) => validate(payload);
|
|
294
308
|
|
|
295
309
|
// helpers/usernames/index.ts
|
|
296
310
|
var getUserProfile = async (address) => {
|
|
@@ -317,6 +331,8 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
317
331
|
Command2["SignTypedData"] = "sign-typed-data";
|
|
318
332
|
Command2["ShareContacts"] = "share-contacts";
|
|
319
333
|
Command2["RequestPermission"] = "request-permission";
|
|
334
|
+
Command2["GetPermissions"] = "get-permissions";
|
|
335
|
+
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
320
336
|
return Command2;
|
|
321
337
|
})(Command || {});
|
|
322
338
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
@@ -328,7 +344,7 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
|
328
344
|
import { AppErrorCodes } from "@worldcoin/idkit-core";
|
|
329
345
|
import { AppErrorCodes as AppErrorCodes2 } from "@worldcoin/idkit-core";
|
|
330
346
|
var VerificationErrorMessage = {
|
|
331
|
-
[AppErrorCodes.VerificationRejected]: "You
|
|
347
|
+
[AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
|
|
332
348
|
[AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
333
349
|
[AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
334
350
|
[AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
@@ -352,7 +368,7 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
352
368
|
})(PaymentErrorCodes || {});
|
|
353
369
|
var PaymentErrorMessage = {
|
|
354
370
|
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
355
|
-
["payment_rejected" /* PaymentRejected */]: "You
|
|
371
|
+
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
356
372
|
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
357
373
|
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
358
374
|
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
@@ -387,6 +403,9 @@ var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) =>
|
|
|
387
403
|
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
388
404
|
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
389
405
|
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
406
|
+
SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
|
|
407
|
+
SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
|
|
408
|
+
SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
|
|
390
409
|
return SendTransactionErrorCodes2;
|
|
391
410
|
})(SendTransactionErrorCodes || {});
|
|
392
411
|
var SendTransactionErrorMessage = {
|
|
@@ -398,7 +417,10 @@ var SendTransactionErrorMessage = {
|
|
|
398
417
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
399
418
|
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
400
419
|
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
401
|
-
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
420
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
|
|
421
|
+
["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
|
|
422
|
+
["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
|
|
423
|
+
["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
|
|
402
424
|
};
|
|
403
425
|
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
404
426
|
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
@@ -422,7 +444,16 @@ var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
|
422
444
|
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
423
445
|
return SignTypedDataErrorCodes2;
|
|
424
446
|
})(SignTypedDataErrorCodes || {});
|
|
425
|
-
var SignTypedDataErrorMessage =
|
|
447
|
+
var SignTypedDataErrorMessage = {
|
|
448
|
+
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
449
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
450
|
+
["input_error" /* InputError */]: "Invalid payload.",
|
|
451
|
+
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
452
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
453
|
+
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
454
|
+
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
455
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
456
|
+
};
|
|
426
457
|
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
427
458
|
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
428
459
|
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
@@ -464,6 +495,22 @@ var RequestPermissionErrorMessage = {
|
|
|
464
495
|
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
465
496
|
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
466
497
|
};
|
|
498
|
+
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
499
|
+
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
500
|
+
return GetPermissionsErrorCodes2;
|
|
501
|
+
})(GetPermissionsErrorCodes || {});
|
|
502
|
+
var GetPermissionsErrorMessage = {
|
|
503
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
504
|
+
};
|
|
505
|
+
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
506
|
+
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
507
|
+
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
508
|
+
return SendHapticFeedbackErrorCodes2;
|
|
509
|
+
})(SendHapticFeedbackErrorCodes || {});
|
|
510
|
+
var SendHapticFeedbackErrorMessage = {
|
|
511
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
512
|
+
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
513
|
+
};
|
|
467
514
|
|
|
468
515
|
// helpers/send-webview-event.ts
|
|
469
516
|
var sendWebviewEvent = (payload) => {
|
|
@@ -484,6 +531,8 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
484
531
|
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
485
532
|
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
486
533
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
534
|
+
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
535
|
+
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
487
536
|
return ResponseEvent2;
|
|
488
537
|
})(ResponseEvent || {});
|
|
489
538
|
|
|
@@ -615,7 +664,9 @@ _MiniKit.commandVersion = {
|
|
|
615
664
|
["sign-message" /* SignMessage */]: 1,
|
|
616
665
|
["sign-typed-data" /* SignTypedData */]: 1,
|
|
617
666
|
["share-contacts" /* ShareContacts */]: 1,
|
|
618
|
-
["request-permission" /* RequestPermission */]: 1
|
|
667
|
+
["request-permission" /* RequestPermission */]: 1,
|
|
668
|
+
["get-permissions" /* GetPermissions */]: 1,
|
|
669
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
619
670
|
};
|
|
620
671
|
_MiniKit.isCommandAvailable = {
|
|
621
672
|
["verify" /* Verify */]: false,
|
|
@@ -625,7 +676,9 @@ _MiniKit.isCommandAvailable = {
|
|
|
625
676
|
["sign-message" /* SignMessage */]: false,
|
|
626
677
|
["sign-typed-data" /* SignTypedData */]: false,
|
|
627
678
|
["share-contacts" /* ShareContacts */]: false,
|
|
628
|
-
["request-permission" /* RequestPermission */]: false
|
|
679
|
+
["request-permission" /* RequestPermission */]: false,
|
|
680
|
+
["get-permissions" /* GetPermissions */]: false,
|
|
681
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
629
682
|
};
|
|
630
683
|
_MiniKit.listeners = {
|
|
631
684
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -643,6 +696,10 @@ _MiniKit.listeners = {
|
|
|
643
696
|
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
644
697
|
},
|
|
645
698
|
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
699
|
+
},
|
|
700
|
+
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
701
|
+
},
|
|
702
|
+
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
646
703
|
}
|
|
647
704
|
};
|
|
648
705
|
_MiniKit.appId = null;
|
|
@@ -754,18 +811,13 @@ _MiniKit.commands = {
|
|
|
754
811
|
);
|
|
755
812
|
return null;
|
|
756
813
|
}
|
|
757
|
-
|
|
758
|
-
console.error(
|
|
759
|
-
"Invalid sendTransaction payload - some object properties are not strings"
|
|
760
|
-
);
|
|
761
|
-
return null;
|
|
762
|
-
}
|
|
814
|
+
const validatedPayload = validateSendTransactionPayload(payload);
|
|
763
815
|
sendMiniKitEvent({
|
|
764
816
|
command: "send-transaction" /* SendTransaction */,
|
|
765
817
|
version: 1,
|
|
766
|
-
payload
|
|
818
|
+
payload: validatedPayload
|
|
767
819
|
});
|
|
768
|
-
return
|
|
820
|
+
return validatedPayload;
|
|
769
821
|
},
|
|
770
822
|
signMessage: (payload) => {
|
|
771
823
|
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-message" /* SignMessage */]) {
|
|
@@ -822,6 +874,36 @@ _MiniKit.commands = {
|
|
|
822
874
|
payload
|
|
823
875
|
});
|
|
824
876
|
return payload;
|
|
877
|
+
},
|
|
878
|
+
getPermissions: () => {
|
|
879
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["get-permissions" /* GetPermissions */]) {
|
|
880
|
+
console.error(
|
|
881
|
+
"'getPermissions' command is unavailable. Check MiniKit.install() or update the app version"
|
|
882
|
+
);
|
|
883
|
+
return null;
|
|
884
|
+
}
|
|
885
|
+
sendMiniKitEvent({
|
|
886
|
+
command: "get-permissions" /* GetPermissions */,
|
|
887
|
+
version: 1,
|
|
888
|
+
payload: {}
|
|
889
|
+
});
|
|
890
|
+
return {
|
|
891
|
+
status: "sent"
|
|
892
|
+
};
|
|
893
|
+
},
|
|
894
|
+
sendHapticFeedback: (payload) => {
|
|
895
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-haptic-feedback" /* SendHapticFeedback */]) {
|
|
896
|
+
console.error(
|
|
897
|
+
"'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
|
|
898
|
+
);
|
|
899
|
+
return null;
|
|
900
|
+
}
|
|
901
|
+
sendMiniKitEvent({
|
|
902
|
+
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
903
|
+
version: 1,
|
|
904
|
+
payload
|
|
905
|
+
});
|
|
906
|
+
return payload;
|
|
825
907
|
}
|
|
826
908
|
};
|
|
827
909
|
/**
|
|
@@ -946,6 +1028,34 @@ _MiniKit.commandsAsync = {
|
|
|
946
1028
|
reject(error);
|
|
947
1029
|
}
|
|
948
1030
|
});
|
|
1031
|
+
},
|
|
1032
|
+
getPermissions: async () => {
|
|
1033
|
+
return new Promise(async (resolve, reject) => {
|
|
1034
|
+
try {
|
|
1035
|
+
const response = await _MiniKit.awaitCommand(
|
|
1036
|
+
"miniapp-get-permissions" /* MiniAppGetPermissions */,
|
|
1037
|
+
"get-permissions" /* GetPermissions */,
|
|
1038
|
+
() => _MiniKit.commands.getPermissions()
|
|
1039
|
+
);
|
|
1040
|
+
resolve(response);
|
|
1041
|
+
} catch (error) {
|
|
1042
|
+
reject(error);
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
},
|
|
1046
|
+
sendHapticFeedback: async (payload) => {
|
|
1047
|
+
return new Promise(async (resolve, reject) => {
|
|
1048
|
+
try {
|
|
1049
|
+
const response = await _MiniKit.awaitCommand(
|
|
1050
|
+
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
1051
|
+
"send-haptic-feedback" /* SendHapticFeedback */,
|
|
1052
|
+
() => _MiniKit.commands.sendHapticFeedback(payload)
|
|
1053
|
+
);
|
|
1054
|
+
resolve(response);
|
|
1055
|
+
} catch (error) {
|
|
1056
|
+
reject(error);
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
949
1059
|
}
|
|
950
1060
|
};
|
|
951
1061
|
var MiniKit = _MiniKit;
|
|
@@ -1009,6 +1119,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
1009
1119
|
};
|
|
1010
1120
|
export {
|
|
1011
1121
|
Command,
|
|
1122
|
+
GetPermissionsErrorCodes,
|
|
1123
|
+
GetPermissionsErrorMessage,
|
|
1012
1124
|
MiniKit,
|
|
1013
1125
|
MiniKitInstallErrorCodes,
|
|
1014
1126
|
MiniKitInstallErrorMessage,
|
|
@@ -1021,6 +1133,8 @@ export {
|
|
|
1021
1133
|
RequestPermissionErrorMessage,
|
|
1022
1134
|
ResponseEvent,
|
|
1023
1135
|
SAFE_CONTRACT_ABI,
|
|
1136
|
+
SendHapticFeedbackErrorCodes,
|
|
1137
|
+
SendHapticFeedbackErrorMessage,
|
|
1024
1138
|
SendTransactionErrorCodes,
|
|
1025
1139
|
SendTransactionErrorMessage,
|
|
1026
1140
|
ShareContactsErrorCodes,
|