Skip to content

Commit

Permalink
Add pending tx query
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolacy committed Jun 20, 2023
1 parent 7198e05 commit 73c8eea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion contracts/provider/vault/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sylvia::{contract, schemars};
use crate::error::ContractError;
use crate::msg::{
AccountClaimsResponse, AccountResponse, AllAccountsResponse, AllAccountsResponseItem,
AllTxsResponse, AllTxsResponseItem, ConfigResponse, LienInfo, StakingInitInfo,
AllTxsResponse, AllTxsResponseItem, ConfigResponse, LienInfo, StakingInitInfo, TxResponse,
};
use crate::state::{Config, Lien, LocalStaking, UserInfo};
use crate::txs::{Tx, TxType, Txs};
Expand Down Expand Up @@ -393,6 +393,13 @@ impl VaultContract<'_> {
Ok(resp)
}

/// Queries a pending tx.
#[msg(query)]
fn pending_tx(&self, ctx: QueryCtx, tx_id: u64) -> Result<TxResponse, ContractError> {
let resp = self.pending.txs.load(ctx.deps.storage, tx_id)?;
Ok(resp)
}

/// Queries for all pending txs.
/// Reports txs in descending order (newest first).
/// `start_after` is the last tx id included in previous page
Expand Down
3 changes: 2 additions & 1 deletion contracts/provider/vault/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ pub struct ConfigResponse {
pub local_staking: String,
}

pub type AllTxsResponseItem = crate::txs::Tx;
pub type TxResponse = crate::txs::Tx;
pub type AllTxsResponseItem = TxResponse;

#[cw_serde]
pub struct AllTxsResponse {
Expand Down

0 comments on commit 73c8eea

Please sign in to comment.