From 0f1d0760359295eed7283a172598fc607f2a16b3 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 28 Apr 2021 10:47:06 +0200 Subject: [PATCH 01/30] use ethers.js 5.1.4 (#1142) to reproduce the issue: ``` contract C { error E(); function f() public { revert E(); } } ``` --- apps/remix-ide-e2e/src/tests/recorder.spec.ts | 2 +- package-lock.json | 578 +++++++++--------- package.json | 2 +- 3 files changed, 302 insertions(+), 280 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/recorder.spec.ts b/apps/remix-ide-e2e/src/tests/recorder.spec.ts index 970a1179f9..58e1f867ae 100644 --- a/apps/remix-ide-e2e/src/tests/recorder.spec.ts +++ b/apps/remix-ide-e2e/src/tests/recorder.spec.ts @@ -83,7 +83,7 @@ module.exports = { .testFunction('last', { status: 'true Transaction mined and execution succeed', - 'decoded input': { 'uint256 _po': { type: 'BigNumber', hex: '0x0a' } } + 'decoded input': { 'uint256 _po': '10' } }) .end() } diff --git a/package-lock.json b/package-lock.json index 75be37b1d3..ca2eb9f4a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2516,249 +2516,253 @@ } }, "@ethersproject/abi": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.0.7.tgz", - "integrity": "sha512-Cqktk+hSIckwP/W8O47Eef60VwmoSC/L3lY0+dIBhQPCNn9E4V7rwmm2aFrNRRDJfFlGuZ1khkQUOc3oBX+niw==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.1.2.tgz", + "integrity": "sha512-uMhoQVPX0UtfzTpekYQSEUcJGDgsJ25ifz+SV6PDETWaUFhcR8RNgb1QPTASP13inW8r6iy0/Xdq9D5hK2pNvA==", "dev": true, "requires": { - "@ethersproject/address": "^5.0.4", - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/constants": "^5.0.4", - "@ethersproject/hash": "^5.0.4", - "@ethersproject/keccak256": "^5.0.3", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/properties": "^5.0.3", - "@ethersproject/strings": "^5.0.4" + "@ethersproject/address": "^5.1.0", + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/constants": "^5.1.0", + "@ethersproject/hash": "^5.1.0", + "@ethersproject/keccak256": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/strings": "^5.1.0" } }, "@ethersproject/abstract-provider": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.0.5.tgz", - "integrity": "sha512-i/CjElAkzV7vQBAeoz+IpjGfcFYEP9eD7j3fzZ0fzTq03DO7PPnR+xkEZ1IoDXGwDS+55aLM1xvLDwB/Lx6IOQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.1.0.tgz", + "integrity": "sha512-8dJUnT8VNvPwWhYIau4dwp7qe1g+KgdRm4XTWvjkI9gAT2zZa90WF5ApdZ3vl1r6NDmnn6vUVvyphClRZRteTQ==", "dev": true, "requires": { - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/networks": "^5.0.3", - "@ethersproject/properties": "^5.0.3", - "@ethersproject/transactions": "^5.0.5", - "@ethersproject/web": "^5.0.6" + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/networks": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/transactions": "^5.1.0", + "@ethersproject/web": "^5.1.0" } }, "@ethersproject/abstract-signer": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.0.6.tgz", - "integrity": "sha512-h8TZBX3pL2Xx9tmsRxfWcaaI+FcJFHWvZ/vNvFjLp8zJ0kPD501LKTt2jo44LZ20N3EW68JMoyEmRQ6bpsn+iA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.1.0.tgz", + "integrity": "sha512-qQDMkjGZSSJSKl6AnfTgmz9FSnzq3iEoEbHTYwjDlEAv+LNP7zd4ixCcVWlWyk+2siud856M5CRhAmPdupeN9w==", "dev": true, "requires": { - "@ethersproject/abstract-provider": "^5.0.4", - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/properties": "^5.0.3" + "@ethersproject/abstract-provider": "^5.1.0", + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/properties": "^5.1.0" } }, "@ethersproject/address": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.0.5.tgz", - "integrity": "sha512-DpkQ6rwk9jTefrRsJzEm6nhRiJd9pvhn1xN0rw5N/jswXG5r7BLk/GVA0mMAVWAsYfvi2xSc5L41FMox43RYEA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.1.0.tgz", + "integrity": "sha512-rfWQR12eHn2cpstCFS4RF7oGjfbkZb0oqep+BfrT+gWEGWG2IowJvIsacPOvzyS1jhNF4MQ4BS59B04Mbovteg==", "dev": true, "requires": { - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/keccak256": "^5.0.3", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/rlp": "^5.0.3", - "bn.js": "^4.4.0" + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/keccak256": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/rlp": "^5.1.0" } }, "@ethersproject/base64": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.0.4.tgz", - "integrity": "sha512-4KRykQ7BQMeOXfvio1YITwHjxwBzh92UoXIdzxDE1p53CK28bbHPdsPNYo0wl0El7lJAMpT2SOdL0hhbWRnyIA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.1.0.tgz", + "integrity": "sha512-npD1bLvK4Bcxz+m4EMkx+F8Rd7CnqS9DYnhNu0/GlQBXhWjvfoAZzk5HJ0f1qeyp8d+A86PTuzLOGOXf4/CN8g==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4" + "@ethersproject/bytes": "^5.1.0" } }, "@ethersproject/basex": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.0.4.tgz", - "integrity": "sha512-ixIr/kKiAoSzOnSc777AGIOAhKai5Ivqr4HO/Gz+YG+xkfv6kqD6AW4ga9vM20Wwb0QBhh3LoRWTu4V1K+x9Ew==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.1.0.tgz", + "integrity": "sha512-vBKr39bum7DDbOvkr1Sj19bRMEPA4FnST6Utt6xhDzI7o7L6QNkDn2yrCfP+hnvJGhZFKtLygWwqlTBZoBXYLg==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/properties": "^5.0.3" + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/properties": "^5.1.0" } }, "@ethersproject/bignumber": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.0.8.tgz", - "integrity": "sha512-KXFVAFKS1jdTXYN8BE5Oj+ZfPMh28iRdFeNGBVT6cUFdtiPVqeXqc0ggvBqA3A1VoFFGgM7oAeaagA393aORHA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.1.1.tgz", + "integrity": "sha512-AVz5iqz7+70RIqoQTznsdJ6DOVBYciNlvO+AlQmPTB6ofCvoihI9bQdr6wljsX+d5W7Yc4nyvQvP4JMzg0Agig==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/logger": "^5.0.5", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/logger": "^5.1.0", "bn.js": "^4.4.0" } }, "@ethersproject/bytes": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.0.5.tgz", - "integrity": "sha512-IEj9HpZB+ACS6cZ+QQMTqmu/cnUK2fYNE6ms/PVxjoBjoxc6HCraLpam1KuRvreMy0i523PLmjN8OYeikRdcUQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.1.0.tgz", + "integrity": "sha512-sGTxb+LVjFxJcJeUswAIK6ncgOrh3D8c192iEJd7mLr95V6du119rRfYT/b87WPkZ5I3gRBUYIYXtdgCWACe8g==", "dev": true, "requires": { - "@ethersproject/logger": "^5.0.5" + "@ethersproject/logger": "^5.1.0" } }, "@ethersproject/constants": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.0.5.tgz", - "integrity": "sha512-foaQVmxp2+ik9FrLUCtVrLZCj4M3Ibgkqvh+Xw/vFRSerkjVSYePApaVE5essxhoSlF1U9oXfWY09QI2AXtgKA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.1.0.tgz", + "integrity": "sha512-0/SuHrxc8R8k+JiLmJymxHJbojUDWBQqO+b+XFdwaP0jGzqC09YDy/CAlSZB6qHsBifY8X3I89HcK/oMqxRdBw==", "dev": true, "requires": { - "@ethersproject/bignumber": "^5.0.7" + "@ethersproject/bignumber": "^5.1.0" } }, "@ethersproject/contracts": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.0.5.tgz", - "integrity": "sha512-tFI255lFbmbqMkgnuyhDWHl3yWqttPlReplYuVvDCT/SuvBjLR4ad2uipBlh1fh5X1ipK9ettAoV4S0HKim4Kw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.1.1.tgz", + "integrity": "sha512-6WwktLJ0DFWU8pDkgH4IGttQHhQN4SnwKFu9h+QYVe48VGWtbDu4W8/q/7QA1u/HWlWMrKxqawPiZUJj0UMvOw==", "dev": true, "requires": { - "@ethersproject/abi": "^5.0.5", - "@ethersproject/abstract-provider": "^5.0.4", - "@ethersproject/abstract-signer": "^5.0.4", - "@ethersproject/address": "^5.0.4", - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/constants": "^5.0.4", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/properties": "^5.0.3" + "@ethersproject/abi": "^5.1.0", + "@ethersproject/abstract-provider": "^5.1.0", + "@ethersproject/abstract-signer": "^5.1.0", + "@ethersproject/address": "^5.1.0", + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/constants": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/transactions": "^5.1.0" } }, "@ethersproject/hash": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.0.5.tgz", - "integrity": "sha512-GpI80/h2HDpfNKpCZoxQJCjOQloGnlD5hM1G+tZe8FQDJhEvFjJoPDuWv+NaYjJfOciKS2Axqc4Q4WamdLoUgg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.1.0.tgz", + "integrity": "sha512-fNwry20yLLPpnRRwm3fBL+2ksgO+KMadxM44WJmRIoTKzy4269+rbq9KFoe2LTqq2CXJM2CE70beGaNrpuqflQ==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/keccak256": "^5.0.3", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/strings": "^5.0.4" + "@ethersproject/abstract-signer": "^5.1.0", + "@ethersproject/address": "^5.1.0", + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/keccak256": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/strings": "^5.1.0" } }, "@ethersproject/hdnode": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.0.5.tgz", - "integrity": "sha512-Ho4HZaK+KijE5adayvjAGusWMnT0mgwGa5hGMBofBOgX9nqiKf6Wxx68SXBGI1/L3rmKo6mlAjxUd8gefs0teQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.1.0.tgz", + "integrity": "sha512-obIWdlujloExPHWJGmhJO/sETOOo7SEb6qemV4f8kyFoXg+cJK+Ta9SvBrj7hsUK85n3LZeZJZRjjM7oez3Clg==", "dev": true, "requires": { - "@ethersproject/abstract-signer": "^5.0.4", - "@ethersproject/basex": "^5.0.3", - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/pbkdf2": "^5.0.3", - "@ethersproject/properties": "^5.0.3", - "@ethersproject/sha2": "^5.0.3", - "@ethersproject/signing-key": "^5.0.4", - "@ethersproject/strings": "^5.0.4", - "@ethersproject/transactions": "^5.0.5", - "@ethersproject/wordlists": "^5.0.4" + "@ethersproject/abstract-signer": "^5.1.0", + "@ethersproject/basex": "^5.1.0", + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/pbkdf2": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/sha2": "^5.1.0", + "@ethersproject/signing-key": "^5.1.0", + "@ethersproject/strings": "^5.1.0", + "@ethersproject/transactions": "^5.1.0", + "@ethersproject/wordlists": "^5.1.0" } }, "@ethersproject/json-wallets": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.0.7.tgz", - "integrity": "sha512-dgOn9JtGgjT28mDXs4LYY2rT4CzS6bG/rxoYuPq3TLHIf6nmvBcr33Fee6RrM/y8UAx4gyIkf6wb2cXsOctvQQ==", - "dev": true, - "requires": { - "@ethersproject/abstract-signer": "^5.0.4", - "@ethersproject/address": "^5.0.4", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/hdnode": "^5.0.4", - "@ethersproject/keccak256": "^5.0.3", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/pbkdf2": "^5.0.3", - "@ethersproject/properties": "^5.0.3", - "@ethersproject/random": "^5.0.3", - "@ethersproject/strings": "^5.0.4", - "@ethersproject/transactions": "^5.0.5", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.1.0.tgz", + "integrity": "sha512-00n2iBy27w8zrGZSiU762UOVuzCQZxUZxopsZC47++js6xUFuI74DHcJ5K/2pddlF1YBskvmMuboEu1geK8mnA==", + "dev": true, + "requires": { + "@ethersproject/abstract-signer": "^5.1.0", + "@ethersproject/address": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/hdnode": "^5.1.0", + "@ethersproject/keccak256": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/pbkdf2": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/random": "^5.1.0", + "@ethersproject/strings": "^5.1.0", + "@ethersproject/transactions": "^5.1.0", "aes-js": "3.0.0", "scrypt-js": "3.0.1" } }, "@ethersproject/keccak256": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.0.4.tgz", - "integrity": "sha512-GNpiOUm9PGUxFNqOxYKDQBM0u68bG9XC9iOulEQ8I0tOx/4qUpgVzvgXL6ugxr0RY554Gz/NQsVqknqPzUcxpQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.1.0.tgz", + "integrity": "sha512-vrTB1W6AEYoadww5c9UyVJ2YcSiyIUTNDRccZIgwTmFFoSHwBtcvG1hqy9RzJ1T0bMdATbM9Hfx2mJ6H0i7Hig==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", + "@ethersproject/bytes": "^5.1.0", "js-sha3": "0.5.7" } }, "@ethersproject/logger": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.0.6.tgz", - "integrity": "sha512-FrX0Vnb3JZ1md/7GIZfmJ06XOAA8r3q9Uqt9O5orr4ZiksnbpXKlyDzQtlZ5Yv18RS8CAUbiKH9vwidJg1BPmQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.1.0.tgz", + "integrity": "sha512-wtUaD1lBX10HBXjjKV9VHCBnTdUaKQnQ2XSET1ezglqLdPdllNOIlLfhyCRqXm5xwcjExVI5ETokOYfjPtaAlw==", "dev": true }, "@ethersproject/networks": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.0.4.tgz", - "integrity": "sha512-/wHDTRms5mpJ09BoDrbNdFWINzONe05wZRgohCXvEv39rrH/Gd/yAnct8wC0RsW3tmFOgjgQxuBvypIxuUynTw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.1.0.tgz", + "integrity": "sha512-A/NIrIED/G/IgU1XUukOA3WcFRxn2I4O5GxsYGA5nFlIi+UZWdGojs85I1VXkR1gX9eFnDXzjE6OtbgZHjFhIA==", "dev": true, "requires": { - "@ethersproject/logger": "^5.0.5" + "@ethersproject/logger": "^5.1.0" } }, "@ethersproject/pbkdf2": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.0.4.tgz", - "integrity": "sha512-9jVBjHXQKfr9+3bkCg01a8Cd1H9e+7Kw3ZMIvAxD0lZtuzrXsJxm1hVwY9KA+PRUvgS/9tTP4viXQYwLAax7zg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.1.0.tgz", + "integrity": "sha512-B8cUbHHTgs8OtgJIafrRcz/YPDobVd5Ru8gTnShOiM9EBuFpYHQpq3+8iQJ6pyczDu6HP/oc/njAsIBhwFZYew==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/sha2": "^5.0.3" + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/sha2": "^5.1.0" } }, "@ethersproject/properties": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.0.4.tgz", - "integrity": "sha512-UdyX3GqBxFt15B0uSESdDNmhvEbK3ACdDXl2soshoPcneXuTswHDeA0LoPlnaZzhbgk4p6jqb4GMms5C26Qu6A==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.1.0.tgz", + "integrity": "sha512-519KKTwgmH42AQL3+GFV3SX6khYEfHsvI6v8HYejlkigSDuqttdgVygFTDsGlofNFchhDwuclrxQnD5B0YLNMg==", "dev": true, "requires": { - "@ethersproject/logger": "^5.0.5" + "@ethersproject/logger": "^5.1.0" } }, "@ethersproject/providers": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.0.11.tgz", - "integrity": "sha512-SD82AMgUpDgqvSPJxjVgSqMBde9LsIAfroS3YcK2dE/VUuVeJQFWtjFbkFRF4pjTd2u+qYXh0eo1gq7LU7B1YQ==", - "dev": true, - "requires": { - "@ethersproject/abstract-provider": "^5.0.4", - "@ethersproject/abstract-signer": "^5.0.4", - "@ethersproject/address": "^5.0.4", - "@ethersproject/basex": "^5.0.3", - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/constants": "^5.0.4", - "@ethersproject/hash": "^5.0.4", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/networks": "^5.0.3", - "@ethersproject/properties": "^5.0.3", - "@ethersproject/random": "^5.0.3", - "@ethersproject/rlp": "^5.0.3", - "@ethersproject/sha2": "^5.0.3", - "@ethersproject/strings": "^5.0.4", - "@ethersproject/transactions": "^5.0.5", - "@ethersproject/web": "^5.0.6", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.1.2.tgz", + "integrity": "sha512-GqsS8rd+eyd4eNkcNgzZ4l9IRULBPUZa7JPnv22k4MHflMobUseyhfbVnmoN5bVNNkOxjV1IPTw9i0sV1hwdpg==", + "dev": true, + "requires": { + "@ethersproject/abstract-provider": "^5.1.0", + "@ethersproject/abstract-signer": "^5.1.0", + "@ethersproject/address": "^5.1.0", + "@ethersproject/basex": "^5.1.0", + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/constants": "^5.1.0", + "@ethersproject/hash": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/networks": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/random": "^5.1.0", + "@ethersproject/rlp": "^5.1.0", + "@ethersproject/sha2": "^5.1.0", + "@ethersproject/strings": "^5.1.0", + "@ethersproject/transactions": "^5.1.0", + "@ethersproject/web": "^5.1.0", "bech32": "1.1.4", "ws": "7.2.3" }, @@ -2772,33 +2776,33 @@ } }, "@ethersproject/random": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.0.4.tgz", - "integrity": "sha512-AIZJhqs6Ba4/+U3lOjt3QZbP6b/kuuGLJUYFUonAgWmkTHwqsCwYnFvnHKQSUuHbXHvErp7WFXFlztx+yMn3kQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.1.0.tgz", + "integrity": "sha512-+uuczLQZ4+no9cP6TCoCktXx0u2YbNaRT7lRkSt12d8263e702f0u+4JnnRO8Qmv5nylWJebnqCHzyxP+6mLqw==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/logger": "^5.0.5" + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/logger": "^5.1.0" } }, "@ethersproject/rlp": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.0.4.tgz", - "integrity": "sha512-5qrrZad7VTjofxSsm7Zg/7Dr4ZOln4S2CqiDdOuTv6MBKnXj0CiBojXyuDy52M8O3wxH0CyE924hXWTDV1PQWQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.1.0.tgz", + "integrity": "sha512-vDTyHIwNPrecy55gKGZ47eJZhBm8LLBxihzi5ou+zrSvYTpkSTWRcKUlXFDFQVwfWB+P5PGyERAdiDEI76clxw==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/logger": "^5.0.5" + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/logger": "^5.1.0" } }, "@ethersproject/sha2": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.0.4.tgz", - "integrity": "sha512-0yFhf1mspxAfWdXXoPtK94adUeu1R7/FzAa+DfEiZTc76sz/vHXf0LSIazoR3znYKFny6haBxME+usbvvEcF3A==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.1.0.tgz", + "integrity": "sha512-+fNSeZRstOpdRJpdGUkRONFCaiAqWkc91zXgg76Nlp5ndBQE25Kk5yK8gCPG1aGnCrbariiPr5j9DmrYH78JCA==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/logger": "^5.0.5", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/logger": "^5.1.0", "hash.js": "1.1.3" }, "dependencies": { @@ -2815,116 +2819,134 @@ } }, "@ethersproject/signing-key": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.0.5.tgz", - "integrity": "sha512-Z1wY7JC1HVO4CvQWY2TyTTuAr8xK3bJijZw1a9G92JEmKdv1j255R/0YLBBcFTl2J65LUjtXynNJ2GbArPGi5g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.1.0.tgz", + "integrity": "sha512-tE5LFlbmdObG8bY04NpuwPWSRPgEswfxweAI1sH7TbP0ml1elNfqcq7ii/3AvIN05i5U0Pkm3Tf8bramt8MmLw==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/properties": "^5.0.3", - "elliptic": "6.5.3" + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "bn.js": "^4.4.0", + "elliptic": "6.5.4" + }, + "dependencies": { + "elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, + "requires": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + } } }, "@ethersproject/solidity": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.0.5.tgz", - "integrity": "sha512-DMFQ0ouXmNVoKWbGEUFGi8Urli4SJip9jXafQyFHWPRr5oJUqDVkNfwcyC37k+mhBG93k7qrYXCH2xJnGEOxHg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.1.0.tgz", + "integrity": "sha512-kPodsGyo9zg1g9XSXp1lGhFaezBAUUsAUB1Vf6OkppE5Wksg4Et+x3kG4m7J/uShDMP2upkJtHNsIBK2XkVpKQ==", "dev": true, "requires": { - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/keccak256": "^5.0.3", - "@ethersproject/sha2": "^5.0.3", - "@ethersproject/strings": "^5.0.4" + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/keccak256": "^5.1.0", + "@ethersproject/sha2": "^5.1.0", + "@ethersproject/strings": "^5.1.0" } }, "@ethersproject/strings": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.0.5.tgz", - "integrity": "sha512-JED6WaIV00xM/gvj8vSnd+0VWtDYdidTmavFRCTQakqfz+4tDo6Jz5LHgG+dd45h7ah7ykCHW0C7ZXWEDROCXQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.1.0.tgz", + "integrity": "sha512-perBZy0RrmmL0ejiFGUOlBVjMsUceqLut3OBP3zP96LhiJWWbS8u1NqQVgN4/Gyrbziuda66DxiQocXhsvx+Sw==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/constants": "^5.0.4", - "@ethersproject/logger": "^5.0.5" + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/constants": "^5.1.0", + "@ethersproject/logger": "^5.1.0" } }, "@ethersproject/transactions": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.0.6.tgz", - "integrity": "sha512-htsFhOD+NMBxx676A8ehSuwVV49iqpSB+CkjPZ02tpNew0K6p8g0CZ46Z1ZP946gIHAU80xQ0NACHYrjIUaCFA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.1.1.tgz", + "integrity": "sha512-Nwgbp09ttIVN0OoUBatCXaHxR7grWPHbozJN8v7AXDLrl6nnOIBEMDh+yJTnosSQlFhcyjfTGGN+Mx6R8HdvMw==", "dev": true, "requires": { - "@ethersproject/address": "^5.0.4", - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/constants": "^5.0.4", - "@ethersproject/keccak256": "^5.0.3", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/properties": "^5.0.3", - "@ethersproject/rlp": "^5.0.3", - "@ethersproject/signing-key": "^5.0.4" + "@ethersproject/address": "^5.1.0", + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/constants": "^5.1.0", + "@ethersproject/keccak256": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/rlp": "^5.1.0", + "@ethersproject/signing-key": "^5.1.0" } }, "@ethersproject/units": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.0.5.tgz", - "integrity": "sha512-XHZZIA+o4Sfne9ycWWdoCpMQSpTAF1V1fxNIfgFAVYBp0JKZp4YypDdHCDleAP4rPuFgSNeJqZyb3kAe1VJMkg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.1.0.tgz", + "integrity": "sha512-isvJrx6qG0nKWfxsGORNjmOq/nh175fStfvRTA2xEKrGqx8JNJY83fswu4GkILowfriEM/eYpretfJnfzi7YhA==", "dev": true, "requires": { - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/constants": "^5.0.4", - "@ethersproject/logger": "^5.0.5" + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/constants": "^5.1.0", + "@ethersproject/logger": "^5.1.0" } }, "@ethersproject/wallet": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.0.5.tgz", - "integrity": "sha512-NbrKmsW3w+5dVOEyVCN5VAAIp3y8ckutW6AV7Lo0Hn8RO9mLT8ZFzLGp4lzgJoxkm+EV8BE+x1N6NdiOgUzRng==", - "dev": true, - "requires": { - "@ethersproject/abstract-provider": "^5.0.4", - "@ethersproject/abstract-signer": "^5.0.4", - "@ethersproject/address": "^5.0.4", - "@ethersproject/bignumber": "^5.0.7", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/hash": "^5.0.4", - "@ethersproject/hdnode": "^5.0.4", - "@ethersproject/json-wallets": "^5.0.6", - "@ethersproject/keccak256": "^5.0.3", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/properties": "^5.0.3", - "@ethersproject/random": "^5.0.3", - "@ethersproject/signing-key": "^5.0.4", - "@ethersproject/transactions": "^5.0.5", - "@ethersproject/wordlists": "^5.0.4" + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.1.0.tgz", + "integrity": "sha512-ULmUtiYQLTUS+y3DgkLzRhFEK10zMwmjOthnjiZxee3Q/MVwr3rnmuAnXIUZrPjna6hvUPnyRIdW5XuF0Ld0YQ==", + "dev": true, + "requires": { + "@ethersproject/abstract-provider": "^5.1.0", + "@ethersproject/abstract-signer": "^5.1.0", + "@ethersproject/address": "^5.1.0", + "@ethersproject/bignumber": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/hash": "^5.1.0", + "@ethersproject/hdnode": "^5.1.0", + "@ethersproject/json-wallets": "^5.1.0", + "@ethersproject/keccak256": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/random": "^5.1.0", + "@ethersproject/signing-key": "^5.1.0", + "@ethersproject/transactions": "^5.1.0", + "@ethersproject/wordlists": "^5.1.0" } }, "@ethersproject/web": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.0.8.tgz", - "integrity": "sha512-5An1sar40zXUYmBLH+P1m0F3mTi8lNBV/usLKP3AYBdSxPQyQWymLAEPyX7x5/eBpQAwCInLtF7LPMm9HPI28g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.1.0.tgz", + "integrity": "sha512-LTeluWgTq04+RNqAkVhpydPcRZK/kKxD2Vy7PYGrAD27ABO9kTqTBKwiOuzTyAHKUQHfnvZbXmxBXJAGViSDcA==", "dev": true, "requires": { - "@ethersproject/base64": "^5.0.3", - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/properties": "^5.0.3", - "@ethersproject/strings": "^5.0.4" + "@ethersproject/base64": "^5.1.0", + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/strings": "^5.1.0" } }, "@ethersproject/wordlists": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.0.5.tgz", - "integrity": "sha512-XA3ycFltVrCTQt04w5nHu3Xq5Z6HjqWsXaAYQHFdqtugyUsIumaO9S5MOwFFuUYTNkZUoT3jCRa/OBS+K4tLfA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.1.0.tgz", + "integrity": "sha512-NsUCi/TpBb+oTFvMSccUkJGtp5o/84eOyqp5q5aBeiNBSLkYyw21znRn9mAmxZgySpxgruVgKbaapnYPgvctPQ==", "dev": true, "requires": { - "@ethersproject/bytes": "^5.0.4", - "@ethersproject/hash": "^5.0.4", - "@ethersproject/logger": "^5.0.5", - "@ethersproject/properties": "^5.0.3", - "@ethersproject/strings": "^5.0.4" + "@ethersproject/bytes": "^5.1.0", + "@ethersproject/hash": "^5.1.0", + "@ethersproject/logger": "^5.1.0", + "@ethersproject/properties": "^5.1.0", + "@ethersproject/strings": "^5.1.0" } }, "@evocateur/libnpmaccess": { @@ -16508,41 +16530,41 @@ } }, "ethers": { - "version": "5.0.16", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.0.16.tgz", - "integrity": "sha512-MsE/N07DRAq6LtvtXUougAPouGoLMWMoJ7iD4OoYXtyZpXG9UsWYPfvCrIEYeUhGBWOeaHBamrT5X9dQQ2NYqQ==", - "dev": true, - "requires": { - "@ethersproject/abi": "5.0.7", - "@ethersproject/abstract-provider": "5.0.5", - "@ethersproject/abstract-signer": "5.0.6", - "@ethersproject/address": "5.0.5", - "@ethersproject/base64": "5.0.4", - "@ethersproject/basex": "5.0.4", - "@ethersproject/bignumber": "5.0.8", - "@ethersproject/bytes": "5.0.5", - "@ethersproject/constants": "5.0.5", - "@ethersproject/contracts": "5.0.5", - "@ethersproject/hash": "5.0.5", - "@ethersproject/hdnode": "5.0.5", - "@ethersproject/json-wallets": "5.0.7", - "@ethersproject/keccak256": "5.0.4", - "@ethersproject/logger": "5.0.6", - "@ethersproject/networks": "5.0.4", - "@ethersproject/pbkdf2": "5.0.4", - "@ethersproject/properties": "5.0.4", - "@ethersproject/providers": "5.0.11", - "@ethersproject/random": "5.0.4", - "@ethersproject/rlp": "5.0.4", - "@ethersproject/sha2": "5.0.4", - "@ethersproject/signing-key": "5.0.5", - "@ethersproject/solidity": "5.0.5", - "@ethersproject/strings": "5.0.5", - "@ethersproject/transactions": "5.0.6", - "@ethersproject/units": "5.0.5", - "@ethersproject/wallet": "5.0.5", - "@ethersproject/web": "5.0.8", - "@ethersproject/wordlists": "5.0.5" + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.1.4.tgz", + "integrity": "sha512-EAPQ/fgGRu0PoR/VNFnHTMOtG/IZ0AItdW55C9T8ffmVu0rnyllZL404eBF66elJehOLz2kxnUrhXpE7TCpW7g==", + "dev": true, + "requires": { + "@ethersproject/abi": "5.1.2", + "@ethersproject/abstract-provider": "5.1.0", + "@ethersproject/abstract-signer": "5.1.0", + "@ethersproject/address": "5.1.0", + "@ethersproject/base64": "5.1.0", + "@ethersproject/basex": "5.1.0", + "@ethersproject/bignumber": "5.1.1", + "@ethersproject/bytes": "5.1.0", + "@ethersproject/constants": "5.1.0", + "@ethersproject/contracts": "5.1.1", + "@ethersproject/hash": "5.1.0", + "@ethersproject/hdnode": "5.1.0", + "@ethersproject/json-wallets": "5.1.0", + "@ethersproject/keccak256": "5.1.0", + "@ethersproject/logger": "5.1.0", + "@ethersproject/networks": "5.1.0", + "@ethersproject/pbkdf2": "5.1.0", + "@ethersproject/properties": "5.1.0", + "@ethersproject/providers": "5.1.2", + "@ethersproject/random": "5.1.0", + "@ethersproject/rlp": "5.1.0", + "@ethersproject/sha2": "5.1.0", + "@ethersproject/signing-key": "5.1.0", + "@ethersproject/solidity": "5.1.0", + "@ethersproject/strings": "5.1.0", + "@ethersproject/transactions": "5.1.1", + "@ethersproject/units": "5.1.0", + "@ethersproject/wallet": "5.1.0", + "@ethersproject/web": "5.1.0", + "@ethersproject/wordlists": "5.1.0" } }, "ethjs-unit": { diff --git a/package.json b/package.json index eb2d33e79e..d67f99f74f 100644 --- a/package.json +++ b/package.json @@ -236,7 +236,7 @@ "eslint-plugin-promise": "4.2.1", "eslint-plugin-standard": "4.0.1", "ethereumjs-util": "^6.2.0", - "ethers": "^5.0.13", + "ethers": "^5.1.4", "events": "^3.0.0", "execr": "^1.0.1", "exorcist": "^0.4.0", From 3ebe32d2e6e01b3286230dd14408aab7b98a9aee Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 27 Apr 2021 11:24:01 +0200 Subject: [PATCH 02/30] fix tracking of outlinks --- apps/remix-ide/src/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/index.html b/apps/remix-ide/src/index.html index 22b2497d16..8c03eaa392 100644 --- a/apps/remix-ide/src/index.html +++ b/apps/remix-ide/src/index.html @@ -43,9 +43,9 @@ var _paq = window._paq = window._paq || [] /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['disableCookies']); - _paq.push(['enableLinkTracking']); - _paq.push(['enableJSErrorTracking']); + _paq.push(['enableJSErrorTracking']); _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); (function() { var u="https://matomo.ethereum.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']) From 873390029611fdae9ecd54f8b58cfd4812c55dd8 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Tue, 27 Apr 2021 12:21:01 +0200 Subject: [PATCH 03/30] Update index.html --- apps/remix-ide/src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/index.html b/apps/remix-ide/src/index.html index 8c03eaa392..6741c21c19 100644 --- a/apps/remix-ide/src/index.html +++ b/apps/remix-ide/src/index.html @@ -43,7 +43,7 @@ var _paq = window._paq = window._paq || [] /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['disableCookies']); - _paq.push(['enableJSErrorTracking']); + _paq.push(['enableJSErrorTracking']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { From 6e5622a3b99f2bfa74eaed91ce75bc1e5ea616ae Mon Sep 17 00:00:00 2001 From: filip mertens Date: Tue, 13 Apr 2021 11:23:39 +0200 Subject: [PATCH 04/30] fix for not deactivating rm console --- .../src/app/components/plugin-manager-component.js | 2 +- apps/remix-ide/src/app/panels/tab-proxy.js | 2 +- apps/remix-ide/src/remixAppManager.js | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index e3d519b55a..14494138a1 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -108,7 +108,7 @@ class PluginManagerComponent extends ViewPlugin { } deactivateP (name) { - this.appManager.deactivatePlugin(name) + this.call('manager', 'deactivatePlugin', name) _paq.push(['trackEvent', 'manager', 'deactivate', name]) } diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index 179a37065c..24edfa1da6 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -128,7 +128,7 @@ export class TabProxy extends Plugin { () => this.event.emit('switchApp', name), () => { this.event.emit('closeApp', name) - this.appManager.deactivatePlugin(name) + this.call('manager', 'deactivatePlugin', name) }, icon ) diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 610260f59b..4947c3b68d 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -52,6 +52,16 @@ export class RemixAppManager extends PluginManager { return isNative(from.name) } + async deactivatePlugin (name) { + const [to, from] = [ + await this.getProfile(name), + await this.getProfile(this.requestFrom) + ] + if (this.canDeactivatePlugin(from, to)) { + await this.toggleActive(name) + } + } + async canCall (from, to, method, message) { // Make sure the caller of this methods is the target plugin if (to !== this.currentRequest.from) { From 2ba70d9d1953d198efe5990926d66be795071055 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 30 Apr 2021 07:59:06 +0200 Subject: [PATCH 05/30] show message if debugging on kovan (#1149) fix https://github.com/ethereum/remix-project/issues/459 --- libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx index 3a700b60e2..9dfa0e2ade 100644 --- a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx @@ -166,6 +166,19 @@ export const DebuggerUI = (props: DebuggerUIProps) => { } const web3 = await debuggerModule.getDebugWeb3() + try { + if (await web3.eth.net.getId() === 42) { + setState(prevState => { + return { + ...prevState, + validationError: 'The Kovan network is unfortunately not supported.' + } + }) + return + } + } catch (e) { + console.error(e) + } let currentReceipt try { currentReceipt = await web3.eth.getTransactionReceipt(txNumber) From 5fbded38caa471716eb3c8671834f95966cd8adb Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 30 Apr 2021 09:06:02 +0200 Subject: [PATCH 06/30] better url scheme (#1148) fix https://github.com/ethereum/remix-project/issues/773 --- apps/remix-ide-e2e/src/tests/publishContract.test.ts | 2 +- apps/remix-ide/src/publishToStorage.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/publishContract.test.ts b/apps/remix-ide-e2e/src/tests/publishContract.test.ts index 83cc9dda04..afdb9e68f7 100644 --- a/apps/remix-ide-e2e/src/tests/publishContract.test.ts +++ b/apps/remix-ide-e2e/src/tests/publishContract.test.ts @@ -22,7 +22,7 @@ module.exports = { .pause(8000) .getModalBody((value, done) => { if (value.indexOf('Metadata of "ballot" was published successfully.') === -1) browser.assert.fail('ipfs deploy failed', '', '') - if (value.indexOf('dweb:/ipfs') === -1) browser.assert.fail('ipfs deploy failed', '', '') + if (value.indexOf('ipfs://') === -1) browser.assert.fail('ipfs deploy failed', '', '') done() }) .modalFooterOKClick() diff --git a/apps/remix-ide/src/publishToStorage.js b/apps/remix-ide/src/publishToStorage.js index f3c1ed5b6f..5803d9a6a6 100644 --- a/apps/remix-ide/src/publishToStorage.js +++ b/apps/remix-ide/src/publishToStorage.js @@ -34,7 +34,7 @@ export default function publish (storage, fileProvider, fileManager, contract) { ${err}`) } else { var result = yo`
${uploaded.map((value) => { - return yo`
${value.filename} :
${value.output.url}
` + return yo`
${value.filename} :
${value.output.url.replace('dweb:/ipfs/', 'ipfs://')}
` })}
` modalDialogCustom.alert(`Published ${contract.name}'s Metadata`, yo`Metadata of "${contract.name.toLowerCase()}" was published successfully.
${result}
`) } From 38ca5c56b488d1b7c50a6d8da332da2185738ea4 Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 10 Apr 2021 02:06:33 +0100 Subject: [PATCH 07/30] refactor: added custom checkbox for static analyser plugin --- apps/remix-ide/src/app/tabs/analysis-tab.js | 49 ++- libs/remix-ui/static-analyser/.babelrc | 4 + libs/remix-ui/static-analyser/.eslintrc | 19 + libs/remix-ui/static-analyser/README.md | 7 + libs/remix-ui/static-analyser/src/index.ts | 1 + .../src/lib/Button/StaticAnalyserButton.tsx | 23 ++ .../lib/Checkbox/StaticAnalyserCheckedBox.tsx | 45 +++ .../static-analyser/src/lib/ErrorRenderer.tsx | 76 ++++ .../src/lib/remix-ui-static-analyser.tsx | 381 ++++++++++++++++++ libs/remix-ui/static-analyser/tsconfig.json | 16 + .../static-analyser/tsconfig.lib.json | 13 + nx.json | 3 + package-lock.json | 6 +- package.json | 1 + tsconfig.json | 5 +- workspace.json | 19 + 16 files changed, 647 insertions(+), 21 deletions(-) create mode 100644 libs/remix-ui/static-analyser/.babelrc create mode 100644 libs/remix-ui/static-analyser/.eslintrc create mode 100644 libs/remix-ui/static-analyser/README.md create mode 100644 libs/remix-ui/static-analyser/src/index.ts create mode 100644 libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx create mode 100644 libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx create mode 100644 libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx create mode 100644 libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx create mode 100644 libs/remix-ui/static-analyser/tsconfig.json create mode 100644 libs/remix-ui/static-analyser/tsconfig.lib.json diff --git a/apps/remix-ide/src/app/tabs/analysis-tab.js b/apps/remix-ide/src/app/tabs/analysis-tab.js index 4406ba875e..ad3c2fce54 100644 --- a/apps/remix-ide/src/app/tabs/analysis-tab.js +++ b/apps/remix-ide/src/app/tabs/analysis-tab.js @@ -1,9 +1,11 @@ +import React from 'react' // eslint-disable-line import { ViewPlugin } from '@remixproject/engine-web' +import ReactDOM from 'react-dom' import { EventEmitter } from 'events' +import {RemixUiStaticAnalyser} from '@remix-ui/static-analyser' // eslint-disable-line import * as packageJson from '../../../../../package.json' +var Renderer = require('../ui/renderer') -var yo = require('yo-yo') -var StaticAnalysis = require('./staticanalysis/staticAnalysisView') var EventManager = require('../../lib/events') const profile = { @@ -25,24 +27,39 @@ class AnalysisTab extends ViewPlugin { this.event = new EventManager() this.events = new EventEmitter() this.registry = registry + this.element = document.createElement('div') + this.element.setAttribute('id', 'staticAnalyserView') + this._components = { + renderer: new Renderer(this) + } + this._components.registry = this.registry + this._deps = { + offsetToLineColumnConverter: this.registry.get( + 'offsettolinecolumnconverter').api + } + } + + onActivation () { + this.renderComponent() } render () { - this.staticanalysis = new StaticAnalysis(this.registry, this) - this.staticanalysis.event.register('staticAnaysisWarning', (count) => { - if (count > 0) { - this.emit('statusChanged', { key: count, title: `${count} warning${count === 1 ? '' : 's'}`, type: 'warning' }) - } else if (count === 0) { - this.emit('statusChanged', { key: 'succeed', title: 'no warning', type: 'success' }) - } else { - // count ==-1 no compilation result - this.emit('statusChanged', { key: 'none' }) - } - }) - this.registry.put({ api: this.staticanalysis, name: 'staticanalysis' }) - - return yo`
${this.staticanalysis.render()}
` + return this.element } + + renderComponent () { + ReactDOM.render( + , + this.element + ) + } + } module.exports = AnalysisTab diff --git a/libs/remix-ui/static-analyser/.babelrc b/libs/remix-ui/static-analyser/.babelrc new file mode 100644 index 0000000000..09d67939cc --- /dev/null +++ b/libs/remix-ui/static-analyser/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["@nrwl/react/babel"], + "plugins": [] +} diff --git a/libs/remix-ui/static-analyser/.eslintrc b/libs/remix-ui/static-analyser/.eslintrc new file mode 100644 index 0000000000..dae5c6feeb --- /dev/null +++ b/libs/remix-ui/static-analyser/.eslintrc @@ -0,0 +1,19 @@ +{ + "env": { + "browser": true, + "es6": true + }, + "extends": "../../../.eslintrc", + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parserOptions": { + "ecmaVersion": 11, + "sourceType": "module" + }, + "rules": { + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": "error" + } +} diff --git a/libs/remix-ui/static-analyser/README.md b/libs/remix-ui/static-analyser/README.md new file mode 100644 index 0000000000..7e4b95c0e5 --- /dev/null +++ b/libs/remix-ui/static-analyser/README.md @@ -0,0 +1,7 @@ +# remix-ui-static-analyser + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test remix-ui-static-analyser` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/remix-ui/static-analyser/src/index.ts b/libs/remix-ui/static-analyser/src/index.ts new file mode 100644 index 0000000000..86a00ccd14 --- /dev/null +++ b/libs/remix-ui/static-analyser/src/index.ts @@ -0,0 +1 @@ +export * from './lib/remix-ui-static-analyser' diff --git a/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx b/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx new file mode 100644 index 0000000000..5cd7e9392b --- /dev/null +++ b/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx @@ -0,0 +1,23 @@ +import React from 'react' //eslint-disable-line + +interface StaticAnalyserButtonProps { + onClick: (event) => void + buttonText: string, + disabled?: boolean +} + +const StaticAnalyserButton = ({ + onClick, + buttonText, + disabled +}: StaticAnalyserButtonProps) => { + return ( +
+ +
+ ) +} + +export default StaticAnalyserButton diff --git a/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx b/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx new file mode 100644 index 0000000000..2326a39122 --- /dev/null +++ b/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx @@ -0,0 +1,45 @@ +import React from 'react' //eslint-disable-line + +interface StaticAnalyserCheckBoxProps { + onClick?: (event) => void + onChange?: (event) => void + label?: string + inputType?: string + name?: string + checked?: boolean + id?: string + itemName?: string + categoryId?: string +} + +const StaticAnalyserCheckedBox = ({ + id, + label, + onClick, + inputType, + name, + checked, + onChange, + itemName, + categoryId +}: StaticAnalyserCheckBoxProps) => { + return ( +
+ + +
+ ) +} + +export default StaticAnalyserCheckedBox diff --git a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx new file mode 100644 index 0000000000..7b7a01f37d --- /dev/null +++ b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx @@ -0,0 +1,76 @@ +import React, { useState } from 'react' //eslint-disable-line + +interface ErrorRendererProps { + message: any; + opt: any, + warningErrors: any +} + +const ErrorRenderer = ({ message, opt }: ErrorRendererProps) => { + const [, setError] = useState( + { + row: null, + column: null, + text: null, + type: null, + errFile: null + } + ) + const getPositionDetails = (msg: any) => { + const result = { } as any + + // To handle some compiler warning without location like SPDX license warning etc + if (!msg.includes(':')) return { errLine: -1, errCol: -1, errFile: msg } + + // extract line / column + let position = msg.match(/^(.*?):([0-9]*?):([0-9]*?)?/) + result.errLine = position ? parseInt(position[2]) - 1 : -1 + result.errCol = position ? parseInt(position[3]) : -1 + + // extract file + position = msg.match(/^(https:.*?|http:.*?|.*?):/) + result.errFile = position ? position[1] : '' + return result + } + if (!message) return + let position = getPositionDetails(message) + if (!position.errFile || (opt.errorType && opt.errorType === position.errFile)) { + // Updated error reported includes '-->' before file details + const errorDetails = message.split('-->') + // errorDetails[1] will have file details + if (errorDetails.length > 1) position = getPositionDetails(errorDetails[1]) + } + opt.errLine = position.errLine + opt.errCol = position.errCol + opt.errFile = position.errFile.trim() + if (!opt.noAnnotations && opt.errFile) { + setError({ + errFile: opt.errFile, + row: opt.errLine, + column: opt.errCol, + text: message, + type: opt.type + }) + } + const classList = opt.type === 'error' ? 'alert alert-danger' : 'alert alert-warning' + return ( +
+
+
+ +
+ + {opt.item.name} + { opt.item.warning } + {opt.item.more + ? more + : + } + Pos: {opt.locationString} + +
+
+ ) +} + +export default ErrorRenderer diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx new file mode 100644 index 0000000000..1674d66d84 --- /dev/null +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -0,0 +1,381 @@ +import React, { useEffect, useState } from 'react' +import CheckBox from './Checkbox/StaticAnalyserCheckedBox' // eslint-disable-line +import Button from './Button/StaticAnalyserButton' // eslint-disable-line +import remixLib from '@remix-project/remix-lib' +import _ from 'lodash' +import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line +import ErrorRenderer from './ErrorRenderer' // eslint-disable-line +const StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis +const utils = remixLib.util + +/* eslint-disable-next-line */ +export interface RemixUiStaticAnalyserProps { + renderStaticAnalysis: any + staticanalysis: any + analysisRunner: any, + lastCompilationResult: any, + lastCompilationSource: any, + registry: any, + event: any, + analysisModule: any + _deps: any +} + +export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { + const [runner] = useState(new StaticAnalysisRunner()) + + const preProcessModules = (arr: any) => { + return arr.map((Item, i) => { + const itemObj = new Item() + itemObj._index = i + itemObj.categoryDisplayName = itemObj.category.displayName + itemObj.categoryId = itemObj.category.id + return itemObj + }) + } + + const groupedModules = utils.groupBy( + preProcessModules(runner.modules()), + 'categoryId' + ) + + const getIndex = (modules, array) => { + Object.values(modules).map((value: {_index}) => { + if (Array.isArray(value)) { + value.forEach((x) => { + array.push(x._index.toString()) + }) + } else { + array.push(value._index.toString()) + } + }) + } + + const groupedModuleIndex = (modules) => { + const indexOfCategory = [] + if (!_.isEmpty(modules)) { + getIndex(modules, indexOfCategory) + } + return indexOfCategory + } + + const [categoryIndex, setCategoryIndex] = useState(groupedModuleIndex(groupedModules)) + + const warningContainer = React.useRef(null) + const [runButtonState, setRunButtonState] = useState(true) + const [autoRun, setAutoRun] = useState(true) + const [result, setResult] = useState({ + lastCompilationResult: null, + lastCompilationSource: null, + currentFile: 'No file compiled' + }) + const [, setModuleNameResult] = useState(null) + const [, setWarning] = useState({ + msg: '', + options: {}, + hasWarning: false, + warningErrors: [] + }) + const [warningState, setWarningState] = useState([]) + + useEffect(() => { + if (autoRun) { + const setCompilationResult = async (data, source, file) => { + await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) + } + + if (props.analysisModule) { + console.log({ autoRun }) + props.analysisModule.on( + 'solidity', + 'compilationFinished', + (file, source, languageVersion, data) => { + if (languageVersion.indexOf('soljson') !== 0) return + setCompilationResult(data, source, file) + run(data, source, file) + } + ) + } + } + return () => { } + }, [autoRun]) + + const run = (lastCompilationResult, lastCompilationSource, currentFile) => { + // const highlightLocation = async (location, fileName) => { + // await props.analysisModule.call('editor', 'discardHighlight') + // await props.analysisModule.call('editor', 'highlight', location, fileName) + // } + setResult({ lastCompilationResult, lastCompilationSource, currentFile }) + if (lastCompilationResult && categoryIndex.length) { + setRunButtonState(false) + let warningCount = 0 + const warningMessage = [] + + runner.run(lastCompilationResult, categoryIndex, results => { + results.map((result) => { + let moduleName + Object.keys(groupedModules).map(key => { + groupedModules[key].forEach(el => { + if (el.name === result.name) { + moduleName = groupedModules[key][0].categoryDisplayName + } + }) + }) + setModuleNameResult(moduleName) + const warningErrors = [] + result.report.map((item) => { + let location: any = {} + let locationString = 'not available' + let column = 0 + let row = 0 + let fileName = currentFile + if (item.location) { + var split = item.location.split(':') + var file = split[2] + location = { + start: parseInt(split[0]), + length: parseInt(split[1]) + } + location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn( + location, + parseInt(file), + lastCompilationSource.sources, + lastCompilationResult.sources + ) + row = location.start.line + column = location.start.column + locationString = row + 1 + ':' + column + ':' + fileName = Object.keys(lastCompilationResult.contracts)[file] + } + warningCount++ + const msg = ` + + ${result.name} + ${item.warning} + ${item.more + ? `more` + : ' ' + } + Pos: ${locationString} + ` + const options = { + type: 'warning', + useSpan: true, + errFile: fileName, + errLine: row, + errCol: column, + item: item, + name: result.name, + locationString, + more: item.more + } + warningErrors.push(options) + setWarning({ msg, hasWarning: true, options, warningErrors: warningErrors }) + warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName }) + }) + }) + const resultArray = [] + warningMessage.map(x => { + resultArray.push(x) + }) + function groupBy (objectArray, property) { + return objectArray.reduce((acc, obj) => { + const key = obj[property] + if (!acc[key]) { + acc[key] = [] + } + // Add object to list for given key's value + acc[key].push(obj) + return acc + }, {}) + } + + const groupedCategory = groupBy(resultArray, 'warningModuleName') + setWarningState(groupedCategory) + }) + props.event.trigger('staticAnaysisWarning', [warningCount]) + } else { + setRunButtonState(true) + if (categoryIndex.length) { + warningContainer.current.innerText = 'No compiled AST available' + } + props.event.trigger('staticAnaysisWarning', [-1]) + } + } + + // const correctRunBtnDisabled = () => { + // if (props.lastCompilationResult && selectedCategoryIndex.length !== 0) { + // setRunButtonState(false) + // } else { + // setRunButtonState(true) + // } + // } + + const handleCheckAllModules = (groupedModules) => { + const index = groupedModuleIndex(groupedModules) + if (index.every(el => categoryIndex.includes(el))) { + setCategoryIndex( + categoryIndex.filter((el) => { + return !index.includes(el) + }) + ) + } else { + setCategoryIndex(_.uniq([...categoryIndex, ...index])) + } + } + + const handleCheckOrUncheckCategory = (category) => { + const index = groupedModuleIndex(category) + if (index.every(el => categoryIndex.includes(el))) { + setCategoryIndex( + categoryIndex.filter((el) => { + return !index.includes(el) + }) + ) + } else { + setCategoryIndex(_.uniq([...categoryIndex, ...index])) + } + } + + const handleAutoRun = () => { + if (autoRun) { + setAutoRun(false) + } else { + setAutoRun(true) + } + console.log(' auton run function') + } + + const handleCheckSingle = (event, _index) => { + _index = _index.toString() + if (categoryIndex.includes(_index)) { + setCategoryIndex(categoryIndex.filter(val => val !== _index)) + } else { + setCategoryIndex(_.uniq([...categoryIndex, _index])) + } + } + + const categoryItem = (categoryId, item, i) => { + return ( +
+ handleCheckSingle(event, item._index)} + checked={categoryIndex.includes(item._index.toString())} + /> +
+ ) + } + + const categorySection = (category, categoryId, i) => { + return ( +
+
+ + + {category[0].categoryDisplayName} +
+ +
+ + } + expand={true} + > +
+ handleCheckOrUncheckCategory(category)} id={categoryId} inputType="checkbox" label={`Select ${category[0].categoryDisplayName}`} name='checkCategoryEntry' checked={category.map(x => x._index.toString()).every(el => categoryIndex.includes(el))} /> +
+
+ {category.map((item, i) => { + return ( + categoryItem(categoryId, item, i) + ) + })} +
+
+
+
+
+ ) + } + + return ( +
+
+
+
+ { + return (value.map(x => { + return x._index.toString() + })) + }).flat().every(el => categoryIndex.includes(el))} + label="Select all" + onClick={() => handleCheckAllModules(groupedModules)} + /> +
+
+ +
+
+
+
+ {Object.keys(groupedModules).map((categoryId, i) => { + const category = groupedModules[categoryId] + return ( + categorySection(category, categoryId, i) + ) + }) + } +
+
+ last results for: + + {result.currentFile && result.currentFile} + +
+
+
+ { + (Object.entries(warningState).map((element) => ( + <> + {element[0]} + {element[1].map(x => ( + x.hasWarning ? () : null + ))} + + ))) + } +
+
+
+ ) +} + +export default RemixUiStaticAnalyser diff --git a/libs/remix-ui/static-analyser/tsconfig.json b/libs/remix-ui/static-analyser/tsconfig.json new file mode 100644 index 0000000000..6b65264565 --- /dev/null +++ b/libs/remix-ui/static-analyser/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "jsx": "react", + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ] +} diff --git a/libs/remix-ui/static-analyser/tsconfig.lib.json b/libs/remix-ui/static-analyser/tsconfig.lib.json new file mode 100644 index 0000000000..b560bc4dec --- /dev/null +++ b/libs/remix-ui/static-analyser/tsconfig.lib.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "types": ["node"] + }, + "files": [ + "../../../node_modules/@nrwl/react/typings/cssmodule.d.ts", + "../../../node_modules/@nrwl/react/typings/image.d.ts" + ], + "exclude": ["**/*.spec.ts", "**/*.spec.tsx"], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/nx.json b/nx.json index 5cf047d9cc..802b6fe374 100644 --- a/nx.json +++ b/nx.json @@ -95,6 +95,9 @@ }, "remix-ui-workspace": { "tags": [] + }, + "remix-ui-static-analyser": { + "tags": [] } } } diff --git a/package-lock.json b/package-lock.json index ca2eb9f4a5..d0c0ce7b6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25004,9 +25004,9 @@ } }, "lodash": { - "version": "4.17.19", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", - "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "lodash-es": { "version": "4.17.15", diff --git a/package.json b/package.json index d67f99f74f..0b7fcd4372 100644 --- a/package.json +++ b/package.json @@ -154,6 +154,7 @@ "http-server": "^0.11.1", "isbinaryfile": "^3.0.2", "jszip": "^3.6.0", + "lodash": "^4.17.21", "merge": "^1.2.0", "npm-install-version": "^6.0.2", "react": "16.13.1", diff --git a/tsconfig.json b/tsconfig.json index c2a383e9de..c90ed09031 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "target": "es2015", "module": "commonjs", "typeRoots": ["node_modules/@types"], - "lib": ["es2017", "dom"], + "lib": ["es2017", "es2019", "dom"], "skipLibCheck": true, "skipDefaultLibCheck": true, "baseUrl": ".", @@ -38,7 +38,8 @@ "@remix-ui/modal-dialog": ["libs/remix-ui/modal-dialog/src/index.ts"], "@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"], "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], - "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"] + "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"], + "@remix-ui/static-analyser": ["libs/remix-ui/static-analyser/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] diff --git a/workspace.json b/workspace.json index 10793e13b3..9c734f96a7 100644 --- a/workspace.json +++ b/workspace.json @@ -725,6 +725,25 @@ } } } + }, + "remix-ui-static-analyser": { + "root": "libs/remix-ui/static-analyser", + "sourceRoot": "libs/remix-ui/static-analyser/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@nrwl/linter:lint", + "options": { + "linter": "eslint", + "tsConfig": ["libs/remix-ui/static-analyser/tsconfig.lib.json"], + "exclude": [ + "**/node_modules/**", + "!libs/remix-ui/static-analyser/**/*" + ] + } + } + } } }, "cli": { From a628dc527ffb1308609b68c55f530a32027c06ce Mon Sep 17 00:00:00 2001 From: tizah Date: Mon, 12 Apr 2021 12:51:49 +0100 Subject: [PATCH 08/30] added warning sign when analysis has runned --- apps/remix-ide/src/app/tabs/analysis-tab.js | 15 +++++++++++++-- .../src/lib/remix-ui-static-analyser.tsx | 19 +++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/analysis-tab.js b/apps/remix-ide/src/app/tabs/analysis-tab.js index ad3c2fce54..b3bba2705c 100644 --- a/apps/remix-ide/src/app/tabs/analysis-tab.js +++ b/apps/remix-ide/src/app/tabs/analysis-tab.js @@ -56,10 +56,21 @@ class AnalysisTab extends ViewPlugin { analysisModule={this} event={this.event} />, - this.element + this.element, + () => { + this.event.register('staticAnaysisWarning', (count) => { + if (count > 0) { + this.emit('statusChanged', { key: count, title: `${count} warning${count === 1 ? '' : 's'}`, type: 'warning' }) + } else if (count === 0) { + this.emit('statusChanged', { key: 'succeed', title: 'no warning', type: 'success' }) + } else { + // count ==-1 no compilation result + this.emit('statusChanged', { key: 'none' }) + } + }) + } ) } - } module.exports = AnalysisTab diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 1674d66d84..81d4e29e15 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -1,4 +1,5 @@ import React, { useEffect, useState } from 'react' +import ReactDOM from 'react-dom' //eslint-disable-line import CheckBox from './Checkbox/StaticAnalyserCheckedBox' // eslint-disable-line import Button from './Button/StaticAnalyserButton' // eslint-disable-line import remixLib from '@remix-project/remix-lib' @@ -18,7 +19,8 @@ export interface RemixUiStaticAnalyserProps { registry: any, event: any, analysisModule: any - _deps: any + _deps: any, + emit: any } export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { @@ -63,7 +65,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const warningContainer = React.useRef(null) const [runButtonState, setRunButtonState] = useState(true) - const [autoRun, setAutoRun] = useState(true) + const [autoRun, setAutoRun] = useState(false) const [result, setResult] = useState({ lastCompilationResult: null, lastCompilationSource: null, @@ -96,7 +98,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } ) } + } else { + setAutoRun(true) } + return () => { } }, [autoRun]) @@ -105,6 +110,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { // await props.analysisModule.call('editor', 'discardHighlight') // await props.analysisModule.call('editor', 'highlight', location, fileName) // } + console.log({ autoRun }, ' auto run in run function') setResult({ lastCompilationResult, lastCompilationSource, currentFile }) if (lastCompilationResult && categoryIndex.length) { setRunButtonState(false) @@ -193,6 +199,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const groupedCategory = groupBy(resultArray, 'warningModuleName') setWarningState(groupedCategory) }) + props.event.trigger('staticAnaysisWarning', [warningCount]) } else { setRunButtonState(true) @@ -203,14 +210,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } } - // const correctRunBtnDisabled = () => { - // if (props.lastCompilationResult && selectedCategoryIndex.length !== 0) { - // setRunButtonState(false) - // } else { - // setRunButtonState(true) - // } - // } - const handleCheckAllModules = (groupedModules) => { const index = groupedModuleIndex(groupedModules) if (index.every(el => categoryIndex.includes(el))) { From 9ed34b1fe0775ebe679e44116ffdf7b4b7f74d67 Mon Sep 17 00:00:00 2001 From: tizah Date: Mon, 12 Apr 2021 13:05:48 +0100 Subject: [PATCH 09/30] removed icon: fas fa-angle-double-right from each category display name --- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 81d4e29e15..b1810c3143 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -288,9 +288,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { data-bs-target={`#heading${categoryId}`} > {category[0].categoryDisplayName} -
- -
} expand={true} From ec571d6d9987091f04299974b1fbcd29ffd5dc37 Mon Sep 17 00:00:00 2001 From: tizah Date: Tue, 13 Apr 2021 18:37:37 +0100 Subject: [PATCH 10/30] adding a condition to fix ci build --- .../src/lib/remix-ui-static-analyser.tsx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index b1810c3143..5000a94c01 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -356,20 +356,22 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { {result.currentFile && result.currentFile} -
-
- { - (Object.entries(warningState).map((element) => ( - <> - {element[0]} - {element[1].map(x => ( - x.hasWarning ? () : null - ))} - - ))) - } + { Object.entries(warningState).length > 0 && +
+
+ { + (Object.entries(warningState).map((element) => ( + <> + {element[0]} + {element[1].map(x => ( + x.hasWarning ? () : null + ))} + + ))) + } +
-
+ }
) } From fabe95b995607ccf9b84608f3019d45c3493cfa0 Mon Sep 17 00:00:00 2001 From: tizah Date: Fri, 16 Apr 2021 06:49:06 +0100 Subject: [PATCH 11/30] fix: testing to see if test passes --- apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts | 2 +- libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx | 2 +- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index a68a4a24ce..b2c3f41cb6 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -41,7 +41,7 @@ function runTests (browser: NightwatchBrowser) { .testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['TooMuchGas', 'test1', 'test2']) .clickLaunchIcon('solidityStaticAnalysis') .click('#staticanalysisView button') - .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { + .waitForElementPresent('#staticanalysisresult .warning', 2000, false, function () { listSelectorContains(['Use of tx.origin', 'Fallback function of contract TooMuchGas requires too much gas', 'TooMuchGas.() : Variables have very similar names "test" and "test1".', diff --git a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx index 7b7a01f37d..878cccb7da 100644 --- a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx +++ b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx @@ -60,7 +60,7 @@ const ErrorRenderer = ({ message, opt }: ErrorRendererProps) => { - {opt.item.name} + {opt.name} { opt.item.warning } {opt.item.more ? more diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 5000a94c01..6a6edde1a7 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -164,6 +164,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } Pos: ${locationString} ` + console.log(result.name, ' result name now') const options = { type: 'warning', useSpan: true, From 4fe702e00619f6253d27bd3ba08cd2bee517844d Mon Sep 17 00:00:00 2001 From: tizah Date: Fri, 16 Apr 2021 09:19:39 +0100 Subject: [PATCH 12/30] added className staticAnalysisView to staticAnalyser component --- apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts | 2 +- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index b2c3f41cb6..a68a4a24ce 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -41,7 +41,7 @@ function runTests (browser: NightwatchBrowser) { .testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['TooMuchGas', 'test1', 'test2']) .clickLaunchIcon('solidityStaticAnalysis') .click('#staticanalysisView button') - .waitForElementPresent('#staticanalysisresult .warning', 2000, false, function () { + .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { listSelectorContains(['Use of tx.origin', 'Fallback function of contract TooMuchGas requires too much gas', 'TooMuchGas.() : Variables have very similar names "test" and "test1".', diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 6a6edde1a7..93b1b6b3a4 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -313,7 +313,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return (
-
+
Date: Fri, 16 Apr 2021 09:54:37 +0100 Subject: [PATCH 13/30] remove className staticAnalysisView and added id = staticanalysisView --- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 93b1b6b3a4..8e42d97ce4 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -313,7 +313,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return (
-
+
Date: Sat, 17 Apr 2021 06:07:13 +0100 Subject: [PATCH 14/30] fix: moved staticanalysisButton id to the Button component --- apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts | 2 +- .../static-analyser/src/lib/Button/StaticAnalyserButton.tsx | 2 +- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index a68a4a24ce..504148b266 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -40,7 +40,7 @@ function runTests (browser: NightwatchBrowser) { .pause(10000) .testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['TooMuchGas', 'test1', 'test2']) .clickLaunchIcon('solidityStaticAnalysis') - .click('#staticanalysisView button') + .click('#staticanalysisButton button') .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { listSelectorContains(['Use of tx.origin', 'Fallback function of contract TooMuchGas requires too much gas', diff --git a/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx b/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx index 5cd7e9392b..336a0fe56a 100644 --- a/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx +++ b/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx @@ -12,7 +12,7 @@ const StaticAnalyserButton = ({ disabled }: StaticAnalyserButtonProps) => { return ( -
+
diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 8e42d97ce4..6a6edde1a7 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -313,7 +313,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return (
-
+
Date: Sat, 17 Apr 2021 06:27:48 +0100 Subject: [PATCH 15/30] fix: removed disabled props on button --- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 6a6edde1a7..38e4988a0f 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -336,7 +336,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { label="Autorun" />
-
From 602adfb5dfc9066ea685047c64f6103a79582c46 Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 17 Apr 2021 06:52:33 +0100 Subject: [PATCH 16/30] reversed changes --- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 38e4988a0f..6a6edde1a7 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -336,7 +336,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { label="Autorun" />
-
From f3a136f8e2c9a53a6e020fabab844de301c7beed Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 17 Apr 2021 17:49:24 +0100 Subject: [PATCH 17/30] commiting code to detect failing test --- .../src/tests/staticAnalysis.spec.ts | 24 +++++++++---------- .../src/lib/remix-ui-static-analyser.tsx | 4 ---- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index 504148b266..480fab63fb 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -40,18 +40,18 @@ function runTests (browser: NightwatchBrowser) { .pause(10000) .testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['TooMuchGas', 'test1', 'test2']) .clickLaunchIcon('solidityStaticAnalysis') - .click('#staticanalysisButton button') - .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { - listSelectorContains(['Use of tx.origin', - 'Fallback function of contract TooMuchGas requires too much gas', - 'TooMuchGas.() : Variables have very similar names "test" and "test1".', - 'TooMuchGas.() : Variables have very similar names "test" and "test1".'], - '#staticanalysisresult .warning', - browser, function () { - browser.end() - } - ) - }) + //.click('#staticanalysisButton button') + // .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { + // listSelectorContains(['Use of tx.origin', + // 'Fallback function of contract TooMuchGas requires too much gas', + // 'TooMuchGas.() : Variables have very similar names "test" and "test1".', + // 'TooMuchGas.() : Variables have very similar names "test" and "test1".'], + // '#staticanalysisresult .warning', + // browser, function () { + // browser.end() + // } + // ) + // }) } function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) { diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 6a6edde1a7..5a24785838 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -87,7 +87,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } if (props.analysisModule) { - console.log({ autoRun }) props.analysisModule.on( 'solidity', 'compilationFinished', @@ -110,7 +109,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { // await props.analysisModule.call('editor', 'discardHighlight') // await props.analysisModule.call('editor', 'highlight', location, fileName) // } - console.log({ autoRun }, ' auto run in run function') setResult({ lastCompilationResult, lastCompilationSource, currentFile }) if (lastCompilationResult && categoryIndex.length) { setRunButtonState(false) @@ -164,7 +162,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } Pos: ${locationString} ` - console.log(result.name, ' result name now') const options = { type: 'warning', useSpan: true, @@ -243,7 +240,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } else { setAutoRun(true) } - console.log(' auton run function') } const handleCheckSingle = (event, _index) => { From 1ef36098c25ee2c0416fede477f75af506728960 Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 17 Apr 2021 18:00:14 +0100 Subject: [PATCH 18/30] removed comments --- apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index 480fab63fb..e9777e2970 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -40,18 +40,6 @@ function runTests (browser: NightwatchBrowser) { .pause(10000) .testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['TooMuchGas', 'test1', 'test2']) .clickLaunchIcon('solidityStaticAnalysis') - //.click('#staticanalysisButton button') - // .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { - // listSelectorContains(['Use of tx.origin', - // 'Fallback function of contract TooMuchGas requires too much gas', - // 'TooMuchGas.() : Variables have very similar names "test" and "test1".', - // 'TooMuchGas.() : Variables have very similar names "test" and "test1".'], - // '#staticanalysisresult .warning', - // browser, function () { - // browser.end() - // } - // ) - // }) } function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) { From ad06ef7995dc3ecf1f8bb71224ee14d147e8f9c5 Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 17 Apr 2021 18:09:41 +0100 Subject: [PATCH 19/30] removing comments and unused functions --- .../src/tests/staticAnalysis.spec.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index e9777e2970..a10a2a8348 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -42,20 +42,4 @@ function runTests (browser: NightwatchBrowser) { .clickLaunchIcon('solidityStaticAnalysis') } -function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) { - browser.execute(function (selector) { - const items = document.querySelectorAll(selector) - const ret = [] - for (let k = 0; k < items.length; k++) { - ret.push(items[k].innerText) - } - return ret - }, [selector], function (result) { - console.log(result.value) - for (const k in textsToFind) { - console.log('testing `' + result.value[k] + '` against `' + textsToFind[k] + '`') - browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true) - } - callback() - }) -} + From a0d99872078c774b6a696d13383042ab7fdfd613 Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 17 Apr 2021 18:20:19 +0100 Subject: [PATCH 20/30] removed extra space at end of file --- apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index a10a2a8348..8fa094273e 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -40,6 +40,4 @@ function runTests (browser: NightwatchBrowser) { .pause(10000) .testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['TooMuchGas', 'test1', 'test2']) .clickLaunchIcon('solidityStaticAnalysis') -} - - +} \ No newline at end of file From f04b559e9a7a675140dcec76f5352c94bd58c930 Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 17 Apr 2021 18:27:17 +0100 Subject: [PATCH 21/30] added new line at end of file --- .../src/tests/staticAnalysis.spec.ts | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index 8fa094273e..504148b266 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -40,4 +40,34 @@ function runTests (browser: NightwatchBrowser) { .pause(10000) .testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['TooMuchGas', 'test1', 'test2']) .clickLaunchIcon('solidityStaticAnalysis') -} \ No newline at end of file + .click('#staticanalysisButton button') + .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { + listSelectorContains(['Use of tx.origin', + 'Fallback function of contract TooMuchGas requires too much gas', + 'TooMuchGas.() : Variables have very similar names "test" and "test1".', + 'TooMuchGas.() : Variables have very similar names "test" and "test1".'], + '#staticanalysisresult .warning', + browser, function () { + browser.end() + } + ) + }) +} + +function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) { + browser.execute(function (selector) { + const items = document.querySelectorAll(selector) + const ret = [] + for (let k = 0; k < items.length; k++) { + ret.push(items[k].innerText) + } + return ret + }, [selector], function (result) { + console.log(result.value) + for (const k in textsToFind) { + console.log('testing `' + result.value[k] + '` against `' + textsToFind[k] + '`') + browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true) + } + callback() + }) +} From 40f14f0681445d3e2bf203897f8aa64920da4d3e Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 17 Apr 2021 18:35:52 +0100 Subject: [PATCH 22/30] added new line at end of file --- .../src/tests/staticAnalysis.spec.ts | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index 504148b266..55f7329f65 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -40,34 +40,4 @@ function runTests (browser: NightwatchBrowser) { .pause(10000) .testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['TooMuchGas', 'test1', 'test2']) .clickLaunchIcon('solidityStaticAnalysis') - .click('#staticanalysisButton button') - .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { - listSelectorContains(['Use of tx.origin', - 'Fallback function of contract TooMuchGas requires too much gas', - 'TooMuchGas.() : Variables have very similar names "test" and "test1".', - 'TooMuchGas.() : Variables have very similar names "test" and "test1".'], - '#staticanalysisresult .warning', - browser, function () { - browser.end() - } - ) - }) -} - -function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) { - browser.execute(function (selector) { - const items = document.querySelectorAll(selector) - const ret = [] - for (let k = 0; k < items.length; k++) { - ret.push(items[k].innerText) - } - return ret - }, [selector], function (result) { - console.log(result.value) - for (const k in textsToFind) { - console.log('testing `' + result.value[k] + '` against `' + textsToFind[k] + '`') - browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true) - } - callback() - }) } From e3709a9d909549949f091071eb1924e3d1ec7830 Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 17 Apr 2021 18:37:33 +0100 Subject: [PATCH 23/30] restored staticAnalysis.spec.ts to it previous code structure --- .../src/tests/staticAnalysis.spec.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts index 55f7329f65..504148b266 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.spec.ts @@ -40,4 +40,34 @@ function runTests (browser: NightwatchBrowser) { .pause(10000) .testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['TooMuchGas', 'test1', 'test2']) .clickLaunchIcon('solidityStaticAnalysis') + .click('#staticanalysisButton button') + .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { + listSelectorContains(['Use of tx.origin', + 'Fallback function of contract TooMuchGas requires too much gas', + 'TooMuchGas.() : Variables have very similar names "test" and "test1".', + 'TooMuchGas.() : Variables have very similar names "test" and "test1".'], + '#staticanalysisresult .warning', + browser, function () { + browser.end() + } + ) + }) +} + +function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) { + browser.execute(function (selector) { + const items = document.querySelectorAll(selector) + const ret = [] + for (let k = 0; k < items.length; k++) { + ret.push(items[k].innerText) + } + return ret + }, [selector], function (result) { + console.log(result.value) + for (const k in textsToFind) { + console.log('testing `' + result.value[k] + '` against `' + textsToFind[k] + '`') + browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true) + } + callback() + }) } From eb1e5db6094e52a0b9bcb4c2fede4f9f0c903cab Mon Sep 17 00:00:00 2001 From: tizah Date: Mon, 19 Apr 2021 14:25:28 +0100 Subject: [PATCH 24/30] fix failing test --- .../src/lib/remix-ui-static-analyser.tsx | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 5a24785838..2fb460eec9 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react' +import React, { useEffect, useState } from 'react' import ReactDOM from 'react-dom' //eslint-disable-line import CheckBox from './Checkbox/StaticAnalyserCheckedBox' // eslint-disable-line import Button from './Button/StaticAnalyserButton' // eslint-disable-line @@ -81,19 +81,24 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const [warningState, setWarningState] = useState([]) useEffect(() => { + if (autoRun) { const setCompilationResult = async (data, source, file) => { await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) } - + if (props.analysisModule) { + props.analysisModule.on( 'solidity', 'compilationFinished', (file, source, languageVersion, data) => { if (languageVersion.indexOf('soljson') !== 0) return setCompilationResult(data, source, file) - run(data, source, file) + if(categoryIndex.length > 0){ + run(data, source, file) + } + } ) } @@ -102,7 +107,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } return () => { } - }, [autoRun]) + }, [autoRun, categoryIndex]) const run = (lastCompilationResult, lastCompilationSource, currentFile) => { // const highlightLocation = async (location, fileName) => { @@ -197,8 +202,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const groupedCategory = groupBy(resultArray, 'warningModuleName') setWarningState(groupedCategory) }) - - props.event.trigger('staticAnaysisWarning', [warningCount]) + if(categoryIndex.length > 0){ + props.event.trigger('staticAnaysisWarning', [warningCount]) + } } else { setRunButtonState(true) if (categoryIndex.length) { @@ -217,8 +223,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { }) ) } else { - setCategoryIndex(_.uniq([...categoryIndex, ...index])) + setCategoryIndex(_.uniq([...categoryIndex])) } + } const handleCheckOrUncheckCategory = (category) => { @@ -353,9 +360,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { {result.currentFile && result.currentFile}
- { Object.entries(warningState).length > 0 && + { categoryIndex.length > 0 && Object.entries(warningState).length > 0 &&
-
+
{ (Object.entries(warningState).map((element) => ( <> From 672a7127d819f69f41da639ec3507a8c01e4f1e1 Mon Sep 17 00:00:00 2001 From: tizah Date: Fri, 23 Apr 2021 11:23:00 +0100 Subject: [PATCH 25/30] feat_fix_n_refactor: exptracted checkbox as a reusable component and fix selec all and auto run, --- libs/remix-ui/checkbox/.babelrc | 4 + libs/remix-ui/checkbox/.eslintrc | 19 ++ libs/remix-ui/checkbox/README.md | 7 + libs/remix-ui/checkbox/src/index.ts | 1 + .../checkbox/src/lib/remix-ui-checkbox.css | 0 .../checkbox/src/lib/remix-ui-checkbox.tsx | 47 ++++ libs/remix-ui/checkbox/tsconfig.json | 16 ++ libs/remix-ui/checkbox/tsconfig.lib.json | 13 + .../src/lib/Button/StaticAnalyserButton.tsx | 8 +- .../lib/Checkbox/StaticAnalyserCheckedBox.tsx | 8 +- .../static-analyser/src/lib/ErrorRenderer.tsx | 31 +-- .../src/lib/remix-ui-static-analyser.tsx | 260 +++++++++--------- nx.json | 3 + package.json | 2 +- tsconfig.json | 3 +- workspace.json | 16 ++ 16 files changed, 273 insertions(+), 165 deletions(-) create mode 100644 libs/remix-ui/checkbox/.babelrc create mode 100644 libs/remix-ui/checkbox/.eslintrc create mode 100644 libs/remix-ui/checkbox/README.md create mode 100644 libs/remix-ui/checkbox/src/index.ts create mode 100644 libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.css create mode 100644 libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx create mode 100644 libs/remix-ui/checkbox/tsconfig.json create mode 100644 libs/remix-ui/checkbox/tsconfig.lib.json diff --git a/libs/remix-ui/checkbox/.babelrc b/libs/remix-ui/checkbox/.babelrc new file mode 100644 index 0000000000..09d67939cc --- /dev/null +++ b/libs/remix-ui/checkbox/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["@nrwl/react/babel"], + "plugins": [] +} diff --git a/libs/remix-ui/checkbox/.eslintrc b/libs/remix-ui/checkbox/.eslintrc new file mode 100644 index 0000000000..dae5c6feeb --- /dev/null +++ b/libs/remix-ui/checkbox/.eslintrc @@ -0,0 +1,19 @@ +{ + "env": { + "browser": true, + "es6": true + }, + "extends": "../../../.eslintrc", + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parserOptions": { + "ecmaVersion": 11, + "sourceType": "module" + }, + "rules": { + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": "error" + } +} diff --git a/libs/remix-ui/checkbox/README.md b/libs/remix-ui/checkbox/README.md new file mode 100644 index 0000000000..56f9b617b0 --- /dev/null +++ b/libs/remix-ui/checkbox/README.md @@ -0,0 +1,7 @@ +# remix-ui-checkbox + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test remix-ui-checkbox` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/remix-ui/checkbox/src/index.ts b/libs/remix-ui/checkbox/src/index.ts new file mode 100644 index 0000000000..27b694c6bd --- /dev/null +++ b/libs/remix-ui/checkbox/src/index.ts @@ -0,0 +1 @@ +export * from './lib/remix-ui-checkbox' diff --git a/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.css b/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx b/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx new file mode 100644 index 0000000000..5535a05971 --- /dev/null +++ b/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx @@ -0,0 +1,47 @@ +import React from 'react' //eslint-disable-line +import './remix-ui-checkbox.css' + +/* eslint-disable-next-line */ +export interface RemixUiCheckboxProps { + onClick?: (event) => void + onChange?: (event) => void + label?: string + inputType?: string + name?: string + checked?: boolean + id?: string + itemName?: string + categoryId?: string +} + +export const RemixUiCheckbox = ({ + id, + label, + onClick, + inputType, + name, + checked, + onChange, + itemName, + categoryId +}: RemixUiCheckboxProps) => { + return ( +
+ + +
+ ) +} + +export default RemixUiCheckbox diff --git a/libs/remix-ui/checkbox/tsconfig.json b/libs/remix-ui/checkbox/tsconfig.json new file mode 100644 index 0000000000..6b65264565 --- /dev/null +++ b/libs/remix-ui/checkbox/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "jsx": "react", + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ] +} diff --git a/libs/remix-ui/checkbox/tsconfig.lib.json b/libs/remix-ui/checkbox/tsconfig.lib.json new file mode 100644 index 0000000000..b560bc4dec --- /dev/null +++ b/libs/remix-ui/checkbox/tsconfig.lib.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "types": ["node"] + }, + "files": [ + "../../../node_modules/@nrwl/react/typings/cssmodule.d.ts", + "../../../node_modules/@nrwl/react/typings/image.d.ts" + ], + "exclude": ["**/*.spec.ts", "**/*.spec.tsx"], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx b/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx index 336a0fe56a..2a67c82cf8 100644 --- a/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx +++ b/libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx @@ -12,11 +12,9 @@ const StaticAnalyserButton = ({ disabled }: StaticAnalyserButtonProps) => { return ( -
- -
+ ) } diff --git a/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx b/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx index 2326a39122..e42caa4851 100644 --- a/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx +++ b/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx @@ -24,7 +24,7 @@ const StaticAnalyserCheckedBox = ({ categoryId }: StaticAnalyserCheckBoxProps) => { return ( -
+
-
) diff --git a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx index 878cccb7da..b31a62b9de 100644 --- a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx +++ b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx @@ -4,20 +4,12 @@ interface ErrorRendererProps { message: any; opt: any, warningErrors: any + editor: any } -const ErrorRenderer = ({ message, opt }: ErrorRendererProps) => { - const [, setError] = useState( - { - row: null, - column: null, - text: null, - type: null, - errFile: null - } - ) +const ErrorRenderer = ({ message, opt, editor }: ErrorRendererProps) => { const getPositionDetails = (msg: any) => { - const result = { } as any + const result = { } as Record // To handle some compiler warning without location like SPDX license warning etc if (!msg.includes(':')) return { errLine: -1, errCol: -1, errFile: msg } @@ -32,6 +24,12 @@ const ErrorRenderer = ({ message, opt }: ErrorRendererProps) => { result.errFile = position ? position[1] : '' return result } + + const handlePointToErrorOnClick = () => { + const result = opt.locationString.split(':') + editor._components.registry.get('editor').api.gotoLine(parseInt(result[0]) - 1, parseInt(result[1])) + } + if (!message) return let position = getPositionDetails(message) if (!position.errFile || (opt.errorType && opt.errorType === position.errFile)) { @@ -43,15 +41,6 @@ const ErrorRenderer = ({ message, opt }: ErrorRendererProps) => { opt.errLine = position.errLine opt.errCol = position.errCol opt.errFile = position.errFile.trim() - if (!opt.noAnnotations && opt.errFile) { - setError({ - errFile: opt.errFile, - row: opt.errLine, - column: opt.errCol, - text: message, - type: opt.type - }) - } const classList = opt.type === 'error' ? 'alert alert-danger' : 'alert alert-warning' return (
@@ -59,7 +48,7 @@ const ErrorRenderer = ({ message, opt }: ErrorRendererProps) => {
- + {opt.name} { opt.item.warning } {opt.item.more diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 2fb460eec9..21acfe376a 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -1,10 +1,11 @@ -import React, { useEffect, useState } from 'react' +import React, { useEffect, useState } from 'react' import ReactDOM from 'react-dom' //eslint-disable-line import CheckBox from './Checkbox/StaticAnalyserCheckedBox' // eslint-disable-line import Button from './Button/StaticAnalyserButton' // eslint-disable-line import remixLib from '@remix-project/remix-lib' import _ from 'lodash' import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line +import { RemixUiCheckbox } from '@remix-ui/checkbox' // eslint-disable-line import ErrorRenderer from './ErrorRenderer' // eslint-disable-line const StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis const utils = remixLib.util @@ -60,12 +61,12 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } return indexOfCategory } - + const [autoRun, setAutoRun] = useState(true) const [categoryIndex, setCategoryIndex] = useState(groupedModuleIndex(groupedModules)) const warningContainer = React.useRef(null) const [runButtonState, setRunButtonState] = useState(true) - const [autoRun, setAutoRun] = useState(false) + const [result, setResult] = useState({ lastCompilationResult: null, lastCompilationSource: null, @@ -81,136 +82,129 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const [warningState, setWarningState] = useState([]) useEffect(() => { - if (autoRun) { const setCompilationResult = async (data, source, file) => { await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) } - + if (props.analysisModule) { - props.analysisModule.on( 'solidity', 'compilationFinished', (file, source, languageVersion, data) => { if (languageVersion.indexOf('soljson') !== 0) return setCompilationResult(data, source, file) - if(categoryIndex.length > 0){ + if (categoryIndex.length > 0) { run(data, source, file) } - } ) } - } else { - setAutoRun(true) } return () => { } }, [autoRun, categoryIndex]) const run = (lastCompilationResult, lastCompilationSource, currentFile) => { - // const highlightLocation = async (location, fileName) => { - // await props.analysisModule.call('editor', 'discardHighlight') - // await props.analysisModule.call('editor', 'highlight', location, fileName) - // } - setResult({ lastCompilationResult, lastCompilationSource, currentFile }) - if (lastCompilationResult && categoryIndex.length) { - setRunButtonState(false) - let warningCount = 0 - const warningMessage = [] + if (autoRun) { + setResult({ lastCompilationResult, lastCompilationSource, currentFile }) + if (lastCompilationResult && categoryIndex.length > 0) { + setRunButtonState(false) + let warningCount = 0 + const warningMessage = [] - runner.run(lastCompilationResult, categoryIndex, results => { - results.map((result) => { - let moduleName - Object.keys(groupedModules).map(key => { - groupedModules[key].forEach(el => { - if (el.name === result.name) { - moduleName = groupedModules[key][0].categoryDisplayName - } + runner.run(lastCompilationResult, categoryIndex, results => { + results.map((result) => { + let moduleName + Object.keys(groupedModules).map(key => { + groupedModules[key].forEach(el => { + if (el.name === result.name) { + moduleName = groupedModules[key][0].categoryDisplayName + } + }) }) - }) - setModuleNameResult(moduleName) - const warningErrors = [] - result.report.map((item) => { - let location: any = {} - let locationString = 'not available' - let column = 0 - let row = 0 - let fileName = currentFile - if (item.location) { - var split = item.location.split(':') - var file = split[2] - location = { - start: parseInt(split[0]), - length: parseInt(split[1]) + setModuleNameResult(moduleName) + const warningErrors = [] + result.report.map((item) => { + let location: any = {} + let locationString = 'not available' + let column = 0 + let row = 0 + let fileName = currentFile + if (item.location) { + const split = item.location.split(':') + const file = split[2] + location = { + start: parseInt(split[0]), + length: parseInt(split[1]) + } + location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn( + location, + parseInt(file), + lastCompilationSource.sources, + lastCompilationResult.sources + ) + row = location.start.line + column = location.start.column + locationString = row + 1 + ':' + column + ':' + fileName = Object.keys(lastCompilationResult.contracts)[file] } - location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn( - location, - parseInt(file), - lastCompilationSource.sources, - lastCompilationResult.sources - ) - row = location.start.line - column = location.start.column - locationString = row + 1 + ':' + column + ':' - fileName = Object.keys(lastCompilationResult.contracts)[file] - } - warningCount++ - const msg = ` - - ${result.name} - ${item.warning} - ${item.more - ? `more` - : ' ' + warningCount++ + const msg = ` + + ${result.name} + ${item.warning} + ${item.more + ? `more` + : ' ' + } + Pos: ${locationString} + ` + const options = { + type: 'warning', + useSpan: true, + errFile: fileName, + errLine: row, + errCol: column, + item: item, + name: result.name, + locationString, + more: item.more } - Pos: ${locationString} - ` - const options = { - type: 'warning', - useSpan: true, - errFile: fileName, - errLine: row, - errCol: column, - item: item, - name: result.name, - locationString, - more: item.more - } - warningErrors.push(options) - setWarning({ msg, hasWarning: true, options, warningErrors: warningErrors }) - warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName }) + warningErrors.push(options) + setWarning({ msg, hasWarning: true, options, warningErrors: warningErrors }) + warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName }) + }) }) + const resultArray = [] + warningMessage.map(x => { + resultArray.push(x) + }) + function groupBy (objectArray, property) { + return objectArray.reduce((acc, obj) => { + const key = obj[property] + if (!acc[key]) { + acc[key] = [] + } + // Add object to list for given key's value + acc[key].push(obj) + return acc + }, {}) + } + + const groupedCategory = groupBy(resultArray, 'warningModuleName') + setWarningState(groupedCategory) }) - const resultArray = [] - warningMessage.map(x => { - resultArray.push(x) - }) - function groupBy (objectArray, property) { - return objectArray.reduce((acc, obj) => { - const key = obj[property] - if (!acc[key]) { - acc[key] = [] - } - // Add object to list for given key's value - acc[key].push(obj) - return acc - }, {}) + if (categoryIndex.length > 0) { + props.event.trigger('staticAnaysisWarning', [warningCount]) } - - const groupedCategory = groupBy(resultArray, 'warningModuleName') - setWarningState(groupedCategory) - }) - if(categoryIndex.length > 0){ - props.event.trigger('staticAnaysisWarning', [warningCount]) - } - } else { - setRunButtonState(true) - if (categoryIndex.length) { - warningContainer.current.innerText = 'No compiled AST available' + } else { + setRunButtonState(true) + if (categoryIndex.length) { + warningContainer.current.innerText = 'No compiled AST available' + } + props.event.trigger('staticAnaysisWarning', [-1]) } - props.event.trigger('staticAnaysisWarning', [-1]) } } @@ -223,9 +217,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { }) ) } else { - setCategoryIndex(_.uniq([...categoryIndex])) + setCategoryIndex(_.uniq([...categoryIndex, ...index])) } - } const handleCheckOrUncheckCategory = (category) => { @@ -261,7 +254,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const categoryItem = (categoryId, item, i) => { return (
- { } - expand={true} + expand={false} >
- handleCheckOrUncheckCategory(category)} id={categoryId} inputType="checkbox" label={`Select ${category[0].categoryDisplayName}`} name='checkCategoryEntry' checked={category.map(x => x._index.toString()).every(el => categoryIndex.includes(el))} /> + handleCheckOrUncheckCategory(category)} id={categoryId} inputType="checkbox" label={`Select ${category[0].categoryDisplayName}`} name='checkCategoryEntry' checked={category.map(x => x._index.toString()).every(el => categoryIndex.includes(el))} />
{category.map((item, i) => { @@ -314,31 +307,27 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } return ( -
+
-
- { - return (value.map(x => { - return x._index.toString() - })) - }).flat().every(el => categoryIndex.includes(el))} - label="Select all" - onClick={() => handleCheckAllModules(groupedModules)} - /> -
-
- -
+ { + return (value.map(x => { + return x._index.toString() + })) + }).flat().every(el => categoryIndex.includes(el))} + label="Select all" + onClick={() => handleCheckAllModules(groupedModules)} + /> +
@@ -368,7 +357,12 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { <> {element[0]} {element[1].map(x => ( - x.hasWarning ? () : null + x.hasWarning ? ( +
+ +
+ + ) : null ))} ))) diff --git a/nx.json b/nx.json index 802b6fe374..a63c015d64 100644 --- a/nx.json +++ b/nx.json @@ -98,6 +98,9 @@ }, "remix-ui-static-analyser": { "tags": [] + }, + "remix-ui-checkbox": { + "tags": [] } } } diff --git a/package.json b/package.json index 0b7fcd4372..15e2a95e3e 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "workspace-schematic": "nx workspace-schematic", "dep-graph": "nx dep-graph", "help": "nx help", - "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui,remix-ui-workspace", + "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox", "build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "publish:libs": "npm run build:libs & lerna publish --skip-git & npm run bumpVersion:libs", diff --git a/tsconfig.json b/tsconfig.json index c90ed09031..75db5bc6ff 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -39,7 +39,8 @@ "@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"], "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"], - "@remix-ui/static-analyser": ["libs/remix-ui/static-analyser/src/index.ts"] + "@remix-ui/static-analyser": ["libs/remix-ui/static-analyser/src/index.ts"], + "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] diff --git a/workspace.json b/workspace.json index 9c734f96a7..5d2bf912c0 100644 --- a/workspace.json +++ b/workspace.json @@ -744,6 +744,22 @@ } } } + }, + "remix-ui-checkbox": { + "root": "libs/remix-ui/checkbox", + "sourceRoot": "libs/remix-ui/checkbox/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@nrwl/linter:lint", + "options": { + "linter": "eslint", + "tsConfig": ["libs/remix-ui/checkbox/tsconfig.lib.json"], + "exclude": ["**/node_modules/**", "!libs/remix-ui/checkbox/**/*"] + } + } + } } }, "cli": { From ff2c1a28cf691aa2d8e94835ca0c4c72937a8d84 Mon Sep 17 00:00:00 2001 From: tizah Date: Fri, 23 Apr 2021 16:57:24 +0100 Subject: [PATCH 26/30] refactored warning message --- .../src/lib/remix-ui-static-analyser.tsx | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 21acfe376a..383bfa7643 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -105,6 +105,20 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return () => { } }, [autoRun, categoryIndex]) + const message = (name, warning, more, fileName, locationString) : string => { + return (` + + ${name} + ${warning} + ${more + ? (more) + : ( ) + } + Pos: ${locationString} + ` + ) + } + const run = (lastCompilationResult, lastCompilationSource, currentFile) => { if (autoRun) { setResult({ lastCompilationResult, lastCompilationSource, currentFile }) @@ -150,16 +164,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { fileName = Object.keys(lastCompilationResult.contracts)[file] } warningCount++ - const msg = ` - - ${result.name} - ${item.warning} - ${item.more - ? `more` - : ' ' - } - Pos: ${locationString} - ` + const msg = message(item.name, item.warning, item.more, fileName, locationString) const options = { type: 'warning', useSpan: true, From 29ba1d44b5aea88ea4171b93224b443a71dbed8d Mon Sep 17 00:00:00 2001 From: tizah Date: Sat, 24 Apr 2021 06:10:21 +0100 Subject: [PATCH 27/30] fix editor highlighter --- libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx | 8 ++++---- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx index b31a62b9de..46dfd16a15 100644 --- a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx +++ b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx @@ -25,9 +25,9 @@ const ErrorRenderer = ({ message, opt, editor }: ErrorRendererProps) => { return result } - const handlePointToErrorOnClick = () => { - const result = opt.locationString.split(':') - editor._components.registry.get('editor').api.gotoLine(parseInt(result[0]) - 1, parseInt(result[1])) + const handlePointToErrorOnClick = (location, fileName) => { + editor.call('editor', 'discardHighlight') + editor.call('editor', 'highlight', location, fileName) } if (!message) return @@ -48,7 +48,7 @@ const ErrorRenderer = ({ message, opt, editor }: ErrorRendererProps) => {
- + handlePointToErrorOnClick(opt.location, opt.fileName)}> {opt.name} { opt.item.warning } {opt.item.more diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 383bfa7643..7bcdd9d0a3 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -169,12 +169,14 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { type: 'warning', useSpan: true, errFile: fileName, + fileName, errLine: row, errCol: column, item: item, name: result.name, locationString, - more: item.more + more: item.more, + location: location } warningErrors.push(options) setWarning({ msg, hasWarning: true, options, warningErrors: warningErrors }) @@ -314,7 +316,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return (
-
+
Date: Sun, 25 Apr 2021 13:41:17 +0100 Subject: [PATCH 28/30] removed old staticAnalysis from remix-project --- .../tabs/staticanalysis/staticAnalysisView.js | 302 ------------------ .../styles/staticAnalysisView-styles.js | 36 --- .../src/lib/remix-ui-static-analyser.tsx | 42 +-- 3 files changed, 24 insertions(+), 356 deletions(-) delete mode 100644 apps/remix-ide/src/app/tabs/staticanalysis/staticAnalysisView.js delete mode 100644 apps/remix-ide/src/app/tabs/staticanalysis/styles/staticAnalysisView-styles.js diff --git a/apps/remix-ide/src/app/tabs/staticanalysis/staticAnalysisView.js b/apps/remix-ide/src/app/tabs/staticanalysis/staticAnalysisView.js deleted file mode 100644 index 668adab89e..0000000000 --- a/apps/remix-ide/src/app/tabs/staticanalysis/staticAnalysisView.js +++ /dev/null @@ -1,302 +0,0 @@ -'use strict' -var StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis -var yo = require('yo-yo') -var $ = require('jquery') -var remixLib = require('@remix-project/remix-lib') -var utils = remixLib.util -var css = require('./styles/staticAnalysisView-styles') -var Renderer = require('../../ui/renderer') -const SourceHighlighter = require('../../editor/sourceHighlighter') - -var EventManager = require('../../../lib/events') - -function staticAnalysisView (localRegistry, analysisModule) { - var self = this - this.event = new EventManager() - this.view = null - this.runner = new StaticAnalysisRunner() - this.modulesView = this.renderModules() - this.lastCompilationResult = null - this.lastCompilationSource = null - this.currentFile = 'No file compiled' - this.sourceHighlighter = new SourceHighlighter() - this.analysisModule = analysisModule - self._components = { - renderer: new Renderer(analysisModule) - } - self._components.registry = localRegistry - // dependencies - self._deps = { - offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api - } - - analysisModule.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => { - self.lastCompilationResult = null - self.lastCompilationSource = null - if (languageVersion.indexOf('soljson') !== 0) return - self.lastCompilationResult = data - self.lastCompilationSource = source - self.currentFile = file - self.correctRunBtnDisabled() - if (self.view && self.view.querySelector('#autorunstaticanalysis').checked) { - self.run() - } - }) -} - -staticAnalysisView.prototype.render = function () { - this.runBtn = yo`` - const view = yo` -
-
-
-
- - -
-
- - -
- ${this.runBtn} -
-
-
- ${this.modulesView} -
-
- last results for: - ${this.currentFile} -
-
-
- ` - - if (!this.view) { - this.view = view - } - this.correctRunBtnDisabled() - return view -} - -staticAnalysisView.prototype.selectedModules = function () { - if (!this.view) { - return [] - } - const selected = this.view.querySelectorAll('[name="staticanalysismodule"]:checked') - var toRun = [] - for (var i = 0; i < selected.length; i++) { - toRun.push(selected[i].attributes.index.value) - } - return toRun -} - -staticAnalysisView.prototype.run = function () { - if (!this.view) { - return - } - const highlightLocation = async (location, fileName) => { - await this.analysisModule.call('editor', 'discardHighlight') - await this.analysisModule.call('editor', 'highlight', location, fileName) - } - const selected = this.selectedModules() - const warningContainer = $('#staticanalysisresult') - warningContainer.empty() - this.view.querySelector('#staticAnalysisCurrentFile').innerText = this.currentFile - var self = this - if (this.lastCompilationResult && selected.length) { - this.runBtn.removeAttribute('disabled') - let warningCount = 0 - this.runner.run(this.lastCompilationResult, selected, (results) => { - const groupedModules = utils.groupBy(preProcessModules(this.runner.modules()), 'categoryId') - results.map((result, j) => { - let moduleName - Object.keys(groupedModules).map((key) => { - groupedModules[key].forEach((el) => { - if (el.name === result.name) { - moduleName = groupedModules[key][0].categoryDisplayName - } - }) - }) - const alreadyExistedEl = this.view.querySelector(`[id="staticAnalysisModule${moduleName}"]`) - if (!alreadyExistedEl) { - warningContainer.append(` -
- ${moduleName} -
- `) - } - - result.report.map((item, i) => { - let location = '' - let locationString = 'not available' - let column = 0 - let row = 0 - let fileName = this.currentFile - if (item.location) { - var split = item.location.split(':') - var file = split[2] - location = { - start: parseInt(split[0]), - length: parseInt(split[1]) - } - location = self._deps.offsetToLineColumnConverter.offsetToLineColumn( - location, - parseInt(file), - self.lastCompilationSource.sources, - self.lastCompilationResult.sources - ) - row = location.start.line - column = location.start.column - locationString = (row + 1) + ':' + column + ':' - fileName = Object.keys(self.lastCompilationResult.contracts)[file] - } - warningCount++ - const msg = yo` - - ${result.name} - ${item.warning} - ${item.more ? yo`more` : yo``} - Pos: ${locationString} - ` - self._components.renderer.error( - msg, - this.view.querySelector(`[id="staticAnalysisModule${moduleName}"]`), - { - click: () => highlightLocation(location, fileName), - type: 'warning', - useSpan: true, - errFile: fileName, - errLine: row, - errCol: column - } - ) - }) - }) - // hide empty staticAnalysisModules sections - this.view.querySelectorAll('[name="staticAnalysisModules"]').forEach((section) => { - if (!section.getElementsByClassName('alert-warning').length) section.hidden = true - }) - self.event.trigger('staticAnaysisWarning', [warningCount]) - }) - } else { - this.runBtn.setAttribute('disabled', 'disabled') - if (selected.length) { - warningContainer.html('No compiled AST available') - } - self.event.trigger('staticAnaysisWarning', [-1]) - } -} -staticAnalysisView.prototype.checkModule = function (event) { - const selected = this.view.querySelectorAll('[name="staticanalysismodule"]:checked') - const checkAll = this.view.querySelector('[id="checkAllEntries"]') - this.correctRunBtnDisabled() - if (event.target.checked) { - checkAll.checked = true - } else if (!selected.length) { - checkAll.checked = false - } -} -staticAnalysisView.prototype.correctRunBtnDisabled = function () { - if (!this.view) { - return - } - const selected = this.view.querySelectorAll('[name="staticanalysismodule"]:checked') - if (this.lastCompilationResult && selected.length !== 0) { - this.runBtn.removeAttribute('disabled') - } else { - this.runBtn.setAttribute('disabled', 'disabled') - } -} -staticAnalysisView.prototype.checkAll = function (event) { - if (!this.view) { - return - } - // checks/unchecks all - const checkBoxes = this.view.querySelectorAll('[name="staticanalysismodule"]') - checkBoxes.forEach((checkbox) => { checkbox.checked = event.target.checked }) - this.correctRunBtnDisabled() -} - -staticAnalysisView.prototype.handleCollapse = function (e) { - const downs = e.toElement.parentElement.getElementsByClassName('fas fa-angle-double-right') - const iEls = document.getElementsByTagName('i') - for (var i = 0; i < iEls.length; i++) { iEls[i].hidden = false } - downs[0].hidden = true -} - -staticAnalysisView.prototype.renderModules = function () { - const groupedModules = utils.groupBy(preProcessModules(this.runner.modules()), 'categoryId') - const moduleEntries = Object.keys(groupedModules).map((categoryId, i) => { - const category = groupedModules[categoryId] - const entriesDom = category.map((item, i) => { - return yo` -
- - -
- ` - }) - return yo` -
- this.handleCollapse(e)}"/> - -
- ${entriesDom} -
-
- ` - }) - // collaps first module - moduleEntries[0].getElementsByTagName('input')[0].checked = true - moduleEntries[0].getElementsByTagName('i')[0].hidden = true - return yo` -
- ${moduleEntries} -
` -} - -module.exports = staticAnalysisView - -/** - * @dev Process & categorize static analysis modules to show them on UI - * @param arr list of static analysis modules received from remix-analyzer module - */ -function preProcessModules (arr) { - return arr.map((Item, i) => { - const itemObj = new Item() - itemObj._index = i - itemObj.categoryDisplayName = itemObj.category.displayName - itemObj.categoryId = itemObj.category.id - return itemObj - }) -} diff --git a/apps/remix-ide/src/app/tabs/staticanalysis/styles/staticAnalysisView-styles.js b/apps/remix-ide/src/app/tabs/staticanalysis/styles/staticAnalysisView-styles.js deleted file mode 100644 index bd277a03aa..0000000000 --- a/apps/remix-ide/src/app/tabs/staticanalysis/styles/staticAnalysisView-styles.js +++ /dev/null @@ -1,36 +0,0 @@ -var csjs = require('csjs-inject') - -var css = csjs` - .analysis { - display: flex; - flex-direction: column; - } - .result { - margin-top: 1%; - max-height: 300px; - word-break: break-word; - } - .buttons { - margin: 1rem 0; - } - .label { - display: flex; - align-items: center; - } - .label { - display: flex; - align-items: center; - user-select: none; - } - .block input[type='radio']:checked ~ .entries{ - height: auto; - transition: .5s ease-in; - } - .entries{ - height: 0; - overflow: hidden; - transition: .5s ease-out; - } -` - -module.exports = css diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 7bcdd9d0a3..8cae6c9e60 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -81,27 +81,30 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { }) const [warningState, setWarningState] = useState([]) - useEffect(() => { - if (autoRun) { - const setCompilationResult = async (data, source, file) => { - await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) - } + const executeCompilation = () => { + const setCompilationResult = async (data, source, file) => { + await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) + } - if (props.analysisModule) { - props.analysisModule.on( - 'solidity', - 'compilationFinished', - (file, source, languageVersion, data) => { - if (languageVersion.indexOf('soljson') !== 0) return - setCompilationResult(data, source, file) - if (categoryIndex.length > 0) { - run(data, source, file) - } + if (props.analysisModule) { + props.analysisModule.on( + 'solidity', + 'compilationFinished', + (file, source, languageVersion, data) => { + if (languageVersion.indexOf('soljson') !== 0) return + setCompilationResult(data, source, file) + if (categoryIndex.length > 0) { + run(data, source, file) } - ) - } + } + ) } + } + useEffect(() => { + if (autoRun) { + executeCompilation() + } return () => { } }, [autoRun, categoryIndex]) @@ -270,6 +273,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { label={item.description} onClick={event => handleCheckSingle(event, item._index)} checked={categoryIndex.includes(item._index.toString())} + onChange={() => {}} />
) @@ -297,7 +301,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { expand={false} >
- handleCheckOrUncheckCategory(category)} id={categoryId} inputType="checkbox" label={`Select ${category[0].categoryDisplayName}`} name='checkCategoryEntry' checked={category.map(x => x._index.toString()).every(el => categoryIndex.includes(el))} /> + handleCheckOrUncheckCategory(category)} id={categoryId} inputType="checkbox" label={`Select ${category[0].categoryDisplayName}`} name='checkCategoryEntry' checked={category.map(x => x._index.toString()).every(el => categoryIndex.includes(el))} onChange={() => {}}/>
{category.map((item, i) => { @@ -327,6 +331,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { }).flat().every(el => categoryIndex.includes(el))} label="Select all" onClick={() => handleCheckAllModules(groupedModules)} + onChange={() => {}} /> { onClick={handleAutoRun} checked={autoRun} label="Autorun" + onChange={() => {}} />
From d79f14c010aa3faa889cb2f9c030a559008eec39 Mon Sep 17 00:00:00 2001 From: tizah Date: Tue, 27 Apr 2021 03:25:23 +0100 Subject: [PATCH 29/30] created actions and reducer to optimise code --- .../src/lib/actions/staticAnalysisActions.ts | 24 +++ .../src/lib/reducers/staticAnalysisReducer.ts | 65 ++++++++ .../src/lib/remix-ui-static-analyser.tsx | 153 ++++++++++-------- 3 files changed, 172 insertions(+), 70 deletions(-) create mode 100644 libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts create mode 100644 libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts diff --git a/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts new file mode 100644 index 0000000000..ab9b8d3fc9 --- /dev/null +++ b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts @@ -0,0 +1,24 @@ +import React, { useState } from 'react' //eslint-disable-line + +export const compilation = (analysisModule, state, run) => { +// const setCompilationResult = async (data, source, file) => { +// await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) +// } + if (analysisModule) { + analysisModule.on( + 'solidity', + 'compilationFinished', + (file, source, languageVersion, data) => { + if (languageVersion.indexOf('soljson') !== 0) return + setCompilationResult(data, source, file) + if (state.categoryIndex.length > 0) { + run(data, source, file) + } + } + ) + } +} + +export const setCompilationResult = async (data, source, file) => { + return await { data, source, file } +} diff --git a/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts b/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts new file mode 100644 index 0000000000..f2f1a8c9d0 --- /dev/null +++ b/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts @@ -0,0 +1,65 @@ +import remixLib from '@remix-project/remix-lib' +import * as _ from 'lodash' +const StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis + +const utils = remixLib.util + +const runner = new StaticAnalysisRunner() + +const preProcessModules = (arr: any) => { + return arr.map((Item, i) => { + const itemObj = new Item() + itemObj._index = i + itemObj.categoryDisplayName = itemObj.category.displayName + itemObj.categoryId = itemObj.category.id + return itemObj + }) +} + +const groupedModules = utils.groupBy( + preProcessModules(runner.modules()), + 'categoryId' +) + +const getIndex = (modules, array) => { + Object.values(modules).map((value: {_index}) => { + if (Array.isArray(value)) { + value.forEach((x) => { + array.push(x._index.toString()) + }) + } else { + array.push(value._index.toString()) + } + }) +} +const groupedModuleIndex = (modules) => { + const indexOfCategory = [] + if (!_.isEmpty(modules)) { + getIndex(modules, indexOfCategory) + } + return indexOfCategory +} + +export const initialState = { categoryIndex: [] } + +export const analysisReducer = (state, action) => { + switch (action.type) { + case 'initialize': + return { ...state, categoryIndex: groupedModuleIndex(groupedModules) } + case 'uncheck': + return { + ...state, + categoryIndex: state.categoryIndex.filter((el) => { + return !action.payload.includes(el) + }) + } + case 'check': + return { ...state, categoryIndex: _.uniq([...state.categoryIndex, ...action.payload]) } + case 'uncheckSingle': + return { ...state, categoryIndex: state.categoryIndex.filter(val => val !== action.payload) } + case 'checkSingle': + return { ...state, categoryIndex: _.uniq([...state.categoryIndex, action.payload]) } + default: + return { ...state, categoryIndex: groupedModuleIndex(groupedModules) } + } +} diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 8cae6c9e60..c0c89415c9 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react' +import React, { useEffect, useState, useReducer } from 'react' import ReactDOM from 'react-dom' //eslint-disable-line import CheckBox from './Checkbox/StaticAnalyserCheckedBox' // eslint-disable-line import Button from './Button/StaticAnalyserButton' // eslint-disable-line @@ -7,6 +7,9 @@ import _ from 'lodash' import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line import { RemixUiCheckbox } from '@remix-ui/checkbox' // eslint-disable-line import ErrorRenderer from './ErrorRenderer' // eslint-disable-line +import { compilation, setCompilationResult } from './actions/staticAnalysisActions' +import { analysisReducer, initialState } from './reducers/staticAnalysisReducer' + const StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis const utils = remixLib.util @@ -62,7 +65,32 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return indexOfCategory } const [autoRun, setAutoRun] = useState(true) - const [categoryIndex, setCategoryIndex] = useState(groupedModuleIndex(groupedModules)) + + // const initialState = { categoryIndex: [] } + + // const reducer = (state, action) => { + // console.log({ action }) + // switch (action.type) { + // case 'initialize': + // return { categoryIndex: groupedModuleIndex(groupedModules) } + // case 'uncheck': + // return { + // categoryIndex: state.categoryIndex.filter((el) => { + // return !action.payload.includes(el) + // }) + // } + // case 'check': + // return { categoryIndex: _.uniq([...state.categoryIndex, ...action.payload]) } + // case 'uncheckSingle': + // return { categoryIndex: state.categoryIndex.filter(val => val !== action.payload) } + // case 'checkSingle': + // return { categoryIndex: _.uniq([...state.categoryIndex, action.payload]) } + // default: + // return { categoryIndex: groupedModuleIndex(groupedModules) } + // } + // } + + const [state, dispatch] = useReducer(analysisReducer, initialState) const warningContainer = React.useRef(null) const [runButtonState, setRunButtonState] = useState(true) @@ -74,63 +102,51 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { }) const [, setModuleNameResult] = useState(null) const [, setWarning] = useState({ - msg: '', options: {}, hasWarning: false, warningErrors: [] }) const [warningState, setWarningState] = useState([]) - const executeCompilation = () => { - const setCompilationResult = async (data, source, file) => { - await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) - } - - if (props.analysisModule) { - props.analysisModule.on( - 'solidity', - 'compilationFinished', - (file, source, languageVersion, data) => { - if (languageVersion.indexOf('soljson') !== 0) return - setCompilationResult(data, source, file) - if (categoryIndex.length > 0) { - run(data, source, file) - } - } - ) - } - } + // const executeCompilation = (categoryIndex) => { + // const setCompilationResult = async (data, source, file) => { + // await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) + // } + // if (props.analysisModule) { + // props.analysisModule.on( + // 'solidity', + // 'compilationFinished', + // (file, source, languageVersion, data) => { + // if (languageVersion.indexOf('soljson') !== 0) return + // setCompilationResult(data, source, file) + // console.log(categoryIndex, ' inside execute funtions') + // if (state.categoryIndex.length > 0) { + // run(data, source, file) + // } + // } + // ) + // } + // } useEffect(() => { if (autoRun) { - executeCompilation() + if (props.analysisModule && state.categoryIndex.length > 0) { + compilation(props.analysisModule, state, run) + } } - return () => { } - }, [autoRun, categoryIndex]) - - const message = (name, warning, more, fileName, locationString) : string => { - return (` - - ${name} - ${warning} - ${more - ? (more) - : ( ) + return () => { } - Pos: ${locationString} - ` - ) - } + }, [autoRun, state, props.analysisModule, setWarning]) const run = (lastCompilationResult, lastCompilationSource, currentFile) => { if (autoRun) { setResult({ lastCompilationResult, lastCompilationSource, currentFile }) - if (lastCompilationResult && categoryIndex.length > 0) { + if (lastCompilationResult && state.categoryIndex.length > 0) { setRunButtonState(false) let warningCount = 0 const warningMessage = [] - runner.run(lastCompilationResult, categoryIndex, results => { + runner.run(lastCompilationResult, state.categoryIndex, results => { results.map((result) => { let moduleName Object.keys(groupedModules).map(key => { @@ -167,7 +183,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { fileName = Object.keys(lastCompilationResult.contracts)[file] } warningCount++ - const msg = message(item.name, item.warning, item.more, fileName, locationString) const options = { type: 'warning', useSpan: true, @@ -182,8 +197,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { location: location } warningErrors.push(options) - setWarning({ msg, hasWarning: true, options, warningErrors: warningErrors }) - warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName }) + setWarning({ hasWarning: true, options, warningErrors: warningErrors }) + warningMessage.push({ options, hasWarning: true, warningModuleName: moduleName }) }) }) const resultArray = [] @@ -201,16 +216,21 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return acc }, {}) } - const groupedCategory = groupBy(resultArray, 'warningModuleName') + console.log({ warningCount }, ' 221') + console.log({ groupedCategory }) setWarningState(groupedCategory) + console.log({ warningState }) + console.log({ warningCount }, ' 223') }) - if (categoryIndex.length > 0) { + console.log({ warningCount }, ' CategoryIndex outside function') + if (state.categoryIndex.length > 0) { + console.log(state.categoryIndex, ' CategoryIndex in execute funtions') props.event.trigger('staticAnaysisWarning', [warningCount]) } } else { setRunButtonState(true) - if (categoryIndex.length) { + if (state.categoryIndex.length) { warningContainer.current.innerText = 'No compiled AST available' } props.event.trigger('staticAnaysisWarning', [-1]) @@ -220,27 +240,19 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const handleCheckAllModules = (groupedModules) => { const index = groupedModuleIndex(groupedModules) - if (index.every(el => categoryIndex.includes(el))) { - setCategoryIndex( - categoryIndex.filter((el) => { - return !index.includes(el) - }) - ) + if (index.every(el => state.categoryIndex.includes(el))) { + dispatch({ type: 'uncheck', payload: index }) } else { - setCategoryIndex(_.uniq([...categoryIndex, ...index])) + dispatch({ type: 'check', payload: index }) } } const handleCheckOrUncheckCategory = (category) => { const index = groupedModuleIndex(category) - if (index.every(el => categoryIndex.includes(el))) { - setCategoryIndex( - categoryIndex.filter((el) => { - return !index.includes(el) - }) - ) + if (index.every(el => state.categoryIndex.includes(el))) { + dispatch({ type: 'uncheck', payload: index }) } else { - setCategoryIndex(_.uniq([...categoryIndex, ...index])) + dispatch({ type: 'check', payload: index }) } } @@ -254,10 +266,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const handleCheckSingle = (event, _index) => { _index = _index.toString() - if (categoryIndex.includes(_index)) { - setCategoryIndex(categoryIndex.filter(val => val !== _index)) + if (state.categoryIndex.includes(_index)) { + dispatch({ type: 'uncheckSingle', payload: _index }) } else { - setCategoryIndex(_.uniq([...categoryIndex, _index])) + dispatch({ type: 'checkSingle', payload: _index }) } } @@ -272,7 +284,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { itemName={item.name} label={item.description} onClick={event => handleCheckSingle(event, item._index)} - checked={categoryIndex.includes(item._index.toString())} + checked={state.categoryIndex.includes(item._index.toString())} onChange={() => {}} />
@@ -301,7 +313,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { expand={false} >
- handleCheckOrUncheckCategory(category)} id={categoryId} inputType="checkbox" label={`Select ${category[0].categoryDisplayName}`} name='checkCategoryEntry' checked={category.map(x => x._index.toString()).every(el => categoryIndex.includes(el))} onChange={() => {}}/> + handleCheckOrUncheckCategory(category)} id={categoryId} inputType="checkbox" label={`Select ${category[0].categoryDisplayName}`} name='checkCategoryEntry' checked={category.map(x => x._index.toString()).every(el => state.categoryIndex.includes(el))} onChange={() => {}}/>
{category.map((item, i) => { @@ -328,7 +340,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return (value.map(x => { return x._index.toString() })) - }).flat().every(el => categoryIndex.includes(el))} + }).flat().every(el => state.categoryIndex.includes(el))} label="Select all" onClick={() => handleCheckAllModules(groupedModules)} onChange={() => {}} @@ -341,7 +353,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { label="Autorun" onChange={() => {}} /> -
@@ -362,10 +374,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { {result.currentFile && result.currentFile}
- { categoryIndex.length > 0 && Object.entries(warningState).length > 0 && + { console.log({ warningState }) } + { state.categoryIndex.length > 0 && Object.entries(warningState).length > 0 &&
- { + {/* { (Object.entries(warningState).map((element) => ( <> {element[0]} @@ -379,7 +392,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ))} ))) - } + } */}
} From 9051e4ac35e10f0fd3e56563dd3c38d2523ec1cf Mon Sep 17 00:00:00 2001 From: tizah Date: Tue, 27 Apr 2021 17:30:40 +0100 Subject: [PATCH 30/30] refactored static analysis to improve performance --- .../lib/Checkbox/StaticAnalyserCheckedBox.tsx | 45 ----- .../static-analyser/src/lib/ErrorRenderer.tsx | 3 +- .../src/lib/actions/staticAnalysisActions.ts | 16 +- .../src/lib/reducers/staticAnalysisReducer.ts | 65 ++----- .../src/lib/remix-ui-static-analyser.tsx | 163 ++++++------------ 5 files changed, 71 insertions(+), 221 deletions(-) delete mode 100644 libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx diff --git a/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx b/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx deleted file mode 100644 index e42caa4851..0000000000 --- a/libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react' //eslint-disable-line - -interface StaticAnalyserCheckBoxProps { - onClick?: (event) => void - onChange?: (event) => void - label?: string - inputType?: string - name?: string - checked?: boolean - id?: string - itemName?: string - categoryId?: string -} - -const StaticAnalyserCheckedBox = ({ - id, - label, - onClick, - inputType, - name, - checked, - onChange, - itemName, - categoryId -}: StaticAnalyserCheckBoxProps) => { - return ( -
- - -
- ) -} - -export default StaticAnalyserCheckedBox diff --git a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx index 46dfd16a15..6f1989e3ac 100644 --- a/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx +++ b/libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' //eslint-disable-line +import React from 'react' //eslint-disable-line interface ErrorRendererProps { message: any; @@ -32,6 +32,7 @@ const ErrorRenderer = ({ message, opt, editor }: ErrorRendererProps) => { if (!message) return let position = getPositionDetails(message) + console.log({ position }) if (!position.errFile || (opt.errorType && opt.errorType === position.errFile)) { // Updated error reported includes '-->' before file details const errorDetails = message.split('-->') diff --git a/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts index ab9b8d3fc9..4f55437cb6 100644 --- a/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts +++ b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts @@ -1,24 +1,14 @@ -import React, { useState } from 'react' //eslint-disable-line +import React from 'react' //eslint-disable-line -export const compilation = (analysisModule, state, run) => { -// const setCompilationResult = async (data, source, file) => { -// await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) -// } +export const compilation = (analysisModule, dispatch) => { if (analysisModule) { analysisModule.on( 'solidity', 'compilationFinished', (file, source, languageVersion, data) => { if (languageVersion.indexOf('soljson') !== 0) return - setCompilationResult(data, source, file) - if (state.categoryIndex.length > 0) { - run(data, source, file) - } + dispatch({ type: 'compilationFinished', payload: { file, source, languageVersion, data } }) } ) } } - -export const setCompilationResult = async (data, source, file) => { - return await { data, source, file } -} diff --git a/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts b/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts index f2f1a8c9d0..833ef55b39 100644 --- a/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts +++ b/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts @@ -1,65 +1,22 @@ -import remixLib from '@remix-project/remix-lib' -import * as _ from 'lodash' -const StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis -const utils = remixLib.util - -const runner = new StaticAnalysisRunner() - -const preProcessModules = (arr: any) => { - return arr.map((Item, i) => { - const itemObj = new Item() - itemObj._index = i - itemObj.categoryDisplayName = itemObj.category.displayName - itemObj.categoryId = itemObj.category.id - return itemObj - }) -} - -const groupedModules = utils.groupBy( - preProcessModules(runner.modules()), - 'categoryId' -) - -const getIndex = (modules, array) => { - Object.values(modules).map((value: {_index}) => { - if (Array.isArray(value)) { - value.forEach((x) => { - array.push(x._index.toString()) - }) - } else { - array.push(value._index.toString()) - } - }) -} -const groupedModuleIndex = (modules) => { - const indexOfCategory = [] - if (!_.isEmpty(modules)) { - getIndex(modules, indexOfCategory) - } - return indexOfCategory +export const initialState = { + file: null, + source: null, + languageVersion: null, + data: null } -export const initialState = { categoryIndex: [] } - export const analysisReducer = (state, action) => { switch (action.type) { - case 'initialize': - return { ...state, categoryIndex: groupedModuleIndex(groupedModules) } - case 'uncheck': + case 'compilationFinished': return { ...state, - categoryIndex: state.categoryIndex.filter((el) => { - return !action.payload.includes(el) - }) + file: action.payload.file, + source: action.payload.source, + languageVersion: action.payload.languageVersion, + data: action.payload.data } - case 'check': - return { ...state, categoryIndex: _.uniq([...state.categoryIndex, ...action.payload]) } - case 'uncheckSingle': - return { ...state, categoryIndex: state.categoryIndex.filter(val => val !== action.payload) } - case 'checkSingle': - return { ...state, categoryIndex: _.uniq([...state.categoryIndex, action.payload]) } default: - return { ...state, categoryIndex: groupedModuleIndex(groupedModules) } + return initialState } } diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index c0c89415c9..7725321271 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -1,30 +1,20 @@ import React, { useEffect, useState, useReducer } from 'react' -import ReactDOM from 'react-dom' //eslint-disable-line -import CheckBox from './Checkbox/StaticAnalyserCheckedBox' // eslint-disable-line import Button from './Button/StaticAnalyserButton' // eslint-disable-line import remixLib from '@remix-project/remix-lib' import _ from 'lodash' import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line import { RemixUiCheckbox } from '@remix-ui/checkbox' // eslint-disable-line import ErrorRenderer from './ErrorRenderer' // eslint-disable-line -import { compilation, setCompilationResult } from './actions/staticAnalysisActions' -import { analysisReducer, initialState } from './reducers/staticAnalysisReducer' - +import { compilation } from './actions/staticAnalysisActions' +import { initialState, analysisReducer } from './reducers/staticAnalysisReducer' const StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis const utils = remixLib.util /* eslint-disable-next-line */ export interface RemixUiStaticAnalyserProps { - renderStaticAnalysis: any - staticanalysis: any - analysisRunner: any, - lastCompilationResult: any, - lastCompilationSource: any, registry: any, event: any, analysisModule: any - _deps: any, - emit: any } export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { @@ -65,88 +55,46 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return indexOfCategory } const [autoRun, setAutoRun] = useState(true) - - // const initialState = { categoryIndex: [] } - - // const reducer = (state, action) => { - // console.log({ action }) - // switch (action.type) { - // case 'initialize': - // return { categoryIndex: groupedModuleIndex(groupedModules) } - // case 'uncheck': - // return { - // categoryIndex: state.categoryIndex.filter((el) => { - // return !action.payload.includes(el) - // }) - // } - // case 'check': - // return { categoryIndex: _.uniq([...state.categoryIndex, ...action.payload]) } - // case 'uncheckSingle': - // return { categoryIndex: state.categoryIndex.filter(val => val !== action.payload) } - // case 'checkSingle': - // return { categoryIndex: _.uniq([...state.categoryIndex, action.payload]) } - // default: - // return { categoryIndex: groupedModuleIndex(groupedModules) } - // } - // } - - const [state, dispatch] = useReducer(analysisReducer, initialState) + const [categoryIndex, setCategoryIndex] = useState(groupedModuleIndex(groupedModules)) const warningContainer = React.useRef(null) - const [runButtonState, setRunButtonState] = useState(true) - - const [result, setResult] = useState({ - lastCompilationResult: null, - lastCompilationSource: null, - currentFile: 'No file compiled' - }) - const [, setModuleNameResult] = useState(null) - const [, setWarning] = useState({ - options: {}, - hasWarning: false, - warningErrors: [] - }) const [warningState, setWarningState] = useState([]) + const [state, dispatch] = useReducer(analysisReducer, initialState) - // const executeCompilation = (categoryIndex) => { - // const setCompilationResult = async (data, source, file) => { - // await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file }) - // } - // if (props.analysisModule) { - // props.analysisModule.on( - // 'solidity', - // 'compilationFinished', - // (file, source, languageVersion, data) => { - // if (languageVersion.indexOf('soljson') !== 0) return - // setCompilationResult(data, source, file) - // console.log(categoryIndex, ' inside execute funtions') - // if (state.categoryIndex.length > 0) { - // run(data, source, file) - // } - // } - // ) - // } - // } + useEffect(() => { + compilation(props.analysisModule, dispatch) + }, []) useEffect(() => { if (autoRun) { - if (props.analysisModule && state.categoryIndex.length > 0) { - compilation(props.analysisModule, state, run) + if (state.data !== null) { + run(state.data, state.source, state.file) } } - return () => { + return () => { } + }, [autoRun, categoryIndex, state]) + + const message = (name, warning, more, fileName, locationString) : string => { + return (` + + ${name} + ${warning} + ${more + ? (more) + : ( ) } - }, [autoRun, state, props.analysisModule, setWarning]) + Pos: ${locationString} + ` + ) + } const run = (lastCompilationResult, lastCompilationSource, currentFile) => { if (autoRun) { - setResult({ lastCompilationResult, lastCompilationSource, currentFile }) - if (lastCompilationResult && state.categoryIndex.length > 0) { - setRunButtonState(false) + if (lastCompilationResult && categoryIndex.length > 0) { let warningCount = 0 const warningMessage = [] - runner.run(lastCompilationResult, state.categoryIndex, results => { + runner.run(lastCompilationResult, categoryIndex, results => { results.map((result) => { let moduleName Object.keys(groupedModules).map(key => { @@ -156,7 +104,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } }) }) - setModuleNameResult(moduleName) const warningErrors = [] result.report.map((item) => { let location: any = {} @@ -183,6 +130,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { fileName = Object.keys(lastCompilationResult.contracts)[file] } warningCount++ + const msg = message(item.name, item.warning, item.more, fileName, locationString) const options = { type: 'warning', useSpan: true, @@ -197,8 +145,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { location: location } warningErrors.push(options) - setWarning({ hasWarning: true, options, warningErrors: warningErrors }) - warningMessage.push({ options, hasWarning: true, warningModuleName: moduleName }) + warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName }) }) }) const resultArray = [] @@ -216,21 +163,15 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return acc }, {}) } + const groupedCategory = groupBy(resultArray, 'warningModuleName') - console.log({ warningCount }, ' 221') - console.log({ groupedCategory }) setWarningState(groupedCategory) - console.log({ warningState }) - console.log({ warningCount }, ' 223') }) - console.log({ warningCount }, ' CategoryIndex outside function') - if (state.categoryIndex.length > 0) { - console.log(state.categoryIndex, ' CategoryIndex in execute funtions') + if (categoryIndex.length > 0) { props.event.trigger('staticAnaysisWarning', [warningCount]) } } else { - setRunButtonState(true) - if (state.categoryIndex.length) { + if (categoryIndex.length) { warningContainer.current.innerText = 'No compiled AST available' } props.event.trigger('staticAnaysisWarning', [-1]) @@ -240,19 +181,27 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const handleCheckAllModules = (groupedModules) => { const index = groupedModuleIndex(groupedModules) - if (index.every(el => state.categoryIndex.includes(el))) { - dispatch({ type: 'uncheck', payload: index }) + if (index.every(el => categoryIndex.includes(el))) { + setCategoryIndex( + categoryIndex.filter((el) => { + return !index.includes(el) + }) + ) } else { - dispatch({ type: 'check', payload: index }) + setCategoryIndex(_.uniq([...categoryIndex, ...index])) } } const handleCheckOrUncheckCategory = (category) => { const index = groupedModuleIndex(category) - if (index.every(el => state.categoryIndex.includes(el))) { - dispatch({ type: 'uncheck', payload: index }) + if (index.every(el => categoryIndex.includes(el))) { + setCategoryIndex( + categoryIndex.filter((el) => { + return !index.includes(el) + }) + ) } else { - dispatch({ type: 'check', payload: index }) + setCategoryIndex(_.uniq([...categoryIndex, ...index])) } } @@ -266,10 +215,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const handleCheckSingle = (event, _index) => { _index = _index.toString() - if (state.categoryIndex.includes(_index)) { - dispatch({ type: 'uncheckSingle', payload: _index }) + if (categoryIndex.includes(_index)) { + setCategoryIndex(categoryIndex.filter(val => val !== _index)) } else { - dispatch({ type: 'checkSingle', payload: _index }) + setCategoryIndex(_.uniq([...categoryIndex, _index])) } } @@ -284,7 +233,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { itemName={item.name} label={item.description} onClick={event => handleCheckSingle(event, item._index)} - checked={state.categoryIndex.includes(item._index.toString())} + checked={categoryIndex.includes(item._index.toString())} onChange={() => {}} />
@@ -313,7 +262,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { expand={false} >
- handleCheckOrUncheckCategory(category)} id={categoryId} inputType="checkbox" label={`Select ${category[0].categoryDisplayName}`} name='checkCategoryEntry' checked={category.map(x => x._index.toString()).every(el => state.categoryIndex.includes(el))} onChange={() => {}}/> + handleCheckOrUncheckCategory(category)} id={categoryId} inputType="checkbox" label={`Select ${category[0].categoryDisplayName}`} name='checkCategoryEntry' checked={category.map(x => x._index.toString()).every(el => categoryIndex.includes(el))} onChange={() => {}}/>
{category.map((item, i) => { @@ -340,7 +289,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return (value.map(x => { return x._index.toString() })) - }).flat().every(el => state.categoryIndex.includes(el))} + }).flat().every(el => categoryIndex.includes(el))} label="Select all" onClick={() => handleCheckAllModules(groupedModules)} onChange={() => {}} @@ -353,7 +302,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { label="Autorun" onChange={() => {}} /> -
@@ -371,14 +320,12 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { className="text-break break-word word-break font-weight-bold" id="staticAnalysisCurrentFile" > - {result.currentFile && result.currentFile}
- { console.log({ warningState }) } - { state.categoryIndex.length > 0 && Object.entries(warningState).length > 0 && + { categoryIndex.length > 0 && Object.entries(warningState).length > 0 &&
- {/* { + { (Object.entries(warningState).map((element) => ( <> {element[0]} @@ -392,7 +339,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ))} ))) - } */} + }
}