Socket
Socket
Sign inDemoInstall

@walletconnect/jsonrpc-provider

Package Overview
Dependencies
Maintainers
10
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walletconnect/jsonrpc-provider - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13-canary.0

4

dist/cjs/provider.d.ts

@@ -15,4 +15,4 @@ /// <reference types="node" />

removeListener(event: string, listener: any): void;
request<Result = any, Params = any>(request: RequestArguments<Params>, context?: any): Promise<Result>;
protected requestStrict<Result = any, Params = any>(request: JsonRpcRequest<Params>, context?: any): Promise<Result>;
request<Result = any, Params = any>(request: RequestArguments<Params>, context?: any, rejectAfter?: number): Promise<Result>;
protected requestStrict<Result = any, Params = any>(request: JsonRpcRequest<Params>, context?: any, rejectAfter?: number): Promise<Result>;
protected setConnection(connection?: IJsonRpcConnection): IJsonRpcConnection;

@@ -19,0 +19,0 @@ protected onPayload(payload: JsonRpcPayload): void;

@@ -39,8 +39,8 @@ "use strict";

}
request(request, context) {
request(request, context, rejectAfter) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.requestStrict(jsonrpc_utils_1.formatJsonRpcRequest(request.method, request.params || [], jsonrpc_utils_1.getBigIntRpcId().toString()), context);
return this.requestStrict((0, jsonrpc_utils_1.formatJsonRpcRequest)(request.method, request.params || [], request.id || (0, jsonrpc_utils_1.getBigIntRpcId)().toString()), context, rejectAfter);
});
}
requestStrict(request, context) {
requestStrict(request, context, rejectAfter) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {

@@ -56,4 +56,10 @@ return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {

}
let rejectTimeout;
if (rejectAfter) {
rejectTimeout = setTimeout(() => {
reject(new Error(`Request timed out after ${rejectAfter}ms`));
}, rejectAfter);
}
this.events.on(`${request.id}`, response => {
if (jsonrpc_utils_1.isJsonRpcError(response)) {
if ((0, jsonrpc_utils_1.isJsonRpcError)(response)) {
reject(response.error);

@@ -64,2 +70,4 @@ }

}
if (rejectTimeout)
clearTimeout(rejectTimeout);
});

@@ -80,3 +88,3 @@ try {

this.events.emit("payload", payload);
if (jsonrpc_utils_1.isJsonRpcResponse(payload)) {
if ((0, jsonrpc_utils_1.isJsonRpcResponse)(payload)) {
this.events.emit(`${payload.id}`, payload);

@@ -92,2 +100,3 @@ }

onClose(event) {
console.log("onClose event emitted");
if (event && event.code === 3000) {

@@ -94,0 +103,0 @@ this.events.emit("error", new Error(`WebSocket connection closed abnormally with code: ${event.code} ${event.reason ? `(${event.reason})` : ""}`));

@@ -15,4 +15,4 @@ /// <reference types="node" />

removeListener(event: string, listener: any): void;
request<Result = any, Params = any>(request: RequestArguments<Params>, context?: any): Promise<Result>;
protected requestStrict<Result = any, Params = any>(request: JsonRpcRequest<Params>, context?: any): Promise<Result>;
request<Result = any, Params = any>(request: RequestArguments<Params>, context?: any, rejectAfter?: number): Promise<Result>;
protected requestStrict<Result = any, Params = any>(request: JsonRpcRequest<Params>, context?: any, rejectAfter?: number): Promise<Result>;
protected setConnection(connection?: IJsonRpcConnection): IJsonRpcConnection;

@@ -19,0 +19,0 @@ protected onPayload(payload: JsonRpcPayload): void;

@@ -31,6 +31,6 @@ import { EventEmitter } from "events";

}
async request(request, context) {
return this.requestStrict(formatJsonRpcRequest(request.method, request.params || [], getBigIntRpcId().toString()), context);
async request(request, context, rejectAfter) {
return this.requestStrict(formatJsonRpcRequest(request.method, request.params || [], request.id || getBigIntRpcId().toString()), context, rejectAfter);
}
async requestStrict(request, context) {
async requestStrict(request, context, rejectAfter) {
return new Promise(async (resolve, reject) => {

@@ -45,2 +45,8 @@ if (!this.connection.connected) {

}
let rejectTimeout;
if (rejectAfter) {
rejectTimeout = setTimeout(() => {
reject(new Error(`Request timed out after ${rejectAfter}ms`));
}, rejectAfter);
}
this.events.on(`${request.id}`, response => {

@@ -53,2 +59,4 @@ if (isJsonRpcError(response)) {

}
if (rejectTimeout)
clearTimeout(rejectTimeout);
});

@@ -79,2 +87,3 @@ try {

onClose(event) {
console.log("onClose event emitted");
if (event && event.code === 3000) {

@@ -81,0 +90,0 @@ this.events.emit("error", new Error(`WebSocket connection closed abnormally with code: ${event.code} ${event.reason ? `(${event.reason})` : ""}`));

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("JsonRpcProvider",[],t):"object"==typeof exports?exports.JsonRpcProvider=t():e.JsonRpcProvider=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=16)}([function(e,t,n){"use strict";n.d(t,"f",(function(){return r})),n.d(t,"d",(function(){return o})),n.d(t,"e",(function(){return i})),n.d(t,"c",(function(){return u})),n.d(t,"b",(function(){return c})),n.d(t,"h",(function(){return s})),n.d(t,"g",(function(){return f})),n.d(t,"i",(function(){return a})),n.d(t,"j",(function(){return d})),n.d(t,"a",(function(){return l}));const r="PARSE_ERROR",o="INVALID_REQUEST",i="METHOD_NOT_FOUND",u="INVALID_PARAMS",c="INTERNAL_ERROR",s="SERVER_ERROR",f=[-32700,-32600,-32601,-32602,-32603],a=[-32e3,-32099],d={[r]:{code:-32700,message:"Parse error"},[o]:{code:-32600,message:"Invalid Request"},[i]:{code:-32601,message:"Method not found"},[u]:{code:-32602,message:"Invalid params"},[c]:{code:-32603,message:"Internal error"},[s]:{code:-32e3,message:"Server error"}},l=s},function(e,t,n){"use strict";n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return i})),n.d(t,"e",(function(){return u})),n.d(t,"a",(function(){return c})),n.d(t,"b",(function(){return s})),n.d(t,"g",(function(){return f})),n.d(t,"f",(function(){return a}));var r=n(0);function o(e){return e<=r.i[0]&&e>=r.i[1]}function i(e){return r.g.includes(e)}function u(e){return"number"==typeof e}function c(e){return Object.keys(r.j).includes(e)?r.j[e]:r.j[r.a]}function s(e){const t=Object.values(r.j).find(t=>t.code===e);return t||r.j[r.a]}function f(e){if(void 0===e.error.code)return{valid:!1,error:"Missing code for JSON-RPC error"};if(void 0===e.error.message)return{valid:!1,error:"Missing message for JSON-RPC error"};if(!u(e.error.code))return{valid:!1,error:"Invalid error code type for JSON-RPC: "+e.error.code};if(i(e.error.code)){const t=s(e.error.code);if(t.message!==r.j[r.a].message&&e.error.message===t.message)return{valid:!1,error:"Invalid error code message for JSON-RPC: "+e.error.code}}return{valid:!0}}function a(e,t,n){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${n} RPC url at ${t}`):e}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(4);r.__exportStar(n(19),t),r.__exportStar(n(21),t)},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return o})),n.d(t,"__assign",(function(){return i})),n.d(t,"__rest",(function(){return u})),n.d(t,"__decorate",(function(){return c})),n.d(t,"__param",(function(){return s})),n.d(t,"__metadata",(function(){return f})),n.d(t,"__awaiter",(function(){return a})),n.d(t,"__generator",(function(){return d})),n.d(t,"__createBinding",(function(){return l})),n.d(t,"__exportStar",(function(){return p})),n.d(t,"__values",(function(){return v})),n.d(t,"__read",(function(){return h})),n.d(t,"__spread",(function(){return y})),n.d(t,"__spreadArrays",(function(){return R})),n.d(t,"__await",(function(){return _})),n.d(t,"__asyncGenerator",(function(){return m})),n.d(t,"__asyncDelegator",(function(){return E})),n.d(t,"__asyncValues",(function(){return g})),n.d(t,"__makeTemplateObject",(function(){return b})),n.d(t,"__importStar",(function(){return O})),n.d(t,"__importDefault",(function(){return w})),n.d(t,"__classPrivateFieldGet",(function(){return S})),n.d(t,"__classPrivateFieldSet",(function(){return L}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("JsonRpcProvider",[],t):"object"==typeof exports?exports.JsonRpcProvider=t():e.JsonRpcProvider=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=11)}([function(e,t,n){"use strict";n.d(t,"f",(function(){return r})),n.d(t,"d",(function(){return o})),n.d(t,"e",(function(){return i})),n.d(t,"c",(function(){return u})),n.d(t,"b",(function(){return c})),n.d(t,"h",(function(){return s})),n.d(t,"g",(function(){return f})),n.d(t,"i",(function(){return a})),n.d(t,"j",(function(){return d})),n.d(t,"a",(function(){return l}));const r="PARSE_ERROR",o="INVALID_REQUEST",i="METHOD_NOT_FOUND",u="INVALID_PARAMS",c="INTERNAL_ERROR",s="SERVER_ERROR",f=[-32700,-32600,-32601,-32602,-32603],a=[-32e3,-32099],d={[r]:{code:-32700,message:"Parse error"},[o]:{code:-32600,message:"Invalid Request"},[i]:{code:-32601,message:"Method not found"},[u]:{code:-32602,message:"Invalid params"},[c]:{code:-32603,message:"Internal error"},[s]:{code:-32e3,message:"Server error"}},l=s},function(e,t,n){"use strict";n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return i})),n.d(t,"e",(function(){return u})),n.d(t,"a",(function(){return c})),n.d(t,"b",(function(){return s})),n.d(t,"g",(function(){return f})),n.d(t,"f",(function(){return a}));var r=n(0);function o(e){return e<=r.i[0]&&e>=r.i[1]}function i(e){return r.g.includes(e)}function u(e){return"number"==typeof e}function c(e){return Object.keys(r.j).includes(e)?r.j[e]:r.j[r.a]}function s(e){const t=Object.values(r.j).find(t=>t.code===e);return t||r.j[r.a]}function f(e){if(void 0===e.error.code)return{valid:!1,error:"Missing code for JSON-RPC error"};if(void 0===e.error.message)return{valid:!1,error:"Missing message for JSON-RPC error"};if(!u(e.error.code))return{valid:!1,error:"Invalid error code type for JSON-RPC: "+e.error.code};if(i(e.error.code)){const t=s(e.error.code);if(t.message!==r.j[r.a].message&&e.error.message===t.message)return{valid:!1,error:"Invalid error code message for JSON-RPC: "+e.error.code}}return{valid:!0}}function a(e,t,n){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${n} RPC url at ${t}`):e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3);r.__exportStar(n(14),t),r.__exportStar(n(16),t)},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return o})),n.d(t,"__assign",(function(){return i})),n.d(t,"__rest",(function(){return u})),n.d(t,"__decorate",(function(){return c})),n.d(t,"__param",(function(){return s})),n.d(t,"__metadata",(function(){return f})),n.d(t,"__awaiter",(function(){return a})),n.d(t,"__generator",(function(){return d})),n.d(t,"__createBinding",(function(){return l})),n.d(t,"__exportStar",(function(){return p})),n.d(t,"__values",(function(){return v})),n.d(t,"__read",(function(){return h})),n.d(t,"__spread",(function(){return y})),n.d(t,"__spreadArrays",(function(){return m})),n.d(t,"__await",(function(){return _})),n.d(t,"__asyncGenerator",(function(){return R})),n.d(t,"__asyncDelegator",(function(){return g})),n.d(t,"__asyncValues",(function(){return b})),n.d(t,"__makeTemplateObject",(function(){return w})),n.d(t,"__importStar",(function(){return E})),n.d(t,"__importDefault",(function(){return O})),n.d(t,"__classPrivateFieldGet",(function(){return j})),n.d(t,"__classPrivateFieldSet",(function(){return L}));
/*! *****************************************************************************

@@ -16,2 +16,2 @@ Copyright (c) Microsoft Corporation.

***************************************************************************** */
var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function u(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function c(e,t,n,r){var o,i=arguments.length,u=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(u=(i<3?o(u):i>3?o(t,n,u):o(t,n))||u);return i>3&&u&&Object.defineProperty(t,n,u),u}function s(e,t){return function(n,r){t(n,r,e)}}function f(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function a(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{s(r.next(e))}catch(e){i(e)}}function c(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}s((r=r.apply(e,t||[])).next())}))}function d(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}function l(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}function p(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||(t[n]=e[n])}function v(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e}function R(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],u=0,c=i.length;u<c;u++,o++)r[o]=i[u];return r}function _(e){return this instanceof _?(this.v=e,this):new _(e)}function m(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},u("next"),u("throw"),u("return"),r[Symbol.asyncIterator]=function(){return this},r;function u(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||c(e,t)}))})}function c(e,t){try{(n=o[e](t)).value instanceof _?Promise.resolve(n.value.v).then(s,f):a(i[0][2],n)}catch(e){a(i[0][3],e)}var n}function s(e){c("next",e)}function f(e){c("throw",e)}function a(e,t){e(t),i.shift(),i.length&&c(i[0][0],i[0][1])}}function E(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:_(e[r](t)),done:"return"===r}:o?o(t):t}:o}}function g(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=v(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}function b(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function O(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function w(e){return e&&e.__esModule?e:{default:e}}function S(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function L(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonRpcProvider=void 0;const r=n(4),o=n(17),i=n(18);class u extends i.IJsonRpcProvider{constructor(e){super(e),this.events=new o.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}connect(e=this.connection){return r.__awaiter(this,void 0,void 0,(function*(){yield this.open(e)}))}disconnect(){return r.__awaiter(this,void 0,void 0,(function*(){yield this.close()}))}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}request(e,t){return r.__awaiter(this,void 0,void 0,(function*(){return this.requestStrict(i.formatJsonRpcRequest(e.method,e.params||[],i.getBigIntRpcId().toString()),t)}))}requestStrict(e,t){return r.__awaiter(this,void 0,void 0,(function*(){return new Promise((n,o)=>r.__awaiter(this,void 0,void 0,(function*(){if(!this.connection.connected)try{yield this.open()}catch(e){o(e)}this.events.on(""+e.id,e=>{i.isJsonRpcError(e)?o(e.error):n(e.result)});try{yield this.connection.send(e,t)}catch(e){o(e)}})))}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),i.isJsonRpcResponse(e)?this.events.emit(""+e.id,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}open(e=this.connection){return r.__awaiter(this,void 0,void 0,(function*(){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(yield this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),yield this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}))}close(){return r.__awaiter(this,void 0,void 0,(function*(){yield this.connection.close()}))}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}t.JsonRpcProvider=u,t.default=u},function(e,t,n){"use strict";n.r(t),n.d(t,"isNodeJs",(function(){return i}));var r=n(3);for(var o in r)["default","isNodeJs"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(o);const i=r.isNode},function(e,t,n){"use strict";n.d(t,"f",(function(){return i})),n.d(t,"e",(function(){return u})),n.d(t,"c",(function(){return c})),n.d(t,"d",(function(){return s})),n.d(t,"b",(function(){return f})),n.d(t,"a",(function(){return a}));var r=n(1),o=n(0);function i(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function u(e=6){return BigInt(i(e))}function c(e,t,n){return{id:n||i(),jsonrpc:"2.0",method:e,params:t}}function s(e,t){return{id:e,jsonrpc:"2.0",result:t}}function f(e,t,n){return{id:e,jsonrpc:"2.0",error:a(t,n)}}function a(e,t){return void 0===e?Object(r.a)(o.b):("string"==typeof e&&(e=Object.assign(Object.assign({},Object(r.a)(o.h)),{message:e})),void 0!==t&&(e.data=t),Object(r.c)(e.code)&&(e=Object(r.b)(e.code)),e)}},function(e,t,n){"use strict";function r(e){return e.includes("*")?i(e):!/\W/g.test(e)}function o(e){return"*"===e}function i(e){return!!o(e)||!!e.includes("*")&&(2===e.split("*").length&&1===e.split("*").filter(e=>""===e.trim()).length)}function u(e){return!o(e)&&i(e)&&!e.split("*")[0].trim()}function c(e){return!o(e)&&i(e)&&!e.split("*")[1].trim()}n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){return o})),n.d(t,"e",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"d",(function(){return c}))},function(e,t,n){"use strict";n.r(t);var r=n(10);for(var o in r)["default"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(o)},function(e,t,n){"use strict";n.r(t);var r=n(11);for(var o in r)["default"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(2);n.d(t,"IEvents",(function(){return i.a}));var u=n(12);n.d(t,"IJsonRpcConnection",(function(){return u.b})),n.d(t,"IBaseJsonRpcProvider",(function(){return u.a})),n.d(t,"IJsonRpcProvider",(function(){return u.c}));var c=n(13);for(var o in c)["default","IEvents","IJsonRpcConnection","IBaseJsonRpcProvider","IJsonRpcProvider"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(o)},function(e,t){},function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return i})),n.d(t,"c",(function(){return u}));var r=n(2);class o extends r.a{constructor(e){super()}}class i extends r.a{constructor(){super()}}class u extends i{constructor(e){super()}}},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"c",(function(){return i})),n.d(t,"b",(function(){return u}));function r(e,t){const n=function(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return void 0!==n&&new RegExp(t).test(n)}function o(e){return r(e,"^https?:")}function i(e){return r(e,"^wss?:")}function u(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}},function(e,t,n){"use strict";function r(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function o(e){return r(e)&&"method"in e}function i(e){return r(e)&&(u(e)||c(e))}function u(e){return"result"in e}function c(e){return"error"in e}function s(e){return"error"in e&&!1===e.valid}n.d(t,"b",(function(){return r})),n.d(t,"c",(function(){return o})),n.d(t,"d",(function(){return i})),n.d(t,"e",(function(){return u})),n.d(t,"a",(function(){return c})),n.d(t,"f",(function(){return s}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(4),o=r.__importDefault(n(5));r.__exportStar(n(5),t),t.default=o.default},function(e,t,n){"use strict";var r,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var u=Number.isNaN||function(e){return e!=e};function c(){c.init.call(this)}e.exports=c,e.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}R(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&R(e,"error",t,n)}(e,o,{once:!0})}))},c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var s=10;function f(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function a(e){return void 0===e._maxListeners?c.defaultMaxListeners:e._maxListeners}function d(e,t,n,r){var o,i,u,c;if(f(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),u=i[t]),void 0===u)u=i[t]=n,++e._eventsCount;else if("function"==typeof u?u=i[t]=r?[n,u]:[u,n]:r?u.unshift(n):u.push(n),(o=a(e))>0&&u.length>o&&!u.warned){u.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=u.length,c=s,console&&console.warn&&console.warn(c)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=l.bind(r);return o.listener=n,r.wrapFn=o,o}function v(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):y(o,o.length)}function h(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function y(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function R(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||u(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),c.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||u(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},c.prototype.getMaxListeners=function(){return a(this)},c.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var u;if(t.length>0&&(u=t[0]),u instanceof Error)throw u;var c=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw c.context=u,c}var s=o[e];if(void 0===s)return!1;if("function"==typeof s)i(s,this,t);else{var f=s.length,a=y(s,f);for(n=0;n<f;++n)i(a[n],this,t)}return!0},c.prototype.addListener=function(e,t){return d(this,e,t,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(e,t){return d(this,e,t,!0)},c.prototype.once=function(e,t){return f(t),this.on(e,p(this,e,t)),this},c.prototype.prependOnceListener=function(e,t){return f(t),this.prependListener(e,p(this,e,t)),this},c.prototype.removeListener=function(e,t){var n,r,o,i,u;if(f(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){u=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,u||t)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},c.prototype.listeners=function(e){return v(this,e,!0)},c.prototype.rawListeners=function(e){return v(this,e,!1)},c.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},c.prototype.listenerCount=h,c.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){"use strict";n.r(t);var r=n(0);n.d(t,"PARSE_ERROR",(function(){return r.f})),n.d(t,"INVALID_REQUEST",(function(){return r.d})),n.d(t,"METHOD_NOT_FOUND",(function(){return r.e})),n.d(t,"INVALID_PARAMS",(function(){return r.c})),n.d(t,"INTERNAL_ERROR",(function(){return r.b})),n.d(t,"SERVER_ERROR",(function(){return r.h})),n.d(t,"RESERVED_ERROR_CODES",(function(){return r.g})),n.d(t,"SERVER_ERROR_CODE_RANGE",(function(){return r.i})),n.d(t,"STANDARD_ERROR_MAP",(function(){return r.j})),n.d(t,"DEFAULT_ERROR",(function(){return r.a}));var o=n(1);n.d(t,"isServerErrorCode",(function(){return o.d})),n.d(t,"isReservedErrorCode",(function(){return o.c})),n.d(t,"isValidErrorCode",(function(){return o.e})),n.d(t,"getError",(function(){return o.a})),n.d(t,"getErrorByCode",(function(){return o.b})),n.d(t,"validateJsonRpcError",(function(){return o.g})),n.d(t,"parseConnectionError",(function(){return o.f}));var i=n(6);for(var u in i)["default","PARSE_ERROR","INVALID_REQUEST","METHOD_NOT_FOUND","INVALID_PARAMS","INTERNAL_ERROR","SERVER_ERROR","RESERVED_ERROR_CODES","SERVER_ERROR_CODE_RANGE","STANDARD_ERROR_MAP","DEFAULT_ERROR","isServerErrorCode","isReservedErrorCode","isValidErrorCode","getError","getErrorByCode","validateJsonRpcError","parseConnectionError"].indexOf(u)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(u);var c=n(7);n.d(t,"payloadId",(function(){return c.f})),n.d(t,"getBigIntRpcId",(function(){return c.e})),n.d(t,"formatJsonRpcRequest",(function(){return c.c})),n.d(t,"formatJsonRpcResult",(function(){return c.d})),n.d(t,"formatJsonRpcError",(function(){return c.b})),n.d(t,"formatErrorMessage",(function(){return c.a}));var s=n(8);n.d(t,"isValidRoute",(function(){return s.c})),n.d(t,"isValidDefaultRoute",(function(){return s.a})),n.d(t,"isValidWildcardRoute",(function(){return s.e})),n.d(t,"isValidLeadingWildcardRoute",(function(){return s.b})),n.d(t,"isValidTrailingWildcardRoute",(function(){return s.d}));var f=n(9);for(var u in f)["default","PARSE_ERROR","INVALID_REQUEST","METHOD_NOT_FOUND","INVALID_PARAMS","INTERNAL_ERROR","SERVER_ERROR","RESERVED_ERROR_CODES","SERVER_ERROR_CODE_RANGE","STANDARD_ERROR_MAP","DEFAULT_ERROR","isServerErrorCode","isReservedErrorCode","isValidErrorCode","getError","getErrorByCode","validateJsonRpcError","parseConnectionError","payloadId","getBigIntRpcId","formatJsonRpcRequest","formatJsonRpcResult","formatJsonRpcError","formatErrorMessage","isValidRoute","isValidDefaultRoute","isValidWildcardRoute","isValidLeadingWildcardRoute","isValidTrailingWildcardRoute"].indexOf(u)<0&&function(e){n.d(t,e,(function(){return f[e]}))}(u);var a=n(14);n.d(t,"isHttpUrl",(function(){return a.a})),n.d(t,"isWsUrl",(function(){return a.c})),n.d(t,"isLocalhostUrl",(function(){return a.b}));var d=n(15);n.d(t,"isJsonRpcPayload",(function(){return d.b})),n.d(t,"isJsonRpcRequest",(function(){return d.c})),n.d(t,"isJsonRpcResponse",(function(){return d.d})),n.d(t,"isJsonRpcResult",(function(){return d.e})),n.d(t,"isJsonRpcError",(function(){return d.a})),n.d(t,"isJsonRpcValidationInvalid",(function(){return d.f}))},function(e,t,n){"use strict";(function(e){function n(){return(null==e?void 0:e.crypto)||(null==e?void 0:e.msCrypto)||{}}function r(){const e=n();return e.subtle||e.webkitSubtle}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowserCryptoAvailable=t.getSubtleCrypto=t.getBrowerCrypto=void 0,t.getBrowerCrypto=n,t.getSubtleCrypto=r,t.isBrowserCryptoAvailable=function(){return!!n()&&!!r()}}).call(this,n(20))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";(function(e){function n(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product}function r(){return void 0!==e&&void 0!==e.versions&&void 0!==e.versions.node}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=t.isNode=t.isReactNative=void 0,t.isReactNative=n,t.isNode=r,t.isBrowser=function(){return!n()&&!r()}}).call(this,n(22))},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}}();var s,f=[],a=!1,d=-1;function l(){a&&s&&(a=!1,s.length?f=s.concat(f):d=-1,f.length&&p())}function p(){if(!a){var e=c(l);a=!0;for(var t=f.length;t;){for(s=f,f=[];++d<t;)s&&s[d].run();d=-1,t=f.length}s=null,a=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function h(){}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];f.push(new v(e,t)),1!==f.length||a||c(p)},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=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,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}}])}));
var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function u(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function c(e,t,n,r){var o,i=arguments.length,u=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(u=(i<3?o(u):i>3?o(t,n,u):o(t,n))||u);return i>3&&u&&Object.defineProperty(t,n,u),u}function s(e,t){return function(n,r){t(n,r,e)}}function f(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function a(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{s(r.next(e))}catch(e){i(e)}}function c(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}s((r=r.apply(e,t||[])).next())}))}function d(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}function l(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}function p(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||(t[n]=e[n])}function v(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e}function m(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],u=0,c=i.length;u<c;u++,o++)r[o]=i[u];return r}function _(e){return this instanceof _?(this.v=e,this):new _(e)}function R(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},u("next"),u("throw"),u("return"),r[Symbol.asyncIterator]=function(){return this},r;function u(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||c(e,t)}))})}function c(e,t){try{(n=o[e](t)).value instanceof _?Promise.resolve(n.value.v).then(s,f):a(i[0][2],n)}catch(e){a(i[0][3],e)}var n}function s(e){c("next",e)}function f(e){c("throw",e)}function a(e,t){e(t),i.shift(),i.length&&c(i[0][0],i[0][1])}}function g(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:_(e[r](t)),done:"return"===r}:o?o(t):t}:o}}function b(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=v(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}function w(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function E(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function O(e){return e&&e.__esModule?e:{default:e}}function j(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function L(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonRpcProvider=void 0;const r=n(3),o=n(12),i=n(13);class u extends i.IJsonRpcProvider{constructor(e){super(e),this.events=new o.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}connect(e=this.connection){return r.__awaiter(this,void 0,void 0,(function*(){yield this.open(e)}))}disconnect(){return r.__awaiter(this,void 0,void 0,(function*(){yield this.close()}))}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}request(e,t,n){return r.__awaiter(this,void 0,void 0,(function*(){return this.requestStrict((0,i.formatJsonRpcRequest)(e.method,e.params||[],e.id||(0,i.getBigIntRpcId)().toString()),t,n)}))}requestStrict(e,t,n){return r.__awaiter(this,void 0,void 0,(function*(){return new Promise((o,u)=>r.__awaiter(this,void 0,void 0,(function*(){if(!this.connection.connected)try{yield this.open()}catch(e){u(e)}let r;n&&(r=setTimeout(()=>{u(new Error(`Request timed out after ${n}ms`))},n)),this.events.on(""+e.id,e=>{(0,i.isJsonRpcError)(e)?u(e.error):o(e.result),r&&clearTimeout(r)});try{yield this.connection.send(e,t)}catch(e){u(e)}})))}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),(0,i.isJsonRpcResponse)(e)?this.events.emit(""+e.id,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){console.log("onClose event emitted"),e&&3e3===e.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}open(e=this.connection){return r.__awaiter(this,void 0,void 0,(function*(){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(yield this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),yield this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}))}close(){return r.__awaiter(this,void 0,void 0,(function*(){yield this.connection.close()}))}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}t.JsonRpcProvider=u,t.default=u},function(e,t,n){"use strict";n.r(t),n.d(t,"isNodeJs",(function(){return i}));var r=n(2);for(var o in r)["default","isNodeJs"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(o);const i=r.isNode},function(e,t,n){"use strict";n.d(t,"f",(function(){return i})),n.d(t,"e",(function(){return u})),n.d(t,"c",(function(){return c})),n.d(t,"d",(function(){return s})),n.d(t,"b",(function(){return f})),n.d(t,"a",(function(){return a}));var r=n(1),o=n(0);function i(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function u(e=6){return BigInt(i(e))}function c(e,t,n){return{id:n||i(),jsonrpc:"2.0",method:e,params:t}}function s(e,t){return{id:e,jsonrpc:"2.0",result:t}}function f(e,t,n){return{id:e,jsonrpc:"2.0",error:a(t,n)}}function a(e,t){return void 0===e?Object(r.a)(o.b):("string"==typeof e&&(e=Object.assign(Object.assign({},Object(r.a)(o.h)),{message:e})),void 0!==t&&(e.data=t),Object(r.c)(e.code)&&(e=Object(r.b)(e.code)),e)}},function(e,t,n){"use strict";function r(e){return e.includes("*")?i(e):!/\W/g.test(e)}function o(e){return"*"===e}function i(e){return!!o(e)||!!e.includes("*")&&(2===e.split("*").length&&1===e.split("*").filter(e=>""===e.trim()).length)}function u(e){return!o(e)&&i(e)&&!e.split("*")[0].trim()}function c(e){return!o(e)&&i(e)&&!e.split("*")[1].trim()}n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){return o})),n.d(t,"e",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"d",(function(){return c}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"c",(function(){return i})),n.d(t,"b",(function(){return u}));function r(e,t){const n=function(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return void 0!==n&&new RegExp(t).test(n)}function o(e){return r(e,"^https?:")}function i(e){return r(e,"^wss?:")}function u(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}},function(e,t,n){"use strict";function r(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function o(e){return r(e)&&"method"in e}function i(e){return r(e)&&(u(e)||c(e))}function u(e){return"result"in e}function c(e){return"error"in e}function s(e){return"error"in e&&!1===e.valid}n.d(t,"b",(function(){return r})),n.d(t,"c",(function(){return o})),n.d(t,"d",(function(){return i})),n.d(t,"e",(function(){return u})),n.d(t,"a",(function(){return c})),n.d(t,"f",(function(){return s}))},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return i})),n.d(t,"d",(function(){return u}));class r{}class o extends r{constructor(e){super()}}class i extends r{constructor(){super()}}class u extends i{constructor(e){super()}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(3),o=r.__importDefault(n(4));r.__exportStar(n(4),t),t.default=o.default},function(e,t,n){"use strict";var r,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var u=Number.isNaN||function(e){return e!=e};function c(){c.init.call(this)}e.exports=c,e.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}m(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&m(e,"error",t,n)}(e,o,{once:!0})}))},c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var s=10;function f(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function a(e){return void 0===e._maxListeners?c.defaultMaxListeners:e._maxListeners}function d(e,t,n,r){var o,i,u,c;if(f(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),u=i[t]),void 0===u)u=i[t]=n,++e._eventsCount;else if("function"==typeof u?u=i[t]=r?[n,u]:[u,n]:r?u.unshift(n):u.push(n),(o=a(e))>0&&u.length>o&&!u.warned){u.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=u.length,c=s,console&&console.warn&&console.warn(c)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=l.bind(r);return o.listener=n,r.wrapFn=o,o}function v(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):y(o,o.length)}function h(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function y(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function m(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||u(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),c.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||u(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},c.prototype.getMaxListeners=function(){return a(this)},c.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var u;if(t.length>0&&(u=t[0]),u instanceof Error)throw u;var c=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw c.context=u,c}var s=o[e];if(void 0===s)return!1;if("function"==typeof s)i(s,this,t);else{var f=s.length,a=y(s,f);for(n=0;n<f;++n)i(a[n],this,t)}return!0},c.prototype.addListener=function(e,t){return d(this,e,t,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(e,t){return d(this,e,t,!0)},c.prototype.once=function(e,t){return f(t),this.on(e,p(this,e,t)),this},c.prototype.prependOnceListener=function(e,t){return f(t),this.prependListener(e,p(this,e,t)),this},c.prototype.removeListener=function(e,t){var n,r,o,i,u;if(f(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){u=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,u||t)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},c.prototype.listeners=function(e){return v(this,e,!0)},c.prototype.rawListeners=function(e){return v(this,e,!1)},c.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},c.prototype.listenerCount=h,c.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){"use strict";n.r(t);var r=n(0);n.d(t,"PARSE_ERROR",(function(){return r.f})),n.d(t,"INVALID_REQUEST",(function(){return r.d})),n.d(t,"METHOD_NOT_FOUND",(function(){return r.e})),n.d(t,"INVALID_PARAMS",(function(){return r.c})),n.d(t,"INTERNAL_ERROR",(function(){return r.b})),n.d(t,"SERVER_ERROR",(function(){return r.h})),n.d(t,"RESERVED_ERROR_CODES",(function(){return r.g})),n.d(t,"SERVER_ERROR_CODE_RANGE",(function(){return r.i})),n.d(t,"STANDARD_ERROR_MAP",(function(){return r.j})),n.d(t,"DEFAULT_ERROR",(function(){return r.a}));var o=n(1);n.d(t,"isServerErrorCode",(function(){return o.d})),n.d(t,"isReservedErrorCode",(function(){return o.c})),n.d(t,"isValidErrorCode",(function(){return o.e})),n.d(t,"getError",(function(){return o.a})),n.d(t,"getErrorByCode",(function(){return o.b})),n.d(t,"validateJsonRpcError",(function(){return o.g})),n.d(t,"parseConnectionError",(function(){return o.f}));var i=n(5);for(var u in i)["default","PARSE_ERROR","INVALID_REQUEST","METHOD_NOT_FOUND","INVALID_PARAMS","INTERNAL_ERROR","SERVER_ERROR","RESERVED_ERROR_CODES","SERVER_ERROR_CODE_RANGE","STANDARD_ERROR_MAP","DEFAULT_ERROR","isServerErrorCode","isReservedErrorCode","isValidErrorCode","getError","getErrorByCode","validateJsonRpcError","parseConnectionError"].indexOf(u)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(u);var c=n(6);n.d(t,"payloadId",(function(){return c.f})),n.d(t,"getBigIntRpcId",(function(){return c.e})),n.d(t,"formatJsonRpcRequest",(function(){return c.c})),n.d(t,"formatJsonRpcResult",(function(){return c.d})),n.d(t,"formatJsonRpcError",(function(){return c.b})),n.d(t,"formatErrorMessage",(function(){return c.a}));var s=n(7);n.d(t,"isValidRoute",(function(){return s.c})),n.d(t,"isValidDefaultRoute",(function(){return s.a})),n.d(t,"isValidWildcardRoute",(function(){return s.e})),n.d(t,"isValidLeadingWildcardRoute",(function(){return s.b})),n.d(t,"isValidTrailingWildcardRoute",(function(){return s.d}));var f=n(10);n.d(t,"IEvents",(function(){return f.b})),n.d(t,"IJsonRpcConnection",(function(){return f.c})),n.d(t,"IBaseJsonRpcProvider",(function(){return f.a})),n.d(t,"IJsonRpcProvider",(function(){return f.d}));var a=n(8);n.d(t,"isHttpUrl",(function(){return a.a})),n.d(t,"isWsUrl",(function(){return a.c})),n.d(t,"isLocalhostUrl",(function(){return a.b}));var d=n(9);n.d(t,"isJsonRpcPayload",(function(){return d.b})),n.d(t,"isJsonRpcRequest",(function(){return d.c})),n.d(t,"isJsonRpcResponse",(function(){return d.d})),n.d(t,"isJsonRpcResult",(function(){return d.e})),n.d(t,"isJsonRpcError",(function(){return d.a})),n.d(t,"isJsonRpcValidationInvalid",(function(){return d.f}))},function(e,t,n){"use strict";(function(e){function n(){return(null==e?void 0:e.crypto)||(null==e?void 0:e.msCrypto)||{}}function r(){const e=n();return e.subtle||e.webkitSubtle}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowserCryptoAvailable=t.getSubtleCrypto=t.getBrowerCrypto=void 0,t.getBrowerCrypto=n,t.getSubtleCrypto=r,t.isBrowserCryptoAvailable=function(){return!!n()&&!!r()}}).call(this,n(15))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";(function(e){function n(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product}function r(){return void 0!==e&&void 0!==e.versions&&void 0!==e.versions.node}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=t.isNode=t.isReactNative=void 0,t.isReactNative=n,t.isNode=r,t.isBrowser=function(){return!n()&&!r()}}).call(this,n(17))},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}}();var s,f=[],a=!1,d=-1;function l(){a&&s&&(a=!1,s.length?f=s.concat(f):d=-1,f.length&&p())}function p(){if(!a){var e=c(l);a=!0;for(var t=f.length;t;){for(s=f,f=[];++d<t;)s&&s[d].run();d=-1,t=f.length}s=null,a=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function h(){}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];f.push(new v(e,t)),1!==f.length||a||c(p)},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=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,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}}])}));
{
"name": "@walletconnect/jsonrpc-provider",
"description": "Provider for JSON-RPC",
"version": "1.0.12",
"version": "1.0.13-canary.0",
"author": "WalletConnect, Inc. <walletconnect.com>",

@@ -48,3 +48,3 @@ "license": "MIT",

"dependencies": {
"@walletconnect/jsonrpc-utils": "^1.0.7",
"@walletconnect/jsonrpc-utils": "^1.0.8",
"@walletconnect/safe-json": "^1.0.2",

@@ -87,3 +87,3 @@ "tslib": "1.14.1"

"prettier": "^1.19.1",
"typescript": "^3.7.5",
"typescript": "^4.9.5",
"webpack": "^4.41.6",

@@ -90,0 +90,0 @@ "webpack-cli": "^3.3.11"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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