diff --git a/user-ops-indexer/user-ops-indexer-logic/src/indexer/base_indexer.rs b/user-ops-indexer/user-ops-indexer-logic/src/indexer/base_indexer.rs index e58d00009..322dcc847 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/indexer/base_indexer.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/indexer/base_indexer.rs @@ -406,13 +406,12 @@ mod tests { repository::tests::get_shared_db, }; use alloy::{ - primitives::U256, + primitives::{address, b256, bytes, U256}, providers::{ProviderBuilder, RootProvider}, transports::BoxTransport, }; use entity::sea_orm_active_enums::{EntryPointVersion, SponsorType}; use sea_orm::EntityTrait; - use std::str::FromStr; const ETH_RPC_URL: &str = "https://eth.drpc.org"; @@ -430,9 +429,7 @@ mod tests { let client = connect_rpc().await; // just some random tx from mainnet - let tx_hash = - TxHash::from_str("0xf9f60f6dc99663c6ce4912ef92fe6a122bb90585e47b5f213efca1705be26d6e") - .unwrap(); + let tx_hash = b256!("f9f60f6dc99663c6ce4912ef92fe6a122bb90585e47b5f213efca1705be26d6e"); let entry_point = EntrypointsSettings::default().v06_entry_point; let indexer = Indexer::new( @@ -446,34 +443,32 @@ mod tests { .await .unwrap(); - let op_hash = - B256::from_str("0x2d5f7a884e9a99cfe2445db2af140a8851fbd860852b668f2f199190f68adf87") - .unwrap(); + let op_hash = b256!("2d5f7a884e9a99cfe2445db2af140a8851fbd860852b668f2f199190f68adf87"); let user_op = repository::user_op::find_user_op_by_op_hash(&db, op_hash) .await .unwrap() .unwrap(); assert_eq!(user_op, UserOp { hash: op_hash, - sender: Address::from_str("0xeae4d85f7733ad522f601ce7ad4f595704a2d677").unwrap(), + sender: address!("eae4d85f7733ad522f601ce7ad4f595704a2d677"), nonce: B256::ZERO, init_code: None, - call_data: Bytes::from_str("0x70641a22000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000001e0049783f008a0085193e00003d00cd54003c71ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000").unwrap(), + call_data: bytes!("70641a22000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000001e0049783f008a0085193e00003d00cd54003c71ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000"), call_gas_limit: U256::from(92599), verification_gas_limit: U256::from(87149), pre_verification_gas: U256::from(49900), max_fee_per_gas: U256::from(53825000000u64), max_priority_fee_per_gas: U256::from(500000000u64), paymaster_and_data: None, - signature: Bytes::from_str("0x000000000000000000000000000000000000000000000000000000000065793a092c25c7a7c5e4bc46467324e2845caf1ccae767786e07806ca720f8a6b83356bc7d43a63a96b34507cfe7c424db37f351d71851ae9318e8d5c3d9f17c8bdb744c1c").unwrap(), + signature: bytes!("000000000000000000000000000000000000000000000000000000000065793a092c25c7a7c5e4bc46467324e2845caf1ccae767786e07806ca720f8a6b83356bc7d43a63a96b34507cfe7c424db37f351d71851ae9318e8d5c3d9f17c8bdb744c1c"), aggregator: None, aggregator_signature: None, entry_point, entry_point_version: EntryPointVersion::V06, transaction_hash: tx_hash, block_number: 18774992, - block_hash: BlockHash::from_str("0xe90aa1d6038c87b029a0666148ac2058ab8397f9c53594cc5a38c0113a48eab4").unwrap(), - bundler: Address::from_str("0x2df993cd76bb8dbda50546eef00eee2e6331a2c8").unwrap(), + block_hash: b256!("e90aa1d6038c87b029a0666148ac2058ab8397f9c53594cc5a38c0113a48eab4"), + bundler: address!("2df993cd76bb8dbda50546eef00eee2e6331a2c8"), bundle_index: 0, index: 0, factory: None, @@ -498,13 +493,9 @@ mod tests { let client = connect_rpc().await; // just some random tx from mainnet - let tx_hash = - TxHash::from_str("0xd69a2233e7ff9034d21f588ffde16ef30dee6ddc4814fa4ecd4a1355630b1730") - .unwrap(); + let tx_hash = b256!("d69a2233e7ff9034d21f588ffde16ef30dee6ddc4814fa4ecd4a1355630b1730"); let entry_point = EntrypointsSettings::default().v06_entry_point; - let op_hash = - B256::from_str("0xe5df829d25b3b0a043a658eb460cf74898eb0ad72a526dba0cd509ed2b83f796") - .unwrap(); + let op_hash = b256!("e5df829d25b3b0a043a658eb460cf74898eb0ad72a526dba0cd509ed2b83f796"); let indexer = Indexer::new( client, @@ -526,25 +517,25 @@ mod tests { .unwrap(); assert_eq!(user_op, UserOp { hash: op_hash, - sender: Address::from_str("0xc09521aa72df1f93e36c776d5464f8bf2ae7b37d").unwrap(), - nonce: B256::from_str("0x0000000000000000000000000000000000000000000021050000000000000002").unwrap(), + sender: address!("c09521aa72df1f93e36c776d5464f8bf2ae7b37d"), + nonce: b256!("0000000000000000000000000000000000000000000021050000000000000002"), init_code: None, - call_data: Bytes::from_str("0x2c2abd1e00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000240f0f3f240000000000000000000000005ecd0d3a7f69c73d86f634b52cb9a4c0eb4df7ae00000000000000000000000000000000000000000000000000000000").unwrap(), + call_data: bytes!("2c2abd1e00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000240f0f3f240000000000000000000000005ecd0d3a7f69c73d86f634b52cb9a4c0eb4df7ae00000000000000000000000000000000000000000000000000000000"), call_gas_limit: U256::from(89016), verification_gas_limit: U256::from(578897), pre_verification_gas: U256::from(107592), max_fee_per_gas: U256::ZERO, max_priority_fee_per_gas: U256::ZERO, paymaster_and_data: None, - signature: Bytes::from_str("0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000013259e664945ba8945c3198dfbfc83dd1c654a7d284dd48b3f4c80544a281938960d7a8386af33457c88801d6e59aa95f374978f0cf400952eea08a15ad68aa7d0000000000000000000000000000000000000000000000000000000000000025f198086b2db17256731bc456673b96bcef23f51d1fbacdd7c4379ef65465572f1d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a224d624230784b7177593773684c3461574c31714f5f315668794c4773433632764354682d544342464c704d222c226f726967696e223a2268747470733a2f2f6b6579732e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000").unwrap(), + signature: bytes!("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000013259e664945ba8945c3198dfbfc83dd1c654a7d284dd48b3f4c80544a281938960d7a8386af33457c88801d6e59aa95f374978f0cf400952eea08a15ad68aa7d0000000000000000000000000000000000000000000000000000000000000025f198086b2db17256731bc456673b96bcef23f51d1fbacdd7c4379ef65465572f1d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a224d624230784b7177593773684c3461574c31714f5f315668794c4773433632764354682d544342464c704d222c226f726967696e223a2268747470733a2f2f6b6579732e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000"), aggregator: None, aggregator_signature: None, entry_point, entry_point_version: EntryPointVersion::V06, transaction_hash: tx_hash, block_number: 21478047, - block_hash: BlockHash::from_str("0x2389d13b5294f5c38f5120671adf870468d892e60e637cb65e0eb47c455160f9").unwrap(), - bundler: Address::from_str("0xc09521aa72df1f93e36c776d5464f8bf2ae7b37d").unwrap(), + block_hash: b256!("2389d13b5294f5c38f5120671adf870468d892e60e637cb65e0eb47c455160f9"), + bundler: address!("c09521aa72df1f93e36c776d5464f8bf2ae7b37d"), bundle_index: 0, index: 0, factory: None, @@ -571,9 +562,7 @@ mod tests { let client = connect_rpc().await; // just some random tx from mainnet - let tx_hash = - TxHash::from_str("0x4a6702f8ef5b7754f5b54dfb00ccba181603e3a6fff77c93e7d0d40148f09ad0") - .unwrap(); + let tx_hash = b256!("4a6702f8ef5b7754f5b54dfb00ccba181603e3a6fff77c93e7d0d40148f09ad0"); let entry_point = EntrypointsSettings::default().v07_entry_point; let indexer = Indexer::new( @@ -587,38 +576,36 @@ mod tests { .await .unwrap(); - let op_hash = - B256::from_str("0xbd48a68e7dd39891fe7f139fe11bfb82d934a5deceb98f0c6fc4ebc7eeca58da") - .unwrap(); + let op_hash = b256!("bd48a68e7dd39891fe7f139fe11bfb82d934a5deceb98f0c6fc4ebc7eeca58da"); let user_op = repository::user_op::find_user_op_by_op_hash(&db, op_hash) .await .unwrap() .unwrap(); assert_eq!(user_op, UserOp { hash: op_hash, - sender: Address::from_str("0x4a7EFb490b2D34D1962f365C5647D84FAdD3Bd6A").unwrap(), - nonce: B256::from_str("0x00005c97aa67ba578e3c54ec5942a7563ea9130e4f5f4c300000000000000000").unwrap(), + sender: address!("4a7EFb490b2D34D1962f365C5647D84FAdD3Bd6A"), + nonce: b256!("00005c97aa67ba578e3c54ec5942a7563ea9130e4f5f4c300000000000000000"), init_code: None, - call_data: Bytes::from_str("0xe9ae5c530100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000000000000000027d9000000000000000000000000000000000000000000000000000000000000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003c44666fc80394356b4034c6f447b20899cff26af1d6d4520e9e3d7616ac0408daeb3cba94a00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000003c170744609c21c313473e3811563073c850c9f500000000000000000000000000000000000000000000000000000000009032d20000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000b44656669417070486f6d65000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783030303030303030303030303030303030303030303030303030303030303030303030303030303000000000000000000000000000000000000000000000000000000000000000000000f2614a233c7c3e7f08b1f887ba133a13f1eb2c55000000000000000000000000f2614a233c7c3e7f08b1f887ba133a13f1eb2c550000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000027d900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001442646478b0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59900000000000000000000000000000000000000000000000000000000000027d9000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000009032d20000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000045022260fac5e5542a773aa44fbcfedf7c193bc2c59901ffff00004375dff511095cc5a197a54140a24efef3a416011231deb6f5749ef6ce6943a275a1d3e7486f4eae000bb800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb00000000000000000000000056eb4bf8b7510323b89fde249d1fb660ae30d2ee00000000000000000000000000000000000000000000000000000000000e7e2700000000000000000000000000000000000000000000000000000000").unwrap(), + call_data: bytes!("e9ae5c530100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000000000000000027d9000000000000000000000000000000000000000000000000000000000000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003c44666fc80394356b4034c6f447b20899cff26af1d6d4520e9e3d7616ac0408daeb3cba94a00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000003c170744609c21c313473e3811563073c850c9f500000000000000000000000000000000000000000000000000000000009032d20000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000b44656669417070486f6d65000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783030303030303030303030303030303030303030303030303030303030303030303030303030303000000000000000000000000000000000000000000000000000000000000000000000f2614a233c7c3e7f08b1f887ba133a13f1eb2c55000000000000000000000000f2614a233c7c3e7f08b1f887ba133a13f1eb2c550000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000027d900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001442646478b0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59900000000000000000000000000000000000000000000000000000000000027d9000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000009032d20000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000045022260fac5e5542a773aa44fbcfedf7c193bc2c59901ffff00004375dff511095cc5a197a54140a24efef3a416011231deb6f5749ef6ce6943a275a1d3e7486f4eae000bb800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb00000000000000000000000056eb4bf8b7510323b89fde249d1fb660ae30d2ee00000000000000000000000000000000000000000000000000000000000e7e2700000000000000000000000000000000000000000000000000000000"), call_gas_limit: U256::from(375068), verification_gas_limit: U256::from(166784), pre_verification_gas: U256::from(69185), max_fee_per_gas: U256::from(1000000), max_priority_fee_per_gas: U256::from(5095252459u64), - paymaster_and_data: Some(Bytes::from_str("0x0000000000000039cd5e8ae05257ce51c473ddd10000000000000000000000000001440600000000000000000000000000000001000000676b732f000000000000bc8f0c8fbbdaa38053b974afd0fe66cc7be40c0941f4ac58304ddda97ee5ba6e14c11f01cbd2c7c46401448bb9615bf29449ead5da1c4755989910524828a2461c").unwrap()), - signature: Bytes::from_str("0xf59f5f4d934312578dbd0c7a8a464cd8c73c1cbbb267b1dcae103d0e2d8f3971314b169eac449874652d7f6cb83de63422c762c4dfbca02629f94fc3a478141d1c").unwrap(), + paymaster_and_data: Some(bytes!("0000000000000039cd5e8ae05257ce51c473ddd10000000000000000000000000001440600000000000000000000000000000001000000676b732f000000000000bc8f0c8fbbdaa38053b974afd0fe66cc7be40c0941f4ac58304ddda97ee5ba6e14c11f01cbd2c7c46401448bb9615bf29449ead5da1c4755989910524828a2461c")), + signature: bytes!("f59f5f4d934312578dbd0c7a8a464cd8c73c1cbbb267b1dcae103d0e2d8f3971314b169eac449874652d7f6cb83de63422c762c4dfbca02629f94fc3a478141d1c"), aggregator: None, aggregator_signature: None, entry_point, entry_point_version: EntryPointVersion::V07, transaction_hash: tx_hash, block_number: 21476573, - block_hash: BlockHash::from_str("0x54f26503211219a84c1c25d8f5c61d6e1a2f253b97508fb88a6e2e13bffee0b3").unwrap(), - bundler: Address::from_str("0x4337003fcD2F56DE3977cCb806383E9161628D0E").unwrap(), + block_hash: b256!("54f26503211219a84c1c25d8f5c61d6e1a2f253b97508fb88a6e2e13bffee0b3"), + bundler: address!("4337003fcD2F56DE3977cCb806383E9161628D0E"), bundle_index: 0, index: 0, factory: None, - paymaster: Some(Address::from_str("0x0000000000000039cd5e8aE05257CE51C473ddd1").unwrap()), + paymaster: Some(address!("0000000000000039cd5e8aE05257CE51C473ddd1")), status: true, revert_reason: None, gas: U256::from(693988), diff --git a/user-ops-indexer/user-ops-indexer-logic/src/indexer/common.rs b/user-ops-indexer/user-ops-indexer-logic/src/indexer/common.rs index e729f7321..42cf90ae4 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/indexer/common.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/indexer/common.rs @@ -115,16 +115,15 @@ pub fn decode_execute_call_data(call_data: &Bytes) -> (Option
, Option Vec { mod tests { use crate::indexer::rpc_utils::{flatten_geth_trace, TraceType}; use alloy::{ - primitives::{Address, Bytes}, + primitives::{address, bytes}, rpc::types::trace::geth::CallFrame, }; - use std::str::FromStr; #[test] fn test_flatten_geth_trace() { @@ -183,13 +182,13 @@ mod tests { assert_eq!(res[1].typ, TraceType::Call); assert_eq!( res[1].from, - Address::from_str("0xcA11bde05977b3631167028862bE2a173976CA11").unwrap() + address!("cA11bde05977b3631167028862bE2a173976CA11") ); assert_eq!( res[1].to, - Some(Address::from_str("0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789").unwrap()) + Some(address!("5FF137D4b0FDCD49DcA30c7CF57E578a026d2789")) ); - assert_eq!(res[1].input, Bytes::from_str("0x1fad948c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000004471500ac7147c158224fee67ac64227d3049de0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000008b9658b654efdfd69be5208e53342f5283f6486e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000000000000000000000000000000000000007a12000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000005a7817d80000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104519454470000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff850000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000000b21f56063860b6aa1b86191a9dec568bebfdec50000000000000000000000000000000000000000000000000000000000e4e1be0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400d5bda3b690c569c1c78a387ed6cf1a88ea7626000000000000000000000000000000000000000000000000000000000000000000000000000000000000004500000000c06e5c395501f2069dcbc9b05e75f9fd632765a99ebe8d2680862b95a3cfee5b581cfbbecc01c954b729c74b6b337e61fff043e1746f753d5a95913d8f13691d1b0000000000000000000000000000000000000000000000000000000000000000000000000000008b9658b654efdfd69be5208e53342f5283f6486e00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000000000000000000000000000000000000007a12000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000005a7817d80000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104519454470000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff850000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb00000000000000000000000004471500ac7147c158224fee67ac64227d3049de00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400d5bda3b690c569c1c78a387ed6cf1a88ea7626000000000000000000000000000000000000000000000000000000000000000000000000000000000000004500000000910c0077d5fba1f751d0ad9ae50d4595d9437fcbc8b7df19b3bdc97c59166df021a9bf7f913df6132acfa223bb9e4b26446461cfb99e837b86e5d070171a763c1c000000000000000000000000000000000000000000000000000000").unwrap()); + assert_eq!(res[1].input, bytes!("1fad948c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000004471500ac7147c158224fee67ac64227d3049de0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000008b9658b654efdfd69be5208e53342f5283f6486e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000000000000000000000000000000000000007a12000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000005a7817d80000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104519454470000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff850000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000000b21f56063860b6aa1b86191a9dec568bebfdec50000000000000000000000000000000000000000000000000000000000e4e1be0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400d5bda3b690c569c1c78a387ed6cf1a88ea7626000000000000000000000000000000000000000000000000000000000000000000000000000000000000004500000000c06e5c395501f2069dcbc9b05e75f9fd632765a99ebe8d2680862b95a3cfee5b581cfbbecc01c954b729c74b6b337e61fff043e1746f753d5a95913d8f13691d1b0000000000000000000000000000000000000000000000000000000000000000000000000000008b9658b654efdfd69be5208e53342f5283f6486e00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000000000000000000000000000000000000007a12000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000005a7817d80000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104519454470000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff850000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb00000000000000000000000004471500ac7147c158224fee67ac64227d3049de00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400d5bda3b690c569c1c78a387ed6cf1a88ea7626000000000000000000000000000000000000000000000000000000000000000000000000000000000000004500000000910c0077d5fba1f751d0ad9ae50d4595d9437fcbc8b7df19b3bdc97c59166df021a9bf7f913df6132acfa223bb9e4b26446461cfb99e837b86e5d070171a763c1c000000000000000000000000000000000000000000000000000000")); assert_eq!( res.iter() diff --git a/user-ops-indexer/user-ops-indexer-logic/src/indexer/settings.rs b/user-ops-indexer/user-ops-indexer-logic/src/indexer/settings.rs index b9f817635..1fa2f460c 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/indexer/settings.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/indexer/settings.rs @@ -1,5 +1,5 @@ use crate::indexer::rpc_utils::TraceClient; -use alloy::primitives::Address; +use alloy::primitives::{address, Address}; use serde::Deserialize; use serde_with::serde_as; use std::time; @@ -127,13 +127,9 @@ impl Default for EntrypointsSettings { fn default() -> Self { Self { v06: true, - v06_entry_point: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" - .parse() - .unwrap(), + v06_entry_point: address!("5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"), v07: true, - v07_entry_point: "0x0000000071727De22E5E9d8BAf0edAc6f37da032" - .parse() - .unwrap(), + v07_entry_point: address!("0000000071727De22E5E9d8BAf0edAc6f37da032"), } } } diff --git a/user-ops-indexer/user-ops-indexer-logic/src/indexer/v06/mod.rs b/user-ops-indexer/user-ops-indexer-logic/src/indexer/v06/mod.rs index 5186f31a4..82313b21b 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/indexer/v06/mod.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/indexer/v06/mod.rs @@ -158,7 +158,7 @@ impl IndexerV06 { let (user_logs_start_index, user_logs_count) = extract_user_logs_boundaries(logs, self.entry_point, paymaster); Ok(UserOp { - hash: B256::from(user_op_event.userOpHash), + hash: user_op_event.userOpHash, sender, nonce: B256::from(user_op.user_op.nonce), init_code: none_if_empty(user_op.user_op.initCode), diff --git a/user-ops-indexer/user-ops-indexer-logic/src/indexer/v07/mod.rs b/user-ops-indexer/user-ops-indexer-logic/src/indexer/v07/mod.rs index 73bbc24c5..0fceb6ea3 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/indexer/v07/mod.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/indexer/v07/mod.rs @@ -177,7 +177,7 @@ impl IndexerV07 { let (user_logs_start_index, user_logs_count) = extract_user_logs_boundaries(logs, self.entry_point, paymaster); Ok(UserOp { - hash: B256::from(user_op_event.userOpHash), + hash: user_op_event.userOpHash, sender, nonce: B256::from(user_op.user_op.nonce), init_code: none_if_empty(user_op.user_op.initCode), diff --git a/user-ops-indexer/user-ops-indexer-logic/src/repository/account.rs b/user-ops-indexer/user-ops-indexer-logic/src/repository/account.rs index e6650f629..4986ed0c7 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/repository/account.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/repository/account.rs @@ -100,18 +100,18 @@ FROM accounts_cte mod tests { use super::*; use crate::repository::tests::get_shared_db; - use alloy::primitives::{B256, U160, U256}; + use alloy::primitives::{address, B256, U256}; use pretty_assertions::assert_eq; #[tokio::test] async fn find_account_by_address_ok() { let db = get_shared_db().await; - let addr = Address::from(U160::from(0xffff)); + let addr = address!("000000000000000000000000000000000000ffff"); let item = find_account_by_address(&db, addr).await.unwrap(); assert_eq!(item, None); - let addr = Address::from(U160::from(0x0102)); + let addr = address!("0000000000000000000000000000000000000102"); let item = find_account_by_address(&db, addr).await.unwrap(); assert_eq!( item, @@ -125,13 +125,13 @@ mod tests { }) ); - let addr = Address::from(U160::from(0x3202)); + let addr = address!("0000000000000000000000000000000000003202"); let item = find_account_by_address(&db, addr).await.unwrap(); assert_eq!( item, Some(Account { address: addr, - factory: Some(Address::from(U160::from(0xf1))), + factory: Some(address!("00000000000000000000000000000000000000f1")), creation_transaction_hash: Some(B256::from(U256::from(0x3204))), creation_op_hash: Some(B256::from(U256::from(0x3201))), creation_timestamp: Some("2024-01-01T00:01:00.000000Z".to_string()), @@ -152,7 +152,7 @@ mod tests { assert_eq!(items.len(), 40); assert_eq!(next_page_token, None); - let factory = Some(Address::from(U160::from(0xf1))); + let factory = Some(address!("00000000000000000000000000000000000000f1")); let (items, next_page_token) = list_accounts(&db, factory, None, 60).await.unwrap(); assert_eq!(items.len(), 10); assert_eq!(next_page_token, None); diff --git a/user-ops-indexer/user-ops-indexer-logic/src/repository/bundle.rs b/user-ops-indexer/user-ops-indexer-logic/src/repository/bundle.rs index 4de7d7383..933de83fa 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/repository/bundle.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/repository/bundle.rs @@ -61,9 +61,8 @@ LIMIT $6"#, mod tests { use super::*; use crate::repository::tests::get_shared_db; - use alloy::primitives::U160; + use alloy::primitives::address; use pretty_assertions::assert_eq; - use std::str::FromStr; #[tokio::test] async fn list_bundles_ok() { @@ -73,9 +72,8 @@ mod tests { assert_eq!(items.len(), 100); assert_ne!(next_page_token, None); - let entrypoint = - Some(Address::from_str("0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789").unwrap()); - let bundler = Some(Address::from(U160::from(0x0105))); + let entrypoint = Some(address!("5FF137D4b0FDCD49DcA30c7CF57E578a026d2789")); + let bundler = Some(address!("0000000000000000000000000000000000000105")); let (items, next_page_token) = list_bundles(&db, None, entrypoint, None, 100) .await diff --git a/user-ops-indexer/user-ops-indexer-logic/src/repository/bundler.rs b/user-ops-indexer/user-ops-indexer-logic/src/repository/bundler.rs index 856905dea..7b3cd7aaf 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/repository/bundler.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/repository/bundler.rs @@ -78,18 +78,18 @@ LIMIT $3"#, mod tests { use super::*; use crate::repository::tests::get_shared_db; - use alloy::primitives::U160; + use alloy::primitives::address; use pretty_assertions::assert_eq; #[tokio::test] async fn find_bundler_by_address_ok() { let db = get_shared_db().await; - let addr = Address::from(U160::from(0xffff)); + let addr = address!("000000000000000000000000000000000000ffff"); let item = find_bundler_by_address(&db, addr).await.unwrap(); assert_eq!(item, None); - let addr = Address::from(U160::from(0x0105)); + let addr = address!("0000000000000000000000000000000000000105"); let item = find_bundler_by_address(&db, addr).await.unwrap(); assert_eq!( item, @@ -100,7 +100,7 @@ mod tests { }) ); - let addr = Address::from(U160::from(0x0505)); + let addr = address!("0000000000000000000000000000000000000505"); let item = find_bundler_by_address(&db, addr).await.unwrap(); assert_eq!( item, diff --git a/user-ops-indexer/user-ops-indexer-logic/src/repository/factory.rs b/user-ops-indexer/user-ops-indexer-logic/src/repository/factory.rs index 07387637b..230218382 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/repository/factory.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/repository/factory.rs @@ -73,18 +73,18 @@ pub async fn list_factories( mod tests { use super::*; use crate::repository::tests::get_shared_db; - use alloy::primitives::U160; + use alloy::primitives::address; use pretty_assertions::assert_eq; #[tokio::test] async fn find_factory_by_address_ok() { let db = get_shared_db().await; - let addr = Address::from(U160::from(0xf3)); + let addr = address!("00000000000000000000000000000000000000f3"); let item = find_factory_by_address(&db, addr).await.unwrap(); assert_eq!(item, None); - let addr = Address::from(U160::from(0xf1)); + let addr = address!("00000000000000000000000000000000000000f1"); let item = find_factory_by_address(&db, addr).await.unwrap(); assert_eq!( item, diff --git a/user-ops-indexer/user-ops-indexer-logic/src/repository/paymaster.rs b/user-ops-indexer/user-ops-indexer-logic/src/repository/paymaster.rs index 312d9202d..938a631e1 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/repository/paymaster.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/repository/paymaster.rs @@ -78,18 +78,18 @@ pub async fn list_paymasters( mod tests { use super::*; use crate::repository::tests::get_shared_db; - use alloy::primitives::U160; + use alloy::primitives::address; use pretty_assertions::assert_eq; #[tokio::test] async fn find_paymaster_by_address_ok() { let db = get_shared_db().await; - let addr = Address::from(U160::from(0xe3)); + let addr = address!("00000000000000000000000000000000000000e3"); let item = find_paymaster_by_address(&db, addr).await.unwrap(); assert_eq!(item, None); - let addr = Address::from(U160::from(0xe1)); + let addr = address!("00000000000000000000000000000000000000e1"); let item = find_paymaster_by_address(&db, addr).await.unwrap(); assert_eq!( item, diff --git a/user-ops-indexer/user-ops-indexer-logic/src/repository/user_op.rs b/user-ops-indexer/user-ops-indexer-logic/src/repository/user_op.rs index a0a9284b1..f331c6924 100644 --- a/user-ops-indexer/user-ops-indexer-logic/src/repository/user_op.rs +++ b/user-ops-indexer/user-ops-indexer-logic/src/repository/user_op.rs @@ -239,9 +239,8 @@ WHERE logs.address_hash = $1 mod tests { use super::*; use crate::repository::tests::get_shared_db; - use alloy::primitives::{U160, U256}; + use alloy::primitives::{address, b256, U256}; use pretty_assertions::assert_eq; - use std::str::FromStr; #[tokio::test] async fn find_user_op_by_op_hash_ok() { @@ -276,7 +275,6 @@ mod tests { #[tokio::test] async fn list_user_ops_ok() { let db = get_shared_db().await; - let entrypoint = Address::from_str("0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789").unwrap(); let (items, next_page_token) = list_user_ops( &db, None, None, None, None, None, None, None, None, None, 5000, @@ -312,7 +310,7 @@ mod tests { let (items, next_page_token) = list_user_ops( &db, - Some(Address::from(U160::from(0x0502))), + Some(address!("0000000000000000000000000000000000000502")), None, None, None, @@ -331,10 +329,10 @@ mod tests { [ ListUserOp { hash: B256::from(U256::from(0x6901)), - entry_point: entrypoint, + entry_point: address!("5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"), entry_point_version: EntryPointVersion::V06, block_number: 0, - sender: Address::from(U160::from(0x0502)), + sender: address!("0000000000000000000000000000000000000502"), transaction_hash: B256::from(U256::from(0x0504)), timestamp: "2024-01-01T00:00:00.000000Z".to_string(), status: true, @@ -342,10 +340,10 @@ mod tests { }, ListUserOp { hash: B256::from(U256::from(0x0501)), - entry_point: entrypoint, + entry_point: address!("5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"), entry_point_version: EntryPointVersion::V06, block_number: 0, - sender: Address::from(U160::from(0x0502)), + sender: address!("0000000000000000000000000000000000000502"), transaction_hash: B256::from(U256::from(0x0504)), timestamp: "2024-01-01T00:00:00.000000Z".to_string(), status: true, @@ -359,10 +357,8 @@ mod tests { async fn find_unprocessed_logs_tx_hashes_ok() { let db = get_shared_db().await; - let entrypoint = Address::from_str("0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789").unwrap(); - let topic = - B256::from_str("0x49628fd1471006c1482da88028e9ce4dbb080b815c9b0344d39e5a8e6ec1419f") - .unwrap(); + let entrypoint = address!("5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"); + let topic = b256!("49628fd1471006c1482da88028e9ce4dbb080b815c9b0344d39e5a8e6ec1419f"); let items: Vec = stream_unprocessed_logs_tx_hashes(&db, entrypoint, topic, 100, 150) .await .unwrap()