Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
99 changes: 75 additions & 24 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2795,6 +2795,33 @@
"schema": {
"type": "string"
}
},
{
"name": "include_balance",
"in": "query",
"description": "Whether to include balance (default: true)",
"required": false,
"schema": {
"type": "boolean"
}
},
{
"name": "include_pending_count",
"in": "query",
"description": "Whether to include pending transaction count (default: true)",
"required": false,
"schema": {
"type": "boolean"
}
},
{
"name": "include_last_confirmed_tx",
"in": "query",
"description": "Whether to include last confirmed transaction timestamp (default: true)",
"required": false,
"schema": {
"type": "boolean"
}
}
],
"responses": {
Expand Down Expand Up @@ -5143,16 +5170,17 @@
{
"type": "object",
"required": [
"balance",
"pending_transactions_count",
"system_disabled",
"paused",
"nonce",
"network_type"
],
"properties": {
"balance": {
"type": "string"
"type": [
"string",
"null"
]
},
"last_confirmed_transaction_timestamp": {
"type": [
Expand All @@ -5173,7 +5201,10 @@
"type": "boolean"
},
"pending_transactions_count": {
"type": "integer",
"type": [
"integer",
"null"
],
"format": "int64",
"minimum": 0
},
Expand All @@ -5185,16 +5216,17 @@
{
"type": "object",
"required": [
"balance",
"pending_transactions_count",
"system_disabled",
"paused",
"sequence_number",
"network_type"
],
"properties": {
"balance": {
"type": "string"
"type": [
"string",
"null"
]
},
"last_confirmed_transaction_timestamp": {
"type": [
Expand All @@ -5212,7 +5244,10 @@
"type": "boolean"
},
"pending_transactions_count": {
"type": "integer",
"type": [
"integer",
"null"
],
"format": "int64",
"minimum": 0
},
Expand All @@ -5227,15 +5262,16 @@
{
"type": "object",
"required": [
"balance",
"pending_transactions_count",
"system_disabled",
"paused",
"network_type"
],
"properties": {
"balance": {
"type": "string"
"type": [
"string",
"null"
]
},
"last_confirmed_transaction_timestamp": {
"type": [
Expand All @@ -5253,7 +5289,10 @@
"type": "boolean"
},
"pending_transactions_count": {
"type": "integer",
"type": [
"integer",
"null"
],
"format": "int64",
"minimum": 0
},
Expand Down Expand Up @@ -8014,16 +8053,17 @@
{
"type": "object",
"required": [
"balance",
"pending_transactions_count",
"system_disabled",
"paused",
"nonce",
"network_type"
],
"properties": {
"balance": {
"type": "string"
"type": [
"string",
"null"
]
},
"last_confirmed_transaction_timestamp": {
"type": [
Expand All @@ -8044,7 +8084,10 @@
"type": "boolean"
},
"pending_transactions_count": {
"type": "integer",
"type": [
"integer",
"null"
],
"format": "int64",
"minimum": 0
},
Expand All @@ -8056,16 +8099,17 @@
{
"type": "object",
"required": [
"balance",
"pending_transactions_count",
"system_disabled",
"paused",
"sequence_number",
"network_type"
],
"properties": {
"balance": {
"type": "string"
"type": [
"string",
"null"
]
},
"last_confirmed_transaction_timestamp": {
"type": [
Expand All @@ -8083,7 +8127,10 @@
"type": "boolean"
},
"pending_transactions_count": {
"type": "integer",
"type": [
"integer",
"null"
],
"format": "int64",
"minimum": 0
},
Expand All @@ -8098,15 +8145,16 @@
{
"type": "object",
"required": [
"balance",
"pending_transactions_count",
"system_disabled",
"paused",
"network_type"
],
"properties": {
"balance": {
"type": "string"
"type": [
"string",
"null"
]
},
"last_confirmed_transaction_timestamp": {
"type": [
Expand All @@ -8124,7 +8172,10 @@
"type": "boolean"
},
"pending_transactions_count": {
"type": "integer",
"type": [
"integer",
"null"
],
"format": "int64",
"minimum": 0
},
Expand Down
11 changes: 9 additions & 2 deletions plugins/lib/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,15 @@ export type Relayer = {

/**
* Gets the relayer status (balance, nonce/sequence number, etc).
* @param options - Optional parameters.
* @param options.includeBalance - Whether to include balance (default: true).
* @returns The relayer status information.
*/
getRelayerStatus: () => Promise<ApiResponseRelayerStatusData>;
getRelayerStatus: (options?: {
includeBalance?: boolean;
includePendingCount?: boolean;
includeLastConfirmedTx?: boolean;
}) => Promise<ApiResponseRelayerStatusData>;
/**
* Gets the relayer info including address.
* @returns The relayer information.
Expand Down Expand Up @@ -561,7 +567,8 @@ export class DefaultPluginAPI implements PluginAPI {
},
getTransaction: (payload: GetTransactionRequest) =>
this._send<TransactionResponse>(relayerId, 'getTransaction', payload),
getRelayerStatus: () => this._send<ApiResponseRelayerStatusData>(relayerId, 'getRelayerStatus', {}),
getRelayerStatus: (options?: { includeBalance?: boolean }) =>
this._send<ApiResponseRelayerStatusData>(relayerId, 'getRelayerStatus', options ?? {}),
signTransaction: (payload: SignTransactionRequest) =>
this._send<SignTransactionResponse>(relayerId, 'signTransaction', payload),
getRelayer: () => this._send<ApiResponseRelayerResponseData>(relayerId, 'getRelayer', {}),
Expand Down
8 changes: 6 additions & 2 deletions plugins/lib/pool-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,12 @@ class PluginAPIImpl implements PluginAPI {
},
getTransaction: (payload: { transactionId: string }) =>
this.send(relayerId, 'getTransaction', payload),
getRelayerStatus: () =>
this.send<ApiResponseRelayerStatusData>(relayerId, 'getRelayerStatus', {}),
getRelayerStatus: (options?: {
includeBalance?: boolean;
includePendingCount?: boolean;
includeLastConfirmedTx?: boolean;
}) =>
this.send<ApiResponseRelayerStatusData>(relayerId, 'getRelayerStatus', options ?? {}),
signTransaction: (payload: SignTransactionRequest) =>
this.send<SignTransactionResponse>(relayerId, 'signTransaction', payload),
getRelayer: () =>
Expand Down
14 changes: 8 additions & 6 deletions src/api/controllers/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ use crate::{
transaction::request::{
SponsoredTransactionBuildRequest, SponsoredTransactionQuoteRequest,
},
ApiError, ApiResponse, CreateRelayerRequest, DefaultAppState, NetworkRepoModel,
NetworkTransactionRequest, NetworkType, NotificationRepoModel, PaginationMeta,
PaginationQuery, Relayer as RelayerDomainModel, RelayerRepoModel, RelayerRepoUpdater,
RelayerResponse, Signer as SignerDomainModel, SignerRepoModel, ThinDataAppState,
TransactionRepoModel, TransactionResponse, TransactionStatus, UpdateRelayerRequestRaw,
ApiError, ApiResponse, CreateRelayerRequest, DefaultAppState, GetStatusOptions,
NetworkRepoModel, NetworkTransactionRequest, NetworkType, NotificationRepoModel,
PaginationMeta, PaginationQuery, Relayer as RelayerDomainModel, RelayerRepoModel,
RelayerRepoUpdater, RelayerResponse, Signer as SignerDomainModel, SignerRepoModel,
ThinDataAppState, TransactionRepoModel, TransactionResponse, TransactionStatus,
UpdateRelayerRequestRaw,
},
repositories::{
ApiKeyRepositoryTrait, NetworkRepository, PluginRepositoryTrait, RelayerRepository,
Expand Down Expand Up @@ -353,6 +354,7 @@ where
/// The status of the specified relayer.
pub async fn get_relayer_status<J, RR, TR, NR, NFR, SR, TCR, PR, AKR>(
relayer_id: String,
options: GetStatusOptions,
state: ThinDataAppState<J, RR, TR, NR, NFR, SR, TCR, PR, AKR>,
) -> Result<HttpResponse, ApiError>
where
Expand All @@ -368,7 +370,7 @@ where
{
let relayer = get_network_relayer(relayer_id, &state).await?;

let status = relayer.get_status().await?;
let status = relayer.get_status(options).await?;

Ok(HttpResponse::Ok().json(ApiResponse::success(status)))
}
Expand Down
5 changes: 4 additions & 1 deletion src/api/routes/docs/relayer_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,10 @@ fn doc_delete_relayer() {}
("bearer_auth" = [])
),
params(
("relayer_id" = String, Path, description = "The unique identifier of the relayer")
("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
("include_balance" = Option<bool>, Query, description = "Whether to include balance (default: true)"),
("include_pending_count" = Option<bool>, Query, description = "Whether to include pending transaction count (default: true)"),
("include_last_confirmed_tx" = Option<bool>, Query, description = "Whether to include last confirmed transaction timestamp (default: true)")
),
responses(
(status = 200, description = "Relayer status retrieved successfully", body = ApiResponse<RelayerStatus>),
Expand Down
Loading