@latticexyz/entrykit 2.2.23-2ade90f493b15b4dbe56c08e97e4f8e97b716c3f → 2.2.23-65e4592911440a38680d2d5d525deb6242614125
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 {
|
|
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 [
|
|
176
|
-
return receipts.get(
|
|
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 {
|
|
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
|
|
531
|
-
const
|
|
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
|
-
|
|
582
|
-
"
|
|
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
|
-
|
|
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
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
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
|
-
|
|
614
|
-
|
|
615
|
-
|
|
691
|
+
sponsor: "address",
|
|
692
|
+
allowance: "uint256",
|
|
693
|
+
next: "address",
|
|
694
|
+
previous: "address"
|
|
616
695
|
},
|
|
617
|
-
key: ["user", "
|
|
696
|
+
key: ["user", "sponsor"]
|
|
618
697
|
},
|
|
619
|
-
|
|
698
|
+
AllowanceList: {
|
|
620
699
|
schema: {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
validityPeriod: "uint256",
|
|
625
|
-
grantor: "address"
|
|
700
|
+
user: "address",
|
|
701
|
+
first: "address",
|
|
702
|
+
length: "uint256"
|
|
626
703
|
},
|
|
627
|
-
key: ["
|
|
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
|
-
|
|
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 {
|
|
835
|
-
import {
|
|
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
|
-
|
|
916
|
+
return await getAction2(
|
|
917
|
+
client,
|
|
918
|
+
readContract,
|
|
919
|
+
"readContract"
|
|
920
|
+
)({
|
|
842
921
|
address: paymaster.address,
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
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
|
|
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
|
|
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/
|
|
1204
|
+
// src/quarry/transports/quarrySponsor.ts
|
|
1144
1205
|
import { http as http2 } from "viem";
|
|
1145
|
-
function
|
|
1206
|
+
function quarrySponsor() {
|
|
1146
1207
|
return ({ chain }) => {
|
|
1147
|
-
if (!chain) throw new Error("No chain provided to
|
|
1148
|
-
const url = "
|
|
1149
|
-
if (!url) throw new Error(`No \`
|
|
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/
|
|
1155
|
-
async function
|
|
1156
|
-
const transport =
|
|
1157
|
-
debug2("
|
|
1158
|
-
await transport.request({
|
|
1159
|
-
method: "quarry_issuePass",
|
|
1160
|
-
params: ["0x01", userAddress]
|
|
1161
|
-
});
|
|
1162
|
-
debug2("Claiming gas allowance for", userAddress);
|
|
1215
|
+
// src/quarry/requestAllowance.ts
|
|
1216
|
+
async function requestAllowance({ chain, userAddress }) {
|
|
1217
|
+
const transport = quarrySponsor()({ chain });
|
|
1218
|
+
debug2("Requesting allowance for", userAddress);
|
|
1163
1219
|
await transport.request({
|
|
1164
|
-
method: "
|
|
1165
|
-
params: [
|
|
1220
|
+
method: "sponsor_requestAllowance",
|
|
1221
|
+
params: [userAddress]
|
|
1166
1222
|
});
|
|
1167
1223
|
}
|
|
1168
1224
|
|
|
1169
|
-
// src/onboarding/quarry/
|
|
1170
|
-
|
|
1171
|
-
function useClaimGasPass() {
|
|
1225
|
+
// src/onboarding/quarry/useRequestAllowance.ts
|
|
1226
|
+
function useRequestAllowance() {
|
|
1172
1227
|
const queryClient = useQueryClient3();
|
|
1173
1228
|
const { chain } = useEntryKitConfig();
|
|
1174
|
-
const
|
|
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
|
-
|
|
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
|
|
1308
|
+
const requestAllowance2 = useShowMutationError(useRequestAllowance());
|
|
1260
1309
|
useEffect6(() => {
|
|
1261
1310
|
const timer = setTimeout(() => {
|
|
1262
|
-
if (isActive &&
|
|
1263
|
-
|
|
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,
|
|
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" ||
|
|
1281
|
-
onClick: () =>
|
|
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, zeroAddress } from "viem";
|
|
1295
1344
|
import { useMutation as useMutation2, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
|
|
1296
|
-
import { getAction as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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,88 @@ 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 (
|
|
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
|
+
await (async () => {
|
|
1570
|
+
console.log("creating session account by sending empty user op");
|
|
1571
|
+
const hash = await getAction5(
|
|
1572
|
+
sessionClient,
|
|
1573
|
+
sendUserOperation2,
|
|
1574
|
+
"sendUserOperation"
|
|
1575
|
+
)({
|
|
1576
|
+
calls: [{ to: zeroAddress }]
|
|
1577
|
+
});
|
|
1578
|
+
const receipt2 = await getAction5(
|
|
1579
|
+
bundlerClient,
|
|
1580
|
+
waitForUserOperationReceipt,
|
|
1581
|
+
"waitForUserOperationReceipt"
|
|
1582
|
+
)({ hash });
|
|
1583
|
+
console.log("got user op receipt", receipt2);
|
|
1584
|
+
if (!receipt2.success) {
|
|
1585
|
+
console.error("not successful?", receipt2);
|
|
1586
|
+
}
|
|
1587
|
+
})();
|
|
1588
|
+
} else if (userClient.account.type === "smart") {
|
|
1405
1589
|
const calls = [];
|
|
1406
1590
|
if (registerSpender && paymaster?.type === "quarry") {
|
|
1407
1591
|
console.log("registering spender");
|
|
@@ -1427,9 +1611,9 @@ function useSetupSession({ userClient }) {
|
|
|
1427
1611
|
}
|
|
1428
1612
|
if (!calls.length) return;
|
|
1429
1613
|
console.log("setting up account with", calls, userClient);
|
|
1430
|
-
const hash = await
|
|
1614
|
+
const hash = await getAction5(userClient, sendUserOperation2, "sendUserOperation")({ calls });
|
|
1431
1615
|
console.log("got user op hash", hash);
|
|
1432
|
-
const receipt = await
|
|
1616
|
+
const receipt = await getAction5(
|
|
1433
1617
|
userClient,
|
|
1434
1618
|
waitForUserOperationReceipt,
|
|
1435
1619
|
"waitForUserOperationReceipt"
|
|
@@ -1477,7 +1661,7 @@ function useSetupSession({ userClient }) {
|
|
|
1477
1661
|
if (!txs.length) return;
|
|
1478
1662
|
console.log("waiting for", txs.length, "receipts");
|
|
1479
1663
|
for (const hash of txs) {
|
|
1480
|
-
const receipt = await
|
|
1664
|
+
const receipt = await getAction5(client, waitForTransactionReceipt2, "waitForTransactionReceipt")({ hash });
|
|
1481
1665
|
console.log("got tx receipt", receipt);
|
|
1482
1666
|
if (receipt.status === "reverted") {
|
|
1483
1667
|
console.error("tx reverted?", receipt);
|
|
@@ -1494,7 +1678,7 @@ function useSetupSession({ userClient }) {
|
|
|
1494
1678
|
}
|
|
1495
1679
|
|
|
1496
1680
|
// src/useSessionClient.ts
|
|
1497
|
-
import { useClient as
|
|
1681
|
+
import { useClient as useClient9 } from "wagmi";
|
|
1498
1682
|
import {
|
|
1499
1683
|
queryOptions as queryOptions8,
|
|
1500
1684
|
useQuery as useQuery10,
|
|
@@ -1504,43 +1688,6 @@ import {
|
|
|
1504
1688
|
// src/getSessionClient.ts
|
|
1505
1689
|
import { smartAccountActions } from "permissionless";
|
|
1506
1690
|
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
1691
|
async function getSessionClient({
|
|
1545
1692
|
userAddress,
|
|
1546
1693
|
sessionAccount,
|
|
@@ -1604,7 +1751,7 @@ function getSessionClientQueryOptions({
|
|
|
1604
1751
|
function useSessionClient(userAddress) {
|
|
1605
1752
|
const queryClient = useQueryClient5();
|
|
1606
1753
|
const { chainId, worldAddress } = useEntryKitConfig();
|
|
1607
|
-
const client =
|
|
1754
|
+
const client = useClient9({ chainId });
|
|
1608
1755
|
return useQuery10(
|
|
1609
1756
|
getSessionClientQueryOptions({
|
|
1610
1757
|
queryClient,
|
|
@@ -1617,20 +1764,15 @@ function useSessionClient(userAddress) {
|
|
|
1617
1764
|
|
|
1618
1765
|
// src/onboarding/Session.tsx
|
|
1619
1766
|
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1620
|
-
function Session({ isActive, isExpanded, userClient, registerSpender, registerDelegation }) {
|
|
1767
|
+
function Session({ isActive, isExpanded, connector, userClient, registerSpender, registerDelegation }) {
|
|
1621
1768
|
const sessionClient = useShowQueryError(useSessionClient(userClient.account.address));
|
|
1622
|
-
const setup = useShowMutationError(useSetupSession({ userClient }));
|
|
1769
|
+
const setup = useShowMutationError(useSetupSession({ userClient, connector }));
|
|
1623
1770
|
const hasSession = !registerDelegation && !registerDelegation;
|
|
1624
1771
|
const { data: prerequisites } = usePrerequisites(userClient.account.address);
|
|
1625
1772
|
const { hasAllowance, hasGasBalance, hasQuarryGasBalance } = prerequisites ?? {};
|
|
1626
1773
|
useEffect7(() => {
|
|
1627
1774
|
const timer = setTimeout(() => {
|
|
1628
1775
|
if (isActive && setup.status === "idle" && sessionClient.data && !hasSession && (hasAllowance || hasGasBalance || hasQuarryGasBalance)) {
|
|
1629
|
-
setup.mutate({
|
|
1630
|
-
sessionClient: sessionClient.data,
|
|
1631
|
-
registerSpender,
|
|
1632
|
-
registerDelegation
|
|
1633
|
-
});
|
|
1634
1776
|
}
|
|
1635
1777
|
});
|
|
1636
1778
|
return () => clearTimeout(timer);
|
|
@@ -1673,7 +1815,7 @@ function Session({ isActive, isExpanded, userClient, registerSpender, registerDe
|
|
|
1673
1815
|
|
|
1674
1816
|
// src/onboarding/GasBalance.tsx
|
|
1675
1817
|
import { useEffect as useEffect9, useState as useState2 } from "react";
|
|
1676
|
-
import { parseEther as
|
|
1818
|
+
import { parseEther as parseEther3 } from "viem";
|
|
1677
1819
|
import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
|
|
1678
1820
|
import { useBalance as useBalance2, useWatchBlockNumber } from "wagmi";
|
|
1679
1821
|
|
|
@@ -1960,11 +2102,11 @@ var relayChains_default = {
|
|
|
1960
2102
|
// src/onboarding/useSetBalance.ts
|
|
1961
2103
|
import { useQueryClient as useQueryClient6, useMutation as useMutation3 } from "@tanstack/react-query";
|
|
1962
2104
|
import { setBalance as setBalance2 } from "viem/actions";
|
|
1963
|
-
import { useClient as
|
|
2105
|
+
import { useClient as useClient10 } from "wagmi";
|
|
1964
2106
|
function useSetBalance() {
|
|
1965
2107
|
const queryClient = useQueryClient6();
|
|
1966
2108
|
const { chainId } = useEntryKitConfig();
|
|
1967
|
-
const client =
|
|
2109
|
+
const client = useClient10({ chainId });
|
|
1968
2110
|
return useMutation3({
|
|
1969
2111
|
retry: 0,
|
|
1970
2112
|
mutationKey: ["setBalance", chainId],
|
|
@@ -2041,7 +2183,7 @@ function CheckIcon(props) {
|
|
|
2041
2183
|
}
|
|
2042
2184
|
|
|
2043
2185
|
// src/onboarding/GasBalance.tsx
|
|
2044
|
-
import { Fragment, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2186
|
+
import { Fragment as Fragment2, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2045
2187
|
function GasBalance({ isActive, isExpanded, sessionAddress }) {
|
|
2046
2188
|
const queryClient = useQueryClient7();
|
|
2047
2189
|
const { chain } = useEntryKitConfig();
|
|
@@ -2077,7 +2219,7 @@ function GasBalance({ isActive, isExpanded, sessionAddress }) {
|
|
|
2077
2219
|
pending: balance.status === "pending" || setBalance3.status === "pending",
|
|
2078
2220
|
onClick: () => setBalance3.mutate({
|
|
2079
2221
|
address: sessionAddress,
|
|
2080
|
-
value:
|
|
2222
|
+
value: parseEther3("0.01") + (balance.data?.value ?? 0n)
|
|
2081
2223
|
}),
|
|
2082
2224
|
children: "Top up"
|
|
2083
2225
|
}
|
|
@@ -2103,7 +2245,7 @@ function GasBalance({ isActive, isExpanded, sessionAddress }) {
|
|
|
2103
2245
|
)
|
|
2104
2246
|
) : null
|
|
2105
2247
|
] }),
|
|
2106
|
-
isExpanded ? /* @__PURE__ */ jsxs14(
|
|
2248
|
+
isExpanded ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
|
|
2107
2249
|
/* @__PURE__ */ jsx19("p", { className: "text-sm", children: "Your session's gas balance is used to pay for onchain computation." }),
|
|
2108
2250
|
/* @__PURE__ */ jsxs14("p", { className: "text-sm", children: [
|
|
2109
2251
|
"Send funds to",
|
|
@@ -2321,7 +2463,7 @@ function useChainBalances({ chains }) {
|
|
|
2321
2463
|
}
|
|
2322
2464
|
|
|
2323
2465
|
// src/onboarding/deposit/ChainSelect.tsx
|
|
2324
|
-
import { Fragment as
|
|
2466
|
+
import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2325
2467
|
function ChainSelect({ value, onChange }) {
|
|
2326
2468
|
const theme = useTheme();
|
|
2327
2469
|
const { frame } = useFrame();
|
|
@@ -2373,7 +2515,7 @@ function ChainSelect({ value, onChange }) {
|
|
|
2373
2515
|
className: "w-8"
|
|
2374
2516
|
}
|
|
2375
2517
|
) }),
|
|
2376
|
-
/* @__PURE__ */ jsx25(Select.Icon, { asChild: true, children: /* @__PURE__ */ jsxs15(
|
|
2518
|
+
/* @__PURE__ */ jsx25(Select.Icon, { asChild: true, children: /* @__PURE__ */ jsxs15(Fragment3, { children: [
|
|
2377
2519
|
/* @__PURE__ */ jsx25(ChevronDownIcon, { className: "text-sm -mr-1 group-aria-expanded:hidden" }),
|
|
2378
2520
|
/* @__PURE__ */ jsx25(ChevronUpIcon, { className: "text-sm -mr-1 hidden group-aria-expanded:inline" })
|
|
2379
2521
|
] }) })
|
|
@@ -2418,7 +2560,7 @@ function ChainSelect({ value, onChange }) {
|
|
|
2418
2560
|
}
|
|
2419
2561
|
|
|
2420
2562
|
// src/onboarding/deposit/AmountInput.tsx
|
|
2421
|
-
import { formatEther as formatEther3, parseEther as
|
|
2563
|
+
import { formatEther as formatEther3, parseEther as parseEther4 } from "viem";
|
|
2422
2564
|
import { twMerge as twMerge13 } from "tailwind-merge";
|
|
2423
2565
|
import { forwardRef as forwardRef3 } from "react";
|
|
2424
2566
|
import { jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
@@ -2445,7 +2587,7 @@ var AmountInput = forwardRef3(function AmountInput2({ initialAmount, onChange },
|
|
|
2445
2587
|
return input.setCustomValidity("Invalid amount.");
|
|
2446
2588
|
}
|
|
2447
2589
|
input.setCustomValidity("");
|
|
2448
|
-
onChange(
|
|
2590
|
+
onChange(parseEther4(value));
|
|
2449
2591
|
}
|
|
2450
2592
|
}
|
|
2451
2593
|
),
|
|
@@ -2456,7 +2598,7 @@ var AmountInput = forwardRef3(function AmountInput2({ initialAmount, onChange },
|
|
|
2456
2598
|
// src/onboarding/deposit/SubmitButton.tsx
|
|
2457
2599
|
import { useAccount as useAccount2, useBalance as useBalance3, useSwitchChain as useSwitchChain2 } from "wagmi";
|
|
2458
2600
|
import { twMerge as twMerge14 } from "tailwind-merge";
|
|
2459
|
-
import { parseEther as
|
|
2601
|
+
import { parseEther as parseEther5 } from "viem";
|
|
2460
2602
|
import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2461
2603
|
var MAX_DEPOSIT_AMOUNT = "0.1";
|
|
2462
2604
|
function SubmitButton({ amount, chainId, className, ...buttonProps }) {
|
|
@@ -2477,7 +2619,7 @@ function SubmitButton({ amount, chainId, className, ...buttonProps }) {
|
|
|
2477
2619
|
}
|
|
2478
2620
|
);
|
|
2479
2621
|
} else if (amount) {
|
|
2480
|
-
if (amount >
|
|
2622
|
+
if (amount > parseEther5(MAX_DEPOSIT_AMOUNT)) {
|
|
2481
2623
|
return /* @__PURE__ */ jsxs17(Button, { type: "button", className: twMerge14("w-full", className), disabled: true, children: [
|
|
2482
2624
|
"Max amount is ",
|
|
2483
2625
|
MAX_DEPOSIT_AMOUNT,
|
|
@@ -2514,7 +2656,7 @@ function formatGas(wei) {
|
|
|
2514
2656
|
}
|
|
2515
2657
|
|
|
2516
2658
|
// src/onboarding/deposit/DepositForm.tsx
|
|
2517
|
-
import { Fragment as
|
|
2659
|
+
import { Fragment as Fragment4, jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2518
2660
|
function DepositForm({
|
|
2519
2661
|
sourceChain,
|
|
2520
2662
|
setSourceChainId,
|
|
@@ -2579,7 +2721,7 @@ function DepositForm({
|
|
|
2579
2721
|
/* @__PURE__ */ jsx29("dt", { children: "Gas balance after deposit" }),
|
|
2580
2722
|
/* @__PURE__ */ jsx29("dd", { children: /* @__PURE__ */ jsx29(Balance, { wei: (quarryBalance.data ?? 0n) + (amount ?? 0n) }) }),
|
|
2581
2723
|
/* @__PURE__ */ jsx29("dt", { children: "Estimated fee" }),
|
|
2582
|
-
/* @__PURE__ */ jsx29("dd", { children: estimatedFee.fee ? /* @__PURE__ */ jsxs18(
|
|
2724
|
+
/* @__PURE__ */ jsx29("dd", { children: estimatedFee.fee ? /* @__PURE__ */ jsxs18(Fragment4, { children: [
|
|
2583
2725
|
formatGas(estimatedFee.fee),
|
|
2584
2726
|
" gwei"
|
|
2585
2727
|
] }) : 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 +3081,7 @@ function DepositStatus({ status, progress, children, onDismiss }) {
|
|
|
2939
3081
|
|
|
2940
3082
|
// src/onboarding/deposit/TransferDepositStatus.tsx
|
|
2941
3083
|
import { useChains as useChains2 } from "wagmi";
|
|
2942
|
-
import { Fragment as
|
|
3084
|
+
import { Fragment as Fragment5, jsx as jsx34, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2943
3085
|
function TransferDepositStatus({
|
|
2944
3086
|
amount,
|
|
2945
3087
|
chainL1Id,
|
|
@@ -2967,7 +3109,7 @@ function TransferDepositStatus({
|
|
|
2967
3109
|
children: (() => {
|
|
2968
3110
|
const blockExplorer = chain.blockExplorers?.default.url;
|
|
2969
3111
|
if (receipt.status === "pending") {
|
|
2970
|
-
return /* @__PURE__ */ jsxs20(
|
|
3112
|
+
return /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
2971
3113
|
"Confirming deposit on",
|
|
2972
3114
|
" ",
|
|
2973
3115
|
/* @__PURE__ */ jsx34(
|
|
@@ -2983,7 +3125,7 @@ function TransferDepositStatus({
|
|
|
2983
3125
|
] });
|
|
2984
3126
|
}
|
|
2985
3127
|
if (receipt.status === "error") {
|
|
2986
|
-
return /* @__PURE__ */ jsxs20(
|
|
3128
|
+
return /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
2987
3129
|
"Could not find deposit on",
|
|
2988
3130
|
" ",
|
|
2989
3131
|
/* @__PURE__ */ jsx34(
|
|
@@ -2998,7 +3140,7 @@ function TransferDepositStatus({
|
|
|
2998
3140
|
"."
|
|
2999
3141
|
] });
|
|
3000
3142
|
}
|
|
3001
|
-
return /* @__PURE__ */ jsxs20(
|
|
3143
|
+
return /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
3002
3144
|
"Successfully",
|
|
3003
3145
|
" ",
|
|
3004
3146
|
/* @__PURE__ */ jsx34(
|
|
@@ -3021,7 +3163,7 @@ function TransferDepositStatus({
|
|
|
3021
3163
|
// src/onboarding/deposit/RelayDepositStatus.tsx
|
|
3022
3164
|
import { useQuery as useQuery16 } from "@tanstack/react-query";
|
|
3023
3165
|
import { useChains as useChains3 } from "wagmi";
|
|
3024
|
-
import { Fragment as
|
|
3166
|
+
import { Fragment as Fragment6, jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3025
3167
|
function RelayDepositStatus({
|
|
3026
3168
|
amount,
|
|
3027
3169
|
chainL1Id,
|
|
@@ -3049,20 +3191,20 @@ function RelayDepositStatus({
|
|
|
3049
3191
|
onDismiss,
|
|
3050
3192
|
children: (() => {
|
|
3051
3193
|
if (deposit.status === "pending") {
|
|
3052
|
-
return /* @__PURE__ */ jsxs21(
|
|
3194
|
+
return /* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
3053
3195
|
"Relay bridge deposit pending on ",
|
|
3054
3196
|
chainL1.name,
|
|
3055
3197
|
"\u2026"
|
|
3056
3198
|
] });
|
|
3057
3199
|
}
|
|
3058
3200
|
if (deposit.status === "error") {
|
|
3059
|
-
return /* @__PURE__ */ jsxs21(
|
|
3201
|
+
return /* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
3060
3202
|
"Relay bridge deposit to ",
|
|
3061
3203
|
chainL2.name,
|
|
3062
3204
|
" failed."
|
|
3063
3205
|
] });
|
|
3064
3206
|
}
|
|
3065
|
-
return /* @__PURE__ */ jsxs21(
|
|
3207
|
+
return /* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
3066
3208
|
"Successfully bridged ",
|
|
3067
3209
|
/* @__PURE__ */ jsx35(Balance, { wei: amount }),
|
|
3068
3210
|
" to ",
|
|
@@ -3075,12 +3217,12 @@ function RelayDepositStatus({
|
|
|
3075
3217
|
}
|
|
3076
3218
|
|
|
3077
3219
|
// src/onboarding/deposit/Deposits.tsx
|
|
3078
|
-
import { useAccount as useAccount6, useClient as
|
|
3220
|
+
import { useAccount as useAccount6, useClient as useClient11 } from "wagmi";
|
|
3079
3221
|
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
3080
3222
|
function Deposits() {
|
|
3081
3223
|
const queryClient = useQueryClient8();
|
|
3082
3224
|
const { chainId } = useEntryKitConfig();
|
|
3083
|
-
const client =
|
|
3225
|
+
const client = useClient11({ chainId });
|
|
3084
3226
|
const { address: userAddress } = useAccount6();
|
|
3085
3227
|
const { deposits, removeDeposit } = useDeposits();
|
|
3086
3228
|
const { data: isComplete } = useQuery17({
|
|
@@ -3157,7 +3299,7 @@ function ArrowLeftIcon(props) {
|
|
|
3157
3299
|
// src/onboarding/quarry/WithdrawGasBalanceButton.tsx
|
|
3158
3300
|
import { getAction as getAction6 } from "viem/utils";
|
|
3159
3301
|
import { waitForTransactionReceipt as waitForTransactionReceipt3 } from "viem/actions";
|
|
3160
|
-
import { useAccount as useAccount7, useClient as
|
|
3302
|
+
import { useAccount as useAccount7, useClient as useClient12, useSwitchChain as useSwitchChain3, useWriteContract as useWriteContract2 } from "wagmi";
|
|
3161
3303
|
import { twMerge as twMerge17 } from "tailwind-merge";
|
|
3162
3304
|
import { useMutation as useMutation6 } from "@tanstack/react-query";
|
|
3163
3305
|
import { useQueryClient as useQueryClient9 } from "@tanstack/react-query";
|
|
@@ -3168,7 +3310,7 @@ function WithdrawGasBalanceButton({ userAddress }) {
|
|
|
3168
3310
|
const { chain, chainId } = useEntryKitConfig();
|
|
3169
3311
|
const { chainId: userChainId } = useAccount7();
|
|
3170
3312
|
const queryClient = useQueryClient9();
|
|
3171
|
-
const client =
|
|
3313
|
+
const client = useClient12({ chainId });
|
|
3172
3314
|
const paymaster = getPaymaster(chain);
|
|
3173
3315
|
const balance = useShowQueryError(useBalance(userAddress));
|
|
3174
3316
|
const shouldSwitchChain = chainId != null && chainId !== userChainId;
|
|
@@ -3288,7 +3430,7 @@ function GasBalance2({ isActive, isExpanded, isFocused, setFocused, userAddress
|
|
|
3288
3430
|
|
|
3289
3431
|
// src/onboarding/ConnectedSteps.tsx
|
|
3290
3432
|
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
3291
|
-
function ConnectedSteps({ userClient, initialUserAddress }) {
|
|
3433
|
+
function ConnectedSteps({ connector, userClient, initialUserAddress }) {
|
|
3292
3434
|
const { chain } = useEntryKitConfig();
|
|
3293
3435
|
const paymaster = getPaymaster(chain);
|
|
3294
3436
|
const [focusedId, setFocusedId] = useState5(null);
|
|
@@ -3340,7 +3482,7 @@ function ConnectedSteps({ userClient, initialUserAddress }) {
|
|
|
3340
3482
|
});
|
|
3341
3483
|
}
|
|
3342
3484
|
} else if (paymaster.type === "quarry") {
|
|
3343
|
-
if (paymaster.
|
|
3485
|
+
if (paymaster.canSponsor) {
|
|
3344
3486
|
steps2.push({
|
|
3345
3487
|
id: "allowance",
|
|
3346
3488
|
isComplete: !!hasAllowance,
|
|
@@ -3357,7 +3499,16 @@ function ConnectedSteps({ userClient, initialUserAddress }) {
|
|
|
3357
3499
|
steps2.push({
|
|
3358
3500
|
id: "session",
|
|
3359
3501
|
isComplete: !!isSpender && !!hasDelegation,
|
|
3360
|
-
content: (props) => /* @__PURE__ */ jsx41(
|
|
3502
|
+
content: (props) => /* @__PURE__ */ jsx41(
|
|
3503
|
+
Session,
|
|
3504
|
+
{
|
|
3505
|
+
...props,
|
|
3506
|
+
userClient,
|
|
3507
|
+
connector,
|
|
3508
|
+
registerSpender: !isSpender,
|
|
3509
|
+
registerDelegation: !hasDelegation
|
|
3510
|
+
}
|
|
3511
|
+
)
|
|
3361
3512
|
});
|
|
3362
3513
|
return steps2;
|
|
3363
3514
|
}, [
|
|
@@ -3369,7 +3520,8 @@ function ConnectedSteps({ userClient, initialUserAddress }) {
|
|
|
3369
3520
|
paymaster,
|
|
3370
3521
|
sessionAddress,
|
|
3371
3522
|
userAddress,
|
|
3372
|
-
userClient
|
|
3523
|
+
userClient,
|
|
3524
|
+
connector
|
|
3373
3525
|
]);
|
|
3374
3526
|
const [selectedStepId] = useState5(null);
|
|
3375
3527
|
const nextStep = steps.find((step) => step.content != null && !step.isComplete);
|
|
@@ -3412,13 +3564,20 @@ import { useRef as useRef6 } from "react";
|
|
|
3412
3564
|
import { jsx as jsx42 } from "react/jsx-runtime";
|
|
3413
3565
|
function AccountModalContent() {
|
|
3414
3566
|
const { chainId } = useEntryKitConfig();
|
|
3415
|
-
const
|
|
3416
|
-
const {
|
|
3567
|
+
const { address: userAddress, connector } = useAccount8();
|
|
3568
|
+
const userClient = useConnectorClient({ chainId, connector });
|
|
3417
3569
|
const initialUserAddress = useRef6(userAddress);
|
|
3418
3570
|
if (userClient.status !== "success") {
|
|
3419
3571
|
return /* @__PURE__ */ jsx42(ConnectWallet, {});
|
|
3420
3572
|
}
|
|
3421
|
-
return /* @__PURE__ */ jsx42(
|
|
3573
|
+
return /* @__PURE__ */ jsx42(
|
|
3574
|
+
ConnectedSteps,
|
|
3575
|
+
{
|
|
3576
|
+
connector,
|
|
3577
|
+
userClient: userClient.data,
|
|
3578
|
+
initialUserAddress: initialUserAddress.current
|
|
3579
|
+
}
|
|
3580
|
+
);
|
|
3422
3581
|
}
|
|
3423
3582
|
|
|
3424
3583
|
// src/AccountModal.tsx
|
|
@@ -3429,7 +3588,7 @@ import { ErrorBoundary } from "react-error-boundary";
|
|
|
3429
3588
|
import { wait } from "@latticexyz/common/utils";
|
|
3430
3589
|
import { useEffect as useEffect16 } from "react";
|
|
3431
3590
|
import { twMerge as twMerge19 } from "tailwind-merge";
|
|
3432
|
-
import { Fragment as
|
|
3591
|
+
import { Fragment as Fragment7, jsx as jsx43, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
3433
3592
|
function ErrorOverlay({ error: error2, retry, dismiss }) {
|
|
3434
3593
|
useEffect16(() => {
|
|
3435
3594
|
if (error2) {
|
|
@@ -3455,7 +3614,7 @@ function ErrorOverlay({ error: error2, retry, dismiss }) {
|
|
|
3455
3614
|
"transition duration-300",
|
|
3456
3615
|
error2 ? "translate-y-0 opacity-100 pointer-events-auto" : "-translate-y-4 opacity-0"
|
|
3457
3616
|
),
|
|
3458
|
-
children: error2 ? /* @__PURE__ */ jsx43(
|
|
3617
|
+
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
3618
|
/* @__PURE__ */ jsxs25("div", { className: "space-y-6 px-8 pt-8", children: [
|
|
3460
3619
|
/* @__PURE__ */ jsx43("div", { className: "text-white text-lg font-bold", children: "Oops! It broke :(" }),
|
|
3461
3620
|
/* @__PURE__ */ jsx43("div", { className: "font-mono text-xs whitespace-pre-wrap", children: error2.message.trim() }),
|
|
@@ -3584,11 +3743,11 @@ import { twMerge as twMerge22 } from "tailwind-merge";
|
|
|
3584
3743
|
|
|
3585
3744
|
// src/AccountName.tsx
|
|
3586
3745
|
import { twMerge as twMerge21 } from "tailwind-merge";
|
|
3587
|
-
import { Fragment as
|
|
3746
|
+
import { Fragment as Fragment8, jsx as jsx48, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
3588
3747
|
function AccountName({ address }) {
|
|
3589
3748
|
const { data: ens } = useENS(address);
|
|
3590
3749
|
const avatar = usePreloadImage(ens?.avatar);
|
|
3591
|
-
return /* @__PURE__ */ jsxs28(
|
|
3750
|
+
return /* @__PURE__ */ jsxs28(Fragment8, { children: [
|
|
3592
3751
|
/* @__PURE__ */ jsxs28("span", { className: "flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center", children: [
|
|
3593
3752
|
/* @__PURE__ */ jsx48(
|
|
3594
3753
|
"img",
|
|
@@ -3632,7 +3791,7 @@ var secondaryClassNames = twMerge22(
|
|
|
3632
3791
|
var secondaryInteractiveClassNames = twMerge22(
|
|
3633
3792
|
"cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700"
|
|
3634
3793
|
);
|
|
3635
|
-
function
|
|
3794
|
+
function AccountButton2() {
|
|
3636
3795
|
const { openAccountModal, accountModalOpen } = useAccountModal();
|
|
3637
3796
|
const { status, address: userAddress } = useAccount9();
|
|
3638
3797
|
const initialUserAddress = useRef7(userAddress);
|
|
@@ -3721,6 +3880,8 @@ function useSessionClientReady() {
|
|
|
3721
3880
|
// src/createWagmiConfig.ts
|
|
3722
3881
|
import { createConfig } from "wagmi";
|
|
3723
3882
|
import { getDefaultConfig } from "connectkit";
|
|
3883
|
+
|
|
3884
|
+
// src/getDefaultConnectors.ts
|
|
3724
3885
|
import { injected, coinbaseWallet, safe } from "wagmi/connectors";
|
|
3725
3886
|
|
|
3726
3887
|
// src/connectors/walletConnect.ts
|
|
@@ -3729,7 +3890,7 @@ import {
|
|
|
3729
3890
|
SwitchChainError,
|
|
3730
3891
|
UserRejectedRequestError,
|
|
3731
3892
|
getAddress,
|
|
3732
|
-
numberToHex as
|
|
3893
|
+
numberToHex as numberToHex2
|
|
3733
3894
|
} from "viem";
|
|
3734
3895
|
walletConnect.type = "walletConnect";
|
|
3735
3896
|
function walletConnect(parameters) {
|
|
@@ -3926,7 +4087,7 @@ function walletConnect(parameters) {
|
|
|
3926
4087
|
}),
|
|
3927
4088
|
provider.request({
|
|
3928
4089
|
method: "wallet_switchEthereumChain",
|
|
3929
|
-
params: [{ chainId:
|
|
4090
|
+
params: [{ chainId: numberToHex2(chainId) }]
|
|
3930
4091
|
})
|
|
3931
4092
|
]);
|
|
3932
4093
|
const requestedChains = await this.getRequestedChainsIds();
|
|
@@ -3945,7 +4106,7 @@ function walletConnect(parameters) {
|
|
|
3945
4106
|
else rpcUrls = [...chain.rpcUrls.default.http];
|
|
3946
4107
|
const addEthereumChain = {
|
|
3947
4108
|
blockExplorerUrls,
|
|
3948
|
-
chainId:
|
|
4109
|
+
chainId: numberToHex2(chainId),
|
|
3949
4110
|
chainName: addEthereumChainParameter?.chainName ?? chain.name,
|
|
3950
4111
|
iconUrls: addEthereumChainParameter?.iconUrls,
|
|
3951
4112
|
nativeCurrency: addEthereumChainParameter?.nativeCurrency ?? chain.nativeCurrency,
|
|
@@ -4056,8 +4217,8 @@ function extractRpcUrls(parameters) {
|
|
|
4056
4217
|
return transports.map(({ value }) => value?.url || fallbackUrl);
|
|
4057
4218
|
}
|
|
4058
4219
|
|
|
4059
|
-
// src/
|
|
4060
|
-
function
|
|
4220
|
+
// src/getDefaultConnectors.ts
|
|
4221
|
+
function getDefaultConnectors(config) {
|
|
4061
4222
|
const connectors = [];
|
|
4062
4223
|
const shouldUseSafeConnector = !(typeof window === "undefined") && window?.parent !== window;
|
|
4063
4224
|
if (shouldUseSafeConnector) {
|
|
@@ -4082,6 +4243,12 @@ function createWagmiConfig(config) {
|
|
|
4082
4243
|
})
|
|
4083
4244
|
);
|
|
4084
4245
|
}
|
|
4246
|
+
return connectors;
|
|
4247
|
+
}
|
|
4248
|
+
|
|
4249
|
+
// src/createWagmiConfig.ts
|
|
4250
|
+
function createWagmiConfig(config) {
|
|
4251
|
+
const connectors = config.connectors ?? getDefaultConnectors(config);
|
|
4085
4252
|
const configParams = getDefaultConfig({
|
|
4086
4253
|
chains: config.chains,
|
|
4087
4254
|
transports: config.transports,
|
|
@@ -4094,8 +4261,27 @@ function createWagmiConfig(config) {
|
|
|
4094
4261
|
return createConfig(configParams);
|
|
4095
4262
|
}
|
|
4096
4263
|
|
|
4264
|
+
// src/utils/withFeeCache.ts
|
|
4265
|
+
import { createClient as createClient3, http as http3 } from "viem";
|
|
4266
|
+
function withFeeCache(chain, options = { refreshInterval: 1e4 }) {
|
|
4267
|
+
if (chain.fees?.estimateFeesPerGas) {
|
|
4268
|
+
throw new Error("withFeeCache: estimateFeesPerGas already defined in chain config");
|
|
4269
|
+
}
|
|
4270
|
+
const client = createClient3({
|
|
4271
|
+
chain,
|
|
4272
|
+
transport: http3()
|
|
4273
|
+
});
|
|
4274
|
+
return {
|
|
4275
|
+
...chain,
|
|
4276
|
+
fees: {
|
|
4277
|
+
...chain.fees,
|
|
4278
|
+
estimateFeesPerGas: cachedFeesPerGas(client, options)
|
|
4279
|
+
}
|
|
4280
|
+
};
|
|
4281
|
+
}
|
|
4282
|
+
|
|
4097
4283
|
// src/validateSigner.ts
|
|
4098
|
-
import { readContract } from "viem/actions";
|
|
4284
|
+
import { readContract as readContract2 } from "viem/actions";
|
|
4099
4285
|
async function internal_validateSigner({
|
|
4100
4286
|
client,
|
|
4101
4287
|
worldAddress,
|
|
@@ -4103,7 +4289,7 @@ async function internal_validateSigner({
|
|
|
4103
4289
|
sessionAddress,
|
|
4104
4290
|
signerAddress
|
|
4105
4291
|
}) {
|
|
4106
|
-
const ownerAddress = await
|
|
4292
|
+
const ownerAddress = await readContract2(client, {
|
|
4107
4293
|
address: sessionAddress,
|
|
4108
4294
|
abi: simpleAccountAbi,
|
|
4109
4295
|
functionName: "owner"
|
|
@@ -4138,15 +4324,20 @@ var simpleAccountAbi = [
|
|
|
4138
4324
|
}
|
|
4139
4325
|
];
|
|
4140
4326
|
export {
|
|
4141
|
-
AccountButton,
|
|
4327
|
+
AccountButton2 as AccountButton,
|
|
4142
4328
|
EntryKitProvider,
|
|
4329
|
+
createBundlerClient,
|
|
4143
4330
|
createWagmiConfig,
|
|
4331
|
+
defineCall,
|
|
4144
4332
|
defineConfig,
|
|
4333
|
+
getBundlerTransport,
|
|
4334
|
+
getDefaultConnectors,
|
|
4145
4335
|
getFundsQueryOptions,
|
|
4146
4336
|
internal_validateSigner,
|
|
4147
4337
|
useAccountModal,
|
|
4148
4338
|
useEntryKitConfig,
|
|
4149
4339
|
useFunds,
|
|
4150
|
-
useSessionClientReady as useSessionClient
|
|
4340
|
+
useSessionClientReady as useSessionClient,
|
|
4341
|
+
withFeeCache
|
|
4151
4342
|
};
|
|
4152
4343
|
//# sourceMappingURL=internal.js.map
|