Socket
Socket
Sign inDemoInstall

xrpl-client

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xrpl-client - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

2

dist/browser.min.js

@@ -13,2 +13,2 @@ require=function e(t,n,r){function i(s,l){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!l&&u)return u(s,!0);if(o)return o(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var c=n[s]={exports:{}};t[s][0].call(c.exports,(function(e){return i(t[s][1][e]||e)}),c,c.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0})},{}],2:[function(e,t,n){(function(n){(function(){"use strict";var r=e("object-assign");

*/
"use strict";var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function s(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,l,u=s(e),a=1;a<arguments.length;a++){for(var c in n=Object(arguments[a]))i.call(n,c)&&(u[c]=n[c]);if(r){l=r(n);for(var f=0;f<l.length;f++)o.call(n,l[f])&&(u[l[f]]=n[l[f]])}}return u}},{}],12:[function(e,t,n){var r,i,o=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function u(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{i="function"==typeof clearTimeout?clearTimeout:l}catch(e){i=l}}();var a,c=[],f=!1,d=-1;function p(){f&&a&&(f=!1,a.length?c=a.concat(c):d=-1,c.length&&h())}function h(){if(!f){var e=u(p);f=!0;for(var t=c.length;t;){for(a=c,c=[];++d<t;)a&&a[d].run();d=-1,t=c.length}a=null,f=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===l||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function m(){}o.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];c.push(new v(e,t)),1!==c.length||f||u(h)},v.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],13:[function(e,t,n){var r;if("object"==typeof globalThis)r=globalThis;else try{r=e("es5-ext/global")}catch(e){}finally{if(r||"undefined"==typeof window||(r=window),!r)throw new Error("Could not determine global this")}var i=r.WebSocket||r.MozWebSocket,o=e("./version");function s(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(s,e,{get:function(){return i[e]}})})),t.exports={w3cwebsocket:i?s:null,version:o}},{"./version":14,"es5-ext/global":8}],14:[function(e,t,n){t.exports=e("../package.json").version},{"../package.json":15}],15:[function(e,t,n){t.exports={name:"websocket",description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],author:"Brian McKelvey <theturtle32@gmail.com> (https://github.com/theturtle32)",contributors:["Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"],version:"1.0.34",repository:{type:"git",url:"https://github.com/theturtle32/WebSocket-Node.git"},homepage:"https://github.com/theturtle32/WebSocket-Node",engines:{node:">=4.0.0"},dependencies:{bufferutil:"^4.0.1",debug:"^2.2.0","es5-ext":"^0.10.50","typedarray-to-buffer":"^3.1.5","utf-8-validate":"^5.0.2",yaeti:"^0.0.6"},devDependencies:{"buffer-equal":"^1.0.0",gulp:"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1",jshint:"^2.0.0",tape:"^4.9.1"},config:{verbose:!1},scripts:{test:"tape test/unit/*.js",gulp:"gulp"},main:"index",directories:{lib:"./lib"},browser:"lib/browser.js",license:"Apache-2.0"}},{}],"xrpl-client":[function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function l(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}u((r=r.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.XrplClient=void 0;const l=s(e("assert")),u=e("events"),a=e("debug"),c=e("websocket");i(e("./types"),n);const f=a.debug("xrplclient"),d=f.extend("warning"),p=f.extend("message"),h=f.extend("node");class v extends u.EventEmitter{constructor(e,t){var n;let r;super(),this.eventBus=new u.EventEmitter,this.closed=!1,this.uplinkReady=!1,this.options={connectAttemptTimeoutSeconds:3,assumeOfflineAfterSeconds:15,maxConnectionAttempts:null},this.callId=0,this.pendingCalls=[],this.subscriptions=[],this.serverState={validatedLedgers:"",reserveBase:null,reserveInc:null,latency:[],fee:[],connectAttempts:-1},t&&Object.assign(this.options,t);const i=()=>{var e;clearTimeout(r);const t=1e3*Number((null===(e=null==this?void 0:this.options)||void 0===e?void 0:e.assumeOfflineAfterSeconds)||15);r=setTimeout((()=>{var e;if(this.uplinkReady){d(`Conn. TIMEOUT, no ledger for ${t} sec.`);try{null===(e=this.connection)||void 0===e||e.close()}catch(e){}}}),t)};i();const s=()=>{var e,t;let n=1;const r=(null===(e=this.options)||void 0===e?void 0:e.maxConnectionAttempts)||null;r&&(n=(((null===(t=this.options)||void 0===t?void 0:t.connectAttemptTimeoutSeconds)||3)-1)/(r-1));return Math.max(1.5,(this.serverState.connectAttempts+1)*n)};this.endpoints=[],e&&(this.endpoints=[...new Set(Array.isArray(e)?e:[e])].map((e=>e.trim())).filter((e=>e.match(/^ws[s]{0,1}:\/\//)))),this.endpoints.length<1&&(this.endpoints=["wss://xrplcluster.com","wss://xrpl.link","wss://s2.ripple.com"],d("No valid WebSocket endpoint(s) specified, falling back to defaults",this.endpoints)),this.endpoint=this.endpoints[0].trim(),this.endpoints.length>1&&!(null===(n=this.options)||void 0===n?void 0:n.maxConnectionAttempts)&&(f(`Multiple endpoints (${this.endpoints.length}) and no maxConnection attempts, set (3)`),Object.assign(this.options,{maxConnectionAttempts:3})),f("Initialized xrpld WebSocket Client"),this.on("ledger",(()=>{v(),i()}));const a=()=>{},v=()=>{this.uplinkReady||(this.serverState.connectAttempts=0,h("Connection ready, fire events"),this.uplinkReady=!0,this.eventBus.emit("flush"),this.emit("online"),this.endpoint=this.endpoints[0],this.emit("state",this.getState()))},m=()=>{if(this.closed||this.connection.readyState!==c.w3cwebsocket.OPEN)try{this.connection.close()}catch(e){}else{if(f("Connection opened :)"),this.connection.url.match(/^wss:\/\/(xrplcluster\.com|xrpl\.link|xrpl\.ws)/))try{this.connection.send(JSON.stringify({__api:"state",origin:"xrpl-client@js/ts"}))}catch(e){}this.send({id:"_WsClient_Internal_Subscription",command:"subscribe",streams:["ledger"]},{sendIfNotReady:!0,noReplayAfterReconnect:!0}).then(a,a),this.send({id:"_WsClient_Internal_ServerInfo@"+Number(new Date),command:"server_info"},{sendIfNotReady:!0,noReplayAfterReconnect:!0}).then((()=>{v()}),a)}},g=e=>{this.emit("close"),this.emit("state",this.getState()),this.uplinkReady&&this.emit("offline"),this.uplinkReady=!1,this.serverInfo=void 0,d("Upstream/Websocket closed",null==e?void 0:e.code,null==e?void 0:e.reason),j(),this.closed?f("Closed on purpose, not reconnecting"):(this.emit("retry"),d(`Not closed on purpose, reconnecting after ${s()}...`),setTimeout((()=>{this.eventBus.emit("reconnect")}),1e3*s()))},y=e=>{var t,n;if(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.info){const t=e;this.serverInfo||h("Connected, server_info:",{pubkey_node:t.result.info.pubkey_node,build_version:t.result.info.build_version,complete_ledgers:t.result.info.complete_ledgers});const r=Number(new Date)-Number(String((null==e?void 0:e.id)||"").split("@").reverse()[0]);r&&(this.serverState.latency.push({moment:new Date,value:r}),this.serverState.latency.splice(0,this.serverState.latency.length-10));const i=1.2,o=t.result.info.load_factor*Number(null===(n=t.result.info.validated_ledger)||void 0===n?void 0:n.base_fee_xrp)*1e6*i;o&&(this.serverState.fee.push({moment:new Date,value:o}),this.serverState.fee.splice(0,this.serverState.fee.length-5)),this.serverInfo=t}},b=e=>{var t,n,r,i,o,s,l,u,c,f;if("_WsClient_Internal_Subscription"!==(null===(t=null==e?void 0:e.id)||void 0===t?void 0:t._Request)){let t;if(null===(n=null==e?void 0:e.id)||void 0===n?void 0:n._WsClient){const n=this.subscriptions.filter((t=>{var n;return t.id===(null===(n=null==e?void 0:e.id)||void 0===n?void 0:n._WsClient)}));n.length>0&&(t=n[0],t.promiseCallables.resolve(Object.assign(e,{id:null===(r=null==e?void 0:e.id)||void 0===r?void 0:r._Request})))}if(this.emit("message",e),"ledgerClosed"===(null==e?void 0:e.type))p("Async",e.type),Object.assign(this.serverState,{validatedLedgers:null==e?void 0:e.validated_ledgers,reserveBase:Number(null==e?void 0:e.reserve_base)/1e6||null,reserveInc:Number(null==e?void 0:e.reserve_inc)/1e6||null}),this.emit("ledger",e),this.send({id:"_WsClient_Internal_ServerInfo@"+Number(new Date),command:"server_info"}).then(a,a);else if("path_find"===(null==e?void 0:e.type))p("Async",e.type),this.emit("path",e);else if("transaction"===(null==e?void 0:e.type))p("Async",e.type),this.emit("transaction",e);else if(null==e?void 0:e.validation_public_key)p("Async","validation"),this.emit("validation",e);else if("path_find"===(null===(i=null==t?void 0:t.request)||void 0===i?void 0:i.command))p("Async",null===(o=null==t?void 0:t.request)||void 0===o?void 0:o.command),this.emit("path",e);else if("subscribe"===(null===(s=null==t?void 0:t.request)||void 0===s?void 0:s.command)&&Array.isArray(null===(l=null==t?void 0:t.request)||void 0===l?void 0:l.streams)&&(null===(u=null==t?void 0:t.request)||void 0===u?void 0:u.streams.indexOf("ledger"))>-1)p("Async","subscription:ledger"),this.emit("ledger",e);else if(t);else{if(!((null===(c=null==e?void 0:e.id)||void 0===c?void 0:c._Request)&&String(e.id._Request).match(/^_WsClient_Internal/))){try{const t=e;if("PROXY"===(null==t?void 0:t.type))return this.clusterInfo_=t,void this.emit("clusterinfo",this.clusterInfo_)}catch(e){}p("Handle <UNKNOWN> Async Message",{internalId:null===(f=null==e?void 0:e.id)||void 0===f?void 0:f._WsClient,matchingSubscription:t,type:null==e?void 0:e.type,message:e})}}}},C=e=>{var t,n,r,i,o,s;try{l.default("string"==typeof e.data,"Unexpected incoming WebSocket message data type");const u=JSON.parse(e.data);if(this.lastContact=new Date,null===(t=null==u?void 0:u.id)||void 0===t?void 0:t._WsClient){const e=this.subscriptions.filter((e=>{var t;return e.id===(null===(t=null==u?void 0:u.id)||void 0===t?void 0:t._WsClient)})),t=this.pendingCalls.filter((e=>{var t;return e.id===(null===(t=null==u?void 0:u.id)||void 0===t?void 0:t._WsClient)}));if(1===e.length)b(u);else if(1===t.length){const e="_WsClient_Internal_ServerInfo"===String((null===(i=null===(r=null===(n=t[0])||void 0===n?void 0:n.request)||void 0===r?void 0:r.id)||void 0===i?void 0:i._Request)||"").split("@")[0];Object.assign(u,{id:null===(o=null==u?void 0:u.id)||void 0===o?void 0:o._Request}),(null===(s=t[0].sendOptions)||void 0===s?void 0:s.timeoutSeconds)&&t[0].timeout&&clearTimeout(t[0].timeout),t[0].promiseCallables.resolve((null==u?void 0:u.result)||u),this.pendingCalls.splice(this.pendingCalls.indexOf(t[0]),1),e?y(u):f("» Pending Call Length",this.pendingCalls.length)}else b(u)}else b(u)}catch(e){d("Uplink response: parse error",e.message)}},w=e=>{d("Upstream/Websocket error")},_=e=>{var t;(null===(t=null==e?void 0:e.sendOptions)||void 0===t?void 0:t.timeoutSeconds)&&!(null==e?void 0:e.timeout)&&Object.assign(e,{timeout:setTimeout((()=>o(this,void 0,void 0,(function*(){var t;"_WsClient_Internal_CallResolved"===(yield Promise.race([e.promise,Promise.resolve("_WsClient_Internal_CallResolved")]))&&e.promiseCallables.reject(new Error(`Call timeout after ${null===(t=e.sendOptions)||void 0===t?void 0:t.timeoutSeconds} seconds`))}))),1e3*Number(e.sendOptions.timeoutSeconds))})},x=e=>{var t,n,r;"_WsClient_Internal_ServerInfo"!==String((null===(n=null===(t=null==e?void 0:e.request)||void 0===t?void 0:t.id)||void 0===n?void 0:n._Request)||"").split("@")[0]&&f(" > Process call",e.id,e.request.command);try{this.connection.send(JSON.stringify(e.request)),(null===(r=null==e?void 0:e.sendOptions)||void 0===r?void 0:r.timeoutStartsWhenOnline)&&_(e)}catch(e){d("Process (send to uplink) error",e.message)}},O=e=>{var t,n,r,i,o;"_WsClient_Internal_ServerInfo"!==String((null===(n=null===(t=null==e?void 0:e.request)||void 0===t?void 0:t.id)||void 0===n?void 0:n._Request)||"").split("@")[0]&&f(`Call ${e.id}: ${e.request.command}\n > `,this.uplinkReady?"Uplink ready, pass immediately":(null===(r=null==e?void 0:e.sendOptions)||void 0===r?void 0:r.sendIfNotReady)?"Uplink not flagged as ready yet, but `sendIfNotReady` = true, so go ahead":"Uplink not ready, wait for flush"),(null===(i=null==e?void 0:e.sendOptions)||void 0===i?void 0:i.timeoutStartsWhenOnline)||_(e),(this.uplinkReady||(null===(o=null==e?void 0:e.sendOptions)||void 0===o?void 0:o.sendIfNotReady))&&x(e)},S=()=>{f("Connected, flushing pending calls & subscriptions"),this.pendingCalls.forEach((e=>{x(e)})),this.subscriptions.forEach((e=>{x(e)}))},E=e=>{this.closed=!0,f("Closing connection"),j();try{this.connection.close()}catch(e){}clearTimeout(r),this.subscriptions.forEach((e=>{e.promiseCallables.reject(new Error("Class (connection) hard close requested"))})),this.pendingCalls.forEach((e=>{e.promiseCallables.reject(new Error("Class (connection) hard close requested"))})),this.eventBus.off("__WsClient_call",O),this.eventBus.off("__WsClient_close",E),this.eventBus.off("flush",S),this.eventBus.off("reconnect",F),e&&this.emit("error",e)},j=()=>{f("Cleanup"),this.connection.removeEventListener("open",m),this.connection.removeEventListener("message",C),this.connection.removeEventListener("error",w),this.connection.removeEventListener("close",g)},F=()=>{var e,t,n,r,i;try{this.connection.close()}catch(e){}if(f("Connecting",this.endpoint),this.serverState.connectAttempts++,this.options.maxConnectionAttempts&&Number((null===(e=this.options)||void 0===e?void 0:e.maxConnectionAttempts)||1)>1&&this.serverState.connectAttempts>=Number((null===(t=this.options)||void 0===t?void 0:t.maxConnectionAttempts)||1))if(h("Too many connection attempts",this.serverState.connectAttempts,null===(n=this.options)||void 0===n?void 0:n.maxConnectionAttempts),f(this.endpoint,this.endpoints,this.endpoints.length,this.endpoints.indexOf(this.endpoint)),this.endpoints.length>1&&this.endpoints.indexOf(this.endpoint)>-1){d("Multiple endpoints, max. connection attempts exceeded. Switch endpoint.");const e=this.endpoints.indexOf(this.endpoint)+1;d("--- Current endpoint",this.endpoint),this.endpoint=this.endpoints[e>=this.endpoints.length?0:e],d("--- New endpoint",this.endpoint),this.serverState.connectAttempts=0,this.emit("nodeswitch",this.endpoint),e>=this.endpoints.length&&this.emit("round")}else d("Only one valid endpoint, after the max. connection attempts: game over"),E(new Error("Max. connection attempts exceeded"));if(!this.closed){const e=new c.w3cwebsocket(this.endpoint,void 0,void 0,Object.assign((null===(r=this.options)||void 0===r?void 0:r.httpHeaders)||{},{"user-agent":"xrpl-client@js/ts"}),(null===(i=this.options)||void 0===i?void 0:i.httpRequestOptions)||{},{maxReceivedFrameSize:2147483648,maxReceivedMessageSize:8589934592});setTimeout((()=>{e.readyState!==c.w3cwebsocket.OPEN&&e.close()}),1e3*s()-1),e.addEventListener("open",m),e.addEventListener("message",C),e.addEventListener("error",w),e.addEventListener("close",g),this.connection=e}return this.connection};this.eventBus.on("__WsClient_call",O),this.eventBus.on("__WsClient_close",E),this.eventBus.on("flush",S),this.eventBus.on("reconnect",F),this.connection=F()}ready(){return new Promise(((e,t)=>{const n=this.getState();if(n.online&&n.secLastContact&&n.secLastContact<10&&n.ledger.last)return e(this);this.on("ledger",(()=>{e(this)}))}))}send(e,t={}){var n,r,i;l.default("object"==typeof e&&e,"`send()`: expecting object containing `command`"),l.default("string"==typeof e.command,"`command` must be typeof string"),this.callId++;const o={resolve:e=>{},reject:e=>{}},s=new Promise(((e,t)=>{Object.assign(o,{resolve:e,reject:t})})),u={id:this.callId,request:Object.assign(e,{id:{_WsClient:this.callId,_Request:null==e?void 0:e.id},command:e.command.toLowerCase().trim()}),promise:s,promiseCallables:o,sendOptions:t};if(this.closed)return o.reject(new Error("Client in closed state")),s;const a=("subscribe"===u.request.command||"unsubscribe"===u.request.command||"path_find"===u.request.command)&&!(null==t?void 0:t.noReplayAfterReconnect);return"unsubscribe"===(null===(n=u.request)||void 0===n?void 0:n.command)&&Array.isArray(null===(r=u.request)||void 0===r?void 0:r.streams)&&(null===(i=u.request)||void 0===i?void 0:i.streams.indexOf("ledger"))>-1&&(u.request.streams.splice(u.request.streams.indexOf("ledger"),1),0===u.request.streams.length&&0===Object.keys(u.request).filter((e=>"id"!==e&&"streams"!==e&&"command"!==e)).length)?Promise.reject(new Error("Unsubscribing from (just) the ledger stream is not allowed")):("_WsClient_Internal_ServerInfo"!==String((null==e?void 0:e.id)||"").split("@")[0]&&this[a?"subscriptions":"pendingCalls"].push(u),this.eventBus.emit("__WsClient_call",u),s)}getState(){var e,t,n,r,i,o,s,l,u;const a=this.serverState.validatedLedgers.split(",").map((e=>{const t=e.split("-");return t.length>1?parseInt(t[1])-parseInt(t[0]):1})).reduce(((e,t)=>e+t),0);return{online:this.uplinkReady&&!this.closed&&this.connection.readyState===c.w3cwebsocket.OPEN,latencyMs:{last:this.serverState.latency.slice(-1).map((e=>e.value))[0]||null,avg:this.serverState.latency.map((e=>e.value)).reduce(((e,t)=>e+t),0)/this.serverState.latency.length||null,secAgo:Number(new Date)/1e3-this.serverState.latency.slice(-1).map((e=>Number(e.moment)/1e3))[0]||null},server:{version:(null===(n=null===(t=null===(e=this.serverInfo)||void 0===e?void 0:e.result)||void 0===t?void 0:t.info)||void 0===n?void 0:n.build_version)||"",uptime:(null===(o=null===(i=null===(r=this.serverInfo)||void 0===r?void 0:r.result)||void 0===i?void 0:i.info)||void 0===o?void 0:o.uptime)||0,publicKey:(null===(u=null===(l=null===(s=this.serverInfo)||void 0===s?void 0:s.result)||void 0===l?void 0:l.info)||void 0===u?void 0:u.pubkey_node)||"",uri:this.connection.url},ledger:{last:Number(this.serverState.validatedLedgers.split(",").reverse()[0].split("-").reverse()[0]),validated:this.serverState.validatedLedgers,count:""===this.serverState.validatedLedgers?0:a},fee:{last:this.serverState.fee.slice(-1).map((e=>e.value))[0]||null,avg:this.serverState.fee.map((e=>e.value)).reduce(((e,t)=>e+t),0)/this.serverState.fee.length||null,secAgo:Number(new Date)/1e3-this.serverState.fee.slice(-1).map((e=>Number(e.moment)/1e3))[0]||null},reserve:{base:this.serverState.reserveBase,owner:this.serverState.reserveInc},secLastContact:this.lastContact?Number(new Date)/1e3-Number(this.lastContact)/1e3:null}}close(){l.default(!this.closed,"Object already in closed state"),this.eventBus.emit("__WsClient_close")}clusterInfo(){return new Promise(((e,t)=>{if(this.clusterInfo_)return e(this.clusterInfo_);this.on("clusterinfo",(t=>{e(t)}))}))}}n.XrplClient=v},{"./types":1,assert:2,debug:6,events:9,websocket:13}]},{},[]);
"use strict";var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function s(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,l,u=s(e),a=1;a<arguments.length;a++){for(var c in n=Object(arguments[a]))i.call(n,c)&&(u[c]=n[c]);if(r){l=r(n);for(var f=0;f<l.length;f++)o.call(n,l[f])&&(u[l[f]]=n[l[f]])}}return u}},{}],12:[function(e,t,n){var r,i,o=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function u(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{i="function"==typeof clearTimeout?clearTimeout:l}catch(e){i=l}}();var a,c=[],f=!1,d=-1;function p(){f&&a&&(f=!1,a.length?c=a.concat(c):d=-1,c.length&&h())}function h(){if(!f){var e=u(p);f=!0;for(var t=c.length;t;){for(a=c,c=[];++d<t;)a&&a[d].run();d=-1,t=c.length}a=null,f=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===l||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function m(){}o.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];c.push(new v(e,t)),1!==c.length||f||u(h)},v.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],13:[function(e,t,n){var r;if("object"==typeof globalThis)r=globalThis;else try{r=e("es5-ext/global")}catch(e){}finally{if(r||"undefined"==typeof window||(r=window),!r)throw new Error("Could not determine global this")}var i=r.WebSocket||r.MozWebSocket,o=e("./version");function s(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(s,e,{get:function(){return i[e]}})})),t.exports={w3cwebsocket:i?s:null,version:o}},{"./version":14,"es5-ext/global":8}],14:[function(e,t,n){t.exports=e("../package.json").version},{"../package.json":15}],15:[function(e,t,n){t.exports={name:"websocket",description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],author:"Brian McKelvey <theturtle32@gmail.com> (https://github.com/theturtle32)",contributors:["Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"],version:"1.0.34",repository:{type:"git",url:"https://github.com/theturtle32/WebSocket-Node.git"},homepage:"https://github.com/theturtle32/WebSocket-Node",engines:{node:">=4.0.0"},dependencies:{bufferutil:"^4.0.1",debug:"^2.2.0","es5-ext":"^0.10.50","typedarray-to-buffer":"^3.1.5","utf-8-validate":"^5.0.2",yaeti:"^0.0.6"},devDependencies:{"buffer-equal":"^1.0.0",gulp:"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1",jshint:"^2.0.0",tape:"^4.9.1"},config:{verbose:!1},scripts:{test:"tape test/unit/*.js",gulp:"gulp"},main:"index",directories:{lib:"./lib"},browser:"lib/browser.js",license:"Apache-2.0"}},{}],"xrpl-client":[function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function l(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}u((r=r.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.XrplClient=void 0;const l=s(e("assert")),u=e("events"),a=e("debug"),c=e("websocket");i(e("./types"),n);const f=a.debug("xrplclient"),d=f.extend("warning"),p=f.extend("message"),h=f.extend("node");class v extends u.EventEmitter{constructor(e,t){var n;let r;super(),this.eventBus=new u.EventEmitter,this.closed=!1,this.uplinkReady=!1,this.options={connectAttemptTimeoutSeconds:3,assumeOfflineAfterSeconds:15,maxConnectionAttempts:null},this.callId=0,this.pendingCalls=[],this.subscriptions=[],this.serverState={validatedLedgers:"",reserveBase:null,reserveInc:null,latency:[],fee:[],connectAttempts:-1},t&&Object.assign(this.options,t);const i=()=>{var e;clearTimeout(r);const t=1e3*Number((null===(e=null==this?void 0:this.options)||void 0===e?void 0:e.assumeOfflineAfterSeconds)||15);r=setTimeout((()=>{var e;if(this.uplinkReady){d(`Conn. TIMEOUT, no ledger for ${t} sec.`);try{null===(e=this.connection)||void 0===e||e.close()}catch(e){}}}),t)};i();const s=()=>{var e,t;let n=1;const r=(null===(e=this.options)||void 0===e?void 0:e.maxConnectionAttempts)||null;r&&(n=(((null===(t=this.options)||void 0===t?void 0:t.connectAttemptTimeoutSeconds)||3)-1)/(r-1));return Math.max(1.5,(this.serverState.connectAttempts+1)*n)};this.endpoints=[],e&&(this.endpoints=[...new Set(Array.isArray(e)?e:[e])].map((e=>e.trim())).filter((e=>e.match(/^ws[s]{0,1}:\/\//)))),this.endpoints.length<1&&(this.endpoints=["wss://xrplcluster.com","wss://xrpl.link","wss://s2.ripple.com"],d("No valid WebSocket endpoint(s) specified, falling back to defaults",this.endpoints)),this.endpoint=this.endpoints[0].trim(),this.endpoints.length>1&&!(null===(n=this.options)||void 0===n?void 0:n.maxConnectionAttempts)&&(f(`Multiple endpoints (${this.endpoints.length}) and no maxConnection attempts, set (3)`),Object.assign(this.options,{maxConnectionAttempts:3})),f("Initialized xrpld WebSocket Client"),this.on("ledger",(()=>{v(),i()}));const a=()=>{},v=()=>{this.uplinkReady||(this.serverState.connectAttempts=0,h("Connection ready, fire events"),this.uplinkReady=!0,this.eventBus.emit("flush"),this.emit("online"),this.emit("state",this.getState()))},m=()=>{if(this.closed||this.connection.readyState!==c.w3cwebsocket.OPEN)try{this.connection.close()}catch(e){}else{if(f("Connection opened :)"),this.endpoint.match(/^wss:\/\/(xrplcluster\.com|xrpl\.link|xrpl\.ws)/))try{this.connection.send(JSON.stringify({__api:"state",origin:"xrpl-client@js/ts"}))}catch(e){}this.send({id:"_WsClient_Internal_Subscription",command:"subscribe",streams:["ledger"]},{sendIfNotReady:!0,noReplayAfterReconnect:!0}).then(a,a),this.send({id:"_WsClient_Internal_ServerInfo@"+Number(new Date),command:"server_info"},{sendIfNotReady:!0,noReplayAfterReconnect:!0}).then((()=>{v()}),a)}},g=e=>{this.emit("close"),this.emit("state",this.getState()),this.uplinkReady&&(this.emit("offline"),this.endpoint=this.endpoints[0]),this.uplinkReady=!1,this.serverInfo=void 0,d("Upstream/Websocket closed",null==e?void 0:e.code,null==e?void 0:e.reason),j(),this.closed?f("Closed on purpose, not reconnecting"):(this.emit("retry"),d(`Not closed on purpose, reconnecting after ${s()}...`),setTimeout((()=>{this.eventBus.emit("reconnect")}),1e3*s()))},y=e=>{var t,n;if(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.info){const t=e;this.serverInfo||h("Connected, server_info:",{pubkey_node:t.result.info.pubkey_node,build_version:t.result.info.build_version,complete_ledgers:t.result.info.complete_ledgers});const r=Number(new Date)-Number(String((null==e?void 0:e.id)||"").split("@").reverse()[0]);r&&(this.serverState.latency.push({moment:new Date,value:r}),this.serverState.latency.splice(0,this.serverState.latency.length-10));const i=1.2,o=t.result.info.load_factor*Number(null===(n=t.result.info.validated_ledger)||void 0===n?void 0:n.base_fee_xrp)*1e6*i;o&&(this.serverState.fee.push({moment:new Date,value:o}),this.serverState.fee.splice(0,this.serverState.fee.length-5)),this.serverInfo=t}},b=e=>{var t,n,r,i,o,s,l,u,c,f;if("_WsClient_Internal_Subscription"!==(null===(t=null==e?void 0:e.id)||void 0===t?void 0:t._Request)){let t;if(null===(n=null==e?void 0:e.id)||void 0===n?void 0:n._WsClient){const n=this.subscriptions.filter((t=>{var n;return t.id===(null===(n=null==e?void 0:e.id)||void 0===n?void 0:n._WsClient)}));n.length>0&&(t=n[0],t.promiseCallables.resolve(Object.assign(e,{id:null===(r=null==e?void 0:e.id)||void 0===r?void 0:r._Request})))}if(this.emit("message",e),"ledgerClosed"===(null==e?void 0:e.type))p("Async",e.type),Object.assign(this.serverState,{validatedLedgers:null==e?void 0:e.validated_ledgers,reserveBase:Number(null==e?void 0:e.reserve_base)/1e6||null,reserveInc:Number(null==e?void 0:e.reserve_inc)/1e6||null}),this.emit("ledger",e),this.send({id:"_WsClient_Internal_ServerInfo@"+Number(new Date),command:"server_info"}).then(a,a);else if("path_find"===(null==e?void 0:e.type))p("Async",e.type),this.emit("path",e);else if("transaction"===(null==e?void 0:e.type))p("Async",e.type),this.emit("transaction",e);else if(null==e?void 0:e.validation_public_key)p("Async","validation"),this.emit("validation",e);else if("path_find"===(null===(i=null==t?void 0:t.request)||void 0===i?void 0:i.command))p("Async",null===(o=null==t?void 0:t.request)||void 0===o?void 0:o.command),this.emit("path",e);else if("subscribe"===(null===(s=null==t?void 0:t.request)||void 0===s?void 0:s.command)&&Array.isArray(null===(l=null==t?void 0:t.request)||void 0===l?void 0:l.streams)&&(null===(u=null==t?void 0:t.request)||void 0===u?void 0:u.streams.indexOf("ledger"))>-1)p("Async","subscription:ledger"),this.emit("ledger",e);else if(t);else{if(!((null===(c=null==e?void 0:e.id)||void 0===c?void 0:c._Request)&&String(e.id._Request).match(/^_WsClient_Internal/))){try{const t=e;if("PROXY"===(null==t?void 0:t.type))return this.clusterInfo_=t,void this.emit("clusterinfo",this.clusterInfo_)}catch(e){}p("Handle <UNKNOWN> Async Message",{internalId:null===(f=null==e?void 0:e.id)||void 0===f?void 0:f._WsClient,matchingSubscription:t,type:null==e?void 0:e.type,message:e})}}}},C=e=>{var t,n,r,i,o,s;try{l.default("string"==typeof e.data,"Unexpected incoming WebSocket message data type");const u=JSON.parse(e.data);if(this.lastContact=new Date,null===(t=null==u?void 0:u.id)||void 0===t?void 0:t._WsClient){const e=this.subscriptions.filter((e=>{var t;return e.id===(null===(t=null==u?void 0:u.id)||void 0===t?void 0:t._WsClient)})),t=this.pendingCalls.filter((e=>{var t;return e.id===(null===(t=null==u?void 0:u.id)||void 0===t?void 0:t._WsClient)}));if(1===e.length)b(u);else if(1===t.length){const e="_WsClient_Internal_ServerInfo"===String((null===(i=null===(r=null===(n=t[0])||void 0===n?void 0:n.request)||void 0===r?void 0:r.id)||void 0===i?void 0:i._Request)||"").split("@")[0];Object.assign(u,{id:null===(o=null==u?void 0:u.id)||void 0===o?void 0:o._Request}),(null===(s=t[0].sendOptions)||void 0===s?void 0:s.timeoutSeconds)&&t[0].timeout&&clearTimeout(t[0].timeout),t[0].promiseCallables.resolve((null==u?void 0:u.result)||u),this.pendingCalls.splice(this.pendingCalls.indexOf(t[0]),1),e?y(u):f("» Pending Call Length",this.pendingCalls.length)}else b(u)}else b(u)}catch(e){d("Uplink response: parse error",e.message)}},w=e=>{d("Upstream/Websocket error")},_=e=>{var t;(null===(t=null==e?void 0:e.sendOptions)||void 0===t?void 0:t.timeoutSeconds)&&!(null==e?void 0:e.timeout)&&Object.assign(e,{timeout:setTimeout((()=>o(this,void 0,void 0,(function*(){var t;"_WsClient_Internal_CallResolved"===(yield Promise.race([e.promise,Promise.resolve("_WsClient_Internal_CallResolved")]))&&e.promiseCallables.reject(new Error(`Call timeout after ${null===(t=e.sendOptions)||void 0===t?void 0:t.timeoutSeconds} seconds`))}))),1e3*Number(e.sendOptions.timeoutSeconds))})},x=e=>{var t,n,r;"_WsClient_Internal_ServerInfo"!==String((null===(n=null===(t=null==e?void 0:e.request)||void 0===t?void 0:t.id)||void 0===n?void 0:n._Request)||"").split("@")[0]&&f(" > Process call",e.id,e.request.command);try{this.connection.send(JSON.stringify(e.request)),(null===(r=null==e?void 0:e.sendOptions)||void 0===r?void 0:r.timeoutStartsWhenOnline)&&_(e)}catch(e){d("Process (send to uplink) error",e.message)}},O=e=>{var t,n,r,i,o;"_WsClient_Internal_ServerInfo"!==String((null===(n=null===(t=null==e?void 0:e.request)||void 0===t?void 0:t.id)||void 0===n?void 0:n._Request)||"").split("@")[0]&&f(`Call ${e.id}: ${e.request.command}\n > `,this.uplinkReady?"Uplink ready, pass immediately":(null===(r=null==e?void 0:e.sendOptions)||void 0===r?void 0:r.sendIfNotReady)?"Uplink not flagged as ready yet, but `sendIfNotReady` = true, so go ahead":"Uplink not ready, wait for flush"),(null===(i=null==e?void 0:e.sendOptions)||void 0===i?void 0:i.timeoutStartsWhenOnline)||_(e),(this.uplinkReady||(null===(o=null==e?void 0:e.sendOptions)||void 0===o?void 0:o.sendIfNotReady))&&x(e)},S=()=>{f("Connected, flushing pending calls & subscriptions"),this.pendingCalls.forEach((e=>{x(e)})),this.subscriptions.forEach((e=>{x(e)}))},E=e=>{this.closed=!0,f("Closing connection"),j();try{this.connection.close()}catch(e){}clearTimeout(r),this.subscriptions.forEach((e=>{e.promiseCallables.reject(new Error("Class (connection) hard close requested"))})),this.pendingCalls.forEach((e=>{e.promiseCallables.reject(new Error("Class (connection) hard close requested"))})),this.eventBus.off("__WsClient_call",O),this.eventBus.off("__WsClient_close",E),this.eventBus.off("flush",S),this.eventBus.off("reconnect",F),e&&this.emit("error",e)},j=()=>{f("Cleanup"),this.connection.removeEventListener("open",m),this.connection.removeEventListener("message",C),this.connection.removeEventListener("error",w),this.connection.removeEventListener("close",g)},F=()=>{var e,t,n,r,i;try{this.connection.close()}catch(e){}if(f("Connecting",this.endpoint),this.serverState.connectAttempts++,this.options.maxConnectionAttempts&&Number((null===(e=this.options)||void 0===e?void 0:e.maxConnectionAttempts)||1)>1&&this.serverState.connectAttempts>=Number((null===(t=this.options)||void 0===t?void 0:t.maxConnectionAttempts)||1))if(h("Too many connection attempts",this.serverState.connectAttempts,null===(n=this.options)||void 0===n?void 0:n.maxConnectionAttempts),f(this.endpoint,this.endpoints,this.endpoints.length,this.endpoints.indexOf(this.endpoint)),this.endpoints.length>1&&this.endpoints.indexOf(this.endpoint)>-1){d("Multiple endpoints, max. connection attempts exceeded. Switch endpoint.");const e=this.endpoints.indexOf(this.endpoint)+1;d("--- Current endpoint",this.endpoint),this.endpoint=this.endpoints[e>=this.endpoints.length?0:e],d("--- New endpoint",this.endpoint),this.serverState.connectAttempts=0,this.emit("nodeswitch",this.endpoint),e>=this.endpoints.length&&this.emit("round")}else d("Only one valid endpoint, after the max. connection attempts: game over"),E(new Error("Max. connection attempts exceeded"));if(!this.closed){const e=new c.w3cwebsocket(this.endpoint,void 0,void 0,Object.assign((null===(r=this.options)||void 0===r?void 0:r.httpHeaders)||{},{"user-agent":"xrpl-client@js/ts"}),(null===(i=this.options)||void 0===i?void 0:i.httpRequestOptions)||{},{maxReceivedFrameSize:2147483648,maxReceivedMessageSize:8589934592});setTimeout((()=>{e.readyState!==c.w3cwebsocket.OPEN&&e.close()}),1e3*s()-1),e.addEventListener("open",m),e.addEventListener("message",C),e.addEventListener("error",w),e.addEventListener("close",g),this.connection=e}return this.connection};this.eventBus.on("__WsClient_call",O),this.eventBus.on("__WsClient_close",E),this.eventBus.on("flush",S),this.eventBus.on("reconnect",F),this.connection=F()}ready(){return new Promise(((e,t)=>{const n=this.getState();if(n.online&&n.secLastContact&&n.secLastContact<10&&n.ledger.last)return e(this);this.on("ledger",(()=>{e(this)}))}))}send(e,t={}){var n,r,i;l.default("object"==typeof e&&e,"`send()`: expecting object containing `command`"),l.default("string"==typeof e.command,"`command` must be typeof string"),this.callId++;const o={resolve:e=>{},reject:e=>{}},s=new Promise(((e,t)=>{Object.assign(o,{resolve:e,reject:t})})),u={id:this.callId,request:Object.assign(e,{id:{_WsClient:this.callId,_Request:null==e?void 0:e.id},command:e.command.toLowerCase().trim()}),promise:s,promiseCallables:o,sendOptions:t};if(this.closed)return o.reject(new Error("Client in closed state")),s;const a=("subscribe"===u.request.command||"unsubscribe"===u.request.command||"path_find"===u.request.command)&&!(null==t?void 0:t.noReplayAfterReconnect);return"unsubscribe"===(null===(n=u.request)||void 0===n?void 0:n.command)&&Array.isArray(null===(r=u.request)||void 0===r?void 0:r.streams)&&(null===(i=u.request)||void 0===i?void 0:i.streams.indexOf("ledger"))>-1&&(u.request.streams.splice(u.request.streams.indexOf("ledger"),1),0===u.request.streams.length&&0===Object.keys(u.request).filter((e=>"id"!==e&&"streams"!==e&&"command"!==e)).length)?Promise.reject(new Error("Unsubscribing from (just) the ledger stream is not allowed")):("_WsClient_Internal_ServerInfo"!==String((null==e?void 0:e.id)||"").split("@")[0]&&this[a?"subscriptions":"pendingCalls"].push(u),this.eventBus.emit("__WsClient_call",u),s)}getState(){var e,t,n,r,i,o,s,l,u;const a=this.serverState.validatedLedgers.split(",").map((e=>{const t=e.split("-");return t.length>1?parseInt(t[1])-parseInt(t[0]):1})).reduce(((e,t)=>e+t),0);return{online:this.uplinkReady&&!this.closed&&this.connection.readyState===c.w3cwebsocket.OPEN,latencyMs:{last:this.serverState.latency.slice(-1).map((e=>e.value))[0]||null,avg:this.serverState.latency.map((e=>e.value)).reduce(((e,t)=>e+t),0)/this.serverState.latency.length||null,secAgo:Number(new Date)/1e3-this.serverState.latency.slice(-1).map((e=>Number(e.moment)/1e3))[0]||null},server:{version:(null===(n=null===(t=null===(e=this.serverInfo)||void 0===e?void 0:e.result)||void 0===t?void 0:t.info)||void 0===n?void 0:n.build_version)||"",uptime:(null===(o=null===(i=null===(r=this.serverInfo)||void 0===r?void 0:r.result)||void 0===i?void 0:i.info)||void 0===o?void 0:o.uptime)||0,publicKey:(null===(u=null===(l=null===(s=this.serverInfo)||void 0===s?void 0:s.result)||void 0===l?void 0:l.info)||void 0===u?void 0:u.pubkey_node)||"",uri:this.endpoint},ledger:{last:Number(this.serverState.validatedLedgers.split(",").reverse()[0].split("-").reverse()[0]),validated:this.serverState.validatedLedgers,count:""===this.serverState.validatedLedgers?0:a},fee:{last:this.serverState.fee.slice(-1).map((e=>e.value))[0]||null,avg:this.serverState.fee.map((e=>e.value)).reduce(((e,t)=>e+t),0)/this.serverState.fee.length||null,secAgo:Number(new Date)/1e3-this.serverState.fee.slice(-1).map((e=>Number(e.moment)/1e3))[0]||null},reserve:{base:this.serverState.reserveBase,owner:this.serverState.reserveInc},secLastContact:this.lastContact?Number(new Date)/1e3-Number(this.lastContact)/1e3:null}}close(){l.default(!this.closed,"Object already in closed state"),this.eventBus.emit("__WsClient_close")}clusterInfo(){return new Promise(((e,t)=>{if(this.clusterInfo_)return e(this.clusterInfo_);this.on("clusterinfo",(t=>{e(t)}))}))}}n.XrplClient=v},{"./types":1,assert:2,debug:6,events:9,websocket:13}]},{},[]);

@@ -136,3 +136,2 @@ "use strict";

this.emit("online");
this.endpoint = this.endpoints[0];
this.emit("state", this.getState());

@@ -153,3 +152,3 @@ }

*/
if (this.connection.url.match(/^wss:\/\/(xrplcluster\.com|xrpl\.link|xrpl\.ws)/)) {
if (this.endpoint.match(/^wss:\/\/(xrplcluster\.com|xrpl\.link|xrpl\.ws)/)) {
try {

@@ -190,2 +189,4 @@ this.connection.send(JSON.stringify({ __api: "state", origin: "xrpl-client@js/ts" }));

this.emit("offline");
// Was online, so start a new cycle instead of trying the next node
this.endpoint = this.endpoints[0];
}

@@ -644,3 +645,3 @@ this.uplinkReady = false;

publicKey: ((_j = (_h = (_g = this.serverInfo) === null || _g === void 0 ? void 0 : _g.result) === null || _h === void 0 ? void 0 : _h.info) === null || _j === void 0 ? void 0 : _j.pubkey_node) || "",
uri: this.connection.url,
uri: this.endpoint,
},

@@ -647,0 +648,0 @@ ledger: {

{
"name": "xrpl-client",
"version": "1.7.0",
"version": "1.8.0",
"description": "Connect to the XRP Ledger using WebSockets",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

@@ -161,1 +161,10 @@ # XRPL WebSocket Client [![npm version](https://badge.fury.io/js/xrpl-client.svg)](https://www.npmjs.com/xrpl-client) [![GitHub Actions NodeJS status](https://github.com/XRPL-Labs/xrpl-client/workflows/NodeJS/badge.svg?branch=main)](https://github.com/XRPL-Labs/xrpl-client/actions) [![CDNJS Browserified](https://img.shields.io/badge/cdnjs-browserified-blue)](https://cdn.jsdelivr.net/npm/xrpl-client/dist/browser.js) [![CDNJS Browserified Minified](https://img.shields.io/badge/cdnjs-minified-orange)](https://cdn.jsdelivr.net/npm/xrpl-client/dist/browser.min.js)

```
### Development & Debugging
To see all debugging info, run the compiled version with the `DEBUG` env. var:
```bash
tsc
DEBUG=xrplclient* node someFile.js
```

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc