Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sylvia #105

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mesh-converter = { path = "./contracts/consumer/converter" }
mesh-simple-price-feed = { path = "./contracts/consumer/simple-price-feed" }
mesh-virtual-staking = { path = "./contracts/consumer/virtual-staking" }

sylvia = "0.5.0"
sylvia = "0.6.0"
cosmwasm-schema = "1.2"
cosmwasm-std = { version = "1.2", features = ["ibc3", "cosmwasm_1_2"] }
cosmwasm-storage = "1.2"
Expand Down
11 changes: 6 additions & 5 deletions contracts/consumer/converter/src/multitest.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod virtual_staking_mock;

use cosmwasm_std::{coin, Addr, Decimal, Uint128};

use cw_multi_test::App as MtApp;
use sylvia::multitest::App;

use crate::contract;
Expand All @@ -16,12 +16,13 @@ struct SetupArgs<'a> {
}

struct SetupResponse<'a> {
price_feed: mesh_simple_price_feed::contract::multitest_utils::SimplePriceFeedContractProxy<'a>,
converter: contract::multitest_utils::ConverterContractProxy<'a>,
virtual_staking: virtual_staking_mock::multitest_utils::VirtualStakingMockProxy<'a>,
price_feed:
mesh_simple_price_feed::contract::multitest_utils::SimplePriceFeedContractProxy<'a, MtApp>,
converter: contract::multitest_utils::ConverterContractProxy<'a, MtApp>,
virtual_staking: virtual_staking_mock::multitest_utils::VirtualStakingMockProxy<'a, MtApp>,
}

fn setup<'a>(app: &'a App, args: SetupArgs<'a>) -> SetupResponse<'a> {
fn setup<'a>(app: &'a App<MtApp>, args: SetupArgs<'a>) -> SetupResponse<'a> {
let SetupArgs {
owner,
admin,
Expand Down
11 changes: 8 additions & 3 deletions contracts/provider/external-staking/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ const LOCAL_SLASHING_PERCENTAGE: u64 = 5;
//
// Returns vault and external staking proxies
fn setup<'app>(
app: &'app App,
app: &'app App<MtApp>,
owner: &str,
unbond_period: u64,
) -> AnyResult<(VaultContractProxy<'app>, ExternalStakingContractProxy<'app>)> {
) -> AnyResult<(
VaultContractProxy<'app, MtApp>,
ExternalStakingContractProxy<'app, MtApp>,
)> {
let native_staking_proxy_code = NativeStakingProxyCodeId::store_code(app);
let native_staking_code = NativeStakingCodeId::store_code(app);
let vault_code = VaultCodeId::store_code(app);
Expand Down Expand Up @@ -303,7 +306,9 @@ fn staking() {
}

#[track_caller]
fn get_last_external_staking_pending_tx_id(contract: &ExternalStakingContractProxy) -> Option<u64> {
fn get_last_external_staking_pending_tx_id(
contract: &ExternalStakingContractProxy<MtApp>,
) -> Option<u64> {
let txs = contract.all_pending_txs_desc(None, None).unwrap().txs;
txs.first().map(Tx::id)
}
Expand Down
16 changes: 12 additions & 4 deletions contracts/provider/native-staking-proxy/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ impl NativeStakingProxyContract<'_> {
set_contract_version(ctx.deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

// Stake info.funds on validator
let res = self.stake(ctx, validator)?;
let exec_ctx = ExecCtx {
deps: ctx.deps,
env: ctx.env,
info: ctx.info,
};
let res = self.stake(exec_ctx, validator)?;

// Set owner as recipient of future withdrawals
let set_withdrawal = DistributionMsg::SetWithdrawAddress {
Expand Down Expand Up @@ -258,7 +263,12 @@ mod tests {
VALIDATOR.to_owned(),
)
.unwrap();
(ctx, contract)
let exec_ctx = ExecCtx {
deps: ctx.deps,
info: mock_info(OWNER, &[]),
env: ctx.env,
};
(exec_ctx, contract)
}

// Extra checks of instantiate returned messages and data
Expand Down Expand Up @@ -311,7 +321,6 @@ mod tests {
let (mut ctx, contract) = do_instantiate(deps.as_mut());

// The owner can vote
ctx.info = mock_info(OWNER, &[]);
let proposal_id = 1;
let vote = Yes;
let res = contract
Expand Down Expand Up @@ -352,7 +361,6 @@ mod tests {
let (mut ctx, contract) = do_instantiate(deps.as_mut());

// The owner can weighted vote
ctx.info = mock_info(OWNER, &[]);
let proposal_id = 2;
let vote = vec![WeightedVoteOption {
option: Yes,
Expand Down
6 changes: 3 additions & 3 deletions contracts/provider/native-staking-proxy/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::msg::ConfigResponse;
const OSMO: &str = "uosmo";
const UNBONDING_PERIOD: u64 = 17 * 24 * 60 * 60; // 7 days

fn init_app(owner: &str, validators: &[&str]) -> App {
fn init_app(owner: &str, validators: &[&str]) -> App<MtApp> {
// Fund the staking contract, and add validators to staking keeper
let block = mock_env().block;
let app = MtApp::new(|router, api, storage| {
Expand Down Expand Up @@ -52,11 +52,11 @@ fn init_app(owner: &str, validators: &[&str]) -> App {
}

fn setup<'app>(
app: &'app App,
app: &'app App<MtApp>,
owner: &str,
user: &str,
validator: &str,
) -> AnyResult<VaultContractProxy<'app>> {
) -> AnyResult<VaultContractProxy<'app, MtApp>> {
let vault_code = mesh_vault::contract::multitest_utils::CodeId::store_code(app);
let staking_code = mesh_native_staking::contract::multitest_utils::CodeId::store_code(app);
let staking_proxy_code = contract::multitest_utils::CodeId::store_code(app);
Expand Down
2 changes: 1 addition & 1 deletion contracts/provider/vault/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ impl VaultContract<'_> {
.users
.may_load(ctx.deps.storage, &ctx.info.sender)?
.unwrap_or_default();
let mut user = user_lock.write()?;
let user = user_lock.write()?;
user.max_lien = user.max_lien.max(lien.amount);
user.total_slashable += amount * lien.slashable;

Expand Down
2 changes: 1 addition & 1 deletion contracts/provider/vault/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ fn stake_local() {
}

#[track_caller]
fn get_last_pending_tx_id(vault: &VaultContractProxy) -> Option<u64> {
fn get_last_pending_tx_id(vault: &VaultContractProxy<MtApp>) -> Option<u64> {
let txs = vault.all_pending_txs_desc(None, None).unwrap().txs;
txs.first().map(Tx::id)
}
Expand Down
Loading