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

imp(erc20): Adjust ERC20 allowance behavior for same spender #2097

Merged
merged 7 commits into from
Nov 29, 2023

Conversation

MalteHerrmann
Copy link
Contributor

Description

This PR adjusts the behavior of the ERC20 EVM extension in the following way:

  • Trying to approve when the owner is the spender will return an error
  • Querying the allowance for the own account will always return abi.MaxUint256 (infinite allowance)
  • Executing transferFrom where the owner is the spender will work without need for an approval and always emit an ApprovalEvent with the new allowance being abi.MaxUint256.

This behavior differs from the standard ERC20 OpenZeppelin contracts, but is not otherwise possible without changes to the Cosmos SDK. Here, grants between the same granter and grantee are not supported.
Since an allowance for oneself is completely useless, this will not inhibit any user stories and should be at most a minor inconvenience for users.

Copy link

codecov bot commented Nov 28, 2023

Codecov Report

Merging #2097 (1af5d9c) into main (97307ca) will increase coverage by 0.12%.
Report is 6 commits behind head on main.
The diff coverage is 79.66%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2097      +/-   ##
==========================================
+ Coverage   70.14%   70.27%   +0.12%     
==========================================
  Files         339      339              
  Lines       25499    25538      +39     
==========================================
+ Hits        17887    17946      +59     
+ Misses       6675     6654      -21     
- Partials      937      938       +1     
Files Coverage Δ
app/app.go 80.15% <100.00%> (+0.02%) ⬆️
precompiles/common/types.go 61.76% <ø> (ø)
precompiles/erc20/approve.go 76.96% <100.00%> (+1.13%) ⬆️
precompiles/erc20/errors.go 55.88% <ø> (+11.76%) ⬆️
precompiles/erc20/query.go 96.00% <100.00%> (ø)
x/evm/types/params.go 74.33% <ø> (ø)
precompiles/erc20/tx.go 90.00% <85.18%> (+5.38%) ⬆️
x/evm/keeper/precompiles.go 79.59% <42.85%> (-0.41%) ⬇️

... and 2 files with indirect coverage changes

Copy link
Contributor

@GAtom22 GAtom22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great work @MalteHerrmann !!

@fedekunze fedekunze merged commit 150b2e9 into main Nov 29, 2023
35 checks passed
@fedekunze fedekunze deleted the malte/adjust-allowance-for-same-spender branch November 29, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants