web3data-js
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).web3data=t()}(this,(function(){"use strict";var e=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},t=Object.prototype.toString;function n(e){return"[object Array]"===t.call(e)}function r(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function o(e){return"[object Function]"===t.call(e)}function i(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),n(e))for(var r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var a={isArray:n,isArrayBuffer:function(e){return"[object ArrayBuffer]"===t.call(e)},isBuffer:function(e){return null!==e&&!r(e)&&null!==e.constructor&&!r(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isUndefined:r,isDate:function(e){return"[object Date]"===t.call(e)},isFile:function(e){return"[object File]"===t.call(e)},isBlob:function(e){return"[object Blob]"===t.call(e)},isFunction:o,isStream:function(e){return s(e)&&o(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:i,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,s=arguments.length;r<s;r++)i(arguments[r],n);return t},deepMerge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]="object"==typeof n?e({},n):n}for(var r=0,s=arguments.length;r<s;r++)i(arguments[r],n);return t},extend:function(t,n,r){return i(n,(function(n,s){t[s]=r&&"function"==typeof n?e(n,r):n})),t},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}};function c(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var d=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(a.isURLSearchParams(t))r=t.toString();else{var s=[];a.forEach(t,(function(e,t){null!=e&&(a.isArray(e)?t+="[]":e=[e],a.forEach(e,(function(e){a.isDate(e)?e=e.toISOString():a.isObject(e)&&(e=JSON.stringify(e)),s.push(c(t)+"="+c(e))})))})),r=s.join("&")}if(r){var o=e.indexOf("#");-1!==o&&(e=e.slice(0,o)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e};function u(){this.handlers=[]}u.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},u.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},u.prototype.forEach=function(e){a.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var h=u,l=function(e,t,n){return a.forEach(n,(function(n){e=n(e,t)})),e},p=function(e){return!(!e||!e.__CANCEL__)},f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function b(){throw new Error("setTimeout has not been defined")}function g(){throw new Error("clearTimeout has not been defined")}var E=b,m=g;function _(e){if(E===setTimeout)return setTimeout(e,0);if((E===b||!E)&&setTimeout)return E=setTimeout,setTimeout(e,0);try{return E(e,0)}catch(t){try{return E.call(null,e,0)}catch(t){return E.call(this,e,0)}}}"function"==typeof f.setTimeout&&(E=setTimeout),"function"==typeof f.clearTimeout&&(m=clearTimeout);var O,w=[],T=!1,N=-1;function S(){T&&O&&(T=!1,O.length?w=O.concat(w):N=-1,w.length&&A())}function A(){if(!T){var e=_(S);T=!0;for(var t=w.length;t;){for(O=w,w=[];++N<t;)O&&O[N].run();N=-1,t=w.length}O=null,T=!1,function(e){if(m===clearTimeout)return clearTimeout(e);if((m===g||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(e);try{m(e)}catch(t){try{return m.call(null,e)}catch(t){return m.call(this,e)}}}(e)}}function R(e,t){this.fun=e,this.array=t}R.prototype.run=function(){this.fun.apply(null,this.array)};function y(){}var v=y,k=y,I=y,C=y,D=y,H=y,B=y;var M=f.performance||{},P=M.now||M.mozNow||M.msNow||M.oNow||M.webkitNow||function(){return(new Date).getTime()};var L=new Date;var x={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];w.push(new R(e,t)),1!==w.length||T||_(A)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:v,addListener:k,once:I,off:C,removeListener:D,removeAllListeners:H,emit:B,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*P.call(M),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-L)/1e3}},U=function(e,t){a.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},K=function(e,t,n,r,s){return function(e,t,n,r,s){return e.config=t,n&&(e.code=n),e.request=r,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}(new Error(e),t,n,r,s)},F=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],j=a.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=a.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},G=a.isStandardBrowserEnv()?{write:function(e,t,n,r,s,o){var i=[];i.push(e+"="+encodeURIComponent(t)),a.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),a.isString(r)&&i.push("path="+r),a.isString(s)&&i.push("domain="+s),!0===o&&i.push("secure"),document.cookie=i.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},$=function(e){return new Promise((function(t,n){var r=e.data,s=e.headers;a.isFormData(r)&&delete s["Content-Type"];var o=new XMLHttpRequest;if(e.auth){var i=e.auth.username||"",c=e.auth.password||"";s.Authorization="Basic "+btoa(i+":"+c)}var u,h,l=(u=e.baseURL,h=e.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(u,h):h);if(o.open(e.method.toUpperCase(),d(l,e.params,e.paramsSerializer),!0),o.timeout=e.timeout,o.onreadystatechange=function(){if(o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in o?function(e){var t,n,r,s={};return e?(a.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=a.trim(e.substr(0,r)).toLowerCase(),n=a.trim(e.substr(r+1)),t){if(s[t]&&F.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}(o.getAllResponseHeaders()):null,s={data:e.responseType&&"text"!==e.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:r,config:e,request:o};!function(e,t,n){var r=n.config.validateStatus;!r||r(n.status)?e(n):t(K("Request failed with status code "+n.status,n.config,null,n.request,n))}(t,n,s),o=null}},o.onabort=function(){o&&(n(K("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){n(K("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(K(t,e,"ECONNABORTED",o)),o=null},a.isStandardBrowserEnv()){var p=G,f=(e.withCredentials||j(l))&&e.xsrfCookieName?p.read(e.xsrfCookieName):void 0;f&&(s[e.xsrfHeaderName]=f)}if("setRequestHeader"in o&&a.forEach(s,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete s[t]:o.setRequestHeader(t,e)})),a.isUndefined(e.withCredentials)||(o.withCredentials=!!e.withCredentials),e.responseType)try{o.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&o.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){o&&(o.abort(),n(e),o=null)})),void 0===r&&(r=null),o.send(r)}))},q={"Content-Type":"application/x-www-form-urlencoded"};function W(e,t){!a.isUndefined(e)&&a.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var z,V={adapter:("undefined"!=typeof XMLHttpRequest?z=$:void 0!==x&&"[object process]"===Object.prototype.toString.call(x)&&(z=$),z),transformRequest:[function(e,t){return U(t,"Accept"),U(t,"Content-Type"),a.isFormData(e)||a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)?e:a.isArrayBufferView(e)?e.buffer:a.isURLSearchParams(e)?(W(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):a.isObject(e)?(W(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};V.headers={common:{Accept:"application/json, text/plain, */*"}},a.forEach(["delete","get","head"],(function(e){V.headers[e]={}})),a.forEach(["post","put","patch"],(function(e){V.headers[e]=a.merge(q)}));var J=V;function X(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Y=function(e){return X(e),e.headers=e.headers||{},e.data=l(e.data,e.headers,e.transformRequest),e.headers=a.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),a.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||J.adapter)(e).then((function(t){return X(e),t.data=l(t.data,t.headers,e.transformResponse),t}),(function(t){return p(t)||(X(e),t&&t.response&&(t.response.data=l(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Z=function(e,t){t=t||{};var n={},r=["url","method","params","data"],s=["headers","auth","proxy"],o=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];a.forEach(r,(function(e){void 0!==t[e]&&(n[e]=t[e])})),a.forEach(s,(function(r){a.isObject(t[r])?n[r]=a.deepMerge(e[r],t[r]):void 0!==t[r]?n[r]=t[r]:a.isObject(e[r])?n[r]=a.deepMerge(e[r]):void 0!==e[r]&&(n[r]=e[r])})),a.forEach(o,(function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])}));var i=r.concat(s).concat(o),c=Object.keys(t).filter((function(e){return-1===i.indexOf(e)}));return a.forEach(c,(function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])})),n};function Q(e){this.defaults=e,this.interceptors={request:new h,response:new h}}Q.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=Z(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[Y,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},Q.prototype.getUri=function(e){return e=Z(this.defaults,e),d(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},a.forEach(["delete","get","head","options"],(function(e){Q.prototype[e]=function(t,n){return this.request(a.merge(n||{},{method:e,url:t}))}})),a.forEach(["post","put","patch"],(function(e){Q.prototype[e]=function(t,n,r){return this.request(a.merge(r||{},{method:e,url:t,data:n}))}}));var ee=Q;function te(e){this.message=e}te.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},te.prototype.__CANCEL__=!0;var ne=te;function re(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new ne(e),t(n.reason))}))}re.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},re.source=function(){var e;return{token:new re((function(t){e=t})),cancel:e}};var se=re;function oe(t){var n=new ee(t),r=e(ee.prototype.request,n);return a.extend(r,ee.prototype,n),a.extend(r,n),r}var ie=oe(J);ie.Axios=ee,ie.create=function(e){return oe(Z(ie.defaults,e))},ie.Cancel=ne,ie.CancelToken=se,ie.isCancel=p,ie.all=function(e){return Promise.all(e)},ie.spread=function(e){return function(t){return e.apply(null,t)}};var ae=ie,ce=ie;ae.default=ce;var de=ae,ue="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var he=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){e.exports.DEFAULT_WEBSOCKET_URL="wss://ws.web3api.io",e.exports.DEFAULT_BASE_URL="https://web3api.io/api/v2",e.exports.DEFAULT_RPC_URL="https://rpc.web3api.io",e.exports.API_KEY_HEADER="x-api-key",e.exports.BLOCKCHAIN_ID_HEADER="x-amberdata-blockchain-id",e.exports.BLOCKCHAIN_ID_ETHEREUM_MAINNET="1c9c969065fcd1cf",e.exports.BLOCKCHAIN_ID_ETHEREUM_RINKEBY="1b3f7a72b3e99c13",e.exports.BLOCKCHAIN_ID_BITCOIN="408fa195a34b533de9ad9889f076045e",e.exports.BLOCKCHAIN_ID_BITCOIN_CASH="43b45e71cc0615b491cb699e7071fc06",e.exports.BLOCKCHAIN_ID_BITCOIN_SV="a818635d36dbe125e26167c4438e2217",e.exports.BLOCKCHAIN_ID_LITECOIN="f94be61fd9f4fa684f992ddfd4e92272",e.exports.BLOCKCHAIN_ID_RIPPLE="2b8a5d8975e8c2a2ed92450450979a3c",e.exports.BLOCKCHAIN_ID_ZCASH="b7d4f994f33c709be4ce6cbae31d7b8e",e.exports.BLOCKCHAIN_ID_STELLAR="822e2ebe02f74df8",e.exports.ADDRESSES_ENDPOINT="/addresses",e.exports.TOKENS_ENDPOINT="/tokens",e.exports.TRANSACTIONS_ENDPOINT="/transactions",e.exports.BLOCKS_ENDPOINT="/blocks",e.exports.BLOCKCHAINS_ENDPOINT="/blockchains",e.exports.CONTRACTS_ENDPOINT="/contracts",e.exports.SIGNATURES_ENDPOINT="/signatures",e.exports.MARKET_ENDPOINT="/market",e.exports.MARKET_FEATURES=["pairs","exchanges","ohlcv","prices","tickers","trades"],e.exports.ERROR_MESSAGE_TOKEN_NO_ADDRESS="No token address supplied",e.exports.ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS="No token holder address supplied",e.exports.ERROR_MESSAGE_TRANSACTION_NO_HASH="No transaction hash supplied",e.exports.ERROR_MESSAGE_ADDRESS_NO_ADDRESS="No address supplied",e.exports.ERROR_MESSAGE_CONTRACT_NO_ADDRESS="No contract address supplied",e.exports.ERROR_MESSAGE_BLOCK_NO_ID="No block number or hash supplied",e.exports.ERROR_MESSAGE_MARKET_NO_PAIR="No market pair supplied",e.exports.ERROR_MESSAGE_MARKET_NO_FEATURE=`Missing or unknown. Features: '${e.exports.MARKET_FEATURES.join("', '")}'`,e.exports.ERROR_MESSAGE_SIGNATURE_NO_HASH="No signature hash supplied",e.exports.ERROR_RPC_NO_METHOD="No RPC method provided",e.exports.ETH_METHODS={getBlockNumber:"block",getBlock:"block",getBlockTransactionCount:"block",getUncle:"block",getCode:"contract",getGasPrice:"transaction",getTransactionFromBlock:"block",getTransactions:"block",getTransaction:"transaction",getPendingTransactions:"transaction",getEtherPrice:"market",getBalance:"address",getMetrics:"block"},e.exports.BTC_METHODS={address:["getAllAddresses","getInformation","getMetadata","getTransactions","getPendingTransactions","getBalance","getMetrics"],block:["getBlocks","getBlock","getBlockNumber","getTransactions","getTransactionFromBlock","getMetrics"],blockchain:["getMetrics"],transaction:["getTransactions","getTransaction","getPendingTransactions","getMetrics"]},e.exports.LTC_METHODS={address:["getAllAddresses","getInformation","getMetadata","getTransactions","getPendingTransactions","getBalance","getMetrics"],block:["getBlocks","getBlock","getBlockNumber","getTransactions","getTransactionFromBlock","getMetrics"],blockchain:["getMetrics"],transaction:["getTransactions","getTransaction","getPendingTransactions","getMetrics"]},e.exports.XLM_METHODS={address:["getAllAddresses","getInformation","getMetadata","getTransactions","getBalance","getMetrics"],block:["getBlocks","getBlock","getBlockNumber","getTransactions","getTransactionFromBlock","getMetrics"],blockchain:["getMetrics"],transaction:["getTransactions","getTransaction","getMetrics"]},e.exports.HTTP_CODE_NOT_FOUND=404})),le=(he.DEFAULT_WEBSOCKET_URL,he.DEFAULT_BASE_URL,he.DEFAULT_RPC_URL,he.API_KEY_HEADER,he.BLOCKCHAIN_ID_HEADER,he.BLOCKCHAIN_ID_ETHEREUM_MAINNET,he.BLOCKCHAIN_ID_ETHEREUM_RINKEBY,he.BLOCKCHAIN_ID_BITCOIN,he.BLOCKCHAIN_ID_BITCOIN_CASH,he.BLOCKCHAIN_ID_BITCOIN_SV,he.BLOCKCHAIN_ID_LITECOIN,he.BLOCKCHAIN_ID_RIPPLE,he.BLOCKCHAIN_ID_ZCASH,he.BLOCKCHAIN_ID_STELLAR,he.ADDRESSES_ENDPOINT,he.TOKENS_ENDPOINT,he.TRANSACTIONS_ENDPOINT,he.BLOCKS_ENDPOINT,he.BLOCKCHAINS_ENDPOINT,he.CONTRACTS_ENDPOINT,he.SIGNATURES_ENDPOINT,he.MARKET_ENDPOINT,he.MARKET_FEATURES,he.ERROR_MESSAGE_TOKEN_NO_ADDRESS,he.ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS,he.ERROR_MESSAGE_TRANSACTION_NO_HASH,he.ERROR_MESSAGE_ADDRESS_NO_ADDRESS,he.ERROR_MESSAGE_CONTRACT_NO_ADDRESS,he.ERROR_MESSAGE_BLOCK_NO_ID,he.ERROR_MESSAGE_MARKET_NO_PAIR,he.ERROR_MESSAGE_MARKET_NO_FEATURE,he.ERROR_MESSAGE_SIGNATURE_NO_HASH,he.ERROR_RPC_NO_METHOD,he.ETH_METHODS,he.BTC_METHODS,he.LTC_METHODS,he.XLM_METHODS,he.HTTP_CODE_NOT_FOUND,[]),pe=0;pe<256;++pe)le[pe]=(pe+256).toString(16).substr(1);var fe=function(e,t){var n=t||0,r=le;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")};function be(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function ge(e,t){return e<<t|e>>>32-t}var Ee=function(e,t,n){var r=function(e,r,s,o){var i=s&&o||0;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(e)),"string"==typeof r&&(r=function(e){var t=[];return e.replace(/[a-fA-F0-9]{2}/g,(function(e){t.push(parseInt(e,16))})),t}(r)),!Array.isArray(e))throw TypeError("value must be an array of bytes");if(!Array.isArray(r)||16!==r.length)throw TypeError("namespace must be uuid string or an Array of 16 byte values");var a=n(r.concat(e));if(a[6]=15&a[6]|t,a[8]=63&a[8]|128,s)for(var c=0;c<16;++c)s[i+c]=a[c];return s||fe(a)};try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=new Array(r.length);for(var s=0;s<r.length;s++)e[s]=r.charCodeAt(s)}e.push(128);var o=e.length/4+2,i=Math.ceil(o/16),a=new Array(i);for(s=0;s<i;s++){a[s]=new Array(16);for(var c=0;c<16;c++)a[s][c]=e[64*s+4*c]<<24|e[64*s+4*c+1]<<16|e[64*s+4*c+2]<<8|e[64*s+4*c+3]}for(a[i-1][14]=8*(e.length-1)/Math.pow(2,32),a[i-1][14]=Math.floor(a[i-1][14]),a[i-1][15]=8*(e.length-1)&4294967295,s=0;s<i;s++){for(var d=new Array(80),u=0;u<16;u++)d[u]=a[s][u];for(u=16;u<80;u++)d[u]=ge(d[u-3]^d[u-8]^d[u-14]^d[u-16],1);var h=n[0],l=n[1],p=n[2],f=n[3],b=n[4];for(u=0;u<80;u++){var g=Math.floor(u/20),E=ge(h,5)+be(g,l,p,f)+b+t[g]+d[u]>>>0;b=f,f=p,p=ge(l,30)>>>0,l=h,h=E}n[0]=n[0]+h>>>0,n[1]=n[1]+l>>>0,n[2]=n[2]+p>>>0,n[3]=n[3]+f>>>0,n[4]=n[4]+b>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));const{ETH_METHODS:me}=he,_e=e=>{let t="";for(const n in e)({}).hasOwnProperty.call(e,n)&&(t+=`${n}=${e[n]}&`);return t},Oe=(e,t)=>{if(e)throw new Error(t)},we=e=>Oe(!0,e),Te=()=>{};Te.string=e=>"string"==typeof e,Te.bool=e=>"boolean"==typeof e,Te.emptyString=e=>Te.string(e)&&0===e.length,Te.emptyObject=e=>0===Object.keys(e).length,Te.inObject=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Te.undefined=e=>void 0===e,Te.null=e=>null===e,Te.notHash=e=>Te.undefined(e)||Te.emptyString(e),Te.notUndefined=e=>!Te.undefined(e),Te.nonEmptyObject=e=>!Te.emptyObject(e),Te.nonEmptyString=e=>!Te.emptyString(e),Te.notInObject=(e,t)=>!Te.inObject(e,t);const Ne=e=>Object.getOwnPropertyNames(e).filter(t=>"function"==typeof e[t]&&"constructor"!==t);var Se={buildFilterUrl:_e,is:Te,throwIf:Oe,get:(e,{endpoint:t="",subendpoint:n="",hash:r="",pathParam:s="",filterOptions:o={}})=>{const i=Te.nonEmptyObject(o)?"?"+_e(o):"";return r=r?"/"+r:"",s=s?"/"+s:"",n=n?"/"+n:"",e.rawQuery(`${t}${r||s}${n}${i}`)},rejectPromiseIf:(e,t)=>{if(e)return Promise.reject(new Error(t))},uuid:e=>Ee(JSON.stringify(e),"ccfeca02-f0e9-4433-a740-b830cceb3d2d"),ethFactory:function(e){const t={};for(const n in me)({}).hasOwnProperty.call(me,n)&&(t[n]=e[me[n]][n].bind(e[me[n]]));return t},methodFactory:(e,t)=>(Object.keys(t).forEach(n=>{Ne(Object.getPrototypeOf(e.web3data[n])).forEach(r=>{t[n].includes(r)&&(e[n]=e[n]?e[n]:{},e[n][r]=e.web3data[n][r].bind(e))})}),e),throwNow:we,onFulfilled:function(e){return Oe(e.error,e.message),this&&this.formatter?this.formatter(e.payload):e.payload},onError:({response:{data:e}})=>we(e.message||e.description),formatJsonRpc:e=>e?(e.params&&(e.params=Array.isArray(e.params)?e.params:[e.params]),JSON.stringify({jsonrpc:e.version||"2.0",method:e.method||"subscribe",id:e.id||0,params:e.params||[]})):"",getMethods:Ne,recordsFormatter:e=>((e,t)=>e&&e[t]?e[t]:e)(e,"records")};const{ERROR_MESSAGE_ADDRESS_NO_ADDRESS:Ae,ADDRESSES_ENDPOINT:Re}=he,{is:ye,get:ve,throwIf:ke,onFulfilled:Ie,onError:Ce,recordsFormatter:De}=Se;var He=class{constructor(e){this.web3data=e}getAllAddresses(e={}){return this.getAll(e)}getAll(e={}){return ve(this.web3data,{endpoint:Re,filterOptions:e}).then(Ie.bind({formatter:De}),Ce)}getInformation(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"information",filterOptions:t}).then(Ie,Ce)}getMetadata(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"metadata",filterOptions:t}).then(Ie,Ce)}getAdoption(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"adoption",filterOptions:t}).then(Ie,Ce)}getInternalMessages(e,t={}){return this.web3data.address.getFunctions(e,t)}getFunctions(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"functions",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getLogs(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"logs",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getTransactions(e,t={}){return ke(!e,Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"transactions",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getPendingTransactions(e,t={}){return ke(!e,Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"pending-transactions",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getBalance(e,t={}){ke(ye.notHash(e),Ae);let n="information";return Array.isArray(e)?(n="balances",t.addresses=e):t.includeTokens?n="balances":(t.startDate||t.endDate)&&(n="account-balances/historical"),ve(this.web3data,{...t.addresses?{}:{hash:e},endpoint:Re,subendpoint:n,filterOptions:t}).then(Ie,Ce)}getTokens(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"tokens",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getTokenTransfers(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"token-transfers",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getTokenBalances(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"token-balances",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getUsage(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"usage",filterOptions:t}).then(Ie,Ce)}getMetrics(){return ve(this.web3data,{endpoint:Re,subendpoint:"metrics/latest"}).then(Ie,Ce)}};const{is:Be,get:Me,onFulfilled:Pe,onError:Le,throwIf:xe,recordsFormatter:Ue}=Se,{ERROR_MESSAGE_TOKEN_NO_ADDRESS:Ke,ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS:Fe,TOKENS_ENDPOINT:je}=he;var Ge=class{constructor(e){this.web3data=e}getRankings(e={}){return Me(this.web3data,{endpoint:je,subendpoint:"rankings",filterOptions:e}).then(Pe,Le)}getVolume(e,t={}){return xe(Be.notHash(e),Ke),Me(this.web3data,{hash:e,endpoint:je,subendpoint:"volume",filterOptions:t}).then(Pe,Le)}getVelocity(e,t={}){return xe(Be.notHash(e),Ke),Me(this.web3data,{hash:e,endpoint:je,subendpoint:"velocity",filterOptions:t}).then(Pe,Le)}getHolders(e,t={}){xe(Be.notHash(e),Ke);let n="holders/latest",r={formatter:Ue};return t.holderAddresses&&(n="holders/historical",r={}),Me(this.web3data,{hash:e,endpoint:je,subendpoint:n,filterOptions:t}).then(Pe.bind(r),Le)}getHoldersHistorical(e,t){return xe(Be.notInObject(t,"holderAddresses"),Fe),this.getHolders(e,t)}getSupplies(e,t={}){xe(Be.notHash(e),Ke);const n=t.startDate||t.endDate?"supplies/historical":"supplies/latest";return Me(this.web3data,{hash:e,endpoint:je,subendpoint:n,filterOptions:t}).then(Pe,Le)}getTransfers(e,t={}){return xe(Be.notHash(e),Ke),Me(this.web3data,{hash:e,endpoint:je,subendpoint:"transfers",filterOptions:t}).then(Pe.bind({formatter:Ue}),Le)}};const{ERROR_MESSAGE_CONTRACT_NO_ADDRESS:$e,CONTRACTS_ENDPOINT:qe}=he,{is:We,get:ze,throwIf:Ve,onFulfilled:Je,onError:Xe}=Se;var Ye=class{constructor(e){this.web3data=e}getDetails(e){return Ve(We.notHash(e),$e),ze(this.web3data,{pathParam:e,endpoint:qe}).then(Je,Xe)}getFunctions(e){return We.notHash(e)?Promise.reject(new Error($e)):ze(this.web3data,{pathParam:e,endpoint:qe,subendpoint:"functions"}).then(Je,Xe)}getAudit(e){return this.getSecurityAudit(e)}getSecurityAudit(e){return We.notHash(e)?Promise.reject(new Error($e)):ze(this.web3data,{pathParam:e,endpoint:qe,subendpoint:"audit"}).then(Je,Xe)}getAbi(e){return Ve(We.notHash(e),$e),this.getDetails(e).then(({abi:e})=>e)}getSourceCode(e){return Ve(We.notHash(e),$e),ze(this.web3data,{pathParam:e,endpoint:qe,subendpoint:"source-code"}).then(Je,Xe)}getCode(e){return this.getDetails(e).then(e=>e.bytecode||"0x")}};const{TRANSACTIONS_ENDPOINT:Ze,ERROR_MESSAGE_TRANSACTION_NO_HASH:Qe}=he,{is:et,get:tt,onFulfilled:nt,onError:rt,throwIf:st,recordsFormatter:ot}=Se;var it=class{constructor(e){this.web3data=e}getTransactions(e={}){return tt(this.web3data,{endpoint:Ze,filterOptions:e}).then(nt.bind({formatter:ot}),rt)}getAll(e){return this.getTransactions(e)}getTransaction(e,t={}){return st(et.notHash(e),Qe),tt(this.web3data,{pathParam:e,endpoint:Ze,filterOptions:t}).then(nt,rt)}getPendingTransactions(){return this.getTransactions({status:"pending"}).then(e=>(st(et.undefined(e)||et.null(e),"Failed to retrieve pending transactions."),e),console.error)}getGasPrediction(){return tt(this.web3data,{endpoint:Ze,subendpoint:"gas/predictions"}).then(nt,rt)}getGasPercentiles(e={}){return tt(this.web3data,{endpoint:Ze,subendpoint:"gas/percentiles",filterOptions:e}).then(nt,rt)}getGasPrice(){return this.getGasPrediction().then(e=>(st(!e.average||!e.average.gasPrice,"Failed to retrieve gas price."),`${e.average.gasPrice}`))}getVolume(e={}){return tt(this.web3data,{endpoint:Ze,subendpoint:"volume",filterOptions:e}).then(nt,rt)}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return tt(this.web3data,{endpoint:`${Ze}/metrics`,subendpoint:t,filterOptions:e}).then(nt.bind({formatter:ot}),rt)}};const{BLOCKS_ENDPOINT:at,ERROR_MESSAGE_BLOCK_NO_ID:ct}=he,{is:dt,get:ut,throwIf:ht,onFulfilled:lt,onError:pt,recordsFormatter:ft}=Se;var bt=class{constructor(e){this.web3data=e}getBlocks(e){return ut(this.web3data,{endpoint:at,filterOptions:e}).then(lt.bind({formatter:ft}),pt)}getBlock(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,filterOptions:t}).then(lt,pt)}getBlockNumber(){return this.web3data.block.getBlock("latest").then(e=>(ht(e|!e.number,"Failed to retrieve block number."),parseInt(e.number,10)))}getBlockTransactionCount(e){return this.web3data.block.getBlock(e).then(e=>(ht(!e||!e.predictions&&!e.numTransactions,"Failed to retrieve block transaction count."),e.predictions?null:parseInt(e.numTransactions,10)))}getTransactions(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,subendpoint:"transactions",filterOptions:t}).then(lt.bind({formatter:ft}),pt)}getTransactionFromBlock(e,t){return ht(dt.undefined(e),ct),this.web3data.block.getTransactions(e).then(e=>(ht(!e,"Failed to retrieve transaction."),t<e.length&&t>-1?e[t]:null))}getUncle(e,t){return ht(dt.undefined(e),ct),ht(dt.undefined(t),"Missing required param 'index'"),this.web3data.block.getBlock(e,{validationMethod:"full"}).then(e=>(ht(!e||!e.predictions&&!e.numTransactions&&!e.validation,"Failed to retrieve uncle."),!e.predictions&&e.validation.uncles&&t<e.validation.uncles.length&&t>-1?e.validation.uncles[t]:null))}getTokenTransfers(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,subendpoint:"token-transfers",filterOptions:t}).then(lt,pt)}getLogs(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,subendpoint:"logs",filterOptions:t}).then(lt.bind({formatter:ft}),pt)}getFunctions(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,subendpoint:"functions",filterOptions:t}).then(lt.bind({formatter:ft}),pt)}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return ut(this.web3data,{endpoint:`${at}/metrics`,subendpoint:t,filterOptions:e}).then(lt.bind({formatter:ft}),pt)}};const{BLOCKCHAINS_ENDPOINT:gt}=he,{get:Et,onFulfilled:mt,onError:_t}=Se;var Ot=class{constructor(e){this.web3data=e}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return Et(this.web3data,{endpoint:`${gt}/metrics`,subendpoint:t,filterOptions:e}).then(mt,_t)}};const{get:wt,is:Tt,throwIf:Nt,onError:St,onFulfilled:At}=Se,{SIGNATURES_ENDPOINT:Rt,ERROR_MESSAGE_SIGNATURE_NO_HASH:yt}=he;var vt=class{constructor(e){this.web3data=e}getSignature(e){return Nt(Tt.notHash(e),yt),wt(this.web3data,{hash:e,endpoint:Rt}).then(At,St)}};const{is:kt,get:It,throwIf:Ct,onFulfilled:Dt,onError:Ht}=Se,{MARKET_FEATURES:Bt,MARKET_ENDPOINT:Mt,ERROR_MESSAGE_MARKET_NO_PAIR:Pt,ERROR_MESSAGE_MARKET_NO_FEATURE:Lt}=he;var xt=class{constructor(e){this.web3data=e}async getEtherPrice(){return It(this.web3data,{endpoint:Mt+"/prices/eth/latest"}).then(e=>e.payload.eth_usd.price,Ht)}getRankings(e){return It(this.web3data,{endpoint:Mt,subendpoint:"rankings",filterOptions:e}).then(Dt,Ht)}getFeatures(e=Bt,t={}){return e=(e=Array.isArray(e)?e:[e]).map(e=>{switch(Ct(kt.undefined(e)||!Bt.includes(e),Lt),e){case"prices":e+="/pairs";break;case"ohlcv":case"tickers":case"trades":e+="/information"}return It(this.web3data,{endpoint:Mt,subendpoint:e,filterOptions:t}).then(Dt,Ht).then(t=>({[e.split("/")[0]]:t}))}),Promise.all([...e]).then(e=>e.reduce((e,t)=>({...e,...t})))}getOhlcv(e,t={}){Ct(kt.undefined(e),Pt);const n=t.startDate||t.endDate?"historical":"latest";return It(this.web3data,{pathParam:e,endpoint:`${Mt}/ohlcv`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getOrders(e,t,n={}){return Ct(kt.undefined(e),Pt),(t=Array.isArray(t)?t:[t]).forEach(e=>Ct(kt.undefined(e),"No exchange specified")),n.exchange=t,It(this.web3data,{pathParam:e,endpoint:`${Mt}/orders`,filterOptions:n}).then(Dt,Ht)}getOrderBooks(e,t={}){return Ct(kt.undefined(e),Pt),It(this.web3data,{pathParam:e,endpoint:`${Mt}/orders`,subendpoint:"update",filterOptions:t}).then(Dt,Ht)}getBbos(e,t={}){Ct(kt.undefined(e),Pt);const n=t.startDate||t.endDate?"bbo/historical":"bbo";return It(this.web3data,{pathParam:e,endpoint:`${Mt}/orders`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getPrices(e,t={}){Ct(kt.undefined(e),Pt);const n=t.startDate||t.endDate?"historical":"latest";return It(this.web3data,{pathParam:e,endpoint:`${Mt}/prices`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getTokenPrices(e,t={}){Ct(kt.notHash(e),Pt);const n=t.startDate||t.endDate?"historical":"latest";return It(this.web3data,{hash:e,endpoint:`${Mt}/tokens/prices`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getVwap(e,t={}){return Ct(kt.undefined(e),Pt),It(this.web3data,{pathParam:e,endpoint:`${Mt}/prices`,subendpoint:"wap/latest",filterOptions:t}).then(Dt,Ht)}getTickers(e,t={}){Ct(kt.undefined(e),Pt);const n=t.startDate||t.endDate?"historical":"latest";return It(this.web3data,{pathParam:e,endpoint:`${Mt}/tickers`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getTrades(e,t={}){return Ct(kt.undefined(e),Pt),It(this.web3data,{pathParam:e,endpoint:`${Mt}/trades`,subendpoint:"historical",filterOptions:t}).then(Dt,Ht)}getAssetAddresses(e="all"){return It(this.web3data,{endpoint:`${Mt}/pairs/addresses`,filterOptions:{symbols:e}}).then(Dt,Ht)}};const{ethFactory:Ut}=Se,{BLOCKCHAIN_ID_ETHEREUM_MAINNET:Kt}=he;var Ft=class{constructor(e,t,n){n.blockchainId=Kt,this.web3data=new e(t,n);const r=Ut(this.web3data);for(const e in r)({}).hasOwnProperty.call(r,e)&&(this[e]=r[e])}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN:jt,BTC_METHODS:Gt}=he,{methodFactory:$t}=Se;var qt=class{constructor(e,t,n){n.blockchainId=jt,this.web3data=new e(t,n),$t(this,Gt)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN_CASH:Wt,BTC_METHODS:zt}=he,{methodFactory:Vt}=Se;var Jt=class{constructor(e,t,n){n.blockchainId=Wt,this.web3data=new e(t,n),Vt(this,zt)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN_SV:Xt,BTC_METHODS:Yt}=he,{methodFactory:Zt}=Se;var Qt=class{constructor(e,t,n){n.blockchainId=Xt,this.web3data=new e(t,n),Zt(this,Yt)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_LITECOIN:en,LTC_METHODS:tn}=he,{methodFactory:nn}=Se;var rn=class{constructor(e,t,n){n.blockchainId=en,this.web3data=new e(t,n),nn(this,tn)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_STELLAR:sn,BTC_METHODS:on}=he,{methodFactory:an}=Se;var cn=class{constructor(e,t,n){n.blockchainId=sn,this.web3data=new e(t,n),an(this,on)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_ZCASH:dn,BTC_METHODS:un}=he,{methodFactory:hn}=Se;var ln=class{constructor(e,t,n){n.blockchainId=dn,this.web3data=new e(t,n),hn(this,un)}rpc(e,t){return this.web3data.rpc(e,t)}},pn=null;"undefined"!=typeof WebSocket?pn=WebSocket:"undefined"!=typeof MozWebSocket?pn=MozWebSocket:void 0!==ue?pn=ue.WebSocket||ue.MozWebSocket:"undefined"!=typeof window?pn=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(pn=self.WebSocket||self.MozWebSocket);var fn=pn;const{DEFAULT_WEBSOCKET_URL:bn}=he,{is:gn,uuid:En}=Se,mn=e=>e?(e.params&&(e.params=Array.isArray(e.params)?e.params:[e.params]),JSON.stringify({jsonrpc:e.version||"2.0",method:e.method||"subscribe",id:e.id||0,params:e.params||[]})):"",_n=0,On=1,wn=2;var Tn=class{constructor(e,t){return this.socket=null,this.baseWsUrl=t&&t.websocketUrl?t.websocketUrl:bn,this.apiKey=e,this.blockchainId=null,this.connected=!1,this.reconnects=0,this.responseReceived=!1,this.dataReceived=!1,t.blockchainId&&(this.blockchainId=t.blockchainId),this.registry={},this.registrySubIds={},this.latestState={},this}connect(e){if(this.socket&&1===this.socket.readyState)return;const t=this.apiKey?`?x-api-key=${this.apiKey}`:"",n=this.blockchainId?`&x-amberdata-blockchain-id=${this.blockchainId}`:"";this.socket=new fn(`${this.baseWsUrl}${t}${n}`),this.socket.addEventListener("open",t=>{console.info("websocket client connection opened"),this.connected=!0,this._refreshSubscriptions(),this._listen(),e&&e(t),setTimeout(()=>{!this.responseReceived&&gn.nonEmptyObject(this.registry)&&this.socket&&this.socket.close()},5e3),setTimeout(()=>{!this.dataReceived&&gn.nonEmptyObject(this.registry)&&this.socket.close()},18e5)}),this.socket.addEventListener("error",t=>{e&&t?e("connection error occurred",t):console.error("connection error occurred"),this._reconnect()}),this.socket.addEventListener("close",e=>{console.info("Websocket client connection closed - code",e.code),this._reconnect()})}disconnect(e=null){this.socket&&1===this.socket.readyState?(this.socket.onclose=e?()=>e("Websocket client connection closed"):()=>console.info("Websocket client connection closed"),this.socket.close(),this.socket=null):console.error("socket is not yet connected")}on({eventName:e,filters:t},n){if(n||console.warn("no callback provided"),!e)return void console.error("no event specified");const r=En({eventName:e,filters:t});this.connected&&this._subscribe(e,t),this.registry[r]={},this.registry[r].callback=n,this.registry[r].args={eventName:e,filters:t}}once({eventName:e,filters:t},n){this.on({eventName:e,filters:t},r=>{this.off({eventName:e,filters:t},()=>{}),n&&n(r),this.registry[En({eventName:e,filters:t})].callback=null})}off({eventName:e,filters:t},n){if(n||console.warn("no callback provided"),!e)return void console.error("no event specified");const r=En({eventName:e,filters:t});this.registry[r]&&this.registry[r].subId?(this.registry[r].isSubscribed=!1,this.registry[r].unsubCallback=n||(()=>{}),this._unsubscribe(e,t,r)):console.error(`Not subscribed to: '${e}'`)}_reconnect(){1===this.socket.readyState&&this.disconnect(),++this.reconnects<=3&&(console.warn(`attempting to reconnect...${this.reconnects}/3`),this.connect())}_refreshSubscriptions(){if(this.registry)for(const{args:{eventName:e,filters:t}}of Object.values(this.registry))this._subscribe(e,t)}_listen(){this.socket.addEventListener("message",e=>{let t;try{t=JSON.parse(e.data)}catch(e){return void console.error("error parsing json request -",e)}switch(this.responseReceived=!0,(e=>e.params?On:gn.string(e.result)?_n:gn.bool(e.result)?wn:void 0)(t)){case _n:this._subHandler(t);break;case On:this._dataHandler(t);break;case wn:this._unsubHandler(t)}})}_subHandler(e){const t=e&&e.id?e.id:"";this.registrySubIds[e.result]=t,this.registry[t].subId=e.result,this.registry[t].isSubscribed=!0}_dataHandler(e){this.dataReceived=!0;const t=e&&e.params&&e.params.result?e.params.result:{},n=e&&e.params&&e.params.subscription?e.params.subscription:"",r=this.registrySubIds[n];this.registry[r].isSubscribed&&(this.registry[r]&&this.registry[r].callback&&this.registry[r].callback(t),gn.notUndefined(this.latestState[r])&&(this.latestState[r]=t))}_unsubHandler(e){const t=e&&e.id?e.id:"",{eventName:n}=this.registry[t].args;e.result?(this.registry[t].unsubCallback(`successfully unsubscribed from - ${n}`),delete this.registry[t]):this.registry[t].unsubCallback(`Error: Not unsubscribed from - ${n}`)}_subscribe(e,t){const n=gn.notUndefined(t)?[t]:[],r=En({eventName:e,filters:t}),s=mn({id:r,params:[e,...n]});this.socket.send(s)}_unsubscribe(e,t,n){const r=mn({id:n,method:"unsubscribe",params:[this.registry[n].subId]});this.socket.readyState===this.socket.OPEN&&this.socket.send(r)}};const{API_KEY_HEADER:Nn,BLOCKCHAIN_ID_HEADER:Sn,DEFAULT_BASE_URL:An,DEFAULT_RPC_URL:Rn,ERROR_RPC_NO_METHOD:yn}=he,{is:vn,throwIf:kn,formatJsonRpc:In}=Se;class Cn{constructor(e,t={}){kn(vn.undefined(e)||vn.emptyString(e),"No api key supplied"),this.apiKey=e,this.blockchainId=null,this.headers={},this.headers[Nn]=this.apiKey,t.blockchainId&&(this.blockchainId=t.blockchainId,this.headers[Sn]=t.blockchainId),this.wsConfig={...t,websocketUrl:t.websocketUrl?t.websocketUrl:null},this.baseUrl=t.baseUrl?t.baseUrl:An,this.address=new He(this),this.token=new Ge(this),this.contract=new Ye(this),this.transaction=new it(this),this.block=new bt(this),this.blockchain=new Ot(this),this.signature=new vt(this),this.market=new xt(this)}rawQuery(e){return de.get(this.baseUrl+e,{headers:this.headers}).then(e=>e.data)}rpc(e,t=[]){return kn(!e,yn),de.post(`${Rn}?${Nn}=${this.apiKey}&${Sn}=${this.blockchainId}`,In({method:e,params:t}),{headers:this.headers}).then(e=>e.data,e=>e.response.data)}}var Dn=class extends Cn{constructor(e,t={}){super(e,t),this.eth=new Ft(Cn,e,t),this.btc=new qt(Cn,e,t),this.bch=new Jt(Cn,e,t),this.bsv=new Qt(Cn,e,t),this.ltc=new rn(Cn,e,t),this.xlm=new cn(Cn,e,t),this.zec=new ln(Cn,e,t),this.websocket=null}connect(e){return this.websocket=this.websocket?this.websocket:new Tn(this.apiKey,this.wsConfig),this.websocket.connect(e)}disconnect(e){this.websocket?this.websocket.disconnect(e):console.error("socket is not yet connected")}on({eventName:e,filters:t},n){n||console.warn("no callback provided"),e?this.websocket.on({eventName:e,filters:t},n):console.error("no event specified")}once({eventName:e,filters:t},n){this.websocket.once({eventName:e,filters:t},n)}off({eventName:e,filters:t},n){n||console.warn("no callback provided"),e?this.websocket.off({eventName:e,filters:t},n):console.error("no event specified")}};return"undefined"!=typeof window&&void 0===window.Web3Data&&(window.Web3Data=Dn),Dn})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).web3data=t()}(this,(function(){"use strict";var e=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},t=Object.prototype.toString;function n(e){return"[object Array]"===t.call(e)}function r(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function o(e){return"[object Function]"===t.call(e)}function i(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),n(e))for(var r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var a={isArray:n,isArrayBuffer:function(e){return"[object ArrayBuffer]"===t.call(e)},isBuffer:function(e){return null!==e&&!r(e)&&null!==e.constructor&&!r(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isUndefined:r,isDate:function(e){return"[object Date]"===t.call(e)},isFile:function(e){return"[object File]"===t.call(e)},isBlob:function(e){return"[object Blob]"===t.call(e)},isFunction:o,isStream:function(e){return s(e)&&o(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:i,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,s=arguments.length;r<s;r++)i(arguments[r],n);return t},deepMerge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]="object"==typeof n?e({},n):n}for(var r=0,s=arguments.length;r<s;r++)i(arguments[r],n);return t},extend:function(t,n,r){return i(n,(function(n,s){t[s]=r&&"function"==typeof n?e(n,r):n})),t},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}};function c(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var d=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(a.isURLSearchParams(t))r=t.toString();else{var s=[];a.forEach(t,(function(e,t){null!=e&&(a.isArray(e)?t+="[]":e=[e],a.forEach(e,(function(e){a.isDate(e)?e=e.toISOString():a.isObject(e)&&(e=JSON.stringify(e)),s.push(c(t)+"="+c(e))})))})),r=s.join("&")}if(r){var o=e.indexOf("#");-1!==o&&(e=e.slice(0,o)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e};function u(){this.handlers=[]}u.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},u.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},u.prototype.forEach=function(e){a.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var h=u,l=function(e,t,n){return a.forEach(n,(function(n){e=n(e,t)})),e},p=function(e){return!(!e||!e.__CANCEL__)},f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function b(){throw new Error("setTimeout has not been defined")}function g(){throw new Error("clearTimeout has not been defined")}var E=b,m=g;function _(e){if(E===setTimeout)return setTimeout(e,0);if((E===b||!E)&&setTimeout)return E=setTimeout,setTimeout(e,0);try{return E(e,0)}catch(t){try{return E.call(null,e,0)}catch(t){return E.call(this,e,0)}}}"function"==typeof f.setTimeout&&(E=setTimeout),"function"==typeof f.clearTimeout&&(m=clearTimeout);var O,w=[],T=!1,N=-1;function S(){T&&O&&(T=!1,O.length?w=O.concat(w):N=-1,w.length&&A())}function A(){if(!T){var e=_(S);T=!0;for(var t=w.length;t;){for(O=w,w=[];++N<t;)O&&O[N].run();N=-1,t=w.length}O=null,T=!1,function(e){if(m===clearTimeout)return clearTimeout(e);if((m===g||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(e);try{m(e)}catch(t){try{return m.call(null,e)}catch(t){return m.call(this,e)}}}(e)}}function R(e,t){this.fun=e,this.array=t}R.prototype.run=function(){this.fun.apply(null,this.array)};function y(){}var v=y,k=y,I=y,C=y,D=y,H=y,B=y;var M=f.performance||{},P=M.now||M.mozNow||M.msNow||M.oNow||M.webkitNow||function(){return(new Date).getTime()};var L=new Date;var x={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];w.push(new R(e,t)),1!==w.length||T||_(A)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:v,addListener:k,once:I,off:C,removeListener:D,removeAllListeners:H,emit:B,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*P.call(M),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-L)/1e3}},U=function(e,t){a.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},K=function(e,t,n,r,s){return function(e,t,n,r,s){return e.config=t,n&&(e.code=n),e.request=r,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}(new Error(e),t,n,r,s)},F=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],j=a.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=a.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},G=a.isStandardBrowserEnv()?{write:function(e,t,n,r,s,o){var i=[];i.push(e+"="+encodeURIComponent(t)),a.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),a.isString(r)&&i.push("path="+r),a.isString(s)&&i.push("domain="+s),!0===o&&i.push("secure"),document.cookie=i.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},$=function(e){return new Promise((function(t,n){var r=e.data,s=e.headers;a.isFormData(r)&&delete s["Content-Type"];var o=new XMLHttpRequest;if(e.auth){var i=e.auth.username||"",c=e.auth.password||"";s.Authorization="Basic "+btoa(i+":"+c)}var u,h,l=(u=e.baseURL,h=e.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(u,h):h);if(o.open(e.method.toUpperCase(),d(l,e.params,e.paramsSerializer),!0),o.timeout=e.timeout,o.onreadystatechange=function(){if(o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in o?function(e){var t,n,r,s={};return e?(a.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=a.trim(e.substr(0,r)).toLowerCase(),n=a.trim(e.substr(r+1)),t){if(s[t]&&F.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}(o.getAllResponseHeaders()):null,s={data:e.responseType&&"text"!==e.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:r,config:e,request:o};!function(e,t,n){var r=n.config.validateStatus;!r||r(n.status)?e(n):t(K("Request failed with status code "+n.status,n.config,null,n.request,n))}(t,n,s),o=null}},o.onabort=function(){o&&(n(K("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){n(K("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(K(t,e,"ECONNABORTED",o)),o=null},a.isStandardBrowserEnv()){var p=G,f=(e.withCredentials||j(l))&&e.xsrfCookieName?p.read(e.xsrfCookieName):void 0;f&&(s[e.xsrfHeaderName]=f)}if("setRequestHeader"in o&&a.forEach(s,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete s[t]:o.setRequestHeader(t,e)})),a.isUndefined(e.withCredentials)||(o.withCredentials=!!e.withCredentials),e.responseType)try{o.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&o.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){o&&(o.abort(),n(e),o=null)})),void 0===r&&(r=null),o.send(r)}))},q={"Content-Type":"application/x-www-form-urlencoded"};function W(e,t){!a.isUndefined(e)&&a.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var z,V={adapter:("undefined"!=typeof XMLHttpRequest?z=$:void 0!==x&&"[object process]"===Object.prototype.toString.call(x)&&(z=$),z),transformRequest:[function(e,t){return U(t,"Accept"),U(t,"Content-Type"),a.isFormData(e)||a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)?e:a.isArrayBufferView(e)?e.buffer:a.isURLSearchParams(e)?(W(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):a.isObject(e)?(W(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};V.headers={common:{Accept:"application/json, text/plain, */*"}},a.forEach(["delete","get","head"],(function(e){V.headers[e]={}})),a.forEach(["post","put","patch"],(function(e){V.headers[e]=a.merge(q)}));var J=V;function X(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Y=function(e){return X(e),e.headers=e.headers||{},e.data=l(e.data,e.headers,e.transformRequest),e.headers=a.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),a.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||J.adapter)(e).then((function(t){return X(e),t.data=l(t.data,t.headers,e.transformResponse),t}),(function(t){return p(t)||(X(e),t&&t.response&&(t.response.data=l(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Z=function(e,t){t=t||{};var n={},r=["url","method","params","data"],s=["headers","auth","proxy"],o=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];a.forEach(r,(function(e){void 0!==t[e]&&(n[e]=t[e])})),a.forEach(s,(function(r){a.isObject(t[r])?n[r]=a.deepMerge(e[r],t[r]):void 0!==t[r]?n[r]=t[r]:a.isObject(e[r])?n[r]=a.deepMerge(e[r]):void 0!==e[r]&&(n[r]=e[r])})),a.forEach(o,(function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])}));var i=r.concat(s).concat(o),c=Object.keys(t).filter((function(e){return-1===i.indexOf(e)}));return a.forEach(c,(function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])})),n};function Q(e){this.defaults=e,this.interceptors={request:new h,response:new h}}Q.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=Z(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[Y,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},Q.prototype.getUri=function(e){return e=Z(this.defaults,e),d(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},a.forEach(["delete","get","head","options"],(function(e){Q.prototype[e]=function(t,n){return this.request(a.merge(n||{},{method:e,url:t}))}})),a.forEach(["post","put","patch"],(function(e){Q.prototype[e]=function(t,n,r){return this.request(a.merge(r||{},{method:e,url:t,data:n}))}}));var ee=Q;function te(e){this.message=e}te.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},te.prototype.__CANCEL__=!0;var ne=te;function re(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new ne(e),t(n.reason))}))}re.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},re.source=function(){var e;return{token:new re((function(t){e=t})),cancel:e}};var se=re;function oe(t){var n=new ee(t),r=e(ee.prototype.request,n);return a.extend(r,ee.prototype,n),a.extend(r,n),r}var ie=oe(J);ie.Axios=ee,ie.create=function(e){return oe(Z(ie.defaults,e))},ie.Cancel=ne,ie.CancelToken=se,ie.isCancel=p,ie.all=function(e){return Promise.all(e)},ie.spread=function(e){return function(t){return e.apply(null,t)}};var ae=ie,ce=ie;ae.default=ce;var de=ae,ue="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var he=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){e.exports.DEFAULT_WEBSOCKET_URL="wss://ws.web3api.io",e.exports.DEFAULT_BASE_URL="https://web3api.io/api/v2",e.exports.DEFAULT_RPC_URL="https://rpc.web3api.io",e.exports.API_KEY_HEADER="x-api-key",e.exports.BLOCKCHAIN_ID_HEADER="x-amberdata-blockchain-id",e.exports.BLOCKCHAIN_ID_ETHEREUM_MAINNET="1c9c969065fcd1cf",e.exports.BLOCKCHAIN_ID_ETHEREUM_RINKEBY="1b3f7a72b3e99c13",e.exports.BLOCKCHAIN_ID_BITCOIN="408fa195a34b533de9ad9889f076045e",e.exports.BLOCKCHAIN_ID_BITCOIN_CASH="43b45e71cc0615b491cb699e7071fc06",e.exports.BLOCKCHAIN_ID_BITCOIN_SV="a818635d36dbe125e26167c4438e2217",e.exports.BLOCKCHAIN_ID_LITECOIN="f94be61fd9f4fa684f992ddfd4e92272",e.exports.BLOCKCHAIN_ID_RIPPLE="2b8a5d8975e8c2a2ed92450450979a3c",e.exports.BLOCKCHAIN_ID_ZCASH="b7d4f994f33c709be4ce6cbae31d7b8e",e.exports.BLOCKCHAIN_ID_STELLAR="822e2ebe02f74df8",e.exports.ADDRESSES_ENDPOINT="/addresses",e.exports.TOKENS_ENDPOINT="/tokens",e.exports.TRANSACTIONS_ENDPOINT="/transactions",e.exports.BLOCKS_ENDPOINT="/blocks",e.exports.BLOCKCHAINS_ENDPOINT="/blockchains",e.exports.CONTRACTS_ENDPOINT="/contracts",e.exports.SIGNATURES_ENDPOINT="/signatures",e.exports.MARKET_ENDPOINT="/market",e.exports.MARKET_FEATURES=["pairs","exchanges","ohlcv","prices","tickers","trades"],e.exports.ERROR_MESSAGE_TOKEN_NO_ADDRESS="No token address supplied",e.exports.ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS="No token holder address supplied",e.exports.ERROR_MESSAGE_TRANSACTION_NO_HASH="No transaction hash supplied",e.exports.ERROR_MESSAGE_ADDRESS_NO_ADDRESS="No address supplied",e.exports.ERROR_MESSAGE_CONTRACT_NO_ADDRESS="No contract address supplied",e.exports.ERROR_MESSAGE_BLOCK_NO_ID="No block number or hash supplied",e.exports.ERROR_MESSAGE_MARKET_NO_PAIR="No market pair supplied",e.exports.ERROR_MESSAGE_MARKET_NO_FEATURE=`Missing or unknown. Features: '${e.exports.MARKET_FEATURES.join("', '")}'`,e.exports.ERROR_MESSAGE_SIGNATURE_NO_HASH="No signature hash supplied",e.exports.ERROR_RPC_NO_METHOD="No RPC method provided",e.exports.ETH_METHODS={getBlockNumber:"block",getBlock:"block",getBlockTransactionCount:"block",getUncle:"block",getCode:"contract",getGasPrice:"transaction",getTransactionFromBlock:"block",getTransactions:"block",getTransaction:"transaction",getPendingTransactions:"transaction",getEtherPrice:"market",getBalance:"address",getMetrics:"block"},e.exports.BTC_METHODS={address:["getAllAddresses","getInformation","getMetadata","getTransactions","getPendingTransactions","getBalance","getMetrics"],block:["getBlocks","getBlock","getBlockNumber","getTransactions","getTransactionFromBlock","getMetrics"],blockchain:["getMetrics"],transaction:["getTransactions","getTransaction","getPendingTransactions","getMetrics"]},e.exports.LTC_METHODS={address:["getAllAddresses","getInformation","getMetadata","getTransactions","getPendingTransactions","getBalance","getMetrics"],block:["getBlocks","getBlock","getBlockNumber","getTransactions","getTransactionFromBlock","getMetrics"],blockchain:["getMetrics"],transaction:["getTransactions","getTransaction","getPendingTransactions","getMetrics"]},e.exports.XLM_METHODS={address:["getAllAddresses","getInformation","getMetadata","getTransactions","getBalance","getMetrics"],block:["getBlocks","getBlock","getBlockNumber","getTransactions","getTransactionFromBlock","getMetrics"],blockchain:["getMetrics"],transaction:["getTransactions","getTransaction","getMetrics"]},e.exports.HTTP_CODE_NOT_FOUND=404})),le=(he.DEFAULT_WEBSOCKET_URL,he.DEFAULT_BASE_URL,he.DEFAULT_RPC_URL,he.API_KEY_HEADER,he.BLOCKCHAIN_ID_HEADER,he.BLOCKCHAIN_ID_ETHEREUM_MAINNET,he.BLOCKCHAIN_ID_ETHEREUM_RINKEBY,he.BLOCKCHAIN_ID_BITCOIN,he.BLOCKCHAIN_ID_BITCOIN_CASH,he.BLOCKCHAIN_ID_BITCOIN_SV,he.BLOCKCHAIN_ID_LITECOIN,he.BLOCKCHAIN_ID_RIPPLE,he.BLOCKCHAIN_ID_ZCASH,he.BLOCKCHAIN_ID_STELLAR,he.ADDRESSES_ENDPOINT,he.TOKENS_ENDPOINT,he.TRANSACTIONS_ENDPOINT,he.BLOCKS_ENDPOINT,he.BLOCKCHAINS_ENDPOINT,he.CONTRACTS_ENDPOINT,he.SIGNATURES_ENDPOINT,he.MARKET_ENDPOINT,he.MARKET_FEATURES,he.ERROR_MESSAGE_TOKEN_NO_ADDRESS,he.ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS,he.ERROR_MESSAGE_TRANSACTION_NO_HASH,he.ERROR_MESSAGE_ADDRESS_NO_ADDRESS,he.ERROR_MESSAGE_CONTRACT_NO_ADDRESS,he.ERROR_MESSAGE_BLOCK_NO_ID,he.ERROR_MESSAGE_MARKET_NO_PAIR,he.ERROR_MESSAGE_MARKET_NO_FEATURE,he.ERROR_MESSAGE_SIGNATURE_NO_HASH,he.ERROR_RPC_NO_METHOD,he.ETH_METHODS,he.BTC_METHODS,he.LTC_METHODS,he.XLM_METHODS,he.HTTP_CODE_NOT_FOUND,[]),pe=0;pe<256;++pe)le[pe]=(pe+256).toString(16).substr(1);var fe=function(e,t){var n=t||0,r=le;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")};function be(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function ge(e,t){return e<<t|e>>>32-t}var Ee=function(e,t,n){var r=function(e,r,s,o){var i=s&&o||0;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(e)),"string"==typeof r&&(r=function(e){var t=[];return e.replace(/[a-fA-F0-9]{2}/g,(function(e){t.push(parseInt(e,16))})),t}(r)),!Array.isArray(e))throw TypeError("value must be an array of bytes");if(!Array.isArray(r)||16!==r.length)throw TypeError("namespace must be uuid string or an Array of 16 byte values");var a=n(r.concat(e));if(a[6]=15&a[6]|t,a[8]=63&a[8]|128,s)for(var c=0;c<16;++c)s[i+c]=a[c];return s||fe(a)};try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=new Array(r.length);for(var s=0;s<r.length;s++)e[s]=r.charCodeAt(s)}e.push(128);var o=e.length/4+2,i=Math.ceil(o/16),a=new Array(i);for(s=0;s<i;s++){a[s]=new Array(16);for(var c=0;c<16;c++)a[s][c]=e[64*s+4*c]<<24|e[64*s+4*c+1]<<16|e[64*s+4*c+2]<<8|e[64*s+4*c+3]}for(a[i-1][14]=8*(e.length-1)/Math.pow(2,32),a[i-1][14]=Math.floor(a[i-1][14]),a[i-1][15]=8*(e.length-1)&4294967295,s=0;s<i;s++){for(var d=new Array(80),u=0;u<16;u++)d[u]=a[s][u];for(u=16;u<80;u++)d[u]=ge(d[u-3]^d[u-8]^d[u-14]^d[u-16],1);var h=n[0],l=n[1],p=n[2],f=n[3],b=n[4];for(u=0;u<80;u++){var g=Math.floor(u/20),E=ge(h,5)+be(g,l,p,f)+b+t[g]+d[u]>>>0;b=f,f=p,p=ge(l,30)>>>0,l=h,h=E}n[0]=n[0]+h>>>0,n[1]=n[1]+l>>>0,n[2]=n[2]+p>>>0,n[3]=n[3]+f>>>0,n[4]=n[4]+b>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));const{ETH_METHODS:me}=he,_e=e=>{let t="";for(const n in e)({}).hasOwnProperty.call(e,n)&&(t+=`${n}=${e[n]}&`);return t},Oe=(e,t)=>{if(e)throw new Error(t)},we=e=>Oe(!0,e),Te=()=>{};Te.string=e=>"string"==typeof e,Te.bool=e=>"boolean"==typeof e,Te.emptyString=e=>Te.string(e)&&0===e.length,Te.emptyObject=e=>0===Object.keys(e).length,Te.inObject=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Te.undefined=e=>void 0===e,Te.null=e=>null===e,Te.notHash=e=>Te.undefined(e)||Te.emptyString(e),Te.notUndefined=e=>!Te.undefined(e),Te.nonEmptyObject=e=>!Te.emptyObject(e),Te.nonEmptyString=e=>!Te.emptyString(e),Te.notInObject=(e,t)=>!Te.inObject(e,t);const Ne=e=>Object.getOwnPropertyNames(e).filter(t=>"function"==typeof e[t]&&"constructor"!==t);var Se={buildFilterUrl:_e,is:Te,throwIf:Oe,get:(e,{endpoint:t="",subendpoint:n="",hash:r="",pathParam:s="",filterOptions:o={}})=>{const i=Te.nonEmptyObject(o)?"?"+_e(o):"";return r=r?"/"+r:"",s=s?"/"+s:"",n=n?"/"+n:"",e.rawQuery(`${t}${r||s}${n}${i}`)},rejectPromiseIf:(e,t)=>{if(e)return Promise.reject(new Error(t))},uuid:e=>Ee(JSON.stringify(e),"ccfeca02-f0e9-4433-a740-b830cceb3d2d"),ethFactory:function(e){const t={};for(const n in me)({}).hasOwnProperty.call(me,n)&&(t[n]=e[me[n]][n].bind(e[me[n]]));return t},methodFactory:(e,t)=>(Object.keys(t).forEach(n=>{Ne(Object.getPrototypeOf(e.web3data[n])).forEach(r=>{t[n].includes(r)&&(e[n]=e[n]?e[n]:{},e[n][r]=e.web3data[n][r].bind(e))})}),e),throwNow:we,onFulfilled:function(e){return Oe(e.error,e.message),this&&this.formatter?this.formatter(e.payload):e.payload},onError:({response:{data:e}})=>we(e.message||e.description),formatJsonRpc:e=>e?(e.params&&(e.params=Array.isArray(e.params)?e.params:[e.params]),JSON.stringify({jsonrpc:e.version||"2.0",method:e.method||"subscribe",id:e.id||0,params:e.params||[]})):"",getMethods:Ne,recordsFormatter:e=>((e,t)=>e&&e[t]?e[t]:e)(e,"records")};const{ERROR_MESSAGE_ADDRESS_NO_ADDRESS:Ae,ADDRESSES_ENDPOINT:Re}=he,{is:ye,get:ve,throwIf:ke,onFulfilled:Ie,onError:Ce,recordsFormatter:De}=Se;var He=class{constructor(e){this.web3data=e}getAllAddresses(e={}){return this.getAll(e)}getAll(e={}){return ve(this.web3data,{endpoint:Re,filterOptions:e}).then(Ie.bind({formatter:De}),Ce)}getInformation(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"information",filterOptions:t}).then(Ie,Ce)}getMetadata(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"metadata",filterOptions:t}).then(Ie,Ce)}getAdoption(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"adoption",filterOptions:t}).then(Ie,Ce)}getInternalMessages(e,t={}){return this.web3data.address.getFunctions(e,t)}getFunctions(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"functions",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getLogs(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"logs",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getTransactions(e,t={}){return ke(!e,Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"transactions",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getPendingTransactions(e,t={}){return ke(!e,Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"pending-transactions",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getBalance(e,t={}){ke(ye.notHash(e),Ae);let n="information";return Array.isArray(e)?(n="balances",t.addresses=e):t.includeTokens?n="balances":(t.startDate||t.endDate)&&(n="account-balances/historical"),ve(this.web3data,{...t.addresses?{}:{hash:e},endpoint:Re,subendpoint:n,filterOptions:t}).then(Ie,Ce)}getTokens(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"tokens",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getTokenTransfers(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"token-transfers",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getTokenBalances(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"token-balances",filterOptions:t}).then(Ie.bind({formatter:De}),Ce)}getUsage(e,t={}){return ke(ye.notHash(e),Ae),ve(this.web3data,{hash:e,endpoint:Re,subendpoint:"usage",filterOptions:t}).then(Ie,Ce)}getMetrics(){return ve(this.web3data,{endpoint:Re,subendpoint:"metrics/latest"}).then(Ie,Ce)}};const{is:Be,get:Me,onFulfilled:Pe,onError:Le,throwIf:xe,recordsFormatter:Ue}=Se,{ERROR_MESSAGE_TOKEN_NO_ADDRESS:Ke,ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS:Fe,TOKENS_ENDPOINT:je}=he;var Ge=class{constructor(e){this.web3data=e}getRankings(e={}){return Me(this.web3data,{endpoint:je,subendpoint:"rankings",filterOptions:e}).then(Pe,Le)}getVolume(e,t={}){return xe(Be.notHash(e),Ke),Me(this.web3data,{hash:e,endpoint:je,subendpoint:"volume",filterOptions:t}).then(Pe,Le)}getVelocity(e,t={}){return xe(Be.notHash(e),Ke),Me(this.web3data,{hash:e,endpoint:je,subendpoint:"velocity",filterOptions:t}).then(Pe,Le)}getHolders(e,t={}){xe(Be.notHash(e),Ke);let n="holders/latest",r={formatter:Ue};return t.holderAddresses&&(n="holders/historical",r={}),Me(this.web3data,{hash:e,endpoint:je,subendpoint:n,filterOptions:t}).then(Pe.bind(r),Le)}getHoldersHistorical(e,t){return xe(Be.notInObject(t,"holderAddresses"),Fe),this.getHolders(e,t)}getSupplies(e,t={}){xe(Be.notHash(e),Ke);const n=t.startDate||t.endDate?"supplies/historical":"supplies/latest";return Me(this.web3data,{hash:e,endpoint:je,subendpoint:n,filterOptions:t}).then(Pe,Le)}getTransfers(e,t={}){return xe(Be.notHash(e),Ke),Me(this.web3data,{hash:e,endpoint:je,subendpoint:"transfers",filterOptions:t}).then(Pe.bind({formatter:Ue}),Le)}};const{ERROR_MESSAGE_CONTRACT_NO_ADDRESS:$e,CONTRACTS_ENDPOINT:qe}=he,{is:We,get:ze,throwIf:Ve,onFulfilled:Je,onError:Xe}=Se;var Ye=class{constructor(e){this.web3data=e}getDetails(e){return Ve(We.notHash(e),$e),ze(this.web3data,{pathParam:e,endpoint:qe}).then(Je,Xe)}getFunctions(e){return We.notHash(e)?Promise.reject(new Error($e)):ze(this.web3data,{pathParam:e,endpoint:qe,subendpoint:"functions"}).then(Je,Xe)}getAbi(e){return Ve(We.notHash(e),$e),this.getDetails(e).then(({abi:e})=>e)}getSourceCode(e){return Ve(We.notHash(e),$e),ze(this.web3data,{pathParam:e,endpoint:qe,subendpoint:"source-code"}).then(Je,Xe)}getCode(e){return this.getDetails(e).then(e=>e.bytecode||"0x")}};const{TRANSACTIONS_ENDPOINT:Ze,ERROR_MESSAGE_TRANSACTION_NO_HASH:Qe}=he,{is:et,get:tt,onFulfilled:nt,onError:rt,throwIf:st,recordsFormatter:ot}=Se;var it=class{constructor(e){this.web3data=e}getTransactions(e={}){return tt(this.web3data,{endpoint:Ze,filterOptions:e}).then(nt.bind({formatter:ot}),rt)}getAll(e){return this.getTransactions(e)}getTransaction(e,t={}){return st(et.notHash(e),Qe),tt(this.web3data,{pathParam:e,endpoint:Ze,filterOptions:t}).then(nt,rt)}getPendingTransactions(){return this.getTransactions({status:"pending"}).then(e=>(st(et.undefined(e)||et.null(e),"Failed to retrieve pending transactions."),e),console.error)}getGasPrediction(){return tt(this.web3data,{endpoint:Ze,subendpoint:"gas/predictions"}).then(nt,rt)}getGasPercentiles(e={}){return tt(this.web3data,{endpoint:Ze,subendpoint:"gas/percentiles",filterOptions:e}).then(nt,rt)}getGasPrice(){return this.getGasPrediction().then(e=>(st(!e.average||!e.average.gasPrice,"Failed to retrieve gas price."),`${e.average.gasPrice}`))}getVolume(e={}){return tt(this.web3data,{endpoint:Ze,subendpoint:"volume",filterOptions:e}).then(nt,rt)}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return tt(this.web3data,{endpoint:`${Ze}/metrics`,subendpoint:t,filterOptions:e}).then(nt.bind({formatter:ot}),rt)}};const{BLOCKS_ENDPOINT:at,ERROR_MESSAGE_BLOCK_NO_ID:ct}=he,{is:dt,get:ut,throwIf:ht,onFulfilled:lt,onError:pt,recordsFormatter:ft}=Se;var bt=class{constructor(e){this.web3data=e}getBlocks(e){return ut(this.web3data,{endpoint:at,filterOptions:e}).then(lt.bind({formatter:ft}),pt)}getBlock(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,filterOptions:t}).then(lt,pt)}getBlockNumber(){return this.web3data.block.getBlock("latest").then(e=>(ht(e|!e.number,"Failed to retrieve block number."),parseInt(e.number,10)))}getBlockTransactionCount(e){return this.web3data.block.getBlock(e).then(e=>(ht(!e||!e.predictions&&!e.numTransactions,"Failed to retrieve block transaction count."),e.predictions?null:parseInt(e.numTransactions,10)))}getTransactions(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,subendpoint:"transactions",filterOptions:t}).then(lt.bind({formatter:ft}),pt)}getTransactionFromBlock(e,t){return ht(dt.undefined(e),ct),this.web3data.block.getTransactions(e).then(e=>(ht(!e,"Failed to retrieve transaction."),t<e.length&&t>-1?e[t]:null))}getUncle(e,t){return ht(dt.undefined(e),ct),ht(dt.undefined(t),"Missing required param 'index'"),this.web3data.block.getBlock(e,{validationMethod:"full"}).then(e=>(ht(!e||!e.predictions&&!e.numTransactions&&!e.validation,"Failed to retrieve uncle."),!e.predictions&&e.validation.uncles&&t<e.validation.uncles.length&&t>-1?e.validation.uncles[t]:null))}getTokenTransfers(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,subendpoint:"token-transfers",filterOptions:t}).then(lt,pt)}getLogs(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,subendpoint:"logs",filterOptions:t}).then(lt.bind({formatter:ft}),pt)}getFunctions(e,t){return ht(dt.undefined(e),ct),ut(this.web3data,{pathParam:e,endpoint:at,subendpoint:"functions",filterOptions:t}).then(lt.bind({formatter:ft}),pt)}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return ut(this.web3data,{endpoint:`${at}/metrics`,subendpoint:t,filterOptions:e}).then(lt.bind({formatter:ft}),pt)}};const{BLOCKCHAINS_ENDPOINT:gt}=he,{get:Et,onFulfilled:mt,onError:_t}=Se;var Ot=class{constructor(e){this.web3data=e}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return Et(this.web3data,{endpoint:`${gt}/metrics`,subendpoint:t,filterOptions:e}).then(mt,_t)}};const{get:wt,is:Tt,throwIf:Nt,onError:St,onFulfilled:At}=Se,{SIGNATURES_ENDPOINT:Rt,ERROR_MESSAGE_SIGNATURE_NO_HASH:yt}=he;var vt=class{constructor(e){this.web3data=e}getSignature(e){return Nt(Tt.notHash(e),yt),wt(this.web3data,{hash:e,endpoint:Rt}).then(At,St)}};const{is:kt,get:It,throwIf:Ct,onFulfilled:Dt,onError:Ht}=Se,{MARKET_FEATURES:Bt,MARKET_ENDPOINT:Mt,ERROR_MESSAGE_MARKET_NO_PAIR:Pt,ERROR_MESSAGE_MARKET_NO_FEATURE:Lt}=he;var xt=class{constructor(e){this.web3data=e}async getEtherPrice(){return It(this.web3data,{endpoint:Mt+"/prices/eth/latest"}).then(e=>e.payload.eth_usd.price,Ht)}getRankings(e){return It(this.web3data,{endpoint:Mt,subendpoint:"rankings",filterOptions:e}).then(Dt,Ht)}getFeatures(e=Bt,t={}){return e=(e=Array.isArray(e)?e:[e]).map(e=>{switch(Ct(kt.undefined(e)||!Bt.includes(e),Lt),e){case"prices":e+="/pairs";break;case"ohlcv":case"tickers":case"trades":e+="/information"}return It(this.web3data,{endpoint:Mt,subendpoint:e,filterOptions:t}).then(Dt,Ht).then(t=>({[e.split("/")[0]]:t}))}),Promise.all([...e]).then(e=>e.reduce((e,t)=>({...e,...t})))}getOhlcv(e,t={}){Ct(kt.undefined(e),Pt);const n=t.startDate||t.endDate?"historical":"latest";return It(this.web3data,{pathParam:e,endpoint:`${Mt}/ohlcv`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getOrders(e,t,n={}){return Ct(kt.undefined(e),Pt),(t=Array.isArray(t)?t:[t]).forEach(e=>Ct(kt.undefined(e),"No exchange specified")),n.exchange=t,It(this.web3data,{pathParam:e,endpoint:`${Mt}/orders`,filterOptions:n}).then(Dt,Ht)}getOrderBooks(e,t={}){return Ct(kt.undefined(e),Pt),It(this.web3data,{pathParam:e,endpoint:`${Mt}/orders`,subendpoint:"update",filterOptions:t}).then(Dt,Ht)}getBbos(e,t={}){Ct(kt.undefined(e),Pt);const n=t.startDate||t.endDate?"bbo/historical":"bbo";return It(this.web3data,{pathParam:e,endpoint:`${Mt}/orders`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getPrices(e,t={}){Ct(kt.undefined(e),Pt);const n=t.startDate||t.endDate?"historical":"latest";return It(this.web3data,{pathParam:e,endpoint:`${Mt}/prices`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getTokenPrices(e,t={}){Ct(kt.notHash(e),Pt);const n=t.startDate||t.endDate?"historical":"latest";return It(this.web3data,{hash:e,endpoint:`${Mt}/tokens/prices`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getVwap(e,t={}){return Ct(kt.undefined(e),Pt),It(this.web3data,{pathParam:e,endpoint:`${Mt}/prices`,subendpoint:"wap/latest",filterOptions:t}).then(Dt,Ht)}getTickers(e,t={}){Ct(kt.undefined(e),Pt);const n=t.startDate||t.endDate?"historical":"latest";return It(this.web3data,{pathParam:e,endpoint:`${Mt}/tickers`,subendpoint:n,filterOptions:t}).then(Dt,Ht)}getTrades(e,t={}){return Ct(kt.undefined(e),Pt),It(this.web3data,{pathParam:e,endpoint:`${Mt}/trades`,subendpoint:"historical",filterOptions:t}).then(Dt,Ht)}getAssetAddresses(e="all"){return It(this.web3data,{endpoint:`${Mt}/pairs/addresses`,filterOptions:{symbols:e}}).then(Dt,Ht)}};const{ethFactory:Ut}=Se,{BLOCKCHAIN_ID_ETHEREUM_MAINNET:Kt}=he;var Ft=class{constructor(e,t,n){n.blockchainId=Kt,this.web3data=new e(t,n);const r=Ut(this.web3data);for(const e in r)({}).hasOwnProperty.call(r,e)&&(this[e]=r[e])}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN:jt,BTC_METHODS:Gt}=he,{methodFactory:$t}=Se;var qt=class{constructor(e,t,n){n.blockchainId=jt,this.web3data=new e(t,n),$t(this,Gt)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN_CASH:Wt,BTC_METHODS:zt}=he,{methodFactory:Vt}=Se;var Jt=class{constructor(e,t,n){n.blockchainId=Wt,this.web3data=new e(t,n),Vt(this,zt)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN_SV:Xt,BTC_METHODS:Yt}=he,{methodFactory:Zt}=Se;var Qt=class{constructor(e,t,n){n.blockchainId=Xt,this.web3data=new e(t,n),Zt(this,Yt)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_LITECOIN:en,LTC_METHODS:tn}=he,{methodFactory:nn}=Se;var rn=class{constructor(e,t,n){n.blockchainId=en,this.web3data=new e(t,n),nn(this,tn)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_STELLAR:sn,BTC_METHODS:on}=he,{methodFactory:an}=Se;var cn=class{constructor(e,t,n){n.blockchainId=sn,this.web3data=new e(t,n),an(this,on)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_ZCASH:dn,BTC_METHODS:un}=he,{methodFactory:hn}=Se;var ln=class{constructor(e,t,n){n.blockchainId=dn,this.web3data=new e(t,n),hn(this,un)}rpc(e,t){return this.web3data.rpc(e,t)}},pn=null;"undefined"!=typeof WebSocket?pn=WebSocket:"undefined"!=typeof MozWebSocket?pn=MozWebSocket:void 0!==ue?pn=ue.WebSocket||ue.MozWebSocket:"undefined"!=typeof window?pn=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(pn=self.WebSocket||self.MozWebSocket);var fn=pn;const{DEFAULT_WEBSOCKET_URL:bn}=he,{is:gn,uuid:En}=Se,mn=e=>e?(e.params&&(e.params=Array.isArray(e.params)?e.params:[e.params]),JSON.stringify({jsonrpc:e.version||"2.0",method:e.method||"subscribe",id:e.id||0,params:e.params||[]})):"",_n=0,On=1,wn=2;var Tn=class{constructor(e,t){return this.socket=null,this.baseWsUrl=t&&t.websocketUrl?t.websocketUrl:bn,this.apiKey=e,this.blockchainId=null,this.connected=!1,this.reconnects=0,this.responseReceived=!1,this.dataReceived=!1,t.blockchainId&&(this.blockchainId=t.blockchainId),this.registry={},this.registrySubIds={},this.latestState={},this}connect(e){if(this.socket&&1===this.socket.readyState)return;const t=this.apiKey?`?x-api-key=${this.apiKey}`:"",n=this.blockchainId?`&x-amberdata-blockchain-id=${this.blockchainId}`:"";this.socket=new fn(`${this.baseWsUrl}${t}${n}`),this.socket.addEventListener("open",t=>{console.info("websocket client connection opened"),this.connected=!0,this._refreshSubscriptions(),this._listen(),e&&e(t),setTimeout(()=>{!this.responseReceived&&gn.nonEmptyObject(this.registry)&&this.socket&&this.socket.close()},5e3),setTimeout(()=>{!this.dataReceived&&gn.nonEmptyObject(this.registry)&&this.socket.close()},18e5)}),this.socket.addEventListener("error",t=>{e&&t?e("connection error occurred",t):console.error("connection error occurred"),this._reconnect()}),this.socket.addEventListener("close",e=>{console.info("Websocket client connection closed - code",e.code),this._reconnect()})}disconnect(e=null){this.socket&&1===this.socket.readyState?(this.socket.onclose=e?()=>e("Websocket client connection closed"):()=>console.info("Websocket client connection closed"),this.socket.close(),this.socket=null):console.error("socket is not yet connected")}on({eventName:e,filters:t},n){if(n||console.warn("no callback provided"),!e)return void console.error("no event specified");const r=En({eventName:e,filters:t});this.connected&&this._subscribe(e,t),this.registry[r]={},this.registry[r].callback=n,this.registry[r].args={eventName:e,filters:t}}once({eventName:e,filters:t},n){this.on({eventName:e,filters:t},r=>{this.off({eventName:e,filters:t},()=>{}),n&&n(r),this.registry[En({eventName:e,filters:t})].callback=null})}off({eventName:e,filters:t},n){if(n||console.warn("no callback provided"),!e)return void console.error("no event specified");const r=En({eventName:e,filters:t});this.registry[r]&&this.registry[r].subId?(this.registry[r].isSubscribed=!1,this.registry[r].unsubCallback=n||(()=>{}),this._unsubscribe(e,t,r)):console.error(`Not subscribed to: '${e}'`)}_reconnect(){1===this.socket.readyState&&this.disconnect(),++this.reconnects<=3&&(console.warn(`attempting to reconnect...${this.reconnects}/3`),this.connect())}_refreshSubscriptions(){if(this.registry)for(const{args:{eventName:e,filters:t}}of Object.values(this.registry))this._subscribe(e,t)}_listen(){this.socket.addEventListener("message",e=>{let t;try{t=JSON.parse(e.data)}catch(e){return void console.error("error parsing json request -",e)}switch(this.responseReceived=!0,(e=>e.params?On:gn.string(e.result)?_n:gn.bool(e.result)?wn:void 0)(t)){case _n:this._subHandler(t);break;case On:this._dataHandler(t);break;case wn:this._unsubHandler(t)}})}_subHandler(e){const t=e&&e.id?e.id:"";this.registrySubIds[e.result]=t,this.registry[t].subId=e.result,this.registry[t].isSubscribed=!0}_dataHandler(e){this.dataReceived=!0;const t=e&&e.params&&e.params.result?e.params.result:{},n=e&&e.params&&e.params.subscription?e.params.subscription:"",r=this.registrySubIds[n];this.registry[r].isSubscribed&&(this.registry[r]&&this.registry[r].callback&&this.registry[r].callback(t),gn.notUndefined(this.latestState[r])&&(this.latestState[r]=t))}_unsubHandler(e){const t=e&&e.id?e.id:"",{eventName:n}=this.registry[t].args;e.result?(this.registry[t].unsubCallback(`successfully unsubscribed from - ${n}`),delete this.registry[t]):this.registry[t].unsubCallback(`Error: Not unsubscribed from - ${n}`)}_subscribe(e,t){const n=gn.notUndefined(t)?[t]:[],r=En({eventName:e,filters:t}),s=mn({id:r,params:[e,...n]});this.socket.send(s)}_unsubscribe(e,t,n){const r=mn({id:n,method:"unsubscribe",params:[this.registry[n].subId]});this.socket.readyState===this.socket.OPEN&&this.socket.send(r)}};const{API_KEY_HEADER:Nn,BLOCKCHAIN_ID_HEADER:Sn,DEFAULT_BASE_URL:An,DEFAULT_RPC_URL:Rn,ERROR_RPC_NO_METHOD:yn}=he,{is:vn,throwIf:kn,formatJsonRpc:In}=Se;class Cn{constructor(e,t={}){kn(vn.undefined(e)||vn.emptyString(e),"No api key supplied"),this.apiKey=e,this.blockchainId=null,this.headers={},this.headers[Nn]=this.apiKey,t.blockchainId&&(this.blockchainId=t.blockchainId,this.headers[Sn]=t.blockchainId),this.wsConfig={...t,websocketUrl:t.websocketUrl?t.websocketUrl:null},this.baseUrl=t.baseUrl?t.baseUrl:An,this.address=new He(this),this.token=new Ge(this),this.contract=new Ye(this),this.transaction=new it(this),this.block=new bt(this),this.blockchain=new Ot(this),this.signature=new vt(this),this.market=new xt(this)}rawQuery(e){return de.get(this.baseUrl+e,{headers:this.headers}).then(e=>e.data)}rpc(e,t=[]){return kn(!e,yn),de.post(`${Rn}?${Nn}=${this.apiKey}&${Sn}=${this.blockchainId}`,In({method:e,params:t}),{headers:this.headers}).then(e=>e.data,e=>e.response.data)}}var Dn=class extends Cn{constructor(e,t={}){super(e,t),this.eth=new Ft(Cn,e,t),this.btc=new qt(Cn,e,t),this.bch=new Jt(Cn,e,t),this.bsv=new Qt(Cn,e,t),this.ltc=new rn(Cn,e,t),this.xlm=new cn(Cn,e,t),this.zec=new ln(Cn,e,t),this.websocket=null}connect(e){return this.websocket=this.websocket?this.websocket:new Tn(this.apiKey,this.wsConfig),this.websocket.connect(e)}disconnect(e){this.websocket?this.websocket.disconnect(e):console.error("socket is not yet connected")}on({eventName:e,filters:t},n){n||console.warn("no callback provided"),e?this.websocket.on({eventName:e,filters:t},n):console.error("no event specified")}once({eventName:e,filters:t},n){this.websocket.once({eventName:e,filters:t},n)}off({eventName:e,filters:t},n){n||console.warn("no callback provided"),e?this.websocket.off({eventName:e,filters:t},n):console.error("no event specified")}};return"undefined"!=typeof window&&void 0===window.Web3Data&&(window.Web3Data=Dn),Dn})); |
@@ -1,6 +0,77 @@ | ||
- Getting Started | ||
- [Overview](README.md) | ||
- [Quick Start](quick-start.md) | ||
- [Examples](examples.md) | ||
- API | ||
- [Methods](api.md) | ||
- [Getting Started](quick-start.md) | ||
- [Examples](examples.md) | ||
- Core Methods | ||
- [Web3Data](api.md?id=web3datafactoryconstructorapikey-options-blockchainid-) | ||
- [Websockets](api.md?id=new-websocketclient) | ||
- [RPC](api.md?id=web3datafactoryrpcmethod-params) | ||
- Market Data Methods | ||
- [market.getFeatures](api.md?id=getfeaturesfeatures-filteroptions) | ||
- [market.getRankings](api.md?id=getrankingsfilteroptions) | ||
- [market.getOhlcv](api.md?id=getohlcvpair-filteroptions) | ||
- [market.getOrders](api.md?id=getorderspair-exchange-filteroptions) | ||
- [market.getOrderBooks](api.md?id=getorderbookspair-filteroptions) | ||
- [market.getBbos](api.md?id=getbbospair-filteroptions) | ||
- [market.getPrices](api.md?id=getpricesbase-filteroptions) | ||
<!-- - [market.getTokenPrices](api.md?id=) --> | ||
- [market.getVwap](api.md?id=getvwapbase-filteroptions) | ||
- [market.getTickers](api.md?id=gettickerspair-filteroptions) | ||
- [market.getTrades](api.md?id=gettradespair-filteroptions) | ||
- [market.getAssetAddresses](api.md?id=getassetaddressesassets) | ||
<!-- - [market.getEtherPrice](api.md?id=) --> | ||
- Blockchain Methods | ||
- Address | ||
- [address.getAllAddresses](api.md?id=addressgetalladdressesfilteroptions) | ||
- [address.getAll](api.md?id=addressgetallfilteroptions) | ||
- [address.getInformation](api.md?id=addressgetinformationhash-filteroptions) | ||
- [address.getMetadata](api.md?id=addressgetmetadatahash-filteroptions) | ||
- [address.getAdoption](api.md?id=addressgetadoptionhash-filteroptions) | ||
- [address.getInternalMessages](api.md?id=addressgetinternalmessageshash-filteroptions) | ||
- [address.getFunctions](api.md?id=addressgetfunctionshash-filteroptions) | ||
- [address.getLogs](api.md?id=addressgetlogshash-filteroptions) | ||
- [address.getTransactions](api.md?id=addressgettransactionshash-filteroptions) | ||
- [address.getPendingTransactions](api.md?id=addressgetpendingtransactionshash-filteroptions) | ||
- [address.getBalance](api.md?id=addressgetbalancehash-filteroptions) | ||
- [address.getTokens](api.md?id=addressgettokenshash-filteroptions) | ||
- [address.getTokenTransfers](api.md?id=addressgettokentransfershash-filteroptions) | ||
- [address.getTokenBalances](api.md?id=addressgettokenbalanceshash-filteroptions) | ||
- [address.getUsage](api.md?id=addressgetusagehash-filteroptions) | ||
- [address.getMetrics](api.md?id=addressgetmetrics) | ||
- Block | ||
- [block.getBlocks](api.md?id=getblockid-filteroptions) | ||
- [block.getBlock](api.md?id=getblockid-filteroptions) | ||
- [block.getBlockNumber](api.md?id=) | ||
- [block.getBlockTransactionCount](api.md?id=) | ||
- [block.getTransactions](api.md?id=) | ||
- [block.getTransactionFromBlock](api.md?id=) | ||
- [block.getUncle](api.md?id=) | ||
- [block.getTokenTransfers](api.md?id=) | ||
- [block.getLogs](api.md?id=) | ||
- [block.getFunctions](api.md?id=) | ||
- [block.getMetrics](api.md?id=) | ||
- Blockchain | ||
- [blockchain.getMetrics](api.md?id=getmetricsfilteroptions) | ||
- Contract | ||
- [contract.getDetails](api.md?id=contractgetdetailshash) | ||
- [contract.getFunctions](api.md?id=contractgetfunctionshash) | ||
- [contract.getAbi](api.md?id=contractgetabihash) | ||
- [contract.getSourceCode](api.md?id=contractgetsourcecodehash) | ||
- Signature | ||
- [signature.getSignature](api.md?id=signaturegetsignaturehash) | ||
- Tokens | ||
- [token.getRankings](api.md?id=tokengetrankingsfilteroptions) | ||
- [token.getVolume](api.md?id=tokengetvolumehash-filteroptions) | ||
- [token.getVelocity](api.md?id=tokengetvelocityhash-filteroptions) | ||
- [token.getHolders](api.md?id=tokengetholdershash-filteroptions) | ||
- [token.getHoldersHistorical](api.md?id=tokengetholdershistoricalhash-filteroptions) | ||
- [token.getSupplies](api.md?id=tokengetsupplieshash-filteroptions) | ||
- [token.getTransfers](api.md?id=tokengettransfershash-filteroptions) | ||
- Transactions | ||
- [transaction.getTransactions](api.md?id=transactiongettransactionsfilteroptions) | ||
- [transaction.getAll](api.md?id=transactiongetallfilteroptions) | ||
- [transaction.getTransaction](api.md?id=transactiongettransactionhash-filteroptions) | ||
- [transaction.getPendingTransactions](api.md?id=transactiongetpendingtransactions) | ||
- [transaction.getGasPrediction](api.md?id=transactiongetgasprediction) | ||
- [transaction.getGasPercentiles](api.md?id=transactiongetgaspercentilesfilteroptions) | ||
- [transaction.getGasPrice](api.md?id=transactiongetgasprice) | ||
- [transaction.getVolume](api.md?id=transactiongetvolumefilteroptions) | ||
- [transaction.getMetrics](api.md?id=transactiongetmetricsfilteroptions) |
634
docs/api.md
@@ -1,2 +0,2 @@ | ||
# [web3data-js](https://github.com/web3data/web3data-js#readme) *0.7.1* | ||
# [web3data-js](https://github.com/web3data/web3data-js#readme) *0.7.3* | ||
@@ -272,3 +272,3 @@ > A javascript wrapper for accessing amberdata's public API. | ||
- {Promise<object>}The balance data of the account or if no address is found. | ||
- `Promise.<object>` The balance data of the account or if no address is found. | ||
@@ -304,3 +304,3 @@ | ||
- {Promise<object>}Promise object containing the array of logs. | ||
- `Promise.<object>` Promise object containing the array of logs. | ||
@@ -572,5 +572,55 @@ | ||
### src/bsv.js | ||
#### new Bsv() *private method* | ||
Class for all Bitcoin SV based methods. | ||
##### Returns | ||
- `Void` | ||
### src/block.js | ||
#### constructor(web3data) | ||
Creates an instance of Block. | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| web3data | `object` | - The web3data instance. | | | ||
##### Examples | ||
```javascript | ||
const block = new Block(new Web3Data('API_KEY')) | ||
``` | ||
##### Returns | ||
- `Void` | ||
#### getBlock(id, filterOptions) | ||
@@ -607,31 +657,38 @@ | ||
#### getBlockNumber() | ||
### src/bsv.js | ||
Retrieves the latest block number | ||
#### new Bsv() *private method* | ||
Class for all Bitcoin SV based methods. | ||
##### Examples | ||
```javascript | ||
``` | ||
##### Returns | ||
- `Void` | ||
- `String` block Number | ||
#### getBlockTransactionCount(id, filterOptions) | ||
### src/btc.js | ||
Retrieves the block transaction count for a specific block based on hash or number | ||
#### new Btc() *private method* | ||
Class for all Bitcoin based methods. | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| id | | - The number or hash of the block for which to retrieve block information. | | | ||
| filterOptions | | - | | | ||
@@ -641,18 +698,29 @@ | ||
##### Examples | ||
```javascript | ||
``` | ||
##### Returns | ||
- `Void` | ||
- | ||
#### getTransactions(id, filterOptions) | ||
### src/contract.js | ||
Retrieves all transactions for a given block specified by its id (number or hash). | ||
#### new Contract() | ||
Contains methods pertaining to the `/contracts` endpoint of Amberdata's API. | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| id | | - The number or hash of the block for which to retrieve block information. | | | ||
| filterOptions | | - | | | ||
@@ -662,12 +730,19 @@ | ||
##### Examples | ||
```javascript | ||
``` | ||
##### Returns | ||
- `Void` | ||
- | ||
#### Contract.constructor(web3data) | ||
#### getTransactionFromBlock(id, index, filterOptions) | ||
Creates an instance of Contract. | ||
Retrieves a single transaction for a block specified by its id (number or hash) and transaction index. | ||
@@ -681,3 +756,5 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| web3data | | - The web3data instance. | | | ||
| id | | - The number or hash of the block for which to retrieve block information. | | | ||
| index | | - The number of the transaction block index | | | ||
| filterOptions | | - | | | ||
@@ -697,2 +774,191 @@ | ||
- | ||
#### getUncle(id, index, filterOptions) | ||
Retrieves the uncle specified by its id (number or hash). | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| id | | - The number or hash of the uncle | | | ||
| index | | - The index of the uncle, in most cases this is 0-2. | | | ||
| filterOptions | | - | | | ||
##### Examples | ||
```javascript | ||
``` | ||
##### Returns | ||
- | ||
#### getTokenTransfers(id, filterOptions) | ||
Retrieves the block token transfers executed at a specific block | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| id | | - The number or hash of the block for which to retrieve block information. | | | ||
| filterOptions | | - | | | ||
##### Examples | ||
```javascript | ||
``` | ||
##### Returns | ||
- | ||
#### getLogs(id, filterOptions) | ||
Retrieves the block logs executed at a specific block | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| id | | - The number or hash of the block for which to retrieve block information. | | | ||
| filterOptions | | - | | | ||
##### Examples | ||
```javascript | ||
``` | ||
##### Returns | ||
- | ||
#### getFunctions(id, filterOptions) | ||
Retrieves the block functions/internalMessages executed at a specific block | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| id | | - The number or hash of the block for which to retrieve block information. | | | ||
| filterOptions | | - | | | ||
##### Examples | ||
```javascript | ||
``` | ||
##### Returns | ||
- | ||
#### getMetrics(filterOptions) | ||
Retrieves the blocks metrics & statistics. If no DateRange is specified, it will return a rolling window of latest data up until now. If startDate/endDate is used, it will return historical timeseries data. | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| filterOptions | | - | | | ||
##### Examples | ||
```javascript | ||
``` | ||
##### Returns | ||
- | ||
### src/blockchain.js | ||
#### constructor(web3data) | ||
Creates an instance of Address. | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| web3data | `object` | - The web3data instance. | | | ||
##### Examples | ||
```javascript | ||
const address = new Address(new Web3Data('API_KEY')) | ||
``` | ||
##### Returns | ||
- `Void` | ||
@@ -702,5 +968,5 @@ | ||
#### Contract.getDetails(hash) | ||
#### getMetrics([filterOptions]) | ||
Retrieves all the detailed information for the specified contract (ABI, bytecode, sourcecode...). | ||
Get metrics for a blockchain for a given blockchain ID. Default metrics are for Ethereum over a 24h period. | ||
@@ -714,3 +980,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| hash | `string` | - The address. | | | ||
| filterOptions | `object` | - The filters associated with the request. See [API docs](https://docs.amberdata.io/reference#blockchains-metrics-latest) for details. | *Optional* | | ||
@@ -723,3 +989,3 @@ | ||
```javascript | ||
const details = await web3data.contract.getDetails('0x06012c8cf97bead5deae237070f9587f8e7a266d') | ||
const metrics = await web3data.blockchain.getMetrics() | ||
``` | ||
@@ -731,13 +997,53 @@ | ||
- `Promise.<object>` The detailed information for the specified contract. | ||
- `Promise.<object>` The blockchain metrics. | ||
#### Contract.getFunctions(hash) | ||
Retrieves the functions of the specified contract (if available). If not available on chain, the byte code is decompiled and a list of functions is extracted from it. | ||
### src/btc.js | ||
#### new Btc() *private method* | ||
Class for all Bitcoin based methods. | ||
##### Returns | ||
- `Void` | ||
### src/contract.js | ||
#### new Contract() | ||
Contains methods pertaining to the `/contracts` endpoint of Amberdata's API. | ||
##### Returns | ||
- `Void` | ||
#### Contract.constructor(web3data) | ||
Creates an instance of Contract. | ||
##### Parameters | ||
@@ -747,3 +1053,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| hash | `string` | - The contract address. | | | ||
| web3data | | - The web3data instance. | | | ||
@@ -756,3 +1062,3 @@ | ||
```javascript | ||
const functions = await web3data.contract.getFunctions('0x06012c8cf97bead5deae237070f9587f8e7a266d') | ||
``` | ||
@@ -764,9 +1070,9 @@ | ||
- `Promise.<object>` The functions or decompiled functions of the specified contract. | ||
- `Void` | ||
#### Contract.getAudit(hash) | ||
#### Contract.getDetails(hash) | ||
Alias for getSecurityAudit. | ||
Retrieves all the detailed information for the specified contract (ABI, bytecode, sourcecode...). | ||
@@ -780,3 +1086,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| hash | `string` | - The contract address. | | | ||
| hash | `string` | - The address. | | | ||
@@ -789,3 +1095,3 @@ | ||
```javascript | ||
const signatureDetails = await web3data.signature.getAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d') | ||
const details = await web3data.contract.getDetails('0x06012c8cf97bead5deae237070f9587f8e7a266d') | ||
``` | ||
@@ -797,9 +1103,9 @@ | ||
- `Promise.<object>` The vulnerabilities audit for the specified contract. | ||
- `Promise.<object>` The detailed information for the specified contract. | ||
#### Contract.getSecurityAudit(hash) | ||
#### Contract.getFunctions(hash) | ||
Retrieves the vulnerabilities audit for the specified contract (if available). | ||
Retrieves the functions of the specified contract (if available). If not available on chain, the byte code is decompiled and a list of functions is extracted from it. | ||
@@ -821,3 +1127,3 @@ | ||
```javascript | ||
const audit = await web3data.contract.getSecurityAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d') | ||
const functions = await web3data.contract.getFunctions('0x06012c8cf97bead5deae237070f9587f8e7a266d') | ||
``` | ||
@@ -829,3 +1135,3 @@ | ||
- `Promise.<object>` The vulnerabilities audit for the specified contract. | ||
- `Promise.<object>` The functions or decompiled functions of the specified contract. | ||
@@ -1738,9 +2044,9 @@ | ||
### src/transaction.js | ||
### src/utils.js | ||
#### new Transaction() | ||
#### get(web3data, subendpoint, endpoint, hash, pathParam, filterOptions) *private method* | ||
Contains methods pertaining to the `/address` endpoint of Amberdata's API. | ||
See [documentation](https://docs.amberdata.io/reference#get-all-transactions) details about our transaction endpoints. | ||
Builds the endpoint url to pass to .rawQuery(). Checks for non empties and appends | ||
the appropriate parameter(s) where applicable. | ||
@@ -1750,14 +2056,33 @@ | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| web3data | | - Instance on which to call .rawQuery(). | | | ||
| subendpoint | | - The sub-endpoint. | | | ||
| endpoint | | - The endpoint. | | | ||
| hash | | - The address hash. | | | ||
| pathParam | | - The path parameter. | | | ||
| filterOptions | | - The filters associated with a given endpoint. | | | ||
##### Examples | ||
```javascript | ||
``` | ||
##### Returns | ||
- `Void` | ||
- Returns a Promise of the rawQuery request from web3data. | ||
#### Transaction.constructor(web3data) | ||
#### onFulfilled(response) *private method* | ||
Creates an instance of Transaction. Meant to be used in conjunction with the Web3Data class. | ||
Handler for all request responses. | ||
@@ -1771,3 +2096,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| web3data | | - The web3data instance. | | | ||
| response | | - The Axios response object. | | | ||
@@ -1787,9 +2112,9 @@ | ||
- `Void` | ||
- The data from the response. | ||
#### Transaction.getTransactions(filterOptions) | ||
#### uuid(data) *private method* | ||
Retrieves all transactions matching the specified filters. | ||
Generates a uuid see [this gist]() for more details. | ||
@@ -1803,5 +2128,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| filterOptions | | - The filter options associated with the request. | | | ||
| filterOptions.status | | - Filter by the status of the transactions to retrieve (all, completed, failed, pending). | | | ||
| filterOptions.includePrice | | - Indicates whether or not to include price data with the results. | | | ||
| data | | | | | ||
@@ -1814,7 +2137,3 @@ | ||
```javascript | ||
const transactions = await web3data.transaction.getTransactions() | ||
// Include pricing data with transactions | ||
const transactions = await web3data.transaction.getTransactions({ | ||
includePrice: true | ||
}) | ||
``` | ||
@@ -1826,9 +2145,9 @@ | ||
- All transactions matched by the specified filters. | ||
- `Void` | ||
#### Transaction.getAll(filterOptions) | ||
#### getMethods(obj) *private method* | ||
See 'getTransactions' for details. | ||
Returns an array of methods defined on the object. | ||
@@ -1842,3 +2161,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| filterOptions | | | | | ||
| obj | | - The object from which get methods. | | | ||
@@ -1858,9 +2177,9 @@ | ||
- `Void` | ||
- An array of method names. | ||
#### Transaction.getTransaction(hash, filterOptions) | ||
#### ethFactory(web3data) *private method* | ||
Retrieves the transaction data for the specified hash. | ||
Creates an object containing Ethereum based methods. | ||
@@ -1874,6 +2193,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| hash | | - The transaction hash. | | | ||
| filterOptions | | - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-transaction) for more details. | | | ||
| filterOptions.validationMethod=none | | - The validation method to be added to the response: `none`, `basic`, `full`. | | | ||
| filterOptions.includePrice=true | | - Indicates whether or not to include price data with the results. | | | ||
| web3data | | - { object } The web3data instance. | | | ||
@@ -1886,3 +2202,3 @@ | ||
```javascript | ||
const transaction = await web3data.transaction.getTransaction('0xd0a5a0912fdf87993b3cebd696f1ee667a8fbbe8fc890a22dcbdf114f36de4cf') | ||
``` | ||
@@ -1894,9 +2210,9 @@ | ||
- The data for the specified transaction hash. | ||
- methods { object } an object containing Ethereum based methods. | ||
#### Transaction.getPendingTransactions() | ||
#### formatJsonRpc(options) *private method* | ||
Retrieves all pending transaction. | ||
Creates a string in json rpc format. | ||
@@ -1906,8 +2222,15 @@ | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| options | | - The json rpc options. | | | ||
##### Examples | ||
```javascript | ||
const pendingTransactions = await web3data.transaction.getPendingTransactions() | ||
``` | ||
@@ -1919,20 +2242,18 @@ | ||
- The pending transactions. | ||
- The json rpc formatted string. | ||
#### Transaction.getGasPrediction() | ||
Retrieves the latest gas predictions for the transactions. | ||
### src/transaction.js | ||
#### new Transaction() | ||
Contains methods pertaining to the `/address` endpoint of Amberdata's API. | ||
See [documentation](https://docs.amberdata.io/reference#get-all-transactions) details about our transaction endpoints. | ||
##### Examples | ||
```javascript | ||
const gasPredictions = await web3data.transaction.getGasPrediction() | ||
``` | ||
@@ -1943,9 +2264,9 @@ | ||
- The latest gas predictions for the transactions. | ||
- `Void` | ||
#### Transaction.getGasPercentiles(filterOptions) | ||
#### Transaction.constructor(web3data) | ||
Retrieves the latest gas price percentiles for the transactions. | ||
Creates an instance of Transaction. Meant to be used in conjunction with the Web3Data class. | ||
@@ -1959,4 +2280,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| filterOptions | | - The filter options associated with the request. | | | ||
| filterOptions.numBlocks | | - Number of past blocks on which to base the percentiles. | | | ||
| web3data | | - The web3data instance. | | | ||
@@ -1969,3 +2289,3 @@ | ||
```javascript | ||
const gasPercentiles = await web3data.transaction.getGasPercentiles() | ||
``` | ||
@@ -1977,9 +2297,9 @@ | ||
- The latest gas price percentiles for the transactions. | ||
- `Void` | ||
#### Transaction.getGasPrice() | ||
#### Transaction.getTransactions(filterOptions) | ||
Retrieves the latest average gas price. Uses `getGasPrediction` under the hood. | ||
Retrieves all transactions matching the specified filters. | ||
@@ -1989,8 +2309,21 @@ | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| filterOptions | | - The filter options associated with the request. | | | ||
| filterOptions.status | | - Filter by the status of the transactions to retrieve (all, completed, failed, pending). | | | ||
| filterOptions.includePrice | | - Indicates whether or not to include price data with the results. | | | ||
##### Examples | ||
```javascript | ||
const gasPrice = await web3data.transaction.getGasPrice() | ||
const transactions = await web3data.transaction.getTransactions() | ||
// Include pricing data with transactions | ||
const transactions = await web3data.transaction.getTransactions({ | ||
includePrice: true | ||
}) | ||
``` | ||
@@ -2002,9 +2335,9 @@ | ||
- The latest gas price. | ||
- All transactions matched by the specified filters. | ||
#### Transaction.getVolume(filterOptions) | ||
#### Transaction.getAll(filterOptions) | ||
Retrieves the historical (time series) volume of transactions. | ||
See 'getTransactions' for details. | ||
@@ -2018,3 +2351,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| filterOptions | | - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-historical-transaction-volume) for more details. | | | ||
| filterOptions | | | | | ||
@@ -2027,3 +2360,3 @@ | ||
```javascript | ||
const volume = await web3data.transaction.getVolume() | ||
``` | ||
@@ -2035,9 +2368,9 @@ | ||
- The historical (time series) volume of transactions. | ||
- `Void` | ||
#### Transaction.getMetrics(filterOptions) | ||
#### Transaction.getTransaction(hash, filterOptions) | ||
Get metrics for recent confirmed transactions for a given blockchain. Default metrics are over a 24h period. | ||
Retrieves the transaction data for the specified hash. | ||
@@ -2051,3 +2384,6 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| filterOptions | | | | | ||
| hash | | - The transaction hash. | | | ||
| filterOptions | | - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-transaction) for more details. | | | ||
| filterOptions.validationMethod=none | | - The validation method to be added to the response: `none`, `basic`, `full`. | | | ||
| filterOptions.includePrice=true | | - Indicates whether or not to include price data with the results. | | | ||
@@ -2060,3 +2396,3 @@ | ||
```javascript | ||
const metrics = await web3data.transaction.getMetrics() | ||
const transaction = await web3data.transaction.getTransaction('0xd0a5a0912fdf87993b3cebd696f1ee667a8fbbe8fc890a22dcbdf114f36de4cf') | ||
``` | ||
@@ -2068,36 +2404,19 @@ | ||
- Metrics for recent confirmed transactions. | ||
- The data for the specified transaction hash. | ||
#### Transaction.getPendingTransactions() | ||
### src/utils.js | ||
Retrieves all pending transaction. | ||
#### get(web3data, subendpoint, endpoint, hash, pathParam, filterOptions) *private method* | ||
Builds the endpoint url to pass to .rawQuery(). Checks for non empties and appends | ||
the appropriate parameter(s) where applicable. | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| web3data | | - Instance on which to call .rawQuery(). | | | ||
| subendpoint | | - The sub-endpoint. | | | ||
| endpoint | | - The endpoint. | | | ||
| hash | | - The address hash. | | | ||
| pathParam | | - The path parameter. | | | ||
| filterOptions | | - The filters associated with a given endpoint. | | | ||
##### Examples | ||
```javascript | ||
const pendingTransactions = await web3data.transaction.getPendingTransactions() | ||
``` | ||
@@ -2109,9 +2428,9 @@ | ||
- Returns a Promise of the rawQuery request from web3data. | ||
- The pending transactions. | ||
#### onFulfilled(response) *private method* | ||
#### Transaction.getGasPrediction() | ||
Handler for all request responses. | ||
Retrieves the latest gas predictions for the transactions. | ||
@@ -2121,15 +2440,8 @@ | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| response | | - The Axios response object. | | | ||
##### Examples | ||
```javascript | ||
const gasPredictions = await web3data.transaction.getGasPrediction() | ||
``` | ||
@@ -2141,9 +2453,9 @@ | ||
- The data from the response. | ||
- The latest gas predictions for the transactions. | ||
#### uuid(data) *private method* | ||
#### Transaction.getGasPercentiles(filterOptions) | ||
Generates a uuid see [this gist]() for more details. | ||
Retrieves the latest gas price percentiles for the transactions. | ||
@@ -2157,3 +2469,4 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| data | | | | | ||
| filterOptions | | - The filter options associated with the request. | | | ||
| filterOptions.numBlocks | | - Number of past blocks on which to base the percentiles. | | | ||
@@ -2166,3 +2479,3 @@ | ||
```javascript | ||
const gasPercentiles = await web3data.transaction.getGasPercentiles() | ||
``` | ||
@@ -2174,9 +2487,9 @@ | ||
- `Void` | ||
- The latest gas price percentiles for the transactions. | ||
#### getMethods(obj) *private method* | ||
#### Transaction.getGasPrice() | ||
Returns an array of methods defined on the object. | ||
Retrieves the latest average gas price. Uses `getGasPrediction` under the hood. | ||
@@ -2186,15 +2499,8 @@ | ||
##### Parameters | ||
| Name | Type | Description | | | ||
| ---- | ---- | ----------- | -------- | | ||
| obj | | - The object from which get methods. | | | ||
##### Examples | ||
```javascript | ||
const gasPrice = await web3data.transaction.getGasPrice() | ||
``` | ||
@@ -2206,9 +2512,9 @@ | ||
- An array of method names. | ||
- The latest gas price. | ||
#### ethFactory(web3data) *private method* | ||
#### Transaction.getVolume(filterOptions) | ||
Creates an object containing Ethereum based methods. | ||
Retrieves the historical (time series) volume of transactions. | ||
@@ -2222,3 +2528,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| web3data | | - { object } The web3data instance. | | | ||
| filterOptions | | - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-historical-transaction-volume) for more details. | | | ||
@@ -2231,3 +2537,3 @@ | ||
```javascript | ||
const volume = await web3data.transaction.getVolume() | ||
``` | ||
@@ -2239,9 +2545,9 @@ | ||
- methods { object } an object containing Ethereum based methods. | ||
- The historical (time series) volume of transactions. | ||
#### formatJsonRpc(options) *private method* | ||
#### Transaction.getMetrics(filterOptions) | ||
Creates a string in json rpc format. | ||
Get metrics for recent confirmed transactions for a given blockchain. Default metrics are over a 24h period. | ||
@@ -2255,3 +2561,3 @@ | ||
| ---- | ---- | ----------- | -------- | | ||
| options | | - The json rpc options. | | | ||
| filterOptions | | | | | ||
@@ -2264,3 +2570,3 @@ | ||
```javascript | ||
const metrics = await web3data.transaction.getMetrics() | ||
``` | ||
@@ -2272,3 +2578,3 @@ | ||
- The json rpc formatted string. | ||
- Metrics for recent confirmed transactions. | ||
@@ -2902,8 +3208,8 @@ | ||
### src/xlm.js | ||
### src/zec.js | ||
#### new Xlm() *private method* | ||
#### new Zec() *private method* | ||
Class for all Stellar based methods. | ||
Class for all ZCash based methods. | ||
@@ -2923,8 +3229,8 @@ | ||
### src/zec.js | ||
### src/xlm.js | ||
#### new Zec() *private method* | ||
#### new Xlm() *private method* | ||
Class for all ZCash based methods. | ||
Class for all Stellar based methods. | ||
@@ -2931,0 +3237,0 @@ |
@@ -1,2 +0,11 @@ | ||
## Installation | ||
 | ||
