-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: cyberhoward <[email protected]> Co-authored-by: CyberHoward <[email protected]>
- Loading branch information
1 parent
750adcf
commit 744539f
Showing
43 changed files
with
1,645 additions
and
137 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
04f4407f6bcd706a28327afb3bf5b2f16a18d75d0adc376ef44f8a4768d41877 abstract_account-xion.wasm | ||
55124e42532e6cbfa306a8d85d3c8a634ec92d2803fe4dfeb8ed7918cd7e0e0c abstract_account.wasm | ||
5f94f255722d33689eeb631bc796fbc1598985f8922d1987573644525dab4a1c abstract_ans_host.wasm | ||
5e920677063397df022ce9ca9dd5e4f799c5ab7f601b7927cef013ca6be2486e abstract_ibc_client.wasm | ||
3a14e2a3beeecc21d830367be33406dd2b5a33ab6733302b07fed0f3046f45dd abstract_ibc_host.wasm | ||
9fb8a8e96e94977fd0b17265f1d4276484fe728ed943e3adcf9b4eca35ebf96a abstract_ica_client.wasm | ||
11f769be8bf52d69c4af2d0ed539747ae359586740e3d05cb4ef20b1f8589422 abstract_module_factory.wasm | ||
dea92cb8f17c18cb3b8ab64b832951d187f7c28747727811eecd640a096d7b35 abstract_registry.wasm | ||
29611e9e921466d6b5848019abb4a27d7a2b385d02997bd8dd3ded25133b6570 abstract_account-xion.wasm | ||
73a9ee61aa92f9203a513e9657d106ecfa8e01d93454126b0144d336294da8e3 abstract_account.wasm | ||
c406ce2d7bc972ea6c320a9a366cf0d3717add9a7ffe63128c17be95a2e76f53 abstract_ans_host.wasm | ||
2b22bd8dfa7529682e66a9304c241c15ff94cb1f83e3ce86ab39401eef3f7e69 abstract_ibc_client.wasm | ||
582f99ce30af486b5b8891e402715947e9d1ef42981dee6ce742ef5e19d7691e abstract_ibc_host.wasm | ||
2154914284863ad50c710dde01c754fb7bd713e203585c5115175161a6f1be5e abstract_ica_client.wasm | ||
1348f236fd26251ddeef941d3c03a9b7fcb323e608b680ef2581734105bd7f29 abstract_module_factory.wasm | ||
97ec7bfd1f89693c1826689153fb7661512e577be2dde6c4dbda38731197a136 abstract_registry.wasm |
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
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
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
174 changes: 174 additions & 0 deletions
174
framework/packages/abstract-interface/tests/interchain_integration/bin/ibc_hook.rs
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,174 @@ | ||
// This script is used for testing a connection between 2 chains | ||
// This script sets up tokens and channels between transfer ports to transfer those tokens | ||
// This also mints tokens to the chain sender for future interactions | ||
|
||
use std::time::{Duration, SystemTime, UNIX_EPOCH}; | ||
|
||
use abstract_interchain_tests::{setup::set_starship_env, JUNO}; | ||
use abstract_interface::{connection::connect_one_way_to, Abstract}; | ||
use abstract_sdk::HookMemoBuilder; | ||
use abstract_std::{ | ||
ans_host::ExecuteMsgFns, | ||
objects::{TruncatedChainId, UncheckedChannelEntry}, | ||
ICS20, PROXY, | ||
}; | ||
use anyhow::Result as AnyResult; | ||
use cosmwasm_std::{coin, coins}; | ||
use counter_contract::CounterContract; | ||
use cw_orch::{daemon::RUNTIME, prelude::*}; | ||
use cw_orch_interchain::prelude::*; | ||
use cw_orch_proto::tokenfactory::{create_denom, get_denom, mint}; | ||
|
||
// Note: Truncated chain id have to be different | ||
pub const JUNO2: &str = "junotwo-1"; | ||
|
||
pub fn test_pfm() -> AnyResult<()> { | ||
dotenv::dotenv().ok(); | ||
set_starship_env(); | ||
env_logger::init(); | ||
|
||
let starship = Starship::new(None).unwrap(); | ||
let interchain = starship.interchain_env(); | ||
|
||
let juno = interchain.get_chain(JUNO).unwrap(); | ||
let juno2 = interchain.get_chain(JUNO2).unwrap(); | ||
|
||
// Create a channel between the 2 chains for the transfer ports | ||
// JUNO>JUNO2 | ||
let juno_juno2_channel = interchain | ||
.create_channel( | ||
JUNO, | ||
JUNO2, | ||
&PortId::transfer(), | ||
&PortId::transfer(), | ||
"ics20-1", | ||
Some(cosmwasm_std::IbcOrder::Unordered), | ||
)? | ||
.interchain_channel; | ||
|
||
let abstr_juno = Abstract::deploy_on(juno.clone(), juno.sender_addr().to_string())?; | ||
let abstr_juno2 = Abstract::deploy_on(juno2.clone(), juno2.sender_addr().to_string())?; | ||
connect_one_way_to(&abstr_juno, &abstr_juno2, &interchain)?; | ||
|
||
// Faster to load if deployed | ||
// let abstr_juno = Abstract::load_from(juno.clone())?; | ||
// let abstr_juno2 = Abstract::load_from(juno2.clone())?; | ||
|
||
let counter_juno2 = init_counter(juno2.clone())?; | ||
|
||
let sender = juno.sender_addr().to_string(); | ||
|
||
let test_amount: u128 = 100_000_000_000; | ||
let token_subdenom = format!( | ||
"testtoken{}", | ||
SystemTime::now() | ||
.duration_since(UNIX_EPOCH) | ||
.unwrap() | ||
.as_secs() | ||
); | ||
|
||
// Create Denom | ||
create_denom(&juno, token_subdenom.as_str())?; | ||
|
||
// Mint Denom | ||
mint(&juno, sender.as_str(), token_subdenom.as_str(), test_amount)?; | ||
|
||
// Register this channel with the abstract ibc implementation for sending tokens | ||
abstr_juno.ans_host.update_channels( | ||
vec![( | ||
UncheckedChannelEntry { | ||
connected_chain: TruncatedChainId::from_chain_id(JUNO2).to_string(), | ||
protocol: ICS20.to_string(), | ||
}, | ||
juno_juno2_channel | ||
.get_chain(JUNO)? | ||
.channel | ||
.unwrap() | ||
.to_string(), | ||
)], | ||
vec![], | ||
)?; | ||
|
||
// Create a test account + Remote account | ||
|
||
let origin_account = abstr_juno.account_factory.create_default_account( | ||
abstract_client::GovernanceDetails::Monarchy { | ||
monarch: juno.sender_addr().to_string(), | ||
}, | ||
)?; | ||
origin_account.manager.set_ibc_status(true)?; | ||
|
||
// Send funds to the remote account | ||
RUNTIME.block_on(juno.sender().bank_send( | ||
&origin_account.proxy.address()?, | ||
vec![coin(test_amount, get_denom(&juno, token_subdenom.as_str()))], | ||
))?; | ||
|
||
let memo = HookMemoBuilder::new( | ||
counter_juno2.address()?, | ||
&counter_contract::msg::ExecuteMsg::Increment {}, | ||
) | ||
.build()?; | ||
// We send from osmosis to juno funds with pfm memo that includes juno-stargaze channel | ||
origin_account.manager.execute_on_module( | ||
PROXY, | ||
abstract_std::proxy::ExecuteMsg::IbcAction { | ||
msg: abstract_std::ibc_client::ExecuteMsg::SendFunds { | ||
host_chain: TruncatedChainId::from_chain_id(JUNO2), | ||
funds: coins(10_000_000_000, get_denom(&juno, token_subdenom.as_str())), | ||
memo: Some(memo.clone()), | ||
receiver: Some(counter_juno2.addr_str()?), | ||
}, | ||
}, | ||
)?; | ||
origin_account.manager.execute_on_module( | ||
PROXY, | ||
abstract_std::proxy::ExecuteMsg::IbcAction { | ||
msg: abstract_std::ibc_client::ExecuteMsg::SendFunds { | ||
host_chain: TruncatedChainId::from_chain_id(JUNO2), | ||
funds: coins(10_000_000_000, get_denom(&juno, token_subdenom.as_str())), | ||
memo: Some(memo.clone()), | ||
receiver: Some(counter_juno2.addr_str()?), | ||
}, | ||
}, | ||
)?; | ||
origin_account.manager.execute_on_module( | ||
PROXY, | ||
abstract_std::proxy::ExecuteMsg::IbcAction { | ||
msg: abstract_std::ibc_client::ExecuteMsg::SendFunds { | ||
host_chain: TruncatedChainId::from_chain_id(JUNO2), | ||
funds: coins(10_000_000_000, get_denom(&juno, token_subdenom.as_str())), | ||
memo: Some(memo), | ||
receiver: Some(counter_juno2.addr_str()?), | ||
}, | ||
}, | ||
)?; | ||
log::info!("waiting for ibc_hook to finish tx"); | ||
std::thread::sleep(Duration::from_secs(15)); | ||
|
||
let count_juno2 = counter_juno2.query(&counter_contract::msg::QueryMsg::GetCount {})?; | ||
log::info!("count juno2: {count_juno2:?}"); | ||
|
||
// Verify the funds have been received | ||
let count_juno2_balance = juno2 | ||
.bank_querier() | ||
.balance(&counter_juno2.address()?, None)?; | ||
|
||
log::info!("count_juno2 balance, {:?}", count_juno2_balance); | ||
Ok(()) | ||
} | ||
|
||
pub fn init_counter<Chain: CwEnv>(chain: Chain) -> anyhow::Result<CounterContract<Chain>> { | ||
let counter = CounterContract::new(chain); | ||
counter.upload()?; | ||
counter.instantiate( | ||
&counter_contract::msg::InstantiateMsg { count: 0 }, | ||
None, | ||
&[], | ||
)?; | ||
Ok(counter) | ||
} | ||
|
||
pub fn main() { | ||
test_pfm().unwrap(); | ||
} |
Oops, something went wrong.