Add ERC1363 implementation (#4631)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com> Co-authored-by: ernestognw <ernestognw@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a51f1e1354
commit
e5f02bc608
@ -4,32 +4,29 @@
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
/**
|
||||
* @dev Interface for any contract that wants to support {IERC1363-transferAndCall}
|
||||
* or {IERC1363-transferFromAndCall} from {ERC1363} token contracts.
|
||||
* @title IERC1363Receiver
|
||||
* @dev Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall`
|
||||
* from ERC-1363 token contracts.
|
||||
*/
|
||||
interface IERC1363Receiver {
|
||||
/*
|
||||
* Note: the ERC-165 identifier for this interface is 0x88a7ca5c.
|
||||
* 0x88a7ca5c === bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))
|
||||
*/
|
||||
|
||||
/**
|
||||
* @notice Handle the receipt of ERC-1363 tokens
|
||||
* @dev Any ERC-1363 smart contract calls this function on the recipient
|
||||
* after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the
|
||||
* transfer. Return of other than the magic value MUST result in the
|
||||
* transaction being reverted.
|
||||
* Note: the token contract address is always the message sender.
|
||||
* @param operator address The address which called `transferAndCall` or `transferFromAndCall` function
|
||||
* @param from address The address which are token transferred from
|
||||
* @param amount uint256 The amount of tokens transferred
|
||||
* @param data bytes Additional data with no specified format
|
||||
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` unless throwing
|
||||
* @dev Whenever ERC-1363 tokens are transferred to this contract via `transferAndCall` or `transferFromAndCall`
|
||||
* by `operator` from `from`, this function is called.
|
||||
*
|
||||
* NOTE: To accept the transfer, this must return
|
||||
* `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
|
||||
* (i.e. 0x88a7ca5c, or its own function selector).
|
||||
*
|
||||
* @param operator The address which called `transferAndCall` or `transferFromAndCall` function.
|
||||
* @param from The address which are tokens transferred from.
|
||||
* @param value The amount of tokens transferred.
|
||||
* @param data Additional data with no specified format.
|
||||
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` if transfer is allowed unless throwing.
|
||||
*/
|
||||
function onTransferReceived(
|
||||
address operator,
|
||||
address from,
|
||||
uint256 amount,
|
||||
bytes memory data
|
||||
uint256 value,
|
||||
bytes calldata data
|
||||
) external returns (bytes4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user