-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(horizon): add horizon package boilerplate
Signed-off-by: Tomás Migone <[email protected]>
- Loading branch information
1 parent
0e8895b
commit 2585495
Showing
28 changed files
with
1,057 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: CI - packages/horizon | ||
|
||
env: | ||
CI: true | ||
|
||
on: | ||
push: | ||
branches: "*" | ||
paths: | ||
- packages/horizon/** | ||
pull_request: | ||
branches: "*" | ||
paths: | ||
- packages/horizon/** | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Set up environment | ||
uses: ./.github/actions/setup | ||
- name: Run tests | ||
run: | | ||
pushd packages/horizon | ||
yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "packages/horizon/lib/forge-std"] | ||
path = packages/horizon/lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Sample Hardhat Project | ||
|
||
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract. | ||
|
||
Try running some of the following tasks: | ||
|
||
```shell | ||
npx hardhat help | ||
npx hardhat test | ||
REPORT_GAS=true npx hardhat test | ||
npx hardhat node | ||
npx hardhat run scripts/deploy.ts | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.4.0 <0.9.0; | ||
|
||
import { Test } from "@graphprotocol/contracts/contracts/staking/IHorizonStaking.sol"; | ||
|
||
contract SimpleTest is Test { | ||
function test() external pure returns (uint256) { | ||
return 42; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// @ts-check | ||
/* eslint-disable no-undef */ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
|
||
const eslintGraphConfig = require('eslint-graph-config') | ||
module.exports = [ | ||
...eslintGraphConfig.default, | ||
{ | ||
rules: { | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
'@typescript-eslint/no-unsafe-member-access': 'off', | ||
'@typescript-eslint/no-unsafe-argument': 'off', | ||
}, | ||
}, | ||
{ | ||
ignores: ['typechain-types/*'], | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[profile.default] | ||
src = 'contracts' | ||
out = 'build' | ||
libs = ['node_modules', 'lib'] | ||
test = 'test' | ||
cache_path = 'cache_forge' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// import '@nomicfoundation/hardhat-foundry' | ||
import '@nomicfoundation/hardhat-toolbox' | ||
import { HardhatUserConfig } from 'hardhat/config' | ||
|
||
const config: HardhatUserConfig = { | ||
solidity: '0.8.24', | ||
paths: { | ||
artifacts: './build/contracts', | ||
sources: './contracts', | ||
}, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"name": "@graphprotocol/horizon", | ||
"version": "0.0.1", | ||
"description": "", | ||
"author": "The Graph Team", | ||
"license": "GPL-2.0-or-later", | ||
"scripts": { | ||
"lint:ts": "eslint '**/*.{js,ts}' --fix", | ||
"lint:sol": "prettier --write contracts/**/*.sol && solhint --noPrompt --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js", | ||
"lint": "yarn lint:ts && yarn lint:sol", | ||
"clean": "rm -rf build cache typechain-types", | ||
"build": "forge build && hardhat compile", | ||
"test": "forge test && hardhat test" | ||
}, | ||
"devDependencies": { | ||
"@graphprotocol/contracts": "workspace:^7.0.0", | ||
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0", | ||
"@nomicfoundation/hardhat-ethers": "^3.0.0", | ||
"@nomicfoundation/hardhat-foundry": "^1.1.1", | ||
"@nomicfoundation/hardhat-network-helpers": "^1.0.0", | ||
"@nomicfoundation/hardhat-toolbox": "^4.0.0", | ||
"@nomicfoundation/hardhat-verify": "^2.0.0", | ||
"@typechain/ethers-v6": "^0.5.0", | ||
"@typechain/hardhat": "^9.0.0", | ||
"@types/chai": "^4.2.0", | ||
"@types/mocha": ">=9.1.0", | ||
"@types/node": ">=16.0.0", | ||
"chai": "^4.2.0", | ||
"eslint": "^8.56.0", | ||
"eslint-graph-config": "workspace:^0.0.1", | ||
"ethers": "^6.4.0", | ||
"hardhat": "^2.20.1", | ||
"hardhat-gas-reporter": "^1.0.8", | ||
"lint-staged": "^15.2.2", | ||
"prettier": "^3.2.5", | ||
"prettier-plugin-solidity": "^1.3.1", | ||
"solhint": "^4.5.2", | ||
"solhint-graph-config": "workspace:^0.0.1", | ||
"solidity-coverage": "^0.8.0", | ||
"ts-node": ">=8.0.0", | ||
"typechain": "^8.3.0", | ||
"typescript": "^5.3.3" | ||
}, | ||
"lint-staged": { | ||
"contracts/**/*.sol": [ | ||
"yarn lint:sol" | ||
], | ||
"**/*.ts": [ | ||
"yarn lint:ts" | ||
], | ||
"**/*.js": [ | ||
"yarn lint:ts" | ||
], | ||
"**/*.json": [ | ||
"yarn lint:ts" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const prettierGraphConfig = require('solhint-graph-config/prettier') | ||
module.exports = prettierGraphConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@graphprotocol/contracts/=node_modules/@graphprotocol/contracts/ | ||
forge-std/=lib/forge-std/src/ | ||
ds-test/=lib/forge-std/lib/ds-test/src/ | ||
eth-gas-reporter/=node_modules/eth-gas-reporter/ | ||
hardhat/=node_modules/hardhat/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ethers } from 'hardhat' | ||
|
||
async function main() { | ||
const currentTimestampInSeconds = Math.round(Date.now() / 1000) | ||
const unlockTime = currentTimestampInSeconds + 60 | ||
|
||
const lockedAmount = ethers.parseEther('0.001') | ||
const a = 1 | ||
console.log(a) | ||
const lock = await ethers.deployContract('Lock', [unlockTime], { | ||
value: lockedAmount, | ||
}) | ||
|
||
await lock.waitForDeployment() | ||
|
||
console.log( | ||
`Lock with ${ethers.formatEther( | ||
lockedAmount, | ||
)}ETH and unlock timestamp ${unlockTime} deployed to ${typeof lock.target == 'string' ? lock.target : ''}`, | ||
) | ||
} | ||
|
||
// We recommend this pattern to be able to use async/await everywhere | ||
// and properly handle errors. | ||
main().catch((error) => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.10; | ||
|
||
import "forge-std/Test.sol"; | ||
import { SimpleTest } from "../contracts/SimpleTest.sol"; | ||
|
||
contract ContractTest is Test { | ||
SimpleTest simpleTest; | ||
|
||
function setUp() public { | ||
simpleTest = new SimpleTest(); | ||
} | ||
|
||
function test_NumberIs42() public { | ||
assertEq(simpleTest.test(), 42); | ||
} | ||
} |
Oops, something went wrong.