From 16f022b870962c2388448dce262c0adf76293949 Mon Sep 17 00:00:00 2001 From: Kerber0x Date: Mon, 24 Jun 2024 14:08:53 +0100 Subject: [PATCH] chore: use ve3-shared 0.9.1 --- Cargo.lock | 19 ++- Cargo.toml | 2 +- .../alliance-hub/schema/alliance-hub.json | 111 ++++++++++++++---- .../raw/response_to_all_staked_balances.json | 37 ++++-- .../raw/response_to_staked_balance.json | 37 ++++-- .../response_to_total_staked_balances.json | 37 ++++-- contracts/alliance-hub/src/query.rs | 24 ++-- contracts/alliance-hub/src/tests/helpers.rs | 3 +- .../alliance-hub/src/tests/stake_unstake.rs | 13 +- .../src/alliance_protocol.rs | 10 +- 10 files changed, 223 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b2b462b..ad13ae8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -744,6 +744,18 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "osmosis-std-derive" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a455e262a6fdfd3914f3a4e11e6bc0ce491901cb9d507d7856d7ef6e129e90c6" +dependencies = [ + "itertools", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "paste" version = "1.0.12" @@ -1121,9 +1133,9 @@ checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "ve3-shared" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac896aa1baaacf667229dea7e4663533041b49e8cf6463f1ae6ff6c3b982a6a" +checksum = "09fbc0ec021c3a51b9be5f07cee2fad4343a54726ea078da4b09be006ca5ef81" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -1134,6 +1146,9 @@ dependencies = [ "cw20", "cw721 0.18.0", "cw721-base 0.18.0", + "osmosis-std-derive", + "prost", + "prost-types", "schemars", "semver", "serde", diff --git a/Cargo.toml b/Cargo.toml index 0c2a556..98d30ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,6 @@ thiserror = { version = "1.0.38" } cw2 = "1.1.2" cw20 ="1.1.2" semver = "1.0.22" -ve3-shared = "0.9.0" +ve3-shared = "0.9.1" alliance-protocol = { path = "./packages/alliance-protocol" } \ No newline at end of file diff --git a/contracts/alliance-hub/schema/alliance-hub.json b/contracts/alliance-hub/schema/alliance-hub.json index c3638fb..4569768 100644 --- a/contracts/alliance-hub/schema/alliance-hub.json +++ b/contracts/alliance-hub/schema/alliance-hub.json @@ -828,6 +828,33 @@ "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" }, + "AssetBase_for_Addr": { + "description": "Represents a fungible asset with a known amount\n\nEach asset instance contains two values: `info`, which specifies the asset's type (CW20 or native), and its `amount`, which specifies the asset's amount.", + "type": "object", + "required": [ + "amount", + "info" + ], + "properties": { + "amount": { + "description": "Specifies the asset's amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "info": { + "description": "Specifies the asset's type (CW20 or native)", + "allOf": [ + { + "$ref": "#/definitions/AssetInfoBase_for_Addr" + } + ] + } + }, + "additionalProperties": false + }, "AssetConfigRuntime": { "type": "object", "required": [ @@ -847,7 +874,7 @@ "minimum": 0.0 }, "stake_config": { - "$ref": "#/definitions/StakeConfig" + "$ref": "#/definitions/StakeConfig_for_Addr" }, "taken": { "$ref": "#/definitions/Uint128" @@ -891,7 +918,7 @@ "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", "type": "string" }, - "StakeConfig": { + "StakeConfig_for_Addr": { "oneOf": [ { "type": "string", @@ -961,16 +988,12 @@ "type": "object", "required": [ "asset", - "balance", "config", "shares" ], "properties": { "asset": { - "$ref": "#/definitions/AssetInfoBase_for_Addr" - }, - "balance": { - "$ref": "#/definitions/Uint128" + "$ref": "#/definitions/AssetBase_for_Addr" }, "config": { "$ref": "#/definitions/AssetConfigRuntime" @@ -1193,16 +1216,12 @@ "type": "object", "required": [ "asset", - "balance", "config", "shares" ], "properties": { "asset": { - "$ref": "#/definitions/AssetInfoBase_for_Addr" - }, - "balance": { - "$ref": "#/definitions/Uint128" + "$ref": "#/definitions/AssetBase_for_Addr" }, "config": { "$ref": "#/definitions/AssetConfigRuntime" @@ -1217,6 +1236,33 @@ "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" }, + "AssetBase_for_Addr": { + "description": "Represents a fungible asset with a known amount\n\nEach asset instance contains two values: `info`, which specifies the asset's type (CW20 or native), and its `amount`, which specifies the asset's amount.", + "type": "object", + "required": [ + "amount", + "info" + ], + "properties": { + "amount": { + "description": "Specifies the asset's amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "info": { + "description": "Specifies the asset's type (CW20 or native)", + "allOf": [ + { + "$ref": "#/definitions/AssetInfoBase_for_Addr" + } + ] + } + }, + "additionalProperties": false + }, "AssetConfigRuntime": { "type": "object", "required": [ @@ -1236,7 +1282,7 @@ "minimum": 0.0 }, "stake_config": { - "$ref": "#/definitions/StakeConfig" + "$ref": "#/definitions/StakeConfig_for_Addr" }, "taken": { "$ref": "#/definitions/Uint128" @@ -1280,7 +1326,7 @@ "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", "type": "string" }, - "StakeConfig": { + "StakeConfig_for_Addr": { "oneOf": [ { "type": "string", @@ -1364,6 +1410,33 @@ "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" }, + "AssetBase_for_Addr": { + "description": "Represents a fungible asset with a known amount\n\nEach asset instance contains two values: `info`, which specifies the asset's type (CW20 or native), and its `amount`, which specifies the asset's amount.", + "type": "object", + "required": [ + "amount", + "info" + ], + "properties": { + "amount": { + "description": "Specifies the asset's amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "info": { + "description": "Specifies the asset's type (CW20 or native)", + "allOf": [ + { + "$ref": "#/definitions/AssetInfoBase_for_Addr" + } + ] + } + }, + "additionalProperties": false + }, "AssetConfigRuntime": { "type": "object", "required": [ @@ -1383,7 +1456,7 @@ "minimum": 0.0 }, "stake_config": { - "$ref": "#/definitions/StakeConfig" + "$ref": "#/definitions/StakeConfig_for_Addr" }, "taken": { "$ref": "#/definitions/Uint128" @@ -1427,7 +1500,7 @@ "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", "type": "string" }, - "StakeConfig": { + "StakeConfig_for_Addr": { "oneOf": [ { "type": "string", @@ -1497,16 +1570,12 @@ "type": "object", "required": [ "asset", - "balance", "config", "shares" ], "properties": { "asset": { - "$ref": "#/definitions/AssetInfoBase_for_Addr" - }, - "balance": { - "$ref": "#/definitions/Uint128" + "$ref": "#/definitions/AssetBase_for_Addr" }, "config": { "$ref": "#/definitions/AssetConfigRuntime" diff --git a/contracts/alliance-hub/schema/raw/response_to_all_staked_balances.json b/contracts/alliance-hub/schema/raw/response_to_all_staked_balances.json index 98ba84c..bbe4a06 100644 --- a/contracts/alliance-hub/schema/raw/response_to_all_staked_balances.json +++ b/contracts/alliance-hub/schema/raw/response_to_all_staked_balances.json @@ -10,6 +10,33 @@ "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" }, + "AssetBase_for_Addr": { + "description": "Represents a fungible asset with a known amount\n\nEach asset instance contains two values: `info`, which specifies the asset's type (CW20 or native), and its `amount`, which specifies the asset's amount.", + "type": "object", + "required": [ + "amount", + "info" + ], + "properties": { + "amount": { + "description": "Specifies the asset's amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "info": { + "description": "Specifies the asset's type (CW20 or native)", + "allOf": [ + { + "$ref": "#/definitions/AssetInfoBase_for_Addr" + } + ] + } + }, + "additionalProperties": false + }, "AssetConfigRuntime": { "type": "object", "required": [ @@ -29,7 +56,7 @@ "minimum": 0.0 }, "stake_config": { - "$ref": "#/definitions/StakeConfig" + "$ref": "#/definitions/StakeConfig_for_Addr" }, "taken": { "$ref": "#/definitions/Uint128" @@ -73,7 +100,7 @@ "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", "type": "string" }, - "StakeConfig": { + "StakeConfig_for_Addr": { "oneOf": [ { "type": "string", @@ -143,16 +170,12 @@ "type": "object", "required": [ "asset", - "balance", "config", "shares" ], "properties": { "asset": { - "$ref": "#/definitions/AssetInfoBase_for_Addr" - }, - "balance": { - "$ref": "#/definitions/Uint128" + "$ref": "#/definitions/AssetBase_for_Addr" }, "config": { "$ref": "#/definitions/AssetConfigRuntime" diff --git a/contracts/alliance-hub/schema/raw/response_to_staked_balance.json b/contracts/alliance-hub/schema/raw/response_to_staked_balance.json index 58f18f7..6bdc5df 100644 --- a/contracts/alliance-hub/schema/raw/response_to_staked_balance.json +++ b/contracts/alliance-hub/schema/raw/response_to_staked_balance.json @@ -4,16 +4,12 @@ "type": "object", "required": [ "asset", - "balance", "config", "shares" ], "properties": { "asset": { - "$ref": "#/definitions/AssetInfoBase_for_Addr" - }, - "balance": { - "$ref": "#/definitions/Uint128" + "$ref": "#/definitions/AssetBase_for_Addr" }, "config": { "$ref": "#/definitions/AssetConfigRuntime" @@ -28,6 +24,33 @@ "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" }, + "AssetBase_for_Addr": { + "description": "Represents a fungible asset with a known amount\n\nEach asset instance contains two values: `info`, which specifies the asset's type (CW20 or native), and its `amount`, which specifies the asset's amount.", + "type": "object", + "required": [ + "amount", + "info" + ], + "properties": { + "amount": { + "description": "Specifies the asset's amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "info": { + "description": "Specifies the asset's type (CW20 or native)", + "allOf": [ + { + "$ref": "#/definitions/AssetInfoBase_for_Addr" + } + ] + } + }, + "additionalProperties": false + }, "AssetConfigRuntime": { "type": "object", "required": [ @@ -47,7 +70,7 @@ "minimum": 0.0 }, "stake_config": { - "$ref": "#/definitions/StakeConfig" + "$ref": "#/definitions/StakeConfig_for_Addr" }, "taken": { "$ref": "#/definitions/Uint128" @@ -91,7 +114,7 @@ "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", "type": "string" }, - "StakeConfig": { + "StakeConfig_for_Addr": { "oneOf": [ { "type": "string", diff --git a/contracts/alliance-hub/schema/raw/response_to_total_staked_balances.json b/contracts/alliance-hub/schema/raw/response_to_total_staked_balances.json index 98ba84c..bbe4a06 100644 --- a/contracts/alliance-hub/schema/raw/response_to_total_staked_balances.json +++ b/contracts/alliance-hub/schema/raw/response_to_total_staked_balances.json @@ -10,6 +10,33 @@ "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" }, + "AssetBase_for_Addr": { + "description": "Represents a fungible asset with a known amount\n\nEach asset instance contains two values: `info`, which specifies the asset's type (CW20 or native), and its `amount`, which specifies the asset's amount.", + "type": "object", + "required": [ + "amount", + "info" + ], + "properties": { + "amount": { + "description": "Specifies the asset's amount", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "info": { + "description": "Specifies the asset's type (CW20 or native)", + "allOf": [ + { + "$ref": "#/definitions/AssetInfoBase_for_Addr" + } + ] + } + }, + "additionalProperties": false + }, "AssetConfigRuntime": { "type": "object", "required": [ @@ -29,7 +56,7 @@ "minimum": 0.0 }, "stake_config": { - "$ref": "#/definitions/StakeConfig" + "$ref": "#/definitions/StakeConfig_for_Addr" }, "taken": { "$ref": "#/definitions/Uint128" @@ -73,7 +100,7 @@ "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", "type": "string" }, - "StakeConfig": { + "StakeConfig_for_Addr": { "oneOf": [ { "type": "string", @@ -143,16 +170,12 @@ "type": "object", "required": [ "asset", - "balance", "config", "shares" ], "properties": { "asset": { - "$ref": "#/definitions/AssetInfoBase_for_Addr" - }, - "balance": { - "$ref": "#/definitions/Uint128" + "$ref": "#/definitions/AssetBase_for_Addr" }, "config": { "$ref": "#/definitions/AssetConfigRuntime" diff --git a/contracts/alliance-hub/src/query.rs b/contracts/alliance-hub/src/query.rs index 004a84b..7a7d2b7 100644 --- a/contracts/alliance-hub/src/query.rs +++ b/contracts/alliance-hub/src/query.rs @@ -1,7 +1,7 @@ use crate::contract::compute_balance_amount; use alliance_protocol::alliance_protocol::{ AllPendingRewardsQuery, AllStakedBalancesQuery, AssetQuery, PendingRewardsRes, QueryMsg, - StakedBalanceRes, WhitelistedAssetsResponse, + WhitelistedAssetsResponse, }; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; @@ -10,7 +10,8 @@ use cw_asset::AssetInfo; use std::cmp::min; use std::collections::HashMap; use ve3_shared::constants::SECONDS_PER_YEAR; -use ve3_shared::msgs_asset_staking::AssetConfigRuntime; +use ve3_shared::extensions::asset_info_ext::AssetInfoExt; +use ve3_shared::msgs_asset_staking::{AssetConfigRuntime, StakedBalanceRes}; use crate::state::{ ASSET_CONFIG, ASSET_REWARD_DISTRIBUTION, ASSET_REWARD_RATE, CONFIG, SHARES, @@ -75,8 +76,11 @@ fn get_staked_balance(deps: Deps, env: Env, asset_query: AssetQuery) -> StdResul compute_take_amount(&env, balance, &mut config)?; to_json_binary(&StakedBalanceRes { - asset: asset_query.asset, - balance: compute_balance_amount(shares, user_shares, balance.checked_sub(config.taken)?), + asset: asset_query.asset.with_balance(compute_balance_amount( + shares, + user_shares, + balance.checked_sub(config.taken)?, + )), shares: user_shares, config, }) @@ -143,12 +147,11 @@ fn get_all_staked_balances( // Append the request res.push(StakedBalanceRes { - asset: asset_info, - balance: compute_balance_amount( + asset: asset_info.with_balance(compute_balance_amount( shares, user_shares, balance.checked_sub(config.taken)?, - ), + )), shares: user_shares, config, }) @@ -192,8 +195,11 @@ fn get_total_staked_balances(deps: Deps, env: Env) -> StdResult { compute_take_amount(&env, balance, &mut config)?; Ok(StakedBalanceRes { - asset, - balance: compute_balance_amount(shares, shares, balance.checked_sub(config.taken)?), + asset: asset.with_balance(compute_balance_amount( + shares, + shares, + balance.checked_sub(config.taken)?, + )), shares, config, }) diff --git a/contracts/alliance-hub/src/tests/helpers.rs b/contracts/alliance-hub/src/tests/helpers.rs index e4ec07a..dc52443 100644 --- a/contracts/alliance-hub/src/tests/helpers.rs +++ b/contracts/alliance-hub/src/tests/helpers.rs @@ -6,12 +6,13 @@ use cosmwasm_std::{ }; use cw20::Cw20ReceiveMsg; use cw_asset::{Asset, AssetInfo}; +use ve3_shared::msgs_asset_staking::StakedBalanceRes; use alliance_protocol::alliance_protocol::{ AllPendingRewardsQuery, AllianceDelegateMsg, AllianceDelegation, AllianceRedelegateMsg, AllianceRedelegation, AllianceUndelegateMsg, AssetDistribution, AssetInfoWithConfig, AssetQuery, ChainId, Config, Cw20HookMsg, ExecuteMsg, InstantiateMsg, PendingRewardsRes, - QueryMsg, StakedBalanceRes, + QueryMsg, }; use crate::contract::{execute, instantiate}; diff --git a/contracts/alliance-hub/src/tests/stake_unstake.rs b/contracts/alliance-hub/src/tests/stake_unstake.rs index 55df272..c1ad875 100644 --- a/contracts/alliance-hub/src/tests/stake_unstake.rs +++ b/contracts/alliance-hub/src/tests/stake_unstake.rs @@ -5,17 +5,20 @@ use crate::tests::helpers::{ query_all_staked_balances, setup_contract, stake, stake_cw20, unstake, unstake_cw20, whitelist_assets, }; -use alliance_protocol::alliance_protocol::{AssetInfoWithConfig, ExecuteMsg, StakedBalanceRes}; +use alliance_protocol::alliance_protocol::{AssetInfoWithConfig, ExecuteMsg}; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{ coin, to_json_binary, Addr, BankMsg, CosmosMsg, Decimal, Response, Uint128, WasmMsg, }; use cw_asset::{Asset, AssetInfo}; use std::collections::HashMap; -use ve3_shared::msgs_asset_staking::AssetConfigRuntime; +use ve3_shared::extensions::asset_info_ext::AssetInfoExt; +use ve3_shared::msgs_asset_staking::{AssetConfigRuntime, StakedBalanceRes}; mod cw20_support { use super::*; + use ve3_shared::extensions::asset_info_ext::AssetInfoExt; + use ve3_shared::msgs_asset_staking::StakedBalanceRes; #[test] fn test_stake_cw20() { @@ -92,8 +95,7 @@ mod cw20_support { assert_eq!( total_balances_res, vec![StakedBalanceRes { - asset: AssetInfo::Cw20(Addr::unchecked("asset1")), - balance: Uint128::new(200), + asset: AssetInfo::Cw20(Addr::unchecked("asset1")).with_balance(Uint128::new(200)), shares: Uint128::new(200), config: AssetConfigRuntime { last_taken_s: 1571797419u64, @@ -281,8 +283,7 @@ fn test_stake() { assert_eq!( total_balances_res, vec![StakedBalanceRes { - asset: AssetInfo::Native("asset1".to_string()), - balance: Uint128::new(200), + asset: AssetInfo::Native("asset1".to_string()).with_balance(Uint128::new(200)), shares: Uint128::new(200), config: AssetConfigRuntime { last_taken_s: 1571797419u64, diff --git a/packages/alliance-protocol/src/alliance_protocol.rs b/packages/alliance-protocol/src/alliance_protocol.rs index 5781d56..cfe310e 100644 --- a/packages/alliance-protocol/src/alliance_protocol.rs +++ b/packages/alliance-protocol/src/alliance_protocol.rs @@ -3,7 +3,7 @@ use cosmwasm_std::{Addr, Decimal, Timestamp, Uint128}; use cw20::Cw20ReceiveMsg; use cw_asset::{Asset, AssetInfo}; use std::collections::{HashMap, HashSet}; -use ve3_shared::msgs_asset_staking::AssetConfigRuntime; +use ve3_shared::msgs_asset_staking::StakedBalanceRes; #[cw_serde] pub struct Config { @@ -164,14 +164,6 @@ pub struct AllPendingRewardsQuery { #[cw_serde] pub struct MigrateMsg {} -#[cw_serde] -pub struct StakedBalanceRes { - pub asset: AssetInfo, - pub balance: Uint128, - pub shares: Uint128, - pub config: AssetConfigRuntime, -} - #[cw_serde] pub struct PendingRewardsRes { pub staked_asset: AssetInfo,