diff --git a/contracts/injective-auction-pool/src/contract.rs b/contracts/injective-auction-pool/src/contract.rs index bfbc91f..c8fe56e 100644 --- a/contracts/injective-auction-pool/src/contract.rs +++ b/contracts/injective-auction-pool/src/contract.rs @@ -31,7 +31,9 @@ pub fn instantiate( }, )?; - let current_auction_round = query_current_auction(deps.as_ref())?.auction_round; + let current_auction_round = query_current_auction(deps.as_ref())? + .auction_round + .ok_or(ContractError::CurrentAuctionQueryError)?; CURRENT_AUCTION_NUMBER.save(deps.storage, ¤t_auction_round)?; //todo mint lp for current auction diff --git a/contracts/injective-auction-pool/src/error.rs b/contracts/injective-auction-pool/src/error.rs index 666379d..a4f2b6f 100644 --- a/contracts/injective-auction-pool/src/error.rs +++ b/contracts/injective-auction-pool/src/error.rs @@ -1,4 +1,5 @@ use cosmwasm_std::StdError; +use cw_utils::PaymentError; use thiserror::Error; #[derive(Error, Debug)] @@ -6,6 +7,9 @@ pub enum ContractError { #[error("{0}")] Std(#[from] StdError), + #[error("{0}")] + PaymentError(#[from] PaymentError), + #[error("Unauthorized")] Unauthorized {}, @@ -22,4 +26,7 @@ pub enum ContractError { "The auction is locked since it's about to finish, therefore no withdrawals are allowed" )] PooledAuctionLocked, + + #[error("Couldn't parse the current auction query response")] + CurrentAuctionQueryError, } diff --git a/contracts/injective-auction-pool/src/executions.rs b/contracts/injective-auction-pool/src/executions.rs index cfd6e83..bf0bcb6 100644 --- a/contracts/injective-auction-pool/src/executions.rs +++ b/contracts/injective-auction-pool/src/executions.rs @@ -25,7 +25,9 @@ pub(crate) fn join_pool( let coin = info.funds[0].clone(); - let current_auction_round = query_current_auction(deps.as_ref())?.auction_round; + let current_auction_round = query_current_auction(deps.as_ref())? + .auction_round + .ok_or(ContractError::CurrentAuctionQueryError)?; ensure!( current_auction_round == auction_round, @@ -81,7 +83,10 @@ pub(crate) fn exit_pool( let lp_denom = format!( "factory/{}/{}", - env.contract.address, current_auction_round_response.auction_round + env.contract.address, + current_auction_round_response + .auction_round + .ok_or(ContractError::CurrentAuctionQueryError)? ); cw_utils::must_pay(&info, lp_denom.as_str())?; @@ -89,6 +94,7 @@ pub(crate) fn exit_pool( DAY_IN_SECONDS > current_auction_round_response .auction_closing_time + .ok_or(ContractError::CurrentAuctionQueryError)? .saturating_sub(env.block.time.seconds()), ContractError::PooledAuctionLocked ); diff --git a/packages/injective_auction/src/auction.rs b/packages/injective_auction/src/auction.rs index 44a360e..a8e6926 100644 --- a/packages/injective_auction/src/auction.rs +++ b/packages/injective_auction/src/auction.rs @@ -49,14 +49,14 @@ pub struct QueryCurrentAuctionBasketRequest {} )] #[proto_message(type_url = "/injective.auction.v1beta1.QueryCurrentAuctionBasketResponse")] pub struct QueryCurrentAuctionBasketResponse { - // #[prost(message, repeated, tag = "1")] + #[prost(message, repeated, tag = "1")] pub amount: Vec, - // #[prost(uint64, optional, tag = "2")] - pub auction_round: u64, - // #[prost(int64, optional, tag = "3")] - pub auction_closing_time: u64, - // #[prost(string, optional, tag = "4")] - pub highest_bidder: String, - // #[prost(string, optional, tag = "5")] - pub highest_bid_amount: String, + #[prost(uint64, optional, tag = "2")] + pub auction_round: ::core::option::Option, + #[prost(uint64, optional, tag = "3")] + pub auction_closing_time: ::core::option::Option, + #[prost(string, optional, tag = "4")] + pub highest_bidder: ::core::option::Option, + #[prost(string, optional, tag = "5")] + pub highest_bid_amount: ::core::option::Option, } diff --git a/packages/injective_auction/src/auction_pool.rs b/packages/injective_auction/src/auction_pool.rs index 0b51b5e..869eee4 100644 --- a/packages/injective_auction/src/auction_pool.rs +++ b/packages/injective_auction/src/auction_pool.rs @@ -1,6 +1,5 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{Addr, Decimal}; -use osmosis_std_derive::CosmwasmExt; #[cw_serde] pub struct InstantiateMsg {