@taquito/sapling 17.3.2 → 17.4.0-beta-RC.0
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/lib/constants.js +0 -1
- package/dist/lib/errors.js +0 -1
- package/dist/lib/sapling-forger/sapling-forger.js +8 -9
- package/dist/lib/sapling-keys/helpers.js +6 -7
- package/dist/lib/sapling-keys/in-memory-proving-key.js +15 -18
- package/dist/lib/sapling-keys/in-memory-spending-key.js +22 -25
- package/dist/lib/sapling-keys/in-memory-viewing-key.js +18 -21
- package/dist/lib/sapling-module-wrapper.js +1 -2
- package/dist/lib/sapling-state/sapling-state.js +6 -7
- package/dist/lib/sapling-state/utils.js +0 -1
- package/dist/lib/sapling-tx-builder/sapling-transactions-builder.js +78 -80
- package/dist/lib/sapling-tx-viewer/helpers.js +2 -3
- package/dist/lib/sapling-tx-viewer/sapling-transaction-viewer.js +36 -39
- package/dist/lib/taquito-sapling.js +55 -58
- package/dist/lib/types.js +0 -1
- package/dist/lib/version.js +2 -3
- package/dist/taquito-sapling.es6.js +1383 -1380
- package/dist/taquito-sapling.es6.js.map +1 -1
- package/dist/taquito-sapling.umd.js +1387 -1393
- package/dist/taquito-sapling.umd.js.map +1 -1
- package/dist/types/constants.d.ts +5 -5
- package/dist/types/errors.d.ts +52 -52
- package/dist/types/sapling-forger/sapling-forger.d.ts +30 -30
- package/dist/types/sapling-keys/helpers.d.ts +2 -2
- package/dist/types/sapling-keys/in-memory-proving-key.d.ts +35 -35
- package/dist/types/sapling-keys/in-memory-spending-key.d.ts +53 -53
- package/dist/types/sapling-keys/in-memory-viewing-key.d.ts +48 -48
- package/dist/types/sapling-module-wrapper.d.ts +19 -19
- package/dist/types/sapling-state/sapling-state.d.ts +56 -56
- package/dist/types/sapling-state/utils.d.ts +22 -22
- package/dist/types/sapling-tx-builder/sapling-transactions-builder.d.ts +32 -32
- package/dist/types/sapling-tx-viewer/helpers.d.ts +11 -11
- package/dist/types/sapling-tx-viewer/sapling-transaction-viewer.d.ts +50 -50
- package/dist/types/taquito-sapling.d.ts +81 -81
- package/dist/types/types.d.ts +147 -147
- package/dist/types/version.d.ts +4 -4
- package/package.json +33 -35
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/errors.js.map +0 -1
- package/dist/lib/sapling-forger/sapling-forger.js.map +0 -1
- package/dist/lib/sapling-keys/helpers.js.map +0 -1
- package/dist/lib/sapling-keys/in-memory-proving-key.js.map +0 -1
- package/dist/lib/sapling-keys/in-memory-spending-key.js.map +0 -1
- package/dist/lib/sapling-keys/in-memory-viewing-key.js.map +0 -1
- package/dist/lib/sapling-module-wrapper.js.map +0 -1
- package/dist/lib/sapling-state/sapling-state.js.map +0 -1
- package/dist/lib/sapling-state/utils.js.map +0 -1
- package/dist/lib/sapling-tx-builder/sapling-transactions-builder.js.map +0 -1
- package/dist/lib/sapling-tx-viewer/helpers.js.map +0 -1
- package/dist/lib/sapling-tx-viewer/sapling-transaction-viewer.js.map +0 -1
- package/dist/lib/taquito-sapling.js.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/version.js.map +0 -1
|
@@ -12,18 +12,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return value;
|
|
15
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
16
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
17
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
18
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
19
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
21
20
|
};
|
|
22
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
23
|
-
if (!
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return privateMap.get(receiver);
|
|
21
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
22
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
23
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
24
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
27
25
|
};
|
|
28
26
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
29
27
|
var t = {};
|
|
@@ -36,7 +34,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
36
34
|
}
|
|
37
35
|
return t;
|
|
38
36
|
};
|
|
39
|
-
var
|
|
37
|
+
var _SaplingToolkit_inMemorySpendingKey, _SaplingToolkit_saplingId, _SaplingToolkit_contractAddress, _SaplingToolkit_memoSize, _SaplingToolkit_readProvider, _SaplingToolkit_packer, _SaplingToolkit_saplingForger, _SaplingToolkit_saplingTxBuilder, _SaplingToolkit_saplingTransactionViewer;
|
|
40
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
39
|
exports.SaplingToolkit = exports.InMemoryProvingKey = exports.InMemorySpendingKey = exports.InMemoryViewingKey = exports.SaplingTransactionViewer = void 0;
|
|
42
40
|
const bignumber_js_1 = require("bignumber.js");
|
|
@@ -81,23 +79,23 @@ Object.defineProperty(exports, "InMemoryProvingKey", { enumerable: true, get: fu
|
|
|
81
79
|
*/
|
|
82
80
|
class SaplingToolkit {
|
|
83
81
|
constructor(keys, saplingContractDetails, readProvider, packer = new taquito_1.MichelCodecPacker(), saplingForger = new sapling_forger_1.SaplingForger(), saplingTxBuilder = new sapling_transactions_builder_1.SaplingTransactionBuilder(keys, saplingForger, saplingContractDetails, readProvider)) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
__classPrivateFieldSet(this,
|
|
94
|
-
__classPrivateFieldSet(this,
|
|
95
|
-
__classPrivateFieldSet(this,
|
|
96
|
-
__classPrivateFieldSet(this,
|
|
97
|
-
__classPrivateFieldSet(this,
|
|
98
|
-
__classPrivateFieldSet(this,
|
|
99
|
-
__classPrivateFieldSet(this,
|
|
100
|
-
__classPrivateFieldSet(this,
|
|
82
|
+
_SaplingToolkit_inMemorySpendingKey.set(this, void 0);
|
|
83
|
+
_SaplingToolkit_saplingId.set(this, void 0);
|
|
84
|
+
_SaplingToolkit_contractAddress.set(this, void 0);
|
|
85
|
+
_SaplingToolkit_memoSize.set(this, void 0);
|
|
86
|
+
_SaplingToolkit_readProvider.set(this, void 0);
|
|
87
|
+
_SaplingToolkit_packer.set(this, void 0);
|
|
88
|
+
_SaplingToolkit_saplingForger.set(this, void 0);
|
|
89
|
+
_SaplingToolkit_saplingTxBuilder.set(this, void 0);
|
|
90
|
+
_SaplingToolkit_saplingTransactionViewer.set(this, void 0);
|
|
91
|
+
__classPrivateFieldSet(this, _SaplingToolkit_inMemorySpendingKey, keys.saplingSigner, "f");
|
|
92
|
+
__classPrivateFieldSet(this, _SaplingToolkit_saplingId, saplingContractDetails.saplingId, "f");
|
|
93
|
+
__classPrivateFieldSet(this, _SaplingToolkit_contractAddress, saplingContractDetails.contractAddress, "f");
|
|
94
|
+
__classPrivateFieldSet(this, _SaplingToolkit_memoSize, saplingContractDetails.memoSize, "f");
|
|
95
|
+
__classPrivateFieldSet(this, _SaplingToolkit_readProvider, readProvider, "f");
|
|
96
|
+
__classPrivateFieldSet(this, _SaplingToolkit_packer, packer, "f");
|
|
97
|
+
__classPrivateFieldSet(this, _SaplingToolkit_saplingForger, saplingForger, "f");
|
|
98
|
+
__classPrivateFieldSet(this, _SaplingToolkit_saplingTxBuilder, saplingTxBuilder, "f");
|
|
101
99
|
}
|
|
102
100
|
/**
|
|
103
101
|
* @description Get an instance of `SaplingTransactionViewer` which allows to retrieve and decrypt sapling transactions and calculate the unspent balance.
|
|
@@ -105,12 +103,12 @@ class SaplingToolkit {
|
|
|
105
103
|
getSaplingTransactionViewer() {
|
|
106
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
105
|
let saplingTransactionViewer;
|
|
108
|
-
if (!__classPrivateFieldGet(this,
|
|
109
|
-
const saplingViewingKey = yield __classPrivateFieldGet(this,
|
|
110
|
-
saplingTransactionViewer = new sapling_transaction_viewer_1.SaplingTransactionViewer(saplingViewingKey, this.getSaplingContractId(), __classPrivateFieldGet(this,
|
|
111
|
-
__classPrivateFieldSet(this,
|
|
106
|
+
if (!__classPrivateFieldGet(this, _SaplingToolkit_saplingTransactionViewer, "f")) {
|
|
107
|
+
const saplingViewingKey = yield __classPrivateFieldGet(this, _SaplingToolkit_inMemorySpendingKey, "f").getSaplingViewingKeyProvider();
|
|
108
|
+
saplingTransactionViewer = new sapling_transaction_viewer_1.SaplingTransactionViewer(saplingViewingKey, this.getSaplingContractId(), __classPrivateFieldGet(this, _SaplingToolkit_readProvider, "f"));
|
|
109
|
+
__classPrivateFieldSet(this, _SaplingToolkit_saplingTransactionViewer, saplingTransactionViewer, "f");
|
|
112
110
|
}
|
|
113
|
-
return __classPrivateFieldGet(this,
|
|
111
|
+
return __classPrivateFieldGet(this, _SaplingToolkit_saplingTransactionViewer, "f");
|
|
114
112
|
});
|
|
115
113
|
}
|
|
116
114
|
/**
|
|
@@ -125,8 +123,8 @@ class SaplingToolkit {
|
|
|
125
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
124
|
const { formatedParams, totalAmount } = this.formatTransactionParams(shieldedTxParams, this.validateDestinationSaplingAddress);
|
|
127
125
|
const root = yield this.getRoot();
|
|
128
|
-
const { inputs, outputs, signature, balance } = yield __classPrivateFieldGet(this,
|
|
129
|
-
const forgedSaplingTx = __classPrivateFieldGet(this,
|
|
126
|
+
const { inputs, outputs, signature, balance } = yield __classPrivateFieldGet(this, _SaplingToolkit_saplingTxBuilder, "f").createShieldedTx(formatedParams, totalAmount, constants_1.DEFAULT_BOUND_DATA);
|
|
127
|
+
const forgedSaplingTx = __classPrivateFieldGet(this, _SaplingToolkit_saplingForger, "f").forgeSaplingTransaction({
|
|
130
128
|
inputs,
|
|
131
129
|
outputs,
|
|
132
130
|
balance,
|
|
@@ -150,8 +148,8 @@ class SaplingToolkit {
|
|
|
150
148
|
const boundData = yield this.createBoundData(formatedParams[0].to);
|
|
151
149
|
const root = yield this.getRoot();
|
|
152
150
|
const chosenInputs = yield this.selectInputsToSpend(new bignumber_js_1.default(formatedParams[0].amount));
|
|
153
|
-
const { inputs, outputs, signature, balance } = yield __classPrivateFieldGet(this,
|
|
154
|
-
const forgedSaplingTx = __classPrivateFieldGet(this,
|
|
151
|
+
const { inputs, outputs, signature, balance } = yield __classPrivateFieldGet(this, _SaplingToolkit_saplingTxBuilder, "f").createSaplingTx([], totalAmount, boundData, chosenInputs);
|
|
152
|
+
const forgedSaplingTx = __classPrivateFieldGet(this, _SaplingToolkit_saplingForger, "f").forgeSaplingTransaction({
|
|
155
153
|
inputs,
|
|
156
154
|
outputs,
|
|
157
155
|
balance,
|
|
@@ -175,8 +173,8 @@ class SaplingToolkit {
|
|
|
175
173
|
const { formatedParams, totalAmount } = this.formatTransactionParams(saplingTxParams, this.validateDestinationSaplingAddress);
|
|
176
174
|
const root = yield this.getRoot();
|
|
177
175
|
const chosenInputs = yield this.selectInputsToSpend(totalAmount);
|
|
178
|
-
const { inputs, outputs, signature, balance } = yield __classPrivateFieldGet(this,
|
|
179
|
-
const forgedSaplingTx = __classPrivateFieldGet(this,
|
|
176
|
+
const { inputs, outputs, signature, balance } = yield __classPrivateFieldGet(this, _SaplingToolkit_saplingTxBuilder, "f").createSaplingTx(formatedParams, totalAmount, constants_1.DEFAULT_BOUND_DATA, chosenInputs);
|
|
177
|
+
const forgedSaplingTx = __classPrivateFieldGet(this, _SaplingToolkit_saplingForger, "f").forgeSaplingTransaction({
|
|
180
178
|
inputs,
|
|
181
179
|
outputs,
|
|
182
180
|
balance,
|
|
@@ -195,11 +193,11 @@ class SaplingToolkit {
|
|
|
195
193
|
validateDestination(param.to);
|
|
196
194
|
const amountMutez = param.mutez
|
|
197
195
|
? param.amount.toString()
|
|
198
|
-
: utils_1.format('tz', 'mutez', param.amount).toString();
|
|
196
|
+
: (0, utils_1.format)('tz', 'mutez', param.amount).toString();
|
|
199
197
|
totalAmount = totalAmount.plus(new bignumber_js_1.default(amountMutez));
|
|
200
198
|
const memo = (_a = param.memo) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_MEMO;
|
|
201
|
-
if (memo.length > __classPrivateFieldGet(this,
|
|
202
|
-
throw new errors_1.InvalidMemo(memo, `expecting length to be less than ${__classPrivateFieldGet(this,
|
|
199
|
+
if (memo.length > __classPrivateFieldGet(this, _SaplingToolkit_memoSize, "f")) {
|
|
200
|
+
throw new errors_1.InvalidMemo(memo, `expecting length to be less than ${__classPrivateFieldGet(this, _SaplingToolkit_memoSize, "f")}`);
|
|
203
201
|
}
|
|
204
202
|
formatedParams.push({ to: param.to, amount: amountMutez, memo });
|
|
205
203
|
});
|
|
@@ -207,12 +205,12 @@ class SaplingToolkit {
|
|
|
207
205
|
}
|
|
208
206
|
getRoot() {
|
|
209
207
|
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
-
if (__classPrivateFieldGet(this,
|
|
211
|
-
const { root } = yield __classPrivateFieldGet(this,
|
|
208
|
+
if (__classPrivateFieldGet(this, _SaplingToolkit_saplingId, "f")) {
|
|
209
|
+
const { root } = yield __classPrivateFieldGet(this, _SaplingToolkit_readProvider, "f").getSaplingDiffById({ id: __classPrivateFieldGet(this, _SaplingToolkit_saplingId, "f") }, 'head');
|
|
212
210
|
return root;
|
|
213
211
|
}
|
|
214
212
|
else {
|
|
215
|
-
const { root } = yield __classPrivateFieldGet(this,
|
|
213
|
+
const { root } = yield __classPrivateFieldGet(this, _SaplingToolkit_readProvider, "f").getSaplingDiffByContract(__classPrivateFieldGet(this, _SaplingToolkit_contractAddress, "f"), 'head');
|
|
216
214
|
return root;
|
|
217
215
|
}
|
|
218
216
|
});
|
|
@@ -235,13 +233,13 @@ class SaplingToolkit {
|
|
|
235
233
|
break;
|
|
236
234
|
}
|
|
237
235
|
default: {
|
|
238
|
-
throw new core_1.InvalidAddressError(destination, utils_1.invalidDetail(utils_1.ValidationResult.NO_PREFIX_MATCHED) +
|
|
236
|
+
throw new core_1.InvalidAddressError(destination, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) +
|
|
239
237
|
` expecting one of the following prefix '${utils_1.Prefix.TZ1}', '${utils_1.Prefix.TZ2}' or '${utils_1.Prefix.TZ3}'.`);
|
|
240
238
|
}
|
|
241
239
|
}
|
|
242
|
-
const decodedDestination = utils_1.b58cdecode(destination, utils_1.prefix[pref]);
|
|
240
|
+
const decodedDestination = (0, utils_1.b58cdecode)(destination, utils_1.prefix[pref]);
|
|
243
241
|
const padDestination = Buffer.concat([pad, Buffer.from(decodedDestination)]);
|
|
244
|
-
const packedDestination = yield __classPrivateFieldGet(this,
|
|
242
|
+
const packedDestination = yield __classPrivateFieldGet(this, _SaplingToolkit_packer, "f").packData({
|
|
245
243
|
data: { bytes: padDestination.toString('hex') },
|
|
246
244
|
type: { prim: 'bytes' },
|
|
247
245
|
});
|
|
@@ -249,23 +247,23 @@ class SaplingToolkit {
|
|
|
249
247
|
});
|
|
250
248
|
}
|
|
251
249
|
validateDestinationImplicitAddress(to) {
|
|
252
|
-
const toValidation = utils_1.validateKeyHash(to);
|
|
250
|
+
const toValidation = (0, utils_1.validateKeyHash)(to);
|
|
253
251
|
if (toValidation !== utils_1.ValidationResult.VALID) {
|
|
254
|
-
throw new core_1.InvalidKeyHashError(to, utils_1.invalidDetail(toValidation));
|
|
252
|
+
throw new core_1.InvalidKeyHashError(to, (0, utils_1.invalidDetail)(toValidation));
|
|
255
253
|
}
|
|
256
254
|
}
|
|
257
255
|
validateDestinationSaplingAddress(to) {
|
|
258
256
|
if (!to.startsWith(utils_1.Prefix.ZET1)) {
|
|
259
|
-
throw new core_1.InvalidAddressError(to, utils_1.invalidDetail(utils_1.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix ${utils_1.Prefix.ZET1}.`);
|
|
257
|
+
throw new core_1.InvalidAddressError(to, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix ${utils_1.Prefix.ZET1}.`);
|
|
260
258
|
}
|
|
261
259
|
}
|
|
262
260
|
getSaplingContractId() {
|
|
263
261
|
let saplingContractId;
|
|
264
|
-
if (__classPrivateFieldGet(this,
|
|
265
|
-
saplingContractId = { saplingId: __classPrivateFieldGet(this,
|
|
262
|
+
if (__classPrivateFieldGet(this, _SaplingToolkit_saplingId, "f")) {
|
|
263
|
+
saplingContractId = { saplingId: __classPrivateFieldGet(this, _SaplingToolkit_saplingId, "f") };
|
|
266
264
|
}
|
|
267
265
|
else {
|
|
268
|
-
saplingContractId = { contractAddress: __classPrivateFieldGet(this,
|
|
266
|
+
saplingContractId = { contractAddress: __classPrivateFieldGet(this, _SaplingToolkit_contractAddress, "f") };
|
|
269
267
|
}
|
|
270
268
|
return saplingContractId;
|
|
271
269
|
}
|
|
@@ -277,7 +275,7 @@ class SaplingToolkit {
|
|
|
277
275
|
let sumSelectedInputs = new bignumber_js_1.default(0);
|
|
278
276
|
incoming.forEach((input) => {
|
|
279
277
|
if (!input.isSpent && sumSelectedInputs.isLessThan(amountMutez)) {
|
|
280
|
-
const txAmount = helpers_1.convertValueToBigNumber(input.value);
|
|
278
|
+
const txAmount = (0, helpers_1.convertValueToBigNumber)(input.value);
|
|
281
279
|
sumSelectedInputs = sumSelectedInputs.plus(txAmount);
|
|
282
280
|
const { isSpent: _isSpent } = input, rest = __rest(input, ["isSpent"]);
|
|
283
281
|
inputsToSpend.push(rest);
|
|
@@ -291,5 +289,4 @@ class SaplingToolkit {
|
|
|
291
289
|
}
|
|
292
290
|
}
|
|
293
291
|
exports.SaplingToolkit = SaplingToolkit;
|
|
294
|
-
|
|
295
|
-
//# sourceMappingURL=taquito-sapling.js.map
|
|
292
|
+
_SaplingToolkit_inMemorySpendingKey = new WeakMap(), _SaplingToolkit_saplingId = new WeakMap(), _SaplingToolkit_contractAddress = new WeakMap(), _SaplingToolkit_memoSize = new WeakMap(), _SaplingToolkit_readProvider = new WeakMap(), _SaplingToolkit_packer = new WeakMap(), _SaplingToolkit_saplingForger = new WeakMap(), _SaplingToolkit_saplingTxBuilder = new WeakMap(), _SaplingToolkit_saplingTransactionViewer = new WeakMap();
|
package/dist/lib/types.js
CHANGED
package/dist/lib/version.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "17.
|
|
6
|
+
"commitHash": "4f44dd73b7659554c167acb80f0c20f222f893a5",
|
|
7
|
+
"version": "17.4.0-beta-RC.0"
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=version.js.map
|