@audius/sdk 3.0.8-beta.4 → 3.0.8-beta.6
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/.nvmrc +1 -1
- package/dist/AudiusLibs.d.ts +3 -1
- package/dist/index.cjs.js +348 -248
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +348 -248
- package/dist/index.esm.js.map +1 -1
- package/dist/legacy.js +348 -248
- package/dist/legacy.js.map +1 -1
- package/dist/native-libs.js +313 -230
- package/dist/native-libs.js.map +1 -1
- package/dist/sdk/api/albums/types.d.ts +36 -36
- package/dist/sdk/api/playlists/types.d.ts +82 -82
- package/dist/sdk/api/tracks/TrackUploadHelper.d.ts +6 -6
- package/dist/services/discoveryProvider/DiscoveryProvider.d.ts +14 -0
- package/dist/services/web3Manager/Web3Manager.d.ts +5 -1
- package/dist/web-libs.js +313 -230
- package/dist/web-libs.js.map +1 -1
- package/package.json +2 -2
- package/src/AudiusLibs.ts +15 -1
- package/src/services/discoveryProvider/DiscoveryProvider.ts +21 -0
- package/src/services/web3Manager/Web3Manager.ts +41 -11
package/dist/index.esm.js
CHANGED
|
@@ -35937,9 +35937,9 @@ var EthWeb3Manager = /*#__PURE__*/function () {
|
|
|
35937
35937
|
}();
|
|
35938
35938
|
|
|
35939
35939
|
var name = "@audius/sdk";
|
|
35940
|
-
var version = "3.0.8-beta.
|
|
35940
|
+
var version = "3.0.8-beta.6";
|
|
35941
35941
|
var audius = {
|
|
35942
|
-
releaseSHA: "
|
|
35942
|
+
releaseSHA: "ea2ae182bca1fca4f27f02f9fa991789e42fe6cf"
|
|
35943
35943
|
};
|
|
35944
35944
|
var description = "Audius SDK";
|
|
35945
35945
|
var keywords = [
|
|
@@ -36780,10 +36780,13 @@ var Web3Manager = /*#__PURE__*/function () {
|
|
|
36780
36780
|
|
|
36781
36781
|
_defineProperty$1(this, "userSuppliedHandle", void 0);
|
|
36782
36782
|
|
|
36783
|
+
_defineProperty$1(this, "discoveryProvider", void 0);
|
|
36784
|
+
|
|
36783
36785
|
this.web3Config = web3Config;
|
|
36784
36786
|
this.isServer = isServer; // Unset if externalWeb3 = true
|
|
36785
36787
|
|
|
36786
36788
|
this.identityService = identityService;
|
|
36789
|
+
this.discoveryProvider = null;
|
|
36787
36790
|
this.hedgehog = hedgehog;
|
|
36788
36791
|
this.AudiusABIDecoder = AudiusABIDecoder;
|
|
36789
36792
|
}
|
|
@@ -36894,6 +36897,16 @@ var Web3Manager = /*#__PURE__*/function () {
|
|
|
36894
36897
|
value: function setWeb3(web3) {
|
|
36895
36898
|
this.web3 = web3;
|
|
36896
36899
|
}
|
|
36900
|
+
}, {
|
|
36901
|
+
key: "setDiscoveryProvider",
|
|
36902
|
+
value: function setDiscoveryProvider(discoveryProvider) {
|
|
36903
|
+
this.discoveryProvider = discoveryProvider;
|
|
36904
|
+
}
|
|
36905
|
+
}, {
|
|
36906
|
+
key: "useDiscoveryRelay",
|
|
36907
|
+
value: function useDiscoveryRelay() {
|
|
36908
|
+
return !(this.discoveryProvider === null);
|
|
36909
|
+
}
|
|
36897
36910
|
}, {
|
|
36898
36911
|
key: "getWalletAddress",
|
|
36899
36912
|
value: function getWalletAddress() {
|
|
@@ -37145,40 +37158,76 @@ var Web3Manager = /*#__PURE__*/function () {
|
|
|
37145
37158
|
_context6.next = 22;
|
|
37146
37159
|
return retry( /*#__PURE__*/function () {
|
|
37147
37160
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(bail) {
|
|
37148
|
-
var _this$identityService;
|
|
37161
|
+
var _this$discoveryProvid, res, _this$identityService;
|
|
37149
37162
|
|
|
37150
37163
|
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
37151
37164
|
while (1) {
|
|
37152
37165
|
switch (_context5.prev = _context5.next) {
|
|
37153
37166
|
case 0:
|
|
37154
37167
|
_context5.prev = 0;
|
|
37155
|
-
|
|
37168
|
+
|
|
37169
|
+
if (!_this.useDiscoveryRelay()) {
|
|
37170
|
+
_context5.next = 10;
|
|
37171
|
+
break;
|
|
37172
|
+
}
|
|
37173
|
+
|
|
37174
|
+
_context5.next = 4;
|
|
37175
|
+
return (_this$discoveryProvid = _this.discoveryProvider) === null || _this$discoveryProvid === void 0 ? void 0 : _this$discoveryProvid.relay({
|
|
37176
|
+
contractRegistryKey: contractRegistryKey,
|
|
37177
|
+
contractAddress: contractAddress,
|
|
37178
|
+
senderAddress: _this.ownerWallet.getAddressString(),
|
|
37179
|
+
encodedABI: encodedABI,
|
|
37180
|
+
gasLimit: gasLimit,
|
|
37181
|
+
handle: _this.userSuppliedHandle,
|
|
37182
|
+
nethermindContractAddress: nethermindContractAddress,
|
|
37183
|
+
nethermindEncodedAbi: nethermindEncodedAbi
|
|
37184
|
+
});
|
|
37185
|
+
|
|
37186
|
+
case 4:
|
|
37187
|
+
res = _context5.sent;
|
|
37188
|
+
|
|
37189
|
+
if (!(res === null || res === undefined)) {
|
|
37190
|
+
_context5.next = 7;
|
|
37191
|
+
break;
|
|
37192
|
+
}
|
|
37193
|
+
|
|
37194
|
+
throw new Error("discovery relay returned empty response");
|
|
37195
|
+
|
|
37196
|
+
case 7:
|
|
37197
|
+
return _context5.abrupt("return", res);
|
|
37198
|
+
|
|
37199
|
+
case 10:
|
|
37200
|
+
_context5.next = 12;
|
|
37156
37201
|
return (_this$identityService = _this.identityService) === null || _this$identityService === void 0 ? void 0 : _this$identityService.relay(contractRegistryKey, contractAddress, _this.ownerWallet.getAddressString(), encodedABI, gasLimit, _this.userSuppliedHandle, nethermindContractAddress, nethermindEncodedAbi);
|
|
37157
37202
|
|
|
37158
|
-
case
|
|
37203
|
+
case 12:
|
|
37159
37204
|
return _context5.abrupt("return", _context5.sent);
|
|
37160
37205
|
|
|
37161
|
-
case
|
|
37162
|
-
_context5.
|
|
37206
|
+
case 13:
|
|
37207
|
+
_context5.next = 21;
|
|
37208
|
+
break;
|
|
37209
|
+
|
|
37210
|
+
case 15:
|
|
37211
|
+
_context5.prev = 15;
|
|
37163
37212
|
_context5.t0 = _context5["catch"](0);
|
|
37164
37213
|
|
|
37165
37214
|
if (!(_context5.t0.response.status === 403)) {
|
|
37166
|
-
_context5.next =
|
|
37215
|
+
_context5.next = 20;
|
|
37167
37216
|
break;
|
|
37168
37217
|
}
|
|
37169
37218
|
|
|
37170
37219
|
bail(_context5.t0);
|
|
37171
37220
|
return _context5.abrupt("return");
|
|
37172
37221
|
|
|
37173
|
-
case
|
|
37222
|
+
case 20:
|
|
37174
37223
|
throw _context5.t0;
|
|
37175
37224
|
|
|
37176
|
-
case
|
|
37225
|
+
case 21:
|
|
37177
37226
|
case "end":
|
|
37178
37227
|
return _context5.stop();
|
|
37179
37228
|
}
|
|
37180
37229
|
}
|
|
37181
|
-
}, _callee5, null, [[0,
|
|
37230
|
+
}, _callee5, null, [[0, 15]]);
|
|
37182
37231
|
}));
|
|
37183
37232
|
|
|
37184
37233
|
return function (_x8) {
|
|
@@ -66507,6 +66556,40 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66507
66556
|
|
|
66508
66557
|
return getUserReplicaSet$1;
|
|
66509
66558
|
}()
|
|
66559
|
+
}, {
|
|
66560
|
+
key: "relay",
|
|
66561
|
+
value: function () {
|
|
66562
|
+
var _relay = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee55(data) {
|
|
66563
|
+
var req;
|
|
66564
|
+
return regeneratorRuntime.wrap(function _callee55$(_context55) {
|
|
66565
|
+
while (1) {
|
|
66566
|
+
switch (_context55.prev = _context55.next) {
|
|
66567
|
+
case 0:
|
|
66568
|
+
req = {
|
|
66569
|
+
endpoint: 'relay',
|
|
66570
|
+
method: 'post',
|
|
66571
|
+
data: data
|
|
66572
|
+
};
|
|
66573
|
+
_context55.next = 3;
|
|
66574
|
+
return this._makeRequest(req, true, 0, true);
|
|
66575
|
+
|
|
66576
|
+
case 3:
|
|
66577
|
+
return _context55.abrupt("return", _context55.sent);
|
|
66578
|
+
|
|
66579
|
+
case 4:
|
|
66580
|
+
case "end":
|
|
66581
|
+
return _context55.stop();
|
|
66582
|
+
}
|
|
66583
|
+
}
|
|
66584
|
+
}, _callee55, this);
|
|
66585
|
+
}));
|
|
66586
|
+
|
|
66587
|
+
function relay(_x74) {
|
|
66588
|
+
return _relay.apply(this, arguments);
|
|
66589
|
+
}
|
|
66590
|
+
|
|
66591
|
+
return relay;
|
|
66592
|
+
}()
|
|
66510
66593
|
/**
|
|
66511
66594
|
* Retrieves an unclaimed ID
|
|
66512
66595
|
* @return encoded ID
|
|
@@ -66515,28 +66598,28 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66515
66598
|
}, {
|
|
66516
66599
|
key: "getUnclaimedId",
|
|
66517
66600
|
value: function () {
|
|
66518
|
-
var _getUnclaimedId = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66601
|
+
var _getUnclaimedId = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee56(type) {
|
|
66519
66602
|
var req;
|
|
66520
|
-
return regeneratorRuntime.wrap(function
|
|
66603
|
+
return regeneratorRuntime.wrap(function _callee56$(_context56) {
|
|
66521
66604
|
while (1) {
|
|
66522
|
-
switch (
|
|
66605
|
+
switch (_context56.prev = _context56.next) {
|
|
66523
66606
|
case 0:
|
|
66524
66607
|
req = getUnclaimedId(type);
|
|
66525
|
-
|
|
66608
|
+
_context56.next = 3;
|
|
66526
66609
|
return this._makeRequest(req);
|
|
66527
66610
|
|
|
66528
66611
|
case 3:
|
|
66529
|
-
return
|
|
66612
|
+
return _context56.abrupt("return", _context56.sent);
|
|
66530
66613
|
|
|
66531
66614
|
case 4:
|
|
66532
66615
|
case "end":
|
|
66533
|
-
return
|
|
66616
|
+
return _context56.stop();
|
|
66534
66617
|
}
|
|
66535
66618
|
}
|
|
66536
|
-
},
|
|
66619
|
+
}, _callee56, this);
|
|
66537
66620
|
}));
|
|
66538
66621
|
|
|
66539
|
-
function getUnclaimedId$1(
|
|
66622
|
+
function getUnclaimedId$1(_x75) {
|
|
66540
66623
|
return _getUnclaimedId.apply(this, arguments);
|
|
66541
66624
|
}
|
|
66542
66625
|
|
|
@@ -66553,24 +66636,24 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66553
66636
|
}, {
|
|
66554
66637
|
key: "_performRequestWithMonitoring",
|
|
66555
66638
|
value: function () {
|
|
66556
|
-
var _performRequestWithMonitoring2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66639
|
+
var _performRequestWithMonitoring2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee57(requestObj, discoveryProviderEndpoint) {
|
|
66557
66640
|
var _axiosRequest$url;
|
|
66558
66641
|
|
|
66559
66642
|
var axiosRequest, response, parsedResponse, url, start, duration, _this$monitoringCallb, _this$monitoringCallb2, _error$response$data, _error$response, error, resp, _duration, errData, _this$monitoringCallb3, _this$monitoringCallb4;
|
|
66560
66643
|
|
|
66561
|
-
return regeneratorRuntime.wrap(function
|
|
66644
|
+
return regeneratorRuntime.wrap(function _callee57$(_context57) {
|
|
66562
66645
|
while (1) {
|
|
66563
|
-
switch (
|
|
66646
|
+
switch (_context57.prev = _context57.next) {
|
|
66564
66647
|
case 0:
|
|
66565
66648
|
axiosRequest = this._createDiscProvRequest(requestObj, discoveryProviderEndpoint);
|
|
66566
66649
|
url = new URL((_axiosRequest$url = axiosRequest.url) !== null && _axiosRequest$url !== void 0 ? _axiosRequest$url : '');
|
|
66567
66650
|
start = Date.now();
|
|
66568
|
-
|
|
66569
|
-
|
|
66651
|
+
_context57.prev = 3;
|
|
66652
|
+
_context57.next = 6;
|
|
66570
66653
|
return axios(axiosRequest);
|
|
66571
66654
|
|
|
66572
66655
|
case 6:
|
|
66573
|
-
response =
|
|
66656
|
+
response = _context57.sent;
|
|
66574
66657
|
duration = Date.now() - start;
|
|
66575
66658
|
parsedResponse = Utils.parseDataFromResponse(response); // Fire monitoring callbacks for request success case
|
|
66576
66659
|
|
|
@@ -66592,13 +66675,13 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66592
66675
|
}
|
|
66593
66676
|
}
|
|
66594
66677
|
|
|
66595
|
-
|
|
66678
|
+
_context57.next = 22;
|
|
66596
66679
|
break;
|
|
66597
66680
|
|
|
66598
66681
|
case 12:
|
|
66599
|
-
|
|
66600
|
-
|
|
66601
|
-
error =
|
|
66682
|
+
_context57.prev = 12;
|
|
66683
|
+
_context57.t0 = _context57["catch"](3);
|
|
66684
|
+
error = _context57.t0;
|
|
66602
66685
|
resp = error.response;
|
|
66603
66686
|
_duration = Date.now() - start;
|
|
66604
66687
|
errData = (_error$response$data = (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) !== null && _error$response$data !== void 0 ? _error$response$data : error; // Fire monitoring callbacks for request failure case
|
|
@@ -66620,7 +66703,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66620
66703
|
}
|
|
66621
66704
|
|
|
66622
66705
|
if (!(resp && resp.status === 404)) {
|
|
66623
|
-
|
|
66706
|
+
_context57.next = 21;
|
|
66624
66707
|
break;
|
|
66625
66708
|
}
|
|
66626
66709
|
|
|
@@ -66632,17 +66715,17 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66632
66715
|
throw errData;
|
|
66633
66716
|
|
|
66634
66717
|
case 22:
|
|
66635
|
-
return
|
|
66718
|
+
return _context57.abrupt("return", parsedResponse);
|
|
66636
66719
|
|
|
66637
66720
|
case 23:
|
|
66638
66721
|
case "end":
|
|
66639
|
-
return
|
|
66722
|
+
return _context57.stop();
|
|
66640
66723
|
}
|
|
66641
66724
|
}
|
|
66642
|
-
},
|
|
66725
|
+
}, _callee57, this, [[3, 12]]);
|
|
66643
66726
|
}));
|
|
66644
66727
|
|
|
66645
|
-
function _performRequestWithMonitoring(
|
|
66728
|
+
function _performRequestWithMonitoring(_x76, _x77) {
|
|
66646
66729
|
return _performRequestWithMonitoring2.apply(this, arguments);
|
|
66647
66730
|
}
|
|
66648
66731
|
|
|
@@ -66659,41 +66742,41 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66659
66742
|
}, {
|
|
66660
66743
|
key: "_getBlocksBehind",
|
|
66661
66744
|
value: function () {
|
|
66662
|
-
var _getBlocksBehind2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66745
|
+
var _getBlocksBehind2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee58(parsedResponse) {
|
|
66663
66746
|
var indexedBlock, chainBlock, blockDiff;
|
|
66664
|
-
return regeneratorRuntime.wrap(function
|
|
66747
|
+
return regeneratorRuntime.wrap(function _callee58$(_context58) {
|
|
66665
66748
|
while (1) {
|
|
66666
|
-
switch (
|
|
66749
|
+
switch (_context58.prev = _context58.next) {
|
|
66667
66750
|
case 0:
|
|
66668
|
-
|
|
66751
|
+
_context58.prev = 0;
|
|
66669
66752
|
indexedBlock = parsedResponse.latest_indexed_block, chainBlock = parsedResponse.latest_chain_block;
|
|
66670
66753
|
blockDiff = chainBlock - indexedBlock;
|
|
66671
66754
|
|
|
66672
66755
|
if (!(blockDiff > this.unhealthyBlockDiff)) {
|
|
66673
|
-
|
|
66756
|
+
_context58.next = 5;
|
|
66674
66757
|
break;
|
|
66675
66758
|
}
|
|
66676
66759
|
|
|
66677
|
-
return
|
|
66760
|
+
return _context58.abrupt("return", blockDiff);
|
|
66678
66761
|
|
|
66679
66762
|
case 5:
|
|
66680
|
-
return
|
|
66763
|
+
return _context58.abrupt("return", null);
|
|
66681
66764
|
|
|
66682
66765
|
case 8:
|
|
66683
|
-
|
|
66684
|
-
|
|
66685
|
-
console.error(
|
|
66686
|
-
return
|
|
66766
|
+
_context58.prev = 8;
|
|
66767
|
+
_context58.t0 = _context58["catch"](0);
|
|
66768
|
+
console.error(_context58.t0);
|
|
66769
|
+
return _context58.abrupt("return", this.unhealthyBlockDiff);
|
|
66687
66770
|
|
|
66688
66771
|
case 12:
|
|
66689
66772
|
case "end":
|
|
66690
|
-
return
|
|
66773
|
+
return _context58.stop();
|
|
66691
66774
|
}
|
|
66692
66775
|
}
|
|
66693
|
-
},
|
|
66776
|
+
}, _callee58, this, [[0, 8]]);
|
|
66694
66777
|
}));
|
|
66695
66778
|
|
|
66696
|
-
function _getBlocksBehind(
|
|
66779
|
+
function _getBlocksBehind(_x78) {
|
|
66697
66780
|
return _getBlocksBehind2.apply(this, arguments);
|
|
66698
66781
|
}
|
|
66699
66782
|
|
|
@@ -66710,49 +66793,49 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66710
66793
|
}, {
|
|
66711
66794
|
key: "_getPlaysSlotsBehind",
|
|
66712
66795
|
value: function () {
|
|
66713
|
-
var _getPlaysSlotsBehind2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66796
|
+
var _getPlaysSlotsBehind2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee59(parsedResponse) {
|
|
66714
66797
|
var indexedSlotPlays, chainSlotPlays, slotDiff;
|
|
66715
|
-
return regeneratorRuntime.wrap(function
|
|
66798
|
+
return regeneratorRuntime.wrap(function _callee59$(_context59) {
|
|
66716
66799
|
while (1) {
|
|
66717
|
-
switch (
|
|
66800
|
+
switch (_context59.prev = _context59.next) {
|
|
66718
66801
|
case 0:
|
|
66719
66802
|
if (this.unhealthySlotDiffPlays) {
|
|
66720
|
-
|
|
66803
|
+
_context59.next = 2;
|
|
66721
66804
|
break;
|
|
66722
66805
|
}
|
|
66723
66806
|
|
|
66724
|
-
return
|
|
66807
|
+
return _context59.abrupt("return", null);
|
|
66725
66808
|
|
|
66726
66809
|
case 2:
|
|
66727
|
-
|
|
66810
|
+
_context59.prev = 2;
|
|
66728
66811
|
indexedSlotPlays = parsedResponse.latest_indexed_slot_plays, chainSlotPlays = parsedResponse.latest_chain_slot_plays;
|
|
66729
66812
|
slotDiff = chainSlotPlays - indexedSlotPlays;
|
|
66730
66813
|
|
|
66731
66814
|
if (!(slotDiff > this.unhealthySlotDiffPlays)) {
|
|
66732
|
-
|
|
66815
|
+
_context59.next = 7;
|
|
66733
66816
|
break;
|
|
66734
66817
|
}
|
|
66735
66818
|
|
|
66736
|
-
return
|
|
66819
|
+
return _context59.abrupt("return", slotDiff);
|
|
66737
66820
|
|
|
66738
66821
|
case 7:
|
|
66739
|
-
return
|
|
66822
|
+
return _context59.abrupt("return", null);
|
|
66740
66823
|
|
|
66741
66824
|
case 10:
|
|
66742
|
-
|
|
66743
|
-
|
|
66744
|
-
console.error(
|
|
66745
|
-
return
|
|
66825
|
+
_context59.prev = 10;
|
|
66826
|
+
_context59.t0 = _context59["catch"](2);
|
|
66827
|
+
console.error(_context59.t0);
|
|
66828
|
+
return _context59.abrupt("return", this.unhealthySlotDiffPlays);
|
|
66746
66829
|
|
|
66747
66830
|
case 14:
|
|
66748
66831
|
case "end":
|
|
66749
|
-
return
|
|
66832
|
+
return _context59.stop();
|
|
66750
66833
|
}
|
|
66751
66834
|
}
|
|
66752
|
-
},
|
|
66835
|
+
}, _callee59, this, [[2, 10]]);
|
|
66753
66836
|
}));
|
|
66754
66837
|
|
|
66755
|
-
function _getPlaysSlotsBehind(
|
|
66838
|
+
function _getPlaysSlotsBehind(_x79) {
|
|
66756
66839
|
return _getPlaysSlotsBehind2.apply(this, arguments);
|
|
66757
66840
|
}
|
|
66758
66841
|
|
|
@@ -66782,61 +66865,61 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66782
66865
|
}, {
|
|
66783
66866
|
key: "_makeRequest",
|
|
66784
66867
|
value: function () {
|
|
66785
|
-
var _makeRequest2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66868
|
+
var _makeRequest2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee60(requestObj) {
|
|
66786
66869
|
var _yield$this$_makeRequ;
|
|
66787
66870
|
|
|
66788
66871
|
var retry,
|
|
66789
66872
|
attemptedRetries,
|
|
66790
66873
|
throwError,
|
|
66791
66874
|
blockNumber,
|
|
66792
|
-
|
|
66793
|
-
return regeneratorRuntime.wrap(function
|
|
66875
|
+
_args60 = arguments;
|
|
66876
|
+
return regeneratorRuntime.wrap(function _callee60$(_context60) {
|
|
66794
66877
|
while (1) {
|
|
66795
|
-
switch (
|
|
66878
|
+
switch (_context60.prev = _context60.next) {
|
|
66796
66879
|
case 0:
|
|
66797
|
-
retry =
|
|
66798
|
-
attemptedRetries =
|
|
66799
|
-
throwError =
|
|
66800
|
-
blockNumber =
|
|
66801
|
-
|
|
66880
|
+
retry = _args60.length > 1 && _args60[1] !== undefined ? _args60[1] : true;
|
|
66881
|
+
attemptedRetries = _args60.length > 2 && _args60[2] !== undefined ? _args60[2] : 0;
|
|
66882
|
+
throwError = _args60.length > 3 && _args60[3] !== undefined ? _args60[3] : false;
|
|
66883
|
+
blockNumber = _args60.length > 4 ? _args60[4] : undefined;
|
|
66884
|
+
_context60.next = 6;
|
|
66802
66885
|
return this._makeRequestInternal(requestObj, retry, attemptedRetries, throwError, blockNumber);
|
|
66803
66886
|
|
|
66804
66887
|
case 6:
|
|
66805
|
-
|
|
66806
|
-
|
|
66888
|
+
_context60.t1 = _yield$this$_makeRequ = _context60.sent;
|
|
66889
|
+
_context60.t0 = _context60.t1 === null;
|
|
66807
66890
|
|
|
66808
|
-
if (
|
|
66809
|
-
|
|
66891
|
+
if (_context60.t0) {
|
|
66892
|
+
_context60.next = 10;
|
|
66810
66893
|
break;
|
|
66811
66894
|
}
|
|
66812
66895
|
|
|
66813
|
-
|
|
66896
|
+
_context60.t0 = _yield$this$_makeRequ === void 0;
|
|
66814
66897
|
|
|
66815
66898
|
case 10:
|
|
66816
|
-
if (!
|
|
66817
|
-
|
|
66899
|
+
if (!_context60.t0) {
|
|
66900
|
+
_context60.next = 14;
|
|
66818
66901
|
break;
|
|
66819
66902
|
}
|
|
66820
66903
|
|
|
66821
|
-
|
|
66822
|
-
|
|
66904
|
+
_context60.t2 = void 0;
|
|
66905
|
+
_context60.next = 15;
|
|
66823
66906
|
break;
|
|
66824
66907
|
|
|
66825
66908
|
case 14:
|
|
66826
|
-
|
|
66909
|
+
_context60.t2 = _yield$this$_makeRequ.data;
|
|
66827
66910
|
|
|
66828
66911
|
case 15:
|
|
66829
|
-
return
|
|
66912
|
+
return _context60.abrupt("return", _context60.t2);
|
|
66830
66913
|
|
|
66831
66914
|
case 16:
|
|
66832
66915
|
case "end":
|
|
66833
|
-
return
|
|
66916
|
+
return _context60.stop();
|
|
66834
66917
|
}
|
|
66835
66918
|
}
|
|
66836
|
-
},
|
|
66919
|
+
}, _callee60, this);
|
|
66837
66920
|
}));
|
|
66838
66921
|
|
|
66839
|
-
function _makeRequest(
|
|
66922
|
+
function _makeRequest(_x80) {
|
|
66840
66923
|
return _makeRequest2.apply(this, arguments);
|
|
66841
66924
|
}
|
|
66842
66925
|
|
|
@@ -66858,48 +66941,48 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66858
66941
|
}, {
|
|
66859
66942
|
key: "_makeRequestInternal",
|
|
66860
66943
|
value: function () {
|
|
66861
|
-
var _makeRequestInternal2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66944
|
+
var _makeRequestInternal2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee61(requestObj) {
|
|
66862
66945
|
var retry,
|
|
66863
66946
|
attemptedRetries,
|
|
66864
66947
|
throwError,
|
|
66865
66948
|
blockNumber,
|
|
66866
|
-
|
|
66867
|
-
return regeneratorRuntime.wrap(function
|
|
66949
|
+
_args61 = arguments;
|
|
66950
|
+
return regeneratorRuntime.wrap(function _callee61$(_context61) {
|
|
66868
66951
|
while (1) {
|
|
66869
|
-
switch (
|
|
66952
|
+
switch (_context61.prev = _context61.next) {
|
|
66870
66953
|
case 0:
|
|
66871
|
-
retry =
|
|
66872
|
-
attemptedRetries =
|
|
66873
|
-
throwError =
|
|
66874
|
-
blockNumber =
|
|
66954
|
+
retry = _args61.length > 1 && _args61[1] !== undefined ? _args61[1] : true;
|
|
66955
|
+
attemptedRetries = _args61.length > 2 && _args61[2] !== undefined ? _args61[2] : 0;
|
|
66956
|
+
throwError = _args61.length > 3 && _args61[3] !== undefined ? _args61[3] : false;
|
|
66957
|
+
blockNumber = _args61.length > 4 ? _args61[4] : undefined;
|
|
66875
66958
|
|
|
66876
66959
|
if (!this.discoveryNodeSelector) {
|
|
66877
|
-
|
|
66960
|
+
_context61.next = 8;
|
|
66878
66961
|
break;
|
|
66879
66962
|
}
|
|
66880
66963
|
|
|
66881
|
-
|
|
66964
|
+
_context61.next = 7;
|
|
66882
66965
|
return this._makeRequestInternalNext(requestObj, throwError, blockNumber);
|
|
66883
66966
|
|
|
66884
66967
|
case 7:
|
|
66885
|
-
return
|
|
66968
|
+
return _context61.abrupt("return", _context61.sent);
|
|
66886
66969
|
|
|
66887
66970
|
case 8:
|
|
66888
|
-
|
|
66971
|
+
_context61.next = 10;
|
|
66889
66972
|
return this._makeRequestInternalLegacy(requestObj, retry, attemptedRetries, throwError, blockNumber);
|
|
66890
66973
|
|
|
66891
66974
|
case 10:
|
|
66892
|
-
return
|
|
66975
|
+
return _context61.abrupt("return", _context61.sent);
|
|
66893
66976
|
|
|
66894
66977
|
case 11:
|
|
66895
66978
|
case "end":
|
|
66896
|
-
return
|
|
66979
|
+
return _context61.stop();
|
|
66897
66980
|
}
|
|
66898
66981
|
}
|
|
66899
|
-
},
|
|
66982
|
+
}, _callee61, this);
|
|
66900
66983
|
}));
|
|
66901
66984
|
|
|
66902
|
-
function _makeRequestInternal(
|
|
66985
|
+
function _makeRequestInternal(_x81) {
|
|
66903
66986
|
return _makeRequestInternal2.apply(this, arguments);
|
|
66904
66987
|
}
|
|
66905
66988
|
|
|
@@ -66908,7 +66991,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66908
66991
|
}, {
|
|
66909
66992
|
key: "_makeRequestInternalLegacy",
|
|
66910
66993
|
value: function () {
|
|
66911
|
-
var _makeRequestInternalLegacy2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66994
|
+
var _makeRequestInternalLegacy2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee62(requestObj) {
|
|
66912
66995
|
var retry,
|
|
66913
66996
|
attemptedRetries,
|
|
66914
66997
|
throwError,
|
|
@@ -66928,16 +67011,16 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66928
67011
|
errorMessage,
|
|
66929
67012
|
playsSlotDiff,
|
|
66930
67013
|
_errorMessage,
|
|
66931
|
-
|
|
67014
|
+
_args62 = arguments;
|
|
66932
67015
|
|
|
66933
|
-
return regeneratorRuntime.wrap(function
|
|
67016
|
+
return regeneratorRuntime.wrap(function _callee62$(_context62) {
|
|
66934
67017
|
while (1) {
|
|
66935
|
-
switch (
|
|
67018
|
+
switch (_context62.prev = _context62.next) {
|
|
66936
67019
|
case 0:
|
|
66937
|
-
retry =
|
|
66938
|
-
attemptedRetries =
|
|
66939
|
-
throwError =
|
|
66940
|
-
blockNumber =
|
|
67020
|
+
retry = _args62.length > 1 && _args62[1] !== undefined ? _args62[1] : true;
|
|
67021
|
+
attemptedRetries = _args62.length > 2 && _args62[2] !== undefined ? _args62[2] : 0;
|
|
67022
|
+
throwError = _args62.length > 3 && _args62[3] !== undefined ? _args62[3] : false;
|
|
67023
|
+
blockNumber = _args62.length > 4 ? _args62[4] : undefined;
|
|
66941
67024
|
|
|
66942
67025
|
returnOrThrow = function returnOrThrow(e) {
|
|
66943
67026
|
if (throwError) {
|
|
@@ -66948,12 +67031,12 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66948
67031
|
return null;
|
|
66949
67032
|
};
|
|
66950
67033
|
|
|
66951
|
-
|
|
66952
|
-
|
|
67034
|
+
_context62.prev = 5;
|
|
67035
|
+
_context62.next = 8;
|
|
66953
67036
|
return this.getHealthyDiscoveryProviderEndpoint(attemptedRetries);
|
|
66954
67037
|
|
|
66955
67038
|
case 8:
|
|
66956
|
-
newDiscProvEndpoint =
|
|
67039
|
+
newDiscProvEndpoint = _context62.sent;
|
|
66957
67040
|
|
|
66958
67041
|
// If new DP endpoint is selected, update disc prov endpoint and reset attemptedRetries count
|
|
66959
67042
|
if (this.discoveryProviderEndpoint !== newDiscProvEndpoint) {
|
|
@@ -66964,29 +67047,29 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66964
67047
|
attemptedRetries = 0;
|
|
66965
67048
|
}
|
|
66966
67049
|
|
|
66967
|
-
|
|
67050
|
+
_context62.next = 16;
|
|
66968
67051
|
break;
|
|
66969
67052
|
|
|
66970
67053
|
case 12:
|
|
66971
|
-
|
|
66972
|
-
|
|
66973
|
-
console.error(
|
|
66974
|
-
return
|
|
67054
|
+
_context62.prev = 12;
|
|
67055
|
+
_context62.t0 = _context62["catch"](5);
|
|
67056
|
+
console.error(_context62.t0);
|
|
67057
|
+
return _context62.abrupt("return");
|
|
66975
67058
|
|
|
66976
67059
|
case 16:
|
|
66977
|
-
|
|
66978
|
-
|
|
67060
|
+
_context62.prev = 16;
|
|
67061
|
+
_context62.next = 19;
|
|
66979
67062
|
return this._performRequestWithMonitoring(requestObj, this.discoveryProviderEndpoint);
|
|
66980
67063
|
|
|
66981
67064
|
case 19:
|
|
66982
|
-
parsedResponse =
|
|
66983
|
-
|
|
67065
|
+
parsedResponse = _context62.sent;
|
|
67066
|
+
_context62.next = 46;
|
|
66984
67067
|
break;
|
|
66985
67068
|
|
|
66986
67069
|
case 22:
|
|
66987
|
-
|
|
66988
|
-
|
|
66989
|
-
error =
|
|
67070
|
+
_context62.prev = 22;
|
|
67071
|
+
_context62.t1 = _context62["catch"](16);
|
|
67072
|
+
error = _context62.t1;
|
|
66990
67073
|
failureStr = 'Failed to make Discovery Provider request, ';
|
|
66991
67074
|
attemptStr = "attempt #".concat(attemptedRetries, ", ");
|
|
66992
67075
|
errorStr = "error ".concat(JSON.stringify(error.message), ", ");
|
|
@@ -66995,55 +67078,55 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66995
67078
|
console.warn(fullErrString);
|
|
66996
67079
|
|
|
66997
67080
|
if (!retry) {
|
|
66998
|
-
|
|
67081
|
+
_context62.next = 45;
|
|
66999
67082
|
break;
|
|
67000
67083
|
}
|
|
67001
67084
|
|
|
67002
67085
|
if (!(error.status === '404')) {
|
|
67003
|
-
|
|
67086
|
+
_context62.next = 42;
|
|
67004
67087
|
break;
|
|
67005
67088
|
}
|
|
67006
67089
|
|
|
67007
67090
|
this.request404Count += 1;
|
|
67008
67091
|
|
|
67009
67092
|
if (!(this.request404Count < this.maxRequestsForTrue404)) {
|
|
67010
|
-
|
|
67093
|
+
_context62.next = 40;
|
|
67011
67094
|
break;
|
|
67012
67095
|
}
|
|
67013
67096
|
|
|
67014
|
-
|
|
67097
|
+
_context62.next = 37;
|
|
67015
67098
|
return this._makeRequestInternalLegacy(requestObj, retry, this.selectionRequestRetries + 1, throwError);
|
|
67016
67099
|
|
|
67017
67100
|
case 37:
|
|
67018
|
-
return
|
|
67101
|
+
return _context62.abrupt("return", _context62.sent);
|
|
67019
67102
|
|
|
67020
67103
|
case 40:
|
|
67021
67104
|
this.request404Count = 0;
|
|
67022
|
-
return
|
|
67105
|
+
return _context62.abrupt("return", returnOrThrow(_context62.t1));
|
|
67023
67106
|
|
|
67024
67107
|
case 42:
|
|
67025
|
-
|
|
67108
|
+
_context62.next = 44;
|
|
67026
67109
|
return this._makeRequestInternalLegacy(requestObj, retry, attemptedRetries + 1, throwError);
|
|
67027
67110
|
|
|
67028
67111
|
case 44:
|
|
67029
|
-
return
|
|
67112
|
+
return _context62.abrupt("return", _context62.sent);
|
|
67030
67113
|
|
|
67031
67114
|
case 45:
|
|
67032
|
-
return
|
|
67115
|
+
return _context62.abrupt("return", returnOrThrow(_context62.t1));
|
|
67033
67116
|
|
|
67034
67117
|
case 46:
|
|
67035
67118
|
// Validate health check response
|
|
67036
67119
|
// Regressed mode signals we couldn't find a node that wasn't behind by some measure
|
|
67037
67120
|
// so we should should pick something
|
|
67038
67121
|
notInRegressedMode = this.ethContracts && !this.ethContracts.isInRegressedMode();
|
|
67039
|
-
|
|
67122
|
+
_context62.next = 49;
|
|
67040
67123
|
return this._getBlocksBehind(parsedResponse);
|
|
67041
67124
|
|
|
67042
67125
|
case 49:
|
|
67043
|
-
blockDiff =
|
|
67126
|
+
blockDiff = _context62.sent;
|
|
67044
67127
|
|
|
67045
67128
|
if (!(blockNumber && parsedResponse.latest_indexed_block < blockNumber)) {
|
|
67046
|
-
|
|
67129
|
+
_context62.next = 52;
|
|
67047
67130
|
break;
|
|
67048
67131
|
}
|
|
67049
67132
|
|
|
@@ -67051,71 +67134,71 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67051
67134
|
|
|
67052
67135
|
case 52:
|
|
67053
67136
|
if (!(notInRegressedMode && blockDiff)) {
|
|
67054
|
-
|
|
67137
|
+
_context62.next = 60;
|
|
67055
67138
|
break;
|
|
67056
67139
|
}
|
|
67057
67140
|
|
|
67058
67141
|
errorMessage = "".concat(this.discoveryProviderEndpoint, " is too far behind [block diff: ").concat(blockDiff, "]");
|
|
67059
67142
|
|
|
67060
67143
|
if (!retry) {
|
|
67061
|
-
|
|
67144
|
+
_context62.next = 59;
|
|
67062
67145
|
break;
|
|
67063
67146
|
}
|
|
67064
67147
|
|
|
67065
67148
|
console.info("".concat(errorMessage, ". Retrying request at attempt #").concat(attemptedRetries, "..."));
|
|
67066
|
-
|
|
67149
|
+
_context62.next = 58;
|
|
67067
67150
|
return this._makeRequestInternalLegacy(requestObj, retry, attemptedRetries + 1, throwError);
|
|
67068
67151
|
|
|
67069
67152
|
case 58:
|
|
67070
|
-
return
|
|
67153
|
+
return _context62.abrupt("return", _context62.sent);
|
|
67071
67154
|
|
|
67072
67155
|
case 59:
|
|
67073
|
-
return
|
|
67156
|
+
return _context62.abrupt("return", returnOrThrow(new Error(errorMessage)));
|
|
67074
67157
|
|
|
67075
67158
|
case 60:
|
|
67076
|
-
|
|
67159
|
+
_context62.next = 62;
|
|
67077
67160
|
return this._getPlaysSlotsBehind(parsedResponse);
|
|
67078
67161
|
|
|
67079
67162
|
case 62:
|
|
67080
|
-
playsSlotDiff =
|
|
67163
|
+
playsSlotDiff = _context62.sent;
|
|
67081
67164
|
|
|
67082
67165
|
if (!(notInRegressedMode && playsSlotDiff)) {
|
|
67083
|
-
|
|
67166
|
+
_context62.next = 71;
|
|
67084
67167
|
break;
|
|
67085
67168
|
}
|
|
67086
67169
|
|
|
67087
67170
|
_errorMessage = "".concat(this.discoveryProviderEndpoint, " is too far behind [slot diff: ").concat(playsSlotDiff, "]");
|
|
67088
67171
|
|
|
67089
67172
|
if (!retry) {
|
|
67090
|
-
|
|
67173
|
+
_context62.next = 70;
|
|
67091
67174
|
break;
|
|
67092
67175
|
}
|
|
67093
67176
|
|
|
67094
67177
|
console.info("".concat(_errorMessage, ". Retrying request at attempt #").concat(attemptedRetries, "..."));
|
|
67095
|
-
|
|
67178
|
+
_context62.next = 69;
|
|
67096
67179
|
return this._makeRequestInternalLegacy(requestObj, retry, attemptedRetries + 1, throwError);
|
|
67097
67180
|
|
|
67098
67181
|
case 69:
|
|
67099
|
-
return
|
|
67182
|
+
return _context62.abrupt("return", _context62.sent);
|
|
67100
67183
|
|
|
67101
67184
|
case 70:
|
|
67102
|
-
return
|
|
67185
|
+
return _context62.abrupt("return", returnOrThrow(new Error(_errorMessage)));
|
|
67103
67186
|
|
|
67104
67187
|
case 71:
|
|
67105
67188
|
// Reset 404 counts
|
|
67106
67189
|
this.request404Count = 0; // Everything looks good, return the data!
|
|
67107
67190
|
|
|
67108
|
-
return
|
|
67191
|
+
return _context62.abrupt("return", parsedResponse);
|
|
67109
67192
|
|
|
67110
67193
|
case 73:
|
|
67111
67194
|
case "end":
|
|
67112
|
-
return
|
|
67195
|
+
return _context62.stop();
|
|
67113
67196
|
}
|
|
67114
67197
|
}
|
|
67115
|
-
},
|
|
67198
|
+
}, _callee62, this, [[5, 12], [16, 22]]);
|
|
67116
67199
|
}));
|
|
67117
67200
|
|
|
67118
|
-
function _makeRequestInternalLegacy(
|
|
67201
|
+
function _makeRequestInternalLegacy(_x82) {
|
|
67119
67202
|
return _makeRequestInternalLegacy2.apply(this, arguments);
|
|
67120
67203
|
}
|
|
67121
67204
|
|
|
@@ -67124,7 +67207,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67124
67207
|
}, {
|
|
67125
67208
|
key: "_makeRequestInternalNext",
|
|
67126
67209
|
value: function () {
|
|
67127
|
-
var _makeRequestInternalNext2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
67210
|
+
var _makeRequestInternalNext2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee63(requestObj) {
|
|
67128
67211
|
var _yield$this$discovery, _this$discoveryNodeMi, _this$discoveryNodeMi2, _yield$this$discovery3, _this$discoveryNodeMi5, _this$discoveryNodeMi6;
|
|
67129
67212
|
|
|
67130
67213
|
var throwError,
|
|
@@ -67141,21 +67224,21 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67141
67224
|
_this$discoveryNodeMi3,
|
|
67142
67225
|
_this$discoveryNodeMi4,
|
|
67143
67226
|
responseBody,
|
|
67144
|
-
|
|
67227
|
+
_args63 = arguments;
|
|
67145
67228
|
|
|
67146
|
-
return regeneratorRuntime.wrap(function
|
|
67229
|
+
return regeneratorRuntime.wrap(function _callee63$(_context63) {
|
|
67147
67230
|
while (1) {
|
|
67148
|
-
switch (
|
|
67231
|
+
switch (_context63.prev = _context63.next) {
|
|
67149
67232
|
case 0:
|
|
67150
|
-
throwError =
|
|
67151
|
-
blockNumber =
|
|
67233
|
+
throwError = _args63.length > 1 && _args63[1] !== undefined ? _args63[1] : false;
|
|
67234
|
+
blockNumber = _args63.length > 2 ? _args63[2] : undefined;
|
|
67152
67235
|
|
|
67153
67236
|
if (!(!this.discoveryProviderEndpoint || !this.discoveryNodeMiddleware)) {
|
|
67154
|
-
|
|
67237
|
+
_context63.next = 4;
|
|
67155
67238
|
break;
|
|
67156
67239
|
}
|
|
67157
67240
|
|
|
67158
|
-
return
|
|
67241
|
+
return _context63.abrupt("return");
|
|
67159
67242
|
|
|
67160
67243
|
case 4:
|
|
67161
67244
|
axiosRequest = this._createDiscProvRequest(requestObj, this.discoveryProviderEndpoint);
|
|
@@ -67167,109 +67250,109 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67167
67250
|
url: url,
|
|
67168
67251
|
init: fetchRequestInit
|
|
67169
67252
|
};
|
|
67170
|
-
|
|
67253
|
+
_context63.next = 10;
|
|
67171
67254
|
return (_this$discoveryNodeMi = (_this$discoveryNodeMi2 = this.discoveryNodeMiddleware).pre) === null || _this$discoveryNodeMi === void 0 ? void 0 : _this$discoveryNodeMi.call(_this$discoveryNodeMi2, _objectSpread2({
|
|
67172
67255
|
fetch: fetch$1
|
|
67173
67256
|
}, fetchParams));
|
|
67174
67257
|
|
|
67175
67258
|
case 10:
|
|
67176
|
-
|
|
67177
|
-
|
|
67259
|
+
_context63.t1 = _yield$this$discovery = _context63.sent;
|
|
67260
|
+
_context63.t0 = _context63.t1 !== null;
|
|
67178
67261
|
|
|
67179
|
-
if (!
|
|
67180
|
-
|
|
67262
|
+
if (!_context63.t0) {
|
|
67263
|
+
_context63.next = 14;
|
|
67181
67264
|
break;
|
|
67182
67265
|
}
|
|
67183
67266
|
|
|
67184
|
-
|
|
67267
|
+
_context63.t0 = _yield$this$discovery !== void 0;
|
|
67185
67268
|
|
|
67186
67269
|
case 14:
|
|
67187
|
-
if (!
|
|
67188
|
-
|
|
67270
|
+
if (!_context63.t0) {
|
|
67271
|
+
_context63.next = 18;
|
|
67189
67272
|
break;
|
|
67190
67273
|
}
|
|
67191
67274
|
|
|
67192
|
-
|
|
67193
|
-
|
|
67275
|
+
_context63.t2 = _yield$this$discovery;
|
|
67276
|
+
_context63.next = 19;
|
|
67194
67277
|
break;
|
|
67195
67278
|
|
|
67196
67279
|
case 18:
|
|
67197
|
-
|
|
67280
|
+
_context63.t2 = fetchParams;
|
|
67198
67281
|
|
|
67199
67282
|
case 19:
|
|
67200
|
-
fetchParams =
|
|
67201
|
-
|
|
67202
|
-
|
|
67283
|
+
fetchParams = _context63.t2;
|
|
67284
|
+
_context63.prev = 20;
|
|
67285
|
+
_context63.next = 23;
|
|
67203
67286
|
return fetch$1(fetchParams.url, fetchParams.init);
|
|
67204
67287
|
|
|
67205
67288
|
case 23:
|
|
67206
|
-
response =
|
|
67207
|
-
|
|
67289
|
+
response = _context63.sent;
|
|
67290
|
+
_context63.next = 48;
|
|
67208
67291
|
break;
|
|
67209
67292
|
|
|
67210
67293
|
case 26:
|
|
67211
|
-
|
|
67212
|
-
|
|
67213
|
-
|
|
67294
|
+
_context63.prev = 26;
|
|
67295
|
+
_context63.t3 = _context63["catch"](20);
|
|
67296
|
+
_context63.next = 30;
|
|
67214
67297
|
return (_this$discoveryNodeMi3 = (_this$discoveryNodeMi4 = this.discoveryNodeMiddleware).onError) === null || _this$discoveryNodeMi3 === void 0 ? void 0 : _this$discoveryNodeMi3.call(_this$discoveryNodeMi4, _objectSpread2(_objectSpread2({
|
|
67215
67298
|
fetch: fetch$1
|
|
67216
67299
|
}, fetchParams), {}, {
|
|
67217
|
-
error:
|
|
67300
|
+
error: _context63.t3,
|
|
67218
67301
|
response: response ? response.clone() : undefined
|
|
67219
67302
|
}));
|
|
67220
67303
|
|
|
67221
67304
|
case 30:
|
|
67222
|
-
|
|
67223
|
-
|
|
67305
|
+
_context63.t5 = _yield$this$discovery2 = _context63.sent;
|
|
67306
|
+
_context63.t4 = _context63.t5 !== null;
|
|
67224
67307
|
|
|
67225
|
-
if (!
|
|
67226
|
-
|
|
67308
|
+
if (!_context63.t4) {
|
|
67309
|
+
_context63.next = 34;
|
|
67227
67310
|
break;
|
|
67228
67311
|
}
|
|
67229
67312
|
|
|
67230
|
-
|
|
67313
|
+
_context63.t4 = _yield$this$discovery2 !== void 0;
|
|
67231
67314
|
|
|
67232
67315
|
case 34:
|
|
67233
|
-
if (!
|
|
67234
|
-
|
|
67316
|
+
if (!_context63.t4) {
|
|
67317
|
+
_context63.next = 38;
|
|
67235
67318
|
break;
|
|
67236
67319
|
}
|
|
67237
67320
|
|
|
67238
|
-
|
|
67239
|
-
|
|
67321
|
+
_context63.t6 = _yield$this$discovery2;
|
|
67322
|
+
_context63.next = 39;
|
|
67240
67323
|
break;
|
|
67241
67324
|
|
|
67242
67325
|
case 38:
|
|
67243
|
-
|
|
67326
|
+
_context63.t6 = response;
|
|
67244
67327
|
|
|
67245
67328
|
case 39:
|
|
67246
|
-
response =
|
|
67329
|
+
response = _context63.t6;
|
|
67247
67330
|
|
|
67248
67331
|
if (!(response === undefined)) {
|
|
67249
|
-
|
|
67332
|
+
_context63.next = 48;
|
|
67250
67333
|
break;
|
|
67251
67334
|
}
|
|
67252
67335
|
|
|
67253
67336
|
if (!throwError) {
|
|
67254
|
-
|
|
67337
|
+
_context63.next = 47;
|
|
67255
67338
|
break;
|
|
67256
67339
|
}
|
|
67257
67340
|
|
|
67258
|
-
if (!(
|
|
67259
|
-
|
|
67341
|
+
if (!(_context63.t3 instanceof Error)) {
|
|
67342
|
+
_context63.next = 46;
|
|
67260
67343
|
break;
|
|
67261
67344
|
}
|
|
67262
67345
|
|
|
67263
|
-
throw new FetchError$1(
|
|
67346
|
+
throw new FetchError$1(_context63.t3, 'The request failed and the interceptors did not return an alternative response');
|
|
67264
67347
|
|
|
67265
67348
|
case 46:
|
|
67266
|
-
throw
|
|
67349
|
+
throw _context63.t3;
|
|
67267
67350
|
|
|
67268
67351
|
case 47:
|
|
67269
|
-
return
|
|
67352
|
+
return _context63.abrupt("return", null);
|
|
67270
67353
|
|
|
67271
67354
|
case 48:
|
|
67272
|
-
|
|
67355
|
+
_context63.next = 50;
|
|
67273
67356
|
return (_this$discoveryNodeMi5 = (_this$discoveryNodeMi6 = this.discoveryNodeMiddleware).post) === null || _this$discoveryNodeMi5 === void 0 ? void 0 : _this$discoveryNodeMi5.call(_this$discoveryNodeMi6, _objectSpread2(_objectSpread2({
|
|
67274
67357
|
fetch: fetch$1
|
|
67275
67358
|
}, fetchParams), {}, {
|
|
@@ -67277,56 +67360,56 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67277
67360
|
}));
|
|
67278
67361
|
|
|
67279
67362
|
case 50:
|
|
67280
|
-
|
|
67281
|
-
|
|
67363
|
+
_context63.t8 = _yield$this$discovery3 = _context63.sent;
|
|
67364
|
+
_context63.t7 = _context63.t8 !== null;
|
|
67282
67365
|
|
|
67283
|
-
if (!
|
|
67284
|
-
|
|
67366
|
+
if (!_context63.t7) {
|
|
67367
|
+
_context63.next = 54;
|
|
67285
67368
|
break;
|
|
67286
67369
|
}
|
|
67287
67370
|
|
|
67288
|
-
|
|
67371
|
+
_context63.t7 = _yield$this$discovery3 !== void 0;
|
|
67289
67372
|
|
|
67290
67373
|
case 54:
|
|
67291
|
-
if (!
|
|
67292
|
-
|
|
67374
|
+
if (!_context63.t7) {
|
|
67375
|
+
_context63.next = 58;
|
|
67293
67376
|
break;
|
|
67294
67377
|
}
|
|
67295
67378
|
|
|
67296
|
-
|
|
67297
|
-
|
|
67379
|
+
_context63.t9 = _yield$this$discovery3;
|
|
67380
|
+
_context63.next = 59;
|
|
67298
67381
|
break;
|
|
67299
67382
|
|
|
67300
67383
|
case 58:
|
|
67301
|
-
|
|
67384
|
+
_context63.t9 = response;
|
|
67302
67385
|
|
|
67303
67386
|
case 59:
|
|
67304
|
-
response =
|
|
67305
|
-
|
|
67387
|
+
response = _context63.t9;
|
|
67388
|
+
_context63.next = 62;
|
|
67306
67389
|
return response.json();
|
|
67307
67390
|
|
|
67308
67391
|
case 62:
|
|
67309
|
-
responseBody =
|
|
67392
|
+
responseBody = _context63.sent;
|
|
67310
67393
|
|
|
67311
67394
|
if (!(blockNumber && responseBody.latest_indexed_block < blockNumber)) {
|
|
67312
|
-
|
|
67395
|
+
_context63.next = 65;
|
|
67313
67396
|
break;
|
|
67314
67397
|
}
|
|
67315
67398
|
|
|
67316
67399
|
throw new Error("Requested blocknumber ".concat(blockNumber, ", but discovery is behind at ").concat(responseBody.latest_indexed_block));
|
|
67317
67400
|
|
|
67318
67401
|
case 65:
|
|
67319
|
-
return
|
|
67402
|
+
return _context63.abrupt("return", responseBody);
|
|
67320
67403
|
|
|
67321
67404
|
case 66:
|
|
67322
67405
|
case "end":
|
|
67323
|
-
return
|
|
67406
|
+
return _context63.stop();
|
|
67324
67407
|
}
|
|
67325
67408
|
}
|
|
67326
|
-
},
|
|
67409
|
+
}, _callee63, this, [[20, 26]]);
|
|
67327
67410
|
}));
|
|
67328
67411
|
|
|
67329
|
-
function _makeRequestInternalNext(
|
|
67412
|
+
function _makeRequestInternalNext(_x83) {
|
|
67330
67413
|
return _makeRequestInternalNext2.apply(this, arguments);
|
|
67331
67414
|
}
|
|
67332
67415
|
|
|
@@ -67342,16 +67425,16 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67342
67425
|
}, {
|
|
67343
67426
|
key: "getHealthyDiscoveryProviderEndpoint",
|
|
67344
67427
|
value: function () {
|
|
67345
|
-
var _getHealthyDiscoveryProviderEndpoint = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
67428
|
+
var _getHealthyDiscoveryProviderEndpoint = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee64(attemptedRetries) {
|
|
67346
67429
|
var endpoint;
|
|
67347
|
-
return regeneratorRuntime.wrap(function
|
|
67430
|
+
return regeneratorRuntime.wrap(function _callee64$(_context64) {
|
|
67348
67431
|
while (1) {
|
|
67349
|
-
switch (
|
|
67432
|
+
switch (_context64.prev = _context64.next) {
|
|
67350
67433
|
case 0:
|
|
67351
67434
|
endpoint = this.discoveryProviderEndpoint;
|
|
67352
67435
|
|
|
67353
67436
|
if (!(attemptedRetries > this.selectionRequestRetries || !endpoint)) {
|
|
67354
|
-
|
|
67437
|
+
_context64.next = 8;
|
|
67355
67438
|
break;
|
|
67356
67439
|
}
|
|
67357
67440
|
|
|
@@ -67360,32 +67443,32 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67360
67443
|
this.serviceSelector.addUnhealthy(endpoint); // Clear the cached endpoint and select new endpoint from backups
|
|
67361
67444
|
|
|
67362
67445
|
this.serviceSelector.clearCached();
|
|
67363
|
-
|
|
67446
|
+
_context64.next = 7;
|
|
67364
67447
|
return this.serviceSelector.select();
|
|
67365
67448
|
|
|
67366
67449
|
case 7:
|
|
67367
|
-
endpoint =
|
|
67450
|
+
endpoint = _context64.sent;
|
|
67368
67451
|
|
|
67369
67452
|
case 8:
|
|
67370
67453
|
if (endpoint) {
|
|
67371
|
-
|
|
67454
|
+
_context64.next = 10;
|
|
67372
67455
|
break;
|
|
67373
67456
|
}
|
|
67374
67457
|
|
|
67375
67458
|
throw new Error('All Discovery Providers are unhealthy and unavailable.');
|
|
67376
67459
|
|
|
67377
67460
|
case 10:
|
|
67378
|
-
return
|
|
67461
|
+
return _context64.abrupt("return", endpoint);
|
|
67379
67462
|
|
|
67380
67463
|
case 11:
|
|
67381
67464
|
case "end":
|
|
67382
|
-
return
|
|
67465
|
+
return _context64.stop();
|
|
67383
67466
|
}
|
|
67384
67467
|
}
|
|
67385
|
-
},
|
|
67468
|
+
}, _callee64, this);
|
|
67386
67469
|
}));
|
|
67387
67470
|
|
|
67388
|
-
function getHealthyDiscoveryProviderEndpoint(
|
|
67471
|
+
function getHealthyDiscoveryProviderEndpoint(_x84) {
|
|
67389
67472
|
return _getHealthyDiscoveryProviderEndpoint.apply(this, arguments);
|
|
67390
67473
|
}
|
|
67391
67474
|
|
|
@@ -74071,7 +74154,9 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74071
74154
|
_ref$preferHigherPatc2 = _ref.preferHigherPatchForSecondaries,
|
|
74072
74155
|
preferHigherPatchForSecondaries = _ref$preferHigherPatc2 === void 0 ? true : _ref$preferHigherPatc2,
|
|
74073
74156
|
_ref$localStorage = _ref.localStorage,
|
|
74074
|
-
localStorage = _ref$localStorage === void 0 ? getPlatformLocalStorage() : _ref$localStorage
|
|
74157
|
+
localStorage = _ref$localStorage === void 0 ? getPlatformLocalStorage() : _ref$localStorage,
|
|
74158
|
+
_ref$useDiscoveryRela = _ref.useDiscoveryRelay,
|
|
74159
|
+
useDiscoveryRelay = _ref$useDiscoveryRela === void 0 ? false : _ref$useDiscoveryRela;
|
|
74075
74160
|
|
|
74076
74161
|
_classCallCheck(this, AudiusLibs);
|
|
74077
74162
|
|
|
@@ -74157,6 +74242,8 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74157
74242
|
|
|
74158
74243
|
_defineProperty$1(this, "localStorage", void 0);
|
|
74159
74244
|
|
|
74245
|
+
_defineProperty$1(this, "useDiscoveryRelay", void 0);
|
|
74246
|
+
|
|
74160
74247
|
// set version
|
|
74161
74248
|
this.version = version_1;
|
|
74162
74249
|
this.ethWeb3Config = ethWeb3Config;
|
|
@@ -74199,7 +74286,8 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74199
74286
|
this.EntityManager = null;
|
|
74200
74287
|
this.preferHigherPatchForPrimary = preferHigherPatchForPrimary;
|
|
74201
74288
|
this.preferHigherPatchForSecondaries = preferHigherPatchForSecondaries;
|
|
74202
|
-
this.localStorage = localStorage;
|
|
74289
|
+
this.localStorage = localStorage;
|
|
74290
|
+
this.useDiscoveryRelay = useDiscoveryRelay; // Schemas
|
|
74203
74291
|
|
|
74204
74292
|
var schemaValidator = new SchemaValidator();
|
|
74205
74293
|
schemaValidator.init();
|
|
@@ -74212,7 +74300,7 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74212
74300
|
key: "init",
|
|
74213
74301
|
value: function () {
|
|
74214
74302
|
var _init = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
74215
|
-
var hedgehogService, contractsToInit, _this$ethWeb3Config, _ref2, _ref2$tokenAddress, tokenAddress, _ref2$registryAddress, registryAddress, _ref2$claimDistributi, claimDistributionContractAddress, _ref2$wormholeContrac, wormholeContractAddress, currentUser, creatorNodeEndpoint, _this$creatorNodeConf, _this$creatorNodeConf2, storageNode, storageV2Nodes, randomNodes, services;
|
|
74303
|
+
var hedgehogService, contractsToInit, _this$ethWeb3Config, _ref2, _ref2$tokenAddress, tokenAddress, _ref2$registryAddress, registryAddress, _ref2$claimDistributi, claimDistributionContractAddress, _ref2$wormholeContrac, wormholeContractAddress, web3Manager, _this$web3Manager, currentUser, creatorNodeEndpoint, _this$creatorNodeConf, _this$creatorNodeConf2, storageNode, storageV2Nodes, randomNodes, services;
|
|
74216
74304
|
|
|
74217
74305
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
74218
74306
|
while (1) {
|
|
@@ -74331,7 +74419,7 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74331
74419
|
|
|
74332
74420
|
|
|
74333
74421
|
if (!this.discoveryProviderConfig) {
|
|
74334
|
-
_context.next =
|
|
74422
|
+
_context.next = 35;
|
|
74335
74423
|
break;
|
|
74336
74424
|
}
|
|
74337
74425
|
|
|
@@ -74345,8 +74433,20 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74345
74433
|
return this.discoveryProvider.init();
|
|
74346
74434
|
|
|
74347
74435
|
case 34:
|
|
74436
|
+
// set discovery provider in web3 for relay
|
|
74437
|
+
if (this.web3Config && this.useDiscoveryRelay) {
|
|
74438
|
+
web3Manager = this.web3Manager;
|
|
74439
|
+
|
|
74440
|
+
if (web3Manager === undefined || web3Manager === null) {
|
|
74441
|
+
console.warn("useDiscoveryRelay is set to true but web3Manager is not configured");
|
|
74442
|
+
} else {
|
|
74443
|
+
(_this$web3Manager = this.web3Manager) === null || _this$web3Manager === void 0 ? void 0 : _this$web3Manager.setDiscoveryProvider(this.discoveryProvider);
|
|
74444
|
+
}
|
|
74445
|
+
}
|
|
74446
|
+
|
|
74447
|
+
case 35:
|
|
74348
74448
|
if (!this.creatorNodeConfig) {
|
|
74349
|
-
_context.next =
|
|
74449
|
+
_context.next = 55;
|
|
74350
74450
|
break;
|
|
74351
74451
|
}
|
|
74352
74452
|
|
|
@@ -74355,12 +74455,12 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74355
74455
|
creatorNodeEndpoint = this.creatorNodeConfig.fallbackUrl;
|
|
74356
74456
|
|
|
74357
74457
|
if (!(currentUser !== null && currentUser !== void 0 && currentUser.wallet)) {
|
|
74358
|
-
_context.next =
|
|
74458
|
+
_context.next = 52;
|
|
74359
74459
|
break;
|
|
74360
74460
|
}
|
|
74361
74461
|
|
|
74362
74462
|
if (!this.creatorNodeConfig.storageNodeSelector) {
|
|
74363
|
-
_context.next =
|
|
74463
|
+
_context.next = 44;
|
|
74364
74464
|
break;
|
|
74365
74465
|
}
|
|
74366
74466
|
|
|
@@ -74370,33 +74470,33 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74370
74470
|
creatorNodeEndpoint = storageNode;
|
|
74371
74471
|
}
|
|
74372
74472
|
|
|
74373
|
-
_context.next =
|
|
74473
|
+
_context.next = 52;
|
|
74374
74474
|
break;
|
|
74375
74475
|
|
|
74376
|
-
case
|
|
74476
|
+
case 44:
|
|
74377
74477
|
if (!this.ethContracts) {
|
|
74378
|
-
_context.next =
|
|
74478
|
+
_context.next = 52;
|
|
74379
74479
|
break;
|
|
74380
74480
|
}
|
|
74381
74481
|
|
|
74382
|
-
_context.next =
|
|
74482
|
+
_context.next = 47;
|
|
74383
74483
|
return this.ethContracts.ServiceProviderFactoryClient.getServiceProviderList('content-node');
|
|
74384
74484
|
|
|
74385
|
-
case
|
|
74485
|
+
case 47:
|
|
74386
74486
|
storageV2Nodes = _context.sent;
|
|
74387
|
-
_context.next =
|
|
74487
|
+
_context.next = 50;
|
|
74388
74488
|
return getNStorageNodes(storageV2Nodes, 1, currentUser.wallet, this.logger);
|
|
74389
74489
|
|
|
74390
|
-
case
|
|
74490
|
+
case 50:
|
|
74391
74491
|
randomNodes = _context.sent;
|
|
74392
74492
|
creatorNodeEndpoint = randomNodes[0];
|
|
74393
74493
|
|
|
74394
|
-
case
|
|
74494
|
+
case 52:
|
|
74395
74495
|
this.creatorNode = new CreatorNode(this.web3Manager, creatorNodeEndpoint, this.isServer, this.userStateManager, this.schemas, this.creatorNodeConfig.passList, this.creatorNodeConfig.blockList, this.creatorNodeConfig.monitoringCallbacks, this.creatorNodeConfig.storageNodeSelector);
|
|
74396
|
-
_context.next =
|
|
74496
|
+
_context.next = 55;
|
|
74397
74497
|
return this.creatorNode.init();
|
|
74398
74498
|
|
|
74399
|
-
case
|
|
74499
|
+
case 55:
|
|
74400
74500
|
/** Comstock */
|
|
74401
74501
|
if (this.comstockConfig) {
|
|
74402
74502
|
this.comstock = new Comstock(this.comstockConfig.url);
|
|
@@ -74415,7 +74515,7 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74415
74515
|
this.Notifications = _construct(Notifications, services);
|
|
74416
74516
|
this.EntityManager = _construct(EntityManager, services);
|
|
74417
74517
|
|
|
74418
|
-
case
|
|
74518
|
+
case 67:
|
|
74419
74519
|
case "end":
|
|
74420
74520
|
return _context.stop();
|
|
74421
74521
|
}
|