Skip to content

Commit

Permalink
dev: change upgratable to upgradeable
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsh Bajpai authored and Harsh Bajpai committed Oct 17, 2023
1 parent cac6874 commit 03f5be8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions crates/contracts/src/components/upgradeable.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use starknet::{replace_class_syscall, ClassHash};

#[starknet::interface]
trait Iupgradeable<TContractState> {
trait IUpgradeable<TContractState> {
fn upgrade_contract(ref self: TContractState, class_hash: ClassHash);
}

Expand All @@ -17,23 +17,23 @@ mod upgradeable_component {
#[event]
#[derive(Drop, starknet::Event)]
enum Event {
ContractUpgrated: ContractUpgrated
ContractUpgraded: ContractUpgraded
}

#[derive(Drop, starknet::Event)]
struct ContractUpgrated {
struct ContractUpgraded {
new_class_hash: ClassHash
}

#[embeddable_as(upgradeableImpl)]
impl upgradeable<
#[embeddable_as(Upgradeable)]
impl UpgradeableImpl<
TContractState, +HasComponent<TContractState>
> of super::Iupgradeable<ComponentState<TContractState>> {
> of super::IUpgradeable<ComponentState<TContractState>> {
fn upgrade_contract(
ref self: ComponentState<TContractState>, class_hash: starknet::ClassHash
) {
starknet::replace_class_syscall(class_hash);
self.emit(ContractUpgrated { new_class_hash: class_hash });
self.emit(ContractUpgraded { new_class_hash: class_hash });
}
}
}
4 changes: 2 additions & 2 deletions crates/contracts/src/kakarot_core/kakarot.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct ContractAccountStorage {
mod KakarotCore {
use contracts::components::ownable::ownable_component::InternalTrait;
use contracts::components::ownable::{ownable_component};
use contracts::components::upgradeable::Iupgradeable;
use contracts::components::upgradeable::IUpgradeable;
use contracts::components::upgradeable::{upgradeable_component};
use contracts::kakarot_core::interface::IKakarotCore;
use contracts::kakarot_core::interface;
Expand All @@ -44,7 +44,7 @@ mod KakarotCore {

impl OwnableInternalImpl = ownable_component::InternalImpl<ContractState>;

impl upgradeableImpl = upgradeable_component::upgradeableImpl<ContractState>;
impl upgradeableImpl = upgradeable_component::UpgradeableImpl<ContractState>;

#[storage]
struct Storage {
Expand Down
12 changes: 6 additions & 6 deletions crates/contracts/src/tests/test_upgradeable.cairo
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use MockContractUpgradeableV0::HasComponentImpl_upgradeable_component;
use contracts::components::upgradeable::{IupgradeableDispatcher, IupgradeableDispatcherTrait};
use contracts::components::upgradeable::{IUpgradeableDispatcher, IUpgradeableDispatcherTrait};
use contracts::components::upgradeable::{upgradeable_component};
use contracts::tests::utils;
use debug::PrintTrait;
use serde::Serde;
use starknet::{deploy_syscall, ClassHash, ContractAddress, testing};

use upgradeable_component::{upgradeableImpl};
use upgradeable_component::{UpgradeableImpl};

#[starknet::interface]
trait IMockContractUpgradeable<TContractState> {
Expand All @@ -17,10 +17,10 @@ trait IMockContractUpgradeable<TContractState> {
mod MockContractUpgradeableV0 {
use contracts::components::upgradeable::{upgradeable_component};
use super::IMockContractUpgradeable;
component!(path: upgradeable_component, storage: upgradeable, event: upgradeableEvent);
component!(path: upgradeable_component, storage: upgradeable, event: UpgradeableEvent);

#[abi(embed_v0)]
impl upgradeableImpl = upgradeable_component::upgradeableImpl<ContractState>;
impl upgradeableImpl = upgradeable_component::Upgradeable<ContractState>;

#[storage]
struct Storage {
Expand All @@ -31,7 +31,7 @@ mod MockContractUpgradeableV0 {
#[event]
#[derive(Drop, starknet::Event)]
enum Event {
upgradeableEvent: upgradeable_component::Event
UpgradeableEvent: upgradeable_component::Event
}

#[external(v0)]
Expand Down Expand Up @@ -67,7 +67,7 @@ fn test_upgradeable_update_contract() {

let new_class_hash: ClassHash = MockContractUpgradeableV1::TEST_CLASS_HASH.try_into().unwrap();

IupgradeableDispatcher { contract_address: contract_address }.upgrade_contract(new_class_hash);
IUpgradeableDispatcher { contract_address: contract_address }.upgrade_contract(new_class_hash);

let version = IMockContractUpgradeableDispatcher { contract_address: contract_address }
.version();
Expand Down

0 comments on commit 03f5be8

Please sign in to comment.