Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add pagination to deposit fetching #1252

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**status** | [**Status**](.md) | the status to search by when getting all deposits. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down Expand Up @@ -112,7 +112,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**recipient** | **String** | the status to search by when getting all deposits. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down Expand Up @@ -142,7 +142,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**txid** | **String** | txid associated with the Deposit. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**status** | [**Status**](.md) | the status to search by when getting all deposits. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub async fn get_deposits(
configuration: &configuration::Configuration,
status: models::Status,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetDepositsResponse, Error<GetDepositsError>> {
let local_var_configuration = configuration;

Expand Down Expand Up @@ -213,7 +213,7 @@ pub async fn get_deposits_for_recipient(
configuration: &configuration::Configuration,
recipient: &str,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetDepositsResponse, Error<GetDepositsForRecipientError>> {
let local_var_configuration = configuration;

Expand Down Expand Up @@ -264,7 +264,7 @@ pub async fn get_deposits_for_transaction(
configuration: &configuration::Configuration,
txid: &str,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetDepositsForTransactionResponse, Error<GetDepositsForTransactionError>> {
let local_var_configuration = configuration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub async fn get_withdrawals(
configuration: &configuration::Configuration,
status: models::Status,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetWithdrawalsResponse, Error<GetWithdrawalsError>> {
let local_var_configuration = configuration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**status** | [**Status**](.md) | the status to search by when getting all deposits. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down Expand Up @@ -112,7 +112,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**recipient** | **String** | the status to search by when getting all deposits. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down Expand Up @@ -142,7 +142,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**txid** | **String** | txid associated with the Deposit. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**status** | [**Status**](.md) | the status to search by when getting all deposits. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub async fn get_deposits(
configuration: &configuration::Configuration,
status: models::Status,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetDepositsResponse, Error<GetDepositsError>> {
let local_var_configuration = configuration;

Expand Down Expand Up @@ -213,7 +213,7 @@ pub async fn get_deposits_for_recipient(
configuration: &configuration::Configuration,
recipient: &str,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetDepositsResponse, Error<GetDepositsForRecipientError>> {
let local_var_configuration = configuration;

Expand Down Expand Up @@ -264,7 +264,7 @@ pub async fn get_deposits_for_transaction(
configuration: &configuration::Configuration,
txid: &str,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetDepositsForTransactionResponse, Error<GetDepositsForTransactionError>> {
let local_var_configuration = configuration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub async fn get_withdrawals(
configuration: &configuration::Configuration,
status: models::Status,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetWithdrawalsResponse, Error<GetWithdrawalsError>> {
let local_var_configuration = configuration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**status** | [**Status**](.md) | the status to search by when getting all deposits. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down Expand Up @@ -112,7 +112,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**recipient** | **String** | the status to search by when getting all deposits. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down Expand Up @@ -142,7 +142,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**txid** | **String** | txid associated with the Deposit. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**status** | [**Status**](.md) | the status to search by when getting all deposits. | [required] |
**next_token** | Option<**String**> | the next token value from the previous return of this api call. | |
**page_size** | Option<**i32**> | the maximum number of items in the response list. | |
**page_size** | Option<**u32**> | the maximum number of items in the response list. | |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub async fn get_deposits(
configuration: &configuration::Configuration,
status: models::Status,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetDepositsResponse, Error<GetDepositsError>> {
let local_var_configuration = configuration;

Expand Down Expand Up @@ -213,7 +213,7 @@ pub async fn get_deposits_for_recipient(
configuration: &configuration::Configuration,
recipient: &str,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetDepositsResponse, Error<GetDepositsForRecipientError>> {
let local_var_configuration = configuration;

Expand Down Expand Up @@ -264,7 +264,7 @@ pub async fn get_deposits_for_transaction(
configuration: &configuration::Configuration,
txid: &str,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetDepositsForTransactionResponse, Error<GetDepositsForTransactionError>> {
let local_var_configuration = configuration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub async fn get_withdrawals(
configuration: &configuration::Configuration,
status: models::Status,
next_token: Option<&str>,
page_size: Option<i32>,
page_size: Option<u32>,
) -> Result<models::GetWithdrawalsResponse, Error<GetWithdrawalsError>> {
let local_var_configuration = configuration;

Expand Down
6 changes: 6 additions & 0 deletions docker/mainnet/sbtc-signer/signer-config.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ endpoints = [
"https://[email protected]"
]

# The pagination timeout, in seconds, used to fetch deposits and withdrawals
# requests from Emily.
djordon marked this conversation as resolved.
Show resolved Hide resolved
# Required: true
# Environment: SIGNER_EMILY__PAGINATION_TIMEOUT
pagination_timeout = 30

# !! ==============================================================================
# !! Bitcoin Core Configuration
# !! ==============================================================================
Expand Down
6 changes: 6 additions & 0 deletions docker/sbtc/signer/signer-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ endpoints = [
"http://testApiKey@emily-server:3031",
]

# The pagination timeout, in seconds, used to fetch deposits and withdrawals
# requests from Emily.
# Required: true
# Environment: SIGNER_EMILY__PAGINATION_TIMEOUT
pagination_timeout = 30

# !! ==============================================================================
# !! Bitcoin Core Configuration
# !! ==============================================================================
Expand Down
6 changes: 3 additions & 3 deletions emily/handler/src/api/handlers/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub async fn get_deposit(
params(
("txid" = String, Path, description = "txid associated with the Deposit."),
("nextToken" = Option<String>, Query, description = "the next token value from the previous return of this api call."),
("pageSize" = Option<i32>, Query, description = "the maximum number of items in the response list.")
("pageSize" = Option<u16>, Query, description = "the maximum number of items in the response list.")
),
tag = "deposit",
responses(
Expand Down Expand Up @@ -143,7 +143,7 @@ pub async fn get_deposits_for_transaction(
params(
("status" = Status, Query, description = "the status to search by when getting all deposits."),
("nextToken" = Option<String>, Query, description = "the next token value from the previous return of this api call."),
("pageSize" = Option<i32>, Query, description = "the maximum number of items in the response list.")
("pageSize" = Option<u16>, Query, description = "the maximum number of items in the response list.")
),
tag = "deposit",
responses(
Expand Down Expand Up @@ -194,7 +194,7 @@ pub async fn get_deposits(
params(
("recipient" = String, Path, description = "the status to search by when getting all deposits."),
("nextToken" = Option<String>, Query, description = "the next token value from the previous return of this api call."),
("pageSize" = Option<i32>, Query, description = "the maximum number of items in the response list.")
("pageSize" = Option<u16>, Query, description = "the maximum number of items in the response list.")
),
tag = "deposit",
responses(
Expand Down
2 changes: 1 addition & 1 deletion emily/handler/src/api/handlers/withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub async fn get_withdrawal(context: EmilyContext, request_id: u64) -> impl warp
params(
("status" = Status, Query, description = "the status to search by when getting all deposits."),
("nextToken" = Option<String>, Query, description = "the next token value from the previous return of this api call."),
("pageSize" = Option<i32>, Query, description = "the maximum number of items in the response list.")
("pageSize" = Option<u16>, Query, description = "the maximum number of items in the response list.")
),
tag = "withdrawal",
responses(
Expand Down
4 changes: 2 additions & 2 deletions emily/handler/tests/integration/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ async fn get_deposits() {
&configuration,
status,
next_token.as_ref().and_then(|o| o.as_deref()),
Some(chunksize as i32),
Some(chunksize as u32),
matteojug marked this conversation as resolved.
Show resolved Hide resolved
)
.await
.expect("Received an error after making a valid get deposits api call.");
Expand Down Expand Up @@ -456,7 +456,7 @@ async fn get_deposits_for_recipient() {
&configuration,
recipient,
next_token.as_ref().and_then(|o| o.as_deref()),
Some(chunksize as i32),
Some(chunksize as u32),
)
.await
.expect("Received an error after making a valid get deposits for recipient api call.");
Expand Down
10 changes: 5 additions & 5 deletions emily/handler/tests/integration/withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ async fn get_withdrawals() {
expected_withdrawal_infos.push(expected_withdrawal_info);
}

let chunksize: u16 = 2;
let chunksize = 2;
// If the number of elements is an exact multiple of the chunk size the "final"
// query will still have a next token, and the next query will now have a next
// token and will return no additional data.
let expected_chunks = expected_withdrawal_infos.len() as u16 / chunksize + 1;
let expected_chunks = expected_withdrawal_infos.len() as u32 / chunksize + 1;

// Act.
// ----
Expand All @@ -157,7 +157,7 @@ async fn get_withdrawals() {
&configuration,
status,
next_token.as_ref().and_then(|o| o.as_deref()),
Some(chunksize as i32),
Some(chunksize),
)
.await
.expect("Received an error after making a valid get withdrawal api call.");
Expand All @@ -171,13 +171,13 @@ async fn get_withdrawals() {

// Assert.
// -------
assert_eq!(expected_chunks, gotten_withdrawal_info_chunks.len() as u16);
assert_eq!(expected_chunks, gotten_withdrawal_info_chunks.len() as u32);
let max_chunk_size = gotten_withdrawal_info_chunks
.iter()
.map(|chunk| chunk.len())
.max()
.unwrap();
assert!(chunksize >= max_chunk_size as u16);
assert!(chunksize >= max_chunk_size as u32);

let mut gotten_withdrawal_infos = gotten_withdrawal_info_chunks
.into_iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@
"schema": {
"type": "integer",
"format": "int32",
"nullable": true
"nullable": true,
"minimum": 0
}
}
],
Expand Down Expand Up @@ -672,7 +673,8 @@
"schema": {
"type": "integer",
"format": "int32",
"nullable": true
"nullable": true,
"minimum": 0
}
}
],
Expand Down Expand Up @@ -798,7 +800,8 @@
"schema": {
"type": "integer",
"format": "int32",
"nullable": true
"nullable": true,
"minimum": 0
}
}
],
Expand Down Expand Up @@ -1478,7 +1481,8 @@
"schema": {
"type": "integer",
"format": "int32",
"nullable": true
"nullable": true,
"minimum": 0
}
}
],
Expand Down
Loading