Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedupe ts deps #81

Closed
wants to merge 12 commits into from
16 changes: 3 additions & 13 deletions ethereum_history_api/tests/.eslintrc.cjs → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module.exports = {
root: true,
ignorePatterns: ['**/.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.json'
project: 'ethereum_history_api/oracles/tsconfig.json'
},
env: {
browser: true,
es2021: true
},
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'plugin:prettier/recommended'],
Expand All @@ -18,17 +19,6 @@ module.exports = {
assertionStyle: 'as',
objectLiteralTypeAssertions: 'allow'
}
],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'json-bigint',
message: 'Use ./src/utils/json-bigint instead'
}
]
}
]
},
overrides: [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ts_lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
echo '{ "abi": [], "bytecode": { "object": "" } }' > ethereum_history_api/contracts/out/UltraVerifier.sol/UltraVerifier.json

- name: Run TypeScript Build
run: yarn build:all
run: yarn build

- name: Run TypeScript format check
run: yarn format:all:ci
2 changes: 1 addition & 1 deletion .github/workflows/ts_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
run: forge build

- name: Run TypeScript Build
run: yarn build:all
run: yarn build

- name: Run Unit Tests
working-directory: ethereum_history_api/oracles
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
target
proofs
contract
contract
dist
928 changes: 114 additions & 814 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file modified .yarn/install-state.gz
Binary file not shown.
55 changes: 13 additions & 42 deletions ethereum_history_api/oracles/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,44 +1,15 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json",
},
env: {
browser: true,
es2021: true,
},
extends: [
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended",
],
rules: {
// Override specific rules
"@typescript-eslint/consistent-type-assertions": [
"error",
{
assertionStyle: "as",
objectLiteralTypeAssertions: "allow",
},
],
"no-restricted-imports": ['error', {
'paths': [{
'name': 'json-bigint',
'message': 'Use ./src/utils/json-bigint instead'
}]
}]
},
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
],
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'json-bigint',
message: 'Use ./src/utils/json-bigint instead'
}
]
}
]
}
};
29 changes: 7 additions & 22 deletions ethereum_history_api/oracles/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "noir-ethereum-api-oracles",
"version": "1.0.0",
"main": "dist/oracles/src/main.js",
"types": "dist/oracles/src/main.d.ts",
"main": "dist/main.js",
"types": "dist/main.d.ts",
"type": "module",
"scripts": {
"test:unit": "vitest run --config vitest.unit.config.ts",
"build": "tsc",
"build": "tsc --build --verbose",
"typecheck": "tsc --noEmit",
"lint": "eslint src test --ext .ts",
"lint:fix": "eslint src test --ext .ts --fix",
"format": "prettier --write src test",
"format:ci": "prettier --check src test",
"lint": "eslint --ext .ts",
"lint:fix": "eslint --ext .ts --fix",
"format": "prettier --write src",
"format:ci": "prettier --check src",
"oracle-server": "tsx src/noir/oracles/server",
"fetch-blocks": "tsx src/script/fetchBlocks",
"fetch-proofs": "tsx src/script/fetchProofs",
Expand All @@ -20,37 +20,22 @@
"author": "",
"license": "ISC",
"dependencies": {
"@noir-lang/backend_barretenberg": "0.23.0",
"@noir-lang/noir_js": "0.23.0",
"@noir-lang/noirc_abi": "^0.23.0",
"body-parser": "^1.20.2",
"dotenv": "^16.3.1",
"fastify": "^4.25.2",
"json-bigint": "^1.0.0",
"json-rpc-2.0": "^1.7.0",
"lodash.isequal": "^4.5.0",
"toml": "^3.0.0",
"viem": "^2.0.0"
},
"devDependencies": {
"@types/body-parser": "^1",
"@types/eslint": "^8",
"@types/express": "^4",
"@types/json-bigint": "^1",
"@types/lodash.isequal": "^4",
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^6.18.0",
"@typescript-eslint/parser": "^6.18.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-promise": "^6.0.0",
"pino-pretty": "^10.3.1",
"prettier": "^3.1.1",
"rollup-plugin-copy": "^3.5.0",
"tsx": "^4.7.0",
"typescript": "^5.3.3",
"vitest": "^1.0.4"
Expand Down
4 changes: 2 additions & 2 deletions ethereum_history_api/oracles/src/ethereum/blockHeader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { parse } from '../util/json-bigint.js';
import { describe, expect, it } from 'vitest';
import { type GetBlockReturnType } from 'viem';
import { type BlockHeader, calculateBlockHash, calculateBlockHeaderHash, headerToRlp } from './blockHeader.js';
import { blockHeaders } from '../../test/fixtures/blockHeader.json';
import { blockHeaders } from '../../fixtures/blockHeader.json';

for (const header of blockHeaders) {
describe('encodeBlockHeader', () => {
Expand All @@ -20,7 +20,7 @@ for (const header of blockHeaders) {
}

describe('calculateBlockHash', async () => {
const blocks = parse(await readFile('./test/fixtures/blocks.json', 'utf-8'));
const blocks = parse(await readFile('./fixtures/blocks.json', 'utf-8'));
for (const block of blocks) {
it(`block #${block.number}`, async () => {
expect(calculateBlockHash(block as GetBlockReturnType)).toBe(block.hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { readObject } from '../util/file.js';

describe('mockingClient', () => {
it('read recorded JSON-RPC API calls from file in mocking client', async () => {
const filePath = './test/fixtures/mockClientData.json';
const filePath = './fixtures/mockClientData.json';
const mockingClient: PublicClient = await createMockClient(filePath);

const block = await mockingClient.getBlock(GET_BLOCK_PARAMETERS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe(
"0x5", "0xd7", "0xa", "0xb8", "0x65", "0xde", "0x6e", "0x19", "0x3b", "0xbb"
]
const blockNumberInNoirFormat = '0xd895ce';
const client = await createMockClient('./test/fixtures/mockClientData.json');
const client = await createMockClient('./fixtures/mockClientData.json');
const account = await getAccountOracle(client, [[blockNumberInNoirFormat], accountAddressInNoirFormat]);
expect(account[OFFSETS.NONCE]).toStrictEqual('0x1');
expect(account[OFFSETS.BALANCE]).toStrictEqual('0x313570a84bf378efd25');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { describe, expect, it } from 'vitest';
import { encodeAccount, encodeStateProof, parseNoirGetAccountArguments } from './accountOracles.js';
import { type GetProofReturnType } from 'viem';
import { ForeignCallOutput } from '@noir-lang/noir_js';
import { readFile } from 'fs/promises';
import { parse } from '../../util/json-bigint.js';
import account from '../../../test/fixtures/account.json';
import stateProof from '../../../test/fixtures/stateProof.json';
import { serializeAccount, serializeStateProof } from '../../../test/helpers.js';
import account from '../../../fixtures/account.json';
import stateProof from '../../../fixtures/stateProof.json';
import { ADDRESS } from '../../ethereum/recordingClient.test.js';

describe('encodeAccount', async () => {
it('encode account', async () => {
const proof: GetProofReturnType = parse(await readFile('./test/fixtures/eth_getProof_response.json', 'utf-8'));
const proof: GetProofReturnType = parse(await readFile('./fixtures/eth_getProof_response.json', 'utf-8'));

expect(encodeAccount(proof)).toStrictEqual(serializeAccount(account));
expect(encodeStateProof(proof)).toStrictEqual(serializeStateProof(stateProof));
Expand All @@ -30,3 +30,25 @@ describe('encodeAccount', async () => {
});
});
});

export interface Account {
nonce: string;
balance: string;
codeHash: string[];
storageHash: string[];
}

export interface AccountStateProof {
key: string[];
value: string[];
proof: string[];
depth: string;
}

export function serializeAccount(account: Account): ForeignCallOutput[] {
return [account.nonce, account.balance, account.storageHash, account.codeHash];
}

export function serializeStateProof(account: AccountStateProof): ForeignCallOutput[] {
return [account.key, account.value, account.proof, account.depth];
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createMockClient } from '../../ethereum/mockClient.js';
describe(
'headerOracle',
async () => {
const client = await createMockClient('./test/fixtures/mockClientData.json');
const client = await createMockClient('./fixtures/mockClientData.json');

it('getBlock', async () => {
const blockHeader: BlockHeader = await getBlock(client, 0n);
Expand Down
2 changes: 1 addition & 1 deletion ethereum_history_api/oracles/src/script/encodeHeader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { blockHeaders } from '../../test/fixtures/blockHeader.json';
import { blockHeaders } from '../../fixtures/blockHeader.json';
import { assert } from '../util/assert.js';
import { type BlockHeader } from '../ethereum/blockHeader.js';
import { encodeBlockHeaderPartial } from '../noir/oracles/headerOracle.js';
Expand Down
34 changes: 0 additions & 34 deletions ethereum_history_api/oracles/test/helpers.ts

This file was deleted.

4 changes: 3 additions & 1 deletion ethereum_history_api/oracles/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig.common.json",
"include": ["src/**/*.ts", "fixtures/*.json", "package.json", "../contracts/out/UltraVerifier.sol/UltraVerifier.json"],
"compilerOptions": {
"rootDir": "src",
"outDir": "dist"
}
}
29 changes: 3 additions & 26 deletions ethereum_history_api/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,26 @@
"type": "module",
"scripts": {
"test:e2e": "vitest run --config vitest.e2e.config.ts",
"build": "tsc",
"build": "tsc --build --verbose",
"typecheck": "tsc --noEmit",
"lint": "eslint src --ext .ts",
"lint:fix": "eslint src --ext .ts --fix",
"lint": "eslint --ext .ts",
"lint:fix": "eslint --ext .ts --fix",
"format": "prettier --write src",
"format:ci": "prettier --check src"
},
"dependencies": {
"@noir-lang/backend_barretenberg": "0.23.0",
"@noir-lang/noir_js": "0.23.0",
"@noir-lang/noirc_abi": "^0.23.0",
"body-parser": "^1.20.2",
"dotenv": "^16.3.1",
"fastify": "^4.25.2",
"json-bigint": "^1.0.0",
"json-rpc-2.0": "^1.7.0",
"lodash.isequal": "^4.5.0",
"noir-ethereum-api-oracles": "^1.0.0",
"toml": "^3.0.0",
"viem": "^2.0.0"
},
"devDependencies": {
"@types/body-parser": "^1",
"@types/eslint": "^8",
"@types/express": "^4",
"@types/json-bigint": "^1",
"@types/lodash.isequal": "^4",
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^6.18.0",
"@typescript-eslint/parser": "^6.18.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-promise": "^6.0.0",
"pino-pretty": "^10.3.1",
"prettier": "^3.1.1",
"rollup-plugin-copy": "^3.5.0",
"tsx": "^4.7.0",
"typescript": "^5.3.3",
"vite": "^4.5.0",
"vitest": "^1.0.4"
}
}
3 changes: 1 addition & 2 deletions ethereum_history_api/tests/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { type CompiledCircuit } from '@noir-lang/backend_barretenberg';
import { WitnessMap } from '@noir-lang/noir_js';
import { promises as fs } from 'fs';
import toml from 'toml';
import noir_ethereum_history_api from '../../../target/ethereum_history_api.json';
import { encodeHexString } from 'noir-ethereum-api-oracles';
import { abiEncode, type InputMap } from '@noir-lang/noirc_abi';
import { abiEncode, type InputMap, WitnessMap } from '@noir-lang/noirc_abi';

export const circuit = noir_ethereum_history_api as unknown as CompiledCircuit;

Expand Down
4 changes: 3 additions & 1 deletion ethereum_history_api/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig.common.json",
"include": ["src/**/*.ts"],
"compilerOptions": {
"rootDir": "src",
"outDir": "dist"
}
}
Loading
Loading