Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Next Next commit
add multisig update
  • Loading branch information
Buckram123 committed Oct 25, 2024
commit 18ad305ec2bf55d27a70fc79da5c605818e76b19
5 changes: 4 additions & 1 deletion framework/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion framework/packages/abstract-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ abstract-std = { workspace = true }
cw-orch = { workspace = true }
cw-orch-interchain = { workspace = true, optional = true }
cw-orch-polytone = { workspace = true, optional = true }
cw-plus-orch = "0.25.0"

log = "0.4.14"
serde_json = "1.0.79"
Expand All @@ -59,7 +60,9 @@ workspace-hack = { version = "0.1", path = "../../workspace-hack" }

# Predictable abstract addresses
cw-blob = { workspace = true }
cosmrs = { version = "0.19.0" }
cosmrs = { version = "0.20.0", features = ["cosmwasm"] }
prost-types = { version = "0.13.3" }
prost = { version = "0.13.3" }

[build-dependencies]
serde_json = "1.0.79"
Expand Down
3 changes: 3 additions & 0 deletions framework/packages/abstract-interface/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ pub enum AbstractInterfaceError {

#[error("No matching module deployed {0:?}")]
NoMatchingModule(StaticDependency),

#[error("Multisig error: {0}")]
Multisig(String),
}

impl AbstractInterfaceError {
Expand Down
2 changes: 2 additions & 0 deletions framework/packages/abstract-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ pub use error::AbstractInterfaceError;
pub use crate::{deployers::*, deployment::*};

pub use daemon_state::AbstractDaemonState;

mod multisig;
53 changes: 53 additions & 0 deletions framework/packages/abstract-interface/src/multisig.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use cosmrs::tx::Msg;
use cosmwasm_std::from_json;
use cw_orch::{contract::Contract, prelude::*};
use cw_plus_orch::cw3_flex_multisig::{self, Cw3FlexMultisig};
use prost::{Message, Name};

use crate::{Abstract, AbstractInterfaceError};

impl<T: CwEnv + Stargate> Abstract<T> {
pub fn update_admin_to_cw3_flex(
&self,
cw3_flex_contract: Cw3FlexMultisig<T>,
extra_contracts: impl IntoIterator<Item = Contract<T>>,
) -> Result<(), AbstractInterfaceError> {
// Make sure we have cw3-flex
let chain = self.registry.environment().clone();
let cw3_flex_address = cw3_flex_contract.address()?;
let cw2_of_cw3: cw2::ContractVersion = cosmwasm_std::from_json(
chain
.wasm_querier()
.raw_query(&cw3_flex_address, cw2::CONTRACT.as_slice().to_vec())
.map_err(Into::into)?,
)?;
if !cw2_of_cw3.contract.contains("cw3-flex-multisig") {
return Err(AbstractInterfaceError::Multisig(
"cw3-flex-multisig contract info missmatch".to_string(),
));
}

for contract in self
.contracts()
.into_iter()
.map(|(contract, _version)| contract.clone())
.chain(extra_contracts)
{
chain
.commit_any::<cosmrs::proto::cosmwasm::wasm::v1::MsgUpdateAdminResponse>(
vec![prost_types::Any {
value: cosmrs::proto::cosmwasm::wasm::v1::MsgUpdateAdmin {
sender: chain.sender_addr().to_string(),
new_admin: cw3_flex_address.to_string(),
contract: contract.address()?.to_string(),
}
.encode_to_vec(),
type_url: cosmrs::proto::cosmwasm::wasm::v1::MsgUpdateAdmin::type_url(),
}],
None,
)
.map_err(Into::into)?;
}
Ok(())
}
}