@mavrykdynamics/taquito
Version:
High level functionality that builds upon the other packages in the Mavryk Typescript Library Suite.
570 lines (569 loc) • 29.3 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RPCEstimateProvider = void 0;
const errors_1 = require("../operations/errors");
const types_1 = require("../operations/types");
const estimate_1 = require("./estimate");
const taquito_utils_1 = require("@mavrykdynamics/taquito-utils");
const errors_2 = require("./errors");
const provider_1 = require("../provider");
const prepare_provider_1 = require("../prepare/prepare-provider");
const taquito_core_1 = require("@mavrykdynamics/taquito-core");
// stub signature that won't be verified by mavryk rpc simulate_operation
const STUB_SIGNATURE = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg';
class RPCEstimateProvider extends provider_1.Provider {
constructor() {
super(...arguments);
this.OP_SIZE_REVEAL = 324; // injecting size mv1=320, mv2=322, mv3=322, mv4=420(not supported)
this.MILLIGAS_BUFFER = 100 * 1000; // 100 buffer depends on operation kind
this.STORAGE_BUFFER = 20; // according to mavkit-client
this.prepare = new prepare_provider_1.PrepareProvider(this.context);
}
getKeys() {
return __awaiter(this, void 0, void 0, function* () {
const isSignerConfigured = this.context.isAnySignerConfigured();
return {
publicKeyHash: isSignerConfigured
? yield this.signer.publicKeyHash()
: yield this.context.walletProvider.getPKH(),
publicKey: isSignerConfigured ? yield this.signer.publicKey() : undefined,
};
});
}
getEstimationPropertiesFromOperationContent(content, size, costPerByte, originationSize) {
const operationResults = (0, errors_1.flattenOperationResult)({ contents: [content] });
let consumedMilligas = 0;
let accumulatedStorage = 0;
operationResults.forEach((result) => {
consumedMilligas += Number(result.consumed_milligas) || 0;
// transfer to unrevealed implicit
accumulatedStorage += 'allocated_destination_contract' in result ? originationSize : 0;
// originate
accumulatedStorage +=
'originated_contracts' in result && Array.isArray(result.originated_contracts)
? result.originated_contracts.length * originationSize
: 0;
// register_global_constants
accumulatedStorage +=
'storage_size' in result && 'global_address' in result
? Number(result.storage_size) || 0
: 0;
// transfer_ticket, originate, contract_call
accumulatedStorage +=
'paid_storage_size_diff' in result ? Number(result.paid_storage_size_diff) || 0 : 0;
//smart_rollup_originate
accumulatedStorage += 'genesis_commitment_hash' in result ? Number(result.size) || 0 : 0;
});
if ((0, types_1.isOpWithFee)(content)) {
return {
milligasLimit: (0, types_1.isOpWithGasBuffer)(content)
? consumedMilligas + Number(this.MILLIGAS_BUFFER)
: consumedMilligas,
storageLimit: accumulatedStorage > 0 ? accumulatedStorage + this.STORAGE_BUFFER : 0,
opSize: size,
minimalFeePerStorageByteMumav: costPerByte.toNumber(),
};
}
else {
return {
milligasLimit: 0,
storageLimit: 0,
opSize: size,
minimalFeePerStorageByteMumav: costPerByte.toNumber(),
baseFeeMumav: 0,
};
}
}
calculateEstimates(op, constants) {
return __awaiter(this, void 0, void 0, function* () {
const { opbytes, opOb: { branch, contents }, } = yield this.forge(op);
const operation = {
operation: { branch, contents, signature: STUB_SIGNATURE },
chain_id: yield this.context.readProvider.getChainId(),
};
const { opResponse } = yield this.simulate(operation);
const { cost_per_byte, origination_size } = constants;
const errors = [...(0, errors_1.flattenErrors)(opResponse, 'backtracked'), ...(0, errors_1.flattenErrors)(opResponse)];
// Fail early in case of errors
if (errors.length) {
throw new errors_1.MavrykOperationError(errors, 'Error occurred during estimation', opResponse.contents);
}
let numberOfOps = 1;
if (Array.isArray(op.opOb.contents) && op.opOb.contents.length > 1) {
numberOfOps =
opResponse.contents[0].kind === 'reveal'
? op.opOb.contents.length - 1
: op.opOb.contents.length;
}
return opResponse.contents.map((x) => {
return this.getEstimationPropertiesFromOperationContent(x,
// diff between estimated and injecting OP_SIZE is 124-126, we added buffer to use 130
x.kind === 'reveal' ? this.OP_SIZE_REVEAL / 2 : (opbytes.length + 130) / 2 / numberOfOps, cost_per_byte, origination_size !== null && origination_size !== void 0 ? origination_size : 257 // protocol constants
);
});
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for an origination operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param OriginationOperation Originate operation parameter
*/
originate(params) {
return __awaiter(this, void 0, void 0, function* () {
const preparedOperation = yield this.prepare.originate(params);
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for an transfer operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param TransferOperation Originate operation parameter
*/
transfer(_a) {
var _b;
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
return __awaiter(this, void 0, void 0, function* () {
const toValidation = (0, taquito_utils_1.validateAddress)(rest.to);
if (toValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new taquito_core_1.InvalidAddressError(rest.to, (0, taquito_utils_1.invalidDetail)(toValidation));
}
const sourceValidation = (0, taquito_utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
if (rest.source && sourceValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new taquito_core_1.InvalidAddressError(rest.source, (0, taquito_utils_1.invalidDetail)(sourceValidation));
}
if (rest.amount < 0) {
throw new taquito_core_1.InvalidAmountError(rest.amount.toString());
}
const preparedOperation = yield this.prepare.transaction(Object.assign({ fee,
storageLimit,
gasLimit }, rest));
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for an stake pseudo-operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param Stake pseudo-operation parameter
*/
stake(_a) {
var _b;
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
return __awaiter(this, void 0, void 0, function* () {
const sourceValidation = (0, taquito_utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
if (rest.source && sourceValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new taquito_core_1.InvalidAddressError(rest.source, (0, taquito_utils_1.invalidDetail)(sourceValidation));
}
if (!rest.to) {
rest.to = rest.source;
}
if (rest.to && rest.to !== rest.source) {
throw new taquito_core_1.InvalidStakingAddressError(rest.to);
}
if (rest.amount < 0) {
throw new taquito_core_1.InvalidAmountError(rest.amount.toString());
}
const preparedOperation = yield this.prepare.stake(Object.assign({ fee,
storageLimit,
gasLimit }, rest));
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for an Unstake pseudo-operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param Unstake pseudo-operation parameter
*/
unstake(_a) {
var _b;
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
return __awaiter(this, void 0, void 0, function* () {
const sourceValidation = (0, taquito_utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
if (rest.source && sourceValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new taquito_core_1.InvalidAddressError(rest.source, (0, taquito_utils_1.invalidDetail)(sourceValidation));
}
if (!rest.to) {
rest.to = rest.source;
}
if (rest.to && rest.to !== rest.source) {
throw new taquito_core_1.InvalidStakingAddressError(rest.to);
}
if (rest.amount < 0) {
throw new taquito_core_1.InvalidAmountError(rest.amount.toString());
}
const preparedOperation = yield this.prepare.unstake(Object.assign({ fee,
storageLimit,
gasLimit }, rest));
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for an finalize_unstake pseudo-operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param finalize_unstake pseudo-operation parameter
*/
finalizeUnstake(_a) {
var _b;
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
return __awaiter(this, void 0, void 0, function* () {
const sourceValidation = (0, taquito_utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
if (rest.source && sourceValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new taquito_core_1.InvalidAddressError(rest.source, (0, taquito_utils_1.invalidDetail)(sourceValidation));
}
if (!rest.to) {
rest.to = rest.source;
}
if (rest.to && rest.to !== rest.source) {
throw new taquito_core_1.InvalidStakingAddressError(rest.to);
}
if (!rest.amount) {
rest.amount = 0;
}
if (rest.amount !== undefined && rest.amount !== 0) {
throw new Error('Amount must be 0 for finalize_unstake operation');
}
const preparedOperation = yield this.prepare.finalizeUnstake(Object.assign({ fee,
storageLimit,
gasLimit }, rest));
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for a transferTicket operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param TransferTicketParams operation parameter
*/
transferTicket(_a) {
var _b;
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
return __awaiter(this, void 0, void 0, function* () {
const destinationValidation = (0, taquito_utils_1.validateAddress)(rest.destination);
if (destinationValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new taquito_core_1.InvalidAddressError(rest.destination, (0, taquito_utils_1.invalidDetail)(destinationValidation));
}
const sourceValidation = (0, taquito_utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
if (rest.source && sourceValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new taquito_core_1.InvalidAddressError(rest.source, (0, taquito_utils_1.invalidDetail)(sourceValidation));
}
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const preparedOperation = yield this.prepare.transferTicket(Object.assign({ fee,
storageLimit,
gasLimit }, rest));
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for a delegate operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param Estimate
*/
setDelegate(_a) {
var _b;
var { fee, gasLimit, storageLimit } = _a, rest = __rest(_a, ["fee", "gasLimit", "storageLimit"]);
return __awaiter(this, void 0, void 0, function* () {
const sourceValidation = (0, taquito_utils_1.validateAddress)(rest.source);
if (rest.source && sourceValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new taquito_core_1.InvalidAddressError(rest.source, (0, taquito_utils_1.invalidDetail)(sourceValidation));
}
const delegateValidation = (0, taquito_utils_1.validateAddress)((_b = rest.delegate) !== null && _b !== void 0 ? _b : '');
if (rest.delegate && delegateValidation !== taquito_utils_1.ValidationResult.VALID) {
throw new taquito_core_1.InvalidAddressError(rest.delegate, (0, taquito_utils_1.invalidDetail)(delegateValidation));
}
const preparedOperation = yield this.prepare.delegation(Object.assign({ fee,
storageLimit,
gasLimit }, rest));
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for a each operation in the batch
*
* @returns An array of Estimate objects. If a reveal operation is needed, the first element of the array is the Estimate for the reveal operation.
*/
batch(params) {
return __awaiter(this, void 0, void 0, function* () {
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const preparedOperations = yield this.prepare.batch(params);
const estimateProperties = yield this.calculateEstimates(preparedOperations, protocolConstants);
return estimate_1.Estimate.createArrayEstimateInstancesFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for a delegate operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param Estimate
*/
registerDelegate(_a, source) {
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
return __awaiter(this, void 0, void 0, function* () {
const pkh = (yield this.getKeys()).publicKeyHash;
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const checkSource = source || pkh;
const preparedOperation = yield this.prepare.registerDelegate(Object.assign({ fee, storageLimit, gasLimit }, rest), checkSource);
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees to reveal the current account
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
*
* @param Estimate
*/
reveal(params) {
return __awaiter(this, void 0, void 0, function* () {
const { publicKeyHash, publicKey } = yield this.getKeys();
if (!publicKey) {
throw new errors_2.RevealEstimateError();
}
if (yield this.isAccountRevealRequired(publicKeyHash)) {
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const preparedOperation = params
? yield this.prepare.reveal(params)
: yield this.prepare.reveal({});
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
}
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for an registerGlobalConstant operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param params registerGlobalConstant operation parameter
*/
registerGlobalConstant(_a) {
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
return __awaiter(this, void 0, void 0, function* () {
const preparedOperation = yield this.prepare.registerGlobalConstant(Object.assign({ fee,
storageLimit,
gasLimit }, rest));
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit, and fees for an increasePaidStorage operation
*
* @returns An estimation of gasLimit, storageLimit, and fees for the operation
*
* @param params increasePaidStorage operation parameters
*/
increasePaidStorage(_a) {
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
return __awaiter(this, void 0, void 0, function* () {
if (rest.amount < 0) {
throw new taquito_core_1.InvalidAmountError(rest.amount.toString());
}
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const preparedOperation = yield this.prepare.increasePaidStorage(Object.assign({ fee,
storageLimit,
gasLimit }, rest));
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for an Update Consensus Key operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param Estimate
*/
updateConsensusKey(params) {
return __awaiter(this, void 0, void 0, function* () {
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const preparedOperation = yield this.prepare.updateConsensusKey(params);
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for a smart_rollup_add_messages operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param Estimate
*/
smartRollupAddMessages(params) {
return __awaiter(this, void 0, void 0, function* () {
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const preparedOperation = yield this.prepare.smartRollupAddMessages(params);
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for an Smart Rollup Originate operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param SmartRollupOriginateParams
*/
smartRollupOriginate(params) {
return __awaiter(this, void 0, void 0, function* () {
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const preparedOperation = yield this.prepare.smartRollupOriginate(params);
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for a smart_rollup_execute_outbox_message operation
*
* @returns An estimation of gasLimit, storageLimit and fees for the operation
*
* @param Estimate
*/
smartRollupExecuteOutboxMessage(params) {
return __awaiter(this, void 0, void 0, function* () {
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const preparedOperation = yield this.prepare.smartRollupExecuteOutboxMessage(params);
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
/**
*
* @description Estimate gasLimit, storageLimit and fees for contract call
*
* @returns An estimation of gasLimit, storageLimit and fees for the contract call
*
* @param Estimate
*/
contractCall(contractMethod) {
return __awaiter(this, void 0, void 0, function* () {
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
const preparedOperation = yield this.prepare.contractCall(contractMethod);
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
estimateProperties.shift();
estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
}
return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
});
}
}
exports.RPCEstimateProvider = RPCEstimateProvider;