-
Notifications
You must be signed in to change notification settings - Fork 0
/
src__pages__Msig__Proposal.async.js
1 lines (1 loc) · 7.21 KB
/
src__pages__Msig__Proposal.async.js
1
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[2386],{28213:function(e,r,t){t.r(r),t.d(r,{default:function(){return y}});var a=t(15009),s=t.n(a),n=t(99289),o=t.n(n),c=t(5574),l=t.n(c),i=t.p+"static/msigProposal.92809959.png",u=t(9554),p=t(49939),f=t(64119),d=t(11774),m=t(38345),h=t(59530),v=t(80507),x=t(45360),g=t(99021),b=t(69677),k=t(57953),S=t(9669),j=t.n(S),N=t(96486),w=t(62435),M=t(86074),y=function(){var e=x.ZP.useMessage(),r=l()(e,2),t=r[0],a=r[1],n=(0,h.useDispatch)(),c=(0,h.useSelector)((function(e){return e.global.contractKit})),S=(0,h.useSelector)((function(e){return e.global.account})),y=S?S.accountName.toString():"",P=(0,h.useSelector)((function(e){return e.global.session})),C=(0,h.useSelector)((function(e){return e.msig.myProposals})),_=(0,h.useSelector)((function(e){return e.msig.myApprovals2})),q=(0,h.useSelector)((function(e){return e.msig.requestedProposals})),A=(0,h.useSelector)((function(e){return e.msig.requestedApprovals2})),T=(0,h.useSelector)((function(e){return e.msig.searchProposals})),Z=(0,h.useSelector)((function(e){return e.msig.searchApprovals2})),z=(0,w.useState)(!1),D=l()(z,2),I=D[0],R=D[1],V=(0,w.useState)(!1),B=l()(V,2),E=B[0],F=B[1],G=(0,w.useState)(!1),$=l()(G,2),K=$[0],O=$[1],H=(0,w.useState)(""),J=l()(H,2),L=J[0],Q=J[1],U=(0,w.useState)(""),W=l()(U,2),X=W[0],Y=W[1],ee=(0,h.useIntl)(),re=ee.formatMessage({id:"contract.intlProposer"}),te=ee.formatMessage({id:"account.intlSearch"}),ae=ee.formatMessage({id:"contract.intlAccountFormatError"}),se=ee.formatMessage({id:"msig.intlCreateProposal"}),ne=ee.formatMessage({id:"msig.intlCreatTxTip1"}),oe=ee.formatMessage({id:"msig.intlCreatTxTip2"}),ce=ee.formatMessage({id:"msig.intlCreatTxTip3"}),le=ee.formatMessage({id:"msig.intlMyProposal"}),ie=ee.formatMessage({id:"msig.intlSearchProposal"}),ue=ee.formatMessage({id:"msig.intlRequestedApproval"}),pe=ee.formatMessage({id:"msig.intlGetProposalFail"}),fe=(0,w.useCallback)(function(){var e=o()(s()().mark((function e(r){var a,o,l,i,u;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,R(!0),e.next=4,c.load("eosio.msig");case 4:return a=e.sent,o=a.table("approvals2"),l=a.table("proposal"),e.next=9,o.all({scope:(0,f.fD)(r)});case 9:return i=e.sent,e.next=12,l.all({scope:(0,f.fD)(r)});case 12:u=e.sent,n(p.N.setMyProposals(u)),n(p.N.setMyApprovals2(i)),R(!1),e.next=22;break;case 18:e.prev=18,e.t0=e.catch(0),R(!1),(0,f.Tv)(e.t0,t,"handleMySearch");case 22:case"end":return e.stop()}}),e,null,[[0,18]])})));return function(r){return e.apply(this,arguments)}}(),[c,t]),de=(0,w.useCallback)(function(){var e=o()(s()().mark((function e(r){var a,o,l,i,u,d,m,h,x,g,b,k,S,N;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,F(!0),a=r.split(".")[0],e.next=5,j().get("https://api2.dfsmoon.com/v2/state/get_proposals?requested=".concat(a,"&executed=false&limit=1000"));case 5:if(200!==(o=e.sent).status){e.next=39;break}l=o.data.proposals,i=[],u=[],d=0;case 11:if(!(d<l.length)){e.next=35;break}m=0;case 13:if(!(m<l[d].requested_approvals.length)){e.next=32;break}if(l[d].requested_approvals[m].actor!==a){e.next=29;break}return h=l[d].proposer,x=l[d].proposal_name,g=l[d].provided_approvals,b=l[d].requested_approvals,u.push({version:v._A.from(1),proposal_name:v.VG.from(x),provided_approvals:g.map((function(e){return{level:v.V5.from("".concat(e.actor,"@").concat(e.permission)),time:v.hI.from(e.time)}})),requested_approvals:b.map((function(e){return{level:v.V5.from("".concat(e.actor,"@").concat(e.permission)),time:v.hI.from(e.time)}}))}),e.next=22,c.load("eosio.msig");case 22:return k=e.sent,S=k.table("proposal"),e.next=26,S.all({scope:(0,f.fD)(h),from:x,to:x});case 26:return N=e.sent,i.push(N[0]),e.abrupt("break",32);case 29:m++,e.next=13;break;case 32:d++,e.next=11;break;case 35:n(p.N.setRequestedProposals(i)),n(p.N.setRequestedApprovals2(u)),e.next=40;break;case 39:t.error(pe);case 40:F(!1),e.next=47;break;case 43:e.prev=43,e.t0=e.catch(0),F(!1),(0,f.Tv)(e.t0,t,"handleRequestSearch");case 47:case"end":return e.stop()}}),e,null,[[0,43]])})));return function(r){return e.apply(this,arguments)}}(),[c,t]),me=(0,w.useCallback)(function(){var e=o()(s()().mark((function e(r,a){var n,o,c;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(/^[a-z1-5.]{1,12}$/.test(r)){e.next=8;break}if(r||a.hasOwnProperty("type")){e.next=4;break}return e.abrupt("return",!1);case 4:return t.error("".concat(ae)),e.abrupt("return",!1);case 8:return e.next=10,(0,f.zI)(P.client.v1.chain.get_account(r));case 10:if(n=e.sent,o=l()(n,1),!(c=o[0])){e.next=16;break}return t.error(c),e.abrupt("return",!1);case 16:return e.abrupt("return",!0);case 17:case"end":return e.stop()}}),e)})));return function(r,t){return e.apply(this,arguments)}}(),[P,t]),he=(0,w.useCallback)((0,N.debounce)(function(){var e=o()(s()().mark((function e(r){var t,a,n,o;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.target.value,/^[a-z1-5.]{1,12}$/.test(t)){e.next=6;break}0===t.trim().length?Q(""):Q("error"),e.next=12;break;case 6:return e.next=8,(0,f.zI)(P.client.v1.chain.get_account(t));case 8:a=e.sent,n=l()(a,2),o=n[1],Q(o?"":"error");case 12:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),1e3),[P]),ve=(0,w.useCallback)(function(){var e=o()(s()().mark((function e(r,a){var o,l,i,u,d;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return O(!0),e.next=3,me(r,a);case 3:if(e.sent){e.next=6;break}return O(!1),e.abrupt("return");case 6:return Y(r),e.prev=7,e.next=10,c.load("eosio.msig");case 10:return o=e.sent,l=o.table("approvals2"),i=o.table("proposal"),e.next=15,l.all({scope:(0,f.fD)(r)});case 15:return u=e.sent,e.next=18,i.all({scope:(0,f.fD)(r)});case 18:d=e.sent,n(p.N.setSearchProposals(d)),n(p.N.setSearchApprovals2(u)),Q(""),O(!1),e.next=29;break;case 25:e.prev=25,e.t0=e.catch(7),O(!1),(0,f.Tv)(e.t0,t,"handleSearch");case 29:case"end":return e.stop()}}),e,null,[[7,25]])})));return function(r,t){return e.apply(this,arguments)}}(),[c,me,t]);return(0,w.useEffect)((function(){c&&y&&(fe(y),de(y))}),[c,fe,de,y]),(0,M.jsxs)(d._z,{className:"msig",ghost:!0,children:[(0,M.jsxs)("div",{className:"flex justify-evenly flex-wrap items-start",children:[(0,M.jsxs)(m.Z,{className:" mb-4",title:(0,M.jsx)("div",{className:" font-semibold text-lg hardline",children:se}),children:[(0,M.jsx)("div",{children:ne}),(0,M.jsx)("div",{children:oe}),(0,M.jsx)("div",{children:ce}),(0,M.jsx)(g.Z,{src:i,width:300})]}),(0,M.jsx)(m.Z,{className:" mb-4 proposal",title:(0,M.jsx)("div",{className:" font-semibold text-lg hardline",children:le}),children:(0,M.jsx)(u.f9,{proposer:y,approvals2:_,proposals:C,loading:I,handleSearch:fe})}),(0,M.jsx)(m.Z,{className:" mb-4 proposal",title:(0,M.jsx)("div",{className:" font-semibold text-lg hardline",children:ue}),children:(0,M.jsx)(u.f9,{proposer:y,approvals2:A,proposals:q,loading:E,handleSearch:de})}),(0,M.jsxs)(m.Z,{className:" mb-4 proposal",title:(0,M.jsx)("div",{className:" font-semibold text-lg hardline",children:ie}),children:[(0,M.jsx)(b.Z.Search,{className:"mb-4",loading:K,addonBefore:(0,M.jsx)(k.Z,{spinning:K,children:re}),placeholder:"Search...",allowClear:!0,enterButton:te,size:"large",status:L,onSearch:ve,onChange:he}),(0,M.jsx)(u.f9,{proposer:X,approvals2:Z,proposals:T,loading:K,handleSearch:ve})]})]}),a]})}}}]);