-
Notifications
You must be signed in to change notification settings - Fork 0
/
src__pages__PPP__GrabCoin.async.js
1 lines (1 loc) · 7.27 KB
/
src__pages__PPP__GrabCoin.async.js
1
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3952],{37057:function(e,t,r){r.r(t);var n=r(15009),a=r.n(n),s=r(19632),c=r.n(s),o=r(97857),u=r.n(o),i=r(99289),l=r.n(i),f=r(5574),p=r.n(f),d=r(64119),m=r(11774),b=r(38345),x=r(97269),g=r(5966),v=r(31199),k=r(59530),h=r(80507),j=r(45360),w=r(15867),S=r(27484),y=r.n(S),F=r(70178),N=r.n(F),C=r(62435),_=r(86074);y().extend(N());var Y=[];t.default=function(){var e=j.ZP.useMessage(),t=p()(e,2),r=t[0],n=t[1],s=(0,k.useSelector)((function(e){return e.global.contractKit})),o=(0,k.useSelector)((function(e){return e.global.account})),i=(0,k.useSelector)((function(e){return e.global.session})),f=(0,k.useSelector)((function(e){return e.global.privateKey})),S=((0,k.useSelector)((function(e){return e.ppp.vipAccounts})),(0,k.useSelector)((function(e){return e.ppp.accessAccounts}))),F=(0,C.useState)(!1),N=p()(F,2),D=N[0],M=N[1],V=(0,C.useState)(""),P=p()(V,2),z=P[0],E=P[1],H=(0,k.useIntl)(),Z=H.formatMessage({id:"coffee.inputException"}),A=H.formatMessage({id:"common.intlPleaseConnectWallet"}),O=H.formatMessage({id:"common.intlPleaseConnectNetwork"}),R=(0,C.useRef)(),T=(0,C.useRef)(!1),I=(0,C.useCallback)((function(){if(D){if(o){var e=o.accountName.toString();return!!S.includes(e)||(M(!1),!1)}return!0}if(o){var t=o.accountName.toString();return!!S.includes(t)&&(M(!0),!0)}return!1}),[o,D,S]),J=((0,C.useCallback)((function(){var e=y()().format("YYYY-MM-DDTHH:mm:ss"),t=JSON.stringify(Y,null,2),r="data:,".concat(t),n=document.createElement("a");n.href=r,n.download="log_".concat(e,".json"),n.click()}),[]),(0,C.useCallback)(function(){var e=l()(a()().mark((function e(t,n){var s,o,l,m,b,x,g,v,k,j,w,S;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.client.v1.chain.get_info();case 2:return s=e.sent,o=s.getTransactionHeader(),l=y()(),m=y()(l).add(3600,"seconds").utc().format("YYYY-MM-DDTHH:mm:ss"),g=[],v=[t,n],b=h.YW.from(u()(u()({},o),{},{expiration:m,actions:v})),g[0]=f.signDigest(b.signingDigest(i.chain.id.toString())),e.next=12,(0,d.zI)(i.transact({transaction:b},{broadcast:!1,transactPlugins:[]}));case 12:if(k=e.sent,j=p()(k,2),w=j[0],S=j[1],!w){e.next=19;break}return r.error(w),e.abrupt("return",!1);case 19:return x=h.uQ.from(u()(u()({},b),{},{signatures:[].concat(g,c()(S.signatures))})),e.abrupt("return",x);case 21:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),[i])),W=(0,C.useCallback)(function(){var e=l()(a()().mark((function e(t){var n,c,u,l,f,p,m,b,x,g,v,k,j,w,S,y,F,N,C,_,Y,D,M,V,P,z;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i&&i.broadcast){e.next=5;break}return r.error("".concat(A)),e.abrupt("return");case 5:if(o){e.next=8;break}return r.error("".concat(O)),e.abrupt("return");case 8:return e.next=10,s.load("swapswapswap");case 10:return n=e.sent,c=n.table("markets"),e.next=14,c.all();case 14:return u=e.sent,e.next=17,c.all();case 17:if(l=e.sent,u.length===l.length){e.next=22;break}return r.error("获取两次markets的数据长度不一致,请重新启动"),console.log("获取两次markets的数据长度不一致,请重新启动"),e.abrupt("return",!1);case 22:f=u[u.length-1].mid.toNumber(),p=f+1,m=i.actor.toString(),b=t.count,x=Number(b),g="swap:".concat(p,":0"),v=x.toFixed(8)+" DFS",k={account:"eosio.token",name:"transfer",authorization:[i.permissionLevel],data:d.FE.from({from:m,to:"swapswapswap",quantity:v,memo:g})},j=h.aU.from(k),w={account:"dfsfreecpu11",name:"freecpu",authorization:[{actor:"dfs.service",permission:"cpu"},i.permissionLevel],data:d._9.from({user:m})},S=h.aU.from(w),F=1,N=5;case 35:return e.next=38,J(S,j);case 38:if(!(y=e.sent)){e.next=43;break}return e.abrupt("break",53);case 43:if(!(F>N)){e.next=47;break}return r.error("交易信息为空,重试超过最大次数,退出执行"),console.log("交易信息为空,重试超过最大次数,退出执行"),e.abrupt("return",!1);case 47:return r.error("交易信息为空,重试第".concat(F,"次")),console.log("交易信息为空,重试第".concat(F,"次")),F+=1,e.abrupt("continue",35);case 51:e.next=35;break;case 53:T.current=!1;case 54:if(!T.current){e.next=57;break}return e.abrupt("return",!0);case 57:return e.prev=57,null===(C=R.current)||void 0===C||C.setFieldValue("result","message"),e.next=61,i.client.v1.chain.push_transaction(y);case 61:if(!(_=e.sent)||!_.processed||"executed"!==_.processed.receipt.status){e.next=68;break}return r.success("交易完成"),null===(Y=R.current)||void 0===Y||Y.setFieldValue("result",JSON.stringify(_)),e.abrupt("return",!0);case 68:return r.success("交易失败"),null===(D=R.current)||void 0===D||D.setFieldValue("result",JSON.stringify(_)),e.abrupt("return",!0);case 71:e.next=81;break;case 73:e.prev=73,e.t0=e.catch(57),P=null===(M=R.current)||void 0===M?void 0:M.getFieldValue("try"),null===(V=R.current)||void 0===V||V.setFieldValue("try",P+1),z="",e.t0 instanceof Error?(console.log(e.t0.details[0].message),e.t0.message.includes("eosio_assert_message assertion failure")&&(z=e.t0.details[0].message)):z=e.t0,E(z),console.log(z);case 81:e.next=54;break;case 83:case"end":return e.stop()}}),e,null,[[57,73]])})));return function(t){return e.apply(this,arguments)}}(),[i,o,s,J]),q=(0,C.useCallback)(l()(a()().mark((function e(){var t,n,c,u,l,f,p,d,m,b;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i&&i.broadcast){e.next=5;break}return r.error("".concat(A)),e.abrupt("return");case 5:if(o){e.next=8;break}return r.error("".concat(O)),e.abrupt("return");case 8:return e.next=10,s.load("dfs3protocol");case 10:return t=e.sent,n=t.table("projects"),c=t.table("globals"),e.next=15,c.all({scope:"dfs3protocol",from:"project",to:"project"});case 15:u=e.sent,l=u[0].val.toNumber(),f=l;case 18:return e.next=21,c.all({scope:"dfs3protocol",from:"project",to:"project"});case 21:if(p=e.sent,(f=p[0].val.toNumber())===l){e.next=25;break}return e.abrupt("break",27);case 25:e.next=18;break;case 27:return e.next=29,n.all({scope:"dfs3protocol",from:f,to:f});case 29:d=e.sent,m=d[0].init_nft_price.value,d[0].init_nft_price.symbol.name,d[0].creator.toString(),b=d[0].init_nft_number.toNumber(),m*b;case 35:case"end":return e.stop()}}),e)}))),[i,o,s]),K=(0,C.useCallback)((function(){T.current=!0}),[]),L=(0,C.useCallback)((function(){var e;T.current=!0,null===(e=R.current)||void 0===e||e.resetFields()}),[]);return(0,C.useEffect)((function(){s&&q()}),[s,q]),(0,_.jsx)(m._z,{className:"",ghost:!0,children:I()?(0,_.jsxs)("div",{className:"flex flex-wrap justify-center gap-5",children:[(0,_.jsx)(b.Z,{title:(0,_.jsx)("div",{className:" font-semibold text-lg hardline",children:"自动抢币"}),style:{maxWidth:"500px"},children:(0,_.jsxs)(x.A,{formRef:R,onFinish:W,onReset:L,layout:"vertical",initialValues:{mid:0,slip:50,try:0,result:""},submitter:{searchConfig:{submitText:"启动"},render:function(e,t){return[t[1],(0,_.jsx)(w.ZP,{onClick:K,children:"停止"},"stop"),t[0]]}},children:[(0,_.jsx)(g.Z,{label:"购买数量DFS",name:"count",placeholder:"",rules:[{required:!0,message:"".concat(Z),whitespace:!0,pattern:/^\d+(\.\d{1,8})?$/}],fieldProps:{autoFocus:!1,size:"large",defaultValue:0}}),(0,_.jsx)(v.Z,{label:(0,_.jsx)("div",{children:"尝试次数"}),name:"try",placeholder:"",fieldProps:{autoFocus:!1,size:"large",defaultValue:0,readOnly:!0}}),(0,_.jsx)(x.A.Item,{label:(0,_.jsx)("div",{children:"尝试结果"}),children:z})]})}),n]}):(0,_.jsx)(_.Fragment,{})})}}}]);