@audius/sdk 0.0.33 → 0.0.34

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.
@@ -509,9 +509,9 @@ if (typeof window !== 'undefined' && window && window.Web3) {
509
509
  var LibsWeb3 = Web3;
510
510
 
511
511
  var name = "@audius/sdk";
512
- var version = "0.0.33";
512
+ var version = "0.0.34";
513
513
  var audius = {
514
- releaseSHA: "8c2deb92b6817f904ba5007ac5eca8d8fba6509d"
514
+ releaseSHA: "c38a6a8f425386cc254501ac0b0d01235b44d36f"
515
515
  };
516
516
  var description = "";
517
517
  var main = "dist/index.cjs.js";
@@ -553,7 +553,7 @@ var dependencies = {
553
553
  "@ethersproject/solidity": "5.0.5",
554
554
  "@improbable-eng/grpc-web-node-http-transport": "0.15.0",
555
555
  "@project-serum/anchor": "0.24.1",
556
- "@solana/spl-token": "0.1.6",
556
+ "@solana/spl-token": "0.1.8",
557
557
  "@solana/web3.js": "1.37.1",
558
558
  "abi-decoder": "2.4.0",
559
559
  ajv: "6.12.2",
@@ -40456,7 +40456,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40456
40456
  key: "submitAndEvaluate",
40457
40457
  value: function () {
40458
40458
  var _submitAndEvaluate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref) {
40459
- var challengeId, encodedUserId, handle, recipientEthAddress, specifier, oracleEthAddress, amount, quorumSize, AAOEndpoint, instructionsPerTransaction, _ref$maxAggregationAt, maxAggregationAttempts, _ref$endpoints, endpoints, _ref$logger, logger, _ref$feePayerOverride, feePayerOverride, phase, nodesToReselect, _yield$this$aggregate, discoveryNodeAttestations, aaoAttestation, aggregateError, erroringNodes, fullTokenAmount, _yield$this$solanaWeb, submitErrorCode, submitError, shouldRetryInSeperateTransactions, _yield$this$solanaWeb2, evaluateErrorCode, evaluateError, err, log;
40459
+ var challengeId, encodedUserId, handle, recipientEthAddress, specifier, oracleEthAddress, amount, quorumSize, AAOEndpoint, instructionsPerTransaction, _ref$maxAggregationAt, maxAggregationAttempts, _ref$endpoints, endpoints, _ref$logger, logger, _ref$feePayerOverride, feePayerOverride, phase, nodesToReselect, aaoErrorCode, _yield$this$aggregate, discoveryNodeAttestations, aaoAttestation, aggregateError, errorCode, erroringNodes, fullTokenAmount, _yield$this$solanaWeb, submitErrorCode, submitError, shouldRetryInSeperateTransactions, _yield$this$solanaWeb2, evaluateErrorCode, evaluateError, err, log;
40460
40460
 
40461
40461
  return regeneratorRuntime.wrap(function _callee$(_context) {
40462
40462
  while (1) {
@@ -40464,21 +40464,22 @@ var Rewards = /*#__PURE__*/function (_Base) {
40464
40464
  case 0:
40465
40465
  challengeId = _ref.challengeId, encodedUserId = _ref.encodedUserId, handle = _ref.handle, recipientEthAddress = _ref.recipientEthAddress, specifier = _ref.specifier, oracleEthAddress = _ref.oracleEthAddress, amount = _ref.amount, quorumSize = _ref.quorumSize, AAOEndpoint = _ref.AAOEndpoint, instructionsPerTransaction = _ref.instructionsPerTransaction, _ref$maxAggregationAt = _ref.maxAggregationAttempts, maxAggregationAttempts = _ref$maxAggregationAt === void 0 ? 20 : _ref$maxAggregationAt, _ref$endpoints = _ref.endpoints, endpoints = _ref$endpoints === void 0 ? null : _ref$endpoints, _ref$logger = _ref.logger, logger = _ref$logger === void 0 ? console : _ref$logger, _ref$feePayerOverride = _ref.feePayerOverride, feePayerOverride = _ref$feePayerOverride === void 0 ? null : _ref$feePayerOverride;
40466
40466
  nodesToReselect = null;
40467
- _context.prev = 2;
40467
+ aaoErrorCode = null;
40468
+ _context.prev = 3;
40468
40469
  phase = AttestationPhases.SANITY_CHECKS; // fail if amount is a decimal
40469
40470
 
40470
40471
  if (!(Number(amount) !== amount || amount % 1 !== 0)) {
40471
- _context.next = 6;
40472
+ _context.next = 7;
40472
40473
  break;
40473
40474
  }
40474
40475
 
40475
40476
  throw new Error('Invalid amount');
40476
40477
 
40477
- case 6:
40478
+ case 7:
40478
40479
  // Aggregate
40479
40480
  logger.info("submitAndEvaluate: aggregating attestations for userId [".concat(decodeHashId(encodedUserId), "], challengeId [").concat(challengeId, "]"));
40480
40481
  phase = AttestationPhases.AGGREGATE_ATTESTATIONS;
40481
- _context.next = 10;
40482
+ _context.next = 11;
40482
40483
  return this.aggregateAttestations({
40483
40484
  challengeId: challengeId,
40484
40485
  encodedUserId: encodedUserId,
@@ -40493,28 +40494,30 @@ var Rewards = /*#__PURE__*/function (_Base) {
40493
40494
  maxAttempts: maxAggregationAttempts
40494
40495
  });
40495
40496
 
40496
- case 10:
40497
+ case 11:
40497
40498
  _yield$this$aggregate = _context.sent;
40498
40499
  discoveryNodeAttestations = _yield$this$aggregate.discoveryNodeAttestations;
40499
40500
  aaoAttestation = _yield$this$aggregate.aaoAttestation;
40500
40501
  aggregateError = _yield$this$aggregate.error;
40502
+ errorCode = _yield$this$aggregate.aaoErrorCode;
40501
40503
  erroringNodes = _yield$this$aggregate.erroringNodes;
40502
40504
 
40503
40505
  if (!aggregateError) {
40504
- _context.next = 18;
40506
+ _context.next = 21;
40505
40507
  break;
40506
40508
  }
40507
40509
 
40508
40510
  nodesToReselect = erroringNodes;
40511
+ aaoErrorCode = errorCode;
40509
40512
  throw new Error(aggregateError);
40510
40513
 
40511
- case 18:
40514
+ case 21:
40512
40515
  // Submit
40513
40516
  logger.info("submitAndEvaluate: submitting for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId(encodedUserId), "] with [").concat(discoveryNodeAttestations === null || discoveryNodeAttestations === void 0 ? void 0 : discoveryNodeAttestations.length, "] DN and [").concat(aaoAttestation ? 1 : 0, "] oracle attestations."));
40514
40517
  fullTokenAmount = new BN$1(amount * WRAPPED_AUDIO_PRECISION);
40515
40518
  phase = AttestationPhases.SUBMIT_ATTESTATIONS; // @ts-expect-error the return types are a bit strange here
40516
40519
 
40517
- _context.next = 23;
40520
+ _context.next = 26;
40518
40521
  return this.solanaWeb3Manager.submitChallengeAttestations({
40519
40522
  attestations: discoveryNodeAttestations,
40520
40523
  oracleAttestation: aaoAttestation,
@@ -40527,13 +40530,13 @@ var Rewards = /*#__PURE__*/function (_Base) {
40527
40530
  feePayerOverride: feePayerOverride
40528
40531
  });
40529
40532
 
40530
- case 23:
40533
+ case 26:
40531
40534
  _yield$this$solanaWeb = _context.sent;
40532
40535
  submitErrorCode = _yield$this$solanaWeb.errorCode;
40533
40536
  submitError = _yield$this$solanaWeb.error;
40534
40537
 
40535
40538
  if (!(submitErrorCode || submitError)) {
40536
- _context.next = 35;
40539
+ _context.next = 38;
40537
40540
  break;
40538
40541
  }
40539
40542
 
@@ -40544,12 +40547,12 @@ var Rewards = /*#__PURE__*/function (_Base) {
40544
40547
  // to evaluate phase and will error there (not ideal)
40545
40548
 
40546
40549
  if (!shouldRetryInSeperateTransactions) {
40547
- _context.next = 34;
40550
+ _context.next = 37;
40548
40551
  break;
40549
40552
  }
40550
40553
 
40551
40554
  logger.warn("submitAndEvaluate: saw repeat senders for userId [".concat(decodeHashId(encodedUserId), "] challengeId: [").concat(challengeId, "] with err: ").concat(submitErrorCode, ", breaking up into individual transactions"));
40552
- _context.next = 32;
40555
+ _context.next = 35;
40553
40556
  return this.solanaWeb3Manager.submitChallengeAttestations({
40554
40557
  attestations: discoveryNodeAttestations,
40555
40558
  oracleAttestation: aaoAttestation,
@@ -40562,18 +40565,18 @@ var Rewards = /*#__PURE__*/function (_Base) {
40562
40565
  feePayerOverride: feePayerOverride
40563
40566
  });
40564
40567
 
40565
- case 32:
40566
- _context.next = 35;
40568
+ case 35:
40569
+ _context.next = 38;
40567
40570
  break;
40568
40571
 
40569
- case 34:
40572
+ case 37:
40570
40573
  throw new Error(submitErrorCode || submitError);
40571
40574
 
40572
- case 35:
40575
+ case 38:
40573
40576
  // Evaluate
40574
40577
  logger.info("submitAndEvaluate: evaluating for challenge [".concat(challengeId, "], userId: [").concat(decodeHashId(encodedUserId), "]"));
40575
40578
  phase = AttestationPhases.EVALUATE_ATTESTATIONS;
40576
- _context.next = 39;
40579
+ _context.next = 42;
40577
40580
  return this.solanaWeb3Manager.evaluateChallengeAttestations({
40578
40581
  challengeId: challengeId,
40579
40582
  specifier: specifier,
@@ -40584,45 +40587,47 @@ var Rewards = /*#__PURE__*/function (_Base) {
40584
40587
  feePayerOverride: feePayerOverride
40585
40588
  });
40586
40589
 
40587
- case 39:
40590
+ case 42:
40588
40591
  _yield$this$solanaWeb2 = _context.sent;
40589
40592
  evaluateErrorCode = _yield$this$solanaWeb2.errorCode;
40590
40593
  evaluateError = _yield$this$solanaWeb2.error;
40591
40594
 
40592
40595
  if (!(evaluateErrorCode !== null && evaluateErrorCode !== void 0 ? evaluateErrorCode : evaluateError)) {
40593
- _context.next = 44;
40596
+ _context.next = 47;
40594
40597
  break;
40595
40598
  }
40596
40599
 
40597
40600
  throw new Error(evaluateErrorCode !== null && evaluateErrorCode !== void 0 ? evaluateErrorCode : evaluateError);
40598
40601
 
40599
- case 44:
40602
+ case 47:
40600
40603
  return _context.abrupt("return", {
40601
40604
  success: true,
40602
40605
  error: null,
40606
+ aaoErrorCode: aaoErrorCode,
40603
40607
  phase: null,
40604
40608
  nodesToReselect: null
40605
40609
  });
40606
40610
 
40607
- case 47:
40608
- _context.prev = 47;
40609
- _context.t0 = _context["catch"](2);
40611
+ case 50:
40612
+ _context.prev = 50;
40613
+ _context.t0 = _context["catch"](3);
40610
40614
  err = _context.t0.message;
40611
40615
  log = err === GetAttestationError.COGNITO_FLOW || err === GetAttestationError.HCAPTCHA ? logger.info : logger.error;
40612
40616
  log("submitAndEvaluate: failed for userId: [".concat(decodeHashId(encodedUserId), "] challenge-id [").concat(challengeId, "] at phase [").concat(phase, "] with err: ").concat(err));
40613
40617
  return _context.abrupt("return", {
40614
40618
  success: false,
40615
40619
  error: err,
40620
+ aaoErrorCode: aaoErrorCode,
40616
40621
  phase: phase,
40617
40622
  nodesToReselect: nodesToReselect
40618
40623
  });
40619
40624
 
40620
- case 53:
40625
+ case 56:
40621
40626
  case "end":
40622
40627
  return _context.stop();
40623
40628
  }
40624
40629
  }
40625
- }, _callee, this, [[2, 47]]);
40630
+ }, _callee, this, [[3, 50]]);
40626
40631
  }));
40627
40632
 
40628
40633
  function submitAndEvaluate(_x) {
@@ -40639,7 +40644,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40639
40644
  key: "aggregateAttestations",
40640
40645
  value: function () {
40641
40646
  var _aggregateAttestations = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref2) {
40642
- var challengeId, encodedUserId, handle, specifier, oracleEthAddress, amount, quorumSize, AAOEndpoint, maxAttempts, _ref2$endpoints, endpoints, _ref2$logger, logger, aaoAttestation, _yield$this$getAAOAtt, success, aaoAttestationError, err, discoveryNodeAttestationResults, discoveryNodeSuccesses, discoveryNodeErrors, error, erroringNodes, _err;
40647
+ var challengeId, encodedUserId, handle, specifier, oracleEthAddress, amount, quorumSize, AAOEndpoint, maxAttempts, _ref2$endpoints, endpoints, _ref2$logger, logger, aaoAttestation, _yield$this$getAAOAtt, success, aaoErrorCode, aaoAttestationError, err, discoveryNodeAttestationResults, discoveryNodeSuccesses, discoveryNodeErrors, error, erroringNodes, _err;
40643
40648
 
40644
40649
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
40645
40650
  while (1) {
@@ -40677,6 +40682,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40677
40682
  discoveryNodeAttestations: null,
40678
40683
  aaoAttestation: null,
40679
40684
  error: AggregateAttestationError.INSUFFICIENT_DISCOVERY_NODE_COUNT,
40685
+ aaoErrorCode: null,
40680
40686
  erroringNodes: null
40681
40687
  });
40682
40688
 
@@ -40697,10 +40703,11 @@ var Rewards = /*#__PURE__*/function (_Base) {
40697
40703
  case 16:
40698
40704
  _yield$this$getAAOAtt = _context2.sent;
40699
40705
  success = _yield$this$getAAOAtt.success;
40706
+ aaoErrorCode = _yield$this$getAAOAtt.aaoErrorCode;
40700
40707
  aaoAttestationError = _yield$this$getAAOAtt.error;
40701
40708
 
40702
40709
  if (!aaoAttestationError) {
40703
- _context2.next = 21;
40710
+ _context2.next = 22;
40704
40711
  break;
40705
40712
  }
40706
40713
 
@@ -40708,16 +40715,17 @@ var Rewards = /*#__PURE__*/function (_Base) {
40708
40715
  discoveryNodeAttestations: null,
40709
40716
  aaoAttestation: null,
40710
40717
  error: aaoAttestationError,
40718
+ aaoErrorCode: aaoErrorCode,
40711
40719
  erroringNodes: null
40712
40720
  });
40713
40721
 
40714
- case 21:
40722
+ case 22:
40715
40723
  aaoAttestation = success;
40716
- _context2.next = 29;
40724
+ _context2.next = 30;
40717
40725
  break;
40718
40726
 
40719
- case 24:
40720
- _context2.prev = 24;
40727
+ case 25:
40728
+ _context2.prev = 25;
40721
40729
  _context2.t0 = _context2["catch"](13);
40722
40730
  err = _context2.t0.message;
40723
40731
  logger.error("Failed to aggregate attestations for user [".concat(decodeHashId(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(err));
@@ -40725,12 +40733,13 @@ var Rewards = /*#__PURE__*/function (_Base) {
40725
40733
  discoveryNodeAttestations: null,
40726
40734
  aaoAttestation: null,
40727
40735
  error: GetAttestationError.AAO_ATTESTATION_ERROR,
40736
+ aaoErrorCode: null,
40728
40737
  erroringNodes: null
40729
40738
  });
40730
40739
 
40731
- case 29:
40732
- _context2.prev = 29;
40733
- _context2.next = 32;
40740
+ case 30:
40741
+ _context2.prev = 30;
40742
+ _context2.next = 33;
40734
40743
  return this._getDiscoveryAttestationsWithRetries({
40735
40744
  endpoints: endpoints,
40736
40745
  challengeId: challengeId,
@@ -40741,7 +40750,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40741
40750
  maxAttempts: maxAttempts
40742
40751
  });
40743
40752
 
40744
- case 32:
40753
+ case 33:
40745
40754
  discoveryNodeAttestationResults = _context2.sent;
40746
40755
  discoveryNodeSuccesses = discoveryNodeAttestationResults.map(function (r) {
40747
40756
  return r.success;
@@ -40752,7 +40761,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40752
40761
  error = discoveryNodeErrors.find(Boolean);
40753
40762
 
40754
40763
  if (!error) {
40755
- _context2.next = 39;
40764
+ _context2.next = 40;
40756
40765
  break;
40757
40766
  }
40758
40767
 
@@ -40769,32 +40778,34 @@ var Rewards = /*#__PURE__*/function (_Base) {
40769
40778
  erroringNodes: erroringNodes
40770
40779
  });
40771
40780
 
40772
- case 39:
40781
+ case 40:
40773
40782
  return _context2.abrupt("return", {
40774
40783
  discoveryNodeAttestations: discoveryNodeSuccesses,
40775
40784
  aaoAttestation: aaoAttestation,
40776
40785
  error: null,
40786
+ aaoErrorCode: null,
40777
40787
  erroringNodes: null
40778
40788
  });
40779
40789
 
40780
- case 42:
40781
- _context2.prev = 42;
40782
- _context2.t1 = _context2["catch"](29);
40790
+ case 43:
40791
+ _context2.prev = 43;
40792
+ _context2.t1 = _context2["catch"](30);
40783
40793
  _err = _context2.t1.message;
40784
40794
  logger.error("Failed to aggregate attestations for user [".concat(decodeHashId(encodedUserId), "], challenge-id: [").concat(challengeId, "] with err: ").concat(_err));
40785
40795
  return _context2.abrupt("return", {
40786
40796
  discoveryNodeAttestations: null,
40787
40797
  aaoAttestation: null,
40788
40798
  error: GetAttestationError.DISCOVERY_NODE_ATTESTATION_ERROR,
40799
+ aaoErrorCode: null,
40789
40800
  erroringNodes: null
40790
40801
  });
40791
40802
 
40792
- case 47:
40803
+ case 48:
40793
40804
  case "end":
40794
40805
  return _context2.stop();
40795
40806
  }
40796
40807
  }
40797
- }, _callee2, this, [[13, 24], [29, 42]]);
40808
+ }, _callee2, this, [[13, 25], [30, 43]]);
40798
40809
  }));
