Skip to content

Commit

Permalink
Merge pull request #45 from fpco/parse-grant
Browse files Browse the repository at this point in the history
Add a parse-grant subcommand to authz
  • Loading branch information
snoyberg authored Sep 9, 2024
2 parents 2161175 + 2d35ea8 commit 09b784a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/cosmos-bin/src/authz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use base64::Engine;
use chrono::{DateTime, Utc};
use cosmos::{
messages::{MsgExecHelper, MsgGrantHelper},
proto::cosmwasm::wasm::v1::MsgExecuteContract,
proto::{
cosmos::authz::v1beta1::MsgGrant, cosmwasm::wasm::v1::MsgExecuteContract, traits::Message,
},
Address, Cosmos, HasAddress, HasAddressHrp, ParsedCoin, TxBuilder, TxMessage,
};

Expand Down Expand Up @@ -73,6 +75,11 @@ enum Subcommand {
#[clap(long)]
granter: Address,
},
/// Parse a base64-encoded grant string from a previous grant transaction
ParseGrant {
/// Base64-encoded string
grant: String,
},
}

pub(crate) async fn go(cosmos: Cosmos, Opt { sub }: Opt) -> Result<()> {
Expand Down Expand Up @@ -109,6 +116,11 @@ pub(crate) async fn go(cosmos: Cosmos, Opt { sub }: Opt) -> Result<()> {
funds,
granter,
} => execute_contract(cosmos, tx_opt, address, msg, funds, granter).await?,
Subcommand::ParseGrant { grant } => {
let grant = base64::engine::general_purpose::STANDARD_NO_PAD.decode(grant)?;
let grant = MsgGrant::decode(&*grant)?;
println!("{grant:#?}");
}
}

Ok(())
Expand Down

0 comments on commit 09b784a

Please sign in to comment.