eigenlayer_contract_deployer/
permissions.rs1use alloy_primitives::Address;
2use alloy_sol_types::SolCall;
3use color_eyre::eyre::Result;
4use tracing::{error, info};
5
6use crate::core::DeployedCoreContracts;
7use crate::deploy::DeployedContracts;
8
9use crate::bindings::{AllocationManager, IAllocationManager, IServiceManager};
10use crate::helpers::get_receipt;
11
12pub async fn setup_avs_permissions(
17 core_contracts: &DeployedCoreContracts,
18 deployed_contracts: &DeployedContracts,
19 signer_wallet: &alloy_provider::RootProvider,
20 deployer_address: Address,
21 avs_metadata_uri: String,
22) -> Result<()> {
23 let service_manager_address = deployed_contracts.squaring_service_manager;
24 let registry_coordinator_address = deployed_contracts.registry_coordinator;
25 let allocation_manager_address = core_contracts.allocation_manager;
26 let slasher_address = deployed_contracts.instant_slasher;
27
28 let service_manager = IServiceManager::new(service_manager_address, signer_wallet.clone());
30 let allocation_manager =
31 IAllocationManager::new(allocation_manager_address, signer_wallet.clone());
32
33 info!("Setting Deployer Account as appointee for setAVSRegistrar on AllocationManager");
35 let set_appointee_call = service_manager.setAppointee(
36 deployer_address,
37 allocation_manager_address,
38 AllocationManager::setAVSRegistrarCall::SELECTOR.into(),
39 );
40 let set_appointee_receipt = get_receipt(set_appointee_call).await?;
41 if !set_appointee_receipt.status() {
42 error!("Failed to set deployer as appointee for setAVSRegistrar on AllocationManager");
43 return Err(color_eyre::eyre::eyre!(
44 "Failed to set deployer as appointee for setAVSRegistrar on AllocationManager"
45 ));
46 }
47
48 info!("Setting AVS Registrar");
50 let set_avs_registrar_call = allocation_manager.setAVSRegistrar(
51 deployed_contracts.squaring_service_manager,
52 deployed_contracts.registry_coordinator,
53 );
54 let set_avs_registrar_receipt = get_receipt(set_avs_registrar_call).await?;
55 if !set_avs_registrar_receipt.status() {
56 error!("Failed to set AVS registrar");
57 return Err(color_eyre::eyre::eyre!("Failed to set AVS registrar"));
58 }
59
60 info!("Setting Deployer Account as appointee for createOperatorSets on AllocationManager");
62 let set_appointee_call = service_manager.setAppointee(
63 deployer_address,
64 allocation_manager_address,
65 AllocationManager::createOperatorSetsCall::SELECTOR.into(),
66 );
67 let set_appointee_receipt = get_receipt(set_appointee_call).await?;
68 if !set_appointee_receipt.status() {
69 error!("Failed to set deployer as appointee for createOperatorSets on AllocationManager");
70 return Err(color_eyre::eyre::eyre!(
71 "Failed to set deployer as appointee for createOperatorSets on AllocationManager"
72 ));
73 }
74
75 info!("Setting Registry Coordinator as appointee for createOperatorSets on AllocationManager");
77 let set_appointee_call = service_manager.setAppointee(
78 registry_coordinator_address,
79 allocation_manager_address,
80 AllocationManager::createOperatorSetsCall::SELECTOR.into(),
81 );
82 let set_appointee_receipt = get_receipt(set_appointee_call).await?;
83 if !set_appointee_receipt.status() {
84 error!(
85 "Failed to set registry coordinator as appointee for createOperatorSets on AllocationManager"
86 );
87 return Err(color_eyre::eyre::eyre!(
88 "Failed to set registry coordinator as appointee for createOperatorSets on AllocationManager"
89 ));
90 }
91
92 info!("Setting Instant Slasher as appointee for slashOperator on AllocationManager");
94 let set_appointee_call = service_manager.setAppointee(
95 slasher_address,
96 allocation_manager_address,
97 AllocationManager::slashOperatorCall::SELECTOR.into(),
98 );
99 let set_appointee_receipt = get_receipt(set_appointee_call).await?;
100 if !set_appointee_receipt.status() {
101 error!("Failed to set slasher as appointee for slashOperator on AllocationManager");
102 return Err(color_eyre::eyre::eyre!(
103 "Failed to set slasher as appointee for slashOperator on AllocationManager"
104 ));
105 }
106
107 info!("Setting Deployer Account as appointee for updateAVSMetadataURI on AllocationManager");
109 let set_appointee_call = service_manager.setAppointee(
110 deployer_address,
111 allocation_manager_address,
112 AllocationManager::updateAVSMetadataURICall::SELECTOR.into(),
113 );
114 let set_appointee_receipt = get_receipt(set_appointee_call).await?;
115 if !set_appointee_receipt.status() {
116 error!("Failed to set deployer as appointee for updateAVSMetadataURI on AllocationManager");
117 return Err(color_eyre::eyre::eyre!(
118 "Failed to set deployer as appointee for updateAVSMetadataURI on AllocationManager"
119 ));
120 }
121
122 info!("Updating AVS Metadata URI");
124 let update_avs_metadata_uri_call =
125 allocation_manager.updateAVSMetadataURI(service_manager_address, avs_metadata_uri);
126 let update_avs_metadata_uri_receipt = get_receipt(update_avs_metadata_uri_call).await?;
127 if !update_avs_metadata_uri_receipt.status() {
128 error!("Failed to update AVS metadata URI");
129 return Err(color_eyre::eyre::eyre!("Failed to update AVS metadata URI"));
130 }
131
132 Ok(())
133}