Skip to content

Commit

Permalink
✨ publish "upgrade" method
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkac committed Sep 2, 2024
1 parent a9c1acf commit 8d6f766
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/contracts/project.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ mod Project {
use openzeppelin::access::ownable::OwnableComponent;
// Upgradable
use openzeppelin::upgrades::upgradeable::UpgradeableComponent;
use openzeppelin::upgrades::interface::IUpgradeable;
//SRC5
use openzeppelin::introspection::src5::SRC5Component;
// ERC1155
Expand Down Expand Up @@ -444,6 +445,18 @@ mod Project {
}
}

#[abi(embed_v0)]
impl UpgradeableImpl of IUpgradeable<ContractState> {
fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {
// This function can only be called by the owner
let isOwner = self.accesscontrol.has_role(OWNER_ROLE, get_caller_address());
assert!(isOwner, "Only Owner can upgrade");

// Replace the class hash upgrading the contract
self.upgradeable._upgrade(new_class_hash);
}
}

#[generate_trait]
impl InternalImpl of InternalTrait {
fn _balance_of(self: @ContractState, account: ContractAddress, token_id: u256) -> u256 {
Expand Down

0 comments on commit 8d6f766

Please sign in to comment.