"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1959],{91959:function(e,t,i){i.d(t,{r:function(){return eC}});var n=i(31549),s=i(10857),l=i(12639),r=i(36489),a=i(42883),c=i(4803),o=i(28713),d=i(70438),u=i(63059),p=i(55836),x=i(84085),h=i(44194),m=i(10085),f=i(51452);let b={to:x.Rl,value:(0,o.L)("0.001")};function S(){let{status:e,chain:t}=(0,d.m)();return Number(null==t?void 0:t.id)!==m.R.id&&"connected"===e?(0,n.jsx)(j,{}):(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:"Feature not available on Ethereum Mainnet"})}function j(){let e=(0,f.p)(),{refetch:t,isFetching:i}=(0,u.N)({...b,query:{enabled:!1}}),[s,o]=(0,h.useState)(!1),{sendTransaction:d}=(0,p.p)({mutation:{onSuccess:t=>{o(!1),e({title:"Transaction Success",description:t,type:"success"})},onError:t=>{o(!1),e({title:"Error",description:(null==t?void 0:t.message)||"Failed to sign transaction",type:"error"})}}}),x=(0,h.useCallback)(async()=>{let{data:i,error:n}=await t();n?e({title:"Error",description:(null==n?void 0:n.message)||"Failed to sign transaction",type:"error"}):(o(!0),d({...b,gas:i}))},[d,t]);return(0,n.jsxs)(l.K,{direction:["column","column","row"],children:[(0,n.jsx)(r.z,{"data-testid":"sign-transaction-button",onClick:x,disabled:!d,isDisabled:s,isLoading:i,children:"Send Transaction to Vitalik"}),(0,n.jsx)(a.L,{}),(0,n.jsx)(c.r,{isExternal:!0,href:"https://sepoliafaucet.com",children:(0,n.jsx)(r.z,{variant:"outline",colorScheme:"blue",isDisabled:s,children:"Sepolia Faucet 1"})}),(0,n.jsx)(c.r,{isExternal:!0,href:"https://www.infura.io/faucet/sepolia",children:(0,n.jsx)(r.z,{variant:"outline",colorScheme:"orange",isDisabled:s,children:"Sepolia Faucet 2"})})]})}var C=i(34615),v=i(62325),g=i(68083);function y(){let e=(0,f.p)(),{address:t}=(0,g.Tj)(),{signMessageAsync:i,isPending:s}=(0,C.Q)(),{isConnected:l}=(0,g.Tj)(),[a,c]=h.useState();async function o(){if(!t){e({title:v.bq.SigningFailedToastTitle,description:"No address found",type:"error"});return}try{let n=await i({message:"Hello AppKit!",account:t});c(n),e({title:v.bq.SigningSucceededToastTitle,description:n,type:"success"})}catch(t){e({title:v.bq.SigningFailedToastTitle,description:"Failed to sign message",type:"error"})}}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.z,{"data-testid":"sign-message-button",onClick:o,isDisabled:!l||s,isLoading:s,children:"Sign Message"}),(0,n.jsx)("div",{"data-testid":"w3m-signature",hidden:!0,children:a})]})}var w=i(93974);let E={Person:[{name:"name",type:"string"},{name:"wallet",type:"address"}],Mail:[{name:"from",type:"Person"},{name:"to",type:"Person"},{name:"contents",type:"string"}]},T={from:{name:"Cow",wallet:"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},to:{name:"Bob",wallet:"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"},contents:"Hello, Bob!"};function L(){let e=(0,f.p)(),{isConnected:t}=(0,g.Tj)(),{chain:i}=(0,d.m)(),s={name:"Ether Mail",version:"1",chainId:null==i?void 0:i.id,verifyingContract:"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},{signTypedDataAsync:l,isPending:a}=(0,w.y)();async function c(){try{let t=await l({domain:s,message:T,primaryType:"Mail",types:E});e({title:"Success",description:t,type:"success"})}catch(t){e({title:"Error",description:"Failed to sign message",type:"error"})}}return(0,n.jsx)(r.z,{"data-testid":"sign-typed-data-button",onClick:c,isDisabled:!t||a,isLoading:a,children:"Sign Typed Data"})}var D=i(34686),z=i(79667),_=i(83533),A=i(5828),F=i(77754),B=i(97558),k=i(78108),I=i(52394),N=i(8730),P=i(10722),R=i(57338),M=i(5830),O=i(89023),W=i(41424);let q=[M.F.id,O.v.id];function X(){let{address:e}=(0,g.Tj)(),{status:t,chain:i}=(0,d.m)();return q.includes(Number(null==i?void 0:i.id))&&"connected"===t?(0,n.jsx)(U,{accountAddress:e}):(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:"Switch to Sepolia or OP to test this feature"})}function U(e){let{accountAddress:t}=e,i=(0,f.p)(),{data:o,refetch:d,isLoading:u,isRefetching:p}=(0,N.u)({abi:W.M,address:W.L,functionName:"getBalance",args:[t],query:{refetchOnWindowFocus:!1}}),{refetch:x,data:m,isFetching:b}=(0,P.G)({abi:W.M,address:W.L,functionName:"purchase",value:(0,I.f)("0.0001"),args:[1],query:{enabled:!1}}),{writeContract:S,reset:j,data:C,error:v,isPending:g}=(0,R.S)(),y=(0,h.useCallback)(async()=>{let{data:e,error:t}=await x();!t&&(null==e?void 0:e.request)?(S(e.request),await d()):i({title:"Error",description:"Not able to execute this transaction. Check your balance.",type:"error"})},[S,x]);return(0,h.useEffect)(()=>{C?i({title:"Donut Purchase Success!",description:C,type:"success"}):v&&i({title:"Error",description:"Failed to purchase donut",type:"error"}),j()},[C,v]),(0,n.jsxs)(l.K,{direction:["column","column","row"],children:[(0,n.jsx)(r.z,{"data-testid":"sign-transaction-button",onClick:y,disabled:!(null==m?void 0:m.request),isDisabled:g,isLoading:b,children:"Purchase crypto donut"}),u||p?(0,n.jsx)(s.x,{children:"Fetching donuts..."}):(0,n.jsxs)(k.k,{alignItems:"center",children:[(0,n.jsx)(s.x,{marginRight:"5px",children:"Crypto donuts left:"}),(0,n.jsx)(s.x,{children:null==o?void 0:o.toString()})]}),(0,n.jsx)(a.L,{}),(0,n.jsx)(c.r,{isExternal:!0,href:"https://sepoliafaucet.com",children:(0,n.jsx)(r.z,{variant:"outline",colorScheme:"blue",isDisabled:g,children:"Sepolia Faucet 1"})}),(0,n.jsx)(c.r,{isExternal:!0,href:"https://www.infura.io/faucet/sepolia",children:(0,n.jsx)(r.z,{variant:"outline",colorScheme:"orange",isDisabled:g,children:"Sepolia Faucet 2"})})]})}var G=i(98719),K=i(73109),H=i(34794),V=i(57322);let J=[K.Fox,K.v4o,K.ueV,K.yXc],Q=J.map(e=>e.id),Y={[K.Fox.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[K.v4o.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[K.ueV.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[K.yXc.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"};function Z(e){let{config:t}=e,{status:i,chain:l}=(0,d.m)();return Q.includes(Number(null==l?void 0:l.id))&&"connected"===i&&l?(0,n.jsx)($,{chain:l,config:t}):(0,n.jsxs)(s.x,{fontSize:"md",color:"yellow",children:["Allowed chains are:"," ",J.map(e=>(0,n.jsxs)("span",{children:[e.name,", "]},e.name))]})}function $(e){let{chain:t,config:i}=e,[o,d]=(0,h.useState)(""),[u,p]=(0,h.useState)(""),[x,m]=(0,h.useState)(!1),b=(0,f.p)();async function S(e){let i=BigInt(1e6*Number(u)),n=Y[t.id],s=await (0,V.x)(e);try{m(!0);let e=await s.writeContract({abi:H.Wo,functionName:"transfer",args:[o,i],address:n});b({title:"Transaction Success",description:e,type:"success"})}catch(e){b({title:"Error",description:"Failed to send transaction",type:"error"})}finally{m(!1)}}return i?(0,n.jsxs)(l.K,{direction:["column","column","row"],children:[(0,n.jsx)(a.L,{}),(0,n.jsx)(G.I,{placeholder:"Destination",onChange:e=>d(e.target.value),value:o}),(0,n.jsx)(G.I,{placeholder:"USDC Amount",onChange:e=>p(e.target.value),value:u,type:"number"}),(0,n.jsx)(r.z,{"data-testid":"sign-transaction-button",onClick:()=>{S(i)},isDisabled:x,isLoading:x,width:"80%",children:"Send USDC"}),(0,n.jsx)(c.r,{isExternal:!0,href:"https://faucet.circle.com",children:(0,n.jsx)(r.z,{variant:"outline",colorScheme:"blue",isDisabled:x,children:"USDC Faucet"})})]}):(0,n.jsx)(s.x,{children:"Config is not available"})}var ee=i(1507),et=i(34897),ei=i(2825);function en(e){let{capability:t,method:i}=e,[n,s]=(0,h.useState)(),[l,r]=(0,h.useState)(!1),[a,c]=(0,h.useState)(),{address:o,isConnected:u}=(0,g.Tj)(),{chain:p,connector:x}=(0,d.m)(),m=(0,h.useMemo)(()=>a&&t?(0,et.uv)(t,a):[],[a,t]),f=(0,h.useMemo)(()=>m.map(e=>e.chainName).join(", "),[m]),b=(0,h.useMemo)(()=>m.find(e=>e.chainId===Number(null==p?void 0:p.id)),[m,p]);async function S(e,t,i){var n;let l=await (null===(n=t.getProvider)||void 0===n?void 0:n.call(t,{chainId:i.id}));if(l instanceof ei.Sd){let e=await l.getCapabilities();s(l),c(e)}else l&&(s(l),c((0,et.Jt)(e,l)))}return(0,h.useEffect)(()=>{u&&x&&o&&p&&S(o,x,p)},[x,o,p,u]),(0,h.useEffect)(()=>{var e,t,s,l;r(n instanceof ei.Sd?Object.values(et.mE).concat(Object.values(et.nf)).includes(i):!!(null==n?void 0:null===(l=n.session)||void 0===l?void 0:null===(s=l.namespaces)||void 0===s?void 0:null===(t=s.eip155)||void 0===t?void 0:null===(e=t.methods)||void 0===e?void 0:e.includes(i)))},[n]),{provider:n,currentChainsInfo:b,availableCapabilities:a,supportedChains:m,supportedChainsName:f,supported:l}}let es={to:x.Rl,value:(0,o.L)("0.0001")},el={to:x.Rl,data:"0xdeadbeef"};function er(){let{provider:e,supported:t,supportedChains:i,supportedChainsName:l,currentChainsInfo:r}=en({capability:et.ec.ATOMIC_BATCH,method:et.mE.WALLET_SEND_CALLS}),{address:a}=(0,g.Tj)(),{status:c}=(0,d.m)();return"connected"===c&&e&&a?t?0===i.length?(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:"Account does not support the atomic batch feature"}):r?(0,n.jsx)(ea,{}):(0,n.jsxs)(s.x,{fontSize:"md",color:"yellow",children:["Switch to ",l," to test this feature"]}):(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:'Wallet does not support the "wallet_sendCalls" RPC method'}):(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:"Wallet not connected"})}function ea(){let e=(0,f.p)(),[t,i]=(0,h.useState)(null),{sendCalls:a,isPending:c}=(0,ee.a)({mutation:{onSuccess:t=>{i(t),e({title:"SendCalls Success",description:t,type:"success"})},onError:()=>{e({title:"SendCalls Error",description:"Failed to send calls",type:"error"})}}}),o=(0,h.useCallback)(()=>{a({calls:[es,el]})},[a]);return(0,n.jsxs)(l.K,{direction:["column","column","row"],children:[(0,n.jsx)(r.z,{"data-testid":"send-calls-button",onClick:o,disabled:!a,isDisabled:c,isLoading:c,children:"Send Batch Calls to Vitalik"}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(_.X,{size:"xs",children:"Last batch call ID:"}),(0,n.jsx)(s.x,{"data-testid":"send-calls-id",children:t})]})]})}var ec=i(56914),eo=i(93363);function ed(){let{supported:e}=en({method:et.mE.WALLET_GET_CALLS_STATUS}),{address:t}=(0,g.Tj)(),{status:i}=(0,d.m)();return"connected"===i&&t?e?(0,n.jsx)(eu,{}):(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:'Wallet does not support the "wallet_getCallsStatus" RPC method'}):(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:"Wallet not connected"})}function eu(){let[e,t]=(0,h.useState)(""),i=(0,f.p)(),{isLoading:s,refetch:a}=(0,eo.Q)({id:e,query:{enabled:!1}}),c=(0,h.useCallback)(async()=>{let{error:e,data:t}=await a();t&&i({title:"GetCallsStatus Success",description:JSON.stringify(t,ec.d),type:"success"}),e&&i({title:"GetCallsStatus Error",description:"Failed to get calls status",type:"error"})},[a]);return(0,n.jsxs)(l.K,{direction:["column","column","row"],children:[(0,n.jsx)(G.I,{placeholder:"0xf34ffa...",onChange:e=>t(e.target.value),value:e,isDisabled:s,"data-testid":"get-calls-id-input"}),(0,n.jsx)(r.z,{"data-testid":"get-calls-status-button",onClick:c,isDisabled:s||!e,isLoading:s,children:"Get Calls Status"})]})}var ep=i(37259);let ex={to:x.Rl,value:(0,o.L)("0.001")},eh={to:x.Rl,data:"0xdeadbeef"};function em(){let{provider:e,supportedChains:t,supportedChainsName:i,currentChainsInfo:l,supported:r}=en({capability:et.ec.PAYMASTER_SERVICE,method:et.mE.WALLET_SEND_CALLS}),{address:a}=(0,g.Tj)(),{status:c}=(0,d.m)();return"connected"===c&&e&&a?r?0===t.length?(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:"Account does not support paymaster service feature"}):l?(0,n.jsx)(ef,{}):(0,n.jsxs)(s.x,{fontSize:"md",color:"yellow",children:["Switch to ",i," to test this feature"]}):(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:'Wallet does not support "wallet_sendCalls" RPC method'}):(0,n.jsx)(s.x,{fontSize:"md",color:"yellow",children:"Wallet not connected"})}function ef(){let[e,t]=(0,h.useState)(""),[i,s]=(0,h.useState)(!1),a=(0,f.p)(),{sendCalls:c}=(0,ee.a)({mutation:{onSuccess:e=>{s(!1),a({title:"SendCalls Success",description:e,type:"success"})},onError:()=>{s(!1),a({title:"SendCalls Error",description:"Failed to send calls",type:"error"})}}}),o=(0,h.useCallback)(()=>{if(s(!0),!e)throw Error("paymasterServiceUrl not set");c({calls:[ex,eh],capabilities:{paymasterService:{url:e}}})},[c,e]);return(0,n.jsxs)(l.K,{direction:["column","column","column"],children:[(0,n.jsx)(ep.u,{label:"Paymaster Service URL should be of ERC-7677 paymaster service proxy",children:(0,n.jsx)(G.I,{placeholder:"http://api.pimlico.io/v2/sepolia/rpc?apikey=...",onChange:e=>t(e.target.value),value:e,isDisabled:i,whiteSpace:"nowrap",textOverflow:"ellipsis"})}),(0,n.jsx)(r.z,{width:"fit-content","data-testid":"send-calls-paymaster-service-button",onClick:o,disabled:!c,isDisabled:i||!e,children:"SendCalls w/ Paymaster Service"})]})}var eb=i(433),eS=i(1630);function ej(){let e=(0,f.p)(),{disconnect:t,isPending:i}=(0,eb.q)(),s=(0,eS.b)(),{isConnected:l}=(0,g.Tj)();return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(r.z,{onClick:function(){try{var i;let n=null==s?void 0:null===(i=s[0])||void 0===i?void 0:i.connector;if(!n){e({title:v.bq.DisconnectingFailedToastTitle,description:"No connector found",type:"error"});return}t({connector:n},{onSuccess:()=>{e({title:v.bq.DisconnectingSuccessToastTitle,description:"Disconnected",type:"success"})},onError:()=>{e({title:v.bq.DisconnectingFailedToastTitle,description:"Failed to disconnect",type:"error"})}})}catch(t){e({title:v.bq.DisconnectingFailedToastTitle,description:"Failed to sign message",type:"error"})}},isDisabled:!l||i,isLoading:i,children:"Disconnect"})})}function eC(e){let{config:t}=e;return(0,n.jsxs)(D.Z,{marginTop:10,marginBottom:10,children:[(0,n.jsx)(z.O,{children:(0,n.jsx)(_.X,{size:"md",children:"Test Interactions"})}),(0,n.jsx)(A.e,{children:(0,n.jsxs)(l.K,{divider:(0,n.jsx)(F.c,{}),spacing:"4",children:[(0,n.jsxs)(B.xu,{children:[(0,n.jsx)(_.X,{size:"xs",textTransform:"uppercase",pb:"2",children:"Sign Message"}),(0,n.jsx)(y,{})]}),(0,n.jsxs)(B.xu,{children:[(0,n.jsx)(_.X,{size:"xs",textTransform:"uppercase",pb:"2",children:"Sign Typed Data"}),(0,n.jsx)(L,{})]}),(0,n.jsxs)(B.xu,{children:[(0,n.jsx)(_.X,{size:"xs",textTransform:"uppercase",pb:"2",children:"Sign Transaction"}),(0,n.jsx)(S,{})]}),(0,n.jsxs)(B.xu,{children:[(0,n.jsx)(_.X,{size:"xs",textTransform:"uppercase",pb:"2",children:"Contract Write"}),(0,n.jsx)(X,{})]}),(0,n.jsxs)(B.xu,{children:[(0,n.jsx)(_.X,{size:"xs",textTransform:"uppercase",pb:"2",children:"USDC Send"}),(0,n.jsx)(Z,{config:t})]}),(0,n.jsxs)(B.xu,{children:[(0,n.jsx)(_.X,{size:"xs",textTransform:"uppercase",pb:"2",children:"Send Calls (Atomic Batch)"}),(0,n.jsx)(er,{})]}),(0,n.jsxs)(B.xu,{children:[(0,n.jsx)(_.X,{size:"xs",textTransform:"uppercase",pb:"2",children:"Get Calls Status"}),(0,n.jsx)(ed,{})]}),(0,n.jsxs)(B.xu,{children:[(0,n.jsx)(_.X,{size:"xs",textTransform:"uppercase",pb:"2",children:"Send Calls (Paymaster Service)"}),(0,n.jsx)(em,{})]}),(0,n.jsxs)(B.xu,{children:[(0,n.jsx)(_.X,{size:"xs",textTransform:"uppercase",pb:"2",children:"Disconnect"}),(0,n.jsx)(ej,{})]})]})})]})}},34897:function(e,t,i){i.d(t,{EZ:function(){return p},Jt:function(){return u},ec:function(){return o},mE:function(){return a},nf:function(){return c},uv:function(){return d}});var n=i(28370),s=i(56914),l=i(29593),r=i(2825);let a={WALLET_GET_CAPABILITIES:"wallet_getCapabilities",WALLET_GET_CALLS_STATUS:"wallet_getCallsStatus",WALLET_SEND_CALLS:"wallet_sendCalls"},c={WALLET_GRANT_PERMISSIONS:"wallet_grantPermissions",WALLET_REVOKE_PERMISSIONS:"wallet_revokePermissions"},o={ATOMIC_BATCH:"atomicBatch",PAYMASTER_SERVICE:"paymasterService",PERMISSIONS:"permissions"};function d(e,t){return Object.keys(t).filter(i=>{var n;let s=t[i];return(null==s?void 0:null===(n=s[e])||void 0===n?void 0:n.supported)===!0}).map(e=>{var t;let i=(0,l.H_)(e,"number"),s=(0,n.z)(i);return{chainId:i,chainName:null!==(t=null==s?void 0:s.name)&&void 0!==t?t:"Unknown Chain(".concat(i,")")}})}function u(e,t){var i,n;let l=null==t?void 0:null===(n=t.session)||void 0===n?void 0:null===(i=n.sessionProperties)||void 0===i?void 0:i.capabilities;if(!l)return;let r=(0,s.R)(l)[e];if(r)return Object.fromEntries(Object.entries(r).map(e=>{let[t,i]=e;return[parseInt(t,16),i]}))}async function p(e,t,i){if(t instanceof r.Sd)return Object.entries(await t.getCapabilities()).map(e=>{var t;let[i]=e,s=(0,n.z)((0,l.H_)(i,"number"));return{chainId:(0,l.H_)(i,"number"),chainName:null!==(t=null==s?void 0:s.name)&&void 0!==t?t:"Unknown Chain (".concat(i,")")}});let s=u(i,t);return s?d(e,s):[]}}}]);