Skip to content

Commit

Permalink
CosmosVerse deploy (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayanski authored Oct 25, 2024
1 parent 566bbb1 commit 5bd866e
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 157 deletions.
2 changes: 1 addition & 1 deletion interchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ abstract-dex-standard = { path = "../framework/packages/standards/dex" }
abstract-staking-standard = { path = "../framework/packages/standards/staking" }
abstract-money-market-standard = { path = "../framework/packages/standards/money-market" }

# TODO: remove after polytone release
#TODO: remove after polytone release
abstract-polytone = { git = "https://github.com/AbstractSDK/polytone.git", branch = "bump/cw2" }
abstract-polytone-note = { git = "https://github.com/AbstractSDK/polytone.git", branch = "bump/cw2" }
abstract-cw-orch-polytone = { git = "https://github.com/AbstractSDK/polytone.git", branch = "bump/cw2" }
Expand Down
3 changes: 2 additions & 1 deletion interchain/scripts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dotenv = "0.15.0"
env_logger = "0.11.3"
url = "2.4.1"

cosmos-sdk-proto = { version = "0.19.0", features = [
cosmos-sdk-proto = { version = "0.24.0", features = [
"grpc-transport",
"cosmwasm",
] }
Expand Down Expand Up @@ -61,5 +61,6 @@ bitcoin = { version = "0.32.2" }
tonic = { version = "0.12.2", features = ["tls"] }
cosmrs = { version = "0.19.0", features = ["dev", "cosmwasm", "grpc"] }
prost = { version = "0.13" }
prost-types = { version = "0.13" }

cw-orch-core = "2.0.0"
83 changes: 0 additions & 83 deletions interchain/scripts/src/bin/deploy-ibc.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,42 +1,18 @@
use abstract_interface::Abstract;
use cw_orch::daemon::networks::{HARPOON_4, PION_1};
use clap::Parser;
use cw_orch::daemon::DaemonState;
use cw_orch::prelude::*;
use cw_orch::tokio::runtime::Handle;

use cw_orch_interchain::prelude::*;
use tokio::runtime::Runtime;

/// Connect IBC between two chains.
/// @TODO update this to take in the networks as arguments.
fn main() -> cw_orch::anyhow::Result<()> {
dotenv::dotenv()?;
env_logger::init();

let chains = vec![
(PION_1, None),
(HARPOON_4, None),
// (OSMOSIS_1, Some(std::env::var("OSMOSIS_MNEMONIC")?)),
];
let runtime = Runtime::new()?;

let src_chain = &chains[1];
let dst_chain = &chains[0];

connect(src_chain.clone(), dst_chain.clone(), runtime.handle())?;

Ok(())
}
use networks::parse_network;

fn get_daemon(
chain: ChainInfo,
handle: &Handle,
mnemonic: Option<String>,
deployment_id: Option<String>,
state: Option<DaemonState>,
) -> cw_orch::anyhow::Result<Daemon> {
let mut builder = DaemonBuilder::new(chain);
builder.handle(handle);
if let Some(state) = state {
builder.state(state);
}
Expand All @@ -56,12 +32,10 @@ pub fn get_deployment_id(src_chain: &ChainInfo, dst_chain: &ChainInfo) -> String
fn connect(
(src_chain, src_mnemonic): (ChainInfo, Option<String>),
(dst_chain, dst_mnemonic): (ChainInfo, Option<String>),
handle: &Handle,
) -> cw_orch::anyhow::Result<()> {
let src_daemon = get_daemon(src_chain.clone(), handle, src_mnemonic.clone(), None, None)?;
let src_daemon = get_daemon(src_chain.clone(), src_mnemonic.clone(), None, None)?;
let dst_daemon = get_daemon(
dst_chain.clone(),
handle,
dst_mnemonic,
None,
Some(src_daemon.state()),
Expand All @@ -70,17 +44,46 @@ fn connect(
let src_abstract = Abstract::load_from(src_daemon.clone())?;
let dst_abstract = Abstract::load_from(dst_daemon.clone())?;

let src_polytone_daemon = get_daemon(
src_chain.clone(),
handle,
src_mnemonic,
Some(get_deployment_id(&src_chain, &dst_chain)),
Some(src_daemon.state()),
)?;

let interchain =
DaemonInterchain::from_daemons(vec![src_daemon, dst_daemon], &ChannelCreationValidator);
src_abstract.connect_to(&dst_abstract, &interchain)?;

Ok(())
}

#[derive(Parser, Default, Debug)]
#[command(author, version, about, long_about = None)]
struct Arguments {
#[arg(short, long)]
src: String,

#[arg(short, long)]
dst: String,
}

fn main() {
dotenv::dotenv().unwrap();
env_logger::init();

let args = Arguments::parse();

// let networks = vec![abstract_scripts::ROLLKIT_TESTNET];

let src_network = parse_network(&args.src).unwrap();
let dst_network = parse_network(&args.dst).unwrap();

if let Err(ref err) = connect((src_network, None), (dst_network, None)) {
log::error!("{}", err);
err.chain()
.skip(1)
.for_each(|cause| log::error!("because: {}", cause));

// The backtrace is not always generated. Try to run this example
// with `$env:RUST_BACKTRACE=1`.
// if let Some(backtrace) = e.backtrace() {
// log::debug!("backtrace: {:?}", backtrace);
// }

::std::process::exit(1);
}
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,21 @@
use abstract_client::AbstractClient;
use clap::Parser;

use cosmwasm_std::CosmosMsg;
use cw_orch::daemon::networks::{PION_1, XION_TESTNET_1};
use cw_orch::daemon::DaemonState;
use cw_orch::environment::ChainState;
use cw_orch::prelude::*;
use cw_orch::tokio::runtime::Handle;

use cw_orch_interchain::prelude::*;
use tokio::runtime::Runtime;

/// Connect IBC between two chains.
/// @TODO update this to take in the networks as arguments.
fn main() -> cw_orch::anyhow::Result<()> {
dotenv::dotenv()?;
env_logger::init();

let chains = vec![
(PION_1, None),
(XION_TESTNET_1, None),
// (OSMOSIS_1, Some(std::env::var("OSMOSIS_MNEMONIC")?)),
];
let runtime = Runtime::new()?;

let src_chain = &chains[0];
let dst_chain = &chains[1];

test_ibc(src_chain.clone(), dst_chain.clone(), runtime.handle())?;

Ok(())
}
use networks::parse_network;

fn get_daemon(
chain: ChainInfo,
handle: &Handle,
mnemonic: Option<String>,
state: Option<DaemonState>,
deployment_id: Option<String>,
) -> cw_orch::anyhow::Result<Daemon> {
let mut builder = DaemonBuilder::new(chain);
builder.handle(handle);
if let Some(mnemonic) = mnemonic {
builder.mnemonic(mnemonic);
}
Expand All @@ -56,15 +32,13 @@ pub fn get_deployment_id(src_chain: &ChainInfo, dst_chain: &ChainInfo) -> String
format!("{}-->{}", src_chain.chain_id, dst_chain.chain_id)
}

fn test_ibc(
fn test(
(src_chain, src_mnemonic): (ChainInfo, Option<String>),
(dst_chain, dst_mnemonic): (ChainInfo, Option<String>),
handle: &Handle,
) -> cw_orch::anyhow::Result<()> {
let src_daemon = get_daemon(src_chain.clone(), handle, src_mnemonic.clone(), None, None)?;
let src_daemon = get_daemon(src_chain.clone(), src_mnemonic.clone(), None, None)?;
let dst_daemon = get_daemon(
dst_chain.clone(),
handle,
dst_mnemonic,
Some(src_daemon.state()),
None,
Expand Down Expand Up @@ -92,3 +66,43 @@ fn test_ibc(

Ok(())
}

#[derive(Parser, Default, Debug)]
#[command(author, version, about, long_about = None)]
struct Arguments {
#[arg(short, long)]
src: String,

#[arg(short, long)]
dst: String,
}

/// Test IBC connection between two chains.
fn main() {
dotenv::dotenv().unwrap();
env_logger::init();

let args = Arguments::parse();

// let networks = vec![abstract_scripts::ROLLKIT_TESTNET];

let src_network = parse_network(&args.src).unwrap();
let dst_network = parse_network(&args.dst).unwrap();

if let Err(ref err) = test((src_network.clone(), None), (dst_network.clone(), None))
.or(test((dst_network, None), (src_network, None)))
{
log::error!("{}", err);
err.chain()
.skip(1)
.for_each(|cause| log::error!("because: {}", cause));

// The backtrace is not always generated. Try to run this example
// with `$env:RUST_BACKTRACE=1`.
// if let Some(backtrace) = e.backtrace() {
// log::debug!("backtrace: {:?}", backtrace);
// }

::std::process::exit(1);
}
}
57 changes: 57 additions & 0 deletions interchain/scripts/src/bin/proposal_template.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use cosmos_sdk_proto::cosmos::gov::v1beta1::MsgSubmitProposalResponse;
use cosmrs::proto::cosmos::gov::v1::MsgSubmitProposal;
use cosmrs::proto::cosmwasm::wasm::v1::{AccessConfig, AccessType, MsgUpdateParams, Params};
use cw_orch::prelude::*;
use cw_orch_interchain::prelude::*;
use networks::COSMOS_HUB_TESTNET;
use prost::Name;
use xionrs::tx::MessageExt;

fn main() -> cw_orch::anyhow::Result<()> {
dotenv::dotenv()?;
env_logger::init();
let mut chain_info = COSMOS_HUB_TESTNET;
chain_info.gas_price = 0.005;
let chain = Daemon::builder(chain_info).build()?;

let msg_update_params = MsgUpdateParams {
authority: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn".to_string(),
params: Some(Params {
code_upload_access: Some(AccessConfig {
permission: AccessType::AnyOfAddresses as i32,
addresses: vec![
"cosmos1559zgk3mxm00qtr0zu2x5n4rh5vw704qaqj6ap".to_string(),
"cosmos14cl2dthqamgucg9sfvv4relp3aa83e4046yfy7".to_string(),
],
}),
instantiate_default_permission: AccessType::Everybody as i32,
}),
};

let msg_proposal = MsgSubmitProposal {
messages: vec![cosmrs::Any {
value: msg_update_params.to_bytes()?,
type_url: MsgUpdateParams::type_url(),
}],
initial_deposit: vec![cosmrs::proto::cosmos::base::v1beta1::Coin {
amount: 50_000_000u128.to_string(),
denom: "uatom".to_string(),
}],
proposer: chain.sender_addr().to_string(),
metadata: "none".to_string(),
title: "Give upload permissions to Abstract".to_string(),
summary: "Give upload permissions to Abstract".to_string(),
expedited: false,
};

let response = chain.commit_any::<MsgSubmitProposalResponse>(
vec![prost_types::Any {
type_url: MsgSubmitProposal::type_url(),
value: msg_proposal.to_bytes()?,
}],
None,
)?;
println!("Tx Hash {:?}", response.txhash);

Ok(())
}
Loading

0 comments on commit 5bd866e

Please sign in to comment.