40799
40810
 
40800
40811
  function aggregateAttestations(_x2) {
@@ -40925,7 +40936,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40925
40936
  key: "getAAOAttestation",
40926
40937
  value: function () {
40927
40938
  var _getAAOAttestation = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(_ref5) {
40928
- var challengeId, specifier, handle, amount, AAOEndpoint, oracleEthAddress, _ref5$logger, logger, data, request, response, _response$data, result, needs, mappedErr, err;
40939
+ var challengeId, specifier, handle, amount, AAOEndpoint, oracleEthAddress, _ref5$logger, logger, data, request, response, _response$data, result, errorCode, needs, mappedErr, err;
40929
40940
 
40930
40941
  return regeneratorRuntime.wrap(function _callee5$(_context5) {
40931
40942
  while (1) {
@@ -40956,7 +40967,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40956
40967
  // otherwise, 'result' is false
40957
40968
  // - there may or may not be a value for `needs` if the attestation fails
40958
40969
  // - depending on whether the user can take an action to attempt remediation
40959
- _response$data = response.data, result = _response$data.result, needs = _response$data.needs;
40970
+ _response$data = response.data, result = _response$data.result, errorCode = _response$data.errorCode, needs = _response$data.needs;
40960
40971
 
40961
40972
  if (result) {
40962
40973
  _context5.next = 12;
@@ -40967,6 +40978,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40967
40978
  mappedErr = needs ? GetAttestationError[needs] || GetAttestationError.AAO_ATTESTATION_UNKNOWN_RESPONSE : GetAttestationError.AAO_ATTESTATION_REJECTION;
40968
40979
  return _context5.abrupt("return", {
40969
40980
  success: null,
40981
+ aaoErrorCode: errorCode,
40970
40982
  error: mappedErr
40971
40983
  });
40972
40984
 
@@ -40976,6 +40988,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40976
40988
  signature: result,
40977
40989
  ethAddress: oracleEthAddress
40978
40990
  },
40991
+ aaoErrorCode: null,
40979
40992
  error: null
40980
40993
  });
40981
40994
 
@@ -40986,6 +40999,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
40986
40999
  logger.error("Failed to get AAO attestation: ".concat(err));
40987
41000
  return _context5.abrupt("return", {
40988
41001
  success: null,
41002
+ aaoErrorCode: null,
40989
41003
  error: GetAttestationError.AAO_ATTESTATION_ERROR
40990
41004
  });
40991
41005