@audius/sdk 2.0.3-beta.4 → 2.0.3-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/legacy.js CHANGED
@@ -25391,9 +25391,13 @@ var fileHasher = {
25391
25391
 
25392
25392
  case 3:
25393
25393
  buffer = _context10.sent;
25394
- return _context10.abrupt("return", fileHasher.hashNonImages(buffer));
25394
+ _context10.next = 6;
25395
+ return fileHasher.hashNonImages(buffer);
25395
25396
 
25396
- case 5:
25397
+ case 6:
25398
+ return _context10.abrupt("return", _context10.sent);
25399
+
25400
+ case 7:
25397
25401
  case "end":
25398
25402
  return _context10.stop();
25399
25403
  }
@@ -25415,9 +25419,13 @@ var fileHasher = {
25415
25419
  while (1) {
25416
25420
  switch (_context11.prev = _context11.next) {
25417
25421
  case 0:
25418
- return _context11.abrupt("return", fileHasher.hashImages(content));
25422
+ _context11.next = 3;
25423
+ return fileHasher.hashImages(content);
25419
25424
 
25420
- case 2:
25425
+ case 3:
25426
+ return _context11.abrupt("return", _context11.sent);
25427
+
25428
+ case 4:
25421
25429
  case "end":
25422
25430
  return _context11.stop();
25423
25431
  }
@@ -26906,9 +26914,9 @@ var EthWeb3Manager = /*#__PURE__*/function () {
26906
26914
  }();
26907
26915
 
26908
26916
  var name = "@audius/sdk";
26909
- var version = "2.0.3-beta.4";
26917
+ var version = "2.0.3-beta.5";
26910
26918
  var audius = {
26911
- releaseSHA: "42c56a1bf4cc52d52da7df738ace6822a91b0fce"
26919
+ releaseSHA: "29b38fb1a75d58b32ce4c98a46dc035540b43e1a"
26912
26920
  };
26913
26921
  var description = "";
26914
26922
  var main = "dist/index.cjs.js";
@@ -49563,9 +49571,13 @@ var AudiusContracts = /*#__PURE__*/function () {
49563
49571
  while (1) {
49564
49572
  switch (_context.prev = _context.next) {
49565
49573
  case 0:
49566
- return _context.abrupt("return", Promise.resolve(''));
49574
+ _context.next = 2;
49575
+ return Promise.resolve('');
49567
49576
 
49568
- case 1:
49577
+ case 2:
49578
+ return _context.abrupt("return", _context.sent);
49579
+
49580
+ case 3:
49569
49581
  case "end":
49570
49582
  return _context.stop();
49571
49583
  }
@@ -52858,9 +52870,13 @@ var CreatorNode = /*#__PURE__*/function () {
52858
52870
  while (1) {
52859
52871
  switch (_context8.prev = _context8.next) {
52860
52872
  case 0:
52861
- return _context8.abrupt("return", _this2.uploadTrackAudioV2(trackFile, onProgress));
52873
+ _context8.next = 2;
52874
+ return _this2.uploadTrackAudioV2(trackFile, onProgress);
52862
52875
 
52863
- case 1:
52876
+ case 2:
52877
+ return _context8.abrupt("return", _context8.sent);
52878
+
52879
+ case 3:
52864
52880
  case "end":
52865
52881
  return _context8.stop();
52866
52882
  }
@@ -52873,9 +52889,13 @@ var CreatorNode = /*#__PURE__*/function () {
52873
52889
  while (1) {
52874
52890
  switch (_context9.prev = _context9.next) {
52875
52891
  case 0:
52876
- return _context9.abrupt("return", _this2.uploadTrackCoverArtV2(coverArtFile, onProgress));
52892
+ _context9.next = 2;
52893
+ return _this2.uploadTrackCoverArtV2(coverArtFile, onProgress);
52877
52894
 
52878
- case 1:
52895
+ case 2:
52896
+ return _context9.abrupt("return", _context9.sent);
52897
+
52898
+ case 3:
52879
52899
  case "end":
52880
52900
  return _context9.stop();
52881
52901
  }
@@ -52893,7 +52913,7 @@ var CreatorNode = /*#__PURE__*/function () {
52893
52913
  // Update metadata to include uploaded CIDs
52894
52914
  // TODO: Make sure discovery and elsewhere accept 0-length array. Some checks in CN currently fail if there's not at least 1 valid segment
52895
52915
  updatedMetadata.track_segments = [];
52896
- updatedMetadata.track_cid = audioResp.results["320"];
52916
+ updatedMetadata.track_cid = audioResp.results['320'];
52897
52917
 
52898
52918
  if ((_updatedMetadata$down = updatedMetadata.download) !== null && _updatedMetadata$down !== void 0 && _updatedMetadata$down.is_downloadable) {
52899
52919
  updatedMetadata.download.cid = updatedMetadata.track_cid;
@@ -52924,9 +52944,13 @@ var CreatorNode = /*#__PURE__*/function () {
52924
52944
  while (1) {
52925
52945
  switch (_context11.prev = _context11.next) {
52926
52946
  case 0:
52927
- return _context11.abrupt("return", this.uploadFileV2(file, onProgress, 'audio'));
52947
+ _context11.next = 2;
52948
+ return this.uploadFileV2(file, onProgress, 'audio');
52928
52949
 
52929
- case 1:
52950
+ case 2:
52951
+ return _context11.abrupt("return", _context11.sent);
52952
+
52953
+ case 3:
52930
52954
  case "end":
52931
52955
  return _context11.stop();
52932
52956
  }
@@ -52948,9 +52972,13 @@ var CreatorNode = /*#__PURE__*/function () {
52948
52972
  while (1) {
52949
52973
  switch (_context12.prev = _context12.next) {
52950
52974
  case 0:
52951
- return _context12.abrupt("return", this.uploadFileV2(file, onProgress, 'img_square'));
52975
+ _context12.next = 2;
52976
+ return this.uploadFileV2(file, onProgress, 'img_square');
52952
52977
 
52953
- case 1:
52978
+ case 2:
52979
+ return _context12.abrupt("return", _context12.sent);
52980
+
52981
+ case 3:
52954
52982
  case "end":
52955
52983
  return _context12.stop();
52956
52984
  }
@@ -52991,9 +53019,13 @@ var CreatorNode = /*#__PURE__*/function () {
52991
53019
 
52992
53020
  case 5:
52993
53021
  response = _context13.sent;
52994
- return _context13.abrupt("return", this.pollProcessingStatusV2(response.data[0].id, template === 'audio' ? MAX_TRACK_TRANSCODE_TIMEOUT : MAX_IMAGE_RESIZE_TIMEOUT_MS));
53022
+ _context13.next = 8;
53023
+ return this.pollProcessingStatusV2(response.data[0].id, template === 'audio' ? MAX_TRACK_TRANSCODE_TIMEOUT : MAX_IMAGE_RESIZE_TIMEOUT_MS);
52995
53024
 
52996
- case 7:
53025
+ case 8:
53026
+ return _context13.abrupt("return", _context13.sent);
53027
+
53028
+ case 9:
52997
53029
  case "end":
52998
53030
  return _context13.stop();
52999
53031
  }
@@ -53724,9 +53756,9 @@ var CreatorNode = /*#__PURE__*/function () {
53724
53756
  /* ------- INTERNAL FUNCTIONS ------- */
53725
53757
 
53726
53758
  /**
53727
- * Makes an axios request to the connected creator node
53728
- * @return response body
53729
- */
53759
+ * Makes an axios request to the connected creator node
53760
+ * @return response body
53761
+ */
53730
53762
 
53731
53763
  }, {
53732
53764
  key: "_makeRequestV2",
@@ -53739,9 +53771,13 @@ var CreatorNode = /*#__PURE__*/function () {
53739
53771
  // TODO: This might want to have other error handling, request UUIDs, etc...
53740
53772
  // But I didn't want to pull in all the chaos and incompatiblity of the old _makeRequest
53741
53773
  axiosRequestObj.baseURL = this.creatorNodeEndpoint;
53742
- return _context27.abrupt("return", axios__default["default"](axiosRequestObj));
53774
+ _context27.next = 3;
53775
+ return axios__default["default"](axiosRequestObj);
53743
53776
 
53744
- case 2:
53777
+ case 3:
53778
+ return _context27.abrupt("return", _context27.sent);
53779
+
53780
+ case 4:
53745
53781
  case "end":
53746
53782
  return _context27.stop();
53747
53783
  }
@@ -54561,15 +54597,19 @@ var CreatorNode = /*#__PURE__*/function () {
54561
54597
  switch (_context39.prev = _context39.next) {
54562
54598
  case 0:
54563
54599
  onRetry = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : function (_err) {};
54564
- return _context39.abrupt("return", retry__default["default"](fn, {
54600
+ _context39.next = 3;
54601
+ return retry__default["default"](fn, {
54565
54602
  minTimeout: 500,
54566
54603
  maxTimeout: 4000,
54567
54604
  factor: 3,
54568
54605
  retries: 3,
54569
54606
  onRetry: onRetry
54570
- }));
54607
+ });
54571
54608
 
54572
- case 2:
54609
+ case 3:
54610
+ return _context39.abrupt("return", _context39.sent);
54611
+
54612
+ case 4:
54573
54613
  case "end":
54574
54614
  return _context39.stop();
54575
54615
  }
@@ -56851,6 +56891,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
56851
56891
  this.userStateManager = userStateManager;
56852
56892
  this.ethContracts = ethContracts;
56853
56893
  this.web3Manager = web3Manager;
56894
+ this.selectionCallback = selectionCallback;
56854
56895
  this.unhealthyBlockDiff = unhealthyBlockDiff !== null && unhealthyBlockDiff !== void 0 ? unhealthyBlockDiff : DEFAULT_UNHEALTHY_BLOCK_DIFF;
56855
56896
  this.serviceSelector = new DiscoveryProviderSelection({
56856
56897
  whitelist: this.whitelist,
@@ -56895,7 +56936,11 @@ var DiscoveryProvider = /*#__PURE__*/function () {
56895
56936
  }
56896
56937
 
56897
56938
  this.discoveryNodeSelector.addEventListener('change', function (endpoint) {
56939
+ var _this$selectionCallba;
56940
+
56898
56941
  _this.setEndpoint(endpoint);
56942
+
56943
+ (_this$selectionCallba = _this.selectionCallback) === null || _this$selectionCallba === void 0 ? void 0 : _this$selectionCallba.call(_this, endpoint, []);
56899
56944
  });
56900
56945
  _context.next = 4;
56901
56946
  return this.discoveryNodeSelector.getSelectedEndpoint();
@@ -59500,7 +59545,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59500
59545
  }
59501
59546
 
59502
59547
  _context59.next = 7;
59503
- return this._makeRequestInternalNext(requestObj, throwError);
59548
+ return this._makeRequestInternalNext(requestObj, throwError, blockNumber);
59504
59549
 
59505
59550
  case 7:
59506
59551
  return _context59.abrupt("return", _context59.sent);
@@ -59749,6 +59794,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59749
59794
  var _yield$this$discovery, _this$discoveryNodeMi, _this$discoveryNodeMi2, _yield$this$discovery3, _this$discoveryNodeMi5, _this$discoveryNodeMi6;
59750
59795
 
59751
59796
  var throwError,
59797
+ blockNumber,
59752
59798
  axiosRequest,
59753
59799
  data,
59754
59800
  _axiosRequest$url2,
@@ -59768,15 +59814,16 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59768
59814
  switch (_context61.prev = _context61.next) {
59769
59815
  case 0:
59770
59816
  throwError = _args61.length > 1 && _args61[1] !== undefined ? _args61[1] : false;
59817
+ blockNumber = _args61.length > 2 ? _args61[2] : undefined;
59771
59818
 
59772
59819
  if (!(!this.discoveryProviderEndpoint || !this.discoveryNodeMiddleware)) {
59773
- _context61.next = 3;
59820
+ _context61.next = 4;
59774
59821
  break;
59775
59822
  }
59776
59823
 
59777
59824
  return _context61.abrupt("return");
59778
59825
 
59779
- case 3:
59826
+ case 4:
59780
59827
  axiosRequest = this._createDiscProvRequest(requestObj, this.discoveryProviderEndpoint);
59781
59828
  data = axiosRequest.data, _axiosRequest$url2 = axiosRequest.url, url = _axiosRequest$url2 === void 0 ? '' : _axiosRequest$url2, restRequest = _objectWithoutProperties(axiosRequest, _excluded);
59782
59829
  fetchRequestInit = _objectSpread2({
@@ -59786,50 +59833,50 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59786
59833
  url: url,
59787
59834
  init: fetchRequestInit
59788
59835
  };
59789
- _context61.next = 9;
59836
+ _context61.next = 10;
59790
59837
  return (_this$discoveryNodeMi = (_this$discoveryNodeMi2 = this.discoveryNodeMiddleware).pre) === null || _this$discoveryNodeMi === void 0 ? void 0 : _this$discoveryNodeMi.call(_this$discoveryNodeMi2, _objectSpread2({
59791
59838
  fetch: fetch
59792
59839
  }, fetchParams));
59793
59840
 
59794
- case 9:
59841
+ case 10:
59795
59842
  _context61.t1 = _yield$this$discovery = _context61.sent;
59796
59843
  _context61.t0 = _context61.t1 !== null;
59797
59844
 
59798
59845
  if (!_context61.t0) {
59799
- _context61.next = 13;
59846
+ _context61.next = 14;
59800
59847
  break;
59801
59848
  }
59802
59849
 
59803
59850
  _context61.t0 = _yield$this$discovery !== void 0;
59804
59851
 
59805
- case 13:
59852
+ case 14:
59806
59853
  if (!_context61.t0) {
59807
- _context61.next = 17;
59854
+ _context61.next = 18;
59808
59855
  break;
59809
59856
  }
59810
59857
 
59811
59858
  _context61.t2 = _yield$this$discovery;
59812
- _context61.next = 18;
59859
+ _context61.next = 19;
59813
59860
  break;
59814
59861
 
59815
- case 17:
59862
+ case 18:
59816
59863
  _context61.t2 = fetchParams;
59817
59864
 
59818
- case 18:
59865
+ case 19:
59819
59866
  fetchParams = _context61.t2;
59820
- _context61.prev = 19;
59821
- _context61.next = 22;
59867
+ _context61.prev = 20;
59868
+ _context61.next = 23;
59822
59869
  return fetch(fetchParams.url, fetchParams.init);
59823
59870
 
59824
- case 22:
59871
+ case 23:
59825
59872
  response = _context61.sent;
59826
- _context61.next = 47;
59873
+ _context61.next = 48;
59827
59874
  break;
59828
59875
 
59829
- case 25:
59830
- _context61.prev = 25;
59831
- _context61.t3 = _context61["catch"](19);
59832
- _context61.next = 29;
59876
+ case 26:
59877
+ _context61.prev = 26;
59878
+ _context61.t3 = _context61["catch"](20);
59879
+ _context61.next = 30;
59833
59880
  return (_this$discoveryNodeMi3 = (_this$discoveryNodeMi4 = this.discoveryNodeMiddleware).onError) === null || _this$discoveryNodeMi3 === void 0 ? void 0 : _this$discoveryNodeMi3.call(_this$discoveryNodeMi4, _objectSpread2(_objectSpread2({
59834
59881
  fetch: fetch
59835
59882
  }, fetchParams), {}, {
@@ -59837,103 +59884,112 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59837
59884
  response: response ? response.clone() : undefined
59838
59885
  }));
59839
59886
 
59840
- case 29:
59887
+ case 30:
59841
59888
  _context61.t5 = _yield$this$discovery2 = _context61.sent;
59842
59889
  _context61.t4 = _context61.t5 !== null;
59843
59890
 
59844
59891
  if (!_context61.t4) {
59845
- _context61.next = 33;
59892
+ _context61.next = 34;
59846
59893
  break;
59847
59894
  }
59848
59895
 
59849
59896
  _context61.t4 = _yield$this$discovery2 !== void 0;
59850
59897
 
59851
- case 33:
59898
+ case 34:
59852
59899
  if (!_context61.t4) {
59853
- _context61.next = 37;
59900
+ _context61.next = 38;
59854
59901
  break;
59855
59902
  }
59856
59903
 
59857
59904
  _context61.t6 = _yield$this$discovery2;
59858
- _context61.next = 38;
59905
+ _context61.next = 39;
59859
59906
  break;
59860
59907
 
59861
- case 37:
59908
+ case 38:
59862
59909
  _context61.t6 = response;
59863
59910
 
59864
- case 38:
59911
+ case 39:
59865
59912
  response = _context61.t6;
59866
59913
 
59867
59914
  if (!(response === undefined)) {
59868
- _context61.next = 47;
59915
+ _context61.next = 48;
59869
59916
  break;
59870
59917
  }
59871
59918
 
59872
59919
  if (!throwError) {
59873
- _context61.next = 46;
59920
+ _context61.next = 47;
59874
59921
  break;
59875
59922
  }
59876
59923
 
59877
59924
  if (!(_context61.t3 instanceof Error)) {
59878
- _context61.next = 45;
59925
+ _context61.next = 46;
59879
59926
  break;
59880
59927
  }
59881
59928
 
59882
59929
  throw new FetchError$1(_context61.t3, 'The request failed and the interceptors did not return an alternative response');
59883
59930
 
59884
- case 45:
59931
+ case 46:
59885
59932
  throw _context61.t3;
59886
59933
 
59887
- case 46:
59934
+ case 47:
59888
59935
  return _context61.abrupt("return", null);
59889
59936
 
59890
- case 47:
59891
- _context61.next = 49;
59937
+ case 48:
59938
+ _context61.next = 50;
59892
59939
  return (_this$discoveryNodeMi5 = (_this$discoveryNodeMi6 = this.discoveryNodeMiddleware).post) === null || _this$discoveryNodeMi5 === void 0 ? void 0 : _this$discoveryNodeMi5.call(_this$discoveryNodeMi6, _objectSpread2(_objectSpread2({
59893
59940
  fetch: fetch
59894
59941
  }, fetchParams), {}, {
59895
59942
  response: response
59896
59943
  }));
59897
59944
 
59898
- case 49:
59945
+ case 50:
59899
59946
  _context61.t8 = _yield$this$discovery3 = _context61.sent;
59900
59947
  _context61.t7 = _context61.t8 !== null;
59901
59948
 
59902
59949
  if (!_context61.t7) {
59903
- _context61.next = 53;
59950
+ _context61.next = 54;
59904
59951
  break;
59905
59952
  }
59906
59953
 
59907
59954
  _context61.t7 = _yield$this$discovery3 !== void 0;
59908
59955
 
59909
- case 53:
59956
+ case 54:
59910
59957
  if (!_context61.t7) {
59911
- _context61.next = 57;
59958
+ _context61.next = 58;
59912
59959
  break;
59913
59960
  }
59914
59961
 
59915
59962
  _context61.t9 = _yield$this$discovery3;
59916
- _context61.next = 58;
59963
+ _context61.next = 59;
59917
59964
  break;
59918
59965
 
59919
- case 57:
59966
+ case 58:
59920
59967
  _context61.t9 = response;
59921
59968
 
59922
- case 58:
59969
+ case 59:
59923
59970
  response = _context61.t9;
59924
- _context61.next = 61;
59971
+ _context61.next = 62;
59925
59972
  return response.json();
59926
59973
 
59927
- case 61:
59974
+ case 62:
59928
59975
  responseBody = _context61.sent;
59976
+
59977
+ if (!(blockNumber && responseBody.latest_indexed_block < blockNumber)) {
59978
+ _context61.next = 65;
59979
+ break;
59980
+ }
59981
+
59982
+ throw new Error("Requested blocknumber ".concat(blockNumber, ", but discovery is behind at ").concat(responseBody.latest_indexed_block));
59983
+
59984
+ case 65:
59929
59985
  return _context61.abrupt("return", responseBody);
59930
59986
 
59931
- case 63:
59987
+ case 66:
59932
59988
  case "end":
59933
59989
  return _context61.stop();
59934
59990
  }
59935
59991
  }
59936
- }, _callee61, this, [[19, 25]]);
59992
+ }, _callee61, this, [[20, 26]]);
59937
59993
  }));
59938
59994
 
59939
59995
  function _makeRequestInternalNext(_x79) {