Skip to content

Commit 4aedc4e

Browse files
feat: add foundry (#55)
* feat: add foundry * ci: update actions * feat: update readme
1 parent 1052263 commit 4aedc4e

13 files changed

Lines changed: 76 additions & 18 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ runs:
44
using: composite
55
steps:
66
- name: Setup Node
7-
uses: actions/setup-node@v4
7+
uses: actions/setup-node@v6
88
with:
99
node-version: 22
1010

@@ -19,3 +19,8 @@ runs:
1919
run: npm ci
2020
shell: bash
2121
if: steps.cache.outputs.cache-hit != 'true'
22+
23+
- name: Install Foundry
24+
uses: foundry-rs/foundry-toolchain@v1
25+
with:
26+
version: stable

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
FORCE_COLOR: 1
1818
steps:
1919
- name: Setup Code
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v5
2121

2222
- name: Setup Environment
2323
uses: ./.github/actions/setup
@@ -32,7 +32,7 @@ jobs:
3232
FORCE_COLOR: 1
3333
steps:
3434
- name: Setup Code
35-
uses: actions/checkout@v4
35+
uses: actions/checkout@v5
3636

3737
- name: Setup Environment
3838
uses: ./.github/actions/setup
@@ -50,7 +50,7 @@ jobs:
5050
FORCE_COLOR: 1
5151
steps:
5252
- name: Setup Code
53-
uses: actions/checkout@v4
53+
uses: actions/checkout@v5
5454

5555
- name: Setup Environment
5656
uses: ./.github/actions/setup
@@ -70,13 +70,13 @@ jobs:
7070
FORCE_COLOR: 1
7171
steps:
7272
- name: Setup Code
73-
uses: actions/checkout@v4
73+
uses: actions/checkout@v5
7474

7575
- name: Setup Environment
7676
uses: ./.github/actions/setup
7777

7878
- name: Run Slither
79-
uses: crytic/slither-action@v0.4.0
79+
uses: crytic/slither-action@v0.4.1
8080
with:
8181
node-version: 22
8282
solc-version: 0.8.30
@@ -88,7 +88,7 @@ jobs:
8888
FORCE_COLOR: 1
8989
steps:
9090
- name: Setup Code
91-
uses: actions/checkout@v4
91+
uses: actions/checkout@v5
9292

9393
- name: Run CodeSpell
9494
uses: codespell-project/actions-codespell@v2

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ contracts-exposed
4444
/artifacts
4545
/cache
4646

47+
# Foundry
48+
foundry.lock
49+
/out
50+
/cache_forge
51+
4752
# macOS
4853
.DS_Store
4954

@@ -53,10 +58,6 @@ contracts-exposed
5358
# IntelliJ IDE
5459
.idea
5560

56-
# vuepress
57-
pages/.vuepress/dist
58-
pages/.vuepress/.env.json
59-
6061
# vitepress
6162
pages/.vitepress/cache
6263
pages/.vitepress/dist

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,22 @@ ERC-1363 is also useful for avoiding token loss or token locking in contracts by
2626
> [!IMPORTANT]
2727
> **This repo contains the reference implementation of the official [ERC-1363](https://eips.ethereum.org/EIPS/eip-1363).**
2828
29-
## Install
29+
## Installation
30+
31+
### Hardhat
3032

3133
```bash
3234
npm install erc-payable-token
3335
```
3436

37+
### Foundry
38+
39+
```bash
40+
forge install vittominacori/erc1363-payable-token
41+
```
42+
43+
Add `erc-payable-token/contracts/=lib/erc1363-payable-token/contracts/` in `remappings.txt`.
44+
3545
## Usage
3646

3747
```solidity

contracts/examples/ERC1363Payable.sol

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ contract ERC1363Payable is ERC1363Guardian {
2929
* @dev Payment can be done only using the accepted token.
3030
*/
3131
modifier onlyAcceptedToken() {
32-
if (msg.sender != _acceptedToken) {
33-
revert NotAcceptedToken(msg.sender, _acceptedToken);
34-
}
32+
_onlyAcceptedToken();
3533
_;
3634
}
3735

@@ -58,6 +56,15 @@ contract ERC1363Payable is ERC1363Guardian {
5856
return _credits[account];
5957
}
6058

59+
/**
60+
* @dev Checks that the caller is the accepted token.
61+
*/
62+
function _onlyAcceptedToken() internal view {
63+
if (msg.sender != _acceptedToken) {
64+
revert NotAcceptedToken(msg.sender, _acceptedToken);
65+
}
66+
}
67+
6168
/**
6269
* @inheritdoc ERC1363Guardian
6370
*/

contracts/mocks/ERC1363ReturnFalseOnERC20Mock.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
pragma solidity ^0.8.20;
44

5-
import {IERC20, ERC20, ERC1363} from "../token/ERC1363/ERC1363.sol";
5+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
6+
7+
import {ERC20, ERC1363} from "../token/ERC1363/ERC1363.sol";
68

79
// mock class testing an ERC-20 token that returns false
810
abstract contract ERC1363ReturnFalseOnERC20Mock is ERC1363 {

contracts/token/ERC1363/ERC1363.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
pragma solidity ^0.8.20;
44

5-
import {IERC20, ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5+
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
66
import {IERC165, ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
77

88
import {IERC1363} from "./IERC1363.sol";

foundry.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[profile.default]
2+
src = 'contracts'
3+
out = 'out'
4+
libs = ['node_modules', 'lib']
5+
test = 'test'
6+
cache_path = 'cache_forge'
7+
solc_version = '0.8.30'
8+
evm_version = 'prague'
9+
optimizer = true
10+
optimizer-runs = 200
11+
12+
[lint]
13+
exclude_lints = ["screaming-snake-case-immutable"]

hardhat.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require('@nomicfoundation/hardhat-chai-matchers');
22
require('@nomiclabs/hardhat-truffle5');
3+
require('@nomicfoundation/hardhat-foundry');
34
require('hardhat-exposed');
45
require('hardhat-gas-reporter');
56
require('solidity-coverage');

0 commit comments

Comments
 (0)