split JSON api functions into existing retrieve_tx and new query_txs functions

This commit is contained in:
Yeastplume 2022-11-29 10:43:10 +00:00
parent 1188f3287d
commit 17edec25c8

View file

@ -216,6 +216,7 @@ pub trait OwnerRpc {
# , 2, false, false, false, false); # , 2, false, false, false, false);
``` ```
*/ */
fn retrieve_outputs( fn retrieve_outputs(
&self, &self,
token: Token, token: Token,
@ -300,27 +301,36 @@ pub trait OwnerRpc {
# "# # "#
# , 2, false, false, false, false); # , 2, false, false, false, false);
``` ```
*/
# JSON-RPC Example, with advanced query arguments - See (../grin_wallet_libwallet/types.struct.RetrieveTxQueryArgs.html) fn retrieve_txs(
&self,
token: Token,
refresh_from_node: bool,
tx_id: Option<u32>,
tx_slate_id: Option<Uuid>,
) -> Result<(bool, Vec<TxLogEntry>), Error>;
/**
Networked version of [Owner::retrieve_txs](struct.Owner.html#method.retrieve_txs), which passes only the `tx_query_args`
parameter. See (../grin_wallet_libwallet/types.struct.RetrieveTxQueryArgs.html)
``` ```
# grin_wallet_api::doctest_helper_json_rpc_owner_assert_response!( # grin_wallet_api::doctest_helper_json_rpc_owner_assert_response!(
# r#" # r#"
{ {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"method": "retrieve_txs", "method": "query_txs",
"params": { "params": {
"token": "d202964900000000d302964900000000d402964900000000d502964900000000", "token": "d202964900000000d302964900000000d402964900000000d502964900000000",
"refresh_from_node": true, "refresh_from_node": true,
"tx_id": null, "query": {
"tx_slate_id": null,
"tx_query_args": {
"min_id_inc": 0, "min_id_inc": 0,
"max_id_inc": 100, "max_id_inc": 100,
"min_amount_inc": "0", "min_amount_inc": "0",
"max_amount_inc": "6000000000", "max_amount_inc": "60000000000",
"sort_field": "Id", "sort_field": "Id",
"sort_order": "Desc" "sort_order": "Asc"
} }
}, },
"id": 1 "id": 1
@ -385,13 +395,11 @@ pub trait OwnerRpc {
*/ */
fn retrieve_txs( fn query_txs(
&self, &self,
token: Token, token: Token,
refresh_from_node: bool, refresh_from_node: bool,
tx_id: Option<u32>, query: RetrieveTxQueryArgs,
tx_slate_id: Option<Uuid>,
tx_query_args: Option<RetrieveTxQueryArgs>,
) -> Result<(bool, Vec<TxLogEntry>), Error>; ) -> Result<(bool, Vec<TxLogEntry>), Error>;
/** /**
@ -1997,7 +2005,6 @@ where
refresh_from_node: bool, refresh_from_node: bool,
tx_id: Option<u32>, tx_id: Option<u32>,
tx_slate_id: Option<Uuid>, tx_slate_id: Option<Uuid>,
query_args: Option<RetrieveTxQueryArgs>,
) -> Result<(bool, Vec<TxLogEntry>), Error> { ) -> Result<(bool, Vec<TxLogEntry>), Error> {
Owner::retrieve_txs( Owner::retrieve_txs(
self, self,
@ -2005,7 +2012,23 @@ where
refresh_from_node, refresh_from_node,
tx_id, tx_id,
tx_slate_id, tx_slate_id,
query_args, None,
)
}
fn query_txs(
&self,
token: Token,
refresh_from_node: bool,
query: RetrieveTxQueryArgs,
) -> Result<(bool, Vec<TxLogEntry>), Error> {
Owner::retrieve_txs(
self,
(&token.keychain_mask).as_ref(),
refresh_from_node,
None,
None,
Some(query),
) )
} }
@ -2565,7 +2588,7 @@ macro_rules! doctest_helper_json_rpc_owner_assert_response {
// These cause LMDB to run out of disk space on CircleCI // These cause LMDB to run out of disk space on CircleCI
// disable for now on windows // disable for now on windows
// TODO: Fix properly // TODO: Fix properly
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "linux"))]
{ {
use grin_wallet_api::run_doctest_owner; use grin_wallet_api::run_doctest_owner;
use serde_json; use serde_json;