@worldcoin/minikit-js 1.7.0 → 1.8.0
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 +154 -30
- package/build/index.d.cts +43 -5
- package/build/index.d.ts +43 -5
- package/build/index.js +156 -29
- package/package.json +3 -3
package/build/index.cjs
CHANGED
|
@@ -35,6 +35,8 @@ __export(core_exports, {
|
|
|
35
35
|
RequestPermissionErrorMessage: () => RequestPermissionErrorMessage,
|
|
36
36
|
ResponseEvent: () => ResponseEvent,
|
|
37
37
|
SAFE_CONTRACT_ABI: () => SAFE_CONTRACT_ABI,
|
|
38
|
+
SendHapticFeedbackErrorCodes: () => SendHapticFeedbackErrorCodes,
|
|
39
|
+
SendHapticFeedbackErrorMessage: () => SendHapticFeedbackErrorMessage,
|
|
38
40
|
SendTransactionErrorCodes: () => SendTransactionErrorCodes,
|
|
39
41
|
SendTransactionErrorMessage: () => SendTransactionErrorMessage,
|
|
40
42
|
ShareContactsErrorCodes: () => ShareContactsErrorCodes,
|
|
@@ -108,9 +110,63 @@ var validatePaymentPayload = (payload) => {
|
|
|
108
110
|
return true;
|
|
109
111
|
};
|
|
110
112
|
|
|
111
|
-
// helpers/
|
|
113
|
+
// helpers/proof/index.ts
|
|
112
114
|
var import_viem = require("viem");
|
|
113
115
|
var import_chains = require("viem/chains");
|
|
116
|
+
var semaphoreVerifierAddress = "0x79f46b94d134109EbcbbddBAeD0E88790409A0e4";
|
|
117
|
+
var semaphoreVerifierAbi = [
|
|
118
|
+
{
|
|
119
|
+
inputs: [
|
|
120
|
+
{
|
|
121
|
+
internalType: "uint256[8]",
|
|
122
|
+
name: "proof",
|
|
123
|
+
type: "uint256[8]"
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
name: "compressProof",
|
|
127
|
+
outputs: [
|
|
128
|
+
{
|
|
129
|
+
internalType: "uint256[4]",
|
|
130
|
+
name: "compressed",
|
|
131
|
+
type: "uint256[4]"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
stateMutability: "view",
|
|
135
|
+
type: "function"
|
|
136
|
+
}
|
|
137
|
+
];
|
|
138
|
+
var compressAndPadProof = async (proof, rpcUrl) => {
|
|
139
|
+
try {
|
|
140
|
+
const publicClient = (0, import_viem.createPublicClient)({
|
|
141
|
+
chain: import_chains.worldchain,
|
|
142
|
+
transport: (0, import_viem.http)(
|
|
143
|
+
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
144
|
+
)
|
|
145
|
+
});
|
|
146
|
+
const decodedProof = (0, import_viem.decodeAbiParameters)(
|
|
147
|
+
[{ type: "uint256[8]" }],
|
|
148
|
+
proof
|
|
149
|
+
)[0];
|
|
150
|
+
const compressedProof = await publicClient.readContract({
|
|
151
|
+
address: semaphoreVerifierAddress,
|
|
152
|
+
abi: semaphoreVerifierAbi,
|
|
153
|
+
functionName: "compressProof",
|
|
154
|
+
args: [decodedProof]
|
|
155
|
+
});
|
|
156
|
+
const paddedProof = [...compressedProof, 0n, 0n, 0n, 0n];
|
|
157
|
+
return (0, import_viem.encodeAbiParameters)([{ type: "uint256[8]" }], [paddedProof]);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.log("Failed to compress proof", {
|
|
160
|
+
e,
|
|
161
|
+
proof
|
|
162
|
+
});
|
|
163
|
+
return proof;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// helpers/siwe/siwe.ts
|
|
168
|
+
var import_viem2 = require("viem");
|
|
169
|
+
var import_chains2 = require("viem/chains");
|
|
114
170
|
var PREAMBLE = " wants you to sign in with your Ethereum account:";
|
|
115
171
|
var URI_TAG = "URI: ";
|
|
116
172
|
var VERSION_TAG = "Version: ";
|
|
@@ -271,16 +327,16 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
271
327
|
`Request ID mismatch. Got: ${siweMessageData.request_id}, Expected: ${requestId}`
|
|
272
328
|
);
|
|
273
329
|
}
|
|
274
|
-
let provider = userProvider || (0,
|
|
330
|
+
let provider = userProvider || (0, import_viem2.createPublicClient)({ chain: import_chains2.worldchain, transport: (0, import_viem2.http)() });
|
|
275
331
|
const signedMessage = `${ERC_191_PREFIX}${message.length}${message}`;
|
|
276
|
-
const hashedMessage = (0,
|
|
277
|
-
const contract = (0,
|
|
332
|
+
const hashedMessage = (0, import_viem2.hashMessage)(signedMessage);
|
|
333
|
+
const contract = (0, import_viem2.getContract)({
|
|
278
334
|
address,
|
|
279
335
|
abi: SAFE_CONTRACT_ABI,
|
|
280
336
|
client: provider
|
|
281
337
|
});
|
|
282
338
|
try {
|
|
283
|
-
const recoveredAddress = await (0,
|
|
339
|
+
const recoveredAddress = await (0, import_viem2.recoverAddress)({
|
|
284
340
|
hash: hashedMessage,
|
|
285
341
|
signature: `0x${signature}`
|
|
286
342
|
});
|
|
@@ -325,7 +381,7 @@ var processPayload = (payload) => {
|
|
|
325
381
|
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
326
382
|
return payload;
|
|
327
383
|
}
|
|
328
|
-
if (typeof payload === "number") {
|
|
384
|
+
if (typeof payload === "number" || typeof payload === "bigint") {
|
|
329
385
|
return String(payload);
|
|
330
386
|
}
|
|
331
387
|
if (Array.isArray(payload)) {
|
|
@@ -386,10 +442,12 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
386
442
|
Command2["ShareContacts"] = "share-contacts";
|
|
387
443
|
Command2["RequestPermission"] = "request-permission";
|
|
388
444
|
Command2["GetPermissions"] = "get-permissions";
|
|
445
|
+
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
389
446
|
return Command2;
|
|
390
447
|
})(Command || {});
|
|
391
448
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
392
449
|
Permission2["Notifications"] = "notifications";
|
|
450
|
+
Permission2["Contacts"] = "contacts";
|
|
393
451
|
return Permission2;
|
|
394
452
|
})(Permission || {});
|
|
395
453
|
|
|
@@ -411,6 +469,7 @@ var VerificationErrorMessage = {
|
|
|
411
469
|
};
|
|
412
470
|
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
413
471
|
PaymentErrorCodes2["InputError"] = "input_error";
|
|
472
|
+
PaymentErrorCodes2["UserRejected"] = "user_rejected";
|
|
414
473
|
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
415
474
|
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
416
475
|
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
@@ -421,6 +480,7 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
421
480
|
})(PaymentErrorCodes || {});
|
|
422
481
|
var PaymentErrorMessage = {
|
|
423
482
|
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
483
|
+
["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
|
|
424
484
|
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
425
485
|
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
426
486
|
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
@@ -555,6 +615,15 @@ var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
|
555
615
|
var GetPermissionsErrorMessage = {
|
|
556
616
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
557
617
|
};
|
|
618
|
+
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
619
|
+
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
620
|
+
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
621
|
+
return SendHapticFeedbackErrorCodes2;
|
|
622
|
+
})(SendHapticFeedbackErrorCodes || {});
|
|
623
|
+
var SendHapticFeedbackErrorMessage = {
|
|
624
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
625
|
+
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
626
|
+
};
|
|
558
627
|
|
|
559
628
|
// helpers/send-webview-event.ts
|
|
560
629
|
var sendWebviewEvent = (payload) => {
|
|
@@ -576,6 +645,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
576
645
|
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
577
646
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
578
647
|
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
648
|
+
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
579
649
|
return ResponseEvent2;
|
|
580
650
|
})(ResponseEvent || {});
|
|
581
651
|
|
|
@@ -603,6 +673,21 @@ var _MiniKit = class _MiniKit {
|
|
|
603
673
|
originalHandler(payload);
|
|
604
674
|
};
|
|
605
675
|
this.listeners[event] = wrappedHandler;
|
|
676
|
+
} else if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
677
|
+
const originalHandler = handler;
|
|
678
|
+
const wrappedHandler = (payload) => {
|
|
679
|
+
if (payload.status === "success" && payload.verification_level === import_idkit_core3.VerificationLevel.Orb) {
|
|
680
|
+
compressAndPadProof(payload.proof).then(
|
|
681
|
+
(compressedProof) => {
|
|
682
|
+
payload.proof = compressedProof;
|
|
683
|
+
originalHandler(payload);
|
|
684
|
+
}
|
|
685
|
+
);
|
|
686
|
+
} else {
|
|
687
|
+
originalHandler(payload);
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
this.listeners[event] = wrappedHandler;
|
|
606
691
|
} else {
|
|
607
692
|
this.listeners[event] = handler;
|
|
608
693
|
}
|
|
@@ -628,18 +713,18 @@ var _MiniKit = class _MiniKit {
|
|
|
628
713
|
commandPayload = executor();
|
|
629
714
|
});
|
|
630
715
|
}
|
|
631
|
-
static commandsValid(
|
|
632
|
-
return Object.entries(this.
|
|
633
|
-
([
|
|
634
|
-
const commandInput =
|
|
635
|
-
(command) => command.name ===
|
|
716
|
+
static commandsValid(worldAppSupportedCommands) {
|
|
717
|
+
return Object.entries(this.miniKitCommandVersion).every(
|
|
718
|
+
([minikitCommandName, version]) => {
|
|
719
|
+
const commandInput = worldAppSupportedCommands.find(
|
|
720
|
+
(command) => command.name === minikitCommandName
|
|
636
721
|
);
|
|
637
722
|
if (!commandInput) {
|
|
638
723
|
console.error(
|
|
639
|
-
`Command ${
|
|
724
|
+
`Command ${minikitCommandName} is not supported by the app. Try updating the app version`
|
|
640
725
|
);
|
|
641
726
|
} else {
|
|
642
|
-
_MiniKit.isCommandAvailable[
|
|
727
|
+
_MiniKit.isCommandAvailable[minikitCommandName] = true;
|
|
643
728
|
}
|
|
644
729
|
return commandInput ? commandInput.supported_versions.includes(version) : false;
|
|
645
730
|
}
|
|
@@ -699,7 +784,7 @@ var _MiniKit = class _MiniKit {
|
|
|
699
784
|
}
|
|
700
785
|
};
|
|
701
786
|
_MiniKit.MINIKIT_VERSION = 1;
|
|
702
|
-
_MiniKit.
|
|
787
|
+
_MiniKit.miniKitCommandVersion = {
|
|
703
788
|
["verify" /* Verify */]: 1,
|
|
704
789
|
["pay" /* Pay */]: 1,
|
|
705
790
|
["wallet-auth" /* WalletAuth */]: 1,
|
|
@@ -708,7 +793,8 @@ _MiniKit.commandVersion = {
|
|
|
708
793
|
["sign-typed-data" /* SignTypedData */]: 1,
|
|
709
794
|
["share-contacts" /* ShareContacts */]: 1,
|
|
710
795
|
["request-permission" /* RequestPermission */]: 1,
|
|
711
|
-
["get-permissions" /* GetPermissions */]: 1
|
|
796
|
+
["get-permissions" /* GetPermissions */]: 1,
|
|
797
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
712
798
|
};
|
|
713
799
|
_MiniKit.isCommandAvailable = {
|
|
714
800
|
["verify" /* Verify */]: false,
|
|
@@ -719,7 +805,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
719
805
|
["sign-typed-data" /* SignTypedData */]: false,
|
|
720
806
|
["share-contacts" /* ShareContacts */]: false,
|
|
721
807
|
["request-permission" /* RequestPermission */]: false,
|
|
722
|
-
["get-permissions" /* GetPermissions */]: false
|
|
808
|
+
["get-permissions" /* GetPermissions */]: false,
|
|
809
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
723
810
|
};
|
|
724
811
|
_MiniKit.listeners = {
|
|
725
812
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -739,6 +826,8 @@ _MiniKit.listeners = {
|
|
|
739
826
|
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
740
827
|
},
|
|
741
828
|
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
829
|
+
},
|
|
830
|
+
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
742
831
|
}
|
|
743
832
|
};
|
|
744
833
|
_MiniKit.appId = null;
|
|
@@ -772,7 +861,7 @@ _MiniKit.commands = {
|
|
|
772
861
|
};
|
|
773
862
|
sendMiniKitEvent({
|
|
774
863
|
command: "verify" /* Verify */,
|
|
775
|
-
version: _MiniKit.
|
|
864
|
+
version: _MiniKit.miniKitCommandVersion["verify" /* Verify */],
|
|
776
865
|
payload: eventPayload
|
|
777
866
|
});
|
|
778
867
|
return eventPayload;
|
|
@@ -794,7 +883,7 @@ _MiniKit.commands = {
|
|
|
794
883
|
};
|
|
795
884
|
sendMiniKitEvent({
|
|
796
885
|
command: "pay" /* Pay */,
|
|
797
|
-
version: _MiniKit.
|
|
886
|
+
version: _MiniKit.miniKitCommandVersion["pay" /* Pay */],
|
|
798
887
|
payload: eventPayload
|
|
799
888
|
});
|
|
800
889
|
return eventPayload;
|
|
@@ -838,7 +927,7 @@ _MiniKit.commands = {
|
|
|
838
927
|
const walletAuthPayload = { siweMessage };
|
|
839
928
|
sendMiniKitEvent({
|
|
840
929
|
command: "wallet-auth" /* WalletAuth */,
|
|
841
|
-
version: _MiniKit.
|
|
930
|
+
version: _MiniKit.miniKitCommandVersion["wallet-auth" /* WalletAuth */],
|
|
842
931
|
payload: walletAuthPayload
|
|
843
932
|
});
|
|
844
933
|
return walletAuthPayload;
|
|
@@ -853,7 +942,7 @@ _MiniKit.commands = {
|
|
|
853
942
|
const validatedPayload = validateSendTransactionPayload(payload);
|
|
854
943
|
sendMiniKitEvent({
|
|
855
944
|
command: "send-transaction" /* SendTransaction */,
|
|
856
|
-
version:
|
|
945
|
+
version: _MiniKit.miniKitCommandVersion["send-transaction" /* SendTransaction */],
|
|
857
946
|
payload: validatedPayload
|
|
858
947
|
});
|
|
859
948
|
return validatedPayload;
|
|
@@ -867,7 +956,7 @@ _MiniKit.commands = {
|
|
|
867
956
|
}
|
|
868
957
|
sendMiniKitEvent({
|
|
869
958
|
command: "sign-message" /* SignMessage */,
|
|
870
|
-
version:
|
|
959
|
+
version: _MiniKit.miniKitCommandVersion["sign-message" /* SignMessage */],
|
|
871
960
|
payload
|
|
872
961
|
});
|
|
873
962
|
return payload;
|
|
@@ -881,7 +970,7 @@ _MiniKit.commands = {
|
|
|
881
970
|
}
|
|
882
971
|
sendMiniKitEvent({
|
|
883
972
|
command: "sign-typed-data" /* SignTypedData */,
|
|
884
|
-
version:
|
|
973
|
+
version: _MiniKit.miniKitCommandVersion["sign-typed-data" /* SignTypedData */],
|
|
885
974
|
payload
|
|
886
975
|
});
|
|
887
976
|
return payload;
|
|
@@ -895,7 +984,7 @@ _MiniKit.commands = {
|
|
|
895
984
|
}
|
|
896
985
|
sendMiniKitEvent({
|
|
897
986
|
command: "share-contacts" /* ShareContacts */,
|
|
898
|
-
version:
|
|
987
|
+
version: _MiniKit.miniKitCommandVersion["share-contacts" /* ShareContacts */],
|
|
899
988
|
payload
|
|
900
989
|
});
|
|
901
990
|
return payload;
|
|
@@ -909,7 +998,7 @@ _MiniKit.commands = {
|
|
|
909
998
|
}
|
|
910
999
|
sendMiniKitEvent({
|
|
911
1000
|
command: "request-permission" /* RequestPermission */,
|
|
912
|
-
version:
|
|
1001
|
+
version: _MiniKit.miniKitCommandVersion["request-permission" /* RequestPermission */],
|
|
913
1002
|
payload
|
|
914
1003
|
});
|
|
915
1004
|
return payload;
|
|
@@ -923,12 +1012,26 @@ _MiniKit.commands = {
|
|
|
923
1012
|
}
|
|
924
1013
|
sendMiniKitEvent({
|
|
925
1014
|
command: "get-permissions" /* GetPermissions */,
|
|
926
|
-
version:
|
|
1015
|
+
version: _MiniKit.miniKitCommandVersion["get-permissions" /* GetPermissions */],
|
|
927
1016
|
payload: {}
|
|
928
1017
|
});
|
|
929
1018
|
return {
|
|
930
1019
|
status: "sent"
|
|
931
1020
|
};
|
|
1021
|
+
},
|
|
1022
|
+
sendHapticFeedback: (payload) => {
|
|
1023
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-haptic-feedback" /* SendHapticFeedback */]) {
|
|
1024
|
+
console.error(
|
|
1025
|
+
"'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1026
|
+
);
|
|
1027
|
+
return null;
|
|
1028
|
+
}
|
|
1029
|
+
sendMiniKitEvent({
|
|
1030
|
+
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
1031
|
+
version: _MiniKit.miniKitCommandVersion["send-haptic-feedback" /* SendHapticFeedback */],
|
|
1032
|
+
payload
|
|
1033
|
+
});
|
|
1034
|
+
return payload;
|
|
932
1035
|
}
|
|
933
1036
|
};
|
|
934
1037
|
/**
|
|
@@ -950,6 +1053,11 @@ _MiniKit.commandsAsync = {
|
|
|
950
1053
|
"verify" /* Verify */,
|
|
951
1054
|
() => _MiniKit.commands.verify(payload)
|
|
952
1055
|
);
|
|
1056
|
+
if (response.finalPayload.status === "success" && response.finalPayload.verification_level === import_idkit_core3.VerificationLevel.Orb) {
|
|
1057
|
+
response.finalPayload.proof = await compressAndPadProof(
|
|
1058
|
+
response.finalPayload.proof
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
953
1061
|
resolve(response);
|
|
954
1062
|
} catch (error) {
|
|
955
1063
|
reject(error);
|
|
@@ -1067,6 +1175,20 @@ _MiniKit.commandsAsync = {
|
|
|
1067
1175
|
reject(error);
|
|
1068
1176
|
}
|
|
1069
1177
|
});
|
|
1178
|
+
},
|
|
1179
|
+
sendHapticFeedback: async (payload) => {
|
|
1180
|
+
return new Promise(async (resolve, reject) => {
|
|
1181
|
+
try {
|
|
1182
|
+
const response = await _MiniKit.awaitCommand(
|
|
1183
|
+
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
1184
|
+
"send-haptic-feedback" /* SendHapticFeedback */,
|
|
1185
|
+
() => _MiniKit.commands.sendHapticFeedback(payload)
|
|
1186
|
+
);
|
|
1187
|
+
resolve(response);
|
|
1188
|
+
} catch (error) {
|
|
1189
|
+
reject(error);
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1070
1192
|
}
|
|
1071
1193
|
};
|
|
1072
1194
|
var MiniKit = _MiniKit;
|
|
@@ -1076,8 +1198,8 @@ var import_idkit_core4 = require("@worldcoin/idkit-core");
|
|
|
1076
1198
|
var import_backend = require("@worldcoin/idkit-core/backend");
|
|
1077
1199
|
|
|
1078
1200
|
// helpers/address-book/index.ts
|
|
1079
|
-
var
|
|
1080
|
-
var
|
|
1201
|
+
var import_viem3 = require("viem");
|
|
1202
|
+
var import_chains3 = require("viem/chains");
|
|
1081
1203
|
var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
|
|
1082
1204
|
var addressVerifiedUntilAbi = [
|
|
1083
1205
|
{
|
|
@@ -1101,9 +1223,9 @@ var addressVerifiedUntilAbi = [
|
|
|
1101
1223
|
}
|
|
1102
1224
|
];
|
|
1103
1225
|
var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
1104
|
-
const publicClient = (0,
|
|
1105
|
-
chain:
|
|
1106
|
-
transport: (0,
|
|
1226
|
+
const publicClient = (0, import_viem3.createPublicClient)({
|
|
1227
|
+
chain: import_chains3.worldchain,
|
|
1228
|
+
transport: (0, import_viem3.http)(
|
|
1107
1229
|
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
1108
1230
|
)
|
|
1109
1231
|
});
|
|
@@ -1143,6 +1265,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
1143
1265
|
RequestPermissionErrorMessage,
|
|
1144
1266
|
ResponseEvent,
|
|
1145
1267
|
SAFE_CONTRACT_ABI,
|
|
1268
|
+
SendHapticFeedbackErrorCodes,
|
|
1269
|
+
SendHapticFeedbackErrorMessage,
|
|
1146
1270
|
SendTransactionErrorCodes,
|
|
1147
1271
|
SendTransactionErrorMessage,
|
|
1148
1272
|
ShareContactsErrorCodes,
|
package/build/index.d.cts
CHANGED
|
@@ -7,6 +7,7 @@ import { Client } from 'viem';
|
|
|
7
7
|
declare const VerificationErrorMessage: Record<AppErrorCodes, string>;
|
|
8
8
|
declare enum PaymentErrorCodes {
|
|
9
9
|
InputError = "input_error",
|
|
10
|
+
UserRejected = "user_rejected",
|
|
10
11
|
PaymentRejected = "payment_rejected",
|
|
11
12
|
InvalidReceiver = "invalid_receiver",
|
|
12
13
|
InsufficientBalance = "insufficient_balance",
|
|
@@ -120,6 +121,14 @@ declare enum GetPermissionsErrorCodes {
|
|
|
120
121
|
declare const GetPermissionsErrorMessage: {
|
|
121
122
|
generic_error: string;
|
|
122
123
|
};
|
|
124
|
+
declare enum SendHapticFeedbackErrorCodes {
|
|
125
|
+
GenericError = "generic_error",
|
|
126
|
+
UserRejected = "user_rejected"
|
|
127
|
+
}
|
|
128
|
+
declare const SendHapticFeedbackErrorMessage: {
|
|
129
|
+
generic_error: string;
|
|
130
|
+
user_rejected: string;
|
|
131
|
+
};
|
|
123
132
|
|
|
124
133
|
declare enum Tokens {
|
|
125
134
|
USDCE = "USDCE",
|
|
@@ -161,7 +170,8 @@ declare enum Command {
|
|
|
161
170
|
SignTypedData = "sign-typed-data",
|
|
162
171
|
ShareContacts = "share-contacts",
|
|
163
172
|
RequestPermission = "request-permission",
|
|
164
|
-
GetPermissions = "get-permissions"
|
|
173
|
+
GetPermissions = "get-permissions",
|
|
174
|
+
SendHapticFeedback = "send-haptic-feedback"
|
|
165
175
|
}
|
|
166
176
|
type WebViewBasePayload = {
|
|
167
177
|
command: Command;
|
|
@@ -231,7 +241,8 @@ type ShareContactsInput = {
|
|
|
231
241
|
};
|
|
232
242
|
type ShareContactsPayload = ShareContactsInput;
|
|
233
243
|
declare enum Permission {
|
|
234
|
-
Notifications = "notifications"
|
|
244
|
+
Notifications = "notifications",
|
|
245
|
+
Contacts = "contacts"
|
|
235
246
|
}
|
|
236
247
|
type RequestPermissionInput = {
|
|
237
248
|
permission: Permission;
|
|
@@ -239,6 +250,17 @@ type RequestPermissionInput = {
|
|
|
239
250
|
type RequestPermissionPayload = RequestPermissionInput;
|
|
240
251
|
type GetPermissionsInput = {};
|
|
241
252
|
type GetPermissionsPayload = GetPermissionsInput;
|
|
253
|
+
type SendHapticFeedbackInput = {
|
|
254
|
+
hapticsType: 'notification';
|
|
255
|
+
style: 'error' | 'success' | 'warning';
|
|
256
|
+
} | {
|
|
257
|
+
hapticsType: 'selection-changed';
|
|
258
|
+
style?: never;
|
|
259
|
+
} | {
|
|
260
|
+
hapticsType: 'impact';
|
|
261
|
+
style: 'light' | 'medium' | 'heavy';
|
|
262
|
+
};
|
|
263
|
+
type SendHapticFeedbackPayload = SendHapticFeedbackInput;
|
|
242
264
|
type CommandReturnPayloadMap = {
|
|
243
265
|
[Command.Verify]: VerifyCommandPayload;
|
|
244
266
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -249,6 +271,7 @@ type CommandReturnPayloadMap = {
|
|
|
249
271
|
[Command.ShareContacts]: ShareContactsPayload;
|
|
250
272
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
251
273
|
[Command.GetPermissions]: GetPermissionsPayload;
|
|
274
|
+
[Command.SendHapticFeedback]: SendHapticFeedbackPayload;
|
|
252
275
|
};
|
|
253
276
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
254
277
|
|
|
@@ -261,7 +284,8 @@ declare enum ResponseEvent {
|
|
|
261
284
|
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
262
285
|
MiniAppShareContacts = "miniapp-share-contacts",
|
|
263
286
|
MiniAppRequestPermission = "miniapp-request-permission",
|
|
264
|
-
MiniAppGetPermissions = "miniapp-get-permissions"
|
|
287
|
+
MiniAppGetPermissions = "miniapp-get-permissions",
|
|
288
|
+
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback"
|
|
265
289
|
}
|
|
266
290
|
type MiniAppVerifyActionSuccessPayload = {
|
|
267
291
|
status: 'success';
|
|
@@ -398,6 +422,17 @@ type MiniAppGetPermissionsErrorPayload = {
|
|
|
398
422
|
version: number;
|
|
399
423
|
};
|
|
400
424
|
type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
|
|
425
|
+
type MiniAppSendHapticFeedbackSuccessPayload = {
|
|
426
|
+
status: 'success';
|
|
427
|
+
version: number;
|
|
428
|
+
timestamp: string;
|
|
429
|
+
};
|
|
430
|
+
type MiniAppSendHapticFeedbackErrorPayload = {
|
|
431
|
+
status: 'error';
|
|
432
|
+
error_code: SendHapticFeedbackErrorCodes;
|
|
433
|
+
version: number;
|
|
434
|
+
};
|
|
435
|
+
type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
|
|
401
436
|
type EventPayloadMap = {
|
|
402
437
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
403
438
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -408,6 +443,7 @@ type EventPayloadMap = {
|
|
|
408
443
|
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
409
444
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
410
445
|
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
446
|
+
[ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
|
|
411
447
|
};
|
|
412
448
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
413
449
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -420,7 +456,7 @@ type User = {
|
|
|
420
456
|
|
|
421
457
|
declare class MiniKit {
|
|
422
458
|
private static readonly MINIKIT_VERSION;
|
|
423
|
-
private static readonly
|
|
459
|
+
private static readonly miniKitCommandVersion;
|
|
424
460
|
private static isCommandAvailable;
|
|
425
461
|
private static listeners;
|
|
426
462
|
static appId: string | null;
|
|
@@ -448,6 +484,7 @@ declare class MiniKit {
|
|
|
448
484
|
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
449
485
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
450
486
|
getPermissions: () => GetPermissionsPayload | null;
|
|
487
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
451
488
|
};
|
|
452
489
|
/**
|
|
453
490
|
* This object contains async versions of all the commands.
|
|
@@ -469,6 +506,7 @@ declare class MiniKit {
|
|
|
469
506
|
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
470
507
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
471
508
|
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
509
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
472
510
|
};
|
|
473
511
|
}
|
|
474
512
|
|
|
@@ -512,4 +550,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
512
550
|
|
|
513
551
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
514
552
|
|
|
515
|
-
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 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, 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 };
|
|
553
|
+
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
|
@@ -7,6 +7,7 @@ import { Client } from 'viem';
|
|
|
7
7
|
declare const VerificationErrorMessage: Record<AppErrorCodes, string>;
|
|
8
8
|
declare enum PaymentErrorCodes {
|
|
9
9
|
InputError = "input_error",
|
|
10
|
+
UserRejected = "user_rejected",
|
|
10
11
|
PaymentRejected = "payment_rejected",
|
|
11
12
|
InvalidReceiver = "invalid_receiver",
|
|
12
13
|
InsufficientBalance = "insufficient_balance",
|
|
@@ -120,6 +121,14 @@ declare enum GetPermissionsErrorCodes {
|
|
|
120
121
|
declare const GetPermissionsErrorMessage: {
|
|
121
122
|
generic_error: string;
|
|
122
123
|
};
|
|
124
|
+
declare enum SendHapticFeedbackErrorCodes {
|
|
125
|
+
GenericError = "generic_error",
|
|
126
|
+
UserRejected = "user_rejected"
|
|
127
|
+
}
|
|
128
|
+
declare const SendHapticFeedbackErrorMessage: {
|
|
129
|
+
generic_error: string;
|
|
130
|
+
user_rejected: string;
|
|
131
|
+
};
|
|
123
132
|
|
|
124
133
|
declare enum Tokens {
|
|
125
134
|
USDCE = "USDCE",
|
|
@@ -161,7 +170,8 @@ declare enum Command {
|
|
|
161
170
|
SignTypedData = "sign-typed-data",
|
|
162
171
|
ShareContacts = "share-contacts",
|
|
163
172
|
RequestPermission = "request-permission",
|
|
164
|
-
GetPermissions = "get-permissions"
|
|
173
|
+
GetPermissions = "get-permissions",
|
|
174
|
+
SendHapticFeedback = "send-haptic-feedback"
|
|
165
175
|
}
|
|
166
176
|
type WebViewBasePayload = {
|
|
167
177
|
command: Command;
|
|
@@ -231,7 +241,8 @@ type ShareContactsInput = {
|
|
|
231
241
|
};
|
|
232
242
|
type ShareContactsPayload = ShareContactsInput;
|
|
233
243
|
declare enum Permission {
|
|
234
|
-
Notifications = "notifications"
|
|
244
|
+
Notifications = "notifications",
|
|
245
|
+
Contacts = "contacts"
|
|
235
246
|
}
|
|
236
247
|
type RequestPermissionInput = {
|
|
237
248
|
permission: Permission;
|
|
@@ -239,6 +250,17 @@ type RequestPermissionInput = {
|
|
|
239
250
|
type RequestPermissionPayload = RequestPermissionInput;
|
|
240
251
|
type GetPermissionsInput = {};
|
|
241
252
|
type GetPermissionsPayload = GetPermissionsInput;
|
|
253
|
+
type SendHapticFeedbackInput = {
|
|
254
|
+
hapticsType: 'notification';
|
|
255
|
+
style: 'error' | 'success' | 'warning';
|
|
256
|
+
} | {
|
|
257
|
+
hapticsType: 'selection-changed';
|
|
258
|
+
style?: never;
|
|
259
|
+
} | {
|
|
260
|
+
hapticsType: 'impact';
|
|
261
|
+
style: 'light' | 'medium' | 'heavy';
|
|
262
|
+
};
|
|
263
|
+
type SendHapticFeedbackPayload = SendHapticFeedbackInput;
|
|
242
264
|
type CommandReturnPayloadMap = {
|
|
243
265
|
[Command.Verify]: VerifyCommandPayload;
|
|
244
266
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -249,6 +271,7 @@ type CommandReturnPayloadMap = {
|
|
|
249
271
|
[Command.ShareContacts]: ShareContactsPayload;
|
|
250
272
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
251
273
|
[Command.GetPermissions]: GetPermissionsPayload;
|
|
274
|
+
[Command.SendHapticFeedback]: SendHapticFeedbackPayload;
|
|
252
275
|
};
|
|
253
276
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
254
277
|
|
|
@@ -261,7 +284,8 @@ declare enum ResponseEvent {
|
|
|
261
284
|
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
262
285
|
MiniAppShareContacts = "miniapp-share-contacts",
|
|
263
286
|
MiniAppRequestPermission = "miniapp-request-permission",
|
|
264
|
-
MiniAppGetPermissions = "miniapp-get-permissions"
|
|
287
|
+
MiniAppGetPermissions = "miniapp-get-permissions",
|
|
288
|
+
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback"
|
|
265
289
|
}
|
|
266
290
|
type MiniAppVerifyActionSuccessPayload = {
|
|
267
291
|
status: 'success';
|
|
@@ -398,6 +422,17 @@ type MiniAppGetPermissionsErrorPayload = {
|
|
|
398
422
|
version: number;
|
|
399
423
|
};
|
|
400
424
|
type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
|
|
425
|
+
type MiniAppSendHapticFeedbackSuccessPayload = {
|
|
426
|
+
status: 'success';
|
|
427
|
+
version: number;
|
|
428
|
+
timestamp: string;
|
|
429
|
+
};
|
|
430
|
+
type MiniAppSendHapticFeedbackErrorPayload = {
|
|
431
|
+
status: 'error';
|
|
432
|
+
error_code: SendHapticFeedbackErrorCodes;
|
|
433
|
+
version: number;
|
|
434
|
+
};
|
|
435
|
+
type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
|
|
401
436
|
type EventPayloadMap = {
|
|
402
437
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
403
438
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -408,6 +443,7 @@ type EventPayloadMap = {
|
|
|
408
443
|
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
409
444
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
410
445
|
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
446
|
+
[ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
|
|
411
447
|
};
|
|
412
448
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
413
449
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -420,7 +456,7 @@ type User = {
|
|
|
420
456
|
|
|
421
457
|
declare class MiniKit {
|
|
422
458
|
private static readonly MINIKIT_VERSION;
|
|
423
|
-
private static readonly
|
|
459
|
+
private static readonly miniKitCommandVersion;
|
|
424
460
|
private static isCommandAvailable;
|
|
425
461
|
private static listeners;
|
|
426
462
|
static appId: string | null;
|
|
@@ -448,6 +484,7 @@ declare class MiniKit {
|
|
|
448
484
|
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
449
485
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
450
486
|
getPermissions: () => GetPermissionsPayload | null;
|
|
487
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
451
488
|
};
|
|
452
489
|
/**
|
|
453
490
|
* This object contains async versions of all the commands.
|
|
@@ -469,6 +506,7 @@ declare class MiniKit {
|
|
|
469
506
|
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
470
507
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
471
508
|
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
509
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
472
510
|
};
|
|
473
511
|
}
|
|
474
512
|
|
|
@@ -512,4 +550,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
512
550
|
|
|
513
551
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
514
552
|
|
|
515
|
-
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 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, 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 };
|
|
553
|
+
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
|
@@ -48,15 +48,74 @@ var validatePaymentPayload = (payload) => {
|
|
|
48
48
|
return true;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
// helpers/
|
|
51
|
+
// helpers/proof/index.ts
|
|
52
52
|
import {
|
|
53
53
|
createPublicClient,
|
|
54
|
+
decodeAbiParameters,
|
|
55
|
+
encodeAbiParameters,
|
|
56
|
+
http
|
|
57
|
+
} from "viem";
|
|
58
|
+
import { worldchain } from "viem/chains";
|
|
59
|
+
var semaphoreVerifierAddress = "0x79f46b94d134109EbcbbddBAeD0E88790409A0e4";
|
|
60
|
+
var semaphoreVerifierAbi = [
|
|
61
|
+
{
|
|
62
|
+
inputs: [
|
|
63
|
+
{
|
|
64
|
+
internalType: "uint256[8]",
|
|
65
|
+
name: "proof",
|
|
66
|
+
type: "uint256[8]"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
name: "compressProof",
|
|
70
|
+
outputs: [
|
|
71
|
+
{
|
|
72
|
+
internalType: "uint256[4]",
|
|
73
|
+
name: "compressed",
|
|
74
|
+
type: "uint256[4]"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
stateMutability: "view",
|
|
78
|
+
type: "function"
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
var compressAndPadProof = async (proof, rpcUrl) => {
|
|
82
|
+
try {
|
|
83
|
+
const publicClient = createPublicClient({
|
|
84
|
+
chain: worldchain,
|
|
85
|
+
transport: http(
|
|
86
|
+
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
87
|
+
)
|
|
88
|
+
});
|
|
89
|
+
const decodedProof = decodeAbiParameters(
|
|
90
|
+
[{ type: "uint256[8]" }],
|
|
91
|
+
proof
|
|
92
|
+
)[0];
|
|
93
|
+
const compressedProof = await publicClient.readContract({
|
|
94
|
+
address: semaphoreVerifierAddress,
|
|
95
|
+
abi: semaphoreVerifierAbi,
|
|
96
|
+
functionName: "compressProof",
|
|
97
|
+
args: [decodedProof]
|
|
98
|
+
});
|
|
99
|
+
const paddedProof = [...compressedProof, 0n, 0n, 0n, 0n];
|
|
100
|
+
return encodeAbiParameters([{ type: "uint256[8]" }], [paddedProof]);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.log("Failed to compress proof", {
|
|
103
|
+
e,
|
|
104
|
+
proof
|
|
105
|
+
});
|
|
106
|
+
return proof;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// helpers/siwe/siwe.ts
|
|
111
|
+
import {
|
|
112
|
+
createPublicClient as createPublicClient2,
|
|
54
113
|
getContract,
|
|
55
114
|
hashMessage,
|
|
56
|
-
http,
|
|
115
|
+
http as http2,
|
|
57
116
|
recoverAddress
|
|
58
117
|
} from "viem";
|
|
59
|
-
import { worldchain } from "viem/chains";
|
|
118
|
+
import { worldchain as worldchain2 } from "viem/chains";
|
|
60
119
|
var PREAMBLE = " wants you to sign in with your Ethereum account:";
|
|
61
120
|
var URI_TAG = "URI: ";
|
|
62
121
|
var VERSION_TAG = "Version: ";
|
|
@@ -217,7 +276,7 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
217
276
|
`Request ID mismatch. Got: ${siweMessageData.request_id}, Expected: ${requestId}`
|
|
218
277
|
);
|
|
219
278
|
}
|
|
220
|
-
let provider = userProvider ||
|
|
279
|
+
let provider = userProvider || createPublicClient2({ chain: worldchain2, transport: http2() });
|
|
221
280
|
const signedMessage = `${ERC_191_PREFIX}${message.length}${message}`;
|
|
222
281
|
const hashedMessage = hashMessage(signedMessage);
|
|
223
282
|
const contract = getContract({
|
|
@@ -271,7 +330,7 @@ var processPayload = (payload) => {
|
|
|
271
330
|
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
272
331
|
return payload;
|
|
273
332
|
}
|
|
274
|
-
if (typeof payload === "number") {
|
|
333
|
+
if (typeof payload === "number" || typeof payload === "bigint") {
|
|
275
334
|
return String(payload);
|
|
276
335
|
}
|
|
277
336
|
if (Array.isArray(payload)) {
|
|
@@ -332,10 +391,12 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
332
391
|
Command2["ShareContacts"] = "share-contacts";
|
|
333
392
|
Command2["RequestPermission"] = "request-permission";
|
|
334
393
|
Command2["GetPermissions"] = "get-permissions";
|
|
394
|
+
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
335
395
|
return Command2;
|
|
336
396
|
})(Command || {});
|
|
337
397
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
338
398
|
Permission2["Notifications"] = "notifications";
|
|
399
|
+
Permission2["Contacts"] = "contacts";
|
|
339
400
|
return Permission2;
|
|
340
401
|
})(Permission || {});
|
|
341
402
|
|
|
@@ -357,6 +418,7 @@ var VerificationErrorMessage = {
|
|
|
357
418
|
};
|
|
358
419
|
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
359
420
|
PaymentErrorCodes2["InputError"] = "input_error";
|
|
421
|
+
PaymentErrorCodes2["UserRejected"] = "user_rejected";
|
|
360
422
|
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
361
423
|
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
362
424
|
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
@@ -367,6 +429,7 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
367
429
|
})(PaymentErrorCodes || {});
|
|
368
430
|
var PaymentErrorMessage = {
|
|
369
431
|
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
432
|
+
["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
|
|
370
433
|
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
371
434
|
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
372
435
|
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
@@ -501,6 +564,15 @@ var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
|
501
564
|
var GetPermissionsErrorMessage = {
|
|
502
565
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
503
566
|
};
|
|
567
|
+
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
568
|
+
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
569
|
+
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
570
|
+
return SendHapticFeedbackErrorCodes2;
|
|
571
|
+
})(SendHapticFeedbackErrorCodes || {});
|
|
572
|
+
var SendHapticFeedbackErrorMessage = {
|
|
573
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
574
|
+
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
575
|
+
};
|
|
504
576
|
|
|
505
577
|
// helpers/send-webview-event.ts
|
|
506
578
|
var sendWebviewEvent = (payload) => {
|
|
@@ -522,6 +594,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
522
594
|
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
523
595
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
524
596
|
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
597
|
+
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
525
598
|
return ResponseEvent2;
|
|
526
599
|
})(ResponseEvent || {});
|
|
527
600
|
|
|
@@ -549,6 +622,21 @@ var _MiniKit = class _MiniKit {
|
|
|
549
622
|
originalHandler(payload);
|
|
550
623
|
};
|
|
551
624
|
this.listeners[event] = wrappedHandler;
|
|
625
|
+
} else if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
626
|
+
const originalHandler = handler;
|
|
627
|
+
const wrappedHandler = (payload) => {
|
|
628
|
+
if (payload.status === "success" && payload.verification_level === VerificationLevel.Orb) {
|
|
629
|
+
compressAndPadProof(payload.proof).then(
|
|
630
|
+
(compressedProof) => {
|
|
631
|
+
payload.proof = compressedProof;
|
|
632
|
+
originalHandler(payload);
|
|
633
|
+
}
|
|
634
|
+
);
|
|
635
|
+
} else {
|
|
636
|
+
originalHandler(payload);
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
this.listeners[event] = wrappedHandler;
|
|
552
640
|
} else {
|
|
553
641
|
this.listeners[event] = handler;
|
|
554
642
|
}
|
|
@@ -574,18 +662,18 @@ var _MiniKit = class _MiniKit {
|
|
|
574
662
|
commandPayload = executor();
|
|
575
663
|
});
|
|
576
664
|
}
|
|
577
|
-
static commandsValid(
|
|
578
|
-
return Object.entries(this.
|
|
579
|
-
([
|
|
580
|
-
const commandInput =
|
|
581
|
-
(command) => command.name ===
|
|
665
|
+
static commandsValid(worldAppSupportedCommands) {
|
|
666
|
+
return Object.entries(this.miniKitCommandVersion).every(
|
|
667
|
+
([minikitCommandName, version]) => {
|
|
668
|
+
const commandInput = worldAppSupportedCommands.find(
|
|
669
|
+
(command) => command.name === minikitCommandName
|
|
582
670
|
);
|
|
583
671
|
if (!commandInput) {
|
|
584
672
|
console.error(
|
|
585
|
-
`Command ${
|
|
673
|
+
`Command ${minikitCommandName} is not supported by the app. Try updating the app version`
|
|
586
674
|
);
|
|
587
675
|
} else {
|
|
588
|
-
_MiniKit.isCommandAvailable[
|
|
676
|
+
_MiniKit.isCommandAvailable[minikitCommandName] = true;
|
|
589
677
|
}
|
|
590
678
|
return commandInput ? commandInput.supported_versions.includes(version) : false;
|
|
591
679
|
}
|
|
@@ -645,7 +733,7 @@ var _MiniKit = class _MiniKit {
|
|
|
645
733
|
}
|
|
646
734
|
};
|
|
647
735
|
_MiniKit.MINIKIT_VERSION = 1;
|
|
648
|
-
_MiniKit.
|
|
736
|
+
_MiniKit.miniKitCommandVersion = {
|
|
649
737
|
["verify" /* Verify */]: 1,
|
|
650
738
|
["pay" /* Pay */]: 1,
|
|
651
739
|
["wallet-auth" /* WalletAuth */]: 1,
|
|
@@ -654,7 +742,8 @@ _MiniKit.commandVersion = {
|
|
|
654
742
|
["sign-typed-data" /* SignTypedData */]: 1,
|
|
655
743
|
["share-contacts" /* ShareContacts */]: 1,
|
|
656
744
|
["request-permission" /* RequestPermission */]: 1,
|
|
657
|
-
["get-permissions" /* GetPermissions */]: 1
|
|
745
|
+
["get-permissions" /* GetPermissions */]: 1,
|
|
746
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
658
747
|
};
|
|
659
748
|
_MiniKit.isCommandAvailable = {
|
|
660
749
|
["verify" /* Verify */]: false,
|
|
@@ -665,7 +754,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
665
754
|
["sign-typed-data" /* SignTypedData */]: false,
|
|
666
755
|
["share-contacts" /* ShareContacts */]: false,
|
|
667
756
|
["request-permission" /* RequestPermission */]: false,
|
|
668
|
-
["get-permissions" /* GetPermissions */]: false
|
|
757
|
+
["get-permissions" /* GetPermissions */]: false,
|
|
758
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
669
759
|
};
|
|
670
760
|
_MiniKit.listeners = {
|
|
671
761
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -685,6 +775,8 @@ _MiniKit.listeners = {
|
|
|
685
775
|
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
686
776
|
},
|
|
687
777
|
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
778
|
+
},
|
|
779
|
+
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
688
780
|
}
|
|
689
781
|
};
|
|
690
782
|
_MiniKit.appId = null;
|
|
@@ -718,7 +810,7 @@ _MiniKit.commands = {
|
|
|
718
810
|
};
|
|
719
811
|
sendMiniKitEvent({
|
|
720
812
|
command: "verify" /* Verify */,
|
|
721
|
-
version: _MiniKit.
|
|
813
|
+
version: _MiniKit.miniKitCommandVersion["verify" /* Verify */],
|
|
722
814
|
payload: eventPayload
|
|
723
815
|
});
|
|
724
816
|
return eventPayload;
|
|
@@ -740,7 +832,7 @@ _MiniKit.commands = {
|
|
|
740
832
|
};
|
|
741
833
|
sendMiniKitEvent({
|
|
742
834
|
command: "pay" /* Pay */,
|
|
743
|
-
version: _MiniKit.
|
|
835
|
+
version: _MiniKit.miniKitCommandVersion["pay" /* Pay */],
|
|
744
836
|
payload: eventPayload
|
|
745
837
|
});
|
|
746
838
|
return eventPayload;
|
|
@@ -784,7 +876,7 @@ _MiniKit.commands = {
|
|
|
784
876
|
const walletAuthPayload = { siweMessage };
|
|
785
877
|
sendMiniKitEvent({
|
|
786
878
|
command: "wallet-auth" /* WalletAuth */,
|
|
787
|
-
version: _MiniKit.
|
|
879
|
+
version: _MiniKit.miniKitCommandVersion["wallet-auth" /* WalletAuth */],
|
|
788
880
|
payload: walletAuthPayload
|
|
789
881
|
});
|
|
790
882
|
return walletAuthPayload;
|
|
@@ -799,7 +891,7 @@ _MiniKit.commands = {
|
|
|
799
891
|
const validatedPayload = validateSendTransactionPayload(payload);
|
|
800
892
|
sendMiniKitEvent({
|
|
801
893
|
command: "send-transaction" /* SendTransaction */,
|
|
802
|
-
version:
|
|
894
|
+
version: _MiniKit.miniKitCommandVersion["send-transaction" /* SendTransaction */],
|
|
803
895
|
payload: validatedPayload
|
|
804
896
|
});
|
|
805
897
|
return validatedPayload;
|
|
@@ -813,7 +905,7 @@ _MiniKit.commands = {
|
|
|
813
905
|
}
|
|
814
906
|
sendMiniKitEvent({
|
|
815
907
|
command: "sign-message" /* SignMessage */,
|
|
816
|
-
version:
|
|
908
|
+
version: _MiniKit.miniKitCommandVersion["sign-message" /* SignMessage */],
|
|
817
909
|
payload
|
|
818
910
|
});
|
|
819
911
|
return payload;
|
|
@@ -827,7 +919,7 @@ _MiniKit.commands = {
|
|
|
827
919
|
}
|
|
828
920
|
sendMiniKitEvent({
|
|
829
921
|
command: "sign-typed-data" /* SignTypedData */,
|
|
830
|
-
version:
|
|
922
|
+
version: _MiniKit.miniKitCommandVersion["sign-typed-data" /* SignTypedData */],
|
|
831
923
|
payload
|
|
832
924
|
});
|
|
833
925
|
return payload;
|
|
@@ -841,7 +933,7 @@ _MiniKit.commands = {
|
|
|
841
933
|
}
|
|
842
934
|
sendMiniKitEvent({
|
|
843
935
|
command: "share-contacts" /* ShareContacts */,
|
|
844
|
-
version:
|
|
936
|
+
version: _MiniKit.miniKitCommandVersion["share-contacts" /* ShareContacts */],
|
|
845
937
|
payload
|
|
846
938
|
});
|
|
847
939
|
return payload;
|
|
@@ -855,7 +947,7 @@ _MiniKit.commands = {
|
|
|
855
947
|
}
|
|
856
948
|
sendMiniKitEvent({
|
|
857
949
|
command: "request-permission" /* RequestPermission */,
|
|
858
|
-
version:
|
|
950
|
+
version: _MiniKit.miniKitCommandVersion["request-permission" /* RequestPermission */],
|
|
859
951
|
payload
|
|
860
952
|
});
|
|
861
953
|
return payload;
|
|
@@ -869,12 +961,26 @@ _MiniKit.commands = {
|
|
|
869
961
|
}
|
|
870
962
|
sendMiniKitEvent({
|
|
871
963
|
command: "get-permissions" /* GetPermissions */,
|
|
872
|
-
version:
|
|
964
|
+
version: _MiniKit.miniKitCommandVersion["get-permissions" /* GetPermissions */],
|
|
873
965
|
payload: {}
|
|
874
966
|
});
|
|
875
967
|
return {
|
|
876
968
|
status: "sent"
|
|
877
969
|
};
|
|
970
|
+
},
|
|
971
|
+
sendHapticFeedback: (payload) => {
|
|
972
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-haptic-feedback" /* SendHapticFeedback */]) {
|
|
973
|
+
console.error(
|
|
974
|
+
"'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
|
|
975
|
+
);
|
|
976
|
+
return null;
|
|
977
|
+
}
|
|
978
|
+
sendMiniKitEvent({
|
|
979
|
+
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
980
|
+
version: _MiniKit.miniKitCommandVersion["send-haptic-feedback" /* SendHapticFeedback */],
|
|
981
|
+
payload
|
|
982
|
+
});
|
|
983
|
+
return payload;
|
|
878
984
|
}
|
|
879
985
|
};
|
|
880
986
|
/**
|
|
@@ -896,6 +1002,11 @@ _MiniKit.commandsAsync = {
|
|
|
896
1002
|
"verify" /* Verify */,
|
|
897
1003
|
() => _MiniKit.commands.verify(payload)
|
|
898
1004
|
);
|
|
1005
|
+
if (response.finalPayload.status === "success" && response.finalPayload.verification_level === VerificationLevel.Orb) {
|
|
1006
|
+
response.finalPayload.proof = await compressAndPadProof(
|
|
1007
|
+
response.finalPayload.proof
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
899
1010
|
resolve(response);
|
|
900
1011
|
} catch (error) {
|
|
901
1012
|
reject(error);
|
|
@@ -1013,6 +1124,20 @@ _MiniKit.commandsAsync = {
|
|
|
1013
1124
|
reject(error);
|
|
1014
1125
|
}
|
|
1015
1126
|
});
|
|
1127
|
+
},
|
|
1128
|
+
sendHapticFeedback: async (payload) => {
|
|
1129
|
+
return new Promise(async (resolve, reject) => {
|
|
1130
|
+
try {
|
|
1131
|
+
const response = await _MiniKit.awaitCommand(
|
|
1132
|
+
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
1133
|
+
"send-haptic-feedback" /* SendHapticFeedback */,
|
|
1134
|
+
() => _MiniKit.commands.sendHapticFeedback(payload)
|
|
1135
|
+
);
|
|
1136
|
+
resolve(response);
|
|
1137
|
+
} catch (error) {
|
|
1138
|
+
reject(error);
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1016
1141
|
}
|
|
1017
1142
|
};
|
|
1018
1143
|
var MiniKit = _MiniKit;
|
|
@@ -1024,8 +1149,8 @@ import {
|
|
|
1024
1149
|
} from "@worldcoin/idkit-core/backend";
|
|
1025
1150
|
|
|
1026
1151
|
// helpers/address-book/index.ts
|
|
1027
|
-
import { createPublicClient as
|
|
1028
|
-
import { worldchain as
|
|
1152
|
+
import { createPublicClient as createPublicClient3, http as http3 } from "viem";
|
|
1153
|
+
import { worldchain as worldchain3 } from "viem/chains";
|
|
1029
1154
|
var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
|
|
1030
1155
|
var addressVerifiedUntilAbi = [
|
|
1031
1156
|
{
|
|
@@ -1049,9 +1174,9 @@ var addressVerifiedUntilAbi = [
|
|
|
1049
1174
|
}
|
|
1050
1175
|
];
|
|
1051
1176
|
var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
1052
|
-
const publicClient =
|
|
1053
|
-
chain:
|
|
1054
|
-
transport:
|
|
1177
|
+
const publicClient = createPublicClient3({
|
|
1178
|
+
chain: worldchain3,
|
|
1179
|
+
transport: http3(
|
|
1055
1180
|
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
1056
1181
|
)
|
|
1057
1182
|
});
|
|
@@ -1090,6 +1215,8 @@ export {
|
|
|
1090
1215
|
RequestPermissionErrorMessage,
|
|
1091
1216
|
ResponseEvent,
|
|
1092
1217
|
SAFE_CONTRACT_ABI,
|
|
1218
|
+
SendHapticFeedbackErrorCodes,
|
|
1219
|
+
SendHapticFeedbackErrorMessage,
|
|
1093
1220
|
SendTransactionErrorCodes,
|
|
1094
1221
|
SendTransactionErrorMessage,
|
|
1095
1222
|
ShareContactsErrorCodes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@worldcoin/idkit-core": "^
|
|
3
|
+
"@worldcoin/idkit-core": "^2.0.2",
|
|
4
4
|
"abitype": "^1.0.6"
|
|
5
5
|
},
|
|
6
6
|
"description": "minikit-js is our SDK for building mini-apps.",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"main": "index.ts",
|
|
47
47
|
"name": "@worldcoin/minikit-js",
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"viem": "2.23.5"
|
|
49
|
+
"viem": "^2.23.5"
|
|
50
50
|
},
|
|
51
51
|
"private": false,
|
|
52
52
|
"type": "module",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
]
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"version": "1.
|
|
62
|
+
"version": "1.8.0",
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "tsup",
|
|
65
65
|
"dev": "tsup --watch",
|