diff --git a/client/src/traits/vault.rs b/client/src/traits/vault.rs index c5759fb..b5f6a80 100644 --- a/client/src/traits/vault.rs +++ b/client/src/traits/vault.rs @@ -1,39 +1,51 @@ -use crate::{Result, RpcApi}; -use defichain_rpc_json::{common::UTXO, vault::*}; +use crate::{obj_into_json, Client, Result, RpcApi}; +use async_trait::async_trait; +use defichain_rpc_json::vault::*; +#[async_trait] pub trait VaultRPC: RpcApi { - fn close_vault(&self, close_vault: CloseVault, utxos: Option) -> Result; - fn create_vault(&self, vault: CreateVault, utxos: Option) -> Result; - fn deposit_to_vault(&self, deposit_vault: DepositVault, utxos: Option) -> Result; - fn estimate_collateral(&self, target_ratio: u64) -> Result<()>; - fn estimate_loan( - &self, - vault_id: String, - token_split: TokenPercentageSplit, - target_ratio: Option, - ) -> Result<()>; - fn estimate_vault(&self) -> Result; - fn get_vault(&self, vault_id: String) -> Result<()>; - fn list_auction_history( - &self, - pagination: Option, - ) -> Result>; - fn list_auctions(&self) -> Result>; - fn list_vaults(&self) -> Result; - fn place_auction_bid( - &self, - place_auction_bid: PlaceAuctionBid, - utxos: Option, - ) -> Result; - fn update_vault( - &self, - vault_id: String, - vault: UpdateVault, - utxos: Option, - ) -> Result; - fn withdraw_from_vault( + // fn close_vault(&self, close_vault: CloseVault, utxos: Option) -> Result; + // fn create_vault(&self, vault: CreateVault, utxos: Option) -> Result; + // fn deposit_to_vault(&self, deposit_vault: DepositVault, utxos: Option) -> Result; + // fn estimate_collateral(&self, target_ratio: u64) -> Result<()>; + // fn estimate_loan( + // &self, + // vault_id: String, + // token_split: TokenPercentageSplit, + // target_ratio: Option, + // ) -> Result<()>; + // fn estimate_vault(&self) -> Result; + // fn get_vault(&self, vault_id: String) -> Result<()>; + // fn list_auction_history( + // &self, + // pagination: Option, + // ) -> Result>; + async fn list_auctions(&self, pagination: Option) -> Result>; + // fn list_vaults(&self) -> Result; + // fn place_auction_bid( + // &self, + // place_auction_bid: PlaceAuctionBid, + // utxos: Option, + // ) -> Result; + // fn update_vault( + // &self, + // vault_id: String, + // vault: UpdateVault, + // utxos: Option, + // ) -> Result; + // fn withdraw_from_vault( + // &self, + // withdraw_vault: WithdrawVault, + // utxos: Option, + // ) -> Result; +} + +#[async_trait] +impl VaultRPC for Client { + async fn list_auctions( &self, - withdraw_vault: WithdrawVault, - utxos: Option, - ) -> Result; + pagination: Option + ) -> Result> { + self.call("listauctions", &[obj_into_json(pagination)?]).await + } }