@airgap/serializer 0.13.7-beta.20 → 0.13.7-beta.22

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.
@@ -209348,7 +209348,10 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
209348
209348
  _this.contract = _this.options.config.contractAddress
209349
209349
  ? new TezosContract_1.TezosContract(_this.options.config.contractAddress, _this.options.network)
209350
209350
  : undefined;
209351
- _this.injectorClient = _this.options.config.injectorUrl ? new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(_this.options.config.injectorUrl) : undefined;
209351
+ _this.injectorClient =
209352
+ _this.options.config.injectorUrl && _this.options.config.contractAddress
209353
+ ? new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(_this.options.config.injectorUrl, _this.options.config.contractAddress)
209354
+ : undefined;
209352
209355
  _this.state = new TezosSaplingState_1.TezosSaplingState(_this.options.config.merkleTreeHeight);
209353
209356
  _this.encoder = new TezosSaplingEncoder_1.TezosSaplingEncoder();
209354
209357
  _this.forger = new TezosSaplingForger_1.TezosSaplingForger(_this.cryptoClient, _this.state, _this.encoder, _this.options.config.externalProvider);
@@ -209475,7 +209478,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
209475
209478
  this.nodeClient = new TezosSaplingNodeClient_1.TezosSaplingNodeClient(this.options.network.rpcUrl, address);
209476
209479
  this.contract = new TezosContract_1.TezosContract(address, this.options.network);
209477
209480
  this.options.config.injectorUrl = configuration === null || configuration === void 0 ? void 0 : configuration.injectorUrl;
209478
- this.injectorClient = new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(configuration === null || configuration === void 0 ? void 0 : configuration.injectorUrl);
209481
+ this.injectorClient = new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(configuration === null || configuration === void 0 ? void 0 : configuration.injectorUrl, address);
209479
209482
  return [2 /*return*/];
209480
209483
  });
209481
209484
  });
@@ -209766,14 +209769,12 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
209766
209769
  });
209767
209770
  };
209768
209771
  TezosSaplingProtocol.prototype.getTransactionDetailsFromSigned = function (transaction, data) {
209772
+ var _a;
209769
209773
  return __awaiter(this, void 0, void 0, function () {
209770
- var airGapTxs, tx, defaultDetails, partialDetails, wrappedOperation, _a, _b, _c, _d, partialDetails;
209771
- return __generator(this, function (_e) {
209772
- switch (_e.label) {
209774
+ var airGapTxs, tx, defaultDetails, partialDetails, wrappedOperation, _b, _c, _d, _e, partialDetails;
209775
+ return __generator(this, function (_f) {
209776
+ switch (_f.label) {
209773
209777
  case 0:
209774
- if (this.contract === undefined) {
209775
- throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
209776
- }
209777
209778
  airGapTxs = [];
209778
209779
  tx = transaction.transaction;
209779
209780
  defaultDetails = {
@@ -209785,28 +209786,28 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
209785
209786
  protocolIdentifier: this.identifier,
209786
209787
  network: this.options.network
209787
209788
  };
209788
- if (!this.contract.areValidParameters(tx)) return [3 /*break*/, 2];
209789
+ if (!((_a = this.contract) === null || _a === void 0 ? void 0 : _a.areValidParameters(tx))) return [3 /*break*/, 2];
209789
209790
  return [4 /*yield*/, this.getPartialDetailsFromContractParameters(tx, data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
209790
209791
  case 1:
209791
- partialDetails = _e.sent();
209792
+ partialDetails = _f.sent();
209792
209793
  airGapTxs.push.apply(airGapTxs, partialDetails.map(function (partial) { return (__assign(__assign({}, defaultDetails), partial)); }));
209793
209794
  return [3 /*break*/, 7];
209794
209795
  case 2:
209795
- _e.trys.push([2, 5, , 7]);
209796
+ _f.trys.push([2, 5, , 7]);
209796
209797
  return [4 /*yield*/, this.tezosProtocol.unforgeSignedTezosWrappedOperation(tx)];
209797
209798
  case 3:
209798
- wrappedOperation = _e.sent();
209799
- _b = (_a = airGapTxs.push).apply;
209800
- _c = [airGapTxs];
209799
+ wrappedOperation = _f.sent();
209800
+ _c = (_b = airGapTxs.push).apply;
209801
+ _d = [airGapTxs];
209801
209802
  return [4 /*yield*/, this.getTransactionDetailsFromWrappedOperation(wrappedOperation, data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
209802
209803
  case 4:
209803
- _b.apply(_a, _c.concat([(_e.sent())]));
209804
+ _c.apply(_b, _d.concat([(_f.sent())]));
209804
209805
  return [3 /*break*/, 7];
209805
209806
  case 5:
209806
- _d = _e.sent();
209807
+ _e = _f.sent();
209807
209808
  return [4 /*yield*/, this.bookkeeper.getTransactionsPartialDetails([tx], data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
209808
209809
  case 6:
209809
- partialDetails = _e.sent();
209810
+ partialDetails = _f.sent();
209810
209811
  airGapTxs.push.apply(airGapTxs, partialDetails.map(function (partial) { return (__assign(__assign({}, defaultDetails), partial)); }));
209811
209812
  return [3 /*break*/, 7];
209812
209813
  case 7: return [2 /*return*/, this.filterOutPaybacks(airGapTxs)];
@@ -210266,7 +210267,7 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
210266
210267
  switch (_a.label) {
210267
210268
  case 0:
210268
210269
  if (!this.injectorClient) {
210269
- throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, "Can't broadcast a sapling transaction, an injector service URL has not be set.");
210270
+ throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, "Can't broadcast a sapling transaction, an injector service URL or contract address has not be set.");
210270
210271
  }
210271
210272
  _a.label = 1;
210272
210273
  case 1:
@@ -210641,15 +210642,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
210641
210642
  exports.TezosSaplingInjectorClient = void 0;
210642
210643
  var axios_0_19_0_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0"));
210643
210644
  var TezosSaplingInjectorClient = /** @class */ (function () {
210644
- function TezosSaplingInjectorClient(url) {
210645
+ function TezosSaplingInjectorClient(url, contractAddress) {
210645
210646
  this.url = url;
210647
+ this.contractAddress = contractAddress;
210646
210648
  }
210647
210649
  TezosSaplingInjectorClient.prototype.injectTransaction = function (transaction) {
210648
210650
  return __awaiter(this, void 0, void 0, function () {
210649
210651
  var response;
210650
210652
  return __generator(this, function (_a) {
210651
210653
  switch (_a.label) {
210652
- case 0: return [4 /*yield*/, axios_0_19_0_1.default.post(this.url + "/sapling_tx", { transaction: transaction })];
210654
+ case 0: return [4 /*yield*/, axios_0_19_0_1.default.post(this.url + "/sapling_transaction", {
210655
+ transaction: transaction,
210656
+ contractAddress: this.contractAddress
210657
+ })];
210653
210658
  case 1:
210654
210659
  response = _a.sent();
210655
210660
  return [2 /*return*/, response.data.hash];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airgap/serializer",
3
- "version": "0.13.7-beta.20",
3
+ "version": "0.13.7-beta.22",
4
4
  "description": "The @airgap/serializer provides serializers used in AirGap applications.",
5
5
  "keywords": [
6
6
  "airgap",