diff --git a/assets/index-DoiqIhGY.js b/assets/index-qGsBZgNv.js similarity index 99% rename from assets/index-DoiqIhGY.js rename to assets/index-qGsBZgNv.js index 525665a..2510322 100644 --- a/assets/index-DoiqIhGY.js +++ b/assets/index-qGsBZgNv.js @@ -67,4 +67,4 @@ Proven: ${(0,encoding_1$f.toHex)(c.key)}`);return ics23_1.ics23.CommitmentProof. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var h=reactExports,n=shimExports;function p(c,g){return c===g&&(c!==0||1/c===1/g)||c!==c&&g!==g}var q=typeof Object.is=="function"?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;withSelector_production_min.useSyncExternalStoreWithSelector=function(c,g,_e,tt,ot){var at=t(null);if(at.current===null){var ct={hasValue:!1,value:null};at.current=ct}else ct=at.current;at=v(function(){function bt(It){if(!Tt){if(Tt=!0,$t=It,It=tt(It),ot!==void 0&&ct.hasValue){var Rt=ct.value;if(ot(Rt,It))return dt=Rt}return dt=It}if(Rt=dt,q($t,It))return Rt;var ft=tt(It);return ot!==void 0&&ot(Rt,ft)?Rt:($t=It,dt=ft)}var Tt=!1,$t,dt,yt=_e===void 0?null:_e;return[function(){return bt(g())},yt===null?void 0:function(){return bt(yt())}]},[g,_e,tt,ot]);var vt=r(c,at[0],at[1]);return u(function(){ct.hasValue=!0,ct.value=vt},[vt]),w(vt),vt};withSelector.exports=withSelector_production_min;var withSelectorExports=withSelector.exports;const isPlainObject=c=>typeof c=="object"&&!Array.isArray(c);function useSyncExternalStoreWithTracked(c,g,_e=g,tt=deepEqual){const ot=reactExports.useRef([]),at=withSelectorExports.useSyncExternalStoreWithSelector(c,g,_e,ct=>ct,(ct,vt)=>{if(isPlainObject(ct)&&isPlainObject(vt)&&ot.current.length){for(const bt of ot.current)if(!tt(ct[bt],vt[bt]))return!1;return!0}return tt(ct,vt)});return reactExports.useMemo(()=>{if(isPlainObject(at)){const ct={...at};let vt={};for(const[bt,Tt]of Object.entries(ct))vt={...vt,[bt]:{configurable:!1,enumerable:!0,get:()=>(ot.current.includes(bt)||ot.current.push(bt),Tt)}};return Object.defineProperties(ct,vt),ct}return at},[at])}function useAccount(c={}){const g=useConfig(c);return useSyncExternalStoreWithTracked(_e=>watchAccount(g,{onChange:_e}),()=>getAccount(g))}function connectMutationOptions(c){return{mutationFn(g){return connect(c,g)},mutationKey:["connect"]}}function disconnectMutationOptions(c){return{mutationFn(g){return disconnect(c,g)},mutationKey:["disconnect"]}}function signMessageMutationOptions(c){return{mutationFn(g){return signMessage(c,g)},mutationKey:["signMessage"]}}function switchChainMutationOptions(c){return{mutationFn(g){return switchChain(c,g)},mutationKey:["switchChain"]}}function useChains(c={}){const g=useConfig(c);return reactExports.useSyncExternalStore(_e=>watchChains(g,{onChange:_e}),()=>getChains(g),()=>getChains(g))}function useConnectors(c={}){const g=useConfig(c);return reactExports.useSyncExternalStore(_e=>watchConnectors(g,{onChange:_e}),()=>getConnectors(g),()=>getConnectors(g))}function useConnect(c={}){const{mutation:g}=c,_e=useConfig(c),tt=connectMutationOptions(_e),{mutate:ot,mutateAsync:at,...ct}=useMutation({...g,...tt});return reactExports.useEffect(()=>_e.subscribe(({status:vt})=>vt,(vt,bt)=>{bt==="connected"&&vt==="disconnected"&&ct.reset()}),[_e,ct.reset]),{...ct,connect:ot,connectAsync:at,connectors:useConnectors({config:_e})}}function useConnections(c={}){const g=useConfig(c);return reactExports.useSyncExternalStore(_e=>watchConnections(g,{onChange:_e}),()=>getConnections(g),()=>getConnections(g))}function useDisconnect(c={}){const{mutation:g}=c,_e=useConfig(c),tt=disconnectMutationOptions(_e),{mutate:ot,mutateAsync:at,...ct}=useMutation({...g,...tt});return{...ct,connectors:useConnections({config:_e}).map(vt=>vt.connector),disconnect:ot,disconnectAsync:at}}function useSignMessage(c={}){const{mutation:g}=c,_e=useConfig(c),tt=signMessageMutationOptions(_e),{mutate:ot,mutateAsync:at,...ct}=useMutation({...g,...tt});return{...ct,signMessage:ot,signMessageAsync:at}}function useSwitchChain(c={}){const{mutation:g}=c,_e=useConfig(c),tt=switchChainMutationOptions(_e),{mutate:ot,mutateAsync:at,...ct}=useMutation({...g,...tt});return{...ct,chains:useChains({config:_e}),switchChain:ot,switchChainAsync:at}}const BrowserWalletImg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQgSURBVHgB7dyxchpHGAfw/4I9sVMpXcrLEwQ/QEa4TCWV6UTKFBlHTcyk4eQKp3EUTyZl0BMYdemCZtKHPEEuT2BVlscW+/lbDmOEhdAdrD4Q/98MAsFJjPZ/++0tuluAiIiIiIiIaJM4bLA0fbb1CtWGE+wAUtOntvSWiVQ6Pz/5/gA3YOMCaKa/J96f7zkndW30+hWbZvedf5Cm+6eI6A42QDN9XheRsJfvirxJ3PV2u+RMqi/0/iEiupU9IJSW17hTGzV6A3lpuZRzrucxOK4A3Xa6nzXTZ6mWoNaH1/1Dfb6HSG5NAHmjV3UPx95EPb/MqTZ6PzT6p0DnshLTTA87+e9BaKHjp+mjXUSy1iVoWM/xdjcMomcyrOmzNg2N3gUGR/eA/vy67jtAJQ9AsI2I1q4HhHruPba1NIS9sjZrOxeOZnTvdfDdMiXkcevwJUa9SN/ri1CeEMFa9ICJQbQh4rdmDaKhnutefqIPe0uo2xlGAbv8PkMEKxnAuJ5Du7+EIxc/dxCdVc/L0pD/1XFgGMAA1QSRrEwAk5Oia9bzE63n3VjH6R6u7yDDcUCPkL5EJKYB/JT+Vjv3fidMikKjuysaXevAUajn1xtEF1fBoC+h6ZWWvxoiufEAJidFAzmfPSly0D3QH2M59byw1xr0Jx++jRZA9KOg8aQodGet5ygwKYIxPRL6T++S8DjWkVCUHjBVz3Xv8aUnRbZcX3tqkj+u1vVLB0u2tACmJ0WrVM9Lc/L/+z9DfJxxYKESNDEpamDUVa94q67We63pd3tYE+LOd+D9L/l3rufc3W+nt2mn32VYQKkAQonRTwr1Ayv5AbTQ/w8qKOFMKn+x8cf0SM6nOmD/gxKqKOjHg+ctJ/INaNrnX21/7f4++bNX5IcK9wDnfbSPZtedfvi3V/RnypSgaJOSWyBBQaXGAFoeBmCMARhjAMYYgDEGYIwBGGMAxhiAMQZgjAEYYwDGGIAxBmCMARhjAMYYgDEGYIwBGGMAI+G81HBB3n3nPwu38BjDCz7i2ojLVOdx4o/aB/uNqad74TZ91eSysQcAWfvJR40/1k7305g9gQFIOF913ibztylr4wNwlXAK+tytMkSy8QH4Ky4YuQnsAcOVUuZtI3O3KYtjAKSuRzr1Wa/qa8lovYkoGADCVZCVF83018b08/kFheFU/Hg4D8hticgfj1uHrfEhp0hNxEc/EZkBXJRowzdwg1iCjDEAYwzAGAMwxgCMMQBjDMAYAzDGAIwxAGMMwBgDMMYAjDEAYwzAGAMwxgCMMQBjZQLIQLNc4ySvi4ovWeZwBLqUc/4QBZVatnK0QiCXLruo//Tg0QMUVGoMCG+kaYd1MjPQaWiLMo0fLLx4d744t+35lVbuaeOv9NLLRERERERERES0Ut4BCQCUeU136wQAAAAASUVORK5CYII=",Wagmi=()=>{const{address:c,connector:g,isConnected:_e,isConnecting:tt,isDisconnected:ot}=useAccount(),{isMobile:at}=useUserAgent(),{connectors:ct,connectAsync:vt}=useConnect(),{disconnect:bt}=useDisconnect(),[Tt,$t]=reactExports.useState(""),[dt,yt]=reactExports.useState(!1),It=()=>{$t("")},Rt=reactExports.useMemo(()=>{const Bt=(g==null?void 0:g.name)==="Injected",Kt=Bt?"Browser Wallet":g==null?void 0:g.name,xt=Bt?BrowserWalletImg:(g==null?void 0:g.icon)||"";return{...g,name:Kt,icon:xt}},[g]),{signMessageAsync:ft}=useSignMessage(),{switchChain:mt}=useSwitchChain();return reactExports.useEffect(()=>{at&&vt({connector:ct[0]})},[vt,ct,at]),ct?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:styles$1.container,children:[jsxRuntimeExports.jsxs("div",{className:styles$1.contentsContainer,children:[jsxRuntimeExports.jsx("h3",{className:styles$1.title,children:"Choose your Wallet"}),jsxRuntimeExports.jsx("div",{className:styles$1.walletButtonContainer,children:ct.map(Bt=>{const Kt=Bt.name==="Injected",xt=Kt?"Browser Wallet":Bt.name,Ft=Kt?BrowserWalletImg:Bt.icon||"";return jsxRuntimeExports.jsx(WalletButton,{walletImage:Ft,walletName:xt,onClick:async()=>{It(),await vt({connector:Bt},{onError:Yt=>{console.error("🚀 ~ onClick={ ~ error:",Yt)}})}},Bt.uid)})})]}),jsxRuntimeExports.jsxs("div",{className:styles$1.contentsContainer,children:[jsxRuntimeExports.jsx("h3",{className:styles$1.title,children:"Current Connected Wallet"}),jsxRuntimeExports.jsx("div",{className:styles$1.connectedWalletContainer,children:tt?jsxRuntimeExports.jsx("div",{children:"Connecting..."}):_e?jsxRuntimeExports.jsxs("div",{className:styles$1.contents,children:[jsxRuntimeExports.jsxs("div",{className:styles$1.connectedWallet,children:[jsxRuntimeExports.jsx("img",{className:styles$1.connectedWalletImage,src:Rt==null?void 0:Rt.icon}),jsxRuntimeExports.jsx("div",{className:styles$1.walletName,children:Rt==null?void 0:Rt.name})]}),jsxRuntimeExports.jsx("div",{className:styles$1.workBreak,children:c})]}):ot?jsxRuntimeExports.jsx("div",{className:styles$1.contents,children:jsxRuntimeExports.jsx("h4",{children:"Not Connected"})}):null}),jsxRuntimeExports.jsx("button",{className:styles$1.baseButton,disabled:!_e,onClick:()=>{bt()},children:jsxRuntimeExports.jsx("h4",{children:"Disconnect"})})]}),jsxRuntimeExports.jsxs("div",{className:styles$1.contentsContainer,children:[jsxRuntimeExports.jsx("h3",{children:"Sign Message"}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("div",{className:styles$1.workBreak,children:dt?"Processing...":Tt||"No Signature"})}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("button",{className:styles$1.baseButton,disabled:!_e||dt,onClick:async()=>{try{yt(!0),at&&await mt({chainId:1});const Bt=await ft({message:"Example `personal_sign` message"});$t(Bt)}catch(Bt){console.log("🚀 ~ error:",Bt)}finally{yt(!1)}},children:"Sign Message"})})]})]})}):jsxRuntimeExports.jsxs("div",{className:styles$1.container,children:[jsxRuntimeExports.jsx("div",{children:"No Wallets To Connect Wallet"}),";"]})},mainnet=defineChain({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),config=createConfig({chains:[mainnet],connectors:[injected()],multiInjectedProviderDiscovery:!0,transports:{[mainnet.id]:http()}}),container="_container_hy1da_1",header="_header_hy1da_9",title$1="_title_hy1da_13",notice="_notice_hy1da_18",body="_body_hy1da_37",warning="_warning_hy1da_50",link="_link_hy1da_59",walletLogo="_walletLogo_hy1da_65",walletButtonContainer="_walletButtonContainer_hy1da_74",walletLogoButton="_walletLogoButton_hy1da_80",connectTypeButtonWrapper="_connectTypeButtonWrapper_hy1da_89",chainCategory="_chainCategory_hy1da_98",chain="_chain_hy1da_98",connectTypeButtonContainer="_connectTypeButtonContainer_hy1da_118",connectTypeButton="_connectTypeButton_hy1da_89",evm="_evm_hy1da_142",active="_active_hy1da_147",divider="_divider_hy1da_151",styles={container,header,title:title$1,notice,body,warning,link,walletLogo,walletButtonContainer,walletLogoButton,connectTypeButtonWrapper,chainCategory,chain,connectTypeButtonContainer,connectTypeButton,evm,active,divider},useCosmostation=()=>{const[c,g]=reactExports.useState(null),{isMobile:_e,isAndroid:tt,isiOS:ot,isChrome:at,isFirefox:ct}=useUserAgent(),vt=reactExports.useRef();reactExports.useEffect(()=>{window.cosmostation&&g(window.cosmostation),vt.current=setTimeout(()=>{window.cosmostation&&g(window.cosmostation),clearTimeout(vt.current)},1e3)},[]);const bt=reactExports.useMemo(()=>c==null?void 0:c.cosmos,[c]),Tt=reactExports.useMemo(()=>!!c,[c]),$t=reactExports.useMemo(()=>{if(_e){if(tt)return"https://play.google.com/store/apps/details?id=wannabit.io.cosmostaion";if(ot)return"https://apps.apple.com/kr/app/cosmostation/id1459830339"}else{if(at)return"https://chromewebstore.google.com/detail/cosmostation-wallet/fpkhgmpbidmiogeglndfbkegfdlnajnf";if(ct)return"https://addons.mozilla.org/en-US/firefox/addon/cosmostation-wallet/"}return null},[_e,tt,ot,at,ct]),dt=reactExports.useCallback(It=>bt==null?void 0:bt.request({method:"cos_requestAccount",params:{chainName:It}}),[bt]),yt=reactExports.useCallback(It=>bt==null?void 0:bt.request({method:"cos_signDirect",params:{chainName:It.chainId,doc:{account_number:It.accountNumber.toString(),chain_id:It.chainId,auth_info_bytes:It.authInfoBytes,body_bytes:It.bodyBytes}}}),[bt]);return{isInstalled:Tt,downloadUrl:$t,provider:c,cosmos:bt,getAccount:dt,signDirect:yt}},queryClient=new QueryClient$2,connectType={"eip-6963":"eip-6963",wagmi:"wagmi","vanilla-cosmos":"vanilla-cosmos","@cosmostation/wallets":"@cosmostation/wallets"},title={"eip-6963":"Connect Ethereum Wallet With EIP-6963",wagmi:"Connect Ethereum Wallet With Wagmi","vanilla-cosmos":"Connect Cosmos Wallet with Vanilla","@cosmostation/wallets":"Connect Cosmos Wallet with @cosmostation/wallets"},App=()=>{const{isInstalled:c,downloadUrl:g}=useCosmostation(),{isMobile:_e,isAndroid:tt,isiOS:ot}=useUserAgent(),[at,ct]=reactExports.useState(connectType["eip-6963"]),vt=reactExports.useCallback(bt=>{ot?(window.location.href=`cosmostation://dapp?url=${bt}`,setTimeout(()=>{g&&(window.location.href=g)},3e3)):tt&&(window.location.href=`cosmostation://dapp?${bt}`)},[g,tt,ot]);return!c&&!g?jsxRuntimeExports.jsxs("div",{className:styles.warning,children:[jsxRuntimeExports.jsx("p",{children:"This client is not supported."}),jsxRuntimeExports.jsxs("p",{children:["Please access it using ",jsxRuntimeExports.jsx("i",{children:"Android / iOS"})," mobile devices or ",jsxRuntimeExports.jsx("i",{children:"Chrome / Firefox"})," on desktop."]})]}):!c&&g&&_e?jsxRuntimeExports.jsxs("div",{className:styles.warning,children:[jsxRuntimeExports.jsx("p",{children:"This page is accessible via the Cosmostation App Wallet or desktop web page."}),jsxRuntimeExports.jsxs("p",{children:[jsxRuntimeExports.jsx("a",{href:"#none",onClick:()=>vt(window.location.href),className:styles.link,children:"Click here"})," to launch the dApp within the Cosmostation App Wallet."]})]}):!c&&g&&!_e?jsxRuntimeExports.jsxs("div",{className:styles.warning,children:[jsxRuntimeExports.jsx("p",{children:"The Cosmostation Wallet Extension is missing."}),jsxRuntimeExports.jsxs("p",{children:[jsxRuntimeExports.jsx("a",{href:g,className:styles.link,target:"_blank",children:"Click here"})," to install, then refresh the page to continue."]})]}):jsxRuntimeExports.jsxs("div",{className:styles.container,children:[jsxRuntimeExports.jsx("h1",{className:styles.header,children:title[at]}),jsxRuntimeExports.jsxs("div",{className:styles.connectTypeButtonWrapper,children:[jsxRuntimeExports.jsxs("div",{className:styles.chainCategory,children:[jsxRuntimeExports.jsxs("div",{className:styles.chain,children:[jsxRuntimeExports.jsx("img",{src:EthereumImage}),jsxRuntimeExports.jsx("h6",{children:"Ethereum networks"})]}),jsxRuntimeExports.jsxs("div",{className:styles.connectTypeButtonContainer,children:[jsxRuntimeExports.jsx("button",{className:`${styles.connectTypeButton} ${at===connectType["eip-6963"]?styles.active:""}`,onClick:()=>ct(connectType["eip-6963"]),children:jsxRuntimeExports.jsxs("h3",{children:["use",jsxRuntimeExports.jsx("br",{}),"EIP-6963"]})}),jsxRuntimeExports.jsx("button",{className:`${styles.connectTypeButton} ${at===connectType.wagmi?styles.active:""}`,onClick:()=>ct(connectType.wagmi),children:jsxRuntimeExports.jsxs("h3",{children:["use",jsxRuntimeExports.jsx("br",{}),"Wagmi"]})})]})]}),jsxRuntimeExports.jsx("div",{className:styles.divider}),jsxRuntimeExports.jsxs("div",{className:styles.chainCategory,children:[jsxRuntimeExports.jsxs("div",{className:styles.chain,children:[jsxRuntimeExports.jsx("img",{src:CosmosImage}),jsxRuntimeExports.jsx("h6",{children:"Cosmos networks"})]}),jsxRuntimeExports.jsxs("div",{className:styles.connectTypeButtonContainer,children:[jsxRuntimeExports.jsx("button",{className:`${styles.connectTypeButton} ${at===connectType["vanilla-cosmos"]?styles.active:""}`,onClick:()=>ct(connectType["vanilla-cosmos"]),children:jsxRuntimeExports.jsxs("h3",{children:["use",jsxRuntimeExports.jsx("br",{}),"Vanilla"]})}),jsxRuntimeExports.jsx("button",{className:`${styles.connectTypeButton} ${at===connectType["@cosmostation/wallets"]?styles.active:""}`,onClick:()=>ct(connectType["@cosmostation/wallets"]),children:jsxRuntimeExports.jsxs("h3",{children:["use",jsxRuntimeExports.jsx("br",{}),"wallets pkg"]})})]})]})]}),at===connectType["eip-6963"]&&jsxRuntimeExports.jsx(VanillaEthereumConnect,{}),at===connectType.wagmi&&jsxRuntimeExports.jsx(WagmiProvider,{config,children:jsxRuntimeExports.jsx(QueryClientProvider$1,{client:queryClient,children:jsxRuntimeExports.jsx(Wagmi,{})})}),at===connectType["vanilla-cosmos"]&&jsxRuntimeExports.jsx(VanillaCosmosConnect,{}),at===connectType["@cosmostation/wallets"]&&jsxRuntimeExports.jsx(y,{children:jsxRuntimeExports.jsx(CosmostationWalletsPkg,{})}),jsxRuntimeExports.jsxs("div",{className:styles.notice,children:[jsxRuntimeExports.jsxs("p",{children:["This page is a sample dApp that allows users to transfer tokens to their wallet. It was designed for developers building dApps with the"," ",jsxRuntimeExports.jsx("b",{children:"Cosmostation App Wallet"})," or ",jsxRuntimeExports.jsx("b",{children:"Extension Wallet"}),"."]}),jsxRuntimeExports.jsxs("p",{children:[jsxRuntimeExports.jsx("a",{className:styles.link,href:"https://github.com/cosmostation/cosmostation-app-injection-example",target:"_blank",children:"Click here"})," to view the complete code."]})]})]})};var createRoot,m=reactDomExports;createRoot=m.createRoot,m.hydrateRoot;createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(reactExports.StrictMode,{children:jsxRuntimeExports.jsx(App,{})})); + */var h=reactExports,n=shimExports;function p(c,g){return c===g&&(c!==0||1/c===1/g)||c!==c&&g!==g}var q=typeof Object.is=="function"?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;withSelector_production_min.useSyncExternalStoreWithSelector=function(c,g,_e,tt,ot){var at=t(null);if(at.current===null){var ct={hasValue:!1,value:null};at.current=ct}else ct=at.current;at=v(function(){function bt(It){if(!Tt){if(Tt=!0,$t=It,It=tt(It),ot!==void 0&&ct.hasValue){var Rt=ct.value;if(ot(Rt,It))return dt=Rt}return dt=It}if(Rt=dt,q($t,It))return Rt;var ft=tt(It);return ot!==void 0&&ot(Rt,ft)?Rt:($t=It,dt=ft)}var Tt=!1,$t,dt,yt=_e===void 0?null:_e;return[function(){return bt(g())},yt===null?void 0:function(){return bt(yt())}]},[g,_e,tt,ot]);var vt=r(c,at[0],at[1]);return u(function(){ct.hasValue=!0,ct.value=vt},[vt]),w(vt),vt};withSelector.exports=withSelector_production_min;var withSelectorExports=withSelector.exports;const isPlainObject=c=>typeof c=="object"&&!Array.isArray(c);function useSyncExternalStoreWithTracked(c,g,_e=g,tt=deepEqual){const ot=reactExports.useRef([]),at=withSelectorExports.useSyncExternalStoreWithSelector(c,g,_e,ct=>ct,(ct,vt)=>{if(isPlainObject(ct)&&isPlainObject(vt)&&ot.current.length){for(const bt of ot.current)if(!tt(ct[bt],vt[bt]))return!1;return!0}return tt(ct,vt)});return reactExports.useMemo(()=>{if(isPlainObject(at)){const ct={...at};let vt={};for(const[bt,Tt]of Object.entries(ct))vt={...vt,[bt]:{configurable:!1,enumerable:!0,get:()=>(ot.current.includes(bt)||ot.current.push(bt),Tt)}};return Object.defineProperties(ct,vt),ct}return at},[at])}function useAccount(c={}){const g=useConfig(c);return useSyncExternalStoreWithTracked(_e=>watchAccount(g,{onChange:_e}),()=>getAccount(g))}function connectMutationOptions(c){return{mutationFn(g){return connect(c,g)},mutationKey:["connect"]}}function disconnectMutationOptions(c){return{mutationFn(g){return disconnect(c,g)},mutationKey:["disconnect"]}}function signMessageMutationOptions(c){return{mutationFn(g){return signMessage(c,g)},mutationKey:["signMessage"]}}function switchChainMutationOptions(c){return{mutationFn(g){return switchChain(c,g)},mutationKey:["switchChain"]}}function useChains(c={}){const g=useConfig(c);return reactExports.useSyncExternalStore(_e=>watchChains(g,{onChange:_e}),()=>getChains(g),()=>getChains(g))}function useConnectors(c={}){const g=useConfig(c);return reactExports.useSyncExternalStore(_e=>watchConnectors(g,{onChange:_e}),()=>getConnectors(g),()=>getConnectors(g))}function useConnect(c={}){const{mutation:g}=c,_e=useConfig(c),tt=connectMutationOptions(_e),{mutate:ot,mutateAsync:at,...ct}=useMutation({...g,...tt});return reactExports.useEffect(()=>_e.subscribe(({status:vt})=>vt,(vt,bt)=>{bt==="connected"&&vt==="disconnected"&&ct.reset()}),[_e,ct.reset]),{...ct,connect:ot,connectAsync:at,connectors:useConnectors({config:_e})}}function useConnections(c={}){const g=useConfig(c);return reactExports.useSyncExternalStore(_e=>watchConnections(g,{onChange:_e}),()=>getConnections(g),()=>getConnections(g))}function useDisconnect(c={}){const{mutation:g}=c,_e=useConfig(c),tt=disconnectMutationOptions(_e),{mutate:ot,mutateAsync:at,...ct}=useMutation({...g,...tt});return{...ct,connectors:useConnections({config:_e}).map(vt=>vt.connector),disconnect:ot,disconnectAsync:at}}function useSignMessage(c={}){const{mutation:g}=c,_e=useConfig(c),tt=signMessageMutationOptions(_e),{mutate:ot,mutateAsync:at,...ct}=useMutation({...g,...tt});return{...ct,signMessage:ot,signMessageAsync:at}}function useSwitchChain(c={}){const{mutation:g}=c,_e=useConfig(c),tt=switchChainMutationOptions(_e),{mutate:ot,mutateAsync:at,...ct}=useMutation({...g,...tt});return{...ct,chains:useChains({config:_e}),switchChain:ot,switchChainAsync:at}}const BrowserWalletImg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQgSURBVHgB7dyxchpHGAfw/4I9sVMpXcrLEwQ/QEa4TCWV6UTKFBlHTcyk4eQKp3EUTyZl0BMYdemCZtKHPEEuT2BVlscW+/lbDmOEhdAdrD4Q/98MAsFJjPZ/++0tuluAiIiIiIiIaJM4bLA0fbb1CtWGE+wAUtOntvSWiVQ6Pz/5/gA3YOMCaKa/J96f7zkndW30+hWbZvedf5Cm+6eI6A42QDN9XheRsJfvirxJ3PV2u+RMqi/0/iEiupU9IJSW17hTGzV6A3lpuZRzrucxOK4A3Xa6nzXTZ6mWoNaH1/1Dfb6HSG5NAHmjV3UPx95EPb/MqTZ6PzT6p0DnshLTTA87+e9BaKHjp+mjXUSy1iVoWM/xdjcMomcyrOmzNg2N3gUGR/eA/vy67jtAJQ9AsI2I1q4HhHruPba1NIS9sjZrOxeOZnTvdfDdMiXkcevwJUa9SN/ri1CeEMFa9ICJQbQh4rdmDaKhnutefqIPe0uo2xlGAbv8PkMEKxnAuJ5Du7+EIxc/dxCdVc/L0pD/1XFgGMAA1QSRrEwAk5Oia9bzE63n3VjH6R6u7yDDcUCPkL5EJKYB/JT+Vjv3fidMikKjuysaXevAUajn1xtEF1fBoC+h6ZWWvxoiufEAJidFAzmfPSly0D3QH2M59byw1xr0Jx++jRZA9KOg8aQodGet5ygwKYIxPRL6T++S8DjWkVCUHjBVz3Xv8aUnRbZcX3tqkj+u1vVLB0u2tACmJ0WrVM9Lc/L/+z9DfJxxYKESNDEpamDUVa94q67We63pd3tYE+LOd+D9L/l3rufc3W+nt2mn32VYQKkAQonRTwr1Ayv5AbTQ/w8qKOFMKn+x8cf0SM6nOmD/gxKqKOjHg+ctJ/INaNrnX21/7f4++bNX5IcK9wDnfbSPZtedfvi3V/RnypSgaJOSWyBBQaXGAFoeBmCMARhjAMYYgDEGYIwBGGMAxhiAMQZgjAEYYwDGGIAxBmCMARhjAMYYgDEGYIwBGGMAI+G81HBB3n3nPwu38BjDCz7i2ojLVOdx4o/aB/uNqad74TZ91eSysQcAWfvJR40/1k7305g9gQFIOF913ibztylr4wNwlXAK+tytMkSy8QH4Ky4YuQnsAcOVUuZtI3O3KYtjAKSuRzr1Wa/qa8lovYkoGADCVZCVF83018b08/kFheFU/Hg4D8hticgfj1uHrfEhp0hNxEc/EZkBXJRowzdwg1iCjDEAYwzAGAMwxgCMMQBjDMAYAzDGAIwxAGMMwBgDMMYAjDEAYwzAGAMwxgCMMQBjZQLIQLNc4ySvi4ovWeZwBLqUc/4QBZVatnK0QiCXLruo//Tg0QMUVGoMCG+kaYd1MjPQaWiLMo0fLLx4d744t+35lVbuaeOv9NLLRERERERERES0Ut4BCQCUeU136wQAAAAASUVORK5CYII=",Wagmi=()=>{const{address:c,connector:g,isConnected:_e,isConnecting:tt,isDisconnected:ot}=useAccount(),{isMobile:at}=useUserAgent(),{connectors:ct,connectAsync:vt}=useConnect(),{disconnect:bt}=useDisconnect(),[Tt,$t]=reactExports.useState(""),[dt,yt]=reactExports.useState(!1),It=()=>{$t("")},Rt=reactExports.useMemo(()=>{const Bt=(g==null?void 0:g.name)==="Injected",Kt=Bt?"Browser Wallet":g==null?void 0:g.name,xt=Bt?BrowserWalletImg:(g==null?void 0:g.icon)||"";return{...g,name:Kt,icon:xt}},[g]),{signMessageAsync:ft}=useSignMessage(),{switchChain:mt}=useSwitchChain();return reactExports.useEffect(()=>{at&&vt({connector:ct[0]})},[vt,ct,at]),ct?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:styles$1.container,children:[jsxRuntimeExports.jsxs("div",{className:styles$1.contentsContainer,children:[jsxRuntimeExports.jsx("h3",{className:styles$1.title,children:"Choose your Wallet"}),jsxRuntimeExports.jsx("div",{className:styles$1.walletButtonContainer,children:ct.map(Bt=>{const Kt=Bt.name==="Injected",xt=Kt?"Browser Wallet":Bt.name,Ft=Kt?BrowserWalletImg:Bt.icon||"";return jsxRuntimeExports.jsx(WalletButton,{walletImage:Ft,walletName:xt,onClick:async()=>{It(),await vt({connector:Bt},{onError:Yt=>{console.error("🚀 ~ onClick={ ~ error:",Yt)}})}},Bt.uid)})})]}),jsxRuntimeExports.jsxs("div",{className:styles$1.contentsContainer,children:[jsxRuntimeExports.jsx("h3",{className:styles$1.title,children:"Current Connected Wallet"}),jsxRuntimeExports.jsx("div",{className:styles$1.connectedWalletContainer,children:tt?jsxRuntimeExports.jsx("div",{children:"Connecting..."}):_e?jsxRuntimeExports.jsxs("div",{className:styles$1.contents,children:[jsxRuntimeExports.jsxs("div",{className:styles$1.connectedWallet,children:[jsxRuntimeExports.jsx("img",{className:styles$1.connectedWalletImage,src:Rt==null?void 0:Rt.icon}),jsxRuntimeExports.jsx("div",{className:styles$1.walletName,children:Rt==null?void 0:Rt.name})]}),jsxRuntimeExports.jsx("div",{className:styles$1.workBreak,children:c})]}):ot?jsxRuntimeExports.jsx("div",{className:styles$1.contents,children:jsxRuntimeExports.jsx("h4",{children:"Not Connected"})}):null}),jsxRuntimeExports.jsx("button",{className:styles$1.baseButton,disabled:!_e,onClick:()=>{bt()},children:jsxRuntimeExports.jsx("h4",{children:"Disconnect"})})]}),jsxRuntimeExports.jsxs("div",{className:styles$1.contentsContainer,children:[jsxRuntimeExports.jsx("h3",{children:"Sign Message"}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("div",{className:styles$1.workBreak,children:dt?"Processing...":Tt||"No Signature"})}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("button",{className:styles$1.baseButton,disabled:!_e||dt,onClick:async()=>{try{yt(!0),at&&await mt({chainId:1});const Bt=await ft({message:"Example `personal_sign` message"});$t(Bt)}catch(Bt){console.log("🚀 ~ error:",Bt)}finally{yt(!1)}},children:"Sign Message"})})]})]})}):jsxRuntimeExports.jsxs("div",{className:styles$1.container,children:[jsxRuntimeExports.jsx("div",{children:"No Wallets To Connect Wallet"}),";"]})},mainnet=defineChain({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),config=createConfig({chains:[mainnet],connectors:[injected()],multiInjectedProviderDiscovery:!0,transports:{[mainnet.id]:http()}}),container="_container_hy1da_1",header="_header_hy1da_9",title$1="_title_hy1da_13",notice="_notice_hy1da_18",body="_body_hy1da_37",warning="_warning_hy1da_50",link="_link_hy1da_59",walletLogo="_walletLogo_hy1da_65",walletButtonContainer="_walletButtonContainer_hy1da_74",walletLogoButton="_walletLogoButton_hy1da_80",connectTypeButtonWrapper="_connectTypeButtonWrapper_hy1da_89",chainCategory="_chainCategory_hy1da_98",chain="_chain_hy1da_98",connectTypeButtonContainer="_connectTypeButtonContainer_hy1da_118",connectTypeButton="_connectTypeButton_hy1da_89",evm="_evm_hy1da_142",active="_active_hy1da_147",divider="_divider_hy1da_151",styles={container,header,title:title$1,notice,body,warning,link,walletLogo,walletButtonContainer,walletLogoButton,connectTypeButtonWrapper,chainCategory,chain,connectTypeButtonContainer,connectTypeButton,evm,active,divider},useCosmostation=()=>{const[c,g]=reactExports.useState(null),{isMobile:_e,isAndroid:tt,isiOS:ot,isChrome:at,isFirefox:ct}=useUserAgent(),vt=reactExports.useRef();reactExports.useEffect(()=>{window.cosmostation?g(window.cosmostation):vt.current=setTimeout(()=>{window.cosmostation&&g(window.cosmostation),clearTimeout(vt.current)},2e3)},[]);const bt=reactExports.useMemo(()=>c==null?void 0:c.cosmos,[c]),Tt=reactExports.useMemo(()=>!!c,[c]),$t=reactExports.useMemo(()=>{if(_e){if(tt)return"https://play.google.com/store/apps/details?id=wannabit.io.cosmostaion";if(ot)return"https://apps.apple.com/kr/app/cosmostation/id1459830339"}else{if(at)return"https://chromewebstore.google.com/detail/cosmostation-wallet/fpkhgmpbidmiogeglndfbkegfdlnajnf";if(ct)return"https://addons.mozilla.org/en-US/firefox/addon/cosmostation-wallet/"}return null},[_e,tt,ot,at,ct]),dt=reactExports.useCallback(It=>bt==null?void 0:bt.request({method:"cos_requestAccount",params:{chainName:It}}),[bt]),yt=reactExports.useCallback(It=>bt==null?void 0:bt.request({method:"cos_signDirect",params:{chainName:It.chainId,doc:{account_number:It.accountNumber.toString(),chain_id:It.chainId,auth_info_bytes:It.authInfoBytes,body_bytes:It.bodyBytes}}}),[bt]);return{isInstalled:Tt,downloadUrl:$t,provider:c,cosmos:bt,getAccount:dt,signDirect:yt}},queryClient=new QueryClient$2,connectType={"eip-6963":"eip-6963",wagmi:"wagmi","vanilla-cosmos":"vanilla-cosmos","@cosmostation/wallets":"@cosmostation/wallets"},title={"eip-6963":"Connect Ethereum Wallet With EIP-6963",wagmi:"Connect Ethereum Wallet With Wagmi","vanilla-cosmos":"Connect Cosmos Wallet with Vanilla","@cosmostation/wallets":"Connect Cosmos Wallet with @cosmostation/wallets"},App=()=>{const{isInstalled:c,downloadUrl:g}=useCosmostation(),{isMobile:_e,isAndroid:tt,isiOS:ot}=useUserAgent(),[at,ct]=reactExports.useState(connectType["eip-6963"]),vt=reactExports.useCallback(bt=>{ot?(window.location.href=`cosmostation://dapp?url=${bt}`,setTimeout(()=>{g&&(window.location.href=g)},3e3)):tt&&(window.location.href=`cosmostation://dapp?${bt}`)},[g,tt,ot]);return!c&&!g?jsxRuntimeExports.jsxs("div",{className:styles.warning,children:[jsxRuntimeExports.jsx("p",{children:"This client is not supported."}),jsxRuntimeExports.jsxs("p",{children:["Please access it using ",jsxRuntimeExports.jsx("i",{children:"Android / iOS"})," mobile devices or ",jsxRuntimeExports.jsx("i",{children:"Chrome / Firefox"})," on desktop."]})]}):!c&&g&&_e?jsxRuntimeExports.jsxs("div",{className:styles.warning,children:[jsxRuntimeExports.jsx("p",{children:"This page is accessible via the Cosmostation App Wallet or desktop web page."}),jsxRuntimeExports.jsxs("p",{children:[jsxRuntimeExports.jsx("a",{href:"#none",onClick:()=>vt(window.location.href),className:styles.link,children:"Click here"})," to launch the dApp within the Cosmostation App Wallet."]})]}):!c&&g&&!_e?jsxRuntimeExports.jsxs("div",{className:styles.warning,children:[jsxRuntimeExports.jsx("p",{children:"The Cosmostation Wallet Extension is missing."}),jsxRuntimeExports.jsxs("p",{children:[jsxRuntimeExports.jsx("a",{href:g,className:styles.link,target:"_blank",children:"Click here"})," to install, then refresh the page to continue."]})]}):jsxRuntimeExports.jsxs("div",{className:styles.container,children:[jsxRuntimeExports.jsx("h1",{className:styles.header,children:title[at]}),jsxRuntimeExports.jsxs("div",{className:styles.connectTypeButtonWrapper,children:[jsxRuntimeExports.jsxs("div",{className:styles.chainCategory,children:[jsxRuntimeExports.jsxs("div",{className:styles.chain,children:[jsxRuntimeExports.jsx("img",{src:EthereumImage}),jsxRuntimeExports.jsx("h6",{children:"Ethereum networks"})]}),jsxRuntimeExports.jsxs("div",{className:styles.connectTypeButtonContainer,children:[jsxRuntimeExports.jsx("button",{className:`${styles.connectTypeButton} ${at===connectType["eip-6963"]?styles.active:""}`,onClick:()=>ct(connectType["eip-6963"]),children:jsxRuntimeExports.jsxs("h3",{children:["use",jsxRuntimeExports.jsx("br",{}),"EIP-6963"]})}),jsxRuntimeExports.jsx("button",{className:`${styles.connectTypeButton} ${at===connectType.wagmi?styles.active:""}`,onClick:()=>ct(connectType.wagmi),children:jsxRuntimeExports.jsxs("h3",{children:["use",jsxRuntimeExports.jsx("br",{}),"Wagmi"]})})]})]}),jsxRuntimeExports.jsx("div",{className:styles.divider}),jsxRuntimeExports.jsxs("div",{className:styles.chainCategory,children:[jsxRuntimeExports.jsxs("div",{className:styles.chain,children:[jsxRuntimeExports.jsx("img",{src:CosmosImage}),jsxRuntimeExports.jsx("h6",{children:"Cosmos networks"})]}),jsxRuntimeExports.jsxs("div",{className:styles.connectTypeButtonContainer,children:[jsxRuntimeExports.jsx("button",{className:`${styles.connectTypeButton} ${at===connectType["vanilla-cosmos"]?styles.active:""}`,onClick:()=>ct(connectType["vanilla-cosmos"]),children:jsxRuntimeExports.jsxs("h3",{children:["use",jsxRuntimeExports.jsx("br",{}),"Vanilla"]})}),jsxRuntimeExports.jsx("button",{className:`${styles.connectTypeButton} ${at===connectType["@cosmostation/wallets"]?styles.active:""}`,onClick:()=>ct(connectType["@cosmostation/wallets"]),children:jsxRuntimeExports.jsxs("h3",{children:["use",jsxRuntimeExports.jsx("br",{}),"wallets pkg"]})})]})]})]}),at===connectType["eip-6963"]&&jsxRuntimeExports.jsx(VanillaEthereumConnect,{}),at===connectType.wagmi&&jsxRuntimeExports.jsx(WagmiProvider,{config,children:jsxRuntimeExports.jsx(QueryClientProvider$1,{client:queryClient,children:jsxRuntimeExports.jsx(Wagmi,{})})}),at===connectType["vanilla-cosmos"]&&jsxRuntimeExports.jsx(VanillaCosmosConnect,{}),at===connectType["@cosmostation/wallets"]&&jsxRuntimeExports.jsx(y,{children:jsxRuntimeExports.jsx(CosmostationWalletsPkg,{})}),jsxRuntimeExports.jsxs("div",{className:styles.notice,children:[jsxRuntimeExports.jsxs("p",{children:["This page is a sample dApp that allows users to transfer tokens to their wallet. It was designed for developers building dApps with the"," ",jsxRuntimeExports.jsx("b",{children:"Cosmostation App Wallet"})," or ",jsxRuntimeExports.jsx("b",{children:"Extension Wallet"}),"."]}),jsxRuntimeExports.jsxs("p",{children:[jsxRuntimeExports.jsx("a",{className:styles.link,href:"https://github.com/cosmostation/cosmostation-app-injection-example",target:"_blank",children:"Click here"})," to view the complete code."]})]})]})};var createRoot,m=reactDomExports;createRoot=m.createRoot,m.hydrateRoot;createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(reactExports.StrictMode,{children:jsxRuntimeExports.jsx(App,{})})); diff --git a/index.html b/index.html index 20abfec..f43af6b 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ Cosmostation App Injection Example - +