Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KGA-24][KGA-128] fix: check kakarot approval dualVMToken #1622

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solidity_contracts/src/CairoPrecompiles/DualVmToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ contract DualVmToken is NoDelegateCall {
}

function _approve(uint256 spender, uint256 amount) private {
if (spender >= STARKNET_FIELD_PRIME) {
if (spender >= STARKNET_FIELD_PRIME || spender == kakarot) {
revert InvalidStarknetAddress();
}
// Split amount in [low, high]
Expand Down
7 changes: 7 additions & 0 deletions tests/end_to_end/CairoPrecompiles/test_dual_vm_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ async def test_should_revert_approve_starknet_address_invalid_address(
with cairo_error(evm_error):
await dual_vm_token.functions["approve(uint256,uint256)"](2**256 - 1, 1)

async def test_should_revert_approve_kakarot(self, kakarot, dual_vm_token):
evm_error = keccak(b"InvalidStarknetAddress()")[:4]
with cairo_error(evm_error):
await dual_vm_token.functions["approve(uint256,uint256)"](
kakarot.address, 1
)

async def test_allowance_owner_starknet_address(
self, starknet_token, dual_vm_token, other
):
Expand Down
Loading