@latticexyz/entrykit 2.2.23-2ade90f493b15b4dbe56c08e97e4f8e97b716c3f → 2.2.23-63fb9640350ff7d87d226fa827ad53e1e79f77e9

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.
@@ -58,10 +58,16 @@ import { privateKeyToAccount } from "viem/accounts";
58
58
  // src/quarry/transports/userOpExecutor.ts
59
59
  import {
60
60
  createTransport,
61
+ getAbiItem,
61
62
  numberToHex,
62
63
  parseEther
63
64
  } from "viem";
64
- import { entryPoint07Address as entryPoint07Address2 } from "viem/account-abstraction";
65
+ import {
66
+ entryPoint06Abi,
67
+ entryPoint06Address,
68
+ entryPoint07Address as entryPoint07Address2,
69
+ entryPoint08Address
70
+ } from "viem/account-abstraction";
65
71
 
66
72
  // src/quarry/transports/methods/estimateUserOperationGas.ts
67
73
  import { formatUserOperationRequest } from "viem/account-abstraction";
@@ -138,7 +144,8 @@ error.log = console.error.bind(console);
138
144
  var debug2 = debug.extend("quarry");
139
145
 
140
146
  // src/quarry/transports/userOpExecutor.ts
141
- import { setBalance } from "viem/actions";
147
+ import { getLogs, getTransactionReceipt, setBalance } from "viem/actions";
148
+ import { getUserOperationReceipt } from "@latticexyz/common/internal";
142
149
  function userOpExecutor({
143
150
  executor,
144
151
  fallbackDefaultTransport
@@ -172,8 +179,38 @@ function userOpExecutor({
172
179
  }
173
180
  }
174
181
  if (method === "eth_getUserOperationReceipt") {
175
- const [hash] = params;
176
- return receipts.get(hash) ?? null;
182
+ const [userOpHash] = params;
183
+ if (receipts.has(userOpHash)) return receipts.get(userOpHash);
184
+ const event = getAbiItem({
185
+ abi: entryPoint06Abi,
186
+ name: "UserOperationEvent"
187
+ });
188
+ const log = (await getLogs(executor, {
189
+ address: [entryPoint06Address, entryPoint07Address2, entryPoint08Address],
190
+ event,
191
+ args: { userOpHash }
192
+ })).at(0);
193
+ if (!log) return null;
194
+ const hash = log.transactionHash;
195
+ const receipt = await getTransactionReceipt(executor, { hash });
196
+ const userOpReceipt = getUserOperationReceipt(userOpHash, {
197
+ ...receipt,
198
+ blobGasPrice: receipt.blobGasPrice ? numberToHex(receipt.blobGasPrice) : void 0,
199
+ blobGasUsed: receipt.blobGasUsed ? numberToHex(receipt.blobGasUsed) : void 0,
200
+ blockNumber: numberToHex(receipt.blockNumber),
201
+ cumulativeGasUsed: numberToHex(receipt.cumulativeGasUsed),
202
+ effectiveGasPrice: numberToHex(receipt.effectiveGasPrice),
203
+ gasUsed: numberToHex(receipt.gasUsed),
204
+ logs: receipt.logs.map((log2) => ({
205
+ ...log2,
206
+ blockNumber: numberToHex(log2.blockNumber),
207
+ logIndex: numberToHex(log2.logIndex),
208
+ transactionIndex: numberToHex(log2.transactionIndex)
209
+ })),
210
+ status: receipt.status,
211
+ transactionIndex: numberToHex(receipt.transactionIndex)
212
+ });
213
+ return userOpReceipt;
177
214
  }
178
215
  if (method === "eth_estimateUserOperationGas") {
179
216
  return await estimateUserOperationGas(params);
@@ -525,37 +562,73 @@ function AppInfo() {
525
562
  // src/ConnectWallet.tsx
526
563
  import { twMerge as twMerge5 } from "tailwind-merge";
527
564
  import { useEffect as useEffect3, useRef as useRef2 } from "react";
528
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
565
+ import { useConnect, useConnectors } from "wagmi";
566
+ import { isIdPlaceConnector } from "@latticexyz/id.place/internal";
567
+ import { Fragment, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
529
568
  function ConnectWallet() {
530
- const { open, setOpen } = useModal();
531
- const hasAutoOpenedRef = useRef2(false);
532
- useEffect3(() => {
533
- if (!open && !hasAutoOpenedRef.current) {
534
- setOpen(true);
535
- hasAutoOpenedRef.current = true;
536
- }
537
- }, [open, setOpen]);
569
+ const connectors = useConnectors();
570
+ const porto = connectors.find(isIdPlaceConnector);
538
571
  return /* @__PURE__ */ jsxs7(
539
572
  "div",
540
573
  {
541
574
  className: twMerge5("flex flex-col gap-6 p-6", "animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),
542
575
  children: [
543
576
  /* @__PURE__ */ jsx9("div", { className: "p-4", children: /* @__PURE__ */ jsx9(AppInfo, {}) }),
544
- /* @__PURE__ */ jsx9("div", { className: "self-center flex flex-col gap-2 w-60", children: /* @__PURE__ */ jsx9(
545
- Button,
546
- {
547
- variant: "secondary",
548
- className: "self-auto flex justify-center",
549
- onClick: () => setOpen(true),
550
- autoFocus: true,
551
- children: "Connect wallet"
552
- },
553
- "create"
554
- ) })
577
+ /* @__PURE__ */ jsx9("div", { className: "self-center flex flex-col gap-2 w-60", children: porto ? /* @__PURE__ */ jsx9(AccountButton, { connector: porto }) : /* @__PURE__ */ jsx9(WalletButton, {}) })
555
578
  ]
556
579
  }
557
580
  );
558
581
  }
582
+ function AccountButton({ connector }) {
583
+ const { setOpen } = useModal();
584
+ const { connect, isPending, error: error2 } = useConnect();
585
+ if (error2) {
586
+ console.error("connect error", error2);
587
+ }
588
+ return /* @__PURE__ */ jsxs7(Fragment, { children: [
589
+ /* @__PURE__ */ jsx9(
590
+ Button,
591
+ {
592
+ variant: "secondary",
593
+ className: "self-auto flex justify-center",
594
+ pending: isPending,
595
+ onClick: () => connect({ connector }),
596
+ autoFocus: true,
597
+ children: "Sign in"
598
+ },
599
+ "signin"
600
+ ),
601
+ /* @__PURE__ */ jsx9(
602
+ "button",
603
+ {
604
+ className: "text-sm self-center transition text-neutral-500 hover:text-white p-2",
605
+ onClick: () => setOpen(true),
606
+ children: "Already have a wallet?"
607
+ }
608
+ )
609
+ ] });
610
+ }
611
+ function WalletButton() {
612
+ const { open, setOpen } = useModal();
613
+ const hasAutoOpenedRef = useRef2(false);
614
+ useEffect3(() => {
615
+ if (!open && !hasAutoOpenedRef.current) {
616
+ setOpen(true);
617
+ hasAutoOpenedRef.current = true;
618
+ }
619
+ }, [open, setOpen]);
620
+ return /* @__PURE__ */ jsx9(Fragment, { children: /* @__PURE__ */ jsx9(
621
+ Button,
622
+ {
623
+ variant: "secondary",
624
+ className: "self-auto flex justify-center",
625
+ onClick: () => setOpen(true),
626
+ autoFocus: true,
627
+ children: "Connect wallet"
628
+ },
629
+ "create"
630
+ ) });
631
+ }
559
632
 
560
633
  // src/onboarding/ConnectedSteps.tsx
561
634
  import { useEffect as useEffect15, useMemo as useMemo4, useRef as useRef5, useState as useState5 } from "react";
@@ -573,26 +646,35 @@ import { queryOptions, skipToken, useQuery as useQuery2 } from "@tanstack/react-
573
646
  import { defineStore } from "@latticexyz/store";
574
647
  import { parseAbi } from "viem";
575
648
  var paymasterAbi = parseAbi([
649
+ // AllowanceSystem
650
+ "error AllowanceSystem_InsufficientAllowance(uint256 allowance, uint256 required)",
651
+ "error AllowanceSystem_NotAuthorized(address caller, address sponsor, address user)",
652
+ "error AllowanceSystem_NotFound(address user, address sponsor)",
653
+ "function removeAllowance(address user, address sponsor)",
654
+ "function getAllowance(address user) view returns (uint256)",
655
+ // GrantSystem
656
+ "error GrantSystem_AllowanceBelowMinimum(uint256 allowance, uint256 min)",
657
+ "error GrantSystem_AllowancesLimitReached(uint256 length, uint256 max)",
658
+ "error GrantSystem_InsufficientBalance(uint256 balance, uint256 required)",
659
+ "function grantAllowance(address user, uint256 allowance) payable",
660
+ // BalanceSystem
661
+ "error BalanceSystem_InsufficientBalance(address user, uint256 amount, uint256 balance)",
662
+ "function depositTo(address to) payable",
663
+ "function withdrawTo(address to, uint256 amount)",
664
+ // SpenderSystem
576
665
  "error SpenderSystem_AlreadyRegistered(address spender, address user)",
577
666
  "error SpenderSystem_HasOwnBalance(address spender)",
578
- "error BalanceSystem_BalanceTooHigh(address user, uint256 balance, uint256 max)",
579
- "error BalanceSystem_InsufficientBalance(address user, uint256 amount, uint256 balance)",
580
667
  "function registerSpender(address spender)",
581
- "function depositTo(address to) payable",
582
- "function withdrawTo(address to, uint256 amount)"
668
+ // PaymasterSystem
669
+ "error PaymasterSystem_InsufficientFunds(address user, uint256 maxCost, uint256 availableAllowance, uint256 availableBalance)",
670
+ "error PaymasterSystem_OnlyEntryPoint()"
583
671
  ]);
584
672
  var paymasterConfig = defineStore({
585
673
  namespaces: {
586
674
  root: {
587
675
  namespace: "",
588
676
  tables: {
589
- Allowance: {
590
- schema: {
591
- user: "address",
592
- allowance: "uint256"
593
- },
594
- key: ["user"]
595
- },
677
+ // Balance gets deposited and is withdrawable
596
678
  Balance: {
597
679
  schema: {
598
680
  user: "address",
@@ -600,31 +682,26 @@ var paymasterConfig = defineStore({
600
682
  },
601
683
  key: ["user"]
602
684
  },
603
- Grantor: {
604
- schema: {
605
- grantor: "address",
606
- allowance: "uint256"
607
- },
608
- key: ["grantor"]
609
- },
610
- PassHolder: {
685
+ // Allowance gets granted and is not withdrawable
686
+ // Allowance is organized as a linked list and gets spent from smallest to largest
687
+ Allowance: {
688
+ name: "AllowanceV2",
611
689
  schema: {
612
690
  user: "address",
613
- passId: "bytes32",
614
- lastRenewed: "uint256",
615
- lastClaimed: "uint256"
691
+ sponsor: "address",
692
+ allowance: "uint256",
693
+ next: "address",
694
+ previous: "address"
616
695
  },
617
- key: ["user", "passId"]
696
+ key: ["user", "sponsor"]
618
697
  },
619
- PassConfig: {
698
+ AllowanceList: {
620
699
  schema: {
621
- passId: "bytes32",
622
- claimAmount: "uint256",
623
- claimInterval: "uint256",
624
- validityPeriod: "uint256",
625
- grantor: "address"
700
+ user: "address",
701
+ first: "address",
702
+ length: "uint256"
626
703
  },
627
- key: ["passId"]
704
+ key: ["user"]
628
705
  },
629
706
  Spender: {
630
707
  schema: {
@@ -656,7 +733,7 @@ function getPaymaster(chain) {
656
733
  return {
657
734
  type: "quarry",
658
735
  address: contracts.quarryPaymaster.address,
659
- isGasPass: !!chain.rpcUrls.quarryPassIssuer?.http?.[0]
736
+ canSponsor: !!chain.rpcUrls.quarrySponsor?.http?.[0]
660
737
  };
661
738
  }
662
739
  }
@@ -831,36 +908,21 @@ import { useClient as useClient4 } from "wagmi";
831
908
  import { queryOptions as queryOptions4, skipToken as skipToken4, useQuery as useQuery5 } from "@tanstack/react-query";
832
909
 
833
910
  // src/quarry/getAllowance.ts
834
- import { numberToHex as numberToHex2 } from "viem";
835
- import { getRecord as getRecord3, getStaticDataLocation } from "@latticexyz/store/internal";
836
- import { getKeyTuple } from "@latticexyz/protocol-parser/internal";
837
- import { setStorageAt } from "viem/actions";
911
+ import { readContract } from "viem/actions";
912
+ import { getAction as getAction2 } from "viem/utils";
838
913
  async function getAllowance({ client, userAddress }) {
839
914
  const paymaster = getPaymaster(client.chain);
840
915
  if (paymaster?.type !== "quarry") return null;
841
- const record = await getRecord3(client, {
916
+ return await getAction2(
917
+ client,
918
+ readContract,
919
+ "readContract"
920
+ )({
842
921
  address: paymaster.address,
843
- table: paymasterTables.Allowance,
844
- key: { user: userAddress },
845
- blockTag: "pending"
922
+ abi: paymasterAbi,
923
+ functionName: "getAllowance",
924
+ args: [userAddress]
846
925
  });
847
- return record.allowance;
848
- }
849
- async function setAllowanceSlot({ client, userAddress, allowance }) {
850
- const paymaster = getPaymaster(client.chain);
851
- if (paymaster?.type !== "quarry") return;
852
- const slot = getStaticDataLocation(
853
- paymasterTables.Allowance.tableId,
854
- getKeyTuple(paymasterTables.Allowance, { user: userAddress })
855
- );
856
- await setStorageAt(
857
- client.extend(() => ({ mode: "anvil" })),
858
- {
859
- address: paymaster.address,
860
- index: slot,
861
- value: numberToHex2(allowance, { size: 32 })
862
- }
863
- );
864
926
  }
865
927
 
866
928
  // src/onboarding/quarry/useAllowance.ts
@@ -884,11 +946,11 @@ import { useClient as useClient5 } from "wagmi";
884
946
  import { queryOptions as queryOptions5, skipToken as skipToken5, useQuery as useQuery6 } from "@tanstack/react-query";
885
947
 
886
948
  // src/quarry/getBalance.ts
887
- import { getRecord as getRecord4 } from "@latticexyz/store/internal";
949
+ import { getRecord as getRecord3 } from "@latticexyz/store/internal";
888
950
  async function getBalance({ client, userAddress }) {
889
951
  const paymaster = getPaymaster(client.chain);
890
952
  if (paymaster?.type !== "quarry") return null;
891
- const record = await getRecord4(client, {
953
+ const record = await getRecord3(client, {
892
954
  address: paymaster.address,
893
955
  table: paymasterTables.Balance,
894
956
  key: { user: userAddress },
@@ -1134,55 +1196,42 @@ function Wallet({ isActive, isExpanded, userAddress }) {
1134
1196
  }
1135
1197
 
1136
1198
  // src/onboarding/quarry/Allowance.tsx
1137
- import { parseEther as parseEther3 } from "viem";
1138
-
1139
- // src/onboarding/quarry/useClaimGasPass.ts
1140
1199
  import { parseEther as parseEther2 } from "viem";
1200
+
1201
+ // src/onboarding/quarry/useRequestAllowance.ts
1141
1202
  import { useMutation, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
1142
1203
 
1143
- // src/quarry/transports/quarryPassIssuer.ts
1204
+ // src/quarry/transports/quarrySponsor.ts
1144
1205
  import { http as http2 } from "viem";
1145
- function quarryPassIssuer() {
1206
+ function quarrySponsor() {
1146
1207
  return ({ chain }) => {
1147
- if (!chain) throw new Error("No chain provided to issuer transport.");
1148
- const url = "quarryPassIssuer" in chain.rpcUrls ? chain.rpcUrls.quarryPassIssuer.http[0] : void 0;
1149
- if (!url) throw new Error(`No \`quarryPassIssuer\` RPC URL found for chain ${chain.id}.`);
1208
+ if (!chain) throw new Error("No chain provided to quarrySponsor transport.");
1209
+ const url = "quarrySponsor" in chain.rpcUrls ? chain.rpcUrls.quarrySponsor.http[0] : void 0;
1210
+ if (!url) throw new Error(`No \`quarrySponsor\` RPC URL found for chain ${chain.id}.`);
1150
1211
  return http2(url)({ chain, retryCount: 0 });
1151
1212
  };
1152
1213
  }
1153
1214
 
1154
- // src/quarry/claimGasPass.ts
1155
- async function claimGasPass({ chain, userAddress }) {
1156
- const transport = quarryPassIssuer()({ chain });
1157
- debug2("Issuing gas pass to", userAddress);
1215
+ // src/quarry/requestAllowance.ts
1216
+ async function requestAllowance({ chain, userAddress }) {
1217
+ const transport = quarrySponsor()({ chain });
1218
+ debug2("Requesting allowance for", userAddress);
1158
1219
  await transport.request({
1159
- method: "quarry_issuePass",
1160
- params: ["0x01", userAddress]
1161
- });
1162
- debug2("Claiming gas allowance for", userAddress);
1163
- await transport.request({
1164
- method: "quarry_claimAllowance",
1165
- params: ["0x01", userAddress]
1220
+ method: "sponsor_requestAllowance",
1221
+ params: [userAddress]
1166
1222
  });
1167
1223
  }
1168
1224
 
1169
- // src/onboarding/quarry/useClaimGasPass.ts
1170
- import { useClient as useClient8 } from "wagmi";
1171
- function useClaimGasPass() {
1225
+ // src/onboarding/quarry/useRequestAllowance.ts
1226
+ function useRequestAllowance() {
1172
1227
  const queryClient = useQueryClient3();
1173
1228
  const { chain } = useEntryKitConfig();
1174
- const client = useClient8({ chainId: chain.id });
1175
- const mutationKey = ["claimGasPass", chain.id];
1229
+ const mutationKey = ["requestAllowance", chain.id];
1176
1230
  return useMutation({
1177
1231
  retry: 0,
1178
1232
  mutationKey,
1179
1233
  mutationFn: async (userAddress) => {
1180
- if (chain.id === 31337) {
1181
- if (!client) throw new Error("No client?");
1182
- await setAllowanceSlot({ client, userAddress, allowance: parseEther2("1") });
1183
- } else {
1184
- await claimGasPass({ chain, userAddress });
1185
- }
1234
+ await requestAllowance({ chain, userAddress });
1186
1235
  await Promise.all([
1187
1236
  queryClient.invalidateQueries({ queryKey: ["getAllowance"] }),
1188
1237
  queryClient.invalidateQueries({ queryKey: ["getFunds"] }),
@@ -1256,15 +1305,15 @@ function useShowQueryError(result) {
1256
1305
  import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
1257
1306
  function Allowance({ isActive, isExpanded, userAddress }) {
1258
1307
  const allowance = useShowQueryError(useAllowance(userAddress));
1259
- const claimGasPass2 = useShowMutationError(useClaimGasPass());
1308
+ const requestAllowance2 = useShowMutationError(useRequestAllowance());
1260
1309
  useEffect6(() => {
1261
1310
  const timer = setTimeout(() => {
1262
- if (isActive && claimGasPass2.status === "idle" && allowance.isSuccess && allowance.data != null && allowance.data < parseEther3("0.01")) {
1263
- claimGasPass2.mutate(userAddress);
1311
+ if (isActive && requestAllowance2.status === "idle" && allowance.isSuccess && allowance.data != null && allowance.data < parseEther2("0.01")) {
1312
+ requestAllowance2.mutate(userAddress);
1264
1313
  }
1265
1314
  });
1266
1315
  return () => clearTimeout(timer);
1267
- }, [allowance.data, allowance.isSuccess, claimGasPass2, isActive, userAddress]);
1316
+ }, [allowance.data, allowance.isSuccess, requestAllowance2, isActive, userAddress]);
1268
1317
  return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-4", children: [
1269
1318
  /* @__PURE__ */ jsxs12("div", { className: "flex justify-between gap-4", children: [
1270
1319
  /* @__PURE__ */ jsxs12("div", { children: [
@@ -1277,8 +1326,8 @@ function Allowance({ isActive, isExpanded, userAddress }) {
1277
1326
  variant: isActive ? "primary" : "tertiary",
1278
1327
  className: "flex-shrink-0 text-sm p-1 w-28",
1279
1328
  autoFocus: isActive || isExpanded,
1280
- pending: allowance.status === "pending" || claimGasPass2.status === "pending",
1281
- onClick: () => claimGasPass2.mutate(userAddress),
1329
+ pending: allowance.status === "pending" || requestAllowance2.status === "pending",
1330
+ onClick: () => requestAllowance2.mutate(userAddress),
1282
1331
  children: "Top up"
1283
1332
  }
1284
1333
  )
@@ -1291,11 +1340,11 @@ function Allowance({ isActive, isExpanded, userAddress }) {
1291
1340
  import { useEffect as useEffect7 } from "react";
1292
1341
 
1293
1342
  // src/onboarding/useSetupSession.ts
1294
- import { encodeFunctionData } from "viem";
1343
+ import { encodeFunctionData, parseEventLogs as parseEventLogs2 } from "viem";
1295
1344
  import { useMutation as useMutation2, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
1296
- import { getAction as getAction4 } from "viem/utils";
1297
- import { sendUserOperation as sendUserOperation2, waitForUserOperationReceipt } from "viem/account-abstraction";
1298
- import { waitForTransactionReceipt as waitForTransactionReceipt2 } from "viem/actions";
1345
+ import { getAction as getAction5 } from "viem/utils";
1346
+ import { entryPoint07Abi as entryPoint07Abi2, sendUserOperation as sendUserOperation2, waitForUserOperationReceipt } from "viem/account-abstraction";
1347
+ import { sendCalls, waitForTransactionReceipt as waitForTransactionReceipt2 } from "viem/actions";
1299
1348
 
1300
1349
  // src/utils/defineCall.ts
1301
1350
  function defineCall(call) {
@@ -1303,23 +1352,23 @@ function defineCall(call) {
1303
1352
  }
1304
1353
 
1305
1354
  // src/onboarding/useSetupSession.ts
1306
- import { useClient as useClient9 } from "wagmi";
1355
+ import { useClient as useClient8 } from "wagmi";
1307
1356
  import { resourceToHex as resourceToHex2 } from "@latticexyz/common";
1308
1357
  import IBaseWorldAbi from "@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json";
1309
1358
 
1310
1359
  // src/utils/callWithSignature.ts
1311
1360
  import { parseErc6492Signature } from "viem";
1312
1361
  import { writeContract as viem_writeContract } from "viem/actions";
1313
- import { getAction as getAction3 } from "viem/utils";
1362
+ import { getAction as getAction4 } from "viem/utils";
1314
1363
 
1315
1364
  // src/utils/signCall.ts
1316
1365
  import { toHex } from "viem";
1317
1366
  import { signTypedData } from "viem/actions";
1318
1367
  import { callWithSignatureTypes } from "@latticexyz/world-module-callwithsignature/internal";
1319
- import { getRecord as getRecord5 } from "@latticexyz/store/internal";
1368
+ import { getRecord as getRecord4 } from "@latticexyz/store/internal";
1320
1369
  import moduleConfig from "@latticexyz/world-module-callwithsignature/mud.config";
1321
1370
  import { hexToResource } from "@latticexyz/common";
1322
- import { getAction as getAction2 } from "viem/utils";
1371
+ import { getAction as getAction3 } from "viem/utils";
1323
1372
  async function signCall({
1324
1373
  userClient,
1325
1374
  worldAddress,
@@ -1328,14 +1377,14 @@ async function signCall({
1328
1377
  nonce: initialNonce,
1329
1378
  client
1330
1379
  }) {
1331
- const nonce = initialNonce ?? (client ? (await getRecord5(client, {
1380
+ const nonce = initialNonce ?? (client ? (await getRecord4(client, {
1332
1381
  address: worldAddress,
1333
1382
  table: moduleConfig.tables.CallWithSignatureNonces,
1334
1383
  key: { signer: userClient.account.address },
1335
1384
  blockTag: "pending"
1336
1385
  })).nonce : 0n);
1337
1386
  const { namespace: systemNamespace, name: systemName } = hexToResource(systemId);
1338
- return await getAction2(
1387
+ return await getAction3(
1339
1388
  userClient,
1340
1389
  signTypedData,
1341
1390
  "signTypedData"
@@ -1370,7 +1419,7 @@ async function callWithSignature({
1370
1419
  "ERC-6492 signatures, like from Coinbase Smart Wallet, are not yet supported. Try using a different wallet?"
1371
1420
  );
1372
1421
  }
1373
- return getAction3(
1422
+ return getAction4(
1374
1423
  sessionClient,
1375
1424
  viem_writeContract,
1376
1425
  "writeContract"
@@ -1384,10 +1433,65 @@ async function callWithSignature({
1384
1433
 
1385
1434
  // src/onboarding/useSetupSession.ts
1386
1435
  import { systemsConfig as worldSystemsConfig } from "@latticexyz/world/mud.config";
1387
- function useSetupSession({ userClient }) {
1436
+
1437
+ // src/createBundlerClient.ts
1438
+ import {
1439
+ createBundlerClient as viem_createBundlerClient
1440
+ } from "viem/account-abstraction";
1441
+
1442
+ // src/actions/cachedFeesPerGas.ts
1443
+ import { estimateFeesPerGas } from "viem/actions";
1444
+ function cachedFeesPerGas(client, options = { refreshInterval: 1e4 }) {
1445
+ let fees = null;
1446
+ async function refreshFees() {
1447
+ fees = await estimateFeesPerGas(client);
1448
+ }
1449
+ refreshFees();
1450
+ setInterval(refreshFees, options.refreshInterval);
1451
+ return async () => {
1452
+ if (fees) return fees;
1453
+ fees = await estimateFeesPerGas(client);
1454
+ return fees;
1455
+ };
1456
+ }
1457
+
1458
+ // src/createBundlerClient.ts
1459
+ function createBundlerClient(config) {
1460
+ const client = config.client;
1461
+ if (!client) throw new Error("No `client` provided to `createBundlerClient`.");
1462
+ const chain = config.chain ?? client.chain;
1463
+ const paymaster = chain ? getPaymaster(chain) : void 0;
1464
+ return viem_createBundlerClient({
1465
+ ...defaultClientConfig,
1466
+ paymaster: paymaster ? {
1467
+ getPaymasterData: async () => ({
1468
+ paymaster: paymaster.address,
1469
+ paymasterData: "0x"
1470
+ })
1471
+ } : void 0,
1472
+ userOperation: {
1473
+ estimateFeesPerGas: createFeeEstimator(client)
1474
+ },
1475
+ ...config
1476
+ });
1477
+ }
1478
+ function createFeeEstimator(client) {
1479
+ if (!client.chain) return;
1480
+ if (client.chain.id === 31337) {
1481
+ return async () => ({ maxFeePerGas: 100000n, maxPriorityFeePerGas: 0n });
1482
+ }
1483
+ if ([690, 17069, 695569].includes(client.chain.id)) {
1484
+ return cachedFeesPerGas(client);
1485
+ }
1486
+ }
1487
+
1488
+ // src/onboarding/useSetupSession.ts
1489
+ import { isIdPlaceConnector as isIdPlaceConnector2 } from "@latticexyz/id.place/internal";
1490
+ import { storeEventsAbi } from "@latticexyz/store";
1491
+ function useSetupSession({ connector, userClient }) {
1388
1492
  const queryClient = useQueryClient4();
1389
1493
  const { chainId, worldAddress } = useEntryKitConfig();
1390
- const client = useClient9({ chainId });
1494
+ const client = useClient8({ chainId });
1391
1495
  const mutationKey = ["setupSession", client?.chain.id, userClient.account.address];
1392
1496
  return useMutation2({
1393
1497
  retry: 0,
@@ -1400,8 +1504,69 @@ function useSetupSession({ userClient }) {
1400
1504
  if (!client) throw new Error("Client not ready.");
1401
1505
  const paymaster = getPaymaster(client.chain);
1402
1506
  const sessionAddress = sessionClient.account.address;
1403
- console.log("setting up session");
1404
- if (userClient.account.type === "smart") {
1507
+ console.log("setting up session", userClient);
1508
+ if (isIdPlaceConnector2(connector)) {
1509
+ const calls = [];
1510
+ if (registerSpender && paymaster?.type === "quarry") {
1511
+ console.log("registering spender");
1512
+ calls.push(
1513
+ defineCall({
1514
+ to: paymaster.address,
1515
+ abi: paymasterAbi,
1516
+ functionName: "registerSpender",
1517
+ args: [sessionAddress]
1518
+ })
1519
+ );
1520
+ }
1521
+ if (registerDelegation) {
1522
+ console.log("registering delegation");
1523
+ calls.push(
1524
+ defineCall({
1525
+ to: worldAddress,
1526
+ abi: worldAbi,
1527
+ functionName: "registerDelegation",
1528
+ args: [sessionAddress, unlimitedDelegationControlId, "0x"]
1529
+ })
1530
+ );
1531
+ }
1532
+ if (!calls.length) return;
1533
+ console.log("setting up account with", calls, userClient.account.address, sessionAddress);
1534
+ const { id } = await getAction5(
1535
+ userClient,
1536
+ sendCalls,
1537
+ "sendCalls"
1538
+ )({
1539
+ account: userClient.account,
1540
+ calls
1541
+ });
1542
+ console.log("got send calls ID", id);
1543
+ const bundlerClient = createBundlerClient({
1544
+ transport: getBundlerTransport(client.chain),
1545
+ client
1546
+ });
1547
+ console.log("waiting for receipt");
1548
+ const receipt = await getAction5(
1549
+ bundlerClient,
1550
+ waitForUserOperationReceipt,
1551
+ "waitForUserOperationReceipt"
1552
+ )({ hash: id });
1553
+ console.log("got result", receipt);
1554
+ console.log(
1555
+ "parsed logs",
1556
+ worldAddress,
1557
+ parseEventLogs2({
1558
+ logs: receipt.logs,
1559
+ abi: [
1560
+ ...entryPoint07Abi2,
1561
+ // TODO: export account abi from id package
1562
+ // ...abi,
1563
+ ...worldAbi,
1564
+ ...storeEventsAbi,
1565
+ ...calls.flatMap((call) => call.abi)
1566
+ ]
1567
+ })
1568
+ );
1569
+ } else if (userClient.account.type === "smart") {
1405
1570
  const calls = [];
1406
1571
  if (registerSpender && paymaster?.type === "quarry") {
1407
1572
  console.log("registering spender");
@@ -1427,9 +1592,9 @@ function useSetupSession({ userClient }) {
1427
1592
  }
1428
1593
  if (!calls.length) return;
1429
1594
  console.log("setting up account with", calls, userClient);
1430
- const hash = await getAction4(userClient, sendUserOperation2, "sendUserOperation")({ calls });
1595
+ const hash = await getAction5(userClient, sendUserOperation2, "sendUserOperation")({ calls });
1431
1596
  console.log("got user op hash", hash);
1432
- const receipt = await getAction4(
1597
+ const receipt = await getAction5(
1433
1598
  userClient,
1434
1599
  waitForUserOperationReceipt,
1435
1600
  "waitForUserOperationReceipt"
@@ -1477,7 +1642,7 @@ function useSetupSession({ userClient }) {
1477
1642
  if (!txs.length) return;
1478
1643
  console.log("waiting for", txs.length, "receipts");
1479
1644
  for (const hash of txs) {
1480
- const receipt = await getAction4(client, waitForTransactionReceipt2, "waitForTransactionReceipt")({ hash });
1645
+ const receipt = await getAction5(client, waitForTransactionReceipt2, "waitForTransactionReceipt")({ hash });
1481
1646
  console.log("got tx receipt", receipt);
1482
1647
  if (receipt.status === "reverted") {
1483
1648
  console.error("tx reverted?", receipt);
@@ -1494,7 +1659,7 @@ function useSetupSession({ userClient }) {
1494
1659
  }
1495
1660
 
1496
1661
  // src/useSessionClient.ts
1497
- import { useClient as useClient10 } from "wagmi";
1662
+ import { useClient as useClient9 } from "wagmi";
1498
1663
  import {
1499
1664
  queryOptions as queryOptions8,
1500
1665
  useQuery as useQuery10,
@@ -1504,43 +1669,6 @@ import {
1504
1669
  // src/getSessionClient.ts
1505
1670
  import { smartAccountActions } from "permissionless";
1506
1671
  import { callFrom, sendUserOperationFrom } from "@latticexyz/world/internal";
1507
-
1508
- // src/createBundlerClient.ts
1509
- import {
1510
- createBundlerClient as viem_createBundlerClient
1511
- } from "viem/account-abstraction";
1512
- import { getAction as getAction5 } from "viem/utils";
1513
- import { estimateFeesPerGas } from "viem/actions";
1514
- function createBundlerClient(config) {
1515
- const client = config.client;
1516
- if (!client) throw new Error("No `client` provided to `createBundlerClient`.");
1517
- const chain = config.chain ?? client.chain;
1518
- const paymaster = chain ? getPaymaster(chain) : void 0;
1519
- return viem_createBundlerClient({
1520
- ...defaultClientConfig,
1521
- paymaster: paymaster ? {
1522
- getPaymasterData: async () => ({
1523
- paymaster: paymaster.address,
1524
- paymasterData: "0x"
1525
- })
1526
- } : void 0,
1527
- userOperation: {
1528
- estimateFeesPerGas: createFeeEstimator(client)
1529
- },
1530
- ...config
1531
- });
1532
- }
1533
- function createFeeEstimator(client) {
1534
- if (!client.chain) return;
1535
- if (client.chain.id === 31337) {
1536
- return async () => ({ maxFeePerGas: 100000n, maxPriorityFeePerGas: 0n });
1537
- }
1538
- if ([690, 17069, 695569].includes(client.chain.id)) {
1539
- return () => getAction5(client, estimateFeesPerGas, "estimateFeesPerGas")({ chain: client.chain });
1540
- }
1541
- }
1542
-
1543
- // src/getSessionClient.ts
1544
1672
  async function getSessionClient({
1545
1673
  userAddress,
1546
1674
  sessionAccount,
@@ -1604,7 +1732,7 @@ function getSessionClientQueryOptions({
1604
1732
  function useSessionClient(userAddress) {
1605
1733
  const queryClient = useQueryClient5();
1606
1734
  const { chainId, worldAddress } = useEntryKitConfig();
1607
- const client = useClient10({ chainId });
1735
+ const client = useClient9({ chainId });
1608
1736
  return useQuery10(
1609
1737
  getSessionClientQueryOptions({
1610
1738
  queryClient,
@@ -1617,20 +1745,15 @@ function useSessionClient(userAddress) {
1617
1745
 
1618
1746
  // src/onboarding/Session.tsx
1619
1747
  import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
1620
- function Session({ isActive, isExpanded, userClient, registerSpender, registerDelegation }) {
1748
+ function Session({ isActive, isExpanded, connector, userClient, registerSpender, registerDelegation }) {
1621
1749
  const sessionClient = useShowQueryError(useSessionClient(userClient.account.address));
1622
- const setup = useShowMutationError(useSetupSession({ userClient }));
1750
+ const setup = useShowMutationError(useSetupSession({ userClient, connector }));
1623
1751
  const hasSession = !registerDelegation && !registerDelegation;
1624
1752
  const { data: prerequisites } = usePrerequisites(userClient.account.address);
1625
1753
  const { hasAllowance, hasGasBalance, hasQuarryGasBalance } = prerequisites ?? {};
1626
1754
  useEffect7(() => {
1627
1755
  const timer = setTimeout(() => {
1628
1756
  if (isActive && setup.status === "idle" && sessionClient.data && !hasSession && (hasAllowance || hasGasBalance || hasQuarryGasBalance)) {
1629
- setup.mutate({
1630
- sessionClient: sessionClient.data,
1631
- registerSpender,
1632
- registerDelegation
1633
- });
1634
1757
  }
1635
1758
  });
1636
1759
  return () => clearTimeout(timer);
@@ -1673,7 +1796,7 @@ function Session({ isActive, isExpanded, userClient, registerSpender, registerDe
1673
1796
 
1674
1797
  // src/onboarding/GasBalance.tsx
1675
1798
  import { useEffect as useEffect9, useState as useState2 } from "react";
1676
- import { parseEther as parseEther4 } from "viem";
1799
+ import { parseEther as parseEther3 } from "viem";
1677
1800
  import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
1678
1801
  import { useBalance as useBalance2, useWatchBlockNumber } from "wagmi";
1679
1802
 
@@ -1960,11 +2083,11 @@ var relayChains_default = {
1960
2083
  // src/onboarding/useSetBalance.ts
1961
2084
  import { useQueryClient as useQueryClient6, useMutation as useMutation3 } from "@tanstack/react-query";
1962
2085
  import { setBalance as setBalance2 } from "viem/actions";
1963
- import { useClient as useClient11 } from "wagmi";
2086
+ import { useClient as useClient10 } from "wagmi";
1964
2087
  function useSetBalance() {
1965
2088
  const queryClient = useQueryClient6();
1966
2089
  const { chainId } = useEntryKitConfig();
1967
- const client = useClient11({ chainId });
2090
+ const client = useClient10({ chainId });
1968
2091
  return useMutation3({
1969
2092
  retry: 0,
1970
2093
  mutationKey: ["setBalance", chainId],
@@ -2041,7 +2164,7 @@ function CheckIcon(props) {
2041
2164
  }
2042
2165
 
2043
2166
  // src/onboarding/GasBalance.tsx
2044
- import { Fragment, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
2167
+ import { Fragment as Fragment2, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
2045
2168
  function GasBalance({ isActive, isExpanded, sessionAddress }) {
2046
2169
  const queryClient = useQueryClient7();
2047
2170
  const { chain } = useEntryKitConfig();
@@ -2077,7 +2200,7 @@ function GasBalance({ isActive, isExpanded, sessionAddress }) {
2077
2200
  pending: balance.status === "pending" || setBalance3.status === "pending",
2078
2201
  onClick: () => setBalance3.mutate({
2079
2202
  address: sessionAddress,
2080
- value: parseEther4("0.01") + (balance.data?.value ?? 0n)
2203
+ value: parseEther3("0.01") + (balance.data?.value ?? 0n)
2081
2204
  }),
2082
2205
  children: "Top up"
2083
2206
  }
@@ -2103,7 +2226,7 @@ function GasBalance({ isActive, isExpanded, sessionAddress }) {
2103
2226
  )
2104
2227
  ) : null
2105
2228
  ] }),
2106
- isExpanded ? /* @__PURE__ */ jsxs14(Fragment, { children: [
2229
+ isExpanded ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
2107
2230
  /* @__PURE__ */ jsx19("p", { className: "text-sm", children: "Your session's gas balance is used to pay for onchain computation." }),
2108
2231
  /* @__PURE__ */ jsxs14("p", { className: "text-sm", children: [
2109
2232
  "Send funds to",
@@ -2321,7 +2444,7 @@ function useChainBalances({ chains }) {
2321
2444
  }
2322
2445
 
2323
2446
  // src/onboarding/deposit/ChainSelect.tsx
2324
- import { Fragment as Fragment2, jsx as jsx25, jsxs as jsxs15 } from "react/jsx-runtime";
2447
+ import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs15 } from "react/jsx-runtime";
2325
2448
  function ChainSelect({ value, onChange }) {
2326
2449
  const theme = useTheme();
2327
2450
  const { frame } = useFrame();
@@ -2373,7 +2496,7 @@ function ChainSelect({ value, onChange }) {
2373
2496
  className: "w-8"
2374
2497
  }
2375
2498
  ) }),
2376
- /* @__PURE__ */ jsx25(Select.Icon, { asChild: true, children: /* @__PURE__ */ jsxs15(Fragment2, { children: [
2499
+ /* @__PURE__ */ jsx25(Select.Icon, { asChild: true, children: /* @__PURE__ */ jsxs15(Fragment3, { children: [
2377
2500
  /* @__PURE__ */ jsx25(ChevronDownIcon, { className: "text-sm -mr-1 group-aria-expanded:hidden" }),
2378
2501
  /* @__PURE__ */ jsx25(ChevronUpIcon, { className: "text-sm -mr-1 hidden group-aria-expanded:inline" })
2379
2502
  ] }) })
@@ -2418,7 +2541,7 @@ function ChainSelect({ value, onChange }) {
2418
2541
  }
2419
2542
 
2420
2543
  // src/onboarding/deposit/AmountInput.tsx
2421
- import { formatEther as formatEther3, parseEther as parseEther5 } from "viem";
2544
+ import { formatEther as formatEther3, parseEther as parseEther4 } from "viem";
2422
2545
  import { twMerge as twMerge13 } from "tailwind-merge";
2423
2546
  import { forwardRef as forwardRef3 } from "react";
2424
2547
  import { jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
@@ -2445,7 +2568,7 @@ var AmountInput = forwardRef3(function AmountInput2({ initialAmount, onChange },
2445
2568
  return input.setCustomValidity("Invalid amount.");
2446
2569
  }
2447
2570
  input.setCustomValidity("");
2448
- onChange(parseEther5(value));
2571
+ onChange(parseEther4(value));
2449
2572
  }
2450
2573
  }
2451
2574
  ),
@@ -2456,7 +2579,7 @@ var AmountInput = forwardRef3(function AmountInput2({ initialAmount, onChange },
2456
2579
  // src/onboarding/deposit/SubmitButton.tsx
2457
2580
  import { useAccount as useAccount2, useBalance as useBalance3, useSwitchChain as useSwitchChain2 } from "wagmi";
2458
2581
  import { twMerge as twMerge14 } from "tailwind-merge";
2459
- import { parseEther as parseEther6 } from "viem";
2582
+ import { parseEther as parseEther5 } from "viem";
2460
2583
  import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
2461
2584
  var MAX_DEPOSIT_AMOUNT = "0.1";
2462
2585
  function SubmitButton({ amount, chainId, className, ...buttonProps }) {
@@ -2477,7 +2600,7 @@ function SubmitButton({ amount, chainId, className, ...buttonProps }) {
2477
2600
  }
2478
2601
  );
2479
2602
  } else if (amount) {
2480
- if (amount > parseEther6(MAX_DEPOSIT_AMOUNT)) {
2603
+ if (amount > parseEther5(MAX_DEPOSIT_AMOUNT)) {
2481
2604
  return /* @__PURE__ */ jsxs17(Button, { type: "button", className: twMerge14("w-full", className), disabled: true, children: [
2482
2605
  "Max amount is ",
2483
2606
  MAX_DEPOSIT_AMOUNT,
@@ -2514,7 +2637,7 @@ function formatGas(wei) {
2514
2637
  }
2515
2638
 
2516
2639
  // src/onboarding/deposit/DepositForm.tsx
2517
- import { Fragment as Fragment3, jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
2640
+ import { Fragment as Fragment4, jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
2518
2641
  function DepositForm({
2519
2642
  sourceChain,
2520
2643
  setSourceChainId,
@@ -2579,7 +2702,7 @@ function DepositForm({
2579
2702
  /* @__PURE__ */ jsx29("dt", { children: "Gas balance after deposit" }),
2580
2703
  /* @__PURE__ */ jsx29("dd", { children: /* @__PURE__ */ jsx29(Balance, { wei: (quarryBalance.data ?? 0n) + (amount ?? 0n) }) }),
2581
2704
  /* @__PURE__ */ jsx29("dt", { children: "Estimated fee" }),
2582
- /* @__PURE__ */ jsx29("dd", { children: estimatedFee.fee ? /* @__PURE__ */ jsxs18(Fragment3, { children: [
2705
+ /* @__PURE__ */ jsx29("dd", { children: estimatedFee.fee ? /* @__PURE__ */ jsxs18(Fragment4, { children: [
2583
2706
  formatGas(estimatedFee.fee),
2584
2707
  " gwei"
2585
2708
  ] }) : estimatedFee.error ? /* @__PURE__ */ jsx29("span", { title: String(estimatedFee.error), children: /* @__PURE__ */ jsx29(WarningIcon, { className: "inline-block text-amber-500" }) }) : estimatedFee.isLoading ? /* @__PURE__ */ jsx29(PendingIcon, { className: "inline-block text-xs" }) : null }),
@@ -2939,7 +3062,7 @@ function DepositStatus({ status, progress, children, onDismiss }) {
2939
3062
 
2940
3063
  // src/onboarding/deposit/TransferDepositStatus.tsx
2941
3064
  import { useChains as useChains2 } from "wagmi";
2942
- import { Fragment as Fragment4, jsx as jsx34, jsxs as jsxs20 } from "react/jsx-runtime";
3065
+ import { Fragment as Fragment5, jsx as jsx34, jsxs as jsxs20 } from "react/jsx-runtime";
2943
3066
  function TransferDepositStatus({
2944
3067
  amount,
2945
3068
  chainL1Id,
@@ -2967,7 +3090,7 @@ function TransferDepositStatus({
2967
3090
  children: (() => {
2968
3091
  const blockExplorer = chain.blockExplorers?.default.url;
2969
3092
  if (receipt.status === "pending") {
2970
- return /* @__PURE__ */ jsxs20(Fragment4, { children: [
3093
+ return /* @__PURE__ */ jsxs20(Fragment5, { children: [
2971
3094
  "Confirming deposit on",
2972
3095
  " ",
2973
3096
  /* @__PURE__ */ jsx34(
@@ -2983,7 +3106,7 @@ function TransferDepositStatus({
2983
3106
  ] });
2984
3107
  }
2985
3108
  if (receipt.status === "error") {
2986
- return /* @__PURE__ */ jsxs20(Fragment4, { children: [
3109
+ return /* @__PURE__ */ jsxs20(Fragment5, { children: [
2987
3110
  "Could not find deposit on",
2988
3111
  " ",
2989
3112
  /* @__PURE__ */ jsx34(
@@ -2998,7 +3121,7 @@ function TransferDepositStatus({
2998
3121
  "."
2999
3122
  ] });
3000
3123
  }
3001
- return /* @__PURE__ */ jsxs20(Fragment4, { children: [
3124
+ return /* @__PURE__ */ jsxs20(Fragment5, { children: [
3002
3125
  "Successfully",
3003
3126
  " ",
3004
3127
  /* @__PURE__ */ jsx34(
@@ -3021,7 +3144,7 @@ function TransferDepositStatus({
3021
3144
  // src/onboarding/deposit/RelayDepositStatus.tsx
3022
3145
  import { useQuery as useQuery16 } from "@tanstack/react-query";
3023
3146
  import { useChains as useChains3 } from "wagmi";
3024
- import { Fragment as Fragment5, jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
3147
+ import { Fragment as Fragment6, jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
3025
3148
  function RelayDepositStatus({
3026
3149
  amount,
3027
3150
  chainL1Id,
@@ -3049,20 +3172,20 @@ function RelayDepositStatus({
3049
3172
  onDismiss,
3050
3173
  children: (() => {
3051
3174
  if (deposit.status === "pending") {
3052
- return /* @__PURE__ */ jsxs21(Fragment5, { children: [
3175
+ return /* @__PURE__ */ jsxs21(Fragment6, { children: [
3053
3176
  "Relay bridge deposit pending on ",
3054
3177
  chainL1.name,
3055
3178
  "\u2026"
3056
3179
  ] });
3057
3180
  }
3058
3181
  if (deposit.status === "error") {
3059
- return /* @__PURE__ */ jsxs21(Fragment5, { children: [
3182
+ return /* @__PURE__ */ jsxs21(Fragment6, { children: [
3060
3183
  "Relay bridge deposit to ",
3061
3184
  chainL2.name,
3062
3185
  " failed."
3063
3186
  ] });
3064
3187
  }
3065
- return /* @__PURE__ */ jsxs21(Fragment5, { children: [
3188
+ return /* @__PURE__ */ jsxs21(Fragment6, { children: [
3066
3189
  "Successfully bridged ",
3067
3190
  /* @__PURE__ */ jsx35(Balance, { wei: amount }),
3068
3191
  " to ",
@@ -3075,12 +3198,12 @@ function RelayDepositStatus({
3075
3198
  }
3076
3199
 
3077
3200
  // src/onboarding/deposit/Deposits.tsx
3078
- import { useAccount as useAccount6, useClient as useClient12 } from "wagmi";
3201
+ import { useAccount as useAccount6, useClient as useClient11 } from "wagmi";
3079
3202
  import { jsx as jsx36 } from "react/jsx-runtime";
3080
3203
  function Deposits() {
3081
3204
  const queryClient = useQueryClient8();
3082
3205
  const { chainId } = useEntryKitConfig();
3083
- const client = useClient12({ chainId });
3206
+ const client = useClient11({ chainId });
3084
3207
  const { address: userAddress } = useAccount6();
3085
3208
  const { deposits, removeDeposit } = useDeposits();
3086
3209
  const { data: isComplete } = useQuery17({
@@ -3157,7 +3280,7 @@ function ArrowLeftIcon(props) {
3157
3280
  // src/onboarding/quarry/WithdrawGasBalanceButton.tsx
3158
3281
  import { getAction as getAction6 } from "viem/utils";
3159
3282
  import { waitForTransactionReceipt as waitForTransactionReceipt3 } from "viem/actions";
3160
- import { useAccount as useAccount7, useClient as useClient13, useSwitchChain as useSwitchChain3, useWriteContract as useWriteContract2 } from "wagmi";
3283
+ import { useAccount as useAccount7, useClient as useClient12, useSwitchChain as useSwitchChain3, useWriteContract as useWriteContract2 } from "wagmi";
3161
3284
  import { twMerge as twMerge17 } from "tailwind-merge";
3162
3285
  import { useMutation as useMutation6 } from "@tanstack/react-query";
3163
3286
  import { useQueryClient as useQueryClient9 } from "@tanstack/react-query";
@@ -3168,7 +3291,7 @@ function WithdrawGasBalanceButton({ userAddress }) {
3168
3291
  const { chain, chainId } = useEntryKitConfig();
3169
3292
  const { chainId: userChainId } = useAccount7();
3170
3293
  const queryClient = useQueryClient9();
3171
- const client = useClient13({ chainId });
3294
+ const client = useClient12({ chainId });
3172
3295
  const paymaster = getPaymaster(chain);
3173
3296
  const balance = useShowQueryError(useBalance(userAddress));
3174
3297
  const shouldSwitchChain = chainId != null && chainId !== userChainId;
@@ -3288,7 +3411,7 @@ function GasBalance2({ isActive, isExpanded, isFocused, setFocused, userAddress
3288
3411
 
3289
3412
  // src/onboarding/ConnectedSteps.tsx
3290
3413
  import { jsx as jsx41 } from "react/jsx-runtime";
3291
- function ConnectedSteps({ userClient, initialUserAddress }) {
3414
+ function ConnectedSteps({ connector, userClient, initialUserAddress }) {
3292
3415
  const { chain } = useEntryKitConfig();
3293
3416
  const paymaster = getPaymaster(chain);
3294
3417
  const [focusedId, setFocusedId] = useState5(null);
@@ -3340,7 +3463,7 @@ function ConnectedSteps({ userClient, initialUserAddress }) {
3340
3463
  });
3341
3464
  }
3342
3465
  } else if (paymaster.type === "quarry") {
3343
- if (paymaster.isGasPass) {
3466
+ if (paymaster.canSponsor) {
3344
3467
  steps2.push({
3345
3468
  id: "allowance",
3346
3469
  isComplete: !!hasAllowance,
@@ -3357,7 +3480,16 @@ function ConnectedSteps({ userClient, initialUserAddress }) {
3357
3480
  steps2.push({
3358
3481
  id: "session",
3359
3482
  isComplete: !!isSpender && !!hasDelegation,
3360
- content: (props) => /* @__PURE__ */ jsx41(Session, { ...props, userClient, registerSpender: !isSpender, registerDelegation: !hasDelegation })
3483
+ content: (props) => /* @__PURE__ */ jsx41(
3484
+ Session,
3485
+ {
3486
+ ...props,
3487
+ userClient,
3488
+ connector,
3489
+ registerSpender: !isSpender,
3490
+ registerDelegation: !hasDelegation
3491
+ }
3492
+ )
3361
3493
  });
3362
3494
  return steps2;
3363
3495
  }, [
@@ -3369,7 +3501,8 @@ function ConnectedSteps({ userClient, initialUserAddress }) {
3369
3501
  paymaster,
3370
3502
  sessionAddress,
3371
3503
  userAddress,
3372
- userClient
3504
+ userClient,
3505
+ connector
3373
3506
  ]);
3374
3507
  const [selectedStepId] = useState5(null);
3375
3508
  const nextStep = steps.find((step) => step.content != null && !step.isComplete);
@@ -3412,13 +3545,20 @@ import { useRef as useRef6 } from "react";
3412
3545
  import { jsx as jsx42 } from "react/jsx-runtime";
3413
3546
  function AccountModalContent() {
3414
3547
  const { chainId } = useEntryKitConfig();
3415
- const userClient = useConnectorClient({ chainId });
3416
- const { address: userAddress } = useAccount8();
3548
+ const { address: userAddress, connector } = useAccount8();
3549
+ const userClient = useConnectorClient({ chainId, connector });
3417
3550
  const initialUserAddress = useRef6(userAddress);
3418
3551
  if (userClient.status !== "success") {
3419
3552
  return /* @__PURE__ */ jsx42(ConnectWallet, {});
3420
3553
  }
3421
- return /* @__PURE__ */ jsx42(ConnectedSteps, { userClient: userClient.data, initialUserAddress: initialUserAddress.current });
3554
+ return /* @__PURE__ */ jsx42(
3555
+ ConnectedSteps,
3556
+ {
3557
+ connector,
3558
+ userClient: userClient.data,
3559
+ initialUserAddress: initialUserAddress.current
3560
+ }
3561
+ );
3422
3562
  }
3423
3563
 
3424
3564
  // src/AccountModal.tsx
@@ -3429,7 +3569,7 @@ import { ErrorBoundary } from "react-error-boundary";
3429
3569
  import { wait } from "@latticexyz/common/utils";
3430
3570
  import { useEffect as useEffect16 } from "react";
3431
3571
  import { twMerge as twMerge19 } from "tailwind-merge";
3432
- import { Fragment as Fragment6, jsx as jsx43, jsxs as jsxs25 } from "react/jsx-runtime";
3572
+ import { Fragment as Fragment7, jsx as jsx43, jsxs as jsxs25 } from "react/jsx-runtime";
3433
3573
  function ErrorOverlay({ error: error2, retry, dismiss }) {
3434
3574
  useEffect16(() => {
3435
3575
  if (error2) {
@@ -3455,7 +3595,7 @@ function ErrorOverlay({ error: error2, retry, dismiss }) {
3455
3595
  "transition duration-300",
3456
3596
  error2 ? "translate-y-0 opacity-100 pointer-events-auto" : "-translate-y-4 opacity-0"
3457
3597
  ),
3458
- children: error2 ? /* @__PURE__ */ jsx43(Fragment6, { children: /* @__PURE__ */ jsxs25("div", { className: "w-full max-h-full bg-blue-700 text-white/80 overflow-auto", children: [
3598
+ children: error2 ? /* @__PURE__ */ jsx43(Fragment7, { children: /* @__PURE__ */ jsxs25("div", { className: "w-full max-h-full bg-blue-700 text-white/80 overflow-auto", children: [
3459
3599
  /* @__PURE__ */ jsxs25("div", { className: "space-y-6 px-8 pt-8", children: [
3460
3600
  /* @__PURE__ */ jsx43("div", { className: "text-white text-lg font-bold", children: "Oops! It broke :(" }),
3461
3601
  /* @__PURE__ */ jsx43("div", { className: "font-mono text-xs whitespace-pre-wrap", children: error2.message.trim() }),
@@ -3584,11 +3724,11 @@ import { twMerge as twMerge22 } from "tailwind-merge";
3584
3724
 
3585
3725
  // src/AccountName.tsx
3586
3726
  import { twMerge as twMerge21 } from "tailwind-merge";
3587
- import { Fragment as Fragment7, jsx as jsx48, jsxs as jsxs28 } from "react/jsx-runtime";
3727
+ import { Fragment as Fragment8, jsx as jsx48, jsxs as jsxs28 } from "react/jsx-runtime";
3588
3728
  function AccountName({ address }) {
3589
3729
  const { data: ens } = useENS(address);
3590
3730
  const avatar = usePreloadImage(ens?.avatar);
3591
- return /* @__PURE__ */ jsxs28(Fragment7, { children: [
3731
+ return /* @__PURE__ */ jsxs28(Fragment8, { children: [
3592
3732
  /* @__PURE__ */ jsxs28("span", { className: "flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center", children: [
3593
3733
  /* @__PURE__ */ jsx48(
3594
3734
  "img",
@@ -3632,7 +3772,7 @@ var secondaryClassNames = twMerge22(
3632
3772
  var secondaryInteractiveClassNames = twMerge22(
3633
3773
  "cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700"
3634
3774
  );
3635
- function AccountButton() {
3775
+ function AccountButton2() {
3636
3776
  const { openAccountModal, accountModalOpen } = useAccountModal();
3637
3777
  const { status, address: userAddress } = useAccount9();
3638
3778
  const initialUserAddress = useRef7(userAddress);
@@ -3721,6 +3861,8 @@ function useSessionClientReady() {
3721
3861
  // src/createWagmiConfig.ts
3722
3862
  import { createConfig } from "wagmi";
3723
3863
  import { getDefaultConfig } from "connectkit";
3864
+
3865
+ // src/getDefaultConnectors.ts
3724
3866
  import { injected, coinbaseWallet, safe } from "wagmi/connectors";
3725
3867
 
3726
3868
  // src/connectors/walletConnect.ts
@@ -3729,7 +3871,7 @@ import {
3729
3871
  SwitchChainError,
3730
3872
  UserRejectedRequestError,
3731
3873
  getAddress,
3732
- numberToHex as numberToHex3
3874
+ numberToHex as numberToHex2
3733
3875
  } from "viem";
3734
3876
  walletConnect.type = "walletConnect";
3735
3877
  function walletConnect(parameters) {
@@ -3926,7 +4068,7 @@ function walletConnect(parameters) {
3926
4068
  }),
3927
4069
  provider.request({
3928
4070
  method: "wallet_switchEthereumChain",
3929
- params: [{ chainId: numberToHex3(chainId) }]
4071
+ params: [{ chainId: numberToHex2(chainId) }]
3930
4072
  })
3931
4073
  ]);
3932
4074
  const requestedChains = await this.getRequestedChainsIds();
@@ -3945,7 +4087,7 @@ function walletConnect(parameters) {
3945
4087
  else rpcUrls = [...chain.rpcUrls.default.http];
3946
4088
  const addEthereumChain = {
3947
4089
  blockExplorerUrls,
3948
- chainId: numberToHex3(chainId),
4090
+ chainId: numberToHex2(chainId),
3949
4091
  chainName: addEthereumChainParameter?.chainName ?? chain.name,
3950
4092
  iconUrls: addEthereumChainParameter?.iconUrls,
3951
4093
  nativeCurrency: addEthereumChainParameter?.nativeCurrency ?? chain.nativeCurrency,
@@ -4056,8 +4198,8 @@ function extractRpcUrls(parameters) {
4056
4198
  return transports.map(({ value }) => value?.url || fallbackUrl);
4057
4199
  }
4058
4200
 
4059
- // src/createWagmiConfig.ts
4060
- function createWagmiConfig(config) {
4201
+ // src/getDefaultConnectors.ts
4202
+ function getDefaultConnectors(config) {
4061
4203
  const connectors = [];
4062
4204
  const shouldUseSafeConnector = !(typeof window === "undefined") && window?.parent !== window;
4063
4205
  if (shouldUseSafeConnector) {
@@ -4082,6 +4224,12 @@ function createWagmiConfig(config) {
4082
4224
  })
4083
4225
  );
4084
4226
  }
4227
+ return connectors;
4228
+ }
4229
+
4230
+ // src/createWagmiConfig.ts
4231
+ function createWagmiConfig(config) {
4232
+ const connectors = config.connectors ?? getDefaultConnectors(config);
4085
4233
  const configParams = getDefaultConfig({
4086
4234
  chains: config.chains,
4087
4235
  transports: config.transports,
@@ -4094,8 +4242,27 @@ function createWagmiConfig(config) {
4094
4242
  return createConfig(configParams);
4095
4243
  }
4096
4244
 
4245
+ // src/utils/withFeeCache.ts
4246
+ import { createClient as createClient3, http as http3 } from "viem";
4247
+ function withFeeCache(chain, options = { refreshInterval: 1e4 }) {
4248
+ if (chain.fees?.estimateFeesPerGas) {
4249
+ throw new Error("withFeeCache: estimateFeesPerGas already defined in chain config");
4250
+ }
4251
+ const client = createClient3({
4252
+ chain,
4253
+ transport: http3()
4254
+ });
4255
+ return {
4256
+ ...chain,
4257
+ fees: {
4258
+ ...chain.fees,
4259
+ estimateFeesPerGas: cachedFeesPerGas(client, options)
4260
+ }
4261
+ };
4262
+ }
4263
+
4097
4264
  // src/validateSigner.ts
4098
- import { readContract } from "viem/actions";
4265
+ import { readContract as readContract2 } from "viem/actions";
4099
4266
  async function internal_validateSigner({
4100
4267
  client,
4101
4268
  worldAddress,
@@ -4103,7 +4270,7 @@ async function internal_validateSigner({
4103
4270
  sessionAddress,
4104
4271
  signerAddress
4105
4272
  }) {
4106
- const ownerAddress = await readContract(client, {
4273
+ const ownerAddress = await readContract2(client, {
4107
4274
  address: sessionAddress,
4108
4275
  abi: simpleAccountAbi,
4109
4276
  functionName: "owner"
@@ -4138,15 +4305,20 @@ var simpleAccountAbi = [
4138
4305
  }
4139
4306
  ];
4140
4307
  export {
4141
- AccountButton,
4308
+ AccountButton2 as AccountButton,
4142
4309
  EntryKitProvider,
4310
+ createBundlerClient,
4143
4311
  createWagmiConfig,
4312
+ defineCall,
4144
4313
  defineConfig,
4314
+ getBundlerTransport,
4315
+ getDefaultConnectors,
4145
4316
  getFundsQueryOptions,
4146
4317
  internal_validateSigner,
4147
4318
  useAccountModal,
4148
4319
  useEntryKitConfig,
4149
4320
  useFunds,
4150
- useSessionClientReady as useSessionClient
4321
+ useSessionClientReady as useSessionClient,
4322
+ withFeeCache
4151
4323
  };
4152
4324
  //# sourceMappingURL=internal.js.map