upload_cosmwasm.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* eslint-disable @typescript-eslint/restrict-template-expressions */
  2. /* eslint-disable no-console */
  3. import yargs from "yargs";
  4. import { hideBin } from "yargs/helpers";
  5. import { toPrivateKey } from "../src/core/base";
  6. import { CosmWasmChain } from "../src/core/chains";
  7. import { CosmWasmPriceFeedContract } from "../src/core/contracts";
  8. import { DefaultStore } from "../src/node/utils/store";
  9. const parser = yargs(hideBin(process.argv))
  10. .usage(
  11. "Usage: $0 --code <path/to/artifact.wasm> --private-key <private-key> --chain <chain>",
  12. )
  13. .options({
  14. code: {
  15. type: "string",
  16. demandOption: true,
  17. desc: "Path to the artifact .wasm file",
  18. },
  19. "private-key": {
  20. type: "string",
  21. demandOption: true,
  22. desc: "Private key to use for the deployment",
  23. },
  24. chain: {
  25. type: "string",
  26. demandOption: true,
  27. desc: "Chain to upload the code on. Can be one of the chains available in the store",
  28. },
  29. });
  30. async function main() {
  31. const argv = await parser.argv;
  32. const { code } = argv;
  33. const { codeId } = await CosmWasmPriceFeedContract.storeCode(
  34. DefaultStore.chains[argv.chain] as CosmWasmChain,
  35. toPrivateKey(argv["private-key"]),
  36. code,
  37. );
  38. console.log(`Successfully uploaded code with id ${codeId}`);
  39. }
  40. // eslint-disable-next-line @typescript-eslint/no-floating-promises, unicorn/prefer-top-level-await
  41. main();