Skip to content

Commit

Permalink
remove upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
codeWhizperer committed Feb 12, 2024
1 parent e5b7154 commit 533c8a7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.9.0#861

[[package]]
name = "snforge_std"
version = "0.17.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.17.0#63f7f0b533a3d852e2b60214e0f40b99c9dcbb26"
version = "0.17.1"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.17.1#f3237f2325d5fd31fb066cbc18f279839521090c"

[[package]]
name = "token_bound_accounts"
Expand Down
2 changes: 1 addition & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ casm = true

[dependencies]
starknet = "2.5.3"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.17.0" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.17.1" }
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.9.0" }
[tool.snforge]
# exit_first = true
33 changes: 0 additions & 33 deletions src/registry/registry.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,19 @@ mod Registry {

use token_bound_accounts::interfaces::IERC721::{IERC721DispatcherTrait, IERC721Dispatcher};
use token_bound_accounts::interfaces::IRegistry::IRegistry;
use openzeppelin::{
access::ownable::OwnableComponent, upgrades::{UpgradeableComponent, interface::IUpgradeable}
};

component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent);
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);

// add an owner
#[abi(embed_v0)]
impl OwnableImpl = OwnableComponent::OwnableImpl<ContractState>;
impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>;
// make it upgradable
impl UpgradeableInternalImpl = UpgradeableComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
admin: ContractAddress,
registry_deployed_accounts: LegacyMap<
(ContractAddress, u256), u8
>, // tracks no. of deployed accounts by registry for an NFT
#[substorage(v0)]
ownable: OwnableComponent::Storage,
#[substorage(v0)]
upgradeable: UpgradeableComponent::Storage,
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
AccountCreated: AccountCreated,
#[flat]
OwnableEvent: OwnableComponent::Event,
#[flat]
UpgradeableEvent: UpgradeableComponent::Event,
}

/// @notice Emitted when a new tokenbound account is deployed/created
Expand All @@ -64,18 +43,6 @@ mod Registry {
token_id: u256,
}

#[constructor]
fn constructor(ref self: ContractState, admin: ContractAddress) {
self.admin.write(admin)
}

#[abi(embed_v0)]
impl UpgradeableImpl of IUpgradeable<ContractState> {
fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {
self.ownable.assert_only_owner();
self.upgradeable._upgrade(new_class_hash);
}
}

#[abi(embed_v0)]
impl IRegistryImpl of IRegistry<ContractState> {
Expand Down

0 comments on commit 533c8a7

Please sign in to comment.