upload_cosmwasm.ts 1.2 KB

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