8 lines
3.3 KiB
JavaScript
8 lines
3.3 KiB
JavaScript
import{e as L,g as $}from"./chunk-LU2D434E.js";import{f as O,g as U,i as j}from"./chunk-CFT2L6ZK.js";import{a as k}from"./chunk-RBSWB7WT.js";import{a as D}from"./chunk-BLOI6ELB.js";import{f as V}from"./chunk-PICDHKDX.js";import{a as b}from"./chunk-FKDP23RV.js";import{o as G}from"./chunk-64WUUNDB.js";import{Kb as x,Lb as E,f as P,jc as K}from"./chunk-QY24TFF7.js";import{J as W,ia as J}from"./chunk-I5E2ION7.js";import{ma as F,ra as I}from"./chunk-GSIHKWLV.js";import{b as A}from"./chunk-BF2V36QE.js";import{f as C,o as T,q as g}from"./chunk-QTLWQ5AJ.js";T();g();var f=C(A()),h=C(K()),y=C(G());I();T();g();function N(e,r){return async n=>(await n(O({walletIds:e,chainId:r}))).map(a=>({walletId:a?.walletId,balanceData:a?.balanceData,coinsMap:a?.coins.reduce((o,s)=>(o[s.coinId]=s,o),{})}))}async function _(e,r){return(await r(N([e]))).find(t=>t.walletId===e)}function Z({walletIds:e,chainId:r,coinId:n,flatten:t=!1}){return async a=>{let o=await a(j({walletIds:e,chainId:r,coinId:n})),s={};return o.forEach(u=>{let i=u.coins.reduce((c,p)=>(c[p.coinId]=p,c),{}),M=u.balanceCoins,l=[],d=["walletId","default"];M.forEach(c=>{if(c.childrenCoin){let p=c.childrenCoin.map(m=>({...m,...i[m.coinId]}));t?(p.forEach(m=>{d.forEach(B=>{m[B]=c[B]})}),l.push(...p)):l.push({...c,...i[c.coinId],childrenCoin:p})}else l.push({...c,...i[c.coinId]})}),s[u.walletId]=l}),s}}function v(e,r,{defaultValue:n,forceRequest:t}={}){let a=(0,h.useDispatch)(),o=k(),{data:s,error:u,loading:i,run:M}=(0,y.useRequest)(_,{manual:!0,cacheKey:r}),l=!!u,d=r!==o||t;(0,f.useEffect)(()=>{r&&d&&M(r,a)},[r,d,a]);let c=(0,y.useMemoizedFn)(async()=>{r&&d?M(r,a):await a(U())});return(0,f.useMemo)(()=>m=>{if(r&&d)return{data:s?e(m,r,s):n,loading:i,error:l,request:c};let B=e(m,o);return{data:B??n,loading:!B?.[o],error:!!B?.[o]?.error,request:c}},[e,r,o,s,n,l,i,d])}var H=(e,r={})=>{let n=(0,f.useRef)({}),t=r.withBalanceStatus,a=v(L,e,{defaultValue:n.current,forceRequest:t}),{data:o,loading:s,error:u,request:i}=(0,h.useSelector)(a);return(0,y.useCreation)(()=>t?{loading:s,error:u,request:i,balance:o[e]}:o[e],[o,e,t,s,u,i])},le=e=>{let r=H(e),t=((0,h.useSelector)(P)[e]??[]).map(a=>V(a));return F([...r?.coins??[],...t],a=>`${a.coinId}_${"addressType"in a?a.addressType:0}`)},Q=()=>{let e=k();return H(e)},de=()=>Q()?.coins??[];function pe(e){let r=(0,f.useRef)([]),n=v($,e,{defaultValue:r.current});return(0,h.useSelector)(n).data}T();g();var q=C(A()),R=C(K()),w=C(G());J();var ye=e=>(0,R.useSelector)(E).find(({currencyId:t})=>t===e)||{},X={},S=()=>{let{data:e}=D(b.coinTickers);return(0,q.useMemo)(()=>e||X,[e])},Me=()=>{let e=S(),r=(0,R.useSelector)(x);return(0,w.useCreation)(()=>Object.keys(e).reduce((n,t)=>(n[t]=W(e?.[t]?.coinToUSDRate,r?.usdToThisRate),n),{}),[e,r?.usdToThisRate])},Re=()=>{let e=S();return(0,w.useCreation)(()=>Object.keys(e).reduce((r,n)=>(r[n]=e?.[n]?.coinToUSDRate,r),{}),[e])},Se=e=>{let r=S(),n=(0,R.useSelector)(x),t=r?.[e]?.coinToUSDRate;return(0,q.useMemo)(()=>W(t,n?.usdToThisRate),[t,n?.usdToThisRate])},We=e=>S()?.[e]?.coinToUSDRate,xe=e=>{let{data:r}=D(b.coinTickers);return r?.[e]?.coinPriceChangePercent24h};export{Z as a,H as b,le as c,de as d,pe as e,ye as f,S as g,Me as h,Re as i,Se as j,We as k,xe as l};
|
|
|
|
window.inOKXExtension = true;
|
|
window.inMiniApp = false;
|
|
window.ASSETS_BUILD_TYPE = "publish";
|
|
|
|
//# sourceMappingURL=chunk-3KQ34RWP.js.map
|