@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.cjs.js CHANGED
@@ -25584,9 +25584,13 @@ var fileHasher = {
25584
25584
 
25585
25585
  case 3:
25586
25586
  buffer = _context10.sent;
25587
- return _context10.abrupt("return", fileHasher.hashNonImages(buffer));
25587
+ _context10.next = 6;
25588
+ return fileHasher.hashNonImages(buffer);
25588
25589
 
25589
- case 5:
25590
+ case 6:
25591
+ return _context10.abrupt("return", _context10.sent);
25592
+
25593
+ case 7:
25590
25594
  case "end":
25591
25595
  return _context10.stop();
25592
25596
  }
@@ -25608,9 +25612,13 @@ var fileHasher = {
25608
25612
  while (1) {
25609
25613
  switch (_context11.prev = _context11.next) {
25610
25614
  case 0:
25611
- return _context11.abrupt("return", fileHasher.hashImages(content));
25615
+ _context11.next = 3;
25616
+ return fileHasher.hashImages(content);
25612
25617
 
25613
- case 2:
25618
+ case 3:
25619
+ return _context11.abrupt("return", _context11.sent);
25620
+
25621
+ case 4:
25614
25622
  case "end":
25615
25623
  return _context11.stop();
25616
25624
  }
@@ -27099,9 +27107,9 @@ var EthWeb3Manager = /*#__PURE__*/function () {
27099
27107
  }();
27100
27108
 
27101
27109
  var name = "@audius/sdk";
27102
- var version = "2.0.3-beta.4";
27110
+ var version = "2.0.3-beta.5";
27103
27111
  var audius = {
27104
- releaseSHA: "42c56a1bf4cc52d52da7df738ace6822a91b0fce"
27112
+ releaseSHA: "29b38fb1a75d58b32ce4c98a46dc035540b43e1a"
27105
27113
  };
27106
27114
  var description = "";
27107
27115
  var main = "dist/index.cjs.js";
@@ -49756,9 +49764,13 @@ var AudiusContracts = /*#__PURE__*/function () {
49756
49764
  while (1) {
49757
49765
  switch (_context.prev = _context.next) {
49758
49766
  case 0:
49759
- return _context.abrupt("return", Promise.resolve(''));
49767
+ _context.next = 2;
49768
+ return Promise.resolve('');
49760
49769
 
49761
- case 1:
49770
+ case 2:
49771
+ return _context.abrupt("return", _context.sent);
49772
+
49773
+ case 3:
49762
49774
  case "end":
49763
49775
  return _context.stop();
49764
49776
  }
@@ -53051,9 +53063,13 @@ var CreatorNode = /*#__PURE__*/function () {
53051
53063
  while (1) {
53052
53064
  switch (_context8.prev = _context8.next) {
53053
53065
  case 0:
53054
- return _context8.abrupt("return", _this2.uploadTrackAudioV2(trackFile, onProgress));
53066
+ _context8.next = 2;
53067
+ return _this2.uploadTrackAudioV2(trackFile, onProgress);
53055
53068
 
53056
- case 1:
53069
+ case 2:
53070
+ return _context8.abrupt("return", _context8.sent);
53071
+
53072
+ case 3:
53057
53073
  case "end":
53058
53074
  return _context8.stop();
53059
53075
  }
@@ -53066,9 +53082,13 @@ var CreatorNode = /*#__PURE__*/function () {
53066
53082
  while (1) {
53067
53083
  switch (_context9.prev = _context9.next) {
53068
53084
  case 0:
53069
- return _context9.abrupt("return", _this2.uploadTrackCoverArtV2(coverArtFile, onProgress));
53085
+ _context9.next = 2;
53086
+ return _this2.uploadTrackCoverArtV2(coverArtFile, onProgress);
53070
53087
 
53071
- case 1:
53088
+ case 2:
53089
+ return _context9.abrupt("return", _context9.sent);
53090
+
53091
+ case 3:
53072
53092
  case "end":
53073
53093
  return _context9.stop();
53074
53094
  }
@@ -53086,7 +53106,7 @@ var CreatorNode = /*#__PURE__*/function () {
53086
53106
  // Update metadata to include uploaded CIDs
53087
53107
  // 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
53088
53108
  updatedMetadata.track_segments = [];
53089
- updatedMetadata.track_cid = audioResp.results["320"];
53109
+ updatedMetadata.track_cid = audioResp.results['320'];
53090
53110
 
53091
53111
  if ((_updatedMetadata$down = updatedMetadata.download) !== null && _updatedMetadata$down !== void 0 && _updatedMetadata$down.is_downloadable) {
53092
53112
  updatedMetadata.download.cid = updatedMetadata.track_cid;
@@ -53117,9 +53137,13 @@ var CreatorNode = /*#__PURE__*/function () {
53117
53137
  while (1) {
53118
53138
  switch (_context11.prev = _context11.next) {
53119
53139
  case 0:
53120
- return _context11.abrupt("return", this.uploadFileV2(file, onProgress, 'audio'));
53140
+ _context11.next = 2;
53141
+ return this.uploadFileV2(file, onProgress, 'audio');
53121
53142
 
53122
- case 1:
53143
+ case 2:
53144
+ return _context11.abrupt("return", _context11.sent);
53145
+
53146
+ case 3:
53123
53147
  case "end":
53124
53148
  return _context11.stop();
53125
53149
  }
@@ -53141,9 +53165,13 @@ var CreatorNode = /*#__PURE__*/function () {
53141
53165
  while (1) {
53142
53166
  switch (_context12.prev = _context12.next) {
53143
53167
  case 0:
53144
- return _context12.abrupt("return", this.uploadFileV2(file, onProgress, 'img_square'));
53168
+ _context12.next = 2;
53169
+ return this.uploadFileV2(file, onProgress, 'img_square');
53145
53170
 
53146
- case 1:
53171
+ case 2:
53172
+ return _context12.abrupt("return", _context12.sent);
53173
+
53174
+ case 3:
53147
53175
  case "end":
53148
53176
  return _context12.stop();
53149
53177
  }
@@ -53184,9 +53212,13 @@ var CreatorNode = /*#__PURE__*/function () {
53184
53212
 
53185
53213
  case 5:
53186
53214
  response = _context13.sent;
53187
- return _context13.abrupt("return", this.pollProcessingStatusV2(response.data[0].id, template === 'audio' ? MAX_TRACK_TRANSCODE_TIMEOUT : MAX_IMAGE_RESIZE_TIMEOUT_MS));
53215
+ _context13.next = 8;
53216
+ return this.pollProcessingStatusV2(response.data[0].id, template === 'audio' ? MAX_TRACK_TRANSCODE_TIMEOUT : MAX_IMAGE_RESIZE_TIMEOUT_MS);
53188
53217
 
53189
- case 7:
53218
+ case 8:
53219
+ return _context13.abrupt("return", _context13.sent);
53220
+
53221
+ case 9:
53190
53222
  case "end":
53191
53223
  return _context13.stop();
53192
53224
  }
@@ -53917,9 +53949,9 @@ var CreatorNode = /*#__PURE__*/function () {
53917
53949
  /* ------- INTERNAL FUNCTIONS ------- */
53918
53950
 
53919
53951
  /**
53920
- * Makes an axios request to the connected creator node
53921
- * @return response body
53922
- */
53952
+ * Makes an axios request to the connected creator node
53953
+ * @return response body
53954
+ */
53923
53955
 
53924
53956
  }, {
53925
53957
  key: "_makeRequestV2",
@@ -53932,9 +53964,13 @@ var CreatorNode = /*#__PURE__*/function () {
53932
53964
  // TODO: This might want to have other error handling, request UUIDs, etc...
53933
53965
  // But I didn't want to pull in all the chaos and incompatiblity of the old _makeRequest
53934
53966
  axiosRequestObj.baseURL = this.creatorNodeEndpoint;
53935
- return _context27.abrupt("return", axios__default["default"](axiosRequestObj));
53967
+ _context27.next = 3;
53968
+ return axios__default["default"](axiosRequestObj);
53936
53969
 
53937
- case 2:
53970
+ case 3:
53971
+ return _context27.abrupt("return", _context27.sent);
53972
+
53973
+ case 4:
53938
53974
  case "end":
53939
53975
  return _context27.stop();
53940
53976
  }
@@ -54754,15 +54790,19 @@ var CreatorNode = /*#__PURE__*/function () {
54754
54790
  switch (_context39.prev = _context39.next) {
54755
54791
  case 0:
54756
54792
  onRetry = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : function (_err) {};
54757
- return _context39.abrupt("return", retry__default["default"](fn, {
54793
+ _context39.next = 3;
54794
+ return retry__default["default"](fn, {
54758
54795
  minTimeout: 500,
54759
54796
  maxTimeout: 4000,
54760
54797
  factor: 3,
54761
54798
  retries: 3,
54762
54799
  onRetry: onRetry
54763
- }));
54800
+ });
54764
54801
 
54765
- case 2:
54802
+ case 3:
54803
+ return _context39.abrupt("return", _context39.sent);
54804
+
54805
+ case 4:
54766
54806
  case "end":
54767
54807
  return _context39.stop();
54768
54808
  }
@@ -57044,6 +57084,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
57044
57084
  this.userStateManager = userStateManager;
57045
57085
  this.ethContracts = ethContracts;
57046
57086
  this.web3Manager = web3Manager;
57087
+ this.selectionCallback = selectionCallback;
57047
57088
  this.unhealthyBlockDiff = unhealthyBlockDiff !== null && unhealthyBlockDiff !== void 0 ? unhealthyBlockDiff : DEFAULT_UNHEALTHY_BLOCK_DIFF;
57048
57089
  this.serviceSelector = new DiscoveryProviderSelection({
57049
57090
  whitelist: this.whitelist,
@@ -57088,7 +57129,11 @@ var DiscoveryProvider = /*#__PURE__*/function () {
57088
57129
  }
57089
57130
 
57090
57131
  this.discoveryNodeSelector.addEventListener('change', function (endpoint) {
57132
+ var _this$selectionCallba;
57133
+
57091
57134
  _this.setEndpoint(endpoint);
57135
+
57136
+ (_this$selectionCallba = _this.selectionCallback) === null || _this$selectionCallba === void 0 ? void 0 : _this$selectionCallba.call(_this, endpoint, []);
57092
57137
  });
57093
57138
  _context.next = 4;
57094
57139
  return this.discoveryNodeSelector.getSelectedEndpoint();
@@ -59693,7 +59738,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59693
59738
  }
59694
59739
 
59695
59740
  _context59.next = 7;
59696
- return this._makeRequestInternalNext(requestObj, throwError);
59741
+ return this._makeRequestInternalNext(requestObj, throwError, blockNumber);
59697
59742
 
59698
59743
  case 7:
59699
59744
  return _context59.abrupt("return", _context59.sent);
@@ -59942,6 +59987,7 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59942
59987
  var _yield$this$discovery, _this$discoveryNodeMi, _this$discoveryNodeMi2, _yield$this$discovery3, _this$discoveryNodeMi5, _this$discoveryNodeMi6;
59943
59988
 
59944
59989
  var throwError,
59990
+ blockNumber,
59945
59991
  axiosRequest,
59946
59992
  data,
59947
59993
  _axiosRequest$url2,
@@ -59961,15 +60007,16 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59961
60007
  switch (_context61.prev = _context61.next) {
59962
60008
  case 0:
59963
60009
  throwError = _args61.length > 1 && _args61[1] !== undefined ? _args61[1] : false;
60010
+ blockNumber = _args61.length > 2 ? _args61[2] : undefined;
59964
60011
 
59965
60012
  if (!(!this.discoveryProviderEndpoint || !this.discoveryNodeMiddleware)) {
59966
- _context61.next = 3;
60013
+ _context61.next = 4;
59967
60014
  break;
59968
60015
  }
59969
60016
 
59970
60017
  return _context61.abrupt("return");
59971
60018
 
59972
- case 3:
60019
+ case 4:
59973
60020
  axiosRequest = this._createDiscProvRequest(requestObj, this.discoveryProviderEndpoint);
59974
60021
  data = axiosRequest.data, _axiosRequest$url2 = axiosRequest.url, url = _axiosRequest$url2 === void 0 ? '' : _axiosRequest$url2, restRequest = _objectWithoutProperties(axiosRequest, _excluded);
59975
60022
  fetchRequestInit = _objectSpread2({
@@ -59979,50 +60026,50 @@ var DiscoveryProvider = /*#__PURE__*/function () {
59979
60026
  url: url,
59980
60027
  init: fetchRequestInit
59981
60028
  };
59982
- _context61.next = 9;
60029
+ _context61.next = 10;
59983
60030
  return (_this$discoveryNodeMi = (_this$discoveryNodeMi2 = this.discoveryNodeMiddleware).pre) === null || _this$discoveryNodeMi === void 0 ? void 0 : _this$discoveryNodeMi.call(_this$discoveryNodeMi2, _objectSpread2({
59984
60031
  fetch: fetch
59985
60032
  }, fetchParams));
59986
60033
 
59987
- case 9:
60034
+ case 10:
59988
60035
  _context61.t1 = _yield$this$discovery = _context61.sent;
59989
60036
  _context61.t0 = _context61.t1 !== null;
59990
60037
 
59991
60038
  if (!_context61.t0) {
59992
- _context61.next = 13;
60039
+ _context61.next = 14;
59993
60040
  break;
59994
60041
  }
59995
60042
 
59996
60043
  _context61.t0 = _yield$this$discovery !== void 0;
59997
60044
 
59998
- case 13:
60045
+ case 14:
59999
60046
  if (!_context61.t0) {
60000
- _context61.next = 17;
60047
+ _context61.next = 18;
60001
60048
  break;
60002
60049
  }
60003
60050
 
60004
60051
  _context61.t2 = _yield$this$discovery;
60005
- _context61.next = 18;
60052
+ _context61.next = 19;
60006
60053
  break;
60007
60054
 
60008
- case 17:
60055
+ case 18:
60009
60056
  _context61.t2 = fetchParams;
60010
60057
 
60011
- case 18:
60058
+ case 19:
60012
60059
  fetchParams = _context61.t2;
60013
- _context61.prev = 19;
60014
- _context61.next = 22;
60060
+ _context61.prev = 20;
60061
+ _context61.next = 23;
60015
60062
  return fetch(fetchParams.url, fetchParams.init);
60016
60063
 
60017
- case 22:
60064
+ case 23:
60018
60065
  response = _context61.sent;
60019
- _context61.next = 47;
60066
+ _context61.next = 48;
60020
60067
  break;
60021
60068
 
60022
- case 25:
60023
- _context61.prev = 25;
60024
- _context61.t3 = _context61["catch"](19);
60025
- _context61.next = 29;
60069
+ case 26:
60070
+ _context61.prev = 26;
60071
+ _context61.t3 = _context61["catch"](20);
60072
+ _context61.next = 30;
60026
60073
  return (_this$discoveryNodeMi3 = (_this$discoveryNodeMi4 = this.discoveryNodeMiddleware).onError) === null || _this$discoveryNodeMi3 === void 0 ? void 0 : _this$discoveryNodeMi3.call(_this$discoveryNodeMi4, _objectSpread2(_objectSpread2({
60027
60074
  fetch: fetch
60028
60075
  }, fetchParams), {}, {
@@ -60030,103 +60077,112 @@ var DiscoveryProvider = /*#__PURE__*/function () {
60030
60077
  response: response ? response.clone() : undefined
60031
60078
  }));
60032
60079
 
60033
- case 29:
60080
+ case 30:
60034
60081
  _context61.t5 = _yield$this$discovery2 = _context61.sent;
60035
60082
  _context61.t4 = _context61.t5 !== null;
60036
60083
 
60037
60084
  if (!_context61.t4) {
60038
- _context61.next = 33;
60085
+ _context61.next = 34;
60039
60086
  break;
60040
60087
  }
60041
60088
 
60042
60089
  _context61.t4 = _yield$this$discovery2 !== void 0;
60043
60090
 
60044
- case 33:
60091
+ case 34:
60045
60092
  if (!_context61.t4) {
60046
- _context61.next = 37;
60093
+ _context61.next = 38;
60047
60094
  break;
60048
60095
  }
60049
60096
 
60050
60097
  _context61.t6 = _yield$this$discovery2;
60051
- _context61.next = 38;
60098
+ _context61.next = 39;
60052
60099
  break;
60053
60100
 
60054
- case 37:
60101
+ case 38:
60055
60102
  _context61.t6 = response;
60056
60103
 
60057
- case 38:
60104
+ case 39:
60058
60105
  response = _context61.t6;
60059
60106
 
60060
60107
  if (!(response === undefined)) {
60061
- _context61.next = 47;
60108
+ _context61.next = 48;
60062
60109
  break;
60063
60110
  }
60064
60111
 
60065
60112
  if (!throwError) {
60066
- _context61.next = 46;
60113
+ _context61.next = 47;
60067
60114
  break;
60068
60115
  }
60069
60116
 
60070
60117
  if (!(_context61.t3 instanceof Error)) {
60071
- _context61.next = 45;
60118
+ _context61.next = 46;
60072
60119
  break;
60073
60120
  }
60074
60121
 
60075
60122
  throw new FetchError$1(_context61.t3, 'The request failed and the interceptors did not return an alternative response');
60076
60123
 
60077
- case 45:
60124
+ case 46:
60078
60125
  throw _context61.t3;
60079
60126
 
60080
- case 46:
60127
+ case 47:
60081
60128
  return _context61.abrupt("return", null);
60082
60129
 
60083
- case 47:
60084
- _context61.next = 49;
60130
+ case 48:
60131
+ _context61.next = 50;
60085
60132
  return (_this$discoveryNodeMi5 = (_this$discoveryNodeMi6 = this.discoveryNodeMiddleware).post) === null || _this$discoveryNodeMi5 === void 0 ? void 0 : _this$discoveryNodeMi5.call(_this$discoveryNodeMi6, _objectSpread2(_objectSpread2({
60086
60133
  fetch: fetch
60087
60134
  }, fetchParams), {}, {
60088
60135
  response: response
60089
60136
  }));
60090
60137
 
60091
- case 49:
60138
+ case 50:
60092
60139
  _context61.t8 = _yield$this$discovery3 = _context61.sent;
60093
60140
  _context61.t7 = _context61.t8 !== null;
60094
60141
 
60095
60142
  if (!_context61.t7) {
60096
- _context61.next = 53;
60143
+ _context61.next = 54;
60097
60144
  break;
60098
60145
  }
60099
60146
 
60100
60147
  _context61.t7 = _yield$this$discovery3 !== void 0;
60101
60148
 
60102
- case 53:
60149
+ case 54:
60103
60150
  if (!_context61.t7) {
60104
- _context61.next = 57;
60151
+ _context61.next = 58;
60105
60152
  break;
60106
60153
  }
60107
60154
 
60108
60155
  _context61.t9 = _yield$this$discovery3;
60109
- _context61.next = 58;
60156
+ _context61.next = 59;
60110
60157
  break;
60111
60158
 
60112
- case 57:
60159
+ case 58:
60113
60160
  _context61.t9 = response;
60114
60161
 
60115
- case 58:
60162
+ case 59:
60116
60163
  response = _context61.t9;
60117
- _context61.next = 61;
60164
+ _context61.next = 62;
60118
60165
  return response.json();
60119
60166
 
60120
- case 61:
60167
+ case 62:
60121
60168
  responseBody = _context61.sent;
60169
+
60170
+ if (!(blockNumber && responseBody.latest_indexed_block < blockNumber)) {
60171
+ _context61.next = 65;
60172
+ break;
60173
+ }
60174
+
60175
+ throw new Error("Requested blocknumber ".concat(blockNumber, ", but discovery is behind at ").concat(responseBody.latest_indexed_block));
60176
+
60177
+ case 65:
60122
60178
  return _context61.abrupt("return", responseBody);
60123
60179
 
60124
- case 63:
60180
+ case 66:
60125
60181
  case "end":
60126
60182
  return _context61.stop();
60127
60183
  }
60128
60184
  }
60129
- }, _callee61, this, [[19, 25]]);
60185
+ }, _callee61, this, [[20, 26]]);
60130
60186
  }));
60131
60187
 
60132
60188
  function _makeRequestInternalNext(_x79) {