@nexus-cross/connect-kit-react 1.4.0-beta.6 → 1.4.0-beta.8
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/README.md +55 -2
- package/dist/chunk-OZRWNMCO.js +144 -0
- package/dist/client.d.ts +2 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +77 -19
- package/dist/index.js +1 -1
- package/package.json +8 -7
- package/dist/chunk-PEAZQ65Y.js +0 -144
package/README.md
CHANGED
|
@@ -244,6 +244,56 @@ For address, chain, balance, and signing use **wagmi's own hooks**
|
|
|
244
244
|
(`useAccount`, `useBalance`, `useSignMessage`, …). This package doesn't
|
|
245
245
|
reinvent them.
|
|
246
246
|
|
|
247
|
+
### `useOnePopSummary()`
|
|
248
|
+
|
|
249
|
+
Fetches the state shown on WalletInfo's **ONEpop** screen (pending claims,
|
|
250
|
+
recent activity) via `@nexus-cross/pop` and shapes it into dapp-ui's
|
|
251
|
+
`OnePopSummary`. dapp-ui can't do this itself — it may not depend on viem, and
|
|
252
|
+
one-pop-api's `/drops` / `/histories` require a cross-auth SIWE JWT.
|
|
253
|
+
|
|
254
|
+
Set `onePopEnabled: true` on the kit config and `<ConnectButton>` wires it for
|
|
255
|
+
you; call the hook directly only if you render the data elsewhere.
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
const { summary, isLoading, error, refetch } = useOnePopSummary({
|
|
259
|
+
enabled: userOpenedTheOnePopScreen, // gates the SIWE signature prompt
|
|
260
|
+
repliesWaitingCount: 0, // no backend contract yet — you supply it
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
SIWE pops a wallet dialog, so `enabled` must stay `false` until the user
|
|
265
|
+
actually opens the screen (`ConnectButton` flips it on `onOnePopOpen`). The
|
|
266
|
+
issued token is cached per address in memory for the session; a declined
|
|
267
|
+
signature is not retried. Use `clearOnePopJwtCache()` to drop it.
|
|
268
|
+
|
|
269
|
+
Executing drops (deposit / withdraw / refund) is **not** wrapped here — use
|
|
270
|
+
`@nexus-cross/pop` directly and pass the destinations to `WalletInfo` via
|
|
271
|
+
`onOnePopSend` / `onOnePopClaim` / `onOnePopActivity`.
|
|
272
|
+
|
|
273
|
+
### ONEpop's "Get ONEUSD"
|
|
274
|
+
|
|
275
|
+
With ONEpop on, `<ConnectButton>` also drops a `<CrossGetOneUsd mode="button">`
|
|
276
|
+
into the ONEpop screen's `Get ONEUSD ›` slot, so the link opens the same
|
|
277
|
+
Swap / Bridge / Transfer chooser as the floating widget instead of navigating
|
|
278
|
+
to the gametoken bridge. Pass widget options through `onePopGetTokenOptions`
|
|
279
|
+
(e.g. share the relay client your app already builds, or collect telemetry):
|
|
280
|
+
|
|
281
|
+
```tsx
|
|
282
|
+
<ConnectButton
|
|
283
|
+
onePopGetTokenOptions={{
|
|
284
|
+
relay: { client: relayClient },
|
|
285
|
+
onEvent: (event) => track(event.name, event),
|
|
286
|
+
}}
|
|
287
|
+
/>
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
To replace the trigger entirely — or to keep the old deep link — pass
|
|
291
|
+
`onePopGetTokenSlot` yourself (`null` restores the deep link). The widget only
|
|
292
|
+
mounts once the user opens the ONEpop screen, and it unmounts with the wallet,
|
|
293
|
+
so a long-running swap's status pill lives only as long as the wallet stays
|
|
294
|
+
open; mount a root-level `<CrossGetOneUsd mode="floating">` if you need it to
|
|
295
|
+
outlive that.
|
|
296
|
+
|
|
247
297
|
## Re-exports
|
|
248
298
|
|
|
249
299
|
For convenience, `@nexus-cross/connect-kit-react` re-exports the types and the
|
|
@@ -323,8 +373,11 @@ createCrossxConfig({
|
|
|
323
373
|
## Allowed dependencies
|
|
324
374
|
|
|
325
375
|
This package may depend on: `@nexus-cross/connect-kit-core`,
|
|
326
|
-
`@nexus-cross/connect-kit-wagmi`,
|
|
327
|
-
|
|
376
|
+
`@nexus-cross/connect-kit-wagmi`, `@nexus-cross/dapp-ui`, and
|
|
377
|
+
`@nexus-cross/pop` — **`/api` subpath only** (read-only ONEpop wiring behind
|
|
378
|
+
`onePopEnabled`; `/api` is fetch-only, so this package stays viem-free —
|
|
379
|
+
`/adapters` would pull viem in). React, wagmi, and TanStack Query stay peer
|
|
380
|
+
dependencies of the consuming app.
|
|
328
381
|
|
|
329
382
|
It must not own low-level wallet transport logic. External SDK access belongs in
|
|
330
383
|
the wagmi layer; this package composes providers, React context, hooks, and
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
var gt="1.4.0-beta.8";var Pt="__nexusCrossAppLauncherRuntime";function Fo(){if(typeof window>"u")return null;let e=window;return e[Pt]??(e[Pt]={mode:"dapp-ui"}),e[Pt]}function Lo(e){if(e.scheduled)return;e.scheduled=!0;let t=()=>{if(e.scheduled=!1,e.loggedMode!==e.mode){if(e.mode==="connect-kit-react"){let n=e.connectKitVersion??gt;console.info(`[CROSSx App Launcher] connect-kit-react v${n} \uCD08\uAE30\uD654 \uC644\uB8CC (dapp-ui v${gt}, \uC0AC\uC6A9 \uBAA8\uB4DC: connect-kit)`)}else console.info(`[CROSSx App Launcher] dapp-ui v${gt} \uCD08\uAE30\uD654 \uC644\uB8CC (\uC0AC\uC6A9 \uBAA8\uB4DC: dapp-ui only)`);e.loggedMode=e.mode}};typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)}function fn(){let e=Fo();e&&(e.mode="connect-kit-react",e.connectKitVersion=gt,Lo(e))}import{useCallback as Re,useEffect as ne,useMemo as We,useRef as ge,useState as Xe}from"react";import{WagmiProvider as Vo,useAccount as jo,useChainId as Qo,useConnect as zo,useDisconnect as Xo,useSwitchChain as Yo}from"wagmi";import{QueryClient as Jo,QueryClientProvider as Zo}from"@tanstack/react-query";import{attachEmbeddedAuthSync as er,clearWalletSessionStorage as Cn,onOpenOtherWallets as tr,pickInitialState as nr,resolveCurrentWallet as or}from"@nexus-cross/connect-kit-wagmi";import{resolveThemeMode as rr}from"@nexus-cross/connect-kit-core";import{buildDesignSystemCss as sr}from"@nexus-cross/crossx-design-system";import{OnRampProvider as ir}from"@nexus-cross/onramp/react";import{KycProvider as ar}from"@nexus-cross/kyc/react";import{createContext as Uo,useContext as Mo}from"react";var Mt=Uo(null);function Ae(){let e=Mo(Mt);if(!e)throw new Error("useCrossConnectKit must be used within <CrossConnectKitProvider>");return e}import{createContext as Go,useContext as gn}from"react";var St=Go(null);function Ko(){let e=gn(St);if(!e)throw new Error("useCrossConnectKitTheme must be used within <CrossConnectKitProvider>");return e}function yt(){return gn(St)}import{createContext as $o}from"react";var At=$o(null);function yn(){let e=new Set,t=n=>{for(let s of[...e])try{s(n)}catch(o){console.debug("[crossx-kit] analytics handler threw",o)}};return{track:t,emit:n=>t({...n,timestamp:Date.now()}),subscribe:n=>(e.add(n),()=>{e.delete(n)})}}import{useCallback as qo,useMemo as bn}from"react";import{WalletConnectModal as hn}from"@nexus-cross/dapp-ui";import{jsx as wn}from"react/jsx-runtime";var Ho=new Set(["cross_wallet","cross_extension","metamask","binance"]);function Gt({open:e,onOpenChange:t}){let{connect:n,availableWallets:s,oauth:o,extraWallets:c,walletAllowlist:g,kitConfig:y}=Ae(),r=yt()?.mode??"dark",m=bn(()=>{let p=g?new Set(g):null,k={};for(let T of s){if(!Ho.has(T.walletId)||p&&!p.has(T.walletId))continue;let x=T.walletId;k[x]=()=>{n(T.walletId)}}for(let[T,x]of Object.entries(c))x&&(p&&!p.has(T)||(k[T]=x));return k},[s,n,c,g]),b=bn(()=>{if(o)return{apple:()=>{o.signIn("apple")},google:()=>{o.signIn("google")}}},[o]),C=qo(p=>t(p),[t]);return wn(hn,{wallets:m,socialProviders:b,termsUrl:y.legal?.termsUrl,privacyUrl:y.legal?.privacyUrl,theme:r,open:e,onOpenChange:C,children:wn(hn.Content,{})})}import{jsx as Ye,jsxs as vn}from"react/jsx-runtime";var cr=new Jo,Kt="crossx-kit:last-wallet-intent",dr=15e3,lr=1500,ur=3;function kn(e,t){return Promise.race([e.then(()=>{},()=>{}),new Promise(n=>setTimeout(n,t))])}function pr(e){let t=[],n=e,s=0;for(;n&&s<5;){let o=n;typeof o.message=="string"&&t.push(o.message),n=o.cause,s+=1}return t.some(o=>/external wallet connection/i.test(o))}function mr(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Kt)??null}catch{return null}}function Tn(e){if(!(typeof window>"u"))try{e?window.localStorage.setItem(Kt,e):window.localStorage.removeItem(Kt)}catch{}}function fr(e,t){if(typeof window>"u")return t;try{let n=window.localStorage.getItem(e);return n==="cross"||n==="reown"?n:t}catch{return t}}function gr(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function yr({children:e,config:t,activeProvider:n,onRequestProviderSwap:s,pendingConnectWalletId:o,clearPending:c,themeMode:g,themeTokens:y,extraWallets:u,walletAllowlist:r,emit:m}){let[b,C]=Xe(!1),[p,k]=Xe(()=>mr()),[T,x]=Xe(null),{address:P,isConnected:v,isConnecting:W,isReconnecting:R,connector:_}=jo(),{connectors:q,connectAsync:U}=zo(),{disconnectAsync:z}=Xo(),{kitConfig:M,connectorRegistry:H,crossProvider:Ee,reownProvider:ke}=t,L=n==="cross"?Ee:ke,O=We(()=>!v||!_?null:or(H,_.id,p),[v,_,H,p]),X=We(()=>H.entries.filter(l=>l.type!=="embedded"),[H]),ee=Re(l=>H.getEntry(l)?.type??"external",[H]),Se=ge(null);Se.current=T;let Ue=ge(O);Ue.current=O;let Ve=ge(P);Ve.current=P;let Me=M.embeddedProjectId?.trim()||M.crossProjectId?.trim(),oe=!!M.onRampEnabled&&!!Me,ue=We(()=>!oe||!Me?null:{projectId:Me,walletState:{getAddress:()=>Ve.current}},[oe,Me]),re=ge(_);re.current=_;let Te=M.embeddedProjectId?.trim()||M.crossProjectId?.trim(),_e=!!M.kycEnabled&&!!Te,je=We(()=>!_e||!Te?null:{projectId:Te,getAccessToken:async()=>{let l=re.current;if(!(!l||typeof l.getProvider!="function"))try{return(await(await l.getProvider())?.sdk?.getUserInfo?.())?.data?.accessToken||void 0}catch{return}}},[_e,Te]);ne(()=>tr(()=>C(!0)),[]),ne(()=>{if(!b||typeof document>"u")return;let l=setTimeout(()=>{document.querySelectorAll("#__crossx-confirm-overlay").forEach(h=>h.remove())},50);return()=>clearTimeout(l)},[b]);let be=ge(v),tt=ge(v);be.current=v;let ve=ge(!1);ne(()=>{console.debug("[crossx-kit] state",{activeProvider:n,isConnected:v,isConnecting:W,isReconnecting:R,activeConnectorId:_?.id,currentWallet:O,lastIntent:p})},[n,v,W,R,_?.id,O,p]),ne(()=>{v&&!tt.current&&L?.closeModal?.({kitConfig:M}),tt.current=v},[v,L,M]),ne(()=>{v&&x(null)},[v]);let Qe=Qo(),{switchChainAsync:nt}=Yo(),Be=ge(null);ne(()=>{if(!M.enforceDefaultNetworkOnConnect)return;let l=M.defaultNetwork?.id;if(!l)return;if(!v||!P||!_){Be.current=null;return}let h=`${_.id}:${P}`;Be.current!==h&&(Be.current=h,Qe!==l&&nt({chainId:l}).catch(()=>{}))},[M.enforceDefaultNetworkOnConnect,M.defaultNetwork,v,P,_,Qe,nt]);let Ge=ge(b);ne(()=>{b&&!Ge.current?m({name:"connect_modal_opened"}):!b&&Ge.current&&m({name:"connect_modal_closed",completed:be.current}),Ge.current=b},[b,m]);let ct=ge(v);ne(()=>{if(v&&!ct.current){let l=Se.current;l&&m({name:"connect_succeeded",walletId:l,walletType:ee(l),chainId:Qe})}ct.current=v},[v,Qe,m,ee]);let i=Re(l=>q.find(h=>h.id===l),[q]);ne(()=>{let l=H.getEntry("cross_embedded");if(!l)return;let h=i(l.connectorId);if(!h)return;let I=!1;return(async()=>{try{let E=await h.getProvider();if(I)return;E?.sdk?.applyTheme?.(g,y??void 0)}catch(E){console.debug("[crossx-kit] applyTheme skipped:",E)}})(),()=>{I=!0}},[H,i,g,y]);let a=Re(l=>{k(l),Tn(l)},[]),d=Re(()=>{k(null),Tn(null),x(null)},[]);ne(()=>{if(!L?.subscribeModalState)return;let l=!1;return L.subscribeModalState({kitConfig:M},h=>{if(ve.current=h,h){l=!0;return}l&&(l=!1,setTimeout(()=>{if(be.current)return;let I=Se.current;I&&m({name:"connect_cancelled",walletId:I,stage:"popup"}),(async()=>{try{await z()}catch{}d()})()},250))})},[L,M,z,d,m]),ne(()=>{if(!T||v||typeof window>"u"||T==="cross_embedded")return;let l=typeof document<"u"&&!document.hasFocus(),h=null,I=()=>{l=!0},E=()=>{l&&(h&&clearTimeout(h),h=setTimeout(()=>{if(be.current||ve.current)return;let B=Se.current;B&&m({name:"connect_cancelled",walletId:B,stage:"popup"}),(async()=>{try{await z()}catch{}d()})()},1e3))};return window.addEventListener("blur",I),window.addEventListener("focus",E),()=>{window.removeEventListener("blur",I),window.removeEventListener("focus",E),h&&clearTimeout(h)}},[T,v,z,d,m]);let f=Re(async l=>{console.debug("[crossx-kit] runConnect enter",{walletId:l,activeProvider:n,isConnected:v,activeConnectorId:_?.id});let h=H.getEntry(l);if(!h){if((l==="metamask"||l==="binance")&&!ke){console.error(`[crossx-kit] "${l}" requires the Reown adapter, but it is not configured. Pass \`reownProjectId\` (and ensure \`reown\` is not set to \`false\`) when calling createConnectKitConfig() or createCrossxConfig() to enable WalletConnect-based wallets.`);return}console.error(`[crossx-kit] Unknown walletId: "${l}"`);return}if(x(l),h.providerKind!==n){console.debug("[crossx-kit] provider swap needed",{from:n,to:h.providerKind,walletId:l}),a(l);try{await z()}catch{}await new Promise(B=>setTimeout(B,0)),s(h.providerKind,l);return}let I=ee(l);if(m({name:"wallet_selected",walletId:l,walletType:I}),m({name:"connect_started",walletId:l,walletType:I}),a(l),L?.beforeConnect)try{let B=await L.beforeConnect({kitConfig:M,themeMode:g},l);if(console.debug("[crossx-kit] beforeConnect result",{walletId:l,result:B}),B==="handled")return}catch(B){console.warn('[crossx-kit] adapter.beforeConnect threw for "%s":',l,B)}let E=i(h.connectorId);if(console.debug("[crossx-kit] findConnector",{lookupId:h.connectorId,found:E?.id,availableIds:q.map(B=>B.id)}),!E){console.error(`[crossx-kit] Connector "${h.connectorId}" not found on provider "${h.providerKind}". Available: ${q.map(B=>B.id).join(", ")}`),m({name:"connect_failed",walletId:l,reason:"connector_not_found"}),d();return}try{console.debug("[crossx-kit] connectAsync start",{connectorId:E.id});let B=await U({connector:E});console.debug("[crossx-kit] connectAsync resolved",{accountsLen:B.accounts.length,chainId:B.chainId});return}catch(B){let Ie=pr(B);if(!Ie){console.error('[crossx-kit] connectAsync error for "%s":',l,B);try{await z()}catch{}}if(!h.fallbackConnectorId){Ie||m({name:"connect_failed",walletId:l,reason:"connector_error"}),d();return}}if(h.fallbackConnectorId){let B=i(h.fallbackConnectorId);if(B)try{await U({connector:B})}catch(Ie){console.error('[crossx-kit] Fallback connect failed for "%s":',l,Ie);try{await z()}catch{}m({name:"connect_failed",walletId:l,reason:"fallback_failed"}),d()}else m({name:"connect_failed",walletId:l,reason:"fallback_failed"}),d()}},[H,q,i,U,z,a,d,L,n,M,s,g,m,ee]);ne(()=>{if(!o)return;let l=o;c(),f(l)},[o,n]);let w=Re(async()=>{C(!0)},[]),N=Re(async()=>{m({name:"disconnected",walletId:Ue.current});try{await z()}catch(l){console.error("[crossx-kit] wagmi disconnect error:",l)}if(L?.teardown)try{await L.teardown({kitConfig:M})}catch(l){console.error("[crossx-kit] adapter teardown error:",l)}Cn(),d()},[z,L,M,d,m]),D=Re(async()=>{await kn(z(),3e3);try{let l=H.getEntry("cross_embedded"),h=l&&i(l.connectorId);if(h?.getProvider){let I=await Promise.race([h.getProvider(),new Promise(B=>setTimeout(B,3e3))]),E=I?.sdk?.signOut;typeof E=="function"&&await kn(E.call(I.sdk),3e3)}}catch{}Cn()},[H,i,z]),A=Re(async()=>{let l=H.getEntry("cross_embedded");if(!l)return null;let h=i(l.connectorId);if(!h)return null;try{let I=await h.getProvider(),E=I?.sdk;if(!E?.selectWallet)return null;let B=await E.selectWallet(E.currentAddress??void 0);return B?.address&&I.notifyAccountsChanged&&I.notifyAccountsChanged([B.address]),B&&m({name:"wallet_switched",index:B.index}),B}catch{return null}},[H,i,m]),G=We(()=>{let l=t.oauth;return l?{signIn:async h=>{x("cross_embedded"),m({name:"wallet_selected",walletId:"cross_embedded",walletType:"embedded"}),m({name:"connect_started",walletId:"cross_embedded",walletType:"embedded"});try{await l.signIn(h)}catch(I){throw m({name:"connect_cancelled",walletId:"cross_embedded",stage:"popup"}),x(null),I}}}:null},[t.oauth,m]),Y=ge(!1);ne(()=>{if(n!=="cross"||v||W||R||T!=null||Y.current)return;let l=H.getEntry("cross_embedded");if(!l)return;let h=i(l.connectorId);if(!h)return;Y.current=!0;let I=!1;return(async()=>{try{let E=await h.isAuthorized?.();if(I||!E)return;await U({connector:h})}catch{}})(),()=>{I=!0}},[n,v,W,R,T,H,i,U]);let S=ge(0);ne(()=>{if(n!=="cross"||v||!W&&!R||S.current>=ur)return;let l=H.getEntry("cross_embedded");if(!l)return;let h=i(l.connectorId);if(!h)return;let I=!1,E=setInterval(()=>{(async()=>{if(I||be.current)return;let B=await Promise.resolve(h.isAuthorized?.()).catch(()=>!1);if(!(I||!B||be.current)){S.current+=1,console.warn("[crossx-kit] wagmi reconnect stalled while the SDK holds a session \u2014 forcing an explicit connect to realign");try{await U({connector:h})}catch{}}})()},lr);return()=>{I=!0,clearInterval(E)}},[n,v,W,R,H,i,U]),ne(()=>{if(T!=="cross_embedded"||v||typeof window>"u")return;let l=!document.hasFocus(),h=()=>{l=!0};window.addEventListener("blur",h);let I=setTimeout(()=>{be.current||l||(console.warn("[crossx-kit] embedded sign-in stalled before the OAuth popup opened \u2014 clearing the stale session so a retry starts clean"),m({name:"connect_cancelled",walletId:"cross_embedded",stage:"stalled"}),d(),D())},dr);return()=>{window.removeEventListener("blur",h),clearTimeout(I)}},[T,v,d,D,m]);let F=T!=null&&!v,V=We(()=>({kitConfig:M,connectorRegistry:H,availableWallets:X,connect:f,connectWallet:w,disconnect:N,selectWallet:A,currentWallet:O,lastIntent:p,isConnecting:F,connectingWalletId:T,openOtherWallets:()=>C(!0),closeOtherWallets:()=>C(!1),otherWalletsOpen:b,oauth:G,extraWallets:u,walletAllowlist:r,onRampEnabled:oe}),[M,H,X,f,w,N,A,O,p,F,T,b,G,u,r,oe]),j=vn(Mt.Provider,{value:V,children:[e,Ye(Gt,{open:b,onOpenChange:C})]});return je&&(j=Ye(ar,{config:je,children:j})),ue&&(j=Ye(ir,{config:ue,children:j})),j}var br=[/Connection interrupted while trying to subscribe/i,/No matching key\. subscription:/i,/Proposal expired/i];function hr(e){let t=e?.message;return typeof t!="string"?!1:br.some(n=>n.test(t))}var wr={};function Cr(e){return e&&{...e,connections:new Map,current:null}}function kr({children:e,config:t,initialState:n,extraWallets:s=wr,walletAllowlist:o}){let[c,g]=Xe(()=>fr(t.activeProviderStorageKey,t.defaultProvider)),[y,u]=Xe(null),r=ge(!1),m=ge(null);m.current||(m.current=yn());let b=m.current,C=We(()=>({subscribe:b.subscribe}),[b]),{kitConfig:p}=t,[k,T]=Xe(null),[x,P]=Xe(null),[v,W]=Xe(0),R=We(()=>rr(p.theme,p.autoDetectTheme),[p.theme,p.autoDetectTheme,v]),_=k??R,q=x??p.themeTokens;ne(()=>{if(!p.autoDetectTheme||k||typeof window>"u"||!window.matchMedia)return;let O=window.matchMedia("(prefers-color-scheme: dark)"),X=()=>W(ee=>ee+1);try{return O.addEventListener("change",X),()=>O.removeEventListener("change",X)}catch{return O.addListener(X),()=>O.removeListener(X)}},[p.autoDetectTheme,k]),ne(()=>{if(typeof document>"u")return;let O=document.documentElement,X=O.getAttribute("data-ds-theme"),ee=O.getAttribute("data-theme");return O.setAttribute("data-ds-theme",_),ee||O.setAttribute("data-theme",_),()=>{X==null?O.removeAttribute("data-ds-theme"):O.setAttribute("data-ds-theme",X),ee==null&&O.removeAttribute("data-theme")}},[_]);let U=We(()=>sr(t.designSystem),[t.designSystem]),z=We(()=>({mode:_,tokens:q,setThemeMode:O=>T(O),setThemeTokens:O=>P(O)}),[_,q]);ne(()=>{if(typeof window>"u")return;let O=X=>{hr(X.reason)&&X.preventDefault()};return window.addEventListener("unhandledrejection",O),()=>window.removeEventListener("unhandledrejection",O)},[]),ne(()=>{if(c!=="cross")return;let O=t.crossWagmiConfig;if(O)return er(O)},[c,t.crossWagmiConfig]);let M=Re((O,X)=>{r.current||(r.current=!0,u(X),g(O),gr(t.activeProviderStorageKey,O),queueMicrotask(()=>{r.current=!1}))},[t.activeProviderStorageKey]),H=Re(()=>u(null),[]),Ee=c==="cross"?t.crossWagmiConfig:t.reownWagmiConfig,ke=Cr(nr(n,c));if(!Ee){if(!(c==="cross"?t.reownWagmiConfig:t.crossWagmiConfig))throw new Error("[crossx-kit] createCrossxConfig returned no wagmi Config for either side");let X=c==="cross"?"reown":"cross";queueMicrotask(()=>g(X))}let L=Ee??(c==="cross"?t.reownWagmiConfig:t.crossWagmiConfig);return Ye(At.Provider,{value:C,children:vn(St.Provider,{value:z,children:[Ye("style",{"data-crossx-design-system":"",children:U}),Ye(Vo,{config:L,initialState:ke,children:Ye(Zo,{client:cr,children:Ye(yr,{config:t,activeProvider:c,onRequestProviderSwap:M,pendingConnectWalletId:y,clearPending:H,themeMode:_,themeTokens:q,extraWallets:s,walletAllowlist:o??t.kitConfig.wallets??null,emit:b.emit,children:e})})},c)]})})}import{useCallback as He,useEffect as ri,useMemo as Tt,useState as si}from"react";import{useQueryClient as ii}from"@tanstack/react-query";import{useAccount as ai,useChainId as ci,useConfig as di,useSendTransaction as li,useSwitchChain as ui}from"wagmi";import{getPublicClient as Zt,readContracts as no}from"wagmi/actions";import{WalletInfo as en,ConnectorId as et,OnePopGetTokenTrigger as pi,resolveEnvironment as mi,WALLET_REGISTRY as fi}from"@nexus-cross/dapp-ui";import{useOptionalOnRamp as gi,useOptionalOnRampEligibility as yi}from"@nexus-cross/onramp/react";import{APPLE_ICON as rn,BINANCE_ICON as so,CROSSX_ICON as on,EXTENSION_ICON as bi,GOOGLE_ICON as io,METAMASK_ICON as ao}from"@nexus-cross/connect-kit-wagmi";import{WALLET_LABELS as vt}from"@nexus-cross/crossx-design-system";import{useCallback as Us,useMemo as zn}from"react";import{useAccount as Ms,useConfig as Gs}from"wagmi";import{waitForTransactionReceipt as Ks}from"wagmi/actions";import{GetOneUsd as $s,resolveEnvironment as qs}from"@nexus-cross/dapp-ui";import{useCallback as ie,useMemo as Ce,useRef as Tr}from"react";import{useQueries as Pn,useQuery as Je}from"@tanstack/react-query";import{encodeFunctionData as bt,formatUnits as Nt,parseSignature as vr,parseUnits as Ir}from"viem";import{getChainId as $t,getPublicClient as Mn,readContract as Oe,signTypedData as xr,switchChain as Sn,waitForTransactionReceipt as Pr,writeContract as An}from"wagmi/actions";import{useConfig as Sr}from"wagmi";async function Rt(e,t,n){if(!(!n||t===void 0))try{if(e.getChainId()===t)return;await e.switchChain(t)}catch{}}var ut=10000n;function In(e){let t=e==="auto"?1:Number(e||"1");return!Number.isFinite(t)||t<0?100n:BigInt(Math.min(1e4,Math.floor(t*100)))}function Ot(e,t){let n=In(t);return n>=ut?0n:e*(ut-n)/ut}function xn(e,t){let n=In(t);return(e*(ut+n)+(ut-1n))/ut}function Ar(e){return e!=="bridge"}var qe="0x0000000000000000000000000000000000000000",Pe=100,mt=18,Rr=180000n,Or=500000n,Gn=new Set([56,97]),Er=130n,_r=100n,Br={dev:"https://stg-contents.crosstoken.io/frontend/game-token/json/hidden-path.json",stage:"https://stg-contents.crosstoken.io/frontend/game-token/json/hidden-path.json",production:"https://contents.crosstoken.io/frontend/game-token/json/hidden-path.json"},Nr={dev:"dev",stage:"stg",production:"prod"};function Wr(e,t){let n=e?.[Nr[t]]?.hiddenPairs;if(!Array.isArray(n))return null;let s=n.filter(o=>!!o&&typeof o=="object"&&typeof o.fromKey=="string"&&typeof o.toKey=="string");return s.length>0?s:null}var Dr={dev:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/contracts.json",stage:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/contracts.json",production:"https://contents.crosstoken.io/frontend/common/app-launcher/contracts.json"},Fr=["BSC_CROSS","W_CROSS","NATIVE_CROSS","USDTX","CROSSD","USDTB","SWAP_BRIDGE_ROUTER"],Lr={BSC_CROSS:qe,W_CROSS:qe,NATIVE_CROSS:qe,USDTX:qe,CROSSD:qe,USDTB:qe,SWAP_BRIDGE_ROUTER:qe},Ur=/^0x[0-9a-fA-F]{40}$/;function Mr(e,t){let n=typeof e=="string"?e:e?.[t];return typeof n=="string"&&Ur.test(n)?n:null}function Gr(e,t){if(!e?.bridge)return null;let n=e.envToNetwork?.[t]??(t==="production"?"mainnet":"testnet"),s={};for(let o of Fr){let c=Mr(e.bridge[o],n);if(!c)return null;s[o]=c}return s}var Kr={dev:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97}},stage:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97}},production:{bridgeApi:"https://bridge-api.crosstoken.io/bridge",walletApi:"https://wallet-server.crosstoken.io/api",chainIds:{cross:612055,bsc:56}}},rt=[{type:"function",name:"quoter",stateMutability:"view",inputs:[],outputs:[{name:"",type:"address"}]},{type:"function",name:"swapRouter",stateMutability:"view",inputs:[],outputs:[{name:"",type:"address"}]},{type:"function",name:"getAmountSwapBridgeOut",stateMutability:"view",inputs:[{name:"toChainID",type:"uint256"},{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountIn",type:"uint256"}],outputs:[{name:"ok",type:"bool"},{name:"swapAmountOut",type:"uint256"},{name:"bridgeValue",type:"uint256"},{name:"networkFee",type:"uint256"},{name:"exFee",type:"uint256"}]},{type:"function",name:"getAmountSwapBridgeIn",stateMutability:"view",inputs:[{name:"toChainID",type:"uint256"},{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"bridgeValue",type:"uint256"}],outputs:[{name:"ok",type:"bool"},{name:"amountIn",type:"uint256"},{name:"swapAmountOut",type:"uint256"},{name:"networkFee",type:"uint256"},{name:"exFee",type:"uint256"}]},{type:"function",name:"swapBridgeExactInputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountIn",type:"uint256"},{name:"amountOutMinimum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"bridgeParams",type:"tuple",components:[{name:"toChainID",type:"uint256"},{name:"recipient",type:"address"},{name:"extraData",type:"bytes"}]}]},{name:"deadline",type:"uint256"}],outputs:[{name:"amountOut",type:"uint256"}]},{type:"function",name:"swapBridgeExactOutputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountOut",type:"uint256"},{name:"amountInMaximum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"bridgeParams",type:"tuple",components:[{name:"toChainID",type:"uint256"},{name:"recipient",type:"address"},{name:"extraData",type:"bytes"}]}]},{name:"deadline",type:"uint256"}],outputs:[{name:"amountIn",type:"uint256"}]}],qt=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Rn=[{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{name:"",type:"string"}]},{type:"function",name:"nonces",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"",type:"uint256"}]}],On=[{type:"function",name:"quoteExactInputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amountIn",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountOut",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}]},{type:"function",name:"quoteExactOutputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amount",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountIn",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}]}],$r=[{type:"function",name:"slot0",stateMutability:"view",inputs:[],outputs:[{name:"sqrtPriceX96",type:"uint160"},{name:"tick",type:"int24"},{name:"observationIndex",type:"uint16"},{name:"observationCardinality",type:"uint16"},{name:"observationCardinalityNext",type:"uint16"},{name:"feeProtocol",type:"uint8"},{name:"unlocked",type:"bool"}]}],Ke=[{type:"function",name:"exactInputSingle",stateMutability:"payable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"recipient",type:"address"},{name:"deadline",type:"uint256"},{name:"amountIn",type:"uint256"},{name:"amountOutMinimum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountOut",type:"uint256"}]},{type:"function",name:"multicall",stateMutability:"payable",inputs:[{name:"data",type:"bytes[]"}],outputs:[{name:"results",type:"bytes[]"}]},{type:"function",name:"unwrapWETH9",stateMutability:"payable",inputs:[{name:"amountMinimum",type:"uint256"},{name:"recipient",type:"address"}],outputs:[]},{type:"function",name:"refundETH",stateMutability:"payable",inputs:[],outputs:[]}],qr=[{type:"function",name:"bridgeToken",stateMutability:"payable",inputs:[{name:"toChainID",type:"uint256"},{name:"fromToken",type:"address"},{name:"to",type:"address"},{name:"value",type:"uint256"},{name:"gasFee",type:"uint256"},{name:"exFee",type:"uint256"},{name:"extraData",type:"bytes"}],outputs:[{name:"",type:"bool"}]}];async function Kn(e){let t="";try{t=await e.text()}catch{}if(t){try{let n=JSON.parse(t),s=typeof n.data=="string"&&n.data||typeof n.message=="string"&&n.message||"";if(s)return`${s} (status ${e.status})`}catch{}return`${t.slice(0,300)} (status ${e.status})`}return`status ${e.status}`}async function De(e,t){let n=await fetch(e,{cache:"no-store",signal:t});if(!n.ok)throw new Error(`CrossD bridge adapter request failed: ${await Kn(n)}`);let s=await n.json();if(s&&typeof s=="object"&&"code"in s&&typeof s.code=="number"&&s.code!==200)throw new Error(s.message||`CrossD bridge adapter API error: ${s.code}`);return s&&typeof s=="object"&&"data"in s?s.data:s}async function En(e,t,n){let s=await fetch(e,{method:"POST",cache:"no-store",signal:n,headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error(`CrossD bridge adapter request failed: ${await Kn(s)}`);let o=await s.json();if(o&&typeof o=="object"&&"code"in o&&typeof o.code=="number"&&o.code!==200)throw new Error(o.message||`CrossD bridge adapter API error: ${o.code}`);return o&&typeof o=="object"&&"data"in o?o.data:o}function Hr(e){return new Promise(t=>setTimeout(t,e))}async function Vr(e,t,{attempts:n=60,intervalMs:s=2e3}={}){for(let o=0;o<n;o+=1){try{let c=await De(`${e}/permit-hash/${t}`);if(jt(c))return c}catch{}await Hr(s)}return null}function ce(e,t){return`${e}-${t.toLowerCase()}`}function fe(e){return ce(e.chainId,e.address)}function Fe(e){return e==="swap"||e==="deposit-swap"||e==="swap-withdraw"}function jr(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"",n=t.toLowerCase();return n.includes("quoteexactinputsingle")||n.includes("quoteexactoutputsingle")||n.includes("getamountswapbridgeout")||n.includes("getamountswapbridgein")||n.includes("execution reverted")?"Amount is too large for this route.":t.split(`
|
|
2
|
+
`)[0]?.trim()||"Failed to quote bridge."}function _n(e){return e===56||e===97?"BSC":e===612044||e===612055?"ONEchain":`Chain ${e}`}function ae(e,t){return t?t.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()?e.contracts.W_CROSS:t:qe}function st(e){let t=Nt(e,mt);return t.includes(".")?t.replace(/\.?0+$/,""):t}function wt(e){return Ir(e||"0",mt)}function ye(e){try{return wt(e||"0")}catch{return 0n}}function Ze(e){if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(Math.trunc(e));if(!e)return 0n;try{return BigInt(e)}catch{return 0n}}function Ht(e){let t=Nt(e,9);return(t.includes(".")?t.replace(/\.?0+$/,""):t)||"0"}function Et(e){return e==="bridge"?Rr:Or}function Bn(e,t){if(!e||!t)return"0";let n=e*e;if(n===0n)return"0";let s=t*t,o=s>n?s-n:n-s;if(o===0n)return"0";let c=(o*100000000n+n/2n)/n;if(c>=100000000n)return"100";let g=c/1000000n,y=(c%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return y?`${g}.${y}`:`${g}`}function Qr(e){if(!e||Number(e)===0)return"0%";let[t,n=""]=e.split("."),s=n.length>4?n.slice(0,4):n;return s?`${t}.${s}%`:`${t}%`}async function Nn(e,t,n,s,o,c=!1){let g=Mn(e,{chainId:t}),y=n;try{let r=await g?.estimateContractGas?.({account:o.account,address:o.address,abi:o.abi,functionName:o.functionName,args:o.args,value:o.value});typeof r=="bigint"&&r>0n&&(y=s?r*Er/_r:r)}catch{}let u={gas:y};if(Gn.has(t))try{let r=await g?.getGasPrice?.();typeof r=="bigint"&&r>0n&&(u.gasPrice=r)}catch{}else if(c)try{let r=await g?.estimateFeesPerGas?.();typeof r?.maxFeePerGas=="bigint"&&(u.maxFeePerGas=r.maxFeePerGas),typeof r?.maxPriorityFeePerGas=="bigint"&&(u.maxPriorityFeePerGas=r.maxPriorityFeePerGas)}catch{}return u}function ht(){return BigInt(Math.floor(Date.now()/1e3)+1800)}var zr={100:"0.01%",500:"0.05%",3e3:"0.3%",1e4:"1%"};function Xr(e){return zr[e]??`${e/1e4}%`}function Yr(e,t){let n=Number(e||"0");return!Number.isFinite(n)||n<=0?"0":(n*t/1e6).toFixed(8).replace(/\.?0+$/,"")}function Wn(e){return st(e)}function Dn(e,t){let n=Number(t??"0");return!Number.isFinite(n)||n<=0?0n:e*BigInt(Math.floor(n))/1000n}function _t(e,t){if(!e)return!1;let n=e.toLowerCase();return t.some(s=>s.toLowerCase()===n)}function Jr(e,t,n){return[{from:[e.contracts.USDTX],to:[e.contracts.CROSSD]},{from:[e.contracts.BSC_CROSS],to:[e.contracts.NATIVE_CROSS,e.contracts.W_CROSS]},{from:[e.contracts.NATIVE_CROSS,e.contracts.W_CROSS],to:[e.contracts.CROSSD]}].some(o=>_t(t,o.from)&&_t(n,o.to)||_t(t,o.to)&&_t(n,o.from))}function Zr(e){if(Fe(e.type))return null;if(e.type==="swap-bridge"){let t=e.steps.find(n=>n.type==="bridge");return t?{from:t.fromChain,to:t.toChain,token:t.fromToken}:null}if(e.type==="bridge-swap"){let t=e.steps.find(n=>n.type==="bridge");return t?{from:t.fromChain,to:t.toChain,token:t.fromToken}:null}return{from:e.from.chainId,to:e.to.chainId,token:e.from.address}}function es({input:e,path:t,config:n}){if(!n||Fe(t.type))return"";let s=Ze(n.minimumValue),o=Ze(n.gasFee??n.gas_fee),c=t.type==="swap-bridge"?s+o*12n/10n:s;return c<=0n?"":e.fromAmount&&ye(e.fromAmount)<c&&t.type!=="swap"?`Minimum ${Wn(c)}`:t.type==="swap-bridge"&&e.toAmount&&ye(e.toAmount)<c?`Available ${Wn(c)} or more.`:""}function ts({input:e,path:t,config:n}){if(!n||t.type!=="bridge"&&t.type!=="bridge-swap")return"";let s=Ze(n.gasFee??n.gas_fee);if(s<=0n||!e.fromAmount)return"";let o=ye(e.fromToken.balance||"0"),c=ye(e.fromAmount);return o-s<c?`Insufficient network fee(${e.fromToken.symbol})`:""}function ns(e,t){let n=new Set;return e?.list?.forEach(s=>{let o=s.localChain??s.local_chain;o&&Object.entries(s.pairs||{}).forEach(([c,g])=>{g.forEach(y=>{y.localToken&&n.add(ce(o,y.localToken)),y.remoteToken&&n.add(ce(Number(c),y.remoteToken))})})}),Object.entries(t?.swapPools||t?.swap_pools||{}).forEach(([s,o])=>{o.forEach(c=>{c.token0&&n.add(ce(Number(s),c.token0)),c.token1&&n.add(ce(Number(s),c.token1))})}),n}function os(e,t){return!e||!t?null:ce(e,t)}function rs({envConfig:e,bridgePairList:t,swapPools:n,tokenInfo:s,tokenStats:o}){let c=ns(t,n),g=new Map;o?.forEach(u=>{let r=os(Number(u.chainId??u.chain_id),u.address);r&&g.set(r,u)});let y={};return c.forEach(u=>{let[r,m]=u.split("-"),b=Number(r),C=s?.find(k=>Number(k.chainId??k.chain_id)===b&&k.address?.toLowerCase()===m);if(!C?.symbol||!C.name)return;let p=g.get(u);y[u]={key:u,chainId:b,address:m,symbol:C.symbol,name:C.name,decimals:C.decimals||mt,image:C.image||C.icon_url,price:p?.price?Number(p.price):void 0,isNativeToken:m.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()}}),y}function $n(e,t){return t?.list?.find(n=>(n.localChain??n.local_chain)===e)?.bridge||""}function qn(e,t,n){let[s,o]=e.split("-"),[c,g]=t.split("-"),y=Number(s),u=Number(c);for(let r of n?.list||[]){if((r.localChain??r.local_chain)!==y)continue;let m=r.pairs?.[c];if(m){for(let b of m)if(b.localToken?.toLowerCase()===o&&b.remoteToken?.toLowerCase()===g)return{type:"bridge",fromChain:y,fromToken:o,toChain:u,toToken:g,bridgeAddress:$n(y,n)}}}return null}function Hn(e,t,n,s){let o,c=1/0;for(let g of e||[]){let y=s(g.token0),u=s(g.token1);if(y===t&&u===n||u===t&&y===n){let r=g.fee??Pe;r<c&&(o=g,c=r)}}return o?{fee:c,poolAddress:o.poolAddress||o.pool_address||""}:null}function Vn(e,t,n,s){let[o,c]=e.split("-"),[g,y]=t.split("-");if(o!==g)return null;let u=Number(o),r=(n?.swapPools||n?.swap_pools)?.[o];if(!r)return null;let m=s.contracts.W_CROSS.toLowerCase(),b=s.contracts.NATIVE_CROSS.toLowerCase(),p=Hn(r,c,y,T=>T?.toLowerCase()===m?b:T?.toLowerCase());if(!p)return null;let k="swap";return u===s.chainIds.cross&&(c===b&&(k="deposit-swap"),y===b&&(k="swap-withdraw")),{pathType:k,step:{type:"swap",chain:u,fromToken:c,toToken:y,fee:p.fee,poolAddress:p.poolAddress}}}function ss(e,t,n,s){let[o,c]=e.split("-"),[g]=t.split("-");if(o===g)return null;let y=(n?.swapPools||n?.swap_pools)?.[o]||[],u=r=>r?.toLowerCase();for(let r of y){let m=u(r.token0),b=u(r.token1),C=m===c?b:b===c?m:null;if(!C)continue;let p=qn(ce(Number(o),C),t,s);if(!p)continue;let k=Hn(y,c,C,u);return[{type:"swap",chain:Number(o),fromToken:c,toToken:C,fee:k?.fee??Pe,poolAddress:k?.poolAddress??""},p]}return null}function is(e,t,n,s,o){let[c,g]=e.split("-"),[y]=t.split("-");if(c===y)return null;for(let u of n?.list||[])if((u.localChain??u.local_chain)===Number(c))for(let r of u.pairs?.[y]||[]){if(r.localToken?.toLowerCase()!==g)continue;let m=r.remoteToken?.toLowerCase();if(!m)continue;let b=Vn(ce(Number(y),m),t,s,o);if(b)return[{type:"bridge",fromChain:Number(c),fromToken:g,toChain:Number(y),toToken:m,bridgeAddress:$n(Number(c),n)},b.step]}return null}function as({envConfig:e,bridgePairList:t,swapPools:n,enrichedTokens:s}){return(o,c)=>{let g=s[o],y=s[c];if(!g||!y||o===c)return null;let u=qn(o,c,t);if(u)return{type:"bridge",steps:[u],from:g,to:y};let r=Vn(o,c,n,e);if(r)return{type:r.pathType,steps:[r.step],from:g,to:y};let m=ss(o,c,n,t);if(m)return{type:"swap-bridge",steps:m,from:g,to:y};let b=is(o,c,t,n,e);return b?{type:"bridge-swap",steps:b,from:g,to:y}:null}}function Fn(e,t){return{name:e.name,symbol:e.symbol,chainId:e.chainId,address:e.address,decimals:e.decimals,balance:t.get(e.key)||"0",iconUrl:e.image,priceUsd:e.price}}function cs(e){return e.length<=10?e:`${e.slice(0,6)}...${e.slice(-4)}`}function ds(e){return e.includes(".")?e.replace(/\.?0+$/,"")||"0":e}function ls(e,t){let n=e.startsWith("-"),s=n?e.slice(1):e,[o,c=""]=s.split("."),g=c.slice(0,t).replace(/0+$/,""),y=g?`${o}.${g}`:o;return n?`-${y}`:y}function us(e){let t=e.startsWith("-"),n=t?e.slice(1):e,[s,o]=n.split("."),c=s.replace(/\B(?=(\d{3})+(?!\d))/g,","),g=o?`${c}.${o}`:c;return t?`-${g}`:g}function Vt(e){if(e==null||e==="")return"0";let t=String(e),n=Number(t);return!Number.isFinite(n)||n===0?"0":us(ls(t,4))}function Ln(e,t){if(e==null||e==="")return"0";try{return ds(Nt(BigInt(String(e)),t.decimals))}catch{return"0"}}function jt(e){return!!(e&&/^0x[0-9a-fA-F]+$/.test(e))}function ps(e){return e?new Date(e*1e3).toISOString():new Date().toISOString()}function ms(e,t){return t.toLowerCase()===e.contracts.W_CROSS.toLowerCase()?e.contracts.NATIVE_CROSS:t}function fs(e,t){let n=cs(t);return{name:n,symbol:n,chainId:e,address:t,decimals:mt,balance:"0"}}function Un({envConfig:e,tokenByBridgeKey:t,chainId:n,address:s}){if(!s)return null;let o=ms(e,s);return t.get(ce(n,o))||t.get(ce(n,s))||fs(n,o)}function Bt(e){return e?.toLowerCase()||""}function gs(e){if(e.source==="swap")return"swap";let t=Bt(e.fromToken??e.from_token),n=Bt(e.toToken??e.to_token),s=Bt(e.swapTokenIn??e.swap_token_in),o=Bt(e.swapTokenOut??e.swap_token_out);return n&&s&&n===s?"bridge-swap":t&&o&&t===o?"swap-bridge":"bridge"}function ys(e,t){let n=e.status??0,s=e.extracallSuccess??e.extracall_success??!1;return t==="bridge-swap"&&n===1&&!s?"failed":n===1?"success":"pending"}function bs({envConfig:e,item:t,tokenByBridgeKey:n}){let s=Number(t.fromChainID??t.from_chain_id??0),o=Number(t.toChainID??t.to_chain_id??0);if(!s||!o)return null;let c=gs(t),g=t.swapTokenIn??t.swap_token_in,y=t.swapTokenOut??t.swap_token_out,u=t.swapAmountIn??t.swap_amount_in,r=t.swapAmountOut??t.swap_amount_out,m=t.fromToken??t.from_token,b=t.toToken??t.to_token,C=t.value,p=t.value;c==="swap"?(m=g,b=y,C=u,p=r):c==="swap-bridge"?(m=g,C=u,p=t.value):c==="bridge-swap"&&(b=y,C=u,p=r);let k=Un({envConfig:e,tokenByBridgeKey:n,chainId:s,address:m}),T=Un({envConfig:e,tokenByBridgeKey:n,chainId:o,address:b}),x=t.initiatedTxHash??t.initiated_tx_hash;return!k||!T||!jt(x)?null:{id:`${x}-${t.index??""}`,timestamp:ps(t.initiatedTime??t.initiated_time),txHash:x,fromToken:k,toToken:T,fromAmount:Ln(C,k),toAmount:Ln(p,T),summary:{pathType:c},status:ys(t,c)}}function hs(e){let t=new Map;return e.flat().forEach(n=>{let s=Number(n.chainId??n.chain_id),o=n.address?.toLowerCase();if(!s||!o)return;let c=n.quantity?.numeric??n.balance??"0",g=n.quantity?.decimals??n.decimals??mt;try{t.set(ce(s,o),Nt(BigInt(c||"0"),g))}catch{t.set(ce(s,o),"0")}}),t}function $e(e,t="first"){let n=e.steps.filter(s=>s.type==="swap");return t==="last"?n[n.length-1]:n[0]}function ws(e,t){let n=(e?.swapPools||e?.swap_pools)?.[String(t.chainIds.cross)];if(!n?.length)return"";let s=t.contracts.CROSSD.toLowerCase(),o=t.contracts.USDTX.toLowerCase(),c=n.find(g=>{let y=g.token0?.toLowerCase(),u=g.token1?.toLowerCase();return y===s&&u===o||y===o&&u===s});return c?.poolAddress||c?.pool_address||""}function Cs(e,t){return e.from.chainId===t.chainIds.cross&&e.from.address.toLowerCase()===t.contracts.CROSSD.toLowerCase()&&e.to.chainId===t.chainIds.bsc&&e.to.address.toLowerCase()===t.contracts.USDTB.toLowerCase()}function ks(e){if(e===void 0)return;let t=10n**BigInt(mt),n=e>=50000n*t?"normal":e>10000n*t?"low":"rebalancing",s=Number(e>0n?e*100n/(100000n*t):0n);return{label:"Available Liquidity",status:n,percentage:Math.min(s,100)}}function pt(e,t,n,s){let o=[e.from,e.to].find(c=>c.chainId===t&&c.address.toLowerCase()===n.toLowerCase())??s?.[ce(t,n)];return{symbol:o?.symbol||n.slice(0,6),iconUrl:o?.image}}function Ts(e,t){let n=[];for(let o of e.steps)o.type==="swap"?(n.push({chain:o.chain,address:o.fromToken}),n.push({chain:o.chain,address:o.toToken})):(n.push({chain:o.fromChain,address:o.fromToken}),n.push({chain:o.toChain,address:o.toToken}));let s=n.filter((o,c)=>c===0||!(o.chain===n[c-1].chain&&o.address.toLowerCase()===n[c-1].address.toLowerCase()));return s.length===0?[{symbol:e.from.symbol,iconUrl:e.from.image},{symbol:e.to.symbol,iconUrl:e.to.image}]:s.map(o=>pt(e,o.chain,o.address,t))}function vs({input:e,path:t,amountData:n,gasInfo:s,liquidity:o,enrichedTokens:c,priceImpact:g}){let y=e.fromAmount||"0",u=e.toAmount||"0",r=$e(t),m=t.steps.find(W=>W.type==="bridge"),b=t.type!=="bridge",C=!Fe(t.type),p=r?Yr(y,r.fee):"0",k=Number(y)>0||Number(u)>0,T=r?pt(t,r.chain,r.fromToken,c):{symbol:e.fromToken.symbol,iconUrl:e.fromToken.iconUrl},x=r?pt(t,r.chain,r.toToken,c):{symbol:e.toToken.symbol,iconUrl:e.toToken.iconUrl},P=m?pt(t,m.fromChain,m.fromToken,c):void 0,v=(W,R,_)=>k?R&&R>0n?{label:W,value:st(R),tone:"default",valueToken:_}:{label:W,value:"Free",tone:"accent"}:{label:W,value:"0"};return{pathType:t.type,priceImpact:g,liquidity:o,bridgeInfo:C&&m?[{label:"Route",value:`${_n(m.fromChain)} \u2192 ${_n(m.toChain)}`},v("Validator Fee",n?.exFee,P),v("Network Fee",n?.networkFee,P)]:void 0,swapInfo:b&&r?[{label:"Route",value:"",routeTokens:[pt(t,r.chain,r.fromToken,c),pt(t,r.chain,r.toToken,c)]},{label:"Price Impact",value:Qr(g)},{label:"In Amount",value:Vt(y),valueToken:T},{label:r&&Fe(t.type)?`Swap Fee (${Xr(r.fee??Pe)})`:"Swap Fee",value:Vt(p),valueToken:T},{label:"Out Amount",value:Vt(u),valueToken:x}]:void 0,txFee:[...s?.gasPrice?[{label:"Gas Price",value:`${s.gasPrice} Gwei`}]:[{label:"Priority Fee Per Gas",value:`${s?.priorityFeePerGas||"0"} Gwei`},{label:"Max Fee Per Gas",value:`${s?.maxFeePerGas||"0"} Gwei`}],{label:"Gas Limit",value:s?.gasLimit||"0"}],txFeeInfo:s?{estTxFee:s.estTxFee,isDelegateFee:s.isDelegateFee,tokenIconUrl:s.gasCurrencyIconUrl,tokenSymbol:s.gasCurrencySymbol}:{estTxFee:"0",isDelegateFee:!1}}}function Ct({env:e,walletAddress:t,enabled:n=!0,restoreChainAfterSwitch:s=!0}){let o=Sr(),c=Tr(new Map),y=Je({queryKey:["crossd-bridge-adapter",e,"remote-contracts"],queryFn:async({signal:i})=>{let a=Gr(await De(Dr[e],i),e);if(!a)throw new Error("CrossD bridge adapter: invalid contracts.json");return a},enabled:n,staleTime:5*6e4}).data??null,u=n&&!!y,r=Ce(()=>({...Kr[e],contracts:y??Lr}),[e,y]),m=Je({queryKey:["crossd-bridge-adapter",e,"pairs"],queryFn:({signal:i})=>De(`${r.bridgeApi}/pairs`,i),enabled:u,staleTime:3e4}),b=Je({queryKey:["crossd-bridge-adapter",e,"swap-pools"],queryFn:({signal:i})=>De(`${r.bridgeApi}/swap-pools`,i),enabled:u,staleTime:3e4}),C=Ce(()=>ws(b.data,r),[r,b.data]),p=Je({queryKey:["crossd-bridge-adapter",e,"available-liquidity",C],queryFn:async()=>await Oe(o,{address:r.contracts.USDTX,abi:qt,functionName:"balanceOf",args:[C],chainId:r.chainIds.cross}),enabled:u&&!!C,staleTime:3e4}),k=Je({queryKey:["crossd-bridge-adapter",e,"token-info"],queryFn:({signal:i})=>De(`${r.walletApi}/v1/public/token/info`,i),enabled:u,staleTime:3e4}),T=Je({queryKey:["crossd-bridge-adapter",e,"token-stats"],queryFn:({signal:i})=>De(`${r.walletApi}/v1/public/token/stats`,i),enabled:u,staleTime:3e4}),x=Pn({queries:[r.chainIds.cross,r.chainIds.bsc].map(i=>({queryKey:["crossd-bridge-adapter",e,"balance",t,i],queryFn:({signal:a})=>{let d=new URLSearchParams({networkId:`eip155:${i}`,account:t||""});return De(`${r.walletApi}/v1/public/token/balance?${d}`,a)},enabled:u&&!!t,staleTime:0,refetchInterval:u&&t?5e3:!1}))}),P=Pn({queries:[r.chainIds.cross,r.chainIds.bsc].map(i=>({queryKey:["crossd-bridge-adapter",e,"gas-suggestion",i],queryFn:async({signal:a})=>{try{let w=await Mn(o,{chainId:i})?.estimateFeesPerGas?.();if(w?.maxFeePerGas||w?.gasPrice)return{fast:{maxFee:w.maxFeePerGas?.toString()||w.gasPrice?.toString(),maxPriorityFee:w.maxPriorityFeePerGas?.toString()||"0"}}}catch{}let d=new URLSearchParams({chain_id:String(i),without_gas_limit:"false"});return De(`${r.walletApi}/v1/public/transaction/gas-suggestion/dynamic?${d}`,a)},enabled:u,staleTime:1e4,retry:1}))}),v=Je({queryKey:["crossd-bridge-adapter",e,"hidden-pairs"],queryFn:async({signal:i})=>Wr(await De(Br[e],i),e),enabled:u,staleTime:5*6e4,retry:1}),W=Ce(()=>v.data??[],[v.data]),R=Ce(()=>rs({envConfig:r,bridgePairList:m.data,swapPools:b.data,tokenInfo:k.data,tokenStats:T.data}),[m.data,r,b.data,k.data,T.data]),_=Ce(()=>as({envConfig:r,bridgePairList:m.data,swapPools:b.data,enrichedTokens:R}),[m.data,R,r,b.data]),q=Ce(()=>hs(x.map(i=>i.data).filter(i=>Array.isArray(i))),[x]),U=Ce(()=>{let i=new Map;return Object.values(R).forEach(a=>{let d=Fn(a,q);i.set(a.key,d)}),i},[q,R]),z=Ce(()=>{let i=new Map,a=U.get(ce(r.chainIds.cross,r.contracts.NATIVE_CROSS));a&&i.set(r.chainIds.cross,{symbol:a.symbol,iconUrl:a.iconUrl});let d=k.data?.find(f=>Number(f.chainId??f.chain_id)===r.chainIds.bsc&&(f.symbol??"").toUpperCase()==="BNB");return d&&i.set(r.chainIds.bsc,{symbol:d.symbol??"BNB",iconUrl:d.image??d.icon_url}),i},[r,U,k.data]),M=Je({queryKey:["crossd-bridge-adapter",e,"history",t],queryFn:({signal:i})=>En(`${r.bridgeApi}/history`,{owner:t,page:1,size:20,sort:"desc",status:"all"},i),enabled:u&&!!t,staleTime:0,refetchInterval:u&&t?5e3:!1}),H=Ce(()=>(M.data?.histories||[]).map(i=>bs({envConfig:r,item:i,tokenByBridgeKey:U})).filter(i=>!!i),[M.data?.histories,r,U]),Ee=Ce(()=>ks(p.data),[p.data]),ke=P[0]?.data,L=P[1]?.data,O=Ce(()=>{let i=new Map;return ke&&i.set(r.chainIds.cross,ke),L&&i.set(r.chainIds.bsc,L),i},[L,ke,r.chainIds.bsc,r.chainIds.cross]),X=ie((i,a,d)=>{let f=O.get(i.from.chainId)?.fast,w=a?d?.gasLimit??Et(i.type):0n,N=d?.gasPrice&&d.gasPrice>0n?d.gasPrice:0n,D=d?.maxFeePerGas&&d.maxFeePerGas>0n?d.maxFeePerGas:0n,A=d?.maxPriorityFeePerGas&&d.maxPriorityFeePerGas>0n?d.maxPriorityFeePerGas:0n,G=Ze(f?.maxFee??f?.max_fee),Y=Ze(f?.maxPriorityFee??f?.max_priority_fee),S=D>0n?D:G>0n?G:N,F=A>0n?A:Y>0n?Y:S,V=N>0n?N:S,$=Gn.has(i.from.chainId)&&V>0n,l=w*($?V:S),h=U.get(ce(i.from.chainId,r.contracts.NATIVE_CROSS)),I=i.type!=="swap-bridge",E=z.get(i.from.chainId);return{estTxFee:a?st(l):"0",priorityFeePerGas:a&&!$?Ht(F):"0",maxFeePerGas:a&&!$?Ht(S):"0",gasLimit:a?w.toString():"0",gasPrice:a&&$?Ht(V):void 0,isDelegateFee:i.type==="swap-bridge"?!1:Jr(r,i.from.address,i.to.address),tokenIconUrl:I?h?.iconUrl:void 0,tokenSymbol:I?h?.symbol:void 0,gasCurrencyIconUrl:E?.iconUrl,gasCurrencySymbol:E?.symbol}},[r,O,z,U]),ee=ie(async i=>{let a=Zr(i);if(!a)return null;let d=`${e}:${a.from}:${a.to}:${a.token.toLowerCase()}`,f=c.current.get(d);if(f)return f;let w=(async()=>{let N=new URLSearchParams({from:String(a.from),to:String(a.to),token:a.token});try{return(await De(`${r.bridgeApi}/token-config?${N}`)).config??null}catch{return null}})();return c.current.set(d,w),w},[e,r.bridgeApi]),Se=Ce(()=>{let i=Object.values(R).map(d=>Fn(d,q)),a=ce(r.chainIds.cross,r.contracts.CROSSD);return i.sort((d,f)=>{let w=fe(d).toLowerCase()===a.toLowerCase(),N=fe(f).toLowerCase()===a.toLowerCase();return w!==N?w?-1:1:fe(d).localeCompare(fe(f))})},[q,R,r]),Ue=Ce(()=>{if(y)return{target:{chainId:r.chainIds.cross,address:r.contracts.CROSSD},swap:{from:{chainId:r.chainIds.cross,address:r.contracts.NATIVE_CROSS},feeDelegated:!0},bridge:{from:[{chainId:r.chainIds.bsc,address:r.contracts.USDTB},{chainId:r.chainIds.cross,address:r.contracts.USDTX}]}}},[r,y]),Ve=ie(i=>{let a=fe(i),d=a.toLowerCase(),f=[];Object.keys(R).forEach(D=>{let A=D.toLowerCase();if(d===A||W.some(S=>S.fromKey===d&&S.toKey===A))return;let G=_(a,D);if(!G)return;let Y=U.get(D);Y&&f.push({token:Y,path:G})});let w=ce(r.chainIds.cross,r.contracts.CROSSD),N=ce(r.chainIds.cross,r.contracts.NATIVE_CROSS);return f.sort((D,A)=>{if(d===w.toLowerCase()){let V=fe(D.token).toLowerCase()===N.toLowerCase(),$=fe(A.token).toLowerCase()===N.toLowerCase();if(V!==$)return V?-1:1}let G=Fe(D.path.type),Y=Fe(A.path.type);if(G!==Y)return G?-1:1;let S=D.token.chainId===i.chainId,F=A.token.chainId===i.chainId;return S!==F?S?-1:1:fe(D.token).localeCompare(fe(A.token))}),f.map(D=>D.token)},[R,r,_,W,U]),Me=ie(async i=>await Oe(o,{address:r.contracts.SWAP_BRIDGE_ROUTER,abi:rt,functionName:"quoter",chainId:i}),[r.contracts.SWAP_BRIDGE_ROUTER,o]),oe=ie(async i=>{$t(o)!==i&&await Sn(o,{chainId:i})},[o]),ue=ie(i=>Rt({getChainId:()=>$t(o),switchChain:a=>Sn(o,{chainId:a})},i,s),[s,o]),re=ie(async i=>await Oe(o,{address:r.contracts.SWAP_BRIDGE_ROUTER,abi:rt,functionName:"swapRouter",chainId:i}),[r.contracts.SWAP_BRIDGE_ROUTER,o]),Te=ie(async({path:i,step:a,amount:d,source:f})=>{let w=await Me(a.chain),N=a.poolAddress?Oe(o,{address:a.poolAddress,abi:$r,functionName:"slot0",chainId:a.chain}).then(G=>G?.[0]).catch(()=>{}):Promise.resolve(void 0);if(f==="from"){let G=await Oe(o,{address:w,abi:On,functionName:"quoteExactInputSingle",args:[{tokenIn:ae(r,a.fromToken),tokenOut:ae(r,a.toToken),amountIn:wt(d),fee:a.fee??Pe,sqrtPriceLimitX96:0n}],chainId:a.chain}),Y=Bn(await N,G[1]);return{amount:st(G[0]),path:i,priceImpact:Y}}let D=await Oe(o,{address:w,abi:On,functionName:"quoteExactOutputSingle",args:[{tokenIn:ae(r,a.fromToken),tokenOut:ae(r,a.toToken),amount:wt(d),fee:a.fee??Pe,sqrtPriceLimitX96:0n}],chainId:a.chain}),A=Bn(await N,D[1]);return{amount:st(D[0]),path:i,priceImpact:A}},[r,Me,o]),_e=ie(async(i,a)=>{if(!t)throw new Error("Wallet is not connected.");let d=Et(a.type);if(Fe(a.type)){let S=$e(a,"first");if(!S)throw new Error("Swap route is not available.");let F=ye(i.fromAmount),V=ye(i.toAmount);if(F<=0n)throw new Error("Bridge amount is empty.");if(V<=0n)throw new Error("Bridge quote is not ready.");let $=await re(S.chain),j=Ot(V,i.slippage),l=a.type==="swap-withdraw"?qe:t,h={tokenIn:ae(r,S.fromToken),tokenOut:ae(r,S.toToken),fee:S.fee??Pe,recipient:l,deadline:ht(),amountIn:F,amountOutMinimum:j,sqrtPriceLimitX96:0n};if(a.type==="swap-withdraw"){let I=bt({abi:Ke,functionName:"exactInputSingle",args:[h]}),E=bt({abi:Ke,functionName:"unwrapWETH9",args:[j,t]});return{address:$,abi:Ke,functionName:"multicall",args:[[I,E]],chainId:S.chain,fallbackGasLimit:d}}if(a.type==="deposit-swap"){let I=bt({abi:Ke,functionName:"exactInputSingle",args:[h]}),E=bt({abi:Ke,functionName:"refundETH",args:[]});return{address:$,abi:Ke,functionName:"multicall",args:[[I,E]],value:F,chainId:S.chain,fallbackGasLimit:d}}return{address:$,abi:Ke,functionName:"exactInputSingle",args:[h],chainId:S.chain,fallbackGasLimit:d}}if(a.type==="swap-bridge"){let S=$e(a,"first");if(!S)throw new Error("Swap bridge route is not available.");let F=ye(i.fromAmount),V=ye(i.toAmount);if(F<=0n)throw new Error("Bridge amount is empty.");if(V<=0n)throw new Error("Bridge quote is not ready.");let $=r.contracts.SWAP_BRIDGE_ROUTER,j=ht(),l={toChainID:BigInt(a.to.chainId),recipient:t,extraData:"0x"},h={tokenIn:ae(r,a.from.address),tokenOut:ae(r,S.toToken),fee:S.fee??Pe,sqrtPriceLimitX96:0n,bridgeParams:l};if(i.lastChangedBy==="to"){let E={...h,amountOut:V,amountInMaximum:xn(F,i.slippage)};return{address:$,abi:rt,functionName:"swapBridgeExactOutputSingle",args:[E,j],value:a.from.isNativeToken?E.amountInMaximum:void 0,chainId:a.from.chainId,fallbackGasLimit:d}}let I={...h,amountIn:F,amountOutMinimum:Ot(V,i.slippage)};return{address:$,abi:rt,functionName:"swapBridgeExactInputSingle",args:[I,j],value:a.from.isNativeToken?F:void 0,chainId:a.from.chainId,fallbackGasLimit:d}}let f=a.steps.find(S=>S.type==="bridge");if(!f?.bridgeAddress)throw new Error("Bridge route is not available.");let w=ye(i.fromAmount);if(w<=0n)throw new Error("Bridge amount is empty.");let N=await ee(a),D=Ze(N?.gasFee??N?.gas_fee),A=Dn(w,N?.exFeeRate??N?.ex_fee_rate),G="0x";if(a.type==="bridge-swap"){let S=$e(a,"last");if(!S)throw new Error("Bridge swap route is not available.");let F=ye(i.toAmount);if(F<=0n)throw new Error("Bridge quote is not ready.");let V=await re(a.to.chainId),$=Ot(F,i.slippage),j=bt({abi:Ke,functionName:"exactInputSingle",args:[{tokenIn:ae(r,S.fromToken),tokenOut:ae(r,S.toToken),fee:S.fee??Pe,recipient:t,deadline:ht(),amountIn:w,amountOutMinimum:$,sqrtPriceLimitX96:0n}]});G=`${V}${j.slice(2)}`}let Y=[BigInt(a.to.chainId),a.from.address,t,w,D,A,G];return{address:f.bridgeAddress,abi:qr,functionName:"bridgeToken",args:Y,value:a.from.isNativeToken?w+A+D:void 0,chainId:a.from.chainId,fallbackGasLimit:d}},[r,ee,re,t]),je=ie(async(i,a)=>{if(a.type==="bridge"||a.type==="bridge-swap")return _e(i,a);if(!t)throw new Error("Wallet is not connected.");let d=ye(i.fromAmount);if(d<=0n)throw new Error("Bridge amount is empty.");if(a.type==="swap-bridge"){let D=$e(a,"first");if(!D)throw new Error("Swap bridge route is not available.");let A=r.contracts.SWAP_BRIDGE_ROUTER,G={tokenIn:ae(r,a.from.address),tokenOut:ae(r,D.toToken),fee:D.fee??Pe,sqrtPriceLimitX96:0n,bridgeParams:{toChainID:BigInt(a.to.chainId),recipient:t,extraData:"0x"},amountIn:d,amountOutMinimum:0n};return{address:A,abi:rt,functionName:"swapBridgeExactInputSingle",args:[G,ht()],value:a.from.isNativeToken?d:void 0,chainId:a.from.chainId,fallbackGasLimit:Et(a.type)}}let f=$e(a,"first");if(!f)throw new Error("Swap route is not available.");let w=await re(f.chain),N={tokenIn:ae(r,f.fromToken),tokenOut:ae(r,f.toToken),fee:f.fee??Pe,recipient:t,deadline:ht(),amountIn:d,amountOutMinimum:0n,sqrtPriceLimitX96:0n};return{address:w,abi:Ke,functionName:"exactInputSingle",args:[N],value:a.from.isNativeToken?d:void 0,chainId:f.chain,fallbackGasLimit:Et(a.type)}},[_e,r,re,t]),be=ie(async(i,a)=>{if(!t)return null;try{let d=await je(i,a),f=Fe(a.type)||a.type==="swap-bridge",w=await Nn(o,d.chainId,d.fallbackGasLimit,f,{account:t,address:d.address,abi:d.abi,functionName:d.functionName,args:d.args,value:d.value},!0);return{gasLimit:w.gas,gasPrice:w.gasPrice,maxFeePerGas:w.maxFeePerGas,maxPriorityFeePerGas:w.maxPriorityFeePerGas}}catch{return null}},[je,o,t]),tt=ie(async i=>{let a=fe(i.fromToken),d=fe(i.toToken),f=_(a,d);if(!f)return{error:"Route is not available."};let w=i.lastChangedBy==="to"?i.toAmount:i.fromAmount,N=!!w&&Number(w)>0,D=Cs(f,r)?Ee:void 0,A=async(j,l,h)=>{let I=N?await be(j,f):null,E=X(f,N,I);return vs({input:j,path:f,gasInfo:E,amountData:l,liquidity:D,enrichedTokens:R,priceImpact:h})};if(!w||Number(w)<=0)return{fromAmount:i.fromAmount,toAmount:i.toAmount,summary:await A(i)};let G=await ee(f),Y=Ze(G?.gasFee??G?.gas_fee),S=f.type==="bridge"||f.type==="bridge-swap"?{networkFee:Y}:void 0,F=f.type==="bridge"?i.lastChangedBy==="to"?{...i,fromAmount:i.toAmount}:{...i,toAmount:i.fromAmount}:i,V=es({input:F,path:f,config:G});if(V)return{fromAmount:F.fromAmount,toAmount:F.toAmount,summary:await A(F,S),error:V};let $=ts({input:F,path:f,config:G});if($)return{fromAmount:F.fromAmount,toAmount:F.toAmount,summary:await A(F,S),error:$};if(f.type==="bridge")return{fromAmount:F.fromAmount,toAmount:F.toAmount,summary:await A(F,S)};try{if(f.type==="swap-bridge"){let I=$e(f,"first"),E=r.contracts.SWAP_BRIDGE_ROUTER;if(!I)return{error:"Swap bridge route is not ready."};let B=Ne=>Te({path:f,step:I,amount:Ne,source:"from"}).then(pe=>pe.priceImpact).catch(()=>{});if(i.lastChangedBy==="from"){let Ne=await Oe(o,{address:E,abi:rt,functionName:"getAmountSwapBridgeOut",args:[BigInt(f.to.chainId),ae(r,f.from.address),ae(r,I.toToken),I.fee??Pe,wt(i.fromAmount)],chainId:f.from.chainId}),pe=st(Ne[1]),Wt={...i,toAmount:pe};return{toAmount:pe,summary:await A(Wt,{networkFee:Ne[3],exFee:Ne[4]},await B(i.fromAmount))}}let Ie=await Oe(o,{address:E,abi:rt,functionName:"getAmountSwapBridgeIn",args:[BigInt(f.to.chainId),ae(r,f.from.address),ae(r,I.toToken),I.fee??Pe,wt(i.toAmount)],chainId:f.from.chainId}),ze=st(Ie[1]),dt={...i,fromAmount:ze};return{fromAmount:ze,summary:await A(dt,{networkFee:Ie[3],exFee:Ie[4]},await B(ze))}}let j=f.type==="bridge-swap"?$e(f,"last"):$e(f,"first");if(!j)return{error:"Swap route is not available."};let l=await Te({path:f,step:j,amount:w,source:i.lastChangedBy});if(i.lastChangedBy==="from"){let I={...i,toAmount:l.amount};return{toAmount:l.amount,summary:await A(I,S,l.priceImpact)}}let h={...i,fromAmount:l.amount};return{fromAmount:l.amount,summary:await A(h,S,l.priceImpact)}}catch(j){return{fromAmount:i.fromAmount,toAmount:i.toAmount,summary:await A(i,S),error:jr(j)}}},[Ee,X,R,r,be,_,ee,Te,o]),ve=ie(async i=>{if(i.from.isNativeToken)return null;if(i.type==="swap"||i.type==="deposit-swap"||i.type==="swap-withdraw")return re(i.from.chainId);if(i.type==="swap-bridge")return r.contracts.SWAP_BRIDGE_ROUTER;let a=i.steps.find(d=>d.type==="bridge");return a?.bridgeAddress?a.bridgeAddress:null},[r.contracts.SWAP_BRIDGE_ROUTER,re]),Qe=ie(async i=>{if(!t)throw new Error("Wallet is not connected.");let a=fe(i.fromToken),d=fe(i.toToken),f=_(a,d);if(!f)throw new Error("Route is not available.");if(!Fe(f.type)&&f.type!=="swap-bridge"||f.from.isNativeToken)return null;let w=ye(i.fromAmount);if(w<=0n)return null;let N=await ve(f);return!N||await Oe(o,{address:f.from.address,abi:qt,functionName:"allowance",args:[t,N],chainId:f.from.chainId})>=w?null:{token:i.fromToken,tokenAddress:f.from.address,spenderAddress:N,amount:i.fromAmount}},[_,ve,o,t]),nt=ie(async(i,a)=>{let d=ye(a.amount||i.fromAmount);if(d<=0n)throw new Error("Approval amount is empty.");await oe(a.token.chainId);let f=await An(o,{address:a.tokenAddress,abi:qt,functionName:"approve",args:[a.spenderAddress,d],chainId:a.token.chainId});await Pr(o,{hash:f,chainId:a.token.chainId})},[oe,o]),Be=ie(async(i,a)=>{let d=await _e(i,a);await oe(d.chainId);let f=await Nn(o,d.chainId,d.fallbackGasLimit,Ar(a.type),{account:t,address:d.address,abi:d.abi,functionName:d.functionName,args:d.args,value:d.value});return{txHash:await An(o,{address:d.address,abi:d.abi,functionName:d.functionName,args:d.args,value:d.value,chainId:d.chainId,...f}),fromToken:i.fromToken,toToken:i.toToken,fromAmount:i.fromAmount,toAmount:i.toAmount}},[_e,oe,o,t]),Ge=ie(async(i,a)=>{let d=t;if(!d)throw new Error("Wallet is not connected.");let f=a.steps.find(pe=>pe.type==="bridge");if(!f?.bridgeAddress)throw new Error("Bridge route is not available.");let w=a.from.address,N=a.from.chainId,D=ye(i.fromAmount);if(D<=0n)throw new Error("Bridge amount is empty.");let A=await ee(a),G=Ze(A?.gasFee??A?.gas_fee),Y=Dn(D,A?.exFeeRate??A?.ex_fee_rate),S=D+Y+G,[F,V]=await Promise.all([Oe(o,{address:w,abi:Rn,functionName:"name",chainId:N}),Oe(o,{address:w,abi:Rn,functionName:"nonces",args:[d],chainId:N})]),$=BigInt(Math.floor(Date.now()/1e3)+300),j=await xr(o,{domain:{name:F,version:"1",chainId:N,verifyingContract:w},types:{Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},primaryType:"Permit",message:{owner:d,spender:f.bridgeAddress,value:S,nonce:V,deadline:$}}),{r:l,s:h,v:I,yParity:E}=vr(j),B=I!==void 0?Number(I):E+27,Ie={exFee:Y.toString(),from:N,fromToken:w,nonce:Number(V),gasFee:G.toString(),permitArgs:{account:d,deadline:$.toString(),r:l,s:h,token:w,v:B,value:S.toString()},to:d,toChainID:String(a.to.chainId),value:S.toString()},ze=await En(`${r.bridgeApi}/permit`,Ie),dt=ze?.requestId??ze?.request_id;if(!dt)throw new Error("Bridge permit request failed.");let Ne=await Vr(r.bridgeApi,dt);if(!jt(Ne))throw new Error("Bridge submitted, but confirmation timed out. Check History shortly.");return{txHash:Ne,fromToken:i.fromToken,toToken:i.toToken,fromAmount:i.fromAmount,toAmount:i.toAmount}},[r,ee,o,t]),ct=ie(async i=>{let a=$t(o),d=fe(i.fromToken),f=fe(i.toToken),w=_(d,f);if(!w)throw new Error("Route is not available.");if(!(Fe(w.type)||w.type==="swap-bridge"||w.type==="bridge-swap"||w.type==="bridge"))throw new Error("This bridge route is not supported yet.");let A=w.type==="bridge"&&w.from.chainId===r.chainIds.bsc&&w.from.address.toLowerCase()===r.contracts.BSC_CROSS.toLowerCase()?await Ge(i,w):await Be(i,w);return await ue(a),{...A,pathType:w.type,routeTokens:Ts(w,R)}},[R,r,_,ue,Ge,Be,o]);return{bridgeTokens:Se,bridgeHistory:H,getBridgeApproval:Qe,approveBridge:nt,getBridgeQuote:tt,getBridgeToTokens:Ve,submitBridge:ct,oneUsdPairs:Ue,isLoading:m.isLoading||b.isLoading||k.isLoading||T.isLoading||x.some(i=>i.isLoading)}}import{useEffect as Is,useMemo as jn}from"react";import{useAccount as xs,useConfig as Ps,useSendTransaction as Ss,useSwitchChain as As,useWriteContract as Rs}from"wagmi";import{getBalance as Os,readContract as Es,readContracts as _s,waitForTransactionReceipt as Bs}from"wagmi/actions";import{RelayDeposit as Qt}from"@nexus-cross/dapp-ui";import{jsx as Ls}from"react/jsx-runtime";var Ns=56,Ws=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{name:"",type:"string"}]}],it=e=>e,Qn=!1;function ft(){let{address:e,chainId:t}=xs(),n=Ps(),{sendTransactionAsync:s}=Ss(),{writeContractAsync:o}=Rs(),{switchChainAsync:c}=As(),g=n.chains.some(u=>u.id===Ns);Is(()=>{g||Qn||(Qn=!0,console.warn("[connect-kit] CrossRelayDeposit: BNB Smart Chain (56) is not in the wagmi config \u2014 one-click deposit verification and fund recovery are disabled. Add `bsc` to `createCrossxConfig({ networks })` to enable them."))},[g]);let y=jn(()=>({sendTransaction:async({chainId:u,to:r,value:m,data:b})=>s({chainId:it(u),to:r,value:m,data:b}),writeContract:async({chainId:u,address:r,abi:m,functionName:b,args:C})=>o({chainId:it(u),address:r,abi:m,functionName:b,args:C}),readContract:g?async({chainId:u,address:r,abi:m,functionName:b,args:C})=>Es(n,{chainId:it(u),address:r,abi:m,functionName:b,args:C}):void 0,switchChain:async u=>{await c({chainId:it(u)})},waitForReceipt:async({chainId:u,hash:r})=>({status:(await Bs(n,{chainId:it(u),hash:r})).status==="success"?"success":"reverted"}),getBalance:async({chainId:u,address:r,token:m})=>{if(!m){let x=await Os(n,{chainId:it(u),address:r});return{value:x.value,decimals:x.decimals,symbol:x.symbol}}let b={address:m,abi:Ws,chainId:it(u)},C=await _s(n,{contracts:[{...b,functionName:"balanceOf",args:[r]},{...b,functionName:"decimals"},{...b,functionName:"symbol"}],allowFailure:!1}),[p,k,T]=C;return{value:p,decimals:k,symbol:T}}}),[n,g,s,o,c]);return jn(()=>({walletAddress:e,walletChainId:t,...y}),[e,t,y])}function Ds(e){let t=ft();return Ls(Qt,{...t,...e,requireWalletConnection:!0})}var Fs=Object.assign(Ds,{Trigger:Qt.Trigger,Content:Qt.Content});import{jsx as Hs}from"react/jsx-runtime";function zt({env:e,pairs:t,bridgeOptions:n,relay:s,restoreChainAfterSwitch:o=!0,waitForTransaction:c,onRequestConnect:g,...y}){let u=qs(e),{address:r}=Ms(),m=Gs(),{connectWallet:b}=Ae(),C=ft(),p=Ct({env:u,walletAddress:r,enabled:!0,restoreChainAfterSwitch:o}),{bridgeHistory:k,getBridgeQuote:T,getBridgeToTokens:x,getBridgeApproval:P,approveBridge:v,submitBridge:W}=p,R=zn(()=>({...n,history:k,getQuote:T,getToTokens:x,getApproval:P,approveBridge:v,submitBridge:W}),[v,k,n,P,T,x,W]),_=zn(()=>({...s,...C}),[s,C]),q=Us(async U=>{if((await Ks(m,{hash:U.txHash,chainId:U.fromToken.chainId})).status!=="success")throw new Error("Transaction reverted.")},[m]);return Hs($s,{...y,env:u,walletAddress:r,tokens:p.bridgeTokens,pairs:t??p.oneUsdPairs,loading:p.isLoading,bridge:R,relay:_,waitForTransaction:c??q,onRequestConnect:g??b})}import{useEffect as Xn,useRef as Vs,useState as Yn}from"react";import{useAccount as js}from"wagmi";function Xt(e){let{address:t,connector:n}=js(),{currentWallet:s}=Ae(),o=e?.walletId!==void 0?e.walletId:s,c=e?.connector!==void 0?e.connector:n,g=e?.address!==void 0?e.address:t,[y,u]=Yn({loginType:null,accountName:null,accounts:[],isResolved:!1}),r=Vs(new Map),[m,b]=Yn(0);return Xn(()=>{let C=!1;if(o!=="cross_embedded")return u({loginType:null,accountName:null,accounts:[],isResolved:!0}),()=>{C=!0};if(!c)return u({loginType:null,accountName:null,accounts:[],isResolved:!1}),()=>{C=!0};u(x=>({...x,isResolved:!1}));let p=20,k=300,T=async()=>{if(typeof c.getProvider!="function")return"retry";let x;try{x=await c.getProvider()}catch{return"retry"}let P=x?.sdk;if(!P)return"giveup";try{let L=P.getRNBridgeActiveWallet?.(),O=L?.walletName?.trim();L&&O&&r.current.set(L.address.toLowerCase(),O)}catch{}let[v,W]=await Promise.all([P.getUserInfo?.().catch(()=>null)??null,P.getAddresses?.().catch(()=>null)??null]);if(C)return"done";let R=v?.loginType,_=R==="google"||R==="apple"?R:null;if(!_)return"retry";let q=g?.toLowerCase(),U=q&&Array.isArray(W)?W.find(L=>L.address.toLowerCase()===q):null,z=Array.isArray(W)?W.filter(L=>/^0x[a-fA-F0-9]{40}$/.test(L.address)).map(L=>({address:L.address.toLowerCase(),...Number.isFinite(L.index)?{index:L.index}:{},...L.name?.trim()?{name:L.name.trim()}:{}})):[],M=q?r.current.get(q)?.trim():void 0,H=!U&&q&&/^0x[a-fA-F0-9]{40}$/.test(q)?[...z,{address:q,index:z.length,...M?{name:M}:{}}]:z,ke=M||U?.name?.trim()||(typeof U?.index=="number"?`Account ${U.index+1}`:g?`${g.slice(0,6)}\u2026${g.slice(-4)}`:null);return u({loginType:_,accountName:ke,accounts:H,isResolved:!0}),"done"};return(async()=>{for(let x=0;x<p;x++){if(C)return;let P=await T();if(P==="done")return;if(P==="giveup"){C||u({loginType:null,accountName:null,accounts:[],isResolved:!0});return}await new Promise(v=>setTimeout(v,k))}C||u({loginType:null,accountName:null,accounts:[],isResolved:!0})})(),()=>{C=!0}},[o,c,g,m]),Xn(()=>{if(o!=="cross_embedded"||!c||typeof c.getProvider!="function")return;let C=!1,p;return(async()=>{let k;try{k=await c.getProvider()}catch{return}if(C)return;let T=k?.sdk;T?.on&&(p=T.on("addressChanged",({address:x,walletName:P})=>{let v=P?.trim();v&&(r.current.set(x.toLowerCase(),v),b(W=>W+1))}))})(),()=>{C=!0,p?.()}},[o,c]),y}import{useCallback as Qs,useMemo as Yt,useRef as zs}from"react";import{useQuery as Xs}from"@tanstack/react-query";import{useAccount as Ys,useSignMessage as Js}from"wagmi";import{CrossAuthClient as Zs,HttpSafeDropApiAdapter as ei,ONE_POP_DEPLOYMENTS as ti,resolvePopEnvironment as ni}from"@nexus-cross/pop/api";function Jn(e,t){let n=[];for(let s of t)s.rejected||n.push({id:`pending-${s.claimAddress}`,direction:"received",handle:s.sender.handle||s.sender.address,...s.sender.profileImageUrl?{avatarUrl:s.sender.profileImageUrl}:{},amountRaw:s.amount.toString(),decimals:18,timestamp:Date.parse(s.depositedAt)||0,status:"ready"});for(let s of e){let o=s.status.toLowerCase(),c=(s.resolvedAt?Date.parse(s.resolvedAt):0)||Date.parse(s.depositedAt)||0,g={id:`${s.type}-${s.id}`,amountRaw:s.amount.toString(),decimals:18,timestamp:c};if(s.type==="sent"){n.push({...g,direction:"sent",handle:s.receiver.handle||s.receiver.address||"",...s.receiver.profileImageUrl?{avatarUrl:s.receiver.profileImageUrl}:{},status:o==="claimed"?"claimed":o==="refunded"?"refunded":"waiting"});continue}o==="claimed"&&n.push({...g,direction:"received",handle:s.sender.handle||s.sender.address,...s.sender.profileImageUrl?{avatarUrl:s.sender.profileImageUrl}:{},status:"claimed"})}return n.sort((s,o)=>o.timestamp-s.timestamp),n}var to="one-pop-summary",eo=20,kt=new Map;function oi(e){e?kt.delete(e.toLowerCase()):kt.clear()}function Jt(e={}){let{enabled:t=!1,environment:n,token:s,apiBaseUrl:o,authBaseUrl:c,getJwt:g,repliesWaitingCount:y=0}=e,u=Yt(()=>{if(s)return s;let P=ni(n);return ti[P]?.contracts?.permitErc20},[s,n]),{address:r,chainId:m}=Ys(),{signMessageAsync:b}=Js(),C=zs(null),p=Qs(async()=>{if(g)return g();if(!r||!m)return;let P=r.toLowerCase(),v=kt.get(P);if(v)return v;if(C.current)return C.current;let W=(async()=>{let R=new Zs(c?{baseUrl:c}:{}),{message:_}=await R.unsignedHash(m,r),q=await b({message:_}),{token:U}=await R.siweToken(r,q);return kt.set(P,U),U})();C.current=W;try{return await W}catch(R){throw kt.delete(P),R}finally{C.current=null}},[g,r,m,c,b]),k=Yt(()=>new ei({...o?{baseUrl:o}:{},getJwt:p}),[o,p]),T=Xs({queryKey:[to,r?.toLowerCase()??null,u?.toLowerCase()??null],enabled:t&&!!r,retry:!1,refetchOnWindowFocus:!1,staleTime:6e4,queryFn:async()=>{let[P,v,W,R]=await Promise.all([u?k.listDrops({token:u}).catch(()=>null):Promise.resolve(null),k.listHistories({type:"sent",page:1,pageSize:eo}).catch(()=>null),k.listHistories({type:"received",page:1,pageSize:eo}).catch(()=>null),k.getXConnection().catch(()=>null)]);return{drops:P,items:[...v?.items??[],...W?.items??[]],xConnected:!!R}}});return{summary:Yt(()=>{if(!t||!r)return;if(!T.data)return T.isLoading?{claimableCount:0,claimableTotalRaw:"0",claimableDecimals:18,repliesWaitingCount:y,activity:[],xConnected:!1,isLoading:!0}:void 0;let{drops:P,items:v,xConnected:W}=T.data;return{claimableCount:P?.count??0,claimableTotalRaw:(P?.totalAmount??0n).toString(),claimableDecimals:18,repliesWaitingCount:y,activity:Jn(v,P?.items??[]),xConnected:W,isLoading:!1}},[t,r,T.data,T.isLoading,y]),isLoading:T.isLoading,error:T.error??null,refetch:T.refetch}}import{Fragment as ro,jsx as le,jsxs as at}from"react/jsx-runtime";var hi=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]}],wi=[{type:"function",name:"earned",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"posaActive",stateMutability:"view",inputs:[],outputs:[{name:"",type:"bool"}]},{type:"function",name:"lastRewardBlock",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"totalStaked",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint256"}]}],Ci={dev:{poolAddress:"0x0000000c5BB5C7B081237B5efaFC753D61201b94",crossChainId:612044,networkStatsUrl:"https://stg-posa-api.crosstoken.io/api/v1/network/stats"},stage:{poolAddress:"0x0000000c5BB5C7B081237B5efaFC753D61201b94",crossChainId:612044,networkStatsUrl:"https://stg-posa-api.crosstoken.io/api/v1/network/stats"},production:{poolAddress:"0x000000068122d9bB43B4BCF5497A10EdfA9F5E93",crossChainId:612055,networkStatsUrl:"https://posa-api.crosstoken.io/api/v1/network/stats"}},tn=10n**18n,ki={google:{name:"Google",iconUrl:io,connectorId:et.CROSSx},apple:{name:"Apple",iconUrl:rn,connectorId:et.CROSSx},cross:{name:vt.default,iconUrl:on,connectorId:et.CROSSx},metamask:{name:"MetaMask",iconUrl:ao,connectorId:et.MetaMask},binance:{name:"Binance Wallet",iconUrl:so,connectorId:et.Binance}};function Ti(e){switch(e){case"cross_embedded":return et.CROSSx;case"metamask":return et.MetaMask;case"binance":return et.Binance;default:return}}function vi(e,t){switch(e){case"cross_embedded":return t==="google"?{name:"Google",iconUrl:io}:t==="apple"?{name:"Apple",iconUrl:rn}:{name:vt.default,iconUrl:on};case"cross_wallet":return{name:vt.default,iconUrl:on};case"cross_extension":return{name:vt.extension,iconUrl:bi};case"metamask":return{name:"MetaMask",iconUrl:ao};case"binance":return{name:"Binance Wallet",iconUrl:so};default:return null}}function Ii(e){if(e)return e==="cross_embedded"?vt.default:fi[e]?.name}function xi({label:e="Connect Wallet",className:t,style:n,walletInfoStyle:s,user:o,enablePortfolio:c,portfolio:g,theme:y,accountName:u,connectorId:r,showPortfolio:m,sendAccounts:b,getTransactionReceipt:C,sendTransaction:p,estimateGas:k,onDisconnect:T,onSelectWallet:x,onBuy:P,onRampRedirectUrl:v,onePopSummary:W,onOnePopOpen:R,onePopGetTokenSlot:_,onePopGetTokenOptions:q,showOnePop:U,bridgeTokens:z,bridgeHistory:M,getBridgeQuote:H,getBridgeToTokens:Ee,getBridgeApproval:ke,approveBridge:L,submitBridge:O,showBalance:X=!0,env:ee,...Se}){let{address:Ue,isConnected:Ve,connector:Me,chain:oe}=ai(),ue=di(),re=ci(),{switchChainAsync:Te}=ui(),{sendTransactionAsync:_e}=li(),{connectWallet:je,disconnect:be,selectWallet:tt,currentWallet:ve,isConnecting:Qe,kitConfig:nt}=Ae(),Be=nt?.restoreChainAfterSwitch!==!1,Ge=!!nt?.onePopEnabled,ct=yt(),i=y??ct?.mode??"dark",a=Tt(()=>mi(ee),[ee]),d=o?.address??Ue,f=o?ki[o.provider]:null,{loginType:w,accountName:N,accounts:D}=Xt({walletId:ve,connector:Me,address:d}),A=Tt(()=>f?{name:f.name,iconUrl:f.iconUrl}:vi(ve,w),[f,ve,w]),G=u??o?.name??N??void 0,Y=Se.connectorName??(f?f.name:Ii(ve)),S=f?f.connectorId:Ti(ve),F=r??S,V=g??m??!!c,$=Ct({env:a,walletAddress:d,enabled:Ve&&!!d&&X,restoreChainAfterSwitch:Be}),j=z??$.bridgeTokens,l=M??$.bridgeHistory,h=H??$.getBridgeQuote,I=Ee??$.getBridgeToTokens,E=ke??$.getBridgeApproval,B=L??$.approveBridge,Ie=O??$.submitBridge,ze=He(()=>{je().catch(K=>{console.error("[crossx-kit] connectWallet error:",K)})},[je]),dt=He(()=>{be()},[be]),Ne=T??dt,pe=gi(),{eligibility:Wt}=yi({network:oe?String(oe.id):void 0}),It=Wt?.allowed===!0,mo=Tt(()=>{if(P)return P;if(!(!pe||!oe||!It))return()=>pe.open({crypto:oe.nativeCurrency?.symbol??"USDT",network:String(oe.id),...v?{redirectUrl:v}:{}}).then(()=>{}).catch(K=>{throw console.warn("[crossx-kit] onramp open failed:",K),K})},[P,pe,oe,It,v]),cn=ii();ri(()=>{if(pe?.onStatus)return pe.onStatus(()=>{cn.invalidateQueries()})},[pe,cn]);let fo=Tt(()=>{if(!P&&!(!pe||!oe)&&!It)return"On-ramp is not available in your region."},[P,pe,oe,It]),[go,yo]=si(!1),bo=He(()=>{yo(!0),R?.()},[R]),{summary:ho}=Jt({enabled:Ge&&!W&&go,environment:a}),wo=W??ho,Dt=U??Ge,Co=Tt(()=>{if(_!==void 0)return _;if(Dt)return le(zt,{...q,env:a,theme:i,mode:"button",buttonComponent:pi})},[q,_,a,Dt,i]),ko=Se.onBridgeDisabledMessage,To=Se.onSendDisabledMessage,vo=o?o.provider==="google"||o.provider==="apple":ve==="cross_embedded",Io=He(()=>{tt().catch(K=>{console.error("[crossx-kit] selectWallet error:",K)})},[tt]),dn=x??(vo?Io:void 0),xo=He(async({hash:K,chainId:te})=>{let se=Zt(ue,te?{chainId:te}:void 0);if(!se)return null;try{return await se.getTransactionReceipt({hash:K})}catch{return null}},[ue]),Po=He(async K=>{let te=re,se=!1;K.chainId!==void 0&&K.chainId!==re&&(await Te({chainId:K.chainId}),se=!0);let me=K.chainId===56||K.chainId===97?{...K,type:"legacy"}:K,J=await(p??_e)(me);return await Rt({getChainId:()=>se?K.chainId:te,switchChain:we=>Te({chainId:we})},te,Be),J},[p,_e,re,Te,Be]),So=V||p?Po:void 0,Ao=He(async K=>{let te=K.chainId??re,se=Zt(ue,te?{chainId:te}:void 0);if(!se)throw new Error(`publicClient for chainId ${te??"unknown"} is not available \u2014 register the chain in createCrossxConfig({ networks }).`);let he=te===56||te===97,[me,xe]=await Promise.all([se.estimateGas({account:K.from,to:K.to,value:K.value,data:K.data}),(async()=>{if(he)return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await se.getGasPrice()};try{let J=await se.estimateFeesPerGas();return{maxFeePerGas:J.maxFeePerGas,maxPriorityFeePerGas:J.maxPriorityFeePerGas,gasPrice:void 0}}catch{return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await se.getGasPrice()}}})()]);return{gasLimit:me,maxFeePerGas:xe.maxFeePerGas,maxPriorityFeePerGas:xe.maxPriorityFeePerGas,gasPrice:xe.gasPrice}},[ue,re]),Ro=k??Ao,Oo=He(async K=>{let te={};if(!Ue||K.length===0)return te;let se=K.flatMap(me=>{let J={address:me,abi:hi,chainId:re};return[{...J,functionName:"balanceOf",args:[Ue]},{...J,functionName:"totalSupply"},{...J,functionName:"decimals"}]}),he;try{he=await no(ue,{contracts:se,allowFailure:!0})}catch{return te}return K.forEach((me,xe)=>{let J=xe*3,we=he[J],xt=he[J+1],lt=he[J+2];!we||we.status!=="success"||(te[me.toLowerCase()]={balance:we.result,totalSupply:xt&&xt.status==="success"?xt.result:void 0,decimals:lt&<.status==="success"?Number(lt.result):void 0})}),te},[ue,Ue,re]),Eo=He(async K=>{let te={earnedWei:0n,stakedWei:0n};if(!K)return te;let se=Ci[a],he={address:se.poolAddress,abi:wi,chainId:se.crossChainId},me;try{me=await no(ue,{allowFailure:!0,contracts:[{...he,functionName:"earned",args:[K]},{...he,functionName:"balanceOf",args:[K]},{...he,functionName:"posaActive"},{...he,functionName:"lastRewardBlock"},{...he,functionName:"totalStaked"}]})}catch{return te}let xe=ot=>me[ot]&&me[ot].status==="success"?me[ot].result:0n,J=xe(0),we=xe(1);if(me[2]&&me[2].status==="success"?me[2].result:!1)return{earnedWei:J,stakedWei:we};let lt=xe(3),pn=xe(4);if(pn===0n)return{earnedWei:J,stakedWei:we};let Ft=0n;try{Ft=await Zt(ue,{chainId:se.crossChainId})?.getBlockNumber?.()??0n}catch{return{earnedWei:J,stakedWei:we}}if(Ft<=lt)return{earnedWei:J,stakedWei:we};let Lt=0n;try{let ot=await fetch(se.networkStatsUrl).then(Ut=>Ut.json()),mn=ot?.data?.block_reward??ot?.block_reward;if(mn){let[Ut,Wo=""]=String(mn).split("."),Do=(Wo+"0".repeat(18)).slice(0,18);Lt=BigInt(Ut||"0")*tn+BigInt(Do||"0")}}catch{}if(Lt===0n)return{earnedWei:J,stakedWei:we};let Bo=(Ft-lt)*Lt*tn/pn,No=we*Bo/tn;return{earnedWei:J+No,stakedWei:we}},[ue,a]),ln=!dn,un=t?`cb-button ${t}`:"cb-button",_o=t?`cb-pill ${t}`:"cb-pill";return Qe&&!Ve?at(ro,{children:[le("style",{children:nn}),at("button",{type:"button",disabled:!0,className:un,style:n,"aria-busy":"true",children:[le("span",{className:"cb-spinner","aria-hidden":"true"}),le("span",{className:"cb-button-label",children:"Connecting..."})]})]}):Ve&&d?at("span",{"data-crossx-wallet-info":ln?"external":"embedded",children:[le("style",{children:nn}),ln&&le("style",{children:Si}),at(en,{...Se,env:a,theme:i,showBalance:X,walletAddress:d,accountName:G,sendAccounts:b??D,connectorName:Y,connectorId:F,showPortfolio:V,showOnePop:Dt,onePopSummary:wo,onOnePopOpen:bo,onePopGetTokenSlot:Co,onDisconnect:Ne,onSelectWallet:dn,onBuy:mo,onBuyDisabledMessage:fo,onBridgeDisabledMessage:ko,onSendDisabledMessage:To,sendTransaction:So,getTransactionReceipt:C??xo,estimateGas:Ro,lpBalanceReader:Oo,stakingRewardsReader:Eo,bridgeTokens:j,bridgeHistory:l,getBridgeQuote:h,getBridgeToTokens:I,getBridgeApproval:E,approveBridge:B,submitBridge:Ie,style:s,children:[le(en.Trigger,{asChild:!0,children:at("button",{type:"button",className:_o,style:n,"aria-label":`Connected with ${A?.name??"wallet"}: ${oo(d)}`,children:[A?.iconUrl?le("img",{src:A.iconUrl,alt:"",width:20,height:20,className:"cb-pill-icon","data-provider":A.iconUrl===rn?"apple":void 0}):le("span",{className:"cb-pill-icon-placeholder","aria-hidden":"true"}),le("span",{className:"cb-pill-address",children:oo(d)})]})}),le(en.Content,{align:"end",sideOffset:8})]})]}):at(ro,{children:[le("style",{children:nn}),at("button",{type:"button",onClick:ze,className:un,style:n,"aria-label":typeof e=="string"?e:"Connect Wallet",children:[le(Pi,{}),le("span",{className:"cb-button-label",children:e})]})]})}function Pi(){return le("svg",{className:"cb-button-icon",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:le("path",{d:"M11.4368 10.5007C11.4368 9.9538 11.6544 9.42855 12.041 9.04175C12.4278 8.65492 12.9529 8.4375 13.5 8.4375H15.1875V6.00073L15.1732 5.92822C15.1639 5.90585 15.15 5.88528 15.1326 5.8678C15.0973 5.83263 15.0494 5.81287 14.9996 5.81287H3.74963C3.4787 5.81287 3.21001 5.75949 2.95972 5.65576C2.90937 5.63488 2.86089 5.61017 2.8125 5.58545V14.2504C2.8125 14.4989 2.91141 14.7371 3.08716 14.9128C3.2629 15.0886 3.50109 15.1875 3.74963 15.1875H15.0007C15.0252 15.1875 15.0495 15.1826 15.0721 15.1732C15.0948 15.1638 15.1152 15.1499 15.1326 15.1326C15.1499 15.1152 15.1638 15.0948 15.1732 15.0721C15.1826 15.0495 15.1875 15.0252 15.1875 15.0007V12.5629H13.5C12.9529 12.5629 12.4278 12.3454 12.041 11.9586C11.6545 11.5719 11.4369 11.0475 11.4368 10.5007ZM12.5618 10.5007C12.5619 10.7491 12.6609 10.9875 12.8364 11.1632C13.0123 11.3391 13.2513 11.4379 13.5 11.4379H15.75C15.7998 11.4379 15.8477 11.4182 15.8829 11.3829C15.9182 11.3477 15.9379 11.2998 15.9379 11.25V9.75037C15.9379 9.70054 15.9182 9.65266 15.8829 9.61743C15.8477 9.5822 15.7998 9.5625 15.75 9.5625H13.5C13.2513 9.5625 13.0123 9.66131 12.8364 9.83716C12.6607 10.013 12.5618 10.2522 12.5618 10.5007ZM13.6879 3.00037C13.6879 2.95054 13.6682 2.90266 13.6329 2.86743C13.5977 2.8322 13.5498 2.8125 13.5 2.8125H3.74963C3.50109 2.8125 3.2629 2.91141 3.08716 3.08716C2.91141 3.2629 2.8125 3.50109 2.8125 3.74963L2.81689 3.84192C2.82585 3.93354 2.8486 4.02351 2.88391 4.10889C2.93096 4.22263 3.00015 4.32614 3.08716 4.41321C3.17403 4.50009 3.2769 4.56936 3.39038 4.61646C3.50412 4.66359 3.62651 4.68787 3.74963 4.68787H13.6879V3.00037ZM14.8129 4.68787H14.9996C15.3473 4.68787 15.6808 4.82576 15.9269 5.07129C16.173 5.31702 16.3119 5.65077 16.3125 5.99854V8.56494C16.4469 8.62873 16.5711 8.7148 16.6783 8.82202C16.9246 9.06823 17.0629 9.40217 17.0629 9.75037V11.25C17.0629 11.5982 16.9246 11.9321 16.6783 12.1783C16.5712 12.2855 16.4468 12.3706 16.3125 12.4343V14.9985L16.3059 15.1282C16.2934 15.2564 16.2619 15.3822 16.2125 15.5017C16.1466 15.6612 16.05 15.806 15.928 15.928C15.806 16.05 15.6612 16.1466 15.5017 16.2125C15.3425 16.2783 15.1719 16.3126 14.9996 16.3125H3.74963C3.20272 16.3125 2.67847 16.095 2.29175 15.7083C1.90502 15.3215 1.6875 14.7973 1.6875 14.2504V3.74963C1.6875 3.20272 1.90502 2.67847 2.29175 2.29175C2.67847 1.90502 3.20272 1.6875 3.74963 1.6875H13.5C13.8482 1.6875 14.1821 1.82581 14.4283 2.07202C14.6746 2.31823 14.8129 2.65217 14.8129 3.00037V4.68787Z",fill:"currentColor"})})}var Si=`
|
|
3
|
+
[data-crossx-wallet-info="external"] .wi-select-wallet-btn {
|
|
4
|
+
display: none !important;
|
|
5
|
+
}
|
|
6
|
+
`;function oo(e){return`${e.slice(0,6)}...${e.slice(-4)}`}var nn=`
|
|
7
|
+
.cb-button {
|
|
8
|
+
-webkit-font-smoothing: antialiased;
|
|
9
|
+
--cb-bg: var(--ds-accent-primary-default, #F0640D);
|
|
10
|
+
--cb-bg-hover: var(--ds-accent-primary-high, #f0640d);
|
|
11
|
+
--cb-color: var(--ds-accent-primary-on, #000);
|
|
12
|
+
--cb-border: none;
|
|
13
|
+
--cb-radius: 8px;
|
|
14
|
+
--cb-height: 36px;
|
|
15
|
+
--cb-padding: 0 16px;
|
|
16
|
+
--cb-font-family: Inter, system-ui, -apple-system, sans-serif;
|
|
17
|
+
--cb-font-size: 14px;
|
|
18
|
+
--cb-font-weight: 500;
|
|
19
|
+
--cb-gap: 8px;
|
|
20
|
+
--cb-transition: background-color 0.15s ease, transform 0.1s ease;
|
|
21
|
+
--cb-loading-opacity: 0.7;
|
|
22
|
+
--cb-press-scale: 0.95;
|
|
23
|
+
--cb-spinner-size: 14px;
|
|
24
|
+
--cb-spinner-thumb: currentColor;
|
|
25
|
+
--cb-spinner-track: color-mix(in srgb, currentColor 20%, transparent);
|
|
26
|
+
--cb-icon-size: 18px;
|
|
27
|
+
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
height: var(--cb-height);
|
|
33
|
+
gap: var(--cb-gap);
|
|
34
|
+
padding: var(--cb-padding);
|
|
35
|
+
border-radius: var(--cb-radius);
|
|
36
|
+
border: var(--cb-border);
|
|
37
|
+
background: var(--cb-bg);
|
|
38
|
+
color: var(--cb-color);
|
|
39
|
+
font-family: var(--cb-font-family);
|
|
40
|
+
font-size: var(--cb-font-size);
|
|
41
|
+
font-weight: var(--cb-font-weight);
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
transition: var(--cb-transition);
|
|
44
|
+
}
|
|
45
|
+
.cb-button:hover:not(:disabled) { background: var(--cb-bg-hover); }
|
|
46
|
+
.cb-button:active:not(:disabled) { transform: scale(var(--cb-press-scale)); }
|
|
47
|
+
.cb-button:disabled, .cb-button[aria-busy="true"] {
|
|
48
|
+
cursor: default;
|
|
49
|
+
opacity: var(--cb-loading-opacity);
|
|
50
|
+
}
|
|
51
|
+
.cb-spinner {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
width: var(--cb-spinner-size);
|
|
54
|
+
height: var(--cb-spinner-size);
|
|
55
|
+
border: 2px solid var(--cb-spinner-track);
|
|
56
|
+
border-top-color: var(--cb-spinner-thumb);
|
|
57
|
+
border-radius: 50%;
|
|
58
|
+
animation: cck-cb-spin 0.6s linear infinite;
|
|
59
|
+
flex-shrink: 0;
|
|
60
|
+
}
|
|
61
|
+
.cb-button-icon {
|
|
62
|
+
width: var(--cb-icon-size);
|
|
63
|
+
height: var(--cb-icon-size);
|
|
64
|
+
flex-shrink: 0;
|
|
65
|
+
}
|
|
66
|
+
.cb-button-label { white-space: nowrap; }
|
|
67
|
+
.cb-pill {
|
|
68
|
+
--cb-pill-bg: var(--ds-surface-default, #1e232e);
|
|
69
|
+
--cb-pill-bg-hover: var(--ds-surface-medium, #252b39);
|
|
70
|
+
--cb-pill-color: var(--ds-content-high, #ffffffd9);
|
|
71
|
+
--cb-pill-border: 1px solid var(--ds-border-default, #ffffff12);
|
|
72
|
+
--cb-pill-border-hover: 1px solid var(--ds-border-medium, #ffffff2e);
|
|
73
|
+
--cb-pill-radius: 8px;
|
|
74
|
+
--cb-pill-height: 36px;
|
|
75
|
+
--cb-pill-padding: 0 12px;
|
|
76
|
+
--cb-pill-press-scale: 0.95;
|
|
77
|
+
--cb-pill-font-family: Inter, system-ui, -apple-system, sans-serif;
|
|
78
|
+
--cb-pill-font-size: 14px;
|
|
79
|
+
--cb-pill-font-weight: 500;
|
|
80
|
+
--cb-pill-gap: 8px;
|
|
81
|
+
--cb-pill-icon-size: 20px;
|
|
82
|
+
--cb-pill-icon-placeholder-bg: var(--ds-surface-high, #2a2d3a);
|
|
83
|
+
--cb-pill-address-font: Inter, system-ui, -apple-system, sans-serif;
|
|
84
|
+
--cb-pill-address-font-size: 14px;
|
|
85
|
+
--cb-pill-address-letter-spacing: -0.01em;
|
|
86
|
+
|
|
87
|
+
display: inline-flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
box-sizing: border-box;
|
|
90
|
+
height: var(--cb-pill-height);
|
|
91
|
+
gap: var(--cb-pill-gap);
|
|
92
|
+
padding: var(--cb-pill-padding);
|
|
93
|
+
border-radius: var(--cb-pill-radius);
|
|
94
|
+
border: var(--cb-pill-border);
|
|
95
|
+
background: var(--cb-pill-bg);
|
|
96
|
+
color: var(--cb-pill-color);
|
|
97
|
+
font-family: var(--cb-pill-font-family);
|
|
98
|
+
font-size: var(--cb-pill-font-size);
|
|
99
|
+
font-weight: var(--cb-pill-font-weight);
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
}
|
|
102
|
+
.cb-pill:hover,
|
|
103
|
+
.cb-pill[data-state="open"] { background: var(--cb-pill-bg-hover); border: var(--cb-pill-border-hover, 1px solid var(--ds-border-medium, #ffffff2e)); }
|
|
104
|
+
.cb-pill:active:not(:disabled) { transform: scale(var(--cb-pill-press-scale)); }
|
|
105
|
+
.cb-pill-icon {
|
|
106
|
+
width: var(--cb-pill-icon-size);
|
|
107
|
+
height: var(--cb-pill-icon-size);
|
|
108
|
+
border-radius: 50%;
|
|
109
|
+
object-fit: contain;
|
|
110
|
+
flex-shrink: 0;
|
|
111
|
+
background: transparent;
|
|
112
|
+
}
|
|
113
|
+
/* Apple is a monochrome black logomark in an <img> data URI (can't follow
|
|
114
|
+
theme via currentColor). Flip it to white in dark mode so it stays
|
|
115
|
+
visible on the dark pill; multicolor marks (Google/MetaMask/Binance/
|
|
116
|
+
CROSSx) are untouched. */
|
|
117
|
+
[data-theme="dark"] .cb-pill-icon[data-provider="apple"] {
|
|
118
|
+
filter: invert(1);
|
|
119
|
+
}
|
|
120
|
+
.cb-pill-icon-placeholder {
|
|
121
|
+
display: inline-block;
|
|
122
|
+
width: var(--cb-pill-icon-size);
|
|
123
|
+
height: var(--cb-pill-icon-size);
|
|
124
|
+
border-radius: 50%;
|
|
125
|
+
background: var(--cb-pill-icon-placeholder-bg);
|
|
126
|
+
flex-shrink: 0;
|
|
127
|
+
}
|
|
128
|
+
.cb-pill-address {
|
|
129
|
+
font-family: var(--cb-pill-address-font);
|
|
130
|
+
font-size: var(--cb-pill-address-font-size);
|
|
131
|
+
letter-spacing: var(--cb-pill-address-letter-spacing);
|
|
132
|
+
}
|
|
133
|
+
@media (max-width: 767.98px) {
|
|
134
|
+
.cb-button, .cb-pill {
|
|
135
|
+
width: 36px;
|
|
136
|
+
min-width: 36px;
|
|
137
|
+
padding: 0;
|
|
138
|
+
}
|
|
139
|
+
.cb-button-label, .cb-pill-address { display: none; }
|
|
140
|
+
}
|
|
141
|
+
@keyframes cck-cb-spin {
|
|
142
|
+
to { transform: rotate(360deg); }
|
|
143
|
+
}
|
|
144
|
+
`;import{useCallback as co,useEffect as Ai,useMemo as lo,useState as Ri}from"react";import{detectWallets as uo,DEFAULT_WALLET_REGISTRY as po}from"@nexus-cross/connect-kit-wagmi";import{jsx as de,jsxs as Le}from"react/jsx-runtime";var Oi=["Ensure your wallet extension is installed and unlocked","Try refreshing the page","Some wallets may require you to first open the extension","You can try clicking the wallet anyway"],Ei="Connect with one of our available wallet providers to continue.";function _i({open:e,onClose:t,onSelect:n,title:s="Connect Wallet",description:o=Ei,troubleshootingTips:c=Oi}){let{availableWallets:g}=Ae(),[y,u]=Ri({});Ai(()=>{if(!e)return;let p=uo(po),k={};for(let x of p)x.installed!==void 0&&(k[x.id]=x.installed);u(k);let T=setTimeout(()=>{let x=uo(po),P={};for(let v of x)v.installed!==void 0&&(P[v.id]=v.installed);u(P)},1e3);return()=>clearTimeout(T)},[e]);let r=lo(()=>typeof navigator>"u"?!1:/Mobi|Android/i.test(navigator.userAgent),[]),m=lo(()=>r?g.filter(p=>p.type!=="extension"):g,[g,r]),b=co(p=>{if(!y[p.walletId]&&p.installUrl&&p.type==="extension"){window.open(p.installUrl,"_blank");return}t(),n(p.walletId)},[t,n,y]),C=co((p,k)=>{p.stopPropagation(),t(),window.open(k,"_blank")},[t]);return e?de("div",{style:Q.overlay,onClick:t,children:Le("div",{style:Q.modal,onClick:p=>p.stopPropagation(),children:[Le("div",{style:Q.header,children:[de("h2",{style:Q.title,children:s}),de("button",{type:"button",onClick:t,style:Q.closeBtn,"aria-label":"Close",children:Le("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[de("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),de("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),de("p",{style:Q.desc,children:o}),de("div",{style:Q.walletList,children:m.map(p=>{let k=y[p.walletId],T=k===!1&&p.type==="extension"&&!!p.installUrl;return Le("div",{style:Q.walletGroup,children:[Le("button",{type:"button",onClick:()=>b(p),style:{...Q.walletItem,...p.walletId==="cross_wallet"?Q.walletItemAccent:{}},"aria-label":`Connect with ${p.name}`,children:[p.iconUrl?de("img",{src:p.iconUrl,alt:"",style:Q.walletIcon}):de("div",{style:Q.walletIconPlaceholder}),Le("div",{style:Q.walletInfo,children:[Le("div",{style:Q.walletNameRow,children:[de("span",{style:Q.walletName,children:p.name}),k!==void 0&&de("span",{style:{...Q.badge,...k?Q.badgeInstalled:Q.badgeNotInstalled},children:k?"Installed":"Not Installed"})]}),de("span",{style:Q.walletDesc,children:T?"Extension not detected \u2014 click to install":p.type==="extension"?"Browser extension approval is required":p.walletId==="cross_wallet"?"App approval is required":p.walletId==="binance"?"Mobile app only \u2014 Add CROSS network first":k?"Connect with browser extension":"Scan QR code with app"})]})]}),p.guideUrl&&Le("button",{type:"button",onClick:x=>C(x,p.guideUrl),style:Q.guideBtn,children:[de("span",{"aria-hidden":"true",children:"\u26A0\uFE0F"}),p.guideLabel??"Required Settings"]})]},p.walletId)})}),Le("div",{style:Q.troubleshoot,children:[de("h3",{style:Q.troubleshootTitle,children:"Wallet not detected?"}),de("ul",{style:Q.troubleshootList,children:c.map(p=>Le("li",{style:Q.troubleshootItem,children:[de("span",{style:Q.troubleshootDot,"aria-hidden":"true"}),de("span",{children:p})]},p))})]})]})}):null}var Z={surfaceBg:"var(--wi-surface-bg, #121212)",surfaceDefault:"var(--wi-surface-default, rgba(255,255,255,0.05))",surfaceSubtle:"var(--wi-surface-subtle, rgba(255,255,255,0.1))",borderDefault:"var(--wi-border-default, rgba(255,255,255,0.05))",textPrimary:"var(--wi-texticon-primary, #ffffff)",textSecondary:"var(--wi-texticon-secondary, rgba(255,255,255,0.7))",textTertiary:"var(--wi-texticon-tertiary, rgba(255,255,255,0.5))",primary:"var(--wi-primary, #019d92)",primarySoft:"var(--crossx-kit-primary-soft, rgba(1,157,146,0.15))",accentGradient:"var(--crossx-kit-accent-gradient, linear-gradient(113deg, rgba(255,255,255,0.05) 0%, rgba(1,157,146,0.12) 70%, rgba(255,255,255,0.05) 70%, rgba(1,157,146,0.12) 80%, rgba(255,255,255,0.05) 80%))",warningBg:"var(--crossx-kit-warning-bg, rgba(245,158,11,0.1))",warningBorder:"var(--crossx-kit-warning-border, rgba(245,158,11,0.25))",warningText:"var(--crossx-kit-warning-text, #fbbf24)"},Q={overlay:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)"},modal:{width:"100%",maxWidth:"420px",margin:"16px",background:Z.surfaceBg,border:`1px solid ${Z.borderDefault}`,borderRadius:"20px",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 0"},title:{fontSize:"18px",fontWeight:700,color:Z.textPrimary,margin:0},closeBtn:{background:"none",border:"none",color:Z.textTertiary,cursor:"pointer",padding:"4px",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center"},desc:{padding:"8px 24px 16px",fontSize:"13px",color:Z.textTertiary,margin:0,lineHeight:1.5},walletList:{display:"flex",flexDirection:"column",gap:"6px",padding:"0 12px 12px"},walletGroup:{display:"flex",flexDirection:"column",borderRadius:"12px",overflow:"hidden",background:Z.surfaceDefault},walletItem:{display:"flex",alignItems:"center",gap:"14px",width:"100%",padding:"14px",background:"transparent",border:"none",color:Z.textPrimary,cursor:"pointer",textAlign:"left"},walletItemAccent:{background:Z.accentGradient},walletIcon:{width:"40px",height:"40px",borderRadius:"10px",flexShrink:0},walletIconPlaceholder:{width:"40px",height:"40px",borderRadius:"10px",background:Z.surfaceSubtle,flexShrink:0},walletInfo:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"3px"},walletNameRow:{display:"flex",alignItems:"center",gap:"8px"},walletName:{fontSize:"15px",fontWeight:700,lineHeight:1.3,color:Z.textPrimary},badge:{fontSize:"10px",fontWeight:600,padding:"2px 7px",borderRadius:"99px",lineHeight:1},badgeInstalled:{background:Z.primarySoft,color:Z.primary},badgeNotInstalled:{background:"rgba(255,255,255,0.05)",color:Z.textTertiary},walletDesc:{fontSize:"11px",color:Z.textSecondary,lineHeight:1.3},guideBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",margin:"0 14px 14px",padding:"10px 12px",borderRadius:"10px",border:`1px solid ${Z.warningBorder}`,background:Z.warningBg,color:Z.warningText,fontWeight:600,fontSize:"13px",cursor:"pointer"},troubleshoot:{margin:"0 12px 16px",background:Z.surfaceDefault,borderRadius:"12px",padding:"14px 16px"},troubleshootTitle:{fontSize:"12px",fontWeight:700,color:Z.textPrimary,margin:"0 0 8px"},troubleshootList:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"8px"},troubleshootItem:{display:"flex",alignItems:"flex-start",gap:"8px",fontSize:"11px",color:Z.textSecondary,lineHeight:1.5},troubleshootDot:{flexShrink:0,width:"4px",height:"4px",marginTop:"6px",borderRadius:"50%",background:Z.textSecondary}};import{useAccount as Bi}from"wagmi";import{RelayHistory as sn}from"@nexus-cross/dapp-ui";import{jsx as Di}from"react/jsx-runtime";function Ni(e){let{address:t}=Bi();return Di(sn,{walletAddress:t,...e})}var Wi=Object.assign(Ni,{Trigger:sn.Trigger,Content:sn.Content});import{RelayRecovery as an}from"@nexus-cross/dapp-ui";import{jsx as Ui}from"react/jsx-runtime";function Fi(e){let t=ft();return Ui(an,{...t,...e})}var Li=Object.assign(Fi,{Trigger:an.Trigger,Content:an.Content});import{useContext as Mi,useEffect as Gi,useRef as Ki}from"react";function $i(e){let t=Mi(At);if(!t)throw new Error("useConnectKitAnalytics must be used within <CrossConnectKitProvider>");let n=Ki(e);n.current=e;let{subscribe:s}=t;Gi(()=>s(c=>n.current(c)),[s])}import{useOnRamp as ed,useOnRampEligibility as td,OnRampProvider as nd}from"@nexus-cross/onramp/react";import{useKyc as rd,useOptionalKyc as sd,KycProvider as id,KycError as ad,launchKycVerification as cd}from"@nexus-cross/kyc/react";import{WalletInfo as ld,ConnectorId as ud}from"@nexus-cross/dapp-ui";import{AppLauncher as md,AppLauncherTrigger as fd,AppLauncherContent as gd,useGlobalMenu as yd}from"@nexus-cross/dapp-ui";import{SkillsButton as hd}from"@nexus-cross/dapp-ui";import{createRelayClient as Cd,RelayApiError as kd,DEFAULT_TRUSTED_FACTORIES as Td,useRelayConfig as vd,useRelayOrders as Id,useRelayRecovery as xd}from"@nexus-cross/dapp-ui";import{OnRampError as Sd}from"@nexus-cross/connect-kit-core";import{ConnectionStatus as Rd,formatBalance as Od,formatWei as Ed}from"@nexus-cross/connect-kit-core";fn();export{Ae as a,Ko as b,yt as c,Gt as d,kr as e,Ct as f,ft as g,Fs as h,zt as i,Xt as j,to as k,oi as l,Jt as m,xi as n,_i as o,Wi as p,Li as q,$i as r,ed as s,td as t,nd as u,rd as v,sd as w,id as x,ad as y,cd as z,ld as A,ud as B,md as C,fd as D,gd as E,yd as F,hd as G,Cd as H,kd as I,Td as J,vd as K,Id as L,xd as M,Sd as N,Rd as O,Od as P,Ed as Q};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ConnectButton, ConnectButtonProps, CrossConnectKitContextValue, CrossConnectKitProvider, CrossConnectKitProviderProps, CrossConnectKitThemeContextValue, CrossConnectModal, CrossConnectModalProps, CrossGetOneUsd, CrossGetOneUsdBridgeOptions, CrossGetOneUsdProps, CrossGetOneUsdRelayProps, CrossRelayDeposit, CrossRelayDepositProps, CrossRelayHistory, CrossRelayHistoryProps, CrossRelayRecovery, CrossRelayRecoveryProps, CrossxEmbeddedInfo, OtherWalletsModal, OtherWalletsModalProps, WalletProvider, WalletUser, useConnectKitAnalytics, useCrossConnectKit, useCrossConnectKitTheme, useCrossdBridgeAdapter, useCrossxEmbeddedInfo, useOptionalCrossConnectKitTheme, useRelayWalletProps } from './index.js';
|
|
1
|
+
export { ConnectButton, ConnectButtonProps, CrossConnectKitContextValue, CrossConnectKitProvider, CrossConnectKitProviderProps, CrossConnectKitThemeContextValue, CrossConnectModal, CrossConnectModalProps, CrossGetOneUsd, CrossGetOneUsdBridgeOptions, CrossGetOneUsdProps, CrossGetOneUsdRelayProps, CrossRelayDeposit, CrossRelayDepositProps, CrossRelayHistory, CrossRelayHistoryProps, CrossRelayRecovery, CrossRelayRecoveryProps, CrossxEmbeddedInfo, ONE_POP_SUMMARY_QUERY_KEY, OtherWalletsModal, OtherWalletsModalProps, UseOnePopSummaryOptions, UseOnePopSummaryResult, WalletProvider, WalletUser, clearOnePopJwtCache, useConnectKitAnalytics, useCrossConnectKit, useCrossConnectKitTheme, useCrossdBridgeAdapter, useCrossxEmbeddedInfo, useOnePopSummary, useOptionalCrossConnectKitTheme, useRelayWalletProps } from './index.js';
|
|
2
2
|
export { OnRampProvider, OnRampProviderProps, UseOnRampEligibilityOptions, UseOnRampEligibilityResult, UseOnRampOptions, UseOnRampResult, useOnRamp, useOnRampEligibility } from '@nexus-cross/onramp/react';
|
|
3
3
|
export { KycError, KycErrorCode, KycIdentity, KycLaunchTarget, KycLoginType, KycProvider, KycProviderProps, KycRejectType, KycStatus, KycVerificationHandle, KycVerificationMode, LaunchKycVerificationOptions, UseKycOptions, UseKycResult, launchKycVerification, useKyc, useOptionalKyc } from '@nexus-cross/kyc/react';
|
|
4
4
|
export { AppLauncher, AppLauncherContent, AppLauncherContentProps, AppLauncherProps, AppLauncherTrigger, AppLauncherTriggerProps, AppLauncherTriggerStyle, Catalog, ConnectButtonStyle, ConnectorId, DEFAULT_TRUSTED_FACTORIES, DepositAddressResult, GetOneUsdActionId, GetOneUsdEvent, GetOneUsdMode, GetOneUsdPairs, GetOneUsdTokenRef, GlobalMenu, GlobalMenuItem, GlobalMenuItemUrl, OrderSummary, OriginOption, QuoteResult, RecoveryInfo, RecoverySuccessResult, RelayApiError, RelayBalance, RelayClient, RelayClientOptions, RelayContractCall, RelayDrawerDirection, RelayHex, RelayRecoveryAction, RelayRecoveryQueryKey, RelayRecoveryQueryOptions, RelayRecoveryState, RelayRecoveryStep, RelayTheme, RelayTxRequest, RelayWalletProps, SendTransactionArgs, SendTransactionFn, SkillsButton, SkillsButtonProps, SkillsButtonStyle, UseRelayConfigOptions, UseRelayConfigResult, UseRelayOrdersOptions, UseRelayOrdersResult, UseRelayRecoveryOptions, UseRelayRecoveryResult, WalletInfo, WalletInfoContentProps, WalletInfoProps, WalletInfoStyle, WalletInfoTriggerProps, createRelayClient, useGlobalMenu, useRelayConfig, useRelayOrders, useRelayRecovery } from '@nexus-cross/dapp-ui';
|
|
@@ -11,6 +11,7 @@ import { ReownAdapterOptions } from '@nexus-cross/connect-kit-wagmi/reown';
|
|
|
11
11
|
import 'react/jsx-runtime';
|
|
12
12
|
import 'react';
|
|
13
13
|
import 'wagmi';
|
|
14
|
+
import '@nexus-cross/pop/api';
|
|
14
15
|
|
|
15
16
|
type ConnectKitWalletPreset = 'all' | 'cross-only' | 'external-only';
|
|
16
17
|
type ConnectKitEnvironmentInput = 'development' | 'dev' | 'staging' | 'stage' | 'stg' | 'production' | 'prod' | 'prd';
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as ie,B as se,C as de,D as pe,E as ce,F as le,G as ue,H as fe,I as Ce,J as we,K as me,L as ge,M as ye,N as Ne,a as S,b as V,c as W,d as X,e as L,f as h,g as j,h as B,i as F,j as D,k as U,l as q,m as z,n as $,o as G,p as H,q as J,r as Q,s as Y,t as Z,u as ee,v as ne,w as te,x as oe,y as re,z as ae}from"./chunk-
|
|
1
|
+
import{A as ie,B as se,C as de,D as pe,E as ce,F as le,G as ue,H as fe,I as Ce,J as we,K as me,L as ge,M as ye,N as Ne,O as ve,P as xe,Q as Ee,a as S,b as V,c as W,d as X,e as L,f as h,g as j,h as B,i as F,j as D,k as U,l as q,m as z,n as $,o as G,p as H,q as J,r as Q,s as Y,t as Z,u as ee,v as ne,w as te,x as oe,y as re,z as ae}from"./chunk-OZRWNMCO.js";import{bscMainnetNetwork as v,bscTestnetNetwork as x,createCrossxConfig as E,crossMainnetNetwork as k,crossTestnetNetwork as O}from"@nexus-cross/connect-kit-wagmi";import{toNexusAdapter as A}from"@nexus-cross/connect-kit-wagmi/to-nexus";import{reownAdapter as M}from"@nexus-cross/connect-kit-wagmi/reown";import{embeddedConnectorFactory as P}from"@nexus-cross/connect-kit-wagmi/embedded";import{WALLET_BRAND_NAME as I}from"@nexus-cross/crossx-design-system";function d(e){try{return import.meta.env?.[e]}catch{return}}function p(e){if(!(typeof process>"u"))return process.env?.[e]}function K(){return d("VITE_CROSSX_ENVIRONMENT")??d("NEXT_PUBLIC_CROSSX_ENVIRONMENT")??p("NEXT_PUBLIC_CROSSX_ENVIRONMENT")??p("CROSSX_ENVIRONMENT")}function R(e){switch(e?.toLowerCase()){case"dev":case"development":return"development";case"stage":case"staging":case"stg":return"staging";default:return"production"}}function T(e){return e==="production"?[k,v]:[O,x]}function b(){let e=typeof window<"u"&&window.location?.origin?window.location.origin:"https://example.com";return{name:`${I} DApp`,url:e}}function _(e){let{app:c,appMetadata:l,networks:u,defaultNetwork:f,wallets:n,embedded:C=!0,environment:w,toNexus:t,reown:o,...r}=e,m=R(w??K()),i=u??T(m),a=Array.isArray(n)?null:n??"all",s=a!=="external-only"&&t!==!1,g=a!=="cross-only"&&o!==!1&&!!r.reownProjectId,y=t===!1?void 0:t,N=o===!1?void 0:o;if(a==="external-only"&&!r.reownProjectId)throw new Error('[crossx-kit] createConnectKitConfig({ wallets: "external-only" }) requires `reownProjectId`.');return E({...r,appMetadata:l??c??b(),networks:i,defaultNetwork:f??i[0],...Array.isArray(n)?{wallets:n}:{},...s?{crossProvider:A(y)}:{},...g?{reownProvider:M(N)}:{},...s&&C?{embeddedConnectorFactory:P}:{}})}export{de as AppLauncher,ce as AppLauncherContent,pe as AppLauncherTrigger,$ as ConnectButton,ve as ConnectionStatus,se as ConnectorId,L as CrossConnectKitProvider,X as CrossConnectModal,F as CrossGetOneUsd,B as CrossRelayDeposit,H as CrossRelayHistory,J as CrossRelayRecovery,we as DEFAULT_TRUSTED_FACTORIES,re as KycError,oe as KycProvider,U as ONE_POP_SUMMARY_QUERY_KEY,Ne as OnRampError,ee as OnRampProvider,G as OtherWalletsModal,Ce as RelayApiError,ue as SkillsButton,ie as WalletInfo,q as clearOnePopJwtCache,_ as createConnectKitConfig,fe as createRelayClient,xe as formatBalance,Ee as formatWei,ae as launchKycVerification,Q as useConnectKitAnalytics,S as useCrossConnectKit,V as useCrossConnectKitTheme,h as useCrossdBridgeAdapter,D as useCrossxEmbeddedInfo,le as useGlobalMenu,ne as useKyc,Y as useOnRamp,Z as useOnRampEligibility,z as useOnePopSummary,W as useOptionalCrossConnectKitTheme,te as useOptionalKyc,me as useRelayConfig,ge as useRelayOrders,ye as useRelayRecovery,j as useRelayWalletProps};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ import { CrossxConfig, CrossConnectKitInitialState, ConnectorRegistry, Connector
|
|
|
4
4
|
export { ConnectorEntry, ConnectorRegistry } from '@nexus-cross/connect-kit-wagmi';
|
|
5
5
|
import { WalletId, CrossConnectKitConfig, OAuthPort, ThemeMode, ThemeTokens, ConnectKitEvent } from '@nexus-cross/connect-kit-core';
|
|
6
6
|
export { Account, ChainBalance, ColorOverrides, ConnectCancelStage, ConnectFailReason, ConnectKitEvent, ConnectKitEventName, ConnectionStatus, ConnectorType, CrossConnectKitConfig, ModalView, OnRampDisallowReason, OnRampEligibility, OnRampError, OnRampErrorCode, OnRampOpenParams, OnRampProviderId, OnRampSession, OnRampStatus, OnRampStatusEvent, Theme, ThemeMode, ThemeTokens, WalletDescriptor, WalletId, WalletState, formatBalance, formatWei } from '@nexus-cross/connect-kit-core';
|
|
7
|
-
import {
|
|
7
|
+
import { GetOneUsdProps, GetOneUsdPairs, GetOneUsdBridgeProps, GetOneUsdRelayProps, RelayWalletProps, WalletInfoProps, ConnectButtonStyle, WalletInfoStyle, RelayDepositProps, RelayDeposit, RelayHistoryProps, RelayHistory, RelayRecoveryProps, RelayRecovery, Environment, BridgeToken, BridgeHistoryItem, BridgeGetApprovalFn, BridgeApproveFn, BridgeQuoteFn, BridgeGetToTokensFn, BridgeSubmitFn, OnePopSummary } from '@nexus-cross/dapp-ui';
|
|
8
8
|
export { AppLauncher, AppLauncherContent, AppLauncherContentProps, AppLauncherProps, AppLauncherTrigger, AppLauncherTriggerProps, AppLauncherTriggerStyle, Catalog, ConnectButtonStyle, ConnectorId, DEFAULT_TRUSTED_FACTORIES, DepositAddressResult, GetOneUsdActionId, GetOneUsdEvent, GetOneUsdMode, GetOneUsdPairs, GetOneUsdTokenRef, GlobalMenu, GlobalMenuItem, GlobalMenuItemUrl, OrderSummary, OriginOption, QuoteResult, RecoveryInfo, RecoverySuccessResult, RelayApiError, RelayBalance, RelayClient, RelayClientOptions, RelayContractCall, RelayDrawerDirection, RelayHex, RelayRecoveryAction, RelayRecoveryQueryKey, RelayRecoveryQueryOptions, RelayRecoveryState, RelayRecoveryStep, RelayTheme, RelayTxRequest, RelayWalletProps, SendTransactionArgs, SendTransactionFn, SkillsButton, SkillsButtonProps, SkillsButtonStyle, UseRelayConfigOptions, UseRelayConfigResult, UseRelayOrdersOptions, UseRelayOrdersResult, UseRelayRecoveryOptions, UseRelayRecoveryResult, WalletInfo, WalletInfoContentProps, WalletInfoProps, WalletInfoStyle, WalletInfoTriggerProps, createRelayClient, useGlobalMenu, useRelayConfig, useRelayOrders, useRelayRecovery } from '@nexus-cross/dapp-ui';
|
|
9
9
|
import { Connector } from 'wagmi';
|
|
10
|
+
import { PopEnvironment } from '@nexus-cross/pop/api';
|
|
10
11
|
export { OnRampProvider, OnRampProviderProps, UseOnRampEligibilityOptions, UseOnRampEligibilityResult, UseOnRampOptions, UseOnRampResult, useOnRamp, useOnRampEligibility } from '@nexus-cross/onramp/react';
|
|
11
12
|
export { KycError, KycErrorCode, KycIdentity, KycLaunchTarget, KycLoginType, KycProvider, KycProviderProps, KycRejectType, KycStatus, KycVerificationHandle, KycVerificationMode, LaunchKycVerificationOptions, UseKycOptions, UseKycResult, launchKycVerification, useKyc, useOptionalKyc } from '@nexus-cross/kyc/react';
|
|
12
13
|
|
|
@@ -50,6 +51,22 @@ interface CrossConnectKitProviderProps {
|
|
|
50
51
|
}
|
|
51
52
|
declare function CrossConnectKitProvider({ children, config, initialState, extraWallets, walletAllowlist, }: CrossConnectKitProviderProps): react_jsx_runtime.JSX.Element;
|
|
52
53
|
|
|
54
|
+
type ManagedBridgeKey = "history" | "getQuote" | "getToTokens" | "getApproval" | "approveBridge" | "submitBridge";
|
|
55
|
+
type CrossGetOneUsdBridgeOptions = Omit<GetOneUsdBridgeProps, ManagedBridgeKey>;
|
|
56
|
+
type CrossGetOneUsdRelayProps = Omit<GetOneUsdRelayProps, keyof RelayWalletProps>;
|
|
57
|
+
interface CrossGetOneUsdProps extends Omit<GetOneUsdProps, "walletAddress" | "tokens" | "pairs" | "loading" | "bridge" | "relay"> {
|
|
58
|
+
/** Override the standard pairs resolved from remote contracts.json. */
|
|
59
|
+
pairs?: GetOneUsdPairs;
|
|
60
|
+
bridgeOptions?: CrossGetOneUsdBridgeOptions;
|
|
61
|
+
relay?: CrossGetOneUsdRelayProps;
|
|
62
|
+
restoreChainAfterSwitch?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Turn-key Get ONEUSD widget. CrossD quote/submit ports and Relay wallet
|
|
66
|
+
* capabilities are derived from the surrounding CrossConnectKitProvider.
|
|
67
|
+
*/
|
|
68
|
+
declare function CrossGetOneUsd({ env, pairs, bridgeOptions, relay, restoreChainAfterSwitch, waitForTransaction, onRequestConnect, ...props }: CrossGetOneUsdProps): react_jsx_runtime.JSX.Element;
|
|
69
|
+
|
|
53
70
|
/**
|
|
54
71
|
* ConnectButton이 사용하는 사용자 프로바이더 식별자.
|
|
55
72
|
* crossy-sdk의 OAuth 로그인(`google`/`apple`)과 실제 지갑 커넥터
|
|
@@ -127,6 +144,19 @@ interface ConnectButtonProps extends ForwardedWalletInfoProps {
|
|
|
127
144
|
* `window.opener.postMessage(...)` + `window.close()`로 메인 윈도우에 알림.
|
|
128
145
|
*/
|
|
129
146
|
onRampRedirectUrl?: string;
|
|
147
|
+
/**
|
|
148
|
+
* ONEpop 화면의 "Get ONEUSD ›"가 여는 Get ONEUSD 위젯 옵션.
|
|
149
|
+
*
|
|
150
|
+
* ONEpop 이 켜져 있으면 ConnectButton 이 `<CrossGetOneUsd mode="button">`을
|
|
151
|
+
* 자동으로 그 자리에 넣는다 — cross-game-swap 의 FAB 과 완전히 같은
|
|
152
|
+
* Swap / Bridge / Transfer 모달이다. 여기서는 그 위젯에 넘길 옵션만
|
|
153
|
+
* 덮어쓴다(예: 앱이 이미 쓰는 relay 클라이언트 공유, `onEvent` 텔레메트리).
|
|
154
|
+
* `env`/`theme`/트리거 모양은 ConnectButton 이 고정한다.
|
|
155
|
+
*
|
|
156
|
+
* 위젯 자체를 끄거나 통째로 바꾸려면 `onePopGetTokenSlot` 을 직접 넘긴다
|
|
157
|
+
* (`null` 이면 예전 게임토큰 브리지 딥링크로 되돌아간다).
|
|
158
|
+
*/
|
|
159
|
+
onePopGetTokenOptions?: Omit<CrossGetOneUsdProps, 'env' | 'theme' | 'mode' | 'buttonComponent'>;
|
|
130
160
|
}
|
|
131
161
|
/**
|
|
132
162
|
* `ConnectButton`은 내부에서 `WalletInfo`를 조립하지만, 호출측은 그 사실을
|
|
@@ -147,7 +177,7 @@ interface ConnectButtonProps extends ForwardedWalletInfoProps {
|
|
|
147
177
|
* Trigger 버튼(주소 옆 pill)은 호출측이 건드릴 수 없다 — 플랫폼 아이콘 + 축약
|
|
148
178
|
* 주소의 통일된 UX를 강제한다.
|
|
149
179
|
*/
|
|
150
|
-
declare function ConnectButton({ label, className, style, walletInfoStyle, user, enablePortfolio, portfolio, theme: themeProp, accountName: accountNameProp, connectorId: connectorIdProp, showPortfolio: showPortfolioProp, sendAccounts: sendAccountsProp, getTransactionReceipt: getTransactionReceiptProp, sendTransaction: sendTransactionProp, estimateGas: estimateGasProp, onDisconnect: onDisconnectProp, onSelectWallet: onSelectWalletProp, onBuy: onBuyProp, onRampRedirectUrl, bridgeTokens: bridgeTokensProp, bridgeHistory: bridgeHistoryProp, getBridgeQuote: getBridgeQuoteProp, getBridgeToTokens: getBridgeToTokensProp, getBridgeApproval: getBridgeApprovalProp, approveBridge: approveBridgeProp, submitBridge: submitBridgeProp, showBalance, env, ...walletInfoRest }: ConnectButtonProps): react_jsx_runtime.JSX.Element;
|
|
180
|
+
declare function ConnectButton({ label, className, style, walletInfoStyle, user, enablePortfolio, portfolio, theme: themeProp, accountName: accountNameProp, connectorId: connectorIdProp, showPortfolio: showPortfolioProp, sendAccounts: sendAccountsProp, getTransactionReceipt: getTransactionReceiptProp, sendTransaction: sendTransactionProp, estimateGas: estimateGasProp, onDisconnect: onDisconnectProp, onSelectWallet: onSelectWalletProp, onBuy: onBuyProp, onRampRedirectUrl, onePopSummary: onePopSummaryProp, onOnePopOpen: onOnePopOpenProp, onePopGetTokenSlot: onePopGetTokenSlotProp, onePopGetTokenOptions, showOnePop: showOnePopProp, bridgeTokens: bridgeTokensProp, bridgeHistory: bridgeHistoryProp, getBridgeQuote: getBridgeQuoteProp, getBridgeToTokens: getBridgeToTokensProp, getBridgeApproval: getBridgeApprovalProp, approveBridge: approveBridgeProp, submitBridge: submitBridgeProp, showBalance, env, ...walletInfoRest }: ConnectButtonProps): react_jsx_runtime.JSX.Element;
|
|
151
181
|
|
|
152
182
|
interface OtherWalletsModalProps {
|
|
153
183
|
open: boolean;
|
|
@@ -251,22 +281,6 @@ declare function CrossRelayDepositRoot(props: CrossRelayDepositProps): react_jsx
|
|
|
251
281
|
*/
|
|
252
282
|
declare const CrossRelayDeposit: typeof CrossRelayDepositRoot & Pick<typeof RelayDeposit, 'Trigger' | 'Content'>;
|
|
253
283
|
|
|
254
|
-
type ManagedBridgeKey = "history" | "getQuote" | "getToTokens" | "getApproval" | "approveBridge" | "submitBridge";
|
|
255
|
-
type CrossGetOneUsdBridgeOptions = Omit<GetOneUsdBridgeProps, ManagedBridgeKey>;
|
|
256
|
-
type CrossGetOneUsdRelayProps = Omit<GetOneUsdRelayProps, keyof RelayWalletProps>;
|
|
257
|
-
interface CrossGetOneUsdProps extends Omit<GetOneUsdProps, "walletAddress" | "tokens" | "pairs" | "loading" | "bridge" | "relay"> {
|
|
258
|
-
/** Override the standard pairs resolved from remote contracts.json. */
|
|
259
|
-
pairs?: GetOneUsdPairs;
|
|
260
|
-
bridgeOptions?: CrossGetOneUsdBridgeOptions;
|
|
261
|
-
relay?: CrossGetOneUsdRelayProps;
|
|
262
|
-
restoreChainAfterSwitch?: boolean;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Turn-key Get ONEUSD widget. CrossD quote/submit ports and Relay wallet
|
|
266
|
-
* capabilities are derived from the surrounding CrossConnectKitProvider.
|
|
267
|
-
*/
|
|
268
|
-
declare function CrossGetOneUsd({ env, pairs, bridgeOptions, relay, restoreChainAfterSwitch, waitForTransaction, onRequestConnect, ...props }: CrossGetOneUsdProps): react_jsx_runtime.JSX.Element;
|
|
269
|
-
|
|
270
284
|
/**
|
|
271
285
|
* Everything `<RelayHistory>` accepts except `walletAddress`, which comes from
|
|
272
286
|
* wagmi. `recipient` is still accepted and still wins — the history subject can
|
|
@@ -544,4 +558,48 @@ type CrossdBridgeAdapter = {
|
|
|
544
558
|
};
|
|
545
559
|
declare function useCrossdBridgeAdapter({ env, walletAddress, enabled, restoreChainAfterSwitch, }: CrossdBridgeAdapterOptions): CrossdBridgeAdapter;
|
|
546
560
|
|
|
547
|
-
|
|
561
|
+
declare const ONE_POP_SUMMARY_QUERY_KEY = "one-pop-summary";
|
|
562
|
+
/** 테스트/로그아웃 시 세션 토큰 폐기. */
|
|
563
|
+
declare function clearOnePopJwtCache(address?: string): void;
|
|
564
|
+
interface UseOnePopSummaryOptions {
|
|
565
|
+
/**
|
|
566
|
+
* true 가 되는 순간 조회를 시작한다(= SIWE 서명 요청). ONEpop 화면 진입
|
|
567
|
+
* 전에는 false 로 두어야 지갑 팝업이 뜨지 않는다.
|
|
568
|
+
*/
|
|
569
|
+
enabled?: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* ONEpop 배포 환경. `/drops` 는 ERC20 token 필터가 **필수**라, 여기서 환경별
|
|
572
|
+
* 배포 프로필의 ONEUSD(permitErc20) 주소를 고른다. 미지정 시 pop 의
|
|
573
|
+
* 환경변수 규칙(`resolvePopEnvironment`).
|
|
574
|
+
*/
|
|
575
|
+
environment?: PopEnvironment;
|
|
576
|
+
/**
|
|
577
|
+
* `/drops` 에 넘길 ERC20 token 주소 override. 지정하면 `environment` 기반
|
|
578
|
+
* 프로필 조회를 건너뛴다. 주소를 결정할 수 없으면(예: production 프로필
|
|
579
|
+
* 미공개) drops 조회를 생략하고 히스토리만으로 화면을 구성한다.
|
|
580
|
+
*/
|
|
581
|
+
token?: string;
|
|
582
|
+
/** one-pop-api base URL override. 미지정 시 pop 의 환경변수 규칙. */
|
|
583
|
+
apiBaseUrl?: string;
|
|
584
|
+
/** cross-auth base URL override. */
|
|
585
|
+
authBaseUrl?: string;
|
|
586
|
+
/**
|
|
587
|
+
* SIWE JWT 공급자 override. 지정하면 내장 서명 플로우를 쓰지 않는다 —
|
|
588
|
+
* 이미 플랫폼 토큰을 들고 있는 DApp 용.
|
|
589
|
+
*/
|
|
590
|
+
getJwt?: () => string | undefined | Promise<string | undefined>;
|
|
591
|
+
/**
|
|
592
|
+
* "N replies waiting" 배너 카운트. one-pop-api 에 대응 개념이 없어
|
|
593
|
+
* 조회하지 않는다 — 값을 아는 DApp 만 넘긴다. 기본 0(배너 미표기).
|
|
594
|
+
*/
|
|
595
|
+
repliesWaitingCount?: number;
|
|
596
|
+
}
|
|
597
|
+
interface UseOnePopSummaryResult {
|
|
598
|
+
summary: OnePopSummary | undefined;
|
|
599
|
+
isLoading: boolean;
|
|
600
|
+
error: Error | null;
|
|
601
|
+
refetch: () => void;
|
|
602
|
+
}
|
|
603
|
+
declare function useOnePopSummary(options?: UseOnePopSummaryOptions): UseOnePopSummaryResult;
|
|
604
|
+
|
|
605
|
+
export { ConnectButton, type ConnectButtonProps, type CrossConnectKitContextValue, CrossConnectKitProvider, type CrossConnectKitProviderProps, type CrossConnectKitThemeContextValue, CrossConnectModal, type CrossConnectModalProps, CrossGetOneUsd, type CrossGetOneUsdBridgeOptions, type CrossGetOneUsdProps, type CrossGetOneUsdRelayProps, CrossRelayDeposit, type CrossRelayDepositProps, CrossRelayHistory, type CrossRelayHistoryProps, CrossRelayRecovery, type CrossRelayRecoveryProps, type CrossxEmbeddedInfo, ONE_POP_SUMMARY_QUERY_KEY, OtherWalletsModal, type OtherWalletsModalProps, type UseOnePopSummaryOptions, type UseOnePopSummaryResult, type WalletProvider, type WalletUser, clearOnePopJwtCache, useConnectKitAnalytics, useCrossConnectKit, useCrossConnectKitTheme, useCrossdBridgeAdapter, useCrossxEmbeddedInfo, useOnePopSummary, useOptionalCrossConnectKitTheme, useRelayWalletProps };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-OZRWNMCO.js";export{C as AppLauncher,E as AppLauncherContent,D as AppLauncherTrigger,n as ConnectButton,O as ConnectionStatus,B as ConnectorId,e as CrossConnectKitProvider,d as CrossConnectModal,i as CrossGetOneUsd,h as CrossRelayDeposit,p as CrossRelayHistory,q as CrossRelayRecovery,J as DEFAULT_TRUSTED_FACTORIES,y as KycError,x as KycProvider,k as ONE_POP_SUMMARY_QUERY_KEY,N as OnRampError,u as OnRampProvider,o as OtherWalletsModal,I as RelayApiError,G as SkillsButton,A as WalletInfo,l as clearOnePopJwtCache,H as createRelayClient,P as formatBalance,Q as formatWei,z as launchKycVerification,r as useConnectKitAnalytics,a as useCrossConnectKit,b as useCrossConnectKitTheme,f as useCrossdBridgeAdapter,j as useCrossxEmbeddedInfo,F as useGlobalMenu,v as useKyc,s as useOnRamp,t as useOnRampEligibility,m as useOnePopSummary,c as useOptionalCrossConnectKitTheme,w as useOptionalKyc,K as useRelayConfig,L as useRelayOrders,M as useRelayRecovery,g as useRelayWalletProps};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cross/connect-kit-react",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.8",
|
|
4
4
|
"description": "React components and hooks for @nexus-cross/connect-kit wallet connection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nexus-cross/connect-kit-core": "1.4.0-beta.
|
|
28
|
-
"@nexus-cross/connect-kit-wagmi": "1.4.0-beta.
|
|
29
|
-
"@nexus-cross/crossx-design-system": "1.4.0-beta.
|
|
30
|
-
"@nexus-cross/dapp-ui": "1.4.0-beta.
|
|
31
|
-
"@nexus-cross/kyc": "1.4.0-beta.
|
|
32
|
-
"@nexus-cross/onramp": "1.4.0-beta.
|
|
27
|
+
"@nexus-cross/connect-kit-core": "1.4.0-beta.8",
|
|
28
|
+
"@nexus-cross/connect-kit-wagmi": "1.4.0-beta.8",
|
|
29
|
+
"@nexus-cross/crossx-design-system": "1.4.0-beta.8",
|
|
30
|
+
"@nexus-cross/dapp-ui": "1.4.0-beta.8",
|
|
31
|
+
"@nexus-cross/kyc": "1.4.0-beta.8",
|
|
32
|
+
"@nexus-cross/onramp": "1.4.0-beta.8",
|
|
33
|
+
"@nexus-cross/pop": "1.4.0-beta.8"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@tanstack/react-query": "^5.60.0",
|
package/dist/chunk-PEAZQ65Y.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
var gt="1.4.0-beta.6";var It="__nexusCrossAppLauncherRuntime";function yo(){if(typeof window>"u")return null;let e=window;return e[It]??(e[It]={mode:"dapp-ui"}),e[It]}function bo(e){if(e.scheduled)return;e.scheduled=!0;let t=()=>{if(e.scheduled=!1,e.loggedMode!==e.mode){if(e.mode==="connect-kit-react"){let n=e.connectKitVersion??gt;console.info(`[CROSSx App Launcher] connect-kit-react v${n} \uCD08\uAE30\uD654 \uC644\uB8CC (dapp-ui v${gt}, \uC0AC\uC6A9 \uBAA8\uB4DC: connect-kit)`)}else console.info(`[CROSSx App Launcher] dapp-ui v${gt} \uCD08\uAE30\uD654 \uC644\uB8CC (\uC0AC\uC6A9 \uBAA8\uB4DC: dapp-ui only)`);e.loggedMode=e.mode}};typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)}function an(){let e=yo();e&&(e.mode="connect-kit-react",e.connectKitVersion=gt,bo(e))}import{useCallback as _e,useEffect as oe,useMemo as We,useRef as be,useState as Qe}from"react";import{WagmiProvider as vo,useAccount as Po,useChainId as So,useConnect as Ro,useDisconnect as Ao,useSwitchChain as Bo}from"wagmi";import{QueryClient as _o,QueryClientProvider as Eo}from"@tanstack/react-query";import{clearWalletSessionStorage as mn,onOpenOtherWallets as Oo,pickInitialState as No,resolveCurrentWallet as Wo}from"@nexus-cross/connect-kit-wagmi";import{resolveThemeMode as Fo}from"@nexus-cross/connect-kit-core";import{buildDesignSystemCss as Do}from"@nexus-cross/crossx-design-system";import{OnRampProvider as Lo}from"@nexus-cross/onramp/react";import{KycProvider as Go}from"@nexus-cross/kyc/react";import{createContext as ho,useContext as wo}from"react";var Dt=ho(null);function Be(){let e=wo(Dt);if(!e)throw new Error("useCrossConnectKit must be used within <CrossConnectKitProvider>");return e}import{createContext as Co,useContext as cn}from"react";var xt=Co(null);function ko(){let e=cn(xt);if(!e)throw new Error("useCrossConnectKitTheme must be used within <CrossConnectKitProvider>");return e}function yt(){return cn(xt)}import{createContext as To}from"react";var vt=To(null);function dn(){let e=new Set,t=n=>{for(let i of[...e])try{i(n)}catch(o){console.debug("[crossx-kit] analytics handler threw",o)}};return{track:t,emit:n=>t({...n,timestamp:Date.now()}),subscribe:n=>(e.add(n),()=>{e.delete(n)})}}import{useCallback as Io,useMemo as ln}from"react";import{WalletConnectModal as un}from"@nexus-cross/dapp-ui";import{jsx as pn}from"react/jsx-runtime";var xo=new Set(["cross_wallet","cross_extension","metamask","binance"]);function Lt({open:e,onOpenChange:t}){let{connect:n,availableWallets:i,oauth:o,extraWallets:c,walletAllowlist:g,kitConfig:y}=Be(),r=yt()?.mode??"dark",m=ln(()=>{let p=g?new Set(g):null,k={};for(let x of i){if(!xo.has(x.walletId)||p&&!p.has(x.walletId))continue;let v=x.walletId;k[v]=()=>{n(x.walletId)}}for(let[x,v]of Object.entries(c))v&&(p&&!p.has(x)||(k[x]=v));return k},[i,n,c,g]),h=ln(()=>{if(o)return{apple:()=>{o.signIn("apple")},google:()=>{o.signIn("google")}}},[o]),C=Io(p=>t(p),[t]);return pn(un,{wallets:m,socialProviders:h,termsUrl:y.legal?.termsUrl,privacyUrl:y.legal?.privacyUrl,theme:r,open:e,onOpenChange:C,children:pn(un.Content,{})})}import{jsx as ze,jsxs as yn}from"react/jsx-runtime";var Mo=new _o,Gt="crossx-kit:last-wallet-intent",Uo=15e3,Ko=1500,$o=3;function fn(e,t){return Promise.race([e.then(()=>{},()=>{}),new Promise(n=>setTimeout(n,t))])}function qo(e){let t=[],n=e,i=0;for(;n&&i<5;){let o=n;typeof o.message=="string"&&t.push(o.message),n=o.cause,i+=1}return t.some(o=>/external wallet connection/i.test(o))}function Ho(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Gt)??null}catch{return null}}function gn(e){if(!(typeof window>"u"))try{e?window.localStorage.setItem(Gt,e):window.localStorage.removeItem(Gt)}catch{}}function Vo(e,t){if(typeof window>"u")return t;try{let n=window.localStorage.getItem(e);return n==="cross"||n==="reown"?n:t}catch{return t}}function jo(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function Qo({children:e,config:t,activeProvider:n,onRequestProviderSwap:i,pendingConnectWalletId:o,clearPending:c,themeMode:g,themeTokens:y,extraWallets:u,walletAllowlist:r,emit:m}){let[h,C]=Qe(!1),[p,k]=Qe(()=>Ho()),[x,v]=Qe(null),{address:W,isConnected:I,isConnecting:U,isReconnecting:D,connector:O}=Po(),{connectors:q,connectAsync:$}=Ro(),{disconnectAsync:z}=Ao(),{kitConfig:L,connectorRegistry:K,crossProvider:Re,reownProvider:de}=t,N=n==="cross"?Re:de,A=We(()=>!I||!O?null:Wo(K,O.id,p),[I,O,K,p]),Y=We(()=>K.entries.filter(l=>l.type!=="embedded"),[K]),V=_e(l=>K.getEntry(l)?.type??"external",[K]),ce=be(null);ce.current=x;let Ie=be(A);Ie.current=A;let qe=be(W);qe.current=W;let Oe=L.embeddedProjectId?.trim()||L.crossProjectId?.trim(),xe=!!L.onRampEnabled&&!!Oe,He=We(()=>!xe||!Oe?null:{projectId:Oe,walletState:{getAddress:()=>qe.current}},[xe,Oe]),we=be(O);we.current=O;let le=L.embeddedProjectId?.trim()||L.crossProjectId?.trim(),Ge=!!L.kycEnabled&&!!le,et=We(()=>!Ge||!le?null:{projectId:le,getAccessToken:async()=>{let l=we.current;if(!(!l||typeof l.getProvider!="function"))try{return(await(await l.getProvider())?.sdk?.getUserInfo?.())?.data?.accessToken||void 0}catch{return}}},[Ge,le]);oe(()=>Oo(()=>C(!0)),[]),oe(()=>{if(!h||typeof document>"u")return;let l=setTimeout(()=>{document.querySelectorAll("#__crossx-confirm-overlay").forEach(b=>b.remove())},50);return()=>clearTimeout(l)},[h]);let ye=be(I),ct=be(I);ye.current=I;let tt=be(!1);oe(()=>{console.debug("[crossx-kit] state",{activeProvider:n,isConnected:I,isConnecting:U,isReconnecting:D,activeConnectorId:O?.id,currentWallet:A,lastIntent:p})},[n,I,U,D,O?.id,A,p]),oe(()=>{I&&!ct.current&&N?.closeModal?.({kitConfig:L}),ct.current=I},[I,N,L]),oe(()=>{I&&v(null)},[I]);let Ae=So(),{switchChainAsync:ve}=Bo(),ue=be(null);oe(()=>{if(!L.enforceDefaultNetworkOnConnect)return;let l=L.defaultNetwork?.id;if(!l)return;if(!I||!W||!O){ue.current=null;return}let b=`${O.id}:${W}`;ue.current!==b&&(ue.current=b,Ae!==l&&ve({chainId:l}).catch(()=>{}))},[L.enforceDefaultNetworkOnConnect,L.defaultNetwork,I,W,O,Ae,ve]);let Me=be(h);oe(()=>{h&&!Me.current?m({name:"connect_modal_opened"}):!h&&Me.current&&m({name:"connect_modal_closed",completed:ye.current}),Me.current=h},[h,m]);let dt=be(I);oe(()=>{if(I&&!dt.current){let l=ce.current;l&&m({name:"connect_succeeded",walletId:l,walletType:V(l),chainId:Ae})}dt.current=I},[I,Ae,m,V]);let s=_e(l=>q.find(b=>b.id===l),[q]);oe(()=>{let l=K.getEntry("cross_embedded");if(!l)return;let b=s(l.connectorId);if(!b)return;let T=!1;return(async()=>{try{let P=await b.getProvider();if(T)return;P?.sdk?.applyTheme?.(g,y??void 0)}catch(P){console.debug("[crossx-kit] applyTheme skipped:",P)}})(),()=>{T=!0}},[K,s,g,y]);let a=_e(l=>{k(l),gn(l)},[]),d=_e(()=>{k(null),gn(null),v(null)},[]);oe(()=>{if(!N?.subscribeModalState)return;let l=!1;return N.subscribeModalState({kitConfig:L},b=>{if(tt.current=b,b){l=!0;return}l&&(l=!1,setTimeout(()=>{if(ye.current)return;let T=ce.current;T&&m({name:"connect_cancelled",walletId:T,stage:"popup"}),(async()=>{try{await z()}catch{}d()})()},250))})},[N,L,z,d,m]),oe(()=>{if(!x||I||typeof window>"u"||x==="cross_embedded")return;let l=typeof document<"u"&&!document.hasFocus(),b=null,T=()=>{l=!0},P=()=>{l&&(b&&clearTimeout(b),b=setTimeout(()=>{if(ye.current||tt.current)return;let B=ce.current;B&&m({name:"connect_cancelled",walletId:B,stage:"popup"}),(async()=>{try{await z()}catch{}d()})()},1e3))};return window.addEventListener("blur",T),window.addEventListener("focus",P),()=>{window.removeEventListener("blur",T),window.removeEventListener("focus",P),b&&clearTimeout(b)}},[x,I,z,d,m]);let f=_e(async l=>{console.debug("[crossx-kit] runConnect enter",{walletId:l,activeProvider:n,isConnected:I,activeConnectorId:O?.id});let b=K.getEntry(l);if(!b){if((l==="metamask"||l==="binance")&&!de){console.error(`[crossx-kit] "${l}" requires the Reown adapter, but it is not configured. Pass \`reownProjectId\` (and ensure \`reown\` is not set to \`false\`) when calling createConnectKitConfig() or createCrossxConfig() to enable WalletConnect-based wallets.`);return}console.error(`[crossx-kit] Unknown walletId: "${l}"`);return}if(v(l),b.providerKind!==n){console.debug("[crossx-kit] provider swap needed",{from:n,to:b.providerKind,walletId:l}),a(l);try{await z()}catch{}await new Promise(B=>setTimeout(B,0)),i(b.providerKind,l);return}let T=V(l);if(m({name:"wallet_selected",walletId:l,walletType:T}),m({name:"connect_started",walletId:l,walletType:T}),a(l),N?.beforeConnect)try{let B=await N.beforeConnect({kitConfig:L,themeMode:g},l);if(console.debug("[crossx-kit] beforeConnect result",{walletId:l,result:B}),B==="handled")return}catch(B){console.warn('[crossx-kit] adapter.beforeConnect threw for "%s":',l,B)}let P=s(b.connectorId);if(console.debug("[crossx-kit] findConnector",{lookupId:b.connectorId,found:P?.id,availableIds:q.map(B=>B.id)}),!P){console.error(`[crossx-kit] Connector "${b.connectorId}" not found on provider "${b.providerKind}". Available: ${q.map(B=>B.id).join(", ")}`),m({name:"connect_failed",walletId:l,reason:"connector_not_found"}),d();return}try{console.debug("[crossx-kit] connectAsync start",{connectorId:P.id});let B=await $({connector:P});console.debug("[crossx-kit] connectAsync resolved",{accountsLen:B.accounts.length,chainId:B.chainId});return}catch(B){let pe=qo(B);if(!pe){console.error('[crossx-kit] connectAsync error for "%s":',l,B);try{await z()}catch{}}if(!b.fallbackConnectorId){pe||m({name:"connect_failed",walletId:l,reason:"connector_error"}),d();return}}if(b.fallbackConnectorId){let B=s(b.fallbackConnectorId);if(B)try{await $({connector:B})}catch(pe){console.error('[crossx-kit] Fallback connect failed for "%s":',l,pe);try{await z()}catch{}m({name:"connect_failed",walletId:l,reason:"fallback_failed"}),d()}else m({name:"connect_failed",walletId:l,reason:"fallback_failed"}),d()}},[K,q,s,$,z,a,d,N,n,L,i,g,m,V]);oe(()=>{if(!o)return;let l=o;c(),f(l)},[o,n]);let w=_e(async()=>{C(!0)},[]),_=_e(async()=>{m({name:"disconnected",walletId:Ie.current});try{await z()}catch(l){console.error("[crossx-kit] wagmi disconnect error:",l)}if(N?.teardown)try{await N.teardown({kitConfig:L})}catch(l){console.error("[crossx-kit] adapter teardown error:",l)}mn(),d()},[z,N,L,d,m]),E=_e(async()=>{await fn(z(),3e3);try{let l=K.getEntry("cross_embedded"),b=l&&s(l.connectorId);if(b?.getProvider){let T=await Promise.race([b.getProvider(),new Promise(B=>setTimeout(B,3e3))]),P=T?.sdk?.signOut;typeof P=="function"&&await fn(P.call(T.sdk),3e3)}}catch{}mn()},[K,s,z]),R=_e(async()=>{let l=K.getEntry("cross_embedded");if(!l)return null;let b=s(l.connectorId);if(!b)return null;try{let T=await b.getProvider(),P=T?.sdk;if(!P?.selectWallet)return null;let B=await P.selectWallet(P.currentAddress??void 0);return B?.address&&T.notifyAccountsChanged&&T.notifyAccountsChanged([B.address]),B&&m({name:"wallet_switched",index:B.index}),B}catch{return null}},[K,s,m]),G=We(()=>{let l=t.oauth;return l?{signIn:async b=>{v("cross_embedded"),m({name:"wallet_selected",walletId:"cross_embedded",walletType:"embedded"}),m({name:"connect_started",walletId:"cross_embedded",walletType:"embedded"});try{await l.signIn(b)}catch(T){throw m({name:"connect_cancelled",walletId:"cross_embedded",stage:"popup"}),v(null),T}}}:null},[t.oauth,m]),Z=be(!1);oe(()=>{if(n!=="cross"||I||U||D||x!=null||Z.current)return;let l=K.getEntry("cross_embedded");if(!l)return;let b=s(l.connectorId);if(!b)return;Z.current=!0;let T=!1;return(async()=>{try{let P=await b.isAuthorized?.();if(T||!P)return;await $({connector:b})}catch{}})(),()=>{T=!0}},[n,I,U,D,x,K,s,$]);let S=be(0);oe(()=>{if(n!=="cross"||I||!U&&!D||S.current>=$o)return;let l=K.getEntry("cross_embedded");if(!l)return;let b=s(l.connectorId);if(!b)return;let T=!1,P=setInterval(()=>{(async()=>{if(T||ye.current)return;let B=await Promise.resolve(b.isAuthorized?.()).catch(()=>!1);if(!(T||!B||ye.current)){S.current+=1,console.warn("[crossx-kit] wagmi reconnect stalled while the SDK holds a session \u2014 forcing an explicit connect to realign");try{await $({connector:b})}catch{}}})()},Ko);return()=>{T=!0,clearInterval(P)}},[n,I,U,D,K,s,$]),oe(()=>{if(x!=="cross_embedded"||I||typeof window>"u")return;let l=!document.hasFocus(),b=()=>{l=!0};window.addEventListener("blur",b);let T=setTimeout(()=>{ye.current||l||(console.warn("[crossx-kit] embedded sign-in stalled before the OAuth popup opened \u2014 clearing the stale session so a retry starts clean"),m({name:"connect_cancelled",walletId:"cross_embedded",stage:"stalled"}),d(),E())},Uo);return()=>{window.removeEventListener("blur",b),clearTimeout(T)}},[x,I,d,E,m]);let F=x!=null&&!I,j=We(()=>({kitConfig:L,connectorRegistry:K,availableWallets:Y,connect:f,connectWallet:w,disconnect:_,selectWallet:R,currentWallet:A,lastIntent:p,isConnecting:F,connectingWalletId:x,openOtherWallets:()=>C(!0),closeOtherWallets:()=>C(!1),otherWalletsOpen:h,oauth:G,extraWallets:u,walletAllowlist:r,onRampEnabled:xe}),[L,K,Y,f,w,_,R,A,p,F,x,h,G,u,r,xe]),H=yn(Dt.Provider,{value:j,children:[e,ze(Lt,{open:h,onOpenChange:C})]});return et&&(H=ze(Go,{config:et,children:H})),He&&(H=ze(Lo,{config:He,children:H})),H}var zo=[/Connection interrupted while trying to subscribe/i,/No matching key\. subscription:/i,/Proposal expired/i];function Xo(e){let t=e?.message;return typeof t!="string"?!1:zo.some(n=>n.test(t))}var Yo={};function Zo(e){return e&&{...e,connections:new Map,current:null}}function Jo({children:e,config:t,initialState:n,extraWallets:i=Yo,walletAllowlist:o}){let[c,g]=Qe(()=>Vo(t.activeProviderStorageKey,t.defaultProvider)),[y,u]=Qe(null),r=be(!1),m=be(null);m.current||(m.current=dn());let h=m.current,C=We(()=>({subscribe:h.subscribe}),[h]),{kitConfig:p}=t,[k,x]=Qe(null),[v,W]=Qe(null),[I,U]=Qe(0),D=We(()=>Fo(p.theme,p.autoDetectTheme),[p.theme,p.autoDetectTheme,I]),O=k??D,q=v??p.themeTokens;oe(()=>{if(!p.autoDetectTheme||k||typeof window>"u"||!window.matchMedia)return;let A=window.matchMedia("(prefers-color-scheme: dark)"),Y=()=>U(V=>V+1);try{return A.addEventListener("change",Y),()=>A.removeEventListener("change",Y)}catch{return A.addListener(Y),()=>A.removeListener(Y)}},[p.autoDetectTheme,k]),oe(()=>{if(typeof document>"u")return;let A=document.documentElement,Y=A.getAttribute("data-ds-theme"),V=A.getAttribute("data-theme");return A.setAttribute("data-ds-theme",O),V||A.setAttribute("data-theme",O),()=>{Y==null?A.removeAttribute("data-ds-theme"):A.setAttribute("data-ds-theme",Y),V==null&&A.removeAttribute("data-theme")}},[O]);let $=We(()=>Do(t.designSystem),[t.designSystem]),z=We(()=>({mode:O,tokens:q,setThemeMode:A=>x(A),setThemeTokens:A=>W(A)}),[O,q]);oe(()=>{if(typeof window>"u")return;let A=Y=>{Xo(Y.reason)&&Y.preventDefault()};return window.addEventListener("unhandledrejection",A),()=>window.removeEventListener("unhandledrejection",A)},[]);let L=_e((A,Y)=>{r.current||(r.current=!0,u(Y),g(A),jo(t.activeProviderStorageKey,A),queueMicrotask(()=>{r.current=!1}))},[t.activeProviderStorageKey]),K=_e(()=>u(null),[]),Re=c==="cross"?t.crossWagmiConfig:t.reownWagmiConfig,de=Zo(No(n,c));if(!Re){if(!(c==="cross"?t.reownWagmiConfig:t.crossWagmiConfig))throw new Error("[crossx-kit] createCrossxConfig returned no wagmi Config for either side");let Y=c==="cross"?"reown":"cross";queueMicrotask(()=>g(Y))}let N=Re??(c==="cross"?t.reownWagmiConfig:t.crossWagmiConfig);return ze(vt.Provider,{value:C,children:yn(xt.Provider,{value:z,children:[ze("style",{"data-crossx-design-system":"",children:$}),ze(vo,{config:N,initialState:de,children:ze(Eo,{client:Mo,children:ze(Qo,{config:t,activeProvider:c,onRequestProviderSwap:L,pendingConnectWalletId:y,clearPending:K,themeMode:O,themeTokens:q,extraWallets:i,walletAllowlist:o??t.kitConfig.wallets??null,emit:h.emit,children:e})})},c)]})})}import{useCallback as Ze,useEffect as rs,useMemo as Et}from"react";import{useQueryClient as ss}from"@tanstack/react-query";import{useAccount as is,useChainId as as,useConfig as cs,useSendTransaction as ds,useSwitchChain as ls}from"wagmi";import{getPublicClient as Vt,readContracts as Kn}from"wagmi/actions";import{WalletInfo as jt,ConnectorId as Je,resolveEnvironment as us,WALLET_REGISTRY as ps}from"@nexus-cross/dapp-ui";import{useOptionalOnRamp as ms,useOptionalOnRampEligibility as fs}from"@nexus-cross/onramp/react";import{APPLE_ICON as Yt,BINANCE_ICON as Hn,CROSSX_ICON as Xt,EXTENSION_ICON as gs,GOOGLE_ICON as Vn,METAMASK_ICON as jn}from"@nexus-cross/connect-kit-wagmi";import{WALLET_LABELS as kt}from"@nexus-cross/crossx-design-system";import{useCallback as re,useMemo as Te,useRef as er}from"react";import{useQueries as wn,useQuery as Xe}from"@tanstack/react-query";import{encodeFunctionData as bt,formatUnits as _t,parseSignature as tr,parseUnits as nr}from"viem";import{getChainId as Mt,getPublicClient as On,readContract as Ee,signTypedData as or,switchChain as Cn,waitForTransactionReceipt as rr,writeContract as kn}from"wagmi/actions";import{useConfig as sr}from"wagmi";async function Pt(e,t,n){if(!(!n||t===void 0))try{if(e.getChainId()===t)return;await e.switchChain(t)}catch{}}var ut=10000n;function bn(e){let t=e==="auto"?1:Number(e||"1");return!Number.isFinite(t)||t<0?100n:BigInt(Math.min(1e4,Math.floor(t*100)))}function St(e,t){let n=bn(t);return n>=ut?0n:e*(ut-n)/ut}function hn(e,t){let n=bn(t);return(e*(ut+n)+(ut-1n))/ut}function ir(e){return e!=="bridge"}var $e="0x0000000000000000000000000000000000000000",Se=100,mt=18,ar=180000n,cr=500000n,Nn=new Set([56,97]),dr=130n,lr=100n,ur={dev:"https://stg-contents.crosstoken.io/frontend/game-token/json/hidden-path.json",stage:"https://stg-contents.crosstoken.io/frontend/game-token/json/hidden-path.json",production:"https://contents.crosstoken.io/frontend/game-token/json/hidden-path.json"},pr={dev:"dev",stage:"stg",production:"prod"};function mr(e,t){let n=e?.[pr[t]]?.hiddenPairs;if(!Array.isArray(n))return null;let i=n.filter(o=>!!o&&typeof o=="object"&&typeof o.fromKey=="string"&&typeof o.toKey=="string");return i.length>0?i:null}var fr={dev:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/contracts.json",stage:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/contracts.json",production:"https://contents.crosstoken.io/frontend/common/app-launcher/contracts.json"},gr=["BSC_CROSS","W_CROSS","NATIVE_CROSS","USDTX","CROSSD","USDTB","SWAP_BRIDGE_ROUTER"],yr={BSC_CROSS:$e,W_CROSS:$e,NATIVE_CROSS:$e,USDTX:$e,CROSSD:$e,USDTB:$e,SWAP_BRIDGE_ROUTER:$e},br=/^0x[0-9a-fA-F]{40}$/;function hr(e,t){let n=typeof e=="string"?e:e?.[t];return typeof n=="string"&&br.test(n)?n:null}function wr(e,t){if(!e?.bridge)return null;let n=e.envToNetwork?.[t]??(t==="production"?"mainnet":"testnet"),i={};for(let o of gr){let c=hr(e.bridge[o],n);if(!c)return null;i[o]=c}return i}var Cr={dev:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97}},stage:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97}},production:{bridgeApi:"https://bridge-api.crosstoken.io/bridge",walletApi:"https://wallet-server.crosstoken.io/api",chainIds:{cross:612055,bsc:56}}},rt=[{type:"function",name:"quoter",stateMutability:"view",inputs:[],outputs:[{name:"",type:"address"}]},{type:"function",name:"swapRouter",stateMutability:"view",inputs:[],outputs:[{name:"",type:"address"}]},{type:"function",name:"getAmountSwapBridgeOut",stateMutability:"view",inputs:[{name:"toChainID",type:"uint256"},{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountIn",type:"uint256"}],outputs:[{name:"ok",type:"bool"},{name:"swapAmountOut",type:"uint256"},{name:"bridgeValue",type:"uint256"},{name:"networkFee",type:"uint256"},{name:"exFee",type:"uint256"}]},{type:"function",name:"getAmountSwapBridgeIn",stateMutability:"view",inputs:[{name:"toChainID",type:"uint256"},{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"bridgeValue",type:"uint256"}],outputs:[{name:"ok",type:"bool"},{name:"amountIn",type:"uint256"},{name:"swapAmountOut",type:"uint256"},{name:"networkFee",type:"uint256"},{name:"exFee",type:"uint256"}]},{type:"function",name:"swapBridgeExactInputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountIn",type:"uint256"},{name:"amountOutMinimum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"bridgeParams",type:"tuple",components:[{name:"toChainID",type:"uint256"},{name:"recipient",type:"address"},{name:"extraData",type:"bytes"}]}]},{name:"deadline",type:"uint256"}],outputs:[{name:"amountOut",type:"uint256"}]},{type:"function",name:"swapBridgeExactOutputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountOut",type:"uint256"},{name:"amountInMaximum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"bridgeParams",type:"tuple",components:[{name:"toChainID",type:"uint256"},{name:"recipient",type:"address"},{name:"extraData",type:"bytes"}]}]},{name:"deadline",type:"uint256"}],outputs:[{name:"amountIn",type:"uint256"}]}],Ut=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Tn=[{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{name:"",type:"string"}]},{type:"function",name:"nonces",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"",type:"uint256"}]}],In=[{type:"function",name:"quoteExactInputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amountIn",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountOut",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}]},{type:"function",name:"quoteExactOutputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amount",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountIn",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}]}],kr=[{type:"function",name:"slot0",stateMutability:"view",inputs:[],outputs:[{name:"sqrtPriceX96",type:"uint160"},{name:"tick",type:"int24"},{name:"observationIndex",type:"uint16"},{name:"observationCardinality",type:"uint16"},{name:"observationCardinalityNext",type:"uint16"},{name:"feeProtocol",type:"uint8"},{name:"unlocked",type:"bool"}]}],Ue=[{type:"function",name:"exactInputSingle",stateMutability:"payable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"recipient",type:"address"},{name:"deadline",type:"uint256"},{name:"amountIn",type:"uint256"},{name:"amountOutMinimum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountOut",type:"uint256"}]},{type:"function",name:"multicall",stateMutability:"payable",inputs:[{name:"data",type:"bytes[]"}],outputs:[{name:"results",type:"bytes[]"}]},{type:"function",name:"unwrapWETH9",stateMutability:"payable",inputs:[{name:"amountMinimum",type:"uint256"},{name:"recipient",type:"address"}],outputs:[]},{type:"function",name:"refundETH",stateMutability:"payable",inputs:[],outputs:[]}],Tr=[{type:"function",name:"bridgeToken",stateMutability:"payable",inputs:[{name:"toChainID",type:"uint256"},{name:"fromToken",type:"address"},{name:"to",type:"address"},{name:"value",type:"uint256"},{name:"gasFee",type:"uint256"},{name:"exFee",type:"uint256"},{name:"extraData",type:"bytes"}],outputs:[{name:"",type:"bool"}]}];async function Wn(e){let t="";try{t=await e.text()}catch{}if(t){try{let n=JSON.parse(t),i=typeof n.data=="string"&&n.data||typeof n.message=="string"&&n.message||"";if(i)return`${i} (status ${e.status})`}catch{}return`${t.slice(0,300)} (status ${e.status})`}return`status ${e.status}`}async function Fe(e,t){let n=await fetch(e,{cache:"no-store",signal:t});if(!n.ok)throw new Error(`CrossD bridge adapter request failed: ${await Wn(n)}`);let i=await n.json();if(i&&typeof i=="object"&&"code"in i&&typeof i.code=="number"&&i.code!==200)throw new Error(i.message||`CrossD bridge adapter API error: ${i.code}`);return i&&typeof i=="object"&&"data"in i?i.data:i}async function xn(e,t,n){let i=await fetch(e,{method:"POST",cache:"no-store",signal:n,headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!i.ok)throw new Error(`CrossD bridge adapter request failed: ${await Wn(i)}`);let o=await i.json();if(o&&typeof o=="object"&&"code"in o&&typeof o.code=="number"&&o.code!==200)throw new Error(o.message||`CrossD bridge adapter API error: ${o.code}`);return o&&typeof o=="object"&&"data"in o?o.data:o}function Ir(e){return new Promise(t=>setTimeout(t,e))}async function xr(e,t,{attempts:n=60,intervalMs:i=2e3}={}){for(let o=0;o<n;o+=1){try{let c=await Fe(`${e}/permit-hash/${t}`);if(qt(c))return c}catch{}await Ir(i)}return null}function ie(e,t){return`${e}-${t.toLowerCase()}`}function fe(e){return ie(e.chainId,e.address)}function De(e){return e==="swap"||e==="deposit-swap"||e==="swap-withdraw"}function vr(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"",n=t.toLowerCase();return n.includes("quoteexactinputsingle")||n.includes("quoteexactoutputsingle")||n.includes("getamountswapbridgeout")||n.includes("getamountswapbridgein")||n.includes("execution reverted")?"Amount is too large for this route.":t.split(`
|
|
2
|
-
`)[0]?.trim()||"Failed to quote bridge."}function vn(e){return e===56||e===97?"BSC":e===612044||e===612055?"ONEchain":`Chain ${e}`}function se(e,t){return t?t.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()?e.contracts.W_CROSS:t:$e}function st(e){let t=_t(e,mt);return t.includes(".")?t.replace(/\.?0+$/,""):t}function wt(e){return nr(e||"0",mt)}function he(e){try{return wt(e||"0")}catch{return 0n}}function Ye(e){if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(Math.trunc(e));if(!e)return 0n;try{return BigInt(e)}catch{return 0n}}function Kt(e){let t=_t(e,9);return(t.includes(".")?t.replace(/\.?0+$/,""):t)||"0"}function Rt(e){return e==="bridge"?ar:cr}function Pn(e,t){if(!e||!t)return"0";let n=e*e;if(n===0n)return"0";let i=t*t,o=i>n?i-n:n-i;if(o===0n)return"0";let c=(o*100000000n+n/2n)/n;if(c>=100000000n)return"100";let g=c/1000000n,y=(c%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return y?`${g}.${y}`:`${g}`}function Pr(e){if(!e||Number(e)===0)return"0%";let[t,n=""]=e.split("."),i=n.length>4?n.slice(0,4):n;return i?`${t}.${i}%`:`${t}%`}async function Sn(e,t,n,i,o,c=!1){let g=On(e,{chainId:t}),y=n;try{let r=await g?.estimateContractGas?.({account:o.account,address:o.address,abi:o.abi,functionName:o.functionName,args:o.args,value:o.value});typeof r=="bigint"&&r>0n&&(y=i?r*dr/lr:r)}catch{}let u={gas:y};if(Nn.has(t))try{let r=await g?.getGasPrice?.();typeof r=="bigint"&&r>0n&&(u.gasPrice=r)}catch{}else if(c)try{let r=await g?.estimateFeesPerGas?.();typeof r?.maxFeePerGas=="bigint"&&(u.maxFeePerGas=r.maxFeePerGas),typeof r?.maxPriorityFeePerGas=="bigint"&&(u.maxPriorityFeePerGas=r.maxPriorityFeePerGas)}catch{}return u}function ht(){return BigInt(Math.floor(Date.now()/1e3)+1800)}var Sr={100:"0.01%",500:"0.05%",3e3:"0.3%",1e4:"1%"};function Rr(e){return Sr[e]??`${e/1e4}%`}function Ar(e,t){let n=Number(e||"0");return!Number.isFinite(n)||n<=0?"0":(n*t/1e6).toFixed(8).replace(/\.?0+$/,"")}function Rn(e){return st(e)}function An(e,t){let n=Number(t??"0");return!Number.isFinite(n)||n<=0?0n:e*BigInt(Math.floor(n))/1000n}function At(e,t){if(!e)return!1;let n=e.toLowerCase();return t.some(i=>i.toLowerCase()===n)}function Br(e,t,n){return[{from:[e.contracts.USDTX],to:[e.contracts.CROSSD]},{from:[e.contracts.BSC_CROSS],to:[e.contracts.NATIVE_CROSS,e.contracts.W_CROSS]},{from:[e.contracts.NATIVE_CROSS,e.contracts.W_CROSS],to:[e.contracts.CROSSD]}].some(o=>At(t,o.from)&&At(n,o.to)||At(t,o.to)&&At(n,o.from))}function _r(e){if(De(e.type))return null;if(e.type==="swap-bridge"){let t=e.steps.find(n=>n.type==="bridge");return t?{from:t.fromChain,to:t.toChain,token:t.fromToken}:null}if(e.type==="bridge-swap"){let t=e.steps.find(n=>n.type==="bridge");return t?{from:t.fromChain,to:t.toChain,token:t.fromToken}:null}return{from:e.from.chainId,to:e.to.chainId,token:e.from.address}}function Er({input:e,path:t,config:n}){if(!n||De(t.type))return"";let i=Ye(n.minimumValue),o=Ye(n.gasFee??n.gas_fee),c=t.type==="swap-bridge"?i+o*12n/10n:i;return c<=0n?"":e.fromAmount&&he(e.fromAmount)<c&&t.type!=="swap"?`Minimum ${Rn(c)}`:t.type==="swap-bridge"&&e.toAmount&&he(e.toAmount)<c?`Available ${Rn(c)} or more.`:""}function Or({input:e,path:t,config:n}){if(!n||t.type!=="bridge"&&t.type!=="bridge-swap")return"";let i=Ye(n.gasFee??n.gas_fee);if(i<=0n||!e.fromAmount)return"";let o=he(e.fromToken.balance||"0"),c=he(e.fromAmount);return o-i<c?`Insufficient network fee(${e.fromToken.symbol})`:""}function Nr(e,t){let n=new Set;return e?.list?.forEach(i=>{let o=i.localChain??i.local_chain;o&&Object.entries(i.pairs||{}).forEach(([c,g])=>{g.forEach(y=>{y.localToken&&n.add(ie(o,y.localToken)),y.remoteToken&&n.add(ie(Number(c),y.remoteToken))})})}),Object.entries(t?.swapPools||t?.swap_pools||{}).forEach(([i,o])=>{o.forEach(c=>{c.token0&&n.add(ie(Number(i),c.token0)),c.token1&&n.add(ie(Number(i),c.token1))})}),n}function Wr(e,t){return!e||!t?null:ie(e,t)}function Fr({envConfig:e,bridgePairList:t,swapPools:n,tokenInfo:i,tokenStats:o}){let c=Nr(t,n),g=new Map;o?.forEach(u=>{let r=Wr(Number(u.chainId??u.chain_id),u.address);r&&g.set(r,u)});let y={};return c.forEach(u=>{let[r,m]=u.split("-"),h=Number(r),C=i?.find(k=>Number(k.chainId??k.chain_id)===h&&k.address?.toLowerCase()===m);if(!C?.symbol||!C.name)return;let p=g.get(u);y[u]={key:u,chainId:h,address:m,symbol:C.symbol,name:C.name,decimals:C.decimals||mt,image:C.image||C.icon_url,price:p?.price?Number(p.price):void 0,isNativeToken:m.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()}}),y}function Fn(e,t){return t?.list?.find(n=>(n.localChain??n.local_chain)===e)?.bridge||""}function Dn(e,t,n){let[i,o]=e.split("-"),[c,g]=t.split("-"),y=Number(i),u=Number(c);for(let r of n?.list||[]){if((r.localChain??r.local_chain)!==y)continue;let m=r.pairs?.[c];if(m){for(let h of m)if(h.localToken?.toLowerCase()===o&&h.remoteToken?.toLowerCase()===g)return{type:"bridge",fromChain:y,fromToken:o,toChain:u,toToken:g,bridgeAddress:Fn(y,n)}}}return null}function Ln(e,t,n,i){let o,c=1/0;for(let g of e||[]){let y=i(g.token0),u=i(g.token1);if(y===t&&u===n||u===t&&y===n){let r=g.fee??Se;r<c&&(o=g,c=r)}}return o?{fee:c,poolAddress:o.poolAddress||o.pool_address||""}:null}function Gn(e,t,n,i){let[o,c]=e.split("-"),[g,y]=t.split("-");if(o!==g)return null;let u=Number(o),r=(n?.swapPools||n?.swap_pools)?.[o];if(!r)return null;let m=i.contracts.W_CROSS.toLowerCase(),h=i.contracts.NATIVE_CROSS.toLowerCase(),p=Ln(r,c,y,x=>x?.toLowerCase()===m?h:x?.toLowerCase());if(!p)return null;let k="swap";return u===i.chainIds.cross&&(c===h&&(k="deposit-swap"),y===h&&(k="swap-withdraw")),{pathType:k,step:{type:"swap",chain:u,fromToken:c,toToken:y,fee:p.fee,poolAddress:p.poolAddress}}}function Dr(e,t,n,i){let[o,c]=e.split("-"),[g]=t.split("-");if(o===g)return null;let y=(n?.swapPools||n?.swap_pools)?.[o]||[],u=r=>r?.toLowerCase();for(let r of y){let m=u(r.token0),h=u(r.token1),C=m===c?h:h===c?m:null;if(!C)continue;let p=Dn(ie(Number(o),C),t,i);if(!p)continue;let k=Ln(y,c,C,u);return[{type:"swap",chain:Number(o),fromToken:c,toToken:C,fee:k?.fee??Se,poolAddress:k?.poolAddress??""},p]}return null}function Lr(e,t,n,i,o){let[c,g]=e.split("-"),[y]=t.split("-");if(c===y)return null;for(let u of n?.list||[])if((u.localChain??u.local_chain)===Number(c))for(let r of u.pairs?.[y]||[]){if(r.localToken?.toLowerCase()!==g)continue;let m=r.remoteToken?.toLowerCase();if(!m)continue;let h=Gn(ie(Number(y),m),t,i,o);if(h)return[{type:"bridge",fromChain:Number(c),fromToken:g,toChain:Number(y),toToken:m,bridgeAddress:Fn(Number(c),n)},h.step]}return null}function Gr({envConfig:e,bridgePairList:t,swapPools:n,enrichedTokens:i}){return(o,c)=>{let g=i[o],y=i[c];if(!g||!y||o===c)return null;let u=Dn(o,c,t);if(u)return{type:"bridge",steps:[u],from:g,to:y};let r=Gn(o,c,n,e);if(r)return{type:r.pathType,steps:[r.step],from:g,to:y};let m=Dr(o,c,n,t);if(m)return{type:"swap-bridge",steps:m,from:g,to:y};let h=Lr(o,c,t,n,e);return h?{type:"bridge-swap",steps:h,from:g,to:y}:null}}function Bn(e,t){return{name:e.name,symbol:e.symbol,chainId:e.chainId,address:e.address,decimals:e.decimals,balance:t.get(e.key)||"0",iconUrl:e.image,priceUsd:e.price}}function Mr(e){return e.length<=10?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Ur(e){return e.includes(".")?e.replace(/\.?0+$/,"")||"0":e}function Kr(e,t){let n=e.startsWith("-"),i=n?e.slice(1):e,[o,c=""]=i.split("."),g=c.slice(0,t).replace(/0+$/,""),y=g?`${o}.${g}`:o;return n?`-${y}`:y}function $r(e){let t=e.startsWith("-"),n=t?e.slice(1):e,[i,o]=n.split("."),c=i.replace(/\B(?=(\d{3})+(?!\d))/g,","),g=o?`${c}.${o}`:c;return t?`-${g}`:g}function $t(e){if(e==null||e==="")return"0";let t=String(e),n=Number(t);return!Number.isFinite(n)||n===0?"0":$r(Kr(t,4))}function _n(e,t){if(e==null||e==="")return"0";try{return Ur(_t(BigInt(String(e)),t.decimals))}catch{return"0"}}function qt(e){return!!(e&&/^0x[0-9a-fA-F]+$/.test(e))}function qr(e){return e?new Date(e*1e3).toISOString():new Date().toISOString()}function Hr(e,t){return t.toLowerCase()===e.contracts.W_CROSS.toLowerCase()?e.contracts.NATIVE_CROSS:t}function Vr(e,t){let n=Mr(t);return{name:n,symbol:n,chainId:e,address:t,decimals:mt,balance:"0"}}function En({envConfig:e,tokenByBridgeKey:t,chainId:n,address:i}){if(!i)return null;let o=Hr(e,i);return t.get(ie(n,o))||t.get(ie(n,i))||Vr(n,o)}function Bt(e){return e?.toLowerCase()||""}function jr(e){if(e.source==="swap")return"swap";let t=Bt(e.fromToken??e.from_token),n=Bt(e.toToken??e.to_token),i=Bt(e.swapTokenIn??e.swap_token_in),o=Bt(e.swapTokenOut??e.swap_token_out);return n&&i&&n===i?"bridge-swap":t&&o&&t===o?"swap-bridge":"bridge"}function Qr(e,t){let n=e.status??0,i=e.extracallSuccess??e.extracall_success??!1;return t==="bridge-swap"&&n===1&&!i?"failed":n===1?"success":"pending"}function zr({envConfig:e,item:t,tokenByBridgeKey:n}){let i=Number(t.fromChainID??t.from_chain_id??0),o=Number(t.toChainID??t.to_chain_id??0);if(!i||!o)return null;let c=jr(t),g=t.swapTokenIn??t.swap_token_in,y=t.swapTokenOut??t.swap_token_out,u=t.swapAmountIn??t.swap_amount_in,r=t.swapAmountOut??t.swap_amount_out,m=t.fromToken??t.from_token,h=t.toToken??t.to_token,C=t.value,p=t.value;c==="swap"?(m=g,h=y,C=u,p=r):c==="swap-bridge"?(m=g,C=u,p=t.value):c==="bridge-swap"&&(h=y,C=u,p=r);let k=En({envConfig:e,tokenByBridgeKey:n,chainId:i,address:m}),x=En({envConfig:e,tokenByBridgeKey:n,chainId:o,address:h}),v=t.initiatedTxHash??t.initiated_tx_hash;return!k||!x||!qt(v)?null:{id:`${v}-${t.index??""}`,timestamp:qr(t.initiatedTime??t.initiated_time),txHash:v,fromToken:k,toToken:x,fromAmount:_n(C,k),toAmount:_n(p,x),summary:{pathType:c},status:Qr(t,c)}}function Xr(e){let t=new Map;return e.flat().forEach(n=>{let i=Number(n.chainId??n.chain_id),o=n.address?.toLowerCase();if(!i||!o)return;let c=n.quantity?.numeric??n.balance??"0",g=n.quantity?.decimals??n.decimals??mt;try{t.set(ie(i,o),_t(BigInt(c||"0"),g))}catch{t.set(ie(i,o),"0")}}),t}function Ke(e,t="first"){let n=e.steps.filter(i=>i.type==="swap");return t==="last"?n[n.length-1]:n[0]}function Yr(e,t){let n=(e?.swapPools||e?.swap_pools)?.[String(t.chainIds.cross)];if(!n?.length)return"";let i=t.contracts.CROSSD.toLowerCase(),o=t.contracts.USDTX.toLowerCase(),c=n.find(g=>{let y=g.token0?.toLowerCase(),u=g.token1?.toLowerCase();return y===i&&u===o||y===o&&u===i});return c?.poolAddress||c?.pool_address||""}function Zr(e,t){return e.from.chainId===t.chainIds.cross&&e.from.address.toLowerCase()===t.contracts.CROSSD.toLowerCase()&&e.to.chainId===t.chainIds.bsc&&e.to.address.toLowerCase()===t.contracts.USDTB.toLowerCase()}function Jr(e){if(e===void 0)return;let t=10n**BigInt(mt),n=e>=50000n*t?"normal":e>10000n*t?"low":"rebalancing",i=Number(e>0n?e*100n/(100000n*t):0n);return{label:"Available Liquidity",status:n,percentage:Math.min(i,100)}}function pt(e,t,n,i){let o=[e.from,e.to].find(c=>c.chainId===t&&c.address.toLowerCase()===n.toLowerCase())??i?.[ie(t,n)];return{symbol:o?.symbol||n.slice(0,6),iconUrl:o?.image}}function es(e,t){let n=[];for(let o of e.steps)o.type==="swap"?(n.push({chain:o.chain,address:o.fromToken}),n.push({chain:o.chain,address:o.toToken})):(n.push({chain:o.fromChain,address:o.fromToken}),n.push({chain:o.toChain,address:o.toToken}));let i=n.filter((o,c)=>c===0||!(o.chain===n[c-1].chain&&o.address.toLowerCase()===n[c-1].address.toLowerCase()));return i.length===0?[{symbol:e.from.symbol,iconUrl:e.from.image},{symbol:e.to.symbol,iconUrl:e.to.image}]:i.map(o=>pt(e,o.chain,o.address,t))}function ts({input:e,path:t,amountData:n,gasInfo:i,liquidity:o,enrichedTokens:c,priceImpact:g}){let y=e.fromAmount||"0",u=e.toAmount||"0",r=Ke(t),m=t.steps.find(U=>U.type==="bridge"),h=t.type!=="bridge",C=!De(t.type),p=r?Ar(y,r.fee):"0",k=Number(y)>0||Number(u)>0,x=r?pt(t,r.chain,r.fromToken,c):{symbol:e.fromToken.symbol,iconUrl:e.fromToken.iconUrl},v=r?pt(t,r.chain,r.toToken,c):{symbol:e.toToken.symbol,iconUrl:e.toToken.iconUrl},W=m?pt(t,m.fromChain,m.fromToken,c):void 0,I=(U,D,O)=>k?D&&D>0n?{label:U,value:st(D),tone:"default",valueToken:O}:{label:U,value:"Free",tone:"accent"}:{label:U,value:"0"};return{pathType:t.type,priceImpact:g,liquidity:o,bridgeInfo:C&&m?[{label:"Route",value:`${vn(m.fromChain)} \u2192 ${vn(m.toChain)}`},I("Validator Fee",n?.exFee,W),I("Network Fee",n?.networkFee,W)]:void 0,swapInfo:h&&r?[{label:"Route",value:"",routeTokens:[pt(t,r.chain,r.fromToken,c),pt(t,r.chain,r.toToken,c)]},{label:"Price Impact",value:Pr(g)},{label:"In Amount",value:$t(y),valueToken:x},{label:r&&De(t.type)?`Swap Fee (${Rr(r.fee??Se)})`:"Swap Fee",value:$t(p),valueToken:x},{label:"Out Amount",value:$t(u),valueToken:v}]:void 0,txFee:[...i?.gasPrice?[{label:"Gas Price",value:`${i.gasPrice} Gwei`}]:[{label:"Priority Fee Per Gas",value:`${i?.priorityFeePerGas||"0"} Gwei`},{label:"Max Fee Per Gas",value:`${i?.maxFeePerGas||"0"} Gwei`}],{label:"Gas Limit",value:i?.gasLimit||"0"}],txFeeInfo:i?{estTxFee:i.estTxFee,isDelegateFee:i.isDelegateFee,tokenIconUrl:i.gasCurrencyIconUrl,tokenSymbol:i.gasCurrencySymbol}:{estTxFee:"0",isDelegateFee:!1}}}function Ct({env:e,walletAddress:t,enabled:n=!0,restoreChainAfterSwitch:i=!0}){let o=sr(),c=er(new Map),y=Xe({queryKey:["crossd-bridge-adapter",e,"remote-contracts"],queryFn:async({signal:s})=>{let a=wr(await Fe(fr[e],s),e);if(!a)throw new Error("CrossD bridge adapter: invalid contracts.json");return a},enabled:n,staleTime:5*6e4}).data??null,u=n&&!!y,r=Te(()=>({...Cr[e],contracts:y??yr}),[e,y]),m=Xe({queryKey:["crossd-bridge-adapter",e,"pairs"],queryFn:({signal:s})=>Fe(`${r.bridgeApi}/pairs`,s),enabled:u,staleTime:3e4}),h=Xe({queryKey:["crossd-bridge-adapter",e,"swap-pools"],queryFn:({signal:s})=>Fe(`${r.bridgeApi}/swap-pools`,s),enabled:u,staleTime:3e4}),C=Te(()=>Yr(h.data,r),[r,h.data]),p=Xe({queryKey:["crossd-bridge-adapter",e,"available-liquidity",C],queryFn:async()=>await Ee(o,{address:r.contracts.USDTX,abi:Ut,functionName:"balanceOf",args:[C],chainId:r.chainIds.cross}),enabled:u&&!!C,staleTime:3e4}),k=Xe({queryKey:["crossd-bridge-adapter",e,"token-info"],queryFn:({signal:s})=>Fe(`${r.walletApi}/v1/public/token/info`,s),enabled:u,staleTime:3e4}),x=Xe({queryKey:["crossd-bridge-adapter",e,"token-stats"],queryFn:({signal:s})=>Fe(`${r.walletApi}/v1/public/token/stats`,s),enabled:u,staleTime:3e4}),v=wn({queries:[r.chainIds.cross,r.chainIds.bsc].map(s=>({queryKey:["crossd-bridge-adapter",e,"balance",t,s],queryFn:({signal:a})=>{let d=new URLSearchParams({networkId:`eip155:${s}`,account:t||""});return Fe(`${r.walletApi}/v1/public/token/balance?${d}`,a)},enabled:u&&!!t,staleTime:0,refetchInterval:u&&t?5e3:!1}))}),W=wn({queries:[r.chainIds.cross,r.chainIds.bsc].map(s=>({queryKey:["crossd-bridge-adapter",e,"gas-suggestion",s],queryFn:async({signal:a})=>{try{let w=await On(o,{chainId:s})?.estimateFeesPerGas?.();if(w?.maxFeePerGas||w?.gasPrice)return{fast:{maxFee:w.maxFeePerGas?.toString()||w.gasPrice?.toString(),maxPriorityFee:w.maxPriorityFeePerGas?.toString()||"0"}}}catch{}let d=new URLSearchParams({chain_id:String(s),without_gas_limit:"false"});return Fe(`${r.walletApi}/v1/public/transaction/gas-suggestion/dynamic?${d}`,a)},enabled:u,staleTime:1e4,retry:1}))}),I=Xe({queryKey:["crossd-bridge-adapter",e,"hidden-pairs"],queryFn:async({signal:s})=>mr(await Fe(ur[e],s),e),enabled:u,staleTime:5*6e4,retry:1}),U=Te(()=>I.data??[],[I.data]),D=Te(()=>Fr({envConfig:r,bridgePairList:m.data,swapPools:h.data,tokenInfo:k.data,tokenStats:x.data}),[m.data,r,h.data,k.data,x.data]),O=Te(()=>Gr({envConfig:r,bridgePairList:m.data,swapPools:h.data,enrichedTokens:D}),[m.data,D,r,h.data]),q=Te(()=>Xr(v.map(s=>s.data).filter(s=>Array.isArray(s))),[v]),$=Te(()=>{let s=new Map;return Object.values(D).forEach(a=>{let d=Bn(a,q);s.set(a.key,d)}),s},[q,D]),z=Te(()=>{let s=new Map,a=$.get(ie(r.chainIds.cross,r.contracts.NATIVE_CROSS));a&&s.set(r.chainIds.cross,{symbol:a.symbol,iconUrl:a.iconUrl});let d=k.data?.find(f=>Number(f.chainId??f.chain_id)===r.chainIds.bsc&&(f.symbol??"").toUpperCase()==="BNB");return d&&s.set(r.chainIds.bsc,{symbol:d.symbol??"BNB",iconUrl:d.image??d.icon_url}),s},[r,$,k.data]),L=Xe({queryKey:["crossd-bridge-adapter",e,"history",t],queryFn:({signal:s})=>xn(`${r.bridgeApi}/history`,{owner:t,page:1,size:20,sort:"desc",status:"all"},s),enabled:u&&!!t,staleTime:0,refetchInterval:u&&t?5e3:!1}),K=Te(()=>(L.data?.histories||[]).map(s=>zr({envConfig:r,item:s,tokenByBridgeKey:$})).filter(s=>!!s),[L.data?.histories,r,$]),Re=Te(()=>Jr(p.data),[p.data]),de=W[0]?.data,N=W[1]?.data,A=Te(()=>{let s=new Map;return de&&s.set(r.chainIds.cross,de),N&&s.set(r.chainIds.bsc,N),s},[N,de,r.chainIds.bsc,r.chainIds.cross]),Y=re((s,a,d)=>{let f=A.get(s.from.chainId)?.fast,w=a?d?.gasLimit??Rt(s.type):0n,_=d?.gasPrice&&d.gasPrice>0n?d.gasPrice:0n,E=d?.maxFeePerGas&&d.maxFeePerGas>0n?d.maxFeePerGas:0n,R=d?.maxPriorityFeePerGas&&d.maxPriorityFeePerGas>0n?d.maxPriorityFeePerGas:0n,G=Ye(f?.maxFee??f?.max_fee),Z=Ye(f?.maxPriorityFee??f?.max_priority_fee),S=E>0n?E:G>0n?G:_,F=R>0n?R:Z>0n?Z:S,j=_>0n?_:S,X=Nn.has(s.from.chainId)&&j>0n,l=w*(X?j:S),b=$.get(ie(s.from.chainId,r.contracts.NATIVE_CROSS)),T=s.type!=="swap-bridge",P=z.get(s.from.chainId);return{estTxFee:a?st(l):"0",priorityFeePerGas:a&&!X?Kt(F):"0",maxFeePerGas:a&&!X?Kt(S):"0",gasLimit:a?w.toString():"0",gasPrice:a&&X?Kt(j):void 0,isDelegateFee:s.type==="swap-bridge"?!1:Br(r,s.from.address,s.to.address),tokenIconUrl:T?b?.iconUrl:void 0,tokenSymbol:T?b?.symbol:void 0,gasCurrencyIconUrl:P?.iconUrl,gasCurrencySymbol:P?.symbol}},[r,A,z,$]),V=re(async s=>{let a=_r(s);if(!a)return null;let d=`${e}:${a.from}:${a.to}:${a.token.toLowerCase()}`,f=c.current.get(d);if(f)return f;let w=(async()=>{let _=new URLSearchParams({from:String(a.from),to:String(a.to),token:a.token});try{return(await Fe(`${r.bridgeApi}/token-config?${_}`)).config??null}catch{return null}})();return c.current.set(d,w),w},[e,r.bridgeApi]),ce=Te(()=>{let s=Object.values(D).map(d=>Bn(d,q)),a=ie(r.chainIds.cross,r.contracts.CROSSD);return s.sort((d,f)=>{let w=fe(d).toLowerCase()===a.toLowerCase(),_=fe(f).toLowerCase()===a.toLowerCase();return w!==_?w?-1:1:fe(d).localeCompare(fe(f))})},[q,D,r]),Ie=Te(()=>{if(y)return{target:{chainId:r.chainIds.cross,address:r.contracts.CROSSD},swap:{from:{chainId:r.chainIds.cross,address:r.contracts.NATIVE_CROSS},feeDelegated:!0},bridge:{from:[{chainId:r.chainIds.bsc,address:r.contracts.USDTB},{chainId:r.chainIds.cross,address:r.contracts.USDTX}]}}},[r,y]),qe=re(s=>{let a=fe(s),d=a.toLowerCase(),f=[];Object.keys(D).forEach(E=>{let R=E.toLowerCase();if(d===R||U.some(S=>S.fromKey===d&&S.toKey===R))return;let G=O(a,E);if(!G)return;let Z=$.get(E);Z&&f.push({token:Z,path:G})});let w=ie(r.chainIds.cross,r.contracts.CROSSD),_=ie(r.chainIds.cross,r.contracts.NATIVE_CROSS);return f.sort((E,R)=>{if(d===w.toLowerCase()){let j=fe(E.token).toLowerCase()===_.toLowerCase(),X=fe(R.token).toLowerCase()===_.toLowerCase();if(j!==X)return j?-1:1}let G=De(E.path.type),Z=De(R.path.type);if(G!==Z)return G?-1:1;let S=E.token.chainId===s.chainId,F=R.token.chainId===s.chainId;return S!==F?S?-1:1:fe(E.token).localeCompare(fe(R.token))}),f.map(E=>E.token)},[D,r,O,U,$]),Oe=re(async s=>await Ee(o,{address:r.contracts.SWAP_BRIDGE_ROUTER,abi:rt,functionName:"quoter",chainId:s}),[r.contracts.SWAP_BRIDGE_ROUTER,o]),xe=re(async s=>{Mt(o)!==s&&await Cn(o,{chainId:s})},[o]),He=re(s=>Pt({getChainId:()=>Mt(o),switchChain:a=>Cn(o,{chainId:a})},s,i),[i,o]),we=re(async s=>await Ee(o,{address:r.contracts.SWAP_BRIDGE_ROUTER,abi:rt,functionName:"swapRouter",chainId:s}),[r.contracts.SWAP_BRIDGE_ROUTER,o]),le=re(async({path:s,step:a,amount:d,source:f})=>{let w=await Oe(a.chain),_=a.poolAddress?Ee(o,{address:a.poolAddress,abi:kr,functionName:"slot0",chainId:a.chain}).then(G=>G?.[0]).catch(()=>{}):Promise.resolve(void 0);if(f==="from"){let G=await Ee(o,{address:w,abi:In,functionName:"quoteExactInputSingle",args:[{tokenIn:se(r,a.fromToken),tokenOut:se(r,a.toToken),amountIn:wt(d),fee:a.fee??Se,sqrtPriceLimitX96:0n}],chainId:a.chain}),Z=Pn(await _,G[1]);return{amount:st(G[0]),path:s,priceImpact:Z}}let E=await Ee(o,{address:w,abi:In,functionName:"quoteExactOutputSingle",args:[{tokenIn:se(r,a.fromToken),tokenOut:se(r,a.toToken),amount:wt(d),fee:a.fee??Se,sqrtPriceLimitX96:0n}],chainId:a.chain}),R=Pn(await _,E[1]);return{amount:st(E[0]),path:s,priceImpact:R}},[r,Oe,o]),Ge=re(async(s,a)=>{if(!t)throw new Error("Wallet is not connected.");let d=Rt(a.type);if(De(a.type)){let S=Ke(a,"first");if(!S)throw new Error("Swap route is not available.");let F=he(s.fromAmount),j=he(s.toAmount);if(F<=0n)throw new Error("Bridge amount is empty.");if(j<=0n)throw new Error("Bridge quote is not ready.");let X=await we(S.chain),H=St(j,s.slippage),l=a.type==="swap-withdraw"?$e:t,b={tokenIn:se(r,S.fromToken),tokenOut:se(r,S.toToken),fee:S.fee??Se,recipient:l,deadline:ht(),amountIn:F,amountOutMinimum:H,sqrtPriceLimitX96:0n};if(a.type==="swap-withdraw"){let T=bt({abi:Ue,functionName:"exactInputSingle",args:[b]}),P=bt({abi:Ue,functionName:"unwrapWETH9",args:[H,t]});return{address:X,abi:Ue,functionName:"multicall",args:[[T,P]],chainId:S.chain,fallbackGasLimit:d}}if(a.type==="deposit-swap"){let T=bt({abi:Ue,functionName:"exactInputSingle",args:[b]}),P=bt({abi:Ue,functionName:"refundETH",args:[]});return{address:X,abi:Ue,functionName:"multicall",args:[[T,P]],value:F,chainId:S.chain,fallbackGasLimit:d}}return{address:X,abi:Ue,functionName:"exactInputSingle",args:[b],chainId:S.chain,fallbackGasLimit:d}}if(a.type==="swap-bridge"){let S=Ke(a,"first");if(!S)throw new Error("Swap bridge route is not available.");let F=he(s.fromAmount),j=he(s.toAmount);if(F<=0n)throw new Error("Bridge amount is empty.");if(j<=0n)throw new Error("Bridge quote is not ready.");let X=r.contracts.SWAP_BRIDGE_ROUTER,H=ht(),l={toChainID:BigInt(a.to.chainId),recipient:t,extraData:"0x"},b={tokenIn:se(r,a.from.address),tokenOut:se(r,S.toToken),fee:S.fee??Se,sqrtPriceLimitX96:0n,bridgeParams:l};if(s.lastChangedBy==="to"){let P={...b,amountOut:j,amountInMaximum:hn(F,s.slippage)};return{address:X,abi:rt,functionName:"swapBridgeExactOutputSingle",args:[P,H],value:a.from.isNativeToken?P.amountInMaximum:void 0,chainId:a.from.chainId,fallbackGasLimit:d}}let T={...b,amountIn:F,amountOutMinimum:St(j,s.slippage)};return{address:X,abi:rt,functionName:"swapBridgeExactInputSingle",args:[T,H],value:a.from.isNativeToken?F:void 0,chainId:a.from.chainId,fallbackGasLimit:d}}let f=a.steps.find(S=>S.type==="bridge");if(!f?.bridgeAddress)throw new Error("Bridge route is not available.");let w=he(s.fromAmount);if(w<=0n)throw new Error("Bridge amount is empty.");let _=await V(a),E=Ye(_?.gasFee??_?.gas_fee),R=An(w,_?.exFeeRate??_?.ex_fee_rate),G="0x";if(a.type==="bridge-swap"){let S=Ke(a,"last");if(!S)throw new Error("Bridge swap route is not available.");let F=he(s.toAmount);if(F<=0n)throw new Error("Bridge quote is not ready.");let j=await we(a.to.chainId),X=St(F,s.slippage),H=bt({abi:Ue,functionName:"exactInputSingle",args:[{tokenIn:se(r,S.fromToken),tokenOut:se(r,S.toToken),fee:S.fee??Se,recipient:t,deadline:ht(),amountIn:w,amountOutMinimum:X,sqrtPriceLimitX96:0n}]});G=`${j}${H.slice(2)}`}let Z=[BigInt(a.to.chainId),a.from.address,t,w,E,R,G];return{address:f.bridgeAddress,abi:Tr,functionName:"bridgeToken",args:Z,value:a.from.isNativeToken?w+R+E:void 0,chainId:a.from.chainId,fallbackGasLimit:d}},[r,V,we,t]),et=re(async(s,a)=>{if(a.type==="bridge"||a.type==="bridge-swap")return Ge(s,a);if(!t)throw new Error("Wallet is not connected.");let d=he(s.fromAmount);if(d<=0n)throw new Error("Bridge amount is empty.");if(a.type==="swap-bridge"){let E=Ke(a,"first");if(!E)throw new Error("Swap bridge route is not available.");let R=r.contracts.SWAP_BRIDGE_ROUTER,G={tokenIn:se(r,a.from.address),tokenOut:se(r,E.toToken),fee:E.fee??Se,sqrtPriceLimitX96:0n,bridgeParams:{toChainID:BigInt(a.to.chainId),recipient:t,extraData:"0x"},amountIn:d,amountOutMinimum:0n};return{address:R,abi:rt,functionName:"swapBridgeExactInputSingle",args:[G,ht()],value:a.from.isNativeToken?d:void 0,chainId:a.from.chainId,fallbackGasLimit:Rt(a.type)}}let f=Ke(a,"first");if(!f)throw new Error("Swap route is not available.");let w=await we(f.chain),_={tokenIn:se(r,f.fromToken),tokenOut:se(r,f.toToken),fee:f.fee??Se,recipient:t,deadline:ht(),amountIn:d,amountOutMinimum:0n,sqrtPriceLimitX96:0n};return{address:w,abi:Ue,functionName:"exactInputSingle",args:[_],value:a.from.isNativeToken?d:void 0,chainId:f.chain,fallbackGasLimit:Rt(a.type)}},[Ge,r,we,t]),ye=re(async(s,a)=>{if(!t)return null;try{let d=await et(s,a),f=De(a.type)||a.type==="swap-bridge",w=await Sn(o,d.chainId,d.fallbackGasLimit,f,{account:t,address:d.address,abi:d.abi,functionName:d.functionName,args:d.args,value:d.value},!0);return{gasLimit:w.gas,gasPrice:w.gasPrice,maxFeePerGas:w.maxFeePerGas,maxPriorityFeePerGas:w.maxPriorityFeePerGas}}catch{return null}},[et,o,t]),ct=re(async s=>{let a=fe(s.fromToken),d=fe(s.toToken),f=O(a,d);if(!f)return{error:"Route is not available."};let w=s.lastChangedBy==="to"?s.toAmount:s.fromAmount,_=!!w&&Number(w)>0,E=Zr(f,r)?Re:void 0,R=async(H,l,b)=>{let T=_?await ye(H,f):null,P=Y(f,_,T);return ts({input:H,path:f,gasInfo:P,amountData:l,liquidity:E,enrichedTokens:D,priceImpact:b})};if(!w||Number(w)<=0)return{fromAmount:s.fromAmount,toAmount:s.toAmount,summary:await R(s)};let G=await V(f),Z=Ye(G?.gasFee??G?.gas_fee),S=f.type==="bridge"||f.type==="bridge-swap"?{networkFee:Z}:void 0,F=f.type==="bridge"?s.lastChangedBy==="to"?{...s,fromAmount:s.toAmount}:{...s,toAmount:s.fromAmount}:s,j=Er({input:F,path:f,config:G});if(j)return{fromAmount:F.fromAmount,toAmount:F.toAmount,summary:await R(F,S),error:j};let X=Or({input:F,path:f,config:G});if(X)return{fromAmount:F.fromAmount,toAmount:F.toAmount,summary:await R(F,S),error:X};if(f.type==="bridge")return{fromAmount:F.fromAmount,toAmount:F.toAmount,summary:await R(F,S)};try{if(f.type==="swap-bridge"){let T=Ke(f,"first"),P=r.contracts.SWAP_BRIDGE_ROUTER;if(!T)return{error:"Swap bridge route is not ready."};let B=Ne=>le({path:f,step:T,amount:Ne,source:"from"}).then(je=>je.priceImpact).catch(()=>{});if(s.lastChangedBy==="from"){let Ne=await Ee(o,{address:P,abi:rt,functionName:"getAmountSwapBridgeOut",args:[BigInt(f.to.chainId),se(r,f.from.address),se(r,T.toToken),T.fee??Se,wt(s.fromAmount)],chainId:f.from.chainId}),je=st(Ne[1]),Ot={...s,toAmount:je};return{toAmount:je,summary:await R(Ot,{networkFee:Ne[3],exFee:Ne[4]},await B(s.fromAmount))}}let pe=await Ee(o,{address:P,abi:rt,functionName:"getAmountSwapBridgeIn",args:[BigInt(f.to.chainId),se(r,f.from.address),se(r,T.toToken),T.fee??Se,wt(s.toAmount)],chainId:f.from.chainId}),Ve=st(pe[1]),nt={...s,fromAmount:Ve};return{fromAmount:Ve,summary:await R(nt,{networkFee:pe[3],exFee:pe[4]},await B(Ve))}}let H=f.type==="bridge-swap"?Ke(f,"last"):Ke(f,"first");if(!H)return{error:"Swap route is not available."};let l=await le({path:f,step:H,amount:w,source:s.lastChangedBy});if(s.lastChangedBy==="from"){let T={...s,toAmount:l.amount};return{toAmount:l.amount,summary:await R(T,S,l.priceImpact)}}let b={...s,fromAmount:l.amount};return{fromAmount:l.amount,summary:await R(b,S,l.priceImpact)}}catch(H){return{fromAmount:s.fromAmount,toAmount:s.toAmount,summary:await R(s,S),error:vr(H)}}},[Re,Y,D,r,ye,O,V,le,o]),tt=re(async s=>{if(s.from.isNativeToken)return null;if(s.type==="swap"||s.type==="deposit-swap"||s.type==="swap-withdraw")return we(s.from.chainId);if(s.type==="swap-bridge")return r.contracts.SWAP_BRIDGE_ROUTER;let a=s.steps.find(d=>d.type==="bridge");return a?.bridgeAddress?a.bridgeAddress:null},[r.contracts.SWAP_BRIDGE_ROUTER,we]),Ae=re(async s=>{if(!t)throw new Error("Wallet is not connected.");let a=fe(s.fromToken),d=fe(s.toToken),f=O(a,d);if(!f)throw new Error("Route is not available.");if(!De(f.type)&&f.type!=="swap-bridge"||f.from.isNativeToken)return null;let w=he(s.fromAmount);if(w<=0n)return null;let _=await tt(f);return!_||await Ee(o,{address:f.from.address,abi:Ut,functionName:"allowance",args:[t,_],chainId:f.from.chainId})>=w?null:{token:s.fromToken,tokenAddress:f.from.address,spenderAddress:_,amount:s.fromAmount}},[O,tt,o,t]),ve=re(async(s,a)=>{let d=he(a.amount||s.fromAmount);if(d<=0n)throw new Error("Approval amount is empty.");await xe(a.token.chainId);let f=await kn(o,{address:a.tokenAddress,abi:Ut,functionName:"approve",args:[a.spenderAddress,d],chainId:a.token.chainId});await rr(o,{hash:f,chainId:a.token.chainId})},[xe,o]),ue=re(async(s,a)=>{let d=await Ge(s,a);await xe(d.chainId);let f=await Sn(o,d.chainId,d.fallbackGasLimit,ir(a.type),{account:t,address:d.address,abi:d.abi,functionName:d.functionName,args:d.args,value:d.value});return{txHash:await kn(o,{address:d.address,abi:d.abi,functionName:d.functionName,args:d.args,value:d.value,chainId:d.chainId,...f}),fromToken:s.fromToken,toToken:s.toToken,fromAmount:s.fromAmount,toAmount:s.toAmount}},[Ge,xe,o,t]),Me=re(async(s,a)=>{let d=t;if(!d)throw new Error("Wallet is not connected.");let f=a.steps.find(je=>je.type==="bridge");if(!f?.bridgeAddress)throw new Error("Bridge route is not available.");let w=a.from.address,_=a.from.chainId,E=he(s.fromAmount);if(E<=0n)throw new Error("Bridge amount is empty.");let R=await V(a),G=Ye(R?.gasFee??R?.gas_fee),Z=An(E,R?.exFeeRate??R?.ex_fee_rate),S=E+Z+G,[F,j]=await Promise.all([Ee(o,{address:w,abi:Tn,functionName:"name",chainId:_}),Ee(o,{address:w,abi:Tn,functionName:"nonces",args:[d],chainId:_})]),X=BigInt(Math.floor(Date.now()/1e3)+300),H=await or(o,{domain:{name:F,version:"1",chainId:_,verifyingContract:w},types:{Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},primaryType:"Permit",message:{owner:d,spender:f.bridgeAddress,value:S,nonce:j,deadline:X}}),{r:l,s:b,v:T,yParity:P}=tr(H),B=T!==void 0?Number(T):P+27,pe={exFee:Z.toString(),from:_,fromToken:w,nonce:Number(j),gasFee:G.toString(),permitArgs:{account:d,deadline:X.toString(),r:l,s:b,token:w,v:B,value:S.toString()},to:d,toChainID:String(a.to.chainId),value:S.toString()},Ve=await xn(`${r.bridgeApi}/permit`,pe),nt=Ve?.requestId??Ve?.request_id;if(!nt)throw new Error("Bridge permit request failed.");let Ne=await xr(r.bridgeApi,nt);if(!qt(Ne))throw new Error("Bridge submitted, but confirmation timed out. Check History shortly.");return{txHash:Ne,fromToken:s.fromToken,toToken:s.toToken,fromAmount:s.fromAmount,toAmount:s.toAmount}},[r,V,o,t]),dt=re(async s=>{let a=Mt(o),d=fe(s.fromToken),f=fe(s.toToken),w=O(d,f);if(!w)throw new Error("Route is not available.");if(!(De(w.type)||w.type==="swap-bridge"||w.type==="bridge-swap"||w.type==="bridge"))throw new Error("This bridge route is not supported yet.");let R=w.type==="bridge"&&w.from.chainId===r.chainIds.bsc&&w.from.address.toLowerCase()===r.contracts.BSC_CROSS.toLowerCase()?await Me(s,w):await ue(s,w);return await He(a),{...R,pathType:w.type,routeTokens:es(w,D)}},[D,r,O,He,Me,ue,o]);return{bridgeTokens:ce,bridgeHistory:K,getBridgeApproval:Ae,approveBridge:ve,getBridgeQuote:ct,getBridgeToTokens:qe,submitBridge:dt,oneUsdPairs:Ie,isLoading:m.isLoading||h.isLoading||k.isLoading||x.isLoading||v.some(s=>s.isLoading)}}import{useEffect as Mn,useRef as ns,useState as Un}from"react";import{useAccount as os}from"wagmi";function Ht(e){let{address:t,connector:n}=os(),{currentWallet:i}=Be(),o=e?.walletId!==void 0?e.walletId:i,c=e?.connector!==void 0?e.connector:n,g=e?.address!==void 0?e.address:t,[y,u]=Un({loginType:null,accountName:null,accounts:[],isResolved:!1}),r=ns(new Map),[m,h]=Un(0);return Mn(()=>{let C=!1;if(o!=="cross_embedded")return u({loginType:null,accountName:null,accounts:[],isResolved:!0}),()=>{C=!0};if(!c)return u({loginType:null,accountName:null,accounts:[],isResolved:!1}),()=>{C=!0};u(v=>({...v,isResolved:!1}));let p=20,k=300,x=async()=>{if(typeof c.getProvider!="function")return"retry";let v;try{v=await c.getProvider()}catch{return"retry"}let W=v?.sdk;if(!W)return"giveup";try{let N=W.getRNBridgeActiveWallet?.(),A=N?.walletName?.trim();N&&A&&r.current.set(N.address.toLowerCase(),A)}catch{}let[I,U]=await Promise.all([W.getUserInfo?.().catch(()=>null)??null,W.getAddresses?.().catch(()=>null)??null]);if(C)return"done";let D=I?.loginType,O=D==="google"||D==="apple"?D:null;if(!O)return"retry";let q=g?.toLowerCase(),$=q&&Array.isArray(U)?U.find(N=>N.address.toLowerCase()===q):null,z=Array.isArray(U)?U.filter(N=>/^0x[a-fA-F0-9]{40}$/.test(N.address)).map(N=>({address:N.address.toLowerCase(),...Number.isFinite(N.index)?{index:N.index}:{},...N.name?.trim()?{name:N.name.trim()}:{}})):[],L=q?r.current.get(q)?.trim():void 0,K=!$&&q&&/^0x[a-fA-F0-9]{40}$/.test(q)?[...z,{address:q,index:z.length,...L?{name:L}:{}}]:z,de=L||$?.name?.trim()||(typeof $?.index=="number"?`Account ${$.index+1}`:g?`${g.slice(0,6)}\u2026${g.slice(-4)}`:null);return u({loginType:O,accountName:de,accounts:K,isResolved:!0}),"done"};return(async()=>{for(let v=0;v<p;v++){if(C)return;let W=await x();if(W==="done")return;if(W==="giveup"){C||u({loginType:null,accountName:null,accounts:[],isResolved:!0});return}await new Promise(I=>setTimeout(I,k))}C||u({loginType:null,accountName:null,accounts:[],isResolved:!0})})(),()=>{C=!0}},[o,c,g,m]),Mn(()=>{if(o!=="cross_embedded"||!c||typeof c.getProvider!="function")return;let C=!1,p;return(async()=>{let k;try{k=await c.getProvider()}catch{return}if(C)return;let x=k?.sdk;x?.on&&(p=x.on("addressChanged",({address:v,walletName:W})=>{let I=W?.trim();I&&(r.current.set(v.toLowerCase(),I),h(U=>U+1))}))})(),()=>{C=!0,p?.()}},[o,c]),y}import{Fragment as qn,jsx as ge,jsxs as it}from"react/jsx-runtime";var ys=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]}],bs=[{type:"function",name:"earned",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"posaActive",stateMutability:"view",inputs:[],outputs:[{name:"",type:"bool"}]},{type:"function",name:"lastRewardBlock",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"totalStaked",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint256"}]}],hs={dev:{poolAddress:"0x0000000c5BB5C7B081237B5efaFC753D61201b94",crossChainId:612044,networkStatsUrl:"https://stg-posa-api.crosstoken.io/api/v1/network/stats"},stage:{poolAddress:"0x0000000c5BB5C7B081237B5efaFC753D61201b94",crossChainId:612044,networkStatsUrl:"https://stg-posa-api.crosstoken.io/api/v1/network/stats"},production:{poolAddress:"0x000000068122d9bB43B4BCF5497A10EdfA9F5E93",crossChainId:612055,networkStatsUrl:"https://posa-api.crosstoken.io/api/v1/network/stats"}},Qt=10n**18n,ws={google:{name:"Google",iconUrl:Vn,connectorId:Je.CROSSx},apple:{name:"Apple",iconUrl:Yt,connectorId:Je.CROSSx},cross:{name:kt.default,iconUrl:Xt,connectorId:Je.CROSSx},metamask:{name:"MetaMask",iconUrl:jn,connectorId:Je.MetaMask},binance:{name:"Binance Wallet",iconUrl:Hn,connectorId:Je.Binance}};function Cs(e){switch(e){case"cross_embedded":return Je.CROSSx;case"metamask":return Je.MetaMask;case"binance":return Je.Binance;default:return}}function ks(e,t){switch(e){case"cross_embedded":return t==="google"?{name:"Google",iconUrl:Vn}:t==="apple"?{name:"Apple",iconUrl:Yt}:{name:kt.default,iconUrl:Xt};case"cross_wallet":return{name:kt.default,iconUrl:Xt};case"cross_extension":return{name:kt.extension,iconUrl:gs};case"metamask":return{name:"MetaMask",iconUrl:jn};case"binance":return{name:"Binance Wallet",iconUrl:Hn};default:return null}}function Ts(e){if(e)return e==="cross_embedded"?kt.default:ps[e]?.name}function Is({label:e="Connect Wallet",className:t,style:n,walletInfoStyle:i,user:o,enablePortfolio:c,portfolio:g,theme:y,accountName:u,connectorId:r,showPortfolio:m,sendAccounts:h,getTransactionReceipt:C,sendTransaction:p,estimateGas:k,onDisconnect:x,onSelectWallet:v,onBuy:W,onRampRedirectUrl:I,bridgeTokens:U,bridgeHistory:D,getBridgeQuote:O,getBridgeToTokens:q,getBridgeApproval:$,approveBridge:z,submitBridge:L,showBalance:K=!0,env:Re,...de}){let{address:N,isConnected:A,connector:Y,chain:V}=is(),ce=cs(),Ie=as(),{switchChainAsync:qe}=ls(),{sendTransactionAsync:Oe}=ds(),{connectWallet:xe,disconnect:He,selectWallet:we,currentWallet:le,isConnecting:Ge,kitConfig:et}=Be(),ye=et?.restoreChainAfterSwitch!==!1,ct=yt(),tt=y??ct?.mode??"dark",Ae=Et(()=>us(Re),[Re]),ve=o?.address??N,ue=o?ws[o.provider]:null,{loginType:Me,accountName:dt,accounts:s}=Ht({walletId:le,connector:Y,address:ve}),a=Et(()=>ue?{name:ue.name,iconUrl:ue.iconUrl}:ks(le,Me),[ue,le,Me]),d=u??o?.name??dt??void 0,f=de.connectorName??(ue?ue.name:Ts(le)),w=ue?ue.connectorId:Cs(le),_=r??w,E=g??m??!!c,R=Ct({env:Ae,walletAddress:ve,enabled:A&&!!ve&&K,restoreChainAfterSwitch:ye}),G=U??R.bridgeTokens,Z=D??R.bridgeHistory,S=O??R.getBridgeQuote,F=q??R.getBridgeToTokens,j=$??R.getBridgeApproval,X=z??R.approveBridge,H=L??R.submitBridge,l=Ze(()=>{xe().catch(M=>{console.error("[crossx-kit] connectWallet error:",M)})},[xe]),b=Ze(()=>{He()},[He]),T=x??b,P=ms(),{eligibility:B}=fs({network:V?String(V.id):void 0}),pe=B?.allowed===!0,Ve=Et(()=>{if(W)return W;if(!(!P||!V||!pe))return()=>P.open({crypto:V.nativeCurrency?.symbol??"USDT",network:String(V.id),...I?{redirectUrl:I}:{}}).then(()=>{}).catch(M=>{throw console.warn("[crossx-kit] onramp open failed:",M),M})},[W,P,V,pe,I]),nt=ss();rs(()=>{if(P?.onStatus)return P.onStatus(()=>{nt.invalidateQueries()})},[P,nt]);let Ne=Et(()=>{if(!W&&!(!P||!V)&&!pe)return"On-ramp is not available in your region."},[W,P,V,pe]),je=de.onBridgeDisabledMessage,Ot=de.onSendDisabledMessage,to=o?o.provider==="google"||o.provider==="apple":le==="cross_embedded",no=Ze(()=>{we().catch(M=>{console.error("[crossx-kit] selectWallet error:",M)})},[we]),tn=v??(to?no:void 0),oo=Ze(async({hash:M,chainId:te})=>{let ne=Vt(ce,te?{chainId:te}:void 0);if(!ne)return null;try{return await ne.getTransactionReceipt({hash:M})}catch{return null}},[ce]),ro=Ze(async M=>{let te=Ie,ne=!1;M.chainId!==void 0&&M.chainId!==Ie&&(await qe({chainId:M.chainId}),ne=!0);let me=M.chainId===56||M.chainId===97?{...M,type:"legacy"}:M,J=await(p??Oe)(me);return await Pt({getChainId:()=>ne?M.chainId:te,switchChain:ke=>qe({chainId:ke})},te,ye),J},[p,Oe,Ie,qe,ye]),so=E||p?ro:void 0,io=Ze(async M=>{let te=M.chainId??Ie,ne=Vt(ce,te?{chainId:te}:void 0);if(!ne)throw new Error(`publicClient for chainId ${te??"unknown"} is not available \u2014 register the chain in createCrossxConfig({ networks }).`);let Ce=te===56||te===97,[me,Pe]=await Promise.all([ne.estimateGas({account:M.from,to:M.to,value:M.value,data:M.data}),(async()=>{if(Ce)return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await ne.getGasPrice()};try{let J=await ne.estimateFeesPerGas();return{maxFeePerGas:J.maxFeePerGas,maxPriorityFeePerGas:J.maxPriorityFeePerGas,gasPrice:void 0}}catch{return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await ne.getGasPrice()}}})()]);return{gasLimit:me,maxFeePerGas:Pe.maxFeePerGas,maxPriorityFeePerGas:Pe.maxPriorityFeePerGas,gasPrice:Pe.gasPrice}},[ce,Ie]),ao=k??io,co=Ze(async M=>{let te={};if(!N||M.length===0)return te;let ne=M.flatMap(me=>{let J={address:me,abi:ys,chainId:Ie};return[{...J,functionName:"balanceOf",args:[N]},{...J,functionName:"totalSupply"},{...J,functionName:"decimals"}]}),Ce;try{Ce=await Kn(ce,{contracts:ne,allowFailure:!0})}catch{return te}return M.forEach((me,Pe)=>{let J=Pe*3,ke=Ce[J],Tt=Ce[J+1],lt=Ce[J+2];!ke||ke.status!=="success"||(te[me.toLowerCase()]={balance:ke.result,totalSupply:Tt&&Tt.status==="success"?Tt.result:void 0,decimals:lt&<.status==="success"?Number(lt.result):void 0})}),te},[ce,N,Ie]),lo=Ze(async M=>{let te={earnedWei:0n,stakedWei:0n};if(!M)return te;let ne=hs[Ae],Ce={address:ne.poolAddress,abi:bs,chainId:ne.crossChainId},me;try{me=await Kn(ce,{allowFailure:!0,contracts:[{...Ce,functionName:"earned",args:[M]},{...Ce,functionName:"balanceOf",args:[M]},{...Ce,functionName:"posaActive"},{...Ce,functionName:"lastRewardBlock"},{...Ce,functionName:"totalStaked"}]})}catch{return te}let Pe=ot=>me[ot]&&me[ot].status==="success"?me[ot].result:0n,J=Pe(0),ke=Pe(1);if(me[2]&&me[2].status==="success"?me[2].result:!1)return{earnedWei:J,stakedWei:ke};let lt=Pe(3),rn=Pe(4);if(rn===0n)return{earnedWei:J,stakedWei:ke};let Nt=0n;try{Nt=await Vt(ce,{chainId:ne.crossChainId})?.getBlockNumber?.()??0n}catch{return{earnedWei:J,stakedWei:ke}}if(Nt<=lt)return{earnedWei:J,stakedWei:ke};let Wt=0n;try{let ot=await fetch(ne.networkStatsUrl).then(Ft=>Ft.json()),sn=ot?.data?.block_reward??ot?.block_reward;if(sn){let[Ft,fo=""]=String(sn).split("."),go=(fo+"0".repeat(18)).slice(0,18);Wt=BigInt(Ft||"0")*Qt+BigInt(go||"0")}}catch{}if(Wt===0n)return{earnedWei:J,stakedWei:ke};let po=(Nt-lt)*Wt*Qt/rn,mo=ke*po/Qt;return{earnedWei:J+mo,stakedWei:ke}},[ce,Ae]),nn=!tn,on=t?`cb-button ${t}`:"cb-button",uo=t?`cb-pill ${t}`:"cb-pill";return Ge&&!A?it(qn,{children:[ge("style",{children:zt}),it("button",{type:"button",disabled:!0,className:on,style:n,"aria-busy":"true",children:[ge("span",{className:"cb-spinner","aria-hidden":"true"}),ge("span",{className:"cb-button-label",children:"Connecting..."})]})]}):A&&ve?it("span",{"data-crossx-wallet-info":nn?"external":"embedded",children:[ge("style",{children:zt}),nn&&ge("style",{children:vs}),it(jt,{...de,env:Ae,theme:tt,showBalance:K,walletAddress:ve,accountName:d,sendAccounts:h??s,connectorName:f,connectorId:_,showPortfolio:E,onDisconnect:T,onSelectWallet:tn,onBuy:Ve,onBuyDisabledMessage:Ne,onBridgeDisabledMessage:je,onSendDisabledMessage:Ot,sendTransaction:so,getTransactionReceipt:C??oo,estimateGas:ao,lpBalanceReader:co,stakingRewardsReader:lo,bridgeTokens:G,bridgeHistory:Z,getBridgeQuote:S,getBridgeToTokens:F,getBridgeApproval:j,approveBridge:X,submitBridge:H,style:i,children:[ge(jt.Trigger,{asChild:!0,children:it("button",{type:"button",className:uo,style:n,"aria-label":`Connected with ${a?.name??"wallet"}: ${$n(ve)}`,children:[a?.iconUrl?ge("img",{src:a.iconUrl,alt:"",width:20,height:20,className:"cb-pill-icon","data-provider":a.iconUrl===Yt?"apple":void 0}):ge("span",{className:"cb-pill-icon-placeholder","aria-hidden":"true"}),ge("span",{className:"cb-pill-address",children:$n(ve)})]})}),ge(jt.Content,{align:"end",sideOffset:8})]})]}):it(qn,{children:[ge("style",{children:zt}),it("button",{type:"button",onClick:l,className:on,style:n,"aria-label":typeof e=="string"?e:"Connect Wallet",children:[ge(xs,{}),ge("span",{className:"cb-button-label",children:e})]})]})}function xs(){return ge("svg",{className:"cb-button-icon",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:ge("path",{d:"M11.4368 10.5007C11.4368 9.9538 11.6544 9.42855 12.041 9.04175C12.4278 8.65492 12.9529 8.4375 13.5 8.4375H15.1875V6.00073L15.1732 5.92822C15.1639 5.90585 15.15 5.88528 15.1326 5.8678C15.0973 5.83263 15.0494 5.81287 14.9996 5.81287H3.74963C3.4787 5.81287 3.21001 5.75949 2.95972 5.65576C2.90937 5.63488 2.86089 5.61017 2.8125 5.58545V14.2504C2.8125 14.4989 2.91141 14.7371 3.08716 14.9128C3.2629 15.0886 3.50109 15.1875 3.74963 15.1875H15.0007C15.0252 15.1875 15.0495 15.1826 15.0721 15.1732C15.0948 15.1638 15.1152 15.1499 15.1326 15.1326C15.1499 15.1152 15.1638 15.0948 15.1732 15.0721C15.1826 15.0495 15.1875 15.0252 15.1875 15.0007V12.5629H13.5C12.9529 12.5629 12.4278 12.3454 12.041 11.9586C11.6545 11.5719 11.4369 11.0475 11.4368 10.5007ZM12.5618 10.5007C12.5619 10.7491 12.6609 10.9875 12.8364 11.1632C13.0123 11.3391 13.2513 11.4379 13.5 11.4379H15.75C15.7998 11.4379 15.8477 11.4182 15.8829 11.3829C15.9182 11.3477 15.9379 11.2998 15.9379 11.25V9.75037C15.9379 9.70054 15.9182 9.65266 15.8829 9.61743C15.8477 9.5822 15.7998 9.5625 15.75 9.5625H13.5C13.2513 9.5625 13.0123 9.66131 12.8364 9.83716C12.6607 10.013 12.5618 10.2522 12.5618 10.5007ZM13.6879 3.00037C13.6879 2.95054 13.6682 2.90266 13.6329 2.86743C13.5977 2.8322 13.5498 2.8125 13.5 2.8125H3.74963C3.50109 2.8125 3.2629 2.91141 3.08716 3.08716C2.91141 3.2629 2.8125 3.50109 2.8125 3.74963L2.81689 3.84192C2.82585 3.93354 2.8486 4.02351 2.88391 4.10889C2.93096 4.22263 3.00015 4.32614 3.08716 4.41321C3.17403 4.50009 3.2769 4.56936 3.39038 4.61646C3.50412 4.66359 3.62651 4.68787 3.74963 4.68787H13.6879V3.00037ZM14.8129 4.68787H14.9996C15.3473 4.68787 15.6808 4.82576 15.9269 5.07129C16.173 5.31702 16.3119 5.65077 16.3125 5.99854V8.56494C16.4469 8.62873 16.5711 8.7148 16.6783 8.82202C16.9246 9.06823 17.0629 9.40217 17.0629 9.75037V11.25C17.0629 11.5982 16.9246 11.9321 16.6783 12.1783C16.5712 12.2855 16.4468 12.3706 16.3125 12.4343V14.9985L16.3059 15.1282C16.2934 15.2564 16.2619 15.3822 16.2125 15.5017C16.1466 15.6612 16.05 15.806 15.928 15.928C15.806 16.05 15.6612 16.1466 15.5017 16.2125C15.3425 16.2783 15.1719 16.3126 14.9996 16.3125H3.74963C3.20272 16.3125 2.67847 16.095 2.29175 15.7083C1.90502 15.3215 1.6875 14.7973 1.6875 14.2504V3.74963C1.6875 3.20272 1.90502 2.67847 2.29175 2.29175C2.67847 1.90502 3.20272 1.6875 3.74963 1.6875H13.5C13.8482 1.6875 14.1821 1.82581 14.4283 2.07202C14.6746 2.31823 14.8129 2.65217 14.8129 3.00037V4.68787Z",fill:"currentColor"})})}var vs=`
|
|
3
|
-
[data-crossx-wallet-info="external"] .wi-select-wallet-btn {
|
|
4
|
-
display: none !important;
|
|
5
|
-
}
|
|
6
|
-
`;function $n(e){return`${e.slice(0,6)}...${e.slice(-4)}`}var zt=`
|
|
7
|
-
.cb-button {
|
|
8
|
-
-webkit-font-smoothing: antialiased;
|
|
9
|
-
--cb-bg: var(--ds-accent-primary-default, #00D5AA);
|
|
10
|
-
--cb-bg-hover: var(--ds-accent-primary-high, #00a0a2);
|
|
11
|
-
--cb-color: var(--ds-accent-primary-on, #000);
|
|
12
|
-
--cb-border: none;
|
|
13
|
-
--cb-radius: 8px;
|
|
14
|
-
--cb-height: 36px;
|
|
15
|
-
--cb-padding: 0 16px;
|
|
16
|
-
--cb-font-family: Inter, system-ui, -apple-system, sans-serif;
|
|
17
|
-
--cb-font-size: 14px;
|
|
18
|
-
--cb-font-weight: 500;
|
|
19
|
-
--cb-gap: 8px;
|
|
20
|
-
--cb-transition: background-color 0.15s ease, transform 0.1s ease;
|
|
21
|
-
--cb-loading-opacity: 0.7;
|
|
22
|
-
--cb-press-scale: 0.95;
|
|
23
|
-
--cb-spinner-size: 14px;
|
|
24
|
-
--cb-spinner-thumb: currentColor;
|
|
25
|
-
--cb-spinner-track: color-mix(in srgb, currentColor 20%, transparent);
|
|
26
|
-
--cb-icon-size: 18px;
|
|
27
|
-
|
|
28
|
-
display: inline-flex;
|
|
29
|
-
align-items: center;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
box-sizing: border-box;
|
|
32
|
-
height: var(--cb-height);
|
|
33
|
-
gap: var(--cb-gap);
|
|
34
|
-
padding: var(--cb-padding);
|
|
35
|
-
border-radius: var(--cb-radius);
|
|
36
|
-
border: var(--cb-border);
|
|
37
|
-
background: var(--cb-bg);
|
|
38
|
-
color: var(--cb-color);
|
|
39
|
-
font-family: var(--cb-font-family);
|
|
40
|
-
font-size: var(--cb-font-size);
|
|
41
|
-
font-weight: var(--cb-font-weight);
|
|
42
|
-
cursor: pointer;
|
|
43
|
-
transition: var(--cb-transition);
|
|
44
|
-
}
|
|
45
|
-
.cb-button:hover:not(:disabled) { background: var(--cb-bg-hover); }
|
|
46
|
-
.cb-button:active:not(:disabled) { transform: scale(var(--cb-press-scale)); }
|
|
47
|
-
.cb-button:disabled, .cb-button[aria-busy="true"] {
|
|
48
|
-
cursor: default;
|
|
49
|
-
opacity: var(--cb-loading-opacity);
|
|
50
|
-
}
|
|
51
|
-
.cb-spinner {
|
|
52
|
-
display: inline-block;
|
|
53
|
-
width: var(--cb-spinner-size);
|
|
54
|
-
height: var(--cb-spinner-size);
|
|
55
|
-
border: 2px solid var(--cb-spinner-track);
|
|
56
|
-
border-top-color: var(--cb-spinner-thumb);
|
|
57
|
-
border-radius: 50%;
|
|
58
|
-
animation: cck-cb-spin 0.6s linear infinite;
|
|
59
|
-
flex-shrink: 0;
|
|
60
|
-
}
|
|
61
|
-
.cb-button-icon {
|
|
62
|
-
width: var(--cb-icon-size);
|
|
63
|
-
height: var(--cb-icon-size);
|
|
64
|
-
flex-shrink: 0;
|
|
65
|
-
}
|
|
66
|
-
.cb-button-label { white-space: nowrap; }
|
|
67
|
-
.cb-pill {
|
|
68
|
-
--cb-pill-bg: var(--ds-surface-default, #1e232e);
|
|
69
|
-
--cb-pill-bg-hover: var(--ds-surface-medium, #252b39);
|
|
70
|
-
--cb-pill-color: var(--ds-content-high, #ffffffd9);
|
|
71
|
-
--cb-pill-border: 1px solid var(--ds-border-default, #ffffff12);
|
|
72
|
-
--cb-pill-border-hover: 1px solid var(--ds-border-medium, #ffffff2e);
|
|
73
|
-
--cb-pill-radius: 8px;
|
|
74
|
-
--cb-pill-height: 36px;
|
|
75
|
-
--cb-pill-padding: 0 12px;
|
|
76
|
-
--cb-pill-press-scale: 0.95;
|
|
77
|
-
--cb-pill-font-family: Inter, system-ui, -apple-system, sans-serif;
|
|
78
|
-
--cb-pill-font-size: 14px;
|
|
79
|
-
--cb-pill-font-weight: 500;
|
|
80
|
-
--cb-pill-gap: 8px;
|
|
81
|
-
--cb-pill-icon-size: 20px;
|
|
82
|
-
--cb-pill-icon-placeholder-bg: var(--ds-surface-high, #2a2d3a);
|
|
83
|
-
--cb-pill-address-font: Inter, system-ui, -apple-system, sans-serif;
|
|
84
|
-
--cb-pill-address-font-size: 14px;
|
|
85
|
-
--cb-pill-address-letter-spacing: -0.01em;
|
|
86
|
-
|
|
87
|
-
display: inline-flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
box-sizing: border-box;
|
|
90
|
-
height: var(--cb-pill-height);
|
|
91
|
-
gap: var(--cb-pill-gap);
|
|
92
|
-
padding: var(--cb-pill-padding);
|
|
93
|
-
border-radius: var(--cb-pill-radius);
|
|
94
|
-
border: var(--cb-pill-border);
|
|
95
|
-
background: var(--cb-pill-bg);
|
|
96
|
-
color: var(--cb-pill-color);
|
|
97
|
-
font-family: var(--cb-pill-font-family);
|
|
98
|
-
font-size: var(--cb-pill-font-size);
|
|
99
|
-
font-weight: var(--cb-pill-font-weight);
|
|
100
|
-
cursor: pointer;
|
|
101
|
-
}
|
|
102
|
-
.cb-pill:hover,
|
|
103
|
-
.cb-pill[data-state="open"] { background: var(--cb-pill-bg-hover); border: var(--cb-pill-border-hover, 1px solid var(--ds-border-medium, #ffffff2e)); }
|
|
104
|
-
.cb-pill:active:not(:disabled) { transform: scale(var(--cb-pill-press-scale)); }
|
|
105
|
-
.cb-pill-icon {
|
|
106
|
-
width: var(--cb-pill-icon-size);
|
|
107
|
-
height: var(--cb-pill-icon-size);
|
|
108
|
-
border-radius: 50%;
|
|
109
|
-
object-fit: contain;
|
|
110
|
-
flex-shrink: 0;
|
|
111
|
-
background: transparent;
|
|
112
|
-
}
|
|
113
|
-
/* Apple is a monochrome black logomark in an <img> data URI (can't follow
|
|
114
|
-
theme via currentColor). Flip it to white in dark mode so it stays
|
|
115
|
-
visible on the dark pill; multicolor marks (Google/MetaMask/Binance/
|
|
116
|
-
CROSSx) are untouched. */
|
|
117
|
-
[data-theme="dark"] .cb-pill-icon[data-provider="apple"] {
|
|
118
|
-
filter: invert(1);
|
|
119
|
-
}
|
|
120
|
-
.cb-pill-icon-placeholder {
|
|
121
|
-
display: inline-block;
|
|
122
|
-
width: var(--cb-pill-icon-size);
|
|
123
|
-
height: var(--cb-pill-icon-size);
|
|
124
|
-
border-radius: 50%;
|
|
125
|
-
background: var(--cb-pill-icon-placeholder-bg);
|
|
126
|
-
flex-shrink: 0;
|
|
127
|
-
}
|
|
128
|
-
.cb-pill-address {
|
|
129
|
-
font-family: var(--cb-pill-address-font);
|
|
130
|
-
font-size: var(--cb-pill-address-font-size);
|
|
131
|
-
letter-spacing: var(--cb-pill-address-letter-spacing);
|
|
132
|
-
}
|
|
133
|
-
@media (max-width: 767.98px) {
|
|
134
|
-
.cb-button, .cb-pill {
|
|
135
|
-
width: 36px;
|
|
136
|
-
min-width: 36px;
|
|
137
|
-
padding: 0;
|
|
138
|
-
}
|
|
139
|
-
.cb-button-label, .cb-pill-address { display: none; }
|
|
140
|
-
}
|
|
141
|
-
@keyframes cck-cb-spin {
|
|
142
|
-
to { transform: rotate(360deg); }
|
|
143
|
-
}
|
|
144
|
-
`;import{useCallback as Qn,useEffect as Ps,useMemo as zn,useState as Ss}from"react";import{detectWallets as Xn,DEFAULT_WALLET_REGISTRY as Yn}from"@nexus-cross/connect-kit-wagmi";import{jsx as ae,jsxs as Le}from"react/jsx-runtime";var Rs=["Ensure your wallet extension is installed and unlocked","Try refreshing the page","Some wallets may require you to first open the extension","You can try clicking the wallet anyway"],As="Connect with one of our available wallet providers to continue.";function Bs({open:e,onClose:t,onSelect:n,title:i="Connect Wallet",description:o=As,troubleshootingTips:c=Rs}){let{availableWallets:g}=Be(),[y,u]=Ss({});Ps(()=>{if(!e)return;let p=Xn(Yn),k={};for(let v of p)v.installed!==void 0&&(k[v.id]=v.installed);u(k);let x=setTimeout(()=>{let v=Xn(Yn),W={};for(let I of v)I.installed!==void 0&&(W[I.id]=I.installed);u(W)},1e3);return()=>clearTimeout(x)},[e]);let r=zn(()=>typeof navigator>"u"?!1:/Mobi|Android/i.test(navigator.userAgent),[]),m=zn(()=>r?g.filter(p=>p.type!=="extension"):g,[g,r]),h=Qn(p=>{if(!y[p.walletId]&&p.installUrl&&p.type==="extension"){window.open(p.installUrl,"_blank");return}t(),n(p.walletId)},[t,n,y]),C=Qn((p,k)=>{p.stopPropagation(),t(),window.open(k,"_blank")},[t]);return e?ae("div",{style:Q.overlay,onClick:t,children:Le("div",{style:Q.modal,onClick:p=>p.stopPropagation(),children:[Le("div",{style:Q.header,children:[ae("h2",{style:Q.title,children:i}),ae("button",{type:"button",onClick:t,style:Q.closeBtn,"aria-label":"Close",children:Le("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[ae("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ae("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),ae("p",{style:Q.desc,children:o}),ae("div",{style:Q.walletList,children:m.map(p=>{let k=y[p.walletId],x=k===!1&&p.type==="extension"&&!!p.installUrl;return Le("div",{style:Q.walletGroup,children:[Le("button",{type:"button",onClick:()=>h(p),style:{...Q.walletItem,...p.walletId==="cross_wallet"?Q.walletItemAccent:{}},"aria-label":`Connect with ${p.name}`,children:[p.iconUrl?ae("img",{src:p.iconUrl,alt:"",style:Q.walletIcon}):ae("div",{style:Q.walletIconPlaceholder}),Le("div",{style:Q.walletInfo,children:[Le("div",{style:Q.walletNameRow,children:[ae("span",{style:Q.walletName,children:p.name}),k!==void 0&&ae("span",{style:{...Q.badge,...k?Q.badgeInstalled:Q.badgeNotInstalled},children:k?"Installed":"Not Installed"})]}),ae("span",{style:Q.walletDesc,children:x?"Extension not detected \u2014 click to install":p.type==="extension"?"Browser extension approval is required":p.walletId==="cross_wallet"?"App approval is required":p.walletId==="binance"?"Mobile app only \u2014 Add CROSS network first":k?"Connect with browser extension":"Scan QR code with app"})]})]}),p.guideUrl&&Le("button",{type:"button",onClick:v=>C(v,p.guideUrl),style:Q.guideBtn,children:[ae("span",{"aria-hidden":"true",children:"\u26A0\uFE0F"}),p.guideLabel??"Required Settings"]})]},p.walletId)})}),Le("div",{style:Q.troubleshoot,children:[ae("h3",{style:Q.troubleshootTitle,children:"Wallet not detected?"}),ae("ul",{style:Q.troubleshootList,children:c.map(p=>Le("li",{style:Q.troubleshootItem,children:[ae("span",{style:Q.troubleshootDot,"aria-hidden":"true"}),ae("span",{children:p})]},p))})]})]})}):null}var ee={surfaceBg:"var(--wi-surface-bg, #121212)",surfaceDefault:"var(--wi-surface-default, rgba(255,255,255,0.05))",surfaceSubtle:"var(--wi-surface-subtle, rgba(255,255,255,0.1))",borderDefault:"var(--wi-border-default, rgba(255,255,255,0.05))",textPrimary:"var(--wi-texticon-primary, #ffffff)",textSecondary:"var(--wi-texticon-secondary, rgba(255,255,255,0.7))",textTertiary:"var(--wi-texticon-tertiary, rgba(255,255,255,0.5))",primary:"var(--wi-primary, #019d92)",primarySoft:"var(--crossx-kit-primary-soft, rgba(1,157,146,0.15))",accentGradient:"var(--crossx-kit-accent-gradient, linear-gradient(113deg, rgba(255,255,255,0.05) 0%, rgba(1,157,146,0.12) 70%, rgba(255,255,255,0.05) 70%, rgba(1,157,146,0.12) 80%, rgba(255,255,255,0.05) 80%))",warningBg:"var(--crossx-kit-warning-bg, rgba(245,158,11,0.1))",warningBorder:"var(--crossx-kit-warning-border, rgba(245,158,11,0.25))",warningText:"var(--crossx-kit-warning-text, #fbbf24)"},Q={overlay:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)"},modal:{width:"100%",maxWidth:"420px",margin:"16px",background:ee.surfaceBg,border:`1px solid ${ee.borderDefault}`,borderRadius:"20px",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 0"},title:{fontSize:"18px",fontWeight:700,color:ee.textPrimary,margin:0},closeBtn:{background:"none",border:"none",color:ee.textTertiary,cursor:"pointer",padding:"4px",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center"},desc:{padding:"8px 24px 16px",fontSize:"13px",color:ee.textTertiary,margin:0,lineHeight:1.5},walletList:{display:"flex",flexDirection:"column",gap:"6px",padding:"0 12px 12px"},walletGroup:{display:"flex",flexDirection:"column",borderRadius:"12px",overflow:"hidden",background:ee.surfaceDefault},walletItem:{display:"flex",alignItems:"center",gap:"14px",width:"100%",padding:"14px",background:"transparent",border:"none",color:ee.textPrimary,cursor:"pointer",textAlign:"left"},walletItemAccent:{background:ee.accentGradient},walletIcon:{width:"40px",height:"40px",borderRadius:"10px",flexShrink:0},walletIconPlaceholder:{width:"40px",height:"40px",borderRadius:"10px",background:ee.surfaceSubtle,flexShrink:0},walletInfo:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"3px"},walletNameRow:{display:"flex",alignItems:"center",gap:"8px"},walletName:{fontSize:"15px",fontWeight:700,lineHeight:1.3,color:ee.textPrimary},badge:{fontSize:"10px",fontWeight:600,padding:"2px 7px",borderRadius:"99px",lineHeight:1},badgeInstalled:{background:ee.primarySoft,color:ee.primary},badgeNotInstalled:{background:"rgba(255,255,255,0.05)",color:ee.textTertiary},walletDesc:{fontSize:"11px",color:ee.textSecondary,lineHeight:1.3},guideBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",margin:"0 14px 14px",padding:"10px 12px",borderRadius:"10px",border:`1px solid ${ee.warningBorder}`,background:ee.warningBg,color:ee.warningText,fontWeight:600,fontSize:"13px",cursor:"pointer"},troubleshoot:{margin:"0 12px 16px",background:ee.surfaceDefault,borderRadius:"12px",padding:"14px 16px"},troubleshootTitle:{fontSize:"12px",fontWeight:700,color:ee.textPrimary,margin:"0 0 8px"},troubleshootList:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"8px"},troubleshootItem:{display:"flex",alignItems:"flex-start",gap:"8px",fontSize:"11px",color:ee.textSecondary,lineHeight:1.5},troubleshootDot:{flexShrink:0,width:"4px",height:"4px",marginTop:"6px",borderRadius:"50%",background:ee.textSecondary}};import{useEffect as _s,useMemo as Zn}from"react";import{useAccount as Es,useConfig as Os,useSendTransaction as Ns,useSwitchChain as Ws,useWriteContract as Fs}from"wagmi";import{getBalance as Ds,readContract as Ls,readContracts as Gs,waitForTransactionReceipt as Ms}from"wagmi/actions";import{RelayDeposit as Zt}from"@nexus-cross/dapp-ui";import{jsx as Hs}from"react/jsx-runtime";var Us=56,Ks=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{name:"",type:"string"}]}],at=e=>e,Jn=!1;function ft(){let{address:e,chainId:t}=Es(),n=Os(),{sendTransactionAsync:i}=Ns(),{writeContractAsync:o}=Fs(),{switchChainAsync:c}=Ws(),g=n.chains.some(u=>u.id===Us);_s(()=>{g||Jn||(Jn=!0,console.warn("[connect-kit] CrossRelayDeposit: BNB Smart Chain (56) is not in the wagmi config \u2014 one-click deposit verification and fund recovery are disabled. Add `bsc` to `createCrossxConfig({ networks })` to enable them."))},[g]);let y=Zn(()=>({sendTransaction:async({chainId:u,to:r,value:m,data:h})=>i({chainId:at(u),to:r,value:m,data:h}),writeContract:async({chainId:u,address:r,abi:m,functionName:h,args:C})=>o({chainId:at(u),address:r,abi:m,functionName:h,args:C}),readContract:g?async({chainId:u,address:r,abi:m,functionName:h,args:C})=>Ls(n,{chainId:at(u),address:r,abi:m,functionName:h,args:C}):void 0,switchChain:async u=>{await c({chainId:at(u)})},waitForReceipt:async({chainId:u,hash:r})=>({status:(await Ms(n,{chainId:at(u),hash:r})).status==="success"?"success":"reverted"}),getBalance:async({chainId:u,address:r,token:m})=>{if(!m){let v=await Ds(n,{chainId:at(u),address:r});return{value:v.value,decimals:v.decimals,symbol:v.symbol}}let h={address:m,abi:Ks,chainId:at(u)},C=await Gs(n,{contracts:[{...h,functionName:"balanceOf",args:[r]},{...h,functionName:"decimals"},{...h,functionName:"symbol"}],allowFailure:!1}),[p,k,x]=C;return{value:p,decimals:k,symbol:x}}}),[n,g,i,o,c]);return Zn(()=>({walletAddress:e,walletChainId:t,...y}),[e,t,y])}function $s(e){let t=ft();return Hs(Zt,{...t,...e,requireWalletConnection:!0})}var qs=Object.assign($s,{Trigger:Zt.Trigger,Content:Zt.Content});import{useCallback as Vs,useMemo as eo}from"react";import{useAccount as js,useConfig as Qs}from"wagmi";import{waitForTransactionReceipt as zs}from"wagmi/actions";import{GetOneUsd as Xs,resolveEnvironment as Ys}from"@nexus-cross/dapp-ui";import{jsx as Js}from"react/jsx-runtime";function Zs({env:e,pairs:t,bridgeOptions:n,relay:i,restoreChainAfterSwitch:o=!0,waitForTransaction:c,onRequestConnect:g,...y}){let u=Ys(e),{address:r}=js(),m=Qs(),{connectWallet:h}=Be(),C=ft(),p=Ct({env:u,walletAddress:r,enabled:!0,restoreChainAfterSwitch:o}),{bridgeHistory:k,getBridgeQuote:x,getBridgeToTokens:v,getBridgeApproval:W,approveBridge:I,submitBridge:U}=p,D=eo(()=>({...n,history:k,getQuote:x,getToTokens:v,getApproval:W,approveBridge:I,submitBridge:U}),[I,k,n,W,x,v,U]),O=eo(()=>({...i,...C}),[i,C]),q=Vs(async $=>{if((await zs(m,{hash:$.txHash,chainId:$.fromToken.chainId})).status!=="success")throw new Error("Transaction reverted.")},[m]);return Js(Xs,{...y,env:u,walletAddress:r,tokens:p.bridgeTokens,pairs:t??p.oneUsdPairs,loading:p.isLoading,bridge:D,relay:O,waitForTransaction:c??q,onRequestConnect:g??h})}import{useAccount as ei}from"wagmi";import{RelayHistory as Jt}from"@nexus-cross/dapp-ui";import{jsx as oi}from"react/jsx-runtime";function ti(e){let{address:t}=ei();return oi(Jt,{walletAddress:t,...e})}var ni=Object.assign(ti,{Trigger:Jt.Trigger,Content:Jt.Content});import{RelayRecovery as en}from"@nexus-cross/dapp-ui";import{jsx as ii}from"react/jsx-runtime";function ri(e){let t=ft();return ii(en,{...t,...e})}var si=Object.assign(ri,{Trigger:en.Trigger,Content:en.Content});import{useContext as ai,useEffect as ci,useRef as di}from"react";function li(e){let t=ai(vt);if(!t)throw new Error("useConnectKitAnalytics must be used within <CrossConnectKitProvider>");let n=di(e);n.current=e;let{subscribe:i}=t;ci(()=>i(c=>n.current(c)),[i])}import{useOnRamp as uc,useOnRampEligibility as pc,OnRampProvider as mc}from"@nexus-cross/onramp/react";import{useKyc as gc,useOptionalKyc as yc,KycProvider as bc,KycError as hc,launchKycVerification as wc}from"@nexus-cross/kyc/react";import{WalletInfo as kc,ConnectorId as Tc}from"@nexus-cross/dapp-ui";import{AppLauncher as xc,AppLauncherTrigger as vc,AppLauncherContent as Pc,useGlobalMenu as Sc}from"@nexus-cross/dapp-ui";import{SkillsButton as Ac}from"@nexus-cross/dapp-ui";import{createRelayClient as _c,RelayApiError as Ec,DEFAULT_TRUSTED_FACTORIES as Oc,useRelayConfig as Nc,useRelayOrders as Wc,useRelayRecovery as Fc}from"@nexus-cross/dapp-ui";import{OnRampError as Lc}from"@nexus-cross/connect-kit-core";import{ConnectionStatus as Mc,formatBalance as Uc,formatWei as Kc}from"@nexus-cross/connect-kit-core";an();export{Be as a,ko as b,yt as c,Lt as d,Jo as e,Ct as f,Ht as g,Is as h,Bs as i,ft as j,qs as k,Zs as l,ni as m,si as n,li as o,uc as p,pc as q,mc as r,gc as s,yc as t,bc as u,hc as v,wc as w,kc as x,Tc as y,xc as z,vc as A,Pc as B,Sc as C,Ac as D,_c as E,Ec as F,Oc as G,Nc as H,Wc as I,Fc as J,Lc as K,Mc as L,Uc as M,Kc as N};
|