From aee1c9be6452842a4eb9090ef2d1b2d62626be23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Jankovi=C4=87?= <39570184+Riphal@users.noreply.github.com> Date: Tue, 8 Nov 2022 11:20:26 +0100 Subject: [PATCH 01/68] Fix for `Error: Cannot find module 'tenderly'` (#86) * Add 'tenderly' package in @tenderly/hardhat-tenderly dependencies * Add changeset * run yarn install --- .changeset/metal-news-itch.md | 5 +++++ examples/contract-verification/package.json | 4 ++-- packages/tenderly-hardhat/package.json | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .changeset/metal-news-itch.md diff --git a/.changeset/metal-news-itch.md b/.changeset/metal-news-itch.md new file mode 100644 index 00000000..03758bbd --- /dev/null +++ b/.changeset/metal-news-itch.md @@ -0,0 +1,5 @@ +--- +"@tenderly/hardhat-tenderly": patch +--- + +Fix for https://github.com/Tenderly/hardhat-tenderly/issues/84 diff --git a/examples/contract-verification/package.json b/examples/contract-verification/package.json index e50457d2..bedc00e6 100644 --- a/examples/contract-verification/package.json +++ b/examples/contract-verification/package.json @@ -54,8 +54,8 @@ }, "dependencies": { "@nomiclabs/hardhat-ethers": "^2.1.0", - "@tenderly/hardhat-tenderly": "^1.3.0", + "@tenderly/hardhat-tenderly": "^1.3.1", "dotenv": "^16.0.1", "hardhat": "^2.10.2" } -} +} \ No newline at end of file diff --git a/packages/tenderly-hardhat/package.json b/packages/tenderly-hardhat/package.json index 586cb312..632ad7ca 100644 --- a/packages/tenderly-hardhat/package.json +++ b/packages/tenderly-hardhat/package.json @@ -55,10 +55,11 @@ "fs-extra": "^10.1.0", "hardhat": "^2.10.2", "hardhat-deploy": "^0.11.14", - "js-yaml": "^4.1.0" + "js-yaml": "^4.1.0", + "tenderly": "^0.0.2" }, "peerDependencies": { "hardhat": "^2.10.2", "tenderly": "^0.0.2" } -} \ No newline at end of file +} From a9288f9d3dc4d869a14f62d8b5bd5a08bf4b1ad1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 8 Nov 2022 11:21:20 +0100 Subject: [PATCH 02/68] Version Packages (#87) Co-authored-by: github-actions[bot] --- .changeset/metal-news-itch.md | 5 ----- packages/tenderly-hardhat/CHANGELOG.md | 6 ++++++ packages/tenderly-hardhat/package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .changeset/metal-news-itch.md diff --git a/.changeset/metal-news-itch.md b/.changeset/metal-news-itch.md deleted file mode 100644 index 03758bbd..00000000 --- a/.changeset/metal-news-itch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@tenderly/hardhat-tenderly": patch ---- - -Fix for https://github.com/Tenderly/hardhat-tenderly/issues/84 diff --git a/packages/tenderly-hardhat/CHANGELOG.md b/packages/tenderly-hardhat/CHANGELOG.md index 2dd9f2a6..244f8c0e 100644 --- a/packages/tenderly-hardhat/CHANGELOG.md +++ b/packages/tenderly-hardhat/CHANGELOG.md @@ -1,5 +1,11 @@ # @tenderly/hardhat-tenderly +## 1.3.1 + +### Patch Changes + +- [#86](https://github.com/Tenderly/hardhat-tenderly/pull/86) [`aee1c9b`](https://github.com/Tenderly/hardhat-tenderly/commit/aee1c9be6452842a4eb9090ef2d1b2d62626be23) Thanks [@Riphal](https://github.com/Riphal)! - Fix for https://github.com/Tenderly/hardhat-tenderly/issues/84 + ## 1.3.0 ### Minor Changes diff --git a/packages/tenderly-hardhat/package.json b/packages/tenderly-hardhat/package.json index 632ad7ca..857949f8 100644 --- a/packages/tenderly-hardhat/package.json +++ b/packages/tenderly-hardhat/package.json @@ -4,7 +4,7 @@ "license": "MIT", "homepage": "https://tenderly.co", "description": "Hardhat plugin for integration with Tenderly", - "version": "1.3.0", + "version": "1.3.1", "main": "dist/index.js", "types": "dist/index.d.ts", "repository": { From 913aad5b23e3c3c170a600b7153dfe085be34919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Jankovi=C4=87?= <39570184+Riphal@users.noreply.github.com> Date: Tue, 8 Nov 2022 12:11:06 +0100 Subject: [PATCH 03/68] Add changeset (#88) --- .changeset/ten-kiwis-walk.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/ten-kiwis-walk.md diff --git a/.changeset/ten-kiwis-walk.md b/.changeset/ten-kiwis-walk.md new file mode 100644 index 00000000..d7f0ba04 --- /dev/null +++ b/.changeset/ten-kiwis-walk.md @@ -0,0 +1,5 @@ +--- +"tenderly": patch +--- + +Remove got package, start using axios. From 9d2e54fb70f09d03840bdcf860e2498ae60c8725 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 8 Nov 2022 12:12:09 +0100 Subject: [PATCH 04/68] Version Packages (#89) Co-authored-by: github-actions[bot] --- .changeset/ten-kiwis-walk.md | 5 ----- packages/tenderly-core/CHANGELOG.md | 6 ++++++ packages/tenderly-core/package.json | 2 +- packages/tenderly-hardhat/CHANGELOG.md | 7 +++++++ packages/tenderly-hardhat/package.json | 6 +++--- 5 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 .changeset/ten-kiwis-walk.md diff --git a/.changeset/ten-kiwis-walk.md b/.changeset/ten-kiwis-walk.md deleted file mode 100644 index d7f0ba04..00000000 --- a/.changeset/ten-kiwis-walk.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"tenderly": patch ---- - -Remove got package, start using axios. diff --git a/packages/tenderly-core/CHANGELOG.md b/packages/tenderly-core/CHANGELOG.md index 88343160..98b40d0e 100644 --- a/packages/tenderly-core/CHANGELOG.md +++ b/packages/tenderly-core/CHANGELOG.md @@ -1,5 +1,11 @@ # tenderly +## 0.0.3 + +### Patch Changes + +- [#88](https://github.com/Tenderly/hardhat-tenderly/pull/88) [`913aad5`](https://github.com/Tenderly/hardhat-tenderly/commit/913aad5b23e3c3c170a600b7153dfe085be34919) Thanks [@Riphal](https://github.com/Riphal)! - Remove got package, start using axios. + ## 0.0.2 ### Patch Changes diff --git a/packages/tenderly-core/package.json b/packages/tenderly-core/package.json index d2a18fc7..700d2936 100644 --- a/packages/tenderly-core/package.json +++ b/packages/tenderly-core/package.json @@ -4,7 +4,7 @@ "license": "MIT", "homepage": "https://tenderly.co", "description": "", - "version": "0.0.2", + "version": "0.0.3", "main": "internal/lib/tenderly-lib.js", "types": "internal/lib/tenderly-lib.d.ts", "repository": { diff --git a/packages/tenderly-hardhat/CHANGELOG.md b/packages/tenderly-hardhat/CHANGELOG.md index 244f8c0e..4b84d16e 100644 --- a/packages/tenderly-hardhat/CHANGELOG.md +++ b/packages/tenderly-hardhat/CHANGELOG.md @@ -1,5 +1,12 @@ # @tenderly/hardhat-tenderly +## 1.3.2 + +### Patch Changes + +- Updated dependencies [[`913aad5`](https://github.com/Tenderly/hardhat-tenderly/commit/913aad5b23e3c3c170a600b7153dfe085be34919)]: + - tenderly@0.0.3 + ## 1.3.1 ### Patch Changes diff --git a/packages/tenderly-hardhat/package.json b/packages/tenderly-hardhat/package.json index 857949f8..c62e35e6 100644 --- a/packages/tenderly-hardhat/package.json +++ b/packages/tenderly-hardhat/package.json @@ -4,7 +4,7 @@ "license": "MIT", "homepage": "https://tenderly.co", "description": "Hardhat plugin for integration with Tenderly", - "version": "1.3.1", + "version": "1.3.2", "main": "dist/index.js", "types": "dist/index.d.ts", "repository": { @@ -56,10 +56,10 @@ "hardhat": "^2.10.2", "hardhat-deploy": "^0.11.14", "js-yaml": "^4.1.0", - "tenderly": "^0.0.2" + "tenderly": "^0.0.3" }, "peerDependencies": { "hardhat": "^2.10.2", - "tenderly": "^0.0.2" + "tenderly": "^0.0.3" } } From f244890a7d76a986195df141e36b10fe85a962c4 Mon Sep 17 00:00:00 2001 From: Boris Jankovic Date: Tue, 8 Nov 2022 12:17:35 +0100 Subject: [PATCH 05/68] Update example dependencies --- examples/contract-verification/package.json | 4 +- examples/contract-verification/yarn.lock | 360 +++++++++++++++++++- 2 files changed, 346 insertions(+), 18 deletions(-) diff --git a/examples/contract-verification/package.json b/examples/contract-verification/package.json index bedc00e6..cb054eb9 100644 --- a/examples/contract-verification/package.json +++ b/examples/contract-verification/package.json @@ -54,8 +54,8 @@ }, "dependencies": { "@nomiclabs/hardhat-ethers": "^2.1.0", - "@tenderly/hardhat-tenderly": "^1.3.1", + "@tenderly/hardhat-tenderly": "^1.3.2", "dotenv": "^16.0.1", "hardhat": "^2.10.2" } -} \ No newline at end of file +} diff --git a/examples/contract-verification/yarn.lock b/examples/contract-verification/yarn.lock index d13ef323..975f8085 100644 --- a/examples/contract-verification/yarn.lock +++ b/examples/contract-verification/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@colors/colors@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" + integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== + "@cspotcode/source-map-support@^0.8.0": version "0.8.1" resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" @@ -778,10 +783,10 @@ "@sentry/types" "5.30.0" tslib "^1.9.3" -"@tenderly/hardhat-tenderly@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@tenderly/hardhat-tenderly/-/hardhat-tenderly-1.3.0.tgz#7bc3b3a9541b8f255c88ec5018d2e53e20e16368" - integrity sha512-cQ1hiubv7z6A1ZpYBJwCDzmyG6d5Eh/lpcsT+e8QEBZewSUsEmb82BploBRHXGV5d/pRvzWN4xhGKLP6HB38VA== +"@tenderly/hardhat-tenderly@^1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@tenderly/hardhat-tenderly/-/hardhat-tenderly-1.3.2.tgz#9ee69ba1fb8650d18160c637e8e487d938f6dcea" + integrity sha512-0kE0gv8RIu0N5JXKCCfYcydsMgGgj8z3qCvbeD/ynBKwOBvbFB+NZFRyTHNopbeaUKO7Q3bGFau8vS1B0EWS0g== dependencies: "@ethersproject/bignumber" "^5.7.0" "@nomiclabs/hardhat-ethers" "^2.1.1" @@ -791,6 +796,7 @@ hardhat "^2.10.2" hardhat-deploy "^0.11.14" js-yaml "^4.1.0" + tenderly "^0.0.3" "@tsconfig/node10@^1.0.7": version "1.0.9" @@ -1015,6 +1021,14 @@ abstract-level@^1.0.0, abstract-level@^1.0.2, abstract-level@^1.0.3: module-error "^1.0.1" queue-microtask "^1.2.3" +accepts@~1.3.8: + version "1.3.8" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" + integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== + dependencies: + mime-types "~2.1.34" + negotiator "0.6.3" + acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" @@ -1139,6 +1153,11 @@ array-back@^4.0.1, array-back@^4.0.2: resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.2.tgz#8004e999a6274586beeb27342168652fdb89fa1e" integrity sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg== +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== + array-includes@^3.1.4: version "3.1.6" resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.6.tgz#9e9e720e194f198266ba9e18c29e6a9b0e4b225f" @@ -1273,6 +1292,24 @@ bn.js@^5.1.2, bn.js@^5.2.0, bn.js@^5.2.1: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== +body-parser@1.20.1: + version "1.20.1" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.1.tgz#b1812a8912c195cd371a3ee5e66faa2338a5c668" + integrity sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw== + dependencies: + bytes "3.1.2" + content-type "~1.0.4" + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + http-errors "2.0.0" + iconv-lite "0.4.24" + on-finished "2.4.1" + qs "6.11.0" + raw-body "2.5.1" + type-is "~1.6.18" + unpipe "1.0.0" + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -1490,6 +1527,15 @@ clean-stack@^2.0.0: resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== +cli-table3@^0.6.2: + version "0.6.3" + resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.3.tgz#61ab765aac156b52f222954ffc607a6f01dbeeb2" + integrity sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg== + dependencies: + string-width "^4.2.0" + optionalDependencies: + "@colors/colors" "1.5.0" + cliui@^7.0.2: version "7.0.4" resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" @@ -1560,11 +1606,38 @@ commander@3.0.2: resolved "https://registry.yarnpkg.com/commander/-/commander-3.0.2.tgz#6837c3fb677ad9933d1cfba42dd14d5117d6b39e" integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow== +commander@^9.4.0: + version "9.4.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.1.tgz#d1dd8f2ce6faf93147295c0df13c7c21141cfbdd" + integrity sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw== + concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== +content-disposition@0.5.4: + version "0.5.4" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" + integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== + dependencies: + safe-buffer "5.2.1" + +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + integrity sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ== + +cookie@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" + integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== + cookie@^0.4.1: version "0.4.2" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" @@ -1612,6 +1685,13 @@ cross-spawn@^7.0.2: shebang-command "^2.0.0" which "^2.0.1" +debug@2.6.9, debug@^2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + debug@4, debug@4.3.4, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" @@ -1619,13 +1699,6 @@ debug@4, debug@4.3.4, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, de dependencies: ms "2.1.2" -debug@^2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - debug@^3.2.7: version "3.2.7" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" @@ -1655,6 +1728,11 @@ deep-is@^0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== +define-lazy-prop@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f" + integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og== + define-properties@^1.1.3, define-properties@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.4.tgz#0b14d7bd7fbeb2f3572c3a7eda80ea5d57fb05b1" @@ -1673,6 +1751,11 @@ depd@2.0.0: resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== +destroy@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== + diff@5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" @@ -1709,6 +1792,11 @@ dotenv@^16.0.1: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.3.tgz#115aec42bac5053db3c456db30cc243a5a836a07" integrity sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ== +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== + elliptic@6.5.4, elliptic@^6.5.2, elliptic@^6.5.4: version "6.5.4" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" @@ -1732,6 +1820,11 @@ encode-utf8@^1.0.2: resolved "https://registry.yarnpkg.com/encode-utf8/-/encode-utf8-1.0.3.tgz#f30fdd31da07fb596f281beb2f6b027851994cda" integrity sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw== +encodeurl@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w== + enquirer@^2.3.0, enquirer@^2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" @@ -1795,6 +1888,11 @@ escalade@^3.1.1: resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== + escape-string-regexp@4.0.0, escape-string-regexp@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" @@ -1967,6 +2065,11 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== + ethereum-cryptography@0.1.3, ethereum-cryptography@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz#8d6143cfc3d74bf79bbd8edecdf29e4ae20dd191" @@ -2087,6 +2190,43 @@ evp_bytestokey@^1.0.3: md5.js "^1.3.4" safe-buffer "^5.1.1" +express@^4.18.1: + version "4.18.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.18.2.tgz#3fabe08296e930c796c19e3c516979386ba9fd59" + integrity sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ== + dependencies: + accepts "~1.3.8" + array-flatten "1.1.1" + body-parser "1.20.1" + content-disposition "0.5.4" + content-type "~1.0.4" + cookie "0.5.0" + cookie-signature "1.0.6" + debug "2.6.9" + depd "2.0.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.2.0" + fresh "0.5.2" + http-errors "2.0.0" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "2.4.1" + parseurl "~1.3.3" + path-to-regexp "0.1.7" + proxy-addr "~2.0.7" + qs "6.11.0" + range-parser "~1.2.1" + safe-buffer "5.2.1" + send "0.18.0" + serve-static "1.15.0" + setprototypeof "1.2.0" + statuses "2.0.1" + type-is "~1.6.18" + utils-merge "1.0.1" + vary "~1.1.2" + fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" @@ -2139,6 +2279,19 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" +finalhandler@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.2.0.tgz#7d23fe5731b207b4640e4fcd00aec1f9207a7b32" + integrity sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg== + dependencies: + debug "2.6.9" + encodeurl "~1.0.2" + escape-html "~1.0.3" + on-finished "2.4.1" + parseurl "~1.3.3" + statuses "2.0.1" + unpipe "~1.0.0" + find-replace@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38" @@ -2200,6 +2353,11 @@ form-data@^4.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" +forwarded@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" + integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== + fp-ts@1.19.3: version "1.19.3" resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-1.19.3.tgz#261a60d1088fbff01f91256f91d21d0caaaaa96f" @@ -2210,6 +2368,11 @@ fp-ts@^1.0.0: resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-1.19.5.tgz#3da865e585dfa1fdfd51785417357ac50afc520a" integrity sha512-wDNqTimnzs8QqpldiId9OavWK2NptormjXnRJTQecNjzwfyp6P/8s/zG8e4h3ja3oqkKaY72UlTjQYt/1yXf9A== +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== + fs-extra@^0.30.0: version "0.30.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.30.0.tgz#f233ffcc08d4da7d432daa449776989db1df93f0" @@ -2556,6 +2719,11 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" +hyperlinker@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/hyperlinker/-/hyperlinker-1.0.0.tgz#23dc9e38a206b208ee49bc2d6c8ef47027df0c0e" + integrity sha512-Ty8UblRWFEcfSuIaajM34LdPXIhbs1ajEX/BBPv24J+enSVaEVY63xQ6lTO9VRYS5LAoghIG0IDJ+p+IPzKUQQ== + iconv-lite@0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" @@ -2630,6 +2798,11 @@ io-ts@1.10.4: dependencies: fp-ts "^1.0.0" +ipaddr.js@1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" + integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== + is-bigint@^1.0.1: version "1.0.4" resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.4.tgz#08147a1875bc2b32005d41ccd8291dffc6691df3" @@ -2676,6 +2849,11 @@ is-date-object@^1.0.1: dependencies: has-tostringtag "^1.0.0" +is-docker@^2.0.0, is-docker@^2.1.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" + integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== + is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" @@ -2766,6 +2944,13 @@ is-weakref@^1.0.2: dependencies: call-bind "^1.0.2" +is-wsl@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" + integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== + dependencies: + is-docker "^2.0.0" + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -2849,6 +3034,11 @@ klaw@^1.0.0: optionalDependencies: graceful-fs "^4.1.9" +kleur@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" + integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== + level-supports@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/level-supports/-/level-supports-4.0.1.tgz#431546f9d81f10ff0fea0e74533a0e875c08c66a" @@ -2971,6 +3161,11 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ== + memory-level@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/memory-level/-/memory-level-1.0.0.tgz#7323c3fd368f9af2f71c3cd76ba403a17ac41692" @@ -2985,11 +3180,21 @@ memorystream@^0.3.1: resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" integrity sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw== +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w== + merge2@^1.3.0, merge2@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== + micromatch@^4.0.4: version "4.0.5" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" @@ -3003,13 +3208,18 @@ mime-db@1.52.0: resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.12: +mime-types@^2.1.12, mime-types@~2.1.24, mime-types@~2.1.34: version "2.1.35" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== dependencies: mime-db "1.52.0" +mime@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== + minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" @@ -3127,6 +3337,11 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== +negotiator@0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== + node-addon-api@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" @@ -3181,6 +3396,13 @@ obliterator@^2.0.0: resolved "https://registry.yarnpkg.com/obliterator/-/obliterator-2.0.4.tgz#fa650e019b2d075d745e44f1effeb13a2adbe816" integrity sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ== +on-finished@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" + integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== + dependencies: + ee-first "1.1.1" + once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" @@ -3188,6 +3410,15 @@ once@^1.3.0: dependencies: wrappy "1" +open@^8.4.0: + version "8.4.0" + resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8" + integrity sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q== + dependencies: + define-lazy-prop "^2.0.0" + is-docker "^2.1.1" + is-wsl "^2.2.0" + optionator@^0.9.1: version "0.9.1" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" @@ -3257,6 +3488,11 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" +parseurl@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" + integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== + path-exists@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" @@ -3282,6 +3518,11 @@ path-parse@^1.0.6, path-parse@^1.0.7: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + integrity sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ== + path-type@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" @@ -3325,12 +3566,28 @@ prettier@^2.3.1, prettier@^2.7.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +prompts@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" + integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== + dependencies: + kleur "^3.0.3" + sisteransi "^1.0.5" + +proxy-addr@~2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" + integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== + dependencies: + forwarded "0.2.0" + ipaddr.js "1.9.1" + punycode@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -qs@^6.7.0, qs@^6.9.4: +qs@6.11.0, qs@^6.7.0, qs@^6.9.4: version "6.11.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== @@ -3349,7 +3606,12 @@ randombytes@^2.1.0: dependencies: safe-buffer "^5.1.0" -raw-body@^2.4.1: +range-parser@~1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" + integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== + +raw-body@2.5.1, raw-body@^2.4.1: version "2.5.1" resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.1.tgz#fe1b1628b181b700215e5fd42389f98b71392857" integrity sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig== @@ -3478,7 +3740,7 @@ rustbn.js@~0.2.0: resolved "https://registry.yarnpkg.com/rustbn.js/-/rustbn.js-0.2.0.tgz#8082cb886e707155fd1cb6f23bd591ab8d55d0ca" integrity sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA== -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: +safe-buffer@5.2.1, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -3528,6 +3790,25 @@ semver@^7.3.7: dependencies: lru-cache "^6.0.0" +send@0.18.0: + version "0.18.0" + resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" + integrity sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg== + dependencies: + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "2.0.0" + mime "1.6.0" + ms "2.1.3" + on-finished "2.4.1" + range-parser "~1.2.1" + statuses "2.0.1" + serialize-javascript@6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" @@ -3535,6 +3816,16 @@ serialize-javascript@6.0.0: dependencies: randombytes "^2.1.0" +serve-static@1.15.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.15.0.tgz#faaef08cffe0a1a62f60cad0c4e513cff0ac9540" + integrity sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g== + dependencies: + encodeurl "~1.0.2" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.18.0" + setimmediate@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" @@ -3574,6 +3865,11 @@ side-channel@^1.0.4: get-intrinsic "^1.0.2" object-inspect "^1.9.0" +sisteransi@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" + integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== + slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" @@ -3743,6 +4039,20 @@ table@^6.8.0: string-width "^4.2.3" strip-ansi "^6.0.1" +tenderly@^0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tenderly/-/tenderly-0.0.3.tgz#8c85e287e080073502420d5c6f13f4762d0f59cd" + integrity sha512-dVf2uxrIOeLDRNDEXcQlV2xJt50TIx8zGQKlNj1deYTV3FYu2L0zheHBHaDU12GqAff2iiGYk+fKqFkK0bB0+w== + dependencies: + axios "^0.27.2" + cli-table3 "^0.6.2" + commander "^9.4.0" + express "^4.18.1" + hyperlinker "^1.0.0" + js-yaml "^4.1.0" + open "^8.4.0" + prompts "^2.4.2" + text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -3865,6 +4175,14 @@ type-fest@^0.7.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.7.1.tgz#8dda65feaf03ed78f0a3f9678f1869147f7c5c48" integrity sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg== +type-is@~1.6.18: + version "1.6.18" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" + integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== + dependencies: + media-typer "0.3.0" + mime-types "~2.1.24" + typechain@^8.1.0: version "8.1.1" resolved "https://registry.yarnpkg.com/typechain/-/typechain-8.1.1.tgz#9c2e8012c2c4c586536fc18402dcd7034c4ff0bd" @@ -3923,7 +4241,7 @@ universalify@^2.0.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== -unpipe@1.0.0: +unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== @@ -3940,6 +4258,11 @@ util-deprecate@^1.0.1: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== + uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" @@ -3950,6 +4273,11 @@ v8-compile-cache-lib@^3.0.1: resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== +vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" + integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== + which-boxed-primitive@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" From cef972a20378583c2ac293a64b5234e0bd591a1c Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 10:01:47 +0100 Subject: [PATCH 06/68] creation of verbose logging logic --- packages/tenderly-core/package.json | 4 ++-- packages/tenderly-core/src/utils/verbose-logging.ts | 13 +++++++++++++ packages/tenderly-hardhat/package.json | 2 +- packages/tenderly-hardhat/src/index.ts | 4 +++- packages/tenderly-hardhat/src/tenderly/extender.ts | 3 ++- 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 packages/tenderly-core/src/utils/verbose-logging.ts diff --git a/packages/tenderly-core/package.json b/packages/tenderly-core/package.json index 700d2936..79017501 100644 --- a/packages/tenderly-core/package.json +++ b/packages/tenderly-core/package.json @@ -39,7 +39,7 @@ "@types/prompts": "^2.0.14", "@typescript-eslint/eslint-plugin": "^5.36.1", "@typescript-eslint/parser": "^5.36.1", - "eslint": "^8.23.0", + "eslint": "8.22.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", @@ -69,4 +69,4 @@ "optional": true } } -} \ No newline at end of file +} diff --git a/packages/tenderly-core/src/utils/verbose-logging.ts b/packages/tenderly-core/src/utils/verbose-logging.ts new file mode 100644 index 00000000..80179e68 --- /dev/null +++ b/packages/tenderly-core/src/utils/verbose-logging.ts @@ -0,0 +1,13 @@ +let verboseLog: (...arg0: string[]) => void; + +export function setupVerboseLogging(isVerbose: boolean) { + if (isVerbose) { + verboseLog = console.log; + } else { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + verboseLog = function (...args: string[]) {}; + } +} + +// eslint-disable-next-line import/no-default-export +export default verboseLog; diff --git a/packages/tenderly-hardhat/package.json b/packages/tenderly-hardhat/package.json index c62e35e6..b03427c9 100644 --- a/packages/tenderly-hardhat/package.json +++ b/packages/tenderly-hardhat/package.json @@ -39,7 +39,7 @@ "@types/node": "^18.7.15", "@typescript-eslint/eslint-plugin": "^5.36.1", "@typescript-eslint/parser": "^5.36.1", - "eslint": "^8.23.0", + "eslint": "^8.22.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", diff --git a/packages/tenderly-hardhat/src/index.ts b/packages/tenderly-hardhat/src/index.ts index a2b613d9..89618a94 100644 --- a/packages/tenderly-hardhat/src/index.ts +++ b/packages/tenderly-hardhat/src/index.ts @@ -4,7 +4,9 @@ import "./tasks"; import * as tenderlyExtender from "./tenderly/extender"; -export function setup(cfg = { automaticVerifications: false }): void { +export function setup(cfg = { automaticVerifications: false, verboseLogging: true }): void { process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications === true ? "true" : "false"; + process.env.VERBOSE_LOGGING = cfg.verboseLogging === true ? "true" : "false"; + tenderlyExtender.setup(); } diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index bc545279..5adaa5e0 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -16,10 +16,11 @@ import { TenderlyNetwork } from "../TenderlyNetwork"; import { PLUGIN_NAME } from "../constants"; import { wrapEthers } from "./ethers"; import { wrapHHDeployments } from "./hardhat-deploy"; - +import { setupVerboseLogging, verboseLogging } from "tenderly"; const tenderlyService = new TenderlyService(PLUGIN_NAME); export function setup() { + setupVerboseLogging(process.env.VERBOSE_LOGGING); extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); extendProvider(hre); From bf36af0317e2bcb7ce23df6871ea120f48935f9e Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 10:42:54 +0100 Subject: [PATCH 07/68] Deleted custom logging, trying to import an already built in logger module --- packages/tenderly-core/src/utils/verbose-logging.ts | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 packages/tenderly-core/src/utils/verbose-logging.ts diff --git a/packages/tenderly-core/src/utils/verbose-logging.ts b/packages/tenderly-core/src/utils/verbose-logging.ts deleted file mode 100644 index 80179e68..00000000 --- a/packages/tenderly-core/src/utils/verbose-logging.ts +++ /dev/null @@ -1,13 +0,0 @@ -let verboseLog: (...arg0: string[]) => void; - -export function setupVerboseLogging(isVerbose: boolean) { - if (isVerbose) { - verboseLog = console.log; - } else { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - verboseLog = function (...args: string[]) {}; - } -} - -// eslint-disable-next-line import/no-default-export -export default verboseLog; From 3a79801444b6e1bd94dfdf938cfe57dd180fa993 Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 10:43:22 +0100 Subject: [PATCH 08/68] Deleted custom logging, trying to import an already built in logger module --- packages/tenderly-hardhat/src/tenderly/extender.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 5adaa5e0..7111ae7a 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -16,11 +16,9 @@ import { TenderlyNetwork } from "../TenderlyNetwork"; import { PLUGIN_NAME } from "../constants"; import { wrapEthers } from "./ethers"; import { wrapHHDeployments } from "./hardhat-deploy"; -import { setupVerboseLogging, verboseLogging } from "tenderly"; const tenderlyService = new TenderlyService(PLUGIN_NAME); export function setup() { - setupVerboseLogging(process.env.VERBOSE_LOGGING); extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); extendProvider(hre); From b713930e90a09f6011525c2e96da97c09ed9306b Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 10:51:01 +0100 Subject: [PATCH 09/68] Installed tslog into hardhat-tenderly package --- packages/tenderly-hardhat/package.json | 3 ++- packages/tenderly-hardhat/src/tenderly/extender.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/tenderly-hardhat/package.json b/packages/tenderly-hardhat/package.json index b03427c9..b44c7db0 100644 --- a/packages/tenderly-hardhat/package.json +++ b/packages/tenderly-hardhat/package.json @@ -56,7 +56,8 @@ "hardhat": "^2.10.2", "hardhat-deploy": "^0.11.14", "js-yaml": "^4.1.0", - "tenderly": "^0.0.3" + "tenderly": "^0.0.3", + "tslog": "^4.3.1" }, "peerDependencies": { "hardhat": "^2.10.2", diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 7111ae7a..2c16de60 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -11,14 +11,18 @@ import { TENDERLY_JSON_RPC_BASE_URL, } from "tenderly/common/constants"; +import { Logger } from "tslog"; import { Tenderly } from "../Tenderly"; import { TenderlyNetwork } from "../TenderlyNetwork"; import { PLUGIN_NAME } from "../constants"; import { wrapEthers } from "./ethers"; import { wrapHHDeployments } from "./hardhat-deploy"; + const tenderlyService = new TenderlyService(PLUGIN_NAME); +const logger = new Logger({ type: "pretty", name: "HardhatLogger" }); export function setup() { + logger.info("Setup function has been called, extending environment..."); extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); extendProvider(hre); @@ -28,6 +32,7 @@ export function setup() { extendHardhatDeploy(hre); } }); + logger.info("Finished setup."); } extendEnvironment((hre: HardhatRuntimeEnvironment) => { From 2bd6d64bbe8725fa7165bc4a1c438fc76af6fb07 Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 11:47:29 +0100 Subject: [PATCH 10/68] Finished setting up and testing debugger setup --- .../tenderly-hardhat/src/tenderly/extender.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 2c16de60..138aefd1 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -19,20 +19,33 @@ import { wrapEthers } from "./ethers"; import { wrapHHDeployments } from "./hardhat-deploy"; const tenderlyService = new TenderlyService(PLUGIN_NAME); -const logger = new Logger({ type: "pretty", name: "HardhatLogger" }); +const logger = new Logger({ + prettyLogTemplate: "{{dateIsoStr}} {{logLevelName}} {{name}} =>", + name: "HardhatLogger", +}); export function setup() { - logger.info("Setup function has been called, extending environment..."); + logger.debug("Setting up hardhat-tenderly plugin..."); + extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); + + logger.debug("Tenderly configuration: ", { + username: hre.config.tenderly?.username, + project: hre.config.tenderly?.project, + automaticVerification: process.env.AUTOMATIC_VERIFICATION_ENABLED, + privateVerification: hre.config.tenderly?.privateVerification, + }); + extendProvider(hre); populateNetworks(); if (process.env.AUTOMATIC_VERIFICATION_ENABLED === "true") { extendEthers(hre); extendHardhatDeploy(hre); } + + logger.debug("Setup finished."); }); - logger.info("Finished setup."); } extendEnvironment((hre: HardhatRuntimeEnvironment) => { From c31a554db62260f9e949450a923856b9b98eb697 Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 12:07:57 +0100 Subject: [PATCH 11/68] Introduced logging levels so we can tell user to configure them when there is a bug, thus see more information --- packages/tenderly-hardhat/src/index.ts | 4 ++-- packages/tenderly-hardhat/src/tenderly/extender.ts | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/tenderly-hardhat/src/index.ts b/packages/tenderly-hardhat/src/index.ts index 89618a94..41e635aa 100644 --- a/packages/tenderly-hardhat/src/index.ts +++ b/packages/tenderly-hardhat/src/index.ts @@ -4,9 +4,9 @@ import "./tasks"; import * as tenderlyExtender from "./tenderly/extender"; -export function setup(cfg = { automaticVerifications: false, verboseLogging: true }): void { +export function setup(cfg = { automaticVerifications: false, minLogLevel: 7 }): void { process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications === true ? "true" : "false"; - process.env.VERBOSE_LOGGING = cfg.verboseLogging === true ? "true" : "false"; + process.env.MIN_LOG_LEVEL = cfg.minLogLevel !== undefined ? cfg.minLogLevel.toString() : "7"; tenderlyExtender.setup(); } diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 138aefd1..85fb0528 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -25,12 +25,13 @@ const logger = new Logger({ }); export function setup() { - logger.debug("Setting up hardhat-tenderly plugin..."); + logger.settings.minLevel = Number(process.env.MIN_LOG_LEVEL); + logger.trace(`Setting up hardhat-tenderly plugin... Log level set to: ${logger.settings.minLevel}`); extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); - logger.debug("Tenderly configuration: ", { + logger.trace("Tenderly configuration: ", { username: hre.config.tenderly?.username, project: hre.config.tenderly?.project, automaticVerification: process.env.AUTOMATIC_VERIFICATION_ENABLED, @@ -44,7 +45,7 @@ export function setup() { extendHardhatDeploy(hre); } - logger.debug("Setup finished."); + logger.trace("Setup finished."); }); } From 1c8d0d3059bbc2b2c22daec3bbe55702d7961efe Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 12:13:43 +0100 Subject: [PATCH 12/68] Extracted logger into a separate file so it can be used from multiple locations --- packages/tenderly-hardhat/src/tenderly/extender.ts | 9 +++------ packages/tenderly-hardhat/src/utils/logger.ts | 6 ++++++ 2 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 packages/tenderly-hardhat/src/utils/logger.ts diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 85fb0528..6afa524b 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -11,7 +11,7 @@ import { TENDERLY_JSON_RPC_BASE_URL, } from "tenderly/common/constants"; -import { Logger } from "tslog"; +import { logger } from "../utils/logger"; import { Tenderly } from "../Tenderly"; import { TenderlyNetwork } from "../TenderlyNetwork"; import { PLUGIN_NAME } from "../constants"; @@ -19,10 +19,6 @@ import { wrapEthers } from "./ethers"; import { wrapHHDeployments } from "./hardhat-deploy"; const tenderlyService = new TenderlyService(PLUGIN_NAME); -const logger = new Logger({ - prettyLogTemplate: "{{dateIsoStr}} {{logLevelName}} {{name}} =>", - name: "HardhatLogger", -}); export function setup() { logger.settings.minLevel = Number(process.env.MIN_LOG_LEVEL); @@ -31,11 +27,12 @@ export function setup() { extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); - logger.trace("Tenderly configuration: ", { + logger.trace("Tenderly running configuration: ", { username: hre.config.tenderly?.username, project: hre.config.tenderly?.project, automaticVerification: process.env.AUTOMATIC_VERIFICATION_ENABLED, privateVerification: hre.config.tenderly?.privateVerification, + networkName: hre.network.name, }); extendProvider(hre); diff --git a/packages/tenderly-hardhat/src/utils/logger.ts b/packages/tenderly-hardhat/src/utils/logger.ts new file mode 100644 index 00000000..fa62841f --- /dev/null +++ b/packages/tenderly-hardhat/src/utils/logger.ts @@ -0,0 +1,6 @@ +import { Logger } from "tslog"; + +export const logger = new Logger({ + prettyLogTemplate: "{{dateIsoStr}} {{logLevelName}} {{name}} =>", + name: "HardhatLogger", +}); From a675d965ec51b11e29425b9cb511e136db32b4aa Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 13:12:49 +0100 Subject: [PATCH 13/68] Covered whole extender.ts in logs --- packages/tenderly-hardhat/src/tenderly/extender.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 6afa524b..438a1640 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -38,8 +38,10 @@ export function setup() { extendProvider(hre); populateNetworks(); if (process.env.AUTOMATIC_VERIFICATION_ENABLED === "true") { + logger.silly("Automatic verification is enabled, proceeding to extend ethers library..."); extendEthers(hre); extendHardhatDeploy(hre); + logger.silly("Wrapping ethers library finished."); } logger.trace("Setup finished."); @@ -60,12 +62,14 @@ extendConfig((resolvedConfig: HardhatConfig) => { const extendProvider = (hre: HardhatRuntimeEnvironment): void => { if (hre.network.name !== "tenderly") { + logger.info("Used network is not 'tenderly' so there is no extending of the provider."); return; } if ("url" in hre.network.config && hre.network.config.url !== undefined) { const forkID = hre.network.config.url.split("/").pop(); hre.tenderly.network().setFork(forkID); + logger.info(`There is a fork url in the 'tenderly' network`, { forkID }); return; } @@ -79,7 +83,7 @@ const extendProvider = (hre: HardhatRuntimeEnvironment): void => { hre.ethers.provider = new hre.ethers.providers.Web3Provider(hre.tenderly.network()); }) .catch((_) => { - console.log(`Error in ${PLUGIN_NAME}: Initializing fork, check your tenderly configuration`); + logger.error(`Error happened while trying to initialize fork ${PLUGIN_NAME}. Check your tenderly configuration`); }); }; @@ -102,9 +106,10 @@ const populateNetworks = (): void => { NETWORK_NAME_CHAIN_ID_MAP[slug] = network.ethereum_network_id; } } + logger.trace("Obtained supported public networks: ", NETWORK_NAME_CHAIN_ID_MAP); }) .catch((_) => { - console.log("Error encountered while fetching public networks"); + logger.error("Error encountered while fetching public networks"); }); }; From bb2c185d27351d627c2aba809415cc890db5cad9 Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 13:33:27 +0100 Subject: [PATCH 14/68] Changed minLogLevel to be a optional value that is set to 7 by default --- packages/tenderly-hardhat/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/tenderly-hardhat/src/index.ts b/packages/tenderly-hardhat/src/index.ts index 41e635aa..d3dda720 100644 --- a/packages/tenderly-hardhat/src/index.ts +++ b/packages/tenderly-hardhat/src/index.ts @@ -4,7 +4,9 @@ import "./tasks"; import * as tenderlyExtender from "./tenderly/extender"; -export function setup(cfg = { automaticVerifications: false, minLogLevel: 7 }): void { +export function setup( + cfg: { automaticVerifications: boolean; minLogLevel?: number } = { automaticVerifications: false, minLogLevel: 7 } +): void { process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications === true ? "true" : "false"; process.env.MIN_LOG_LEVEL = cfg.minLogLevel !== undefined ? cfg.minLogLevel.toString() : "7"; From a66e75808714fdf4e26d7879a7d74283d97d6f26 Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 24 Nov 2022 14:49:23 +0100 Subject: [PATCH 15/68] Added logs to Tenderly.ts in hardhat-tenderly --- packages/tenderly-hardhat/src/Tenderly.ts | 57 +++++++++++++++++---- packages/tenderly-hardhat/src/utils/util.ts | 10 +++- 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index 4fdd3088..eb171d6c 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -5,6 +5,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"; import { TenderlyService } from "tenderly"; import { TenderlyArtifact, TenderlyContractUploadRequest, TenderlyForkContractUploadRequest } from "tenderly/types"; import { NETWORK_NAME_CHAIN_ID_MAP } from "tenderly/common/constants"; +import { logger } from "./utils/logger"; import { ContractByName, Metadata } from "./tenderly/types"; import { CONTRACTS_NOT_DETECTED, NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG } from "./tenderly/errors"; @@ -19,17 +20,27 @@ export class Tenderly { private tenderlyService = new TenderlyService(PLUGIN_NAME); constructor(hre: HardhatRuntimeEnvironment) { + logger.silly("Making hardhat Tenderly interface..."); + this.env = hre; this.tenderlyNetwork = new TenderlyNetwork(hre); + + logger.silly("Finished making hardhat Tenderly interface."); } public async verify(...contracts: any[]): Promise { + logger.info("Public verification has been called."); + const priv = this.env.config.tenderly?.privateVerification; if (priv !== undefined && priv && this.env.network.name !== "tenderly") { + logger.info( + "Private verification flag is set to TRUE in tenderly configuration. Redirecting to private verification..." + ); return this.push(...contracts); } if (this.env.network.name === "tenderly") { + logger.info("Network parameter is set to 'tenderly', redirecting to fork verification..."); return this.tenderlyNetwork.verify(contracts); } @@ -38,7 +49,7 @@ export class Tenderly { const requestData = await this._filterContracts(flatContracts); if (requestData === null) { - console.log("Verification failed"); + logger.error("Verification failed"); return; } @@ -46,9 +57,11 @@ export class Tenderly { } public async verifyAPI(request: TenderlyContractUploadRequest): Promise { + logger.info("Public verification API has been called."); + if (this.env.network.name === "tenderly") { - console.log( - `Error in ${PLUGIN_NAME}: .verifyAPI() is not available for fork deployments, please use verifyForkAPI().` + logger.error( + `Error in ${PLUGIN_NAME}: Network parameter is set to 'tenderly' and verifyAPI() is not available for fork deployments, please use verifyForkAPI().` ); return; } @@ -62,9 +75,10 @@ export class Tenderly { username: string, forkID: string ): Promise { + logger.info("Fork verification has been called."); if (this.env.network.name !== "tenderly") { console.log( - `Error in ${PLUGIN_NAME}: .verifyForkAPI() is only available for tenderly fork deployments, please use --network tenderly.` + `Error in ${PLUGIN_NAME}: Network parameter is not set to 'tenderly' and verifyForkAPI() is only available for tenderly fork deployments, please use --network tenderly.` ); return; } @@ -78,12 +92,19 @@ export class Tenderly { public setNetwork(network: TenderlyNetwork): TenderlyNetwork { this.tenderlyNetwork = network; + logger.trace("Network is set to 'tenderly'.", network); + return this.tenderlyNetwork; } public async push(...contracts: any[]): Promise { + logger.info("Private verification has been called."); + const priv = this.env.config.tenderly?.privateVerification; if (priv !== undefined && !priv) { + logger.info( + "Private verification flag is set to FALSE in tenderly configuration. Redirecting to public verification..." + ); return this.verify(...contracts); } @@ -92,14 +113,14 @@ export class Tenderly { const requestData = await this._filterContracts(flatContracts); if (this.env.config.tenderly.project === undefined) { - console.log( + logger.error( `Error in ${PLUGIN_NAME}: Please provide the project field in the tenderly object in hardhat.config.js` ); return; } if (this.env.config.tenderly.username === undefined) { - console.log( + logger.error( `Error in ${PLUGIN_NAME}: Please provide the username field in the tenderly object in hardhat.config.js` ); return; @@ -122,9 +143,11 @@ export class Tenderly { tenderlyProject: string, username: string ): Promise { + logger.info("Private verification API has been called."); + if (this.env.network.name === "tenderly") { - console.log( - `Error in ${PLUGIN_NAME}: .pushAPI() is not available for fork deployments, please use verifyForkAPI().` + logger.error( + `Error in ${PLUGIN_NAME}: Network parameter is set to 'tenderly' and pushAPI() is not available for fork deployments, please use verifyForkAPI().` ); return; } @@ -133,7 +156,9 @@ export class Tenderly { } public async persistArtifacts(...contracts: ContractByName[]) { + logger.info("Artifact persisting has been called."); if (contracts.length === 0) { + logger.error("No contracts were provided during artifact persisting."); return; } @@ -201,6 +226,8 @@ export class Tenderly { abi: contractData.abi, }; + logger.trace("Processed artifact: ", artifact); + fs.outputFileSync(`${destPath}${name}.json`, JSON.stringify(artifact)); } } @@ -208,11 +235,15 @@ export class Tenderly { } private async _filterContracts(flatContracts: ContractByName[]): Promise { + logger.info("Contract filtering has been called."); + let contract: ContractByName; let requestData: TenderlyContractUploadRequest; try { requestData = await this._getContractData(flatContracts); + logger.trace("Request data obtained: ", requestData); } catch (e) { + logger.error("Error caught while trying to process contracts by name: ", e); return null; } @@ -222,7 +253,7 @@ export class Tenderly { ? this.env.hardhatArguments.network ?? contract.network : contract.network; if (network === undefined) { - console.log( + logger.error( `Error in ${PLUGIN_NAME}: Please provide a network via the hardhat --network argument or directly in the contract` ); return null; @@ -232,6 +263,7 @@ export class Tenderly { (requestContract) => requestContract.contractName === contract.name ); if (index === -1) { + logger.error(`Contract '${contract.name}' was not found in processed data.`); continue; } let chainID: string = NETWORK_NAME_CHAIN_ID_MAP[network!.toLowerCase()]; @@ -240,7 +272,7 @@ export class Tenderly { } if (chainID === undefined) { - console.log( + logger.error( `Error in ${PLUGIN_NAME}: Couldn't identify network. Please provide a chainID in the network config object` ); return null; @@ -253,6 +285,9 @@ export class Tenderly { }; } + fs.outputFileSync("filterContractsData.json", requestData); + logger.trace("Wrote data to a separate file 'filterContractsData.json' to avoid console clutter."); + return requestData; } @@ -261,7 +296,7 @@ export class Tenderly { const config = getCompilerDataFromContracts(contracts, flatContracts, this.env.config); if (config === undefined) { - console.log(NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG); + logger.error(NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG); } return { diff --git a/packages/tenderly-hardhat/src/utils/util.ts b/packages/tenderly-hardhat/src/utils/util.ts index 5ba9612e..132002ae 100644 --- a/packages/tenderly-hardhat/src/utils/util.ts +++ b/packages/tenderly-hardhat/src/utils/util.ts @@ -6,12 +6,15 @@ import { TenderlyContract, TenderlyContractConfig } from "tenderly/types"; import { PLUGIN_NAME } from "../constants"; import { CONTRACTS_NOT_DETECTED } from "../tenderly/errors"; import { ContractByName, Metadata } from "../tenderly/types"; +import { logger } from "./logger"; export const getCompilerDataFromContracts = ( contracts: TenderlyContract[], flatContracts: ContractByName[], hhConfig: HardhatConfig ): TenderlyContractConfig | undefined => { + logger.trace("Obtaining compiler data from contracts..."); + let contract: TenderlyContract; let mainContract: ContractByName; let config: TenderlyContractConfig | undefined; @@ -23,13 +26,14 @@ export const getCompilerDataFromContracts = ( const contractConfig = newCompilerConfig(hhConfig, contract.sourcePath, contract.compiler?.version); if (config !== null && config !== undefined && !compareConfigs(contractConfig, config)) { - console.log(`Error in ${PLUGIN_NAME}: Different compiler versions provided in same request`); + logger.error(`Error in ${PLUGIN_NAME}: Different compiler versions provided in same request`); throw new Error("Compiler version mismatch"); } else { config = contractConfig; } } } + logger.trace("Compiler data has been obtained."); return config; }; @@ -38,6 +42,8 @@ export const getContracts = async ( hre: HardhatRuntimeEnvironment, flatContracts: ContractByName[] ): Promise => { + logger.trace("Processing contracts from the artifacts/ folder."); + const sourcePaths = await hre.run("compile:solidity:get-source-paths"); const sourceNames = await hre.run("compile:solidity:get-source-names", { sourcePaths, @@ -90,6 +96,8 @@ export const getContracts = async ( }; requestContracts.push(contractToPush); } + + logger.trace("Finished processing contracts from the artifacts/ folder."); return requestContracts; }; From 6d008ff0cc96cce6ef54f82a7a5e8f43cd465c7b Mon Sep 17 00:00:00 2001 From: dule-git Date: Fri, 25 Nov 2022 14:24:25 +0100 Subject: [PATCH 16/68] Changed some log levels and added some new logs. --- packages/tenderly-hardhat/src/Tenderly.ts | 24 +++++++--- .../tenderly-hardhat/src/tenderly/extender.ts | 12 ++--- packages/tenderly-hardhat/src/utils/util.ts | 44 +++++++++++++++++-- 3 files changed, 65 insertions(+), 15 deletions(-) diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index eb171d6c..b1f69898 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -20,12 +20,12 @@ export class Tenderly { private tenderlyService = new TenderlyService(PLUGIN_NAME); constructor(hre: HardhatRuntimeEnvironment) { - logger.silly("Making hardhat Tenderly interface..."); + logger.debug("Making hardhat Tenderly interface..."); this.env = hre; this.tenderlyNetwork = new TenderlyNetwork(hre); - logger.silly("Finished making hardhat Tenderly interface."); + logger.debug("Finished making hardhat Tenderly interface."); } public async verify(...contracts: any[]): Promise { @@ -175,10 +175,15 @@ export class Tenderly { data._resolvedFiles.forEach((resolvedFile: any, _: any) => { const sourcePath: string = resolvedFile.sourceName; + logger.trace("Currently processing file:", sourcePath); + const name = sourcePath.split("/").slice(-1)[0].split(".")[0]; + logger.trace("Obtained name from source file:", name); for (contract of contracts) { if (contract.name === name) { + logger.trace("Found contract:", contract.name); + const network = this.env.hardhatArguments.network !== "hardhat" ? this.env.hardhatArguments.network ?? contract.network @@ -241,7 +246,7 @@ export class Tenderly { let requestData: TenderlyContractUploadRequest; try { requestData = await this._getContractData(flatContracts); - logger.trace("Request data obtained: ", requestData); + logger.silly("Request data obtained: ", requestData); } catch (e) { logger.error("Error caught while trying to process contracts by name: ", e); return null; @@ -258,6 +263,7 @@ export class Tenderly { ); return null; } + logger.trace("Found network is:", network); const index = requestData.contracts.findIndex( (requestContract) => requestContract.contractName === contract.name @@ -270,6 +276,7 @@ export class Tenderly { if (this.env.config.networks[network!].chainId !== undefined) { chainID = this.env.config.networks[network!].chainId!.toString(); } + logger.trace(`ChainID for network '${network}' is ${chainID}`); if (chainID === undefined) { logger.error( @@ -285,8 +292,15 @@ export class Tenderly { }; } - fs.outputFileSync("filterContractsData.json", requestData); - logger.trace("Wrote data to a separate file 'filterContractsData.json' to avoid console clutter."); + if ( + process.env.MIN_LOG_LEVEL !== undefined && + process.env.MIN_LOG_LEVEL !== null && + process.env.MIN_LOG_LEVEL !== "" && + Number(process.env.MIN_LOG_LEVEL) <= 2 + ) { + fs.outputFileSync("./filterContractsData.json", JSON.stringify(requestData)); + logger.debug("Wrote data to a separate file 'filterContractsData.json' to avoid console clutter."); + } return requestData; } diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 438a1640..b3d8875a 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -22,12 +22,12 @@ const tenderlyService = new TenderlyService(PLUGIN_NAME); export function setup() { logger.settings.minLevel = Number(process.env.MIN_LOG_LEVEL); - logger.trace(`Setting up hardhat-tenderly plugin... Log level set to: ${logger.settings.minLevel}`); + logger.debug(`Setting up hardhat-tenderly plugin... Log level set to: ${logger.settings.minLevel}`); extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); - logger.trace("Tenderly running configuration: ", { + logger.info("Tenderly running configuration: ", { username: hre.config.tenderly?.username, project: hre.config.tenderly?.project, automaticVerification: process.env.AUTOMATIC_VERIFICATION_ENABLED, @@ -38,13 +38,13 @@ export function setup() { extendProvider(hre); populateNetworks(); if (process.env.AUTOMATIC_VERIFICATION_ENABLED === "true") { - logger.silly("Automatic verification is enabled, proceeding to extend ethers library..."); + logger.debug("Automatic verification is enabled, proceeding to extend ethers library..."); extendEthers(hre); extendHardhatDeploy(hre); - logger.silly("Wrapping ethers library finished."); + logger.debug("Wrapping ethers library finished."); } - logger.trace("Setup finished."); + logger.debug("Setup finished."); }); } @@ -106,7 +106,7 @@ const populateNetworks = (): void => { NETWORK_NAME_CHAIN_ID_MAP[slug] = network.ethereum_network_id; } } - logger.trace("Obtained supported public networks: ", NETWORK_NAME_CHAIN_ID_MAP); + logger.info("Obtained supported public networks: ", NETWORK_NAME_CHAIN_ID_MAP); }) .catch((_) => { logger.error("Error encountered while fetching public networks"); diff --git a/packages/tenderly-hardhat/src/utils/util.ts b/packages/tenderly-hardhat/src/utils/util.ts index 132002ae..3fd6b3a8 100644 --- a/packages/tenderly-hardhat/src/utils/util.ts +++ b/packages/tenderly-hardhat/src/utils/util.ts @@ -13,7 +13,7 @@ export const getCompilerDataFromContracts = ( flatContracts: ContractByName[], hhConfig: HardhatConfig ): TenderlyContractConfig | undefined => { - logger.trace("Obtaining compiler data from contracts..."); + logger.debug("Obtaining compiler data from contracts..."); let contract: TenderlyContract; let mainContract: ContractByName; @@ -23,6 +23,7 @@ export const getCompilerDataFromContracts = ( if (mainContract.name !== contract.contractName) { continue; } + logger.trace("Currently obtaining compiler data from contract:", mainContract.name); const contractConfig = newCompilerConfig(hhConfig, contract.sourcePath, contract.compiler?.version); if (config !== null && config !== undefined && !compareConfigs(contractConfig, config)) { @@ -33,7 +34,8 @@ export const getCompilerDataFromContracts = ( } } } - logger.trace("Compiler data has been obtained."); + logger.debug("Compiler data has been obtained."); + logger.silly("Obtained compiler configuration is:", config); return config; }; @@ -42,7 +44,7 @@ export const getContracts = async ( hre: HardhatRuntimeEnvironment, flatContracts: ContractByName[] ): Promise => { - logger.trace("Processing contracts from the artifacts/ folder."); + logger.debug("Processing contracts from the artifacts/ folder."); const sourcePaths = await hre.run("compile:solidity:get-source-paths"); const sourceNames = await hre.run("compile:solidity:get-source-names", { @@ -63,20 +65,41 @@ export const getContracts = async ( }, sources: {}, }; + logger.trace("Extracted compiler version is:", metadata.defaultCompiler.version); data._resolvedFiles.forEach((resolvedFile: any, _: any) => { const sourcePath: string = resolvedFile.sourceName; + logger.trace("Currently processing file:", sourcePath); + const name = sourcePath.split("/").slice(-1)[0].split(".")[0]; + logger.trace("Obtained name from source file:", name); for (contract of flatContracts) { if (contract.name !== name) { continue; } + logger.trace("Found contract:", contract.name); metadata.sources[sourcePath] = { content: resolvedFile.content.rawContent, versionPragma: resolvedFile.content.versionPragmas[0], }; + + if ( + metadata.sources[sourcePath].content === undefined || + metadata.sources[sourcePath].content === null || + metadata.sources[sourcePath].content === "" + ) { + logger.error("Metadata source content is empty!"); + } + if ( + metadata.sources[sourcePath].versionPragma === undefined || + metadata.sources[sourcePath].versionPragma === null || + metadata.sources[sourcePath].versionPragma === "" + ) { + logger.error("Metadata source version pragma is empty!"); + } + const visited: Record = {}; resolveDependencies(data, sourcePath, metadata, visited); } @@ -97,7 +120,8 @@ export const getContracts = async ( requestContracts.push(contractToPush); } - logger.trace("Finished processing contracts from the artifacts/ folder."); + logger.silly("Finished processing contracts from the artifacts/ folder:", requestContracts); + return requestContracts; }; @@ -144,6 +168,8 @@ export const newCompilerConfig = ( contractCompiler?: string ): TenderlyContractConfig => { if (sourcePath !== undefined && config.solidity.overrides[sourcePath] !== undefined) { + logger.trace("There is an compiler config override for:", sourcePath); + return { compiler_version: config.solidity.overrides[sourcePath].version, optimizations_used: config.solidity.overrides[sourcePath].settings.optimizer.enabled, @@ -152,10 +178,14 @@ export const newCompilerConfig = ( debug: config.solidity.overrides[sourcePath].settings.debug, }; } + if (contractCompiler !== undefined) { + logger.trace("There is a provided compiler configuration, determining it..."); return determineCompilerConfig(config.solidity.compilers, contractCompiler); } + logger.trace("Returning the first compiler in the configuration"); + return { compiler_version: config.solidity.compilers[0].version, optimizations_used: config.solidity.compilers[0].settings.optimizer.enabled, @@ -183,6 +213,8 @@ export const extractCompilerVersion = (config: HardhatConfig, sourcePath?: strin const determineCompilerConfig = (compilers: SolcConfig[], contractCompiler: string): TenderlyContractConfig => { for (const compiler of compilers) { if (compareVersions(compiler.version, contractCompiler)) { + logger.trace("Provided compiler matched the version: ", compiler.version); + return { compiler_version: compiler.version, optimizations_used: compiler.settings.optimizer.enabled, @@ -193,6 +225,10 @@ const determineCompilerConfig = (compilers: SolcConfig[], contractCompiler: stri } } + logger.trace( + "Couldn't find the provided compiler among compilers in the configuration, returning the configuration of the first one" + ); + return { compiler_version: compilers[0].version, optimizations_used: compilers[0].settings.optimizer.enabled, From 4cbe47bfb8db3512bb035fd92c11f5030f81e24e Mon Sep 17 00:00:00 2001 From: dule-git Date: Fri, 25 Nov 2022 14:53:02 +0100 Subject: [PATCH 17/68] Added logs into TenderlyNetwork.ts --- .../tenderly-hardhat/src/TenderlyNetwork.ts | 61 +++++++++++++++---- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index a3d4b69a..b1c7330f 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -1,15 +1,16 @@ import * as axios from "axios"; -import { HardhatRuntimeEnvironment } from "hardhat/types"; -import { TenderlyService } from "tenderly"; -import { TenderlyForkContractUploadRequest } from "tenderly/types"; -import { getConfig, writeConfig } from "tenderly/utils/config"; -import { TENDERLY_JSON_RPC_BASE_URL } from "tenderly/common/constants"; - -import { PLUGIN_NAME } from "./constants"; -import { ContractByName } from "./tenderly/types"; -import { NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG } from "./tenderly/errors"; -import { getCompilerDataFromContracts, getContracts } from "./utils/util"; +import {HardhatRuntimeEnvironment} from "hardhat/types"; +import {TenderlyService} from "tenderly"; +import {TenderlyForkContractUploadRequest} from "tenderly/types"; +import {getConfig, writeConfig} from "tenderly/utils/config"; +import {TENDERLY_JSON_RPC_BASE_URL} from "tenderly/common/constants"; + +import {PLUGIN_NAME} from "./constants"; +import {ContractByName} from "./tenderly/types"; +import {NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG} from "./tenderly/errors"; +import {getCompilerDataFromContracts, getContracts} from "./utils/util"; +import {logger} from "./utils/logger"; export class TenderlyNetwork { public host: string; @@ -24,17 +25,23 @@ export class TenderlyNetwork { private tenderlyService = new TenderlyService(PLUGIN_NAME); constructor(hre: HardhatRuntimeEnvironment) { + logger.debug("Making an interface towards tenderly network..."); + this.env = hre; this.connected = true; const tdlyGlobalConfig = getConfig(); + logger.info("Obtained global tenderly config:", tdlyGlobalConfig); + this.accessKey = tdlyGlobalConfig?.access_key; this.tenderlyJsonRpc = this._configureTenderlyRPCInstance(); this.host = this.tenderlyJsonRpc.defaults.baseURL!; + logger.info("Obtained tenderly json rpc:", tdlyGlobalConfig); if (hre.network.name === "tenderly" && "url" in hre.network.config && hre.network.config.url !== undefined) { this.forkID = hre.network.config.url.split("/").pop(); + logger.info("Fork ID is:", this.forkID); } } @@ -53,6 +60,7 @@ export class TenderlyNetwork { } public async send(payload: any, cb: any) { + // I won't put logs here because it isn't called from anywhere if (!this._checkNetwork()) { return; } @@ -85,20 +93,26 @@ export class TenderlyNetwork { } public async verify(...contracts: any[]) { + logger.info("Fork verification has been called."); if (!this._checkNetwork()) { return; } if (this.head === undefined && this.forkID === undefined) { + logger.warn("Head or fork are not initialized."); await this.initializeFork(); } const flatContracts: ContractByName[] = contracts.reduce((accumulator, value) => accumulator.concat(value), []); const requestData = await this._filterContracts(flatContracts); + logger.silly("Obtained request data needed for verifying contracts:", requestData); + if (requestData === null) { + logger.error("Filtering contracts did not succeed."); return; } if (requestData?.contracts.length === 0) { + logger.error("Filtering contracts did not succeed. The length of the contracts is 0."); return; } @@ -116,6 +130,7 @@ export class TenderlyNetwork { username: string, forkID: string ) { + logger.info("Fork verification via API has been called,"); await this.tenderlyService.verifyForkContracts(request, tenderlyProject, username, forkID); } @@ -149,23 +164,35 @@ export class TenderlyNetwork { } public async initializeFork() { + logger.debug("Fork initialization has been called."); + if (!this._checkNetwork()) { return; } if (this.env.config.tenderly?.forkNetwork === undefined) { + logger.error("There is no information about the fork network. Fork won't be initialized"); return; } const username: string = this.env.config.tenderly.username; const projectID: string = this.env.config.tenderly.project; + logger.trace("Username and projectID obtained from tenderly configuration:", {username, projectID}); + try { + logger.debug("Making a call to initialize fork..."); const resp = await this.tenderlyJsonRpc.post(`/account/${username}/project/${projectID}/fork`, { network_id: this.env.config.tenderly.forkNetwork, }); + + logger.trace("Obtained information from a call:", resp); + this.head = resp.data.root_transaction.id; this.accounts = resp.data.simulation_fork.accounts; this.forkID = resp.data.simulation_fork.id; + + logger.debug("Successfully initialized fork."); } catch (err) { + logger.error("Error was caught while calling fork initialization:", err); throw err; } } @@ -177,11 +204,15 @@ export class TenderlyNetwork { } private async _filterContracts(flatContracts: ContractByName[]): Promise { + logger.info("Filtering contracts for fork verification has been called."); + let contract: ContractByName; let requestData: TenderlyForkContractUploadRequest; try { requestData = await this._getForkContractData(flatContracts); + logger.silly("Obtained request data needed for fork verification:", requestData); } catch (e) { + logger.error("Caught and error while trying to obtain data needed for fork verification", e); return null; } @@ -190,20 +221,26 @@ export class TenderlyNetwork { (requestContract) => requestContract.contractName === contract.name ); if (index === -1) { + logger.error(`Couldn't find a contract '${contract.name}' among the obtained request data.`); continue; } + + logger.trace("Currently processing contract:", contract.name); requestData.contracts[index].networks = { [this.forkID!]: { address: contract.address, links: contract.libraries, }, }; + logger.trace(`Contract ${contract.name} has been processed,`); } return requestData; } private async _getForkContractData(flatContracts: ContractByName[]): Promise { + logger.trace("Getting contract data for fork verification has been called."); + const contracts = await getContracts(this.env, flatContracts); if (contracts.length === 0) { throw new Error("Failed to get contracts"); @@ -212,7 +249,7 @@ export class TenderlyNetwork { const solcConfig = getCompilerDataFromContracts(contracts, flatContracts, this.env.config); if (solcConfig === undefined) { - console.log(NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG); + logger.error(NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG); } return { @@ -224,7 +261,7 @@ export class TenderlyNetwork { private _checkNetwork(): boolean { if (this.env.network.name !== "tenderly") { - console.log( + logger.error( `Warning in ${PLUGIN_NAME}: Network is not set to tenderly. Please call the task again with --network tenderly` ); return false; From 26e8d4f2c217304d95d62cdb31051f2038d7b5e5 Mon Sep 17 00:00:00 2001 From: dule-git Date: Fri, 25 Nov 2022 14:54:37 +0100 Subject: [PATCH 18/68] Linter correction. --- .../tenderly-hardhat/src/TenderlyNetwork.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index b1c7330f..a1cc287a 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -1,16 +1,16 @@ import * as axios from "axios"; -import {HardhatRuntimeEnvironment} from "hardhat/types"; -import {TenderlyService} from "tenderly"; -import {TenderlyForkContractUploadRequest} from "tenderly/types"; -import {getConfig, writeConfig} from "tenderly/utils/config"; -import {TENDERLY_JSON_RPC_BASE_URL} from "tenderly/common/constants"; - -import {PLUGIN_NAME} from "./constants"; -import {ContractByName} from "./tenderly/types"; -import {NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG} from "./tenderly/errors"; -import {getCompilerDataFromContracts, getContracts} from "./utils/util"; -import {logger} from "./utils/logger"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { TenderlyService } from "tenderly"; +import { TenderlyForkContractUploadRequest } from "tenderly/types"; +import { getConfig, writeConfig } from "tenderly/utils/config"; +import { TENDERLY_JSON_RPC_BASE_URL } from "tenderly/common/constants"; + +import { PLUGIN_NAME } from "./constants"; +import { ContractByName } from "./tenderly/types"; +import { NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG } from "./tenderly/errors"; +import { getCompilerDataFromContracts, getContracts } from "./utils/util"; +import { logger } from "./utils/logger"; export class TenderlyNetwork { public host: string; @@ -176,7 +176,7 @@ export class TenderlyNetwork { const username: string = this.env.config.tenderly.username; const projectID: string = this.env.config.tenderly.project; - logger.trace("Username and projectID obtained from tenderly configuration:", {username, projectID}); + logger.trace("Username and projectID obtained from tenderly configuration:", { username, projectID }); try { logger.debug("Making a call to initialize fork..."); From 9eab7f4b143eea89df6d1605d047f7105a3018a6 Mon Sep 17 00:00:00 2001 From: dule-git Date: Fri, 25 Nov 2022 15:00:28 +0100 Subject: [PATCH 19/68] Added logs to Tenderly.ts in hardhat-tenderly --- packages/tenderly-core/package.json | 3 ++- packages/tenderly-core/src/utils/logger.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 packages/tenderly-core/src/utils/logger.ts diff --git a/packages/tenderly-core/package.json b/packages/tenderly-core/package.json index 79017501..a321e96e 100644 --- a/packages/tenderly-core/package.json +++ b/packages/tenderly-core/package.json @@ -55,7 +55,8 @@ "hyperlinker": "^1.0.0", "js-yaml": "^4.1.0", "open": "^8.4.0", - "prompts": "^2.4.2" + "prompts": "^2.4.2", + "tslog": "^4.4.0" }, "peerDependencies": { "ts-node": "*", diff --git a/packages/tenderly-core/src/utils/logger.ts b/packages/tenderly-core/src/utils/logger.ts new file mode 100644 index 00000000..68b13471 --- /dev/null +++ b/packages/tenderly-core/src/utils/logger.ts @@ -0,0 +1,6 @@ +import { Logger } from "tslog"; + +export const logger = new Logger({ + prettyLogTemplate: "{{dateIsoStr}} {{logLevelName}} {{name}} =>", + name: "TenderlyService", +}); From be7a732cf25d4ede0356e4d64bdff1359f59a7ab Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 10:17:47 +0100 Subject: [PATCH 20/68] Introduced a logger into TenderlyService. Changed some log levels to silly because they take up too much space. --- .../tenderly-core/src/internal/core/common/logger.ts | 5 +++-- .../src/internal/core/services/TenderlyService.ts | 12 +++++++++++- packages/tenderly-hardhat/src/Tenderly.ts | 2 +- packages/tenderly-hardhat/src/TenderlyNetwork.ts | 2 +- packages/tenderly-hardhat/src/tenderly/extender.ts | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts index ecae80a4..57b25182 100644 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ b/packages/tenderly-core/src/internal/core/common/logger.ts @@ -1,4 +1,5 @@ const API_ERR_MSG = "Unexpected error occurred. \n Error reason %s %s. \n Error context: %s"; +import { logger } from "../../../utils/logger"; export function logApiError(err: any) { // api error @@ -12,12 +13,12 @@ export function logApiError(err: any) { message = err.response.data; } - console.log(API_ERR_MSG, code, codeText, message); + logger.error(API_ERR_MSG, code, codeText, message); return; } // general error if (err instanceof Error) { - console.log(err.message); + logger.error(err.message); } } diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 743a0a98..9a5035f8 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -19,23 +19,33 @@ import { TenderlyContractUploadRequest, TenderlyForkContractUploadRequest, } from "../types"; +import { logger } from "../../../utils/logger"; import { TenderlyApiService } from "./TenderlyApiService"; export class TenderlyService { private pluginName: string; - constructor(pluginName: string) { + constructor(pluginName: string, minLogLevel: number = 4) { + logger.settings.minLevel = minLogLevel; + logger.info("Made tenderly service with plugin name:", pluginName); this.pluginName = pluginName; } public async getNetworks(): Promise { + logger.debug("Getting networks has been called."); + let tenderlyApi = TenderlyApiService.configureAnonymousInstance(); if (TenderlyApiService.isAuthenticated()) { + logger.debug("API service has been authenticated. Configuring instance..."); tenderlyApi = TenderlyApiService.configureInstance(); + logger.debug("Instance has been configured."); } try { + logger.debug("Making a call to get all of the public networks..."); const res = await tenderlyApi.get("/api/v1/public-networks"); + logger.silly("Obtained public networks:", res.data); + return res.data; } catch (err) { logApiError(err); diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index b1f69898..16466872 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -17,7 +17,7 @@ export class Tenderly { public env: HardhatRuntimeEnvironment; public tenderlyNetwork: TenderlyNetwork; - private tenderlyService = new TenderlyService(PLUGIN_NAME); + private tenderlyService = new TenderlyService(PLUGIN_NAME, Number(process.env.MIN_LOG_LEVEL)); constructor(hre: HardhatRuntimeEnvironment) { logger.debug("Making hardhat Tenderly interface..."); diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index a1cc287a..82feba62 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -22,7 +22,7 @@ export class TenderlyNetwork { public accounts: Record | undefined; public env: HardhatRuntimeEnvironment; - private tenderlyService = new TenderlyService(PLUGIN_NAME); + private tenderlyService = new TenderlyService(PLUGIN_NAME, Number(process.env.MIN_LOG_LEVEL)); constructor(hre: HardhatRuntimeEnvironment) { logger.debug("Making an interface towards tenderly network..."); diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index b3d8875a..83da4476 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -106,7 +106,7 @@ const populateNetworks = (): void => { NETWORK_NAME_CHAIN_ID_MAP[slug] = network.ethereum_network_id; } } - logger.info("Obtained supported public networks: ", NETWORK_NAME_CHAIN_ID_MAP); + logger.silly("Obtained supported public networks: ", NETWORK_NAME_CHAIN_ID_MAP); }) .catch((_) => { logger.error("Error encountered while fetching public networks"); From de88f0a31cc246e7b7977e5b80bf712d4e3eac3b Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 11:18:17 +0100 Subject: [PATCH 21/68] Introduced configuration for Hardhat and Service logger. Now the user can configure the these two loggers independently. --- packages/tenderly-core/src/utils/logger.ts | 2 +- packages/tenderly-hardhat/src/Tenderly.ts | 2 +- packages/tenderly-hardhat/src/TenderlyNetwork.ts | 2 +- packages/tenderly-hardhat/src/index.ts | 13 +++++++++++-- packages/tenderly-hardhat/src/tenderly/extender.ts | 13 +++++++++++-- packages/tenderly-hardhat/src/utils/logger.ts | 2 +- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/packages/tenderly-core/src/utils/logger.ts b/packages/tenderly-core/src/utils/logger.ts index 68b13471..a31459d5 100644 --- a/packages/tenderly-core/src/utils/logger.ts +++ b/packages/tenderly-core/src/utils/logger.ts @@ -2,5 +2,5 @@ import { Logger } from "tslog"; export const logger = new Logger({ prettyLogTemplate: "{{dateIsoStr}} {{logLevelName}} {{name}} =>", - name: "TenderlyService", + name: "Service", }); diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index 16466872..b1f69898 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -17,7 +17,7 @@ export class Tenderly { public env: HardhatRuntimeEnvironment; public tenderlyNetwork: TenderlyNetwork; - private tenderlyService = new TenderlyService(PLUGIN_NAME, Number(process.env.MIN_LOG_LEVEL)); + private tenderlyService = new TenderlyService(PLUGIN_NAME); constructor(hre: HardhatRuntimeEnvironment) { logger.debug("Making hardhat Tenderly interface..."); diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index 82feba62..a1cc287a 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -22,7 +22,7 @@ export class TenderlyNetwork { public accounts: Record | undefined; public env: HardhatRuntimeEnvironment; - private tenderlyService = new TenderlyService(PLUGIN_NAME, Number(process.env.MIN_LOG_LEVEL)); + private tenderlyService = new TenderlyService(PLUGIN_NAME); constructor(hre: HardhatRuntimeEnvironment) { logger.debug("Making an interface towards tenderly network..."); diff --git a/packages/tenderly-hardhat/src/index.ts b/packages/tenderly-hardhat/src/index.ts index d3dda720..329f19eb 100644 --- a/packages/tenderly-hardhat/src/index.ts +++ b/packages/tenderly-hardhat/src/index.ts @@ -5,10 +5,19 @@ import "./tasks"; import * as tenderlyExtender from "./tenderly/extender"; export function setup( - cfg: { automaticVerifications: boolean; minLogLevel?: number } = { automaticVerifications: false, minLogLevel: 7 } + cfg: { + automaticVerifications: boolean; + minLogLevelHardhat?: number; + minLogLevelService?: number; + } = { + automaticVerifications: false, + minLogLevelHardhat: 7, + minLogLevelService: 7, + } ): void { process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications === true ? "true" : "false"; - process.env.MIN_LOG_LEVEL = cfg.minLogLevel !== undefined ? cfg.minLogLevel.toString() : "7"; + process.env.MIN_LOG_LEVEL_HARDHAT = cfg.minLogLevelHardhat !== undefined ? cfg.minLogLevelHardhat.toString() : "7"; + process.env.MIN_LOG_LEVEL_SERVICE = cfg.minLogLevelService !== undefined ? cfg.minLogLevelService.toString() : "7"; tenderlyExtender.setup(); } diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 83da4476..1888772e 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -4,6 +4,7 @@ import { extendConfig, extendEnvironment } from "hardhat/config"; import { HardhatRuntimeEnvironment, HttpNetworkConfig, HardhatConfig } from "hardhat/types"; import { HardhatEthersHelpers } from "@nomiclabs/hardhat-ethers/types"; import { TenderlyService } from "tenderly"; +import { logger as serviceLogger } from "tenderly/utils/logger"; import { TenderlyNetwork as TenderlyNetworkInterface } from "tenderly/types"; import { CHAIN_ID_NETWORK_NAME_MAP, @@ -21,8 +22,16 @@ import { wrapHHDeployments } from "./hardhat-deploy"; const tenderlyService = new TenderlyService(PLUGIN_NAME); export function setup() { - logger.settings.minLevel = Number(process.env.MIN_LOG_LEVEL); - logger.debug(`Setting up hardhat-tenderly plugin... Log level set to: ${logger.settings.minLevel}`); + logger.settings.minLevel = Number(process.env.MIN_LOG_LEVEL_HARDHAT); + logger.debug( + `Setting up hardhat-tenderly plugin... Log level of hardhat tenderly plugin set to: ${logger.settings.minLevel}` + ); + + // serviceLogger is used here just for initialization, nothing else, it will be used in TenderlyService.ts + serviceLogger.settings.minLevel = Number(process.env.MIN_LOG_LEVEL_SERVICE); + serviceLogger.debug( + `Setting up hardhat-tenderly plugin... Log level of tenderly service set to: ${serviceLogger.settings.minLevel}` + ); extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); diff --git a/packages/tenderly-hardhat/src/utils/logger.ts b/packages/tenderly-hardhat/src/utils/logger.ts index fa62841f..59638f45 100644 --- a/packages/tenderly-hardhat/src/utils/logger.ts +++ b/packages/tenderly-hardhat/src/utils/logger.ts @@ -2,5 +2,5 @@ import { Logger } from "tslog"; export const logger = new Logger({ prettyLogTemplate: "{{dateIsoStr}} {{logLevelName}} {{name}} =>", - name: "HardhatLogger", + name: "Hardhat", }); From 75c9b09c3d104b346389a3b712bee07897fcb26e Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 11:57:25 +0100 Subject: [PATCH 22/68] Added logs to TenderlyService.ts and changed default log levels to display warnings and errors in both loggers. --- .../internal/core/services/TenderlyService.ts | 64 +++++++++++++------ packages/tenderly-hardhat/src/index.ts | 19 ++++-- 2 files changed, 61 insertions(+), 22 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 9a5035f8..49902322 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -25,7 +25,7 @@ import { TenderlyApiService } from "./TenderlyApiService"; export class TenderlyService { private pluginName: string; - constructor(pluginName: string, minLogLevel: number = 4) { + constructor(pluginName: string, minLogLevel: number = 7) { logger.settings.minLevel = minLogLevel; logger.info("Made tenderly service with plugin name:", pluginName); this.pluginName = pluginName; @@ -55,22 +55,29 @@ export class TenderlyService { } public async getLatestBlockNumber(networkId: string): Promise { + logger.debug("Getting latest block number..."); + let tenderlyApi = TenderlyApiService.configureAnonymousInstance(); if (TenderlyApiService.isAuthenticated()) { tenderlyApi = TenderlyApiService.configureInstance(); } try { + logger.trace("Making a call to the api..."); const res = await tenderlyApi.get(`/api/v1/network/${networkId}/block-number`); + logger.trace(`Api successfully returned: ${res.data.block_number}`); + return res.data.block_number; } catch (err) { logApiError(err); - console.log(`Error in ${this.pluginName}: ${LATEST_BLOCK_NUMBER_FETCH_FAILED_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${LATEST_BLOCK_NUMBER_FETCH_FAILED_ERR_MSG}`); } return null; } public async verifyContracts(request: TenderlyContractUploadRequest): Promise { + logger.info("Verifying contracts has been called."); + let tenderlyApi = TenderlyApiService.configureAnonymousInstance(); if (TenderlyApiService.isAuthenticated()) { tenderlyApi = TenderlyApiService.configureInstance(); @@ -78,15 +85,18 @@ export class TenderlyService { try { if (request.contracts.length === 0) { - console.log(NO_VERIFIABLE_CONTRACTS_ERR_MSG); + logger.error(NO_VERIFIABLE_CONTRACTS_ERR_MSG); return; } + logger.debug("Making a call to the api..."); const res = await tenderlyApi.post("/api/v1/public/verify-contracts", { ...request }); + logger.debug("API call successfully made."); + logger.trace("Retrieved data:", res.data); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { - console.log(`Error in ${this.pluginName}: ${BYTECODE_MISMATCH_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${BYTECODE_MISMATCH_ERR_MSG}`); return; } @@ -96,7 +106,7 @@ export class TenderlyService { addresses += `${cont.contractName}, `; } - console.log(`Error in ${this.pluginName}: ${NO_NEW_CONTRACTS_VERIFIED_ERR_MSG}`, addresses); + logger.error(`Error in ${this.pluginName}: ${NO_NEW_CONTRACTS_VERIFIED_ERR_MSG}`, addresses); return; } @@ -112,7 +122,7 @@ export class TenderlyService { console.groupEnd(); } catch (err) { logApiError(err); - console.log(`Error in ${this.pluginName}: ${API_VERIFICATION_REQUEST_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${API_VERIFICATION_REQUEST_ERR_MSG}`); } } @@ -122,19 +132,22 @@ export class TenderlyService { username: string ): Promise { if (!TenderlyApiService.isAuthenticated()) { - console.log(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); return; } const tenderlyApi = TenderlyApiService.configureInstance(); try { + logger.debug("Making a call to the api..."); const res = await tenderlyApi.post(`/api/v1/account/${username}/project/${tenderlyProject}/contracts`, { ...request, }); + logger.debug("Call to the api successfully made."); + logger.trace("Retrieved data:", res.data); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { - console.log(`Error in ${this.pluginName}: ${BYTECODE_MISMATCH_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${BYTECODE_MISMATCH_ERR_MSG}`); return; } @@ -144,7 +157,7 @@ export class TenderlyService { addresses += `${cont.contractName}, `; } - console.log(`Error in ${this.pluginName}: ${NO_NEW_CONTRACTS_VERIFIED_ERR_MSG}`, addresses); + logger.error(`Error in ${this.pluginName}: ${NO_NEW_CONTRACTS_VERIFIED_ERR_MSG}`, addresses); return; } @@ -154,7 +167,7 @@ export class TenderlyService { ); } catch (err) { logApiError(err); - console.log(`Error in ${this.pluginName}: ${API_VERIFICATION_REQUEST_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${API_VERIFICATION_REQUEST_ERR_MSG}`); } } @@ -164,20 +177,25 @@ export class TenderlyService { username: string, fork: string ): Promise { + logger.info("Fork verification has been called."); + if (!TenderlyApiService.isAuthenticated()) { - console.log(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); return; } const tenderlyApi = TenderlyApiService.configureTenderlyRPCInstance(); try { + logger.debug("Making a call to the api..."); const res = await tenderlyApi.post(`/account/${username}/project/${tenderlyProject}/fork/${fork}/verify`, { ...request, }); + logger.debug("Call to the api successfully made."); + logger.trace("Retrieved data:", res.data); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { - console.log(BYTECODE_MISMATCH_ERR_MSG); + logger.error(BYTECODE_MISMATCH_ERR_MSG); return; } @@ -187,7 +205,7 @@ export class TenderlyService { addresses += `${cont.contractName}, `; } - console.log(`Error in ${this.pluginName}: ${NO_NEW_CONTRACTS_VERIFIED_ERR_MSG}`, addresses); + logger.error(`Error in ${this.pluginName}: ${NO_NEW_CONTRACTS_VERIFIED_ERR_MSG}`, addresses); return; } @@ -198,43 +216,53 @@ export class TenderlyService { console.groupEnd(); } catch (err) { logApiError(err); - console.log(`Error in ${this.pluginName}: ${API_VERIFICATION_REQUEST_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${API_VERIFICATION_REQUEST_ERR_MSG}`); } } public async getPrincipal(): Promise { + logger.debug("Getting principal has been called."); + if (!TenderlyApiService.isAuthenticated()) { - console.log(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); return null; } const tenderlyApi = TenderlyApiService.configureInstance(); try { + logger.debug("Making a call to the api..."); const res = await tenderlyApi.get("/api/v1/user"); + logger.trace("Retrieved data:", { id: res.data.user.id, username: res.data.user.username }); + return { id: res.data.user.id, username: res.data.user.username, }; } catch (err) { logApiError(err); - console.log(`Error in ${this.pluginName}: ${PRINCIPAL_FETCH_FAILED_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${PRINCIPAL_FETCH_FAILED_ERR_MSG}`); } return null; } public async getProjectSlugs(principalId: string): Promise { + logger.debug("Getting project slugs has been called."); + if (!TenderlyApiService.isAuthenticated()) { - console.log(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); return []; } const tenderlyApi = TenderlyApiService.configureInstance(); try { + logger.debug("Making a call to the api..."); const res = await tenderlyApi.get(`/api/v1/account/${principalId}/projects`); + logger.trace("Retrieved data:", res.data.projects); + return res.data.projects; } catch (err) { logApiError(err); - console.log(`Error in ${this.pluginName}: ${PROJECTS_FETCH_FAILED_ERR_MSG}`); + logger.error(`Error in ${this.pluginName}: ${PROJECTS_FETCH_FAILED_ERR_MSG}`); } return []; } diff --git a/packages/tenderly-hardhat/src/index.ts b/packages/tenderly-hardhat/src/index.ts index 329f19eb..9a2cfa04 100644 --- a/packages/tenderly-hardhat/src/index.ts +++ b/packages/tenderly-hardhat/src/index.ts @@ -11,13 +11,24 @@ export function setup( minLogLevelService?: number; } = { automaticVerifications: false, - minLogLevelHardhat: 7, - minLogLevelService: 7, + minLogLevelHardhat: 4, + minLogLevelService: 4, } ): void { process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications === true ? "true" : "false"; - process.env.MIN_LOG_LEVEL_HARDHAT = cfg.minLogLevelHardhat !== undefined ? cfg.minLogLevelHardhat.toString() : "7"; - process.env.MIN_LOG_LEVEL_SERVICE = cfg.minLogLevelService !== undefined ? cfg.minLogLevelService.toString() : "7"; + + /* + * Log levels in tslog + * 0 - silly + * 1 - trace + * 2 - debug + * 3 - info + * 4 - warning + * 5 - error + * 6 - fatal + */ + process.env.MIN_LOG_LEVEL_HARDHAT = cfg.minLogLevelHardhat !== undefined ? cfg.minLogLevelHardhat.toString() : "4"; + process.env.MIN_LOG_LEVEL_SERVICE = cfg.minLogLevelService !== undefined ? cfg.minLogLevelService.toString() : "4"; tenderlyExtender.setup(); } From 0a986cca0cb580c742ab11db80a334e40aefacc7 Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 12:23:56 +0100 Subject: [PATCH 23/68] Added logs to TenderlyApiService.ts --- .../core/services/TenderlyApiService.ts | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts index 667b981b..c3e7e9d0 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts @@ -1,35 +1,52 @@ import * as axios from "axios"; +import { logger } from "../../../utils/logger"; import { getConfig, isAccessTokenSet } from "../../../utils/config"; import { TENDERLY_API_BASE_URL, TENDERLY_JSON_RPC_BASE_URL } from "../../../common/constants"; export class TenderlyApiService { public static configureInstance(): axios.AxiosInstance { + logger.debug("Configuring instance..."); + const tdlyConfig = getConfig(); - return axios.default.create({ + const params = { baseURL: TENDERLY_API_BASE_URL, - headers: { "x-access-key": tdlyConfig.access_key }, - }); + accessKey: tdlyConfig.access_key, + }; + logger.debug("Configured instance with parameters:", params); + + return axios.default.create(params); } public static configureAnonymousInstance(): axios.AxiosInstance { + logger.debug("Configured anonymous instance with base url:", TENDERLY_API_BASE_URL); + return axios.default.create({ baseURL: TENDERLY_API_BASE_URL, }); } public static configureTenderlyRPCInstance(): axios.AxiosInstance { + logger.debug("Configuring tenderly RPC instance..."); + const tdlyConfig = getConfig(); - return axios.default.create({ + const params = { baseURL: TENDERLY_JSON_RPC_BASE_URL, headers: { "x-access-key": tdlyConfig.access_key, Head: tdlyConfig.head !== undefined ? tdlyConfig.head : "", }, - }); + }; + logger.debug("Configured tenderly rpc instance with parameters:", params); + + return axios.default.create(params); } public static isAuthenticated(): boolean { - return isAccessTokenSet(); + logger.debug("Getting if user is authenticated..."); + const isAuth = isAccessTokenSet(); + logger.debug("isAuthenticated returned:", isAuth); + + return isAuth; } } From 321d7276a408f3566549846e01504b01a171d86b Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 12:35:14 +0100 Subject: [PATCH 24/68] Added logs to config.ts --- packages/tenderly-core/src/utils/config.ts | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/tenderly-core/src/utils/config.ts b/packages/tenderly-core/src/utils/config.ts index 5ae171ed..3c69124f 100644 --- a/packages/tenderly-core/src/utils/config.ts +++ b/packages/tenderly-core/src/utils/config.ts @@ -2,17 +2,25 @@ import fs from "fs"; import os from "os"; import path from "path"; import * as yaml from "js-yaml"; - import { TenderlyConfig } from "../types"; +import { logger } from "./logger"; const configDir = `${os.homedir() + path.sep}.tenderly`; export const configFilePath = `${configDir + path.sep}config.yaml`; export function getConfig(): TenderlyConfig { + logger.trace("Getting tenderly config..."); + if (configExists()) { const fileData = fs.readFileSync(configFilePath); - return yaml.load(fileData.toString()) as TenderlyConfig; + + const tenderlyConfig = yaml.load(fileData.toString()) as TenderlyConfig; + logger.trace("Tenderly config exists. Value of the config:", tenderlyConfig); + + return tenderlyConfig; } + + logger.trace("Tenderly config doesn't exist, empty string values have been returned."); return { access_key: "", access_key_id: "", @@ -24,27 +32,43 @@ export function getConfig(): TenderlyConfig { } export function writeConfig(config: TenderlyConfig): void { + logger.trace(`Writing config to a file @ ${configDir}/${configFilePath}`); + logger.trace("Value of the config:", config); + fs.mkdirSync(configDir, { recursive: true }); fs.writeFileSync(configFilePath, yaml.dump(config), "utf8"); } export function configExists(): boolean { + logger.trace("Checking if config exists..."); return fs.existsSync(configFilePath); } export function isAccessTokenSet(): boolean { + logger.trace("Determining if access token in tenderly config file is set..."); const config = getConfig(); - return config.access_key !== undefined || config.access_key !== ""; + + const isSet = config.access_key !== undefined || config.access_key !== ""; + logger.trace("Access key is set:", isSet); + + return isSet; } export function getAccessToken(): string { + logger.trace("Getting access token..."); if (!isAccessTokenSet()) { + logger.trace("Access key is not set, returning empty string value."); return ""; } - return getConfig().access_key; + + const accessKey = getConfig().access_key; + logger.trace("Access key:", accessKey); + + return accessKey; } export function setAccessToken(accessToken: string): void { + logger.trace("Setting access key to value:", accessToken, " ...."); const config = getConfig(); config.access_key = accessToken; writeConfig(config); From f50b6044adbc8f8fc79063cee6d38d64ef19dbce Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 12:58:26 +0100 Subject: [PATCH 25/68] Added logs to LoginCommand.ts --- .../src/internal/cli/commands/LoginCommand.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 04bae70e..8d454e52 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -2,32 +2,41 @@ import open from "open"; import axios from "axios"; import prompts from "prompts"; import commander from "commander"; +import { logger } from "../../../utils/logger"; import { isAccessTokenSet, setAccessToken } from "../../../utils/config"; import { TENDERLY_API_BASE_URL, TENDERLY_DASHBOARD_BASE_URL } from "../../../common/constants"; export const LoginCommand = new commander.Command("login").description("login to Tenderly").action(async () => { + logger.info("Making LoginCommand..."); + if (isAccessTokenSet()) { + logger.debug("Access token is set. Prompting user to overwrite access token with a new one."); const response = await prompts({ type: "confirm", name: "overwrite", message: "Access token already set. Would you like to overwrite it?", }); if (!response.overwrite) { + logger.debug("User didn't request an overwrite of the token. Login command is made with existing token."); return; } } + logger.info("Access token isn't set. Prompting user to enter access token..."); const accessToken = await promptAccessToken(); + logger.debug("User entered access token. Setting access token..."); setAccessToken(accessToken); - console.log("Successfully logged in."); + + logger.info("Successfully logged in."); }); async function promptAccessToken(): Promise { - console.log(`Redirecting to ${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`); + logger.debug(`Redirecting to ${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`); await open(`${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`); + logger.info("Prompting user to enter access token"); const response = await prompts({ type: "text", name: "accessToken", @@ -35,6 +44,7 @@ async function promptAccessToken(): Promise { validate: validator, }); + logger.info("User entered access token:", response.accessToken); return response.accessToken; } @@ -53,14 +63,20 @@ const validator = async function (value: string) { async function canAuthenticate(accessToken: string): Promise { try { + logger.debug("Determining if the user can be authenticated with provided access token:", accessToken); + + logger.trace("Making a call to the url..."); const response = await axios.get(`${TENDERLY_API_BASE_URL}/api/v1/user`, { headers: { "x-access-key": accessToken }, }); if (response.data.user !== undefined) { + logger.debug("The user can be authenticated."); return true; } + logger.error("The user cannot be authenticated with access token:", accessToken); return false; } catch (err) { + logger.error(`There was an error while making the api call ${TENDERLY_API_BASE_URL}/api/v1/user`); return false; } } From 8abff3a9dbfca75286557c51634e81cf0776f2c9 Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 13:13:10 +0100 Subject: [PATCH 26/68] Removed log level parameter from TenderlyService since logging on tenderly-core isn't tied to TenderlyService. --- .../internal/core/services/TenderlyService.ts | 3 +- yarn.lock | 111 +++++++++++++++--- 2 files changed, 98 insertions(+), 16 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 49902322..79f52a4d 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -25,8 +25,7 @@ import { TenderlyApiService } from "./TenderlyApiService"; export class TenderlyService { private pluginName: string; - constructor(pluginName: string, minLogLevel: number = 7) { - logger.settings.minLevel = minLogLevel; + constructor(pluginName: string) { logger.info("Made tenderly service with plugin name:", pluginName); this.pluginName = pluginName; } diff --git a/yarn.lock b/yarn.lock index 266e8edc..04ebf328 100644 --- a/yarn.lock +++ b/yarn.lock @@ -258,10 +258,10 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@eslint/eslintrc@^1.3.1": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.1.tgz#de0807bfeffc37b964a7d0400e0c348ce5a2543d" - integrity sha512-OhSY22oQQdw3zgPOOwdoj01l/Dzl1Z+xyUP33tkSN+aqyEhymJCcPHyXt+ylW8FSe0TfRC2VG+ROQOapD0aZSQ== +"@eslint/eslintrc@^1.3.0", "@eslint/eslintrc@^1.3.3": + version "1.3.3" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.3.tgz#2b044ab39fdfa75b4688184f9e573ce3c5b0ff95" + integrity sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg== dependencies: ajv "^6.12.4" debug "^4.3.2" @@ -624,6 +624,15 @@ debug "^4.1.1" minimatch "^3.0.4" +"@humanwhocodes/config-array@^0.11.6": + version "0.11.7" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.7.tgz#38aec044c6c828f6ed51d5d7ae3d9b9faf6dbb0f" + integrity sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw== + dependencies: + "@humanwhocodes/object-schema" "^1.2.1" + debug "^4.1.1" + minimatch "^3.0.5" + "@humanwhocodes/gitignore-to-minimatch@^1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz#316b0a63b91c10e53f242efb4ace5c3b34e8728d" @@ -722,7 +731,7 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== -"@nodelib/fs.walk@^1.2.3": +"@nodelib/fs.walk@^1.2.3", "@nodelib/fs.walk@^1.2.8": version "1.2.8" resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== @@ -2376,15 +2385,14 @@ eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@^8.23.0: - version "8.23.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.23.0.tgz#a184918d288820179c6041bb3ddcc99ce6eea040" - integrity sha512-pBG/XOn0MsJcKcTRLr27S5HpzQo4kLr+HjLQIyK4EiCsijDl/TB+h5uEuJU6bQ8Edvwz1XWOjpaP2qgnXGpTcA== +eslint@8.22.0: + version "8.22.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.22.0.tgz#78fcb044196dfa7eef30a9d65944f6f980402c48" + integrity sha512-ci4t0sz6vSRKdmkOGmprBo6fmI4PrphDFMy5JEq/fNS0gQkJM3rLmrqcp8ipMcdobH3KtUP40KniAE9W19S4wA== dependencies: - "@eslint/eslintrc" "^1.3.1" + "@eslint/eslintrc" "^1.3.0" "@humanwhocodes/config-array" "^0.10.4" "@humanwhocodes/gitignore-to-minimatch" "^1.0.2" - "@humanwhocodes/module-importer" "^1.0.1" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" @@ -2394,7 +2402,7 @@ eslint@^8.23.0: eslint-scope "^7.1.1" eslint-utils "^3.0.0" eslint-visitor-keys "^3.3.0" - espree "^9.4.0" + espree "^9.3.3" esquery "^1.4.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" @@ -2420,6 +2428,61 @@ eslint@^8.23.0: strip-ansi "^6.0.1" strip-json-comments "^3.1.0" text-table "^0.2.0" + v8-compile-cache "^2.0.3" + +eslint@^8.22.0: + version "8.28.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.28.0.tgz#81a680732634677cc890134bcdd9fdfea8e63d6e" + integrity sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ== + dependencies: + "@eslint/eslintrc" "^1.3.3" + "@humanwhocodes/config-array" "^0.11.6" + "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" + ajv "^6.10.0" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" + doctrine "^3.0.0" + escape-string-regexp "^4.0.0" + eslint-scope "^7.1.1" + eslint-utils "^3.0.0" + eslint-visitor-keys "^3.3.0" + espree "^9.4.0" + esquery "^1.4.0" + esutils "^2.0.2" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + find-up "^5.0.0" + glob-parent "^6.0.2" + globals "^13.15.0" + grapheme-splitter "^1.0.4" + ignore "^5.2.0" + import-fresh "^3.0.0" + imurmurhash "^0.1.4" + is-glob "^4.0.0" + is-path-inside "^3.0.3" + js-sdsl "^4.1.4" + js-yaml "^4.1.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.1.2" + natural-compare "^1.4.0" + optionator "^0.9.1" + regexpp "^3.2.0" + strip-ansi "^6.0.1" + strip-json-comments "^3.1.0" + text-table "^0.2.0" + +espree@^9.3.3: + version "9.4.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.1.tgz#51d6092615567a2c2cff7833445e37c28c0065bd" + integrity sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg== + dependencies: + acorn "^8.8.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.3.0" espree@^9.4.0: version "9.4.0" @@ -2913,7 +2976,7 @@ glob-parent@^5.1.2, glob-parent@~5.1.2: dependencies: is-glob "^4.0.1" -glob-parent@^6.0.1: +glob-parent@^6.0.1, glob-parent@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== @@ -3345,6 +3408,11 @@ is-number@^7.0.0: resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== +is-path-inside@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" + integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== + is-plain-obj@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" @@ -3434,6 +3502,11 @@ jest-changed-files@^24.9.0: execa "^1.0.0" throat "^4.0.0" +js-sdsl@^4.1.4: + version "4.2.0" + resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.2.0.tgz#278e98b7bea589b8baaf048c20aeb19eb7ad09d0" + integrity sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ== + js-sha3@0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" @@ -3791,7 +3864,7 @@ minimatch@5.0.1: dependencies: brace-expansion "^2.0.1" -minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: +minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== @@ -4918,6 +4991,11 @@ tslib@^1.8.1, tslib@^1.9.3: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== +tslog@^4.3.1, tslog@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/tslog/-/tslog-4.4.0.tgz#ac3f47959cdb7c12e9daad085e6d3517d26f93b9" + integrity sha512-7HrI6Yb3oeg3uZA7nWI2Z2z3W8kb7hTYoljpWOuPxc44Q7Qn1Ski/j6t/CDjJdn9rqFc/Aali+gMpG+S+StPuw== + tsort@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/tsort/-/tsort-0.0.1.tgz#e2280f5e817f8bf4275657fd0f9aebd44f5a2786" @@ -5060,6 +5138,11 @@ v8-compile-cache-lib@^3.0.1: resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== +v8-compile-cache@^2.0.3: + version "2.3.0" + resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" + integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== + validate-npm-package-license@^3.0.1: version "3.0.4" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" From b23a9fe0e5fc5dfee9b6a3931f188db8bd6990ab Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 13:29:03 +0100 Subject: [PATCH 27/68] Added logs to NetworksCommand.ts --- .../src/internal/cli/commands/NetworksCommand.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts index b1c68f00..17360716 100644 --- a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts @@ -1,5 +1,6 @@ import Table from "cli-table3"; import commander from "commander"; +import { logger } from "../../../utils/logger"; import { PLUGIN_NAME } from "../../../common/constants"; import { TenderlyService } from "../../core/services"; @@ -12,6 +13,7 @@ export const NetworksCommand = new commander.Command("networks") .option("-v, --verbose", "display detailed network information") .action(async (options) => { const verbose = options.verbose !== undefined && options.verbose === true; + logger.info("Making NetworksCommand... --verbose parameter is:", verbose); const headers = ["Network ID", "Network name"]; if (verbose) { @@ -22,6 +24,8 @@ export const NetworksCommand = new commander.Command("networks") const filteredNetworks = networks.filter(isNotExcluded); filteredNetworks.sort((a, b) => a.sort_order - b.sort_order); + logger.silly("Filtered networks:", filteredNetworks); + const table = new Table({ style: { head: ["magenta"] }, head: headers, @@ -39,6 +43,7 @@ export const NetworksCommand = new commander.Command("networks") }) )) ); + logger.silly("Networks table:", table); console.log(table.toString()); }); From 661c42684a7c8fabe65cbc8cfc83cb841d0d6fd6 Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 13:39:37 +0100 Subject: [PATCH 28/68] Added logs to hardhat tasks. --- packages/tenderly-hardhat/src/tasks/common/index.ts | 8 +++++++- packages/tenderly-hardhat/src/tasks/push.ts | 3 +++ packages/tenderly-hardhat/src/tasks/verify.ts | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/tenderly-hardhat/src/tasks/common/index.ts b/packages/tenderly-hardhat/src/tasks/common/index.ts index 2a826a65..c6e00258 100644 --- a/packages/tenderly-hardhat/src/tasks/common/index.ts +++ b/packages/tenderly-hardhat/src/tasks/common/index.ts @@ -3,6 +3,7 @@ import { RunTaskFunction, HardhatConfig } from "hardhat/types"; import { TenderlyContract } from "tenderly/types"; import { NETWORK_NAME_CHAIN_ID_MAP } from "tenderly/common/constants"; +import { logger } from "../../utils/logger"; import { PLUGIN_NAME } from "../../constants"; import { Metadata } from "../../tenderly/types"; import { CONTRACTS_NOT_DETECTED } from "../../tenderly/errors"; @@ -14,6 +15,8 @@ export async function extractContractData( config: HardhatConfig, run: RunTaskFunction ): Promise { + logger.info("Extracing contract data..."); + let contract: string; const requestContracts: TenderlyContract[] = []; @@ -63,6 +66,7 @@ export async function extractContractData( for (const [key, value] of Object.entries(metadata.sources)) { const name = key.split("/").slice(-1)[0].split(".")[0]; + logger.trace("Currently processing contract:", name); const contractToPush: TenderlyContract = { contractName: name, source: value.content, @@ -82,7 +86,7 @@ export async function extractContractData( chainID = config.networks[network!].chainId!.toString(); } if (chainID === undefined) { - console.log( + logger.error( `Error in ${PLUGIN_NAME}: Couldn't identify network. Please provide a chainID in the network config object` ); return []; @@ -94,6 +98,8 @@ export async function extractContractData( }; } } + logger.silly(`Processed contract ${name}:`, contractToPush); + requestContracts.push(contractToPush); } return requestContracts; diff --git a/packages/tenderly-hardhat/src/tasks/push.ts b/packages/tenderly-hardhat/src/tasks/push.ts index 9888dfaf..e3aae4ad 100644 --- a/packages/tenderly-hardhat/src/tasks/push.ts +++ b/packages/tenderly-hardhat/src/tasks/push.ts @@ -2,6 +2,7 @@ import { HardhatPluginError } from "hardhat/plugins"; import { task } from "hardhat/config"; import { TenderlyService } from "tenderly"; +import { logger } from "../utils/logger"; import { PLUGIN_NAME } from "../constants"; import { newCompilerConfig } from "../utils/util"; import { extractContractData } from "./common"; @@ -16,6 +17,8 @@ task("tenderly:push", "Privately pushes contracts to Tenderly") .setAction(pushContracts); async function pushContracts({ contracts }: any, { config, hardhatArguments, run }: any) { + logger.info("Private verification hardhat task has been invoked."); + if (contracts === undefined) { throw new HardhatPluginError(PLUGIN_NAME, `At least one contract must be provided (ContractName=Address)`); } diff --git a/packages/tenderly-hardhat/src/tasks/verify.ts b/packages/tenderly-hardhat/src/tasks/verify.ts index 6f921b80..38cccc01 100644 --- a/packages/tenderly-hardhat/src/tasks/verify.ts +++ b/packages/tenderly-hardhat/src/tasks/verify.ts @@ -2,6 +2,7 @@ import { task } from "hardhat/config"; import { HardhatPluginError } from "hardhat/plugins"; import { TenderlyService } from "tenderly"; +import { logger } from "../utils/logger"; import { PLUGIN_NAME } from "../constants"; import { newCompilerConfig } from "../utils/util"; import { extractContractData } from "./common"; @@ -16,6 +17,7 @@ task("tenderly:verify", "Verifies contracts on Tenderly") .setAction(verifyContract); async function verifyContract({ contracts }: any, { config, hardhatArguments, run }: any) { + logger.info("Public verification hardhat task has been invoked."); if (contracts === undefined) { throw new HardhatPluginError( PLUGIN_NAME, From 105fa688aad303f5d61d57bc774205b4ab83b7a5 Mon Sep 17 00:00:00 2001 From: dule-git Date: Mon, 28 Nov 2022 14:01:26 +0100 Subject: [PATCH 29/68] Fixed a log typo. --- packages/tenderly-hardhat/src/tasks/common/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-hardhat/src/tasks/common/index.ts b/packages/tenderly-hardhat/src/tasks/common/index.ts index c6e00258..c096a624 100644 --- a/packages/tenderly-hardhat/src/tasks/common/index.ts +++ b/packages/tenderly-hardhat/src/tasks/common/index.ts @@ -15,7 +15,7 @@ export async function extractContractData( config: HardhatConfig, run: RunTaskFunction ): Promise { - logger.info("Extracing contract data..."); + logger.info("Extracting contract data..."); let contract: string; const requestContracts: TenderlyContract[] = []; From d46d674ef78d1c3f79bb41c206e87e48751c7072 Mon Sep 17 00:00:00 2001 From: dule-git Date: Tue, 29 Nov 2022 09:09:02 +0100 Subject: [PATCH 30/68] Changed condition to use concrete logger setting. --- packages/tenderly-hardhat/src/Tenderly.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index b1f69898..f52981ca 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -292,12 +292,7 @@ export class Tenderly { }; } - if ( - process.env.MIN_LOG_LEVEL !== undefined && - process.env.MIN_LOG_LEVEL !== null && - process.env.MIN_LOG_LEVEL !== "" && - Number(process.env.MIN_LOG_LEVEL) <= 2 - ) { + if (logger.settings.minLevel <= 2) { fs.outputFileSync("./filterContractsData.json", JSON.stringify(requestData)); logger.debug("Wrote data to a separate file 'filterContractsData.json' to avoid console clutter."); } From 75e3ad1b13fa7d3c051b6ed254ec227f13aa5bbb Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 1 Dec 2022 12:09:15 +0100 Subject: [PATCH 31/68] Removed log configuration from hardhat.config.js. Now, the loggers are set to verbose if --verbose flag is provided with npx hardhat run command. --- .../internal/core/services/TenderlyService.ts | 1 - packages/tenderly-hardhat/src/Tenderly.ts | 5 +--- packages/tenderly-hardhat/src/index.ts | 26 +------------------ .../tenderly-hardhat/src/tenderly/extender.ts | 23 +++++++++------- 4 files changed, 15 insertions(+), 40 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 79f52a4d..de68a665 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -26,7 +26,6 @@ export class TenderlyService { private pluginName: string; constructor(pluginName: string) { - logger.info("Made tenderly service with plugin name:", pluginName); this.pluginName = pluginName; } diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index f52981ca..b640144f 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -292,10 +292,7 @@ export class Tenderly { }; } - if (logger.settings.minLevel <= 2) { - fs.outputFileSync("./filterContractsData.json", JSON.stringify(requestData)); - logger.debug("Wrote data to a separate file 'filterContractsData.json' to avoid console clutter."); - } + logger.debug("Processed request data from _filterContracts:", requestData); return requestData; } diff --git a/packages/tenderly-hardhat/src/index.ts b/packages/tenderly-hardhat/src/index.ts index 9a2cfa04..284eafa8 100644 --- a/packages/tenderly-hardhat/src/index.ts +++ b/packages/tenderly-hardhat/src/index.ts @@ -4,31 +4,7 @@ import "./tasks"; import * as tenderlyExtender from "./tenderly/extender"; -export function setup( - cfg: { - automaticVerifications: boolean; - minLogLevelHardhat?: number; - minLogLevelService?: number; - } = { - automaticVerifications: false, - minLogLevelHardhat: 4, - minLogLevelService: 4, - } -): void { +export function setup(cfg: { automaticVerifications: boolean } = { automaticVerifications: false }): void { process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications === true ? "true" : "false"; - - /* - * Log levels in tslog - * 0 - silly - * 1 - trace - * 2 - debug - * 3 - info - * 4 - warning - * 5 - error - * 6 - fatal - */ - process.env.MIN_LOG_LEVEL_HARDHAT = cfg.minLogLevelHardhat !== undefined ? cfg.minLogLevelHardhat.toString() : "4"; - process.env.MIN_LOG_LEVEL_SERVICE = cfg.minLogLevelService !== undefined ? cfg.minLogLevelService.toString() : "4"; - tenderlyExtender.setup(); } diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 1888772e..46353962 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -22,20 +22,23 @@ import { wrapHHDeployments } from "./hardhat-deploy"; const tenderlyService = new TenderlyService(PLUGIN_NAME); export function setup() { - logger.settings.minLevel = Number(process.env.MIN_LOG_LEVEL_HARDHAT); - logger.debug( - `Setting up hardhat-tenderly plugin... Log level of hardhat tenderly plugin set to: ${logger.settings.minLevel}` - ); - - // serviceLogger is used here just for initialization, nothing else, it will be used in TenderlyService.ts - serviceLogger.settings.minLevel = Number(process.env.MIN_LOG_LEVEL_SERVICE); - serviceLogger.debug( - `Setting up hardhat-tenderly plugin... Log level of tenderly service set to: ${serviceLogger.settings.minLevel}` - ); + // set to loggers to error level by default + logger.settings.minLevel = 4; + serviceLogger.settings.minLevel = 4; extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); + if (hre.hardhatArguments.verbose) { + logger.settings.minLevel = 1; // trace level + serviceLogger.settings.minLevel = 1; // trace level + } + logger.info( + `Setting up hardhat-tenderly plugin... Log level of hardhat tenderly plugin set to: ${logger.settings.minLevel}` + ); + // serviceLogger is used here just for initialization, nothing else, it will be used in TenderlyService.ts + serviceLogger.info(`Log level of tenderly service set to: ${serviceLogger.settings.minLevel}`); + logger.info("Tenderly running configuration: ", { username: hre.config.tenderly?.username, project: hre.config.tenderly?.project, From 81a4e6dff7a43ea8d3a688064139bc06957bd483 Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 1 Dec 2022 12:39:04 +0100 Subject: [PATCH 32/68] Changed logs to not show PII telemetry. --- .../core/services/TenderlyApiService.ts | 9 ++++++++- packages/tenderly-core/src/utils/config.ts | 18 +++++++++++++++++- .../tenderly-hardhat/src/TenderlyNetwork.ts | 2 -- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts index c3e7e9d0..47874048 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts @@ -13,7 +13,14 @@ export class TenderlyApiService { baseURL: TENDERLY_API_BASE_URL, accessKey: tdlyConfig.access_key, }; - logger.debug("Configured instance with parameters:", params); + + logger.debug("Configured instance with parameters:", { + baseURL: TENDERLY_API_BASE_URL, + accessKey: + tdlyConfig.access_key !== undefined && tdlyConfig.access_key !== null && tdlyConfig.access_key !== "" + ? "super secret access_key is set" + : "undefined or null or empty string", + }); return axios.default.create(params); } diff --git a/packages/tenderly-core/src/utils/config.ts b/packages/tenderly-core/src/utils/config.ts index 3c69124f..f2af7bbb 100644 --- a/packages/tenderly-core/src/utils/config.ts +++ b/packages/tenderly-core/src/utils/config.ts @@ -15,7 +15,23 @@ export function getConfig(): TenderlyConfig { const fileData = fs.readFileSync(configFilePath); const tenderlyConfig = yaml.load(fileData.toString()) as TenderlyConfig; - logger.trace("Tenderly config exists. Value of the config:", tenderlyConfig); + logger.trace("Tenderly config exists. Value of the config:", { + email: tenderlyConfig.email, + account_id: tenderlyConfig.account_id, + username: tenderlyConfig.username, + access_key: + tenderlyConfig.access_key !== undefined && + tenderlyConfig.access_key !== null && + tenderlyConfig.access_key !== "" + ? "super secret access_key is set" + : "undefined or null or empty string", + access_key_id: + tenderlyConfig.access_key_id !== undefined && + tenderlyConfig.access_key_id !== null && + tenderlyConfig.access_key_id !== "" + ? "super secret access_key_id is set" + : "undefined or null or empty string", + }); return tenderlyConfig; } diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index a1cc287a..e9711bb1 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -31,13 +31,11 @@ export class TenderlyNetwork { this.connected = true; const tdlyGlobalConfig = getConfig(); - logger.info("Obtained global tenderly config:", tdlyGlobalConfig); this.accessKey = tdlyGlobalConfig?.access_key; this.tenderlyJsonRpc = this._configureTenderlyRPCInstance(); this.host = this.tenderlyJsonRpc.defaults.baseURL!; - logger.info("Obtained tenderly json rpc:", tdlyGlobalConfig); if (hre.network.name === "tenderly" && "url" in hre.network.config && hre.network.config.url !== undefined) { this.forkID = hre.network.config.url.split("/").pop(); From ac2b7769a7fe98834c098452c07c6aa680104826 Mon Sep 17 00:00:00 2001 From: dule-git Date: Fri, 2 Dec 2022 11:16:42 +0100 Subject: [PATCH 33/68] Added version log at the begging of logging. Added the env var name of access key logging. Added a case when api call returns contracts as null. --- .../src/internal/core/services/TenderlyApiService.ts | 4 ++-- .../src/internal/core/services/TenderlyService.ts | 5 +++++ packages/tenderly-core/src/utils/config.ts | 4 ++-- packages/tenderly-hardhat/src/tenderly/extender.ts | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts index 47874048..72dd5a69 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts @@ -16,9 +16,9 @@ export class TenderlyApiService { logger.debug("Configured instance with parameters:", { baseURL: TENDERLY_API_BASE_URL, - accessKey: + access_key: tdlyConfig.access_key !== undefined && tdlyConfig.access_key !== null && tdlyConfig.access_key !== "" - ? "super secret access_key is set" + ? "super secret access_key is set in 'access_key' field" : "undefined or null or empty string", }); diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index de68a665..4565a93e 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -98,6 +98,11 @@ export class TenderlyService { return; } + if (responseData.contracts === null) { + logger.error("API call returned null value for contracts."); + return; + } + if (responseData.contracts.length === 0) { let addresses = ""; for (const cont of request.contracts) { diff --git a/packages/tenderly-core/src/utils/config.ts b/packages/tenderly-core/src/utils/config.ts index f2af7bbb..4e3a0647 100644 --- a/packages/tenderly-core/src/utils/config.ts +++ b/packages/tenderly-core/src/utils/config.ts @@ -23,13 +23,13 @@ export function getConfig(): TenderlyConfig { tenderlyConfig.access_key !== undefined && tenderlyConfig.access_key !== null && tenderlyConfig.access_key !== "" - ? "super secret access_key is set" + ? "super secret access_key is set in 'access_key' field" : "undefined or null or empty string", access_key_id: tenderlyConfig.access_key_id !== undefined && tenderlyConfig.access_key_id !== null && tenderlyConfig.access_key_id !== "" - ? "super secret access_key_id is set" + ? "super secret access_key_id is set in 'access_key' field" : "undefined or null or empty string", }); diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 46353962..8137d862 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -39,6 +39,9 @@ export function setup() { // serviceLogger is used here just for initialization, nothing else, it will be used in TenderlyService.ts serviceLogger.info(`Log level of tenderly service set to: ${serviceLogger.settings.minLevel}`); + const pjson = require("../../package.json"); + logger.info("@tenderly/hardhat-tenderly version:", pjson.version); + logger.info("Tenderly running configuration: ", { username: hre.config.tenderly?.username, project: hre.config.tenderly?.project, From ea11bf4f1bc2457baed60666c5553f537bc2cd98 Mon Sep 17 00:00:00 2001 From: dule-git Date: Fri, 2 Dec 2022 16:11:41 +0100 Subject: [PATCH 34/68] Explained how to use --verbose flag in README.md --- packages/tenderly-hardhat/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/tenderly-hardhat/README.md b/packages/tenderly-hardhat/README.md index 6d815e9a..7157958d 100644 --- a/packages/tenderly-hardhat/README.md +++ b/packages/tenderly-hardhat/README.md @@ -159,6 +159,11 @@ module.exports = { }; ``` +If you are having trouble with the plugin and want to contact support, you can rum the deploy script with the following ```--verbose``` flag as so: +```bash +npx hardhat run scripts/{your_deploy_script_here.js} --network {network_name} --verbose > tenderly.log 2>&1 +``` +This will create a ```tenderly.log``` file that you can send to our customer support. ## Usage For this plugin to function you need to create a `config.yaml` file at `$HOME/.tenderly/config.yaml` or `%HOMEPATH%\.tenderly\config.yaml` and add an `access_key` field to it: From b31dea7eab0be6a49feba8c9a0b1ab03e41cdd5f Mon Sep 17 00:00:00 2001 From: dule-git Date: Tue, 6 Dec 2022 14:36:28 +0100 Subject: [PATCH 35/68] Changed an error log. --- packages/tenderly-hardhat/src/Tenderly.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index b640144f..f1784cfa 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -269,7 +269,7 @@ export class Tenderly { (requestContract) => requestContract.contractName === contract.name ); if (index === -1) { - logger.error(`Contract '${contract.name}' was not found in processed data.`); + logger.error(`Contract '${contract.name}' was not found among the contracts in /artifacts.`); continue; } let chainID: string = NETWORK_NAME_CHAIN_ID_MAP[network!.toLowerCase()]; From 49084ef814f411c1c45d31fccafbeb76656f7a09 Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 7 Dec 2022 09:55:58 +0100 Subject: [PATCH 36/68] Changed logs based on PR comments. --- .../src/internal/cli/commands/LoginCommand.ts | 14 +++++----- .../internal/cli/commands/NetworksCommand.ts | 1 - .../core/services/TenderlyApiService.ts | 6 ++--- .../internal/core/services/TenderlyService.ts | 2 +- packages/tenderly-core/src/utils/config.ts | 27 ++++++++++++------- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 8d454e52..aa1e82b8 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -8,7 +8,7 @@ import { isAccessTokenSet, setAccessToken } from "../../../utils/config"; import { TENDERLY_API_BASE_URL, TENDERLY_DASHBOARD_BASE_URL } from "../../../common/constants"; export const LoginCommand = new commander.Command("login").description("login to Tenderly").action(async () => { - logger.info("Making LoginCommand..."); + logger.info("Trying to log in to Tenderly..."); if (isAccessTokenSet()) { logger.debug("Access token is set. Prompting user to overwrite access token with a new one."); @@ -18,7 +18,7 @@ export const LoginCommand = new commander.Command("login").description("login to message: "Access token already set. Would you like to overwrite it?", }); if (!response.overwrite) { - logger.debug("User didn't request an overwrite of the token. Login command is made with existing token."); + logger.debug("User didn't request an overwrite of the token. Proceeding logging in with existing token."); return; } } @@ -44,7 +44,7 @@ async function promptAccessToken(): Promise { validate: validator, }); - logger.info("User entered access token:", response.accessToken); + logger.info("User entered access token."); return response.accessToken; } @@ -63,17 +63,15 @@ const validator = async function (value: string) { async function canAuthenticate(accessToken: string): Promise { try { - logger.debug("Determining if the user can be authenticated with provided access token:", accessToken); - - logger.trace("Making a call to the url..."); + logger.debug("Checking if user access token is valid..."); const response = await axios.get(`${TENDERLY_API_BASE_URL}/api/v1/user`, { headers: { "x-access-key": accessToken }, }); if (response.data.user !== undefined) { - logger.debug("The user can be authenticated."); + logger.debug("User has a valid access token."); return true; } - logger.error("The user cannot be authenticated with access token:", accessToken); + logger.error("User doesn't have a valid access token."); return false; } catch (err) { logger.error(`There was an error while making the api call ${TENDERLY_API_BASE_URL}/api/v1/user`); diff --git a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts index 17360716..ba9d3692 100644 --- a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts @@ -13,7 +13,6 @@ export const NetworksCommand = new commander.Command("networks") .option("-v, --verbose", "display detailed network information") .action(async (options) => { const verbose = options.verbose !== undefined && options.verbose === true; - logger.info("Making NetworksCommand... --verbose parameter is:", verbose); const headers = ["Network ID", "Network name"]; if (verbose) { diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts index 72dd5a69..68422b1e 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts @@ -26,7 +26,7 @@ export class TenderlyApiService { } public static configureAnonymousInstance(): axios.AxiosInstance { - logger.debug("Configured anonymous instance with base url:", TENDERLY_API_BASE_URL); + logger.debug("Configured anonymous instance towards tenderly api."); return axios.default.create({ baseURL: TENDERLY_API_BASE_URL, @@ -50,9 +50,9 @@ export class TenderlyApiService { } public static isAuthenticated(): boolean { - logger.debug("Getting if user is authenticated..."); + logger.debug("Checking if user is authenticated..."); const isAuth = isAccessTokenSet(); - logger.debug("isAuthenticated returned:", isAuth); + logger.debug(isAuth ? "User is authenticated." : "User is not authenticated."); return isAuth; } diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 4565a93e..6c485843 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -40,7 +40,7 @@ export class TenderlyService { } try { - logger.debug("Making a call to get all of the public networks..."); + logger.debug("Obtaining public networks..."); const res = await tenderlyApi.get("/api/v1/public-networks"); logger.silly("Obtained public networks:", res.data); diff --git a/packages/tenderly-core/src/utils/config.ts b/packages/tenderly-core/src/utils/config.ts index 4e3a0647..f92f4759 100644 --- a/packages/tenderly-core/src/utils/config.ts +++ b/packages/tenderly-core/src/utils/config.ts @@ -36,7 +36,7 @@ export function getConfig(): TenderlyConfig { return tenderlyConfig; } - logger.trace("Tenderly config doesn't exist, empty string values have been returned."); + logger.trace("Tenderly config doesn't exist, empty string values are returned instead."); return { access_key: "", access_key_id: "", @@ -49,7 +49,19 @@ export function getConfig(): TenderlyConfig { export function writeConfig(config: TenderlyConfig): void { logger.trace(`Writing config to a file @ ${configDir}/${configFilePath}`); - logger.trace("Value of the config:", config); + logger.trace("Value of the config:", { + email: config.email, + account_id: config.account_id, + username: config.username, + access_key: + config.access_key !== undefined && config.access_key !== null && config.access_key !== "" + ? "super secret access_key is set in 'access_key' field" + : "undefined or null or empty string", + access_key_id: + config.access_key_id !== undefined && config.access_key_id !== null && config.access_key_id !== "" + ? "super secret access_key_id is set in 'access_key' field" + : "undefined or null or empty string", + }); fs.mkdirSync(configDir, { recursive: true }); fs.writeFileSync(configFilePath, yaml.dump(config), "utf8"); @@ -64,8 +76,8 @@ export function isAccessTokenSet(): boolean { logger.trace("Determining if access token in tenderly config file is set..."); const config = getConfig(); - const isSet = config.access_key !== undefined || config.access_key !== ""; - logger.trace("Access key is set:", isSet); + const isSet = config.access_key !== undefined && config.access_key !== null && config.access_key !== ""; + logger.trace(isSet ? "Access key is set." : "Access key is not set."); return isSet; } @@ -77,14 +89,11 @@ export function getAccessToken(): string { return ""; } - const accessKey = getConfig().access_key; - logger.trace("Access key:", accessKey); - - return accessKey; + return getConfig().access_key; } export function setAccessToken(accessToken: string): void { - logger.trace("Setting access key to value:", accessToken, " ...."); + logger.trace("Setting access key..."); const config = getConfig(); config.access_key = accessToken; writeConfig(config); From da62762719354cd1b8fe74acb04e2d21139ab07d Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 7 Dec 2022 12:17:25 +0100 Subject: [PATCH 37/68] Changed logs based on PR comments. --- .../src/internal/cli/commands/LoginCommand.ts | 24 +++++----- .../src/internal/core/common/logger.ts | 24 ++++++++++ .../core/services/TenderlyApiService.ts | 9 +++- .../internal/core/services/TenderlyService.ts | 47 ++++++++++++++----- packages/tenderly-core/src/utils/config.ts | 33 ++----------- packages/tenderly-hardhat/src/utils/util.ts | 6 +-- 6 files changed, 84 insertions(+), 59 deletions(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index aa1e82b8..bec453fa 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -8,10 +8,10 @@ import { isAccessTokenSet, setAccessToken } from "../../../utils/config"; import { TENDERLY_API_BASE_URL, TENDERLY_DASHBOARD_BASE_URL } from "../../../common/constants"; export const LoginCommand = new commander.Command("login").description("login to Tenderly").action(async () => { - logger.info("Trying to log in to Tenderly..."); + logger.info("Trying to login to Tenderly..."); if (isAccessTokenSet()) { - logger.debug("Access token is set. Prompting user to overwrite access token with a new one."); + logger.debug("Access token is already set. Checking if user wants to overwrite it with a new one..."); const response = await prompts({ type: "confirm", name: "overwrite", @@ -23,13 +23,13 @@ export const LoginCommand = new commander.Command("login").description("login to } } - logger.info("Access token isn't set. Prompting user to enter access token..."); + logger.info("Access token isn't set. Waiting for user to provide it..."); const accessToken = await promptAccessToken(); - logger.debug("User entered access token. Setting access token..."); + logger.debug("User access token accepted. Trying to log in..."); setAccessToken(accessToken); - logger.info("Successfully logged in."); + logger.info("The user successfully logged in to Tenderly."); }); async function promptAccessToken(): Promise { @@ -44,7 +44,7 @@ async function promptAccessToken(): Promise { validate: validator, }); - logger.info("User entered access token."); + logger.info("User access token accepted."); return response.accessToken; } @@ -67,14 +67,14 @@ async function canAuthenticate(accessToken: string): Promise { const response = await axios.get(`${TENDERLY_API_BASE_URL}/api/v1/user`, { headers: { "x-access-key": accessToken }, }); - if (response.data.user !== undefined) { - logger.debug("User has a valid access token."); - return true; + if (response.data.user === undefined || response.data.user === null) { + logger.error("User doesn't have a valid access token."); + return false; } - logger.error("User doesn't have a valid access token."); - return false; + logger.debug("User has a valid access token."); + return true; } catch (err) { - logger.error(`There was an error while making the api call ${TENDERLY_API_BASE_URL}/api/v1/user`); + logger.error(`There was an error while trying to authenticate user.`); return false; } } diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts index 57b25182..62b26e51 100644 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ b/packages/tenderly-core/src/internal/core/common/logger.ts @@ -1,3 +1,5 @@ +import { TenderlyConfig } from "../../../types"; + const API_ERR_MSG = "Unexpected error occurred. \n Error reason %s %s. \n Error context: %s"; import { logger } from "../../../utils/logger"; @@ -22,3 +24,25 @@ export function logApiError(err: any) { logger.error(err.message); } } + +export function logConfig(config: TenderlyConfig) { + logger.trace("Value of the config:", { + email: + config.email !== undefined && config.email !== null && config.email !== "" + ? "super secret access_key is set in 'access_key' field" + : "undefined or null or empty string", + account_id: config.account_id, + username: + config.username !== undefined && config.username !== null && config.username !== "" + ? "super secret access_key is set in 'access_key' field" + : "undefined or null or empty string", + access_key: + config.access_key !== undefined && config.access_key !== null && config.access_key !== "" + ? "super secret access_key is set in 'access_key' field" + : "undefined or null or empty string", + access_key_id: + config.access_key_id !== undefined && config.access_key_id !== null && config.access_key_id !== "" + ? "super secret access_key_id is set in 'access_key' field" + : "undefined or null or empty string", + }); +} diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts index 68422b1e..2a7bb4a4 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts @@ -44,7 +44,14 @@ export class TenderlyApiService { Head: tdlyConfig.head !== undefined ? tdlyConfig.head : "", }, }; - logger.debug("Configured tenderly rpc instance with parameters:", params); + + logger.debug("Configured tenderly rpc instance with parameters:", { + baseURL: TENDERLY_API_BASE_URL, + access_key: + tdlyConfig.access_key !== undefined && tdlyConfig.access_key !== null && tdlyConfig.access_key !== "" + ? "super secret access_key is set in 'access_key' field" + : "undefined or null or empty string", + }); return axios.default.create(params); } diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 6c485843..a013f6bd 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -34,14 +34,16 @@ export class TenderlyService { let tenderlyApi = TenderlyApiService.configureAnonymousInstance(); if (TenderlyApiService.isAuthenticated()) { - logger.debug("API service has been authenticated. Configuring instance..."); tenderlyApi = TenderlyApiService.configureInstance(); - logger.debug("Instance has been configured."); } try { logger.debug("Obtaining public networks..."); const res = await tenderlyApi.get("/api/v1/public-networks"); + if (res.data === undefined || res.data === null) { + logger.error("There was an error while obtaining public networks from Tenderly. Obtained response is invalid."); + return []; + } logger.silly("Obtained public networks:", res.data); return res.data; @@ -61,8 +63,13 @@ export class TenderlyService { } try { - logger.trace("Making a call to the api..."); const res = await tenderlyApi.get(`/api/v1/network/${networkId}/block-number`); + if (res.data === undefined || res.data === null) { + logger.error( + "There was an error while obtaining latest block number from Tenderly. Obtained response is invalid." + ); + return null; + } logger.trace(`Api successfully returned: ${res.data.block_number}`); return res.data.block_number; @@ -87,9 +94,14 @@ export class TenderlyService { return; } - logger.debug("Making a call to the api..."); + logger.debug("Verifying contracts publicly..."); const res = await tenderlyApi.post("/api/v1/public/verify-contracts", { ...request }); - logger.debug("API call successfully made."); + if (res.data === undefined || res.data === null) { + logger.error( + "There was an error while publicly verifying contracts on Tenderly. Obtained response is invalid." + ); + return; + } logger.trace("Retrieved data:", res.data); const responseData: ContractResponse = res.data; @@ -141,11 +153,14 @@ export class TenderlyService { const tenderlyApi = TenderlyApiService.configureInstance(); try { - logger.debug("Making a call to the api..."); + logger.debug("Trying to push contracts onto Tenderly..."); const res = await tenderlyApi.post(`/api/v1/account/${username}/project/${tenderlyProject}/contracts`, { ...request, }); - logger.debug("Call to the api successfully made."); + if (res.data === undefined || res.data === null) { + logger.error("There was an error while pushing contracts to Tenderly. Obtained response is invalid."); + return; + } logger.trace("Retrieved data:", res.data); const responseData: ContractResponse = res.data; @@ -189,11 +204,13 @@ export class TenderlyService { const tenderlyApi = TenderlyApiService.configureTenderlyRPCInstance(); try { - logger.debug("Making a call to the api..."); + logger.debug("Trying to verify contracts on fork..."); const res = await tenderlyApi.post(`/account/${username}/project/${tenderlyProject}/fork/${fork}/verify`, { ...request, }); - logger.debug("Call to the api successfully made."); + if (res.data === undefined || res.data === null) { + logger.error("There was an error while verifying contracts on fork. Obtained response is invalid."); + } logger.trace("Retrieved data:", res.data); const responseData: ContractResponse = res.data; @@ -233,9 +250,11 @@ export class TenderlyService { const tenderlyApi = TenderlyApiService.configureInstance(); try { - logger.debug("Making a call to the api..."); const res = await tenderlyApi.get("/api/v1/user"); - logger.trace("Retrieved data:", { id: res.data.user.id, username: res.data.user.username }); + if (res.data === undefined || res.data === null) { + logger.error("There was an error while obtaining principal from Tenderly. Obtained response is invalid."); + } + logger.trace("Retrieved data:", { id: res.data.user.id }); return { id: res.data.user.id, @@ -249,7 +268,7 @@ export class TenderlyService { } public async getProjectSlugs(principalId: string): Promise { - logger.debug("Getting project slugs has been called."); + logger.debug("Getting project slugs..."); if (!TenderlyApiService.isAuthenticated()) { logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); @@ -258,8 +277,10 @@ export class TenderlyService { const tenderlyApi = TenderlyApiService.configureInstance(); try { - logger.debug("Making a call to the api..."); const res = await tenderlyApi.get(`/api/v1/account/${principalId}/projects`); + if (res.data === undefined || res.data === null) { + logger.error("There was an error while obtaining project slug from Tenderly. Obtained response is invalid."); + } logger.trace("Retrieved data:", res.data.projects); return res.data.projects; diff --git a/packages/tenderly-core/src/utils/config.ts b/packages/tenderly-core/src/utils/config.ts index f92f4759..55ac9f38 100644 --- a/packages/tenderly-core/src/utils/config.ts +++ b/packages/tenderly-core/src/utils/config.ts @@ -3,6 +3,7 @@ import os from "os"; import path from "path"; import * as yaml from "js-yaml"; import { TenderlyConfig } from "../types"; +import { logConfig } from "../internal/core/common/logger"; import { logger } from "./logger"; const configDir = `${os.homedir() + path.sep}.tenderly`; @@ -15,23 +16,7 @@ export function getConfig(): TenderlyConfig { const fileData = fs.readFileSync(configFilePath); const tenderlyConfig = yaml.load(fileData.toString()) as TenderlyConfig; - logger.trace("Tenderly config exists. Value of the config:", { - email: tenderlyConfig.email, - account_id: tenderlyConfig.account_id, - username: tenderlyConfig.username, - access_key: - tenderlyConfig.access_key !== undefined && - tenderlyConfig.access_key !== null && - tenderlyConfig.access_key !== "" - ? "super secret access_key is set in 'access_key' field" - : "undefined or null or empty string", - access_key_id: - tenderlyConfig.access_key_id !== undefined && - tenderlyConfig.access_key_id !== null && - tenderlyConfig.access_key_id !== "" - ? "super secret access_key_id is set in 'access_key' field" - : "undefined or null or empty string", - }); + logConfig(tenderlyConfig); return tenderlyConfig; } @@ -49,19 +34,7 @@ export function getConfig(): TenderlyConfig { export function writeConfig(config: TenderlyConfig): void { logger.trace(`Writing config to a file @ ${configDir}/${configFilePath}`); - logger.trace("Value of the config:", { - email: config.email, - account_id: config.account_id, - username: config.username, - access_key: - config.access_key !== undefined && config.access_key !== null && config.access_key !== "" - ? "super secret access_key is set in 'access_key' field" - : "undefined or null or empty string", - access_key_id: - config.access_key_id !== undefined && config.access_key_id !== null && config.access_key_id !== "" - ? "super secret access_key_id is set in 'access_key' field" - : "undefined or null or empty string", - }); + logConfig(config); fs.mkdirSync(configDir, { recursive: true }); fs.writeFileSync(configFilePath, yaml.dump(config), "utf8"); diff --git a/packages/tenderly-hardhat/src/utils/util.ts b/packages/tenderly-hardhat/src/utils/util.ts index 3fd6b3a8..8278d465 100644 --- a/packages/tenderly-hardhat/src/utils/util.ts +++ b/packages/tenderly-hardhat/src/utils/util.ts @@ -23,7 +23,7 @@ export const getCompilerDataFromContracts = ( if (mainContract.name !== contract.contractName) { continue; } - logger.trace("Currently obtaining compiler data from contract:", mainContract.name); + logger.trace("Obtaining compiler data from contract:", mainContract.name); const contractConfig = newCompilerConfig(hhConfig, contract.sourcePath, contract.compiler?.version); if (config !== null && config !== undefined && !compareConfigs(contractConfig, config)) { @@ -44,7 +44,7 @@ export const getContracts = async ( hre: HardhatRuntimeEnvironment, flatContracts: ContractByName[] ): Promise => { - logger.debug("Processing contracts from the artifacts/ folder."); + logger.debug("Processing contracts from the artifacts/ directory."); const sourcePaths = await hre.run("compile:solidity:get-source-paths"); const sourceNames = await hre.run("compile:solidity:get-source-names", { @@ -168,7 +168,7 @@ export const newCompilerConfig = ( contractCompiler?: string ): TenderlyContractConfig => { if (sourcePath !== undefined && config.solidity.overrides[sourcePath] !== undefined) { - logger.trace("There is an compiler config override for:", sourcePath); + logger.trace("There is a compiler config override for:", sourcePath); return { compiler_version: config.solidity.overrides[sourcePath].version, From 7625dc66e90a168c41ed41448beacf2292c7deaf Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 7 Dec 2022 13:05:51 +0100 Subject: [PATCH 38/68] Edited logConfig function. --- packages/tenderly-core/src/internal/core/common/logger.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts index 62b26e51..67f18c27 100644 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ b/packages/tenderly-core/src/internal/core/common/logger.ts @@ -29,12 +29,12 @@ export function logConfig(config: TenderlyConfig) { logger.trace("Value of the config:", { email: config.email !== undefined && config.email !== null && config.email !== "" - ? "super secret access_key is set in 'access_key' field" + ? "set in 'email' field" : "undefined or null or empty string", account_id: config.account_id, username: config.username !== undefined && config.username !== null && config.username !== "" - ? "super secret access_key is set in 'access_key' field" + ? "set in 'username' field" : "undefined or null or empty string", access_key: config.access_key !== undefined && config.access_key !== null && config.access_key !== "" From 9ae251834627d5a6b8f8fe49d29df3cecdd7c104 Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 7 Dec 2022 13:12:51 +0100 Subject: [PATCH 39/68] Put 'x-access-key' as a header parameter in configureInstance. --- .../src/internal/core/services/TenderlyApiService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts index 2a7bb4a4..492ffbcf 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts @@ -11,7 +11,7 @@ export class TenderlyApiService { const tdlyConfig = getConfig(); const params = { baseURL: TENDERLY_API_BASE_URL, - accessKey: tdlyConfig.access_key, + headers: { "x-access-key": tdlyConfig.access_key }, }; logger.debug("Configured instance with parameters:", { From 6f1605d47a0b8af924dd90d0201ccb9ad0918335 Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 7 Dec 2022 13:19:05 +0100 Subject: [PATCH 40/68] Deleted logs inside isAuthenticated since it only checks if accessToken is set, it doesn't call the api to check if the accessToken is valid. We already have logs inside isAccessTokenSet so there is no need for logs inside isAuthenticated. --- .../src/internal/core/services/TenderlyApiService.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts index 492ffbcf..bafb29f5 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts @@ -57,10 +57,6 @@ export class TenderlyApiService { } public static isAuthenticated(): boolean { - logger.debug("Checking if user is authenticated..."); - const isAuth = isAccessTokenSet(); - logger.debug(isAuth ? "User is authenticated." : "User is not authenticated."); - - return isAuth; + return isAccessTokenSet(); } } From d36b93b466ca86464bc2e271de09202d5d98e1b2 Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 7 Dec 2022 14:39:14 +0100 Subject: [PATCH 41/68] Made logs more concise and understandable. --- .../internal/core/services/TenderlyService.ts | 17 ++++++------- packages/tenderly-core/src/utils/config.ts | 13 ++++++---- packages/tenderly-hardhat/src/Tenderly.ts | 24 +++++++++---------- .../tenderly-hardhat/src/TenderlyNetwork.ts | 23 +++++++++--------- packages/tenderly-hardhat/src/index.ts | 2 +- packages/tenderly-hardhat/src/utils/util.ts | 2 +- 6 files changed, 40 insertions(+), 41 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index a013f6bd..f92303cd 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -30,7 +30,7 @@ export class TenderlyService { } public async getNetworks(): Promise { - logger.debug("Getting networks has been called."); + logger.debug("Obtaining public networks..."); let tenderlyApi = TenderlyApiService.configureAnonymousInstance(); if (TenderlyApiService.isAuthenticated()) { @@ -38,7 +38,6 @@ export class TenderlyService { } try { - logger.debug("Obtaining public networks..."); const res = await tenderlyApi.get("/api/v1/public-networks"); if (res.data === undefined || res.data === null) { logger.error("There was an error while obtaining public networks from Tenderly. Obtained response is invalid."); @@ -81,7 +80,7 @@ export class TenderlyService { } public async verifyContracts(request: TenderlyContractUploadRequest): Promise { - logger.info("Verifying contracts has been called."); + logger.debug("Verifying contracts publicly..."); let tenderlyApi = TenderlyApiService.configureAnonymousInstance(); if (TenderlyApiService.isAuthenticated()) { @@ -94,7 +93,6 @@ export class TenderlyService { return; } - logger.debug("Verifying contracts publicly..."); const res = await tenderlyApi.post("/api/v1/public/verify-contracts", { ...request }); if (res.data === undefined || res.data === null) { logger.error( @@ -110,8 +108,8 @@ export class TenderlyService { return; } - if (responseData.contracts === null) { - logger.error("API call returned null value for contracts."); + if (responseData.contracts === undefined || responseData.contracts === null) { + logger.error("There was an error during public verification. There are no returned contracts."); return; } @@ -146,6 +144,7 @@ export class TenderlyService { tenderlyProject: string, username: string ): Promise { + logger.debug("Pushing contracts onto Tenderly..."); if (!TenderlyApiService.isAuthenticated()) { logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); return; @@ -153,7 +152,6 @@ export class TenderlyService { const tenderlyApi = TenderlyApiService.configureInstance(); try { - logger.debug("Trying to push contracts onto Tenderly..."); const res = await tenderlyApi.post(`/api/v1/account/${username}/project/${tenderlyProject}/contracts`, { ...request, }); @@ -195,7 +193,7 @@ export class TenderlyService { username: string, fork: string ): Promise { - logger.info("Fork verification has been called."); + logger.info("Verifying contracts on fork..."); if (!TenderlyApiService.isAuthenticated()) { logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); @@ -204,7 +202,6 @@ export class TenderlyService { const tenderlyApi = TenderlyApiService.configureTenderlyRPCInstance(); try { - logger.debug("Trying to verify contracts on fork..."); const res = await tenderlyApi.post(`/account/${username}/project/${tenderlyProject}/fork/${fork}/verify`, { ...request, }); @@ -241,7 +238,7 @@ export class TenderlyService { } public async getPrincipal(): Promise { - logger.debug("Getting principal has been called."); + logger.debug("Getting principal..."); if (!TenderlyApiService.isAuthenticated()) { logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); diff --git a/packages/tenderly-core/src/utils/config.ts b/packages/tenderly-core/src/utils/config.ts index 55ac9f38..b94f11dd 100644 --- a/packages/tenderly-core/src/utils/config.ts +++ b/packages/tenderly-core/src/utils/config.ts @@ -21,7 +21,7 @@ export function getConfig(): TenderlyConfig { return tenderlyConfig; } - logger.trace("Tenderly config doesn't exist, empty string values are returned instead."); + logger.warn("Tenderly config doesn't exist, empty string values are returned instead."); return { access_key: "", access_key_id: "", @@ -33,7 +33,7 @@ export function getConfig(): TenderlyConfig { } export function writeConfig(config: TenderlyConfig): void { - logger.trace(`Writing config to a file @ ${configDir}/${configFilePath}`); + logger.trace(`Writing tenderly config to a file @ ${configDir}/${configFilePath}`); logConfig(config); fs.mkdirSync(configDir, { recursive: true }); @@ -41,8 +41,11 @@ export function writeConfig(config: TenderlyConfig): void { } export function configExists(): boolean { - logger.trace("Checking if config exists..."); - return fs.existsSync(configFilePath); + logger.trace("Checking if tenderly config exists..."); + const exists = fs.existsSync(configFilePath); + logger.trace(exists ? "Tenderly config exists." : "Tenderly config doesn't exist."); + + return exists; } export function isAccessTokenSet(): boolean { @@ -58,7 +61,7 @@ export function isAccessTokenSet(): boolean { export function getAccessToken(): string { logger.trace("Getting access token..."); if (!isAccessTokenSet()) { - logger.trace("Access key is not set, returning empty string value."); + logger.warn("Access key is not set, returning empty string value."); return ""; } diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index f1784cfa..280e8ed6 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -20,16 +20,16 @@ export class Tenderly { private tenderlyService = new TenderlyService(PLUGIN_NAME); constructor(hre: HardhatRuntimeEnvironment) { - logger.debug("Making hardhat Tenderly interface..."); + logger.debug("Creating Tenderly plugin..."); this.env = hre; this.tenderlyNetwork = new TenderlyNetwork(hre); - logger.debug("Finished making hardhat Tenderly interface."); + logger.debug("Created Tenderly plugin."); } public async verify(...contracts: any[]): Promise { - logger.info("Public verification has been called."); + logger.info("Invoked public verification."); const priv = this.env.config.tenderly?.privateVerification; if (priv !== undefined && priv && this.env.network.name !== "tenderly") { @@ -49,7 +49,7 @@ export class Tenderly { const requestData = await this._filterContracts(flatContracts); if (requestData === null) { - logger.error("Verification failed"); + logger.error("Verification failed due to bad processing of the data in /artifacts directory."); return; } @@ -57,7 +57,7 @@ export class Tenderly { } public async verifyAPI(request: TenderlyContractUploadRequest): Promise { - logger.info("Public verification API has been called."); + logger.info("Invoked public verification through API request."); if (this.env.network.name === "tenderly") { logger.error( @@ -75,7 +75,7 @@ export class Tenderly { username: string, forkID: string ): Promise { - logger.info("Fork verification has been called."); + logger.info("Invoked fork verification through API request."); if (this.env.network.name !== "tenderly") { console.log( `Error in ${PLUGIN_NAME}: Network parameter is not set to 'tenderly' and verifyForkAPI() is only available for tenderly fork deployments, please use --network tenderly.` @@ -98,7 +98,7 @@ export class Tenderly { } public async push(...contracts: any[]): Promise { - logger.info("Private verification has been called."); + logger.info("Invoked pushing onto Tenderly."); const priv = this.env.config.tenderly?.privateVerification; if (priv !== undefined && !priv) { @@ -127,7 +127,7 @@ export class Tenderly { } if (requestData === null) { - console.log("Push failed"); + logger.error("Pushing failed due to bad processing of the data in /artifacts directory."); return; } @@ -143,7 +143,7 @@ export class Tenderly { tenderlyProject: string, username: string ): Promise { - logger.info("Private verification API has been called."); + logger.info("Invoked pushing contracts through API."); if (this.env.network.name === "tenderly") { logger.error( @@ -156,7 +156,7 @@ export class Tenderly { } public async persistArtifacts(...contracts: ContractByName[]) { - logger.info("Artifact persisting has been called."); + logger.info("Invoked persisting artifacts."); if (contracts.length === 0) { logger.error("No contracts were provided during artifact persisting."); return; @@ -240,13 +240,13 @@ export class Tenderly { } private async _filterContracts(flatContracts: ContractByName[]): Promise { - logger.info("Contract filtering has been called."); + logger.info("Processing data needed for verification..."); let contract: ContractByName; let requestData: TenderlyContractUploadRequest; try { requestData = await this._getContractData(flatContracts); - logger.silly("Request data obtained: ", requestData); + logger.silly("Processed request data:", requestData); } catch (e) { logger.error("Error caught while trying to process contracts by name: ", e); return null; diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index e9711bb1..a7a820c0 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -91,7 +91,7 @@ export class TenderlyNetwork { } public async verify(...contracts: any[]) { - logger.info("Fork verification has been called."); + logger.info("Invoked fork verification."); if (!this._checkNetwork()) { return; } @@ -103,12 +103,12 @@ export class TenderlyNetwork { const flatContracts: ContractByName[] = contracts.reduce((accumulator, value) => accumulator.concat(value), []); const requestData = await this._filterContracts(flatContracts); - logger.silly("Obtained request data needed for verifying contracts:", requestData); - if (requestData === null) { - logger.error("Filtering contracts did not succeed."); + logger.error("Fork verification failed due to bad processing of data in /artifacts directory."); return; } + logger.silly("Processed request data:", requestData); + if (requestData?.contracts.length === 0) { logger.error("Filtering contracts did not succeed. The length of the contracts is 0."); return; @@ -128,7 +128,7 @@ export class TenderlyNetwork { username: string, forkID: string ) { - logger.info("Fork verification via API has been called,"); + logger.info("Invoked fork verification via API."); await this.tenderlyService.verifyForkContracts(request, tenderlyProject, username, forkID); } @@ -162,7 +162,7 @@ export class TenderlyNetwork { } public async initializeFork() { - logger.debug("Fork initialization has been called."); + logger.debug("Initializing tenderly fork..."); if (!this._checkNetwork()) { return; @@ -174,10 +174,9 @@ export class TenderlyNetwork { const username: string = this.env.config.tenderly.username; const projectID: string = this.env.config.tenderly.project; - logger.trace("Username and projectID obtained from tenderly configuration:", { username, projectID }); + logger.trace("ProjectID obtained from tenderly configuration:", { projectID }); try { - logger.debug("Making a call to initialize fork..."); const resp = await this.tenderlyJsonRpc.post(`/account/${username}/project/${projectID}/fork`, { network_id: this.env.config.tenderly.forkNetwork, }); @@ -188,7 +187,7 @@ export class TenderlyNetwork { this.accounts = resp.data.simulation_fork.accounts; this.forkID = resp.data.simulation_fork.id; - logger.debug("Successfully initialized fork."); + logger.debug("Successfully initialized tenderly fork."); } catch (err) { logger.error("Error was caught while calling fork initialization:", err); throw err; @@ -202,7 +201,7 @@ export class TenderlyNetwork { } private async _filterContracts(flatContracts: ContractByName[]): Promise { - logger.info("Filtering contracts for fork verification has been called."); + logger.info("Processing data needed for fork verification..."); let contract: ContractByName; let requestData: TenderlyForkContractUploadRequest; @@ -237,11 +236,11 @@ export class TenderlyNetwork { } private async _getForkContractData(flatContracts: ContractByName[]): Promise { - logger.trace("Getting contract data for fork verification has been called."); + logger.trace("Getting contract data needed for fork verification..."); const contracts = await getContracts(this.env, flatContracts); if (contracts.length === 0) { - throw new Error("Failed to get contracts"); + throw new Error("Fork verification failed due to bad processing of data in /artifacts folder."); } const solcConfig = getCompilerDataFromContracts(contracts, flatContracts, this.env.config); diff --git a/packages/tenderly-hardhat/src/index.ts b/packages/tenderly-hardhat/src/index.ts index 284eafa8..a2b613d9 100644 --- a/packages/tenderly-hardhat/src/index.ts +++ b/packages/tenderly-hardhat/src/index.ts @@ -4,7 +4,7 @@ import "./tasks"; import * as tenderlyExtender from "./tenderly/extender"; -export function setup(cfg: { automaticVerifications: boolean } = { automaticVerifications: false }): void { +export function setup(cfg = { automaticVerifications: false }): void { process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications === true ? "true" : "false"; tenderlyExtender.setup(); } diff --git a/packages/tenderly-hardhat/src/utils/util.ts b/packages/tenderly-hardhat/src/utils/util.ts index 8278d465..b1be904e 100644 --- a/packages/tenderly-hardhat/src/utils/util.ts +++ b/packages/tenderly-hardhat/src/utils/util.ts @@ -69,7 +69,7 @@ export const getContracts = async ( data._resolvedFiles.forEach((resolvedFile: any, _: any) => { const sourcePath: string = resolvedFile.sourceName; - logger.trace("Currently processing file:", sourcePath); + logger.trace("Processing file:", sourcePath); const name = sourcePath.split("/").slice(-1)[0].split(".")[0]; logger.trace("Obtained name from source file:", name); From 7416b4212cbbc6b88ba81bcde5f7be8e29560b94 Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 8 Dec 2022 09:42:40 +0100 Subject: [PATCH 42/68] Added logs for project so it doesn't log sensitive data. --- .../tenderly-core/src/internal/core/common/logger.ts | 11 +++++++++++ .../src/internal/core/services/TenderlyService.ts | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts index 67f18c27..839559b0 100644 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ b/packages/tenderly-core/src/internal/core/common/logger.ts @@ -46,3 +46,14 @@ export function logConfig(config: TenderlyConfig) { : "undefined or null or empty string", }); } + +export function logGetProjectsResponse(projects: any[]) { + for (const project of projects) { + const projectLog = { + owner_principal_id: project.owner.id, + owner_principal_type: project.owner.type, + owner_permissions_for_project: project.permissions, + }; + logger.trace("Obtained project:", projectLog); + } +} diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index f92303cd..8ac8774d 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -1,5 +1,5 @@ import { TENDERLY_DASHBOARD_BASE_URL, CHAIN_ID_NETWORK_NAME_MAP } from "../../../common/constants"; -import { logApiError } from "../common/logger"; +import { logApiError, logGetProjectsResponse } from "../common/logger"; import { API_VERIFICATION_REQUEST_ERR_MSG, BYTECODE_MISMATCH_ERR_MSG, @@ -278,7 +278,7 @@ export class TenderlyService { if (res.data === undefined || res.data === null) { logger.error("There was an error while obtaining project slug from Tenderly. Obtained response is invalid."); } - logger.trace("Retrieved data:", res.data.projects); + logGetProjectsResponse(res.data.projects); return res.data.projects; } catch (err) { From 145e81d96ca2e884bca33049749f13a66c24f1b9 Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 8 Dec 2022 09:59:03 +0100 Subject: [PATCH 43/68] Added logs for project so it doesn't log sensitive data. --- .../tenderly-core/src/internal/core/common/logger.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts index 839559b0..96cfa279 100644 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ b/packages/tenderly-core/src/internal/core/common/logger.ts @@ -50,7 +50,17 @@ export function logConfig(config: TenderlyConfig) { export function logGetProjectsResponse(projects: any[]) { for (const project of projects) { const projectLog = { - owner_principal_id: project.owner.id, + project_id: project.id, + project_name: project.name, + project_slug: project.slug, + high_volume: project.high_volume, + in_transfer: project.in_transfer, + is_module: project.is_module, + created_at: project.created_at, + last_push_at: project.last_push_at, + number_of_users: project.number_of_users, + options: project.options, + owner_principal_id: project.owner_id, owner_principal_type: project.owner.type, owner_permissions_for_project: project.permissions, }; From 1dcc273d9b517c2bc172a62aafc9ccdafc2fea32 Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:21:45 +0100 Subject: [PATCH 44/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index bec453fa..3310fdbe 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -11,7 +11,7 @@ export const LoginCommand = new commander.Command("login").description("login to logger.info("Trying to login to Tenderly..."); if (isAccessTokenSet()) { - logger.debug("Access token is already set. Checking if user wants to overwrite it with a new one..."); + logger.debug("Access token is already set. Checking if access token overwrite is needed."); const response = await prompts({ type: "confirm", name: "overwrite", From 765d6200ef80dd10e30dbd7b4f544a3663694ddb Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:23:00 +0100 Subject: [PATCH 45/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 3310fdbe..ab71b71e 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -18,7 +18,7 @@ export const LoginCommand = new commander.Command("login").description("login to message: "Access token already set. Would you like to overwrite it?", }); if (!response.overwrite) { - logger.debug("User didn't request an overwrite of the token. Proceeding logging in with existing token."); + logger.debug("Access token overwrite skipped. Trying to login with the existing token."); return; } } From 0bcdf4183b1da58926aa158aa77cef8c857e31bc Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:23:11 +0100 Subject: [PATCH 46/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index ab71b71e..61081dd9 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -23,7 +23,7 @@ export const LoginCommand = new commander.Command("login").description("login to } } - logger.info("Access token isn't set. Waiting for user to provide it..."); + logger.info("Access token not set."); const accessToken = await promptAccessToken(); logger.debug("User access token accepted. Trying to log in..."); From 62c198b93b2bed1425e49f1cfbcb211bb52a2f30 Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:23:19 +0100 Subject: [PATCH 47/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 61081dd9..b6044ad5 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -26,7 +26,7 @@ export const LoginCommand = new commander.Command("login").description("login to logger.info("Access token not set."); const accessToken = await promptAccessToken(); - logger.debug("User access token accepted. Trying to log in..."); + logger.debug("Access token accepted. Trying to log in."); setAccessToken(accessToken); logger.info("The user successfully logged in to Tenderly."); From e333dbf62e33fdc4527eab94b1487821ef93901f Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:23:26 +0100 Subject: [PATCH 48/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index b6044ad5..c3f160e0 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -29,7 +29,7 @@ export const LoginCommand = new commander.Command("login").description("login to logger.debug("Access token accepted. Trying to log in."); setAccessToken(accessToken); - logger.info("The user successfully logged in to Tenderly."); + logger.info("Successfully logged in to Tenderly."); }); async function promptAccessToken(): Promise { From f4dd46da233ed760631adc94d0f49f86c63f9805 Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:23:39 +0100 Subject: [PATCH 49/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index c3f160e0..26f7ce3d 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -36,7 +36,7 @@ async function promptAccessToken(): Promise { logger.debug(`Redirecting to ${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`); await open(`${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`); - logger.info("Prompting user to enter access token"); + logger.info("Requesting access token."); const response = await prompts({ type: "text", name: "accessToken", From 4cd1b8994a01ef5c0f1c032890b0a21faa888869 Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:23:50 +0100 Subject: [PATCH 50/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 26f7ce3d..15821ad4 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -44,7 +44,7 @@ async function promptAccessToken(): Promise { validate: validator, }); - logger.info("User access token accepted."); + logger.info("Access token accepted."); return response.accessToken; } From 527cb07e74f16805d0113e35c65398eb319b7ee3 Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:24:02 +0100 Subject: [PATCH 51/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 15821ad4..d710d9a2 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -63,7 +63,7 @@ const validator = async function (value: string) { async function canAuthenticate(accessToken: string): Promise { try { - logger.debug("Checking if user access token is valid..."); + logger.debug("Checking if access token is valid."); const response = await axios.get(`${TENDERLY_API_BASE_URL}/api/v1/user`, { headers: { "x-access-key": accessToken }, }); From eaf028683dd0f3ac5bb6c666480add625e1d2f21 Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:24:14 +0100 Subject: [PATCH 52/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index d710d9a2..7b345c4f 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -68,7 +68,7 @@ async function canAuthenticate(accessToken: string): Promise { headers: { "x-access-key": accessToken }, }); if (response.data.user === undefined || response.data.user === null) { - logger.error("User doesn't have a valid access token."); + logger.error("Access token is invalid."); return false; } logger.debug("User has a valid access token."); From 68ad6d8b71f61e18ea3b75743bb252ce7b8a6d7a Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:24:26 +0100 Subject: [PATCH 53/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 7b345c4f..97faae23 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -71,7 +71,7 @@ async function canAuthenticate(accessToken: string): Promise { logger.error("Access token is invalid."); return false; } - logger.debug("User has a valid access token."); + logger.debug("Access token is valid."); return true; } catch (err) { logger.error(`There was an error while trying to authenticate user.`); From e1fe17e683ce40c916b4f933ca2edc306b1dd7ac Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:29:39 +0100 Subject: [PATCH 54/68] Update packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 97faae23..190e8242 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -74,7 +74,7 @@ async function canAuthenticate(accessToken: string): Promise { logger.debug("Access token is valid."); return true; } catch (err) { - logger.error(`There was an error while trying to authenticate user.`); + logger.error("Authentication error."); return false; } } From ee37864cb28a45f974d4d436c01e4062eaec054a Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:41:16 +0100 Subject: [PATCH 55/68] Update packages/tenderly-hardhat/README.md Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- packages/tenderly-hardhat/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-hardhat/README.md b/packages/tenderly-hardhat/README.md index 7157958d..58c414c7 100644 --- a/packages/tenderly-hardhat/README.md +++ b/packages/tenderly-hardhat/README.md @@ -159,7 +159,7 @@ module.exports = { }; ``` -If you are having trouble with the plugin and want to contact support, you can rum the deploy script with the following ```--verbose``` flag as so: +If you are having trouble with the plugin and want to contact support, you can run the deploy script with the following ```--verbose``` flag as so: ```bash npx hardhat run scripts/{your_deploy_script_here.js} --network {network_name} --verbose > tenderly.log 2>&1 ``` From ac176b1bb8c124d27115cbcffe2e0e0801192480 Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:41:56 +0100 Subject: [PATCH 56/68] Update packages/tenderly-hardhat/README.md Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- packages/tenderly-hardhat/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-hardhat/README.md b/packages/tenderly-hardhat/README.md index 58c414c7..0318c310 100644 --- a/packages/tenderly-hardhat/README.md +++ b/packages/tenderly-hardhat/README.md @@ -163,7 +163,7 @@ If you are having trouble with the plugin and want to contact support, you can r ```bash npx hardhat run scripts/{your_deploy_script_here.js} --network {network_name} --verbose > tenderly.log 2>&1 ``` -This will create a ```tenderly.log``` file that you can send to our customer support. +This will create a ```tenderly.log``` file that you can send to our customer support engineers for investigation. ## Usage For this plugin to function you need to create a `config.yaml` file at `$HOME/.tenderly/config.yaml` or `%HOMEPATH%\.tenderly\config.yaml` and add an `access_key` field to it: From 5442c2102bece90041542af6c7092397f7e21a8a Mon Sep 17 00:00:00 2001 From: dule-git Date: Thu, 8 Dec 2022 11:37:01 +0100 Subject: [PATCH 57/68] Added filter logs for public networks and verify contracts. Needed to update response data structures so that I could create log structures. --- .../src/internal/core/common/logger.ts | 71 ++++++++++++++++++- .../internal/core/services/TenderlyService.ts | 11 ++- .../src/internal/core/types/Contract.ts | 27 ++++++- 3 files changed, 104 insertions(+), 5 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts index 96cfa279..72bc0318 100644 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ b/packages/tenderly-core/src/internal/core/common/logger.ts @@ -1,4 +1,4 @@ -import { TenderlyConfig } from "../../../types"; +import { ContractResponse, TenderlyConfig } from "../../../types"; const API_ERR_MSG = "Unexpected error occurred. \n Error reason %s %s. \n Error context: %s"; import { logger } from "../../../utils/logger"; @@ -67,3 +67,72 @@ export function logGetProjectsResponse(projects: any[]) { logger.trace("Obtained project:", projectLog); } } + +export function logGetPublicNetworksResponse(networks: any[]) { + for (const network of networks) { + const networkLog = { + id: network.id, + name: network.name, + ethereum_network_id: network.ethereum_network_id, + slug: network.slug, + metadata: { + color: network.metadata.color, + explorer_base_url: network.metadata.explorer_base_url, + icon: network.metadata.icon, + label: network.metadata.label, + native_currency: network.metadata.native_currency, + secondary_slugs: network.metadata.secondary_slugs, + short_identifier: network.metadata.short_identifier, + slug: network.metadata.slug, + }, + chain_config: network.chain_config, + sort_order: network.sort_order, + }; + logger.silly("Obtained public network:", networkLog); + } +} + +export function logVerifyContractsResponse(response: ContractResponse) { + for (const contract of response.contracts) { + const contractLog = { + id: contract.id, + contract_id: contract.contract_id, + balance: contract.balance, + network_id: contract.network_id, + public: contract.public, + export: contract.export, + verification_date: contract.verification_date, + address: contract.address, + contract_name: contract.contract_name, + ens_domain: contract.ens_domain, + type: contract.type, + evm_version: contract.evm_version, + compiler_version: contract.compiler_version, + optimizations_used: contract.optimizations_used, + optimization_runs: contract.optimization_runs, + libraries: contract.libraries, + data: contract.data, + creation_block: contract.creation_block, + creation_tx: contract.creation_tx, + creator_address: contract.creator_address, + created_at: contract.created_at, + number_of_watches: contract.number_of_watches, + language: contract.language, + in_project: contract.in_project, + number_of_files: contract.number_of_files, + }; + + logger.trace("Verified contract:", contractLog); + } + + for (const err of response.bytecode_mismatch_errors) { + const errLog = { + contract_id: err.contract_id, + expected: err.expected, + got: err.got, + similarity: err.similarity, + assumed_reason: err.assumed_reason, + }; + logger.trace("Bytecode mismatch error:", errLog); + } +} diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 8ac8774d..506b2556 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -1,5 +1,10 @@ import { TENDERLY_DASHBOARD_BASE_URL, CHAIN_ID_NETWORK_NAME_MAP } from "../../../common/constants"; -import { logApiError, logGetProjectsResponse } from "../common/logger"; +import { + logApiError, + logGetProjectsResponse, + logGetPublicNetworksResponse, + logVerifyContractsResponse, +} from "../common/logger"; import { API_VERIFICATION_REQUEST_ERR_MSG, BYTECODE_MISMATCH_ERR_MSG, @@ -43,7 +48,7 @@ export class TenderlyService { logger.error("There was an error while obtaining public networks from Tenderly. Obtained response is invalid."); return []; } - logger.silly("Obtained public networks:", res.data); + logGetPublicNetworksResponse(res.data); return res.data; } catch (err) { @@ -100,7 +105,7 @@ export class TenderlyService { ); return; } - logger.trace("Retrieved data:", res.data); + logVerifyContractsResponse(res.data); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { diff --git a/packages/tenderly-core/src/internal/core/types/Contract.ts b/packages/tenderly-core/src/internal/core/types/Contract.ts index f04599b4..2b4f9362 100644 --- a/packages/tenderly-core/src/internal/core/types/Contract.ts +++ b/packages/tenderly-core/src/internal/core/types/Contract.ts @@ -39,12 +39,37 @@ export interface ContractNetwork { } export interface ApiContract { - address: string; + id: string; + contract_id: string; + balance: string; network_id: string; + public: boolean; + export: boolean; + verification_date: string; + address: string; + contract_name: string; + ens_domain: string[]; + type: string; + evm_version: string; + compiler_version: string; + optimizations_used: boolean; + optimization_runs: number; + libraries: Record; + data: object; + creation_block: number; + creation_tx: string; + creator_address: string; + created_at: string; + number_of_watches: number; + language: string; + in_project: boolean; + number_of_files: number; } export interface BytecodeMismatchError { contract_id: string; expected: string; got: string; + similarity: number; + assumed_reason: string; } From 05d5356f6f75be0e84806d97ae89f10cac2acf8b Mon Sep 17 00:00:00 2001 From: dule-git Date: Fri, 9 Dec 2022 10:44:09 +0100 Subject: [PATCH 58/68] Made log filter functions so that we don't log whole responses. --- .../src/internal/cli/commands/NetworksCommand.ts | 3 ++- .../tenderly-core/src/internal/core/common/logger.ts | 10 +++++++++- .../src/internal/core/services/TenderlyService.ts | 9 +++++---- packages/tenderly-hardhat/src/TenderlyNetwork.ts | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts index ba9d3692..4cdacdc0 100644 --- a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts @@ -5,6 +5,7 @@ import { logger } from "../../../utils/logger"; import { PLUGIN_NAME } from "../../../common/constants"; import { TenderlyService } from "../../core/services"; import { TenderlyNetwork } from "../../core/types"; +import { logGetPublicNetworksResponse } from "../../core/common/logger"; const tenderlyService = new TenderlyService(PLUGIN_NAME); @@ -23,7 +24,7 @@ export const NetworksCommand = new commander.Command("networks") const filteredNetworks = networks.filter(isNotExcluded); filteredNetworks.sort((a, b) => a.sort_order - b.sort_order); - logger.silly("Filtered networks:", filteredNetworks); + logGetPublicNetworksResponse(filteredNetworks); const table = new Table({ style: { head: ["magenta"] }, diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts index 72bc0318..9a31eb7c 100644 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ b/packages/tenderly-core/src/internal/core/common/logger.ts @@ -92,7 +92,7 @@ export function logGetPublicNetworksResponse(networks: any[]) { } } -export function logVerifyContractsResponse(response: ContractResponse) { +export function logVerificationResponse(response: ContractResponse) { for (const contract of response.contracts) { const contractLog = { id: contract.id, @@ -136,3 +136,11 @@ export function logVerifyContractsResponse(response: ContractResponse) { logger.trace("Bytecode mismatch error:", errLog); } } + +export function logInitializeForkResponse(data: any) { + logger.trace("Initialized fork:", { + fork_id: data.simulation_fork.id, + root_transaction: data.root_transaction.id, + project_id: data.simulation_fork.project_id, + }); +} diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 506b2556..4e2c579f 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -3,8 +3,9 @@ import { logApiError, logGetProjectsResponse, logGetPublicNetworksResponse, - logVerifyContractsResponse, + logVerificationResponse, } from "../common/logger"; + import { API_VERIFICATION_REQUEST_ERR_MSG, BYTECODE_MISMATCH_ERR_MSG, @@ -105,7 +106,7 @@ export class TenderlyService { ); return; } - logVerifyContractsResponse(res.data); + logVerificationResponse(res.data); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { @@ -164,7 +165,7 @@ export class TenderlyService { logger.error("There was an error while pushing contracts to Tenderly. Obtained response is invalid."); return; } - logger.trace("Retrieved data:", res.data); + logVerificationResponse(res.data); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { @@ -213,7 +214,7 @@ export class TenderlyService { if (res.data === undefined || res.data === null) { logger.error("There was an error while verifying contracts on fork. Obtained response is invalid."); } - logger.trace("Retrieved data:", res.data); + logVerificationResponse(res.data); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index a7a820c0..761860b4 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -6,6 +6,7 @@ import { TenderlyForkContractUploadRequest } from "tenderly/types"; import { getConfig, writeConfig } from "tenderly/utils/config"; import { TENDERLY_JSON_RPC_BASE_URL } from "tenderly/common/constants"; +import { logInitializeForkResponse } from "tenderly/internal/core/common/logger"; import { PLUGIN_NAME } from "./constants"; import { ContractByName } from "./tenderly/types"; import { NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG } from "./tenderly/errors"; @@ -180,8 +181,7 @@ export class TenderlyNetwork { const resp = await this.tenderlyJsonRpc.post(`/account/${username}/project/${projectID}/fork`, { network_id: this.env.config.tenderly.forkNetwork, }); - - logger.trace("Obtained information from a call:", resp); + logInitializeForkResponse(resp.data); this.head = resp.data.root_transaction.id; this.accounts = resp.data.simulation_fork.accounts; From e5d9c2c01a6ecc06d40ef23ef903a188b47976f8 Mon Sep 17 00:00:00 2001 From: dule-git Date: Fri, 9 Dec 2022 10:55:11 +0100 Subject: [PATCH 59/68] Upgraded linter version. --- packages/tenderly-core/package.json | 2 +- packages/tenderly-hardhat/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/tenderly-core/package.json b/packages/tenderly-core/package.json index a321e96e..71bb5d78 100644 --- a/packages/tenderly-core/package.json +++ b/packages/tenderly-core/package.json @@ -39,7 +39,7 @@ "@types/prompts": "^2.0.14", "@typescript-eslint/eslint-plugin": "^5.36.1", "@typescript-eslint/parser": "^5.36.1", - "eslint": "8.22.0", + "eslint": "^8.23.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", diff --git a/packages/tenderly-hardhat/package.json b/packages/tenderly-hardhat/package.json index b44c7db0..da938e6c 100644 --- a/packages/tenderly-hardhat/package.json +++ b/packages/tenderly-hardhat/package.json @@ -39,7 +39,7 @@ "@types/node": "^18.7.15", "@typescript-eslint/eslint-plugin": "^5.36.1", "@typescript-eslint/parser": "^5.36.1", - "eslint": "^8.22.0", + "eslint": "^8.23.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", From 7c82313addb1e7d84c8c4a79fa48832816d68a41 Mon Sep 17 00:00:00 2001 From: dule-git Date: Fri, 9 Dec 2022 11:16:03 +0100 Subject: [PATCH 60/68] Changed logs towards the user to be in initial state. --- .../tenderly-core/src/internal/cli/commands/LoginCommand.ts | 4 +++- packages/tenderly-hardhat/src/Tenderly.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 190e8242..805d238b 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -28,11 +28,13 @@ export const LoginCommand = new commander.Command("login").description("login to logger.debug("Access token accepted. Trying to log in."); setAccessToken(accessToken); - + + console.log("Successfully logged in to Tenderly."); logger.info("Successfully logged in to Tenderly."); }); async function promptAccessToken(): Promise { + console.log(`Redirecting to ${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`) logger.debug(`Redirecting to ${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`); await open(`${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`); diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index 280e8ed6..b02fd473 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -77,7 +77,7 @@ export class Tenderly { ): Promise { logger.info("Invoked fork verification through API request."); if (this.env.network.name !== "tenderly") { - console.log( + logger.error( `Error in ${PLUGIN_NAME}: Network parameter is not set to 'tenderly' and verifyForkAPI() is only available for tenderly fork deployments, please use --network tenderly.` ); return; From f499dce0bb215e3ee0e1cd946cf58b1a6146b1da Mon Sep 17 00:00:00 2001 From: dule-git Date: Tue, 13 Dec 2022 10:28:22 +0100 Subject: [PATCH 61/68] Added null pointer guards in log filter functions. --- .../src/internal/core/common/logger.ts | 160 +++++++++--------- 1 file changed, 84 insertions(+), 76 deletions(-) diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts index 9a31eb7c..879a30fd 100644 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ b/packages/tenderly-core/src/internal/core/common/logger.ts @@ -48,92 +48,100 @@ export function logConfig(config: TenderlyConfig) { } export function logGetProjectsResponse(projects: any[]) { - for (const project of projects) { - const projectLog = { - project_id: project.id, - project_name: project.name, - project_slug: project.slug, - high_volume: project.high_volume, - in_transfer: project.in_transfer, - is_module: project.is_module, - created_at: project.created_at, - last_push_at: project.last_push_at, - number_of_users: project.number_of_users, - options: project.options, - owner_principal_id: project.owner_id, - owner_principal_type: project.owner.type, - owner_permissions_for_project: project.permissions, - }; - logger.trace("Obtained project:", projectLog); + if (projects) { + for (const project of projects) { + const projectLog = { + project_id: project.id, + project_name: project.name, + project_slug: project.slug, + high_volume: project.high_volume, + in_transfer: project.in_transfer, + is_module: project.is_module, + created_at: project.created_at, + last_push_at: project.last_push_at, + number_of_users: project.number_of_users, + options: project.options, + owner_principal_id: project.owner_id, + owner_principal_type: project.owner.type, + owner_permissions_for_project: project.permissions, + }; + logger.trace("Obtained project:", projectLog); + } } } export function logGetPublicNetworksResponse(networks: any[]) { - for (const network of networks) { - const networkLog = { - id: network.id, - name: network.name, - ethereum_network_id: network.ethereum_network_id, - slug: network.slug, - metadata: { - color: network.metadata.color, - explorer_base_url: network.metadata.explorer_base_url, - icon: network.metadata.icon, - label: network.metadata.label, - native_currency: network.metadata.native_currency, - secondary_slugs: network.metadata.secondary_slugs, - short_identifier: network.metadata.short_identifier, - slug: network.metadata.slug, - }, - chain_config: network.chain_config, - sort_order: network.sort_order, - }; - logger.silly("Obtained public network:", networkLog); + if (networks) { + for (const network of networks) { + const networkLog = { + id: network.id, + name: network.name, + ethereum_network_id: network.ethereum_network_id, + slug: network.slug, + metadata: { + color: network.metadata.color, + explorer_base_url: network.metadata.explorer_base_url, + icon: network.metadata.icon, + label: network.metadata.label, + native_currency: network.metadata.native_currency, + secondary_slugs: network.metadata.secondary_slugs, + short_identifier: network.metadata.short_identifier, + slug: network.metadata.slug, + }, + chain_config: network.chain_config, + sort_order: network.sort_order, + }; + logger.silly("Obtained public network:", networkLog); + } } } export function logVerificationResponse(response: ContractResponse) { - for (const contract of response.contracts) { - const contractLog = { - id: contract.id, - contract_id: contract.contract_id, - balance: contract.balance, - network_id: contract.network_id, - public: contract.public, - export: contract.export, - verification_date: contract.verification_date, - address: contract.address, - contract_name: contract.contract_name, - ens_domain: contract.ens_domain, - type: contract.type, - evm_version: contract.evm_version, - compiler_version: contract.compiler_version, - optimizations_used: contract.optimizations_used, - optimization_runs: contract.optimization_runs, - libraries: contract.libraries, - data: contract.data, - creation_block: contract.creation_block, - creation_tx: contract.creation_tx, - creator_address: contract.creator_address, - created_at: contract.created_at, - number_of_watches: contract.number_of_watches, - language: contract.language, - in_project: contract.in_project, - number_of_files: contract.number_of_files, - }; + if (response.contracts) { + for (const contract of response.contracts) { + const contractLog = { + id: contract.id, + contract_id: contract.contract_id, + balance: contract.balance, + network_id: contract.network_id, + public: contract.public, + export: contract.export, + verification_date: contract.verification_date, + address: contract.address, + contract_name: contract.contract_name, + ens_domain: contract.ens_domain, + type: contract.type, + evm_version: contract.evm_version, + compiler_version: contract.compiler_version, + optimizations_used: contract.optimizations_used, + optimization_runs: contract.optimization_runs, + libraries: contract.libraries, + data: contract.data, + creation_block: contract.creation_block, + creation_tx: contract.creation_tx, + creator_address: contract.creator_address, + created_at: contract.created_at, + number_of_watches: contract.number_of_watches, + language: contract.language, + in_project: contract.in_project, + number_of_files: contract.number_of_files, + }; - logger.trace("Verified contract:", contractLog); - } + logger.trace("Verified contract:", contractLog); + } + } - for (const err of response.bytecode_mismatch_errors) { - const errLog = { - contract_id: err.contract_id, - expected: err.expected, - got: err.got, - similarity: err.similarity, - assumed_reason: err.assumed_reason, - }; - logger.trace("Bytecode mismatch error:", errLog); + if (response.bytecode_mismatch_errors) { + for (const err of response?.bytecode_mismatch_errors) { + const errLog = { + contract_id: err.contract_id, + expected: err.expected, + got: err.got, + similarity: err.similarity, + assumed_reason: err.assumed_reason, + }; + logger.trace("Bytecode mismatch error:", errLog); + } } } From 4a95ae7bc1b5407093d049a3c82fedec880aed3e Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Tue, 13 Dec 2022 14:38:45 +0100 Subject: [PATCH 62/68] Added extraction of compiler configuration from hardhat. (#92) * Added extraction of compiler configuration from hardhat. * Pretty the code. * Added changeset * Added sweet-starfishes-listen.md changeset * Added changeset --- .changeset/sweet-starfishes-listen.md | 11 +++++ .../tenderly-hardhat/.changeset/README.md | 8 ++++ .../tenderly-hardhat/.changeset/config.json | 11 +++++ .../.changeset/sixty-trainers-occur.md | 5 +++ .../tenderly-hardhat/src/TenderlyNetwork.ts | 4 +- packages/tenderly-hardhat/src/utils/util.ts | 43 ++++++++++++++++++- 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 .changeset/sweet-starfishes-listen.md create mode 100644 packages/tenderly-hardhat/.changeset/README.md create mode 100644 packages/tenderly-hardhat/.changeset/config.json create mode 100644 packages/tenderly-hardhat/.changeset/sixty-trainers-occur.md diff --git a/.changeset/sweet-starfishes-listen.md b/.changeset/sweet-starfishes-listen.md new file mode 100644 index 00000000..5148f345 --- /dev/null +++ b/.changeset/sweet-starfishes-listen.md @@ -0,0 +1,11 @@ +--- +"@tenderly/hardhat-tenderly": patch +--- + +There was an issue while extracting compiler version from the contracts that were given for verification. +We extracted these configurations on our own, thus providing the first compiler configuration that is suitable for a file without minding the dependencies because at the time of implementation of this logic, there weren't any hardhat tasks that could do such things. + +Now, there is a task that can get a compiler job for a given file. +A compiler job is hardhats' concept for all the data that is needed for compilation of contracts. It has all the dependencies and the configuration of the compiler. + +We used this task to obtain the compiler job and send it to the backend, after which the problem was fixed. diff --git a/packages/tenderly-hardhat/.changeset/README.md b/packages/tenderly-hardhat/.changeset/README.md new file mode 100644 index 00000000..e5b6d8d6 --- /dev/null +++ b/packages/tenderly-hardhat/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/packages/tenderly-hardhat/.changeset/config.json b/packages/tenderly-hardhat/.changeset/config.json new file mode 100644 index 00000000..16879c3e --- /dev/null +++ b/packages/tenderly-hardhat/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "master", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/packages/tenderly-hardhat/.changeset/sixty-trainers-occur.md b/packages/tenderly-hardhat/.changeset/sixty-trainers-occur.md new file mode 100644 index 00000000..e963262b --- /dev/null +++ b/packages/tenderly-hardhat/.changeset/sixty-trainers-occur.md @@ -0,0 +1,5 @@ +--- +"@tenderly/hardhat-tenderly": patch +--- + +Patch that fixed wrong extraction of compiler configuration from contract source files. diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index a3d4b69a..cdfa5e72 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -9,7 +9,7 @@ import { TENDERLY_JSON_RPC_BASE_URL } from "tenderly/common/constants"; import { PLUGIN_NAME } from "./constants"; import { ContractByName } from "./tenderly/types"; import { NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG } from "./tenderly/errors"; -import { getCompilerDataFromContracts, getContracts } from "./utils/util"; +import { getCompilerDataFromHardhat, getContracts} from "./utils/util"; export class TenderlyNetwork { public host: string; @@ -209,7 +209,7 @@ export class TenderlyNetwork { throw new Error("Failed to get contracts"); } - const solcConfig = getCompilerDataFromContracts(contracts, flatContracts, this.env.config); + const solcConfig = await getCompilerDataFromHardhat(this.env, contracts[0].contractName); if (solcConfig === undefined) { console.log(NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG); diff --git a/packages/tenderly-hardhat/src/utils/util.ts b/packages/tenderly-hardhat/src/utils/util.ts index 5ba9612e..972c3007 100644 --- a/packages/tenderly-hardhat/src/utils/util.ts +++ b/packages/tenderly-hardhat/src/utils/util.ts @@ -1,6 +1,6 @@ import { HardhatPluginError } from "hardhat/plugins"; import { HardhatConfig } from "hardhat/src/types/config"; -import { HardhatRuntimeEnvironment, SolcConfig } from "hardhat/types"; +import { CompilationJob, DependencyGraph, HardhatRuntimeEnvironment, SolcConfig } from "hardhat/types"; import { TenderlyContract, TenderlyContractConfig } from "tenderly/types"; import { PLUGIN_NAME } from "../constants"; @@ -130,6 +130,47 @@ export const compareConfigs = (originalConfig: TenderlyContractConfig, newConfig return true; }; +export const getCompilerDataFromHardhat = async ( + hre: HardhatRuntimeEnvironment, + contractName: string, +): Promise => { + const dependencyGraph: DependencyGraph = await _getDependencyGraph(hre); + const file = dependencyGraph.getResolvedFiles().find((resolvedFile) => { + const name = resolvedFile.sourceName.split("/").slice(-1)[0].split(".")[0]; + return name === contractName; + }); + const job: CompilationJob = await hre.run("compile:solidity:get-compilation-job-for-file", { + dependencyGraph, + file + }); + + const hhConfig: SolcConfig = job.getSolcConfig(); + + const tenderlyConfig: TenderlyContractConfig = { + compiler_version: hhConfig?.version, + optimizations_used: hhConfig?.settings?.optimizer?.enabled, + optimizations_count: hhConfig?.settings?.optimizer?.runs, + evm_version: hhConfig?.settings?.evmVersion, + } + if (hhConfig?.settings?.debug?.revertStrings) { + tenderlyConfig.debug = { + revertStrings: hhConfig.settings.debug.revertStrings + } + } + + return tenderlyConfig; +} + +async function _getDependencyGraph(hre: HardhatRuntimeEnvironment): Promise { + const sourcePaths = await hre.run("compile:solidity:get-source-paths"); + const sourceNames: string[] = await hre.run("compile:solidity:get-source-names", { + sourcePaths, + }); + return hre.run("compile:solidity:get-dependency-graph", { + sourceNames, + }); +} + export const newCompilerConfig = ( config: HardhatConfig, sourcePath?: string, From 66af51fa47d88e4b207e52df52566f3edf0bc9fe Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 13 Dec 2022 14:48:42 +0100 Subject: [PATCH 63/68] Version Packages (#93) Co-authored-by: github-actions[bot] --- .changeset/sweet-starfishes-listen.md | 11 ----------- packages/tenderly-hardhat/CHANGELOG.md | 10 ++++++++++ packages/tenderly-hardhat/package.json | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 .changeset/sweet-starfishes-listen.md diff --git a/.changeset/sweet-starfishes-listen.md b/.changeset/sweet-starfishes-listen.md deleted file mode 100644 index 5148f345..00000000 --- a/.changeset/sweet-starfishes-listen.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -"@tenderly/hardhat-tenderly": patch ---- - -There was an issue while extracting compiler version from the contracts that were given for verification. -We extracted these configurations on our own, thus providing the first compiler configuration that is suitable for a file without minding the dependencies because at the time of implementation of this logic, there weren't any hardhat tasks that could do such things. - -Now, there is a task that can get a compiler job for a given file. -A compiler job is hardhats' concept for all the data that is needed for compilation of contracts. It has all the dependencies and the configuration of the compiler. - -We used this task to obtain the compiler job and send it to the backend, after which the problem was fixed. diff --git a/packages/tenderly-hardhat/CHANGELOG.md b/packages/tenderly-hardhat/CHANGELOG.md index 4b84d16e..f511c694 100644 --- a/packages/tenderly-hardhat/CHANGELOG.md +++ b/packages/tenderly-hardhat/CHANGELOG.md @@ -1,5 +1,15 @@ # @tenderly/hardhat-tenderly +## 1.3.3 + +### Patch Changes + +- [#92](https://github.com/Tenderly/hardhat-tenderly/pull/92) [`4a95ae7`](https://github.com/Tenderly/hardhat-tenderly/commit/4a95ae7bc1b5407093d049a3c82fedec880aed3e) Thanks [@dule-git](https://github.com/dule-git)! - There was an issue while extracting compiler version from the contracts that were given for verification. We extracted these configurations on our own, thus providing the first compiler configuration that is suitable for a file without minding the dependencies because at the time of implementation of this logic, there weren't any hardhat tasks that could do such things. + + Now, there is a task that can get a compiler job for a given file. A compiler job is hardhats' concept for all the data that is needed for compilation of contracts. It has all the dependencies and the configuration of the compiler. + + We used this task to obtain the compiler job and send it to the backend, after which the problem was fixed. + ## 1.3.2 ### Patch Changes diff --git a/packages/tenderly-hardhat/package.json b/packages/tenderly-hardhat/package.json index c62e35e6..7866b19b 100644 --- a/packages/tenderly-hardhat/package.json +++ b/packages/tenderly-hardhat/package.json @@ -4,7 +4,7 @@ "license": "MIT", "homepage": "https://tenderly.co", "description": "Hardhat plugin for integration with Tenderly", - "version": "1.3.2", + "version": "1.3.3", "main": "dist/index.js", "types": "dist/index.d.ts", "repository": { From 0505412ea7796e7d8cbb250c5ccf3d24e68cca25 Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 14 Dec 2022 11:14:28 +0100 Subject: [PATCH 64/68] Changed chainID -> chainId so someone wouldn't misspell it as a variable --- packages/tenderly-hardhat/src/Tenderly.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index b02fd473..cdf66823 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -280,7 +280,7 @@ export class Tenderly { if (chainID === undefined) { logger.error( - `Error in ${PLUGIN_NAME}: Couldn't identify network. Please provide a chainID in the network config object` + `Error in ${PLUGIN_NAME}: Couldn't identify network. Please provide a chainId in the network config object` ); return null; } From b307d84601d891893f11917000865786206934a3 Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 14 Dec 2022 11:25:53 +0100 Subject: [PATCH 65/68] Replaced three dots instead of one. --- .../src/internal/cli/commands/LoginCommand.ts | 2 +- .../internal/core/services/TenderlyApiService.ts | 4 ++-- .../src/internal/core/services/TenderlyService.ts | 14 +++++++------- packages/tenderly-core/src/utils/config.ts | 10 +++++----- packages/tenderly-hardhat/src/Tenderly.ts | 10 +++++----- packages/tenderly-hardhat/src/TenderlyNetwork.ts | 8 ++++---- .../tenderly-hardhat/src/tasks/common/index.ts | 2 +- packages/tenderly-hardhat/src/tenderly/extender.ts | 4 ++-- packages/tenderly-hardhat/src/utils/util.ts | 4 ++-- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts index 805d238b..764f0d2a 100644 --- a/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts @@ -8,7 +8,7 @@ import { isAccessTokenSet, setAccessToken } from "../../../utils/config"; import { TENDERLY_API_BASE_URL, TENDERLY_DASHBOARD_BASE_URL } from "../../../common/constants"; export const LoginCommand = new commander.Command("login").description("login to Tenderly").action(async () => { - logger.info("Trying to login to Tenderly..."); + logger.info("Trying to login to Tenderly."); if (isAccessTokenSet()) { logger.debug("Access token is already set. Checking if access token overwrite is needed."); diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts index bafb29f5..51ee3ee2 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts @@ -6,7 +6,7 @@ import { TENDERLY_API_BASE_URL, TENDERLY_JSON_RPC_BASE_URL } from "../../../comm export class TenderlyApiService { public static configureInstance(): axios.AxiosInstance { - logger.debug("Configuring instance..."); + logger.debug("Configuring instance."); const tdlyConfig = getConfig(); const params = { @@ -34,7 +34,7 @@ export class TenderlyApiService { } public static configureTenderlyRPCInstance(): axios.AxiosInstance { - logger.debug("Configuring tenderly RPC instance..."); + logger.debug("Configuring tenderly RPC instance."); const tdlyConfig = getConfig(); const params = { diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 4e2c579f..0285b16a 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -36,7 +36,7 @@ export class TenderlyService { } public async getNetworks(): Promise { - logger.debug("Obtaining public networks..."); + logger.debug("Obtaining public networks."); let tenderlyApi = TenderlyApiService.configureAnonymousInstance(); if (TenderlyApiService.isAuthenticated()) { @@ -60,7 +60,7 @@ export class TenderlyService { } public async getLatestBlockNumber(networkId: string): Promise { - logger.debug("Getting latest block number..."); + logger.debug("Getting latest block number."); let tenderlyApi = TenderlyApiService.configureAnonymousInstance(); if (TenderlyApiService.isAuthenticated()) { @@ -86,7 +86,7 @@ export class TenderlyService { } public async verifyContracts(request: TenderlyContractUploadRequest): Promise { - logger.debug("Verifying contracts publicly..."); + logger.debug("Verifying contracts publicly."); let tenderlyApi = TenderlyApiService.configureAnonymousInstance(); if (TenderlyApiService.isAuthenticated()) { @@ -150,7 +150,7 @@ export class TenderlyService { tenderlyProject: string, username: string ): Promise { - logger.debug("Pushing contracts onto Tenderly..."); + logger.debug("Pushing contracts onto Tenderly."); if (!TenderlyApiService.isAuthenticated()) { logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); return; @@ -199,7 +199,7 @@ export class TenderlyService { username: string, fork: string ): Promise { - logger.info("Verifying contracts on fork..."); + logger.info("Verifying contracts on fork."); if (!TenderlyApiService.isAuthenticated()) { logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); @@ -244,7 +244,7 @@ export class TenderlyService { } public async getPrincipal(): Promise { - logger.debug("Getting principal..."); + logger.debug("Getting principal."); if (!TenderlyApiService.isAuthenticated()) { logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); @@ -271,7 +271,7 @@ export class TenderlyService { } public async getProjectSlugs(principalId: string): Promise { - logger.debug("Getting project slugs..."); + logger.debug("Getting project slugs."); if (!TenderlyApiService.isAuthenticated()) { logger.error(`Error in ${this.pluginName}: ${ACCESS_TOKEN_NOT_PROVIDED_ERR_MSG}`); diff --git a/packages/tenderly-core/src/utils/config.ts b/packages/tenderly-core/src/utils/config.ts index b94f11dd..e40a6815 100644 --- a/packages/tenderly-core/src/utils/config.ts +++ b/packages/tenderly-core/src/utils/config.ts @@ -10,7 +10,7 @@ const configDir = `${os.homedir() + path.sep}.tenderly`; export const configFilePath = `${configDir + path.sep}config.yaml`; export function getConfig(): TenderlyConfig { - logger.trace("Getting tenderly config..."); + logger.trace("Getting tenderly config."); if (configExists()) { const fileData = fs.readFileSync(configFilePath); @@ -41,7 +41,7 @@ export function writeConfig(config: TenderlyConfig): void { } export function configExists(): boolean { - logger.trace("Checking if tenderly config exists..."); + logger.trace("Checking if tenderly config exists."); const exists = fs.existsSync(configFilePath); logger.trace(exists ? "Tenderly config exists." : "Tenderly config doesn't exist."); @@ -49,7 +49,7 @@ export function configExists(): boolean { } export function isAccessTokenSet(): boolean { - logger.trace("Determining if access token in tenderly config file is set..."); + logger.trace("Determining if access token in tenderly config file is set."); const config = getConfig(); const isSet = config.access_key !== undefined && config.access_key !== null && config.access_key !== ""; @@ -59,7 +59,7 @@ export function isAccessTokenSet(): boolean { } export function getAccessToken(): string { - logger.trace("Getting access token..."); + logger.trace("Getting access token."); if (!isAccessTokenSet()) { logger.warn("Access key is not set, returning empty string value."); return ""; @@ -69,7 +69,7 @@ export function getAccessToken(): string { } export function setAccessToken(accessToken: string): void { - logger.trace("Setting access key..."); + logger.trace("Setting access key."); const config = getConfig(); config.access_key = accessToken; writeConfig(config); diff --git a/packages/tenderly-hardhat/src/Tenderly.ts b/packages/tenderly-hardhat/src/Tenderly.ts index cdf66823..39864ea3 100644 --- a/packages/tenderly-hardhat/src/Tenderly.ts +++ b/packages/tenderly-hardhat/src/Tenderly.ts @@ -20,7 +20,7 @@ export class Tenderly { private tenderlyService = new TenderlyService(PLUGIN_NAME); constructor(hre: HardhatRuntimeEnvironment) { - logger.debug("Creating Tenderly plugin..."); + logger.debug("Creating Tenderly plugin."); this.env = hre; this.tenderlyNetwork = new TenderlyNetwork(hre); @@ -34,13 +34,13 @@ export class Tenderly { const priv = this.env.config.tenderly?.privateVerification; if (priv !== undefined && priv && this.env.network.name !== "tenderly") { logger.info( - "Private verification flag is set to TRUE in tenderly configuration. Redirecting to private verification..." + "Private verification flag is set to TRUE in tenderly configuration. Redirecting to private verification." ); return this.push(...contracts); } if (this.env.network.name === "tenderly") { - logger.info("Network parameter is set to 'tenderly', redirecting to fork verification..."); + logger.info("Network parameter is set to 'tenderly', redirecting to fork verification."); return this.tenderlyNetwork.verify(contracts); } @@ -103,7 +103,7 @@ export class Tenderly { const priv = this.env.config.tenderly?.privateVerification; if (priv !== undefined && !priv) { logger.info( - "Private verification flag is set to FALSE in tenderly configuration. Redirecting to public verification..." + "Private verification flag is set to FALSE in tenderly configuration. Redirecting to public verification." ); return this.verify(...contracts); } @@ -240,7 +240,7 @@ export class Tenderly { } private async _filterContracts(flatContracts: ContractByName[]): Promise { - logger.info("Processing data needed for verification..."); + logger.info("Processing data needed for verification."); let contract: ContractByName; let requestData: TenderlyContractUploadRequest; diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index 9f4edddc..1e705321 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -26,7 +26,7 @@ export class TenderlyNetwork { private tenderlyService = new TenderlyService(PLUGIN_NAME); constructor(hre: HardhatRuntimeEnvironment) { - logger.debug("Making an interface towards tenderly network..."); + logger.debug("Making an interface towards tenderly network."); this.env = hre; this.connected = true; @@ -162,7 +162,7 @@ export class TenderlyNetwork { } public async initializeFork() { - logger.debug("Initializing tenderly fork..."); + logger.debug("Initializing tenderly fork."); if (!this._checkNetwork()) { return; @@ -200,7 +200,7 @@ export class TenderlyNetwork { } private async _filterContracts(flatContracts: ContractByName[]): Promise { - logger.info("Processing data needed for fork verification..."); + logger.info("Processing data needed for fork verification."); let contract: ContractByName; let requestData: TenderlyForkContractUploadRequest; @@ -235,7 +235,7 @@ export class TenderlyNetwork { } private async _getForkContractData(flatContracts: ContractByName[]): Promise { - logger.trace("Getting contract data needed for fork verification..."); + logger.trace("Getting contract data needed for fork verification."); const contracts = await getContracts(this.env, flatContracts); if (contracts.length === 0) { diff --git a/packages/tenderly-hardhat/src/tasks/common/index.ts b/packages/tenderly-hardhat/src/tasks/common/index.ts index c096a624..61a92df0 100644 --- a/packages/tenderly-hardhat/src/tasks/common/index.ts +++ b/packages/tenderly-hardhat/src/tasks/common/index.ts @@ -15,7 +15,7 @@ export async function extractContractData( config: HardhatConfig, run: RunTaskFunction ): Promise { - logger.info("Extracting contract data..."); + logger.info("Extracting contract data."); let contract: string; const requestContracts: TenderlyContract[] = []; diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 8137d862..081542af 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -34,7 +34,7 @@ export function setup() { serviceLogger.settings.minLevel = 1; // trace level } logger.info( - `Setting up hardhat-tenderly plugin... Log level of hardhat tenderly plugin set to: ${logger.settings.minLevel}` + `Setting up hardhat-tenderly plugin. Log level of hardhat tenderly plugin set to: ${logger.settings.minLevel}` ); // serviceLogger is used here just for initialization, nothing else, it will be used in TenderlyService.ts serviceLogger.info(`Log level of tenderly service set to: ${serviceLogger.settings.minLevel}`); @@ -53,7 +53,7 @@ export function setup() { extendProvider(hre); populateNetworks(); if (process.env.AUTOMATIC_VERIFICATION_ENABLED === "true") { - logger.debug("Automatic verification is enabled, proceeding to extend ethers library..."); + logger.debug("Automatic verification is enabled, proceeding to extend ethers library."); extendEthers(hre); extendHardhatDeploy(hre); logger.debug("Wrapping ethers library finished."); diff --git a/packages/tenderly-hardhat/src/utils/util.ts b/packages/tenderly-hardhat/src/utils/util.ts index 62e78854..056e8bc9 100644 --- a/packages/tenderly-hardhat/src/utils/util.ts +++ b/packages/tenderly-hardhat/src/utils/util.ts @@ -13,7 +13,7 @@ export const getCompilerDataFromContracts = ( flatContracts: ContractByName[], hhConfig: HardhatConfig ): TenderlyContractConfig | undefined => { - logger.debug("Obtaining compiler data from contracts..."); + logger.debug("Obtaining compiler data from contracts."); let contract: TenderlyContract; let mainContract: ContractByName; @@ -221,7 +221,7 @@ export const newCompilerConfig = ( } if (contractCompiler !== undefined) { - logger.trace("There is a provided compiler configuration, determining it..."); + logger.trace("There is a provided compiler configuration, determining it."); return determineCompilerConfig(config.solidity.compilers, contractCompiler); } From 71a134fcc3831b7b0a8a37015774b6f12054fe2a Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 14 Dec 2022 11:28:00 +0100 Subject: [PATCH 66/68] Changed a log related to tenderly config. --- packages/tenderly-core/src/internal/core/common/logger.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts index 879a30fd..b0e675a4 100644 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ b/packages/tenderly-core/src/internal/core/common/logger.ts @@ -26,7 +26,7 @@ export function logApiError(err: any) { } export function logConfig(config: TenderlyConfig) { - logger.trace("Value of the config:", { + logger.trace("Checking config:", { email: config.email !== undefined && config.email !== null && config.email !== "" ? "set in 'email' field" From 0579ef962f5146f6ccd0619361831dfbcff0b561 Mon Sep 17 00:00:00 2001 From: dule-git Date: Wed, 14 Dec 2022 13:19:33 +0100 Subject: [PATCH 67/68] Removed custom log filter functions. Introduced compliant log structures that can be logged safely. --- .../internal/cli/commands/NetworksCommand.ts | 5 +- .../src/internal/core/common/logger.ts | 154 --------------- .../internal/core/services/TenderlyService.ts | 49 +++-- packages/tenderly-core/src/utils/config.ts | 10 +- .../tenderly-core/src/utils/log-compliance.ts | 177 ++++++++++++++++++ .../tenderly-hardhat/src/TenderlyNetwork.ts | 12 +- .../tenderly-hardhat/src/tenderly/extender.ts | 4 +- yarn.lock | 85 +-------- 8 files changed, 232 insertions(+), 264 deletions(-) delete mode 100644 packages/tenderly-core/src/internal/core/common/logger.ts create mode 100644 packages/tenderly-core/src/utils/log-compliance.ts diff --git a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts index 4cdacdc0..12d869db 100644 --- a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts @@ -5,7 +5,7 @@ import { logger } from "../../../utils/logger"; import { PLUGIN_NAME } from "../../../common/constants"; import { TenderlyService } from "../../core/services"; import { TenderlyNetwork } from "../../core/types"; -import { logGetPublicNetworksResponse } from "../../core/common/logger"; +import { convertToLogCompliantNetworks } from "../../../utils/log-compliance"; const tenderlyService = new TenderlyService(PLUGIN_NAME); @@ -24,7 +24,8 @@ export const NetworksCommand = new commander.Command("networks") const filteredNetworks = networks.filter(isNotExcluded); filteredNetworks.sort((a, b) => a.sort_order - b.sort_order); - logGetPublicNetworksResponse(filteredNetworks); + const logCompliantNetworks = convertToLogCompliantNetworks(filteredNetworks); + logger.silly("Obtained filtered public networks:", filteredNetworks); const table = new Table({ style: { head: ["magenta"] }, diff --git a/packages/tenderly-core/src/internal/core/common/logger.ts b/packages/tenderly-core/src/internal/core/common/logger.ts deleted file mode 100644 index b0e675a4..00000000 --- a/packages/tenderly-core/src/internal/core/common/logger.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { ContractResponse, TenderlyConfig } from "../../../types"; - -const API_ERR_MSG = "Unexpected error occurred. \n Error reason %s %s. \n Error context: %s"; -import { logger } from "../../../utils/logger"; - -export function logApiError(err: any) { - // api error - if ("response" in err) { - const code = err?.response?.status; - const codeText = err?.response?.statusText; - let message = "No message"; - if (err.response?.data?.error?.message) { - message = err.response.data.error.message; - } else if (err.response?.data) { - message = err.response.data; - } - - logger.error(API_ERR_MSG, code, codeText, message); - return; - } - - // general error - if (err instanceof Error) { - logger.error(err.message); - } -} - -export function logConfig(config: TenderlyConfig) { - logger.trace("Checking config:", { - email: - config.email !== undefined && config.email !== null && config.email !== "" - ? "set in 'email' field" - : "undefined or null or empty string", - account_id: config.account_id, - username: - config.username !== undefined && config.username !== null && config.username !== "" - ? "set in 'username' field" - : "undefined or null or empty string", - access_key: - config.access_key !== undefined && config.access_key !== null && config.access_key !== "" - ? "super secret access_key is set in 'access_key' field" - : "undefined or null or empty string", - access_key_id: - config.access_key_id !== undefined && config.access_key_id !== null && config.access_key_id !== "" - ? "super secret access_key_id is set in 'access_key' field" - : "undefined or null or empty string", - }); -} - -export function logGetProjectsResponse(projects: any[]) { - if (projects) { - for (const project of projects) { - const projectLog = { - project_id: project.id, - project_name: project.name, - project_slug: project.slug, - high_volume: project.high_volume, - in_transfer: project.in_transfer, - is_module: project.is_module, - created_at: project.created_at, - last_push_at: project.last_push_at, - number_of_users: project.number_of_users, - options: project.options, - owner_principal_id: project.owner_id, - owner_principal_type: project.owner.type, - owner_permissions_for_project: project.permissions, - }; - logger.trace("Obtained project:", projectLog); - } - } -} - -export function logGetPublicNetworksResponse(networks: any[]) { - if (networks) { - for (const network of networks) { - const networkLog = { - id: network.id, - name: network.name, - ethereum_network_id: network.ethereum_network_id, - slug: network.slug, - metadata: { - color: network.metadata.color, - explorer_base_url: network.metadata.explorer_base_url, - icon: network.metadata.icon, - label: network.metadata.label, - native_currency: network.metadata.native_currency, - secondary_slugs: network.metadata.secondary_slugs, - short_identifier: network.metadata.short_identifier, - slug: network.metadata.slug, - }, - chain_config: network.chain_config, - sort_order: network.sort_order, - }; - logger.silly("Obtained public network:", networkLog); - } - } -} - -export function logVerificationResponse(response: ContractResponse) { - if (response.contracts) { - for (const contract of response.contracts) { - const contractLog = { - id: contract.id, - contract_id: contract.contract_id, - balance: contract.balance, - network_id: contract.network_id, - public: contract.public, - export: contract.export, - verification_date: contract.verification_date, - address: contract.address, - contract_name: contract.contract_name, - ens_domain: contract.ens_domain, - type: contract.type, - evm_version: contract.evm_version, - compiler_version: contract.compiler_version, - optimizations_used: contract.optimizations_used, - optimization_runs: contract.optimization_runs, - libraries: contract.libraries, - data: contract.data, - creation_block: contract.creation_block, - creation_tx: contract.creation_tx, - creator_address: contract.creator_address, - created_at: contract.created_at, - number_of_watches: contract.number_of_watches, - language: contract.language, - in_project: contract.in_project, - number_of_files: contract.number_of_files, - }; - - logger.trace("Verified contract:", contractLog); - } - } - - if (response.bytecode_mismatch_errors) { - for (const err of response?.bytecode_mismatch_errors) { - const errLog = { - contract_id: err.contract_id, - expected: err.expected, - got: err.got, - similarity: err.similarity, - assumed_reason: err.assumed_reason, - }; - logger.trace("Bytecode mismatch error:", errLog); - } - } -} - -export function logInitializeForkResponse(data: any) { - logger.trace("Initialized fork:", { - fork_id: data.simulation_fork.id, - root_transaction: data.root_transaction.id, - project_id: data.simulation_fork.project_id, - }); -} diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts index 0285b16a..a76fb884 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyService.ts @@ -1,11 +1,4 @@ import { TENDERLY_DASHBOARD_BASE_URL, CHAIN_ID_NETWORK_NAME_MAP } from "../../../common/constants"; -import { - logApiError, - logGetProjectsResponse, - logGetPublicNetworksResponse, - logVerificationResponse, -} from "../common/logger"; - import { API_VERIFICATION_REQUEST_ERR_MSG, BYTECODE_MISMATCH_ERR_MSG, @@ -27,6 +20,12 @@ import { } from "../types"; import { logger } from "../../../utils/logger"; import { TenderlyApiService } from "./TenderlyApiService"; +import { + convertToLogCompliantApiError, + convertToLogCompliantNetworks, + convertToLogCompliantProjects, + convertToLogCompliantVerificationResponse +} from "../../../utils/log-compliance"; export class TenderlyService { private pluginName: string; @@ -49,11 +48,13 @@ export class TenderlyService { logger.error("There was an error while obtaining public networks from Tenderly. Obtained response is invalid."); return []; } - logGetPublicNetworksResponse(res.data); + const logCompliantNetworks = convertToLogCompliantNetworks(res.data); + logger.silly("Obtained public networks:", logCompliantNetworks); return res.data; } catch (err) { - logApiError(err); + const logCompliantApiErr = convertToLogCompliantApiError(err); + logger.error(logCompliantApiErr); console.log(`Error in ${this.pluginName}: ${NETWORK_FETCH_FAILED_ERR_MSG}`); } return []; @@ -79,7 +80,8 @@ export class TenderlyService { return res.data.block_number; } catch (err) { - logApiError(err); + const logCompliantApiErr = convertToLogCompliantApiError(err); + logger.error(logCompliantApiErr); logger.error(`Error in ${this.pluginName}: ${LATEST_BLOCK_NUMBER_FETCH_FAILED_ERR_MSG}`); } return null; @@ -106,7 +108,8 @@ export class TenderlyService { ); return; } - logVerificationResponse(res.data); + const logCompliantVerificationResponse = convertToLogCompliantVerificationResponse(res.data); + logger.trace("Verification response:", logCompliantVerificationResponse); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { @@ -140,7 +143,8 @@ export class TenderlyService { } console.groupEnd(); } catch (err) { - logApiError(err); + const logCompliantApiError = convertToLogCompliantApiError(err); + logger.error(logCompliantApiError); logger.error(`Error in ${this.pluginName}: ${API_VERIFICATION_REQUEST_ERR_MSG}`); } } @@ -165,7 +169,8 @@ export class TenderlyService { logger.error("There was an error while pushing contracts to Tenderly. Obtained response is invalid."); return; } - logVerificationResponse(res.data); + const logCompliantVerificationResponse = convertToLogCompliantVerificationResponse(res.data); + logger.trace("Verification response:", logCompliantVerificationResponse); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { @@ -188,7 +193,8 @@ export class TenderlyService { `Successfully privately verified Smart Contracts for project ${tenderlyProject}. You can view your contracts at ${dashLink}` ); } catch (err) { - logApiError(err); + const logCompliantApiError = convertToLogCompliantApiError(err); + logger.error(logCompliantApiError); logger.error(`Error in ${this.pluginName}: ${API_VERIFICATION_REQUEST_ERR_MSG}`); } } @@ -214,7 +220,8 @@ export class TenderlyService { if (res.data === undefined || res.data === null) { logger.error("There was an error while verifying contracts on fork. Obtained response is invalid."); } - logVerificationResponse(res.data); + const logCompliantVerificationResponse = convertToLogCompliantVerificationResponse(res.data); + logger.trace("Verification response:", logCompliantVerificationResponse); const responseData: ContractResponse = res.data; if (responseData.bytecode_mismatch_errors !== null) { @@ -238,7 +245,8 @@ export class TenderlyService { } console.groupEnd(); } catch (err) { - logApiError(err); + const logCompliantApiError = convertToLogCompliantApiError(err); + logger.error(logCompliantApiError); logger.error(`Error in ${this.pluginName}: ${API_VERIFICATION_REQUEST_ERR_MSG}`); } } @@ -264,7 +272,8 @@ export class TenderlyService { username: res.data.user.username, }; } catch (err) { - logApiError(err); + const logCompliantApiError = convertToLogCompliantApiError(err); + logger.error(logCompliantApiError); logger.error(`Error in ${this.pluginName}: ${PRINCIPAL_FETCH_FAILED_ERR_MSG}`); } return null; @@ -284,11 +293,13 @@ export class TenderlyService { if (res.data === undefined || res.data === null) { logger.error("There was an error while obtaining project slug from Tenderly. Obtained response is invalid."); } - logGetProjectsResponse(res.data.projects); + const logCompliantProjects = convertToLogCompliantProjects(res.data.projects); + logger.trace("Obtained projects:", logCompliantProjects); return res.data.projects; } catch (err) { - logApiError(err); + const logCompliantApiError = convertToLogCompliantApiError(err); + logger.error(logCompliantApiError); logger.error(`Error in ${this.pluginName}: ${PROJECTS_FETCH_FAILED_ERR_MSG}`); } return []; diff --git a/packages/tenderly-core/src/utils/config.ts b/packages/tenderly-core/src/utils/config.ts index e40a6815..28387af6 100644 --- a/packages/tenderly-core/src/utils/config.ts +++ b/packages/tenderly-core/src/utils/config.ts @@ -3,8 +3,8 @@ import os from "os"; import path from "path"; import * as yaml from "js-yaml"; import { TenderlyConfig } from "../types"; -import { logConfig } from "../internal/core/common/logger"; import { logger } from "./logger"; +import { convertToLogCompliantTenderlyConfig } from "./log-compliance"; const configDir = `${os.homedir() + path.sep}.tenderly`; export const configFilePath = `${configDir + path.sep}config.yaml`; @@ -16,7 +16,9 @@ export function getConfig(): TenderlyConfig { const fileData = fs.readFileSync(configFilePath); const tenderlyConfig = yaml.load(fileData.toString()) as TenderlyConfig; - logConfig(tenderlyConfig); + + const logCompliantTenderlyConfig = convertToLogCompliantTenderlyConfig(tenderlyConfig); + logger.trace("Checking config:", logCompliantTenderlyConfig); return tenderlyConfig; } @@ -34,7 +36,9 @@ export function getConfig(): TenderlyConfig { export function writeConfig(config: TenderlyConfig): void { logger.trace(`Writing tenderly config to a file @ ${configDir}/${configFilePath}`); - logConfig(config); + + const logCompliantTenderlyConfig = convertToLogCompliantTenderlyConfig(config); + logger.trace("Checking config:", logCompliantTenderlyConfig); fs.mkdirSync(configDir, { recursive: true }); fs.writeFileSync(configFilePath, yaml.dump(config), "utf8"); diff --git a/packages/tenderly-core/src/utils/log-compliance.ts b/packages/tenderly-core/src/utils/log-compliance.ts new file mode 100644 index 00000000..d6d71795 --- /dev/null +++ b/packages/tenderly-core/src/utils/log-compliance.ts @@ -0,0 +1,177 @@ +import { + ApiContract, + BytecodeMismatchError, + ContractResponse, +} from "../internal/core/types"; +import { TenderlyConfig } from "../types"; + +export function convertToLogCompliantApiError(err: any) { + // api error + if ("response" in err) { + const code = err?.response?.status; + const codeText = err?.response?.statusText; + let message = "No message"; + if (err.response?.data?.error?.message) { + message = err.response.data.error.message; + } else if (err.response?.data) { + message = err.response.data; + } + return `Unexpected error occurred. \n Error reason ${code} ${codeText}. \n Error context: ${message}`; + } + + // general error + if (err instanceof Error) { + return err.message; + } +} + +export function convertToLogCompliantVerificationResponse(res: ContractResponse) { + const logCompliantContracts = convertToLogCompliantContracts(res.contracts); + const logCompliantBytecodeMismatchErrors = convertToLogCompliantBytecodeMismatchErrors(res.bytecode_mismatch_errors); + + return { + contracts: logCompliantContracts, + bytecode_mismatch_errors: logCompliantBytecodeMismatchErrors, + } +} + +export function convertToLogCompliantContracts(contracts: ApiContract[]) { + if (contracts === undefined || contracts === null) { + return undefined; + } + + const logCompliantContracts = []; + for (const contract of contracts) { + logCompliantContracts.push({ + id: contract.id, + contract_id: contract.contract_id, + balance: contract.balance, + network_id: contract.network_id, + public: contract.public, + export: contract.export, + verification_date: contract.verification_date, + address: contract.address, + contract_name: contract.contract_name, + ens_domain: contract.ens_domain, + type: contract.type, + evm_version: contract.evm_version, + compiler_version: contract.compiler_version, + optimizations_used: contract.optimizations_used, + optimization_runs: contract.optimization_runs, + libraries: contract.libraries, + data: contract.data, + creation_block: contract.creation_block, + creation_tx: contract.creation_tx, + creator_address: contract.creator_address, + created_at: contract.created_at, + number_of_watches: contract.number_of_watches, + language: contract.language, + in_project: contract.in_project, + number_of_files: contract.number_of_files, + }); + } + return logCompliantContracts; +} + +export function convertToLogCompliantBytecodeMismatchErrors(bytecodeMismatchErrors: BytecodeMismatchError[]) { + if (bytecodeMismatchErrors === undefined || bytecodeMismatchErrors === null) { + return undefined; + } + + const logCompliantBytecodeMismatchErrors = []; + for (const err of bytecodeMismatchErrors) { + logCompliantBytecodeMismatchErrors.push({ + contract_id: err.contract_id, + expected: err.expected, + got: err.got, + similarity: err.similarity, + assumed_reason: err.assumed_reason, + }); + } + return logCompliantBytecodeMismatchErrors; +} + +export function convertToLogCompliantProjects(projects: any[]) { + if (projects === undefined || projects === null) { + return undefined; + } + + const logCompliantProjects = []; + for (const project of projects) { + logCompliantProjects.push({ + project_id: project.id, + project_name: project.name, + project_slug: project.slug, + high_volume: project.high_volume, + in_transfer: project.in_transfer, + is_module: project.is_module, + created_at: project.created_at, + last_push_at: project.last_push_at, + number_of_users: project.number_of_users, + options: project.options, + owner_principal_id: project.owner_id, + owner_principal_type: project.owner.type, + owner_permissions_for_project: project.permissions, + }); + } + return logCompliantProjects; +} + +export function convertToLogCompliantNetworks(networks: any[]) { + if (networks === undefined || networks === null) { + return undefined; + } + + const logCompliantNetworks = []; + for (const network of networks) { + logCompliantNetworks.push({ + id: network.id, + name: network.name, + ethereum_network_id: network.ethereum_network_id, + slug: network.slug, + metadata: { + color: network.metadata.color, + explorer_base_url: network.metadata.explorer_base_url, + icon: network.metadata.icon, + label: network.metadata.label, + native_currency: network.metadata.native_currency, + secondary_slugs: network.metadata.secondary_slugs, + short_identifier: network.metadata.short_identifier, + slug: network.metadata.slug, + }, + chain_config: network.chain_config, + sort_order: network.sort_order, + }); + } + return logCompliantNetworks; +} + +export function convertToLogCompliantForkInitializeResponse(res: any) { + return { + fork_id: res.simulation_fork.id, + root_transaction: res.root_transaction.id, + project_id: res.simulation_fork.project_id, + }; +} + +export function convertToLogCompliantTenderlyConfig(config: TenderlyConfig) { + return { + email: + config.email !== undefined && config.email !== null && config.email !== "" + ? "set in 'email' field" + : "undefined or null or empty string", + account_id: config.account_id, + username: + config.username !== undefined && config.username !== null && config.username !== "" + ? "set in 'username' field" + : "undefined or null or empty string", + access_key: + config.access_key !== undefined && config.access_key !== null && config.access_key !== "" + ? "super secret access_key is set in 'access_key' field" + : "undefined or null or empty string", + access_key_id: + config.access_key_id !== undefined && config.access_key_id !== null && config.access_key_id !== "" + ? "super secret access_key_id is set in 'access_key' field" + : "undefined or null or empty string", + }; +} diff --git a/packages/tenderly-hardhat/src/TenderlyNetwork.ts b/packages/tenderly-hardhat/src/TenderlyNetwork.ts index 1e705321..57bcd4a1 100644 --- a/packages/tenderly-hardhat/src/TenderlyNetwork.ts +++ b/packages/tenderly-hardhat/src/TenderlyNetwork.ts @@ -6,12 +6,12 @@ import { TenderlyForkContractUploadRequest } from "tenderly/types"; import { getConfig, writeConfig } from "tenderly/utils/config"; import { TENDERLY_JSON_RPC_BASE_URL } from "tenderly/common/constants"; -import { logInitializeForkResponse } from "tenderly/internal/core/common/logger"; import { PLUGIN_NAME } from "./constants"; import { ContractByName } from "./tenderly/types"; import { NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG } from "./tenderly/errors"; -import { getCompilerDataFromHardhat, getContracts} from "./utils/util"; +import {getCompilerDataFromContracts, getCompilerDataFromHardhat, getContracts} from "./utils/util"; import { logger } from "./utils/logger"; +import { convertToLogCompliantForkInitializeResponse } from "tenderly/utils/log-compliance"; export class TenderlyNetwork { public host: string; @@ -180,7 +180,8 @@ export class TenderlyNetwork { const resp = await this.tenderlyJsonRpc.post(`/account/${username}/project/${projectID}/fork`, { network_id: this.env.config.tenderly.forkNetwork, }); - logInitializeForkResponse(resp.data); + const logCompliantInitializeForkResponse = convertToLogCompliantForkInitializeResponse(resp); + logger.trace("Initialized fork:", logCompliantInitializeForkResponse); this.head = resp.data.root_transaction.id; this.accounts = resp.data.simulation_fork.accounts; @@ -242,8 +243,9 @@ export class TenderlyNetwork { throw new Error("Fork verification failed due to bad processing of data in /artifacts folder."); } - const solcConfig = await getCompilerDataFromHardhat(this.env, contracts[0].contractName); - + // const solcConfig = await getCompilerDataFromHardhat(this.env, contracts[0].contractName); + const solcConfig = await getCompilerDataFromContracts(contracts, flatContracts, this.env.config); + if (solcConfig === undefined) { logger.error(NO_COMPILER_FOUND_FOR_CONTRACT_ERR_MSG); } diff --git a/packages/tenderly-hardhat/src/tenderly/extender.ts b/packages/tenderly-hardhat/src/tenderly/extender.ts index 081542af..1929bb10 100644 --- a/packages/tenderly-hardhat/src/tenderly/extender.ts +++ b/packages/tenderly-hardhat/src/tenderly/extender.ts @@ -23,8 +23,8 @@ const tenderlyService = new TenderlyService(PLUGIN_NAME); export function setup() { // set to loggers to error level by default - logger.settings.minLevel = 4; - serviceLogger.settings.minLevel = 4; + logger.settings.minLevel = 1; + serviceLogger.settings.minLevel = 1; extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.tenderly = lazyObject(() => new Tenderly(hre)); diff --git a/yarn.lock b/yarn.lock index 04ebf328..0c6b4842 100644 --- a/yarn.lock +++ b/yarn.lock @@ -258,7 +258,7 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@eslint/eslintrc@^1.3.0", "@eslint/eslintrc@^1.3.3": +"@eslint/eslintrc@^1.3.3": version "1.3.3" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.3.tgz#2b044ab39fdfa75b4688184f9e573ce3c5b0ff95" integrity sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg== @@ -615,15 +615,6 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" -"@humanwhocodes/config-array@^0.10.4": - version "0.10.4" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.10.4.tgz#01e7366e57d2ad104feea63e72248f22015c520c" - integrity sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw== - dependencies: - "@humanwhocodes/object-schema" "^1.2.1" - debug "^4.1.1" - minimatch "^3.0.4" - "@humanwhocodes/config-array@^0.11.6": version "0.11.7" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.7.tgz#38aec044c6c828f6ed51d5d7ae3d9b9faf6dbb0f" @@ -633,11 +624,6 @@ debug "^4.1.1" minimatch "^3.0.5" -"@humanwhocodes/gitignore-to-minimatch@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz#316b0a63b91c10e53f242efb4ace5c3b34e8728d" - integrity sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA== - "@humanwhocodes/module-importer@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" @@ -2385,55 +2371,10 @@ eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@8.22.0: - version "8.22.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.22.0.tgz#78fcb044196dfa7eef30a9d65944f6f980402c48" - integrity sha512-ci4t0sz6vSRKdmkOGmprBo6fmI4PrphDFMy5JEq/fNS0gQkJM3rLmrqcp8ipMcdobH3KtUP40KniAE9W19S4wA== - dependencies: - "@eslint/eslintrc" "^1.3.0" - "@humanwhocodes/config-array" "^0.10.4" - "@humanwhocodes/gitignore-to-minimatch" "^1.0.2" - ajv "^6.10.0" - chalk "^4.0.0" - cross-spawn "^7.0.2" - debug "^4.3.2" - doctrine "^3.0.0" - escape-string-regexp "^4.0.0" - eslint-scope "^7.1.1" - eslint-utils "^3.0.0" - eslint-visitor-keys "^3.3.0" - espree "^9.3.3" - esquery "^1.4.0" - esutils "^2.0.2" - fast-deep-equal "^3.1.3" - file-entry-cache "^6.0.1" - find-up "^5.0.0" - functional-red-black-tree "^1.0.1" - glob-parent "^6.0.1" - globals "^13.15.0" - globby "^11.1.0" - grapheme-splitter "^1.0.4" - ignore "^5.2.0" - import-fresh "^3.0.0" - imurmurhash "^0.1.4" - is-glob "^4.0.0" - js-yaml "^4.1.0" - json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.4.1" - lodash.merge "^4.6.2" - minimatch "^3.1.2" - natural-compare "^1.4.0" - optionator "^0.9.1" - regexpp "^3.2.0" - strip-ansi "^6.0.1" - strip-json-comments "^3.1.0" - text-table "^0.2.0" - v8-compile-cache "^2.0.3" - -eslint@^8.22.0: - version "8.28.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.28.0.tgz#81a680732634677cc890134bcdd9fdfea8e63d6e" - integrity sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ== +eslint@^8.23.0: + version "8.29.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.29.0.tgz#d74a88a20fb44d59c51851625bc4ee8d0ec43f87" + integrity sha512-isQ4EEiyUjZFbEKvEGJKKGBwXtvXX+zJbkVKCgTuB9t/+jUBcy8avhkEwWJecI15BkRkOYmvIM5ynbhRjEkoeg== dependencies: "@eslint/eslintrc" "^1.3.3" "@humanwhocodes/config-array" "^0.11.6" @@ -2475,15 +2416,6 @@ eslint@^8.22.0: strip-json-comments "^3.1.0" text-table "^0.2.0" -espree@^9.3.3: - version "9.4.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.1.tgz#51d6092615567a2c2cff7833445e37c28c0065bd" - integrity sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg== - dependencies: - acorn "^8.8.0" - acorn-jsx "^5.3.2" - eslint-visitor-keys "^3.3.0" - espree@^9.4.0: version "9.4.0" resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.0.tgz#cd4bc3d6e9336c433265fc0aa016fc1aaf182f8a" @@ -2976,7 +2908,7 @@ glob-parent@^5.1.2, glob-parent@~5.1.2: dependencies: is-glob "^4.0.1" -glob-parent@^6.0.1, glob-parent@^6.0.2: +glob-parent@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== @@ -5138,11 +5070,6 @@ v8-compile-cache-lib@^3.0.1: resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== -v8-compile-cache@^2.0.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - validate-npm-package-license@^3.0.1: version "3.0.4" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" From 674bed56502e6b6b9f037dec1d7552ba9760dd20 Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Wed, 14 Dec 2022 14:05:06 +0100 Subject: [PATCH 68/68] Update packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts Co-authored-by: Dalibor Aleksov <110389065+daleksov@users.noreply.github.com> --- .../tenderly-core/src/internal/cli/commands/NetworksCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts index 12d869db..4562a1cd 100644 --- a/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts +++ b/packages/tenderly-core/src/internal/cli/commands/NetworksCommand.ts @@ -25,7 +25,7 @@ export const NetworksCommand = new commander.Command("networks") filteredNetworks.sort((a, b) => a.sort_order - b.sort_order); const logCompliantNetworks = convertToLogCompliantNetworks(filteredNetworks); - logger.silly("Obtained filtered public networks:", filteredNetworks); + logger.silly("Obtained filtered public networks:", logCompliantNetworks); const table = new Table({ style: { head: ["magenta"] },