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

Improve ERC1363 documentation #3993

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions contracts/interfaces/IERC1363.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./IERC165.sol";

/**
* @dev Interface of an ERC1363 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1363[EIP].
*
* Defines a interface for ERC20 tokens that supports executing recipient
* code after `transfer` or `transferFrom`, or spender code after `approve`.
*/
interface IERC1363 is IERC165, IERC20 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
Expand All @@ -21,53 +28,53 @@ interface IERC1363 is IERC165, IERC20 {
/**
* @dev Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param amount uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
function transferAndCall(address to, uint256 amount) external returns (bool);

/**
* @dev Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param amount uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value, bytes memory data) external returns (bool);
function transferAndCall(address to, uint256 amount, bytes memory data) external returns (bool);

/**
* @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param amount uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
function transferFromAndCall(address from, address to, uint256 amount) external returns (bool);

/**
* @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param amount uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) external returns (bool);
function transferFromAndCall(address from, address to, uint256 amount, bytes memory data) external returns (bool);

/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param amount uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
function approveAndCall(address spender, uint256 amount) external returns (bool);

/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param amount uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCall(address spender, uint256 value, bytes memory data) external returns (bool);
function approveAndCall(address spender, uint256 amount, bytes memory data) external returns (bool);
}
11 changes: 7 additions & 4 deletions contracts/interfaces/IERC1363Receiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

pragma solidity ^0.8.0;

/**
* @dev Interface for any contract that wants to support {IERC1363-transferAndCall}
* or {IERC1363-transferFromAndCall} from {ERC1363} token contracts.
*/
interface IERC1363Receiver {
/*
* Note: the ERC-165 identifier for this interface is 0x88a7ca5c.
Expand All @@ -18,15 +22,14 @@ interface IERC1363Receiver {
* 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 value uint256 The amount of tokens transferred
* @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
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` unless throwing
*/
function onTransferReceived(
address operator,
address from,
uint256 value,
uint256 amount,
bytes memory data
) external returns (bytes4);
}
11 changes: 7 additions & 4 deletions contracts/interfaces/IERC1363Spender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

pragma solidity ^0.8.0;

/**
* @dev Interface for any contract that wants to support {IERC1363-approveAndCall}
* from {ERC1363} token contracts.
*/
interface IERC1363Spender {
/*
* Note: the ERC-165 identifier for this interface is 0x7b04a2d0.
Expand All @@ -17,10 +21,9 @@ interface IERC1363Spender {
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param owner address The address which called `approveAndCall` function
* @param value uint256 The amount of tokens to be spent
* @param amount uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
* unless throwing
* @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`unless throwing
*/
function onApprovalReceived(address owner, uint256 value, bytes memory data) external returns (bytes4);
function onApprovalReceived(address owner, uint256 amount, bytes memory data) external returns (bytes4);
}