Skip to content

Commit

Permalink
dev update function
Browse files Browse the repository at this point in the history
  • Loading branch information
ermvrs committed Dec 18, 2024
1 parent 0a4ab77 commit 8db9b51
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ sepolia
sepolia_account
deployment
deployment.md
d
21 changes: 20 additions & 1 deletion src/rosettanet.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub trait IRosettanet<TState> {
fn set_account_class(ref self: TState, class: ClassHash); // Sets account class, this function will be removed after stable account
fn register_matched_addresses(ref self: TState, sn_address: ContractAddress, eth_address: EthAddress); // Will be used during alpha
fn upgrade(ref self: TState, class: ClassHash); // Upgrades contract
fn change_dev(ref self: TState, dev: ContractAddress); // Changes dev
// Read methods
fn get_starknet_address(self: @TState, eth_address: EthAddress) -> ContractAddress;
fn get_ethereum_address(self: @TState, sn_address: ContractAddress) -> EthAddress;
Expand All @@ -33,7 +34,8 @@ pub mod Rosettanet {
AccountDeployed: AccountDeployed,
AccountClassChanged: AccountClassChanged,
Upgraded: Upgraded,
PredeployedAccountRegistered: PredeployedAccountRegistered
PredeployedAccountRegistered: PredeployedAccountRegistered,
DevAddressUpdated: DevAddressUpdated
}

#[derive(Drop, starknet::Event)]
Expand Down Expand Up @@ -69,6 +71,12 @@ pub mod Rosettanet {
pub new_class: ClassHash,
}

#[derive(Drop, starknet::Event)]
pub struct DevAddressUpdated {
pub old: ContractAddress,
pub new: ContractAddress,
}

#[storage]
struct Storage {
sn_to_eth: Map<ContractAddress, EthAddress>,
Expand Down Expand Up @@ -168,6 +176,17 @@ pub mod Rosettanet {
self.emit(Upgraded {upgrader: get_caller_address(), new_class: class});
}

/// Updates dev address
/// # Arguments
/// * `dev` - New dev address
fn change_dev(ref self: ContractState, dev: ContractAddress) {
assert(get_caller_address() == self.dev.read(), 'only dev');

self.dev.write(dev);

self.emit(DevAddressUpdated { old: get_caller_address(), new: dev });
}

/// Returns registered starknet contract address for specified ethereum address
/// returns zero if not registered
/// # Arguments
Expand Down

0 comments on commit 8db9b51

Please sign in to comment.