@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.
@@ -1,11 +1,11 @@
1
1
  import { OpKind, RpcClient } from '@taquito/rpc';
2
2
  export { OpKind } from '@taquito/rpc';
3
3
  import { HttpResponseError, STATUS_CODE } from '@taquito/http-utils';
4
- import { TezosToolkitConfigError, ParameterValidationError, RpcError, TaquitoError, NetworkError, InvalidOperationHashError, InvalidAddressError, InvalidOperationKindError as InvalidOperationKindError$1, InvalidContractAddressError, InvalidViewParameterError, DeprecationError, InvalidChainIdError, PublicKeyNotFoundError, InvalidAmountError, InvalidKeyHashError } from '@taquito/core';
4
+ import { TezosToolkitConfigError, ParameterValidationError, RpcError, TaquitoError, NetworkError, InvalidOperationHashError, InvalidAddressError, InvalidOperationKindError as InvalidOperationKindError$1, InvalidStakingAddressError, InvalidFinalizeUnstakeAmountError, InvalidContractAddressError, InvalidViewParameterError, DeprecationError, InvalidChainIdError, PublicKeyNotFoundError, InvalidAmountError, InvalidKeyHashError } from '@taquito/core';
5
5
  import { Observable, ReplaySubject, BehaviorSubject, throwError, defer, range, of, EMPTY, combineLatest, from, concat, Subject, NEVER, timer } from 'rxjs';
6
6
  import { switchMap, timeout, concatMap, endWith, tap, shareReplay, map, filter, first, catchError, share, distinctUntilChanged, takeWhile, startWith, mergeMap, takeUntil, retry, pluck, distinctUntilKeyChanged, publish, refCount } from 'rxjs/operators';
7
- import { Schema, ParameterSchema, ViewSchema, EventSchema, MichelsonMap } from '@taquito/michelson-encoder';
8
- export { MichelsonMap, UnitValue } from '@taquito/michelson-encoder';
7
+ import { Schema, ParameterSchema, ViewSchema, EventSchema, MichelsonMap, Token } from '@taquito/michelson-encoder';
8
+ export { MichelsonMap, Token, UnitValue } from '@taquito/michelson-encoder';
9
9
  import { format, validateOperation, ValidationResult, InvalidOperationKindError, validateAddress, invalidDetail, validateContractAddress, validateChain, validateKeyHash, InvalidKeyHashError as InvalidKeyHashError$1, encodeExpr } from '@taquito/utils';
10
10
  import BigNumber, { BigNumber as BigNumber$1 } from 'bignumber.js';
11
11
  import { Parser, packDataBytes } from '@taquito/michel-codec';
@@ -234,6 +234,8 @@ var Protocols;
234
234
  Protocols["PtMumbai2"] = "PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1";
235
235
  Protocols["PtNairobi"] = "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf";
236
236
  Protocols["ProxfordY"] = "ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH";
237
+ Protocols["PtParisBQ"] = "PtParisBQscdCm6Cfow6ndeU6wKJyA3aV1j4D3gQBQMsTQyJCrz";
238
+ Protocols["PtParisBx"] = "PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ";
237
239
  Protocols["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
238
240
  })(Protocols || (Protocols = {}));
239
241
  const protocols = {
@@ -272,6 +274,7 @@ var ChainIds;
272
274
  ChainIds["MUMBAINET2"] = "NetXgbcrNtXD2yA";
273
275
  ChainIds["NAIROBINET"] = "NetXyuzvDo2Ugzb";
274
276
  ChainIds["OXFORDNET2"] = "NetXxWsskGahzQB";
277
+ ChainIds["PARISNET"] = "NetXo8SqH1c38SS";
275
278
  })(ChainIds || (ChainIds = {}));
276
279
  // 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)
277
280
  const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
@@ -1165,9 +1168,7 @@ class WalletOperationBatch {
1165
1168
  this.operations = [];
1166
1169
  }
