From b612cdb6f8b2fbf0a2f8cbb3ae5383d4bd5dd44e Mon Sep 17 00:00:00 2001 From: Nilesh Gupta Date: Wed, 20 Nov 2024 18:25:57 +0530 Subject: [PATCH] feat: added upgradeAndCall fn for flexibility --- src/lib.cairo | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.cairo b/src/lib.cairo index ae40474..62d2e03 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -25,6 +25,7 @@ pub mod PushComm { use openzeppelin::access::ownable::OwnableComponent; use openzeppelin::upgrades::UpgradeableComponent; use openzeppelin::upgrades::interface::IUpgradeable; + use openzeppelin::upgrades::interface::IUpgradeAndCall; component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent); @@ -170,6 +171,15 @@ pub mod PushComm { fn upgrade(ref self: ContractState, new_class_hash: ClassHash) { self.ownable.assert_only_owner(); self.upgradeable.upgrade(new_class_hash); + } + } + + #[abi(embed_v0)] + impl UpgradeAndCallImpl of IUpgradeAndCall { + fn upgrade_and_call(ref self: ContractState, new_class_hash: ClassHash, selector: felt252, + calldata: Span) -> Span { + self.ownable.assert_only_owner(); + self.upgradeable.upgrade_and_call(new_class_hash, selector, calldata) } }