11#[starknet:: contract]
22pub (crate ) mod DualCaseERC20Mock {
33 use openzeppelin :: access :: ownable :: OwnableComponent ;
4+ use openzeppelin :: token :: erc20 :: interface :: IERC20Metadata ;
45 use openzeppelin :: token :: erc20 :: {DefaultConfig , ERC20Component , ERC20HooksEmptyImpl };
56 use starknet :: ContractAddress ;
7+ use starknet :: storage :: {StoragePointerReadAccess , StoragePointerWriteAccess };
68 use starkware_utils :: interfaces :: mintable_token :: {IMintableToken , IMintableTokenCamelOnly };
79
810 component! (path : ERC20Component , storage : erc20 , event : ERC20Event );
@@ -11,8 +13,6 @@ pub(crate) mod DualCaseERC20Mock {
1113 #[abi(embed_v0)]
1214 impl ERC20Impl = ERC20Component :: ERC20Impl <ContractState >;
1315 #[abi(embed_v0)]
14- impl ERC20MetadataImpl = ERC20Component :: ERC20MetadataImpl <ContractState >;
15- #[abi(embed_v0)]
1616 impl ERC20CamelOnlyImpl = ERC20Component :: ERC20CamelOnlyImpl <ContractState >;
1717 impl InternalImpl = ERC20Component :: InternalImpl <ContractState >;
1818 #[abi(embed_v0)]
@@ -25,6 +25,7 @@ pub(crate) mod DualCaseERC20Mock {
2525 erc20 : ERC20Component :: Storage ,
2626 #[substorage(v0)]
2727 ownable : OwnableComponent :: Storage ,
28+ decimals : u8 ,
2829 }
2930
3031 #[event]
@@ -41,14 +42,31 @@ pub(crate) mod DualCaseERC20Mock {
4142 ref self : ContractState ,
4243 name : ByteArray ,
4344 symbol : ByteArray ,
45+ decimals : u8 ,
4446 initial_supply : u256 ,
4547 owner : ContractAddress ,
4648 ) {
49+ self . decimals. write (decimals );
4750 self . erc20. initializer (name , symbol );
4851 self . erc20. mint (recipient : owner , amount : initial_supply );
4952 self . ownable. initializer (: owner );
5053 }
5154
55+ #[abi(embed_v0)]
56+ impl ERC20CustomMetadataImpl of IERC20Metadata <ContractState > {
57+ fn name (self : @ ContractState ) -> ByteArray {
58+ self . erc20. ERC20_name . read ()
59+ }
60+
61+ fn symbol (self : @ ContractState ) -> ByteArray {
62+ self . erc20. ERC20_symbol . read ()
63+ }
64+
65+ fn decimals (self : @ ContractState ) -> u8 {
66+ self . decimals. read ()
67+ }
68+ }
69+
5270 #[abi(embed_v0)]
5371 impl IMintableTokenImpl of IMintableToken <ContractState > {
5472 fn permissioned_mint (ref self : ContractState , account : ContractAddress , amount : u256 ) {
@@ -82,72 +100,6 @@ pub(crate) mod DualCaseERC20Mock {
82100 }
83101}
84102
85- #[starknet:: contract]
86- mod ERC20DecimalsMock {
87- use openzeppelin :: token :: erc20 :: interface :: IERC20Metadata ;
88- use openzeppelin :: token :: erc20 :: {ERC20Component , ERC20HooksEmptyImpl };
89- use starknet :: ContractAddress ;
90- use starknet :: storage :: {StoragePointerReadAccess , StoragePointerWriteAccess };
91-
92- component! (path : ERC20Component , storage : erc20 , event : ERC20Event );
93-
94- #[abi(embed_v0)]
95- impl ERC20Impl = ERC20Component :: ERC20Impl <ContractState >;
96- #[abi(embed_v0)]
97- impl ERC20CamelOnlyImpl = ERC20Component :: ERC20CamelOnlyImpl <ContractState >;
98- impl ERC20InternalImpl = ERC20Component :: InternalImpl <ContractState >;
99-
100- #[storage]
101- struct Storage {
102- #[substorage(v0)]
103- erc20 : ERC20Component :: Storage ,
104- decimals : u8 ,
105- }
106-
107- #[event]
108- #[derive(Drop , starknet:: Event )]
109- enum Event {
110- #[flat]
111- ERC20Event : ERC20Component :: Event ,
112- }
113-
114- #[constructor]
115- fn constructor (
116- ref self : ContractState ,
117- name : ByteArray ,
118- symbol : ByteArray ,
119- decimals : u8 ,
120- initial_supply : u256 ,
121- recipient : ContractAddress ,
122- ) {
123- self . _set_decimals (decimals );
124- self . erc20. initializer (name , symbol );
125- self . erc20. mint (recipient , initial_supply );
126- }
127-
128- #[abi(embed_v0)]
129- impl ERC20CustomMetadataImpl of IERC20Metadata <ContractState > {
130- fn name (self : @ ContractState ) -> ByteArray {
131- self . erc20. ERC20_name . read ()
132- }
133-
134- fn symbol (self : @ ContractState ) -> ByteArray {
135- self . erc20. ERC20_symbol . read ()
136- }
137-
138- fn decimals (self : @ ContractState ) -> u8 {
139- self . decimals. read ()
140- }
141- }
142-
143- #[generate_trait]
144- impl InternalImpl of InternalTrait {
145- fn _set_decimals (ref self : ContractState , decimals : u8 ) {
146- self . decimals. write (decimals );
147- }
148- }
149- }
150-
151103#[starknet:: contract]
152104pub (crate ) mod SnakeERC20Mock {
153105 use openzeppelin :: token :: erc20 :: {DefaultConfig , ERC20Component , ERC20HooksEmptyImpl };
0 commit comments