1167
1170
  /**
1168
- *
1169
1171
  * @description Add a transaction operation to the batch
1170
- *
1171
1172
  * @param params Transfer operation parameter
1172
1173
  */
1173
1174
  withTransfer(params) {
@@ -1179,9 +1180,7 @@ class WalletOperationBatch {
1179
1180
  return this;
1180
1181
  }
1181
1182
  /**
1182
- *
1183
1183
  * @description Add a contract call to the batch
1184
- *
1185
1184
  * @param params Call a contract method
1186
1185
  * @param options Generic operation parameters
1187
1186
  */
@@ -1189,9 +1188,7 @@ class WalletOperationBatch {
1189
1188
  return this.withTransfer(params.toTransferParams(options));
1190
1189
  }
1191
1190
  /**
1192
- *
1193
1191
  * @description Add a delegation operation to the batch
1194
- *
1195
1192
  * @param params Delegation operation parameter
1196
1193
  */
1197
1194
  withDelegation(params) {
@@ -1204,9 +1201,7 @@ class WalletOperationBatch {
1204
1201
  return this;
1205
1202
  }
1206
1203
  /**
1207
- *
1208
1204
  * @description Add an origination operation to the batch
1209
- *
1210
1205
  * @param params Origination operation parameter
1211
1206
  */
1212
1207
  withOrigination(params) {
@@ -1214,9 +1209,7 @@ class WalletOperationBatch {
1214
1209
  return this;
1215
1210
  }
1216
1211
  /**
1217
- *
1218
1212
  * @description Add an IncreasePaidStorage operation to the batch
1219
- *
1220
1213
  * @param param IncreasePaidStorage operation parameter
1221
1214
  */
1222
1215
  withIncreasePaidStorage(params) {
@@ -1246,9 +1239,7 @@ class WalletOperationBatch {
1246
1239
  });
1247
1240
  }
1248
1241
  /**
1249
- *
1250
1242
  * @description Add a group operation to the batch. Operation will be applied in the order they are in the params array
1251
- *
1252
1243
  * @param params Operations parameter
1253
1244
  * @throws {@link InvalidOperationKindError}
1254
1245
  */
@@ -1274,9 +1265,7 @@ class WalletOperationBatch {
1274
1265
  return this;
1275
1266
  }
1276
1267
  /**
1277
- *
1278
1268
  * @description Submit batch operation to wallet
1279
- *
1280
1269
  */
1281
1270
  send() {
1282
1271
  return __awaiter(this, void 0, void 0, function* () {
@@ -1303,7 +1292,6 @@ class Wallet {
1303
1292
  }
1304
1293
  /**
1305
1294
  * @description Retrieve the PKH of the account that is currently in use by the wallet
1306
- *
1307
1295
  * @param option Option to use while fetching the PKH.
1308
1296
  * If forceRefetch is specified the wallet provider implementation will refetch the PKH from the wallet
1309
1297
  */
@@ -1317,7 +1305,6 @@ class Wallet {
1317
1305
  }
1318
1306
  /**
1319
1307
  * @description Retrieve the PK of the account that is currently in use by the wallet
1320
- *
1321
1308
  * @param option Option to use while fetching the PK.
1322
1309
  * If forceRefetch is specified the wallet provider implementation will refetch the PK from the wallet
1323
1310
  */
@@ -1330,11 +1317,8 @@ class Wallet {
1330
1317
  });
1331
1318
  }
1332
1319
  /**
1333
- *
1334
1320
  * @description Originate a new contract according to the script in parameters.
1335
- *
1336
- * @returns An operation handle with the result from the rpc node
1337
- *
1321
+ * @returns a OriginationWalletOperation promise object when followed by .send()
1338
1322
  * @param originateParams Originate operation parameter
1339
1323
  */
1340
1324
  originate(params) {
@@ -1345,11 +1329,8 @@ class Wallet {
1345
1329
  }));
1346
1330
  }
1347
1331
  /**
1348
- *
1349
1332
  * @description Set the delegate for a contract.
1350
- *
1351
- * @returns An operation handle with the result from the rpc node
1352
- *
1333
+ * @returns a WalletDelegateParams promise object when followed by .send()
1353
1334
  * @param delegateParams operation parameter
1354
1335
  */
1355
1336
  setDelegate(params) {
@@ -1365,11 +1346,8 @@ class Wallet {
1365
1346
  }));
