@taquito/taquito 19.2.1 → 20.0.0-RC.1

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.
@@ -227,6 +227,8 @@
227
227
  Protocols["PtMumbai2"] = "PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1";
228
228
  Protocols["PtNairobi"] = "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf";
229
229
  Protocols["ProxfordY"] = "ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH";
230
+ Protocols["PtParisBQ"] = "PtParisBQscdCm6Cfow6ndeU6wKJyA3aV1j4D3gQBQMsTQyJCrz";
231
+ Protocols["PtParisBx"] = "PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ";
230
232
  Protocols["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
231
233
  })(exports.Protocols || (exports.Protocols = {}));
232
234
  const protocols = {
@@ -265,6 +267,7 @@
265
267
  ChainIds["MUMBAINET2"] = "NetXgbcrNtXD2yA";
266
268
  ChainIds["NAIROBINET"] = "NetXyuzvDo2Ugzb";
267
269
  ChainIds["OXFORDNET2"] = "NetXxWsskGahzQB";
270
+ ChainIds["PARISNET"] = "NetXo8SqH1c38SS";
268
271
  })(exports.ChainIds || (exports.ChainIds = {}));
269
272
  // 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)
270
273
  const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
@@ -1158,9 +1161,7 @@
1158
1161
  this.operations = [];
1159
1162
  }
1160
1163
  /**
1161
- *
1162
1164
  * @description Add a transaction operation to the batch
1163
- *
1164
1165
  * @param params Transfer operation parameter
1165
1166
  */
1166
1167
  withTransfer(params) {
@@ -1172,9 +1173,7 @@
1172
1173
  return this;
1173
1174
  }
1174
1175
  /**
1175
- *
1176
1176
  * @description Add a contract call to the batch
1177
- *
1178
1177
  * @param params Call a contract method
1179
1178
  * @param options Generic operation parameters
1180
1179
  */
@@ -1182,9 +1181,7 @@
1182
1181
  return this.withTransfer(params.toTransferParams(options));
1183
1182
  }
1184
1183
  /**
1185
- *
1186
1184
  * @description Add a delegation operation to the batch
1187
- *
1188
1185
  * @param params Delegation operation parameter
1189
1186
  */
1190
1187
  withDelegation(params) {
@@ -1197,9 +1194,7 @@
1197
1194
  return this;
1198
1195
  }
1199
1196
  /**
1200
- *
1201
1197
  * @description Add an origination operation to the batch
1202
- *
1203
1198
  * @param params Origination operation parameter
1204
1199
  */
1205
1200
  withOrigination(params) {
@@ -1207,9 +1202,7 @@
1207
1202
  return this;
1208
1203
  }
1209
1204
  /**
1210
- *
1211
1205
  * @description Add an IncreasePaidStorage operation to the batch
1212
- *
1213
1206
  * @param param IncreasePaidStorage operation parameter
1214
1207
  */
1215
1208
  withIncreasePaidStorage(params) {
@@ -1239,9 +1232,7 @@
1239
1232
  });
1240
1233
  }
1241
1234
  /**
1242
- *
1243
1235
  * @description Add a group operation to the batch. Operation will be applied in the order they are in the params array
1244
- *
1245
1236
  * @param params Operations parameter
1246
1237
  * @throws {@link InvalidOperationKindError}
1247
1238
  */
@@ -1267,9 +1258,7 @@
1267
1258
  return this;
1268
1259
  }
1269
1260
  /**
1270
- *
1271
1261
  * @description Submit batch operation to wallet
1272
- *
1273
1262
  */
1274
1263
  send() {
1275
1264
  return __awaiter(this, void 0, void 0, function* () {
@@ -1296,7 +1285,6 @@
1296
1285
  }
1297
1286
  /**
1298
1287
  * @description Retrieve the PKH of the account that is currently in use by the wallet
1299
- *
1300
1288
  * @param option Option to use while fetching the PKH.
1301
1289
  * If forceRefetch is specified the wallet provider implementation will refetch the PKH from the wallet
1302
1290
  */
@@ -1310,7 +1298,6 @@
1310
1298
  }
1311
1299
  /**
1312
1300
  * @description Retrieve the PK of the account that is currently in use by the wallet
1313
- *
1314
1301
  * @param option Option to use while fetching the PK.
1315
1302
  * If forceRefetch is specified the wallet provider implementation will refetch the PK from the wallet
1316
1303
  */
@@ -1323,11 +1310,8 @@
1323
1310
  });
