Skip to content

Commit 7fa04f8

Browse files
committed
feat(replaceability): replace_to only_upgrader
1 parent 5de28fd commit 7fa04f8

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

packages/utils/src/components/replaceability/replaceability.cairo

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ pub(crate) mod ReplaceabilityComponent {
107107
fn replace_to(
108108
ref self: ComponentState<TContractState>, implementation_data: ImplementationData,
109109
) {
110-
// The call is restricted to the upgrade governor.
110+
// The call is restricted to the upgrade agent or upgrade governor.
111111
let roles_comp = get_dep_component!(@self, Roles);
112-
roles_comp.only_upgrade_governor();
112+
roles_comp.only_upgrader();
113113

114114
// Validate implementation is not finalized.
115115
assert!(!self.is_finalized(), "{}", ReplaceErrors::FINALIZED);
@@ -136,22 +136,19 @@ pub(crate) mod ReplaceabilityComponent {
136136
}
137137

138138
// Handle EIC.
139-
match implementation_data.eic_data {
140-
Option::Some(eic_data) => {
141-
// Wrap the calldata as a span, as preparation for the library_call_syscall
142-
// invocation.
143-
let mut calldata_wrapper = ArrayTrait::new();
144-
eic_data.eic_init_data.serialize(ref calldata_wrapper);
145-
146-
// Invoke the EIC's initialize function as a library call.
147-
let res = library_call_syscall(
148-
class_hash: eic_data.eic_hash,
149-
function_selector: EIC_INITIALIZE_SELECTOR,
150-
calldata: calldata_wrapper.span(),
151-
);
152-
assert!(res.is_ok(), "{}", ReplaceErrors::EIC_LIB_CALL_FAILED);
153-
},
154-
Option::None(()) => {},
139+
if let Option::Some(eic_data) = implementation_data.eic_data {
140+
// Wrap the calldata as a span, as preparation for the library_call_syscall
141+
// invocation.
142+
let mut calldata_wrapper = ArrayTrait::new();
143+
eic_data.eic_init_data.serialize(ref calldata_wrapper);
144+
145+
// Invoke the EIC's initialize function as a library call.
146+
let res = library_call_syscall(
147+
class_hash: eic_data.eic_hash,
148+
function_selector: EIC_INITIALIZE_SELECTOR,
149+
calldata: calldata_wrapper.span(),
150+
);
151+
assert!(res.is_ok(), "{}", ReplaceErrors::EIC_LIB_CALL_FAILED);
155152
}
156153

157154
// Replace the class hash.

packages/utils/src/components/replaceability/test.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ mod ReplaceabilityTests {
312312
}
313313

314314
#[test]
315-
#[should_panic(expected: "ONLY_UPGRADE_GOVERNOR")]
315+
#[should_panic(expected: "ONLY_UPGRADER")]
316316
fn test_replace_to_not_upgrade_governor() {
317317
let replaceable_dispatcher = deploy_replaceability_mock();
318318
let contract_address = replaceable_dispatcher.contract_address;

0 commit comments

Comments
 (0)