1366
1347
  }
1367
1348
  /**
1368
- *
1369
1349
  * @description failing_noop operation that is guaranteed to fail. DISCLAIMER: Not all wallets support signing failing_noop operations.
1370
- *
1371
1350
  * @returns Signature for a failing_noop
1372
- *
1373
1351
  * @param params operation parameter
1374
1352
  */
1375
1353
  signFailingNoop(params) {
@@ -1400,11 +1378,8 @@ class Wallet {
1400
1378
  });
1401
1379
  }
1402
1380
  /**
1403
- *
1404
1381
  * @description Register the current address as delegate.
1405
- *
1406
- * @returns An operation handle with the result from the rpc node
1407
- *
1382
+ * @returns a DelegationWalletOperation promise object when followed by .send()
1408
1383
  */
1409
1384
  registerDelegate() {
1410
1385
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
@@ -1417,11 +1392,8 @@ class Wallet {
1417
1392
  }));
1418
1393
  }
1419
1394
  /**
1420
- *
1421
1395
  * @description Transfer tezos tokens from current address to a specific address or call a smart contract.
1422
- *
1423
- * @returns A wallet command from which we can send the operation to the wallet
1424
- *
1396
+ * @returns a TransactionWalletOperation promise object when followed by .send()
1425
1397
  * @param params operation parameter
1426
1398
  */
1427
1399
  transfer(params) {
@@ -1436,12 +1408,83 @@ class Wallet {
1436
1408
  }));
1437
1409
  }
1438
1410
  /**
1439
- *
1440
- * @description
1441
- *
1442
- * @returns
1443
- *
1444
- * @param params
1411
+ * @description Stake a given amount for the source address
1412
+ * @returns a TransactionWalletOperation promise object when followed by .send()
1413
+ * @param Stake pseudo-operation parameter
1414
+ */
1415
+ stake(params) {
1416
+ return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1417
+ const mappedParams = yield this.walletProvider.mapStakeParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () {
1418
+ const source = yield this.pkh();
1419
+ if (!params.to) {
1420
+ params.to = source;
1421
+ }
1422
+ if (params.to !== source) {
1423
+ throw new InvalidStakingAddressError(params.to);
1424
+ }
1425
+ params.parameter = { entrypoint: 'stake', value: { prim: 'Unit' } };
1426
+ return params;
1427
+ }));
1428
+ const opHash = yield this.walletProvider.sendOperations([mappedParams]);
1429
+ return this.context.operationFactory.createTransactionOperation(opHash);
1430
+ }));
1431
+ }
1432
+ /**
1433
+ * @description Unstake the given amount. If "everything" is given as amount, unstakes everything from the staking balance.
1434
+ * Unstaked tez remains frozen for a set amount of cycles (the slashing period) after the operation. Once this period is over,
1435
+ * the operation "finalize unstake" must be called for the funds to appear in the liquid balance.
1436
+ * @returns a TransactionWalletOperation promise object when followed by .send()
1437
+ * @param Unstake pseudo-operation parameter
1438
+ */
1439
+ unstake(params) {
1440
+ return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1441
+ const mappedParams = yield this.walletProvider.mapUnstakeParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () {
1442
+ const source = yield this.pkh();
1443
+ if (!params.to) {
1444
+ params.to = source;
1445
+ }
1446
+ if (params.to !== source) {
1447
+ throw new InvalidStakingAddressError(params.to);
1448
+ }
1449
+ params.parameter = { entrypoint: 'unstake', value: { prim: 'Unit' } };
1450
+ return params;
1451
+ }));
1452
+ const opHash = yield this.walletProvider.sendOperations([mappedParams]);
1453
+ return yield this.context.operationFactory.createTransactionOperation(opHash);
1454
+ }));
1455
+ }
1456
+ /**
1457
+ * @description Transfer all the finalizable unstaked funds of the source to their liquid balance
1458
+ * @returns a TransactionWalletOperation promise object when followed by .send()
1459
+ * @param Finalize_unstake pseudo-operation parameter
1460
+ */
1461
+ finalizeUnstake(params) {
1462
+ return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1463
+ const mappedParams = yield this.walletProvider.mapFinalizeUnstakeParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () {
1464
+ const source = yield this.pkh();
1465
+ if (!params.to) {
1466
+ params.to = source;
1467
+ }
1468
+ if (params.to !== source) {
1469
+ throw new InvalidStakingAddressError(params.to);
1470
+ }
1471
+ if (!params.amount) {
1472
+ params.amount = 0;
1473
+ }
1474
+ if (params.amount !== 0) {
1475
+ throw new InvalidFinalizeUnstakeAmountError('Amount must be 0 to finalize unstake.');
1476
+ }
1477
+ params.parameter = { entrypoint: 'finalize_unstake', value: { prim: 'Unit' } };
1478
+ return params;
1479
+ }));
1480
+ const opHash = yield this.walletProvider.sendOperations([mappedParams]);
1481
+ return yield this.context.operationFactory.createTransactionOperation(opHash);
1482
+ }));
1483
+ }
1484
+ /**
1485
+ * @description Increase the paid storage of a smart contract.
1486
+ * @returns a IncreasePaidStorageWalletOperation promise object when followed by .send()
1487
+ * @param params operation parameter
1445
1488
  */
