From 918360622eb9d6e2d16b391663e67e6b5a8c6065 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:55:46 +0200 Subject: [PATCH] fix(json-abi): correct to-sol for UDVT arrays in structs (#745) * fix(json-abi): correct to-sol for UDVT arrays in structs * chore: clippy --- crates/json-abi/src/param.rs | 4 +- crates/json-abi/src/to_sol.rs | 10 +- crates/json-abi/tests/abi.rs | 2 + .../json-abi/tests/abi/DelegationManager.json | 1767 +++++++++++++++++ .../json-abi/tests/abi/DelegationManager.sol | 131 ++ crates/sol-types/tests/macros/sol/json.rs | 6 + crates/syn-solidity/tests/contracts.rs | 2 +- 7 files changed, 1915 insertions(+), 7 deletions(-) create mode 100644 crates/json-abi/tests/abi/DelegationManager.json create mode 100644 crates/json-abi/tests/abi/DelegationManager.sol diff --git a/crates/json-abi/src/param.rs b/crates/json-abi/src/param.rs index 2868c5bcb4..2766b0eb2b 100644 --- a/crates/json-abi/src/param.rs +++ b/crates/json-abi/src/param.rs @@ -35,7 +35,7 @@ pub struct Param { /// instantiate directly. Use Param::new instead. #[doc(hidden)] pub name: String, - /// If the paramaeter is a compound type (a struct or tuple), a list of the + /// If the parameter is a compound type (a struct or tuple), a list of the /// parameter's components, in order. Empty otherwise pub components: Vec, /// The internal type of the parameter. This type represents the type that @@ -325,7 +325,7 @@ pub struct EventParam { /// Whether the parameter is indexed. Indexed parameters have their /// value, or the hash of their value, stored in the log topics. pub indexed: bool, - /// If the paramaeter is a compound type (a struct or tuple), a list of the + /// If the parameter is a compound type (a struct or tuple), a list of the /// parameter's components, in order. Empty otherwise. Because the /// components are not top-level event params, they will not have an /// `indexed` field. diff --git a/crates/json-abi/src/to_sol.rs b/crates/json-abi/src/to_sol.rs index 4721646578..de13d1102f 100644 --- a/crates/json-abi/src/to_sol.rs +++ b/crates/json-abi/src/to_sol.rs @@ -216,7 +216,7 @@ impl<'a> InternalTypes<'a> { &mut self, internal_type: Option<&'a InternalType>, components: &'a Vec, - real_ty: &'a String, + real_ty: &'a str, ) { match internal_type { None | Some(InternalType::AddressPayable(_) | InternalType::Contract(_)) => {} @@ -229,9 +229,11 @@ impl<'a> InternalTypes<'a> { } } Some(it @ InternalType::Other { contract, ty }) => { - // `Other` is a UDVT if it's not a basic Solidity type and not an array + // `Other` is a UDVT if it's not a basic Solidity type. if let Some(it) = it.other_specifier() { - if it.try_basic_solidity().is_err() && !it.is_array() { + if it.try_basic_solidity().is_err() { + let ty = ty.split('[').next().unwrap(); + let real_ty = real_ty.split('[').next().unwrap(); self.extend_one(contract, It::new(ty, ItKind::Udvt(real_ty))); } } @@ -264,7 +266,7 @@ struct It<'a> { #[derive(PartialEq, Eq)] enum ItKind<'a> { Enum, - Udvt(&'a String), + Udvt(&'a str), Struct(&'a Vec), } diff --git a/crates/json-abi/tests/abi.rs b/crates/json-abi/tests/abi.rs index 544b8c7e08..c3212c227e 100644 --- a/crates/json-abi/tests/abi.rs +++ b/crates/json-abi/tests/abi.rs @@ -96,6 +96,8 @@ fn to_sol_test(path: &str, abi: &JsonAbi, run_solc: bool) { |"ZeroXExchange"| "GaugeController" | "DoubleExponentInterestSetter" | "NamelessParams" // UniswapV1Exchange has return values with the same name. | "UniswapV1Exchange" + // https://github.com/alloy-rs/core/issues/744 + | "DelegationManager" ) { return; } diff --git a/crates/json-abi/tests/abi/DelegationManager.json b/crates/json-abi/tests/abi/DelegationManager.json new file mode 100644 index 0000000000..af934c2e3a --- /dev/null +++ b/crates/json-abi/tests/abi/DelegationManager.json @@ -0,0 +1,1767 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "_strategyManager", + "type": "address", + "internalType": "contract IStrategyManager" + }, + { + "name": "_slasher", + "type": "address", + "internalType": "contract ISlasher" + }, + { + "name": "_eigenPodManager", + "type": "address", + "internalType": "contract IEigenPodManager" + }, + { + "name": "_avsDirectory", + "type": "address", + "internalType": "contract IAVSDirectory" + }, + { + "name": "_allocationManager", + "type": "address", + "internalType": "contract IAllocationManager" + }, + { + "name": "_MIN_WITHDRAWAL_DELAY", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "DELEGATION_APPROVAL_TYPEHASH", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "DOMAIN_TYPEHASH", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "LEGACY_MIN_WITHDRAWAL_DELAY_BLOCKS", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "LEGACY_WITHDRAWALS_TIMESTAMP", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "MIN_WITHDRAWAL_DELAY", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "STAKER_DELEGATION_TYPEHASH", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "allocationManager", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract IAllocationManager" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "avsDirectory", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract IAVSDirectory" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "beaconChainETHStrategy", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract IStrategy" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "calculateCurrentStakerDelegationDigestHash", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "expiry", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "calculateDelegationApprovalDigestHash", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "_delegationApprover", + "type": "address", + "internalType": "address" + }, + { + "name": "approverSalt", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "expiry", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "calculateStakerDelegationDigestHash", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "_stakerNonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "expiry", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "calculateWithdrawalRoot", + "inputs": [ + { + "name": "withdrawal", + "type": "tuple", + "internalType": "struct IDelegationManager.Withdrawal", + "components": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "delegatedTo", + "type": "address", + "internalType": "address" + }, + { + "name": "withdrawer", + "type": "address", + "internalType": "address" + }, + { + "name": "nonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "startTimestamp", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "strategies", + "type": "address[]", + "internalType": "contract IStrategy[]" + }, + { + "name": "delegatedShares", + "type": "uint256[]", + "internalType": "DelegatedShares[]" + } + ] + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "completeQueuedWithdrawal", + "inputs": [ + { + "name": "withdrawal", + "type": "tuple", + "internalType": "struct IDelegationManager.Withdrawal", + "components": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "delegatedTo", + "type": "address", + "internalType": "address" + }, + { + "name": "withdrawer", + "type": "address", + "internalType": "address" + }, + { + "name": "nonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "startTimestamp", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "strategies", + "type": "address[]", + "internalType": "contract IStrategy[]" + }, + { + "name": "delegatedShares", + "type": "uint256[]", + "internalType": "DelegatedShares[]" + } + ] + }, + { + "name": "tokens", + "type": "address[]", + "internalType": "contract IERC20[]" + }, + { + "name": "receiveAsTokens", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "completeQueuedWithdrawals", + "inputs": [ + { + "name": "withdrawals", + "type": "tuple[]", + "internalType": "struct IDelegationManager.Withdrawal[]", + "components": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "delegatedTo", + "type": "address", + "internalType": "address" + }, + { + "name": "withdrawer", + "type": "address", + "internalType": "address" + }, + { + "name": "nonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "startTimestamp", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "strategies", + "type": "address[]", + "internalType": "contract IStrategy[]" + }, + { + "name": "delegatedShares", + "type": "uint256[]", + "internalType": "DelegatedShares[]" + } + ] + }, + { + "name": "tokens", + "type": "address[][]", + "internalType": "contract IERC20[][]" + }, + { + "name": "receiveAsTokens", + "type": "bool[]", + "internalType": "bool[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "cumulativeWithdrawalsQueued", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "decreaseDelegatedShares", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "strategy", + "type": "address", + "internalType": "contract IStrategy" + }, + { + "name": "removedShares", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "delegateTo", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "approverSignatureAndExpiry", + "type": "tuple", + "internalType": "struct ISignatureUtils.SignatureWithExpiry", + "components": [ + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "expiry", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "approverSalt", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "delegateToBySignature", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "stakerSignatureAndExpiry", + "type": "tuple", + "internalType": "struct ISignatureUtils.SignatureWithExpiry", + "components": [ + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "expiry", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "approverSignatureAndExpiry", + "type": "tuple", + "internalType": "struct ISignatureUtils.SignatureWithExpiry", + "components": [ + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "expiry", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "approverSalt", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "delegatedTo", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "delegationApprover", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "delegationApproverSaltIsSpent", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "depositScalingFactors", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "address", + "internalType": "contract IStrategy" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "domainSeparator", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "eigenPodManager", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract IEigenPodManager" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDelegatableShares", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address[]", + "internalType": "contract IStrategy[]" + }, + { + "name": "", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDelegatableShares", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "strategies", + "type": "address[]", + "internalType": "contract IStrategy[]" + } + ], + "outputs": [ + { + "name": "shares", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getOperatorDelegatedShares", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "strategies", + "type": "address[]", + "internalType": "contract IStrategy[]" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "increaseDelegatedShares", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "strategy", + "type": "address", + "internalType": "contract IStrategy" + }, + { + "name": "existingPrincipalShares", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "addedShares", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "initialOwner", + "type": "address", + "internalType": "address" + }, + { + "name": "_pauserRegistry", + "type": "address", + "internalType": "contract IPauserRegistry" + }, + { + "name": "initialPausedStatus", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "isDelegated", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isOperator", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "modifyOperatorDetails", + "inputs": [ + { + "name": "newOperatorDetails", + "type": "tuple", + "internalType": "struct IDelegationManager.OperatorDetails", + "components": [ + { + "name": "__deprecated_earningsReceiver", + "type": "address", + "internalType": "address" + }, + { + "name": "delegationApprover", + "type": "address", + "internalType": "address" + }, + { + "name": "stakerOptOutWindowBlocks", + "type": "uint32", + "internalType": "uint32" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "operatorDelegatedShares", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "address", + "internalType": "contract IStrategy" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "operatorDetails", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct IDelegationManager.OperatorDetails", + "components": [ + { + "name": "__deprecated_earningsReceiver", + "type": "address", + "internalType": "address" + }, + { + "name": "delegationApprover", + "type": "address", + "internalType": "address" + }, + { + "name": "stakerOptOutWindowBlocks", + "type": "uint32", + "internalType": "uint32" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "operatorShares", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "strategy", + "type": "address", + "internalType": "contract IStrategy" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "pause", + "inputs": [ + { + "name": "newPausedStatus", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "pauseAll", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "paused", + "inputs": [ + { + "name": "index", + "type": "uint8", + "internalType": "uint8" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "paused", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "pauserRegistry", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract IPauserRegistry" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "pendingWithdrawals", + "inputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "queueWithdrawals", + "inputs": [ + { + "name": "queuedWithdrawalParams", + "type": "tuple[]", + "internalType": "struct IDelegationManager.QueuedWithdrawalParams[]", + "components": [ + { + "name": "strategies", + "type": "address[]", + "internalType": "contract IStrategy[]" + }, + { + "name": "shares", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "withdrawer", + "type": "address", + "internalType": "address" + } + ] + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32[]", + "internalType": "bytes32[]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerAsOperator", + "inputs": [ + { + "name": "registeringOperatorDetails", + "type": "tuple", + "internalType": "struct IDelegationManager.OperatorDetails", + "components": [ + { + "name": "__deprecated_earningsReceiver", + "type": "address", + "internalType": "address" + }, + { + "name": "delegationApprover", + "type": "address", + "internalType": "address" + }, + { + "name": "stakerOptOutWindowBlocks", + "type": "uint32", + "internalType": "uint32" + } + ] + }, + { + "name": "allocationDelay", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "metadataURI", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setPauserRegistry", + "inputs": [ + { + "name": "newPauserRegistry", + "type": "address", + "internalType": "contract IPauserRegistry" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "slasher", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract ISlasher" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "stakerNonce", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "stakerOptOutWindowBlocks", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "strategyManager", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract IStrategyManager" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "undelegate", + "inputs": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "withdrawalRoots", + "type": "bytes32[]", + "internalType": "bytes32[]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "unpause", + "inputs": [ + { + "name": "newPausedStatus", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "updateOperatorMetadataURI", + "inputs": [ + { + "name": "metadataURI", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint8", + "indexed": false, + "internalType": "uint8" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OperatorDetailsModified", + "inputs": [ + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOperatorDetails", + "type": "tuple", + "indexed": false, + "internalType": "struct IDelegationManager.OperatorDetails", + "components": [ + { + "name": "__deprecated_earningsReceiver", + "type": "address", + "internalType": "address" + }, + { + "name": "delegationApprover", + "type": "address", + "internalType": "address" + }, + { + "name": "stakerOptOutWindowBlocks", + "type": "uint32", + "internalType": "uint32" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OperatorMetadataURIUpdated", + "inputs": [ + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "metadataURI", + "type": "string", + "indexed": false, + "internalType": "string" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OperatorRegistered", + "inputs": [ + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "operatorDetails", + "type": "tuple", + "indexed": false, + "internalType": "struct IDelegationManager.OperatorDetails", + "components": [ + { + "name": "__deprecated_earningsReceiver", + "type": "address", + "internalType": "address" + }, + { + "name": "delegationApprover", + "type": "address", + "internalType": "address" + }, + { + "name": "stakerOptOutWindowBlocks", + "type": "uint32", + "internalType": "uint32" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OperatorSharesDecreased", + "inputs": [ + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "staker", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "strategy", + "type": "address", + "indexed": false, + "internalType": "contract IStrategy" + }, + { + "name": "shares", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OperatorSharesIncreased", + "inputs": [ + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "staker", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "strategy", + "type": "address", + "indexed": false, + "internalType": "contract IStrategy" + }, + { + "name": "shares", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Paused", + "inputs": [ + { + "name": "account", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newPausedStatus", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "PauserRegistrySet", + "inputs": [ + { + "name": "pauserRegistry", + "type": "address", + "indexed": false, + "internalType": "contract IPauserRegistry" + }, + { + "name": "newPauserRegistry", + "type": "address", + "indexed": false, + "internalType": "contract IPauserRegistry" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StakerDelegated", + "inputs": [ + { + "name": "staker", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StakerForceUndelegated", + "inputs": [ + { + "name": "staker", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StakerUndelegated", + "inputs": [ + { + "name": "staker", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Unpaused", + "inputs": [ + { + "name": "account", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newPausedStatus", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "WithdrawalCompleted", + "inputs": [ + { + "name": "withdrawalRoot", + "type": "bytes32", + "indexed": false, + "internalType": "bytes32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "WithdrawalQueued", + "inputs": [ + { + "name": "withdrawalRoot", + "type": "bytes32", + "indexed": false, + "internalType": "bytes32" + }, + { + "name": "withdrawal", + "type": "tuple", + "indexed": false, + "internalType": "struct IDelegationManager.Withdrawal", + "components": [ + { + "name": "staker", + "type": "address", + "internalType": "address" + }, + { + "name": "delegatedTo", + "type": "address", + "internalType": "address" + }, + { + "name": "withdrawer", + "type": "address", + "internalType": "address" + }, + { + "name": "nonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "startTimestamp", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "strategies", + "type": "address[]", + "internalType": "contract IStrategy[]" + }, + { + "name": "delegatedShares", + "type": "uint256[]", + "internalType": "DelegatedShares[]" + } + ] + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "ActivelyDelegated", + "inputs": [] + }, + { + "type": "error", + "name": "AllocationDelaySet", + "inputs": [] + }, + { + "type": "error", + "name": "CallerCannotUndelegate", + "inputs": [] + }, + { + "type": "error", + "name": "CurrentlyPaused", + "inputs": [] + }, + { + "type": "error", + "name": "InputAddressZero", + "inputs": [] + }, + { + "type": "error", + "name": "InputArrayLengthMismatch", + "inputs": [] + }, + { + "type": "error", + "name": "InputArrayLengthZero", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidNewPausedStatus", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidSignatureEIP1271", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidSignatureSigner", + "inputs": [] + }, + { + "type": "error", + "name": "NotActivelyDelegated", + "inputs": [] + }, + { + "type": "error", + "name": "OnlyPauser", + "inputs": [] + }, + { + "type": "error", + "name": "OnlyStrategyManagerOrEigenPodManager", + "inputs": [] + }, + { + "type": "error", + "name": "OnlyUnpauser", + "inputs": [] + }, + { + "type": "error", + "name": "OperatorNotRegistered", + "inputs": [] + }, + { + "type": "error", + "name": "OperatorsCannotUndelegate", + "inputs": [] + }, + { + "type": "error", + "name": "SaltSpent", + "inputs": [] + }, + { + "type": "error", + "name": "SignatureExpired", + "inputs": [] + }, + { + "type": "error", + "name": "StakerOptOutWindowBlocksCannotDecrease", + "inputs": [] + }, + { + "type": "error", + "name": "StakerOptOutWindowBlocksExceedsMax", + "inputs": [] + }, + { + "type": "error", + "name": "WithdrawalDelayExeedsMax", + "inputs": [] + }, + { + "type": "error", + "name": "WithdrawalDelayNotElapsed", + "inputs": [] + }, + { + "type": "error", + "name": "WithdrawalExeedsMax", + "inputs": [] + }, + { + "type": "error", + "name": "WithdrawalNotQueued", + "inputs": [] + }, + { + "type": "error", + "name": "WithdrawerNotCaller", + "inputs": [] + }, + { + "type": "error", + "name": "WithdrawerNotStaker", + "inputs": [] + } +] diff --git a/crates/json-abi/tests/abi/DelegationManager.sol b/crates/json-abi/tests/abi/DelegationManager.sol new file mode 100644 index 0000000000..ba48a7514f --- /dev/null +++ b/crates/json-abi/tests/abi/DelegationManager.sol @@ -0,0 +1,131 @@ +library IDelegationManager { + struct OperatorDetails { + address __deprecated_earningsReceiver; + address delegationApprover; + uint32 stakerOptOutWindowBlocks; + } + struct QueuedWithdrawalParams { + address[] strategies; + uint256[] shares; + address withdrawer; + } + struct Withdrawal { + address staker; + address delegatedTo; + address withdrawer; + uint256 nonce; + uint32 startTimestamp; + address[] strategies; + DelegatedShares[] delegatedShares; + } +} + +library ISignatureUtils { + struct SignatureWithExpiry { + bytes signature; + uint256 expiry; + } +} + +interface DelegationManager { + type DelegatedShares is uint256; + + error ActivelyDelegated(); + error AllocationDelaySet(); + error CallerCannotUndelegate(); + error CurrentlyPaused(); + error InputAddressZero(); + error InputArrayLengthMismatch(); + error InputArrayLengthZero(); + error InvalidNewPausedStatus(); + error InvalidSignatureEIP1271(); + error InvalidSignatureSigner(); + error NotActivelyDelegated(); + error OnlyPauser(); + error OnlyStrategyManagerOrEigenPodManager(); + error OnlyUnpauser(); + error OperatorNotRegistered(); + error OperatorsCannotUndelegate(); + error SaltSpent(); + error SignatureExpired(); + error StakerOptOutWindowBlocksCannotDecrease(); + error StakerOptOutWindowBlocksExceedsMax(); + error WithdrawalDelayExeedsMax(); + error WithdrawalDelayNotElapsed(); + error WithdrawalExeedsMax(); + error WithdrawalNotQueued(); + error WithdrawerNotCaller(); + error WithdrawerNotStaker(); + + event Initialized(uint8 version); + event OperatorDetailsModified(address indexed operator, IDelegationManager.OperatorDetails newOperatorDetails); + event OperatorMetadataURIUpdated(address indexed operator, string metadataURI); + event OperatorRegistered(address indexed operator, IDelegationManager.OperatorDetails operatorDetails); + event OperatorSharesDecreased(address indexed operator, address staker, address strategy, uint256 shares); + event OperatorSharesIncreased(address indexed operator, address staker, address strategy, uint256 shares); + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + event Paused(address indexed account, uint256 newPausedStatus); + event PauserRegistrySet(address pauserRegistry, address newPauserRegistry); + event StakerDelegated(address indexed staker, address indexed operator); + event StakerForceUndelegated(address indexed staker, address indexed operator); + event StakerUndelegated(address indexed staker, address indexed operator); + event Unpaused(address indexed account, uint256 newPausedStatus); + event WithdrawalCompleted(bytes32 withdrawalRoot); + event WithdrawalQueued(bytes32 withdrawalRoot, IDelegationManager.Withdrawal withdrawal); + + function DELEGATION_APPROVAL_TYPEHASH() external view returns (bytes32); + function DOMAIN_TYPEHASH() external view returns (bytes32); + function LEGACY_MIN_WITHDRAWAL_DELAY_BLOCKS() external view returns (uint256); + function LEGACY_WITHDRAWALS_TIMESTAMP() external view returns (uint32); + function MIN_WITHDRAWAL_DELAY() external view returns (uint32); + function STAKER_DELEGATION_TYPEHASH() external view returns (bytes32); + function allocationManager() external view returns (address); + function avsDirectory() external view returns (address); + function beaconChainETHStrategy() external view returns (address); + function calculateCurrentStakerDelegationDigestHash(address staker, address operator, uint256 expiry) external view returns (bytes32); + function calculateDelegationApprovalDigestHash(address staker, address operator, address _delegationApprover, bytes32 approverSalt, uint256 expiry) external view returns (bytes32); + function calculateStakerDelegationDigestHash(address staker, uint256 _stakerNonce, address operator, uint256 expiry) external view returns (bytes32); + function calculateWithdrawalRoot(IDelegationManager.Withdrawal memory withdrawal) external pure returns (bytes32); + function completeQueuedWithdrawal(IDelegationManager.Withdrawal memory withdrawal, address[] memory tokens, bool receiveAsTokens) external; + function completeQueuedWithdrawals(IDelegationManager.Withdrawal[] memory withdrawals, address[][] memory tokens, bool[] memory receiveAsTokens) external; + function cumulativeWithdrawalsQueued(address) external view returns (uint256); + function decreaseDelegatedShares(address staker, address strategy, uint256 removedShares) external; + function delegateTo(address operator, ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry, bytes32 approverSalt) external; + function delegateToBySignature(address staker, address operator, ISignatureUtils.SignatureWithExpiry memory stakerSignatureAndExpiry, ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry, bytes32 approverSalt) external; + function delegatedTo(address) external view returns (address); + function delegationApprover(address operator) external view returns (address); + function delegationApproverSaltIsSpent(address, bytes32) external view returns (bool); + function depositScalingFactors(address, address) external view returns (uint256); + function domainSeparator() external view returns (bytes32); + function eigenPodManager() external view returns (address); + function getDelegatableShares(address staker) external view returns (address[] memory, uint256[] memory); + function getDelegatableShares(address staker, address[] memory strategies) external view returns (uint256[] memory shares); + function getOperatorDelegatedShares(address operator, address[] memory strategies) external view returns (uint256[] memory); + function increaseDelegatedShares(address staker, address strategy, uint256 existingPrincipalShares, uint256 addedShares) external; + function initialize(address initialOwner, address _pauserRegistry, uint256 initialPausedStatus) external; + function isDelegated(address staker) external view returns (bool); + function isOperator(address operator) external view returns (bool); + function modifyOperatorDetails(IDelegationManager.OperatorDetails memory newOperatorDetails) external; + function operatorDelegatedShares(address, address) external view returns (uint256); + function operatorDetails(address operator) external view returns (IDelegationManager.OperatorDetails memory); + function operatorShares(address operator, address strategy) external view returns (uint256); + function owner() external view returns (address); + function pause(uint256 newPausedStatus) external; + function pauseAll() external; + function paused(uint8 index) external view returns (bool); + function paused() external view returns (uint256); + function pauserRegistry() external view returns (address); + function pendingWithdrawals(bytes32) external view returns (bool); + function queueWithdrawals(IDelegationManager.QueuedWithdrawalParams[] memory queuedWithdrawalParams) external returns (bytes32[] memory); + function registerAsOperator(IDelegationManager.OperatorDetails memory registeringOperatorDetails, uint32 allocationDelay, string memory metadataURI) external; + function renounceOwnership() external; + function setPauserRegistry(address newPauserRegistry) external; + function slasher() external view returns (address); + function stakerNonce(address) external view returns (uint256); + function stakerOptOutWindowBlocks(address operator) external view returns (uint256); + function strategyManager() external view returns (address); + function transferOwnership(address newOwner) external; + function undelegate(address staker) external returns (bytes32[] memory withdrawalRoots); + function unpause(uint256 newPausedStatus) external; + function updateOperatorMetadataURI(string memory metadataURI) external; +} \ No newline at end of file diff --git a/crates/sol-types/tests/macros/sol/json.rs b/crates/sol-types/tests/macros/sol/json.rs index af4041f986..4af9b030b6 100644 --- a/crates/sol-types/tests/macros/sol/json.rs +++ b/crates/sol-types/tests/macros/sol/json.rs @@ -227,3 +227,9 @@ fn balancer_v2_vault() { "PoolBalanceChanged(bytes32,address,address[],int256[],uint256[])" ); } + +// TODO: https://github.com/alloy-rs/core/issues/744 +// #[test] +// fn eigenlayer_delegation_manager() { +// sol!(DelegationManager, "../json-abi/tests/abi/DelegationManager.json"); +// } diff --git a/crates/syn-solidity/tests/contracts.rs b/crates/syn-solidity/tests/contracts.rs index f9af4fc875..c9fb26ea03 100644 --- a/crates/syn-solidity/tests/contracts.rs +++ b/crates/syn-solidity/tests/contracts.rs @@ -1,6 +1,6 @@ -#![cfg(feature = "visit")] #![allow(clippy::missing_const_for_fn)] #![allow(missing_docs)] +#![cfg(feature = "visit")] use std::{ fs::{self, DirEntry},