From 544e059f122971d49f432c8bc62697e5fa1cec64 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:18:01 +0530 Subject: [PATCH 1/6] feat(`sol-macro-expander`): make `#[sol(rpc)]` default --- crates/sol-macro-expander/src/expand/contract.rs | 2 +- crates/sol-macro/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/sol-macro-expander/src/expand/contract.rs b/crates/sol-macro-expander/src/expand/contract.rs index 03a4a4e3c..83763855f 100644 --- a/crates/sol-macro-expander/src/expand/contract.rs +++ b/crates/sol-macro-expander/src/expand/contract.rs @@ -34,7 +34,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result]` (contracts and alike only): generates a structs with methods to +/// - `rpc [ = ]` (contracts and alike only): generates a structs with methods to /// construct `eth_call`s to an on-chain contract through Ethereum JSON RPC, similar to the /// default behavior of [`abigen`]. This makes use of the [`alloy-contract`](https://github.com/alloy-rs/alloy) /// crate. From 3c0d94c779be3c38ac8cbcf1d5cab96314b49caa Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:01:36 +0530 Subject: [PATCH 2/6] fix tests --- crates/core/tests/sol.rs | 1 + crates/sol-macro/doctests/contracts.rs | 1 + crates/sol-macro/doctests/json.rs | 2 + crates/sol-types/src/types/error.rs | 1 + crates/sol-types/src/types/interface/mod.rs | 2 + crates/sol-types/tests/macros/sol/abi.rs | 2 +- crates/sol-types/tests/macros/sol/json.rs | 72 +++++++++++++++++---- crates/sol-types/tests/macros/sol/mod.rs | 26 ++++++-- tests/core-sol/src/lib.rs | 2 + 9 files changed, 90 insertions(+), 19 deletions(-) diff --git a/crates/core/tests/sol.rs b/crates/core/tests/sol.rs index 2da1bfe29..82eab52d8 100644 --- a/crates/core/tests/sol.rs +++ b/crates/core/tests/sol.rs @@ -13,6 +13,7 @@ sol! { event MyEvent(uint32 a, uint32 b); error MyError(uint32 a, uint32 b); + #[sol(rpc = false)] contract MyContract { struct MyOtherStruct { uint32 a; diff --git a/crates/sol-macro/doctests/contracts.rs b/crates/sol-macro/doctests/contracts.rs index aa1bd5bed..720d25ba8 100644 --- a/crates/sol-macro/doctests/contracts.rs +++ b/crates/sol-macro/doctests/contracts.rs @@ -6,6 +6,7 @@ sol! { /// /// [the EIP]: https://eips.ethereum.org/EIPS/eip-20 #[derive(Debug, PartialEq, Eq)] + #[sol(rpc = false)] contract ERC20 { mapping(address account => uint256) public balanceOf; diff --git a/crates/sol-macro/doctests/json.rs b/crates/sol-macro/doctests/json.rs index 4ccfcf54d..6ce61b144 100644 --- a/crates/sol-macro/doctests/json.rs +++ b/crates/sol-macro/doctests/json.rs @@ -1,6 +1,7 @@ use alloy_sol_types::{sol, SolCall}; sol!( + #[sol(rpc = false)] MyJsonContract1, r#"[ { @@ -26,6 +27,7 @@ sol!( // This is the same as: sol! { + #[sol(rpc = false)] interface MyJsonContract2 { struct MyStruct { bool[] a; diff --git a/crates/sol-types/src/types/error.rs b/crates/sol-types/src/types/error.rs index b51d31400..e4b911086 100644 --- a/crates/sol-types/src/types/error.rs +++ b/crates/sol-types/src/types/error.rs @@ -499,6 +499,7 @@ mod tests { #[test] fn decode_solidity_no_interface() { sol! { + #[sol(rpc = false)] interface C { #[derive(Debug, PartialEq)] error SenderAddressError(address); diff --git a/crates/sol-types/src/types/interface/mod.rs b/crates/sol-types/src/types/interface/mod.rs index a054cf1e3..0cdfa5141 100644 --- a/crates/sol-types/src/types/interface/mod.rs +++ b/crates/sol-types/src/types/interface/mod.rs @@ -535,6 +535,7 @@ mod tests { #[test] fn contract_error_enum_1() { crate::sol! { + #[sol(rpc = false)] contract C { error Err1(); } @@ -564,6 +565,7 @@ mod tests { fn contract_error_enum_2() { crate::sol! { #[derive(Debug, PartialEq, Eq)] + #[sol(rpc = false)] contract C { error Err1(); error Err2(uint256); diff --git a/crates/sol-types/tests/macros/sol/abi.rs b/crates/sol-types/tests/macros/sol/abi.rs index a3bb4d37b..a3120af89 100644 --- a/crates/sol-types/tests/macros/sol/abi.rs +++ b/crates/sol-types/tests/macros/sol/abi.rs @@ -462,7 +462,7 @@ fn custom() { } sol! { - #![sol(abi)] + #![sol(rpc = false, abi)] #[allow(dead_code)] contract Contract { diff --git a/crates/sol-types/tests/macros/sol/json.rs b/crates/sol-types/tests/macros/sol/json.rs index 8751a598f..227d3deda 100644 --- a/crates/sol-types/tests/macros/sol/json.rs +++ b/crates/sol-types/tests/macros/sol/json.rs @@ -7,7 +7,7 @@ use std::borrow::Cow; #[test] fn large_array() { sol!( - #[sol(abi)] + #[sol(rpc = false, abi)] #[derive(Debug)] LargeArray, "../json-abi/tests/abi/LargeArray.json" @@ -47,7 +47,11 @@ fn large_array() { #[test] fn seaport() { - sol!(Seaport, "../json-abi/tests/abi/Seaport.json"); + sol!( + #[sol(rpc = false)] + Seaport, + "../json-abi/tests/abi/Seaport.json" + ); use Seaport::*; // Constructor with a single argument @@ -71,7 +75,7 @@ fn seaport() { // https://etherscan.io/address/0x1111111254eeb25477b68fb85ed929f73a960582#code sol!( - #[sol(docs = false)] + #![sol(rpc = false, docs = false)] #[derive(Debug)] AggregationRouterV5, "../json-abi/tests/abi/AggregationRouterV5.json" @@ -93,7 +97,11 @@ fn aggregation_router_v5() { #[test] fn uniswap_v3_position() { // https://etherscan.io/address/0x8638fbd429b19249bb3bcf3ec72d07a657e49642#code - sol!(UniswapV3Position, "../json-abi/tests/abi/UniswapV3Position.json"); + sol!( + #[sol(rpc = false)] + UniswapV3Position, + "../json-abi/tests/abi/UniswapV3Position.json" + ); let _ = UniswapV3Position::getLiquidityByRangeCall { pool_: Address::ZERO, @@ -122,7 +130,11 @@ fn uniswap_v3_position() { #[test] fn double_exponent_interest_setter() { // https://etherscan.io/address/0xef2ed07cc7a0825ced8ac1a67f88a0e17414fa6c#code - sol!(DoubleExponentInterestSetter, "../json-abi/tests/abi/DoubleExponentInterestSetter.json"); + sol!( + #[sol(rpc = false)] + DoubleExponentInterestSetter, + "../json-abi/tests/abi/DoubleExponentInterestSetter.json" + ); let _ = DoubleExponentInterestSetter::getInterestRateCall { _0: Address::ZERO, borrowWei: U256::ZERO, @@ -134,7 +146,11 @@ fn double_exponent_interest_setter() { // https://github.com/alloy-rs/core/issues/361 #[test] fn uniswap_v2_factory() { - sol!(UniswapV2Factory, "../json-abi/tests/abi/UniswapV2Factory.json"); + sol!( + #[sol(rpc = false)] + UniswapV2Factory, + "../json-abi/tests/abi/UniswapV2Factory.json" + ); let _ = UniswapV2Factory::PairCreated { token0: Address::ZERO, token1: Address::ZERO, @@ -143,7 +159,11 @@ fn uniswap_v2_factory() { }; } -sol!(GnosisSafe, "../json-abi/tests/abi/GnosisSafe.json"); +sol!( + #![sol(rpc = false)] + GnosisSafe, + "../json-abi/tests/abi/GnosisSafe.json" +); // Fully qualify `SolInterface::NAME` which conflicted with the `NAME` call // https://github.com/alloy-rs/core/issues/361 @@ -157,14 +177,22 @@ fn gnosis_safe() { // https://github.com/alloy-rs/core/issues/371 #[test] fn blur_exchange() { - sol!(BlurExchange, "../json-abi/tests/abi/BlurExchange.json"); + sol!( + #[sol(rpc = false)] + BlurExchange, + "../json-abi/tests/abi/BlurExchange.json" + ); let BlurExchange::NAMECall {} = BlurExchange::NAMECall {}; let BlurExchange::NAMEReturn { _0: _ } = BlurExchange::NAMEReturn { _0: String::new() }; } #[test] fn zerox_exchange_proxy() { - sol!(ZeroXExchangeProxy, "../json-abi/tests/abi/ZeroxExchangeProxy.json"); + sol!( + #[sol(rpc = false)] + ZeroXExchangeProxy, + "../json-abi/tests/abi/ZeroxExchangeProxy.json" + ); } // TODO: Error and event with the same name @@ -173,7 +201,11 @@ fn zerox_exchange_proxy() { #[cfg(any())] fn auction() { // https://etherscan.io/address/0xbb37a88508d464a1bb54cf627d05e39883ae0ef9 - sol!(Auction, "../json-abi/tests/abi/Auction.json"); + sol!( + #[sol(rpc = false)] + Auction, + "../json-abi/tests/abi/Auction.json" + ); } // https://github.com/alloy-rs/core/issues/378 @@ -183,14 +215,22 @@ fn uniswap_v2_factory_with_migrator() { // https://etherscan.io/address/0x1ffbe925f22fca796adf2a63313b8b70b5b1a7f4 // https://etherscan.io/address/0xc1a2706ceb8c21967d5c930c00c8ed16480f7255 - sol!(UniswapV2FactoryWithMigrator, "../json-abi/tests/abi/UniswapV2FactoryWithMigrator.json"); + sol!( + #[sol(rpc = false)] + UniswapV2FactoryWithMigrator, + "../json-abi/tests/abi/UniswapV2FactoryWithMigrator.json" + ); } // https://github.com/alloy-rs/core/issues/379 #[test] fn junkyard() { // https://etherscan.io/address/0x2e4b0f20bdb1caa0886c531256efdaab925dbe72 - sol!(Junkyard, "../json-abi/tests/abi/Junkyard.json"); + sol!( + #[sol(rpc = false)] + Junkyard, + "../json-abi/tests/abi/Junkyard.json" + ); } // Handle missing state mutability in JSON ABI @@ -198,7 +238,11 @@ fn junkyard() { #[test] fn zrx_token() { // https://etherscan.io/address/0xe41d2489571d322189246dafa5ebde1f4699f498#code - sol!(ZRXToken, "../json-abi/tests/abi/ZRXToken.json"); + sol!( + #[sol(rpc = false)] + ZRXToken, + "../json-abi/tests/abi/ZRXToken.json" + ); let _ = ZRXToken::approveCall { _spender: Address::ZERO, _value: U256::ZERO }; assert_eq!(ZRXToken::approveCall::SIGNATURE, "approve(address,uint256)"); @@ -206,7 +250,7 @@ fn zrx_token() { // https://etherscan.io/address/0xBA12222222228d8Ba445958a75a0704d566BF2C8#code sol!( - #![sol(all_derives)] + #![sol(rpc = false, all_derives)] BalancerV2Vault, "../json-abi/tests/abi/BalancerV2Vault.json" ); diff --git a/crates/sol-types/tests/macros/sol/mod.rs b/crates/sol-types/tests/macros/sol/mod.rs index 8e9d0b68d..2300e47fc 100644 --- a/crates/sol-types/tests/macros/sol/mod.rs +++ b/crates/sol-types/tests/macros/sol/mod.rs @@ -174,6 +174,7 @@ fn error() { #[test] fn empty_call() { sol! { + #[sol(rpc = false)] interface WETH { function deposit() external payable; } @@ -193,7 +194,7 @@ fn empty_call() { #[test] fn function_names() { sol! { - #[sol(extra_methods)] + #[sol(rpc = false, extra_methods)] contract LeadingUnderscores { function f(); function _f(); @@ -241,6 +242,7 @@ fn getters() { #[test] fn getter_names() { sol! { + #[sol(rpc = false)] contract Getters { string public value; string[] public array; @@ -269,12 +271,15 @@ fn getter_names() { #[test] fn abigen_sol_multicall() { - sol!("../syn-solidity/tests/contracts/Multicall.sol"); + sol!( + #[sol(rpc = false)] + "../syn-solidity/tests/contracts/Multicall.sol" + ); sol! { // SPDX-License-Identifier: MIT pragma solidity >=0.8.12 <0.9.0; - + #[sol(rpc = false)] interface IMulticall3_2 { struct Call { address target; @@ -433,6 +438,7 @@ fn nested_items() { } #[derive(Debug, PartialEq)] + #[sol(rpc = false)] interface InterfaceTest { function f1(FilAddress memory fAddress, uint256 value) public payable; @@ -470,6 +476,7 @@ fn enum_field_of_struct() { #[test] fn same_names_different_namespaces() { sol! { + #![sol(rpc = false)] library RouterErrors { error ReturnAmountIsNotEnough(); error InvalidMsgValue(); @@ -491,6 +498,7 @@ fn same_names_different_namespaces() { #[test] fn rust_keywords() { sol! { + #[sol(rpc = false)] contract dyn { struct const { bool unsafe; @@ -597,6 +605,7 @@ fn raw_identifiers() { #[test] fn contract_type() { sol! { + #[sol(rpc = false)] interface IERC20 {} function func(IERC20 addr); struct Struct { @@ -686,6 +695,7 @@ fn event_tokenize_fields() { #[test] fn duplicate_attributes() { sol! { + #[sol(rpc = false)] contract TaxableTeamToken is IERC20, Context, Ownable { constructor( string memory name, @@ -722,6 +732,7 @@ fn duplicate_attributes() { fn duplicate_events() { sol! { #[derive(derive_more::Display)] + #[sol(rpc = false)] interface Console { #[display("{val}")] event log(string val); @@ -834,7 +845,7 @@ fn decoder_fixed_array_before_dynamic() { #[test] fn bytecode_attributes() { sol! { - #[sol(bytecode = "1234", deployed_bytecode = "0x5678")] + #[sol(rpc = false, bytecode = "1234", deployed_bytecode = "0x5678")] contract Dummy {} } @@ -913,6 +924,7 @@ fn event_overrides() { fn contract_derive_default() { sol! { #[derive(Debug, Default)] + #[sol(rpc = false)] contract MyContract { function f1(); function f2(); @@ -933,6 +945,7 @@ fn contract_derive_default() { fn contract_namespaces() { mod inner { alloy_sol_types::sol! { + #![sol(rpc = false)] library LibA { struct Struct { uint64 field64; @@ -981,6 +994,7 @@ fn contract_namespaces() { #[test] fn regression_overloads() { sol! { + #[sol(rpc = false)] contract Vm { struct Wallet { uint stuff; @@ -1006,6 +1020,7 @@ fn regression_overloads() { #[test] fn normal_paths() { sol! { + #[sol(rpc = false)] interface I { struct S { uint x; @@ -1021,6 +1036,7 @@ fn normal_paths() { fn regression_nested_namespaced_structs() { mod inner { super::sol! { + #![sol(rpc = false)] library LibA { struct Simple { uint256 x; @@ -1181,6 +1197,7 @@ fn mapping_getters() { sol! { #![sol(all_derives)] + #[sol(rpc = false)] contract TestIbc { /// ConnectionId -> Connection mapping(uint32 => Connection) public connections; @@ -1252,6 +1269,7 @@ fn array_sizes() { uint constant x = 1; uint constant y = x + 1; + #[sol(rpc = false)] contract C { uint constant z = y * 2; diff --git a/tests/core-sol/src/lib.rs b/tests/core-sol/src/lib.rs index 72cd38751..aacd00605 100644 --- a/tests/core-sol/src/lib.rs +++ b/tests/core-sol/src/lib.rs @@ -38,6 +38,7 @@ sol! { } sol! { + #[sol(rpc = false)] contract MyContract { enum MyOtherEnum { A, B @@ -68,6 +69,7 @@ sol! { #[deny(missing_docs)] pub mod no_missing_docs { alloy_core::sol! { + #![sol(rpc = false)] #[allow(missing_docs)] contract Allowed { uint256 public number; From 4dd7c757198a807a83db633c7e24155c5b3e872d Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Sat, 25 Jan 2025 11:04:25 +0530 Subject: [PATCH 3/6] introduce "rpc" feature --- crates/core/Cargo.toml | 2 +- crates/sol-macro-expander/Cargo.toml | 1 + crates/sol-macro-expander/src/expand/contract.rs | 2 +- crates/sol-macro/Cargo.toml | 1 + crates/sol-types/Cargo.toml | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index e9a9945fc..f88e89254 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -50,7 +50,7 @@ std = [ "alloy-rlp?/std", ] nightly = ["alloy-primitives/nightly"] - +rpc = ["alloy-sol-types?/rpc"] dyn-abi = ["sol-types", "dep:alloy-dyn-abi"] json-abi = ["json", "serde", "dep:alloy-json-abi"] json = ["alloy-sol-types?/json"] diff --git a/crates/sol-macro-expander/Cargo.toml b/crates/sol-macro-expander/Cargo.toml index a660de967..0cfa767f3 100644 --- a/crates/sol-macro-expander/Cargo.toml +++ b/crates/sol-macro-expander/Cargo.toml @@ -43,3 +43,4 @@ alloy-json-abi = { workspace = true, optional = true } [features] json = ["dep:alloy-json-abi", "alloy-sol-macro-input/json"] +rpc = [] diff --git a/crates/sol-macro-expander/src/expand/contract.rs b/crates/sol-macro-expander/src/expand/contract.rs index 83763855f..3969ee2ff 100644 --- a/crates/sol-macro-expander/src/expand/contract.rs +++ b/crates/sol-macro-expander/src/expand/contract.rs @@ -34,7 +34,7 @@ pub(super) fn expand(cx: &mut ExpCtxt<'_>, contract: &ItemContract) -> Result Date: Sat, 25 Jan 2025 11:04:50 +0530 Subject: [PATCH 4/6] Revert "fix tests" This reverts commit 3c0d94c779be3c38ac8cbcf1d5cab96314b49caa. --- crates/core/tests/sol.rs | 1 - crates/sol-macro/doctests/contracts.rs | 1 - crates/sol-macro/doctests/json.rs | 2 - crates/sol-types/src/types/error.rs | 1 - crates/sol-types/src/types/interface/mod.rs | 2 - crates/sol-types/tests/macros/sol/abi.rs | 2 +- crates/sol-types/tests/macros/sol/json.rs | 72 ++++----------------- crates/sol-types/tests/macros/sol/mod.rs | 26 ++------ tests/core-sol/src/lib.rs | 2 - 9 files changed, 19 insertions(+), 90 deletions(-) diff --git a/crates/core/tests/sol.rs b/crates/core/tests/sol.rs index 82eab52d8..2da1bfe29 100644 --- a/crates/core/tests/sol.rs +++ b/crates/core/tests/sol.rs @@ -13,7 +13,6 @@ sol! { event MyEvent(uint32 a, uint32 b); error MyError(uint32 a, uint32 b); - #[sol(rpc = false)] contract MyContract { struct MyOtherStruct { uint32 a; diff --git a/crates/sol-macro/doctests/contracts.rs b/crates/sol-macro/doctests/contracts.rs index 720d25ba8..aa1bd5bed 100644 --- a/crates/sol-macro/doctests/contracts.rs +++ b/crates/sol-macro/doctests/contracts.rs @@ -6,7 +6,6 @@ sol! { /// /// [the EIP]: https://eips.ethereum.org/EIPS/eip-20 #[derive(Debug, PartialEq, Eq)] - #[sol(rpc = false)] contract ERC20 { mapping(address account => uint256) public balanceOf; diff --git a/crates/sol-macro/doctests/json.rs b/crates/sol-macro/doctests/json.rs index 6ce61b144..4ccfcf54d 100644 --- a/crates/sol-macro/doctests/json.rs +++ b/crates/sol-macro/doctests/json.rs @@ -1,7 +1,6 @@ use alloy_sol_types::{sol, SolCall}; sol!( - #[sol(rpc = false)] MyJsonContract1, r#"[ { @@ -27,7 +26,6 @@ sol!( // This is the same as: sol! { - #[sol(rpc = false)] interface MyJsonContract2 { struct MyStruct { bool[] a; diff --git a/crates/sol-types/src/types/error.rs b/crates/sol-types/src/types/error.rs index e4b911086..b51d31400 100644 --- a/crates/sol-types/src/types/error.rs +++ b/crates/sol-types/src/types/error.rs @@ -499,7 +499,6 @@ mod tests { #[test] fn decode_solidity_no_interface() { sol! { - #[sol(rpc = false)] interface C { #[derive(Debug, PartialEq)] error SenderAddressError(address); diff --git a/crates/sol-types/src/types/interface/mod.rs b/crates/sol-types/src/types/interface/mod.rs index 0cdfa5141..a054cf1e3 100644 --- a/crates/sol-types/src/types/interface/mod.rs +++ b/crates/sol-types/src/types/interface/mod.rs @@ -535,7 +535,6 @@ mod tests { #[test] fn contract_error_enum_1() { crate::sol! { - #[sol(rpc = false)] contract C { error Err1(); } @@ -565,7 +564,6 @@ mod tests { fn contract_error_enum_2() { crate::sol! { #[derive(Debug, PartialEq, Eq)] - #[sol(rpc = false)] contract C { error Err1(); error Err2(uint256); diff --git a/crates/sol-types/tests/macros/sol/abi.rs b/crates/sol-types/tests/macros/sol/abi.rs index a3120af89..a3bb4d37b 100644 --- a/crates/sol-types/tests/macros/sol/abi.rs +++ b/crates/sol-types/tests/macros/sol/abi.rs @@ -462,7 +462,7 @@ fn custom() { } sol! { - #![sol(rpc = false, abi)] + #![sol(abi)] #[allow(dead_code)] contract Contract { diff --git a/crates/sol-types/tests/macros/sol/json.rs b/crates/sol-types/tests/macros/sol/json.rs index 227d3deda..8751a598f 100644 --- a/crates/sol-types/tests/macros/sol/json.rs +++ b/crates/sol-types/tests/macros/sol/json.rs @@ -7,7 +7,7 @@ use std::borrow::Cow; #[test] fn large_array() { sol!( - #[sol(rpc = false, abi)] + #[sol(abi)] #[derive(Debug)] LargeArray, "../json-abi/tests/abi/LargeArray.json" @@ -47,11 +47,7 @@ fn large_array() { #[test] fn seaport() { - sol!( - #[sol(rpc = false)] - Seaport, - "../json-abi/tests/abi/Seaport.json" - ); + sol!(Seaport, "../json-abi/tests/abi/Seaport.json"); use Seaport::*; // Constructor with a single argument @@ -75,7 +71,7 @@ fn seaport() { // https://etherscan.io/address/0x1111111254eeb25477b68fb85ed929f73a960582#code sol!( - #![sol(rpc = false, docs = false)] + #[sol(docs = false)] #[derive(Debug)] AggregationRouterV5, "../json-abi/tests/abi/AggregationRouterV5.json" @@ -97,11 +93,7 @@ fn aggregation_router_v5() { #[test] fn uniswap_v3_position() { // https://etherscan.io/address/0x8638fbd429b19249bb3bcf3ec72d07a657e49642#code - sol!( - #[sol(rpc = false)] - UniswapV3Position, - "../json-abi/tests/abi/UniswapV3Position.json" - ); + sol!(UniswapV3Position, "../json-abi/tests/abi/UniswapV3Position.json"); let _ = UniswapV3Position::getLiquidityByRangeCall { pool_: Address::ZERO, @@ -130,11 +122,7 @@ fn uniswap_v3_position() { #[test] fn double_exponent_interest_setter() { // https://etherscan.io/address/0xef2ed07cc7a0825ced8ac1a67f88a0e17414fa6c#code - sol!( - #[sol(rpc = false)] - DoubleExponentInterestSetter, - "../json-abi/tests/abi/DoubleExponentInterestSetter.json" - ); + sol!(DoubleExponentInterestSetter, "../json-abi/tests/abi/DoubleExponentInterestSetter.json"); let _ = DoubleExponentInterestSetter::getInterestRateCall { _0: Address::ZERO, borrowWei: U256::ZERO, @@ -146,11 +134,7 @@ fn double_exponent_interest_setter() { // https://github.com/alloy-rs/core/issues/361 #[test] fn uniswap_v2_factory() { - sol!( - #[sol(rpc = false)] - UniswapV2Factory, - "../json-abi/tests/abi/UniswapV2Factory.json" - ); + sol!(UniswapV2Factory, "../json-abi/tests/abi/UniswapV2Factory.json"); let _ = UniswapV2Factory::PairCreated { token0: Address::ZERO, token1: Address::ZERO, @@ -159,11 +143,7 @@ fn uniswap_v2_factory() { }; } -sol!( - #![sol(rpc = false)] - GnosisSafe, - "../json-abi/tests/abi/GnosisSafe.json" -); +sol!(GnosisSafe, "../json-abi/tests/abi/GnosisSafe.json"); // Fully qualify `SolInterface::NAME` which conflicted with the `NAME` call // https://github.com/alloy-rs/core/issues/361 @@ -177,22 +157,14 @@ fn gnosis_safe() { // https://github.com/alloy-rs/core/issues/371 #[test] fn blur_exchange() { - sol!( - #[sol(rpc = false)] - BlurExchange, - "../json-abi/tests/abi/BlurExchange.json" - ); + sol!(BlurExchange, "../json-abi/tests/abi/BlurExchange.json"); let BlurExchange::NAMECall {} = BlurExchange::NAMECall {}; let BlurExchange::NAMEReturn { _0: _ } = BlurExchange::NAMEReturn { _0: String::new() }; } #[test] fn zerox_exchange_proxy() { - sol!( - #[sol(rpc = false)] - ZeroXExchangeProxy, - "../json-abi/tests/abi/ZeroxExchangeProxy.json" - ); + sol!(ZeroXExchangeProxy, "../json-abi/tests/abi/ZeroxExchangeProxy.json"); } // TODO: Error and event with the same name @@ -201,11 +173,7 @@ fn zerox_exchange_proxy() { #[cfg(any())] fn auction() { // https://etherscan.io/address/0xbb37a88508d464a1bb54cf627d05e39883ae0ef9 - sol!( - #[sol(rpc = false)] - Auction, - "../json-abi/tests/abi/Auction.json" - ); + sol!(Auction, "../json-abi/tests/abi/Auction.json"); } // https://github.com/alloy-rs/core/issues/378 @@ -215,22 +183,14 @@ fn uniswap_v2_factory_with_migrator() { // https://etherscan.io/address/0x1ffbe925f22fca796adf2a63313b8b70b5b1a7f4 // https://etherscan.io/address/0xc1a2706ceb8c21967d5c930c00c8ed16480f7255 - sol!( - #[sol(rpc = false)] - UniswapV2FactoryWithMigrator, - "../json-abi/tests/abi/UniswapV2FactoryWithMigrator.json" - ); + sol!(UniswapV2FactoryWithMigrator, "../json-abi/tests/abi/UniswapV2FactoryWithMigrator.json"); } // https://github.com/alloy-rs/core/issues/379 #[test] fn junkyard() { // https://etherscan.io/address/0x2e4b0f20bdb1caa0886c531256efdaab925dbe72 - sol!( - #[sol(rpc = false)] - Junkyard, - "../json-abi/tests/abi/Junkyard.json" - ); + sol!(Junkyard, "../json-abi/tests/abi/Junkyard.json"); } // Handle missing state mutability in JSON ABI @@ -238,11 +198,7 @@ fn junkyard() { #[test] fn zrx_token() { // https://etherscan.io/address/0xe41d2489571d322189246dafa5ebde1f4699f498#code - sol!( - #[sol(rpc = false)] - ZRXToken, - "../json-abi/tests/abi/ZRXToken.json" - ); + sol!(ZRXToken, "../json-abi/tests/abi/ZRXToken.json"); let _ = ZRXToken::approveCall { _spender: Address::ZERO, _value: U256::ZERO }; assert_eq!(ZRXToken::approveCall::SIGNATURE, "approve(address,uint256)"); @@ -250,7 +206,7 @@ fn zrx_token() { // https://etherscan.io/address/0xBA12222222228d8Ba445958a75a0704d566BF2C8#code sol!( - #![sol(rpc = false, all_derives)] + #![sol(all_derives)] BalancerV2Vault, "../json-abi/tests/abi/BalancerV2Vault.json" ); diff --git a/crates/sol-types/tests/macros/sol/mod.rs b/crates/sol-types/tests/macros/sol/mod.rs index 2300e47fc..8e9d0b68d 100644 --- a/crates/sol-types/tests/macros/sol/mod.rs +++ b/crates/sol-types/tests/macros/sol/mod.rs @@ -174,7 +174,6 @@ fn error() { #[test] fn empty_call() { sol! { - #[sol(rpc = false)] interface WETH { function deposit() external payable; } @@ -194,7 +193,7 @@ fn empty_call() { #[test] fn function_names() { sol! { - #[sol(rpc = false, extra_methods)] + #[sol(extra_methods)] contract LeadingUnderscores { function f(); function _f(); @@ -242,7 +241,6 @@ fn getters() { #[test] fn getter_names() { sol! { - #[sol(rpc = false)] contract Getters { string public value; string[] public array; @@ -271,15 +269,12 @@ fn getter_names() { #[test] fn abigen_sol_multicall() { - sol!( - #[sol(rpc = false)] - "../syn-solidity/tests/contracts/Multicall.sol" - ); + sol!("../syn-solidity/tests/contracts/Multicall.sol"); sol! { // SPDX-License-Identifier: MIT pragma solidity >=0.8.12 <0.9.0; - #[sol(rpc = false)] + interface IMulticall3_2 { struct Call { address target; @@ -438,7 +433,6 @@ fn nested_items() { } #[derive(Debug, PartialEq)] - #[sol(rpc = false)] interface InterfaceTest { function f1(FilAddress memory fAddress, uint256 value) public payable; @@ -476,7 +470,6 @@ fn enum_field_of_struct() { #[test] fn same_names_different_namespaces() { sol! { - #![sol(rpc = false)] library RouterErrors { error ReturnAmountIsNotEnough(); error InvalidMsgValue(); @@ -498,7 +491,6 @@ fn same_names_different_namespaces() { #[test] fn rust_keywords() { sol! { - #[sol(rpc = false)] contract dyn { struct const { bool unsafe; @@ -605,7 +597,6 @@ fn raw_identifiers() { #[test] fn contract_type() { sol! { - #[sol(rpc = false)] interface IERC20 {} function func(IERC20 addr); struct Struct { @@ -695,7 +686,6 @@ fn event_tokenize_fields() { #[test] fn duplicate_attributes() { sol! { - #[sol(rpc = false)] contract TaxableTeamToken is IERC20, Context, Ownable { constructor( string memory name, @@ -732,7 +722,6 @@ fn duplicate_attributes() { fn duplicate_events() { sol! { #[derive(derive_more::Display)] - #[sol(rpc = false)] interface Console { #[display("{val}")] event log(string val); @@ -845,7 +834,7 @@ fn decoder_fixed_array_before_dynamic() { #[test] fn bytecode_attributes() { sol! { - #[sol(rpc = false, bytecode = "1234", deployed_bytecode = "0x5678")] + #[sol(bytecode = "1234", deployed_bytecode = "0x5678")] contract Dummy {} } @@ -924,7 +913,6 @@ fn event_overrides() { fn contract_derive_default() { sol! { #[derive(Debug, Default)] - #[sol(rpc = false)] contract MyContract { function f1(); function f2(); @@ -945,7 +933,6 @@ fn contract_derive_default() { fn contract_namespaces() { mod inner { alloy_sol_types::sol! { - #![sol(rpc = false)] library LibA { struct Struct { uint64 field64; @@ -994,7 +981,6 @@ fn contract_namespaces() { #[test] fn regression_overloads() { sol! { - #[sol(rpc = false)] contract Vm { struct Wallet { uint stuff; @@ -1020,7 +1006,6 @@ fn regression_overloads() { #[test] fn normal_paths() { sol! { - #[sol(rpc = false)] interface I { struct S { uint x; @@ -1036,7 +1021,6 @@ fn normal_paths() { fn regression_nested_namespaced_structs() { mod inner { super::sol! { - #![sol(rpc = false)] library LibA { struct Simple { uint256 x; @@ -1197,7 +1181,6 @@ fn mapping_getters() { sol! { #![sol(all_derives)] - #[sol(rpc = false)] contract TestIbc { /// ConnectionId -> Connection mapping(uint32 => Connection) public connections; @@ -1269,7 +1252,6 @@ fn array_sizes() { uint constant x = 1; uint constant y = x + 1; - #[sol(rpc = false)] contract C { uint constant z = y * 2; diff --git a/tests/core-sol/src/lib.rs b/tests/core-sol/src/lib.rs index aacd00605..72cd38751 100644 --- a/tests/core-sol/src/lib.rs +++ b/tests/core-sol/src/lib.rs @@ -38,7 +38,6 @@ sol! { } sol! { - #[sol(rpc = false)] contract MyContract { enum MyOtherEnum { A, B @@ -69,7 +68,6 @@ sol! { #[deny(missing_docs)] pub mod no_missing_docs { alloy_core::sol! { - #![sol(rpc = false)] #[allow(missing_docs)] contract Allowed { uint256 public number; From df839dd56b3c22d73eab4aa0cb512c8a84a61154 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Sat, 25 Jan 2025 11:09:32 +0530 Subject: [PATCH 5/6] doc nits --- crates/sol-macro/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/sol-macro/src/lib.rs b/crates/sol-macro/src/lib.rs index e0b59d6ae..80325f38f 100644 --- a/crates/sol-macro/src/lib.rs +++ b/crates/sol-macro/src/lib.rs @@ -107,10 +107,11 @@ use syn::parse_macro_input; /// This is a limitation of the proc-macro API. /// /// List of all `#[sol(...)]` supported values: -/// - `rpc [ = ]` (contracts and alike only): generates a structs with methods to +/// - `rpc [ = ]` (contracts and alike only): generates a structs with methods to /// construct `eth_call`s to an on-chain contract through Ethereum JSON RPC, similar to the /// default behavior of [`abigen`]. This makes use of the [`alloy-contract`](https://github.com/alloy-rs/alloy) -/// crate. +/// crate. RPC-related code will be automatically generated if the "rpc" feature is enabled in +/// Cargo.toml removing the need to specify this `#[sol(rpc)]` attribute. /// /// N.B: at the time of writing, the `alloy-contract` crate is not yet released on `crates.io`, /// and its API is completely unstable and subject to change, so this feature is not yet From 4bf62d25453ad1058aaf69bcd2f0d87db4d4c16d Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Sat, 25 Jan 2025 11:12:30 +0530 Subject: [PATCH 6/6] #[sol(rpc = false)] for tests This reverts commit 0e9ddada217c8b679031844bbbb3e9b7b1588b7e. --- crates/core/tests/sol.rs | 1 + crates/sol-macro/doctests/contracts.rs | 1 + crates/sol-macro/doctests/json.rs | 2 + crates/sol-types/src/types/error.rs | 1 + crates/sol-types/src/types/interface/mod.rs | 2 + crates/sol-types/tests/macros/sol/abi.rs | 2 +- crates/sol-types/tests/macros/sol/json.rs | 72 +++++++++++++++++---- crates/sol-types/tests/macros/sol/mod.rs | 26 ++++++-- tests/core-sol/src/lib.rs | 2 + 9 files changed, 90 insertions(+), 19 deletions(-) diff --git a/crates/core/tests/sol.rs b/crates/core/tests/sol.rs index 2da1bfe29..82eab52d8 100644 --- a/crates/core/tests/sol.rs +++ b/crates/core/tests/sol.rs @@ -13,6 +13,7 @@ sol! { event MyEvent(uint32 a, uint32 b); error MyError(uint32 a, uint32 b); + #[sol(rpc = false)] contract MyContract { struct MyOtherStruct { uint32 a; diff --git a/crates/sol-macro/doctests/contracts.rs b/crates/sol-macro/doctests/contracts.rs index aa1bd5bed..720d25ba8 100644 --- a/crates/sol-macro/doctests/contracts.rs +++ b/crates/sol-macro/doctests/contracts.rs @@ -6,6 +6,7 @@ sol! { /// /// [the EIP]: https://eips.ethereum.org/EIPS/eip-20 #[derive(Debug, PartialEq, Eq)] + #[sol(rpc = false)] contract ERC20 { mapping(address account => uint256) public balanceOf; diff --git a/crates/sol-macro/doctests/json.rs b/crates/sol-macro/doctests/json.rs index 4ccfcf54d..6ce61b144 100644 --- a/crates/sol-macro/doctests/json.rs +++ b/crates/sol-macro/doctests/json.rs @@ -1,6 +1,7 @@ use alloy_sol_types::{sol, SolCall}; sol!( + #[sol(rpc = false)] MyJsonContract1, r#"[ { @@ -26,6 +27,7 @@ sol!( // This is the same as: sol! { + #[sol(rpc = false)] interface MyJsonContract2 { struct MyStruct { bool[] a; diff --git a/crates/sol-types/src/types/error.rs b/crates/sol-types/src/types/error.rs index b51d31400..e4b911086 100644 --- a/crates/sol-types/src/types/error.rs +++ b/crates/sol-types/src/types/error.rs @@ -499,6 +499,7 @@ mod tests { #[test] fn decode_solidity_no_interface() { sol! { + #[sol(rpc = false)] interface C { #[derive(Debug, PartialEq)] error SenderAddressError(address); diff --git a/crates/sol-types/src/types/interface/mod.rs b/crates/sol-types/src/types/interface/mod.rs index a054cf1e3..0cdfa5141 100644 --- a/crates/sol-types/src/types/interface/mod.rs +++ b/crates/sol-types/src/types/interface/mod.rs @@ -535,6 +535,7 @@ mod tests { #[test] fn contract_error_enum_1() { crate::sol! { + #[sol(rpc = false)] contract C { error Err1(); } @@ -564,6 +565,7 @@ mod tests { fn contract_error_enum_2() { crate::sol! { #[derive(Debug, PartialEq, Eq)] + #[sol(rpc = false)] contract C { error Err1(); error Err2(uint256); diff --git a/crates/sol-types/tests/macros/sol/abi.rs b/crates/sol-types/tests/macros/sol/abi.rs index a3bb4d37b..a3120af89 100644 --- a/crates/sol-types/tests/macros/sol/abi.rs +++ b/crates/sol-types/tests/macros/sol/abi.rs @@ -462,7 +462,7 @@ fn custom() { } sol! { - #![sol(abi)] + #![sol(rpc = false, abi)] #[allow(dead_code)] contract Contract { diff --git a/crates/sol-types/tests/macros/sol/json.rs b/crates/sol-types/tests/macros/sol/json.rs index 8751a598f..227d3deda 100644 --- a/crates/sol-types/tests/macros/sol/json.rs +++ b/crates/sol-types/tests/macros/sol/json.rs @@ -7,7 +7,7 @@ use std::borrow::Cow; #[test] fn large_array() { sol!( - #[sol(abi)] + #[sol(rpc = false, abi)] #[derive(Debug)] LargeArray, "../json-abi/tests/abi/LargeArray.json" @@ -47,7 +47,11 @@ fn large_array() { #[test] fn seaport() { - sol!(Seaport, "../json-abi/tests/abi/Seaport.json"); + sol!( + #[sol(rpc = false)] + Seaport, + "../json-abi/tests/abi/Seaport.json" + ); use Seaport::*; // Constructor with a single argument @@ -71,7 +75,7 @@ fn seaport() { // https://etherscan.io/address/0x1111111254eeb25477b68fb85ed929f73a960582#code sol!( - #[sol(docs = false)] + #![sol(rpc = false, docs = false)] #[derive(Debug)] AggregationRouterV5, "../json-abi/tests/abi/AggregationRouterV5.json" @@ -93,7 +97,11 @@ fn aggregation_router_v5() { #[test] fn uniswap_v3_position() { // https://etherscan.io/address/0x8638fbd429b19249bb3bcf3ec72d07a657e49642#code - sol!(UniswapV3Position, "../json-abi/tests/abi/UniswapV3Position.json"); + sol!( + #[sol(rpc = false)] + UniswapV3Position, + "../json-abi/tests/abi/UniswapV3Position.json" + ); let _ = UniswapV3Position::getLiquidityByRangeCall { pool_: Address::ZERO, @@ -122,7 +130,11 @@ fn uniswap_v3_position() { #[test] fn double_exponent_interest_setter() { // https://etherscan.io/address/0xef2ed07cc7a0825ced8ac1a67f88a0e17414fa6c#code - sol!(DoubleExponentInterestSetter, "../json-abi/tests/abi/DoubleExponentInterestSetter.json"); + sol!( + #[sol(rpc = false)] + DoubleExponentInterestSetter, + "../json-abi/tests/abi/DoubleExponentInterestSetter.json" + ); let _ = DoubleExponentInterestSetter::getInterestRateCall { _0: Address::ZERO, borrowWei: U256::ZERO, @@ -134,7 +146,11 @@ fn double_exponent_interest_setter() { // https://github.com/alloy-rs/core/issues/361 #[test] fn uniswap_v2_factory() { - sol!(UniswapV2Factory, "../json-abi/tests/abi/UniswapV2Factory.json"); + sol!( + #[sol(rpc = false)] + UniswapV2Factory, + "../json-abi/tests/abi/UniswapV2Factory.json" + ); let _ = UniswapV2Factory::PairCreated { token0: Address::ZERO, token1: Address::ZERO, @@ -143,7 +159,11 @@ fn uniswap_v2_factory() { }; } -sol!(GnosisSafe, "../json-abi/tests/abi/GnosisSafe.json"); +sol!( + #![sol(rpc = false)] + GnosisSafe, + "../json-abi/tests/abi/GnosisSafe.json" +); // Fully qualify `SolInterface::NAME` which conflicted with the `NAME` call // https://github.com/alloy-rs/core/issues/361 @@ -157,14 +177,22 @@ fn gnosis_safe() { // https://github.com/alloy-rs/core/issues/371 #[test] fn blur_exchange() { - sol!(BlurExchange, "../json-abi/tests/abi/BlurExchange.json"); + sol!( + #[sol(rpc = false)] + BlurExchange, + "../json-abi/tests/abi/BlurExchange.json" + ); let BlurExchange::NAMECall {} = BlurExchange::NAMECall {}; let BlurExchange::NAMEReturn { _0: _ } = BlurExchange::NAMEReturn { _0: String::new() }; } #[test] fn zerox_exchange_proxy() { - sol!(ZeroXExchangeProxy, "../json-abi/tests/abi/ZeroxExchangeProxy.json"); + sol!( + #[sol(rpc = false)] + ZeroXExchangeProxy, + "../json-abi/tests/abi/ZeroxExchangeProxy.json" + ); } // TODO: Error and event with the same name @@ -173,7 +201,11 @@ fn zerox_exchange_proxy() { #[cfg(any())] fn auction() { // https://etherscan.io/address/0xbb37a88508d464a1bb54cf627d05e39883ae0ef9 - sol!(Auction, "../json-abi/tests/abi/Auction.json"); + sol!( + #[sol(rpc = false)] + Auction, + "../json-abi/tests/abi/Auction.json" + ); } // https://github.com/alloy-rs/core/issues/378 @@ -183,14 +215,22 @@ fn uniswap_v2_factory_with_migrator() { // https://etherscan.io/address/0x1ffbe925f22fca796adf2a63313b8b70b5b1a7f4 // https://etherscan.io/address/0xc1a2706ceb8c21967d5c930c00c8ed16480f7255 - sol!(UniswapV2FactoryWithMigrator, "../json-abi/tests/abi/UniswapV2FactoryWithMigrator.json"); + sol!( + #[sol(rpc = false)] + UniswapV2FactoryWithMigrator, + "../json-abi/tests/abi/UniswapV2FactoryWithMigrator.json" + ); } // https://github.com/alloy-rs/core/issues/379 #[test] fn junkyard() { // https://etherscan.io/address/0x2e4b0f20bdb1caa0886c531256efdaab925dbe72 - sol!(Junkyard, "../json-abi/tests/abi/Junkyard.json"); + sol!( + #[sol(rpc = false)] + Junkyard, + "../json-abi/tests/abi/Junkyard.json" + ); } // Handle missing state mutability in JSON ABI @@ -198,7 +238,11 @@ fn junkyard() { #[test] fn zrx_token() { // https://etherscan.io/address/0xe41d2489571d322189246dafa5ebde1f4699f498#code - sol!(ZRXToken, "../json-abi/tests/abi/ZRXToken.json"); + sol!( + #[sol(rpc = false)] + ZRXToken, + "../json-abi/tests/abi/ZRXToken.json" + ); let _ = ZRXToken::approveCall { _spender: Address::ZERO, _value: U256::ZERO }; assert_eq!(ZRXToken::approveCall::SIGNATURE, "approve(address,uint256)"); @@ -206,7 +250,7 @@ fn zrx_token() { // https://etherscan.io/address/0xBA12222222228d8Ba445958a75a0704d566BF2C8#code sol!( - #![sol(all_derives)] + #![sol(rpc = false, all_derives)] BalancerV2Vault, "../json-abi/tests/abi/BalancerV2Vault.json" ); diff --git a/crates/sol-types/tests/macros/sol/mod.rs b/crates/sol-types/tests/macros/sol/mod.rs index 8e9d0b68d..2300e47fc 100644 --- a/crates/sol-types/tests/macros/sol/mod.rs +++ b/crates/sol-types/tests/macros/sol/mod.rs @@ -174,6 +174,7 @@ fn error() { #[test] fn empty_call() { sol! { + #[sol(rpc = false)] interface WETH { function deposit() external payable; } @@ -193,7 +194,7 @@ fn empty_call() { #[test] fn function_names() { sol! { - #[sol(extra_methods)] + #[sol(rpc = false, extra_methods)] contract LeadingUnderscores { function f(); function _f(); @@ -241,6 +242,7 @@ fn getters() { #[test] fn getter_names() { sol! { + #[sol(rpc = false)] contract Getters { string public value; string[] public array; @@ -269,12 +271,15 @@ fn getter_names() { #[test] fn abigen_sol_multicall() { - sol!("../syn-solidity/tests/contracts/Multicall.sol"); + sol!( + #[sol(rpc = false)] + "../syn-solidity/tests/contracts/Multicall.sol" + ); sol! { // SPDX-License-Identifier: MIT pragma solidity >=0.8.12 <0.9.0; - + #[sol(rpc = false)] interface IMulticall3_2 { struct Call { address target; @@ -433,6 +438,7 @@ fn nested_items() { } #[derive(Debug, PartialEq)] + #[sol(rpc = false)] interface InterfaceTest { function f1(FilAddress memory fAddress, uint256 value) public payable; @@ -470,6 +476,7 @@ fn enum_field_of_struct() { #[test] fn same_names_different_namespaces() { sol! { + #![sol(rpc = false)] library RouterErrors { error ReturnAmountIsNotEnough(); error InvalidMsgValue(); @@ -491,6 +498,7 @@ fn same_names_different_namespaces() { #[test] fn rust_keywords() { sol! { + #[sol(rpc = false)] contract dyn { struct const { bool unsafe; @@ -597,6 +605,7 @@ fn raw_identifiers() { #[test] fn contract_type() { sol! { + #[sol(rpc = false)] interface IERC20 {} function func(IERC20 addr); struct Struct { @@ -686,6 +695,7 @@ fn event_tokenize_fields() { #[test] fn duplicate_attributes() { sol! { + #[sol(rpc = false)] contract TaxableTeamToken is IERC20, Context, Ownable { constructor( string memory name, @@ -722,6 +732,7 @@ fn duplicate_attributes() { fn duplicate_events() { sol! { #[derive(derive_more::Display)] + #[sol(rpc = false)] interface Console { #[display("{val}")] event log(string val); @@ -834,7 +845,7 @@ fn decoder_fixed_array_before_dynamic() { #[test] fn bytecode_attributes() { sol! { - #[sol(bytecode = "1234", deployed_bytecode = "0x5678")] + #[sol(rpc = false, bytecode = "1234", deployed_bytecode = "0x5678")] contract Dummy {} } @@ -913,6 +924,7 @@ fn event_overrides() { fn contract_derive_default() { sol! { #[derive(Debug, Default)] + #[sol(rpc = false)] contract MyContract { function f1(); function f2(); @@ -933,6 +945,7 @@ fn contract_derive_default() { fn contract_namespaces() { mod inner { alloy_sol_types::sol! { + #![sol(rpc = false)] library LibA { struct Struct { uint64 field64; @@ -981,6 +994,7 @@ fn contract_namespaces() { #[test] fn regression_overloads() { sol! { + #[sol(rpc = false)] contract Vm { struct Wallet { uint stuff; @@ -1006,6 +1020,7 @@ fn regression_overloads() { #[test] fn normal_paths() { sol! { + #[sol(rpc = false)] interface I { struct S { uint x; @@ -1021,6 +1036,7 @@ fn normal_paths() { fn regression_nested_namespaced_structs() { mod inner { super::sol! { + #![sol(rpc = false)] library LibA { struct Simple { uint256 x; @@ -1181,6 +1197,7 @@ fn mapping_getters() { sol! { #![sol(all_derives)] + #[sol(rpc = false)] contract TestIbc { /// ConnectionId -> Connection mapping(uint32 => Connection) public connections; @@ -1252,6 +1269,7 @@ fn array_sizes() { uint constant x = 1; uint constant y = x + 1; + #[sol(rpc = false)] contract C { uint constant z = y * 2; diff --git a/tests/core-sol/src/lib.rs b/tests/core-sol/src/lib.rs index 72cd38751..aacd00605 100644 --- a/tests/core-sol/src/lib.rs +++ b/tests/core-sol/src/lib.rs @@ -38,6 +38,7 @@ sol! { } sol! { + #[sol(rpc = false)] contract MyContract { enum MyOtherEnum { A, B @@ -68,6 +69,7 @@ sol! { #[deny(missing_docs)] pub mod no_missing_docs { alloy_core::sol! { + #![sol(rpc = false)] #[allow(missing_docs)] contract Allowed { uint256 public number;