Skip to content

Commit af9b15e

Browse files
bowenli86ypatil12
authored andcommitted
feat: enable AVS update metadata uri (#354)
* feat:enable AVS update metadata uri * test: add unit test
1 parent fd28375 commit af9b15e

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ broadcast
2222

2323
# Deployment tools
2424
/data
25+
.idea/
2526

2627
# Certora Outputs
2728
.certora_internal/

src/contracts/core/DelegationManager.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
139139
emit OperatorMetadataURIUpdated(msg.sender, metadataURI);
140140
}
141141

142+
/**
143+
* @notice Called by an avs to emit an `AVSMetadataURIUpdated` event indicating the information has updated.
144+
* @param metadataURI The URI for metadata associated with an avs
145+
*/
146+
function updateAVSMetadataURI(string calldata metadataURI) external {
147+
emit AVSMetadataURIUpdated(msg.sender, metadataURI);
148+
}
149+
142150
/**
143151
* @notice Caller delegates their stake to an operator.
144152
* @param operator The account (`msg.sender`) is delegating its assets to for use in serving applications built on EigenLayer.

src/contracts/interfaces/IDelegationManager.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ interface IDelegationManager is ISignatureUtils {
116116
*/
117117
event OperatorMetadataURIUpdated(address indexed operator, string metadataURI);
118118

119+
/**
120+
* @notice Emitted when @param avs indicates that they are updating their MetadataURI string
121+
* @dev Note that these strings are *never stored in storage* and are instead purely emitted in events for off-chain indexing
122+
*/
123+
event AVSMetadataURIUpdated(address indexed avs, string metadataURI);
124+
119125
/// @notice Emitted whenever an operator's shares are increased for a given strategy. Note that shares is the delta in the operator's shares.
120126
event OperatorSharesIncreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);
121127

@@ -173,9 +179,17 @@ interface IDelegationManager is ISignatureUtils {
173179
/**
174180
* @notice Called by an operator to emit an `OperatorMetadataURIUpdated` event indicating the information has updated.
175181
* @param metadataURI The URI for metadata associated with an operator
182+
* @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event
176183
*/
177184
function updateOperatorMetadataURI(string calldata metadataURI) external;
178185

186+
/**
187+
* @notice Called by an AVS to emit an `AVSMetadataURIUpdated` event indicating the information has updated.
188+
* @param metadataURI The URI for metadata associated with an AVS
189+
* @dev Note that the `metadataURI` is *never stored * and is only emitted in the `AVSMetadataURIUpdated` event
190+
*/
191+
function updateAVSMetadataURI(string calldata metadataURI) external;
192+
179193
/**
180194
* @notice Caller delegates their stake to an operator.
181195
* @param operator The account (`msg.sender`) is delegating its assets to for use in serving applications built on EigenLayer.

src/test/events/IDelegationManagerEvents.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ interface IDelegationManagerEvents {
2020
*/
2121
event OperatorMetadataURIUpdated(address indexed operator, string metadataURI);
2222

23+
/**
24+
* @notice Emitted when @param avs indicates that they are updating their MetadataURI string
25+
* @dev Note that these strings are *never stored in storage* and are instead purely emitted in events for off-chain indexing
26+
*/
27+
event AVSMetadataURIUpdated(address indexed avs, string metadataURI);
28+
2329
/// @notice Emitted whenever an operator's shares are increased for a given strategy
2430
event OperatorSharesIncreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);
2531

src/test/mocks/DelegationManagerMock.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ contract DelegationManagerMock is IDelegationManager, Test {
2828

2929
function updateOperatorMetadataURI(string calldata /*metadataURI*/) external pure {}
3030

31+
function updateAVSMetadataURI(string calldata /*metadataURI*/) external pure {}
32+
3133
function delegateTo(address operator, SignatureWithExpiry memory /*approverSignatureAndExpiry*/, bytes32 /*approverSalt*/) external {
3234
delegatedTo[msg.sender] = operator;
3335
}

src/test/unit/DelegationUnit.t.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag
4242
// reused in various tests. in storage to help handle stack-too-deep errors
4343
address defaultStaker = cheats.addr(uint256(123_456_789));
4444
address defaultOperator = address(this);
45+
address defaultAVS = address(this);
4546

4647
IStrategy public constant beaconChainETHStrategy = IStrategy(0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0);
4748

@@ -580,6 +581,15 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU
580581
emit OperatorMetadataURIUpdated(defaultOperator, metadataURI);
581582
delegationManager.updateOperatorMetadataURI(metadataURI);
582583
}
584+
585+
// @notice Tests that an avs who calls `updateAVSMetadataURI` will correctly see an `AVSMetadataURIUpdated` event emitted with their input
586+
function testFuzz_UpdateAVSMetadataURI(string memory metadataURI) public {
587+
// call `updateAVSMetadataURI` and check for event
588+
cheats.prank(defaultAVS);
589+
cheats.expectEmit(true, true, true, true, address(delegationManager));
590+
emit AVSMetadataURIUpdated(defaultAVS, metadataURI);
591+
delegationManager.updateAVSMetadataURI(metadataURI);
592+
}
583593
}
584594

585595
contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests {

0 commit comments

Comments
 (0)