@imtbl/sdk 1.77.3-alpha.1 → 1.77.3
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.
- package/dist/{blockchain_data-CArmhGSW.js → blockchain_data-DkZl-ok7.js} +2 -2
- package/dist/blockchain_data.js +3 -3
- package/dist/browser/checkout/{AddTokensWidget-CzAE1d3f.js → AddTokensWidget-aDzekY-Z.js} +12 -11
- package/dist/browser/checkout/{BridgeWidget-6snvryex.js → BridgeWidget-DNT1nR4Q.js} +9 -9
- package/dist/browser/checkout/{CommerceWidget-BQzxxBBp.js → CommerceWidget-BuE9AMeb.js} +17 -17
- package/dist/browser/checkout/{CryptoFiatProvider-DrL1vFka.js → CryptoFiatProvider-ChK3yyuj.js} +1 -1
- package/dist/browser/checkout/{FeesBreakdown-6N1PBhxc.js → FeesBreakdown-DsQ1GiPL.js} +1 -1
- package/dist/browser/checkout/{HandoverContent-DACeI3Ql.js → HandoverContent-DrYtfRBM.js} +1 -1
- package/dist/browser/checkout/{OnRampWidget-C27NOCDj.js → OnRampWidget-_eHJr4db.js} +3 -3
- package/dist/browser/checkout/{SaleWidget-0wqfnQkL.js → SaleWidget-CmbwEKdx.js} +14 -14
- package/dist/browser/checkout/{SpendingCapHero-se43V9Us.js → SpendingCapHero-CzoLRzbM.js} +1 -1
- package/dist/browser/checkout/{SwapWidget-DL3WYUw9.js → SwapWidget-Dgov2HpO.js} +9 -9
- package/dist/browser/checkout/{TokenImage-Im5drCmP.js → TokenImage-DqPCiIZX.js} +1 -1
- package/dist/browser/checkout/{TopUpView-h8yzvXWl.js → TopUpView-B_BueCyt.js} +3 -3
- package/dist/browser/checkout/{WalletApproveHero-ByDRA_kK.js → WalletApproveHero-BSmphjGQ.js} +3 -3
- package/dist/browser/checkout/{WalletWidget-BRLER2vp.js → WalletWidget-D4O0R6py.js} +4 -4
- package/dist/browser/checkout/{auto-track-D_sVcc3q.js → auto-track-DIMS5DYU.js} +1 -1
- package/dist/browser/checkout/{index-C6VrFT0d.js → index-3Y6xc4zD.js} +1 -1
- package/dist/browser/checkout/{index-CLIIegap.js → index-B5cXrUQI.js} +1 -1
- package/dist/browser/checkout/{index-CpPB7WU9.js → index-BDI1eB3s.js} +1 -1
- package/dist/browser/checkout/{index-CU8j8oV7.js → index-BRoEmUAs.js} +1 -1
- package/dist/browser/checkout/{index-Ciq_hY6N.js → index-BrmWfPrW.js} +1 -1
- package/dist/browser/checkout/{index-DIgPyYaY.js → index-CSB2x7sJ.js} +1 -1
- package/dist/browser/checkout/{index-D7zuN_2m.js → index-CWLWMLW8.js} +18 -18
- package/dist/browser/checkout/{index-BrPk4SVq.js → index-DE0qGsoB.js} +1 -1
- package/dist/browser/checkout/{index-D-6LYeBT.js → index-DmcEGZvP.js} +1 -1
- package/dist/browser/checkout/{index-ZsTq7hP6.js → index-DwBzFvJj.js} +2 -2
- package/dist/browser/checkout/{index.umd-BTRWYRB0.js → index.umd-Js96ZE0P.js} +1 -1
- package/dist/browser/checkout/sdk.js +4 -4
- package/dist/browser/checkout/{useInterval-DeDgB1gY.js → useInterval-DlTwMY61.js} +1 -1
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +856 -800
- package/dist/{checkout-BhTtaESf.js → checkout-c43bAXCO.js} +5 -5
- package/dist/checkout.js +5 -5
- package/dist/{config-fXqK1r9g.js → config-Bo0VDpMU.js} +1 -1
- package/dist/config.js +1 -1
- package/dist/{index-CoCKmkEn.js → index-B93YEIgA.js} +1 -1
- package/dist/{index-D4jZsZRi.js → index-BYGkydHM.js} +3 -3
- package/dist/{index-Jvu4oWxu.js → index-Bjvl2BxB.js} +1 -1
- package/dist/{index-Bu4xIXQj.js → index-C_aEGeIY.js} +4 -4
- package/dist/{index-Dl872d0t.js → index-CdoLGKvW.js} +1 -1
- package/dist/{index-Dat84Bus.js → index-DsuFLJpT.js} +1 -1
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.js +14 -14
- package/dist/{minting_backend-Bw9DhzFI.js → minting_backend-B2KW-nGM.js} +3 -3
- package/dist/minting_backend.js +5 -5
- package/dist/{orderbook-vSa-Hufk.js → orderbook-D_esea5D.js} +1 -1
- package/dist/orderbook.js +2 -2
- package/dist/{passport-BFB5k_mf.js → passport-BUHqowqA.js} +3 -3
- package/dist/passport.js +4 -4
- package/dist/version.json +1 -1
- package/dist/{webhook-Cgox-WOQ.js → webhook-CxF8S59z.js} +1 -1
- package/dist/webhook.js +2 -2
- package/dist/{x-CHXhfkcZ.js → x-BBgDYQSS.js} +3 -3
- package/dist/x.js +4 -4
- package/package.json +1 -1
|
@@ -61635,11 +61635,11 @@
|
|
|
61635
61635
|
|
|
61636
61636
|
var utf8$7 = {};
|
|
61637
61637
|
|
|
61638
|
-
var hasRequiredUtf8$
|
|
61638
|
+
var hasRequiredUtf8$3;
|
|
61639
61639
|
|
|
61640
|
-
function requireUtf8$
|
|
61641
|
-
if (hasRequiredUtf8$
|
|
61642
|
-
hasRequiredUtf8$
|
|
61640
|
+
function requireUtf8$3 () {
|
|
61641
|
+
if (hasRequiredUtf8$3) return utf8$7;
|
|
61642
|
+
hasRequiredUtf8$3 = 1;
|
|
61643
61643
|
(function (exports) {
|
|
61644
61644
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61645
61645
|
exports.toUtf8CodePoints = exports.toUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = void 0;
|
|
@@ -61958,7 +61958,7 @@
|
|
|
61958
61958
|
const data_js_1 = requireData$2();
|
|
61959
61959
|
const errors_js_1 = requireErrors$2();
|
|
61960
61960
|
const properties_js_1 = requireProperties$2();
|
|
61961
|
-
const utf8_js_1 = requireUtf8$
|
|
61961
|
+
const utf8_js_1 = requireUtf8$3();
|
|
61962
61962
|
const geturl_js_1 = requireGeturlBrowser$2();
|
|
61963
61963
|
const MAX_ATTEMPTS = 12;
|
|
61964
61964
|
const SLOT_INTERVAL = 250;
|
|
@@ -63697,7 +63697,7 @@
|
|
|
63697
63697
|
Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return units_js_1.parseEther; } });
|
|
63698
63698
|
Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return units_js_1.formatUnits; } });
|
|
63699
63699
|
Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return units_js_1.parseUnits; } });
|
|
63700
|
-
var utf8_js_1 = requireUtf8$
|
|
63700
|
+
var utf8_js_1 = requireUtf8$3();
|
|
63701
63701
|
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return utf8_js_1.toUtf8Bytes; } });
|
|
63702
63702
|
Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return utf8_js_1.toUtf8CodePoints; } });
|
|
63703
63703
|
Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return utf8_js_1.toUtf8String; } });
|
|
@@ -71580,7 +71580,7 @@
|
|
|
71580
71580
|
hasRequiredString$2 = 1;
|
|
71581
71581
|
Object.defineProperty(string$3, "__esModule", { value: true });
|
|
71582
71582
|
string$3.StringCoder = void 0;
|
|
71583
|
-
const utf8_js_1 = requireUtf8$
|
|
71583
|
+
const utf8_js_1 = requireUtf8$3();
|
|
71584
71584
|
const typed_js_1 = requireTyped$2();
|
|
71585
71585
|
const bytes_js_1 = requireBytes$2();
|
|
71586
71586
|
/**
|
|
@@ -80042,15 +80042,15 @@
|
|
|
80042
80042
|
return contract$4;
|
|
80043
80043
|
}
|
|
80044
80044
|
|
|
80045
|
-
var factory$
|
|
80045
|
+
var factory$2 = {};
|
|
80046
80046
|
|
|
80047
80047
|
var hasRequiredFactory$2;
|
|
80048
80048
|
|
|
80049
80049
|
function requireFactory$2 () {
|
|
80050
|
-
if (hasRequiredFactory$2) return factory$
|
|
80050
|
+
if (hasRequiredFactory$2) return factory$2;
|
|
80051
80051
|
hasRequiredFactory$2 = 1;
|
|
80052
|
-
Object.defineProperty(factory$
|
|
80053
|
-
factory$
|
|
80052
|
+
Object.defineProperty(factory$2, "__esModule", { value: true });
|
|
80053
|
+
factory$2.ContractFactory = void 0;
|
|
80054
80054
|
const index_js_1 = requireAbi$2();
|
|
80055
80055
|
const index_js_2 = requireAddress$a();
|
|
80056
80056
|
const index_js_3 = requireUtils$c();
|
|
@@ -80162,9 +80162,9 @@
|
|
|
80162
80162
|
return new this(abi, bytecode, runner);
|
|
80163
80163
|
}
|
|
80164
80164
|
}
|
|
80165
|
-
factory$
|
|
80165
|
+
factory$2.ContractFactory = ContractFactory;
|
|
80166
80166
|
|
|
80167
|
-
return factory$
|
|
80167
|
+
return factory$2;
|
|
80168
80168
|
}
|
|
80169
80169
|
|
|
80170
80170
|
var hasRequiredContract$4;
|
|
@@ -128798,7 +128798,7 @@
|
|
|
128798
128798
|
}
|
|
128799
128799
|
var baseLogger = new Logger();
|
|
128800
128800
|
|
|
128801
|
-
let EventEmitter$
|
|
128801
|
+
let EventEmitter$2 = class EventEmitter {
|
|
128802
128802
|
constructor() {
|
|
128803
128803
|
this.observers = {};
|
|
128804
128804
|
}
|
|
@@ -128998,7 +128998,7 @@
|
|
|
128998
128998
|
return code;
|
|
128999
128999
|
}
|
|
129000
129000
|
|
|
129001
|
-
class ResourceStore extends EventEmitter$
|
|
129001
|
+
class ResourceStore extends EventEmitter$2 {
|
|
129002
129002
|
constructor(data) {
|
|
129003
129003
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
129004
129004
|
ns: ['translation'],
|
|
@@ -129135,7 +129135,7 @@
|
|
|
129135
129135
|
};
|
|
129136
129136
|
|
|
129137
129137
|
const checkedLoadedFor = {};
|
|
129138
|
-
class Translator extends EventEmitter$
|
|
129138
|
+
class Translator extends EventEmitter$2 {
|
|
129139
129139
|
constructor(services) {
|
|
129140
129140
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
129141
129141
|
super();
|
|
@@ -130243,7 +130243,7 @@
|
|
|
130243
130243
|
q.pendingCount--;
|
|
130244
130244
|
}
|
|
130245
130245
|
}
|
|
130246
|
-
class Connector extends EventEmitter$
|
|
130246
|
+
class Connector extends EventEmitter$2 {
|
|
130247
130247
|
constructor(backend, store, services) {
|
|
130248
130248
|
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
130249
130249
|
super();
|
|
@@ -130542,7 +130542,7 @@
|
|
|
130542
130542
|
}
|
|
130543
130543
|
});
|
|
130544
130544
|
}
|
|
130545
|
-
class I18n extends EventEmitter$
|
|
130545
|
+
class I18n extends EventEmitter$2 {
|
|
130546
130546
|
constructor() {
|
|
130547
130547
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
130548
130548
|
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -136719,27 +136719,27 @@
|
|
|
136719
136719
|
function EventHandlers() {}
|
|
136720
136720
|
EventHandlers.prototype = Object.create(null);
|
|
136721
136721
|
|
|
136722
|
-
function EventEmitter$
|
|
136723
|
-
EventEmitter$
|
|
136722
|
+
function EventEmitter$1() {
|
|
136723
|
+
EventEmitter$1.init.call(this);
|
|
136724
136724
|
}
|
|
136725
136725
|
|
|
136726
136726
|
// nodejs oddity
|
|
136727
136727
|
// require('events') === require('events').EventEmitter
|
|
136728
|
-
EventEmitter$
|
|
136728
|
+
EventEmitter$1.EventEmitter = EventEmitter$1;
|
|
136729
136729
|
|
|
136730
|
-
EventEmitter$
|
|
136730
|
+
EventEmitter$1.usingDomains = false;
|
|
136731
136731
|
|
|
136732
|
-
EventEmitter$
|
|
136733
|
-
EventEmitter$
|
|
136734
|
-
EventEmitter$
|
|
136732
|
+
EventEmitter$1.prototype.domain = undefined;
|
|
136733
|
+
EventEmitter$1.prototype._events = undefined;
|
|
136734
|
+
EventEmitter$1.prototype._maxListeners = undefined;
|
|
136735
136735
|
|
|
136736
136736
|
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
136737
136737
|
// added to it. This is a useful default which helps finding memory leaks.
|
|
136738
|
-
EventEmitter$
|
|
136738
|
+
EventEmitter$1.defaultMaxListeners = 10;
|
|
136739
136739
|
|
|
136740
|
-
EventEmitter$
|
|
136740
|
+
EventEmitter$1.init = function() {
|
|
136741
136741
|
this.domain = null;
|
|
136742
|
-
if (EventEmitter$
|
|
136742
|
+
if (EventEmitter$1.usingDomains) {
|
|
136743
136743
|
// if there is an active domain, then attach to it.
|
|
136744
136744
|
if (domain.active) ;
|
|
136745
136745
|
}
|
|
@@ -136754,7 +136754,7 @@
|
|
|
136754
136754
|
|
|
136755
136755
|
// Obviously not all Emitters should be limited to 10. This function allows
|
|
136756
136756
|
// that to be increased. Set to zero for unlimited.
|
|
136757
|
-
EventEmitter$
|
|
136757
|
+
EventEmitter$1.prototype.setMaxListeners = function setMaxListeners(n) {
|
|
136758
136758
|
if (typeof n !== 'number' || n < 0 || isNaN(n))
|
|
136759
136759
|
throw new TypeError('"n" argument must be a positive number');
|
|
136760
136760
|
this._maxListeners = n;
|
|
@@ -136763,11 +136763,11 @@
|
|
|
136763
136763
|
|
|
136764
136764
|
function $getMaxListeners(that) {
|
|
136765
136765
|
if (that._maxListeners === undefined)
|
|
136766
|
-
return EventEmitter$
|
|
136766
|
+
return EventEmitter$1.defaultMaxListeners;
|
|
136767
136767
|
return that._maxListeners;
|
|
136768
136768
|
}
|
|
136769
136769
|
|
|
136770
|
-
EventEmitter$
|
|
136770
|
+
EventEmitter$1.prototype.getMaxListeners = function getMaxListeners() {
|
|
136771
136771
|
return $getMaxListeners(this);
|
|
136772
136772
|
};
|
|
136773
136773
|
|
|
@@ -136828,7 +136828,7 @@
|
|
|
136828
136828
|
}
|
|
136829
136829
|
}
|
|
136830
136830
|
|
|
136831
|
-
EventEmitter$
|
|
136831
|
+
EventEmitter$1.prototype.emit = function emit(type) {
|
|
136832
136832
|
var er, handler, len, args, i, events, domain;
|
|
136833
136833
|
var doError = (type === 'error');
|
|
136834
136834
|
|
|
@@ -136959,13 +136959,13 @@
|
|
|
136959
136959
|
function emitWarning(e) {
|
|
136960
136960
|
typeof console.warn === 'function' ? console.warn(e) : console.log(e);
|
|
136961
136961
|
}
|
|
136962
|
-
EventEmitter$
|
|
136962
|
+
EventEmitter$1.prototype.addListener = function addListener(type, listener) {
|
|
136963
136963
|
return _addListener(this, type, listener, false);
|
|
136964
136964
|
};
|
|
136965
136965
|
|
|
136966
|
-
EventEmitter$
|
|
136966
|
+
EventEmitter$1.prototype.on = EventEmitter$1.prototype.addListener;
|
|
136967
136967
|
|
|
136968
|
-
EventEmitter$
|
|
136968
|
+
EventEmitter$1.prototype.prependListener =
|
|
136969
136969
|
function prependListener(type, listener) {
|
|
136970
136970
|
return _addListener(this, type, listener, true);
|
|
136971
136971
|
};
|
|
@@ -136983,14 +136983,14 @@
|
|
|
136983
136983
|
return g;
|
|
136984
136984
|
}
|
|
136985
136985
|
|
|
136986
|
-
EventEmitter$
|
|
136986
|
+
EventEmitter$1.prototype.once = function once(type, listener) {
|
|
136987
136987
|
if (typeof listener !== 'function')
|
|
136988
136988
|
throw new TypeError('"listener" argument must be a function');
|
|
136989
136989
|
this.on(type, _onceWrap(this, type, listener));
|
|
136990
136990
|
return this;
|
|
136991
136991
|
};
|
|
136992
136992
|
|
|
136993
|
-
EventEmitter$
|
|
136993
|
+
EventEmitter$1.prototype.prependOnceListener =
|
|
136994
136994
|
function prependOnceListener(type, listener) {
|
|
136995
136995
|
if (typeof listener !== 'function')
|
|
136996
136996
|
throw new TypeError('"listener" argument must be a function');
|
|
@@ -136999,7 +136999,7 @@
|
|
|
136999
136999
|
};
|
|
137000
137000
|
|
|
137001
137001
|
// emits a 'removeListener' event iff the listener was removed
|
|
137002
|
-
EventEmitter$
|
|
137002
|
+
EventEmitter$1.prototype.removeListener =
|
|
137003
137003
|
function removeListener(type, listener) {
|
|
137004
137004
|
var list, events, position, i, originalListener;
|
|
137005
137005
|
|
|
@@ -137058,11 +137058,11 @@
|
|
|
137058
137058
|
|
|
137059
137059
|
// Alias for removeListener added in NodeJS 10.0
|
|
137060
137060
|
// https://nodejs.org/api/events.html#events_emitter_off_eventname_listener
|
|
137061
|
-
EventEmitter$
|
|
137061
|
+
EventEmitter$1.prototype.off = function(type, listener){
|
|
137062
137062
|
return this.removeListener(type, listener);
|
|
137063
137063
|
};
|
|
137064
137064
|
|
|
137065
|
-
EventEmitter$
|
|
137065
|
+
EventEmitter$1.prototype.removeAllListeners =
|
|
137066
137066
|
function removeAllListeners(type) {
|
|
137067
137067
|
var listeners, events;
|
|
137068
137068
|
|
|
@@ -137112,7 +137112,7 @@
|
|
|
137112
137112
|
return this;
|
|
137113
137113
|
};
|
|
137114
137114
|
|
|
137115
|
-
EventEmitter$
|
|
137115
|
+
EventEmitter$1.prototype.listeners = function listeners(type) {
|
|
137116
137116
|
var evlistener;
|
|
137117
137117
|
var ret;
|
|
137118
137118
|
var events = this._events;
|
|
@@ -137132,7 +137132,7 @@
|
|
|
137132
137132
|
return ret;
|
|
137133
137133
|
};
|
|
137134
137134
|
|
|
137135
|
-
EventEmitter$
|
|
137135
|
+
EventEmitter$1.listenerCount = function(emitter, type) {
|
|
137136
137136
|
if (typeof emitter.listenerCount === 'function') {
|
|
137137
137137
|
return emitter.listenerCount(type);
|
|
137138
137138
|
} else {
|
|
@@ -137140,7 +137140,7 @@
|
|
|
137140
137140
|
}
|
|
137141
137141
|
};
|
|
137142
137142
|
|
|
137143
|
-
EventEmitter$
|
|
137143
|
+
EventEmitter$1.prototype.listenerCount = listenerCount;
|
|
137144
137144
|
function listenerCount(type) {
|
|
137145
137145
|
var events = this._events;
|
|
137146
137146
|
|
|
@@ -137157,7 +137157,7 @@
|
|
|
137157
137157
|
return 0;
|
|
137158
137158
|
}
|
|
137159
137159
|
|
|
137160
|
-
EventEmitter$
|
|
137160
|
+
EventEmitter$1.prototype.eventNames = function eventNames() {
|
|
137161
137161
|
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
|
137162
137162
|
};
|
|
137163
137163
|
|
|
@@ -137185,8 +137185,8 @@
|
|
|
137185
137185
|
|
|
137186
137186
|
var _polyfillNode_events = /*#__PURE__*/Object.freeze({
|
|
137187
137187
|
__proto__: null,
|
|
137188
|
-
EventEmitter: EventEmitter$
|
|
137189
|
-
default: EventEmitter$
|
|
137188
|
+
EventEmitter: EventEmitter$1,
|
|
137189
|
+
default: EventEmitter$1
|
|
137190
137190
|
});
|
|
137191
137191
|
|
|
137192
137192
|
var chacha20poly1305 = {};
|
|
@@ -137526,7 +137526,7 @@
|
|
|
137526
137526
|
*
|
|
137527
137527
|
* Supports bit lengths divisible by 8, up to 48.
|
|
137528
137528
|
*/
|
|
137529
|
-
function readUintBE
|
|
137529
|
+
function readUintBE(bitLength, array, offset) {
|
|
137530
137530
|
if (offset === void 0) { offset = 0; }
|
|
137531
137531
|
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
137532
137532
|
if (bitLength % 8 !== 0) {
|
|
@@ -137543,14 +137543,14 @@
|
|
|
137543
137543
|
}
|
|
137544
137544
|
return result;
|
|
137545
137545
|
}
|
|
137546
|
-
binary$1.readUintBE = readUintBE
|
|
137546
|
+
binary$1.readUintBE = readUintBE;
|
|
137547
137547
|
/**
|
|
137548
137548
|
* Reads bytes from array starting at offset as little-endian
|
|
137549
137549
|
* unsigned bitLen-bit integer and returns it.
|
|
137550
137550
|
*
|
|
137551
137551
|
* Supports bit lengths divisible by 8, up to 48.
|
|
137552
137552
|
*/
|
|
137553
|
-
function readUintLE
|
|
137553
|
+
function readUintLE(bitLength, array, offset) {
|
|
137554
137554
|
if (offset === void 0) { offset = 0; }
|
|
137555
137555
|
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
137556
137556
|
if (bitLength % 8 !== 0) {
|
|
@@ -137567,7 +137567,7 @@
|
|
|
137567
137567
|
}
|
|
137568
137568
|
return result;
|
|
137569
137569
|
}
|
|
137570
|
-
binary$1.readUintLE = readUintLE
|
|
137570
|
+
binary$1.readUintLE = readUintLE;
|
|
137571
137571
|
/**
|
|
137572
137572
|
* Writes a big-endian representation of bitLen-bit unsigned
|
|
137573
137573
|
* value to array starting at offset.
|
|
@@ -137578,7 +137578,7 @@
|
|
|
137578
137578
|
*
|
|
137579
137579
|
* Returns the output byte array.
|
|
137580
137580
|
*/
|
|
137581
|
-
function writeUintBE
|
|
137581
|
+
function writeUintBE(bitLength, value, out, offset) {
|
|
137582
137582
|
if (out === void 0) { out = new Uint8Array(bitLength / 8); }
|
|
137583
137583
|
if (offset === void 0) { offset = 0; }
|
|
137584
137584
|
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
@@ -137595,7 +137595,7 @@
|
|
|
137595
137595
|
}
|
|
137596
137596
|
return out;
|
|
137597
137597
|
}
|
|
137598
|
-
binary$1.writeUintBE = writeUintBE
|
|
137598
|
+
binary$1.writeUintBE = writeUintBE;
|
|
137599
137599
|
/**
|
|
137600
137600
|
* Writes a little-endian representation of bitLen-bit unsigned
|
|
137601
137601
|
* value to array starting at offset.
|
|
@@ -137606,7 +137606,7 @@
|
|
|
137606
137606
|
*
|
|
137607
137607
|
* Returns the output byte array.
|
|
137608
137608
|
*/
|
|
137609
|
-
function writeUintLE
|
|
137609
|
+
function writeUintLE(bitLength, value, out, offset) {
|
|
137610
137610
|
if (out === void 0) { out = new Uint8Array(bitLength / 8); }
|
|
137611
137611
|
if (offset === void 0) { offset = 0; }
|
|
137612
137612
|
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
@@ -137623,7 +137623,7 @@
|
|
|
137623
137623
|
}
|
|
137624
137624
|
return out;
|
|
137625
137625
|
}
|
|
137626
|
-
binary$1.writeUintLE = writeUintLE
|
|
137626
|
+
binary$1.writeUintLE = writeUintLE;
|
|
137627
137627
|
/**
|
|
137628
137628
|
* Reads 4 bytes from array starting at offset as big-endian
|
|
137629
137629
|
* 32-bit floating-point number and returns it.
|
|
@@ -145012,7 +145012,7 @@
|
|
|
145012
145012
|
class JsonRpcProvider extends IJsonRpcProvider {
|
|
145013
145013
|
constructor(connection) {
|
|
145014
145014
|
super(connection);
|
|
145015
|
-
this.events = new EventEmitter$
|
|
145015
|
+
this.events = new EventEmitter$1();
|
|
145016
145016
|
this.hasRegisteredEventListeners = false;
|
|
145017
145017
|
this.connection = this.setConnection(connection);
|
|
145018
145018
|
if (this.connection.connected) {
|
|
@@ -145115,7 +145115,7 @@
|
|
|
145115
145115
|
}
|
|
145116
145116
|
}
|
|
145117
145117
|
|
|
145118
|
-
const w$3=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),b$2=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",a$4=c=>c.split("?")[0],h$5=10,S$5=w$3();let f$8 = class f{constructor(e){if(this.url=e,this.events=new EventEmitter$
|
|
145118
|
+
const w$3=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),b$2=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",a$4=c=>c.split("?")[0],h$5=10,S$5=w$3();let f$8 = class f{constructor(e){if(this.url=e,this.events=new EventEmitter$1,this.registering=!1,!isWsUrl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e;}get connected(){return typeof this.socket<"u"}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(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),e();},this.socket.close();})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(safeJsonStringify(e));}catch(t){this.onError(e.id,t);}}register(e=this.url){if(!isWsUrl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return (this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((n,o)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),o(s);}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return o(new Error("WebSocket connection is missing or invalid"));n(this.socket);});})}return this.url=e,this.registering=!0,new Promise((t,n)=>{const o=new URLSearchParams(e).get("origin"),s=cjs.isReactNative()?{headers:{origin:o}}:{rejectUnauthorized:!isLocalhostUrl(e)},i=new S$5(e,[],s);b$2()?i.onerror=r=>{const l=r;n(this.emitError(l.error));}:i.on("error",r=>{n(this.emitError(r));}),i.onopen=()=>{this.onOpen(i),t(i);};})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open");}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e);}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?safeJsonParse(e.data):e.data;this.events.emit("payload",t);}onError(e,t){const n=this.parseError(t),o=n.message||n.toString(),s=formatJsonRpcError(e,o);this.events.emit("payload",s);}parseError(e,t=this.url){return parseConnectionError(e,a$4(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>h$5&&this.events.setMaxListeners(h$5);}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${a$4(this.url)}`));return this.events.emit("register_error",t),t}};
|
|
145119
145119
|
|
|
145120
145120
|
var lodash_isequal$1 = {exports: {}};
|
|
145121
145121
|
|
|
@@ -146987,9 +146987,9 @@
|
|
|
146987
146987
|
|
|
146988
146988
|
var Yi$1 = /*@__PURE__*/getDefaultExportFromCjs$3(browser$2);
|
|
146989
146989
|
|
|
146990
|
-
function Hi$1(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var s=0;s<n.length;s++){var r=n.charAt(s),o=r.charCodeAt(0);if(t[o]!==255)throw new TypeError(r+" is ambiguous");t[o]=s;}var a=n.length,h=n.charAt(0),l=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function p(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var m=0,z=0,I=0,_=u.length;I!==_&&u[I]===0;)I++,m++;for(var T=(_-I)*d+1>>>0,f=new Uint8Array(T);I!==_;){for(var S=u[I],A=0,C=T-1;(S!==0||A<z)&&C!==-1;C--,A++)S+=256*f[C]>>>0,f[C]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");z=A,I++;}for(var x=T-z;x!==T&&f[x]===0;)x++;for(var j=h.repeat(m);x<T;++x)j+=n.charAt(f[x]);return j}function y(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var m=0;if(u[m]!==" "){for(var z=0,I=0;u[m]===h;)z++,m++;for(var _=(u.length-m)*l+1>>>0,T=new Uint8Array(_);u[m];){var f=t[u.charCodeAt(m)];if(f===255)return;for(var S=0,A=_-1;(f!==0||S<I)&&A!==-1;A--,S++)f+=a*T[A]>>>0,T[A]=f%256>>>0,f=f/256>>>0;if(f!==0)throw new Error("Non-zero carry");I=S,m++;}if(u[m]!==" "){for(var C=_-I;C!==_&&T[C]===0;)C++;for(var x=new Uint8Array(z+(_-C)),j=z;C!==_;)x[j++]=T[C++];return x}}}function M(u){var m=y(u);if(m)return m;throw new Error(`Non-${e} character`)}return {encode:p,decodeUnsafe:y,decode:M}}var Ji$1=Hi$1,Xi$1=Ji$1;const Ne$2=n=>{if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")},Wi$2=n=>new TextEncoder().encode(n),Qi$1=n=>new TextDecoder().decode(n);let Zi$1 = class Zi{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i;}encode(e){if(e instanceof Uint8Array)return `${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};class es{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i;}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ue$3(this,e)}}class ts{constructor(e){this.decoders=e;}or(e){return Ue$3(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Ue$3=(n,e)=>new ts({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class is{constructor(e,t,i,s){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=s,this.encoder=new Zi$1(e,t,i),this.decoder=new es(e,t,s);}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const W$2=({name:n,prefix:e,encode:t,decode:i})=>new is(n,e,t,i),B$4=({prefix:n,name:e,alphabet:t})=>{const{encode:i,decode:s}=Xi$1(t,e);return W$2({prefix:n,name:e,encode:i,decode:r=>Ne$2(s(r))})},ss=(n,e,t,i)=>{const s={};for(let d=0;d<e.length;++d)s[e[d]]=d;let r=n.length;for(;n[r-1]==="=";)--r;const o=new Uint8Array(r*t/8|0);let a=0,h=0,l=0;for(let d=0;d<r;++d){const p=s[n[d]];if(p===void 0)throw new SyntaxError(`Non-${i} character`);h=h<<t|p,a+=t,a>=8&&(a-=8,o[l++]=255&h>>a);}if(a>=t||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o},rs=(n,e,t)=>{const i=e[e.length-1]==="=",s=(1<<t)-1;let r="",o=0,a=0;for(let h=0;h<n.length;++h)for(a=a<<8|n[h],o+=8;o>t;)o-=t,r+=e[s&a>>o];if(o&&(r+=e[s&a<<t-o]),i)for(;r.length*t&7;)r+="=";return r},g$6=({name:n,prefix:e,bitsPerChar:t,alphabet:i})=>W$2({prefix:e,name:n,encode(s){return rs(s,i,t)},decode(s){return ss(s,i,t,n)}}),ns=W$2({prefix:"\0",name:"identity",encode:n=>Qi$1(n),decode:n=>Wi$2(n)});var os=Object.freeze({__proto__:null,identity:ns});const as$1=g$6({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hs$1=Object.freeze({__proto__:null,base2:as$1});const cs$1=g$6({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var us$1=Object.freeze({__proto__:null,base8:cs$1});const ls$1=B$4({prefix:"9",name:"base10",alphabet:"0123456789"});var ds$1=Object.freeze({__proto__:null,base10:ls$1});const gs$1=g$6({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ps$1=g$6({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ds=Object.freeze({__proto__:null,base16:gs$1,base16upper:ps$1});const ys=g$6({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ms=g$6({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bs=g$6({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fs=g$6({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Es=g$6({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ws$1=g$6({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vs=g$6({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Is=g$6({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cs=g$6({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rs=Object.freeze({__proto__:null,base32:ys,base32upper:ms,base32pad:bs,base32padupper:fs,base32hex:Es,base32hexupper:ws$1,base32hexpad:vs,base32hexpadupper:Is,base32z:Cs});const _s=B$4({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ts=B$4({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ss=Object.freeze({__proto__:null,base36:_s,base36upper:Ts});const Ps=B$4({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xs$1=B$4({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Os=Object.freeze({__proto__:null,base58btc:Ps,base58flickr:xs$1});const As=g$6({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zs=g$6({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ns=g$6({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Us=g$6({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ls=Object.freeze({__proto__:null,base64:As,base64pad:zs,base64url:Ns,base64urlpad:Us});const Le$3=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),$s=Le$3.reduce((n,e,t)=>(n[t]=e,n),[]),Fs=Le$3.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]);function Ms(n){return n.reduce((e,t)=>(e+=$s[t],e),"")}function ks(n){const e=[];for(const t of n){const i=Fs[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i);}return new Uint8Array(e)}const Ks=W$2({prefix:"\u{1F680}",name:"base256emoji",encode:Ms,decode:ks});var Bs=Object.freeze({__proto__:null,base256emoji:Ks}),Vs=Fe$3,$e$3=128,qs=127,js=~qs,Gs=Math.pow(2,31);function Fe$3(n,e,t){e=e||[],t=t||0;for(var i=t;n>=Gs;)e[t++]=n&255|$e$3,n/=128;for(;n&js;)e[t++]=n&255|$e$3,n>>>=7;return e[t]=n|0,Fe$3.bytes=t-i+1,e}var Ys=he$4,Hs=128,Me$2=127;function he$4(n,i){var t=0,i=i||0,s=0,r=i,o,a=n.length;do{if(r>=a)throw he$4.bytes=0,new RangeError("Could not decode varint");o=n[r++],t+=s<28?(o&Me$2)<<s:(o&Me$2)*Math.pow(2,s),s+=7;}while(o>=Hs);return he$4.bytes=r-i,t}var Js=Math.pow(2,7),Xs=Math.pow(2,14),Ws=Math.pow(2,21),Qs=Math.pow(2,28),Zs=Math.pow(2,35),er$1=Math.pow(2,42),tr$1=Math.pow(2,49),ir$2=Math.pow(2,56),sr$2=Math.pow(2,63),rr$1=function(n){return n<Js?1:n<Xs?2:n<Ws?3:n<Qs?4:n<Zs?5:n<er$1?6:n<tr$1?7:n<ir$2?8:n<sr$2?9:10},nr$2={encode:Vs,decode:Ys,encodingLength:rr$1},ke$3=nr$2;const Ke$2=(n,e,t=0)=>(ke$3.encode(n,e,t),e),Be$2=n=>ke$3.encodingLength(n),ce$4=(n,e)=>{const t=e.byteLength,i=Be$2(n),s=i+Be$2(t),r=new Uint8Array(s+t);return Ke$2(n,r,0),Ke$2(t,r,i),r.set(e,s),new or$1(n,t,e,r)};let or$1 = class or{constructor(e,t,i,s){this.code=e,this.size=t,this.digest=i,this.bytes=s;}};const Ve$2=({name:n,code:e,encode:t})=>new ar$1(n,e,t);let ar$1 = class ar{constructor(e,t,i){this.name=e,this.code=t,this.encode=i;}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ce$4(this.code,t):t.then(i=>ce$4(this.code,i))}else throw Error("Unknown type, must be binary type")}};const qe$3=n=>async e=>new Uint8Array(await crypto.subtle.digest(n,e)),hr$3=Ve$2({name:"sha2-256",code:18,encode:qe$3("SHA-256")}),cr$3=Ve$2({name:"sha2-512",code:19,encode:qe$3("SHA-512")});var ur$1=Object.freeze({__proto__:null,sha256:hr$3,sha512:cr$3});const je$3=0,lr$1="identity",Ge$3=Ne$2,dr$2=n=>ce$4(je$3,Ge$3(n)),gr$1={code:je$3,name:lr$1,encode:Ge$3,digest:dr$2};var pr$1=Object.freeze({__proto__:null,identity:gr$1});new TextEncoder,new TextDecoder;const Ye$3={...os,...hs$1,...us$1,...ds$1,...Ds,...Rs,...Ss,...Os,...Ls,...Bs};({...ur$1,...pr$1});function He$2(n){return globalThis.Buffer!=null?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n}function Dr$1(n=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?He$2(globalThis.Buffer.allocUnsafe(n)):new Uint8Array(n)}function Je$1(n,e,t,i){return {name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:i}}}const Xe$2=Je$1("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),ue$4=Je$1("ascii","a",n=>{let e="a";for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return e},n=>{n=n.substring(1);const e=Dr$1(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e}),yr$1={utf8:Xe$2,"utf-8":Xe$2,hex:Ye$3.base16,latin1:ue$4,ascii:ue$4,binary:ue$4,...Ye$3};function mr$1(n,e="utf8"){const t=yr$1[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?He$2(globalThis.Buffer.from(n,"utf-8")):t.decoder.decode(`${t.prefix}${n}`)}const le$4="wc",We$3=2,Q$5="core",O$2=`${le$4}@2:${Q$5}:`,Qe$2={name:Q$5,logger:"error"},Ze$1={database:":memory:"},et$1="crypto",de$4="client_ed25519_seed",tt$1=cjs$5.ONE_DAY,it$1="keychain",st$1="0.3",rt$1="messages",nt$1="0.3",ot$1=cjs$5.SIX_HOURS,at$1="publisher",ht="irn",ct$1="error",ge$4="wss://relay.walletconnect.com",pe$3="wss://relay.walletconnect.org",ut$1="relayer",D$5={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},lt$1="_subscription",P$3={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},dt$1=cjs$5.ONE_SECOND,gt="2.11.1",pt$1=1e4,Dt$1="0.3",yt$1="WALLETCONNECT_CLIENT_ID",w$2={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},mt="subscription",bt$1="0.3",ft$1=cjs$5.FIVE_SECONDS*1e3,Et$1="pairing",wt$1="0.3",$$2={wc_pairingDelete:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:0},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:0}}},V$3={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},R$4={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},vt="history",It$1="0.3",Ct$1="expirer",v$6={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Rt$1="0.3",Z$4="verify-api",F$4="https://verify.walletconnect.com",ee$3="https://verify.walletconnect.org",_t$1=[F$4,ee$3],Tt$1="echo",St$1="https://echo.walletconnect.com";let Pt$1 = class Pt{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=it$1,this.version=st$1,this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0;}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist();},this.get=i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:r}=N$4("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(r)}return s},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist();},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,rt$2(e));}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ot$2(e):void 0}async persist(){await this.setKeyChain(this.keychain);}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};class xt{constructor(e,t,i){this.core=e,this.logger=t,this.name=et$1,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0);},this.hasKeys=s=>(this.isInitialized(),this.keychain.has(s)),this.getClientId=async()=>{this.isInitialized();const s=await this.getClientSeed(),r=generateKeyPair(s);return encodeIss(r.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const s=kn();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();const r=await this.getClientSeed(),o=generateKeyPair(r),a=Vn$1(),h=tt$1;return await signJWT(a,s,h,o)},this.generateSharedKey=(s,r,o)=>{this.isInitialized();const a=this.getPrivateKey(s),h=Mn(a,r);return this.setSymKey(h,o)},this.setSymKey=async(s,r)=>{this.isInitialized();const o=r||Kn(s);return await this.keychain.set(o,s),o},this.deleteKeyPair=async s=>{this.isInitialized(),await this.keychain.del(s);},this.deleteSymKey=async s=>{this.isInitialized(),await this.keychain.del(s);},this.encode=async(s,r,o)=>{this.isInitialized();const a=Ae$3(o),h=safeJsonStringify(r);if(qn(a)){const y=a.senderPublicKey,M=a.receiverPublicKey;s=await this.generateSharedKey(y,M);}const l=this.getSymKey(s),{type:d,senderPublicKey:p}=a;return xn({type:d,symKey:l,message:h,senderPublicKey:p})},this.decode=async(s,r,o)=>{this.isInitialized();const a=Hn(r,o);if(qn(a)){const h=a.receiverPublicKey,l=a.senderPublicKey;s=await this.generateSharedKey(h,l);}try{const h=this.getSymKey(s),l=Fn({symKey:h,encoded:r});return safeJsonParse(l)}catch(h){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(h);}},this.getPayloadType=s=>{const r=ee$4(s);return j$3(r.type)},this.getPayloadSenderPublicKey=s=>{const r=ee$4(s);return r.senderPublicKey?toString$3(r.senderPublicKey,p$9):void 0},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.keychain=i||new Pt$1(this.core,this.logger);}get context(){return cjs$1.getLoggerContext(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(de$4);}catch{e=Vn$1(),await this.keychain.set(de$4,e);}return mr$1(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}}let Ot$1 = class Ot extends a$5{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=rt$1,this.version=nt$1,this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size});}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i);}finally{this.initialized=!0;}}},this.set=async(i,s)=>{this.isInitialized();const r=Ln(s);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[r]<"u"||(o[r]=s,this.messages.set(i,o),await this.persist()),r},this.get=i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s},this.has=(i,s)=>{this.isInitialized();const r=this.get(i),o=Ln(s);return typeof r[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist();},this.logger=cjs$1.generateChildLogger(e,this.name),this.core=t;}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,rt$2(e));}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ot$2(e):void 0}async persist(){await this.setRelayerMessages(this.messages);}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let vr$1 = class vr extends u$4{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new EventEmitter$2,this.name=at$1,this.queue=new Map,this.publishTimeout=cjs$5.toMiliseconds(cjs$5.TEN_SECONDS*2),this.needsTransportRestart=!1,this.publish=async(i,s,r)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:r}});try{const a=r?.ttl||ot$1,h=vt$1(r),l=r?.prompt||!1,d=r?.tag||0,p=r?.id||getBigIntRpcId().toString(),y={topic:i,message:s,opts:{ttl:a,relay:h,prompt:l,tag:d,id:p}},M=setTimeout(()=>this.queue.set(p,y),this.publishTimeout);try{await await ut$2(this.rpcPublish(i,s,a,h,l,d,p),this.publishTimeout,`Failed to publish payload, please try again. id:${p} tag:${d}`),this.removeRequestFromQueue(p),this.relayer.events.emit(D$5.publish,y);}catch(u){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(o=r?.internal)!=null&&o.throwOnFailedPublish)throw this.removeRequestFromQueue(p),u;return}finally{clearTimeout(M);}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:r}});}catch(a){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(a),a}},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.relayer=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.registerEventListeners();}get context(){return cjs$1.getLoggerContext(this.logger)}rpcPublish(e,t,i,s,r,o,a){var h,l,d,p;const y={method:Et$2(s.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:r,tag:o},id:a};return w$5((h=y.params)==null?void 0:h.prompt)&&((l=y.params)==null||delete l.prompt),w$5((d=y.params)==null?void 0:d.tag)&&((p=y.params)==null||delete p.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:y}),this.relayer.request(y)}removeRequestFromQueue(e){this.queue.delete(e);}checkQueue(){this.queue.forEach(async e=>{const{topic:t,message:i,opts:s}=e;await this.publish(t,i,s);});}registerEventListeners(){this.relayer.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(D$5.connection_stalled);return}this.checkQueue();}),this.relayer.on(D$5.message_ack,e=>{this.removeRequestFromQueue(e.id.toString());});}};class Ir{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t]);},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const s=i.filter(r=>r!==t);if(!s.length){this.map.delete(e);return}this.map.set(e,s);},this.clear=()=>{this.map.clear();};}get topics(){return Array.from(this.map.keys())}}var Cr$1=Object.defineProperty,Rr=Object.defineProperties,_r=Object.getOwnPropertyDescriptors,At$1=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,zt$1=(n,e,t)=>e in n?Cr$1(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,q$5=(n,e)=>{for(var t in e||(e={}))Tr.call(e,t)&&zt$1(n,t,e[t]);if(At$1)for(var t of At$1(e))Sr.call(e,t)&&zt$1(n,t,e[t]);return n},De$3=(n,e)=>Rr(n,_r(e));let Nt$1 = class Nt extends d$5{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Ir,this.events=new EventEmitter$2,this.name=mt,this.version=bt$1,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=O$2,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId());},this.subscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const r=vt$1(s),o={topic:i,relay:r};this.pending.set(i,o);const a=await this.rpcSubscribe(i,r);return this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}}),a}catch(r){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(r),r}},this.unsubscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s);},this.isSubscribed=async i=>{if(this.topics.includes(i))return !0;const s=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((r,o)=>{const a=new cjs$5.Watch;a.start(s);const h=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(h),a.stop(s),r(!0)),a.elapsed(s)>=ft$1&&(clearInterval(h),a.stop(s),o(new Error("Subscription resolution timeout")));},this.pollingInterval);}).catch(()=>!1)},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1;},this.relayer=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.clientId="";}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}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}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t;}catch{}return i}onEnable(){this.cached=[],this.initialized=!0;}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear();}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async s=>await this.unsubscribeById(e,s,t)));}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const s=vt$1(i);await this.rpcUnsubscribe(e,t,s);const r=U$5("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,t){const i={method:Et$2(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await ut$2(this.relayer.request(i),this.subscribeTimeout);}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(D$5.connection_stalled);}return Ln(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:Et$2(t.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await ut$2(this.relayer.request(i),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(D$5.connection_stalled);}}rpcUnsubscribe(e,t,i){const s={method:Et$2(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,De$3(q$5({},t),{id:e})),this.pending.delete(t.topic);}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,q$5({},t)),this.pending.delete(t.topic);});}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e);}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e);}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t));}addSubscription(e,t){this.subscriptions.set(e,q$5({},t)),this.topicMap.set(t.topic,e),this.events.emit(w$2.created,t);}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(w$2.deleted,De$3(q$5({},i),{reason:t}));}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(w$2.sync);}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i);}}this.events.emit(w$2.resubscribed);}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values});}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e);}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);k$4(t)&&this.onBatchSubscribe(t.map((i,s)=>De$3(q$5({},e[s]),{id:i})));}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable());}onDisconnect(){this.onDisable();}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach(t=>{e.push(t);}),await this.batchSubscribe(e);}registerEventListeners(){this.relayer.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending();}),this.relayer.on(D$5.connect,async()=>{await this.onConnect();}),this.relayer.on(D$5.disconnect,()=>{this.onDisconnect();}),this.events.on(w$2.created,async e=>{const t=w$2.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist();}),this.events.on(w$2.deleted,async e=>{const t=w$2.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e());},this.pollingInterval);});}};var Pr$1=Object.defineProperty,Ut$1=Object.getOwnPropertySymbols,xr$1=Object.prototype.hasOwnProperty,Or$1=Object.prototype.propertyIsEnumerable,Lt$1=(n,e,t)=>e in n?Pr$1(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ar$1=(n,e)=>{for(var t in e||(e={}))xr$1.call(e,t)&&Lt$1(n,t,e[t]);if(Ut$1)for(var t of Ut$1(e))Or$1.call(e,t)&&Lt$1(n,t,e[t]);return n};let $t$1 = class $t extends g$7{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new EventEmitter$2,this.name=ut$1,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.request=async t=>{this.logger.debug("Publishing Request Payload");const i=t.id,s=this.provider.request(t);this.requestsInFlight.set(i,{promise:s,request:t});try{return await this.toEstablishConnection(),await s}catch(r){throw this.logger.debug("Failed to Publish Request"),this.logger.error(r),r}finally{this.requestsInFlight.delete(i);}},this.onPayloadHandler=t=>{this.onProviderPayload(t);},this.onConnectHandler=()=>{this.events.emit(D$5.connect);},this.onDisconnectHandler=()=>{this.onProviderDisconnect();},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(D$5.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose();},this.registerProviderListeners=()=>{this.provider.on(P$3.payload,this.onPayloadHandler),this.provider.on(P$3.connect,this.onConnectHandler),this.provider.on(P$3.disconnect,this.onDisconnectHandler),this.provider.on(P$3.error,this.onProviderErrorHandler);},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?cjs$1.generateChildLogger(e.logger,this.name):cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:e.logger||ct$1})),this.messages=new Ot$1(this.logger,e.core),this.subscriber=new Nt$1(this,this.logger),this.publisher=new vr$1(this,this.logger),this.relayUrl=e?.relayUrl||ge$4,this.projectId=e.projectId,this.bundleId=Jn(),this.provider={};}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen();}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$3}...`),await this.restartTransport(pe$3);}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1);},pt$1);}get context(){return cjs$1.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()});}async subscribe(e,t){var i;this.isInitialized();let s=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"";if(s)return s;let r;const o=a=>{a.topic===e&&(this.subscriber.off(w$2.created,o),r());};return await Promise.all([new Promise(a=>{r=a,this.subscriber.on(w$2.created,o);}),new Promise(async a=>{s=await this.subscriber.subscribe(e,t),a();})]),s}async unsubscribe(e,t){this.isInitialized(),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 transportClose(){this.requestsInFlight.size>0&&(this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."),this.requestsInFlight.forEach(async e=>{await e.promise;})),this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await ut$2(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect();}async transportOpen(e){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(t=>{if(!this.initialized)return t();this.subscriber.once(w$2.resubscribed,()=>{t();});}),new Promise(async(t,i)=>{try{await ut$2(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`);}catch(s){i(s);return}t();})]);}catch(t){this.logger.error(t);const i=t;if(!this.isConnectionStalled(i.message))throw t;this.provider.events.emit(P$3.disconnect);}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1;}}}async restartTransport(e){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen());}async confirmOnlineStateOrThrow(){if(!await rr$2())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new JsonRpcProvider(new f$8(Xn({sdkVersion:gt,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners();}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i);}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const s=this.messages.has(t,i);return s&&this.logger.debug(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),isJsonRpcRequest(e)){if(!e.method.endsWith(lt$1))return;const t=e.params,{topic:i,message:s,publishedAt:r}=t.data,o={topic:i,message:s,publishedAt:r};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Ar$1({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o);}else isJsonRpcResponse(e)&&this.events.emit(D$5.message_ack,e);}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(D$5.message,e),await this.recordMessageEvent(e));}async acknowledgePayload(e){const t=formatJsonRpcResult(e.id,!0);await this.provider.connection.send(t);}unregisterProviderListeners(){this.provider.off(P$3.payload,this.onPayloadHandler),this.provider.off(P$3.connect,this.onConnectHandler),this.provider.off(P$3.disconnect,this.onDisconnectHandler),this.provider.off(P$3.error,this.onProviderErrorHandler);}async registerEventListeners(){this.events.on(D$5.connection_stalled,()=>{this.restartTransport().catch(t=>this.logger.error(t));});let e=await rr$2();or$2(async t=>{this.initialized&&e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(i=>this.logger.error(i))));});}onProviderDisconnect(){this.events.emit(D$5.disconnect),this.attemptToReconnect();}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(e=>this.logger.error(e));},cjs$5.toMiliseconds(dt$1)));}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(e=>{const t=setInterval(()=>{this.connected&&(clearInterval(t),e());},this.connectionStatusPollingInterval);});await this.restartTransport();}}};var zr=Object.defineProperty,Ft=Object.getOwnPropertySymbols,Nr$1=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,Mt$1=(n,e,t)=>e in n?zr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,kt=(n,e)=>{for(var t in e||(e={}))Nr$1.call(e,t)&&Mt$1(n,t,e[t]);if(Ft)for(var t of Ft(e))Ur.call(e,t)&&Mt$1(n,t,e[t]);return n};let Kt$1 = class Kt extends p$8{constructor(e,t,i,s=O$2,r=void 0){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=Dt$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!w$5(o)?this.map.set(this.getKey(o),o):Lt$2(o)?this.map.set(o.id,o):xt$1(o)&&this.map.set(o.topic,o);}),this.cached=[],this.initialized=!0);},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist());},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(h=>Gi$1(a[h],o[h]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const h=kt(kt({},this.getData(o)),a);this.map.set(o,h),await this.persist();},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),await this.persist());},this.logger=cjs$1.generateChildLogger(t,this.name),this.storagePrefix=s,this.getKey=r;}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e);}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values);}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values});}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e);}}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let Bt$1 = class Bt{constructor(e,t){this.core=e,this.logger=t,this.name=Et$1,this.version=wt$1,this.events=new EventEmitter$2,this.initialized=!1,this.storagePrefix=O$2,this.ignoredPayloadTypes=[_$4],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"));},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])];},this.create=async()=>{this.isInitialized();const i=Vn$1(),s=await this.core.crypto.setSymKey(i),r=pt$2(cjs$5.FIVE_MINUTES),o={protocol:ht},a={topic:s,expiry:r,relay:o,active:!1},h=Rt$2({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:i,relay:o,expiryTimestamp:r});return await this.pairings.set(s,a),await this.core.relayer.subscribe(s),this.core.expirer.set(s,r),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized(),this.isValidPair(i);const{topic:s,symKey:r,relay:o,expiryTimestamp:a}=Pt$2(i.uri);let h;if(this.pairings.keys.includes(s)&&(h=this.pairings.get(s),h.active))throw new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);const l=a||pt$2(cjs$5.FIVE_MINUTES),d={topic:s,relay:o,expiry:l,active:!1};return await this.pairings.set(s,d),this.core.expirer.set(s,l),i.activatePairing&&await this.activate({topic:s}),this.events.emit(V$3.create,d),this.core.crypto.keychain.has(s)||(await this.core.crypto.setSymKey(r,s),await this.core.relayer.subscribe(s,{relay:o})),d},this.activate=async({topic:i})=>{this.isInitialized();const s=pt$2(cjs$5.THIRTY_DAYS);await this.pairings.update(i,{active:!0,expiry:s}),this.core.expirer.set(i,s);},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:s}=i;if(this.pairings.keys.includes(s)){const r=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:h}=at$2();this.events.once(yt$2("pairing_ping",r),({error:l})=>{l?h(l):a();}),await o();}},this.updateExpiry=async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s});},this.updateMetadata=async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s});},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",U$5("USER_DISCONNECTED")),await this.deletePairing(s));},this.sendRequest=async(i,s,r)=>{const o=formatJsonRpcRequest(s,r),a=await this.core.crypto.encode(i,o),h=$$2[s].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,h),o.id},this.sendResult=async(i,s,r)=>{const o=formatJsonRpcResult(i,r),a=await this.core.crypto.encode(s,o),h=await this.core.history.get(s,i),l=$$2[h.request.method].res;await this.core.relayer.publish(s,a,l),await this.core.history.resolve(o);},this.sendError=async(i,s,r)=>{const o=formatJsonRpcError(i,r),a=await this.core.crypto.encode(s,o),h=await this.core.history.get(s,i),l=$$2[h.request.method]?$$2[h.request.method].res:$$2.unregistered_method.res;await this.core.relayer.publish(s,a,l),await this.core.history.resolve(o);},this.deletePairing=async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,U$5("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)]);},this.cleanup=async()=>{const i=this.pairings.getAll().filter(s=>mt$1(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)));},this.onRelayEventRequest=i=>{const{topic:s,payload:r}=i;switch(r.method){case"wc_pairingPing":return this.onPairingPingRequest(s,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,r);default:return this.onUnknownRpcMethodRequest(s,r)}},this.onRelayEventResponse=async i=>{const{topic:s,payload:r}=i,o=(await this.core.history.get(s,r.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(s,r);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,s)=>{const{id:r}=s;try{this.isValidPing({topic:i}),await this.sendResult(r,i,!0),this.events.emit(V$3.ping,{id:r,topic:i});}catch(o){await this.sendError(r,i,o),this.logger.error(o);}},this.onPairingPingResponse=(i,s)=>{const{id:r}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(yt$2("pairing_ping",r),{}):isJsonRpcError(s)&&this.events.emit(yt$2("pairing_ping",r),{error:s.error});},500);},this.onPairingDeleteRequest=async(i,s)=>{const{id:r}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(V$3.delete,{id:r,topic:i});}catch(o){await this.sendError(r,i,o),this.logger.error(o);}},this.onUnknownRpcMethodRequest=async(i,s)=>{const{id:r,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=U$5("WC_METHOD_UNSUPPORTED",o);await this.sendError(r,i,a),this.logger.error(a);}catch(a){await this.sendError(r,i,a),this.logger.error(a);}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(U$5("WC_METHOD_UNSUPPORTED",i));},this.isValidPair=i=>{var s;if(!Gt$2(i)){const{message:o}=N$4("MISSING_OR_INVALID",`pair() params: ${i}`);throw new Error(o)}if(!Kt$2(i.uri)){const{message:o}=N$4("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw new Error(o)}const r=Pt$2(i.uri);if(!((s=r?.relay)!=null&&s.protocol)){const{message:o}=N$4("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(o)}if(!(r!=null&&r.symKey)){const{message:o}=N$4("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(o)}if(r!=null&&r.expiryTimestamp&&cjs$5.toMiliseconds(r?.expiryTimestamp)<Date.now()){const{message:o}=N$4("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(o)}},this.isValidPing=async i=>{if(!Gt$2(i)){const{message:r}=N$4("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(r)}const{topic:s}=i;await this.isValidPairingTopic(s);},this.isValidDisconnect=async i=>{if(!Gt$2(i)){const{message:r}=N$4("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(r)}const{topic:s}=i;await this.isValidPairingTopic(s);},this.isValidPairingTopic=async i=>{if(!g$8(i,!1)){const{message:s}=N$4("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=N$4("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(mt$1(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=N$4("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.pairings=new Kt$1(this.core,this.logger,this.name,this.storagePrefix);}get context(){return cjs$1.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(D$5.message,async e=>{const{topic:t,message:i}=e;if(!this.pairings.keys.includes(t)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{isJsonRpcRequest(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):isJsonRpcResponse(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id));}catch(r){this.logger.error(r);}});}registerExpirerEvents(){this.core.expirer.on(v$6.expired,async e=>{const{topic:t}=ft$2(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(V$3.expire,{topic:t}));});}};class Vt extends h$6{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new EventEmitter$2,this.name=vt,this.version=It$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0);},this.set=(i,s,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:r}),this.records.has(s.id))return;const o={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:r,expiry:pt$2(cjs$5.THIRTY_DAYS)};this.records.set(o.id,o),this.events.emit(R$4.created,o);},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=isJsonRpcError(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.events.emit(R$4.updated,s));},this.get=async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s)),this.delete=(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(r=>{if(r.topic===i){if(typeof s<"u"&&r.id!==s)return;this.records.delete(r.id),this.events.emit(R$4.deleted,r);}});},this.exists=async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:!1),this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}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(typeof t.response<"u")return;const i={topic:t.topic,request:formatJsonRpcRequest(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e);}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(R$4.sync);}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values});}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e);}}registerEventListeners(){this.events.on(R$4.created,e=>{const t=R$4.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.events.on(R$4.updated,e=>{const t=R$4.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.events.on(R$4.deleted,e=>{const t=R$4.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup();});}cleanup(){try{this.records.forEach(e=>{cjs$5.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id));});}catch(e){this.logger.warn(e);}}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}}let qt$1 = class qt extends E$3{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new EventEmitter$2,this.name=Ct$1,this.version=Rt$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0);},this.has=i=>{try{const s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return !1}},this.set=(i,s)=>{this.isInitialized();const r=this.formatTarget(i),o={target:r,expiry:s};this.expirations.set(r,o),this.checkExpiry(r,o),this.events.emit(v$6.created,{target:r,expiration:o});},this.get=i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)},this.del=i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),r=this.getExpiration(s);this.expirations.delete(s),this.events.emit(v$6.deleted,{target:s,expiration:r});}},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return lt$2(e);if(typeof e=="number")return dt$2(e);const{message:t}=N$4("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e);}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(v$6.sync);}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values});}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e);}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;cjs$5.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t);}expire(e,t){this.expirations.delete(e),this.events.emit(v$6.expired,{target:e,expiration:t});}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e));}registerEventListeners(){this.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(v$6.created,e=>{const t=v$6.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(v$6.expired,e=>{const t=v$6.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(v$6.deleted,e=>{const t=v$6.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let jt$1 = class jt extends y$5{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=Z$4,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async i=>{if(this.verifyDisabled||$$3()||!D$7())return;const s=this.getVerifyUrl(i?.verifyUrl);this.verifyUrl!==s&&this.removeIframe(),this.verifyUrl=s;try{await this.createIframe();}catch(r){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(r);}if(!this.initialized){this.removeIframe(),this.verifyUrl=ee$3;try{await this.createIframe();}catch(r){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(r),this.verifyDisabled=!0;}}},this.register=async i=>{this.initialized?this.sendPost(i.attestationId):(this.addToQueue(i.attestationId),await this.init());},this.resolve=async i=>{if(this.isDevEnv)return "";const s=this.getVerifyUrl(i?.verifyUrl);let r;try{r=await this.fetchAttestation(i.attestationId,s);}catch(o){this.logger.info(`failed to resolve attestation: ${i.attestationId} from url: ${s}`),this.logger.info(o),r=await this.fetchAttestation(i.attestationId,ee$3);}return r},this.fetchAttestation=async(i,s)=>{this.logger.info(`resolving attestation: ${i} from url: ${s}`);const r=this.startAbortTimer(cjs$5.ONE_SECOND*2),o=await fetch(`${s}/attestation/${i}`,{signal:this.abortController.signal});return clearTimeout(r),o.status===200?await o.json():void 0},this.addToQueue=i=>{this.queue.push(i);},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(i=>this.sendPost(i)),this.queue=[]);},this.sendPost=i=>{var s;try{if(!this.iframe)return;(s=this.iframe.contentWindow)==null||s.postMessage(i,"*"),this.logger.info(`postMessage sent: ${i} ${this.verifyUrl}`);}catch{}},this.createIframe=async()=>{let i;const s=r=>{r.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",s),i());};await Promise.race([new Promise(r=>{if(document.getElementById(Z$4))return r();window.addEventListener("message",s);const o=document.createElement("iframe");o.id=Z$4,o.src=`${this.verifyUrl}/${this.projectId}`,o.style.display="none",document.body.append(o),this.iframe=o,i=r;}),new Promise((r,o)=>setTimeout(()=>{window.removeEventListener("message",s),o("verify iframe load timeout");},cjs$5.toMiliseconds(cjs$5.FIVE_SECONDS)))]);},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1);},this.getVerifyUrl=i=>{let s=i||F$4;return _t$1.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${F$4}`),s=F$4),s},this.logger=cjs$1.generateChildLogger(t,this.name),this.verifyUrl=F$4,this.abortController=new AbortController,this.isDevEnv=te$4()&&process.env.IS_VITEST;}get context(){return cjs$1.getLoggerContext(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),cjs$5.toMiliseconds(e))}};let Gt$1 = class Gt extends v$7{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=Tt$1,this.registerDeviceToken=async i=>{const{clientId:s,token:r,notificationType:o,enableEncrypted:a=!1}=i,h=`${St$1}/${this.projectId}/clients`;await Yi$1(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:r,always_raw:a})});},this.logger=cjs$1.generateChildLogger(t,this.context);}};var Lr=Object.defineProperty,Yt$1=Object.getOwnPropertySymbols,$r=Object.prototype.hasOwnProperty,Fr=Object.prototype.propertyIsEnumerable,Ht$1=(n,e,t)=>e in n?Lr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Jt$1=(n,e)=>{for(var t in e||(e={}))$r.call(e,t)&&Ht$1(n,t,e[t]);if(Yt$1)for(var t of Yt$1(e))Fr.call(e,t)&&Ht$1(n,t,e[t]);return n};let te$3 = class te extends n$a{constructor(e){super(e),this.protocol=le$4,this.version=We$3,this.name=Q$5,this.events=new EventEmitter$2,this.initialized=!1,this.on=(i,s)=>this.events.on(i,s),this.once=(i,s)=>this.events.once(i,s),this.off=(i,s)=>this.events.off(i,s),this.removeListener=(i,s)=>this.events.removeListener(i,s),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||ge$4,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:e?.logger||Qe$2.logger}));this.logger=cjs$1.generateChildLogger(t,this.name),this.heartbeat=new cjs$2.HeartBeat,this.crypto=new xt(this,this.logger,e?.keychain),this.history=new Vt(this,this.logger),this.expirer=new qt$1(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new h$7(Jt$1(Jt$1({},Ze$1),e?.storageOptions)),this.relayer=new $t$1({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Bt$1(this,this.logger),this.verify=new jt$1(this.projectId||"",this.logger),this.echoClient=new Gt$1(this.projectId||"",this.logger);}static async init(e){const t=new te(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(yt$1,i),t}get context(){return cjs$1.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize();}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success");}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}};const Mr$1=te$3;
|
|
146990
|
+
function Hi$1(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var s=0;s<n.length;s++){var r=n.charAt(s),o=r.charCodeAt(0);if(t[o]!==255)throw new TypeError(r+" is ambiguous");t[o]=s;}var a=n.length,h=n.charAt(0),l=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function p(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var m=0,z=0,I=0,_=u.length;I!==_&&u[I]===0;)I++,m++;for(var T=(_-I)*d+1>>>0,f=new Uint8Array(T);I!==_;){for(var S=u[I],A=0,C=T-1;(S!==0||A<z)&&C!==-1;C--,A++)S+=256*f[C]>>>0,f[C]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");z=A,I++;}for(var x=T-z;x!==T&&f[x]===0;)x++;for(var j=h.repeat(m);x<T;++x)j+=n.charAt(f[x]);return j}function y(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var m=0;if(u[m]!==" "){for(var z=0,I=0;u[m]===h;)z++,m++;for(var _=(u.length-m)*l+1>>>0,T=new Uint8Array(_);u[m];){var f=t[u.charCodeAt(m)];if(f===255)return;for(var S=0,A=_-1;(f!==0||S<I)&&A!==-1;A--,S++)f+=a*T[A]>>>0,T[A]=f%256>>>0,f=f/256>>>0;if(f!==0)throw new Error("Non-zero carry");I=S,m++;}if(u[m]!==" "){for(var C=_-I;C!==_&&T[C]===0;)C++;for(var x=new Uint8Array(z+(_-C)),j=z;C!==_;)x[j++]=T[C++];return x}}}function M(u){var m=y(u);if(m)return m;throw new Error(`Non-${e} character`)}return {encode:p,decodeUnsafe:y,decode:M}}var Ji$1=Hi$1,Xi$1=Ji$1;const Ne$2=n=>{if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")},Wi$2=n=>new TextEncoder().encode(n),Qi$1=n=>new TextDecoder().decode(n);let Zi$1 = class Zi{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i;}encode(e){if(e instanceof Uint8Array)return `${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};class es{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i;}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ue$3(this,e)}}class ts{constructor(e){this.decoders=e;}or(e){return Ue$3(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Ue$3=(n,e)=>new ts({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class is{constructor(e,t,i,s){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=s,this.encoder=new Zi$1(e,t,i),this.decoder=new es(e,t,s);}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const W$2=({name:n,prefix:e,encode:t,decode:i})=>new is(n,e,t,i),B$4=({prefix:n,name:e,alphabet:t})=>{const{encode:i,decode:s}=Xi$1(t,e);return W$2({prefix:n,name:e,encode:i,decode:r=>Ne$2(s(r))})},ss=(n,e,t,i)=>{const s={};for(let d=0;d<e.length;++d)s[e[d]]=d;let r=n.length;for(;n[r-1]==="=";)--r;const o=new Uint8Array(r*t/8|0);let a=0,h=0,l=0;for(let d=0;d<r;++d){const p=s[n[d]];if(p===void 0)throw new SyntaxError(`Non-${i} character`);h=h<<t|p,a+=t,a>=8&&(a-=8,o[l++]=255&h>>a);}if(a>=t||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o},rs=(n,e,t)=>{const i=e[e.length-1]==="=",s=(1<<t)-1;let r="",o=0,a=0;for(let h=0;h<n.length;++h)for(a=a<<8|n[h],o+=8;o>t;)o-=t,r+=e[s&a>>o];if(o&&(r+=e[s&a<<t-o]),i)for(;r.length*t&7;)r+="=";return r},g$6=({name:n,prefix:e,bitsPerChar:t,alphabet:i})=>W$2({prefix:e,name:n,encode(s){return rs(s,i,t)},decode(s){return ss(s,i,t,n)}}),ns=W$2({prefix:"\0",name:"identity",encode:n=>Qi$1(n),decode:n=>Wi$2(n)});var os=Object.freeze({__proto__:null,identity:ns});const as$1=g$6({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hs$1=Object.freeze({__proto__:null,base2:as$1});const cs$1=g$6({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var us$1=Object.freeze({__proto__:null,base8:cs$1});const ls$1=B$4({prefix:"9",name:"base10",alphabet:"0123456789"});var ds$1=Object.freeze({__proto__:null,base10:ls$1});const gs$1=g$6({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ps$1=g$6({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ds=Object.freeze({__proto__:null,base16:gs$1,base16upper:ps$1});const ys=g$6({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ms=g$6({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bs=g$6({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fs=g$6({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Es=g$6({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ws$1=g$6({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vs=g$6({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Is=g$6({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cs=g$6({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rs=Object.freeze({__proto__:null,base32:ys,base32upper:ms,base32pad:bs,base32padupper:fs,base32hex:Es,base32hexupper:ws$1,base32hexpad:vs,base32hexpadupper:Is,base32z:Cs});const _s=B$4({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ts=B$4({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ss=Object.freeze({__proto__:null,base36:_s,base36upper:Ts});const Ps=B$4({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xs$1=B$4({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Os=Object.freeze({__proto__:null,base58btc:Ps,base58flickr:xs$1});const As=g$6({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zs=g$6({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ns=g$6({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Us=g$6({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ls=Object.freeze({__proto__:null,base64:As,base64pad:zs,base64url:Ns,base64urlpad:Us});const Le$3=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),$s=Le$3.reduce((n,e,t)=>(n[t]=e,n),[]),Fs=Le$3.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]);function Ms(n){return n.reduce((e,t)=>(e+=$s[t],e),"")}function ks(n){const e=[];for(const t of n){const i=Fs[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i);}return new Uint8Array(e)}const Ks=W$2({prefix:"\u{1F680}",name:"base256emoji",encode:Ms,decode:ks});var Bs=Object.freeze({__proto__:null,base256emoji:Ks}),Vs=Fe$3,$e$3=128,qs=127,js=~qs,Gs=Math.pow(2,31);function Fe$3(n,e,t){e=e||[],t=t||0;for(var i=t;n>=Gs;)e[t++]=n&255|$e$3,n/=128;for(;n&js;)e[t++]=n&255|$e$3,n>>>=7;return e[t]=n|0,Fe$3.bytes=t-i+1,e}var Ys=he$4,Hs=128,Me$2=127;function he$4(n,i){var t=0,i=i||0,s=0,r=i,o,a=n.length;do{if(r>=a)throw he$4.bytes=0,new RangeError("Could not decode varint");o=n[r++],t+=s<28?(o&Me$2)<<s:(o&Me$2)*Math.pow(2,s),s+=7;}while(o>=Hs);return he$4.bytes=r-i,t}var Js=Math.pow(2,7),Xs=Math.pow(2,14),Ws=Math.pow(2,21),Qs=Math.pow(2,28),Zs=Math.pow(2,35),er$1=Math.pow(2,42),tr$1=Math.pow(2,49),ir$2=Math.pow(2,56),sr$2=Math.pow(2,63),rr$1=function(n){return n<Js?1:n<Xs?2:n<Ws?3:n<Qs?4:n<Zs?5:n<er$1?6:n<tr$1?7:n<ir$2?8:n<sr$2?9:10},nr$2={encode:Vs,decode:Ys,encodingLength:rr$1},ke$3=nr$2;const Ke$2=(n,e,t=0)=>(ke$3.encode(n,e,t),e),Be$2=n=>ke$3.encodingLength(n),ce$4=(n,e)=>{const t=e.byteLength,i=Be$2(n),s=i+Be$2(t),r=new Uint8Array(s+t);return Ke$2(n,r,0),Ke$2(t,r,i),r.set(e,s),new or$1(n,t,e,r)};let or$1 = class or{constructor(e,t,i,s){this.code=e,this.size=t,this.digest=i,this.bytes=s;}};const Ve$2=({name:n,code:e,encode:t})=>new ar$1(n,e,t);let ar$1 = class ar{constructor(e,t,i){this.name=e,this.code=t,this.encode=i;}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ce$4(this.code,t):t.then(i=>ce$4(this.code,i))}else throw Error("Unknown type, must be binary type")}};const qe$3=n=>async e=>new Uint8Array(await crypto.subtle.digest(n,e)),hr$3=Ve$2({name:"sha2-256",code:18,encode:qe$3("SHA-256")}),cr$3=Ve$2({name:"sha2-512",code:19,encode:qe$3("SHA-512")});var ur$1=Object.freeze({__proto__:null,sha256:hr$3,sha512:cr$3});const je$3=0,lr$1="identity",Ge$3=Ne$2,dr$2=n=>ce$4(je$3,Ge$3(n)),gr$1={code:je$3,name:lr$1,encode:Ge$3,digest:dr$2};var pr$1=Object.freeze({__proto__:null,identity:gr$1});new TextEncoder,new TextDecoder;const Ye$3={...os,...hs$1,...us$1,...ds$1,...Ds,...Rs,...Ss,...Os,...Ls,...Bs};({...ur$1,...pr$1});function He$2(n){return globalThis.Buffer!=null?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n}function Dr$1(n=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?He$2(globalThis.Buffer.allocUnsafe(n)):new Uint8Array(n)}function Je$1(n,e,t,i){return {name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:i}}}const Xe$2=Je$1("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),ue$4=Je$1("ascii","a",n=>{let e="a";for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return e},n=>{n=n.substring(1);const e=Dr$1(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e}),yr$1={utf8:Xe$2,"utf-8":Xe$2,hex:Ye$3.base16,latin1:ue$4,ascii:ue$4,binary:ue$4,...Ye$3};function mr$1(n,e="utf8"){const t=yr$1[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?He$2(globalThis.Buffer.from(n,"utf-8")):t.decoder.decode(`${t.prefix}${n}`)}const le$4="wc",We$3=2,Q$5="core",O$2=`${le$4}@2:${Q$5}:`,Qe$2={name:Q$5,logger:"error"},Ze$1={database:":memory:"},et$1="crypto",de$4="client_ed25519_seed",tt$1=cjs$5.ONE_DAY,it$1="keychain",st$1="0.3",rt$1="messages",nt$1="0.3",ot$1=cjs$5.SIX_HOURS,at$1="publisher",ht="irn",ct$1="error",ge$4="wss://relay.walletconnect.com",pe$3="wss://relay.walletconnect.org",ut$1="relayer",D$5={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},lt$1="_subscription",P$3={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},dt$1=cjs$5.ONE_SECOND,gt="2.11.1",pt$1=1e4,Dt$1="0.3",yt$1="WALLETCONNECT_CLIENT_ID",w$2={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},mt="subscription",bt$1="0.3",ft$1=cjs$5.FIVE_SECONDS*1e3,Et$1="pairing",wt$1="0.3",$$2={wc_pairingDelete:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:0},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:0}}},V$3={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},R$4={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},vt="history",It$1="0.3",Ct$1="expirer",v$6={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Rt$1="0.3",Z$4="verify-api",F$4="https://verify.walletconnect.com",ee$3="https://verify.walletconnect.org",_t$1=[F$4,ee$3],Tt$1="echo",St$1="https://echo.walletconnect.com";let Pt$1 = class Pt{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=it$1,this.version=st$1,this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0;}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist();},this.get=i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:r}=N$4("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(r)}return s},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist();},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,rt$2(e));}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ot$2(e):void 0}async persist(){await this.setKeyChain(this.keychain);}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};class xt{constructor(e,t,i){this.core=e,this.logger=t,this.name=et$1,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0);},this.hasKeys=s=>(this.isInitialized(),this.keychain.has(s)),this.getClientId=async()=>{this.isInitialized();const s=await this.getClientSeed(),r=generateKeyPair(s);return encodeIss(r.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const s=kn();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();const r=await this.getClientSeed(),o=generateKeyPair(r),a=Vn$1(),h=tt$1;return await signJWT(a,s,h,o)},this.generateSharedKey=(s,r,o)=>{this.isInitialized();const a=this.getPrivateKey(s),h=Mn(a,r);return this.setSymKey(h,o)},this.setSymKey=async(s,r)=>{this.isInitialized();const o=r||Kn(s);return await this.keychain.set(o,s),o},this.deleteKeyPair=async s=>{this.isInitialized(),await this.keychain.del(s);},this.deleteSymKey=async s=>{this.isInitialized(),await this.keychain.del(s);},this.encode=async(s,r,o)=>{this.isInitialized();const a=Ae$3(o),h=safeJsonStringify(r);if(qn(a)){const y=a.senderPublicKey,M=a.receiverPublicKey;s=await this.generateSharedKey(y,M);}const l=this.getSymKey(s),{type:d,senderPublicKey:p}=a;return xn({type:d,symKey:l,message:h,senderPublicKey:p})},this.decode=async(s,r,o)=>{this.isInitialized();const a=Hn(r,o);if(qn(a)){const h=a.receiverPublicKey,l=a.senderPublicKey;s=await this.generateSharedKey(h,l);}try{const h=this.getSymKey(s),l=Fn({symKey:h,encoded:r});return safeJsonParse(l)}catch(h){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(h);}},this.getPayloadType=s=>{const r=ee$4(s);return j$3(r.type)},this.getPayloadSenderPublicKey=s=>{const r=ee$4(s);return r.senderPublicKey?toString$3(r.senderPublicKey,p$9):void 0},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.keychain=i||new Pt$1(this.core,this.logger);}get context(){return cjs$1.getLoggerContext(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(de$4);}catch{e=Vn$1(),await this.keychain.set(de$4,e);}return mr$1(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}}let Ot$1 = class Ot extends a$5{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=rt$1,this.version=nt$1,this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size});}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i);}finally{this.initialized=!0;}}},this.set=async(i,s)=>{this.isInitialized();const r=Ln(s);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[r]<"u"||(o[r]=s,this.messages.set(i,o),await this.persist()),r},this.get=i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s},this.has=(i,s)=>{this.isInitialized();const r=this.get(i),o=Ln(s);return typeof r[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist();},this.logger=cjs$1.generateChildLogger(e,this.name),this.core=t;}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,rt$2(e));}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ot$2(e):void 0}async persist(){await this.setRelayerMessages(this.messages);}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let vr$1 = class vr extends u$4{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new EventEmitter$1,this.name=at$1,this.queue=new Map,this.publishTimeout=cjs$5.toMiliseconds(cjs$5.TEN_SECONDS*2),this.needsTransportRestart=!1,this.publish=async(i,s,r)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:r}});try{const a=r?.ttl||ot$1,h=vt$1(r),l=r?.prompt||!1,d=r?.tag||0,p=r?.id||getBigIntRpcId().toString(),y={topic:i,message:s,opts:{ttl:a,relay:h,prompt:l,tag:d,id:p}},M=setTimeout(()=>this.queue.set(p,y),this.publishTimeout);try{await await ut$2(this.rpcPublish(i,s,a,h,l,d,p),this.publishTimeout,`Failed to publish payload, please try again. id:${p} tag:${d}`),this.removeRequestFromQueue(p),this.relayer.events.emit(D$5.publish,y);}catch(u){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(o=r?.internal)!=null&&o.throwOnFailedPublish)throw this.removeRequestFromQueue(p),u;return}finally{clearTimeout(M);}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:r}});}catch(a){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(a),a}},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.relayer=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.registerEventListeners();}get context(){return cjs$1.getLoggerContext(this.logger)}rpcPublish(e,t,i,s,r,o,a){var h,l,d,p;const y={method:Et$2(s.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:r,tag:o},id:a};return w$5((h=y.params)==null?void 0:h.prompt)&&((l=y.params)==null||delete l.prompt),w$5((d=y.params)==null?void 0:d.tag)&&((p=y.params)==null||delete p.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:y}),this.relayer.request(y)}removeRequestFromQueue(e){this.queue.delete(e);}checkQueue(){this.queue.forEach(async e=>{const{topic:t,message:i,opts:s}=e;await this.publish(t,i,s);});}registerEventListeners(){this.relayer.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(D$5.connection_stalled);return}this.checkQueue();}),this.relayer.on(D$5.message_ack,e=>{this.removeRequestFromQueue(e.id.toString());});}};class Ir{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t]);},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const s=i.filter(r=>r!==t);if(!s.length){this.map.delete(e);return}this.map.set(e,s);},this.clear=()=>{this.map.clear();};}get topics(){return Array.from(this.map.keys())}}var Cr$1=Object.defineProperty,Rr=Object.defineProperties,_r=Object.getOwnPropertyDescriptors,At$1=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,zt$1=(n,e,t)=>e in n?Cr$1(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,q$5=(n,e)=>{for(var t in e||(e={}))Tr.call(e,t)&&zt$1(n,t,e[t]);if(At$1)for(var t of At$1(e))Sr.call(e,t)&&zt$1(n,t,e[t]);return n},De$3=(n,e)=>Rr(n,_r(e));let Nt$1 = class Nt extends d$5{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Ir,this.events=new EventEmitter$1,this.name=mt,this.version=bt$1,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=O$2,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId());},this.subscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const r=vt$1(s),o={topic:i,relay:r};this.pending.set(i,o);const a=await this.rpcSubscribe(i,r);return this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}}),a}catch(r){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(r),r}},this.unsubscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s);},this.isSubscribed=async i=>{if(this.topics.includes(i))return !0;const s=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((r,o)=>{const a=new cjs$5.Watch;a.start(s);const h=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(h),a.stop(s),r(!0)),a.elapsed(s)>=ft$1&&(clearInterval(h),a.stop(s),o(new Error("Subscription resolution timeout")));},this.pollingInterval);}).catch(()=>!1)},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1;},this.relayer=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.clientId="";}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}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}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t;}catch{}return i}onEnable(){this.cached=[],this.initialized=!0;}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear();}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async s=>await this.unsubscribeById(e,s,t)));}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const s=vt$1(i);await this.rpcUnsubscribe(e,t,s);const r=U$5("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,t){const i={method:Et$2(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await ut$2(this.relayer.request(i),this.subscribeTimeout);}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(D$5.connection_stalled);}return Ln(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:Et$2(t.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await ut$2(this.relayer.request(i),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(D$5.connection_stalled);}}rpcUnsubscribe(e,t,i){const s={method:Et$2(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,De$3(q$5({},t),{id:e})),this.pending.delete(t.topic);}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,q$5({},t)),this.pending.delete(t.topic);});}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e);}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e);}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t));}addSubscription(e,t){this.subscriptions.set(e,q$5({},t)),this.topicMap.set(t.topic,e),this.events.emit(w$2.created,t);}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(w$2.deleted,De$3(q$5({},i),{reason:t}));}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(w$2.sync);}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i);}}this.events.emit(w$2.resubscribed);}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values});}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e);}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);k$4(t)&&this.onBatchSubscribe(t.map((i,s)=>De$3(q$5({},e[s]),{id:i})));}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable());}onDisconnect(){this.onDisable();}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach(t=>{e.push(t);}),await this.batchSubscribe(e);}registerEventListeners(){this.relayer.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending();}),this.relayer.on(D$5.connect,async()=>{await this.onConnect();}),this.relayer.on(D$5.disconnect,()=>{this.onDisconnect();}),this.events.on(w$2.created,async e=>{const t=w$2.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist();}),this.events.on(w$2.deleted,async e=>{const t=w$2.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e());},this.pollingInterval);});}};var Pr$1=Object.defineProperty,Ut$1=Object.getOwnPropertySymbols,xr$1=Object.prototype.hasOwnProperty,Or$1=Object.prototype.propertyIsEnumerable,Lt$1=(n,e,t)=>e in n?Pr$1(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ar$1=(n,e)=>{for(var t in e||(e={}))xr$1.call(e,t)&&Lt$1(n,t,e[t]);if(Ut$1)for(var t of Ut$1(e))Or$1.call(e,t)&&Lt$1(n,t,e[t]);return n};let $t$1 = class $t extends g$7{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new EventEmitter$1,this.name=ut$1,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.request=async t=>{this.logger.debug("Publishing Request Payload");const i=t.id,s=this.provider.request(t);this.requestsInFlight.set(i,{promise:s,request:t});try{return await this.toEstablishConnection(),await s}catch(r){throw this.logger.debug("Failed to Publish Request"),this.logger.error(r),r}finally{this.requestsInFlight.delete(i);}},this.onPayloadHandler=t=>{this.onProviderPayload(t);},this.onConnectHandler=()=>{this.events.emit(D$5.connect);},this.onDisconnectHandler=()=>{this.onProviderDisconnect();},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(D$5.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose();},this.registerProviderListeners=()=>{this.provider.on(P$3.payload,this.onPayloadHandler),this.provider.on(P$3.connect,this.onConnectHandler),this.provider.on(P$3.disconnect,this.onDisconnectHandler),this.provider.on(P$3.error,this.onProviderErrorHandler);},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?cjs$1.generateChildLogger(e.logger,this.name):cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:e.logger||ct$1})),this.messages=new Ot$1(this.logger,e.core),this.subscriber=new Nt$1(this,this.logger),this.publisher=new vr$1(this,this.logger),this.relayUrl=e?.relayUrl||ge$4,this.projectId=e.projectId,this.bundleId=Jn(),this.provider={};}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen();}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$3}...`),await this.restartTransport(pe$3);}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1);},pt$1);}get context(){return cjs$1.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()});}async subscribe(e,t){var i;this.isInitialized();let s=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"";if(s)return s;let r;const o=a=>{a.topic===e&&(this.subscriber.off(w$2.created,o),r());};return await Promise.all([new Promise(a=>{r=a,this.subscriber.on(w$2.created,o);}),new Promise(async a=>{s=await this.subscriber.subscribe(e,t),a();})]),s}async unsubscribe(e,t){this.isInitialized(),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 transportClose(){this.requestsInFlight.size>0&&(this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."),this.requestsInFlight.forEach(async e=>{await e.promise;})),this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await ut$2(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect();}async transportOpen(e){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(t=>{if(!this.initialized)return t();this.subscriber.once(w$2.resubscribed,()=>{t();});}),new Promise(async(t,i)=>{try{await ut$2(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`);}catch(s){i(s);return}t();})]);}catch(t){this.logger.error(t);const i=t;if(!this.isConnectionStalled(i.message))throw t;this.provider.events.emit(P$3.disconnect);}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1;}}}async restartTransport(e){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen());}async confirmOnlineStateOrThrow(){if(!await rr$2())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new JsonRpcProvider(new f$8(Xn({sdkVersion:gt,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners();}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i);}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const s=this.messages.has(t,i);return s&&this.logger.debug(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),isJsonRpcRequest(e)){if(!e.method.endsWith(lt$1))return;const t=e.params,{topic:i,message:s,publishedAt:r}=t.data,o={topic:i,message:s,publishedAt:r};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Ar$1({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o);}else isJsonRpcResponse(e)&&this.events.emit(D$5.message_ack,e);}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(D$5.message,e),await this.recordMessageEvent(e));}async acknowledgePayload(e){const t=formatJsonRpcResult(e.id,!0);await this.provider.connection.send(t);}unregisterProviderListeners(){this.provider.off(P$3.payload,this.onPayloadHandler),this.provider.off(P$3.connect,this.onConnectHandler),this.provider.off(P$3.disconnect,this.onDisconnectHandler),this.provider.off(P$3.error,this.onProviderErrorHandler);}async registerEventListeners(){this.events.on(D$5.connection_stalled,()=>{this.restartTransport().catch(t=>this.logger.error(t));});let e=await rr$2();or$2(async t=>{this.initialized&&e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(i=>this.logger.error(i))));});}onProviderDisconnect(){this.events.emit(D$5.disconnect),this.attemptToReconnect();}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(e=>this.logger.error(e));},cjs$5.toMiliseconds(dt$1)));}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(e=>{const t=setInterval(()=>{this.connected&&(clearInterval(t),e());},this.connectionStatusPollingInterval);});await this.restartTransport();}}};var zr=Object.defineProperty,Ft=Object.getOwnPropertySymbols,Nr$1=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,Mt$1=(n,e,t)=>e in n?zr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,kt=(n,e)=>{for(var t in e||(e={}))Nr$1.call(e,t)&&Mt$1(n,t,e[t]);if(Ft)for(var t of Ft(e))Ur.call(e,t)&&Mt$1(n,t,e[t]);return n};let Kt$1 = class Kt extends p$8{constructor(e,t,i,s=O$2,r=void 0){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=Dt$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!w$5(o)?this.map.set(this.getKey(o),o):Lt$2(o)?this.map.set(o.id,o):xt$1(o)&&this.map.set(o.topic,o);}),this.cached=[],this.initialized=!0);},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist());},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(h=>Gi$1(a[h],o[h]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const h=kt(kt({},this.getData(o)),a);this.map.set(o,h),await this.persist();},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),await this.persist());},this.logger=cjs$1.generateChildLogger(t,this.name),this.storagePrefix=s,this.getKey=r;}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e);}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values);}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values});}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e);}}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let Bt$1 = class Bt{constructor(e,t){this.core=e,this.logger=t,this.name=Et$1,this.version=wt$1,this.events=new EventEmitter$1,this.initialized=!1,this.storagePrefix=O$2,this.ignoredPayloadTypes=[_$4],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"));},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])];},this.create=async()=>{this.isInitialized();const i=Vn$1(),s=await this.core.crypto.setSymKey(i),r=pt$2(cjs$5.FIVE_MINUTES),o={protocol:ht},a={topic:s,expiry:r,relay:o,active:!1},h=Rt$2({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:i,relay:o,expiryTimestamp:r});return await this.pairings.set(s,a),await this.core.relayer.subscribe(s),this.core.expirer.set(s,r),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized(),this.isValidPair(i);const{topic:s,symKey:r,relay:o,expiryTimestamp:a}=Pt$2(i.uri);let h;if(this.pairings.keys.includes(s)&&(h=this.pairings.get(s),h.active))throw new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);const l=a||pt$2(cjs$5.FIVE_MINUTES),d={topic:s,relay:o,expiry:l,active:!1};return await this.pairings.set(s,d),this.core.expirer.set(s,l),i.activatePairing&&await this.activate({topic:s}),this.events.emit(V$3.create,d),this.core.crypto.keychain.has(s)||(await this.core.crypto.setSymKey(r,s),await this.core.relayer.subscribe(s,{relay:o})),d},this.activate=async({topic:i})=>{this.isInitialized();const s=pt$2(cjs$5.THIRTY_DAYS);await this.pairings.update(i,{active:!0,expiry:s}),this.core.expirer.set(i,s);},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:s}=i;if(this.pairings.keys.includes(s)){const r=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:h}=at$2();this.events.once(yt$2("pairing_ping",r),({error:l})=>{l?h(l):a();}),await o();}},this.updateExpiry=async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s});},this.updateMetadata=async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s});},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",U$5("USER_DISCONNECTED")),await this.deletePairing(s));},this.sendRequest=async(i,s,r)=>{const o=formatJsonRpcRequest(s,r),a=await this.core.crypto.encode(i,o),h=$$2[s].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,h),o.id},this.sendResult=async(i,s,r)=>{const o=formatJsonRpcResult(i,r),a=await this.core.crypto.encode(s,o),h=await this.core.history.get(s,i),l=$$2[h.request.method].res;await this.core.relayer.publish(s,a,l),await this.core.history.resolve(o);},this.sendError=async(i,s,r)=>{const o=formatJsonRpcError(i,r),a=await this.core.crypto.encode(s,o),h=await this.core.history.get(s,i),l=$$2[h.request.method]?$$2[h.request.method].res:$$2.unregistered_method.res;await this.core.relayer.publish(s,a,l),await this.core.history.resolve(o);},this.deletePairing=async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,U$5("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)]);},this.cleanup=async()=>{const i=this.pairings.getAll().filter(s=>mt$1(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)));},this.onRelayEventRequest=i=>{const{topic:s,payload:r}=i;switch(r.method){case"wc_pairingPing":return this.onPairingPingRequest(s,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,r);default:return this.onUnknownRpcMethodRequest(s,r)}},this.onRelayEventResponse=async i=>{const{topic:s,payload:r}=i,o=(await this.core.history.get(s,r.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(s,r);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,s)=>{const{id:r}=s;try{this.isValidPing({topic:i}),await this.sendResult(r,i,!0),this.events.emit(V$3.ping,{id:r,topic:i});}catch(o){await this.sendError(r,i,o),this.logger.error(o);}},this.onPairingPingResponse=(i,s)=>{const{id:r}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(yt$2("pairing_ping",r),{}):isJsonRpcError(s)&&this.events.emit(yt$2("pairing_ping",r),{error:s.error});},500);},this.onPairingDeleteRequest=async(i,s)=>{const{id:r}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(V$3.delete,{id:r,topic:i});}catch(o){await this.sendError(r,i,o),this.logger.error(o);}},this.onUnknownRpcMethodRequest=async(i,s)=>{const{id:r,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=U$5("WC_METHOD_UNSUPPORTED",o);await this.sendError(r,i,a),this.logger.error(a);}catch(a){await this.sendError(r,i,a),this.logger.error(a);}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(U$5("WC_METHOD_UNSUPPORTED",i));},this.isValidPair=i=>{var s;if(!Gt$2(i)){const{message:o}=N$4("MISSING_OR_INVALID",`pair() params: ${i}`);throw new Error(o)}if(!Kt$2(i.uri)){const{message:o}=N$4("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw new Error(o)}const r=Pt$2(i.uri);if(!((s=r?.relay)!=null&&s.protocol)){const{message:o}=N$4("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(o)}if(!(r!=null&&r.symKey)){const{message:o}=N$4("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(o)}if(r!=null&&r.expiryTimestamp&&cjs$5.toMiliseconds(r?.expiryTimestamp)<Date.now()){const{message:o}=N$4("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(o)}},this.isValidPing=async i=>{if(!Gt$2(i)){const{message:r}=N$4("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(r)}const{topic:s}=i;await this.isValidPairingTopic(s);},this.isValidDisconnect=async i=>{if(!Gt$2(i)){const{message:r}=N$4("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(r)}const{topic:s}=i;await this.isValidPairingTopic(s);},this.isValidPairingTopic=async i=>{if(!g$8(i,!1)){const{message:s}=N$4("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=N$4("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(mt$1(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=N$4("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.pairings=new Kt$1(this.core,this.logger,this.name,this.storagePrefix);}get context(){return cjs$1.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(D$5.message,async e=>{const{topic:t,message:i}=e;if(!this.pairings.keys.includes(t)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{isJsonRpcRequest(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):isJsonRpcResponse(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id));}catch(r){this.logger.error(r);}});}registerExpirerEvents(){this.core.expirer.on(v$6.expired,async e=>{const{topic:t}=ft$2(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(V$3.expire,{topic:t}));});}};class Vt extends h$6{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new EventEmitter$1,this.name=vt,this.version=It$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0);},this.set=(i,s,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:r}),this.records.has(s.id))return;const o={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:r,expiry:pt$2(cjs$5.THIRTY_DAYS)};this.records.set(o.id,o),this.events.emit(R$4.created,o);},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=isJsonRpcError(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.events.emit(R$4.updated,s));},this.get=async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s)),this.delete=(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(r=>{if(r.topic===i){if(typeof s<"u"&&r.id!==s)return;this.records.delete(r.id),this.events.emit(R$4.deleted,r);}});},this.exists=async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:!1),this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}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(typeof t.response<"u")return;const i={topic:t.topic,request:formatJsonRpcRequest(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e);}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(R$4.sync);}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values});}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e);}}registerEventListeners(){this.events.on(R$4.created,e=>{const t=R$4.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.events.on(R$4.updated,e=>{const t=R$4.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.events.on(R$4.deleted,e=>{const t=R$4.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup();});}cleanup(){try{this.records.forEach(e=>{cjs$5.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id));});}catch(e){this.logger.warn(e);}}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}}let qt$1 = class qt extends E$3{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new EventEmitter$1,this.name=Ct$1,this.version=Rt$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$2,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0);},this.has=i=>{try{const s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return !1}},this.set=(i,s)=>{this.isInitialized();const r=this.formatTarget(i),o={target:r,expiry:s};this.expirations.set(r,o),this.checkExpiry(r,o),this.events.emit(v$6.created,{target:r,expiration:o});},this.get=i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)},this.del=i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),r=this.getExpiration(s);this.expirations.delete(s),this.events.emit(v$6.deleted,{target:s,expiration:r});}},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return lt$2(e);if(typeof e=="number")return dt$2(e);const{message:t}=N$4("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e);}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(v$6.sync);}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values});}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e);}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;cjs$5.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t);}expire(e,t){this.expirations.delete(e),this.events.emit(v$6.expired,{target:e,expiration:t});}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e));}registerEventListeners(){this.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(v$6.created,e=>{const t=v$6.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(v$6.expired,e=>{const t=v$6.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(v$6.deleted,e=>{const t=v$6.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let jt$1 = class jt extends y$5{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=Z$4,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async i=>{if(this.verifyDisabled||$$3()||!D$7())return;const s=this.getVerifyUrl(i?.verifyUrl);this.verifyUrl!==s&&this.removeIframe(),this.verifyUrl=s;try{await this.createIframe();}catch(r){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(r);}if(!this.initialized){this.removeIframe(),this.verifyUrl=ee$3;try{await this.createIframe();}catch(r){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(r),this.verifyDisabled=!0;}}},this.register=async i=>{this.initialized?this.sendPost(i.attestationId):(this.addToQueue(i.attestationId),await this.init());},this.resolve=async i=>{if(this.isDevEnv)return "";const s=this.getVerifyUrl(i?.verifyUrl);let r;try{r=await this.fetchAttestation(i.attestationId,s);}catch(o){this.logger.info(`failed to resolve attestation: ${i.attestationId} from url: ${s}`),this.logger.info(o),r=await this.fetchAttestation(i.attestationId,ee$3);}return r},this.fetchAttestation=async(i,s)=>{this.logger.info(`resolving attestation: ${i} from url: ${s}`);const r=this.startAbortTimer(cjs$5.ONE_SECOND*2),o=await fetch(`${s}/attestation/${i}`,{signal:this.abortController.signal});return clearTimeout(r),o.status===200?await o.json():void 0},this.addToQueue=i=>{this.queue.push(i);},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(i=>this.sendPost(i)),this.queue=[]);},this.sendPost=i=>{var s;try{if(!this.iframe)return;(s=this.iframe.contentWindow)==null||s.postMessage(i,"*"),this.logger.info(`postMessage sent: ${i} ${this.verifyUrl}`);}catch{}},this.createIframe=async()=>{let i;const s=r=>{r.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",s),i());};await Promise.race([new Promise(r=>{if(document.getElementById(Z$4))return r();window.addEventListener("message",s);const o=document.createElement("iframe");o.id=Z$4,o.src=`${this.verifyUrl}/${this.projectId}`,o.style.display="none",document.body.append(o),this.iframe=o,i=r;}),new Promise((r,o)=>setTimeout(()=>{window.removeEventListener("message",s),o("verify iframe load timeout");},cjs$5.toMiliseconds(cjs$5.FIVE_SECONDS)))]);},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1);},this.getVerifyUrl=i=>{let s=i||F$4;return _t$1.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${F$4}`),s=F$4),s},this.logger=cjs$1.generateChildLogger(t,this.name),this.verifyUrl=F$4,this.abortController=new AbortController,this.isDevEnv=te$4()&&process.env.IS_VITEST;}get context(){return cjs$1.getLoggerContext(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),cjs$5.toMiliseconds(e))}};let Gt$1 = class Gt extends v$7{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=Tt$1,this.registerDeviceToken=async i=>{const{clientId:s,token:r,notificationType:o,enableEncrypted:a=!1}=i,h=`${St$1}/${this.projectId}/clients`;await Yi$1(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:r,always_raw:a})});},this.logger=cjs$1.generateChildLogger(t,this.context);}};var Lr=Object.defineProperty,Yt$1=Object.getOwnPropertySymbols,$r=Object.prototype.hasOwnProperty,Fr=Object.prototype.propertyIsEnumerable,Ht$1=(n,e,t)=>e in n?Lr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Jt$1=(n,e)=>{for(var t in e||(e={}))$r.call(e,t)&&Ht$1(n,t,e[t]);if(Yt$1)for(var t of Yt$1(e))Fr.call(e,t)&&Ht$1(n,t,e[t]);return n};let te$3 = class te extends n$a{constructor(e){super(e),this.protocol=le$4,this.version=We$3,this.name=Q$5,this.events=new EventEmitter$1,this.initialized=!1,this.on=(i,s)=>this.events.on(i,s),this.once=(i,s)=>this.events.once(i,s),this.off=(i,s)=>this.events.off(i,s),this.removeListener=(i,s)=>this.events.removeListener(i,s),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||ge$4,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:e?.logger||Qe$2.logger}));this.logger=cjs$1.generateChildLogger(t,this.name),this.heartbeat=new cjs$2.HeartBeat,this.crypto=new xt(this,this.logger,e?.keychain),this.history=new Vt(this,this.logger),this.expirer=new qt$1(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new h$7(Jt$1(Jt$1({},Ze$1),e?.storageOptions)),this.relayer=new $t$1({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Bt$1(this,this.logger),this.verify=new jt$1(this.projectId||"",this.logger),this.echoClient=new Gt$1(this.projectId||"",this.logger);}static async init(e){const t=new te(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(yt$1,i),t}get context(){return cjs$1.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize();}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success");}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}};const Mr$1=te$3;
|
|
146991
146991
|
|
|
146992
|
-
const J$1="wc",F$3=2,X$2="client",G$3=`${J$1}@${F$3}:${X$2}:`,M$4={name:X$2,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},H$3="WALLETCONNECT_DEEPLINK_CHOICE",oe$3="proposal",ae$3="Proposal expired",ce$3="session",L$5=cjs$5.SEVEN_DAYS,le$3="engine",R$3={wc_sessionPropose:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1104},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1106},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1112},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1115}}},U$4={min:cjs$5.FIVE_MINUTES,max:cjs$5.SEVEN_DAYS},I$3={idle:"IDLE",active:"ACTIVE"},pe$2="request",he$3=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var as=Object.defineProperty,cs=Object.defineProperties,ls=Object.getOwnPropertyDescriptors,de$3=Object.getOwnPropertySymbols,ps=Object.prototype.hasOwnProperty,hs=Object.prototype.propertyIsEnumerable,ue$3=(w,r,e)=>r in w?as(w,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[r]=e,g$5=(w,r)=>{for(var e in r||(r={}))ps.call(r,e)&&ue$3(w,e,r[e]);if(de$3)for(var e of de$3(r))hs.call(r,e)&&ue$3(w,e,r[e]);return w},D$4=(w,r)=>cs(w,ls(r));class ds extends w$4{constructor(r){super(r),this.name=le$3,this.events=new EventEmitter$2,this.initialized=!1,this.ignoredPayloadTypes=[_$4],this.requestQueue={state:I$3.idle,queue:[]},this.sessionRequestQueue={state:I$3.idle,queue:[]},this.requestQueueDelay=cjs$5.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(R$3)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue();},cjs$5.toMiliseconds(this.requestQueueDelay)));},this.connect=async e=>{await this.isInitialized();const s=D$4(g$5({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(s);const{pairingTopic:t,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:o,relays:a}=s;let c=t,p,d=!1;if(c&&(d=this.client.core.pairing.pairings.get(c).active),!c||!d){const{topic:T,uri:_}=await this.client.core.pairing.create();c=T,p=_;}const h=await this.client.core.crypto.generateKeyPair(),N=R$3.wc_sessionPropose.req.ttl||cjs$5.FIVE_MINUTES,m=pt$2(N),f=g$5({requiredNamespaces:i,optionalNamespaces:n,relays:a??[{protocol:ht}],proposer:{publicKey:h,metadata:this.client.metadata},expiryTimestamp:m},o&&{sessionProperties:o}),{reject:k,resolve:O,done:we}=at$2(N,ae$3);if(this.events.once(yt$2("session_connect"),async({error:T,session:_})=>{if(T)k(T);else if(_){_.self.publicKey=h;const B=D$4(g$5({},_),{requiredNamespaces:f.requiredNamespaces,optionalNamespaces:f.optionalNamespaces});await this.client.session.set(_.topic,B),await this.setExpiry(_.topic,_.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:_.peer.metadata}),O(B);}}),!c){const{message:T}=N$4("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(T)}const W=await this.sendRequest({topic:c,method:"wc_sessionPropose",params:f,throwOnFailedPublish:!0});return await this.setProposal(W,g$5({id:W},f)),{uri:p,approval:we}},this.pair=async e=>(await this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{await this.isInitialized(),await this.isValidApprove(e);const{id:s,relayProtocol:t,namespaces:i,sessionProperties:n}=e,o=this.client.proposal.get(s);let{pairingTopic:a,proposer:c,requiredNamespaces:p,optionalNamespaces:d}=o;a=a||"";const h=await this.client.core.crypto.generateKeyPair(),N=c.publicKey,m=await this.client.core.crypto.generateSharedKey(h,N);a&&s&&(await this.client.core.pairing.updateMetadata({topic:a,metadata:c.metadata}),await this.sendResult({id:s,topic:a,result:{relay:{protocol:t??"irn"},responderPublicKey:h}}),await this.client.proposal.delete(s,U$5("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:a}));const f=g$5({relay:{protocol:t??"irn"},namespaces:i,pairingTopic:a,controller:{publicKey:h,metadata:this.client.metadata},expiry:pt$2(L$5)},n&&{sessionProperties:n});await this.client.core.relayer.subscribe(m);const k=D$4(g$5({},f),{topic:m,requiredNamespaces:p,optionalNamespaces:d,pairingTopic:a,acknowledged:!1,self:f.controller,peer:{publicKey:c.publicKey,metadata:c.metadata},controller:h});await this.client.session.set(m,k);try{await this.sendRequest({topic:m,method:"wc_sessionSettle",params:f,throwOnFailedPublish:!0});}catch(O){throw this.client.logger.error(O),this.client.session.delete(m,U$5("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(m),O}return await this.setExpiry(m,pt$2(L$5)),{topic:m,acknowledged:()=>new Promise(O=>setTimeout(()=>O(this.client.session.get(m)),500))}},this.reject=async e=>{await this.isInitialized(),await this.isValidReject(e);const{id:s,reason:t}=e,{pairingTopic:i}=this.client.proposal.get(s);i&&(await this.sendError(s,i,t),await this.client.proposal.delete(s,U$5("USER_DISCONNECTED")));},this.update=async e=>{await this.isInitialized(),await this.isValidUpdate(e);const{topic:s,namespaces:t}=e,i=await this.sendRequest({topic:s,method:"wc_sessionUpdate",params:{namespaces:t}}),{done:n,resolve:o,reject:a}=at$2();return this.events.once(yt$2("session_update",i),({error:c})=>{c?a(c):o();}),await this.client.session.update(s,{namespaces:t}),{acknowledged:n}},this.extend=async e=>{await this.isInitialized(),await this.isValidExtend(e);const{topic:s}=e,t=await this.sendRequest({topic:s,method:"wc_sessionExtend",params:{}}),{done:i,resolve:n,reject:o}=at$2();return this.events.once(yt$2("session_extend",t),({error:a})=>{a?o(a):n();}),await this.setExpiry(s,pt$2(L$5)),{acknowledged:i}},this.request=async e=>{await this.isInitialized(),await this.isValidRequest(e);const{chainId:s,request:t,topic:i,expiry:n=R$3.wc_sessionRequest.req.ttl}=e,o=payloadId(),{done:a,resolve:c,reject:p}=at$2(n,"Request expired. Please try again.");return this.events.once(yt$2("session_request",o),({error:d,result:h})=>{d?p(d):c(h);}),await Promise.all([new Promise(async d=>{await this.sendRequest({clientRpcId:o,topic:i,method:"wc_sessionRequest",params:{request:D$4(g$5({},t),{expiryTimestamp:pt$2(n)}),chainId:s},expiry:n,throwOnFailedPublish:!0}).catch(h=>p(h)),this.client.events.emit("session_request_sent",{topic:i,request:t,chainId:s,id:o}),d();}),new Promise(async d=>{const h=await ht$1(this.client.core.storage,H$3);gt$1({id:o,topic:i,wcDeepLink:h}),d();}),a()]).then(d=>d[2])},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:s,response:t}=e,{id:i}=t;isJsonRpcResult(t)?await this.sendResult({id:i,topic:s,result:t.result,throwOnFailedPublish:!0}):isJsonRpcError(t)&&await this.sendError(i,s,t.error),this.cleanupAfterResponse(e);},this.ping=async e=>{await this.isInitialized(),await this.isValidPing(e);const{topic:s}=e;if(this.client.session.keys.includes(s)){const t=await this.sendRequest({topic:s,method:"wc_sessionPing",params:{}}),{done:i,resolve:n,reject:o}=at$2();this.events.once(yt$2("session_ping",t),({error:a})=>{a?o(a):n();}),await i();}else this.client.core.pairing.pairings.keys.includes(s)&&await this.client.core.pairing.ping({topic:s});},this.emit=async e=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:s,event:t,chainId:i}=e;await this.sendRequest({topic:s,method:"wc_sessionEvent",params:{event:t,chainId:i}});},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:s}=e;if(this.client.session.keys.includes(s))await this.sendRequest({topic:s,method:"wc_sessionDelete",params:U$5("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:s,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(s))await this.client.core.pairing.disconnect({topic:s});else {const{message:t}=N$4("MISMATCHED_TOPIC",`Session or pairing topic not found: ${s}`);throw new Error(t)}},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter(s=>Mt$2(s,e))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const s=this.client.core.pairing.pairings.get(e.pairingTopic),t=this.client.core.pairing.pairings.getAll().filter(i=>{var n,o;return ((n=i.peerMetadata)==null?void 0:n.url)&&((o=i.peerMetadata)==null?void 0:o.url)===e.peer.metadata.url&&i.topic&&i.topic!==s.topic});if(t.length===0)return;this.client.logger.info(`Cleaning up ${t.length} duplicate pairing(s)`),await Promise.all(t.map(i=>this.client.core.pairing.disconnect({topic:i.topic}))),this.client.logger.info("Duplicate pairings clean up finished");}catch(s){this.client.logger.error(s);}},this.deleteSession=async e=>{const{topic:s,expirerHasDeleted:t=!1,emitEvent:i=!0,id:n=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,U$5("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),t||this.client.core.expirer.del(s),this.client.core.storage.removeItem(H$3).catch(a=>this.client.logger.warn(a)),this.getPendingSessionRequests().forEach(a=>{a.topic===s&&this.deletePendingSessionRequest(a.id,U$5("USER_DISCONNECTED"));}),i&&this.client.events.emit("session_delete",{id:n,topic:s});},this.deleteProposal=async(e,s)=>{await Promise.all([this.client.proposal.delete(e,U$5("USER_DISCONNECTED")),s?Promise.resolve():this.client.core.expirer.del(e)]);},this.deletePendingSessionRequest=async(e,s,t=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,s),t?Promise.resolve():this.client.core.expirer.del(e)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(i=>i.id!==e),t&&(this.sessionRequestQueue.state=I$3.idle,this.client.events.emit("session_request_expire",{id:e}));},this.setExpiry=async(e,s)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:s}),this.client.core.expirer.set(e,s);},this.setProposal=async(e,s)=>{await this.client.proposal.set(e,s),this.client.core.expirer.set(e,pt$2(R$3.wc_sessionPropose.req.ttl));},this.setPendingSessionRequest=async e=>{const{id:s,topic:t,params:i,verifyContext:n}=e,o=i.request.expiryTimestamp||pt$2(R$3.wc_sessionRequest.req.ttl);await this.client.pendingRequest.set(s,{id:s,topic:t,params:i,verifyContext:n}),o&&this.client.core.expirer.set(s,o);},this.sendRequest=async e=>{const{topic:s,method:t,params:i,expiry:n,relayRpcId:o,clientRpcId:a,throwOnFailedPublish:c}=e,p=formatJsonRpcRequest(t,i,a);if(D$7()&&he$3.includes(t)){const N=Ln(JSON.stringify(p));this.client.core.verify.register({attestationId:N});}const d=await this.client.core.crypto.encode(s,p),h=R$3[t].req;return n&&(h.ttl=n),o&&(h.id=o),this.client.core.history.set(s,p),c?(h.internal=D$4(g$5({},h.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,d,h)):this.client.core.relayer.publish(s,d,h).catch(N=>this.client.logger.error(N)),p.id},this.sendResult=async e=>{const{id:s,topic:t,result:i,throwOnFailedPublish:n}=e,o=formatJsonRpcResult(s,i),a=await this.client.core.crypto.encode(t,o),c=await this.client.core.history.get(t,s),p=R$3[c.request.method].res;n?(p.internal=D$4(g$5({},p.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,a,p)):this.client.core.relayer.publish(t,a,p).catch(d=>this.client.logger.error(d)),await this.client.core.history.resolve(o);},this.sendError=async(e,s,t)=>{const i=formatJsonRpcError(e,t),n=await this.client.core.crypto.encode(s,i),o=await this.client.core.history.get(s,e),a=R$3[o.request.method].res;this.client.core.relayer.publish(s,n,a),await this.client.core.history.resolve(i);},this.cleanup=async()=>{const e=[],s=[];this.client.session.getAll().forEach(t=>{let i=!1;mt$1(t.expiry)&&(i=!0),this.client.core.crypto.keychain.has(t.topic)||(i=!0),i&&e.push(t.topic);}),this.client.proposal.getAll().forEach(t=>{mt$1(t.expiryTimestamp)&&s.push(t.id);}),await Promise.all([...e.map(t=>this.deleteSession({topic:t})),...s.map(t=>this.deleteProposal(t))]);},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue();},this.processRequestsQueue=async()=>{if(this.requestQueue.state===I$3.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=I$3.active;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise(s=>setTimeout(s,300));}catch(s){this.client.logger.warn(s);}}this.requestQueue.state=I$3.idle;},this.processRequest=e=>{const{topic:s,payload:t}=e,i=t.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeRequest(s,t);case"wc_sessionSettle":return this.onSessionSettleRequest(s,t);case"wc_sessionUpdate":return this.onSessionUpdateRequest(s,t);case"wc_sessionExtend":return this.onSessionExtendRequest(s,t);case"wc_sessionPing":return this.onSessionPingRequest(s,t);case"wc_sessionDelete":return this.onSessionDeleteRequest(s,t);case"wc_sessionRequest":return this.onSessionRequest(s,t);case"wc_sessionEvent":return this.onSessionEventRequest(s,t);default:return this.client.logger.info(`Unsupported request method ${i}`)}},this.onRelayEventResponse=async e=>{const{topic:s,payload:t}=e,i=(await this.client.core.history.get(s,t.id)).request.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeResponse(s,t);case"wc_sessionSettle":return this.onSessionSettleResponse(s,t);case"wc_sessionUpdate":return this.onSessionUpdateResponse(s,t);case"wc_sessionExtend":return this.onSessionExtendResponse(s,t);case"wc_sessionPing":return this.onSessionPingResponse(s,t);case"wc_sessionRequest":return this.onSessionRequestResponse(s,t);default:return this.client.logger.info(`Unsupported response method ${i}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:s}=e,{message:t}=N$4("MISSING_OR_INVALID",`Decoded payload on topic ${s} is not identifiable as a JSON-RPC request or a response.`);throw new Error(t)},this.onSessionProposeRequest=async(e,s)=>{const{params:t,id:i}=s;try{this.isValidConnect(g$5({},s.params));const n=t.expiryTimestamp||pt$2(R$3.wc_sessionPropose.req.ttl),o=g$5({id:i,pairingTopic:e,expiryTimestamp:n},t);await this.setProposal(i,o);const a=Ln(JSON.stringify(s)),c=await this.getVerifyContext(a,o.proposer.metadata);this.client.events.emit("session_proposal",{id:i,params:o,verifyContext:c});}catch(n){await this.sendError(i,e,n),this.client.logger.error(n);}},this.onSessionProposeResponse=async(e,s)=>{const{id:t}=s;if(isJsonRpcResult(s)){const{result:i}=s;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:i});const n=this.client.proposal.get(t);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=i.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:c});const p=await this.client.core.relayer.subscribe(c);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:p}),await this.client.core.pairing.activate({topic:e});}else isJsonRpcError(s)&&(await this.client.proposal.delete(t,U$5("USER_DISCONNECTED")),this.events.emit(yt$2("session_connect"),{error:s.error}));},this.onSessionSettleRequest=async(e,s)=>{const{id:t,params:i}=s;try{this.isValidSessionSettleRequest(i);const{relay:n,controller:o,expiry:a,namespaces:c,sessionProperties:p,pairingTopic:d}=s.params,h=g$5({topic:e,relay:n,expiry:a,namespaces:c,acknowledged:!0,pairingTopic:d,requiredNamespaces:{},optionalNamespaces:{},controller:o.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:o.publicKey,metadata:o.metadata}},p&&{sessionProperties:p});await this.sendResult({id:s.id,topic:e,result:!0}),this.events.emit(yt$2("session_connect"),{session:h}),this.cleanupDuplicatePairings(h);}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.onSessionSettleResponse=async(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(yt$2("session_approve",t),{})):isJsonRpcError(s)&&(await this.client.session.delete(e,U$5("USER_DISCONNECTED")),this.events.emit(yt$2("session_approve",t),{error:s.error}));},this.onSessionUpdateRequest=async(e,s)=>{const{params:t,id:i}=s;try{const n=`${e}_session_update`,o=sr$3.get(n);if(o&&this.isRequestOutOfSync(o,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidUpdate(g$5({topic:e},t)),await this.client.session.update(e,{namespaces:t.namespaces}),await this.sendResult({id:i,topic:e,result:!0}),this.client.events.emit("session_update",{id:i,topic:e,params:t}),sr$3.set(n,i);}catch(n){await this.sendError(i,e,n),this.client.logger.error(n);}},this.isRequestOutOfSync=(e,s)=>parseInt(s.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_update",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_update",t),{error:s.error});},this.onSessionExtendRequest=async(e,s)=>{const{id:t}=s;try{this.isValidExtend({topic:e}),await this.setExpiry(e,pt$2(L$5)),await this.sendResult({id:t,topic:e,result:!0}),this.client.events.emit("session_extend",{id:t,topic:e});}catch(i){await this.sendError(t,e,i),this.client.logger.error(i);}},this.onSessionExtendResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_extend",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_extend",t),{error:s.error});},this.onSessionPingRequest=async(e,s)=>{const{id:t}=s;try{this.isValidPing({topic:e}),await this.sendResult({id:t,topic:e,result:!0}),this.client.events.emit("session_ping",{id:t,topic:e});}catch(i){await this.sendError(t,e,i),this.client.logger.error(i);}},this.onSessionPingResponse=(e,s)=>{const{id:t}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(yt$2("session_ping",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_ping",t),{error:s.error});},500);},this.onSessionDeleteRequest=async(e,s)=>{const{id:t}=s;try{this.isValidDisconnect({topic:e,reason:s.params}),await Promise.all([new Promise(i=>{this.client.core.relayer.once(D$5.publish,async()=>{i(await this.deleteSession({topic:e,id:t}));});}),this.sendResult({id:t,topic:e,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:U$5("USER_DISCONNECTED")})]);}catch(i){this.client.logger.error(i);}},this.onSessionRequest=async(e,s)=>{const{id:t,params:i}=s;try{this.isValidRequest(g$5({topic:e},i));const n=Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest",i,t))),o=this.client.session.get(e),a=await this.getVerifyContext(n,o.peer.metadata),c={id:t,topic:e,params:i,verifyContext:a};await this.setPendingSessionRequest(c),this.addSessionRequestToSessionRequestQueue(c),this.processSessionRequestQueue();}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.onSessionRequestResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_request",t),{result:s.result}):isJsonRpcError(s)&&this.events.emit(yt$2("session_request",t),{error:s.error});},this.onSessionEventRequest=async(e,s)=>{const{id:t,params:i}=s;try{const n=`${e}_session_event_${i.event.name}`,o=sr$3.get(n);if(o&&this.isRequestOutOfSync(o,t)){this.client.logger.info(`Discarding out of sync request - ${t}`);return}this.isValidEmit(g$5({topic:e},i)),this.client.events.emit("session_event",{id:t,topic:e,params:i}),sr$3.set(n,t);}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e);},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=I$3.idle,this.processSessionRequestQueue();},cjs$5.toMiliseconds(this.requestQueueDelay));},this.cleanupPendingSentRequestsForTopic=({topic:e,error:s})=>{const t=this.client.core.history.pending;t.length>0&&t.filter(i=>i.topic===e&&i.request.method==="wc_sessionRequest").forEach(i=>{this.events.emit(yt$2("session_request",i.request.id),{error:s});});},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===I$3.active){this.client.logger.info("session request queue is already active.");return}const e=this.sessionRequestQueue.queue[0];if(!e){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=I$3.active,this.client.events.emit("session_request",e);}catch(s){this.client.logger.error(s);}},this.onPairingCreated=e=>{if(e.active)return;const s=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);s&&this.onSessionProposeRequest(e.topic,formatJsonRpcRequest("wc_sessionPropose",{requiredNamespaces:s.requiredNamespaces,optionalNamespaces:s.optionalNamespaces,relays:s.relays,proposer:s.proposer,sessionProperties:s.sessionProperties},s.id));},this.isValidConnect=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(a)}const{pairingTopic:s,requiredNamespaces:t,optionalNamespaces:i,sessionProperties:n,relays:o}=e;if(w$5(s)||await this.isValidPairingTopic(s),!qt$2(o)){const{message:a}=N$4("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(a)}!w$5(t)&&B$5(t)!==0&&this.validateNamespaces(t,"requiredNamespaces"),!w$5(i)&&B$5(i)!==0&&this.validateNamespaces(i,"optionalNamespaces"),w$5(n)||this.validateSessionProps(n,"sessionProperties");},this.validateNamespaces=(e,s)=>{const t=Ht$2(e,"connect()",s);if(t)throw new Error(t.message)},this.isValidApprove=async e=>{if(!Gt$2(e))throw new Error(N$4("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:s,namespaces:t,relayProtocol:i,sessionProperties:n}=e;await this.isValidProposalId(s);const o=this.client.proposal.get(s),a=ln(t,"approve()");if(a)throw new Error(a.message);const c=fn(o.requiredNamespaces,t,"approve()");if(c)throw new Error(c.message);if(!g$8(i,!0)){const{message:p}=N$4("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(p)}w$5(n)||this.validateSessionProps(n,"sessionProperties");},this.isValidReject=async e=>{if(!Gt$2(e)){const{message:i}=N$4("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(i)}const{id:s,reason:t}=e;if(await this.isValidProposalId(s),!Wt$1(t)){const{message:i}=N$4("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(t)}`);throw new Error(i)}},this.isValidSessionSettleRequest=e=>{if(!Gt$2(e)){const{message:c}=N$4("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(c)}const{relay:s,controller:t,namespaces:i,expiry:n}=e;if(!dn(s)){const{message:c}=N$4("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}const o=Ft$1(t,"onSessionSettleRequest()");if(o)throw new Error(o.message);const a=ln(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);if(mt$1(n)){const{message:c}=N$4("EXPIRED","onSessionSettleRequest()");throw new Error(c)}},this.isValidUpdate=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(a)}const{topic:s,namespaces:t}=e;await this.isValidSessionTopic(s);const i=this.client.session.get(s),n=ln(t,"update()");if(n)throw new Error(n.message);const o=fn(i.requiredNamespaces,t,"update()");if(o)throw new Error(o.message)},this.isValidExtend=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionTopic(s);},this.isValidRequest=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(a)}const{topic:s,request:t,chainId:i,expiry:n}=e;await this.isValidSessionTopic(s);const{namespaces:o}=this.client.session.get(s);if(!Qt$1(o,i)){const{message:a}=N$4("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(a)}if(!zt$2(t)){const{message:a}=N$4("MISSING_OR_INVALID",`request() ${JSON.stringify(t)}`);throw new Error(a)}if(!Zt$1(o,i,t.method)){const{message:a}=N$4("MISSING_OR_INVALID",`request() method: ${t.method}`);throw new Error(a)}if(n&&!tr$2(n,U$4)){const{message:a}=N$4("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${U$4.min} and ${U$4.max}`);throw new Error(a)}},this.isValidRespond=async e=>{var s;if(!Gt$2(e)){const{message:n}=N$4("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(n)}const{topic:t,response:i}=e;try{await this.isValidSessionTopic(t);}catch(n){throw (s=e?.response)!=null&&s.id&&this.cleanupAfterResponse(e),n}if(!Yt$2(i)){const{message:n}=N$4("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(n)}},this.isValidPing=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionOrPairingTopic(s);},this.isValidEmit=async e=>{if(!Gt$2(e)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(o)}const{topic:s,event:t,chainId:i}=e;await this.isValidSessionTopic(s);const{namespaces:n}=this.client.session.get(s);if(!Qt$1(n,i)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(o)}if(!Jt$2(t)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(t)}`);throw new Error(o)}if(!Xt$1(n,i,t.name)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(t)}`);throw new Error(o)}},this.isValidDisconnect=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionOrPairingTopic(s);},this.getVerifyContext=async(e,s)=>{const t={verified:{verifyUrl:s.verifyUrl||F$4,validation:"UNKNOWN",origin:s.url||""}};try{const i=await this.client.core.verify.resolve({attestationId:e,verifyUrl:s.verifyUrl});i&&(t.verified.origin=i.origin,t.verified.isScam=i.isScam,t.verified.validation=i.origin===new URL(s.url).origin?"VALID":"INVALID");}catch(i){this.client.logger.info(i);}return this.client.logger.info(`Verify context: ${JSON.stringify(t)}`),t},this.validateSessionProps=(e,s)=>{Object.values(e).forEach(t=>{if(!g$8(t,!1)){const{message:i}=N$4("MISSING_OR_INVALID",`${s} must be in Record<string, string> format. Received: ${JSON.stringify(t)}`);throw new Error(i)}});};}async isInitialized(){if(!this.initialized){const{message:r}=N$4("NOT_INITIALIZED",this.name);throw new Error(r)}await this.client.core.relayer.confirmOnlineStateOrThrow();}registerRelayerEvents(){this.client.core.relayer.on(D$5.message,async r=>{const{topic:e,message:s}=r;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s)))return;const t=await this.client.core.crypto.decode(e,s);try{isJsonRpcRequest(t)?(this.client.core.history.set(e,t),this.onRelayEventRequest({topic:e,payload:t})):isJsonRpcResponse(t)?(await this.client.core.history.resolve(t),await this.onRelayEventResponse({topic:e,payload:t}),this.client.core.history.delete(e,t.id)):this.onRelayEventUnknownPayload({topic:e,payload:t});}catch(i){this.client.logger.error(i);}});}registerExpirerEvents(){this.client.core.expirer.on(v$6.expired,async r=>{const{topic:e,id:s}=ft$2(r.target);if(s&&this.client.pendingRequest.keys.includes(s))return await this.deletePendingSessionRequest(s,N$4("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession({topic:e,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:e})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s}));});}registerPairingEvents(){this.client.core.pairing.events.on(V$3.create,r=>this.onPairingCreated(r));}isValidPairingTopic(r){if(!g$8(r,!1)){const{message:e}=N$4("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.core.pairing.pairings.get(r).expiry)){const{message:e}=N$4("EXPIRED",`pairing topic: ${r}`);throw new Error(e)}}async isValidSessionTopic(r){if(!g$8(r,!1)){const{message:e}=N$4("MISSING_OR_INVALID",`session topic should be a string: ${r}`);throw new Error(e)}if(!this.client.session.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`session topic doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.session.get(r).expiry)){await this.deleteSession({topic:r});const{message:e}=N$4("EXPIRED",`session topic: ${r}`);throw new Error(e)}if(!this.client.core.crypto.keychain.has(r)){const{message:e}=N$4("MISSING_OR_INVALID",`session topic does not exist in keychain: ${r}`);throw await this.deleteSession({topic:r}),new Error(e)}}async isValidSessionOrPairingTopic(r){if(this.client.session.keys.includes(r))await this.isValidSessionTopic(r);else if(this.client.core.pairing.pairings.keys.includes(r))this.isValidPairingTopic(r);else if(g$8(r,!1)){const{message:e}=N$4("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${r}`);throw new Error(e)}else {const{message:e}=N$4("MISSING_OR_INVALID",`session or pairing topic should be a string: ${r}`);throw new Error(e)}}async isValidProposalId(r){if(!Bt$2(r)){const{message:e}=N$4("MISSING_OR_INVALID",`proposal id should be a number: ${r}`);throw new Error(e)}if(!this.client.proposal.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`proposal id doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.proposal.get(r).expiryTimestamp)){await this.deleteProposal(r);const{message:e}=N$4("EXPIRED",`proposal id: ${r}`);throw new Error(e)}}}class us extends Kt$1{constructor(r,e){super(r,e,oe$3,G$3),this.core=r,this.logger=e;}}let ge$3 = class ge extends Kt$1{constructor(r,e){super(r,e,ce$3,G$3),this.core=r,this.logger=e;}};class gs extends Kt$1{constructor(r,e){super(r,e,pe$2,G$3,s=>s.id),this.core=r,this.logger=e;}}let Q$4 = class Q extends b$3{constructor(r){super(r),this.protocol=J$1,this.version=F$3,this.name=M$4.name,this.events=new EventEmitter$2,this.on=(s,t)=>this.events.on(s,t),this.once=(s,t)=>this.events.once(s,t),this.off=(s,t)=>this.events.off(s,t),this.removeListener=(s,t)=>this.events.removeListener(s,t),this.removeAllListeners=s=>this.events.removeAllListeners(s),this.connect=async s=>{try{return await this.engine.connect(s)}catch(t){throw this.logger.error(t.message),t}},this.pair=async s=>{try{return await this.engine.pair(s)}catch(t){throw this.logger.error(t.message),t}},this.approve=async s=>{try{return await this.engine.approve(s)}catch(t){throw this.logger.error(t.message),t}},this.reject=async s=>{try{return await this.engine.reject(s)}catch(t){throw this.logger.error(t.message),t}},this.update=async s=>{try{return await this.engine.update(s)}catch(t){throw this.logger.error(t.message),t}},this.extend=async s=>{try{return await this.engine.extend(s)}catch(t){throw this.logger.error(t.message),t}},this.request=async s=>{try{return await this.engine.request(s)}catch(t){throw this.logger.error(t.message),t}},this.respond=async s=>{try{return await this.engine.respond(s)}catch(t){throw this.logger.error(t.message),t}},this.ping=async s=>{try{return await this.engine.ping(s)}catch(t){throw this.logger.error(t.message),t}},this.emit=async s=>{try{return await this.engine.emit(s)}catch(t){throw this.logger.error(t.message),t}},this.disconnect=async s=>{try{return await this.engine.disconnect(s)}catch(t){throw this.logger.error(t.message),t}},this.find=s=>{try{return this.engine.find(s)}catch(t){throw this.logger.error(t.message),t}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(s){throw this.logger.error(s.message),s}},this.name=r?.name||M$4.name,this.metadata=r?.metadata||Qn();const e=typeof r?.logger<"u"&&typeof r?.logger!="string"?r.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:r?.logger||M$4.logger}));this.core=r?.core||new Mr$1(r),this.logger=cjs$1.generateChildLogger(e,this.name),this.session=new ge$3(this.core,this.logger),this.proposal=new us(this.core,this.logger),this.pendingRequest=new gs(this.core,this.logger),this.engine=new ds(this);}static async init(r){const e=new Q(r);return await e.initialize(),e}get context(){return cjs$1.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success");}catch(r){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(r.message),r}}};
|
|
146992
|
+
const J$1="wc",F$3=2,X$2="client",G$3=`${J$1}@${F$3}:${X$2}:`,M$4={name:X$2,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},H$3="WALLETCONNECT_DEEPLINK_CHOICE",oe$3="proposal",ae$3="Proposal expired",ce$3="session",L$5=cjs$5.SEVEN_DAYS,le$3="engine",R$3={wc_sessionPropose:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1104},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1106},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1112},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1115}}},U$4={min:cjs$5.FIVE_MINUTES,max:cjs$5.SEVEN_DAYS},I$3={idle:"IDLE",active:"ACTIVE"},pe$2="request",he$3=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var as=Object.defineProperty,cs=Object.defineProperties,ls=Object.getOwnPropertyDescriptors,de$3=Object.getOwnPropertySymbols,ps=Object.prototype.hasOwnProperty,hs=Object.prototype.propertyIsEnumerable,ue$3=(w,r,e)=>r in w?as(w,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[r]=e,g$5=(w,r)=>{for(var e in r||(r={}))ps.call(r,e)&&ue$3(w,e,r[e]);if(de$3)for(var e of de$3(r))hs.call(r,e)&&ue$3(w,e,r[e]);return w},D$4=(w,r)=>cs(w,ls(r));class ds extends w$4{constructor(r){super(r),this.name=le$3,this.events=new EventEmitter$1,this.initialized=!1,this.ignoredPayloadTypes=[_$4],this.requestQueue={state:I$3.idle,queue:[]},this.sessionRequestQueue={state:I$3.idle,queue:[]},this.requestQueueDelay=cjs$5.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(R$3)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue();},cjs$5.toMiliseconds(this.requestQueueDelay)));},this.connect=async e=>{await this.isInitialized();const s=D$4(g$5({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(s);const{pairingTopic:t,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:o,relays:a}=s;let c=t,p,d=!1;if(c&&(d=this.client.core.pairing.pairings.get(c).active),!c||!d){const{topic:T,uri:_}=await this.client.core.pairing.create();c=T,p=_;}const h=await this.client.core.crypto.generateKeyPair(),N=R$3.wc_sessionPropose.req.ttl||cjs$5.FIVE_MINUTES,m=pt$2(N),f=g$5({requiredNamespaces:i,optionalNamespaces:n,relays:a??[{protocol:ht}],proposer:{publicKey:h,metadata:this.client.metadata},expiryTimestamp:m},o&&{sessionProperties:o}),{reject:k,resolve:O,done:we}=at$2(N,ae$3);if(this.events.once(yt$2("session_connect"),async({error:T,session:_})=>{if(T)k(T);else if(_){_.self.publicKey=h;const B=D$4(g$5({},_),{requiredNamespaces:f.requiredNamespaces,optionalNamespaces:f.optionalNamespaces});await this.client.session.set(_.topic,B),await this.setExpiry(_.topic,_.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:_.peer.metadata}),O(B);}}),!c){const{message:T}=N$4("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(T)}const W=await this.sendRequest({topic:c,method:"wc_sessionPropose",params:f,throwOnFailedPublish:!0});return await this.setProposal(W,g$5({id:W},f)),{uri:p,approval:we}},this.pair=async e=>(await this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{await this.isInitialized(),await this.isValidApprove(e);const{id:s,relayProtocol:t,namespaces:i,sessionProperties:n}=e,o=this.client.proposal.get(s);let{pairingTopic:a,proposer:c,requiredNamespaces:p,optionalNamespaces:d}=o;a=a||"";const h=await this.client.core.crypto.generateKeyPair(),N=c.publicKey,m=await this.client.core.crypto.generateSharedKey(h,N);a&&s&&(await this.client.core.pairing.updateMetadata({topic:a,metadata:c.metadata}),await this.sendResult({id:s,topic:a,result:{relay:{protocol:t??"irn"},responderPublicKey:h}}),await this.client.proposal.delete(s,U$5("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:a}));const f=g$5({relay:{protocol:t??"irn"},namespaces:i,pairingTopic:a,controller:{publicKey:h,metadata:this.client.metadata},expiry:pt$2(L$5)},n&&{sessionProperties:n});await this.client.core.relayer.subscribe(m);const k=D$4(g$5({},f),{topic:m,requiredNamespaces:p,optionalNamespaces:d,pairingTopic:a,acknowledged:!1,self:f.controller,peer:{publicKey:c.publicKey,metadata:c.metadata},controller:h});await this.client.session.set(m,k);try{await this.sendRequest({topic:m,method:"wc_sessionSettle",params:f,throwOnFailedPublish:!0});}catch(O){throw this.client.logger.error(O),this.client.session.delete(m,U$5("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(m),O}return await this.setExpiry(m,pt$2(L$5)),{topic:m,acknowledged:()=>new Promise(O=>setTimeout(()=>O(this.client.session.get(m)),500))}},this.reject=async e=>{await this.isInitialized(),await this.isValidReject(e);const{id:s,reason:t}=e,{pairingTopic:i}=this.client.proposal.get(s);i&&(await this.sendError(s,i,t),await this.client.proposal.delete(s,U$5("USER_DISCONNECTED")));},this.update=async e=>{await this.isInitialized(),await this.isValidUpdate(e);const{topic:s,namespaces:t}=e,i=await this.sendRequest({topic:s,method:"wc_sessionUpdate",params:{namespaces:t}}),{done:n,resolve:o,reject:a}=at$2();return this.events.once(yt$2("session_update",i),({error:c})=>{c?a(c):o();}),await this.client.session.update(s,{namespaces:t}),{acknowledged:n}},this.extend=async e=>{await this.isInitialized(),await this.isValidExtend(e);const{topic:s}=e,t=await this.sendRequest({topic:s,method:"wc_sessionExtend",params:{}}),{done:i,resolve:n,reject:o}=at$2();return this.events.once(yt$2("session_extend",t),({error:a})=>{a?o(a):n();}),await this.setExpiry(s,pt$2(L$5)),{acknowledged:i}},this.request=async e=>{await this.isInitialized(),await this.isValidRequest(e);const{chainId:s,request:t,topic:i,expiry:n=R$3.wc_sessionRequest.req.ttl}=e,o=payloadId(),{done:a,resolve:c,reject:p}=at$2(n,"Request expired. Please try again.");return this.events.once(yt$2("session_request",o),({error:d,result:h})=>{d?p(d):c(h);}),await Promise.all([new Promise(async d=>{await this.sendRequest({clientRpcId:o,topic:i,method:"wc_sessionRequest",params:{request:D$4(g$5({},t),{expiryTimestamp:pt$2(n)}),chainId:s},expiry:n,throwOnFailedPublish:!0}).catch(h=>p(h)),this.client.events.emit("session_request_sent",{topic:i,request:t,chainId:s,id:o}),d();}),new Promise(async d=>{const h=await ht$1(this.client.core.storage,H$3);gt$1({id:o,topic:i,wcDeepLink:h}),d();}),a()]).then(d=>d[2])},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:s,response:t}=e,{id:i}=t;isJsonRpcResult(t)?await this.sendResult({id:i,topic:s,result:t.result,throwOnFailedPublish:!0}):isJsonRpcError(t)&&await this.sendError(i,s,t.error),this.cleanupAfterResponse(e);},this.ping=async e=>{await this.isInitialized(),await this.isValidPing(e);const{topic:s}=e;if(this.client.session.keys.includes(s)){const t=await this.sendRequest({topic:s,method:"wc_sessionPing",params:{}}),{done:i,resolve:n,reject:o}=at$2();this.events.once(yt$2("session_ping",t),({error:a})=>{a?o(a):n();}),await i();}else this.client.core.pairing.pairings.keys.includes(s)&&await this.client.core.pairing.ping({topic:s});},this.emit=async e=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:s,event:t,chainId:i}=e;await this.sendRequest({topic:s,method:"wc_sessionEvent",params:{event:t,chainId:i}});},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:s}=e;if(this.client.session.keys.includes(s))await this.sendRequest({topic:s,method:"wc_sessionDelete",params:U$5("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:s,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(s))await this.client.core.pairing.disconnect({topic:s});else {const{message:t}=N$4("MISMATCHED_TOPIC",`Session or pairing topic not found: ${s}`);throw new Error(t)}},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter(s=>Mt$2(s,e))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const s=this.client.core.pairing.pairings.get(e.pairingTopic),t=this.client.core.pairing.pairings.getAll().filter(i=>{var n,o;return ((n=i.peerMetadata)==null?void 0:n.url)&&((o=i.peerMetadata)==null?void 0:o.url)===e.peer.metadata.url&&i.topic&&i.topic!==s.topic});if(t.length===0)return;this.client.logger.info(`Cleaning up ${t.length} duplicate pairing(s)`),await Promise.all(t.map(i=>this.client.core.pairing.disconnect({topic:i.topic}))),this.client.logger.info("Duplicate pairings clean up finished");}catch(s){this.client.logger.error(s);}},this.deleteSession=async e=>{const{topic:s,expirerHasDeleted:t=!1,emitEvent:i=!0,id:n=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,U$5("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),t||this.client.core.expirer.del(s),this.client.core.storage.removeItem(H$3).catch(a=>this.client.logger.warn(a)),this.getPendingSessionRequests().forEach(a=>{a.topic===s&&this.deletePendingSessionRequest(a.id,U$5("USER_DISCONNECTED"));}),i&&this.client.events.emit("session_delete",{id:n,topic:s});},this.deleteProposal=async(e,s)=>{await Promise.all([this.client.proposal.delete(e,U$5("USER_DISCONNECTED")),s?Promise.resolve():this.client.core.expirer.del(e)]);},this.deletePendingSessionRequest=async(e,s,t=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,s),t?Promise.resolve():this.client.core.expirer.del(e)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(i=>i.id!==e),t&&(this.sessionRequestQueue.state=I$3.idle,this.client.events.emit("session_request_expire",{id:e}));},this.setExpiry=async(e,s)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:s}),this.client.core.expirer.set(e,s);},this.setProposal=async(e,s)=>{await this.client.proposal.set(e,s),this.client.core.expirer.set(e,pt$2(R$3.wc_sessionPropose.req.ttl));},this.setPendingSessionRequest=async e=>{const{id:s,topic:t,params:i,verifyContext:n}=e,o=i.request.expiryTimestamp||pt$2(R$3.wc_sessionRequest.req.ttl);await this.client.pendingRequest.set(s,{id:s,topic:t,params:i,verifyContext:n}),o&&this.client.core.expirer.set(s,o);},this.sendRequest=async e=>{const{topic:s,method:t,params:i,expiry:n,relayRpcId:o,clientRpcId:a,throwOnFailedPublish:c}=e,p=formatJsonRpcRequest(t,i,a);if(D$7()&&he$3.includes(t)){const N=Ln(JSON.stringify(p));this.client.core.verify.register({attestationId:N});}const d=await this.client.core.crypto.encode(s,p),h=R$3[t].req;return n&&(h.ttl=n),o&&(h.id=o),this.client.core.history.set(s,p),c?(h.internal=D$4(g$5({},h.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,d,h)):this.client.core.relayer.publish(s,d,h).catch(N=>this.client.logger.error(N)),p.id},this.sendResult=async e=>{const{id:s,topic:t,result:i,throwOnFailedPublish:n}=e,o=formatJsonRpcResult(s,i),a=await this.client.core.crypto.encode(t,o),c=await this.client.core.history.get(t,s),p=R$3[c.request.method].res;n?(p.internal=D$4(g$5({},p.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,a,p)):this.client.core.relayer.publish(t,a,p).catch(d=>this.client.logger.error(d)),await this.client.core.history.resolve(o);},this.sendError=async(e,s,t)=>{const i=formatJsonRpcError(e,t),n=await this.client.core.crypto.encode(s,i),o=await this.client.core.history.get(s,e),a=R$3[o.request.method].res;this.client.core.relayer.publish(s,n,a),await this.client.core.history.resolve(i);},this.cleanup=async()=>{const e=[],s=[];this.client.session.getAll().forEach(t=>{let i=!1;mt$1(t.expiry)&&(i=!0),this.client.core.crypto.keychain.has(t.topic)||(i=!0),i&&e.push(t.topic);}),this.client.proposal.getAll().forEach(t=>{mt$1(t.expiryTimestamp)&&s.push(t.id);}),await Promise.all([...e.map(t=>this.deleteSession({topic:t})),...s.map(t=>this.deleteProposal(t))]);},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue();},this.processRequestsQueue=async()=>{if(this.requestQueue.state===I$3.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=I$3.active;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise(s=>setTimeout(s,300));}catch(s){this.client.logger.warn(s);}}this.requestQueue.state=I$3.idle;},this.processRequest=e=>{const{topic:s,payload:t}=e,i=t.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeRequest(s,t);case"wc_sessionSettle":return this.onSessionSettleRequest(s,t);case"wc_sessionUpdate":return this.onSessionUpdateRequest(s,t);case"wc_sessionExtend":return this.onSessionExtendRequest(s,t);case"wc_sessionPing":return this.onSessionPingRequest(s,t);case"wc_sessionDelete":return this.onSessionDeleteRequest(s,t);case"wc_sessionRequest":return this.onSessionRequest(s,t);case"wc_sessionEvent":return this.onSessionEventRequest(s,t);default:return this.client.logger.info(`Unsupported request method ${i}`)}},this.onRelayEventResponse=async e=>{const{topic:s,payload:t}=e,i=(await this.client.core.history.get(s,t.id)).request.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeResponse(s,t);case"wc_sessionSettle":return this.onSessionSettleResponse(s,t);case"wc_sessionUpdate":return this.onSessionUpdateResponse(s,t);case"wc_sessionExtend":return this.onSessionExtendResponse(s,t);case"wc_sessionPing":return this.onSessionPingResponse(s,t);case"wc_sessionRequest":return this.onSessionRequestResponse(s,t);default:return this.client.logger.info(`Unsupported response method ${i}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:s}=e,{message:t}=N$4("MISSING_OR_INVALID",`Decoded payload on topic ${s} is not identifiable as a JSON-RPC request or a response.`);throw new Error(t)},this.onSessionProposeRequest=async(e,s)=>{const{params:t,id:i}=s;try{this.isValidConnect(g$5({},s.params));const n=t.expiryTimestamp||pt$2(R$3.wc_sessionPropose.req.ttl),o=g$5({id:i,pairingTopic:e,expiryTimestamp:n},t);await this.setProposal(i,o);const a=Ln(JSON.stringify(s)),c=await this.getVerifyContext(a,o.proposer.metadata);this.client.events.emit("session_proposal",{id:i,params:o,verifyContext:c});}catch(n){await this.sendError(i,e,n),this.client.logger.error(n);}},this.onSessionProposeResponse=async(e,s)=>{const{id:t}=s;if(isJsonRpcResult(s)){const{result:i}=s;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:i});const n=this.client.proposal.get(t);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=i.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:c});const p=await this.client.core.relayer.subscribe(c);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:p}),await this.client.core.pairing.activate({topic:e});}else isJsonRpcError(s)&&(await this.client.proposal.delete(t,U$5("USER_DISCONNECTED")),this.events.emit(yt$2("session_connect"),{error:s.error}));},this.onSessionSettleRequest=async(e,s)=>{const{id:t,params:i}=s;try{this.isValidSessionSettleRequest(i);const{relay:n,controller:o,expiry:a,namespaces:c,sessionProperties:p,pairingTopic:d}=s.params,h=g$5({topic:e,relay:n,expiry:a,namespaces:c,acknowledged:!0,pairingTopic:d,requiredNamespaces:{},optionalNamespaces:{},controller:o.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:o.publicKey,metadata:o.metadata}},p&&{sessionProperties:p});await this.sendResult({id:s.id,topic:e,result:!0}),this.events.emit(yt$2("session_connect"),{session:h}),this.cleanupDuplicatePairings(h);}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.onSessionSettleResponse=async(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(yt$2("session_approve",t),{})):isJsonRpcError(s)&&(await this.client.session.delete(e,U$5("USER_DISCONNECTED")),this.events.emit(yt$2("session_approve",t),{error:s.error}));},this.onSessionUpdateRequest=async(e,s)=>{const{params:t,id:i}=s;try{const n=`${e}_session_update`,o=sr$3.get(n);if(o&&this.isRequestOutOfSync(o,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidUpdate(g$5({topic:e},t)),await this.client.session.update(e,{namespaces:t.namespaces}),await this.sendResult({id:i,topic:e,result:!0}),this.client.events.emit("session_update",{id:i,topic:e,params:t}),sr$3.set(n,i);}catch(n){await this.sendError(i,e,n),this.client.logger.error(n);}},this.isRequestOutOfSync=(e,s)=>parseInt(s.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_update",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_update",t),{error:s.error});},this.onSessionExtendRequest=async(e,s)=>{const{id:t}=s;try{this.isValidExtend({topic:e}),await this.setExpiry(e,pt$2(L$5)),await this.sendResult({id:t,topic:e,result:!0}),this.client.events.emit("session_extend",{id:t,topic:e});}catch(i){await this.sendError(t,e,i),this.client.logger.error(i);}},this.onSessionExtendResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_extend",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_extend",t),{error:s.error});},this.onSessionPingRequest=async(e,s)=>{const{id:t}=s;try{this.isValidPing({topic:e}),await this.sendResult({id:t,topic:e,result:!0}),this.client.events.emit("session_ping",{id:t,topic:e});}catch(i){await this.sendError(t,e,i),this.client.logger.error(i);}},this.onSessionPingResponse=(e,s)=>{const{id:t}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(yt$2("session_ping",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_ping",t),{error:s.error});},500);},this.onSessionDeleteRequest=async(e,s)=>{const{id:t}=s;try{this.isValidDisconnect({topic:e,reason:s.params}),await Promise.all([new Promise(i=>{this.client.core.relayer.once(D$5.publish,async()=>{i(await this.deleteSession({topic:e,id:t}));});}),this.sendResult({id:t,topic:e,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:U$5("USER_DISCONNECTED")})]);}catch(i){this.client.logger.error(i);}},this.onSessionRequest=async(e,s)=>{const{id:t,params:i}=s;try{this.isValidRequest(g$5({topic:e},i));const n=Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest",i,t))),o=this.client.session.get(e),a=await this.getVerifyContext(n,o.peer.metadata),c={id:t,topic:e,params:i,verifyContext:a};await this.setPendingSessionRequest(c),this.addSessionRequestToSessionRequestQueue(c),this.processSessionRequestQueue();}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.onSessionRequestResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_request",t),{result:s.result}):isJsonRpcError(s)&&this.events.emit(yt$2("session_request",t),{error:s.error});},this.onSessionEventRequest=async(e,s)=>{const{id:t,params:i}=s;try{const n=`${e}_session_event_${i.event.name}`,o=sr$3.get(n);if(o&&this.isRequestOutOfSync(o,t)){this.client.logger.info(`Discarding out of sync request - ${t}`);return}this.isValidEmit(g$5({topic:e},i)),this.client.events.emit("session_event",{id:t,topic:e,params:i}),sr$3.set(n,t);}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e);},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=I$3.idle,this.processSessionRequestQueue();},cjs$5.toMiliseconds(this.requestQueueDelay));},this.cleanupPendingSentRequestsForTopic=({topic:e,error:s})=>{const t=this.client.core.history.pending;t.length>0&&t.filter(i=>i.topic===e&&i.request.method==="wc_sessionRequest").forEach(i=>{this.events.emit(yt$2("session_request",i.request.id),{error:s});});},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===I$3.active){this.client.logger.info("session request queue is already active.");return}const e=this.sessionRequestQueue.queue[0];if(!e){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=I$3.active,this.client.events.emit("session_request",e);}catch(s){this.client.logger.error(s);}},this.onPairingCreated=e=>{if(e.active)return;const s=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);s&&this.onSessionProposeRequest(e.topic,formatJsonRpcRequest("wc_sessionPropose",{requiredNamespaces:s.requiredNamespaces,optionalNamespaces:s.optionalNamespaces,relays:s.relays,proposer:s.proposer,sessionProperties:s.sessionProperties},s.id));},this.isValidConnect=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(a)}const{pairingTopic:s,requiredNamespaces:t,optionalNamespaces:i,sessionProperties:n,relays:o}=e;if(w$5(s)||await this.isValidPairingTopic(s),!qt$2(o)){const{message:a}=N$4("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(a)}!w$5(t)&&B$5(t)!==0&&this.validateNamespaces(t,"requiredNamespaces"),!w$5(i)&&B$5(i)!==0&&this.validateNamespaces(i,"optionalNamespaces"),w$5(n)||this.validateSessionProps(n,"sessionProperties");},this.validateNamespaces=(e,s)=>{const t=Ht$2(e,"connect()",s);if(t)throw new Error(t.message)},this.isValidApprove=async e=>{if(!Gt$2(e))throw new Error(N$4("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:s,namespaces:t,relayProtocol:i,sessionProperties:n}=e;await this.isValidProposalId(s);const o=this.client.proposal.get(s),a=ln(t,"approve()");if(a)throw new Error(a.message);const c=fn(o.requiredNamespaces,t,"approve()");if(c)throw new Error(c.message);if(!g$8(i,!0)){const{message:p}=N$4("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(p)}w$5(n)||this.validateSessionProps(n,"sessionProperties");},this.isValidReject=async e=>{if(!Gt$2(e)){const{message:i}=N$4("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(i)}const{id:s,reason:t}=e;if(await this.isValidProposalId(s),!Wt$1(t)){const{message:i}=N$4("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(t)}`);throw new Error(i)}},this.isValidSessionSettleRequest=e=>{if(!Gt$2(e)){const{message:c}=N$4("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(c)}const{relay:s,controller:t,namespaces:i,expiry:n}=e;if(!dn(s)){const{message:c}=N$4("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}const o=Ft$1(t,"onSessionSettleRequest()");if(o)throw new Error(o.message);const a=ln(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);if(mt$1(n)){const{message:c}=N$4("EXPIRED","onSessionSettleRequest()");throw new Error(c)}},this.isValidUpdate=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(a)}const{topic:s,namespaces:t}=e;await this.isValidSessionTopic(s);const i=this.client.session.get(s),n=ln(t,"update()");if(n)throw new Error(n.message);const o=fn(i.requiredNamespaces,t,"update()");if(o)throw new Error(o.message)},this.isValidExtend=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionTopic(s);},this.isValidRequest=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(a)}const{topic:s,request:t,chainId:i,expiry:n}=e;await this.isValidSessionTopic(s);const{namespaces:o}=this.client.session.get(s);if(!Qt$1(o,i)){const{message:a}=N$4("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(a)}if(!zt$2(t)){const{message:a}=N$4("MISSING_OR_INVALID",`request() ${JSON.stringify(t)}`);throw new Error(a)}if(!Zt$1(o,i,t.method)){const{message:a}=N$4("MISSING_OR_INVALID",`request() method: ${t.method}`);throw new Error(a)}if(n&&!tr$2(n,U$4)){const{message:a}=N$4("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${U$4.min} and ${U$4.max}`);throw new Error(a)}},this.isValidRespond=async e=>{var s;if(!Gt$2(e)){const{message:n}=N$4("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(n)}const{topic:t,response:i}=e;try{await this.isValidSessionTopic(t);}catch(n){throw (s=e?.response)!=null&&s.id&&this.cleanupAfterResponse(e),n}if(!Yt$2(i)){const{message:n}=N$4("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(n)}},this.isValidPing=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionOrPairingTopic(s);},this.isValidEmit=async e=>{if(!Gt$2(e)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(o)}const{topic:s,event:t,chainId:i}=e;await this.isValidSessionTopic(s);const{namespaces:n}=this.client.session.get(s);if(!Qt$1(n,i)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(o)}if(!Jt$2(t)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(t)}`);throw new Error(o)}if(!Xt$1(n,i,t.name)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(t)}`);throw new Error(o)}},this.isValidDisconnect=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionOrPairingTopic(s);},this.getVerifyContext=async(e,s)=>{const t={verified:{verifyUrl:s.verifyUrl||F$4,validation:"UNKNOWN",origin:s.url||""}};try{const i=await this.client.core.verify.resolve({attestationId:e,verifyUrl:s.verifyUrl});i&&(t.verified.origin=i.origin,t.verified.isScam=i.isScam,t.verified.validation=i.origin===new URL(s.url).origin?"VALID":"INVALID");}catch(i){this.client.logger.info(i);}return this.client.logger.info(`Verify context: ${JSON.stringify(t)}`),t},this.validateSessionProps=(e,s)=>{Object.values(e).forEach(t=>{if(!g$8(t,!1)){const{message:i}=N$4("MISSING_OR_INVALID",`${s} must be in Record<string, string> format. Received: ${JSON.stringify(t)}`);throw new Error(i)}});};}async isInitialized(){if(!this.initialized){const{message:r}=N$4("NOT_INITIALIZED",this.name);throw new Error(r)}await this.client.core.relayer.confirmOnlineStateOrThrow();}registerRelayerEvents(){this.client.core.relayer.on(D$5.message,async r=>{const{topic:e,message:s}=r;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s)))return;const t=await this.client.core.crypto.decode(e,s);try{isJsonRpcRequest(t)?(this.client.core.history.set(e,t),this.onRelayEventRequest({topic:e,payload:t})):isJsonRpcResponse(t)?(await this.client.core.history.resolve(t),await this.onRelayEventResponse({topic:e,payload:t}),this.client.core.history.delete(e,t.id)):this.onRelayEventUnknownPayload({topic:e,payload:t});}catch(i){this.client.logger.error(i);}});}registerExpirerEvents(){this.client.core.expirer.on(v$6.expired,async r=>{const{topic:e,id:s}=ft$2(r.target);if(s&&this.client.pendingRequest.keys.includes(s))return await this.deletePendingSessionRequest(s,N$4("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession({topic:e,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:e})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s}));});}registerPairingEvents(){this.client.core.pairing.events.on(V$3.create,r=>this.onPairingCreated(r));}isValidPairingTopic(r){if(!g$8(r,!1)){const{message:e}=N$4("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.core.pairing.pairings.get(r).expiry)){const{message:e}=N$4("EXPIRED",`pairing topic: ${r}`);throw new Error(e)}}async isValidSessionTopic(r){if(!g$8(r,!1)){const{message:e}=N$4("MISSING_OR_INVALID",`session topic should be a string: ${r}`);throw new Error(e)}if(!this.client.session.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`session topic doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.session.get(r).expiry)){await this.deleteSession({topic:r});const{message:e}=N$4("EXPIRED",`session topic: ${r}`);throw new Error(e)}if(!this.client.core.crypto.keychain.has(r)){const{message:e}=N$4("MISSING_OR_INVALID",`session topic does not exist in keychain: ${r}`);throw await this.deleteSession({topic:r}),new Error(e)}}async isValidSessionOrPairingTopic(r){if(this.client.session.keys.includes(r))await this.isValidSessionTopic(r);else if(this.client.core.pairing.pairings.keys.includes(r))this.isValidPairingTopic(r);else if(g$8(r,!1)){const{message:e}=N$4("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${r}`);throw new Error(e)}else {const{message:e}=N$4("MISSING_OR_INVALID",`session or pairing topic should be a string: ${r}`);throw new Error(e)}}async isValidProposalId(r){if(!Bt$2(r)){const{message:e}=N$4("MISSING_OR_INVALID",`proposal id should be a number: ${r}`);throw new Error(e)}if(!this.client.proposal.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`proposal id doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.proposal.get(r).expiryTimestamp)){await this.deleteProposal(r);const{message:e}=N$4("EXPIRED",`proposal id: ${r}`);throw new Error(e)}}}class us extends Kt$1{constructor(r,e){super(r,e,oe$3,G$3),this.core=r,this.logger=e;}}let ge$3 = class ge extends Kt$1{constructor(r,e){super(r,e,ce$3,G$3),this.core=r,this.logger=e;}};class gs extends Kt$1{constructor(r,e){super(r,e,pe$2,G$3,s=>s.id),this.core=r,this.logger=e;}}let Q$4 = class Q extends b$3{constructor(r){super(r),this.protocol=J$1,this.version=F$3,this.name=M$4.name,this.events=new EventEmitter$1,this.on=(s,t)=>this.events.on(s,t),this.once=(s,t)=>this.events.once(s,t),this.off=(s,t)=>this.events.off(s,t),this.removeListener=(s,t)=>this.events.removeListener(s,t),this.removeAllListeners=s=>this.events.removeAllListeners(s),this.connect=async s=>{try{return await this.engine.connect(s)}catch(t){throw this.logger.error(t.message),t}},this.pair=async s=>{try{return await this.engine.pair(s)}catch(t){throw this.logger.error(t.message),t}},this.approve=async s=>{try{return await this.engine.approve(s)}catch(t){throw this.logger.error(t.message),t}},this.reject=async s=>{try{return await this.engine.reject(s)}catch(t){throw this.logger.error(t.message),t}},this.update=async s=>{try{return await this.engine.update(s)}catch(t){throw this.logger.error(t.message),t}},this.extend=async s=>{try{return await this.engine.extend(s)}catch(t){throw this.logger.error(t.message),t}},this.request=async s=>{try{return await this.engine.request(s)}catch(t){throw this.logger.error(t.message),t}},this.respond=async s=>{try{return await this.engine.respond(s)}catch(t){throw this.logger.error(t.message),t}},this.ping=async s=>{try{return await this.engine.ping(s)}catch(t){throw this.logger.error(t.message),t}},this.emit=async s=>{try{return await this.engine.emit(s)}catch(t){throw this.logger.error(t.message),t}},this.disconnect=async s=>{try{return await this.engine.disconnect(s)}catch(t){throw this.logger.error(t.message),t}},this.find=s=>{try{return this.engine.find(s)}catch(t){throw this.logger.error(t.message),t}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(s){throw this.logger.error(s.message),s}},this.name=r?.name||M$4.name,this.metadata=r?.metadata||Qn();const e=typeof r?.logger<"u"&&typeof r?.logger!="string"?r.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:r?.logger||M$4.logger}));this.core=r?.core||new Mr$1(r),this.logger=cjs$1.generateChildLogger(e,this.name),this.session=new ge$3(this.core,this.logger),this.proposal=new us(this.core,this.logger),this.pendingRequest=new gs(this.core,this.logger),this.engine=new ds(this);}static async init(r){const e=new Q(r);return await e.initialize(),e}get context(){return cjs$1.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success");}catch(r){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(r.message),r}}};
|
|
146993
146993
|
|
|
146994
146994
|
var browserPonyfill = {exports: {}};
|
|
146995
146995
|
|
|
@@ -147567,7 +147567,7 @@
|
|
|
147567
147567
|
constructor(url, disableProviderPing = false) {
|
|
147568
147568
|
this.url = url;
|
|
147569
147569
|
this.disableProviderPing = disableProviderPing;
|
|
147570
|
-
this.events = new EventEmitter$
|
|
147570
|
+
this.events = new EventEmitter$1();
|
|
147571
147571
|
this.isAvailable = false;
|
|
147572
147572
|
this.registering = false;
|
|
147573
147573
|
if (!isHttpUrl(url)) {
|
|
@@ -147715,9 +147715,9 @@ __p += '`),$&&(m+=`' +
|
|
|
147715
147715
|
function print() { __p += __j.call(arguments, '') }
|
|
147716
147716
|
`:`;
|
|
147717
147717
|
`)+m+`return __p
|
|
147718
|
-
}`;var b=_a(function(){return U(o,I+"return "+m).apply(i,f)});if(b.source=m,Ei(b))throw b;return b}function Ud(n){return W(n).toLowerCase()}function Wd(n){return W(n).toUpperCase()}function Fd(n,t,e){if(n=W(n),n&&(e||t===i))return ys(n);if(!n||!(t=ln(t)))return n;var r=On(n),s=On(t),o=Ss(r,s),f=Os(r,s)+1;return ut(r,o,f).join("")}function Md(n,t,e){if(n=W(n),n&&(e||t===i))return n.slice(0,bs(n)+1);if(!n||!(t=ln(t)))return n;var r=On(n),s=Os(r,On(t))+1;return ut(r,0,s).join("")}function qd(n,t,e){if(n=W(n),n&&(e||t===i))return n.replace(Er,"");if(!n||!(t=ln(t)))return n;var r=On(n),s=Ss(r,On(t));return ut(r,s).join("")}function Bd(n,t){var e=Da,r=Ha;if(K(t)){var s="separator"in t?t.separator:s;e="length"in t?R(t.length):e,r="omission"in t?ln(t.omission):r;}n=W(n);var o=n.length;if(Lt(n)){var f=On(n);o=f.length;}if(e>=o)return n;var c=e-Dt(r);if(c<1)return r;var l=f?ut(f,0,c).join(""):n.slice(0,c);if(s===i)return l+r;if(f&&(c+=l.length-c),yi(s)){if(n.slice(c).search(s)){var v,_=l;for(s.global||(s=Br(s.source,W(Ji.exec(s))+"g")),s.lastIndex=0;v=s.exec(_);)var m=v.index;l=l.slice(0,m===i?c:m);}}else if(n.indexOf(ln(s),c)!=c){var P=l.lastIndexOf(s);P>-1&&(l=l.slice(0,P));}return l+r}function Gd(n){return n=W(n),n&&ka.test(n)?n.replace(Ki,mf):n}var zd=Mt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Ri=mu("toUpperCase");function va(n,t,e){return n=W(n),t=e?i:t,t===i?pf(n)?Af(n):rf(n):n.match(t)||[]}var _a=T(function(n,t){try{return cn(n,i,t)}catch(e){return Ei(e)?e:new S(e)}}),Kd=Yn(function(n,t){return mn(t,function(e){e=Wn(e),zn(n,e,Ii(n[e],n));}),n});function Yd(n){var t=n==null?0:n.length,e=x();return n=t?G(n,function(r){if(typeof r[1]!="function")throw new wn(D);return [e(r[0]),r[1]]}):[],T(function(r){for(var s=-1;++s<t;){var o=n[s];if(cn(o[0],this,r))return cn(o[1],this,r)}})}function Zd(n){return mc(An(n,Ln))}function bi(n){return function(){return n}}function Jd(n,t){return n==null||n!==n?t:n}var Xd=Pu(),Qd=Pu(!0);function fn(n){return n}function Ti(n){return Qs(typeof n=="function"?n:An(n,Ln))}function Vd(n){return ks(An(n,Ln))}function kd(n,t){return js(n,An(t,Ln))}var jd=T(function(n,t){return function(e){return ae(e,n,t)}}),ng=T(function(n,t){return function(e){return ae(n,e,t)}});function Li(n,t,e){var r=V(t),s=ze(t,r);e==null&&!(K(t)&&(s.length||!r.length))&&(e=t,t=n,n=this,s=ze(t,V(t)));var o=!(K(e)&&"chain"in e)||!!e.chain,f=Jn(n);return mn(s,function(c){var l=t[c];n[c]=l,f&&(n.prototype[c]=function(){var v=this.__chain__;if(o||v){var _=n(this.__wrapped__),m=_.__actions__=un(this.__actions__);return m.push({func:l,args:arguments,thisArg:n}),_.__chain__=v,_}return l.apply(n,nt([this.value()],arguments))});}),n}function tg(){return k._===this&&(k._=Sf),this}function Di(){}function eg(n){return n=R(n),T(function(t){return nu(t,n)})}var rg=ci(G),ig=ci(As),sg=ci(Nr);function ma(n){return _i(n)?$r(Wn(n)):Nc(n)}function ug(n){return function(t){return n==null?i:_t(n,t)}}var ag=Cu(),og=Cu(!0);function Hi(){return []}function Ni(){return !1}function fg(){return {}}function cg(){return ""}function hg(){return !0}function lg(n,t){if(n=R(n),n<1||n>kn)return [];var e=Nn,r=nn(n,Nn);t=x(t),n-=Nn;for(var s=Fr(r,t);++e<n;)t(e);return s}function pg(n){return O(n)?G(n,Wn):pn(n)?[n]:un(Wu(W(n)))}function dg(n){var t=++Ef;return W(n)+t}var gg=Qe(function(n,t){return n+t},0),vg=hi("ceil"),_g=Qe(function(n,t){return n/t},1),mg=hi("floor");function wg(n){return n&&n.length?Ge(n,fn,Qr):i}function Pg(n,t){return n&&n.length?Ge(n,x(t,2),Qr):i}function Ag(n){return xs(n,fn)}function Cg(n,t){return xs(n,x(t,2))}function Ig(n){return n&&n.length?Ge(n,fn,ni):i}function xg(n,t){return n&&n.length?Ge(n,x(t,2),ni):i}var Eg=Qe(function(n,t){return n*t},1),yg=hi("round"),Sg=Qe(function(n,t){return n-t},0);function Og(n){return n&&n.length?Wr(n,fn):0}function Rg(n,t){return n&&n.length?Wr(n,x(t,2)):0}return a.after=Vl,a.ary=Xu,a.assign=Wp,a.assignIn=fa,a.assignInWith=fr,a.assignWith=Fp,a.at=Mp,a.before=Qu,a.bind=Ii,a.bindAll=Kd,a.bindKey=Vu,a.castArray=fp,a.chain=Yu,a.chunk=mh,a.compact=wh,a.concat=Ph,a.cond=Yd,a.conforms=Zd,a.constant=bi,a.countBy=Ol,a.create=qp,a.curry=ku,a.curryRight=ju,a.debounce=na,a.defaults=Bp,a.defaultsDeep=Gp,a.defer=kl,a.delay=jl,a.difference=Ah,a.differenceBy=Ch,a.differenceWith=Ih,a.drop=xh,a.dropRight=Eh,a.dropRightWhile=yh,a.dropWhile=Sh,a.fill=Oh,a.filter=bl,a.flatMap=Dl,a.flatMapDeep=Hl,a.flatMapDepth=Nl,a.flatten=Bu,a.flattenDeep=Rh,a.flattenDepth=bh,a.flip=np,a.flow=Xd,a.flowRight=Qd,a.fromPairs=Th,a.functions=Qp,a.functionsIn=Vp,a.groupBy=$l,a.initial=Dh,a.intersection=Hh,a.intersectionBy=Nh,a.intersectionWith=$h,a.invert=jp,a.invertBy=nd,a.invokeMap=Wl,a.iteratee=Ti,a.keyBy=Fl,a.keys=V,a.keysIn=on,a.map=rr,a.mapKeys=ed,a.mapValues=rd,a.matches=Vd,a.matchesProperty=kd,a.memoize=sr,a.merge=id,a.mergeWith=ca,a.method=jd,a.methodOf=ng,a.mixin=Li,a.negate=ur,a.nthArg=eg,a.omit=sd,a.omitBy=ud,a.once=tp,a.orderBy=Ml,a.over=rg,a.overArgs=ep,a.overEvery=ig,a.overSome=sg,a.partial=xi,a.partialRight=ta,a.partition=ql,a.pick=ad,a.pickBy=ha,a.property=ma,a.propertyOf=ug,a.pull=Mh,a.pullAll=zu,a.pullAllBy=qh,a.pullAllWith=Bh,a.pullAt=Gh,a.range=ag,a.rangeRight=og,a.rearg=rp,a.reject=zl,a.remove=zh,a.rest=ip,a.reverse=Ai,a.sampleSize=Yl,a.set=fd,a.setWith=cd,a.shuffle=Zl,a.slice=Kh,a.sortBy=Ql,a.sortedUniq=kh,a.sortedUniqBy=jh,a.split=Dd,a.spread=sp,a.tail=nl,a.take=tl,a.takeRight=el,a.takeRightWhile=rl,a.takeWhile=il,a.tap=wl,a.throttle=up,a.thru=er,a.toArray=ua,a.toPairs=la,a.toPairsIn=pa,a.toPath=pg,a.toPlainObject=oa,a.transform=hd,a.unary=ap,a.union=sl,a.unionBy=ul,a.unionWith=al,a.uniq=ol,a.uniqBy=fl,a.uniqWith=cl,a.unset=ld,a.unzip=Ci,a.unzipWith=Ku,a.update=pd,a.updateWith=dd,a.values=Gt,a.valuesIn=gd,a.without=hl,a.words=va,a.wrap=op,a.xor=ll,a.xorBy=pl,a.xorWith=dl,a.zip=gl,a.zipObject=vl,a.zipObjectDeep=_l,a.zipWith=ml,a.entries=la,a.entriesIn=pa,a.extend=fa,a.extendWith=fr,Li(a,a),a.add=gg,a.attempt=_a,a.camelCase=wd,a.capitalize=da,a.ceil=vg,a.clamp=vd,a.clone=cp,a.cloneDeep=lp,a.cloneDeepWith=pp,a.cloneWith=hp,a.conformsTo=dp,a.deburr=ga,a.defaultTo=Jd,a.divide=_g,a.endsWith=Pd,a.eq=bn,a.escape=Ad,a.escapeRegExp=Cd,a.every=Rl,a.find=Tl,a.findIndex=Mu,a.findKey=zp,a.findLast=Ll,a.findLastIndex=qu,a.findLastKey=Kp,a.floor=mg,a.forEach=Zu,a.forEachRight=Ju,a.forIn=Yp,a.forInRight=Zp,a.forOwn=Jp,a.forOwnRight=Xp,a.get=Si,a.gt=gp,a.gte=vp,a.has=kp,a.hasIn=Oi,a.head=Gu,a.identity=fn,a.includes=Ul,a.indexOf=Lh,a.inRange=_d,a.invoke=td,a.isArguments=Pt,a.isArray=O,a.isArrayBuffer=_p,a.isArrayLike=an,a.isArrayLikeObject=Z,a.isBoolean=mp,a.isBuffer=at,a.isDate=wp,a.isElement=Pp,a.isEmpty=Ap,a.isEqual=Cp,a.isEqualWith=Ip,a.isError=Ei,a.isFinite=xp,a.isFunction=Jn,a.isInteger=ea,a.isLength=ar,a.isMap=ra,a.isMatch=Ep,a.isMatchWith=yp,a.isNaN=Sp,a.isNative=Op,a.isNil=bp,a.isNull=Rp,a.isNumber=ia,a.isObject=K,a.isObjectLike=Y,a.isPlainObject=pe,a.isRegExp=yi,a.isSafeInteger=Tp,a.isSet=sa,a.isString=or,a.isSymbol=pn,a.isTypedArray=Bt,a.isUndefined=Lp,a.isWeakMap=Dp,a.isWeakSet=Hp,a.join=Uh,a.kebabCase=Id,a.last=In,a.lastIndexOf=Wh,a.lowerCase=xd,a.lowerFirst=Ed,a.lt=Np,a.lte=$p,a.max=wg,a.maxBy=Pg,a.mean=Ag,a.meanBy=Cg,a.min=Ig,a.minBy=xg,a.stubArray=Hi,a.stubFalse=Ni,a.stubObject=fg,a.stubString=cg,a.stubTrue=hg,a.multiply=Eg,a.nth=Fh,a.noConflict=tg,a.noop=Di,a.now=ir,a.pad=yd,a.padEnd=Sd,a.padStart=Od,a.parseInt=Rd,a.random=md,a.reduce=Bl,a.reduceRight=Gl,a.repeat=bd,a.replace=Td,a.result=od,a.round=yg,a.runInContext=h,a.sample=Kl,a.size=Jl,a.snakeCase=Ld,a.some=Xl,a.sortedIndex=Yh,a.sortedIndexBy=Zh,a.sortedIndexOf=Jh,a.sortedLastIndex=Xh,a.sortedLastIndexBy=Qh,a.sortedLastIndexOf=Vh,a.startCase=Hd,a.startsWith=Nd,a.subtract=Sg,a.sum=Og,a.sumBy=Rg,a.template=$d,a.times=lg,a.toFinite=Xn,a.toInteger=R,a.toLength=aa,a.toLower=Ud,a.toNumber=xn,a.toSafeInteger=Up,a.toString=W,a.toUpper=Wd,a.trim=Fd,a.trimEnd=Md,a.trimStart=qd,a.truncate=Bd,a.unescape=Gd,a.uniqueId=dg,a.upperCase=zd,a.upperFirst=Ri,a.each=Zu,a.eachRight=Ju,a.first=Gu,Li(a,function(){var n={};return $n(a,function(t,e){F.call(a.prototype,e)||(n[e]=t);}),n}(),{chain:!1}),a.VERSION=d,mn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a;}),mn(["drop","take"],function(n,t){N.prototype[n]=function(e){e=e===i?1:Q(R(e),0);var r=this.__filtered__&&!t?new N(this):this.clone();return r.__filtered__?r.__takeCount__=nn(e,r.__takeCount__):r.__views__.push({size:nn(e,Nn),type:n+(r.__dir__<0?"Right":"")}),r},N.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()};}),mn(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==Bi||e==Wa;N.prototype[n]=function(s){var o=this.clone();return o.__iteratees__.push({iteratee:x(s,3),type:e}),o.__filtered__=o.__filtered__||r,o};}),mn(["head","last"],function(n,t){var e="take"+(t?"Right":"");N.prototype[n]=function(){return this[e](1).value()[0]};}),mn(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");N.prototype[n]=function(){return this.__filtered__?new N(this):this[e](1)};}),N.prototype.compact=function(){return this.filter(fn)},N.prototype.find=function(n){return this.filter(n).head()},N.prototype.findLast=function(n){return this.reverse().find(n)},N.prototype.invokeMap=T(function(n,t){return typeof n=="function"?new N(this):this.map(function(e){return ae(e,n,t)})}),N.prototype.reject=function(n){return this.filter(ur(x(n)))},N.prototype.slice=function(n,t){n=R(n);var e=this;return e.__filtered__&&(n>0||t<0)?new N(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=R(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},N.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},N.prototype.toArray=function(){return this.take(Nn)},$n(N.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),s=a[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);s&&(a.prototype[t]=function(){var f=this.__wrapped__,c=r?[1]:arguments,l=f instanceof N,v=c[0],_=l||O(f),m=function(H){var $=s.apply(a,nt([H],c));return r&&P?$[0]:$};_&&e&&typeof v=="function"&&v.length!=1&&(l=_=!1);var P=this.__chain__,I=!!this.__actions__.length,E=o&&!P,b=l&&!I;if(!o&&_){f=b?f:new N(this);var y=n.apply(f,c);return y.__actions__.push({func:er,args:[m],thisArg:i}),new Pn(y,P)}return E&&b?n.apply(this,c):(y=this.thru(m),E?r?y.value()[0]:y.value():y)});}),mn(["pop","push","shift","sort","splice","unshift"],function(n){var t=Oe[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var s=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(O(o)?o:[],s)}return this[e](function(f){return t.apply(O(f)?f:[],s)})};}),$n(N.prototype,function(n,t){var e=a[t];if(e){var r=e.name+"";F.call(Ut,r)||(Ut[r]=[]),Ut[r].push({name:t,func:e});}}),Ut[Xe(i,ct).name]=[{name:"wrapper",func:i}],N.prototype.clone=Gf,N.prototype.reverse=zf,N.prototype.value=Kf,a.prototype.at=Pl,a.prototype.chain=Al,a.prototype.commit=Cl,a.prototype.next=Il,a.prototype.plant=El,a.prototype.reverse=yl,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Sl,a.prototype.first=a.prototype.head,ne&&(a.prototype[ne]=xl),a},Ht=Cf();lt?((lt.exports=Ht)._=Ht,Tr._=Ht):k._=Ht;}).call(ge$2);})(Ui$1,Ui$1.exports);var Gg$1=Object.defineProperty,zg$1=Object.defineProperties,Kg$1=Object.getOwnPropertyDescriptors,Ea$1=Object.getOwnPropertySymbols,Yg$1=Object.prototype.hasOwnProperty,Zg$1=Object.prototype.propertyIsEnumerable,ya$1=(A,u,i)=>u in A?Gg$1(A,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):A[u]=i,cr$2=(A,u)=>{for(var i in u||(u={}))Yg$1.call(u,i)&&ya$1(A,i,u[i]);if(Ea$1)for(var i of Ea$1(u))Zg$1.call(u,i)&&ya$1(A,i,u[i]);return A},Jg$1=(A,u)=>zg$1(A,Kg$1(u));function ft(A,u,i){var d;const w=ve$3(A);return ((d=u.rpcMap)==null?void 0:d[w.reference])||`${Bg$1}?chainId=${w.namespace}:${w.reference}&projectId=${i}`}function Ct(A){return A.includes(":")?A.split(":")[1]:A}function Sa$1(A){return A.map(u=>`${u.split(":")[0]}:${u.split(":")[1]}`)}function Xg$1(A,u){const i=Object.keys(u.namespaces).filter(w=>w.includes(A));if(!i.length)return [];const d=[];return i.forEach(w=>{const L=u.namespaces[w].accounts;d.push(...L);}),d}function Oa$1(A={},u={}){const i=Ra$1(A),d=Ra$1(u);return Ui$1.exports.merge(i,d)}function Ra$1(A){var u,i,d,w;const L={};if(!B$5(A))return L;for(const[D,En]of Object.entries(A)){const zt=oe$4(D)?[D]:En.chains,pr=En.methods||[],It=En.events||[],Ln=En.rpcMap||{},Fn=en(D);L[Fn]=Jg$1(cr$2(cr$2({},L[Fn]),En),{chains:S$6(zt,(u=L[Fn])==null?void 0:u.chains),methods:S$6(pr,(i=L[Fn])==null?void 0:i.methods),events:S$6(It,(d=L[Fn])==null?void 0:d.events),rpcMap:cr$2(cr$2({},Ln),(w=L[Fn])==null?void 0:w.rpcMap)});}return L}function Qg$1(A){return A.includes(":")?A.split(":")[2]:A}function Vg$1(A){const u={};for(const[i,d]of Object.entries(A)){const w=d.methods||[],L=d.events||[],D=d.accounts||[],En=oe$4(i)?[i]:d.chains?d.chains:Sa$1(d.accounts);u[i]={chains:En,methods:w,events:L,accounts:D};}return u}function Wi$1(A){return typeof A=="number"?A:A.includes("0x")?parseInt(A,16):(A=A.includes(":")?A.split(":")[1]:A,isNaN(Number(A))?A:Number(A))}const ba={},z$4=A=>ba[A],Fi$1=(A,u)=>{ba[A]=u;};let kg$1 = class kg{constructor(u){this.name="polkadot",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getAccounts(){const u=this.namespace.accounts;return u?u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}};let jg$1 = class jg{constructor(u){this.name="eip155",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain());}async request(u){switch(u.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(u);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(u.request.method)?await this.client.request(u):this.getHttpProvider().request(u.request)}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(parseInt(u),i),this.chainId=parseInt(u),this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}createHttpProvider(u,i){const d=i||ft(`${this.name}:${u}`,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=parseInt(Ct(i));u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}getHttpProvider(){const u=this.chainId,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}async handleSwitchChain(u){var i,d;let w=u.request.params?(i=u.request.params[0])==null?void 0:i.chainId:"0x0";w=w.startsWith("0x")?w:`0x${w}`;const L=parseInt(w,16);if(this.isChainApproved(L))this.setDefaultChain(`${L}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:u.topic,request:{method:u.request.method,params:[{chainId:w}]},chainId:(d=this.namespace.chains)==null?void 0:d[0]}),this.setDefaultChain(`${L}`);else throw new Error(`Failed to switch to chain 'eip155:${L}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(u){return this.namespace.chains.includes(`${this.name}:${u}`)}};class nv{constructor(u){this.name="solana",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class tv{constructor(u){this.name="cosmos",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class ev{constructor(u){this.name="cip34",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{const d=this.getCardanoRPCUrl(i),w=Ct(i);u[w]=this.createHttpProvider(w,d);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}getCardanoRPCUrl(u){const i=this.namespace.rpcMap;if(i)return i[u]}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||this.getCardanoRPCUrl(u);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class rv{constructor(u){this.name="elrond",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class iv{constructor(u){this.name="multiversx",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class sv{constructor(u){this.name="near",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){if(this.chainId=u,!this.httpProviders[u]){const d=i||ft(`${this.name}:${u}`,this.namespace);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);this.setHttpProvider(u,d);}this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;u[i]=this.createHttpProvider(i,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace);return typeof d>"u"?void 0:new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}var uv=Object.defineProperty,av=Object.defineProperties,ov=Object.getOwnPropertyDescriptors,Ta$1=Object.getOwnPropertySymbols,fv=Object.prototype.hasOwnProperty,cv=Object.prototype.propertyIsEnumerable,La$1=(A,u,i)=>u in A?uv(A,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):A[u]=i,hr$2=(A,u)=>{for(var i in u||(u={}))fv.call(u,i)&&La$1(A,i,u[i]);if(Ta$1)for(var i of Ta$1(u))cv.call(u,i)&&La$1(A,i,u[i]);return A},Mi$1=(A,u)=>av(A,ov(u));class lr{constructor(u){this.events=new EventEmitter$2,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=u,this.logger=typeof u?.logger<"u"&&typeof u?.logger!="string"?u.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:u?.logger||Ia$1})),this.disableProviderPing=u?.disableProviderPing||!1;}static async init(u){const i=new lr(u);return await i.initialize(),i}async request(u,i,d){const[w,L]=this.validateChain(i);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(w).request({request:hr$2({},u),chainId:`${w}:${L}`,topic:this.session.topic,expiry:d})}sendAsync(u,i,d,w){const L=new Date().getTime();this.request(u,d,w).then(D=>i(null,formatJsonRpcResult(L,D))).catch(D=>i(D,void 0));}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var u;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(u=this.session)==null?void 0:u.topic,reason:U$5("USER_DISCONNECTED")}),await this.cleanup();}async connect(u){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(u),await this.cleanupPendingPairings(),!u.skipPairing)return await this.pair(u.pairingTopic)}on(u,i){this.events.on(u,i);}once(u,i){this.events.once(u,i);}removeListener(u,i){this.events.removeListener(u,i);}off(u,i){this.events.off(u,i);}get isWalletConnect(){return !0}async pair(u){this.shouldAbortPairingAttempt=!1;let i=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(i>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:d,approval:w}=await this.client.connect({pairingTopic:u,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});d&&(this.uri=d,this.events.emit("display_uri",d)),await w().then(L=>{this.session=L;const D=Vg$1(L.namespaces);this.namespaces=Oa$1(this.namespaces,D),this.persist("namespaces",this.namespaces);}).catch(L=>{if(L.message!==ae$3)throw L;i++;});}while(!this.session);return this.onConnect(),this.session}setDefaultChain(u,i){try{if(!this.session)return;const[d,w]=this.validateChain(u);this.getProvider(d).setDefaultChain(w,i);}catch(d){if(!/Please call connect/.test(d.message))throw d}}async cleanupPendingPairings(u={}){this.logger.info("Cleaning up inactive pairings...");const i=this.client.pairing.getAll();if(k$4(i)){for(const d of i)u.deletePairings?this.client.core.expirer.set(d.topic,0):await this.client.core.relayer.subscriber.unsubscribe(d.topic);this.logger.info(`Inactive pairings cleared: ${i.length}`);}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0;}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const u=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[u]),this.createProviders();}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners();}async createClient(){this.client=this.providerOpts.client||await Q$4.init({logger:this.providerOpts.logger||Ia$1,relayUrl:this.providerOpts.relayUrl||Fg$1,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized");}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const u=[...new Set(Object.keys(this.session.namespaces).map(i=>en(i)))];Fi$1("client",this.client),Fi$1("events",this.events),Fi$1("disableProviderPing",this.disableProviderPing),u.forEach(i=>{if(!this.session)return;const d=Xg$1(i,this.session),w=Sa$1(d),L=Oa$1(this.namespaces,this.optionalNamespaces),D=Mi$1(hr$2({},L[i]),{accounts:d,chains:w});switch(i){case"eip155":this.rpcProviders[i]=new jg$1({namespace:D});break;case"solana":this.rpcProviders[i]=new nv({namespace:D});break;case"cosmos":this.rpcProviders[i]=new tv({namespace:D});break;case"polkadot":this.rpcProviders[i]=new kg$1({namespace:D});break;case"cip34":this.rpcProviders[i]=new ev({namespace:D});break;case"elrond":this.rpcProviders[i]=new rv({namespace:D});break;case"multiversx":this.rpcProviders[i]=new iv({namespace:D});break;case"near":this.rpcProviders[i]=new sv({namespace:D});break}});}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",u=>{this.events.emit("session_ping",u);}),this.client.on("session_event",u=>{const{params:i}=u,{event:d}=i;if(d.name==="accountsChanged"){const w=d.data;w&&k$4(w)&&this.events.emit("accountsChanged",w.map(Qg$1));}else if(d.name==="chainChanged"){const w=i.chainId,L=i.event.data,D=en(w),En=Wi$1(w)!==Wi$1(L)?`${D}:${Wi$1(L)}`:w;this.onChainChanged(En);}else this.events.emit(d.name,d.data);this.events.emit("session_event",u);}),this.client.on("session_update",({topic:u,params:i})=>{var d;const{namespaces:w}=i,L=(d=this.client)==null?void 0:d.session.get(u);this.session=Mi$1(hr$2({},L),{namespaces:w}),this.onSessionUpdate(),this.events.emit("session_update",{topic:u,params:i});}),this.client.on("session_delete",async u=>{await this.cleanup(),this.events.emit("session_delete",u),this.events.emit("disconnect",Mi$1(hr$2({},U$5("USER_DISCONNECTED")),{data:u.topic}));}),this.on(Vn.DEFAULT_CHAIN_CHANGED,u=>{this.onChainChanged(u,!0);});}getProvider(u){if(!this.rpcProviders[u])throw new Error(`Provider not found: ${u}`);return this.rpcProviders[u]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(u=>{var i;this.getProvider(u).updateNamespace((i=this.session)==null?void 0:i.namespaces[u]);});}setNamespaces(u){const{namespaces:i,optionalNamespaces:d,sessionProperties:w}=u;i&&Object.keys(i).length&&(this.namespaces=i),d&&Object.keys(d).length&&(this.optionalNamespaces=d),this.sessionProperties=w,this.persist("namespaces",i),this.persist("optionalNamespaces",d);}validateChain(u){const[i,d]=u?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return [i,d];if(i&&!Object.keys(this.namespaces||{}).map(D=>en(D)).includes(i))throw new Error(`Namespace '${i}' is not configured. Please call connect() first with namespace config.`);if(i&&d)return [i,d];const w=en(Object.keys(this.namespaces)[0]),L=this.rpcProviders[w].getDefaultChain();return [w,L]}async requestAccounts(){const[u]=this.validateChain();return await this.getProvider(u).requestAccounts()}onChainChanged(u,i=!1){if(!this.namespaces)return;const[d,w]=this.validateChain(u);w&&(i||this.getProvider(d).setDefaultChain(w),this.namespaces[d]?this.namespaces[d].defaultChain=w:this.namespaces[`${d}:${w}`]?this.namespaces[`${d}:${w}`].defaultChain=w:this.namespaces[`${d}:${w}`]={defaultChain:w},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",w));}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session});}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0});}persist(u,i){this.client.core.storage.setItem(`${xa}/${u}`,i);}async getFromStore(u){return await this.client.core.storage.getItem(`${xa}/${u}`)}}const hv=lr;
|
|
147718
|
+
}`;var b=_a(function(){return U(o,I+"return "+m).apply(i,f)});if(b.source=m,Ei(b))throw b;return b}function Ud(n){return W(n).toLowerCase()}function Wd(n){return W(n).toUpperCase()}function Fd(n,t,e){if(n=W(n),n&&(e||t===i))return ys(n);if(!n||!(t=ln(t)))return n;var r=On(n),s=On(t),o=Ss(r,s),f=Os(r,s)+1;return ut(r,o,f).join("")}function Md(n,t,e){if(n=W(n),n&&(e||t===i))return n.slice(0,bs(n)+1);if(!n||!(t=ln(t)))return n;var r=On(n),s=Os(r,On(t))+1;return ut(r,0,s).join("")}function qd(n,t,e){if(n=W(n),n&&(e||t===i))return n.replace(Er,"");if(!n||!(t=ln(t)))return n;var r=On(n),s=Ss(r,On(t));return ut(r,s).join("")}function Bd(n,t){var e=Da,r=Ha;if(K(t)){var s="separator"in t?t.separator:s;e="length"in t?R(t.length):e,r="omission"in t?ln(t.omission):r;}n=W(n);var o=n.length;if(Lt(n)){var f=On(n);o=f.length;}if(e>=o)return n;var c=e-Dt(r);if(c<1)return r;var l=f?ut(f,0,c).join(""):n.slice(0,c);if(s===i)return l+r;if(f&&(c+=l.length-c),yi(s)){if(n.slice(c).search(s)){var v,_=l;for(s.global||(s=Br(s.source,W(Ji.exec(s))+"g")),s.lastIndex=0;v=s.exec(_);)var m=v.index;l=l.slice(0,m===i?c:m);}}else if(n.indexOf(ln(s),c)!=c){var P=l.lastIndexOf(s);P>-1&&(l=l.slice(0,P));}return l+r}function Gd(n){return n=W(n),n&&ka.test(n)?n.replace(Ki,mf):n}var zd=Mt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Ri=mu("toUpperCase");function va(n,t,e){return n=W(n),t=e?i:t,t===i?pf(n)?Af(n):rf(n):n.match(t)||[]}var _a=T(function(n,t){try{return cn(n,i,t)}catch(e){return Ei(e)?e:new S(e)}}),Kd=Yn(function(n,t){return mn(t,function(e){e=Wn(e),zn(n,e,Ii(n[e],n));}),n});function Yd(n){var t=n==null?0:n.length,e=x();return n=t?G(n,function(r){if(typeof r[1]!="function")throw new wn(D);return [e(r[0]),r[1]]}):[],T(function(r){for(var s=-1;++s<t;){var o=n[s];if(cn(o[0],this,r))return cn(o[1],this,r)}})}function Zd(n){return mc(An(n,Ln))}function bi(n){return function(){return n}}function Jd(n,t){return n==null||n!==n?t:n}var Xd=Pu(),Qd=Pu(!0);function fn(n){return n}function Ti(n){return Qs(typeof n=="function"?n:An(n,Ln))}function Vd(n){return ks(An(n,Ln))}function kd(n,t){return js(n,An(t,Ln))}var jd=T(function(n,t){return function(e){return ae(e,n,t)}}),ng=T(function(n,t){return function(e){return ae(n,e,t)}});function Li(n,t,e){var r=V(t),s=ze(t,r);e==null&&!(K(t)&&(s.length||!r.length))&&(e=t,t=n,n=this,s=ze(t,V(t)));var o=!(K(e)&&"chain"in e)||!!e.chain,f=Jn(n);return mn(s,function(c){var l=t[c];n[c]=l,f&&(n.prototype[c]=function(){var v=this.__chain__;if(o||v){var _=n(this.__wrapped__),m=_.__actions__=un(this.__actions__);return m.push({func:l,args:arguments,thisArg:n}),_.__chain__=v,_}return l.apply(n,nt([this.value()],arguments))});}),n}function tg(){return k._===this&&(k._=Sf),this}function Di(){}function eg(n){return n=R(n),T(function(t){return nu(t,n)})}var rg=ci(G),ig=ci(As),sg=ci(Nr);function ma(n){return _i(n)?$r(Wn(n)):Nc(n)}function ug(n){return function(t){return n==null?i:_t(n,t)}}var ag=Cu(),og=Cu(!0);function Hi(){return []}function Ni(){return !1}function fg(){return {}}function cg(){return ""}function hg(){return !0}function lg(n,t){if(n=R(n),n<1||n>kn)return [];var e=Nn,r=nn(n,Nn);t=x(t),n-=Nn;for(var s=Fr(r,t);++e<n;)t(e);return s}function pg(n){return O(n)?G(n,Wn):pn(n)?[n]:un(Wu(W(n)))}function dg(n){var t=++Ef;return W(n)+t}var gg=Qe(function(n,t){return n+t},0),vg=hi("ceil"),_g=Qe(function(n,t){return n/t},1),mg=hi("floor");function wg(n){return n&&n.length?Ge(n,fn,Qr):i}function Pg(n,t){return n&&n.length?Ge(n,x(t,2),Qr):i}function Ag(n){return xs(n,fn)}function Cg(n,t){return xs(n,x(t,2))}function Ig(n){return n&&n.length?Ge(n,fn,ni):i}function xg(n,t){return n&&n.length?Ge(n,x(t,2),ni):i}var Eg=Qe(function(n,t){return n*t},1),yg=hi("round"),Sg=Qe(function(n,t){return n-t},0);function Og(n){return n&&n.length?Wr(n,fn):0}function Rg(n,t){return n&&n.length?Wr(n,x(t,2)):0}return a.after=Vl,a.ary=Xu,a.assign=Wp,a.assignIn=fa,a.assignInWith=fr,a.assignWith=Fp,a.at=Mp,a.before=Qu,a.bind=Ii,a.bindAll=Kd,a.bindKey=Vu,a.castArray=fp,a.chain=Yu,a.chunk=mh,a.compact=wh,a.concat=Ph,a.cond=Yd,a.conforms=Zd,a.constant=bi,a.countBy=Ol,a.create=qp,a.curry=ku,a.curryRight=ju,a.debounce=na,a.defaults=Bp,a.defaultsDeep=Gp,a.defer=kl,a.delay=jl,a.difference=Ah,a.differenceBy=Ch,a.differenceWith=Ih,a.drop=xh,a.dropRight=Eh,a.dropRightWhile=yh,a.dropWhile=Sh,a.fill=Oh,a.filter=bl,a.flatMap=Dl,a.flatMapDeep=Hl,a.flatMapDepth=Nl,a.flatten=Bu,a.flattenDeep=Rh,a.flattenDepth=bh,a.flip=np,a.flow=Xd,a.flowRight=Qd,a.fromPairs=Th,a.functions=Qp,a.functionsIn=Vp,a.groupBy=$l,a.initial=Dh,a.intersection=Hh,a.intersectionBy=Nh,a.intersectionWith=$h,a.invert=jp,a.invertBy=nd,a.invokeMap=Wl,a.iteratee=Ti,a.keyBy=Fl,a.keys=V,a.keysIn=on,a.map=rr,a.mapKeys=ed,a.mapValues=rd,a.matches=Vd,a.matchesProperty=kd,a.memoize=sr,a.merge=id,a.mergeWith=ca,a.method=jd,a.methodOf=ng,a.mixin=Li,a.negate=ur,a.nthArg=eg,a.omit=sd,a.omitBy=ud,a.once=tp,a.orderBy=Ml,a.over=rg,a.overArgs=ep,a.overEvery=ig,a.overSome=sg,a.partial=xi,a.partialRight=ta,a.partition=ql,a.pick=ad,a.pickBy=ha,a.property=ma,a.propertyOf=ug,a.pull=Mh,a.pullAll=zu,a.pullAllBy=qh,a.pullAllWith=Bh,a.pullAt=Gh,a.range=ag,a.rangeRight=og,a.rearg=rp,a.reject=zl,a.remove=zh,a.rest=ip,a.reverse=Ai,a.sampleSize=Yl,a.set=fd,a.setWith=cd,a.shuffle=Zl,a.slice=Kh,a.sortBy=Ql,a.sortedUniq=kh,a.sortedUniqBy=jh,a.split=Dd,a.spread=sp,a.tail=nl,a.take=tl,a.takeRight=el,a.takeRightWhile=rl,a.takeWhile=il,a.tap=wl,a.throttle=up,a.thru=er,a.toArray=ua,a.toPairs=la,a.toPairsIn=pa,a.toPath=pg,a.toPlainObject=oa,a.transform=hd,a.unary=ap,a.union=sl,a.unionBy=ul,a.unionWith=al,a.uniq=ol,a.uniqBy=fl,a.uniqWith=cl,a.unset=ld,a.unzip=Ci,a.unzipWith=Ku,a.update=pd,a.updateWith=dd,a.values=Gt,a.valuesIn=gd,a.without=hl,a.words=va,a.wrap=op,a.xor=ll,a.xorBy=pl,a.xorWith=dl,a.zip=gl,a.zipObject=vl,a.zipObjectDeep=_l,a.zipWith=ml,a.entries=la,a.entriesIn=pa,a.extend=fa,a.extendWith=fr,Li(a,a),a.add=gg,a.attempt=_a,a.camelCase=wd,a.capitalize=da,a.ceil=vg,a.clamp=vd,a.clone=cp,a.cloneDeep=lp,a.cloneDeepWith=pp,a.cloneWith=hp,a.conformsTo=dp,a.deburr=ga,a.defaultTo=Jd,a.divide=_g,a.endsWith=Pd,a.eq=bn,a.escape=Ad,a.escapeRegExp=Cd,a.every=Rl,a.find=Tl,a.findIndex=Mu,a.findKey=zp,a.findLast=Ll,a.findLastIndex=qu,a.findLastKey=Kp,a.floor=mg,a.forEach=Zu,a.forEachRight=Ju,a.forIn=Yp,a.forInRight=Zp,a.forOwn=Jp,a.forOwnRight=Xp,a.get=Si,a.gt=gp,a.gte=vp,a.has=kp,a.hasIn=Oi,a.head=Gu,a.identity=fn,a.includes=Ul,a.indexOf=Lh,a.inRange=_d,a.invoke=td,a.isArguments=Pt,a.isArray=O,a.isArrayBuffer=_p,a.isArrayLike=an,a.isArrayLikeObject=Z,a.isBoolean=mp,a.isBuffer=at,a.isDate=wp,a.isElement=Pp,a.isEmpty=Ap,a.isEqual=Cp,a.isEqualWith=Ip,a.isError=Ei,a.isFinite=xp,a.isFunction=Jn,a.isInteger=ea,a.isLength=ar,a.isMap=ra,a.isMatch=Ep,a.isMatchWith=yp,a.isNaN=Sp,a.isNative=Op,a.isNil=bp,a.isNull=Rp,a.isNumber=ia,a.isObject=K,a.isObjectLike=Y,a.isPlainObject=pe,a.isRegExp=yi,a.isSafeInteger=Tp,a.isSet=sa,a.isString=or,a.isSymbol=pn,a.isTypedArray=Bt,a.isUndefined=Lp,a.isWeakMap=Dp,a.isWeakSet=Hp,a.join=Uh,a.kebabCase=Id,a.last=In,a.lastIndexOf=Wh,a.lowerCase=xd,a.lowerFirst=Ed,a.lt=Np,a.lte=$p,a.max=wg,a.maxBy=Pg,a.mean=Ag,a.meanBy=Cg,a.min=Ig,a.minBy=xg,a.stubArray=Hi,a.stubFalse=Ni,a.stubObject=fg,a.stubString=cg,a.stubTrue=hg,a.multiply=Eg,a.nth=Fh,a.noConflict=tg,a.noop=Di,a.now=ir,a.pad=yd,a.padEnd=Sd,a.padStart=Od,a.parseInt=Rd,a.random=md,a.reduce=Bl,a.reduceRight=Gl,a.repeat=bd,a.replace=Td,a.result=od,a.round=yg,a.runInContext=h,a.sample=Kl,a.size=Jl,a.snakeCase=Ld,a.some=Xl,a.sortedIndex=Yh,a.sortedIndexBy=Zh,a.sortedIndexOf=Jh,a.sortedLastIndex=Xh,a.sortedLastIndexBy=Qh,a.sortedLastIndexOf=Vh,a.startCase=Hd,a.startsWith=Nd,a.subtract=Sg,a.sum=Og,a.sumBy=Rg,a.template=$d,a.times=lg,a.toFinite=Xn,a.toInteger=R,a.toLength=aa,a.toLower=Ud,a.toNumber=xn,a.toSafeInteger=Up,a.toString=W,a.toUpper=Wd,a.trim=Fd,a.trimEnd=Md,a.trimStart=qd,a.truncate=Bd,a.unescape=Gd,a.uniqueId=dg,a.upperCase=zd,a.upperFirst=Ri,a.each=Zu,a.eachRight=Ju,a.first=Gu,Li(a,function(){var n={};return $n(a,function(t,e){F.call(a.prototype,e)||(n[e]=t);}),n}(),{chain:!1}),a.VERSION=d,mn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a;}),mn(["drop","take"],function(n,t){N.prototype[n]=function(e){e=e===i?1:Q(R(e),0);var r=this.__filtered__&&!t?new N(this):this.clone();return r.__filtered__?r.__takeCount__=nn(e,r.__takeCount__):r.__views__.push({size:nn(e,Nn),type:n+(r.__dir__<0?"Right":"")}),r},N.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()};}),mn(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==Bi||e==Wa;N.prototype[n]=function(s){var o=this.clone();return o.__iteratees__.push({iteratee:x(s,3),type:e}),o.__filtered__=o.__filtered__||r,o};}),mn(["head","last"],function(n,t){var e="take"+(t?"Right":"");N.prototype[n]=function(){return this[e](1).value()[0]};}),mn(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");N.prototype[n]=function(){return this.__filtered__?new N(this):this[e](1)};}),N.prototype.compact=function(){return this.filter(fn)},N.prototype.find=function(n){return this.filter(n).head()},N.prototype.findLast=function(n){return this.reverse().find(n)},N.prototype.invokeMap=T(function(n,t){return typeof n=="function"?new N(this):this.map(function(e){return ae(e,n,t)})}),N.prototype.reject=function(n){return this.filter(ur(x(n)))},N.prototype.slice=function(n,t){n=R(n);var e=this;return e.__filtered__&&(n>0||t<0)?new N(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=R(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},N.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},N.prototype.toArray=function(){return this.take(Nn)},$n(N.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),s=a[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);s&&(a.prototype[t]=function(){var f=this.__wrapped__,c=r?[1]:arguments,l=f instanceof N,v=c[0],_=l||O(f),m=function(H){var $=s.apply(a,nt([H],c));return r&&P?$[0]:$};_&&e&&typeof v=="function"&&v.length!=1&&(l=_=!1);var P=this.__chain__,I=!!this.__actions__.length,E=o&&!P,b=l&&!I;if(!o&&_){f=b?f:new N(this);var y=n.apply(f,c);return y.__actions__.push({func:er,args:[m],thisArg:i}),new Pn(y,P)}return E&&b?n.apply(this,c):(y=this.thru(m),E?r?y.value()[0]:y.value():y)});}),mn(["pop","push","shift","sort","splice","unshift"],function(n){var t=Oe[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var s=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(O(o)?o:[],s)}return this[e](function(f){return t.apply(O(f)?f:[],s)})};}),$n(N.prototype,function(n,t){var e=a[t];if(e){var r=e.name+"";F.call(Ut,r)||(Ut[r]=[]),Ut[r].push({name:t,func:e});}}),Ut[Xe(i,ct).name]=[{name:"wrapper",func:i}],N.prototype.clone=Gf,N.prototype.reverse=zf,N.prototype.value=Kf,a.prototype.at=Pl,a.prototype.chain=Al,a.prototype.commit=Cl,a.prototype.next=Il,a.prototype.plant=El,a.prototype.reverse=yl,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Sl,a.prototype.first=a.prototype.head,ne&&(a.prototype[ne]=xl),a},Ht=Cf();lt?((lt.exports=Ht)._=Ht,Tr._=Ht):k._=Ht;}).call(ge$2);})(Ui$1,Ui$1.exports);var Gg$1=Object.defineProperty,zg$1=Object.defineProperties,Kg$1=Object.getOwnPropertyDescriptors,Ea$1=Object.getOwnPropertySymbols,Yg$1=Object.prototype.hasOwnProperty,Zg$1=Object.prototype.propertyIsEnumerable,ya$1=(A,u,i)=>u in A?Gg$1(A,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):A[u]=i,cr$2=(A,u)=>{for(var i in u||(u={}))Yg$1.call(u,i)&&ya$1(A,i,u[i]);if(Ea$1)for(var i of Ea$1(u))Zg$1.call(u,i)&&ya$1(A,i,u[i]);return A},Jg$1=(A,u)=>zg$1(A,Kg$1(u));function ft(A,u,i){var d;const w=ve$3(A);return ((d=u.rpcMap)==null?void 0:d[w.reference])||`${Bg$1}?chainId=${w.namespace}:${w.reference}&projectId=${i}`}function Ct(A){return A.includes(":")?A.split(":")[1]:A}function Sa$1(A){return A.map(u=>`${u.split(":")[0]}:${u.split(":")[1]}`)}function Xg$1(A,u){const i=Object.keys(u.namespaces).filter(w=>w.includes(A));if(!i.length)return [];const d=[];return i.forEach(w=>{const L=u.namespaces[w].accounts;d.push(...L);}),d}function Oa$1(A={},u={}){const i=Ra$1(A),d=Ra$1(u);return Ui$1.exports.merge(i,d)}function Ra$1(A){var u,i,d,w;const L={};if(!B$5(A))return L;for(const[D,En]of Object.entries(A)){const zt=oe$4(D)?[D]:En.chains,pr=En.methods||[],It=En.events||[],Ln=En.rpcMap||{},Fn=en(D);L[Fn]=Jg$1(cr$2(cr$2({},L[Fn]),En),{chains:S$6(zt,(u=L[Fn])==null?void 0:u.chains),methods:S$6(pr,(i=L[Fn])==null?void 0:i.methods),events:S$6(It,(d=L[Fn])==null?void 0:d.events),rpcMap:cr$2(cr$2({},Ln),(w=L[Fn])==null?void 0:w.rpcMap)});}return L}function Qg$1(A){return A.includes(":")?A.split(":")[2]:A}function Vg$1(A){const u={};for(const[i,d]of Object.entries(A)){const w=d.methods||[],L=d.events||[],D=d.accounts||[],En=oe$4(i)?[i]:d.chains?d.chains:Sa$1(d.accounts);u[i]={chains:En,methods:w,events:L,accounts:D};}return u}function Wi$1(A){return typeof A=="number"?A:A.includes("0x")?parseInt(A,16):(A=A.includes(":")?A.split(":")[1]:A,isNaN(Number(A))?A:Number(A))}const ba={},z$4=A=>ba[A],Fi$1=(A,u)=>{ba[A]=u;};let kg$1 = class kg{constructor(u){this.name="polkadot",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getAccounts(){const u=this.namespace.accounts;return u?u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}};let jg$1 = class jg{constructor(u){this.name="eip155",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain());}async request(u){switch(u.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(u);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(u.request.method)?await this.client.request(u):this.getHttpProvider().request(u.request)}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(parseInt(u),i),this.chainId=parseInt(u),this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}createHttpProvider(u,i){const d=i||ft(`${this.name}:${u}`,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=parseInt(Ct(i));u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}getHttpProvider(){const u=this.chainId,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}async handleSwitchChain(u){var i,d;let w=u.request.params?(i=u.request.params[0])==null?void 0:i.chainId:"0x0";w=w.startsWith("0x")?w:`0x${w}`;const L=parseInt(w,16);if(this.isChainApproved(L))this.setDefaultChain(`${L}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:u.topic,request:{method:u.request.method,params:[{chainId:w}]},chainId:(d=this.namespace.chains)==null?void 0:d[0]}),this.setDefaultChain(`${L}`);else throw new Error(`Failed to switch to chain 'eip155:${L}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(u){return this.namespace.chains.includes(`${this.name}:${u}`)}};class nv{constructor(u){this.name="solana",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class tv{constructor(u){this.name="cosmos",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class ev{constructor(u){this.name="cip34",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{const d=this.getCardanoRPCUrl(i),w=Ct(i);u[w]=this.createHttpProvider(w,d);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}getCardanoRPCUrl(u){const i=this.namespace.rpcMap;if(i)return i[u]}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||this.getCardanoRPCUrl(u);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class rv{constructor(u){this.name="elrond",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class iv{constructor(u){this.name="multiversx",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class sv{constructor(u){this.name="near",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){if(this.chainId=u,!this.httpProviders[u]){const d=i||ft(`${this.name}:${u}`,this.namespace);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);this.setHttpProvider(u,d);}this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;u[i]=this.createHttpProvider(i,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace);return typeof d>"u"?void 0:new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}var uv=Object.defineProperty,av=Object.defineProperties,ov=Object.getOwnPropertyDescriptors,Ta$1=Object.getOwnPropertySymbols,fv=Object.prototype.hasOwnProperty,cv=Object.prototype.propertyIsEnumerable,La$1=(A,u,i)=>u in A?uv(A,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):A[u]=i,hr$2=(A,u)=>{for(var i in u||(u={}))fv.call(u,i)&&La$1(A,i,u[i]);if(Ta$1)for(var i of Ta$1(u))cv.call(u,i)&&La$1(A,i,u[i]);return A},Mi$1=(A,u)=>av(A,ov(u));class lr{constructor(u){this.events=new EventEmitter$1,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=u,this.logger=typeof u?.logger<"u"&&typeof u?.logger!="string"?u.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:u?.logger||Ia$1})),this.disableProviderPing=u?.disableProviderPing||!1;}static async init(u){const i=new lr(u);return await i.initialize(),i}async request(u,i,d){const[w,L]=this.validateChain(i);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(w).request({request:hr$2({},u),chainId:`${w}:${L}`,topic:this.session.topic,expiry:d})}sendAsync(u,i,d,w){const L=new Date().getTime();this.request(u,d,w).then(D=>i(null,formatJsonRpcResult(L,D))).catch(D=>i(D,void 0));}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var u;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(u=this.session)==null?void 0:u.topic,reason:U$5("USER_DISCONNECTED")}),await this.cleanup();}async connect(u){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(u),await this.cleanupPendingPairings(),!u.skipPairing)return await this.pair(u.pairingTopic)}on(u,i){this.events.on(u,i);}once(u,i){this.events.once(u,i);}removeListener(u,i){this.events.removeListener(u,i);}off(u,i){this.events.off(u,i);}get isWalletConnect(){return !0}async pair(u){this.shouldAbortPairingAttempt=!1;let i=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(i>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:d,approval:w}=await this.client.connect({pairingTopic:u,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});d&&(this.uri=d,this.events.emit("display_uri",d)),await w().then(L=>{this.session=L;const D=Vg$1(L.namespaces);this.namespaces=Oa$1(this.namespaces,D),this.persist("namespaces",this.namespaces);}).catch(L=>{if(L.message!==ae$3)throw L;i++;});}while(!this.session);return this.onConnect(),this.session}setDefaultChain(u,i){try{if(!this.session)return;const[d,w]=this.validateChain(u);this.getProvider(d).setDefaultChain(w,i);}catch(d){if(!/Please call connect/.test(d.message))throw d}}async cleanupPendingPairings(u={}){this.logger.info("Cleaning up inactive pairings...");const i=this.client.pairing.getAll();if(k$4(i)){for(const d of i)u.deletePairings?this.client.core.expirer.set(d.topic,0):await this.client.core.relayer.subscriber.unsubscribe(d.topic);this.logger.info(`Inactive pairings cleared: ${i.length}`);}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0;}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const u=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[u]),this.createProviders();}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners();}async createClient(){this.client=this.providerOpts.client||await Q$4.init({logger:this.providerOpts.logger||Ia$1,relayUrl:this.providerOpts.relayUrl||Fg$1,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized");}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const u=[...new Set(Object.keys(this.session.namespaces).map(i=>en(i)))];Fi$1("client",this.client),Fi$1("events",this.events),Fi$1("disableProviderPing",this.disableProviderPing),u.forEach(i=>{if(!this.session)return;const d=Xg$1(i,this.session),w=Sa$1(d),L=Oa$1(this.namespaces,this.optionalNamespaces),D=Mi$1(hr$2({},L[i]),{accounts:d,chains:w});switch(i){case"eip155":this.rpcProviders[i]=new jg$1({namespace:D});break;case"solana":this.rpcProviders[i]=new nv({namespace:D});break;case"cosmos":this.rpcProviders[i]=new tv({namespace:D});break;case"polkadot":this.rpcProviders[i]=new kg$1({namespace:D});break;case"cip34":this.rpcProviders[i]=new ev({namespace:D});break;case"elrond":this.rpcProviders[i]=new rv({namespace:D});break;case"multiversx":this.rpcProviders[i]=new iv({namespace:D});break;case"near":this.rpcProviders[i]=new sv({namespace:D});break}});}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",u=>{this.events.emit("session_ping",u);}),this.client.on("session_event",u=>{const{params:i}=u,{event:d}=i;if(d.name==="accountsChanged"){const w=d.data;w&&k$4(w)&&this.events.emit("accountsChanged",w.map(Qg$1));}else if(d.name==="chainChanged"){const w=i.chainId,L=i.event.data,D=en(w),En=Wi$1(w)!==Wi$1(L)?`${D}:${Wi$1(L)}`:w;this.onChainChanged(En);}else this.events.emit(d.name,d.data);this.events.emit("session_event",u);}),this.client.on("session_update",({topic:u,params:i})=>{var d;const{namespaces:w}=i,L=(d=this.client)==null?void 0:d.session.get(u);this.session=Mi$1(hr$2({},L),{namespaces:w}),this.onSessionUpdate(),this.events.emit("session_update",{topic:u,params:i});}),this.client.on("session_delete",async u=>{await this.cleanup(),this.events.emit("session_delete",u),this.events.emit("disconnect",Mi$1(hr$2({},U$5("USER_DISCONNECTED")),{data:u.topic}));}),this.on(Vn.DEFAULT_CHAIN_CHANGED,u=>{this.onChainChanged(u,!0);});}getProvider(u){if(!this.rpcProviders[u])throw new Error(`Provider not found: ${u}`);return this.rpcProviders[u]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(u=>{var i;this.getProvider(u).updateNamespace((i=this.session)==null?void 0:i.namespaces[u]);});}setNamespaces(u){const{namespaces:i,optionalNamespaces:d,sessionProperties:w}=u;i&&Object.keys(i).length&&(this.namespaces=i),d&&Object.keys(d).length&&(this.optionalNamespaces=d),this.sessionProperties=w,this.persist("namespaces",i),this.persist("optionalNamespaces",d);}validateChain(u){const[i,d]=u?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return [i,d];if(i&&!Object.keys(this.namespaces||{}).map(D=>en(D)).includes(i))throw new Error(`Namespace '${i}' is not configured. Please call connect() first with namespace config.`);if(i&&d)return [i,d];const w=en(Object.keys(this.namespaces)[0]),L=this.rpcProviders[w].getDefaultChain();return [w,L]}async requestAccounts(){const[u]=this.validateChain();return await this.getProvider(u).requestAccounts()}onChainChanged(u,i=!1){if(!this.namespaces)return;const[d,w]=this.validateChain(u);w&&(i||this.getProvider(d).setDefaultChain(w),this.namespaces[d]?this.namespaces[d].defaultChain=w:this.namespaces[`${d}:${w}`]?this.namespaces[`${d}:${w}`].defaultChain=w:this.namespaces[`${d}:${w}`]={defaultChain:w},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",w));}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session});}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0});}persist(u,i){this.client.core.storage.setItem(`${xa}/${u}`,i);}async getFromStore(u){return await this.client.core.storage.getItem(`${xa}/${u}`)}}const hv=lr;
|
|
147719
147719
|
|
|
147720
|
-
const P$2="wc",S$4="ethereum_provider",$$1=`${P$2}@2:${S$4}:`,j$1="https://rpc.walletconnect.com/v1/",u$3=["eth_sendTransaction","personal_sign"],E$2=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],m$4=["chainChanged","accountsChanged"],_$2=["chainChanged","accountsChanged","message","disconnect","connect"];var N$2=Object.defineProperty,q$4=Object.defineProperties,D$3=Object.getOwnPropertyDescriptors,y$4=Object.getOwnPropertySymbols,U$3=Object.prototype.hasOwnProperty,Q$3=Object.prototype.propertyIsEnumerable,O$1=(a,t,s)=>t in a?N$2(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,p$7=(a,t)=>{for(var s in t||(t={}))U$3.call(t,s)&&O$1(a,s,t[s]);if(y$4)for(var s of y$4(t))Q$3.call(t,s)&&O$1(a,s,t[s]);return a},M$3=(a,t)=>q$4(a,D$3(t));function g$4(a){return Number(a[0].split(":")[1])}function f$7(a){return `0x${a.toString(16)}`}function L$4(a){const{chains:t,optionalChains:s,methods:i,optionalMethods:n,events:e,optionalEvents:h,rpcMap:c}=a;if(!k$4(t))throw new Error("Invalid chains");const o={chains:t,methods:i||u$3,events:e||m$4,rpcMap:p$7({},t.length?{[g$4(t)]:c[g$4(t)]}:{})},r=e?.filter(l=>!m$4.includes(l)),d=i?.filter(l=>!u$3.includes(l));if(!s&&!h&&!n&&!(r!=null&&r.length)&&!(d!=null&&d.length))return {required:t.length?o:void 0};const C=r?.length&&d?.length||!s,I={chains:[...new Set(C?o.chains.concat(s||[]):s)],methods:[...new Set(o.methods.concat(n!=null&&n.length?n:E$2))],events:[...new Set(o.events.concat(h!=null&&h.length?h:_$2))],rpcMap:c};return {required:t.length?o:void 0,optional:s.length?I:void 0}}let v$5 = class v{constructor(){this.events=new EventEmitter$
|
|
147720
|
+
const P$2="wc",S$4="ethereum_provider",$$1=`${P$2}@2:${S$4}:`,j$1="https://rpc.walletconnect.com/v1/",u$3=["eth_sendTransaction","personal_sign"],E$2=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],m$4=["chainChanged","accountsChanged"],_$2=["chainChanged","accountsChanged","message","disconnect","connect"];var N$2=Object.defineProperty,q$4=Object.defineProperties,D$3=Object.getOwnPropertyDescriptors,y$4=Object.getOwnPropertySymbols,U$3=Object.prototype.hasOwnProperty,Q$3=Object.prototype.propertyIsEnumerable,O$1=(a,t,s)=>t in a?N$2(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,p$7=(a,t)=>{for(var s in t||(t={}))U$3.call(t,s)&&O$1(a,s,t[s]);if(y$4)for(var s of y$4(t))Q$3.call(t,s)&&O$1(a,s,t[s]);return a},M$3=(a,t)=>q$4(a,D$3(t));function g$4(a){return Number(a[0].split(":")[1])}function f$7(a){return `0x${a.toString(16)}`}function L$4(a){const{chains:t,optionalChains:s,methods:i,optionalMethods:n,events:e,optionalEvents:h,rpcMap:c}=a;if(!k$4(t))throw new Error("Invalid chains");const o={chains:t,methods:i||u$3,events:e||m$4,rpcMap:p$7({},t.length?{[g$4(t)]:c[g$4(t)]}:{})},r=e?.filter(l=>!m$4.includes(l)),d=i?.filter(l=>!u$3.includes(l));if(!s&&!h&&!n&&!(r!=null&&r.length)&&!(d!=null&&d.length))return {required:t.length?o:void 0};const C=r?.length&&d?.length||!s,I={chains:[...new Set(C?o.chains.concat(s||[]):s)],methods:[...new Set(o.methods.concat(n!=null&&n.length?n:E$2))],events:[...new Set(o.events.concat(h!=null&&h.length?h:_$2))],rpcMap:c};return {required:t.length?o:void 0,optional:s.length?I:void 0}}let v$5 = class v{constructor(){this.events=new EventEmitter$1,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=$$1,this.on=(t,s)=>(this.events.on(t,s),this),this.once=(t,s)=>(this.events.once(t,s),this),this.removeListener=(t,s)=>(this.events.removeListener(t,s),this),this.off=(t,s)=>(this.events.off(t,s),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={};}static async init(t){const s=new v;return await s.initialize(t),s}async request(t,s){return await this.signer.request(t,this.formatChainId(this.chainId),s)}sendAsync(t,s,i){this.signer.sendAsync(t,s,this.formatChainId(this.chainId),i);}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:s,optional:i}=L$4(this.rpc);try{const n=await new Promise(async(h,c)=>{var o;this.rpc.showQrModal&&((o=this.modal)==null||o.subscribeModal(r=>{!r.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")));})),await this.signer.connect(M$3(p$7({namespaces:p$7({},s&&{[this.namespace]:s})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:t?.pairingTopic})).then(r=>{h(r);}).catch(r=>{c(new Error(r.message));});});if(!n)return;const e=Un(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:e),this.setAccounts(e),this.events.emit("connect",{chainId:f$7(this.chainId)});}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal();}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset();}get isWalletConnect(){return !0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:s}=t,{event:i}=s;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",t);}),this.signer.on("chainChanged",t=>{const s=parseInt(t);this.chainId=s,this.events.emit("chainChanged",f$7(this.chainId)),this.persist();}),this.signer.on("session_update",t=>{this.events.emit("session_update",t);}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",M$3(p$7({},U$5("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}));}),this.signer.on("display_uri",t=>{var s,i;this.rpc.showQrModal&&((s=this.modal)==null||s.closeModal(),(i=this.modal)==null||i.openModal({uri:t})),this.events.emit("display_uri",t);});}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]});}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return `${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const s=t.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));s.length&&(this.chainId=s[0],this.events.emit("chainChanged",f$7(this.chainId)),this.persist());}setChainId(t){if(this.isCompatibleChainId(t)){const s=this.parseChainId(t);this.chainId=s,this.switchEthereumChain(s);}}parseAccountId(t){const[s,i,n]=t.split(":");return {chainId:`${s}:${i}`,address:n}}setAccounts(t){this.accounts=t.filter(s=>this.parseChainId(this.parseAccountId(s).chainId)===this.chainId).map(s=>this.parseAccountId(s).address),this.events.emit("accountsChanged",this.accounts);}getRpcConfig(t){var s,i;const n=(s=t?.chains)!=null?s:[],e=(i=t?.optionalChains)!=null?i:[],h=n.concat(e);if(!h.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const c=n.length?t?.methods||u$3:[],o=n.length?t?.events||m$4:[],r=t?.optionalMethods||[],d=t?.optionalEvents||[],C=t?.rpcMap||this.buildRpcMap(h,t.projectId),I=t?.qrModalOptions||void 0;return {chains:n?.map(l=>this.formatChainId(l)),optionalChains:e.map(l=>this.formatChainId(l)),methods:c,events:o,optionalMethods:r,optionalEvents:d,rpcMap:C,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:I,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,s){const i={};return t.forEach(n=>{i[n]=this.getRpcUrl(n,s);}),i}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?g$4(this.rpc.chains):g$4(this.rpc.optionalChains),this.signer=await hv.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let s;try{const{WalletConnectModal:i}=await Promise.resolve().then(function () { return index$9; });s=i;}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(s)try{this.modal=new s(p$7({projectId:this.rpc.projectId},this.rpc.qrModalOptions));}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:s,optionalChains:i,rpcMap:n}=t;s&&k$4(s)&&(this.rpc.chains=s.map(e=>this.formatChainId(e)),s.forEach(e=>{this.rpc.rpcMap[e]=n?.[e]||this.getRpcUrl(e);})),i&&k$4(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i?.map(e=>this.formatChainId(e)),i.forEach(e=>{this.rpc.rpcMap[e]=n?.[e]||this.getRpcUrl(e);}));}getRpcUrl(t,s){var i;return ((i=this.rpc.rpcMap)==null?void 0:i[t])||`${j$1}?chainId=eip155:${t}&projectId=${s||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),s=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:s?.accounts),this.setAccounts(s?.accounts);}reset(){this.chainId=1,this.accounts=[];}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId);}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(s=>this.parseAccount(s))}};
|
|
147721
147721
|
|
|
147722
147722
|
const walletConnectProviderInfo = {
|
|
147723
147723
|
name: 'Other',
|
|
@@ -189375,7 +189375,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
189375
189375
|
} (eventemitter3));
|
|
189376
189376
|
|
|
189377
189377
|
var eventemitter3Exports = eventemitter3.exports;
|
|
189378
|
-
var EventEmitter
|
|
189378
|
+
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
|
189379
189379
|
|
|
189380
189380
|
class TransmuxerInterface {
|
|
189381
189381
|
constructor(hls, id, onTransmuxComplete, onFlush) {
|
|
@@ -189408,7 +189408,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
189408
189408
|
};
|
|
189409
189409
|
|
|
189410
189410
|
// forward events to main thread
|
|
189411
|
-
this.observer = new EventEmitter
|
|
189411
|
+
this.observer = new EventEmitter();
|
|
189412
189412
|
this.observer.on(Events.FRAG_DECRYPTED, forwardMessage);
|
|
189413
189413
|
this.observer.on(Events.ERROR, forwardMessage);
|
|
189414
189414
|
const MediaSource = getMediaSource(config.preferManagedMediaSource) || {
|
|
@@ -196417,7 +196417,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
196417
196417
|
}
|
|
196418
196418
|
const keyId = this.getKeyIdString(context.decryptdata);
|
|
196419
196419
|
this.log(`Generating key-session request for "${reason}": ${keyId} (init data type: ${initDataType} length: ${initData ? initData.byteLength : null})`);
|
|
196420
|
-
const licenseStatus = new EventEmitter
|
|
196420
|
+
const licenseStatus = new EventEmitter();
|
|
196421
196421
|
const onmessage = context._onmessage = event => {
|
|
196422
196422
|
const keySession = context.mediaKeysSession;
|
|
196423
196423
|
if (!keySession) {
|
|
@@ -201833,7 +201833,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
201833
201833
|
this.coreComponents = void 0;
|
|
201834
201834
|
this.networkControllers = void 0;
|
|
201835
201835
|
this.started = false;
|
|
201836
|
-
this._emitter = new EventEmitter
|
|
201836
|
+
this._emitter = new EventEmitter();
|
|
201837
201837
|
this._autoLevelCapping = -1;
|
|
201838
201838
|
this._maxHdcpLevel = null;
|
|
201839
201839
|
this.abrController = void 0;
|
|
@@ -246998,11 +246998,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
246998
246998
|
|
|
246999
246999
|
const SQUID_SDK_BASE_URL = 'https://apiplus.squidrouter.com';
|
|
247000
247000
|
const SQUID_NATIVE_TOKEN = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
247001
|
-
const APPROVE_TXN_ANIMATION = '/access_coins.riv';
|
|
247002
|
-
const EXECUTE_TXN_ANIMATION = '/swapping_coins.riv';
|
|
247003
|
-
const TOOLKIT_SQUID_URL = 'https://toolkit.immutable.com/squid-bridge/';
|
|
247004
|
-
const FIXED_HANDOVER_DURATION = 2000;
|
|
247005
|
-
const TOKEN_PRIORITY_ORDER = ['IMX', 'USDC', 'ETH'];
|
|
247006
247001
|
|
|
247007
247002
|
const BASE_SLIPPAGE_HIGH_TIER = 0.005;
|
|
247008
247003
|
const BASE_SLIPPAGE_MEDIUM_TIER = 0.01;
|
|
@@ -250385,6 +250380,12 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
250385
250380
|
}, children: t(`views.ADD_TOKENS.onboarding.screen${screenIndex}.title`) }), jsx$1(OnboardingPagination, { disabled: true, size: "small", currentPage: screenIndex, totalPages: 3, sx: { mt: 'base.spacing.x11', mb: 'base.spacing.x8' } }), jsx$1(Button, { variant: screenIndex === 3 ? 'primary' : 'tertiary', onClick: handleCtaOnClick, size: "large", sx: { alignSelf: 'stretch' }, children: t(`views.ADD_TOKENS.onboarding.screen${screenIndex}.buttonText`) })] }) }));
|
|
250386
250381
|
}
|
|
250387
250382
|
|
|
250383
|
+
const FIXED_HANDOVER_DURATION = 2000;
|
|
250384
|
+
const APPROVE_TXN_ANIMATION = '/access_coins.riv';
|
|
250385
|
+
const EXECUTE_TXN_ANIMATION = '/swapping_coins.riv';
|
|
250386
|
+
const TOKEN_PRIORITY_ORDER = ['IMX', 'USDC', 'ETH'];
|
|
250387
|
+
const TOOLKIT_SQUID_URL = 'https://toolkit.immutable.com/squid-bridge/';
|
|
250388
|
+
|
|
250388
250389
|
function HandoverContent({ headingText, subheadingText, primaryButtonText, onPrimaryButtonClick, secondaryButtonText, onSecondaryButtonClick, }) {
|
|
250389
250390
|
return (jsxs(Box, { sx: {
|
|
250390
250391
|
height: '100%',
|
|
@@ -273422,11 +273423,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
273422
273423
|
|
|
273423
273424
|
var utf8$6 = {};
|
|
273424
273425
|
|
|
273425
|
-
var hasRequiredUtf8$
|
|
273426
|
+
var hasRequiredUtf8$2;
|
|
273426
273427
|
|
|
273427
|
-
function requireUtf8$
|
|
273428
|
-
if (hasRequiredUtf8$
|
|
273429
|
-
hasRequiredUtf8$
|
|
273428
|
+
function requireUtf8$2 () {
|
|
273429
|
+
if (hasRequiredUtf8$2) return utf8$6;
|
|
273430
|
+
hasRequiredUtf8$2 = 1;
|
|
273430
273431
|
(function (exports) {
|
|
273431
273432
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
273432
273433
|
exports.toUtf8CodePoints = exports.toUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = void 0;
|
|
@@ -273744,7 +273745,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
273744
273745
|
const data_js_1 = requireData$1();
|
|
273745
273746
|
const errors_js_1 = requireErrors$1();
|
|
273746
273747
|
const properties_js_1 = requireProperties$1();
|
|
273747
|
-
const utf8_js_1 = requireUtf8$
|
|
273748
|
+
const utf8_js_1 = requireUtf8$2();
|
|
273748
273749
|
const geturl_js_1 = requireGeturlBrowser$1();
|
|
273749
273750
|
const MAX_ATTEMPTS = 12;
|
|
273750
273751
|
const SLOT_INTERVAL = 250;
|
|
@@ -275468,7 +275469,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
275468
275469
|
Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return units_js_1.parseEther; } });
|
|
275469
275470
|
Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return units_js_1.formatUnits; } });
|
|
275470
275471
|
Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return units_js_1.parseUnits; } });
|
|
275471
|
-
var utf8_js_1 = requireUtf8$
|
|
275472
|
+
var utf8_js_1 = requireUtf8$2();
|
|
275472
275473
|
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return utf8_js_1.toUtf8Bytes; } });
|
|
275473
275474
|
Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return utf8_js_1.toUtf8CodePoints; } });
|
|
275474
275475
|
Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return utf8_js_1.toUtf8String; } });
|
|
@@ -280262,7 +280263,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
280262
280263
|
hasRequiredString$1 = 1;
|
|
280263
280264
|
Object.defineProperty(string$1, "__esModule", { value: true });
|
|
280264
280265
|
string$1.StringCoder = void 0;
|
|
280265
|
-
const utf8_js_1 = requireUtf8$
|
|
280266
|
+
const utf8_js_1 = requireUtf8$2();
|
|
280266
280267
|
const typed_js_1 = requireTyped$1();
|
|
280267
280268
|
const bytes_js_1 = requireBytes$1();
|
|
280268
280269
|
/**
|
|
@@ -288467,15 +288468,15 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
288467
288468
|
return contract$2;
|
|
288468
288469
|
}
|
|
288469
288470
|
|
|
288470
|
-
var factory$
|
|
288471
|
+
var factory$1 = {};
|
|
288471
288472
|
|
|
288472
288473
|
var hasRequiredFactory$1;
|
|
288473
288474
|
|
|
288474
288475
|
function requireFactory$1 () {
|
|
288475
|
-
if (hasRequiredFactory$1) return factory$
|
|
288476
|
+
if (hasRequiredFactory$1) return factory$1;
|
|
288476
288477
|
hasRequiredFactory$1 = 1;
|
|
288477
|
-
Object.defineProperty(factory$
|
|
288478
|
-
factory$
|
|
288478
|
+
Object.defineProperty(factory$1, "__esModule", { value: true });
|
|
288479
|
+
factory$1.ContractFactory = void 0;
|
|
288479
288480
|
const index_js_1 = requireAbi$1();
|
|
288480
288481
|
const index_js_2 = requireAddress$6();
|
|
288481
288482
|
const index_js_3 = requireUtils$5();
|
|
@@ -288587,9 +288588,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
288587
288588
|
return new this(abi, bytecode, runner);
|
|
288588
288589
|
}
|
|
288589
288590
|
}
|
|
288590
|
-
factory$
|
|
288591
|
+
factory$1.ContractFactory = ContractFactory;
|
|
288591
288592
|
|
|
288592
|
-
return factory$
|
|
288593
|
+
return factory$1;
|
|
288593
288594
|
}
|
|
288594
288595
|
|
|
288595
288596
|
var hasRequiredContract$2;
|
|
@@ -299787,11 +299788,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
299787
299788
|
|
|
299788
299789
|
var utf8$5 = {};
|
|
299789
299790
|
|
|
299790
|
-
var hasRequiredUtf8;
|
|
299791
|
+
var hasRequiredUtf8$1;
|
|
299791
299792
|
|
|
299792
|
-
function requireUtf8 () {
|
|
299793
|
-
if (hasRequiredUtf8) return utf8$5;
|
|
299794
|
-
hasRequiredUtf8 = 1;
|
|
299793
|
+
function requireUtf8$1 () {
|
|
299794
|
+
if (hasRequiredUtf8$1) return utf8$5;
|
|
299795
|
+
hasRequiredUtf8$1 = 1;
|
|
299795
299796
|
(function (exports) {
|
|
299796
299797
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
299797
299798
|
exports.toUtf8CodePoints = exports.toUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = void 0;
|
|
@@ -300127,7 +300128,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
300127
300128
|
const data_js_1 = requireData();
|
|
300128
300129
|
const errors_js_1 = requireErrors();
|
|
300129
300130
|
const properties_js_1 = requireProperties();
|
|
300130
|
-
const utf8_js_1 = requireUtf8();
|
|
300131
|
+
const utf8_js_1 = requireUtf8$1();
|
|
300131
300132
|
const geturl_js_1 = requireGeturlBrowser();
|
|
300132
300133
|
const MAX_ATTEMPTS = 12;
|
|
300133
300134
|
const SLOT_INTERVAL = 250;
|
|
@@ -301867,7 +301868,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
301867
301868
|
Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return units_js_1.parseEther; } });
|
|
301868
301869
|
Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return units_js_1.formatUnits; } });
|
|
301869
301870
|
Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return units_js_1.parseUnits; } });
|
|
301870
|
-
var utf8_js_1 = requireUtf8();
|
|
301871
|
+
var utf8_js_1 = requireUtf8$1();
|
|
301871
301872
|
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return utf8_js_1.toUtf8Bytes; } });
|
|
301872
301873
|
Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return utf8_js_1.toUtf8CodePoints; } });
|
|
301873
301874
|
Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return utf8_js_1.toUtf8String; } });
|
|
@@ -306726,7 +306727,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
306726
306727
|
hasRequiredString = 1;
|
|
306727
306728
|
Object.defineProperty(string, "__esModule", { value: true });
|
|
306728
306729
|
string.StringCoder = void 0;
|
|
306729
|
-
const utf8_js_1 = requireUtf8();
|
|
306730
|
+
const utf8_js_1 = requireUtf8$1();
|
|
306730
306731
|
const typed_js_1 = requireTyped();
|
|
306731
306732
|
const bytes_js_1 = requireBytes();
|
|
306732
306733
|
/**
|
|
@@ -315347,15 +315348,15 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
315347
315348
|
return contract;
|
|
315348
315349
|
}
|
|
315349
315350
|
|
|
315350
|
-
var factory
|
|
315351
|
+
var factory = {};
|
|
315351
315352
|
|
|
315352
315353
|
var hasRequiredFactory;
|
|
315353
315354
|
|
|
315354
315355
|
function requireFactory () {
|
|
315355
|
-
if (hasRequiredFactory) return factory
|
|
315356
|
+
if (hasRequiredFactory) return factory;
|
|
315356
315357
|
hasRequiredFactory = 1;
|
|
315357
|
-
Object.defineProperty(factory
|
|
315358
|
-
factory
|
|
315358
|
+
Object.defineProperty(factory, "__esModule", { value: true });
|
|
315359
|
+
factory.ContractFactory = void 0;
|
|
315359
315360
|
const index_js_1 = requireAbi();
|
|
315360
315361
|
const index_js_2 = requireAddress$2();
|
|
315361
315362
|
const index_js_3 = requireUtils$2();
|
|
@@ -315467,9 +315468,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
315467
315468
|
return new this(abi, bytecode, runner);
|
|
315468
315469
|
}
|
|
315469
315470
|
}
|
|
315470
|
-
factory
|
|
315471
|
+
factory.ContractFactory = ContractFactory;
|
|
315471
315472
|
|
|
315472
|
-
return factory
|
|
315473
|
+
return factory;
|
|
315473
315474
|
}
|
|
315474
315475
|
|
|
315475
315476
|
var hasRequiredContract;
|
|
@@ -326815,783 +326816,838 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
326815
326816
|
|
|
326816
326817
|
var minimal$1 = {};
|
|
326817
326818
|
|
|
326818
|
-
var aspromise
|
|
326819
|
+
var aspromise;
|
|
326820
|
+
var hasRequiredAspromise;
|
|
326821
|
+
|
|
326822
|
+
function requireAspromise () {
|
|
326823
|
+
if (hasRequiredAspromise) return aspromise;
|
|
326824
|
+
hasRequiredAspromise = 1;
|
|
326825
|
+
aspromise = asPromise;
|
|
326819
326826
|
|
|
326820
|
-
|
|
326821
|
-
|
|
326822
|
-
|
|
326823
|
-
|
|
326824
|
-
|
|
326825
|
-
|
|
326826
|
-
|
|
326827
|
-
|
|
326827
|
+
/**
|
|
326828
|
+
* Callback as used by {@link util.asPromise}.
|
|
326829
|
+
* @typedef asPromiseCallback
|
|
326830
|
+
* @type {function}
|
|
326831
|
+
* @param {Error|null} error Error, if any
|
|
326832
|
+
* @param {...*} params Additional arguments
|
|
326833
|
+
* @returns {undefined}
|
|
326834
|
+
*/
|
|
326828
326835
|
|
|
326829
|
-
|
|
326830
|
-
|
|
326831
|
-
|
|
326832
|
-
|
|
326833
|
-
|
|
326834
|
-
|
|
326835
|
-
|
|
326836
|
-
|
|
326837
|
-
|
|
326838
|
-
|
|
326839
|
-
|
|
326840
|
-
|
|
326841
|
-
|
|
326842
|
-
|
|
326843
|
-
|
|
326844
|
-
|
|
326845
|
-
|
|
326846
|
-
|
|
326847
|
-
|
|
326848
|
-
|
|
326849
|
-
|
|
326850
|
-
|
|
326851
|
-
|
|
326852
|
-
|
|
326853
|
-
|
|
326854
|
-
|
|
326855
|
-
|
|
326856
|
-
|
|
326857
|
-
|
|
326858
|
-
|
|
326859
|
-
|
|
326860
|
-
|
|
326861
|
-
|
|
326862
|
-
|
|
326863
|
-
|
|
326864
|
-
|
|
326865
|
-
|
|
326866
|
-
|
|
326867
|
-
|
|
326836
|
+
/**
|
|
326837
|
+
* Returns a promise from a node-style callback function.
|
|
326838
|
+
* @memberof util
|
|
326839
|
+
* @param {asPromiseCallback} fn Function to call
|
|
326840
|
+
* @param {*} ctx Function context
|
|
326841
|
+
* @param {...*} params Function arguments
|
|
326842
|
+
* @returns {Promise<*>} Promisified function
|
|
326843
|
+
*/
|
|
326844
|
+
function asPromise(fn, ctx/*, varargs */) {
|
|
326845
|
+
var params = new Array(arguments.length - 1),
|
|
326846
|
+
offset = 0,
|
|
326847
|
+
index = 2,
|
|
326848
|
+
pending = true;
|
|
326849
|
+
while (index < arguments.length)
|
|
326850
|
+
params[offset++] = arguments[index++];
|
|
326851
|
+
return new Promise(function executor(resolve, reject) {
|
|
326852
|
+
params[offset] = function callback(err/*, varargs */) {
|
|
326853
|
+
if (pending) {
|
|
326854
|
+
pending = false;
|
|
326855
|
+
if (err)
|
|
326856
|
+
reject(err);
|
|
326857
|
+
else {
|
|
326858
|
+
var params = new Array(arguments.length - 1),
|
|
326859
|
+
offset = 0;
|
|
326860
|
+
while (offset < params.length)
|
|
326861
|
+
params[offset++] = arguments[offset];
|
|
326862
|
+
resolve.apply(null, params);
|
|
326863
|
+
}
|
|
326864
|
+
}
|
|
326865
|
+
};
|
|
326866
|
+
try {
|
|
326867
|
+
fn.apply(ctx || null, params);
|
|
326868
|
+
} catch (err) {
|
|
326869
|
+
if (pending) {
|
|
326870
|
+
pending = false;
|
|
326871
|
+
reject(err);
|
|
326872
|
+
}
|
|
326873
|
+
}
|
|
326874
|
+
});
|
|
326875
|
+
}
|
|
326876
|
+
return aspromise;
|
|
326868
326877
|
}
|
|
326869
326878
|
|
|
326870
326879
|
var base64$2 = {};
|
|
326871
326880
|
|
|
326872
|
-
|
|
326881
|
+
var hasRequiredBase64;
|
|
326882
|
+
|
|
326883
|
+
function requireBase64 () {
|
|
326884
|
+
if (hasRequiredBase64) return base64$2;
|
|
326885
|
+
hasRequiredBase64 = 1;
|
|
326886
|
+
(function (exports) {
|
|
326873
326887
|
|
|
326874
|
-
|
|
326875
|
-
|
|
326876
|
-
|
|
326877
|
-
|
|
326878
|
-
|
|
326879
|
-
|
|
326888
|
+
/**
|
|
326889
|
+
* A minimal base64 implementation for number arrays.
|
|
326890
|
+
* @memberof util
|
|
326891
|
+
* @namespace
|
|
326892
|
+
*/
|
|
326893
|
+
var base64 = exports;
|
|
326894
|
+
|
|
326895
|
+
/**
|
|
326896
|
+
* Calculates the byte length of a base64 encoded string.
|
|
326897
|
+
* @param {string} string Base64 encoded string
|
|
326898
|
+
* @returns {number} Byte length
|
|
326899
|
+
*/
|
|
326900
|
+
base64.length = function length(string) {
|
|
326901
|
+
var p = string.length;
|
|
326902
|
+
if (!p)
|
|
326903
|
+
return 0;
|
|
326904
|
+
var n = 0;
|
|
326905
|
+
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
326906
|
+
++n;
|
|
326907
|
+
return Math.ceil(string.length * 3) / 4 - n;
|
|
326908
|
+
};
|
|
326880
326909
|
|
|
326881
|
-
|
|
326882
|
-
|
|
326883
|
-
|
|
326884
|
-
|
|
326885
|
-
|
|
326886
|
-
|
|
326887
|
-
|
|
326888
|
-
|
|
326889
|
-
|
|
326890
|
-
|
|
326891
|
-
|
|
326892
|
-
|
|
326893
|
-
|
|
326894
|
-
|
|
326910
|
+
// Base64 encoding table
|
|
326911
|
+
var b64 = new Array(64);
|
|
326912
|
+
|
|
326913
|
+
// Base64 decoding table
|
|
326914
|
+
var s64 = new Array(123);
|
|
326915
|
+
|
|
326916
|
+
// 65..90, 97..122, 48..57, 43, 47
|
|
326917
|
+
for (var i = 0; i < 64;)
|
|
326918
|
+
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
|
|
326919
|
+
|
|
326920
|
+
/**
|
|
326921
|
+
* Encodes a buffer to a base64 encoded string.
|
|
326922
|
+
* @param {Uint8Array} buffer Source buffer
|
|
326923
|
+
* @param {number} start Source start
|
|
326924
|
+
* @param {number} end Source end
|
|
326925
|
+
* @returns {string} Base64 encoded string
|
|
326926
|
+
*/
|
|
326927
|
+
base64.encode = function encode(buffer, start, end) {
|
|
326928
|
+
var parts = null,
|
|
326929
|
+
chunk = [];
|
|
326930
|
+
var i = 0, // output index
|
|
326931
|
+
j = 0, // goto index
|
|
326932
|
+
t; // temporary
|
|
326933
|
+
while (start < end) {
|
|
326934
|
+
var b = buffer[start++];
|
|
326935
|
+
switch (j) {
|
|
326936
|
+
case 0:
|
|
326937
|
+
chunk[i++] = b64[b >> 2];
|
|
326938
|
+
t = (b & 3) << 4;
|
|
326939
|
+
j = 1;
|
|
326940
|
+
break;
|
|
326941
|
+
case 1:
|
|
326942
|
+
chunk[i++] = b64[t | b >> 4];
|
|
326943
|
+
t = (b & 15) << 2;
|
|
326944
|
+
j = 2;
|
|
326945
|
+
break;
|
|
326946
|
+
case 2:
|
|
326947
|
+
chunk[i++] = b64[t | b >> 6];
|
|
326948
|
+
chunk[i++] = b64[b & 63];
|
|
326949
|
+
j = 0;
|
|
326950
|
+
break;
|
|
326951
|
+
}
|
|
326952
|
+
if (i > 8191) {
|
|
326953
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
326954
|
+
i = 0;
|
|
326955
|
+
}
|
|
326956
|
+
}
|
|
326957
|
+
if (j) {
|
|
326958
|
+
chunk[i++] = b64[t];
|
|
326959
|
+
chunk[i++] = 61;
|
|
326960
|
+
if (j === 1)
|
|
326961
|
+
chunk[i++] = 61;
|
|
326962
|
+
}
|
|
326963
|
+
if (parts) {
|
|
326964
|
+
if (i)
|
|
326965
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
326966
|
+
return parts.join("");
|
|
326967
|
+
}
|
|
326968
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
326969
|
+
};
|
|
326895
326970
|
|
|
326896
|
-
|
|
326897
|
-
|
|
326971
|
+
var invalidEncoding = "invalid encoding";
|
|
326972
|
+
|
|
326973
|
+
/**
|
|
326974
|
+
* Decodes a base64 encoded string to a buffer.
|
|
326975
|
+
* @param {string} string Source string
|
|
326976
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
326977
|
+
* @param {number} offset Destination offset
|
|
326978
|
+
* @returns {number} Number of bytes written
|
|
326979
|
+
* @throws {Error} If encoding is invalid
|
|
326980
|
+
*/
|
|
326981
|
+
base64.decode = function decode(string, buffer, offset) {
|
|
326982
|
+
var start = offset;
|
|
326983
|
+
var j = 0, // goto index
|
|
326984
|
+
t; // temporary
|
|
326985
|
+
for (var i = 0; i < string.length;) {
|
|
326986
|
+
var c = string.charCodeAt(i++);
|
|
326987
|
+
if (c === 61 && j > 1)
|
|
326988
|
+
break;
|
|
326989
|
+
if ((c = s64[c]) === undefined)
|
|
326990
|
+
throw Error(invalidEncoding);
|
|
326991
|
+
switch (j) {
|
|
326992
|
+
case 0:
|
|
326993
|
+
t = c;
|
|
326994
|
+
j = 1;
|
|
326995
|
+
break;
|
|
326996
|
+
case 1:
|
|
326997
|
+
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
326998
|
+
t = c;
|
|
326999
|
+
j = 2;
|
|
327000
|
+
break;
|
|
327001
|
+
case 2:
|
|
327002
|
+
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
327003
|
+
t = c;
|
|
327004
|
+
j = 3;
|
|
327005
|
+
break;
|
|
327006
|
+
case 3:
|
|
327007
|
+
buffer[offset++] = (t & 3) << 6 | c;
|
|
327008
|
+
j = 0;
|
|
327009
|
+
break;
|
|
327010
|
+
}
|
|
327011
|
+
}
|
|
327012
|
+
if (j === 1)
|
|
327013
|
+
throw Error(invalidEncoding);
|
|
327014
|
+
return offset - start;
|
|
327015
|
+
};
|
|
326898
327016
|
|
|
326899
|
-
|
|
326900
|
-
|
|
327017
|
+
/**
|
|
327018
|
+
* Tests if the specified string appears to be base64 encoded.
|
|
327019
|
+
* @param {string} string String to test
|
|
327020
|
+
* @returns {boolean} `true` if probably base64 encoded, otherwise false
|
|
327021
|
+
*/
|
|
327022
|
+
base64.test = function test(string) {
|
|
327023
|
+
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
|
|
327024
|
+
};
|
|
327025
|
+
} (base64$2));
|
|
327026
|
+
return base64$2;
|
|
327027
|
+
}
|
|
327028
|
+
|
|
327029
|
+
var eventemitter;
|
|
327030
|
+
var hasRequiredEventemitter;
|
|
327031
|
+
|
|
327032
|
+
function requireEventemitter () {
|
|
327033
|
+
if (hasRequiredEventemitter) return eventemitter;
|
|
327034
|
+
hasRequiredEventemitter = 1;
|
|
327035
|
+
eventemitter = EventEmitter;
|
|
326901
327036
|
|
|
326902
|
-
|
|
326903
|
-
|
|
326904
|
-
|
|
327037
|
+
/**
|
|
327038
|
+
* Constructs a new event emitter instance.
|
|
327039
|
+
* @classdesc A minimal event emitter.
|
|
327040
|
+
* @memberof util
|
|
327041
|
+
* @constructor
|
|
327042
|
+
*/
|
|
327043
|
+
function EventEmitter() {
|
|
327044
|
+
|
|
327045
|
+
/**
|
|
327046
|
+
* Registered listeners.
|
|
327047
|
+
* @type {Object.<string,*>}
|
|
327048
|
+
* @private
|
|
327049
|
+
*/
|
|
327050
|
+
this._listeners = {};
|
|
327051
|
+
}
|
|
326905
327052
|
|
|
326906
327053
|
/**
|
|
326907
|
-
*
|
|
326908
|
-
* @param {
|
|
326909
|
-
* @param {
|
|
326910
|
-
* @param {
|
|
326911
|
-
* @returns {
|
|
327054
|
+
* Registers an event listener.
|
|
327055
|
+
* @param {string} evt Event name
|
|
327056
|
+
* @param {function} fn Listener
|
|
327057
|
+
* @param {*} [ctx] Listener context
|
|
327058
|
+
* @returns {util.EventEmitter} `this`
|
|
326912
327059
|
*/
|
|
326913
|
-
|
|
326914
|
-
|
|
326915
|
-
|
|
326916
|
-
|
|
326917
|
-
|
|
326918
|
-
|
|
326919
|
-
while (start < end) {
|
|
326920
|
-
var b = buffer[start++];
|
|
326921
|
-
switch (j) {
|
|
326922
|
-
case 0:
|
|
326923
|
-
chunk[i++] = b64[b >> 2];
|
|
326924
|
-
t = (b & 3) << 4;
|
|
326925
|
-
j = 1;
|
|
326926
|
-
break;
|
|
326927
|
-
case 1:
|
|
326928
|
-
chunk[i++] = b64[t | b >> 4];
|
|
326929
|
-
t = (b & 15) << 2;
|
|
326930
|
-
j = 2;
|
|
326931
|
-
break;
|
|
326932
|
-
case 2:
|
|
326933
|
-
chunk[i++] = b64[t | b >> 6];
|
|
326934
|
-
chunk[i++] = b64[b & 63];
|
|
326935
|
-
j = 0;
|
|
326936
|
-
break;
|
|
326937
|
-
}
|
|
326938
|
-
if (i > 8191) {
|
|
326939
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
326940
|
-
i = 0;
|
|
326941
|
-
}
|
|
326942
|
-
}
|
|
326943
|
-
if (j) {
|
|
326944
|
-
chunk[i++] = b64[t];
|
|
326945
|
-
chunk[i++] = 61;
|
|
326946
|
-
if (j === 1)
|
|
326947
|
-
chunk[i++] = 61;
|
|
326948
|
-
}
|
|
326949
|
-
if (parts) {
|
|
326950
|
-
if (i)
|
|
326951
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
326952
|
-
return parts.join("");
|
|
326953
|
-
}
|
|
326954
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
327060
|
+
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
327061
|
+
(this._listeners[evt] || (this._listeners[evt] = [])).push({
|
|
327062
|
+
fn : fn,
|
|
327063
|
+
ctx : ctx || this
|
|
327064
|
+
});
|
|
327065
|
+
return this;
|
|
326955
327066
|
};
|
|
326956
327067
|
|
|
326957
|
-
var invalidEncoding = "invalid encoding";
|
|
326958
|
-
|
|
326959
327068
|
/**
|
|
326960
|
-
*
|
|
326961
|
-
* @param {string}
|
|
326962
|
-
* @param {
|
|
326963
|
-
* @
|
|
326964
|
-
* @returns {number} Number of bytes written
|
|
326965
|
-
* @throws {Error} If encoding is invalid
|
|
327069
|
+
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
327070
|
+
* @param {string} [evt] Event name. Removes all listeners if omitted.
|
|
327071
|
+
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
327072
|
+
* @returns {util.EventEmitter} `this`
|
|
326966
327073
|
*/
|
|
326967
|
-
|
|
326968
|
-
|
|
326969
|
-
|
|
326970
|
-
|
|
326971
|
-
|
|
326972
|
-
|
|
326973
|
-
|
|
326974
|
-
|
|
326975
|
-
|
|
326976
|
-
|
|
326977
|
-
|
|
326978
|
-
|
|
326979
|
-
|
|
326980
|
-
j = 1;
|
|
326981
|
-
break;
|
|
326982
|
-
case 1:
|
|
326983
|
-
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
326984
|
-
t = c;
|
|
326985
|
-
j = 2;
|
|
326986
|
-
break;
|
|
326987
|
-
case 2:
|
|
326988
|
-
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
326989
|
-
t = c;
|
|
326990
|
-
j = 3;
|
|
326991
|
-
break;
|
|
326992
|
-
case 3:
|
|
326993
|
-
buffer[offset++] = (t & 3) << 6 | c;
|
|
326994
|
-
j = 0;
|
|
326995
|
-
break;
|
|
327074
|
+
EventEmitter.prototype.off = function off(evt, fn) {
|
|
327075
|
+
if (evt === undefined)
|
|
327076
|
+
this._listeners = {};
|
|
327077
|
+
else {
|
|
327078
|
+
if (fn === undefined)
|
|
327079
|
+
this._listeners[evt] = [];
|
|
327080
|
+
else {
|
|
327081
|
+
var listeners = this._listeners[evt];
|
|
327082
|
+
for (var i = 0; i < listeners.length;)
|
|
327083
|
+
if (listeners[i].fn === fn)
|
|
327084
|
+
listeners.splice(i, 1);
|
|
327085
|
+
else
|
|
327086
|
+
++i;
|
|
326996
327087
|
}
|
|
326997
327088
|
}
|
|
326998
|
-
|
|
326999
|
-
throw Error(invalidEncoding);
|
|
327000
|
-
return offset - start;
|
|
327089
|
+
return this;
|
|
327001
327090
|
};
|
|
327002
327091
|
|
|
327003
327092
|
/**
|
|
327004
|
-
*
|
|
327005
|
-
* @param {string}
|
|
327006
|
-
* @
|
|
327093
|
+
* Emits an event by calling its listeners with the specified arguments.
|
|
327094
|
+
* @param {string} evt Event name
|
|
327095
|
+
* @param {...*} args Arguments
|
|
327096
|
+
* @returns {util.EventEmitter} `this`
|
|
327007
327097
|
*/
|
|
327008
|
-
|
|
327009
|
-
|
|
327010
|
-
|
|
327011
|
-
|
|
327098
|
+
EventEmitter.prototype.emit = function emit(evt) {
|
|
327099
|
+
var listeners = this._listeners[evt];
|
|
327100
|
+
if (listeners) {
|
|
327101
|
+
var args = [],
|
|
327102
|
+
i = 1;
|
|
327103
|
+
for (; i < arguments.length;)
|
|
327104
|
+
args.push(arguments[i++]);
|
|
327105
|
+
for (i = 0; i < listeners.length;)
|
|
327106
|
+
listeners[i].fn.apply(listeners[i++].ctx, args);
|
|
327107
|
+
}
|
|
327108
|
+
return this;
|
|
327109
|
+
};
|
|
327110
|
+
return eventemitter;
|
|
327111
|
+
}
|
|
327012
327112
|
|
|
327013
|
-
var
|
|
327014
|
-
|
|
327015
|
-
/**
|
|
327016
|
-
* Constructs a new event emitter instance.
|
|
327017
|
-
* @classdesc A minimal event emitter.
|
|
327018
|
-
* @memberof util
|
|
327019
|
-
* @constructor
|
|
327020
|
-
*/
|
|
327021
|
-
function EventEmitter() {
|
|
327022
|
-
|
|
327023
|
-
/**
|
|
327024
|
-
* Registered listeners.
|
|
327025
|
-
* @type {Object.<string,*>}
|
|
327026
|
-
* @private
|
|
327027
|
-
*/
|
|
327028
|
-
this._listeners = {};
|
|
327029
|
-
}
|
|
327030
|
-
|
|
327031
|
-
/**
|
|
327032
|
-
* Registers an event listener.
|
|
327033
|
-
* @param {string} evt Event name
|
|
327034
|
-
* @param {function} fn Listener
|
|
327035
|
-
* @param {*} [ctx] Listener context
|
|
327036
|
-
* @returns {util.EventEmitter} `this`
|
|
327037
|
-
*/
|
|
327038
|
-
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
327039
|
-
(this._listeners[evt] || (this._listeners[evt] = [])).push({
|
|
327040
|
-
fn : fn,
|
|
327041
|
-
ctx : ctx || this
|
|
327042
|
-
});
|
|
327043
|
-
return this;
|
|
327044
|
-
};
|
|
327045
|
-
|
|
327046
|
-
/**
|
|
327047
|
-
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
327048
|
-
* @param {string} [evt] Event name. Removes all listeners if omitted.
|
|
327049
|
-
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
327050
|
-
* @returns {util.EventEmitter} `this`
|
|
327051
|
-
*/
|
|
327052
|
-
EventEmitter.prototype.off = function off(evt, fn) {
|
|
327053
|
-
if (evt === undefined)
|
|
327054
|
-
this._listeners = {};
|
|
327055
|
-
else {
|
|
327056
|
-
if (fn === undefined)
|
|
327057
|
-
this._listeners[evt] = [];
|
|
327058
|
-
else {
|
|
327059
|
-
var listeners = this._listeners[evt];
|
|
327060
|
-
for (var i = 0; i < listeners.length;)
|
|
327061
|
-
if (listeners[i].fn === fn)
|
|
327062
|
-
listeners.splice(i, 1);
|
|
327063
|
-
else
|
|
327064
|
-
++i;
|
|
327065
|
-
}
|
|
327066
|
-
}
|
|
327067
|
-
return this;
|
|
327068
|
-
};
|
|
327069
|
-
|
|
327070
|
-
/**
|
|
327071
|
-
* Emits an event by calling its listeners with the specified arguments.
|
|
327072
|
-
* @param {string} evt Event name
|
|
327073
|
-
* @param {...*} args Arguments
|
|
327074
|
-
* @returns {util.EventEmitter} `this`
|
|
327075
|
-
*/
|
|
327076
|
-
EventEmitter.prototype.emit = function emit(evt) {
|
|
327077
|
-
var listeners = this._listeners[evt];
|
|
327078
|
-
if (listeners) {
|
|
327079
|
-
var args = [],
|
|
327080
|
-
i = 1;
|
|
327081
|
-
for (; i < arguments.length;)
|
|
327082
|
-
args.push(arguments[i++]);
|
|
327083
|
-
for (i = 0; i < listeners.length;)
|
|
327084
|
-
listeners[i].fn.apply(listeners[i++].ctx, args);
|
|
327085
|
-
}
|
|
327086
|
-
return this;
|
|
327087
|
-
};
|
|
327113
|
+
var float;
|
|
327114
|
+
var hasRequiredFloat;
|
|
327088
327115
|
|
|
327089
|
-
|
|
327116
|
+
function requireFloat () {
|
|
327117
|
+
if (hasRequiredFloat) return float;
|
|
327118
|
+
hasRequiredFloat = 1;
|
|
327090
327119
|
|
|
327091
|
-
|
|
327092
|
-
* Reads / writes floats / doubles from / to buffers.
|
|
327093
|
-
* @name util.float
|
|
327094
|
-
* @namespace
|
|
327095
|
-
*/
|
|
327120
|
+
float = factory(factory);
|
|
327096
327121
|
|
|
327097
|
-
|
|
327098
|
-
|
|
327099
|
-
|
|
327100
|
-
|
|
327101
|
-
|
|
327102
|
-
* @param {Uint8Array} buf Target buffer
|
|
327103
|
-
* @param {number} pos Target buffer offset
|
|
327104
|
-
* @returns {undefined}
|
|
327105
|
-
*/
|
|
327122
|
+
/**
|
|
327123
|
+
* Reads / writes floats / doubles from / to buffers.
|
|
327124
|
+
* @name util.float
|
|
327125
|
+
* @namespace
|
|
327126
|
+
*/
|
|
327106
327127
|
|
|
327107
|
-
|
|
327108
|
-
|
|
327109
|
-
|
|
327110
|
-
|
|
327111
|
-
|
|
327112
|
-
|
|
327113
|
-
|
|
327114
|
-
|
|
327115
|
-
|
|
327128
|
+
/**
|
|
327129
|
+
* Writes a 32 bit float to a buffer using little endian byte order.
|
|
327130
|
+
* @name util.float.writeFloatLE
|
|
327131
|
+
* @function
|
|
327132
|
+
* @param {number} val Value to write
|
|
327133
|
+
* @param {Uint8Array} buf Target buffer
|
|
327134
|
+
* @param {number} pos Target buffer offset
|
|
327135
|
+
* @returns {undefined}
|
|
327136
|
+
*/
|
|
327116
327137
|
|
|
327117
|
-
|
|
327118
|
-
|
|
327119
|
-
|
|
327120
|
-
|
|
327121
|
-
|
|
327122
|
-
|
|
327123
|
-
|
|
327124
|
-
|
|
327138
|
+
/**
|
|
327139
|
+
* Writes a 32 bit float to a buffer using big endian byte order.
|
|
327140
|
+
* @name util.float.writeFloatBE
|
|
327141
|
+
* @function
|
|
327142
|
+
* @param {number} val Value to write
|
|
327143
|
+
* @param {Uint8Array} buf Target buffer
|
|
327144
|
+
* @param {number} pos Target buffer offset
|
|
327145
|
+
* @returns {undefined}
|
|
327146
|
+
*/
|
|
327125
327147
|
|
|
327126
|
-
|
|
327127
|
-
|
|
327128
|
-
|
|
327129
|
-
|
|
327130
|
-
|
|
327131
|
-
|
|
327132
|
-
|
|
327133
|
-
|
|
327148
|
+
/**
|
|
327149
|
+
* Reads a 32 bit float from a buffer using little endian byte order.
|
|
327150
|
+
* @name util.float.readFloatLE
|
|
327151
|
+
* @function
|
|
327152
|
+
* @param {Uint8Array} buf Source buffer
|
|
327153
|
+
* @param {number} pos Source buffer offset
|
|
327154
|
+
* @returns {number} Value read
|
|
327155
|
+
*/
|
|
327134
327156
|
|
|
327135
|
-
|
|
327136
|
-
|
|
327137
|
-
|
|
327138
|
-
|
|
327139
|
-
|
|
327140
|
-
|
|
327141
|
-
|
|
327142
|
-
|
|
327143
|
-
*/
|
|
327157
|
+
/**
|
|
327158
|
+
* Reads a 32 bit float from a buffer using big endian byte order.
|
|
327159
|
+
* @name util.float.readFloatBE
|
|
327160
|
+
* @function
|
|
327161
|
+
* @param {Uint8Array} buf Source buffer
|
|
327162
|
+
* @param {number} pos Source buffer offset
|
|
327163
|
+
* @returns {number} Value read
|
|
327164
|
+
*/
|
|
327144
327165
|
|
|
327145
|
-
|
|
327146
|
-
|
|
327147
|
-
|
|
327148
|
-
|
|
327149
|
-
|
|
327150
|
-
|
|
327151
|
-
|
|
327152
|
-
|
|
327153
|
-
|
|
327166
|
+
/**
|
|
327167
|
+
* Writes a 64 bit double to a buffer using little endian byte order.
|
|
327168
|
+
* @name util.float.writeDoubleLE
|
|
327169
|
+
* @function
|
|
327170
|
+
* @param {number} val Value to write
|
|
327171
|
+
* @param {Uint8Array} buf Target buffer
|
|
327172
|
+
* @param {number} pos Target buffer offset
|
|
327173
|
+
* @returns {undefined}
|
|
327174
|
+
*/
|
|
327154
327175
|
|
|
327155
|
-
|
|
327156
|
-
|
|
327157
|
-
|
|
327158
|
-
|
|
327159
|
-
|
|
327160
|
-
|
|
327161
|
-
|
|
327162
|
-
|
|
327176
|
+
/**
|
|
327177
|
+
* Writes a 64 bit double to a buffer using big endian byte order.
|
|
327178
|
+
* @name util.float.writeDoubleBE
|
|
327179
|
+
* @function
|
|
327180
|
+
* @param {number} val Value to write
|
|
327181
|
+
* @param {Uint8Array} buf Target buffer
|
|
327182
|
+
* @param {number} pos Target buffer offset
|
|
327183
|
+
* @returns {undefined}
|
|
327184
|
+
*/
|
|
327163
327185
|
|
|
327164
|
-
|
|
327165
|
-
|
|
327166
|
-
|
|
327167
|
-
|
|
327168
|
-
|
|
327169
|
-
|
|
327170
|
-
|
|
327171
|
-
|
|
327186
|
+
/**
|
|
327187
|
+
* Reads a 64 bit double from a buffer using little endian byte order.
|
|
327188
|
+
* @name util.float.readDoubleLE
|
|
327189
|
+
* @function
|
|
327190
|
+
* @param {Uint8Array} buf Source buffer
|
|
327191
|
+
* @param {number} pos Source buffer offset
|
|
327192
|
+
* @returns {number} Value read
|
|
327193
|
+
*/
|
|
327172
327194
|
|
|
327173
|
-
|
|
327174
|
-
|
|
327195
|
+
/**
|
|
327196
|
+
* Reads a 64 bit double from a buffer using big endian byte order.
|
|
327197
|
+
* @name util.float.readDoubleBE
|
|
327198
|
+
* @function
|
|
327199
|
+
* @param {Uint8Array} buf Source buffer
|
|
327200
|
+
* @param {number} pos Source buffer offset
|
|
327201
|
+
* @returns {number} Value read
|
|
327202
|
+
*/
|
|
327175
327203
|
|
|
327176
|
-
|
|
327177
|
-
|
|
327204
|
+
// Factory function for the purpose of node-based testing in modified global environments
|
|
327205
|
+
function factory(exports) {
|
|
327178
327206
|
|
|
327179
|
-
|
|
327180
|
-
|
|
327181
|
-
le = f8b[3] === 128;
|
|
327207
|
+
// float: typed array
|
|
327208
|
+
if (typeof Float32Array !== "undefined") (function() {
|
|
327182
327209
|
|
|
327183
|
-
|
|
327184
|
-
|
|
327185
|
-
|
|
327186
|
-
buf[pos + 1] = f8b[1];
|
|
327187
|
-
buf[pos + 2] = f8b[2];
|
|
327188
|
-
buf[pos + 3] = f8b[3];
|
|
327189
|
-
}
|
|
327210
|
+
var f32 = new Float32Array([ -0 ]),
|
|
327211
|
+
f8b = new Uint8Array(f32.buffer),
|
|
327212
|
+
le = f8b[3] === 128;
|
|
327190
327213
|
|
|
327191
|
-
|
|
327192
|
-
|
|
327193
|
-
|
|
327194
|
-
|
|
327195
|
-
|
|
327196
|
-
|
|
327197
|
-
|
|
327214
|
+
function writeFloat_f32_cpy(val, buf, pos) {
|
|
327215
|
+
f32[0] = val;
|
|
327216
|
+
buf[pos ] = f8b[0];
|
|
327217
|
+
buf[pos + 1] = f8b[1];
|
|
327218
|
+
buf[pos + 2] = f8b[2];
|
|
327219
|
+
buf[pos + 3] = f8b[3];
|
|
327220
|
+
}
|
|
327198
327221
|
|
|
327199
|
-
|
|
327200
|
-
|
|
327201
|
-
|
|
327202
|
-
|
|
327203
|
-
|
|
327204
|
-
|
|
327205
|
-
|
|
327206
|
-
f8b[1] = buf[pos + 1];
|
|
327207
|
-
f8b[2] = buf[pos + 2];
|
|
327208
|
-
f8b[3] = buf[pos + 3];
|
|
327209
|
-
return f32[0];
|
|
327210
|
-
}
|
|
327222
|
+
function writeFloat_f32_rev(val, buf, pos) {
|
|
327223
|
+
f32[0] = val;
|
|
327224
|
+
buf[pos ] = f8b[3];
|
|
327225
|
+
buf[pos + 1] = f8b[2];
|
|
327226
|
+
buf[pos + 2] = f8b[1];
|
|
327227
|
+
buf[pos + 3] = f8b[0];
|
|
327228
|
+
}
|
|
327211
327229
|
|
|
327212
|
-
|
|
327213
|
-
|
|
327214
|
-
|
|
327215
|
-
|
|
327216
|
-
|
|
327217
|
-
|
|
327218
|
-
|
|
327230
|
+
/* istanbul ignore next */
|
|
327231
|
+
exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
|
|
327232
|
+
/* istanbul ignore next */
|
|
327233
|
+
exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
|
|
327234
|
+
|
|
327235
|
+
function readFloat_f32_cpy(buf, pos) {
|
|
327236
|
+
f8b[0] = buf[pos ];
|
|
327237
|
+
f8b[1] = buf[pos + 1];
|
|
327238
|
+
f8b[2] = buf[pos + 2];
|
|
327239
|
+
f8b[3] = buf[pos + 3];
|
|
327240
|
+
return f32[0];
|
|
327241
|
+
}
|
|
327219
327242
|
|
|
327220
|
-
|
|
327221
|
-
|
|
327222
|
-
|
|
327223
|
-
|
|
327224
|
-
|
|
327225
|
-
|
|
327226
|
-
|
|
327227
|
-
|
|
327228
|
-
function writeFloat_ieee754(writeUint, val, buf, pos) {
|
|
327229
|
-
var sign = val < 0 ? 1 : 0;
|
|
327230
|
-
if (sign)
|
|
327231
|
-
val = -val;
|
|
327232
|
-
if (val === 0)
|
|
327233
|
-
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
|
|
327234
|
-
else if (isNaN(val))
|
|
327235
|
-
writeUint(2143289344, buf, pos);
|
|
327236
|
-
else if (val > 3.4028234663852886e+38) // +-Infinity
|
|
327237
|
-
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
|
|
327238
|
-
else if (val < 1.1754943508222875e-38) // denormal
|
|
327239
|
-
writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
|
|
327240
|
-
else {
|
|
327241
|
-
var exponent = Math.floor(Math.log(val) / Math.LN2),
|
|
327242
|
-
mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
|
|
327243
|
-
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
|
|
327244
|
-
}
|
|
327245
|
-
}
|
|
327243
|
+
function readFloat_f32_rev(buf, pos) {
|
|
327244
|
+
f8b[3] = buf[pos ];
|
|
327245
|
+
f8b[2] = buf[pos + 1];
|
|
327246
|
+
f8b[1] = buf[pos + 2];
|
|
327247
|
+
f8b[0] = buf[pos + 3];
|
|
327248
|
+
return f32[0];
|
|
327249
|
+
}
|
|
327246
327250
|
|
|
327247
|
-
|
|
327248
|
-
|
|
327249
|
-
|
|
327250
|
-
|
|
327251
|
-
|
|
327252
|
-
|
|
327253
|
-
|
|
327254
|
-
|
|
327255
|
-
|
|
327256
|
-
|
|
327257
|
-
|
|
327258
|
-
|
|
327259
|
-
|
|
327260
|
-
|
|
327261
|
-
|
|
327262
|
-
|
|
327251
|
+
/* istanbul ignore next */
|
|
327252
|
+
exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
|
|
327253
|
+
/* istanbul ignore next */
|
|
327254
|
+
exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
|
|
327255
|
+
|
|
327256
|
+
// float: ieee754
|
|
327257
|
+
})(); else (function() {
|
|
327258
|
+
|
|
327259
|
+
function writeFloat_ieee754(writeUint, val, buf, pos) {
|
|
327260
|
+
var sign = val < 0 ? 1 : 0;
|
|
327261
|
+
if (sign)
|
|
327262
|
+
val = -val;
|
|
327263
|
+
if (val === 0)
|
|
327264
|
+
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
|
|
327265
|
+
else if (isNaN(val))
|
|
327266
|
+
writeUint(2143289344, buf, pos);
|
|
327267
|
+
else if (val > 3.4028234663852886e+38) // +-Infinity
|
|
327268
|
+
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
|
|
327269
|
+
else if (val < 1.1754943508222875e-38) // denormal
|
|
327270
|
+
writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
|
|
327271
|
+
else {
|
|
327272
|
+
var exponent = Math.floor(Math.log(val) / Math.LN2),
|
|
327273
|
+
mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
|
|
327274
|
+
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
|
|
327275
|
+
}
|
|
327276
|
+
}
|
|
327263
327277
|
|
|
327264
|
-
|
|
327265
|
-
|
|
327278
|
+
exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
|
|
327279
|
+
exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
|
|
327280
|
+
|
|
327281
|
+
function readFloat_ieee754(readUint, buf, pos) {
|
|
327282
|
+
var uint = readUint(buf, pos),
|
|
327283
|
+
sign = (uint >> 31) * 2 + 1,
|
|
327284
|
+
exponent = uint >>> 23 & 255,
|
|
327285
|
+
mantissa = uint & 8388607;
|
|
327286
|
+
return exponent === 255
|
|
327287
|
+
? mantissa
|
|
327288
|
+
? NaN
|
|
327289
|
+
: sign * Infinity
|
|
327290
|
+
: exponent === 0 // denormal
|
|
327291
|
+
? sign * 1.401298464324817e-45 * mantissa
|
|
327292
|
+
: sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
|
|
327293
|
+
}
|
|
327266
327294
|
|
|
327267
|
-
|
|
327295
|
+
exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
|
|
327296
|
+
exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
|
|
327268
327297
|
|
|
327269
|
-
|
|
327270
|
-
if (typeof Float64Array !== "undefined") (function() {
|
|
327298
|
+
})();
|
|
327271
327299
|
|
|
327272
|
-
|
|
327273
|
-
|
|
327274
|
-
le = f8b[7] === 128;
|
|
327300
|
+
// double: typed array
|
|
327301
|
+
if (typeof Float64Array !== "undefined") (function() {
|
|
327275
327302
|
|
|
327276
|
-
|
|
327277
|
-
|
|
327278
|
-
|
|
327279
|
-
buf[pos + 1] = f8b[1];
|
|
327280
|
-
buf[pos + 2] = f8b[2];
|
|
327281
|
-
buf[pos + 3] = f8b[3];
|
|
327282
|
-
buf[pos + 4] = f8b[4];
|
|
327283
|
-
buf[pos + 5] = f8b[5];
|
|
327284
|
-
buf[pos + 6] = f8b[6];
|
|
327285
|
-
buf[pos + 7] = f8b[7];
|
|
327286
|
-
}
|
|
327303
|
+
var f64 = new Float64Array([-0]),
|
|
327304
|
+
f8b = new Uint8Array(f64.buffer),
|
|
327305
|
+
le = f8b[7] === 128;
|
|
327287
327306
|
|
|
327288
|
-
|
|
327289
|
-
|
|
327290
|
-
|
|
327291
|
-
|
|
327292
|
-
|
|
327293
|
-
|
|
327294
|
-
|
|
327295
|
-
|
|
327296
|
-
|
|
327297
|
-
|
|
327298
|
-
|
|
327307
|
+
function writeDouble_f64_cpy(val, buf, pos) {
|
|
327308
|
+
f64[0] = val;
|
|
327309
|
+
buf[pos ] = f8b[0];
|
|
327310
|
+
buf[pos + 1] = f8b[1];
|
|
327311
|
+
buf[pos + 2] = f8b[2];
|
|
327312
|
+
buf[pos + 3] = f8b[3];
|
|
327313
|
+
buf[pos + 4] = f8b[4];
|
|
327314
|
+
buf[pos + 5] = f8b[5];
|
|
327315
|
+
buf[pos + 6] = f8b[6];
|
|
327316
|
+
buf[pos + 7] = f8b[7];
|
|
327317
|
+
}
|
|
327299
327318
|
|
|
327300
|
-
|
|
327301
|
-
|
|
327302
|
-
|
|
327303
|
-
|
|
327304
|
-
|
|
327305
|
-
|
|
327306
|
-
|
|
327307
|
-
|
|
327308
|
-
|
|
327309
|
-
|
|
327310
|
-
|
|
327311
|
-
f8b[5] = buf[pos + 5];
|
|
327312
|
-
f8b[6] = buf[pos + 6];
|
|
327313
|
-
f8b[7] = buf[pos + 7];
|
|
327314
|
-
return f64[0];
|
|
327315
|
-
}
|
|
327319
|
+
function writeDouble_f64_rev(val, buf, pos) {
|
|
327320
|
+
f64[0] = val;
|
|
327321
|
+
buf[pos ] = f8b[7];
|
|
327322
|
+
buf[pos + 1] = f8b[6];
|
|
327323
|
+
buf[pos + 2] = f8b[5];
|
|
327324
|
+
buf[pos + 3] = f8b[4];
|
|
327325
|
+
buf[pos + 4] = f8b[3];
|
|
327326
|
+
buf[pos + 5] = f8b[2];
|
|
327327
|
+
buf[pos + 6] = f8b[1];
|
|
327328
|
+
buf[pos + 7] = f8b[0];
|
|
327329
|
+
}
|
|
327316
327330
|
|
|
327317
|
-
|
|
327318
|
-
|
|
327319
|
-
|
|
327320
|
-
|
|
327321
|
-
|
|
327322
|
-
|
|
327323
|
-
|
|
327324
|
-
|
|
327325
|
-
|
|
327326
|
-
|
|
327327
|
-
|
|
327331
|
+
/* istanbul ignore next */
|
|
327332
|
+
exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
|
|
327333
|
+
/* istanbul ignore next */
|
|
327334
|
+
exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
|
|
327335
|
+
|
|
327336
|
+
function readDouble_f64_cpy(buf, pos) {
|
|
327337
|
+
f8b[0] = buf[pos ];
|
|
327338
|
+
f8b[1] = buf[pos + 1];
|
|
327339
|
+
f8b[2] = buf[pos + 2];
|
|
327340
|
+
f8b[3] = buf[pos + 3];
|
|
327341
|
+
f8b[4] = buf[pos + 4];
|
|
327342
|
+
f8b[5] = buf[pos + 5];
|
|
327343
|
+
f8b[6] = buf[pos + 6];
|
|
327344
|
+
f8b[7] = buf[pos + 7];
|
|
327345
|
+
return f64[0];
|
|
327346
|
+
}
|
|
327328
327347
|
|
|
327329
|
-
|
|
327330
|
-
|
|
327331
|
-
|
|
327332
|
-
|
|
327333
|
-
|
|
327334
|
-
|
|
327335
|
-
|
|
327336
|
-
|
|
327337
|
-
|
|
327338
|
-
|
|
327339
|
-
|
|
327340
|
-
val = -val;
|
|
327341
|
-
if (val === 0) {
|
|
327342
|
-
writeUint(0, buf, pos + off0);
|
|
327343
|
-
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
|
|
327344
|
-
} else if (isNaN(val)) {
|
|
327345
|
-
writeUint(0, buf, pos + off0);
|
|
327346
|
-
writeUint(2146959360, buf, pos + off1);
|
|
327347
|
-
} else if (val > 1.7976931348623157e+308) { // +-Infinity
|
|
327348
|
-
writeUint(0, buf, pos + off0);
|
|
327349
|
-
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
|
|
327350
|
-
} else {
|
|
327351
|
-
var mantissa;
|
|
327352
|
-
if (val < 2.2250738585072014e-308) { // denormal
|
|
327353
|
-
mantissa = val / 5e-324;
|
|
327354
|
-
writeUint(mantissa >>> 0, buf, pos + off0);
|
|
327355
|
-
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
|
|
327356
|
-
} else {
|
|
327357
|
-
var exponent = Math.floor(Math.log(val) / Math.LN2);
|
|
327358
|
-
if (exponent === 1024)
|
|
327359
|
-
exponent = 1023;
|
|
327360
|
-
mantissa = val * Math.pow(2, -exponent);
|
|
327361
|
-
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
|
|
327362
|
-
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
|
|
327363
|
-
}
|
|
327364
|
-
}
|
|
327365
|
-
}
|
|
327348
|
+
function readDouble_f64_rev(buf, pos) {
|
|
327349
|
+
f8b[7] = buf[pos ];
|
|
327350
|
+
f8b[6] = buf[pos + 1];
|
|
327351
|
+
f8b[5] = buf[pos + 2];
|
|
327352
|
+
f8b[4] = buf[pos + 3];
|
|
327353
|
+
f8b[3] = buf[pos + 4];
|
|
327354
|
+
f8b[2] = buf[pos + 5];
|
|
327355
|
+
f8b[1] = buf[pos + 6];
|
|
327356
|
+
f8b[0] = buf[pos + 7];
|
|
327357
|
+
return f64[0];
|
|
327358
|
+
}
|
|
327366
327359
|
|
|
327367
|
-
|
|
327368
|
-
|
|
327369
|
-
|
|
327370
|
-
|
|
327371
|
-
|
|
327372
|
-
|
|
327373
|
-
|
|
327374
|
-
|
|
327375
|
-
|
|
327376
|
-
|
|
327377
|
-
|
|
327378
|
-
|
|
327379
|
-
|
|
327380
|
-
|
|
327381
|
-
|
|
327382
|
-
|
|
327383
|
-
|
|
327360
|
+
/* istanbul ignore next */
|
|
327361
|
+
exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
|
|
327362
|
+
/* istanbul ignore next */
|
|
327363
|
+
exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
|
|
327364
|
+
|
|
327365
|
+
// double: ieee754
|
|
327366
|
+
})(); else (function() {
|
|
327367
|
+
|
|
327368
|
+
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
|
|
327369
|
+
var sign = val < 0 ? 1 : 0;
|
|
327370
|
+
if (sign)
|
|
327371
|
+
val = -val;
|
|
327372
|
+
if (val === 0) {
|
|
327373
|
+
writeUint(0, buf, pos + off0);
|
|
327374
|
+
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
|
|
327375
|
+
} else if (isNaN(val)) {
|
|
327376
|
+
writeUint(0, buf, pos + off0);
|
|
327377
|
+
writeUint(2146959360, buf, pos + off1);
|
|
327378
|
+
} else if (val > 1.7976931348623157e+308) { // +-Infinity
|
|
327379
|
+
writeUint(0, buf, pos + off0);
|
|
327380
|
+
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
|
|
327381
|
+
} else {
|
|
327382
|
+
var mantissa;
|
|
327383
|
+
if (val < 2.2250738585072014e-308) { // denormal
|
|
327384
|
+
mantissa = val / 5e-324;
|
|
327385
|
+
writeUint(mantissa >>> 0, buf, pos + off0);
|
|
327386
|
+
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
|
|
327387
|
+
} else {
|
|
327388
|
+
var exponent = Math.floor(Math.log(val) / Math.LN2);
|
|
327389
|
+
if (exponent === 1024)
|
|
327390
|
+
exponent = 1023;
|
|
327391
|
+
mantissa = val * Math.pow(2, -exponent);
|
|
327392
|
+
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
|
|
327393
|
+
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
|
|
327394
|
+
}
|
|
327395
|
+
}
|
|
327396
|
+
}
|
|
327384
327397
|
|
|
327385
|
-
|
|
327386
|
-
|
|
327398
|
+
exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
|
|
327399
|
+
exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
|
|
327400
|
+
|
|
327401
|
+
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
|
|
327402
|
+
var lo = readUint(buf, pos + off0),
|
|
327403
|
+
hi = readUint(buf, pos + off1);
|
|
327404
|
+
var sign = (hi >> 31) * 2 + 1,
|
|
327405
|
+
exponent = hi >>> 20 & 2047,
|
|
327406
|
+
mantissa = 4294967296 * (hi & 1048575) + lo;
|
|
327407
|
+
return exponent === 2047
|
|
327408
|
+
? mantissa
|
|
327409
|
+
? NaN
|
|
327410
|
+
: sign * Infinity
|
|
327411
|
+
: exponent === 0 // denormal
|
|
327412
|
+
? sign * 5e-324 * mantissa
|
|
327413
|
+
: sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
|
|
327414
|
+
}
|
|
327387
327415
|
|
|
327388
|
-
|
|
327416
|
+
exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
|
|
327417
|
+
exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
|
|
327389
327418
|
|
|
327390
|
-
|
|
327391
|
-
}
|
|
327419
|
+
})();
|
|
327392
327420
|
|
|
327393
|
-
|
|
327421
|
+
return exports;
|
|
327422
|
+
}
|
|
327394
327423
|
|
|
327395
|
-
|
|
327396
|
-
buf[pos ] = val & 255;
|
|
327397
|
-
buf[pos + 1] = val >>> 8 & 255;
|
|
327398
|
-
buf[pos + 2] = val >>> 16 & 255;
|
|
327399
|
-
buf[pos + 3] = val >>> 24;
|
|
327400
|
-
}
|
|
327424
|
+
// uint helpers
|
|
327401
327425
|
|
|
327402
|
-
|
|
327403
|
-
|
|
327404
|
-
|
|
327405
|
-
|
|
327406
|
-
|
|
327407
|
-
|
|
327426
|
+
function writeUintLE(val, buf, pos) {
|
|
327427
|
+
buf[pos ] = val & 255;
|
|
327428
|
+
buf[pos + 1] = val >>> 8 & 255;
|
|
327429
|
+
buf[pos + 2] = val >>> 16 & 255;
|
|
327430
|
+
buf[pos + 3] = val >>> 24;
|
|
327431
|
+
}
|
|
327408
327432
|
|
|
327409
|
-
|
|
327410
|
-
|
|
327411
|
-
|
|
327412
|
-
|
|
327413
|
-
|
|
327414
|
-
|
|
327433
|
+
function writeUintBE(val, buf, pos) {
|
|
327434
|
+
buf[pos ] = val >>> 24;
|
|
327435
|
+
buf[pos + 1] = val >>> 16 & 255;
|
|
327436
|
+
buf[pos + 2] = val >>> 8 & 255;
|
|
327437
|
+
buf[pos + 3] = val & 255;
|
|
327438
|
+
}
|
|
327415
327439
|
|
|
327416
|
-
|
|
327417
|
-
|
|
327418
|
-
|
|
327419
|
-
|
|
327420
|
-
|
|
327421
|
-
|
|
327422
|
-
|
|
327423
|
-
var inquire_1 = inquire;
|
|
327440
|
+
function readUintLE(buf, pos) {
|
|
327441
|
+
return (buf[pos ]
|
|
327442
|
+
| buf[pos + 1] << 8
|
|
327443
|
+
| buf[pos + 2] << 16
|
|
327444
|
+
| buf[pos + 3] << 24) >>> 0;
|
|
327445
|
+
}
|
|
327424
327446
|
|
|
327425
|
-
|
|
327426
|
-
|
|
327427
|
-
|
|
327428
|
-
|
|
327429
|
-
|
|
327430
|
-
|
|
327431
|
-
|
|
327432
|
-
try {
|
|
327433
|
-
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
|
|
327434
|
-
if (mod && (mod.length || Object.keys(mod).length))
|
|
327435
|
-
return mod;
|
|
327436
|
-
} catch (e) {} // eslint-disable-line no-empty
|
|
327437
|
-
return null;
|
|
327447
|
+
function readUintBE(buf, pos) {
|
|
327448
|
+
return (buf[pos ] << 24
|
|
327449
|
+
| buf[pos + 1] << 16
|
|
327450
|
+
| buf[pos + 2] << 8
|
|
327451
|
+
| buf[pos + 3]) >>> 0;
|
|
327452
|
+
}
|
|
327453
|
+
return float;
|
|
327438
327454
|
}
|
|
327439
327455
|
|
|
327440
|
-
var
|
|
327456
|
+
var inquire_1;
|
|
327457
|
+
var hasRequiredInquire;
|
|
327441
327458
|
|
|
327442
|
-
|
|
327459
|
+
function requireInquire () {
|
|
327460
|
+
if (hasRequiredInquire) return inquire_1;
|
|
327461
|
+
hasRequiredInquire = 1;
|
|
327462
|
+
inquire_1 = inquire;
|
|
327443
327463
|
|
|
327444
327464
|
/**
|
|
327445
|
-
*
|
|
327465
|
+
* Requires a module only if available.
|
|
327446
327466
|
* @memberof util
|
|
327447
|
-
* @
|
|
327467
|
+
* @param {string} moduleName Module to require
|
|
327468
|
+
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
327448
327469
|
*/
|
|
327449
|
-
|
|
327470
|
+
function inquire(moduleName) {
|
|
327471
|
+
try {
|
|
327472
|
+
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
|
|
327473
|
+
if (mod && (mod.length || Object.keys(mod).length))
|
|
327474
|
+
return mod;
|
|
327475
|
+
} catch (e) {} // eslint-disable-line no-empty
|
|
327476
|
+
return null;
|
|
327477
|
+
}
|
|
327478
|
+
return inquire_1;
|
|
327479
|
+
}
|
|
327480
|
+
|
|
327481
|
+
var utf8$4 = {};
|
|
327482
|
+
|
|
327483
|
+
var hasRequiredUtf8;
|
|
327484
|
+
|
|
327485
|
+
function requireUtf8 () {
|
|
327486
|
+
if (hasRequiredUtf8) return utf8$4;
|
|
327487
|
+
hasRequiredUtf8 = 1;
|
|
327488
|
+
(function (exports) {
|
|
327489
|
+
|
|
327490
|
+
/**
|
|
327491
|
+
* A minimal UTF8 implementation for number arrays.
|
|
327492
|
+
* @memberof util
|
|
327493
|
+
* @namespace
|
|
327494
|
+
*/
|
|
327495
|
+
var utf8 = exports;
|
|
327496
|
+
|
|
327497
|
+
/**
|
|
327498
|
+
* Calculates the UTF8 byte length of a string.
|
|
327499
|
+
* @param {string} string String
|
|
327500
|
+
* @returns {number} Byte length
|
|
327501
|
+
*/
|
|
327502
|
+
utf8.length = function utf8_length(string) {
|
|
327503
|
+
var len = 0,
|
|
327504
|
+
c = 0;
|
|
327505
|
+
for (var i = 0; i < string.length; ++i) {
|
|
327506
|
+
c = string.charCodeAt(i);
|
|
327507
|
+
if (c < 128)
|
|
327508
|
+
len += 1;
|
|
327509
|
+
else if (c < 2048)
|
|
327510
|
+
len += 2;
|
|
327511
|
+
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
327512
|
+
++i;
|
|
327513
|
+
len += 4;
|
|
327514
|
+
} else
|
|
327515
|
+
len += 3;
|
|
327516
|
+
}
|
|
327517
|
+
return len;
|
|
327518
|
+
};
|
|
327519
|
+
|
|
327520
|
+
/**
|
|
327521
|
+
* Reads UTF8 bytes as a string.
|
|
327522
|
+
* @param {Uint8Array} buffer Source buffer
|
|
327523
|
+
* @param {number} start Source start
|
|
327524
|
+
* @param {number} end Source end
|
|
327525
|
+
* @returns {string} String read
|
|
327526
|
+
*/
|
|
327527
|
+
utf8.read = function utf8_read(buffer, start, end) {
|
|
327528
|
+
var len = end - start;
|
|
327529
|
+
if (len < 1)
|
|
327530
|
+
return "";
|
|
327531
|
+
var parts = null,
|
|
327532
|
+
chunk = [],
|
|
327533
|
+
i = 0, // char offset
|
|
327534
|
+
t; // temporary
|
|
327535
|
+
while (start < end) {
|
|
327536
|
+
t = buffer[start++];
|
|
327537
|
+
if (t < 128)
|
|
327538
|
+
chunk[i++] = t;
|
|
327539
|
+
else if (t > 191 && t < 224)
|
|
327540
|
+
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
327541
|
+
else if (t > 239 && t < 365) {
|
|
327542
|
+
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
327543
|
+
chunk[i++] = 0xD800 + (t >> 10);
|
|
327544
|
+
chunk[i++] = 0xDC00 + (t & 1023);
|
|
327545
|
+
} else
|
|
327546
|
+
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
327547
|
+
if (i > 8191) {
|
|
327548
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
327549
|
+
i = 0;
|
|
327550
|
+
}
|
|
327551
|
+
}
|
|
327552
|
+
if (parts) {
|
|
327553
|
+
if (i)
|
|
327554
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
327555
|
+
return parts.join("");
|
|
327556
|
+
}
|
|
327557
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
327558
|
+
};
|
|
327559
|
+
|
|
327560
|
+
/**
|
|
327561
|
+
* Writes a string as UTF8 bytes.
|
|
327562
|
+
* @param {string} string Source string
|
|
327563
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
327564
|
+
* @param {number} offset Destination offset
|
|
327565
|
+
* @returns {number} Bytes written
|
|
327566
|
+
*/
|
|
327567
|
+
utf8.write = function utf8_write(string, buffer, offset) {
|
|
327568
|
+
var start = offset,
|
|
327569
|
+
c1, // character 1
|
|
327570
|
+
c2; // character 2
|
|
327571
|
+
for (var i = 0; i < string.length; ++i) {
|
|
327572
|
+
c1 = string.charCodeAt(i);
|
|
327573
|
+
if (c1 < 128) {
|
|
327574
|
+
buffer[offset++] = c1;
|
|
327575
|
+
} else if (c1 < 2048) {
|
|
327576
|
+
buffer[offset++] = c1 >> 6 | 192;
|
|
327577
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
327578
|
+
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
327579
|
+
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
327580
|
+
++i;
|
|
327581
|
+
buffer[offset++] = c1 >> 18 | 240;
|
|
327582
|
+
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
327583
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
327584
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
327585
|
+
} else {
|
|
327586
|
+
buffer[offset++] = c1 >> 12 | 224;
|
|
327587
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
327588
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
327589
|
+
}
|
|
327590
|
+
}
|
|
327591
|
+
return offset - start;
|
|
327592
|
+
};
|
|
327593
|
+
} (utf8$4));
|
|
327594
|
+
return utf8$4;
|
|
327595
|
+
}
|
|
327596
|
+
|
|
327597
|
+
var pool_1;
|
|
327598
|
+
var hasRequiredPool;
|
|
327599
|
+
|
|
327600
|
+
function requirePool () {
|
|
327601
|
+
if (hasRequiredPool) return pool_1;
|
|
327602
|
+
hasRequiredPool = 1;
|
|
327603
|
+
pool_1 = pool;
|
|
327450
327604
|
|
|
327451
327605
|
/**
|
|
327452
|
-
*
|
|
327453
|
-
* @
|
|
327454
|
-
* @
|
|
327606
|
+
* An allocator as used by {@link util.pool}.
|
|
327607
|
+
* @typedef PoolAllocator
|
|
327608
|
+
* @type {function}
|
|
327609
|
+
* @param {number} size Buffer size
|
|
327610
|
+
* @returns {Uint8Array} Buffer
|
|
327455
327611
|
*/
|
|
327456
|
-
utf8.length = function utf8_length(string) {
|
|
327457
|
-
var len = 0,
|
|
327458
|
-
c = 0;
|
|
327459
|
-
for (var i = 0; i < string.length; ++i) {
|
|
327460
|
-
c = string.charCodeAt(i);
|
|
327461
|
-
if (c < 128)
|
|
327462
|
-
len += 1;
|
|
327463
|
-
else if (c < 2048)
|
|
327464
|
-
len += 2;
|
|
327465
|
-
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
327466
|
-
++i;
|
|
327467
|
-
len += 4;
|
|
327468
|
-
} else
|
|
327469
|
-
len += 3;
|
|
327470
|
-
}
|
|
327471
|
-
return len;
|
|
327472
|
-
};
|
|
327473
327612
|
|
|
327474
327613
|
/**
|
|
327475
|
-
*
|
|
327476
|
-
* @
|
|
327477
|
-
* @
|
|
327478
|
-
* @param {number}
|
|
327479
|
-
* @
|
|
327614
|
+
* A slicer as used by {@link util.pool}.
|
|
327615
|
+
* @typedef PoolSlicer
|
|
327616
|
+
* @type {function}
|
|
327617
|
+
* @param {number} start Start offset
|
|
327618
|
+
* @param {number} end End offset
|
|
327619
|
+
* @returns {Uint8Array} Buffer slice
|
|
327620
|
+
* @this {Uint8Array}
|
|
327480
327621
|
*/
|
|
327481
|
-
utf8.read = function utf8_read(buffer, start, end) {
|
|
327482
|
-
var len = end - start;
|
|
327483
|
-
if (len < 1)
|
|
327484
|
-
return "";
|
|
327485
|
-
var parts = null,
|
|
327486
|
-
chunk = [],
|
|
327487
|
-
i = 0, // char offset
|
|
327488
|
-
t; // temporary
|
|
327489
|
-
while (start < end) {
|
|
327490
|
-
t = buffer[start++];
|
|
327491
|
-
if (t < 128)
|
|
327492
|
-
chunk[i++] = t;
|
|
327493
|
-
else if (t > 191 && t < 224)
|
|
327494
|
-
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
327495
|
-
else if (t > 239 && t < 365) {
|
|
327496
|
-
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
327497
|
-
chunk[i++] = 0xD800 + (t >> 10);
|
|
327498
|
-
chunk[i++] = 0xDC00 + (t & 1023);
|
|
327499
|
-
} else
|
|
327500
|
-
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
327501
|
-
if (i > 8191) {
|
|
327502
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
327503
|
-
i = 0;
|
|
327504
|
-
}
|
|
327505
|
-
}
|
|
327506
|
-
if (parts) {
|
|
327507
|
-
if (i)
|
|
327508
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
327509
|
-
return parts.join("");
|
|
327510
|
-
}
|
|
327511
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
327512
|
-
};
|
|
327513
327622
|
|
|
327514
327623
|
/**
|
|
327515
|
-
*
|
|
327516
|
-
* @
|
|
327517
|
-
* @
|
|
327518
|
-
* @param {
|
|
327519
|
-
* @
|
|
327624
|
+
* A general purpose buffer pool.
|
|
327625
|
+
* @memberof util
|
|
327626
|
+
* @function
|
|
327627
|
+
* @param {PoolAllocator} alloc Allocator
|
|
327628
|
+
* @param {PoolSlicer} slice Slicer
|
|
327629
|
+
* @param {number} [size=8192] Slab size
|
|
327630
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
327520
327631
|
*/
|
|
327521
|
-
|
|
327522
|
-
var
|
|
327523
|
-
|
|
327524
|
-
|
|
327525
|
-
|
|
327526
|
-
|
|
327527
|
-
if (
|
|
327528
|
-
|
|
327529
|
-
|
|
327530
|
-
|
|
327531
|
-
|
|
327532
|
-
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
327533
|
-
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
327534
|
-
++i;
|
|
327535
|
-
buffer[offset++] = c1 >> 18 | 240;
|
|
327536
|
-
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
327537
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
327538
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
327539
|
-
} else {
|
|
327540
|
-
buffer[offset++] = c1 >> 12 | 224;
|
|
327541
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
327542
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
327632
|
+
function pool(alloc, slice, size) {
|
|
327633
|
+
var SIZE = size || 8192;
|
|
327634
|
+
var MAX = SIZE >>> 1;
|
|
327635
|
+
var slab = null;
|
|
327636
|
+
var offset = SIZE;
|
|
327637
|
+
return function pool_alloc(size) {
|
|
327638
|
+
if (size < 1 || size > MAX)
|
|
327639
|
+
return alloc(size);
|
|
327640
|
+
if (offset + size > SIZE) {
|
|
327641
|
+
slab = alloc(SIZE);
|
|
327642
|
+
offset = 0;
|
|
327543
327643
|
}
|
|
327544
|
-
|
|
327545
|
-
|
|
327546
|
-
|
|
327547
|
-
|
|
327548
|
-
|
|
327549
|
-
|
|
327550
|
-
|
|
327551
|
-
/**
|
|
327552
|
-
* An allocator as used by {@link util.pool}.
|
|
327553
|
-
* @typedef PoolAllocator
|
|
327554
|
-
* @type {function}
|
|
327555
|
-
* @param {number} size Buffer size
|
|
327556
|
-
* @returns {Uint8Array} Buffer
|
|
327557
|
-
*/
|
|
327558
|
-
|
|
327559
|
-
/**
|
|
327560
|
-
* A slicer as used by {@link util.pool}.
|
|
327561
|
-
* @typedef PoolSlicer
|
|
327562
|
-
* @type {function}
|
|
327563
|
-
* @param {number} start Start offset
|
|
327564
|
-
* @param {number} end End offset
|
|
327565
|
-
* @returns {Uint8Array} Buffer slice
|
|
327566
|
-
* @this {Uint8Array}
|
|
327567
|
-
*/
|
|
327568
|
-
|
|
327569
|
-
/**
|
|
327570
|
-
* A general purpose buffer pool.
|
|
327571
|
-
* @memberof util
|
|
327572
|
-
* @function
|
|
327573
|
-
* @param {PoolAllocator} alloc Allocator
|
|
327574
|
-
* @param {PoolSlicer} slice Slicer
|
|
327575
|
-
* @param {number} [size=8192] Slab size
|
|
327576
|
-
* @returns {PoolAllocator} Pooled allocator
|
|
327577
|
-
*/
|
|
327578
|
-
function pool$1(alloc, slice, size) {
|
|
327579
|
-
var SIZE = size || 8192;
|
|
327580
|
-
var MAX = SIZE >>> 1;
|
|
327581
|
-
var slab = null;
|
|
327582
|
-
var offset = SIZE;
|
|
327583
|
-
return function pool_alloc(size) {
|
|
327584
|
-
if (size < 1 || size > MAX)
|
|
327585
|
-
return alloc(size);
|
|
327586
|
-
if (offset + size > SIZE) {
|
|
327587
|
-
slab = alloc(SIZE);
|
|
327588
|
-
offset = 0;
|
|
327589
|
-
}
|
|
327590
|
-
var buf = slice.call(slab, offset, offset += size);
|
|
327591
|
-
if (offset & 7) // align to 32 bit
|
|
327592
|
-
offset = (offset | 7) + 1;
|
|
327593
|
-
return buf;
|
|
327594
|
-
};
|
|
327644
|
+
var buf = slice.call(slab, offset, offset += size);
|
|
327645
|
+
if (offset & 7) // align to 32 bit
|
|
327646
|
+
offset = (offset | 7) + 1;
|
|
327647
|
+
return buf;
|
|
327648
|
+
};
|
|
327649
|
+
}
|
|
327650
|
+
return pool_1;
|
|
327595
327651
|
}
|
|
327596
327652
|
|
|
327597
327653
|
var longbits;
|
|
@@ -327811,25 +327867,25 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
327811
327867
|
var util = exports;
|
|
327812
327868
|
|
|
327813
327869
|
// used to return a Promise where callback is omitted
|
|
327814
|
-
util.asPromise =
|
|
327870
|
+
util.asPromise = requireAspromise();
|
|
327815
327871
|
|
|
327816
327872
|
// converts to / from base64 encoded strings
|
|
327817
|
-
util.base64 =
|
|
327873
|
+
util.base64 = requireBase64();
|
|
327818
327874
|
|
|
327819
327875
|
// base class of rpc.Service
|
|
327820
|
-
util.EventEmitter =
|
|
327876
|
+
util.EventEmitter = requireEventemitter();
|
|
327821
327877
|
|
|
327822
327878
|
// float handling accross browsers
|
|
327823
|
-
util.float =
|
|
327879
|
+
util.float = requireFloat();
|
|
327824
327880
|
|
|
327825
327881
|
// requires modules optionally and hides the call from bundlers
|
|
327826
|
-
util.inquire =
|
|
327882
|
+
util.inquire = requireInquire();
|
|
327827
327883
|
|
|
327828
327884
|
// converts to / from utf8 encoded strings
|
|
327829
|
-
util.utf8 =
|
|
327885
|
+
util.utf8 = requireUtf8();
|
|
327830
327886
|
|
|
327831
327887
|
// provides a node-like buffer pool in the browser
|
|
327832
|
-
util.pool =
|
|
327888
|
+
util.pool = requirePool();
|
|
327833
327889
|
|
|
327834
327890
|
// utility to work with the low and high bits of a 64 bit value
|
|
327835
327891
|
util.LongBits = requireLongbits();
|