Skip to content

Commit

Permalink
fix: use eslint-graph-config for data-edge
Browse files Browse the repository at this point in the history
  • Loading branch information
Maikol committed Mar 20, 2024
1 parent 6c06202 commit 14f4970
Show file tree
Hide file tree
Showing 23 changed files with 1,809 additions and 12,132 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
# contracts
cd packages/contracts
npx --no-install lint-staged

# data-edge
cd ../data-edge
npx --no-install lint-staged
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"packages/eslint-graph-config",
"packages/sdk",
"packages/solhint-graph-config",
"packages/token-distribution"
"packages/token-distribution",
"packages/data-edge"
],
"scripts": {
"postinstall": "husky install",
Expand Down
5 changes: 0 additions & 5 deletions packages/data-edge/.eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions packages/data-edge/.eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion packages/data-edge/.gitattributes

This file was deleted.

4 changes: 0 additions & 4 deletions packages/data-edge/.husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions packages/data-edge/.husky/pre-commit

This file was deleted.

35 changes: 0 additions & 35 deletions packages/data-edge/.prettierrc.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/data-edge/commitlint.config.js

This file was deleted.

17 changes: 17 additions & 0 deletions packages/data-edge/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const config = require('eslint-graph-config')

module.exports = [
...config.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: ['**/reports/*'],
},
]
2 changes: 1 addition & 1 deletion packages/data-edge/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function setupDefaultNetworkProviders(buidlerConfig) {

// Tasks

task('accounts', 'Prints the list of accounts', async (taskArgs, bre) => {
task('accounts', 'Prints the list of accounts', async (_, bre) => {
const accounts = await bre.ethers.getSigners()
for (const account of accounts) {
console.log(await account.getAddress())
Expand Down
26 changes: 7 additions & 19 deletions packages/data-edge/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@graphprotocol/graph-data-edge",
"name": "@graphprotocol/data-edge",
"version": "0.2.0",
"description": "The Graph Data Edge",
"main": "index.js",
Expand All @@ -13,11 +13,8 @@
"test:gas": "RUN_EVM=true REPORT_GAS=true scripts/test",
"test:coverage": "scripts/coverage",
"lint": "yarn lint:ts && yarn lint:sol",
"lint:fix": "yarn lint:ts:fix && yarn lint:sol:fix",
"lint:ts": "eslint '*/**/*.{js,ts}'",
"lint:ts:fix": "yarn prettier:ts && eslint '*/**/*.{js,ts}' --fix",
"lint:sol": "solhint './contracts/**/*.sol'",
"lint:sol:fix": "yarn prettier:sol && solhint --fix './contracts/**/*.sol'",
"lint:ts": "eslint '**/*.{js,ts}' --fix",
"lint:sol": "prettier --write 'contracts/**/*.sol' && solhint --fix --noPrompt contracts/**/*.sol --config node_modules/solhint-graph-config/index.js",
"prettier": "yarn prettier:ts && yarn prettier:sol",
"prettier:ts": "prettier --write 'test/**/*.ts'",
"prettier:sol": "prettier --write 'contracts/**/*.sol'",
Expand Down Expand Up @@ -62,19 +59,10 @@
"@typechain/hardhat": "^4.0.0",
"@types/mocha": "^9.0.0",
"@types/node": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"chai": "^4.2.0",
"dotenv": "^16.0.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^8.0.0",
"eslint-config-standard": "^16.0.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-mocha-no-only": "^1.1.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-standard": "^5.0.0",
"eslint": "^8.57.0",
"eslint-graph-config": "workspace:^0.0.1",
"ethereum-waffle": "^3.0.2",
"ethers": "^5.1.3",
"ethlint": "^1.2.5",
Expand All @@ -86,8 +74,8 @@
"lint-staged": "^12.3.5",
"prettier": "^2.1.1",
"prettier-plugin-solidity": "^1.0.0-alpha.56",
"solhint": "^3.3.7",
"solhint-plugin-prettier": "^0.0.5",
"solhint": "^4.5.2",
"solhint-graph-config": "workspace:^0.0.1",
"solidity-coverage": "^0.7.10",
"truffle-flattener": "^1.4.4",
"ts-node": "^10.5.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/data-edge/scripts/deploy-local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ async function main() {
// The address the Contract WILL have once mined
console.log(`> deployer: ${await contract.signer.getAddress()}`)
console.log(`> contract: ${contract.address}`)
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)

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

// Update addresses.json
const chainId = (network.config.chainId as number).toString()
const chainId = (network.config.chainId).toString()
if (!addresses[chainId]) {
addresses[chainId] = {}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/data-edge/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ async function main() {
// The address the Contract WILL have once mined
console.log(`> deployer: ${await contract.signer.getAddress()}`)
console.log(`> contract: ${contract.address}`)
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)

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

// Update addresses.json
const chainId = (network.config.chainId as number).toString()
const chainId = (network.config.chainId).toString()
if (!addresses[chainId]) {
addresses[chainId] = {}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/data-edge/tasks/craft-calldata.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task } from 'hardhat/config'
import '@nomiclabs/hardhat-ethers'
import { Contract } from 'ethers'
import { task } from 'hardhat/config'

const baseABI = [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/data-edge/tasks/post-calldata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { task } from 'hardhat/config'
import '@nomiclabs/hardhat-ethers'
import { task } from 'hardhat/config'

task('data:post', 'Post calldata')
.addParam('edge', 'Address of the data edge contract')
Expand All @@ -20,7 +20,7 @@ task('data:post', 'Post calldata')
console.log(`> sender: ${await contract.signer.getAddress()}`)
console.log(`> payload: ${txData}`)
const tx = await contract.signer.sendTransaction(txRequest)
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
console.log(`> tx: ${tx.hash} nonce:${tx.nonce} limit: ${tx.gasLimit.toString()} gas: ${tx.gasPrice.toNumber() / 1e9} (gwei)`)
const rx = await tx.wait()
console.log('> rx: ', rx.status == 1 ? 'success' : 'failed')
console.log(`Done!`)
Expand Down
73 changes: 38 additions & 35 deletions packages/data-edge/test/dataedge.test.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,59 @@
import { ethers } from 'hardhat'
import '@nomiclabs/hardhat-ethers'
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
import "@nomiclabs/hardhat-ethers";
import { ethers } from "hardhat";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";

import { DataEdge__factory, DataEdge } from '../build/types'
import { expect } from 'chai'
import { DataEdge, DataEdge__factory } from "../build/types";
import { expect } from "chai";

const { getContractFactory, getSigners } = ethers
const { id, hexConcat, randomBytes, hexlify, defaultAbiCoder } = ethers.utils
const { getContractFactory, getSigners } = ethers;
const { id, hexConcat, randomBytes, hexlify, defaultAbiCoder } = ethers.utils;

describe('DataEdge', () => {
let edge: DataEdge
let me: SignerWithAddress
describe("DataEdge", () => {
let edge: DataEdge;
let me: SignerWithAddress;

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

const factory = (await getContractFactory('DataEdge', me)) as DataEdge__factory
edge = await factory.deploy()
await edge.deployed()
})
const factory = (await getContractFactory(
"DataEdge",
me
)) as DataEdge__factory;
edge = await factory.deploy();
await edge.deployed();
});

describe('submit data', async () => {
it('post any arbitrary data as selector', async () => {
describe("submit data", () => {
it("post any arbitrary data as selector", async () => {
// virtual function call
const txRequest = {
data: '0x123123',
data: "0x123123",
to: edge.address,
}
};
// send transaction
const tx = await me.sendTransaction(txRequest)
const rx = await tx.wait()
const tx = await me.sendTransaction(txRequest);
const rx = await tx.wait();
// transaction must work - it just stores data
expect(rx.status).eq(1)
})
expect(rx.status).eq(1);
});

it('post long calldata', async () => {
it("post long calldata", async () => {
// virtual function call
const selector = id('setEpochBlocksPayload(bytes)').slice(0, 10)
const selector = id("setEpochBlocksPayload(bytes)").slice(0, 10);
// calldata payload
const messageBlocks = hexlify(randomBytes(1000))
const txCalldata = defaultAbiCoder.encode(['bytes'], [messageBlocks]) // we abi encode to allow the subgraph to decode it properly
const txData = hexConcat([selector, txCalldata])
const messageBlocks = hexlify(randomBytes(1000));
const txCalldata = defaultAbiCoder.encode(["bytes"], [messageBlocks]); // we abi encode to allow the subgraph to decode it properly
const txData = hexConcat([selector, txCalldata]);
// craft full transaction
const txRequest = {
data: txData,
to: edge.address,
}
};
// send transaction
const tx = await me.sendTransaction(txRequest)
const rx = await tx.wait()
const tx = await me.sendTransaction(txRequest);
const rx = await tx.wait();
// transaction must work - it just stores data
expect(rx.status).eq(1)
})
})
})
expect(rx.status).eq(1);
});
});
});
Loading

0 comments on commit 14f4970

Please sign in to comment.