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