1446
1489
  increasePaidStorage(params) {
1447
1490
  const destinationValidation = validateAddress(params.destination);
@@ -1455,11 +1498,8 @@ class Wallet {
1455
1498
  }));
1456
1499
  }
1457
1500
  /**
1458
- *
1459
1501
  * @description Create a batch of operation
1460
- *
1461
1502
  * @returns A batch object from which we can add more operation or send a command to the wallet to execute the batch
1462
- *
1463
1503
  * @param params List of operation to initialize the batch with
1464
1504
  */
1465
1505
  batch(params) {
@@ -1470,10 +1510,8 @@ class Wallet {
1470
1510
  return batch;
1471
1511
  }
1472
1512
  /**
1473
- *
1474
1513
  * @description Create an smart contract abstraction for the address specified. Calling entrypoints with the returned
1475
1514
  * smart contract abstraction will leverage the wallet provider to make smart contract calls
1476
- *
1477
1515
  * @param address Smart contract address
1478
1516
  * @throws {@link InvalidContractAddressError} If the contract address is not valid
1479
1517
  */
@@ -1848,6 +1886,21 @@ class LegacyWalletProvider {
1848
1886
  return attachKind(yield params(), OpKind.TRANSACTION);
1849
1887
  });
1850
1888
  }
1889
+ mapStakeParamsToWalletParams(params) {
1890
+ return __awaiter(this, void 0, void 0, function* () {
1891
+ return attachKind(yield params(), OpKind.TRANSACTION);
1892
+ });
1893
+ }
1894
+ mapUnstakeParamsToWalletParams(params) {
1895
+ return __awaiter(this, void 0, void 0, function* () {
1896
+ return attachKind(yield params(), OpKind.TRANSACTION);
1897
+ });
1898
+ }
1899
+ mapFinalizeUnstakeParamsToWalletParams(params) {
1900
+ return __awaiter(this, void 0, void 0, function* () {
1901
+ return attachKind(yield params(), OpKind.TRANSACTION);
1902
+ });
1903
+ }
1851
1904
  mapOriginateParamsToWalletParams(params) {
1852
1905
  return __awaiter(this, void 0, void 0, function* () {
1853
1906
  return attachKind(yield params(), OpKind.ORIGINATION);
@@ -2809,6 +2862,110 @@ class PrepareProvider extends Provider {
2809
2862
  };
2810
2863
  });
2811
2864
  }
