cli.rs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //! CLI options
  2. use solana_program::pubkey::Pubkey;
  3. use std::path::PathBuf;
  4. use clap::Clap;
  5. #[derive(Clap)]
  6. #[clap(
  7. about = "A client for the pyth2wormhole Solana program",
  8. author = "The Wormhole Project"
  9. )]
  10. pub struct Cli {
  11. #[clap(
  12. short,
  13. long,
  14. default_value = "3",
  15. about = "Logging level, where 0..=1 RUST_LOG=error and 5.. is RUST_LOG=trace"
  16. )]
  17. pub log_level: u32,
  18. #[clap(
  19. long,
  20. about = "Identity JSON file for the entity meant to cover transaction costs",
  21. default_value = "~/.config/solana/id.json"
  22. )]
  23. pub payer: String,
  24. #[clap(short, long, default_value = "http://localhost:8899")]
  25. pub rpc_url: String,
  26. #[clap(long)]
  27. pub p2w_addr: Pubkey,
  28. #[clap(subcommand)]
  29. pub action: Action,
  30. }
  31. #[derive(Clap)]
  32. pub enum Action {
  33. #[clap(about = "Initialize a pyth2wormhole program freshly deployed under <p2w_addr>")]
  34. Init {
  35. /// The bridge program account
  36. #[clap(short = 'w', long = "wh-prog")]
  37. wh_prog: Pubkey,
  38. #[clap(short = 'o', long = "owner")]
  39. owner_addr: Pubkey,
  40. #[clap(short = 'p', long = "pyth-owner")]
  41. pyth_owner_addr: Pubkey,
  42. },
  43. #[clap(
  44. about = "Use an existing pyth2wormhole program to attest product price information to another chain"
  45. )]
  46. Attest {
  47. #[clap(short = 'f', long = "--config", about = "Attestation YAML config")]
  48. attestation_cfg: PathBuf,
  49. #[clap(
  50. short = 'n',
  51. long = "--retries",
  52. about = "How many times to retry each batch on failure",
  53. default_value = "3"
  54. )]
  55. n_retries: usize,
  56. },
  57. #[clap(about = "Retrieve a pyth2wormhole program's current settings")]
  58. GetConfig,
  59. #[clap(about = "Update an existing pyth2wormhole program's settings")]
  60. SetConfig {
  61. /// Current owner keypair path
  62. #[clap(long = "owner", default_value = "~/.config/solana/id.json")]
  63. owner: String,
  64. /// New owner to set
  65. #[clap(long = "new-owner")]
  66. new_owner_addr: Pubkey,
  67. #[clap(long = "new-wh-prog")]
  68. new_wh_prog: Pubkey,
  69. #[clap(long = "new-pyth-owner")]
  70. new_pyth_owner_addr: Pubkey,
  71. },
  72. }