@ledgerhq/coin-tezos
Version:
31 lines • 1.34 kB
JavaScript
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
// SPDX-License-Identifier: Apache-2.0
import { log } from '@ledgerhq/logs';
import { getRevealFee, getRevealGasLimit } from '@taquito/taquito';
/**
* Estimate the reveal-operation limits for an unrevealed manager account, clamped to
* the configured minimums. Falls back to the SDK helpers when node estimation fails
* (some addresses error with "inconsistent_hash").
*/
export async function estimateRevealLimits(tezosToolkit, address, feesConfig) {
let revealEstimate;
try {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
revealEstimate = (await tezosToolkit.estimate.reveal());
}
catch (error) {
log('estimate-error', 'error estimating reveal fees, trying to use getRevealGasLimit', {
error,
});
revealEstimate = {
gasLimit: getRevealGasLimit(address),
suggestedFeeMutez: getRevealFee(address),
};
}
return {
fee: Math.max(feesConfig.minFees, revealEstimate?.suggestedFeeMutez ?? getRevealFee(address)),
gasLimit: Math.max(feesConfig.minRevealGasLimit, revealEstimate?.gasLimit ?? 0),
storageLimit: Math.max(feesConfig.minStorageLimit, revealEstimate?.storageLimit ?? 0),
};
}
//# sourceMappingURL=estimateRevealLimits.js.map