@taquito/taquito 19.2.0 → 20.0.0-beta.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/README.md +1 -1
- package/dist/lib/constants.js +2 -0
- package/dist/lib/contract/rpc-contract-provider.js +106 -0
- package/dist/lib/estimate/rpc-estimate-provider.js +114 -0
- package/dist/lib/prepare/prepare-provider.js +104 -0
- package/dist/lib/read-provider/rpc-read-adapter.js +8 -1
- package/dist/lib/version.js +2 -2
- package/dist/lib/wallet/legacy.js +15 -0
- package/dist/lib/wallet/wallet.js +85 -3
- package/dist/taquito.es6.js +437 -7
- package/dist/taquito.es6.js.map +1 -1
- package/dist/taquito.min.js +1 -1
- package/dist/taquito.umd.js +436 -6
- package/dist/taquito.umd.js.map +1 -1
- package/dist/types/constants.d.ts +3 -1
- package/dist/types/contract/interface.d.ts +28 -1
- package/dist/types/contract/rpc-contract-provider.d.ts +29 -1
- package/dist/types/estimate/estimate-provider-interface.d.ts +28 -1
- package/dist/types/estimate/rpc-estimate-provider.d.ts +28 -1
- package/dist/types/operations/types.d.ts +39 -0
- package/dist/types/prepare/prepare-provider.d.ts +25 -1
- package/dist/types/read-provider/interface.d.ts +7 -2
- package/dist/types/read-provider/rpc-read-adapter.d.ts +7 -2
- package/dist/types/tz/interface.d.ts +1 -1
- package/dist/types/wallet/interface.d.ts +16 -1
- package/dist/types/wallet/legacy.d.ts +4 -1
- package/dist/types/wallet/wallet.d.ts +38 -4
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The `@taquito/taquito` package contains higher-level functionality that builds u
|
|
|
7
7
|
## CDN Bundle
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
|
-
<script src="https://unpkg.com/@taquito/taquito@
|
|
10
|
+
<script src="https://unpkg.com/@taquito/taquito@20.0.0-beta.0/dist/taquito.min.js"
|
|
11
11
|
crossorigin="anonymous" integrity="sha384-IxvP0ECHi5oqLyz94wF85pU9+ktcsL1HHtA42MITxZsGbsUMEu/g+0Vkjj5vqiMR"></script>
|
|
12
12
|
```
|
|
13
13
|
|
package/dist/lib/constants.js
CHANGED
|
@@ -71,6 +71,7 @@ var Protocols;
|
|
|
71
71
|
Protocols["PtMumbai2"] = "PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1";
|
|
72
72
|
Protocols["PtNairobi"] = "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf";
|
|
73
73
|
Protocols["ProxfordY"] = "ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH";
|
|
74
|
+
Protocols["PtParisBQ"] = "PtParisBQscdCm6Cfow6ndeU6wKJyA3aV1j4D3gQBQMsTQyJCrz";
|
|
74
75
|
Protocols["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
|
|
75
76
|
})(Protocols || (exports.Protocols = Protocols = {}));
|
|
76
77
|
exports.protocols = {
|
|
@@ -109,6 +110,7 @@ var ChainIds;
|
|
|
109
110
|
ChainIds["MUMBAINET2"] = "NetXgbcrNtXD2yA";
|
|
110
111
|
ChainIds["NAIROBINET"] = "NetXyuzvDo2Ugzb";
|
|
111
112
|
ChainIds["OXFORDNET2"] = "NetXxWsskGahzQB";
|
|
113
|
+
ChainIds["PARISNET"] = "NetXo8SqH1c38SS";
|
|
112
114
|
})(ChainIds || (exports.ChainIds = ChainIds = {}));
|
|
113
115
|
// A fixed fee reveal operation gasLimit accepted by both simulate and injection endpoint is between 1.2-5 times of actual gas consumption (3.5 fails occasionally with gas exhausted; 4 fails occasionally with fee too low)
|
|
114
116
|
const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
|
|
@@ -302,6 +302,112 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
302
302
|
return new transaction_operation_1.TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
*
|
|
307
|
+
* @description Stake a given amount for the source address
|
|
308
|
+
*
|
|
309
|
+
* @returns An operation handle with the result from the rpc node
|
|
310
|
+
*
|
|
311
|
+
* @param Stake pseudo-operation parameter
|
|
312
|
+
*/
|
|
313
|
+
stake(params) {
|
|
314
|
+
var _a;
|
|
315
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
316
|
+
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
317
|
+
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
318
|
+
throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
|
|
319
|
+
}
|
|
320
|
+
if (!params.to) {
|
|
321
|
+
params.to = params.source;
|
|
322
|
+
}
|
|
323
|
+
if (params.to && params.to !== params.source) {
|
|
324
|
+
throw new core_1.InvalidStakingAddressError(params.to);
|
|
325
|
+
}
|
|
326
|
+
if (params.amount < 0) {
|
|
327
|
+
throw new core_1.InvalidAmountError(params.amount.toString());
|
|
328
|
+
}
|
|
329
|
+
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
330
|
+
const estimate = yield this.estimate(params, this.estimator.stake.bind(this.estimator));
|
|
331
|
+
const source = params.source || publicKeyHash;
|
|
332
|
+
const prepared = yield this.prepare.stake(Object.assign(Object.assign({}, params), estimate));
|
|
333
|
+
const content = prepared.opOb.contents.find((op) => op.kind === rpc_1.OpKind.TRANSACTION);
|
|
334
|
+
const opBytes = yield this.forge(prepared);
|
|
335
|
+
const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
|
|
336
|
+
return new transaction_operation_1.TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
*
|
|
341
|
+
* @description Unstake the given amount. If "everything" is given as amount, unstakes everything from the staking balance.
|
|
342
|
+
* Unstaked tez remains frozen for a set amount of cycles (the slashing period) after the operation. Once this period is over,
|
|
343
|
+
* the operation "finalize unstake" must be called for the funds to appear in the liquid balance.
|
|
344
|
+
*
|
|
345
|
+
* @returns An operation handle with the result from the rpc node
|
|
346
|
+
*
|
|
347
|
+
* @param Unstake pseudo-operation parameter
|
|
348
|
+
*/
|
|
349
|
+
unstake(params) {
|
|
350
|
+
var _a;
|
|
351
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
352
|
+
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
353
|
+
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
354
|
+
throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
|
|
355
|
+
}
|
|
356
|
+
if (!params.to) {
|
|
357
|
+
params.to = params.source;
|
|
358
|
+
}
|
|
359
|
+
if (params.to && params.to !== params.source) {
|
|
360
|
+
throw new core_1.InvalidStakingAddressError(params.to);
|
|
361
|
+
}
|
|
362
|
+
if (params.amount < 0) {
|
|
363
|
+
throw new core_1.InvalidAmountError(params.amount.toString());
|
|
364
|
+
}
|
|
365
|
+
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
366
|
+
const estimate = yield this.estimate(params, this.estimator.unstake.bind(this.estimator));
|
|
367
|
+
const source = params.source || publicKeyHash;
|
|
368
|
+
const prepared = yield this.prepare.unstake(Object.assign(Object.assign({}, params), estimate));
|
|
369
|
+
const content = prepared.opOb.contents.find((op) => op.kind === rpc_1.OpKind.TRANSACTION);
|
|
370
|
+
const opBytes = yield this.forge(prepared);
|
|
371
|
+
const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
|
|
372
|
+
return new transaction_operation_1.TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
*
|
|
377
|
+
* @description Transfer all the finalizable unstaked funds of the source to their liquid balance
|
|
378
|
+
* @returns An operation handle with the result from the rpc node
|
|
379
|
+
*
|
|
380
|
+
* @param Finalize_unstake pseudo-operation parameter
|
|
381
|
+
*/
|
|
382
|
+
finalizeUnstake(params) {
|
|
383
|
+
var _a;
|
|
384
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
385
|
+
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
386
|
+
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
387
|
+
throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
|
|
388
|
+
}
|
|
389
|
+
if (!params.to) {
|
|
390
|
+
params.to = params.source;
|
|
391
|
+
}
|
|
392
|
+
if (params.to && params.to !== params.source) {
|
|
393
|
+
throw new core_1.InvalidStakingAddressError(params.to);
|
|
394
|
+
}
|
|
395
|
+
if (!params.amount) {
|
|
396
|
+
params.amount = 0;
|
|
397
|
+
}
|
|
398
|
+
if (params.amount !== undefined && params.amount > 0) {
|
|
399
|
+
throw new core_1.InvalidFinalizeUnstakeAmountError('Amount must be 0 to finalize unstake.');
|
|
400
|
+
}
|
|
401
|
+
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
402
|
+
const estimate = yield this.estimate(params, this.estimator.finalizeUnstake.bind(this.estimator));
|
|
403
|
+
const source = params.source || publicKeyHash;
|
|
404
|
+
const prepared = yield this.prepare.finalizeUnstake(Object.assign(Object.assign({}, params), estimate));
|
|
405
|
+
const content = prepared.opOb.contents.find((op) => op.kind === rpc_1.OpKind.TRANSACTION);
|
|
406
|
+
const opBytes = yield this.forge(prepared);
|
|
407
|
+
const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
|
|
408
|
+
return new transaction_operation_1.TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
|
|
409
|
+
});
|
|
410
|
+
}
|
|
305
411
|
/**
|
|
306
412
|
*
|
|
307
413
|
* @description Transfer Tickets to a smart contract address
|
|
@@ -178,6 +178,120 @@ class RPCEstimateProvider extends provider_1.Provider {
|
|
|
178
178
|
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
*
|
|
183
|
+
* @description Estimate gasLimit, storageLimit and fees for an stake pseudo-operation
|
|
184
|
+
*
|
|
185
|
+
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
186
|
+
*
|
|
187
|
+
* @param Stake pseudo-operation parameter
|
|
188
|
+
*/
|
|
189
|
+
stake(_a) {
|
|
190
|
+
var _b;
|
|
191
|
+
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
194
|
+
if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
195
|
+
throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
|
|
196
|
+
}
|
|
197
|
+
if (!rest.to) {
|
|
198
|
+
rest.to = rest.source;
|
|
199
|
+
}
|
|
200
|
+
if (rest.to && rest.to !== rest.source) {
|
|
201
|
+
throw new core_1.InvalidStakingAddressError(rest.to);
|
|
202
|
+
}
|
|
203
|
+
if (rest.amount < 0) {
|
|
204
|
+
throw new core_1.InvalidAmountError(rest.amount.toString());
|
|
205
|
+
}
|
|
206
|
+
const preparedOperation = yield this.prepare.stake(Object.assign({ fee,
|
|
207
|
+
storageLimit,
|
|
208
|
+
gasLimit }, rest));
|
|
209
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
210
|
+
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
211
|
+
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
212
|
+
estimateProperties.shift();
|
|
213
|
+
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
|
|
214
|
+
}
|
|
215
|
+
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
*
|
|
220
|
+
* @description Estimate gasLimit, storageLimit and fees for an Unstake pseudo-operation
|
|
221
|
+
*
|
|
222
|
+
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
223
|
+
*
|
|
224
|
+
* @param Unstake pseudo-operation parameter
|
|
225
|
+
*/
|
|
226
|
+
unstake(_a) {
|
|
227
|
+
var _b;
|
|
228
|
+
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
231
|
+
if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
232
|
+
throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
|
|
233
|
+
}
|
|
234
|
+
if (!rest.to) {
|
|
235
|
+
rest.to = rest.source;
|
|
236
|
+
}
|
|
237
|
+
if (rest.to && rest.to !== rest.source) {
|
|
238
|
+
throw new core_1.InvalidStakingAddressError(rest.to);
|
|
239
|
+
}
|
|
240
|
+
if (rest.amount < 0) {
|
|
241
|
+
throw new core_1.InvalidAmountError(rest.amount.toString());
|
|
242
|
+
}
|
|
243
|
+
const preparedOperation = yield this.prepare.unstake(Object.assign({ fee,
|
|
244
|
+
storageLimit,
|
|
245
|
+
gasLimit }, rest));
|
|
246
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
247
|
+
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
248
|
+
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
249
|
+
estimateProperties.shift();
|
|
250
|
+
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
|
|
251
|
+
}
|
|
252
|
+
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
*
|
|
257
|
+
* @description Estimate gasLimit, storageLimit and fees for an finalize_unstake pseudo-operation
|
|
258
|
+
*
|
|
259
|
+
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
260
|
+
*
|
|
261
|
+
* @param finalize_unstake pseudo-operation parameter
|
|
262
|
+
*/
|
|
263
|
+
finalizeUnstake(_a) {
|
|
264
|
+
var _b;
|
|
265
|
+
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
268
|
+
if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
269
|
+
throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
|
|
270
|
+
}
|
|
271
|
+
if (!rest.to) {
|
|
272
|
+
rest.to = rest.source;
|
|
273
|
+
}
|
|
274
|
+
if (rest.to && rest.to !== rest.source) {
|
|
275
|
+
throw new core_1.InvalidStakingAddressError(rest.to);
|
|
276
|
+
}
|
|
277
|
+
if (!rest.amount) {
|
|
278
|
+
rest.amount = 0;
|
|
279
|
+
}
|
|
280
|
+
if (rest.amount !== undefined && rest.amount !== 0) {
|
|
281
|
+
throw new Error('Amount must be 0 for finalize_unstake operation');
|
|
282
|
+
}
|
|
283
|
+
const preparedOperation = yield this.prepare.finalizeUnstake(Object.assign({ fee,
|
|
284
|
+
storageLimit,
|
|
285
|
+
gasLimit }, rest));
|
|
286
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
287
|
+
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
288
|
+
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
289
|
+
estimateProperties.shift();
|
|
290
|
+
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
|
|
291
|
+
}
|
|
292
|
+
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
181
295
|
/**
|
|
182
296
|
*
|
|
183
297
|
* @description Estimate gasLimit, storageLimit and fees for a transferTicket operation
|
|
@@ -314,6 +314,110 @@ class PrepareProvider extends provider_1.Provider {
|
|
|
314
314
|
};
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
*
|
|
319
|
+
* @description Method to prepare a stake pseudo-operation
|
|
320
|
+
* @param operation RPCOperation object or RPCOperation array
|
|
321
|
+
* @param source string or undefined source pkh
|
|
322
|
+
* @returns a PreparedOperation object
|
|
323
|
+
*/
|
|
324
|
+
stake(_a) {
|
|
325
|
+
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
+
const { pkh } = yield this.getKeys();
|
|
328
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
329
|
+
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
330
|
+
const op = yield (0, contract_1.createTransferOperation)(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
|
|
331
|
+
entrypoint: 'stake',
|
|
332
|
+
value: {
|
|
333
|
+
prim: 'Unit',
|
|
334
|
+
},
|
|
335
|
+
} }));
|
|
336
|
+
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
337
|
+
const ops = this.convertIntoArray(operation);
|
|
338
|
+
const hash = yield this.getBlockHash();
|
|
339
|
+
const protocol = yield this.getProtocolHash();
|
|
340
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
341
|
+
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
342
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
343
|
+
return {
|
|
344
|
+
opOb: {
|
|
345
|
+
branch: hash,
|
|
346
|
+
contents,
|
|
347
|
+
protocol,
|
|
348
|
+
},
|
|
349
|
+
counter: headCounter,
|
|
350
|
+
};
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
*
|
|
355
|
+
* @description Method to prepare a unstake pseudo-operation
|
|
356
|
+
* @param operation RPCOperation object or RPCOperation array
|
|
357
|
+
* @param source string or undefined source pkh
|
|
358
|
+
* @returns a PreparedOperation object
|
|
359
|
+
*/
|
|
360
|
+
unstake(_a) {
|
|
361
|
+
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
362
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
363
|
+
const { pkh } = yield this.getKeys();
|
|
364
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
365
|
+
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
366
|
+
const op = yield (0, contract_1.createTransferOperation)(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
|
|
367
|
+
entrypoint: 'unstake',
|
|
368
|
+
value: { prim: 'Unit' },
|
|
369
|
+
} }));
|
|
370
|
+
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
371
|
+
const ops = this.convertIntoArray(operation);
|
|
372
|
+
const hash = yield this.getBlockHash();
|
|
373
|
+
const protocol = yield this.getProtocolHash();
|
|
374
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
375
|
+
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
376
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
377
|
+
return {
|
|
378
|
+
opOb: {
|
|
379
|
+
branch: hash,
|
|
380
|
+
contents,
|
|
381
|
+
protocol,
|
|
382
|
+
},
|
|
383
|
+
counter: headCounter,
|
|
384
|
+
};
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
*
|
|
389
|
+
* @description Method to prepare a finalize_unstake pseudo-operation
|
|
390
|
+
* @param operation RPCOperation object or RPCOperation array
|
|
391
|
+
* @param source string or undefined source pkh
|
|
392
|
+
* @returns a PreparedOperation object
|
|
393
|
+
*/
|
|
394
|
+
finalizeUnstake(_a) {
|
|
395
|
+
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
396
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
397
|
+
const { pkh } = yield this.getKeys();
|
|
398
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
399
|
+
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
400
|
+
const op = yield (0, contract_1.createTransferOperation)(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh, amount: 0 }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
|
|
401
|
+
entrypoint: 'finalize_unstake',
|
|
402
|
+
value: { prim: 'Unit' },
|
|
403
|
+
} }));
|
|
404
|
+
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
405
|
+
const ops = this.convertIntoArray(operation);
|
|
406
|
+
const hash = yield this.getBlockHash();
|
|
407
|
+
const protocol = yield this.getProtocolHash();
|
|
408
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
409
|
+
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
410
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
411
|
+
return {
|
|
412
|
+
opOb: {
|
|
413
|
+
branch: hash,
|
|
414
|
+
contents,
|
|
415
|
+
protocol,
|
|
416
|
+
},
|
|
417
|
+
counter: headCounter,
|
|
418
|
+
};
|
|
419
|
+
});
|
|
420
|
+
}
|
|
317
421
|
/**
|
|
318
422
|
*
|
|
319
423
|
* @description Method to prepare a delegation operation
|
|
@@ -18,7 +18,7 @@ class RpcReadAdapter {
|
|
|
18
18
|
this.rpc = rpc;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* @description Access the balance of a contract.
|
|
21
|
+
* @description Access the spendable balance of a contract, excluding frozen bonds.
|
|
22
22
|
* @param address address from which we want to retrieve the balance
|
|
23
23
|
* @param block from which we want to retrieve the balance
|
|
24
24
|
* @returns the balance in mutez
|
|
@@ -206,5 +206,12 @@ class RpcReadAdapter {
|
|
|
206
206
|
getLiveBlocks(block) {
|
|
207
207
|
return this.rpc.getLiveBlocks({ block: String(block) });
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* @description Returns the cycle at which the launch of the Adaptive Issuance feature is set to happen. A result of null means that the feature is not yet set to launch.
|
|
211
|
+
* @param block from which we want to retrieve the information
|
|
212
|
+
*/
|
|
213
|
+
getAdaptiveIssuanceLaunchCycle(block) {
|
|
214
|
+
return this.rpc.getAdaptiveIssuanceLaunchCycle({ block: String(block) });
|
|
215
|
+
}
|
|
209
216
|
}
|
|
210
217
|
exports.RpcReadAdapter = RpcReadAdapter;
|
package/dist/lib/version.js
CHANGED
|
@@ -3,6 +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": "
|
|
6
|
+
"commitHash": "0ef631853ccfda5c5faed584f16069f34085817e",
|
|
7
|
+
"version": "20.0.0-beta.0"
|
|
8
8
|
};
|
|
@@ -30,6 +30,21 @@ class LegacyWalletProvider {
|
|
|
30
30
|
return (0, types_1.attachKind)(yield params(), types_1.OpKind.TRANSACTION);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
+
mapStakeParamsToWalletParams(params) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return (0, types_1.attachKind)(yield params(), types_1.OpKind.TRANSACTION);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
mapUnstakeParamsToWalletParams(params) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return (0, types_1.attachKind)(yield params(), types_1.OpKind.TRANSACTION);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
mapFinalizeUnstakeParamsToWalletParams(params) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return (0, types_1.attachKind)(yield params(), types_1.OpKind.TRANSACTION);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
33
48
|
mapOriginateParamsToWalletParams(params) {
|
|
34
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
50
|
return (0, types_1.attachKind)(yield params(), types_1.OpKind.ORIGINATION);
|
|
@@ -294,11 +294,93 @@ class Wallet {
|
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
*
|
|
297
|
-
* @description
|
|
297
|
+
* @description Stake a given amount for the source address
|
|
298
298
|
*
|
|
299
|
-
* @returns
|
|
299
|
+
* @returns An operation handle with the result from the rpc node
|
|
300
|
+
*
|
|
301
|
+
* @param Stake pseudo-operation parameter
|
|
302
|
+
*/
|
|
303
|
+
stake(params) {
|
|
304
|
+
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
const mappedParams = yield this.walletProvider.mapStakeParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () {
|
|
306
|
+
const source = yield this.pkh();
|
|
307
|
+
if (!params.to) {
|
|
308
|
+
params.to = source;
|
|
309
|
+
}
|
|
310
|
+
if (params.to !== source) {
|
|
311
|
+
throw new core_1.InvalidStakingAddressError(params.to);
|
|
312
|
+
}
|
|
313
|
+
params.parameter = { entrypoint: 'stake', value: { prim: 'Unit' } };
|
|
314
|
+
return params;
|
|
315
|
+
}));
|
|
316
|
+
const opHash = yield this.walletProvider.sendOperations([mappedParams]);
|
|
317
|
+
return this.context.operationFactory.createTransactionOperation(opHash);
|
|
318
|
+
}));
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
*
|
|
322
|
+
* @description Unstake the given amount. If "everything" is given as amount, unstakes everything from the staking balance.
|
|
323
|
+
* Unstaked tez remains frozen for a set amount of cycles (the slashing period) after the operation. Once this period is over,
|
|
324
|
+
* the operation "finalize unstake" must be called for the funds to appear in the liquid balance.
|
|
300
325
|
*
|
|
301
|
-
* @
|
|
326
|
+
* @returns An operation handle with the result from the rpc node
|
|
327
|
+
*
|
|
328
|
+
* @param Unstake pseudo-operation parameter
|
|
329
|
+
*/
|
|
330
|
+
unstake(params) {
|
|
331
|
+
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
332
|
+
const mappedParams = yield this.walletProvider.mapUnstakeParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () {
|
|
333
|
+
const source = yield this.pkh();
|
|
334
|
+
if (!params.to) {
|
|
335
|
+
params.to = source;
|
|
336
|
+
}
|
|
337
|
+
if (params.to !== source) {
|
|
338
|
+
throw new core_1.InvalidStakingAddressError(params.to);
|
|
339
|
+
}
|
|
340
|
+
params.parameter = { entrypoint: 'unstake', value: { prim: 'Unit' } };
|
|
341
|
+
return params;
|
|
342
|
+
}));
|
|
343
|
+
const opHash = yield this.walletProvider.sendOperations([mappedParams]);
|
|
344
|
+
return yield this.context.operationFactory.createTransactionOperation(opHash);
|
|
345
|
+
}));
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
*
|
|
349
|
+
* @description Transfer all the finalizable unstaked funds of the source to their liquid balance
|
|
350
|
+
* @returns An operation handle with the result from the rpc node
|
|
351
|
+
*
|
|
352
|
+
* @param Finalize_unstake pseudo-operation parameter
|
|
353
|
+
*/
|
|
354
|
+
finalizeUnstake(params) {
|
|
355
|
+
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
356
|
+
const mappedParams = yield this.walletProvider.mapFinalizeUnstakeParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () {
|
|
357
|
+
const source = yield this.pkh();
|
|
358
|
+
if (!params.to) {
|
|
359
|
+
params.to = source;
|
|
360
|
+
}
|
|
361
|
+
if (params.to !== source) {
|
|
362
|
+
throw new core_1.InvalidStakingAddressError(params.to);
|
|
363
|
+
}
|
|
364
|
+
if (!params.amount) {
|
|
365
|
+
params.amount = 0;
|
|
366
|
+
}
|
|
367
|
+
if (params.amount !== 0) {
|
|
368
|
+
throw new core_1.InvalidFinalizeUnstakeAmountError('Amount must be 0 to finalize unstake.');
|
|
369
|
+
}
|
|
370
|
+
params.parameter = { entrypoint: 'finalize_unstake', value: { prim: 'Unit' } };
|
|
371
|
+
return params;
|
|
372
|
+
}));
|
|
373
|
+
const opHash = yield this.walletProvider.sendOperations([mappedParams]);
|
|
374
|
+
return yield this.context.operationFactory.createTransactionOperation(opHash);
|
|
375
|
+
}));
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
*
|
|
379
|
+
* @description Increase the paid storage of a smart contract.
|
|
380
|
+
*
|
|
381
|
+
* @returns A wallet command from which we can send the operation to the wallet
|
|
382
|
+
*
|
|
383
|
+
* @param params operation parameter
|
|
302
384
|
*/
|
|
303
385
|
increasePaidStorage(params) {
|
|
304
386
|
const destinationValidation = (0, utils_1.validateAddress)(params.destination);
|