diff --git a/src/api_key.rs b/src/api_key.rs index b000143..c497ace 100644 --- a/src/api_key.rs +++ b/src/api_key.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use base64::Engine; use poem_openapi::registry::{MetaSchema, MetaSchemaRef}; -use poem_openapi::types::{ParseFromJSON, ToJSON}; +use poem_openapi::types::{ParseFromJSON, ParseFromParameter, ToJSON}; use rand::rngs::OsRng; use rand::Rng; use serde::Serialize; @@ -138,7 +138,7 @@ impl poem_openapi::types::Type for ApiKey { let mut schema_ref = MetaSchema::new_with_format("string", "api-key"); schema_ref.example = Some(serde_json::Value::String( - "MyDwh6wBRyOAkrA-ANOGjViioo3fXMa53nbdLhezV4s=".to_string(), + "G5CKNF3BTS2hRl60bpdYMNPqXvXsP-QZd2lrtmgctsk=".to_string(), )); schema_ref.title = Some("Api Key".to_string()); schema_ref.description = Some("Base64 encoded API key"); @@ -176,6 +176,12 @@ impl ToJSON for ApiKey { } } +impl ParseFromParameter for ApiKey { + fn parse_from_parameter(value: &str) -> poem_openapi::types::ParseResult { + value.parse().map_err(|_| poem_openapi::types::ParseError::expected_input()) + } +} + impl ApiKey { pub fn reveal(&self) -> eyre::Result { let relayer_id = uuid::Uuid::parse_str(&self.relayer_id) diff --git a/src/db.rs b/src/db.rs index 4b34565..688547b 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1229,7 +1229,7 @@ mod tests { use postgres_docker_utils::DockerContainerGuard; use super::*; - use crate::types::wrappers::u256::U256Wrapper; + use crate::types::wrappers::hex_u256::HexU256; use crate::types::RelayerGasPriceLimit; async fn setup_db() -> eyre::Result<(Database, DockerContainerGuard)> { @@ -1381,7 +1381,7 @@ mod tests { max_queued_txs: Some(20), gas_price_limits: Some(vec![RelayerGasPriceLimit { chain_id: 1, - value: U256Wrapper(U256::from(10_123u64)), + value: HexU256(U256::from(10_123u64)), }]), enabled: None, }, @@ -1403,7 +1403,7 @@ mod tests { relayer.gas_price_limits, vec![RelayerGasPriceLimit { chain_id: 1, - value: U256Wrapper(U256::from(10_123u64)), + value: HexU256(U256::from(10_123u64)), }] ); diff --git a/src/db/data.rs b/src/db/data.rs index a003d7a..ca65aec 100644 --- a/src/db/data.rs +++ b/src/db/data.rs @@ -7,7 +7,7 @@ use sqlx::Database; use crate::broadcast_utils::gas_estimation::FeesEstimate; use crate::types::wrappers::address::AddressWrapper; -use crate::types::wrappers::u256::U256Wrapper; +use crate::types::wrappers::hex_u256::HexU256; use crate::types::TransactionPriority; #[derive(Debug, Clone, FromRow)] @@ -16,8 +16,8 @@ pub struct UnsentTx { pub id: String, pub tx_to: AddressWrapper, pub data: Vec, - pub value: U256Wrapper, - pub gas_limit: U256Wrapper, + pub value: HexU256, + pub gas_limit: HexU256, pub priority: TransactionPriority, #[sqlx(try_from = "i64")] pub nonce: u64, @@ -33,16 +33,16 @@ pub struct TxForEscalation { pub id: String, pub tx_to: AddressWrapper, pub data: Vec, - pub value: U256Wrapper, - pub gas_limit: U256Wrapper, + pub value: HexU256, + pub gas_limit: HexU256, #[sqlx(try_from = "i64")] pub nonce: u64, pub blobs: Option>>, pub key_id: String, #[sqlx(try_from = "i64")] pub chain_id: u64, - pub initial_max_fee_per_gas: U256Wrapper, - pub initial_max_priority_fee_per_gas: U256Wrapper, + pub initial_max_fee_per_gas: HexU256, + pub initial_max_priority_fee_per_gas: HexU256, #[sqlx(try_from = "i64")] pub escalation_count: usize, } @@ -52,8 +52,8 @@ pub struct ReadTxData { pub tx_id: String, pub to: AddressWrapper, pub data: Vec, - pub value: U256Wrapper, - pub gas_limit: U256Wrapper, + pub value: HexU256, + pub gas_limit: HexU256, #[sqlx(try_from = "i64")] pub nonce: u64, pub blobs: Option>>, diff --git a/src/new_server.rs b/src/new_server.rs index 8e9e5f9..698bbd1 100644 --- a/src/new_server.rs +++ b/src/new_server.rs @@ -19,7 +19,7 @@ use crate::service::Service; use crate::task_runner::TaskRunner; use crate::types::{ CreateRelayerRequest, CreateRelayerResponse, NetworkInfo, NewNetworkInfo, - RelayerInfo, RelayerUpdate, + RelayerInfo, RelayerUpdate, SendTxResponse, }; mod security; @@ -252,10 +252,101 @@ impl AdminApi { } } -struct ConsumerApi; +struct RelayerApi; #[OpenApi(prefix_path = "/1/api/")] -impl ConsumerApi {} +impl RelayerApi { + /// Send Transaction + #[oai(path = "/:api_token/tx", method = "post")] + async fn send_tx( + &self, + Data(app): Data<&Arc>, + Path(api_token): Path, + // Json(req): Json, + ) -> Result> { + api_token.validate(app).await?; + + // let tx_id = if let Some(id) = req.tx_id { + // id + // } else { + // uuid::Uuid::new_v4().to_string() + // }; + + // let relayer = app.db.get_relayer(api_token.relayer_id()).await?; + + // if !relayer.enabled { + // return Err(ApiError::RelayerDisabled); + // } + + // let relayer_queued_tx_count = app + // .db + // .get_relayer_pending_txs(api_token.relayer_id()) + // .await?; + + // if relayer_queued_tx_count > relayer.max_queued_txs as usize { + // return Err(ApiError::TooManyTransactions { + // max: relayer.max_queued_txs as usize, + // current: relayer_queued_tx_count, + // }); + // } + + // app.db + // .create_transaction( + // &tx_id, + // req.to, + // req.data.as_ref().map(|d| &d[..]).unwrap_or(&[]), + // req.value, + // req.gas_limit, + // req.priority, + // req.blobs, + // api_token.relayer_id(), + // ) + // .await?; + + // tracing::info!(tx_id, "Transaction created"); + + // Ok(Json(SendTxResponse { tx_id })) + + todo!() + } + + /// Get Transaction + #[oai(path = "/:api_token/tx/:tx_id", method = "get")] + async fn get_tx( + &self, + Data(app): Data<&Arc>, + Path(api_token): Path, + Path(tx_id): Path, + ) -> Result> { + api_token.validate(app).await?; + + todo!() + } + + /// Get Transactions + #[oai(path = "/:api_token/txs", method = "get")] + async fn get_txs( + &self, + Data(app): Data<&Arc>, + Path(api_token): Path, + ) -> Result<()> { + api_token.validate(app).await?; + + Ok(()) + } + + /// Relayer RPC + #[oai(path = "/:api_token/rpc", method = "post")] + async fn relayer_rpc( + &self, + Data(app): Data<&Arc>, + Path(api_token): Path, + ) -> Result<()> { + api_token.validate(app).await?; + + Ok(()) + } +} struct ServiceApi; @@ -292,7 +383,7 @@ impl ServerHandle { pub async fn spawn_server(app: Arc) -> eyre::Result { let mut api_service = OpenApiService::new( - (AdminApi, ConsumerApi, ServiceApi), + (AdminApi, RelayerApi, ServiceApi), "Tx Sitter", version::version!(), ); diff --git a/src/new_server/security.rs b/src/new_server/security.rs index 8fdc2b4..e22f92d 100644 --- a/src/new_server/security.rs +++ b/src/new_server/security.rs @@ -1,6 +1,7 @@ use poem::Result; use poem_openapi::{auth, SecurityScheme}; +use crate::api_key::ApiKey; use crate::app::App; #[derive(SecurityScheme)] @@ -23,3 +24,25 @@ impl BasicAuth { Ok(()) } } + +impl ApiKey { + pub async fn validate(&self, app: impl AsRef) -> Result<()> { + let app = app.as_ref(); + + let is_authorized = app.is_authorized(self).await.map_err(|err| { + poem::error::Error::from_string( + err.to_string(), + poem::http::StatusCode::INTERNAL_SERVER_ERROR, + ) + })?; + + if !is_authorized { + return Err(poem::error::Error::from_string( + "Unauthorized".to_string(), + poem::http::StatusCode::UNAUTHORIZED, + )); + } + + Ok(()) + } +} diff --git a/src/serde_utils.rs b/src/serde_utils.rs index 596953b..b54f388 100644 --- a/src/serde_utils.rs +++ b/src/serde_utils.rs @@ -1,2 +1 @@ pub mod base64_binary; -pub mod decimal_u256; diff --git a/src/serde_utils/decimal_u256.rs b/src/serde_utils/decimal_u256.rs deleted file mode 100644 index f37e802..0000000 --- a/src/serde_utils/decimal_u256.rs +++ /dev/null @@ -1,42 +0,0 @@ -use ethers::types::U256; - -pub fn serialize(u256: &U256, serializer: S) -> Result -where - S: serde::Serializer, -{ - let s = u256.to_string(); - serializer.serialize_str(&s) -} - -pub fn deserialize<'de, D>(deserializer: D) -> Result -where - D: serde::Deserializer<'de>, -{ - let s: &str = serde::Deserialize::deserialize(deserializer)?; - let u256 = U256::from_dec_str(s).map_err(serde::de::Error::custom)?; - Ok(u256) -} - -#[cfg(test)] -mod tests { - use serde::{Deserialize, Serialize}; - - use super::*; - - #[derive(Debug, Clone, Serialize, Deserialize)] - struct Test { - #[serde(with = "super")] - v: U256, - } - - #[test] - fn test_u256_serde() { - let test = Test { v: U256::from(123) }; - - let s = serde_json::to_string(&test).unwrap(); - assert_eq!(s, r#"{"v":"123"}"#); - - let test: Test = serde_json::from_str(&s).unwrap(); - assert_eq!(test.v, U256::from(123)); - } -} diff --git a/src/server/routes/transaction.rs b/src/server/routes/transaction.rs index fef6d5e..c6c2617 100644 --- a/src/server/routes/transaction.rs +++ b/src/server/routes/transaction.rs @@ -9,18 +9,17 @@ use crate::api_key::ApiKey; use crate::app::App; use crate::db::TxStatus; use crate::server::ApiError; +use crate::types::wrappers::decimal_u256::DecimalU256; use crate::types::TransactionPriority; #[derive(Debug, Default, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct SendTxRequest { pub to: Address, - #[serde(with = "crate::serde_utils::decimal_u256")] - pub value: U256, + pub value: DecimalU256, #[serde(default)] pub data: Option, - #[serde(with = "crate::serde_utils::decimal_u256")] - pub gas_limit: U256, + pub gas_limit: DecimalU256, #[serde(default)] pub priority: TransactionPriority, #[serde(default)] @@ -49,10 +48,8 @@ pub struct GetTxResponse { pub to: Address, #[serde(default, skip_serializing_if = "Option::is_none")] pub data: Option, - #[serde(with = "crate::serde_utils::decimal_u256")] - pub value: U256, - #[serde(with = "crate::serde_utils::decimal_u256")] - pub gas_limit: U256, + pub value: DecimalU256, + pub gas_limit: DecimalU256, pub nonce: u64, // Sent tx data @@ -115,8 +112,8 @@ pub async fn send_tx( &tx_id, req.to, req.data.as_ref().map(|d| &d[..]).unwrap_or(&[]), - req.value, - req.gas_limit, + req.value.0, + req.gas_limit.0, req.priority, req.blobs, api_token.relayer_id(), @@ -160,8 +157,8 @@ pub async fn get_txs( } else { Some(tx.data.into()) }, - value: tx.value.0, - gas_limit: tx.gas_limit.0, + value: tx.value.into(), + gas_limit: tx.gas_limit.into(), nonce: tx.nonce, tx_hash: tx.tx_hash.map(|h| h.0), status: tx.status.map(GetTxResponseStatus::TxStatus).unwrap_or( @@ -192,8 +189,8 @@ pub async fn get_tx( } else { Some(tx.data.into()) }, - value: tx.value.0, - gas_limit: tx.gas_limit.0, + value: tx.value.into(), + gas_limit: tx.gas_limit.into(), nonce: tx.nonce, tx_hash: tx.tx_hash.map(|h| h.0), status: tx diff --git a/src/types.rs b/src/types.rs index 46cf356..64cdbfd 100644 --- a/src/types.rs +++ b/src/types.rs @@ -2,7 +2,7 @@ use poem_openapi::Object; use serde::{Deserialize, Serialize}; use sqlx::prelude::FromRow; use wrappers::address::AddressWrapper; -use wrappers::u256::U256Wrapper; +use wrappers::hex_u256::HexU256; pub mod wrappers; @@ -73,7 +73,7 @@ pub struct RelayerUpdate { #[serde(rename_all = "camelCase")] #[oai(rename_all = "camelCase")] pub struct RelayerGasPriceLimit { - pub value: U256Wrapper, + pub value: HexU256, pub chain_id: i64, } @@ -118,6 +118,29 @@ pub struct CreateRelayerResponse { pub address: AddressWrapper, } +#[derive(Debug, Clone, Serialize, Deserialize, Object)] +#[serde(rename_all = "camelCase")] +#[oai(rename_all = "camelCase")] +pub struct SendTxRequest { + pub to: AddressWrapper, + pub value: HexU256, + // #[serde(default)] + // pub data: Option, + pub gas_limit: HexU256, + // #[serde(default)] + // pub priority: TransactionPriority, + #[serde(default)] + pub tx_id: Option, + #[serde(default, with = "crate::serde_utils::base64_binary")] + pub blobs: Option>>, +} + +#[derive(Debug, Clone, Serialize, Deserialize, Object)] +#[serde(rename_all = "camelCase")] +#[oai(rename_all = "camelCase")] +pub struct SendTxResponse { + pub tx_id: String, +} impl RelayerUpdate { pub fn with_relayer_name(mut self, relayer_name: String) -> Self { @@ -168,7 +191,7 @@ mod tests { max_inflight_txs: 0, max_queued_txs: 0, gas_price_limits: vec![RelayerGasPriceLimit { - value: U256Wrapper(U256::zero()), + value: U256::zero().into(), chain_id: 1, }], enabled: true, diff --git a/src/types/wrappers.rs b/src/types/wrappers.rs index a70adfc..fd52d0c 100644 --- a/src/types/wrappers.rs +++ b/src/types/wrappers.rs @@ -1,3 +1,21 @@ -pub mod u256; +use decimal_u256::DecimalU256; +use hex_u256::HexU256; + pub mod address; pub mod h256; + +// TODO: Remove repeated code in these 2 modules +pub mod decimal_u256; +pub mod hex_u256; + +impl From for DecimalU256 { + fn from(value: HexU256) -> DecimalU256 { + DecimalU256::from(value.0) + } +} + +impl From for HexU256 { + fn from(value: DecimalU256) -> HexU256 { + HexU256::from(value.0) + } +} diff --git a/src/types/wrappers/decimal_u256.rs b/src/types/wrappers/decimal_u256.rs new file mode 100644 index 0000000..b47872b --- /dev/null +++ b/src/types/wrappers/decimal_u256.rs @@ -0,0 +1,157 @@ +use ethers::types::U256; +use poem_openapi::registry::{MetaSchema, MetaSchemaRef}; +use poem_openapi::types::{ParseFromJSON, ToJSON}; +use serde::{Deserialize, Serialize}; +use sqlx::database::{HasArguments, HasValueRef}; +use sqlx::Database; + +#[derive(Debug, Default, Clone, PartialEq, Eq)] +pub struct DecimalU256(pub U256); + +impl Serialize for DecimalU256 { + fn serialize( + &self, + serializer: S, + ) -> Result { + let s = self.0.to_string(); + serializer.serialize_str(&s) + } +} + +impl<'de> Deserialize<'de> for DecimalU256 { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let s: &str = serde::Deserialize::deserialize(deserializer)?; + + let u256 = U256::from_dec_str(s).map_err(serde::de::Error::custom)?; + + Ok(Self(u256)) + } +} + +impl<'r, DB> sqlx::Decode<'r, DB> for DecimalU256 +where + DB: Database, + [u8; 32]: sqlx::Decode<'r, DB>, +{ + fn decode( + value: >::ValueRef, + ) -> Result { + let bytes = <[u8; 32] as sqlx::Decode>::decode(value)?; + + let value = U256::from_big_endian(&bytes); + + Ok(Self(value)) + } +} + +impl sqlx::Type for DecimalU256 +where + [u8; 32]: sqlx::Type, +{ + fn type_info() -> DB::TypeInfo { + <[u8; 32] as sqlx::Type>::type_info() + } + + fn compatible(ty: &DB::TypeInfo) -> bool { + *ty == Self::type_info() + } +} + +impl<'q, DB> sqlx::Encode<'q, DB> for DecimalU256 +where + DB: Database, + [u8; 32]: sqlx::Encode<'q, DB>, +{ + fn encode_by_ref( + &self, + buf: &mut >::ArgumentBuffer, + ) -> sqlx::encode::IsNull { + let mut bytes = [0u8; 32]; + self.0.to_big_endian(&mut bytes); + + <[u8; 32] as sqlx::Encode>::encode_by_ref(&bytes, buf) + } +} + +impl From for DecimalU256 { + fn from(value: U256) -> Self { + Self(value) + } +} + +impl poem_openapi::types::Type for DecimalU256 { + const IS_REQUIRED: bool = true; + + type RawValueType = Self; + + type RawElementValueType = Self; + + fn name() -> std::borrow::Cow<'static, str> { + "string(u256)".into() + } + + fn schema_ref() -> MetaSchemaRef { + let mut schema_ref = MetaSchema::new_with_format("string", "u256"); + + schema_ref.example = + Some(serde_json::Value::String("0xff".to_string())); + schema_ref.title = Some("Address".to_string()); + schema_ref.description = Some( + "A 256-bit unsigned integer. Supports hex and decimal encoding", + ); + + MetaSchemaRef::Inline(Box::new(MetaSchema::new_with_format( + "string", "u256", + ))) + } + + fn as_raw_value(&self) -> Option<&Self::RawValueType> { + Some(self) + } + + fn raw_element_iter<'a>( + &'a self, + ) -> Box + 'a> { + Box::new(self.as_raw_value().into_iter()) + } +} + +impl ParseFromJSON for DecimalU256 { + fn parse_from_json( + value: Option, + ) -> poem_openapi::types::ParseResult { + // TODO: Better error handling + let value = value + .ok_or_else(|| poem_openapi::types::ParseError::expected_input())?; + + let inner = serde_json::from_value(value) + .map_err(|_| poem_openapi::types::ParseError::expected_input())?; + + Ok(Self(inner)) + } +} + +impl ToJSON for DecimalU256 { + fn to_json(&self) -> Option { + serde_json::to_value(self.0).ok() + } +} + +#[cfg(test)] +mod tests { + use test_case::test_case; + + use super::*; + + #[test_case("10", 10)] + #[test_case("255", 255)] + fn deserialize_string(s: &str, v: u64) { + let s = format!("\"{s}\""); + let actual: DecimalU256 = serde_json::from_str(&s).unwrap(); + + assert_eq!(actual.0, U256::from(v)); + } +} diff --git a/src/types/wrappers/u256.rs b/src/types/wrappers/hex_u256.rs similarity index 85% rename from src/types/wrappers/u256.rs rename to src/types/wrappers/hex_u256.rs index d77f47d..5c27b93 100644 --- a/src/types/wrappers/u256.rs +++ b/src/types/wrappers/hex_u256.rs @@ -7,9 +7,9 @@ use sqlx::Database; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(transparent)] -pub struct U256Wrapper(pub U256); +pub struct HexU256(pub U256); -impl<'r, DB> sqlx::Decode<'r, DB> for U256Wrapper +impl<'r, DB> sqlx::Decode<'r, DB> for HexU256 where DB: Database, [u8; 32]: sqlx::Decode<'r, DB>, @@ -25,7 +25,7 @@ where } } -impl sqlx::Type for U256Wrapper +impl sqlx::Type for HexU256 where [u8; 32]: sqlx::Type, { @@ -38,7 +38,7 @@ where } } -impl<'q, DB> sqlx::Encode<'q, DB> for U256Wrapper +impl<'q, DB> sqlx::Encode<'q, DB> for HexU256 where DB: Database, [u8; 32]: sqlx::Encode<'q, DB>, @@ -54,13 +54,13 @@ where } } -impl From for U256Wrapper { +impl From for HexU256 { fn from(value: U256) -> Self { Self(value) } } -impl poem_openapi::types::Type for U256Wrapper { +impl poem_openapi::types::Type for HexU256 { const IS_REQUIRED: bool = true; type RawValueType = Self; @@ -78,7 +78,7 @@ impl poem_openapi::types::Type for U256Wrapper { "0xff".to_string(), )); schema_ref.title = Some("Address".to_string()); - schema_ref.description = Some("Hex encoded 256-bit unsigned integer"); + schema_ref.description = Some("A 256-bit unsigned integer. Supports hex and decimal encoding"); MetaSchemaRef::Inline(Box::new(MetaSchema::new_with_format( "string", "u256", @@ -96,7 +96,7 @@ impl poem_openapi::types::Type for U256Wrapper { } } -impl ParseFromJSON for U256Wrapper { +impl ParseFromJSON for HexU256 { fn parse_from_json( value: Option, ) -> poem_openapi::types::ParseResult { @@ -111,7 +111,7 @@ impl ParseFromJSON for U256Wrapper { } } -impl ToJSON for U256Wrapper { +impl ToJSON for HexU256 { fn to_json(&self) -> Option { serde_json::to_value(self.0).ok() } @@ -124,10 +124,10 @@ mod tests { use super::*; #[test_case("0xff", 255)] - #[test_case("ff", 255)] + #[test_case("0x10", 16)] fn deserialize_string(s: &str, v: u64) { let s = format!("\"{s}\""); - let actual: U256Wrapper = serde_json::from_str(&s).unwrap(); + let actual: HexU256 = serde_json::from_str(&s).unwrap(); assert_eq!(actual.0, U256::from(v)); } diff --git a/tests/disabled_relayer.rs b/tests/disabled_relayer.rs index 20a1953..16d0a92 100644 --- a/tests/disabled_relayer.rs +++ b/tests/disabled_relayer.rs @@ -40,8 +40,8 @@ async fn disabled_relayer() -> eyre::Result<()> { &api_key, &SendTxRequest { to: ARBITRARY_ADDRESS, - value, - gas_limit: U256::from(21_000), + value: value.into(), + gas_limit: U256::from(21_000).into(), ..Default::default() }, ) diff --git a/tests/escalation.rs b/tests/escalation.rs index cab10c6..2cf3220 100644 --- a/tests/escalation.rs +++ b/tests/escalation.rs @@ -32,8 +32,8 @@ async fn escalation() -> eyre::Result<()> { &api_key, &SendTxRequest { to: ARBITRARY_ADDRESS, - value, - gas_limit: U256::from(21_000), + value: value.into(), + gas_limit: U256::from(21_000).into(), ..Default::default() }, ) diff --git a/tests/reorg.rs b/tests/reorg.rs index a25ae9a..0b5fe3c 100644 --- a/tests/reorg.rs +++ b/tests/reorg.rs @@ -27,8 +27,8 @@ async fn reorg() -> eyre::Result<()> { &api_key, &SendTxRequest { to: ARBITRARY_ADDRESS, - value, - gas_limit: U256::from(21_000), + value: value.into(), + gas_limit: U256::from(21_000).into(), ..Default::default() }, ) diff --git a/tests/send_many_txs.rs b/tests/send_many_txs.rs index bb273f6..371ff6f 100644 --- a/tests/send_many_txs.rs +++ b/tests/send_many_txs.rs @@ -30,8 +30,8 @@ async fn send_many_txs() -> eyre::Result<()> { &api_key, &SendTxRequest { to: ARBITRARY_ADDRESS, - value, - gas_limit: U256::from(21_000), + value: value.into(), + gas_limit: U256::from(21_000).into(), ..Default::default() }, ) diff --git a/tests/send_too_many_txs.rs b/tests/send_too_many_txs.rs index d93b3fa..cb360f9 100644 --- a/tests/send_too_many_txs.rs +++ b/tests/send_too_many_txs.rs @@ -54,9 +54,9 @@ async fn send_too_many_txs() -> eyre::Result<()> { &secondary_api_key, &SendTxRequest { to: ARBITRARY_ADDRESS, - value, + value: value.into(), data: None, - gas_limit: U256::from(21_000), + gas_limit: U256::from(21_000).into(), priority: TransactionPriority::Regular, tx_id: None, blobs: None, @@ -71,9 +71,9 @@ async fn send_too_many_txs() -> eyre::Result<()> { &secondary_api_key, &SendTxRequest { to: ARBITRARY_ADDRESS, - value, + value: value.into(), data: None, - gas_limit: U256::from(21_000), + gas_limit: U256::from(21_000).into(), priority: TransactionPriority::Regular, tx_id: None, blobs: None, @@ -99,9 +99,9 @@ async fn send_too_many_txs() -> eyre::Result<()> { &api_key, &SendTxRequest { to: secondary_relayer_address, - value: total_required_value, + value: total_required_value.into(), data: None, - gas_limit: U256::from(21_000), + gas_limit: U256::from(21_000).into(), priority: TransactionPriority::Regular, tx_id: None, blobs: None, diff --git a/tests/send_tx.rs b/tests/send_tx.rs index 1a8fe62..07b55ec 100644 --- a/tests/send_tx.rs +++ b/tests/send_tx.rs @@ -23,8 +23,8 @@ async fn send_tx() -> eyre::Result<()> { &api_key, &SendTxRequest { to: ARBITRARY_ADDRESS, - value, - gas_limit: U256::from(21_000), + value: value.into(), + gas_limit: U256::from(21_000).into(), ..Default::default() }, )