@worldcoin/minikit-js 2.0.1 → 2.0.3

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.
Files changed (33) hide show
  1. package/build/chunk-2ADHLH4F.js +14 -0
  2. package/build/{chunk-6SCI6OTQ.js → chunk-5B6BPEWR.js} +105 -73
  3. package/build/chunk-6E2XIIO6.js +8 -0
  4. package/build/{chunk-MOORQBWF.js → chunk-7RB4UJBW.js} +6 -4
  5. package/build/{chunk-XHYUUG6Y.js → chunk-AH3WTRZY.js} +16 -221
  6. package/build/chunk-DZ2YRSIU.js +216 -0
  7. package/build/{chunk-QX4OA3EY.js → chunk-MXMNPAOF.js} +8 -10
  8. package/build/{chunk-IYL4VCWR.js → chunk-YPZEODWL.js} +30 -13
  9. package/build/command-exports.cjs +18 -20
  10. package/build/command-exports.d.cts +4 -4
  11. package/build/command-exports.d.ts +4 -4
  12. package/build/command-exports.js +14 -12
  13. package/build/connector/index.cjs +275 -246
  14. package/build/connector/index.js +10 -7
  15. package/build/index.cjs +33 -29
  16. package/build/index.d.cts +2 -2
  17. package/build/index.d.ts +2 -2
  18. package/build/index.js +6 -4
  19. package/build/minikit-provider.cjs +36 -307
  20. package/build/minikit-provider.js +15 -8
  21. package/build/siwe-exports.cjs +28 -12
  22. package/build/siwe-exports.d.cts +3 -2
  23. package/build/siwe-exports.d.ts +3 -2
  24. package/build/siwe-exports.js +1 -1
  25. package/build/{types-BV7utGi5.d.ts → types-B3FhypWE.d.ts} +1 -1
  26. package/build/{types-UxYgWVfF.d.ts → types-COxx4rrS.d.cts} +2 -0
  27. package/build/{types-UxYgWVfF.d.cts → types-COxx4rrS.d.ts} +2 -0
  28. package/build/{types-CBzfDT31.d.cts → types-D_X89fCc.d.cts} +1 -1
  29. package/build/wagmi-fallback-register.cjs +362 -0
  30. package/build/wagmi-fallback-register.d.cts +10 -0
  31. package/build/wagmi-fallback-register.d.ts +10 -0
  32. package/build/wagmi-fallback-register.js +14 -0
  33. package/package.json +11 -1
@@ -0,0 +1,14 @@
1
+ // src/helpers/hex.ts
2
+ var HEX_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/;
3
+ var HEX_STRING_REGEX = /^0x[0-9a-fA-F]*$/;
4
+ function isHexAddress(value) {
5
+ return typeof value === "string" && HEX_ADDRESS_REGEX.test(value);
6
+ }
7
+ function isHexString(value) {
8
+ return typeof value === "string" && HEX_STRING_REGEX.test(value);
9
+ }
10
+
11
+ export {
12
+ isHexAddress,
13
+ isHexString
14
+ };
@@ -1,19 +1,25 @@
1
1
  import {
2
+ isHexAddress,
3
+ isHexString
4
+ } from "./chunk-2ADHLH4F.js";
5
+ import {
6
+ WAGMI_CONFIG_KEY,
7
+ WAGMI_INSTALL_HOOK_KEY
8
+ } from "./chunk-6E2XIIO6.js";
9
+ import {
10
+ PartialExecutionError,
2
11
  setFallbackAdapter
3
- } from "./chunk-XHYUUG6Y.js";
12
+ } from "./chunk-DZ2YRSIU.js";
4
13
 
5
14
  // src/commands/wagmi-fallback.ts
6
15
  var SIWE_NONCE_REGEX = /^[a-zA-Z0-9]{8,}$/;
7
- var WAGMI_KEY = "__minikit_wagmi_config__";
8
16
  function setWagmiConfig(config) {
9
- globalThis[WAGMI_KEY] = config;
17
+ globalThis[WAGMI_CONFIG_KEY] = config;
10
18
  registerWagmiFallbacks();
11
19
  }
20
+ globalThis[WAGMI_INSTALL_HOOK_KEY] = setWagmiConfig;
12
21
  function getWagmiConfig() {
13
- return globalThis[WAGMI_KEY];
14
- }
15
- function hasWagmiConfig() {
16
- return globalThis[WAGMI_KEY] !== void 0;
22
+ return globalThis[WAGMI_CONFIG_KEY];
17
23
  }
