@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/index.esm.js CHANGED
@@ -22,7 +22,7 @@ import { Transaction } from 'ethereumjs-tx';
22
22
  import * as AudiusData from '@audius/anchor-audius-data';
23
23
  import { idl } from '@audius/anchor-audius-data';
24
24
  import anchor, { ProgramError, BN as BN$1 } from '@project-serum/anchor';
25
- import solanaWeb3, { PublicKey, SYSVAR_RENT_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SystemProgram, Secp256k1Program, TransactionInstruction, Keypair, Transaction as Transaction$1 } from '@solana/web3.js';
25
+ import solanaWeb3, { PublicKey, SYSVAR_RENT_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SystemProgram, Secp256k1Program, TransactionInstruction, Keypair, Transaction as Transaction$1, Connection } from '@solana/web3.js';
26
26
  import splToken, { ASSOCIATED_TOKEN_PROGRAM_ID, Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';
27
27
  import borsh from 'borsh';
28
28
  import BN from 'bn.js';
@@ -33409,9 +33409,9 @@ var formatProviders = function formatProviders(providers) {
33409
33409
  };
33410
33410
 
33411
33411
  var name = "@audius/sdk";
33412
- var version = "0.0.35";
33412
+ var version = "0.0.38";
33413
33413
  var audius = {
33414
- releaseSHA: "87ed35aa1374bdcf5632ef58ce55efbdd4031b03"
33414
+ releaseSHA: "74503074cb96dea181ec2b218c5cb6d528c1db86"
33415
33415
  };
33416
33416
  var description = "";
33417
33417
  var main = "dist/index.cjs.js";
@@ -33507,6 +33507,7 @@ var devDependencies = {
33507
33507
  "@types/expect": "24.3.0",
33508
33508
  "@types/form-data": "^2.5.0",
33509
33509
  "@types/hashids": "2.0.1",
33510
+ "@types/lodash": "4.14.149",
33510
33511
  "@types/mocha": "9.1.0",
33511
33512
  "@types/node-localstorage": "1.3.0",
33512
33513
  "@types/pify": "^5.0.1",
@@ -35919,7 +35920,7 @@ var SolanaWeb3Manager = /*#__PURE__*/function () {
35919
35920
  case 0:
35920
35921
  _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;
35921
35922
  this.solanaClusterEndpoint = solanaClusterEndpoint;
35922
- this.connection = new solanaWeb3.Connection(this.solanaClusterEndpoint, {
35923
+ this.connection = new Connection(this.solanaClusterEndpoint, {
35923
35924
  confirmTransactionInitialTimeout: confirmationTimeout || DEFAULT_CONNECTION_CONFIRMATION_TIMEOUT_MS
35924
35925
  });
35925
35926
  this.transactionHandler = new TransactionHandler({
@@ -35979,9 +35980,8 @@ var SolanaWeb3Manager = /*#__PURE__*/function () {
35979
35980
  this.audiusDataIdl = audiusDataIdl || idl;
35980
35981
 
35981
35982
  if (this.audiusDataProgramId && this.audiusDataAdminStorageKeypairPublicKey && this.audiusDataIdl) {
35982
- connection = new solanaWeb3.Connection(this.solanaClusterEndpoint, anchor.AnchorProvider.defaultOptions());
35983
- anchorProvider = new anchor.AnchorProvider(connection, // @ts-expect-error weirdness with 3rd party types
35984
- solanaWeb3.Keypair.generate(), anchor.AnchorProvider.defaultOptions());
35983
+ connection = new Connection(this.solanaClusterEndpoint, anchor.AnchorProvider.defaultOptions());
35984
+ anchorProvider = new anchor.AnchorProvider(connection, Keypair.generate(), anchor.AnchorProvider.defaultOptions());
35985
35985
  this.anchorProgram = new anchor.Program(this.audiusDataIdl, audiusDataProgramId, anchorProvider);
35986
35986
  }
35987
35987
 
@@ -37023,7 +37023,7 @@ var Base = /*#__PURE__*/function () {
37023
37023
  return Base;
37024
37024
  }();
37025
37025
 
37026
- var decodeHashId$2 = Utils.decodeHashId;
37026
+ var decodeHashId$1 = Utils.decodeHashId;
37027
37027
  var GetAttestationError = Object.freeze({
37028
37028
  CHALLENGE_INCOMPLETE: 'CHALLENGE_INCOMPLETE',
37029
37029
  ALREADY_DISBURSED: 'ALREADY_DISBURSED',
@@ -37108,7 +37108,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37108
37108
 
37109
37109
  case 7:
37110
37110
  // Aggregate
37111
- logger.info("submitAndEvaluate: aggregating attestations for userId [".concat(decodeHashId$2(encodedUserId), "], challengeId [").concat(challengeId, "]"));
37111
+ logger.info("submitAndEvaluate: aggregating attestations for userId [".concat(decodeHashId$1(encodedUserId), "], challengeId [").concat(challengeId, "]"));
37112
37112
  phase = AttestationPhases.AGGREGATE_ATTESTATIONS;
37113
37113
  _context.next = 11;
37114
37114
  return this.aggregateAttestations({
@@ -37144,7 +37144,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37144
37144
 
37145
37145
  case 21:
37146
37146
  // Submit
37147
- 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."));
37147
+ 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."));
37148
37148
  fullTokenAmount = new BN(amount * WRAPPED_AUDIO_PRECISION);
37149
37149
  phase = AttestationPhases.SUBMIT_ATTESTATIONS; // @ts-expect-error the return types are a bit strange here
37150
37150
 
@@ -37182,7 +37182,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37182
37182
  break;
37183
37183
  }
37184
37184
 
37185
- logger.warn("submitAndEvaluate: saw repeat senders for userId [".concat(decodeHashId$2(encodedUserId), "] challengeId: [").concat(challengeId, "] with err: ").concat(submitErrorCode, ", breaking up into individual transactions"));
37185
+ logger.warn("submitAndEvaluate: saw repeat senders for userId [".concat(decodeHashId$1(encodedUserId), "] challengeId: [").concat(challengeId, "] with err: ").concat(submitErrorCode, ", breaking up into individual transactions"));
37186
37186
  _context.next = 35;
37187
37187
  return this.solanaWeb3Manager.submitChallengeAttestations({
37188
37188
  attestations: discoveryNodeAttestations,
@@ -37205,7 +37205,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37205
37205
 
37206
37206
  case 38:
37207
37207
  // Evaluate
37208
- logger.info("submitAndEvaluate: evaluating for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$2(encodedUserId), "]"));
37208
+ logger.info("submitAndEvaluate: evaluating for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "]"));
37209
37209
  phase = AttestationPhases.EVALUATE_ATTESTATIONS;
37210
37210
  _context.next = 42;
37211
37211
  return this.solanaWeb3Manager.evaluateChallengeAttestations({
@@ -37244,7 +37244,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37244
37244
  _context.t0 = _context["catch"](3);
37245
37245
  err = _context.t0.message;
37246
37246
  log = err === GetAttestationError.COGNITO_FLOW || err === GetAttestationError.HCAPTCHA ? logger.info : logger.error;
37247
- log("submitAndEvaluate: failed for userId: [".concat(decodeHashId$2(encodedUserId), "] challenge-id [").concat(challengeId, "] at phase [").concat(phase, "] with err: ").concat(err));
37247
+ log("submitAndEvaluate: failed for userId: [".concat(decodeHashId$1(encodedUserId), "] challenge-id [").concat(challengeId, "] at phase [").concat(phase, "] with err: ").concat(err));
37248
37248
  return _context.abrupt("return", {
37249
37249
  success: false,
37250
37250
  error: err,
@@ -37359,7 +37359,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37359
37359
  _context2.prev = 25;
37360
37360
  _context2.t0 = _context2["catch"](13);
37361
37361
  err = _context2.t0.message;
37362
- logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$2(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(err));
37362
+ logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$1(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(err));
37363
37363
  return _context2.abrupt("return", {
37364
37364
  discoveryNodeAttestations: null,
37365
37365
  aaoAttestation: null,
@@ -37422,7 +37422,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37422
37422
  _context2.prev = 43;
37423
37423
  _context2.t1 = _context2["catch"](30);
37424
37424
  _err = _context2.t1.message;
37425
- logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$2(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(_err));
37425
+ logger.error("Failed to aggregate attestations for user [".concat(decodeHashId$1(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(_err));
37426
37426
  return _context2.abrupt("return", {
37427
37427
  discoveryNodeAttestations: null,
37428
37428
  aaoAttestation: null,
@@ -37480,7 +37480,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37480
37480
  _context3.prev = 10;
37481
37481
  _context3.t0 = _context3["catch"](2);
37482
37482
  err = _context3.t0.message;
37483
- logger.error("Failed to get challenge attestation for userId [".concat(decodeHashId$2(encodedUserId), "] challengeId [").concat(challengeId, "]from ").concat(discoveryProviderEndpoint, " with ").concat(err));
37483
+ logger.error("Failed to get challenge attestation for userId [".concat(decodeHashId$1(encodedUserId), "] challengeId [").concat(challengeId, "]from ").concat(discoveryProviderEndpoint, " with ").concat(err));
37484
37484
  mappedErr = GetAttestationError[err] || GetAttestationError.DISCOVERY_NODE_UNKNOWN_RESPONSE;
37485
37485
  return _context3.abrupt("return", {
37486
37486
  success: null,
@@ -37753,9 +37753,9 @@ var Rewards = /*#__PURE__*/function (_Base) {
37753
37753
 
37754
37754
  case 16:
37755
37755
  if (needsAttestations.length || unrecoverableError) {
37756
- logger.info("Failed to aggregate attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$2(encodedUserId), "]"));
37756
+ logger.info("Failed to aggregate attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "]"));
37757
37757
  } else {
37758
- logger.info("Successfully aggregated attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$2(encodedUserId), "]"));
37758
+ logger.info("Successfully aggregated attestations for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId$1(encodedUserId), "]"));
37759
37759
  }
37760
37760
 
37761
37761
  return _context7.abrupt("return", completedAttestations);
@@ -37980,7 +37980,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
37980
37980
  return Rewards;
37981
37981
  }(Base);
37982
37982
 
37983
- var decodeHashId$1 = Utils.decodeHashId; // `BaseRewardsReporter` is intended to be subclassed, and provides
37983
+ var decodeHashId = Utils.decodeHashId; // `BaseRewardsReporter` is intended to be subclassed, and provides
37984
37984
  // "reporting" functionality to RewardsAttester (i.e. posts to Slack if something notable happens)
37985
37985
 
37986
37986
  var BaseRewardsReporter = /*#__PURE__*/function () {
@@ -38984,7 +38984,7 @@ var RewardsAttester = /*#__PURE__*/function () {
38984
38984
  switch (_context17.prev = _context17.next) {
38985
38985
  case 0:
38986
38986
  challengeId = _ref9.challengeId, userId = _ref9.userId, specifier = _ref9.specifier, amount = _ref9.amount, handle = _ref9.handle, wallet = _ref9.wallet, completedBlocknumber = _ref9.completedBlocknumber;
38987
- this.logger.info("Attempting to attest for userId [".concat(decodeHashId$1(userId), "], challengeId: [").concat(challengeId, "], quorum size: [").concat(this.quorumSize, "]}"));
38987
+ this.logger.info("Attempting to attest for userId [".concat(decodeHashId(userId), "], challengeId: [").concat(challengeId, "], quorum size: [").concat(this.quorumSize, "]}"));
38988
38988
  _context17.next = 4;
38989
38989
  return this.libs.Rewards.submitAndEvaluate({
38990
38990
  challengeId: challengeId,
@@ -39015,7 +39015,7 @@ var RewardsAttester = /*#__PURE__*/function () {
39015
39015
  break;
39016
39016
  }
39017
39017
 
39018
- this.logger.info("Successfully attestested for challenge [".concat(challengeId, "] for user [").concat(decodeHashId$1(userId), "], amount [").concat(amount, "]!"));
39018
+ this.logger.info("Successfully attestested for challenge [".concat(challengeId, "] for user [").concat(decodeHashId(userId), "], amount [").concat(amount, "]!"));
39019
39019
  return _context17.abrupt("return", {
39020
39020
  challengeId: challengeId,
39021
39021
  userId: userId,
@@ -39029,7 +39029,7 @@ var RewardsAttester = /*#__PURE__*/function () {
39029
39029
 
39030
39030
  case 13:
39031
39031
  // Handle error path
39032
- 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, "]"));
39032
+ 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, "]"));
39033
39033
  return _context17.abrupt("return", {
39034
39034
  challengeId: challengeId,
39035
39035
  userId: userId,
@@ -39287,7 +39287,7 @@ var RewardsAttester = /*#__PURE__*/function () {
39287
39287
  successful.push(res);
39288
39288
 
39289
39289
  _this5.reporter.reportSuccess({
39290
- userId: (_decodeHashId = decodeHashId$1(res.userId)) !== null && _decodeHashId !== void 0 ? _decodeHashId : -1,
39290
+ userId: (_decodeHashId = decodeHashId(res.userId)) !== null && _decodeHashId !== void 0 ? _decodeHashId : -1,
39291
39291
  challengeId: res.challengeId,
39292
39292
  amount: res.amount,
39293
39293
  specifier: res.specifier
@@ -39308,7 +39308,7 @@ var RewardsAttester = /*#__PURE__*/function () {
39308
39308
  var _decodeHashId2;
39309
39309
 
39310
39310
  var report = {
39311
- userId: (_decodeHashId2 = decodeHashId$1(res.userId)) !== null && _decodeHashId2 !== void 0 ? _decodeHashId2 : -1,
39311
+ userId: (_decodeHashId2 = decodeHashId(res.userId)) !== null && _decodeHashId2 !== void 0 ? _decodeHashId2 : -1,
39312
39312
  challengeId: res.challengeId,
39313
39313
  amount: res.amount,
39314
39314
  error: res.error,
@@ -57079,15 +57079,13 @@ var EntityType;
57079
57079
  (function (EntityType) {
57080
57080
  EntityType["PLAYLIST"] = "Playlist";
57081
57081
  })(EntityType || (EntityType = {}));
57082
-
57083
- var encodeHashId = Utils.encodeHashId,
57084
- decodeHashId = Utils.decodeHashId;
57085
57082
  /*
57086
57083
  API surface for updated data contract interactions.
57087
57084
  Provides simplified entity management in a generic fashion
57088
57085
  Handles metadata + file upload etc. for entities such as Playlist/Track/User
57089
57086
  */
57090
57087
 
57088
+
57091
57089
  var EntityManager = /*#__PURE__*/function (_Base) {
57092
57090
  _inherits(EntityManager, _Base);
57093
57091
 
@@ -57111,46 +57109,15 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57111
57109
  return Math.floor(Math.random() * (max - min) + min);
57112
57110
  }
57113
57111
  }, {
57114
- key: "getFullPlaylist",
57115
- value: function () {
57116
- var _getFullPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(playlistId, userId) {
57117
- var encodedPlaylistId, encodedUserId, playlist;
57118
- return regeneratorRuntime.wrap(function _callee$(_context) {
57119
- while (1) {
57120
- switch (_context.prev = _context.next) {
57121
- case 0:
57122
- encodedPlaylistId = encodeHashId(playlistId);
57123
- encodedUserId = encodeHashId(userId);
57124
- _context.next = 4;
57125
- return this.discoveryProvider.getFullPlaylist(encodedPlaylistId, encodedUserId);
57126
-
57127
- case 4:
57128
- playlist = _context.sent[0];
57129
- return _context.abrupt("return", playlist);
57130
-
57131
- case 6:
57132
- case "end":
57133
- return _context.stop();
57134
- }
57135
- }
57136
- }, _callee, this);
57137
- }));
57138
-
57139
- function getFullPlaylist(_x, _x2) {
57140
- return _getFullPlaylist.apply(this, arguments);
57141
- }
57142
-
57143
- return getFullPlaylist;
57144
- }()
57145
- }, {
57146
- key: "mapAddedTimestamps",
57147
- value: function mapAddedTimestamps(addedTimestamps) {
57112
+ key: "mapTimestamps",
57113
+ value: function mapTimestamps(addedTimestamps) {
57148
57114
  var trackIds = addedTimestamps.map(function (trackObj) {
57149
57115
  var _trackObj$metadata_ti;
57150
57116
 
57151
57117
  return {
57152
- track: decodeHashId(trackObj.track_id),
57153
- time: (_trackObj$metadata_ti = trackObj.metadata_timestamp) !== null && _trackObj$metadata_ti !== void 0 ? _trackObj$metadata_ti : trackObj.timestamp
57118
+ track: trackObj.track,
57119
+ time: (_trackObj$metadata_ti = trackObj.metadata_time) !== null && _trackObj$metadata_ti !== void 0 ? _trackObj$metadata_ti : trackObj.time // default to time for legacy playlists
57120
+
57154
57121
  };
57155
57122
  });
57156
57123
  return trackIds;
@@ -57165,7 +57132,6 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57165
57132
  return {
57166
57133
  blockHash: null,
57167
57134
  blockNumber: null,
57168
- playlistId: null,
57169
57135
  error: null
57170
57136
  };
57171
57137
  }
@@ -57176,105 +57142,94 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57176
57142
  }, {
57177
57143
  key: "createPlaylist",
57178
57144
  value: function () {
57179
- var _createPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref) {
57180
- 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;
57145
+ var _createPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(playlist) {
57146
+ var responseValues, _playlist$artwork, _dirCID, userId, createAction, entityType, dirCID, updatedPlaylistImage, tracks, metadata, _yield$this$creatorNo, metadataMultihash, manageEntityResponse, txReceipt, error;
57181
57147
 
57182
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
57148
+ return regeneratorRuntime.wrap(function _callee$(_context) {
57183
57149
  while (1) {
57184
- switch (_context2.prev = _context2.next) {
57150
+ switch (_context.prev = _context.next) {
57185
57151
  case 0:
57186
- playlistId = _ref.playlistId, playlistName = _ref.playlistName, trackIds = _ref.trackIds, description = _ref.description, isAlbum = _ref.isAlbum, isPrivate = _ref.isPrivate, coverArt = _ref.coverArt;
57187
57152
  responseValues = this.getDefaultPlaylistReponseValues();
57188
- _context2.prev = 2;
57189
- currentUserId = this.userStateManager.getCurrentUserId();
57153
+ _context.prev = 1;
57154
+ userId = this.userStateManager.getCurrentUserId();
57190
57155
 
57191
- if (currentUserId) {
57192
- _context2.next = 7;
57156
+ if (userId) {
57157
+ _context.next = 6;
57193
57158
  break;
57194
57159
  }
57195
57160
 
57196
57161
  responseValues.error = 'Missing current user ID';
57197
- return _context2.abrupt("return", responseValues);
57162
+ return _context.abrupt("return", responseValues);
57198
57163
 
57199
- case 7:
57200
- userId = parseInt(currentUserId);
57164
+ case 6:
57201
57165
  createAction = Action.CREATE;
57202
57166
  entityType = EntityType.PLAYLIST;
57203
57167
  this.REQUIRES(Services.CREATOR_NODE);
57204
- _context2.next = 13;
57205
- return this.creatorNode.uploadImage(coverArt, true // square
57206
- );
57207
57168
 
57208
- case 13:
57209
- updatedPlaylistImage = _context2.sent;
57210
- web3 = this.web3Manager.getWeb3();
57211
- _context2.next = 17;
57212
- return web3.eth.getBlockNumber();
57169
+ if (!(playlist !== null && playlist !== void 0 && (_playlist$artwork = playlist.artwork) !== null && _playlist$artwork !== void 0 && _playlist$artwork.file)) {
57170
+ _context.next = 14;
57171
+ break;
57172
+ }
57213
57173
 
57214
- case 17:
57215
- currentBlockNumber = _context2.sent;
57216
- _context2.next = 20;
57217
- return web3.eth.getBlock(currentBlockNumber);
57174
+ _context.next = 12;
57175
+ return this.creatorNode.uploadImage(playlist.artwork.file, true // square
57176
+ );
57218
57177
 
57219
- case 20:
57220
- currentBlock = _context2.sent;
57221
- tracks = trackIds.map(function (trackId) {
57222
- return {
57223
- track: trackId,
57224
- time: currentBlock.timestamp
57225
- };
57226
- });
57178
+ case 12:
57179
+ updatedPlaylistImage = _context.sent;
57227
57180
  dirCID = updatedPlaylistImage.dirCID;
57181
+
57182
+ case 14:
57183
+ tracks = this.mapTimestamps(playlist.playlist_contents.track_ids);
57228
57184
  metadata = {
57229
- playlist_id: playlistId,
57185
+ playlist_id: playlist.playlist_id,
57230
57186
  playlist_contents: {
57231
57187
  track_ids: tracks
57232
57188
  },
57233
- playlist_name: playlistName,
57234
- playlist_image_sizes_multihash: dirCID,
57235
- description: description,
57236
- is_album: isAlbum,
57237
- is_private: isPrivate
57189
+ playlist_name: playlist.playlist_name,
57190
+ playlist_image_sizes_multihash: (_dirCID = dirCID) !== null && _dirCID !== void 0 ? _dirCID : playlist.cover_art_sizes,
57191
+ description: playlist.description,
57192
+ is_album: playlist.is_album,
57193
+ is_private: playlist.is_private
57238
57194
  };
57239
- _context2.next = 26;
57195
+ _context.next = 18;
57240
57196
  return this.creatorNode.uploadPlaylistMetadata(metadata);
57241
57197
 
57242
- case 26:
57243
- _yield$this$creatorNo = _context2.sent;
57198
+ case 18:
57199
+ _yield$this$creatorNo = _context.sent;
57244
57200
  metadataMultihash = _yield$this$creatorNo.metadataMultihash;
57245
- _context2.next = 30;
57201
+ _context.next = 22;
57246
57202
  return this.manageEntity({
57247
57203
  userId: userId,
57248
57204
  entityType: entityType,
57249
- entityId: playlistId,
57205
+ entityId: playlist.playlist_id,
57250
57206
  action: createAction,
57251
57207
  metadataMultihash: metadataMultihash
57252
57208
  });
57253
57209
 
57254
- case 30:
57255
- manageEntityResponse = _context2.sent;
57210
+ case 22:
57211
+ manageEntityResponse = _context.sent;
57256
57212
  txReceipt = manageEntityResponse.txReceipt;
57257
57213
  responseValues.blockHash = txReceipt.blockHash;
57258
57214
  responseValues.blockNumber = txReceipt.blockNumber;
57259
- responseValues.playlistId = playlistId;
57260
- return _context2.abrupt("return", responseValues);
57215
+ return _context.abrupt("return", responseValues);
57261
57216
 
57262
- case 38:
57263
- _context2.prev = 38;
57264
- _context2.t0 = _context2["catch"](2);
57265
- error = _context2.t0.message;
57217
+ case 29:
57218
+ _context.prev = 29;
57219
+ _context.t0 = _context["catch"](1);
57220
+ error = _context.t0.message;
57266
57221
  responseValues.error = error;
57267
- return _context2.abrupt("return", responseValues);
57222
+ return _context.abrupt("return", responseValues);
57268
57223
 
57269
- case 43:
57224
+ case 34:
57270
57225
  case "end":
57271
- return _context2.stop();
57226
+ return _context.stop();
57272
57227
  }
57273
57228
  }
57274
- }, _callee2, this, [[2, 38]]);
57229
+ }, _callee, this, [[1, 29]]);
57275
57230
  }));
57276
57231
 
57277
- function createPlaylist(_x3) {
57232
+ function createPlaylist(_x) {
57278
57233
  return _createPlaylist.apply(this, arguments);
57279
57234
  }
57280
57235
 
@@ -57287,29 +57242,26 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57287
57242
  }, {
57288
57243
  key: "deletePlaylist",
57289
57244
  value: function () {
57290
- var _deletePlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref2) {
57291
- var playlistId, responseValues, currentUserId, userId, resp, txReceipt, error;
57292
-
57293
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
57245
+ var _deletePlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(playlistId) {
57246
+ var responseValues, userId, resp, txReceipt, error;
57247
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
57294
57248
  while (1) {
57295
- switch (_context3.prev = _context3.next) {
57249
+ switch (_context2.prev = _context2.next) {
57296
57250
  case 0:
57297
- playlistId = _ref2.playlistId;
57298
57251
  responseValues = this.getDefaultPlaylistReponseValues();
57299
- currentUserId = this.userStateManager.getCurrentUserId();
57252
+ userId = this.userStateManager.getCurrentUserId();
57300
57253
 
57301
- if (currentUserId) {
57302
- _context3.next = 6;
57254
+ if (userId) {
57255
+ _context2.next = 5;
57303
57256
  break;
57304
57257
  }
57305
57258
 
57306
57259
  responseValues.error = 'Missing current user ID';
57307
- return _context3.abrupt("return", responseValues);
57260
+ return _context2.abrupt("return", responseValues);
57308
57261
 
57309
- case 6:
57310
- userId = parseInt(currentUserId);
57311
- _context3.prev = 7;
57312
- _context3.next = 10;
57262
+ case 5:
57263
+ _context2.prev = 5;
57264
+ _context2.next = 8;
57313
57265
  return this.manageEntity({
57314
57266
  userId: userId,
57315
57267
  entityType: EntityType.PLAYLIST,
@@ -57318,30 +57270,29 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57318
57270
  metadataMultihash: ''
57319
57271
  });
57320
57272
 
57321
- case 10:
57322
- resp = _context3.sent;
57273
+ case 8:
57274
+ resp = _context2.sent;
57323
57275
  txReceipt = resp.txReceipt;
57324
57276
  responseValues.blockHash = txReceipt.blockHash;
57325
57277
  responseValues.blockNumber = txReceipt.blockNumber;
57326
- responseValues.playlistId = playlistId;
57327
- return _context3.abrupt("return", responseValues);
57278
+ return _context2.abrupt("return", responseValues);
57328
57279
 
57329
- case 18:
57330
- _context3.prev = 18;
57331
- _context3.t0 = _context3["catch"](7);
57332
- error = _context3.t0.message;
57280
+ case 15:
57281
+ _context2.prev = 15;
57282
+ _context2.t0 = _context2["catch"](5);
57283
+ error = _context2.t0.message;
57333
57284
  responseValues.error = error;
57334
- return _context3.abrupt("return", responseValues);
57285
+ return _context2.abrupt("return", responseValues);
57335
57286
 
57336
- case 23:
57287
+ case 20:
57337
57288
  case "end":
57338
- return _context3.stop();
57289
+ return _context2.stop();
57339
57290
  }
57340
57291
  }
57341
- }, _callee3, this, [[7, 18]]);
57292
+ }, _callee2, this, [[5, 15]]);
57342
57293
  }));
57343
57294
 
57344
- function deletePlaylist(_x4) {
57295
+ function deletePlaylist(_x2) {
57345
57296
  return _deletePlaylist.apply(this, arguments);
57346
57297
  }
57347
57298
 
@@ -57349,448 +57300,112 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57349
57300
  }()
57350
57301
  /**
57351
57302
  * Update a playlist using updated data contracts flow
57352
- **/
57303
+ */
57353
57304
 
57354
57305
  }, {
57355
- key: "editPlaylist",
57306
+ key: "updatePlaylist",
57356
57307
  value: function () {
57357
- var _editPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref3) {
57358
- 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;
57308
+ var _updatePlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(playlist) {
57309
+ var responseValues, _playlist$artwork2, _dirCID2, userId, updateAction, entityType, dirCID, updatedPlaylistImage, trackIds, metadata, _yield$this$creatorNo2, metadataMultihash, resp, txReceipt, error;
57359
57310
 
57360
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
57311
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
57361
57312
  while (1) {
57362
- switch (_context4.prev = _context4.next) {
57313
+ switch (_context3.prev = _context3.next) {
57363
57314
  case 0:
57364
- playlistId = _ref3.playlistId, playlistName = _ref3.playlistName, description = _ref3.description, isAlbum = _ref3.isAlbum, isPrivate = _ref3.isPrivate, coverArt = _ref3.coverArt;
57365
57315
  responseValues = this.getDefaultPlaylistReponseValues();
57366
- _context4.prev = 2;
57367
- currentUserId = this.userStateManager.getCurrentUserId();
57316
+ _context3.prev = 1;
57317
+ userId = this.userStateManager.getCurrentUserId();
57368
57318
 
57369
- if (!(!playlistId || playlistId === undefined)) {
57370
- _context4.next = 7;
57319
+ if (!(!playlist || playlist === undefined)) {
57320
+ _context3.next = 6;
57371
57321
  break;
57372
57322
  }
57373
57323
 
57374
- responseValues.error = 'Missing current playlistId';
57375
- return _context4.abrupt("return", responseValues);
57324
+ responseValues.error = 'Missing current playlist';
57325
+ return _context3.abrupt("return", responseValues);
57376
57326
 
57377
- case 7:
57378
- if (currentUserId) {
57379
- _context4.next = 10;
57327
+ case 6:
57328
+ if (userId) {
57329
+ _context3.next = 9;
57380
57330
  break;
57381
57331
  }
57382
57332
 
57383
57333
  responseValues.error = 'Missing current user ID';
57384
- return _context4.abrupt("return", responseValues);
57334
+ return _context3.abrupt("return", responseValues);
57385
57335
 
57386
- case 10:
57387
- userId = parseInt(currentUserId);
57336
+ case 9:
57388
57337
  updateAction = Action.UPDATE;
57389
57338
  entityType = EntityType.PLAYLIST;
57390
57339
  this.REQUIRES(Services.CREATOR_NODE);
57391
57340
 
57392
- if (!coverArt) {
57393
- _context4.next = 19;
57341
+ if (!(playlist !== null && playlist !== void 0 && (_playlist$artwork2 = playlist.artwork) !== null && _playlist$artwork2 !== void 0 && _playlist$artwork2.file)) {
57342
+ _context3.next = 17;
57394
57343
  break;
57395
57344
  }
57396
57345
 
57397
- _context4.next = 17;
57398
- return this.creatorNode.uploadImage(coverArt, true // square
57346
+ _context3.next = 15;
57347
+ return this.creatorNode.uploadImage(playlist.artwork.file, true // square
57399
57348
  );
57400
57349
 
57401
- case 17:
57402
- updatedPlaylistImage = _context4.sent;
57350
+ case 15:
57351
+ updatedPlaylistImage = _context3.sent;
57403
57352
  dirCID = updatedPlaylistImage.dirCID;
57404
57353
 
57405
- case 19:
57406
- _context4.next = 21;
57407
- return this.getFullPlaylist(playlistId, userId);
57408
-
57409
- case 21:
57410
- playlist = _context4.sent;
57411
- existingPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
57412
- metadata = {
57413
- playlist_id: playlistId,
57414
- playlist_contents: {
57415
- track_ids: existingPlaylistTracks
57416
- },
57417
- playlist_name: playlistName !== null && playlistName !== void 0 ? playlistName : playlist.playlist_name,
57418
- playlist_image_sizes_multihash: (_dirCID = dirCID) !== null && _dirCID !== void 0 ? _dirCID : playlist.cover_art,
57419
- description: description !== null && description !== void 0 ? description : playlist.description,
57420
- is_album: isAlbum !== null && isAlbum !== void 0 ? isAlbum : playlist.is_album,
57421
- is_private: isPrivate !== null && isPrivate !== void 0 ? isPrivate : playlist.is_private
57422
- };
57423
- _context4.next = 26;
57424
- return this.creatorNode.uploadPlaylistMetadata(metadata);
57425
-
57426
- case 26:
57427
- _yield$this$creatorNo2 = _context4.sent;
57428
- metadataMultihash = _yield$this$creatorNo2.metadataMultihash;
57429
- _context4.next = 30;
57430
- return this.manageEntity({
57431
- userId: userId,
57432
- entityType: entityType,
57433
- entityId: playlistId,
57434
- action: updateAction,
57435
- metadataMultihash: metadataMultihash
57436
- });
57437
-
57438
- case 30:
57439
- resp = _context4.sent;
57440
- txReceipt = resp.txReceipt;
57441
- responseValues.blockHash = txReceipt.blockHash;
57442
- responseValues.blockNumber = txReceipt.blockNumber;
57443
- responseValues.playlistId = playlistId;
57444
- return _context4.abrupt("return", responseValues);
57445
-
57446
- case 38:
57447
- _context4.prev = 38;
57448
- _context4.t0 = _context4["catch"](2);
57449
- error = _context4.t0.message;
57450
- responseValues.error = error;
57451
- return _context4.abrupt("return", responseValues);
57452
-
57453
- case 43:
57454
- case "end":
57455
- return _context4.stop();
57456
- }
57457
- }
57458
- }, _callee4, this, [[2, 38]]);
57459
- }));
57460
-
57461
- function editPlaylist(_x5) {
57462
- return _editPlaylist.apply(this, arguments);
57463
- }
57464
-
57465
- return editPlaylist;
57466
- }()
57467
- }, {
57468
- key: "addPlaylistTrack",
57469
- value: function () {
57470
- var _addPlaylistTrack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(_ref4) {
57471
- var playlistId, trackId, timestamp, responseValues, currentUserId, userId, updateAction, entityType, playlist, updatedPlaylistTracks, metadata, _yield$this$creatorNo3, metadataMultihash, resp, txReceipt, error;
57472
-
57473
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
57474
- while (1) {
57475
- switch (_context5.prev = _context5.next) {
57476
- case 0:
57477
- playlistId = _ref4.playlistId, trackId = _ref4.trackId, timestamp = _ref4.timestamp;
57478
- responseValues = this.getDefaultPlaylistReponseValues();
57479
- _context5.prev = 2;
57480
- currentUserId = this.userStateManager.getCurrentUserId();
57481
-
57482
- if (!(!playlistId || playlistId === undefined)) {
57483
- _context5.next = 7;
57484
- break;
57485
- }
57486
-
57487
- responseValues.error = 'Missing current playlistId';
57488
- return _context5.abrupt("return", responseValues);
57489
-
57490
- case 7:
57491
- if (currentUserId) {
57492
- _context5.next = 10;
57493
- break;
57494
- }
57495
-
57496
- responseValues.error = 'Missing current user ID';
57497
- return _context5.abrupt("return", responseValues);
57498
-
57499
- case 10:
57500
- userId = parseInt(currentUserId);
57501
- updateAction = Action.UPDATE;
57502
- entityType = EntityType.PLAYLIST;
57503
- this.REQUIRES(Services.CREATOR_NODE);
57504
- _context5.next = 16;
57505
- return this.getFullPlaylist(playlistId, userId);
57506
-
57507
- case 16:
57508
- playlist = _context5.sent;
57509
- updatedPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
57510
- updatedPlaylistTracks.push({
57511
- track: trackId,
57512
- time: timestamp
57513
- });
57514
- metadata = {
57515
- playlist_id: playlistId,
57516
- playlist_contents: {
57517
- track_ids: updatedPlaylistTracks
57518
- },
57519
- playlist_name: playlist.playlist_name,
57520
- playlist_image_sizes_multihash: playlist.cover_art,
57521
- description: playlist.description,
57522
- is_album: playlist.is_album,
57523
- is_private: playlist.is_private
57524
- };
57525
- _context5.next = 22;
57526
- return this.creatorNode.uploadPlaylistMetadata(metadata);
57527
-
57528
- case 22:
57529
- _yield$this$creatorNo3 = _context5.sent;
57530
- metadataMultihash = _yield$this$creatorNo3.metadataMultihash;
57531
- _context5.next = 26;
57532
- return this.manageEntity({
57533
- userId: userId,
57534
- entityType: entityType,
57535
- entityId: playlistId,
57536
- action: updateAction,
57537
- metadataMultihash: metadataMultihash
57538
- });
57539
-
57540
- case 26:
57541
- resp = _context5.sent;
57542
- txReceipt = resp.txReceipt;
57543
- responseValues.blockHash = txReceipt.blockHash;
57544
- responseValues.blockNumber = txReceipt.blockNumber;
57545
- responseValues.playlistId = playlistId;
57546
- return _context5.abrupt("return", responseValues);
57547
-
57548
- case 34:
57549
- _context5.prev = 34;
57550
- _context5.t0 = _context5["catch"](2);
57551
- error = _context5.t0.message;
57552
- responseValues.error = error;
57553
- return _context5.abrupt("return", responseValues);
57554
-
57555
- case 39:
57556
- case "end":
57557
- return _context5.stop();
57558
- }
57559
- }
57560
- }, _callee5, this, [[2, 34]]);
57561
- }));
57562
-
57563
- function addPlaylistTrack(_x6) {
57564
- return _addPlaylistTrack.apply(this, arguments);
57565
- }
57566
-
57567
- return addPlaylistTrack;
57568
- }()
57569
- }, {
57570
- key: "deletePlaylistTrack",
57571
- value: function () {
57572
- var _deletePlaylistTrack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(_ref5) {
57573
- var playlistId, trackId, timestamp, responseValues, currentUserId, userId, updateAction, entityType, playlist, existingPlaylistTracks, updatedTrackIds, metadata, _yield$this$creatorNo4, metadataMultihash, resp, txReceipt, error;
57574
-
57575
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
57576
- while (1) {
57577
- switch (_context6.prev = _context6.next) {
57578
- case 0:
57579
- playlistId = _ref5.playlistId, trackId = _ref5.trackId, timestamp = _ref5.timestamp;
57580
- responseValues = this.getDefaultPlaylistReponseValues();
57581
- _context6.prev = 2;
57582
- currentUserId = this.userStateManager.getCurrentUserId();
57583
-
57584
- if (!(!playlistId || playlistId === undefined)) {
57585
- _context6.next = 7;
57586
- break;
57587
- }
57588
-
57589
- responseValues.error = 'Missing current playlistId';
57590
- return _context6.abrupt("return", responseValues);
57591
-
57592
- case 7:
57593
- if (currentUserId) {
57594
- _context6.next = 10;
57595
- break;
57596
- }
57597
-
57598
- responseValues.error = 'Missing current user ID';
57599
- return _context6.abrupt("return", responseValues);
57600
-
57601
- case 10:
57602
- userId = parseInt(currentUserId);
57603
- updateAction = Action.UPDATE;
57604
- entityType = EntityType.PLAYLIST;
57605
- this.REQUIRES(Services.CREATOR_NODE);
57606
- _context6.next = 16;
57607
- return this.getFullPlaylist(playlistId, userId);
57608
-
57609
- case 16:
57610
- playlist = _context6.sent;
57611
- existingPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
57612
- updatedTrackIds = existingPlaylistTracks.filter(function (trackObj) {
57613
- var _ref6;
57614
-
57615
- return (_ref6 = trackObj.track !== trackId && timestamp !== trackObj.metadata_time) !== null && _ref6 !== void 0 ? _ref6 : trackObj.time;
57616
- });
57354
+ case 17:
57355
+ trackIds = this.mapTimestamps(playlist.playlist_contents.track_ids);
57617
57356
  metadata = {
57618
- playlist_id: playlistId,
57357
+ playlist_id: playlist.playlist_id,
57619
57358
  playlist_contents: {
57620
- track_ids: updatedTrackIds
57359
+ track_ids: trackIds
57621
57360
  },
57622
57361
  playlist_name: playlist.playlist_name,
57623
- playlist_image_sizes_multihash: playlist.cover_art,
57362
+ playlist_image_sizes_multihash: (_dirCID2 = dirCID) !== null && _dirCID2 !== void 0 ? _dirCID2 : playlist.cover_art_sizes,
57624
57363
  description: playlist.description,
57625
57364
  is_album: playlist.is_album,
57626
57365
  is_private: playlist.is_private
57627
57366
  };
57628
- _context6.next = 22;
57367
+ _context3.next = 21;
57629
57368
  return this.creatorNode.uploadPlaylistMetadata(metadata);
57630
57369
 
57631
- case 22:
57632
- _yield$this$creatorNo4 = _context6.sent;
57633
- metadataMultihash = _yield$this$creatorNo4.metadataMultihash;
57634
- _context6.next = 26;
57370
+ case 21:
57371
+ _yield$this$creatorNo2 = _context3.sent;
57372
+ metadataMultihash = _yield$this$creatorNo2.metadataMultihash;
57373
+ _context3.next = 25;
57635
57374
  return this.manageEntity({
57636
57375
  userId: userId,
57637
57376
  entityType: entityType,
57638
- entityId: playlistId,
57377
+ entityId: playlist.playlist_id,
57639
57378
  action: updateAction,
57640
57379
  metadataMultihash: metadataMultihash
57641
57380
  });
57642
57381
 
57643
- case 26:
57644
- resp = _context6.sent;
57645
- txReceipt = resp.txReceipt;
57646
- responseValues.blockHash = txReceipt.blockHash;
57647
- responseValues.blockNumber = txReceipt.blockNumber;
57648
- responseValues.playlistId = playlistId;
57649
- return _context6.abrupt("return", responseValues);
57650
-
57651
- case 34:
57652
- _context6.prev = 34;
57653
- _context6.t0 = _context6["catch"](2);
57654
- error = _context6.t0.message;
57655
- responseValues.error = error;
57656
- return _context6.abrupt("return", responseValues);
57657
-
57658
- case 39:
57659
- case "end":
57660
- return _context6.stop();
57661
- }
57662
- }
57663
- }, _callee6, this, [[2, 34]]);
57664
- }));
57665
-
57666
- function deletePlaylistTrack(_x7) {
57667
- return _deletePlaylistTrack.apply(this, arguments);
57668
- }
57669
-
57670
- return deletePlaylistTrack;
57671
- }()
57672
- /**
57673
- * Update a playlist using updated data contracts flow
57674
- **/
57675
-
57676
- }, {
57677
- key: "orderPlaylist",
57678
- value: function () {
57679
- var _orderPlaylist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(_ref7) {
57680
- var playlistId, trackIds, responseValues, currentUserId, userId, updateAction, entityType, playlist, existingPlaylistTracks, trackIdsWithTimes, trackIdTimes, metadata, _yield$this$creatorNo5, metadataMultihash, resp, txReceipt, error;
57681
-
57682
- return regeneratorRuntime.wrap(function _callee7$(_context7) {
57683
- while (1) {
57684
- switch (_context7.prev = _context7.next) {
57685
- case 0:
57686
- playlistId = _ref7.playlistId, trackIds = _ref7.trackIds;
57687
- responseValues = this.getDefaultPlaylistReponseValues();
57688
- _context7.prev = 2;
57689
- currentUserId = this.userStateManager.getCurrentUserId();
57690
-
57691
- if (!(!playlistId || playlistId === undefined)) {
57692
- _context7.next = 7;
57693
- break;
57694
- }
57695
-
57696
- responseValues.error = 'Missing current playlistId';
57697
- return _context7.abrupt("return", responseValues);
57698
-
57699
- case 7:
57700
- if (currentUserId) {
57701
- _context7.next = 10;
57702
- break;
57703
- }
57704
-
57705
- responseValues.error = 'Missing current user ID';
57706
- return _context7.abrupt("return", responseValues);
57707
-
57708
- case 10:
57709
- userId = parseInt(currentUserId);
57710
- updateAction = Action.UPDATE;
57711
- entityType = EntityType.PLAYLIST;
57712
- this.REQUIRES(Services.CREATOR_NODE);
57713
- _context7.next = 16;
57714
- return this.getFullPlaylist(playlistId, userId);
57715
-
57716
- case 16:
57717
- playlist = _context7.sent;
57718
- existingPlaylistTracks = this.mapAddedTimestamps(playlist.added_timestamps);
57719
- trackIdsWithTimes = [];
57720
- trackIdTimes = {};
57721
- existingPlaylistTracks.forEach(function (trackObj) {
57722
- var _trackObj$metadata_ti2;
57723
-
57724
- var trackId = trackObj.track;
57725
- var timestamp = (_trackObj$metadata_ti2 = trackObj.metadata_time) !== null && _trackObj$metadata_ti2 !== void 0 ? _trackObj$metadata_ti2 : trackObj.time;
57726
-
57727
- if (trackId in trackIdTimes) {
57728
- trackIdTimes[trackId].push(timestamp);
57729
- } else {
57730
- trackIdTimes[trackId] = [timestamp];
57731
- }
57732
- }); // new tracks default to currentBlock timestamp
57733
-
57734
- trackIdsWithTimes = trackIds.map(function (trackId) {
57735
- return {
57736
- track: trackId,
57737
- time: trackIdTimes[trackId].pop()
57738
- };
57739
- });
57740
- metadata = {
57741
- playlist_id: playlistId,
57742
- playlist_contents: {
57743
- track_ids: trackIdsWithTimes
57744
- },
57745
- playlist_name: playlist.playlist_name,
57746
- playlist_image_sizes_multihash: playlist.cover_art,
57747
- description: playlist.description,
57748
- is_album: playlist.is_album,
57749
- is_private: playlist.is_private
57750
- };
57751
- _context7.next = 25;
57752
- return this.creatorNode.uploadPlaylistMetadata(metadata);
57753
-
57754
57382
  case 25:
57755
- _yield$this$creatorNo5 = _context7.sent;
57756
- metadataMultihash = _yield$this$creatorNo5.metadataMultihash;
57757
- _context7.next = 29;
57758
- return this.manageEntity({
57759
- userId: userId,
57760
- entityType: entityType,
57761
- entityId: playlistId,
57762
- action: updateAction,
57763
- metadataMultihash: metadataMultihash
57764
- });
57765
-
57766
- case 29:
57767
- resp = _context7.sent;
57383
+ resp = _context3.sent;
57768
57384
  txReceipt = resp.txReceipt;
57769
57385
  responseValues.blockHash = txReceipt.blockHash;
57770
57386
  responseValues.blockNumber = txReceipt.blockNumber;
57771
- responseValues.playlistId = playlistId;
57772
- return _context7.abrupt("return", responseValues);
57387
+ return _context3.abrupt("return", responseValues);
57773
57388
 
57774
- case 37:
57775
- _context7.prev = 37;
57776
- _context7.t0 = _context7["catch"](2);
57777
- error = _context7.t0.message;
57389
+ case 32:
57390
+ _context3.prev = 32;
57391
+ _context3.t0 = _context3["catch"](1);
57392
+ error = _context3.t0.message;
57778
57393
  responseValues.error = error;
57779
- return _context7.abrupt("return", responseValues);
57394
+ return _context3.abrupt("return", responseValues);
57780
57395
 
57781
- case 42:
57396
+ case 37:
57782
57397
  case "end":
57783
- return _context7.stop();
57398
+ return _context3.stop();
57784
57399
  }
57785
57400
  }
57786
- }, _callee7, this, [[2, 37]]);
57401
+ }, _callee3, this, [[1, 32]]);
57787
57402
  }));
57788
57403
 
57789
- function orderPlaylist(_x8) {
57790
- return _orderPlaylist.apply(this, arguments);
57404
+ function updatePlaylist(_x3) {
57405
+ return _updatePlaylist.apply(this, arguments);
57791
57406
  }
57792
57407
 
57793
- return orderPlaylist;
57408
+ return updatePlaylist;
57794
57409
  }()
57795
57410
  /**
57796
57411
  * Manage an entity with the updated data contract flow
@@ -57800,44 +57415,44 @@ var EntityManager = /*#__PURE__*/function (_Base) {
57800
57415
  }, {
57801
57416
  key: "manageEntity",
57802
57417
  value: function () {
57803
- var _manageEntity = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(_ref8) {
57418
+ var _manageEntity = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref) {
57804
57419
  var userId, entityType, entityId, action, metadataMultihash, error, resp, _this$contracts$Entit;
57805
57420
 
57806
- return regeneratorRuntime.wrap(function _callee8$(_context8) {
57421
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
57807
57422
  while (1) {
57808
- switch (_context8.prev = _context8.next) {
57423
+ switch (_context4.prev = _context4.next) {
57809
57424
  case 0:
57810
- userId = _ref8.userId, entityType = _ref8.entityType, entityId = _ref8.entityId, action = _ref8.action, metadataMultihash = _ref8.metadataMultihash;
57425
+ userId = _ref.userId, entityType = _ref.entityType, entityId = _ref.entityId, action = _ref.action, metadataMultihash = _ref.metadataMultihash;
57811
57426
  error = null;
57812
- _context8.prev = 2;
57813
- _context8.next = 5;
57427
+ _context4.prev = 2;
57428
+ _context4.next = 5;
57814
57429
  return (_this$contracts$Entit = this.contracts.EntityManagerClient) === null || _this$contracts$Entit === void 0 ? void 0 : _this$contracts$Entit.manageEntity(userId, entityType, entityId, action, metadataMultihash);
57815
57430
 
57816
57431
  case 5:
57817
- resp = _context8.sent;
57818
- return _context8.abrupt("return", {
57432
+ resp = _context4.sent;
57433
+ return _context4.abrupt("return", {
57819
57434
  txReceipt: resp.txReceipt,
57820
57435
  error: error
57821
57436
  });
57822
57437
 
57823
57438
  case 9:
57824
- _context8.prev = 9;
57825
- _context8.t0 = _context8["catch"](2);
57826
- error = _context8.t0.message;
57827
- return _context8.abrupt("return", {
57439
+ _context4.prev = 9;
57440
+ _context4.t0 = _context4["catch"](2);
57441
+ error = _context4.t0.message;
57442
+ return _context4.abrupt("return", {
57828
57443
  txReceipt: null,
57829
57444
  error: error
57830
57445
  });
57831
57446
 
57832
57447
  case 13:
57833
57448
  case "end":
57834
- return _context8.stop();
57449
+ return _context4.stop();
57835
57450
  }
57836
57451
  }
57837
- }, _callee8, this, [[2, 9]]);
57452
+ }, _callee4, this, [[2, 9]]);
57838
57453
  }));
57839
57454
 
57840
- function manageEntity(_x9) {
57455
+ function manageEntity(_x4) {
57841
57456
  return _manageEntity.apply(this, arguments);
57842
57457
  }
57843
57458