Skip to content

Commit 2c2729d

Browse files
committed
v0.8.1
1 parent c787ec8 commit 2c2729d

23 files changed

+80
-45
lines changed
20 KB
Binary file not shown.

scripts/cairo-format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
99
EXECUTABLE = os.path.join(ROOT_DIR, ".downloads", "cairo", "bin", "cairo-format")
10-
EXPECTED_EXECUTABLE_VERSION = "cairo-format 2.10.0-rc.0"
10+
EXPECTED_EXECUTABLE_VERSION = "cairo-format 2.10.1"
1111

1212

1313
def main():

scripts/cairo-test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
99
EXECUTABLE = os.path.join(ROOT_DIR, ".downloads", "cairo", "bin", "cairo-test")
10-
EXPECTED_EXECUTABLE_VERSION = "cairo-test 2.10.0-rc.0"
10+
EXPECTED_EXECUTABLE_VERSION = "cairo-test 2.10.1"
1111

1212

1313
def main():

scripts/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ printf "${COLOR_OFF}"
3030
mkdir -p .downloads
3131
cd .downloads
3232

33-
wget -c https://github.com/starkware-libs/cairo/releases/download/v2.10.0-rc.0/release-x86_64-unknown-linux-musl.tar.gz -O - | tar -xz
33+
wget -c https://github.com/starkware-libs/cairo/releases/download/v2.10.1/release-x86_64-unknown-linux-musl.tar.gz -O - | tar -xz
3434
curl https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.8.20+commit.a1b79de6 -o solc-0.8.20 && chmod +x solc-0.8.20
3535

3636
cd ..

scripts/starknet-compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
99
EXECUTABLE = os.path.join(ROOT_DIR, ".downloads", "cairo", "bin", "starknet-compile")
10-
EXPECTED_EXECUTABLE_VERSION = "starknet-compile 2.10.0-rc.0"
10+
EXPECTED_EXECUTABLE_VERSION = "starknet-compile 2.10.1"
1111

1212

1313
def main():

src/cairo/err_msg.cairo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mod AccessErrors {
2323
const ONLY_MINTER: felt252 = 'MINTER_ONLY';
2424
const ONLY_SELF_CAN_RENOUNCE: felt252 = 'ONLY_SELF_CAN_RENOUNCE';
2525
const GOV_ADMIN_CANNOT_RENOUNCE: felt252 = 'GOV_ADMIN_CANNOT_SELF_REMOVE';
26+
const SEC_ADMIN_CANNOT_RENOUNCE: felt252 = 'SEC_ADMIN_CANNOT_SELF_REMOVE';
2627
}
2728

