-
Notifications
You must be signed in to change notification settings - Fork 6
/
473.d1bc7e5e04cf371a5bde.js
1 lines (1 loc) · 7.46 KB
/
473.d1bc7e5e04cf371a5bde.js
1
(this.webpackChunkRuDEX3_light=this.webpackChunkRuDEX3_light||[]).push([[473],{89473:(e,t,r)=>{const{groupEntries:n,parseData:o}=r(51916),{resolveBlockTimes:a,resolveAssets:s}=r(6871),{getAccountHistoryES:c,getAccountHistory:i}=r(70922)(!0);e.exports={groupEntries:n,parseData:o,getAccountHistoryES:c,getAccountHistory:i,resolveBlockTimes:a,resolveAssets:s}},70922:(e,t,r)=>{const n=r(55420);let o;e.exports=function(e){return o=e?fetch:r(50989),{getAccountHistory:function(e,t,r,o){return new Promise(((a,s)=>{n.Apis.instance().history_api().exec("get_account_history",[e,t,r,o]).then((e=>{a(e)})).catch(s)}))},getAccountHistoryES:function(e,t,r,n="https://es-wrapper.gph.ai"){return console.log("query",`${n}/es/account_history?account_id=${e}&from_=${r}&size=${t}&sort_by=block_data.block_time&type=data&agg_field=operation_type`),new Promise(((a,s)=>{o(`${n}/es/account_history?account_id=${e}&from_=${r}&size=${t}&sort_by=block_data.block_time&type=data&agg_field=operation_type`).then((e=>e.json())).then((e=>{let t=e.map((e=>("amount_"in e.operation_history.op_object&&(e.operation_history.op_object.amount=e.operation_history.op_object.amount_),{id:e.account_history.operation_id,op:e.operation_history.op_object,operation_type:e.operation_type,result:JSON.parse(e.operation_history.operation_result),block_num:e.block_data.block_num,block_time:e.block_data.block_time+"Z"})));a(t)})).catch((e=>{console.log("getAccountHistory errror:",e),a([])}))}))}}}},6871:(e,t,r)=>{const n=r(23128),o=r(55420),{ChainTypes:a,ChainStore:s,FetchChain:c}=r(30806),{operations:i}=a,u=Object.keys(i);let l={},p={};function m(e){return new Promise(((t,r)=>{if(l[e])return t(l[e]);o.Apis.instance().db_api().exec("get_block",[e]).then((r=>{l[e]=new Date(r.timestamp+"Z"),t(l[e])})).catch(r)}))}function _(e){return new Promise(((t,r)=>{if(p[e])return t(p[e]);c("getObject",e,void 0,{[e]:!1}).then((r=>{let n=r.toJS();p[e]={symbol:n.symbol.replace(/OPEN\.|BRIDGE\.|RUDEX\.|GDEX\.|BLOCK\./,""),precision:n.precision},t(p[e])})).catch((e=>{r()}))}))}e.exports={connect:function(){return new Promise((e=>{o.Apis.instance(n.apiNode,!0).init_promise.then((t=>{s.init(!1).then((()=>{e(t)}))})).catch((e=>{console.error("Error connection to node:",e)}))}))},disconnect:function(){o.Apis.instance().close()},getUser:function(e){return new Promise(((t,r)=>{c("getAccount",e,void 0,{[e]:!1}).then((e=>{let r=e.toJS();r.balances||(r.balances={}),r.call_orders||(r.call_orders=[]);let n=Object.keys(r.balances);t({accountId:r.id,assets:n,balances:r.balances})})).catch(r)}))},getBlockTime:m,getAssetData:_,resolveAssets:function(e,t){return new Promise(((r,n)=>{let o=[],a={};e&&e.forEach((e=>{switch(u[e.op[0]]){case"transfer":a[e.op[1].amount.asset_id]=!0,a[e.op[1].fee.asset_id]=!0;break;case"fill_order":a[e.op[1].pays.asset_id]=!0,a[e.op[1].receives.asset_id]=!0,a[e.op[1].fee.asset_id]=!0;break;case"asset_issue":a[e.op[1].asset_to_issue.asset_id]=!0,a[e.op[1].fee.asset_id]=!0}})),t&&t.forEach((e=>{a[e]=!0})),Object.keys(a).forEach((e=>{!p[e]&&e&&o.push(_(e))})),Promise.all(o).then(r).catch(n)}))},resolveBlockTimes:function(e){return new Promise(((t,r)=>{let n=e.map((e=>(e.block_time&&(l[e.block_num]=new Date(e.block_time)),m(e.block_num))));Promise.all(n).then(t).catch(r)}))},getAsset:function(e){return p[e]},getBlock:function(e){return l[e]}}},23128:e=>{e.exports={apiNode:"wss://node.gph.ai",useES:!0,esNode:"https://es-wrapper.gph.ai",botPaymentAccounts:[]}},51916:(e,t,r)=>{const n=r(30381),o=r(33981);let a={},s={},c={};function i(e,t,r,n){a[e]||(a[e]=[]),s[e]||(s[e]=[]),a[e].push(t),s[e].push([r,t,new Date(n)]),c[e]||(c[e]={}),c[e][r]||(c[e][r]={deposit:[],withdrawal:[]}),c[e][r][t>0?"deposit":"withdrawal"].push(t)}function u(e,t,r,n,a,s,c,u,l){return r||(r={amount:"",currency:""}),n||(n={amount:"",currency:""}),a||(a={amount:"",currency:""}),r.amount&&i(r.currency,r.amount,c,s),n.amount&&i(n.currency,-n.amount,c,s),a.amount&&i(a.currency,-a.amount,c,s),e.push([t,o.printAmount(r),r.currency,o.printAmount(n),n.currency,o.printAmount(a),a.currency,"GPH-DEX",l||"",u||"",s]),e}e.exports={parseData:function(e,t,r){let n=[];n.push(["Type","Buy Amount","Buy Currency","Sell Amount","Sell Currency","Fee Amount","Fee Currency","Exchange","Trade Group","Comment","Date"]);let a={};function s(e){a[e]||(a[e]=0),a[e]++}for(let a of Object.keys(e)){const{timestamp:c,type:i,data:l}=e[a];let p=null;switch(i){case"vesting_balance_withdraw":let e=o.parseCurrency(l.amount);p=o.parseCurrency(l.fee),n=u(n,"1.2.30665"===l.owner&&e.amount>1e4?"Income":"Deposit",e,null,p,c,i,`${r} : Vesting balance withdraw`),s(i);break;case"balance_claim":n=u(n,"Deposit",o.parseCurrency(l.total_claimed),null,null,c,i,`${r} : Balance claim`),s(i);break;case"transfer":let a=o.parseCurrency(l.amount);p=o.parseCurrency(l.fee),n=l.to==t?u(n,"1.2.391938"===l.to&&"1.2.381086"===l.from?"Income":"Deposit",a,null,null,c,i,`${r} : From ${l.from}`):u(n,"Withdrawal",null,a,p,c,i,`${r}: To ${l.to}`),s(i);break;case"fill_order":let m=o.parseCurrency(l.pays),_=o.parseCurrency(l.receives);p=o.parseCurrency(l.fee),"BTS"!==p.currency&&(_.currency===p.currency?(_.amount-=p.amount,p.amount=0):m.currency===p.currency&&(m.amount-=p.amount,p.amount=0)),n=u(n,"Trade",_,m,p,c,i),s(i);break;case"asset_issue":{let e=o.parseCurrency(l.asset_to_issue);p=l.issuer===t?o.parseCurrency(l.fee):null,l.issue_to_account===t&&(n=u(n,"Deposit",e,null,p,c,i,`${r} : Issued to account`)),s(i);break}case"account_update":case"proposal_create":case"proposal_update":case"account_whitelist":case"worker_create":case"limit_order_create":case"limit_order_cancel":case"call_order_update":p=o.parseCurrency(l.fee),p.amount>0&&(n=u(n,"Withdrawal",null,p,null,c,i,`${i} fee`),s(i));break;case"account_create":l.registrar===t&&(p=o.parseCurrency(l.fee),n=u(n,"Withdrawal",null,p,null,c,i,`${i} fee`),s(i));break;case"asset_fund_fee_pool":p=o.parseCurrency(l.fee),n=u(n,"Withdrawal",null,o.parseCurrency({amount:l.amount,asset_id:"1.3.0"}),p,c,i,`${i}`),s(i);break;default:console.log("Unhandled type:",i,l)}}return n},filterEntries:function(e,t,r){if(!t&&!r)return e;let n=Object.keys(e);for(var o=n.length-1;o>=0;o--){let a=n[o],{timestamp:s,type:c,data:i}=e[a];(t&&c!==t||r&&new Date(s).getTime()<r)&&delete e[a]}return console.log(`Removed ${n.length-Object.keys(e).length} entries by filtering`),e},groupEntries:function(e){let t={},r=Object.keys(e);for(var o=r.length-1;o>=0;o--){let a=r[o],{timestamp:s,type:c,data:i}=e[a];if("fill_order"===c){let r=n(s),o=i.receives.asset_id+"_"+i.pays.asset_id,c=t[o],u=c?n(c.timestamp):null;c&&r.isSame(u,"day")&&c.data.pays.asset_id===i.pays.asset_id&&c.data.receives.asset_id===i.receives.asset_id&&(i.pays.amount=parseInt(i.pays.amount,10)+parseInt(c.data.pays.amount,10),i.receives.amount=parseInt(i.receives.amount,10)+parseInt(c.data.receives.amount,10),i.fee.amount=parseInt(i.fee.amount,10)+parseInt(c.data.fee.amount,10),e[a].data=i,delete e[c.trx_id]),t[o]={data:i,timestamp:s,trx_id:a}}}return console.log(`Removed ${r.length-Object.keys(e).length} fill_order entries by grouping`),e}}},33981:(e,t,r)=>{const{ChainStore:n}=r(30806);e.exports={parseCurrency:function(e){let t=n.getAsset(e.asset_id);t=t?t.toJS():{precision:5};let r=function(e){if("number"!=typeof e)throw new Error("Input must be a number");return Math.pow(10,e)}(t.precision);return{amount:e.amount/r,currency:t.symbol,asset_id:e.asset_id}},printAmount:function(e){if(!e.amount||!e.currency)return"";let t=n.getAsset(e.asset_id);return t=t?t.toJS():{precision:5},e.amount.toFixed(t.precision)},getIndex:function(e){let t=e.split(".");return parseInt(t[2],10)}}},50989:()=>{}}]);