Skip to content
This repository was archived by the owner on Jul 5, 2022. It is now read-only.
Open
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
19 changes: 0 additions & 19 deletions .dapprc

This file was deleted.

14 changes: 9 additions & 5 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v3
with:
node-version: '14'

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install Dependencies
run: yarn
- name: Update Modules
run: yarn sync
- name: Build
run: yarn setup
- name: Run lints
run: yarn lint
15 changes: 10 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v3
with:
node-version: '14'

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install Dependencies
run: yarn
- name: Update Modules
run: yarn sync
- name: Build
run: yarn setup
- name: Run Tests
run: yarn test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ node_modules
.vscode/*.log

# Ignore flattened files
flattened.txt
flattened.txt

.gas-snapshot
7 changes: 2 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[submodule "lib/ds-test"]
path = lib/ds-test
url = https://github.com/dapphub/ds-test
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/rari-capital/solmate
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/brockelmore/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/clones-with-immutable-args"]
path = lib/clones-with-immutable-args
url = https://github.com/ZeframLou/clones-with-immutable-args
url = https://github.com/wighawag/clones-with-immutable-args
[submodule "lib/chainlink-brownie-contracts"]
path = lib/chainlink-brownie-contracts
url = https://github.com/smartcontractkit/chainlink-brownie-contracts
37 changes: 19 additions & 18 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.5.8"],
"const-name-snakecase": "off",
"constructor-syntax": "error",
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"not-rely-on-time": "off",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"reason-string": ["warn", { "maxLength": 64 }]
}
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.5.0"],
"const-name-snakecase": "off",
"constructor-syntax": "error",
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 160],
"not-rely-on-time": "off",
"no-inline-assembly": "off",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"reason-string": ["warn", { "maxLength": 64 }]
}
}
3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# folders
lib/
node_modules/
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"makefile.extensionOutputFolder": "./.vscode"
}
"makefile.extensionOutputFolder": "./.vscode",
"solidity.compileUsingRemoteVersion": "0.8.11"
}
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
# (-include to ignore error if it does not exist)
-include .env

all: clean remove install update solc build dappbuild

# Install proper solc version.
solc:; nix-env -f https://github.com/dapphub/dapptools/archive/master.tar.gz -iA solc-static-versions.solc_0_8_11
all: clean remove install update build

# Clean the repo
clean :; forge clean
Expand All @@ -14,23 +11,25 @@ clean :; forge clean
remove :; rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib && touch .gitmodules && git add . && git commit -m "modules"

# Install the Modules
install :; forge install dapphub/ds-test && forge install rari-capital/solmate && forge install brockelmore/forge-std && forge install ZeframLou/clones-with-immutable-args && forge install smartcontractkit/chainlink-brownie-contracts
install :; forge install rari-capital/solmate && forge install foundry-rs/forge-std && forge install wighawag/clones-with-immutable-args && forge install smartcontractkit/chainlink-brownie-contracts

# Update Dependencies
update:; forge update

# Builds
build :; forge clean && forge build --optimize --optimize-runs 1000000
dappbuild :; dapp build

# chmod scripts
scripts :; chmod +x ./scripts/*

# Tests
test :; forge clean && forge test --optimize --optimize-runs 1000000 -v # --ffi # enable if you need the `ffi` cheat code on HEVM
test :; forge clean && forge test --optimize --optimize-runs 1000000 # --ffi # enable if you need the `ffi` cheat code on HEVM

# Lints
lint :; yarn prettier --write src/**/*.sol && prettier --write src/*.sol
lint :; yarn solhint --config ./.solhint.json --max-warnings 0 "src/**/*.sol"

# prettier
sol-prettier :; yarn prettier --config .prettierrc --write "src/**/*.sol"

