Skip to content

Commit 14f4970

Browse files
committed
fix: use eslint-graph-config for data-edge
1 parent 6c06202 commit 14f4970

23 files changed

+1809
-12132
lines changed

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
# contracts
55
cd packages/contracts
66
npx --no-install lint-staged
7+
8+
# data-edge
9+
cd ../data-edge
10+
npx --no-install lint-staged

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"packages/eslint-graph-config",
1212
"packages/sdk",
1313
"packages/solhint-graph-config",
14-
"packages/token-distribution"
14+
"packages/token-distribution",
15+
"packages/data-edge"
1516
],
1617
"scripts": {
1718
"postinstall": "husky install",

packages/data-edge/.eslintignore

-5
This file was deleted.

packages/data-edge/.eslintrc

-15
This file was deleted.

packages/data-edge/.gitattributes

-1
This file was deleted.

packages/data-edge/.husky/commit-msg

-4
This file was deleted.

packages/data-edge/.husky/pre-commit

-4
This file was deleted.

packages/data-edge/.prettierrc.json

-35
This file was deleted.

packages/data-edge/commitlint.config.js

-1
This file was deleted.

packages/data-edge/eslint.config.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const config = require('eslint-graph-config')
2+
3+
module.exports = [
4+
...config.default,
5+
{
6+
rules: {
7+
'@typescript-eslint/no-unsafe-assignment': 'off',
8+
'@typescript-eslint/no-var-requires': 'off',
9+
'@typescript-eslint/no-unsafe-call': 'off',
10+
'@typescript-eslint/no-unsafe-member-access': 'off',
11+
'@typescript-eslint/no-unsafe-argument': 'off',
12+
},
13+
},
14+
{
15+
ignores: ['**/reports/*'],
16+
},
17+
]

packages/data-edge/hardhat.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function setupDefaultNetworkProviders(buidlerConfig) {
7878

7979
// Tasks
8080

81-
task('accounts', 'Prints the list of accounts', async (taskArgs, bre) => {
81+
task('accounts', 'Prints the list of accounts', async (_, bre) => {
8282
const accounts = await bre.ethers.getSigners()
8383
for (const account of accounts) {
8484
console.log(await account.getAddress())

packages/data-edge/package.json

+7-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@graphprotocol/graph-data-edge",
2+
"name": "@graphprotocol/data-edge",
33
"version": "0.2.0",
44
"description": "The Graph Data Edge",
55
"main": "index.js",
@@ -13,11 +13,8 @@
1313
"test:gas": "RUN_EVM=true REPORT_GAS=true scripts/test",
1414
"test:coverage": "scripts/coverage",
1515
"lint": "yarn lint:ts && yarn lint:sol",
16-
"lint:fix": "yarn lint:ts:fix && yarn lint:sol:fix",
17-
"lint:ts": "eslint '*/**/*.{js,ts}'",
18-
"lint:ts:fix": "yarn prettier:ts && eslint '*/**/*.{js,ts}' --fix",
19-
"lint:sol": "solhint './contracts/**/*.sol'",
20-
"lint:sol:fix": "yarn prettier:sol && solhint --fix './contracts/**/*.sol'",
16+
"lint:ts": "eslint '**/*.{js,ts}' --fix",
17+
"lint:sol": "prettier --write 'contracts/**/*.sol' && solhint --fix --noPrompt contracts/**/*.sol --config node_modules/solhint-graph-config/index.js",
2118
"prettier": "yarn prettier:ts && yarn prettier:sol",
2219
"prettier:ts": "prettier --write 'test/**/*.ts'",
2320
"prettier:sol": "prettier --write 'contracts/**/*.sol'",
@@ -62,19 +59,10 @@
6259
"@typechain/hardhat": "^4.0.0",
6360
"@types/mocha": "^9.0.0",
6461
"@types/node": "^17.0.0",
65-
"@typescript-eslint/eslint-plugin": "^5.0.0",
66-
"@typescript-eslint/parser": "^5.0.0",
6762
"chai": "^4.2.0",
6863
"dotenv": "^16.0.0",
69-
"eslint": "^8.0.0",
70-
"eslint-config-prettier": "^8.0.0",
71-
"eslint-config-standard": "^16.0.0",
72-
"eslint-plugin-import": "^2.22.0",
73-
"eslint-plugin-mocha-no-only": "^1.1.1",
74-
"eslint-plugin-node": "^11.1.0",
75-
"eslint-plugin-prettier": "^4.0.0",
76-
"eslint-plugin-promise": "^6.0.0",
77-
"eslint-plugin-standard": "^5.0.0",
64+
"eslint": "^8.57.0",
65+
"eslint-graph-config": "workspace:^0.0.1",
7866
"ethereum-waffle": "^3.0.2",
7967
"ethers": "^5.1.3",
8068
"ethlint": "^1.2.5",
@@ -86,8 +74,8 @@
8674
"lint-staged": "^12.3.5",
8775
"prettier": "^2.1.1",
8876
"prettier-plugin-solidity": "^1.0.0-alpha.56",
89-
"solhint": "^3.3.7",
90-
"solhint-plugin-prettier": "^0.0.5",
77+
"solhint": "^4.5.2",
78+
"solhint-graph-config": "workspace:^0.0.1",
9179
"solidity-coverage": "^0.7.10",
9280
"truffle-flattener": "^1.4.4",
9381
"ts-node": "^10.5.0",

packages/data-edge/scripts/deploy-local.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ async function main() {
1616
// The address the Contract WILL have once mined
1717
console.log(`> deployer: ${await contract.signer.getAddress()}`)
1818
console.log(`> contract: ${contract.address}`)
19-
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
19+
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
2020

2121
// The contract is NOT deployed yet; we must wait until it is mined
2222
await contract.deployed()
2323
console.log(`Done!`)
2424

2525
// Update addresses.json
26-
const chainId = (network.config.chainId as number).toString()
26+
const chainId = (network.config.chainId).toString()
2727
if (!addresses[chainId]) {
2828
addresses[chainId] = {}
2929
}

packages/data-edge/scripts/deploy.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ async function main() {
1616
// The address the Contract WILL have once mined
1717
console.log(`> deployer: ${await contract.signer.getAddress()}`)
1818
console.log(`> contract: ${contract.address}`)
19-
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
19+
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
2020

2121
// The contract is NOT deployed yet; we must wait until it is mined
2222
await contract.deployed()
2323
console.log(`Done!`)
2424

2525
// Update addresses.json
26-
const chainId = (network.config.chainId as number).toString()
26+
const chainId = (network.config.chainId).toString()
2727
if (!addresses[chainId]) {
2828
addresses[chainId] = {}
2929
}

packages/data-edge/tasks/craft-calldata.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { task } from 'hardhat/config'
21
import '@nomiclabs/hardhat-ethers'
32
import { Contract } from 'ethers'
3+
import { task } from 'hardhat/config'
44

55
const baseABI = [
66
{

packages/data-edge/tasks/post-calldata.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { task } from 'hardhat/config'
21
import '@nomiclabs/hardhat-ethers'
2+
import { task } from 'hardhat/config'
33

44
task('data:post', 'Post calldata')
55
.addParam('edge', 'Address of the data edge contract')
@@ -20,7 +20,7 @@ task('data:post', 'Post calldata')
2020
console.log(`> sender: ${await contract.signer.getAddress()}`)
2121
console.log(`> payload: ${txData}`)
2222
const tx = await contract.signer.sendTransaction(txRequest)
23-
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
23+
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
2424
const rx = await tx.wait()
2525
console.log('> rx: ', rx.status == 1 ? 'success' : 'failed')
2626
console.log(`Done!`)
+38-35
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,59 @@
1-
import { ethers } from 'hardhat'
2-
import '@nomiclabs/hardhat-ethers'
3-
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
1+
import "@nomiclabs/hardhat-ethers";
2+
import { ethers } from "hardhat";
3+
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
44

5-
import { DataEdge__factory, DataEdge } from '../build/types'
6-
import { expect } from 'chai'
5+
import { DataEdge, DataEdge__factory } from "../build/types";
6+
import { expect } from "chai";
77

8-
const { getContractFactory, getSigners } = ethers
9-
const { id, hexConcat, randomBytes, hexlify, defaultAbiCoder } = ethers.utils
8+
const { getContractFactory, getSigners } = ethers;
9+
const { id, hexConcat, randomBytes, hexlify, defaultAbiCoder } = ethers.utils;
1010

11-
describe('DataEdge', () => {
12-
let edge: DataEdge
13-
let me: SignerWithAddress
11+
describe("DataEdge", () => {
12+
let edge: DataEdge;
13+
let me: SignerWithAddress;
1414

1515
beforeEach(async () => {
16-
;[me] = await getSigners() // eslint-disable-line @typescript-eslint/no-extra-semi
16+
[me] = await getSigners(); // eslint-disable-line @typescript-eslint/no-extra-semi
1717

18-
const factory = (await getContractFactory('DataEdge', me)) as DataEdge__factory
19-
edge = await factory.deploy()
20-
await edge.deployed()
21-
})
18+
const factory = (await getContractFactory(
19+
"DataEdge",
20+
me
21+
)) as DataEdge__factory;
22+
edge = await factory.deploy();
23+
await edge.deployed();
24+
});
2225

23-
describe('submit data', async () => {
24-
it('post any arbitrary data as selector', async () => {
26+
describe("submit data", () => {
27+
it("post any arbitrary data as selector", async () => {
2528
// virtual function call
2629
const txRequest = {
27-
data: '0x123123',
30+
data: "0x123123",
2831
to: edge.address,
29-
}
32+
};
3033
// send transaction
31-
const tx = await me.sendTransaction(txRequest)
32-
const rx = await tx.wait()
34+
const tx = await me.sendTransaction(txRequest);
35+
const rx = await tx.wait();
3336
// transaction must work - it just stores data
34-
expect(rx.status).eq(1)
35-
})
37+
expect(rx.status).eq(1);
38+
});
3639

37-
it('post long calldata', async () => {
40+
it("post long calldata", async () => {
3841
// virtual function call
39-
const selector = id('setEpochBlocksPayload(bytes)').slice(0, 10)
42+
const selector = id("setEpochBlocksPayload(bytes)").slice(0, 10);
4043
// calldata payload
41-
const messageBlocks = hexlify(randomBytes(1000))
42-
const txCalldata = defaultAbiCoder.encode(['bytes'], [messageBlocks]) // we abi encode to allow the subgraph to decode it properly
43-
const txData = hexConcat([selector, txCalldata])
44+
const messageBlocks = hexlify(randomBytes(1000));
45+
const txCalldata = defaultAbiCoder.encode(["bytes"], [messageBlocks]); // we abi encode to allow the subgraph to decode it properly
46+
const txData = hexConcat([selector, txCalldata]);
4447
// craft full transaction
4548
const txRequest = {
4649
data: txData,
4750
to: edge.address,
48-
}
51+
};
4952
// send transaction
50-
const tx = await me.sendTransaction(txRequest)
51-
const rx = await tx.wait()
53+
const tx = await me.sendTransaction(txRequest);
54+
const rx = await tx.wait();
5255
// transaction must work - it just stores data
53-
expect(rx.status).eq(1)
54-
})
55-
})
56-
})
56+
expect(rx.status).eq(1);
57+
});
58+
});
59+
});

0 commit comments

Comments
 (0)