From fd018e251822572704c62ffc82fcd6fdeeaeba18 Mon Sep 17 00:00:00 2001 From: Dzejkop Date: Tue, 4 Jun 2024 14:54:18 +0200 Subject: [PATCH] Fix --- src/server/routes/transaction.rs | 2 ++ src/types.rs | 7 +++++-- src/types/wrappers/decimal_u256.rs | 12 ++++-------- src/types/wrappers/hex_u256.rs | 6 ++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/server/routes/transaction.rs b/src/server/routes/transaction.rs index c6c2617..57c8b30 100644 --- a/src/server/routes/transaction.rs +++ b/src/server/routes/transaction.rs @@ -17,8 +17,10 @@ use crate::types::TransactionPriority; pub struct SendTxRequest { pub to: Address, pub value: DecimalU256, + /// Transaction data #[serde(default)] pub data: Option, + /// Transaction gas limit pub gas_limit: DecimalU256, #[serde(default)] pub priority: TransactionPriority, diff --git a/src/types.rs b/src/types.rs index d424c52..93b492d 100644 --- a/src/types.rs +++ b/src/types.rs @@ -2,6 +2,7 @@ use poem_openapi::{Enum, Object}; use serde::{Deserialize, Serialize}; use sqlx::prelude::FromRow; use wrappers::address::AddressWrapper; +use wrappers::decimal_u256::DecimalU256; use wrappers::hex_bytes::HexBytes; use wrappers::hex_u256::HexU256; @@ -124,11 +125,13 @@ pub struct CreateRelayerResponse { #[oai(rename_all = "camelCase")] pub struct SendTxRequest { pub to: AddressWrapper, - pub value: HexU256, + /// Transaction value + pub value: DecimalU256, #[serde(default)] #[oai(default)] pub data: Option, - pub gas_limit: HexU256, + /// Transaction gas limit + pub gas_limit: DecimalU256, #[serde(default)] #[oai(default)] pub priority: TransactionPriority, diff --git a/src/types/wrappers/decimal_u256.rs b/src/types/wrappers/decimal_u256.rs index a3d1922..3f1fe3e 100644 --- a/src/types/wrappers/decimal_u256.rs +++ b/src/types/wrappers/decimal_u256.rs @@ -96,18 +96,14 @@ impl poem_openapi::types::Type for DecimalU256 { fn schema_ref() -> MetaSchemaRef { let mut schema_ref = MetaSchema::new_with_format("u256", "decimal"); - schema_ref.example = - Some(serde_json::Value::String("0".to_string())); - schema_ref.default = - Some(serde_json::Value::String("0".to_string())); + schema_ref.example = Some(serde_json::Value::String("0".to_string())); + schema_ref.default = Some(serde_json::Value::String("0".to_string())); schema_ref.title = Some("Decimal U256".to_string()); schema_ref.description = Some( - "A 256-bit unsigned integer. Supports hex and decimal encoding", + "A decimal 256-bit unsigned integer", ); - MetaSchemaRef::Inline(Box::new(MetaSchema::new_with_format( - "u256", "decimal", - ))) + MetaSchemaRef::Inline(Box::new(schema_ref)) } fn as_raw_value(&self) -> Option<&Self::RawValueType> { diff --git a/src/types/wrappers/hex_u256.rs b/src/types/wrappers/hex_u256.rs index 3e9b742..f212c01 100644 --- a/src/types/wrappers/hex_u256.rs +++ b/src/types/wrappers/hex_u256.rs @@ -81,11 +81,9 @@ impl poem_openapi::types::Type for HexU256 { "0x0".to_string(), )); schema_ref.title = Some("Hex U256".to_string()); - schema_ref.description = Some("A 256-bit unsigned integer. Supports hex and decimal encoding"); + schema_ref.description = Some("A hex encoded 256-bit unsigned integer"); - MetaSchemaRef::Inline(Box::new(MetaSchema::new_with_format( - "u256", "hex", - ))) + MetaSchemaRef::Inline(Box::new(schema_ref)) } fn as_raw_value(&self) -> Option<&Self::RawValueType> {