-
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.
feat: add subgraph service boilerplate
Signed-off-by: Tomás Migone <[email protected]>
- Loading branch information
Showing
29 changed files
with
1,189 additions
and
60 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/subgraph-service | ||
|
||
env: | ||
CI: true | ||
|
||
on: | ||
push: | ||
branches: "*" | ||
paths: | ||
- packages/subgraph-service/** | ||
pull_request: | ||
branches: "*" | ||
paths: | ||
- packages/subgraph-service/** | ||
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/subgraph-service | ||
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/subgraph-service/lib/forge-std"] | ||
path = packages/subgraph-service/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
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,12 @@ | ||
// @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, | ||
{ | ||
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,12 @@ | ||
import '@nomicfoundation/hardhat-foundry' | ||
import '@nomicfoundation/hardhat-toolbox' | ||
import { HardhatUserConfig } from 'hardhat/config' | ||
|
||
const config: HardhatUserConfig = { | ||
solidity: '0.8.25', | ||
paths: { | ||
artifacts: './build/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,54 @@ | ||
{ | ||
"name": "@graphprotocol/subgraph-service", | ||
"version": "0.0.1", | ||
"description": "", | ||
"author": "The Graph Team", | ||
"license": "GPL-2.0-or-later", | ||
"scripts": { | ||
"lint:ts": "eslint '**/*.{js,ts}' --fix", | ||
"lint:sol": "forge fmt", | ||
"lint": "yarn lint:ts && yarn lint:sol", | ||
"clean": "rm -rf build cache typechain-types", | ||
"build": "hardhat compile", | ||
"test": "forge 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", | ||
"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,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 | ||
}) |
Oops, something went wrong.