# Generate Gas Snapshots
snapshot :; forge clean && forge snapshot --optimize --optimize-runs 1000000
Expand Down
3 changes: 1 addition & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ src = 'src'
test = 'test'
out = 'out'
libs = ['lib']
remappings = ['ds-test/=lib/ds-test/src/']
libraries = []
cache = true
force = false
Expand All @@ -14,7 +13,7 @@ solc_version = '0.8.11'
auto_detect_solc = true
optimizer = true
optimizer_runs = 200
verbosity = 0
verbosity = 3
ignored_error_codes = []
fuzz_runs = 500
ffi = false
Expand Down
1 change: 0 additions & 1 deletion lib/ds-test
Submodule ds-test deleted from 0a5da5
2 changes: 1 addition & 1 deletion lib/forge-std
2 changes: 1 addition & 1 deletion lib/solmate
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
"devDependencies": {
"hardhat": "^2.7.0",
"prettier": "^2.3.1",
"prettier-plugin-solidity": "^1.0.0-beta.13"
"prettier-plugin-solidity": "^1.0.0-beta.13",
"solhint": "^3.3.7",
"solhint-plugin-prettier": "^0.0.5"
},
"scripts": {
"setup": "make clean && make build",
"sync": "make update",
"test": "make test",
"snapshot": "make snapshot",
"lint": "make lint"
"lint": "make lint",
"sol-prettier": "make sol-prettier"
}
}
2 changes: 0 additions & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@ds=lib/ds-test/src/
@solmate=lib/solmate/src/
@std=lib/forge-std/src/
@clones=lib/clones-with-immutable-args/src/
@chainlink/=lib/chainlink-brownie-contracts/
ds-test=lib/ds-test/src/
6 changes: 4 additions & 2 deletions src/APIConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract APIConsumer is ChainlinkClient {
bytes32 _jobId,
uint256 _fee,
address _link
) public {
) {
if (_link == address(0)) {
setPublicChainlinkToken();
} else {
Expand Down Expand Up @@ -75,7 +75,8 @@ contract APIConsumer is ChainlinkClient {
// }
// }
// }
// request.add("path", "RAW.ETH.USD.VOLUME24HOUR"); // Chainlink node versions prior to 1.0.0 supported this format
// request.add("path", "RAW.ETH.USD.VOLUME24HOUR");
// Chainlink node versions prior to 1.0.0 supported this format
request.add("path", "RAW,ETH,USD,VOLUME24HOUR");

// Multiply the result by 1000000000000000000 to remove decimals
Expand Down Expand Up @@ -104,5 +105,6 @@ contract APIConsumer is ChainlinkClient {
* @notice Witdraws LINK from the contract
* @dev Implement a withdraw function to avoid locking your LINK in the contract
*/
// solhint-disable-next-line no-empty-blocks
function withdrawLink() external {}
}
94 changes: 47 additions & 47 deletions src/KeepersCounter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,58 @@ import "@chainlink/contracts/src/v0.8/interfaces/KeeperCompatibleInterface.sol";
* @notice A keeper-compatible contract that increments counter variable at fixed time intervals
*/
contract KeepersCounter is KeeperCompatibleInterface {
/**
* Public counter variable
*/
uint256 public counter;
/**
* Public counter variable
*/
uint256 public counter;

/**
* Use an interval in seconds and a timestamp to slow execution of Upkeep
*/
uint256 public immutable interval;
uint256 public lastTimeStamp;
/**
* Use an interval in seconds and a timestamp to slow execution of Upkeep
*/
uint256 public immutable interval;
uint256 public lastTimeStamp;

/**
* @notice Executes once when a contract is created to initialize state variables
*
* @param updateInterval - Period of time between two counter increments expressed as UNIX timestamp value
*/
constructor(uint256 updateInterval) {
interval = updateInterval;
lastTimeStamp = block.timestamp;
/**
* @notice Executes once when a contract is created to initialize state variables
*
* @param updateInterval - Period of time between two counter increments expressed as UNIX timestamp value
*/
constructor(uint256 updateInterval) {
interval = updateInterval;
lastTimeStamp = block.timestamp;

counter = 0;
}
counter = 0;
}

/**
* @notice Checks if the contract requires work to be done
*/
function checkUpkeep(
bytes memory /* checkData */
)
public
override
returns (
bool upkeepNeeded,
bytes memory /* performData */
/**
* @notice Checks if the contract requires work to be done
*/
function checkUpkeep(
bytes memory /* checkData */
)
{
upkeepNeeded = (block.timestamp - lastTimeStamp) > interval;
// We don't use the checkData in this example. The checkData is defined when the Upkeep was registered.
}
public
view
override
returns (bool upkeepNeeded, bytes memory performData)
{
upkeepNeeded = (block.timestamp - lastTimeStamp) > interval;
performData = "";
// We don't use the checkData in this example. The checkData is defined when the Upkeep was registered.
}

/**
* @notice Performs the work on the contract, if instructed by :checkUpkeep():
*/
function performUpkeep(
bytes calldata /* performData */
) external override {
// add some verification
(bool upkeepNeeded, ) = checkUpkeep("");
require(upkeepNeeded, "Time interval not met");
/**
* @notice Performs the work on the contract, if instructed by :checkUpkeep():
*/
function performUpkeep(
bytes calldata /* performData */
) external override {
// add some verification
(bool upkeepNeeded, ) = checkUpkeep("");
require(upkeepNeeded, "Time interval not met");

lastTimeStamp = block.timestamp;
counter = counter + 1;
// We don't use the performData in this example. The performData is generated by the Keeper's call to your checkUpkeep function
}
lastTimeStamp = block.timestamp;
counter = counter + 1;
// We don't use the performData in this example.
// The performData is generated by the Keeper's call to your checkUpkeep function.
}
}
8 changes: 1 addition & 7 deletions src/PriceFeedConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ contract PriceFeedConsumer {
* @return latest price
*/
function getLatestPrice() public view returns (int256) {
(
uint80 roundID,
int256 price,
uint256 startedAt,
uint256 timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
(, int256 price, , , ) = priceFeed.latestRoundData();
return price;
}

Expand Down
Loading