@latticexyz/entrykit 2.2.17-dead80e682bfa1bd23f4d3b9bac338aee38c281e → 2.2.17-e347d31fd6f6ac4225ee679bceb6e040c6f8d0d8
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.
- package/bin/{deploy-local-prereqs.js → deploy.js} +1 -1
- package/dist/tsup/bin/deploy.js +13 -0
- package/dist/tsup/bin/deploy.js.map +1 -0
- package/dist/tsup/exports/internal.js +3 -3
- package/dist/tsup/exports/internal.js.map +1 -1
- package/package.json +10 -9
- package/dist/tsup/bin/deploy-local-prereqs.js +0 -16
- package/dist/tsup/bin/deploy-local-prereqs.js.map +0 -1
- /package/dist/tsup/bin/{deploy-local-prereqs.d.ts → deploy.d.ts} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import"dotenv/config";import{concatHex as p,http as x,isHex as P,parseAbiParameters as l,encodeAbiParameters as m,size as r,parseEther as w,createClient as E}from"viem";import{privateKeyToAccount as g}from"viem/accounts";import{getRpcUrl as v}from"@latticexyz/common/foundry";import{ensureContractsDeployed as s,ensureDeployer as h,getContractAddress as b,waitForTransactions as H}from"@latticexyz/common/internal";import a from"@account-abstraction/contracts/artifacts/EntryPoint.json"assert{type:"json"};import d from"@account-abstraction/contracts/artifacts/SimpleAccountFactory.json"assert{type:"json"};import i from"@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json"assert{type:"json"};import{getChainId as B}from"viem/actions";import{writeContract as T}from"@latticexyz/common";import{entryPoint07Address as y}from"viem/account-abstraction";var f=process.env.PRIVATE_KEY;if(!P(f))throw new Error(`Missing \`PRIVATE_KEY\` environment variable. If you're using Anvil, run
|
|
2
|
+
|
|
3
|
+
echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env
|
|
4
|
+
|
|
5
|
+
to use a prefunded Anvil account.`);var I=g(f),K=await v(),e=E({account:I,transport:x(K)}),j=await B(e),t=await h(e),u="0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3",o=b({deployerAddress:t,bytecode:a.bytecode,salt:u});if(o!==y)throw new Error(`Unexpected EntryPoint v0.7 address
|
|
6
|
+
|
|
7
|
+
Expected: ${y}
|
|
8
|
+
Actual: ${o}`);await s({client:e,deployerAddress:t,contracts:[{bytecode:a.bytecode,salt:u,deployedBytecodeSize:r(a.deployedBytecode),debugLabel:"EntryPoint v0.7"}]});await s({client:e,deployerAddress:t,contracts:[{bytecode:p([d.bytecode,m(l("address"),[o])]),deployedBytecodeSize:r(d.deployedBytecode),debugLabel:"SimpleAccountFactory"}]});if(j===31337){let c=p([i.bytecode.object,m(l("address"),[o])]),n=b({deployerAddress:t,bytecode:c});await s({client:e,deployerAddress:t,contracts:[{bytecode:c,deployedBytecodeSize:r(i.deployedBytecode.object),debugLabel:"GenerousPaymaster"}]});let A=await T(e,{chain:null,address:o,abi:[{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"}],functionName:"depositTo",args:[n],value:w("100")});await H({client:e,hashes:[A]}),console.log(`
|
|
9
|
+
Funded local paymaster at:`,n,`
|
|
10
|
+
`)}console.log(`
|
|
11
|
+
EntryKit contracts are ready!
|
|
12
|
+
`);process.exit(0);
|
|
13
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/bin/deploy.ts"],"sourcesContent":["import \"dotenv/config\";\nimport {\n Hex,\n concatHex,\n http,\n isHex,\n parseAbiParameters,\n encodeAbiParameters,\n size,\n parseEther,\n createClient,\n} from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { getRpcUrl } from \"@latticexyz/common/foundry\";\nimport {\n ensureContractsDeployed,\n ensureDeployer,\n getContractAddress,\n waitForTransactions,\n} from \"@latticexyz/common/internal\";\nimport entryPointArtifact from \"@account-abstraction/contracts/artifacts/EntryPoint.json\" assert { type: \"json\" };\nimport simpleAccountFactoryArtifact from \"@account-abstraction/contracts/artifacts/SimpleAccountFactory.json\" assert { type: \"json\" };\nimport localPaymasterArtifact from \"@latticexyz/paymaster/out/GenerousPaymaster.sol/GenerousPaymaster.json\" assert { type: \"json\" };\nimport { getChainId } from \"viem/actions\";\nimport { writeContract } from \"@latticexyz/common\";\nimport { entryPoint07Address } from \"viem/account-abstraction\";\n\n// TODO: parse env with arktype (to avoid zod dep) and throw when absent\n\nconst privateKey = process.env.PRIVATE_KEY;\nif (!isHex(privateKey)) {\n // TODO: detect anvil and automatically put this env var where it needs to go?\n throw new Error(\n `Missing \\`PRIVATE_KEY\\` environment variable. If you're using Anvil, run\n\n echo \"PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\" > .env\n\nto use a prefunded Anvil account.`,\n );\n}\nconst account = privateKeyToAccount(privateKey);\nconst rpcUrl = await getRpcUrl();\n\nconst client = createClient({ account, transport: http(rpcUrl) });\n\nconst chainId = await getChainId(client);\n\n// TODO: deployer address flag/env var?\nconst deployerAddress = await ensureDeployer(client);\n\n// https://github.com/eth-infinitism/account-abstraction/blob/b3bae63bd9bc0ed394dfca8668008213127adb62/hardhat.config.ts#L11\nconst entryPointSalt = \"0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3\";\nconst entryPointAddress = getContractAddress({\n deployerAddress,\n bytecode: entryPointArtifact.bytecode as Hex,\n salt: entryPointSalt,\n});\nif (entryPointAddress !== entryPoint07Address) {\n throw new Error(\n `Unexpected EntryPoint v0.7 address\\n\\n Expected: ${entryPoint07Address}\\nActual: ${entryPointAddress}`,\n );\n}\n\n// Deploy entrypoint first, because following deploys need to be able to call it.\nawait ensureContractsDeployed({\n client,\n deployerAddress,\n contracts: [\n {\n bytecode: entryPointArtifact.bytecode as Hex,\n salt: entryPointSalt,\n deployedBytecodeSize: size(entryPointArtifact.deployedBytecode as Hex),\n debugLabel: \"EntryPoint v0.7\",\n },\n ],\n});\n\nawait ensureContractsDeployed({\n client,\n deployerAddress,\n contracts: [\n {\n bytecode: concatHex([\n simpleAccountFactoryArtifact.bytecode as Hex,\n encodeAbiParameters(parseAbiParameters(\"address\"), [entryPointAddress]),\n ]),\n deployedBytecodeSize: size(simpleAccountFactoryArtifact.deployedBytecode as Hex),\n debugLabel: \"SimpleAccountFactory\",\n },\n ],\n});\n\nif (chainId === 31337) {\n const localPaymasterBytecode = concatHex([\n localPaymasterArtifact.bytecode.object as Hex,\n encodeAbiParameters(parseAbiParameters(\"address\"), [entryPointAddress]),\n ]);\n const localPaymasterAddress = getContractAddress({ deployerAddress, bytecode: localPaymasterBytecode });\n\n await ensureContractsDeployed({\n client,\n deployerAddress,\n contracts: [\n {\n bytecode: localPaymasterBytecode,\n deployedBytecodeSize: size(localPaymasterArtifact.deployedBytecode.object as Hex),\n debugLabel: \"GenerousPaymaster\",\n },\n ],\n });\n\n const tx = await writeContract(client, {\n chain: null,\n address: entryPointAddress,\n abi: [\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"depositTo\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n ],\n functionName: \"depositTo\",\n args: [localPaymasterAddress],\n value: parseEther(\"100\"),\n });\n await waitForTransactions({ client, hashes: [tx] });\n console.log(\"\\nFunded local paymaster at:\", localPaymasterAddress, \"\\n\");\n}\n\nconsole.log(\"\\nEntryKit contracts are ready!\\n\");\nprocess.exit(0);\n"],"mappings":"AAAA,MAAO,gBACP,OAEE,aAAAA,EACA,QAAAC,EACA,SAAAC,EACA,sBAAAC,EACA,uBAAAC,EACA,QAAAC,EACA,cAAAC,EACA,gBAAAC,MACK,OACP,OAAS,uBAAAC,MAA2B,gBACpC,OAAS,aAAAC,MAAiB,6BAC1B,OACE,2BAAAC,EACA,kBAAAC,EACA,sBAAAC,EACA,uBAAAC,MACK,8BACP,OAAOC,MAAwB,0DAA2D,MAAO,CAAE,KAAM,MAAO,EAChH,OAAOC,MAAkC,oEAAqE,MAAO,CAAE,KAAM,MAAO,EACpI,OAAOC,MAA4B,wEAAyE,MAAO,CAAE,KAAM,MAAO,EAClI,OAAS,cAAAC,MAAkB,eAC3B,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,uBAAAC,MAA2B,2BAIpC,IAAMC,EAAa,QAAQ,IAAI,YAC/B,GAAI,CAAClB,EAAMkB,CAAU,EAEnB,MAAM,IAAI,MACR;AAAA;AAAA;AAAA;AAAA,kCAKF,EAEF,IAAMC,EAAUb,EAAoBY,CAAU,EACxCE,EAAS,MAAMb,EAAU,EAEzBc,EAAShB,EAAa,CAAE,QAAAc,EAAS,UAAWpB,EAAKqB,CAAM,CAAE,CAAC,EAE1DE,EAAU,MAAMP,EAAWM,CAAM,EAGjCE,EAAkB,MAAMd,EAAeY,CAAM,EAG7CG,EAAiB,qEACjBC,EAAoBf,EAAmB,CAC3C,gBAAAa,EACA,SAAUX,EAAmB,SAC7B,KAAMY,CACR,CAAC,EACD,GAAIC,IAAsBR,EACxB,MAAM,IAAI,MACR;AAAA;AAAA,cAAqDA,CAAmB;AAAA,UAAaQ,CAAiB,EACxG,EAIF,MAAMjB,EAAwB,CAC5B,OAAAa,EACA,gBAAAE,EACA,UAAW,CACT,CACE,SAAUX,EAAmB,SAC7B,KAAMY,EACN,qBAAsBrB,EAAKS,EAAmB,gBAAuB,EACrE,WAAY,iBACd,CACF,CACF,CAAC,EAED,MAAMJ,EAAwB,CAC5B,OAAAa,EACA,gBAAAE,EACA,UAAW,CACT,CACE,SAAUzB,EAAU,CAClBe,EAA6B,SAC7BX,EAAoBD,EAAmB,SAAS,EAAG,CAACwB,CAAiB,CAAC,CACxE,CAAC,EACD,qBAAsBtB,EAAKU,EAA6B,gBAAuB,EAC/E,WAAY,sBACd,CACF,CACF,CAAC,EAED,GAAIS,IAAY,MAAO,CACrB,IAAMI,EAAyB5B,EAAU,CACvCgB,EAAuB,SAAS,OAChCZ,EAAoBD,EAAmB,SAAS,EAAG,CAACwB,CAAiB,CAAC,CACxE,CAAC,EACKE,EAAwBjB,EAAmB,CAAE,gBAAAa,EAAiB,SAAUG,CAAuB,CAAC,EAEtG,MAAMlB,EAAwB,CAC5B,OAAAa,EACA,gBAAAE,EACA,UAAW,CACT,CACE,SAAUG,EACV,qBAAsBvB,EAAKW,EAAuB,iBAAiB,MAAa,EAChF,WAAY,mBACd,CACF,CACF,CAAC,EAED,IAAMc,EAAK,MAAMZ,EAAcK,EAAQ,CACrC,MAAO,KACP,QAASI,EACT,IAAK,CACH,CACE,OAAQ,CAAC,CAAE,KAAM,UAAW,KAAM,SAAU,CAAC,EAC7C,KAAM,YACN,QAAS,CAAC,EACV,gBAAiB,UACjB,KAAM,UACR,CACF,EACA,aAAc,YACd,KAAM,CAACE,CAAqB,EAC5B,MAAOvB,EAAW,KAAK,CACzB,CAAC,EACD,MAAMO,EAAoB,CAAE,OAAAU,EAAQ,OAAQ,CAACO,CAAE,CAAE,CAAC,EAClD,QAAQ,IAAI;AAAA,4BAAgCD,EAAuB;AAAA,CAAI,CACzE,CAEA,QAAQ,IAAI;AAAA;AAAA,CAAmC,EAC/C,QAAQ,KAAK,CAAC","names":["concatHex","http","isHex","parseAbiParameters","encodeAbiParameters","size","parseEther","createClient","privateKeyToAccount","getRpcUrl","ensureContractsDeployed","ensureDeployer","getContractAddress","waitForTransactions","entryPointArtifact","simpleAccountFactoryArtifact","localPaymasterArtifact","getChainId","writeContract","entryPoint07Address","privateKey","account","rpcUrl","client","chainId","deployerAddress","entryPointSalt","entryPointAddress","localPaymasterBytecode","localPaymasterAddress","tx"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function Gt(e){return{...e,appName:e.appName??document.title,appIcon:e.appIcon??document.querySelector("link[rel~='icon']")?.getAttribute("href")??"/favico.ico"}}import{Root as ar,DialogPortal as ir,DialogContent as sr}from"@radix-ui/react-dialog";import{forwardRef as Zt,useEffect as Jt,useRef as
|
|
1
|
+
function Gt(e){return{...e,appName:e.appName??document.title,appIcon:e.appIcon??document.querySelector("link[rel~='icon']")?.getAttribute("href")??"/favico.ico"}}import{Root as ar,DialogPortal as ir,DialogContent as sr}from"@radix-ui/react-dialog";import{forwardRef as Zt,useEffect as Jt,useRef as Te,useState as Ee}from"react";import er from"react-dom";var ve=`*, ::before, ::after {
|
|
2
2
|
--tw-border-spacing-x: 0;
|
|
3
3
|
--tw-border-spacing-y: 0;
|
|
4
4
|
--tw-translate-x: 0;
|
|
@@ -1392,7 +1392,7 @@ video {
|
|
|
1392
1392
|
--tw-text-opacity: 1;
|
|
1393
1393
|
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
1394
1394
|
}
|
|
1395
|
-
`;import{useResizeObserver as tr}from"usehooks-ts";import{mergeRefs as rr}from"react-merge-refs";import{createContext as Vt,useContext as Wt}from"react";import{jsx as _t}from"react/jsx-runtime";var Ce=Vt(null);function ke({frame:e,children:t}){if(Wt(Ce))throw new Error("`FrameProvider` can only be used once.");return _t(Ce.Provider,{value:{frame:e},children:t})}import{useMediaQuery as $t}from"usehooks-ts";import"@rainbow-me/rainbowkit/styles.css";import{createContext as Yt,useContext as
|
|
1395
|
+
`;import{useResizeObserver as tr}from"usehooks-ts";import{mergeRefs as rr}from"react-merge-refs";import{createContext as Vt,useContext as Wt}from"react";import{jsx as _t}from"react/jsx-runtime";var Ce=Vt(null);function ke({frame:e,children:t}){if(Wt(Ce))throw new Error("`FrameProvider` can only be used once.");return _t(Ce.Provider,{value:{frame:e},children:t})}import{useMediaQuery as $t}from"usehooks-ts";import"@rainbow-me/rainbowkit/styles.css";import{createContext as Yt,useContext as Ue}from"react";import{RainbowKitProvider as Xt,lightTheme as Se,midnightTheme as Ae}from"@rainbow-me/rainbowkit";import{useChains as jt}from"wagmi";import{jsx as Pe}from"react/jsx-runtime";var ne=Yt(null);function Ne({config:e,children:t}){if(Ue(ne))throw new Error("`EntryKitProvider` can only be used once.");let n=jt().find(({id:a})=>a===e.chainId);if(!n)throw new Error(`Could not find configured chain for chain ID ${e.chainId}.`);return Pe(Xt,{initialChain:0,appInfo:{appName:e.appName},theme:e.theme==="light"?Se({borderRadius:"none"}):e.theme==="dark"?Ae({borderRadius:"none"}):{lightMode:Se({borderRadius:"none"}),darkMode:Ae({borderRadius:"none"})},children:Pe(ne.Provider,{value:{...e,chain:n},children:t})})}function l(){let e=Ue(ne);if(!e)throw new Error("`useEntryKitConfig` can only be used within a `EntryKitProvider`.");return e}function Re(){let{theme:e}=l(),t=$t("(prefers-color-scheme: dark)");return e??(t?"dark":"light")}import{jsx as O,jsxs as nr}from"react/jsx-runtime";function or({onSize:e,...t}){let r=Te(null);return tr({ref:r,onResize:e}),O("div",{ref:r,...t,style:{...t.style,display:"inline-grid"}})}var G=Zt(function({mode:t,children:r},o){let n=Te(null),[a,i]=Ee(!1),s=a?n.current:null,[c,g]=Ee({width:void 0,height:void 0}),m=s?.contentDocument,d=Re();Jt(()=>{m&&m.body.setAttribute("data-theme",d)},[m,d]);let p=t==="modal"?{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",zIndex:"2147483646"}:c.width&&c.height?{all:"unset",display:"inline-grid",width:`${c.width}px`,height:`${c.height}px`}:{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",opacity:0,pointerEvents:"none"};return O("iframe",{ref:rr([o,n]),style:p,onLoad:()=>i(!0),srcDoc:"<!doctype html><title>\u2026</title>",children:m?er.createPortal(nr(ke,{frame:s,children:[O("div",{children:t==="modal"?r:O(or,{onSize:g,children:r})}),O("style",{dangerouslySetInnerHTML:{__html:ve}})]}),m.body):null})});import{twMerge as Me}from"tailwind-merge";import{jsx as R,jsxs as lr}from"react/jsx-runtime";function Ie({open:e,onOpenChange:t,children:r}){return R(ar,{open:e,onOpenChange:t,children:R(ir,{children:lr(G,{mode:"modal",children:[R("div",{className:Me("fixed inset-0","bg-neutral-800/85","animate-in animate-duration-300 fade-in")}),R("div",{className:Me("fixed inset-0","grid items-end sm:items-center","animate-in animate-duration-300 fade-in slide-in-from-bottom-16"),children:R("div",{children:R(sr,{className:"outline-none w-full max-w-[26rem] mx-auto","aria-describedby":void 0,onOpenAutoFocus:o=>{o.preventDefault()},children:r})})})]})})})}import{useCallback as ae,useMemo as dr}from"react";import{useStore as cr}from"zustand";import{createStore as pr}from"zustand/vanilla";var Q=pr(()=>({open:!1}));function C(){let e=cr(Q,n=>n.open),t=ae(()=>{Q.setState({open:!0})},[]),r=ae(()=>{Q.setState({open:!1})},[]),o=ae(n=>{Q.setState({open:n})},[]);return dr(()=>({accountModalOpen:e,openAccountModal:t,closeAccountModal:r,toggleAccountModal:o}),[e,t,r,o])}import{twMerge as It}from"tailwind-merge";import{useAccount as Un,useConnectorClient as Nn}from"wagmi";import{useAccount as xr}from"wagmi";import{twMerge as q}from"tailwind-merge";import{twMerge as mr}from"tailwind-merge";import{jsx as He,jsxs as ur}from"react/jsx-runtime";function b({className:e,...t}){return ur("svg",{className:mr("-my-[0.125em] h-[1.25em] w-[1.25em] animate-spin",e),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",...t,children:[He("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),He("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}import{jsx as z,jsxs as fr}from"react/jsx-runtime";var gr=({variant:e="secondary"}={})=>q("group/button self-center leading-none outline-none border-4 border-transparent","transition hover:brightness-125 active:brightness-150","focus:border-orange-500","aria-disabled:pointer-events-none aria-busy:pointer-events-none","aria-disabled:opacity-50","p-[.75em] font-medium",{primary:q("bg-orange-600 text-white focus:border-yellow-400"),secondary:q("bg-neutral-700 text-white focus:border-orange-500"),tertiary:q("bg-neutral-800 text-white focus:border-orange-500")}[e]),y=({pending:e,variant:t,type:r,className:o,children:n,disabled:a,...i})=>z("button",{type:r||"button",className:q(gr({variant:t,pending:e}),o),"aria-busy":e,"aria-disabled":a,disabled:a||e,...i,children:fr("span",{className:"grid grid-cols-[1fr_auto_1fr] gap-2",children:[z("span",{className:"flex items-center justify-end text-[.75em]",children:z("span",{className:"transition opacity-0 translate-x-2 group-aria-busy/button:opacity-100 group-aria-busy/button:translate-x-0 duration-100 group-aria-busy/button:duration-300",children:z(b,{})})}),z("span",{children:n})]})});import{useConnectModal as vr}from"@rainbow-me/rainbowkit";import{twMerge as hr}from"tailwind-merge";import{jsx as ie,jsxs as yr}from"react/jsx-runtime";function A({className:e,...t}){return yr("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 8 8",fill:"currentColor",shapeRendering:"crispEdges",className:hr("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...t,children:[ie("path",{d:"M0 0h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm2-1h1v1H7zm0 1h1v1H7zM6 7h1v1H6zm1-2h1v1H7zm0-1h1v1H7zm0-1h1v1H7z"}),ie("path",{d:"M2 2h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm1-3h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm0 1h1v1H5zm0 1h1v1H5zm0 1h1v1H5zM4 5h1v1H4zM3 5h1v1H3z",opacity:".5"}),ie("path",{d:"M7 2h1v1H7zm0-1h1v1H7zM1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm1 0h1v1H6zm1 0h1v1H7z"})]})}import{useQuery as br}from"@tanstack/react-query";function V(e){return br({enabled:!!e,retry:!1,retryOnMount:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,queryKey:["preloadImage",e],queryFn:()=>new Promise((t,r)=>{if(!e)throw new Error("usePreloadImage: Must provide `url` to preload image.");let o=new Image;o.onload=()=>t(o),o.onerror=()=>r(new Error(`usePreloadImage: Could not load image.
|
|
1396
1396
|
|
|
1397
|
-
URL: ${e}`)),o.src=e})})}import{jsx as W,jsxs as br}from"react/jsx-runtime";function ze(){let{appName:e,appIcon:t}=l(),{data:r,isLoading:o}=V(t);return br("div",{className:"flex-grow flex flex-col items-center justify-center gap-2",children:[W("div",{className:"w-16 h-16 m-2",children:o?null:r?W("img",{src:t,className:"w-full h-full object-cover"}):W(P,{className:"w-full h-full text-orange-500 dark:bg-neutral-800"})}),W("div",{className:"text-2xl text-white text-center",children:e})]})}import{twMerge as Cr}from"tailwind-merge";import{useEffect as kr,useState as Sr}from"react";import{jsx as _,jsxs as Pr}from"react/jsx-runtime";function qe(){let e=xr(),{openConnectModal:t,connectModalOpen:r}=vr(),[o,n]=Sr(!1);return kr(()=>{!r&&!o&&(t?.(),n(!0))},[r,o,t]),Pr("div",{className:Cr("flex flex-col gap-6 p-6","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:[_("div",{className:"p-4",children:_(ze,{})}),_("div",{className:"self-center flex flex-col gap-2 w-60",children:_(y,{variant:"secondary",className:"self-auto flex justify-center",disabled:e.status==="connecting",onClick:t,autoFocus:!0,children:"Connect wallet"},"create")})]})}import{useEffect as kn,useMemo as Sn,useRef as Pn,useState as An}from"react";import{twMerge as ye}from"tailwind-merge";import{parseEther as Ar}from"viem";var A=Ar("0.01");import{useClient as zr}from"wagmi";import{queryOptions as qr,useQuery as Br}from"@tanstack/react-query";import{numberToHex as Tr}from"viem";import{defineStore as Nr}from"@latticexyz/store";import{parseAbi as Er}from"viem";var se=Er(["error SpenderSystem_AlreadyRegistered(address spender, address user)","error SpenderSystem_HasOwnBalance(address spender)","function registerSpender(address spender)"]),Rr=Nr({namespaces:{root:{namespace:"",tables:{Allowance:{schema:{user:"address",allowance:"uint256"},key:["user"]},Grantor:{schema:{grantor:"address",allowance:"uint256"},key:["grantor"]},PassHolder:{schema:{user:"address",passId:"bytes32",lastRenewed:"uint256",lastClaimed:"uint256"},key:["user","passId"]},PassConfig:{schema:{passId:"bytes32",claimAmount:"uint256",claimInterval:"uint256",validityPeriod:"uint256",grantor:"address"},key:["passId"]},Spender:{schema:{spender:"address",user:"address"},key:["spender"]},SystemConfig:{schema:{entryPoint:"address"},key:[]}}}}}),T=Rr.namespaces.root.tables;import{getRecord as Mr,getStaticDataLocation as Ir}from"@latticexyz/store/internal";import{getKeyTuple as Hr}from"@latticexyz/protocol-parser/internal";import{setStorageAt as Or}from"viem/actions";function h(e){let t=e.contracts??{};if("quarryPaymaster"in t&&t.quarryPaymaster!=null&&"address"in t.quarryPaymaster)return{type:"quarry",address:t.quarryPaymaster.address};if("paymaster"in t&&t.paymaster!=null&&"address"in t.paymaster)return{type:"simple",address:t.paymaster.address}}async function Be({client:e,userAddress:t}){let r=h(e.chain);return r?.type!=="quarry"?null:(await Mr(e,{address:r.address,table:T.Allowance,key:{user:t},blockTag:"pending"})).allowance}async function Le({client:e,userAddress:t,allowance:r}){let o=h(e.chain);if(o?.type!=="quarry")return;let n=Ir(T.Allowance.tableId,Hr(T.Allowance,{user:t}));await Or(e.extend(()=>({mode:"anvil"})),{address:o.address,index:n,value:Tr(r,{size:32})})}function le({client:e,userAddress:t}){let r=["getAllowance",e?.chain.id,t];return qr(e&&t?{queryKey:r,queryFn:()=>Be({client:e,userAddress:t})}:{queryKey:r,enabled:!1})}function Fe(e){let{chainId:t}=l(),r=zr({chainId:t});return Br(le({client:r,userAddress:e}))}import{useClient as Fi}from"wagmi";import{queryOptions as Fr,useQuery as Ui}from"@tanstack/react-query";import{getRecord as Lr}from"@latticexyz/store/internal";async function Ke({client:e,userAddress:t,sessionAddress:r}){let o=h(e.chain);return o?.type!=="quarry"?null:(await Lr(e,{address:o.address,table:T.Spender,key:{spender:r},blockTag:"pending"})).user.toLowerCase()===t.toLowerCase()}function Ue({client:e,userAddress:t,sessionAddress:r}){let o=["getSpender",e?.chain.id,t,r];return Fr(e&&t&&r?{queryKey:o,queryFn:()=>Ke({client:e,userAddress:t,sessionAddress:r})}:{queryKey:o,enabled:!1})}import{useClient as as}from"wagmi";import{queryOptions as Qr,useQuery as ss}from"@tanstack/react-query";import{getRecord as Gr}from"@latticexyz/store/internal";import{resourceToHex as Kr}from"@latticexyz/common";import{parseAbi as Ur}from"viem";import Dr from"@latticexyz/world/mud.config";var De={pollingInterval:250},L=Kr({type:"system",namespace:"",name:"unlimited"}),Ge=Dr.namespaces.world.tables,Qe=Ur(["function registerDelegation(address delegatee, bytes32 delegationControlId, bytes initCallData)"]);async function Ve({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){return(await Gr(e,{address:t,table:Ge.UserDelegationControl,key:{delegator:r,delegatee:o},blockTag:"pending"})).delegationControlId===L}function We({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){let n=["getDelegation",e?.chain.id,t,r,o];return Qr(e&&r&&o?{queryKey:n,queryFn:()=>Ve({client:e,worldAddress:t,userAddress:r,sessionAddress:o})}:{queryKey:n,enabled:!1})}import{queryOptions as to,useQuery as ro,useQueryClient as oo}from"@tanstack/react-query";import{useClient as no,useConfig as ao}from"wagmi";import{useClient as Zr}from"wagmi";import{queryOptions as Jr,useQuery as eo}from"@tanstack/react-query";import{toSimpleSmartAccount as $r}from"permissionless/accounts";import{isHex as Yr}from"viem";import{createStore as Vr}from"zustand/vanilla";import{persist as Wr}from"zustand/middleware";var F=Vr(Wr(()=>({signers:{}}),{name:"mud:entrykit",partialize:({signers:e})=>({signers:e})}));function _r(e){e.key===F.persist.getOptions().name&&F.persist.rehydrate()}window.addEventListener("storage",_r);import{generatePrivateKey as Xr,privateKeyToAccount as jr}from"viem/accounts";function _e(e){let t=e.toLowerCase(),r=F.getState().signers[t]??(()=>{let o=localStorage.getItem(`mud:appSigner:privateKey:${e.toLowerCase()}`),n=Yr(o)?o:Xr();return F.setState(a=>({signers:{...a.signers,[t]:n}})),n})();return jr(r)}async function Ye({client:e,userAddress:t}){let r=_e(t);return await $r({client:e,owner:r})}function ce({client:e,userAddress:t}){let r=["getSessionAccount",e?.chain.id,t];return Jr(e&&t?{queryKey:r,queryFn:()=>Ye({client:e,userAddress:t}),staleTime:1/0}:{queryKey:r,enabled:!1})}function Xe(e){let{chainId:t}=l(),r=Zr({chainId:t});return eo(ce({userAddress:e,client:r}))}import{getBalanceQueryOptions as io}from"wagmi/query";function so({queryClient:e,config:t,client:r,userAddress:o,worldAddress:n}){let a=["getPrerequisites",r?.chain.id,o];return to(r&&o?{queryKey:a,queryFn:async()=>{let i=h(r.chain),{address:s}=await e.fetchQuery(ce({client:r,userAddress:o})),[d,f,m,c]=await Promise.all([i?null:e.fetchQuery(io(t,{chainId:r.chain.id,address:s})),i?.type==="quarry"?e.fetchQuery(le({client:r,userAddress:o})):null,i?.type==="quarry"?e.fetchQuery(Ue({client:r,userAddress:o,sessionAddress:s})):null,e.fetchQuery(We({client:r,worldAddress:n,userAddress:o,sessionAddress:s}))]),p=f==null||f>=A,g=m??!0,x=d==null||d.value>=A;return{sessionAddress:s,hasAllowance:p,isSpender:g,hasGasBalance:x,hasDelegation:c,complete:p&&g&&c}}}:{queryKey:a,enabled:!1})}function M(e){let t=oo(),{chainId:r,worldAddress:o}=l(),n=ao(),a=no({chainId:r});return ro(so({config:n,queryClient:t,client:a,userAddress:e,worldAddress:o}),t)}import{useDisconnect as po}from"wagmi";import{useQuery as lo}from"@tanstack/react-query";function Y(e){let t=e?.toLowerCase();return lo({enabled:!!t,queryKey:["ens",t],queryFn:async()=>{let r=await fetch(`https://api.ensideas.com/ens/resolve/${t}`).then(o=>o.json());return{address:r.address??void 0,name:r.name??void 0,displayName:r.displayName??void 0,avatar:r.avatar??void 0}}})}import{jsx as de,jsxs as co}from"react/jsx-runtime";function I({hex:e}){return e.length<=10?de("span",{title:e,children:e}):co("span",{title:e,children:[de("span",{className:"after:select-none after:content-['\u2026']",children:e.slice(0,6)}),de("span",{className:"tracking-[-1ch] text-transparent",children:e.slice(6,-4)}),e.slice(-4)]})}import{jsx as K,jsxs as pe}from"react/jsx-runtime";function je({isActive:e,isExpanded:t,userAddress:r}){let{data:o}=Y(r),{disconnect:n,isPending:a}=po(),{closeAccountModal:i}=C();return pe("div",{className:"flex flex-col gap-4",children:[pe("div",{className:"flex justify-between gap-4",children:[pe("div",{children:[K("div",{children:"Account"}),K("div",{className:"font-mono text-white",children:o?.name??K(I,{hex:r})})]}),K(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:a,onClick:()=>{i(),n()},children:"Sign out"})]}),t?K("p",{className:"text-sm",children:"Each of your onchain actions in this app is associated with your account."}):null]})}import{parseEther as fo}from"viem";import{useMutation as go,useQueryClient as ho}from"@tanstack/react-query";import{http as mo}from"viem";function $e(){return({chain:e})=>{if(!e)throw new Error("No chain provided to issuer transport.");let t="quarryPassIssuer"in e.rpcUrls?e.rpcUrls.quarryPassIssuer.http[0]:void 0;if(!t)throw new Error(`No \`quarryPassIssuer\` RPC URL found for chain ${e.id}.`);return mo(t)({chain:e,retryCount:0})}}import Ze from"debug";var me=Ze("mud:entrykit"),uo=Ze("mud:entrykit");me.log=console.debug.bind(console);uo.log=console.error.bind(console);var H=me.extend("quarry");async function Je({chain:e,userAddress:t}){let r=$e()({chain:e});H("Issuing gas pass to",t),await r.request({method:"quarry_issuePass",params:["0x01",t]}),H("Claiming gas allowance for",t),await r.request({method:"quarry_claimAllowance",params:["0x01",t]})}import{useClient as yo}from"wagmi";function et(){let e=ho(),{chain:t}=l(),r=yo({chainId:t.id}),o=["claimGasPass",t.id];return go({mutationKey:o,onError:n=>console.error(n),mutationFn:async n=>{if(t.id===31337){if(!r)throw new Error("No client?");await Le({client:r,userAddress:n,allowance:fo("1")})}else await Je({chain:t,userAddress:n});await Promise.all([e.invalidateQueries({queryKey:["getAllowance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{twMerge as wo}from"tailwind-merge";import{jsx as X,jsxs as bo}from"react/jsx-runtime";function tt({className:e,...t}){return bo("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 263 428",fill:"currentColor",className:wo("w-[0.6em] h-[1em]",e),...t,children:[X("path",{d:"M132 321V428L263 243L132 321Z"}),X("path",{d:"M0 243L132 321V428",fillOpacity:"0.5"}),X("path",{d:"M132 0V296L263 218"}),X("path",{d:"M0 218L132 296V0L0 218Z",fillOpacity:"0.5"})]})}import{formatEther as xo}from"viem";function rt(e){let t=xo(e),r=Math.floor(parseFloat(t)).toString().length;return parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:Math.max(0,6-r)})}import{formatEther as vo}from"viem";import{jsx as Co,jsxs as ko}from"react/jsx-runtime";function j({wei:e}){return ko("span",{className:"inline-flex items-center gap-1",title:vo(e),children:[rt(e)," ",Co(tt,{})]})}import{useEffect as So}from"react";import{jsx as O,jsxs as ue}from"react/jsx-runtime";function ot({isActive:e,isExpanded:t,userAddress:r}){let o=Fe(r),n=et();return So(()=>{let a=setTimeout(()=>{e&&n.status==="idle"&&o.isSuccess&&o.data!=null&&o.data<A&&n.mutate(r)});return()=>clearTimeout(a)},[o.data,o.isSuccess,n,e,r]),ue("div",{className:"flex flex-col gap-4",children:[ue("div",{className:"flex justify-between gap-4",children:[ue("div",{children:[O("div",{children:"Allowance"}),O("div",{className:"font-mono text-white",children:o.data!=null?O(j,{wei:o.data}):O(w,{className:"text-sm"})})]}),O(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:o.status==="pending"||n.status==="pending",onClick:()=>n.mutate(r),children:"Top up"})]}),t?O("p",{className:"text-sm",children:"Your allowance is used to pay for onchain computation."}):null]})}import{encodeFunctionData as at}from"viem";import{useMutation as zo,useQueryClient as qo}from"@tanstack/react-query";import{getAction as ge}from"viem/utils";import{sendUserOperation as Bo,waitForUserOperationReceipt as Lo}from"viem/account-abstraction";import{waitForTransactionReceipt as Fo}from"viem/actions";import{useClient as Ko}from"wagmi";import{resourceToHex as it}from"@latticexyz/common";import Uo from"@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json";import{writeContract as Io}from"viem/actions";import{getAction as Ho}from"viem/utils";import{toHex as Po}from"viem";import{signTypedData as Ao}from"viem/actions";import{callWithSignatureTypes as No}from"@latticexyz/world-module-callwithsignature/internal";import{getRecord as Eo}from"@latticexyz/store/internal";import Ro from"@latticexyz/world-module-callwithsignature/mud.config";import{hexToResource as To}from"@latticexyz/common";import{getAction as Mo}from"viem/utils";async function nt({userClient:e,worldAddress:t,systemId:r,callData:o,nonce:n,client:a}){let i=n??(a?(await Eo(a,{address:t,table:Ro.tables.CallWithSignatureNonces,key:{signer:e.account.address},blockTag:"pending"})).nonce:0n),{namespace:s,name:d}=To(r);return await Mo(e,Ao,"signTypedData")({account:e.account,domain:{verifyingContract:t,salt:Po(e.chain.id,{size:32})},types:No,primaryType:"Call",message:{signer:e.account.address,systemNamespace:s,systemName:d,callData:o,nonce:i}})}import Oo from"@latticexyz/world-module-callwithsignature/out/CallWithSignatureSystem.sol/CallWithSignatureSystem.abi.json";async function fe({sessionClient:e,...t}){let r=await nt(t);return Ho(e,Io,"writeContract")({address:t.worldAddress,abi:Oo,functionName:"callWithSignature",args:[t.userClient.account.address,t.systemId,t.callData,r]})}function st({userClient:e}){let t=qo(),{chainId:r,worldAddress:o}=l(),n=Ko({chainId:r}),a=["setupSession",n?.chain.id,e.account.address];return zo({mutationKey:a,onError:i=>console.error(i),mutationFn:async({sessionClient:i,registerSpender:s,registerDelegation:d})=>{if(!n)throw new Error("Client not ready.");let f=h(n.chain),m=i.account.address;if(console.log("setting up session"),e.account.type==="smart"){let c=[];if(s&&f?.type==="quarry"&&(console.log("registering spender"),c.push({to:f.address,abi:se,functionName:"registerSpender",args:[m]})),d&&(console.log("registering delegation"),c.push({to:o,abi:Qe,functionName:"registerDelegation",args:[m,L,"0x"]})),!c.length)return;console.log("setting up account with",c,e);let p=await ge(e,Bo,"sendUserOperation")({calls:c});console.log("got user op hash",p);let g=await ge(e,Lo,"waitForUserOperationReceipt")({hash:p});console.log("got user op receipt",g),g.success||console.error("not successful?",g)}else{let c=[];if(s&&f?.type==="quarry"){console.log("registering spender");let p=await fe({client:n,userClient:e,sessionClient:i,worldAddress:f.address,systemId:it({type:"system",namespace:"",name:"SpenderSystem"}),callData:at({abi:se,functionName:"registerSpender",args:[m]})});console.log("got spender tx",p),c.push(p)}if(d){console.log("registering delegation");let p=await fe({client:n,userClient:e,sessionClient:i,worldAddress:o,systemId:it({type:"system",namespace:"",name:"Registration"}),callData:at({abi:Uo,functionName:"registerDelegation",args:[m,L,"0x"]})});console.log("got delegation tx",p),c.push(p)}if(!c.length)return;console.log("waiting for",c.length,"receipts");for(let p of c){let g=await ge(n,Fo,"waitForTransactionReceipt")({hash:p});console.log("got tx receipt",g),g.status==="reverted"&&console.error("tx reverted?",g)}}await Promise.all([t.invalidateQueries({queryKey:["getSpender"]}),t.invalidateQueries({queryKey:["getDelegation"]}),t.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{useEffect as gn}from"react";import{useClient as pn}from"wagmi";import{queryOptions as mn,useQuery as un}from"@tanstack/react-query";import{smartAccountActions as cn}from"permissionless";import{callFrom as dn}from"@latticexyz/world/internal";import{createBundlerClient as Do}from"viem/account-abstraction";var Go=new Set([31337,17420,17069,690]);function lt(e){let t=e.chain??e.client?.chain,r=t?h(t):void 0;return Do({...De,paymaster:r?{getPaymasterData:async()=>({paymaster:r.address,paymasterData:"0x"})}:void 0,userOperation:{estimateFeesPerGas:t&&Go.has(t.id)?async()=>({maxFeePerGas:100000n,maxPriorityFeePerGas:0n}):void 0},...e})}import{transactionQueue as tn}from"@latticexyz/common/actions";import{createClient as rn,fallback as on,http as ht,keccak256 as nn,stringToHex as an,webSocket as sn}from"viem";import{privateKeyToAccount as ln}from"viem/accounts";import{createTransport as $o,numberToHex as Zo,parseEther as Jo}from"viem";import{entryPoint07Address as ft}from"viem/account-abstraction";import{formatUserOperationRequest as Qo}from"viem/account-abstraction";async function ct(e){return Qo({callGasLimit:20000000n,preVerificationGas:200000n,verificationGasLimit:2000000n,paymasterVerificationGasLimit:200000n,paymasterPostOpGasLimit:200000n})}import{parseEventLogs as Vo}from"viem";import{formatUserOperation as Wo,toPackedUserOperation as _o,getUserOperationHash as Yo,entryPoint07Address as dt,entryPoint07Abi as pt}from"viem/account-abstraction";import{waitForTransactionReceipt as Xo,writeContract as jo}from"viem/actions";import{getAction as mt}from"viem/utils";async function ut({executor:e,rpcUserOp:t}){let r=Wo(t),o=_o(r),n=Yo({userOperation:r,chainId:e.chain.id,entryPointVersion:"0.7",entryPointAddress:dt}),a=await mt(e,jo,"writeContract")({abi:pt,address:dt,functionName:"handleOps",args:[[o],e.account.address],chain:e.chain,account:e.account}),i=await mt(e,Xo,"waitForTransactionReceipt")({hash:a});return{success:Vo({logs:i.logs,abi:pt,eventName:"UserOperationEvent"})[0].args.success,userOpHash:n,receipt:i}}import{setBalance as en}from"viem/actions";function gt({executor:e}){return()=>{H("using a local user op executor",e.account.address),e.chain.id===31337&&(H("setting executor balance"),en(e.extend(()=>({mode:"anvil"})),{address:e.account.address,value:Jo("100")}));let t=new Map;return $o({key:"userOpExecutor",type:"userOpExecutor",name:"User Operation Executor Transport",request:async({method:o,params:n})=>{if(o==="eth_chainId")return Zo(e.chain.id);if(o==="eth_supportedEntryPoints")return[ft];if(o==="eth_sendUserOperation"){let[a,i]=n;if(i===ft){let s=await ut({executor:e,rpcUserOp:a});return t.set(s.userOpHash,s),s.userOpHash}}if(o==="eth_getUserOperationReceipt"){let[a]=n;return t.get(a)??null}if(o==="eth_estimateUserOperationGas")return await ct(n);throw new Error("Method not implemented.")}})}}function yt(e){let t=e.rpcUrls.bundler?.http[0],r=t?ht(t):e.id===31337?gt({executor:rn({chain:e,transport:on([sn(),ht()]),account:ln(nn(an("local user op executor"))),pollingInterval:10}).extend(tn())}):null;if(!r)throw new Error(`Chain ${e.id} config did not include a bundler RPC URL.`);return r}async function wt({client:e,userAddress:t,sessionAccount:r,worldAddress:o}){let n=yt(e.chain);return lt({transport:n,client:e,account:r}).extend(cn).extend(dn({worldAddress:o,delegatorAddress:t,publicClient:e})).extend(()=>({userAddress:t}))}function fn({sessionAccount:e,client:t,userAddress:r,worldAddress:o}){let n=["getSessionClient",t?.uid,r,e?.address,o];return mn(t&&r&&e?{queryKey:n,queryFn:()=>wt({sessionAccount:e,client:t,userAddress:r,worldAddress:o}),staleTime:1/0}:{queryKey:n,enabled:!1})}function $(e){let{chainId:t,worldAddress:r}=l(),o=pn({chainId:t}),{data:n}=Xe(e);return un(fn({sessionAccount:n,userAddress:e,client:o,worldAddress:r}))}import{jsx as U,jsxs as he}from"react/jsx-runtime";function bt({isActive:e,isExpanded:t,userClient:r,registerSpender:o,registerDelegation:n}){let a=$(r.account.address),i=st({userClient:r}),s=!n&&!n;return gn(()=>{let d=setTimeout(()=>{e&&i.status==="idle"&&a.data&&!s&&i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n})});return()=>clearTimeout(d)},[s,e,n,o,a,i]),he("div",{className:"flex flex-col gap-4",children:[he("div",{className:"flex justify-between gap-4",children:[he("div",{children:[U("div",{children:"Session"}),U("div",{className:"font-mono text-white",children:s?"Enabled":"Set up"})]}),s?U(y,{variant:"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,disabled:!0,children:"Enabled"}):U(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:!a.data||i.status==="pending",onClick:a.data?()=>i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n}):void 0,children:"Enable"})]}),t?U("p",{className:"text-sm",children:"You can perform actions in this app without interruptions for approvals."}):null]})}import{useBalance as vn}from"wagmi";var xt={"1":"ethereum","10":"optimism","56":"bnb","100":"gnosis","111":"bob","137":"polygon","185":"mint","288":"boba","324":"zksync","360":"shape","480":"world-chain","690":"redstone","919":"mode-testnet","1101":"polygon-zkevm","1135":"lisk","1301":"unichain-sepolia","1329":"sei","1625":"gravity","1993":"b3","2911":"hychain","4202":"lisk-sepolia","4321":"echos","5000":"mantle","5112":"ham","7560":"cyber","8333":"B3","8453":"base","9897":"arena-z-testnet","11011":"shape-sepolia","11124":"abstract","13746":"game7-testnet","17000":"holesky","17071":"onchain-points","33139":"apechain","33979":"funki","34443":"mode","42161":"arbitrum","42170":"arbitrum-nova","43114":"avalanche","55244":"superposition","57073":"ink","59144":"linea","60808":"bob","70700":"apex","70701":"boss","70800":"apex-testnet","70805":"cloud","80002":"amoy","81457":"blast","84532":"base-sepolia","167009":"hekla","421614":"arbitrum-sepolia","534352":"scroll","543210":"zero-network","660279":"xai","911867":"odyssey","984122":"forma","1118190":"eclipse-testnet","3397901":"funki-testnet","4457845":"zero-sepolia","7777777":"zora","8253038":"bitcoin","9092725":"bitcoin-testnet4","9286185":"eclipse","11155111":"sepolia","11155420":"op-sepolia","666666666":"degen","792703809":"solana","888888888":"ancient8","999999999":"zora-sepolia","1380012617":"rari","1936682084":"solana-devnet","88153591557":"arbitrum-blueberry"};import{useQueryClient as yn,useMutation as wn}from"@tanstack/react-query";import{setBalance as bn}from"viem/actions";import{useClient as xn}from"wagmi";function vt(){let e=yn(),{chainId:t}=l(),r=xn({chainId:t});return wn({mutationKey:["setBalance",t],onError:o=>console.error(o),mutationFn:async o=>(r&&(await bn({...r,mode:"anvil"},o),await Promise.all([e.invalidateQueries({queryKey:["balance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])),null),retry:0})}import{Fragment as Cn,jsx as b,jsxs as D}from"react/jsx-runtime";function Ct({isActive:e,isExpanded:t,sessionAddress:r}){let{chain:o}=l(),n=vn({chainId:o.id,address:r,query:{refetchInterval:2e3}}),a=vt(),i=xt[o.id];return D("div",{className:"flex flex-col gap-4",children:[D("div",{className:"flex justify-between gap-4",children:[D("div",{children:[b("div",{children:"Gas balance"}),b("div",{className:"font-mono text-white",children:n.data!=null?b(j,{wei:n.data.value}):b(w,{className:"text-sm"})})]}),o.id===31337?b(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending"||a.status==="pending",onClick:()=>a.mutate({address:r,value:A+(n.data?.value??0n)}),children:"Top up"}):i!=null?b("a",{href:`https://relay.link/bridge/${i}?${new URLSearchParams({toAddress:r})}`,target:"_blank",rel:"noopener noreferrer",children:b(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending",children:"Top up"})}):null]}),t?D(Cn,{children:[b("p",{className:"text-sm",children:"Your session's gas balance is used to pay for onchain computation."}),i==null?D("p",{className:"text-sm",children:["Send funds to"," ",b("span",{className:"font-mono text-white",children:b(I,{hex:r})})," ","on ",o.name," to top up your session balance."]}):null]}):null]})}import{jsx as N}from"react/jsx-runtime";function kt({userClient:e,initialUserAddress:t}){let{chain:r}=l(),o=h(r),n=e.account.address,{data:a}=M(n),{closeAccountModal:i}=C(),s=n!==t,d=Pn(a);kn(()=>{a!=null&&(d.current==null&&(d.current=a),a.complete&&(s||!d.current.complete)&&i())},[i,s,a]);let{sessionAddress:f,hasAllowance:m,isSpender:c,hasDelegation:p,hasGasBalance:g}=a??{},x=Sn(()=>{if(!n)return[{id:"wallet",isComplete:!1,content:()=>null}];let u=[{id:"wallet",isComplete:!0,content:v=>N(je,{...v,userAddress:n})}];return o?o.type==="quarry"&&u.push({id:"allowance",isComplete:!!m,content:v=>N(ot,{...v,userAddress:n})}):f!=null&&u.push({id:"gasBalance",isComplete:!!g,content:v=>N(Ct,{...v,sessionAddress:f})}),u.push({id:"session",isComplete:!!c&&!!p,content:v=>N(bt,{...v,userClient:e,registerSpender:!c,registerDelegation:!p})}),u},[m,p,g,c,o,f,n,e]),[be]=An(null),Kt=x.find(u=>u.content!=null&&!u.isComplete),te=x.filter(u=>u.isComplete),re=(be!=null?x.find(u=>u.id===be):null)??Kt??(te.length<x.length?te.at(-1):null),xe=re?x.indexOf(re):-1;return N("div",{className:ye("px-8 flex flex-col divide-y divide-neutral-800","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:x.map((u,v)=>{let oe=u===re,Ut=oe||te.length===x.length,Dt=!u.isComplete&&xe!==-1&&v>xe;return N("div",{className:ye("py-8 flex flex-col justify-center",oe?"flex-grow":null),children:N("div",{className:ye("flex flex-col",Dt?"opacity-30 pointer-events-none":null),children:u.content({isActive:oe,isExpanded:Ut})})},u.id)})})}import{useRef as Rn}from"react";import{jsx as St}from"react/jsx-runtime";function Pt(){let{chainId:e}=l(),t=En({chainId:e}),{address:r}=Nn(),o=Rn(r);return t.status!=="success"?St(qe,{}):St(kt,{userClient:t.data,initialUserAddress:o.current})}import{useState as On}from"react";import{ErrorBoundary as zn}from"react-error-boundary";import{twMerge as Tn}from"tailwind-merge";import{BaseError as Mn,UserRejectedRequestError as In}from"viem";import{jsx as At,jsxs as Hn}from"react/jsx-runtime";function Nt({title:e,error:t}){if(!t||t instanceof Mn&&t.walk(n=>n instanceof In)!=null)return null;let r=e??"Error",o=typeof t=="string"?t:t instanceof Error?String(t):"Something unexpected happened.";return Hn("div",{className:Tn("text-sm border-l-4 border-red-500","bg-red-100 text-red-900","dark:bg-red-900 dark:text-red-50"),children:[At("div",{className:"p-3 font-semibold",children:r}),At("div",{className:"px-3 whitespace-break-spaces break-all max-h-32 overflow-y-scroll",children:o})]})}import{wait as qn}from"@latticexyz/common/utils";import{twMerge as Bn}from"tailwind-merge";import{useIsMounted as Ln}from"usehooks-ts";import{jsx as Z,jsxs as Et}from"react/jsx-runtime";function Rt({children:e}){let t=Ln(),[r,o]=On(1);return Z(zn,{fallbackRender:({error:n,resetErrorBoundary:a})=>Et("div",{className:Bn("flex-grow flex flex-col justify-center p-5 gap-2"),children:[Z(Nt,{error:n instanceof Error?n.stack??n.message:n}),r>0?Et("button",{type:"button",onClick:async i=>{i.currentTarget.ariaBusy="true",await qn(1e3),a(),t()&&(o(s=>s-1),i.currentTarget.ariaBusy=null)},className:"group aria-busy:pointer-events-none self-end flex items-center gap-1",children:[Z(w,{className:"transition opacity-0 group-aria-busy:opacity-100 text-xs text-neutral-500 dark:text-neutral-400"}),Z("span",{className:"text-sm text-neutral-500 dark:text-neutral-400 group-hover:text-black dark:group-hover:text-white",children:"Retry?"})]}):null]}),children:e})}import{DialogClose as Un,DialogTitle as Dn}from"@radix-ui/react-dialog";import{twMerge as Fn}from"tailwind-merge";import{jsx as Kn}from"react/jsx-runtime";function Tt({className:e,children:t,...r}){return Kn("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:Fn("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...r,children:t})}import{jsx as Mt}from"react/jsx-runtime";function It(e){return Mt(Tt,{strokeWidth:"2",stroke:"currentColor",...e,children:Mt("path",{d:"M6 18L18 6M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as k,jsxs as we}from"react/jsx-runtime";function Ot(){let{accountModalOpen:e,toggleAccountModal:t}=C();return we(He,{open:e,onOpenChange:t,children:[k(Dn,{className:"sr-only",children:"Connect with EntryKit"}),e?we("div",{className:Ht("relative py-2 ring-1","bg-neutral-900 text-neutral-400 ring-neutral-700/50 divide-neutral-700","links:font-medium links:underline links:underline-offset-4","links:text-white","links:decoration-neutral-500 hover:links:decoration-orange-500"),children:[k(Rt,{children:k(Pt,{})}),we("a",{href:"https://mud.dev",target:"_blank",rel:"noreferrer noopener",className:"group self-center p-3 flex items-center justify-center gap-2 links-unset text-sm font-mono transition text-neutral-400 hover:text-white",children:[k("span",{className:"block w-4 h-4",children:k(P,{className:"w-full h-full text-orange-500 group-hover:rotate-90 transition duration-300"})}),k("span",{children:"Powered by MUD"})]}),k("div",{className:"absolute top-0 right-0",children:k(Un,{className:Ht("pointer-events-auto leading-none p-2 transition","text-neutral-700 hover:text-neutral-500"),title:"Close",children:k(It,{className:"m-0"})})})]}):null]})}import{jsx as Qn,jsxs as Vn}from"react/jsx-runtime";function Gn({config:e,children:t}){return Vn(Ee,{config:e,children:[t,Qn(Ot,{})]})}import{useAccount as _n}from"wagmi";import{twMerge as E}from"tailwind-merge";import{twMerge as zt}from"tailwind-merge";import{Fragment as Wn,jsx as J,jsxs as qt}from"react/jsx-runtime";function Bt({address:e}){let{data:t}=Y(e),r=V(t?.avatar);return qt(Wn,{children:[qt("span",{className:"flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center",children:[J("img",{src:t?.avatar&&r.isSuccess?t.avatar:void 0,className:zt("col-start-1 row-start-1","inline-flex w-full h-full rounded-full bg-black/10 dark:bg-white/10 bg-cover bg-no-repeat bg-center","transtion duration-300",r.isSuccess?"opacity-100":"opacity-0")}),J(P,{className:zt("col-start-1 row-start-1 text-orange-500","transition duration-300",t&&(!t.avatar||r.isError)?"opacity-100":"opacity-0")})]}),J("span",{className:"flex-grow",children:t?.name??J(I,{hex:e})})]})}import{useRef as Yn}from"react";import{jsx as S,jsxs as Ft}from"react/jsx-runtime";var Lt=E("w-48 p-3 inline-flex outline-none transition","border border-transparent","text-base leading-none"),Xn=E("bg-neutral-100 border-neutral-300 text-black","dark:bg-neutral-800 dark:border-neutral-700 dark:text-white"),jn=E("cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700");function $n(){let{openAccountModal:e,accountModalOpen:t}=C(),{status:r,address:o}=_n(),n=Yn(o),a=M(o),i=r==="connected"||r==="reconnecting"&&o,s=o!==n.current,d=a.isSuccess?a.data.complete:s?!1:i,f=(()=>{if(a.isSuccess){if(!a.data.hasAllowance)return"Top up";if(!a.data.hasDelegation||!a.data.isSpender)return"Set up"}return"Sign in"})();return S(G,{mode:"child",children:d?S("button",{type:"button",className:E(Lt,Xn,jn),onClick:e,children:S("span",{className:"flex-grow inline-flex gap-2.5 items-center text-left font-medium",children:o?S(Bt,{address:o}):null})},"connected"):Ft("button",{type:"button",className:E(Lt,"group","items-center justify-center gap-2.5","bg-orange-500 text-white font-medium","hover:bg-orange-400","active:bg-orange-600"),"aria-busy":t,onClick:e,children:[Ft("span",{className:"pointer-events-none inline-grid place-items-center -ml-3",children:[S("span",{className:E("col-start-1 row-start-1 leading-none","scale-100 opacity-100 transition duration-300","group-aria-busy:scale-125 group-aria-busy:opacity-0"),children:S(P,{})}),S("span",{"aria-hidden":!0,className:E("col-start-1 row-start-1","scale-50 opacity-0 transition duration-300 delay-50","group-aria-busy:scale-100 group-aria-busy:opacity-100"),children:S(w,{})})]}),S("span",{className:"font-medium",children:f})]},"sign in")})}import{useConnectorClient as Zn}from"wagmi";function Jn(){let{chainId:e}=l(),t=Zn({chainId:e});t.error&&console.error("Error retrieving user client",t.error);let r=t.data?.account.address,o=M(r),n=$(r);return t.isSuccess?!o.isSuccess||!o.data.complete?{...o,data:void 0}:n:{...t,data:void 0}}import{connectorsForWallets as ta}from"@rainbow-me/rainbowkit";import{createConfig as ra}from"wagmi";import{getDefaultWallets as ea}from"@rainbow-me/rainbowkit";function ee(e){let{wallets:t}=ea();return[...t]}function oa(e){let t=ee(e),r=ta(t,{appName:e.appName,projectId:e.walletConnectProjectId});return ra({connectors:r,chains:e.chains,transports:e.transports,pollingInterval:e.pollingInterval})}import{connectorsForWallets as na}from"@rainbow-me/rainbowkit";function wm({wallets:e,...t}){return na(e??ee(t),{appName:t.appName,projectId:t.walletConnectProjectId})}export{$n as AccountButton,Gn as EntryKitProvider,oa as createWagmiConfig,Gt as defineConfig,wm as getConnectors,ee as getWallets,C as useAccountModal,l as useEntryKitConfig,Jn as useSessionClient};
|
|
1397
|
+
URL: ${e}`)),o.src=e})})}import{jsx as W,jsxs as wr}from"react/jsx-runtime";function Oe(){let{appName:e,appIcon:t}=l(),{data:r,isLoading:o}=V(t);return wr("div",{className:"flex-grow flex flex-col items-center justify-center gap-2",children:[W("div",{className:"w-16 h-16 m-2",children:o?null:r?W("img",{src:t,className:"w-full h-full object-cover"}):W(A,{className:"w-full h-full text-orange-500 dark:bg-neutral-800"})}),W("div",{className:"text-2xl text-white text-center",children:e})]})}import{twMerge as Cr}from"tailwind-merge";import{useEffect as kr,useState as Sr}from"react";import{jsx as _,jsxs as Ar}from"react/jsx-runtime";function ze(){let e=xr(),{openConnectModal:t,connectModalOpen:r}=vr(),[o,n]=Sr(!1);return kr(()=>{!r&&!o&&(t?.(),n(!0))},[r,o,t]),Ar("div",{className:Cr("flex flex-col gap-6 p-6","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:[_("div",{className:"p-4",children:_(Oe,{})}),_("div",{className:"self-center flex flex-col gap-2 w-60",children:_(y,{variant:"secondary",className:"self-auto flex justify-center",disabled:e.status==="connecting",onClick:t,autoFocus:!0,children:"Connect wallet"},"create")})]})}import{useEffect as kn,useMemo as Sn,useRef as An,useState as Pn}from"react";import{twMerge as ye}from"tailwind-merge";import{parseEther as Pr}from"viem";var P=Pr("0.01");import{useClient as Or}from"wagmi";import{queryOptions as zr,useQuery as qr}from"@tanstack/react-query";import{numberToHex as Er}from"viem";import{defineStore as Ur}from"@latticexyz/store";import{parseAbi as Nr}from"viem";var se=Nr(["error SpenderSystem_AlreadyRegistered(address spender, address user)","error SpenderSystem_HasOwnBalance(address spender)","function registerSpender(address spender)"]),Rr=Ur({namespaces:{root:{namespace:"",tables:{Allowance:{schema:{user:"address",allowance:"uint256"},key:["user"]},Grantor:{schema:{grantor:"address",allowance:"uint256"},key:["grantor"]},PassHolder:{schema:{user:"address",passId:"bytes32",lastRenewed:"uint256",lastClaimed:"uint256"},key:["user","passId"]},PassConfig:{schema:{passId:"bytes32",claimAmount:"uint256",claimInterval:"uint256",validityPeriod:"uint256",grantor:"address"},key:["passId"]},Spender:{schema:{spender:"address",user:"address"},key:["spender"]},SystemConfig:{schema:{entryPoint:"address"},key:[]}}}}}),E=Rr.namespaces.root.tables;import{getRecord as Tr,getStaticDataLocation as Mr}from"@latticexyz/store/internal";import{getKeyTuple as Ir}from"@latticexyz/protocol-parser/internal";import{setStorageAt as Hr}from"viem/actions";function h(e){let t=e.contracts??{};if("quarryPaymaster"in t&&t.quarryPaymaster!=null&&"address"in t.quarryPaymaster)return{type:"quarry",address:t.quarryPaymaster.address};if("paymaster"in t&&t.paymaster!=null&&"address"in t.paymaster)return{type:"simple",address:t.paymaster.address}}async function qe({client:e,userAddress:t}){let r=h(e.chain);return r?.type!=="quarry"?null:(await Tr(e,{address:r.address,table:E.Allowance,key:{user:t},blockTag:"pending"})).allowance}async function Be({client:e,userAddress:t,allowance:r}){let o=h(e.chain);if(o?.type!=="quarry")return;let n=Mr(E.Allowance.tableId,Ir(E.Allowance,{user:t}));await Hr(e.extend(()=>({mode:"anvil"})),{address:o.address,index:n,value:Er(r,{size:32})})}function le({client:e,userAddress:t}){let r=["getAllowance",e?.chain.id,t];return zr(e&&t?{queryKey:r,queryFn:()=>qe({client:e,userAddress:t})}:{queryKey:r,enabled:!1})}function Le(e){let{chainId:t}=l(),r=Or({chainId:t});return qr(le({client:r,userAddress:e}))}import{useClient as Li}from"wagmi";import{queryOptions as Lr,useQuery as Ki}from"@tanstack/react-query";import{getRecord as Br}from"@latticexyz/store/internal";async function Fe({client:e,userAddress:t,sessionAddress:r}){let o=h(e.chain);return o?.type!=="quarry"?null:(await Br(e,{address:o.address,table:E.Spender,key:{spender:r},blockTag:"pending"})).user.toLowerCase()===t.toLowerCase()}function Ke({client:e,userAddress:t,sessionAddress:r}){let o=["getSpender",e?.chain.id,t,r];return Lr(e&&t&&r?{queryKey:o,queryFn:()=>Fe({client:e,userAddress:t,sessionAddress:r})}:{queryKey:o,enabled:!1})}import{useClient as as}from"wagmi";import{queryOptions as Qr,useQuery as ss}from"@tanstack/react-query";import{getRecord as Gr}from"@latticexyz/store/internal";import{resourceToHex as Fr}from"@latticexyz/common";import{parseAbi as Kr}from"viem";import Dr from"@latticexyz/world/mud.config";var De={pollingInterval:250},B=Fr({type:"system",namespace:"",name:"unlimited"}),Ge=Dr.namespaces.world.tables,Qe=Kr(["function registerDelegation(address delegatee, bytes32 delegationControlId, bytes initCallData)"]);async function Ve({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){return(await Gr(e,{address:t,table:Ge.UserDelegationControl,key:{delegator:r,delegatee:o},blockTag:"pending"})).delegationControlId===B}function We({client:e,worldAddress:t,userAddress:r,sessionAddress:o}){let n=["getDelegation",e?.chain.id,t,r,o];return Qr(e&&r&&o?{queryKey:n,queryFn:()=>Ve({client:e,worldAddress:t,userAddress:r,sessionAddress:o})}:{queryKey:n,enabled:!1})}import{queryOptions as to,useQuery as ro,useQueryClient as oo}from"@tanstack/react-query";import{useClient as no,useConfig as ao}from"wagmi";import{useClient as Zr}from"wagmi";import{queryOptions as Jr,useQuery as eo}from"@tanstack/react-query";import{toSimpleSmartAccount as $r}from"permissionless/accounts";import{isHex as Yr}from"viem";import{createStore as Vr}from"zustand/vanilla";import{persist as Wr}from"zustand/middleware";var L=Vr(Wr(()=>({signers:{}}),{name:"mud:entrykit",partialize:({signers:e})=>({signers:e})}));function _r(e){e.key===L.persist.getOptions().name&&L.persist.rehydrate()}window.addEventListener("storage",_r);import{generatePrivateKey as Xr,privateKeyToAccount as jr}from"viem/accounts";function _e(e){let t=e.toLowerCase(),r=L.getState().signers[t]??(()=>{let o=localStorage.getItem(`mud:appSigner:privateKey:${e.toLowerCase()}`),n=Yr(o)?o:Xr();return L.setState(a=>({signers:{...a.signers,[t]:n}})),n})();return jr(r)}async function Ye({client:e,userAddress:t}){let r=_e(t);return await $r({client:e,owner:r})}function de({client:e,userAddress:t}){let r=["getSessionAccount",e?.chain.id,t];return Jr(e&&t?{queryKey:r,queryFn:()=>Ye({client:e,userAddress:t}),staleTime:1/0}:{queryKey:r,enabled:!1})}function Xe(e){let{chainId:t}=l(),r=Zr({chainId:t});return eo(de({userAddress:e,client:r}))}import{getBalanceQueryOptions as io}from"wagmi/query";function so({queryClient:e,config:t,client:r,userAddress:o,worldAddress:n}){let a=["getPrerequisites",r?.chain.id,o];return to(r&&o?{queryKey:a,queryFn:async()=>{let i=h(r.chain),{address:s}=await e.fetchQuery(de({client:r,userAddress:o})),[c,g,m,d]=await Promise.all([i?null:e.fetchQuery(io(t,{chainId:r.chain.id,address:s})),i?.type==="quarry"?e.fetchQuery(le({client:r,userAddress:o})):null,i?.type==="quarry"?e.fetchQuery(Ke({client:r,userAddress:o,sessionAddress:s})):null,e.fetchQuery(We({client:r,worldAddress:n,userAddress:o,sessionAddress:s}))]),p=g==null||g>=P,f=m??!0,x=c==null||c.value>=P;return{sessionAddress:s,hasAllowance:p,isSpender:f,hasGasBalance:x,hasDelegation:d,complete:p&&f&&d}}}:{queryKey:a,enabled:!1})}function T(e){let t=oo(),{chainId:r,worldAddress:o}=l(),n=ao(),a=no({chainId:r});return ro(so({config:n,queryClient:t,client:a,userAddress:e,worldAddress:o}),t)}import{useDisconnect as po}from"wagmi";import{useQuery as lo}from"@tanstack/react-query";function Y(e){let t=e?.toLowerCase();return lo({enabled:!!t,queryKey:["ens",t],queryFn:async()=>{let r=await fetch(`https://api.ensideas.com/ens/resolve/${t}`).then(o=>o.json());return{address:r.address??void 0,name:r.name??void 0,displayName:r.displayName??void 0,avatar:r.avatar??void 0}}})}import{jsx as ce,jsxs as co}from"react/jsx-runtime";function M({hex:e}){return e.length<=10?ce("span",{title:e,children:e}):co("span",{title:e,children:[ce("span",{className:"after:select-none after:content-['\u2026']",children:e.slice(0,6)}),ce("span",{className:"tracking-[-1ch] text-transparent",children:e.slice(6,-4)}),e.slice(-4)]})}import{jsx as F,jsxs as pe}from"react/jsx-runtime";function je({isActive:e,isExpanded:t,userAddress:r}){let{data:o}=Y(r),{disconnect:n,isPending:a}=po(),{closeAccountModal:i}=C();return pe("div",{className:"flex flex-col gap-4",children:[pe("div",{className:"flex justify-between gap-4",children:[pe("div",{children:[F("div",{children:"Account"}),F("div",{className:"font-mono text-white",children:o?.name??F(M,{hex:r})})]}),F(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:a,onClick:()=>{i(),n()},children:"Sign out"})]}),t?F("p",{className:"text-sm",children:"Each of your onchain actions in this app is associated with your account."}):null]})}import{parseEther as go}from"viem";import{useMutation as fo,useQueryClient as ho}from"@tanstack/react-query";import{http as mo}from"viem";function $e(){return({chain:e})=>{if(!e)throw new Error("No chain provided to issuer transport.");let t="quarryPassIssuer"in e.rpcUrls?e.rpcUrls.quarryPassIssuer.http[0]:void 0;if(!t)throw new Error(`No \`quarryPassIssuer\` RPC URL found for chain ${e.id}.`);return mo(t)({chain:e,retryCount:0})}}import Ze from"debug";var me=Ze("mud:entrykit"),uo=Ze("mud:entrykit");me.log=console.debug.bind(console);uo.log=console.error.bind(console);var I=me.extend("quarry");async function Je({chain:e,userAddress:t}){let r=$e()({chain:e});I("Issuing gas pass to",t),await r.request({method:"quarry_issuePass",params:["0x01",t]}),I("Claiming gas allowance for",t),await r.request({method:"quarry_claimAllowance",params:["0x01",t]})}import{useClient as yo}from"wagmi";function et(){let e=ho(),{chain:t}=l(),r=yo({chainId:t.id}),o=["claimGasPass",t.id];return fo({mutationKey:o,onError:n=>console.error(n),mutationFn:async n=>{if(t.id===31337){if(!r)throw new Error("No client?");await Be({client:r,userAddress:n,allowance:go("1")})}else await Je({chain:t,userAddress:n});await Promise.all([e.invalidateQueries({queryKey:["getAllowance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{twMerge as bo}from"tailwind-merge";import{jsx as X,jsxs as wo}from"react/jsx-runtime";function tt({className:e,...t}){return wo("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 263 428",fill:"currentColor",className:bo("w-[0.6em] h-[1em]",e),...t,children:[X("path",{d:"M132 321V428L263 243L132 321Z"}),X("path",{d:"M0 243L132 321V428",fillOpacity:"0.5"}),X("path",{d:"M132 0V296L263 218"}),X("path",{d:"M0 218L132 296V0L0 218Z",fillOpacity:"0.5"})]})}import{formatEther as xo}from"viem";function rt(e){let t=xo(e),r=Math.floor(parseFloat(t)).toString().length;return parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:Math.max(0,6-r)})}import{formatEther as vo}from"viem";import{jsx as Co,jsxs as ko}from"react/jsx-runtime";function j({wei:e}){return ko("span",{className:"inline-flex items-center gap-1",title:vo(e),children:[rt(e)," ",Co(tt,{})]})}import{useEffect as So}from"react";import{jsx as H,jsxs as ue}from"react/jsx-runtime";function ot({isActive:e,isExpanded:t,userAddress:r}){let o=Le(r),n=et();return So(()=>{let a=setTimeout(()=>{e&&n.status==="idle"&&o.isSuccess&&o.data!=null&&o.data<P&&n.mutate(r)});return()=>clearTimeout(a)},[o.data,o.isSuccess,n,e,r]),ue("div",{className:"flex flex-col gap-4",children:[ue("div",{className:"flex justify-between gap-4",children:[ue("div",{children:[H("div",{children:"Allowance"}),H("div",{className:"font-mono text-white",children:o.data!=null?H(j,{wei:o.data}):H(b,{className:"text-sm"})})]}),H(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:o.status==="pending"||n.status==="pending",onClick:()=>n.mutate(r),children:"Top up"})]}),t?H("p",{className:"text-sm",children:"Your allowance is used to pay for onchain computation."}):null]})}import{encodeFunctionData as at}from"viem";import{useMutation as Oo,useQueryClient as zo}from"@tanstack/react-query";import{getAction as fe}from"viem/utils";import{sendUserOperation as qo,waitForUserOperationReceipt as Bo}from"viem/account-abstraction";import{waitForTransactionReceipt as Lo}from"viem/actions";import{useClient as Fo}from"wagmi";import{resourceToHex as it}from"@latticexyz/common";import Ko from"@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json";import{writeContract as Mo}from"viem/actions";import{getAction as Io}from"viem/utils";import{toHex as Ao}from"viem";import{signTypedData as Po}from"viem/actions";import{callWithSignatureTypes as Uo}from"@latticexyz/world-module-callwithsignature/internal";import{getRecord as No}from"@latticexyz/store/internal";import Ro from"@latticexyz/world-module-callwithsignature/mud.config";import{hexToResource as Eo}from"@latticexyz/common";import{getAction as To}from"viem/utils";async function nt({userClient:e,worldAddress:t,systemId:r,callData:o,nonce:n,client:a}){let i=n??(a?(await No(a,{address:t,table:Ro.tables.CallWithSignatureNonces,key:{signer:e.account.address},blockTag:"pending"})).nonce:0n),{namespace:s,name:c}=Eo(r);return await To(e,Po,"signTypedData")({account:e.account,domain:{verifyingContract:t,salt:Ao(e.chain.id,{size:32})},types:Uo,primaryType:"Call",message:{signer:e.account.address,systemNamespace:s,systemName:c,callData:o,nonce:i}})}import Ho from"@latticexyz/world-module-callwithsignature/out/CallWithSignatureSystem.sol/CallWithSignatureSystem.abi.json";async function ge({sessionClient:e,...t}){let r=await nt(t);return Io(e,Mo,"writeContract")({address:t.worldAddress,abi:Ho,functionName:"callWithSignature",args:[t.userClient.account.address,t.systemId,t.callData,r]})}function st({userClient:e}){let t=zo(),{chainId:r,worldAddress:o}=l(),n=Fo({chainId:r}),a=["setupSession",n?.chain.id,e.account.address];return Oo({mutationKey:a,onError:i=>console.error(i),mutationFn:async({sessionClient:i,registerSpender:s,registerDelegation:c})=>{if(!n)throw new Error("Client not ready.");let g=h(n.chain),m=i.account.address;if(console.log("setting up session"),e.account.type==="smart"){let d=[];if(s&&g?.type==="quarry"&&(console.log("registering spender"),d.push({to:g.address,abi:se,functionName:"registerSpender",args:[m]})),c&&(console.log("registering delegation"),d.push({to:o,abi:Qe,functionName:"registerDelegation",args:[m,B,"0x"]})),!d.length)return;console.log("setting up account with",d,e);let p=await fe(e,qo,"sendUserOperation")({calls:d});console.log("got user op hash",p);let f=await fe(e,Bo,"waitForUserOperationReceipt")({hash:p});console.log("got user op receipt",f),f.success||console.error("not successful?",f)}else{let d=[];if(s&&g?.type==="quarry"){console.log("registering spender");let p=await ge({client:n,userClient:e,sessionClient:i,worldAddress:g.address,systemId:it({type:"system",namespace:"",name:"SpenderSystem"}),callData:at({abi:se,functionName:"registerSpender",args:[m]})});console.log("got spender tx",p),d.push(p)}if(c){console.log("registering delegation");let p=await ge({client:n,userClient:e,sessionClient:i,worldAddress:o,systemId:it({type:"system",namespace:"",name:"Registration"}),callData:at({abi:Ko,functionName:"registerDelegation",args:[m,B,"0x"]})});console.log("got delegation tx",p),d.push(p)}if(!d.length)return;console.log("waiting for",d.length,"receipts");for(let p of d){let f=await fe(n,Lo,"waitForTransactionReceipt")({hash:p});console.log("got tx receipt",f),f.status==="reverted"&&console.error("tx reverted?",f)}}await Promise.all([t.invalidateQueries({queryKey:["getSpender"]}),t.invalidateQueries({queryKey:["getDelegation"]}),t.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{useEffect as fn}from"react";import{useClient as pn}from"wagmi";import{queryOptions as mn,useQuery as un}from"@tanstack/react-query";import{smartAccountActions as dn}from"permissionless";import{callFrom as cn}from"@latticexyz/world/internal";import{createBundlerClient as Do}from"viem/account-abstraction";var Go=new Set([31337,17420,17069,690]);function lt(e){let t=e.chain??e.client?.chain,r=t?h(t):void 0;return Do({...De,paymaster:r?{getPaymasterData:async()=>({paymaster:r.address,paymasterData:"0x"})}:void 0,userOperation:{estimateFeesPerGas:t&&Go.has(t.id)?async()=>({maxFeePerGas:100000n,maxPriorityFeePerGas:0n}):void 0},...e})}import{transactionQueue as tn}from"@latticexyz/common/actions";import{createClient as rn,fallback as on,http as ht,keccak256 as nn,stringToHex as an,webSocket as sn}from"viem";import{privateKeyToAccount as ln}from"viem/accounts";import{createTransport as $o,numberToHex as Zo,parseEther as Jo}from"viem";import{entryPoint07Address as gt}from"viem/account-abstraction";import{formatUserOperationRequest as Qo}from"viem/account-abstraction";async function dt(e){return Qo({callGasLimit:20000000n,preVerificationGas:200000n,verificationGasLimit:2000000n,paymasterVerificationGasLimit:200000n,paymasterPostOpGasLimit:200000n})}import{parseEventLogs as Vo}from"viem";import{formatUserOperation as Wo,toPackedUserOperation as _o,getUserOperationHash as Yo,entryPoint07Address as ct,entryPoint07Abi as pt}from"viem/account-abstraction";import{waitForTransactionReceipt as Xo,writeContract as jo}from"viem/actions";import{getAction as mt}from"viem/utils";async function ut({executor:e,rpcUserOp:t}){let r=Wo(t),o=_o(r),n=Yo({userOperation:r,chainId:e.chain.id,entryPointVersion:"0.7",entryPointAddress:ct}),a=await mt(e,jo,"writeContract")({abi:pt,address:ct,functionName:"handleOps",args:[[o],e.account.address],chain:e.chain,account:e.account}),i=await mt(e,Xo,"waitForTransactionReceipt")({hash:a});return{success:Vo({logs:i.logs,abi:pt,eventName:"UserOperationEvent"})[0].args.success,userOpHash:n,receipt:i}}import{setBalance as en}from"viem/actions";function ft({executor:e}){return()=>{I("using a local user op executor",e.account.address),e.chain.id===31337&&(I("setting executor balance"),en(e.extend(()=>({mode:"anvil"})),{address:e.account.address,value:Jo("100")}));let t=new Map;return $o({key:"userOpExecutor",type:"userOpExecutor",name:"User Operation Executor Transport",request:async({method:o,params:n})=>{if(o==="eth_chainId")return Zo(e.chain.id);if(o==="eth_supportedEntryPoints")return[gt];if(o==="eth_sendUserOperation"){let[a,i]=n;if(i===gt){let s=await ut({executor:e,rpcUserOp:a});return t.set(s.userOpHash,s),s.userOpHash}}if(o==="eth_getUserOperationReceipt"){let[a]=n;return t.get(a)??null}if(o==="eth_estimateUserOperationGas")return await dt(n);throw new Error("Method not implemented.")}})}}function yt(e){let t=e.rpcUrls.bundler?.http[0],r=t?ht(t):e.id===31337?ft({executor:rn({chain:e,transport:on([sn(),ht()]),account:ln(nn(an("local user op executor"))),pollingInterval:10}).extend(tn())}):null;if(!r)throw new Error(`Chain ${e.id} config did not include a bundler RPC URL.`);return r}async function bt({client:e,userAddress:t,sessionAccount:r,worldAddress:o}){let n=yt(e.chain);return lt({transport:n,client:e,account:r}).extend(dn).extend(cn({worldAddress:o,delegatorAddress:t,publicClient:e})).extend(()=>({userAddress:t}))}function gn({sessionAccount:e,client:t,userAddress:r,worldAddress:o}){let n=["getSessionClient",t?.uid,r,e?.address,o];return mn(t&&r&&e?{queryKey:n,queryFn:()=>bt({sessionAccount:e,client:t,userAddress:r,worldAddress:o}),staleTime:1/0}:{queryKey:n,enabled:!1})}function $(e){let{chainId:t,worldAddress:r}=l(),o=pn({chainId:t}),{data:n}=Xe(e);return un(gn({sessionAccount:n,userAddress:e,client:o,worldAddress:r}))}import{jsx as K,jsxs as he}from"react/jsx-runtime";function wt({isActive:e,isExpanded:t,userClient:r,registerSpender:o,registerDelegation:n}){let a=$(r.account.address),i=st({userClient:r}),s=!n&&!n;return fn(()=>{let c=setTimeout(()=>{e&&i.status==="idle"&&a.data&&!s&&i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n})});return()=>clearTimeout(c)},[s,e,n,o,a,i]),he("div",{className:"flex flex-col gap-4",children:[he("div",{className:"flex justify-between gap-4",children:[he("div",{children:[K("div",{children:"Session"}),K("div",{className:"font-mono text-white",children:s?"Enabled":"Set up"})]}),s?K(y,{variant:"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,disabled:!0,children:"Enabled"}):K(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e,pending:!a.data||i.status==="pending",onClick:a.data?()=>i.mutate({sessionClient:a.data,registerSpender:o,registerDelegation:n}):void 0,children:"Enable"})]}),t?K("p",{className:"text-sm",children:"You can perform actions in this app without interruptions for approvals."}):null]})}import{useBalance as vn}from"wagmi";var xt={"1":{bridgeUrl:"https://relay.link/bridge/ethereum"},"10":{bridgeUrl:"https://relay.link/bridge/optimism"},"56":{bridgeUrl:"https://relay.link/bridge/bnb"},"100":{bridgeUrl:"https://relay.link/bridge/gnosis"},"111":{bridgeUrl:"https://testnets.relay.link/bridge/bob"},"137":{bridgeUrl:"https://relay.link/bridge/polygon"},"185":{bridgeUrl:"https://relay.link/bridge/mint"},"288":{bridgeUrl:"https://relay.link/bridge/boba"},"324":{bridgeUrl:"https://relay.link/bridge/zksync"},"360":{bridgeUrl:"https://relay.link/bridge/shape"},"480":{bridgeUrl:"https://relay.link/bridge/world-chain"},"690":{bridgeUrl:"https://relay.link/bridge/redstone"},"919":{bridgeUrl:"https://testnets.relay.link/bridge/mode-testnet"},"1101":{bridgeUrl:"https://relay.link/bridge/polygon-zkevm"},"1135":{bridgeUrl:"https://relay.link/bridge/lisk"},"1301":{bridgeUrl:"https://testnets.relay.link/bridge/unichain-sepolia"},"1329":{bridgeUrl:"https://relay.link/bridge/sei"},"1625":{bridgeUrl:"https://relay.link/bridge/gravity"},"1868":{bridgeUrl:"https://relay.link/bridge/soneium"},"1993":{bridgeUrl:"https://testnets.relay.link/bridge/b3"},"1996":{bridgeUrl:"https://relay.link/bridge/sanko"},"2741":{bridgeUrl:"https://relay.link/bridge/abstract"},"2911":{bridgeUrl:"https://relay.link/bridge/hychain"},"4202":{bridgeUrl:"https://testnets.relay.link/bridge/lisk-sepolia"},"4321":{bridgeUrl:"https://relay.link/bridge/echos"},"5000":{bridgeUrl:"https://relay.link/bridge/mantle"},"5112":{bridgeUrl:"https://relay.link/bridge/ham"},"7560":{bridgeUrl:"https://relay.link/bridge/cyber"},"7865":{bridgeUrl:"https://relay.link/bridge/powerloom"},"7897":{bridgeUrl:"https://relay.link/bridge/arena-z"},"8333":{bridgeUrl:"https://relay.link/bridge/B3"},"8453":{bridgeUrl:"https://relay.link/bridge/base"},"9897":{bridgeUrl:"https://testnets.relay.link/bridge/arena-z-testnet"},"11011":{bridgeUrl:"https://testnets.relay.link/bridge/shape-sepolia"},"11124":{bridgeUrl:"https://testnets.relay.link/bridge/abstract"},"13746":{bridgeUrl:"https://testnets.relay.link/bridge/game7-testnet"},"17000":{bridgeUrl:"https://testnets.relay.link/bridge/holesky"},"17069":{bridgeUrl:"https://testnets.relay.link/bridge/garnet"},"17071":{bridgeUrl:"https://relay.link/bridge/onchain-points"},"33139":{bridgeUrl:"https://relay.link/bridge/apechain"},"33979":{bridgeUrl:"https://relay.link/bridge/funki"},"34443":{bridgeUrl:"https://relay.link/bridge/mode"},"42161":{bridgeUrl:"https://relay.link/bridge/arbitrum"},"42170":{bridgeUrl:"https://relay.link/bridge/arbitrum-nova"},"43114":{bridgeUrl:"https://relay.link/bridge/avalanche"},"55244":{bridgeUrl:"https://relay.link/bridge/superposition"},"57073":{bridgeUrl:"https://relay.link/bridge/ink"},"59144":{bridgeUrl:"https://relay.link/bridge/linea"},"60808":{bridgeUrl:"https://relay.link/bridge/bob"},"70700":{bridgeUrl:"https://relay.link/bridge/apex"},"70701":{bridgeUrl:"https://relay.link/bridge/boss"},"70800":{bridgeUrl:"https://testnets.relay.link/bridge/apex-testnet"},"70805":{bridgeUrl:"https://testnets.relay.link/bridge/cloud"},"80002":{bridgeUrl:"https://testnets.relay.link/bridge/amoy"},"81457":{bridgeUrl:"https://relay.link/bridge/blast"},"84532":{bridgeUrl:"https://testnets.relay.link/bridge/base-sepolia"},"167009":{bridgeUrl:"https://testnets.relay.link/bridge/hekla"},"421614":{bridgeUrl:"https://testnets.relay.link/bridge/arbitrum-sepolia"},"534352":{bridgeUrl:"https://relay.link/bridge/scroll"},"543210":{bridgeUrl:"https://relay.link/bridge/zero-network"},"660279":{bridgeUrl:"https://relay.link/bridge/xai"},"911867":{bridgeUrl:"https://testnets.relay.link/bridge/odyssey"},"984122":{bridgeUrl:"https://relay.link/bridge/forma"},"1118190":{bridgeUrl:"https://testnets.relay.link/bridge/eclipse-testnet"},"3397901":{bridgeUrl:"https://testnets.relay.link/bridge/funki-testnet"},"4457845":{bridgeUrl:"https://testnets.relay.link/bridge/zero-sepolia"},"7777777":{bridgeUrl:"https://relay.link/bridge/zora"},"8253038":{bridgeUrl:"https://relay.link/bridge/bitcoin"},"9092725":{bridgeUrl:"https://testnets.relay.link/bridge/bitcoin-testnet4"},"9286185":{bridgeUrl:"https://relay.link/bridge/eclipse"},"11155111":{bridgeUrl:"https://testnets.relay.link/bridge/sepolia"},"11155420":{bridgeUrl:"https://testnets.relay.link/bridge/op-sepolia"},"666666666":{bridgeUrl:"https://relay.link/bridge/degen"},"792703809":{bridgeUrl:"https://relay.link/bridge/solana"},"888888888":{bridgeUrl:"https://relay.link/bridge/ancient8"},"999999999":{bridgeUrl:"https://testnets.relay.link/bridge/zora-sepolia"},"1380012617":{bridgeUrl:"https://relay.link/bridge/rari"},"1936682084":{bridgeUrl:"https://testnets.relay.link/bridge/solana-devnet"},"88153591557":{bridgeUrl:"https://testnets.relay.link/bridge/arbitrum-blueberry"}};import{useQueryClient as yn,useMutation as bn}from"@tanstack/react-query";import{setBalance as wn}from"viem/actions";import{useClient as xn}from"wagmi";function vt(){let e=yn(),{chainId:t}=l(),r=xn({chainId:t});return bn({mutationKey:["setBalance",t],onError:o=>console.error(o),mutationFn:async o=>(r&&(await wn({...r,mode:"anvil"},o),await Promise.all([e.invalidateQueries({queryKey:["balance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])),null),retry:0})}import{Fragment as Cn,jsx as w,jsxs as D}from"react/jsx-runtime";function Ct({isActive:e,isExpanded:t,sessionAddress:r}){let{chain:o}=l(),n=vn({chainId:o.id,address:r,query:{refetchInterval:2e3}}),a=vt(),i=xt[o.id];return D("div",{className:"flex flex-col gap-4",children:[D("div",{className:"flex justify-between gap-4",children:[D("div",{children:[w("div",{children:"Gas balance"}),w("div",{className:"font-mono text-white",children:n.data!=null?w(j,{wei:n.data.value}):w(b,{className:"text-sm"})})]}),o.id===31337?w(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending"||a.status==="pending",onClick:()=>a.mutate({address:r,value:P+(n.data?.value??0n)}),children:"Top up"}):i!=null?w("a",{href:`${i.bridgeUrl}?${new URLSearchParams({toAddress:r})}`,target:"_blank",rel:"noopener noreferrer",children:w(y,{variant:e?"primary":"tertiary",className:"flex-shrink-0 text-sm p-1 w-28",autoFocus:e||t,pending:n.status==="pending",children:"Top up"})}):null]}),t?D(Cn,{children:[w("p",{className:"text-sm",children:"Your session's gas balance is used to pay for onchain computation."}),D("p",{className:"text-sm",children:["Send funds to"," ",w("span",{className:"font-mono text-white",children:w(M,{hex:r})})," ","on ",o.name," to top up your session balance."]})]}):null]})}import{jsx as U}from"react/jsx-runtime";function kt({userClient:e,initialUserAddress:t}){let{chain:r}=l(),o=h(r),n=e.account.address,{data:a}=T(n),{closeAccountModal:i}=C(),s=n!==t,c=An(a);kn(()=>{a!=null&&(c.current==null&&(c.current=a),a.complete&&(s||!c.current.complete)&&i())},[i,s,a]);let{sessionAddress:g,hasAllowance:m,isSpender:d,hasDelegation:p,hasGasBalance:f}=a??{},x=Sn(()=>{if(!n)return[{id:"wallet",isComplete:!1,content:()=>null}];let u=[{id:"wallet",isComplete:!0,content:v=>U(je,{...v,userAddress:n})}];return o?o.type==="quarry"&&u.push({id:"allowance",isComplete:!!m,content:v=>U(ot,{...v,userAddress:n})}):g!=null&&u.push({id:"gasBalance",isComplete:!!f,content:v=>U(Ct,{...v,sessionAddress:g})}),u.push({id:"session",isComplete:!!d&&!!p,content:v=>U(wt,{...v,userClient:e,registerSpender:!d,registerDelegation:!p})}),u},[m,p,f,d,o,g,n,e]),[we]=Pn(null),Ft=x.find(u=>u.content!=null&&!u.isComplete),te=x.filter(u=>u.isComplete),re=(we!=null?x.find(u=>u.id===we):null)??Ft??(te.length<x.length?te.at(-1):null),xe=re?x.indexOf(re):-1;return U("div",{className:ye("px-8 flex flex-col divide-y divide-neutral-800","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:x.map((u,v)=>{let oe=u===re,Kt=oe||te.length===x.length,Dt=!u.isComplete&&xe!==-1&&v>xe;return U("div",{className:ye("py-8 flex flex-col justify-center",oe?"flex-grow":null),children:U("div",{className:ye("flex flex-col",Dt?"opacity-30 pointer-events-none":null),children:u.content({isActive:oe,isExpanded:Kt})})},u.id)})})}import{useRef as Rn}from"react";import{jsx as St}from"react/jsx-runtime";function At(){let{chainId:e}=l(),t=Nn({chainId:e}),{address:r}=Un(),o=Rn(r);return t.status!=="success"?St(ze,{}):St(kt,{userClient:t.data,initialUserAddress:o.current})}import{useState as Hn}from"react";import{ErrorBoundary as On}from"react-error-boundary";import{twMerge as En}from"tailwind-merge";import{BaseError as Tn,UserRejectedRequestError as Mn}from"viem";import{jsx as Pt,jsxs as In}from"react/jsx-runtime";function Ut({title:e,error:t}){if(!t||t instanceof Tn&&t.walk(n=>n instanceof Mn)!=null)return null;let r=e??"Error",o=typeof t=="string"?t:t instanceof Error?String(t):"Something unexpected happened.";return In("div",{className:En("text-sm border-l-4 border-red-500","bg-red-100 text-red-900","dark:bg-red-900 dark:text-red-50"),children:[Pt("div",{className:"p-3 font-semibold",children:r}),Pt("div",{className:"px-3 whitespace-break-spaces break-all max-h-32 overflow-y-scroll",children:o})]})}import{wait as zn}from"@latticexyz/common/utils";import{twMerge as qn}from"tailwind-merge";import{useIsMounted as Bn}from"usehooks-ts";import{jsx as Z,jsxs as Nt}from"react/jsx-runtime";function Rt({children:e}){let t=Bn(),[r,o]=Hn(1);return Z(On,{fallbackRender:({error:n,resetErrorBoundary:a})=>Nt("div",{className:qn("flex-grow flex flex-col justify-center p-5 gap-2"),children:[Z(Ut,{error:n instanceof Error?n.stack??n.message:n}),r>0?Nt("button",{type:"button",onClick:async i=>{i.currentTarget.ariaBusy="true",await zn(1e3),a(),t()&&(o(s=>s-1),i.currentTarget.ariaBusy=null)},className:"group aria-busy:pointer-events-none self-end flex items-center gap-1",children:[Z(b,{className:"transition opacity-0 group-aria-busy:opacity-100 text-xs text-neutral-500 dark:text-neutral-400"}),Z("span",{className:"text-sm text-neutral-500 dark:text-neutral-400 group-hover:text-black dark:group-hover:text-white",children:"Retry?"})]}):null]}),children:e})}import{DialogClose as Kn,DialogTitle as Dn}from"@radix-ui/react-dialog";import{twMerge as Ln}from"tailwind-merge";import{jsx as Fn}from"react/jsx-runtime";function Et({className:e,children:t,...r}){return Fn("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:Ln("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...r,children:t})}import{jsx as Tt}from"react/jsx-runtime";function Mt(e){return Tt(Et,{strokeWidth:"2",stroke:"currentColor",...e,children:Tt("path",{d:"M6 18L18 6M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as k,jsxs as be}from"react/jsx-runtime";function Ht(){let{accountModalOpen:e,toggleAccountModal:t}=C();return be(Ie,{open:e,onOpenChange:t,children:[k(Dn,{className:"sr-only",children:"Connect with EntryKit"}),e?be("div",{className:It("relative py-2 ring-1","bg-neutral-900 text-neutral-400 ring-neutral-700/50 divide-neutral-700","links:font-medium links:underline links:underline-offset-4","links:text-white","links:decoration-neutral-500 hover:links:decoration-orange-500"),children:[k(Rt,{children:k(At,{})}),be("a",{href:"https://mud.dev",target:"_blank",rel:"noreferrer noopener",className:"group self-center p-3 flex items-center justify-center gap-2 links-unset text-sm font-mono transition text-neutral-400 hover:text-white",children:[k("span",{className:"block w-4 h-4",children:k(A,{className:"w-full h-full text-orange-500 group-hover:rotate-90 transition duration-300"})}),k("span",{children:"Powered by MUD"})]}),k("div",{className:"absolute top-0 right-0",children:k(Kn,{className:It("pointer-events-auto leading-none p-2 transition","text-neutral-700 hover:text-neutral-500"),title:"Close",children:k(Mt,{className:"m-0"})})})]}):null]})}import{jsx as Qn,jsxs as Vn}from"react/jsx-runtime";function Gn({config:e,children:t}){return Vn(Ne,{config:e,children:[t,Qn(Ht,{})]})}import{useAccount as _n}from"wagmi";import{twMerge as N}from"tailwind-merge";import{twMerge as Ot}from"tailwind-merge";import{Fragment as Wn,jsx as J,jsxs as zt}from"react/jsx-runtime";function qt({address:e}){let{data:t}=Y(e),r=V(t?.avatar);return zt(Wn,{children:[zt("span",{className:"flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center",children:[J("img",{src:t?.avatar&&r.isSuccess?t.avatar:void 0,className:Ot("col-start-1 row-start-1","inline-flex w-full h-full rounded-full bg-black/10 dark:bg-white/10 bg-cover bg-no-repeat bg-center","transtion duration-300",r.isSuccess?"opacity-100":"opacity-0")}),J(A,{className:Ot("col-start-1 row-start-1 text-orange-500","transition duration-300",t&&(!t.avatar||r.isError)?"opacity-100":"opacity-0")})]}),J("span",{className:"flex-grow",children:t?.name??J(M,{hex:e})})]})}import{useRef as Yn}from"react";import{jsx as S,jsxs as Lt}from"react/jsx-runtime";var Bt=N("w-48 p-3 inline-flex outline-none transition","border border-transparent","text-base leading-none"),Xn=N("bg-neutral-100 border-neutral-300 text-black","dark:bg-neutral-800 dark:border-neutral-700 dark:text-white"),jn=N("cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700");function $n(){let{openAccountModal:e,accountModalOpen:t}=C(),{status:r,address:o}=_n(),n=Yn(o),a=T(o),i=r==="connected"||r==="reconnecting"&&o,s=o!==n.current,c=a.isSuccess?a.data.complete:s?!1:i,g=(()=>{if(a.isSuccess){if(!a.data.hasAllowance)return"Top up";if(!a.data.hasDelegation||!a.data.isSpender)return"Set up"}return"Sign in"})();return S(G,{mode:"child",children:c?S("button",{type:"button",className:N(Bt,Xn,jn),onClick:e,children:S("span",{className:"flex-grow inline-flex gap-2.5 items-center text-left font-medium",children:o?S(qt,{address:o}):null})},"connected"):Lt("button",{type:"button",className:N(Bt,"group","items-center justify-center gap-2.5","bg-orange-500 text-white font-medium","hover:bg-orange-400","active:bg-orange-600"),"aria-busy":t,onClick:e,children:[Lt("span",{className:"pointer-events-none inline-grid place-items-center -ml-3",children:[S("span",{className:N("col-start-1 row-start-1 leading-none","scale-100 opacity-100 transition duration-300","group-aria-busy:scale-125 group-aria-busy:opacity-0"),children:S(A,{})}),S("span",{"aria-hidden":!0,className:N("col-start-1 row-start-1","scale-50 opacity-0 transition duration-300 delay-50","group-aria-busy:scale-100 group-aria-busy:opacity-100"),children:S(b,{})})]}),S("span",{className:"font-medium",children:g})]},"sign in")})}import{useConnectorClient as Zn}from"wagmi";function Jn(){let{chainId:e}=l(),t=Zn({chainId:e});t.error&&console.error("Error retrieving user client",t.error);let r=t.data?.account.address,o=T(r),n=$(r);return t.isSuccess?!o.isSuccess||!o.data.complete?{...o,data:void 0}:n:{...t,data:void 0}}import{connectorsForWallets as ta}from"@rainbow-me/rainbowkit";import{createConfig as ra}from"wagmi";import{getDefaultWallets as ea}from"@rainbow-me/rainbowkit";function ee(e){let{wallets:t}=ea();return[...t]}function oa(e){let t=ee(e),r=ta(t,{appName:e.appName,projectId:e.walletConnectProjectId});return ra({connectors:r,chains:e.chains,transports:e.transports,pollingInterval:e.pollingInterval})}import{connectorsForWallets as na}from"@rainbow-me/rainbowkit";function wm({wallets:e,...t}){return na(e??ee(t),{appName:t.appName,projectId:t.walletConnectProjectId})}export{$n as AccountButton,Gn as EntryKitProvider,oa as createWagmiConfig,Gt as defineConfig,wm as getConnectors,ee as getWallets,C as useAccountModal,l as useEntryKitConfig,Jn as useSessionClient};
|
|
1398
1398
|
//# sourceMappingURL=internal.js.map
|