-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
645 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity =0.8.19; | ||
|
||
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; | ||
import {IERC777Recipient} from "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol"; | ||
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; | ||
import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; | ||
|
||
/** | ||
* Token callback handler. | ||
* Handles supported tokens' callbacks, allowing account receiving these tokens. | ||
*/ | ||
contract TokenCallbackHandler is IERC777Recipient, IERC721Receiver, IERC1155Receiver { | ||
function tokensReceived(address, address, address, uint256, bytes calldata, bytes calldata) | ||
external | ||
pure | ||
override | ||
{} | ||
|
||
function onERC721Received(address, address, uint256, bytes calldata) | ||
external | ||
view | ||
virtual | ||
override | ||
returns (bytes4) | ||
{ | ||
return IERC721Receiver.onERC721Received.selector; | ||
} | ||
|
||
function onERC1155Received(address, address, uint256, uint256, bytes calldata) | ||
external | ||
pure | ||
override | ||
returns (bytes4) | ||
{ | ||
return IERC1155Receiver.onERC1155Received.selector; | ||
} | ||
|
||
function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) | ||
external | ||
pure | ||
override | ||
returns (bytes4) | ||
{ | ||
return IERC1155Receiver.onERC1155BatchReceived.selector; | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) { | ||
return interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId | ||
|| interfaceId == type(IERC165).interfaceId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity =0.8.19; | ||
|
||
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
|
||
error InvalidImplementation(); | ||
|
||
/** | ||
* @title ERC6551OpenfortProxy (Non-upgradeable) | ||
* @notice Contract to create the ERC6551 proxies | ||
* It inherits from: | ||
* - ERC1967Proxy | ||
*/ | ||
contract ERC6551OpenfortProxy is ERC1967Proxy { | ||
address internal immutable defaultImplementation; | ||
|
||
constructor(address _logic, bytes memory _data) ERC1967Proxy(_logic, _data) { | ||
if (_logic == address(0)) revert InvalidImplementation(); | ||
defaultImplementation = _logic; | ||
} | ||
|
||
// constructor(address _logic, bytes memory _data) ERC1967Proxy(_logic, _data) {} | ||
|
||
function implementation() external view returns (address) { | ||
return _implementation(); | ||
} | ||
|
||
function _implementation() internal view virtual override returns (address implementationAddress) { | ||
implementationAddress = _getImplementation(); | ||
if (implementationAddress == address(0)) return defaultImplementation; | ||
} | ||
|
||
function _beforeFallback() internal virtual override { | ||
super._beforeFallback(); | ||
if (msg.data.length == 0) { | ||
if (_getImplementation() == address(0)) { | ||
_upgradeTo(defaultImplementation); | ||
_delegate(defaultImplementation); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.