Skip to content

Commit

Permalink
Merge pull request #18 from push-protocol/audit/issue-11
Browse files Browse the repository at this point in the history
Audit issue11: added upgradeAndCall fn of oz for flexibility
  • Loading branch information
0xNilesh authored Nov 20, 2024
2 parents be79d28 + b612cdb commit 0e4778b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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);
Expand Down Expand Up @@ -156,6 +157,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<ContractState> {
fn upgrade_and_call(ref self: ContractState, new_class_hash: ClassHash, selector: felt252,
calldata: Span<felt252>) -> Span<felt252> {
self.ownable.assert_only_owner();
self.upgradeable.upgrade_and_call(new_class_hash, selector, calldata)
}
}

Expand Down

0 comments on commit 0e4778b

Please sign in to comment.