@latticexyz/entrykit 2.2.15-entrykit-9f7c977a92973d8e7290aafb7ebf6f2d1d8f4b99 → 2.2.15-entrykit-e66a8c91a521eb7d297ed2c6fb85cfa227419c8c
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/dist/tsup/internal.js
CHANGED
|
@@ -1422,7 +1422,7 @@ video {
|
|
|
1422
1422
|
--tw-text-opacity: 1;
|
|
1423
1423
|
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
1424
1424
|
}
|
|
1425
|
-
`;import{useResizeObserver as Jt}from"usehooks-ts";import{mergeRefs as Zt}from"react-merge-refs";import{createContext as Ut,useContext as qt}from"react";import{jsx as Vt}from"react/jsx-runtime";var Ie=Ut(null);function Ne({frame:e,children:t}){if(qt(Ie))throw new Error("`FrameProvider` can only be used once.");return Vt(Ie.Provider,{value:{frame:e},children:t})}import{useMediaQuery as Yt}from"usehooks-ts";import"@rainbow-me/rainbowkit/styles.css";import{createContext as Qt,useContext as Oe}from"react";import{RainbowKitProvider as _t,lightTheme as Te,midnightTheme as Ee}from"@rainbow-me/rainbowkit";import{jsx as He}from"react/jsx-runtime";var le=Qt(null);function Re({config:e,children:t}){if(Oe(le))throw new Error("`EntryKitProvider` can only be used once.");return He(_t,{initialChain:e.chainId,appInfo:{appName:e.appInfo?.name},theme:e.theme==="light"?Te({borderRadius:"none"}):e.theme==="dark"?Ee({borderRadius:"none"}):{lightMode:Te({borderRadius:"none"}),darkMode:Ee({borderRadius:"none"})},children:He(le.Provider,{value:e,children:t})})}function p(){let e=Oe(le);if(!e)throw new Error("`useEntryKitConfig` can only be used within a `EntryKitProvider`.");return e}function De(){let{theme:e}=p(),t=Yt("(prefers-color-scheme: dark)");return e??(t?"dark":"light")}import{jsx as H,jsxs as tn}from"react/jsx-runtime";function en({onSize:e,...t}){let n=Ke(null);return Jt({ref:n,onResize:e}),H("div",{ref:n,...t,style:{...t.style,display:"inline-grid"}})}var G=Xt(function({mode:t,children:n},r){let o=Ke(null),[s,a]=ze(!1),d=s?o.current:null,[l,c]=ze({width:void 0,height:void 0}),i=d?.contentDocument,u=De();jt(()=>{i&&i.body.setAttribute("data-theme",u)},[i,u]);let y=t==="modal"?{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",zIndex:"2147483646"}:l.width&&l.height?{all:"unset",display:"inline-grid",width:`${l.width}px`,height:`${l.height}px`}:{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",opacity:0,pointerEvents:"none"};return H("iframe",{ref:Zt([r,o]),style:y,onLoad:()=>a(!0),srcDoc:"<!doctype html><title>\u2026</title>",children:i?$t.createPortal(tn(Ne,{frame:d,children:[H("div",{children:t==="modal"?n:H(en,{onSize:c,children:n})}),H("style",{dangerouslySetInnerHTML:{__html:Me}})]}),i.body):null})});import{twMerge as Le}from"tailwind-merge";import{jsx as P,jsxs as an}from"react/jsx-runtime";function Be({open:e,onOpenChange:t,children:n}){return P(nn,{open:e,onOpenChange:t,children:P(rn,{children:an(G,{mode:"modal",children:[P("div",{className:Le("fixed inset-0","bg-neutral-800/85","animate-in animate-duration-300 fade-in")}),P("div",{className:Le("fixed inset-0","grid items-end sm:items-center","animate-in animate-duration-300 fade-in slide-in-from-bottom-16"),children:P("div",{children:P(on,{className:"outline-none w-full max-w-[26rem] mx-auto","aria-describedby":void 0,onOpenAutoFocus:r=>{r.preventDefault()},children:n})})})]})})})}import{useCallback as pe,useMemo as sn}from"react";import{useStore as cn}from"zustand";import{createStore as dn}from"zustand/vanilla";var W=dn(()=>({open:!1}));function h(){let e=cn(W,o=>o.open),t=pe(()=>{W.setState({open:!0})},[]),n=pe(()=>{W.setState({open:!1})},[]),r=pe(o=>{W.setState({open:o})},[]);return sn(()=>({accountModalOpen:e,openAccountModal:t,closeAccountModal:n,toggleAccountModal:r}),[e,t,n,r])}import{twMerge as Tt}from"tailwind-merge";import{useAccount as co,useConnectorClient as lo}from"wagmi";import{useAccount as cr}from"wagmi";import{twMerge as U}from"tailwind-merge";import{twMerge as ln}from"tailwind-merge";import{jsx as Fe,jsxs as pn}from"react/jsx-runtime";function C({className:e,...t}){return pn("svg",{className:ln("-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:[Fe("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Fe("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 O,jsxs as mn}from"react/jsx-runtime";var un=({variant:e="primary"}={})=>U("group 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:U("bg-neutral-700 text-white"),secondary:U("bg-neutral-800 text-white")}[e]),w=({pending:e,variant:t,type:n,className:r,children:o,disabled:s,...a})=>O("button",{type:n||"button",className:U(un({variant:t,pending:e}),r),"aria-busy":e,"aria-disabled":s,disabled:s||e,...a,children:mn("span",{className:"grid grid-cols-[1fr_auto_1fr] gap-2",children:[O("span",{className:"flex items-center justify-end text-[.75em]",children:O("span",{className:"transition opacity-0 translate-x-2 group-aria-busy:opacity-100 group-aria-busy:translate-x-0 duration-100 group-aria-busy:duration-300",children:O(C,{})})}),O("span",{children:o})]})});import{useConnectModal as dr}from"@rainbow-me/rainbowkit";import{useMutation as et}from"@tanstack/react-query";import{useConnectors as rr}from"wagmi";import{createClient as Xn,custom as jn,getAddress as $n,numberToHex as je,SwitchChainError as Jn}from"viem";import{ChainNotConfiguredError as Zn,createConnector as er}from"wagmi";import{createStore as fn}from"zustand/vanilla";import{persist as yn}from"zustand/middleware";var f=fn(yn(()=>({publicKeys:{},addresses:{},activeCredential:null}),{name:"mud:passkey:cache"}));function gn(e){e.key===f.persist.getOptions().name&&f.persist.rehydrate()}window.addEventListener("storage",gn);import{smartAccountActions as tr}from"permissionless/clients";import{toWebAuthnAccount as En}from"viem/account-abstraction";import{BaseError as hn}from"abitype";import{pad as wn,encodeFunctionData as ue,hashMessage as bn,hashTypedData as We,encodeAbiParameters as Ue,stringToHex as xn,size as vn,encodePacked as Cn,parseSignature as An}from"viem";import{entryPoint07Abi as kn,entryPoint07Address as Sn,getUserOperationHash as Pn,toSmartAccount as Mn}from"viem/account-abstraction";import{readContract as Ge}from"viem/actions";import{parseSignature as In}from"webauthn-p256";async function Q(e){let{client:t,owners:n,nonce:r=0n}=e,o=e.address,s={abi:kn,address:Sn,version:"0.7"},a={abi:Tn,address:"0x356336adA1619BeC1Ae4E6D94Dd9c0490DA414a8"};if(!n.length)throw new Error("`owners` must have at least one account.");function d(i){return i.type==="webAuthn"?i.publicKey:wn(i.address)}let l=e.signer??n[0],c=n.indexOf(l);if(c===-1)throw new Error("`signer` must be one of `owners`.");return Mn({client:t,entryPoint:s,extend:{__isCoinbaseSmartAccount:!0,abi:V,factory:a,signer:l},async encodeCalls(i){return i.length===1?ue({abi:V,functionName:"execute",args:[i[0].to,i[0].value??0n,i[0].data??"0x"]}):ue({abi:V,functionName:"executeBatch",args:[i.map(u=>({data:u.data??"0x",target:u.to,value:u.value??0n}))]})},async getAddress(){return o??=await Ge(t,{...a,functionName:"getAddress",args:[n.map(d),r]}),o},async getFactoryArgs(){let i=ue({abi:a.abi,functionName:"createAccount",args:[n.map(d),r]});return{factory:a.address,factoryData:i}},async getStubSignature(){return l.type==="webAuthn"?"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000":R({signature:"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",ownerIndex:c})},async sign(i){let u=await this.getAddress(),y=me({address:u,chainId:t.chain.id,hash:i.hash}),g=await q({hash:y,owner:l});return R({signature:g,ownerIndex:c})},async signMessage(i){let{message:u}=i,y=await this.getAddress(),g=me({address:y,chainId:t.chain.id,hash:bn(u)}),b=await q({hash:g,owner:l});return R({signature:b,ownerIndex:c})},async signTypedData(i){let{domain:u,types:y,primaryType:g,message:b}=i,S=await this.getAddress(),m=me({address:S,chainId:t.chain.id,hash:We({domain:u,message:b,primaryType:g,types:y})}),ce=await q({hash:m,owner:l});return R({signature:ce,ownerIndex:c})},async signUserOperation(i){let{chainId:u=t.chain.id,...y}=i,g=await this.getAddress(),b=Pn({chainId:u,entryPointAddress:s.address,entryPointVersion:s.version,userOperation:{...y,sender:g}}),S=await q({hash:b,owner:l});return R({signature:S,ownerIndex:c})},userOperation:{async estimateGas(i){if(l.type==="webAuthn")return{verificationGasLimit:BigInt(Math.max(Number(i.verificationGasLimit??0n),8e5))}}},async isOwner(i){return await Ge(t,{abi:V,address:await this.getAddress(),functionName:"isOwnerBytes",args:[d(i)]})}})}async function q({hash:e,owner:t}){if(t.type==="webAuthn"){let{signature:n,webauthn:r}=await t.sign({hash:e});return Nn({signature:n,webauthn:r})}if(t.sign)return t.sign({hash:e});throw new hn("`owner` does not support raw sign.")}function me({address:e,chainId:t,hash:n}){return We({domain:{chainId:t,name:"Coinbase Smart Wallet",verifyingContract:e,version:"1"},types:{CoinbaseSmartWalletMessage:[{name:"hash",type:"bytes32"}]},primaryType:"CoinbaseSmartWalletMessage",message:{hash:n}})}function Nn({webauthn:e,signature:t}){let{r:n,s:r}=In(t);return Ue([{components:[{name:"authenticatorData",type:"bytes"},{name:"clientDataJSON",type:"bytes"},{name:"challengeIndex",type:"uint256"},{name:"typeIndex",type:"uint256"},{name:"r",type:"uint256"},{name:"s",type:"uint256"}],type:"tuple"}],[{authenticatorData:e.authenticatorData,clientDataJSON:xn(e.clientDataJSON),challengeIndex:BigInt(e.challengeIndex),typeIndex:BigInt(e.typeIndex),r:n,s:r}])}function R(e){let{ownerIndex:t}=e,n=(()=>{if(vn(e.signature)!==65)return e.signature;let r=An(e.signature);return Cn(["bytes32","bytes32","uint8"],[r.r,r.s,r.yParity===0?27:28])})();return Ue([{components:[{name:"ownerIndex",type:"uint8"},{name:"signatureData",type:"bytes"}],type:"tuple"}],[{ownerIndex:t,signatureData:n}])}var V=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"owner",type:"bytes"}],name:"AlreadyOwner",type:"error"},{inputs:[],name:"Initialized",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidEthereumAddressOwner",type:"error"},{inputs:[{name:"key",type:"uint256"}],name:"InvalidNonceKey",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidOwnerBytesLength",type:"error"},{inputs:[],name:"LastOwner",type:"error"},{inputs:[{name:"index",type:"uint256"}],name:"NoOwnerAtIndex",type:"error"},{inputs:[{name:"ownersRemaining",type:"uint256"}],name:"NotLastOwner",type:"error"},{inputs:[{name:"selector",type:"bytes4"}],name:"SelectorNotAllowed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"UnauthorizedCallContext",type:"error"},{inputs:[],name:"UpgradeFailed",type:"error"},{inputs:[{name:"index",type:"uint256"},{name:"expectedOwner",type:"bytes"},{name:"actualOwner",type:"bytes"}],name:"WrongOwnerAtIndex",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"AddOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"RemoveOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"REPLAYABLE_NONCE_KEY",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"addOwnerAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"addOwnerPublicKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"functionSelector",type:"bytes4"}],name:"canSkipChainIdValidation",outputs:[{name:"",type:"bool"}],stateMutability:"pure",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"entryPoint",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"calls",type:"bytes[]"}],name:"executeWithoutChainIdValidation",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHashWithoutChainId",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"$",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"owners",type:"bytes[]"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"isOwnerAddress",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"bytes"}],name:"isOwnerBytes",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"isOwnerPublicKey",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"result",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextOwnerIndex",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"}],name:"ownerAtIndex",outputs:[{name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ownerCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeLastOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeOwnerAtIndex",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"removedOwnersCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"}],name:"replaySafeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"newImplementation",type:"address"},{name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"missingAccountFunds",type:"uint256"}],name:"validateUserOp",outputs:[{name:"validationData",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],Tn=[{inputs:[{name:"implementation_",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"OwnerRequired",type:"error"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"createAccount",outputs:[{name:"account",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"getAddress",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initCodeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"}];async function D(e,t){let{publicKeys:n}=f.getState(),r=n[t];if(!r)throw new Error("No public key found for passkey credential.");let s=[En({credential:{id:t,publicKey:r}})];return await Q({client:e,owners:s})}import{bytesToHex as Fn,hashMessage as Gn}from"viem";import{sign as Wn}from"webauthn-p256";import{bytesToHex as Hn,hexToBytes as qe}from"webauthn-p256";import{concatBytes as On,utf8ToBytes as Rn}from"@noble/curves/abstract/utils";async function _(e){let{authenticatorData:t,challengeIndex:n,clientDataJSON:r,typeIndex:o,userVerificationRequired:s}=e,a=o||r.indexOf('"type"'),d=n||r.indexOf('"challenge"'),l=qe(t);if(l.length<37)throw new Error("Invalid authenticatorData");let c=l[32];if((c&1)!==1)throw new Error("Invalid authenticatorData");if(s&&(c&4)!==4)throw new Error("Invalid authenticatorData");if((c&8)!==8&&(c&16)===16)throw new Error("Invalid authenticatorData");let i='"type":"webauthn.get"';if(i!==r.slice(Number(a),i.length+1))throw new Error("Invalid clientDataJSON");if(!r.slice(Number(d)).match(/^"challenge":"(.*?)"/))throw new Error("Invalid clientDataJSON");let y=new Uint8Array(await crypto.subtle.digest("SHA-256",Rn(r))),g=new Uint8Array(await crypto.subtle.digest("SHA-256",On(qe(t),y)));return Hn(g)}import{sign as zn}from"webauthn-p256";import{parseSignature as Dn,serializePublicKey as Ve}from"webauthn-p256";import{secp256r1 as Qe}from"@noble/curves/p256";function fe(e){let{r:t,s:n}=Dn(e.signatureHex),r=new Qe.Signature(t,n).addRecoveryBit(1).recoverPublicKey(e.messageHash.slice(2)),o=new Qe.Signature(t,n).addRecoveryBit(0).recoverPublicKey(e.messageHash.slice(2));return[Ve(r),Ve(o)]}import{hashMessage as Kn}from"viem";function Ln([e,t]){return Bn([...fe(e),...fe(t)])}async function _e(e){let t=Kn(e.signatureHex),{signature:n,webauthn:r,raw:o}=await zn({credentialId:e.credentialId,hash:t}),s=await _(r),a=Ln([e,{signatureHex:n,messageHash:s}]);if(a)return{publicKey:a,credential:o}}function Bn(e){let t=new Set;for(let n of e){if(t.has(n))return n;t.add(n)}}async function ye(){let e=Fn(crypto.getRandomValues(new Uint8Array(256))),t=Gn(e),{signature:n,webauthn:r,raw:o}=await Wn({hash:t}),s=await(async()=>{let a=f.getState().publicKeys[o.id];if(a)return a;let d=await _(r),l=await _e({credentialId:o.id,messageHash:d,signatureHex:n});if(!l)throw new Error("recovery failed");if(l.credential.id!==o.id)throw new Error("wrong credential");return f.setState(c=>({publicKeys:{...c.publicKeys,[o.id]:l.publicKey}})),l.publicKey})();return console.log("recovered passkey",o.id,s),f.setState(()=>({activeCredential:o.id})),{id:o.id,publicKey:s,raw:o}}import{createCredential as Un}from"webauthn-p256";async function Ye(){let e=await Un({name:"MUD Account"});return console.log("created passkey",e),f.setState(t=>({activeCredential:e.id,publicKeys:{...t.publicKeys,[e.id]:e.publicKey}})),e}import{resourceToHex as qn}from"@latticexyz/common";import{parseAbi as Vn}from"viem";import Qn from"@latticexyz/world/mud.config";var Y={pollingInterval:250},z=qn({type:"system",namespace:"",name:"unlimited"}),Xe=Qn.namespaces.world.tables,ge=Vn(["function registerDelegation(address delegatee, bytes32 delegationControlId, bytes initCallData)"]);import{createBundlerClient as _n}from"viem/account-abstraction";var Yn=new Set([31337,17420,17069,690]);function X({paymasterAddress:e,...t}){let n=t.chain??t.client?.chain;return _n({...Y,paymaster:{getPaymasterData:async()=>({paymaster:e,paymasterData:"0x"})},userOperation:{estimateFeesPerGas:n&&Yn.has(n.id)?async()=>({maxFeePerGas:100000n,maxPriorityFeePerGas:0n}):void 0},...t})}import{observer as nr}from"@latticexyz/explorer/observer";M.type="passkey";function M({chainId:e,bundlerTransport:t,paymasterAddress:n,explorerUrl:r}){return er(o=>{if(!o.transports)throw new Error("Wagmi must be configured with transports to use the passkey connector.");let s=o.chains.find(c=>c.id===e);if(!s)throw new Error(`Could not find configured chain for chain ID ${e}.`);let a=o.transports[s.id];if(!a)throw new Error(`Could not find configured transport for chain ID ${e}.`);let d=Xn({...Y,chain:s,transport:a}),l=f.getState().activeCredential!=null;return{id:"passkey",type:M.type,name:"Passkey",async createPasskey(){let{id:c}=await Ye(),i=await D(d,c);this.onAccountsChanged([i.address]),this.onConnect?.({chainId:je(e)})},async reusePasskey(){let{id:c}=await ye(),i=await D(d,c);this.onAccountsChanged([i.address]),this.onConnect?.({chainId:je(e)})},hasPasskey(){return Object.keys(f.getState().publicKeys).length>0},async connect(c){if(console.log("connect"),c?.chainId!=null&&c.chainId!==e)throw new Error(`Can't connect to chain ${c.chainId}. Passkey connector is bound to chain ${e}.`);!f.getState().activeCredential&&!c?.isReconnecting&&await ye();let i=await this.getAccounts();return l=i.length>0,{accounts:i,chainId:e}},async disconnect(){console.log("disconnect"),l=!1,f.setState({activeCredential:null})},async getAccounts(){console.log("getAccounts");let c=f.getState().activeCredential;if(!c)return[];try{console.log("getting account for credential",c);let i=await D(d,c);return console.log("got account",i),[i.address]}catch{console.log("could not get address for credential ID",c)}return[]},async getChainId(){return e},async isAuthorized(){return console.log("isAuthorized"),l?(await this.getAccounts()).length>0:!1},async switchChain(c){if(c.chainId!==e)throw new Error(`Can't connect to chain ${c.chainId}. Passkey connector is bound to chain ${e}.`);let i=o.chains.find(u=>u.id===c.chainId);if(!i)throw new Jn(new Zn);return i},onAccountsChanged(c){console.log("onAccountsChanged"),c.length>0?o.emitter.emit("change",{accounts:c.map(i=>$n(i))}):this.onDisconnect()},onChainChanged(c){console.log("onChainChanged"),o.emitter.emit("change",{chainId:Number(c)})},async onConnect(c){console.log("onConnect");let i=await this.getAccounts();o.emitter.emit("connect",{accounts:i,chainId:e})},async onDisconnect(c){console.log("onDisconnect"),o.emitter.emit("disconnect"),l=!1},async getClient(c){console.log("passkeyConnector.getClient",c);let i=f.getState().activeCredential;if(!i)throw new Error("Not connected.");let u=await D(d,i);return X({paymasterAddress:n,transport:t,client:d,account:u}).extend(tr()).extend(y=>r?nr({explorerUrl:r})(y):{})},async getProvider(c){return jn({request:d.transport.request})({retryCount:0})}}})}function $e(){let t=rr().find(n=>n.type===M.type);if(!t)throw new Error("Could not find passkey connector. Did you configure Wagmi with the EntryKit passkey connector or passkey wallet?");return t}import{twMerge as or}from"tailwind-merge";import{jsx as he,jsxs as ar}from"react/jsx-runtime";function A({className:e,...t}){return ar("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 8 8",fill:"currentColor",shapeRendering:"crispEdges",className:or("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...t,children:[he("path",{d:"M0 0h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm2-1h1v1H7zm0 1h1v1H7zM6 7h1v1H6zm1-2h1v1H7zm0-1h1v1H7zm0-1h1v1H7z"}),he("path",{d:"M2 2h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm1-3h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm0 1h1v1H5zm0 1h1v1H5zm0 1h1v1H5zM4 5h1v1H4zM3 5h1v1H3z",opacity:".5"}),he("path",{d:"M7 2h1v1H7zm0-1h1v1H7zM1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm1 0h1v1H6zm1 0h1v1H7z"})]})}function Je(){let{appInfo:e}=p(),t=e?.name??document.title,n=location.host,r=e?.icon??document.querySelector("link[rel~='icon']")?.getAttribute("href")??"/favico.ico",o=e?.image;return{appName:t,appOrigin:n,appIcon:r,appImage:o}}import{useQuery as ir}from"@tanstack/react-query";function j(e){return ir({enabled:!!e,retry:!1,retryOnMount:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,queryKey:[e],queryFn:()=>new Promise((t,n)=>{if(!e)throw new Error("usePreloadImage: Must provide `url` to preload image.");let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error(`usePreloadImage: Could not load image.
|
|
1425
|
+
`;import{useResizeObserver as Jt}from"usehooks-ts";import{mergeRefs as Zt}from"react-merge-refs";import{createContext as Ut,useContext as qt}from"react";import{jsx as Vt}from"react/jsx-runtime";var Ie=Ut(null);function Ne({frame:e,children:t}){if(qt(Ie))throw new Error("`FrameProvider` can only be used once.");return Vt(Ie.Provider,{value:{frame:e},children:t})}import{useMediaQuery as Yt}from"usehooks-ts";import"@rainbow-me/rainbowkit/styles.css";import{createContext as Qt,useContext as Oe}from"react";import{RainbowKitProvider as _t,lightTheme as Te,midnightTheme as Ee}from"@rainbow-me/rainbowkit";import{jsx as He}from"react/jsx-runtime";var le=Qt(null);function Re({config:e,children:t}){if(Oe(le))throw new Error("`EntryKitProvider` can only be used once.");return He(_t,{initialChain:e.chainId,appInfo:{appName:e.appInfo?.name},theme:e.theme==="light"?Te({borderRadius:"none"}):e.theme==="dark"?Ee({borderRadius:"none"}):{lightMode:Te({borderRadius:"none"}),darkMode:Ee({borderRadius:"none"})},children:He(le.Provider,{value:e,children:t})})}function p(){let e=Oe(le);if(!e)throw new Error("`useEntryKitConfig` can only be used within a `EntryKitProvider`.");return e}function De(){let{theme:e}=p(),t=Yt("(prefers-color-scheme: dark)");return e??(t?"dark":"light")}import{jsx as H,jsxs as tn}from"react/jsx-runtime";function en({onSize:e,...t}){let n=Ke(null);return Jt({ref:n,onResize:e}),H("div",{ref:n,...t,style:{...t.style,display:"inline-grid"}})}var G=Xt(function({mode:t,children:n},r){let o=Ke(null),[a,i]=ze(!1),d=a?o.current:null,[l,c]=ze({width:void 0,height:void 0}),s=d?.contentDocument,u=De();jt(()=>{s&&s.body.setAttribute("data-theme",u)},[s,u]);let y=t==="modal"?{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",zIndex:"2147483646"}:l.width&&l.height?{all:"unset",display:"inline-grid",width:`${l.width}px`,height:`${l.height}px`}:{all:"unset",display:"block",position:"fixed",inset:"0",width:"100%",height:"100%",opacity:0,pointerEvents:"none"};return H("iframe",{ref:Zt([r,o]),style:y,onLoad:()=>i(!0),srcDoc:"<!doctype html><title>\u2026</title>",children:s?$t.createPortal(tn(Ne,{frame:d,children:[H("div",{children:t==="modal"?n:H(en,{onSize:c,children:n})}),H("style",{dangerouslySetInnerHTML:{__html:Me}})]}),s.body):null})});import{twMerge as Le}from"tailwind-merge";import{jsx as P,jsxs as an}from"react/jsx-runtime";function Be({open:e,onOpenChange:t,children:n}){return P(nn,{open:e,onOpenChange:t,children:P(rn,{children:an(G,{mode:"modal",children:[P("div",{className:Le("fixed inset-0","bg-neutral-800/85","animate-in animate-duration-300 fade-in")}),P("div",{className:Le("fixed inset-0","grid items-end sm:items-center","animate-in animate-duration-300 fade-in slide-in-from-bottom-16"),children:P("div",{children:P(on,{className:"outline-none w-full max-w-[26rem] mx-auto","aria-describedby":void 0,onOpenAutoFocus:r=>{r.preventDefault()},children:n})})})]})})})}import{useCallback as pe,useMemo as sn}from"react";import{useStore as cn}from"zustand";import{createStore as dn}from"zustand/vanilla";var W=dn(()=>({open:!1}));function h(){let e=cn(W,o=>o.open),t=pe(()=>{W.setState({open:!0})},[]),n=pe(()=>{W.setState({open:!1})},[]),r=pe(o=>{W.setState({open:o})},[]);return sn(()=>({accountModalOpen:e,openAccountModal:t,closeAccountModal:n,toggleAccountModal:r}),[e,t,n,r])}import{twMerge as Tt}from"tailwind-merge";import{useAccount as co,useConnectorClient as lo}from"wagmi";import{useAccount as cr}from"wagmi";import{twMerge as U}from"tailwind-merge";import{twMerge as ln}from"tailwind-merge";import{jsx as Fe,jsxs as pn}from"react/jsx-runtime";function C({className:e,...t}){return pn("svg",{className:ln("-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:[Fe("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Fe("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 O,jsxs as mn}from"react/jsx-runtime";var un=({variant:e="primary"}={})=>U("group 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:U("bg-neutral-700 text-white"),secondary:U("bg-neutral-800 text-white")}[e]),w=({pending:e,variant:t,type:n,className:r,children:o,disabled:a,...i})=>O("button",{type:n||"button",className:U(un({variant:t,pending:e}),r),"aria-busy":e,"aria-disabled":a,disabled:a||e,...i,children:mn("span",{className:"grid grid-cols-[1fr_auto_1fr] gap-2",children:[O("span",{className:"flex items-center justify-end text-[.75em]",children:O("span",{className:"transition opacity-0 translate-x-2 group-aria-busy:opacity-100 group-aria-busy:translate-x-0 duration-100 group-aria-busy:duration-300",children:O(C,{})})}),O("span",{children:o})]})});import{useConnectModal as dr}from"@rainbow-me/rainbowkit";import{useMutation as et}from"@tanstack/react-query";import{useConnectors as rr}from"wagmi";import{createClient as Xn,custom as jn,getAddress as $n,numberToHex as je,SwitchChainError as Jn}from"viem";import{ChainNotConfiguredError as Zn,createConnector as er}from"wagmi";import{createStore as fn}from"zustand/vanilla";import{persist as yn}from"zustand/middleware";var f=fn(yn(()=>({publicKeys:{},activeCredential:null}),{name:"mud:passkey:cache"}));function gn(e){e.key===f.persist.getOptions().name&&f.persist.rehydrate()}window.addEventListener("storage",gn);import{smartAccountActions as tr}from"permissionless/clients";import{toWebAuthnAccount as En}from"viem/account-abstraction";import{BaseError as hn}from"abitype";import{pad as wn,encodeFunctionData as ue,hashMessage as bn,hashTypedData as We,encodeAbiParameters as Ue,stringToHex as xn,size as vn,encodePacked as Cn,parseSignature as An}from"viem";import{entryPoint07Abi as kn,entryPoint07Address as Sn,getUserOperationHash as Pn,toSmartAccount as Mn}from"viem/account-abstraction";import{readContract as Ge}from"viem/actions";import{parseSignature as In}from"webauthn-p256";async function Q(e){let{client:t,owners:n,nonce:r=0n}=e,o=e.address,a={abi:kn,address:Sn,version:"0.7"},i={abi:Tn,address:"0x356336adA1619BeC1Ae4E6D94Dd9c0490DA414a8"};if(!n.length)throw new Error("`owners` must have at least one account.");function d(s){return s.type==="webAuthn"?s.publicKey:wn(s.address)}let l=e.signer??n[0],c=n.indexOf(l);if(c===-1)throw new Error("`signer` must be one of `owners`.");return Mn({client:t,entryPoint:a,extend:{__isCoinbaseSmartAccount:!0,abi:V,factory:i,signer:l},async encodeCalls(s){return s.length===1?ue({abi:V,functionName:"execute",args:[s[0].to,s[0].value??0n,s[0].data??"0x"]}):ue({abi:V,functionName:"executeBatch",args:[s.map(u=>({data:u.data??"0x",target:u.to,value:u.value??0n}))]})},async getAddress(){return o??=await Ge(t,{...i,functionName:"getAddress",args:[n.map(d),r]}),o},async getFactoryArgs(){let s=ue({abi:i.abi,functionName:"createAccount",args:[n.map(d),r]});return{factory:i.address,factoryData:s}},async getStubSignature(){return l.type==="webAuthn"?"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000":R({signature:"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",ownerIndex:c})},async sign(s){let u=await this.getAddress(),y=me({address:u,chainId:t.chain.id,hash:s.hash}),g=await q({hash:y,owner:l});return R({signature:g,ownerIndex:c})},async signMessage(s){let{message:u}=s,y=await this.getAddress(),g=me({address:y,chainId:t.chain.id,hash:bn(u)}),b=await q({hash:g,owner:l});return R({signature:b,ownerIndex:c})},async signTypedData(s){let{domain:u,types:y,primaryType:g,message:b}=s,S=await this.getAddress(),m=me({address:S,chainId:t.chain.id,hash:We({domain:u,message:b,primaryType:g,types:y})}),ce=await q({hash:m,owner:l});return R({signature:ce,ownerIndex:c})},async signUserOperation(s){let{chainId:u=t.chain.id,...y}=s,g=await this.getAddress(),b=Pn({chainId:u,entryPointAddress:a.address,entryPointVersion:a.version,userOperation:{...y,sender:g}}),S=await q({hash:b,owner:l});return R({signature:S,ownerIndex:c})},userOperation:{async estimateGas(s){if(l.type==="webAuthn")return{verificationGasLimit:BigInt(Math.max(Number(s.verificationGasLimit??0n),8e5))}}},async isOwner(s){return await Ge(t,{abi:V,address:await this.getAddress(),functionName:"isOwnerBytes",args:[d(s)]})}})}async function q({hash:e,owner:t}){if(t.type==="webAuthn"){let{signature:n,webauthn:r}=await t.sign({hash:e});return Nn({signature:n,webauthn:r})}if(t.sign)return t.sign({hash:e});throw new hn("`owner` does not support raw sign.")}function me({address:e,chainId:t,hash:n}){return We({domain:{chainId:t,name:"Coinbase Smart Wallet",verifyingContract:e,version:"1"},types:{CoinbaseSmartWalletMessage:[{name:"hash",type:"bytes32"}]},primaryType:"CoinbaseSmartWalletMessage",message:{hash:n}})}function Nn({webauthn:e,signature:t}){let{r:n,s:r}=In(t);return Ue([{components:[{name:"authenticatorData",type:"bytes"},{name:"clientDataJSON",type:"bytes"},{name:"challengeIndex",type:"uint256"},{name:"typeIndex",type:"uint256"},{name:"r",type:"uint256"},{name:"s",type:"uint256"}],type:"tuple"}],[{authenticatorData:e.authenticatorData,clientDataJSON:xn(e.clientDataJSON),challengeIndex:BigInt(e.challengeIndex),typeIndex:BigInt(e.typeIndex),r:n,s:r}])}function R(e){let{ownerIndex:t}=e,n=(()=>{if(vn(e.signature)!==65)return e.signature;let r=An(e.signature);return Cn(["bytes32","bytes32","uint8"],[r.r,r.s,r.yParity===0?27:28])})();return Ue([{components:[{name:"ownerIndex",type:"uint8"},{name:"signatureData",type:"bytes"}],type:"tuple"}],[{ownerIndex:t,signatureData:n}])}var V=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"owner",type:"bytes"}],name:"AlreadyOwner",type:"error"},{inputs:[],name:"Initialized",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidEthereumAddressOwner",type:"error"},{inputs:[{name:"key",type:"uint256"}],name:"InvalidNonceKey",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidOwnerBytesLength",type:"error"},{inputs:[],name:"LastOwner",type:"error"},{inputs:[{name:"index",type:"uint256"}],name:"NoOwnerAtIndex",type:"error"},{inputs:[{name:"ownersRemaining",type:"uint256"}],name:"NotLastOwner",type:"error"},{inputs:[{name:"selector",type:"bytes4"}],name:"SelectorNotAllowed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"UnauthorizedCallContext",type:"error"},{inputs:[],name:"UpgradeFailed",type:"error"},{inputs:[{name:"index",type:"uint256"},{name:"expectedOwner",type:"bytes"},{name:"actualOwner",type:"bytes"}],name:"WrongOwnerAtIndex",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"AddOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"RemoveOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"REPLAYABLE_NONCE_KEY",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"addOwnerAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"addOwnerPublicKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"functionSelector",type:"bytes4"}],name:"canSkipChainIdValidation",outputs:[{name:"",type:"bool"}],stateMutability:"pure",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"entryPoint",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"calls",type:"bytes[]"}],name:"executeWithoutChainIdValidation",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHashWithoutChainId",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"$",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"owners",type:"bytes[]"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"isOwnerAddress",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"bytes"}],name:"isOwnerBytes",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"isOwnerPublicKey",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"result",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextOwnerIndex",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"}],name:"ownerAtIndex",outputs:[{name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ownerCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeLastOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeOwnerAtIndex",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"removedOwnersCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"}],name:"replaySafeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"newImplementation",type:"address"},{name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"missingAccountFunds",type:"uint256"}],name:"validateUserOp",outputs:[{name:"validationData",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],Tn=[{inputs:[{name:"implementation_",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"OwnerRequired",type:"error"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"createAccount",outputs:[{name:"account",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"getAddress",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initCodeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"}];async function D(e,t){let{publicKeys:n}=f.getState(),r=n[t];if(!r)throw new Error("No public key found for passkey credential.");let a=[En({credential:{id:t,publicKey:r}})];return await Q({client:e,owners:a})}import{bytesToHex as Fn,hashMessage as Gn}from"viem";import{sign as Wn}from"webauthn-p256";import{bytesToHex as Hn,hexToBytes as qe}from"webauthn-p256";import{concatBytes as On,utf8ToBytes as Rn}from"@noble/curves/abstract/utils";async function _(e){let{authenticatorData:t,challengeIndex:n,clientDataJSON:r,typeIndex:o,userVerificationRequired:a}=e,i=o||r.indexOf('"type"'),d=n||r.indexOf('"challenge"'),l=qe(t);if(l.length<37)throw new Error("Invalid authenticatorData");let c=l[32];if((c&1)!==1)throw new Error("Invalid authenticatorData");if(a&&(c&4)!==4)throw new Error("Invalid authenticatorData");if((c&8)!==8&&(c&16)===16)throw new Error("Invalid authenticatorData");let s='"type":"webauthn.get"';if(s!==r.slice(Number(i),s.length+1))throw new Error("Invalid clientDataJSON");if(!r.slice(Number(d)).match(/^"challenge":"(.*?)"/))throw new Error("Invalid clientDataJSON");let y=new Uint8Array(await crypto.subtle.digest("SHA-256",Rn(r))),g=new Uint8Array(await crypto.subtle.digest("SHA-256",On(qe(t),y)));return Hn(g)}import{sign as zn}from"webauthn-p256";import{parseSignature as Dn,serializePublicKey as Ve}from"webauthn-p256";import{secp256r1 as Qe}from"@noble/curves/p256";function fe(e){let{r:t,s:n}=Dn(e.signatureHex),r=new Qe.Signature(t,n).addRecoveryBit(1).recoverPublicKey(e.messageHash.slice(2)),o=new Qe.Signature(t,n).addRecoveryBit(0).recoverPublicKey(e.messageHash.slice(2));return[Ve(r),Ve(o)]}import{hashMessage as Kn}from"viem";function Ln([e,t]){return Bn([...fe(e),...fe(t)])}async function _e(e){let t=Kn(e.signatureHex),{signature:n,webauthn:r,raw:o}=await zn({credentialId:e.credentialId,hash:t}),a=await _(r),i=Ln([e,{signatureHex:n,messageHash:a}]);if(i)return{publicKey:i,credential:o}}function Bn(e){let t=new Set;for(let n of e){if(t.has(n))return n;t.add(n)}}async function ye(){let e=Fn(crypto.getRandomValues(new Uint8Array(256))),t=Gn(e),{signature:n,webauthn:r,raw:o}=await Wn({hash:t}),a=await(async()=>{let i=f.getState().publicKeys[o.id];if(i)return i;let d=await _(r),l=await _e({credentialId:o.id,messageHash:d,signatureHex:n});if(!l)throw new Error("recovery failed");if(l.credential.id!==o.id)throw new Error("wrong credential");return f.setState(c=>({publicKeys:{...c.publicKeys,[o.id]:l.publicKey}})),l.publicKey})();return console.log("recovered passkey",o.id,a),f.setState(()=>({activeCredential:o.id})),{id:o.id,publicKey:a,raw:o}}import{createCredential as Un}from"webauthn-p256";async function Ye(){let e=await Un({name:"MUD Account"});return console.log("created passkey",e),f.setState(t=>({activeCredential:e.id,publicKeys:{...t.publicKeys,[e.id]:e.publicKey}})),e}import{resourceToHex as qn}from"@latticexyz/common";import{parseAbi as Vn}from"viem";import Qn from"@latticexyz/world/mud.config";var Y={pollingInterval:250},z=qn({type:"system",namespace:"",name:"unlimited"}),Xe=Qn.namespaces.world.tables,ge=Vn(["function registerDelegation(address delegatee, bytes32 delegationControlId, bytes initCallData)"]);import{createBundlerClient as _n}from"viem/account-abstraction";var Yn=new Set([31337,17420,17069,690]);function X({paymasterAddress:e,...t}){let n=t.chain??t.client?.chain;return _n({...Y,paymaster:{getPaymasterData:async()=>({paymaster:e,paymasterData:"0x"})},userOperation:{estimateFeesPerGas:n&&Yn.has(n.id)?async()=>({maxFeePerGas:100000n,maxPriorityFeePerGas:0n}):void 0},...t})}import{observer as nr}from"@latticexyz/explorer/observer";M.type="passkey";function M({chainId:e,bundlerTransport:t,paymasterAddress:n,explorerUrl:r}){return er(o=>{if(!o.transports)throw new Error("Wagmi must be configured with transports to use the passkey connector.");let a=o.chains.find(c=>c.id===e);if(!a)throw new Error(`Could not find configured chain for chain ID ${e}.`);let i=o.transports[a.id];if(!i)throw new Error(`Could not find configured transport for chain ID ${e}.`);let d=Xn({...Y,chain:a,transport:i}),l=f.getState().activeCredential!=null;return{id:"passkey",type:M.type,name:"Passkey",async createPasskey(){let{id:c}=await Ye(),s=await D(d,c);this.onAccountsChanged([s.address]),this.onConnect?.({chainId:je(e)})},async reusePasskey(){let{id:c}=await ye(),s=await D(d,c);this.onAccountsChanged([s.address]),this.onConnect?.({chainId:je(e)})},hasPasskey(){return Object.keys(f.getState().publicKeys).length>0},async connect(c){if(console.log("connect"),c?.chainId!=null&&c.chainId!==e)throw new Error(`Can't connect to chain ${c.chainId}. Passkey connector is bound to chain ${e}.`);!f.getState().activeCredential&&!c?.isReconnecting&&await ye();let s=await this.getAccounts();return l=s.length>0,{accounts:s,chainId:e}},async disconnect(){console.log("disconnect"),l=!1,f.setState({activeCredential:null})},async getAccounts(){console.log("getAccounts");let c=f.getState().activeCredential;if(!c)return[];try{console.log("getting account for credential",c);let s=await D(d,c);return console.log("got account",s),[s.address]}catch{console.log("could not get address for credential ID",c)}return[]},async getChainId(){return e},async isAuthorized(){return console.log("isAuthorized"),l?(await this.getAccounts()).length>0:!1},async switchChain(c){if(c.chainId!==e)throw new Error(`Can't connect to chain ${c.chainId}. Passkey connector is bound to chain ${e}.`);let s=o.chains.find(u=>u.id===c.chainId);if(!s)throw new Jn(new Zn);return s},onAccountsChanged(c){console.log("onAccountsChanged"),c.length>0?o.emitter.emit("change",{accounts:c.map(s=>$n(s))}):this.onDisconnect()},onChainChanged(c){console.log("onChainChanged"),o.emitter.emit("change",{chainId:Number(c)})},async onConnect(c){console.log("onConnect");let s=await this.getAccounts();o.emitter.emit("connect",{accounts:s,chainId:e})},async onDisconnect(c){console.log("onDisconnect"),o.emitter.emit("disconnect"),l=!1},async getClient(c){console.log("passkeyConnector.getClient",c);let s=f.getState().activeCredential;if(!s)throw new Error("Not connected.");let u=await D(d,s);return X({paymasterAddress:n,transport:t,client:d,account:u}).extend(tr()).extend(y=>r?nr({explorerUrl:r})(y):{})},async getProvider(c){return jn({request:d.transport.request})({retryCount:0})}}})}function $e(){let t=rr().find(n=>n.type===M.type);if(!t)throw new Error("Could not find passkey connector. Did you configure Wagmi with the EntryKit passkey connector or passkey wallet?");return t}import{twMerge as or}from"tailwind-merge";import{jsx as he,jsxs as ar}from"react/jsx-runtime";function A({className:e,...t}){return ar("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 8 8",fill:"currentColor",shapeRendering:"crispEdges",className:or("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...t,children:[he("path",{d:"M0 0h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm0 1h1v1H0zm1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm2-1h1v1H7zm0 1h1v1H7zM6 7h1v1H6zm1-2h1v1H7zm0-1h1v1H7zm0-1h1v1H7z"}),he("path",{d:"M2 2h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm0 1h1v1H2zm1-3h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm0 1h1v1H5zm0 1h1v1H5zm0 1h1v1H5zM4 5h1v1H4zM3 5h1v1H3z",opacity:".5"}),he("path",{d:"M7 2h1v1H7zm0-1h1v1H7zM1 0h1v1H1zm1 0h1v1H2zm1 0h1v1H3zm1 0h1v1H4zm1 0h1v1H5zm1 0h1v1H6zm1 0h1v1H7z"})]})}function Je(){let{appInfo:e}=p(),t=e?.name??document.title,n=location.host,r=e?.icon??document.querySelector("link[rel~='icon']")?.getAttribute("href")??"/favico.ico",o=e?.image;return{appName:t,appOrigin:n,appIcon:r,appImage:o}}import{useQuery as ir}from"@tanstack/react-query";function j(e){return ir({enabled:!!e,retry:!1,retryOnMount:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,queryKey:[e],queryFn:()=>new Promise((t,n)=>{if(!e)throw new Error("usePreloadImage: Must provide `url` to preload image.");let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error(`usePreloadImage: Could not load image.
|
|
1426
1426
|
|
|
1427
|
-
URL: ${e}`)),r.src=e})})}import{jsx as $,jsxs as sr}from"react/jsx-runtime";function Ze(){let{appName:e,appIcon:t}=Je(),{data:n,isLoading:r}=j(t);return sr("div",{className:"flex-grow flex flex-col items-center justify-center gap-2",children:[$("div",{className:"w-16 h-16 m-2",children:r?null:n?$("img",{src:t,className:"w-full h-full object-cover"}):$(A,{className:"w-full h-full text-orange-500 dark:bg-neutral-800"})}),$("div",{className:"text-2xl text-white text-center",children:e})]})}import{twMerge as lr}from"tailwind-merge";import{jsx as K,jsxs as tt}from"react/jsx-runtime";function nt(){let e=cr(),{accountModalOpen:t}=h(),{openConnectModal:n,connectModalOpen:r}=dr(),o=$e(),s=et({onError:c=>console.error(c),mutationKey:["createPasskey",o.id,t,r,e.status],mutationFn:()=>o.createPasskey()}),a=et({onError:c=>console.error(c),mutationKey:["reusePasskey",o.id,t,r,e.status],mutationFn:()=>o.reusePasskey()}),d=o.hasPasskey(),l=[K(w,{variant:d?"secondary":"primary",className:"self-auto flex justify-center",pending:s.status==="pending",onClick:()=>s.mutate(),autoFocus:!d,children:"Create account"},"create"),K(w,{variant:d?"primary":"secondary",className:"self-auto flex justify-center",pending:a.status==="pending",onClick:()=>a.mutate(),autoFocus:d,children:"Sign in"},"signin")];return d&&l.reverse(),tt("div",{className:lr("flex flex-col gap-6 p-6","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:[K("div",{className:"p-4",children:K(Ze,{})}),tt("div",{className:"self-center flex flex-col gap-2 w-60",children:[l,K("button",{className:"text-sm self-center transition text-neutral-500 hover:text-white p-2",disabled:e.status==="connecting",onClick:n,children:"Already have a wallet?"})]})]})}import{useEffect as oo,useMemo as ao,useRef as io,useState as so}from"react";import{twMerge as Se}from"tailwind-merge";import{parseEther as pr}from"viem";var J=pr("0.01");import{useClient as Cr}from"wagmi";import{queryOptions as Ar,useQuery as kr}from"@tanstack/react-query";import{defineStore as ur}from"@latticexyz/store";import{parseAbi as mr}from"viem";var we=mr(["error SpenderSystem_AlreadyRegistered(address spender, address user)","error SpenderSystem_HasOwnBalance(address spender)","function registerSpender(address spender)"]),fr=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:[]}}}}}),Z=fr.namespaces.root.tables;import{decodeValueArgs as yr,getKeyTuple as gr,getSchemaTypes as hr,getValueSchema as wr}from"@latticexyz/protocol-parser/internal";import{readContract as br}from"viem/actions";import{getAction as xr}from"viem/utils";async function I(e,{address:t,table:n,key:r,blockTag:o}){let[s,a,d]=await xr(e,br,"readContract")({address:t,abi:vr,functionName:"getRecord",args:[n.tableId,gr(n,r)],blockTag:o});return{...r,...yr(hr(wr(n)),{staticData:s,encodedLengths:a,dynamicData:d})}}var vr=[{type:"function",name:"getRecord",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[{name:"staticData",type:"bytes",internalType:"bytes"},{name:"encodedLengths",type:"bytes32",internalType:"EncodedLengths"},{name:"dynamicData",type:"bytes",internalType:"bytes"}],stateMutability:"view"}];async function rt({client:e,paymasterAddress:t,userAddress:n}){return(await I(e,{address:t,table:Z.Allowance,key:{user:n}})).allowance}function be({client:e,paymasterAddress:t,userAddress:n}){let r=["getAllowance",e?.chain.id,t,n];return Ar(e&&n?{queryKey:r,queryFn:()=>rt({client:e,paymasterAddress:t,userAddress:n})}:{queryKey:r,enabled:!1})}function ot(e){let{chainId:t,paymasterAddress:n}=p(),r=Cr({chainId:t});return kr(be({client:r,paymasterAddress:n,userAddress:e}))}import{useClient as ic}from"wagmi";import{queryOptions as Sr,useQuery as cc}from"@tanstack/react-query";async function at({client:e,paymasterAddress:t,userAddress:n,sessionAddress:r}){return(await I(e,{address:t,table:Z.Spender,key:{spender:r}})).user.toLowerCase()===n.toLowerCase()}function it({client:e,paymasterAddress:t,userAddress:n,sessionAddress:r}){let o=["getSpender",e?.chain.id,t,n,r];return Sr(e&&n&&r?{queryKey:o,queryFn:()=>at({client:e,paymasterAddress:t,userAddress:n,sessionAddress:r})}:{queryKey:o,enabled:!1})}import{useClient as gc}from"wagmi";import{queryOptions as Pr,useQuery as wc}from"@tanstack/react-query";async function st({client:e,worldAddress:t,userAddress:n,sessionAddress:r}){return(await I(e,{address:t,table:Xe.UserDelegationControl,key:{delegator:n,delegatee:r}})).delegationControlId===z}function ct({client:e,worldAddress:t,userAddress:n,sessionAddress:r}){let o=["getDelegation",e?.chain.id,t,n,r];return Pr(e&&n&&r?{queryKey:o,queryFn:()=>st({client:e,worldAddress:t,userAddress:n,sessionAddress:r})}:{queryKey:o,enabled:!1})}import{queryOptions as Dr,useQuery as zr,useQueryClient as Kr}from"@tanstack/react-query";import{useClient as Lr}from"wagmi";import{useClient as Hr}from"wagmi";import{queryOptions as Or,useQuery as Rr}from"@tanstack/react-query";import{createStore as Mr}from"zustand/vanilla";import{persist as Ir}from"zustand/middleware";var L=Mr(Ir(()=>({signers:{}}),{name:"mud:entrykit",partialize:({signers:e})=>({signers:e})}));function Nr(e){e.key===L.persist.getOptions().name&&L.persist.rehydrate()}window.addEventListener("storage",Nr);import{generatePrivateKey as Tr,privateKeyToAccount as Er}from"viem/accounts";function dt(e){let t=L.getState().signers[e]??(()=>{let n=Tr();return L.setState(r=>({signers:{...r.signers,[e]:n}})),n})();return Er(t)}async function lt({client:e,userAddress:t}){let n=dt(t);return await Q({client:e,owners:[n]})}function xe({client:e,userAddress:t}){let n=["getSessionAccount",e?.chain.id,t];return Or(e&&t?{queryKey:n,queryFn:()=>lt({client:e,userAddress:t}),staleTime:1/0}:{queryKey:n,enabled:!1})}function ee(e){let{chainId:t}=p(),n=Hr({chainId:t});return Rr(xe({userAddress:e,client:n}))}function Br({queryClient:e,client:t,userAddress:n,paymasterAddress:r,worldAddress:o}){let s=["getPrerequisites",t?.chain.id,n];return Dr(t&&n?{queryKey:s,queryFn:async()=>{let{address:a}=await e.fetchQuery(xe({client:t,userAddress:n})),[d,l,c]=await Promise.all([e.fetchQuery(be({client:t,paymasterAddress:r,userAddress:n})),e.fetchQuery(it({client:t,paymasterAddress:r,userAddress:n,sessionAddress:a})),e.fetchQuery(ct({client:t,worldAddress:o,userAddress:n,sessionAddress:a}))]),i=d>=J;return{hasAllowance:i,isSpender:l,hasDelegation:c,complete:i&&l&&c}}}:{queryKey:s,enabled:!1})}function N(e){let t=Kr(),{chainId:n,paymasterAddress:r,worldAddress:o}=p(),s=Lr({chainId:n});return zr(Br({queryClient:t,client:s,userAddress:e,paymasterAddress:r,worldAddress:o}),t)}import{useDisconnect as Wr}from"wagmi";import{useQuery as Fr}from"@tanstack/react-query";function te(e){let t=e?.toLowerCase();return Fr({enabled:!!t,queryKey:["ens",t],initialData:{address:void 0,name:void 0,displayName:void 0,avatar:void 0},queryFn:async()=>{let n=await fetch(`https://api.ensideas.com/ens/resolve/${t}`).then(r=>r.json());return{address:n.address??void 0,name:n.name??void 0,displayName:n.displayName??void 0,avatar:n.avatar??void 0}}})}import{jsx as ve,jsxs as Gr}from"react/jsx-runtime";function ne({hex:e}){return e.length<=10?ve("span",{title:e,children:e}):Gr("span",{title:e,children:[ve("span",{className:"after:select-none after:content-['\u2026']",children:e.slice(0,6)}),ve("span",{className:"tracking-[-1ch] text-transparent",children:e.slice(6,-4)}),e.slice(-4)]})}import{jsx as B,jsxs as Ce}from"react/jsx-runtime";function pt({isActive:e,isExpanded:t,userAddress:n}){let{data:r}=te(n),{disconnect:o,isPending:s}=Wr(),{closeAccountModal:a}=h();return Ce("div",{className:"flex flex-col gap-4",children:[Ce("div",{className:"flex justify-between gap-4",children:[Ce("div",{children:[B("div",{children:"Account"}),B("div",{className:"font-mono text-white",children:r.name??B(ne,{hex:n})})]}),B(w,{variant:e?"primary":"secondary",className:"flex-shrink-0 text-sm p-1 w-28",pending:s,onClick:()=>{a(),o()},children:"Sign out"})]}),t?B("p",{className:"text-sm",children:"Each of your onchain actions in this app is associated with your account."}):null]})}import{useMutation as Ur,useQueryClient as qr}from"@tanstack/react-query";function ut(){let e=qr(),{passIssuerTransport:t}=p();return Ur({mutationKey:["claimGasPass"],onError:r=>console.error(r),mutationFn:async r=>{let o=t({retryCount:0});await o.request({method:"quarry_issuePass",params:["0x01",r]}),await o.request({method:"quarry_claimAllowance",params:["0x01",r]}),await Promise.all([e.invalidateQueries({queryKey:["getAllowance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{twMerge as Vr}from"tailwind-merge";import{jsx as re,jsxs as Qr}from"react/jsx-runtime";function mt({className:e,...t}){return Qr("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 263 428",fill:"currentColor",className:Vr("w-[0.6em] h-[1em]",e),...t,children:[re("path",{d:"M132 321V428L263 243L132 321Z"}),re("path",{d:"M0 243L132 321V428",fillOpacity:"0.5"}),re("path",{d:"M132 0V296L263 218"}),re("path",{d:"M0 218L132 296V0L0 218Z",fillOpacity:"0.5"})]})}import{formatEther as _r}from"viem";function ft(e){let t=_r(e),n=Math.floor(parseFloat(t)).toString().length;return parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:Math.max(0,6-n)})}import{jsx as Yr,jsxs as Xr}from"react/jsx-runtime";function yt({wei:e}){return Xr("span",{className:"inline-flex items-center gap-1",children:[ft(e)," ",Yr(mt,{})]})}import{useEffect as jr,useRef as $r}from"react";import{jsx as T,jsxs as Ae}from"react/jsx-runtime";function gt({isActive:e,isExpanded:t,userAddress:n}){let r=ot(n),o=ut(),s=$r(!1);return jr(()=>{e&&o.status==="idle"&&r.isSuccess&&r.data<J&&!s.current&&(s.current=!0,o.mutate(n,{onSettled:()=>s.current=!1}))},[r.data,r.isSuccess,o,e,n]),Ae("div",{className:"flex flex-col gap-4",children:[Ae("div",{className:"flex justify-between gap-4",children:[Ae("div",{children:[T("div",{children:"Allowance"}),T("div",{className:"font-mono text-white",children:r.data!=null?T(yt,{wei:r.data}):T(C,{className:"text-sm"})})]}),T(w,{variant:e?"primary":"secondary",className:"flex-shrink-0 text-sm p-1 w-28",pending:o.status==="pending",onClick:()=>o.mutate(n),children:"Top up"})]}),t?T("p",{className:"text-sm",children:"Your allowance is used to pay for onchain computation."}):null]})}import{useMutation as Jr,useQueryClient as Zr}from"@tanstack/react-query";import{getAction as oe}from"viem/utils";import{sendUserOperation as eo,waitForUserOperationReceipt as to}from"viem/account-abstraction";import{writeContract as ht}from"viem/actions";function wt(){let{worldAddress:e,paymasterAddress:t}=p(),n=Zr();return Jr({mutationKey:["setupSession"],onError:o=>console.error(o),mutationFn:async({userClient:o,sessionAddress:s,registerSpender:a,registerDelegation:d})=>{o.account.type!=="smart"&&(await oe(o,ht,"writeContract")({chain:o.chain,account:o.account,address:t,abi:we,functionName:"registerSpender",args:[s]}),await oe(o,ht,"writeContract")({chain:o.chain,account:o.account,address:e,abi:ge,functionName:"registerDelegation",args:[s,z,"0x"]}));let l=[];if(a&&(console.log("registering spender"),l.push({to:t,abi:we,functionName:"registerSpender",args:[s]})),d&&(console.log("registering delegation"),l.push({to:e,abi:ge,functionName:"registerDelegation",args:[s,z,"0x"]})),!l.length)return;console.log("setting up account with",l);let c=await oe(o,eo,"sendUserOperation")({calls:l});console.log("got user op hash",c);let i=await oe(o,to,"waitForUserOperationReceipt")({hash:c});console.log("got user op receipt",i),i.success&&await Promise.all([n.invalidateQueries({queryKey:["getSpender"]}),n.invalidateQueries({queryKey:["getDelegation"]}),n.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{useEffect as no,useRef as ro}from"react";import{jsx as F,jsxs as ke}from"react/jsx-runtime";function bt({isActive:e,isExpanded:t,userClient:n,registerSpender:r,registerDelegation:o}){let a=ee(n.account.address).data?.address,d=wt(),l=!o&&!o,c=ro(!1);return no(()=>{e&&d.status==="idle"&&a&&!l&&!c.current&&(c.current=!0,d.mutate({userClient:n,sessionAddress:a,registerSpender:r,registerDelegation:o},{onSettled:()=>c.current=!1}))},[e,l,o,r,a,d,n]),ke("div",{className:"flex flex-col gap-4",children:[ke("div",{className:"flex justify-between gap-4",children:[ke("div",{children:[F("div",{children:"Session"}),F("div",{className:"font-mono text-white",children:l?"Enabled":"Set up"})]}),l?F(w,{variant:e?"primary":"secondary",className:"flex-shrink-0 text-sm p-1 w-28",disabled:!0,children:"Disable"}):F(w,{variant:e?"primary":"secondary",className:"flex-shrink-0 text-sm p-1 w-28",pending:!a||d.status==="pending",onClick:a?()=>d.mutate({userClient:n,sessionAddress:a,registerSpender:r,registerDelegation:o}):void 0,children:"Enable"})]}),t?F("p",{className:"text-sm",children:"You can perform actions in this app without interruptions for approvals."}):null]})}import{jsx as E}from"react/jsx-runtime";function xt({userClient:e,initialAddress:t}){let n=e.account.address,{data:r}=N(n),{closeAccountModal:o}=h(),s=n!==t,a=io(r);oo(()=>{r!=null&&(a.current==null&&(a.current=r),r.complete&&(s||!a.current.complete)&&o())},[o,s,r]);let{hasAllowance:d,isSpender:l,hasDelegation:c}=r??{},i=ao(()=>n?[{id:"wallet",isComplete:!0,content:m=>E(pt,{...m,userAddress:n})},{id:"allowance",isComplete:!!d,content:m=>E(gt,{...m,userAddress:n})},{id:"session",isComplete:!!l&&!!c,content:m=>E(bt,{...m,userClient:e,registerSpender:!l,registerDelegation:!c})}]:[{id:"wallet",isComplete:!1,content:()=>null}],[d,c,l,n,e]),[u]=so(null),y=i.find(m=>m.content!=null&&!m.isComplete),g=i.filter(m=>m.isComplete),b=(u!=null?i.find(m=>m.id===u):null)??y??(g.length<i.length?g.at(-1):null),S=b?i.indexOf(b):-1;return E("div",{className:Se("min-h-[26rem] px-8 flex flex-col divide-y divide-neutral-800","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:i.map((m,ce)=>{let de=m===b,Ft=de||g.length===i.length,Gt=!m.isComplete&&S!==-1&&ce>S;return E("div",{className:Se("py-8 flex flex-col justify-center",de?"flex-grow":null),children:E("div",{className:Se("flex flex-col",Gt?"opacity-30 pointer-events-none":null),children:m.content({isActive:de,isExpanded:Ft})})},m.id)})})}import{useRef as po}from"react";import{jsx as vt}from"react/jsx-runtime";function Ct(){let{chainId:e}=p(),t=lo({chainId:e}),n=po(co().address);return t.status!=="success"?vt(nt,{}):vt(xt,{userClient:t.data,initialAddress:n.current})}import{useState as go}from"react";import{ErrorBoundary as ho}from"react-error-boundary";import{twMerge as uo}from"tailwind-merge";import{BaseError as mo,UserRejectedRequestError as fo}from"viem";import{jsx as At,jsxs as yo}from"react/jsx-runtime";function kt({title:e,error:t}){if(!t||t instanceof mo&&t.walk(o=>o instanceof fo)!=null)return null;let n=e??"Error",r=typeof t=="string"?t:t instanceof Error?String(t):"Something unexpected happened.";return yo("div",{className:uo("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:n}),At("div",{className:"px-3 whitespace-break-spaces break-all max-h-32 overflow-y-scroll",children:r})]})}import{wait as wo}from"@latticexyz/common/utils";import{twMerge as bo}from"tailwind-merge";import{useIsMounted as xo}from"usehooks-ts";import{jsx as ae,jsxs as St}from"react/jsx-runtime";function Pt({children:e}){let t=xo(),[n,r]=go(1);return ae(ho,{fallbackRender:({error:o,resetErrorBoundary:s})=>St("div",{className:bo("flex-grow flex flex-col justify-center p-5 gap-2"),children:[ae(kt,{error:o instanceof Error?o.stack??o.message:o}),n>0?St("button",{type:"button",onClick:async a=>{a.currentTarget.ariaBusy="true",await wo(1e3),s(),t()&&(r(d=>d-1),a.currentTarget.ariaBusy=null)},className:"group aria-busy:pointer-events-none self-end flex items-center gap-1",children:[ae(C,{className:"transition opacity-0 group-aria-busy:opacity-100 text-xs text-neutral-500 dark:text-neutral-400"}),ae("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 Ao,DialogTitle as ko}from"@radix-ui/react-dialog";import{twMerge as vo}from"tailwind-merge";import{jsx as Co}from"react/jsx-runtime";function Mt({className:e,children:t,...n}){return Co("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:vo("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...n,children:t})}import{jsx as It}from"react/jsx-runtime";function Nt(e){return It(Mt,{strokeWidth:"2",stroke:"currentColor",...e,children:It("path",{d:"M6 18L18 6M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as x,jsxs as Pe}from"react/jsx-runtime";function Et(){let{accountModalOpen:e,toggleAccountModal:t}=h();return Pe(Be,{open:e,onOpenChange:t,children:[x(ko,{className:"sr-only",children:"Connect with EntryKit"}),e?Pe("div",{className:Tt("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:[x(Pt,{children:x(Ct,{})}),Pe("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:[x("span",{className:"block w-4 h-4",children:x(A,{className:"w-full h-full text-orange-500 group-hover:rotate-90 transition duration-300"})}),x("span",{children:"Powered by MUD"})]}),x("div",{className:"absolute top-0 right-0",children:x(Ao,{className:Tt("pointer-events-auto leading-none p-2 transition","text-neutral-700 hover:text-neutral-500"),title:"Close",children:x(Nt,{className:"m-0"})})})]}):null]})}import{jsx as Po,jsxs as Mo}from"react/jsx-runtime";function So({config:e,children:t}){return Mo(Re,{config:e,children:[t,Po(Et,{})]})}import{useAccount as No}from"wagmi";import{twMerge as k}from"tailwind-merge";import{twMerge as Ht}from"tailwind-merge";import{Fragment as Io,jsx as ie,jsxs as Ot}from"react/jsx-runtime";function Rt({address:e}){let{data:t}=te(e),{isSuccess:n}=j(t.avatar);return Ot(Io,{children:[Ot("span",{className:"flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center",children:[ie("img",{src:n?t.avatar:void 0,className:Ht("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",n?"opacity-100":"opacity-0")}),ie(A,{className:Ht("col-start-1 row-start-1 text-orange-500","transition duration-300",n?"opacity-0":"opacity-100")})]}),ie("span",{className:"flex-grow",children:t.name??(e?ie(ne,{hex:e}):null)})]})}import{jsx as v,jsxs as zt}from"react/jsx-runtime";var Dt=k("w-48 inline-flex outline-none transition","border border-transparent","text-base leading-none"),To=k("bg-neutral-100 border-neutral-300 text-black","dark:bg-neutral-800 dark:border-neutral-700 dark:text-white"),Eo=k("cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700");function Ho(){let{openAccountModal:e,accountModalOpen:t}=h(),{status:n,address:r}=No(),o=N(r),s=n==="connected"||n==="reconnecting"&&r,a=o.isSuccess?o.data.complete:s,d=(()=>{if(o.isSuccess){if(!o.data.hasAllowance)return"Top up";if(!o.data.hasDelegation||!o.data.isSpender)return"Set up"}return"Sign in"})();return v(G,{mode:"child",children:a?v("button",{type:"button",className:k(Dt,To,Eo,"p-3"),onClick:e,children:v("span",{className:"flex-grow inline-flex gap-2.5 items-center text-left font-medium",children:v(Rt,{address:r})})},"connected"):zt("button",{type:"button",className:k(Dt,"group","items-center justify-center gap-2.5 p-3","bg-orange-500 text-white font-medium","hover:bg-orange-400","active:bg-orange-600"),"aria-busy":t,onClick:e,children:[zt("span",{className:"pointer-events-none inline-grid place-items-center -ml-3",children:[v("span",{className:k("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:v(A,{})}),v("span",{"aria-hidden":!0,className:k("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:v(C,{})})]}),v("span",{className:"font-medium",children:d})]},"sign in")})}import{useConnectorClient as Fo}from"wagmi";import{useClient as zo}from"wagmi";import{queryOptions as Ko,useQuery as Lo}from"@tanstack/react-query";import{smartAccountActions as Oo}from"permissionless";import{callFrom as Ro}from"@latticexyz/world/internal";import{observer as Do}from"@latticexyz/explorer/observer";async function Kt({sessionAccount:e,worldAddress:t,userAddress:n,client:r,bundlerTransport:o,paymasterAddress:s,explorerUrl:a}){return X({paymasterAddress:s,transport:o,client:r,account:e}).extend(Oo()).extend(Ro({worldAddress:t,delegatorAddress:n,publicClient:r})).extend(l=>a?Do({explorerUrl:a})(l):{}).extend(()=>({userAddress:n}))}function Bo({sessionAccount:e,client:t,userAddress:n,bundlerTransport:r,paymasterAddress:o,worldAddress:s,explorerUrl:a}){let d=["getSessionClient",t?.uid,n,e?.address,s,o,a];return Ko(t&&n&&e?{queryKey:d,queryFn:()=>Kt({sessionAccount:e,client:t,userAddress:n,worldAddress:s,bundlerTransport:r,paymasterAddress:o,explorerUrl:a}),staleTime:1/0}:{queryKey:d,enabled:!1})}function Lt(e){let{chainId:t,bundlerTransport:n,paymasterAddress:r,worldAddress:o,explorerUrl:s}=p(),a=zo({chainId:t}),{data:d}=ee(e);return Lo(Bo({sessionAccount:d,userAddress:e,client:a,bundlerTransport:n,paymasterAddress:r,worldAddress:o,explorerUrl:s}))}function Go(){let{chainId:e}=p(),t=Fo({chainId:e});t.error&&console.error("Error retrieving user client",t.error);let n=t.data?.account.address,r=N(n),o=Lt(n);return t.isSuccess?!r.isSuccess||!r.data.complete?{...r,data:void 0}:o:{...t,data:void 0}}import{connectorsForWallets as Uo,getDefaultWallets as qo}from"@rainbow-me/rainbowkit";import{createConfig as Vo}from"wagmi";var Wo=`data:image/svg+xml;base64,${btoa('<svg xmlns="http://www.w3.org/2000/svg" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" width="512" height="512" viewBox="-64 -32 608 512"><path d="M6.206 425.469A6.202 6.202 0 010 419.263c0-1.771.235-3.517.663-5.245 9.95-78.847 57.22-96.006 100.964-107.256 21.008-5.412 62.901-26.489 57.822-53.668-10.596-9.819-21.113-23.39-22.946-43.63l-1.274.026c-2.932-.044-5.778-.716-8.422-2.217-5.848-3.325-9.051-9.697-10.596-16.958-3.238-22.186-4.058-33.515 7.768-38.464l.096-.035c-1.467-27.37 3.159-67.64-24.944-76.141C154.622 7.1 218.597-30.203 266.627 30.805c53.519 2.801 77.389 78.611 44.154 121.046h-1.405c11.826 4.949 10.045 17.674 7.767 38.464-1.544 7.261-4.747 13.633-10.595 16.958-2.645 1.501-5.481 2.173-8.422 2.217l-1.275-.026c-1.833 20.24-12.376 33.811-22.972 43.63-4.459 23.871 27.275 43.011 49.33 50.997a139.442 139.442 0 004.268 5.525c-7.2 9.941-8.771 22.797-4.564 34.038-17.002 8.763-24.255 29.334-16.479 46.86-11.966 7.55-18.258 21.305-16.609 34.955H6.206zm419.058-105.362a86.778 86.778 0 0019.446-1.641c29.36-5.822 53.152-27.467 62.657-55.823 3.596-10.544 5.071-21.663 4.521-33.341-1.179-23.46-12.193-46.633-29.631-62.369-17.107-15.361-38.342-23.574-61.383-23.042-22.841.507-45.359 11.216-60.187 28.593-14.977 17.551-22.003 39.144-20.921 62.133.585 11.661 3.482 23.016 8.737 34.074 7.741 16.303 19.934 29.735 35.391 39.048l-22.457 20.711 13.232 27.86-29.413 13.973 13.991 29.456-26.769 12.717 16.81 35.374 35.601-16.915 40.375-110.808zm15.239-129.364c13.685 4.869 20.824 19.908 15.954 33.593-4.87 13.685-19.908 20.833-33.593 15.963-13.685-4.87-20.834-19.917-15.963-33.602 4.87-13.685 19.917-20.825 33.602-15.954z"/></svg>')}`,se=e=>()=>({id:"passkey",name:"Passkey",iconUrl:Wo,iconBackground:"#fec",createConnector:t=>n=>({...M(e)(n),...t})});function Qo(e){let{wallets:t}=qo(),n=[{groupName:"Recommended",wallets:[se({chainId:e.chainId,bundlerTransport:e.bundlerTransport,paymasterAddress:e.paymasterAddress})]},...t],r=Uo(n,{appName:e.appInfo.name,projectId:e.walletConnectProjectId});return Vo({connectors:r,chains:e.chains,transports:e.transports})}function kp(e){return e!=null&&"__isCoinbaseSmartAccount"in e&&e.__isCoinbaseSmartAccount===!0}var Pp=new Set([17420,31337]);function Mp(e){return t=>{let{request:n,...r}=e(t),o=null,s=new Map;return{...r,async request(a){if(a.method==="eth_chainId")return o??(o=await n(a));if(a.method==="eth_call")return n({...a,method:"wiresaw_call"});if(a.method==="eth_getTransactionReceipt"){let d=a.params[0],l=s.get(d)??await n(a);return s.has(d)||s.set(d,l),l}if(a.method==="eth_sendUserOperation"){let d=await n({...a,method:"wiresaw_sendUserOperation"});return s.set(d.userOpHash,{success:!0,userOpHash:d.userOpHash,receipt:{transactionHash:d.txHash}}),d.userOpHash}if(a.method==="eth_getUserOperationReceipt"){let d=a.params[0],l=s.get(d)??await n(a);return s.has(d)||s.set(d,l),l}return n(a)}}}}import{connectorsForWallets as Yo}from"@rainbow-me/rainbowkit";import{getDefaultWallets as _o}from"@rainbow-me/rainbowkit";function Bt(e){let{wallets:t}=_o();return[{groupName:"Recommended",wallets:[se({chainId:e.chainId,bundlerTransport:e.bundlerTransport,paymasterAddress:e.paymasterAddress})]},...t]}function zp({wallets:e,...t}){return Yo(e??Bt(t),{appName:t.appInfo?.name??document.title,projectId:t.walletConnectProjectId})}export{Ho as AccountButton,So as EntryKitProvider,V as abi,Qo as createWagmiConfig,zp as getConnectors,Bt as getWallets,kp as isCoinbaseSmartAccount,M as passkeyConnector,se as passkeyWallet,q as sign,Q as toCoinbaseSmartAccount,me as toReplaySafeHash,Nn as toWebAuthnSignature,h as useAccountModal,p as useEntryKitConfig,Go as useSessionClient,Mp as wiresaw,Pp as wiresawChainIds,R as wrapSignature};
|
|
1427
|
+
URL: ${e}`)),r.src=e})})}import{jsx as $,jsxs as sr}from"react/jsx-runtime";function Ze(){let{appName:e,appIcon:t}=Je(),{data:n,isLoading:r}=j(t);return sr("div",{className:"flex-grow flex flex-col items-center justify-center gap-2",children:[$("div",{className:"w-16 h-16 m-2",children:r?null:n?$("img",{src:t,className:"w-full h-full object-cover"}):$(A,{className:"w-full h-full text-orange-500 dark:bg-neutral-800"})}),$("div",{className:"text-2xl text-white text-center",children:e})]})}import{twMerge as lr}from"tailwind-merge";import{jsx as K,jsxs as tt}from"react/jsx-runtime";function nt(){let e=cr(),{accountModalOpen:t}=h(),{openConnectModal:n,connectModalOpen:r}=dr(),o=$e(),a=et({onError:c=>console.error(c),mutationKey:["createPasskey",o.id,t,r,e.status],mutationFn:()=>o.createPasskey()}),i=et({onError:c=>console.error(c),mutationKey:["reusePasskey",o.id,t,r,e.status],mutationFn:()=>o.reusePasskey()}),d=o.hasPasskey(),l=[K(w,{variant:d?"secondary":"primary",className:"self-auto flex justify-center",pending:a.status==="pending",onClick:()=>a.mutate(),autoFocus:!d,children:"Create account"},"create"),K(w,{variant:d?"primary":"secondary",className:"self-auto flex justify-center",pending:i.status==="pending",onClick:()=>i.mutate(),autoFocus:d,children:"Sign in"},"signin")];return d&&l.reverse(),tt("div",{className:lr("flex flex-col gap-6 p-6","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:[K("div",{className:"p-4",children:K(Ze,{})}),tt("div",{className:"self-center flex flex-col gap-2 w-60",children:[l,K("button",{className:"text-sm self-center transition text-neutral-500 hover:text-white p-2",disabled:e.status==="connecting",onClick:n,children:"Already have a wallet?"})]})]})}import{useEffect as oo,useMemo as ao,useRef as io,useState as so}from"react";import{twMerge as Se}from"tailwind-merge";import{parseEther as pr}from"viem";var J=pr("0.01");import{useClient as Cr}from"wagmi";import{queryOptions as Ar,useQuery as kr}from"@tanstack/react-query";import{defineStore as ur}from"@latticexyz/store";import{parseAbi as mr}from"viem";var we=mr(["error SpenderSystem_AlreadyRegistered(address spender, address user)","error SpenderSystem_HasOwnBalance(address spender)","function registerSpender(address spender)"]),fr=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:[]}}}}}),Z=fr.namespaces.root.tables;import{decodeValueArgs as yr,getKeyTuple as gr,getSchemaTypes as hr,getValueSchema as wr}from"@latticexyz/protocol-parser/internal";import{readContract as br}from"viem/actions";import{getAction as xr}from"viem/utils";async function I(e,{address:t,table:n,key:r,blockTag:o}){let[a,i,d]=await xr(e,br,"readContract")({address:t,abi:vr,functionName:"getRecord",args:[n.tableId,gr(n,r)],blockTag:o});return{...r,...yr(hr(wr(n)),{staticData:a,encodedLengths:i,dynamicData:d})}}var vr=[{type:"function",name:"getRecord",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[{name:"staticData",type:"bytes",internalType:"bytes"},{name:"encodedLengths",type:"bytes32",internalType:"EncodedLengths"},{name:"dynamicData",type:"bytes",internalType:"bytes"}],stateMutability:"view"}];async function rt({client:e,paymasterAddress:t,userAddress:n}){return(await I(e,{address:t,table:Z.Allowance,key:{user:n}})).allowance}function be({client:e,paymasterAddress:t,userAddress:n}){let r=["getAllowance",e?.chain.id,t,n];return Ar(e&&n?{queryKey:r,queryFn:()=>rt({client:e,paymasterAddress:t,userAddress:n})}:{queryKey:r,enabled:!1})}function ot(e){let{chainId:t,paymasterAddress:n}=p(),r=Cr({chainId:t});return kr(be({client:r,paymasterAddress:n,userAddress:e}))}import{useClient as sc}from"wagmi";import{queryOptions as Sr,useQuery as dc}from"@tanstack/react-query";async function at({client:e,paymasterAddress:t,userAddress:n,sessionAddress:r}){return(await I(e,{address:t,table:Z.Spender,key:{spender:r}})).user.toLowerCase()===n.toLowerCase()}function it({client:e,paymasterAddress:t,userAddress:n,sessionAddress:r}){let o=["getSpender",e?.chain.id,t,n,r];return Sr(e&&n&&r?{queryKey:o,queryFn:()=>at({client:e,paymasterAddress:t,userAddress:n,sessionAddress:r})}:{queryKey:o,enabled:!1})}import{useClient as hc}from"wagmi";import{queryOptions as Pr,useQuery as bc}from"@tanstack/react-query";async function st({client:e,worldAddress:t,userAddress:n,sessionAddress:r}){return(await I(e,{address:t,table:Xe.UserDelegationControl,key:{delegator:n,delegatee:r}})).delegationControlId===z}function ct({client:e,worldAddress:t,userAddress:n,sessionAddress:r}){let o=["getDelegation",e?.chain.id,t,n,r];return Pr(e&&n&&r?{queryKey:o,queryFn:()=>st({client:e,worldAddress:t,userAddress:n,sessionAddress:r})}:{queryKey:o,enabled:!1})}import{queryOptions as Dr,useQuery as zr,useQueryClient as Kr}from"@tanstack/react-query";import{useClient as Lr}from"wagmi";import{useClient as Hr}from"wagmi";import{queryOptions as Or,useQuery as Rr}from"@tanstack/react-query";import{createStore as Mr}from"zustand/vanilla";import{persist as Ir}from"zustand/middleware";var L=Mr(Ir(()=>({signers:{}}),{name:"mud:entrykit",partialize:({signers:e})=>({signers:e})}));function Nr(e){e.key===L.persist.getOptions().name&&L.persist.rehydrate()}window.addEventListener("storage",Nr);import{generatePrivateKey as Tr,privateKeyToAccount as Er}from"viem/accounts";function dt(e){let t=L.getState().signers[e]??(()=>{let n=Tr();return L.setState(r=>({signers:{...r.signers,[e]:n}})),n})();return Er(t)}async function lt({client:e,userAddress:t}){let n=dt(t);return await Q({client:e,owners:[n]})}function xe({client:e,userAddress:t}){let n=["getSessionAccount",e?.chain.id,t];return Or(e&&t?{queryKey:n,queryFn:()=>lt({client:e,userAddress:t}),staleTime:1/0}:{queryKey:n,enabled:!1})}function ee(e){let{chainId:t}=p(),n=Hr({chainId:t});return Rr(xe({userAddress:e,client:n}))}function Br({queryClient:e,client:t,userAddress:n,paymasterAddress:r,worldAddress:o}){let a=["getPrerequisites",t?.chain.id,n];return Dr(t&&n?{queryKey:a,queryFn:async()=>{let{address:i}=await e.fetchQuery(xe({client:t,userAddress:n})),[d,l,c]=await Promise.all([e.fetchQuery(be({client:t,paymasterAddress:r,userAddress:n})),e.fetchQuery(it({client:t,paymasterAddress:r,userAddress:n,sessionAddress:i})),e.fetchQuery(ct({client:t,worldAddress:o,userAddress:n,sessionAddress:i}))]),s=d>=J;return{hasAllowance:s,isSpender:l,hasDelegation:c,complete:s&&l&&c}}}:{queryKey:a,enabled:!1})}function N(e){let t=Kr(),{chainId:n,paymasterAddress:r,worldAddress:o}=p(),a=Lr({chainId:n});return zr(Br({queryClient:t,client:a,userAddress:e,paymasterAddress:r,worldAddress:o}),t)}import{useDisconnect as Wr}from"wagmi";import{useQuery as Fr}from"@tanstack/react-query";function te(e){let t=e?.toLowerCase();return Fr({enabled:!!t,queryKey:["ens",t],initialData:{address:void 0,name:void 0,displayName:void 0,avatar:void 0},queryFn:async()=>{let n=await fetch(`https://api.ensideas.com/ens/resolve/${t}`).then(r=>r.json());return{address:n.address??void 0,name:n.name??void 0,displayName:n.displayName??void 0,avatar:n.avatar??void 0}}})}import{jsx as ve,jsxs as Gr}from"react/jsx-runtime";function ne({hex:e}){return e.length<=10?ve("span",{title:e,children:e}):Gr("span",{title:e,children:[ve("span",{className:"after:select-none after:content-['\u2026']",children:e.slice(0,6)}),ve("span",{className:"tracking-[-1ch] text-transparent",children:e.slice(6,-4)}),e.slice(-4)]})}import{jsx as B,jsxs as Ce}from"react/jsx-runtime";function pt({isActive:e,isExpanded:t,userAddress:n}){let{data:r}=te(n),{disconnect:o,isPending:a}=Wr(),{closeAccountModal:i}=h();return Ce("div",{className:"flex flex-col gap-4",children:[Ce("div",{className:"flex justify-between gap-4",children:[Ce("div",{children:[B("div",{children:"Account"}),B("div",{className:"font-mono text-white",children:r.name??B(ne,{hex:n})})]}),B(w,{variant:e?"primary":"secondary",className:"flex-shrink-0 text-sm p-1 w-28",pending:a,onClick:()=>{i(),o()},children:"Sign out"})]}),t?B("p",{className:"text-sm",children:"Each of your onchain actions in this app is associated with your account."}):null]})}import{useMutation as Ur,useQueryClient as qr}from"@tanstack/react-query";function ut(){let e=qr(),{passIssuerTransport:t}=p();return Ur({mutationKey:["claimGasPass"],onError:r=>console.error(r),mutationFn:async r=>{let o=t({retryCount:0});await o.request({method:"quarry_issuePass",params:["0x01",r]}),await o.request({method:"quarry_claimAllowance",params:["0x01",r]}),await Promise.all([e.invalidateQueries({queryKey:["getAllowance"]}),e.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{twMerge as Vr}from"tailwind-merge";import{jsx as re,jsxs as Qr}from"react/jsx-runtime";function mt({className:e,...t}){return Qr("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 263 428",fill:"currentColor",className:Vr("w-[0.6em] h-[1em]",e),...t,children:[re("path",{d:"M132 321V428L263 243L132 321Z"}),re("path",{d:"M0 243L132 321V428",fillOpacity:"0.5"}),re("path",{d:"M132 0V296L263 218"}),re("path",{d:"M0 218L132 296V0L0 218Z",fillOpacity:"0.5"})]})}import{formatEther as _r}from"viem";function ft(e){let t=_r(e),n=Math.floor(parseFloat(t)).toString().length;return parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:Math.max(0,6-n)})}import{jsx as Yr,jsxs as Xr}from"react/jsx-runtime";function yt({wei:e}){return Xr("span",{className:"inline-flex items-center gap-1",children:[ft(e)," ",Yr(mt,{})]})}import{useEffect as jr,useRef as $r}from"react";import{jsx as T,jsxs as Ae}from"react/jsx-runtime";function gt({isActive:e,isExpanded:t,userAddress:n}){let r=ot(n),o=ut(),a=$r(!1);return jr(()=>{e&&o.status==="idle"&&r.isSuccess&&r.data<J&&!a.current&&(a.current=!0,o.mutate(n,{onSettled:()=>a.current=!1}))},[r.data,r.isSuccess,o,e,n]),Ae("div",{className:"flex flex-col gap-4",children:[Ae("div",{className:"flex justify-between gap-4",children:[Ae("div",{children:[T("div",{children:"Allowance"}),T("div",{className:"font-mono text-white",children:r.data!=null?T(yt,{wei:r.data}):T(C,{className:"text-sm"})})]}),T(w,{variant:e?"primary":"secondary",className:"flex-shrink-0 text-sm p-1 w-28",pending:o.status==="pending",onClick:()=>o.mutate(n),children:"Top up"})]}),t?T("p",{className:"text-sm",children:"Your allowance is used to pay for onchain computation."}):null]})}import{useMutation as Jr,useQueryClient as Zr}from"@tanstack/react-query";import{getAction as oe}from"viem/utils";import{sendUserOperation as eo,waitForUserOperationReceipt as to}from"viem/account-abstraction";import{writeContract as ht}from"viem/actions";function wt(){let{worldAddress:e,paymasterAddress:t}=p(),n=Zr();return Jr({mutationKey:["setupSession"],onError:o=>console.error(o),mutationFn:async({userClient:o,sessionAddress:a,registerSpender:i,registerDelegation:d})=>{o.account.type!=="smart"&&(await oe(o,ht,"writeContract")({chain:o.chain,account:o.account,address:t,abi:we,functionName:"registerSpender",args:[a]}),await oe(o,ht,"writeContract")({chain:o.chain,account:o.account,address:e,abi:ge,functionName:"registerDelegation",args:[a,z,"0x"]}));let l=[];if(i&&(console.log("registering spender"),l.push({to:t,abi:we,functionName:"registerSpender",args:[a]})),d&&(console.log("registering delegation"),l.push({to:e,abi:ge,functionName:"registerDelegation",args:[a,z,"0x"]})),!l.length)return;console.log("setting up account with",l);let c=await oe(o,eo,"sendUserOperation")({calls:l});console.log("got user op hash",c);let s=await oe(o,to,"waitForUserOperationReceipt")({hash:c});if(console.log("got user op receipt",s),!s.success){console.error("not successful?",s);return}await Promise.all([n.invalidateQueries({queryKey:["getSpender"]}),n.invalidateQueries({queryKey:["getDelegation"]}),n.invalidateQueries({queryKey:["getPrerequisites"]})])},retry:0})}import{useEffect as no,useRef as ro}from"react";import{jsx as F,jsxs as ke}from"react/jsx-runtime";function bt({isActive:e,isExpanded:t,userClient:n,registerSpender:r,registerDelegation:o}){let i=ee(n.account.address).data?.address,d=wt(),l=!o&&!o,c=ro(!1);return no(()=>{e&&d.status==="idle"&&i&&!l&&!c.current&&(c.current=!0,d.mutate({userClient:n,sessionAddress:i,registerSpender:r,registerDelegation:o},{onSettled:()=>c.current=!1}))},[e,l,o,r,i,d,n]),ke("div",{className:"flex flex-col gap-4",children:[ke("div",{className:"flex justify-between gap-4",children:[ke("div",{children:[F("div",{children:"Session"}),F("div",{className:"font-mono text-white",children:l?"Enabled":"Set up"})]}),l?F(w,{variant:e?"primary":"secondary",className:"flex-shrink-0 text-sm p-1 w-28",disabled:!0,children:"Enabled"}):F(w,{variant:e?"primary":"secondary",className:"flex-shrink-0 text-sm p-1 w-28",pending:!i||d.status==="pending",onClick:i?()=>d.mutate({userClient:n,sessionAddress:i,registerSpender:r,registerDelegation:o}):void 0,children:"Enable"})]}),t?F("p",{className:"text-sm",children:"You can perform actions in this app without interruptions for approvals."}):null]})}import{jsx as E}from"react/jsx-runtime";function xt({userClient:e,initialAddress:t}){let n=e.account.address,{data:r}=N(n),{closeAccountModal:o}=h(),a=n!==t,i=io(r);oo(()=>{r!=null&&(i.current==null&&(i.current=r),r.complete&&(a||!i.current.complete)&&o())},[o,a,r]);let{hasAllowance:d,isSpender:l,hasDelegation:c}=r??{},s=ao(()=>n?[{id:"wallet",isComplete:!0,content:m=>E(pt,{...m,userAddress:n})},{id:"allowance",isComplete:!!d,content:m=>E(gt,{...m,userAddress:n})},{id:"session",isComplete:!!l&&!!c,content:m=>E(bt,{...m,userClient:e,registerSpender:!l,registerDelegation:!c})}]:[{id:"wallet",isComplete:!1,content:()=>null}],[d,c,l,n,e]),[u]=so(null),y=s.find(m=>m.content!=null&&!m.isComplete),g=s.filter(m=>m.isComplete),b=(u!=null?s.find(m=>m.id===u):null)??y??(g.length<s.length?g.at(-1):null),S=b?s.indexOf(b):-1;return E("div",{className:Se("min-h-[26rem] px-8 flex flex-col divide-y divide-neutral-800","animate-in animate-duration-300 fade-in slide-in-from-bottom-8"),children:s.map((m,ce)=>{let de=m===b,Ft=de||g.length===s.length,Gt=!m.isComplete&&S!==-1&&ce>S;return E("div",{className:Se("py-8 flex flex-col justify-center",de?"flex-grow":null),children:E("div",{className:Se("flex flex-col",Gt?"opacity-30 pointer-events-none":null),children:m.content({isActive:de,isExpanded:Ft})})},m.id)})})}import{useRef as po}from"react";import{jsx as vt}from"react/jsx-runtime";function Ct(){let{chainId:e}=p(),t=lo({chainId:e}),n=po(co().address);return t.status!=="success"?vt(nt,{}):vt(xt,{userClient:t.data,initialAddress:n.current})}import{useState as go}from"react";import{ErrorBoundary as ho}from"react-error-boundary";import{twMerge as uo}from"tailwind-merge";import{BaseError as mo,UserRejectedRequestError as fo}from"viem";import{jsx as At,jsxs as yo}from"react/jsx-runtime";function kt({title:e,error:t}){if(!t||t instanceof mo&&t.walk(o=>o instanceof fo)!=null)return null;let n=e??"Error",r=typeof t=="string"?t:t instanceof Error?String(t):"Something unexpected happened.";return yo("div",{className:uo("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:n}),At("div",{className:"px-3 whitespace-break-spaces break-all max-h-32 overflow-y-scroll",children:r})]})}import{wait as wo}from"@latticexyz/common/utils";import{twMerge as bo}from"tailwind-merge";import{useIsMounted as xo}from"usehooks-ts";import{jsx as ae,jsxs as St}from"react/jsx-runtime";function Pt({children:e}){let t=xo(),[n,r]=go(1);return ae(ho,{fallbackRender:({error:o,resetErrorBoundary:a})=>St("div",{className:bo("flex-grow flex flex-col justify-center p-5 gap-2"),children:[ae(kt,{error:o instanceof Error?o.stack??o.message:o}),n>0?St("button",{type:"button",onClick:async i=>{i.currentTarget.ariaBusy="true",await wo(1e3),a(),t()&&(r(d=>d-1),i.currentTarget.ariaBusy=null)},className:"group aria-busy:pointer-events-none self-end flex items-center gap-1",children:[ae(C,{className:"transition opacity-0 group-aria-busy:opacity-100 text-xs text-neutral-500 dark:text-neutral-400"}),ae("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 Ao,DialogTitle as ko}from"@radix-ui/react-dialog";import{twMerge as vo}from"tailwind-merge";import{jsx as Co}from"react/jsx-runtime";function Mt({className:e,children:t,...n}){return Co("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:vo("-my-[0.125em] h-[1.25em] w-[1.25em]",e),...n,children:t})}import{jsx as It}from"react/jsx-runtime";function Nt(e){return It(Mt,{strokeWidth:"2",stroke:"currentColor",...e,children:It("path",{d:"M6 18L18 6M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as x,jsxs as Pe}from"react/jsx-runtime";function Et(){let{accountModalOpen:e,toggleAccountModal:t}=h();return Pe(Be,{open:e,onOpenChange:t,children:[x(ko,{className:"sr-only",children:"Connect with EntryKit"}),e?Pe("div",{className:Tt("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:[x(Pt,{children:x(Ct,{})}),Pe("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:[x("span",{className:"block w-4 h-4",children:x(A,{className:"w-full h-full text-orange-500 group-hover:rotate-90 transition duration-300"})}),x("span",{children:"Powered by MUD"})]}),x("div",{className:"absolute top-0 right-0",children:x(Ao,{className:Tt("pointer-events-auto leading-none p-2 transition","text-neutral-700 hover:text-neutral-500"),title:"Close",children:x(Nt,{className:"m-0"})})})]}):null]})}import{jsx as Po,jsxs as Mo}from"react/jsx-runtime";function So({config:e,children:t}){return Mo(Re,{config:e,children:[t,Po(Et,{})]})}import{useAccount as No}from"wagmi";import{twMerge as k}from"tailwind-merge";import{twMerge as Ht}from"tailwind-merge";import{Fragment as Io,jsx as ie,jsxs as Ot}from"react/jsx-runtime";function Rt({address:e}){let{data:t}=te(e),{isSuccess:n}=j(t.avatar);return Ot(Io,{children:[Ot("span",{className:"flex-shrink-0 w-6 h-6 -my-1 -mx-0.5 grid place-items-center",children:[ie("img",{src:n?t.avatar:void 0,className:Ht("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",n?"opacity-100":"opacity-0")}),ie(A,{className:Ht("col-start-1 row-start-1 text-orange-500","transition duration-300",n?"opacity-0":"opacity-100")})]}),ie("span",{className:"flex-grow",children:t.name??(e?ie(ne,{hex:e}):null)})]})}import{useRef as To}from"react";import{jsx as v,jsxs as zt}from"react/jsx-runtime";var Dt=k("w-48 p-3 inline-flex outline-none transition","border border-transparent","text-base leading-none"),Eo=k("bg-neutral-100 border-neutral-300 text-black","dark:bg-neutral-800 dark:border-neutral-700 dark:text-white"),Ho=k("cursor-pointer outline-none hover:bg-neutral-200 data-[highlighted]:bg-neutral-200 dark:hover:bg-neutral-700");function Oo(){let{openAccountModal:e,accountModalOpen:t}=h(),{status:n,address:r}=No(),o=To(r),a=N(r),i=n==="connected"||n==="reconnecting"&&r,d=r!==o.current,l=a.isSuccess?a.data.complete:d?!1:i,c=(()=>{if(a.isSuccess){if(!a.data.hasAllowance)return"Top up";if(!a.data.hasDelegation||!a.data.isSpender)return"Set up"}return"Sign in"})();return v(G,{mode:"child",children:l?v("button",{type:"button",className:k(Dt,Eo,Ho),onClick:e,children:v("span",{className:"flex-grow inline-flex gap-2.5 items-center text-left font-medium",children:v(Rt,{address:r})})},"connected"):zt("button",{type:"button",className:k(Dt,"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:[zt("span",{className:"pointer-events-none inline-grid place-items-center -ml-3",children:[v("span",{className:k("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:v(A,{})}),v("span",{"aria-hidden":!0,className:k("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:v(C,{})})]}),v("span",{className:"font-medium",children:c})]},"sign in")})}import{useConnectorClient as Go}from"wagmi";import{useClient as Ko}from"wagmi";import{queryOptions as Lo,useQuery as Bo}from"@tanstack/react-query";import{smartAccountActions as Ro}from"permissionless";import{callFrom as Do}from"@latticexyz/world/internal";import{observer as zo}from"@latticexyz/explorer/observer";async function Kt({sessionAccount:e,worldAddress:t,userAddress:n,client:r,bundlerTransport:o,paymasterAddress:a,explorerUrl:i}){return X({paymasterAddress:a,transport:o,client:r,account:e}).extend(Ro()).extend(Do({worldAddress:t,delegatorAddress:n,publicClient:r})).extend(l=>i?zo({explorerUrl:i})(l):{}).extend(()=>({userAddress:n}))}function Fo({sessionAccount:e,client:t,userAddress:n,bundlerTransport:r,paymasterAddress:o,worldAddress:a,explorerUrl:i}){let d=["getSessionClient",t?.uid,n,e?.address,a,o,i];return Lo(t&&n&&e?{queryKey:d,queryFn:()=>Kt({sessionAccount:e,client:t,userAddress:n,worldAddress:a,bundlerTransport:r,paymasterAddress:o,explorerUrl:i}),staleTime:1/0}:{queryKey:d,enabled:!1})}function Lt(e){let{chainId:t,bundlerTransport:n,paymasterAddress:r,worldAddress:o,explorerUrl:a}=p(),i=Ko({chainId:t}),{data:d}=ee(e);return Bo(Fo({sessionAccount:d,userAddress:e,client:i,bundlerTransport:n,paymasterAddress:r,worldAddress:o,explorerUrl:a}))}function Wo(){let{chainId:e}=p(),t=Go({chainId:e});t.error&&console.error("Error retrieving user client",t.error);let n=t.data?.account.address,r=N(n),o=Lt(n);return t.isSuccess?!r.isSuccess||!r.data.complete?{...r,data:void 0}:o:{...t,data:void 0}}import{connectorsForWallets as qo,getDefaultWallets as Vo}from"@rainbow-me/rainbowkit";import{createConfig as Qo}from"wagmi";var Uo=`data:image/svg+xml;base64,${btoa('<svg xmlns="http://www.w3.org/2000/svg" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" width="512" height="512" viewBox="-64 -32 608 512"><path d="M6.206 425.469A6.202 6.202 0 010 419.263c0-1.771.235-3.517.663-5.245 9.95-78.847 57.22-96.006 100.964-107.256 21.008-5.412 62.901-26.489 57.822-53.668-10.596-9.819-21.113-23.39-22.946-43.63l-1.274.026c-2.932-.044-5.778-.716-8.422-2.217-5.848-3.325-9.051-9.697-10.596-16.958-3.238-22.186-4.058-33.515 7.768-38.464l.096-.035c-1.467-27.37 3.159-67.64-24.944-76.141C154.622 7.1 218.597-30.203 266.627 30.805c53.519 2.801 77.389 78.611 44.154 121.046h-1.405c11.826 4.949 10.045 17.674 7.767 38.464-1.544 7.261-4.747 13.633-10.595 16.958-2.645 1.501-5.481 2.173-8.422 2.217l-1.275-.026c-1.833 20.24-12.376 33.811-22.972 43.63-4.459 23.871 27.275 43.011 49.33 50.997a139.442 139.442 0 004.268 5.525c-7.2 9.941-8.771 22.797-4.564 34.038-17.002 8.763-24.255 29.334-16.479 46.86-11.966 7.55-18.258 21.305-16.609 34.955H6.206zm419.058-105.362a86.778 86.778 0 0019.446-1.641c29.36-5.822 53.152-27.467 62.657-55.823 3.596-10.544 5.071-21.663 4.521-33.341-1.179-23.46-12.193-46.633-29.631-62.369-17.107-15.361-38.342-23.574-61.383-23.042-22.841.507-45.359 11.216-60.187 28.593-14.977 17.551-22.003 39.144-20.921 62.133.585 11.661 3.482 23.016 8.737 34.074 7.741 16.303 19.934 29.735 35.391 39.048l-22.457 20.711 13.232 27.86-29.413 13.973 13.991 29.456-26.769 12.717 16.81 35.374 35.601-16.915 40.375-110.808zm15.239-129.364c13.685 4.869 20.824 19.908 15.954 33.593-4.87 13.685-19.908 20.833-33.593 15.963-13.685-4.87-20.834-19.917-15.963-33.602 4.87-13.685 19.917-20.825 33.602-15.954z"/></svg>')}`,se=e=>()=>({id:"passkey",name:"Passkey",iconUrl:Uo,iconBackground:"#fec",createConnector:t=>n=>({...M(e)(n),...t})});function _o(e){let{wallets:t}=Vo(),n=[{groupName:"Recommended",wallets:[se({chainId:e.chainId,bundlerTransport:e.bundlerTransport,paymasterAddress:e.paymasterAddress})]},...t],r=qo(n,{appName:e.appInfo.name,projectId:e.walletConnectProjectId});return Qo({connectors:r,chains:e.chains,transports:e.transports})}function Pp(e){return e!=null&&"__isCoinbaseSmartAccount"in e&&e.__isCoinbaseSmartAccount===!0}var Ip=new Set([17420,31337]);function Np(e){return t=>{let{request:n,...r}=e(t),o=null,a=new Map;return{...r,async request(i){if(i.method==="eth_chainId")return o??(o=await n(i));if(i.method==="eth_call")return n({...i,method:"wiresaw_call"});if(i.method==="eth_getTransactionReceipt"){let d=i.params[0],l=a.get(d)??await n(i);return a.has(d)||a.set(d,l),l}if(i.method==="eth_sendUserOperation"){let d=await n({...i,method:"wiresaw_sendUserOperation"});return a.set(d.userOpHash,{success:!0,userOpHash:d.userOpHash,receipt:{transactionHash:d.txHash}}),d.userOpHash}if(i.method==="eth_getUserOperationReceipt"){let d=i.params[0],l=a.get(d)??await n(i);return a.has(d)||a.set(d,l),l}return n(i)}}}}import{connectorsForWallets as Xo}from"@rainbow-me/rainbowkit";import{getDefaultWallets as Yo}from"@rainbow-me/rainbowkit";function Bt(e){let{wallets:t}=Yo();return[{groupName:"Recommended",wallets:[se({chainId:e.chainId,bundlerTransport:e.bundlerTransport,paymasterAddress:e.paymasterAddress})]},...t]}function Lp({wallets:e,...t}){return Xo(e??Bt(t),{appName:t.appInfo?.name??document.title,projectId:t.walletConnectProjectId})}export{Oo as AccountButton,So as EntryKitProvider,V as abi,_o as createWagmiConfig,Lp as getConnectors,Bt as getWallets,Pp as isCoinbaseSmartAccount,M as passkeyConnector,se as passkeyWallet,q as sign,Q as toCoinbaseSmartAccount,me as toReplaySafeHash,Nn as toWebAuthnSignature,h as useAccountModal,p as useEntryKitConfig,Wo as useSessionClient,Np as wiresaw,Ip as wiresawChainIds,R as wrapSignature};
|
|
1428
1428
|
//# sourceMappingURL=internal.js.map
|