From 6c3fa0e2219ca6e8339f146ccc187da9fc621774 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 10:36:54 +0200 Subject: [PATCH 01/31] added targets for linters of libs --- libs/ghaction-helper/project.json | 3 ++- libs/remix-analyzer/project.json | 3 ++- libs/remix-astwalker/project.json | 3 ++- libs/remix-core-plugin/project.json | 3 ++- libs/remix-debug/project.json | 3 ++- libs/remix-lib/project.json | 3 ++- libs/remix-simulator/project.json | 3 ++- libs/remix-solidity/project.json | 3 ++- libs/remix-tests/project.json | 3 ++- libs/remix-url-resolver/project.json | 3 ++- libs/remix-ws-templates/project.json | 3 ++- libs/remixd/project.json | 3 ++- 12 files changed, 24 insertions(+), 12 deletions(-) diff --git a/libs/ghaction-helper/project.json b/libs/ghaction-helper/project.json index 9d93dfcab8..26e659e41d 100644 --- a/libs/ghaction-helper/project.json +++ b/libs/ghaction-helper/project.json @@ -22,7 +22,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/ghaction-helper/**/*.ts"] + "lintFilePatterns": ["libs/ghaction-helper/**/*.ts"], + "eslintConfig": "libs/ghaction-helper/.eslintrc" } } }, diff --git a/libs/remix-analyzer/project.json b/libs/remix-analyzer/project.json index 6700532bb1..0afd267977 100644 --- a/libs/remix-analyzer/project.json +++ b/libs/remix-analyzer/project.json @@ -25,7 +25,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remix-analyzer/**/*.ts"] + "lintFilePatterns": ["libs/remix-analyzer/**/*.ts"], + "eslintConfig": "libs/remix-analyzer/.eslintrc" } } }, diff --git a/libs/remix-astwalker/project.json b/libs/remix-astwalker/project.json index ba70ffc27d..a5f9f364d8 100644 --- a/libs/remix-astwalker/project.json +++ b/libs/remix-astwalker/project.json @@ -24,7 +24,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remix-astwalker/**/*.ts"] + "lintFilePatterns": ["libs/remix-astwalker/**/*.ts"], + "eslintConfig": "libs/remix-astwalker/.eslintrc" } } }, diff --git a/libs/remix-core-plugin/project.json b/libs/remix-core-plugin/project.json index f7d0ab2428..63e5359f06 100644 --- a/libs/remix-core-plugin/project.json +++ b/libs/remix-core-plugin/project.json @@ -19,7 +19,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remix-core-plugin/**/*.ts"] + "lintFilePatterns": ["libs/remix-core-plugin/**/*.ts"], + "eslintConfig": "libs/remix-core-plugin/.eslintrc" } } }, diff --git a/libs/remix-debug/project.json b/libs/remix-debug/project.json index 2f67c8b8cb..8db5345b74 100644 --- a/libs/remix-debug/project.json +++ b/libs/remix-debug/project.json @@ -34,7 +34,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remix-debug/**/*.ts"] + "lintFilePatterns": ["libs/remix-debug/**/*.ts"], + "eslintConfig": "libs/remix-debug/.eslintrc" } } }, diff --git a/libs/remix-lib/project.json b/libs/remix-lib/project.json index 6b5d30f821..b4f06e9063 100644 --- a/libs/remix-lib/project.json +++ b/libs/remix-lib/project.json @@ -21,7 +21,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remix-lib/**/*.ts"] + "lintFilePatterns": ["libs/remix-lib/**/*.ts"], + "eslintConfig": "libs/remix-lib/.eslinrc" } } }, diff --git a/libs/remix-simulator/project.json b/libs/remix-simulator/project.json index b4aa8b3007..e7aa4885df 100644 --- a/libs/remix-simulator/project.json +++ b/libs/remix-simulator/project.json @@ -33,7 +33,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remix-simulator/**/*.ts"] + "lintFilePatterns": ["libs/remix-simulator/**/*.ts"], + "eslintConfig": "libs/remix-simulator/.eslintrc" } } }, diff --git a/libs/remix-solidity/project.json b/libs/remix-solidity/project.json index 71785eb335..e0a9edd436 100644 --- a/libs/remix-solidity/project.json +++ b/libs/remix-solidity/project.json @@ -24,7 +24,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remix-solidity/**/*.ts"] + "lintFilePatterns": ["libs/remix-solidity/**/*.ts"], + "eslintConfig": "libs/remix-solidity/.eslintrc" } } }, diff --git a/libs/remix-tests/project.json b/libs/remix-tests/project.json index e2e4741e35..dd29dafdde 100644 --- a/libs/remix-tests/project.json +++ b/libs/remix-tests/project.json @@ -41,7 +41,8 @@ "options": { "lintFilePatterns": [ "libs/remix-tests/**/*.ts" - ] + ], + "eslintConfig": "libs/remix-tests/.eslintrc" } } }, diff --git a/libs/remix-url-resolver/project.json b/libs/remix-url-resolver/project.json index 5bd43c8a61..cfe894b3ca 100644 --- a/libs/remix-url-resolver/project.json +++ b/libs/remix-url-resolver/project.json @@ -23,7 +23,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remix-url-resolver/**/*.ts"] + "lintFilePatterns": ["libs/remix-url-resolver/**/*.ts"], + "eslintConfig": "libs/remix-url-resolver/.eslintrc" } } }, diff --git a/libs/remix-ws-templates/project.json b/libs/remix-ws-templates/project.json index 7ebf0408d5..5835378d9c 100644 --- a/libs/remix-ws-templates/project.json +++ b/libs/remix-ws-templates/project.json @@ -40,7 +40,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remix-ws-templates/**/*.ts"] + "lintFilePatterns": ["libs/remix-ws-templates/**/*.ts"], + "eslintConfig": "libs/remix-ws-templates/.eslintrc" } } }, diff --git a/libs/remixd/project.json b/libs/remixd/project.json index b4da03d85f..ac783b5aff 100644 --- a/libs/remixd/project.json +++ b/libs/remixd/project.json @@ -24,7 +24,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/remixd/**/*.ts"] + "lintFilePatterns": ["libs/remixd/**/*.ts"], + "eslintConfig": "libs/remixd/.eslintrc" } } }, From 8a7298b014052d785dcc0e02dc6ea5fa3dfdabd4 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 10:58:01 +0200 Subject: [PATCH 02/31] added raegets for lint to plugins cleanup --- apps/circuit-compiler/project.json | 8 ++++++++ apps/debugger/.eslintrc | 3 +++ apps/debugger/project.json | 8 ++++++++ apps/doc-gen/.eslintrc | 3 +++ apps/doc-gen/project.json | 8 ++++++++ apps/doc-viewer/.eslintrc | 3 +++ apps/doc-viewer/project.json | 8 ++++++++ apps/etherscan/.eslintrc | 3 +++ apps/etherscan/project.json | 8 ++++++++ apps/learneth/.eslintrc | 3 +++ apps/learneth/project.json | 8 ++++++++ apps/solhint/.eslintrc | 3 +++ apps/solhint/project.json | 8 ++++++++ apps/solidity-compiler/.eslintrc | 3 +++ apps/solidity-compiler/project.json | 8 ++++++++ apps/vyper/project.json | 8 ++++++++ apps/walletconnect/.eslintrc | 3 +++ apps/walletconnect/project.json | 8 ++++++++ 18 files changed, 104 insertions(+) create mode 100644 apps/debugger/.eslintrc create mode 100644 apps/doc-gen/.eslintrc create mode 100644 apps/doc-viewer/.eslintrc create mode 100644 apps/etherscan/.eslintrc create mode 100644 apps/learneth/.eslintrc create mode 100644 apps/solhint/.eslintrc create mode 100644 apps/solidity-compiler/.eslintrc create mode 100644 apps/walletconnect/.eslintrc diff --git a/apps/circuit-compiler/project.json b/apps/circuit-compiler/project.json index a8efde346c..1e3753d307 100644 --- a/apps/circuit-compiler/project.json +++ b/apps/circuit-compiler/project.json @@ -35,6 +35,14 @@ } } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/circuit-compiler/**/*.ts"], + "eslintConfig": "apps/circuit-compiler/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", diff --git a/apps/debugger/.eslintrc b/apps/debugger/.eslintrc new file mode 100644 index 0000000000..2d85f9fa66 --- /dev/null +++ b/apps/debugger/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../.eslintrc.json", +} \ No newline at end of file diff --git a/apps/debugger/project.json b/apps/debugger/project.json index 3426f35d13..aaaf9b10bd 100644 --- a/apps/debugger/project.json +++ b/apps/debugger/project.json @@ -40,6 +40,14 @@ } } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/debugger/**/*.ts"], + "eslintConfig": "apps/debugger/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", diff --git a/apps/doc-gen/.eslintrc b/apps/doc-gen/.eslintrc new file mode 100644 index 0000000000..2d85f9fa66 --- /dev/null +++ b/apps/doc-gen/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../.eslintrc.json", +} \ No newline at end of file diff --git a/apps/doc-gen/project.json b/apps/doc-gen/project.json index 4b997606a5..d074969ae4 100644 --- a/apps/doc-gen/project.json +++ b/apps/doc-gen/project.json @@ -38,6 +38,14 @@ } } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/doc-gen/**/*.ts"], + "eslintConfig": "apps/doc-gen/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", diff --git a/apps/doc-viewer/.eslintrc b/apps/doc-viewer/.eslintrc new file mode 100644 index 0000000000..2d85f9fa66 --- /dev/null +++ b/apps/doc-viewer/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../.eslintrc.json", +} \ No newline at end of file diff --git a/apps/doc-viewer/project.json b/apps/doc-viewer/project.json index 2e5455cc30..9289f16886 100644 --- a/apps/doc-viewer/project.json +++ b/apps/doc-viewer/project.json @@ -38,6 +38,14 @@ } } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/doc-viewer/**/*.ts"], + "eslintConfig": "apps/doc-viewer/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", diff --git a/apps/etherscan/.eslintrc b/apps/etherscan/.eslintrc new file mode 100644 index 0000000000..2d85f9fa66 --- /dev/null +++ b/apps/etherscan/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../.eslintrc.json", +} \ No newline at end of file diff --git a/apps/etherscan/project.json b/apps/etherscan/project.json index fe53c7f39e..6803ffe20b 100644 --- a/apps/etherscan/project.json +++ b/apps/etherscan/project.json @@ -38,6 +38,14 @@ } } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/etherscan/**/*.ts"], + "eslintConfig": "apps/etherscan/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", diff --git a/apps/learneth/.eslintrc b/apps/learneth/.eslintrc new file mode 100644 index 0000000000..2d85f9fa66 --- /dev/null +++ b/apps/learneth/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../.eslintrc.json", +} \ No newline at end of file diff --git a/apps/learneth/project.json b/apps/learneth/project.json index a4db7488a7..cafdc12eb9 100644 --- a/apps/learneth/project.json +++ b/apps/learneth/project.json @@ -35,6 +35,14 @@ } } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/learneth/**/*.ts"], + "eslintConfig": "apps/learneth/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", diff --git a/apps/solhint/.eslintrc b/apps/solhint/.eslintrc new file mode 100644 index 0000000000..2d85f9fa66 --- /dev/null +++ b/apps/solhint/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../.eslintrc.json", +} \ No newline at end of file diff --git a/apps/solhint/project.json b/apps/solhint/project.json index dbd4bdce84..a76ec45b49 100644 --- a/apps/solhint/project.json +++ b/apps/solhint/project.json @@ -47,6 +47,14 @@ "parallel": false } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/solhint/**/*.ts"], + "eslintConfig": "libs/solhint/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", diff --git a/apps/solidity-compiler/.eslintrc b/apps/solidity-compiler/.eslintrc new file mode 100644 index 0000000000..2d85f9fa66 --- /dev/null +++ b/apps/solidity-compiler/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../.eslintrc.json", +} \ No newline at end of file diff --git a/apps/solidity-compiler/project.json b/apps/solidity-compiler/project.json index 395ec9e94e..b714633a8e 100644 --- a/apps/solidity-compiler/project.json +++ b/apps/solidity-compiler/project.json @@ -41,6 +41,14 @@ } } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/solidity-compiler/**/*.ts"], + "eslintConfig": "libs/solidity-compiler/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", diff --git a/apps/vyper/project.json b/apps/vyper/project.json index 543c0873fd..28c8835367 100644 --- a/apps/vyper/project.json +++ b/apps/vyper/project.json @@ -38,6 +38,14 @@ } } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/vyper/**/*.ts"], + "eslintConfig": "libs/vyper/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", diff --git a/apps/walletconnect/.eslintrc b/apps/walletconnect/.eslintrc new file mode 100644 index 0000000000..2d85f9fa66 --- /dev/null +++ b/apps/walletconnect/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../.eslintrc.json", +} \ No newline at end of file diff --git a/apps/walletconnect/project.json b/apps/walletconnect/project.json index b8baae9b60..589011838a 100644 --- a/apps/walletconnect/project.json +++ b/apps/walletconnect/project.json @@ -35,6 +35,14 @@ } } }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/walletconnect/**/*.ts"], + "eslintConfig": "libs/walletconnect/.eslintrc" + } + }, "serve": { "executor": "@nrwl/webpack:dev-server", "defaultConfiguration": "development", From 382acb5c6057b3c02bf647e210fd060dbd4a2bfd Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 11:52:16 +0200 Subject: [PATCH 03/31] fixing url --- apps/solidity-compiler/.eslintrc | 2 +- apps/solidity-compiler/project.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/solidity-compiler/.eslintrc b/apps/solidity-compiler/.eslintrc index 2d85f9fa66..f7a0ddac8e 100644 --- a/apps/solidity-compiler/.eslintrc +++ b/apps/solidity-compiler/.eslintrc @@ -1,3 +1,3 @@ { - "extends": "../../.eslintrc.json", + "extends": "../../.eslintrc.json" } \ No newline at end of file diff --git a/apps/solidity-compiler/project.json b/apps/solidity-compiler/project.json index b714633a8e..876c5f83bf 100644 --- a/apps/solidity-compiler/project.json +++ b/apps/solidity-compiler/project.json @@ -45,8 +45,8 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/solidity-compiler/**/*.ts"], - "eslintConfig": "libs/solidity-compiler/.eslintrc" + "lintFilePatterns": ["apps/solidity-compiler/**/*.ts"], + "eslintConfig": "apps/solidity-compiler/.eslintrc" } }, "serve": { From 16200e29941538805524e3574500d534a2dbb766 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 12:18:07 +0200 Subject: [PATCH 04/31] adding apps/circuit-compiler/.eslintrc --- apps/circuit-compiler/.eslintrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 apps/circuit-compiler/.eslintrc diff --git a/apps/circuit-compiler/.eslintrc b/apps/circuit-compiler/.eslintrc new file mode 100644 index 0000000000..2d85f9fa66 --- /dev/null +++ b/apps/circuit-compiler/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../.eslintrc.json", +} \ No newline at end of file From ca4ac3abf39fe8f791c3d29d78a29b099f7e2576 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 12:24:53 +0200 Subject: [PATCH 05/31] new rules --- .eslintrc.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 7a9a8f1431..d6efa4afee 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -54,7 +54,13 @@ "react-hooks/exhaustive-deps": "off", "array-callback-return": "off", "prefer-spread": "off", - "indent": ["error", 2] + "indent": ["error", 2], + "keyword-spacing": ["error", { "after": true, "before": true }], + "array-bracket-spacing": ["error", "never"], + "object-curly-spacing": ["error", "always", { "arraysInObjects": false }], + "no-trailing-spaces": "error", + "no-multi-spaces": "error", + "no-multiple-empty-lines": ["error" , { "max": 1}] } }, { From 4fe4b7f97e7d517a6d951737407bd6bb3493b7c5 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 12:28:06 +0200 Subject: [PATCH 06/31] fixing remix-url-resolver lint errors --- libs/remix-url-resolver/src/resolve.ts | 13 ++++++------- libs/remix-url-resolver/tests/test.ts | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libs/remix-url-resolver/src/resolve.ts b/libs/remix-url-resolver/src/resolve.ts index f9b77e2b3e..b1225ccdb5 100644 --- a/libs/remix-url-resolver/src/resolve.ts +++ b/libs/remix-url-resolver/src/resolve.ts @@ -64,7 +64,7 @@ export class RemixURLResolver { // eslint-disable-next-line no-useless-catch try { const req = `https://raw.githubusercontent.com/${root}/${reference}/${filePath}` - const response: AxiosResponse = await axios.get(req, { transformResponse: [] }) + const response: AxiosResponse = await axios.get(req, { transformResponse: []}) return { content: response.data, cleanUrl: root + '/' + filePath } } catch (e) { throw e @@ -79,7 +79,7 @@ export class RemixURLResolver { async handleHttp(url: string, cleanUrl: string): Promise { // eslint-disable-next-line no-useless-catch try { - const response: AxiosResponse = await axios.get(url, { transformResponse: [] }) + const response: AxiosResponse = await axios.get(url, { transformResponse: []}) return { content: response.data, cleanUrl } } catch (e) { throw e @@ -94,7 +94,7 @@ export class RemixURLResolver { async handleHttps(url: string, cleanUrl: string): Promise { // eslint-disable-next-line no-useless-catch try { - const response: AxiosResponse = await axios.get(url, { transformResponse: [] }) + const response: AxiosResponse = await axios.get(url, { transformResponse: []}) return { content: response.data, cleanUrl } } catch (e) { throw e @@ -106,7 +106,7 @@ export class RemixURLResolver { try { const bzz = new Bzz({ url: this.protocol + '//swarm-gateways.net' }) const url = bzz.getDownloadURL(cleanUrl, { mode: 'raw' }) - const response: AxiosResponse = await axios.get(url, { transformResponse: [] }) + const response: AxiosResponse = await axios.get(url, { transformResponse: []}) return { content: response.data, cleanUrl } } catch (e) { throw e @@ -125,7 +125,7 @@ export class RemixURLResolver { const req = 'https://jqgt.remixproject.org/' + url // If you don't find greeter.sol on ipfs gateway use local // const req = 'http://localhost:8080/' + url - const response: AxiosResponse = await axios.get(req, { transformResponse: [] }) + const response: AxiosResponse = await axios.get(req, { transformResponse: []}) return { content: response.data, cleanUrl: url.replace('ipfs/', '') } } catch (e) { throw e @@ -190,7 +190,7 @@ export class RemixURLResolver { for (let i = 0; i < npm_urls.length; i++) { try { const req = npm_urls[i] + url - const response: AxiosResponse = await axios.get(req, { transformResponse: [] }) + const response: AxiosResponse = await axios.get(req, { transformResponse: []}) content = response.data break } catch (e) { @@ -201,7 +201,6 @@ export class RemixURLResolver { if (!content) throw new Error('Unable to load ' + url) return { content, cleanUrl: url } } - getHandlers (): Handler[] { return [ diff --git a/libs/remix-url-resolver/tests/test.ts b/libs/remix-url-resolver/tests/test.ts index 952967d9c3..1a8eebe0ba 100644 --- a/libs/remix-url-resolver/tests/test.ts +++ b/libs/remix-url-resolver/tests/test.ts @@ -109,7 +109,7 @@ describe('testRunner', () => { it('should return contract content of given github path', () => { const expt: object = { cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol', - content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}), + content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8' }), type: 'github' } assert.deepEqual(results, expt) @@ -139,7 +139,7 @@ describe('testRunner', () => { it('should return contract content of given github path', () => { const expt: object = { cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol', - content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}) + '\n', + content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8' }) + '\n', type: 'github' } assert.deepEqual(results, expt) @@ -169,7 +169,7 @@ describe('testRunner', () => { it('should return contract content of given github path', () => { const expt: object = { cleanUrl: 'ethereum/remix-project/libs/remix-url-resolver/tests/example_1/greeter.sol', - content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}), + content: fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8' }), type: 'github' } assert.deepEqual(results, expt) @@ -257,7 +257,7 @@ describe('testRunner', () => { assert.equal(Object.keys(results).length, 3) }) it('should return contract content from IPFS url', () => { - const content = fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}) + const content = fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8' }) const expt: object = { content: content, cleanUrl: 'QmcuCKyokk9Z6f65ADAADNiS2R2xCjfRkv7mYBSWDwtA7M', From 811d90ae3660ea8cbbf940df32536b8e910a4921 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 13:50:10 +0200 Subject: [PATCH 07/31] linting fixes for remix-ws-templates --- .../basic-contract-deploy.ts | 6 ++-- .../contract-deployer/index.ts | 6 ++-- .../create2-solidity-factory/index.ts | 2 +- .../src/script-templates/etherscan/index.ts | 6 ++-- .../etherscan/receiptGuidScript.ts | 2 +- .../etherscan/verifyScript.ts | 2 +- .../src/script-templates/sindri/index.ts | 4 +-- .../script-templates/sindri/run_compile.ts | 2 +- .../src/script-templates/sindri/run_prove.ts | 2 +- .../src/script-templates/sindri/utils.ts | 4 +-- .../gnosisSafeMultisig/scripts/ethers-lib.ts | 6 ++-- .../gnosisSafeMultisig/scripts/web3-lib.ts | 4 +-- .../scripts/groth16/groth16_trusted_setup.ts | 6 ++-- .../scripts/groth16/groth16_zkproof.ts | 21 ++++++------- .../scripts/plonk/plonk_zkproof.ts | 12 +++---- .../src/templates/ozerc1155/index.ts | 2 +- .../templates/ozerc1155/scripts/ethers-lib.ts | 6 ++-- .../templates/ozerc1155/scripts/web3-lib.ts | 4 +-- .../src/templates/ozerc20/index.ts | 2 +- .../templates/ozerc20/scripts/ethers-lib.ts | 6 ++-- .../src/templates/ozerc20/scripts/web3-lib.ts | 4 +-- .../templates/ozerc721/scripts/ethers-lib.ts | 6 ++-- .../templates/ozerc721/scripts/web3-lib.ts | 4 +-- .../playground/scripts/ethers-lib.ts | 6 ++-- .../templates/playground/scripts/web3-lib.ts | 4 +-- .../remixDefault/scripts/ethers-lib.ts | 6 ++-- .../remixDefault/scripts/web3-lib.ts | 4 +-- .../scripts/groth16/groth16_trusted_setup.ts | 6 ++-- .../rln/scripts/groth16/groth16_zkproof.ts | 28 ++++++++--------- .../rln/scripts/plonk/plonk_zkproof.ts | 28 ++++++++--------- .../scripts/groth16/groth16_trusted_setup.ts | 6 ++-- .../scripts/groth16/groth16_zkproof.ts | 28 ++++++++--------- .../scripts/plonk/plonk_trusted_setup.ts | 6 ++-- .../semaphore/scripts/plonk/plonk_zkproof.ts | 30 +++++++++--------- .../templates/semaphore/scripts/run_setup.ts | 10 +++--- .../semaphore/scripts/run_verification.ts | 31 +++++++++---------- .../zeroxErc20/scripts/ethers-lib.ts | 6 ++-- .../templates/zeroxErc20/scripts/web3-lib.ts | 4 +-- 38 files changed, 159 insertions(+), 163 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/contract-deployer/basic-contract-deploy.ts b/libs/remix-ws-templates/src/script-templates/contract-deployer/basic-contract-deploy.ts index 2753f9bcd0..8e4adf95a6 100644 --- a/libs/remix-ws-templates/src/script-templates/contract-deployer/basic-contract-deploy.ts +++ b/libs/remix-ws-templates/src/script-templates/contract-deployer/basic-contract-deploy.ts @@ -7,7 +7,7 @@ import { ethers } from 'ethers' * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -16,12 +16,12 @@ export const deploy = async (contractName: string, args: Array, accountInde const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - const contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/script-templates/contract-deployer/index.ts b/libs/remix-ws-templates/src/script-templates/contract-deployer/index.ts index 93682c8002..5ef8cb395b 100644 --- a/libs/remix-ws-templates/src/script-templates/contract-deployer/index.ts +++ b/libs/remix-ws-templates/src/script-templates/contract-deployer/index.ts @@ -1,12 +1,12 @@ export const contractDeployerScripts = async (plugin) => { - await plugin.call('fileManager', 'writeFile', + await plugin.call('fileManager', 'writeFile', 'scripts/contract-deployer/create2-factory-deploy.ts' , // @ts-ignore (await import('!!raw-loader!./create2-factory-deploy.ts')).default) await plugin.call('fileManager', 'open', 'scripts/contract-deployer/create2-factory-deploy.ts') - - await plugin.call('fileManager', 'writeFile', + + await plugin.call('fileManager', 'writeFile', 'scripts/contract-deployer/basic-contract-deploy.ts' , // @ts-ignore (await import('!!raw-loader!./basic-contract-deploy.ts')).default) diff --git a/libs/remix-ws-templates/src/script-templates/create2-solidity-factory/index.ts b/libs/remix-ws-templates/src/script-templates/create2-solidity-factory/index.ts index 4d7bedb2d8..80283660a2 100644 --- a/libs/remix-ws-templates/src/script-templates/create2-solidity-factory/index.ts +++ b/libs/remix-ws-templates/src/script-templates/create2-solidity-factory/index.ts @@ -1,5 +1,5 @@ export const contractCreate2Factory = async (plugin) => { - await plugin.call('fileManager', 'writeFile', + await plugin.call('fileManager', 'writeFile', 'contracts/libs/create2-factory.sol' , // @ts-ignore (await import('!!raw-loader!./create2-factory.sol')).default) diff --git a/libs/remix-ws-templates/src/script-templates/etherscan/index.ts b/libs/remix-ws-templates/src/script-templates/etherscan/index.ts index 3abbe27dd6..747e4fd8b8 100644 --- a/libs/remix-ws-templates/src/script-templates/etherscan/index.ts +++ b/libs/remix-ws-templates/src/script-templates/etherscan/index.ts @@ -1,12 +1,12 @@ export const etherscanScripts = async (plugin) => { - await plugin.call('fileManager', 'writeFile', + await plugin.call('fileManager', 'writeFile', 'scripts/etherscan/verifyScript.ts' , // @ts-ignore (await import('!!raw-loader!./verifyScript.ts')).default) - + await plugin.call('fileManager', 'open', 'scripts/etherscan/verifyScript.ts') - await plugin.call('fileManager', 'writeFile', + await plugin.call('fileManager', 'writeFile', 'scripts/etherscan/receiptGuidScript.ts' , // @ts-ignore (await import('!!raw-loader!./receiptGuidScript.ts')).default) diff --git a/libs/remix-ws-templates/src/script-templates/etherscan/receiptGuidScript.ts b/libs/remix-ws-templates/src/script-templates/etherscan/receiptGuidScript.ts index cc96dc14e6..b5bdeb3139 100644 --- a/libs/remix-ws-templates/src/script-templates/etherscan/receiptGuidScript.ts +++ b/libs/remix-ws-templates/src/script-templates/etherscan/receiptGuidScript.ts @@ -5,5 +5,5 @@ * @returns {{ status, message, succeed }} receiptStatus */ export const receiptStatus = async (apikey: string, guid: string, isProxyContract?: boolean) => { - return await remix.call('etherscan' as any, 'receiptStatus', guid, apikey, isProxyContract) + return await remix.call('etherscan' as any, 'receiptStatus', guid, apikey, isProxyContract) } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/script-templates/etherscan/verifyScript.ts b/libs/remix-ws-templates/src/script-templates/etherscan/verifyScript.ts index 2126bca90b..ba9c552a70 100644 --- a/libs/remix-ws-templates/src/script-templates/etherscan/verifyScript.ts +++ b/libs/remix-ws-templates/src/script-templates/etherscan/verifyScript.ts @@ -13,5 +13,5 @@ export const verify = async (apikey: string, contractAddress: string, contractAr const compilationResultParam = await remix.call('compilerArtefacts' as any, 'getCompilerAbstract', contractFile) console.log('verifying.. ' + contractName) // update apiKey and chainRef to verify contract on multiple networks - return await remix.call('etherscan' as any, 'verify', apikey, contractAddress, contractArguments, contractName, compilationResultParam, chainRef, isProxyContract, expectedImplAddress) + return await remix.call('etherscan' as any, 'verify', apikey, contractAddress, contractArguments, contractName, compilationResultParam, chainRef, isProxyContract, expectedImplAddress) } diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index fdc58bfad1..0abcebdb2e 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -71,12 +71,12 @@ export const sindriScripts = async (plugin: any) => { if (a.isTemplateEntrypoint !== b.isTemplateEntrypoint) return +b.isTemplateEntrypoint - +a.isTemplateEntrypoint return a.path.localeCompare(b.path) }) - .map(({path}) => path)[0] || './circuit.circom' + .map(({ path }) => path)[0] || './circuit.circom' sindriManifest.circuitPath = circomCircuitPath } // Derive the circuit name from the workspace name. - const {name: workspaceName} = await plugin.call('filePanel', 'getCurrentWorkspace') + const { name: workspaceName } = await plugin.call('filePanel', 'getCurrentWorkspace') sindriManifest.name = workspaceName .replace(/\s*-+\s*\d*$/, '') diff --git a/libs/remix-ws-templates/src/script-templates/sindri/run_compile.ts b/libs/remix-ws-templates/src/script-templates/sindri/run_compile.ts index 40a2bb42ad..5d9acda605 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/run_compile.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/run_compile.ts @@ -1,4 +1,4 @@ -import {compile} from './utils' +import { compile } from './utils' const main = async () => { const circuit = await compile() diff --git a/libs/remix-ws-templates/src/script-templates/sindri/run_prove.ts b/libs/remix-ws-templates/src/script-templates/sindri/run_prove.ts index 98e2ea43d7..cd81dbde15 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/run_prove.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/run_prove.ts @@ -1,4 +1,4 @@ -import {prove} from './utils' +import { prove } from './utils' // You must modify the input signals to include the data you're trying to generate a proof for. const signals: {[name: string]: number | string} = {} diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 8905d037da..006cd9fa6c 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -1,5 +1,5 @@ import sindriClient from 'sindri' -import type {CircuitInfoResponse, ProofInfoResponse} from 'sindri' +import type { CircuitInfoResponse, ProofInfoResponse } from 'sindri' sindriClient.logLevel = 'info' @@ -9,7 +9,7 @@ const authorize = async () => { if (!apiKey) { throw new Error('Missing API key.') } - sindriClient.authorize({apiKey}) + sindriClient.authorize({ apiKey }) } catch { const message = 'No Sindri API key found. Please click the gear in the lower left corner to open the settings page, and add your API key under "Sindri Credentials".' await remix.call('notification', 'toast', message) diff --git a/libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/ethers-lib.ts index 2753f9bcd0..8e4adf95a6 100644 --- a/libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/ethers-lib.ts @@ -7,7 +7,7 @@ import { ethers } from 'ethers' * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -16,12 +16,12 @@ export const deploy = async (contractName: string, args: Array, accountInde const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - const contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/web3-lib.ts index c57e501039..cbd4f48489 100644 --- a/libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/web3-lib.ts @@ -21,7 +21,7 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - const contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, @@ -32,5 +32,5 @@ export const deploy = async (contractName: string, args: Array, from?: stri from: from || accounts[0], gas: gas || 1500000 }) - return newContractInstance.options + return newContractInstance.options } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/hashchecker/scripts/groth16/groth16_trusted_setup.ts b/libs/remix-ws-templates/src/templates/hashchecker/scripts/groth16/groth16_trusted_setup.ts index 278146b08a..9692a62954 100644 --- a/libs/remix-ws-templates/src/templates/hashchecker/scripts/groth16/groth16_trusted_setup.ts +++ b/libs/remix-ws-templates/src/templates/hashchecker/scripts/groth16/groth16_trusted_setup.ts @@ -40,12 +40,12 @@ const logger = { console.log('exportVerificationKey') const vKey = await snarkjs.zKey.exportVerificationKey(zkey_final) await remix.call('fileManager', 'writeFile', './zk/keys/groth16/verification_key.json', JSON.stringify(vKey, null, 2)) - + console.log('save zkey_final') await remix.call('fileManager', 'writeFile', './zk/keys/groth16/zkey_final.txt', JSON.stringify(Array.from(((zkey_final as any).data)))) - + console.log('setup done.') - + } catch (e) { console.error(e.message) } diff --git a/libs/remix-ws-templates/src/templates/hashchecker/scripts/groth16/groth16_zkproof.ts b/libs/remix-ws-templates/src/templates/hashchecker/scripts/groth16/groth16_zkproof.ts index daea2ed230..146bdab52b 100644 --- a/libs/remix-ws-templates/src/templates/hashchecker/scripts/groth16/groth16_zkproof.ts +++ b/libs/remix-ws-templates/src/templates/hashchecker/scripts/groth16/groth16_zkproof.ts @@ -20,21 +20,21 @@ const logger = { // @ts-ignore const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/calculate_hash.wasm', { encoding: null }); // @ts-ignore - const wasm = new Uint8Array(wasmBuffer); - + const wasm = new Uint8Array(wasmBuffer); + const zkey_final = { type: "mem", data: new Uint8Array(JSON.parse(await remix.call('fileManager', 'readFile', './zk/keys/groth16/zkey_final.txt'))) } - const wtns = { type: "mem" }; + const wtns = { type: "mem" }; const vKey = JSON.parse(await remix.call('fileManager', 'readFile', './zk/keys/groth16/verification_key.json')) - + const value1 = '1234' const value2 = '2' const value3 = '3' const value4 = '4' - + const wrongValue = '5' // put this in the poseidon hash calculation to simulate a non matching hash. const signals = { @@ -44,25 +44,24 @@ const logger = { value4, hash: poseidon([value1, value2, value3, value4]) } - + console.log('calculate') await snarkjs.wtns.calculate(signals, wasm, wtns); - + console.log('check') await snarkjs.wtns.check(r1cs, wtns, logger); - console.log('prove') const { proof, publicSignals } = await snarkjs.groth16.prove(zkey_final, wtns); - + const verified = await snarkjs.groth16.verify(vKey, publicSignals, proof, logger); console.log('zk proof validity', verified); - + const templates = { groth16: await remix.call('fileManager', 'readFile', 'templates/groth16_verifier.sol.ejs') } const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates) - + await remix.call('fileManager', 'writeFile', './zk/build/groth16/zk_verifier.sol', solidityContract) await remix.call('fileManager', 'writeFile', 'zk/build/groth16/input.json', JSON.stringify({ _pA: [proof.pi_a[0], proof.pi_a[1]], diff --git a/libs/remix-ws-templates/src/templates/hashchecker/scripts/plonk/plonk_zkproof.ts b/libs/remix-ws-templates/src/templates/hashchecker/scripts/plonk/plonk_zkproof.ts index 31b2b8a1f9..544cd10b6d 100644 --- a/libs/remix-ws-templates/src/templates/hashchecker/scripts/plonk/plonk_zkproof.ts +++ b/libs/remix-ws-templates/src/templates/hashchecker/scripts/plonk/plonk_zkproof.ts @@ -28,7 +28,7 @@ const logger = { const value2 = '2' const value3 = '3' const value4 = '4' - + const wrongValue = '5' // put this in the poseidon hash calculation to simulate a non matching hash. const signals = { @@ -41,11 +41,11 @@ const logger = { console.log('calculate') await snarkjs.wtns.calculate(signals, wasm, wtns, logger); - + const { proof, publicSignals } = await snarkjs.plonk.prove(zkey_final, wtns); const vKey = JSON.parse(await remix.call('fileManager', 'readFile', './zk/keys/plonk/verification_key.json')) - + const verified = await snarkjs.plonk.verify(vKey, publicSignals, proof); console.log('zk proof validity', verified); @@ -53,7 +53,7 @@ const logger = { plonk: await remix.call('fileManager', 'readFile', 'templates/plonk_verifier.sol.ejs') } const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates) - + await remix.call('fileManager', 'writeFile', 'zk/build/plonk/zk_verifier.sol', solidityContract) await remix.call('fileManager', 'writeFile', 'zk/build/plonk/input.json', JSON.stringify({ _proof: [ @@ -84,9 +84,9 @@ const logger = { ], _pubSignals: publicSignals }, null, 2)) - + console.log('proof done.') - + } catch (e) { console.error(e.message) } diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts index f200464c07..40811b978f 100644 --- a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts @@ -29,6 +29,6 @@ export default async (opts) => { // @ts-ignore else filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default } - + return filesObj } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/ethers-lib.ts index 2753f9bcd0..8e4adf95a6 100644 --- a/libs/remix-ws-templates/src/templates/ozerc1155/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/ethers-lib.ts @@ -7,7 +7,7 @@ import { ethers } from 'ethers' * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -16,12 +16,12 @@ export const deploy = async (contractName: string, args: Array, accountInde const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - const contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/web3-lib.ts index 921774572a..32369998ad 100644 --- a/libs/remix-ws-templates/src/templates/ozerc1155/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/web3-lib.ts @@ -21,7 +21,7 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - const contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, @@ -32,5 +32,5 @@ export const deploy = async (contractName: string, args: Array, from?: stri from: from || accounts[0], gas: gas || 3600000 }) - return newContractInstance.options + return newContractInstance.options } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts index 2a8b0c8f3c..09b55ae00b 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -23,7 +23,7 @@ export default async (opts) => { // If no options is selected, opts.upgradeable will be undefined // We do not show test file for upgradeable contract - + if (!opts || opts.upgradeable === undefined || !opts.upgradeable) { // @ts-ignore if (erc20.defaults.mintable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_mintable_test.sol')).default diff --git a/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts index 2753f9bcd0..8e4adf95a6 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts @@ -7,7 +7,7 @@ import { ethers } from 'ethers' * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -16,12 +16,12 @@ export const deploy = async (contractName: string, args: Array, accountInde const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - const contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts index c57e501039..cbd4f48489 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts @@ -21,7 +21,7 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - const contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, @@ -32,5 +32,5 @@ export const deploy = async (contractName: string, args: Array, from?: stri from: from || accounts[0], gas: gas || 1500000 }) - return newContractInstance.options + return newContractInstance.options } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts index 2753f9bcd0..8e4adf95a6 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts @@ -7,7 +7,7 @@ import { ethers } from 'ethers' * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -16,12 +16,12 @@ export const deploy = async (contractName: string, args: Array, accountInde const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - const contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts index c57e501039..cbd4f48489 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts @@ -21,7 +21,7 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - const contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, @@ -32,5 +32,5 @@ export const deploy = async (contractName: string, args: Array, from?: stri from: from || accounts[0], gas: gas || 1500000 }) - return newContractInstance.options + return newContractInstance.options } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/playground/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/playground/scripts/ethers-lib.ts index 2753f9bcd0..8e4adf95a6 100644 --- a/libs/remix-ws-templates/src/templates/playground/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/playground/scripts/ethers-lib.ts @@ -7,7 +7,7 @@ import { ethers } from 'ethers' * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -16,12 +16,12 @@ export const deploy = async (contractName: string, args: Array, accountInde const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - const contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/playground/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/playground/scripts/web3-lib.ts index c57e501039..cbd4f48489 100644 --- a/libs/remix-ws-templates/src/templates/playground/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/playground/scripts/web3-lib.ts @@ -21,7 +21,7 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - const contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, @@ -32,5 +32,5 @@ export const deploy = async (contractName: string, args: Array, from?: stri from: from || accounts[0], gas: gas || 1500000 }) - return newContractInstance.options + return newContractInstance.options } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts index 2753f9bcd0..8e4adf95a6 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts @@ -7,7 +7,7 @@ import { ethers } from 'ethers' * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -16,12 +16,12 @@ export const deploy = async (contractName: string, args: Array, accountInde const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - const contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts index c57e501039..cbd4f48489 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts @@ -21,7 +21,7 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - const contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, @@ -32,5 +32,5 @@ export const deploy = async (contractName: string, args: Array, from?: stri from: from || accounts[0], gas: gas || 1500000 }) - return newContractInstance.options + return newContractInstance.options } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/rln/scripts/groth16/groth16_trusted_setup.ts b/libs/remix-ws-templates/src/templates/rln/scripts/groth16/groth16_trusted_setup.ts index 19b9736314..c4a9513c92 100644 --- a/libs/remix-ws-templates/src/templates/rln/scripts/groth16/groth16_trusted_setup.ts +++ b/libs/remix-ws-templates/src/templates/rln/scripts/groth16/groth16_trusted_setup.ts @@ -40,12 +40,12 @@ const logger = { console.log('exportVerificationKey') const vKey = await snarkjs.zKey.exportVerificationKey(zkey_final) await remix.call('fileManager', 'writeFile', './zk/keys/groth16/verification_key.json', JSON.stringify(vKey, null, 2)) - + console.log('save zkey_final') await remix.call('fileManager', 'writeFile', './zk/keys/groth16/zkey_final.txt', (zkey_final as any).data, { encoding: null }) - + console.log('setup done.') - + } catch (e) { console.error(e.message) } diff --git a/libs/remix-ws-templates/src/templates/rln/scripts/groth16/groth16_zkproof.ts b/libs/remix-ws-templates/src/templates/rln/scripts/groth16/groth16_zkproof.ts index f8cef8c28e..d982568928 100644 --- a/libs/remix-ws-templates/src/templates/rln/scripts/groth16/groth16_zkproof.ts +++ b/libs/remix-ws-templates/src/templates/rln/scripts/groth16/groth16_zkproof.ts @@ -45,13 +45,13 @@ function hashNullifier(message: any): bigint { async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { console.log('calculate') await snarkjs.wtns.calculate(signals, wasm, wtns); - + console.log('check') - await snarkjs.wtns.check(r1cs, wtns, logger); + await snarkjs.wtns.check(r1cs, wtns, logger); console.log('prove') const { proof, publicSignals } = await snarkjs.groth16.prove(zkey_final, wtns); - + const verified = await snarkjs.groth16.verify(vKey, publicSignals, proof, logger); console.log('zk proof validity', verified); @@ -81,33 +81,33 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { // @ts-ignore const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/rln.wasm', { encoding: null }); // @ts-ignore - const wasm = new Uint8Array(wasmBuffer); - + const wasm = new Uint8Array(wasmBuffer); + const zkey_final = { type: "mem", data: new Uint8Array(await remix.call('fileManager', 'readFile', './zk/keys/groth16/zkey_final.txt', { encoding: null })) } - const wtns = { type: "mem" }; + const wtns = { type: "mem" }; const vKey = JSON.parse(await remix.call('fileManager', 'readFile', './zk/keys/groth16/verification_key.json')) - + // build list of identity commitments const secrets = [] const identityCommitments = [] const rateCommitments = [] const userMessageLimit = 0x2 - for (let k = 0; k < 2; k++) { + for (let k = 0; k < 2; k++) { const identitySecret = BigInt(ethers.utils.hexlify(ethers.utils.randomBytes(32))) secrets.push(identitySecret) - + const identityCommitment = poseidon([identitySecret]) const rateCommitment = poseidon([identityCommitment, userMessageLimit]) identityCommitments.push(identityCommitment) rateCommitments.push(rateCommitment) } - + let tree - + try { tree = new IncrementalMerkleTree(poseidon, 20, BigInt(0), 2, rateCommitments) // Binary tree. } catch (e) { @@ -130,7 +130,7 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { externalNullifier: 0xa // hash(epoch, appId) } const proof1 = await prove(signals1, wasm, wtns, r1cs, zkey_final, vKey) - + const signals2 = { identitySecret: secrets[0], userMessageLimit, @@ -146,12 +146,12 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { console.log(secret.toString(10)) console.log(Fq.normalize(secrets[0])) - + const templates = { groth16: await remix.call('fileManager', 'readFile', 'templates/groth16_verifier.sol.ejs') } const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates) - + await remix.call('fileManager', 'writeFile', './zk/build/groth16/zk_verifier.sol', solidityContract) } catch (e) { console.error(e.message) diff --git a/libs/remix-ws-templates/src/templates/rln/scripts/plonk/plonk_zkproof.ts b/libs/remix-ws-templates/src/templates/rln/scripts/plonk/plonk_zkproof.ts index 09b0a885f8..b05c84720b 100644 --- a/libs/remix-ws-templates/src/templates/rln/scripts/plonk/plonk_zkproof.ts +++ b/libs/remix-ws-templates/src/templates/rln/scripts/plonk/plonk_zkproof.ts @@ -45,13 +45,13 @@ function hashNullifier(message: any): bigint { async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { console.log('calculate') await snarkjs.wtns.calculate(signals, wasm, wtns); - + console.log('check') - await snarkjs.wtns.check(r1cs, wtns, logger); + await snarkjs.wtns.check(r1cs, wtns, logger); console.log('prove') const { proof, publicSignals } = await snarkjs.plonk.prove(zkey_final, wtns); - + const verified = await snarkjs.plonk.verify(vKey, publicSignals, proof, logger); console.log('zk proof validity', verified); @@ -84,7 +84,7 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { ethers.utils.hexZeroPad(ethers.BigNumber.from(proof.eval_zw).toHexString(), 32), ] }, null, 2)) - + console.log('proof done.') return { proof, @@ -104,8 +104,8 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { // @ts-ignore const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/rln.wasm', { encoding: null }); // @ts-ignore - const wasm = new Uint8Array(wasmBuffer); - + const wasm = new Uint8Array(wasmBuffer); + const zkey_final = { type: "mem", // @ts-ignore @@ -114,24 +114,24 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { const wtns = { type: "mem" }; const vKey = JSON.parse(await remix.call('fileManager', 'readFile', './zk/keys/plonk/verification_key.json')) - + // build list of identity commitments const secrets = [] const identityCommitments = [] const rateCommitments = [] const userMessageLimit = 0x2 - for (let k = 0; k < 2; k++) { + for (let k = 0; k < 2; k++) { const identitySecret = BigInt(ethers.utils.hexlify(ethers.utils.randomBytes(32))) secrets.push(identitySecret) - + const identityCommitment = poseidon([identitySecret]) const rateCommitment = poseidon([identityCommitment, userMessageLimit]) identityCommitments.push(identityCommitment) rateCommitments.push(rateCommitment) } - + let tree - + try { tree = new IncrementalMerkleTree(poseidon, 20, BigInt(0), 2, rateCommitments) // Binary tree. } catch (e) { @@ -154,7 +154,7 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { externalNullifier: 0xa // hash(epoch, appId) } const proof1 = await prove(signals1, wasm, wtns, r1cs, zkey_final, vKey) - + const signals2 = { identitySecret: secrets[0], userMessageLimit, @@ -170,12 +170,12 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) { console.log(secret.toString(10)) console.log(Fq.normalize(secrets[0])) - + const templates = { plonk: await remix.call('fileManager', 'readFile', 'templates/plonk_verifier.sol.ejs') } const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates) - + await remix.call('fileManager', 'writeFile', './zk/build/plonk/zk_verifier.sol', solidityContract) } catch (e) { console.error(e.message) diff --git a/libs/remix-ws-templates/src/templates/semaphore/scripts/groth16/groth16_trusted_setup.ts b/libs/remix-ws-templates/src/templates/semaphore/scripts/groth16/groth16_trusted_setup.ts index d3b205f858..a155ef2192 100644 --- a/libs/remix-ws-templates/src/templates/semaphore/scripts/groth16/groth16_trusted_setup.ts +++ b/libs/remix-ws-templates/src/templates/semaphore/scripts/groth16/groth16_trusted_setup.ts @@ -40,13 +40,13 @@ const logger = { console.log('exportVerificationKey') const vKey = await snarkjs.zKey.exportVerificationKey(zkey_final) await remix.call('fileManager', 'writeFile', './zk/keys/groth16/verification_key.json', JSON.stringify(vKey, null, 2)) - + console.log('save zkey_final') // @ts-ignore await remix.call('fileManager', 'writeFile', './zk/keys/groth16/zkey_final.txt', (zkey_final as any).data, { encoding: null }) - + console.log('setup done.') - + } catch (e) { console.error(e.message) } diff --git a/libs/remix-ws-templates/src/templates/semaphore/scripts/groth16/groth16_zkproof.ts b/libs/remix-ws-templates/src/templates/semaphore/scripts/groth16/groth16_zkproof.ts index d477342506..35c708efa7 100644 --- a/libs/remix-ws-templates/src/templates/semaphore/scripts/groth16/groth16_zkproof.ts +++ b/libs/remix-ws-templates/src/templates/semaphore/scripts/groth16/groth16_zkproof.ts @@ -33,33 +33,33 @@ function hash(message: any): bigint { // @ts-ignore const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore.wasm', true); // @ts-ignore - const wasm = new Uint8Array(wasmBuffer); - + const wasm = new Uint8Array(wasmBuffer); + const zkey_final = { type: "mem", // @ts-ignore data: new Uint8Array(await remix.call('fileManager', 'readFile', './zk/keys/groth16/zkey_final.txt', { encoding: null })) } - const wtns = { type: "mem" }; + const wtns = { type: "mem" }; const vKey = JSON.parse(await remix.call('fileManager', 'readFile', './zk/keys/groth16/verification_key.json')) - + // build list of identity commitments const secrets = [] const identityCommitments = [] for (let k = 0; k < 2; k++) { const identityTrapdoor = BigInt(ethers.utils.hexlify(ethers.utils.randomBytes(32))) const identityNullifier = BigInt(ethers.utils.hexlify(ethers.utils.randomBytes(32))) - secrets.push({identityTrapdoor, identityNullifier}) - + secrets.push({ identityTrapdoor, identityNullifier }) + const secret = poseidon([identityNullifier, identityTrapdoor]) const identityCommitment = poseidon([secret]) identityCommitments.push(identityCommitment) } //console.log('incremental tree', identityCommitments.map((x) => x.toString())) - + let tree - + try { tree = new IncrementalMerkleTree(poseidon, 20, BigInt(0), 2, identityCommitments) // Binary tree. } catch (e) { @@ -69,11 +69,11 @@ function hash(message: any): bigint { const index = tree.indexOf(identityCommitments[0]) console.log(index.toString()) - + const proof1 = tree.createProof(0) console.log('prepare signals for id ', identityCommitments[0].toString(), tree.indexOf(identityCommitments[0]), proof1.siblings.map((x)=> x.toString())) - + const signals = { identityTrapdoor: secrets[0].identityTrapdoor, identityNullifier: secrets[0].identityNullifier, @@ -82,16 +82,16 @@ function hash(message: any): bigint { externalNullifier: hash(42), signalHash: hash(ethers.utils.formatBytes32String("Hello World")) } - + console.log('calculate') await snarkjs.wtns.calculate(signals, wasm, wtns); - + console.log('check') await snarkjs.wtns.check(r1cs, wtns, logger); console.log('prove') const { proof, publicSignals } = await snarkjs.groth16.prove(zkey_final, wtns); - + const verified = await snarkjs.groth16.verify(vKey, publicSignals, proof, logger); console.log('zk proof validity', verified); proof1.root.toString() === publicSignals[0] ? console.log('merkle proof valid') : console.log('merkle proof invalid') @@ -100,7 +100,7 @@ function hash(message: any): bigint { groth16: await remix.call('fileManager', 'readFile', 'templates/groth16_verifier.sol.ejs') } const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates) - + await remix.call('fileManager', 'writeFile', './zk/build/groth16/zk_verifier.sol', solidityContract) await remix.call('fileManager', 'writeFile', 'zk/build/groth16/input.json', JSON.stringify({ _pA: [proof.pi_a[0], proof.pi_a[1]], diff --git a/libs/remix-ws-templates/src/templates/semaphore/scripts/plonk/plonk_trusted_setup.ts b/libs/remix-ws-templates/src/templates/semaphore/scripts/plonk/plonk_trusted_setup.ts index 8ebdab1e71..c6d73a91fb 100644 --- a/libs/remix-ws-templates/src/templates/semaphore/scripts/plonk/plonk_trusted_setup.ts +++ b/libs/remix-ws-templates/src/templates/semaphore/scripts/plonk/plonk_trusted_setup.ts @@ -24,13 +24,13 @@ const logger = { console.log('exportVerificationKey') const vKey = await snarkjs.zKey.exportVerificationKey(zkey_final) await remix.call('fileManager', 'writeFile', './zk/keys/plonk/verification_key.json', JSON.stringify(vKey, null, 2)) - + console.log('save zkey_final') // @ts-ignore await remix.call('fileManager', 'writeFile', './zk/keys/plonk/zkey_final.txt', (zkey_final as any).data, { encoding: null }) - + console.log('setup done.') - + } catch (e) { console.error(e.message) } diff --git a/libs/remix-ws-templates/src/templates/semaphore/scripts/plonk/plonk_zkproof.ts b/libs/remix-ws-templates/src/templates/semaphore/scripts/plonk/plonk_zkproof.ts index 6472567bb1..fd7f51d4a0 100644 --- a/libs/remix-ws-templates/src/templates/semaphore/scripts/plonk/plonk_zkproof.ts +++ b/libs/remix-ws-templates/src/templates/semaphore/scripts/plonk/plonk_zkproof.ts @@ -33,33 +33,33 @@ function hash(message: any): bigint { // @ts-ignore const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore.wasm', true); // @ts-ignore - const wasm = new Uint8Array(wasmBuffer); - + const wasm = new Uint8Array(wasmBuffer); + const zkey_final = { type: "mem", // @ts-ignore data: new Uint8Array(await remix.call('fileManager', 'readFile', './zk/keys/plonk/zkey_final.txt', { encoding: null })) } - const wtns = { type: "mem" }; + const wtns = { type: "mem" }; const vKey = JSON.parse(await remix.call('fileManager', 'readFile', './zk/keys/plonk/verification_key.json')) - + // build list of identity commitments const secrets = [] const identityCommitments = [] for (let k = 0; k < 2; k++) { const identityTrapdoor = BigInt(ethers.utils.hexlify(ethers.utils.randomBytes(32))) const identityNullifier = BigInt(ethers.utils.hexlify(ethers.utils.randomBytes(32))) - secrets.push({identityTrapdoor, identityNullifier}) - + secrets.push({ identityTrapdoor, identityNullifier }) + const secret = poseidon([identityNullifier, identityTrapdoor]) const identityCommitment = poseidon([secret]) identityCommitments.push(identityCommitment) } //console.log('incremental tree', identityCommitments.map((x) => x.toString())) - + let tree - + try { tree = new IncrementalMerkleTree(poseidon, 20, BigInt(0), 2, identityCommitments) // Binary tree. } catch (e) { @@ -69,11 +69,11 @@ function hash(message: any): bigint { const index = tree.indexOf(identityCommitments[0]) console.log(index.toString()) - + const proof1 = tree.createProof(0) console.log('prepare signals for id ', identityCommitments[0].toString(), tree.indexOf(identityCommitments[0]), proof1.siblings.map((x)=> x.toString())) - + const signals = { identityTrapdoor: secrets[0].identityTrapdoor, identityNullifier: secrets[0].identityNullifier, @@ -82,16 +82,16 @@ function hash(message: any): bigint { externalNullifier: hash(42), signalHash: hash(ethers.utils.formatBytes32String("Hello World")) } - + console.log('calculate') await snarkjs.wtns.calculate(signals, wasm, wtns); - + console.log('check') await snarkjs.wtns.check(r1cs, wtns, logger); console.log('prove') const { proof, publicSignals } = await snarkjs.plonk.prove(zkey_final, wtns); - + const verified = await snarkjs.plonk.verify(vKey, publicSignals, proof, logger); console.log('zk proof validity', verified); proof1.root.toString() === publicSignals[0] ? console.log('merkle proof valid') : console.log('merkle proof invalid') @@ -100,7 +100,7 @@ function hash(message: any): bigint { plonk: await remix.call('fileManager', 'readFile', 'templates/plonk_verifier.sol.ejs') } const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates) - + await remix.call('fileManager', 'writeFile', './zk/build/plonk/zk_verifier.sol', solidityContract) await remix.call('fileManager', 'writeFile', 'zk/build/plonk/input.json', JSON.stringify({ _proof: [ @@ -131,7 +131,7 @@ function hash(message: any): bigint { ], _pubSignals: publicSignals }, null, 2)) - + console.log('proof done.') } catch (e) { console.error(e.message) diff --git a/libs/remix-ws-templates/src/templates/semaphore/scripts/run_setup.ts b/libs/remix-ws-templates/src/templates/semaphore/scripts/run_setup.ts index 1d8505b71d..26764841d7 100644 --- a/libs/remix-ws-templates/src/templates/semaphore/scripts/run_setup.ts +++ b/libs/remix-ws-templates/src/templates/semaphore/scripts/run_setup.ts @@ -53,19 +53,19 @@ function hash(message: any): bigint { console.log('exportVerificationKey') const vKey = await snarkjs.zKey.exportVerificationKey(zkey_final) await remix.call('fileManager', 'writeFile', './zk/build/verification_key.json', JSON.stringify(vKey)) - + const templates = { groth16: await remix.call('fileManager', 'readFile', 'templates/groth16_verifier.sol.ejs') } const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates) - + await remix.call('fileManager', 'writeFile', './zk/build/zk_verifier.sol', solidityContract) - + console.log('buffer', (zkey_final as any).data.length) await remix.call('fileManager', 'writeFile', './zk/build/zk_setup.txt', JSON.stringify(Array.from(((zkey_final as any).data)))) - + console.log('setup done.') - + } catch (e) { console.error(e.message) } diff --git a/libs/remix-ws-templates/src/templates/semaphore/scripts/run_verification.ts b/libs/remix-ws-templates/src/templates/semaphore/scripts/run_verification.ts index e97e4074e9..24da889470 100644 --- a/libs/remix-ws-templates/src/templates/semaphore/scripts/run_verification.ts +++ b/libs/remix-ws-templates/src/templates/semaphore/scripts/run_verification.ts @@ -31,32 +31,32 @@ function hash(message: any): bigint { // @ts-ignore const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore.wasm', true); // @ts-ignore - const wasm = new Uint8Array(wasmBuffer); - + const wasm = new Uint8Array(wasmBuffer); + const zkey_final = { type: "mem", data: new Uint8Array(JSON.parse(await remix.call('fileManager', 'readFile', './zk/build/zk_setup.txt'))) } - const wtns = { type: "mem" }; + const wtns = { type: "mem" }; const vKey = JSON.parse(await remix.call('fileManager', 'readFile', './zk/build/verification_key.json')) - + // build list of identity commitments const secrets = [] const identityCommitments = [] - for (let k = 0; k < 2; k++) { + for (let k = 0; k < 2; k++) { const identityTrapdoor = BigInt(ethers.utils.hexlify(ethers.utils.randomBytes(32))) const identityNullifier = BigInt(ethers.utils.hexlify(ethers.utils.randomBytes(32))) - secrets.push({identityTrapdoor, identityNullifier}) - + secrets.push({ identityTrapdoor, identityNullifier }) + const secret = poseidon([identityNullifier, identityTrapdoor]) const identityCommitment = poseidon([secret]) identityCommitments.push(identityCommitment) } //console.log('incremental tree', identityCommitments.map((x) => x.toString())) - + let tree - + try { tree = new IncrementalMerkleTree(poseidon, 20, BigInt(0), 2, identityCommitments) // Binary tree. } catch (e) { @@ -66,11 +66,11 @@ function hash(message: any): bigint { const index = tree.indexOf(identityCommitments[0]) console.log(index.toString()) - + const proof1 = tree.createProof(0) console.log('prepare signals for id ', identityCommitments[0].toString(), tree.indexOf(identityCommitments[0]), proof1.siblings.map((x)=> x.toString())) - + const signals = { identityTrapdoor: secrets[0].identityTrapdoor, identityNullifier: secrets[0].identityNullifier, @@ -79,23 +79,20 @@ function hash(message: any): bigint { externalNullifier: hash(42), signalHash: hash(ethers.utils.formatBytes32String("Hello World")) } - + console.log('calculate') await snarkjs.wtns.calculate(signals, wasm, wtns); - + console.log('check') await snarkjs.wtns.check(r1cs, wtns, logger); - console.log('prove') const { proof, publicSignals } = await snarkjs.groth16.prove(zkey_final, wtns); - + const verified = await snarkjs.groth16.verify(vKey, publicSignals, proof, logger); console.log('zk proof validity', verified); proof1.root.toString() === publicSignals[0] ? console.log('merkle proof valid') : console.log('merkle proof invalid') - - } catch (e) { console.error(e.message) } diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts index 2753f9bcd0..8e4adf95a6 100644 --- a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts @@ -7,7 +7,7 @@ import { ethers } from 'ethers' * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -16,12 +16,12 @@ export const deploy = async (contractName: string, args: Array, accountInde const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - const contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts index c57e501039..cbd4f48489 100644 --- a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts @@ -21,7 +21,7 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - const contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, @@ -32,5 +32,5 @@ export const deploy = async (contractName: string, args: Array, from?: stri from: from || accounts[0], gas: gas || 1500000 }) - return newContractInstance.options + return newContractInstance.options } \ No newline at end of file From 4ecaca9218c92cb91e7f3b43fa68c05c4c561aba Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 13:51:35 +0200 Subject: [PATCH 08/31] lint fixes for remix-simulator --- libs/remix-simulator/src/VmProxy.ts | 18 +++++++++--------- libs/remix-simulator/src/methods/accounts.ts | 2 +- libs/remix-simulator/src/methods/blocks.ts | 4 ++-- .../src/methods/transactions.ts | 6 +++--- libs/remix-simulator/src/provider.ts | 12 ++++++------ libs/remix-simulator/src/server.ts | 2 +- libs/remix-simulator/src/vm-context.ts | 19 +++++++++---------- libs/remix-simulator/test/blocks.ts | 8 ++++---- libs/remix-simulator/test/events.ts | 8 ++++---- libs/remix-simulator/test/misc.ts | 14 +++++++------- libs/remix-simulator/test/transactions.ts | 2 +- 11 files changed, 47 insertions(+), 48 deletions(-) diff --git a/libs/remix-simulator/src/VmProxy.ts b/libs/remix-simulator/src/VmProxy.ts index 04ecf1f1f8..90df1fb8f0 100644 --- a/libs/remix-simulator/src/VmProxy.ts +++ b/libs/remix-simulator/src/VmProxy.ts @@ -1,11 +1,11 @@ -import { util } from '@remix-project/remix-lib' +import { util } from '@remix-project/remix-lib' const { toHexPaddedString, formatMemory } = util import { helpers } from '@remix-project/remix-lib' -const { normalizeHexAddress } = helpers.ui +const { normalizeHexAddress } = helpers.ui import { ConsoleLogs, hash } from '@remix-project/remix-lib' -import { toChecksumAddress, bytesToHex, Address, toBytes, bigIntToHex} from '@ethereumjs/util' -import utils, {toBigInt} from 'web3-utils' -import {isBigInt} from 'web3-validator' +import { toChecksumAddress, bytesToHex, Address, toBytes, bigIntToHex } from '@ethereumjs/util' +import utils, { toBigInt } from 'web3-utils' +import { isBigInt } from 'web3-validator' import { ethers } from 'ethers' import { VMContext } from './vm-context' import type { EVMStateManagerInterface } from '@ethereumjs/common' @@ -99,7 +99,7 @@ export class VmProxy { setVM (vm) { if (this.vm === vm) return this.vm = vm - this.vm.evm.events.on('step', async (data: InterpreterStep, resolve: (result?: any) => void) => { + this.vm.evm.events.on('step', async (data: InterpreterStep, resolve: (result?: any) => void) => { await this.pushTrace(data) resolve() }) @@ -110,7 +110,7 @@ export class VmProxy { }) this.vm.events.on('beforeTx', async (data: TypedTransaction, resolve: (result?: any) => void) => { this.txRunning = true - await this.txWillProcess(data) + await this.txWillProcess(data) resolve() }) } @@ -124,7 +124,7 @@ export class VmProxy { recordVMSteps (record) { this.flagrecordVMSteps = record } - + async txWillProcess (data: TypedTransaction) { if (!this.flagrecordVMSteps) return this.lastMemoryUpdate = [] @@ -234,7 +234,7 @@ export class VmProxy { async pushTrace (data: InterpreterStep) { if (!this.flagrecordVMSteps) return - + try { const depth = data.depth + 1 // geth starts the depth from 1 if (!this.processingHash) { diff --git a/libs/remix-simulator/src/methods/accounts.ts b/libs/remix-simulator/src/methods/accounts.ts index 5ac0116555..5151499d9f 100644 --- a/libs/remix-simulator/src/methods/accounts.ts +++ b/libs/remix-simulator/src/methods/accounts.ts @@ -56,7 +56,7 @@ export class Web3Accounts { } catch (e) { console.error(e) } - + } newAccount (cb) { diff --git a/libs/remix-simulator/src/methods/blocks.ts b/libs/remix-simulator/src/methods/blocks.ts index 0ca0dd768f..f708dacd92 100644 --- a/libs/remix-simulator/src/methods/blocks.ts +++ b/libs/remix-simulator/src/methods/blocks.ts @@ -59,7 +59,7 @@ export class Blocks { nonce: bigIntToHex(tx.nonce), transactionIndex: this.TX_INDEX, value: bigIntToHex(tx.value), - to: receipt.to ? receipt.to : null + to: receipt.to ? receipt.to : null } } }) @@ -113,7 +113,7 @@ export class Blocks { nonce: bigIntToHex(tx.nonce), transactionIndex: this.TX_INDEX, value: bigIntToHex(tx.value), - to: receipt.to ? receipt.to : null + to: receipt.to ? receipt.to : null } } }) diff --git a/libs/remix-simulator/src/methods/transactions.ts b/libs/remix-simulator/src/methods/transactions.ts index 9ac74d3d79..416e2e4ad8 100644 --- a/libs/remix-simulator/src/methods/transactions.ts +++ b/libs/remix-simulator/src/methods/transactions.ts @@ -1,5 +1,5 @@ import { toHex, toNumber, toBigInt } from 'web3-utils' -import { toChecksumAddress, Address, bigIntToHex, bytesToHex} from '@ethereumjs/util' +import { toChecksumAddress, Address, bigIntToHex, bytesToHex } from '@ethereumjs/util' import { processTx } from './txProcess' import { execution } from '@remix-project/remix-lib' import { ethers } from 'ethers' @@ -59,7 +59,7 @@ export class Transactions { this.txRunnerInstance = new TxRunner(this.txRunnerVMInstance, {}) this.txRunnerInstance.vmaccounts = accounts } - + methods () { return { eth_sendTransaction: this.eth_sendTransaction.bind(this), @@ -163,7 +163,7 @@ export class Transactions { this.txRunnerInstance.internalRunner.standaloneTx = false this.vmContext.web3().recordVMSteps(true) if (error) return cb(error) - const result: any = value.result + const result: any = value.result if ((result as any).receipt?.status === '0x0' || (result as any).receipt?.status === 0) { try { const msg = `${bytesToHex(result.execResult.returnValue) || '0x00'}` diff --git a/libs/remix-simulator/src/provider.ts b/libs/remix-simulator/src/provider.ts index 95b7cf6632..39b1cd1c5f 100644 --- a/libs/remix-simulator/src/provider.ts +++ b/libs/remix-simulator/src/provider.ts @@ -26,7 +26,7 @@ export interface JSONRPCResponsePayload { jsonrpc: string; } -export type JSONRPCResponseCallback = (err: Error, result?: JSONRPCResponsePayload) => void +export type JSONRPCResponseCallback = (err: Error, result?: JSONRPCResponsePayload) => void export type State = Record @@ -83,7 +83,7 @@ export class Provider { } } - _send(payload: JSONRPCRequestPayload, callback: (err: Error, result?: JSONRPCResponsePayload) => void) { + _send(payload: JSONRPCRequestPayload, callback: (err: Error, result?: JSONRPCResponsePayload) => void) { // log.info('payload method is ', payload.method) // commented because, this floods the IDE console if (!this.initialized) { this.pendingRequests.push({ payload, callback }) @@ -109,13 +109,13 @@ export class Provider { callback(new Error('unknown method ' + payload.method)) } - sendAsync (payload: JSONRPCRequestPayload, callback: (err: Error, result?: JSONRPCResponsePayload) => void) { + sendAsync (payload: JSONRPCRequestPayload, callback: (err: Error, result?: JSONRPCResponsePayload) => void) { return new Promise((resolve,reject)=>{ const cb = (err, result) => { - if(typeof callback==='function'){ + if (typeof callback==='function'){ callback(err,result) } - if(err){ + if (err){ return reject(err) } return resolve(result) @@ -146,7 +146,7 @@ export class Provider { } export function extend (web3) { - if(!web3.remix){ + if (!web3.remix){ web3.registerPlugin(new Web3TestPlugin()) } } diff --git a/libs/remix-simulator/src/server.ts b/libs/remix-simulator/src/server.ts index 73a2cd0552..15636cac5a 100644 --- a/libs/remix-simulator/src/server.ts +++ b/libs/remix-simulator/src/server.ts @@ -22,7 +22,7 @@ class Server { start (host, port) { const wsApp = expressWs(app) - + app.use(cors()) app.use(bodyParser.urlencoded({ extended: true })) app.use(bodyParser.json()) diff --git a/libs/remix-simulator/src/vm-context.ts b/libs/remix-simulator/src/vm-context.ts index 0b85f4cf60..f7e532c508 100644 --- a/libs/remix-simulator/src/vm-context.ts +++ b/libs/remix-simulator/src/vm-context.ts @@ -59,7 +59,7 @@ class StateManagerCommonStorageDump extends DefaultStateManager { } shallowCopy(): StateManagerCommonStorageDump { - const copyState = new StateManagerCommonStorageDump({ + const copyState = new StateManagerCommonStorageDump({ trie: this._trie.shallowCopy(false), }) copyState.keyHashes = this.keyHashes @@ -93,7 +93,7 @@ class StateManagerCommonStorageDump extends DefaultStateManager { }) } catch (e) { reject(e) - } + } }) } } @@ -110,7 +110,7 @@ export interface CustomEthersStateManagerOpts { class CustomEthersStateManager extends StateManagerCommonStorageDump { private provider: ethers.providers.StaticJsonRpcProvider | ethers.providers.JsonRpcProvider private blockTag: string - + constructor(opts: CustomEthersStateManagerOpts) { super(opts) if (typeof opts.provider === 'string') { @@ -188,7 +188,7 @@ class CustomEthersStateManager extends StateManagerCommonStorageDump { async accountExists(address: Address): Promise { const account = await super.getAccount(address) if (!account.isEmpty()) return true - + // Get merkle proof for `address` from provider const proof = await this.provider.send('eth_getProof', [address.toString(), [], this.blockTag]) @@ -245,12 +245,11 @@ class CustomEthersStateManager extends StateManagerCommonStorageDump { codeHash: hexToBytes(codeHash) // storageRoot: toBuffer([]), // we have to remove this in order to force the creation of the Trie in the local state. }) - } + } return account } } - export type CurrentVm = { vm: VM, web3vm: VmProxy, @@ -263,7 +262,7 @@ export class VMCommon extends Common { /** * Always return the fork set at initialization */ - setHardforkBy() { + setHardforkBy() { return this._hardfork; } } @@ -281,7 +280,7 @@ export class VMContext { txByHash: Record currentVm: CurrentVm web3vm: VmProxy - logsManager: any // LogsManager + logsManager: any // LogsManager exeResults: Record nodeUrl: string blockNumber: number | 'latest' @@ -332,7 +331,7 @@ export class VMContext { const db = this.stateDb ? new Map(Object.entries(this.stateDb).map(([k, v]) => [k, hexToBytes(v)])) : new Map() const mapDb = new MapDB(db) const trie = await Trie.create({ useKeyHashing: true, db: mapDb, useRootPersistence: true }) - + stateManager = new StateManagerCommonStorageDump({ trie }) } @@ -357,7 +356,7 @@ export class VMContext { const blockchain = await Blockchain.create({ common, validateBlocks: false, validateConsensus: false, genesisBlock }) const evm = await EVM.create({ common, allowUnlimitedContractSize: true, stateManager, blockchain }) - + const vm = await VM.create({ common, activatePrecompiles: true, diff --git a/libs/remix-simulator/test/blocks.ts b/libs/remix-simulator/test/blocks.ts index 08c5fe2e10..7923103edd 100644 --- a/libs/remix-simulator/test/blocks.ts +++ b/libs/remix-simulator/test/blocks.ts @@ -93,7 +93,7 @@ describe('blocks', () => { it('should get block given its hash', async () => { const correctBlock = await web3.eth.getBlock(0) const numberTransactions = await (new Promise((resolve, reject) => { - web3['_requestManager'].send({method: 'eth_getUncleCountByBlockHash', params: [correctBlock.hash]}) + web3['_requestManager'].send({ method: 'eth_getUncleCountByBlockHash', params: [correctBlock.hash]}) .then(numberTransactions => resolve(numberTransactions)) .catch(err => reject(err)) })) @@ -105,7 +105,7 @@ describe('blocks', () => { it('should get block given its number', async () => { const correctBlock = await web3.eth.getBlock(0) const numberTransactions = await (new Promise((resolve, reject) => { - web3['_requestManager'].send({method: 'eth_getUncleCountByBlockHash', params: [0]}) + web3['_requestManager'].send({ method: 'eth_getUncleCountByBlockHash', params: [0]}) .then(numberTransactions => resolve(numberTransactions)) .catch(err => reject(err)) })) @@ -201,7 +201,7 @@ describe('blocks', () => { const contract = new web3.eth.Contract(abi) const accounts = await web3.eth.getAccounts() - const contractInstance: any = await contract.deploy({ data: code, arguments: [100] }).send({ from: accounts[0], gas: '400000' }) + const contractInstance: any = await contract.deploy({ data: code, arguments: [100]}).send({ from: accounts[0], gas: '400000' }) contractInstance.currentProvider = web3.eth.currentProvider // contractInstance.givenProvider = web3.eth.currentProvider @@ -307,7 +307,7 @@ describe('blocks', () => { const contract = new web3.eth.Contract(abi) const accounts = await web3.eth.getAccounts() - const contractInstance: any = await contract.deploy({ data: code, arguments: [100] }).send({ from: accounts[0], gas: '400000' }) + const contractInstance: any = await contract.deploy({ data: code, arguments: [100]}).send({ from: accounts[0], gas: '400000' }) contractInstance.currentProvider = web3.eth.currentProvider const value = await contractInstance.methods.get().call({ from: accounts[0] }) diff --git a/libs/remix-simulator/test/events.ts b/libs/remix-simulator/test/events.ts index de8bb9b02a..7d8fad7e9c 100644 --- a/libs/remix-simulator/test/events.ts +++ b/libs/remix-simulator/test/events.ts @@ -47,7 +47,7 @@ describe('Events', () => { toBlock: 'latest', topics: ['0x342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a735', '0xdcd9c7fa0342f01013bd0bf2bec103a81936162dcebd1f0c38b1d4164c17e0fc'] }) - + // this should include the event triggered by the "set" transaction call. assert.equal(testLogs.length, 1, '1) testLogs length should be equal to 1') assert.equal(ownerLogs.length, 1, '2) ownerLogs length should be equal to 1') @@ -80,8 +80,8 @@ pragma solidity >=0.7.0 <0.9.0; import "hardhat/console.sol"; -contract test { - event testEvent(uint indexed value); +contract test { + event testEvent(uint indexed value); function set(Owner p) public { p.changeOwner(address(this)); emit testEvent(123); @@ -119,5 +119,5 @@ contract Owner { function getOwner() external view returns (address) { return owner; } -} +} */ diff --git a/libs/remix-simulator/test/misc.ts b/libs/remix-simulator/test/misc.ts index 785cc3dd55..673e98a35b 100644 --- a/libs/remix-simulator/test/misc.ts +++ b/libs/remix-simulator/test/misc.ts @@ -13,7 +13,7 @@ describe('Misc', () => { describe('web3_clientVersion', () => { it('should get correct remix simulator version', async () => { - web3['_requestManager'].send({ method: 'web3_clientVersion', params: [] }) + web3['_requestManager'].send({ method: 'web3_clientVersion', params: []}) .then(version => { const remixVersion = require('../package.json').version assert.equal(version, 'Remix Simulator/' + remixVersion) @@ -24,7 +24,7 @@ describe('Misc', () => { describe('eth_protocolVersion', () => { it('should get protocol version', async () => { - web3['_requestManager'].send({ method: 'eth_protocolVersion', params: [] }) + web3['_requestManager'].send({ method: 'eth_protocolVersion', params: []}) .then(result => assert.equal(result, '0x3f')) .catch(err => { throw new Error(err) }) }) @@ -53,7 +53,7 @@ describe('Misc', () => { describe('web3_sha3', () => { it('should get result of a sha3', async () => { - web3['_requestManager'].send({ method: 'web3_sha3', params: ['0x68656c6c6f20776f726c64'] }) + web3['_requestManager'].send({ method: 'web3_sha3', params: ['0x68656c6c6f20776f726c64']}) .then(result => assert.equal(result, '0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad')) .catch(err => { throw new Error(err)} ) }) @@ -61,7 +61,7 @@ describe('Misc', () => { describe('eth_getCompilers', () => { it('should get list of compilers', async () => { - web3['_requestManager'].send({ method: 'eth_getCompilers', params: [] }) + web3['_requestManager'].send({ method: 'eth_getCompilers', params: []}) .then(result => assert.equal(result, 0)) .catch(err => { throw new Error(err) }) }) @@ -69,7 +69,7 @@ describe('Misc', () => { describe('eth_compileSolidity', () => { it('get unsupported result when requesting solidity compiler', async () => { - web3['_requestManager'].send({ method: 'eth_compileSolidity', params: [] }) + web3['_requestManager'].send({ method: 'eth_compileSolidity', params: []}) .then(result => assert.equal(result, 'unsupported')) .catch(err => { throw new Error(err) }) }) @@ -77,7 +77,7 @@ describe('Misc', () => { describe('eth_compileLLL', () => { it('get unsupported result when requesting LLL compiler', async () => { - web3['_requestManager'].send({ method: 'eth_compileLLL', params: [] }) + web3['_requestManager'].send({ method: 'eth_compileLLL', params: []}) .then(result => assert.equal(result, 'unsupported')) .catch(err => { throw new Error(err) }) }) @@ -85,7 +85,7 @@ describe('Misc', () => { describe('eth_compileSerpent', () => { it('get unsupported result when requesting serpent compiler', async () => { - web3['_requestManager'].send({ method: 'eth_compileSerpent', params: [] }) + web3['_requestManager'].send({ method: 'eth_compileSerpent', params: []}) .then(result => assert.equal(result, 'unsupported')) .catch(err => { throw new Error(err)} ) }) diff --git a/libs/remix-simulator/test/transactions.ts b/libs/remix-simulator/test/transactions.ts index 30f9a96fd2..88e7a09c05 100644 --- a/libs/remix-simulator/test/transactions.ts +++ b/libs/remix-simulator/test/transactions.ts @@ -6,7 +6,7 @@ import * as assert from 'assert' describe('Transactions', () => { before(async function () { - const provider = new Provider({ fork: 'shanghai'}) + const provider = new Provider({ fork: 'shanghai' }) await provider.init() web3.setProvider(provider as any) }) From f5cdc389a71a7fed101a783f3a20819ef2210a43 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 13:52:37 +0200 Subject: [PATCH 09/31] linting fixed for remix-analyzer --- .../test/analysis/staticAnalysisCommon-test.ts | 11 +++++------ .../analysis/staticAnalysisIntegration-test-0.4.24.ts | 4 ++-- .../analysis/staticAnalysisIntegration-test-0.5.0.ts | 3 --- .../test/analysis/staticAnalysisIssues-test-0.4.24.ts | 6 +++--- .../test/analysis/staticAnalysisIssues-test-0.5.0.ts | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/libs/remix-analyzer/test/analysis/staticAnalysisCommon-test.ts b/libs/remix-analyzer/test/analysis/staticAnalysisCommon-test.ts index 4dd79d9689..596abee649 100644 --- a/libs/remix-analyzer/test/analysis/staticAnalysisCommon-test.ts +++ b/libs/remix-analyzer/test/analysis/staticAnalysisCommon-test.ts @@ -1,4 +1,4 @@ -import { default as test} from "tape" +import { default as test } from "tape" import * as common from '../../src/solidity-analyzer/modules/staticAnalysisCommon' const { localCall, thisLocalCall, libCall, externalDirect, superLocal, assignment, abiNamespaceCallNodes, inlineAssembly, unaryOperation, nowAst, blockTimestamp, stateVariableContractNode, @@ -6,7 +6,6 @@ const { localCall, thisLocalCall, libCall, externalDirect, superLocal, assignmen // eslint-disable-next-line @typescript-eslint/no-var-requires lowlevelCall, parameterFunction, parameterFunctionCall, inheritance, blockHashAccess, contractDefinition, funcDefForComplexParams } = require('./astBlocks') - // eslint-disable-next-line @typescript-eslint/no-var-requires const compiledContractObj = require('./compilationDetails/CompiledContractObj.json') function escapeRegExp (str) { @@ -89,7 +88,7 @@ test('staticAnalysisCommon.helpers.operator', function (t) { test('staticAnalysisCommon.helpers.nodeType', function (t) { t.plan(3) - const node = { nodeType: 'Identifier', name: 'now'} + const node = { nodeType: 'Identifier', name: 'now' } const node2 = { nodeType: 'FunctionCall', memberName: 'call' } t.ok(common.helpers.nodeType(node, common.nodeTypes.IDENTIFIER), 'should work for identifier') @@ -140,7 +139,7 @@ test('staticAnalysisCommon.helpers.expressionTypeDescription', function (t) { test('staticAnalysisCommon.getType', function (t) { t.plan(3) - const node = { "argumentTypes": null, + const node = { "argumentTypes": null, "id": 3, "name": "a", "nodeType": "Identifier", @@ -357,9 +356,9 @@ test('staticAnalysisCommon.isStateVariable', function (t) { test('staticAnalysisCommon.isConstantFunction', function (t) { t.plan(3) t.ok(common.isConstantFunction(functionDefinition), 'should be const func definition') - functionDefinition.stateMutability = 'view' + functionDefinition.stateMutability = 'view' t.ok(common.isConstantFunction(functionDefinition), 'should be const func definition') - functionDefinition.stateMutability = 'nonpayable' + functionDefinition.stateMutability = 'nonpayable' t.notOk(common.isConstantFunction(functionDefinition), 'should not be const func definition') }) diff --git a/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts b/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts index 305b53ae97..7c3273a0a8 100644 --- a/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts +++ b/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts @@ -46,7 +46,7 @@ test('setup', function (t: test.Test) { testFiles.forEach((fileName) => { const content: string = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8') - // Latest AST is available under 'compileStandardWrapper' under solc for, 0.4.12 <= version < 0.5.0 + // Latest AST is available under 'compileStandardWrapper' under solc for, 0.4.12 <= version < 0.5.0 compilationResults[fileName] = JSON.parse(compiler.compile(compilerInput(content))) }) @@ -820,5 +820,5 @@ function runModuleOnFiles (Module: any, t: test.Test, cb: ((fname: string, repor t.comment('Error while executing Module: ' + JSON.stringify(report)) } cb(fileName, report) - }) + }) } diff --git a/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts b/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts index 18881e20ef..6957b9de48 100644 --- a/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts +++ b/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts @@ -53,9 +53,6 @@ test('setup', function (t) { }) }); - - - test('Integration test thisLocal module', function (t: test.Test) { t.plan(testFiles.length) const module: any = modules.thisLocal diff --git a/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts b/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts index 2a6091dc32..94f7c32636 100644 --- a/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts +++ b/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts @@ -29,11 +29,11 @@ test('staticAnalysisIssues.functionParameterPassingError', function (t) { const res: CompilationResult = compile('functionParameters.sol') const Module: any = checksEffectsInteraction const statRunner: StatRunner = new StatRunner() - + t.doesNotThrow(() => { - statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module()}]) + statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }]) }, 'Analysis should not throw') - const reports = statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module()}]) + const reports = statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }]) t.ok(!reports.some((mod: AnalysisReport) => mod.report.some((rep: AnalysisReportObj) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors')) }) diff --git a/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts b/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts index 43234e4168..212eb0114c 100644 --- a/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts +++ b/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts @@ -6,7 +6,7 @@ import { default as StatRunner } from '../../src/solidity-analyzer' import solc from 'solc'; import { CompilationResult, AnalysisReportObj, AnalysisReport } from '../../src/types' import { checksEffectsInteraction } from '../../src/solidity-analyzer/modules/' -const {compilerInput } = helpers.compiler +const { compilerInput } = helpers.compiler const folder: string = 'solidity-v0.5' let compiler From e5920ae3b299997de1784e49b175761cb01abf17 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 13:53:47 +0200 Subject: [PATCH 10/31] linting fixed for remix-debug --- libs/remix-debug/src/Ethdebugger.ts | 10 ++--- libs/remix-debug/src/debugger/VmDebugger.ts | 10 ++--- libs/remix-debug/src/debugger/debugger.ts | 8 ++-- .../remix-debug/src/debugger/solidityState.ts | 2 +- libs/remix-debug/src/debugger/stepManager.ts | 2 +- libs/remix-debug/src/init.ts | 4 +- .../src/solidity-decoder/internalCallTree.ts | 18 ++++---- .../src/solidity-decoder/solidityProxy.ts | 2 +- libs/remix-debug/src/trace/traceAnalyser.ts | 2 +- libs/remix-debug/src/trace/traceManager.ts | 2 +- libs/remix-debug/test.ts | 2 +- libs/remix-debug/test/codeManager.ts | 2 +- libs/remix-debug/test/debugger.ts | 12 +++--- .../test/decoder/contracts/calldata.ts | 2 +- .../test/decoder/contracts/intLocal.ts | 2 +- .../test/decoder/contracts/miscLocal.ts | 2 +- .../decoder/contracts/structArrayLocal.ts | 2 +- libs/remix-debug/test/decoder/localDecoder.ts | 6 +-- .../test/decoder/localsTests/calldata.ts | 7 ++-- .../test/decoder/localsTests/int.ts | 28 ++++++------- .../test/decoder/localsTests/misc.ts | 12 +++--- .../test/decoder/localsTests/misc2.ts | 10 ++--- .../test/decoder/localsTests/structArray.ts | 26 ++++++------ .../test/decoder/stateTests/mapping.ts | 8 ++-- .../test/helpers/compilerHelper.ts | 4 +- libs/remix-debug/test/resources/ast.ts | 41 +++++++++---------- libs/remix-debug/test/resources/testWeb3.ts | 4 +- .../remix-debug/test/sourceLocationTracker.ts | 30 +++++++------- libs/remix-debug/test/traceManager.ts | 2 +- libs/remix-debug/test/vmCall.ts | 3 +- 30 files changed, 130 insertions(+), 135 deletions(-) diff --git a/libs/remix-debug/src/Ethdebugger.ts b/libs/remix-debug/src/Ethdebugger.ts index f4e2d66ae8..a22b29313c 100644 --- a/libs/remix-debug/src/Ethdebugger.ts +++ b/libs/remix-debug/src/Ethdebugger.ts @@ -44,10 +44,10 @@ export class Ethdebugger { this.event = new EventManager() this.traceManager = new TraceManager({ web3: this.web3 }) this.codeManager = new CodeManager(this.traceManager) - this.solidityProxy = new SolidityProxy({ - getCurrentCalledAddressAt: this.traceManager.getCurrentCalledAddressAt.bind(this.traceManager), + this.solidityProxy = new SolidityProxy({ + getCurrentCalledAddressAt: this.traceManager.getCurrentCalledAddressAt.bind(this.traceManager), getCode: this.codeManager.getCode.bind(this.codeManager), - compilationResult: this.compilationResult + compilationResult: this.compilationResult }) this.storageResolver = null @@ -63,8 +63,8 @@ export class Ethdebugger { setManagers () { this.traceManager = new TraceManager({ web3: this.web3 }) this.codeManager = new CodeManager(this.traceManager) - this.solidityProxy = new SolidityProxy({ - getCurrentCalledAddressAt: this.traceManager.getCurrentCalledAddressAt.bind(this.traceManager), + this.solidityProxy = new SolidityProxy({ + getCurrentCalledAddressAt: this.traceManager.getCurrentCalledAddressAt.bind(this.traceManager), getCode: this.codeManager.getCode.bind(this.codeManager), compilationResult: this.compilationResult }) diff --git a/libs/remix-debug/src/debugger/VmDebugger.ts b/libs/remix-debug/src/debugger/VmDebugger.ts index 19a8be3d51..d8c3c909b6 100644 --- a/libs/remix-debug/src/debugger/VmDebugger.ts +++ b/libs/remix-debug/src/debugger/VmDebugger.ts @@ -110,7 +110,7 @@ export class VmDebuggerLogic { } catch (e) { console.log(e) } - + try { const memory = this._traceManager.getMemoryAt(index) if (this.stepManager.currentStepIndex === index) { @@ -122,9 +122,9 @@ export class VmDebuggerLogic { try { const address = this._traceManager.getCurrentCalledAddressAt(index) if (!this.storageResolver) return - + const storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this._traceManager) - + storageViewer.storageRange().then((storage) => { if (this.stepManager.currentStepIndex === index) { const header = storageViewer.isComplete(address) ? '[Completely Loaded]' : '[Partially Loaded]' @@ -145,8 +145,8 @@ export class VmDebuggerLogic { } catch (error) { this.event.trigger('traceReturnValueUpdate', [[error]]) } - })() - }, 1000) + })() + }, 1000) try { const step = this._traceManager.getCurrentStep(index) diff --git a/libs/remix-debug/src/debugger/debugger.ts b/libs/remix-debug/src/debugger/debugger.ts index a939357a98..643a391719 100644 --- a/libs/remix-debug/src/debugger/debugger.ts +++ b/libs/remix-debug/src/debugger/debugger.ts @@ -84,10 +84,10 @@ export class Debugger { const generatedSources = this.debugger.callTree.sourceLocationTracker.getGeneratedSourcesFromAddress(address) const lineColumnPos = rawLocationAndOpcode.lineColumnPos - + let lineGasCostObj = null try { - lineGasCostObj = await this.debugger.callTree.getGasCostPerLine(rawLocation.file, lineColumnPos.start.line) + lineGasCostObj = await this.debugger.callTree.getGasCostPerLine(rawLocation.file, lineColumnPos.start.line) } catch (e) { console.log(e) } @@ -97,9 +97,9 @@ export class Debugger { const instructionIndexes = lineGasCostObj.indexes.map((index) => { // translate from vmtrace index to instruction index return this.debugger.codeManager.getInstructionIndex(address, index) }) - this.vmDebuggerLogic.event.trigger('lineGasCostChanged', [instructionIndexes, lineColumnPos.start.line ]) + this.vmDebuggerLogic.event.trigger('lineGasCostChanged', [instructionIndexes, lineColumnPos.start.line]) this.currentFile = rawLocation.file - this.currentLine = lineColumnPos.start.line + this.currentLine = lineColumnPos.start.line } } else { this.event.trigger('newSourceLocation', [null]) diff --git a/libs/remix-debug/src/debugger/solidityState.ts b/libs/remix-debug/src/debugger/solidityState.ts index 237be4e7da..3605cb946d 100644 --- a/libs/remix-debug/src/debugger/solidityState.ts +++ b/libs/remix-debug/src/debugger/solidityState.ts @@ -32,7 +32,7 @@ export class DebuggerSolidityState { } if (this.stepManager.currentStepIndex !== index) return - + if (!this.storageResolver) { return } diff --git a/libs/remix-debug/src/debugger/stepManager.ts b/libs/remix-debug/src/debugger/stepManager.ts index 8c0e6512d5..02da0263bb 100644 --- a/libs/remix-debug/src/debugger/stepManager.ts +++ b/libs/remix-debug/src/debugger/stepManager.ts @@ -77,7 +77,7 @@ export class DebuggerStepManager { const revertedReason = this.currentCall.outofgas ? 'outofgas' : 'reverted' this.revertionPoint = this.currentCall.return this.event.trigger('revertWarning', [revertedReason]) - return + return } for (let k = callsPath.length - 2; k >= 0; k--) { const parent = callsPath[k] diff --git a/libs/remix-debug/src/init.ts b/libs/remix-debug/src/init.ts index 28923df9d0..4ddafff021 100644 --- a/libs/remix-debug/src/init.ts +++ b/libs/remix-debug/src/init.ts @@ -1,9 +1,9 @@ 'use strict' import Web3, { Web3PluginBase } from 'web3' -import {toNumber} from 'web3-utils' +import { toNumber } from 'web3-utils' export function extendWeb3 (web3) { - if(!web3.debug){ + if (!web3.debug){ web3.registerPlugin(new Web3DebugPlugin()) } } diff --git a/libs/remix-debug/src/solidity-decoder/internalCallTree.ts b/libs/remix-debug/src/solidity-decoder/internalCallTree.ts index 4f74ad4585..3ac6fe985b 100644 --- a/libs/remix-debug/src/solidity-decoder/internalCallTree.ts +++ b/libs/remix-debug/src/solidity-decoder/internalCallTree.ts @@ -97,7 +97,7 @@ export class InternalCallTree { }) } catch (e) { console.log(e) - } + } } }) } @@ -214,7 +214,7 @@ export class InternalCallTree { } throw new Error('Could not find gas cost per line') } - + getLocalVariableById (id: number) { return this.variables[id] } @@ -226,7 +226,7 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?, const address = tree.traceManager.getCurrentCalledAddressAt(step) await registerFunctionParameters(tree, functionDefinition, step, scopeId, contractObj, validSourceLocation, address) } - + function callDepthChange (step, trace) { if (step + 1 < trace.length) { return trace[step].depth !== trace[step + 1].depth @@ -252,11 +252,11 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?, let sourceLocation let validSourceLocation let address - + try { address = tree.traceManager.getCurrentCalledAddressAt(step) sourceLocation = await tree.extractSourceLocation(step, address) - + if (!includedSource(sourceLocation, currentSourceLocation)) { tree.reducedTrace.push(step) currentSourceLocation = sourceLocation @@ -270,7 +270,7 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?, validSourceLocation = previousValidSourceLocation } else validSourceLocation = currentSourceLocation - + } catch (e) { return { outStep: step, error: 'InternalCallTree - Error resolving source location. ' + step + ' ' + e } } @@ -285,7 +285,7 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?, } else { stepDetail.gasCost = parseInt(stepDetail.gasCost as unknown as string) } - + // gas per line let lineColumnPos if (tree.offsetToLineColumnConverter) { @@ -299,7 +299,7 @@ async function buildTree (tree, step, scopeId, isCreation, functionDefinition?, sources[genSource.name] = { content: genSource.contents } } } - + lineColumnPos = await tree.offsetToLineColumnConverter.offsetToLineColumn(validSourceLocation, validSourceLocation.file, sources, astSources) if (!tree.gasCostPerLine[validSourceLocation.file]) tree.gasCostPerLine[validSourceLocation.file] = {} if (!tree.gasCostPerLine[validSourceLocation.file][lineColumnPos.start.line]) { @@ -391,7 +391,7 @@ function getGeneratedSources (tree, scopeId, contractObj) { async function registerFunctionParameters (tree, functionDefinition, step, scopeId, contractObj, sourceLocation, address) { tree.functionCallStack.push(step) - const functionDefinitionAndInputs = { functionDefinition, inputs: [] } + const functionDefinitionAndInputs = { functionDefinition, inputs: []} // means: the previous location was a function definition && JUMPDEST // => we are at the beginning of the function and input/output are setup try { diff --git a/libs/remix-debug/src/solidity-decoder/solidityProxy.ts b/libs/remix-debug/src/solidity-decoder/solidityProxy.ts index fd91e23195..b49e1d6fe7 100644 --- a/libs/remix-debug/src/solidity-decoder/solidityProxy.ts +++ b/libs/remix-debug/src/solidity-decoder/solidityProxy.ts @@ -64,7 +64,7 @@ export class SolidityProxy { */ async extractStatesDefinitions (address: string) { const compilationResult = await this.compilationResult(address) - if (!this.cache.contractDeclarations[address]) { + if (!this.cache.contractDeclarations[address]) { this.cache.contractDeclarations[address] = extractContractDefinitions(compilationResult.data.sources) } if (!this.cache.statesDefinitions[address]) { diff --git a/libs/remix-debug/src/trace/traceAnalyser.ts b/libs/remix-debug/src/trace/traceAnalyser.ts index ba41085d19..24491c9d77 100644 --- a/libs/remix-debug/src/trace/traceAnalyser.ts +++ b/libs/remix-debug/src/trace/traceAnalyser.ts @@ -1,5 +1,5 @@ 'use strict' -import { util } from '@remix-project/remix-lib' +import { util } from '@remix-project/remix-lib' import { bytesToHex } from '@ethereumjs/util' const { toHexPaddedString } = util import * as traceHelper from './traceHelper' diff --git a/libs/remix-debug/src/trace/traceManager.ts b/libs/remix-debug/src/trace/traceManager.ts index 97b3d70ce9..d8b164a0ab 100644 --- a/libs/remix-debug/src/trace/traceManager.ts +++ b/libs/remix-debug/src/trace/traceManager.ts @@ -155,7 +155,7 @@ export class TraceManager { return stack.map(el => toHexPaddedString(el)) } else { // it's an object coming from the VM. - // for performance reasons, + // for performance reasons, // we don't turn the stack coming from the VM into an array when the tx is executed // but now when the app needs it. const stack = [] diff --git a/libs/remix-debug/test.ts b/libs/remix-debug/test.ts index e1e5b12946..0fe8ab5edb 100644 --- a/libs/remix-debug/test.ts +++ b/libs/remix-debug/test.ts @@ -37,7 +37,7 @@ const compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(in console.dir(Object.keys(compilationData)) const compilation = {} compilation['data'] = compilationData -compilation['source'] = {sources: inputJson.sources} +compilation['source'] = { sources: inputJson.sources } console.dir(compilation) console.dir(compilation['data'].errors) diff --git a/libs/remix-debug/test/codeManager.ts b/libs/remix-debug/test/codeManager.ts index 3ba95be60a..449562afeb 100644 --- a/libs/remix-debug/test/codeManager.ts +++ b/libs/remix-debug/test/codeManager.ts @@ -5,7 +5,7 @@ import { CodeManager } from '../src/code/codeManager' const web3Test = require('./resources/testWeb3.ts') tape('CodeManager', function (t) { - const traceManager = new TraceManager({web3: web3Test}) + const traceManager = new TraceManager({ web3: web3Test }) const codeManager = new CodeManager(traceManager) const contractCode = web3Test.eth.getCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5') codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', contractCode) // so a call to web3 is not necessary diff --git a/libs/remix-debug/test/debugger.ts b/libs/remix-debug/test/debugger.ts index 4c93d17f18..7c51ce7fc4 100644 --- a/libs/remix-debug/test/debugger.ts +++ b/libs/remix-debug/test/debugger.ts @@ -156,7 +156,7 @@ contract Ballot { output = JSON.parse(output) const param = '0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000148656c6c6f20576f726c64210000000000000000000000000000000000000000' const web3 = await vmCall.getWeb3() - vmCall.sendTx(web3, {nonce: 0, privateKey: privateKey}, undefined, 0, output.contracts['test.sol']['Ballot'].evm.bytecode.object + param, (error, hash) => { + vmCall.sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, output.contracts['test.sol']['Ballot'].evm.bytecode.object + param, (error, hash) => { console.log(error, hash) if (error) { throw error @@ -177,7 +177,7 @@ contract Ballot { } } }) - + debugManager.callTree.event.register('callTreeReady', () => { testDebugging(debugManager) }) @@ -189,7 +189,7 @@ contract Ballot { console.error(error) throw error }) - + debugManager.debug(tx) }) .catch(error => { throw error }) @@ -279,10 +279,10 @@ function testDebugging (debugManager) { tape('breakPointManager', (t) => { t.plan(2) - const {traceManager, callTree, solidityProxy} = debugManager - const breakPointManager = new BreakpointManager({traceManager, callTree, solidityProxy}) + const { traceManager, callTree, solidityProxy } = debugManager + const breakPointManager = new BreakpointManager({ traceManager, callTree, solidityProxy }) - breakPointManager.add({fileName: 'test.sol', row: 39}) + breakPointManager.add({ fileName: 'test.sol', row: 39 }) breakPointManager.event.register('breakpointHit', function (sourceLocation, step) { t.equal(JSON.stringify(sourceLocation), JSON.stringify({ start: 1146, length: 6, file: 0, jump: '-' })) diff --git a/libs/remix-debug/test/decoder/contracts/calldata.ts b/libs/remix-debug/test/decoder/contracts/calldata.ts index 62d3df3ea4..39a5f08173 100644 --- a/libs/remix-debug/test/decoder/contracts/calldata.ts +++ b/libs/remix-debug/test/decoder/contracts/calldata.ts @@ -11,4 +11,4 @@ module.exports = { uint p = 45; } } -`} +` } diff --git a/libs/remix-debug/test/decoder/contracts/intLocal.ts b/libs/remix-debug/test/decoder/contracts/intLocal.ts index 0b4a112808..5a4775f888 100644 --- a/libs/remix-debug/test/decoder/contracts/intLocal.ts +++ b/libs/remix-debug/test/decoder/contracts/intLocal.ts @@ -39,4 +39,4 @@ contract intLocal { uint8 ui81 = asd; } } -`} +` } diff --git a/libs/remix-debug/test/decoder/contracts/miscLocal.ts b/libs/remix-debug/test/decoder/contracts/miscLocal.ts index 2447e2f959..56d3a63649 100644 --- a/libs/remix-debug/test/decoder/contracts/miscLocal.ts +++ b/libs/remix-debug/test/decoder/contracts/miscLocal.ts @@ -36,4 +36,4 @@ contract miscLocal { string memory smallstring = "test_test_test"; } } -`} +` } diff --git a/libs/remix-debug/test/decoder/contracts/structArrayLocal.ts b/libs/remix-debug/test/decoder/contracts/structArrayLocal.ts index c8391005d8..34b67e887c 100644 --- a/libs/remix-debug/test/decoder/contracts/structArrayLocal.ts +++ b/libs/remix-debug/test/decoder/contracts/structArrayLocal.ts @@ -81,4 +81,4 @@ contract structArrayLocal { arrayStruct.c = enumdef.three; } } -`} +` } diff --git a/libs/remix-debug/test/decoder/localDecoder.ts b/libs/remix-debug/test/decoder/localDecoder.ts index e8e92d25f2..637b636bda 100644 --- a/libs/remix-debug/test/decoder/localDecoder.ts +++ b/libs/remix-debug/test/decoder/localDecoder.ts @@ -31,7 +31,7 @@ async function test (st, privateKey) { let compilationResults = new CompilerAbstract('json', output, sources) console.log('intLocalTest') await intLocalTest(st, privateKey, output.contracts['test.sol']['intLocal'].evm.bytecode.object, compilationResults, intLocal.contract) - + output = compiler.compile(compilerInput(miscLocal.contract)) output = JSON.parse(output) sources = { @@ -41,7 +41,7 @@ async function test (st, privateKey) { compilationResults = new CompilerAbstract('json', output, sources) console.log('miscLocalTest') await miscLocalTest(st, privateKey, output.contracts['test.sol']['miscLocal'].evm.bytecode.object, compilationResults, miscLocal.contract) - + output = compiler.compile(compilerInput(miscLocal.contract)) output = JSON.parse(output) sources = { @@ -51,7 +51,7 @@ async function test (st, privateKey) { compilationResults = new CompilerAbstract('json', output, sources) console.log('misc2LocalTest') await misc2LocalTest(st, privateKey, output.contracts['test.sol']['miscLocal2'].evm.bytecode.object, compilationResults, miscLocal.contract) - + output = compiler.compile(compilerInput(structArrayLocal.contract)) output = JSON.parse(output) sources = { diff --git a/libs/remix-debug/test/decoder/localsTests/calldata.ts b/libs/remix-debug/test/decoder/localsTests/calldata.ts index 213fd5d96b..de2932ea0f 100644 --- a/libs/remix-debug/test/decoder/localsTests/calldata.ts +++ b/libs/remix-debug/test/decoder/localsTests/calldata.ts @@ -30,8 +30,8 @@ module.exports = async function (st, privateKey, contractBytecode, compilationRe const traceManager = new TraceManager({ web3 }) const codeManager = new CodeManager(traceManager) codeManager.clear() - const solidityProxy = new SolidityProxy({ - getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), + const solidityProxy = new SolidityProxy({ + getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), getCode: codeManager.getCode.bind(codeManager), compilationResult: () => compilationResult }) @@ -54,7 +54,7 @@ module.exports = async function (st, privateKey, contractBytecode, compilationRe callTree.event.register('callTreeReady', (scopes, scopeStarts) => { helper.decodeLocals(st, 140, traceManager, callTree, function (locals) { try { - const expected = {"p":{"value":"45","type":"uint256"},"foo":{"length":"1","value":[{"value":"3","type":"uint8"}],"type":"uint8[1]"},"boo":{"length":"1","value":[{"length":"2","value":[{"value":"R","type":"string"},{"value":"T","type":"string"}],"type":"string[2]"}],"type":"string[2][1]"}} + const expected = { "p":{ "value":"45","type":"uint256" },"foo":{ "length":"1","value":[{ "value":"3","type":"uint8" }],"type":"uint8[1]" },"boo":{ "length":"1","value":[{ "length":"2","value":[{ "value":"R","type":"string" },{ "value":"T","type":"string" }],"type":"string[2]" }],"type":"string[2][1]" } } st.deepEqual(locals, expected) } catch (e) { st.fail(e.message) @@ -62,7 +62,6 @@ module.exports = async function (st, privateKey, contractBytecode, compilationRe resolve({}) }) }) - traceManager.resolveTrace(tx).then(() => { debuggerEvent.trigger('newTraceLoaded', [traceManager.trace]) diff --git a/libs/remix-debug/test/decoder/localsTests/int.ts b/libs/remix-debug/test/decoder/localsTests/int.ts index fa52b55714..06b7a78e5d 100644 --- a/libs/remix-debug/test/decoder/localsTests/int.ts +++ b/libs/remix-debug/test/decoder/localsTests/int.ts @@ -12,9 +12,9 @@ import * as helper from './helper' module.exports = function (st, privateKey, contractBytecode, compilationResult, contractCode) { // eslint-disable-next-line no-async-promise-executor - return new Promise(async (resolve) => { + return new Promise(async (resolve) => { const web3 = await (vmCall as any).getWeb3(); - (vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, contractBytecode, function (error, hash) { + (vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, contractBytecode, function (error, hash) { if (error) { return st.fail(error) } @@ -24,10 +24,10 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, const traceManager = new TraceManager({ web3 }) const codeManager = new CodeManager(traceManager) codeManager.clear() - const solidityProxy = new SolidityProxy({ - getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), + const solidityProxy = new SolidityProxy({ + getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), getCode: codeManager.getCode.bind(codeManager), - compilationResult: () => compilationResult + compilationResult: () => compilationResult }) const debuggerEvent = new EventManager() const offsetToLineColumnConverter = { @@ -47,26 +47,26 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, }) callTree.event.register('callTreeReady', async (scopes, scopeStarts) => { try { - + // test gas cost per line st.equals((await callTree.getGasCostPerLine(0, 16)).gasCost, 11) st.equals((await callTree.getGasCostPerLine(0, 32)).gasCost, 84) - + const functions1 = callTree.retrieveFunctionsStack(103) const functions2 = callTree.retrieveFunctionsStack(116) const functions3 = callTree.retrieveFunctionsStack(13) - + st.equals(functions1.length, 2) st.equals(functions2.length, 3) st.equals(functions3.length, 1) - + st.equal(functions1[0].gasCost, 54) st.equal(functions1[1].gasCost, 436) st.equal(functions2[0].gasCost, 23) st.equal(functions2[1].gasCost, 54) st.equal(functions2[2].gasCost, 436) - + st.equals(Object.keys(functions1[0])[0], 'functionDefinition') st.equals(Object.keys(functions1[0])[1], 'inputs') st.equals(functions1[0].inputs[0], 'foo') @@ -76,11 +76,11 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, st.equals(Object.keys(functions2[1])[1], 'inputs') st.equals(functions2[0].inputs[0], 'asd') st.equals(functions2[1].inputs[0], 'foo') - + st.equals(functions1[0].functionDefinition.name, 'level11') st.equals(functions2[0].functionDefinition.name, 'level12') st.equals(functions2[1].functionDefinition.name, 'level11') - + st.equals(scopeStarts[0], '1') st.equals(scopeStarts[10], '1.1') st.equals(scopeStarts[102], '1.1.1') @@ -111,7 +111,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, } catch (e) { st.fail(e.message) } - + helper.decodeLocals(st, 95, traceManager, callTree, function (locals) { st.equals(Object.keys(locals).length, 16) st.equals(locals['ui8'].value, '130') @@ -130,7 +130,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, st.equals(locals['i'].value, '-32432423423') st.equals(locals['ishrink'].value, '2') }) - + helper.decodeLocals(st, 106, traceManager, callTree, function (locals) { try { st.equals(locals['ui8'].value, '123') diff --git a/libs/remix-debug/test/decoder/localsTests/misc.ts b/libs/remix-debug/test/decoder/localsTests/misc.ts index c7f7c329bf..1c76b42499 100644 --- a/libs/remix-debug/test/decoder/localsTests/misc.ts +++ b/libs/remix-debug/test/decoder/localsTests/misc.ts @@ -13,7 +13,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, // eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve) => { const web3 = await (vmCall as any).getWeb3(); - (vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, contractBytecode, function (error, hash) { + (vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, contractBytecode, function (error, hash) { if (error) { return st.fail(error) } @@ -23,10 +23,10 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, const traceManager = new TraceManager({ web3 }) const codeManager = new CodeManager(traceManager) codeManager.clear() - const solidityProxy = new SolidityProxy({ - getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), + const solidityProxy = new SolidityProxy({ + getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), getCode: codeManager.getCode.bind(codeManager), - compilationResult: () => compilationResult + compilationResult: () => compilationResult }) const debuggerEvent = new EventManager() const offsetToLineColumnConverter = { @@ -65,7 +65,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, st.fail(e.message) } }) - + helper.decodeLocals(st, 7, traceManager, callTree, function (locals) { try { // st.equals(Object.keys(locals).length, 0) @@ -84,5 +84,5 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, }) .catch(error => st.fail(error)) }) - }) + }) } diff --git a/libs/remix-debug/test/decoder/localsTests/misc2.ts b/libs/remix-debug/test/decoder/localsTests/misc2.ts index d92d2c59a9..c10dfacd46 100644 --- a/libs/remix-debug/test/decoder/localsTests/misc2.ts +++ b/libs/remix-debug/test/decoder/localsTests/misc2.ts @@ -23,10 +23,10 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, const traceManager = new TraceManager({ web3 }) const codeManager = new CodeManager(traceManager) codeManager.clear() - const solidityProxy = new SolidityProxy({ - getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), + const solidityProxy = new SolidityProxy({ + getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), getCode: codeManager.getCode.bind(codeManager), - compilationResult: () => compilationResult + compilationResult: () => compilationResult }) const debuggerEvent = new EventManager() const offsetToLineColumnConverter = { @@ -51,7 +51,7 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, st.fail(e.message) } }) - + helper.decodeLocals(st, 7, traceManager, callTree, function (locals) { try { // st.equals(Object.keys(locals).length, 0) @@ -70,5 +70,5 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult, }) .catch(error => st.fail(error)) }) - }) + }) } diff --git a/libs/remix-debug/test/decoder/localsTests/structArray.ts b/libs/remix-debug/test/decoder/localsTests/structArray.ts index 6324377a48..4410711624 100644 --- a/libs/remix-debug/test/decoder/localsTests/structArray.ts +++ b/libs/remix-debug/test/decoder/localsTests/structArray.ts @@ -23,10 +23,10 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,c const traceManager = new TraceManager({ web3 }) const codeManager = new CodeManager(traceManager) codeManager.clear() - const solidityProxy = new SolidityProxy({ - getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), + const solidityProxy = new SolidityProxy({ + getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), getCode: codeManager.getCode.bind(codeManager), - compilationResult: () => compilationResult + compilationResult: () => compilationResult }) const debuggerEvent = new EventManager() const offsetToLineColumnConverter = { @@ -59,24 +59,24 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,c st.equals(locals['f'].raw, '0x746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f746573745f6c6f6e675f') st.equals(locals['f'].value, 'test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_test_long_') st.equals(locals['e'].value['e'].value, true) - + st.equals(locals['simpleArray'].value[0].value, '45') st.equals(locals['simpleArray'].value[1].value, '324324') st.equals(locals['simpleArray'].value[2].value, '-333') st.equals(locals['simpleArray'].value[3].value, '5656') st.equals(locals['simpleArray'].value[4].value, '-1111') - + st.equals(locals['stringArray'].value[0].value, 'long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_long_one_') st.equals(locals['stringArray'].value[1].value, 'two') st.equals(locals['stringArray'].value[2].value, 'three') - + st.equals(locals['dynArray'].value[0].value[0].value, '3423423532') st.equals(locals['dynArray'].value[1].value[0].value, '-342343323532') st.equals(locals['dynArray'].value[1].value[1].value, '23432') st.equals(locals['dynArray'].value[2].value[0].value, '-432432') st.equals(locals['dynArray'].value[2].value[1].value, '3423423532') st.equals(locals['dynArray'].value[2].value[2].value, '-432432') - + st.equals(locals['structArray'].value[0].value['a'].value, 'test') st.equals(locals['structArray'].value[0].value['a'].length, '0x8') st.equals(locals['structArray'].value[0].value['a'].raw, '0x74657374') @@ -86,31 +86,31 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,c st.equals(locals['structArray'].value[0].value['c'].value, 'test_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_testtest_long_test_long_test_long_test') st.equals(locals['structArray'].value[0].value['d'].value, '3') st.equals(locals['structArray'].value[0].value['e'].value, true) - + st.equals(locals['structArray'].value[1].value['a'].value, 'item1 a') st.equals(locals['structArray'].value[1].value['b'].value, '20') st.equals(locals['structArray'].value[1].value['c'].value, 'item1 c') st.equals(locals['structArray'].value[1].value['d'].value, '-45') st.equals(locals['structArray'].value[1].value['e'].value, false) - + st.equals(locals['structArray'].value[2].value['a'].value, 'item2 a') st.equals(locals['structArray'].value[2].value['b'].value, '200') st.equals(locals['structArray'].value[2].value['c'].value, 'item2 c') st.equals(locals['structArray'].value[2].value['d'].value, '-450') st.equals(locals['structArray'].value[2].value['e'].value, true) - + st.equals(locals['arrayStruct'].value.a.value[0].value, 'string') st.equals(locals['arrayStruct'].value.b.value[0].value, '34') st.equals(locals['arrayStruct'].value.b.value[1].value, '-23') st.equals(locals['arrayStruct'].value.b.value[2].value, '-3') st.equals(locals['arrayStruct'].value.c.value, 'three') - + st.equals(Object.keys(locals).length, 8) } catch (e) { st.fail(e.message) } }) - + helper.decodeLocals(st, 7, traceManager, callTree, function (locals) { try { console.log('at 7', locals) @@ -130,5 +130,5 @@ module.exports = function (st, privateKey, contractBytecode, compilationResult,c }) .catch(error => st.fail(error)) }) - }) + }) } diff --git a/libs/remix-debug/test/decoder/stateTests/mapping.ts b/libs/remix-debug/test/decoder/stateTests/mapping.ts index d13f4c36f5..3ca31823a5 100644 --- a/libs/remix-debug/test/decoder/stateTests/mapping.ts +++ b/libs/remix-debug/test/decoder/stateTests/mapping.ts @@ -10,7 +10,7 @@ import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree import * as vmCall from '../../vmCall' import { StorageResolver } from '../../../src/storage/storageResolver' import { StorageViewer } from '../../../src/storage/storageViewer' -import { Address, bytesToHex } from '@ethereumjs/util' +import { Address, bytesToHex } from '@ethereumjs/util' module.exports = async function testMappingStorage (st, cb) { const mappingStorage = require('../contracts/mappingStorage') @@ -23,7 +23,7 @@ module.exports = async function testMappingStorage (st, cb) { } const compilationResults = new CompilerAbstract('json', output, sources) const web3 = await (vmCall as any).getWeb3(); - (vmCall as any).sendTx(web3, {nonce: 0, privateKey: privateKey}, undefined, 0, output.contracts['test.sol']['SimpleMappingState'].evm.bytecode.object, function (error, hash) { + (vmCall as any).sendTx(web3, { nonce: 0, privateKey: privateKey }, undefined, 0, output.contracts['test.sol']['SimpleMappingState'].evm.bytecode.object, function (error, hash) { if (error) { console.log(error) st.end(error) @@ -44,7 +44,7 @@ module.exports = async function testMappingStorage (st, cb) { } function testMapping (st, privateKey, contractAddress, output, compilationResults, web3, cb) { - (vmCall as any).sendTx(web3, {nonce: 1, privateKey: privateKey}, contractAddress, 0, '2fd0a83a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001074686973206973206120737472696e6700000000000000000000000000000000', + (vmCall as any).sendTx(web3, { nonce: 1, privateKey: privateKey }, contractAddress, 0, '2fd0a83a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001074686973206973206120737472696e6700000000000000000000000000000000', function (error, hash) { if (error) { console.log(error) @@ -74,7 +74,7 @@ function testMapping (st, privateKey, contractAddress, output, compilationResult stepIndex: 268, tx: tx, address: contractAddress - }, new StorageResolver({web3}), traceManager) + }, new StorageResolver({ web3 }), traceManager) const stateVars = stateDecoder.extractStateVariables('SimpleMappingState', output.sources) stateDecoder.decodeState(stateVars, storageViewer).then((result) => { st.equal(result['_num'].value, '1') diff --git a/libs/remix-debug/test/helpers/compilerHelper.ts b/libs/remix-debug/test/helpers/compilerHelper.ts index 542d10a1b9..1681520c95 100644 --- a/libs/remix-debug/test/helpers/compilerHelper.ts +++ b/libs/remix-debug/test/helpers/compilerHelper.ts @@ -13,8 +13,8 @@ export function compilerInput (contracts) { }, outputSelection: { '*': { - '': [ 'ast' ], - '*': [ 'abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ] + '': ['ast'], + '*': ['abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates'] } } } diff --git a/libs/remix-debug/test/resources/ast.ts b/libs/remix-debug/test/resources/ast.ts index f4ca65f47e..00a96493dc 100644 --- a/libs/remix-debug/test/resources/ast.ts +++ b/libs/remix-debug/test/resources/ast.ts @@ -1,14 +1,14 @@ const node = {} -node['ast'] = {"legacyAST":{"children":[{"attributes":{"fullyImplemented":true,"isLibrary":false,"linearizedBaseContracts":[5640396],"name":"test"},"children":[{"attributes":{"name":"x","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5657860,"name":"ElementaryTypeName","src":"21:3:11"}],"id":5658100,"name":"VariableDeclaration","src":"21:5:11"},{"attributes":{"name":"y","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5658180,"name":"ElementaryTypeName","src":"38:3:11"}],"id":5658268,"name":"VariableDeclaration","src":"38:5:11"},{"attributes":{"constant":false,"name":"set","public":true},"children":[{"children":[{"attributes":{"name":"_x","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5658404,"name":"ElementaryTypeName","src":"68:3:11"}],"id":5658492,"name":"VariableDeclaration","src":"68:6:11"}],"id":5658572,"name":"ParameterList","src":"67:8:11"},{"children":[{"attributes":{"name":"_r","type":"int256"},"children":[{"attributes":{"name":"int"},"id":5658628,"name":"ElementaryTypeName","src":"85:3:11"}],"id":5658716,"name":"VariableDeclaration","src":"85:6:11"}],"id":5658796,"name":"ParameterList","src":"84:8:11"},{"children":[{"children":[{"attributes":{"operator":"=","type":"int256"},"children":[{"attributes":{"type":"int256","value":"x"},"id":5658900,"name":"Identifier","src":"108:1:11"},{"attributes":{"type":"int256","value":"_x"},"id":5658980,"name":"Identifier","src":"112:2:11"}],"id":5657492,"name":"Assignment","src":"108:6:11"}],"id":5659028,"name":"ExpressionStatement","src":"108:6:11"},{"children":[{"attributes":{"operator":"=","type":"int256"},"children":[{"attributes":{"type":"int256","value":"y"},"id":5659116,"name":"Identifier","src":"125:1:11"},{"attributes":{"string":null,"type":"int_const 10","value":"10"},"id":5659196,"name":"Literal","src":"129:2:11"}],"id":5659252,"name":"Assignment","src":"125:6:11"}],"id":5659316,"name":"ExpressionStatement","src":"125:6:11"},{"children":[{"attributes":{"operator":"=","type":"int256"},"children":[{"attributes":{"type":"int256","value":"_r"},"id":5659428,"name":"Identifier","src":"141:2:11"},{"attributes":{"type":"int256","value":"x"},"id":5639308,"name":"Identifier","src":"146:1:11"}],"id":5639356,"name":"Assignment","src":"141:6:11"}],"id":5639420,"name":"ExpressionStatement","src":"141:6:11"}],"id":5639516,"name":"Block","src":"97:57:11"}],"id":5639612,"name":"FunctionDefinition","src":"55:99:11"},{"attributes":{"constant":false,"name":"get","public":true},"children":[{"children":[],"id":5639764,"name":"ParameterList","src":"179:2:11"},{"children":[{"attributes":{"name":"x","type":"uint256"},"children":[{"attributes":{"name":"uint"},"id":5639820,"name":"ElementaryTypeName","src":"191:4:11"}],"id":5639908,"name":"VariableDeclaration","src":"191:6:11"},{"attributes":{"name":"y","type":"uint256"},"children":[{"attributes":{"name":"uint"},"id":5639988,"name":"ElementaryTypeName","src":"199:4:11"}],"id":5640076,"name":"VariableDeclaration","src":"199:6:11"}],"id":5640156,"name":"ParameterList","src":"190:16:11"},{"children":[],"id":5640212,"name":"Block","src":"212:17:11"}],"id":5640276,"name":"FunctionDefinition","src":"167:62:11"}],"id":5640396,"name":"ContractDefinition","src":"0:231:11"}],"name":"SourceUnit"}} +node['ast'] = { "legacyAST":{ "children":[{ "attributes":{ "fullyImplemented":true,"isLibrary":false,"linearizedBaseContracts":[5640396],"name":"test" },"children":[{ "attributes":{ "name":"x","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5657860,"name":"ElementaryTypeName","src":"21:3:11" }],"id":5658100,"name":"VariableDeclaration","src":"21:5:11" },{ "attributes":{ "name":"y","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5658180,"name":"ElementaryTypeName","src":"38:3:11" }],"id":5658268,"name":"VariableDeclaration","src":"38:5:11" },{ "attributes":{ "constant":false,"name":"set","public":true },"children":[{ "children":[{ "attributes":{ "name":"_x","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5658404,"name":"ElementaryTypeName","src":"68:3:11" }],"id":5658492,"name":"VariableDeclaration","src":"68:6:11" }],"id":5658572,"name":"ParameterList","src":"67:8:11" },{ "children":[{ "attributes":{ "name":"_r","type":"int256" },"children":[{ "attributes":{ "name":"int" },"id":5658628,"name":"ElementaryTypeName","src":"85:3:11" }],"id":5658716,"name":"VariableDeclaration","src":"85:6:11" }],"id":5658796,"name":"ParameterList","src":"84:8:11" },{ "children":[{ "children":[{ "attributes":{ "operator":"=","type":"int256" },"children":[{ "attributes":{ "type":"int256","value":"x" },"id":5658900,"name":"Identifier","src":"108:1:11" },{ "attributes":{ "type":"int256","value":"_x" },"id":5658980,"name":"Identifier","src":"112:2:11" }],"id":5657492,"name":"Assignment","src":"108:6:11" }],"id":5659028,"name":"ExpressionStatement","src":"108:6:11" },{ "children":[{ "attributes":{ "operator":"=","type":"int256" },"children":[{ "attributes":{ "type":"int256","value":"y" },"id":5659116,"name":"Identifier","src":"125:1:11" },{ "attributes":{ "string":null,"type":"int_const 10","value":"10" },"id":5659196,"name":"Literal","src":"129:2:11" }],"id":5659252,"name":"Assignment","src":"125:6:11" }],"id":5659316,"name":"ExpressionStatement","src":"125:6:11" },{ "children":[{ "attributes":{ "operator":"=","type":"int256" },"children":[{ "attributes":{ "type":"int256","value":"_r" },"id":5659428,"name":"Identifier","src":"141:2:11" },{ "attributes":{ "type":"int256","value":"x" },"id":5639308,"name":"Identifier","src":"146:1:11" }],"id":5639356,"name":"Assignment","src":"141:6:11" }],"id":5639420,"name":"ExpressionStatement","src":"141:6:11" }],"id":5639516,"name":"Block","src":"97:57:11" }],"id":5639612,"name":"FunctionDefinition","src":"55:99:11" },{ "attributes":{ "constant":false,"name":"get","public":true },"children":[{ "children":[],"id":5639764,"name":"ParameterList","src":"179:2:11" },{ "children":[{ "attributes":{ "name":"x","type":"uint256" },"children":[{ "attributes":{ "name":"uint" },"id":5639820,"name":"ElementaryTypeName","src":"191:4:11" }],"id":5639908,"name":"VariableDeclaration","src":"191:6:11" },{ "attributes":{ "name":"y","type":"uint256" },"children":[{ "attributes":{ "name":"uint" },"id":5639988,"name":"ElementaryTypeName","src":"199:4:11" }],"id":5640076,"name":"VariableDeclaration","src":"199:6:11" }],"id":5640156,"name":"ParameterList","src":"190:16:11" },{ "children":[],"id":5640212,"name":"Block","src":"212:17:11" }],"id":5640276,"name":"FunctionDefinition","src":"167:62:11" }],"id":5640396,"name":"ContractDefinition","src":"0:231:11" }],"name":"SourceUnit" } } -node['ast'].ast = { +node['ast'].ast = { absolutePath: 'sample.sol', - exportedSymbols: { test: [ 33 ] }, + exportedSymbols: { test: [33]}, id: 34, nodeType: 'SourceUnit', nodes: - [ { + [{ abstract: false, baseContracts: [], contractDependencies: [], @@ -16,11 +16,11 @@ node['ast'].ast = { documentation: null, fullyImplemented: true, id: 33, - linearizedBaseContracts: [ 33 ], + linearizedBaseContracts: [33], name: 'test', nodeType: 'ContractDefinition', nodes: - [ { constant: false, + [{ constant: false, id: 2, name: 'x', nodeType: 'VariableDeclaration', @@ -30,12 +30,12 @@ node['ast'].ast = { stateVariable: true, storageLocation: 'default', typeDescriptions: { typeIdentifier: 't_int256', typeString: 'int256' }, - typeName: { + typeName: { id: 1, name: 'int', nodeType: 'ElementaryTypeName', src: '20:3:0', - typeDescriptions: [Object] + typeDescriptions: [Object] }, value: null, visibility: 'internal' }, @@ -54,14 +54,14 @@ node['ast'].ast = { name: 'int', nodeType: 'ElementaryTypeName', src: '31:3:0', - typeDescriptions: [Object] }, + typeDescriptions: [Object]}, value: null, visibility: 'internal' }, { body: { id: 23, nodeType: 'Block', src: '96:55:0', statements: - [ { expression: + [{ expression: { argumentTypes: null, id: 13, isConstant: false, @@ -69,7 +69,7 @@ node['ast'].ast = { isPure: false, lValueRequested: false, leftHandSide: - { argumentTypes: null, + { argumentTypes: null, id: 11, name: 'x', nodeType: 'Identifier', @@ -89,7 +89,7 @@ node['ast'].ast = { src: '110:2:0', typeDescriptions: { typeIdentifier: 't_int256', typeString: 'int256' } }, src: '106:6:0', - typeDescriptions: { typeIdentifier: 't_int256', typeString: 'int256' } + typeDescriptions: { typeIdentifier: 't_int256', typeString: 'int256' } }, id: 14, nodeType: 'ExpressionStatement', @@ -106,7 +106,7 @@ node['ast'].ast = { operator: '=', rightHandSide: [Object], src: '122:6:0', - typeDescriptions: [Object] }, + typeDescriptions: [Object]}, id: 18, nodeType: 'ExpressionStatement', src: '122:6:0' }, @@ -122,10 +122,10 @@ node['ast'].ast = { operator: '=', rightHandSide: [Object], src: '138:6:0', - typeDescriptions: [Object] }, + typeDescriptions: [Object]}, id: 22, nodeType: 'ExpressionStatement', - src: '138:6:0' } ] + src: '138:6:0' }] }, documentation: null, functionSelector: 'e5c19b2d', @@ -149,7 +149,7 @@ node['ast'].ast = { stateMutability: 'nonpayable', virtual: false, visibility: 'public' }, - { body: { id: 31, nodeType: 'Block', src: '214:17:0', statements: [] }, + { body: { id: 31, nodeType: 'Block', src: '214:17:0', statements: []}, documentation: null, functionSelector: '6d4ce63c', id: 32, @@ -173,13 +173,12 @@ node['ast'].ast = { src: '163:68:0', stateMutability: 'nonpayable', virtual: false, - visibility: 'public' } ], + visibility: 'public' }], scope: 34, - src: '0:233:0' - } ], - src: '0:233:0' + src: '0:233:0' + }], + src: '0:233:0' } - node['source'] = `contract test { int x; diff --git a/libs/remix-debug/test/resources/testWeb3.ts b/libs/remix-debug/test/resources/testWeb3.ts index e91f584fd4..60bf50eae6 100644 --- a/libs/remix-debug/test/resources/testWeb3.ts +++ b/libs/remix-debug/test/resources/testWeb3.ts @@ -7,7 +7,7 @@ let data = init.readFile(require('path').resolve(__dirname, 'testWeb3.json'), nu data = JSON.parse(data) let traceWithABIEncoder = init.readFile(require('path').resolve(__dirname, 'traceWithABIEncoder.json'), null) -traceWithABIEncoder = +traceWithABIEncoder = data.testTraces['0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd53'] = JSON.parse(traceWithABIEncoder) web3Override.eth.getCode = function (address, callback) { @@ -48,7 +48,7 @@ web3Override.eth.setProvider = function (provider) {} web3Override.eth.providers = { 'HttpProvider': function (url) {} } -web3Override.eth.currentProvider = {'host': 'test provider'} +web3Override.eth.currentProvider = { 'host': 'test provider' } if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') { module.exports = web3Override diff --git a/libs/remix-debug/test/sourceLocationTracker.ts b/libs/remix-debug/test/sourceLocationTracker.ts index 2b5ad856f9..88a5b7977b 100644 --- a/libs/remix-debug/test/sourceLocationTracker.ts +++ b/libs/remix-debug/test/sourceLocationTracker.ts @@ -11,20 +11,20 @@ import { compilerInput } from './helpers/compilerHelper' tape('SourceLocationTracker', function (t) { t.test('SourceLocationTracker.getSourceLocationFromVMTraceIndex - simple contract', async function (st) { - const traceManager = new TraceManager({web3: web3Test}) - const codeManager = new CodeManager(traceManager) + const traceManager = new TraceManager({ web3: web3Test }) + const codeManager = new CodeManager(traceManager) let output = compiler.compile(compilerInput(contracts)) output = JSON.parse(output) - + codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', '0x' + output.contracts['test.sol']['test'].evm.deployedBytecode.object) - + const tx = web3Test.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd52') - traceManager.resolveTrace(tx).then(async () => { + traceManager.resolveTrace(tx).then(async () => { + + const sourceLocationTracker = new SourceLocationTracker(codeManager, { debugWithGeneratedSources: false }) - const sourceLocationTracker = new SourceLocationTracker(codeManager, {debugWithGeneratedSources: false}) - try { const map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 0, output.contracts) st.equal(map['file'], 0) @@ -42,20 +42,18 @@ tape('SourceLocationTracker', function (t) { t.test('SourceLocationTracker.getSourceLocationFromVMTraceIndex - ABIEncoder V2 contract', async function (st) { - const traceManager = new TraceManager({web3: web3Test}) - const codeManager = new CodeManager(traceManager) + const traceManager = new TraceManager({ web3: web3Test }) + const codeManager = new CodeManager(traceManager) let output = compiler.compile(compilerInput(ABIEncoderV2)) output = JSON.parse(output) - + codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', '0x' + output.contracts['test.sol']['test'].evm.deployedBytecode.object) - + const tx = web3Test.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd53') - traceManager.resolveTrace(tx).then(async () => { + traceManager.resolveTrace(tx).then(async () => { - - try { // with debugWithGeneratedSources: false const sourceLocationTracker = new SourceLocationTracker(codeManager, { debugWithGeneratedSources: false }) @@ -67,7 +65,7 @@ tape('SourceLocationTracker', function (t) { map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 45, output.contracts) st.equal(map['file'], 1) // 1 refers to the generated source (pragma experimental ABIEncoderV2) - + map = await sourceLocationTracker.getValidSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 45, output.contracts) st.equal(map['file'], 0) // 1 refers to the generated source (pragma experimental ABIEncoderV2) st.equal(map['start'], 303) @@ -84,7 +82,7 @@ tape('SourceLocationTracker', function (t) { try { // with debugWithGeneratedSources: true const sourceLocationTracker = new SourceLocationTracker(codeManager, { debugWithGeneratedSources: true }) - + let map = await sourceLocationTracker.getSourceLocationFromVMTraceIndex('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', 0, output.contracts) console.log(map) st.equal(map['file'], 0) diff --git a/libs/remix-debug/test/traceManager.ts b/libs/remix-debug/test/traceManager.ts index 8128e21ac8..523d0d4927 100644 --- a/libs/remix-debug/test/traceManager.ts +++ b/libs/remix-debug/test/traceManager.ts @@ -7,7 +7,7 @@ tape('TraceManager', function (t) { let traceManager t.test('TraceManager.init', function (st) { - traceManager = new TraceManager({web3: web3Test}) + traceManager = new TraceManager({ web3: web3Test }) st.end() }) diff --git a/libs/remix-debug/test/vmCall.ts b/libs/remix-debug/test/vmCall.ts index e9d6e28012..0866b065e6 100644 --- a/libs/remix-debug/test/vmCall.ts +++ b/libs/remix-debug/test/vmCall.ts @@ -1,10 +1,9 @@ 'use strict' -import { extendWeb3 } from '../src/init' +import { extendWeb3 } from '../src/init' import { Address } from '@ethereumjs/util' import { Web3 } from 'web3'; const { Provider } = require('@remix-project/remix-simulator') - async function getWeb3 () { const remixSimulatorProvider = new Provider({ fork: 'berlin' }) await remixSimulatorProvider.init() From 47624a555ea10e65805d1d748c68e0960915b5e6 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 14:05:53 +0200 Subject: [PATCH 11/31] fixib linting for solidity-compiler --- apps/solidity-compiler/src/app/compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index 9915d473b4..d86d5322cb 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -22,7 +22,7 @@ export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements this.compileTabLogic = new CompileTabLogic(this, this.contentImport) this.compiler = this.compileTabLogic.compiler this.compileTabLogic.init() - this.initCompilerApi() + this.initCompilerApi() } getCompilerQueryParameters () { From e5be10a5d324ad242270d6cd79be3f69d8895c1b Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 14:07:10 +0200 Subject: [PATCH 12/31] fix linting for circuit-compiler --- apps/circuit-compiler/src/app/contexts/index.ts | 4 ++-- apps/circuit-compiler/src/app/reducers/state.ts | 2 +- .../src/app/services/circomPluginClient.ts | 10 +++++----- apps/circuit-compiler/src/app/types/index.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/circuit-compiler/src/app/contexts/index.ts b/apps/circuit-compiler/src/app/contexts/index.ts index 45fe6d3aeb..8c84ae6b14 100644 --- a/apps/circuit-compiler/src/app/contexts/index.ts +++ b/apps/circuit-compiler/src/app/contexts/index.ts @@ -1,4 +1,4 @@ -import {createContext} from 'react' -import {ICircuitAppContext} from '../types' +import { createContext } from 'react' +import { ICircuitAppContext } from '../types' export const CircuitAppContext = createContext({} as ICircuitAppContext) diff --git a/apps/circuit-compiler/src/app/reducers/state.ts b/apps/circuit-compiler/src/app/reducers/state.ts index 6e1c21cd9a..e63b5e5a2a 100644 --- a/apps/circuit-compiler/src/app/reducers/state.ts +++ b/apps/circuit-compiler/src/app/reducers/state.ts @@ -1,4 +1,4 @@ -import {Actions, AppState} from '../types' +import { Actions, AppState } from '../types' import { compiler_list } from 'circom_wasm' export const appInitialState: AppState = { diff --git a/apps/circuit-compiler/src/app/services/circomPluginClient.ts b/apps/circuit-compiler/src/app/services/circomPluginClient.ts index 8ba5bb4672..44d69b9314 100644 --- a/apps/circuit-compiler/src/app/services/circomPluginClient.ts +++ b/apps/circuit-compiler/src/app/services/circomPluginClient.ts @@ -163,7 +163,7 @@ export class CircomPluginClient extends PluginClient { } else { this.lastCompiledFile = path const fileName = extractNameFromKey(path) - + this.lastCompiledCircuitPath = extractParentFromKey(path) + "/.bin/" + fileName.replace('circom', 'wasm') // @ts-ignore await this.call('fileManager', 'writeFile', this.lastCompiledCircuitPath, circuitProgram, { encoding: null }) @@ -179,7 +179,7 @@ export class CircomPluginClient extends PluginClient { this.internalEvents.emit('circuit_compiling_done', []) } circuitApi.log().map(log => { - log && this.call('terminal', 'log', { type: 'log', value: log }) + log && this.call('terminal', 'log', { type: 'log', value: log }) }) // @ts-ignore this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay' }) @@ -222,11 +222,11 @@ export class CircomPluginClient extends PluginClient { this.internalEvents.emit('circuit_generating_r1cs_done') const fileName = extractNameFromKey(path) const writePath = extractParentFromKey(path) + "/.bin/" + fileName.replace('circom', 'r1cs') - + // @ts-ignore await this.call('fileManager', 'writeFile', writePath, r1csProgram, true) r1csApi.log().map(log => { - log && this.call('terminal', 'log', { type: 'log', value: log }) + log && this.call('terminal', 'log', { type: 'log', value: log }) }) // @ts-ignore this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay' }) @@ -339,7 +339,7 @@ export class CircomPluginClient extends PluginClient { absFilePath = include.startsWith('circomlib') ? absFilePath.substring(1) : absFilePath if (!blackPath.includes(absFilePath)) { - if(!includeName.startsWith('circomlib')) { + if (!includeName.startsWith('circomlib')) { dependencyContent = dependencyContent.replace(`${includeName}`, `${absFilePath}`) return absFilePath } diff --git a/apps/circuit-compiler/src/app/types/index.ts b/apps/circuit-compiler/src/app/types/index.ts index fc78c3a237..64f3b3281f 100644 --- a/apps/circuit-compiler/src/app/types/index.ts +++ b/apps/circuit-compiler/src/app/types/index.ts @@ -1,5 +1,5 @@ import { compiler_list } from 'circom_wasm' -import {Dispatch} from 'react' +import { Dispatch } from 'react' import type { CircomPluginClient } from '../services/circomPluginClient' export type CompilerStatus = "compiling" | "generating" | "computing" | "idle" | "errored" | "warning" From 866e58c0997536e371119761cceb713eeb81407f Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 14:08:40 +0200 Subject: [PATCH 13/31] fixing linting for doc-gen --- apps/doc-gen/src/app/docgen-client.ts | 6 +- .../src/app/docgen/common/properties.ts | 72 +++++++++---------- apps/doc-gen/src/app/docgen/templates.ts | 7 +- .../src/app/docgen/utils/memoized-getter.ts | 18 ++--- apps/doc-gen/src/app/docgen/utils/natspec.ts | 8 +-- .../app/docgen/utils/normalizeContractPath.ts | 2 +- 6 files changed, 56 insertions(+), 57 deletions(-) diff --git a/apps/doc-gen/src/app/docgen-client.ts b/apps/doc-gen/src/app/docgen-client.ts index ee06c3237f..c3801ecf81 100644 --- a/apps/doc-gen/src/app/docgen-client.ts +++ b/apps/doc-gen/src/app/docgen-client.ts @@ -17,7 +17,7 @@ export class DocGenClient extends PluginClient { public docs: string[] = [] private fileName: string = '' private contractPath: string = '' - + constructor() { super() this.eventEmitter = new EventEmitter() @@ -30,7 +30,7 @@ export class DocGenClient extends PluginClient { async setListeners() { this.currentTheme = await this.call('theme', 'currentTheme') - + this.on('theme', 'themeChanged', (theme: any) => { this.currentTheme = theme this.eventEmitter.emit('themeChanged', this.currentTheme) @@ -50,7 +50,7 @@ export class DocGenClient extends PluginClient { } const segmentedPathList = normalizeContractPath(fileName) this.fileName = segmentedPathList[segmentedPathList.length - 1] - this.contractPath = segmentedPathList[0] + this.contractPath = segmentedPathList[0] this.eventEmitter.emit('compilationFinished', this.build, this.fileName) }) } diff --git a/apps/doc-gen/src/app/docgen/common/properties.ts b/apps/doc-gen/src/app/docgen/common/properties.ts index 5366e8d7ef..f3e197953e 100644 --- a/apps/doc-gen/src/app/docgen/common/properties.ts +++ b/apps/doc-gen/src/app/docgen/common/properties.ts @@ -36,47 +36,47 @@ export function fullName ({ item, contract }: DocItemContext): string { export function signature ({ item }: DocItemContext): string | undefined { switch (item.nodeType) { - case 'ContractDefinition': - return undefined; - - case 'FunctionDefinition': { - const { kind, name } = item; - const params = item.parameters.parameters; - const returns = item.returnParameters.parameters; - const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind; - const res = [ - `${head}(${params.map(formatVariable).join(', ')})`, - item.visibility, - ]; - if (item.stateMutability !== 'nonpayable') { - res.push(item.stateMutability); - } - if (item.virtual) { - res.push('virtual'); - } - if (returns.length > 0) { - res.push(`returns (${returns.map(formatVariable).join(', ')})`); - } - return res.join(' '); + case 'ContractDefinition': + return undefined; + + case 'FunctionDefinition': { + const { kind, name } = item; + const params = item.parameters.parameters; + const returns = item.returnParameters.parameters; + const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind; + const res = [ + `${head}(${params.map(formatVariable).join(', ')})`, + item.visibility, + ]; + if (item.stateMutability !== 'nonpayable') { + res.push(item.stateMutability); } - - case 'EventDefinition': { - const params = item.parameters.parameters; - return `event ${item.name}(${params.map(formatVariable).join(', ')})`; + if (item.virtual) { + res.push('virtual'); } - - case 'ErrorDefinition': { - const params = item.parameters.parameters; - return `error ${item.name}(${params.map(formatVariable).join(', ')})`; + if (returns.length > 0) { + res.push(`returns (${returns.map(formatVariable).join(', ')})`); } + return res.join(' '); + } - case 'ModifierDefinition': { - const params = item.parameters.parameters; - return `modifier ${item.name}(${params.map(formatVariable).join(', ')})`; - } + case 'EventDefinition': { + const params = item.parameters.parameters; + return `event ${item.name}(${params.map(formatVariable).join(', ')})`; + } + + case 'ErrorDefinition': { + const params = item.parameters.parameters; + return `error ${item.name}(${params.map(formatVariable).join(', ')})`; + } + + case 'ModifierDefinition': { + const params = item.parameters.parameters; + return `modifier ${item.name}(${params.map(formatVariable).join(', ')})`; + } - case 'VariableDeclaration': - return formatVariable(item); + case 'VariableDeclaration': + return formatVariable(item); } } diff --git a/apps/doc-gen/src/app/docgen/templates.ts b/apps/doc-gen/src/app/docgen/templates.ts index b83d0ac77d..34ee88df38 100644 --- a/apps/doc-gen/src/app/docgen/templates.ts +++ b/apps/doc-gen/src/app/docgen/templates.ts @@ -3,7 +3,7 @@ import { mapKeys } from './utils/map-keys'; import { DocItemContext } from './site'; import * as defaultProperties from './common/properties'; -import * as themeHelpers from './themes/markdown/helpers' +import * as themeHelpers from './themes/markdown/helpers' const common = require('./themes/markdown/common.hbs'); const contract = require('./themes/markdown/contract.hbs'); @@ -45,7 +45,6 @@ export async function loadTemplates(defaultTheme: string, root: string, userTemp properties: { ...defaultProperties }, }; - // Add partials and helpers from all themes, prefixed with the theme name. for (const [themeName, theme] of Object.entries(themes)) { const addPrefix = (k: string) => `${themeName}/${k}`; @@ -86,7 +85,7 @@ async function readPartials() { } async function readHelpers(name: string) { - + const helpers: Record any> = {}; for (const name in themeHelpers) { @@ -94,7 +93,7 @@ async function readHelpers(name: string) { helpers[name] = themeHelpers[name]; } } - + return helpers; } diff --git a/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts b/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts index 1a2fef4ae5..d4814e1da2 100644 --- a/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts +++ b/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts @@ -6,17 +6,17 @@ export function defineGetterMemoized Date: Mon, 29 Apr 2024 17:09:02 +0200 Subject: [PATCH 14/31] lint fixes for remix-ui --- .../app/src/lib/remix-app/actions/modals.ts | 2 +- .../remix-app/components/dragbar/dragbar.tsx | 4 +- .../components/modals/dialogViewPlugin.tsx | 10 +- .../remix-app/components/modals/dialogs.tsx | 8 +- .../lib/remix-app/components/modals/enter.tsx | 20 +- .../remix-app/components/modals/matomo.tsx | 12 +- .../components/modals/modal-wrapper.tsx | 14 +- .../components/modals/origin-warning.tsx | 10 +- .../lib/remix-app/components/splashscreen.tsx | 2 +- .../app/src/lib/remix-app/context/context.tsx | 6 +- .../src/lib/remix-app/context/provider.tsx | 34 +- .../app/src/lib/remix-app/interface/index.ts | 2 +- .../app/src/lib/remix-app/reducer/modals.ts | 2 +- .../checkbox/src/lib/remix-ui-checkbox.tsx | 12 +- .../copy-to-clipboard/copy-to-clipboard.tsx | 10 +- .../debugger-ui/src/hooks/extract-data.tsx | 4 +- .../debugger-ui/src/lib/api/debugger-api.ts | 4 +- .../lib/button-navigator/button-navigator.tsx | 32 +- .../debugger-ui/src/lib/debugger-ui.tsx | 26 +- .../debugger-ui/src/lib/slider/slider.tsx | 2 +- .../src/lib/step-manager/step-manager.tsx | 6 +- .../src/lib/tx-browser/tx-browser.tsx | 12 +- .../src/lib/vm-debugger/assembly-items.tsx | 8 +- .../src/lib/vm-debugger/calldata-panel.tsx | 2 +- .../src/lib/vm-debugger/callstack-panel.tsx | 2 +- .../src/lib/vm-debugger/code-list-view.tsx | 2 +- .../src/lib/vm-debugger/dropdown-panel.tsx | 30 +- .../lib/vm-debugger/full-storages-changes.tsx | 2 +- .../src/lib/vm-debugger/function-panel.tsx | 4 +- .../src/lib/vm-debugger/global-variables.tsx | 4 +- .../src/lib/vm-debugger/memory-panel.tsx | 4 +- .../src/lib/vm-debugger/solidity-locals.tsx | 6 +- .../src/lib/vm-debugger/solidity-state.tsx | 8 +- .../src/lib/vm-debugger/stack-panel.tsx | 4 +- .../src/lib/vm-debugger/step-detail.tsx | 2 +- .../src/lib/vm-debugger/storage-panel.tsx | 2 +- .../src/lib/vm-debugger/vm-debugger-head.tsx | 26 +- .../src/lib/vm-debugger/vm-debugger.tsx | 4 +- .../drag-n-drop/src/lib/drag-n-drop.tsx | 10 +- .../remix-ui/editor/src/lib/actions/editor.ts | 2 +- .../src/lib/hardhat-ethers-extension.ts | 2 +- .../src/lib/providers/codeActionProvider.ts | 12 +- .../providers/completion/completionGlobals.ts | 4 - .../src/lib/providers/completionProvider.ts | 12 +- .../src/lib/providers/definitionProvider.ts | 2 +- .../editor/src/lib/providers/hoverProvider.ts | 4 +- .../lib/providers/inlineCompletionProvider.ts | 27 +- .../editor/src/lib/remix-ui-editor.tsx | 64 ++-- libs/remix-ui/editor/src/lib/syntaxes/move.ts | 2 +- libs/remix-ui/editor/src/lib/web-types.ts | 2 +- .../lib/components/file-decoration-icon.tsx | 4 +- .../file-decoration-custom-icon.tsx | 2 +- .../file-decoration-error-icon.tsx | 2 +- .../file-decoration-tooltip.tsx | 6 +- .../file-decoration-warning-icon.tsx | 2 +- .../file-decorators/src/lib/helper/index.tsx | 2 +- .../src/lib/components/customCheckbox.tsx | 2 +- .../grid-view/src/lib/remix-ui-grid-cell.tsx | 13 +- .../grid-view/src/lib/remix-ui-grid-view.tsx | 14 +- libs/remix-ui/helper/src/lib/bleach.ts | 4 +- .../src/lib/components/PluginViewWrapper.tsx | 2 +- .../src/lib/components/custom-dropdown.tsx | 14 +- .../helper/src/lib/components/web3Dialog.tsx | 2 +- .../helper/src/lib/helper-components.tsx | 4 +- .../helper/src/lib/remix-ui-helper.ts | 4 +- .../src/lib/components/customNavButtons.tsx | 4 +- .../src/lib/components/homeTabFeatured.tsx | 52 ++-- .../lib/components/homeTabFeaturedPlugins.tsx | 22 +- .../src/lib/components/homeTabFile.tsx | 6 +- .../src/lib/components/homeTabGetStarted.tsx | 23 +- .../src/lib/components/homeTabLearn.tsx | 34 +- .../src/lib/components/homeTabScamAlert.tsx | 6 +- .../src/lib/components/homeTabTitle.tsx | 16 +- .../src/lib/components/homeTablangOptions.tsx | 8 +- .../src/lib/components/pluginButton.tsx | 12 +- .../src/lib/components/workspaceTemplate.tsx | 12 +- .../home-tab/src/lib/remix-ui-home-tab.tsx | 8 +- .../src/lib/remix-ui-modal-dialog.tsx | 8 +- .../panel/src/lib/dragbar/dragbar.tsx | 4 +- .../panel/src/lib/main/main-panel.tsx | 4 +- .../panel/src/lib/plugins/panel-header.tsx | 6 +- .../panel/src/lib/plugins/panel-plugin.tsx | 2 +- .../panel/src/lib/plugins/remix-ui-panel.tsx | 2 +- .../src/lib/permission-dialog.tsx | 10 +- .../src/lib/components/ActivePluginCard.tsx | 8 +- .../components/ActivePluginCardContainer.tsx | 14 +- .../src/lib/components/InactivePluginCard.tsx | 20 +- .../InactivePluginCardContainer.tsx | 10 +- .../src/lib/components/LocalPluginForm.tsx | 28 +- .../src/lib/components/moduleHeading.tsx | 4 +- .../lib/components/permissionsSettings.tsx | 18 +- .../src/lib/components/rootView.tsx | 12 +- .../src/lib/remix-ui-plugin-manager.tsx | 8 +- .../src/lib/publish-to-storage.tsx | 30 +- .../src/lib/publishOnSwarm.tsx | 10 +- .../src/lib/publishToIPFS.tsx | 8 +- libs/remix-ui/renderer/src/lib/renderer.tsx | 16 +- .../run-tab/src/lib/actions/account.ts | 5 +- .../run-tab/src/lib/actions/deploy.ts | 14 +- .../run-tab/src/lib/actions/events.ts | 19 +- .../remix-ui/run-tab/src/lib/actions/index.ts | 6 +- .../run-tab/src/lib/actions/payload.ts | 4 +- .../run-tab/src/lib/components/account.tsx | 78 ++--- .../src/lib/components/contractDropdownUI.tsx | 2 +- .../src/lib/components/contractGUI.tsx | 48 +-- .../src/lib/components/deployButton.tsx | 16 +- .../src/lib/components/deployInput.tsx | 8 +- .../src/lib/components/environment.tsx | 16 +- .../run-tab/src/lib/components/gasLimit.tsx | 12 +- .../lib/components/instanceContainerUI.tsx | 6 +- .../run-tab/src/lib/components/mainnet.tsx | 32 +- .../src/lib/components/multiDeployInput.tsx | 12 +- .../run-tab/src/lib/components/network.tsx | 2 +- .../run-tab/src/lib/components/passphrase.tsx | 2 +- .../src/lib/components/recorderCardUI.tsx | 24 +- .../run-tab/src/lib/components/scenario.tsx | 2 +- .../run-tab/src/lib/components/settingsUI.tsx | 12 +- .../src/lib/components/universalDappUI.tsx | 58 ++-- .../run-tab/src/lib/components/value.tsx | 12 +- .../run-tab/src/lib/reducers/runTab.ts | 4 +- libs/remix-ui/run-tab/src/lib/run-tab.tsx | 40 +-- .../search/src/lib/components/Exclude.tsx | 10 +- .../search/src/lib/components/Find.tsx | 10 +- .../src/lib/components/FindContainer.tsx | 16 +- .../search/src/lib/components/Include.tsx | 10 +- .../src/lib/components/OverWriteCheck.tsx | 8 +- .../search/src/lib/components/Replace.tsx | 10 +- .../search/src/lib/components/Search.tsx | 14 +- .../search/src/lib/components/StopSearch.tsx | 8 +- .../search/src/lib/components/Undo.tsx | 14 +- .../lib/components/results/ResultFileName.tsx | 6 +- .../src/lib/components/results/ResultItem.tsx | 26 +- .../lib/components/results/ResultSummary.tsx | 24 +- .../src/lib/components/results/Results.tsx | 16 +- .../lib/components/results/SearchHelper.ts | 5 +- .../search/src/lib/context/context.tsx | 8 +- .../search/src/lib/reducers/Reducer.ts | 14 +- libs/remix-ui/search/src/lib/types/index.ts | 2 - .../settings/src/lib/etherscan-settings.tsx | 16 +- .../settings/src/lib/github-settings.tsx | 16 +- .../settings/src/lib/remix-ui-settings.tsx | 48 +-- .../settings/src/lib/settingsReducer.ts | 4 +- .../settings/src/lib/sindri-settings.tsx | 16 +- .../src/lib/components/solidityCompile.tsx | 5 +- .../src/lib/api/compiler-api.ts | 9 +- .../src/lib/compiler-container.tsx | 136 ++++---- .../src/lib/components/compiler-menu.tsx | 2 +- .../src/lib/contract-selection.tsx | 22 +- .../src/lib/logic/compileTabLogic.ts | 12 +- .../src/lib/logic/flattenerUtilities.ts | 28 +- .../src/lib/solidity-compiler.tsx | 5 +- .../solidity-compiler/src/lib/types/index.ts | 1 - .../src/lib/components/UmlDownload.tsx | 12 +- .../src/lib/solidity-uml-gen.tsx | 24 +- .../src/lib/utilities/UmlDownloadStrategy.ts | 2 +- .../solidity-uml-gen/src/types/index.ts | 2 +- .../src/lib/logic/testTabLogic.ts | 8 +- .../src/lib/solidity-unit-testing.tsx | 4 +- .../src/lib/Button/StaticAnalyserButton.tsx | 6 +- .../static-analyser/src/lib/ErrorRenderer.tsx | 8 +- .../src/lib/actions/staticAnalysisActions.ts | 6 +- .../src/lib/components/BasicTitle.tsx | 6 +- .../src/lib/remix-ui-static-analyser.tsx | 30 +- .../static-analyser/src/staticanalyser.d.ts | 1 - libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 34 +- .../src/lib/actions/terminalAction.ts | 2 +- .../src/lib/components/ChechTxStatus.tsx | 2 +- .../terminal/src/lib/components/Context.tsx | 6 +- .../src/lib/components/RenderCall.tsx | 16 +- .../components/RenderKnownTransactions.tsx | 16 +- .../components/RenderUnknownTransactions.tsx | 14 +- .../terminal/src/lib/components/Table.tsx | 14 +- .../lib/components/remix-ui-terminal-bar.tsx | 2 +- .../lib/components/remix-ui-terminal-menu.tsx | 2 +- .../src/lib/custom-hooks/useKeyPress.tsx | 4 +- .../src/lib/reducers/terminalReducer.ts | 42 +-- .../terminal/src/lib/remix-ui-terminal.tsx | 20 +- .../terminal/src/lib/terminalWelcome.tsx | 4 +- .../src/lib/remix-ui-theme-module.tsx | 8 +- libs/remix-ui/toaster/src/lib/toaster.tsx | 16 +- .../tooltip-popup/src/lib/tooltip-popup.tsx | 6 +- .../tree-view/src/lib/remix-ui-tree-view.tsx | 4 +- .../src/lib/tree-view-item/tree-view-item.tsx | 6 +- .../src/lib/components/Badge.tsx | 10 +- .../src/lib/components/BasicLogo.tsx | 4 +- .../src/lib/components/Chevron.tsx | 8 +- .../src/lib/components/Home.tsx | 6 +- .../src/lib/components/Icon.tsx | 33 +- .../src/lib/components/IconList.tsx | 8 +- .../src/lib/remix-ui-vertical-icons-panel.tsx | 2 +- .../src/lib/vertical-icons-context-menu.tsx | 8 +- .../src/lib/vyper-compile-details.tsx | 3 +- .../src/lib/vyperCompile.tsx | 4 +- .../workspace/src/lib/actions/events.ts | 10 +- .../workspace/src/lib/actions/index.ts | 18 +- .../workspace/src/lib/actions/workspace.ts | 16 +- .../src/lib/components/electron-menu.tsx | 2 - .../components/electron-workspace-name.tsx | 5 +- .../components/file-explorer-context-menu.tsx | 12 +- .../components/file-explorer-hovericons.tsx | 8 +- .../src/lib/components/file-explorer-menu.tsx | 18 +- .../src/lib/components/file-explorer.tsx | 4 - .../src/lib/components/flat-tree-drop.tsx | 2 - .../lib/components/flat-tree-item-input.tsx | 14 +- .../src/lib/components/upload-file.tsx | 4 +- .../components/workspace-hamburger-item.tsx | 14 +- .../lib/components/workspace-hamburger.tsx | 14 +- .../workspace/src/lib/contexts/index.ts | 3 +- .../src/lib/providers/FileSystemProvider.tsx | 25 +- .../workspace/src/lib/reducers/workspace.ts | 49 ++- .../workspace/src/lib/remix-ui-workspace.tsx | 290 +++++++++--------- .../src/lib/components/remix-ui-xterm.tsx | 18 +- .../lib/components/remix-ui-xterminals.tsx | 6 +- .../src/lib/components/xterm-fit-addOn.ts | 2 - 214 files changed, 1419 insertions(+), 1472 deletions(-) diff --git a/libs/remix-ui/app/src/lib/remix-app/actions/modals.ts b/libs/remix-ui/app/src/lib/remix-app/actions/modals.ts index 7e78c46cd5..4c2e70764d 100644 --- a/libs/remix-ui/app/src/lib/remix-app/actions/modals.ts +++ b/libs/remix-ui/app/src/lib/remix-app/actions/modals.ts @@ -22,7 +22,7 @@ export const enum modalActionTypes { type ModalPayload = { [modalActionTypes.setModal]: AppModal [modalActionTypes.handleHideModal]: any - [modalActionTypes.setToast]: { message: string | JSX.Element, timestamp: number } + [modalActionTypes.setToast]: { message: string | JSX.Element, timestamp: number } [modalActionTypes.handleToaster]: any, [modalActionTypes.processQueue]: any } diff --git a/libs/remix-ui/app/src/lib/remix-app/components/dragbar/dragbar.tsx b/libs/remix-ui/app/src/lib/remix-app/components/dragbar/dragbar.tsx index 46b7f851c2..24c8099606 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/dragbar/dragbar.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/dragbar/dragbar.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState, useRef} from 'react' +import React, { useEffect, useState, useRef } from 'react' import Draggable from 'react-draggable' import './dragbar.css' @@ -77,7 +77,7 @@ const DragBar = (props: IRemixDragBarUi) => { return ( <>
- +
diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/dialogViewPlugin.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/dialogViewPlugin.tsx index 091795a900..d5610de56c 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/modals/dialogViewPlugin.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/dialogViewPlugin.tsx @@ -1,13 +1,13 @@ -import React, {useContext, useEffect} from 'react' -import {AppContext} from '../../context/context' -import {useDialogDispatchers} from '../../context/provider' +import React, { useContext, useEffect } from 'react' +import { AppContext } from '../../context/context' +import { useDialogDispatchers } from '../../context/provider' const DialogViewPlugin = () => { - const {modal, alert, toast} = useDialogDispatchers() + const { modal, alert, toast } = useDialogDispatchers() const app = useContext(AppContext) useEffect(() => { - app.modal.setDispatcher({modal, alert, toast}) + app.modal.setDispatcher({ modal, alert, toast }) }, []) return <> } diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/dialogs.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/dialogs.tsx index 052b8661b3..da5cbd8a72 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/modals/dialogs.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/dialogs.tsx @@ -1,11 +1,11 @@ import React from 'react' -import {useDialogDispatchers, useDialogs} from '../../context/provider' -import {Toaster} from '@remix-ui/toaster' +import { useDialogDispatchers, useDialogs } from '../../context/provider' +import { Toaster } from '@remix-ui/toaster' import ModalWrapper from './modal-wrapper' const AppDialogs = () => { - const {handleHideModal, handleToaster} = useDialogDispatchers() - const {focusModal, focusToaster} = useDialogs() + const { handleHideModal, handleToaster } = useDialogDispatchers() + const { focusModal, focusToaster } = useDialogs() return ( <> diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/enter.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/enter.tsx index 4b95fa1cfc..a514a1f166 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/modals/enter.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/enter.tsx @@ -1,7 +1,7 @@ -import React, {useContext, useEffect, useState} from 'react' -import {FormattedMessage} from 'react-intl' -import {AppContext} from '../../context/context' -import {UsageTypes} from '../../types' +import React, { useContext, useEffect, useState } from 'react' +import { FormattedMessage } from 'react-intl' +import { AppContext } from '../../context/context' +import { UsageTypes } from '../../types' import { type } from 'os' interface EnterDialogProps { @@ -27,7 +27,7 @@ const EnterDialog = (props: EnterDialogProps) => {
{ + onKeyDown={({ keyCode }) => { }} >
@@ -36,14 +36,14 @@ const EnterDialog = (props: EnterDialogProps) => {
- +
- - - - + + + +
diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/matomo.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/matomo.tsx index daad75b4b2..bdd57d8b11 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/modals/matomo.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/matomo.tsx @@ -1,7 +1,7 @@ -import React, {useContext, useEffect, useState} from 'react' -import {FormattedMessage} from 'react-intl' -import {AppContext} from '../../context/context' -import {useDialogDispatchers} from '../../context/provider' +import React, { useContext, useEffect, useState } from 'react' +import { FormattedMessage } from 'react-intl' +import { AppContext } from '../../context/context' +import { useDialogDispatchers } from '../../context/provider' declare global { interface Window { _paq: any @@ -15,8 +15,8 @@ interface MatomoDialogProps { } const MatomoDialog = (props: MatomoDialogProps) => { - const {settings, showMatamo, appManager} = useContext(AppContext) - const {modal} = useDialogDispatchers() + const { settings, showMatamo, appManager } = useContext(AppContext) + const { modal } = useDialogDispatchers() const [visible, setVisible] = useState(props.hide) const message = () => { diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx index 07b974d3fe..d0ae6026b2 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx @@ -1,6 +1,6 @@ -import React, {useEffect, useRef, useState} from 'react' -import {ModalDialog, ModalDialogProps, ValidationResult} from '@remix-ui/modal-dialog' -import {ModalTypes} from '../../types' +import React, { useEffect, useRef, useState } from 'react' +import { ModalDialog, ModalDialogProps, ValidationResult } from '@remix-ui/modal-dialog' +import { ModalTypes } from '../../types' interface ModalWrapperProps extends ModalDialogProps { modalType?: ModalTypes @@ -80,7 +80,7 @@ const ModalWrapper = (props: ModalWrapperProps) => { if (props.validationFn) { const validation = props.validationFn(getFormData()) setState((prevState) => { - return {...prevState, message: createForm(validation), validation} + return { ...prevState, message: createForm(validation), validation } }) } } @@ -106,7 +106,7 @@ const ModalWrapper = (props: ModalWrapperProps) => { ...props, okFn: onFinishPrompt, cancelFn: onCancelFn, - message: createModalMessage(props.defaultValue, {valid: true}) + message: createModalMessage(props.defaultValue, { valid: true }) }) break case ModalTypes.form: @@ -114,7 +114,7 @@ const ModalWrapper = (props: ModalWrapperProps) => { ...props, okFn: onFinishPrompt, cancelFn: onCancelFn, - message: createForm({valid: true}) + message: createForm({ valid: true }) }) break default: @@ -137,7 +137,7 @@ const ModalWrapper = (props: ModalWrapperProps) => { // reset the message and input if any, so when the modal is shown again it doesn't show the previous value. const handleHide = () => { setState((prevState) => { - return {...prevState, message: ''} + return { ...prevState, message: '' } }) props.handleHide() } diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/origin-warning.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/origin-warning.tsx index f36e5f0938..fe9e0ba234 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/modals/origin-warning.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/origin-warning.tsx @@ -1,9 +1,9 @@ -import React, {useEffect, useState} from 'react' -import {ModalDialog} from '@remix-ui/modal-dialog' -import {useDialogDispatchers} from '../../context/provider' +import React, { useEffect, useState } from 'react' +import { ModalDialog } from '@remix-ui/modal-dialog' +import { useDialogDispatchers } from '../../context/provider' const OriginWarning = () => { - const {alert} = useDialogDispatchers() + const { alert } = useDialogDispatchers() const [content, setContent] = useState(null) useEffect(() => { @@ -29,7 +29,7 @@ const OriginWarning = () => { useEffect(() => { if (content) { - alert({id: 'warningOriging', title: null, message: content}) + alert({ id: 'warningOriging', title: null, message: content }) } }, [content]) diff --git a/libs/remix-ui/app/src/lib/remix-app/components/splashscreen.tsx b/libs/remix-ui/app/src/lib/remix-app/components/splashscreen.tsx index 4f013c4761..f110eb66b4 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/splashscreen.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/splashscreen.tsx @@ -4,7 +4,7 @@ const RemixSplashScreen = (props) => { return ( <> {' '} -
+
diff --git a/libs/remix-ui/app/src/lib/remix-app/context/context.tsx b/libs/remix-ui/app/src/lib/remix-app/context/context.tsx index a3cc4b7c9e..9fcf53d4a7 100644 --- a/libs/remix-ui/app/src/lib/remix-app/context/context.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/context/context.tsx @@ -1,6 +1,6 @@ import React from 'react' -import {AlertModal, AppModal} from '../interface' -import {ModalInitialState} from '../state/modals' +import { AlertModal, AppModal } from '../interface' +import { ModalInitialState } from '../state/modals' export type appProviderContextType = { settings: any, @@ -10,7 +10,7 @@ export type appProviderContextType = { modal: any } -export enum appPlatformTypes { +export enum appPlatformTypes { web = 'web', desktop = 'desktop' } diff --git a/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx b/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx index 54a3c1d1b4..5b64e8e5f6 100644 --- a/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx @@ -1,11 +1,11 @@ -import React, {useReducer} from 'react' -import {useIntl, IntlShape} from 'react-intl' -import {modalActionTypes} from '../actions/modals' -import {AlertModal, AppModal} from '../interface' -import {modalReducer} from '../reducer/modals' -import {ModalInitialState} from '../state/modals' -import {ModalTypes} from '../types' -import {AppContext, dispatchModalContext, modalContext, platformContext, onLineContext} from './context' +import React, { useReducer } from 'react' +import { useIntl, IntlShape } from 'react-intl' +import { modalActionTypes } from '../actions/modals' +import { AlertModal, AppModal } from '../interface' +import { modalReducer } from '../reducer/modals' +import { ModalInitialState } from '../state/modals' +import { ModalTypes } from '../types' +import { AppContext, dispatchModalContext, modalContext, platformContext, onLineContext } from './context' declare global { interface Window { @@ -13,8 +13,8 @@ declare global { } } -export const ModalProvider = ({children = [], reducer = modalReducer, initialState = ModalInitialState} = {}) => { - const [{modals, toasters, focusModal, focusToaster}, dispatch] = useReducer(reducer, initialState) +export const ModalProvider = ({ children = [], reducer = modalReducer, initialState = ModalInitialState } = {}) => { + const [{ modals, toasters, focusModal, focusToaster }, dispatch] = useReducer(reducer, initialState) const onNextFn = async () => { dispatch({ @@ -23,7 +23,7 @@ export const ModalProvider = ({children = [], reducer = modalReducer, initialSta } const modal = (modalData: AppModal) => { - const {id, title, message, validationFn, okLabel, okFn, cancelLabel, cancelFn, modalType, defaultValue, hideFn, data} = modalData + const { id, title, message, validationFn, okLabel, okFn, cancelLabel, cancelFn, modalType, defaultValue, hideFn, data } = modalData return new Promise((resolve, reject) => { dispatch({ type: modalActionTypes.setModal, @@ -50,9 +50,9 @@ export const ModalProvider = ({children = [], reducer = modalReducer, initialSta const alert = (modalData: AlertModal) => { return modal({ id: modalData.id, - title: modalData.title || window._intl.formatMessage({id: 'remixApp.alert'}), + title: modalData.title || window._intl.formatMessage({ id: 'remixApp.alert' }), message: modalData.message || modalData.title, - okLabel: window._intl.formatMessage({id: 'remixApp.ok'}), + okLabel: window._intl.formatMessage({ id: 'remixApp.ok' }), okFn: (value?: any) => {}, cancelLabel: '', cancelFn: () => {} @@ -69,7 +69,7 @@ export const ModalProvider = ({children = [], reducer = modalReducer, initialSta const toast = (message: string | JSX.Element) => { dispatch({ type: modalActionTypes.setToast, - payload: {message, timestamp: Date.now()} + payload: { message, timestamp: Date.now() } }) } @@ -81,13 +81,13 @@ export const ModalProvider = ({children = [], reducer = modalReducer, initialSta } return ( - - {children} + + {children} ) } -export const AppProvider = ({children = [], value = {}} = null) => { +export const AppProvider = ({ children = [], value = {} } = null) => { window._intl = useIntl() return ( diff --git a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts index eb298090ea..17afcc9e35 100644 --- a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts +++ b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts @@ -35,7 +35,7 @@ export interface ModalState { modals: AppModal[], toasters: {message: (string | JSX.Element), timestamp: number }[], focusModal: AppModal, - focusToaster: {message: (string | JSX.Element), timestamp: number } + focusToaster: {message: (string | JSX.Element), timestamp: number } } export interface forceChoiceModal { diff --git a/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts b/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts index 4330d967a6..4578170385 100644 --- a/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts +++ b/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts @@ -76,7 +76,7 @@ export const modalReducer = (state: ModalState = ModalInitialState, action: Moda const toaster = toasterList[0] return { ...state, toasters: toasterList, focusToaster: toaster } } else { - return { ...state, toasters: [] } + return { ...state, toasters: []} } } } diff --git a/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx b/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx index 5c11d96b0f..25253b0302 100644 --- a/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx +++ b/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx @@ -1,7 +1,7 @@ -import {CustomTooltip} from '@remix-ui/helper' +import { CustomTooltip } from '@remix-ui/helper' import React, {CSSProperties} from 'react' //eslint-disable-line import './remix-ui-checkbox.css' -import {Placement} from 'react-bootstrap/esm/Overlay' +import { Placement } from 'react-bootstrap/esm/Overlay' /* eslint-disable-next-line */ export interface RemixUiCheckboxProps { @@ -52,8 +52,8 @@ export const RemixUiCheckbox = ({ } onClick={onClick} > - -
{itemName}
: ''} {label} @@ -72,8 +72,8 @@ export const RemixUiCheckbox = ({ } onClick={onClick} > - -
-
+
This call has reverted, state changes made during the call will be reverted. - + This call will run out of gas. { }) debuggerModule.onBreakpointAdded((fileName, row) => { - if (state.debugger) state.debugger.breakPointManager.add({fileName: fileName, row: row}) + if (state.debugger) state.debugger.breakPointManager.add({ fileName: fileName, row: row }) }) debuggerModule.onEditorContentChanged(() => { @@ -107,7 +107,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { debuggerModule.onEnvChanged((provider) => { setState((prevState) => { const isLocalNodeUsed = !provider.startsWith('vm') && !provider.startsWith('injected') - return {...prevState, isLocalNodeUsed: isLocalNodeUsed} + return { ...prevState, isLocalNodeUsed: isLocalNodeUsed } }) }) } @@ -121,7 +121,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { debuggerInstance.event.register('debuggerStatus', async (isActive) => { await debuggerModule.discardHighlight() setState((prevState) => { - return {...prevState, isActive} + return { ...prevState, isActive } }) }) @@ -129,14 +129,14 @@ export const DebuggerUI = (props: DebuggerUIProps) => { setState((prevState) => { return { ...prevState, - sourceLocationStatus: intl.formatMessage({id: 'debugger.sourceLocationStatus1'}) + sourceLocationStatus: intl.formatMessage({ id: 'debugger.sourceLocationStatus1' }) } }) }) debuggerInstance.event.register('noBreakpointHit', async (isActive) => { setState((prevState) => { - return {...prevState, sourceLocationStatus: ''} + return { ...prevState, sourceLocationStatus: '' } }) }) @@ -146,7 +146,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { setState((prevState) => { return { ...prevState, - sourceLocationStatus: intl.formatMessage({id: 'debugger.sourceLocationStatus2'}) + sourceLocationStatus: intl.formatMessage({ id: 'debugger.sourceLocationStatus2' }) } }) return @@ -175,7 +175,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { } if (path) { setState((prevState) => { - return {...prevState, sourceLocationStatus: ''} + return { ...prevState, sourceLocationStatus: '' } }) await debuggerModule.discardHighlight() await debuggerModule.highlight(lineColumnPos, path, rawLocation, stepDetail, lineGasCost) @@ -381,11 +381,11 @@ export const DebuggerUI = (props: DebuggerUIProps) => { { + onChange={({ target: { checked } }) => { setState((prevState) => { return { ...prevState, - opt: {...prevState.opt, debugWithGeneratedSources: checked} + opt: { ...prevState.opt, debugWithGeneratedSources: checked } } }) }} @@ -413,11 +413,11 @@ export const DebuggerUI = (props: DebuggerUIProps) => { { + onChange={({ target: { checked } }) => { setState((prevState) => { return { ...prevState, - opt: {...prevState.opt, debugWithLocalNode: checked} + opt: { ...prevState.opt, debugWithLocalNode: checked } } }) }} diff --git a/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx b/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx index 517bbfe87a..7610531373 100644 --- a/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx @@ -1,6 +1,6 @@ import React, {useState, useEffect, useRef} from 'react' // eslint-disable-line -export const Slider = ({jumpTo, sliderValue, traceLength}) => { +export const Slider = ({ jumpTo, sliderValue, traceLength }) => { const onChangeId = useRef(null) const slider = useRef(null) diff --git a/libs/remix-ui/debugger-ui/src/lib/step-manager/step-manager.tsx b/libs/remix-ui/debugger-ui/src/lib/step-manager/step-manager.tsx index 1fc85769cc..7b9ddfc84c 100644 --- a/libs/remix-ui/debugger-ui/src/lib/step-manager/step-manager.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/step-manager/step-manager.tsx @@ -31,16 +31,16 @@ export const StepManager = ({ const setRevertWarning = (warning) => { setState((prevState) => { - return {...prevState, revertWarning: warning} + return { ...prevState, revertWarning: warning } }) } const updateStep = (step, stepState, jumpOutDisabled) => { setState((prevState) => { - return {...prevState, sliderValue: step, stepState, jumpOutDisabled} + return { ...prevState, sliderValue: step, stepState, jumpOutDisabled } }) } - const {sliderValue, revertWarning, stepState, jumpOutDisabled} = state + const { sliderValue, revertWarning, stepState, jumpOutDisabled } = state return (
diff --git a/libs/remix-ui/debugger-ui/src/lib/tx-browser/tx-browser.tsx b/libs/remix-ui/debugger-ui/src/lib/tx-browser/tx-browser.tsx index 2e07121534..e5c4a534dd 100644 --- a/libs/remix-ui/debugger-ui/src/lib/tx-browser/tx-browser.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/tx-browser/tx-browser.tsx @@ -1,9 +1,9 @@ -import {CustomTooltip, isValidHash} from '@remix-ui/helper' +import { CustomTooltip, isValidHash } from '@remix-ui/helper' import React, {useState, useEffect, useRef} from 'react' //eslint-disable-line -import {useIntl, FormattedMessage} from 'react-intl' +import { useIntl, FormattedMessage } from 'react-intl' import './tx-browser.css' -export const TxBrowser = ({requestDebug, updateTxNumberFlag, unloadRequested, transactionNumber, debugging}) => { +export const TxBrowser = ({ requestDebug, updateTxNumberFlag, unloadRequested, transactionNumber, debugging }) => { const [state, setState] = useState({ txNumber: '', isTxNumberValid: false @@ -63,7 +63,7 @@ export const TxBrowser = ({requestDebug, updateTxNumberFlag, unloadRequested, tr onClick={handleSubmit} data-id="debuggerTransactionStartButton" disabled={!state.txNumber || !state.isTxNumberValid} - style={{pointerEvents: 'none', color: 'white'}} + style={{ pointerEvents: 'none', color: 'white' }} > @@ -81,9 +81,9 @@ export const TxBrowser = ({requestDebug, updateTxNumberFlag, unloadRequested, tr className="form-control m-0 txinput" id="txinput" type="text" - onChange={({target: {value}}) => txInputChanged(value)} + onChange={({ target: { value } }) => txInputChanged(value)} onInput={txInputOnInput} - placeholder={intl.formatMessage({id: 'debugger.placeholder'})} + placeholder={intl.formatMessage({ id: 'debugger.placeholder' })} data-id="debuggerTransactionInput" disabled={debugging} /> diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index 96c194e93f..2330257708 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -1,9 +1,9 @@ import React, {useState, useRef, useEffect, useReducer} from 'react' // eslint-disable-line -import {FormattedMessage} from 'react-intl' -import {initialState, reducer} from '../../reducers/assembly-items' +import { FormattedMessage } from 'react-intl' +import { initialState, reducer } from '../../reducers/assembly-items' import './styles/assembly-items.css' -export const AssemblyItems = ({registerEvent}) => { +export const AssemblyItems = ({ registerEvent }) => { const [assemblyItems, dispatch] = useReducer(reducer, initialState) const [absoluteSelectedIndex, setAbsoluteSelectedIndex] = useState(0) const [selectedItem, setSelectedItem] = useState(0) @@ -34,7 +34,7 @@ export const AssemblyItems = ({registerEvent}) => { registerEvent('lineGasCostChanged', (instructionsIndexes: number[], line: []) => { dispatch({ type: 'FETCH_INDEXES_FOR_NEW_LINE', - payload: {currentLineIndexes: instructionsIndexes || [], line} + payload: { currentLineIndexes: instructionsIndexes || [], line } }) }) }, []) diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/calldata-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/calldata-panel.tsx index a7b01c5cc5..71c29247bc 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/calldata-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/calldata-panel.tsx @@ -1,7 +1,7 @@ import React from 'react' // eslint-disable-line import DropdownPanel from './dropdown-panel' // eslint-disable-line -export const CalldataPanel = ({calldata, className = ''}) => { +export const CalldataPanel = ({ calldata, className = '' }) => { return (
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/callstack-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/callstack-panel.tsx index 1636fdf67d..3554c1f9b2 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/callstack-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/callstack-panel.tsx @@ -1,7 +1,7 @@ import React from 'react' // eslint-disable-line import DropdownPanel from './dropdown-panel' // eslint-disable-line -export const CallstackPanel = ({calldata, className}) => { +export const CallstackPanel = ({ calldata, className }) => { return (
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/code-list-view.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/code-list-view.tsx index da2b6b0b7d..12e891061e 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/code-list-view.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/code-list-view.tsx @@ -1,7 +1,7 @@ import React, {useState, useEffect} from 'react' // eslint-disable-line import AssemblyItems from './assembly-items' // eslint-disable-line -export const CodeListView = ({registerEvent, className = ''}) => { +export const CodeListView = ({ registerEvent, className = '' }) => { return (
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx index 55174aee9b..bdcce84a11 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx @@ -1,10 +1,10 @@ import React, {useState, useEffect, useReducer} from 'react' // eslint-disable-line -import {useIntl} from 'react-intl' +import { useIntl } from 'react-intl' import {TreeView, TreeViewItem} from '@remix-ui/tree-view' // eslint-disable-line import {DropdownPanelProps, ExtractData, ExtractFunc} from '../../types' // eslint-disable-line import {CopyToClipboard} from '@remix-ui/clipboard' // eslint-disable-line -import {initialState, reducer} from '../../reducers/calldata' -import {isBigInt} from 'web3-validator' +import { initialState, reducer } from '../../reducers/calldata' +import { isBigInt } from 'web3-validator' import './styles/dropdown-panel.css' export const DropdownPanel = (props: DropdownPanelProps) => { @@ -34,14 +34,14 @@ export const DropdownPanel = (props: DropdownPanelProps) => { if (item instanceof Array) { ret.children = item.map((item, index) => { - return {key: index, value: item} + return { key: index, value: item } }) ret.self = 'Array' ret.isNode = true ret.isLeaf = false } else if (item instanceof Object) { ret.children = Object.keys(item).map((key) => { - return {key: key, value: item[key]} + return { key: key, value: item[key] } }) ret.self = 'Object' ret.isNode = true @@ -90,7 +90,7 @@ export const DropdownPanel = (props: DropdownPanelProps) => { header: '', toggleDropdown: true, message: { - innerText: intl.formatMessage({id: 'debugger.noDataAvailable'}), + innerText: intl.formatMessage({ id: 'debugger.noDataAvailable' }), display: 'block' }, dropdownContent: { @@ -110,12 +110,12 @@ export const DropdownPanel = (props: DropdownPanelProps) => { useEffect(() => { registerEvent && registerEvent(loadMoreCompletedEvent, (updatedCalldata) => { - dispatch({type: 'UPDATE_CALLDATA_SUCCESS', payload: updatedCalldata}) + dispatch({ type: 'UPDATE_CALLDATA_SUCCESS', payload: updatedCalldata }) }) }, []) useEffect(() => { - dispatch({type: 'FETCH_CALLDATA_SUCCESS', payload: calldata}) + dispatch({ type: 'FETCH_CALLDATA_SUCCESS', payload: calldata }) }, [calldata]) useEffect(() => { @@ -199,7 +199,7 @@ export const DropdownPanel = (props: DropdownPanelProps) => { // replace 0xNaN with 0x0 copiableContent, message: { - innerText: isEmpty ? intl.formatMessage({id: 'debugger.noDataAvailable'}) : '', + innerText: isEmpty ? intl.formatMessage({ id: 'debugger.noDataAvailable' }) : '', display: isEmpty ? 'block' : 'none' }, updating: false, @@ -232,7 +232,7 @@ export const DropdownPanel = (props: DropdownPanelProps) => { id={'treeViewLoadMore'} data-id={'treeViewLoadMore'} className="cursor_pointer" - label={intl.formatMessage({id: 'debugger.loadMore'})} + label={intl.formatMessage({ id: 'debugger.loadMore' })} onClick={() => { triggerEvent(loadMoreEvent, [data.cursor]) }} @@ -267,17 +267,17 @@ export const DropdownPanel = (props: DropdownPanelProps) => { {header} - +
-
- -
+
+ +
{state.data && {Object.keys(state.data).map((innerkey) => renderData(state.data[innerkey], state.data, innerkey, innerkey))}}
-
+
{state.message.innerText}
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/full-storages-changes.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/full-storages-changes.tsx index 46ef22dbbd..b053d932be 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/full-storages-changes.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/full-storages-changes.tsx @@ -1,7 +1,7 @@ import React from 'react' // eslint-disable-line import {DropdownPanel} from './dropdown-panel' // eslint-disable-line -export const FullStoragesChanges = ({calldata, className = ''}) => { +export const FullStoragesChanges = ({ calldata, className = '' }) => { return (
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/function-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/function-panel.tsx index d2106977ed..9c76bd1649 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/function-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/function-panel.tsx @@ -2,7 +2,7 @@ import React, {useState, useEffect} from 'react' // eslint-disable-line import DropdownPanel from './dropdown-panel' // eslint-disable-line import {default as deepequal} from 'deep-equal' // eslint-disable-line -export const FunctionPanel = ({data, className, stepManager}) => { +export const FunctionPanel = ({ data, className, stepManager }) => { const [functionData, setFunctionData] = useState(null) useEffect(() => { @@ -24,7 +24,7 @@ export const FunctionPanel = ({data, className, stepManager}) => { } return ( - +
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx index a649cc73b3..33d9e6c1f8 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx @@ -2,7 +2,7 @@ import React from 'react' // eslint-disable-line import DropdownPanel from './dropdown-panel' // eslint-disable-line import {toBigInt} from 'web3-utils' // eslint-disable-line -export const GlobalVariables = ({block, receipt, tx, className}) => { +export const GlobalVariables = ({ block, receipt, tx, className }) => { // see https://docs.soliditylang.org/en/latest/units-and-global-variables.html#block-and-transaction-properties const globals = { 'block.chainid': tx && tx.chainId, @@ -22,7 +22,7 @@ export const GlobalVariables = ({block, receipt, tx, className}) => { return (
- +
) } diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/memory-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/memory-panel.tsx index b92df380ed..7fcb07766f 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/memory-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/memory-panel.tsx @@ -1,10 +1,10 @@ import React from 'react' // eslint-disable-line import DropdownPanel from './dropdown-panel' // eslint-disable-line -export const MemoryPanel = ({calldata, className}) => { +export const MemoryPanel = ({ calldata, className }) => { return (
- +
) } diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx index d2864200a3..e5abd074c0 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx @@ -3,7 +3,7 @@ import DropdownPanel from './dropdown-panel' // eslint-disable-line import {extractData} from '../../utils/solidityTypeFormatter' // eslint-disable-line import {ExtractData} from '../../types' // eslint-disable-line -export const SolidityLocals = ({data, message, registerEvent, triggerEvent, className = ''}) => { +export const SolidityLocals = ({ data, message, registerEvent, triggerEvent, className = '' }) => { const [calldata, setCalldata] = useState(null) useEffect(() => { @@ -34,10 +34,10 @@ export const SolidityLocals = ({data, message, registerEvent, triggerEvent, clas }} > {' ' + key}: - ) } diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-state.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-state.tsx index 0032208953..0b19a5e256 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-state.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-state.tsx @@ -1,9 +1,9 @@ import React from 'react' // eslint-disable-line import DropdownPanel from './dropdown-panel' // eslint-disable-line -import {extractData} from '../../utils/solidityTypeFormatter' +import { extractData } from '../../utils/solidityTypeFormatter' import {ExtractData} from '../../types' // eslint-disable-line -export const SolidityState = ({calldata, message, className}) => { +export const SolidityState = ({ calldata, message, className }) => { const formatSelf = (key: string, data: ExtractData) => { try { let color = 'var(--primary)' @@ -26,10 +26,10 @@ export const SolidityState = ({calldata, message, className}) => { }} > {' ' + key}: - ) } catch (e) { diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/stack-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/stack-panel.tsx index 12dcf502cc..8a4db54de1 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/stack-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/stack-panel.tsx @@ -1,10 +1,10 @@ import React from 'react' // eslint-disable-line import DropdownPanel from './dropdown-panel' // eslint-disable-line -export const StackPanel = ({calldata, className}) => { +export const StackPanel = ({ calldata, className }) => { return (
- +
) } diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/step-detail.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/step-detail.tsx index e64bad1005..ba38925d18 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/step-detail.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/step-detail.tsx @@ -1,7 +1,7 @@ import React from 'react' // eslint-disable-line import DropdownPanel from './dropdown-panel' // eslint-disable-line -export const StepDetail = ({stepDetail, className = ''}) => { +export const StepDetail = ({ stepDetail, className = '' }) => { return (
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/storage-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/storage-panel.tsx index 7514ab633f..06009a4dfc 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/storage-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/storage-panel.tsx @@ -1,7 +1,7 @@ import React from 'react' // eslint-disable-line import DropdownPanel from './dropdown-panel' // eslint-disable-line -export const StoragePanel = ({calldata, header, className}) => { +export const StoragePanel = ({ calldata, header, className }) => { return (
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx index 035d5f619a..a2ef485944 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx @@ -5,7 +5,7 @@ import StepDetail from './step-detail' // eslint-disable-line import SolidityState from './solidity-state' // eslint-disable-line import SolidityLocals from './solidity-locals' // eslint-disable-line -export const VmDebuggerHead = ({vmDebugger: {registerEvent, triggerEvent}, debugging, stepManager}) => { +export const VmDebuggerHead = ({ vmDebugger: { registerEvent, triggerEvent }, debugging, stepManager }) => { const [functionPanel, setFunctionPanel] = useState(null) const [stepDetail, setStepDetail] = useState({ 'vm trace step': '-', @@ -69,73 +69,73 @@ export const VmDebuggerHead = ({vmDebugger: {registerEvent, triggerEvent}, debug registerEvent && registerEvent('traceCurrentStepUpdate', (error, step) => { setStepDetail((prevState) => { - return {...prevState, 'execution step': error ? '-' : step} + return { ...prevState, 'execution step': error ? '-' : step } }) }) registerEvent && registerEvent('traceMemExpandUpdate', (error, addmem) => { setStepDetail((prevState) => { - return {...prevState, 'add memory': error ? '-' : addmem} + return { ...prevState, 'add memory': error ? '-' : addmem } }) }) registerEvent && registerEvent('traceStepCostUpdate', (error, gas) => { setStepDetail((prevState) => { - return {...prevState, gas: error ? '-' : gas} + return { ...prevState, gas: error ? '-' : gas } }) }) registerEvent && registerEvent('traceCurrentCalledAddressAtUpdate', (error, address) => { setStepDetail((prevState) => { - return {...prevState, 'loaded address': error ? '-' : address} + return { ...prevState, 'loaded address': error ? '-' : address } }) }) registerEvent && registerEvent('traceRemainingGasUpdate', (error, remainingGas) => { setStepDetail((prevState) => { - return {...prevState, 'remaining gas': error ? '-' : remainingGas} + return { ...prevState, 'remaining gas': error ? '-' : remainingGas } }) }) registerEvent && registerEvent('indexUpdate', (index) => { setStepDetail((prevState) => { - return {...prevState, 'vm trace step': index} + return { ...prevState, 'vm trace step': index } }) }) registerEvent && registerEvent('solidityState', (calldata) => { setSolidityState(() => { - return {...solidityState, calldata} + return { ...solidityState, calldata } }) }) registerEvent && registerEvent('solidityStateMessage', (message) => { setSolidityState(() => { - return {...solidityState, message} + return { ...solidityState, message } }) }) registerEvent && registerEvent('solidityLocals', (calldata) => { setSolidityLocals(() => { - return {...solidityLocals, calldata} + return { ...solidityLocals, calldata } }) }) registerEvent && registerEvent('solidityLocalsMessage', (message) => { setSolidityLocals(() => { - return {...solidityLocals, message} + return { ...solidityLocals, message } }) }) }, [debugging]) return (
-
+
-
+
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx index 3231e18bcb..442c692ae3 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx @@ -8,7 +8,7 @@ import ReturnValuesPanel from './dropdown-panel' // eslint-disable-line import FullStoragesChangesPanel from './full-storages-changes' // eslint-disable-line import GlobalVariables from './global-variables' // eslint-disable-line -export const VmDebugger = ({vmDebugger: {registerEvent}, currentBlock, currentReceipt, currentTransaction, debugging}) => { +export const VmDebugger = ({ vmDebugger: { registerEvent }, currentBlock, currentReceipt, currentTransaction, debugging }) => { const [calldataPanel, setCalldataPanel] = useState(null) const [memoryPanel, setMemoryPanel] = useState(null) const [callStackPanel, setCallStackPanel] = useState(null) @@ -40,7 +40,7 @@ export const VmDebugger = ({vmDebugger: {registerEvent}, currentBlock, currentRe registerEvent && registerEvent('traceManagerStorageUpdate', (calldata, header) => { setStoragePanel(() => { - return {calldata, header} + return { calldata, header } }) }) registerEvent && diff --git a/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx b/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx index 5549a5ef33..d03a3ac8b2 100644 --- a/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx +++ b/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx @@ -1,7 +1,7 @@ -import {extractParentFromKey} from '@remix-ui/helper' -import React, {useContext, useRef, useState} from 'react' -import {MoveContext} from './context/moveContext' -import {DraggableType, DragType} from './types' +import { extractParentFromKey } from '@remix-ui/helper' +import React, { useContext, useRef, useState } from 'react' +import { MoveContext } from './context/moveContext' +import { DraggableType, DragType } from './types' export const Drag = (props: DragType) => { const [dragged, setDragged] = useState<{path: string; isDirectory: boolean}>({} as {path: string; isDirectory: boolean}) @@ -56,7 +56,7 @@ export const Draggable = (props: DraggableType) => { const handleDragover = (event: React.DragEvent) => { //Checks if the folder is opened event.preventDefault() - if (destination.isDirectory && !props.expandedPath.includes(destination.path) && folderToOpen !== destination.path && props.handleClickFolder) { + if (destination.isDirectory && !props.expandedPath.includes(destination.path) && folderToOpen !== destination.path && props.handleClickFolder) { setFolderToOpen(destination.path) timer && clearTimeout(timer) setTimer( diff --git a/libs/remix-ui/editor/src/lib/actions/editor.ts b/libs/remix-ui/editor/src/lib/actions/editor.ts index f6d82dc757..d533823af1 100644 --- a/libs/remix-ui/editor/src/lib/actions/editor.ts +++ b/libs/remix-ui/editor/src/lib/actions/editor.ts @@ -87,7 +87,7 @@ export const reducerActions = (models = initialState, action: Action) => { const size = action.payload.size if (size === 1) { editor.trigger('keyboard', 'editor.action.fontZoomIn', {}); - } else{ + } else { editor.trigger('keyboard', 'editor.action.fontZoomOut', {}); } return models diff --git a/libs/remix-ui/editor/src/lib/hardhat-ethers-extension.ts b/libs/remix-ui/editor/src/lib/hardhat-ethers-extension.ts index 13cfaf0066..0dd3974406 100644 --- a/libs/remix-ui/editor/src/lib/hardhat-ethers-extension.ts +++ b/libs/remix-ui/editor/src/lib/hardhat-ethers-extension.ts @@ -1,4 +1,4 @@ -export const hardhatEthersExtension = +export const hardhatEthersExtension = ` interface Libraries { [libraryName: string]: string; diff --git a/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts b/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts index 9670282e9f..3596ce6f16 100644 --- a/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/codeActionProvider.ts @@ -1,7 +1,7 @@ -import {Monaco} from '@monaco-editor/react' +import { Monaco } from '@monaco-editor/react' import monaco from '../../types/monaco' -import {EditorUIProps} from '../remix-ui-editor' -import {default as fixesList} from './quickfixes' +import { EditorUIProps } from '../remix-ui-editor' +import { default as fixesList } from './quickfixes' export class RemixCodeActionProvider implements monaco.languages.CodeActionProvider { props: EditorUIProps @@ -75,7 +75,7 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi case 9.1: case 9.2: case 10.1: - case 10.2: + case 10.2: case 10.3: case 11.1: case 11.2: { @@ -115,7 +115,7 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi * @param fix details of quick fix to apply */ addQuickFix(actions: monaco.languages.CodeAction[], error: monaco.editor.IMarkerData, uri: monaco.Uri, fix: Record) { - const {id, title, range, text} = fix + const { id, title, range, text } = fix actions.push({ title, diagnostics: [error], @@ -124,7 +124,7 @@ export class RemixCodeActionProvider implements monaco.languages.CodeActionProvi edits: [ { resource: uri, - textEdit: {range, text}, + textEdit: { range, text }, versionId: undefined } ] diff --git a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts index 1b89b72af7..cd8fc48e67 100644 --- a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts +++ b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts @@ -33,7 +33,6 @@ export function getBytesCompletionItems(range: monacoTypes.IRange, monaco): mona ] } - export function getBlockCompletionItems(range: monacoTypes.IRange, monaco): monacoTypes.languages.CompletionItem[] { return [ { @@ -442,7 +441,6 @@ export function getAbiCompletionItems(range: monacoTypes.IRange, monaco): monaco ]; } - export function GetCompletionTypes(range: monacoTypes.IRange, monaco): monacoTypes.languages.CompletionItem[] { const completionItems = []; const types = ['address', 'string', 'bytes', 'byte', 'int', 'uint', 'bool', 'hash']; @@ -510,7 +508,6 @@ export function GetCompletionKeywords(range: monacoTypes.IRange, monaco): monaco return completionItems; } - export function GeCompletionUnits(range: monacoTypes.IRange, monaco): monacoTypes.languages.CompletionItem[] { const completionItems = []; const etherUnits = ['wei', 'gwei', 'finney', 'szabo', 'ether']; @@ -557,7 +554,6 @@ export function GetImports(range: monacoTypes.IRange } })] - list = [...list, ...data.files .filter((item) => item.startsWith(word)) diff --git a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts index d375748413..66fbe8a10e 100644 --- a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts @@ -158,7 +158,6 @@ export class RemixCompletionProvider implements monacoTypes.languages.Completion return variableDeclaration } - for (const node of Object.values(filteredNodes) as any[]) { if (!node.name) continue if (node.nodeType === 'VariableDeclaration') { @@ -282,7 +281,7 @@ export class RemixCompletionProvider implements monacoTypes.languages.Completion } else { // we use the block info from the nodesAtPosition const contractNodes = fileNodes.contracts[node.name].contractNodes for (const contractNode of Object.values(contractNodes)) { - if((contractNode as any).nodeType === 'Block'){ + if ((contractNode as any).nodeType === 'Block'){ const nodeOfScope = await this.props.plugin.call('codeParser', 'getNodesWithScope', (contractNode as any).id) nodes = [...nodes, ...nodeOfScope] } @@ -348,7 +347,6 @@ export class RemixCompletionProvider implements monacoTypes.languages.Completion }) } - for (const nodeOfScope of contractCompletions) { if (nodeOfScope.name === nameOfLastTypedExpression) { if (nodeOfScope.typeName && nodeOfScope.typeName.nodeType === 'UserDefinedTypeName') { @@ -373,8 +371,6 @@ export class RemixCompletionProvider implements monacoTypes.languages.Completion } - - return { nodes, suggestions } } @@ -392,9 +388,9 @@ export class RemixCompletionProvider implements monacoTypes.languages.Completion } /** - * - * @param lineTextBeforeCursor - * @returns + * + * @param lineTextBeforeCursor + * @returns */ private async getLastNodeInExpression(lineTextBeforeCursor: string) { diff --git a/libs/remix-ui/editor/src/lib/providers/definitionProvider.ts b/libs/remix-ui/editor/src/lib/providers/definitionProvider.ts index 247a215eab..d74a5a0750 100644 --- a/libs/remix-ui/editor/src/lib/providers/definitionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/definitionProvider.ts @@ -77,7 +77,7 @@ export class RemixDefinitionProvider implements monaco.languages.DefinitionProvi return pos } } - const lastCompilationResult = await this.props.plugin.call('codeParser', 'getLastCompilationResult') // await this.props.plugin.call('compilerArtefacts', 'getLastCompilationResult') + const lastCompilationResult = await this.props.plugin.call('codeParser', 'getLastCompilationResult') // await this.props.plugin.call('compilerArtefacts', 'getLastCompilationResult') if (lastCompilationResult && lastCompilationResult.languageversion.indexOf('soljson') === 0 && lastCompilationResult.data) { const lineColumn = await this.props.plugin.call('codeParser', 'getLineColumnOfPosition', position) diff --git a/libs/remix-ui/editor/src/lib/providers/hoverProvider.ts b/libs/remix-ui/editor/src/lib/providers/hoverProvider.ts index 035eca6f4f..60523bdeac 100644 --- a/libs/remix-ui/editor/src/lib/providers/hoverProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/hoverProvider.ts @@ -46,7 +46,6 @@ export class RemixHoverProvider implements monacoTypes.languages.HoverProvider { return await this.props.plugin.call('codeParser', 'getVariableDeclaration', node) } - const getParamaters = async (node: any) => { return await this.props.plugin.call('codeParser', 'getFunctionParamaters', node) } @@ -55,7 +54,6 @@ export class RemixHoverProvider implements monacoTypes.languages.HoverProvider { return await this.props.plugin.call('codeParser', 'getFunctionReturnParameters', node) } - const getOverrides = async (node: any) => { if (node.overrides) { const overrides = [] @@ -179,7 +177,7 @@ export class RemixHoverProvider implements monacoTypes.languages.HoverProvider { try { const decodedVar = await this.props.plugin.call('debugger', 'decodeStateVariable', nodeAtPosition.id) - if (decodedVar !== null && decodedVar.type) { + if (decodedVar !== null && decodedVar.type) { contents.push({ value: `STATE VARIABLE ${nodeAtPosition.name}: ${typeof(decodedVar.value) === 'string' ? decodedVar.value : JSON.stringify(decodedVar.value, null, '\t')}` }) diff --git a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts index 601a5513e3..92c79914b5 100644 --- a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts @@ -2,7 +2,7 @@ import { EditorUIProps, monacoTypes } from '@remix-ui/editor'; import { CompletionTimer } from './completionTimer'; -import axios, {AxiosResponse} from 'axios' +import axios, { AxiosResponse } from 'axios' import { slice } from 'lodash'; const _paq = (window._paq = window._paq || []) @@ -20,7 +20,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli this.completionEnabled = true } - async provideInlineCompletions(model: monacoTypes.editor.ITextModel, position: monacoTypes.Position, context: monacoTypes.languages.InlineCompletionContext, token: monacoTypes.CancellationToken): Promise> { if (context.selectedSuggestionInfo) { return; @@ -28,7 +27,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli const getTextAtLine = (lineNumber) => { const lineRange = model.getFullModelRange().setStartPosition(lineNumber, 1).setEndPosition(lineNumber + 1, 1); return model.getValueInRange(lineRange); - } + } // get text before the position of the completion const word = model.getValueInRange({ startLineNumber: 1, @@ -46,13 +45,13 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli }); if (!word.endsWith(' ') && - !word.endsWith('.') && + !word.endsWith('.') && !word.endsWith('(')) { return; } try { - const isActivate = await await this.props.plugin.call('settings', 'get', 'settings/copilot/suggest/activate') + const isActivate = await await this.props.plugin.call('settings', 'get', 'settings/copilot/suggest/activate') if (!isActivate) return } catch (err) { return; @@ -63,8 +62,8 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli if (split.length < 2) return const ask = split[split.length - 2].trimStart() if (split[split.length - 1].trim() === '' && ask.startsWith('///')) { - // use the code generation model, only take max 1000 word as context - this.props.plugin.call('terminal', 'log', {type: 'aitypewriterwarning', value: 'Solcoder - generating code for following comment: ' + ask.replace('///', '')}) + // use the code generation model, only take max 1000 word as context + this.props.plugin.call('terminal', 'log', { type: 'aitypewriterwarning', value: 'Solcoder - generating code for following comment: ' + ask.replace('///', '') }) const data = await this.props.plugin.call('solcoder', 'code_generation', word) _paq.push(['trackEvent', 'ai', 'solcoder', 'code_generation']) @@ -81,17 +80,17 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli } catch (e) { console.error(e) return - } + } - if (word.split('\n').at(-1).trimStart().startsWith('//') || + if (word.split('\n').at(-1).trimStart().startsWith('//') || word.split('\n').at(-1).trimStart().startsWith('/*') || word.split('\n').at(-1).trimStart().startsWith('*') || word.split('\n').at(-1).trimStart().startsWith('*/') || - word.split('\n').at(-1).endsWith(';') + word.split('\n').at(-1).endsWith(';') ){ return; // do not do completion on single and multiline comment } - + // abort if there is a signal if (token.isCancellationRequested) { return @@ -104,10 +103,10 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli if (word.replace(/ +$/, '').endsWith('\n')){ // Code insertion - try{ + try { const output = await this.props.plugin.call('solcoder', 'code_insertion', word, word_after) _paq.push(['trackEvent', 'ai', 'solcoder', 'code_insertion']) - const generatedText = output[0] // no need to clean it. should already be + const generatedText = output[0] // no need to clean it. should already be const item: monacoTypes.languages.InlineCompletion = { insertText: generatedText @@ -166,7 +165,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli if (clean.startsWith('//') || clean.startsWith('/*') || clean.startsWith('*') || clean.startsWith('*/')){ return "" } - // remove comment inline + // remove comment inline clean = clean.split('//')[0].trimEnd() return clean } diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 16bd12b1cf..b43b97fe6d 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -152,16 +152,16 @@ export const EditorUI = (props: EditorUIProps) => { \t\t\t\t\t\t\t| |_) | | _| | |\\/| | | | \\ / | | | | | | | _| \t\t\t\t\t\t\t| _ < | |___ | | | | | | / \\ | | | |_| | | |___ \t\t\t\t\t\t\t|_| \\_\\ |_____| |_| |_| |___| /_/\\_\\ |___| |____/ |_____|\n\n - \t\t\t\t\t\t\t${intl.formatMessage({id: 'editor.keyboardShortcuts'})}:\n - \t\t\t\t\t\t\t\tCTRL + S: ${intl.formatMessage({id: 'editor.keyboardShortcuts.text1'})}\n - \t\t\t\t\t\t\t\tCTRL + Shift + F : ${intl.formatMessage({id: 'editor.keyboardShortcuts.text2'})}\n - \t\t\t\t\t\t\t\tCTRL + Shift + A : ${intl.formatMessage({id: 'editor.keyboardShortcuts.text3'})}\n - \t\t\t\t\t\t\t\tCTRL + SHIFT + S: ${intl.formatMessage({id: 'editor.keyboardShortcuts.text4'})}\n - \t\t\t\t\t\t\t${intl.formatMessage({id: 'editor.editorKeyboardShortcuts'})}:\n - \t\t\t\t\t\t\t\tCTRL + Alt + F : ${intl.formatMessage({id: 'editor.editorKeyboardShortcuts.text1'})}\n - \t\t\t\t\t\t\t${intl.formatMessage({id: 'editor.importantLinks'})}:\n - \t\t\t\t\t\t\t\t${intl.formatMessage({id: 'editor.importantLinks.text1'})}: https://remix-project.org/\n - \t\t\t\t\t\t\t\t${intl.formatMessage({id: 'editor.importantLinks.text2'})}: https://remix-ide.readthedocs.io/en/latest/\n + \t\t\t\t\t\t\t${intl.formatMessage({ id: 'editor.keyboardShortcuts' })}:\n + \t\t\t\t\t\t\t\tCTRL + S: ${intl.formatMessage({ id: 'editor.keyboardShortcuts.text1' })}\n + \t\t\t\t\t\t\t\tCTRL + Shift + F : ${intl.formatMessage({ id: 'editor.keyboardShortcuts.text2' })}\n + \t\t\t\t\t\t\t\tCTRL + Shift + A : ${intl.formatMessage({ id: 'editor.keyboardShortcuts.text3' })}\n + \t\t\t\t\t\t\t\tCTRL + SHIFT + S: ${intl.formatMessage({ id: 'editor.keyboardShortcuts.text4' })}\n + \t\t\t\t\t\t\t${intl.formatMessage({ id: 'editor.editorKeyboardShortcuts' })}:\n + \t\t\t\t\t\t\t\tCTRL + Alt + F : ${intl.formatMessage({ id: 'editor.editorKeyboardShortcuts.text1' })}\n + \t\t\t\t\t\t\t${intl.formatMessage({ id: 'editor.importantLinks' })}:\n + \t\t\t\t\t\t\t\t${intl.formatMessage({ id: 'editor.importantLinks.text1' })}: https://remix-project.org/\n + \t\t\t\t\t\t\t\t${intl.formatMessage({ id: 'editor.importantLinks.text2' })}: https://remix-ide.readthedocs.io/en/latest/\n \t\t\t\t\t\t\t\tGithub: https://github.com/ethereum/remix-project\n \t\t\t\t\t\t\t\tGitter: https://gitter.im/ethereum/remix\n \t\t\t\t\t\t\t\tMedium: https://medium.com/remix-ide\n @@ -472,7 +472,7 @@ export const EditorUI = (props: EditorUIProps) => { const addDecoration = (decoration: sourceAnnotation | sourceMarker, filePath: string, typeOfDecoration: string) => { const model = editorModelsState[filePath]?.model - if (!model) return { currentDecorations: [] } + if (!model) return { currentDecorations: []} const monacoDecoration = convertToMonacoDecoration(decoration, typeOfDecoration) return { currentDecorations: model.deltaDecorations([], [monacoDecoration]), @@ -629,7 +629,7 @@ export const EditorUI = (props: EditorUIProps) => { if (!pasteCodeRef.current && e && e.range && e.range.startLineNumber >= 0 && e.range.endLineNumber >= 0 && e.range.endLineNumber - e.range.startLineNumber > 10) { const modalContent: AlertModal = { id: 'newCodePasted', - title: intl.formatMessage({id: 'editor.title1'}), + title: intl.formatMessage({ id: 'editor.title1' }), message: (
{' '} @@ -638,7 +638,7 @@ export const EditorUI = (props: EditorUIProps) => {
- {chunks}}} /> + {chunks} }} />
@@ -670,7 +670,7 @@ export const EditorUI = (props: EditorUIProps) => { // add context menu items const zoominAction = { id: 'zoomIn', - label: intl.formatMessage({id: 'editor.zoomIn'}), + label: intl.formatMessage({ id: 'editor.zoomIn' }), contextMenuOrder: 0, // choose the order contextMenuGroupId: 'zooming', // create a new grouping keybindings: [ @@ -683,7 +683,7 @@ export const EditorUI = (props: EditorUIProps) => { } const zoomOutAction = { id: 'zoomOut', - label: intl.formatMessage({id: 'editor.zoomOut'}), + label: intl.formatMessage({ id: 'editor.zoomOut' }), contextMenuOrder: 0, // choose the order contextMenuGroupId: 'zooming', // create a new grouping keybindings: [ @@ -696,7 +696,7 @@ export const EditorUI = (props: EditorUIProps) => { } const formatAction = { id: 'autoFormat', - label: intl.formatMessage({id: 'editor.formatCode'}), + label: intl.formatMessage({ id: 'editor.formatCode' }), contextMenuOrder: 0, // choose the order contextMenuGroupId: 'formatting', // create a new grouping keybindings: [ @@ -712,14 +712,14 @@ export const EditorUI = (props: EditorUIProps) => { let gptGenerateDocumentationAction const executeGptGenerateDocumentationAction = { id: 'generateDocumentation', - label: intl.formatMessage({id: 'editor.generateDocumentation'}), + label: intl.formatMessage({ id: 'editor.generateDocumentation' }), contextMenuOrder: 0, // choose the order contextMenuGroupId: 'gtp', // create a new grouping keybindings: [], run: async () => { const file = await props.plugin.call('fileManager', 'getCurrentFile') const content = await props.plugin.call('fileManager', 'readFile', file) - const message = intl.formatMessage({id: 'editor.generateDocumentationByAI'}, {content, currentFunction: currentFunction.current}) + const message = intl.formatMessage({ id: 'editor.generateDocumentationByAI' }, { content, currentFunction: currentFunction.current }) await props.plugin.call('openaigpt', 'message', message) _paq.push(['trackEvent', 'ai', 'openai', 'generateDocumentation']) }, @@ -728,14 +728,14 @@ export const EditorUI = (props: EditorUIProps) => { let gptExplainFunctionAction const executegptExplainFunctionAction = { id: 'explainFunction', - label: intl.formatMessage({id: 'editor.explainFunction'}), + label: intl.formatMessage({ id: 'editor.explainFunction' }), contextMenuOrder: 1, // choose the order contextMenuGroupId: 'gtp', // create a new grouping keybindings: [], run: async () => { const file = await props.plugin.call('fileManager', 'getCurrentFile') const content = await props.plugin.call('fileManager', 'readFile', file) - const message = intl.formatMessage({id: 'editor.explainFunctionByAI'}, {content, currentFunction: currentFunction.current}) + const message = intl.formatMessage({ id: 'editor.explainFunctionByAI' }, { content, currentFunction: currentFunction.current }) await props.plugin.call('openaigpt', 'message', message) _paq.push(['trackEvent', 'ai', 'openai', 'explainFunction']) }, @@ -744,7 +744,7 @@ export const EditorUI = (props: EditorUIProps) => { let solgptExplainFunctionAction const executeSolgptExplainFunctionAction = { id: 'solExplainFunction', - label: intl.formatMessage({id: 'editor.explainFunctionSol'}), + label: intl.formatMessage({ id: 'editor.explainFunctionSol' }), contextMenuOrder: 1, // choose the order contextMenuGroupId: 'sol-gtp', // create a new grouping keybindings: [], @@ -758,12 +758,11 @@ export const EditorUI = (props: EditorUIProps) => { }, } - const freeFunctionCondition = editor.createContextKey('freeFunctionCondition', false) let freeFunctionAction const executeFreeFunctionAction = { id: 'executeFreeFunction', - label: intl.formatMessage({id: 'editor.executeFreeFunction'}), + label: intl.formatMessage({ id: 'editor.executeFreeFunction' }), contextMenuOrder: 0, // choose the order contextMenuGroupId: 'execute', // create a new grouping precondition: 'freeFunctionCondition', @@ -780,10 +779,10 @@ export const EditorUI = (props: EditorUIProps) => { const file = await props.plugin.call('fileManager', 'getCurrentFile') props.plugin.call('solidity-script', 'execute', file, freeFunctionNode.name) } else { - props.plugin.call('notification', 'toast', intl.formatMessage({id: 'editor.toastText1'})) + props.plugin.call('notification', 'toast', intl.formatMessage({ id: 'editor.toastText1' })) } } else { - props.plugin.call('notification', 'toast', intl.formatMessage({id: 'editor.toastText2'})) + props.plugin.call('notification', 'toast', intl.formatMessage({ id: 'editor.toastText2' })) } }, } @@ -824,27 +823,26 @@ export const EditorUI = (props: EditorUIProps) => { return } - const { nodesAtPosition } = await retrieveNodesAtPosition(props.editorAPI, props.plugin) const freeFunctionNode = nodesAtPosition.find((node) => node.kind === 'freeFunction') if (freeFunctionNode) { - executeFreeFunctionAction.label = intl.formatMessage({id: 'editor.executeFreeFunction2'}, {name: freeFunctionNode.name}) + executeFreeFunctionAction.label = intl.formatMessage({ id: 'editor.executeFreeFunction2' }, { name: freeFunctionNode.name }) freeFunctionAction = editor.addAction(executeFreeFunctionAction) } const functionImpl = nodesAtPosition.find((node) => node.kind === 'function') if (functionImpl) { currentFunction.current = functionImpl.name - executeGptGenerateDocumentationAction.label = intl.formatMessage({id: 'editor.generateDocumentation2'}, {name: functionImpl.name}) + executeGptGenerateDocumentationAction.label = intl.formatMessage({ id: 'editor.generateDocumentation2' }, { name: functionImpl.name }) gptGenerateDocumentationAction = editor.addAction(executeGptGenerateDocumentationAction) - executegptExplainFunctionAction.label = intl.formatMessage({id: 'editor.explainFunction2'}, {name: functionImpl.name}) + executegptExplainFunctionAction.label = intl.formatMessage({ id: 'editor.explainFunction2' }, { name: functionImpl.name }) gptExplainFunctionAction = editor.addAction(executegptExplainFunctionAction) - executeSolgptExplainFunctionAction.label = intl.formatMessage({id: 'editor.explainFunctionSol'}) + executeSolgptExplainFunctionAction.label = intl.formatMessage({ id: 'editor.explainFunctionSol' }) solgptExplainFunctionAction = editor.addAction(executeSolgptExplainFunctionAction) - }else{ + } else { // do not allow single character explaining if (editor.getModel().getValueInRange(editor.getSelection()).length <=1){ return} - executeSolgptExplainFunctionAction.label = intl.formatMessage({id: 'editor.explainFunctionSol'}) + executeSolgptExplainFunctionAction.label = intl.formatMessage({ id: 'editor.explainFunctionSol' }) solgptExplainFunctionAction = editor.addAction(executeSolgptExplainFunctionAction) } freeFunctionCondition.set(!!freeFunctionNode) @@ -892,7 +890,7 @@ export const EditorUI = (props: EditorUIProps) => { monacoRef.current.languages.register({ id: 'remix-circom' }) // Allow JSON schema requests - monacoRef.current.languages.json.jsonDefaults.setDiagnosticsOptions({enableSchemaRequest: true}) + monacoRef.current.languages.json.jsonDefaults.setDiagnosticsOptions({ enableSchemaRequest: true }) // Register a tokens provider for the language monacoRef.current.languages.setMonarchTokensProvider('remix-solidity', solidityTokensProvider as any) diff --git a/libs/remix-ui/editor/src/lib/syntaxes/move.ts b/libs/remix-ui/editor/src/lib/syntaxes/move.ts index f89188589e..f55d1dfc38 100644 --- a/libs/remix-ui/editor/src/lib/syntaxes/move.ts +++ b/libs/remix-ui/editor/src/lib/syntaxes/move.ts @@ -13,7 +13,7 @@ export const moveLanguageConfig = { { open: "[", close: "]" }, { open: "{", close: "}" }, { open: "(", close: ")" }, - { open: '"', close: '"', notIn: ["string"] }, + { open: '"', close: '"', notIn: ["string"]}, ], surroundingPairs: [ { open: "{", close: "}" }, diff --git a/libs/remix-ui/editor/src/lib/web-types.ts b/libs/remix-ui/editor/src/lib/web-types.ts index ae8253f65f..4dddad6159 100644 --- a/libs/remix-ui/editor/src/lib/web-types.ts +++ b/libs/remix-ui/editor/src/lib/web-types.ts @@ -28,7 +28,7 @@ export const loadTypes = async (monaco) => { const ethersBase64 = await import('raw-loader!@ethersproject/base64/lib/index.d.ts') const ethersBase64Default = ethersBase64.default.replace(/@ethersproject\//g, '@ethersproject_') monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersBase64Default, `file:///node_modules/@types/@ethersproject_base64/index.d.ts`) - + // @ts-ignore const ethersBasex = await import('raw-loader!@ethersproject/basex/lib/index.d.ts') const ethersBasexDefault = ethersBasex.default.replace(/@ethersproject\//g, '@ethersproject_') diff --git a/libs/remix-ui/file-decorators/src/lib/components/file-decoration-icon.tsx b/libs/remix-ui/file-decorators/src/lib/components/file-decoration-icon.tsx index b7506bc0c9..fdbeb4081c 100644 --- a/libs/remix-ui/file-decorators/src/lib/components/file-decoration-icon.tsx +++ b/libs/remix-ui/file-decorators/src/lib/components/file-decoration-icon.tsx @@ -1,7 +1,7 @@ // eslint-disable-next-line no-use-before-define -import React, {useEffect, useState} from 'react' +import React, { useEffect, useState } from 'react' -import {fileDecoration, fileDecorationType, FileType} from '../types' +import { fileDecoration, fileDecorationType, FileType } from '../types' import FileDecorationCustomIcon from './filedecorationicons/file-decoration-custom-icon' import FileDecorationErrorIcon from './filedecorationicons/file-decoration-error-icon' import FileDecorationTooltip from './filedecorationicons/file-decoration-tooltip' diff --git a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-custom-icon.tsx b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-custom-icon.tsx index af36c9c49e..59bc29823f 100644 --- a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-custom-icon.tsx +++ b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-custom-icon.tsx @@ -1,6 +1,6 @@ // eslint-disable-next-line no-use-before-define import React from 'react' -import {fileDecoration} from '../../types' +import { fileDecoration } from '../../types' const FileDecorationCustomIcon = (props: {fileDecoration: fileDecoration}) => { return ( diff --git a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx index 1aeebf0cf0..1d95295fec 100644 --- a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx +++ b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx @@ -1,7 +1,7 @@ // eslint-disable-next-line no-use-before-define import React from 'react' -import {fileDecoration} from '../../types' +import { fileDecoration } from '../../types' const FileDecorationErrorIcon = (props: {fileDecoration: fileDecoration}) => { return ( diff --git a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-tooltip.tsx b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-tooltip.tsx index 7eaf905a84..72a31f9817 100644 --- a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-tooltip.tsx +++ b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-tooltip.tsx @@ -1,6 +1,6 @@ import React from 'react' -import {OverlayTrigger, Popover} from 'react-bootstrap' -import {fileDecoration} from '../../types' +import { OverlayTrigger, Popover } from 'react-bootstrap' +import { fileDecoration } from '../../types' const FileDecorationTooltip = (props: {fileDecoration: fileDecoration; icon: JSX.Element; index: number}) => { const getComments = function (fileDecoration: fileDecoration) { @@ -22,7 +22,7 @@ const FileDecorationTooltip = (props: {fileDecoration: fileDecoration; icon: JSX placement="auto" overlay={ - +
{getComments(props.fileDecoration)}
diff --git a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-warning-icon.tsx b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-warning-icon.tsx index d8a574b926..3a5f601e35 100644 --- a/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-warning-icon.tsx +++ b/libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-warning-icon.tsx @@ -1,6 +1,6 @@ // eslint-disable-next-line no-use-before-define import React from 'react' -import {fileDecoration} from '../../types' +import { fileDecoration } from '../../types' const FileDecorationWarningIcon = (props: {fileDecoration: fileDecoration}) => { return ( diff --git a/libs/remix-ui/file-decorators/src/lib/helper/index.tsx b/libs/remix-ui/file-decorators/src/lib/helper/index.tsx index 92a0a448c2..8091eec8de 100644 --- a/libs/remix-ui/file-decorators/src/lib/helper/index.tsx +++ b/libs/remix-ui/file-decorators/src/lib/helper/index.tsx @@ -1,5 +1,5 @@ import React from 'react' -import {fileDecoration} from '../types' +import { fileDecoration } from '../types' export const getComments = function (fileDecoration: fileDecoration) { if (fileDecoration.comment) { diff --git a/libs/remix-ui/grid-view/src/lib/components/customCheckbox.tsx b/libs/remix-ui/grid-view/src/lib/components/customCheckbox.tsx index bd08f4d59a..102b80d72d 100644 --- a/libs/remix-ui/grid-view/src/lib/components/customCheckbox.tsx +++ b/libs/remix-ui/grid-view/src/lib/components/customCheckbox.tsx @@ -16,7 +16,7 @@ export const CustomCheckbox = (props: CustomCheckboxProps) => { if (!textColor || textColor == '') textColor = filterCon.keyValueMap[props.label].color return ( -
+
{ useEffect(() => { if (props.tagList) setAnyEnabled(props.tagList.some((key) => filterCon.keyValueMap[key]?.enabled)) - else setAnyEnabled(filterCon.showUntagged) + else setAnyEnabled(filterCon.showUntagged) }, [filterCon, props.tagList]) return ( @@ -39,11 +38,11 @@ export const RemixUIGridCell = (props: RemixUIGridCellProps) => { { anyEnabled &&
-
- { props.logo && } +
+ { props.logo && } { props.title && } @@ -75,7 +74,7 @@ export const RemixUIGridCell = (props: RemixUIGridCellProps) => { ) )) }
} - { !props.tagList && }
} diff --git a/libs/remix-ui/grid-view/src/lib/remix-ui-grid-view.tsx b/libs/remix-ui/grid-view/src/lib/remix-ui-grid-view.tsx index 19fdfe452c..4184de4967 100644 --- a/libs/remix-ui/grid-view/src/lib/remix-ui-grid-view.tsx +++ b/libs/remix-ui/grid-view/src/lib/remix-ui-grid-view.tsx @@ -1,7 +1,7 @@ import React, {useState, useEffect, useContext, useRef, ReactNode} from 'react' // eslint-disable-line import './remix-ui-grid-view.css' -import {ThemeContext, themes} from './themeContext' +import { ThemeContext, themes } from './themeContext' import CustomCheckbox from './components/customCheckbox' import FiltersContext from "./filtersContext" @@ -35,7 +35,7 @@ export const RemixUIGridView = (props: RemixUIGridViewProps) => { if (!color || color === '') color = setKeyValueMap[key].color setKeyValueMap((prevMap) => ({ ...prevMap, - [key]: {color, enabled}, + [key]: { color, enabled }, })) } @@ -52,7 +52,7 @@ export const RemixUIGridView = (props: RemixUIGridViewProps) => { })) } - const {plugin} = props.plugin + const { plugin } = props.plugin const searchInputRef = useRef(null) const [state, setState] = useState<{ @@ -65,13 +65,13 @@ export const RemixUIGridView = (props: RemixUIGridViewProps) => { useEffect(() => { if (props.tagList && Array.isArray(props.tagList)) { const initialKeyValueMap: Record = {}; - + // Limit to first 8 elements, ignoring the rest for (let i = 0; i < props.tagList.length; i++) { const [key, color] = props.tagList[i] - initialKeyValueMap[key] = { enabled: true, color } + initialKeyValueMap[key] = { enabled: true, color } } - if (showUntagged) initialKeyValueMap['no tag'] = { enabled: true, color: 'primary' } + if (showUntagged) initialKeyValueMap['no tag'] = { enabled: true, color: 'primary' } setKeyValueMap(initialKeyValueMap) } }, []) @@ -121,7 +121,7 @@ export const RemixUIGridView = (props: RemixUIGridViewProps) => { } > - + )} @@ -102,7 +102,7 @@ export const CustomMenu = React.forwardRef( const height = window.innerHeight * 0.6 return (
-
    +
      {children}
@@ -143,8 +143,8 @@ export const ProxyAddressToggle = React.forwardRef( }} className="udapp_input form-control" value={address} - placeholder={intl.formatMessage({id: 'udapp.enterProxyAddress'})} - style={{width: '100%'}} + placeholder={intl.formatMessage({ id: 'udapp.enterProxyAddress' })} + style={{ width: '100%' }} data-id="ERC1967AddressInput" />
diff --git a/libs/remix-ui/helper/src/lib/components/web3Dialog.tsx b/libs/remix-ui/helper/src/lib/components/web3Dialog.tsx index 234bbe5a5f..b313fb6c78 100644 --- a/libs/remix-ui/helper/src/lib/components/web3Dialog.tsx +++ b/libs/remix-ui/helper/src/lib/components/web3Dialog.tsx @@ -47,7 +47,7 @@ export function Web3ProviderDialog(props: web3ProviderDialogProps) { type="text" name="prompt_text" id="prompt_text" - style={{width: '100%'}} + style={{ width: '100%' }} className="form-control" defaultValue={props.externalEndpoint} data-id="modalDialogCustomPromptText" diff --git a/libs/remix-ui/helper/src/lib/helper-components.tsx b/libs/remix-ui/helper/src/lib/helper-components.tsx index ea7d833d64..663955414e 100644 --- a/libs/remix-ui/helper/src/lib/helper-components.tsx +++ b/libs/remix-ui/helper/src/lib/helper-components.tsx @@ -1,4 +1,4 @@ -import {LayoutCompatibilityReport} from '@openzeppelin/upgrades-core/dist/storage/report' +import { LayoutCompatibilityReport } from '@openzeppelin/upgrades-core/dist/storage/report' import React from 'react' export const fileChangedToastMsg = (from: string, path: string) => ( @@ -123,7 +123,7 @@ export const upgradeReportMsg = (report: LayoutCompatibilityReport) => (
- +
The storage layout of new implementation is NOT diff --git a/libs/remix-ui/helper/src/lib/remix-ui-helper.ts b/libs/remix-ui/helper/src/lib/remix-ui-helper.ts index 68ea85b72d..ac51759f6a 100644 --- a/libs/remix-ui/helper/src/lib/remix-ui-helper.ts +++ b/libs/remix-ui/helper/src/lib/remix-ui-helper.ts @@ -113,7 +113,7 @@ export const isHexadecimal = (value) => { return /^[0-9a-fA-F]+$/.test(value) && (value.length % 2 === 0) } -export const isValidHash = (hash) => { // 0x prefixed, hexadecimal, 64digit +export const isValidHash = (hash) => { // 0x prefixed, hexadecimal, 64digit const hexValue = hash.slice(2, hash.length) return is0XPrefixed(hash) && /^[0-9a-fA-F]{64}$/.test(hexValue) } @@ -138,6 +138,6 @@ export const shortenProxyAddress = (address: string) => { export const shortenDate = (dateString: string) => { const date = new Date(dateString) - + return date.toLocaleDateString(undefined, { month: "short", day: "numeric" }) + ', ' + date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' }) } diff --git a/libs/remix-ui/home-tab/src/lib/components/customNavButtons.tsx b/libs/remix-ui/home-tab/src/lib/components/customNavButtons.tsx index f7c611a0f3..d2725f5dc6 100644 --- a/libs/remix-ui/home-tab/src/lib/components/customNavButtons.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/customNavButtons.tsx @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import React from 'react' -const CustomNavButtons = ({parent, next, previous, goToSlide, ...rest}) => { +const CustomNavButtons = ({ parent, next, previous, goToSlide, ...rest }) => { const { - carouselState: {currentSlide, totalItems, containerWidth, transform} + carouselState: { currentSlide, totalItems, containerWidth, transform } } = rest return (
diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFeatured.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFeatured.tsx index 4478818e27..766dd494fc 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFeatured.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFeatured.tsx @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import React, {useEffect, useState, useRef, useContext} from 'react' -import {FormattedMessage} from 'react-intl' -import {ThemeContext, themes} from '../themeContext' +import React, { useEffect, useState, useRef, useContext } from 'react' +import { FormattedMessage } from 'react-intl' +import { ThemeContext, themes } from '../themeContext' import Carousel from 'react-multi-carousel' import 'react-multi-carousel/lib/styles.css' import * as releaseDetails from './../../../../../../releaseDetails.json' @@ -13,11 +13,11 @@ function HomeTabFeatured() { return (
-