@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.
@@ -4,6 +4,7 @@ import {
4
4
 
5
5
  // src/commands/types.ts
6
6
  var Command = /* @__PURE__ */ ((Command2) => {
7
+ Command2["Attestation"] = "attestation";
7
8
  Command2["Pay"] = "pay";
8
9
  Command2["WalletAuth"] = "wallet-auth";
9
10
  Command2["SendTransaction"] = "send-transaction";
@@ -15,9 +16,11 @@ var Command = /* @__PURE__ */ ((Command2) => {
15
16
  Command2["SendHapticFeedback"] = "send-haptic-feedback";
16
17
  Command2["Share"] = "share";
17
18
  Command2["Chat"] = "chat";
19
+ Command2["CloseMiniApp"] = "close-miniapp";
18
20
  return Command2;
19
21
  })(Command || {});
20
22
  var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
23
+ ResponseEvent2["MiniAppAttestation"] = "miniapp-attestation";
21
24
  ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
22
25
  ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
23
26
  ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
@@ -33,9 +36,10 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
33
36
  return ResponseEvent2;
34
37
  })(ResponseEvent || {});
35
38
  var COMMAND_VERSIONS = {
39
+ ["attestation" /* Attestation */]: 1,
36
40
  ["pay" /* Pay */]: 1,
37
41
  ["wallet-auth" /* WalletAuth */]: 2,
38
- ["send-transaction" /* SendTransaction */]: 1,
42
+ ["send-transaction" /* SendTransaction */]: 2,
39
43
  ["sign-message" /* SignMessage */]: 1,
40
44
  ["sign-typed-data" /* SignTypedData */]: 1,
41
45
  ["share-contacts" /* ShareContacts */]: 1,
@@ -43,9 +47,11 @@ var COMMAND_VERSIONS = {
43
47
  ["get-permissions" /* GetPermissions */]: 1,
44
48
  ["send-haptic-feedback" /* SendHapticFeedback */]: 1,
45
49
  ["share" /* Share */]: 1,
46
- ["chat" /* Chat */]: 1
50
+ ["chat" /* Chat */]: 1,
51
+ ["close-miniapp" /* CloseMiniApp */]: 1
47
52
  };
48
53
  var commandAvailability = {
54
+ ["attestation" /* Attestation */]: false,
49
55
  ["pay" /* Pay */]: false,
50
56
  ["wallet-auth" /* WalletAuth */]: false,
51
57
  ["send-transaction" /* SendTransaction */]: false,
@@ -56,7 +62,8 @@ var commandAvailability = {
56
62
  ["get-permissions" /* GetPermissions */]: false,
57
63
  ["send-haptic-feedback" /* SendHapticFeedback */]: false,
58
64
  ["share" /* Share */]: false,
59
- ["chat" /* Chat */]: false
65
+ ["chat" /* Chat */]: false,
66
+ ["close-miniapp" /* CloseMiniApp */]: false
60
67
  };
61
68
  function isCommandAvailable(command) {
62
69
  return commandAvailability[command] ?? false;
@@ -124,18 +131,20 @@ var CommandUnavailableError = class extends Error {
124
131
  }
125
132
  };
126
133
 
127
- // src/commands/chat/types.ts
128
- var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
129
- ChatErrorCodes2["UserRejected"] = "user_rejected";
130
- ChatErrorCodes2["SendFailed"] = "send_failed";
131
- ChatErrorCodes2["GenericError"] = "generic_error";
132
- return ChatErrorCodes2;
133
- })(ChatErrorCodes || {});
134
- var ChatError = class extends Error {
134
+ // src/commands/attestation/types.ts
135
+ var AttestationErrorCodes = /* @__PURE__ */ ((AttestationErrorCodes2) => {
136
+ AttestationErrorCodes2["Unauthorized"] = "unauthorized";
137
+ AttestationErrorCodes2["AttestationFailed"] = "attestation_failed";
138
+ AttestationErrorCodes2["IntegrityFailed"] = "integrity_failed";
139
+ AttestationErrorCodes2["InvalidInput"] = "invalid_input";
140
+ AttestationErrorCodes2["UnsupportedVersion"] = "unsupported_version";
141
+ return AttestationErrorCodes2;
142
+ })(AttestationErrorCodes || {});
143
+ var AttestationError = class extends Error {
135
144
  constructor(error_code) {
136
- super(`Chat failed: ${error_code}`);
145
+ super(`Attestation failed: ${error_code}`);
137
146
  this.error_code = error_code;
138
- this.name = "ChatError";
147
+ this.name = "AttestationError";
139
148
  }
140
149
  };
141
150
 
@@ -143,6 +152,8 @@ var ChatError = class extends Error {
143
152
  var EventManager = class {
144
153
  constructor() {
145
154
  this.listeners = {
155
+ ["miniapp-attestation" /* MiniAppAttestation */]: () => {
156
+ },
146
157
  ["miniapp-payment" /* MiniAppPayment */]: () => {
147
158
  },
148
159
  ["miniapp-wallet-auth" /* MiniAppWalletAuth */]: () => {
@@ -186,194 +197,6 @@ var EventManager = class {
186
197
  }
187
198
  };
188
199
 
189
- // src/commands/wagmi-fallback.ts
190
- var SIWE_NONCE_REGEX = /^[a-zA-Z0-9]{8,}$/;
191
- var WAGMI_KEY = "__minikit_wagmi_config__";
192
- function setWagmiConfig(config) {
193
- globalThis[WAGMI_KEY] = config;
194
- }
195
- function getWagmiConfig() {
196
- return globalThis[WAGMI_KEY];
197
- }
198
- function hasWagmiConfig() {
199
- return globalThis[WAGMI_KEY] !== void 0;
200
- }
201
- async function ensureConnected(config) {
202
- const { connect, getConnections } = await import("wagmi/actions");
203
- const isWorldApp = typeof window !== "undefined" && Boolean(window.WorldApp);
204
- const existingConnection = getConnections(config).find(
205
- (connection) => connection.accounts && connection.accounts.length > 0 && (isWorldApp || connection.connector?.id !== "worldApp")
206
- );
207
- if (existingConnection && existingConnection.accounts) {
208
- return existingConnection.accounts[0];
209
- }
210
- const connectors = config.connectors;
211
- if (!connectors || connectors.length === 0) {
212
- throw new Error("No Wagmi connectors configured");
213
- }
214
- const candidateConnectors = isWorldApp ? connectors : connectors.filter(
215
- (connector) => connector.id !== "worldApp"
216
- );
217
- if (!isWorldApp && candidateConnectors.length === 0) {
218
- throw new Error(
219
- "No web Wagmi connectors configured. Add a web connector (e.g. injected or walletConnect) after worldApp()."
220
- );
221
- }
222
- const selectedConnector = candidateConnectors[0];
223
- try {
224
- const result = await connect(config, { connector: selectedConnector });
225
- if (result.accounts.length > 0) {
226
- const account = result.accounts[0];
227
- const address = typeof account === "string" ? account : account.address;
228
- if (address) {
229
- return address;
230
- }
231
- }
232
- } catch (error) {
233
- const connectorId = selectedConnector.id ?? "unknown";
234
- const wrappedError = new Error(
235
- `Failed to connect with connector "${connectorId}". Reorder connectors to change the default connector.`
236
- );
237
- wrappedError.cause = error;
238
- throw wrappedError;
239
- }
240
- throw new Error("Failed to connect wallet");
241
- }
242
- async function wagmiWalletAuth(params) {
243
- const config = getWagmiConfig();
244
- if (!config) {
245
- throw new Error(
246
- "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
247
- );
248
- }
249
- const { signMessage: signMessage2 } = await import("wagmi/actions");
250
- const { SiweMessage } = await import("siwe");
251
- const address = await ensureConnected(config);
252
- if (!SIWE_NONCE_REGEX.test(params.nonce)) {
253
- throw new Error(
254
- "Invalid nonce: must be alphanumeric and at least 8 characters (EIP-4361)"
255
- );
256
- }
257
- const siweMessage = new SiweMessage({
258
- domain: typeof window !== "undefined" ? window.location.host : "localhost",
259
- address,
260
- statement: params.statement,
261
- uri: typeof window !== "undefined" ? window.location.origin : "http://localhost",
262
- version: "1",
263
- chainId: 480,
264
- // World Chain
265
- nonce: params.nonce,
266
- expirationTime: params.expirationTime?.toISOString()
267
- });
268
- const message = siweMessage.prepareMessage();
269
- const signature = await signMessage2(config, { message });
270
- return {
271
- address,
272
- message,
273
- signature
274
- };
275
- }
276
- async function wagmiSignMessage(params) {
277
- const config = getWagmiConfig();
278
- if (!config) {
279
- throw new Error(
280
- "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
281
- );
282
- }
283
- const { signMessage: signMessage2 } = await import("wagmi/actions");
284
- const address = await ensureConnected(config);
285
- const signature = await signMessage2(config, {
286
- account: address,
287
- message: params.message
288
- });
289
- return {
290
- status: "success",
291
- version: 1,
292
- signature,
293
- address
294
- };
295
- }
296
- async function wagmiSignTypedData(params) {
297
- const config = getWagmiConfig();
298
- if (!config) {
299
- throw new Error(
300
- "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
301
- );
302
- }
303
- const { getChainId, signTypedData: signTypedData2, switchChain } = await import("wagmi/actions");
304
- const address = await ensureConnected(config);
305
- if (params.chainId !== void 0) {
306
- const currentChainId = await getChainId(config);
307
- if (currentChainId !== params.chainId) {
308
- await switchChain(config, { chainId: params.chainId });
309
- }
310
- }
311
- const signature = await signTypedData2(config, {
312
- account: address,
313
- types: params.types,
314
- primaryType: params.primaryType,
315
- domain: params.domain,
316
- message: params.message
317
- });
318
- return {
319
- status: "success",
320
- version: 1,
321
- signature,
322
- address
323
- };
324
- }
325
- function isChainMismatchError(error) {
326
- const message = error instanceof Error ? error.message : String(error);
327
- return message.includes("does not match the target chain");
328
- }
329
- async function wagmiSendTransaction(params) {
330
- const config = getWagmiConfig();
331
- if (!config) {
332
- throw new Error(
333
- "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
334
- );
335
- }
336
- const { getChainId, getWalletClient, sendTransaction: sendTransaction2, switchChain } = await import("wagmi/actions");
337
- await ensureConnected(config);
338
- const targetChainId = params.chainId ?? config.chains?.[0]?.id;
339
- const ensureTargetChain = async () => {
340
- if (targetChainId === void 0) return;
341
- const currentChainId = await getChainId(config);
342
- if (currentChainId !== targetChainId) {
343
- await switchChain(config, { chainId: targetChainId });
344
- }
345
- const walletClient = await getWalletClient(config);
346
- const providerChainId = walletClient ? await walletClient.getChainId() : await getChainId(config);
347
- if (providerChainId !== targetChainId) {
348
- throw new Error(
349
- `Wallet network mismatch: expected chain ${targetChainId}, got ${providerChainId}. Please switch networks in your wallet and retry.`
350
- );
351
- }
352
- };
353
- await ensureTargetChain();
354
- let transactionHash;
355
- try {
356
- transactionHash = await sendTransaction2(config, {
357
- chainId: targetChainId,
358
- to: params.transaction.address,
359
- data: params.transaction.data,
360
- value: params.transaction.value ? BigInt(params.transaction.value) : void 0
361
- });
362
- } catch (error) {
363
- if (targetChainId === void 0 || !isChainMismatchError(error)) {
364
- throw error;
365
- }
366
- await ensureTargetChain();
367
- transactionHash = await sendTransaction2(config, {
368
- chainId: targetChainId,
369
- to: params.transaction.address,
370
- data: params.transaction.data,
371
- value: params.transaction.value ? BigInt(params.transaction.value) : void 0
372
- });
373
- }
374
- return { transactionHash };
375
- }
376
-
377
200
  // src/commands/fallback.ts
378
201
  async function executeWithFallback(options) {
379
202
  const {
@@ -395,7 +218,7 @@ async function executeWithFallback(options) {
395
218
  console.warn(`Native ${command} failed, attempting fallback:`, error);
396
219
  }
397
220
  }
398
- if (!inWorldApp && wagmiFallback && hasWagmiConfig()) {
221
+ if (!inWorldApp && wagmiFallback) {
399
222
  try {
400
223
  const data = await wagmiFallback();
401
224
  return { data, executedWith: "wagmi" };
@@ -403,7 +226,7 @@ async function executeWithFallback(options) {
403
226
  console.warn(`Wagmi fallback for ${command} failed:`, error);
404
227
  }
405
228
  }
406
- if (customFallback) {
229
+ if (!inWorldApp && customFallback) {
407
230
  const data = await customFallback();
408
231
  return { data, executedWith: "fallback" };
409
232
  }
@@ -425,6 +248,73 @@ function determineFallbackReason(command) {
425
248
  return "commandNotSupported";
426
249
  }
427
250
 
251
+ // src/commands/attestation/index.ts
252
+ async function attestation(options, ctx) {
253
+ const result = await executeWithFallback({
254
+ command: "attestation" /* Attestation */,
255
+ nativeExecutor: () => nativeAttestation(options, ctx),
256
+ customFallback: options.fallback
257
+ });
258
+ if (result.executedWith === "fallback") {
259
+ return { executedWith: "fallback", data: result.data };
260
+ }
261
+ return {
262
+ executedWith: "minikit",
263
+ data: result.data
264
+ };
265
+ }
266
+ async function nativeAttestation(options, ctx) {
267
+ if (!ctx) {
268
+ ctx = { events: new EventManager(), state: { deviceProperties: {} } };
269
+ }
270
+ if (typeof window === "undefined" || !isCommandAvailable("attestation" /* Attestation */)) {
271
+ throw new Error(
272
+ "'attestation' command is unavailable. Check MiniKit.install() or update the app version"
273
+ );
274
+ }
275
+ if (!options.requestHash || options.requestHash.length === 0) {
276
+ throw new Error("'attestation' command requires a non-empty requestHash");
277
+ }
278
+ const payload = await new Promise(
279
+ (resolve, reject) => {
280
+ try {
281
+ ctx.events.subscribe("miniapp-attestation" /* MiniAppAttestation */, (response) => {
282
+ ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
283
+ resolve(response);
284
+ });
285
+ sendMiniKitEvent({
286
+ command: "attestation" /* Attestation */,
287
+ version: COMMAND_VERSIONS["attestation" /* Attestation */],
288
+ payload: {
289
+ request_hash: options.requestHash
290
+ }
291
+ });
292
+ } catch (error) {
293
+ reject(error);
294
+ }
295
+ }
296
+ );
297
+ if (payload.status === "error") {
298
+ throw new AttestationError(payload.error_code);
299
+ }
300
+ return payload;
301
+ }
302
+
303
+ // src/commands/chat/types.ts
304
+ var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
305
+ ChatErrorCodes2["UserRejected"] = "user_rejected";
306
+ ChatErrorCodes2["SendFailed"] = "send_failed";
307
+ ChatErrorCodes2["GenericError"] = "generic_error";
308
+ return ChatErrorCodes2;
309
+ })(ChatErrorCodes || {});
310
+ var ChatError = class extends Error {
311
+ constructor(error_code) {
312
+ super(`Chat failed: ${error_code}`);
313
+ this.error_code = error_code;
314
+ this.name = "ChatError";
315
+ }
316
+ };
317
+
428
318
  // src/commands/chat/index.ts
429
319
  async function chat(options, ctx) {
430
320
  const result = await executeWithFallback({
@@ -477,6 +367,38 @@ async function nativeChat(options, ctx) {
477
367
  return payload;
478
368
  }
479
369
 
370
+ // src/commands/close-miniapp/index.ts
371
+ async function closeMiniApp(options = {}, _ctx) {
372
+ const result = await executeWithFallback({
373
+ command: "close-miniapp" /* CloseMiniApp */,
374
+ nativeExecutor: () => nativeCloseMiniApp(),
375
+ customFallback: options.fallback
376
+ });
377
+ if (result.executedWith === "fallback") {
378
+ return { executedWith: "fallback", data: result.data };
379
+ }
380
+ return {
381
+ executedWith: "minikit",
382
+ data: result.data
383
+ };
384
+ }
385
+ async function nativeCloseMiniApp() {
386
+ if (typeof window === "undefined" || !isCommandAvailable("close-miniapp" /* CloseMiniApp */)) {
387
+ throw new Error(
388
+ "'closeMiniApp' command is unavailable. Check MiniKit.install() or update the app version"
389
+ );
390
+ }
391
+ sendMiniKitEvent({
392
+ command: "close-miniapp" /* CloseMiniApp */,
393
+ version: COMMAND_VERSIONS["close-miniapp" /* CloseMiniApp */],
394
+ payload: {}
395
+ });
396
+ return {
397
+ status: "success",
398
+ version: COMMAND_VERSIONS["close-miniapp" /* CloseMiniApp */]
399
+ };
400
+ }
401
+
480
402
  // src/commands/get-permissions/types.ts
481
403
  var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
482
404
  GetPermissionsErrorCodes2["GenericError"] = "generic_error";
@@ -548,14 +470,27 @@ async function nativeGetPermissions(ctx) {
548
470
  var Tokens = /* @__PURE__ */ ((Tokens2) => {
549
471
  Tokens2["USDC"] = "USDCE";
550
472
  Tokens2["WLD"] = "WLD";
473
+ Tokens2["WARS"] = "WARS";
474
+ Tokens2["WCOP"] = "WCOP";
475
+ Tokens2["WMXN"] = "WMXN";
476
+ Tokens2["WBRL"] = "WBRL";
477
+ Tokens2["WPEN"] = "WPEN";
478
+ Tokens2["WCLP"] = "WCLP";
479
+ Tokens2["EURC"] = "EURC";
551
480
  return Tokens2;
552
481
  })(Tokens || {});
553
482
  var TokenDecimals = {
554
483
  ["USDCE" /* USDC */]: 6,
555
- ["WLD" /* WLD */]: 18
484
+ ["WLD" /* WLD */]: 18,
485
+ ["WARS" /* WARS */]: 18,
486
+ ["WCOP" /* WCOP */]: 18,
487
+ ["WMXN" /* WMXN */]: 18,
488
+ ["WBRL" /* WBRL */]: 18,
489
+ ["WPEN" /* WPEN */]: 18,
490
+ ["WCLP" /* WCLP */]: 18,
491
+ ["EURC" /* EURC */]: 6
556
492
  };
557
493
  var Network = /* @__PURE__ */ ((Network2) => {
558
- Network2["Optimism"] = "optimism";
559
494
  Network2["WorldChain"] = "worldchain";
560
495
  return Network2;
561
496
  })(Network || {});
@@ -867,23 +802,19 @@ var SendTransactionError = class extends Error {
867
802
  }
868
803
  };
869
804
 
870
- // src/commands/send-transaction/index.ts
871
- import { encodeFunctionData } from "viem";
805
+ // src/commands/fallback-adapter-registry.ts
806
+ var FALLBACK_ADAPTER_KEY = "__minikit_fallback_adapter__";
807
+ function setFallbackAdapter(adapter) {
808
+ globalThis[FALLBACK_ADAPTER_KEY] = adapter;
809
+ }
810
+ function getFallbackAdapter() {
811
+ return globalThis[FALLBACK_ADAPTER_KEY];
812
+ }
872
813
 
873
814
  // src/commands/send-transaction/validate.ts
874
815
  var isValidHex = (str) => {
875
816
  return /^0x[0-9A-Fa-f]+$/.test(str);
876
817
  };
877
- var objectValuesToArrayRecursive = (input) => {
878
- if (input === null || typeof input !== "object") {
879
- return input;
880
- }
881
- if (Array.isArray(input)) {
882
- return input.map((item) => objectValuesToArrayRecursive(item));
883
- }
884
- const values = Object.values(input);
885
- return values.map((value) => objectValuesToArrayRecursive(value));
886
- };
887
818
  var processPayload = (payload) => {
888
819
  if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
889
820
  return payload;
@@ -896,6 +827,20 @@ var processPayload = (payload) => {
896
827
  }
897
828
  if (typeof payload === "object") {
898
829
  const result = { ...payload };
830
+ if ("chainId" in result && result.chainId !== void 0) {
831
+ if (typeof result.chainId === "string") {
832
+ const parsed = Number(result.chainId);
833
+ if (Number.isFinite(parsed)) {
834
+ result.chainId = parsed;
835
+ }
836
+ } else if (typeof result.chainId === "bigint") {
837
+ const parsed = Number(result.chainId);
838
+ if (!Number.isSafeInteger(parsed)) {
839
+ throw new Error(`Invalid chainId: ${String(result.chainId)}`);
840
+ }
841
+ result.chainId = parsed;
842
+ }
843
+ }
899
844
  if ("value" in result && result.value !== void 0) {
900
845
  if (typeof result.value !== "string") {
901
846
  result.value = String(result.value);
@@ -912,6 +857,7 @@ var processPayload = (payload) => {
912
857
  }
913
858
  for (const key in result) {
914
859
  if (Object.prototype.hasOwnProperty.call(result, key)) {
860
+ if (key === "chainId") continue;
915
861
  result[key] = processPayload(result[key]);
916
862
  }
917
863
  }
@@ -920,37 +866,48 @@ var processPayload = (payload) => {
920
866
  return payload;
921
867
  };
922
868
  var validateSendTransactionPayload = (payload) => {
923
- if (payload.formatPayload) {
924
- const formattedPayload = processPayload(payload);
925
- formattedPayload.transaction = formattedPayload.transaction.map((tx) => {
926
- if ("args" in tx && tx.args !== void 0) {
927
- const args = objectValuesToArrayRecursive(tx.args);
928
- return {
929
- ...tx,
930
- args
931
- };
932
- }
933
- return tx;
934
- });
935
- return formattedPayload;
936
- }
937
- return payload;
869
+ return processPayload(payload);
938
870
  };
939
871
 
940
872
  // src/commands/send-transaction/index.ts
941
873
  var WORLD_CHAIN_ID = 480;
942
874
  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.";
875
+ function resolveChainId(options) {
876
+ return options.chainId;
877
+ }
878
+ function resolveTransactions(options) {
879
+ if (options.transactions.length === 0) {
880
+ throw new SendTransactionError("input_error" /* InputError */, {
881
+ reason: "At least one transaction is required. Use `transactions: [{ to, data, value }]`."
882
+ });
883
+ }
884
+ return options.transactions;
885
+ }
886
+ function normalizeSendTransactionOptions(options) {
887
+ const chainId = resolveChainId(options);
888
+ if (chainId !== WORLD_CHAIN_ID) {
889
+ throw new SendTransactionError("invalid_operation" /* InvalidOperation */, {
890
+ reason: `World App only supports World Chain (chainId: ${WORLD_CHAIN_ID})`
891
+ });
892
+ }
893
+ return {
894
+ transactions: resolveTransactions(options),
895
+ chainId
896
+ };
897
+ }
943
898
  async function sendTransaction(options, ctx) {
944
- const isWagmiFallbackPath = !isInWorldApp() && hasWagmiConfig();
945
- if (isWagmiFallbackPath && options.transaction.length > 1 && !options.fallback) {
899
+ const normalizedOptions = normalizeSendTransactionOptions(options);
900
+ const fallbackAdapter = getFallbackAdapter();
901
+ const isWagmiFallbackPath = !isInWorldApp() && Boolean(fallbackAdapter?.sendTransaction);
902
+ if (isWagmiFallbackPath && normalizedOptions.transactions.length > 1 && !options.fallback) {
946
903
  throw new SendTransactionError("invalid_operation" /* InvalidOperation */, {
947
904
  reason: WAGMI_MULTI_TX_ERROR_MESSAGE
948
905
  });
949
906
  }
950
907
  const result = await executeWithFallback({
951
908
  command: "send-transaction" /* SendTransaction */,
952
- nativeExecutor: () => nativeSendTransaction(options, ctx),
953
- wagmiFallback: () => wagmiSendTransactionAdapter(options),
909
+ nativeExecutor: () => nativeSendTransaction(normalizedOptions, ctx),
910
+ wagmiFallback: fallbackAdapter?.sendTransaction ? () => adapterSendTransactionFallback(normalizedOptions) : void 0,
954
911
  customFallback: options.fallback
955
912
  });
956
913
  if (result.executedWith === "fallback") {
@@ -976,15 +933,22 @@ async function nativeSendTransaction(options, ctx) {
976
933
  "'sendTransaction' command is unavailable. Check MiniKit.install() or update the app version"
977
934
  );
978
935
  }
979
- if (options.chainId !== void 0 && options.chainId !== WORLD_CHAIN_ID) {
936
+ if (options.chainId !== WORLD_CHAIN_ID) {
980
937
  throw new Error(
981
938
  `World App only supports World Chain (chainId: ${WORLD_CHAIN_ID})`
982
939
  );
983
940
  }
941
+ const commandInput = window.WorldApp?.supported_commands.find(
942
+ (command) => command.name === "send-transaction" /* SendTransaction */
943
+ );
944
+ if (commandInput && !commandInput.supported_versions.includes(
945
+ COMMAND_VERSIONS["send-transaction" /* SendTransaction */]
946
+ )) {
947
+ throw new CommandUnavailableError("send-transaction" /* SendTransaction */, "oldAppVersion");
948
+ }
984
949
  const input = {
985
- transaction: options.transaction,
986
- permit2: options.permit2,
987
- formatPayload: options.formatPayload !== false
950
+ transactions: options.transactions,
951
+ chainId: options.chainId
988
952
  };
989
953
  const validatedPayload = validateSendTransactionPayload(input);
990
954
  const finalPayload = await new Promise(
@@ -1010,71 +974,43 @@ async function nativeSendTransaction(options, ctx) {
1010
974
  finalPayload.details
1011
975
  );
1012
976
  }
977
+ const successPayload = finalPayload;
1013
978
  return {
1014
- transactionHash: null,
1015
- userOpHash: finalPayload.userOpHash ?? null,
1016
- mini_app_id: finalPayload.mini_app_id ?? null,
979
+ userOpHash: String(successPayload.userOpHash ?? ""),
1017
980
  status: finalPayload.status,
1018
981
  version: finalPayload.version,
1019
- transactionId: finalPayload.transaction_id,
1020
- reference: finalPayload.reference,
1021
- from: finalPayload.from,
1022
- chain: finalPayload.chain,
1023
- timestamp: finalPayload.timestamp,
1024
- // Deprecated aliases
1025
- transaction_id: finalPayload.transaction_id,
1026
- transaction_status: "submitted"
982
+ from: String(successPayload.from ?? ""),
983
+ timestamp: String(successPayload.timestamp ?? (/* @__PURE__ */ new Date()).toISOString())
1027
984
  };
1028
985
  }
1029
- async function wagmiSendTransactionAdapter(options) {
1030
- if (options.transaction.length > 1) {
986
+ async function adapterSendTransactionFallback(options) {
987
+ if (options.transactions.length > 1) {
1031
988
  throw new Error(WAGMI_MULTI_TX_ERROR_MESSAGE);
1032
989
  }
1033
- if (options.permit2 && options.permit2.length > 0) {
1034
- console.warn(
1035
- "Permit2 signature is not automatically supported via Wagmi fallback. Transactions will execute without permit2."
1036
- );
1037
- }
1038
- const transactions = options.transaction.map((tx) => ({
1039
- address: tx.address,
1040
- // Encode the function call data
1041
- data: encodeTransactionData(tx),
1042
- value: tx.value
1043
- }));
1044
- const firstTransaction = transactions[0];
990
+ const firstTransaction = options.transactions[0];
1045
991
  if (!firstTransaction) {
1046
992
  throw new Error("At least one transaction is required");
1047
993
  }
1048
- const result = await wagmiSendTransaction({
1049
- transaction: firstTransaction,
994
+ const fallbackAdapter = getFallbackAdapter();
995
+ if (!fallbackAdapter?.sendTransaction) {
996
+ throw new Error("Fallback adapter is not registered.");
997
+ }
998
+ const result = await fallbackAdapter.sendTransaction({
999
+ transaction: {
1000
+ address: firstTransaction.to,
1001
+ data: firstTransaction.data,
1002
+ value: firstTransaction.value
1003
+ },
1050
1004
  chainId: options.chainId
1051
1005
  });
1052
1006
  return {
1053
- transactionHash: result.transactionHash,
1054
- userOpHash: null,
1055
- mini_app_id: null,
1007
+ userOpHash: result.transactionHash,
1056
1008
  status: "success",
1057
- version: 1,
1058
- transactionId: null,
1059
- reference: null,
1060
- from: null,
1061
- chain: null,
1062
- timestamp: null
1009
+ version: COMMAND_VERSIONS["send-transaction" /* SendTransaction */],
1010
+ from: "",
1011
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1063
1012
  };
1064
1013
  }
1065
- function encodeTransactionData(tx) {
1066
- if (tx.data) {
1067
- return tx.data;
1068
- }
1069
- if (!tx.abi || !tx.functionName) {
1070
- throw new Error("Transaction requires `data` or `abi` + `functionName`.");
1071
- }
1072
- return encodeFunctionData({
1073
- abi: tx.abi,
1074
- functionName: tx.functionName,
1075
- args: tx.args ?? []
1076
- });
1077
- }
1078
1014
 
1079
1015
  // src/commands/share/types.ts
1080
1016
  var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
@@ -1315,12 +1251,13 @@ var SignMessageError = class extends Error {
1315
1251
 
1316
1252
  // src/commands/sign-message/index.ts
1317
1253
  async function signMessage(options, ctx) {
1254
+ const fallbackAdapter = getFallbackAdapter();
1318
1255
  const result = await executeWithFallback({
1319
1256
  command: "sign-message" /* SignMessage */,
1320
1257
  nativeExecutor: () => nativeSignMessage(options, ctx),
1321
- wagmiFallback: () => wagmiSignMessage({
1258
+ wagmiFallback: fallbackAdapter?.signMessage ? () => fallbackAdapter.signMessage({
1322
1259
  message: options.message
1323
- }),
1260
+ }) : void 0,
1324
1261
  customFallback: options.fallback
1325
1262
  });
1326
1263
  if (result.executedWith === "fallback") {
@@ -1391,16 +1328,17 @@ var SignTypedDataError = class extends Error {
1391
1328
 
1392
1329
  // src/commands/sign-typed-data/index.ts
1393
1330
  async function signTypedData(options, ctx) {
1331
+ const fallbackAdapter = getFallbackAdapter();
1394
1332
  const result = await executeWithFallback({
1395
1333
  command: "sign-typed-data" /* SignTypedData */,
1396
1334
  nativeExecutor: () => nativeSignTypedData(options, ctx),
1397
- wagmiFallback: () => wagmiSignTypedData({
1335
+ wagmiFallback: fallbackAdapter?.signTypedData ? () => fallbackAdapter.signTypedData({
1398
1336
  types: options.types,
1399
1337
  primaryType: options.primaryType,
1400
1338
  message: options.message,
1401
1339
  domain: options.domain,
1402
1340
  chainId: options.chainId
1403
- }),
1341
+ }) : void 0,
1404
1342
  customFallback: options.fallback
1405
1343
  });
1406
1344
  if (result.executedWith === "fallback") {
@@ -1478,7 +1416,7 @@ var WalletAuthError = class extends Error {
1478
1416
  };
1479
1417
 
1480
1418
  // src/commands/wallet-auth/validate.ts
1481
- var SIWE_NONCE_REGEX2 = /^[a-zA-Z0-9]+$/;
1419
+ var SIWE_NONCE_REGEX = /^[a-zA-Z0-9]+$/;
1482
1420
  var validateWalletAuthCommandInput = (params) => {
1483
1421
  if (!params.nonce) {
1484
1422
  return { valid: false, message: "'nonce' is required" };
@@ -1486,7 +1424,7 @@ var validateWalletAuthCommandInput = (params) => {
1486
1424
  if (params.nonce.length < 8) {
1487
1425
  return { valid: false, message: "'nonce' must be at least 8 characters" };
1488
1426
  }
1489
- if (!SIWE_NONCE_REGEX2.test(params.nonce)) {
1427
+ if (!SIWE_NONCE_REGEX.test(params.nonce)) {
1490
1428
  return {
1491
1429
  valid: false,
1492
1430
  message: "'nonce' must be alphanumeric (letters and numbers only)"
@@ -1509,14 +1447,15 @@ var validateWalletAuthCommandInput = (params) => {
1509
1447
 
1510
1448
  // src/commands/wallet-auth/index.ts
1511
1449
  async function walletAuth(options, ctx) {
1450
+ const fallbackAdapter = getFallbackAdapter();
1512
1451
  const result = await executeWithFallback({
1513
1452
  command: "wallet-auth" /* WalletAuth */,
1514
1453
  nativeExecutor: () => nativeWalletAuth(options, ctx),
1515
- wagmiFallback: () => wagmiWalletAuth({
1454
+ wagmiFallback: fallbackAdapter?.walletAuth ? () => fallbackAdapter.walletAuth({
1516
1455
  nonce: options.nonce,
1517
1456
  statement: options.statement,
1518
1457
  expirationTime: options.expirationTime
1519
- }),
1458
+ }) : void 0,
1520
1459
  customFallback: options.fallback
1521
1460
  });
1522
1461
  if (result.executedWith === "fallback") {
@@ -1640,10 +1579,13 @@ export {
1640
1579
  FallbackRequiredError,
1641
1580
  CommandUnavailableError,
1642
1581
  EventManager,
1643
- setWagmiConfig,
1582
+ AttestationErrorCodes,
1583
+ AttestationError,
1584
+ attestation,
1644
1585
  ChatErrorCodes,
1645
1586
  ChatError,
1646
1587
  chat,
1588
+ closeMiniApp,
1647
1589
  GetPermissionsErrorCodes,
1648
1590
  Permission,
1649
1591
  GetPermissionsError,
@@ -1662,6 +1604,7 @@ export {
1662
1604
  SendHapticFeedbackErrorCodes,
1663
1605
  SendHapticFeedbackError,
1664
1606
  sendHapticFeedback,
1607
+ setFallbackAdapter,
1665
1608
  SendTransactionErrorCodes,
1666
1609
  SendTransactionErrorMessage,
1667
1610
  WORLD_APP_FEATURES,