@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/index.esm.js CHANGED
@@ -25342,9 +25342,13 @@ var fileHasher = {
25342
25342
 
25343
25343
  case 3:
25344
25344
  buffer = _context10.sent;
25345
- return _context10.abrupt("return", fileHasher.hashNonImages(buffer));
25345
+ _context10.next = 6;
25346
+ return fileHasher.hashNonImages(buffer);
25346
25347
 
25347
- case 5:
25348
+ case 6:
25349
+ return _context10.abrupt("return", _context10.sent);
25350
+
25351
+ case 7:
25348
25352
  case "end":
25349
25353
  return _context10.stop();
25350
25354
  }
@@ -25366,9 +25370,13 @@ var fileHasher = {
25366
25370
  while (1) {
25367
25371
  switch (_context11.prev = _context11.next) {
25368
25372
  case 0:
25369
- return _context11.abrupt("return", fileHasher.hashImages(content));
25373
+ _context11.next = 3;
25374
+ return fileHasher.hashImages(content);
25370
25375
 
25371
- case 2:
25376
+ case 3:
25377
+ return _context11.abrupt("return", _context11.sent);
25378
+
25379
+ case 4:
25372
25380
  case "end":
25373
25381
  return _context11.stop();
25374
25382
  }
@@ -26857,9 +26865,9 @@ var EthWeb3Manager = /*#__PURE__*/function () {
26857
26865
  }();
26858
26866
 
26859
26867
  var name = "@audius/sdk";
26860
- var version = "2.0.3-beta.4";
26868
+ var version = "2.0.3-beta.5";
26861
26869
  var audius = {
26862
- releaseSHA: "42c56a1bf4cc52d52da7df738ace6822a91b0fce"
26870
+ releaseSHA: "29b38fb1a75d58b32ce4c98a46dc035540b43e1a"
26863
26871
  };
26864
26872
  var description = "";
26865
26873
  var main = "dist/index.cjs.js";
@@ -49514,9 +49522,13 @@ var AudiusContracts = /*#__PURE__*/function () {
49514
49522
  while (1) {
49515
49523
  switch (_context.prev = _context.next) {
49516
49524
  case 0:
49517
- return _context.abrupt("return", Promise.resolve(''));
49525
+ _context.next = 2;
49526
+ return Promise.resolve('');
49518
49527
 
49519
- case 1:
49528
+ case 2:
49529
+ return _context.abrupt("return", _context.sent);
49530
+
49531
+ case 3:
49520
49532
  case "end":
49521
49533
  return _context.stop();
49522
49534
  }
@@ -52809,9 +52821,13 @@ var CreatorNode = /*#__PURE__*/function () {
52809
52821
  while (1) {
52810
52822
  switch (_context8.prev = _context8.next) {
52811
52823
  case 0:
52812
- return _context8.abrupt("return", _this2.uploadTrackAudioV2(trackFile, onProgress));
52824
+ _context8.next = 2;
52825
+ return _this2.uploadTrackAudioV2(trackFile, onProgress);
52813
52826
 
52814
- case 1:
52827
+ case 2:
52828
+ return _context8.abrupt("return", _context8.sent);
52829
+
52830
+ case 3:
52815
52831
  case "end":
52816
52832
  return _context8.stop();
52817
52833
  }
@@ -52824,9 +52840,13 @@ var CreatorNode = /*#__PURE__*/function () {
52824
52840
  while (1) {
52825
52841
  switch (_context9.prev = _context9.next) {
52826
52842
  case 0:
52827
- return _context9.abrupt("return", _this2.uploadTrackCoverArtV2(coverArtFile, onProgress));
52843
+ _context9.next = 2;
52844
+ return _this2.uploadTrackCoverArtV2(coverArtFile, onProgress);
52828
52845
 
52829
- case 1:
52846
+ case 2:
52847
+ return _context9.abrupt("return", _context9.sent);
52848
+
52849
+ case 3:
52830
52850
  case "end":
52831
52851
  return _context9.stop();
52832
52852
  }
@@ -52844,7 +52864,7 @@ var CreatorNode = /*#__PURE__*/function () {
52844
52864
  // Update metadata to include uploaded CIDs
52845
52865
  // 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
52846
52866
  updatedMetadata.track_segments = [];
52847
- updatedMetadata.track_cid = audioResp.results["320"];
52867
+ updatedMetadata.track_cid = audioResp.results['320'];
52848
52868
 
52849
52869
  if ((_updatedMetadata$down = updatedMetadata.download) !== null && _updatedMetadata$down !== void 0 && _updatedMetadata$down.is_downloadable) {
52850
52870
  updatedMetadata.download.cid = updatedMetadata.track_cid;
@@ -52875,9 +52895,13 @@ var CreatorNode = /*#__PURE__*/function () {
52875
52895
  while (1) {
52876
52896
  switch (_context11.prev = _context11.next) {
52877
52897
  case 0:
52878
- return _context11.abrupt("return", this.uploadFileV2(file, onProgress, 'audio'));
52898
+ _context11.next = 2;
52899
+ return this.uploadFileV2(file, onProgress, 'audio');
52879
52900
 
52880
- case 1:
52901
+ case 2:
52902
+ return _context11.abrupt("return", _context11.sent);
52903
+
52904
+ case 3:
52881
52905
  case "end":
52882
52906
  return _context11.stop();
52883
52907
  }
@@ -52899,9 +52923,13 @@ var CreatorNode = /*#__PURE__*/function () {
52899
52923
  while (1) {
52900
52924
  switch (_context12.prev = _context12.next) {
52901
52925
  case 0:
52902
- return _context12.abrupt("return", this.uploadFileV2(file, onProgress, 'img_square'));
52926
+ _context12.next = 2;
52927
+ return this.uploadFileV2(file, onProgress, 'img_square');
52903
52928
 
52904
- case 1:
52929
+ case 2:
52930
+ return _context12.abrupt("return", _context12.sent);
52931
+
52932
+ case 3:
52905
52933
  case "end":
52906
52934
  return _context12.stop();
52907
52935
  }
@@ -52942,9 +52970,13 @@ var CreatorNode = /*#__PURE__*/function () {
52942
52970
 
52943
52971
  case 5:
52944
52972
  response = _context13.sent;
52945
- return _context13.abrupt("return", this.pollProcessingStatusV2(response.data[0].id, template === 'audio' ? MAX_TRACK_TRANSCODE_TIMEOUT : MAX_IMAGE_RESIZE_TIMEOUT_MS));
52973
+ _context13.next = 8;
52974
+ return this.pollProcessingStatusV2(response.data[0].id, template === 'audio' ? MAX_TRACK_TRANSCODE_TIMEOUT : MAX_IMAGE_RESIZE_TIMEOUT_MS);
52946
52975
 
52947
- case 7:
52976
+ case 8:
52977
+ return _context13.abrupt("return", _context13.sent);
52978
+
52979
+ case 9:
52948
52980
  case "end":
52949
52981
  return _context13.stop();
52950
52982
  }
@@ -53675,9 +53707,9 @@ var CreatorNode = /*#__PURE__*/function () {
53675
53707
  /* ------- INTERNAL FUNCTIONS ------- */
53676
53708
 
53677
53709
  /**
53678
- * Makes an axios request to the connected creator node
53679
- * @return response body
53680
- */
53710
+ * Makes an axios request to the connected creator node
53711
+ * @return response body
53712
+ */
53681
53713
 
53682
53714
  }, {
53683
53715
  key: "_makeRequestV2",
@@ -53690,9 +53722,13 @@ var CreatorNode = /*#__PURE__*/function () {
53690
53722
  // TODO: This might want to have other error handling, request UUIDs, etc...
53691
53723
  // But I didn't want to pull in all the chaos and incompatiblity of the old _makeRequest
53692
53724
  axiosRequestObj.baseURL = this.creatorNodeEndpoint;
53693
- return _context27.abrupt("return", axios(axiosRequestObj));
53725
+ _context27.next = 3;
53726
+ return axios(axiosRequestObj);
53694
53727
 
53695
- case 2:
53728
+ case 3:
53729
+ return _context27.abrupt("return", _context27.sent);
53730
+
53731
+ case 4:
53696
53732
  case "end":
53697
53733
  return _context27.stop();
53698
53734
  }
@@ -54512,15 +54548,19 @@ var CreatorNode = /*#__PURE__*/function () {
54512
54548
  switch (_context39.prev = _context39.next) {
54513
54549
  case 0:
54514
54550
  onRetry = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : function (_err) {};
54515
- return _context39.abrupt("return", retry(fn, {
54551
+ _context39.next = 3;
54552
+ return retry(fn, {
54516
54553
  minTimeout: 500,
54517
54554
  maxTimeout: 4000,
54518
54555
  factor: 3,
54519
54556
  retries: 3,
54520
54557
  onRetry: onRetry
54521
- }));
54558
+ });
54522
54559
 
54523
- case 2:
54560
+ case 3:
54561
+ return _context39.abrupt("return", _context39.sent);
54562
+
54563
+ case 4:
54524
54564
  case "end":
54525
54565
  return _context39.stop();
54526
54566
  }
@@ -56802,6 +56842,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
56802
56842
  this.userStateManager = userStateManager;
56803
56843
  this.ethContracts = ethContracts;
56804
56844
  this.web3Manager = web3Manager;
56845
+ this.selectionCallback = selectionCallback;
56805
56846
  this.unhealthyBlockDiff = unhealthyBlockDiff !== null && unhealthyBlockDiff !== void 0 ? unhealthyBlockDiff : DEFAULT_UNHEALTHY_BLOCK_DIFF;
56806
56847
  this.serviceSelector = new DiscoveryProviderSelection({
56807
56848
  whitelist: this.whitelist,
@@ -56846,7 +56887,11 @@ var DiscoveryProvider = /*#__PURE__*/function () {
56846
56887
  }
56847
56888
 
56848
56889
  this.discoveryNodeSelector.addEventListener('change', function (endpoint) {
56890
+ var _this$selectionCallba;
56891
+
56849
56892
  _this.setEndpoint(endpoint);
56893
+
56894
+ (_this$selectionCallba = _this.selectionCallback) === null || _this$selectionCallba === void 0 ? void 0 : _this$selectionCallba.call(_this, endpoint, []);
56850
56895
  });
56851
56896
  _context.next = 4;
56852
56897
  return this.discoveryNodeSelector.getSelectedEndpoint();
@@ -59451,7 +59496,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59451
59496
  }
59452
59497
 
59453
59498
  _context59.next = 7;
59454
- return this._makeRequestInternalNext(requestObj, throwError);
59499
+ return this._makeRequestInternalNext(requestObj, throwError, blockNumber);
59455
59500
 
59456
59501
  case 7:
59457
59502
  return _context59.abrupt("return", _context59.sent);
@@ -59700,6 +59745,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59700
59745
  var _yield$this$discovery, _this$discoveryNodeMi, _this$discoveryNodeMi2, _yield$this$discovery3, _this$discoveryNodeMi5, _this$discoveryNodeMi6;
59701
59746
 
59702
59747
  var throwError,
59748
+ blockNumber,
59703
59749
  axiosRequest,
59704
59750
  data,
59705
59751
  _axiosRequest$url2,
@@ -59719,15 +59765,16 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59719
59765
  switch (_context61.prev = _context61.next) {
59720
59766
  case 0:
59721
59767
  throwError = _args61.length > 1 && _args61[1] !== undefined ? _args61[1] : false;
59768
+ blockNumber = _args61.length > 2 ? _args61[2] : undefined;
59722
59769
 
59723
59770
  if (!(!this.discoveryProviderEndpoint || !this.discoveryNodeMiddleware)) {
59724
- _context61.next = 3;
59771
+ _context61.next = 4;
59725
59772
  break;
59726
59773
  }
59727
59774
 
59728
59775
  return _context61.abrupt("return");
59729
59776
 
59730
- case 3:
59777
+ case 4:
59731
59778
  axiosRequest = this._createDiscProvRequest(requestObj, this.discoveryProviderEndpoint);
59732
59779
  data = axiosRequest.data, _axiosRequest$url2 = axiosRequest.url, url = _axiosRequest$url2 === void 0 ? '' : _axiosRequest$url2, restRequest = _objectWithoutProperties(axiosRequest, _excluded);
59733
59780
  fetchRequestInit = _objectSpread2({
@@ -59737,50 +59784,50 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59737
59784
  url: url,
59738
59785
  init: fetchRequestInit
59739
59786
  };
59740
- _context61.next = 9;
59787
+ _context61.next = 10;
59741
59788
  return (_this$discoveryNodeMi = (_this$discoveryNodeMi2 = this.discoveryNodeMiddleware).pre) === null || _this$discoveryNodeMi === void 0 ? void 0 : _this$discoveryNodeMi.call(_this$discoveryNodeMi2, _objectSpread2({
59742
59789
  fetch: fetch
59743
59790
  }, fetchParams));
59744
59791
 
59745
- case 9:
59792
+ case 10:
59746
59793
  _context61.t1 = _yield$this$discovery = _context61.sent;
59747
59794
  _context61.t0 = _context61.t1 !== null;
59748
59795
 
59749
59796
  if (!_context61.t0) {
59750
- _context61.next = 13;
59797
+ _context61.next = 14;
59751
59798
  break;
59752
59799
  }
59753
59800
 
59754
59801
  _context61.t0 = _yield$this$discovery !== void 0;
59755
59802
 
59756
- case 13:
59803
+ case 14:
59757
59804
  if (!_context61.t0) {
59758
- _context61.next = 17;
59805
+ _context61.next = 18;
59759
59806
  break;
59760
59807
  }
59761
59808
 
59762
59809
  _context61.t2 = _yield$this$discovery;
59763
- _context61.next = 18;
59810
+ _context61.next = 19;
59764
59811
  break;
59765
59812
 
59766
- case 17:
59813
+ case 18:
59767
59814
  _context61.t2 = fetchParams;
59768
59815
 
59769
- case 18:
59816
+ case 19:
59770
59817
  fetchParams = _context61.t2;
59771
- _context61.prev = 19;
59772
- _context61.next = 22;
59818
+ _context61.prev = 20;
59819
+ _context61.next = 23;
59773
59820
  return fetch(fetchParams.url, fetchParams.init);
59774
59821
 
59775
- case 22:
59822
+ case 23:
59776
59823
  response = _context61.sent;
59777
- _context61.next = 47;
59824
+ _context61.next = 48;
59778
59825
  break;
59779
59826
 
59780
- case 25:
59781
- _context61.prev = 25;
59782
- _context61.t3 = _context61["catch"](19);
59783
- _context61.next = 29;
59827
+ case 26:
59828
+ _context61.prev = 26;
59829
+ _context61.t3 = _context61["catch"](20);
59830
+ _context61.next = 30;
59784
59831
  return (_this$discoveryNodeMi3 = (_this$discoveryNodeMi4 = this.discoveryNodeMiddleware).onError) === null || _this$discoveryNodeMi3 === void 0 ? void 0 : _this$discoveryNodeMi3.call(_this$discoveryNodeMi4, _objectSpread2(_objectSpread2({
59785
59832
  fetch: fetch
59786
59833
  }, fetchParams), {}, {
@@ -59788,103 +59835,112 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59788
59835
  response: response ? response.clone() : undefined
59789
59836
  }));
59790
59837
 
59791
- case 29:
59838
+ case 30:
59792
59839
  _context61.t5 = _yield$this$discovery2 = _context61.sent;
59793
59840
  _context61.t4 = _context61.t5 !== null;
59794
59841
 
59795
59842
  if (!_context61.t4) {
59796
- _context61.next = 33;
59843
+ _context61.next = 34;
59797
59844
  break;
59798
59845
  }
59799
59846
 
59800
59847
  _context61.t4 = _yield$this$discovery2 !== void 0;
59801
59848
 
59802
- case 33:
59849
+ case 34:
59803
59850
  if (!_context61.t4) {
59804
- _context61.next = 37;
59851
+ _context61.next = 38;
59805
59852
  break;
59806
59853
  }
59807
59854
 
59808
59855
  _context61.t6 = _yield$this$discovery2;
59809
- _context61.next = 38;
59856
+ _context61.next = 39;
59810
59857
  break;
59811
59858
 
59812
- case 37:
59859
+ case 38:
59813
59860
  _context61.t6 = response;
59814
59861
 
59815
- case 38:
59862
+ case 39:
59816
59863
  response = _context61.t6;
59817
59864
 
59818
59865
  if (!(response === undefined)) {
59819
- _context61.next = 47;
59866
+ _context61.next = 48;
59820
59867
  break;
59821
59868
  }
59822
59869
 
59823
59870
  if (!throwError) {
59824
- _context61.next = 46;
59871
+ _context61.next = 47;
59825
59872
  break;
59826
59873
  }
59827
59874
 
59828
59875
  if (!(_context61.t3 instanceof Error)) {
59829
- _context61.next = 45;
59876
+ _context61.next = 46;
59830
59877
  break;
59831
59878
  }
59832
59879
 
59833
59880
  throw new FetchError$1(_context61.t3, 'The request failed and the interceptors did not return an alternative response');
59834
59881
 
59835
- case 45:
59882
+ case 46:
59836
59883
  throw _context61.t3;
59837
59884
 
59838
- case 46:
59885
+ case 47:
59839
59886
  return _context61.abrupt("return", null);
59840
59887
 
59841
- case 47:
59842
- _context61.next = 49;
59888
+ case 48:
59889
+ _context61.next = 50;
59843
59890
  return (_this$discoveryNodeMi5 = (_this$discoveryNodeMi6 = this.discoveryNodeMiddleware).post) === null || _this$discoveryNodeMi5 === void 0 ? void 0 : _this$discoveryNodeMi5.call(_this$discoveryNodeMi6, _objectSpread2(_objectSpread2({
59844
59891
  fetch: fetch
59845
59892
  }, fetchParams), {}, {
59846
59893
  response: response
59847
59894
  }));
59848
59895
 
59849
- case 49:
59896
+ case 50:
59850
59897
  _context61.t8 = _yield$this$discovery3 = _context61.sent;
59851
59898
  _context61.t7 = _context61.t8 !== null;
59852
59899
 
59853
59900
  if (!_context61.t7) {
59854
- _context61.next = 53;
59901
+ _context61.next = 54;
59855
59902
  break;
59856
59903
  }
59857
59904
 
59858
59905
  _context61.t7 = _yield$this$discovery3 !== void 0;
59859
59906
 
59860
- case 53:
59907
+ case 54:
59861
59908
  if (!_context61.t7) {
59862
- _context61.next = 57;
59909
+ _context61.next = 58;
59863
59910
  break;
59864
59911
  }
59865
59912
 
59866
59913
  _context61.t9 = _yield$this$discovery3;
59867
- _context61.next = 58;
59914
+ _context61.next = 59;
59868
59915
  break;
59869
59916
 
59870
- case 57:
59917
+ case 58:
59871
59918
  _context61.t9 = response;
59872
59919
 
59873
- case 58:
59920
+ case 59:
59874
59921
  response = _context61.t9;
59875
- _context61.next = 61;
59922
+ _context61.next = 62;
59876
59923
  return response.json();
59877
59924
 
59878
- case 61:
59925
+ case 62:
59879
59926
  responseBody = _context61.sent;
59927
+
59928
+ if (!(blockNumber && responseBody.latest_indexed_block < blockNumber)) {
59929
+ _context61.next = 65;
59930
+ break;
59931
+ }
59932
+
59933
+ throw new Error("Requested blocknumber ".concat(blockNumber, ", but discovery is behind at ").concat(responseBody.latest_indexed_block));
59934
+
59935
+ case 65:
59880
59936
  return _context61.abrupt("return", responseBody);
59881
59937
 
59882
- case 63:
59938
+ case 66:
59883
59939
  case "end":
59884
59940
  return _context61.stop();
59885
59941
  }
59886
59942
  }
59887
- }, _callee61, this, [[19, 25]]);
59943
+ }, _callee61, this, [[20, 26]]);
59888
59944
  }));
59889
59945
 
59890
59946
  function _makeRequestInternalNext(_x79) {