18
24
  function registerWagmiFallbacks() {
19
25
  setFallbackAdapter({
@@ -24,21 +30,9 @@ function registerWagmiFallbacks() {
24
30
  });
25
31
  }
26
32
  async function loadWagmiActions() {
27
- console.log("[MiniKit WagmiFallback] loadWagmiActions:start", {
28
- hasWindow: typeof window !== "undefined",
29
- hasWagmiConfig: hasWagmiConfig()
30
- });
31
33
  try {
32
- const actions = await import(
33
- /* webpackIgnore: true */
34
- "wagmi/actions"
35
- );
36
- console.log("[MiniKit WagmiFallback] loadWagmiActions:success");
37
- return actions;
34
+ return await import("wagmi/actions");
38
35
  } catch (error) {
39
- console.log("[MiniKit WagmiFallback] loadWagmiActions:error", {
40
- message: error instanceof Error ? error.message : String(error)
41
- });
42
36
  const wrappedError = new Error(
43
37
  'Wagmi fallback requires the "wagmi" package. Install wagmi or provide a custom fallback.'
44
38
  );
@@ -48,10 +42,7 @@ async function loadWagmiActions() {
48
42
  }
49
43
  async function loadSiwe() {
50
44
  try {
51
- return await import(
52
- /* webpackIgnore: true */
53
- "siwe"
54
- );
45
+ return await import("siwe");
55
46
  } catch (error) {
56
47
  const wrappedError = new Error(
57
48
  'Wagmi walletAuth fallback requires the "siwe" package. Install siwe or provide a custom fallback.'
@@ -62,10 +53,7 @@ async function loadSiwe() {
62
53
  }
63
54
  async function checksumAddress(addr) {
64
55
  try {
65
- const { getAddress } = await import(
66
- /* webpackIgnore: true */
67
- "viem"
68
- );
56
+ const { getAddress } = await import("viem");
69
57
  return getAddress(addr);
70
58
  } catch {
71
59
  return addr;
@@ -78,7 +66,10 @@ async function ensureConnected(config) {
78
66
  (connection) => connection.accounts && connection.accounts.length > 0 && (isWorldApp || connection.connector?.id !== "worldApp")
79
67
  );
80
68
  if (existingConnection && existingConnection.accounts) {
81
- return checksumAddress(existingConnection.accounts[0]);
69
+ return {
70
+ address: await checksumAddress(existingConnection.accounts[0]),
71
+ connector: existingConnection.connector
72
+ };
82
73
  }
83
74
  const connectors = config.connectors;
84
75
  if (!connectors || connectors.length === 0) {
@@ -99,7 +90,10 @@ async function ensureConnected(config) {
99
90
  const account = result.accounts[0];
100
91
  const address = typeof account === "string" ? account : account.address;
101
92
  if (address) {
102
- return checksumAddress(address);
93
+ return {
94
+ address: await checksumAddress(address),
95
+ connector: selectedConnector
96
+ };
103
97
  }
104
98
  }
105
99
  } catch (error) {
@@ -113,20 +107,15 @@ async function ensureConnected(config) {
113
107
  throw new Error("Failed to connect wallet");
114
108
  }
115
109
  async function wagmiWalletAuth(params) {
116
- console.log("[MiniKit WagmiFallback] walletAuth:start", {
117
- hasWagmiConfig: hasWagmiConfig(),
118
- nonceLength: params.nonce?.length ?? 0
119
- });
120
110
  const config = getWagmiConfig();
121
111
  if (!config) {
122
- console.log("[MiniKit WagmiFallback] walletAuth:error:no-config");
123
112
  throw new Error(
124
113
  "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
125
114
  );
126
115
  }
127
116
  const { signMessage } = await loadWagmiActions();
128
117
  const { SiweMessage } = await loadSiwe();
129
- const address = await ensureConnected(config);
118
+ const { address, connector } = await ensureConnected(config);
130
119
  if (!SIWE_NONCE_REGEX.test(params.nonce)) {
131
120
  throw new Error(
132
121
  "Invalid nonce: must be alphanumeric and at least 8 characters (EIP-4361)"
@@ -144,7 +133,11 @@ async function wagmiWalletAuth(params) {
144
133
  expirationTime: params.expirationTime?.toISOString()
145
134
  });
146
135
  const message = siweMessage.prepareMessage();
147
- const signature = await signMessage(config, { message });
136
+ const signature = await signMessage(config, {
137
+ connector,
138
+ account: address,
139
+ message
140
+ });
148
141
  return {
149
142
  address,
150
143
  message,
@@ -152,19 +145,16 @@ async function wagmiWalletAuth(params) {
152
145
  };
153
146
  }
154
147
  async function wagmiSignMessage(params) {
155
- console.log("[MiniKit WagmiFallback] signMessage:start", {
156
- hasWagmiConfig: hasWagmiConfig()
157
- });
158
148
  const config = getWagmiConfig();
159
149
  if (!config) {
160
- console.log("[MiniKit WagmiFallback] signMessage:error:no-config");
161
150
  throw new Error(
162
151
  "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
163
152
  );
164
153
  }
165
154
  const { signMessage } = await loadWagmiActions();
166
- const address = await ensureConnected(config);
155
+ const { address, connector } = await ensureConnected(config);
167
156
  const signature = await signMessage(config, {
157
+ connector,
168
158
  account: address,
169
159
  message: params.message
170
160
  });
@@ -176,26 +166,22 @@ async function wagmiSignMessage(params) {
176
166
  };
177
167
  }
178
168
  async function wagmiSignTypedData(params) {
179
- console.log("[MiniKit WagmiFallback] signTypedData:start", {
180
- hasWagmiConfig: hasWagmiConfig(),
181
- hasChainId: params.chainId !== void 0
182
- });
183
169
  const config = getWagmiConfig();
184
170
  if (!config) {
185
- console.log("[MiniKit WagmiFallback] signTypedData:error:no-config");
186
171
  throw new Error(
187
172
  "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
188
173
  );
189
174
  }
190
175
  const { getChainId, signTypedData, switchChain } = await loadWagmiActions();
191
- const address = await ensureConnected(config);
176
+ const { address, connector } = await ensureConnected(config);
192
177
  if (params.chainId !== void 0) {
193
178
  const currentChainId = await getChainId(config);
194
179
  if (currentChainId !== params.chainId) {
195
- await switchChain(config, { chainId: params.chainId });
180
+ await switchChain(config, { chainId: params.chainId, connector });
196
181
  }
197
182
  }
198
183
  const signature = await signTypedData(config, {
184
+ connector,
199
185
  account: address,
200
186
  types: params.types,
201
187
  primaryType: params.primaryType,
@@ -213,27 +199,59 @@ function isChainMismatchError(error) {
213
199
  const message = error instanceof Error ? error.message : String(error);
214
200
  return message.includes("does not match the target chain");
215
201
  }
216
- async function wagmiSendTransaction(params) {
217
- console.log("[MiniKit WagmiFallback] sendTransaction:start", {
218
- hasWagmiConfig: hasWagmiConfig(),
219
- chainId: params.chainId,
220
- hasData: Boolean(params.transaction.data)
202
+ function validateBatch(transactions) {
203
+ return transactions.map((tx, i) => {
204
+ if (!isHexAddress(tx.address)) {
205
+ throw new Error(
206
+ `Transaction ${i + 1}: invalid address "${tx.address}". Must be a 0x-prefixed 20-byte hex string.`
207
+ );
208
+ }
209
+ if (tx.data !== void 0 && !isHexString(tx.data)) {
210
+ throw new Error(
211
+ `Transaction ${i + 1}: invalid data "${tx.data}". Must be a 0x-prefixed hex string.`
212
+ );
213
+ }
214
+ let value;
215
+ if (tx.value !== void 0 && tx.value !== "") {
216
+ try {
217
+ value = BigInt(tx.value);
218
+ } catch {
219
+ throw new Error(
220
+ `Transaction ${i + 1}: invalid value "${tx.value}". Must be a decimal or hex string parseable as BigInt.`
221
+ );
222
+ }
223
+ if (value < 0n) {
224
+ throw new Error(
225
+ `Transaction ${i + 1}: value cannot be negative (got "${tx.value}").`
226
+ );
227
+ }
228
+ }
229
+ return {
230
+ to: tx.address,
231
+ ...tx.data !== void 0 ? { data: tx.data } : {},
232
+ ...value !== void 0 ? { value } : {}
233
+ };
221
234
  });
235
+ }
236
+ async function wagmiSendTransaction(params) {
237
+ if (params.transactions.length === 0) {
238
+ throw new Error("At least one transaction is required");
239
+ }
240
+ const normalizedTxs = validateBatch(params.transactions);
222
241
  const config = getWagmiConfig();
223
242
  if (!config) {
224
- console.log("[MiniKit WagmiFallback] sendTransaction:error:no-config");
225
243
  throw new Error(
226
244
  "Wagmi config not available. Pass wagmiConfig to MiniKitProvider."
227
245
  );
228
246
  }
229
247
  const { getChainId, getWalletClient, sendTransaction, switchChain } = await loadWagmiActions();
230
- await ensureConnected(config);
248
+ const { address, connector } = await ensureConnected(config);
231
249
  const targetChainId = params.chainId ?? config.chains?.[0]?.id;
232
250
  const ensureTargetChain = async () => {
233
251
  if (targetChainId === void 0) return;
234
252
  const currentChainId = await getChainId(config);
235
253
  if (currentChainId !== targetChainId) {
236
- await switchChain(config, { chainId: targetChainId });
254
+ await switchChain(config, { chainId: targetChainId, connector });
237
255
  }
238
256
  const walletClient = await getWalletClient(config);
239
257
  const providerChainId = walletClient ? await walletClient.getChainId() : await getChainId(config);
@@ -244,27 +262,41 @@ async function wagmiSendTransaction(params) {
244
262
  }
245
263
  };
246
264
  await ensureTargetChain();
247
- let transactionHash;
248
- try {
249
- transactionHash = await sendTransaction(config, {
265
+ const sendWithChainRetry = async (tx) => {
266
+ const send = () => sendTransaction(config, {
267
+ connector,
268
+ account: address,
250
269
  chainId: targetChainId,
251
- to: params.transaction.address,
252
- data: params.transaction.data,
253
- value: params.transaction.value ? BigInt(params.transaction.value) : void 0
270
+ to: tx.to,
271
+ data: tx.data,
272
+ value: tx.value
254
273
  });
255
- } catch (error) {
256
- if (targetChainId === void 0 || !isChainMismatchError(error)) {
274
+ try {
275
+ return await send();
276
+ } catch (error) {
277
+ if (targetChainId !== void 0 && isChainMismatchError(error)) {
278
+ await ensureTargetChain();
279
+ return await send();
280
+ }
281
+ throw error;
282
+ }
283
+ };
284
+ const submitted = [];
285
+ for (let i = 0; i < normalizedTxs.length; i++) {
286
+ try {
287
+ submitted.push(await sendWithChainRetry(normalizedTxs[i]));
288
+ } catch (error) {
289
+ if (submitted.length > 0) {
290
+ throw new PartialExecutionError(
291
+ `Transaction ${i + 1}/${normalizedTxs.length} failed after ${submitted.length} tx(s) were already submitted. Resolve manually.`,
292
+ submitted,
293
+ error
294
+ );
295
+ }
257
296
  throw error;
258
297
  }
259
- await ensureTargetChain();
260
- transactionHash = await sendTransaction(config, {
261
- chainId: targetChainId,
262
- to: params.transaction.address,
263
- data: params.transaction.data,
264
- value: params.transaction.value ? BigInt(params.transaction.value) : void 0
265
- });
266
298
  }
267
- return { transactionHash };
299
+ return { transactionHash: submitted[submitted.length - 1] };
268
300
  }
269
301
 
270
302
  export {
@@ -0,0 +1,8 @@
1
+ // src/global-keys.ts
2
+ var WAGMI_CONFIG_KEY = "__minikit_wagmi_config__";
3
+ var WAGMI_INSTALL_HOOK_KEY = "__minikit_install_wagmi_fallback__";
4
+
5
+ export {
6
+ WAGMI_CONFIG_KEY,
7
+ WAGMI_INSTALL_HOOK_KEY
8
+ };
@@ -5,19 +5,21 @@ import {
5
5
  chat,
6
6
  closeMiniApp,
7
7
  getPermissions,
8
- isInWorldApp,
9
8
  pay,
10
9
  requestPermission,
11
10
  sendHapticFeedback,
12
- sendMiniKitEvent,
13
11
  sendTransaction,
14
12
  share,
15
13
  shareContacts,
16
14
  signMessage,
17
15
  signTypedData,
18
- validateCommands,
19
16
  walletAuth
20
- } from "./chunk-XHYUUG6Y.js";
17
+ } from "./chunk-AH3WTRZY.js";
18
+ import {
19
+ isInWorldApp,
20
+ sendMiniKitEvent,
21
+ validateCommands
22
+ } from "./chunk-DZ2YRSIU.js";
21
23
 
22
24
  // src/helpers/microphone.ts
23
25
  var microphoneSetupDone = false;
@@ -1,135 +1,14 @@
1
1
  import {
2
2
  generateSiweMessage
3
- } from "./chunk-IYL4VCWR.js";
4
-
5
- // src/commands/types.ts
6
- var Command = /* @__PURE__ */ ((Command2) => {
7
- Command2["Attestation"] = "attestation";
8
- Command2["Pay"] = "pay";
9
- Command2["WalletAuth"] = "wallet-auth";
10
- Command2["SendTransaction"] = "send-transaction";
11
- Command2["SignMessage"] = "sign-message";
12
- Command2["SignTypedData"] = "sign-typed-data";
13
- Command2["ShareContacts"] = "share-contacts";
14
- Command2["RequestPermission"] = "request-permission";
15
- Command2["GetPermissions"] = "get-permissions";
16
- Command2["SendHapticFeedback"] = "send-haptic-feedback";
17
- Command2["Share"] = "share";
18
- Command2["Chat"] = "chat";
19
- Command2["CloseMiniApp"] = "close-miniapp";
20
- return Command2;
21
- })(Command || {});
22
- var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
23
- ResponseEvent2["MiniAppAttestation"] = "miniapp-attestation";
24
- ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
25
- ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
26
- ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
27
- ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
28
- ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
29
- ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
30
- ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
31
- ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
32
- ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
33
- ResponseEvent2["MiniAppShare"] = "miniapp-share";
34
- ResponseEvent2["MiniAppMicrophone"] = "miniapp-microphone";
35
- ResponseEvent2["MiniAppChat"] = "miniapp-chat";
36
- return ResponseEvent2;
37
- })(ResponseEvent || {});
38
- var COMMAND_VERSIONS = {
39
- ["attestation" /* Attestation */]: 1,
40
- ["pay" /* Pay */]: 1,
41
- ["wallet-auth" /* WalletAuth */]: 2,
42
- ["send-transaction" /* SendTransaction */]: 2,
43
- ["sign-message" /* SignMessage */]: 1,
44
- ["sign-typed-data" /* SignTypedData */]: 1,
45
- ["share-contacts" /* ShareContacts */]: 1,
46
- ["request-permission" /* RequestPermission */]: 1,
47
- ["get-permissions" /* GetPermissions */]: 1,
48
- ["send-haptic-feedback" /* SendHapticFeedback */]: 1,
49
- ["share" /* Share */]: 1,
50
- ["chat" /* Chat */]: 1,
51
- ["close-miniapp" /* CloseMiniApp */]: 1
52
- };
53
- var commandAvailability = {
54
- ["attestation" /* Attestation */]: false,
55
- ["pay" /* Pay */]: false,
56
- ["wallet-auth" /* WalletAuth */]: false,
57
- ["send-transaction" /* SendTransaction */]: false,
58
- ["sign-message" /* SignMessage */]: false,
59
- ["sign-typed-data" /* SignTypedData */]: false,
60
- ["share-contacts" /* ShareContacts */]: false,
61
- ["request-permission" /* RequestPermission */]: false,
62
- ["get-permissions" /* GetPermissions */]: false,
63
- ["send-haptic-feedback" /* SendHapticFeedback */]: false,
64
- ["share" /* Share */]: false,
65
- ["chat" /* Chat */]: false,
66
- ["close-miniapp" /* CloseMiniApp */]: false
67
- };
68
- function isCommandAvailable(command) {
69
- return commandAvailability[command] ?? false;
70
- }
71
- function setCommandAvailable(command, available) {
72
- commandAvailability[command] = available;
73
- }
74
- function validateCommands(worldAppSupportedCommands) {
75
- let allCommandsValid = true;
76
- Object.entries(COMMAND_VERSIONS).forEach(([commandName, version]) => {
77
- const commandInput = worldAppSupportedCommands.find(
78
- (cmd) => cmd.name === commandName
79
- );
80
- let isCommandValid = false;
81
- if (!commandInput) {
82
- console.warn(
83
- `Command ${commandName} is not supported by the app. Try updating the app version`
84
- );
85
- } else {
86
- if (commandInput.supported_versions.includes(version)) {
87
- setCommandAvailable(commandName, true);
88
- isCommandValid = true;
89
- } else {
90
- isCommandValid = true;
91
- console.warn(
92
- `Command ${commandName} version ${version} is not supported by the app. Supported versions: ${commandInput.supported_versions.join(", ")}. This is not an error, but it is recommended to update the World App version.`
93
- );
94
- setCommandAvailable(commandName, true);
95
- }
96
- }
97
- if (!isCommandValid) {
98
- allCommandsValid = false;
99
- }
100
- });
101
- return allCommandsValid;
102
- }
103
- function sendMiniKitEvent(payload) {
104
- if (window.webkit) {
105
- window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
106
- } else if (window.Android) {
107
- window.Android?.postMessage?.(JSON.stringify(payload));
108
- }
109
- }
110
- function isInWorldApp() {
111
- return typeof window !== "undefined" && Boolean(window.WorldApp);
112
- }
113
- var FallbackRequiredError = class extends Error {
114
- constructor(command) {
115
- super(
116
- `${command} requires a fallback function when running outside World App. Provide a fallback option: MiniKit.${command}({ ..., fallback: () => yourFallback() })`
117
- );
118
- this.name = "FallbackRequiredError";
119
- }
120
- };
121
- var CommandUnavailableError = class extends Error {
122
- constructor(command, reason) {
123
- const messages = {
124
- notInWorldApp: "Not running inside World App",
125
- commandNotSupported: "Command not supported in this environment",
126
- oldAppVersion: "World App version does not support this command"
127
- };
128
- super(`${command} is unavailable: ${messages[reason]}`);
129
- this.name = "CommandUnavailableError";
130
- this.reason = reason;
131
- }
132
- };
3
+ } from "./chunk-YPZEODWL.js";
4
+ import {
5
+ COMMAND_VERSIONS,
6
+ CommandUnavailableError,
7
+ executeWithFallback,
8
+ getFallbackAdapter,
9
+ isCommandAvailable,
10
+ sendMiniKitEvent
11
+ } from "./chunk-DZ2YRSIU.js";
133
12
 
134
13
  // src/commands/attestation/types.ts
135
14
  var AttestationErrorCodes = /* @__PURE__ */ ((AttestationErrorCodes2) => {
@@ -197,57 +76,6 @@ var EventManager = class {
197
76
  }
198
77
  };
199
78
 
200
- // src/commands/fallback.ts
201
- async function executeWithFallback(options) {
202
- const {
203
- command,
204
- nativeExecutor,
205
- wagmiFallback,
206
- customFallback,
207
- requiresFallback = false
208
- } = options;
209
- const inWorldApp = isInWorldApp();
210
- const commandAvailable = isCommandAvailable(command);
211
- let nativeError;
212
- if (inWorldApp && commandAvailable) {
213
- try {
214
- const data = await nativeExecutor();
215
- return { data, executedWith: "minikit" };
216
- } catch (error) {
217
- nativeError = error;
218
- console.warn(`Native ${command} failed, attempting fallback:`, error);
219
- }
220
- }
221
- if (!inWorldApp && wagmiFallback) {
222
- try {
223
- const data = await wagmiFallback();
224
- return { data, executedWith: "wagmi" };
225
- } catch (error) {
226
- console.warn(`Wagmi fallback for ${command} failed:`, error);
227
- }
228
- }
229
- if (!inWorldApp && customFallback) {
230
- const data = await customFallback();
231
- return { data, executedWith: "fallback" };
232
- }
233
- if (nativeError) {
234
- throw nativeError;
235
- }
236
- if (requiresFallback && !inWorldApp) {
237
- throw new FallbackRequiredError(command);
238
- }
239
- throw new CommandUnavailableError(command, determineFallbackReason(command));
240
- }
241
- function determineFallbackReason(command) {
242
- if (!isInWorldApp()) {
243
- return "notInWorldApp";
244
- }
245
- if (!isCommandAvailable(command)) {
246
- return "oldAppVersion";
247
- }
248
- return "commandNotSupported";
249
- }
250
-
251
79
  // src/commands/attestation/index.ts
252
80
  async function attestation(options, ctx) {
253
81
  const result = await executeWithFallback({
@@ -802,15 +630,6 @@ var SendTransactionError = class extends Error {
802
630
  }
803
631
  };
804
632
 
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
- }
813
-
814
633
  // src/commands/send-transaction/validate.ts
815
634
  var isValidHex = (str) => {
816
635
  return /^0x[0-9A-Fa-f]+$/.test(str);
@@ -871,7 +690,6 @@ var validateSendTransactionPayload = (payload) => {
871
690
 
872
691
  // src/commands/send-transaction/index.ts
873
692
  var WORLD_CHAIN_ID = 480;
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
693
  function resolveChainId(options) {
876
694
  return options.chainId;
877
695
  }
@@ -898,12 +716,6 @@ function normalizeSendTransactionOptions(options) {
898
716
  async function sendTransaction(options, ctx) {
899
717
  const normalizedOptions = normalizeSendTransactionOptions(options);
900
718
  const fallbackAdapter = getFallbackAdapter();
901
- const isWagmiFallbackPath = !isInWorldApp() && Boolean(fallbackAdapter?.sendTransaction);
902
- if (isWagmiFallbackPath && normalizedOptions.transactions.length > 1 && !options.fallback) {
903
- throw new SendTransactionError("invalid_operation" /* InvalidOperation */, {
904
- reason: WAGMI_MULTI_TX_ERROR_MESSAGE
905
- });
906
- }
907
719
  const result = await executeWithFallback({
908
720
  command: "send-transaction" /* SendTransaction */,
909
721
  nativeExecutor: () => nativeSendTransaction(normalizedOptions, ctx),
@@ -984,23 +796,16 @@ async function nativeSendTransaction(options, ctx) {
984
796
  };
985
797
  }
986
798
  async function adapterSendTransactionFallback(options) {
987
- if (options.transactions.length > 1) {
988
- throw new Error(WAGMI_MULTI_TX_ERROR_MESSAGE);
989
- }
990
- const firstTransaction = options.transactions[0];
991
- if (!firstTransaction) {
992
- throw new Error("At least one transaction is required");
993
- }
994
799
  const fallbackAdapter = getFallbackAdapter();
995
800
  if (!fallbackAdapter?.sendTransaction) {
996
801
  throw new Error("Fallback adapter is not registered.");
997
802
  }
998
803
  const result = await fallbackAdapter.sendTransaction({
999
- transaction: {
1000
- address: firstTransaction.to,
1001
- data: firstTransaction.data,
1002
- value: firstTransaction.value
1003
- },
804
+ transactions: options.transactions.map((tx) => ({
805
+ address: tx.to,
806
+ data: tx.data,
807
+ value: tx.value
808
+ })),
1004
809
  chainId: options.chainId
1005
810
  });
1006
811
  return {
@@ -1542,7 +1347,8 @@ async function nativeWalletAuth(options, ctx) {
1542
1347
  return {
1543
1348
  address: finalPayload.address,
1544
1349
  message: finalPayload.message,
1545
- signature: finalPayload.signature
1350
+ signature: finalPayload.signature,
1351
+ version: finalPayload.version
1546
1352
  };
1547
1353
  }
1548
1354
 
@@ -1572,16 +1378,6 @@ var MiniKitInstallErrorMessage = {
1572
1378
  };
1573
1379
 
1574
1380
  export {
1575
- Command,
1576
- ResponseEvent,
1577
- COMMAND_VERSIONS,
1578
- isCommandAvailable,
1579
- setCommandAvailable,
1580
- validateCommands,
1581
- sendMiniKitEvent,
1582
- isInWorldApp,
1583
- FallbackRequiredError,
1584
- CommandUnavailableError,
1585
1381
  EventManager,
1586
1382
  AttestationErrorCodes,
1587
1383
  AttestationError,
@@ -1608,7 +1404,6 @@ export {
1608
1404
  SendHapticFeedbackErrorCodes,
1609
1405
  SendHapticFeedbackError,
1610
1406
  sendHapticFeedback,
1611
- setFallbackAdapter,
1612
1407
  SendTransactionErrorCodes,
1613
1408
  SendTransactionErrorMessage,
1614
1409
  WORLD_APP_FEATURES,