@airgap/serializer 0.13.7-beta.12 → 0.13.7-beta.14
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/airgap-coinlib-serializer.min.js +61 -13
- package/package.json +1 -1
|
@@ -209300,8 +209300,12 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
209300
209300
|
_this.units = (_f = _this.options.config.units) !== null && _f !== void 0 ? _f : _this.tezosProtocol.units;
|
|
209301
209301
|
_this.standardDerivationPath = _this.tezosProtocol.standardDerivationPath;
|
|
209302
209302
|
_this.cryptoClient = new TezosSaplingCryptoClient_1.TezosSaplingCryptoClient(_this.tezosProtocol.cryptoClient);
|
|
209303
|
-
_this.nodeClient =
|
|
209304
|
-
|
|
209303
|
+
_this.nodeClient = _this.options.config.contractAddress
|
|
209304
|
+
? new TezosSaplingNodeClient_1.TezosSaplingNodeClient(_this.options.network.rpcUrl, _this.options.config.contractAddress)
|
|
209305
|
+
: undefined;
|
|
209306
|
+
_this.contract = _this.options.config.contractAddress
|
|
209307
|
+
? new TezosContract_1.TezosContract(_this.options.config.contractAddress, _this.options.network)
|
|
209308
|
+
: undefined;
|
|
209305
209309
|
_this.state = new TezosSaplingState_1.TezosSaplingState(_this.options.config.merkleTreeHeight);
|
|
209306
209310
|
_this.encoder = new TezosSaplingEncoder_1.TezosSaplingEncoder();
|
|
209307
209311
|
_this.forger = new TezosSaplingForger_1.TezosSaplingForger(_this.cryptoClient, _this.state, _this.encoder, _this.options.config.externalProvider);
|
|
@@ -209413,6 +209417,16 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
209413
209417
|
});
|
|
209414
209418
|
});
|
|
209415
209419
|
};
|
|
209420
|
+
TezosSaplingProtocol.prototype.setContractAddress = function (address) {
|
|
209421
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
209422
|
+
return __generator(this, function (_a) {
|
|
209423
|
+
this.options.config.contractAddress = address;
|
|
209424
|
+
this.nodeClient = new TezosSaplingNodeClient_1.TezosSaplingNodeClient(this.options.network.rpcUrl, address);
|
|
209425
|
+
this.contract = new TezosContract_1.TezosContract(address, this.options.network);
|
|
209426
|
+
return [2 /*return*/];
|
|
209427
|
+
});
|
|
209428
|
+
});
|
|
209429
|
+
};
|
|
209416
209430
|
TezosSaplingProtocol.prototype.initParameters = function (spendParams, outputParams) {
|
|
209417
209431
|
var _a;
|
|
209418
209432
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -209567,7 +209581,14 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
209567
209581
|
var _this = this;
|
|
209568
209582
|
return __generator(this, function (_b) {
|
|
209569
209583
|
switch (_b.label) {
|
|
209570
|
-
case 0:
|
|
209584
|
+
case 0:
|
|
209585
|
+
if (this.nodeClient === undefined) {
|
|
209586
|
+
return [2 /*return*/, {
|
|
209587
|
+
transactions: [],
|
|
209588
|
+
cursor: { page: 0 }
|
|
209589
|
+
}];
|
|
209590
|
+
}
|
|
209591
|
+
return [4 /*yield*/, this.nodeClient.getSaplingStateDiff()];
|
|
209571
209592
|
case 1:
|
|
209572
209593
|
saplingStateDiff = _b.sent();
|
|
209573
209594
|
incoming = [];
|
|
@@ -209697,6 +209718,9 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
209697
209718
|
return __generator(this, function (_e) {
|
|
209698
209719
|
switch (_e.label) {
|
|
209699
209720
|
case 0:
|
|
209721
|
+
if (this.contract === undefined) {
|
|
209722
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
209723
|
+
}
|
|
209700
209724
|
airGapTxs = [];
|
|
209701
209725
|
tx = transaction.transaction;
|
|
209702
209726
|
defaultDetails = {
|
|
@@ -209774,6 +209798,9 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
209774
209798
|
return __generator(this, function (_a) {
|
|
209775
209799
|
switch (_a.label) {
|
|
209776
209800
|
case 0:
|
|
209801
|
+
if (this.contract === undefined) {
|
|
209802
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
209803
|
+
}
|
|
209777
209804
|
parameters = typeof rawOrParsed === 'string' ? this.contract.parseParameters(rawOrParsed) : rawOrParsed;
|
|
209778
209805
|
return [4 /*yield*/, this.parseParameters(parameters)];
|
|
209779
209806
|
case 1:
|
|
@@ -209799,7 +209826,11 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
209799
209826
|
var saplingStateDiff, unspends, balance;
|
|
209800
209827
|
return __generator(this, function (_a) {
|
|
209801
209828
|
switch (_a.label) {
|
|
209802
|
-
case 0:
|
|
209829
|
+
case 0:
|
|
209830
|
+
if (this.nodeClient === undefined) {
|
|
209831
|
+
return [2 /*return*/, '0'];
|
|
209832
|
+
}
|
|
209833
|
+
return [4 /*yield*/, this.nodeClient.getSaplingStateDiff()];
|
|
209803
209834
|
case 1:
|
|
209804
209835
|
saplingStateDiff = _a.sent();
|
|
209805
209836
|
return [4 /*yield*/, this.bookkeeper.getUnspends(publicKey, saplingStateDiff.commitments_and_ciphertexts, saplingStateDiff.nullifiers)];
|
|
@@ -209855,6 +209886,9 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
209855
209886
|
return __generator(this, function (_a) {
|
|
209856
209887
|
switch (_a.label) {
|
|
209857
209888
|
case 0:
|
|
209889
|
+
if (this.contract === undefined) {
|
|
209890
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
209891
|
+
}
|
|
209858
209892
|
if (!(typeof transactionsOrString === 'string' && this.contract.areValidParameters(transactionsOrString))) return [3 /*break*/, 1];
|
|
209859
209893
|
parameters = this.contract.parseParameters(transactionsOrString);
|
|
209860
209894
|
operations = [this.prepareTezosOperation(parameters, fee)];
|
|
@@ -209943,6 +209977,9 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
209943
209977
|
return __generator(this, function (_g) {
|
|
209944
209978
|
switch (_g.label) {
|
|
209945
209979
|
case 0:
|
|
209980
|
+
if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
|
|
209981
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
209982
|
+
}
|
|
209946
209983
|
if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
209947
209984
|
return [2 /*return*/, Promise.reject("Invalid recpient, expected a 'zet' address, got " + recipient)];
|
|
209948
209985
|
}
|
|
@@ -209992,6 +210029,9 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
209992
210029
|
return __generator(this, function (_c) {
|
|
209993
210030
|
switch (_c.label) {
|
|
209994
210031
|
case 0:
|
|
210032
|
+
if (this.nodeClient === undefined) {
|
|
210033
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
210034
|
+
}
|
|
209995
210035
|
if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
209996
210036
|
return [2 /*return*/, Promise.reject("Invalid recipient, expected a 'zet' address, got " + recipient)];
|
|
209997
210037
|
}
|
|
@@ -210026,10 +210066,14 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
210026
210066
|
var _c;
|
|
210027
210067
|
return __generator(this, function (_d) {
|
|
210028
210068
|
switch (_d.label) {
|
|
210029
|
-
case 0:
|
|
210030
|
-
|
|
210031
|
-
|
|
210032
|
-
|
|
210069
|
+
case 0:
|
|
210070
|
+
if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
|
|
210071
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
210072
|
+
}
|
|
210073
|
+
return [4 /*yield*/, Promise.all([
|
|
210074
|
+
this.nodeClient.getSaplingStateDiff(),
|
|
210075
|
+
this.nodeClient.getChainId()
|
|
210076
|
+
])];
|
|
210033
210077
|
case 1:
|
|
210034
210078
|
_a = _d.sent(), stateDiff = _a[0], chainId = _a[1];
|
|
210035
210079
|
return [4 /*yield*/, this.chooseInputs(viewingKey, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value)];
|
|
@@ -210290,14 +210334,14 @@ var TezosProtocol_1 = require("../TezosProtocol");
|
|
|
210290
210334
|
var TezosProtocolOptions_1 = require("../TezosProtocolOptions");
|
|
210291
210335
|
var TezosSaplingProtocolConfig = /** @class */ (function (_super) {
|
|
210292
210336
|
__extends(TezosSaplingProtocolConfig, _super);
|
|
210293
|
-
function TezosSaplingProtocolConfig(name, identifier,
|
|
210337
|
+
function TezosSaplingProtocolConfig(name, identifier, memoSize, merkleTreeHeight, contractAddress, symbol, marketSymbol, feeDefaults, decimals, units, externalProvider) {
|
|
210294
210338
|
if (merkleTreeHeight === void 0) { merkleTreeHeight = 32; }
|
|
210295
210339
|
var _this = _super.call(this) || this;
|
|
210296
210340
|
_this.name = name;
|
|
210297
210341
|
_this.identifier = identifier;
|
|
210298
|
-
_this.contractAddress = contractAddress;
|
|
210299
210342
|
_this.memoSize = memoSize;
|
|
210300
210343
|
_this.merkleTreeHeight = merkleTreeHeight;
|
|
210344
|
+
_this.contractAddress = contractAddress;
|
|
210301
210345
|
_this.symbol = symbol;
|
|
210302
210346
|
_this.marketSymbol = marketSymbol;
|
|
210303
210347
|
_this.feeDefaults = feeDefaults;
|
|
@@ -210314,10 +210358,9 @@ var TezosShieldedTezProtocolConfig = /** @class */ (function (_super) {
|
|
|
210314
210358
|
function TezosShieldedTezProtocolConfig(name, identifier, contractAddress, externalProvider, memoSize, merkleTreeHeight) {
|
|
210315
210359
|
if (name === void 0) { name = 'Shielded Tez'; }
|
|
210316
210360
|
if (identifier === void 0) { identifier = ProtocolSymbols_1.MainProtocolSymbols.XTZ_SHIELDED; }
|
|
210317
|
-
if (contractAddress === void 0) { contractAddress = 'KT1Wr1z3CwrZamPsazpVXefpEjXUBScUPuHZ'; }
|
|
210318
210361
|
if (memoSize === void 0) { memoSize = 8; }
|
|
210319
210362
|
if (merkleTreeHeight === void 0) { merkleTreeHeight = 32; }
|
|
210320
|
-
var _this = _super.call(this, name, identifier,
|
|
210363
|
+
var _this = _super.call(this, name, identifier, memoSize, merkleTreeHeight, contractAddress, undefined, undefined, undefined, undefined, undefined, externalProvider) || this;
|
|
210321
210364
|
_this.name = name;
|
|
210322
210365
|
_this.identifier = identifier;
|
|
210323
210366
|
_this.contractAddress = contractAddress;
|
|
@@ -210402,7 +210445,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
210402
210445
|
};
|
|
210403
210446
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
210404
210447
|
exports.TezosShieldedTezProtocol = void 0;
|
|
210448
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
210405
210449
|
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
210450
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
210406
210451
|
var hex_1 = require("@airgap/coinlib-core/utils/hex");
|
|
210407
210452
|
var MichelsonList_1 = require("../types/michelson/generics/MichelsonList");
|
|
210408
210453
|
var MichelsonBytes_1 = require("../types/michelson/primitives/MichelsonBytes");
|
|
@@ -210421,6 +210466,9 @@ var TezosShieldedTezProtocol = /** @class */ (function (_super) {
|
|
|
210421
210466
|
return __generator(this, function (_a) {
|
|
210422
210467
|
switch (_a.label) {
|
|
210423
210468
|
case 0:
|
|
210469
|
+
if (this.contract === undefined) {
|
|
210470
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'Contract address not set.');
|
|
210471
|
+
}
|
|
210424
210472
|
balances = transactions.map(function (transaction) {
|
|
210425
210473
|
var signedBuffer = Buffer.isBuffer(transaction) ? transaction : hex_1.isHex(transaction) ? Buffer.from(transaction, 'hex') : undefined;
|
|
210426
210474
|
return signedBuffer ? _this.encoder.decodeBalanceFromTransaction(signedBuffer) : new bignumber_1.default(0);
|
|
@@ -210457,7 +210505,7 @@ var TezosShieldedTezProtocol = /** @class */ (function (_super) {
|
|
|
210457
210505
|
exports.TezosShieldedTezProtocol = TezosShieldedTezProtocol;
|
|
210458
210506
|
|
|
210459
210507
|
}).call(this)}).call(this,require("buffer").Buffer)
|
|
210460
|
-
},{"../types/michelson/generics/MichelsonList":1284,"../types/michelson/primitives/MichelsonBytes":1291,"./TezosSaplingProtocol":1271,"./TezosSaplingProtocolOptions":1272,"@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber":454,"@airgap/coinlib-core/utils/hex":694,"buffer":76}],1274:[function(require,module,exports){
|
|
210508
|
+
},{"../types/michelson/generics/MichelsonList":1284,"../types/michelson/primitives/MichelsonBytes":1291,"./TezosSaplingProtocol":1271,"./TezosSaplingProtocolOptions":1272,"@airgap/coinlib-core":674,"@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber":454,"@airgap/coinlib-core/errors":673,"@airgap/coinlib-core/utils/hex":694,"buffer":76}],1274:[function(require,module,exports){
|
|
210461
210509
|
"use strict";
|
|
210462
210510
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
210463
210511
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|