Skip to content

Commit

Permalink
feat: update docs and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
vittominacori committed Oct 26, 2023
1 parent 34fe366 commit 312c410
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 79 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- name: Setup Code
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup

Expand All @@ -33,7 +33,7 @@ jobs:
steps:
- name: Setup Code
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup

Expand All @@ -51,17 +51,15 @@ jobs:
steps:
- name: Setup Code
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup

- name: Run Coverage
run: npm run coverage

- name: Post to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

slither:
name: Slither
Expand All @@ -74,7 +72,7 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/setup

- name: Run Slither
uses: crytic/[email protected]
with:
Expand All @@ -83,6 +81,8 @@ jobs:
codespell:
name: Codespell
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
- uses: actions/checkout@v4
- name: Run CodeSpell
Expand Down
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ The following are functions and callbacks introduced by ERC-1363:
ERC-1363 tokens can be used for specific utilities in all cases that require a callback to be executed after a transfer or an approval received.
ERC-1363 is also useful for avoiding token loss or token locking in contracts by verifying the recipient contract's ability to handle tokens.

**NOTE: This repo contains the reference implementation of the official [ERC-1363](https://eips.ethereum.org/EIPS/eip-1363).**
::: tip NOTE
**This repo contains the reference implementation of the official [ERC-1363](https://eips.ethereum.org/EIPS/eip-1363).**
:::

## Install

Expand All @@ -49,8 +51,6 @@ contract MyToken is ERC1363 {

## Code

This repo contains:

### IERC1363

[IERC1363.sol](https://github.com/vittominacori/erc1363-payable-token/blob/master/contracts/token/ERC1363/IERC1363.sol)
Expand Down Expand Up @@ -106,17 +106,21 @@ Implementation of the ERC-1363 interface.

The reference implementation of ERC-1363 that extends ERC-20 and adds support for executing code after transfers and approvals on recipient contracts.

> **NOTE**: `transferAndCall`, `transferFromAndCall` and `approveAndCall` revert if the recipient/spender is an EOA address. To transfer tokens to an EOA or approve it to spend tokens, use the ERC-20 `transfer`, `transferFrom` or `approve` methods.
::: tip NOTE
`transferAndCall`, `transferFromAndCall` and `approveAndCall` revert if the recipient/spender is an EOA address. To transfer tokens to an EOA or approve it to spend tokens, use the ERC-20 `transfer`, `transferFrom` or `approve` methods.
:::

## Examples

**IMPORTANT**: the example contracts are for testing purpose only. When inheriting or copying from these contracts, you must include a way to use the received tokens, otherwise they will be stuck into the contract.
::: warning IMPORTANT
The example contracts are for testing purpose only. When inheriting or copying from these contracts, you must include a way to use the received tokens, otherwise they will be stuck into the contract.
:::

### ERC1363Guardian

[ERC1363Guardian.sol](https://github.com/vittominacori/erc1363-payable-token/blob/master/contracts/examples/ERC1363Guardian.sol)

As example: a contract that allows to accept ERC-1363 callback after transfers or approvals.
As example: a contract that allows to accept ERC-1363 callbacks after transfers or approvals.

It emits a `TokensReceived` event to notify the transfer received by the contract.

Expand All @@ -132,7 +136,7 @@ It also implements a `_approvalReceived` function that can be overridden to make

As example: a contract that allows to test passing methods via abi encoded function call.

It executed the method passed via `data`. Methods emit a `MethodCall` event.
It executes the method passed via `data`. Methods emit a `MethodCall` event.

## Documentation

Expand All @@ -153,27 +157,19 @@ It executed the method passed via `data`. Methods emit a `MethodCall` event.
npm install
```

### Usage

Open the console

```bash
npm run console
```

#### Compile
### Compile

```bash
npm run compile
```

#### Test
### Test

```bash
npm test
```

#### Code Coverage
### Code Coverage

```bash
npm run coverage
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/ERC1363Guardian.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {IERC1363Spender} from "../token/ERC1363/IERC1363Spender.sol";

/**
* @title ERC1363Guardian
* @dev Implementation example of a contract that allows to accept ERC-1363 callback after transfers or approvals.
* @dev Implementation example of a contract that allows to accept ERC-1363 callbacks after transfers or approvals.
*
* IMPORTANT: This contract is for testing purpose only. When inheriting or copying from this contract,
* you must include a way to use the received tokens, otherwise they will be stuck into the contract.
Expand Down
6 changes: 2 additions & 4 deletions contracts/token/ERC1363/ERC1363.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ abstract contract ERC1363 is ERC20, ERC165, IERC1363, IERC1363Errors {
}

/**
* @dev Performs a call to `IERC1363Receiver-onTransferReceived` on a target address.
* @dev Performs a call to `IERC1363Receiver::onTransferReceived` on a target address.
* This will revert if the target doesn't implement the `IERC1363Receiver` interface or
* if the target doesn't accept the token transfer or
* if the target address is not a contract.
Expand All @@ -102,7 +102,6 @@ abstract contract ERC1363 is ERC20, ERC165, IERC1363, IERC1363Errors {
if (reason.length == 0) {
revert ERC1363InvalidReceiver(to);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
Expand All @@ -111,7 +110,7 @@ abstract contract ERC1363 is ERC20, ERC165, IERC1363, IERC1363Errors {
}

/**
* @dev Performs a call to `IERC1363Spender-onApprovalReceived` on a target address.
* @dev Performs a call to `IERC1363Spender::onApprovalReceived` on a target address.
* This will revert if the target doesn't implement the `IERC1363Spender` interface or
* if the target doesn't accept the token approval or
* if the target address is not a contract.
Expand All @@ -133,7 +132,6 @@ abstract contract ERC1363 is ERC20, ERC165, IERC1363, IERC1363Errors {
if (reason.length == 0) {
revert ERC1363InvalidSpender(spender);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC1363/IERC1363.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* NOTE: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
Expand Down
36 changes: 16 additions & 20 deletions dist/ERC1363.dist.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

// Sources flattened with hardhat v2.18.2 https://hardhat.org
// Sources flattened with hardhat v2.18.3 https://hardhat.org



Expand Down Expand Up @@ -693,15 +693,14 @@ pragma solidity ^0.8.20;

/**
* @title IERC1363
* @dev Interface of the ERC1363 standard as defined in the
* https://eips.ethereum.org/EIPS/eip-1363[EIP-1363].
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
* An extension interface for ERC-20 tokens that supports executing code on a recipient contract after
* `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* NOTE: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
Expand Down Expand Up @@ -780,7 +779,7 @@ pragma solidity ^0.8.20;

/**
* @title IERC1363Errors
* @dev Interface of the ERC1363 custom errors following the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] rationale.
* @dev Interface of the ERC-1363 custom errors following the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] rationale.
*/
interface IERC1363Errors {
/**
Expand Down Expand Up @@ -818,11 +817,11 @@ pragma solidity ^0.8.20;
/**
* @title IERC1363Receiver
* @dev Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall`
* from ERC1363 token contracts.
* from ERC-1363 token contracts.
*/
interface IERC1363Receiver {
/**
* @dev Whenever ERC1363 tokens are transferred to this contract via `transferAndCall` or `transferFromAndCall`
* @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
Expand Down Expand Up @@ -853,11 +852,11 @@ pragma solidity ^0.8.20;
/**
* @title ERC1363Spender
* @dev Interface for any contract that wants to support `approveAndCall`
* from ERC1363 token contracts.
* from ERC-1363 token contracts.
*/
interface IERC1363Spender {
/**
* @dev Whenever an ERC1363 tokens `owner` approved this contract via `approveAndCall`
* @dev Whenever an ERC-1363 tokens `owner` approved this contract via `approveAndCall`
* to spent their tokens, this function is called.
*
* NOTE: To accept the approval, this must return
Expand Down Expand Up @@ -885,11 +884,10 @@ pragma solidity ^0.8.20;

/**
* @title ERC1363
* @dev Implementation of the ERC1363 interface.
* Extension of ERC20 tokens that adds support for code execution after transfers and approvals
* on recipient contracts in a single transaction.
* Calls after transfers are enabled through the `ERC1363-transferAndCall` and `ERC1363-transferFromAndCall`,
* while calls after approvals can be made with `ERC1363-approveAndCall`.
* @dev Implementation of the ERC-1363 interface.
*
* Extension of ERC-20 tokens that supports executing code on a recipient contract after `transfer` or `transferFrom`,
* or code on a spender contract after `approve`, in a single transaction.
*/
abstract contract ERC1363 is ERC20, ERC165, IERC1363, IERC1363Errors {
/**
Expand Down Expand Up @@ -953,7 +951,7 @@ abstract contract ERC1363 is ERC20, ERC165, IERC1363, IERC1363Errors {
}

/**
* @dev Performs a call to `IERC1363Receiver-onTransferReceived` on a target address.
* @dev Performs a call to `IERC1363Receiver::onTransferReceived` on a target address.
* This will revert if the target doesn't implement the `IERC1363Receiver` interface or
* if the target doesn't accept the token transfer or
* if the target address is not a contract.
Expand All @@ -976,7 +974,6 @@ abstract contract ERC1363 is ERC20, ERC165, IERC1363, IERC1363Errors {
if (reason.length == 0) {
revert ERC1363InvalidReceiver(to);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
Expand All @@ -985,7 +982,7 @@ abstract contract ERC1363 is ERC20, ERC165, IERC1363, IERC1363Errors {
}

/**
* @dev Performs a call to `IERC1363Spender-onApprovalReceived` on a target address.
* @dev Performs a call to `IERC1363Spender::onApprovalReceived` on a target address.
* This will revert if the target doesn't implement the `IERC1363Spender` interface or
* if the target doesn't accept the token approval or
* if the target address is not a contract.
Expand All @@ -1007,7 +1004,6 @@ abstract contract ERC1363 is ERC20, ERC165, IERC1363, IERC1363Errors {
if (reason.length == 0) {
revert ERC1363InvalidSpender(spender);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require('solidity-docgen');
module.exports = {
defaultNetwork: 'hardhat',
solidity: {
version: '0.8.21',
version: '0.8.22',
settings: {
evmVersion: 'shanghai',
optimizer: {
Expand Down
Loading

0 comments on commit 312c410

Please sign in to comment.