forked from axelarnetwork/axelar-amplifier
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(minor-ampd): add commands to unbond and claim stake (axelarnetwo…
- Loading branch information
Showing
5 changed files
with
112 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use axelar_wasm_std::nonempty; | ||
use cosmrs::cosmwasm::MsgExecuteContract; | ||
use cosmrs::tx::Msg; | ||
use error_stack::Result; | ||
use report::ResultCompatExt; | ||
use service_registry::msg::ExecuteMsg; | ||
use valuable::Valuable; | ||
|
||
use crate::commands::{broadcast_tx, verifier_pub_key}; | ||
use crate::config::Config; | ||
use crate::{Error, PREFIX}; | ||
|
||
#[derive(clap::Args, Debug, Valuable)] | ||
pub struct Args { | ||
pub service_name: nonempty::String, | ||
} | ||
|
||
pub async fn run(config: Config, args: Args) -> Result<Option<String>, Error> { | ||
let pub_key = verifier_pub_key(config.tofnd_config.clone()).await?; | ||
|
||
let msg = serde_json::to_vec(&ExecuteMsg::ClaimStake { | ||
service_name: args.service_name.into(), | ||
}) | ||
.expect("claim stake msg should be serializable"); | ||
|
||
let tx = MsgExecuteContract { | ||
sender: pub_key.account_id(PREFIX).change_context(Error::Tofnd)?, | ||
contract: config.service_registry.cosmwasm_contract.as_ref().clone(), | ||
msg, | ||
funds: vec![], | ||
} | ||
.into_any() | ||
.expect("failed to serialize proto message"); | ||
|
||
let tx_hash = broadcast_tx(config, tx, pub_key).await?.txhash; | ||
|
||
Ok(Some(format!( | ||
"successfully broadcast claim stake transaction, tx hash: {}", | ||
tx_hash | ||
))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use axelar_wasm_std::nonempty; | ||
use cosmrs::cosmwasm::MsgExecuteContract; | ||
use cosmrs::tx::Msg; | ||
use error_stack::Result; | ||
use report::ResultCompatExt; | ||
use service_registry::msg::ExecuteMsg; | ||
use valuable::Valuable; | ||
|
||
use crate::commands::{broadcast_tx, verifier_pub_key}; | ||
use crate::config::Config; | ||
use crate::{Error, PREFIX}; | ||
|
||
#[derive(clap::Args, Debug, Valuable)] | ||
pub struct Args { | ||
pub service_name: nonempty::String, | ||
} | ||
|
||
pub async fn run(config: Config, args: Args) -> Result<Option<String>, Error> { | ||
let pub_key = verifier_pub_key(config.tofnd_config.clone()).await?; | ||
|
||
let msg = serde_json::to_vec(&ExecuteMsg::UnbondVerifier { | ||
service_name: args.service_name.into(), | ||
}) | ||
.expect("unbond verifier msg should be serializable"); | ||
|
||
let tx = MsgExecuteContract { | ||
sender: pub_key.account_id(PREFIX).change_context(Error::Tofnd)?, | ||
contract: config.service_registry.cosmwasm_contract.as_ref().clone(), | ||
msg, | ||
funds: vec![], | ||
} | ||
.into_any() | ||
.expect("failed to serialize proto message"); | ||
|
||
let tx_hash = broadcast_tx(config, tx, pub_key).await?.txhash; | ||
|
||
Ok(Some(format!( | ||
"successfully broadcast unbond verifier transaction, tx hash: {}", | ||
tx_hash | ||
))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters