deploy_cosmwasm.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* eslint-disable @typescript-eslint/no-unsafe-call */
  2. /* eslint-disable @typescript-eslint/no-floating-promises */
  3. /* eslint-disable unicorn/prefer-top-level-await */
  4. /* eslint-disable no-console */
  5. import yargs from "yargs";
  6. import { hideBin } from "yargs/helpers";
  7. import { COMMON_DEPLOY_OPTIONS } from "./common";
  8. import { CosmWasmChain } from "../src/core/chains";
  9. import { CosmWasmPriceFeedContract } from "../src/core/contracts/cosmwasm";
  10. import { DefaultStore } from "../src/node/utils/store";
  11. const parser = yargs(hideBin(process.argv))
  12. .scriptName("deploy_cosmwasm.ts")
  13. .usage(
  14. "Usage: $0 --code <path/to/artifact.wasm> --private-key <private-key> --chain <chain>",
  15. )
  16. .options({
  17. code: {
  18. type: "string",
  19. demandOption: true,
  20. desc: "Path to the artifact .wasm file",
  21. },
  22. "private-key": COMMON_DEPLOY_OPTIONS["private-key"],
  23. chain: {
  24. type: "string",
  25. demandOption: true,
  26. desc: "Chain to upload the code on. Can be one of the chains available in the store",
  27. },
  28. wormholeContract: {
  29. type: "string",
  30. demandOption: true,
  31. desc: "Wormhole contract address deployed on this chain",
  32. },
  33. });
  34. async function main() {
  35. const argv = await parser.argv;
  36. const { code, wormholeContract } = argv;
  37. console.log(
  38. // @ts-expect-error - TODO: The typings do not indicate that the deploy() function
  39. // exists on the COsmWasmPriceFeedContract(), so this may explode at runtime
  40. await CosmWasmPriceFeedContract.deploy(
  41. DefaultStore.chains[argv.chain] as CosmWasmChain,
  42. wormholeContract,
  43. argv["private-key"],
  44. code,
  45. ),
  46. );
  47. }
  48. main();