[](https://travis-ci.com/web3data/web3data-js) | ||
[](https://github.com/xojs/xo) | ||
[](https://npm.runkit.com/web3data-js) | ||
# Web3data.js Javascript API | ||
Wrapper for [Amberdata.io](http://amberdata.io)'s [REST API](http://docs.amberdata.io/reference) | ||
## Installation | ||
<i>Note that you must have node (and npm) installed.</i> | ||
@@ -14,2 +23,13 @@ | ||
## The API Key | ||
Visit [Amberdata.io](https://amberdata.io/pricing) and select the developer plan to get started! | ||
Once you've got your key, place it in a file named `.env` — see [env.example](./env.example) for reference. | ||
Then in you code you can use it like so: | ||
```javascript | ||
const web3Data = new Web3Data(process.env.API_KEY) | ||
``` | ||
## Configuration | ||
@@ -32,2 +52,33 @@ Web3data configuration is simple and only requires an API Key upon instantiation. | ||
## Simple Usage Example | ||
For more examples, [click here to head over to view more quick examples](/examples). For a full spectrum of guides, tutorials & sample code, go to [our Amberdata Documentation](https://amberdata.io/docs). For filters & optional parameters, please [refer to the API documentation](https://docs.amberdata.io). | ||
#### Within Node | ||
```js | ||
import Web3Data from 'web3data-js' | ||
const w3d = new Web3Data('<api-key>') | ||
;( async () => { | ||
const contract = await w3d.contract.getDetails("0x06012c8cf97bead5deae237070f9587f8e7a266d") | ||
console.log(contract) // { ... } | ||
})() | ||
``` | ||
#### Websockets Events | ||
```js | ||
import Web3Data from 'web3data-js' | ||
const w3d = new Web3Data('<api-key>') | ||
w3d.connect(status => { | ||
console.log('status ->', status.type) | ||
}) | ||
w3d.on({eventName: 'block'}, data => { | ||
console.log(data) | ||
}) | ||
``` | ||
## Blockchains/Networks | ||
@@ -38,2 +89,43 @@ It's possible to the namespace convention to specify which blockchain to use when making requests. | ||
### Supported Blockchain Namespaces | ||
<table style="width:100%"> | ||
<tr> | ||
<th>Name</th> | ||
<th>Namespace</th> | ||
</tr> | ||
<tr> | ||
<td>default</td> | ||
<td>web3data.* (Ethereum)</td> | ||
</tr> | ||
<tr> | ||
<td>Bitcoin</td> | ||
<td>web3data.btc</td> | ||
</tr> | ||
<tr> | ||
<td>Ethereum</td> | ||
<td>web3data.eth</td> | ||
</tr> | ||
<tr> | ||
<td>Litecoin</td> | ||
<td>web3data.ltc</td> | ||
</tr> | ||
<tr> | ||
<td>Bitcoin Cash</td> | ||
<td>web3data.bch</td> | ||
</tr> | ||
<tr> | ||
<td>Bitcoin SV</td> | ||
<td>web3data.bsv</td> | ||
</tr> | ||
<tr> | ||
<td>Stellar</td> | ||
<td>web3data.xlm</td> | ||
</tr> | ||
<tr> | ||
<td>Zcash</td> | ||
<td>web3data.zec</td> | ||
</tr> | ||
</table> | ||
### Ethereum | ||
@@ -43,3 +135,58 @@ | ||
##### Example: | ||
<details><summary><b>Supported Methods </b></summary> | ||
<table style="width:100%"> | ||
<tr> | ||
<th>address</th> | ||
<th>block</th> | ||
<th>contract</th> | ||
<th>market</th> | ||
<th>transaction</th> | ||
</tr> | ||
<tr> | ||
<td>getBalance</td> | ||
<td>getBlockNumber</td> | ||
<td>getCode</td> | ||
<td>getEtherPrice</td> | ||
<td>getTransaction</td> | ||
</tr> | ||
<tr> | ||
<td></td> | ||
<td>getBlock</td> | ||
<td></td> | ||
<td></td> | ||
<td>getPendingTransactions</td> | ||
</tr> | ||
<tr> | ||
<td></td> | ||
<td>getBlockTransactionCount</td> | ||
<td></td> | ||
<td></td> | ||
<td>getGasPrice</td> | ||
</tr> | ||
<tr> | ||
<td></td> | ||
<td>getTransactionFromBlock</td> | ||
<td></td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td></td> | ||
<td>getTransactions</td> | ||
<td></td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td></td> | ||
<td>getMetrics</td> | ||
<td></td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
</details> | ||
##### Example: | ||
```javascript | ||
@@ -79,2 +226,3 @@ web3data.eth.address.getBalance('0x734Ac651Dd95a339c633cdEd410228515F97fAfF') | ||
<td>getTransactions</td> | ||
<td>getMetrics</td> | ||
</tr> | ||
@@ -84,2 +232,3 @@ <tr> | ||
<td>getTransactionFromBlock</td> | ||
<td></td> | ||
</tr> | ||
@@ -89,17 +238,28 @@ <tr> | ||
<td>getMetrics</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getLatestBalance</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getHistoricalBalance</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMultipleBalances</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getBalancesBatch</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMetrics</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
@@ -109,3 +269,3 @@ </table> | ||
##### Example: | ||
##### Example: | ||
```javascript | ||
@@ -119,4 +279,64 @@ web3data.btc.address.getBalance('1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL') | ||
<details><summary><b>Supported Methods </b></summary> | ||
##### Example: | ||
<table style="width:100%"> | ||
<tr> | ||
<th>address</th> | ||
<th>block</th> | ||
<th>transaction</th> | ||
</tr> | ||
<tr> | ||
<td>getAllAddresses</td> | ||
<td>getBlocks</td> | ||
<td>getTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getInformation</td> | ||
<td>getBlock</td> | ||
<td>getTransaction</td> | ||
</tr> | ||
<tr> | ||
<td>getMetadata</td> | ||
<td>getBlockNumber</td> | ||
<td>getPendingTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getTransactions</td> | ||
<td>getTransactions</td> | ||
<td>getMetrics</td> | ||
</tr> | ||
<tr> | ||
<td>getBalance</td> | ||
<td>getTransactionFromBlock</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getLatestBalance</td> | ||
<td>getMetrics</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getHistoricalBalance</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMultipleBalances</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getBalancesBatch</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMetrics</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
</details> | ||
##### Example: | ||
```javascript | ||
@@ -126,2 +346,284 @@ web3data.ltc.address.getBalance('LZo1qx6S5JEVh43KahTFBdvnkVFeQCz9Ze') | ||
### Bitcoin Cash | ||
**Namespace**: `.bch` | ||
<details><summary><b>Supported Methods </b></summary> | ||
<table style="width:100%"> | ||
<tr> | ||
<th>address</th> | ||
<th>block</th> | ||
<th>transaction</th> | ||
</tr> | ||
<tr> | ||
<td>getAllAddresses</td> | ||
<td>getBlocks</td> | ||
<td>getTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getInformation</td> | ||
<td>getBlock</td> | ||
<td>getTransaction</td> | ||
</tr> | ||
<tr> | ||
<td>getMetadata</td> | ||
<td>getBlockNumber</td> | ||
<td>getPendingTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getTransactions</td> | ||
<td>getTransactions</td> | ||
<td>getMetrics</td> | ||
</tr> | ||
<tr> | ||
<td>getBalance</td> | ||
<td>getTransactionFromBlock</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getLatestBalance</td> | ||
<td>getMetrics</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getHistoricalBalance</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMultipleBalances</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getBalancesBatch</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMetrics</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
</details> | ||
##### Example: | ||
```javascript | ||
web3data.bch.address.getBalance('1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL') | ||
``` | ||
### Bitcoin SV | ||
**Namespace**: `.bsv` | ||
<details><summary><b>Supported Methods </b></summary> | ||
<table style="width:100%"> | ||
<tr> | ||
<th>address</th> | ||
<th>block</th> | ||
<th>transaction</th> | ||
</tr> | ||
<tr> | ||
<td>getAllAddresses</td> | ||
<td>getBlocks</td> | ||
<td>getTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getInformation</td> | ||
<td>getBlock</td> | ||
<td>getTransaction</td> | ||
</tr> | ||
<tr> | ||
<td>getMetadata</td> | ||
<td>getBlockNumber</td> | ||
<td>getPendingTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getTransactions</td> | ||
<td>getTransactions</td> | ||
<td>getMetrics</td> | ||
</tr> | ||
<tr> | ||
<td>getBalance</td> | ||
<td>getTransactionFromBlock</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getLatestBalance</td> | ||
<td>getMetrics</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getHistoricalBalance</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMultipleBalances</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getBalancesBatch</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMetrics</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
</details> | ||
##### Example: | ||
```javascript | ||
web3data.bsv.address.getBalance('1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL') | ||
``` | ||
### Stellar | ||
**Namespace**: `.xlm` | ||
<details><summary><b>Supported Methods </b></summary> | ||
<table style="width:100%"> | ||
<tr> | ||
<th>address</th> | ||
<th>block</th> | ||
<th>transaction</th> | ||
</tr> | ||
<tr> | ||
<td>getAllAddresses</td> | ||
<td>getBlocks</td> | ||
<td>getTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getInformation</td> | ||
<td>getBlock</td> | ||
<td>getTransaction</td> | ||
</tr> | ||
<tr> | ||
<td>getMetadata</td> | ||
<td>getBlockNumber</td> | ||
<td>getPendingTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getTransactions</td> | ||
<td>getTransactions</td> | ||
<td>getMetrics</td> | ||
</tr> | ||
<tr> | ||
<td>getBalance</td> | ||
<td>getTransactionFromBlock</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getLatestBalance</td> | ||
<td>getMetrics</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getHistoricalBalance</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMultipleBalances</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getBalancesBatch</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMetrics</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
</details> | ||
##### Example: | ||
```javascript | ||
web3data.xlm.address.getBalance('GB42PDYTMHVL7FG2KQ6DGCJSEOF6RXWX7BYJ7UISU5GCRRA5DPCY2X7R') | ||
``` | ||
### Zcash | ||
**Namespace**: `.zec` | ||
<details><summary><b>Supported Methods </b></summary> | ||
<table style="width:100%"> | ||
<tr> | ||
<th>address</th> | ||
<th>block</th> | ||
<th>transaction</th> | ||
</tr> | ||
<tr> | ||
<td>getAllAddresses</td> | ||
<td>getBlocks</td> | ||
<td>getTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getInformation</td> | ||
<td>getBlock</td> | ||
<td>getTransaction</td> | ||
</tr> | ||
<tr> | ||
<td>getMetadata</td> | ||
<td>getBlockNumber</td> | ||
<td>getPendingTransactions</td> | ||
</tr> | ||
<tr> | ||
<td>getTransactions</td> | ||
<td>getTransactions</td> | ||
<td>getMetrics</td> | ||
</tr> | ||
<tr> | ||
<td>getBalance</td> | ||
<td>getTransactionFromBlock</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getLatestBalance</td> | ||
<td>getMetrics</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getHistoricalBalance</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMultipleBalances</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getBalancesBatch</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>getMetrics</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
</details> | ||
##### Example: | ||
```javascript | ||
web3data.zec.address.getBalance('t1M5GSbdVpPA1XFkuzi12sJyqGkrEEfGwLJ') | ||
``` | ||
Note: When using the namespaced methods the blockchain Id set during instantiation will be ignored. |
{ | ||
"name": "web3data-js", | ||
"version": "0.7.1", | ||
"version": "0.7.3", | ||
"description": "A javascript wrapper for accessing amberdata's public API.", | ||
@@ -9,2 +9,3 @@ "main": "index.js", | ||
"build": "rimraf dist/web3data.min.js && rollup -c", | ||
"docs:init": "docsify init ./docs", | ||
"docs:serve": "docsify serve ./docs", | ||
@@ -29,5 +30,10 @@ "docs:gen": "doxdox 'src/**/*.js' --layout markdown --output docs/api.md", | ||
"web3", | ||
"data" | ||
"web3data", | ||
"amberdata", | ||
"ethereum", | ||
"bitcoin", | ||
"litecoin", | ||
"zcash" | ||
], | ||
"author": "Taylor Dawson", | ||
"authors": ["@trevorjtclarke", "Taylor Dawson"], | ||
"license": "Apache-2.0", | ||
@@ -52,2 +58,3 @@ "bugs": { | ||
"cross-env": "^7.0.0", | ||
"docsify-cli": "^4.4.0", | ||
"dotenv": "^8.2.0", | ||
@@ -54,0 +61,0 @@ "doxdox": "^3.0.0", |
@@ -0,1 +1,3 @@ | ||
 | ||
[](https://travis-ci.com/web3data/web3data-js) | ||
@@ -48,3 +50,3 @@ [](https://github.com/xojs/xo) | ||
```js | ||
import Web3Data from 'Web3Data' | ||
import Web3Data from 'web3data-js' | ||
@@ -61,3 +63,3 @@ const w3d = new Web3Data('<api-key>') | ||
```js | ||
import Web3Data from 'Web3Data' | ||
import Web3Data from 'web3data-js' | ||
@@ -64,0 +66,0 @@ const w3d = new Web3Data('<api-key>') |
@@ -139,3 +139,3 @@ const { | ||
* @param {object} [filterOptions] - The filter options associated with the request. | ||
* @returns {Promise<object>}The balance data of the account or if no address is found. | ||
* @returns {Promise<object>} The balance data of the account or if no address is found. | ||
* @example | ||
@@ -159,3 +159,3 @@ * const functions = await web3data.address.getFunctions('0x06012c8cf97bead5deae237070f9587f8e7a266d') | ||
* @param {object} [filterOptions] - The filter options associated with the request. | ||
* @returns {Promise<object>}Promise object containing the array of logs. | ||
* @returns {Promise<object>} Promise object containing the array of logs. | ||
* @public | ||
@@ -162,0 +162,0 @@ * @example |
@@ -16,2 +16,9 @@ const { | ||
class Block { | ||
/** | ||
* Creates an instance of Block. | ||
* | ||
* @param {object} web3data - The web3data instance. | ||
* @example | ||
* const block = new Block(new Web3Data('API_KEY')) | ||
*/ | ||
constructor(web3data) { | ||
@@ -21,2 +28,9 @@ this.web3data = web3data | ||
/** | ||
* Retrieves a list of blocks. | ||
* | ||
* @param [filterOptions] - | ||
* @returns | ||
* @example | ||
*/ | ||
// TODO: Needs tests | ||
@@ -47,2 +61,8 @@ getBlocks(filterOptions) { | ||
/** | ||
* Retrieves the latest block number | ||
* | ||
* @returns {String} block Number | ||
* @example | ||
*/ | ||
getBlockNumber() { | ||
@@ -55,2 +75,10 @@ return this.web3data.block.getBlock('latest').then(block => { | ||
/** | ||
* Retrieves the block transaction count for a specific block based on hash or number | ||
* | ||
* @param id - The number or hash of the block for which to retrieve block information. | ||
* @param [filterOptions] - | ||
* @returns | ||
* @example | ||
*/ | ||
getBlockTransactionCount(id) { | ||
@@ -67,2 +95,10 @@ return this.web3data.block.getBlock(id).then(block => { | ||
/** | ||
* Retrieves all transactions for a given block specified by its id (number or hash). | ||
* | ||
* @param id - The number or hash of the block for which to retrieve block information. | ||
* @param [filterOptions] - | ||
* @returns | ||
* @example | ||
*/ | ||
getTransactions(id, filterOptions) { | ||
@@ -78,2 +114,11 @@ throwIf(is.undefined(id), NO_BLOCK_ID) | ||
/** | ||
* Retrieves a single transaction for a block specified by its id (number or hash) and transaction index. | ||
* | ||
* @param id - The number or hash of the block for which to retrieve block information. | ||
* @param index - The number of the transaction block index | ||
* @param [filterOptions] - | ||
* @returns | ||
* @example | ||
*/ | ||
getTransactionFromBlock(id, index) { | ||
@@ -89,2 +134,11 @@ throwIf(is.undefined(id), NO_BLOCK_ID) | ||
/** | ||
* Retrieves the uncle specified by its id (number or hash). | ||
* | ||
* @param id - The number or hash of the uncle | ||
* @param index - The index of the uncle, in most cases this is 0-2. | ||
* @param [filterOptions] - | ||
* @returns | ||
* @example | ||
*/ | ||
getUncle(id, index) { | ||
@@ -116,2 +170,10 @@ throwIf(is.undefined(id), NO_BLOCK_ID) | ||
/** | ||
* Retrieves the block token transfers executed at a specific block | ||
* | ||
* @param id - The number or hash of the block for which to retrieve block information. | ||
* @param [filterOptions] - | ||
* @returns | ||
* @example | ||
*/ | ||
getTokenTransfers(id, filterOptions) { | ||
@@ -127,2 +189,10 @@ throwIf(is.undefined(id), NO_BLOCK_ID) | ||
/** | ||
* Retrieves the block logs executed at a specific block | ||
* | ||
* @param id - The number or hash of the block for which to retrieve block information. | ||
* @param [filterOptions] - | ||
* @returns | ||
* @example | ||
*/ | ||
getLogs(id, filterOptions) { | ||
@@ -138,2 +208,10 @@ throwIf(is.undefined(id), NO_BLOCK_ID) | ||
/** | ||
* Retrieves the block functions/internalMessages executed at a specific block | ||
* | ||
* @param id - The number or hash of the block for which to retrieve block information. | ||
* @param [filterOptions] - | ||
* @returns | ||
* @example | ||
*/ | ||
getFunctions(id, filterOptions) { | ||
@@ -149,2 +227,9 @@ throwIf(is.undefined(id), NO_BLOCK_ID) | ||
/** | ||
* Retrieves the blocks metrics & statistics. If no DateRange is specified, it will return a rolling window of latest data up until now. If startDate/endDate is used, it will return historical timeseries data. | ||
* | ||
* @param [filterOptions] - | ||
* @returns | ||
* @example | ||
*/ | ||
getMetrics(filterOptions) { | ||
@@ -151,0 +236,0 @@ const subendpoint = |
@@ -6,2 +6,9 @@ const {BLOCKCHAINS_ENDPOINT: ENDPOINT} = require('./constants') | ||
class Blockchain { | ||
/** | ||
* Creates an instance of Address. | ||
* | ||
* @param {object} web3data - The web3data instance. | ||
* @example | ||
* const address = new Address(new Web3Data('API_KEY')) | ||
*/ | ||
constructor(web3data) { | ||
@@ -11,2 +18,10 @@ this.web3data = web3data | ||
/** | ||
* Get metrics for a blockchain for a given blockchain ID. Default metrics are for Ethereum over a 24h period. | ||
* | ||
* @param {object} [filterOptions] - The filters associated with the request. See [API docs](https://docs.amberdata.io/reference#blockchains-metrics-latest) for details. | ||
* @returns {Promise<object>} The blockchain metrics. | ||
* @example | ||
* const metrics = await web3data.blockchain.getMetrics() | ||
*/ | ||
getMetrics(filterOptions) { | ||
@@ -13,0 +28,0 @@ const subendpoint = |
@@ -53,29 +53,2 @@ const { | ||
/** | ||
* Alias for getSecurityAudit. | ||
* | ||
* @param {string} hash - The contract address. | ||
* @returns {Promise<object>} The vulnerabilities audit for the specified contract. | ||
* @example const signatureDetails = await web3data.signature.getAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d') | ||
*/ | ||
getAudit(hash) { | ||
return this.getSecurityAudit(hash) | ||
} | ||
/** | ||
* Retrieves the vulnerabilities audit for the specified contract (if available). | ||
* | ||
* @param {string} hash - The contract address. | ||
* @returns {Promise<object>} The vulnerabilities audit for the specified contract. | ||
* @example const audit = await web3data.contract.getSecurityAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d') | ||
*/ | ||
getSecurityAudit(hash) { | ||
if (is.notHash(hash)) return Promise.reject(new Error(NO_ADDRESS)) | ||
return get(this.web3data, { | ||
pathParam: hash, | ||
endpoint: ENDPOINT, | ||
subendpoint: 'audit' | ||
}).then(onFulfilled, onError) | ||
} | ||
/** | ||
* Retrieves the contract's abi. | ||
@@ -82,0 +55,0 @@ * |
@@ -46,22 +46,22 @@ import test from "ava"; | ||
/*********** Test getSecurityAudit() ***********/ | ||
test('Successfully calls getSecurityAudit', async t => { | ||
const audit = await t.context.web3data.contract.getSecurityAudit(TOKEN_ADDRESS); | ||
t.true(audit.hasProp('issues')) | ||
}); | ||
test('throws exception when calling getSecurityAudit without hash', async t => { | ||
await t.throwsAsync(async () => { | ||
await t.context.web3data.contract.getSecurityAudit() | ||
}, { instanceOf: Error, message: 'No contract address supplied' }); | ||
}); | ||
// test('Successfully calls getSecurityAudit', async t => { | ||
// const audit = await t.context.web3data.contract.getSecurityAudit(TOKEN_ADDRESS); | ||
// t.true(audit.hasProp('issues')) | ||
// }); | ||
// test('throws exception when calling getSecurityAudit without hash', async t => { | ||
// await t.throwsAsync(async () => { | ||
// await t.context.web3data.contract.getSecurityAudit() | ||
// }, { instanceOf: Error, message: 'No contract address supplied' }); | ||
// }); | ||
/*********** Test getAudit() ***********/ | ||
test('Successfully calls getAudit', async t => { | ||
const audit = await t.context.web3data.contract.getAudit(TOKEN_ADDRESS); | ||
t.true(audit.hasProp('issues')) | ||
}); | ||
test('throws exception when calling getAudit without hash', async t => { | ||
await t.throwsAsync(async () => { | ||
await t.context.web3data.contract.getAudit() | ||
}, { instanceOf: Error, message: 'No contract address supplied' }); | ||
}); | ||
// test('Successfully calls getAudit', async t => { | ||
// const audit = await t.context.web3data.contract.getAudit(TOKEN_ADDRESS); | ||
// t.true(audit.hasProp('issues')) | ||
// }); | ||
// test('throws exception when calling getAudit without hash', async t => { | ||
// await t.throwsAsync(async () => { | ||
// await t.context.web3data.contract.getAudit() | ||
// }, { instanceOf: Error, message: 'No contract address supplied' }); | ||
// }); | ||
@@ -68,0 +68,0 @@ /*********** Test getAbi() ***********/ |
Sorry, the diff of this file is not supported yet
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
28211152
0.3%74
1.37%4464
1.71%111
1.83%37
2.78%1
Infinity%