@@ -49,28 +49,48 @@ def get_function_sighashes(self, bytecode):
4949 # https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC20/ERC20.sol
5050 def is_erc20_contract (self , function_sighashes ):
5151 c = ContractWrapper (function_sighashes )
52- return c .implements ('totalSupply()' ) and \
53- c .implements ('balanceOf(address)' ) and \
54- c .implements ('transfer(address,uint256)' ) and \
55- c .implements ('transferFrom(address,address,uint256)' ) and \
56- c .implements ('approve(address,uint256)' ) and \
57- c .implements ('allowance(address,address)' )
52+ return all ([
53+ c .implements ('totalSupply()' ),
54+ c .implements ('balanceOf(address)' ),
55+ c .implements ('transfer(address,uint256)' ),
56+ c .implements ('transferFrom(address,address,uint256)' ),
57+ c .implements ('approve(address,uint256)' ),
58+ c .implements ('allowance(address,address)' )
59+ ])
5860
5961 # https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
6062 # https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/ERC721Basic.sol
61- # Doesn't check the below ERC721 methods to match CryptoKitties contract
62- # getApproved(uint256)
63- # setApprovalForAll(address,bool)
64- # isApprovedForAll(address,address)
65- # transferFrom(address,address,uint256)
66- # safeTransferFrom(address,address,uint256)
67- # safeTransferFrom(address,address,uint256,bytes)
63+ # CryptoKitties contracts doesn't strictly implement erc721 interface
64+ # so we have to check for it's sighashes explicitly
6865 def is_erc721_contract (self , function_sighashes ):
6966 c = ContractWrapper (function_sighashes )
70- return c .implements ('balanceOf(address)' ) and \
71- c .implements ('ownerOf(uint256)' ) and \
72- c .implements_any_of ('transfer(address,uint256)' , 'transferFrom(address,address,uint256)' ) and \
73- c .implements ('approve(address,uint256)' )
67+ return all ([
68+ c .implements ('balanceOf(address)' ),
69+ c .implements ('ownerOf(uint256)' ),
70+ c .implements_any_of ('transfer(address,uint256)' , 'transferFrom(address,address,uint256)' ),
71+ c .implements ('approve(address,uint256)' ),
72+ c .implements ('getApproved(uint256)' ),
73+ c .implements ('setApprovalForAll(address,bool)' ),
74+ c .implements ('isApprovedForAll(address,address)' ),
75+ c .implements ('transferFrom(address,address,uint256)' ),
76+ c .implements ('safeTransferFrom(address,address,uint256)' ),
77+ c .implements ('safeTransferFrom(address,address,uint256,bytes)' ),
78+ ]) or self .is_crypto_kitties_contract (function_sighashes )
79+
80+ # https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code#L52
81+ def is_crypto_kitties_contract (self , function_sighashes ):
82+ return function_sighashes == [
83+ '0x01ffc9a7' , '0x0519ce79' , '0x0560ff44' , '0x05e45546' , '0x06fdde03' , '0x095ea7b3' ,'0x0a0f8168' ,
84+ '0x0d9f5aed' , '0x0e583df0' , '0x14001f4c' , '0x18160ddd' , '0x183a7947' , '0x1940a936' , '0x19c2f201' ,
85+ '0x21717ebf' , '0x23b872dd' , '0x24e7a38a' , '0x27d7874c' , '0x27ebe40a' , '0x2ba73c15' , '0x3d7d3f5a' ,
86+ '0x3f4ba83a' , '0x454a2ab3' , '0x46116e6f' , '0x46d22c70' , '0x481af3d3' , '0x4ad8c938' , '0x4b85fd55' ,
87+ '0x4dfff04f' , '0x4e0a3379' , '0x54c15b82' , '0x56129134' , '0x5663896e' , '0x5c975abb' , '0x5fd8c710' ,
88+ '0x6352211e' , '0x680eba27' , '0x6af04a57' , '0x6fbde40d' , '0x70a08231' , '0x71587988' , '0x76190f8f' ,
89+ '0x7a7d4937' , '0x8456cb59' , '0x8462151c' , '0x85b86188' , '0x88c2a0bf' , '0x91876e57' , '0x95d89b41' ,
90+ '0x9d6fac6f' , '0xa45f4bfc' , '0xa9059cbb' , '0xb047fb50' , '0xb0c35c05' , '0xbc4006f5' , '0xc3bea9af' ,
91+ '0xc55d0f56' , '0xcb4799f2' , '0xd3e6f49f' , '0xdefb9584' , '0xe17b25af' , '0xe6cbe351' , '0xe98b7f4d' ,
92+ '0xeac9d94c' , '0xed60ade6' , '0xf1ca9410' , '0xf2b47d52' , '0xf7d8c883' , '0xffffffff'
93+ ]
7494
7595
7696def clean_bytecode (bytecode ):
0 commit comments