@eluvio/elv-client-js 3.1.76 → 3.1.77

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.
@@ -480,7 +480,7 @@ function () {
480
480
 
481
481
  case 22:
482
482
  if (success) {
483
- _context6.next = 45;
483
+ _context6.next = 49;
484
484
  break;
485
485
  }
486
486
 
@@ -491,7 +491,7 @@ function () {
491
491
  case 26:
492
492
  result = _context6.sent;
493
493
  success = true;
494
- _context6.next = 43;
494
+ _context6.next = 47;
495
495
  break;
496
496
 
497
497
  case 30:
@@ -513,41 +513,51 @@ function () {
513
513
  latestBlock = _context6.sent;
514
514
  overrides.gasLimit = latestBlock.gasLimit;
515
515
  overrides.gasPrice = overrides.gasPrice ? overrides.gasPrice * 1.50 : 8000000000;
516
- _context6.next = 43;
516
+ _context6.next = 47;
517
517
  break;
518
518
 
519
519
  case 40:
520
+ if (!(_context6.t0.code === "NONCE_EXPIRED" && _context6.t0.reason === "nonce has already been used")) {
521
+ _context6.next = 44;
522
+ break;
523
+ }
524
+
525
+ this.Log("Retrying method call ".concat(methodName));
526
+ _context6.next = 47;
527
+ break;
528
+
529
+ case 44:
520
530
  if ((_context6.t0.message || _context6.t0).includes("invalid response")) {
521
- _context6.next = 43;
531
+ _context6.next = 47;
522
532
  break;
523
533
  }
524
534
 
525
535
  this.Log(_typeof(_context6.t0) === "object" ? JSON.stringify(_context6.t0, null, 2) : _context6.t0, true);
526
536
  throw _context6.t0;
527
537
 
528
- case 43:
538
+ case 47:
529
539
  _context6.next = 22;
530
540
  break;
531
541
 
532
- case 45:
542
+ case 49:
533
543
  return _context6.abrupt("return", result);
534
544
 
535
- case 46:
536
- _context6.prev = 46;
545
+ case 50:
546
+ _context6.prev = 50;
537
547
 
538
548
  // Unlock if performing a transaction
539
549
  if (!methodAbi || !methodAbi.constant) {
540
550
  this.locked = false;
541
551
  }
542
552
 
543
- return _context6.finish(46);
553
+ return _context6.finish(50);
544
554
 
545
- case 49:
555
+ case 53:
546
556
  case "end":
547
557
  return _context6.stop();
548
558
  }
549
559
  }
550
- }, null, this, [[20,, 46, 49], [23, 30]]);
560
+ }, null, this, [[20,, 50, 53], [23, 30]]);
551
561
  }