2829
mod ReplaceErrors {

src/cairo/strk/erc20_lockable.cairo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ mod ERC20Lockable {
101101
/// Emitted when tokens are moved from address `from` to address `to`.
102102
#[derive(Copy, Drop, PartialEq, starknet::Event)]
103103
struct Transfer {
104-
#[key]
104+
// #[key] - Not indexed, to maintain backward compatibility.
105105
from: ContractAddress,
106-
#[key]
106+
// #[key] - Not indexed, to maintain backward compatibility.
107107
to: ContractAddress,
108108
value: u256,
109109
}
@@ -112,9 +112,9 @@ mod ERC20Lockable {
112112
/// to [approve](approve). `value` is the new allowance.
113113
#[derive(Copy, Drop, PartialEq, starknet::Event)]
114114
struct Approval {
115-
#[key]
115+
// #[key] - Not indexed, to maintain backward compatibility.
116116
owner: ContractAddress,
117-
#[key]
117+
// #[key] - Not indexed, to maintain backward compatibility.
118118
spender: ContractAddress,
119119
value: u256,
120120
}

src/cairo/token_bridge.cairo

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod TokenBridge {
99
use super::super::err_msg::AccessErrors::{
1010
CALLER_MISSING_ROLE, ZERO_ADDRESS, ALREADY_INITIALIZED, ONLY_APP_GOVERNOR, ONLY_OPERATOR,
1111
ONLY_TOKEN_ADMIN, ONLY_UPGRADE_GOVERNOR, ONLY_SECURITY_ADMIN, ONLY_SECURITY_AGENT,
12-
GOV_ADMIN_CANNOT_RENOUNCE,
12+
GOV_ADMIN_CANNOT_RENOUNCE, SEC_ADMIN_CANNOT_RENOUNCE,
1313
};
1414
use super::super::err_msg::ERC20Errors as ERC20Errors;
1515
use super::super::err_msg::ReplaceErrors as ReplaceErrors;
@@ -46,10 +46,8 @@ mod TokenBridge {
4646
OperatorAdded, OperatorRemoved, TokenAdminAdded, TokenAdminRemoved, UpgradeGovernorAdded,
4747
UpgradeGovernorRemoved,
4848
};
49-
use super::super::erc20_interface::{IERC20Dispatcher, IERC20DispatcherTrait};
50-
use super::super::mintable_token_interface::{
51-
IMintableTokenDispatcher, IMintableTokenDispatcherTrait,
52-
};
49+
use src::erc20_interface::{IERC20Dispatcher, IERC20DispatcherTrait};
50+
use src::mintable_token_interface::{IMintableTokenDispatcher, IMintableTokenDispatcherTrait};
5351

5452
use super::super::replaceability_interface::{
5553
ImplementationData, IReplaceable, IReplaceableDispatcher, IReplaceableDispatcherTrait,
@@ -62,7 +60,7 @@ mod TokenBridge {
6260

6361
const WITHDRAW_MESSAGE: felt252 = 0;
6462
const CONTRACT_IDENTITY: felt252 = 'STARKGATE';
65-
const CONTRACT_VERSION: felt252 = 2;
63+
const CONTRACT_VERSION: felt252 = '2.0.1';
6664

6765
const DEFAULT_DAILY_WITHDRAW_LIMIT_PCT: u8 = 5;
6866

@@ -452,6 +450,11 @@ mod TokenBridge {
452450
fn get_l1_token(self: @ContractState, l2_token: ContractAddress) -> EthAddress {
453451
self.l2_l1_token_map.read(l2_token)
454452
}
453+
454+
fn get_l1_bridge(self: @ContractState) -> EthAddress {
455+
self.l1_bridge.read()
456+
}
457+
455458
fn get_l2_token(self: @ContractState, l1_token: EthAddress) -> ContractAddress {
456459
self.l1_l2_token_map.read(l1_token)
457460
}
@@ -827,6 +830,7 @@ mod TokenBridge {
827830
let event = Event::SecurityAdminRemoved(
828831
SecurityAdminRemoved { removed_account: account, removed_by: get_caller_address() },
829832
);
833+
self.prevent_self_removal(:account, error: SEC_ADMIN_CANNOT_RENOUNCE);
830834
self._revoke_role_and_emit(role: SECURITY_ADMIN, :account, :event);
831835
}
832836

@@ -858,6 +862,7 @@ mod TokenBridge {
858862
removed_account: account, removed_by: get_caller_address(),
859863
},
860864
);
865+
self.prevent_self_removal(:account, error: GOV_ADMIN_CANNOT_RENOUNCE);
861866
self._revoke_role_and_emit(role: GOVERNANCE_ADMIN, :account, :event);
862867
}
863868

@@ -905,21 +910,20 @@ mod TokenBridge {
905910
self._revoke_role_and_emit(role: UPGRADE_GOVERNOR, :account, :event);
906911
}
907912

908-
// TODO - change the fn name to renounce_role when we can have modularity.
909-
// TODO - change to GOVERNANCE_ADMIN_CANNOT_SELF_REMOVE when the 32 characters limitations
910-
// is off.
911913
fn renounce(ref self: ContractState, role: RoleId) {
912914
assert(role != GOVERNANCE_ADMIN, GOV_ADMIN_CANNOT_RENOUNCE);
915+
assert(role != SECURITY_ADMIN, SEC_ADMIN_CANNOT_RENOUNCE);
913916
self.renounce_role(:role, account: get_caller_address())
914-
// TODO add another event? Currently there are two events when a role is removed but
915-
// only one if it was renounced.
916917
}
917918
}
918919

919920

920921
#[generate_trait]
921922
impl RolesInternal of _RolesInternal {
922-
// TODO - change the fn name to _grant_role when we can have modularity.
923+
fn prevent_self_removal(self: @ContractState, account: ContractAddress, error: felt252) {
924+
assert(account != get_caller_address(), error);
925+
}
926+
923927
fn _grant_role_and_emit(
924928
ref self: ContractState, role: RoleId, account: ContractAddress, event: Event,
925929
) {
@@ -930,7 +934,6 @@ mod TokenBridge {
930934
}
931935
}
932936

933-
// TODO - change the fn name to _revoke_role when we can have modularity.
934937
fn _revoke_role_and_emit(
935938
ref self: ContractState, role: RoleId, account: ContractAddress, event: Event,
936939
) {

src/cairo/token_bridge_interface.cairo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ trait ITokenBridge<TContractState> {
77
fn get_version(self: @TContractState) -> felt252;
88
fn get_identity(self: @TContractState) -> felt252;
99
fn get_l1_token(self: @TContractState, l2_token: ContractAddress) -> EthAddress;
10+
fn get_l1_bridge(self: @TContractState) -> EthAddress;
1011
fn get_l2_token(self: @TContractState, l1_token: EthAddress) -> ContractAddress;
1112
fn get_remaining_withdrawal_quota(self: @TContractState, l1_token: EthAddress) -> u256;
1213
fn initiate_withdraw(ref self: TContractState, l1_recipient: EthAddress, amount: u256);

src/cairo/token_bridge_test.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ mod token_bridge_test {
5858
};
5959

6060
const EXPECTED_CONTRACT_IDENTITY: felt252 = 'STARKGATE';
61-
const EXPECTED_CONTRACT_VERSION: felt252 = 2;
61+
const EXPECTED_CONTRACT_VERSION: felt252 = '2.0.1';
6262

6363
const DEFAULT_DEPOSITOR_ETH_ADDRESS: felt252 = 7;
6464

0 commit comments

Comments
 (0)