2865
+ /**
2866
+ *
2867
+ * @description Method to prepare a stake pseudo-operation
2868
+ * @param operation RPCOperation object or RPCOperation array
2869
+ * @param source string or undefined source pkh
2870
+ * @returns a PreparedOperation object
2871
+ */
2872
+ stake(_a) {
2873
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
2874
+ return __awaiter(this, void 0, void 0, function* () {
2875
+ const { pkh } = yield this.getKeys();
2876
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
2877
+ const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
2878
+ const op = yield createTransferOperation(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
2879
+ entrypoint: 'stake',
2880
+ value: {
2881
+ prim: 'Unit',
2882
+ },
2883
+ } }));
2884
+ const operation = yield this.addRevealOperationIfNeeded(op, pkh);
2885
+ const ops = this.convertIntoArray(operation);
2886
+ const hash = yield this.getBlockHash();
2887
+ const protocol = yield this.getProtocolHash();
2888
+ __classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
2889
+ const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
2890
+ const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
2891
+ return {
2892
+ opOb: {
2893
+ branch: hash,
2894
+ contents,
2895
+ protocol,
2896
+ },
2897
+ counter: headCounter,
2898
+ };
2899
+ });
2900
+ }
2901
+ /**
2902
+ *
2903
+ * @description Method to prepare a unstake pseudo-operation
2904
+ * @param operation RPCOperation object or RPCOperation array
2905
+ * @param source string or undefined source pkh
2906
+ * @returns a PreparedOperation object
2907
+ */
2908
+ unstake(_a) {
2909
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
2910
+ return __awaiter(this, void 0, void 0, function* () {
2911
+ const { pkh } = yield this.getKeys();
2912
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
2913
+ const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
2914
+ const op = yield createTransferOperation(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
2915
+ entrypoint: 'unstake',
2916
+ value: { prim: 'Unit' },
2917
+ } }));
2918
+ const operation = yield this.addRevealOperationIfNeeded(op, pkh);
2919
+ const ops = this.convertIntoArray(operation);
2920
+ const hash = yield this.getBlockHash();
2921
+ const protocol = yield this.getProtocolHash();
2922
+ __classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
2923
+ const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
2924
+ const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
2925
+ return {
2926
+ opOb: {
2927
+ branch: hash,
2928
+ contents,
2929
+ protocol,
2930
+ },
2931
+ counter: headCounter,
2932
+ };
2933
+ });
2934
+ }
2935
+ /**
2936
+ *
2937
+ * @description Method to prepare a finalize_unstake pseudo-operation
2938
+ * @param operation RPCOperation object or RPCOperation array
2939
+ * @param source string or undefined source pkh
2940
+ * @returns a PreparedOperation object
2941
+ */
2942
+ finalizeUnstake(_a) {
2943
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
2944
+ return __awaiter(this, void 0, void 0, function* () {
2945
+ const { pkh } = yield this.getKeys();
2946
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
2947
+ const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
2948
+ const op = yield createTransferOperation(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh, amount: 0 }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
2949
+ entrypoint: 'finalize_unstake',
2950
+ value: { prim: 'Unit' },
2951
+ } }));
2952
+ const operation = yield this.addRevealOperationIfNeeded(op, pkh);
2953
+ const ops = this.convertIntoArray(operation);
2954
+ const hash = yield this.getBlockHash();
2955
+ const protocol = yield this.getProtocolHash();
2956
+ __classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
2957
+ const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
2958
+ const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
2959
+ return {
2960
+ opOb: {
2961
+ branch: hash,
2962
+ contents,
2963
+ protocol,
2964
+ },
2965
+ counter: headCounter,
2966
+ };
2967
+ });
2968
+ }
2812
2969
  /**
2813
2970
  *
2814
2971
  * @description Method to prepare a delegation operation
@@ -4090,6 +4247,120 @@ class RPCEstimateProvider extends Provider {
4090
4247
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4091
4248
  });
4092
4249
  }
4250
+ /**
4251
+ *
4252
+ * @description Estimate gasLimit, storageLimit and fees for an stake pseudo-operation
4253
+ *
4254
+ * @returns An estimation of gasLimit, storageLimit and fees for the operation
4255
+ *
4256
+ * @param Stake pseudo-operation parameter
4257
+ */
4258
+ stake(_a) {
4259
+ var _b;
4260
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4261
+ return __awaiter(this, void 0, void 0, function* () {
4262
+ const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4263
+ if (rest.source && sourceValidation !== ValidationResult.VALID) {
4264
+ throw new InvalidAddressError(rest.source, invalidDetail(sourceValidation));
4265
+ }
4266
+ if (!rest.to) {
4267
+ rest.to = rest.source;
4268
+ }
4269
+ if (rest.to && rest.to !== rest.source) {
4270
+ throw new InvalidStakingAddressError(rest.to);
4271
+ }
4272
+ if (rest.amount < 0) {
4273
+ throw new InvalidAmountError(rest.amount.toString());
4274
+ }
4275
+ const preparedOperation = yield this.prepare.stake(Object.assign({ fee,
4276
+ storageLimit,
4277
+ gasLimit }, rest));
4278
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4279
+ const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4280
+ if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4281
+ estimateProperties.shift();
4282
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
4283
+ }
4284
+ return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4285
+ });
4286
+ }
4287
+ /**
4288
+ *
4289
+ * @description Estimate gasLimit, storageLimit and fees for an Unstake pseudo-operation
4290
+ *
4291
+ * @returns An estimation of gasLimit, storageLimit and fees for the operation
4292
+ *
4293
+ * @param Unstake pseudo-operation parameter
4294
+ */
4295
+ unstake(_a) {
4296
+ var _b;
4297
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4298
+ return __awaiter(this, void 0, void 0, function* () {
4299
+ const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4300
+ if (rest.source && sourceValidation !== ValidationResult.VALID) {
4301
+ throw new InvalidAddressError(rest.source, invalidDetail(sourceValidation));
4302
+ }
4303
+ if (!rest.to) {
4304
+ rest.to = rest.source;
4305
+ }
4306
+ if (rest.to && rest.to !== rest.source) {
4307
+ throw new InvalidStakingAddressError(rest.to);
4308
+ }
4309
+ if (rest.amount < 0) {
4310
+ throw new InvalidAmountError(rest.amount.toString());
4311
+ }
4312
+ const preparedOperation = yield this.prepare.unstake(Object.assign({ fee,
4313
+ storageLimit,
4314
+ gasLimit }, rest));
4315
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4316
+ const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4317
+ if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4318
+ estimateProperties.shift();
4319
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
4320
+ }
4321
+ return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4322
+ });
4323
+ }
4324
+ /**
4325
+ *
4326
+ * @description Estimate gasLimit, storageLimit and fees for an finalize_unstake pseudo-operation
4327
+ *
4328
+ * @returns An estimation of gasLimit, storageLimit and fees for the operation
4329
+ *
4330
+ * @param finalize_unstake pseudo-operation parameter
4331
+ */
4332
+ finalizeUnstake(_a) {
4333
+ var _b;
4334
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4335
+ return __awaiter(this, void 0, void 0, function* () {
4336
+ const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4337
+ if (rest.source && sourceValidation !== ValidationResult.VALID) {
4338
+ throw new InvalidAddressError(rest.source, invalidDetail(sourceValidation));
4339
+ }
4340
+ if (!rest.to) {
4341
+ rest.to = rest.source;
4342
+ }
4343
+ if (rest.to && rest.to !== rest.source) {
4344
+ throw new InvalidStakingAddressError(rest.to);
4345
+ }
4346
+ if (!rest.amount) {
4347
+ rest.amount = 0;
4348
+ }
4349
+ if (rest.amount !== undefined && rest.amount !== 0) {
4350
+ throw new Error('Amount must be 0 for finalize_unstake operation');
4351
+ }
4352
+ const preparedOperation = yield this.prepare.finalizeUnstake(Object.assign({ fee,
4353
+ storageLimit,
4354
+ gasLimit }, rest));
4355
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4356
+ const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4357
+ if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4358
+ estimateProperties.shift();
4359
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
4360
+ }
4361
+ return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4362
+ });
4363
+ }
4093
4364
  /**
4094
4365
  *
4095
4366
  * @description Estimate gasLimit, storageLimit and fees for a transferTicket operation
@@ -5290,6 +5561,112 @@ class RpcContractProvider extends Provider {
5290
5561
  return new TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
5291
5562
  });
5292
5563
  }
5564
+ /**
5565
+ *
5566
+ * @description Stake a given amount for the source address
5567
+ *
5568
+ * @returns An operation handle with the result from the rpc node
5569
+ *
5570
+ * @param Stake pseudo-operation parameter
5571
+ */
5572
+ stake(params) {
5573
+ var _a;
5574
+ return __awaiter(this, void 0, void 0, function* () {
5575
+ const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5576
+ if (params.source && sourceValidation !== ValidationResult.VALID) {
5577
+ throw new InvalidAddressError(params.source, invalidDetail(sourceValidation));
5578
+ }
5579
+ if (!params.to) {
5580
+ params.to = params.source;
5581
+ }
5582
+ if (params.to && params.to !== params.source) {
5583
+ throw new InvalidStakingAddressError(params.to);
5584
+ }
5585
+ if (params.amount < 0) {
5586
+ throw new InvalidAmountError(params.amount.toString());
5587
+ }
5588
+ const publicKeyHash = yield this.signer.publicKeyHash();
5589
+ const estimate = yield this.estimate(params, this.estimator.stake.bind(this.estimator));
5590
+ const source = params.source || publicKeyHash;
5591
+ const prepared = yield this.prepare.stake(Object.assign(Object.assign({}, params), estimate));
5592
+ const content = prepared.opOb.contents.find((op) => op.kind === OpKind.TRANSACTION);
5593
+ const opBytes = yield this.forge(prepared);
5594
+ const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
5595
+ return new TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
5596
+ });
5597
+ }
5598
+ /**
5599
+ *
5600
+ * @description Unstake the given amount. If "everything" is given as amount, unstakes everything from the staking balance.
5601
+ * Unstaked tez remains frozen for a set amount of cycles (the slashing period) after the operation. Once this period is over,
5602
+ * the operation "finalize unstake" must be called for the funds to appear in the liquid balance.
5603
+ *
5604
+ * @returns An operation handle with the result from the rpc node
5605
+ *
5606
+ * @param Unstake pseudo-operation parameter
5607
+ */
5608
+ unstake(params) {
5609
+ var _a;
5610
+ return __awaiter(this, void 0, void 0, function* () {
5611
+ const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5612
+ if (params.source && sourceValidation !== ValidationResult.VALID) {
5613
+ throw new InvalidAddressError(params.source, invalidDetail(sourceValidation));
5614
+ }
5615
+ if (!params.to) {
5616
+ params.to = params.source;
5617
+ }
5618
+ if (params.to && params.to !== params.source) {
5619
+ throw new InvalidStakingAddressError(params.to);
5620
+ }
5621
+ if (params.amount < 0) {
5622
+ throw new InvalidAmountError(params.amount.toString());
5623
+ }
5624
+ const publicKeyHash = yield this.signer.publicKeyHash();
5625
+ const estimate = yield this.estimate(params, this.estimator.unstake.bind(this.estimator));
5626
+ const source = params.source || publicKeyHash;
5627
+ const prepared = yield this.prepare.unstake(Object.assign(Object.assign({}, params), estimate));
5628
+ const content = prepared.opOb.contents.find((op) => op.kind === OpKind.TRANSACTION);
5629
+ const opBytes = yield this.forge(prepared);
5630
+ const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
5631
+ return new TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
5632
+ });
5633
+ }
5634
+ /**
5635
+ *
5636
+ * @description Transfer all the finalizable unstaked funds of the source to their liquid balance
5637
+ * @returns An operation handle with the result from the rpc node
5638
+ *
5639
+ * @param Finalize_unstake pseudo-operation parameter
5640
+ */
5641
+ finalizeUnstake(params) {
5642
+ var _a;
5643
+ return __awaiter(this, void 0, void 0, function* () {
5644
+ const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5645
+ if (params.source && sourceValidation !== ValidationResult.VALID) {
5646
+ throw new InvalidAddressError(params.source, invalidDetail(sourceValidation));
5647
+ }
5648
+ if (!params.to) {
5649
+ params.to = params.source;
5650
+ }
5651
+ if (params.to && params.to !== params.source) {
5652
+ throw new InvalidStakingAddressError(params.to);
5653
+ }
5654
+ if (!params.amount) {
5655
+ params.amount = 0;
5656
+ }
5657
+ if (params.amount !== undefined && params.amount > 0) {
5658
+ throw new InvalidFinalizeUnstakeAmountError('Amount must be 0 to finalize unstake.');
5659
+ }
5660
+ const publicKeyHash = yield this.signer.publicKeyHash();
5661
+ const estimate = yield this.estimate(params, this.estimator.finalizeUnstake.bind(this.estimator));
5662
+ const source = params.source || publicKeyHash;
5663
+ const prepared = yield this.prepare.finalizeUnstake(Object.assign(Object.assign({}, params), estimate));
5664
+ const content = prepared.opOb.contents.find((op) => op.kind === OpKind.TRANSACTION);
5665
+ const opBytes = yield this.forge(prepared);
5666
+ const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
5667
+ return new TransactionOperation(hash, content, source, forgedBytes, opResponse, context);
5668
+ });
5669
+ }
5293
5670
  /**
5294
5671
  *
5295
5672
  * @description Transfer Tickets to a smart contract address
@@ -5762,7 +6139,7 @@ class RpcReadAdapter {
5762
6139
  this.rpc = rpc;
5763
6140
  }
5764
6141
  /**
5765
- * @description Access the balance of a contract.
6142
+ * @description Access the spendable balance of a contract, excluding frozen bonds.
5766
6143
  * @param address address from which we want to retrieve the balance
5767
6144
  * @param block from which we want to retrieve the balance
5768
6145
  * @returns the balance in mutez
@@ -5950,6 +6327,13 @@ class RpcReadAdapter {
5950
6327
  getLiveBlocks(block) {
5951
6328
  return this.rpc.getLiveBlocks({ block: String(block) });
5952
6329
  }
6330
+ /**
6331
+ * @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.
6332
+ * @param block from which we want to retrieve the information
6333
+ */
6334
+ getAdaptiveIssuanceLaunchCycle(block) {
6335
+ return this.rpc.getAdaptiveIssuanceLaunchCycle({ block: String(block) });
6336
+ }
5953
6337
  }
5954
6338
 
5955
6339
  /**
@@ -6414,8 +6798,8 @@ class Context {
6414
6798
 
6415
6799
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
6416
6800
  const VERSION = {
6417
- "commitHash": "2e05f6f865be17a1b367b284542b24ffa9823271",
6418
- "version": "19.2.1"
6801
+ "commitHash": "3374a558006fdf94f6a51f86c64c2bfd970d619d",
6802
+ "version": "20.0.0-RC.1"
6419
6803
  };
6420
6804
 
6421
6805
  /**
@@ -6774,6 +7158,13 @@ class TezosToolkit {
6774
7158
  this._options.injectorProvider = injectorProvider;
6775
7159
  }
6776
7160
  }
7161
+ /**
7162
+ * @description Sets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects
7163
+ * @param strategy a value of type FieldNumberingStrategy that controls how field numbers are calculated
7164
+ */
7165
+ setFieldNumberingStrategy(strategy) {
7166
+ Token.fieldNumberingStrategy = strategy;
7167
+ }
6777
7168
  /**
6778
7169
  * @description Provide access to tezos account management
6779
7170
  */