1324
1311
  }
1325
1312
  /**
1326
- *
1327
1313
  * @description Originate a new contract according to the script in parameters.
1328
- *
1329
- * @returns An operation handle with the result from the rpc node
1330
- *
1314
+ * @returns a OriginationWalletOperation promise object when followed by .send()
1331
1315
  * @param originateParams Originate operation parameter
1332
1316
  */
1333
1317
  originate(params) {
@@ -1338,11 +1322,8 @@
1338
1322
  }));
1339
1323
  }
1340
1324
  /**
1341
- *
1342
1325
  * @description Set the delegate for a contract.
1343
- *
1344
- * @returns An operation handle with the result from the rpc node
1345
- *
1326
+ * @returns a WalletDelegateParams promise object when followed by .send()
1346
1327
  * @param delegateParams operation parameter
1347
1328
  */
1348
1329
  setDelegate(params) {
@@ -1358,11 +1339,8 @@
1358
1339
  }));
1359
1340
  }
1360
1341
  /**
1361
- *
1362
1342
  * @description failing_noop operation that is guaranteed to fail. DISCLAIMER: Not all wallets support signing failing_noop operations.
1363
- *
1364
1343
  * @returns Signature for a failing_noop
1365
- *
1366
1344
  * @param params operation parameter
1367
1345
  */
1368
1346
  signFailingNoop(params) {
@@ -1393,11 +1371,8 @@
1393
1371
  });
1394
1372
  }
1395
1373
  /**
1396
- *
1397
1374
  * @description Register the current address as delegate.
1398
- *
1399
- * @returns An operation handle with the result from the rpc node
1400
- *
1375
+ * @returns a DelegationWalletOperation promise object when followed by .send()
1401
1376
  */
1402
1377
  registerDelegate() {
1403
1378
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
@@ -1410,11 +1385,8 @@
1410
1385
  }));
1411
1386
  }
1412
1387
  /**
1413
- *
1414
1388
  * @description Transfer tezos tokens from current address to a specific address or call a smart contract.
1415
- *
1416
- * @returns A wallet command from which we can send the operation to the wallet
1417
- *
1389
+ * @returns a TransactionWalletOperation promise object when followed by .send()
1418
1390
  * @param params operation parameter
1419
1391
  */
1420
1392
  transfer(params) {
@@ -1429,12 +1401,83 @@
1429
1401
  }));
1430
1402
  }
