Skip to content

Commit

Permalink
Support of ERC1363, ERC4524 for slither-check-erc (#1274)
Browse files Browse the repository at this point in the history
* fix typo in `--help` output for `--print` flag (#1149)

* Support of ERC1363, ERC4524 for slither-check-erc (#1263)

Co-authored-by: Erick <edag94@live.com>
  • Loading branch information
h00p30 and edag94 committed Jul 26, 2022
1 parent 2e341ae commit a3fa7e6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
23 changes: 23 additions & 0 deletions slither/core/declarations/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
ERC777_signatures,
ERC1155_signatures,
ERC2612_signatures,
ERC1363_signatures,
ERC4524_signatures,
ERC4626_signatures,
)
from slither.utils.tests_pattern import is_test_contract
Expand Down Expand Up @@ -903,6 +905,7 @@ def ercs(self) -> List[str]:
("ERC721", self.is_erc721),
("ERC777", self.is_erc777),
("ERC2612", self.is_erc2612),
("ERC1363", self.is_erc1363),
("ERC4626", self.is_erc4626),
]

Expand Down Expand Up @@ -998,6 +1001,26 @@ def is_erc2612(self) -> bool:
full_names = self.functions_signatures
return all(s in full_names for s in ERC2612_signatures)

def is_erc1363(self) -> bool:
"""
Check if the contract is an erc1363
Note: it does not check for correct return values
:return: Returns a true if the contract is an erc1363
"""
full_names = self.functions_signatures
return all(s in full_names for s in ERC1363_signatures)

def is_erc4524(self) -> bool:
"""
Check if the contract is an erc4524
Note: it does not check for correct return values
:return: Returns a true if the contract is an erc4524
"""
full_names = self.functions_signatures
return all(s in full_names for s in ERC4524_signatures)

@property
def is_token(self) -> bool:
"""
Expand Down
49 changes: 49 additions & 0 deletions slither/utils/erc.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,53 @@ def erc_to_signatures(erc: List[ERC]):

ERC2612_signatures = erc_to_signatures(ERC2612)

# Review
# https://eips.ethereum.org/EIPS/eip-1363
# Must have ERC20 and ERC165

ERC1363_EVENTS = []
ERC1363 = (
[
ERC("transferAndCall", ["address", "uint256"], "bool", False, True, []),
ERC("transferAndCall", ["address", "uint256", "bytes"], "bool", False, True, []),
ERC("transferFromAndCall", ["address", "address", "uint256"], "bool", False, True, []),
ERC(
"transferFromAndCall",
["address", "address", "uint256", "bytes"],
"bool",
False,
True,
[],
),
ERC("approveAndCall", ["address", "uint256"], "bool", False, True, []),
ERC("approveAndCall", ["address", "uint256", "bytes"], "bool", False, True, []),
]
+ ERC20
+ ERC165
)

ERC1363_signatures = erc_to_signatures(ERC1363)

# Review
# https://eips.ethereum.org/EIPS/eip-4524
# Must have ERC20 and ERC165

ERC4524_EVENTS = []
ERC4524 = (
[
ERC("safeTransfer", ["address", "uint256"], "bool", False, True, []),
ERC("safeTransfer", ["address", "uint256", "bytes"], "bool", False, True, []),
ERC("safeTransferFrom", ["address", "address", "uint256"], "bool", False, True, []),
ERC(
"safeTransferFrom", ["address", "address", "uint256", "bytes"], "bool", False, True, []
),
]
+ ERC20
+ ERC165
)

ERC4524_signatures = erc_to_signatures(ERC4524)

# Final
# https://eips.ethereum.org/EIPS/eip-4626
# Must have ERC20
Expand Down Expand Up @@ -405,5 +452,7 @@ def erc_to_signatures(erc: List[ERC]):
"ERC777": (ERC777, ERC777_EVENTS),
"ERC1155": (ERC1155, ERC1155_EVENTS),
"ERC2612": (ERC2612, ERC2612_EVENTS),
"ERC1363": (ERC1363, ERC1363_EVENTS),
"ERC4524": (ERC4524, ERC4524_EVENTS),
"ERC4626": (ERC4626, ERC4626_EVENTS),
}

0 comments on commit a3fa7e6

Please sign in to comment.