From 9a14b87f4e667b639dfa380182b221e8b9399e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Holm=20Gj=C3=B8rup?= Date: Thu, 9 Jan 2025 16:05:59 +0100 Subject: [PATCH] Fix minor API changes --- backend-rust/src/address.rs | 6 ++++++ backend-rust/src/graphql_api/contract.rs | 10 ++++++---- backend-rust/src/transaction_event/smart_contracts.rs | 1 + backend-rust/src/transaction_event/transfers.rs | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backend-rust/src/address.rs b/backend-rust/src/address.rs index 52d3c333..d605af67 100644 --- a/backend-rust/src/address.rs +++ b/backend-rust/src/address.rs @@ -67,3 +67,9 @@ impl From for Address { } } } + +impl From for Address { + fn from(address: concordium_rust_sdk::common::types::AccountAddress) -> Self { + Address::AccountAddress(address.into()) + } +} diff --git a/backend-rust/src/graphql_api/contract.rs b/backend-rust/src/graphql_api/contract.rs index f9bd635a..25787cc0 100644 --- a/backend-rust/src/graphql_api/contract.rs +++ b/backend-rust/src/graphql_api/contract.rs @@ -196,23 +196,25 @@ impl Contract { async fn contract_events( &self, ctx: &Context<'_>, - skip: u32, - take: u32, + skip: Option, + take: Option, ) -> ApiResult { let config = get_config(ctx)?; let pool = get_pool(ctx)?; + let skip = skip.unwrap_or(0); + let take = take.unwrap_or(config.contract_events_collection_limit); // If `skip` is 0 and at least one event is taken, include the // `init_transaction_event`. let include_initial_event = skip == 0 && take > 0; // Adjust the `take` and `skip` values considering if the // `init_transaction_event` is requested to be included or not. - let take_without_initial_event = take.saturating_sub(include_initial_event as u32); + let take_without_initial_event = take.saturating_sub(include_initial_event as u64); let skip_without_initial_event = skip.saturating_sub(1); // Limit the number of events to be fetched from the `contract_events` table. let limit = std::cmp::min( - take_without_initial_event as u64, + take_without_initial_event, config.contract_events_collection_limit.saturating_sub(include_initial_event as u64), ); diff --git a/backend-rust/src/transaction_event/smart_contracts.rs b/backend-rust/src/transaction_event/smart_contracts.rs index e1fde283..51031191 100644 --- a/backend-rust/src/transaction_event/smart_contracts.rs +++ b/backend-rust/src/transaction_event/smart_contracts.rs @@ -271,6 +271,7 @@ pub struct ContractCall { } #[derive(SimpleObject, serde::Serialize, serde::Deserialize)] +#[graphql(complex)] pub struct ContractInterrupted { pub contract_address: ContractAddress, // All logged events by the smart contract during this section of the transaction execution. diff --git a/backend-rust/src/transaction_event/transfers.rs b/backend-rust/src/transaction_event/transfers.rs index a79f2b5a..bdc3694a 100644 --- a/backend-rust/src/transaction_event/transfers.rs +++ b/backend-rust/src/transaction_event/transfers.rs @@ -11,7 +11,7 @@ use tracing::error; pub struct Transferred { pub amount: Amount, pub from: Address, - pub to: AccountAddress, + pub to: Address, } #[derive(SimpleObject, serde::Serialize, serde::Deserialize)]