1431
1403
  /**
1432
- *
1433
- * @description
1434
- *
1435
- * @returns
1436
- *
1437
- * @param params
1404
+ * @description Stake a given amount for the source address
1405
+ * @returns a TransactionWalletOperation promise object when followed by .send()
1406
+ * @param Stake pseudo-operation parameter
1407
+ */
1408
+ stake(params) {
1409
+ return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1410
+ const mappedParams = yield this.walletProvider.mapStakeParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () {
1411
+ const source = yield this.pkh();
1412
+ if (!params.to) {
1413
+ params.to = source;
1414
+ }
1415
+ if (params.to !== source) {
1416
+ throw new core.InvalidStakingAddressError(params.to);
1417
+ }
1418
+ params.parameter = { entrypoint: 'stake', value: { prim: 'Unit' } };
1419
+ return params;
1420
+ }));
1421
+ const opHash = yield this.walletProvider.sendOperations([mappedParams]);
1422
+ return this.context.operationFactory.createTransactionOperation(opHash);
1423
+ }));
1424
+ }
1425
+ /**
1426
+ * @description Unstake the given amount. If "everything" is given as amount, unstakes everything from the staking balance.
1427
+ * Unstaked tez remains frozen for a set amount of cycles (the slashing period) after the operation. Once this period is over,
1428
+ * the operation "finalize unstake" must be called for the funds to appear in the liquid balance.
1429
+ * @returns a TransactionWalletOperation promise object when followed by .send()
1430
+ * @param Unstake pseudo-operation parameter
1431
+ */
1432
+ unstake(params) {
1433
+ return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1434
+ const mappedParams = yield this.walletProvider.mapUnstakeParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () {
1435
+ const source = yield this.pkh();
1436
+ if (!params.to) {
1437
+ params.to = source;
1438
+ }
1439
+ if (params.to !== source) {
1440
+ throw new core.InvalidStakingAddressError(params.to);
1441
+ }
1442
+ params.parameter = { entrypoint: 'unstake', value: { prim: 'Unit' } };
1443
+ return params;
1444
+ }));
1445
+ const opHash = yield this.walletProvider.sendOperations([mappedParams]);
1446
+ return yield this.context.operationFactory.createTransactionOperation(opHash);
1447
+ }));
1448
+ }
1449
+ /**
1450
+ * @description Transfer all the finalizable unstaked funds of the source to their liquid balance
1451
+ * @returns a TransactionWalletOperation promise object when followed by .send()
1452
+ * @param Finalize_unstake pseudo-operation parameter
1453
+ */
1454
+ finalizeUnstake(params) {
1455
+ return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1456
+ const mappedParams = yield this.walletProvider.mapFinalizeUnstakeParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () {
1457
+ const source = yield this.pkh();
1458
+ if (!params.to) {
1459
+ params.to = source;
1460
+ }
1461
+ if (params.to !== source) {
1462
+ throw new core.InvalidStakingAddressError(params.to);
1463
+ }
1464
+ if (!params.amount) {
1465
+ params.amount = 0;
1466
+ }
1467
+ if (params.amount !== 0) {
1468
+ throw new core.InvalidFinalizeUnstakeAmountError('Amount must be 0 to finalize unstake.');
1469
+ }
1470
+ params.parameter = { entrypoint: 'finalize_unstake', value: { prim: 'Unit' } };
1471
+ return params;
1472
+ }));
1473
+ const opHash = yield this.walletProvider.sendOperations([mappedParams]);
1474
+ return yield this.context.operationFactory.createTransactionOperation(opHash);
1475
+ }));
1476
+ }
1477
+ /**
1478
+ * @description Increase the paid storage of a smart contract.
1479
+ * @returns a IncreasePaidStorageWalletOperation promise object when followed by .send()
1480
+ * @param params operation parameter
1438
1481
  */
1439
1482
  increasePaidStorage(params) {
1440
1483
  const destinationValidation = utils.validateAddress(params.destination);
@@ -1448,11 +1491,8 @@
1448
1491
  }));
1449
1492
  }
1450
1493
  /**
1451
- *
1452
1494
  * @description Create a batch of operation
1453
- *
1454
1495
  * @returns A batch object from which we can add more operation or send a command to the wallet to execute the batch
1455
- *
1456
1496
  * @param params List of operation to initialize the batch with
1457
1497
  */
1458
1498
  batch(params) {
@@ -1463,10 +1503,8 @@
1463
1503
  return batch;
1464
1504
  }
1465
1505
  /**
1466
- *
1467
1506
  * @description Create an smart contract abstraction for the address specified. Calling entrypoints with the returned
1468
1507
  * smart contract abstraction will leverage the wallet provider to make smart contract calls
1469
- *
1470
1508
  * @param address Smart contract address
1471
1509
  * @throws {@link InvalidContractAddressError} If the contract address is not valid
1472
1510
  */
@@ -1841,6 +1879,21 @@
1841
1879
  return attachKind(yield params(), rpc.OpKind.TRANSACTION);
1842
1880
  });
1843
1881
  }
