diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..cbdb25a --- /dev/null +++ b/.env.template @@ -0,0 +1,11 @@ +# The name of the network (e.g., mainnet, arbitrum, etc.) +NETWORK_NAME=... + +# The URL of the Graph Node endpoint for self-hosted Graph Node +GRAPHNODE_URL=... + +# The URL of the IPFS endpoint for self-hosted IPFS +IPFS_URL=... + +# The version label for the deployment (e.g., v1.0.0) +VERSION_LABEL=... diff --git a/.gitignore b/.gitignore index 6dbc95f..9534881 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ subgraph.test.yaml test-stack/.env tests/.bin tests/.latest.json +.env diff --git a/.mocharc.json b/.mocharc.json index 1c4ae6c..89ba3a2 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -1,6 +1,5 @@ { "extension": ["ts"], - "spec": "itest/**/*.ts", "require": ["ts-node/register"], "timeout": 1000000, "node-option": [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4e401..b9e9448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## vNEXT +- Add Arbitrum & Avalanche networks. (#47) - Migrate integration tests from Jenkins to GitHub Actions. (#44) - Remove unused files to streamline the repository. (#42) - Rewrite Jenkins CI for future migration (#36, #37) diff --git a/config/env.ts b/config/env.ts new file mode 100644 index 0000000..9a53cc2 --- /dev/null +++ b/config/env.ts @@ -0,0 +1,17 @@ +import 'dotenv/config'; +import { z } from 'zod'; + +const envSchema = z.object({ + NETWORK_NAME: z.string().min(1, 'NETWORK_NAME is required').default('bellecour'), + + GRAPHNODE_URL: z + .string() + .url('GRAPHNODE_URL must be a valid URL') + .default('http://localhost:8020'), + + IPFS_URL: z.string().url('IPFS_URL must be a valid URL').default('http://localhost:5001'), + + VERSION_LABEL: z.string().min(1, 'VERSION_LABEL is required').default('bellecour/poco-v5'), +}); + +export const env = envSchema.parse(process.env); diff --git a/networks.json b/networks.json index f3cd007..85bc701 100644 --- a/networks.json +++ b/networks.json @@ -1,4 +1,48 @@ { + "fuji": { + "ERC1538": { + "address": "0x14B465079537655E1662F012e99EBa3863c8B9E0", + "startBlock": 39496461 + }, + "Core": { + "address": "0x14B465079537655E1662F012e99EBa3863c8B9E0", + "startBlock": 39496461 + }, + "AppRegistry": { + "address": "0x4a6531ce5150ee716b2d93865D0fbB9ce5492D17", + "startBlock": 39496461 + }, + "DatasetRegistry": { + "address": "0x3441A0C9FE488c51fcABa2bAAA048720f4D4F72D", + "startBlock": 39496461 + }, + "WorkerpoolRegistry": { + "address": "0xf81970E3CB0f8711bEaA79135e686873FfbBAC4A", + "startBlock": 39496461 + } + }, + "arbitrum-sepolia": { + "ERC1538": { + "address": "0x14B465079537655E1662F012e99EBa3863c8B9E0", + "startBlock": 145249746 + }, + "Core": { + "address": "0x14B465079537655E1662F012e99EBa3863c8B9E0", + "startBlock": 145249746 + }, + "AppRegistry": { + "address": "0x4a6531ce5150ee716b2d93865D0fbB9ce5492D17", + "startBlock": 145249746 + }, + "DatasetRegistry": { + "address": "0x3441A0C9FE488c51fcABa2bAAA048720f4D4F72D", + "startBlock": 145249746 + }, + "WorkerpoolRegistry": { + "address": "0xf81970E3CB0f8711bEaA79135e686873FfbBAC4A", + "startBlock": 145249746 + } + }, "bellecour": { "ERC1538": { "address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f", diff --git a/package-lock.json b/package-lock.json index a25a2ba..6e9e390 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,9 +15,11 @@ "devDependencies": { "@apollo/client": "^3.11.8", "@graphprotocol/graph-cli": "^0.96.0", - "@graphprotocol/graph-ts": "^0.38.0", + "@graphprotocol/graph-ts": "0.35.1", "@typechain/ethers-v6": "^0.5.1", "@types/mocha": "^10.0.9", + "dotenv": "^16.5.0", + "dotenv-cli": "^8.0.0", "ethers": "^6.13.5", "husky": "^9.1.6", "lint-staged": "^15.2.10", @@ -27,7 +29,8 @@ "prettier-plugin-organize-imports": "^4.1.0", "testcontainers": "^10.13.2", "ts-node": "^10.9.2", - "tsx": "^4.19.3" + "tsx": "^4.19.3", + "zod": "^3.24.3" } }, "node_modules/@adraffy/ens-normalize": { @@ -648,31 +651,27 @@ } }, "node_modules/@graphprotocol/graph-ts": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@graphprotocol/graph-ts/-/graph-ts-0.38.0.tgz", - "integrity": "sha512-fx9IpqbXHWMskl6wLDstKLy0VeszTQg6K5xsUEHXPkpOtceDkWAiDE8FyqsGF0IVTmE2Pxafw4t6+rEG8lVfyw==", + "version": "0.35.1", + "resolved": "https://registry.npmjs.org/@graphprotocol/graph-ts/-/graph-ts-0.35.1.tgz", + "integrity": "sha512-74CfuQmf7JI76/XCC34FTkMMKeaf+3Pn0FIV3m9KNeaOJ+OI3CvjMIVRhOZdKcJxsFCBGaCCl0eQjh47xTjxKA==", "dev": true, "dependencies": { - "assemblyscript": "0.27.31" + "assemblyscript": "0.19.10" } }, "node_modules/@graphprotocol/graph-ts/node_modules/assemblyscript": { - "version": "0.27.31", - "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.27.31.tgz", - "integrity": "sha512-Ra8kiGhgJQGZcBxjtMcyVRxOEJZX64kd+XGpjWzjcjgxWJVv+CAQO0aDBk4GQVhjYbOkATarC83mHjAVGtwPBQ==", + "version": "0.19.10", + "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.10.tgz", + "integrity": "sha512-HavcUBXB3mBTRGJcpvaQjmnmaqKHBGREjSPNsIvnAk2f9dj78y4BkMaSSdvBQYWcDDzsHQjyUC8stICFkD1Odg==", "dev": true, "license": "Apache-2.0", "dependencies": { - "binaryen": "116.0.0-nightly.20240114", - "long": "^5.2.1" + "binaryen": "101.0.0-nightly.20210723", + "long": "^4.0.0" }, "bin": { - "asc": "bin/asc.js", - "asinit": "bin/asinit.js" - }, - "engines": { - "node": ">=16", - "npm": ">=7" + "asc": "bin/asc", + "asinit": "bin/asinit" }, "funding": { "type": "opencollective", @@ -680,16 +679,22 @@ } }, "node_modules/@graphprotocol/graph-ts/node_modules/binaryen": { - "version": "116.0.0-nightly.20240114", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-116.0.0-nightly.20240114.tgz", - "integrity": "sha512-0GZrojJnuhoe+hiwji7QFaL3tBlJoA+KFUN7ouYSDGZLSo9CKM8swQX8n/UcbR0d1VuZKU+nhogNzv423JEu5A==", + "version": "101.0.0-nightly.20210723", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz", + "integrity": "sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA==", "dev": true, "license": "Apache-2.0", "bin": { - "wasm-opt": "bin/wasm-opt", - "wasm2js": "bin/wasm2js" + "wasm-opt": "bin/wasm-opt" } }, + "node_modules/@graphprotocol/graph-ts/node_modules/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/@graphql-typed-document-node/core": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz", @@ -3825,6 +3830,45 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/dotenv": { + "version": "16.5.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz", + "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dotenv-cli": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-8.0.0.tgz", + "integrity": "sha512-aLqYbK7xKOiTMIRf1lDPbI+Y+Ip/wo5k3eyp6ePysVaSqbyxjyK3dK35BTxG+rmd7djf5q2UPs4noPNH+cj0Qw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.6", + "dotenv": "^16.3.0", + "dotenv-expand": "^10.0.0", + "minimist": "^1.2.6" + }, + "bin": { + "dotenv": "cli.js" + } + }, + "node_modules/dotenv-expand": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-10.0.0.tgz", + "integrity": "sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -6516,6 +6560,16 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/minipass": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", diff --git a/package.json b/package.json index 3c39497..5dbcec7 100644 --- a/package.json +++ b/package.json @@ -7,13 +7,13 @@ "scripts": { "prepare": "husky", "generate:typechain": "typechain --target ethers-v6 --out-dir generated/typechain './node_modules/@iexec/poco/build/contracts/*.json' --ts-nocheck", - "build": "rm -rf generated && rm -rf build && npm run generate:typechain && graph codegen && graph build --network ${NETWORK_NAME:-bellecour}", + "build": "dotenv -e .env -- rm -rf generated && rm -rf build && npm run generate:typechain && graph codegen && graph build --network ${NETWORK_NAME:-bellecour}", "test": "npm run test:unit && npm run test:e2e", - "test:unit": "graph test", - "test:e2e": "NETWORK_NAME=${NETWORK_NAME:-bellecour} mocha", + "test:unit": "graph test unit", + "test:e2e": "mocha tests/e2e/**/*.ts", "coverage": "graph test -- -c", - "create": "graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}", - "deploy": "graph deploy ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --version-label ${VERSION_LABEL:-bellecour/poco-v5}", + "create": "dotenv -e .env -- graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}", + "deploy": "dotenv -e .env -- graph deploy ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --version-label ${VERSION_LABEL:-bellecour/poco-v5}", "all": "npm run build && npm run create && npm run deploy", "stop-test-stack": "cd test-stack && docker compose down --remove-orphans --volumes", "start-test-stack": "npm run stop-test-stack && cd test-stack && export NETWORK_NAME=${NETWORK_NAME:-bellecour} && tsx prepare-test-env.ts && docker compose build && docker compose up -d", @@ -36,9 +36,11 @@ "devDependencies": { "@apollo/client": "^3.11.8", "@graphprotocol/graph-cli": "^0.96.0", - "@graphprotocol/graph-ts": "^0.38.0", + "@graphprotocol/graph-ts": "0.35.1", "@typechain/ethers-v6": "^0.5.1", "@types/mocha": "^10.0.9", + "dotenv": "^16.5.0", + "dotenv-cli": "^8.0.0", "ethers": "^6.13.5", "husky": "^9.1.6", "lint-staged": "^15.2.10", @@ -48,7 +50,8 @@ "prettier-plugin-organize-imports": "^4.1.0", "testcontainers": "^10.13.2", "ts-node": "^10.9.2", - "tsx": "^4.19.3" + "tsx": "^4.19.3", + "zod": "^3.24.3" }, "dependencies": { "@iexec/poco": "^5.5.0", diff --git a/subgraph.yaml b/subgraph.yaml index ebc6c8b..b895ddb 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -40,6 +40,7 @@ dataSources: language: wasm/assemblyscript entities: - Category + - Protocol - Account - AppOrder - DatasetOrder diff --git a/itest/integration.test.ts b/tests/e2e/integration.test.ts similarity index 87% rename from itest/integration.test.ts rename to tests/e2e/integration.test.ts index 95caee0..b7b7449 100644 --- a/itest/integration.test.ts +++ b/tests/e2e/integration.test.ts @@ -2,15 +2,16 @@ import { InMemoryCache } from '@apollo/client/cache'; import { ApolloClient, gql } from '@apollo/client/core'; import { equal } from 'assert'; import { JsonRpcProvider, Wallet, ZeroHash } from 'ethers'; -import { AppRegistry__factory, IexecInterfaceToken__factory } from '../generated/typechain'; -import config from '../networks.json' with { type: 'json' }; +import { env } from '../../config/env'; +import { AppRegistry__factory, IexecInterfaceToken__factory } from '../../generated/typechain'; +import config from '../../networks.json' with { type: 'json' }; -const APIURL = `http://localhost:8000/subgraphs/name/${process.env.NETWORK_NAME}/poco`; +const APIURL = `http://localhost:8000/subgraphs/name/${env.NETWORK_NAME}/poco`; const client = new ApolloClient({ uri: APIURL, cache: new InMemoryCache(), }); -const networkName = process.env.NETWORK_NAME!; +const networkName = env.NETWORK_NAME!; const iexecProxyAddress = (config as any)[networkName].ERC1538.address; describe('Integration tests', () => {