@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.cjs.js
CHANGED
|
@@ -36180,9 +36180,9 @@ var EthWeb3Manager = /*#__PURE__*/function () {
|
|
|
36180
36180
|
}();
|
|
36181
36181
|
|
|
36182
36182
|
var name = "@audius/sdk";
|
|
36183
|
-
var version = "3.0.8-beta.
|
|
36183
|
+
var version = "3.0.8-beta.6";
|
|
36184
36184
|
var audius = {
|
|
36185
|
-
releaseSHA: "
|
|
36185
|
+
releaseSHA: "ea2ae182bca1fca4f27f02f9fa991789e42fe6cf"
|
|
36186
36186
|
};
|
|
36187
36187
|
var description = "Audius SDK";
|
|
36188
36188
|
var keywords = [
|
|
@@ -37023,10 +37023,13 @@ var Web3Manager = /*#__PURE__*/function () {
|
|
|
37023
37023
|
|
|
37024
37024
|
_defineProperty$1(this, "userSuppliedHandle", void 0);
|
|
37025
37025
|
|
|
37026
|
+
_defineProperty$1(this, "discoveryProvider", void 0);
|
|
37027
|
+
|
|
37026
37028
|
this.web3Config = web3Config;
|
|
37027
37029
|
this.isServer = isServer; // Unset if externalWeb3 = true
|
|
37028
37030
|
|
|
37029
37031
|
this.identityService = identityService;
|
|
37032
|
+
this.discoveryProvider = null;
|
|
37030
37033
|
this.hedgehog = hedgehog;
|
|
37031
37034
|
this.AudiusABIDecoder = AudiusABIDecoder;
|
|
37032
37035
|
}
|
|
@@ -37137,6 +37140,16 @@ var Web3Manager = /*#__PURE__*/function () {
|
|
|
37137
37140
|
value: function setWeb3(web3) {
|
|
37138
37141
|
this.web3 = web3;
|
|
37139
37142
|
}
|
|
37143
|
+
}, {
|
|
37144
|
+
key: "setDiscoveryProvider",
|
|
37145
|
+
value: function setDiscoveryProvider(discoveryProvider) {
|
|
37146
|
+
this.discoveryProvider = discoveryProvider;
|
|
37147
|
+
}
|
|
37148
|
+
}, {
|
|
37149
|
+
key: "useDiscoveryRelay",
|
|
37150
|
+
value: function useDiscoveryRelay() {
|
|
37151
|
+
return !(this.discoveryProvider === null);
|
|
37152
|
+
}
|
|
37140
37153
|
}, {
|
|
37141
37154
|
key: "getWalletAddress",
|
|
37142
37155
|
value: function getWalletAddress() {
|
|
@@ -37388,40 +37401,76 @@ var Web3Manager = /*#__PURE__*/function () {
|
|
|
37388
37401
|
_context6.next = 22;
|
|
37389
37402
|
return retry__default["default"]( /*#__PURE__*/function () {
|
|
37390
37403
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(bail) {
|
|
37391
|
-
var _this$identityService;
|
|
37404
|
+
var _this$discoveryProvid, res, _this$identityService;
|
|
37392
37405
|
|
|
37393
37406
|
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
37394
37407
|
while (1) {
|
|
37395
37408
|
switch (_context5.prev = _context5.next) {
|
|
37396
37409
|
case 0:
|
|
37397
37410
|
_context5.prev = 0;
|
|
37398
|
-
|
|
37411
|
+
|
|
37412
|
+
if (!_this.useDiscoveryRelay()) {
|
|
37413
|
+
_context5.next = 10;
|
|
37414
|
+
break;
|
|
37415
|
+
}
|
|
37416
|
+
|
|
37417
|
+
_context5.next = 4;
|
|
37418
|
+
return (_this$discoveryProvid = _this.discoveryProvider) === null || _this$discoveryProvid === void 0 ? void 0 : _this$discoveryProvid.relay({
|
|
37419
|
+
contractRegistryKey: contractRegistryKey,
|
|
37420
|
+
contractAddress: contractAddress,
|
|
37421
|
+
senderAddress: _this.ownerWallet.getAddressString(),
|
|
37422
|
+
encodedABI: encodedABI,
|
|
37423
|
+
gasLimit: gasLimit,
|
|
37424
|
+
handle: _this.userSuppliedHandle,
|
|
37425
|
+
nethermindContractAddress: nethermindContractAddress,
|
|
37426
|
+
nethermindEncodedAbi: nethermindEncodedAbi
|
|
37427
|
+
});
|
|
37428
|
+
|
|
37429
|
+
case 4:
|
|
37430
|
+
res = _context5.sent;
|
|
37431
|
+
|
|
37432
|
+
if (!(res === null || res === undefined)) {
|
|
37433
|
+
_context5.next = 7;
|
|
37434
|
+
break;
|
|
37435
|
+
}
|
|
37436
|
+
|
|
37437
|
+
throw new Error("discovery relay returned empty response");
|
|
37438
|
+
|
|
37439
|
+
case 7:
|
|
37440
|
+
return _context5.abrupt("return", res);
|
|
37441
|
+
|
|
37442
|
+
case 10:
|
|
37443
|
+
_context5.next = 12;
|
|
37399
37444
|
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);
|
|
37400
37445
|
|
|
37401
|
-
case
|
|
37446
|
+
case 12:
|
|
37402
37447
|
return _context5.abrupt("return", _context5.sent);
|
|
37403
37448
|
|
|
37404
|
-
case
|
|
37405
|
-
_context5.
|
|
37449
|
+
case 13:
|
|
37450
|
+
_context5.next = 21;
|
|
37451
|
+
break;
|
|
37452
|
+
|
|
37453
|
+
case 15:
|
|
37454
|
+
_context5.prev = 15;
|
|
37406
37455
|
_context5.t0 = _context5["catch"](0);
|
|
37407
37456
|
|
|
37408
37457
|
if (!(_context5.t0.response.status === 403)) {
|
|
37409
|
-
_context5.next =
|
|
37458
|
+
_context5.next = 20;
|
|
37410
37459
|
break;
|
|
37411
37460
|
}
|
|
37412
37461
|
|
|
37413
37462
|
bail(_context5.t0);
|
|
37414
37463
|
return _context5.abrupt("return");
|
|
37415
37464
|
|
|
37416
|
-
case
|
|
37465
|
+
case 20:
|
|
37417
37466
|
throw _context5.t0;
|
|
37418
37467
|
|
|
37419
|
-
case
|
|
37468
|
+
case 21:
|
|
37420
37469
|
case "end":
|
|
37421
37470
|
return _context5.stop();
|
|
37422
37471
|
}
|
|
37423
37472
|
}
|
|
37424
|
-
}, _callee5, null, [[0,
|
|
37473
|
+
}, _callee5, null, [[0, 15]]);
|
|
37425
37474
|
}));
|
|
37426
37475
|
|
|
37427
37476
|
return function (_x8) {
|
|
@@ -66750,6 +66799,40 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66750
66799
|
|
|
66751
66800
|
return getUserReplicaSet$1;
|
|
66752
66801
|
}()
|
|
66802
|
+
}, {
|
|
66803
|
+
key: "relay",
|
|
66804
|
+
value: function () {
|
|
66805
|
+
var _relay = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee55(data) {
|
|
66806
|
+
var req;
|
|
66807
|
+
return regeneratorRuntime.wrap(function _callee55$(_context55) {
|
|
66808
|
+
while (1) {
|
|
66809
|
+
switch (_context55.prev = _context55.next) {
|
|
66810
|
+
case 0:
|
|
66811
|
+
req = {
|
|
66812
|
+
endpoint: 'relay',
|
|
66813
|
+
method: 'post',
|
|
66814
|
+
data: data
|
|
66815
|
+
};
|
|
66816
|
+
_context55.next = 3;
|
|
66817
|
+
return this._makeRequest(req, true, 0, true);
|
|
66818
|
+
|
|
66819
|
+
case 3:
|
|
66820
|
+
return _context55.abrupt("return", _context55.sent);
|
|
66821
|
+
|
|
66822
|
+
case 4:
|
|
66823
|
+
case "end":
|
|
66824
|
+
return _context55.stop();
|
|
66825
|
+
}
|
|
66826
|
+
}
|
|
66827
|
+
}, _callee55, this);
|
|
66828
|
+
}));
|
|
66829
|
+
|
|
66830
|
+
function relay(_x74) {
|
|
66831
|
+
return _relay.apply(this, arguments);
|
|
66832
|
+
}
|
|
66833
|
+
|
|
66834
|
+
return relay;
|
|
66835
|
+
}()
|
|
66753
66836
|
/**
|
|
66754
66837
|
* Retrieves an unclaimed ID
|
|
66755
66838
|
* @return encoded ID
|
|
@@ -66758,28 +66841,28 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66758
66841
|
}, {
|
|
66759
66842
|
key: "getUnclaimedId",
|
|
66760
66843
|
value: function () {
|
|
66761
|
-
var _getUnclaimedId = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66844
|
+
var _getUnclaimedId = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee56(type) {
|
|
66762
66845
|
var req;
|
|
66763
|
-
return regeneratorRuntime.wrap(function
|
|
66846
|
+
return regeneratorRuntime.wrap(function _callee56$(_context56) {
|
|
66764
66847
|
while (1) {
|
|
66765
|
-
switch (
|
|
66848
|
+
switch (_context56.prev = _context56.next) {
|
|
66766
66849
|
case 0:
|
|
66767
66850
|
req = getUnclaimedId(type);
|
|
66768
|
-
|
|
66851
|
+
_context56.next = 3;
|
|
66769
66852
|
return this._makeRequest(req);
|
|
66770
66853
|
|
|
66771
66854
|
case 3:
|
|
66772
|
-
return
|
|
66855
|
+
return _context56.abrupt("return", _context56.sent);
|
|
66773
66856
|
|
|
66774
66857
|
case 4:
|
|
66775
66858
|
case "end":
|
|
66776
|
-
return
|
|
66859
|
+
return _context56.stop();
|
|
66777
66860
|
}
|
|
66778
66861
|
}
|
|
66779
|
-
},
|
|
66862
|
+
}, _callee56, this);
|
|
66780
66863
|
}));
|
|
66781
66864
|
|
|
66782
|
-
function getUnclaimedId$1(
|
|
66865
|
+
function getUnclaimedId$1(_x75) {
|
|
66783
66866
|
return _getUnclaimedId.apply(this, arguments);
|
|
66784
66867
|
}
|
|
66785
66868
|
|
|
@@ -66796,24 +66879,24 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66796
66879
|
}, {
|
|
66797
66880
|
key: "_performRequestWithMonitoring",
|
|
66798
66881
|
value: function () {
|
|
66799
|
-
var _performRequestWithMonitoring2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66882
|
+
var _performRequestWithMonitoring2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee57(requestObj, discoveryProviderEndpoint) {
|
|
66800
66883
|
var _axiosRequest$url;
|
|
66801
66884
|
|
|
66802
66885
|
var axiosRequest, response, parsedResponse, url, start, duration, _this$monitoringCallb, _this$monitoringCallb2, _error$response$data, _error$response, error, resp, _duration, errData, _this$monitoringCallb3, _this$monitoringCallb4;
|
|
66803
66886
|
|
|
66804
|
-
return regeneratorRuntime.wrap(function
|
|
66887
|
+
return regeneratorRuntime.wrap(function _callee57$(_context57) {
|
|
66805
66888
|
while (1) {
|
|
66806
|
-
switch (
|
|
66889
|
+
switch (_context57.prev = _context57.next) {
|
|
66807
66890
|
case 0:
|
|
66808
66891
|
axiosRequest = this._createDiscProvRequest(requestObj, discoveryProviderEndpoint);
|
|
66809
66892
|
url = new URL((_axiosRequest$url = axiosRequest.url) !== null && _axiosRequest$url !== void 0 ? _axiosRequest$url : '');
|
|
66810
66893
|
start = Date.now();
|
|
66811
|
-
|
|
66812
|
-
|
|
66894
|
+
_context57.prev = 3;
|
|
66895
|
+
_context57.next = 6;
|
|
66813
66896
|
return axios__default["default"](axiosRequest);
|
|
66814
66897
|
|
|
66815
66898
|
case 6:
|
|
66816
|
-
response =
|
|
66899
|
+
response = _context57.sent;
|
|
66817
66900
|
duration = Date.now() - start;
|
|
66818
66901
|
parsedResponse = Utils.parseDataFromResponse(response); // Fire monitoring callbacks for request success case
|
|
66819
66902
|
|
|
@@ -66835,13 +66918,13 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66835
66918
|
}
|
|
66836
66919
|
}
|
|
66837
66920
|
|
|
66838
|
-
|
|
66921
|
+
_context57.next = 22;
|
|
66839
66922
|
break;
|
|
66840
66923
|
|
|
66841
66924
|
case 12:
|
|
66842
|
-
|
|
66843
|
-
|
|
66844
|
-
error =
|
|
66925
|
+
_context57.prev = 12;
|
|
66926
|
+
_context57.t0 = _context57["catch"](3);
|
|
66927
|
+
error = _context57.t0;
|
|
66845
66928
|
resp = error.response;
|
|
66846
66929
|
_duration = Date.now() - start;
|
|
66847
66930
|
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
|
|
@@ -66863,7 +66946,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66863
66946
|
}
|
|
66864
66947
|
|
|
66865
66948
|
if (!(resp && resp.status === 404)) {
|
|
66866
|
-
|
|
66949
|
+
_context57.next = 21;
|
|
66867
66950
|
break;
|
|
66868
66951
|
}
|
|
66869
66952
|
|
|
@@ -66875,17 +66958,17 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66875
66958
|
throw errData;
|
|
66876
66959
|
|
|
66877
66960
|
case 22:
|
|
66878
|
-
return
|
|
66961
|
+
return _context57.abrupt("return", parsedResponse);
|
|
66879
66962
|
|
|
66880
66963
|
case 23:
|
|
66881
66964
|
case "end":
|
|
66882
|
-
return
|
|
66965
|
+
return _context57.stop();
|
|
66883
66966
|
}
|
|
66884
66967
|
}
|
|
66885
|
-
},
|
|
66968
|
+
}, _callee57, this, [[3, 12]]);
|
|
66886
66969
|
}));
|
|
66887
66970
|
|
|
66888
|
-
function _performRequestWithMonitoring(
|
|
66971
|
+
function _performRequestWithMonitoring(_x76, _x77) {
|
|
66889
66972
|
return _performRequestWithMonitoring2.apply(this, arguments);
|
|
66890
66973
|
}
|
|
66891
66974
|
|
|
@@ -66902,41 +66985,41 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66902
66985
|
}, {
|
|
66903
66986
|
key: "_getBlocksBehind",
|
|
66904
66987
|
value: function () {
|
|
66905
|
-
var _getBlocksBehind2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
66988
|
+
var _getBlocksBehind2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee58(parsedResponse) {
|
|
66906
66989
|
var indexedBlock, chainBlock, blockDiff;
|
|
66907
|
-
return regeneratorRuntime.wrap(function
|
|
66990
|
+
return regeneratorRuntime.wrap(function _callee58$(_context58) {
|
|
66908
66991
|
while (1) {
|
|
66909
|
-
switch (
|
|
66992
|
+
switch (_context58.prev = _context58.next) {
|
|
66910
66993
|
case 0:
|
|
66911
|
-
|
|
66994
|
+
_context58.prev = 0;
|
|
66912
66995
|
indexedBlock = parsedResponse.latest_indexed_block, chainBlock = parsedResponse.latest_chain_block;
|
|
66913
66996
|
blockDiff = chainBlock - indexedBlock;
|
|
66914
66997
|
|
|
66915
66998
|
if (!(blockDiff > this.unhealthyBlockDiff)) {
|
|
66916
|
-
|
|
66999
|
+
_context58.next = 5;
|
|
66917
67000
|
break;
|
|
66918
67001
|
}
|
|
66919
67002
|
|
|
66920
|
-
return
|
|
67003
|
+
return _context58.abrupt("return", blockDiff);
|
|
66921
67004
|
|
|
66922
67005
|
case 5:
|
|
66923
|
-
return
|
|
67006
|
+
return _context58.abrupt("return", null);
|
|
66924
67007
|
|
|
66925
67008
|
case 8:
|
|
66926
|
-
|
|
66927
|
-
|
|
66928
|
-
console.error(
|
|
66929
|
-
return
|
|
67009
|
+
_context58.prev = 8;
|
|
67010
|
+
_context58.t0 = _context58["catch"](0);
|
|
67011
|
+
console.error(_context58.t0);
|
|
67012
|
+
return _context58.abrupt("return", this.unhealthyBlockDiff);
|
|
66930
67013
|
|
|
66931
67014
|
case 12:
|
|
66932
67015
|
case "end":
|
|
66933
|
-
return
|
|
67016
|
+
return _context58.stop();
|
|
66934
67017
|
}
|
|
66935
67018
|
}
|
|
66936
|
-
},
|
|
67019
|
+
}, _callee58, this, [[0, 8]]);
|
|
66937
67020
|
}));
|
|
66938
67021
|
|
|
66939
|
-
function _getBlocksBehind(
|
|
67022
|
+
function _getBlocksBehind(_x78) {
|
|
66940
67023
|
return _getBlocksBehind2.apply(this, arguments);
|
|
66941
67024
|
}
|
|
66942
67025
|
|
|
@@ -66953,49 +67036,49 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
66953
67036
|
}, {
|
|
66954
67037
|
key: "_getPlaysSlotsBehind",
|
|
66955
67038
|
value: function () {
|
|
66956
|
-
var _getPlaysSlotsBehind2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
67039
|
+
var _getPlaysSlotsBehind2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee59(parsedResponse) {
|
|
66957
67040
|
var indexedSlotPlays, chainSlotPlays, slotDiff;
|
|
66958
|
-
return regeneratorRuntime.wrap(function
|
|
67041
|
+
return regeneratorRuntime.wrap(function _callee59$(_context59) {
|
|
66959
67042
|
while (1) {
|
|
66960
|
-
switch (
|
|
67043
|
+
switch (_context59.prev = _context59.next) {
|
|
66961
67044
|
case 0:
|
|
66962
67045
|
if (this.unhealthySlotDiffPlays) {
|
|
66963
|
-
|
|
67046
|
+
_context59.next = 2;
|
|
66964
67047
|
break;
|
|
66965
67048
|
}
|
|
66966
67049
|
|
|
66967
|
-
return
|
|
67050
|
+
return _context59.abrupt("return", null);
|
|
66968
67051
|
|
|
66969
67052
|
case 2:
|
|
66970
|
-
|
|
67053
|
+
_context59.prev = 2;
|
|
66971
67054
|
indexedSlotPlays = parsedResponse.latest_indexed_slot_plays, chainSlotPlays = parsedResponse.latest_chain_slot_plays;
|
|
66972
67055
|
slotDiff = chainSlotPlays - indexedSlotPlays;
|
|
66973
67056
|
|
|
66974
67057
|
if (!(slotDiff > this.unhealthySlotDiffPlays)) {
|
|
66975
|
-
|
|
67058
|
+
_context59.next = 7;
|
|
66976
67059
|
break;
|
|
66977
67060
|
}
|
|
66978
67061
|
|
|
66979
|
-
return
|
|
67062
|
+
return _context59.abrupt("return", slotDiff);
|
|
66980
67063
|
|
|
66981
67064
|
case 7:
|
|
66982
|
-
return
|
|
67065
|
+
return _context59.abrupt("return", null);
|
|
66983
67066
|
|
|
66984
67067
|
case 10:
|
|
66985
|
-
|
|
66986
|
-
|
|
66987
|
-
console.error(
|
|
66988
|
-
return
|
|
67068
|
+
_context59.prev = 10;
|
|
67069
|
+
_context59.t0 = _context59["catch"](2);
|
|
67070
|
+
console.error(_context59.t0);
|
|
67071
|
+
return _context59.abrupt("return", this.unhealthySlotDiffPlays);
|
|
66989
67072
|
|
|
66990
67073
|
case 14:
|
|
66991
67074
|
case "end":
|
|
66992
|
-
return
|
|
67075
|
+
return _context59.stop();
|
|
66993
67076
|
}
|
|
66994
67077
|
}
|
|
66995
|
-
},
|
|
67078
|
+
}, _callee59, this, [[2, 10]]);
|
|
66996
67079
|
}));
|
|
66997
67080
|
|
|
66998
|
-
function _getPlaysSlotsBehind(
|
|
67081
|
+
function _getPlaysSlotsBehind(_x79) {
|
|
66999
67082
|
return _getPlaysSlotsBehind2.apply(this, arguments);
|
|
67000
67083
|
}
|
|
67001
67084
|
|
|
@@ -67025,61 +67108,61 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67025
67108
|
}, {
|
|
67026
67109
|
key: "_makeRequest",
|
|
67027
67110
|
value: function () {
|
|
67028
|
-
var _makeRequest2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
67111
|
+
var _makeRequest2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee60(requestObj) {
|
|
67029
67112
|
var _yield$this$_makeRequ;
|
|
67030
67113
|
|
|
67031
67114
|
var retry,
|
|
67032
67115
|
attemptedRetries,
|
|
67033
67116
|
throwError,
|
|
67034
67117
|
blockNumber,
|
|
67035
|
-
|
|
67036
|
-
return regeneratorRuntime.wrap(function
|
|
67118
|
+
_args60 = arguments;
|
|
67119
|
+
return regeneratorRuntime.wrap(function _callee60$(_context60) {
|
|
67037
67120
|
while (1) {
|
|
67038
|
-
switch (
|
|
67121
|
+
switch (_context60.prev = _context60.next) {
|
|
67039
67122
|
case 0:
|
|
67040
|
-
retry =
|
|
67041
|
-
attemptedRetries =
|
|
67042
|
-
throwError =
|
|
67043
|
-
blockNumber =
|
|
67044
|
-
|
|
67123
|
+
retry = _args60.length > 1 && _args60[1] !== undefined ? _args60[1] : true;
|
|
67124
|
+
attemptedRetries = _args60.length > 2 && _args60[2] !== undefined ? _args60[2] : 0;
|
|
67125
|
+
throwError = _args60.length > 3 && _args60[3] !== undefined ? _args60[3] : false;
|
|
67126
|
+
blockNumber = _args60.length > 4 ? _args60[4] : undefined;
|
|
67127
|
+
_context60.next = 6;
|
|
67045
67128
|
return this._makeRequestInternal(requestObj, retry, attemptedRetries, throwError, blockNumber);
|
|
67046
67129
|
|
|
67047
67130
|
case 6:
|
|
67048
|
-
|
|
67049
|
-
|
|
67131
|
+
_context60.t1 = _yield$this$_makeRequ = _context60.sent;
|
|
67132
|
+
_context60.t0 = _context60.t1 === null;
|
|
67050
67133
|
|
|
67051
|
-
if (
|
|
67052
|
-
|
|
67134
|
+
if (_context60.t0) {
|
|
67135
|
+
_context60.next = 10;
|
|
67053
67136
|
break;
|
|
67054
67137
|
}
|
|
67055
67138
|
|
|
67056
|
-
|
|
67139
|
+
_context60.t0 = _yield$this$_makeRequ === void 0;
|
|
67057
67140
|
|
|
67058
67141
|
case 10:
|
|
67059
|
-
if (!
|
|
67060
|
-
|
|
67142
|
+
if (!_context60.t0) {
|
|
67143
|
+
_context60.next = 14;
|
|
67061
67144
|
break;
|
|
67062
67145
|
}
|
|
67063
67146
|
|
|
67064
|
-
|
|
67065
|
-
|
|
67147
|
+
_context60.t2 = void 0;
|
|
67148
|
+
_context60.next = 15;
|
|
67066
67149
|
break;
|
|
67067
67150
|
|
|
67068
67151
|
case 14:
|
|
67069
|
-
|
|
67152
|
+
_context60.t2 = _yield$this$_makeRequ.data;
|
|
67070
67153
|
|
|
67071
67154
|
case 15:
|
|
67072
|
-
return
|
|
67155
|
+
return _context60.abrupt("return", _context60.t2);
|
|
67073
67156
|
|
|
67074
67157
|
case 16:
|
|
67075
67158
|
case "end":
|
|
67076
|
-
return
|
|
67159
|
+
return _context60.stop();
|
|
67077
67160
|
}
|
|
67078
67161
|
}
|
|
67079
|
-
},
|
|
67162
|
+
}, _callee60, this);
|
|
67080
67163
|
}));
|
|
67081
67164
|
|
|
67082
|
-
function _makeRequest(
|
|
67165
|
+
function _makeRequest(_x80) {
|
|
67083
67166
|
return _makeRequest2.apply(this, arguments);
|
|
67084
67167
|
}
|
|
67085
67168
|
|
|
@@ -67101,48 +67184,48 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67101
67184
|
}, {
|
|
67102
67185
|
key: "_makeRequestInternal",
|
|
67103
67186
|
value: function () {
|
|
67104
|
-
var _makeRequestInternal2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
67187
|
+
var _makeRequestInternal2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee61(requestObj) {
|
|
67105
67188
|
var retry,
|
|
67106
67189
|
attemptedRetries,
|
|
67107
67190
|
throwError,
|
|
67108
67191
|
blockNumber,
|
|
67109
|
-
|
|
67110
|
-
return regeneratorRuntime.wrap(function
|
|
67192
|
+
_args61 = arguments;
|
|
67193
|
+
return regeneratorRuntime.wrap(function _callee61$(_context61) {
|
|
67111
67194
|
while (1) {
|
|
67112
|
-
switch (
|
|
67195
|
+
switch (_context61.prev = _context61.next) {
|
|
67113
67196
|
case 0:
|
|
67114
|
-
retry =
|
|
67115
|
-
attemptedRetries =
|
|
67116
|
-
throwError =
|
|
67117
|
-
blockNumber =
|
|
67197
|
+
retry = _args61.length > 1 && _args61[1] !== undefined ? _args61[1] : true;
|
|
67198
|
+
attemptedRetries = _args61.length > 2 && _args61[2] !== undefined ? _args61[2] : 0;
|
|
67199
|
+
throwError = _args61.length > 3 && _args61[3] !== undefined ? _args61[3] : false;
|
|
67200
|
+
blockNumber = _args61.length > 4 ? _args61[4] : undefined;
|
|
67118
67201
|
|
|
67119
67202
|
if (!this.discoveryNodeSelector) {
|
|
67120
|
-
|
|
67203
|
+
_context61.next = 8;
|
|
67121
67204
|
break;
|
|
67122
67205
|
}
|
|
67123
67206
|
|
|
67124
|
-
|
|
67207
|
+
_context61.next = 7;
|
|
67125
67208
|
return this._makeRequestInternalNext(requestObj, throwError, blockNumber);
|
|
67126
67209
|
|
|
67127
67210
|
case 7:
|
|
67128
|
-
return
|
|
67211
|
+
return _context61.abrupt("return", _context61.sent);
|
|
67129
67212
|
|
|
67130
67213
|
case 8:
|
|
67131
|
-
|
|
67214
|
+
_context61.next = 10;
|
|
67132
67215
|
return this._makeRequestInternalLegacy(requestObj, retry, attemptedRetries, throwError, blockNumber);
|
|
67133
67216
|
|
|
67134
67217
|
case 10:
|
|
67135
|
-
return
|
|
67218
|
+
return _context61.abrupt("return", _context61.sent);
|
|
67136
67219
|
|
|
67137
67220
|
case 11:
|
|
67138
67221
|
case "end":
|
|
67139
|
-
return
|
|
67222
|
+
return _context61.stop();
|
|
67140
67223
|
}
|
|
67141
67224
|
}
|
|
67142
|
-
},
|
|
67225
|
+
}, _callee61, this);
|
|
67143
67226
|
}));
|
|
67144
67227
|
|
|
67145
|
-
function _makeRequestInternal(
|
|
67228
|
+
function _makeRequestInternal(_x81) {
|
|
67146
67229
|
return _makeRequestInternal2.apply(this, arguments);
|
|
67147
67230
|
}
|
|
67148
67231
|
|
|
@@ -67151,7 +67234,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67151
67234
|
}, {
|
|
67152
67235
|
key: "_makeRequestInternalLegacy",
|
|
67153
67236
|
value: function () {
|
|
67154
|
-
var _makeRequestInternalLegacy2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
67237
|
+
var _makeRequestInternalLegacy2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee62(requestObj) {
|
|
67155
67238
|
var retry,
|
|
67156
67239
|
attemptedRetries,
|
|
67157
67240
|
throwError,
|
|
@@ -67171,16 +67254,16 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67171
67254
|
errorMessage,
|
|
67172
67255
|
playsSlotDiff,
|
|
67173
67256
|
_errorMessage,
|
|
67174
|
-
|
|
67257
|
+
_args62 = arguments;
|
|
67175
67258
|
|
|
67176
|
-
return regeneratorRuntime.wrap(function
|
|
67259
|
+
return regeneratorRuntime.wrap(function _callee62$(_context62) {
|
|
67177
67260
|
while (1) {
|
|
67178
|
-
switch (
|
|
67261
|
+
switch (_context62.prev = _context62.next) {
|
|
67179
67262
|
case 0:
|
|
67180
|
-
retry =
|
|
67181
|
-
attemptedRetries =
|
|
67182
|
-
throwError =
|
|
67183
|
-
blockNumber =
|
|
67263
|
+
retry = _args62.length > 1 && _args62[1] !== undefined ? _args62[1] : true;
|
|
67264
|
+
attemptedRetries = _args62.length > 2 && _args62[2] !== undefined ? _args62[2] : 0;
|
|
67265
|
+
throwError = _args62.length > 3 && _args62[3] !== undefined ? _args62[3] : false;
|
|
67266
|
+
blockNumber = _args62.length > 4 ? _args62[4] : undefined;
|
|
67184
67267
|
|
|
67185
67268
|
returnOrThrow = function returnOrThrow(e) {
|
|
67186
67269
|
if (throwError) {
|
|
@@ -67191,12 +67274,12 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67191
67274
|
return null;
|
|
67192
67275
|
};
|
|
67193
67276
|
|
|
67194
|
-
|
|
67195
|
-
|
|
67277
|
+
_context62.prev = 5;
|
|
67278
|
+
_context62.next = 8;
|
|
67196
67279
|
return this.getHealthyDiscoveryProviderEndpoint(attemptedRetries);
|
|
67197
67280
|
|
|
67198
67281
|
case 8:
|
|
67199
|
-
newDiscProvEndpoint =
|
|
67282
|
+
newDiscProvEndpoint = _context62.sent;
|
|
67200
67283
|
|
|
67201
67284
|
// If new DP endpoint is selected, update disc prov endpoint and reset attemptedRetries count
|
|
67202
67285
|
if (this.discoveryProviderEndpoint !== newDiscProvEndpoint) {
|
|
@@ -67207,29 +67290,29 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67207
67290
|
attemptedRetries = 0;
|
|
67208
67291
|
}
|
|
67209
67292
|
|
|
67210
|
-
|
|
67293
|
+
_context62.next = 16;
|
|
67211
67294
|
break;
|
|
67212
67295
|
|
|
67213
67296
|
case 12:
|
|
67214
|
-
|
|
67215
|
-
|
|
67216
|
-
console.error(
|
|
67217
|
-
return
|
|
67297
|
+
_context62.prev = 12;
|
|
67298
|
+
_context62.t0 = _context62["catch"](5);
|
|
67299
|
+
console.error(_context62.t0);
|
|
67300
|
+
return _context62.abrupt("return");
|
|
67218
67301
|
|
|
67219
67302
|
case 16:
|
|
67220
|
-
|
|
67221
|
-
|
|
67303
|
+
_context62.prev = 16;
|
|
67304
|
+
_context62.next = 19;
|
|
67222
67305
|
return this._performRequestWithMonitoring(requestObj, this.discoveryProviderEndpoint);
|
|
67223
67306
|
|
|
67224
67307
|
case 19:
|
|
67225
|
-
parsedResponse =
|
|
67226
|
-
|
|
67308
|
+
parsedResponse = _context62.sent;
|
|
67309
|
+
_context62.next = 46;
|
|
67227
67310
|
break;
|
|
67228
67311
|
|
|
67229
67312
|
case 22:
|
|
67230
|
-
|
|
67231
|
-
|
|
67232
|
-
error =
|
|
67313
|
+
_context62.prev = 22;
|
|
67314
|
+
_context62.t1 = _context62["catch"](16);
|
|
67315
|
+
error = _context62.t1;
|
|
67233
67316
|
failureStr = 'Failed to make Discovery Provider request, ';
|
|
67234
67317
|
attemptStr = "attempt #".concat(attemptedRetries, ", ");
|
|
67235
67318
|
errorStr = "error ".concat(JSON.stringify(error.message), ", ");
|
|
@@ -67238,55 +67321,55 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67238
67321
|
console.warn(fullErrString);
|
|
67239
67322
|
|
|
67240
67323
|
if (!retry) {
|
|
67241
|
-
|
|
67324
|
+
_context62.next = 45;
|
|
67242
67325
|
break;
|
|
67243
67326
|
}
|
|
67244
67327
|
|
|
67245
67328
|
if (!(error.status === '404')) {
|
|
67246
|
-
|
|
67329
|
+
_context62.next = 42;
|
|
67247
67330
|
break;
|
|
67248
67331
|
}
|
|
67249
67332
|
|
|
67250
67333
|
this.request404Count += 1;
|
|
67251
67334
|
|
|
67252
67335
|
if (!(this.request404Count < this.maxRequestsForTrue404)) {
|
|
67253
|
-
|
|
67336
|
+
_context62.next = 40;
|
|
67254
67337
|
break;
|
|
67255
67338
|
}
|
|
67256
67339
|
|
|
67257
|
-
|
|
67340
|
+
_context62.next = 37;
|
|
67258
67341
|
return this._makeRequestInternalLegacy(requestObj, retry, this.selectionRequestRetries + 1, throwError);
|
|
67259
67342
|
|
|
67260
67343
|
case 37:
|
|
67261
|
-
return
|
|
67344
|
+
return _context62.abrupt("return", _context62.sent);
|
|
67262
67345
|
|
|
67263
67346
|
case 40:
|
|
67264
67347
|
this.request404Count = 0;
|
|
67265
|
-
return
|
|
67348
|
+
return _context62.abrupt("return", returnOrThrow(_context62.t1));
|
|
67266
67349
|
|
|
67267
67350
|
case 42:
|
|
67268
|
-
|
|
67351
|
+
_context62.next = 44;
|
|
67269
67352
|
return this._makeRequestInternalLegacy(requestObj, retry, attemptedRetries + 1, throwError);
|
|
67270
67353
|
|
|
67271
67354
|
case 44:
|
|
67272
|
-
return
|
|
67355
|
+
return _context62.abrupt("return", _context62.sent);
|
|
67273
67356
|
|
|
67274
67357
|
case 45:
|
|
67275
|
-
return
|
|
67358
|
+
return _context62.abrupt("return", returnOrThrow(_context62.t1));
|
|
67276
67359
|
|
|
67277
67360
|
case 46:
|
|
67278
67361
|
// Validate health check response
|
|
67279
67362
|
// Regressed mode signals we couldn't find a node that wasn't behind by some measure
|
|
67280
67363
|
// so we should should pick something
|
|
67281
67364
|
notInRegressedMode = this.ethContracts && !this.ethContracts.isInRegressedMode();
|
|
67282
|
-
|
|
67365
|
+
_context62.next = 49;
|
|
67283
67366
|
return this._getBlocksBehind(parsedResponse);
|
|
67284
67367
|
|
|
67285
67368
|
case 49:
|
|
67286
|
-
blockDiff =
|
|
67369
|
+
blockDiff = _context62.sent;
|
|
67287
67370
|
|
|
67288
67371
|
if (!(blockNumber && parsedResponse.latest_indexed_block < blockNumber)) {
|
|
67289
|
-
|
|
67372
|
+
_context62.next = 52;
|
|
67290
67373
|
break;
|
|
67291
67374
|
}
|
|
67292
67375
|
|
|
@@ -67294,71 +67377,71 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67294
67377
|
|
|
67295
67378
|
case 52:
|
|
67296
67379
|
if (!(notInRegressedMode && blockDiff)) {
|
|
67297
|
-
|
|
67380
|
+
_context62.next = 60;
|
|
67298
67381
|
break;
|
|
67299
67382
|
}
|
|
67300
67383
|
|
|
67301
67384
|
errorMessage = "".concat(this.discoveryProviderEndpoint, " is too far behind [block diff: ").concat(blockDiff, "]");
|
|
67302
67385
|
|
|
67303
67386
|
if (!retry) {
|
|
67304
|
-
|
|
67387
|
+
_context62.next = 59;
|
|
67305
67388
|
break;
|
|
67306
67389
|
}
|
|
67307
67390
|
|
|
67308
67391
|
console.info("".concat(errorMessage, ". Retrying request at attempt #").concat(attemptedRetries, "..."));
|
|
67309
|
-
|
|
67392
|
+
_context62.next = 58;
|
|
67310
67393
|
return this._makeRequestInternalLegacy(requestObj, retry, attemptedRetries + 1, throwError);
|
|
67311
67394
|
|
|
67312
67395
|
case 58:
|
|
67313
|
-
return
|
|
67396
|
+
return _context62.abrupt("return", _context62.sent);
|
|
67314
67397
|
|
|
67315
67398
|
case 59:
|
|
67316
|
-
return
|
|
67399
|
+
return _context62.abrupt("return", returnOrThrow(new Error(errorMessage)));
|
|
67317
67400
|
|
|
67318
67401
|
case 60:
|
|
67319
|
-
|
|
67402
|
+
_context62.next = 62;
|
|
67320
67403
|
return this._getPlaysSlotsBehind(parsedResponse);
|
|
67321
67404
|
|
|
67322
67405
|
case 62:
|
|
67323
|
-
playsSlotDiff =
|
|
67406
|
+
playsSlotDiff = _context62.sent;
|
|
67324
67407
|
|
|
67325
67408
|
if (!(notInRegressedMode && playsSlotDiff)) {
|
|
67326
|
-
|
|
67409
|
+
_context62.next = 71;
|
|
67327
67410
|
break;
|
|
67328
67411
|
}
|
|
67329
67412
|
|
|
67330
67413
|
_errorMessage = "".concat(this.discoveryProviderEndpoint, " is too far behind [slot diff: ").concat(playsSlotDiff, "]");
|
|
67331
67414
|
|
|
67332
67415
|
if (!retry) {
|
|
67333
|
-
|
|
67416
|
+
_context62.next = 70;
|
|
67334
67417
|
break;
|
|
67335
67418
|
}
|
|
67336
67419
|
|
|
67337
67420
|
console.info("".concat(_errorMessage, ". Retrying request at attempt #").concat(attemptedRetries, "..."));
|
|
67338
|
-
|
|
67421
|
+
_context62.next = 69;
|
|
67339
67422
|
return this._makeRequestInternalLegacy(requestObj, retry, attemptedRetries + 1, throwError);
|
|
67340
67423
|
|
|
67341
67424
|
case 69:
|
|
67342
|
-
return
|
|
67425
|
+
return _context62.abrupt("return", _context62.sent);
|
|
67343
67426
|
|
|
67344
67427
|
case 70:
|
|
67345
|
-
return
|
|
67428
|
+
return _context62.abrupt("return", returnOrThrow(new Error(_errorMessage)));
|
|
67346
67429
|
|
|
67347
67430
|
case 71:
|
|
67348
67431
|
// Reset 404 counts
|
|
67349
67432
|
this.request404Count = 0; // Everything looks good, return the data!
|
|
67350
67433
|
|
|
67351
|
-
return
|
|
67434
|
+
return _context62.abrupt("return", parsedResponse);
|
|
67352
67435
|
|
|
67353
67436
|
case 73:
|
|
67354
67437
|
case "end":
|
|
67355
|
-
return
|
|
67438
|
+
return _context62.stop();
|
|
67356
67439
|
}
|
|
67357
67440
|
}
|
|
67358
|
-
},
|
|
67441
|
+
}, _callee62, this, [[5, 12], [16, 22]]);
|
|
67359
67442
|
}));
|
|
67360
67443
|
|
|
67361
|
-
function _makeRequestInternalLegacy(
|
|
67444
|
+
function _makeRequestInternalLegacy(_x82) {
|
|
67362
67445
|
return _makeRequestInternalLegacy2.apply(this, arguments);
|
|
67363
67446
|
}
|
|
67364
67447
|
|
|
@@ -67367,7 +67450,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67367
67450
|
}, {
|
|
67368
67451
|
key: "_makeRequestInternalNext",
|
|
67369
67452
|
value: function () {
|
|
67370
|
-
var _makeRequestInternalNext2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
67453
|
+
var _makeRequestInternalNext2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee63(requestObj) {
|
|
67371
67454
|
var _yield$this$discovery, _this$discoveryNodeMi, _this$discoveryNodeMi2, _yield$this$discovery3, _this$discoveryNodeMi5, _this$discoveryNodeMi6;
|
|
67372
67455
|
|
|
67373
67456
|
var throwError,
|
|
@@ -67384,21 +67467,21 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67384
67467
|
_this$discoveryNodeMi3,
|
|
67385
67468
|
_this$discoveryNodeMi4,
|
|
67386
67469
|
responseBody,
|
|
67387
|
-
|
|
67470
|
+
_args63 = arguments;
|
|
67388
67471
|
|
|
67389
|
-
return regeneratorRuntime.wrap(function
|
|
67472
|
+
return regeneratorRuntime.wrap(function _callee63$(_context63) {
|
|
67390
67473
|
while (1) {
|
|
67391
|
-
switch (
|
|
67474
|
+
switch (_context63.prev = _context63.next) {
|
|
67392
67475
|
case 0:
|
|
67393
|
-
throwError =
|
|
67394
|
-
blockNumber =
|
|
67476
|
+
throwError = _args63.length > 1 && _args63[1] !== undefined ? _args63[1] : false;
|
|
67477
|
+
blockNumber = _args63.length > 2 ? _args63[2] : undefined;
|
|
67395
67478
|
|
|
67396
67479
|
if (!(!this.discoveryProviderEndpoint || !this.discoveryNodeMiddleware)) {
|
|
67397
|
-
|
|
67480
|
+
_context63.next = 4;
|
|
67398
67481
|
break;
|
|
67399
67482
|
}
|
|
67400
67483
|
|
|
67401
|
-
return
|
|
67484
|
+
return _context63.abrupt("return");
|
|
67402
67485
|
|
|
67403
67486
|
case 4:
|
|
67404
67487
|
axiosRequest = this._createDiscProvRequest(requestObj, this.discoveryProviderEndpoint);
|
|
@@ -67410,109 +67493,109 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67410
67493
|
url: url,
|
|
67411
67494
|
init: fetchRequestInit
|
|
67412
67495
|
};
|
|
67413
|
-
|
|
67496
|
+
_context63.next = 10;
|
|
67414
67497
|
return (_this$discoveryNodeMi = (_this$discoveryNodeMi2 = this.discoveryNodeMiddleware).pre) === null || _this$discoveryNodeMi === void 0 ? void 0 : _this$discoveryNodeMi.call(_this$discoveryNodeMi2, _objectSpread2({
|
|
67415
67498
|
fetch: fetch__default["default"]
|
|
67416
67499
|
}, fetchParams));
|
|
67417
67500
|
|
|
67418
67501
|
case 10:
|
|
67419
|
-
|
|
67420
|
-
|
|
67502
|
+
_context63.t1 = _yield$this$discovery = _context63.sent;
|
|
67503
|
+
_context63.t0 = _context63.t1 !== null;
|
|
67421
67504
|
|
|
67422
|
-
if (!
|
|
67423
|
-
|
|
67505
|
+
if (!_context63.t0) {
|
|
67506
|
+
_context63.next = 14;
|
|
67424
67507
|
break;
|
|
67425
67508
|
}
|
|
67426
67509
|
|
|
67427
|
-
|
|
67510
|
+
_context63.t0 = _yield$this$discovery !== void 0;
|
|
67428
67511
|
|
|
67429
67512
|
case 14:
|
|
67430
|
-
if (!
|
|
67431
|
-
|
|
67513
|
+
if (!_context63.t0) {
|
|
67514
|
+
_context63.next = 18;
|
|
67432
67515
|
break;
|
|
67433
67516
|
}
|
|
67434
67517
|
|
|
67435
|
-
|
|
67436
|
-
|
|
67518
|
+
_context63.t2 = _yield$this$discovery;
|
|
67519
|
+
_context63.next = 19;
|
|
67437
67520
|
break;
|
|
67438
67521
|
|
|
67439
67522
|
case 18:
|
|
67440
|
-
|
|
67523
|
+
_context63.t2 = fetchParams;
|
|
67441
67524
|
|
|
67442
67525
|
case 19:
|
|
67443
|
-
fetchParams =
|
|
67444
|
-
|
|
67445
|
-
|
|
67526
|
+
fetchParams = _context63.t2;
|
|
67527
|
+
_context63.prev = 20;
|
|
67528
|
+
_context63.next = 23;
|
|
67446
67529
|
return fetch__default["default"](fetchParams.url, fetchParams.init);
|
|
67447
67530
|
|
|
67448
67531
|
case 23:
|
|
67449
|
-
response =
|
|
67450
|
-
|
|
67532
|
+
response = _context63.sent;
|
|
67533
|
+
_context63.next = 48;
|
|
67451
67534
|
break;
|
|
67452
67535
|
|
|
67453
67536
|
case 26:
|
|
67454
|
-
|
|
67455
|
-
|
|
67456
|
-
|
|
67537
|
+
_context63.prev = 26;
|
|
67538
|
+
_context63.t3 = _context63["catch"](20);
|
|
67539
|
+
_context63.next = 30;
|
|
67457
67540
|
return (_this$discoveryNodeMi3 = (_this$discoveryNodeMi4 = this.discoveryNodeMiddleware).onError) === null || _this$discoveryNodeMi3 === void 0 ? void 0 : _this$discoveryNodeMi3.call(_this$discoveryNodeMi4, _objectSpread2(_objectSpread2({
|
|
67458
67541
|
fetch: fetch__default["default"]
|
|
67459
67542
|
}, fetchParams), {}, {
|
|
67460
|
-
error:
|
|
67543
|
+
error: _context63.t3,
|
|
67461
67544
|
response: response ? response.clone() : undefined
|
|
67462
67545
|
}));
|
|
67463
67546
|
|
|
67464
67547
|
case 30:
|
|
67465
|
-
|
|
67466
|
-
|
|
67548
|
+
_context63.t5 = _yield$this$discovery2 = _context63.sent;
|
|
67549
|
+
_context63.t4 = _context63.t5 !== null;
|
|
67467
67550
|
|
|
67468
|
-
if (!
|
|
67469
|
-
|
|
67551
|
+
if (!_context63.t4) {
|
|
67552
|
+
_context63.next = 34;
|
|
67470
67553
|
break;
|
|
67471
67554
|
}
|
|
67472
67555
|
|
|
67473
|
-
|
|
67556
|
+
_context63.t4 = _yield$this$discovery2 !== void 0;
|
|
67474
67557
|
|
|
67475
67558
|
case 34:
|
|
67476
|
-
if (!
|
|
67477
|
-
|
|
67559
|
+
if (!_context63.t4) {
|
|
67560
|
+
_context63.next = 38;
|
|
67478
67561
|
break;
|
|
67479
67562
|
}
|
|
67480
67563
|
|
|
67481
|
-
|
|
67482
|
-
|
|
67564
|
+
_context63.t6 = _yield$this$discovery2;
|
|
67565
|
+
_context63.next = 39;
|
|
67483
67566
|
break;
|
|
67484
67567
|
|
|
67485
67568
|
case 38:
|
|
67486
|
-
|
|
67569
|
+
_context63.t6 = response;
|
|
67487
67570
|
|
|
67488
67571
|
case 39:
|
|
67489
|
-
response =
|
|
67572
|
+
response = _context63.t6;
|
|
67490
67573
|
|
|
67491
67574
|
if (!(response === undefined)) {
|
|
67492
|
-
|
|
67575
|
+
_context63.next = 48;
|
|
67493
67576
|
break;
|
|
67494
67577
|
}
|
|
67495
67578
|
|
|
67496
67579
|
if (!throwError) {
|
|
67497
|
-
|
|
67580
|
+
_context63.next = 47;
|
|
67498
67581
|
break;
|
|
67499
67582
|
}
|
|
67500
67583
|
|
|
67501
|
-
if (!(
|
|
67502
|
-
|
|
67584
|
+
if (!(_context63.t3 instanceof Error)) {
|
|
67585
|
+
_context63.next = 46;
|
|
67503
67586
|
break;
|
|
67504
67587
|
}
|
|
67505
67588
|
|
|
67506
|
-
throw new FetchError$1(
|
|
67589
|
+
throw new FetchError$1(_context63.t3, 'The request failed and the interceptors did not return an alternative response');
|
|
67507
67590
|
|
|
67508
67591
|
case 46:
|
|
67509
|
-
throw
|
|
67592
|
+
throw _context63.t3;
|
|
67510
67593
|
|
|
67511
67594
|
case 47:
|
|
67512
|
-
return
|
|
67595
|
+
return _context63.abrupt("return", null);
|
|
67513
67596
|
|
|
67514
67597
|
case 48:
|
|
67515
|
-
|
|
67598
|
+
_context63.next = 50;
|
|
67516
67599
|
return (_this$discoveryNodeMi5 = (_this$discoveryNodeMi6 = this.discoveryNodeMiddleware).post) === null || _this$discoveryNodeMi5 === void 0 ? void 0 : _this$discoveryNodeMi5.call(_this$discoveryNodeMi6, _objectSpread2(_objectSpread2({
|
|
67517
67600
|
fetch: fetch__default["default"]
|
|
67518
67601
|
}, fetchParams), {}, {
|
|
@@ -67520,56 +67603,56 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67520
67603
|
}));
|
|
67521
67604
|
|
|
67522
67605
|
case 50:
|
|
67523
|
-
|
|
67524
|
-
|
|
67606
|
+
_context63.t8 = _yield$this$discovery3 = _context63.sent;
|
|
67607
|
+
_context63.t7 = _context63.t8 !== null;
|
|
67525
67608
|
|
|
67526
|
-
if (!
|
|
67527
|
-
|
|
67609
|
+
if (!_context63.t7) {
|
|
67610
|
+
_context63.next = 54;
|
|
67528
67611
|
break;
|
|
67529
67612
|
}
|
|
67530
67613
|
|
|
67531
|
-
|
|
67614
|
+
_context63.t7 = _yield$this$discovery3 !== void 0;
|
|
67532
67615
|
|
|
67533
67616
|
case 54:
|
|
67534
|
-
if (!
|
|
67535
|
-
|
|
67617
|
+
if (!_context63.t7) {
|
|
67618
|
+
_context63.next = 58;
|
|
67536
67619
|
break;
|
|
67537
67620
|
}
|
|
67538
67621
|
|
|
67539
|
-
|
|
67540
|
-
|
|
67622
|
+
_context63.t9 = _yield$this$discovery3;
|
|
67623
|
+
_context63.next = 59;
|
|
67541
67624
|
break;
|
|
67542
67625
|
|
|
67543
67626
|
case 58:
|
|
67544
|
-
|
|
67627
|
+
_context63.t9 = response;
|
|
67545
67628
|
|
|
67546
67629
|
case 59:
|
|
67547
|
-
response =
|
|
67548
|
-
|
|
67630
|
+
response = _context63.t9;
|
|
67631
|
+
_context63.next = 62;
|
|
67549
67632
|
return response.json();
|
|
67550
67633
|
|
|
67551
67634
|
case 62:
|
|
67552
|
-
responseBody =
|
|
67635
|
+
responseBody = _context63.sent;
|
|
67553
67636
|
|
|
67554
67637
|
if (!(blockNumber && responseBody.latest_indexed_block < blockNumber)) {
|
|
67555
|
-
|
|
67638
|
+
_context63.next = 65;
|
|
67556
67639
|
break;
|
|
67557
67640
|
}
|
|
67558
67641
|
|
|
67559
67642
|
throw new Error("Requested blocknumber ".concat(blockNumber, ", but discovery is behind at ").concat(responseBody.latest_indexed_block));
|
|
67560
67643
|
|
|
67561
67644
|
case 65:
|
|
67562
|
-
return
|
|
67645
|
+
return _context63.abrupt("return", responseBody);
|
|
67563
67646
|
|
|
67564
67647
|
case 66:
|
|
67565
67648
|
case "end":
|
|
67566
|
-
return
|
|
67649
|
+
return _context63.stop();
|
|
67567
67650
|
}
|
|
67568
67651
|
}
|
|
67569
|
-
},
|
|
67652
|
+
}, _callee63, this, [[20, 26]]);
|
|
67570
67653
|
}));
|
|
67571
67654
|
|
|
67572
|
-
function _makeRequestInternalNext(
|
|
67655
|
+
function _makeRequestInternalNext(_x83) {
|
|
67573
67656
|
return _makeRequestInternalNext2.apply(this, arguments);
|
|
67574
67657
|
}
|
|
67575
67658
|
|
|
@@ -67585,16 +67668,16 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67585
67668
|
}, {
|
|
67586
67669
|
key: "getHealthyDiscoveryProviderEndpoint",
|
|
67587
67670
|
value: function () {
|
|
67588
|
-
var _getHealthyDiscoveryProviderEndpoint = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
67671
|
+
var _getHealthyDiscoveryProviderEndpoint = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee64(attemptedRetries) {
|
|
67589
67672
|
var endpoint;
|
|
67590
|
-
return regeneratorRuntime.wrap(function
|
|
67673
|
+
return regeneratorRuntime.wrap(function _callee64$(_context64) {
|
|
67591
67674
|
while (1) {
|
|
67592
|
-
switch (
|
|
67675
|
+
switch (_context64.prev = _context64.next) {
|
|
67593
67676
|
case 0:
|
|
67594
67677
|
endpoint = this.discoveryProviderEndpoint;
|
|
67595
67678
|
|
|
67596
67679
|
if (!(attemptedRetries > this.selectionRequestRetries || !endpoint)) {
|
|
67597
|
-
|
|
67680
|
+
_context64.next = 8;
|
|
67598
67681
|
break;
|
|
67599
67682
|
}
|
|
67600
67683
|
|
|
@@ -67603,32 +67686,32 @@ var DiscoveryProvider = /*#__PURE__*/function () {
|
|
|
67603
67686
|
this.serviceSelector.addUnhealthy(endpoint); // Clear the cached endpoint and select new endpoint from backups
|
|
67604
67687
|
|
|
67605
67688
|
this.serviceSelector.clearCached();
|
|
67606
|
-
|
|
67689
|
+
_context64.next = 7;
|
|
67607
67690
|
return this.serviceSelector.select();
|
|
67608
67691
|
|
|
67609
67692
|
case 7:
|
|
67610
|
-
endpoint =
|
|
67693
|
+
endpoint = _context64.sent;
|
|
67611
67694
|
|
|
67612
67695
|
case 8:
|
|
67613
67696
|
if (endpoint) {
|
|
67614
|
-
|
|
67697
|
+
_context64.next = 10;
|
|
67615
67698
|
break;
|
|
67616
67699
|
}
|
|
67617
67700
|
|
|
67618
67701
|
throw new Error('All Discovery Providers are unhealthy and unavailable.');
|
|
67619
67702
|
|
|
67620
67703
|
case 10:
|
|
67621
|
-
return
|
|
67704
|
+
return _context64.abrupt("return", endpoint);
|
|
67622
67705
|
|
|
67623
67706
|
case 11:
|
|
67624
67707
|
case "end":
|
|
67625
|
-
return
|
|
67708
|
+
return _context64.stop();
|
|
67626
67709
|
}
|
|
67627
67710
|
}
|
|
67628
|
-
},
|
|
67711
|
+
}, _callee64, this);
|
|
67629
67712
|
}));
|
|
67630
67713
|
|
|
67631
|
-
function getHealthyDiscoveryProviderEndpoint(
|
|
67714
|
+
function getHealthyDiscoveryProviderEndpoint(_x84) {
|
|
67632
67715
|
return _getHealthyDiscoveryProviderEndpoint.apply(this, arguments);
|
|
67633
67716
|
}
|
|
67634
67717
|
|
|
@@ -74314,7 +74397,9 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74314
74397
|
_ref$preferHigherPatc2 = _ref.preferHigherPatchForSecondaries,
|
|
74315
74398
|
preferHigherPatchForSecondaries = _ref$preferHigherPatc2 === void 0 ? true : _ref$preferHigherPatc2,
|
|
74316
74399
|
_ref$localStorage = _ref.localStorage,
|
|
74317
|
-
localStorage = _ref$localStorage === void 0 ? getPlatformLocalStorage() : _ref$localStorage
|
|
74400
|
+
localStorage = _ref$localStorage === void 0 ? getPlatformLocalStorage() : _ref$localStorage,
|
|
74401
|
+
_ref$useDiscoveryRela = _ref.useDiscoveryRelay,
|
|
74402
|
+
useDiscoveryRelay = _ref$useDiscoveryRela === void 0 ? false : _ref$useDiscoveryRela;
|
|
74318
74403
|
|
|
74319
74404
|
_classCallCheck(this, AudiusLibs);
|
|
74320
74405
|
|
|
@@ -74400,6 +74485,8 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74400
74485
|
|
|
74401
74486
|
_defineProperty$1(this, "localStorage", void 0);
|
|
74402
74487
|
|
|
74488
|
+
_defineProperty$1(this, "useDiscoveryRelay", void 0);
|
|
74489
|
+
|
|
74403
74490
|
// set version
|
|
74404
74491
|
this.version = version_1;
|
|
74405
74492
|
this.ethWeb3Config = ethWeb3Config;
|
|
@@ -74442,7 +74529,8 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74442
74529
|
this.EntityManager = null;
|
|
74443
74530
|
this.preferHigherPatchForPrimary = preferHigherPatchForPrimary;
|
|
74444
74531
|
this.preferHigherPatchForSecondaries = preferHigherPatchForSecondaries;
|
|
74445
|
-
this.localStorage = localStorage;
|
|
74532
|
+
this.localStorage = localStorage;
|
|
74533
|
+
this.useDiscoveryRelay = useDiscoveryRelay; // Schemas
|
|
74446
74534
|
|
|
74447
74535
|
var schemaValidator = new SchemaValidator();
|
|
74448
74536
|
schemaValidator.init();
|
|
@@ -74455,7 +74543,7 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74455
74543
|
key: "init",
|
|
74456
74544
|
value: function () {
|
|
74457
74545
|
var _init = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
74458
|
-
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;
|
|
74546
|
+
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;
|
|
74459
74547
|
|
|
74460
74548
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
74461
74549
|
while (1) {
|
|
@@ -74574,7 +74662,7 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74574
74662
|
|
|
74575
74663
|
|
|
74576
74664
|
if (!this.discoveryProviderConfig) {
|
|
74577
|
-
_context.next =
|
|
74665
|
+
_context.next = 35;
|
|
74578
74666
|
break;
|
|
74579
74667
|
}
|
|
74580
74668
|
|
|
@@ -74588,8 +74676,20 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74588
74676
|
return this.discoveryProvider.init();
|
|
74589
74677
|
|
|
74590
74678
|
case 34:
|
|
74679
|
+
// set discovery provider in web3 for relay
|
|
74680
|
+
if (this.web3Config && this.useDiscoveryRelay) {
|
|
74681
|
+
web3Manager = this.web3Manager;
|
|
74682
|
+
|
|
74683
|
+
if (web3Manager === undefined || web3Manager === null) {
|
|
74684
|
+
console.warn("useDiscoveryRelay is set to true but web3Manager is not configured");
|
|
74685
|
+
} else {
|
|
74686
|
+
(_this$web3Manager = this.web3Manager) === null || _this$web3Manager === void 0 ? void 0 : _this$web3Manager.setDiscoveryProvider(this.discoveryProvider);
|
|
74687
|
+
}
|
|
74688
|
+
}
|
|
74689
|
+
|
|
74690
|
+
case 35:
|
|
74591
74691
|
if (!this.creatorNodeConfig) {
|
|
74592
|
-
_context.next =
|
|
74692
|
+
_context.next = 55;
|
|
74593
74693
|
break;
|
|
74594
74694
|
}
|
|
74595
74695
|
|
|
@@ -74598,12 +74698,12 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74598
74698
|
creatorNodeEndpoint = this.creatorNodeConfig.fallbackUrl;
|
|
74599
74699
|
|
|
74600
74700
|
if (!(currentUser !== null && currentUser !== void 0 && currentUser.wallet)) {
|
|
74601
|
-
_context.next =
|
|
74701
|
+
_context.next = 52;
|
|
74602
74702
|
break;
|
|
74603
74703
|
}
|
|
74604
74704
|
|
|
74605
74705
|
if (!this.creatorNodeConfig.storageNodeSelector) {
|
|
74606
|
-
_context.next =
|
|
74706
|
+
_context.next = 44;
|
|
74607
74707
|
break;
|
|
74608
74708
|
}
|
|
74609
74709
|
|
|
@@ -74613,33 +74713,33 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74613
74713
|
creatorNodeEndpoint = storageNode;
|
|
74614
74714
|
}
|
|
74615
74715
|
|
|
74616
|
-
_context.next =
|
|
74716
|
+
_context.next = 52;
|
|
74617
74717
|
break;
|
|
74618
74718
|
|
|
74619
|
-
case
|
|
74719
|
+
case 44:
|
|
74620
74720
|
if (!this.ethContracts) {
|
|
74621
|
-
_context.next =
|
|
74721
|
+
_context.next = 52;
|
|
74622
74722
|
break;
|
|
74623
74723
|
}
|
|
74624
74724
|
|
|
74625
|
-
_context.next =
|
|
74725
|
+
_context.next = 47;
|
|
74626
74726
|
return this.ethContracts.ServiceProviderFactoryClient.getServiceProviderList('content-node');
|
|
74627
74727
|
|
|
74628
|
-
case
|
|
74728
|
+
case 47:
|
|
74629
74729
|
storageV2Nodes = _context.sent;
|
|
74630
|
-
_context.next =
|
|
74730
|
+
_context.next = 50;
|
|
74631
74731
|
return getNStorageNodes(storageV2Nodes, 1, currentUser.wallet, this.logger);
|
|
74632
74732
|
|
|
74633
|
-
case
|
|
74733
|
+
case 50:
|
|
74634
74734
|
randomNodes = _context.sent;
|
|
74635
74735
|
creatorNodeEndpoint = randomNodes[0];
|
|
74636
74736
|
|
|
74637
|
-
case
|
|
74737
|
+
case 52:
|
|
74638
74738
|
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);
|
|
74639
|
-
_context.next =
|
|
74739
|
+
_context.next = 55;
|
|
74640
74740
|
return this.creatorNode.init();
|
|
74641
74741
|
|
|
74642
|
-
case
|
|
74742
|
+
case 55:
|
|
74643
74743
|
/** Comstock */
|
|
74644
74744
|
if (this.comstockConfig) {
|
|
74645
74745
|
this.comstock = new Comstock(this.comstockConfig.url);
|
|
@@ -74658,7 +74758,7 @@ var AudiusLibs = /*#__PURE__*/function () {
|
|
|
74658
74758
|
this.Notifications = _construct(Notifications, services);
|
|
74659
74759
|
this.EntityManager = _construct(EntityManager, services);
|
|
74660
74760
|
|
|
74661
|
-
case
|
|
74761
|
+
case 67:
|
|
74662
74762
|
case "end":
|
|
74663
74763
|
return _context.stop();
|
|
74664
74764
|
}
|