diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 38ca55efc..47ca26769 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -81,24 +81,45 @@ jobs: path: ./artifacts/ if-no-files-found: error - # ibc-tests: - # runs-on: ubuntu-latest - # name: Post Build - IBC Tests - # needs: build - # steps: - # - uses: actions/checkout@v4 - # with: - # fetch-depth: 1 - # - name: Download Contracts - # uses: actions/download-artifact@v2 - # with: - # name: contracts - # path: "./ibc-tests/contracts" - # - name: Run IBC Tests - # run: | - # cd ./ibc-tests - # npm i - # npm test + ibc-tests: + runs-on: ubuntu-latest + name: Running E2E Test + needs: build + steps: + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: andromedaprotocol/localrelayer + ref: develop + token: ${{ secrets.LOCALRELAYER_ACCESS_TOKEN }} + path: localrelayer + - name: Setup docker + run: | + curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + chmod +x /usr/local/bin/docker-compose + docker-compose --version + - name: Setup localrelayer + run: | + cd ./localrelayer + make start-chains + make start-validators + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.75.0 + profile: minimal + - name: Download Artifacts To ibc-tests + uses: actions/download-artifact@v3 + with: + name: contracts + path: ./ibc-tests/artifacts + - name: Download Artifacts To andromeda testing + uses: actions/download-artifact@v3 + with: + name: contracts + path: ./packages/andromeda-testing-e2e/artifacts + - name: Run IBC Tests + run: | + cargo test -p ibc-tests -- --test-threads 1 build-schemas: runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index 81e05ba1a..cb03595e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,6 +133,7 @@ dependencies = [ "cosmwasm-schema 1.5.8", "cosmwasm-std 1.5.8", "cw-multi-test", + "cw-orch", "serde", ] @@ -147,6 +148,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "enum-repr", ] @@ -246,6 +248,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "cw-utils 1.0.3", "cw20 1.1.2", @@ -281,6 +284,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "cw-utils 1.0.3", "cw20 1.1.2", @@ -334,6 +338,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "cw721 0.18.0", "cw721-base 0.18.0", @@ -471,6 +476,7 @@ dependencies = [ "andromeda-std", "cosmwasm-schema 1.5.8", "cosmwasm-std 1.5.8", + "cw-orch", "cw-utils 1.0.3", "cw3 1.1.2", "cw4", @@ -509,6 +515,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-asset", "cw-controllers", + "cw-orch", "cw-utils 1.0.3", "cw20 1.1.2", "cw20-base", @@ -677,6 +684,7 @@ dependencies = [ "andromeda-std", "cosmwasm-schema 1.5.8", "cosmwasm-std 1.5.8", + "cw-orch", "cw-utils 1.0.3", "cw20 1.1.2", "cw721 0.18.0", @@ -926,6 +934,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "cw2 1.1.2", "enum-repr", @@ -3335,9 +3344,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", @@ -3375,7 +3384,7 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "rustls 0.23.17", "rustls-pki-types", @@ -3417,7 +3426,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "native-tls", "tokio", @@ -3436,7 +3445,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.5.1", "pin-project-lite", "socket2", "tokio", @@ -3533,7 +3542,10 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-orch", "cw-orch-daemon", + "cw20 1.1.2", + "cw721 0.18.0", "prost-types 0.13.3", + "rstest 0.19.0", "serde", "tokio", ] @@ -4626,7 +4638,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-rustls 0.27.3", "hyper-tls 0.6.0", "hyper-util", @@ -4690,9 +4702,9 @@ dependencies = [ [[package]] name = "rstest" -version = "0.23.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2c585be59b6b5dd66a9d2084aa1d8bd52fbdb806eafdeffb52791147862035" +checksum = "9d5316d2a1479eeef1ea21e7f9ddc67c191d497abc8fc3ba2467857abbb68330" dependencies = [ "futures", "futures-timer", @@ -4712,6 +4724,23 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "rstest_macros" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04a9df72cc1f67020b0d63ad9bfe4a323e459ea7eb68e03bd9824db49f9a4c25" +dependencies = [ + "cfg-if", + "glob", + "proc-macro2", + "quote", + "regex", + "relative-path", + "rustc_version", + "syn 2.0.87", + "unicode-ident", +] + [[package]] name = "rstest_macros" version = "0.23.0" @@ -4747,9 +4776,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.40" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags 2.6.0", "errno", @@ -4863,9 +4892,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -5727,7 +5756,7 @@ dependencies = [ "cw721 0.18.0", "cw721-base 0.18.0", "ibc-relayer-types", - "rstest", + "rstest 0.23.0", "toml 0.8.19", ] diff --git a/contracts/app/andromeda-app-contract/Cargo.toml b/contracts/app/andromeda-app-contract/Cargo.toml index b4eeaa325..84ad62546 100644 --- a/contracts/app/andromeda-app-contract/Cargo.toml +++ b/contracts/app/andromeda-app-contract/Cargo.toml @@ -21,7 +21,7 @@ enum-repr = { workspace = true } cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true, optional = true } cw-orch = { workspace = true } - +cw-orch-daemon = "0.24.2" [features] testing = ["cw-multi-test", "andromeda-testing"] diff --git a/contracts/app/andromeda-app-contract/src/interface.rs b/contracts/app/andromeda-app-contract/src/interface.rs index 7947678f4..9b34e7513 100644 --- a/contracts/app/andromeda-app-contract/src/interface.rs +++ b/contracts/app/andromeda-app-contract/src/interface.rs @@ -1,6 +1,16 @@ use andromeda_app::app::{ExecuteMsg, InstantiateMsg, QueryMsg}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "app-contract"; contract_interface!(AppContract, CONTRACT_ID, "andromeda_app_contract.wasm"); + +type Chain = DaemonBase; + +impl AppContract { + pub fn get_address(&self, name: impl Into) -> String { + let query_msg = QueryMsg::GetAddress { name: name.into() }; + self.query(&query_msg).unwrap() + } +} diff --git a/contracts/finance/andromeda-validator-staking/Cargo.toml b/contracts/finance/andromeda-validator-staking/Cargo.toml index 240461e82..7688331a7 100644 --- a/contracts/finance/andromeda-validator-staking/Cargo.toml +++ b/contracts/finance/andromeda-validator-staking/Cargo.toml @@ -30,3 +30,4 @@ chrono = "0.3" cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true } cw-orch = { workspace = true } +cw-orch-daemon = "0.24.2" \ No newline at end of file diff --git a/contracts/finance/andromeda-validator-staking/src/interface.rs b/contracts/finance/andromeda-validator-staking/src/interface.rs index 8fb3c29fa..97d664768 100644 --- a/contracts/finance/andromeda-validator-staking/src/interface.rs +++ b/contracts/finance/andromeda-validator-staking/src/interface.rs @@ -1,5 +1,6 @@ use andromeda_finance::validator_staking::{ExecuteMsg, InstantiateMsg, QueryMsg}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "validator-staking"; @@ -8,3 +9,12 @@ contract_interface!( CONTRACT_ID, "andromeda_validator_staking.wasm" ); + +type Chain = DaemonBase; + +impl ValidatorStakingContract { + pub fn staked_tokens(&self, validator: Option) -> Option<::cosmwasm_std::FullDelegation> { + let query_msg = QueryMsg::StakedTokens { validator }; + self.query(&query_msg).unwrap() + } +} diff --git a/contracts/fungible-tokens/andromeda-cw20/Cargo.toml b/contracts/fungible-tokens/andromeda-cw20/Cargo.toml index ff4d08cca..354833d8c 100644 --- a/contracts/fungible-tokens/andromeda-cw20/Cargo.toml +++ b/contracts/fungible-tokens/andromeda-cw20/Cargo.toml @@ -30,6 +30,7 @@ andromeda-fungible-tokens = { workspace = true } cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true, optional = true } cw-orch = { workspace = true } +cw-orch-daemon = "0.24.2" [dev-dependencies] andromeda-app = { workspace = true } diff --git a/contracts/fungible-tokens/andromeda-cw20/src/interface.rs b/contracts/fungible-tokens/andromeda-cw20/src/interface.rs index 49633dcab..61399024c 100644 --- a/contracts/fungible-tokens/andromeda-cw20/src/interface.rs +++ b/contracts/fungible-tokens/andromeda-cw20/src/interface.rs @@ -1,6 +1,19 @@ use andromeda_fungible_tokens::cw20::{ExecuteMsg, InstantiateMsg, QueryMsg}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw20::BalanceResponse; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "cw20"; contract_interface!(CW20Contract, CONTRACT_ID, "andromeda_cw20.wasm"); + +type Chain = DaemonBase; + +impl CW20Contract { + pub fn balance(&self, address: impl Into) -> BalanceResponse { + let query_msg = QueryMsg::Balance { + address: address.into(), + }; + self.query(&query_msg).unwrap() + } +} diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/Cargo.toml b/contracts/non-fungible-tokens/andromeda-crowdfund/Cargo.toml index 7e98a51aa..e33bac69a 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/Cargo.toml +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/Cargo.toml @@ -30,6 +30,7 @@ andromeda-non-fungible-tokens = { workspace = true } cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true, optional = true } cw-orch = { workspace = true } +cw-orch-daemon = "0.24.2" [dev-dependencies] andromeda-app = { workspace = true } diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/src/interface.rs b/contracts/non-fungible-tokens/andromeda-crowdfund/src/interface.rs index 498bced4b..06df9f467 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/src/interface.rs +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/src/interface.rs @@ -1,6 +1,18 @@ -use andromeda_non_fungible_tokens::crowdfund::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use andromeda_non_fungible_tokens::crowdfund::{ + CampaignSummaryResponse, ExecuteMsg, InstantiateMsg, QueryMsg, +}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "crowdfund"; contract_interface!(CrowdfundContract, CONTRACT_ID, "andromeda_crowdfund.wasm"); + +type Chain = DaemonBase; + +impl CrowdfundContract { + pub fn campaign_summary(&self) -> CampaignSummaryResponse { + let query_msg = QueryMsg::CampaignSummary {}; + self.query(&query_msg).unwrap() + } +} diff --git a/contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml b/contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml index 3459072f5..f47166e3c 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml +++ b/contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml @@ -38,3 +38,4 @@ andromeda-std = { workspace = true, features = ["rates"] } cw-multi-test = { workspace = true, optional = true } cw-orch = { workspace = true } andromeda-testing = { workspace = true, optional = true } +cw-orch-daemon = "0.24.2" diff --git a/contracts/non-fungible-tokens/andromeda-cw721/src/interface.rs b/contracts/non-fungible-tokens/andromeda-cw721/src/interface.rs index 70d63c9e7..9f65cf2a5 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/src/interface.rs +++ b/contracts/non-fungible-tokens/andromeda-cw721/src/interface.rs @@ -1,6 +1,19 @@ use andromeda_non_fungible_tokens::cw721::{ExecuteMsg, InstantiateMsg, QueryMsg}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "cw721"; contract_interface!(CW721Contract, CONTRACT_ID, "andromeda_cw721.wasm"); + +type Chain = DaemonBase; + +impl CW721Contract { + pub fn owner_of(&self, token_id: impl Into) -> cw721::OwnerOfResponse { + let query_msg = QueryMsg::OwnerOf { + token_id: token_id.into(), + include_expired: None, + }; + self.query(&query_msg).unwrap() + } +} diff --git a/ibc-tests/src/lib.rs b/ibc-tests/src/lib.rs index 9671c6ff2..a4447cafb 100644 --- a/ibc-tests/src/lib.rs +++ b/ibc-tests/src/lib.rs @@ -1,2 +1,2 @@ pub mod constants; -pub mod interface_macro; \ No newline at end of file +pub mod interface_macro; diff --git a/ibc-tests/src/main.rs b/ibc-tests/src/main.rs index e61b4155b..1e93effd6 100644 --- a/ibc-tests/src/main.rs +++ b/ibc-tests/src/main.rs @@ -1,9 +1,10 @@ use std::cmp; -use andromeda_std::ado_base::MigrateMsg; +use andromeda_app_contract::AppContract; +use andromeda_std::os::adodb::ExecuteMsgFns as AdodbExecuteMsgFns; use andromeda_testing_e2e::mock::{mock_app, MockAndromeda}; +use andromeda_validator_staking::ValidatorStakingContract; use cosmwasm_std::{coin, to_json_binary, Uint128}; -use cw_orch::interface; use cw_orch::prelude::*; use cw_orch::{ environment::{ChainKind, NetworkInfo}, @@ -13,10 +14,9 @@ use cw_orch_daemon::{ queriers::{Staking, StakingBondStatus}, DaemonBase, Wallet, }; -use ibc_tests::{contract_interface, interfaces::app_interface::AppContract}; use andromeda_app::app::{self, AppComponent}; -use andromeda_finance::validator_staking; +use andromeda_finance::validator_staking::{self, ExecuteMsgFns as ValidatorStakingExecuteMsgFns}; const TESTNET_MNEMONIC: &str = "across left ignore gold echo argue track joy hire release captain enforce hotel wide flash hotel brisk joke midnight duck spare drop chronic stool"; pub const TERRA_NETWORK: NetworkInfo = NetworkInfo { @@ -67,25 +67,22 @@ fn main() { let app_contract = AppContract::new(daemon.clone()); app_contract.upload().unwrap(); - adodb_contract.clone().execute_publish( - app_contract.code_id().unwrap(), - "app-contract".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "app-contract".to_string(), + app_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); println!("app_contract->code_id: {:?}", app_contract.code_id()); println!("//==============================Base Test Environment Ready=================================//"); prepare_validator_staking(&daemon, &mock_andromeda, &app_contract); } -contract_interface!( - ValidatorStakingContract, - andromeda_validator_staking, - validator_staking, - "validator_staking_contract", - "validator_staking" -); - fn prepare_validator_staking( daemon: &DaemonBase, mock_andromeda: &MockAndromeda, @@ -102,11 +99,16 @@ fn prepare_validator_staking( adodb_contract, .. } = mock_andromeda; - adodb_contract.clone().execute_publish( - validator_staking_contract.code_id().unwrap(), - "validator-staking".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "validator-staking".to_string(), + validator_staking_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); println!("//================================Validator Staking Prepared-=================================//"); println!( @@ -150,14 +152,7 @@ fn prepare_validator_staking( app_contract.instantiate(&app_init_msg, None, None).unwrap(); - let get_addr_message = app::QueryMsg::GetAddress { - name: validator_staking_component.name, - }; - - let validator_staking_addr: String = daemon - .wasm_querier() - .smart_query(app_contract.addr_str().unwrap(), &get_addr_message) - .unwrap(); + let validator_staking_addr = app_contract.get_address(validator_staking_component.name); validator_staking_contract.set_address(&Addr::unchecked(validator_staking_addr)); @@ -176,16 +171,17 @@ fn prepare_validator_staking( println!("//===============================Processing Stake For testing=================================//"); validators.into_iter().for_each(|validator| { - let stake_msg = validator_staking::ExecuteMsg::Stake { - validator: Some(Addr::unchecked(validator.address.to_string())), - }; let balance = daemon .balance(daemon.sender_addr(), Some(denom.to_string())) .unwrap(); let amount_to_send = cmp::min(balance[0].amount, Uint128::new(10000000000)); validator_staking_contract - .execute(&stake_msg, Some(&[coin(amount_to_send.u128(), denom)])) + .stake( + Some(Addr::unchecked(validator.address.to_string())), + &[coin(amount_to_send.u128(), denom)], + ) .unwrap(); + println!( "validator: {:?}, delegator: {:?}", validator.address, diff --git a/ibc-tests/tests/crowdfund.rs b/ibc-tests/tests/crowdfund.rs index 98932641b..aab75f930 100644 --- a/ibc-tests/tests/crowdfund.rs +++ b/ibc-tests/tests/crowdfund.rs @@ -1,17 +1,20 @@ use std::str::FromStr; use andromeda_app::app::AppComponent; +use andromeda_app_contract::AppContract; use andromeda_finance::splitter::{self, AddressPercent}; -use andromeda_fungible_tokens::cw20 as andr_cw20; +use andromeda_fungible_tokens::cw20::{self as andr_cw20, ExecuteMsgFns as Cw20ExecuteMsgFns}; use andromeda_non_fungible_tokens::{ crowdfund::{ - self, CampaignConfig, CampaignStage, PresaleTierOrder, SimpleTierOrder, TierMetaData, + self, CampaignConfig, CampaignStage, Cw20HookMsg, ExecuteMsgFns as CrowdfundExecuteMsgFns, + PresaleTierOrder, SimpleTierOrder, Tier, TierMetaData, }, cw721::{self, TokenExtension}, }; use andromeda_std::{ amp::{AndrAddr, Recipient}, - common::{denom::Asset, Milliseconds}, + common::{denom::Asset, expiration::Expiry, Milliseconds}, + os::adodb::ExecuteMsgFns as AdodbExecuteMsgFns, }; use andromeda_testing_e2e::{ faucet::fund, @@ -21,26 +24,25 @@ use cosmwasm_std::{coin, to_json_binary, Decimal, Uint128, Uint64}; use cw20::{Cw20Coin, MinterResponse}; use cw_orch::prelude::*; use cw_orch_daemon::{DaemonBase, TxSender, Wallet}; -use ibc_tests::{ - constants::{ - LOCAL_TERRA, LOCAL_WASM, PURCHASER_MNEMONIC_1, RECIPIENT_MNEMONIC_1, RECIPIENT_MNEMONIC_2, - USER_MNEMONIC, - }, - interfaces::{ - app_interface, - crowdfund_interface::{self, purchase_cw20_msg, CrowdfundContract}, - cw20_interface::{self, Cw20Contract}, - cw721_interface::{self, Cw721Contract}, - splitter_interface::{self, SplitterContract}, - }, +use ibc_tests::constants::{ + LOCAL_TERRA, LOCAL_WASM, PURCHASER_MNEMONIC_1, RECIPIENT_MNEMONIC_1, RECIPIENT_MNEMONIC_2, + USER_MNEMONIC, }; + +use andromeda_crowdfund::CrowdfundContract; +use andromeda_cw20::CW20Contract; +use andromeda_cw721::CW721Contract; +use andromeda_splitter::SplitterContract; + +use andromeda_app::app; + use rstest::{fixture, rstest}; struct TestCase { daemon: DaemonBase, crowdfund_contract: CrowdfundContract>, - cw20_contract: Cw20Contract>, - cw721_contract: Cw721Contract>, + cw20_contract: CW20Contract>, + cw721_contract: CW721Contract>, splitter_contract: SplitterContract>, presale: Vec, } @@ -54,11 +56,77 @@ fn setup( let daemon = mock_app(chain_info.clone(), USER_MNEMONIC); let mock_andromeda = MockAndromeda::new(&daemon); - let app_contract = app_interface::prepare(&daemon, &mock_andromeda); - let cw20_contract = cw20_interface::prepare(&daemon, &mock_andromeda); - let cw721_contract = cw721_interface::prepare(&daemon, &mock_andromeda); - let crowdfund_contract = crowdfund_interface::prepare(&daemon, &mock_andromeda); - let splitter_contract = splitter_interface::prepare(&daemon, &mock_andromeda); + // Preparing contracts + let app_contract = AppContract::new(daemon.clone()); + app_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "app-contract".to_string(), + app_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + + let cw20_contract = CW20Contract::new(daemon.clone()); + cw20_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "cw20".to_string(), + cw20_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + + let cw721_contract = CW721Contract::new(daemon.clone()); + cw721_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "cw721".to_string(), + cw721_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + + let crowdfund_contract = CrowdfundContract::new(daemon.clone()); + crowdfund_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "crowdfund".to_string(), + crowdfund_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + + let splitter_contract = SplitterContract::new(daemon.clone()); + splitter_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "splitter".to_string(), + splitter_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + // Prepare App Components let recipient_1_daemon = daemon .rebuild() @@ -188,18 +256,31 @@ fn setup( ); app_components.push(crowdfund_component.clone()); - app_contract.init(&mock_andromeda, "Crowdfund App", app_components, None); - let crowdfund_addr = app_contract.query_address_by_component_name(crowdfund_component.name); + app_contract + .instantiate( + &app::InstantiateMsg { + app_components, + name: "Crowdfund App".to_string(), + chain_info: None, + kernel_address: kernel_address.clone(), + owner: None, + }, + None, + None, + ) + .unwrap(); + + let crowdfund_addr = app_contract.get_address(crowdfund_component.name); crowdfund_contract.set_address(&Addr::unchecked(crowdfund_addr)); - let cw721_addr = app_contract.query_address_by_component_name(cw721_component.name); + let cw721_addr = app_contract.get_address(cw721_component.name); cw721_contract.set_address(&Addr::unchecked(cw721_addr)); - let splitter_addr = app_contract.query_address_by_component_name(splitter_component.name); + let splitter_addr = app_contract.get_address(splitter_component.name); splitter_contract.set_address(&Addr::unchecked(splitter_addr)); if !use_native_token { - let cw20_addr = app_contract.query_address_by_component_name(cw20_component.unwrap().name); + let cw20_addr = app_contract.get_address(cw20_component.unwrap().name); cw20_contract.set_address(&Addr::unchecked(cw20_addr)); } @@ -209,20 +290,25 @@ fn setup( ..Default::default() }, }; - crowdfund_contract.execute_add_tier( - "Tier 1".to_string(), - Uint64::one(), - Uint128::new(10000), - None, - meta_data.clone(), - ); - crowdfund_contract.execute_add_tier( - "Tier 2".to_string(), - Uint64::new(2u64), - Uint128::new(20000), - Some(Uint128::new(100)), - meta_data, - ); + crowdfund_contract + .add_tier(Tier { + label: "Tier 1".to_string(), + level: Uint64::one(), + price: Uint128::new(10000), + limit: None, + metadata: meta_data.clone(), + }) + .unwrap(); + + crowdfund_contract + .add_tier(Tier { + label: "Tier 2".to_string(), + level: Uint64::new(2u64), + price: Uint128::new(20000), + limit: Some(Uint128::new(100)), + metadata: meta_data, + }) + .unwrap(); let presale = vec![PresaleTierOrder { level: Uint64::one(), @@ -277,10 +363,13 @@ fn test_successful_crowdfund_app_native(#[with(true, LOCAL_WASM)] setup: TestCas let start_time = None; let end_time = Milliseconds::from_nanos(daemon.block_info().unwrap().time.plus_days(1).nanos()); + let end_time = Expiry::AtTime(end_time); - crowdfund_contract.execute_start_campaign(start_time, end_time, Some(presale)); + crowdfund_contract + .start_campaign(end_time, Some(presale), start_time) + .unwrap(); - let summary = crowdfund_contract.query_campaign_summary(); + let summary = crowdfund_contract.campaign_summary(); assert_eq!(summary.current_capital, 0); assert_eq!(summary.current_stage, CampaignStage::ONGOING.to_string()); @@ -302,12 +391,12 @@ fn test_successful_crowdfund_app_native(#[with(true, LOCAL_WASM)] setup: TestCas .unwrap(); crowdfund_contract.set_sender(purchaser_1_daemon.sender()); let funds = vec![coin(500000, LOCAL_WASM.gas_denom)]; - crowdfund_contract.execute_purchase(orders, Some(&funds)); + crowdfund_contract.purchase_tiers(orders, &funds).unwrap(); crowdfund_contract.set_sender(daemon.sender()); - crowdfund_contract.execute_end_campaign(); + crowdfund_contract.end_campaign().unwrap(); - let summary = crowdfund_contract.query_campaign_summary(); + let summary = crowdfund_contract.campaign_summary(); assert_eq!(summary.current_capital, 10 * 10000 + 20000 * 10); assert_eq!(summary.current_stage, CampaignStage::SUCCESS.to_string()); @@ -333,12 +422,12 @@ fn test_successful_crowdfund_app_native(#[with(true, LOCAL_WASM)] setup: TestCas assert_eq!(recipient_2_change.u128(), summary.current_capital * 4 / 5); crowdfund_contract.set_sender(purchaser_1_daemon.sender()); - crowdfund_contract.execute_claim(); + crowdfund_contract.claim().unwrap(); - let owner_resp = cw721_contract.query_owner_of("0".to_string()).owner; + let owner_resp = cw721_contract.owner_of("0".to_string()).owner; assert_eq!(owner_resp, purchaser_1_daemon.sender_addr().into_string()); - let owner_resp = cw721_contract.query_owner_of("29".to_string()).owner; + let owner_resp = cw721_contract.owner_of("29".to_string()).owner; assert_eq!(owner_resp, purchaser_1_daemon.sender_addr().into_string()); } @@ -356,15 +445,18 @@ fn test_successful_crowdfund_app_cw20(#[with(false)] setup: TestCase) { let start_time = None; let end_time = Milliseconds::from_nanos(daemon.block_info().unwrap().time.plus_days(1).nanos()); + let end_time = Expiry::AtTime(end_time); - crowdfund_contract.execute_start_campaign(start_time, end_time, Some(presale)); + crowdfund_contract + .start_campaign(end_time, Some(presale), start_time) + .unwrap(); - let summary = crowdfund_contract.query_campaign_summary(); + let summary = crowdfund_contract.campaign_summary(); assert_eq!(summary.current_capital, 0); assert_eq!(summary.current_stage, CampaignStage::ONGOING.to_string()); let recipient_balance = cw20_contract - .query_balance(splitter_contract.addr_str().unwrap()) + .balance(splitter_contract.addr_str().unwrap()) .balance; let orders = vec![ @@ -378,7 +470,7 @@ fn test_successful_crowdfund_app_cw20(#[with(false)] setup: TestCase) { }, ]; - let hook_msg = purchase_cw20_msg(orders); + let hook_msg = to_json_binary(&Cw20HookMsg::PurchaseTiers { orders }).unwrap(); let purchaser_1_daemon = daemon .rebuild() @@ -387,44 +479,46 @@ fn test_successful_crowdfund_app_cw20(#[with(false)] setup: TestCase) { .unwrap(); let purchaser_1_balance = cw20_contract - .query_balance(purchaser_1_daemon.sender_addr()) + .balance(purchaser_1_daemon.sender_addr()) .balance; cw20_contract.set_sender(purchaser_1_daemon.sender()); - cw20_contract.execute_send( - crowdfund_contract.addr_str().unwrap(), - Uint128::new(500000), - &hook_msg, - ); + cw20_contract + .send( + Uint128::new(500000), + AndrAddr::from_string(crowdfund_contract.addr_str().unwrap()), + hook_msg, + ) + .unwrap(); cw20_contract.set_sender(daemon.sender()); let purchaser_1_change = purchaser_1_balance - cw20_contract - .query_balance(purchaser_1_daemon.sender_addr()) + .balance(purchaser_1_daemon.sender_addr()) .balance; assert_eq!(purchaser_1_change, Uint128::new(10 * 10000 + 20000 * 10)); - crowdfund_contract.execute_end_campaign(); + crowdfund_contract.end_campaign().unwrap(); - let summary = crowdfund_contract.query_campaign_summary(); + let summary = crowdfund_contract.campaign_summary(); assert_eq!(summary.current_capital, 10 * 10000 + 20000 * 10); assert_eq!(summary.current_stage, CampaignStage::SUCCESS.to_string()); // Splitter is only working for native token, not for cw20 token let recipient_change = cw20_contract - .query_balance(splitter_contract.addr_str().unwrap()) + .balance(splitter_contract.addr_str().unwrap()) .balance - recipient_balance; assert_eq!(recipient_change.u128(), summary.current_capital); crowdfund_contract.set_sender(purchaser_1_daemon.sender()); - crowdfund_contract.execute_claim(); + crowdfund_contract.claim().unwrap(); - let owner_resp = cw721_contract.query_owner_of("0".to_string()).owner; + let owner_resp = cw721_contract.owner_of("0".to_string()).owner; assert_eq!(owner_resp, purchaser_1_daemon.sender_addr().into_string()); - let owner_resp = cw721_contract.query_owner_of("29".to_string()).owner; + let owner_resp = cw721_contract.owner_of("29".to_string()).owner; assert_eq!(owner_resp, purchaser_1_daemon.sender_addr().into_string()); } diff --git a/ibc-tests/tests/validator_staking.rs b/ibc-tests/tests/validator_staking.rs index b8510d035..42c7cd0e2 100644 --- a/ibc-tests/tests/validator_staking.rs +++ b/ibc-tests/tests/validator_staking.rs @@ -1,44 +1,14 @@ -use andromeda_std::ado_base::MigrateMsg; +use andromeda_finance::validator_staking::ExecuteMsgFns; +use andromeda_validator_staking::ValidatorStakingContract; use cosmwasm_std::Uint128; -use cw_orch::environment::ChainKind; -use cw_orch::environment::NetworkInfo; -use cw_orch::interface; use cw_orch::prelude::*; use cw_orch_daemon::queriers::Staking; use cw_orch_daemon::queriers::StakingBondStatus; use cw_orch_daemon::Daemon; -use ibc_tests::contract_interface; -// import messages -use andromeda_finance::validator_staking; +use ibc_tests::constants::LOCAL_TERRA; const TESTNET_MNEMONIC: &str = "across left ignore gold echo argue track joy hire release captain enforce hotel wide flash hotel brisk joke midnight duck spare drop chronic stool"; -// include ados be tested -contract_interface!( - ValidatorStakingContract, - andromeda_validator_staking, - validator_staking, - "validator_staking_contract", - "validator_staking" -); - -pub const TERRA_NETWORK: NetworkInfo = NetworkInfo { - chain_name: "terra", - pub_address_prefix: "terra", - coin_type: 330u32, -}; - -pub const LOCAL_TERRA: ChainInfo = ChainInfo { - kind: ChainKind::Local, - chain_id: "localterraa-1", - gas_denom: "uluna", - gas_price: 0.15, - grpc_urls: &["http://localhost:20331"], - network_info: TERRA_NETWORK, - lcd_url: None, - fcd_url: None, -}; - #[test] #[ignore] fn test_validator_staking() { @@ -72,37 +42,27 @@ fn test_validator_staking() { let default_validator = &validators[0]; - let staking_query_msg = validator_staking::QueryMsg::StakedTokens { - validator: Some(Addr::unchecked(default_validator.address.to_string())), - }; let _rewards_response: Option = validator_staking_contract - .query(&staking_query_msg) - .unwrap(); + .staked_tokens(Some(Addr::unchecked(default_validator.address.to_string()))); - let claim_msg = validator_staking::ExecuteMsg::Claim { - validator: Some(Addr::unchecked(default_validator.address.to_string())), - restake: None, - }; validator_staking_contract - .execute(&claim_msg, None) + .claim( + None, + Some(Addr::unchecked(default_validator.address.to_string())), + ) .unwrap(); - let unstake_msg = validator_staking::ExecuteMsg::Unstake { - validator: Some(Addr::unchecked(default_validator.address.to_string())), - amount: None, - }; validator_staking_contract - .execute(&unstake_msg, None) + .unstake( + None, + Some(Addr::unchecked(default_validator.address.to_string())), + ) .unwrap(); daemon.wait_seconds(61).unwrap(); - let withdraw_msg = validator_staking::ExecuteMsg::WithdrawFunds { - denom: Some(denom.to_string()), - recipient: None, - }; validator_staking_contract - .execute(&withdraw_msg, None) + .withdraw_funds(Some(denom.to_string()), None) .unwrap(); let contract_balance = daemon @@ -166,30 +126,24 @@ fn test_kicked_validator() { .amount; assert_eq!(contract_balance, Uint128::zero()); - let claim_msg = validator_staking::ExecuteMsg::Claim { - validator: Some(Addr::unchecked(kicked_validator.address.to_string())), - restake: None, - }; validator_staking_contract - .execute(&claim_msg, None) + .claim( + None, + Some(Addr::unchecked(kicked_validator.address.to_string())), + ) .unwrap(); - let unstake_msg = validator_staking::ExecuteMsg::Unstake { - validator: Some(Addr::unchecked(kicked_validator.address.to_string())), - amount: None, - }; validator_staking_contract - .execute(&unstake_msg, None) + .unstake( + None, + Some(Addr::unchecked(kicked_validator.address.to_string())), + ) .unwrap(); daemon.wait_seconds(61).unwrap(); - let withdraw_msg = validator_staking::ExecuteMsg::WithdrawFunds { - denom: Some(denom.to_string()), - recipient: None, - }; validator_staking_contract - .execute(&withdraw_msg, None) + .withdraw_funds(Some(denom.to_string()), None) .unwrap(); let contract_balance = daemon diff --git a/packages/andromeda-app/Cargo.toml b/packages/andromeda-app/Cargo.toml index bd45cc835..d00c01457 100644 --- a/packages/andromeda-app/Cargo.toml +++ b/packages/andromeda-app/Cargo.toml @@ -18,6 +18,7 @@ cosmwasm-std = { workspace = true, features = ["cosmwasm_1_2"] } cosmwasm-schema = { workspace = true } serde = { workspace = true } andromeda-std = { workspace = true } +cw-orch = { workspace = true } [dev-dependencies] cw-multi-test = { version = "1.0.0" } diff --git a/packages/andromeda-finance/Cargo.toml b/packages/andromeda-finance/Cargo.toml index 43757aa94..68f5d7afc 100644 --- a/packages/andromeda-finance/Cargo.toml +++ b/packages/andromeda-finance/Cargo.toml @@ -18,6 +18,7 @@ cosmwasm-std = { workspace = true, features = ["staking"] } cosmwasm-schema = { workspace = true } serde = { version = "1.0.215", default-features = false, features = ["derive"] } cw-utils = { workspace = true } +cw-orch = { workspace = true } cw3 = { workspace = true } cw4 = { workspace = true } cw721 = { workspace = true } diff --git a/packages/andromeda-finance/src/validator_staking.rs b/packages/andromeda-finance/src/validator_staking.rs index 1c1a0e4be..735b629d1 100644 --- a/packages/andromeda-finance/src/validator_staking.rs +++ b/packages/andromeda-finance/src/validator_staking.rs @@ -14,7 +14,9 @@ pub struct InstantiateMsg { #[andr_exec] #[cw_serde] +#[derive(cw_orch::ExecuteFns)] pub enum ExecuteMsg { + #[cw_orch(payable)] Stake { validator: Option, }, diff --git a/packages/andromeda-fungible-tokens/Cargo.toml b/packages/andromeda-fungible-tokens/Cargo.toml index 51e023857..2ea37356f 100644 --- a/packages/andromeda-fungible-tokens/Cargo.toml +++ b/packages/andromeda-fungible-tokens/Cargo.toml @@ -22,5 +22,6 @@ cw20 = { workspace = true } cw20-base = { workspace = true } cw-asset = { workspace = true } cw-controllers = "=1.1.2" +cw-orch = { workspace = true } andromeda-std = { workspace = true } diff --git a/packages/andromeda-fungible-tokens/src/cw20.rs b/packages/andromeda-fungible-tokens/src/cw20.rs index 9422fa6f6..bc7397834 100644 --- a/packages/andromeda-fungible-tokens/src/cw20.rs +++ b/packages/andromeda-fungible-tokens/src/cw20.rs @@ -34,6 +34,7 @@ impl From for Cw20InstantiateMsg { #[andr_exec] #[cw_serde] +#[derive(cw_orch::ExecuteFns)] pub enum ExecuteMsg { /// Transfer is a base message to move tokens to another account without triggering actions Transfer { diff --git a/packages/andromeda-non-fungible-tokens/Cargo.toml b/packages/andromeda-non-fungible-tokens/Cargo.toml index 63f638cd9..31eb7062f 100644 --- a/packages/andromeda-non-fungible-tokens/Cargo.toml +++ b/packages/andromeda-non-fungible-tokens/Cargo.toml @@ -18,6 +18,7 @@ cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } serde = { version = "1.0.215", default-features = false, features = ["derive"] } cw-utils = { workspace = true } +cw-orch = { workspace = true } cw721 = { workspace = true } cw721-base = { workspace = true } cw20 = { workspace = true } diff --git a/packages/andromeda-non-fungible-tokens/src/crowdfund.rs b/packages/andromeda-non-fungible-tokens/src/crowdfund.rs index abd70ec9c..fac18cdfb 100644 --- a/packages/andromeda-non-fungible-tokens/src/crowdfund.rs +++ b/packages/andromeda-non-fungible-tokens/src/crowdfund.rs @@ -22,6 +22,7 @@ pub struct InstantiateMsg { #[andr_exec] #[cw_serde] +#[derive(cw_orch::ExecuteFns)] pub enum ExecuteMsg { /// Add a tier AddTier { tier: Tier }, @@ -36,6 +37,7 @@ pub enum ExecuteMsg { presale: Option>, }, /// Purchase tiers + #[cw_orch(payable)] PurchaseTiers { orders: Vec }, /// Purchase tiers with cw20 Receive(Cw20ReceiveMsg), diff --git a/packages/andromeda-testing-e2e/src/adodb.rs b/packages/andromeda-testing-e2e/src/adodb.rs deleted file mode 100644 index fba2b23bd..000000000 --- a/packages/andromeda-testing-e2e/src/adodb.rs +++ /dev/null @@ -1,39 +0,0 @@ -use crate::contract_interface; -use andromeda_std::ado_base::MigrateMsg; -use cw_orch::interface; -use cw_orch::prelude::*; - -use andromeda_std::os::adodb; -use cw_orch_daemon::DaemonBase; -use cw_orch_daemon::Wallet; - -contract_interface!( - AdodbContract, - andromeda_adodb, - adodb, - "adodb_contract", - "adodb" -); -impl AdodbContract> { - pub fn init(self, kernel_address: String) { - let msg = adodb::InstantiateMsg { - kernel_address, - owner: None, - }; - self.instantiate(&msg, None, None).unwrap(); - } - - pub fn execute_publish(self, code_id: u64, ado_type: String, version: String) { - self.execute( - &adodb::ExecuteMsg::Publish { - code_id, - ado_type, - action_fees: None, - version, - publisher: None, - }, - None, - ) - .unwrap(); - } -} diff --git a/packages/andromeda-testing-e2e/src/economics.rs b/packages/andromeda-testing-e2e/src/economics.rs deleted file mode 100644 index 58f45001f..000000000 --- a/packages/andromeda-testing-e2e/src/economics.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::contract_interface; -use andromeda_std::ado_base::MigrateMsg; -use cw_orch::interface; -use cw_orch::prelude::*; - -use andromeda_std::os::economics; -use cw_orch_daemon::DaemonBase; -use cw_orch_daemon::Wallet; - -contract_interface!( - EconomicsContract, - andromeda_economics, - economics, - "economics_contract", - "economics" -); -impl EconomicsContract> { - pub fn init(self, kernel_address: String) { - let msg = economics::InstantiateMsg { - kernel_address, - owner: None, - }; - self.instantiate(&msg, None, None).unwrap(); - } -} diff --git a/packages/andromeda-testing-e2e/src/interface_macro.rs b/packages/andromeda-testing-e2e/src/interface_macro.rs deleted file mode 100644 index 462e40112..000000000 --- a/packages/andromeda-testing-e2e/src/interface_macro.rs +++ /dev/null @@ -1,26 +0,0 @@ -#[macro_export] -macro_rules! contract_interface { - ($contract_name:ident, $module_path:ident, $package_path:ident, $contract_id:expr, $wasm_path:expr) => { - #[interface($package_path::InstantiateMsg, $package_path::ExecuteMsg, $package_path::QueryMsg, MigrateMsg, id = $contract_id)] - pub struct $contract_name; - - impl Uploadable for $contract_name { - fn wrapper() -> Box> { - Box::new( - ContractWrapper::new_with_empty( - $module_path::contract::execute, - $module_path::contract::instantiate, - $module_path::contract::query, - ) - .with_migrate($module_path::contract::migrate), - ) - } - - fn wasm(_chain: &ChainInfoOwned) -> WasmPath { - artifacts_dir_from_workspace!() - .find_wasm_path($wasm_path) - .unwrap() - } - } - }; -} diff --git a/packages/andromeda-testing-e2e/src/kernel.rs b/packages/andromeda-testing-e2e/src/kernel.rs deleted file mode 100644 index ebf375eaa..000000000 --- a/packages/andromeda-testing-e2e/src/kernel.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::contract_interface; -use andromeda_std::ado_base::MigrateMsg; -use cw_orch::interface; -use cw_orch::prelude::*; - -use andromeda_std::os::kernel; -use cw_orch_daemon::DaemonBase; -use cw_orch_daemon::Wallet; - -contract_interface!( - KernelContract, - andromeda_kernel, - kernel, - "kernel_contract", - "kernel" -); - -impl KernelContract> { - pub fn init(self, chain_name: String) { - let msg = kernel::InstantiateMsg { - chain_name, - owner: None, - }; - self.instantiate(&msg, None, None).unwrap(); - } - - pub fn execute_store_key_address(self, key: String, value: String) { - self.execute(&kernel::ExecuteMsg::UpsertKeyAddress { key, value }, None) - .unwrap(); - } -} diff --git a/packages/andromeda-testing-e2e/src/lib.rs b/packages/andromeda-testing-e2e/src/lib.rs index e96f910f9..fff67acab 100644 --- a/packages/andromeda-testing-e2e/src/lib.rs +++ b/packages/andromeda-testing-e2e/src/lib.rs @@ -1,20 +1,5 @@ #[cfg(not(target_arch = "wasm32"))] pub mod faucet; -#[cfg(not(target_arch = "wasm32"))] -pub mod interface_macro; - #[cfg(not(target_arch = "wasm32"))] pub mod mock; - -#[cfg(not(target_arch = "wasm32"))] -pub mod kernel; - -#[cfg(not(target_arch = "wasm32"))] -pub mod adodb; - -#[cfg(not(target_arch = "wasm32"))] -pub mod vfs; - -#[cfg(not(target_arch = "wasm32"))] -pub mod economics; diff --git a/packages/andromeda-testing-e2e/src/mock.rs b/packages/andromeda-testing-e2e/src/mock.rs index 1d6d68b9b..ae99de768 100644 --- a/packages/andromeda-testing-e2e/src/mock.rs +++ b/packages/andromeda-testing-e2e/src/mock.rs @@ -1,10 +1,17 @@ +use andromeda_adodb::ADODBContract; +use andromeda_economics::EconomicsContract; +use andromeda_kernel::KernelContract; +use andromeda_std::os::{ + adodb::{self, ExecuteMsgFns}, + economics, + kernel::{self, ExecuteMsgFns as KernelExecuteMsgFns}, + vfs, +}; +use andromeda_vfs::VFSContract; use cw_orch::prelude::*; use cw_orch_daemon::{Daemon, DaemonBase, Wallet}; -use crate::{ - adodb::AdodbContract, economics::EconomicsContract, faucet::fund, kernel::KernelContract, - vfs::VfsContract, -}; +use crate::faucet::fund; pub fn mock_app(chain: ChainInfo, mnemonic: &str) -> DaemonBase { let daemon = Daemon::builder(chain.clone()) // set the network to use @@ -19,8 +26,8 @@ pub fn mock_app(chain: ChainInfo, mnemonic: &str) -> DaemonBase { pub struct MockAndromeda { pub kernel_contract: KernelContract>, - pub adodb_contract: AdodbContract>, - pub vfs_contract: VfsContract>, + pub adodb_contract: ADODBContract>, + pub vfs_contract: VFSContract>, pub economics_contract: EconomicsContract>, } @@ -31,56 +38,110 @@ impl MockAndromeda { // Upload and instantiate os ADOs let kernel_contract = KernelContract::new(daemon.clone()); kernel_contract.upload().unwrap(); - kernel_contract.clone().init(chain_name); + kernel_contract + .clone() + .instantiate( + &kernel::InstantiateMsg { + chain_name, + owner: None, + }, + None, + None, + ) + .unwrap(); - let adodb_contract = AdodbContract::new(daemon.clone()); + let adodb_contract = ADODBContract::new(daemon.clone()); adodb_contract.upload().unwrap(); adodb_contract .clone() - .init(kernel_contract.addr_str().unwrap()); + .instantiate( + &adodb::InstantiateMsg { + kernel_address: kernel_contract.addr_str().unwrap(), + owner: None, + }, + None, + None, + ) + .unwrap(); - let vfs_contract = VfsContract::new(daemon.clone()); + let vfs_contract = VFSContract::new(daemon.clone()); vfs_contract.upload().unwrap(); vfs_contract .clone() - .init(kernel_contract.addr_str().unwrap()); + .instantiate( + &vfs::InstantiateMsg { + kernel_address: kernel_contract.addr_str().unwrap(), + owner: None, + }, + None, + None, + ) + .unwrap(); let economics_contract = EconomicsContract::new(daemon.clone()); economics_contract.upload().unwrap(); economics_contract .clone() - .init(kernel_contract.addr_str().unwrap()); + .instantiate( + &economics::InstantiateMsg { + kernel_address: kernel_contract.addr_str().unwrap(), + owner: None, + }, + None, + None, + ) + .unwrap(); - // register code ids in ado db - adodb_contract.clone().execute_publish( - adodb_contract.code_id().unwrap(), - "adodb".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "adodb".to_string(), + adodb_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); - adodb_contract.clone().execute_publish( - vfs_contract.code_id().unwrap(), - "vfs".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "vfs".to_string(), + vfs_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); - adodb_contract.clone().execute_publish( - kernel_contract.code_id().unwrap(), - "kernel".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "kernel".to_string(), + kernel_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); // update kernel kernel_contract .clone() - .execute_store_key_address("adodb".to_string(), adodb_contract.addr_str().unwrap()); + .upsert_key_address("adodb".to_string(), adodb_contract.addr_str().unwrap()) + .unwrap(); + // .upsert_key_address("adodb".to_string(), adodb_contract.addr_str().unwrap()); + kernel_contract + .clone() + .upsert_key_address("vfs".to_string(), vfs_contract.addr_str().unwrap()) + .unwrap(); kernel_contract .clone() - .execute_store_key_address("vfs".to_string(), vfs_contract.addr_str().unwrap()); - kernel_contract.clone().execute_store_key_address( - "economics".to_string(), - economics_contract.addr_str().unwrap(), - ); + .upsert_key_address( + "economics".to_string(), + economics_contract.addr_str().unwrap(), + ) + .unwrap(); MockAndromeda { kernel_contract, diff --git a/packages/andromeda-testing-e2e/src/vfs.rs b/packages/andromeda-testing-e2e/src/vfs.rs deleted file mode 100644 index 6e29963fc..000000000 --- a/packages/andromeda-testing-e2e/src/vfs.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::contract_interface; -use andromeda_std::ado_base::MigrateMsg; -use cw_orch::interface; -use cw_orch::prelude::*; - -use andromeda_std::os::vfs; -use cw_orch_daemon::DaemonBase; -use cw_orch_daemon::Wallet; - -contract_interface!(VfsContract, andromeda_vfs, vfs, "vfs_contract", "vfs"); -impl VfsContract> { - pub fn init(self, kernel_address: String) { - let msg = vfs::InstantiateMsg { - kernel_address, - owner: None, - }; - self.instantiate(&msg, None, None).unwrap(); - } -}