@audius/sdk 0.0.35 → 0.0.38

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
@@ -33455,9 +33455,9 @@ var formatProviders = function formatProviders(providers) {
33455
33455
  };
33456
33456
 
33457
33457
  var name = "@audius/sdk";
33458
- var version = "0.0.35";
33458
+ var version = "0.0.38";
33459
33459
  var audius = {
33460
- releaseSHA: "87ed35aa1374bdcf5632ef58ce55efbdd4031b03"
33460
+ releaseSHA: "74503074cb96dea181ec2b218c5cb6d528c1db86"
33461
33461
  };
33462
33462
  var description = "";
33463
33463
  var main = "dist/index.cjs.js";
@@ -33553,6 +33553,7 @@ var devDependencies = {
33553
33553
  "@types/expect": "24.3.0",
33554
33554
  "@types/form-data": "^2.5.0",
33555
33555
  "@types/hashids": "2.0.1",
33556
+ "@types/lodash": "4.14.149",
33556
33557
  "@types/mocha": "9.1.0",
33557
33558
  "@types/node-localstorage": "1.3.0",
33558
33559
  "@types/pify": "^5.0.1",
@@ -35965,7 +35966,7 @@ var SolanaWeb3Manager = /*#__PURE__*/function () {
35965
35966
  case 0:
35966
35967
  _this$solanaWeb3Confi = this.solanaWeb3Config, solanaClusterEndpoint = _this$solanaWeb3Confi.solanaClusterEndpoint, mintAddress = _this$solanaWeb3Confi.mintAddress, solanaTokenAddress = _this$solanaWeb3Confi.solanaTokenAddress, claimableTokenPDA = _this$solanaWeb3Confi.claimableTokenPDA, feePayerAddress = _this$solanaWeb3Confi.feePayerAddress, claimableTokenProgramAddress = _this$solanaWeb3Confi.claimableTokenProgramAddress, rewardsManagerProgramId = _this$solanaWeb3Confi.rewardsManagerProgramId, rewardsManagerProgramPDA = _this$solanaWeb3Confi.rewardsManagerProgramPDA, rewardsManagerTokenPDA = _this$solanaWeb3Confi.rewardsManagerTokenPDA, useRelay = _this$solanaWeb3Confi.useRelay, feePayerKeypairs = _this$solanaWeb3Confi.feePayerKeypairs, confirmationTimeout = _this$solanaWeb3Confi.confirmationTimeout, audiusDataProgramId = _this$solanaWeb3Confi.audiusDataProgramId, audiusDataAdminStorageKeypairPublicKey = _this$solanaWeb3Confi.audiusDataAdminStorageKeypairPublicKey, audiusDataIdl = _this$solanaWeb3Confi.audiusDataIdl;
35967
35968
  this.solanaClusterEndpoint = solanaClusterEndpoint;
35968
- this.connection = new solanaWeb3__default["default"].Connection(this.solanaClusterEndpoint, {
35969
+ this.connection = new solanaWeb3.Connection(this.solanaClusterEndpoint, {
35969
35970
  confirmTransactionInitialTimeout: confirmationTimeout || DEFAULT_CONNECTION_CONFIRMATION_TIMEOUT_MS
35970
35971
  });
35971
35972
  this.transactionHandler = new TransactionHandler({
@@ -36025,9 +36026,8 @@ var SolanaWeb3Manager = /*#__PURE__*/function () {
36025
36026
  this.audiusDataIdl = audiusDataIdl || AudiusData.idl;
36026
36027
 
36027
36028
  if (this.audiusDataProgramId && this.audiusDataAdminStorageKeypairPublicKey && this.audiusDataIdl) {
36028
- connection = new solanaWeb3__default["default"].Connection(this.solanaClusterEndpoint, anchor__default["default"].AnchorProvider.defaultOptions());
36029
- anchorProvider = new anchor__default["default"].AnchorProvider(connection, // @ts-expect-error weirdness with 3rd party types
36030
- solanaWeb3__default["default"].Keypair.generate(), anchor__default["default"].AnchorProvider.defaultOptions());
36029
+ connection = new solanaWeb3.Connection(this.solanaClusterEndpoint, anchor__default["default"].AnchorProvider.defaultOptions());
36030
+ anchorProvider = new anchor__default["default"].AnchorProvider(connection, solanaWeb3.Keypair.generate(), anchor__default["default"].AnchorProvider.defaultOptions());
36031
36031
  this.anchorProgram = new anchor__default["default"].Program(this.audiusDataIdl, audiusDataProgramId, anchorProvider);
36032
36032
  }
36033
36033
 
@@ -37069,7 +37069,7 @@ var Base = /*#__PURE__*/function () {
37069
37069
  return Base;
37070
37070
  }();
37071
37071
 
37072
- var decodeHashId$2 = Utils.decodeHashId;
37072
+ var decodeHashId$1 = Utils.decodeHashId;
37073
37073
  var GetAttestationError = Object.freeze({
37074
37074
  CHALLENGE_INCOMPLETE: 'CHALLENGE_INCOMPLETE',
37075
37075
  ALREADY_DISBURSED: 'ALREADY_DISBURSED',
@@ -37154,7 +37154,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37154
37154
 
37155
37155
  case 7:
37156
37156
  // Aggregate
37157
- logger.info("submitAndEvaluate: aggregating attestations for userId [".concat(decodeHashId$2(encodedUserId), "], challengeId [").concat(challengeId, "]"));
37157
+ logger.info("submitAndEvaluate: aggregating attestations for userId [".concat(decodeHashId$1(encodedUserId), "], challengeId [").concat(challengeId, "]"));
37158
37158
  phase = AttestationPhases.AGGREGATE_ATTESTATIONS;
37159
37159
  _context.next = 11;
37160
37160
  return this.aggregateAttestations({
@@ -37190,7 +37190,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37190
37190
 
37191
37191
  case 21:
37192
37192
  // Submit
37193
- logger.info("submitAndEvaluate: submitting for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$2(encodedUserId), "] with [").concat(discoveryNodeAttestations === null || discoveryNodeAttestations === void 0 ? void 0 : discoveryNodeAttestations.length, "] DN and [").concat(aaoAttestation ? 1 : 0, "] oracle attestations."));
37193
+ logger.info("submitAndEvaluate: submitting for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "] with [").concat(discoveryNodeAttestations === null || discoveryNodeAttestations === void 0 ? void 0 : discoveryNodeAttestations.length, "] DN and [").concat(aaoAttestation ? 1 : 0, "] oracle attestations."));
37194
37194
  fullTokenAmount = new BN__default["default"](amount * WRAPPED_AUDIO_PRECISION);
37195
37195
  phase = AttestationPhases.SUBMIT_ATTESTATIONS; // @ts-expect-error the return types are a bit strange here
37196
37196
 
@@ -37228,7 +37228,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37228
37228
  break;
37229
37229
  }
37230
37230
 
37231
- logger.warn("submitAndEvaluate: saw repeat senders for userId [".concat(decodeHashId$2(encodedUserId), "] challengeId: [").concat(challengeId, "] with err: ").concat(submitErrorCode, ", breaking up into individual transactions"));
37231
+ logger.warn("submitAndEvaluate: saw repeat senders for userId [".concat(decodeHashId$1(encodedUserId), "] challengeId: [").concat(challengeId, "] with err: ").concat(submitErrorCode, ", breaking up into individual transactions"));
37232
37232
  _context.next = 35;
37233
37233
  return this.solanaWeb3Manager.submitChallengeAttestations({
37234
37234
  attestations: discoveryNodeAttestations,
@@ -37251,7 +37251,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37251
37251
 
37252
37252
  case 38:
37253
37253
  // Evaluate
37254
- logger.info("submitAndEvaluate: evaluating for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$2(encodedUserId), "]"));
37254
+ logger.info("submitAndEvaluate: evaluating for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "]"));
37255
37255
  phase = AttestationPhases.EVALUATE_ATTESTATIONS;
37256
37256
  _context.next = 42;
37257
37257
  return this.solanaWeb3Manager.evaluateChallengeAttestations({
@@ -37290,7 +37290,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37290
37290
  _context.t0 = _context["catch"](3);
37291
37291
  err = _context.t0.message;
37292
37292
  log = err === GetAttestationError.COGNITO_FLOW || err === GetAttestationError.HCAPTCHA ? logger.info : logger.error;
37293
- log("submitAndEvaluate: failed for userId: [".concat(decodeHashId$2(encodedUserId), "] challenge-id [").concat(challengeId, "] at phase [").concat(phase, "] with err: ").concat(err));
37293
+ log("submitAndEvaluate: failed for userId: [".concat(decodeHashId$1(encodedUserId), "] challenge-id [").concat(challengeId, "] at phase [").concat(phase, "] with err: ").concat(err));
37294
37294
  return _context.abrupt("return", {
37295
37295
  success: false,
37296
37296
  error: err,
@@ -37405,7 +37405,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37405
37405
  _context2.prev = 25;
37406
37406
  _context2.t0 = _context2["catch"](13);
37407
37407
  err = _context2.t0.message;
37408
- logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$2(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(err));
37408
+ logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$1(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(err));
37409
37409
  return _context2.abrupt("return", {
37410
37410
  discoveryNodeAttestations: null,
37411
37411
  aaoAttestation: null,
@@ -37468,7 +37468,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37468
37468
  _context2.prev = 43;
37469
37469
  _context2.t1 = _context2["catch"](30);
37470
37470
  _err = _context2.t1.message;
37471
- logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$2(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(_err));
37471
+ logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$1(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(_err));
37472
37472
  return _context2.abrupt("return", {
37473
37473
  discoveryNodeAttestations: null,
37474
37474
  aaoAttestation: null,
@@ -37526,7 +37526,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37526
37526
  _context3.prev = 10;
37527
37527
  _context3.t0 = _context3["catch"](2);
37528
37528
  err = _context3.t0.message;
37529
- logger.error("Failed to get challenge attestation for userId [".concat(decodeHashId$2(encodedUserId), "] challengeId [").concat(challengeId, "]from ").concat(discoveryProviderEndpoint, " with ").concat(err));
37529
+ logger.error("Failed to get challenge attestation for userId [".concat(decodeHashId$1(encodedUserId), "] challengeId [").concat(challengeId, "]from ").concat(discoveryProviderEndpoint, " with ").concat(err));
37530
37530
  mappedErr = GetAttestationError[err] || GetAttestationError.DISCOVERY_NODE_UNKNOWN_RESPONSE;
37531
37531
  return _context3.abrupt("return", {
37532
37532
  success: null,
@@ -37799,9 +37799,9 @@ var Rewards = /*#__PURE__*/function (_Base) {
37799
37799
 
37800
37800
  case 16:
37801
37801
  if (needsAttestations.length || unrecoverableError) {
37802
- logger.info("Failed to aggregate attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$2(encodedUserId), "]"));
37802
+ logger.info("Failed to aggregate attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "]"));
37803
37803
  } else {
37804
- logger.info("Successfully aggregated attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$2(encodedUserId), "]"));
37804
+ logger.info("Successfully aggregated attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "]"));
37805
37805
  }
37806
37806
 
37807
37807
  return _context7.abrupt("return", completedAttestations);
@@ -38026,7 +38026,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
38026
38026
  return Rewards;
38027
38027
  }(Base);
38028
38028
 
38029
- var decodeHashId$1 = Utils.decodeHashId; // `BaseRewardsReporter` is intended to be subclassed, and provides
38029
+ var decodeHashId = Utils.decodeHashId; // `BaseRewardsReporter` is intended to be subclassed, and provides
38030
38030
  // "reporting" functionality to RewardsAttester (i.e. posts to Slack if something notable happens)
38031
38031
 
38032
38032
  var BaseRewardsReporter = /*#__PURE__*/function () {
@@ -39030,7 +39030,7 @@ var RewardsAttester = /*#__PURE__*/function () {
39030
39030
  switch (_context17.prev = _context17.next) {
39031
39031
  case 0:
39032
39032
  challengeId = _ref9.challengeId, userId = _ref9.userId, specifier = _ref9.specifier, amount = _ref9.amount, handle = _ref9.handle, wallet = _ref9.wallet, completedBlocknumber = _ref9.completedBlocknumber;
39033
- this.logger.info("Attempting to attest for userId [".concat(decodeHashId$1(userId), "], challengeId: [").concat(challengeId, "], quorum size: [").concat(this.quorumSize, "]}"));
39033
+ this.logger.info("Attempting to attest for userId [".concat(decodeHashId(userId), "], challengeId: [").concat(challengeId, "], quorum size: [").concat(this.quorumSize, "]}"));
39034
39034
  _context17.next = 4;
39035
39035
  return this.libs.Rewards.submitAndEvaluate({
39036
39036
  challengeId: challengeId,
@@ -39061,7 +39061,7 @@ var RewardsAttester = /*#__PURE__*/function () {
39061
39061
  break;
39062
39062
  }
39063
39063
 
39064
- this.logger.info("Successfully attestested for challenge [".concat(challengeId, "] for user [").concat(decodeHashId$1(userId), "], amount [").concat(amount, "]!"));
39064
+ this.logger.info("Successfully attestested for challenge [".concat(challengeId, "] for user [").concat(decodeHashId(userId), "], amount [").concat(amount, "]!"));
39065
39065
  return _context17.abrupt("return", {
39066
39066
  challengeId: challengeId,
39067
39067
  userId: userId,
@@ -39075,7 +39075,7 @@ var RewardsAttester = /*#__PURE__*/function () {
39075
39075
 
39076
39076
  case 13:
39077
39077
  // Handle error path
39078
- this.logger.error("Failed to attest for challenge [".concat(challengeId, "] for user [").concat(decodeHashId$1(userId), "], amount [").concat(amount, "], oracle: [").concat(this.aaoAddress, "] at phase: [").concat(phase, "] with error [").concat(error, "]"));
39078
+ this.logger.error("Failed to attest for challenge [".concat(challengeId, "] for user [").concat(decodeHashId(userId), "], amount [").concat(amount, "], oracle: [").concat(this.aaoAddress, "] at phase: [").concat(phase, "] with error [").concat(error, "]"));
39079
39079
  return _context17.abrupt("return", {
39080
39080
  challengeId: challengeId,
39081
39081
  userId: userId,
@@ -39333,7 +39333,7 @@ var RewardsAttester = /*#__PURE__*/function () {
39333
39333
  successful.push(res);
39334
39334
 
39335
39335
  _this5.reporter.reportSuccess({
39336
- userId: (_decodeHashId = decodeHashId$1(res.userId)) !== null && _decodeHashId !== void 0 ? _decodeHashId : -1,
39336
+ userId: (_decodeHashId = decodeHashId(res.userId)) !== null && _decodeHashId !== void 0 ? _decodeHashId : -1,
39337
39337
  challengeId: res.challengeId,
39338
39338
  amount: res.amount,
39339
39339
  specifier: res.specifier
@@ -39354,7 +39354,7 @@ var RewardsAttester = /*#__PURE__*/function () {
39354
39354
  var _decodeHashId2;
39355
39355
 
39356
39356
  var report = {
39357
- userId: (_decodeHashId2 = decodeHashId$1(res.userId)) !== null && _decodeHashId2 !== void 0 ? _decodeHashId2 : -1,
39357
+ userId: (_decodeHashId2 = decodeHashId(res.userId)) !== null && _decodeHashId2 !== void 0 ? _decodeHashId2 : -1,
39358
39358
  challengeId: res.challengeId,
39359
39359
  amount: res.amount,
39360
39360
  error: res.error,
@@ -57125,15 +57125,13 @@ var EntityType;
57125
57125
  (function (EntityType) {
57126
57126
  EntityType["PLAYLIST"] = "Playlist";
57127
57127
  })(EntityType || (EntityType = {}));
57128
-
57129
- var encodeHashId = Utils.encodeHashId,
57130
- decodeHashId = Utils.decodeHashId;
57131
57128
  /*
57132
57129
  API surface for updated data contract interactions.
57133
57130
  Provides simplified entity management in a generic fashion
57134
57131
  Handles metadata + file upload etc. for entities such as Playlist/Track/User
57135
57132
  */
57136
57133
 
57134
+
57137
57135
  var EntityManager = /*#__PURE__*/function (_Base) {
57138
57136
  _inherits(EntityManager, _Base);
57139
57137
 
@@ -57157,46 +57155,15 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57157
57155
  return Math.floor(Math.random() * (max - min) + min);
57158
57156
  }
57159
57157
  }, {
57160
- key: "getFullPlaylist",
57161
- value: function () {
57162
- var _getFullPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(playlistId, userId) {
57163
- var encodedPlaylistId, encodedUserId, playlist;
57164
- return regeneratorRuntime.wrap(function _callee$(_context) {
57165
- while (1) {
57166
- switch (_context.prev = _context.next) {
57167
- case 0:
57168
- encodedPlaylistId = encodeHashId(playlistId);
57169
- encodedUserId = encodeHashId(userId);
57170
- _context.next = 4;
57171
- return this.discoveryProvider.getFullPlaylist(encodedPlaylistId, encodedUserId);
57172
-
57173
- case 4:
57174
- playlist = _context.sent[0];
57175
- return _context.abrupt("return", playlist);
57176
-
57177
- case 6:
57178
- case "end":
57179
- return _context.stop();
57180
- }
57181
- }
57182
- }, _callee, this);
57183
- }));
57184
-
57185
- function getFullPlaylist(_x, _x2) {
57186
- return _getFullPlaylist.apply(this, arguments);
57187
- }
57188
-
57189
- return getFullPlaylist;
57190
- }()
57191
- }, {
57192
- key: "mapAddedTimestamps",
57193
- value: function mapAddedTimestamps(addedTimestamps) {
57158
+ key: "mapTimestamps",
57159
+ value: function mapTimestamps(addedTimestamps) {
57194
57160
  var trackIds = addedTimestamps.map(function (trackObj) {
57195
57161
  var _trackObj$metadata_ti;
57196
57162
 
57197
57163
  return {
57198
- track: decodeHashId(trackObj.track_id),
57199
- time: (_trackObj$metadata_ti = trackObj.metadata_timestamp) !== null && _trackObj$metadata_ti !== void 0 ? _trackObj$metadata_ti : trackObj.timestamp
57164
+ track: trackObj.track,
57165
+ time: (_trackObj$metadata_ti = trackObj.metadata_time) !== null && _trackObj$metadata_ti !== void 0 ? _trackObj$metadata_ti : trackObj.time // default to time for legacy playlists
57166
+
57200
57167
  };
57201
57168
  });
57202
57169
  return trackIds;
@@ -57211,7 +57178,6 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57211
57178
  return {
57212
57179
  blockHash: null,
57213
57180
  blockNumber: null,
57214
- playlistId: null,
57215
57181
  error: null
57216
57182
  };
57217
57183
  }
@@ -57222,105 +57188,94 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57222
57188
  }, {
57223
57189
  key: "createPlaylist",
57224
57190
  value: function () {
57225
- var _createPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref) {
57226
- var playlistId, playlistName, trackIds, description, isAlbum, isPrivate, coverArt, responseValues, currentUserId, userId, createAction, entityType, updatedPlaylistImage, web3, currentBlockNumber, currentBlock, tracks, dirCID, metadata, _yield$this$creatorNo, metadataMultihash, manageEntityResponse, txReceipt, error;
57191
+ var _createPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(playlist) {
57192
+ var responseValues, _playlist$artwork, _dirCID, userId, createAction, entityType, dirCID, updatedPlaylistImage, tracks, metadata, _yield$this$creatorNo, metadataMultihash, manageEntityResponse, txReceipt, error;
57227
57193
 
57228
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
57194
+ return regeneratorRuntime.wrap(function _callee$(_context) {
57229
57195
  while (1) {
57230
- switch (_context2.prev = _context2.next) {
57196
+ switch (_context.prev = _context.next) {
57231
57197
  case 0:
57232
- playlistId = _ref.playlistId, playlistName = _ref.playlistName, trackIds = _ref.trackIds, description = _ref.description, isAlbum = _ref.isAlbum, isPrivate = _ref.isPrivate, coverArt = _ref.coverArt;
57233
57198
  responseValues = this.getDefaultPlaylistReponseValues();
57234
- _context2.prev = 2;
57235
- currentUserId = this.userStateManager.getCurrentUserId();
57199
+ _context.prev = 1;
57200
+ userId = this.userStateManager.getCurrentUserId();
57236
57201
 
57237
- if (currentUserId) {
57238
- _context2.next = 7;
57202
+ if (userId) {
57203
+ _context.next = 6;
57239
57204
  break;
57240
57205
  }
57241
57206
 
57242
57207
  responseValues.error = 'Missing current user ID';
57243
- return _context2.abrupt("return", responseValues);
57208
+ return _context.abrupt("return", responseValues);
57244
57209
 
57245
- case 7:
57246
- userId = parseInt(currentUserId);
57210
+ case 6:
57247
57211
  createAction = Action.CREATE;
57248
57212
  entityType = EntityType.PLAYLIST;
57249
57213
  this.REQUIRES(Services.CREATOR_NODE);
57250
- _context2.next = 13;
57251
- return this.creatorNode.uploadImage(coverArt, true // square
57252
- );
57253
57214
 
57254
- case 13:
57255
- updatedPlaylistImage = _context2.sent;
57256
- web3 = this.web3Manager.getWeb3();
57257
- _context2.next = 17;
57258
- return web3.eth.getBlockNumber();
57215
+ if (!(playlist !== null && playlist !== void 0 && (_playlist$artwork = playlist.artwork) !== null && _playlist$artwork !== void 0 && _playlist$artwork.file)) {
57216
+ _context.next = 14;
57217
+ break;
57218
+ }
57259
57219
 
57260
- case 17:
57261
- currentBlockNumber = _context2.sent;
57262
- _context2.next = 20;
57263
- return web3.eth.getBlock(currentBlockNumber);
57220
+ _context.next = 12;
57221
+ return this.creatorNode.uploadImage(playlist.artwork.file, true // square
57222
+ );
57264
57223
 
57265
- case 20:
57266
- currentBlock = _context2.sent;
57267
- tracks = trackIds.map(function (trackId) {
57268
- return {
57269
- track: trackId,
57270
- time: currentBlock.timestamp
57271
- };
57272
- });
57224
+ case 12:
57225
+ updatedPlaylistImage = _context.sent;
57273
57226
  dirCID = updatedPlaylistImage.dirCID;
57227
+
57228
+ case 14:
57229
+ tracks = this.mapTimestamps(playlist.playlist_contents.track_ids);
57274
57230
  metadata = {
57275
- playlist_id: playlistId,
57231
+ playlist_id: playlist.playlist_id,
57276
57232
  playlist_contents: {
57277
57233
  track_ids: tracks
57278
57234
  },
57279
- playlist_name: playlistName,
57280
- playlist_image_sizes_multihash: dirCID,
57281
- description: description,
57282
- is_album: isAlbum,
57283
- is_private: isPrivate
57235
+ playlist_name: playlist.playlist_name,
57236
+ playlist_image_sizes_multihash: (_dirCID = dirCID) !== null && _dirCID !== void 0 ? _dirCID : playlist.cover_art_sizes,
57237
+ description: playlist.description,
57238
+ is_album: playlist.is_album,
57239
+ is_private: playlist.is_private
57284
57240
  };
57285
- _context2.next = 26;
57241
+ _context.next = 18;
57286
57242
  return this.creatorNode.uploadPlaylistMetadata(metadata);
57287
57243
 
57288
- case 26:
57289
- _yield$this$creatorNo = _context2.sent;
57244
+ case 18:
57245
+ _yield$this$creatorNo = _context.sent;
57290
57246
  metadataMultihash = _yield$this$creatorNo.metadataMultihash;
57291
- _context2.next = 30;
57247
+ _context.next = 22;
57292
57248
  return this.manageEntity({
57293
57249
  userId: userId,
57294
57250
  entityType: entityType,
57295
- entityId: playlistId,
57251
+ entityId: playlist.playlist_id,
57296
57252
  action: createAction,
57297
57253
  metadataMultihash: metadataMultihash
57298
57254
  });
57299
57255
 
57300
- case 30:
57301
- manageEntityResponse = _context2.sent;
57256
+ case 22:
57257
+ manageEntityResponse = _context.sent;
57302
57258
  txReceipt = manageEntityResponse.txReceipt;
57303
57259
  responseValues.blockHash = txReceipt.blockHash;
57304
57260
  responseValues.blockNumber = txReceipt.blockNumber;
57305
- responseValues.playlistId = playlistId;
57306
- return _context2.abrupt("return", responseValues);
57261
+ return _context.abrupt("return", responseValues);
57307
57262
 
57308
- case 38:
57309
- _context2.prev = 38;
57310
- _context2.t0 = _context2["catch"](2);
57311
- error = _context2.t0.message;
57263
+ case 29:
57264
+ _context.prev = 29;
57265
+ _context.t0 = _context["catch"](1);
57266
+ error = _context.t0.message;
57312
57267
  responseValues.error = error;
57313
- return _context2.abrupt("return", responseValues);
57268
+ return _context.abrupt("return", responseValues);
57314
57269
 
57315
- case 43:
57270
+ case 34:
57316
57271
  case "end":
57317
- return _context2.stop();
57272
+ return _context.stop();
57318
57273
  }
57319
57274
  }
57320
- }, _callee2, this, [[2, 38]]);
57275
+ }, _callee, this, [[1, 29]]);
57321
57276
  }));
57322
57277
 
57323
- function createPlaylist(_x3) {
57278
+ function createPlaylist(_x) {
57324
57279
  return _createPlaylist.apply(this, arguments);
57325
57280
  }
57326
57281
 
@@ -57333,29 +57288,26 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57333
57288
  }, {
57334
57289
  key: "deletePlaylist",
57335
57290
  value: function () {
57336
- var _deletePlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref2) {
57337
- var playlistId, responseValues, currentUserId, userId, resp, txReceipt, error;
57338
-
57339
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
57291
+ var _deletePlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(playlistId) {
57292
+ var responseValues, userId, resp, txReceipt, error;
57293
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
57340
57294
  while (1) {
57341
- switch (_context3.prev = _context3.next) {
57295
+ switch (_context2.prev = _context2.next) {
57342
57296
  case 0:
57343
- playlistId = _ref2.playlistId;
57344
57297
  responseValues = this.getDefaultPlaylistReponseValues();
57345
- currentUserId = this.userStateManager.getCurrentUserId();
57298
+ userId = this.userStateManager.getCurrentUserId();
57346
57299
 
57347
- if (currentUserId) {
57348
- _context3.next = 6;
57300
+ if (userId) {
57301
+ _context2.next = 5;
57349
57302
  break;
57350
57303
  }
57351
57304
 
57352
57305
  responseValues.error = 'Missing current user ID';
57353
- return _context3.abrupt("return", responseValues);
57306
+ return _context2.abrupt("return", responseValues);
57354
57307
 
57355
- case 6:
57356
- userId = parseInt(currentUserId);
57357
- _context3.prev = 7;
57358
- _context3.next = 10;
57308
+ case 5:
57309
+ _context2.prev = 5;
57310
+ _context2.next = 8;
57359
57311
  return this.manageEntity({
57360
57312
  userId: userId,
57361
57313
  entityType: EntityType.PLAYLIST,
@@ -57364,30 +57316,29 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57364
57316
  metadataMultihash: ''
57365
57317
  });
57366
57318
 
57367
- case 10:
57368
- resp = _context3.sent;
57319
+ case 8:
57320
+ resp = _context2.sent;
57369
57321
  txReceipt = resp.txReceipt;
57370
57322
  responseValues.blockHash = txReceipt.blockHash;
57371
57323
  responseValues.blockNumber = txReceipt.blockNumber;
57372
- responseValues.playlistId = playlistId;
57373
- return _context3.abrupt("return", responseValues);
57324
+ return _context2.abrupt("return", responseValues);
57374
57325
 
57375
- case 18:
57376
- _context3.prev = 18;
57377
- _context3.t0 = _context3["catch"](7);
57378
- error = _context3.t0.message;
57326
+ case 15:
57327
+ _context2.prev = 15;
57328
+ _context2.t0 = _context2["catch"](5);
57329
+ error = _context2.t0.message;
57379
57330
  responseValues.error = error;
57380
- return _context3.abrupt("return", responseValues);
57331
+ return _context2.abrupt("return", responseValues);
57381
57332
 
57382
- case 23:
57333
+ case 20:
57383
57334
  case "end":
57384
- return _context3.stop();
57335
+ return _context2.stop();
57385
57336
  }
57386
57337
  }
57387
- }, _callee3, this, [[7, 18]]);
57338
+ }, _callee2, this, [[5, 15]]);
57388
57339
  }));
57389
57340
 
57390
- function deletePlaylist(_x4) {
57341
+ function deletePlaylist(_x2) {
57391
57342
  return _deletePlaylist.apply(this, arguments);
57392
57343
  }
57393
57344
 
@@ -57395,448 +57346,112 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57395
57346
  }()
57396
57347
  /**
57397
57348
  * Update a playlist using updated data contracts flow
57398
- **/
57349
+ */
57399
57350
 
57400
57351
  }, {
57401
- key: "editPlaylist",
57352
+ key: "updatePlaylist",
57402
57353
  value: function () {
57403
- var _editPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref3) {
57404
- var playlistId, playlistName, description, isAlbum, isPrivate, coverArt, responseValues, _dirCID, currentUserId, userId, updateAction, entityType, dirCID, updatedPlaylistImage, playlist, existingPlaylistTracks, metadata, _yield$this$creatorNo2, metadataMultihash, resp, txReceipt, error;
57354
+ var _updatePlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(playlist) {
57355
+ var responseValues, _playlist$artwork2, _dirCID2, userId, updateAction, entityType, dirCID, updatedPlaylistImage, trackIds, metadata, _yield$this$creatorNo2, metadataMultihash, resp, txReceipt, error;
57405
57356
 
57406
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
57357
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
57407
57358
  while (1) {
57408
- switch (_context4.prev = _context4.next) {
57359
+ switch (_context3.prev = _context3.next) {
57409
57360
  case 0:
57410
- playlistId = _ref3.playlistId, playlistName = _ref3.playlistName, description = _ref3.description, isAlbum = _ref3.isAlbum, isPrivate = _ref3.isPrivate, coverArt = _ref3.coverArt;
57411
57361
  responseValues = this.getDefaultPlaylistReponseValues();
57412
- _context4.prev = 2;
57413
- currentUserId = this.userStateManager.getCurrentUserId();
57362
+ _context3.prev = 1;
57363
+ userId = this.userStateManager.getCurrentUserId();
57414
57364
 
57415
- if (!(!playlistId || playlistId === undefined)) {
57416
- _context4.next = 7;
57365
+ if (!(!playlist || playlist === undefined)) {
57366
+ _context3.next = 6;
57417
57367
  break;
57418
57368
  }
57419
57369
 
57420
- responseValues.error = 'Missing current playlistId';
57421
- return _context4.abrupt("return", responseValues);
57370
+ responseValues.error = 'Missing current playlist';
57371
+ return _context3.abrupt("return", responseValues);
57422
57372
 
57423
- case 7:
57424
- if (currentUserId) {
57425
- _context4.next = 10;
57373
+ case 6:
57374
+ if (userId) {
57375
+ _context3.next = 9;
57426
57376
  break;
57427
57377
  }
57428
57378
 
57429
57379
  responseValues.error = 'Missing current user ID';
57430
- return _context4.abrupt("return", responseValues);
57380
+ return _context3.abrupt("return", responseValues);
57431
57381
 
57432
- case 10:
57433
- userId = parseInt(currentUserId);
57382
+ case 9:
57434
57383
  updateAction = Action.UPDATE;
57435
57384
  entityType = EntityType.PLAYLIST;
57436
57385
  this.REQUIRES(Services.CREATOR_NODE);
57437
57386
 
57438
- if (!coverArt) {
57439
- _context4.next = 19;
57387
+ if (!(playlist !== null && playlist !== void 0 && (_playlist$artwork2 = playlist.artwork) !== null && _playlist$artwork2 !== void 0 && _playlist$artwork2.file)) {
57388
+ _context3.next = 17;
57440
57389
  break;
57441
57390
  }
57442
57391
 
57443
- _context4.next = 17;
57444
- return this.creatorNode.uploadImage(coverArt, true // square
57392
+ _context3.next = 15;
57393
+ return this.creatorNode.uploadImage(playlist.artwork.file, true // square
57445
57394
  );
57446
57395
 
57447
- case 17:
57448
- updatedPlaylistImage = _context4.sent;
57396
+ case 15:
57397
+ updatedPlaylistImage = _context3.sent;
57449
57398
  dirCID = updatedPlaylistImage.dirCID;
57450
57399
 
57451
- case 19:
57452
- _context4.next = 21;
57453
- return this.getFullPlaylist(playlistId, userId);
57454
-
57455
- case 21:
57456
- playlist = _context4.sent;
57457
- existingPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
57458
- metadata = {
57459
- playlist_id: playlistId,
57460
- playlist_contents: {
57461
- track_ids: existingPlaylistTracks
57462
- },
57463
- playlist_name: playlistName !== null && playlistName !== void 0 ? playlistName : playlist.playlist_name,
57464
- playlist_image_sizes_multihash: (_dirCID = dirCID) !== null && _dirCID !== void 0 ? _dirCID : playlist.cover_art,
57465
- description: description !== null && description !== void 0 ? description : playlist.description,
57466
- is_album: isAlbum !== null && isAlbum !== void 0 ? isAlbum : playlist.is_album,
57467
- is_private: isPrivate !== null && isPrivate !== void 0 ? isPrivate : playlist.is_private
57468
- };
57469
- _context4.next = 26;
57470
- return this.creatorNode.uploadPlaylistMetadata(metadata);
57471
-
57472
- case 26:
57473
- _yield$this$creatorNo2 = _context4.sent;
57474
- metadataMultihash = _yield$this$creatorNo2.metadataMultihash;
57475
- _context4.next = 30;
57476
- return this.manageEntity({
57477
- userId: userId,
57478
- entityType: entityType,
57479
- entityId: playlistId,
57480
- action: updateAction,
57481
- metadataMultihash: metadataMultihash
57482
- });
57483
-
57484
- case 30:
57485
- resp = _context4.sent;
57486
- txReceipt = resp.txReceipt;
57487
- responseValues.blockHash = txReceipt.blockHash;
57488
- responseValues.blockNumber = txReceipt.blockNumber;
57489
- responseValues.playlistId = playlistId;
57490
- return _context4.abrupt("return", responseValues);
57491
-
57492
- case 38:
57493
- _context4.prev = 38;
57494
- _context4.t0 = _context4["catch"](2);
57495
- error = _context4.t0.message;
57496
- responseValues.error = error;
57497
- return _context4.abrupt("return", responseValues);
57498
-
57499
- case 43:
57500
- case "end":
57501
- return _context4.stop();
57502
- }
57503
- }
57504
- }, _callee4, this, [[2, 38]]);
57505
- }));
57506
-
57507
- function editPlaylist(_x5) {
57508
- return _editPlaylist.apply(this, arguments);
57509
- }
57510
-
57511
- return editPlaylist;
57512
- }()
57513
- }, {
57514
- key: "addPlaylistTrack",
57515
- value: function () {
57516
- var _addPlaylistTrack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(_ref4) {
57517
- var playlistId, trackId, timestamp, responseValues, currentUserId, userId, updateAction, entityType, playlist, updatedPlaylistTracks, metadata, _yield$this$creatorNo3, metadataMultihash, resp, txReceipt, error;
57518
-
57519
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
57520
- while (1) {
57521
- switch (_context5.prev = _context5.next) {
57522
- case 0:
57523
- playlistId = _ref4.playlistId, trackId = _ref4.trackId, timestamp = _ref4.timestamp;
57524
- responseValues = this.getDefaultPlaylistReponseValues();
57525
- _context5.prev = 2;
57526
- currentUserId = this.userStateManager.getCurrentUserId();
57527
-
57528
- if (!(!playlistId || playlistId === undefined)) {
57529
- _context5.next = 7;
57530
- break;
57531
- }
57532
-
57533
- responseValues.error = 'Missing current playlistId';
57534
- return _context5.abrupt("return", responseValues);
57535
-
57536
- case 7:
57537
- if (currentUserId) {
57538
- _context5.next = 10;
57539
- break;
57540
- }
57541
-
57542
- responseValues.error = 'Missing current user ID';
57543
- return _context5.abrupt("return", responseValues);
57544
-
57545
- case 10:
57546
- userId = parseInt(currentUserId);
57547
- updateAction = Action.UPDATE;
57548
- entityType = EntityType.PLAYLIST;
57549
- this.REQUIRES(Services.CREATOR_NODE);
57550
- _context5.next = 16;
57551
- return this.getFullPlaylist(playlistId, userId);
57552
-
57553
- case 16:
57554
- playlist = _context5.sent;
57555
- updatedPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
57556
- updatedPlaylistTracks.push({
57557
- track: trackId,
57558
- time: timestamp
57559
- });
57560
- metadata = {
57561
- playlist_id: playlistId,
57562
- playlist_contents: {
57563
- track_ids: updatedPlaylistTracks
57564
- },
57565
- playlist_name: playlist.playlist_name,
57566
- playlist_image_sizes_multihash: playlist.cover_art,
57567
- description: playlist.description,
57568
- is_album: playlist.is_album,
57569
- is_private: playlist.is_private
57570
- };
57571
- _context5.next = 22;
57572
- return this.creatorNode.uploadPlaylistMetadata(metadata);
57573
-
57574
- case 22:
57575
- _yield$this$creatorNo3 = _context5.sent;
57576
- metadataMultihash = _yield$this$creatorNo3.metadataMultihash;
57577
- _context5.next = 26;
57578
- return this.manageEntity({
57579
- userId: userId,
57580
- entityType: entityType,
57581
- entityId: playlistId,
57582
- action: updateAction,
57583
- metadataMultihash: metadataMultihash
57584
- });
57585
-
57586
- case 26:
57587
- resp = _context5.sent;
57588
- txReceipt = resp.txReceipt;
57589
- responseValues.blockHash = txReceipt.blockHash;
57590
- responseValues.blockNumber = txReceipt.blockNumber;
57591
- responseValues.playlistId = playlistId;
57592
- return _context5.abrupt("return", responseValues);
57593
-
57594
- case 34:
57595
- _context5.prev = 34;
57596
- _context5.t0 = _context5["catch"](2);
57597
- error = _context5.t0.message;
57598
- responseValues.error = error;
57599
- return _context5.abrupt("return", responseValues);
57600
-
57601
- case 39:
57602
- case "end":
57603
- return _context5.stop();
57604
- }
57605
- }
57606
- }, _callee5, this, [[2, 34]]);
57607
- }));
57608
-
57609
- function addPlaylistTrack(_x6) {
57610
- return _addPlaylistTrack.apply(this, arguments);
57611
- }
57612
-
57613
- return addPlaylistTrack;
57614
- }()
57615
- }, {
57616
- key: "deletePlaylistTrack",
57617
- value: function () {
57618
- var _deletePlaylistTrack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(_ref5) {
57619
- var playlistId, trackId, timestamp, responseValues, currentUserId, userId, updateAction, entityType, playlist, existingPlaylistTracks, updatedTrackIds, metadata, _yield$this$creatorNo4, metadataMultihash, resp, txReceipt, error;
57620
-
57621
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
57622
- while (1) {
57623
- switch (_context6.prev = _context6.next) {
57624
- case 0:
57625
- playlistId = _ref5.playlistId, trackId = _ref5.trackId, timestamp = _ref5.timestamp;
57626
- responseValues = this.getDefaultPlaylistReponseValues();
57627
- _context6.prev = 2;
57628
- currentUserId = this.userStateManager.getCurrentUserId();
57629
-
57630
- if (!(!playlistId || playlistId === undefined)) {
57631
- _context6.next = 7;
57632
- break;
57633
- }
57634
-
57635
- responseValues.error = 'Missing current playlistId';
57636
- return _context6.abrupt("return", responseValues);
57637
-
57638
- case 7:
57639
- if (currentUserId) {
57640
- _context6.next = 10;
57641
- break;
57642
- }
57643
-
57644
- responseValues.error = 'Missing current user ID';
57645
- return _context6.abrupt("return", responseValues);
57646
-
57647
- case 10:
57648
- userId = parseInt(currentUserId);
57649
- updateAction = Action.UPDATE;
57650
- entityType = EntityType.PLAYLIST;
57651
- this.REQUIRES(Services.CREATOR_NODE);
57652
- _context6.next = 16;
57653
- return this.getFullPlaylist(playlistId, userId);
57654
-
57655
- case 16:
57656
- playlist = _context6.sent;
57657
- existingPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
57658
- updatedTrackIds = existingPlaylistTracks.filter(function (trackObj) {
57659
- var _ref6;
57660
-
57661
- return (_ref6 = trackObj.track !== trackId && timestamp !== trackObj.metadata_time) !== null && _ref6 !== void 0 ? _ref6 : trackObj.time;
57662
- });
57400
+ case 17:
57401
+ trackIds = this.mapTimestamps(playlist.playlist_contents.track_ids);
57663
57402
  metadata = {
57664
- playlist_id: playlistId,
57403
+ playlist_id: playlist.playlist_id,
57665
57404
  playlist_contents: {
57666
- track_ids: updatedTrackIds
57405
+ track_ids: trackIds
57667
57406
  },
57668
57407
  playlist_name: playlist.playlist_name,
57669
- playlist_image_sizes_multihash: playlist.cover_art,
57408
+ playlist_image_sizes_multihash: (_dirCID2 = dirCID) !== null && _dirCID2 !== void 0 ? _dirCID2 : playlist.cover_art_sizes,
57670
57409
  description: playlist.description,
57671
57410
  is_album: playlist.is_album,
57672
57411
  is_private: playlist.is_private
57673
57412
  };
57674
- _context6.next = 22;
57413
+ _context3.next = 21;
57675
57414
  return this.creatorNode.uploadPlaylistMetadata(metadata);
57676
57415
 
57677
- case 22:
57678
- _yield$this$creatorNo4 = _context6.sent;
57679
- metadataMultihash = _yield$this$creatorNo4.metadataMultihash;
57680
- _context6.next = 26;
57416
+ case 21:
57417
+ _yield$this$creatorNo2 = _context3.sent;
57418
+ metadataMultihash = _yield$this$creatorNo2.metadataMultihash;
57419
+ _context3.next = 25;
57681
57420
  return this.manageEntity({
57682
57421
  userId: userId,
57683
57422
  entityType: entityType,
57684
- entityId: playlistId,
57423
+ entityId: playlist.playlist_id,
57685
57424
  action: updateAction,
57686
57425
  metadataMultihash: metadataMultihash
57687
57426
  });
57688
57427
 
57689
- case 26:
57690
- resp = _context6.sent;
57691
- txReceipt = resp.txReceipt;
57692
- responseValues.blockHash = txReceipt.blockHash;
57693
- responseValues.blockNumber = txReceipt.blockNumber;
57694
- responseValues.playlistId = playlistId;
57695
- return _context6.abrupt("return", responseValues);
57696
-
57697
- case 34:
57698
- _context6.prev = 34;
57699
- _context6.t0 = _context6["catch"](2);
57700
- error = _context6.t0.message;
57701
- responseValues.error = error;
57702
- return _context6.abrupt("return", responseValues);
57703
-
57704
- case 39:
57705
- case "end":
57706
- return _context6.stop();
57707
- }
57708
- }
57709
- }, _callee6, this, [[2, 34]]);
57710
- }));
57711
-
57712
- function deletePlaylistTrack(_x7) {
57713
- return _deletePlaylistTrack.apply(this, arguments);
57714
- }
57715
-
57716
- return deletePlaylistTrack;
57717
- }()
57718
- /**
57719
- * Update a playlist using updated data contracts flow
57720
- **/
57721
-
57722
- }, {
57723
- key: "orderPlaylist",
57724
- value: function () {
57725
- var _orderPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(_ref7) {
57726
- var playlistId, trackIds, responseValues, currentUserId, userId, updateAction, entityType, playlist, existingPlaylistTracks, trackIdsWithTimes, trackIdTimes, metadata, _yield$this$creatorNo5, metadataMultihash, resp, txReceipt, error;
57727
-
57728
- return regeneratorRuntime.wrap(function _callee7$(_context7) {
57729
- while (1) {
57730
- switch (_context7.prev = _context7.next) {
57731
- case 0:
57732
- playlistId = _ref7.playlistId, trackIds = _ref7.trackIds;
57733
- responseValues = this.getDefaultPlaylistReponseValues();
57734
- _context7.prev = 2;
57735
- currentUserId = this.userStateManager.getCurrentUserId();
57736
-
57737
- if (!(!playlistId || playlistId === undefined)) {
57738
- _context7.next = 7;
57739
- break;
57740
- }
57741
-
57742
- responseValues.error = 'Missing current playlistId';
57743
- return _context7.abrupt("return", responseValues);
57744
-
57745
- case 7:
57746
- if (currentUserId) {
57747
- _context7.next = 10;
57748
- break;
57749
- }
57750
-
57751
- responseValues.error = 'Missing current user ID';
57752
- return _context7.abrupt("return", responseValues);
57753
-
57754
- case 10:
57755
- userId = parseInt(currentUserId);
57756
- updateAction = Action.UPDATE;
57757
- entityType = EntityType.PLAYLIST;
57758
- this.REQUIRES(Services.CREATOR_NODE);
57759
- _context7.next = 16;
57760
- return this.getFullPlaylist(playlistId, userId);
57761
-
57762
- case 16:
57763
- playlist = _context7.sent;
57764
- existingPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
57765
- trackIdsWithTimes = [];
57766
- trackIdTimes = {};
57767
- existingPlaylistTracks.forEach(function (trackObj) {
57768
- var _trackObj$metadata_ti2;
57769
-
57770
- var trackId = trackObj.track;
57771
- var timestamp = (_trackObj$metadata_ti2 = trackObj.metadata_time) !== null && _trackObj$metadata_ti2 !== void 0 ? _trackObj$metadata_ti2 : trackObj.time;
57772
-
57773
- if (trackId in trackIdTimes) {
57774
- trackIdTimes[trackId].push(timestamp);
57775
- } else {
57776
- trackIdTimes[trackId] = [timestamp];
57777
- }
57778
- }); // new tracks default to currentBlock timestamp
57779
-
57780
- trackIdsWithTimes = trackIds.map(function (trackId) {
57781
- return {
57782
- track: trackId,
57783
- time: trackIdTimes[trackId].pop()
57784
- };
57785
- });
57786
- metadata = {
57787
- playlist_id: playlistId,
57788
- playlist_contents: {
57789
- track_ids: trackIdsWithTimes
57790
- },
57791
- playlist_name: playlist.playlist_name,
57792
- playlist_image_sizes_multihash: playlist.cover_art,
57793
- description: playlist.description,
57794
- is_album: playlist.is_album,
57795
- is_private: playlist.is_private
57796
- };
57797
- _context7.next = 25;
57798
- return this.creatorNode.uploadPlaylistMetadata(metadata);
57799
-
57800
57428
  case 25:
57801
- _yield$this$creatorNo5 = _context7.sent;
57802
- metadataMultihash = _yield$this$creatorNo5.metadataMultihash;
57803
- _context7.next = 29;
57804
- return this.manageEntity({
57805
- userId: userId,
57806
- entityType: entityType,
57807
- entityId: playlistId,
57808
- action: updateAction,
57809
- metadataMultihash: metadataMultihash
57810
- });
57811
-
57812
- case 29:
57813
- resp = _context7.sent;
57429
+ resp = _context3.sent;
57814
57430
  txReceipt = resp.txReceipt;
57815
57431
  responseValues.blockHash = txReceipt.blockHash;
57816
57432
  responseValues.blockNumber = txReceipt.blockNumber;
57817
- responseValues.playlistId = playlistId;
57818
- return _context7.abrupt("return", responseValues);
57433
+ return _context3.abrupt("return", responseValues);
57819
57434
 
57820
- case 37:
57821
- _context7.prev = 37;
57822
- _context7.t0 = _context7["catch"](2);
57823
- error = _context7.t0.message;
57435
+ case 32:
57436
+ _context3.prev = 32;
57437
+ _context3.t0 = _context3["catch"](1);
57438
+ error = _context3.t0.message;
57824
57439
  responseValues.error = error;
57825
- return _context7.abrupt("return", responseValues);
57440
+ return _context3.abrupt("return", responseValues);
57826
57441
 
57827
- case 42:
57442
+ case 37:
57828
57443
  case "end":
57829
- return _context7.stop();
57444
+ return _context3.stop();
57830
57445
  }
57831
57446
  }
57832
- }, _callee7, this, [[2, 37]]);
57447
+ }, _callee3, this, [[1, 32]]);
57833
57448
  }));
57834
57449
 
57835
- function orderPlaylist(_x8) {
57836
- return _orderPlaylist.apply(this, arguments);
57450
+ function updatePlaylist(_x3) {
57451
+ return _updatePlaylist.apply(this, arguments);
57837
57452
  }
57838
57453
 
57839
- return orderPlaylist;
57454
+ return updatePlaylist;
57840
57455
  }()
57841
57456
  /**
57842
57457
  * Manage an entity with the updated data contract flow
@@ -57846,44 +57461,44 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57846
57461
  }, {
57847
57462
  key: "manageEntity",
57848
57463
  value: function () {
57849
- var _manageEntity = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(_ref8) {
57464
+ var _manageEntity = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref) {
57850
57465
  var userId, entityType, entityId, action, metadataMultihash, error, resp, _this$contracts$Entit;
57851
57466
 
57852
- return regeneratorRuntime.wrap(function _callee8$(_context8) {
57467
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
57853
57468
  while (1) {
57854
- switch (_context8.prev = _context8.next) {
57469
+ switch (_context4.prev = _context4.next) {
57855
57470
  case 0:
57856
- userId = _ref8.userId, entityType = _ref8.entityType, entityId = _ref8.entityId, action = _ref8.action, metadataMultihash = _ref8.metadataMultihash;
57471
+ userId = _ref.userId, entityType = _ref.entityType, entityId = _ref.entityId, action = _ref.action, metadataMultihash = _ref.metadataMultihash;
57857
57472
  error = null;
57858
- _context8.prev = 2;
57859
- _context8.next = 5;
57473
+ _context4.prev = 2;
57474
+ _context4.next = 5;
57860
57475
  return (_this$contracts$Entit = this.contracts.EntityManagerClient) === null || _this$contracts$Entit === void 0 ? void 0 : _this$contracts$Entit.manageEntity(userId, entityType, entityId, action, metadataMultihash);
57861
57476
 
57862
57477
  case 5:
57863
- resp = _context8.sent;
57864
- return _context8.abrupt("return", {
57478
+ resp = _context4.sent;
57479
+ return _context4.abrupt("return", {
57865
57480
  txReceipt: resp.txReceipt,
57866
57481
  error: error
57867
57482
  });
57868
57483
 
57869
57484
  case 9:
57870
- _context8.prev = 9;
57871
- _context8.t0 = _context8["catch"](2);
57872
- error = _context8.t0.message;
57873
- return _context8.abrupt("return", {
57485
+ _context4.prev = 9;
57486
+ _context4.t0 = _context4["catch"](2);
57487
+ error = _context4.t0.message;
57488
+ return _context4.abrupt("return", {
57874
57489
  txReceipt: null,
57875
57490
  error: error
57876
57491
  });
57877
57492
 
57878
57493
  case 13:
57879
57494
  case "end":
57880
- return _context8.stop();
57495
+ return _context4.stop();
57881
57496
  }
57882
57497
  }
57883
- }, _callee8, this, [[2, 9]]);
57498
+ }, _callee4, this, [[2, 9]]);
57884
57499
  }));
57885
57500
 
57886
- function manageEntity(_x9) {
57501
+ function manageEntity(_x4) {
57887
57502
  return _manageEntity.apply(this, arguments);
57888
57503
  }
57889
57504