1882
+ mapStakeParamsToWalletParams(params) {
1883
+ return __awaiter(this, void 0, void 0, function* () {
1884
+ return attachKind(yield params(), rpc.OpKind.TRANSACTION);
1885
+ });
1886
+ }
1887
+ mapUnstakeParamsToWalletParams(params) {
1888
+ return __awaiter(this, void 0, void 0, function* () {
1889
+ return attachKind(yield params(), rpc.OpKind.TRANSACTION);
1890
+ });
1891
+ }
1892
+ mapFinalizeUnstakeParamsToWalletParams(params) {
1893
+ return __awaiter(this, void 0, void 0, function* () {
1894
+ return attachKind(yield params(), rpc.OpKind.TRANSACTION);
1895
+ });
1896
+ }
1844
1897
  mapOriginateParamsToWalletParams(params) {
1845
1898
  return __awaiter(this, void 0, void 0, function* () {
1846
1899
  return attachKind(yield params(), rpc.OpKind.ORIGINATION);
@@ -2802,6 +2855,110 @@
2802
2855
  };
2803
2856
  });
2804
2857
  }
2858
+ /**
2859
+ *
2860
+ * @description Method to prepare a stake pseudo-operation
2861
+ * @param operation RPCOperation object or RPCOperation array
2862
+ * @param source string or undefined source pkh
2863
+ * @returns a PreparedOperation object
2864
+ */
2865
+ stake(_a) {
2866
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
2867
+ return __awaiter(this, void 0, void 0, function* () {
2868
+ const { pkh } = yield this.getKeys();
2869
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
2870
+ const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
2871
+ const op = yield createTransferOperation(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
2872
+ entrypoint: 'stake',
2873
+ value: {
2874
+ prim: 'Unit',
2875
+ },
2876
+ } }));
2877
+ const operation = yield this.addRevealOperationIfNeeded(op, pkh);
2878
+ const ops = this.convertIntoArray(operation);
2879
+ const hash = yield this.getBlockHash();
2880
+ const protocol = yield this.getProtocolHash();
2881
+ __classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
2882
+ const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
2883
+ const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
2884
+ return {
2885
+ opOb: {
2886
+ branch: hash,
2887
+ contents,
2888
+ protocol,
2889
+ },
2890
+ counter: headCounter,
2891
+ };
2892
+ });
2893
+ }
2894
+ /**
2895
+ *
2896
+ * @description Method to prepare a unstake pseudo-operation
2897
+ * @param operation RPCOperation object or RPCOperation array
2898
+ * @param source string or undefined source pkh
2899
+ * @returns a PreparedOperation object
2900
+ */
2901
+ unstake(_a) {
2902
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
2903
+ return __awaiter(this, void 0, void 0, function* () {
2904
+ const { pkh } = yield this.getKeys();
2905
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
2906
+ const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
2907
+ const op = yield createTransferOperation(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
2908
+ entrypoint: 'unstake',
2909
+ value: { prim: 'Unit' },
2910
+ } }));
2911
+ const operation = yield this.addRevealOperationIfNeeded(op, pkh);
2912
+ const ops = this.convertIntoArray(operation);
2913
+ const hash = yield this.getBlockHash();
2914
+ const protocol = yield this.getProtocolHash();
2915
+ __classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
2916
+ const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
2917
+ const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
2918
+ return {
2919
+ opOb: {
2920
+ branch: hash,
2921
+ contents,
2922
+ protocol,
2923
+ },
2924
+ counter: headCounter,
2925
+ };
2926
+ });
2927
+ }
2928
+ /**
2929
+ *
2930
+ * @description Method to prepare a finalize_unstake pseudo-operation
2931
+ * @param operation RPCOperation object or RPCOperation array
2932
+ * @param source string or undefined source pkh
2933
+ * @returns a PreparedOperation object
2934
+ */
2935
+ finalizeUnstake(_a) {
2936
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
2937
+ return __awaiter(this, void 0, void 0, function* () {
2938
+ const { pkh } = yield this.getKeys();
2939
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
2940
+ const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
2941
+ const op = yield createTransferOperation(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh, amount: 0 }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
2942
+ entrypoint: 'finalize_unstake',
2943
+ value: { prim: 'Unit' },
2944
+ } }));
2945
+ const operation = yield this.addRevealOperationIfNeeded(op, pkh);
2946
+ const ops = this.convertIntoArray(operation);
2947
+ const hash = yield this.getBlockHash();
2948
+ const protocol = yield this.getProtocolHash();
2949
+ __classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
2950
+ const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
2951
+ const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
2952
+ return {
2953
+ opOb: {
2954
+ branch: hash,
2955
+ contents,
2956
+ protocol,
2957
+ },
2958
+ counter: headCounter,
2959
+ };
2960
+ });
2961
+ }
2805
2962
  /**
2806
2963
  *
2807
2964
  * @description Method to prepare a delegation operation
@@ -4083,6 +4240,120 @@
4083
4240
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4084
4241
  });
4085
4242
  }
4243
+ /**
4244
+ *
4245
+ * @description Estimate gasLimit, storageLimit and fees for an stake pseudo-operation
4246
+ *
4247
+ * @returns An estimation of gasLimit, storageLimit and fees for the operation
4248
+ *
4249
+ * @param Stake pseudo-operation parameter
4250
+ */
4251
+ stake(_a) {
4252
+ var _b;
4253
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4254
+ return __awaiter(this, void 0, void 0, function* () {
4255
+ const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4256
+ if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
4257
+ throw new core.InvalidAddressError(rest.source, utils.invalidDetail(sourceValidation));
4258
+ }
4259
+ if (!rest.to) {
4260
+ rest.to = rest.source;
4261
+ }
4262
+ if (rest.to && rest.to !== rest.source) {
4263
+ throw new core.InvalidStakingAddressError(rest.to);
4264
+ }
4265
+ if (rest.amount < 0) {
4266
+ throw new core.InvalidAmountError(rest.amount.toString());
4267
+ }
4268
+ const preparedOperation = yield this.prepare.stake(Object.assign({ fee,
4269
+ storageLimit,
4270
+ gasLimit }, rest));
4271
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4272
+ const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4273
+ if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4274
+ estimateProperties.shift();
4275
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
4276
+ }
4277
+ return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4278
+ });
4279
+ }
4280
+ /**
4281
+ *
4282
+ * @description Estimate gasLimit, storageLimit and fees for an Unstake pseudo-operation
4283
+ *
4284
+ * @returns An estimation of gasLimit, storageLimit and fees for the operation
4285
+ *
4286
+ * @param Unstake pseudo-operation parameter
4287
+ */
4288
+ unstake(_a) {
4289
+ var _b;
4290
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4291
+ return __awaiter(this, void 0, void 0, function* () {
4292
+ const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4293
+ if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
4294
+ throw new core.InvalidAddressError(rest.source, utils.invalidDetail(sourceValidation));
4295
+ }
4296
+ if (!rest.to) {
4297
+ rest.to = rest.source;
4298
+ }
4299
+ if (rest.to && rest.to !== rest.source) {
4300
+ throw new core.InvalidStakingAddressError(rest.to);
4301
+ }
4302
+ if (rest.amount < 0) {
4303
+ throw new core.InvalidAmountError(rest.amount.toString());
4304
+ }
4305
+ const preparedOperation = yield this.prepare.unstake(Object.assign({ fee,
4306
+ storageLimit,
4307
+ gasLimit }, rest));
4308
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4309
+ const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4310
+ if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4311
+ estimateProperties.shift();
4312
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
4313
+ }
4314
+ return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4315
+ });
4316
+ }
4317
+ /**
4318
+ *
4319
+ * @description Estimate gasLimit, storageLimit and fees for an finalize_unstake pseudo-operation
4320
+ *
4321
+ * @returns An estimation of gasLimit, storageLimit and fees for the operation
4322
+ *
4323
+ * @param finalize_unstake pseudo-operation parameter
4324
+ */
4325
+ finalizeUnstake(_a) {
4326
+ var _b;
4327
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4328
+ return __awaiter(this, void 0, void 0, function* () {
4329
+ const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4330
+ if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
4331
+ throw new core.InvalidAddressError(rest.source, utils.invalidDetail(sourceValidation));
4332
+ }
4333
+ if (!rest.to) {
4334
+ rest.to = rest.source;
4335
+ }
4336
+ if (rest.to && rest.to !== rest.source) {
4337
+ throw new core.InvalidStakingAddressError(rest.to);
4338
+ }
4339
+ if (!rest.amount) {
4340
+ rest.amount = 0;
4341
+ }
4342
+ if (rest.amount !== undefined && rest.amount !== 0) {
4343
+ throw new Error('Amount must be 0 for finalize_unstake operation');
4344
+ }
4345
+ const preparedOperation = yield this.prepare.finalizeUnstake(Object.assign({ fee,
4346
+ storageLimit,
4347
+ gasLimit }, rest));
4348
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4349
+ const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4350
+ if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4351
+ estimateProperties.shift();
4352
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
4353
+ }
4354
+ return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4355
+ });
4356
+ }
4086
4357
  /**
4087
4358
  *
4088
4359
  * @description Estimate gasLimit, storageLimit and fees for a transferTicket operation
@@ -5283,6 +5554,112 @@
5283
5554
  return new TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
5284
5555
  });
5285
5556
  }
5557
+ /**
5558
+ *
5559
+ * @description Stake a given amount for the source address
5560
+ *
5561
+ * @returns An operation handle with the result from the rpc node
5562
+ *
5563
+ * @param Stake pseudo-operation parameter
5564
+ */
5565
+ stake(params) {
5566
+ var _a;
5567
+ return __awaiter(this, void 0, void 0, function* () {
5568
+ const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5569
+ if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5570
+ throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
5571
+ }
5572
+ if (!params.to) {
5573
+ params.to = params.source;
5574
+ }
5575
+ if (params.to && params.to !== params.source) {
5576
+ throw new core.InvalidStakingAddressError(params.to);
5577
+ }
5578
+ if (params.amount < 0) {
5579
+ throw new core.InvalidAmountError(params.amount.toString());
5580
+ }
5581
+ const publicKeyHash = yield this.signer.publicKeyHash();
5582
+ const estimate = yield this.estimate(params, this.estimator.stake.bind(this.estimator));
5583
+ const source = params.source || publicKeyHash;
5584
+ const prepared = yield this.prepare.stake(Object.assign(Object.assign({}, params), estimate));
5585
+ const content = prepared.opOb.contents.find((op) => op.kind === rpc.OpKind.TRANSACTION);
5586
+ const opBytes = yield this.forge(prepared);
5587
+ const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
5588
+ return new TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
5589
+ });
5590
+ }
5591
+ /**
5592
+ *
5593
+ * @description Unstake the given amount. If "everything" is given as amount, unstakes everything from the staking balance.
5594
+ * Unstaked tez remains frozen for a set amount of cycles (the slashing period) after the operation. Once this period is over,
5595
+ * the operation "finalize unstake" must be called for the funds to appear in the liquid balance.
5596
+ *
5597
+ * @returns An operation handle with the result from the rpc node
5598
+ *
5599
+ * @param Unstake pseudo-operation parameter
5600
+ */
5601
+ unstake(params) {
5602
+ var _a;
5603
+ return __awaiter(this, void 0, void 0, function* () {
5604
+ const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5605
+ if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5606
+ throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
5607
+ }
5608
+ if (!params.to) {
5609
+ params.to = params.source;
5610
+ }
5611
+ if (params.to && params.to !== params.source) {
5612
+ throw new core.InvalidStakingAddressError(params.to);
5613
+ }
5614
+ if (params.amount < 0) {
5615
+ throw new core.InvalidAmountError(params.amount.toString());
5616
+ }
5617
+ const publicKeyHash = yield this.signer.publicKeyHash();
5618
+ const estimate = yield this.estimate(params, this.estimator.unstake.bind(this.estimator));
5619
+ const source = params.source || publicKeyHash;
5620
+ const prepared = yield this.prepare.unstake(Object.assign(Object.assign({}, params), estimate));
5621
+ const content = prepared.opOb.contents.find((op) => op.kind === rpc.OpKind.TRANSACTION);
5622
+ const opBytes = yield this.forge(prepared);
5623
+ const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
5624
+ return new TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
5625
+ });
5626
+ }
5627
+ /**
5628
+ *
5629
+ * @description Transfer all the finalizable unstaked funds of the source to their liquid balance
5630
+ * @returns An operation handle with the result from the rpc node
5631
+ *
5632
+ * @param Finalize_unstake pseudo-operation parameter
5633
+ */
5634
+ finalizeUnstake(params) {
5635
+ var _a;
5636
+ return __awaiter(this, void 0, void 0, function* () {
5637
+ const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5638
+ if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5639
+ throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
5640
+ }
5641
+ if (!params.to) {
5642
+ params.to = params.source;
5643
+ }
5644
+ if (params.to && params.to !== params.source) {
5645
+ throw new core.InvalidStakingAddressError(params.to);
5646
+ }
5647
+ if (!params.amount) {
5648
+ params.amount = 0;
5649
+ }
5650
+ if (params.amount !== undefined && params.amount > 0) {
5651
+ throw new core.InvalidFinalizeUnstakeAmountError('Amount must be 0 to finalize unstake.');
5652
+ }
5653
+ const publicKeyHash = yield this.signer.publicKeyHash();
5654
+ const estimate = yield this.estimate(params, this.estimator.finalizeUnstake.bind(this.estimator));
5655
+ const source = params.source || publicKeyHash;
5656
+ const prepared = yield this.prepare.finalizeUnstake(Object.assign(Object.assign({}, params), estimate));
5657
+ const content = prepared.opOb.contents.find((op) => op.kind === rpc.OpKind.TRANSACTION);
5658
+ const opBytes = yield this.forge(prepared);
5659
+ const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
5660
+ return new TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
5661
+ });
5662
+ }
5286
5663
  /**
5287
5664
  *
5288
5665
  * @description Transfer Tickets to a smart contract address
@@ -5755,7 +6132,7 @@
5755
6132
  this.rpc = rpc;
5756
6133
  }
5757
6134
  /**
5758
- * @description Access the balance of a contract.
6135
+ * @description Access the spendable balance of a contract, excluding frozen bonds.
5759
6136
  * @param address address from which we want to retrieve the balance
5760
6137
  * @param block from which we want to retrieve the balance
5761
6138
  * @returns the balance in mutez
@@ -5943,6 +6320,13 @@
5943
6320
  getLiveBlocks(block) {
5944
6321
  return this.rpc.getLiveBlocks({ block: String(block) });
5945
6322
  }
6323
+ /**
6324
+ * @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.
6325
+ * @param block from which we want to retrieve the information
6326
+ */
6327
+ getAdaptiveIssuanceLaunchCycle(block) {
6328
+ return this.rpc.getAdaptiveIssuanceLaunchCycle({ block: String(block) });
6329
+ }
5946
6330
  }
