diff --git a/crates/json-abi/tests/abi/UniswapV3Position.json b/crates/json-abi/tests/abi/UniswapV3Position.json new file mode 100644 index 0000000000..beaee32d7f --- /dev/null +++ b/crates/json-abi/tests/abi/UniswapV3Position.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"contract IUniswapV3Pool","name":"pool_","type":"IUniswapV3Pool"},{"internalType":"address","name":"self_","type":"address"},{"internalType":"int24","name":"lowerTick_","type":"int24"},{"internalType":"int24","name":"upperTick_","type":"int24"}],"name":"getLiquidityByRange","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"self_","type":"address"},{"internalType":"int24","name":"lowerTick_","type":"int24"},{"internalType":"int24","name":"upperTick_","type":"int24"}],"name":"getPositionId","outputs":[{"internalType":"bytes32","name":"positionId","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"int24","name":"lowerTick","type":"int24"},{"internalType":"int24","name":"upperTick","type":"int24"},{"internalType":"uint24","name":"feeTier","type":"uint24"}],"internalType":"struct Range[]","name":"currentRanges_","type":"tuple[]"},{"components":[{"internalType":"int24","name":"lowerTick","type":"int24"},{"internalType":"int24","name":"upperTick","type":"int24"},{"internalType":"uint24","name":"feeTier","type":"uint24"}],"internalType":"struct Range","name":"range_","type":"tuple"}],"name":"rangeExists","outputs":[{"internalType":"bool","name":"ok","type":"bool"},{"internalType":"uint256","name":"index","type":"uint256"}],"stateMutability":"pure","type":"function"}] \ No newline at end of file diff --git a/crates/sol-types/tests/sol.rs b/crates/sol-types/tests/sol.rs index 966b56fd18..d65c51c6ee 100644 --- a/crates/sol-types/tests/sol.rs +++ b/crates/sol-types/tests/sol.rs @@ -147,6 +147,7 @@ fn error() { assert_eq!(e.abi_encoded_size(), 64); } +// Handle empty call encoding/decoding correctly // https://github.com/alloy-rs/core/issues/158 #[test] fn empty_call() { @@ -409,6 +410,7 @@ fn nested_items() { assert_eq!(f2Call::SIGNATURE, "f2((bytes,bool))"); } +// Allow enums as fields of structs // https://github.com/alloy-rs/core/issues/319 #[test] fn enum_field_of_struct() { @@ -456,9 +458,8 @@ fn rust_keywords() { } } -// TODO +// Translate contract types to `address` // https://github.com/alloy-rs/core/issues/347 -// https://github.com/alloy-rs/core/issues/351 #[test] #[cfg(TODO)] fn contract_type() { @@ -471,6 +472,7 @@ fn contract_type() { } } +// Correctly identify whether a type is dynamic // https://github.com/alloy-rs/core/issues/352 #[test] fn word_dynarray_event() { @@ -548,11 +550,11 @@ fn abigen_json_seaport() { ); } +// Handle multiple identical error objects in the JSON ABI // https://github.com/alloy-rs/core/issues/344 #[test] #[cfg(feature = "json")] fn abigen_json_aggregation_router_v5() { - // There's multiple identical error objects in the JSON ABI sol!( AggregationRouterV5, "../json-abi/tests/abi/AggregationRouterV5.json" @@ -568,6 +570,27 @@ fn abigen_json_aggregation_router_v5() { ); } +// Handle contract types in JSON ABI +// https://github.com/alloy-rs/core/issues/351 +#[test] +#[cfg(feature = "json")] +fn abigen_json_uniswap_v3_position() { + sol!( + UniswapV3Position, + "../json-abi/tests/abi/UniswapV3Position.json" + ); + + let _ = UniswapV3Position::getPositionIdCall { + self_: Address::ZERO, + lowerTick_: 0, + upperTick_: 0, + }; + assert_eq!( + UniswapV3Position::getPositionIdCall::SIGNATURE, + "getPositionId(address,int24,int24)" + ); +} + #[test] fn eip712_encode_type_nesting() { sol! {