From 478a021a3ec08811f2d090908b28fb8a73c45efc Mon Sep 17 00:00:00 2001 From: Alejandro Date: Fri, 11 Oct 2024 09:24:32 -0300 Subject: [PATCH] Bootstrap optiguides pkg --- package-lock.json | 21 ++++++++++++-- packages/ethernaut-cli/hardhat.config.js | 1 + packages/ethernaut-cli/package.json | 1 + packages/ethernaut-optiguides/package.json | 28 +++++++++++++++++++ packages/ethernaut-optiguides/src/index.js | 11 ++++++++ .../src/scopes/optiguides.js | 4 +++ .../ethernaut-optiguides/src/tasks/query.js | 13 +++++++++ 7 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 packages/ethernaut-optiguides/package.json create mode 100644 packages/ethernaut-optiguides/src/index.js create mode 100644 packages/ethernaut-optiguides/src/scopes/optiguides.js create mode 100644 packages/ethernaut-optiguides/src/tasks/query.js diff --git a/package-lock.json b/package-lock.json index c4915e94..1a2a3c04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,9 +10,6 @@ "workspaces": [ "packages/*" ], - "dependencies": { - "ethernaut-util": "^1.1.11" - }, "devDependencies": { "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", @@ -5754,6 +5751,10 @@ "resolved": "packages/ethernaut-network-ui", "link": true }, + "node_modules/ethernaut-optiguides": { + "resolved": "packages/ethernaut-optiguides", + "link": true + }, "node_modules/ethernaut-oso": { "resolved": "packages/ethernaut-oso", "link": true @@ -14962,6 +14963,7 @@ "ethernaut-interact-ui": "^1.1.11", "ethernaut-network": "^1.1.11", "ethernaut-network-ui": "^1.1.11", + "ethernaut-optiguides": "^1.0.0", "ethernaut-oso": "^1.1.12", "ethernaut-ui": "^1.1.11", "ethernaut-util": "^1.1.11", @@ -15171,6 +15173,19 @@ "hardhat": "^2.22.2" } }, + "packages/ethernaut-optiguides": { + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "hardhat": "^2.22.2", + "mocha": "^10.4.0", + "nyc": "^15.1.0", + "nyc-report-lcov-absolute": "^1.0.0" + }, + "peerDependencies": { + "hardhat": "^2.22.2" + } + }, "packages/ethernaut-oso": { "version": "1.1.12", "license": "ISC", diff --git a/packages/ethernaut-cli/hardhat.config.js b/packages/ethernaut-cli/hardhat.config.js index 98c29794..c73c7cb6 100644 --- a/packages/ethernaut-cli/hardhat.config.js +++ b/packages/ethernaut-cli/hardhat.config.js @@ -26,6 +26,7 @@ require('ethernaut-wallet-ui') require('ethernaut-challenges') require('ethernaut-ui') require('ethernaut-oso') +require('ethernaut-optiguides') require('ethernaut-ai-ui') async function main() { diff --git a/packages/ethernaut-cli/package.json b/packages/ethernaut-cli/package.json index 9c6c3f28..3ca35f19 100644 --- a/packages/ethernaut-cli/package.json +++ b/packages/ethernaut-cli/package.json @@ -50,6 +50,7 @@ "ethernaut-util-ui": "^1.1.11", "ethernaut-wallet": "^1.1.11", "ethernaut-wallet-ui": "^1.1.11", + "ethernaut-optiguides": "^1.0.0", "figlet": "^1.7.0", "hardhat": "^2.22.2" }, diff --git a/packages/ethernaut-optiguides/package.json b/packages/ethernaut-optiguides/package.json new file mode 100644 index 00000000..19d1aa0e --- /dev/null +++ b/packages/ethernaut-optiguides/package.json @@ -0,0 +1,28 @@ +{ + "name": "ethernaut-optiguides", + "version": "1.0.0", + "description": "Embeddings for Optimism guides", + "main": "src/index.js", + "scripts": { + "build": "npm run install:test", + "compile": "echo 'No compile step'", + "install:test": "cd test/fixture-projects/basic-project && npm install", + "test": "nyc --nycrc-path ../../.nycrc.json mocha --config ../../.mocharc.json" + }, + "author": "Alejandro Santander", + "license": "ISC", + "peerDependencies": { + "hardhat": "^2.22.2" + }, + "devDependencies": { + "hardhat": "^2.22.2", + "mocha": "^10.4.0", + "nyc": "^15.1.0", + "nyc-report-lcov-absolute": "^1.0.0" + }, + "directories": { + "test": "test" + }, + "keywords": [], + "gitHead": "5ffea95c7b8186e6365da19d189a79f09a78d475" +} diff --git a/packages/ethernaut-optiguides/src/index.js b/packages/ethernaut-optiguides/src/index.js new file mode 100644 index 00000000..019ddb55 --- /dev/null +++ b/packages/ethernaut-optiguides/src/index.js @@ -0,0 +1,11 @@ +const { extendEnvironment } = require('hardhat/config') +const requireAll = require('ethernaut-common/src/io/require-all') +const spinner = require('ethernaut-common/src/ui/spinner') +const output = require('ethernaut-common/src/ui/output') + +requireAll(__dirname, 'tasks') + +extendEnvironment((hre) => { + spinner.enable(!hre.hardhatArguments.verbose) + output.setErrorVerbose(hre.hardhatArguments.verbose) +}) diff --git a/packages/ethernaut-optiguides/src/scopes/optiguides.js b/packages/ethernaut-optiguides/src/scopes/optiguides.js new file mode 100644 index 00000000..1370cd6d --- /dev/null +++ b/packages/ethernaut-optiguides/src/scopes/optiguides.js @@ -0,0 +1,4 @@ +const { scope } = require('hardhat/config') +const { description } = require('../../package.json') + +module.exports = scope('optiguides', description) diff --git a/packages/ethernaut-optiguides/src/tasks/query.js b/packages/ethernaut-optiguides/src/tasks/query.js new file mode 100644 index 00000000..00aa9705 --- /dev/null +++ b/packages/ethernaut-optiguides/src/tasks/query.js @@ -0,0 +1,13 @@ +const output = require('ethernaut-common/src/ui/output') + +require('../scopes/optiguides') + .task('query', 'Query the Optimism guides') + .setAction(async (_, hre) => { + try { + // TODO + + return output.resultBox('TODO') + } catch (err) { + return output.errorBox(err) + } + })