Skip to content

Commit

Permalink
feat: added upgradeAndCall fn for flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNilesh committed Nov 20, 2024
1 parent e5ff018 commit b612cdb
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 @@ -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);
Expand Down Expand Up @@ -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<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 b612cdb

Please sign in to comment.