diff --git a/Cargo.lock b/Cargo.lock index f67a81e..2147abf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -269,6 +269,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "cw-paginate-storage" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8693baa8dc275f86c5b4f6b86702994e859ac1657e19c5cbcb55d295592a5c04" +dependencies = [ + "cosmwasm-std", + "cosmwasm-storage", + "cw-storage-plus", + "serde", +] + [[package]] name = "cw-storage-plus" version = "1.2.0" @@ -492,6 +504,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-multi-test", + "cw-paginate-storage", "cw-storage-plus", "cw-utils", "cw2", diff --git a/Cargo.toml b/Cargo.toml index 2798488..52e7dba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -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 @@ -54,4 +57,3 @@ opt-level = 3 overflow-checks = true rpath = false panic = 'abort' - diff --git a/contracts/injective-auction-pool/Cargo.toml b/contracts/injective-auction-pool/Cargo.toml index 5d34ecd..03e01f9 100644 --- a/contracts/injective-auction-pool/Cargo.toml +++ b/contracts/injective-auction-pool/Cargo.toml @@ -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 ", "Nahem ", "PFC "] +authors = [ + "Kerber0x ", + "Nahem ", + "PFC ", +] version = "0.1.0" edition = { workspace = true } @@ -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 } @@ -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 } diff --git a/contracts/injective-auction-pool/src/contract.rs b/contracts/injective-auction-pool/src/contract.rs index 56ce2c8..8ecf7f3 100644 --- a/contracts/injective-auction-pool/src/contract.rs +++ b/contracts/injective-auction-pool/src/contract.rs @@ -132,5 +132,10 @@ pub fn execute( pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { 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), } } diff --git a/contracts/injective-auction-pool/src/queries.rs b/contracts/injective-auction-pool/src/queries.rs index 8dd7eaa..5d4e3da 100644 --- a/contracts/injective-auction-pool/src/queries.rs +++ b/contracts/injective-auction-pool/src/queries.rs @@ -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 { to_json_binary(&ConfigResponse { config: CONFIG.load(deps.storage)?, }) } +pub fn query_treasure_chest_contracts( + deps: Deps, + start_after: Option, + limit: Option, +) -> StdResult { + 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 { + let bidding_balance = BIDDING_BALANCE.load(deps.storage)?; + to_json_binary(&BiddingBalanceResponse { + bidding_balance, + }) +} diff --git a/contracts/injective-auction-pool/src/state.rs b/contracts/injective-auction-pool/src/state.rs index 5443dfd..6ba9af5 100644 --- a/contracts/injective-auction-pool/src/state.rs +++ b/contracts/injective-auction-pool/src/state.rs @@ -17,11 +17,9 @@ pub struct Auction { /// Stores the config of the contract pub const CONFIG: Item = Item::new("config"); -/// Stores the reward vault addresses. Key is the auction number. -pub const REWARD_VAULTS: Map = Map::new("reward_vaults"); /// Available balance to be used for bidding pub const BIDDING_BALANCE: Item = Item::new("bidding_balance"); /// Stores the current auction details -pub const UNSETTLED_AUCTION: Item = Item::new("current_auction"); +pub const UNSETTLED_AUCTION: Item = Item::new("usnsettled_auction"); /// Maps the auction round to the treasure chest contract address pub const TREASURE_CHEST_CONTRACTS: Map = Map::new("treasure_chest_contracts"); diff --git a/packages/injective_auction/src/auction_pool.rs b/packages/injective_auction/src/auction_pool.rs index 4e19b0f..b9b6cfc 100644 --- a/packages/injective_auction/src/auction_pool.rs +++ b/packages/injective_auction/src/auction_pool.rs @@ -63,6 +63,13 @@ pub enum ExecuteMsg { pub enum QueryMsg { #[returns(ConfigResponse)] Config {}, + #[returns(TreasureChestContractsResponse)] + TreasureChestContracts { + start_after: Option, + limit: Option, + }, + #[returns(BiddingBalanceResponse)] + BiddingBalance {}, } #[cw_serde] @@ -70,6 +77,16 @@ 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 {