Skip to content

Commit 78b73af

Browse files
committed
v0.3
1 parent e348aee commit 78b73af

39 files changed

+4031
-1112
lines changed

scripts/build-cairo.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ scripts/starknet-compile.py src --contract-path src::permissioned_erc20::Permis
77
scripts/starknet-compile.py src --contract-path src::token_bridge::TokenBridge cairo_contracts/TokenBridge.sierra
88
scripts/starknet-compile.py src --contract-path openzeppelin::token::erc20::erc20::ERC20 cairo_contracts/ERC20.sierra
99
scripts/starknet-compile.py src --contract-path openzeppelin::token::erc20::presets::erc20votes::ERC20VotesPreset cairo_contracts/ERC20VotesPreset.sierra
10+
scripts/starknet-compile.py src --contract-path openzeppelin::token::erc20_v070::erc20::ERC20 cairo_contracts/ERC20.sierra
1011

1112
popd

scripts/tests.sh

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

2020

2121
printf "${YELLOW}Check Line Length...\n"
22-
scripts/line_length.py -l 110
22+
scripts/line_length.py
2323
if [ $? -ne 0 ]; then
2424
exit 1
2525
fi
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use starknet::ContractAddress;
22

3+
4+
type RoleId = felt252;
5+
36
#[starknet::interface]
47
trait IAccessControl<TContractState> {
5-
fn has_role(self: @TContractState, role: felt252, account: ContractAddress) -> bool;
6-
fn get_role_admin(self: @TContractState, role: felt252) -> felt252;
7-
fn grant_role(ref self: TContractState, role: felt252, account: ContractAddress);
8-
fn revoke_role(ref self: TContractState, role: felt252, account: ContractAddress);
9-
fn renounce_role(ref self: TContractState, role: felt252, account: ContractAddress);
8+
fn has_role(self: @TContractState, role: RoleId, account: ContractAddress) -> bool;
9+
fn get_role_admin(self: @TContractState, role: RoleId) -> RoleId;
1010
}

src/cairo/erc20_interface.cairo

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ trait IERC20<TContractState> {
2121
) -> bool;
2222
}
2323

24+
#[starknet::interface]
25+
trait IERC20CamelOnly<TState> {
26+
fn totalSupply(self: @TState) -> u256;
27+
fn balanceOf(self: @TState, account: ContractAddress) -> u256;
28+
fn transferFrom(
29+
ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256
30+
) -> bool;
31+
}
32+

src/cairo/lib.cairo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ mod permissioned_erc20;
1414
mod test_utils;
1515
mod token_bridge_test;
1616
mod permissioned_token_test;
17+
mod stub_msg_receiver;
18+
mod replaceability_test;

src/cairo/permissioned_erc20.cairo

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ mod PermissionedERC20 {
66
ContractAddress, get_caller_address, contract_address::ContractAddressZeroable,
77
contract_address_const
88
};
9-
use super::super::{erc20_interface::IERC20, mintable_token_interface::IMintableToken};
9+
use super::super::{
10+
erc20_interface::IERC20, erc20_interface::IERC20CamelOnly,
11+
mintable_token_interface::IMintableToken
12+
};
1013

1114

1215
#[storage]
@@ -225,4 +228,24 @@ mod PermissionedERC20 {
225228
self._decrease_allowance(spender, subtracted_value)
226229
}
227230
}
231+
232+
#[external(v0)]
233+
impl ERC20CamelOnlyImpl of IERC20CamelOnly<ContractState> {
234+
fn totalSupply(self: @ContractState) -> u256 {
235+
PermissionedERC20::total_supply(self)
236+
}
237+
238+
fn balanceOf(self: @ContractState, account: ContractAddress) -> u256 {
239+
PermissionedERC20::balance_of(self, account)
240+
}
241+
242+
fn transferFrom(
243+
ref self: ContractState,
244+
sender: ContractAddress,
245+
recipient: ContractAddress,
246+
amount: u256
247+
) -> bool {
248+
PermissionedERC20::transfer_from(ref self, sender, recipient, amount)
249+
}
250+
}
228251
}

src/cairo/permissioned_token_test.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod permissioned_token_test {
1414
IMintableTokenDispatcher, IMintableTokenDispatcherTrait
1515
};
1616
use super::super::erc20_interface::{IERC20Dispatcher, IERC20DispatcherTrait};
17-
use super::super::test_utils::{
17+
use super::super::test_utils::test_utils::{
1818
get_erc20_token, deploy_l2_votes_token, deploy_l2_token, get_mintable_token,
1919
get_l2_token_deployment_calldata
2020
};

src/cairo/replaceability_interface.cairo

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,40 @@ use option::OptionTrait;
44

55
use starknet::class_hash::{ClassHash, Felt252TryIntoClassHash};
66

7+
// Holds EIC data.
8+
// * eic_hash is the EIC class hash.
9+
// * eic_init_data is a span of the EIC init args.
10+
#[derive(Copy, Drop, Serde, PartialEq)]
11+
struct EICData {
12+
eic_hash: ClassHash,
13+
eic_init_data: Span<felt252>
14+
}
15+
16+
// Holds implementation data.
17+
// * impl_hash is the implementation class hash.
18+
// * eic_data is the EIC data when applicable, and empty otherwise.
19+
// * final indicates whether the implementation is finalized.
720
#[derive(Copy, Drop, Serde, PartialEq)]
821
struct ImplementationData {
922
impl_hash: ClassHash,
10-
// TODO we don't need init data without eic_hash, so consolidate these into a more meaningful
11-
// data structure.
12-
eic_hash: ClassHash,
13-
eic_init_data: Span<felt252>,
23+
eic_data: Option<EICData>,
1424
final: bool
1525
}
1626

27+
28+
// starknet_keccak(eic_initialize).
29+
const EIC_INITIALIZE_SELECTOR: felt252 =
30+
1770792127795049777084697565458798191120226931451376769053057094489776256516;
31+
32+
// Duration from implementation is eligible until it expires. (1209600 = 2 weeks).
33+
const IMPLEMENTATION_EXPIRATION: u64 = 1209600;
34+
35+
#[starknet::interface]
36+
trait IEICInitializable<TContractState> {
37+
fn eic_initialize(ref self: TContractState, eic_init_data: Span<felt252>);
38+
}
39+
40+
1741
#[starknet::interface]
1842
trait IReplaceable<TContractState> {
1943
fn get_upgrade_delay(self: @TContractState) -> u64;

0 commit comments

Comments
 (0)