UNPKG

locklift

Version:

Node JS framework for working with Ever contracts. Inspired by Truffle and Hardhat. Helps you to build, test, run and maintain your smart contracts.

51 lines (50 loc) 2.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); require("ts-node"); const config_1 = require("../../config"); const initLocklift_1 = require("../steps/initLocklift"); const everscale_inpage_provider_1 = require("everscale-inpage-provider"); const program = new commander_1.Command(); program .name("fee") .description("Print storage fee for the given contract and period of time") .requiredOption("-a --address <address>", "Contract address") .option("-t --time <time>", "Time in seconds, default is one year", (365 * 24 * 60 * 60).toString()) .option("-m --masterChain <masterChain>", "Is master chain") .option("-n, --network <network>", "Network to use, choose from configuration", config_1.LOCKLIFT_NETWORK_NAME) .addOption(new commander_1.Option("--config <config>", "Path to the config file") .default(() => (0, config_1.loadConfig)("locklift.config.ts")) .argParser(config => () => (0, config_1.loadConfig)(config))) .action(async (options) => { const DUMMY_ABI = { "ABI version": 2, version: "2.2", header: [], functions: [], events: [], fields: [ { name: "paramsRoot", type: "cell", }, ], }; const config = options.config(); const locklift = await (0, initLocklift_1.initLockliftStep)(config, options); const contractAddress = new everscale_inpage_provider_1.Address(options.address); const contractState = await new locklift.provider.Contract(DUMMY_ABI, contractAddress) .getFullState() .then(res => res.state); if (!contractState) { console.error(`Can't find contract with address ${contractAddress.toString()}`); process.exit(1); } const res = await locklift.provider.computeStorageFee({ state: contractState, timestamp: Date.now() / 1000 + Number(options.time), masterchain: !!options.masterChain, }); console.log(res); }); exports.default = program;