contracts
contracts copied to clipboard
Proof-of-concept ERC721 Bridge Implementation
Description
- This introduces an example ERC721 bridging implementation
- The base ERC721 contracts are slightly amended from OpenZeppelin's latest implementation of the standard
- There is an assumption in the existing ERC20 implementation that the source contract will always be on L1, with tokens depositing to L2. The naming convention in this ERC721 implementation doesn't make an assumption which side (Gateway / Deposited) is on L1 and which is on L2
- This implementation makes the assumption that the source ERC721 contract has implemented the optional Metadata standard and so implements
function tokenURI(uint256 _tokenId) external view returns (string);(this is implemented at the Abstract contract level)
Additionally this adds init() tests to the DepositedERC20 contract as they were quite transferable.
Questions
- I tried to follow the patterns implemented for the ERC20 bridge as closely as possible
- The OpenZeppelin ERC721 implementation is quite a lot heavier than the UniswapV2 standard used for ERC20 in this repo. Open to amending or slimming this down if there are other preferred reference implementations.
- I had an issue setting bytes on smoddit, it seems like that is currently unsupported?
Metadata
Contributing Agreement
- [x] I have read and understood the Optimism Contributing Guide and Code of Conduct and am following those guidelines in this pull request.
Had to increase Default Withdrawal Gas on DepositedERC721 for this to work with the origin contract on L2. Not sure what the ramifications of that might be, comments welcome.
Hey thank you for this. I'll take a look this week!
Any updates on this?
I have added onERC721Received support to the gateway (cc @wighawag ), though I couldn't get the smocked Messenger to support it in the tests to check the message as in the other deposit tests. I have verified that it works as intended in an integration branch (https://github.com/austintgriffith/scaffold-eth/tree/oo-wip), so not sure if it is my user error, or something with smocked when it is called as the result of a callback:
const depositCallToMessenger =
Mock__OVM_L1CrossDomainMessenger.smocked.sendMessage.calls[0]
in the new test throws with: TypeError: Cannot read property 'map' of undefined
@platocrat & @maurelian not sure where this ended up (as I know there was a thread on bridging and the preferred approach there), happy to adjust this accordingly
Fixed the smocked issue (with thanks to @smartcontracts see more here)