Skip to content

Commit

Permalink
feat(smart-contracts): add bidding balance & treasure chest contracts…
Browse files Browse the repository at this point in the history
… qieries
  • Loading branch information
nseguias committed Mar 11, 2024
1 parent 1593bcc commit a76333c
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 11 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

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

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cosmwasm-std = { version = "1.5.3", features = [
# Kuji is @ 1.2
"cosmwasm_1_2",
"iterator",
"stargate"
"stargate",
] }
cw-storage-plus = "1.2.0"
cosmwasm-storage = "1.5.2"
Expand All @@ -33,16 +33,19 @@ serde = { version = "1.0.196", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.56" }
treasurechest = { path = "packages/treasurechest" }
injective_auction = { path = "packages/injective_auction" }
cw-multi-test = { version="0.20.0" , features = ["cosmwasm_1_2"] }
cw-multi-test = { version = "0.20.0", features = ["cosmwasm_1_2"] }
pfc-whitelist = "1.4.0"
pfc-whitelist-derive = "1.4.0"
cw-item-set = "0.7.1"
cw-utils = "1.0.3"
osmosis-std-derive = "0.15.3"
prost = { version = "0.12.3", default-features = false, features = ["prost-derive"] }
prost = { version = "0.12.3", default-features = false, features = [
"prost-derive",
] }
prost-types = { version = "0.12.3", default-features = false }
protobuf = { version = "3.3.0", features = ["with-bytes"] }
getrandom = { version = "0.2", features = ["js"] }
cw-paginate-storage = "2.3.0"

[profile.release]
codegen-units = 1
Expand All @@ -54,4 +57,3 @@ opt-level = 3
overflow-checks = true
rpath = false
panic = 'abort'

9 changes: 7 additions & 2 deletions contracts/injective-auction-pool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[package]
name = "injective-auction-pool"
description = "Smart contract that allows for community members to pool together INJ to participate in burn auctions"
authors = ["Kerber0x <[email protected]>", "Nahem <[email protected]>", "PFC <[email protected]>"]
authors = [
"Kerber0x <[email protected]>",
"Nahem <[email protected]>",
"PFC <[email protected]>",
]
version = "0.1.0"

edition = { workspace = true }
Expand All @@ -22,7 +26,7 @@ backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true}
cosmwasm-std = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
cw2 = { workspace = true }
Expand All @@ -32,6 +36,7 @@ injective_auction = { workspace = true }
prost = { workspace = true }
cw-utils = { workspace = true }
treasurechest = { workspace = true }
cw-paginate-storage = { workspace = true }

[dev-dependencies]
cw-multi-test = { workspace = true }
5 changes: 5 additions & 0 deletions contracts/injective-auction-pool/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,10 @@ pub fn execute(
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Config {} => queries::query_config(deps),
QueryMsg::TreasureChestContracts {
start_after,
limit,
} => queries::query_treasure_chest_contracts(deps, start_after, limit),
QueryMsg::BiddingBalance {} => queries::query_bidding_balance(deps),
}
}
30 changes: 28 additions & 2 deletions contracts/injective-auction-pool/src/queries.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
use cosmwasm_std::{to_json_binary, Binary, Deps, StdResult};
use injective_auction::auction_pool::ConfigResponse;
use injective_auction::auction_pool::{
BiddingBalanceResponse, ConfigResponse, TreasureChestContractsResponse,
};

use crate::state::CONFIG;
use crate::state::{BIDDING_BALANCE, CONFIG, TREASURE_CHEST_CONTRACTS};

pub fn query_config(deps: Deps) -> StdResult<Binary> {
to_json_binary(&ConfigResponse {
config: CONFIG.load(deps.storage)?,
})
}
pub fn query_treasure_chest_contracts(
deps: Deps,
start_after: Option<u64>,
limit: Option<u32>,
) -> StdResult<Binary> {
let treasure_chest_contracts = cw_paginate_storage::paginate_map(
deps,
&TREASURE_CHEST_CONTRACTS,
start_after,
limit,
cosmwasm_std::Order::Ascending,
)?;

to_json_binary(&TreasureChestContractsResponse {
treasure_chest_contracts,
})
}

pub fn query_bidding_balance(deps: Deps) -> StdResult<Binary> {
let bidding_balance = BIDDING_BALANCE.load(deps.storage)?;
to_json_binary(&BiddingBalanceResponse {
bidding_balance,
})
}
4 changes: 1 addition & 3 deletions contracts/injective-auction-pool/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ pub struct Auction {

/// Stores the config of the contract
pub const CONFIG: Item<Config> = Item::new("config");
/// Stores the reward vault addresses. Key is the auction number.
pub const REWARD_VAULTS: Map<u128, Addr> = Map::new("reward_vaults");
/// Available balance to be used for bidding
pub const BIDDING_BALANCE: Item<Uint128> = Item::new("bidding_balance");
/// Stores the current auction details
pub const UNSETTLED_AUCTION: Item<Auction> = Item::new("current_auction");
pub const UNSETTLED_AUCTION: Item<Auction> = Item::new("usnsettled_auction");
/// Maps the auction round to the treasure chest contract address
pub const TREASURE_CHEST_CONTRACTS: Map<u64, Addr> = Map::new("treasure_chest_contracts");
17 changes: 17 additions & 0 deletions packages/injective_auction/src/auction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,30 @@ pub enum ExecuteMsg {
pub enum QueryMsg {
#[returns(ConfigResponse)]
Config {},
#[returns(TreasureChestContractsResponse)]
TreasureChestContracts {
start_after: Option<u64>,
limit: Option<u32>,
},
#[returns(BiddingBalanceResponse)]
BiddingBalance {},
}

#[cw_serde]
pub struct ConfigResponse {
pub config: Config,
}

#[cw_serde]
pub struct TreasureChestContractsResponse {
pub treasure_chest_contracts: Vec<(u64, Addr)>,
}

#[cw_serde]
pub struct BiddingBalanceResponse {
pub bidding_balance: Uint128,
}

#[cw_serde]
/// Config of the contract
pub struct Config {
Expand Down

0 comments on commit a76333c

Please sign in to comment.