-
Notifications
You must be signed in to change notification settings - Fork 0
/
7024.async.js
1 lines (1 loc) · 12.2 KB
/
7024.async.js
1
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[7024],{7024:function(e,t,n){n.r(t);var r=n(97857),a=n.n(r),s=n(15009),o=n.n(s),c=n(99289),l=n.n(c),i=n(5574),u=n.n(i),f=n(9554),p=n(3990),d=n(64119),h=n(11774),m=n(38345),g=n(59530),b=n(80507),k=n(45360),v=n(69677),y=n(57953),x=n(92398),N=n(9669),S=n.n(N),w=n(27484),j=n.n(w),P=n(96486),_=n(62435),L=(n(31145),n(86074));t.default=function(){var e=k.ZP.useMessage(),t=u()(e,2),n=t[0],r=t[1],s=(0,g.useDispatch)(),c=(0,g.useSelector)((function(e){return e.global.session})),i=(0,g.useSelector)((function(e){return e.global.contractKit})),N=(0,g.useSelector)((function(e){return e.global.accountKit})),w=(0,g.useSelector)((function(e){return e.account.activeKey})),V=(0,g.useSelector)((function(e){return e.account.accountInfo})),O=(0,g.useSelector)((function(e){return e.account.loading})),T=(0,g.useSelector)((function(e){return e.account.approvals2})),D=(0,g.useSelector)((function(e){return e.account.proposals})),M=(0,g.useSelector)((function(e){return e.global.tokenContracts})),C=(0,_.useRef)(),E=(0,_.useState)(""),I=u()(E,2),q=I[0],z=I[1],A=(0,g.useSearchParams)(),K=u()(A,2),F=K[0],R=K[1],Z=F.get("tab")?F.get("tab"):void 0,U=(0,g.useIntl)(),B=U.formatMessage({id:"account.intlAccount"}),$=U.formatMessage({id:"account.intlSearch"}),G=U.formatMessage({id:"contract.intlAccountFormatError"}),Y=U.formatMessage({id:"account.intlSearchAccount"}),H=U.formatMessage({id:"account.intlProfile"}),J=U.formatMessage({id:"account.intlAuth"}),Q=U.formatMessage({id:"account.intlToken"}),W=U.formatMessage({id:"account.intlNft"}),X=U.formatMessage({id:"account.intlLiq"}),ee=U.formatMessage({id:"account.intlTx"}),te=U.formatMessage({id:"account.intlProposal"}),ne=U.formatMessage({id:"account.intlInvite"}),re=(0,_.useMemo)((function(){return V?V.accountName.toString():""}),[V]),ae=(0,_.useCallback)(function(){var e=l()(o()().mark((function e(t,r){var a,l,i,f;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(/^[a-z1-5.]{1,12}$/.test(t)){e.next=8;break}if(t||r.hasOwnProperty("type")){e.next=4;break}return e.abrupt("return",!1);case 4:return n.error("".concat(G)),e.abrupt("return",!1);case 8:return e.next=10,(0,d.zI)(c.client.v1.chain.get_abi(t));case 10:if(a=e.sent,l=u()(a,2),i=l[0],f=l[1],!i){e.next=17;break}return n.error(i),e.abrupt("return",!1);case 17:return!i&&f.hasOwnProperty("abi")?s(p.N.setIsContract(!0)):s(p.N.setIsContract(!1)),e.abrupt("return",!0);case 19:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),[c,n]),se=(0,_.useCallback)(function(){var e=l()(o()().mark((function e(t,n,r){var c,l,i,u;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c=[],l={},i={},n.forEach((function(e){var n=e.max_token_supply.symbol.name,r=e.init_nft_price.symbol.name,a=e.id,s=e.nft_img,o=e.project_name,c="";"DFS"===r?c="eosio.token-DFS-8":"USDT"===r?c="usdtusdtusdt-USDT-8":"ORDI"===r&&(c="ordiordiordi-ORDI-8");var l=t[c];i[a]={logo:s,sym:n,price:l,name:o}})),r.forEach((function(e){var t=e.pid.toString(),n=e.current_price.value,r=i[t].price*n,a=i[t].name;l.hasOwnProperty(t)?(l[t].count+=1,l[t].value+=r):l[t]={count:1,value:r,logo:i[t].logo,sym:i[t].sym,name:a}})),u=0,Object.keys(l).forEach((function(e){u+=l[e].value,c.push(a()({pid:e},l[e]))})),c.sort((function(e,t){return t.value-e.value})),s(p.N.setNfts(c)),s(p.N.setNftsValue(u)),s(p.N.setNftsLoading(!1));case 11:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),[]),oe=(0,_.useCallback)(function(){var e=l()(o()().mark((function e(t,r,a,c,l,i){var u,f,h,m,g,b,k,v,y,x,N,S,w,P,_,L;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,u=[],h={},m=[],g=[],b=0,k={balValue:0,reserveValue:0,diffValue:0},"usdtusdtusdt-USDT-8",v="eosio.token-DFS-8",y=[],(f={})["usdtusdtusdt-USDT-8"]=1,f[v]=(0,d.ri)(a[0].reserve0)/(0,d.ri)(a[0].reserve1),a.forEach((function(e){var t=e.contract0.toString()+"-"+e.sym0.toString().split(",")[1]+"-"+e.sym0.toString().split(",")[0],n=e.contract1.toString()+"-"+e.sym1.toString().split(",")[1]+"-"+e.sym1.toString().split(",")[0];u.includes(t)||(u.push(t),h[t]=u.length),u.includes(n)||(u.push(n),h[n]=u.length);var r=(0,d.ri)(e.reserve0),a=(0,d.ri)(e.reserve1);"eosio.token"===e.contract0.toString()?f.hasOwnProperty(n)||(f[n]=r/a*f[v]):"eosio.token"===e.contract1.toString()?f.hasOwnProperty(t)||(f[t]=a/r*f[v]):"usdtusdtusdt"===e.contract0.toString()?f.hasOwnProperty(n)||(f[n]=r/a):"usdtusdtusdt"===e.contract1.toString()?f.hasOwnProperty(t)||(f[t]=a/r):y.push({key0:t,key1:n,value0:r,value1:a})})),y.forEach((function(e){f.hasOwnProperty(e.key0)&&!f.hasOwnProperty(e.key1)?f[e.key1]=e.value0/e.value1*f[e.key0]:!f.hasOwnProperty(e.key0)&&f.hasOwnProperty(e.key1)?f[e.key0]=e.value1/e.value0*f[e.key1]:f.hasOwnProperty(e.key0)||f.hasOwnProperty(e.key1)||(f[e.key0]=0,f[e.key1]=0),Number.isNaN(f[e.key0])&&(f[e.key0]=0)})),Object.keys(f).forEach((function(e){Number.isNaN(f[e])&&(f[e]=0)})),f["dfs3protocol-DFS-8"]=0,x={},c.forEach((function(e){var t=e.max_token_supply.symbol.name;x[t]=e.token_url})),se(f,c,l),N=[],M.forEach((function(e){N.push(t.client.v1.chain.get_currency_balance(e,i))})),e.next=24,Promise.all(N);case 24:S=e.sent,w=o()().mark((function e(t){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(S[t].length){e.next=2;break}return e.abrupt("return",1);case 2:S[t].forEach((function(e){if((0,d.ri)(e)){var n=e.symbol.precision.toString(),r=e.symbol.name,a=M[t],s=a+"-"+r,o="".concat(s,"-").concat(n),c=f[o],l=(0,d.ri)(e)*c,i="dfsppptokens"===a?x[r]:"https://dfs.land/assets/tokens/".concat(s,".png");b+=l,m.push({key:s,contract:a,sym:r,precision:n,price:c,asset:e,value:l,logo:i})}}));case 3:case"end":return e.stop()}}),e)})),P=0;case 27:if(!(P<S.length)){e.next=34;break}return e.delegateYield(w(P),"t0",29);case 29:if(!e.t0){e.next=31;break}return e.abrupt("continue",31);case 31:++P,e.next=27;break;case 34:return e.next=36,r.load("loglogloglog");case 36:return _=e.sent,L=_.table("liqs"),e.next=40,L.all({scope:(0,d.fD)(i)});case 40:e.sent.forEach((function(e){var t=a.find((function(t){return t.mid.equals(e.mid)})),n=t.contract0.toString(),r=t.contract1.toString(),s=t.sym0.name,o=t.sym1.name,c=t.sym0.precision,l=t.sym1.precision,i=n+"-"+s,u=r+"-"+o,p=f[i+"-"+c],h=f[u+"-"+l],m=(0,d.ri)(e.bal0),b=(0,d.ri)(e.bal1),v=m*p,y=b*h,N=e.token.toNumber()/t.liquidity_token.toNumber(),S=N*(0,d.ri)(t.reserve0),w=N*(0,d.ri)(t.reserve1),P=S*p,_=w*h,L=P+_-v-y,V=j()().diff(j().utc(e.start.toString()),"days"),O="dfsppptokens"===n?x[s]:"https://dfs.land/assets/tokens/".concat(i,".png"),T="dfsppptokens"===r?x[o]:"https://dfs.land/assets/tokens/".concat(u,".png");k.reserveValue+=P+_,k.balValue+=v+y,g.push({ratio:N,contract0:n,sym0:s,precision0:c,bal0:m,key0:i,bal0Value:v,reserve0Value:P,contract1:r,sym1:o,precision1:l,bal1:b,key1:u,reserve0:S,reserve1:w,price0:p,price1:h,bal1Value:y,reserve1Value:_,diffValue:L,days:V,logo0:O,logo1:T})})),k.diffValue=k.reserveValue-k.balValue,s(p.N.setTokensLoading(!1)),s(p.N.setTokens(m)),s(p.N.setLiqTokens(g)),s(p.N.setTokensValue(b)),s(p.N.setLiqsValue(k)),s(p.N.setDfsPrice(f[v])),e.next=56;break;case 51:e.prev=51,e.t1=e.catch(0),s(p.N.setTokensLoading(!1)),s(p.N.setNftsLoading(!1)),(0,d.Tv)(e.t1,n,"handleGetTokenInfo");case 56:case"end":return e.stop()}}),e,null,[[0,51]])})));return function(t,n,r,a,s,o){return e.apply(this,arguments)}}(),[n,se,M]),ce=(0,_.useCallback)(function(){var e=l()(o()().mark((function e(t,r){var a,l,f,h,m,g,k,v,y,x,w,j,P,_,L,V,O,T,D,M,E,I,q,A,K,F,R,Z,U,B;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(N&&i&&c)){e.next=99;break}return s(p.N.setLoading(!0)),s(p.N.setTokensLoading(!0)),s(p.N.setNftsLoading(!0)),e.next=6,ae(t,r);case 6:if(e.sent){e.next=11;break}return s(p.N.setLoading(!1)),s(p.N.setTokensLoading(!1)),s(p.N.setNftsLoading(!1)),e.abrupt("return");case 11:return e.prev=11,a="",e.next=15,N.load(t);case 15:return l=e.sent,e.next=18,i.load("swapswapswap");case 18:return f=e.sent,e.next=21,i.load("dfsweb3desoc");case 21:return h=e.sent,e.next=24,i.load("dfsbpsvoters");case 24:return m=e.sent,e.next=27,i.load("eosio.msig");case 27:return g=e.sent,e.next=30,i.load("dfsrefdfsref");case 30:return k=e.sent,e.next=33,i.load("dfs3protocol");case 33:return v=e.sent,y=f.table("markets"),x=h.table("profiles"),w=m.table("voters"),j=g.table("approvals2"),P=g.table("proposal"),_=k.table("referrers"),L=k.table("relations"),V=v.table("projects"),O=v.table("registry"),e.next=45,O.all({scope:"dfs3protocol",from:t,to:t,index_position:"tertiary",key_type:"name"});case 45:return T=e.sent,e.next=48,y.all();case 48:return D=e.sent,e.next=51,w.all({scope:"dfsbpsvoters",from:t,to:t});case 51:return M=e.sent,e.next=54,x.all({scope:"dfsweb3desoc",from:t,to:t});case 54:return(E=e.sent).length||E.push({avatar:"",cover:"",desc:"",join:"",nick:"",owner:b.VG.from(t),sex:b.zM.from(2),update:""}),e.next=58,j.all({scope:(0,d.fD)(t)});case 58:return I=e.sent,e.next=61,P.all({scope:(0,d.fD)(t)});case 61:return q=e.sent,e.next=64,_.all({scope:"dfsrefdfsref",from:t,to:t});case 64:return A=e.sent,e.next=67,L.all({scope:"dfsrefdfsref",from:t,to:t});case 67:return K=e.sent,e.next=70,V.all();case 70:return F=e.sent,e.next=73,(0,d.zI)(S().get("https://api2.dfsmoon.com/v2/history/get_creator?account=".concat(l.accountName.toString()),{timeout:1e3}));case 73:R=e.sent,Z=u()(R,2),U=Z[0],B=Z[1],U||200!==B.status||(a=B.data.creator),oe(c,i,D,F,T,t),s(p.N.setMarkets(D)),s(p.N.setAccountInfo(l)),s(p.N.setCreator(a)),s(p.N.setProfile(E[0])),s(p.N.setVoter(M[0])),s(p.N.setProposals(q)),s(p.N.setApprovals2(I)),s(p.N.setReferrer(A[0])),s(p.N.setRelation(K[0])),z(""),s(p.N.setLoading(!1)),C.current&&C.current.handleSearch(),e.next=99;break;case 93:e.prev=93,e.t0=e.catch(11),s(p.N.setLoading(!1)),s(p.N.setTokensLoading(!1)),s(p.N.setNftsLoading(!1)),(0,d.Tv)(e.t0,n,"handleSearch");case 99:case"end":return e.stop()}}),e,null,[[11,93]])})));return function(t,n){return e.apply(this,arguments)}}(),[N,i,c,ae,n,oe]),le=(0,_.useCallback)((0,P.debounce)(function(){var e=l()(o()().mark((function e(t){var n,r,a,s;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.target.value,/^[a-z1-5.]{1,12}$/.test(n)){e.next=6;break}0===n.trim().length?z(""):z("error"),e.next=12;break;case 6:return e.next=8,(0,d.zI)(c.client.v1.chain.get_account(n));case 8:r=e.sent,a=u()(r,2),s=a[1],z(s?"":"error");case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),1e3),[c]),ie=[{key:"info",label:(0,L.jsx)("span",{className:"text-lg font-semibold",children:H}),children:!!V&&(0,L.jsx)(f.i3,{handleSearch:ce})},{key:"token",label:(0,L.jsx)("span",{className:"text-lg font-semibold",children:Q}),children:!!V&&(0,L.jsx)(f.DL,{})},{key:"nft",label:(0,L.jsx)("span",{className:"text-lg font-semibold",children:W}),children:!!V&&(0,L.jsx)(f.tw,{})},{key:"liq",label:(0,L.jsx)("span",{className:"text-lg font-semibold",children:X}),children:!!V&&(0,L.jsx)(f.uq,{})},{key:"tx",label:(0,L.jsx)("span",{className:"text-lg font-semibold",children:ee}),children:!!V&&(0,L.jsx)(f.ps,{ref:C})},{key:"auth",label:(0,L.jsx)("span",{className:"text-lg font-semibold",children:J}),children:!!V&&(0,L.jsx)(f.Bf,{})},{key:"proposal",label:(0,L.jsx)("span",{className:"text-lg font-semibold",children:te}),children:!!V&&(0,L.jsx)(f.f9,{proposer:V.accountName.toString(),approvals2:T,proposals:D,loading:O,handleSearch:ce})},{key:"invite",label:(0,L.jsx)("span",{className:"text-lg font-semibold",children:ne}),children:!!V&&(0,L.jsx)(f.$7,{handleSearch:ce})},{key:"tip",label:(0,L.jsx)("span",{className:"text-lg font-semibold",children:re}),disabled:!0}],ue=(0,_.useCallback)((function(e,t){var n={};e&&(n.search=e),n.tab=t||w,R(n)}),[w]);return(0,_.useEffect)((function(){var e=F.get("search"),t=F.get("tab");t&&s(p.N.setActiveKey(t)),e&&ce(e,""),ue(e,t)}),[ce]),(0,_.useEffect)((function(){var e=V?V.accountName.toString():"";ue(e,w)}),[V,w,ue]),(0,L.jsxs)(h._z,{className:"account",ghost:!0,children:[(0,L.jsxs)(m.Z,{title:(0,L.jsx)("div",{className:"hardline font-semibold text-lg mb-3",children:Y}),children:[(0,L.jsx)(v.Z.Search,{className:" ",loading:O,addonBefore:(0,L.jsx)(y.Z,{spinning:O,children:B}),placeholder:"Search...",allowClear:!0,enterButton:$,size:"large",status:q,onSearch:ce,onChange:le}),(0,L.jsx)(x.Z,{className:"mt-2",items:ie,activeKey:Z,onChange:function(e){s(p.N.setActiveKey(e))}})]}),r]})}},31145:function(){}}]);