5947
6331
 
5948
6332
  /**
@@ -6407,8 +6791,8 @@
6407
6791
 
6408
6792
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
6409
6793
  const VERSION = {
6410
- "commitHash": "2e05f6f865be17a1b367b284542b24ffa9823271",
6411
- "version": "19.2.1"
6794
+ "commitHash": "3374a558006fdf94f6a51f86c64c2bfd970d619d",
6795
+ "version": "20.0.0-RC.1"
6412
6796
  };
6413
6797
 
6414
6798
  /**
@@ -6767,6 +7151,13 @@
6767
7151
  this._options.injectorProvider = injectorProvider;
6768
7152
  }
6769
7153
  }
7154
+ /**
7155
+ * @description Sets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects
7156
+ * @param strategy a value of type FieldNumberingStrategy that controls how field numbers are calculated
7157
+ */
7158
+ setFieldNumberingStrategy(strategy) {
7159
+ michelsonEncoder.Token.fieldNumberingStrategy = strategy;
7160
+ }
6770
7161
  /**
6771
7162
  * @description Provide access to tezos account management
6772
7163
  */
@@ -6857,6 +7248,10 @@
6857
7248
  enumerable: true,
6858
7249
  get: function () { return michelsonEncoder.MichelsonMap; }
6859
7250
  });
7251
+ Object.defineProperty(exports, "Token", {
7252
+ enumerable: true,
7253
+ get: function () { return michelsonEncoder.Token; }
7254
+ });
6860
7255
  Object.defineProperty(exports, "UnitValue", {
6861
7256
  enumerable: true,
6862
7257
  get: function () { return michelsonEncoder.UnitValue; }