Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzejkop committed Jun 4, 2024
1 parent ca4e111 commit fd018e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/server/routes/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ use crate::types::TransactionPriority;
pub struct SendTxRequest {
pub to: Address,
pub value: DecimalU256,
/// Transaction data
#[serde(default)]
pub data: Option<Bytes>,
/// Transaction gas limit
pub gas_limit: DecimalU256,
#[serde(default)]
pub priority: TransactionPriority,
Expand Down
7 changes: 5 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<HexBytes>,
pub gas_limit: HexU256,
/// Transaction gas limit
pub gas_limit: DecimalU256,
#[serde(default)]
#[oai(default)]
pub priority: TransactionPriority,
Expand Down
12 changes: 4 additions & 8 deletions src/types/wrappers/decimal_u256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Check warning on line 99 in src/types/wrappers/decimal_u256.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/tx-sitter-monolith/tx-sitter-monolith/src/types/wrappers/decimal_u256.rs
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> {
Expand Down
6 changes: 2 additions & 4 deletions src/types/wrappers/hex_u256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit fd018e2

Please sign in to comment.