fetch_fees.ts 877 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import yargs from "yargs";
  2. import { hideBin } from "yargs/helpers";
  3. import {
  4. AptosContract,
  5. CosmWasmContract,
  6. DefaultStore,
  7. EvmContract,
  8. } from "../src";
  9. const parser = yargs(hideBin(process.argv))
  10. .usage("Usage: $0")
  11. .options({
  12. testnet: {
  13. type: "boolean",
  14. default: false,
  15. desc: "Fetch testnet contract fees instead of mainnet",
  16. },
  17. });
  18. async function main() {
  19. const argv = await parser.argv;
  20. for (const contract of Object.values(DefaultStore.contracts)) {
  21. if (contract.getChain().isMainnet() === argv.testnet) continue;
  22. if (
  23. contract instanceof AptosContract ||
  24. contract instanceof EvmContract ||
  25. contract instanceof CosmWasmContract
  26. ) {
  27. try {
  28. console.log(`${contract.getId()} ${await contract.getTotalFee()}`);
  29. } catch (e) {
  30. console.error(e);
  31. }
  32. }
  33. }
  34. }
  35. main();