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

Solmate Token Tests (ERC20.sol, WETH.sol, ERC721.sol, ERC1155.sol) #2

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

MarcusWentz
Copy link

@MarcusWentz MarcusWentz commented Feb 12, 2023

🟢 Contracts are set to Solidity 0.8.14 for Warp compatibility.

🔴 Contracts have been slightly modified with some features removed to transpile in Warp.

Features not supported yet have been removed and mentioned in the branch README:

https://github.com/NethermindEth/warping-contracts/tree/solmate#solmate

Running shell command:

bin/warp version

Returns:

Warp Version 2.4.7
Starknet Version 0.10.3

@MarcusWentz
Copy link
Author

MarcusWentz commented Feb 12, 2023

Instead of using this to check if an address is a wallet for ERC-721 and ERC-1155:

function isWallet(address account) public view returns (bool) {
    uint size;
    assembly {
            size := extcodesize(account)
    }
    return size == 0;
}

we could try to see if this works instead:

function isWallet(address account) internal view returns (bool) {
    bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
    bytes32 codeHash;    
    assembly { 
            codeHash := extcodehash(account) 
    }
    return (codeHash != accountHash && codeHash != 0x0) == false;
}

@MarcusWentz
Copy link
Author

MarcusWentz commented Feb 12, 2023

Warp does not appear to support opcode extcodehash with the test above here:

assembly { 
        codeHash := extcodehash(account) 
}

I tried to work around this by getting the bytecode and then trying to hash it manually as specified in EIP-1052:

https://eips.ethereum.org/EIPS/eip-1052

function isWallet(address account) public view returns (bool) {
    bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
    bytes32 codeHash = keccak256(abi.encodePacked(account.code));
    return (codeHash != accountHash && codeHash != 0x0) == false;
}  

However,

account.code

seems to fail as well since it depends on opcode EXTCODESIZE.

Are there other ways to check if an address is a wallet?

If not, maybe we ignore the wallet address checks for ERC-721 and ERC-1155 for now.

@MarcusWentz MarcusWentz changed the title Solmate Token Tests Solmate Token Tests (ERC-20, WETH, ERC-721, ERC-1155) Feb 12, 2023
@rodrigo-pino
Copy link
Collaborator

Warp does not appear to support opcode extcodehash with the test above here:

assembly { 
        codeHash := extcodehash(account) 
}

I tried to work around this by getting the bytecode and then trying to hash it manually as specified in EIP-1052:

https://eips.ethereum.org/EIPS/eip-1052

function isWallet(address account) public view returns (bool) {
    bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
    bytes32 codeHash = keccak256(abi.encodePacked(account.code));
    return (codeHash != accountHash && codeHash != 0x0) == false;
}  

However,

account.code

seems to fail as well since it depends on opcode EXTCODESIZE.

Are there other ways to check if an address is a wallet?

If not, maybe we ignore the wallet address checks for ERC-721 and ERC-1155 for now.

Warp does not appear to support opcode extcodehash with the test above here:

assembly { 
        codeHash := extcodehash(account) 
}

I tried to work around this by getting the bytecode and then trying to hash it manually as specified in EIP-1052:

https://eips.ethereum.org/EIPS/eip-1052

function isWallet(address account) public view returns (bool) {
    bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
    bytes32 codeHash = keccak256(abi.encodePacked(account.code));
    return (codeHash != accountHash && codeHash != 0x0) == false;
}  

However,

account.code

seems to fail as well since it depends on opcode EXTCODESIZE.

Are there other ways to check if an address is a wallet?

If not, maybe we ignore the wallet address checks for ERC-721 and ERC-1155 for now.

Starknet implements Account Abstraction, so you cannot differentiate an "externally" owned account from a contract

@MarcusWentz
Copy link
Author

MarcusWentz commented Feb 13, 2023

Should we remove all wallet address checks for ERC-721 and ERC-1155
(useful for safe functions) for now so we can add these contracts to Warp to work around Account Abstraction:

https://eips.ethereum.org/EIPS/eip-2938

?

@MarcusWentz MarcusWentz changed the title Solmate Token Tests (ERC-20, WETH, ERC-721, ERC-1155) Solmate Token Tests (ERC20.sol, WETH.sol, ERC721.sol, ERC1155.sol) Mar 9, 2023
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.

2 participants