@worldcoin/minikit-js 2.0.0-dev.0 → 2.0.0-dev.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.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,19 +15,13 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/command-exports.ts
31
21
  var command_exports_exports = {};
32
22
  __export(command_exports_exports, {
23
+ AttestationError: () => AttestationError,
24
+ AttestationErrorCodes: () => AttestationErrorCodes,
33
25
  COMMAND_VERSIONS: () => COMMAND_VERSIONS,
34
26
  ChatError: () => ChatError,
35
27
  ChatErrorCodes: () => ChatErrorCodes,
@@ -70,7 +62,9 @@ __export(command_exports_exports, {
70
62
  WalletAuthError: () => WalletAuthError,
71
63
  WalletAuthErrorCodes: () => WalletAuthErrorCodes,
72
64
  WalletAuthErrorMessage: () => WalletAuthErrorMessage,
65
+ attestation: () => attestation,
73
66
  chat: () => chat,
67
+ closeMiniApp: () => closeMiniApp,
74
68
  getContacts: () => getContacts,
75
69
  getPermissions: () => getPermissions,
76
70
  isCommandAvailable: () => isCommandAvailable,
@@ -93,6 +87,7 @@ module.exports = __toCommonJS(command_exports_exports);
93
87
 
94
88
  // src/commands/types.ts
95
89
  var Command = /* @__PURE__ */ ((Command2) => {
90
+ Command2["Attestation"] = "attestation";
96
91
  Command2["Pay"] = "pay";
97
92
  Command2["WalletAuth"] = "wallet-auth";
98
93
  Command2["SendTransaction"] = "send-transaction";
@@ -104,9 +99,11 @@ var Command = /* @__PURE__ */ ((Command2) => {
104
99
  Command2["SendHapticFeedback"] = "send-haptic-feedback";
105
100
  Command2["Share"] = "share";
106
101
  Command2["Chat"] = "chat";
102
+ Command2["CloseMiniApp"] = "close-miniapp";
107
103
  return Command2;
108
104
  })(Command || {});
109
105
  var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
106
+ ResponseEvent2["MiniAppAttestation"] = "miniapp-attestation";
110
107
  ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
111
108
  ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
112
109
  ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
@@ -122,9 +119,10 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
122
119
  return ResponseEvent2;
123
120
  })(ResponseEvent || {});
124
121
  var COMMAND_VERSIONS = {
122
+ ["attestation" /* Attestation */]: 1,
125
123
  ["pay" /* Pay */]: 1,
126
124
  ["wallet-auth" /* WalletAuth */]: 2,
127
- ["send-transaction" /* SendTransaction */]: 1,
125
+ ["send-transaction" /* SendTransaction */]: 2,
128
126
  ["sign-message" /* SignMessage */]: 1,
129
127
  ["sign-typed-data" /* SignTypedData */]: 1,
130
128
  ["share-contacts" /* ShareContacts */]: 1,
@@ -132,9 +130,11 @@ var COMMAND_VERSIONS = {
132
130
  ["get-permissions" /* GetPermissions */]: 1,
133
131
  ["send-haptic-feedback" /* SendHapticFeedback */]: 1,
134
132
  ["share" /* Share */]: 1,
135
- ["chat" /* Chat */]: 1
133
+ ["chat" /* Chat */]: 1,
134
+ ["close-miniapp" /* CloseMiniApp */]: 1
136
135
  };
137
136
  var commandAvailability = {
137
+ ["attestation" /* Attestation */]: false,
138
138
  ["pay" /* Pay */]: false,
139
139
  ["wallet-auth" /* WalletAuth */]: false,
140
140
  ["send-transaction" /* SendTransaction */]: false,
@@ -145,7 +145,8 @@ var commandAvailability = {
145
145
  ["get-permissions" /* GetPermissions */]: false,
146
146
  ["send-haptic-feedback" /* SendHapticFeedback */]: false,
147
147
  ["share" /* Share */]: false,
148
- ["chat" /* Chat */]: false
148
+ ["chat" /* Chat */]: false,
149
+ ["close-miniapp" /* CloseMiniApp */]: false
149
150
  };
150
151
  function isCommandAvailable(command) {
151
152
  return commandAvailability[command] ?? false;
@@ -217,6 +218,8 @@ var CommandUnavailableError = class extends Error {
217
218
  var EventManager = class {
218
219
  constructor() {
219
220
  this.listeners = {
221
+ ["miniapp-attestation" /* MiniAppAttestation */]: () => {
222
+ },
220
223
  ["miniapp-payment" /* MiniAppPayment */]: () => {
221
224
  },
222
225
  ["miniapp-wallet-auth" /* MiniAppWalletAuth */]: () => {
@@ -260,191 +263,6 @@ var EventManager = class {
260
263
  }
261
264
  };
262
265
 
263
- // src/commands/wagmi-fallback.ts
264
- var SIWE_NONCE_REGEX = /^[a-zA-Z0-9]{8,}$/;
265
- var WAGMI_KEY = "__minikit_wagmi_config__";
266
- function getWagmiConfig() {
267
- return globalThis[WAGMI_KEY];
268
- }
269
- function hasWagmiConfig() {
270
- return globalThis[WAGMI_KEY] !== void 0;
271
- }
272
- async function ensureConnected(config) {
273
- const { connect, getConnections } = await import("wagmi/actions");
274
- const isWorldApp = typeof window !== "undefined" && Boolean(window.WorldApp);
275
- const existingConnection = getConnections(config).find(
276
- (connection) => connection.accounts && connection.accounts.length > 0 && (isWorldApp || connection.connector?.id !== "worldApp")
277
- );
278
- if (existingConnection && existingConnection.accounts) {
279
- return existingConnection.accounts[0];
280
- }
281
- const connectors = config.connectors;
282
- if (!connectors || connectors.length === 0) {
283
- throw new Error("No Wagmi connectors configured");
284
- }
285
- const candidateConnectors = isWorldApp ? connectors : connectors.filter(
286
- (connector) => connector.id !== "worldApp"
287
- );
288
- if (!isWorldApp && candidateConnectors.length === 0) {
289
- throw new Error(
290
- "No web Wagmi connectors configured. Add a web connector (e.g. injected or walletConnect) after worldApp()."
291
- );
292
- }
293
- const selectedConnector = candidateConnectors[0];
294
- try {
295
- const result = await connect(config, { connector: selectedConnector });
296
- if (result.accounts.length > 0) {
297
- const account = result.accounts[0];
298
- const address = typeof account === "string" ? account : account.address;
299
- if (address) {
300
- return address;
301
- }
302
- }
303
- } catch (error) {
304
- const connectorId = selectedConnector.id ?? "unknown";
305
- const wrappedError = new Error(
306
- `Failed to connect with connector "${connectorId}". Reorder connectors to change the default connector.`
307
- );
308
- wrappedError.cause = error;
309
- throw wrappedError;
310
- }
311
- throw new Error("Failed to connect wallet");
312
- }
313
- async function wagmiWalletAuth(params) {
314
- const config = getWagmiConfig();
315
- if (!config) {
316
- throw new Error(
317
- "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
318
- );
319
- }
320
- const { signMessage: signMessage2 } = await import("wagmi/actions");
321
- const { SiweMessage } = await import("siwe");
322
- const address = await ensureConnected(config);
323
- if (!SIWE_NONCE_REGEX.test(params.nonce)) {
324
- throw new Error(
325
- "Invalid nonce: must be alphanumeric and at least 8 characters (EIP-4361)"
326
- );
327
- }
328
- const siweMessage = new SiweMessage({
329
- domain: typeof window !== "undefined" ? window.location.host : "localhost",
330
- address,
331
- statement: params.statement,
332
- uri: typeof window !== "undefined" ? window.location.origin : "http://localhost",
333
- version: "1",
334
- chainId: 480,
335
- // World Chain
336
- nonce: params.nonce,
337
- expirationTime: params.expirationTime?.toISOString()
338
- });
339
- const message = siweMessage.prepareMessage();
340
- const signature = await signMessage2(config, { message });
341
- return {
342
- address,
343
- message,
344
- signature
345
- };
346
- }
347
- async function wagmiSignMessage(params) {
348
- const config = getWagmiConfig();
349
- if (!config) {
350
- throw new Error(
351
- "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
352
- );
353
- }
354
- const { signMessage: signMessage2 } = await import("wagmi/actions");
355
- const address = await ensureConnected(config);
356
- const signature = await signMessage2(config, {
357
- account: address,
358
- message: params.message
359
- });
360
- return {
361
- status: "success",
362
- version: 1,
363
- signature,
364
- address
365
- };
366
- }
367
- async function wagmiSignTypedData(params) {
368
- const config = getWagmiConfig();
369
- if (!config) {
370
- throw new Error(
371
- "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
372
- );
373
- }
374
- const { getChainId, signTypedData: signTypedData2, switchChain } = await import("wagmi/actions");
375
- const address = await ensureConnected(config);
376
- if (params.chainId !== void 0) {
377
- const currentChainId = await getChainId(config);
378
- if (currentChainId !== params.chainId) {
379
- await switchChain(config, { chainId: params.chainId });
380
- }
381
- }
382
- const signature = await signTypedData2(config, {
383
- account: address,
384
- types: params.types,
385
- primaryType: params.primaryType,
386
- domain: params.domain,
387
- message: params.message
388
- });
389
- return {
390
- status: "success",
391
- version: 1,
392
- signature,
393
- address
394
- };
395
- }
396
- function isChainMismatchError(error) {
397
- const message = error instanceof Error ? error.message : String(error);
398
- return message.includes("does not match the target chain");
399
- }
400
- async function wagmiSendTransaction(params) {
401
- const config = getWagmiConfig();
402
- if (!config) {
403
- throw new Error(
404
- "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
405
- );
406
- }
407
- const { getChainId, getWalletClient, sendTransaction: sendTransaction2, switchChain } = await import("wagmi/actions");
408
- await ensureConnected(config);
409
- const targetChainId = params.chainId ?? config.chains?.[0]?.id;
410
- const ensureTargetChain = async () => {
411
- if (targetChainId === void 0) return;
412
- const currentChainId = await getChainId(config);
413
- if (currentChainId !== targetChainId) {
414
- await switchChain(config, { chainId: targetChainId });
415
- }
416
- const walletClient = await getWalletClient(config);
417
- const providerChainId = walletClient ? await walletClient.getChainId() : await getChainId(config);
418
- if (providerChainId !== targetChainId) {
419
- throw new Error(
420
- `Wallet network mismatch: expected chain ${targetChainId}, got ${providerChainId}. Please switch networks in your wallet and retry.`
421
- );
422
- }
423
- };
424
- await ensureTargetChain();
425
- let transactionHash;
426
- try {
427
- transactionHash = await sendTransaction2(config, {
428
- chainId: targetChainId,
429
- to: params.transaction.address,
430
- data: params.transaction.data,
431
- value: params.transaction.value ? BigInt(params.transaction.value) : void 0
432
- });
433
- } catch (error) {
434
- if (targetChainId === void 0 || !isChainMismatchError(error)) {
435
- throw error;
436
- }
437
- await ensureTargetChain();
438
- transactionHash = await sendTransaction2(config, {
439
- chainId: targetChainId,
440
- to: params.transaction.address,
441
- data: params.transaction.data,
442
- value: params.transaction.value ? BigInt(params.transaction.value) : void 0
443
- });
444
- }
445
- return { transactionHash };
446
- }
447
-
448
266
  // src/commands/fallback.ts
449
267
  async function executeWithFallback(options) {
450
268
  const {
@@ -466,7 +284,7 @@ async function executeWithFallback(options) {
466
284
  console.warn(`Native ${command} failed, attempting fallback:`, error);
467
285
  }
468
286
  }
469
- if (!inWorldApp && wagmiFallback && hasWagmiConfig()) {
287
+ if (!inWorldApp && wagmiFallback) {
470
288
  try {
471
289
  const data = await wagmiFallback();
472
290
  return { data, executedWith: "wagmi" };
@@ -474,7 +292,7 @@ async function executeWithFallback(options) {
474
292
  console.warn(`Wagmi fallback for ${command} failed:`, error);
475
293
  }
476
294
  }
477
- if (customFallback) {
295
+ if (!inWorldApp && customFallback) {
478
296
  const data = await customFallback();
479
297
  return { data, executedWith: "fallback" };
480
298
  }
@@ -496,6 +314,75 @@ function determineFallbackReason(command) {
496
314
  return "commandNotSupported";
497
315
  }
498
316
 
317
+ // src/commands/attestation/types.ts
318
+ var AttestationErrorCodes = /* @__PURE__ */ ((AttestationErrorCodes2) => {
319
+ AttestationErrorCodes2["Unauthorized"] = "unauthorized";
320
+ AttestationErrorCodes2["AttestationFailed"] = "attestation_failed";
321
+ AttestationErrorCodes2["IntegrityFailed"] = "integrity_failed";
322
+ AttestationErrorCodes2["InvalidInput"] = "invalid_input";
323
+ AttestationErrorCodes2["UnsupportedVersion"] = "unsupported_version";
324
+ return AttestationErrorCodes2;
325
+ })(AttestationErrorCodes || {});
326
+ var AttestationError = class extends Error {
327
+ constructor(error_code) {
328
+ super(`Attestation failed: ${error_code}`);
329
+ this.error_code = error_code;
330
+ this.name = "AttestationError";
331
+ }
332
+ };
333
+
334
+ // src/commands/attestation/index.ts
335
+ async function attestation(options, ctx) {
336
+ const result = await executeWithFallback({
337
+ command: "attestation" /* Attestation */,
338
+ nativeExecutor: () => nativeAttestation(options, ctx),
339
+ customFallback: options.fallback
340
+ });
341
+ if (result.executedWith === "fallback") {
342
+ return { executedWith: "fallback", data: result.data };
343
+ }
344
+ return {
345
+ executedWith: "minikit",
346
+ data: result.data
347
+ };
348
+ }
349
+ async function nativeAttestation(options, ctx) {
350
+ if (!ctx) {
351
+ ctx = { events: new EventManager(), state: { deviceProperties: {} } };
352
+ }
353
+ if (typeof window === "undefined" || !isCommandAvailable("attestation" /* Attestation */)) {
354
+ throw new Error(
355
+ "'attestation' command is unavailable. Check MiniKit.install() or update the app version"
356
+ );
357
+ }
358
+ if (!options.requestHash || options.requestHash.length === 0) {
359
+ throw new Error("'attestation' command requires a non-empty requestHash");
360
+ }
361
+ const payload = await new Promise(
362
+ (resolve, reject) => {
363
+ try {
364
+ ctx.events.subscribe("miniapp-attestation" /* MiniAppAttestation */, (response) => {
365
+ ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
366
+ resolve(response);
367
+ });
368
+ sendMiniKitEvent({
369
+ command: "attestation" /* Attestation */,
370
+ version: COMMAND_VERSIONS["attestation" /* Attestation */],
371
+ payload: {
372
+ request_hash: options.requestHash
373
+ }
374
+ });
375
+ } catch (error) {
376
+ reject(error);
377
+ }
378
+ }
379
+ );
380
+ if (payload.status === "error") {
381
+ throw new AttestationError(payload.error_code);
382
+ }
383
+ return payload;
384
+ }
385
+
499
386
  // src/commands/chat/types.ts
500
387
  var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
501
388
  ChatErrorCodes2["UserRejected"] = "user_rejected";
@@ -563,6 +450,38 @@ async function nativeChat(options, ctx) {
563
450
  return payload;
564
451
  }
565
452
 
453
+ // src/commands/close-miniapp/index.ts
454
+ async function closeMiniApp(options = {}, _ctx) {
455
+ const result = await executeWithFallback({
456
+ command: "close-miniapp" /* CloseMiniApp */,
457
+ nativeExecutor: () => nativeCloseMiniApp(),
458
+ customFallback: options.fallback
459
+ });
460
+ if (result.executedWith === "fallback") {
461
+ return { executedWith: "fallback", data: result.data };
462
+ }
463
+ return {
464
+ executedWith: "minikit",
465
+ data: result.data
466
+ };
467
+ }
468
+ async function nativeCloseMiniApp() {
469
+ if (typeof window === "undefined" || !isCommandAvailable("close-miniapp" /* CloseMiniApp */)) {
470
+ throw new Error(
471
+ "'closeMiniApp' command is unavailable. Check MiniKit.install() or update the app version"
472
+ );
473
+ }
474
+ sendMiniKitEvent({
475
+ command: "close-miniapp" /* CloseMiniApp */,
476
+ version: COMMAND_VERSIONS["close-miniapp" /* CloseMiniApp */],
477
+ payload: {}
478
+ });
479
+ return {
480
+ status: "success",
481
+ version: COMMAND_VERSIONS["close-miniapp" /* CloseMiniApp */]
482
+ };
483
+ }
484
+
566
485
  // src/commands/get-permissions/types.ts
567
486
  var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
568
487
  GetPermissionsErrorCodes2["GenericError"] = "generic_error";
@@ -634,14 +553,27 @@ async function nativeGetPermissions(ctx) {
634
553
  var Tokens = /* @__PURE__ */ ((Tokens2) => {
635
554
  Tokens2["USDC"] = "USDCE";
636
555
  Tokens2["WLD"] = "WLD";
556
+ Tokens2["WARS"] = "WARS";
557
+ Tokens2["WCOP"] = "WCOP";
558
+ Tokens2["WMXN"] = "WMXN";
559
+ Tokens2["WBRL"] = "WBRL";
560
+ Tokens2["WPEN"] = "WPEN";
561
+ Tokens2["WCLP"] = "WCLP";
562
+ Tokens2["EURC"] = "EURC";
637
563
  return Tokens2;
638
564
  })(Tokens || {});
639
565
  var TokenDecimals = {
640
566
  ["USDCE" /* USDC */]: 6,
641
- ["WLD" /* WLD */]: 18
567
+ ["WLD" /* WLD */]: 18,
568
+ ["WARS" /* WARS */]: 18,
569
+ ["WCOP" /* WCOP */]: 18,
570
+ ["WMXN" /* WMXN */]: 18,
571
+ ["WBRL" /* WBRL */]: 18,
572
+ ["WPEN" /* WPEN */]: 18,
573
+ ["WCLP" /* WCLP */]: 18,
574
+ ["EURC" /* EURC */]: 6
642
575
  };
643
576
  var Network = /* @__PURE__ */ ((Network2) => {
644
- Network2["Optimism"] = "optimism";
645
577
  Network2["WorldChain"] = "worldchain";
646
578
  return Network2;
647
579
  })(Network || {});
@@ -902,8 +834,11 @@ async function nativeSendHapticFeedback(options, ctx) {
902
834
  return payload;
903
835
  }
904
836
 
905
- // src/commands/send-transaction/index.ts
906
- var import_viem = require("viem");
837
+ // src/commands/fallback-adapter-registry.ts
838
+ var FALLBACK_ADAPTER_KEY = "__minikit_fallback_adapter__";
839
+ function getFallbackAdapter() {
840
+ return globalThis[FALLBACK_ADAPTER_KEY];
841
+ }
907
842
 
908
843
  // src/commands/send-transaction/types.ts
909
844
  var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
@@ -960,16 +895,6 @@ var SendTransactionError = class extends Error {
960
895
  var isValidHex = (str) => {
961
896
  return /^0x[0-9A-Fa-f]+$/.test(str);
962
897
  };
963
- var objectValuesToArrayRecursive = (input) => {
964
- if (input === null || typeof input !== "object") {
965
- return input;
966
- }
967
- if (Array.isArray(input)) {
968
- return input.map((item) => objectValuesToArrayRecursive(item));
969
- }
970
- const values = Object.values(input);
971
- return values.map((value) => objectValuesToArrayRecursive(value));
972
- };
973
898
  var processPayload = (payload) => {
974
899
  if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
975
900
  return payload;
@@ -982,6 +907,20 @@ var processPayload = (payload) => {
982
907
  }
983
908
  if (typeof payload === "object") {
984
909
  const result = { ...payload };
910
+ if ("chainId" in result && result.chainId !== void 0) {
911
+ if (typeof result.chainId === "string") {
912
+ const parsed = Number(result.chainId);
913
+ if (Number.isFinite(parsed)) {
914
+ result.chainId = parsed;
915
+ }
916
+ } else if (typeof result.chainId === "bigint") {
917
+ const parsed = Number(result.chainId);
918
+ if (!Number.isSafeInteger(parsed)) {
919
+ throw new Error(`Invalid chainId: ${String(result.chainId)}`);
920
+ }
921
+ result.chainId = parsed;
922
+ }
923
+ }
985
924
  if ("value" in result && result.value !== void 0) {
986
925
  if (typeof result.value !== "string") {
987
926
  result.value = String(result.value);
@@ -998,6 +937,7 @@ var processPayload = (payload) => {
998
937
  }
999
938
  for (const key in result) {
1000
939
  if (Object.prototype.hasOwnProperty.call(result, key)) {
940
+ if (key === "chainId") continue;
1001
941
  result[key] = processPayload(result[key]);
1002
942
  }
1003
943
  }
@@ -1006,37 +946,48 @@ var processPayload = (payload) => {
1006
946
  return payload;
1007
947
  };
1008
948
  var validateSendTransactionPayload = (payload) => {
1009
- if (payload.formatPayload) {
1010
- const formattedPayload = processPayload(payload);
1011
- formattedPayload.transaction = formattedPayload.transaction.map((tx) => {
1012
- if ("args" in tx && tx.args !== void 0) {
1013
- const args = objectValuesToArrayRecursive(tx.args);
1014
- return {
1015
- ...tx,
1016
- args
1017
- };
1018
- }
1019
- return tx;
1020
- });
1021
- return formattedPayload;
1022
- }
1023
- return payload;
949
+ return processPayload(payload);
1024
950
  };
1025
951
 
1026
952
  // src/commands/send-transaction/index.ts
1027
953
  var WORLD_CHAIN_ID = 480;
1028
954
  var WAGMI_MULTI_TX_ERROR_MESSAGE = "Wagmi fallback does not support multi-transaction execution. Pass a single transaction, run inside World App for batching, or provide a custom fallback.";
955
+ function resolveChainId(options) {
956
+ return options.chainId;
957
+ }
958
+ function resolveTransactions(options) {
959
+ if (options.transactions.length === 0) {
960
+ throw new SendTransactionError("input_error" /* InputError */, {
961
+ reason: "At least one transaction is required. Use `transactions: [{ to, data, value }]`."
962
+ });
963
+ }
964
+ return options.transactions;
965
+ }
966
+ function normalizeSendTransactionOptions(options) {
967
+ const chainId = resolveChainId(options);
968
+ if (chainId !== WORLD_CHAIN_ID) {
969
+ throw new SendTransactionError("invalid_operation" /* InvalidOperation */, {
970
+ reason: `World App only supports World Chain (chainId: ${WORLD_CHAIN_ID})`
971
+ });
972
+ }
973
+ return {
974
+ transactions: resolveTransactions(options),
975
+ chainId
976
+ };
977
+ }
1029
978
  async function sendTransaction(options, ctx) {
1030
- const isWagmiFallbackPath = !isInWorldApp() && hasWagmiConfig();
1031
- if (isWagmiFallbackPath && options.transaction.length > 1 && !options.fallback) {
979
+ const normalizedOptions = normalizeSendTransactionOptions(options);
980
+ const fallbackAdapter = getFallbackAdapter();
981
+ const isWagmiFallbackPath = !isInWorldApp() && Boolean(fallbackAdapter?.sendTransaction);
982
+ if (isWagmiFallbackPath && normalizedOptions.transactions.length > 1 && !options.fallback) {
1032
983
  throw new SendTransactionError("invalid_operation" /* InvalidOperation */, {
1033
984
  reason: WAGMI_MULTI_TX_ERROR_MESSAGE
1034
985
  });
1035
986
  }
1036
987
  const result = await executeWithFallback({
1037
988
  command: "send-transaction" /* SendTransaction */,
1038
- nativeExecutor: () => nativeSendTransaction(options, ctx),
1039
- wagmiFallback: () => wagmiSendTransactionAdapter(options),
989
+ nativeExecutor: () => nativeSendTransaction(normalizedOptions, ctx),
990
+ wagmiFallback: fallbackAdapter?.sendTransaction ? () => adapterSendTransactionFallback(normalizedOptions) : void 0,
1040
991
  customFallback: options.fallback
1041
992
  });
1042
993
  if (result.executedWith === "fallback") {
@@ -1062,15 +1013,22 @@ async function nativeSendTransaction(options, ctx) {
1062
1013
  "'sendTransaction' command is unavailable. Check MiniKit.install() or update the app version"
1063
1014
  );
1064
1015
  }
1065
- if (options.chainId !== void 0 && options.chainId !== WORLD_CHAIN_ID) {
1016
+ if (options.chainId !== WORLD_CHAIN_ID) {
1066
1017
  throw new Error(
1067
1018
  `World App only supports World Chain (chainId: ${WORLD_CHAIN_ID})`
1068
1019
  );
1069
1020
  }
1021
+ const commandInput = window.WorldApp?.supported_commands.find(
1022
+ (command) => command.name === "send-transaction" /* SendTransaction */
1023
+ );
1024
+ if (commandInput && !commandInput.supported_versions.includes(
1025
+ COMMAND_VERSIONS["send-transaction" /* SendTransaction */]
1026
+ )) {
1027
+ throw new CommandUnavailableError("send-transaction" /* SendTransaction */, "oldAppVersion");
1028
+ }
1070
1029
  const input = {
1071
- transaction: options.transaction,
1072
- permit2: options.permit2,
1073
- formatPayload: options.formatPayload !== false
1030
+ transactions: options.transactions,
1031
+ chainId: options.chainId
1074
1032
  };
1075
1033
  const validatedPayload = validateSendTransactionPayload(input);
1076
1034
  const finalPayload = await new Promise(
@@ -1096,71 +1054,43 @@ async function nativeSendTransaction(options, ctx) {
1096
1054
  finalPayload.details
1097
1055
  );
1098
1056
  }
1057
+ const successPayload = finalPayload;
1099
1058
  return {
1100
- transactionHash: null,
1101
- userOpHash: finalPayload.userOpHash ?? null,
1102
- mini_app_id: finalPayload.mini_app_id ?? null,
1059
+ userOpHash: String(successPayload.userOpHash ?? ""),
1103
1060
  status: finalPayload.status,
1104
1061
  version: finalPayload.version,
1105
- transactionId: finalPayload.transaction_id,
1106
- reference: finalPayload.reference,
1107
- from: finalPayload.from,
1108
- chain: finalPayload.chain,
1109
- timestamp: finalPayload.timestamp,
1110
- // Deprecated aliases
1111
- transaction_id: finalPayload.transaction_id,
1112
- transaction_status: "submitted"
1062
+ from: String(successPayload.from ?? ""),
1063
+ timestamp: String(successPayload.timestamp ?? (/* @__PURE__ */ new Date()).toISOString())
1113
1064
  };
1114
1065
  }
1115
- async function wagmiSendTransactionAdapter(options) {
1116
- if (options.transaction.length > 1) {
1066
+ async function adapterSendTransactionFallback(options) {
1067
+ if (options.transactions.length > 1) {
1117
1068
  throw new Error(WAGMI_MULTI_TX_ERROR_MESSAGE);
1118
1069
  }
1119
- if (options.permit2 && options.permit2.length > 0) {
1120
- console.warn(
1121
- "Permit2 signature is not automatically supported via Wagmi fallback. Transactions will execute without permit2."
1122
- );
1123
- }
1124
- const transactions = options.transaction.map((tx) => ({
1125
- address: tx.address,
1126
- // Encode the function call data
1127
- data: encodeTransactionData(tx),
1128
- value: tx.value
1129
- }));
1130
- const firstTransaction = transactions[0];
1070
+ const firstTransaction = options.transactions[0];
1131
1071
  if (!firstTransaction) {
1132
1072
  throw new Error("At least one transaction is required");
1133
1073
  }
1134
- const result = await wagmiSendTransaction({
1135
- transaction: firstTransaction,
1074
+ const fallbackAdapter = getFallbackAdapter();
1075
+ if (!fallbackAdapter?.sendTransaction) {
1076
+ throw new Error("Fallback adapter is not registered.");
1077
+ }
1078
+ const result = await fallbackAdapter.sendTransaction({
1079
+ transaction: {
1080
+ address: firstTransaction.to,
1081
+ data: firstTransaction.data,
1082
+ value: firstTransaction.value
1083
+ },
1136
1084
  chainId: options.chainId
1137
1085
  });
1138
1086
  return {
1139
- transactionHash: result.transactionHash,
1140
- userOpHash: null,
1141
- mini_app_id: null,
1087
+ userOpHash: result.transactionHash,
1142
1088
  status: "success",
1143
- version: 1,
1144
- transactionId: null,
1145
- reference: null,
1146
- from: null,
1147
- chain: null,
1148
- timestamp: null
1089
+ version: COMMAND_VERSIONS["send-transaction" /* SendTransaction */],
1090
+ from: "",
1091
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1149
1092
  };
1150
1093
  }
1151
- function encodeTransactionData(tx) {
1152
- if (tx.data) {
1153
- return tx.data;
1154
- }
1155
- if (!tx.abi || !tx.functionName) {
1156
- throw new Error("Transaction requires `data` or `abi` + `functionName`.");
1157
- }
1158
- return (0, import_viem.encodeFunctionData)({
1159
- abi: tx.abi,
1160
- functionName: tx.functionName,
1161
- args: tx.args ?? []
1162
- });
1163
- }
1164
1094
 
1165
1095
  // src/commands/share/format.ts
1166
1096
  var MAX_FILES = 10;
@@ -1401,12 +1331,13 @@ var SignMessageError = class extends Error {
1401
1331
 
1402
1332
  // src/commands/sign-message/index.ts
1403
1333
  async function signMessage(options, ctx) {
1334
+ const fallbackAdapter = getFallbackAdapter();
1404
1335
  const result = await executeWithFallback({
1405
1336
  command: "sign-message" /* SignMessage */,
1406
1337
  nativeExecutor: () => nativeSignMessage(options, ctx),
1407
- wagmiFallback: () => wagmiSignMessage({
1338
+ wagmiFallback: fallbackAdapter?.signMessage ? () => fallbackAdapter.signMessage({
1408
1339
  message: options.message
1409
- }),
1340
+ }) : void 0,
1410
1341
  customFallback: options.fallback
1411
1342
  });
1412
1343
  if (result.executedWith === "fallback") {
@@ -1477,16 +1408,17 @@ var SignTypedDataError = class extends Error {
1477
1408
 
1478
1409
  // src/commands/sign-typed-data/index.ts
1479
1410
  async function signTypedData(options, ctx) {
1411
+ const fallbackAdapter = getFallbackAdapter();
1480
1412
  const result = await executeWithFallback({
1481
1413
  command: "sign-typed-data" /* SignTypedData */,
1482
1414
  nativeExecutor: () => nativeSignTypedData(options, ctx),
1483
- wagmiFallback: () => wagmiSignTypedData({
1415
+ wagmiFallback: fallbackAdapter?.signTypedData ? () => fallbackAdapter.signTypedData({
1484
1416
  types: options.types,
1485
1417
  primaryType: options.primaryType,
1486
1418
  message: options.message,
1487
1419
  domain: options.domain,
1488
1420
  chainId: options.chainId
1489
- }),
1421
+ }) : void 0,
1490
1422
  customFallback: options.fallback
1491
1423
  });
1492
1424
  if (result.executedWith === "fallback") {
@@ -1543,7 +1475,7 @@ async function nativeSignTypedData(options, ctx) {
1543
1475
  }
1544
1476
 
1545
1477
  // src/commands/wallet-auth/siwe.ts
1546
- var import_viem2 = require("viem");
1478
+ var import_viem = require("viem");
1547
1479
  var import_chains = require("viem/chains");
1548
1480
  var generateSiweMessage = (siweMessageData) => {
1549
1481
  let siweMessage = "";
@@ -1613,7 +1545,7 @@ var WalletAuthError = class extends Error {
1613
1545
  };
1614
1546
 
1615
1547
  // src/commands/wallet-auth/validate.ts
1616
- var SIWE_NONCE_REGEX2 = /^[a-zA-Z0-9]+$/;
1548
+ var SIWE_NONCE_REGEX = /^[a-zA-Z0-9]+$/;
1617
1549
  var validateWalletAuthCommandInput = (params) => {
1618
1550
  if (!params.nonce) {
1619
1551
  return { valid: false, message: "'nonce' is required" };
@@ -1621,7 +1553,7 @@ var validateWalletAuthCommandInput = (params) => {
1621
1553
  if (params.nonce.length < 8) {
1622
1554
  return { valid: false, message: "'nonce' must be at least 8 characters" };
1623
1555
  }
1624
- if (!SIWE_NONCE_REGEX2.test(params.nonce)) {
1556
+ if (!SIWE_NONCE_REGEX.test(params.nonce)) {
1625
1557
  return {
1626
1558
  valid: false,
1627
1559
  message: "'nonce' must be alphanumeric (letters and numbers only)"
@@ -1644,14 +1576,15 @@ var validateWalletAuthCommandInput = (params) => {
1644
1576
 
1645
1577
  // src/commands/wallet-auth/index.ts
1646
1578
  async function walletAuth(options, ctx) {
1579
+ const fallbackAdapter = getFallbackAdapter();
1647
1580
  const result = await executeWithFallback({
1648
1581
  command: "wallet-auth" /* WalletAuth */,
1649
1582
  nativeExecutor: () => nativeWalletAuth(options, ctx),
1650
- wagmiFallback: () => wagmiWalletAuth({
1583
+ wagmiFallback: fallbackAdapter?.walletAuth ? () => fallbackAdapter.walletAuth({
1651
1584
  nonce: options.nonce,
1652
1585
  statement: options.statement,
1653
1586
  expirationTime: options.expirationTime
1654
- }),
1587
+ }) : void 0,
1655
1588
  customFallback: options.fallback
1656
1589
  });
1657
1590
  if (result.executedWith === "fallback") {
@@ -1764,6 +1697,8 @@ var MiniKitInstallErrorMessage = {
1764
1697
  };
1765
1698
  // Annotate the CommonJS export names for ESM import in node:
1766
1699
  0 && (module.exports = {
1700
+ AttestationError,
1701
+ AttestationErrorCodes,
1767
1702
  COMMAND_VERSIONS,
1768
1703
  ChatError,
1769
1704
  ChatErrorCodes,
@@ -1804,7 +1739,9 @@ var MiniKitInstallErrorMessage = {
1804
1739
  WalletAuthError,
1805
1740
  WalletAuthErrorCodes,
1806
1741
  WalletAuthErrorMessage,
1742
+ attestation,
1807
1743
  chat,
1744
+ closeMiniApp,
1808
1745
  getContacts,
1809
1746
  getPermissions,
1810
1747
  isCommandAvailable,