diff --git a/dist/web3data.min.js b/dist/web3data.min.js index 5d21ae9..2e36988 100644 --- a/dist/web3data.min.js +++ b/dist/web3data.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).web3data=t()}(this,(function(){"use strict";var e=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r1)for(var n=1;n=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(h))&&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)}))},$={"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||void 0!==U&&"[object process]"===Object.prototype.toString.call(U))&&(z=q),z),transformRequest:[function(e,t){return x(t,"Accept"),x(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($)}));var J=V;function X(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Y=function(e){return X(e),e.headers=e.headers||{},e.data=h(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=h(t.data,t.headers,e.transformResponse),t}),(function(t){return p(t)||(X(e),t&&t.response&&(t.response.data=h(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 l,response:new l}}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:{};var le=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_BASE="No market base 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})),he=(le.DEFAULT_WEBSOCKET_URL,le.DEFAULT_BASE_URL,le.DEFAULT_RPC_URL,le.API_KEY_HEADER,le.BLOCKCHAIN_ID_HEADER,le.BLOCKCHAIN_ID_ETHEREUM_MAINNET,le.BLOCKCHAIN_ID_ETHEREUM_RINKEBY,le.BLOCKCHAIN_ID_BITCOIN,le.BLOCKCHAIN_ID_BITCOIN_CASH,le.BLOCKCHAIN_ID_BITCOIN_SV,le.BLOCKCHAIN_ID_LITECOIN,le.BLOCKCHAIN_ID_RIPPLE,le.BLOCKCHAIN_ID_ZCASH,le.BLOCKCHAIN_ID_STELLAR,le.ADDRESSES_ENDPOINT,le.TOKENS_ENDPOINT,le.TRANSACTIONS_ENDPOINT,le.BLOCKS_ENDPOINT,le.BLOCKCHAINS_ENDPOINT,le.CONTRACTS_ENDPOINT,le.SIGNATURES_ENDPOINT,le.MARKET_ENDPOINT,le.MARKET_FEATURES,le.ERROR_MESSAGE_TOKEN_NO_ADDRESS,le.ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS,le.ERROR_MESSAGE_TRANSACTION_NO_HASH,le.ERROR_MESSAGE_ADDRESS_NO_ADDRESS,le.ERROR_MESSAGE_CONTRACT_NO_ADDRESS,le.ERROR_MESSAGE_BLOCK_NO_ID,le.ERROR_MESSAGE_MARKET_NO_PAIR,le.ERROR_MESSAGE_MARKET_NO_BASE,le.ERROR_MESSAGE_MARKET_NO_FEATURE,le.ERROR_MESSAGE_SIGNATURE_NO_HASH,le.ERROR_RPC_NO_METHOD,le.ETH_METHODS,le.BTC_METHODS,le.LTC_METHODS,le.XLM_METHODS,le.HTTP_CODE_NOT_FOUND,"undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)),pe=new Uint8Array(16);function fe(){if(!he)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return he(pe)}var be=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ge(e){return"string"==typeof e&&be.test(e)}for(var me,Ee,_e=[],Oe=0;Oe<256;++Oe)_e.push((Oe+256).toString(16).substr(1));function we(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(_e[e[t+0]]+_e[e[t+1]]+_e[e[t+2]]+_e[e[t+3]]+"-"+_e[e[t+4]]+_e[e[t+5]]+"-"+_e[e[t+6]]+_e[e[t+7]]+"-"+_e[e[t+8]]+_e[e[t+9]]+"-"+_e[e[t+10]]+_e[e[t+11]]+_e[e[t+12]]+_e[e[t+13]]+_e[e[t+14]]+_e[e[t+15]]).toLowerCase();if(!ge(n))throw TypeError("Stringified UUID is invalid");return n}var Te=0,Ne=0;function Se(e){if(!ge(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}function Re(e,t,n){function r(e,r,s,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n>>9<<4)+1}function ye(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function ve(e,t,n,r,s,o){return ye((i=ye(ye(t,e),ye(r,o)))<<(a=s)|i>>>32-a,n);var i,a}function Ie(e,t,n,r,s,o,i){return ve(t&n|~t&r,e,t,s,o,i)}function ke(e,t,n,r,s,o,i){return ve(t&r|n&~r,e,t,s,o,i)}function Ce(e,t,n,r,s,o,i){return ve(t^n^r,e,t,s,o,i)}function De(e,t,n,r,s,o,i){return ve(n^(t|~r),e,t,s,o,i)}var He=Re("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n>5]>>>r%32&255,o=parseInt("0123456789abcdef".charAt(s>>>4&15)+"0123456789abcdef".charAt(15&s),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<>5]|=(255&e[r/8])<>>32-t}var Pe=Re("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=[];for(var s=0;s>>0;_=E,E=m,m=Me(g,30)>>>0,g=b,b=T}n[0]=n[0]+b>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+m>>>0,n[3]=n[3]+E>>>0,n[4]=n[4]+_>>>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]]}));var Le=Object.freeze({__proto__:null,v1:function(e,t,n){var r=t&&n||0,s=t||new Array(16),o=(e=e||{}).node||me,i=void 0!==e.clockseq?e.clockseq:Ee;if(null==o||null==i){var a=e.random||(e.rng||fe)();null==o&&(o=me=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==i&&(i=Ee=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),d=void 0!==e.nsecs?e.nsecs:Ne+1,u=c-Te+(d-Ne)/1e4;if(u<0&&void 0===e.clockseq&&(i=i+1&16383),(u<0||c>Te)&&void 0===e.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Te=c,Ne=d,Ee=i;var l=(1e4*(268435455&(c+=122192928e5))+d)%4294967296;s[r++]=l>>>24&255,s[r++]=l>>>16&255,s[r++]=l>>>8&255,s[r++]=255&l;var h=c/4294967296*1e4&268435455;s[r++]=h>>>8&255,s[r++]=255&h,s[r++]=h>>>24&15|16,s[r++]=h>>>16&255,s[r++]=i>>>8|128,s[r++]=255&i;for(var p=0;p<6;++p)s[r+p]=o[p];return t||we(s)},v3:He,v4:function(e,t,n){var r=(e=e||{}).random||(e.rng||fe)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var s=0;s<16;++s)t[n+s]=r[s];return t}return we(r)},v5:Pe,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!ge(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:ge,stringify:we,parse:Se});const{ETH_METHODS:Ue}=le,xe=e=>{let t="";for(const n in e)({}).hasOwnProperty.call(e,n)&&(t+=`${n}=${e[n]}&`);return t},Ke=(e,t)=>{if(e)throw new Error(t)},Fe=e=>Ke(!0,e),je=()=>{};je.string=e=>"string"==typeof e,je.bool=e=>"boolean"==typeof e,je.emptyString=e=>je.string(e)&&0===e.length,je.emptyObject=e=>0===Object.keys(e).length,je.inObject=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),je.undefined=e=>void 0===e,je.null=e=>null===e,je.notHash=e=>je.undefined(e)||je.emptyString(e),je.notUndefined=e=>!je.undefined(e),je.nonEmptyObject=e=>!je.emptyObject(e),je.nonEmptyString=e=>!je.emptyString(e),je.notInObject=(e,t)=>!je.inObject(e,t);const Ge=e=>Object.getOwnPropertyNames(e).filter(t=>"function"==typeof e[t]&&"constructor"!==t);var qe={buildFilterUrl:xe,is:je,throwIf:Ke,get:(e,{endpoint:t="",subendpoint:n="",hash:r="",pathParam:s="",filterOptions:o={}})=>{const i=je.nonEmptyObject(o)?"?"+xe(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=>Le.v5(JSON.stringify(e),"ccfeca02-f0e9-4433-a740-b830cceb3d2d"),ethFactory:function(e){const t={};for(const n in Ue)({}).hasOwnProperty.call(Ue,n)&&(t[n]=e[Ue[n]][n].bind(e[Ue[n]]));return t},methodFactory:(e,t)=>(Object.keys(t).forEach(n=>{Ge(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:Fe,onFulfilled:function(e){return Ke(e.error,e.message),this&&this.formatter?this.formatter(e.payload):e.payload},onError:({response:{data:e}})=>Fe(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:Ge,recordsFormatter:e=>((e,t)=>e&&e[t]?e[t]:e)(e,"records")};const{ERROR_MESSAGE_ADDRESS_NO_ADDRESS:$e,ADDRESSES_ENDPOINT:We}=le,{is:ze,get:Ve,throwIf:Je,onFulfilled:Xe,onError:Ye,recordsFormatter:Ze}=qe;var Qe=class{constructor(e){this.web3data=e}getAllAddresses(e={}){return this.getAll(e)}getAll(e={}){return Ve(this.web3data,{endpoint:We,filterOptions:e}).then(Xe.bind({formatter:Ze}),Ye)}getInformation(e,t={}){return Je(ze.notHash(e),$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"information",filterOptions:t}).then(Xe,Ye)}getMetadata(e,t={}){return Je(ze.notHash(e),$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"metadata",filterOptions:t}).then(Xe,Ye)}getAdoption(e,t={}){return Je(ze.notHash(e),$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"adoption",filterOptions:t}).then(Xe,Ye)}getInternalMessages(e,t={}){return this.web3data.address.getFunctions(e,t)}getFunctions(e,t={}){return Je(ze.notHash(e),$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"functions",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getLogs(e,t={}){return Je(ze.notHash(e),$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"logs",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getTransactions(e,t={}){return Je(!e,$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"transactions",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getPendingTransactions(e,t={}){return Je(!e,$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"pending-transactions",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getBalance(e,t={}){Je(ze.notHash(e),$e);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:We,subendpoint:n,filterOptions:t}).then(Xe,Ye)}getTokens(e,t={}){return Je(ze.notHash(e),$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"tokens",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getTokenTransfers(e,t={}){return Je(ze.notHash(e),$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"token-transfers",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getTokenBalances(e,t={}){return Je(ze.notHash(e),$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"token-balances",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getUsage(e,t={}){return Je(ze.notHash(e),$e),Ve(this.web3data,{hash:e,endpoint:We,subendpoint:"usage",filterOptions:t}).then(Xe,Ye)}getMetrics(){return Ve(this.web3data,{endpoint:We,subendpoint:"metrics/latest"}).then(Xe,Ye)}};const{is:et,get:tt,onFulfilled:nt,onError:rt,throwIf:st,recordsFormatter:ot}=qe,{ERROR_MESSAGE_TOKEN_NO_ADDRESS:it,ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS:at,TOKENS_ENDPOINT:ct}=le;var dt=class{constructor(e){this.web3data=e}getRankings(e={}){return tt(this.web3data,{endpoint:ct,subendpoint:"rankings",filterOptions:e}).then(nt,rt)}getVolume(e,t={}){return st(et.notHash(e),it),tt(this.web3data,{hash:e,endpoint:ct,subendpoint:"volume",filterOptions:t}).then(nt,rt)}getVelocity(e,t={}){return st(et.notHash(e),it),tt(this.web3data,{hash:e,endpoint:ct,subendpoint:"velocity",filterOptions:t}).then(nt,rt)}getHolders(e,t={}){st(et.notHash(e),it);let n="holders/latest",r={formatter:ot};return t.holderAddresses&&(n="holders/historical",r={}),tt(this.web3data,{hash:e,endpoint:ct,subendpoint:n,filterOptions:t}).then(nt.bind(r),rt)}getHoldersHistorical(e,t){return st(et.notInObject(t,"holderAddresses"),at),this.getHolders(e,t)}getSupplies(e,t={}){st(et.notHash(e),it);const n=t.startDate||t.endDate?"supplies/historical":"supplies/latest";return tt(this.web3data,{hash:e,endpoint:ct,subendpoint:n,filterOptions:t}).then(nt,rt)}getTransfers(e,t={}){return st(et.notHash(e),it),tt(this.web3data,{hash:e,endpoint:ct,subendpoint:"transfers",filterOptions:t}).then(nt.bind({formatter:ot}),rt)}};const{ERROR_MESSAGE_CONTRACT_NO_ADDRESS:ut,CONTRACTS_ENDPOINT:lt}=le,{is:ht,get:pt,throwIf:ft,onFulfilled:bt,onError:gt}=qe;var mt=class{constructor(e){this.web3data=e}getDetails(e){return ft(ht.notHash(e),ut),pt(this.web3data,{pathParam:e,endpoint:lt}).then(bt,gt)}getFunctions(e){return ht.notHash(e)?Promise.reject(new Error(ut)):pt(this.web3data,{pathParam:e,endpoint:lt,subendpoint:"functions"}).then(bt,gt)}getAbi(e){return ft(ht.notHash(e),ut),this.getDetails(e).then(({abi:e})=>e)}getSourceCode(e){return ft(ht.notHash(e),ut),pt(this.web3data,{pathParam:e,endpoint:lt,subendpoint:"source-code"}).then(bt,gt)}getCode(e){return this.getDetails(e).then(e=>e.bytecode||"0x")}};const{TRANSACTIONS_ENDPOINT:Et,ERROR_MESSAGE_TRANSACTION_NO_HASH:_t}=le,{is:Ot,get:wt,onFulfilled:Tt,onError:Nt,throwIf:St,recordsFormatter:Rt}=qe;var At=class{constructor(e){this.web3data=e}getTransactions(e={}){return wt(this.web3data,{endpoint:Et,filterOptions:e}).then(Tt.bind({formatter:Rt}),Nt)}getAll(e){return this.getTransactions(e)}getTransaction(e,t={}){return St(Ot.notHash(e),_t),wt(this.web3data,{pathParam:e,endpoint:Et,filterOptions:t}).then(Tt,Nt)}getPendingTransactions(){return this.getTransactions({status:"pending"}).then(e=>(St(Ot.undefined(e)||Ot.null(e),"Failed to retrieve pending transactions."),e),console.error)}getGasPrediction(){return wt(this.web3data,{endpoint:Et,subendpoint:"gas/predictions"}).then(Tt,Nt)}getGasPercentiles(e={}){return wt(this.web3data,{endpoint:Et,subendpoint:"gas/percentiles",filterOptions:e}).then(Tt,Nt)}getGasPrice(){return this.getGasPrediction().then(e=>(St(!e.average||!e.average.gasPrice,"Failed to retrieve gas price."),""+e.average.gasPrice))}getVolume(e={}){return wt(this.web3data,{endpoint:Et,subendpoint:"volume",filterOptions:e}).then(Tt,Nt)}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return wt(this.web3data,{endpoint:Et+"/metrics",subendpoint:t,filterOptions:e}).then(Tt.bind({formatter:Rt}),Nt)}};const{BLOCKS_ENDPOINT:yt,ERROR_MESSAGE_BLOCK_NO_ID:vt}=le,{is:It,get:kt,throwIf:Ct,onFulfilled:Dt,onError:Ht,recordsFormatter:Bt}=qe;var Mt=class{constructor(e){this.web3data=e}getBlocks(e){return kt(this.web3data,{endpoint:yt,filterOptions:e}).then(Dt.bind({formatter:Bt}),Ht)}getBlock(e,t){return Ct(It.undefined(e),vt),kt(this.web3data,{pathParam:e,endpoint:yt,filterOptions:t}).then(Dt,Ht)}getBlockNumber(){return this.web3data.block.getBlock("latest").then(e=>(Ct(e|!e.number,"Failed to retrieve block number."),Number.parseInt(e.number,10)))}getBlockTransactionCount(e){return this.web3data.block.getBlock(e).then(e=>(Ct(!e||!e.predictions&&!e.numTransactions,"Failed to retrieve block transaction count."),e.predictions?null:Number.parseInt(e.numTransactions,10)))}getTransactions(e,t){return Ct(It.undefined(e),vt),kt(this.web3data,{pathParam:e,endpoint:yt,subendpoint:"transactions",filterOptions:t}).then(Dt.bind({formatter:Bt}),Ht)}getTransactionFromBlock(e,t){return Ct(It.undefined(e),vt),this.web3data.block.getTransactions(e).then(e=>(Ct(!e,"Failed to retrieve transaction."),t-1?e[t]:null))}getUncle(e,t){return Ct(It.undefined(e),vt),Ct(It.undefined(t),"Missing required param 'index'"),this.web3data.block.getBlock(e,{validationMethod:"full"}).then(e=>(Ct(!e||!e.predictions&&!e.numTransactions&&!e.validation,"Failed to retrieve uncle."),!e.predictions&&e.validation.uncles&&t-1?e.validation.uncles[t]:null))}getTokenTransfers(e,t){return Ct(It.undefined(e),vt),kt(this.web3data,{pathParam:e,endpoint:yt,subendpoint:"token-transfers",filterOptions:t}).then(Dt,Ht)}getLogs(e,t){return Ct(It.undefined(e),vt),kt(this.web3data,{pathParam:e,endpoint:yt,subendpoint:"logs",filterOptions:t}).then(Dt.bind({formatter:Bt}),Ht)}getFunctions(e,t){return Ct(It.undefined(e),vt),kt(this.web3data,{pathParam:e,endpoint:yt,subendpoint:"functions",filterOptions:t}).then(Dt.bind({formatter:Bt}),Ht)}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return kt(this.web3data,{endpoint:yt+"/metrics",subendpoint:t,filterOptions:e}).then(Dt.bind({formatter:Bt}),Ht)}};const{BLOCKCHAINS_ENDPOINT:Pt}=le,{get:Lt,onFulfilled:Ut,onError:xt}=qe;var Kt=class{constructor(e){this.web3data=e}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return Lt(this.web3data,{endpoint:Pt+"/metrics",subendpoint:t,filterOptions:e}).then(Ut,xt)}};const{get:Ft,is:jt,throwIf:Gt,onError:qt,onFulfilled:$t}=qe,{SIGNATURES_ENDPOINT:Wt,ERROR_MESSAGE_SIGNATURE_NO_HASH:zt}=le;var Vt=class{constructor(e){this.web3data=e}getSignature(e){return Gt(jt.notHash(e),zt),Ft(this.web3data,{hash:e,endpoint:Wt}).then($t,qt)}};const{is:Jt,get:Xt,throwIf:Yt,onFulfilled:Zt,onError:Qt}=qe,{MARKET_FEATURES:en,MARKET_ENDPOINT:tn,ERROR_MESSAGE_MARKET_NO_PAIR:nn,ERROR_MESSAGE_MARKET_NO_FEATURE:rn}=le;var sn=class{constructor(e){this.web3data=e}getEtherPrice(){return Xt(this.web3data,{endpoint:tn+"/spot/prices/pairs/eth_usd/latest"}).then(e=>e.payload.price,Qt)}getRankings(e){return Xt(this.web3data,{endpoint:tn,subendpoint:"rankings",filterOptions:e}).then(Zt,Qt)}async getFeatures(e=en,t={}){e=(e=Array.isArray(e)?e:[e]).map(e=>{switch(Yt(Jt.undefined(e)||!en.includes(e),rn),e){case"prices":e+="/pairs";break;case"ohlcv":case"tickers":case"trades":e+="/information"}return Xt(this.web3data,{endpoint:tn,subendpoint:e,filterOptions:t}).then(Zt,Qt).then(t=>({[e.split("/")[0]]:t}))});let n={};return(await Promise.all([...e])).map(e=>(n={...n,...e},e)),n}getOhlcv(e,t={}){Yt(Jt.undefined(e),nn);const n=t.startDate||t.endDate?"historical":"latest";return Xt(this.web3data,{pathParam:e,endpoint:tn+"/ohlcv",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getOrders(e,t,n={}){return Yt(Jt.undefined(e),nn),(t=Array.isArray(t)?t:[t]).forEach(e=>Yt(Jt.undefined(e),"No exchange specified")),n.exchange=t,Xt(this.web3data,{pathParam:e,endpoint:tn+"/orders",filterOptions:n}).then(Zt,Qt)}getOrderBooks(e,t={}){return Yt(Jt.undefined(e),nn),Xt(this.web3data,{pathParam:e,endpoint:tn+"/orders",subendpoint:"update",filterOptions:t}).then(Zt,Qt)}getBbos(e,t={}){Yt(Jt.undefined(e),nn);const n=t.startDate||t.endDate?"bbo/historical":"bbo";return Xt(this.web3data,{pathParam:e,endpoint:tn+"/orders",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getPrices(e,t={}){Yt(Jt.undefined(e),nn);const n=t.startDate||t.endDate?"historical":"latest";return Xt(this.web3data,{pathParam:e,endpoint:tn+"/spot/prices/pairs",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getTokenPrices(e,t={}){Yt(Jt.notHash(e),nn);const n=t.startDate||t.endDate?"historical":"latest";return Xt(this.web3data,{hash:e,endpoint:tn+"/tokens/prices",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getVwap(e,t={}){return Yt(Jt.undefined(e),nn),Xt(this.web3data,{pathParam:e,endpoint:tn+"/prices",subendpoint:"wap/latest",filterOptions:t}).then(Zt,Qt)}getTickers(e,t={}){Yt(Jt.undefined(e),nn);const n=t.startDate||t.endDate?"historical":"latest";return Xt(this.web3data,{pathParam:e,endpoint:tn+"/tickers",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getTrades(e,t={}){return Yt(Jt.undefined(e),nn),Xt(this.web3data,{pathParam:e,endpoint:tn+"/trades",subendpoint:"historical",filterOptions:t}).then(Zt,Qt)}getAssetAddresses(e="all"){return Xt(this.web3data,{endpoint:tn+"/pairs/addresses",filterOptions:{symbols:e}}).then(Zt,Qt)}};const{ethFactory:on}=qe,{BLOCKCHAIN_ID_ETHEREUM_MAINNET:an}=le;var cn=class{constructor(e,t,n){n.blockchainId=an,this.web3data=new e(t,n);const r=on(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:dn,BTC_METHODS:un}=le,{methodFactory:ln}=qe;var hn=class{constructor(e,t,n){n.blockchainId=dn,this.web3data=new e(t,n),ln(this,un)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN_CASH:pn,BTC_METHODS:fn}=le,{methodFactory:bn}=qe;var gn=class{constructor(e,t,n){n.blockchainId=pn,this.web3data=new e(t,n),bn(this,fn)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN_SV:mn,BTC_METHODS:En}=le,{methodFactory:_n}=qe;var On=class{constructor(e,t,n){n.blockchainId=mn,this.web3data=new e(t,n),_n(this,En)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_LITECOIN:wn,LTC_METHODS:Tn}=le,{methodFactory:Nn}=qe;var Sn=class{constructor(e,t,n){n.blockchainId=wn,this.web3data=new e(t,n),Nn(this,Tn)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_STELLAR:Rn,BTC_METHODS:An}=le,{methodFactory:yn}=qe;var vn=class{constructor(e,t,n){n.blockchainId=Rn,this.web3data=new e(t,n),yn(this,An)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_ZCASH:In,BTC_METHODS:kn}=le,{methodFactory:Cn}=qe;var Dn=class{constructor(e,t,n){n.blockchainId=In,this.web3data=new e(t,n),Cn(this,kn)}rpc(e,t){return this.web3data.rpc(e,t)}},Hn=null;"undefined"!=typeof WebSocket?Hn=WebSocket:"undefined"!=typeof MozWebSocket?Hn=MozWebSocket:void 0!==ue?Hn=ue.WebSocket||ue.MozWebSocket:"undefined"!=typeof window?Hn=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(Hn=self.WebSocket||self.MozWebSocket);var Bn=Hn;const{DEFAULT_WEBSOCKET_URL:Mn}=le,{is:Pn,uuid:Ln}=qe,Un=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||[]})):"",xn=0,Kn=1,Fn=2;var jn=class{constructor(e,t){this.socket=null,this.baseWsUrl=t&&t.websocketUrl?t.websocketUrl:Mn,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={}}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 Bn(`${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&&Pn.nonEmptyObject(this.registry)&&this.socket&&this.socket.close()},5e3),setTimeout(()=>{!this.dataReceived&&Pn.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=Ln({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[Ln({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=Ln({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?Kn:Pn.string(e.result)?xn:Pn.bool(e.result)?Fn:void 0)(t)){case xn:this._subHandler(t);break;case Kn:this._dataHandler(t);break;case Fn: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),Pn.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=Pn.notUndefined(t)?[t]:[],r=Ln({eventName:e,filters:t}),s=Un({id:r,params:[e,...n]});this.socket.send(s)}_unsubscribe(e,t,n){const r=Un({id:n,method:"unsubscribe",params:[this.registry[n].subId]});this.socket.readyState===this.socket.OPEN&&this.socket.send(r)}};const{API_KEY_HEADER:Gn,BLOCKCHAIN_ID_HEADER:qn,DEFAULT_BASE_URL:$n,DEFAULT_RPC_URL:Wn,ERROR_RPC_NO_METHOD:zn}=le,{is:Vn,throwIf:Jn,formatJsonRpc:Xn}=qe;class Yn{constructor(e,t={}){Jn(Vn.undefined(e)||Vn.emptyString(e),"No api key supplied"),this.apiKey=e,this.blockchainId=null,this.headers={},this.headers[Gn]=this.apiKey,t.blockchainId&&(this.blockchainId=t.blockchainId,this.headers[qn]=t.blockchainId),this.wsConfig={...t,websocketUrl:t.websocketUrl?t.websocketUrl:null},this.baseUrl=t.baseUrl?t.baseUrl:$n,this.address=new Qe(this),this.token=new dt(this),this.contract=new mt(this),this.transaction=new At(this),this.block=new Mt(this),this.blockchain=new Kt(this),this.signature=new Vt(this),this.market=new sn(this)}rawQuery(e){return de.get(this.baseUrl+e,{headers:this.headers}).then(e=>e.data)}rpc(e,t=[]){return Jn(!e,zn),de.post(`${Wn}?${Gn}=${this.apiKey}&${qn}=${this.blockchainId}`,Xn({method:e,params:t}),{headers:this.headers}).then(e=>e.data,e=>e.response.data)}}var Zn=class extends Yn{constructor(e,t={}){super(e,t),this.eth=new cn(Yn,e,t),this.btc=new hn(Yn,e,t),this.bch=new gn(Yn,e,t),this.bsv=new On(Yn,e,t),this.ltc=new Sn(Yn,e,t),this.xlm=new vn(Yn,e,t),this.zec=new Dn(Yn,e,t),this.websocket=null}connect(e){return this.websocket=this.websocket?this.websocket:new jn(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=Zn),Zn})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).web3data=t()}(this,(function(){"use strict";var e=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r1)for(var n=1;n=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(x("Request failed with status code "+n.status,n.config,null,n.request,n))}(t,n,s),o=null}},o.onabort=function(){o&&(n(x("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){n(x("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(x(t,e,"ECONNABORTED",o)),o=null},a.isStandardBrowserEnv()){var p=G,f=(e.withCredentials||j(h))&&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)}))},$={"Content-Type":"application/x-www-form-urlencoded"};function W(e,t){!a.isUndefined(e)&&a.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var V,z={adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==U&&"[object process]"===Object.prototype.toString.call(U))&&(V=q),V),transformRequest:[function(e,t){return K(t,"Accept"),K(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}};z.headers={common:{Accept:"application/json, text/plain, */*"}},a.forEach(["delete","get","head"],(function(e){z.headers[e]={}})),a.forEach(["post","put","patch"],(function(e){z.headers[e]=a.merge($)}));var J=z;function X(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Y=function(e){return X(e),e.headers=e.headers||{},e.data=h(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=h(t.data,t.headers,e.transformResponse),t}),(function(t){return p(t)||(X(e),t&&t.response&&(t.response.data=h(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 l,response:new l}}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:{};var le=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_BASE="No market base 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})),he=(le.DEFAULT_WEBSOCKET_URL,le.DEFAULT_BASE_URL,le.DEFAULT_RPC_URL,le.API_KEY_HEADER,le.BLOCKCHAIN_ID_HEADER,le.BLOCKCHAIN_ID_ETHEREUM_MAINNET,le.BLOCKCHAIN_ID_ETHEREUM_RINKEBY,le.BLOCKCHAIN_ID_BITCOIN,le.BLOCKCHAIN_ID_BITCOIN_CASH,le.BLOCKCHAIN_ID_BITCOIN_SV,le.BLOCKCHAIN_ID_LITECOIN,le.BLOCKCHAIN_ID_RIPPLE,le.BLOCKCHAIN_ID_ZCASH,le.BLOCKCHAIN_ID_STELLAR,le.ADDRESSES_ENDPOINT,le.TOKENS_ENDPOINT,le.TRANSACTIONS_ENDPOINT,le.BLOCKS_ENDPOINT,le.BLOCKCHAINS_ENDPOINT,le.CONTRACTS_ENDPOINT,le.SIGNATURES_ENDPOINT,le.MARKET_ENDPOINT,le.MARKET_FEATURES,le.ERROR_MESSAGE_TOKEN_NO_ADDRESS,le.ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS,le.ERROR_MESSAGE_TRANSACTION_NO_HASH,le.ERROR_MESSAGE_ADDRESS_NO_ADDRESS,le.ERROR_MESSAGE_CONTRACT_NO_ADDRESS,le.ERROR_MESSAGE_BLOCK_NO_ID,le.ERROR_MESSAGE_MARKET_NO_PAIR,le.ERROR_MESSAGE_MARKET_NO_BASE,le.ERROR_MESSAGE_MARKET_NO_FEATURE,le.ERROR_MESSAGE_SIGNATURE_NO_HASH,le.ERROR_RPC_NO_METHOD,le.ETH_METHODS,le.BTC_METHODS,le.LTC_METHODS,le.XLM_METHODS,le.HTTP_CODE_NOT_FOUND,"undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)),pe=new Uint8Array(16);function fe(){if(!he)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return he(pe)}var be=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ge(e){return"string"==typeof e&&be.test(e)}for(var Ee,me,_e=[],Oe=0;Oe<256;++Oe)_e.push((Oe+256).toString(16).substr(1));function Ne(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(_e[e[t+0]]+_e[e[t+1]]+_e[e[t+2]]+_e[e[t+3]]+"-"+_e[e[t+4]]+_e[e[t+5]]+"-"+_e[e[t+6]]+_e[e[t+7]]+"-"+_e[e[t+8]]+_e[e[t+9]]+"-"+_e[e[t+10]]+_e[e[t+11]]+_e[e[t+12]]+_e[e[t+13]]+_e[e[t+14]]+_e[e[t+15]]).toLowerCase();if(!ge(n))throw TypeError("Stringified UUID is invalid");return n}var we=0,Te=0;function Ae(e){if(!ge(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}function Ie(e,t,n){function r(e,r,s,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n>>9<<4)+1}function Se(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function ye(e,t,n,r,s,o){return Se((i=Se(Se(t,e),Se(r,o)))<<(a=s)|i>>>32-a,n);var i,a}function ve(e,t,n,r,s,o,i){return ye(t&n|~t&r,e,t,s,o,i)}function Ce(e,t,n,r,s,o,i){return ye(t&r|n&~r,e,t,s,o,i)}function De(e,t,n,r,s,o,i){return ye(t^n^r,e,t,s,o,i)}function ke(e,t,n,r,s,o,i){return ye(n^(t|~r),e,t,s,o,i)}var He=Ie("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n>5]>>>r%32&255,o=parseInt("0123456789abcdef".charAt(s>>>4&15)+"0123456789abcdef".charAt(15&s),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<>5]|=(255&e[r/8])<>>32-t}var Me=Ie("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=[];for(var s=0;s>>0;_=m,m=E,E=Le(g,30)>>>0,g=b,b=w}n[0]=n[0]+b>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+E>>>0,n[3]=n[3]+m>>>0,n[4]=n[4]+_>>>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]]}));var Pe=Object.freeze({__proto__:null,v1:function(e,t,n){var r=t&&n||0,s=t||new Array(16),o=(e=e||{}).node||Ee,i=void 0!==e.clockseq?e.clockseq:me;if(null==o||null==i){var a=e.random||(e.rng||fe)();null==o&&(o=Ee=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==i&&(i=me=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),d=void 0!==e.nsecs?e.nsecs:Te+1,u=c-we+(d-Te)/1e4;if(u<0&&void 0===e.clockseq&&(i=i+1&16383),(u<0||c>we)&&void 0===e.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");we=c,Te=d,me=i;var l=(1e4*(268435455&(c+=122192928e5))+d)%4294967296;s[r++]=l>>>24&255,s[r++]=l>>>16&255,s[r++]=l>>>8&255,s[r++]=255&l;var h=c/4294967296*1e4&268435455;s[r++]=h>>>8&255,s[r++]=255&h,s[r++]=h>>>24&15|16,s[r++]=h>>>16&255,s[r++]=i>>>8|128,s[r++]=255&i;for(var p=0;p<6;++p)s[r+p]=o[p];return t||Ne(s)},v3:He,v4:function(e,t,n){var r=(e=e||{}).random||(e.rng||fe)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var s=0;s<16;++s)t[n+s]=r[s];return t}return Ne(r)},v5:Me,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!ge(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:ge,stringify:Ne,parse:Ae});const{ETH_METHODS:Ue}=le,Ke=e=>{let t="";for(const n in e)({}).hasOwnProperty.call(e,n)&&(t+=`${n}=${e[n]}&`);return t},xe=(e,t)=>{if(e)throw new Error(t)},Fe=e=>xe(!0,e),je=()=>{};je.string=e=>"string"==typeof e,je.bool=e=>"boolean"==typeof e,je.emptyString=e=>je.string(e)&&0===e.length,je.emptyObject=e=>0===Object.keys(e).length,je.inObject=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),je.undefined=e=>void 0===e,je.null=e=>null===e,je.notHash=e=>je.undefined(e)||je.emptyString(e),je.notUndefined=e=>!je.undefined(e),je.nonEmptyObject=e=>!je.emptyObject(e),je.nonEmptyString=e=>!je.emptyString(e),je.notInObject=(e,t)=>!je.inObject(e,t);const Ge=e=>Object.getOwnPropertyNames(e).filter(t=>"function"==typeof e[t]&&"constructor"!==t);var qe={buildFilterUrl:Ke,is:je,throwIf:xe,get:(e,{endpoint:t="",subendpoint:n="",hash:r="",pathParam:s="",filterOptions:o={}})=>{const i=je.nonEmptyObject(o)?"?"+Ke(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=>Pe.v5(JSON.stringify(e),"ccfeca02-f0e9-4433-a740-b830cceb3d2d"),ethFactory:function(e){const t={};for(const n in Ue)({}).hasOwnProperty.call(Ue,n)&&(t[n]=e[Ue[n]][n].bind(e[Ue[n]]));return t},methodFactory:(e,t)=>(Object.keys(t).forEach(n=>{Ge(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:Fe,onFulfilled:function(e){return xe(e.error,e.message),this&&this.formatter?this.formatter(e.payload):e.payload},onError:({response:{data:e}})=>Fe(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:Ge,recordsFormatter:e=>((e,t)=>e&&e[t]?e[t]:e)(e,"records")};const{ERROR_MESSAGE_ADDRESS_NO_ADDRESS:$e,ADDRESSES_ENDPOINT:We}=le,{is:Ve,get:ze,throwIf:Je,onFulfilled:Xe,onError:Ye,recordsFormatter:Ze}=qe;var Qe=class{constructor(e){this.web3data=e}getAllAddresses(e={}){return this.getAll(e)}getAll(e={}){return ze(this.web3data,{endpoint:We,filterOptions:e}).then(Xe.bind({formatter:Ze}),Ye)}getInformation(e,t={}){return Je(Ve.notHash(e),$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"information",filterOptions:t}).then(Xe,Ye)}getMetadata(e,t={}){return Je(Ve.notHash(e),$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"metadata",filterOptions:t}).then(Xe,Ye)}getAdoption(e,t={}){return Je(Ve.notHash(e),$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"adoption",filterOptions:t}).then(Xe,Ye)}getInternalMessages(e,t={}){return this.web3data.address.getFunctions(e,t)}getFunctions(e,t={}){return Je(Ve.notHash(e),$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"functions",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getLogs(e,t={}){return Je(Ve.notHash(e),$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"logs",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getTransactions(e,t={}){return Je(!e,$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"transactions",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getPendingTransactions(e,t={}){return Je(!e,$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"pending-transactions",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getBalance(e,t={}){Je(Ve.notHash(e),$e);let n="information";return Array.isArray(e)?(n="balances",t.addresses=e):t.includeTokens?n="balances":(t.startDate||t.endDate)&&(n="account-balances/historical"),ze(this.web3data,{...t.addresses?{}:{hash:e},endpoint:We,subendpoint:n,filterOptions:t}).then(Xe,Ye)}getTokens(e,t={}){return Je(Ve.notHash(e),$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"tokens",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getTokenTransfers(e,t={}){return Je(Ve.notHash(e),$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"token-transfers",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getTokenBalances(e,t={}){return Je(Ve.notHash(e),$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"token-balances",filterOptions:t}).then(Xe.bind({formatter:Ze}),Ye)}getUsage(e,t={}){return Je(Ve.notHash(e),$e),ze(this.web3data,{hash:e,endpoint:We,subendpoint:"usage",filterOptions:t}).then(Xe,Ye)}getMetrics(){return ze(this.web3data,{endpoint:We,subendpoint:"metrics/latest"}).then(Xe,Ye)}};const{is:et,get:tt,onFulfilled:nt,onError:rt,throwIf:st,recordsFormatter:ot}=qe,{ERROR_MESSAGE_TOKEN_NO_ADDRESS:it,ERROR_MESSAGE_TOKEN_NO_HOLDER_ADDRESS:at,TOKENS_ENDPOINT:ct}=le;var dt=class{constructor(e){this.web3data=e}getRankings(e={}){return tt(this.web3data,{endpoint:ct,subendpoint:"rankings",filterOptions:e}).then(nt,rt)}getVolume(e,t={}){return st(et.notHash(e),it),tt(this.web3data,{hash:e,endpoint:ct,subendpoint:"volume",filterOptions:t}).then(nt,rt)}getVelocity(e,t={}){return st(et.notHash(e),it),tt(this.web3data,{hash:e,endpoint:ct,subendpoint:"velocity",filterOptions:t}).then(nt,rt)}getHolders(e,t={}){st(et.notHash(e),it);let n="holders/latest",r={formatter:ot};return t.holderAddresses&&(n="holders/historical",r={}),tt(this.web3data,{hash:e,endpoint:ct,subendpoint:n,filterOptions:t}).then(nt.bind(r),rt)}getHoldersHistorical(e,t){return st(et.notInObject(t,"holderAddresses"),at),this.getHolders(e,t)}getSupplies(e,t={}){st(et.notHash(e),it);const n=t.startDate||t.endDate?"supplies/historical":"supplies/latest";return tt(this.web3data,{hash:e,endpoint:ct,subendpoint:n,filterOptions:t}).then(nt,rt)}getTransfers(e,t={}){return st(et.notHash(e),it),tt(this.web3data,{hash:e,endpoint:ct,subendpoint:"transfers",filterOptions:t}).then(nt.bind({formatter:ot}),rt)}};const{ERROR_MESSAGE_CONTRACT_NO_ADDRESS:ut,CONTRACTS_ENDPOINT:lt}=le,{is:ht,get:pt,throwIf:ft,onFulfilled:bt,onError:gt}=qe;var Et=class{constructor(e){this.web3data=e}getDetails(e){return ft(ht.notHash(e),ut),pt(this.web3data,{pathParam:e,endpoint:lt}).then(bt,gt)}getFunctions(e){return ht.notHash(e)?Promise.reject(new Error(ut)):pt(this.web3data,{pathParam:e,endpoint:lt,subendpoint:"functions"}).then(bt,gt)}getAbi(e){return ft(ht.notHash(e),ut),this.getDetails(e).then(({abi:e})=>e)}getSourceCode(e){return ft(ht.notHash(e),ut),pt(this.web3data,{pathParam:e,endpoint:lt,subendpoint:"source-code"}).then(bt,gt)}getCode(e){return this.getDetails(e).then(e=>e.bytecode||"0x")}};const{TRANSACTIONS_ENDPOINT:mt,ERROR_MESSAGE_TRANSACTION_NO_HASH:_t}=le,{is:Ot,get:Nt,onFulfilled:wt,onError:Tt,throwIf:At,recordsFormatter:It}=qe;var Rt=class{constructor(e){this.web3data=e}getTransactions(e={}){return Nt(this.web3data,{endpoint:mt,filterOptions:e}).then(wt.bind({formatter:It}),Tt)}getAll(e){return this.getTransactions(e)}getTransaction(e,t={}){return At(Ot.notHash(e),_t),Nt(this.web3data,{pathParam:e,endpoint:mt,filterOptions:t}).then(wt,Tt)}getPendingTransactions(){return this.getTransactions({status:"pending"}).then(e=>(At(Ot.undefined(e)||Ot.null(e),"Failed to retrieve pending transactions."),e),console.error)}getGasPrediction(){return Nt(this.web3data,{endpoint:mt,subendpoint:"gas/predictions"}).then(wt,Tt)}getGasPercentiles(e={}){return Nt(this.web3data,{endpoint:mt,subendpoint:"gas/percentiles",filterOptions:e}).then(wt,Tt)}getGasPrice(){return this.getGasPrediction().then(e=>(At(!e.average||!e.average.gasPrice,"Failed to retrieve gas price."),""+e.average.gasPrice))}getVolume(e={}){return Nt(this.web3data,{endpoint:mt,subendpoint:"volume",filterOptions:e}).then(wt,Tt)}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return Nt(this.web3data,{endpoint:mt+"/metrics",subendpoint:t,filterOptions:e}).then(wt.bind({formatter:It}),Tt)}};const{BLOCKS_ENDPOINT:St,ERROR_MESSAGE_BLOCK_NO_ID:yt}=le,{is:vt,get:Ct,throwIf:Dt,onFulfilled:kt,onError:Ht,recordsFormatter:Bt}=qe;var Lt=class{constructor(e){this.web3data=e}getBlocks(e){return Ct(this.web3data,{endpoint:St,filterOptions:e}).then(kt.bind({formatter:Bt}),Ht)}getBlock(e,t){return Dt(vt.undefined(e),yt),Ct(this.web3data,{pathParam:e,endpoint:St,filterOptions:t}).then(kt,Ht)}getBlockNumber(){return this.web3data.block.getBlock("latest").then(e=>(Dt(e|!e.number,"Failed to retrieve block number."),Number.parseInt(e.number,10)))}getBlockTransactionCount(e){return this.web3data.block.getBlock(e).then(e=>(Dt(!e||!e.predictions&&!e.numTransactions,"Failed to retrieve block transaction count."),e.predictions?null:Number.parseInt(e.numTransactions,10)))}getTransactions(e,t){return Dt(vt.undefined(e),yt),Ct(this.web3data,{pathParam:e,endpoint:St,subendpoint:"transactions",filterOptions:t}).then(kt.bind({formatter:Bt}),Ht)}getTransactionFromBlock(e,t){return Dt(vt.undefined(e),yt),this.web3data.block.getTransactions(e).then(e=>(Dt(!e,"Failed to retrieve transaction."),t-1?e[t]:null))}getUncle(e,t){return Dt(vt.undefined(e),yt),Dt(vt.undefined(t),"Missing required param 'index'"),this.web3data.block.getBlock(e,{validationMethod:"full"}).then(e=>(Dt(!e||!e.predictions&&!e.numTransactions&&!e.validation,"Failed to retrieve uncle."),!e.predictions&&e.validation.uncles&&t-1?e.validation.uncles[t]:null))}getTokenTransfers(e,t){return Dt(vt.undefined(e),yt),Ct(this.web3data,{pathParam:e,endpoint:St,subendpoint:"token-transfers",filterOptions:t}).then(kt,Ht)}getLogs(e,t){return Dt(vt.undefined(e),yt),Ct(this.web3data,{pathParam:e,endpoint:St,subendpoint:"logs",filterOptions:t}).then(kt.bind({formatter:Bt}),Ht)}getFunctions(e,t){return Dt(vt.undefined(e),yt),Ct(this.web3data,{pathParam:e,endpoint:St,subendpoint:"functions",filterOptions:t}).then(kt.bind({formatter:Bt}),Ht)}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return Ct(this.web3data,{endpoint:St+"/metrics",subendpoint:t,filterOptions:e}).then(kt.bind({formatter:Bt}),Ht)}};const{BLOCKCHAINS_ENDPOINT:Mt}=le,{get:Pt,onFulfilled:Ut,onError:Kt}=qe;var xt=class{constructor(e){this.web3data=e}getMetrics(e){const t=e&&(e.startDate||e.endDate)?"historical":"latest";return Pt(this.web3data,{endpoint:Mt+"/metrics",subendpoint:t,filterOptions:e}).then(Ut,Kt)}};const{get:Ft,is:jt,throwIf:Gt,onError:qt,onFulfilled:$t}=qe,{SIGNATURES_ENDPOINT:Wt,ERROR_MESSAGE_SIGNATURE_NO_HASH:Vt}=le;var zt=class{constructor(e){this.web3data=e}getSignature(e){return Gt(jt.notHash(e),Vt),Ft(this.web3data,{hash:e,endpoint:Wt}).then($t,qt)}};const{is:Jt,get:Xt,throwIf:Yt,onFulfilled:Zt,onError:Qt}=qe,{MARKET_FEATURES:en,MARKET_ENDPOINT:tn,ERROR_MESSAGE_MARKET_NO_PAIR:nn,ERROR_MESSAGE_MARKET_NO_FEATURE:rn}=le;var sn=class{constructor(e){this.web3data=e}getEtherPrice(){return Xt(this.web3data,{endpoint:tn+"/spot/prices/pairs/eth_usd/latest"}).then(e=>e.payload.price,Qt)}getRankings(e){return Xt(this.web3data,{endpoint:tn,subendpoint:"rankings",filterOptions:e}).then(Zt,Qt)}async getFeatures(e=en,t={}){e=(e=Array.isArray(e)?e:[e]).map(e=>{switch(Yt(Jt.undefined(e)||!en.includes(e),rn),e){case"prices":e+="/pairs";break;case"ohlcv":case"tickers":case"trades":e+="/information"}return Xt(this.web3data,{endpoint:tn,subendpoint:e,filterOptions:t}).then(Zt,Qt).then(t=>({[e.split("/")[0]]:t}))});let n={};return(await Promise.all([...e])).map(e=>(n={...n,...e},e)),n}getOhlcv(e,t={}){Yt(Jt.undefined(e),nn);const n=t.startDate||t.endDate?"historical":"latest";return Xt(this.web3data,{pathParam:e,endpoint:tn+"/ohlcv",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getOrders(e,t,n={}){return Yt(Jt.undefined(e),nn),(t=Array.isArray(t)?t:[t]).forEach(e=>Yt(Jt.undefined(e),"No exchange specified")),n.exchange=t,Xt(this.web3data,{pathParam:e,endpoint:tn+"/orders",filterOptions:n}).then(Zt,Qt)}getOrderBooks(e,t={}){return Yt(Jt.undefined(e),nn),Xt(this.web3data,{pathParam:e,endpoint:tn+"/orders",subendpoint:"update",filterOptions:t}).then(Zt,Qt)}getBbos(e,t={}){Yt(Jt.undefined(e),nn);const n=t.startDate||t.endDate?"bbo/historical":"bbo";return Xt(this.web3data,{pathParam:e,endpoint:tn+"/orders",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getPrices(e,t={}){Yt(Jt.undefined(e),nn);const n=t.startDate||t.endDate?"historical":"latest";return Xt(this.web3data,{pathParam:e,endpoint:tn+"/spot/prices/pairs",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getTokenPrices(e,t={}){Yt(Jt.notHash(e),nn);const n=t.startDate||t.endDate?"historical":"latest";return Xt(this.web3data,{hash:e,endpoint:tn+"/tokens/prices",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getVwap(e,t={}){return Yt(Jt.undefined(e),nn),Xt(this.web3data,{pathParam:e,endpoint:tn+"/prices",subendpoint:"wap/latest",filterOptions:t}).then(Zt,Qt)}getTickers(e,t={}){Yt(Jt.undefined(e),nn);const n=t.startDate||t.endDate?"historical":"latest";return Xt(this.web3data,{pathParam:e,endpoint:tn+"/tickers",subendpoint:n,filterOptions:t}).then(Zt,Qt)}getTrades(e,t={}){return Yt(Jt.undefined(e),nn),Xt(this.web3data,{pathParam:e,endpoint:tn+"/trades",subendpoint:"historical",filterOptions:t}).then(Zt,Qt)}getAssetAddresses(e="all"){return Xt(this.web3data,{endpoint:tn+"/pairs/addresses",filterOptions:{symbols:e}}).then(Zt,Qt)}};const{ethFactory:on}=qe,{BLOCKCHAIN_ID_ETHEREUM_MAINNET:an}=le;var cn=class{constructor(e,t,n){n.blockchainId=an,this.web3data=new e(t,n);const r=on(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:dn,BTC_METHODS:un}=le,{methodFactory:ln}=qe;var hn=class{constructor(e,t,n){n.blockchainId=dn,this.web3data=new e(t,n),ln(this,un)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN_CASH:pn,BTC_METHODS:fn}=le,{methodFactory:bn}=qe;var gn=class{constructor(e,t,n){n.blockchainId=pn,this.web3data=new e(t,n),bn(this,fn)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_BITCOIN_SV:En,BTC_METHODS:mn}=le,{methodFactory:_n}=qe;var On=class{constructor(e,t,n){n.blockchainId=En,this.web3data=new e(t,n),_n(this,mn)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_LITECOIN:Nn,LTC_METHODS:wn}=le,{methodFactory:Tn}=qe;var An=class{constructor(e,t,n){n.blockchainId=Nn,this.web3data=new e(t,n),Tn(this,wn)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_STELLAR:In,BTC_METHODS:Rn}=le,{methodFactory:Sn}=qe;var yn=class{constructor(e,t,n){n.blockchainId=In,this.web3data=new e(t,n),Sn(this,Rn)}rpc(e,t){return this.web3data.rpc(e,t)}};const{BLOCKCHAIN_ID_ZCASH:vn,BTC_METHODS:Cn}=le,{methodFactory:Dn}=qe;var kn=class{constructor(e,t,n){n.blockchainId=vn,this.web3data=new e(t,n),Dn(this,Cn)}rpc(e,t){return this.web3data.rpc(e,t)}},Hn=null;"undefined"!=typeof WebSocket?Hn=WebSocket:"undefined"!=typeof MozWebSocket?Hn=MozWebSocket:void 0!==ue?Hn=ue.WebSocket||ue.MozWebSocket:"undefined"!=typeof window?Hn=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(Hn=self.WebSocket||self.MozWebSocket);var Bn=Hn;const{DEFAULT_WEBSOCKET_URL:Ln}=le,{is:Mn,uuid:Pn}=qe,Un=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||[]})):"",Kn=0,xn=1,Fn=2;var jn=class{constructor(e,t){this.socket=null,this.baseWsUrl=t&&t.websocketUrl?t.websocketUrl:Ln,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={}}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 Bn(`${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&&Mn.nonEmptyObject(this.registry)&&this.socket&&this.socket.close()},5e3),setTimeout(()=>{!this.dataReceived&&Mn.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=Pn({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[Pn({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=Pn({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?xn:Mn.string(e.result)?Kn:Mn.bool(e.result)?Fn:void 0)(t)){case Kn:this._subHandler(t);break;case xn:this._dataHandler(t);break;case Fn: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),Mn.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=Mn.notUndefined(t)?[t]:[],r=Pn({eventName:e,filters:t}),s=Un({id:r,params:[e,...n]});this.socket.send(s)}_unsubscribe(e,t,n){const r=Un({id:n,method:"unsubscribe",params:[this.registry[n].subId]});this.socket.readyState===this.socket.OPEN&&this.socket.send(r)}};const{API_KEY_HEADER:Gn,BLOCKCHAIN_ID_HEADER:qn,DEFAULT_BASE_URL:$n,DEFAULT_RPC_URL:Wn,ERROR_RPC_NO_METHOD:Vn,BLOCKCHAIN_ID_ETHEREUM_MAINNET:zn,BLOCKCHAIN_ID_ETHEREUM_RINKEBY:Jn,BLOCKCHAIN_ID_BITCOIN:Xn,BLOCKCHAIN_ID_BITCOIN_CASH:Yn,BLOCKCHAIN_ID_BITCOIN_SV:Zn,BLOCKCHAIN_ID_LITECOIN:Qn,BLOCKCHAIN_ID_RIPPLE:er,BLOCKCHAIN_ID_ZCASH:tr,BLOCKCHAIN_ID_STELLAR:nr}=le,{is:rr,throwIf:sr,formatJsonRpc:or}=qe;class ir{constructor(e,t={}){sr(rr.undefined(e)||rr.emptyString(e),"No api key supplied"),this.apiKey=e,this.blockchainId=null,this.headers={},this.headers[Gn]=this.apiKey,t.blockchainId&&(this.blockchainId=t.blockchainId,this.headers[qn]=t.blockchainId),this.wsConfig={...t,websocketUrl:t.websocketUrl?t.websocketUrl:null},this.baseUrl=t.baseUrl?t.baseUrl:$n,this.address=new Qe(this),this.token=new dt(this),this.contract=new Et(this),this.transaction=new Rt(this),this.block=new Lt(this),this.blockchain=new xt(this),this.signature=new zt(this),this.market=new sn(this)}rawQuery(e){return de.get(this.baseUrl+e,{headers:this.headers}).then(e=>e.data)}rpc(e,t=[]){return sr(!e,Vn),de.post(`${Wn}?${Gn}=${this.apiKey}&${qn}=${this.blockchainId}`,or({method:e,params:t}),{headers:this.headers}).then(e=>e.data,e=>e.response.data)}}class ar extends ir{constructor(e,t={}){super(e,t),this.eth=new cn(ir,e,t),this.btc=new hn(ir,e,t),this.bch=new gn(ir,e,t),this.bsv=new On(ir,e,t),this.ltc=new An(ir,e,t),this.xlm=new yn(ir,e,t),this.zec=new kn(ir,e,t),this.websocket=null}connect(e){return this.websocket=this.websocket?this.websocket:new jn(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")}}Object.assign(ar,{BLOCKCHAIN_ID_ETHEREUM_MAINNET:zn,BLOCKCHAIN_ID_ETHEREUM_RINKEBY:Jn,BLOCKCHAIN_ID_BITCOIN:Xn,BLOCKCHAIN_ID_BITCOIN_CASH:Yn,BLOCKCHAIN_ID_BITCOIN_SV:Zn,BLOCKCHAIN_ID_LITECOIN:Qn,BLOCKCHAIN_ID_RIPPLE:er,BLOCKCHAIN_ID_ZCASH:tr,BLOCKCHAIN_ID_STELLAR:nr});var cr=ar;return"undefined"!=typeof window&&void 0===window.Web3Data&&(window.Web3Data=cr),cr})); \ No newline at end of file diff --git a/src/web3data.js b/src/web3data.js index 0fc6959..a780f7d 100644 --- a/src/web3data.js +++ b/src/web3data.js @@ -4,7 +4,16 @@ const { BLOCKCHAIN_ID_HEADER, DEFAULT_BASE_URL, DEFAULT_RPC_URL, - ERROR_RPC_NO_METHOD + ERROR_RPC_NO_METHOD, + BLOCKCHAIN_ID_ETHEREUM_MAINNET, + BLOCKCHAIN_ID_ETHEREUM_RINKEBY, + BLOCKCHAIN_ID_BITCOIN, + BLOCKCHAIN_ID_BITCOIN_CASH, + BLOCKCHAIN_ID_BITCOIN_SV, + BLOCKCHAIN_ID_LITECOIN, + BLOCKCHAIN_ID_RIPPLE, + BLOCKCHAIN_ID_ZCASH, + BLOCKCHAIN_ID_STELLAR } = require('./constants') const {is, throwIf, formatJsonRpc} = require('./utils') const Address = require('./address') @@ -181,4 +190,16 @@ class Web3Data extends Web3DataFactory { } } +Object.assign(Web3Data, { + BLOCKCHAIN_ID_ETHEREUM_MAINNET, + BLOCKCHAIN_ID_ETHEREUM_RINKEBY, + BLOCKCHAIN_ID_BITCOIN, + BLOCKCHAIN_ID_BITCOIN_CASH, + BLOCKCHAIN_ID_BITCOIN_SV, + BLOCKCHAIN_ID_LITECOIN, + BLOCKCHAIN_ID_RIPPLE, + BLOCKCHAIN_ID_ZCASH, + BLOCKCHAIN_ID_STELLAR +}) + module.exports = Web3Data diff --git a/test/web3data.test.js b/test/web3data.test.js index 6bd6dd3..0044a83 100644 --- a/test/web3data.test.js +++ b/test/web3data.test.js @@ -1,6 +1,19 @@ import Web3Data from '../src/web3data' import test from 'ava' -import {API_KEY_HEADER, DEFAULT_BASE_URL, BLOCKCHAIN_ID_HEADER} from "../src/constants"; +import { + API_KEY_HEADER, + DEFAULT_BASE_URL, + BLOCKCHAIN_ID_HEADER, + BLOCKCHAIN_ID_ETHEREUM_MAINNET, + BLOCKCHAIN_ID_ETHEREUM_RINKEBY, + BLOCKCHAIN_ID_BITCOIN, + BLOCKCHAIN_ID_BITCOIN_CASH, + BLOCKCHAIN_ID_BITCOIN_SV, + BLOCKCHAIN_ID_LITECOIN, + BLOCKCHAIN_ID_RIPPLE, + BLOCKCHAIN_ID_ZCASH, + BLOCKCHAIN_ID_STELLAR +} from "../src/constants"; import { TOKEN_ADDRESS, @@ -53,6 +66,18 @@ test('web3data should accept a blockchain id & add to headers', t => { t.is(web3data.headers[BLOCKCHAIN_ID_HEADER], BLOCKCHAIN_ID) }); +test('Web3data exposes blockchain id constants as public class properties', t => { + t.is(Web3Data.BLOCKCHAIN_ID_ETHEREUM_MAINNET, BLOCKCHAIN_ID_ETHEREUM_MAINNET) + t.is(Web3Data.BLOCKCHAIN_ID_ETHEREUM_RINKEBY, BLOCKCHAIN_ID_ETHEREUM_RINKEBY) + t.is(Web3Data.BLOCKCHAIN_ID_BITCOIN, BLOCKCHAIN_ID_BITCOIN) + t.is(Web3Data.BLOCKCHAIN_ID_BITCOIN_CASH, BLOCKCHAIN_ID_BITCOIN_CASH) + t.is(Web3Data.BLOCKCHAIN_ID_BITCOIN_SV, BLOCKCHAIN_ID_BITCOIN_SV) + t.is(Web3Data.BLOCKCHAIN_ID_LITECOIN, BLOCKCHAIN_ID_LITECOIN) + t.is(Web3Data.BLOCKCHAIN_ID_RIPPLE, BLOCKCHAIN_ID_RIPPLE) + t.is(Web3Data.BLOCKCHAIN_ID_ZCASH, BLOCKCHAIN_ID_ZCASH) + t.is(Web3Data.BLOCKCHAIN_ID_STELLAR, BLOCKCHAIN_ID_STELLAR) +}); + test('Web3data rawQuery accepts url and returns valid response', async t => { let response = await t.context.web3data.rawQuery('/addresses'); t.is(response.status, 200)