-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvendors~transfer.4d52e108f8ffb4420986.js
2 lines (2 loc) · 10.7 KB
/
vendors~transfer.4d52e108f8ffb4420986.js
1
2
(window.webpackJsonp=window.webpackJsonp||[]).push([[31],{1771:function(e,t,r){var n=r(30),o=r(1772),a={},c={},s={};function i(e,t,r,n){a[e]||(a[e]=[]),c[e]||(c[e]=[]),a[e].push(t),c[e].push([r,t,new Date(n)]),s[e]||(s[e]={}),s[e][r]||(s[e][r]={deposit:[],withdrawal:[]}),s[e][r][t>0?"deposit":"withdrawal"].push(t)}function u(e,t,r,n,a,c,s,u,l){return r||(r={amount:"",currency:""}),n||(n={amount:"",currency:""}),a||(a={amount:"",currency:""}),r.amount&&i(r.currency,r.amount,s,c),n.amount&&i(n.currency,-n.amount,s,c),a.amount&&i(a.currency,-a.amount,s,c),e.push([t,o.printAmount(r),r.currency,o.printAmount(n),n.currency,o.printAmount(a),a.currency,"BTS-DEX",l||"",u||"",c]),e}e.exports={parseData:function(e,t,r){var n=[];n.push(["Type","Buy Amount","Buy Currency","Sell Amount","Sell Currency","Fee Amount","Fee Currency","Exchange","Trade Group","Comment","Date"]);var a={};function c(e){a[e]||(a[e]=0),a[e]++}var s=Object.keys(e),i=Array.isArray(s),l=0;for(s=i?s:s[Symbol.iterator]();;){var p;if(i){if(l>=s.length)break;p=s[l++]}else{if((l=s.next()).done)break;p=l.value}var f=e[p],d=f.timestamp,m=f.type,y=f.data,_=null;switch(m){case"vesting_balance_withdraw":var h=o.parseCurrency(y.amount);_=o.parseCurrency(y.fee),n=u(n,"1.2.30665"===y.owner&&h.amount>1e4?"Income":"Deposit",h,null,_,d,m,r+" : Vesting balance withdraw"),c(m);break;case"balance_claim":n=u(n,"Deposit",o.parseCurrency(y.total_claimed),null,null,d,m,r+" : Balance claim"),c(m);break;case"transfer":var b=o.parseCurrency(y.amount);_=o.parseCurrency(y.fee),n=y.to==t?u(n,"1.2.391938"===y.to&&"1.2.381086"===y.from?"Income":"Deposit",b,null,null,d,m,r+" : From "+y.from):u(n,"Withdrawal",null,b,_,d,m,r+": To "+y.to),c(m);break;case"fill_order":var g=o.parseCurrency(y.pays),v=o.parseCurrency(y.receives);"BTS"!==(_=o.parseCurrency(y.fee)).currency&&(v.currency===_.currency?(v.amount-=_.amount,_.amount=0):g.currency===_.currency&&(g.amount-=_.amount,_.amount=0)),n=u(n,"Trade",v,g,_,d,m),c(m);break;case"asset_issue":var w=o.parseCurrency(y.asset_to_issue);_=y.issuer===t?o.parseCurrency(y.fee):null,y.issue_to_account===t&&(n=u(n,"Deposit",w,null,_,d,m,r+" : Issued to account")),c(m);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":(_=o.parseCurrency(y.fee)).amount>0&&(n=u(n,"Withdrawal",null,_,null,d,m,m+" fee"),c(m));break;case"account_create":y.registrar===t&&(n=u(n,"Withdrawal",null,_=o.parseCurrency(y.fee),null,d,m,m+" fee"),c(m));break;case"asset_fund_fee_pool":_=o.parseCurrency(y.fee),n=u(n,"Withdrawal",null,o.parseCurrency({amount:y.amount,asset_id:"1.3.0"}),_,d,m,""+m),c(m);break;default:console.log("Unhandled type:",m,y)}}return n},filterEntries:function(e,t,r){if(!t&&!r)return e;for(var n=Object.keys(e),o=n.length-1;o>=0;o--){var a=n[o],c=e[a],s=c.timestamp,i=c.type;c.data,t&&i!==t?delete e[a]: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){for(var t={},r=Object.keys(e),o=r.length-1;o>=0;o--){var a=r[o],c=e[a],s=c.timestamp,i=c.type,u=c.data;switch(i){case"fill_order":var l=n(s),p=u.receives.asset_id+"_"+u.pays.asset_id,f=t[p],d=f?n(f.timestamp):null;f&&l.isSame(d,"day")&&f.data.pays.asset_id===u.pays.asset_id&&f.data.receives.asset_id===u.receives.asset_id&&(u.pays.amount=parseInt(u.pays.amount,10)+parseInt(f.data.pays.amount,10),u.receives.amount=parseInt(u.receives.amount,10)+parseInt(f.data.receives.amount,10),u.fee.amount=parseInt(u.fee.amount,10)+parseInt(f.data.fee.amount,10),e[a].data=u,delete e[f.trx_id]),t[p]={data:u,timestamp:s,trx_id:a}}}return console.log("Removed "+(r.length-Object.keys(e).length)+" fill_order entries by grouping"),e}}},1772:function(e,t,r){var n=r(10).ChainStore;e.exports={parseCurrency:function(e){var t=n.getAsset(e.asset_id),r=function(e){if("number"!=typeof e)throw new Error("Input must be a number");return Math.pow(10,e)}((t=t?t.toJS():{precision:5}).precision);return{amount:e.amount/r,currency:t.symbol,asset_id:e.asset_id}},printAmount:function(e){if(!e.amount||!e.currency)return"";var t=n.getAsset(e.asset_id);return t=t?t.toJS():{precision:5},e.amount.toFixed(t.precision)},getIndex:function(e){var t=e.split(".");return parseInt(t[2],10)}}},1773:function(e,t,r){var n=r(1774),o=r(13),a=r(10),c=a.ChainTypes,s=a.ChainStore,i=a.FetchChain,u=c.operations,l=Object.keys(u),p={},f={};function d(e){return new Promise(function(t,r){if(p[e])return t(p[e]);o.Apis.instance().db_api().exec("get_block",[e]).then(function(r){p[e]=new Date(r.timestamp+"Z"),t(p[e])}).catch(r)})}function m(e){return new Promise(function(t,r){var n;if(f[e])return t(f[e]);i("getObject",e,void 0,(n={},n[e]=!1,n)).then(function(r){var n=r.toJS();f[e]={symbol:n.symbol.replace(/OPEN\.|BRIDGE\.|RUDEX\.|GDEX\.|BLOCK\./,""),precision:n.precision},t(f[e])}).catch(function(e){r()})})}e.exports={connect:function(){return new Promise(function(e){o.Apis.instance(n.apiNode,!0).init_promise.then(function(t){s.init(!1).then(function(){e(t)})}).catch(function(e){console.error("Error connection to node:",e)})})},disconnect:function(){o.Apis.instance().close()},getUser:function(e){return new Promise(function(t,r){var n;i("getAccount",e,void 0,(n={},n[e]=!1,n)).then(function(e){var r=e.toJS();r.balances||(r.balances={}),r.call_orders||(r.call_orders=[]);var n=Object.keys(r.balances);t({accountId:r.id,assets:n,balances:r.balances})}).catch(r)})},getBlockTime:d,getAssetData:m,resolveAssets:function(e,t){return new Promise(function(r,n){var o=[],a={};e&&e.forEach(function(e){switch(l[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(function(e){a[e]=!0}),Object.keys(a).forEach(function(e){!f[e]&&e&&o.push(m(e))}),Promise.all(o).then(r).catch(n)})},resolveBlockTimes:function(e){return new Promise(function(t,r){var n=e.map(function(e){return e.block_time&&(p[e.block_num]=new Date(e.block_time)),d(e.block_num)});Promise.all(n).then(t).catch(r)})},getAsset:function(e){return f[e]},getBlock:function(e){return p[e]}}},1774:function(e,t){e.exports={apiNode:"wss://eu.nodes.bitshares.ws",useES:!0,esNode:"https://eswrapper.bitshares.eu",botPaymentAccounts:[]}},1775:function(e,t,r){var n=r(13),o=void 0;e.exports=function(e){return o=e?fetch:r(1776),{getAccountHistory:function(e,t,r,o){return new Promise(function(a,c){n.Apis.instance().history_api().exec("get_account_history",[e,t,r,o]).then(function(e){a(e)}).catch(c)})},getAccountHistoryES:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"https://eswrapper.bitshares.eu";return console.log("query",n+"/get_account_history?account_id="+e+"&from_="+r+"&size="+t+"&sort_by=block_data.block_time&type=data&agg_field=operation_type"),new Promise(function(a,c){o(n+"/get_account_history?account_id="+e+"&from_="+r+"&size="+t+"&sort_by=block_data.block_time&type=data&agg_field=operation_type").then(function(e){return e.json()}).then(function(e){var t=e.map(function(e){return{id:e.account_history.operation_id,op:JSON.parse(e.operation_history.op),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(function(){a([])})})}}}},1776:function(e,t){},1782:function(e,t,r){var n=r(1771),o=n.groupEntries,a=n.parseData,c=r(1773),s=c.resolveBlockTimes,i=c.resolveAssets,u=r(1775)(!0),l=u.getAccountHistoryES,p=u.getAccountHistory;e.exports={groupEntries:o,parseData:a,getAccountHistoryES:l,getAccountHistory:p,resolveBlockTimes:s,resolveAssets:i}},1935:function(e,t,r){"use strict";const n=r(1936),o=r(1937);function a(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function c(e,t){return t.decode?o(e):e}function s(e){const t=e.indexOf("?");return-1===t?"":e.slice(t+1)}function i(e,t){const r=function(e){let t;switch(e.arrayFormat){case"index":return(e,r,n)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return(e,r,n)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t=Object.assign({decode:!0,arrayFormat:"none"},t)),n=Object.create(null);if("string"!=typeof e)return n;if(!(e=e.trim().replace(/^[?#&]/,"")))return n;for(const o of e.split("&")){let[e,a]=o.replace(/\+/g," ").split("=");a=void 0===a?null:c(a,t),r(c(e,t),a,n)}return Object.keys(n).sort().reduce((e,t)=>{const r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort((e,t)=>Number(e)-Number(t)).map(e=>t[e]):t}(r):e[t]=r,e},Object.create(null))}t.extract=s,t.parse=i,t.stringify=((e,t)=>{!1===(t=Object.assign({encode:!0,strict:!0,arrayFormat:"none"},t)).sort&&(t.sort=(()=>{}));const r=function(e){switch(e.arrayFormat){case"index":return(t,r,n)=>null===r?[a(t,e),"[",n,"]"].join(""):[a(t,e),"[",a(n,e),"]=",a(r,e)].join("");case"bracket":return(t,r)=>null===r?[a(t,e),"[]"].join(""):[a(t,e),"[]=",a(r,e)].join("");default:return(t,r)=>null===r?a(t,e):[a(t,e),"=",a(r,e)].join("")}}(t);return e?Object.keys(e).sort(t.sort).map(n=>{const o=e[n];if(void 0===o)return"";if(null===o)return a(n,t);if(Array.isArray(o)){const e=[];for(const t of o.slice())void 0!==t&&e.push(r(n,t,e.length));return e.join("&")}return a(n,t)+"="+a(o,t)}).filter(e=>e.length>0).join("&"):""}),t.parseUrl=((e,t)=>({url:e.split("?")[0]||"",query:i(s(e),t)}))},1936:function(e,t,r){"use strict";e.exports=(e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`))},1937:function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),o=new RegExp("(%[a-f0-9]{2})+","gi");function a(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],a(r),a(n))}function c(e){try{return decodeURIComponent(e)}catch(o){for(var t=e.match(n),r=1;r<t.length;r++)t=(e=a(t,r).join("")).match(n);return e}}e.exports=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var t={"%FE%FF":"��","%FF%FE":"��"},r=o.exec(e);r;){try{t[r[0]]=decodeURIComponent(r[0])}catch(e){var n=c(r[0]);n!==r[0]&&(t[r[0]]=n)}r=o.exec(e)}t["%C2"]="�";for(var a=Object.keys(t),s=0;s<a.length;s++){var i=a[s];e=e.replace(new RegExp(i,"g"),t[i])}return e}(e)}}}}]);
//# sourceMappingURL=vendors~transfer.js.map