diff --git a/client/src/client.rs b/client/src/client.rs index 6c854ef..0a85804 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -28,7 +28,7 @@ use json::bitcoin::Txid; use jsonrpc_async; use log::Level::{Debug, Trace, Warn}; use serde::{self, Serialize}; -use serde_json::{self, json, Map}; +use serde_json::{self, Map}; use crate::error::*; use crate::json; @@ -892,7 +892,7 @@ pub trait RpcApi: Sized { ) -> Result> { let hexes: Vec = rawtxs.to_vec().into_iter().map(|r| r.raw_hex().into()).collect(); - let mut args = [into_json(hexes)?, opt_into_json(max_fee_rate)?]; + let args = [into_json(hexes)?, opt_into_json(max_fee_rate)?]; self.call("testmempoolaccept", &args).await } @@ -1121,7 +1121,7 @@ pub trait RpcApi: Sized { tx: R, max_fee_rate: Option, ) -> Result { - let mut args = [into_json(tx.raw_hex())?, opt_into_json(max_fee_rate)?]; + let args = [into_json(tx.raw_hex())?, opt_into_json(max_fee_rate)?]; self.call("sendrawtransaction", &args).await } diff --git a/client/src/lib.rs b/client/src/lib.rs index ed7b091..9a02cd9 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -31,7 +31,7 @@ use json::bitcoin::consensus::{Decodable, ReadExt}; use json::bitcoin::hex::HexToBytesIter; mod client; -mod error; +pub mod error; mod queryable; mod traits; diff --git a/client/src/traits/account.rs b/client/src/traits/account.rs index 0e50692..9fdf72a 100644 --- a/client/src/traits/account.rs +++ b/client/src/traits/account.rs @@ -48,13 +48,13 @@ pub trait AccountRPC: RpcApi { owner: Option, options: AccountHistoryOptions, ) -> Result>; - // TODO handle AccountResult enum type - // async fn list_accounts( - // &self, - // pagination: Option, - // verbose: Option, - // options: Option, - // ) -> Result>>; + async fn list_accounts( + &self, + pagination: Option, + verbose: Option, + indexed_amounts: Option, + is_mine_only: Option, + ) -> Result>>; async fn list_burn_history(&self, options: BurnHistoryOptions) -> Result>; async fn list_community_balances(&self) -> Result; async fn list_pending_dusd_swaps(&self) -> Result>; @@ -157,17 +157,24 @@ impl AccountRPC for Client { ) -> Result> { self.call("listaccounthistory", &[into_json(owner)?, into_json(options)?]).await } - // async fn list_accounts( - // &self, - // pagination: Option, - // verbose: Option, - // options: Option, - // ) -> Result>> { - // self.call( - // "listaccounts", - // &[into_json(pagination)?, into_json(verbose)?, into_json(options)?], - // ) - // } + async fn list_accounts( + &self, + pagination: Option, + verbose: Option, + indexed_amounts: Option, + is_mine_only: Option, + ) -> Result>> { + self.call( + "listaccounts", + &[ + into_json(pagination)?, + into_json(verbose)?, + into_json(indexed_amounts)?, + into_json(is_mine_only)?, + ], + ) + .await + } async fn list_burn_history(&self, options: BurnHistoryOptions) -> Result> { self.call("listburnhistory", &[into_json(options)?]).await } diff --git a/json/src/account.rs b/json/src/account.rs index 399912b..d623408 100644 --- a/json/src/account.rs +++ b/json/src/account.rs @@ -9,7 +9,7 @@ pub enum OwnerType { All, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum Format { Id, @@ -30,13 +30,23 @@ pub enum TransferDomainType { Evm = 3, } -#[derive(Debug, Serialize, Deserialize)] -pub struct ListAccountPagination { +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ListAccountsPagination { start: Option, including_start: Option, limit: Option, } +impl ListAccountsPagination { + pub fn new(start: Option, including_start: Option, limit: Option) -> Self { + Self { + start, + including_start, + limit, + } + } +} + #[derive(Debug, Serialize, Deserialize)] pub struct GetAccountPagination { start: Option, @@ -44,34 +54,26 @@ pub struct GetAccountPagination { limit: Option, } -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct AccountResult { +#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] +pub struct AccountsResult { key: String, owner: T, amount: U, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "camelCase")] -pub struct AccountOwner { +pub struct AccountsResultOwner { asm: String, hex: String, - req_sigs: i64, + req_sigs: Option, r#type: String, - addresses: Vec, + addresses: Option>, } #[derive(Debug, Serialize, Deserialize)] pub struct AccountAmount(pub HashMap); -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct ListAccountOptions { - indexed_amounts: Option, - is_mine_only: Option, -} - #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct GetAccountOptions { @@ -107,7 +109,7 @@ pub struct AccountHistory { pub amounts: Vec, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct AccountHistoryOptions { max_block_height: Option,