Skip to content

Commit 19047c1

Browse files
author
Stanisław Drozd
authored
p2w-client: add get-emitter for printing emitter address (#267)
* p2w-client: add get-emitter for printing emitter address * Move get-emitter before CLI checks
1 parent b4c8f2e commit 19047c1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

solana/pyth2wormhole/client/src/cli.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,6 @@ pub enum Action {
128128
)]
129129
owner: String,
130130
},
131+
#[clap(about = "Print out emitter address for the specified pyth2wormhole contract")]
132+
GetEmitter,
131133
}

solana/pyth2wormhole/client/src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ async fn main() -> Result<(), ErrBox> {
7272
let cli = Cli::parse();
7373
init_logging(cli.log_level);
7474

75+
// All other CLI actions make rpc requests, this one's meant to be
76+
// off-chain explicitly
77+
if let Action::GetEmitter = cli.action {
78+
let emitter_addr = P2WEmitter::key(None, &cli.p2w_addr);
79+
println!("{}", emitter_addr);
80+
81+
// Exit early
82+
return Ok(());
83+
}
84+
7585
let payer = read_keypair_file(&*shellexpand::tilde(&cli.payer))?;
7686

7787
let rpc_client = RpcClient::new_with_commitment(cli.rpc_url.clone(), cli.commitment.clone());
@@ -179,6 +189,7 @@ async fn main() -> Result<(), ErrBox> {
179189
)
180190
.await?;
181191
}
192+
Action::GetEmitter => unreachable!{}
182193
}
183194

184195
Ok(())

0 commit comments

Comments
 (0)