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