@walletconnect/ethereum-provider 2.0.0-beta.21 → 2.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -607,8 +607,8 @@
|
|
|
607
607
|
"affectsGlobalScope": false
|
|
608
608
|
},
|
|
609
609
|
"../node_modules/@walletconnect/types/dist/cjs/sequence.d.ts": {
|
|
610
|
-
"version": "
|
|
611
|
-
"signature": "
|
|
610
|
+
"version": "eef9ba64a7b42bab0d6a8531f5cc997e3eacb47732b0f365140be6a0d2284138",
|
|
611
|
+
"signature": "eef9ba64a7b42bab0d6a8531f5cc997e3eacb47732b0f365140be6a0d2284138",
|
|
612
612
|
"affectsGlobalScope": false
|
|
613
613
|
},
|
|
614
614
|
"../node_modules/@walletconnect/types/dist/cjs/session.d.ts": {
|
|
@@ -607,8 +607,8 @@
|
|
|
607
607
|
"affectsGlobalScope": false
|
|
608
608
|
},
|
|
609
609
|
"../node_modules/@walletconnect/types/dist/cjs/sequence.d.ts": {
|
|
610
|
-
"version": "
|
|
611
|
-
"signature": "
|
|
610
|
+
"version": "eef9ba64a7b42bab0d6a8531f5cc997e3eacb47732b0f365140be6a0d2284138",
|
|
611
|
+
"signature": "eef9ba64a7b42bab0d6a8531f5cc997e3eacb47732b0f365140be6a0d2284138",
|
|
612
612
|
"affectsGlobalScope": false
|
|
613
613
|
},
|
|
614
614
|
"../node_modules/@walletconnect/types/dist/cjs/session.d.ts": {
|
package/dist/umd/index.min.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WalletConnectEthereumProvider",[],t):"object"==typeof exports?exports.WalletConnectEthereumProvider=t():e.WalletConnectEthereumProvider=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.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 i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));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=76)}([function(e,t,n){"use strict";n(9);var r=n(16);n.d(t,"parseConnectionError",(function(){return r.d}));var i=n(31);n.o(i,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return i.IJsonRpcProvider})),n.o(i,"formatJsonRpcError")&&n.d(t,"formatJsonRpcError",(function(){return i.formatJsonRpcError})),n.o(i,"formatJsonRpcRequest")&&n.d(t,"formatJsonRpcRequest",(function(){return i.formatJsonRpcRequest})),n.o(i,"formatJsonRpcResult")&&n.d(t,"formatJsonRpcResult",(function(){return i.formatJsonRpcResult})),n.o(i,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return i.isHttpUrl})),n.o(i,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return i.isJsonRpcError})),n.o(i,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return i.isJsonRpcRequest})),n.o(i,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return i.isJsonRpcResponse})),n.o(i,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return i.isLocalhostUrl})),n.o(i,"isReactNative")&&n.d(t,"isReactNative",(function(){return i.isReactNative})),n.o(i,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return i.isWsUrl}));var o=n(33);n.d(t,"formatJsonRpcError",(function(){return o.a})),n.d(t,"formatJsonRpcRequest",(function(){return o.b})),n.d(t,"formatJsonRpcResult",(function(){return o.c}));n(34);var s=n(35);n.o(s,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return s.IJsonRpcProvider})),n.o(s,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return s.isHttpUrl})),n.o(s,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return s.isJsonRpcError})),n.o(s,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return s.isJsonRpcRequest})),n.o(s,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return s.isJsonRpcResponse})),n.o(s,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return s.isLocalhostUrl})),n.o(s,"isReactNative")&&n.d(t,"isReactNative",(function(){return s.isReactNative})),n.o(s,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return s.isWsUrl}));var a=n(39);n.d(t,"isHttpUrl",(function(){return a.a})),n.d(t,"isLocalhostUrl",(function(){return a.b})),n.d(t,"isWsUrl",(function(){return a.c}));var c=n(40);n.d(t,"isJsonRpcError",(function(){return c.a})),n.d(t,"isJsonRpcRequest",(function(){return c.b})),n.d(t,"isJsonRpcResponse",(function(){return c.c}))},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||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(69),t),i(n(101),t)},function(e,t,n){"use strict";(function(e){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.removeHexLeadingZeros=t.sanitizeHex=t.addHexPrefix=t.removeHexPrefix=t.padRight=t.padLeft=t.sanitizeBytes=t.swapHex=t.swapBytes=t.splitBytes=t.calcByteLength=t.trimRight=t.trimLeft=t.concatArrays=t.concatBuffers=t.getEncoding=t.getType=t.isArrayBuffer=t.isTypedArray=t.isBuffer=t.isHexString=t.isBinaryString=t.binaryToNumber=t.binaryToUtf8=t.binaryToHex=t.binaryToArray=t.binaryToBuffer=t.numberToBinary=t.numberToUtf8=t.numberToHex=t.numberToArray=t.numberToBuffer=t.utf8ToBinary=t.utf8ToNumber=t.utf8ToHex=t.utf8ToArray=t.utf8ToBuffer=t.hexToBinary=t.hexToNumber=t.hexToUtf8=t.hexToArray=t.hexToBuffer=t.arrayToBinary=t.arrayToNumber=t.arrayToUtf8=t.arrayToHex=t.arrayToBuffer=t.bufferToBinary=t.bufferToNumber=t.bufferToUtf8=t.bufferToHex=t.bufferToArray=void 0;const i=r(n(68)),o=r(n(89));function s(e){return new Uint8Array(e)}function a(e,t=!1){const n=e.toString("hex");return t?j(n):n}function c(e){return e.toString("utf8")}function u(e){return e.readUIntBE(0,e.length)}function h(e){return o.default(e)}function l(e,t=!1){return a(h(e),t)}function d(e){return c(h(e))}function f(e){return u(h(e))}function p(e){return Array.from(e).map(b).join("")}function g(t){return e.from(L(t),"hex")}function y(e){return s(g(e))}function v(e){return p(y(e))}function m(t){return e.from(t,"utf8")}function E(e){return s(m(e))}function b(e){return C((e>>>0).toString(2))}function _(e){return h(w(e))}function w(e){return new Uint8Array(P(e).map(e=>parseInt(e,2)))}function R(e,t){return l(w(e),t)}function O(e){return!("string"!=typeof e||!new RegExp(/^[01]+$/).test(e))&&e.length%8==0}function T(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(!t||e.length===2+2*t)}function S(t){return e.isBuffer(t)}function I(e){return i.default.strict(e)&&!S(e)}function N(e){return!I(e)&&!S(e)&&void 0!==e.byteLength}function A(e,t=8){const n=e%t;return n?(e-n)/t*t+t:e}function P(e,t=8){const n=C(e).match(new RegExp(`.{${t}}`,"gi"));return Array.from(n||[])}function U(e){return P(e).map(x).join("")}function C(e,t=8,n="0"){return D(e,A(e.length,t),n)}function D(e,t,n="0"){return q(e,t,!0,n)}function L(e){return e.replace(/^0x/,"")}function j(e){return e.startsWith("0x")?e:"0x"+e}function x(e){return e.split("").reverse().join("")}function q(e,t,n,r="0"){const i=t-e.length;let o=e;if(i>0){const t=r.repeat(i);o=n?t+e:e+t}return o}t.bufferToArray=s,t.bufferToHex=a,t.bufferToUtf8=c,t.bufferToNumber=u,t.bufferToBinary=function(e){return p(s(e))},t.arrayToBuffer=h,t.arrayToHex=l,t.arrayToUtf8=d,t.arrayToNumber=f,t.arrayToBinary=p,t.hexToBuffer=g,t.hexToArray=y,t.hexToUtf8=function(e){return c(g(e))},t.hexToNumber=function(e){return f(y(e))},t.hexToBinary=v,t.utf8ToBuffer=m,t.utf8ToArray=E,t.utf8ToHex=function(e,t=!1){return a(m(e),t)},t.utf8ToNumber=function(e){const t=parseInt(e,10);return function(e,t){if(!e)throw new Error(t)}(!function(e){return void 0===e}(t),"Number can only safely store up to 53 bits"),t},t.utf8ToBinary=function(e){return p(E(e))},t.numberToBuffer=function(e){return _(b(e))},t.numberToArray=function(e){return w(b(e))},t.numberToHex=function(e,t){return R(b(e),t)},t.numberToUtf8=function(e){return""+e},t.numberToBinary=b,t.binaryToBuffer=_,t.binaryToArray=w,t.binaryToHex=R,t.binaryToUtf8=function(e){return d(w(e))},t.binaryToNumber=function(e){return f(w(e))},t.isBinaryString=O,t.isHexString=T,t.isBuffer=S,t.isTypedArray=I,t.isArrayBuffer=N,t.getType=function(e){return S(e)?"buffer":I(e)?"typed-array":N(e)?"array-buffer":Array.isArray(e)?"array":typeof e},t.getEncoding=function(e){return O(e)?"binary":T(e)?"hex":"utf8"},t.concatBuffers=function(...t){return e.concat(t)},t.concatArrays=function(...e){let t=[];return e.forEach(e=>t=t.concat(Array.from(e))),new Uint8Array([...t])},t.trimLeft=function(e,t){const n=e.length-t;return n>0&&(e=e.slice(n)),e},t.trimRight=function(e,t){return e.slice(0,t)},t.calcByteLength=A,t.splitBytes=P,t.swapBytes=U,t.swapHex=function(e){return R(U(v(e)))},t.sanitizeBytes=C,t.padLeft=D,t.padRight=function(e,t,n="0"){return q(e,t,!1,n)},t.removeHexPrefix=L,t.addHexPrefix=j,t.sanitizeHex=function(e){return(e=C(e=L(e),2))&&(e=j(e)),e},t.removeHexLeadingZeros=function(e){const t=e.startsWith("0x");return e=(e=L(e)).startsWith("0")?e.substring(1):e,t?j(e):e}}).call(this,n(67).Buffer)},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}v(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&v(e,"error",t,n)}(e,i,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function l(e,t,n,r){var i,o,s,a;if(u(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=h(e))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return e}function d(){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 f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=d.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]: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}(i):y(i,i.length)}function g(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 v(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 i(o){r.once&&e.removeEventListener(t,i),n(o)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),a.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},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(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},a.prototype.getMaxListeners=function(){return h(this)},a.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var u=c.length,h=y(c,u);for(n=0;n<u;++n)o(h[n],this,t)}return!0},a.prototype.addListener=function(e,t){return l(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return l(this,e,t,!0)},a.prototype.once=function(e,t){return u(t),this.on(e,f(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,f(this,e,t)),this},a.prototype.removeListener=function(e,t){var n,r,i,o,s;if(u(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(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},a.prototype.off=a.prototype.removeListener,a.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 i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);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},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"h",(function(){return s})),n.d(t,"a",(function(){return a})),n.d(t,"g",(function(){return c})),n.d(t,"f",(function(){return u})),n.d(t,"n",(function(){return h})),n.d(t,"o",(function(){return l})),n.d(t,"j",(function(){return d})),n.d(t,"i",(function(){return f})),n.d(t,"m",(function(){return p})),n.d(t,"e",(function(){return g})),n.d(t,"k",(function(){return r})),n.d(t,"l",(function(){return i})),n.d(t,"d",(function(){return y})),n.d(t,"c",(function(){return v})),n.d(t,"p",(function(){return m})),n.d(t,"q",(function(){return E}));const r=0,i=512,o=256,s=256,a="AES-CBC",c="SHA-"+o,u="HMAC",h="SHA-256",l="SHA-512",d=32,f=16,p=32,g="Bad MAC",y="encrypt",v="decrypt",m="sign",E="verify"},function(e,t,n){"use strict";var r=n(36);n.o(r,"IEvents")&&n.d(t,"IEvents",(function(){return r.IEvents})),n.o(r,"IJsonRpcConnection")&&n.d(t,"IJsonRpcConnection",(function(){return r.IJsonRpcConnection})),n.o(r,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return r.IJsonRpcProvider})),n.o(r,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return r.isHttpUrl})),n.o(r,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return r.isJsonRpcError})),n.o(r,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return r.isJsonRpcRequest})),n.o(r,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return r.isJsonRpcResponse})),n.o(r,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return r.isLocalhostUrl})),n.o(r,"isReactNative")&&n.d(t,"isReactNative",(function(){return r.isReactNative})),n.o(r,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return r.isWsUrl}));var i=n(23);n.d(t,"IEvents",(function(){return i.a}));var o=n(37);n.d(t,"IJsonRpcConnection",(function(){return o.a})),n.d(t,"IJsonRpcProvider",(function(){return o.b}));var s=n(38);n.o(s,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return s.isHttpUrl})),n.o(s,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return s.isJsonRpcError})),n.o(s,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return s.isJsonRpcRequest})),n.o(s,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return s.isJsonRpcResponse})),n.o(s,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return s.isLocalhostUrl})),n.o(s,"isReactNative")&&n.d(t,"isReactNative",(function(){return s.isReactNative})),n.o(s,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return s.isWsUrl}))},function(e,t,n){"use strict";var r=n(42);n.d(t,"IClient",(function(){return r.a}));n(43),n(44);var i=n(45);n.d(t,"IEngine",(function(){return i.a}));var o=n(46);n.d(t,"IExpirer",(function(){return o.a}));var s=n(47);n.d(t,"IHeartBeat",(function(){return s.a}));var a=n(48);n.d(t,"IJsonRpcHistory",(function(){return a.a}));var c=n(49);n.o(c,"IPairing")&&n.d(t,"IPairing",(function(){return c.IPairing})),n.o(c,"IRelayer")&&n.d(t,"IRelayer",(function(){return c.IRelayer})),n.o(c,"ISession")&&n.d(t,"ISession",(function(){return c.ISession})),n.o(c,"IStore")&&n.d(t,"IStore",(function(){return c.IStore})),n.o(c,"ISubscriber")&&n.d(t,"ISubscriber",(function(){return c.ISubscriber}));var u=n(50);n.o(u,"IPairing")&&n.d(t,"IPairing",(function(){return u.IPairing})),n.o(u,"IRelayer")&&n.d(t,"IRelayer",(function(){return u.IRelayer})),n.o(u,"ISession")&&n.d(t,"ISession",(function(){return u.ISession})),n.o(u,"IStore")&&n.d(t,"IStore",(function(){return u.IStore})),n.o(u,"ISubscriber")&&n.d(t,"ISubscriber",(function(){return u.ISubscriber}));var h=n(51);n.d(t,"IPairing",(function(){return h.a}));n(52);var l=n(53);n.d(t,"IRelayer",(function(){return l.a}));n(18);var d=n(54);n.d(t,"ISession",(function(){return d.a}));var f=n(55);n.d(t,"IStore",(function(){return f.a}));n(56);var p=n(57);n.d(t,"ISubscriber",(function(){return p.a}))},function(e,t,n){"use strict";var r=n(58);n.d(t,"randomBytes",(function(){return r.a}));var i=n(59);n.d(t,"aesCbcDecrypt",(function(){return i.a})),n.d(t,"aesCbcEncrypt",(function(){return i.b}));var o=n(60);n.d(t,"hmacSha256Sign",(function(){return o.a})),n.d(t,"hmacSha256Verify",(function(){return o.b}));var s=n(65);n.d(t,"sha256",(function(){return s.a})),n.d(t,"sha512",(function(){return s.b}));var a=n(24);n.o(a,"ERROR_BAD_MAC")&&n.d(t,"ERROR_BAD_MAC",(function(){return a.ERROR_BAD_MAC})),n.o(a,"IV_LENGTH")&&n.d(t,"IV_LENGTH",(function(){return a.IV_LENGTH})),n.o(a,"KEY_LENGTH")&&n.d(t,"KEY_LENGTH",(function(){return a.KEY_LENGTH})),n.o(a,"LENGTH_0")&&n.d(t,"LENGTH_0",(function(){return a.LENGTH_0})),n.o(a,"MAC_LENGTH")&&n.d(t,"MAC_LENGTH",(function(){return a.MAC_LENGTH})),n.o(a,"assert")&&n.d(t,"assert",(function(){return a.assert})),n.o(a,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return a.decryptWithSharedKey})),n.o(a,"derive")&&n.d(t,"derive",(function(){return a.derive})),n.o(a,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return a.encryptWithSharedKey})),n.o(a,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return a.generateKeyPair}));var c=n(4);n.d(t,"ERROR_BAD_MAC",(function(){return c.e})),n.d(t,"IV_LENGTH",(function(){return c.i})),n.d(t,"KEY_LENGTH",(function(){return c.j})),n.d(t,"LENGTH_0",(function(){return c.k})),n.d(t,"MAC_LENGTH",(function(){return c.m}))},function(e,t,n){"use strict";function r(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return JSON.parse(e)}catch(t){return e}}function i(e){return"string"==typeof e?e:JSON.stringify(e)}n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"c",(function(){return i})),n.d(t,"b",(function(){return o})),n.d(t,"d",(function(){return s})),n.d(t,"e",(function(){return a}));const r="INTERNAL_ERROR",i="SERVER_ERROR",o=[-32700,-32600,-32601,-32602,-32603],s=[-32e3,-32099],a={PARSE_ERROR:{code:-32700,message:"Parse error"},INVALID_REQUEST:{code:-32600,message:"Invalid Request"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params"},[r]:{code:-32603,message:"Internal error"},[i]:{code:-32e3,message:"Server error"}}},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||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(78),t),i(n(79),t)},function(e,t,n){"use strict";function r(e,t,n="string"){if(!e[t]||typeof e[t]!==n)throw new Error(`Missing or invalid "${t}" param`)}function i(e,t){return Array.isArray(e)?e.length===t:Object.keys(e).length===t}function o(e,t,n="_"){const r=e.split(n);return r[r.length-1].trim().toLowerCase()===t.trim().toLowerCase()}n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return o}))},function(e,t,n){"use strict";(function(e){n.d(t,"h",(function(){return p})),n.d(t,"e",(function(){return g})),n.d(t,"d",(function(){return v})),n.d(t,"f",(function(){return m})),n.d(t,"i",(function(){return E})),n.d(t,"k",(function(){return b})),n.d(t,"j",(function(){return _})),n.d(t,"l",(function(){return w})),n.d(t,"c",(function(){return R})),n.d(t,"b",(function(){return O})),n.d(t,"m",(function(){return T})),n.d(t,"g",(function(){return S})),n.d(t,"a",(function(){return I}));var r=n(73),i=n.n(r),o=n(20),s=n(74),a=n(21);const c="react-native",u="node",h="browser",l="unknown";function d(){return void 0!==e&&void 0!==e.versions&&void 0!==e.versions.node}function f(){return!Object(a.getDocument)()&&Object(a.getNavigator)()&&"ReactNative"===navigator.product?c:d()?u:!d()&&Object(a.getNavigator)()?h:l}function p(){return Object(s.getWindowMetadata)()||void 0}function g(e,t,n,r){const i=n.split("?"),s=function(e,t){var n;const r=f(),i={protocol:e,version:t,env:r};return"browser"===r&&(i.host=(null===(n=Object(a.getLocation)())||void 0===n?void 0:n.host)||""),i}(e,t),c=r?Object.assign(Object.assign({},s),{projectId:r}):s,u=function(e,t){let n=o.parse(e);return n=Object.assign(Object.assign({},n),t),e=o.stringify(n)}(i[1]||"",c);return i[0]+"?"+u}function y(e,t=2){return function(e,t=2){return e.slice(Math.max(e.length-t,0))}(e.split("/"),t)}function v(e){return y(e).join(" ")}function m(e){return y(e).join(":")}function E(e,t){return e.filter(e=>t.includes(e)).length===e.length}function b(e,t){return i()(e,t)}function _(e){return Object.fromEntries(e.entries())}function w(e){return new Map(Object.entries(e))}const R=e=>e;function O(e){return e.split(" ").map(e=>e.trim().replace(/^\w/,e=>e.toUpperCase())).join(" ")}function T(e){return 1e3*e}function S(e){return Math.floor(e/1e3)}function I(e,t){return S((t||Date.now())+T(e))}}).call(this,n(32))},function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return a})),n.d(t,"c",(function(){return c})),n.d(t,"d",(function(){return u})),n.d(t,"e",(function(){return h})),n.d(t,"f",(function(){return l}));var r=n(10),i=n(4);async function o(e,t=i.a){return r.getSubtleCrypto().importKey("raw",e,function(e){return e===i.a?{length:i.b,name:i.a}:{hash:{name:i.g},name:i.f}}(t),!0,function(e){return e===i.a?[i.d,i.c]:[i.p,i.q]}(t))}async function s(e,t,n){const s=r.getSubtleCrypto(),a=await o(t,i.a),c=await s.encrypt({iv:e,name:i.a},a,n);return new Uint8Array(c)}async function a(e,t,n){const s=r.getSubtleCrypto(),a=await o(t,i.a),c=await s.decrypt({iv:e,name:i.a},a,n);return new Uint8Array(c)}async function c(e,t){const n=r.getSubtleCrypto(),s=await o(e,i.f),a=await n.sign({length:i.h,name:i.f},s,t);return new Uint8Array(a)}async function u(e,t){const n=r.getSubtleCrypto(),s=await o(e,i.f),a=await n.sign({length:i.l,name:i.f},s,t);return new Uint8Array(a)}async function h(e){const t=r.getSubtleCrypto(),n=await t.digest({name:i.n},e);return new Uint8Array(n)}async function l(e){const t=r.getSubtleCrypto(),n=await t.digest({name:i.o},e);return new Uint8Array(n)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"c",(function(){return a})),n.d(t,"f",(function(){return c})),n.d(t,"g",(function(){return u})),n.d(t,"d",(function(){return h})),n.d(t,"e",(function(){return l})),n.d(t,"h",(function(){return d})),n.d(t,"b",(function(){return f}));var r=n(30),i=n(2),o=n(7);function s(e,t){return r.sharedKey(e,t)}function a(e){const t=void 0!==e?function(e){return{isAvailable:!0,randomBytes:()=>e}}(e):void 0,n=r.generateKeyPair(t);return{publicKey:n.publicKey,privateKey:n.secretKey}}function c(e){const t=(null==e?void 0:e.sender)||a();return{privateKey:t.privateKey,publicKey:t.publicKey}}function u(e,t){return s(e,t)}function h(e){return new Uint8Array(e.slice(o.LENGTH_0,o.KEY_LENGTH))}function l(e){return new Uint8Array(e.slice(o.KEY_LENGTH))}function d(e){return Object(i.concatArrays)(e.iv,e.publicKey,e.mac,e.ciphertext)}function f(e){const t=o.LENGTH_0,n=t+o.IV_LENGTH,r=n+o.KEY_LENGTH,i=r+o.MAC_LENGTH,s=e.length;return{iv:e.slice(t,n),publicKey:e.slice(n,r),mac:e.slice(r,i),ciphertext:e.slice(i,s)}}},function(e,t,n){"use strict";n.d(t,"c",(function(){return i})),n.d(t,"d",(function(){return o})),n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return a})),n.d(t,"g",(function(){return c})),n.d(t,"h",(function(){return u})),n.d(t,"e",(function(){return h})),n.d(t,"f",(function(){return l}));var r=n(11);function i(e){return Object(r.c)(e,"subscribe")}function o(e){return Object(r.b)(e,1)&&"topic"in e}function s(e){return Object(r.c)(e,"publish")}function a(e){return Object(r.b)(e,3)&&"message"in e&&"topic"in e&&"ttl"in e}function c(e){return Object(r.c)(e,"unsubscribe")}function u(e){return Object(r.b)(e,2)&&"id"in e&&"topic"in e}function h(e){return Object(r.c)(e,"subscription")}function l(e){return Object(r.b)(e,2)&&"id"in e&&"data"in e}},function(e,t,n){"use strict";n.d(t,"c",(function(){return i})),n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s})),n.d(t,"d",(function(){return a}));var r=n(9);function i(e){return r.b.includes(e)}function o(e){return Object.keys(r.e).includes(e)?r.e[e]:r.e[r.a]}function s(e){const t=Object.values(r.e).find(t=>t.code===e);return t||r.e[r.a]}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";var r=n(7);n.o(r,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return r.decryptWithSharedKey})),n.o(r,"derive")&&n.d(t,"derive",(function(){return r.derive})),n.o(r,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return r.encryptWithSharedKey})),n.o(r,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return r.generateKeyPair})),n.o(r,"randomBytes")&&n.d(t,"randomBytes",(function(){return r.randomBytes})),n.o(r,"sha256")&&n.d(t,"sha256",(function(){return r.sha256}));var i=n(66);n.d(t,"decryptWithSharedKey",(function(){return i.a})),n.d(t,"encryptWithSharedKey",(function(){return i.b}));var o=n(14);n.d(t,"derive",(function(){return o.a})),n.d(t,"generateKeyPair",(function(){return o.c}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t){super(),this.client=e,this.logger=t}}},function(e,t,n){"use strict";const r=n(80);e.exports=s;const i=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},o={mapHttpRequest:p,mapHttpResponse:p,wrapRequestSerializer:g,wrapResponseSerializer:g,wrapErrorSerializer:g,req:p,res:p,err:function(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const n in e)void 0===t[n]&&(t[n]=e[n]);return t}};function s(e){(e=e||{}).browser=e.browser||{};const t=e.browser.transmit;if(t&&"function"!=typeof t.send)throw Error("pino: transmit option must have a send function");const n=e.browser.write||i;e.browser.write&&(e.browser.asObject=!0);const r=e.serializers||{},o=function(e,t){if(Array.isArray(e)){return e.filter((function(e){return"!stdSerializers.err"!==e}))}return!0===e&&Object.keys(t)}(e.browser.serialize,r);let c=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(c=!1);"function"==typeof n&&(n.error=n.fatal=n.warn=n.info=n.debug=n.trace=n),!1===e.enabled&&(e.level="silent");const l=e.level||"info",p=Object.create(n);p.log||(p.log=y),Object.defineProperty(p,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(p,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,a(g,p,"error","log"),a(g,p,"fatal","error"),a(g,p,"warn","error"),a(g,p,"info","log"),a(g,p,"debug","log"),a(g,p,"trace","log")}});const g={transmit:t,serialize:o,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:f(e)};return p.levels=s.levels,p.level=l,p.setMaxListeners=p.getMaxListeners=p.emit=p.addListener=p.on=p.prependListener=p.once=p.prependOnceListener=p.removeListener=p.removeAllListeners=p.listeners=p.listenerCount=p.eventNames=p.write=p.flush=y,p.serializers=r,p._serialize=o,p._stdErrSerialize=c,p.child=function(n,i){if(!n)throw new Error("missing bindings for child Pino");i=i||{},o&&n.serializers&&(i.serializers=n.serializers);const s=i.serializers;if(o&&s){var a=Object.assign({},r,s),c=!0===e.browser.serialize?Object.keys(a):o;delete n.serializers,u([n],c,a,this._stdErrSerialize)}function l(e){this._childLevel=1+(0|e._childLevel),this.error=h(e,n,"error"),this.fatal=h(e,n,"fatal"),this.warn=h(e,n,"warn"),this.info=h(e,n,"info"),this.debug=h(e,n,"debug"),this.trace=h(e,n,"trace"),a&&(this.serializers=a,this._serialize=c),t&&(this._logEvent=d([].concat(e._logEvent.bindings,n)))}return l.prototype=this,new l(this)},t&&(p._logEvent=d()),p}function a(e,t,n,r){const o=Object.getPrototypeOf(t);t[n]=t.levelVal>t.levels.values[n]?y:o[n]?o[n]:i[n]||i[r]||y,function(e,t,n){if(!e.transmit&&t[n]===y)return;t[n]=(r=t[n],function(){const o=e.timestamp(),a=new Array(arguments.length),h=Object.getPrototypeOf&&Object.getPrototypeOf(this)===i?i:this;for(var d=0;d<a.length;d++)a[d]=arguments[d];if(e.serialize&&!e.asObject&&u(a,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?r.call(h,c(this,n,a,o)):r.apply(h,a),e.transmit){const r=e.transmit.level||t.level,i=s.levels.values[r],c=s.levels.values[n];if(c<i)return;l(this,{ts:o,methodLevel:n,methodValue:c,transmitLevel:r,transmitValue:s.levels.values[e.transmit.level||t.level],send:e.transmit.send,val:t.levelVal},a)}});var r}(e,t,n)}function c(e,t,n,i){e._serialize&&u(n,e._serialize,e.serializers,e._stdErrSerialize);const o=n.slice();let a=o[0];const c={};i&&(c.time=i),c.level=s.levels.values[t];let h=1+(0|e._childLevel);if(h<1&&(h=1),null!==a&&"object"==typeof a){for(;h--&&"object"==typeof o[0];)Object.assign(c,o.shift());a=o.length?r(o.shift(),o):void 0}else"string"==typeof a&&(a=r(o.shift(),o));return void 0!==a&&(c.msg=a),c}function u(e,t,n,r){for(const i in e)if(r&&e[i]instanceof Error)e[i]=s.stdSerializers.err(e[i]);else if("object"==typeof e[i]&&!Array.isArray(e[i]))for(const r in e[i])t&&t.indexOf(r)>-1&&r in n&&(e[i][r]=n[r](e[i][r]))}function h(e,t,n){return function(){const r=new Array(1+arguments.length);r[0]=t;for(var i=1;i<r.length;i++)r[i]=arguments[i-1];return e[n].apply(this,r)}}function l(e,t,n){const r=t.send,i=t.ts,o=t.methodLevel,s=t.methodValue,a=t.val,c=e._logEvent.bindings;u(n,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=n.filter((function(e){return-1===c.indexOf(e)})),e._logEvent.level.label=o,e._logEvent.level.value=s,r(o,e._logEvent,a),e._logEvent=d(c)}function d(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function f(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?v:m}function p(){return{}}function g(e){return e}function y(){}function v(){return!1}function m(){return Date.now()}s.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},s.stdSerializers=o,s.stdTimeFunctions=Object.assign({},{nullTime:v,epochTime:m,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}})},function(e,t,n){"use strict";const r=n(97),i=n(98),o=n(99),s=n(100);function a(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function c(e,t){return t.encode?t.strict?r(e):encodeURIComponent(e):e}function u(e,t){return t.decode?i(e):e}function h(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function l(e){const t=(e=h(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function d(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function f(e,t){a((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const n=function(e){let t;switch(e.arrayFormat){case"index":return(e,n,r)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===r[e]&&(r[e]={}),r[e][t[1]]=n):r[e]=n};case"bracket":return(e,n,r)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==r[e]?r[e]=[].concat(r[e],n):r[e]=[n]:r[e]=n};case"comma":case"separator":return(t,n,r)=>{const i="string"==typeof n&&n.includes(e.arrayFormatSeparator),o="string"==typeof n&&!i&&u(n,e).includes(e.arrayFormatSeparator);n=o?u(n,e):n;const s=i||o?n.split(e.arrayFormatSeparator).map(t=>u(t,e)):null===n?n:u(n,e);r[t]=s};default:return(e,t,n)=>{void 0!==n[e]?n[e]=[].concat(n[e],t):n[e]=t}}}(t),r=Object.create(null);if("string"!=typeof e)return r;if(!(e=e.trim().replace(/^[?#&]/,"")))return r;for(const i of e.split("&")){if(""===i)continue;let[e,s]=o(t.decode?i.replace(/\+/g," "):i,"=");s=void 0===s?null:["comma","separator"].includes(t.arrayFormat)?s:u(s,t),n(u(e,t),s,r)}for(const e of Object.keys(r)){const n=r[e];if("object"==typeof n&&null!==n)for(const e of Object.keys(n))n[e]=d(n[e],t);else r[e]=d(n,t)}return!1===t.sort?r:(!0===t.sort?Object.keys(r).sort():Object.keys(r).sort(t.sort)).reduce((e,t)=>{const n=r[t];return Boolean(n)&&"object"==typeof n&&!Array.isArray(n)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort((e,t)=>Number(e)-Number(t)).map(e=>t[e]):t}(n):e[t]=n,e},Object.create(null))}t.extract=l,t.parse=f,t.stringify=(e,t)=>{if(!e)return"";a((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const n=n=>t.skipNull&&null==e[n]||t.skipEmptyString&&""===e[n],r=function(e){switch(e.arrayFormat){case"index":return t=>(n,r)=>{const i=n.length;return void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[c(t,e),"[",i,"]"].join("")]:[...n,[c(t,e),"[",c(i,e),"]=",c(r,e)].join("")]};case"bracket":return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[c(t,e),"[]"].join("")]:[...n,[c(t,e),"[]=",c(r,e)].join("")];case"comma":case"separator":return t=>(n,r)=>null==r||0===r.length?n:0===n.length?[[c(t,e),"=",c(r,e)].join("")]:[[n,c(r,e)].join(e.arrayFormatSeparator)];default:return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,c(t,e)]:[...n,[c(t,e),"=",c(r,e)].join("")]}}(t),i={};for(const t of Object.keys(e))n(t)||(i[t]=e[t]);const o=Object.keys(i);return!1!==t.sort&&o.sort(t.sort),o.map(n=>{const i=e[n];return void 0===i?"":null===i?c(n,t):Array.isArray(i)?i.reduce(r(n),[]).join("&"):c(n,t)+"="+c(i,t)}).filter(e=>e.length>0).join("&")},t.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[n,r]=o(e,"#");return Object.assign({url:n.split("?")[0]||"",query:f(l(e),t)},t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:u(r,t)}:{})},t.stringifyUrl=(e,n)=>{n=Object.assign({encode:!0,strict:!0},n);const r=h(e.url).split("?")[0]||"",i=t.extract(e.url),o=t.parse(i,{sort:!1}),s=Object.assign(o,e.query);let a=t.stringify(s,n);a&&(a="?"+a);let u=function(e){let t="";const n=e.indexOf("#");return-1!==n&&(t=e.slice(n)),t}(e.url);return e.fragmentIdentifier&&(u="#"+c(e.fragmentIdentifier,n)),`${r}${a}${u}`},t.pick=(e,n,r)=>{r=Object.assign({parseFragmentIdentifier:!0},r);const{url:i,query:o,fragmentIdentifier:a}=t.parseUrl(e,r);return t.stringifyUrl({url:i,query:s(o,n),fragmentIdentifier:a},r)},t.exclude=(e,n,r)=>{const i=Array.isArray(n)?e=>!n.includes(e):(e,t)=>!n(e,t);return t.pick(e,i,r)}},function(e,t,n){"use strict";function r(e){let t=void 0;return"undefined"!=typeof window&&void 0!==window[e]&&(t=window[e]),t}function i(e){const t=r(e);if(!t)throw new Error(e+" is not defined in Window");return t}Object.defineProperty(t,"__esModule",{value:!0}),t.getLocalStorage=t.getLocalStorageOrThrow=t.getCrypto=t.getCryptoOrThrow=t.getLocation=t.getLocationOrThrow=t.getNavigator=t.getNavigatorOrThrow=t.getDocument=t.getDocumentOrThrow=t.getFromWindowOrThrow=t.getFromWindow=void 0,t.getFromWindow=r,t.getFromWindowOrThrow=i,t.getDocumentOrThrow=function(){return i("document")},t.getDocument=function(){return r("document")},t.getNavigatorOrThrow=function(){return i("navigator")},t.getNavigator=function(){return r("navigator")},t.getLocationOrThrow=function(){return i("location")},t.getLocation=function(){return r("location")},t.getCryptoOrThrow=function(){return i("crypto")},t.getCrypto=function(){return r("crypto")},t.getLocalStorageOrThrow=function(){return i("localStorage")},t.getLocalStorage=function(){return r("localStorage")}},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";n.d(t,"a",(function(){return r}));class r{}},function(e,t,n){"use strict";var r=n(61);n.o(r,"ERROR_BAD_MAC")&&n.d(t,"ERROR_BAD_MAC",(function(){return r.ERROR_BAD_MAC})),n.o(r,"IV_LENGTH")&&n.d(t,"IV_LENGTH",(function(){return r.IV_LENGTH})),n.o(r,"KEY_LENGTH")&&n.d(t,"KEY_LENGTH",(function(){return r.KEY_LENGTH})),n.o(r,"LENGTH_0")&&n.d(t,"LENGTH_0",(function(){return r.LENGTH_0})),n.o(r,"MAC_LENGTH")&&n.d(t,"MAC_LENGTH",(function(){return r.MAC_LENGTH})),n.o(r,"assert")&&n.d(t,"assert",(function(){return r.assert})),n.o(r,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return r.decryptWithSharedKey})),n.o(r,"derive")&&n.d(t,"derive",(function(){return r.derive})),n.o(r,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return r.encryptWithSharedKey})),n.o(r,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return r.generateKeyPair})),n.o(r,"isConstantTime")&&n.d(t,"isConstantTime",(function(){return r.isConstantTime}));n(62);var i=n(63);n.o(i,"ERROR_BAD_MAC")&&n.d(t,"ERROR_BAD_MAC",(function(){return i.ERROR_BAD_MAC})),n.o(i,"IV_LENGTH")&&n.d(t,"IV_LENGTH",(function(){return i.IV_LENGTH})),n.o(i,"KEY_LENGTH")&&n.d(t,"KEY_LENGTH",(function(){return i.KEY_LENGTH})),n.o(i,"LENGTH_0")&&n.d(t,"LENGTH_0",(function(){return i.LENGTH_0})),n.o(i,"MAC_LENGTH")&&n.d(t,"MAC_LENGTH",(function(){return i.MAC_LENGTH})),n.o(i,"assert")&&n.d(t,"assert",(function(){return i.assert})),n.o(i,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return i.decryptWithSharedKey})),n.o(i,"derive")&&n.d(t,"derive",(function(){return i.derive})),n.o(i,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return i.encryptWithSharedKey})),n.o(i,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return i.generateKeyPair})),n.o(i,"isConstantTime")&&n.d(t,"isConstantTime",(function(){return i.isConstantTime}));var o=n(64);n.d(t,"assert",(function(){return o.a})),n.d(t,"isConstantTime",(function(){return o.b}))},function(e,t,n){"use strict";(function(e){var r=n(3),i=n(8),o=n(0);const s=void 0!==e.WebSocket?e.WebSocket:n(102);t.a=class{constructor(e){if(this.url=e,this.events=new r.EventEmitter,this.registering=!1,!Object(o.isWsUrl)(e))throw new Error("Provided URL is not compatible with WebSocket connection: "+e);this.url=e}get connected(){return void 0!==this.socket}get connecting(){return this.registering}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)}async open(e=this.url){await this.register(e)}async close(){if(void 0===this.socket)throw new Error("Connection already closed");this.socket.close(),this.onClose()}async send(e,t){void 0===this.socket&&(this.socket=await this.register());try{this.socket.send(Object(i.b)(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Object(o.isWsUrl)(e))throw new Error("Provided URL is not compatible with WebSocket connection: "+e);return this.registering?new Promise((e,t)=>{this.events.once("register_error",e=>{t(e)}),this.events.once("open",()=>{if(void 0===this.socket)return t(new Error("WebSocket connection is missing or invalid"));e(this.socket)})}):(this.url=e,this.registering=!0,new Promise((t,n)=>{const r=Object(o.isReactNative)()?void 0:{rejectUnauthorized:!Object(o.isLocalhostUrl)(e)},i=new s(e,[],r);i.onopen=()=>{this.onOpen(i),t(i)},i.onerror=e=>{const t=this.parseError(e.error);this.events.emit("register_error",t),this.onClose(),n(t)}}))}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=()=>this.onClose(),e.onerror=e=>{const t=this.parseError(e.error);this.events.emit("error",t)},this.socket=e,this.registering=!1,this.events.emit("open")}onClose(){this.socket=void 0,this.registering=!1,this.events.emit("close")}onPayload(e){if(void 0===e.data)return;const t="string"==typeof e.data?Object(i.a)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const n=this.parseError(t),r=n.message||n.toString(),i=Object(o.formatJsonRpcError)(e,r);this.events.emit("payload",i)}parseError(e,t=this.url){return Object(o.parseConnectionError)(e,t,"WS")}}}).call(this,n(22))},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(n(81)),s=n(41),a=n(82);class c{constructor(){this.localStorage=o.default}getKeys(){return r(this,void 0,void 0,(function*(){return Object.keys(this.localStorage)}))}getEntries(){return r(this,void 0,void 0,(function*(){return Object.entries(this.localStorage).map(a.parseEntry)}))}getItem(e){return r(this,void 0,void 0,(function*(){const t=this.localStorage.getItem(e);if(null!==t)return s.safeJsonParse(t)}))}setItem(e,t){return r(this,void 0,void 0,(function*(){this.localStorage.setItem(e,s.safeJsonStringify(t))}))}removeItem(e){return r(this,void 0,void 0,(function*(){this.localStorage.removeItem(e)}))}}t.KeyValueStorage=c,t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wipe=function(e){for(var t=0;t<e.length;t++)e[t]=0;return e}},function(e,t,n){"use strict";n.r(t),n.d(t,"JsonRpcProvider",(function(){return o}));var r=n(3),i=n(0);class o extends i.IJsonRpcProvider{constructor(e){super(e),this.events=new r.EventEmitter,this.connection=this.setConnection(e)}async connect(e=this.connection){await this.open(e)}async disconnect(){await 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)}async request(e,t){return this.requestStrict(Object(i.formatJsonRpcRequest)(e.method,e.params||[]),t)}async requestStrict(e,t){return new Promise(async(n,r)=>{if(!this.connection.connected)try{await this.open()}catch(e){r(e)}this.events.on(""+e.id,e=>{Object(i.isJsonRpcError)(e)?r(e.error.message):n(e.result)});try{await this.connection.send(e,t)}catch(e){r(e)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Object(i.isJsonRpcResponse)(e)?this.events.emit(""+e.id,e):this.events.emit("message",{type:e.method,data:e.params})}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",()=>this.events.emit("disconnect")),this.connection.on("error",e=>this.events.emit("error",e)),this.events.emit("connect"))}async close(){await this.connection.close(),this.events.emit("disconnect")}}var s=o;t.default=s},function(e,t){var n="undefined"!=typeof self?self:this,r=function(){function e(){this.fetch=!1,this.DOMException=n.DOMException}return e.prototype=n,new e}();!function(e){!function(t){var n="URLSearchParams"in e,r="Symbol"in e&&"iterator"in Symbol,i="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),o="FormData"in e,s="ArrayBuffer"in e;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function h(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function g(e){var t=new FileReader,n=p(t);return t.readAsArrayBuffer(e),n}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:o&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():s&&i&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var e,t,n,r=f(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=p(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=u(e),t=h(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},d.prototype.delete=function(e){delete this.map[u(e)]},d.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},d.prototype.set=function(e,t){this.map[u(e)]=h(t)},d.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),l(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),l(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),l(e)},r&&(d.prototype[Symbol.iterator]=d.prototype.entries);var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function E(e,t){var n,r,i=(t=t||{}).body;if(e instanceof E){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),m.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function b(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}E.prototype.clone=function(){return new E(this,{body:this._bodyInit})},v.call(E.prototype),v.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var w=[301,302,303,307,308];_.redirect=function(e,t){if(-1===w.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function R(e,n){return new Promise((function(r,o){var s=new E(e,n);if(s.signal&&s.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var e,t,n={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();t.append(r,i)}})),t)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;r(new _(i,n))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),s.signal&&(s.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",c)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}R.polyfill=!0,e.fetch||(e.fetch=R,e.Headers=d,e.Request=E,e.Response=_),t.Headers=d,t.Request=E,t.Response=_,t.fetch=R,Object.defineProperty(t,"__esModule",{value:!0})}({})}(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=r;(t=i.fetch).default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,e.exports=t},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(90),i=n(27);function o(e){var t=new Float64Array(16);if(e)for(var n=0;n<e.length;n++)t[n]=e[n];return t}t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;var s=new Uint8Array(32);s[0]=9;var a=o([56129,1]);function c(e){for(var t=1,n=0;n<16;n++){var r=e[n]+t+65535;t=Math.floor(r/65536),e[n]=r-65536*t}e[0]+=t-1+37*(t-1)}function u(e,t,n){for(var r=~(n-1),i=0;i<16;i++){var o=r&(e[i]^t[i]);e[i]^=o,t[i]^=o}}function h(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function l(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function d(e,t,n){var r,i,o=0,s=0,a=0,c=0,u=0,h=0,l=0,d=0,f=0,p=0,g=0,y=0,v=0,m=0,E=0,b=0,_=0,w=0,R=0,O=0,T=0,S=0,I=0,N=0,A=0,P=0,U=0,C=0,D=0,L=0,j=0,x=n[0],q=n[1],M=n[2],H=n[3],K=n[4],J=n[5],B=n[6],G=n[7],k=n[8],V=n[9],F=n[10],z=n[11],Y=n[12],W=n[13],$=n[14],Q=n[15];o+=(r=t[0])*x,s+=r*q,a+=r*M,c+=r*H,u+=r*K,h+=r*J,l+=r*B,d+=r*G,f+=r*k,p+=r*V,g+=r*F,y+=r*z,v+=r*Y,m+=r*W,E+=r*$,b+=r*Q,s+=(r=t[1])*x,a+=r*q,c+=r*M,u+=r*H,h+=r*K,l+=r*J,d+=r*B,f+=r*G,p+=r*k,g+=r*V,y+=r*F,v+=r*z,m+=r*Y,E+=r*W,b+=r*$,_+=r*Q,a+=(r=t[2])*x,c+=r*q,u+=r*M,h+=r*H,l+=r*K,d+=r*J,f+=r*B,p+=r*G,g+=r*k,y+=r*V,v+=r*F,m+=r*z,E+=r*Y,b+=r*W,_+=r*$,w+=r*Q,c+=(r=t[3])*x,u+=r*q,h+=r*M,l+=r*H,d+=r*K,f+=r*J,p+=r*B,g+=r*G,y+=r*k,v+=r*V,m+=r*F,E+=r*z,b+=r*Y,_+=r*W,w+=r*$,R+=r*Q,u+=(r=t[4])*x,h+=r*q,l+=r*M,d+=r*H,f+=r*K,p+=r*J,g+=r*B,y+=r*G,v+=r*k,m+=r*V,E+=r*F,b+=r*z,_+=r*Y,w+=r*W,R+=r*$,O+=r*Q,h+=(r=t[5])*x,l+=r*q,d+=r*M,f+=r*H,p+=r*K,g+=r*J,y+=r*B,v+=r*G,m+=r*k,E+=r*V,b+=r*F,_+=r*z,w+=r*Y,R+=r*W,O+=r*$,T+=r*Q,l+=(r=t[6])*x,d+=r*q,f+=r*M,p+=r*H,g+=r*K,y+=r*J,v+=r*B,m+=r*G,E+=r*k,b+=r*V,_+=r*F,w+=r*z,R+=r*Y,O+=r*W,T+=r*$,S+=r*Q,d+=(r=t[7])*x,f+=r*q,p+=r*M,g+=r*H,y+=r*K,v+=r*J,m+=r*B,E+=r*G,b+=r*k,_+=r*V,w+=r*F,R+=r*z,O+=r*Y,T+=r*W,S+=r*$,I+=r*Q,f+=(r=t[8])*x,p+=r*q,g+=r*M,y+=r*H,v+=r*K,m+=r*J,E+=r*B,b+=r*G,_+=r*k,w+=r*V,R+=r*F,O+=r*z,T+=r*Y,S+=r*W,I+=r*$,N+=r*Q,p+=(r=t[9])*x,g+=r*q,y+=r*M,v+=r*H,m+=r*K,E+=r*J,b+=r*B,_+=r*G,w+=r*k,R+=r*V,O+=r*F,T+=r*z,S+=r*Y,I+=r*W,N+=r*$,A+=r*Q,g+=(r=t[10])*x,y+=r*q,v+=r*M,m+=r*H,E+=r*K,b+=r*J,_+=r*B,w+=r*G,R+=r*k,O+=r*V,T+=r*F,S+=r*z,I+=r*Y,N+=r*W,A+=r*$,P+=r*Q,y+=(r=t[11])*x,v+=r*q,m+=r*M,E+=r*H,b+=r*K,_+=r*J,w+=r*B,R+=r*G,O+=r*k,T+=r*V,S+=r*F,I+=r*z,N+=r*Y,A+=r*W,P+=r*$,U+=r*Q,v+=(r=t[12])*x,m+=r*q,E+=r*M,b+=r*H,_+=r*K,w+=r*J,R+=r*B,O+=r*G,T+=r*k,S+=r*V,I+=r*F,N+=r*z,A+=r*Y,P+=r*W,U+=r*$,C+=r*Q,m+=(r=t[13])*x,E+=r*q,b+=r*M,_+=r*H,w+=r*K,R+=r*J,O+=r*B,T+=r*G,S+=r*k,I+=r*V,N+=r*F,A+=r*z,P+=r*Y,U+=r*W,C+=r*$,D+=r*Q,E+=(r=t[14])*x,b+=r*q,_+=r*M,w+=r*H,R+=r*K,O+=r*J,T+=r*B,S+=r*G,I+=r*k,N+=r*V,A+=r*F,P+=r*z,U+=r*Y,C+=r*W,D+=r*$,L+=r*Q,b+=(r=t[15])*x,s+=38*(w+=r*M),a+=38*(R+=r*H),c+=38*(O+=r*K),u+=38*(T+=r*J),h+=38*(S+=r*B),l+=38*(I+=r*G),d+=38*(N+=r*k),f+=38*(A+=r*V),p+=38*(P+=r*F),g+=38*(U+=r*z),y+=38*(C+=r*Y),v+=38*(D+=r*W),m+=38*(L+=r*$),E+=38*(j+=r*Q),o=(r=(o+=38*(_+=r*q))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),s=(r=s+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),E=(r=E+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),o=(r=(o+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),s=(r=s+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),E=(r=E+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),o+=i-1+37*(i-1),e[0]=o,e[1]=s,e[2]=a,e[3]=c,e[4]=u,e[5]=h,e[6]=l,e[7]=d,e[8]=f,e[9]=p,e[10]=g,e[11]=y,e[12]=v,e[13]=m,e[14]=E,e[15]=b}function f(e,t){d(e,t,t)}function p(e,t){for(var n=new Uint8Array(32),r=new Float64Array(80),i=o(),s=o(),p=o(),g=o(),y=o(),v=o(),m=0;m<31;m++)n[m]=e[m];n[31]=127&e[31]|64,n[0]&=248,function(e,t){for(var n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}(r,t);for(m=0;m<16;m++)s[m]=r[m];i[0]=g[0]=1;for(m=254;m>=0;--m){var E=n[m>>>3]>>>(7&m)&1;u(i,s,E),u(p,g,E),h(y,i,p),l(i,i,p),h(p,s,g),l(s,s,g),f(g,y),f(v,i),d(i,p,i),d(p,s,y),h(y,i,p),l(i,i,p),f(s,i),l(p,g,v),d(i,p,a),h(i,i,g),d(p,p,i),d(i,g,v),d(g,s,r),f(s,y),u(i,s,E),u(p,g,E)}for(m=0;m<16;m++)r[m+16]=i[m],r[m+32]=p[m],r[m+48]=s[m],r[m+64]=g[m];var b=r.subarray(32),_=r.subarray(16);!function(e,t){for(var n=o(),r=0;r<16;r++)n[r]=t[r];for(r=253;r>=0;r--)f(n,n),2!==r&&4!==r&&d(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}(b,b),d(_,_,b);var w=new Uint8Array(32);return function(e,t){for(var n=o(),r=o(),i=0;i<16;i++)r[i]=t[i];c(r),c(r),c(r);for(var s=0;s<2;s++){n[0]=r[0]-65517;for(i=1;i<15;i++)n[i]=r[i]-65535-(n[i-1]>>16&1),n[i-1]&=65535;n[15]=r[15]-32767-(n[14]>>16&1);var a=n[15]>>16&1;n[14]&=65535,u(r,n,1-a)}for(i=0;i<16;i++)e[2*i]=255&r[i],e[2*i+1]=r[i]>>8}(w,_),w}function g(e){return p(e,s)}function y(e){if(e.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var n=new Uint8Array(e);return{publicKey:g(n),secretKey:n}}t.scalarMult=p,t.scalarMultBase=g,t.generateKeyPairFromSeed=y,t.generateKeyPair=function(e){var t=r.randomBytes(32,e),n=y(t);return i.wipe(t),n},t.sharedKey=function(e,n,r){if(void 0===r&&(r=!1),e.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(n.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var i=p(e,n);if(r){for(var o=0,s=0;s<i.length;s++)o|=i[s];if(0===o)throw new Error("X25519: invalid shared key")}return i}},function(e,t,n){"use strict";var r=n(10);n.o(r,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return r.IJsonRpcProvider})),n.o(r,"formatJsonRpcError")&&n.d(t,"formatJsonRpcError",(function(){return r.formatJsonRpcError})),n.o(r,"formatJsonRpcRequest")&&n.d(t,"formatJsonRpcRequest",(function(){return r.formatJsonRpcRequest})),n.o(r,"formatJsonRpcResult")&&n.d(t,"formatJsonRpcResult",(function(){return r.formatJsonRpcResult})),n.o(r,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return r.isHttpUrl})),n.o(r,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return r.isJsonRpcError})),n.o(r,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return r.isJsonRpcRequest})),n.o(r,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return r.isJsonRpcResponse})),n.o(r,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return r.isLocalhostUrl})),n.o(r,"isReactNative")&&n.d(t,"isReactNative",(function(){return r.isReactNative})),n.o(r,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return r.isWsUrl}));r.isNode},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!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:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,u=[],h=!1,l=-1;function d(){h&&c&&(h=!1,c.length?u=c.concat(u):l=-1,u.length&&f())}function f(){if(!h){var e=a(d);h=!0;for(var t=u.length;t;){for(c=u,u=[];++l<t;)c&&c[l].run();l=-1,t=u.length}c=null,h=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!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 p(e,t){this.fun=e,this.array=t}function g(){}i.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];u.push(new p(e,t)),1!==u.length||h||a(f)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"c",(function(){return s})),n.d(t,"a",(function(){return a}));var r=n(16),i=n(9);function o(e,t,n){return{id:n||Date.now()*Math.pow(10,3)+Math.floor(Math.random()*Math.pow(10,3)),jsonrpc:"2.0",method:e,params:t}}function s(e,t){return{id:e,jsonrpc:"2.0",result:t}}function a(e,t){return{id:e,jsonrpc:"2.0",error:c(t)}}function c(e){return void 0===e?Object(r.a)(i.a):("string"==typeof e&&(e=Object.assign(Object.assign({},Object(r.a)(i.c)),{message:e})),Object(r.c)(e.code)&&(e=Object(r.b)(e.code)),e)}},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r=n(5);n.o(r,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return r.IJsonRpcProvider})),n.o(r,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return r.isHttpUrl})),n.o(r,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return r.isJsonRpcError})),n.o(r,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return r.isJsonRpcRequest})),n.o(r,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return r.isJsonRpcResponse})),n.o(r,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return r.isLocalhostUrl})),n.o(r,"isReactNative")&&n.d(t,"isReactNative",(function(){return r.isReactNative})),n.o(r,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return r.isWsUrl}))},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return s}));var r=n(23);class i extends r.a{constructor(e){super()}}class o extends r.a{constructor(){super()}}class s extends o{constructor(e){super()}}},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"c",(function(){return o})),n.d(t,"b",(function(){return s}));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 i(e){return r(e,"^https?:")}function o(e){return r(e,"^wss?:")}function s(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}},function(e,t,n){"use strict";function r(e){return"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function i(e){return r(e)&&"method"in e}function o(e){return r(e)&&(function(e){return"result"in e}(e)||s(e))}function s(e){return"error"in e}n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return s}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeJsonParse=function(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return JSON.parse(e)}catch(t){return e}},t.safeJsonStringify=function(e){return"string"==typeof e?e:JSON.stringify(e,(e,t)=>void 0===t?null:t)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e){super(),this.protocol="wc",this.version=2}}},function(e,t,n){"use strict"},function(e,t,n){"use strict"},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{constructor(e){this.sequence=e}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t){super(),this.client=e,this.logger=t}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e){super()}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t){super(),this.logger=e,this.storage=t,this.records=new Map}}},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(18);class i extends r.a{}},function(e,t,n){"use strict";var r=n(5);r.IEvents},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e){super()}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(18);class i extends r.a{}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t,n){super(),this.client=e,this.logger=t,this.name=n}}},function(e,t,n){"use strict"},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(10);function i(e){return r.getBrowerCrypto().getRandomValues(new Uint8Array(e))}},function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return o}));var r=n(13);function i(e,t,n){return Object(r.b)(e,t,n)}function o(e,t,n){return Object(r.a)(e,t,n)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s}));var r=n(13),i=n(24);async function o(e,t){return await Object(r.c)(e,t)}async function s(e,t,n){const o=await Object(r.c)(e,t);return Object(i.isConstantTime)(o,n)}},function(e,t,n){"use strict";var r=n(10);n.o(r,"ERROR_BAD_MAC")&&n.d(t,"ERROR_BAD_MAC",(function(){return r.ERROR_BAD_MAC})),n.o(r,"IV_LENGTH")&&n.d(t,"IV_LENGTH",(function(){return r.IV_LENGTH})),n.o(r,"KEY_LENGTH")&&n.d(t,"KEY_LENGTH",(function(){return r.KEY_LENGTH})),n.o(r,"LENGTH_0")&&n.d(t,"LENGTH_0",(function(){return r.LENGTH_0})),n.o(r,"MAC_LENGTH")&&n.d(t,"MAC_LENGTH",(function(){return r.MAC_LENGTH})),n.o(r,"assert")&&n.d(t,"assert",(function(){return r.assert})),n.o(r,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return r.decryptWithSharedKey})),n.o(r,"derive")&&n.d(t,"derive",(function(){return r.derive})),n.o(r,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return r.encryptWithSharedKey})),n.o(r,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return r.generateKeyPair})),n.o(r,"isConstantTime")&&n.d(t,"isConstantTime",(function(){return r.isConstantTime}))},function(e,t,n){"use strict"},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return o}));var r=n(13);async function i(e){return await Object(r.e)(e)}async function o(e){return await Object(r.f)(e)}},function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return c}));var r=n(7),i=n(2),o=n(14);async function s(e){const t=await Object(r.sha512)(e);return{encryptionKey:Object(o.d)(t),macKey:Object(o.e)(t)}}async function a(e,t,n,a=Object(r.randomBytes)(r.IV_LENGTH)){const{encryptionKey:c,macKey:u}=await s(t),h=await Object(r.aesCbcEncrypt)(a,c,e),l=Object(i.concatArrays)(a,n,h),d=await Object(r.hmacSha256Sign)(u,l);return Object(o.h)({iv:a,publicKey:n,ciphertext:h,mac:d})}async function c(e,t){const{iv:n,publicKey:a,mac:c,ciphertext:u}=Object(o.b)(e),{encryptionKey:h,macKey:l}=await s(t),d=Object(i.concatArrays)(n,a,u),f=await Object(r.hmacSha256Verify)(l,d,c);Object(r.assert)(f,r.ERROR_BAD_MAC);return await Object(r.aesCbcDecrypt)(n,h,u)}},function(e,t,n){"use strict";(function(e){
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WalletConnectEthereumProvider",[],t):"object"==typeof exports?exports.WalletConnectEthereumProvider=t():e.WalletConnectEthereumProvider=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.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 i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));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=76)}([function(e,t,n){"use strict";n(9);var r=n(16);n.d(t,"parseConnectionError",(function(){return r.d}));var i=n(31);n.o(i,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return i.IJsonRpcProvider})),n.o(i,"formatJsonRpcError")&&n.d(t,"formatJsonRpcError",(function(){return i.formatJsonRpcError})),n.o(i,"formatJsonRpcRequest")&&n.d(t,"formatJsonRpcRequest",(function(){return i.formatJsonRpcRequest})),n.o(i,"formatJsonRpcResult")&&n.d(t,"formatJsonRpcResult",(function(){return i.formatJsonRpcResult})),n.o(i,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return i.isHttpUrl})),n.o(i,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return i.isJsonRpcError})),n.o(i,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return i.isJsonRpcRequest})),n.o(i,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return i.isJsonRpcResponse})),n.o(i,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return i.isLocalhostUrl})),n.o(i,"isReactNative")&&n.d(t,"isReactNative",(function(){return i.isReactNative})),n.o(i,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return i.isWsUrl}));var o=n(33);n.d(t,"formatJsonRpcError",(function(){return o.a})),n.d(t,"formatJsonRpcRequest",(function(){return o.b})),n.d(t,"formatJsonRpcResult",(function(){return o.c}));n(34);var s=n(35);n.o(s,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return s.IJsonRpcProvider})),n.o(s,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return s.isHttpUrl})),n.o(s,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return s.isJsonRpcError})),n.o(s,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return s.isJsonRpcRequest})),n.o(s,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return s.isJsonRpcResponse})),n.o(s,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return s.isLocalhostUrl})),n.o(s,"isReactNative")&&n.d(t,"isReactNative",(function(){return s.isReactNative})),n.o(s,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return s.isWsUrl}));var a=n(39);n.d(t,"isHttpUrl",(function(){return a.a})),n.d(t,"isLocalhostUrl",(function(){return a.b})),n.d(t,"isWsUrl",(function(){return a.c}));var c=n(40);n.d(t,"isJsonRpcError",(function(){return c.a})),n.d(t,"isJsonRpcRequest",(function(){return c.b})),n.d(t,"isJsonRpcResponse",(function(){return c.c}))},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||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(72),t),i(n(101),t)},function(e,t,n){"use strict";(function(e){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.removeHexLeadingZeros=t.sanitizeHex=t.addHexPrefix=t.removeHexPrefix=t.padRight=t.padLeft=t.sanitizeBytes=t.swapHex=t.swapBytes=t.splitBytes=t.calcByteLength=t.trimRight=t.trimLeft=t.concatArrays=t.concatBuffers=t.getEncoding=t.getType=t.isArrayBuffer=t.isTypedArray=t.isBuffer=t.isHexString=t.isBinaryString=t.binaryToNumber=t.binaryToUtf8=t.binaryToHex=t.binaryToArray=t.binaryToBuffer=t.numberToBinary=t.numberToUtf8=t.numberToHex=t.numberToArray=t.numberToBuffer=t.utf8ToBinary=t.utf8ToNumber=t.utf8ToHex=t.utf8ToArray=t.utf8ToBuffer=t.hexToBinary=t.hexToNumber=t.hexToUtf8=t.hexToArray=t.hexToBuffer=t.arrayToBinary=t.arrayToNumber=t.arrayToUtf8=t.arrayToHex=t.arrayToBuffer=t.bufferToBinary=t.bufferToNumber=t.bufferToUtf8=t.bufferToHex=t.bufferToArray=void 0;const i=r(n(68)),o=r(n(89));function s(e){return new Uint8Array(e)}function a(e,t=!1){const n=e.toString("hex");return t?j(n):n}function c(e){return e.toString("utf8")}function u(e){return e.readUIntBE(0,e.length)}function h(e){return o.default(e)}function l(e,t=!1){return a(h(e),t)}function d(e){return c(h(e))}function f(e){return u(h(e))}function p(e){return Array.from(e).map(b).join("")}function g(t){return e.from(L(t),"hex")}function y(e){return s(g(e))}function v(e){return p(y(e))}function m(t){return e.from(t,"utf8")}function E(e){return s(m(e))}function b(e){return C((e>>>0).toString(2))}function _(e){return h(w(e))}function w(e){return new Uint8Array(P(e).map(e=>parseInt(e,2)))}function R(e,t){return l(w(e),t)}function O(e){return!("string"!=typeof e||!new RegExp(/^[01]+$/).test(e))&&e.length%8==0}function T(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(!t||e.length===2+2*t)}function S(t){return e.isBuffer(t)}function I(e){return i.default.strict(e)&&!S(e)}function N(e){return!I(e)&&!S(e)&&void 0!==e.byteLength}function A(e,t=8){const n=e%t;return n?(e-n)/t*t+t:e}function P(e,t=8){const n=C(e).match(new RegExp(`.{${t}}`,"gi"));return Array.from(n||[])}function U(e){return P(e).map(x).join("")}function C(e,t=8,n="0"){return D(e,A(e.length,t),n)}function D(e,t,n="0"){return q(e,t,!0,n)}function L(e){return e.replace(/^0x/,"")}function j(e){return e.startsWith("0x")?e:"0x"+e}function x(e){return e.split("").reverse().join("")}function q(e,t,n,r="0"){const i=t-e.length;let o=e;if(i>0){const t=r.repeat(i);o=n?t+e:e+t}return o}t.bufferToArray=s,t.bufferToHex=a,t.bufferToUtf8=c,t.bufferToNumber=u,t.bufferToBinary=function(e){return p(s(e))},t.arrayToBuffer=h,t.arrayToHex=l,t.arrayToUtf8=d,t.arrayToNumber=f,t.arrayToBinary=p,t.hexToBuffer=g,t.hexToArray=y,t.hexToUtf8=function(e){return c(g(e))},t.hexToNumber=function(e){return f(y(e))},t.hexToBinary=v,t.utf8ToBuffer=m,t.utf8ToArray=E,t.utf8ToHex=function(e,t=!1){return a(m(e),t)},t.utf8ToNumber=function(e){const t=parseInt(e,10);return function(e,t){if(!e)throw new Error(t)}(!function(e){return void 0===e}(t),"Number can only safely store up to 53 bits"),t},t.utf8ToBinary=function(e){return p(E(e))},t.numberToBuffer=function(e){return _(b(e))},t.numberToArray=function(e){return w(b(e))},t.numberToHex=function(e,t){return R(b(e),t)},t.numberToUtf8=function(e){return""+e},t.numberToBinary=b,t.binaryToBuffer=_,t.binaryToArray=w,t.binaryToHex=R,t.binaryToUtf8=function(e){return d(w(e))},t.binaryToNumber=function(e){return f(w(e))},t.isBinaryString=O,t.isHexString=T,t.isBuffer=S,t.isTypedArray=I,t.isArrayBuffer=N,t.getType=function(e){return S(e)?"buffer":I(e)?"typed-array":N(e)?"array-buffer":Array.isArray(e)?"array":typeof e},t.getEncoding=function(e){return O(e)?"binary":T(e)?"hex":"utf8"},t.concatBuffers=function(...t){return e.concat(t)},t.concatArrays=function(...e){let t=[];return e.forEach(e=>t=t.concat(Array.from(e))),new Uint8Array([...t])},t.trimLeft=function(e,t){const n=e.length-t;return n>0&&(e=e.slice(n)),e},t.trimRight=function(e,t){return e.slice(0,t)},t.calcByteLength=A,t.splitBytes=P,t.swapBytes=U,t.swapHex=function(e){return R(U(v(e)))},t.sanitizeBytes=C,t.padLeft=D,t.padRight=function(e,t,n="0"){return q(e,t,!1,n)},t.removeHexPrefix=L,t.addHexPrefix=j,t.sanitizeHex=function(e){return(e=C(e=L(e),2))&&(e=j(e)),e},t.removeHexLeadingZeros=function(e){const t=e.startsWith("0x");return e=(e=L(e)).startsWith("0")?e.substring(1):e,t?j(e):e}}).call(this,n(67).Buffer)},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}v(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&v(e,"error",t,n)}(e,i,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function l(e,t,n,r){var i,o,s,a;if(u(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=h(e))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return e}function d(){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 f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=d.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]: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}(i):y(i,i.length)}function g(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 v(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 i(o){r.once&&e.removeEventListener(t,i),n(o)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),a.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},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(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},a.prototype.getMaxListeners=function(){return h(this)},a.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var u=c.length,h=y(c,u);for(n=0;n<u;++n)o(h[n],this,t)}return!0},a.prototype.addListener=function(e,t){return l(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return l(this,e,t,!0)},a.prototype.once=function(e,t){return u(t),this.on(e,f(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,f(this,e,t)),this},a.prototype.removeListener=function(e,t){var n,r,i,o,s;if(u(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(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},a.prototype.off=a.prototype.removeListener,a.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 i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);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},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"h",(function(){return s})),n.d(t,"a",(function(){return a})),n.d(t,"g",(function(){return c})),n.d(t,"f",(function(){return u})),n.d(t,"n",(function(){return h})),n.d(t,"o",(function(){return l})),n.d(t,"j",(function(){return d})),n.d(t,"i",(function(){return f})),n.d(t,"m",(function(){return p})),n.d(t,"e",(function(){return g})),n.d(t,"k",(function(){return r})),n.d(t,"l",(function(){return i})),n.d(t,"d",(function(){return y})),n.d(t,"c",(function(){return v})),n.d(t,"p",(function(){return m})),n.d(t,"q",(function(){return E}));const r=0,i=512,o=256,s=256,a="AES-CBC",c="SHA-"+o,u="HMAC",h="SHA-256",l="SHA-512",d=32,f=16,p=32,g="Bad MAC",y="encrypt",v="decrypt",m="sign",E="verify"},function(e,t,n){"use strict";var r=n(36);n.o(r,"IEvents")&&n.d(t,"IEvents",(function(){return r.IEvents})),n.o(r,"IJsonRpcConnection")&&n.d(t,"IJsonRpcConnection",(function(){return r.IJsonRpcConnection})),n.o(r,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return r.IJsonRpcProvider})),n.o(r,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return r.isHttpUrl})),n.o(r,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return r.isJsonRpcError})),n.o(r,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return r.isJsonRpcRequest})),n.o(r,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return r.isJsonRpcResponse})),n.o(r,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return r.isLocalhostUrl})),n.o(r,"isReactNative")&&n.d(t,"isReactNative",(function(){return r.isReactNative})),n.o(r,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return r.isWsUrl}));var i=n(23);n.d(t,"IEvents",(function(){return i.a}));var o=n(37);n.d(t,"IJsonRpcConnection",(function(){return o.a})),n.d(t,"IJsonRpcProvider",(function(){return o.b}));var s=n(38);n.o(s,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return s.isHttpUrl})),n.o(s,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return s.isJsonRpcError})),n.o(s,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return s.isJsonRpcRequest})),n.o(s,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return s.isJsonRpcResponse})),n.o(s,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return s.isLocalhostUrl})),n.o(s,"isReactNative")&&n.d(t,"isReactNative",(function(){return s.isReactNative})),n.o(s,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return s.isWsUrl}))},function(e,t,n){"use strict";var r=n(42);n.d(t,"IClient",(function(){return r.a}));n(43),n(44);var i=n(45);n.d(t,"IEngine",(function(){return i.a}));var o=n(46);n.d(t,"IExpirer",(function(){return o.a}));var s=n(47);n.d(t,"IHeartBeat",(function(){return s.a}));var a=n(48);n.d(t,"IJsonRpcHistory",(function(){return a.a}));var c=n(49);n.o(c,"IPairing")&&n.d(t,"IPairing",(function(){return c.IPairing})),n.o(c,"IRelayer")&&n.d(t,"IRelayer",(function(){return c.IRelayer})),n.o(c,"ISession")&&n.d(t,"ISession",(function(){return c.ISession})),n.o(c,"IStore")&&n.d(t,"IStore",(function(){return c.IStore})),n.o(c,"ISubscriber")&&n.d(t,"ISubscriber",(function(){return c.ISubscriber}));var u=n(50);n.o(u,"IPairing")&&n.d(t,"IPairing",(function(){return u.IPairing})),n.o(u,"IRelayer")&&n.d(t,"IRelayer",(function(){return u.IRelayer})),n.o(u,"ISession")&&n.d(t,"ISession",(function(){return u.ISession})),n.o(u,"IStore")&&n.d(t,"IStore",(function(){return u.IStore})),n.o(u,"ISubscriber")&&n.d(t,"ISubscriber",(function(){return u.ISubscriber}));var h=n(51);n.d(t,"IPairing",(function(){return h.a}));n(52);var l=n(53);n.d(t,"IRelayer",(function(){return l.a}));n(18);var d=n(54);n.d(t,"ISession",(function(){return d.a}));var f=n(55);n.d(t,"IStore",(function(){return f.a}));n(56);var p=n(57);n.d(t,"ISubscriber",(function(){return p.a}))},function(e,t,n){"use strict";var r=n(58);n.d(t,"randomBytes",(function(){return r.a}));var i=n(59);n.d(t,"aesCbcDecrypt",(function(){return i.a})),n.d(t,"aesCbcEncrypt",(function(){return i.b}));var o=n(60);n.d(t,"hmacSha256Sign",(function(){return o.a})),n.d(t,"hmacSha256Verify",(function(){return o.b}));var s=n(65);n.d(t,"sha256",(function(){return s.a})),n.d(t,"sha512",(function(){return s.b}));var a=n(24);n.o(a,"ERROR_BAD_MAC")&&n.d(t,"ERROR_BAD_MAC",(function(){return a.ERROR_BAD_MAC})),n.o(a,"IV_LENGTH")&&n.d(t,"IV_LENGTH",(function(){return a.IV_LENGTH})),n.o(a,"KEY_LENGTH")&&n.d(t,"KEY_LENGTH",(function(){return a.KEY_LENGTH})),n.o(a,"LENGTH_0")&&n.d(t,"LENGTH_0",(function(){return a.LENGTH_0})),n.o(a,"MAC_LENGTH")&&n.d(t,"MAC_LENGTH",(function(){return a.MAC_LENGTH})),n.o(a,"assert")&&n.d(t,"assert",(function(){return a.assert})),n.o(a,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return a.decryptWithSharedKey})),n.o(a,"derive")&&n.d(t,"derive",(function(){return a.derive})),n.o(a,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return a.encryptWithSharedKey})),n.o(a,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return a.generateKeyPair}));var c=n(4);n.d(t,"ERROR_BAD_MAC",(function(){return c.e})),n.d(t,"IV_LENGTH",(function(){return c.i})),n.d(t,"KEY_LENGTH",(function(){return c.j})),n.d(t,"LENGTH_0",(function(){return c.k})),n.d(t,"MAC_LENGTH",(function(){return c.m}))},function(e,t,n){"use strict";function r(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return JSON.parse(e)}catch(t){return e}}function i(e){return"string"==typeof e?e:JSON.stringify(e)}n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"c",(function(){return i})),n.d(t,"b",(function(){return o})),n.d(t,"d",(function(){return s})),n.d(t,"e",(function(){return a}));const r="INTERNAL_ERROR",i="SERVER_ERROR",o=[-32700,-32600,-32601,-32602,-32603],s=[-32e3,-32099],a={PARSE_ERROR:{code:-32700,message:"Parse error"},INVALID_REQUEST:{code:-32600,message:"Invalid Request"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params"},[r]:{code:-32603,message:"Internal error"},[i]:{code:-32e3,message:"Server error"}}},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||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(78),t),i(n(79),t)},function(e,t,n){"use strict";function r(e,t,n="string"){if(!e[t]||typeof e[t]!==n)throw new Error(`Missing or invalid "${t}" param`)}function i(e,t){return Array.isArray(e)?e.length===t:Object.keys(e).length===t}function o(e,t,n="_"){const r=e.split(n);return r[r.length-1].trim().toLowerCase()===t.trim().toLowerCase()}n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return o}))},function(e,t,n){"use strict";(function(e){n.d(t,"h",(function(){return p})),n.d(t,"e",(function(){return g})),n.d(t,"d",(function(){return v})),n.d(t,"f",(function(){return m})),n.d(t,"i",(function(){return E})),n.d(t,"k",(function(){return b})),n.d(t,"j",(function(){return _})),n.d(t,"l",(function(){return w})),n.d(t,"c",(function(){return R})),n.d(t,"b",(function(){return O})),n.d(t,"m",(function(){return T})),n.d(t,"g",(function(){return S})),n.d(t,"a",(function(){return I}));var r=n(73),i=n.n(r),o=n(20),s=n(74),a=n(21);const c="react-native",u="node",h="browser",l="unknown";function d(){return void 0!==e&&void 0!==e.versions&&void 0!==e.versions.node}function f(){return!Object(a.getDocument)()&&Object(a.getNavigator)()&&"ReactNative"===navigator.product?c:d()?u:!d()&&Object(a.getNavigator)()?h:l}function p(){return Object(s.getWindowMetadata)()||void 0}function g(e,t,n,r){const i=n.split("?"),s=function(e,t){var n;const r=f(),i={protocol:e,version:t,env:r};return"browser"===r&&(i.host=(null===(n=Object(a.getLocation)())||void 0===n?void 0:n.host)||""),i}(e,t),c=r?Object.assign(Object.assign({},s),{projectId:r}):s,u=function(e,t){let n=o.parse(e);return n=Object.assign(Object.assign({},n),t),e=o.stringify(n)}(i[1]||"",c);return i[0]+"?"+u}function y(e,t=2){return function(e,t=2){return e.slice(Math.max(e.length-t,0))}(e.split("/"),t)}function v(e){return y(e).join(" ")}function m(e){return y(e).join(":")}function E(e,t){return e.filter(e=>t.includes(e)).length===e.length}function b(e,t){return i()(e,t)}function _(e){return Object.fromEntries(e.entries())}function w(e){return new Map(Object.entries(e))}const R=e=>e;function O(e){return e.split(" ").map(e=>e.trim().replace(/^\w/,e=>e.toUpperCase())).join(" ")}function T(e){return 1e3*e}function S(e){return Math.floor(e/1e3)}function I(e,t){return S((t||Date.now())+T(e))}}).call(this,n(32))},function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return a})),n.d(t,"c",(function(){return c})),n.d(t,"d",(function(){return u})),n.d(t,"e",(function(){return h})),n.d(t,"f",(function(){return l}));var r=n(10),i=n(4);async function o(e,t=i.a){return r.getSubtleCrypto().importKey("raw",e,function(e){return e===i.a?{length:i.b,name:i.a}:{hash:{name:i.g},name:i.f}}(t),!0,function(e){return e===i.a?[i.d,i.c]:[i.p,i.q]}(t))}async function s(e,t,n){const s=r.getSubtleCrypto(),a=await o(t,i.a),c=await s.encrypt({iv:e,name:i.a},a,n);return new Uint8Array(c)}async function a(e,t,n){const s=r.getSubtleCrypto(),a=await o(t,i.a),c=await s.decrypt({iv:e,name:i.a},a,n);return new Uint8Array(c)}async function c(e,t){const n=r.getSubtleCrypto(),s=await o(e,i.f),a=await n.sign({length:i.h,name:i.f},s,t);return new Uint8Array(a)}async function u(e,t){const n=r.getSubtleCrypto(),s=await o(e,i.f),a=await n.sign({length:i.l,name:i.f},s,t);return new Uint8Array(a)}async function h(e){const t=r.getSubtleCrypto(),n=await t.digest({name:i.n},e);return new Uint8Array(n)}async function l(e){const t=r.getSubtleCrypto(),n=await t.digest({name:i.o},e);return new Uint8Array(n)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"c",(function(){return a})),n.d(t,"f",(function(){return c})),n.d(t,"g",(function(){return u})),n.d(t,"d",(function(){return h})),n.d(t,"e",(function(){return l})),n.d(t,"h",(function(){return d})),n.d(t,"b",(function(){return f}));var r=n(30),i=n(2),o=n(7);function s(e,t){return r.sharedKey(e,t)}function a(e){const t=void 0!==e?function(e){return{isAvailable:!0,randomBytes:()=>e}}(e):void 0,n=r.generateKeyPair(t);return{publicKey:n.publicKey,privateKey:n.secretKey}}function c(e){const t=(null==e?void 0:e.sender)||a();return{privateKey:t.privateKey,publicKey:t.publicKey}}function u(e,t){return s(e,t)}function h(e){return new Uint8Array(e.slice(o.LENGTH_0,o.KEY_LENGTH))}function l(e){return new Uint8Array(e.slice(o.KEY_LENGTH))}function d(e){return Object(i.concatArrays)(e.iv,e.publicKey,e.mac,e.ciphertext)}function f(e){const t=o.LENGTH_0,n=t+o.IV_LENGTH,r=n+o.KEY_LENGTH,i=r+o.MAC_LENGTH,s=e.length;return{iv:e.slice(t,n),publicKey:e.slice(n,r),mac:e.slice(r,i),ciphertext:e.slice(i,s)}}},function(e,t,n){"use strict";n.d(t,"c",(function(){return i})),n.d(t,"d",(function(){return o})),n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return a})),n.d(t,"g",(function(){return c})),n.d(t,"h",(function(){return u})),n.d(t,"e",(function(){return h})),n.d(t,"f",(function(){return l}));var r=n(11);function i(e){return Object(r.c)(e,"subscribe")}function o(e){return Object(r.b)(e,1)&&"topic"in e}function s(e){return Object(r.c)(e,"publish")}function a(e){return Object(r.b)(e,3)&&"message"in e&&"topic"in e&&"ttl"in e}function c(e){return Object(r.c)(e,"unsubscribe")}function u(e){return Object(r.b)(e,2)&&"id"in e&&"topic"in e}function h(e){return Object(r.c)(e,"subscription")}function l(e){return Object(r.b)(e,2)&&"id"in e&&"data"in e}},function(e,t,n){"use strict";n.d(t,"c",(function(){return i})),n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s})),n.d(t,"d",(function(){return a}));var r=n(9);function i(e){return r.b.includes(e)}function o(e){return Object.keys(r.e).includes(e)?r.e[e]:r.e[r.a]}function s(e){const t=Object.values(r.e).find(t=>t.code===e);return t||r.e[r.a]}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";var r=n(7);n.o(r,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return r.decryptWithSharedKey})),n.o(r,"derive")&&n.d(t,"derive",(function(){return r.derive})),n.o(r,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return r.encryptWithSharedKey})),n.o(r,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return r.generateKeyPair})),n.o(r,"randomBytes")&&n.d(t,"randomBytes",(function(){return r.randomBytes})),n.o(r,"sha256")&&n.d(t,"sha256",(function(){return r.sha256}));var i=n(66);n.d(t,"decryptWithSharedKey",(function(){return i.a})),n.d(t,"encryptWithSharedKey",(function(){return i.b}));var o=n(14);n.d(t,"derive",(function(){return o.a})),n.d(t,"generateKeyPair",(function(){return o.c}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t){super(),this.client=e,this.logger=t}}},function(e,t,n){"use strict";const r=n(80);e.exports=s;const i=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},o={mapHttpRequest:p,mapHttpResponse:p,wrapRequestSerializer:g,wrapResponseSerializer:g,wrapErrorSerializer:g,req:p,res:p,err:function(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const n in e)void 0===t[n]&&(t[n]=e[n]);return t}};function s(e){(e=e||{}).browser=e.browser||{};const t=e.browser.transmit;if(t&&"function"!=typeof t.send)throw Error("pino: transmit option must have a send function");const n=e.browser.write||i;e.browser.write&&(e.browser.asObject=!0);const r=e.serializers||{},o=function(e,t){if(Array.isArray(e)){return e.filter((function(e){return"!stdSerializers.err"!==e}))}return!0===e&&Object.keys(t)}(e.browser.serialize,r);let c=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(c=!1);"function"==typeof n&&(n.error=n.fatal=n.warn=n.info=n.debug=n.trace=n),!1===e.enabled&&(e.level="silent");const l=e.level||"info",p=Object.create(n);p.log||(p.log=y),Object.defineProperty(p,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(p,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,a(g,p,"error","log"),a(g,p,"fatal","error"),a(g,p,"warn","error"),a(g,p,"info","log"),a(g,p,"debug","log"),a(g,p,"trace","log")}});const g={transmit:t,serialize:o,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:f(e)};return p.levels=s.levels,p.level=l,p.setMaxListeners=p.getMaxListeners=p.emit=p.addListener=p.on=p.prependListener=p.once=p.prependOnceListener=p.removeListener=p.removeAllListeners=p.listeners=p.listenerCount=p.eventNames=p.write=p.flush=y,p.serializers=r,p._serialize=o,p._stdErrSerialize=c,p.child=function(n,i){if(!n)throw new Error("missing bindings for child Pino");i=i||{},o&&n.serializers&&(i.serializers=n.serializers);const s=i.serializers;if(o&&s){var a=Object.assign({},r,s),c=!0===e.browser.serialize?Object.keys(a):o;delete n.serializers,u([n],c,a,this._stdErrSerialize)}function l(e){this._childLevel=1+(0|e._childLevel),this.error=h(e,n,"error"),this.fatal=h(e,n,"fatal"),this.warn=h(e,n,"warn"),this.info=h(e,n,"info"),this.debug=h(e,n,"debug"),this.trace=h(e,n,"trace"),a&&(this.serializers=a,this._serialize=c),t&&(this._logEvent=d([].concat(e._logEvent.bindings,n)))}return l.prototype=this,new l(this)},t&&(p._logEvent=d()),p}function a(e,t,n,r){const o=Object.getPrototypeOf(t);t[n]=t.levelVal>t.levels.values[n]?y:o[n]?o[n]:i[n]||i[r]||y,function(e,t,n){if(!e.transmit&&t[n]===y)return;t[n]=(r=t[n],function(){const o=e.timestamp(),a=new Array(arguments.length),h=Object.getPrototypeOf&&Object.getPrototypeOf(this)===i?i:this;for(var d=0;d<a.length;d++)a[d]=arguments[d];if(e.serialize&&!e.asObject&&u(a,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?r.call(h,c(this,n,a,o)):r.apply(h,a),e.transmit){const r=e.transmit.level||t.level,i=s.levels.values[r],c=s.levels.values[n];if(c<i)return;l(this,{ts:o,methodLevel:n,methodValue:c,transmitLevel:r,transmitValue:s.levels.values[e.transmit.level||t.level],send:e.transmit.send,val:t.levelVal},a)}});var r}(e,t,n)}function c(e,t,n,i){e._serialize&&u(n,e._serialize,e.serializers,e._stdErrSerialize);const o=n.slice();let a=o[0];const c={};i&&(c.time=i),c.level=s.levels.values[t];let h=1+(0|e._childLevel);if(h<1&&(h=1),null!==a&&"object"==typeof a){for(;h--&&"object"==typeof o[0];)Object.assign(c,o.shift());a=o.length?r(o.shift(),o):void 0}else"string"==typeof a&&(a=r(o.shift(),o));return void 0!==a&&(c.msg=a),c}function u(e,t,n,r){for(const i in e)if(r&&e[i]instanceof Error)e[i]=s.stdSerializers.err(e[i]);else if("object"==typeof e[i]&&!Array.isArray(e[i]))for(const r in e[i])t&&t.indexOf(r)>-1&&r in n&&(e[i][r]=n[r](e[i][r]))}function h(e,t,n){return function(){const r=new Array(1+arguments.length);r[0]=t;for(var i=1;i<r.length;i++)r[i]=arguments[i-1];return e[n].apply(this,r)}}function l(e,t,n){const r=t.send,i=t.ts,o=t.methodLevel,s=t.methodValue,a=t.val,c=e._logEvent.bindings;u(n,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=n.filter((function(e){return-1===c.indexOf(e)})),e._logEvent.level.label=o,e._logEvent.level.value=s,r(o,e._logEvent,a),e._logEvent=d(c)}function d(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function f(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?v:m}function p(){return{}}function g(e){return e}function y(){}function v(){return!1}function m(){return Date.now()}s.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},s.stdSerializers=o,s.stdTimeFunctions=Object.assign({},{nullTime:v,epochTime:m,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}})},function(e,t,n){"use strict";const r=n(97),i=n(98),o=n(99),s=n(100);function a(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function c(e,t){return t.encode?t.strict?r(e):encodeURIComponent(e):e}function u(e,t){return t.decode?i(e):e}function h(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function l(e){const t=(e=h(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function d(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function f(e,t){a((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const n=function(e){let t;switch(e.arrayFormat){case"index":return(e,n,r)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===r[e]&&(r[e]={}),r[e][t[1]]=n):r[e]=n};case"bracket":return(e,n,r)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==r[e]?r[e]=[].concat(r[e],n):r[e]=[n]:r[e]=n};case"comma":case"separator":return(t,n,r)=>{const i="string"==typeof n&&n.includes(e.arrayFormatSeparator),o="string"==typeof n&&!i&&u(n,e).includes(e.arrayFormatSeparator);n=o?u(n,e):n;const s=i||o?n.split(e.arrayFormatSeparator).map(t=>u(t,e)):null===n?n:u(n,e);r[t]=s};default:return(e,t,n)=>{void 0!==n[e]?n[e]=[].concat(n[e],t):n[e]=t}}}(t),r=Object.create(null);if("string"!=typeof e)return r;if(!(e=e.trim().replace(/^[?#&]/,"")))return r;for(const i of e.split("&")){if(""===i)continue;let[e,s]=o(t.decode?i.replace(/\+/g," "):i,"=");s=void 0===s?null:["comma","separator"].includes(t.arrayFormat)?s:u(s,t),n(u(e,t),s,r)}for(const e of Object.keys(r)){const n=r[e];if("object"==typeof n&&null!==n)for(const e of Object.keys(n))n[e]=d(n[e],t);else r[e]=d(n,t)}return!1===t.sort?r:(!0===t.sort?Object.keys(r).sort():Object.keys(r).sort(t.sort)).reduce((e,t)=>{const n=r[t];return Boolean(n)&&"object"==typeof n&&!Array.isArray(n)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort((e,t)=>Number(e)-Number(t)).map(e=>t[e]):t}(n):e[t]=n,e},Object.create(null))}t.extract=l,t.parse=f,t.stringify=(e,t)=>{if(!e)return"";a((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const n=n=>t.skipNull&&null==e[n]||t.skipEmptyString&&""===e[n],r=function(e){switch(e.arrayFormat){case"index":return t=>(n,r)=>{const i=n.length;return void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[c(t,e),"[",i,"]"].join("")]:[...n,[c(t,e),"[",c(i,e),"]=",c(r,e)].join("")]};case"bracket":return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[c(t,e),"[]"].join("")]:[...n,[c(t,e),"[]=",c(r,e)].join("")];case"comma":case"separator":return t=>(n,r)=>null==r||0===r.length?n:0===n.length?[[c(t,e),"=",c(r,e)].join("")]:[[n,c(r,e)].join(e.arrayFormatSeparator)];default:return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,c(t,e)]:[...n,[c(t,e),"=",c(r,e)].join("")]}}(t),i={};for(const t of Object.keys(e))n(t)||(i[t]=e[t]);const o=Object.keys(i);return!1!==t.sort&&o.sort(t.sort),o.map(n=>{const i=e[n];return void 0===i?"":null===i?c(n,t):Array.isArray(i)?i.reduce(r(n),[]).join("&"):c(n,t)+"="+c(i,t)}).filter(e=>e.length>0).join("&")},t.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[n,r]=o(e,"#");return Object.assign({url:n.split("?")[0]||"",query:f(l(e),t)},t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:u(r,t)}:{})},t.stringifyUrl=(e,n)=>{n=Object.assign({encode:!0,strict:!0},n);const r=h(e.url).split("?")[0]||"",i=t.extract(e.url),o=t.parse(i,{sort:!1}),s=Object.assign(o,e.query);let a=t.stringify(s,n);a&&(a="?"+a);let u=function(e){let t="";const n=e.indexOf("#");return-1!==n&&(t=e.slice(n)),t}(e.url);return e.fragmentIdentifier&&(u="#"+c(e.fragmentIdentifier,n)),`${r}${a}${u}`},t.pick=(e,n,r)=>{r=Object.assign({parseFragmentIdentifier:!0},r);const{url:i,query:o,fragmentIdentifier:a}=t.parseUrl(e,r);return t.stringifyUrl({url:i,query:s(o,n),fragmentIdentifier:a},r)},t.exclude=(e,n,r)=>{const i=Array.isArray(n)?e=>!n.includes(e):(e,t)=>!n(e,t);return t.pick(e,i,r)}},function(e,t,n){"use strict";function r(e){let t=void 0;return"undefined"!=typeof window&&void 0!==window[e]&&(t=window[e]),t}function i(e){const t=r(e);if(!t)throw new Error(e+" is not defined in Window");return t}Object.defineProperty(t,"__esModule",{value:!0}),t.getLocalStorage=t.getLocalStorageOrThrow=t.getCrypto=t.getCryptoOrThrow=t.getLocation=t.getLocationOrThrow=t.getNavigator=t.getNavigatorOrThrow=t.getDocument=t.getDocumentOrThrow=t.getFromWindowOrThrow=t.getFromWindow=void 0,t.getFromWindow=r,t.getFromWindowOrThrow=i,t.getDocumentOrThrow=function(){return i("document")},t.getDocument=function(){return r("document")},t.getNavigatorOrThrow=function(){return i("navigator")},t.getNavigator=function(){return r("navigator")},t.getLocationOrThrow=function(){return i("location")},t.getLocation=function(){return r("location")},t.getCryptoOrThrow=function(){return i("crypto")},t.getCrypto=function(){return r("crypto")},t.getLocalStorageOrThrow=function(){return i("localStorage")},t.getLocalStorage=function(){return r("localStorage")}},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";n.d(t,"a",(function(){return r}));class r{}},function(e,t,n){"use strict";var r=n(61);n.o(r,"ERROR_BAD_MAC")&&n.d(t,"ERROR_BAD_MAC",(function(){return r.ERROR_BAD_MAC})),n.o(r,"IV_LENGTH")&&n.d(t,"IV_LENGTH",(function(){return r.IV_LENGTH})),n.o(r,"KEY_LENGTH")&&n.d(t,"KEY_LENGTH",(function(){return r.KEY_LENGTH})),n.o(r,"LENGTH_0")&&n.d(t,"LENGTH_0",(function(){return r.LENGTH_0})),n.o(r,"MAC_LENGTH")&&n.d(t,"MAC_LENGTH",(function(){return r.MAC_LENGTH})),n.o(r,"assert")&&n.d(t,"assert",(function(){return r.assert})),n.o(r,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return r.decryptWithSharedKey})),n.o(r,"derive")&&n.d(t,"derive",(function(){return r.derive})),n.o(r,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return r.encryptWithSharedKey})),n.o(r,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return r.generateKeyPair})),n.o(r,"isConstantTime")&&n.d(t,"isConstantTime",(function(){return r.isConstantTime}));n(62);var i=n(63);n.o(i,"ERROR_BAD_MAC")&&n.d(t,"ERROR_BAD_MAC",(function(){return i.ERROR_BAD_MAC})),n.o(i,"IV_LENGTH")&&n.d(t,"IV_LENGTH",(function(){return i.IV_LENGTH})),n.o(i,"KEY_LENGTH")&&n.d(t,"KEY_LENGTH",(function(){return i.KEY_LENGTH})),n.o(i,"LENGTH_0")&&n.d(t,"LENGTH_0",(function(){return i.LENGTH_0})),n.o(i,"MAC_LENGTH")&&n.d(t,"MAC_LENGTH",(function(){return i.MAC_LENGTH})),n.o(i,"assert")&&n.d(t,"assert",(function(){return i.assert})),n.o(i,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return i.decryptWithSharedKey})),n.o(i,"derive")&&n.d(t,"derive",(function(){return i.derive})),n.o(i,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return i.encryptWithSharedKey})),n.o(i,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return i.generateKeyPair})),n.o(i,"isConstantTime")&&n.d(t,"isConstantTime",(function(){return i.isConstantTime}));var o=n(64);n.d(t,"assert",(function(){return o.a})),n.d(t,"isConstantTime",(function(){return o.b}))},function(e,t,n){"use strict";(function(e){var r=n(3),i=n(8),o=n(0);const s=void 0!==e.WebSocket?e.WebSocket:n(102);t.a=class{constructor(e){if(this.url=e,this.events=new r.EventEmitter,this.registering=!1,!Object(o.isWsUrl)(e))throw new Error("Provided URL is not compatible with WebSocket connection: "+e);this.url=e}get connected(){return void 0!==this.socket}get connecting(){return this.registering}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)}async open(e=this.url){await this.register(e)}async close(){if(void 0===this.socket)throw new Error("Connection already closed");this.socket.close(),this.onClose()}async send(e,t){void 0===this.socket&&(this.socket=await this.register());try{this.socket.send(Object(i.b)(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Object(o.isWsUrl)(e))throw new Error("Provided URL is not compatible with WebSocket connection: "+e);return this.registering?new Promise((e,t)=>{this.events.once("register_error",e=>{t(e)}),this.events.once("open",()=>{if(void 0===this.socket)return t(new Error("WebSocket connection is missing or invalid"));e(this.socket)})}):(this.url=e,this.registering=!0,new Promise((t,n)=>{const r=Object(o.isReactNative)()?void 0:{rejectUnauthorized:!Object(o.isLocalhostUrl)(e)},i=new s(e,[],r);i.onopen=()=>{this.onOpen(i),t(i)},i.onerror=e=>{const t=this.parseError(e.error);this.events.emit("register_error",t),this.onClose(),n(t)}}))}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=()=>this.onClose(),e.onerror=e=>{const t=this.parseError(e.error);this.events.emit("error",t)},this.socket=e,this.registering=!1,this.events.emit("open")}onClose(){this.socket=void 0,this.registering=!1,this.events.emit("close")}onPayload(e){if(void 0===e.data)return;const t="string"==typeof e.data?Object(i.a)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const n=this.parseError(t),r=n.message||n.toString(),i=Object(o.formatJsonRpcError)(e,r);this.events.emit("payload",i)}parseError(e,t=this.url){return Object(o.parseConnectionError)(e,t,"WS")}}}).call(this,n(22))},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(n(81)),s=n(41),a=n(82);class c{constructor(){this.localStorage=o.default}getKeys(){return r(this,void 0,void 0,(function*(){return Object.keys(this.localStorage)}))}getEntries(){return r(this,void 0,void 0,(function*(){return Object.entries(this.localStorage).map(a.parseEntry)}))}getItem(e){return r(this,void 0,void 0,(function*(){const t=this.localStorage.getItem(e);if(null!==t)return s.safeJsonParse(t)}))}setItem(e,t){return r(this,void 0,void 0,(function*(){this.localStorage.setItem(e,s.safeJsonStringify(t))}))}removeItem(e){return r(this,void 0,void 0,(function*(){this.localStorage.removeItem(e)}))}}t.KeyValueStorage=c,t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wipe=function(e){for(var t=0;t<e.length;t++)e[t]=0;return e}},function(e,t,n){"use strict";n.r(t),n.d(t,"JsonRpcProvider",(function(){return o}));var r=n(3),i=n(0);class o extends i.IJsonRpcProvider{constructor(e){super(e),this.events=new r.EventEmitter,this.connection=this.setConnection(e)}async connect(e=this.connection){await this.open(e)}async disconnect(){await 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)}async request(e,t){return this.requestStrict(Object(i.formatJsonRpcRequest)(e.method,e.params||[]),t)}async requestStrict(e,t){return new Promise(async(n,r)=>{if(!this.connection.connected)try{await this.open()}catch(e){r(e)}this.events.on(""+e.id,e=>{Object(i.isJsonRpcError)(e)?r(e.error.message):n(e.result)});try{await this.connection.send(e,t)}catch(e){r(e)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Object(i.isJsonRpcResponse)(e)?this.events.emit(""+e.id,e):this.events.emit("message",{type:e.method,data:e.params})}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",()=>this.events.emit("disconnect")),this.connection.on("error",e=>this.events.emit("error",e)),this.events.emit("connect"))}async close(){await this.connection.close(),this.events.emit("disconnect")}}var s=o;t.default=s},function(e,t){var n="undefined"!=typeof self?self:this,r=function(){function e(){this.fetch=!1,this.DOMException=n.DOMException}return e.prototype=n,new e}();!function(e){!function(t){var n="URLSearchParams"in e,r="Symbol"in e&&"iterator"in Symbol,i="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),o="FormData"in e,s="ArrayBuffer"in e;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function h(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function g(e){var t=new FileReader,n=p(t);return t.readAsArrayBuffer(e),n}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:o&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():s&&i&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var e,t,n,r=f(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=p(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=u(e),t=h(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},d.prototype.delete=function(e){delete this.map[u(e)]},d.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},d.prototype.set=function(e,t){this.map[u(e)]=h(t)},d.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),l(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),l(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),l(e)},r&&(d.prototype[Symbol.iterator]=d.prototype.entries);var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function E(e,t){var n,r,i=(t=t||{}).body;if(e instanceof E){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),m.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function b(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}E.prototype.clone=function(){return new E(this,{body:this._bodyInit})},v.call(E.prototype),v.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var w=[301,302,303,307,308];_.redirect=function(e,t){if(-1===w.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function R(e,n){return new Promise((function(r,o){var s=new E(e,n);if(s.signal&&s.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var e,t,n={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();t.append(r,i)}})),t)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;r(new _(i,n))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),s.signal&&(s.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",c)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}R.polyfill=!0,e.fetch||(e.fetch=R,e.Headers=d,e.Request=E,e.Response=_),t.Headers=d,t.Request=E,t.Response=_,t.fetch=R,Object.defineProperty(t,"__esModule",{value:!0})}({})}(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=r;(t=i.fetch).default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,e.exports=t},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(90),i=n(27);function o(e){var t=new Float64Array(16);if(e)for(var n=0;n<e.length;n++)t[n]=e[n];return t}t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;var s=new Uint8Array(32);s[0]=9;var a=o([56129,1]);function c(e){for(var t=1,n=0;n<16;n++){var r=e[n]+t+65535;t=Math.floor(r/65536),e[n]=r-65536*t}e[0]+=t-1+37*(t-1)}function u(e,t,n){for(var r=~(n-1),i=0;i<16;i++){var o=r&(e[i]^t[i]);e[i]^=o,t[i]^=o}}function h(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function l(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function d(e,t,n){var r,i,o=0,s=0,a=0,c=0,u=0,h=0,l=0,d=0,f=0,p=0,g=0,y=0,v=0,m=0,E=0,b=0,_=0,w=0,R=0,O=0,T=0,S=0,I=0,N=0,A=0,P=0,U=0,C=0,D=0,L=0,j=0,x=n[0],q=n[1],M=n[2],H=n[3],K=n[4],J=n[5],B=n[6],G=n[7],k=n[8],V=n[9],F=n[10],z=n[11],Y=n[12],W=n[13],$=n[14],Q=n[15];o+=(r=t[0])*x,s+=r*q,a+=r*M,c+=r*H,u+=r*K,h+=r*J,l+=r*B,d+=r*G,f+=r*k,p+=r*V,g+=r*F,y+=r*z,v+=r*Y,m+=r*W,E+=r*$,b+=r*Q,s+=(r=t[1])*x,a+=r*q,c+=r*M,u+=r*H,h+=r*K,l+=r*J,d+=r*B,f+=r*G,p+=r*k,g+=r*V,y+=r*F,v+=r*z,m+=r*Y,E+=r*W,b+=r*$,_+=r*Q,a+=(r=t[2])*x,c+=r*q,u+=r*M,h+=r*H,l+=r*K,d+=r*J,f+=r*B,p+=r*G,g+=r*k,y+=r*V,v+=r*F,m+=r*z,E+=r*Y,b+=r*W,_+=r*$,w+=r*Q,c+=(r=t[3])*x,u+=r*q,h+=r*M,l+=r*H,d+=r*K,f+=r*J,p+=r*B,g+=r*G,y+=r*k,v+=r*V,m+=r*F,E+=r*z,b+=r*Y,_+=r*W,w+=r*$,R+=r*Q,u+=(r=t[4])*x,h+=r*q,l+=r*M,d+=r*H,f+=r*K,p+=r*J,g+=r*B,y+=r*G,v+=r*k,m+=r*V,E+=r*F,b+=r*z,_+=r*Y,w+=r*W,R+=r*$,O+=r*Q,h+=(r=t[5])*x,l+=r*q,d+=r*M,f+=r*H,p+=r*K,g+=r*J,y+=r*B,v+=r*G,m+=r*k,E+=r*V,b+=r*F,_+=r*z,w+=r*Y,R+=r*W,O+=r*$,T+=r*Q,l+=(r=t[6])*x,d+=r*q,f+=r*M,p+=r*H,g+=r*K,y+=r*J,v+=r*B,m+=r*G,E+=r*k,b+=r*V,_+=r*F,w+=r*z,R+=r*Y,O+=r*W,T+=r*$,S+=r*Q,d+=(r=t[7])*x,f+=r*q,p+=r*M,g+=r*H,y+=r*K,v+=r*J,m+=r*B,E+=r*G,b+=r*k,_+=r*V,w+=r*F,R+=r*z,O+=r*Y,T+=r*W,S+=r*$,I+=r*Q,f+=(r=t[8])*x,p+=r*q,g+=r*M,y+=r*H,v+=r*K,m+=r*J,E+=r*B,b+=r*G,_+=r*k,w+=r*V,R+=r*F,O+=r*z,T+=r*Y,S+=r*W,I+=r*$,N+=r*Q,p+=(r=t[9])*x,g+=r*q,y+=r*M,v+=r*H,m+=r*K,E+=r*J,b+=r*B,_+=r*G,w+=r*k,R+=r*V,O+=r*F,T+=r*z,S+=r*Y,I+=r*W,N+=r*$,A+=r*Q,g+=(r=t[10])*x,y+=r*q,v+=r*M,m+=r*H,E+=r*K,b+=r*J,_+=r*B,w+=r*G,R+=r*k,O+=r*V,T+=r*F,S+=r*z,I+=r*Y,N+=r*W,A+=r*$,P+=r*Q,y+=(r=t[11])*x,v+=r*q,m+=r*M,E+=r*H,b+=r*K,_+=r*J,w+=r*B,R+=r*G,O+=r*k,T+=r*V,S+=r*F,I+=r*z,N+=r*Y,A+=r*W,P+=r*$,U+=r*Q,v+=(r=t[12])*x,m+=r*q,E+=r*M,b+=r*H,_+=r*K,w+=r*J,R+=r*B,O+=r*G,T+=r*k,S+=r*V,I+=r*F,N+=r*z,A+=r*Y,P+=r*W,U+=r*$,C+=r*Q,m+=(r=t[13])*x,E+=r*q,b+=r*M,_+=r*H,w+=r*K,R+=r*J,O+=r*B,T+=r*G,S+=r*k,I+=r*V,N+=r*F,A+=r*z,P+=r*Y,U+=r*W,C+=r*$,D+=r*Q,E+=(r=t[14])*x,b+=r*q,_+=r*M,w+=r*H,R+=r*K,O+=r*J,T+=r*B,S+=r*G,I+=r*k,N+=r*V,A+=r*F,P+=r*z,U+=r*Y,C+=r*W,D+=r*$,L+=r*Q,b+=(r=t[15])*x,s+=38*(w+=r*M),a+=38*(R+=r*H),c+=38*(O+=r*K),u+=38*(T+=r*J),h+=38*(S+=r*B),l+=38*(I+=r*G),d+=38*(N+=r*k),f+=38*(A+=r*V),p+=38*(P+=r*F),g+=38*(U+=r*z),y+=38*(C+=r*Y),v+=38*(D+=r*W),m+=38*(L+=r*$),E+=38*(j+=r*Q),o=(r=(o+=38*(_+=r*q))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),s=(r=s+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),E=(r=E+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),o=(r=(o+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),s=(r=s+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),E=(r=E+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),o+=i-1+37*(i-1),e[0]=o,e[1]=s,e[2]=a,e[3]=c,e[4]=u,e[5]=h,e[6]=l,e[7]=d,e[8]=f,e[9]=p,e[10]=g,e[11]=y,e[12]=v,e[13]=m,e[14]=E,e[15]=b}function f(e,t){d(e,t,t)}function p(e,t){for(var n=new Uint8Array(32),r=new Float64Array(80),i=o(),s=o(),p=o(),g=o(),y=o(),v=o(),m=0;m<31;m++)n[m]=e[m];n[31]=127&e[31]|64,n[0]&=248,function(e,t){for(var n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}(r,t);for(m=0;m<16;m++)s[m]=r[m];i[0]=g[0]=1;for(m=254;m>=0;--m){var E=n[m>>>3]>>>(7&m)&1;u(i,s,E),u(p,g,E),h(y,i,p),l(i,i,p),h(p,s,g),l(s,s,g),f(g,y),f(v,i),d(i,p,i),d(p,s,y),h(y,i,p),l(i,i,p),f(s,i),l(p,g,v),d(i,p,a),h(i,i,g),d(p,p,i),d(i,g,v),d(g,s,r),f(s,y),u(i,s,E),u(p,g,E)}for(m=0;m<16;m++)r[m+16]=i[m],r[m+32]=p[m],r[m+48]=s[m],r[m+64]=g[m];var b=r.subarray(32),_=r.subarray(16);!function(e,t){for(var n=o(),r=0;r<16;r++)n[r]=t[r];for(r=253;r>=0;r--)f(n,n),2!==r&&4!==r&&d(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}(b,b),d(_,_,b);var w=new Uint8Array(32);return function(e,t){for(var n=o(),r=o(),i=0;i<16;i++)r[i]=t[i];c(r),c(r),c(r);for(var s=0;s<2;s++){n[0]=r[0]-65517;for(i=1;i<15;i++)n[i]=r[i]-65535-(n[i-1]>>16&1),n[i-1]&=65535;n[15]=r[15]-32767-(n[14]>>16&1);var a=n[15]>>16&1;n[14]&=65535,u(r,n,1-a)}for(i=0;i<16;i++)e[2*i]=255&r[i],e[2*i+1]=r[i]>>8}(w,_),w}function g(e){return p(e,s)}function y(e){if(e.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var n=new Uint8Array(e);return{publicKey:g(n),secretKey:n}}t.scalarMult=p,t.scalarMultBase=g,t.generateKeyPairFromSeed=y,t.generateKeyPair=function(e){var t=r.randomBytes(32,e),n=y(t);return i.wipe(t),n},t.sharedKey=function(e,n,r){if(void 0===r&&(r=!1),e.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(n.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var i=p(e,n);if(r){for(var o=0,s=0;s<i.length;s++)o|=i[s];if(0===o)throw new Error("X25519: invalid shared key")}return i}},function(e,t,n){"use strict";var r=n(10);n.o(r,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return r.IJsonRpcProvider})),n.o(r,"formatJsonRpcError")&&n.d(t,"formatJsonRpcError",(function(){return r.formatJsonRpcError})),n.o(r,"formatJsonRpcRequest")&&n.d(t,"formatJsonRpcRequest",(function(){return r.formatJsonRpcRequest})),n.o(r,"formatJsonRpcResult")&&n.d(t,"formatJsonRpcResult",(function(){return r.formatJsonRpcResult})),n.o(r,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return r.isHttpUrl})),n.o(r,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return r.isJsonRpcError})),n.o(r,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return r.isJsonRpcRequest})),n.o(r,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return r.isJsonRpcResponse})),n.o(r,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return r.isLocalhostUrl})),n.o(r,"isReactNative")&&n.d(t,"isReactNative",(function(){return r.isReactNative})),n.o(r,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return r.isWsUrl}));r.isNode},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!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:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,u=[],h=!1,l=-1;function d(){h&&c&&(h=!1,c.length?u=c.concat(u):l=-1,u.length&&f())}function f(){if(!h){var e=a(d);h=!0;for(var t=u.length;t;){for(c=u,u=[];++l<t;)c&&c[l].run();l=-1,t=u.length}c=null,h=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!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 p(e,t){this.fun=e,this.array=t}function g(){}i.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];u.push(new p(e,t)),1!==u.length||h||a(f)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"c",(function(){return s})),n.d(t,"a",(function(){return a}));var r=n(16),i=n(9);function o(e,t,n){return{id:n||Date.now()*Math.pow(10,3)+Math.floor(Math.random()*Math.pow(10,3)),jsonrpc:"2.0",method:e,params:t}}function s(e,t){return{id:e,jsonrpc:"2.0",result:t}}function a(e,t){return{id:e,jsonrpc:"2.0",error:c(t)}}function c(e){return void 0===e?Object(r.a)(i.a):("string"==typeof e&&(e=Object.assign(Object.assign({},Object(r.a)(i.c)),{message:e})),Object(r.c)(e.code)&&(e=Object(r.b)(e.code)),e)}},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r=n(5);n.o(r,"IJsonRpcProvider")&&n.d(t,"IJsonRpcProvider",(function(){return r.IJsonRpcProvider})),n.o(r,"isHttpUrl")&&n.d(t,"isHttpUrl",(function(){return r.isHttpUrl})),n.o(r,"isJsonRpcError")&&n.d(t,"isJsonRpcError",(function(){return r.isJsonRpcError})),n.o(r,"isJsonRpcRequest")&&n.d(t,"isJsonRpcRequest",(function(){return r.isJsonRpcRequest})),n.o(r,"isJsonRpcResponse")&&n.d(t,"isJsonRpcResponse",(function(){return r.isJsonRpcResponse})),n.o(r,"isLocalhostUrl")&&n.d(t,"isLocalhostUrl",(function(){return r.isLocalhostUrl})),n.o(r,"isReactNative")&&n.d(t,"isReactNative",(function(){return r.isReactNative})),n.o(r,"isWsUrl")&&n.d(t,"isWsUrl",(function(){return r.isWsUrl}))},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return s}));var r=n(23);class i extends r.a{constructor(e){super()}}class o extends r.a{constructor(){super()}}class s extends o{constructor(e){super()}}},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"c",(function(){return o})),n.d(t,"b",(function(){return s}));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 i(e){return r(e,"^https?:")}function o(e){return r(e,"^wss?:")}function s(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}},function(e,t,n){"use strict";function r(e){return"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function i(e){return r(e)&&"method"in e}function o(e){return r(e)&&(function(e){return"result"in e}(e)||s(e))}function s(e){return"error"in e}n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return s}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeJsonParse=function(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return JSON.parse(e)}catch(t){return e}},t.safeJsonStringify=function(e){return"string"==typeof e?e:JSON.stringify(e,(e,t)=>void 0===t?null:t)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e){super(),this.protocol="wc",this.version=2}}},function(e,t,n){"use strict"},function(e,t,n){"use strict"},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{constructor(e){this.sequence=e}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t){super(),this.client=e,this.logger=t}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e){super()}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t){super(),this.logger=e,this.storage=t,this.records=new Map}}},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(18);class i extends r.a{}},function(e,t,n){"use strict";var r=n(5);r.IEvents},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e){super()}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(18);class i extends r.a{}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t,n){super(),this.client=e,this.logger=t,this.name=n}}},function(e,t,n){"use strict"},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);class i extends r.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(10);function i(e){return r.getBrowerCrypto().getRandomValues(new Uint8Array(e))}},function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return o}));var r=n(13);function i(e,t,n){return Object(r.b)(e,t,n)}function o(e,t,n){return Object(r.a)(e,t,n)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return s}));var r=n(13),i=n(24);async function o(e,t){return await Object(r.c)(e,t)}async function s(e,t,n){const o=await Object(r.c)(e,t);return Object(i.isConstantTime)(o,n)}},function(e,t,n){"use strict";var r=n(10);n.o(r,"ERROR_BAD_MAC")&&n.d(t,"ERROR_BAD_MAC",(function(){return r.ERROR_BAD_MAC})),n.o(r,"IV_LENGTH")&&n.d(t,"IV_LENGTH",(function(){return r.IV_LENGTH})),n.o(r,"KEY_LENGTH")&&n.d(t,"KEY_LENGTH",(function(){return r.KEY_LENGTH})),n.o(r,"LENGTH_0")&&n.d(t,"LENGTH_0",(function(){return r.LENGTH_0})),n.o(r,"MAC_LENGTH")&&n.d(t,"MAC_LENGTH",(function(){return r.MAC_LENGTH})),n.o(r,"assert")&&n.d(t,"assert",(function(){return r.assert})),n.o(r,"decryptWithSharedKey")&&n.d(t,"decryptWithSharedKey",(function(){return r.decryptWithSharedKey})),n.o(r,"derive")&&n.d(t,"derive",(function(){return r.derive})),n.o(r,"encryptWithSharedKey")&&n.d(t,"encryptWithSharedKey",(function(){return r.encryptWithSharedKey})),n.o(r,"generateKeyPair")&&n.d(t,"generateKeyPair",(function(){return r.generateKeyPair})),n.o(r,"isConstantTime")&&n.d(t,"isConstantTime",(function(){return r.isConstantTime}))},function(e,t,n){"use strict"},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return o}));var r=n(13);async function i(e){return await Object(r.e)(e)}async function o(e){return await Object(r.f)(e)}},function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return c}));var r=n(7),i=n(2),o=n(14);async function s(e){const t=await Object(r.sha512)(e);return{encryptionKey:Object(o.d)(t),macKey:Object(o.e)(t)}}async function a(e,t,n,a=Object(r.randomBytes)(r.IV_LENGTH)){const{encryptionKey:c,macKey:u}=await s(t),h=await Object(r.aesCbcEncrypt)(a,c,e),l=Object(i.concatArrays)(a,n,h),d=await Object(r.hmacSha256Sign)(u,l);return Object(o.h)({iv:a,publicKey:n,ciphertext:h,mac:d})}async function c(e,t){const{iv:n,publicKey:a,mac:c,ciphertext:u}=Object(o.b)(e),{encryptionKey:h,macKey:l}=await s(t),d=Object(i.concatArrays)(n,a,u),f=await Object(r.hmacSha256Verify)(l,d,c);Object(r.assert)(f,r.ERROR_BAD_MAC);return await Object(r.aesCbcDecrypt)(n,h,u)}},function(e,t,n){"use strict";(function(e){
|
|
2
2
|
/*!
|
|
3
3
|
* The buffer module from node.js, for the browser.
|
|
4
4
|
*
|
|
5
5
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
|
-
var r=n(86),i=n(87),o=n(88);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=d(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(t,n),i=(e=a(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(c.isBuffer(t)){var n=0|f(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):d(e,t);if("Buffer"===t.type&&o(t.data))return d(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(h(t),e=a(e,t<0?0:0|f(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function d(e,t){var n=t.length<0?0:0|f(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function f(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(e).length;default:if(r)return K(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,n);case"utf8":case"utf-8":return S(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return N(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:m(e,t,n,r,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):m(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=n;o<a;o++)if(u(e,o)===u(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===c)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var l=!0,d=0;d<c;d++)if(u(e,o+d)!==u(t,d)){l=!1;break}if(l)return o}return-1}function E(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function b(e,t,n,r){return B(K(t,e.length-n),e,n,r)}function _(e,t,n,r){return B(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function w(e,t,n,r){return _(e,t,n,r)}function R(e,t,n,r){return B(J(t),e,n,r)}function O(e,t,n,r){return B(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function T(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function S(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,u=e[i],h=null,l=u>239?4:u>223?3:u>191?2:1;if(i+l<=n)switch(l){case 1:u<128&&(h=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(h=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,l=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return h(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},c.allocUnsafe=function(e){return l(null,e)},c.allocUnsafeSlow=function(e){return l(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?S(this,0,e):g.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,n,r,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(r,i),h=e.slice(t,n),l=0;l<a;++l)if(u[l]!==h[l]){o=u[l],s=h[l];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return v(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return v(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return _(this,e,t,n);case"latin1":case"binary":return w(this,e,t,n);case"base64":return R(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function N(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function A(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=H(e[o]);return i}function P(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function U(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function C(e,t,n,r,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function D(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function L(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function j(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function x(e,t,n,r,o){return o||j(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function q(e,t,n,r,o){return o||j(e,0,n,8),i.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;n=new c(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},c.prototype.readUInt8=function(e,t){return t||U(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||U(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||U(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||U(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||U(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||U(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||U(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||U(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||U(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||C(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||C(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):L(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);C(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);C(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return x(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return x(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=c.isBuffer(e)?e:K(new c(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function K(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function J(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function B(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(22))},function(e,t){e.exports=i,i.strict=o,i.loose=s;var n=Object.prototype.toString,r={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function i(e){return o(e)||s(e)}function o(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return r[n.call(e)]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PINO_CUSTOM_CONTEXT_KEY=t.PINO_LOGGER_DEFAULTS=void 0,t.PINO_LOGGER_DEFAULTS={level:"info",prettyPrint:{colorize:!0,translateTime:"SYS:standard",ignore:"pid,hostname"}},t.PINO_CUSTOM_CONTEXT_KEY="custom_context"},function(e,t){},function(e,t,n){"use strict";n(11),n(15)},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r={waku:{info:"waku_info",connect:"waku_connect",disconnect:"waku_disconnect",publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"}}},function(e,t,n){(function(t){var n=/^\[object .+?Constructor\]$/,r="object"==typeof t&&t&&t.Object===Object&&t,i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();function s(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function a(e,t){return!!(e?e.length:0)&&function(e,t,n){if(t!=t)return function(e,t,n,r){var i=e.length,o=n+(r?1:-1);for(;r?o--:++o<i;)if(t(e[o],o,e))return o;return-1}(e,h,n);var r=n-1,i=e.length;for(;++r<i;)if(e[r]===t)return r;return-1}(e,t,0)>-1}function c(e,t,n){for(var r=-1,i=e?e.length:0;++r<i;)if(n(t,e[r]))return!0;return!1}function u(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function h(e){return e!=e}function l(e,t){return e.has(t)}function d(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var f,p=Array.prototype,g=Function.prototype,y=Object.prototype,v=o["__core-js_shared__"],m=(f=/[^.]+$/.exec(v&&v.keys&&v.keys.IE_PROTO||""))?"Symbol(src)_1."+f:"",E=g.toString,b=y.hasOwnProperty,_=y.toString,w=RegExp("^"+E.call(b).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),R=o.Symbol,O=y.propertyIsEnumerable,T=p.splice,S=R?R.isConcatSpreadable:void 0,I=Math.max,N=H(o,"Map"),A=H(o,"Set"),P=H(Object,"create");function U(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function C(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function D(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function L(e){var t=-1,n=e?e.length:0;for(this.__data__=new D;++t<n;)this.add(e[t])}function j(e,t){for(var n,r,i=e.length;i--;)if((n=e[i][0])===(r=t)||n!=n&&r!=r)return i;return-1}function x(e){return!(!Y(e)||(t=e,m&&m in t))&&(z(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?w:n).test(function(e){if(null!=e){try{return E.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}U.prototype.clear=function(){this.__data__=P?P(null):{}},U.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},U.prototype.get=function(e){var t=this.__data__;if(P){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return b.call(t,e)?t[e]:void 0},U.prototype.has=function(e){var t=this.__data__;return P?void 0!==t[e]:b.call(t,e)},U.prototype.set=function(e,t){return this.__data__[e]=P&&void 0===t?"__lodash_hash_undefined__":t,this},C.prototype.clear=function(){this.__data__=[]},C.prototype.delete=function(e){var t=this.__data__,n=j(t,e);return!(n<0)&&(n==t.length-1?t.pop():T.call(t,n,1),!0)},C.prototype.get=function(e){var t=this.__data__,n=j(t,e);return n<0?void 0:t[n][1]},C.prototype.has=function(e){return j(this.__data__,e)>-1},C.prototype.set=function(e,t){var n=this.__data__,r=j(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},D.prototype.clear=function(){this.__data__={hash:new U,map:new(N||C),string:new U}},D.prototype.delete=function(e){return M(this,e).delete(e)},D.prototype.get=function(e){return M(this,e).get(e)},D.prototype.has=function(e){return M(this,e).has(e)},D.prototype.set=function(e,t){return M(this,e).set(e,t),this},L.prototype.add=L.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},L.prototype.has=function(e){return this.__data__.has(e)};var q=A&&1/d(new A([,-0]))[1]==1/0?function(e){return new A(e)}:function(){};function M(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function H(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return x(n)?n:void 0}function K(e){return k(e)||function(e){return F(e)&&b.call(e,"callee")&&(!O.call(e,"callee")||"[object Arguments]"==_.call(e))}(e)||!!(S&&e&&e[S])}var J,B,G=(J=function(e){return function(e,t,n){var r=-1,i=a,o=e.length,s=!0,u=[],h=u;if(n)s=!1,i=c;else if(o>=200){var f=t?null:q(e);if(f)return d(f);s=!1,i=l,h=new L}else h=t?[]:u;e:for(;++r<o;){var p=e[r],g=t?t(p):p;if(p=n||0!==p?p:0,s&&g==g){for(var y=h.length;y--;)if(h[y]===g)continue e;t&&h.push(g),u.push(p)}else i(h,g,n)||(h!==u&&h.push(g),u.push(p))}return u}(function e(t,n,r,i,o){var s=-1,a=t.length;for(r||(r=K),o||(o=[]);++s<a;){var c=t[s];n>0&&r(c)?n>1?e(c,n-1,r,i,o):u(o,c):i||(o[o.length]=c)}return o}(e,1,F,!0))},B=I(void 0===B?J.length-1:B,0),function(){for(var e=arguments,t=-1,n=I(e.length-B,0),r=Array(n);++t<n;)r[t]=e[B+t];t=-1;for(var i=Array(B+1);++t<B;)i[t]=e[t];return i[B]=r,s(J,this,i)});var k=Array.isArray;function V(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}(e.length)&&!z(e)}function F(e){return function(e){return!!e&&"object"==typeof e}(e)&&V(e)}function z(e){var t=Y(e)?_.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}function Y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=G}).call(this,n(22))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWindowMetadata=void 0;const r=n(21);t.getWindowMetadata=function(){let e,t;try{e=r.getDocumentOrThrow(),t=r.getLocationOrThrow()}catch(e){return null}function n(...t){const n=e.getElementsByTagName("meta");for(let e=0;e<n.length;e++){const r=n[e],i=["itemprop","property","name"].map(e=>r.getAttribute(e)).filter(e=>!!e&&t.includes(e));if(i.length&&i){const e=r.getAttribute("content");if(e)return e}}return""}const i=function(){let t=n("name","og:site_name","og:title","twitter:title");return t||(t=e.title),t}();return{description:n("description","og:description","twitter:description","keywords"),url:t.origin,icons:function(){const n=e.getElementsByTagName("link"),r=[];for(let e=0;e<n.length;e++){const i=n[e],o=i.getAttribute("rel");if(o&&o.toLowerCase().indexOf("icon")>-1){const e=i.getAttribute("href");if(e)if(-1===e.toLowerCase().indexOf("https:")&&-1===e.toLowerCase().indexOf("http:")&&0!==e.indexOf("//")){let n=t.protocol+"//"+t.host;if(0===e.indexOf("/"))n+=e;else{const r=t.pathname.split("/");r.pop();n+=r.join("/")+"/"+e}r.push(n)}else if(0===e.indexOf("//")){const n=t.protocol+e;r.push(n)}else r.push(e)}}return r}(),name:i}}},function(e,t,n){"use strict";var r=n(70);n.o(r,"RELAY_JSONRPC")&&n.d(t,"RELAY_JSONRPC",(function(){return r.RELAY_JSONRPC}));n(71);var i=n(72);n.d(t,"RELAY_JSONRPC",(function(){return i.a}));n(15)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRpcUrl=t.getInfuraRpcUrl=t.providerEvents=t.infuraNetworks=t.signerMethods=void 0;const r=n(77),i=n(3),o=n(28),s=n(104),a=n(103);function c(e,n){let r;const i=t.infuraNetworks[e];return i&&(r=`https://${i}.infura.io/v3/${n}`),r}function u(e,t){let n;const r=c(e,null==t?void 0:t.infuraId);return t&&t.custom?n=t.custom[e]:r&&(n=r),n}t.signerMethods=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],t.infuraNetworks={1:"mainnet",3:"ropsten",4:"rinkeby",5:"goerli",42:"kovan"},t.providerEvents={changed:{chain:"chainChanged",accounts:"accountsChanged"}},t.getInfuraRpcUrl=c,t.getRpcUrl=u;t.default=class{constructor(e){this.events=new i.EventEmitter,this.namespace="eip155",this.chainId=1,this.methods=t.signerMethods,this.accounts=[],this.rpc=null==e?void 0:e.rpc,this.chainId=(null==e?void 0:e.chainId)||this.chainId,this.methods=(null==e?void 0:e.methods)?[...null==e?void 0:e.methods,...this.methods]:this.methods,this.signer=this.setSignerProvider(null==e?void 0:e.client),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}request(e){return r.__awaiter(this,void 0,void 0,(function*(){switch(e.method){case"eth_requestAccounts":return yield this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(void 0===this.http)throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}enable(){return r.__awaiter(this,void 0,void 0,(function*(){return yield this.request({method:"eth_requestAccounts"})}))}connect(){return r.__awaiter(this,void 0,void 0,(function*(){yield this.signer.connect()}))}disconnect(){return r.__awaiter(this,void 0,void 0,(function*(){yield this.signer.disconnect()}))}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}registerEventListeners(){this.signer.on("connect",()=>r.__awaiter(this,void 0,void 0,(function*(){const e=this.signer.connection.chains;e&&e.length&&this.setChainId(e);const t=this.signer.connection.accounts;t&&t.length&&this.setAccounts(t)}))),this.signer.connection.on(a.SIGNER_EVENTS.created,e=>{this.setChainId(e.permissions.blockchain.chains),this.setAccounts(e.state.accounts)}),this.signer.connection.on(a.SIGNER_EVENTS.updated,e=>{const t=this.formatChainId(this.chainId);e.permissions.blockchain.chains.includes(t)||this.setChainId(e.permissions.blockchain.chains),e.state.accounts!==this.accounts&&this.setAccounts(e.state.accounts)}),this.signer.connection.on(a.SIGNER_EVENTS.notification,e=>{e.type===t.providerEvents.changed.accounts?(this.accounts=e.data,this.events.emit(t.providerEvents.changed.accounts,this.accounts)):e.type===t.providerEvents.changed.chain?(this.chainId=e.data,this.events.emit(t.providerEvents.changed.chain,this.chainId)):this.events.emit(e.type,e.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on(t.providerEvents.changed.chain,e=>this.setHttpProvider(e))}setSignerProvider(e){const t=new a.SignerConnection({chains:[this.formatChainId(this.chainId)],methods:this.methods,client:e});return new o.JsonRpcProvider(t)}setHttpProvider(e){const t=u(e,this.rpc);if(void 0===t)return;return new o.JsonRpcProvider(new s.HttpConnection(t))}isCompatibleChainId(e){return e.startsWith(this.namespace+":")}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainId(e){const n=e.filter(e=>this.isCompatibleChainId(e));n.length&&(this.chainId=this.parseChainId(n[0]),this.events.emit(t.providerEvents.changed.chain,this.chainId))}parseAccountId(e){const[t,n,r]=e.split(":");return{chainId:`${t}:${n}`,address:r}}setAccounts(e){this.accounts=e.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit(t.providerEvents.changed.accounts,this.accounts)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return i})),n.d(t,"__assign",(function(){return o})),n.d(t,"__rest",(function(){return s})),n.d(t,"__decorate",(function(){return a})),n.d(t,"__param",(function(){return c})),n.d(t,"__metadata",(function(){return u})),n.d(t,"__awaiter",(function(){return h})),n.d(t,"__generator",(function(){return l})),n.d(t,"__createBinding",(function(){return d})),n.d(t,"__exportStar",(function(){return f})),n.d(t,"__values",(function(){return p})),n.d(t,"__read",(function(){return g})),n.d(t,"__spread",(function(){return y})),n.d(t,"__spreadArrays",(function(){return v})),n.d(t,"__await",(function(){return m})),n.d(t,"__asyncGenerator",(function(){return E})),n.d(t,"__asyncDelegator",(function(){return b})),n.d(t,"__asyncValues",(function(){return _})),n.d(t,"__makeTemplateObject",(function(){return w})),n.d(t,"__importStar",(function(){return R})),n.d(t,"__importDefault",(function(){return O})),n.d(t,"__classPrivateFieldGet",(function(){return T})),n.d(t,"__classPrivateFieldSet",(function(){return S}));
|
|
8
|
+
var r=n(86),i=n(87),o=n(88);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=d(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(t,n),i=(e=a(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(c.isBuffer(t)){var n=0|f(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):d(e,t);if("Buffer"===t.type&&o(t.data))return d(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(h(t),e=a(e,t<0?0:0|f(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function d(e,t){var n=t.length<0?0:0|f(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function f(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(e).length;default:if(r)return K(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,n);case"utf8":case"utf-8":return S(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return N(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:m(e,t,n,r,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):m(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=n;o<a;o++)if(u(e,o)===u(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===c)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var l=!0,d=0;d<c;d++)if(u(e,o+d)!==u(t,d)){l=!1;break}if(l)return o}return-1}function E(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function b(e,t,n,r){return B(K(t,e.length-n),e,n,r)}function _(e,t,n,r){return B(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function w(e,t,n,r){return _(e,t,n,r)}function R(e,t,n,r){return B(J(t),e,n,r)}function O(e,t,n,r){return B(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function T(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function S(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,u=e[i],h=null,l=u>239?4:u>223?3:u>191?2:1;if(i+l<=n)switch(l){case 1:u<128&&(h=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(h=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,l=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return h(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},c.allocUnsafe=function(e){return l(null,e)},c.allocUnsafeSlow=function(e){return l(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?S(this,0,e):g.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,n,r,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(r,i),h=e.slice(t,n),l=0;l<a;++l)if(u[l]!==h[l]){o=u[l],s=h[l];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return v(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return v(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return _(this,e,t,n);case"latin1":case"binary":return w(this,e,t,n);case"base64":return R(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function N(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function A(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=H(e[o]);return i}function P(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function U(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function C(e,t,n,r,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function D(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function L(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function j(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function x(e,t,n,r,o){return o||j(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function q(e,t,n,r,o){return o||j(e,0,n,8),i.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;n=new c(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},c.prototype.readUInt8=function(e,t){return t||U(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||U(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||U(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||U(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||U(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||U(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||U(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||U(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||U(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||C(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||C(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):L(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);C(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);C(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return x(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return x(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=c.isBuffer(e)?e:K(new c(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function K(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function J(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function B(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(22))},function(e,t){e.exports=i,i.strict=o,i.loose=s;var n=Object.prototype.toString,r={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function i(e){return o(e)||s(e)}function o(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return r[n.call(e)]}},function(e,t){},function(e,t,n){"use strict";n(11),n(15)},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));const r={waku:{info:"waku_info",connect:"waku_connect",disconnect:"waku_disconnect",publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PINO_CUSTOM_CONTEXT_KEY=t.PINO_LOGGER_DEFAULTS=void 0,t.PINO_LOGGER_DEFAULTS={level:"info",prettyPrint:{colorize:!0,translateTime:"SYS:standard",ignore:"pid,hostname"}},t.PINO_CUSTOM_CONTEXT_KEY="custom_context"},function(e,t,n){(function(t){var n=/^\[object .+?Constructor\]$/,r="object"==typeof t&&t&&t.Object===Object&&t,i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();function s(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function a(e,t){return!!(e?e.length:0)&&function(e,t,n){if(t!=t)return function(e,t,n,r){var i=e.length,o=n+(r?1:-1);for(;r?o--:++o<i;)if(t(e[o],o,e))return o;return-1}(e,h,n);var r=n-1,i=e.length;for(;++r<i;)if(e[r]===t)return r;return-1}(e,t,0)>-1}function c(e,t,n){for(var r=-1,i=e?e.length:0;++r<i;)if(n(t,e[r]))return!0;return!1}function u(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function h(e){return e!=e}function l(e,t){return e.has(t)}function d(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var f,p=Array.prototype,g=Function.prototype,y=Object.prototype,v=o["__core-js_shared__"],m=(f=/[^.]+$/.exec(v&&v.keys&&v.keys.IE_PROTO||""))?"Symbol(src)_1."+f:"",E=g.toString,b=y.hasOwnProperty,_=y.toString,w=RegExp("^"+E.call(b).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),R=o.Symbol,O=y.propertyIsEnumerable,T=p.splice,S=R?R.isConcatSpreadable:void 0,I=Math.max,N=H(o,"Map"),A=H(o,"Set"),P=H(Object,"create");function U(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function C(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function D(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function L(e){var t=-1,n=e?e.length:0;for(this.__data__=new D;++t<n;)this.add(e[t])}function j(e,t){for(var n,r,i=e.length;i--;)if((n=e[i][0])===(r=t)||n!=n&&r!=r)return i;return-1}function x(e){return!(!Y(e)||(t=e,m&&m in t))&&(z(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?w:n).test(function(e){if(null!=e){try{return E.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}U.prototype.clear=function(){this.__data__=P?P(null):{}},U.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},U.prototype.get=function(e){var t=this.__data__;if(P){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return b.call(t,e)?t[e]:void 0},U.prototype.has=function(e){var t=this.__data__;return P?void 0!==t[e]:b.call(t,e)},U.prototype.set=function(e,t){return this.__data__[e]=P&&void 0===t?"__lodash_hash_undefined__":t,this},C.prototype.clear=function(){this.__data__=[]},C.prototype.delete=function(e){var t=this.__data__,n=j(t,e);return!(n<0)&&(n==t.length-1?t.pop():T.call(t,n,1),!0)},C.prototype.get=function(e){var t=this.__data__,n=j(t,e);return n<0?void 0:t[n][1]},C.prototype.has=function(e){return j(this.__data__,e)>-1},C.prototype.set=function(e,t){var n=this.__data__,r=j(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},D.prototype.clear=function(){this.__data__={hash:new U,map:new(N||C),string:new U}},D.prototype.delete=function(e){return M(this,e).delete(e)},D.prototype.get=function(e){return M(this,e).get(e)},D.prototype.has=function(e){return M(this,e).has(e)},D.prototype.set=function(e,t){return M(this,e).set(e,t),this},L.prototype.add=L.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},L.prototype.has=function(e){return this.__data__.has(e)};var q=A&&1/d(new A([,-0]))[1]==1/0?function(e){return new A(e)}:function(){};function M(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function H(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return x(n)?n:void 0}function K(e){return k(e)||function(e){return F(e)&&b.call(e,"callee")&&(!O.call(e,"callee")||"[object Arguments]"==_.call(e))}(e)||!!(S&&e&&e[S])}var J,B,G=(J=function(e){return function(e,t,n){var r=-1,i=a,o=e.length,s=!0,u=[],h=u;if(n)s=!1,i=c;else if(o>=200){var f=t?null:q(e);if(f)return d(f);s=!1,i=l,h=new L}else h=t?[]:u;e:for(;++r<o;){var p=e[r],g=t?t(p):p;if(p=n||0!==p?p:0,s&&g==g){for(var y=h.length;y--;)if(h[y]===g)continue e;t&&h.push(g),u.push(p)}else i(h,g,n)||(h!==u&&h.push(g),u.push(p))}return u}(function e(t,n,r,i,o){var s=-1,a=t.length;for(r||(r=K),o||(o=[]);++s<a;){var c=t[s];n>0&&r(c)?n>1?e(c,n-1,r,i,o):u(o,c):i||(o[o.length]=c)}return o}(e,1,F,!0))},B=I(void 0===B?J.length-1:B,0),function(){for(var e=arguments,t=-1,n=I(e.length-B,0),r=Array(n);++t<n;)r[t]=e[B+t];t=-1;for(var i=Array(B+1);++t<B;)i[t]=e[t];return i[B]=r,s(J,this,i)});var k=Array.isArray;function V(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}(e.length)&&!z(e)}function F(e){return function(e){return!!e&&"object"==typeof e}(e)&&V(e)}function z(e){var t=Y(e)?_.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}function Y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=G}).call(this,n(22))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWindowMetadata=void 0;const r=n(21);t.getWindowMetadata=function(){let e,t;try{e=r.getDocumentOrThrow(),t=r.getLocationOrThrow()}catch(e){return null}function n(...t){const n=e.getElementsByTagName("meta");for(let e=0;e<n.length;e++){const r=n[e],i=["itemprop","property","name"].map(e=>r.getAttribute(e)).filter(e=>!!e&&t.includes(e));if(i.length&&i){const e=r.getAttribute("content");if(e)return e}}return""}const i=function(){let t=n("name","og:site_name","og:title","twitter:title");return t||(t=e.title),t}();return{description:n("description","og:description","twitter:description","keywords"),url:t.origin,icons:function(){const n=e.getElementsByTagName("link"),r=[];for(let e=0;e<n.length;e++){const i=n[e],o=i.getAttribute("rel");if(o&&o.toLowerCase().indexOf("icon")>-1){const e=i.getAttribute("href");if(e)if(-1===e.toLowerCase().indexOf("https:")&&-1===e.toLowerCase().indexOf("http:")&&0!==e.indexOf("//")){let n=t.protocol+"//"+t.host;if(0===e.indexOf("/"))n+=e;else{const r=t.pathname.split("/");r.pop();n+=r.join("/")+"/"+e}r.push(n)}else if(0===e.indexOf("//")){const n=t.protocol+e;r.push(n)}else r.push(e)}}return r}(),name:i}}},function(e,t,n){"use strict";var r=n(69);n.o(r,"RELAY_JSONRPC")&&n.d(t,"RELAY_JSONRPC",(function(){return r.RELAY_JSONRPC}));n(70);var i=n(71);n.d(t,"RELAY_JSONRPC",(function(){return i.a}));n(15)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRpcUrl=t.getInfuraRpcUrl=t.providerEvents=t.infuraNetworks=t.signerMethods=void 0;const r=n(77),i=n(3),o=n(28),s=n(104),a=n(103);function c(e,n){let r;const i=t.infuraNetworks[e];return i&&(r=`https://${i}.infura.io/v3/${n}`),r}function u(e,t){let n;const r=c(e,null==t?void 0:t.infuraId);return t&&t.custom?n=t.custom[e]:r&&(n=r),n}t.signerMethods=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],t.infuraNetworks={1:"mainnet",3:"ropsten",4:"rinkeby",5:"goerli",42:"kovan"},t.providerEvents={changed:{chain:"chainChanged",accounts:"accountsChanged"}},t.getInfuraRpcUrl=c,t.getRpcUrl=u;t.default=class{constructor(e){this.events=new i.EventEmitter,this.namespace="eip155",this.chainId=1,this.methods=t.signerMethods,this.accounts=[],this.rpc=null==e?void 0:e.rpc,this.chainId=(null==e?void 0:e.chainId)||this.chainId,this.methods=(null==e?void 0:e.methods)?[...null==e?void 0:e.methods,...this.methods]:this.methods,this.signer=this.setSignerProvider(null==e?void 0:e.client),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}request(e){return r.__awaiter(this,void 0,void 0,(function*(){switch(e.method){case"eth_requestAccounts":return yield this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(void 0===this.http)throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}enable(){return r.__awaiter(this,void 0,void 0,(function*(){return yield this.request({method:"eth_requestAccounts"})}))}connect(){return r.__awaiter(this,void 0,void 0,(function*(){yield this.signer.connect()}))}disconnect(){return r.__awaiter(this,void 0,void 0,(function*(){yield this.signer.disconnect()}))}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}registerEventListeners(){this.signer.on("connect",()=>r.__awaiter(this,void 0,void 0,(function*(){const e=this.signer.connection.chains;e&&e.length&&this.setChainId(e);const t=this.signer.connection.accounts;t&&t.length&&this.setAccounts(t)}))),this.signer.connection.on(a.SIGNER_EVENTS.created,e=>{this.setChainId(e.permissions.blockchain.chains),this.setAccounts(e.state.accounts)}),this.signer.connection.on(a.SIGNER_EVENTS.updated,e=>{const t=this.formatChainId(this.chainId);e.permissions.blockchain.chains.includes(t)||this.setChainId(e.permissions.blockchain.chains),e.state.accounts!==this.accounts&&this.setAccounts(e.state.accounts)}),this.signer.connection.on(a.SIGNER_EVENTS.notification,e=>{e.type===t.providerEvents.changed.accounts?(this.accounts=e.data,this.events.emit(t.providerEvents.changed.accounts,this.accounts)):e.type===t.providerEvents.changed.chain?(this.chainId=e.data,this.events.emit(t.providerEvents.changed.chain,this.chainId)):this.events.emit(e.type,e.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on(t.providerEvents.changed.chain,e=>this.setHttpProvider(e))}setSignerProvider(e){const t=new a.SignerConnection({chains:[this.formatChainId(this.chainId)],methods:this.methods,client:e});return new o.JsonRpcProvider(t)}setHttpProvider(e){const t=u(e,this.rpc);if(void 0===t)return;return new o.JsonRpcProvider(new s.HttpConnection(t))}isCompatibleChainId(e){return e.startsWith(this.namespace+":")}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainId(e){const n=e.filter(e=>this.isCompatibleChainId(e));n.length&&(this.chainId=this.parseChainId(n[0]),this.events.emit(t.providerEvents.changed.chain,this.chainId))}parseAccountId(e){const[t,n,r]=e.split(":");return{chainId:`${t}:${n}`,address:r}}setAccounts(e){this.accounts=e.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit(t.providerEvents.changed.accounts,this.accounts)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return i})),n.d(t,"__assign",(function(){return o})),n.d(t,"__rest",(function(){return s})),n.d(t,"__decorate",(function(){return a})),n.d(t,"__param",(function(){return c})),n.d(t,"__metadata",(function(){return u})),n.d(t,"__awaiter",(function(){return h})),n.d(t,"__generator",(function(){return l})),n.d(t,"__createBinding",(function(){return d})),n.d(t,"__exportStar",(function(){return f})),n.d(t,"__values",(function(){return p})),n.d(t,"__read",(function(){return g})),n.d(t,"__spread",(function(){return y})),n.d(t,"__spreadArrays",(function(){return v})),n.d(t,"__await",(function(){return m})),n.d(t,"__asyncGenerator",(function(){return E})),n.d(t,"__asyncDelegator",(function(){return b})),n.d(t,"__asyncValues",(function(){return _})),n.d(t,"__makeTemplateObject",(function(){return w})),n.d(t,"__importStar",(function(){return R})),n.d(t,"__importDefault",(function(){return O})),n.d(t,"__classPrivateFieldGet",(function(){return T})),n.d(t,"__classPrivateFieldSet",(function(){return S}));
|
|
9
9
|
/*! *****************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
11
11
|
|
|
@@ -22,4 +22,4 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
22
22
|
***************************************************************************** */
|
|
23
23
|
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 i(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function s(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 i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function a(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function c(e,t){return function(n,r){t(n,r,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function l(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function d(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}function f(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||(t[n]=e[n])}function p(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 g(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function v(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}function m(e){return this instanceof m?(this.v=e,this):new m(e)}function E(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),o=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){i[e]&&(r[e]=function(t){return new Promise((function(n,r){o.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=i[e](t)).value instanceof m?Promise.resolve(n.value.v).then(c,u):h(o[0][2],n)}catch(e){h(o[0][3],e)}var n}function c(e){a("next",e)}function u(e){a("throw",e)}function h(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function b(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,i){t[r]=e[r]?function(t){return(n=!n)?{value:m(e[r](t)),done:"return"===r}:i?i(t):t}:i}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=p(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,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(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 R(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 T(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function S(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";(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(22))},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(32))},function(e,t,n){"use strict";function r(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}e.exports=function(e,t,n){var i=n&&n.stringify||r;if("object"==typeof e&&null!==e){var o=t.length+1;if(1===o)return e;var s=new Array(o);s[0]=i(e);for(var a=1;a<o;a++)s[a]=i(t[a]);return s.join(" ")}if("string"!=typeof e)return e;var c=t.length;if(0===c)return e;for(var u="",h=0,l=-1,d=e&&e.length||0,f=0;f<d;){if(37===e.charCodeAt(f)&&f+1<d){switch(l=l>-1?l:0,e.charCodeAt(f+1)){case 100:case 102:if(h>=c)break;if(null==t[h])break;l<f&&(u+=e.slice(l,f)),u+=Number(t[h]),l=f+2,f++;break;case 105:if(h>=c)break;if(null==t[h])break;l<f&&(u+=e.slice(l,f)),u+=Math.floor(Number(t[h])),l=f+2,f++;break;case 79:case 111:case 106:if(h>=c)break;if(void 0===t[h])break;l<f&&(u+=e.slice(l,f));var p=typeof t[h];if("string"===p){u+="'"+t[h]+"'",l=f+2,f++;break}if("function"===p){u+=t[h].name||"<anonymous>",l=f+2,f++;break}u+=i(t[h]),l=f+2,f++;break;case 115:if(h>=c)break;l<f&&(u+=e.slice(l,f)),u+=String(t[h]),l=f+2,f++;break;case 37:l<f&&(u+=e.slice(l,f)),u+="%",l=f+2,f++,h--}++h}++f}if(-1===l)return e;l<d&&(u+=e.slice(l));return u}},function(e,t,n){(function(t){!function(){"use strict";var n;function r(){}(n=r).prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},n.prototype.setItem=function(e,t){this[e]=String(t)},n.prototype.removeItem=function(e){delete this[e]},n.prototype.clear=function(){var e=this;Object.keys(e).forEach((function(t){e[t]=void 0,delete e[t]}))},n.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},n.prototype.__defineGetter__("length",(function(){return Object.keys(this).length})),t.localStorage?e.exports=localStorage:e.exports=new r}()}).call(this,n(22))},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(83)),r(n(85))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(84);t.IKeyValueStorage=r.IKeyValueStorage},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.IKeyValueStorage=class{}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(41);function i(e){return t.REACT_NATIVE_REQUIRED_OPTION in e}function o(e){return t.NODE_JS_REQUIRED_OPTION in e}t.REACT_NATIVE_REQUIRED_OPTION="asyncStorage",t.isReactNativeOptions=i,t.getReactNativeOptions=function(e){if(void 0===e||!i(e))throw new Error(`Missing ${t.REACT_NATIVE_REQUIRED_OPTION} option required for React-Native`);return e},t.NODE_JS_REQUIRED_OPTION="database",t.isNodeJSOptions=o,t.getNodeJSOptions=function(e){if(void 0===e||!o(e))throw new Error(`Missing ${t.NODE_JS_REQUIRED_OPTION} option required for NodeJS`);return e},t.parseEntry=function(e){return[e[0],r.safeJsonParse(e[1])]}},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],a=r[1],c=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),h=0,l=a>0?s-4:s;for(n=0;n<l;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],c[h++]=t>>16&255,c[h++]=t>>8&255,c[h++]=255&t;2===a&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,c[h++]=255&t);1===a&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,c[h++]=t>>8&255,c[h++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=0,a=n-i;s<a;s+=16383)o.push(h(e,s,s+16383>a?a:s+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],i[s.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function h(e,t,n){for(var i,o,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
24
24
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
25
|
-
t.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,u=c>>1,h=-7,l=n?i-1:0,d=n?-1:1,f=e[t+l];for(l+=d,o=f&(1<<-h)-1,f>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+e[t+l],l+=d,h-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=u}return(f?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var s,a,c,u=8*o-i-1,h=(1<<u)-1,l=h>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?d/c:d*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*c-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[n+f]=255&s,f+=p,s/=256,u-=8);e[n+f-p]|=128*g}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){(function(t){var r=n(68).strict;e.exports=function(e){if(r(e)){var n=t.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(n=n.slice(e.byteOffset,e.byteOffset+e.byteLength)),n}return t.from(e)}}).call(this,n(67).Buffer)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(91),i=n(95),o=n(27);function s(e,n){return void 0===n&&(n=t.defaultRandomSource),n.randomBytes(e)}t.defaultRandomSource=new r.SystemRandomSource,t.randomBytes=s,t.randomUint32=function(e){void 0===e&&(e=t.defaultRandomSource);var n=s(4,e),r=i.readUint32LE(n);return o.wipe(n),r};var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(e,n,r){if(void 0===n&&(n=a),void 0===r&&(r=t.defaultRandomSource),n.length<2)throw new Error("randomString charset is too short");if(n.length>256)throw new Error("randomString charset is too long");for(var i="",c=n.length,u=256-256%c;e>0;){for(var h=s(Math.ceil(256*e/u),r),l=0;l<h.length&&e>0;l++){var d=h[l];d<u&&(i+=n.charAt(d%c),e--)}o.wipe(h)}return i}t.randomString=c,t.randomStringForEntropy=function(e,n,r){return void 0===n&&(n=a),void 0===r&&(r=t.defaultRandomSource),c(Math.ceil(e/(Math.log(n.length)/Math.LN2)),n,r)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(92),i=n(93),o=function(){function e(){return this.isAvailable=!1,this.name="",this._source=new r.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new i.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}return e.prototype.randomBytes=function(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)},e}();t.SystemRandomSource=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.isAvailable=!1,this.isInstantiated=!1;var e="undefined"!=typeof self?self.crypto||self.msCrypto:null;e&&e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return e.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");for(var t=new Uint8Array(e),n=0;n<t.length;n+=65536)this._crypto.getRandomValues(t.subarray(n,n+Math.min(t.length-n,65536)));return t},e}();t.BrowserRandomSource=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(27),i=function(){function e(){this.isAvailable=!1,this.isInstantiated=!1;var e=n(94);e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return e.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");var t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");for(var n=new Uint8Array(e),i=0;i<n.length;i++)n[i]=t[i];return r.wipe(t),n},e}();t.NodeRandomSource=i},function(e,t){},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(96);function i(e,t,n){return void 0===t&&(t=new Uint8Array(2)),void 0===n&&(n=0),t[n+0]=e>>>8,t[n+1]=e>>>0,t}function o(e,t,n){return void 0===t&&(t=new Uint8Array(2)),void 0===n&&(n=0),t[n+0]=e>>>0,t[n+1]=e>>>8,t}function s(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function a(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function c(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function u(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function h(e,t,n){return void 0===t&&(t=new Uint8Array(4)),void 0===n&&(n=0),t[n+0]=e>>>24,t[n+1]=e>>>16,t[n+2]=e>>>8,t[n+3]=e>>>0,t}function l(e,t,n){return void 0===t&&(t=new Uint8Array(4)),void 0===n&&(n=0),t[n+0]=e>>>0,t[n+1]=e>>>8,t[n+2]=e>>>16,t[n+3]=e>>>24,t}function d(e,t,n){return void 0===t&&(t=new Uint8Array(8)),void 0===n&&(n=0),h(e/4294967296>>>0,t,n),h(e>>>0,t,n+4),t}function f(e,t,n){return void 0===t&&(t=new Uint8Array(8)),void 0===n&&(n=0),l(e>>>0,t,n),l(e/4294967296>>>0,t,n+4),t}t.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},t.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},t.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},t.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},t.writeUint16BE=i,t.writeInt16BE=i,t.writeUint16LE=o,t.writeInt16LE=o,t.readInt32BE=s,t.readUint32BE=a,t.readInt32LE=c,t.readUint32LE=u,t.writeUint32BE=h,t.writeInt32BE=h,t.writeUint32LE=l,t.writeInt32LE=l,t.readInt64BE=function(e,t){void 0===t&&(t=0);var n=s(e,t),r=s(e,t+4);return 4294967296*n+r-4294967296*(r>>31)},t.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*a(e,t)+a(e,t+4)},t.readInt64LE=function(e,t){void 0===t&&(t=0);var n=c(e,t);return 4294967296*c(e,t+4)+n-4294967296*(n>>31)},t.readUint64LE=function(e,t){void 0===t&&(t=0);var n=u(e,t);return 4294967296*u(e,t+4)+n},t.writeUint64BE=d,t.writeInt64BE=d,t.writeUint64LE=f,t.writeInt64LE=f,t.readUintBE=function(e,t,n){if(void 0===n&&(n=0),e%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-n)throw new Error("readUintBE: array is too short for the given bitLength");for(var r=0,i=1,o=e/8+n-1;o>=n;o--)r+=t[o]*i,i*=256;return r},t.readUintLE=function(e,t,n){if(void 0===n&&(n=0),e%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-n)throw new Error("readUintLE: array is too short for the given bitLength");for(var r=0,i=1,o=n;o<n+e/8;o++)r+=t[o]*i,i*=256;return r},t.writeUintBE=function(e,t,n,i){if(void 0===n&&(n=new Uint8Array(e/8)),void 0===i&&(i=0),e%8!=0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!r.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var o=1,s=e/8+i-1;s>=i;s--)n[s]=t/o&255,o*=256;return n},t.writeUintLE=function(e,t,n,i){if(void 0===n&&(n=new Uint8Array(e/8)),void 0===i&&(i=0),e%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!r.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var o=1,s=i;s<i+e/8;s++)n[s]=t/o&255,o*=256;return n},t.readFloat32BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t)},t.readFloat32LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t,!0)},t.readFloat64BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t)},t.readFloat64LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t,!0)},t.writeFloat32BE=function(e,t,n){return void 0===t&&(t=new Uint8Array(4)),void 0===n&&(n=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(n,e),t},t.writeFloat32LE=function(e,t,n){return void 0===t&&(t=new Uint8Array(4)),void 0===n&&(n=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(n,e,!0),t},t.writeFloat64BE=function(e,t,n){return void 0===t&&(t=new Uint8Array(8)),void 0===n&&(n=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(n,e),t},t.writeFloat64LE=function(e,t,n){return void 0===t&&(t=new Uint8Array(8)),void 0===n&&(n=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(n,e,!0),t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mul=Math.imul||function(e,t){var n=65535&e,r=65535&t;return n*r+((e>>>16&65535)*r+n*(t>>>16&65535)<<16>>>0)|0},t.add=function(e,t){return e+t|0},t.sub=function(e,t){return e-t|0},t.rotl=function(e,t){return e<<t|e>>>32-t},t.rotr=function(e,t){return e<<32-t|e>>>t},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(e){return t.isInteger(e)&&e>=-t.MAX_SAFE_INTEGER&&e<=t.MAX_SAFE_INTEGER}},function(e,t,n){"use strict";e.exports=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())},function(e,t,n){"use strict";var r=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],o(n),o(r))}function s(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(r),n=1;n<t.length;n++)t=(e=o(t,n).join("")).match(r);return e}}e.exports=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var t={"%FE%FF":"��","%FF%FE":"��"},n=i.exec(e);n;){try{t[n[0]]=decodeURIComponent(n[0])}catch(e){var r=s(n[0]);r!==n[0]&&(t[n[0]]=r)}n=i.exec(e)}t["%C2"]="�";for(var o=Object.keys(t),a=0;a<o.length;a++){var c=o[a];e=e.replace(new RegExp(c,"g"),t[c])}return e}(e)}}},function(e,t,n){"use strict";e.exports=(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const n=e.indexOf(t);return-1===n?[e]:[e.slice(0,n),e.slice(n+t.length)]}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n={},r=Object.keys(e),i=Array.isArray(t),o=0;o<r.length;o++){var s=r[o],a=e[s];(i?-1!==t.indexOf(s):t(s,a,e))&&(n[s]=a)}return n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateChildLogger=t.formatChildLoggerContext=t.getLoggerContext=t.setBrowserLoggerContext=t.getBrowserLoggerContext=t.getDefaultLoggerOptions=void 0;const r=n(69);function i(e,t=r.PINO_CUSTOM_CONTEXT_KEY){return e[t]||""}function o(e,t,n=r.PINO_CUSTOM_CONTEXT_KEY){return e[n]=t,e}function s(e,t=r.PINO_CUSTOM_CONTEXT_KEY){let n="";return n=void 0===e.bindings?i(e,t):e.bindings().context||"",n}function a(e,t,n=r.PINO_CUSTOM_CONTEXT_KEY){const i=s(e,n);return i.trim()?`${i}/${t}`:t}t.getDefaultLoggerOptions=function(e){return Object.assign(Object.assign({},e),{level:(null==e?void 0:e.level)||r.PINO_LOGGER_DEFAULTS.level,prettyPrint:(null==e?void 0:e.prettyPrint)||r.PINO_LOGGER_DEFAULTS.prettyPrint})},t.getBrowserLoggerContext=i,t.setBrowserLoggerContext=o,t.getLoggerContext=s,t.formatChildLoggerContext=a,t.generateChildLogger=function(e,t,n=r.PINO_CUSTOM_CONTEXT_KEY){const i=a(e,t,n);return o(e.child({context:i}),i,n)}},function(e,t,n){"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},function(e,t,n){"use strict";n.r(t),n.d(t,"SIGNER_EVENTS",(function(){return nt})),n.d(t,"SignerConnection",(function(){return rt}));var r=n(3),i=n(5),o=n(0),s=n(19),a=n.n(s),c=n(26),u=n.n(c),h=n(6),l=n(17),d=n(2);var f=n(12);const p=Object(f.c)({GENERIC:"GENERIC",MISSING_OR_INVALID:"MISSING_OR_INVALID",MISSING_RESPONSE:"MISSING_RESPONSE",MISSING_DECRYPT_PARAMS:"MISSING_DECRYPT_PARAMS",INVALID_UPDATE_REQUEST:"INVALID_UPDATE_REQUEST",INVALID_UPGRADE_REQUEST:"INVALID_UPGRADE_REQUEST",INVALID_STORAGE_KEY_NAME:"INVALID_STORAGE_KEY_NAME",RECORD_ALREADY_EXISTS:"RECORD_ALREADY_EXISTS",RESTORE_WILL_OVERRIDE:"RESTORE_WILL_OVERRIDE",NO_MATCHING_ID:"NO_MATCHING_ID",NO_MATCHING_TOPIC:"NO_MATCHING_TOPIC",NO_MATCHING_RESPONSE:"NO_MATCHING_RESPONSE",NO_MATCHING_KEY:"NO_MATCHING_KEY",UNKNOWN_JSONRPC_METHOD:"UNKNOWN_JSONRPC_METHOD",MISMATCHED_TOPIC:"MISMATCHED_TOPIC",MISMATCHED_ACCOUNTS:"MISMATCHED_ACCOUNTS",SETTLED:"SETTLED",NOT_APPROVED:"NOT_APPROVED",PROPOSAL_RESPONDED:"PROPOSAL_RESPONDED",RESPONSE_ACKNOWLEDGED:"RESPONSE_ACKNOWLEDGED",EXPIRED:"EXPIRED",DELETED:"DELETED",RESUBSCRIBED:"RESUBSCRIBED",SETTLE_TIMEOUT:"SETTLE_TIMEOUT",JSONRPC_REQUEST_TIMEOUT:"JSONRPC_REQUEST_TIMEOUT",UNAUTHORIZED_TARGET_CHAIN:"UNAUTHORIZED_TARGET_CHAIN",UNAUTHORIZED_JSON_RPC_METHOD:"UNAUTHORIZED_JSON_RPC_METHOD",UNAUTHORIZED_NOTIFICATION_TYPE:"UNAUTHORIZED_NOTIFICATION_TYPE",UNAUTHORIZED_UPDATE_REQUEST:"UNAUTHORIZED_UPDATE_REQUEST",UNAUTHORIZED_UPGRADE_REQUEST:"UNAUTHORIZED_UPGRADE_REQUEST",UNAUTHORIZED_MATCHING_CONTROLLER:"UNAUTHORIZED_MATCHING_CONTROLLER",JSONRPC_REQUEST_METHOD_REJECTED:"JSONRPC_REQUEST_METHOD_REJECTED",JSONRPC_REQUEST_METHOD_UNAUTHORIZED:"JSONRPC_REQUEST_METHOD_UNAUTHORIZED",JSONRPC_REQUEST_METHOD_UNSUPPORTED:"JSONRPC_REQUEST_METHOD_UNSUPPORTED",DISCONNECTED_ALL_CHAINS:"DISCONNECTED_ALL_CHAINS",DISCONNECTED_TARGET_CHAIN:"DISCONNECTED_TARGET_CHAIN",DISAPPROVED_CHAINS:"DISAPPROVED_CHAINS",DISAPPROVED_JSONRPC:"DISAPPROVED_JSONRPC",DISAPPROVED_NOTIFICATION:"DISAPPROVED_NOTIFICATION",UNSUPPORTED_CHAINS:"UNSUPPORTED_CHAINS",UNSUPPORTED_JSONRPC:"UNSUPPORTED_JSONRPC",UNSUPPORTED_NOTIFICATION:"UNSUPPORTED_NOTIFICATION",UNSUPPORTED_SIGNAL:"UNSUPPORTED_SIGNAL",USER_DISCONNECTED:"USER_DISCONNECTED",UNKNOWN:"UNKNOWN"}),g="undefined",y="Something went wrong",v="parameter",m="session",E="Ethereum",b={[p.GENERIC]:{type:p.GENERIC,code:0,stringify:e=>(null==e?void 0:e.message)||y,format:e=>({code:b[p.GENERIC].code,message:b[p.GENERIC].stringify(e)})},[p.MISSING_OR_INVALID]:{type:p.MISSING_OR_INVALID,code:1e3,stringify:e=>"Missing or invalid "+((null==e?void 0:e.name)||v),format:e=>({code:b[p.MISSING_OR_INVALID].code,message:b[p.MISSING_OR_INVALID].stringify(e)})},[p.MISSING_RESPONSE]:{type:p.MISSING_RESPONSE,code:1001,stringify:e=>`Response is required for approved ${(null==e?void 0:e.context)||m} proposals`,format:e=>({code:b[p.MISSING_RESPONSE].code,message:b[p.MISSING_RESPONSE].stringify(e)})},[p.MISSING_DECRYPT_PARAMS]:{type:p.MISSING_DECRYPT_PARAMS,code:1002,stringify:e=>"Decrypt params required for "+((null==e?void 0:e.context)||m),format:e=>({code:b[p.MISSING_DECRYPT_PARAMS].code,message:b[p.MISSING_DECRYPT_PARAMS].stringify(e)})},[p.INVALID_UPDATE_REQUEST]:{type:p.INVALID_UPDATE_REQUEST,code:1003,stringify:e=>`Invalid ${(null==e?void 0:e.context)||m} update request`,format:e=>({code:b[p.INVALID_UPDATE_REQUEST].code,message:b[p.INVALID_UPDATE_REQUEST].stringify(e)})},[p.INVALID_UPGRADE_REQUEST]:{type:p.INVALID_UPGRADE_REQUEST,code:1004,stringify:e=>`Invalid ${(null==e?void 0:e.context)||m} upgrade request`,format:e=>({code:b[p.INVALID_UPGRADE_REQUEST].code,message:b[p.INVALID_UPGRADE_REQUEST].stringify(e)})},[p.INVALID_STORAGE_KEY_NAME]:{type:p.INVALID_STORAGE_KEY_NAME,code:1005,stringify:e=>"Invalid storage key name: "+((null==e?void 0:e.name)||v),format:e=>({code:b[p.INVALID_STORAGE_KEY_NAME].code,message:b[p.INVALID_STORAGE_KEY_NAME].stringify(e)})},[p.RECORD_ALREADY_EXISTS]:{type:p.RECORD_ALREADY_EXISTS,code:1100,stringify:e=>`Record already exists for ${(null==e?void 0:e.context)||m} matching id: ${null==e?void 0:e.id}`,format:e=>({code:b[p.RECORD_ALREADY_EXISTS].code,message:b[p.RECORD_ALREADY_EXISTS].stringify(e)})},[p.RESTORE_WILL_OVERRIDE]:{type:p.RESTORE_WILL_OVERRIDE,code:1200,stringify:e=>"Restore will override already set "+((null==e?void 0:e.context)||m),format:e=>({code:b[p.RESTORE_WILL_OVERRIDE].code,message:b[p.RESTORE_WILL_OVERRIDE].stringify(e)})},[p.NO_MATCHING_ID]:{type:p.NO_MATCHING_ID,code:1300,stringify:e=>`No matching ${(null==e?void 0:e.context)||m} with id: ${null==e?void 0:e.id}`,format:e=>({code:b[p.NO_MATCHING_ID].code,message:b[p.NO_MATCHING_ID].stringify(e)})},[p.NO_MATCHING_TOPIC]:{type:p.NO_MATCHING_TOPIC,code:1301,stringify:e=>`No matching ${(null==e?void 0:e.context)||m} with topic: ${null==e?void 0:e.topic}`,format:e=>({code:b[p.NO_MATCHING_TOPIC].code,message:b[p.NO_MATCHING_TOPIC].stringify(e)})},[p.NO_MATCHING_RESPONSE]:{type:p.NO_MATCHING_RESPONSE,code:1302,stringify:e=>`No response found in pending ${(null==e?void 0:e.context)||m} proposal`,format:e=>({code:b[p.NO_MATCHING_RESPONSE].code,message:b[p.NO_MATCHING_RESPONSE].stringify(e)})},[p.NO_MATCHING_KEY]:{type:p.NO_MATCHING_KEY,code:1303,stringify:e=>"No matching key with tag: "+(null==e?void 0:e.tag),format:e=>({code:b[p.NO_MATCHING_KEY].code,message:b[p.NO_MATCHING_KEY].stringify(e)})},[p.UNKNOWN_JSONRPC_METHOD]:{type:p.UNKNOWN_JSONRPC_METHOD,code:1400,stringify:e=>"Unknown JSON-RPC Method Requested: "+(null==e?void 0:e.method),format:e=>({code:b[p.UNKNOWN_JSONRPC_METHOD].code,message:b[p.UNKNOWN_JSONRPC_METHOD].stringify(e)})},[p.MISMATCHED_TOPIC]:{type:p.MISMATCHED_TOPIC,code:1500,stringify:e=>`Mismatched topic for ${(null==e?void 0:e.context)||m} with id: ${null==e?void 0:e.id}`,format:e=>({code:b[p.MISMATCHED_TOPIC].code,message:b[p.MISMATCHED_TOPIC].stringify(e)})},[p.MISMATCHED_ACCOUNTS]:{type:p.MISMATCHED_ACCOUNTS,code:1501,stringify:e=>"Invalid accounts with mismatched chains: "+(null==e?void 0:e.mismatched.toString()),format:e=>({code:b[p.MISMATCHED_ACCOUNTS].code,message:b[p.MISMATCHED_ACCOUNTS].stringify(e)})},[p.SETTLED]:{type:p.SETTLED,code:1600,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" settled",format:e=>({code:b[p.SETTLED].code,message:b[p.SETTLED].stringify(e)})},[p.NOT_APPROVED]:{type:p.NOT_APPROVED,code:1601,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" not approved",format:e=>({code:b[p.NOT_APPROVED].code,message:b[p.NOT_APPROVED].stringify(e)})},[p.PROPOSAL_RESPONDED]:{type:p.PROPOSAL_RESPONDED,code:1602,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" proposal responded",format:e=>({code:b[p.PROPOSAL_RESPONDED].code,message:b[p.PROPOSAL_RESPONDED].stringify(e)})},[p.RESPONSE_ACKNOWLEDGED]:{type:p.RESPONSE_ACKNOWLEDGED,code:1603,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" response acknowledge",format:e=>({code:b[p.RESPONSE_ACKNOWLEDGED].code,message:b[p.RESPONSE_ACKNOWLEDGED].stringify(e)})},[p.EXPIRED]:{type:p.EXPIRED,code:1604,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" expired",format:e=>({code:b[p.EXPIRED].code,message:b[p.EXPIRED].stringify(e)})},[p.DELETED]:{type:p.DELETED,code:1605,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" deleted",format:e=>({code:b[p.DELETED].code,message:b[p.DELETED].stringify(e)})},[p.RESUBSCRIBED]:{type:p.RESUBSCRIBED,code:1606,stringify:e=>"Subscription resubscribed with topic: "+(e.topic||g),format:e=>({code:b[p.RESUBSCRIBED].code,message:b[p.RESUBSCRIBED].stringify(e)})},[p.SETTLE_TIMEOUT]:{type:p.SETTLE_TIMEOUT,code:2e3,stringify:e=>`${Object(f.b)((null==e?void 0:e.context)||m)} failed to settle after ${Object(f.g)(null==e?void 0:e.timeout)} seconds`,format:e=>({code:b[p.SETTLE_TIMEOUT].code,message:b[p.SETTLE_TIMEOUT].stringify(e)})},[p.JSONRPC_REQUEST_TIMEOUT]:{type:p.JSONRPC_REQUEST_TIMEOUT,code:2001,stringify:e=>`JSON-RPC Request timeout after ${Object(f.g)(null==e?void 0:e.timeout)} seconds: ${null==e?void 0:e.method}`,format:e=>({code:b[p.JSONRPC_REQUEST_TIMEOUT].code,message:b[p.JSONRPC_REQUEST_TIMEOUT].stringify(e)})},[p.UNAUTHORIZED_TARGET_CHAIN]:{type:p.UNAUTHORIZED_TARGET_CHAIN,code:3e3,stringify:e=>"Unauthorized Target ChainId Requested: "+(null==e?void 0:e.chainId),format:e=>({code:b[p.UNAUTHORIZED_TARGET_CHAIN].code,message:b[p.UNAUTHORIZED_TARGET_CHAIN].stringify(e)})},[p.UNAUTHORIZED_JSON_RPC_METHOD]:{type:p.UNAUTHORIZED_JSON_RPC_METHOD,code:3001,stringify:e=>"Unauthorized JSON-RPC Method Requested: "+(null==e?void 0:e.method),format:e=>({code:b[p.UNAUTHORIZED_JSON_RPC_METHOD].code,message:b[p.UNAUTHORIZED_JSON_RPC_METHOD].stringify(e)})},[p.UNAUTHORIZED_NOTIFICATION_TYPE]:{type:p.UNAUTHORIZED_NOTIFICATION_TYPE,code:3002,stringify:e=>"Unauthorized Notification Type Requested: "+(null==e?void 0:e.type),format:e=>({code:b[p.UNAUTHORIZED_NOTIFICATION_TYPE].code,message:b[p.UNAUTHORIZED_NOTIFICATION_TYPE].stringify(e)})},[p.UNAUTHORIZED_UPDATE_REQUEST]:{type:p.UNAUTHORIZED_UPDATE_REQUEST,code:3003,stringify:e=>`Unauthorized ${(null==e?void 0:e.context)||m} update request`,format:e=>({code:b[p.UNAUTHORIZED_UPDATE_REQUEST].code,message:b[p.UNAUTHORIZED_UPDATE_REQUEST].stringify(e)})},[p.UNAUTHORIZED_UPGRADE_REQUEST]:{type:p.UNAUTHORIZED_UPGRADE_REQUEST,code:3004,stringify:e=>`Unauthorized ${(null==e?void 0:e.context)||m} upgrade request`,format:e=>({code:b[p.UNAUTHORIZED_UPGRADE_REQUEST].code,message:b[p.UNAUTHORIZED_UPGRADE_REQUEST].stringify(e)})},[p.UNAUTHORIZED_MATCHING_CONTROLLER]:{type:p.UNAUTHORIZED_MATCHING_CONTROLLER,code:3005,stringify:e=>`Unauthorized: peer is also ${(null==e?void 0:e.controller)?"":"not "}controller`,format:e=>({code:b[p.UNAUTHORIZED_MATCHING_CONTROLLER].code,message:b[p.UNAUTHORIZED_MATCHING_CONTROLLER].stringify(e)})},[p.JSONRPC_REQUEST_METHOD_REJECTED]:{type:p.JSONRPC_REQUEST_METHOD_REJECTED,code:4001,stringify:e=>"User rejected the request.",format:e=>({code:b[p.JSONRPC_REQUEST_METHOD_REJECTED].code,message:b[p.JSONRPC_REQUEST_METHOD_REJECTED].stringify(e)})},[p.JSONRPC_REQUEST_METHOD_UNAUTHORIZED]:{type:p.JSONRPC_REQUEST_METHOD_UNAUTHORIZED,code:4100,stringify:e=>"The requested account and/or method has not been authorized by the user.",format:e=>({code:b[p.JSONRPC_REQUEST_METHOD_UNAUTHORIZED].code,message:b[p.JSONRPC_REQUEST_METHOD_UNAUTHORIZED].stringify(e)})},[p.JSONRPC_REQUEST_METHOD_UNSUPPORTED]:{type:p.JSONRPC_REQUEST_METHOD_UNSUPPORTED,code:4200,stringify:e=>`The requested method is not supported by this ${(null==e?void 0:e.blockhain)||E} provider.`,format:e=>({code:b[p.JSONRPC_REQUEST_METHOD_UNSUPPORTED].code,message:b[p.JSONRPC_REQUEST_METHOD_UNSUPPORTED].stringify(e)})},[p.DISCONNECTED_ALL_CHAINS]:{type:p.DISCONNECTED_ALL_CHAINS,code:4900,stringify:e=>"The provider is disconnected from all chains.",format:e=>({code:b[p.DISCONNECTED_ALL_CHAINS].code,message:b[p.DISCONNECTED_ALL_CHAINS].stringify(e)})},[p.DISCONNECTED_TARGET_CHAIN]:{type:p.DISCONNECTED_TARGET_CHAIN,code:4901,stringify:e=>"The provider is disconnected from the specified chain.",format:e=>({code:b[p.DISCONNECTED_TARGET_CHAIN].code,message:b[p.DISCONNECTED_TARGET_CHAIN].stringify(e)})},[p.DISAPPROVED_CHAINS]:{type:p.DISAPPROVED_CHAINS,code:5e3,stringify:e=>"User disapproved requested chains",format:e=>({code:b[p.DISAPPROVED_CHAINS].code,message:b[p.DISAPPROVED_CHAINS].stringify(e)})},[p.DISAPPROVED_JSONRPC]:{type:p.DISAPPROVED_JSONRPC,code:5001,stringify:e=>"User disapproved requested json-rpc methods",format:e=>({code:b[p.DISAPPROVED_JSONRPC].code,message:b[p.DISAPPROVED_JSONRPC].stringify(e)})},[p.DISAPPROVED_NOTIFICATION]:{type:p.DISAPPROVED_NOTIFICATION,code:5002,stringify:e=>"User disapproved requested notification types",format:e=>({code:b[p.DISAPPROVED_NOTIFICATION].code,message:b[p.DISAPPROVED_NOTIFICATION].stringify(e)})},[p.UNSUPPORTED_CHAINS]:{type:p.UNSUPPORTED_CHAINS,code:5100,stringify:e=>"Requested chains are not supported: "+(null==e?void 0:e.chains.toString()),format:e=>({code:b[p.UNSUPPORTED_CHAINS].code,message:b[p.UNSUPPORTED_CHAINS].stringify(e)})},[p.UNSUPPORTED_JSONRPC]:{type:p.UNSUPPORTED_JSONRPC,code:5101,stringify:e=>"Requested json-rpc methods are not supported: "+(null==e?void 0:e.methods.toString()),format:e=>({code:b[p.UNSUPPORTED_JSONRPC].code,message:b[p.UNSUPPORTED_JSONRPC].stringify(e)})},[p.UNSUPPORTED_NOTIFICATION]:{type:p.UNSUPPORTED_NOTIFICATION,code:5102,stringify:e=>"Requested notification types are not supported: "+(null==e?void 0:e.types.toString()),format:e=>({code:b[p.UNSUPPORTED_NOTIFICATION].code,message:b[p.UNSUPPORTED_NOTIFICATION].stringify(e)})},[p.UNSUPPORTED_SIGNAL]:{type:p.UNSUPPORTED_SIGNAL,code:5103,stringify:e=>`Proposed ${(null==e?void 0:e.context)||m} signal is unsupported`,format:e=>({code:b[p.UNSUPPORTED_SIGNAL].code,message:b[p.UNSUPPORTED_SIGNAL].stringify(e)})},[p.USER_DISCONNECTED]:{type:p.USER_DISCONNECTED,code:5900,stringify:e=>"User disconnected "+((null==e?void 0:e.context)||m),format:e=>({code:b[p.USER_DISCONNECTED].code,message:b[p.USER_DISCONNECTED].stringify(e)})},[p.UNKNOWN]:{type:p.UNKNOWN,code:9e3,stringify:e=>"Unknown error"+(e?": "+(null==e?void 0:e.toString()):""),format:e=>({code:b[p.UNKNOWN].code,message:b[p.UNKNOWN].stringify(e)})}};var _=n(20),w=n(8);function R(e){return"pairing"===e.method}function O(e){return"responded"===e.status&&"outcome"in e}function T(e){return"reason"in e}function S(e){return"responded"===e}function I(e){const t=function(e){if(void 0===e||void 0===e.chains||!P(e.chains,C))return x(b.MISSING_OR_INVALID.format({name:"blockchain permissions"}));return{valid:!0}}(e.blockchain);if(j(t))return t;const n=function(e){if(void 0===e||void 0===e.methods||!P(e.methods,U))return x(b.MISSING_OR_INVALID.format({name:"jsonrpc permissions"}));return{valid:!0}}(e.jsonrpc);if(j(n))return n;const r=function(e){if(void 0===e||void 0===e.types||!P(e.types,U))return x(b.MISSING_OR_INVALID.format({name:"notification permissions"}));return{valid:!0}}(e.notifications);return j(r)?r:{valid:!0}}function N(e){return U(e.name)?U(e.description)?void 0!==e.url&&L(e.url)?void 0!==e.icons&&P(e.icons,L)?{valid:!0}:x(b.MISSING_OR_INVALID.format({name:"metadata icons"})):x(b.MISSING_OR_INVALID.format({name:"metadata url"})):x(b.MISSING_OR_INVALID.format({name:"metadata description"})):x(b.MISSING_OR_INVALID.format({name:"metadata name"}))}function A(e){if(e.approved){if(void 0===e.response)return x(b.MISSING_RESPONSE.format({context:"session"}));const t=function(e,t){if(void 0===t||void 0===t.chains||!P(t.chains,C))return x(b.MISSING_OR_INVALID.format({name:"blockchain permissions"}));if(void 0===e||void 0===e.accounts||!P(e.accounts,D))return x(b.MISSING_OR_INVALID.format({name:"state accounts"}));const n=e.accounts.filter(e=>{const[n,r]=e.split(":"),i=`${n}:${r}`;return!t.chains.includes(i)});if(n.length)return x(b.MISMATCHED_ACCOUNTS.format({mismatched:n}));return{valid:!0}}(e.response.state,e.proposal.permissions.blockchain);if(j(t))return t;const n=N(e.response.metadata);if(j(n))return n}return{valid:!0}}function P(e,t){if(Array.isArray(e)){if(void 0!==t&&e.length){return e.filter(t).length===e.length}return!0}return!1}function U(e){return"string"==typeof e&&!!e.trim()}function C(e){if(U(e)&&e.includes(":")){return 2===e.split(":").length}return!1}function D(e){if(U(e)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&C(e)}}return!1}function L(e){if(U(e))try{return void 0!==new URL(e)}catch(e){return!1}return!1}function j(e){return"valid"in e&&!1===e.valid&&"error"in e&&"number"==typeof e.error.code&&"string"==typeof e.error.message}function x(e){return{valid:!1,error:e}}var q=n(1);const M="client",H="error",K=!1,J="wss://relay.walletconnect.com",B={proposal:"pairing_proposal",updated:"pairing_updated",created:"pairing_created",deleted:"pairing_deleted",sync:"pairing_sync"},G={proposal:"session_proposal",updated:"session_updated",created:"session_created",deleted:"session_deleted",notification:"session_notification",request:"session_request",response:"session_response",sync:"session_sync"},k={database:":memory:"},V="expirer_created",F="expirer_deleted",z="expirer_expired",Y="expirer_init",W="expirer_sync",$="heartbeat_pulse",Q="history_created",Z="history_updated",X="history_deleted",ee="history_init",te="history_sync",ne={propose:"wc_pairingPropose",approve:"wc_pairingApprove",reject:"wc_pairingReject",update:"wc_pairingUpdate",upgrade:"wc_pairingUpgrade",delete:"wc_pairingDelete",payload:"wc_pairingPayload",ping:"wc_pairingPing",notification:"wc_pairingNotification"},re={proposed:"proposed",responded:"responded",pending:"pending",settled:"settled"},ie={proposed:"pairing_proposed",responded:"pairing_responded",settled:"pairing_settled",updated:"pairing_updated",deleted:"pairing_deleted",request:"pairing_request",response:"pairing_response",sync:"pairing_sync",notification:"pairing_notification"},oe="relayer_payload",se="relayer_connect",ae="relayer_disconnect",ce="relayer_error",ue="payload",he="connect",le="disconnect",de="error",fe={database:":memory:"},pe={propose:"wc_sessionPropose",approve:"wc_sessionApprove",reject:"wc_sessionReject",update:"wc_sessionUpdate",upgrade:"wc_sessionUpgrade",delete:"wc_sessionDelete",payload:"wc_sessionPayload",ping:"wc_sessionPing",notification:"wc_sessionNotification"},ge={proposed:"proposed",responded:"responded",pending:"pending",settled:"settled"},ye={proposed:"session_proposed",responded:"session_responded",settled:"session_settled",updated:"session_updated",deleted:"session_deleted",request:"session_request",response:"session_response",sync:"session_sync",notification:"session_notification"},ve={jsonrpc:{methods:[]},blockchain:{chains:[]},notifications:{types:[]}},me={accounts:[]},Ee={metadata:{name:"",description:"",url:"",icons:[]},state:me},be="store_created",_e="store_updated",we="store_deleted",Re="store_init",Oe="store_sync",Te={crypto:{keychain:"crypto:keychain"},session:{pending:"session:pending",settled:"session:settled",history:"session:history",expirer:"session:expirer"},pairing:{pending:"pairing:pending",settled:"pairing:settled",history:"pairing:history",expirer:"pairing:expirer"},relayer:{history:"relayer:history",subscription:"relayer:subscription"}},Se="subscription_created",Ie="subscription_deleted",Ne="subscription_enabled",Ae="subscription_disabled",Pe="subscription_sync";class Ue{constructor(e,t){this.client=e,this.logger=t,this.keychain=new Map,this.name="keychain",this.client=e,this.logger=Object(q.generateChildLogger)(t,this.name)}get context(){return Object(q.getLoggerContext)(this.logger)}async init(){await this.restore()}async has(e,t){return this.keychain.has(e)}async set(e,t,n){this.keychain.set(e,t),await this.persist()}async get(e,t){const n=this.keychain.get(e);if(void 0===n)throw new Error(b.NO_MATCHING_KEY.format({tag:e}).message);return n}async del(e,t){this.keychain.delete(e),await this.persist()}async restore(){const e=await this.client.storage.getKeyChain(this.context);void 0!==e&&(this.keychain=e)}async persist(){await this.client.storage.setKeyChain(this.context,this.keychain)}}class Ce{constructor(e,t,n){this.client=e,this.logger=t,this.name="crypto",this.client=e,this.logger=Object(q.generateChildLogger)(t,this.name),this.keychain=n||new Ue(this.client,this.logger)}get context(){return Object(q.getLoggerContext)(this.logger)}async init(){await this.keychain.init()}async hasKeys(e){return this.keychain.has(e)}async generateKeyPair(){const e=function(){const e=l.generateKeyPair();return{privateKey:d.arrayToHex(e.privateKey),publicKey:d.arrayToHex(e.publicKey)}}();return this.setKeyPair(e)}async generateSharedKey(e,t,n){const r=await this.getKeyPair(e.publicKey),i=function(e,t){const n=l.derive(d.hexToArray(e),d.hexToArray(t));return d.arrayToHex(n)}(r.privateKey,t.publicKey);return this.setEncryptionKeys({sharedKey:i,publicKey:r.publicKey},n)}async encrypt(e,t){const{sharedKey:n,publicKey:r}=await this.getEncryptionKeys(e);return await async function(e){const t=d.utf8ToArray(e.message),n=d.hexToArray(e.sharedKey),r=d.hexToArray(e.publicKey),i=void 0!==e.iv?d.hexToArray(e.iv):void 0,o=await l.encryptWithSharedKey(t,n,r,i);return d.arrayToHex(o)}({message:t,sharedKey:n,publicKey:r})}async decrypt(e,t){const{sharedKey:n}=await this.getEncryptionKeys(e);return await async function(e){const t=d.hexToArray(e.encrypted),n=d.hexToArray(e.sharedKey),r=await l.decryptWithSharedKey(t,n);return d.arrayToUtf8(r)}({encrypted:t,sharedKey:n})}async encode(e,t){const n=Object(w.b)(t);return await this.hasKeys(e)?await this.encrypt(e,n):d.utf8ToHex(n)}async decode(e,t){const n=await this.hasKeys(e)?await this.decrypt(e,t):d.hexToUtf8(t);return Object(w.a)(n)}concatKeys(e,t){return d.arrayToHex(d.concatArrays(d.hexToArray(e),d.hexToArray(t)))}splitKeys(e){const t=d.hexToArray(e);return[d.arrayToHex(t.slice(0,32)),d.arrayToHex(t.slice(32,64))]}async setKeyPair(e){const t=this.concatKeys(e.publicKey,e.privateKey);return await this.keychain.set(e.publicKey,t),e.publicKey}async getKeyPair(e){const[t,n]=this.splitKeys(await this.keychain.get(e));return{publicKey:e,privateKey:n}}async setEncryptionKeys(e,t){const n=t||await async function(e){const t=await l.sha256(d.hexToArray(e));return d.arrayToHex(t)}(e.sharedKey),r=this.concatKeys(e.sharedKey,e.publicKey);return await this.keychain.set(n,r),n}async getEncryptionKeys(e){const[t,n]=this.splitKeys(await this.keychain.get(e));return{sharedKey:t,publicKey:n}}}class De{constructor(e,t){this.client=e,this.logger=t,this.name="encoder",this.client=e,this.logger=Object(q.generateChildLogger)(t,this.name)}get context(){return Object(q.getLoggerContext)(this.logger)}async encode(e,t){const n=Object(w.b)(t);return await this.client.crypto.hasKeys(e)?await this.client.crypto.encrypt(e,n):d.utf8ToHex(n)}async decode(e,t){const n=await this.client.crypto.hasKeys(e)?await this.client.crypto.decrypt(e,t):d.hexToUtf8(t);return Object(w.a)(n)}}class Le{async encode(e,t){return d.utf8ToHex(Object(w.b)(t))}async decode(e,t){return Object(w.a)(d.hexToUtf8(t))}}class je extends h.IEngine{constructor(e){super(e),this.sequence=e,this.registerEventListeners()}async find(e){return this.sequence.values.filter(t=>{var n,r,i,o,s,a;let c=!1;return(null===(n=t.permissions)||void 0===n?void 0:n.jsonrpc)&&(null===(r=e.jsonrpc)||void 0===r?void 0:r.methods)&&Object(f.i)(e.jsonrpc.methods,t.permissions.jsonrpc.methods)&&(c=!0),(null===(i=t.permissions)||void 0===i?void 0:i.blockchain)&&(null===(o=e.blockchain)||void 0===o?void 0:o.chains)&&Object(f.i)(e.blockchain.chains,t.permissions.blockchain.chains)&&(c=!0),(null===(s=t.permissions)||void 0===s?void 0:s.notifications)&&(null===(a=e.notifications)||void 0===a?void 0:a.types)&&Object(f.i)(e.notifications.types,t.permissions.notifications.types)&&(c=!0),c})}async ping(e,t){const n={method:this.sequence.config.jsonrpc.ping,params:{}};return this.request({topic:e,request:n,timeout:t||Object(f.m)(30)})}async send(e,t,n){const r=t,i=await this.sequence.settled.get(e);if(Object(o.isJsonRpcRequest)(t)&&!Object.values(this.sequence.config.jsonrpc).includes(t.method)){await this.isJsonRpcAuthorized(e,i.self,t),await this.sequence.validateRequest({topic:e,request:t,chainId:n});const r={chainId:n,request:{method:t.method,params:t.params}};r.chainId||delete r.chainId,t=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.payload,r,t.id)}await this.sequence.client.relayer.publish(i.topic,t,{relay:i.relay}),(Object(o.isJsonRpcResponse)(r)||Object(o.isJsonRpcRequest)(r)&&!Object.values(this.sequence.config.jsonrpc).includes(r.method))&&await this.recordPayloadEvent({topic:e,payload:r,chainId:n})}get length(){return this.sequence.settled.length}get topics(){return this.sequence.settled.topics}get values(){return this.sequence.settled.values}create(e){return new Promise(async(t,n)=>{this.sequence.logger.debug("Create "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"create",params:e});const r=(null==e?void 0:e.timeout)||Object(f.m)(300),i=setTimeout(()=>{const e=b.SETTLE_TIMEOUT.format({context:this.sequence.name,timeout:r});this.sequence.logger.error(e.message),n(e.message)},r);let o;try{o=await this.propose(e)}catch(e){return clearTimeout(i),n(e)}this.sequence.pending.on(_e,async e=>{if(o.topic===e.sequence.topic&&O(e.sequence)){const r=e.sequence.outcome;if(clearTimeout(i),T(r)){try{await this.sequence.pending.delete(o.topic,r.reason)}catch(e){return n(e)}n(new Error(r.reason.message))}else try{const e=await this.sequence.settled.get(r.topic),n=b.SETTLED.format({context:this.sequence.name});await this.sequence.pending.delete(o.topic,n),t(e)}catch(e){return n(e)}}})})}async respond(e){this.sequence.logger.debug("Respond "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"respond",params:e}),await this.sequence.validateRespond(e);const{approved:t,proposal:n,response:r}=e,{relay:i,ttl:o}=n,s={publicKey:await this.sequence.client.crypto.generateKeyPair(),metadata:null==r?void 0:r.metadata};if(s.metadata||delete s.metadata,!t){const t=b.NOT_APPROVED.format({context:this.sequence.name}),r={reason:(null==e?void 0:e.reason)||t},o={status:this.sequence.config.status.responded,topic:n.topic,relay:i,self:s,proposal:n,outcome:r};return await this.sequence.pending.set(o.topic,o),o}try{const e={publicKey:s.publicKey,metadata:null==r?void 0:r.metadata};e.metadata||delete e.metadata;const t=Object(f.a)(n.ttl),a=(null==r?void 0:r.state)||{},c={publicKey:n.proposer.publicKey,metadata:n.proposer.metadata};c.metadata||delete c.metadata;const u=n.proposer.controller?{publicKey:c.publicKey}:{publicKey:s.publicKey},h=Object.assign(Object.assign({},n.permissions),{controller:u}),l={topic:(await this.settle({relay:i,self:s,peer:c,permissions:h,state:a,ttl:o,expiry:t})).topic,relay:i,state:a,responder:e,expiry:t},d={status:this.sequence.config.status.responded,topic:n.topic,relay:i,self:s,proposal:n,outcome:l};return await this.sequence.pending.set(d.topic,d),d}catch(e){const t={reason:b.GENERIC.format({message:e.message})},r={status:this.sequence.config.status.responded,topic:n.topic,relay:i,self:s,proposal:n,outcome:t};return await this.sequence.pending.set(r.topic,r),r}}async update(e){this.sequence.logger.debug("Update "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"update",params:e});const t=await this.sequence.settled.get(e.topic),n={publicKey:t.self.publicKey},r=await this.handleUpdate(e.topic,e,n),i=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.update,r);return await this.send(t.topic,i),t}async upgrade(e){this.sequence.logger.debug("Upgrade "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"upgrade",params:e});const t=await this.sequence.settled.get(e.topic),n={publicKey:t.self.publicKey},r=await this.handleUpgrade(e.topic,e,n),i=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.upgrade,r);return await this.send(t.topic,i),t}async request(e){return new Promise(async(t,n)=>{try{await this.sequence.validateRequest(e)}catch(e){return n(e)}const r=Object(o.formatJsonRpcRequest)(e.request.method,e.request.params),i=(null==e?void 0:e.timeout)||Object(f.m)(300),s=setTimeout(()=>{const e=b.JSONRPC_REQUEST_TIMEOUT.format({method:r.method,timeout:i});this.sequence.logger.error(e.message),n(e.message)},i);this.sequence.events.on(this.sequence.config.events.response,i=>{if(e.topic!==i.topic)return;const a=i.response;if(a.id===r.id){if(clearTimeout(s),Object(o.isJsonRpcError)(a)){const e=a.error.message;return this.sequence.logger.error(e),n(new Error(e))}return t(a.result)}});try{await this.send(e.topic,r,null==e?void 0:e.chainId)}catch(e){return clearTimeout(s),n(e)}})}async delete(e){this.sequence.logger.debug("Delete "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"delete",params:e}),await this.sequence.settled.delete(e.topic,e.reason)}async notify(e){const{topic:t,notification:n}=e,r=await this.sequence.settled.get(e.topic);await this.isNotificationAuthorized(e.topic,r.self,n.type);const i=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.notification,n);await this.send(e.topic,i)}async propose(e){this.sequence.logger.debug("Propose "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"propose",params:e}),await this.sequence.validatePropose(e);const t=(null==e?void 0:e.relay)||{protocol:"waku"},n=d.arrayToHex(l.randomBytes(32)),r={publicKey:await this.sequence.client.crypto.generateKeyPair(),metadata:null==e?void 0:e.metadata};r.metadata||delete r.metadata;const i={publicKey:r.publicKey,controller:this.sequence.client.controller,metadata:r.metadata};i.metadata||delete i.metadata;const o={relay:t,topic:n,proposer:i,signal:(null==e?void 0:e.signal)||await this.sequence.getDefaultSignal({topic:n,relay:t,proposer:i}),permissions:(null==e?void 0:e.permissions)||await this.sequence.getDefaultPermissions(),ttl:(null==e?void 0:e.ttl)||await this.sequence.getDefaultTTL()},s={status:this.sequence.config.status.proposed,topic:o.topic,relay:o.relay,self:r,proposal:o};return await this.sequence.pending.set(s.topic,s),s}async settle(e){this.sequence.logger.debug("Settle "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"settle",params:e});const t={topic:await this.sequence.client.crypto.generateSharedKey(e.self,e.peer),relay:e.relay,self:e.self,peer:e.peer,permissions:e.permissions,expiry:e.expiry,state:e.state,acknowledged:!1};return await this.sequence.settled.set(t.topic,t),t}async onResponse(e){const{topic:t,payload:n}=e;this.sequence.logger.debug(`Receiving ${this.sequence.context} response`),this.sequence.logger.trace({type:"method",method:"onResponse",topic:t,payload:n});const r=n,i=r.params,s=await this.sequence.pending.get(t);let a,c;if(function(e){return"reason"in e}(i))this.sequence.logger.error(i.reason),await this.sequence.pending.update(t,{status:this.sequence.config.status.responded,outcome:{reason:i.reason}});else{try{const e=s.proposal.proposer.controller?{publicKey:s.proposal.proposer.publicKey}:{publicKey:i.responder.publicKey},n={publicKey:i.responder.publicKey,metadata:i.responder.metadata};n.metadata||delete n.metadata;const r=i.state||{},o=Object.assign(Object.assign({},s.proposal.permissions),{controller:e}),a=await this.settle({relay:s.relay,self:s.self,peer:n,permissions:o,ttl:s.proposal.ttl,expiry:i.expiry,state:r}),c={topic:a.topic,relay:a.relay,responder:i.responder,expiry:a.expiry,state:a.state};await this.sequence.pending.update(t,{status:this.sequence.config.status.responded,outcome:c})}catch(e){this.sequence.logger.error(e),a=b.GENERIC.format({message:e.message}),c={reason:a},await this.sequence.pending.update(t,{status:this.sequence.config.status.responded,outcome:c})}await this.sequence.client.relayer.publish(s.topic,void 0===a?Object(o.formatJsonRpcResult)(r.id,!0):Object(o.formatJsonRpcError)(r.id,a),{relay:s.relay}),void 0===c||T(c)||await this.sequence.settled.update(c.topic,{acknowledged:!0})}}async onAcknowledge(e){const{topic:t,payload:n}=e;this.sequence.logger.debug(`Receiving ${this.sequence.context} acknowledge`),this.sequence.logger.trace({type:"method",method:"onAcknowledge",topic:t,payload:n});const r=n,i=await this.sequence.pending.get(t);if(!O(i))return;const{outcome:s}=i;Object(o.isJsonRpcError)(r)&&!T(s)&&await this.sequence.settled.delete(s.topic,r.error),void 0===s||T(s)||await this.sequence.settled.update(s.topic,{acknowledged:!0});const a=b.RESPONSE_ACKNOWLEDGED.format({context:this.sequence.name});await this.sequence.pending.delete(t,a)}async onMessage(e){const{topic:t,payload:n}=e;if(this.sequence.logger.debug(`Receiving ${this.sequence.context} message`),this.sequence.logger.trace({type:"method",method:"onMessage",topic:t,payload:n}),Object(o.isJsonRpcRequest)(n)){const t=n,r=await this.sequence.settled.get(e.topic);let i;switch(t.method){case this.sequence.config.jsonrpc.payload:await this.onPayload(e);break;case this.sequence.config.jsonrpc.update:await this.onUpdate(e);break;case this.sequence.config.jsonrpc.upgrade:await this.onUpgrade(e);break;case this.sequence.config.jsonrpc.notification:await this.onNotification(e);break;case this.sequence.config.jsonrpc.delete:await this.sequence.settled.delete(r.topic,t.params.reason);break;case this.sequence.config.jsonrpc.ping:await this.send(r.topic,Object(o.formatJsonRpcResult)(t.id,!0));break;default:i=b.UNKNOWN_JSONRPC_METHOD.format({method:t.method}),this.sequence.logger.error(i.message),await this.send(r.topic,Object(o.formatJsonRpcError)(t.id,i))}}else this.onPayloadEvent(e)}async onPayload(e){const{topic:t,payload:n}=e;if(Object(o.isJsonRpcRequest)(n)){const{id:e,params:r}=n,{chainId:i}=r,s=Object(o.formatJsonRpcRequest)(r.request.method,r.request.params,e),a=await this.sequence.settled.get(t);await this.isJsonRpcAuthorized(t,a.peer,s),await this.sequence.validateRequest({topic:t,request:s,chainId:i});const c={topic:t,payload:s,chainId:i};this.sequence.logger.debug(`Receiving ${this.sequence.context} payload`),this.sequence.logger.trace(Object.assign({type:"method",method:"onPayload"},c)),this.onPayloadEvent(c)}else{const e={topic:t,payload:n};this.sequence.logger.debug(`Receiving ${this.sequence.context} payload`),this.sequence.logger.trace(Object.assign({type:"method",method:"onPayload"},e)),this.onPayloadEvent(e)}}async onUpdate(e){const{topic:t,payload:n}=e;this.sequence.logger.debug(`Receiving ${this.sequence.context} update`),this.sequence.logger.trace({type:"method",method:"onUpdate",topic:t,payload:n});const r=e.payload,i=await this.sequence.settled.get(e.topic);try{const e={publicKey:i.peer.publicKey};await this.handleUpdate(t,r.params,e);const n=Object(o.formatJsonRpcResult)(r.id,!0);await this.send(i.topic,n)}catch(e){this.sequence.logger.error(e);const t=Object(o.formatJsonRpcError)(r.id,e.message);await this.send(i.topic,t)}}async onUpgrade(e){const{topic:t,payload:n}=e;this.sequence.logger.debug(`Receiving ${this.sequence.context} upgrade`),this.sequence.logger.trace({type:"method",method:"onUpgrade",topic:t,payload:n});const r=e.payload,i=await this.sequence.settled.get(e.topic);try{const e={publicKey:i.peer.publicKey};await this.handleUpgrade(t,r.params,e);const n=Object(o.formatJsonRpcResult)(r.id,!0);await this.send(i.topic,n)}catch(e){this.sequence.logger.error(e);const t=Object(o.formatJsonRpcError)(r.id,e.message);await this.send(i.topic,t)}}async onNotification(e){const{params:t}=e.payload,n=e.payload,r=await this.sequence.settled.get(e.topic);try{await this.isNotificationAuthorized(e.topic,r.peer,t.type);const i={topic:e.topic,notification:t},s=this.sequence.config.events.notification;this.sequence.logger.info("Emitting "+s),this.sequence.logger.debug({type:"event",event:s,notificationEvent:i}),this.sequence.events.emit(s,i);const a=Object(o.formatJsonRpcResult)(n.id,!0);await this.send(r.topic,a)}catch(e){this.sequence.logger.error(e);const t=Object(o.formatJsonRpcError)(n.id,e.message);await this.send(r.topic,t)}}async handleUpdate(e,t,n){if(void 0===t.state){const e=b.INVALID_UPDATE_REQUEST.format({context:this.sequence.name});throw this.sequence.logger.error(e.message),new Error(e.message)}const r=await this.sequence.settled.get(e);if(n.publicKey!==r.permissions.controller.publicKey){const e=b.UNAUTHORIZED_UPDATE_REQUEST.format({context:this.sequence.name});throw this.sequence.logger.error(e.message),new Error(e.message)}return r.state=await this.sequence.mergeUpdate(e,t),await this.sequence.settled.update(r.topic,r),t}async handleUpgrade(e,t,n){if(void 0===t.permissions){const e=b.INVALID_UPGRADE_REQUEST.format({context:this.sequence.name});throw this.sequence.logger.error(e.message),new Error(e.message)}const r=await this.sequence.settled.get(e);if(n.publicKey!==r.permissions.controller.publicKey){const e=b.UNAUTHORIZED_UPGRADE_REQUEST.format({context:this.sequence.name});throw this.sequence.logger.error(e.message),new Error(e.message)}return r.permissions=await this.sequence.mergeUpgrade(e,t),await this.sequence.settled.update(r.topic,r),t}async isJsonRpcAuthorized(e,t,n){const r=await this.sequence.settled.get(e);if(t.publicKey!==r.permissions.controller.publicKey&&!r.permissions.jsonrpc.methods.includes(n.method)){const e=b.UNAUTHORIZED_JSON_RPC_METHOD.format({method:n.method});throw this.sequence.logger.error(e.message),new Error(e.message)}}async isNotificationAuthorized(e,t,n){const r=await this.sequence.settled.get(e);if(t.publicKey!==r.permissions.controller.publicKey&&r.self.publicKey!==r.permissions.controller.publicKey&&!r.permissions.notifications.types.includes(n)){const e=b.UNAUTHORIZED_NOTIFICATION_TYPE.format({type:n});throw this.sequence.logger.error(e.message),new Error(e.message)}}async recordPayloadEvent(e){const{topic:t,payload:n,chainId:r}=e;Object(o.isJsonRpcRequest)(n)?await this.sequence.history.set(t,n,r):await this.sequence.history.resolve(n)}async shouldIgnorePayloadEvent(e){const{topic:t,payload:n}=e;if(!this.sequence.settled.sequences.has(t))return!0;let r=!1;try{if(Object(o.isJsonRpcRequest)(n))r=await this.sequence.history.exists(t,n.id);else{let e;try{e=await this.sequence.history.get(t,n.id)}catch(e){}r=void 0!==e&&void 0!==e.response}}catch(e){}return r}async onPayloadEvent(e){const{topic:t,payload:n,chainId:r}=e;if(!await this.shouldIgnorePayloadEvent(e)){if(Object(o.isJsonRpcRequest)(n)){const e={topic:t,request:n,chainId:r},i=this.sequence.config.events.request;this.sequence.logger.info("Emitting "+i),this.sequence.logger.debug({type:"event",event:i,sequence:e}),this.sequence.events.emit(i,e)}else{const e={topic:t,response:n,chainId:r},i=this.sequence.config.events.response;this.sequence.logger.info("Emitting "+i),this.sequence.logger.debug({type:"event",event:i,sequence:e}),this.sequence.events.emit(i,e)}await this.recordPayloadEvent(e)}}async onPendingPayloadEvent(e){if(Object(o.isJsonRpcRequest)(e.payload))switch(e.payload.method){case this.sequence.config.jsonrpc.approve:case this.sequence.config.jsonrpc.reject:this.onResponse(e)}else this.onAcknowledge(e)}async onPendingStatusEvent(e){const{sequence:t}=e;if(R(t.proposal.signal)&&!await this.sequence.client.crypto.hasKeys(t.proposal.topic)){const e=await this.sequence.client.pairing.settled.get(t.proposal.signal.params.topic);await this.sequence.client.crypto.generateSharedKey(e.self,e.peer,t.proposal.topic)}if(O(t)){const n=this.sequence.config.events.responded;if(this.sequence.logger.info("Emitting "+n),this.sequence.logger.debug({type:"event",event:n,sequence:t}),this.sequence.events.emit(n,t),!function(e){return"update"in e}(e)){const{topic:e,outcome:n,relay:r}=t,i=T(n)?this.sequence.config.jsonrpc.reject:this.sequence.config.jsonrpc.approve,s=T(n)?{reason:n.reason}:{relay:n.relay,responder:n.responder,expiry:n.expiry,state:n.state},a=Object(o.formatJsonRpcRequest)(i,s);await this.sequence.client.relayer.publish(e,a,{relay:r})}}else{const e=this.sequence.config.events.proposed;if(this.sequence.logger.info("Emitting "+e),this.sequence.logger.debug({type:"event",event:e,sequence:t}),this.sequence.events.emit(e,t),R(t.proposal.signal)){const e=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.propose,t.proposal);await this.sequence.client.pairing.send(t.proposal.signal.params.topic,e)}}}async subscribeNewPending(e){const{topic:t,sequence:n}=e,r=Object(f.a)(86400);await this.sequence.client.relayer.subscribe(t,{relay:n.relay}),await this.sequence.expirer.set(t,{topic:t,expiry:r})}async subscribeNewSettled(e){const{topic:t,sequence:n}=e,{expiry:r}=n;await this.sequence.client.relayer.subscribe(t,{relay:n.relay}),await this.sequence.expirer.set(t,{topic:t,expiry:r})}registerEventListeners(){this.sequence.pending.on(be,async e=>{await this.subscribeNewPending(e),await this.onPendingStatusEvent(e)}),this.sequence.pending.on(_e,async e=>await this.onPendingStatusEvent(e)),this.sequence.pending.on(we,async e=>{const{sequence:t}=e;await this.sequence.client.relayer.unsubscribe(t.topic,{relay:t.relay}),await this.sequence.expirer.del(t.topic)}),this.sequence.settled.on(be,async e=>{await this.subscribeNewSettled(e);const{sequence:t}=e,n=this.sequence.config.events.settled;this.sequence.logger.info("Emitting "+n),this.sequence.logger.debug({type:"event",event:n,sequence:t}),this.sequence.events.emit(n,t)}),this.sequence.settled.on(_e,async e=>{const{sequence:t,update:n}=e,r=this.sequence.config.events.updated;this.sequence.logger.info("Emitting "+r),this.sequence.logger.debug({type:"event",event:r,sequence:t,update:n}),this.sequence.events.emit(r,t,n)}),this.sequence.settled.on(we,async e=>{const{sequence:t,reason:n}=e,r=this.sequence.config.events.deleted;this.sequence.logger.info("Emitting "+r),this.sequence.logger.debug({type:"event",event:r,sequence:t,reason:n}),this.sequence.events.emit(r,t,n);const i=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.delete,{reason:n});await this.sequence.history.delete(t.topic),await this.sequence.client.relayer.publish(t.topic,i,{relay:t.relay}),await this.sequence.client.relayer.unsubscribe(t.topic,{relay:t.relay}),await this.sequence.expirer.del(t.topic)}),this.sequence.settled.on(Oe,()=>this.sequence.events.emit(this.sequence.config.events.sync)),this.sequence.client.relayer.on(oe,e=>{this.sequence.pending.sequences.has(e.topic)?this.onPendingPayloadEvent(e):this.sequence.settled.sequences.has(e.topic)&&this.onMessage(e)}),this.sequence.expirer.on(z,async e=>{if(this.sequence.pending.sequences.has(e.topic)){const t=b.EXPIRED.format({context:Object(f.d)(this.sequence.pending.context)});this.sequence.pending.delete(e.topic,t)}else{const t=b.EXPIRED.format({context:Object(f.d)(this.sequence.settled.context)});this.sequence.settled.delete(e.topic,t)}})}}class xe extends h.IExpirer{constructor(e,t){super(e,t),this.client=e,this.logger=t,this.expirations=new Map,this.events=new r.EventEmitter,this.name="expirer",this.cached=[],this.client,this.logger=Object(q.generateChildLogger)(t,this.name),this.registerEventListeners()}get context(){return Object(q.getLoggerContext)(this.logger)}get length(){return this.expirations.size}get topics(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}async init(){this.logger.trace("Initialized"),await this.initialize()}async has(e){try{return void 0!==this.getExpiration(e)}catch(e){return!1}}async set(e,t){await this.isInitialized(),this.expirations.set(e,t),this.checkExpiry(e,t),this.events.emit(V,{topic:e,expiration:t})}async get(e){return await this.isInitialized(),this.getExpiration(e)}async del(e){await this.isInitialized();const t=this.getExpiration(e);this.expirations.delete(e),this.events.emit(F,{topic:e,expiration:t})}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)}async persist(){await this.client.storage.setSequenceStore(this.context,this.values),this.events.emit(W)}async restore(){try{const e=await this.client.storage.getSequenceStore(this.context);if(void 0===e)return;if(!e.length)return;if(this.expirations.size){const e=b.RESTORE_WILL_OVERRIDE.format({context:Object(f.d)(this.context)});throw this.logger.error(e.message),new Error(e.message)}this.cached=e,this.logger.debug("Successfully Restored expirations for "+Object(f.d)(this.context)),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug("Failed to Restore expirations for "+Object(f.d)(this.context)),this.logger.error(e)}}async initialize(){await this.restore(),this.reset(),this.onInit()}reset(){this.cached.forEach(e=>this.expirations.set(e.topic,e))}onInit(){this.cached=[],this.events.emit(Y)}async isInitialized(){if(this.cached.length)return new Promise(e=>{this.events.once(Y,()=>e())})}getExpiration(e){const t=this.expirations.get(e);if(!t){const t=b.NO_MATCHING_ID.format({context:Object(f.d)(this.context),topic:e});throw new Error(t.message)}return t}checkExpiry(e,t){const{expiry:n}=t;Object(f.m)(n)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(z,{topic:e,expiration:t})}checkExpirations(){this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.client.heartbeat.on($,()=>this.checkExpirations()),this.events.on(V,e=>{const t=V;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(z,e=>{const t=z;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(F,e=>{const t=F;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}}class qe extends h.IHeartBeat{constructor(e){super(e),this.events=new r.EventEmitter,this.interval=5,this.name="heartbeat",this.logger=void 0!==(null==e?void 0:e.logger)&&"string"!=typeof(null==e?void 0:e.logger)?Object(q.generateChildLogger)(e.logger,this.name):a()(Object(q.getDefaultLoggerOptions)({level:(null==e?void 0:e.logger)||"error"})),this.interval=(null==e?void 0:e.interval)||5}static async init(e){const t=new qe(e);return await t.init(),t}get context(){return Object(q.getLoggerContext)(this.logger)}async init(){this.logger.trace("Initialized"),await this.initialize()}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)}async initialize(){setInterval(()=>this.pulse(),Object(f.m)(this.interval)),this.logger.trace("Initialized")}pulse(){this.events.emit($)}}class Me extends h.IJsonRpcHistory{constructor(e,t){super(e,t),this.logger=e,this.storage=t,this.records=new Map,this.events=new r.EventEmitter,this.name="history",this.cached=[],this.logger=Object(q.generateChildLogger)(e,this.name),this.storage=t,this.registerEventListeners()}async init(){this.logger.trace("Initialized"),await this.initialize()}get context(){return Object(q.getLoggerContext)(this.logger)}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(void 0!==t.response)return;const n={topic:t.topic,request:Object(o.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(n)}),e}async set(e,t,n){if(await this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:n}),this.records.has(t.id))return;const r={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:n};this.records.set(r.id,r),this.events.emit(Q,r)}async resolve(e){if(await this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);void 0===t.response&&(t.response=Object(o.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(Z,t))}async get(e,t){await this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t});const n=await this.getRecord(t);if(n.topic!==e){const e=b.MISMATCHED_TOPIC.format({context:Object(f.d)(this.context),id:t});throw new Error(e.message)}return n}async delete(e,t){await this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(n=>{if(n.topic===e){if(void 0!==t&&n.id!==t)return;this.records.delete(n.id),this.events.emit(X,n)}})}async exists(e,t){if(await this.isInitialized(),!this.records.has(t))return!1;return(await this.getRecord(t)).topic===e}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)}async getRecord(e){await this.isInitialized();const t=this.records.get(e);if(!t){const t=b.NO_MATCHING_ID.format({context:Object(f.d)(this.context),id:e});throw new Error(t.message)}return t}async persist(){await this.storage.setJsonRpcRecords(this.context,this.values),this.events.emit(te)}async restore(){try{const e=await this.storage.getJsonRpcRecords(this.context);if(void 0===e)return;if(!e.length)return;if(this.records.size){const e=b.RESTORE_WILL_OVERRIDE.format({context:Object(f.d)(this.context)});throw this.logger.error(e.message),new Error(e.message)}this.cached=e,this.logger.debug("Successfully Restored records for "+Object(f.d)(this.context)),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug("Failed to Restore records for "+Object(f.d)(this.context)),this.logger.error(e)}}async initialize(){await this.restore(),this.reset(),this.onInit()}reset(){this.cached.forEach(e=>this.records.set(e.id,e))}onInit(){this.cached=[],this.events.emit(ee)}async isInitialized(){if(this.cached.length)return new Promise(e=>{this.events.once(ee,()=>e())})}registerEventListeners(){this.events.on(Q,e=>{const t=Q;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.events.on(Z,e=>{const t=Z;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.events.on(X,e=>{const t=X;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,record:e}),this.persist()})}}class He extends h.IStore{constructor(e,t,n){super(e,t,n),this.client=e,this.logger=t,this.name=n,this.sequences=new Map,this.events=new r.EventEmitter,this.cached=[],this.logger=Object(q.generateChildLogger)(t,this.name),this.registerEventListeners()}async init(){this.logger.trace("Initialized"),await this.initialize()}get context(){return Object(q.getLoggerContext)(this.logger)}get length(){return this.sequences.size}get topics(){return Array.from(this.sequences.keys())}get values(){return Array.from(this.sequences.values())}async set(e,t){await this.isInitialized(),this.sequences.has(e)?this.update(e,t):(this.logger.debug("Setting sequence"),this.logger.trace({type:"method",method:"set",topic:e,sequence:t}),this.sequences.set(e,t),this.events.emit(be,{topic:e,sequence:t}))}async get(e){await this.isInitialized(),this.logger.debug("Getting sequence"),this.logger.trace({type:"method",method:"get",topic:e});return await this.getSequence(e)}async update(e,t){await this.isInitialized(),this.logger.debug("Updating sequence"),this.logger.trace({type:"method",method:"update",topic:e,update:t});const n=Object.assign(Object.assign({},await this.getSequence(e)),t);this.sequences.set(e,n),this.events.emit(_e,{topic:e,sequence:n,update:t})}async delete(e,t){if(await this.isInitialized(),!this.sequences.has(e))return;this.logger.debug("Deleting sequence"),this.logger.trace({type:"method",method:"delete",topic:e,reason:t});const n=await this.getSequence(e);this.sequences.delete(e),this.events.emit(we,{topic:e,sequence:n,reason:t})}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)}async getSequence(e){await this.isInitialized();const t=this.sequences.get(e);if(!t){const t=b.NO_MATCHING_TOPIC.format({context:Object(f.d)(this.context),topic:e});throw this.logger.error(t.message),new Error(t.message)}return t}async persist(){await this.client.storage.setSequenceStore(this.context,this.values),this.events.emit(Oe)}async restore(){try{const e=await this.client.storage.getSequenceStore(this.context);if(void 0===e)return;if(!e.length)return;if(this.sequences.size){const e=b.RESTORE_WILL_OVERRIDE.format({context:Object(f.d)(this.context)});throw this.logger.error(e.message),new Error(e.message)}this.cached=e,this.logger.debug("Successfully Restored sequences for "+Object(f.d)(this.context)),this.logger.trace({type:"method",method:"restore",sequences:this.values})}catch(e){this.logger.debug("Failed to Restore sequences for "+Object(f.d)(this.context)),this.logger.error(e)}}async initialize(){await this.restore(),this.reset(),this.onInit()}reset(){this.cached.forEach(e=>this.sequences.set(e.topic,e))}onInit(){this.cached=[],this.events.emit(Re)}async isInitialized(){if(this.cached.length)return new Promise(e=>{this.events.once(Re,()=>e())})}registerEventListeners(){this.events.on(be,e=>{const t=be;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(_e,e=>{const t=_e;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(we,e=>{const t=we;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}}class Ke extends h.IPairing{constructor(e,t){super(e,t),this.client=e,this.logger=t,this.events=new r.EventEmitter,this.name="pairing",this.config={status:re,events:ie,jsonrpc:ne},this.logger=Object(q.generateChildLogger)(t,this.name),this.pending=new He(e,this.logger,this.config.status.pending),this.settled=new He(e,this.logger,this.config.status.settled),this.history=new Me(this.logger,this.client.storage),this.expirer=new xe(e,this.logger),this.engine=new je(this)}async init(){this.logger.trace("Initialized"),await this.pending.init(),await this.settled.init(),await this.history.init(),await this.expirer.init()}get(e){return this.settled.get(e)}find(e){return this.engine.find(e)}ping(e,t){return this.engine.ping(e,t)}send(e,t){return this.engine.send(e,t)}get context(){return Object(q.getLoggerContext)(this.logger)}get length(){return this.settled.length}get topics(){return this.settled.topics}get values(){return this.settled.values}create(e){return this.engine.create(e)}respond(e){return this.engine.respond(e)}upgrade(e){return this.engine.upgrade(e)}update(e){return this.engine.update(e)}request(e){return this.engine.request(e)}delete(e){return this.engine.delete(e)}notify(e){return this.engine.notify(e)}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)}async mergeUpdate(e,t){const n=await this.settled.get(e);return{metadata:t.state.metadata||n.state.metadata}}async mergeUpgrade(e,t){var n,r,i;const o=await this.settled.get(e);return{jsonrpc:{methods:Object(f.k)(o.permissions.jsonrpc.methods,(null===(n=t.permissions.jsonrpc)||void 0===n?void 0:n.methods)||[])},notifications:{types:Object(f.k)((null===(r=o.permissions.notifications)||void 0===r?void 0:r.types)||[],(null===(i=t.permissions.notifications)||void 0===i?void 0:i.types)||[])},controller:o.permissions.controller}}async validateRespond(e){}async validateRequest(e){}async validatePropose(e){}async getDefaultSignal({topic:e,relay:t,proposer:n}){var r;return{method:"uri",params:{uri:`${(r={protocol:this.client.protocol,version:this.client.version,topic:e,publicKey:n.publicKey,controller:n.controller,relay:t}).protocol}:${r.topic}@${r.version}?`+_.stringify({publicKey:r.publicKey,controller:r.controller,relay:Object(w.b)(r.relay)})}}}async getDefaultTTL(){return 2592e3}async getDefaultPermissions(){return{jsonrpc:{methods:[pe.propose]},notifications:{types:[]}}}}var Je=n(75),Be=n(28),Ge=n(25).a;class ke{constructor(){this.map=new Map}get topics(){return Array.from(this.map.keys())}set(e,t){const n=this.get(e);this.exists(e,t)||this.map.set(e,[...n,t])}get(e){return this.map.get(e)||[]}exists(e,t){return this.get(e).includes(t)}delete(e,t){if(void 0===t)return void this.map.delete(e);if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,t))return;const r=n.filter(e=>e!==t);r.length?this.map.set(e,r):this.map.delete(e)}clear(){this.map.clear()}}class Ve extends h.ISubscriber{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new ke,this.events=new r.EventEmitter,this.name="subscription",this.pending=new Map,this.cached=[],this.relayer=e,this.logger=Object(q.generateChildLogger)(t,this.name),this.registerEventListeners()}async init(){this.logger.trace("Initialized"),await this.initialize()}get context(){return Object(q.getLoggerContext)(this.logger)}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}async subscribe(e,t){this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const n=Qe(t),r={topic:e,relay:n};this.pending.set(e,r);const i=await this.rpcSubscribe(e,n);return await this.onSubscribe(i,r),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}}),i}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}async unsubscribe(e,t){void 0!==(null==t?void 0:t.id)?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}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)}async enable(){this.cached.length&&this.onEnable()}async disable(){this.cached.length||this.onDisable()}async hasSubscription(e,t){await this.isEnabled();let n=!1;try{n=(await this.getSubscription(e)).topic===t}catch(e){}return n}onEnable(){this.cached=[],this.events.emit(Ne)}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear(),this.events.emit(Ae)}async unsubscribeByTopic(e,t){const n=this.topicMap.get(e);await Promise.all(n.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}});try{const r=Qe(n);await this.rpcUnsubscribe(e,t,r);const i=b.DELETED.format({context:Object(f.d)(this.context)});await this.onUnsubscribe(e,t,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t){const n={method:Ze(t.protocol).subscribe,params:{topic:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.provider.request(n)}async rpcUnsubscribe(e,t,n){const r={method:Ze(n.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r}),this.relayer.provider.request(r)}async onSubscribe(e,t){await this.setSubscription(e,Object.assign(Object.assign({},t),{id:e})),this.pending.delete(t.topic)}async onResubscribe(e,t){await this.addSubscription(e,Object.assign(Object.assign({},t),{id:e})),this.pending.delete(t.topic)}async onUnsubscribe(e,t,n){this.events.removeAllListeners(t),await this.hasSubscription(t,e)&&await this.deleteSubscription(t,n),await this.relayer.history.delete(e)}async setSubscription(e,t){await this.isEnabled(),this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),await this.addSubscription(e,t))}async addSubscription(e,t){this.subscriptions.set(e,Object.assign({},t)),this.topicMap.set(t.topic,e),this.events.emit(Se,t)}async getSubscription(e){await this.isEnabled(),this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const t=b.NO_MATCHING_ID.format({context:Object(f.d)(this.context),id:e});throw new Error(t.message)}return t}async deleteSubscription(e,t){await this.isEnabled(),this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const n=await this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Ie,Object.assign(Object.assign({},n),{reason:t}))}async persist(){await this.relayer.storage.setRelayerSubscriptions(this.context,this.values),this.events.emit(Pe)}async restore(){try{const e=await this.relayer.storage.getRelayerSubscriptions(this.context);if(void 0===e)return;if(!e.length)return;if(this.subscriptions.size){const e=b.RESTORE_WILL_OVERRIDE.format({context:Object(f.d)(this.context)});throw this.logger.error(e.message),new Error(e.message)}this.cached=e,this.logger.debug("Successfully Restored subscriptions for "+Object(f.d)(this.context)),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug("Failed to Restore subscriptions for "+Object(f.d)(this.context)),this.logger.error(e)}}async initialize(){await this.restore(),await this.reset(),await this.enable()}async isEnabled(){if(this.cached.length)return new Promise(e=>{this.events.once(Ne,()=>e())})}async reset(){this.cached.length&&await Promise.all(this.cached.map(async e=>this.resubscribe(e)))}async resubscribe(e){const{topic:t,relay:n}=e,r={topic:t,relay:n};this.pending.set(r.topic,r);const i=await this.rpcSubscribe(r.topic,r.relay);if(await this.onResubscribe(i,r),this.ids.includes(e.id)){const t=b.RESUBSCRIBED.format({topic:e.topic});await this.deleteSubscription(e.id,t)}}async onConnect(){await this.reset(),await this.enable()}async onDisconnect(){await this.disable()}checkPending(){this.pending.forEach(async e=>{const t=await this.rpcSubscribe(e.topic,e.relay);await this.onSubscribe(t,e)})}registerEventListeners(){this.relayer.heartbeat.on($,()=>{this.checkPending()}),this.relayer.provider.on(he,async()=>{await this.onConnect()}),this.relayer.provider.on(le,async()=>{await this.onDisconnect()}),this.events.on(Se,async e=>{const t=Se;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(Ie,async e=>{const t=Ie;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}}class Fe extends class{constructor(e,t,n){this.logger=e,this.keyValueStorage=t,this.config=n,this.name="storage",this.version="0.2",this.keyMap=Te,this.logger=Object(q.generateChildLogger)(e,this.name),this.keyValueStorage=t,this.config=n}get context(){return Object(q.getLoggerContext)(this.logger)}get prefix(){return`${this.config.protocol}@${this.config.version}:${this.config.context}:${this.version}`}getStorageKey(e){const t=this.getStorageKeyName(e);if(!this.isValidStorageKeyName(t)){const e=b.INVALID_STORAGE_KEY_NAME.format({name:t});throw new Error(e.message)}return this.prefix+"//"+t}getStorageKeyName(e){return Object(f.f)(e)}isValidStorageKeyName(e){return Object.keys(this.keyMap).map(e=>Object.values(this.keyMap[e])).flat().includes(e.toLowerCase())}}{constructor(e,t,n){super(e,t,n),this.logger=e,this.keyValueStorage=t,this.config=n}async setJsonRpcRecords(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,t)}async getJsonRpcRecords(e){const t=this.getStorageKey(e);return await this.keyValueStorage.getItem(t)}async setRelayerSubscriptions(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,t)}async getRelayerSubscriptions(e){const t=this.getStorageKey(e);return await this.keyValueStorage.getItem(t)}}class ze extends Fe{constructor(e,t,n){super(e,t,n),this.logger=e,this.keyValueStorage=t,this.config=n}async setKeyChain(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,Object(f.j)(t))}async getKeyChain(e){const t=this.getStorageKey(e),n=await this.keyValueStorage.getItem(t);return void 0!==n?Object(f.l)(n):void 0}async setSequenceStore(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,t)}async getSequenceStore(e){const t=this.getStorageKey(e);return await this.keyValueStorage.getItem(t)}async setExpirations(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,t)}async getExpirations(e){const t=this.getStorageKey(e);return await this.keyValueStorage.getItem(t)}}class Ye extends i.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}}class We extends Ye{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new r.EventEmitter,this.name="publisher",this.queue=new Map,this.relayer=e,this.logger=Object(q.generateChildLogger)(t,this.name),this.registerEventListeners()}get context(){return Object(q.getLoggerContext)(this.logger)}async init(){this.logger.trace("Initialized"),await this.initialize()}async publish(e,t,n){this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,payload:t,opts:n}});try{const r=(null==n?void 0:n.ttl)||21600,i=Qe(n),o={topic:e,payload:t,opts:{ttl:r,relay:i}};this.queue.set(t.id,o);const s=await this.relayer.encoder.encode(e,t);await this.rpcPublish(e,s,r,i),await this.onPublish(t.id,o),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,payload:t,opts:n}})}catch(e){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(e),e}}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)}async initialize(){}async rpcPublish(e,t,n,r){const i={method:Ze(r.protocol).publish,params:{topic:e,message:t,ttl:n}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.provider.request(i)}async onPublish(e,t){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:t,payload:n,opts:{ttl:r,relay:i}}=e,o=await this.relayer.encoder.encode(t,n);await this.rpcPublish(t,o,r,i),await this.onPublish(n.id,e)})}registerEventListeners(){this.relayer.heartbeat.on($,()=>{this.checkQueue()})}}class $e extends h.IRelayer{constructor(e){super(e),this.protocol="irn",this.version=1,this.events=new r.EventEmitter,this.name="relayer",this.logger=void 0!==(null==e?void 0:e.logger)&&"string"!=typeof(null==e?void 0:e.logger)?Object(q.generateChildLogger)(e.logger,this.name):a()(Object(q.getDefaultLoggerOptions)({level:(null==e?void 0:e.logger)||"error"}));const t=Object.assign(Object.assign({},fe),null==e?void 0:e.keyValueStorageOptions);this.storage=void 0!==(null==e?void 0:e.storage)?e.storage:new Fe(this.logger,(null==e?void 0:e.keyValueStorage)||new u.a(t),{protocol:this.protocol,version:this.version,context:this.context}),this.heartbeat=(null==e?void 0:e.heartbeat)||new qe({logger:this.logger}),this.encoder=(null==e?void 0:e.encoder)||new Le;const n=(null==e?void 0:e.rpcUrl)||Object(f.e)(this.protocol,this.version,"wss://relay.walletconnect.com",null==e?void 0:e.projectId);this.provider="string"!=typeof(null==e?void 0:e.relayProvider)&&void 0!==(null==e?void 0:e.relayProvider)?null==e?void 0:e.relayProvider:new Be.JsonRpcProvider(new Ge(n)),this.history=new Me(this.logger,this.storage),this.subscriber=new Ve(this,this.logger),this.publisher=new We(this,this.logger),this.registerEventListeners()}get context(){return Object(q.getLoggerContext)(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async init(){this.logger.trace("Initialized"),await this.history.init(),await this.provider.connect(),await this.subscriber.init(),await this.publisher.init()}async publish(e,t,n){await this.publisher.publish(e,t,n),await this.recordPayloadEvent({topic:e,payload:t})}async subscribe(e,t){return await this.subscriber.subscribe(e,t)}async unsubscribe(e,t){await this.subscriber.unsubscribe(e,t)}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)}async recordPayloadEvent(e){const{topic:t,payload:n}=e;Object(o.isJsonRpcRequest)(n)?await this.history.set(t,n):await this.history.resolve(n)}async shouldIgnorePayloadEvent(e){const{topic:t,payload:n}=e;if(!this.subscriber.topics.includes(t))return!0;let r=!1;try{if(Object(o.isJsonRpcRequest)(n))r=await this.history.exists(t,n.id);else{let e;try{e=await this.history.get(t,n.id)}catch(e){}r=void 0!==e&&void 0!==e.response}}catch(e){}return r}async onPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Object(o.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:n,message:r}=t.data,i={topic:n,payload:await this.encoder.decode(n,r)};if(await this.shouldIgnorePayloadEvent(i))return;this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Object.assign({type:"event",event:t.id},i)),this.events.emit(t.id,i),this.events.emit(oe,i),await this.acknowledgePayload(e),await this.recordPayloadEvent(i)}}async acknowledgePayload(e){const t=Object(o.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}registerEventListeners(){this.provider.on(ue,e=>this.onPayload(e)),this.provider.on(he,async()=>{this.events.emit(se)}),this.provider.on(le,async()=>{this.events.emit(ae),setTimeout(()=>{this.provider.connect()},1)}),this.provider.on(de,e=>this.events.emit(ce,e))}}function Qe(e){return(null==e?void 0:e.relay)||{protocol:"waku"}}function Ze(e){const t=Je.RELAY_JSONRPC[e];if(void 0===t)throw new Error("Relay Protocol not supported: "+e);return t}class Xe extends h.ISession{constructor(e,t){super(e,t),this.client=e,this.logger=t,this.events=new r.EventEmitter,this.name="session",this.config={status:ge,events:ye,jsonrpc:pe},this.logger=Object(q.generateChildLogger)(t,this.name),this.pending=new He(e,this.logger,this.config.status.pending),this.settled=new He(e,this.logger,this.config.status.settled),this.history=new Me(this.logger,this.client.storage),this.expirer=new xe(e,this.logger),this.engine=new je(this)}async init(){this.logger.trace("Initialized"),await this.pending.init(),await this.settled.init(),await this.history.init(),await this.expirer.init()}get(e){return this.settled.get(e)}find(e){return this.engine.find(e)}ping(e,t){return this.engine.ping(e,t)}send(e,t,n){return this.engine.send(e,t,n)}get context(){return Object(q.getLoggerContext)(this.logger)}get length(){return this.settled.length}get topics(){return this.settled.topics}get values(){return this.settled.values}create(e){return this.engine.create(e)}respond(e){return this.engine.respond(e)}upgrade(e){return this.engine.upgrade(e)}update(e){return this.engine.update(e)}request(e){return this.engine.request(e)}delete(e){return this.engine.delete(e)}notify(e){return this.engine.notify(e)}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)}async mergeUpdate(e,t){var n;const r=await this.settled.get(e);return{accounts:(null===(n=t.state)||void 0===n?void 0:n.accounts)||r.state.accounts}}async mergeUpgrade(e,t){var n,r,i,o,s;const a=await this.settled.get(e);return{jsonrpc:{methods:Object(f.k)(a.permissions.jsonrpc.methods,(null===(n=t.permissions.jsonrpc)||void 0===n?void 0:n.methods)||[])},notifications:{types:Object(f.k)((null===(r=a.permissions.notifications)||void 0===r?void 0:r.types)||[],(null===(i=t.permissions.notifications)||void 0===i?void 0:i.types)||[])},blockchain:{chains:Object(f.k)((null===(o=a.permissions.blockchain)||void 0===o?void 0:o.chains)||[],(null===(s=t.permissions.blockchain)||void 0===s?void 0:s.chains)||[])},controller:a.permissions.controller}}async validateRespond(e){if(void 0===e){const e=b.MISSING_OR_INVALID.format({name:"respond params"});throw this.logger.error(e.message),new Error(e.message)}const t=A(e);if(j(t))throw this.logger.error(t.error.message),new Error(t.error.message)}async validateRequest(e){if(void 0===e){const e=b.MISSING_OR_INVALID.format({name:"request params"});throw this.logger.error(e.message),new Error(e.message)}const{topic:t,chainId:n}=e,r=await this.settled.get(t);if(n&&!r.permissions.blockchain.chains.includes(n)){const e=b.UNAUTHORIZED_TARGET_CHAIN.format({chainId:n});throw this.logger.error(e.message),new Error(e.message)}}async validatePropose(e){if(void 0===e){const e=b.MISSING_OR_INVALID.format({name:"propose params"});throw this.logger.error(e.message),new Error(e.message)}const t=function(e){const t=I(e.permissions);if(j(t))return t;const n=N(e.metadata);return j(n)?n:{valid:!0}}(e);if(j(t))throw this.logger.error(t.error.message),new Error(t.error.message);if("pairing"!==e.signal.method){const e=b.UNSUPPORTED_SIGNAL.format({context:this.context});throw this.logger.error(e.message),new Error(e.message)}}async getDefaultSignal(e){return{method:"pairing",params:{topic:(await this.client.pairing.settled.get(e.topic)).topic}}}async getDefaultTTL(){return 604800}async getDefaultPermissions(){return{jsonrpc:{methods:[]},notifications:{types:[]},blockchain:{chains:[]}}}}class et extends h.IClient{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new r.EventEmitter,this.name=M;const t=void 0!==(null==e?void 0:e.logger)&&"string"!=typeof(null==e?void 0:e.logger)?e.logger:a()(Object(q.getDefaultLoggerOptions)({level:(null==e?void 0:e.logger)||H}));this.name=(null==e?void 0:e.name)||M,this.controller=(null==e?void 0:e.controller)||K,this.metadata=(null==e?void 0:e.metadata)||Object(f.h)(),this.projectId=null==e?void 0:e.projectId,this.logger=Object(q.generateChildLogger)(t,this.name),this.heartbeat=new qe({logger:this.logger}),this.crypto=new Ce(this,this.logger,null==e?void 0:e.keychain),this.encoder=new De(this,this.logger);const n=Object.assign(Object.assign({},k),null==e?void 0:e.storageOptions);this.storage=new ze(this.logger,(null==e?void 0:e.storage)||new u.a(n),{protocol:this.protocol,version:this.version,context:this.context}),this.relayUrl=Object(f.e)(this.protocol,this.version,(null==e?void 0:e.relayUrl)||J,this.projectId),this.relayer=new $e({rpcUrl:this.relayUrl,heartbeat:this.heartbeat,encoder:this.encoder,logger:this.logger,storage:this.storage,projectId:this.projectId,keyValueStorageOptions:n}),this.pairing=new Ke(this,this.logger),this.session=new Xe(this,this.logger)}static async init(e){const t=new et(e);return await t.initialize(),t}get context(){return Object(q.getLoggerContext)(this.logger)}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)}async connect(e){this.logger.debug("Connecting Application"),this.logger.trace({type:"method",method:"connect",params:e});try{void 0===typeof e.pairing&&this.logger.info("Connecing with existing pairing");const t=void 0===e.pairing?await this.pairing.create():await this.pairing.get(e.pairing.topic);this.logger.trace({type:"method",method:"connect",pairing:t});const n=e.metadata||this.metadata;if(void 0===n){const e=b.MISSING_OR_INVALID.format({name:"app metadata"});throw this.logger.error(e.message),new Error(e.message)}const r=await this.session.create({signal:{method:"pairing",params:{topic:t.topic}},relay:e.relay||{protocol:"waku"},metadata:n,permissions:Object.assign(Object.assign({},e.permissions),{notifications:ve.notifications})});return this.logger.debug("Application Connection Successful"),this.logger.trace({type:"method",method:"connect",session:r}),r}catch(e){throw this.logger.debug("Application Connection Failure"),this.logger.error(e),e}}async pair(e){this.logger.debug("Pairing"),this.logger.trace({type:"method",method:"pair",params:e});const t=function(e){const t=function(e){const t=e.indexOf(":"),n=-1!==e.indexOf("?")?e.indexOf("?"):void 0,r=e.substring(0,t),i=e.substring(t+1,n).split("@"),o=void 0!==n?e.substr(n):"",s=_.parse(o);return{protocol:r,topic:i[0],version:parseInt(i[1],10),publicKey:s.publicKey,controller:"true"===s.controller,relay:Object(w.a)(s.relay)}}(e);return{topic:t.topic,relay:t.relay,proposer:{publicKey:t.publicKey,controller:t.controller},signal:{method:"uri",params:{uri:e}},permissions:{jsonrpc:{methods:[pe.propose]},notifications:{types:[]}},ttl:2592e3}}(e.uri),n=t.proposer.controller!==this.controller,r=n?void 0:b.UNAUTHORIZED_MATCHING_CONTROLLER.format({controller:this.controller}),i=await this.pairing.respond({approved:n,proposal:t,reason:r});if(!function(e){return S(e.status)&&"outcome"in e}(i)){const e=b.NO_MATCHING_RESPONSE.format({context:"pairing"});throw this.logger.error(e.message),new Error(e.message)}if("reason"in i.outcome)throw this.logger.debug("Pairing Failure"),this.logger.trace({type:"method",method:"pair",outcome:i.outcome}),new Error(i.outcome.reason.message);this.logger.debug("Pairing Success"),this.logger.trace({type:"method",method:"pair",pending:i});return await this.pairing.get(i.outcome.topic)}async approve(e){if(this.logger.debug("Approving Session Proposal"),this.logger.trace({type:"method",method:"approve",params:e}),void 0===e.response){const e=b.MISSING_RESPONSE.format({context:"session"});throw this.logger.error(e.message),new Error(e.message)}const t=e.response.state||me,n=e.response.metadata||this.metadata;if(void 0===n){const e=b.MISSING_OR_INVALID.format({name:"app metadata"});throw this.logger.error(e.message),new Error(e.message)}const r=e.proposal.proposer.controller!==this.controller,i=r?void 0:b.UNAUTHORIZED_MATCHING_CONTROLLER.format({controller:this.controller}),o=await this.session.respond({approved:r,proposal:e.proposal,response:{state:t,metadata:n},reason:i});if(!function(e){return S(e.status)&&"outcome"in e}(o)){const e=b.NO_MATCHING_RESPONSE.format({context:"session"});throw this.logger.error(e.message),new Error(e.message)}if("reason"in o.outcome)throw this.logger.debug("Session Proposal Approval Failure"),this.logger.trace({type:"method",method:"approve",outcome:o.outcome}),new Error(o.outcome.reason.message);return this.logger.debug("Session Proposal Approval Success"),this.logger.trace({type:"method",method:"approve",pending:o}),this.session.get(o.outcome.topic)}async reject(e){this.logger.debug("Rejecting Session Proposal"),this.logger.trace({type:"method",method:"reject",params:e});const t=await this.session.respond({approved:!1,proposal:e.proposal,response:Ee,reason:e.reason});this.logger.debug("Session Proposal Response Success"),this.logger.trace({type:"method",method:"reject",pending:t})}async upgrade(e){await this.session.upgrade(e)}async update(e){await this.session.update(e)}async request(e){return this.session.request(e)}async respond(e){await this.session.send(e.topic,e.response)}async ping(e){await this.session.ping(e.topic,e.timeout)}async notify(e){await this.session.notify(e)}async disconnect(e){this.logger.debug("Disconnecting Application"),this.logger.trace({type:"method",method:"disconnect",params:e}),await this.session.delete(e)}async onPairingRequest(e,t){if(e.method===pe.propose){const n=e.params;if(n.proposer.controller===this.controller){const e=b.UNAUTHORIZED_MATCHING_CONTROLLER.format({controller:this.controller});return void await this.session.respond({approved:!1,proposal:n,response:Ee,reason:e})}const r=G.proposal;this.logger.info("Emitting "+r),this.logger.debug({type:"event",event:r,data:n}),this.events.emit(r,n);const i=Object(o.formatJsonRpcResult)(e.id,!0);await this.pairing.send(t,i)}}async onPairingSettled(e){e.permissions.controller.publicKey===e.self.publicKey&&void 0===e.state.metadata&&setTimeout(async()=>await this.pairing.update({topic:e.topic,state:{metadata:this.metadata}}),50)}async initialize(){this.logger.trace("Initialized");try{await this.pairing.init(),await this.session.init(),await this.crypto.init(),await this.relayer.init(),await this.heartbeat.init(),this.registerEventListeners(),this.logger.info("Client Initilization Success")}catch(e){throw this.logger.info("Client Initilization Failure"),this.logger.error(e),e}}registerEventListeners(){this.pairing.on(ie.proposed,e=>{const t=B.proposal;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e.proposal}),this.events.emit(t,e.proposal)}),this.pairing.on(ie.settled,e=>{const t=B.created;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e),this.onPairingSettled(e)}),this.pairing.on(ie.updated,(e,t)=>{const n=B.updated;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,update:t}),this.events.emit(n,e,t)}),this.pairing.on(ie.deleted,(e,t)=>{const n=B.deleted;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,reason:t}),this.events.emit(n,e,t)}),this.pairing.on(ie.request,e=>{this.onPairingRequest(e.request,e.topic)}),this.session.on(ie.sync,()=>this.events.emit(B.sync)),this.session.on(ye.proposed,e=>{const t=G.proposal;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e.proposal}),this.events.emit(t,e.proposal)}),this.session.on(ye.settled,e=>{const t=G.created;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e)}),this.session.on(ye.updated,(e,t)=>{const n=G.updated;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,update:t}),this.events.emit(n,e,t)}),this.session.on(ye.deleted,(e,t)=>{const n=G.deleted;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,reason:t}),this.events.emit(n,e,t)}),this.session.on(ye.request,e=>{const t=G.request;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e)}),this.session.on(ye.response,e=>{const t=G.response;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e)}),this.session.on(ye.notification,e=>{const t=G.notification;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e)}),this.session.on(ye.sync,()=>this.events.emit(G.sync))}}const tt=et;const nt={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",notification:"signer_notification"};class rt extends i.IJsonRpcConnection{constructor(e){super(),this.events=new r.EventEmitter,this.pending=!1,this.initializing=!1,this.chains=(null==e?void 0:e.chains)||[],this.methods=(null==e?void 0:e.methods)||[],this.opts=null==e?void 0:e.client}get connected(){return void 0!==this.session}get connecting(){return this.pending}get accounts(){var e;return(null===(e=this.session)||void 0===e?void 0:e.state.accounts)||[]}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)}async open(){if(this.pending)return new Promise((e,t)=>{this.events.once("open",()=>{if(this.events.once("open_error",e=>{t(e)}),void 0===this.client)return t(new Error("Client not initialized"));e()})});try{this.pending=!0;const e=await this.register(),t=await e.session.find({blockchain:{chains:this.chains},jsonrpc:{methods:this.methods}});if(t.length)return this.onOpen(t[0]);this.session=await e.connect({permissions:{blockchain:{chains:this.chains},jsonrpc:{methods:this.methods}}}),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){if(void 0===this.session)return;const e=await this.register();await e.disconnect({topic:this.session.topic,reason:b.USER_DISCONNECTED.format()}),this.onClose()}async send(e,t){if(void 0===this.client&&(this.client=await this.register(),this.connected||await this.open()),void 0===this.session)throw new Error("Signer connection is missing session");this.client.request({topic:this.session.topic,request:e,chainId:null==t?void 0:t.chainId}).then(t=>this.events.emit("payload",Object(o.formatJsonRpcResult)(e.id,t))).catch(t=>this.events.emit("payload",Object(o.formatJsonRpcError)(e.id,t.message)))}async register(e=this.opts){if(void 0!==this.client)return this.client;if(this.initializing)return new Promise((e,t)=>{this.events.once("register_error",e=>{t(e)}),this.events.once(nt.init,()=>{if(void 0===this.client)return t(new Error("Client not initialized"));e(this.client)})});if(function(e){return void 0!==e&&void 0!==e.context}(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await tt.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(nt.init),this.client}catch(e){throw this.events.emit("register_error",e),e}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){void 0!==this.client&&(this.client.on(G.created,e=>{var t;this.session&&(null===(t=this.session)||void 0===t?void 0:t.topic)!==e.topic||(this.session=e,this.events.emit(nt.created,e))}),this.client.on(G.updated,e=>{var t;this.session&&(null===(t=this.session)||void 0===t?void 0:t.topic)!==e.topic||(this.session=e,this.events.emit(nt.updated,e))}),this.client.on(G.notification,e=>{var t;this.session&&(null===(t=this.session)||void 0===t?void 0:t.topic)!==e.topic||this.events.emit(nt.notification,e.notification)}),this.client.on(G.deleted,e=>{var t;this.session&&(this.session&&(null===(t=this.session)||void 0===t?void 0:t.topic)!==e.topic||(this.onClose(),this.events.emit(nt.deleted,e),this.session=void 0))}),this.client.on(B.proposal,async e=>{const t=e.signal.params.uri;this.events.emit(nt.uri,{uri:t})}))}}t.default=rt},function(e,t,n){"use strict";n.r(t),n.d(t,"HttpConnection",(function(){return u}));var r=n(3),i=n(29),o=n.n(i),s=n(8),a=n(0);const c={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class u{constructor(e){if(this.url=e,this.events=new r.EventEmitter,this.isAvailable=!1,this.registering=!1,!Object(a.isHttpUrl)(e))throw new Error("Provided URL is not compatible with HTTP connection: "+e);this.url=e}get connected(){return this.isAvailable}get connecting(){return this.registering}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)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e,t){this.isAvailable||await this.register();try{const t=Object(s.b)(e),n=await o()(this.url,Object.assign(Object.assign({},c),{body:t})),r=await n.json();this.onPayload({data:r})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!Object(a.isHttpUrl)(e))throw new Error("Provided URL is not compatible with HTTP connection: "+e);if(this.registering)return new Promise((e,t)=>{this.events.once("register_error",e=>{t(e)}),this.events.once("open",()=>{if(void 0===this.isAvailable)return t(new Error("HTTP connection is missing or invalid"));e()})});this.url=e,this.registering=!0;try{const t=Object(s.b)({id:1,jsonrpc:"2.0",method:"test",params:[]});await o()(e,Object.assign(Object.assign({},c),{body:t})),this.onOpen()}catch(e){const t=this.parseError(e);throw this.events.emit("register_error",t),this.onClose(),t}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(void 0===e.data)return;const t="string"==typeof e.data?Object(s.a)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const n=this.parseError(t),r=n.message||n.toString(),i=Object(a.formatJsonRpcError)(e,r);this.events.emit("payload",i)}parseError(e,t=this.url){return Object(a.parseConnectionError)(e,t,"HTTP")}}var h=u;t.default=h}])}));
|
|
25
|
+
t.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,u=c>>1,h=-7,l=n?i-1:0,d=n?-1:1,f=e[t+l];for(l+=d,o=f&(1<<-h)-1,f>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+e[t+l],l+=d,h-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=u}return(f?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var s,a,c,u=8*o-i-1,h=(1<<u)-1,l=h>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?d/c:d*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*c-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[n+f]=255&s,f+=p,s/=256,u-=8);e[n+f-p]|=128*g}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){(function(t){var r=n(68).strict;e.exports=function(e){if(r(e)){var n=t.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(n=n.slice(e.byteOffset,e.byteOffset+e.byteLength)),n}return t.from(e)}}).call(this,n(67).Buffer)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(91),i=n(95),o=n(27);function s(e,n){return void 0===n&&(n=t.defaultRandomSource),n.randomBytes(e)}t.defaultRandomSource=new r.SystemRandomSource,t.randomBytes=s,t.randomUint32=function(e){void 0===e&&(e=t.defaultRandomSource);var n=s(4,e),r=i.readUint32LE(n);return o.wipe(n),r};var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(e,n,r){if(void 0===n&&(n=a),void 0===r&&(r=t.defaultRandomSource),n.length<2)throw new Error("randomString charset is too short");if(n.length>256)throw new Error("randomString charset is too long");for(var i="",c=n.length,u=256-256%c;e>0;){for(var h=s(Math.ceil(256*e/u),r),l=0;l<h.length&&e>0;l++){var d=h[l];d<u&&(i+=n.charAt(d%c),e--)}o.wipe(h)}return i}t.randomString=c,t.randomStringForEntropy=function(e,n,r){return void 0===n&&(n=a),void 0===r&&(r=t.defaultRandomSource),c(Math.ceil(e/(Math.log(n.length)/Math.LN2)),n,r)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(92),i=n(93),o=function(){function e(){return this.isAvailable=!1,this.name="",this._source=new r.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new i.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}return e.prototype.randomBytes=function(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)},e}();t.SystemRandomSource=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.isAvailable=!1,this.isInstantiated=!1;var e="undefined"!=typeof self?self.crypto||self.msCrypto:null;e&&e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return e.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");for(var t=new Uint8Array(e),n=0;n<t.length;n+=65536)this._crypto.getRandomValues(t.subarray(n,n+Math.min(t.length-n,65536)));return t},e}();t.BrowserRandomSource=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(27),i=function(){function e(){this.isAvailable=!1,this.isInstantiated=!1;var e=n(94);e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return e.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");var t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");for(var n=new Uint8Array(e),i=0;i<n.length;i++)n[i]=t[i];return r.wipe(t),n},e}();t.NodeRandomSource=i},function(e,t){},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(96);function i(e,t,n){return void 0===t&&(t=new Uint8Array(2)),void 0===n&&(n=0),t[n+0]=e>>>8,t[n+1]=e>>>0,t}function o(e,t,n){return void 0===t&&(t=new Uint8Array(2)),void 0===n&&(n=0),t[n+0]=e>>>0,t[n+1]=e>>>8,t}function s(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function a(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function c(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function u(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function h(e,t,n){return void 0===t&&(t=new Uint8Array(4)),void 0===n&&(n=0),t[n+0]=e>>>24,t[n+1]=e>>>16,t[n+2]=e>>>8,t[n+3]=e>>>0,t}function l(e,t,n){return void 0===t&&(t=new Uint8Array(4)),void 0===n&&(n=0),t[n+0]=e>>>0,t[n+1]=e>>>8,t[n+2]=e>>>16,t[n+3]=e>>>24,t}function d(e,t,n){return void 0===t&&(t=new Uint8Array(8)),void 0===n&&(n=0),h(e/4294967296>>>0,t,n),h(e>>>0,t,n+4),t}function f(e,t,n){return void 0===t&&(t=new Uint8Array(8)),void 0===n&&(n=0),l(e>>>0,t,n),l(e/4294967296>>>0,t,n+4),t}t.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},t.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},t.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},t.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},t.writeUint16BE=i,t.writeInt16BE=i,t.writeUint16LE=o,t.writeInt16LE=o,t.readInt32BE=s,t.readUint32BE=a,t.readInt32LE=c,t.readUint32LE=u,t.writeUint32BE=h,t.writeInt32BE=h,t.writeUint32LE=l,t.writeInt32LE=l,t.readInt64BE=function(e,t){void 0===t&&(t=0);var n=s(e,t),r=s(e,t+4);return 4294967296*n+r-4294967296*(r>>31)},t.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*a(e,t)+a(e,t+4)},t.readInt64LE=function(e,t){void 0===t&&(t=0);var n=c(e,t);return 4294967296*c(e,t+4)+n-4294967296*(n>>31)},t.readUint64LE=function(e,t){void 0===t&&(t=0);var n=u(e,t);return 4294967296*u(e,t+4)+n},t.writeUint64BE=d,t.writeInt64BE=d,t.writeUint64LE=f,t.writeInt64LE=f,t.readUintBE=function(e,t,n){if(void 0===n&&(n=0),e%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-n)throw new Error("readUintBE: array is too short for the given bitLength");for(var r=0,i=1,o=e/8+n-1;o>=n;o--)r+=t[o]*i,i*=256;return r},t.readUintLE=function(e,t,n){if(void 0===n&&(n=0),e%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-n)throw new Error("readUintLE: array is too short for the given bitLength");for(var r=0,i=1,o=n;o<n+e/8;o++)r+=t[o]*i,i*=256;return r},t.writeUintBE=function(e,t,n,i){if(void 0===n&&(n=new Uint8Array(e/8)),void 0===i&&(i=0),e%8!=0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!r.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var o=1,s=e/8+i-1;s>=i;s--)n[s]=t/o&255,o*=256;return n},t.writeUintLE=function(e,t,n,i){if(void 0===n&&(n=new Uint8Array(e/8)),void 0===i&&(i=0),e%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!r.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var o=1,s=i;s<i+e/8;s++)n[s]=t/o&255,o*=256;return n},t.readFloat32BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t)},t.readFloat32LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t,!0)},t.readFloat64BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t)},t.readFloat64LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t,!0)},t.writeFloat32BE=function(e,t,n){return void 0===t&&(t=new Uint8Array(4)),void 0===n&&(n=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(n,e),t},t.writeFloat32LE=function(e,t,n){return void 0===t&&(t=new Uint8Array(4)),void 0===n&&(n=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(n,e,!0),t},t.writeFloat64BE=function(e,t,n){return void 0===t&&(t=new Uint8Array(8)),void 0===n&&(n=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(n,e),t},t.writeFloat64LE=function(e,t,n){return void 0===t&&(t=new Uint8Array(8)),void 0===n&&(n=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(n,e,!0),t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mul=Math.imul||function(e,t){var n=65535&e,r=65535&t;return n*r+((e>>>16&65535)*r+n*(t>>>16&65535)<<16>>>0)|0},t.add=function(e,t){return e+t|0},t.sub=function(e,t){return e-t|0},t.rotl=function(e,t){return e<<t|e>>>32-t},t.rotr=function(e,t){return e<<32-t|e>>>t},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(e){return t.isInteger(e)&&e>=-t.MAX_SAFE_INTEGER&&e<=t.MAX_SAFE_INTEGER}},function(e,t,n){"use strict";e.exports=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())},function(e,t,n){"use strict";var r=new RegExp("%[a-f0-9]{2}","gi"),i=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],o(n),o(r))}function s(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(r),n=1;n<t.length;n++)t=(e=o(t,n).join("")).match(r);return e}}e.exports=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var t={"%FE%FF":"��","%FF%FE":"��"},n=i.exec(e);n;){try{t[n[0]]=decodeURIComponent(n[0])}catch(e){var r=s(n[0]);r!==n[0]&&(t[n[0]]=r)}n=i.exec(e)}t["%C2"]="�";for(var o=Object.keys(t),a=0;a<o.length;a++){var c=o[a];e=e.replace(new RegExp(c,"g"),t[c])}return e}(e)}}},function(e,t,n){"use strict";e.exports=(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const n=e.indexOf(t);return-1===n?[e]:[e.slice(0,n),e.slice(n+t.length)]}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n={},r=Object.keys(e),i=Array.isArray(t),o=0;o<r.length;o++){var s=r[o],a=e[s];(i?-1!==t.indexOf(s):t(s,a,e))&&(n[s]=a)}return n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateChildLogger=t.formatChildLoggerContext=t.getLoggerContext=t.setBrowserLoggerContext=t.getBrowserLoggerContext=t.getDefaultLoggerOptions=void 0;const r=n(72);function i(e,t=r.PINO_CUSTOM_CONTEXT_KEY){return e[t]||""}function o(e,t,n=r.PINO_CUSTOM_CONTEXT_KEY){return e[n]=t,e}function s(e,t=r.PINO_CUSTOM_CONTEXT_KEY){let n="";return n=void 0===e.bindings?i(e,t):e.bindings().context||"",n}function a(e,t,n=r.PINO_CUSTOM_CONTEXT_KEY){const i=s(e,n);return i.trim()?`${i}/${t}`:t}t.getDefaultLoggerOptions=function(e){return Object.assign(Object.assign({},e),{level:(null==e?void 0:e.level)||r.PINO_LOGGER_DEFAULTS.level,prettyPrint:(null==e?void 0:e.prettyPrint)||r.PINO_LOGGER_DEFAULTS.prettyPrint})},t.getBrowserLoggerContext=i,t.setBrowserLoggerContext=o,t.getLoggerContext=s,t.formatChildLoggerContext=a,t.generateChildLogger=function(e,t,n=r.PINO_CUSTOM_CONTEXT_KEY){const i=a(e,t,n);return o(e.child({context:i}),i,n)}},function(e,t,n){"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},function(e,t,n){"use strict";n.r(t),n.d(t,"SIGNER_EVENTS",(function(){return nt})),n.d(t,"SignerConnection",(function(){return rt}));var r=n(3),i=n(5),o=n(0),s=n(19),a=n.n(s),c=n(26),u=n.n(c),h=n(6),l=n(17),d=n(2);var f=n(12);const p=Object(f.c)({GENERIC:"GENERIC",MISSING_OR_INVALID:"MISSING_OR_INVALID",MISSING_RESPONSE:"MISSING_RESPONSE",MISSING_DECRYPT_PARAMS:"MISSING_DECRYPT_PARAMS",INVALID_UPDATE_REQUEST:"INVALID_UPDATE_REQUEST",INVALID_UPGRADE_REQUEST:"INVALID_UPGRADE_REQUEST",INVALID_STORAGE_KEY_NAME:"INVALID_STORAGE_KEY_NAME",RECORD_ALREADY_EXISTS:"RECORD_ALREADY_EXISTS",RESTORE_WILL_OVERRIDE:"RESTORE_WILL_OVERRIDE",NO_MATCHING_ID:"NO_MATCHING_ID",NO_MATCHING_TOPIC:"NO_MATCHING_TOPIC",NO_MATCHING_RESPONSE:"NO_MATCHING_RESPONSE",NO_MATCHING_KEY:"NO_MATCHING_KEY",UNKNOWN_JSONRPC_METHOD:"UNKNOWN_JSONRPC_METHOD",MISMATCHED_TOPIC:"MISMATCHED_TOPIC",MISMATCHED_ACCOUNTS:"MISMATCHED_ACCOUNTS",SETTLED:"SETTLED",NOT_APPROVED:"NOT_APPROVED",PROPOSAL_RESPONDED:"PROPOSAL_RESPONDED",RESPONSE_ACKNOWLEDGED:"RESPONSE_ACKNOWLEDGED",EXPIRED:"EXPIRED",DELETED:"DELETED",RESUBSCRIBED:"RESUBSCRIBED",SETTLE_TIMEOUT:"SETTLE_TIMEOUT",JSONRPC_REQUEST_TIMEOUT:"JSONRPC_REQUEST_TIMEOUT",UNAUTHORIZED_TARGET_CHAIN:"UNAUTHORIZED_TARGET_CHAIN",UNAUTHORIZED_JSON_RPC_METHOD:"UNAUTHORIZED_JSON_RPC_METHOD",UNAUTHORIZED_NOTIFICATION_TYPE:"UNAUTHORIZED_NOTIFICATION_TYPE",UNAUTHORIZED_UPDATE_REQUEST:"UNAUTHORIZED_UPDATE_REQUEST",UNAUTHORIZED_UPGRADE_REQUEST:"UNAUTHORIZED_UPGRADE_REQUEST",UNAUTHORIZED_MATCHING_CONTROLLER:"UNAUTHORIZED_MATCHING_CONTROLLER",JSONRPC_REQUEST_METHOD_REJECTED:"JSONRPC_REQUEST_METHOD_REJECTED",JSONRPC_REQUEST_METHOD_UNAUTHORIZED:"JSONRPC_REQUEST_METHOD_UNAUTHORIZED",JSONRPC_REQUEST_METHOD_UNSUPPORTED:"JSONRPC_REQUEST_METHOD_UNSUPPORTED",DISCONNECTED_ALL_CHAINS:"DISCONNECTED_ALL_CHAINS",DISCONNECTED_TARGET_CHAIN:"DISCONNECTED_TARGET_CHAIN",DISAPPROVED_CHAINS:"DISAPPROVED_CHAINS",DISAPPROVED_JSONRPC:"DISAPPROVED_JSONRPC",DISAPPROVED_NOTIFICATION:"DISAPPROVED_NOTIFICATION",UNSUPPORTED_CHAINS:"UNSUPPORTED_CHAINS",UNSUPPORTED_JSONRPC:"UNSUPPORTED_JSONRPC",UNSUPPORTED_NOTIFICATION:"UNSUPPORTED_NOTIFICATION",UNSUPPORTED_SIGNAL:"UNSUPPORTED_SIGNAL",USER_DISCONNECTED:"USER_DISCONNECTED",UNKNOWN:"UNKNOWN"}),g="undefined",y="Something went wrong",v="parameter",m="session",E="Ethereum",b={[p.GENERIC]:{type:p.GENERIC,code:0,stringify:e=>(null==e?void 0:e.message)||y,format:e=>({code:b[p.GENERIC].code,message:b[p.GENERIC].stringify(e)})},[p.MISSING_OR_INVALID]:{type:p.MISSING_OR_INVALID,code:1e3,stringify:e=>"Missing or invalid "+((null==e?void 0:e.name)||v),format:e=>({code:b[p.MISSING_OR_INVALID].code,message:b[p.MISSING_OR_INVALID].stringify(e)})},[p.MISSING_RESPONSE]:{type:p.MISSING_RESPONSE,code:1001,stringify:e=>`Response is required for approved ${(null==e?void 0:e.context)||m} proposals`,format:e=>({code:b[p.MISSING_RESPONSE].code,message:b[p.MISSING_RESPONSE].stringify(e)})},[p.MISSING_DECRYPT_PARAMS]:{type:p.MISSING_DECRYPT_PARAMS,code:1002,stringify:e=>"Decrypt params required for "+((null==e?void 0:e.context)||m),format:e=>({code:b[p.MISSING_DECRYPT_PARAMS].code,message:b[p.MISSING_DECRYPT_PARAMS].stringify(e)})},[p.INVALID_UPDATE_REQUEST]:{type:p.INVALID_UPDATE_REQUEST,code:1003,stringify:e=>`Invalid ${(null==e?void 0:e.context)||m} update request`,format:e=>({code:b[p.INVALID_UPDATE_REQUEST].code,message:b[p.INVALID_UPDATE_REQUEST].stringify(e)})},[p.INVALID_UPGRADE_REQUEST]:{type:p.INVALID_UPGRADE_REQUEST,code:1004,stringify:e=>`Invalid ${(null==e?void 0:e.context)||m} upgrade request`,format:e=>({code:b[p.INVALID_UPGRADE_REQUEST].code,message:b[p.INVALID_UPGRADE_REQUEST].stringify(e)})},[p.INVALID_STORAGE_KEY_NAME]:{type:p.INVALID_STORAGE_KEY_NAME,code:1005,stringify:e=>"Invalid storage key name: "+((null==e?void 0:e.name)||v),format:e=>({code:b[p.INVALID_STORAGE_KEY_NAME].code,message:b[p.INVALID_STORAGE_KEY_NAME].stringify(e)})},[p.RECORD_ALREADY_EXISTS]:{type:p.RECORD_ALREADY_EXISTS,code:1100,stringify:e=>`Record already exists for ${(null==e?void 0:e.context)||m} matching id: ${null==e?void 0:e.id}`,format:e=>({code:b[p.RECORD_ALREADY_EXISTS].code,message:b[p.RECORD_ALREADY_EXISTS].stringify(e)})},[p.RESTORE_WILL_OVERRIDE]:{type:p.RESTORE_WILL_OVERRIDE,code:1200,stringify:e=>"Restore will override already set "+((null==e?void 0:e.context)||m),format:e=>({code:b[p.RESTORE_WILL_OVERRIDE].code,message:b[p.RESTORE_WILL_OVERRIDE].stringify(e)})},[p.NO_MATCHING_ID]:{type:p.NO_MATCHING_ID,code:1300,stringify:e=>`No matching ${(null==e?void 0:e.context)||m} with id: ${null==e?void 0:e.id}`,format:e=>({code:b[p.NO_MATCHING_ID].code,message:b[p.NO_MATCHING_ID].stringify(e)})},[p.NO_MATCHING_TOPIC]:{type:p.NO_MATCHING_TOPIC,code:1301,stringify:e=>`No matching ${(null==e?void 0:e.context)||m} with topic: ${null==e?void 0:e.topic}`,format:e=>({code:b[p.NO_MATCHING_TOPIC].code,message:b[p.NO_MATCHING_TOPIC].stringify(e)})},[p.NO_MATCHING_RESPONSE]:{type:p.NO_MATCHING_RESPONSE,code:1302,stringify:e=>`No response found in pending ${(null==e?void 0:e.context)||m} proposal`,format:e=>({code:b[p.NO_MATCHING_RESPONSE].code,message:b[p.NO_MATCHING_RESPONSE].stringify(e)})},[p.NO_MATCHING_KEY]:{type:p.NO_MATCHING_KEY,code:1303,stringify:e=>"No matching key with tag: "+(null==e?void 0:e.tag),format:e=>({code:b[p.NO_MATCHING_KEY].code,message:b[p.NO_MATCHING_KEY].stringify(e)})},[p.UNKNOWN_JSONRPC_METHOD]:{type:p.UNKNOWN_JSONRPC_METHOD,code:1400,stringify:e=>"Unknown JSON-RPC Method Requested: "+(null==e?void 0:e.method),format:e=>({code:b[p.UNKNOWN_JSONRPC_METHOD].code,message:b[p.UNKNOWN_JSONRPC_METHOD].stringify(e)})},[p.MISMATCHED_TOPIC]:{type:p.MISMATCHED_TOPIC,code:1500,stringify:e=>`Mismatched topic for ${(null==e?void 0:e.context)||m} with id: ${null==e?void 0:e.id}`,format:e=>({code:b[p.MISMATCHED_TOPIC].code,message:b[p.MISMATCHED_TOPIC].stringify(e)})},[p.MISMATCHED_ACCOUNTS]:{type:p.MISMATCHED_ACCOUNTS,code:1501,stringify:e=>"Invalid accounts with mismatched chains: "+(null==e?void 0:e.mismatched.toString()),format:e=>({code:b[p.MISMATCHED_ACCOUNTS].code,message:b[p.MISMATCHED_ACCOUNTS].stringify(e)})},[p.SETTLED]:{type:p.SETTLED,code:1600,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" settled",format:e=>({code:b[p.SETTLED].code,message:b[p.SETTLED].stringify(e)})},[p.NOT_APPROVED]:{type:p.NOT_APPROVED,code:1601,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" not approved",format:e=>({code:b[p.NOT_APPROVED].code,message:b[p.NOT_APPROVED].stringify(e)})},[p.PROPOSAL_RESPONDED]:{type:p.PROPOSAL_RESPONDED,code:1602,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" proposal responded",format:e=>({code:b[p.PROPOSAL_RESPONDED].code,message:b[p.PROPOSAL_RESPONDED].stringify(e)})},[p.RESPONSE_ACKNOWLEDGED]:{type:p.RESPONSE_ACKNOWLEDGED,code:1603,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" response acknowledge",format:e=>({code:b[p.RESPONSE_ACKNOWLEDGED].code,message:b[p.RESPONSE_ACKNOWLEDGED].stringify(e)})},[p.EXPIRED]:{type:p.EXPIRED,code:1604,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" expired",format:e=>({code:b[p.EXPIRED].code,message:b[p.EXPIRED].stringify(e)})},[p.DELETED]:{type:p.DELETED,code:1605,stringify:e=>Object(f.b)((null==e?void 0:e.context)||m)+" deleted",format:e=>({code:b[p.DELETED].code,message:b[p.DELETED].stringify(e)})},[p.RESUBSCRIBED]:{type:p.RESUBSCRIBED,code:1606,stringify:e=>"Subscription resubscribed with topic: "+(e.topic||g),format:e=>({code:b[p.RESUBSCRIBED].code,message:b[p.RESUBSCRIBED].stringify(e)})},[p.SETTLE_TIMEOUT]:{type:p.SETTLE_TIMEOUT,code:2e3,stringify:e=>`${Object(f.b)((null==e?void 0:e.context)||m)} failed to settle after ${Object(f.g)(null==e?void 0:e.timeout)} seconds`,format:e=>({code:b[p.SETTLE_TIMEOUT].code,message:b[p.SETTLE_TIMEOUT].stringify(e)})},[p.JSONRPC_REQUEST_TIMEOUT]:{type:p.JSONRPC_REQUEST_TIMEOUT,code:2001,stringify:e=>`JSON-RPC Request timeout after ${Object(f.g)(null==e?void 0:e.timeout)} seconds: ${null==e?void 0:e.method}`,format:e=>({code:b[p.JSONRPC_REQUEST_TIMEOUT].code,message:b[p.JSONRPC_REQUEST_TIMEOUT].stringify(e)})},[p.UNAUTHORIZED_TARGET_CHAIN]:{type:p.UNAUTHORIZED_TARGET_CHAIN,code:3e3,stringify:e=>"Unauthorized Target ChainId Requested: "+(null==e?void 0:e.chainId),format:e=>({code:b[p.UNAUTHORIZED_TARGET_CHAIN].code,message:b[p.UNAUTHORIZED_TARGET_CHAIN].stringify(e)})},[p.UNAUTHORIZED_JSON_RPC_METHOD]:{type:p.UNAUTHORIZED_JSON_RPC_METHOD,code:3001,stringify:e=>"Unauthorized JSON-RPC Method Requested: "+(null==e?void 0:e.method),format:e=>({code:b[p.UNAUTHORIZED_JSON_RPC_METHOD].code,message:b[p.UNAUTHORIZED_JSON_RPC_METHOD].stringify(e)})},[p.UNAUTHORIZED_NOTIFICATION_TYPE]:{type:p.UNAUTHORIZED_NOTIFICATION_TYPE,code:3002,stringify:e=>"Unauthorized Notification Type Requested: "+(null==e?void 0:e.type),format:e=>({code:b[p.UNAUTHORIZED_NOTIFICATION_TYPE].code,message:b[p.UNAUTHORIZED_NOTIFICATION_TYPE].stringify(e)})},[p.UNAUTHORIZED_UPDATE_REQUEST]:{type:p.UNAUTHORIZED_UPDATE_REQUEST,code:3003,stringify:e=>`Unauthorized ${(null==e?void 0:e.context)||m} update request`,format:e=>({code:b[p.UNAUTHORIZED_UPDATE_REQUEST].code,message:b[p.UNAUTHORIZED_UPDATE_REQUEST].stringify(e)})},[p.UNAUTHORIZED_UPGRADE_REQUEST]:{type:p.UNAUTHORIZED_UPGRADE_REQUEST,code:3004,stringify:e=>`Unauthorized ${(null==e?void 0:e.context)||m} upgrade request`,format:e=>({code:b[p.UNAUTHORIZED_UPGRADE_REQUEST].code,message:b[p.UNAUTHORIZED_UPGRADE_REQUEST].stringify(e)})},[p.UNAUTHORIZED_MATCHING_CONTROLLER]:{type:p.UNAUTHORIZED_MATCHING_CONTROLLER,code:3005,stringify:e=>`Unauthorized: peer is also ${(null==e?void 0:e.controller)?"":"not "}controller`,format:e=>({code:b[p.UNAUTHORIZED_MATCHING_CONTROLLER].code,message:b[p.UNAUTHORIZED_MATCHING_CONTROLLER].stringify(e)})},[p.JSONRPC_REQUEST_METHOD_REJECTED]:{type:p.JSONRPC_REQUEST_METHOD_REJECTED,code:4001,stringify:e=>"User rejected the request.",format:e=>({code:b[p.JSONRPC_REQUEST_METHOD_REJECTED].code,message:b[p.JSONRPC_REQUEST_METHOD_REJECTED].stringify(e)})},[p.JSONRPC_REQUEST_METHOD_UNAUTHORIZED]:{type:p.JSONRPC_REQUEST_METHOD_UNAUTHORIZED,code:4100,stringify:e=>"The requested account and/or method has not been authorized by the user.",format:e=>({code:b[p.JSONRPC_REQUEST_METHOD_UNAUTHORIZED].code,message:b[p.JSONRPC_REQUEST_METHOD_UNAUTHORIZED].stringify(e)})},[p.JSONRPC_REQUEST_METHOD_UNSUPPORTED]:{type:p.JSONRPC_REQUEST_METHOD_UNSUPPORTED,code:4200,stringify:e=>`The requested method is not supported by this ${(null==e?void 0:e.blockhain)||E} provider.`,format:e=>({code:b[p.JSONRPC_REQUEST_METHOD_UNSUPPORTED].code,message:b[p.JSONRPC_REQUEST_METHOD_UNSUPPORTED].stringify(e)})},[p.DISCONNECTED_ALL_CHAINS]:{type:p.DISCONNECTED_ALL_CHAINS,code:4900,stringify:e=>"The provider is disconnected from all chains.",format:e=>({code:b[p.DISCONNECTED_ALL_CHAINS].code,message:b[p.DISCONNECTED_ALL_CHAINS].stringify(e)})},[p.DISCONNECTED_TARGET_CHAIN]:{type:p.DISCONNECTED_TARGET_CHAIN,code:4901,stringify:e=>"The provider is disconnected from the specified chain.",format:e=>({code:b[p.DISCONNECTED_TARGET_CHAIN].code,message:b[p.DISCONNECTED_TARGET_CHAIN].stringify(e)})},[p.DISAPPROVED_CHAINS]:{type:p.DISAPPROVED_CHAINS,code:5e3,stringify:e=>"User disapproved requested chains",format:e=>({code:b[p.DISAPPROVED_CHAINS].code,message:b[p.DISAPPROVED_CHAINS].stringify(e)})},[p.DISAPPROVED_JSONRPC]:{type:p.DISAPPROVED_JSONRPC,code:5001,stringify:e=>"User disapproved requested json-rpc methods",format:e=>({code:b[p.DISAPPROVED_JSONRPC].code,message:b[p.DISAPPROVED_JSONRPC].stringify(e)})},[p.DISAPPROVED_NOTIFICATION]:{type:p.DISAPPROVED_NOTIFICATION,code:5002,stringify:e=>"User disapproved requested notification types",format:e=>({code:b[p.DISAPPROVED_NOTIFICATION].code,message:b[p.DISAPPROVED_NOTIFICATION].stringify(e)})},[p.UNSUPPORTED_CHAINS]:{type:p.UNSUPPORTED_CHAINS,code:5100,stringify:e=>"Requested chains are not supported: "+(null==e?void 0:e.chains.toString()),format:e=>({code:b[p.UNSUPPORTED_CHAINS].code,message:b[p.UNSUPPORTED_CHAINS].stringify(e)})},[p.UNSUPPORTED_JSONRPC]:{type:p.UNSUPPORTED_JSONRPC,code:5101,stringify:e=>"Requested json-rpc methods are not supported: "+(null==e?void 0:e.methods.toString()),format:e=>({code:b[p.UNSUPPORTED_JSONRPC].code,message:b[p.UNSUPPORTED_JSONRPC].stringify(e)})},[p.UNSUPPORTED_NOTIFICATION]:{type:p.UNSUPPORTED_NOTIFICATION,code:5102,stringify:e=>"Requested notification types are not supported: "+(null==e?void 0:e.types.toString()),format:e=>({code:b[p.UNSUPPORTED_NOTIFICATION].code,message:b[p.UNSUPPORTED_NOTIFICATION].stringify(e)})},[p.UNSUPPORTED_SIGNAL]:{type:p.UNSUPPORTED_SIGNAL,code:5103,stringify:e=>`Proposed ${(null==e?void 0:e.context)||m} signal is unsupported`,format:e=>({code:b[p.UNSUPPORTED_SIGNAL].code,message:b[p.UNSUPPORTED_SIGNAL].stringify(e)})},[p.USER_DISCONNECTED]:{type:p.USER_DISCONNECTED,code:5900,stringify:e=>"User disconnected "+((null==e?void 0:e.context)||m),format:e=>({code:b[p.USER_DISCONNECTED].code,message:b[p.USER_DISCONNECTED].stringify(e)})},[p.UNKNOWN]:{type:p.UNKNOWN,code:9e3,stringify:e=>"Unknown error"+(e?": "+(null==e?void 0:e.toString()):""),format:e=>({code:b[p.UNKNOWN].code,message:b[p.UNKNOWN].stringify(e)})}};var _=n(75);function w(e){return(null==e?void 0:e.relay)||{protocol:"waku"}}function R(e){const t=_.RELAY_JSONRPC[e];if(void 0===t)throw new Error("Relay Protocol not supported: "+e);return t}var O=n(20),T=n(8);function S(e){return"pairing"===e.method}function I(e){return"responded"===e.status&&"outcome"in e}function N(e){return"reason"in e}function A(e){return"responded"===e}function P(e){const t=function(e){if(void 0===e||void 0===e.chains||!D(e.chains,j))return H(b.MISSING_OR_INVALID.format({name:"blockchain permissions"}));return{valid:!0}}(e.blockchain);if(M(t))return t;const n=function(e){if(void 0===e||void 0===e.methods||!D(e.methods,L))return H(b.MISSING_OR_INVALID.format({name:"jsonrpc permissions"}));return{valid:!0}}(e.jsonrpc);if(M(n))return n;const r=function(e){if(void 0===e||void 0===e.types||!D(e.types,L))return H(b.MISSING_OR_INVALID.format({name:"notification permissions"}));return{valid:!0}}(e.notifications);return M(r)?r:{valid:!0}}function U(e){return L(e.name)?L(e.description)?void 0!==e.url&&q(e.url)?void 0!==e.icons&&D(e.icons,q)?{valid:!0}:H(b.MISSING_OR_INVALID.format({name:"metadata icons"})):H(b.MISSING_OR_INVALID.format({name:"metadata url"})):H(b.MISSING_OR_INVALID.format({name:"metadata description"})):H(b.MISSING_OR_INVALID.format({name:"metadata name"}))}function C(e){if(e.approved){if(void 0===e.response)return H(b.MISSING_RESPONSE.format({context:"session"}));const t=function(e,t){if(void 0===t||void 0===t.chains||!D(t.chains,j))return H(b.MISSING_OR_INVALID.format({name:"blockchain permissions"}));if(void 0===e||void 0===e.accounts||!D(e.accounts,x))return H(b.MISSING_OR_INVALID.format({name:"state accounts"}));const n=e.accounts.filter(e=>{const[n,r]=e.split(":"),i=`${n}:${r}`;return!t.chains.includes(i)});if(n.length)return H(b.MISMATCHED_ACCOUNTS.format({mismatched:n}));return{valid:!0}}(e.response.state,e.proposal.permissions.blockchain);if(M(t))return t;const n=U(e.response.metadata);if(M(n))return n}return{valid:!0}}function D(e,t){if(Array.isArray(e)){if(void 0!==t&&e.length){return e.filter(t).length===e.length}return!0}return!1}function L(e){return"string"==typeof e&&!!e.trim()}function j(e){if(L(e)&&e.includes(":")){return 2===e.split(":").length}return!1}function x(e){if(L(e)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&j(e)}}return!1}function q(e){if(L(e))try{return void 0!==new URL(e)}catch(e){return!1}return!1}function M(e){return"valid"in e&&!1===e.valid&&"error"in e&&"number"==typeof e.error.code&&"string"==typeof e.error.message}function H(e){return{valid:!1,error:e}}var K=n(1);const J="client",B="error",G=!1,k="wss://relay.walletconnect.com",V={proposal:"pairing_proposal",updated:"pairing_updated",upgraded:"pairing_upgraded",created:"pairing_created",deleted:"pairing_deleted",sync:"pairing_sync"},F={proposal:"session_proposal",updated:"session_updated",upgraded:"session_upgraded",created:"session_created",deleted:"session_deleted",notification:"session_notification",request:"session_request",response:"session_response",sync:"session_sync"},z={database:":memory:"},Y="expirer_created",W="expirer_deleted",$="expirer_expired",Q="expirer_init",Z="expirer_sync",X="heartbeat_pulse",ee="history_created",te="history_updated",ne="history_deleted",re="history_init",ie="history_sync",oe={propose:"wc_pairingPropose",approve:"wc_pairingApprove",reject:"wc_pairingReject",update:"wc_pairingUpdate",upgrade:"wc_pairingUpgrade",delete:"wc_pairingDelete",payload:"wc_pairingPayload",ping:"wc_pairingPing",notification:"wc_pairingNotification"},se={proposed:"proposed",responded:"responded",pending:"pending",settled:"settled"},ae={proposed:"pairing_proposed",responded:"pairing_responded",settled:"pairing_settled",updated:"pairing_updated",upgraded:"pairing_upgraded",deleted:"pairing_deleted",request:"pairing_request",response:"pairing_response",sync:"pairing_sync",notification:"pairing_notification"},ce="relayer_payload",ue="relayer_connect",he="relayer_disconnect",le="relayer_error",de="payload",fe="connect",pe="disconnect",ge="error",ye={database:":memory:"},ve={propose:"wc_sessionPropose",approve:"wc_sessionApprove",reject:"wc_sessionReject",update:"wc_sessionUpdate",upgrade:"wc_sessionUpgrade",delete:"wc_sessionDelete",payload:"wc_sessionPayload",ping:"wc_sessionPing",notification:"wc_sessionNotification"},me={proposed:"proposed",responded:"responded",pending:"pending",settled:"settled"},Ee={proposed:"session_proposed",responded:"session_responded",settled:"session_settled",updated:"session_updated",upgraded:"session_upgraded",deleted:"session_deleted",request:"session_request",response:"session_response",sync:"session_sync",notification:"session_notification"},be={jsonrpc:{methods:[]},blockchain:{chains:[]},notifications:{types:[]}},_e={accounts:[]},we={metadata:{name:"",description:"",url:"",icons:[]},state:_e},Re="store_created",Oe="store_updated",Te="store_deleted",Se="store_init",Ie="store_sync",Ne={crypto:{keychain:"crypto:keychain"},session:{pending:"session:pending",settled:"session:settled",history:"session:history",expirer:"session:expirer"},pairing:{pending:"pairing:pending",settled:"pairing:settled",history:"pairing:history",expirer:"pairing:expirer"},relayer:{history:"relayer:history",subscription:"relayer:subscription"}},Ae="subscription_created",Pe="subscription_deleted",Ue="subscription_enabled",Ce="subscription_disabled",De="subscription_sync";class Le{constructor(e,t){this.client=e,this.logger=t,this.keychain=new Map,this.name="keychain",this.client=e,this.logger=Object(K.generateChildLogger)(t,this.name)}get context(){return Object(K.getLoggerContext)(this.logger)}async init(){await this.restore()}async has(e,t){return this.keychain.has(e)}async set(e,t,n){this.keychain.set(e,t),await this.persist()}async get(e,t){const n=this.keychain.get(e);if(void 0===n)throw new Error(b.NO_MATCHING_KEY.format({tag:e}).message);return n}async del(e,t){this.keychain.delete(e),await this.persist()}async restore(){const e=await this.client.storage.getKeyChain(this.context);void 0!==e&&(this.keychain=e)}async persist(){await this.client.storage.setKeyChain(this.context,this.keychain)}}class je{constructor(e,t,n){this.client=e,this.logger=t,this.name="crypto",this.client=e,this.logger=Object(K.generateChildLogger)(t,this.name),this.keychain=n||new Le(this.client,this.logger)}get context(){return Object(K.getLoggerContext)(this.logger)}async init(){await this.keychain.init()}async hasKeys(e){return this.keychain.has(e)}async generateKeyPair(){const e=function(){const e=l.generateKeyPair();return{privateKey:d.arrayToHex(e.privateKey),publicKey:d.arrayToHex(e.publicKey)}}();return this.setKeyPair(e)}async generateSharedKey(e,t,n){const r=await this.getKeyPair(e.publicKey),i=function(e,t){const n=l.derive(d.hexToArray(e),d.hexToArray(t));return d.arrayToHex(n)}(r.privateKey,t.publicKey);return this.setEncryptionKeys({sharedKey:i,publicKey:r.publicKey},n)}async encrypt(e,t){const{sharedKey:n,publicKey:r}=await this.getEncryptionKeys(e);return await async function(e){const t=d.utf8ToArray(e.message),n=d.hexToArray(e.sharedKey),r=d.hexToArray(e.publicKey),i=void 0!==e.iv?d.hexToArray(e.iv):void 0,o=await l.encryptWithSharedKey(t,n,r,i);return d.arrayToHex(o)}({message:t,sharedKey:n,publicKey:r})}async decrypt(e,t){const{sharedKey:n}=await this.getEncryptionKeys(e);return await async function(e){const t=d.hexToArray(e.encrypted),n=d.hexToArray(e.sharedKey),r=await l.decryptWithSharedKey(t,n);return d.arrayToUtf8(r)}({encrypted:t,sharedKey:n})}async encode(e,t){const n=Object(T.b)(t);return await this.hasKeys(e)?await this.encrypt(e,n):d.utf8ToHex(n)}async decode(e,t){const n=await this.hasKeys(e)?await this.decrypt(e,t):d.hexToUtf8(t);return Object(T.a)(n)}concatKeys(e,t){return d.arrayToHex(d.concatArrays(d.hexToArray(e),d.hexToArray(t)))}splitKeys(e){const t=d.hexToArray(e);return[d.arrayToHex(t.slice(0,32)),d.arrayToHex(t.slice(32,64))]}async setKeyPair(e){const t=this.concatKeys(e.publicKey,e.privateKey);return await this.keychain.set(e.publicKey,t),e.publicKey}async getKeyPair(e){const[t,n]=this.splitKeys(await this.keychain.get(e));return{publicKey:e,privateKey:n}}async setEncryptionKeys(e,t){const n=t||await async function(e){const t=await l.sha256(d.hexToArray(e));return d.arrayToHex(t)}(e.sharedKey),r=this.concatKeys(e.sharedKey,e.publicKey);return await this.keychain.set(n,r),n}async getEncryptionKeys(e){const[t,n]=this.splitKeys(await this.keychain.get(e));return{sharedKey:t,publicKey:n}}}class xe{constructor(e,t){this.client=e,this.logger=t,this.name="encoder",this.client=e,this.logger=Object(K.generateChildLogger)(t,this.name)}get context(){return Object(K.getLoggerContext)(this.logger)}async encode(e,t){const n=Object(T.b)(t);return await this.client.crypto.hasKeys(e)?await this.client.crypto.encrypt(e,n):d.utf8ToHex(n)}async decode(e,t){const n=await this.client.crypto.hasKeys(e)?await this.client.crypto.decrypt(e,t):d.hexToUtf8(t);return Object(T.a)(n)}}class qe{async encode(e,t){return d.utf8ToHex(Object(T.b)(t))}async decode(e,t){return Object(T.a)(d.hexToUtf8(t))}}class Me extends h.IEngine{constructor(e){super(e),this.sequence=e,this.registerEventListeners()}async find(e){return this.sequence.values.filter(t=>{var n,r,i,o,s,a;let c=!1;return(null===(n=t.permissions)||void 0===n?void 0:n.jsonrpc)&&(null===(r=e.jsonrpc)||void 0===r?void 0:r.methods)&&Object(f.i)(e.jsonrpc.methods,t.permissions.jsonrpc.methods)&&(c=!0),(null===(i=t.permissions)||void 0===i?void 0:i.blockchain)&&(null===(o=e.blockchain)||void 0===o?void 0:o.chains)&&Object(f.i)(e.blockchain.chains,t.permissions.blockchain.chains)&&(c=!0),(null===(s=t.permissions)||void 0===s?void 0:s.notifications)&&(null===(a=e.notifications)||void 0===a?void 0:a.types)&&Object(f.i)(e.notifications.types,t.permissions.notifications.types)&&(c=!0),c})}async ping(e,t){const n={method:this.sequence.config.jsonrpc.ping,params:{}};return this.request({topic:e,request:n,timeout:t||Object(f.m)(30)})}async send(e,t,n){const r=t,i=await this.sequence.settled.get(e);if(Object(o.isJsonRpcRequest)(t)&&!Object.values(this.sequence.config.jsonrpc).includes(t.method)){await this.isJsonRpcAuthorized(e,i.self,t),await this.sequence.validateRequest({topic:e,request:t,chainId:n});const r={chainId:n,request:{method:t.method,params:t.params}};r.chainId||delete r.chainId,t=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.payload,r,t.id)}await this.sequence.client.relayer.publish(i.topic,t,{relay:i.relay}),(Object(o.isJsonRpcResponse)(r)||Object(o.isJsonRpcRequest)(r)&&!Object.values(this.sequence.config.jsonrpc).includes(r.method))&&await this.recordPayloadEvent({topic:e,payload:r,chainId:n})}get length(){return this.sequence.settled.length}get topics(){return this.sequence.settled.topics}get values(){return this.sequence.settled.values}create(e){return new Promise(async(t,n)=>{this.sequence.logger.debug("Create "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"create",params:e});const r=(null==e?void 0:e.timeout)||Object(f.m)(300),i=setTimeout(()=>{const e=b.SETTLE_TIMEOUT.format({context:this.sequence.name,timeout:r});this.sequence.logger.error(e.message),n(e.message)},r);let o;try{o=await this.propose(e)}catch(e){return clearTimeout(i),n(e)}this.sequence.pending.on(Oe,async e=>{if(o.topic===e.sequence.topic&&I(e.sequence)){const r=e.sequence.outcome;if(clearTimeout(i),N(r)){try{await this.sequence.pending.delete(o.topic,r.reason)}catch(e){return n(e)}n(new Error(r.reason.message))}else try{const e=await this.sequence.settled.get(r.topic),n=b.SETTLED.format({context:this.sequence.name});await this.sequence.pending.delete(o.topic,n),t(e)}catch(e){return n(e)}}})})}async respond(e){this.sequence.logger.debug("Respond "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"respond",params:e}),await this.sequence.validateRespond(e);const{approved:t,proposal:n,response:r}=e,{relay:i,ttl:o}=n,s={publicKey:await this.sequence.client.crypto.generateKeyPair(),metadata:null==r?void 0:r.metadata};if(s.metadata||delete s.metadata,!t){const t=b.NOT_APPROVED.format({context:this.sequence.name}),r={reason:(null==e?void 0:e.reason)||t},o={status:this.sequence.config.status.responded,topic:n.topic,relay:i,self:s,proposal:n,outcome:r};return await this.sequence.pending.set(o.topic,o),o}try{const e={publicKey:s.publicKey,metadata:null==r?void 0:r.metadata};e.metadata||delete e.metadata;const t=Object(f.a)(n.ttl),a=(null==r?void 0:r.state)||{},c={publicKey:n.proposer.publicKey,metadata:n.proposer.metadata};c.metadata||delete c.metadata;const u=n.proposer.controller?{publicKey:c.publicKey}:{publicKey:s.publicKey},h=Object.assign(Object.assign({},n.permissions),{controller:u}),l={topic:(await this.settle({relay:i,self:s,peer:c,permissions:h,state:a,ttl:o,expiry:t})).topic,relay:i,state:a,responder:e,expiry:t},d={status:this.sequence.config.status.responded,topic:n.topic,relay:i,self:s,proposal:n,outcome:l};return await this.sequence.pending.set(d.topic,d),d}catch(e){const t={reason:b.GENERIC.format({message:e.message})},r={status:this.sequence.config.status.responded,topic:n.topic,relay:i,self:s,proposal:n,outcome:t};return await this.sequence.pending.set(r.topic,r),r}}async update(e){this.sequence.logger.debug("Update "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"update",params:e});const t=await this.sequence.settled.get(e.topic),n={publicKey:t.self.publicKey},r=await this.handleUpdate(e.topic,e,n),i=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.update,r);return await this.send(t.topic,i),t}async upgrade(e){this.sequence.logger.debug("Upgrade "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"upgrade",params:e});const t=await this.sequence.settled.get(e.topic),n={publicKey:t.self.publicKey},r=await this.handleUpgrade(e.topic,e,n),i=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.upgrade,r);return await this.send(t.topic,i),t}async request(e){return new Promise(async(t,n)=>{try{await this.sequence.validateRequest(e)}catch(e){return n(e)}const r=Object(o.formatJsonRpcRequest)(e.request.method,e.request.params),i=(null==e?void 0:e.timeout)||Object(f.m)(300),s=setTimeout(()=>{const e=b.JSONRPC_REQUEST_TIMEOUT.format({method:r.method,timeout:i});this.sequence.logger.error(e.message),n(e.message)},i);this.sequence.events.on(this.sequence.config.events.response,i=>{if(e.topic!==i.topic)return;const a=i.response;if(a.id===r.id){if(clearTimeout(s),Object(o.isJsonRpcError)(a)){const e=a.error.message;return this.sequence.logger.error(e),n(new Error(e))}return t(a.result)}});try{await this.send(e.topic,r,null==e?void 0:e.chainId)}catch(e){return clearTimeout(s),n(e)}})}async delete(e){this.sequence.logger.debug("Delete "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"delete",params:e}),await this.sequence.settled.delete(e.topic,e.reason)}async notify(e){const{topic:t,notification:n}=e,r=await this.sequence.settled.get(e.topic);await this.isNotificationAuthorized(e.topic,r.self,n.type);const i=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.notification,n);await this.send(e.topic,i)}async propose(e){this.sequence.logger.debug("Propose "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"propose",params:e}),await this.sequence.validatePropose(e);const t=(null==e?void 0:e.relay)||{protocol:"waku"},n=d.arrayToHex(l.randomBytes(32)),r={publicKey:await this.sequence.client.crypto.generateKeyPair(),metadata:null==e?void 0:e.metadata};r.metadata||delete r.metadata;const i={publicKey:r.publicKey,controller:this.sequence.client.controller,metadata:r.metadata};i.metadata||delete i.metadata;const o={relay:t,topic:n,proposer:i,signal:(null==e?void 0:e.signal)||await this.sequence.getDefaultSignal({topic:n,relay:t,proposer:i}),permissions:(null==e?void 0:e.permissions)||await this.sequence.getDefaultPermissions(),ttl:(null==e?void 0:e.ttl)||await this.sequence.getDefaultTTL()},s={status:this.sequence.config.status.proposed,topic:o.topic,relay:o.relay,self:r,proposal:o};return await this.sequence.pending.set(s.topic,s),s}async settle(e){this.sequence.logger.debug("Settle "+this.sequence.context),this.sequence.logger.trace({type:"method",method:"settle",params:e});const t={topic:await this.sequence.client.crypto.generateSharedKey(e.self,e.peer),relay:e.relay,self:e.self,peer:e.peer,permissions:e.permissions,expiry:e.expiry,state:e.state,acknowledged:!1};return await this.sequence.settled.set(t.topic,t),t}async onResponse(e){const{topic:t,payload:n}=e;this.sequence.logger.debug(`Receiving ${this.sequence.context} response`),this.sequence.logger.trace({type:"method",method:"onResponse",topic:t,payload:n});const r=n,i=r.params,s=await this.sequence.pending.get(t);let a,c;if(function(e){return"reason"in e}(i))this.sequence.logger.error(i.reason),await this.sequence.pending.update(t,{status:this.sequence.config.status.responded,outcome:{reason:i.reason}});else{try{const e=s.proposal.proposer.controller?{publicKey:s.proposal.proposer.publicKey}:{publicKey:i.responder.publicKey},n={publicKey:i.responder.publicKey,metadata:i.responder.metadata};n.metadata||delete n.metadata;const r=i.state||{},o=Object.assign(Object.assign({},s.proposal.permissions),{controller:e}),a=await this.settle({relay:s.relay,self:s.self,peer:n,permissions:o,ttl:s.proposal.ttl,expiry:i.expiry,state:r}),c={topic:a.topic,relay:a.relay,responder:i.responder,expiry:a.expiry,state:a.state};await this.sequence.pending.update(t,{status:this.sequence.config.status.responded,outcome:c})}catch(e){this.sequence.logger.error(e),a=b.GENERIC.format({message:e.message}),c={reason:a},await this.sequence.pending.update(t,{status:this.sequence.config.status.responded,outcome:c})}await this.sequence.client.relayer.publish(s.topic,void 0===a?Object(o.formatJsonRpcResult)(r.id,!0):Object(o.formatJsonRpcError)(r.id,a),{relay:s.relay}),void 0===c||N(c)||await this.sequence.settled.update(c.topic,{acknowledged:!0})}}async onAcknowledge(e){const{topic:t,payload:n}=e;this.sequence.logger.debug(`Receiving ${this.sequence.context} acknowledge`),this.sequence.logger.trace({type:"method",method:"onAcknowledge",topic:t,payload:n});const r=n,i=await this.sequence.pending.get(t);if(!I(i))return;const{outcome:s}=i;Object(o.isJsonRpcError)(r)&&!N(s)&&await this.sequence.settled.delete(s.topic,r.error),void 0===s||N(s)||await this.sequence.settled.update(s.topic,{acknowledged:!0});const a=b.RESPONSE_ACKNOWLEDGED.format({context:this.sequence.name});await this.sequence.pending.delete(t,a)}async onMessage(e){const{topic:t,payload:n}=e;if(this.sequence.logger.debug(`Receiving ${this.sequence.context} message`),this.sequence.logger.trace({type:"method",method:"onMessage",topic:t,payload:n}),Object(o.isJsonRpcRequest)(n)){const t=n,r=await this.sequence.settled.get(e.topic);let i;switch(t.method){case this.sequence.config.jsonrpc.payload:await this.onPayload(e);break;case this.sequence.config.jsonrpc.update:await this.onUpdate(e);break;case this.sequence.config.jsonrpc.upgrade:await this.onUpgrade(e);break;case this.sequence.config.jsonrpc.notification:await this.onNotification(e);break;case this.sequence.config.jsonrpc.delete:await this.sequence.settled.delete(r.topic,t.params.reason);break;case this.sequence.config.jsonrpc.ping:await this.send(r.topic,Object(o.formatJsonRpcResult)(t.id,!0));break;default:i=b.UNKNOWN_JSONRPC_METHOD.format({method:t.method}),this.sequence.logger.error(i.message),await this.send(r.topic,Object(o.formatJsonRpcError)(t.id,i))}}else this.onPayloadEvent(e)}async onPayload(e){const{topic:t,payload:n}=e;if(Object(o.isJsonRpcRequest)(n)){const{id:e,params:r}=n,{chainId:i}=r,s=Object(o.formatJsonRpcRequest)(r.request.method,r.request.params,e),a=await this.sequence.settled.get(t);await this.isJsonRpcAuthorized(t,a.peer,s),await this.sequence.validateRequest({topic:t,request:s,chainId:i});const c={topic:t,payload:s,chainId:i};this.sequence.logger.debug(`Receiving ${this.sequence.context} payload`),this.sequence.logger.trace(Object.assign({type:"method",method:"onPayload"},c)),this.onPayloadEvent(c)}else{const e={topic:t,payload:n};this.sequence.logger.debug(`Receiving ${this.sequence.context} payload`),this.sequence.logger.trace(Object.assign({type:"method",method:"onPayload"},e)),this.onPayloadEvent(e)}}async onUpdate(e){const{topic:t,payload:n}=e;this.sequence.logger.debug(`Receiving ${this.sequence.context} update`),this.sequence.logger.trace({type:"method",method:"onUpdate",topic:t,payload:n});const r=e.payload,i=await this.sequence.settled.get(e.topic);try{const e={publicKey:i.peer.publicKey};await this.handleUpdate(t,r.params,e);const n=Object(o.formatJsonRpcResult)(r.id,!0);await this.send(i.topic,n)}catch(e){this.sequence.logger.error(e);const t=Object(o.formatJsonRpcError)(r.id,e.message);await this.send(i.topic,t)}}async onUpgrade(e){const{topic:t,payload:n}=e;this.sequence.logger.debug(`Receiving ${this.sequence.context} upgrade`),this.sequence.logger.trace({type:"method",method:"onUpgrade",topic:t,payload:n});const r=e.payload,i=await this.sequence.settled.get(e.topic);try{const e={publicKey:i.peer.publicKey};await this.handleUpgrade(t,r.params,e);const n=Object(o.formatJsonRpcResult)(r.id,!0);await this.send(i.topic,n)}catch(e){this.sequence.logger.error(e);const t=Object(o.formatJsonRpcError)(r.id,e.message);await this.send(i.topic,t)}}async onNotification(e){const{params:t}=e.payload,n=e.payload,r=await this.sequence.settled.get(e.topic);try{await this.isNotificationAuthorized(e.topic,r.peer,t.type);const i={topic:e.topic,notification:t},s=this.sequence.config.events.notification;this.sequence.logger.info("Emitting "+s),this.sequence.logger.debug({type:"event",event:s,notificationEvent:i}),this.sequence.events.emit(s,i);const a=Object(o.formatJsonRpcResult)(n.id,!0);await this.send(r.topic,a)}catch(e){this.sequence.logger.error(e);const t=Object(o.formatJsonRpcError)(n.id,e.message);await this.send(r.topic,t)}}async handleUpdate(e,t,n){if(void 0===t.state){const e=b.INVALID_UPDATE_REQUEST.format({context:this.sequence.name});throw this.sequence.logger.error(e.message),new Error(e.message)}const r=await this.sequence.settled.get(e);if(n.publicKey!==r.permissions.controller.publicKey){const e=b.UNAUTHORIZED_UPDATE_REQUEST.format({context:this.sequence.name});throw this.sequence.logger.error(e.message),new Error(e.message)}const i=await this.sequence.mergeUpdate(e,t);return await this.sequence.settled.update(r.topic,{state:i}),t}async handleUpgrade(e,t,n){if(void 0===t.permissions){const e=b.INVALID_UPGRADE_REQUEST.format({context:this.sequence.name});throw this.sequence.logger.error(e.message),new Error(e.message)}const r=await this.sequence.settled.get(e);if(n.publicKey!==r.permissions.controller.publicKey){const e=b.UNAUTHORIZED_UPGRADE_REQUEST.format({context:this.sequence.name});throw this.sequence.logger.error(e.message),new Error(e.message)}const i=await this.sequence.mergeUpgrade(e,t);return await this.sequence.settled.update(r.topic,{permissions:i}),t}async isJsonRpcAuthorized(e,t,n){const r=await this.sequence.settled.get(e);if(t.publicKey!==r.permissions.controller.publicKey&&!r.permissions.jsonrpc.methods.includes(n.method)){const e=b.UNAUTHORIZED_JSON_RPC_METHOD.format({method:n.method});throw this.sequence.logger.error(e.message),new Error(e.message)}}async isNotificationAuthorized(e,t,n){const r=await this.sequence.settled.get(e);if(t.publicKey!==r.permissions.controller.publicKey&&r.self.publicKey!==r.permissions.controller.publicKey&&!r.permissions.notifications.types.includes(n)){const e=b.UNAUTHORIZED_NOTIFICATION_TYPE.format({type:n});throw this.sequence.logger.error(e.message),new Error(e.message)}}async recordPayloadEvent(e){const{topic:t,payload:n,chainId:r}=e;Object(o.isJsonRpcRequest)(n)?await this.sequence.history.set(t,n,r):await this.sequence.history.resolve(n)}async shouldIgnorePayloadEvent(e){const{topic:t,payload:n}=e;if(!this.sequence.settled.sequences.has(t))return!0;let r=!1;try{if(Object(o.isJsonRpcRequest)(n))r=await this.sequence.history.exists(t,n.id);else{let e;try{e=await this.sequence.history.get(t,n.id)}catch(e){}r=void 0!==e&&void 0!==e.response}}catch(e){}return r}async onPayloadEvent(e){const{topic:t,payload:n,chainId:r}=e;if(!await this.shouldIgnorePayloadEvent(e)){if(Object(o.isJsonRpcRequest)(n)){const e={topic:t,request:n,chainId:r},i=this.sequence.config.events.request;this.sequence.logger.info("Emitting "+i),this.sequence.logger.debug({type:"event",event:i,sequence:e}),this.sequence.events.emit(i,e)}else{const e={topic:t,response:n,chainId:r},i=this.sequence.config.events.response;this.sequence.logger.info("Emitting "+i),this.sequence.logger.debug({type:"event",event:i,sequence:e}),this.sequence.events.emit(i,e)}await this.recordPayloadEvent(e)}}async onPendingPayloadEvent(e){if(Object(o.isJsonRpcRequest)(e.payload))switch(e.payload.method){case this.sequence.config.jsonrpc.approve:case this.sequence.config.jsonrpc.reject:this.onResponse(e)}else this.onAcknowledge(e)}async onPendingStatusEvent(e){const{sequence:t}=e;if(S(t.proposal.signal)&&!await this.sequence.client.crypto.hasKeys(t.proposal.topic)){const e=await this.sequence.client.pairing.settled.get(t.proposal.signal.params.topic);await this.sequence.client.crypto.generateSharedKey(e.self,e.peer,t.proposal.topic)}if(I(t)){const n=this.sequence.config.events.responded;if(this.sequence.logger.info("Emitting "+n),this.sequence.logger.debug({type:"event",event:n,sequence:t}),this.sequence.events.emit(n,t),!function(e){return"update"in e}(e)){const{topic:e,outcome:n,relay:r}=t,i=N(n)?this.sequence.config.jsonrpc.reject:this.sequence.config.jsonrpc.approve,s=N(n)?{reason:n.reason}:{relay:n.relay,responder:n.responder,expiry:n.expiry,state:n.state},a=Object(o.formatJsonRpcRequest)(i,s);await this.sequence.client.relayer.publish(e,a,{relay:r})}}else{const e=this.sequence.config.events.proposed;if(this.sequence.logger.info("Emitting "+e),this.sequence.logger.debug({type:"event",event:e,sequence:t}),this.sequence.events.emit(e,t),S(t.proposal.signal)){const e=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.propose,t.proposal);await this.sequence.client.pairing.send(t.proposal.signal.params.topic,e)}}}async subscribeNewPending(e){const{topic:t,sequence:n}=e,r=Object(f.a)(86400);await this.sequence.client.relayer.subscribe(t,{relay:n.relay}),await this.sequence.expirer.set(t,{topic:t,expiry:r})}async subscribeNewSettled(e){const{topic:t,sequence:n}=e,{expiry:r}=n;await this.sequence.client.relayer.subscribe(t,{relay:n.relay}),await this.sequence.expirer.set(t,{topic:t,expiry:r})}registerEventListeners(){this.sequence.pending.on(Re,async e=>{await this.subscribeNewPending(e),await this.onPendingStatusEvent(e)}),this.sequence.pending.on(Oe,async e=>await this.onPendingStatusEvent(e)),this.sequence.pending.on(Te,async e=>{const{sequence:t}=e;await this.sequence.client.relayer.unsubscribe(t.topic,{relay:t.relay}),await this.sequence.expirer.del(t.topic)}),this.sequence.settled.on(Re,async e=>{await this.subscribeNewSettled(e);const{sequence:t}=e,n=this.sequence.config.events.settled;this.sequence.logger.info("Emitting "+n),this.sequence.logger.debug({type:"event",event:n,sequence:t}),this.sequence.events.emit(n,t)}),this.sequence.settled.on(Oe,async e=>{const{sequence:t,update:n}=e;if(void 0!==n.state){const e=this.sequence.config.events.updated;this.sequence.logger.info("Emitting "+e),this.sequence.logger.debug({type:"event",event:e,sequence:t,update:n}),this.sequence.events.emit(e,t,n)}else if(void 0!==n.permissions){const e=this.sequence.config.events.upgraded,r=n;this.sequence.logger.info("Emitting "+e),this.sequence.logger.debug({type:"event",event:e,sequence:t,upgrade:r}),this.sequence.events.emit(e,t,r)}}),this.sequence.settled.on(Te,async e=>{const{sequence:t,reason:n}=e,r=this.sequence.config.events.deleted;this.sequence.logger.info("Emitting "+r),this.sequence.logger.debug({type:"event",event:r,sequence:t,reason:n}),this.sequence.events.emit(r,t,n);const i=Object(o.formatJsonRpcRequest)(this.sequence.config.jsonrpc.delete,{reason:n});await this.sequence.history.delete(t.topic),await this.sequence.client.relayer.publish(t.topic,i,{relay:t.relay}),await this.sequence.client.relayer.unsubscribe(t.topic,{relay:t.relay}),await this.sequence.expirer.del(t.topic)}),this.sequence.settled.on(Ie,()=>this.sequence.events.emit(this.sequence.config.events.sync)),this.sequence.client.relayer.on(ce,e=>{this.sequence.pending.sequences.has(e.topic)?this.onPendingPayloadEvent(e):this.sequence.settled.sequences.has(e.topic)&&this.onMessage(e)}),this.sequence.expirer.on($,async e=>{if(this.sequence.pending.sequences.has(e.topic)){const t=b.EXPIRED.format({context:Object(f.d)(this.sequence.pending.context)});this.sequence.pending.delete(e.topic,t)}else{const t=b.EXPIRED.format({context:Object(f.d)(this.sequence.settled.context)});this.sequence.settled.delete(e.topic,t)}})}}class He extends h.IExpirer{constructor(e,t){super(e,t),this.client=e,this.logger=t,this.expirations=new Map,this.events=new r.EventEmitter,this.name="expirer",this.cached=[],this.client,this.logger=Object(K.generateChildLogger)(t,this.name),this.registerEventListeners()}get context(){return Object(K.getLoggerContext)(this.logger)}get length(){return this.expirations.size}get topics(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}async init(){this.logger.trace("Initialized"),await this.initialize()}async has(e){try{return void 0!==this.getExpiration(e)}catch(e){return!1}}async set(e,t){await this.isInitialized(),this.expirations.set(e,t),this.checkExpiry(e,t),this.events.emit(Y,{topic:e,expiration:t})}async get(e){return await this.isInitialized(),this.getExpiration(e)}async del(e){await this.isInitialized();const t=this.getExpiration(e);this.expirations.delete(e),this.events.emit(W,{topic:e,expiration:t})}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)}async persist(){await this.client.storage.setSequenceStore(this.context,this.values),this.events.emit(Z)}async restore(){try{const e=await this.client.storage.getSequenceStore(this.context);if(void 0===e)return;if(!e.length)return;if(this.expirations.size){const e=b.RESTORE_WILL_OVERRIDE.format({context:Object(f.d)(this.context)});throw this.logger.error(e.message),new Error(e.message)}this.cached=e,this.logger.debug("Successfully Restored expirations for "+Object(f.d)(this.context)),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug("Failed to Restore expirations for "+Object(f.d)(this.context)),this.logger.error(e)}}async initialize(){await this.restore(),this.reset(),this.onInit()}reset(){this.cached.forEach(e=>this.expirations.set(e.topic,e))}onInit(){this.cached=[],this.events.emit(Q)}async isInitialized(){if(this.cached.length)return new Promise(e=>{this.events.once(Q,()=>e())})}getExpiration(e){const t=this.expirations.get(e);if(!t){const t=b.NO_MATCHING_ID.format({context:Object(f.d)(this.context),topic:e});throw new Error(t.message)}return t}checkExpiry(e,t){const{expiry:n}=t;Object(f.m)(n)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit($,{topic:e,expiration:t})}checkExpirations(){this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.client.heartbeat.on(X,()=>this.checkExpirations()),this.events.on(Y,e=>{const t=Y;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on($,e=>{const t=$;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(W,e=>{const t=W;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}}class Ke extends h.IHeartBeat{constructor(e){super(e),this.events=new r.EventEmitter,this.interval=5,this.name="heartbeat",this.logger=void 0!==(null==e?void 0:e.logger)&&"string"!=typeof(null==e?void 0:e.logger)?Object(K.generateChildLogger)(e.logger,this.name):a()(Object(K.getDefaultLoggerOptions)({level:(null==e?void 0:e.logger)||"error"})),this.interval=(null==e?void 0:e.interval)||5}static async init(e){const t=new Ke(e);return await t.init(),t}get context(){return Object(K.getLoggerContext)(this.logger)}async init(){this.logger.trace("Initialized"),await this.initialize()}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)}async initialize(){setInterval(()=>this.pulse(),Object(f.m)(this.interval)),this.logger.trace("Initialized")}pulse(){this.events.emit(X)}}class Je extends h.IJsonRpcHistory{constructor(e,t){super(e,t),this.logger=e,this.storage=t,this.records=new Map,this.events=new r.EventEmitter,this.name="history",this.cached=[],this.logger=Object(K.generateChildLogger)(e,this.name),this.storage=t,this.registerEventListeners()}async init(){this.logger.trace("Initialized"),await this.initialize()}get context(){return Object(K.getLoggerContext)(this.logger)}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(void 0!==t.response)return;const n={topic:t.topic,request:Object(o.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(n)}),e}async set(e,t,n){if(await this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:n}),this.records.has(t.id))return;const r={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:n};this.records.set(r.id,r),this.events.emit(ee,r)}async resolve(e){if(await this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);void 0===t.response&&(t.response=Object(o.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(te,t))}async get(e,t){await this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t});const n=await this.getRecord(t);if(n.topic!==e){const e=b.MISMATCHED_TOPIC.format({context:Object(f.d)(this.context),id:t});throw new Error(e.message)}return n}async delete(e,t){await this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(n=>{if(n.topic===e){if(void 0!==t&&n.id!==t)return;this.records.delete(n.id),this.events.emit(ne,n)}})}async exists(e,t){if(await this.isInitialized(),!this.records.has(t))return!1;return(await this.getRecord(t)).topic===e}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)}async getRecord(e){await this.isInitialized();const t=this.records.get(e);if(!t){const t=b.NO_MATCHING_ID.format({context:Object(f.d)(this.context),id:e});throw new Error(t.message)}return t}async persist(){await this.storage.setJsonRpcRecords(this.context,this.values),this.events.emit(ie)}async restore(){try{const e=await this.storage.getJsonRpcRecords(this.context);if(void 0===e)return;if(!e.length)return;if(this.records.size){const e=b.RESTORE_WILL_OVERRIDE.format({context:Object(f.d)(this.context)});throw this.logger.error(e.message),new Error(e.message)}this.cached=e,this.logger.debug("Successfully Restored records for "+Object(f.d)(this.context)),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug("Failed to Restore records for "+Object(f.d)(this.context)),this.logger.error(e)}}async initialize(){await this.restore(),this.reset(),this.onInit()}reset(){this.cached.forEach(e=>this.records.set(e.id,e))}onInit(){this.cached=[],this.events.emit(re)}async isInitialized(){if(this.cached.length)return new Promise(e=>{this.events.once(re,()=>e())})}registerEventListeners(){this.events.on(ee,e=>{const t=ee;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.events.on(te,e=>{const t=te;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.events.on(ne,e=>{const t=ne;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,record:e}),this.persist()})}}class Be extends h.IStore{constructor(e,t,n){super(e,t,n),this.client=e,this.logger=t,this.name=n,this.sequences=new Map,this.events=new r.EventEmitter,this.cached=[],this.logger=Object(K.generateChildLogger)(t,this.name),this.registerEventListeners()}async init(){this.logger.trace("Initialized"),await this.initialize()}get context(){return Object(K.getLoggerContext)(this.logger)}get length(){return this.sequences.size}get topics(){return Array.from(this.sequences.keys())}get values(){return Array.from(this.sequences.values())}async set(e,t){await this.isInitialized(),this.sequences.has(e)?this.update(e,t):(this.logger.debug("Setting sequence"),this.logger.trace({type:"method",method:"set",topic:e,sequence:t}),this.sequences.set(e,t),this.events.emit(Re,{topic:e,sequence:t}))}async get(e){await this.isInitialized(),this.logger.debug("Getting sequence"),this.logger.trace({type:"method",method:"get",topic:e});return await this.getSequence(e)}async update(e,t){await this.isInitialized(),this.logger.debug("Updating sequence"),this.logger.trace({type:"method",method:"update",topic:e,update:t});const n=Object.assign(Object.assign({},await this.getSequence(e)),t);this.sequences.set(e,n),this.events.emit(Oe,{topic:e,sequence:n,update:t})}async delete(e,t){if(await this.isInitialized(),!this.sequences.has(e))return;this.logger.debug("Deleting sequence"),this.logger.trace({type:"method",method:"delete",topic:e,reason:t});const n=await this.getSequence(e);this.sequences.delete(e),this.events.emit(Te,{topic:e,sequence:n,reason:t})}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)}async getSequence(e){await this.isInitialized();const t=this.sequences.get(e);if(!t){const t=b.NO_MATCHING_TOPIC.format({context:Object(f.d)(this.context),topic:e});throw this.logger.error(t.message),new Error(t.message)}return t}async persist(){await this.client.storage.setSequenceStore(this.context,this.values),this.events.emit(Ie)}async restore(){try{const e=await this.client.storage.getSequenceStore(this.context);if(void 0===e)return;if(!e.length)return;if(this.sequences.size){const e=b.RESTORE_WILL_OVERRIDE.format({context:Object(f.d)(this.context)});throw this.logger.error(e.message),new Error(e.message)}this.cached=e,this.logger.debug("Successfully Restored sequences for "+Object(f.d)(this.context)),this.logger.trace({type:"method",method:"restore",sequences:this.values})}catch(e){this.logger.debug("Failed to Restore sequences for "+Object(f.d)(this.context)),this.logger.error(e)}}async initialize(){await this.restore(),this.reset(),this.onInit()}reset(){this.cached.forEach(e=>this.sequences.set(e.topic,e))}onInit(){this.cached=[],this.events.emit(Se)}async isInitialized(){if(this.cached.length)return new Promise(e=>{this.events.once(Se,()=>e())})}registerEventListeners(){this.events.on(Re,e=>{const t=Re;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Oe,e=>{const t=Oe;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Te,e=>{const t=Te;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}}class Ge extends h.IPairing{constructor(e,t){super(e,t),this.client=e,this.logger=t,this.events=new r.EventEmitter,this.name="pairing",this.config={status:se,events:ae,jsonrpc:oe},this.logger=Object(K.generateChildLogger)(t,this.name),this.pending=new Be(e,this.logger,this.config.status.pending),this.settled=new Be(e,this.logger,this.config.status.settled),this.history=new Je(this.logger,this.client.storage),this.expirer=new He(e,this.logger),this.engine=new Me(this)}async init(){this.logger.trace("Initialized"),await this.pending.init(),await this.settled.init(),await this.history.init(),await this.expirer.init()}get(e){return this.settled.get(e)}find(e){return this.engine.find(e)}ping(e,t){return this.engine.ping(e,t)}send(e,t){return this.engine.send(e,t)}get context(){return Object(K.getLoggerContext)(this.logger)}get length(){return this.settled.length}get topics(){return this.settled.topics}get values(){return this.settled.values}create(e){return this.engine.create(e)}respond(e){return this.engine.respond(e)}upgrade(e){return this.engine.upgrade(e)}update(e){return this.engine.update(e)}request(e){return this.engine.request(e)}delete(e){return this.engine.delete(e)}notify(e){return this.engine.notify(e)}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)}async mergeUpdate(e,t){const n=await this.settled.get(e);return{metadata:t.state.metadata||n.state.metadata}}async mergeUpgrade(e,t){var n,r,i;const o=await this.settled.get(e);return{jsonrpc:{methods:Object(f.k)(o.permissions.jsonrpc.methods,(null===(n=t.permissions.jsonrpc)||void 0===n?void 0:n.methods)||[])},notifications:{types:Object(f.k)((null===(r=o.permissions.notifications)||void 0===r?void 0:r.types)||[],(null===(i=t.permissions.notifications)||void 0===i?void 0:i.types)||[])},controller:o.permissions.controller}}async validateRespond(e){}async validateRequest(e){}async validatePropose(e){}async getDefaultSignal({topic:e,relay:t,proposer:n}){var r;return{method:"uri",params:{uri:`${(r={protocol:this.client.protocol,version:this.client.version,topic:e,publicKey:n.publicKey,controller:n.controller,relay:t}).protocol}:${r.topic}@${r.version}?`+O.stringify({publicKey:r.publicKey,controller:r.controller,relay:Object(T.b)(r.relay)})}}}async getDefaultTTL(){return 2592e3}async getDefaultPermissions(){return{jsonrpc:{methods:[ve.propose]},notifications:{types:[]}}}}var ke=n(28),Ve=n(25).a;class Fe{constructor(){this.map=new Map}get topics(){return Array.from(this.map.keys())}set(e,t){const n=this.get(e);this.exists(e,t)||this.map.set(e,[...n,t])}get(e){return this.map.get(e)||[]}exists(e,t){return this.get(e).includes(t)}delete(e,t){if(void 0===t)return void this.map.delete(e);if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,t))return;const r=n.filter(e=>e!==t);r.length?this.map.set(e,r):this.map.delete(e)}clear(){this.map.clear()}}class ze extends h.ISubscriber{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Fe,this.events=new r.EventEmitter,this.name="subscription",this.pending=new Map,this.cached=[],this.relayer=e,this.logger=Object(K.generateChildLogger)(t,this.name),this.registerEventListeners()}async init(){this.logger.trace("Initialized"),await this.initialize()}get context(){return Object(K.getLoggerContext)(this.logger)}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}async subscribe(e,t){this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const n=w(t),r={topic:e,relay:n};this.pending.set(e,r);const i=await this.rpcSubscribe(e,n);return await this.onSubscribe(i,r),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}}),i}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}async unsubscribe(e,t){void 0!==(null==t?void 0:t.id)?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}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)}async enable(){this.cached.length&&this.onEnable()}async disable(){this.cached.length||this.onDisable()}async hasSubscription(e,t){await this.isEnabled();let n=!1;try{n=(await this.getSubscription(e)).topic===t}catch(e){}return n}onEnable(){this.cached=[],this.events.emit(Ue)}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear(),this.events.emit(Ce)}async unsubscribeByTopic(e,t){const n=this.topicMap.get(e);await Promise.all(n.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}});try{const r=w(n);await this.rpcUnsubscribe(e,t,r);const i=b.DELETED.format({context:Object(f.d)(this.context)});await this.onUnsubscribe(e,t,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t){const n={method:R(t.protocol).subscribe,params:{topic:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.provider.request(n)}async rpcUnsubscribe(e,t,n){const r={method:R(n.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r}),this.relayer.provider.request(r)}async onSubscribe(e,t){await this.setSubscription(e,Object.assign(Object.assign({},t),{id:e})),this.pending.delete(t.topic)}async onResubscribe(e,t){await this.addSubscription(e,Object.assign(Object.assign({},t),{id:e})),this.pending.delete(t.topic)}async onUnsubscribe(e,t,n){this.events.removeAllListeners(t),await this.hasSubscription(t,e)&&await this.deleteSubscription(t,n),await this.relayer.history.delete(e)}async setSubscription(e,t){await this.isEnabled(),this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),await this.addSubscription(e,t))}async addSubscription(e,t){this.subscriptions.set(e,Object.assign({},t)),this.topicMap.set(t.topic,e),this.events.emit(Ae,t)}async getSubscription(e){await this.isEnabled(),this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const t=b.NO_MATCHING_ID.format({context:Object(f.d)(this.context),id:e});throw new Error(t.message)}return t}async deleteSubscription(e,t){await this.isEnabled(),this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const n=await this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Pe,Object.assign(Object.assign({},n),{reason:t}))}async persist(){await this.relayer.storage.setRelayerSubscriptions(this.context,this.values),this.events.emit(De)}async restore(){try{const e=await this.relayer.storage.getRelayerSubscriptions(this.context);if(void 0===e)return;if(!e.length)return;if(this.subscriptions.size){const e=b.RESTORE_WILL_OVERRIDE.format({context:Object(f.d)(this.context)});throw this.logger.error(e.message),new Error(e.message)}this.cached=e,this.logger.debug("Successfully Restored subscriptions for "+Object(f.d)(this.context)),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug("Failed to Restore subscriptions for "+Object(f.d)(this.context)),this.logger.error(e)}}async initialize(){await this.restore(),await this.reset(),await this.enable()}async isEnabled(){if(this.cached.length)return new Promise(e=>{this.events.once(Ue,()=>e())})}async reset(){this.cached.length&&await Promise.all(this.cached.map(async e=>this.resubscribe(e)))}async resubscribe(e){const{topic:t,relay:n}=e,r={topic:t,relay:n};this.pending.set(r.topic,r);const i=await this.rpcSubscribe(r.topic,r.relay);if(await this.onResubscribe(i,r),this.ids.includes(e.id)){const t=b.RESUBSCRIBED.format({topic:e.topic});await this.deleteSubscription(e.id,t)}}async onConnect(){await this.reset(),await this.enable()}async onDisconnect(){await this.disable()}checkPending(){this.pending.forEach(async e=>{const t=await this.rpcSubscribe(e.topic,e.relay);await this.onSubscribe(t,e)})}registerEventListeners(){this.relayer.heartbeat.on(X,()=>{this.checkPending()}),this.relayer.provider.on(fe,async()=>{await this.onConnect()}),this.relayer.provider.on(pe,async()=>{await this.onDisconnect()}),this.events.on(Ae,async e=>{const t=Ae;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(Pe,async e=>{const t=Pe;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}}class Ye extends class{constructor(e,t,n){this.logger=e,this.keyValueStorage=t,this.config=n,this.name="storage",this.version="0.2",this.keyMap=Ne,this.logger=Object(K.generateChildLogger)(e,this.name),this.keyValueStorage=t,this.config=n}get context(){return Object(K.getLoggerContext)(this.logger)}get prefix(){return`${this.config.protocol}@${this.config.version}:${this.config.context}:${this.version}`}getStorageKey(e){const t=this.getStorageKeyName(e);if(!this.isValidStorageKeyName(t)){const e=b.INVALID_STORAGE_KEY_NAME.format({name:t});throw new Error(e.message)}return this.prefix+"//"+t}getStorageKeyName(e){return Object(f.f)(e)}isValidStorageKeyName(e){return Object.keys(this.keyMap).map(e=>Object.values(this.keyMap[e])).flat().includes(e.toLowerCase())}}{constructor(e,t,n){super(e,t,n),this.logger=e,this.keyValueStorage=t,this.config=n}async setJsonRpcRecords(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,t)}async getJsonRpcRecords(e){const t=this.getStorageKey(e);return await this.keyValueStorage.getItem(t)}async setRelayerSubscriptions(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,t)}async getRelayerSubscriptions(e){const t=this.getStorageKey(e);return await this.keyValueStorage.getItem(t)}}class We extends Ye{constructor(e,t,n){super(e,t,n),this.logger=e,this.keyValueStorage=t,this.config=n}async setKeyChain(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,Object(f.j)(t))}async getKeyChain(e){const t=this.getStorageKey(e),n=await this.keyValueStorage.getItem(t);return void 0!==n?Object(f.l)(n):void 0}async setSequenceStore(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,t)}async getSequenceStore(e){const t=this.getStorageKey(e);return await this.keyValueStorage.getItem(t)}async setExpirations(e,t){const n=this.getStorageKey(e);await this.keyValueStorage.setItem(n,t)}async getExpirations(e){const t=this.getStorageKey(e);return await this.keyValueStorage.getItem(t)}}class $e extends i.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Qe extends $e{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new r.EventEmitter,this.name="publisher",this.queue=new Map,this.relayer=e,this.logger=Object(K.generateChildLogger)(t,this.name),this.registerEventListeners()}get context(){return Object(K.getLoggerContext)(this.logger)}async init(){this.logger.trace("Initialized"),await this.initialize()}async publish(e,t,n){this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,payload:t,opts:n}});try{const r=(null==n?void 0:n.ttl)||21600,i=w(n),o={topic:e,payload:t,opts:{ttl:r,relay:i}};this.queue.set(t.id,o);const s=await this.relayer.encoder.encode(e,t);await this.rpcPublish(e,s,r,i),await this.onPublish(t.id,o),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,payload:t,opts:n}})}catch(e){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(e),e}}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)}async initialize(){}async rpcPublish(e,t,n,r){const i={method:R(r.protocol).publish,params:{topic:e,message:t,ttl:n}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.provider.request(i)}async onPublish(e,t){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:t,payload:n,opts:{ttl:r,relay:i}}=e,o=await this.relayer.encoder.encode(t,n);await this.rpcPublish(t,o,r,i),await this.onPublish(n.id,e)})}registerEventListeners(){this.relayer.heartbeat.on(X,()=>{this.checkQueue()})}}class Ze extends h.IRelayer{constructor(e){super(e),this.protocol="irn",this.version=1,this.events=new r.EventEmitter,this.name="relayer",this.logger=void 0!==(null==e?void 0:e.logger)&&"string"!=typeof(null==e?void 0:e.logger)?Object(K.generateChildLogger)(e.logger,this.name):a()(Object(K.getDefaultLoggerOptions)({level:(null==e?void 0:e.logger)||"error"}));const t=Object.assign(Object.assign({},ye),null==e?void 0:e.keyValueStorageOptions);this.storage=void 0!==(null==e?void 0:e.storage)?e.storage:new Ye(this.logger,(null==e?void 0:e.keyValueStorage)||new u.a(t),{protocol:this.protocol,version:this.version,context:this.context}),this.heartbeat=(null==e?void 0:e.heartbeat)||new Ke({logger:this.logger}),this.encoder=(null==e?void 0:e.encoder)||new qe;const n=(null==e?void 0:e.rpcUrl)||Object(f.e)(this.protocol,this.version,"wss://relay.walletconnect.com",null==e?void 0:e.projectId);this.provider="string"!=typeof(null==e?void 0:e.relayProvider)&&void 0!==(null==e?void 0:e.relayProvider)?null==e?void 0:e.relayProvider:new ke.JsonRpcProvider(new Ve(n)),this.history=new Je(this.logger,this.storage),this.subscriber=new ze(this,this.logger),this.publisher=new Qe(this,this.logger),this.registerEventListeners()}get context(){return Object(K.getLoggerContext)(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async init(){this.logger.trace("Initialized"),await this.history.init(),await this.provider.connect(),await this.subscriber.init(),await this.publisher.init()}async publish(e,t,n){await this.publisher.publish(e,t,n),await this.recordPayloadEvent({topic:e,payload:t})}async subscribe(e,t){return await this.subscriber.subscribe(e,t)}async unsubscribe(e,t){await this.subscriber.unsubscribe(e,t)}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)}async recordPayloadEvent(e){const{topic:t,payload:n}=e;Object(o.isJsonRpcRequest)(n)?await this.history.set(t,n):await this.history.resolve(n)}async shouldIgnorePayloadEvent(e){const{topic:t,payload:n}=e;if(!this.subscriber.topics.includes(t))return!0;let r=!1;try{if(Object(o.isJsonRpcRequest)(n))r=await this.history.exists(t,n.id);else{let e;try{e=await this.history.get(t,n.id)}catch(e){}r=void 0!==e&&void 0!==e.response}}catch(e){}return r}async onPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Object(o.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:n,message:r}=t.data,i={topic:n,payload:await this.encoder.decode(n,r)};if(await this.shouldIgnorePayloadEvent(i))return;this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Object.assign({type:"event",event:t.id},i)),this.events.emit(t.id,i),this.events.emit(ce,i),await this.acknowledgePayload(e),await this.recordPayloadEvent(i)}}async acknowledgePayload(e){const t=Object(o.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}registerEventListeners(){this.provider.on(de,e=>this.onPayload(e)),this.provider.on(fe,async()=>{this.events.emit(ue)}),this.provider.on(pe,async()=>{this.events.emit(he),setTimeout(()=>{this.provider.connect()},1)}),this.provider.on(ge,e=>this.events.emit(le,e))}}class Xe extends h.ISession{constructor(e,t){super(e,t),this.client=e,this.logger=t,this.events=new r.EventEmitter,this.name="session",this.config={status:me,events:Ee,jsonrpc:ve},this.logger=Object(K.generateChildLogger)(t,this.name),this.pending=new Be(e,this.logger,this.config.status.pending),this.settled=new Be(e,this.logger,this.config.status.settled),this.history=new Je(this.logger,this.client.storage),this.expirer=new He(e,this.logger),this.engine=new Me(this)}async init(){this.logger.trace("Initialized"),await this.pending.init(),await this.settled.init(),await this.history.init(),await this.expirer.init()}get(e){return this.settled.get(e)}find(e){return this.engine.find(e)}ping(e,t){return this.engine.ping(e,t)}send(e,t,n){return this.engine.send(e,t,n)}get context(){return Object(K.getLoggerContext)(this.logger)}get length(){return this.settled.length}get topics(){return this.settled.topics}get values(){return this.settled.values}create(e){return this.engine.create(e)}respond(e){return this.engine.respond(e)}upgrade(e){return this.engine.upgrade(e)}update(e){return this.engine.update(e)}request(e){return this.engine.request(e)}delete(e){return this.engine.delete(e)}notify(e){return this.engine.notify(e)}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)}async mergeUpdate(e,t){var n;const r=await this.settled.get(e);return{accounts:(null===(n=t.state)||void 0===n?void 0:n.accounts)||r.state.accounts}}async mergeUpgrade(e,t){var n,r,i,o,s;const a=await this.settled.get(e);return{jsonrpc:{methods:Object(f.k)(a.permissions.jsonrpc.methods,(null===(n=t.permissions.jsonrpc)||void 0===n?void 0:n.methods)||[])},notifications:{types:Object(f.k)((null===(r=a.permissions.notifications)||void 0===r?void 0:r.types)||[],(null===(i=t.permissions.notifications)||void 0===i?void 0:i.types)||[])},blockchain:{chains:Object(f.k)((null===(o=a.permissions.blockchain)||void 0===o?void 0:o.chains)||[],(null===(s=t.permissions.blockchain)||void 0===s?void 0:s.chains)||[])},controller:a.permissions.controller}}async validateRespond(e){if(void 0===e){const e=b.MISSING_OR_INVALID.format({name:"respond params"});throw this.logger.error(e.message),new Error(e.message)}const t=C(e);if(M(t))throw this.logger.error(t.error.message),new Error(t.error.message)}async validateRequest(e){if(void 0===e){const e=b.MISSING_OR_INVALID.format({name:"request params"});throw this.logger.error(e.message),new Error(e.message)}const{topic:t,chainId:n}=e,r=await this.settled.get(t);if(n&&!r.permissions.blockchain.chains.includes(n)){const e=b.UNAUTHORIZED_TARGET_CHAIN.format({chainId:n});throw this.logger.error(e.message),new Error(e.message)}}async validatePropose(e){if(void 0===e){const e=b.MISSING_OR_INVALID.format({name:"propose params"});throw this.logger.error(e.message),new Error(e.message)}const t=function(e){const t=P(e.permissions);if(M(t))return t;const n=U(e.metadata);return M(n)?n:{valid:!0}}(e);if(M(t))throw this.logger.error(t.error.message),new Error(t.error.message);if("pairing"!==e.signal.method){const e=b.UNSUPPORTED_SIGNAL.format({context:this.context});throw this.logger.error(e.message),new Error(e.message)}}async getDefaultSignal(e){return{method:"pairing",params:{topic:(await this.client.pairing.settled.get(e.topic)).topic}}}async getDefaultTTL(){return 604800}async getDefaultPermissions(){return{jsonrpc:{methods:[]},notifications:{types:[]},blockchain:{chains:[]}}}}class et extends h.IClient{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new r.EventEmitter,this.name=J;const t=void 0!==(null==e?void 0:e.logger)&&"string"!=typeof(null==e?void 0:e.logger)?e.logger:a()(Object(K.getDefaultLoggerOptions)({level:(null==e?void 0:e.logger)||B}));this.name=(null==e?void 0:e.name)||J,this.controller=(null==e?void 0:e.controller)||G,this.metadata=(null==e?void 0:e.metadata)||Object(f.h)(),this.projectId=null==e?void 0:e.projectId,this.logger=Object(K.generateChildLogger)(t,this.name),this.heartbeat=new Ke({logger:this.logger}),this.crypto=new je(this,this.logger,null==e?void 0:e.keychain),this.encoder=new xe(this,this.logger);const n=Object.assign(Object.assign({},z),null==e?void 0:e.storageOptions);this.storage=new We(this.logger,(null==e?void 0:e.storage)||new u.a(n),{protocol:this.protocol,version:this.version,context:this.context}),this.relayUrl=Object(f.e)(this.protocol,this.version,(null==e?void 0:e.relayUrl)||k,this.projectId),this.relayer=new Ze({rpcUrl:this.relayUrl,heartbeat:this.heartbeat,encoder:this.encoder,logger:this.logger,storage:this.storage,projectId:this.projectId,keyValueStorageOptions:n}),this.pairing=new Ge(this,this.logger),this.session=new Xe(this,this.logger)}static async init(e){const t=new et(e);return await t.initialize(),t}get context(){return Object(K.getLoggerContext)(this.logger)}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)}async connect(e){this.logger.debug("Connecting Application"),this.logger.trace({type:"method",method:"connect",params:e});try{void 0===typeof e.pairing&&this.logger.info("Connecing with existing pairing");const t=void 0===e.pairing?await this.pairing.create():await this.pairing.get(e.pairing.topic);this.logger.trace({type:"method",method:"connect",pairing:t});const n=e.metadata||this.metadata;if(void 0===n){const e=b.MISSING_OR_INVALID.format({name:"app metadata"});throw this.logger.error(e.message),new Error(e.message)}const r=await this.session.create({signal:{method:"pairing",params:{topic:t.topic}},relay:e.relay||{protocol:"waku"},metadata:n,permissions:Object.assign(Object.assign({},e.permissions),{notifications:be.notifications})});return this.logger.debug("Application Connection Successful"),this.logger.trace({type:"method",method:"connect",session:r}),r}catch(e){throw this.logger.debug("Application Connection Failure"),this.logger.error(e),e}}async pair(e){this.logger.debug("Pairing"),this.logger.trace({type:"method",method:"pair",params:e});const t=function(e){const t=function(e){const t=e.indexOf(":"),n=-1!==e.indexOf("?")?e.indexOf("?"):void 0,r=e.substring(0,t),i=e.substring(t+1,n).split("@"),o=void 0!==n?e.substr(n):"",s=O.parse(o);return{protocol:r,topic:i[0],version:parseInt(i[1],10),publicKey:s.publicKey,controller:"true"===s.controller,relay:Object(T.a)(s.relay)}}(e);return{topic:t.topic,relay:t.relay,proposer:{publicKey:t.publicKey,controller:t.controller},signal:{method:"uri",params:{uri:e}},permissions:{jsonrpc:{methods:[ve.propose]},notifications:{types:[]}},ttl:2592e3}}(e.uri),n=t.proposer.controller!==this.controller,r=n?void 0:b.UNAUTHORIZED_MATCHING_CONTROLLER.format({controller:this.controller}),i=await this.pairing.respond({approved:n,proposal:t,reason:r});if(!function(e){return A(e.status)&&"outcome"in e}(i)){const e=b.NO_MATCHING_RESPONSE.format({context:"pairing"});throw this.logger.error(e.message),new Error(e.message)}if("reason"in i.outcome)throw this.logger.debug("Pairing Failure"),this.logger.trace({type:"method",method:"pair",outcome:i.outcome}),new Error(i.outcome.reason.message);this.logger.debug("Pairing Success"),this.logger.trace({type:"method",method:"pair",pending:i});return await this.pairing.get(i.outcome.topic)}async approve(e){if(this.logger.debug("Approving Session Proposal"),this.logger.trace({type:"method",method:"approve",params:e}),void 0===e.response){const e=b.MISSING_RESPONSE.format({context:"session"});throw this.logger.error(e.message),new Error(e.message)}const t=e.response.state||_e,n=e.response.metadata||this.metadata;if(void 0===n){const e=b.MISSING_OR_INVALID.format({name:"app metadata"});throw this.logger.error(e.message),new Error(e.message)}const r=e.proposal.proposer.controller!==this.controller,i=r?void 0:b.UNAUTHORIZED_MATCHING_CONTROLLER.format({controller:this.controller}),o=await this.session.respond({approved:r,proposal:e.proposal,response:{state:t,metadata:n},reason:i});if(!function(e){return A(e.status)&&"outcome"in e}(o)){const e=b.NO_MATCHING_RESPONSE.format({context:"session"});throw this.logger.error(e.message),new Error(e.message)}if("reason"in o.outcome)throw this.logger.debug("Session Proposal Approval Failure"),this.logger.trace({type:"method",method:"approve",outcome:o.outcome}),new Error(o.outcome.reason.message);return this.logger.debug("Session Proposal Approval Success"),this.logger.trace({type:"method",method:"approve",pending:o}),this.session.get(o.outcome.topic)}async reject(e){this.logger.debug("Rejecting Session Proposal"),this.logger.trace({type:"method",method:"reject",params:e});const t=await this.session.respond({approved:!1,proposal:e.proposal,response:we,reason:e.reason});this.logger.debug("Session Proposal Response Success"),this.logger.trace({type:"method",method:"reject",pending:t})}async upgrade(e){await this.session.upgrade(e)}async update(e){await this.session.update(e)}async request(e){return this.session.request(e)}async respond(e){await this.session.send(e.topic,e.response)}async ping(e){await this.session.ping(e.topic,e.timeout)}async notify(e){await this.session.notify(e)}async disconnect(e){this.logger.debug("Disconnecting Application"),this.logger.trace({type:"method",method:"disconnect",params:e}),await this.session.delete(e)}async onPairingRequest(e,t){if(e.method===ve.propose){const n=e.params;if(n.proposer.controller===this.controller){const e=b.UNAUTHORIZED_MATCHING_CONTROLLER.format({controller:this.controller});return void await this.session.respond({approved:!1,proposal:n,response:we,reason:e})}const r=F.proposal;this.logger.info("Emitting "+r),this.logger.debug({type:"event",event:r,data:n}),this.events.emit(r,n);const i=Object(o.formatJsonRpcResult)(e.id,!0);await this.pairing.send(t,i)}}async onPairingSettled(e){e.permissions.controller.publicKey===e.self.publicKey&&void 0===e.state.metadata&&setTimeout(async()=>await this.pairing.update({topic:e.topic,state:{metadata:this.metadata}}),50)}async initialize(){this.logger.trace("Initialized");try{await this.pairing.init(),await this.session.init(),await this.crypto.init(),await this.relayer.init(),await this.heartbeat.init(),this.registerEventListeners(),this.logger.info("Client Initilization Success")}catch(e){throw this.logger.info("Client Initilization Failure"),this.logger.error(e),e}}registerEventListeners(){this.pairing.on(ae.proposed,e=>{const t=V.proposal;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e.proposal}),this.events.emit(t,e.proposal)}),this.pairing.on(ae.settled,e=>{const t=V.created;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e),this.onPairingSettled(e)}),this.pairing.on(ae.updated,(e,t)=>{const n=V.updated;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,update:t}),this.events.emit(n,e,t)}),this.pairing.on(ae.upgraded,(e,t)=>{const n=V.upgraded;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,upgrade:t}),this.events.emit(n,e,t)}),this.pairing.on(ae.deleted,(e,t)=>{const n=V.deleted;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,reason:t}),this.events.emit(n,e,t)}),this.pairing.on(ae.request,e=>{this.onPairingRequest(e.request,e.topic)}),this.session.on(ae.sync,()=>this.events.emit(V.sync)),this.session.on(Ee.proposed,e=>{const t=F.proposal;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e.proposal}),this.events.emit(t,e.proposal)}),this.session.on(Ee.settled,e=>{const t=F.created;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e)}),this.session.on(Ee.updated,(e,t)=>{const n=F.updated;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,update:t}),this.events.emit(n,e,t)}),this.session.on(Ee.upgraded,(e,t)=>{const n=F.upgraded;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,upgrade:t}),this.events.emit(n,e,t)}),this.session.on(Ee.deleted,(e,t)=>{const n=F.deleted;this.logger.info("Emitting "+n),this.logger.debug({type:"event",event:n,data:e,reason:t}),this.events.emit(n,e,t)}),this.session.on(Ee.request,e=>{const t=F.request;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e)}),this.session.on(Ee.response,e=>{const t=F.response;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e)}),this.session.on(Ee.notification,e=>{const t=F.notification;this.logger.info("Emitting "+t),this.logger.debug({type:"event",event:t,data:e}),this.events.emit(t,e)}),this.session.on(Ee.sync,()=>this.events.emit(F.sync))}}const tt=et;const nt={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",notification:"signer_notification"};class rt extends i.IJsonRpcConnection{constructor(e){super(),this.events=new r.EventEmitter,this.pending=!1,this.initializing=!1,this.chains=(null==e?void 0:e.chains)||[],this.methods=(null==e?void 0:e.methods)||[],this.opts=null==e?void 0:e.client}get connected(){return void 0!==this.session}get connecting(){return this.pending}get accounts(){var e;return(null===(e=this.session)||void 0===e?void 0:e.state.accounts)||[]}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)}async open(){if(this.pending)return new Promise((e,t)=>{this.events.once("open",()=>{if(this.events.once("open_error",e=>{t(e)}),void 0===this.client)return t(new Error("Client not initialized"));e()})});try{this.pending=!0;const e=await this.register(),t=await e.session.find({blockchain:{chains:this.chains},jsonrpc:{methods:this.methods}});if(t.length)return this.onOpen(t[0]);this.session=await e.connect({permissions:{blockchain:{chains:this.chains},jsonrpc:{methods:this.methods}}}),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){if(void 0===this.session)return;const e=await this.register();await e.disconnect({topic:this.session.topic,reason:b.USER_DISCONNECTED.format()}),this.onClose()}async send(e,t){if(void 0===this.client&&(this.client=await this.register(),this.connected||await this.open()),void 0===this.session)throw new Error("Signer connection is missing session");this.client.request({topic:this.session.topic,request:e,chainId:null==t?void 0:t.chainId}).then(t=>this.events.emit("payload",Object(o.formatJsonRpcResult)(e.id,t))).catch(t=>this.events.emit("payload",Object(o.formatJsonRpcError)(e.id,t.message)))}async register(e=this.opts){if(void 0!==this.client)return this.client;if(this.initializing)return new Promise((e,t)=>{this.events.once("register_error",e=>{t(e)}),this.events.once(nt.init,()=>{if(void 0===this.client)return t(new Error("Client not initialized"));e(this.client)})});if(function(e){return void 0!==e&&void 0!==e.context}(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await tt.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(nt.init),this.client}catch(e){throw this.events.emit("register_error",e),e}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){void 0!==this.client&&(this.client.on(F.created,e=>{var t;this.session&&(null===(t=this.session)||void 0===t?void 0:t.topic)!==e.topic||(this.session=e,this.events.emit(nt.created,e))}),this.client.on(F.updated,e=>{var t;this.session&&(null===(t=this.session)||void 0===t?void 0:t.topic)!==e.topic||(this.session=e,this.events.emit(nt.updated,e))}),this.client.on(F.notification,e=>{var t;this.session&&(null===(t=this.session)||void 0===t?void 0:t.topic)!==e.topic||this.events.emit(nt.notification,e.notification)}),this.client.on(F.deleted,e=>{var t;this.session&&(this.session&&(null===(t=this.session)||void 0===t?void 0:t.topic)!==e.topic||(this.onClose(),this.events.emit(nt.deleted,e),this.session=void 0))}),this.client.on(V.proposal,async e=>{const t=e.signal.params.uri;this.events.emit(nt.uri,{uri:t})}))}}t.default=rt},function(e,t,n){"use strict";n.r(t),n.d(t,"HttpConnection",(function(){return u}));var r=n(3),i=n(29),o=n.n(i),s=n(8),a=n(0);const c={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class u{constructor(e){if(this.url=e,this.events=new r.EventEmitter,this.isAvailable=!1,this.registering=!1,!Object(a.isHttpUrl)(e))throw new Error("Provided URL is not compatible with HTTP connection: "+e);this.url=e}get connected(){return this.isAvailable}get connecting(){return this.registering}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)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e,t){this.isAvailable||await this.register();try{const t=Object(s.b)(e),n=await o()(this.url,Object.assign(Object.assign({},c),{body:t})),r=await n.json();this.onPayload({data:r})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!Object(a.isHttpUrl)(e))throw new Error("Provided URL is not compatible with HTTP connection: "+e);if(this.registering)return new Promise((e,t)=>{this.events.once("register_error",e=>{t(e)}),this.events.once("open",()=>{if(void 0===this.isAvailable)return t(new Error("HTTP connection is missing or invalid"));e()})});this.url=e,this.registering=!0;try{const t=Object(s.b)({id:1,jsonrpc:"2.0",method:"test",params:[]});await o()(e,Object.assign(Object.assign({},c),{body:t})),this.onOpen()}catch(e){const t=this.parseError(e);throw this.events.emit("register_error",t),this.onClose(),t}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(void 0===e.data)return;const t="string"==typeof e.data?Object(s.a)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const n=this.parseError(t),r=n.message||n.toString(),i=Object(a.formatJsonRpcError)(e,r);this.events.emit("payload",i)}parseError(e,t=this.url){return Object(a.parseConnectionError)(e,t,"HTTP")}}var h=u;t.default=h}])}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walletconnect/ethereum-provider",
|
|
3
3
|
"description": "Ethereum Provider for WalletConnect Protocol",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.22",
|
|
5
5
|
"author": "WalletConnect, Inc. <walletconnect.com>",
|
|
6
6
|
"homepage": "https://github.com/walletconnect/walletconnect-monorepo/",
|
|
7
7
|
"repository": {
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"lint": "eslint -c '../../.eslintrc' --fix './src/**/*.ts'"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@walletconnect/client": "^2.0.0-beta.
|
|
37
|
+
"@walletconnect/client": "^2.0.0-beta.22",
|
|
38
38
|
"@walletconnect/jsonrpc-http-connection": "^1.0.0",
|
|
39
39
|
"@walletconnect/jsonrpc-provider": "^1.0.0",
|
|
40
40
|
"@walletconnect/jsonrpc-types": "^1.0.0",
|
|
41
41
|
"@walletconnect/jsonrpc-utils": "^1.0.0",
|
|
42
|
-
"@walletconnect/signer-connection": "^2.0.0-beta.
|
|
43
|
-
"@walletconnect/types": "^2.0.0-beta.
|
|
44
|
-
"@walletconnect/utils": "^2.0.0-beta.
|
|
42
|
+
"@walletconnect/signer-connection": "^2.0.0-beta.22",
|
|
43
|
+
"@walletconnect/types": "^2.0.0-beta.22",
|
|
44
|
+
"@walletconnect/utils": "^2.0.0-beta.22",
|
|
45
45
|
"eip1193-provider": "^1.0.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|