552
562
  }, {
553
563
  key: "CallContractMethodAndWait",
@@ -15,6 +15,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
15
  *
16
16
  * @module ElvClient/ABRPublishing
17
17
  */
18
+ var R = require("ramda");
19
+
18
20
  var UrlJoin = require("url-join");
19
21
 
20
22
  var HttpClient = require("../HttpClient");
@@ -344,7 +346,7 @@ exports.CreateProductionMaster = function _callee(_ref) {
344
346
 
345
347
 
346
348
  exports.CreateABRMezzanine = function _callee2(_ref4) {
347
- var libraryId, objectId, type, name, description, metadata, masterVersionHash, abrProfile, _ref4$variant, variant, _ref4$offeringKey, offeringKey, existingMez, options, id, write_token, editResponse, createResponse, masterName, authorizationTokens, headers, body, storeClear, _ref5, logs, errors, warnings, finalizeResponse;
349
+ var libraryId, objectId, type, name, description, metadata, masterVersionHash, abrProfile, _ref4$variant, variant, _ref4$offeringKey, offeringKey, existingMez, options, id, write_token, editResponse, createResponse, masterName, authorizationTokens, headers, body, storeClear, _ref5, logs, errors, warnings, existingMetadata, finalizeResponse;
348
350
 
349
351
  return _regeneratorRuntime.async(function _callee2$(_context2) {
350
352
  while (1) {
@@ -541,7 +543,6 @@ exports.CreateABRMezzanine = function _callee2(_ref4) {
541
543
  "/": "./rep/playout/".concat(offeringKey, "/options.json")
542
544
  })
543
545
  }, metadata["public"].asset_metadata);
544
- metadata.elv_created_at = new Date().getTime();
545
546
 
546
547
  if (name || !existingMez) {
547
548
  metadata.name = name || "".concat(masterName, " Mezzanine");
@@ -551,18 +552,38 @@ exports.CreateABRMezzanine = function _callee2(_ref4) {
551
552
  if (description || !existingMez) {
552
553
  metadata.description = description || "";
553
554
  metadata["public"].description = description || "";
554
- }
555
+ } // retrieve existing metadata to merge with updated metadata
555
556
 
556
- _context2.next = 72;
557
- return _regeneratorRuntime.awrap(this.MergeMetadata({
557
+
558
+ _context2.next = 71;
559
+ return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
560
+ libraryId: libraryId,
561
+ objectId: id,
562
+ writeToken: write_token
563
+ }));
564
+
565
+ case 71:
566
+ existingMetadata = _context2.sent;
567
+ // newer metadata values replace existing metadata, unless both new and old values are objects,
568
+ // in which case their keys are merged recursively
569
+ metadata = R.mergeDeepRight(existingMetadata, metadata);
570
+
571
+ if (!existingMez) {
572
+ // set creation date
573
+ metadata.elv_created_at = new Date().getTime();
574
+ } // write metadata to mezzanine object
575
+
576
+
577
+ _context2.next = 76;
578
+ return _regeneratorRuntime.awrap(this.ReplaceMetadata({
558
579
  libraryId: libraryId,
559
580
  objectId: id,
560
581
  writeToken: write_token,
561
582
  metadata: metadata
562
583
  }));
563
584
 
564
- case 72:
565
- _context2.next = 74;
585
+ case 76:
586
+ _context2.next = 78;
566
587
  return _regeneratorRuntime.awrap(this.FinalizeContentObject({
567
588
  libraryId: libraryId,
568
589
  objectId: id,
@@ -570,7 +591,7 @@ exports.CreateABRMezzanine = function _callee2(_ref4) {
570
591
  commitMessage: "Create ABR mezzanine"
571
592
  }));
572
593
 
573
- case 74:
594
+ case 78:
574
595
  finalizeResponse = _context2.sent;
575
596
  return _context2.abrupt("return", _objectSpread({
576
597
  logs: logs || [],
@@ -578,7 +599,7 @@ exports.CreateABRMezzanine = function _callee2(_ref4) {
578
599
  errors: errors || []
579
600
  }, finalizeResponse));
580
601
 
581
- case 76:
602
+ case 80:
582
603
  case "end":
583
604
  return _context2.stop();
584
605
  }
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.76",
3
+ "version": "3.1.77",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.76",
3
+ "version": "3.1.77",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/ElvClient.js",
6
6
  "author": "Kevin Talmadge",
package/src/EthClient.js CHANGED
@@ -285,6 +285,8 @@ class EthClient {
285
285
  const latestBlock = await this.MakeProviderCall({methodName: "getBlock", args: ["latest"]});
286
286
  overrides.gasLimit = latestBlock.gasLimit;
287
287
  overrides.gasPrice = overrides.gasPrice ? overrides.gasPrice * 1.50 : 8000000000;
288
+ } else if(error.code === "NONCE_EXPIRED" && error.reason === "nonce has already been used") {
289
+ this.Log(`Retrying method call ${methodName}`);
288
290
  } else if(!(error.message || error).includes("invalid response")) {
289
291
  this.Log(typeof error === "object" ? JSON.stringify(error, null, 2) : error, true);
290
292
  throw error;
@@ -6,6 +6,7 @@
6
6
  * @module ElvClient/ABRPublishing
7
7
  */
8
8
 
9
+ const R = require("ramda");
9
10
  const UrlJoin = require("url-join");
10
11
  const HttpClient = require("../HttpClient");
11
12
 
@@ -355,8 +356,6 @@ exports.CreateABRMezzanine = async function({
355
356
  ...metadata.public.asset_metadata
356
357
  };
357
358
 
358
- metadata.elv_created_at = new Date().getTime();
359
-
360
359
  if(name || !existingMez) {
361
360
  metadata.name = name || `${masterName} Mezzanine`;
362
361
  metadata.public.name = name || `${masterName} Mezzanine`;
@@ -367,7 +366,23 @@ exports.CreateABRMezzanine = async function({
367
366
  metadata.public.description = description || "";
368
367
  }
369
368
 
370
- await this.MergeMetadata({
369
+ // retrieve existing metadata to merge with updated metadata
370
+ const existingMetadata = await this.ContentObjectMetadata({
371
+ libraryId,
372
+ objectId: id,
373
+ writeToken: write_token,
374
+ });
375
+ // newer metadata values replace existing metadata, unless both new and old values are objects,
376
+ // in which case their keys are merged recursively
377
+ metadata = R.mergeDeepRight(existingMetadata, metadata);
378
+
379
+ if(!existingMez) {
380
+ // set creation date
381
+ metadata.elv_created_at = new Date().getTime();
382
+ }
383
+
384
+ // write metadata to mezzanine object
385
+ await this.ReplaceMetadata({
371
386
  libraryId,
372
387
  objectId: id,
373
388
  writeToken: write_token,
@@ -126,7 +126,7 @@ class MezzanineCreate extends Utility {
126
126
 
127
127
  if(!existingPublicMetadata.asset_metadata) existingPublicMetadata.asset_metadata = {};
128
128
 
129
- const mergedExistingAndArgMetadata = R.mergeRight(
129
+ const mergedExistingAndArgMetadata = R.mergeDeepRight(
130
130
  {public: existingPublicMetadata},
131
131
  metadataFromArg
132
132
  );
@@ -248,4 +248,4 @@ if(require.main === module) {
248
248
  Utility.cmdLineInvoke(MezzanineCreate);
249
249
  } else {
250
250
  module.exports = MezzanineCreate;
251
- }
251
+ }