@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.
@@ -595,9 +595,9 @@ if (typeof window !== 'undefined' && window && window.Web3) {
595
595
  var LibsWeb3 = Web3;
596
596
 
597
597
  var name = "@audius/sdk";
598
- var version = "2.0.3-beta.4";
598
+ var version = "2.0.3-beta.5";
599
599
  var audius = {
600
- releaseSHA: "42c56a1bf4cc52d52da7df738ace6822a91b0fce"
600
+ releaseSHA: "29b38fb1a75d58b32ce4c98a46dc035540b43e1a"
601
601
  };
602
602
  var description = "";
603
603
  var main = "dist/index.cjs.js";
@@ -1665,9 +1665,13 @@ var fileHasher = {
1665
1665
 
1666
1666
  case 3:
1667
1667
  buffer = _context10.sent;
1668
- return _context10.abrupt("return", fileHasher.hashNonImages(buffer));
1668
+ _context10.next = 6;
1669
+ return fileHasher.hashNonImages(buffer);
1669
1670
 
1670
- case 5:
1671
+ case 6:
1672
+ return _context10.abrupt("return", _context10.sent);
1673
+
1674
+ case 7:
1671
1675
  case "end":
1672
1676
  return _context10.stop();
1673
1677
  }
@@ -1689,9 +1693,13 @@ var fileHasher = {
1689
1693
  while (1) {
1690
1694
  switch (_context11.prev = _context11.next) {
1691
1695
  case 0:
1692
- return _context11.abrupt("return", fileHasher.hashImages(content));
1696
+ _context11.next = 3;
1697
+ return fileHasher.hashImages(content);
1693
1698
 
1694
- case 2:
1699
+ case 3:
1700
+ return _context11.abrupt("return", _context11.sent);
1701
+
1702
+ case 4:
1695
1703
  case "end":
1696
1704
  return _context11.stop();
1697
1705
  }
@@ -4221,9 +4229,13 @@ var CreatorNode = /*#__PURE__*/function () {
4221
4229
  while (1) {
4222
4230
  switch (_context8.prev = _context8.next) {
4223
4231
  case 0:
4224
- return _context8.abrupt("return", _this2.uploadTrackAudioV2(trackFile, onProgress));
4232
+ _context8.next = 2;
4233
+ return _this2.uploadTrackAudioV2(trackFile, onProgress);
4225
4234
 
4226
- case 1:
4235
+ case 2:
4236
+ return _context8.abrupt("return", _context8.sent);
4237
+
4238
+ case 3:
4227
4239
  case "end":
4228
4240
  return _context8.stop();
4229
4241
  }
@@ -4236,9 +4248,13 @@ var CreatorNode = /*#__PURE__*/function () {
4236
4248
  while (1) {
4237
4249
  switch (_context9.prev = _context9.next) {
4238
4250
  case 0:
4239
- return _context9.abrupt("return", _this2.uploadTrackCoverArtV2(coverArtFile, onProgress));
4251
+ _context9.next = 2;
4252
+ return _this2.uploadTrackCoverArtV2(coverArtFile, onProgress);
4253
+
4254
+ case 2:
4255
+ return _context9.abrupt("return", _context9.sent);
4240
4256
 
4241
- case 1:
4257
+ case 3:
4242
4258
  case "end":
4243
4259
  return _context9.stop();
4244
4260
  }
@@ -4256,7 +4272,7 @@ var CreatorNode = /*#__PURE__*/function () {
4256
4272
  // Update metadata to include uploaded CIDs
4257
4273
  // 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
4258
4274
  updatedMetadata.track_segments = [];
4259
- updatedMetadata.track_cid = audioResp.results["320"];
4275
+ updatedMetadata.track_cid = audioResp.results['320'];
4260
4276
 
4261
4277
  if ((_updatedMetadata$down = updatedMetadata.download) !== null && _updatedMetadata$down !== void 0 && _updatedMetadata$down.is_downloadable) {
4262
4278
  updatedMetadata.download.cid = updatedMetadata.track_cid;
@@ -4287,9 +4303,13 @@ var CreatorNode = /*#__PURE__*/function () {
4287
4303
  while (1) {
4288
4304
  switch (_context11.prev = _context11.next) {
4289
4305
  case 0:
4290
- return _context11.abrupt("return", this.uploadFileV2(file, onProgress, 'audio'));
4306
+ _context11.next = 2;
4307
+ return this.uploadFileV2(file, onProgress, 'audio');
4291
4308
 
4292
- case 1:
4309
+ case 2:
4310
+ return _context11.abrupt("return", _context11.sent);
4311
+
4312
+ case 3:
4293
4313
  case "end":
4294
4314
  return _context11.stop();
4295
4315
  }
@@ -4311,9 +4331,13 @@ var CreatorNode = /*#__PURE__*/function () {
4311
4331
  while (1) {
4312
4332
  switch (_context12.prev = _context12.next) {
4313
4333
  case 0:
4314
- return _context12.abrupt("return", this.uploadFileV2(file, onProgress, 'img_square'));
4334
+ _context12.next = 2;
4335
+ return this.uploadFileV2(file, onProgress, 'img_square');
4315
4336
 
4316
- case 1:
4337
+ case 2:
4338
+ return _context12.abrupt("return", _context12.sent);
4339
+
4340
+ case 3:
4317
4341
  case "end":
4318
4342
  return _context12.stop();
4319
4343
  }
@@ -4354,9 +4378,13 @@ var CreatorNode = /*#__PURE__*/function () {
4354
4378
 
4355
4379
  case 5:
4356
4380
  response = _context13.sent;
4357
- return _context13.abrupt("return", this.pollProcessingStatusV2(response.data[0].id, template === 'audio' ? MAX_TRACK_TRANSCODE_TIMEOUT : MAX_IMAGE_RESIZE_TIMEOUT_MS));
4381
+ _context13.next = 8;
4382
+ return this.pollProcessingStatusV2(response.data[0].id, template === 'audio' ? MAX_TRACK_TRANSCODE_TIMEOUT : MAX_IMAGE_RESIZE_TIMEOUT_MS);
4358
4383
 
4359
- case 7:
4384
+ case 8:
4385
+ return _context13.abrupt("return", _context13.sent);
4386
+
4387
+ case 9:
4360
4388
  case "end":
4361
4389
  return _context13.stop();
4362
4390
  }
@@ -5087,9 +5115,9 @@ var CreatorNode = /*#__PURE__*/function () {
5087
5115
  /* ------- INTERNAL FUNCTIONS ------- */
5088
5116
 
5089
5117
  /**
5090
- * Makes an axios request to the connected creator node
5091
- * @return response body
5092
- */
5118
+ * Makes an axios request to the connected creator node
5119
+ * @return response body
5120
+ */
5093
5121
 
5094
5122
  }, {
5095
5123
  key: "_makeRequestV2",
@@ -5102,9 +5130,13 @@ var CreatorNode = /*#__PURE__*/function () {
5102
5130
  // TODO: This might want to have other error handling, request UUIDs, etc...
5103
5131
  // But I didn't want to pull in all the chaos and incompatiblity of the old _makeRequest
5104
5132
  axiosRequestObj.baseURL = this.creatorNodeEndpoint;
5105
- return _context27.abrupt("return", axios(axiosRequestObj));
5133
+ _context27.next = 3;
5134
+ return axios(axiosRequestObj);
5106
5135
 
5107
- case 2:
5136
+ case 3:
5137
+ return _context27.abrupt("return", _context27.sent);
5138
+
5139
+ case 4:
5108
5140
  case "end":
5109
5141
  return _context27.stop();
5110
5142
  }
@@ -5924,15 +5956,19 @@ var CreatorNode = /*#__PURE__*/function () {
5924
5956
  switch (_context39.prev = _context39.next) {
5925
5957
  case 0:
5926
5958
  onRetry = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : function (_err) {};
5927
- return _context39.abrupt("return", retry(fn, {
5959
+ _context39.next = 3;
5960
+ return retry(fn, {
5928
5961
  minTimeout: 500,
5929
5962
  maxTimeout: 4000,
5930
5963
  factor: 3,
5931
5964
  retries: 3,
5932
5965
  onRetry: onRetry
5933
- }));
5966
+ });
5934
5967
 
5935
- case 2:
5968
+ case 3:
5969
+ return _context39.abrupt("return", _context39.sent);
5970
+
5971
+ case 4:
5936
5972
  case "end":
5937
5973
  return _context39.stop();
5938
5974
  }
@@ -11823,6 +11859,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
11823
11859
  this.userStateManager = userStateManager;
11824
11860
  this.ethContracts = ethContracts;
11825
11861
  this.web3Manager = web3Manager;
11862
+ this.selectionCallback = selectionCallback;
11826
11863
  this.unhealthyBlockDiff = unhealthyBlockDiff !== null && unhealthyBlockDiff !== void 0 ? unhealthyBlockDiff : DEFAULT_UNHEALTHY_BLOCK_DIFF;
11827
11864
  this.serviceSelector = new DiscoveryProviderSelection({
11828
11865
  whitelist: this.whitelist,
@@ -11867,7 +11904,11 @@ var DiscoveryProvider = /*#__PURE__*/function () {
11867
11904
  }
11868
11905
 
11869
11906
  this.discoveryNodeSelector.addEventListener('change', function (endpoint) {
11907
+ var _this$selectionCallba;
11908
+
11870
11909
  _this.setEndpoint(endpoint);
11910
+
11911
+ (_this$selectionCallba = _this.selectionCallback) === null || _this$selectionCallba === void 0 ? void 0 : _this$selectionCallba.call(_this, endpoint, []);
11871
11912
  });
11872
11913
  _context.next = 4;
11873
11914
  return this.discoveryNodeSelector.getSelectedEndpoint();
@@ -14472,7 +14513,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
14472
14513
  }
14473
14514
 
14474
14515
  _context59.next = 7;
14475
- return this._makeRequestInternalNext(requestObj, throwError);
14516
+ return this._makeRequestInternalNext(requestObj, throwError, blockNumber);
14476
14517
 
14477
14518
  case 7:
14478
14519
  return _context59.abrupt("return", _context59.sent);
@@ -14721,6 +14762,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
14721
14762
  var _yield$this$discovery, _this$discoveryNodeMi, _this$discoveryNodeMi2, _yield$this$discovery3, _this$discoveryNodeMi5, _this$discoveryNodeMi6;
14722
14763
 
14723
14764
  var throwError,
14765
+ blockNumber,
14724
14766
  axiosRequest,
14725
14767
  data,
14726
14768
  _axiosRequest$url2,
@@ -14740,15 +14782,16 @@ var DiscoveryProvider = /*#__PURE__*/function () {
14740
14782
  switch (_context61.prev = _context61.next) {
14741
14783
  case 0:
14742
14784
  throwError = _args61.length > 1 && _args61[1] !== undefined ? _args61[1] : false;
14785
+ blockNumber = _args61.length > 2 ? _args61[2] : undefined;
14743
14786
 
14744
14787
  if (!(!this.discoveryProviderEndpoint || !this.discoveryNodeMiddleware)) {
14745
- _context61.next = 3;
14788
+ _context61.next = 4;
14746
14789
  break;
14747
14790
  }
14748
14791
 
14749
14792
  return _context61.abrupt("return");
14750
14793
 
14751
- case 3:
14794
+ case 4:
14752
14795
  axiosRequest = this._createDiscProvRequest(requestObj, this.discoveryProviderEndpoint);
14753
14796
  data = axiosRequest.data, _axiosRequest$url2 = axiosRequest.url, url = _axiosRequest$url2 === void 0 ? '' : _axiosRequest$url2, restRequest = _objectWithoutProperties(axiosRequest, _excluded);
14754
14797
  fetchRequestInit = _objectSpread2({
@@ -14758,50 +14801,50 @@ var DiscoveryProvider = /*#__PURE__*/function () {
14758
14801
  url: url,
14759
14802
  init: fetchRequestInit
14760
14803
  };
14761
- _context61.next = 9;
14804
+ _context61.next = 10;
14762
14805
  return (_this$discoveryNodeMi = (_this$discoveryNodeMi2 = this.discoveryNodeMiddleware).pre) === null || _this$discoveryNodeMi === void 0 ? void 0 : _this$discoveryNodeMi.call(_this$discoveryNodeMi2, _objectSpread2({
14763
14806
  fetch: fetch
14764
14807
  }, fetchParams));
14765
14808
 
14766
- case 9:
14809
+ case 10:
14767
14810
  _context61.t1 = _yield$this$discovery = _context61.sent;
14768
14811
  _context61.t0 = _context61.t1 !== null;
14769
14812
 
14770
14813
  if (!_context61.t0) {
14771
- _context61.next = 13;
14814
+ _context61.next = 14;
14772
14815
  break;
14773
14816
  }
14774
14817
 
14775
14818
  _context61.t0 = _yield$this$discovery !== void 0;
14776
14819
 
14777
- case 13:
14820
+ case 14:
14778
14821
  if (!_context61.t0) {
14779
- _context61.next = 17;
14822
+ _context61.next = 18;
14780
14823
  break;
14781
14824
  }
14782
14825
 
14783
14826
  _context61.t2 = _yield$this$discovery;
14784
- _context61.next = 18;
14827
+ _context61.next = 19;
14785
14828
  break;
14786
14829
 
14787
- case 17:
14830
+ case 18:
14788
14831
  _context61.t2 = fetchParams;
14789
14832
 
14790
- case 18:
14833
+ case 19:
14791
14834
  fetchParams = _context61.t2;
14792
- _context61.prev = 19;
14793
- _context61.next = 22;
14835
+ _context61.prev = 20;
14836
+ _context61.next = 23;
14794
14837
  return fetch(fetchParams.url, fetchParams.init);
14795
14838
 
14796
- case 22:
14839
+ case 23:
14797
14840
  response = _context61.sent;
14798
- _context61.next = 47;
14841
+ _context61.next = 48;
14799
14842
  break;
14800
14843
 
14801
- case 25:
14802
- _context61.prev = 25;
14803
- _context61.t3 = _context61["catch"](19);
14804
- _context61.next = 29;
14844
+ case 26:
14845
+ _context61.prev = 26;
14846
+ _context61.t3 = _context61["catch"](20);
14847
+ _context61.next = 30;
14805
14848
  return (_this$discoveryNodeMi3 = (_this$discoveryNodeMi4 = this.discoveryNodeMiddleware).onError) === null || _this$discoveryNodeMi3 === void 0 ? void 0 : _this$discoveryNodeMi3.call(_this$discoveryNodeMi4, _objectSpread2(_objectSpread2({
14806
14849
  fetch: fetch
14807
14850
  }, fetchParams), {}, {
@@ -14809,103 +14852,112 @@ var DiscoveryProvider = /*#__PURE__*/function () {
14809
14852
  response: response ? response.clone() : undefined
14810
14853
  }));
14811
14854
 
14812
- case 29:
14855
+ case 30:
14813
14856
  _context61.t5 = _yield$this$discovery2 = _context61.sent;
14814
14857
  _context61.t4 = _context61.t5 !== null;
14815
14858
 
14816
14859
  if (!_context61.t4) {
14817
- _context61.next = 33;
14860
+ _context61.next = 34;
14818
14861
  break;
14819
14862
  }
14820
14863
 
14821
14864
  _context61.t4 = _yield$this$discovery2 !== void 0;
14822
14865
 
14823
- case 33:
14866
+ case 34:
14824
14867
  if (!_context61.t4) {
14825
- _context61.next = 37;
14868
+ _context61.next = 38;
14826
14869
  break;
14827
14870
  }
14828
14871
 
14829
14872
  _context61.t6 = _yield$this$discovery2;
14830
- _context61.next = 38;
14873
+ _context61.next = 39;
14831
14874
  break;
14832
14875
 
14833
- case 37:
14876
+ case 38:
14834
14877
  _context61.t6 = response;
14835
14878
 
14836
- case 38:
14879
+ case 39:
14837
14880
  response = _context61.t6;
14838
14881
 
14839
14882
  if (!(response === undefined)) {
14840
- _context61.next = 47;
14883
+ _context61.next = 48;
14841
14884
  break;
14842
14885
  }
14843
14886
 
14844
14887
  if (!throwError) {
14845
- _context61.next = 46;
14888
+ _context61.next = 47;
14846
14889
  break;
14847
14890
  }
14848
14891
 
14849
14892
  if (!(_context61.t3 instanceof Error)) {
14850
- _context61.next = 45;
14893
+ _context61.next = 46;
14851
14894
  break;
14852
14895
  }
14853
14896
 
14854
14897
  throw new FetchError(_context61.t3, 'The request failed and the interceptors did not return an alternative response');
14855
14898
 
14856
- case 45:
14899
+ case 46:
14857
14900
  throw _context61.t3;
14858
14901
 
14859
- case 46:
14902
+ case 47:
14860
14903
  return _context61.abrupt("return", null);
14861
14904
 
14862
- case 47:
14863
- _context61.next = 49;
14905
+ case 48:
14906
+ _context61.next = 50;
14864
14907
  return (_this$discoveryNodeMi5 = (_this$discoveryNodeMi6 = this.discoveryNodeMiddleware).post) === null || _this$discoveryNodeMi5 === void 0 ? void 0 : _this$discoveryNodeMi5.call(_this$discoveryNodeMi6, _objectSpread2(_objectSpread2({
14865
14908
  fetch: fetch
14866
14909
  }, fetchParams), {}, {
14867
14910
  response: response
14868
14911
  }));
14869
14912
 
14870
- case 49:
14913
+ case 50:
14871
14914
  _context61.t8 = _yield$this$discovery3 = _context61.sent;
14872
14915
  _context61.t7 = _context61.t8 !== null;
14873
14916
 
14874
14917
  if (!_context61.t7) {
14875
- _context61.next = 53;
14918
+ _context61.next = 54;
14876
14919
  break;
14877
14920
  }
14878
14921
 
14879
14922
  _context61.t7 = _yield$this$discovery3 !== void 0;
14880
14923
 
14881
- case 53:
14924
+ case 54:
14882
14925
  if (!_context61.t7) {
14883
- _context61.next = 57;
14926
+ _context61.next = 58;
14884
14927
  break;
14885
14928
  }
14886
14929
 
14887
14930
  _context61.t9 = _yield$this$discovery3;
14888
- _context61.next = 58;
14931
+ _context61.next = 59;
14889
14932
  break;
14890
14933
 
14891
- case 57:
14934
+ case 58:
14892
14935
  _context61.t9 = response;
14893
14936
 
14894
- case 58:
14937
+ case 59:
14895
14938
  response = _context61.t9;
14896
- _context61.next = 61;
14939
+ _context61.next = 62;
14897
14940
  return response.json();
14898
14941
 
14899
- case 61:
14942
+ case 62:
14900
14943
  responseBody = _context61.sent;
14944
+
14945
+ if (!(blockNumber && responseBody.latest_indexed_block < blockNumber)) {
14946
+ _context61.next = 65;
14947
+ break;
14948
+ }
14949
+
14950
+ throw new Error("Requested blocknumber ".concat(blockNumber, ", but discovery is behind at ").concat(responseBody.latest_indexed_block));
14951
+
14952
+ case 65:
14901
14953
  return _context61.abrupt("return", responseBody);
14902
14954
 
14903
- case 63:
14955
+ case 66:
14904
14956
  case "end":
14905
14957
  return _context61.stop();
14906
14958
  }
14907
14959
  }
14908
- }, _callee61, this, [[19, 25]]);
14960
+ }, _callee61, this, [[20, 26]]);
14909
14961
  }));
14910
14962
 
14911
14963
  function _makeRequestInternalNext(_x79) {
@@ -38930,9 +38982,13 @@ var AudiusContracts = /*#__PURE__*/function () {
38930
38982
  while (1) {
38931
38983
  switch (_context.prev = _context.next) {
38932
38984
  case 0:
38933
- return _context.abrupt("return", Promise.resolve(''));
38985
+ _context.next = 2;
38986
+ return Promise.resolve('');
38934
38987
 
38935
- case 1:
38988
+ case 2:
38989
+ return _context.abrupt("return", _context.sent);
38990
+
38991
+ case 3:
38936
38992
  case "end":
38937
38993
  return _context.stop();
38938
38994
  }