diff --git a/contracts/cairo/src/ERC20.cairo b/contracts/cairo/src/ERC20.cairo index f78c647f..0a76f9b9 100644 --- a/contracts/cairo/src/ERC20.cairo +++ b/contracts/cairo/src/ERC20.cairo @@ -78,11 +78,11 @@ mod ERC20 { 18 } - fn total_supply(self: @ContractState) -> u256 { + fn totalSupply(self: @ContractState) -> u256 { self.ERC20_total_supply.read() } - fn balance_of(self: @ContractState, account: ContractAddress) -> u256 { + fn balanceOf(self: @ContractState, account: ContractAddress) -> u256 { self.ERC20_balances.read(account) } @@ -98,7 +98,7 @@ mod ERC20 { true } - fn transfer_from( + fn transferFrom( ref self: ContractState, sender: ContractAddress, recipient: ContractAddress, diff --git a/contracts/cairo/src/escrow.cairo b/contracts/cairo/src/escrow.cairo index 2c722185..b593eecc 100644 --- a/contracts/cairo/src/escrow.cairo +++ b/contracts/cairo/src/escrow.cairo @@ -80,8 +80,8 @@ mod Escrow { orders_used: LegacyMap::, herodotus_facts_registry_contract: ContractAddress, eth_transfer_contract: EthAddress, // our transfer contract in L1 - mm_ethereum_contract: EthAddress, - mm_starknet_contract: ContractAddress, + mm_ethereum_wallet: EthAddress, + mm_starknet_wallet: ContractAddress, native_token_eth_starknet: ContractAddress } @@ -90,8 +90,8 @@ mod Escrow { ref self: ContractState, herodotus_facts_registry_contract: ContractAddress, eth_transfer_contract: EthAddress, - mm_ethereum_contract: EthAddress, - mm_starknet_contract: ContractAddress, + mm_ethereum_wallet: EthAddress, + mm_starknet_wallet: ContractAddress, native_token_eth_starknet: ContractAddress ) { let mut unsafe_state = Ownable::unsafe_new_contract_state(); @@ -100,8 +100,8 @@ mod Escrow { self.current_order_id.write(0); self.herodotus_facts_registry_contract.write(herodotus_facts_registry_contract); self.eth_transfer_contract.write(eth_transfer_contract); - self.mm_ethereum_contract.write(mm_ethereum_contract); - self.mm_starknet_contract.write(mm_starknet_contract); + self.mm_ethereum_wallet.write(mm_ethereum_wallet); + self.mm_starknet_wallet.write(mm_starknet_wallet); self.native_token_eth_starknet.write(native_token_eth_starknet); } @@ -121,7 +121,7 @@ mod Escrow { // TODO: add allowance ? IERC20Dispatcher { contract_address: self.native_token_eth_starknet.read() } - .transfer_from(get_caller_address(), get_contract_address(), order.amount); + .transferFrom(get_caller_address(), get_contract_address(), order.amount); self .emit( @@ -146,8 +146,7 @@ mod Escrow { fn withdraw(ref self: ContractState, order_id: u256, block: u256, slot: u256,) { assert( - self.mm_starknet_contract.read() == get_caller_address(), - 'Only MM_STARKNET_CONTRACT' + self.mm_starknet_wallet.read() == get_caller_address(), 'Only MM_STARKNET_CONTRACT' ); assert(!self.orders_used.read(order_id), 'Order already withdrawed'); @@ -196,9 +195,9 @@ mod Escrow { // - add fee // - confirm slot values against local order IERC20Dispatcher { contract_address: self.native_token_eth_starknet.read() } - .transfer(self.mm_starknet_contract.read(), amount); + .transfer(self.mm_starknet_wallet.read(), amount); - self.emit(Withdraw { order_id, address: self.mm_starknet_contract.read(), amount }); + self.emit(Withdraw { order_id, address: self.mm_starknet_wallet.read(), amount }); } fn get_herodotus_facts_registry_contract(self: @ContractState) -> ContractAddress { @@ -210,11 +209,11 @@ mod Escrow { } fn get_mm_ethereum_contract(self: @ContractState) -> EthAddress { - self.mm_ethereum_contract.read() + self.mm_ethereum_wallet.read() } fn get_mm_starknet_contract(self: @ContractState) -> ContractAddress { - self.mm_starknet_contract.read() + self.mm_starknet_wallet.read() } fn set_herodotus_facts_registry_contract( @@ -234,13 +233,13 @@ mod Escrow { fn set_mm_ethereum_contract(ref self: ContractState, new_contract: EthAddress) { let unsafe_state = Ownable::unsafe_new_contract_state(); Ownable::InternalImpl::assert_only_owner(@unsafe_state); - self.mm_ethereum_contract.write(new_contract); + self.mm_ethereum_wallet.write(new_contract); } fn set_mm_starknet_contract(ref self: ContractState, new_contract: ContractAddress) { let unsafe_state = Ownable::unsafe_new_contract_state(); Ownable::InternalImpl::assert_only_owner(@unsafe_state); - self.mm_starknet_contract.write(new_contract); + self.mm_starknet_wallet.write(new_contract); } } diff --git a/contracts/cairo/src/interfaces/IERC20.cairo b/contracts/cairo/src/interfaces/IERC20.cairo index ec5d9d85..a36051c9 100644 --- a/contracts/cairo/src/interfaces/IERC20.cairo +++ b/contracts/cairo/src/interfaces/IERC20.cairo @@ -5,11 +5,11 @@ trait IERC20 { fn name(self: @TState) -> felt252; fn symbol(self: @TState) -> felt252; fn decimals(self: @TState) -> u8; - fn total_supply(self: @TState) -> u256; - fn balance_of(self: @TState, account: ContractAddress) -> u256; + fn totalSupply(self: @TState) -> u256; + fn balanceOf(self: @TState, account: ContractAddress) -> u256; fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256; fn transfer(ref self: TState, recipient: ContractAddress, amount: u256) -> bool; - fn transfer_from( + fn transferFrom( ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256 ) -> bool; fn approve(ref self: TState, spender: ContractAddress, amount: u256) -> bool; diff --git a/contracts/cairo/src/tests/test_escrow.cairo b/contracts/cairo/src/tests/test_escrow.cairo index b6e31016..86cc9936 100644 --- a/contracts/cairo/src/tests/test_escrow.cairo +++ b/contracts/cairo/src/tests/test_escrow.cairo @@ -78,8 +78,8 @@ mod Escrow { let (escrow, eth_token) = setup(); // check balance - assert(eth_token.balance_of(escrow.contract_address) == 0, 'init: wrong balance'); - assert(eth_token.balance_of(MM_STARKNET()) == 0, 'init: wrong balance'); + assert(eth_token.balanceOf(escrow.contract_address) == 0, 'init: wrong balance'); + assert(eth_token.balanceOf(MM_STARKNET()) == 0, 'init: wrong balance'); start_prank(escrow.contract_address, USER()); let order = Order { recipient_address: 12345.try_into().unwrap(), amount: 500 }; @@ -87,8 +87,8 @@ mod Escrow { stop_prank(escrow.contract_address); // check balance - assert(eth_token.balance_of(escrow.contract_address) == 500, 'set_order: wrong balance '); - assert(eth_token.balance_of(MM_STARKNET()) == 0, 'set_order: wrong balance'); + assert(eth_token.balanceOf(escrow.contract_address) == 500, 'set_order: wrong balance '); + assert(eth_token.balanceOf(MM_STARKNET()) == 0, 'set_order: wrong balance'); // check Order assert(order_id == 0, 'wrong order_id'); @@ -104,7 +104,7 @@ mod Escrow { // check Order assert(escrow.get_order_used(order_id), 'wrong order used'); // check balance - assert(eth_token.balance_of(escrow.contract_address) == 0, 'withdraw: wrong balance'); - assert(eth_token.balance_of(MM_STARKNET()) == 500, 'withdraw: wrong balance'); + assert(eth_token.balanceOf(escrow.contract_address) == 0, 'withdraw: wrong balance'); + assert(eth_token.balanceOf(MM_STARKNET()) == 500, 'withdraw: wrong balance'); } } diff --git a/contracts/solidity/src/YABTransfer.sol b/contracts/solidity/src/YABTransfer.sol index 1fabcbe8..b8b8a0c6 100644 --- a/contracts/solidity/src/YABTransfer.sol +++ b/contracts/solidity/src/YABTransfer.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.21; contract YABTransfer { struct TransferInfo { uint256 destAddress; - uint128 amount; + uint256 amount; bool isUsed; }