Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix[smock]: add support for hardhat 2.4.0 #1112

Merged
merged 3 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nice-terms-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/smock': patch
---

Minor smock patch to add support for hardhat 2.4.0 and up
4 changes: 2 additions & 2 deletions packages/smock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@nomiclabs/ethereumjs-vm": "^4",
"@nomiclabs/hardhat-ethers": "^2",
"ethers": "^5",
"hardhat": "^2.2.1"
"hardhat": "^2"
},
"dependencies": {
"@eth-optimism/core-utils": "^0.4.5",
Expand Down Expand Up @@ -54,7 +54,7 @@
"eslint-plugin-unicorn": "^32.0.1",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.0.31",
"hardhat": "^2.2.1",
"hardhat": "^2.4.0",
"lodash": "^4.17.20",
"prettier": "^2.2.1"
}
Expand Down
15 changes: 14 additions & 1 deletion packages/smock/src/smockit/binding.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
/* Imports: External */
import { HardhatNetworkProvider } from 'hardhat/internal/hardhat-network/provider/provider'
import { decodeRevertReason } from 'hardhat/internal/hardhat-network/stack-traces/revert-reasons'
import { VmError } from '@nomiclabs/ethereumjs-vm/dist/exceptions'
import BN from 'bn.js'

// Handle hardhat ^2.4.0
let decodeRevertReason: (value: Buffer) => string
try {
decodeRevertReason = require('hardhat/internal/hardhat-network/stack-traces/revert-reasons')
.decodeRevertReason
} catch (err) {
const {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes a lot of sense. I was wondering how you'd support both versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah meh this is good enough for now.

ReturnData,
} = require('hardhat/internal/hardhat-network/provider/return-data')
decodeRevertReason = (value: Buffer) => {
return new ReturnData(value).decodeError()
}
}

// Handle hardhat ^2.2.0
let TransactionExecutionError: any
try {
Expand Down
114 changes: 113 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,16 @@
ethereumjs-util "^7.0.10"
merkle-patricia-tree "^4.1.0"

"@ethereumjs/block@^3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@ethereumjs/block/-/block-3.3.0.tgz#a1b3baec831c71c0d9e7f6145f25e919cff4939c"
integrity sha512-WoefY9Rs4W8vZTxG9qwntAlV61xsSv0NPoXmHO7x3SH16dwJQtU15YvahPCz4HEEXbu7GgGgNgu0pv8JY7VauA==
dependencies:
"@ethereumjs/common" "^2.3.0"
"@ethereumjs/tx" "^3.2.0"
ethereumjs-util "^7.0.10"
merkle-patricia-tree "^4.2.0"

"@ethereumjs/blockchain@^5.2.1":
version "5.2.1"
resolved "https://registry.yarnpkg.com/@ethereumjs/blockchain/-/blockchain-5.2.1.tgz#83ed83647667265f1666f111caf065ef9d1e82b5"
Expand All @@ -580,6 +590,21 @@
rlp "^2.2.4"
semaphore-async-await "^1.5.1"

"@ethereumjs/blockchain@^5.3.0":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@ethereumjs/blockchain/-/blockchain-5.3.0.tgz#206936e30a4320d87a26e58d157eadef21ef6ff1"
integrity sha512-B0Y5QDZcRDQISPilv3m8nzk97QmC98DnSE9WxzGpCxfef22Mw7xhwGipci5Iy0dVC2Np2Cr5d3F6bHAR7+yVmQ==
dependencies:
"@ethereumjs/block" "^3.3.0"
"@ethereumjs/common" "^2.3.0"
"@ethereumjs/ethash" "^1.0.0"
debug "^2.2.0"
ethereumjs-util "^7.0.10"
level-mem "^5.0.1"
lru-cache "^5.1.1"
rlp "^2.2.4"
semaphore-async-await "^1.5.1"

"@ethereumjs/common@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-2.2.0.tgz#850a3e3e594ee707ad8d44a11e8152fb62450535"
Expand All @@ -588,6 +613,14 @@
crc-32 "^1.2.0"
ethereumjs-util "^7.0.9"

"@ethereumjs/common@^2.3.0", "@ethereumjs/common@^2.3.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-2.3.1.tgz#d692e3aff5adb35dd587dd1e6caab69e0ed2fa0b"
integrity sha512-V8hrULExoq0H4HFs3cCmdRGbgmipmlNzak6Xg34nHYfQyqkSdrCuflvYjyWmsNpI8GtrcZhzifAbgX/1C1Cjwg==
dependencies:
crc-32 "^1.2.0"
ethereumjs-util "^7.0.10"

"@ethereumjs/ethash@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@ethereumjs/ethash/-/ethash-1.0.0.tgz#4e77f85b37be1ade5393e8719bdabac3e796ddaa"
Expand All @@ -606,6 +639,14 @@
"@ethereumjs/common" "^2.2.0"
ethereumjs-util "^7.0.10"

"@ethereumjs/tx@^3.2.0", "@ethereumjs/tx@^3.2.1":
version "3.2.1"
resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.2.1.tgz#65f5f1c11541764f08377a94ba4b0dcbbd67739e"
integrity sha512-i9V39OtKvwWos1uVNZxdVhd7zFOyzFLjgt69CoiOY0EmXugS0HjO3uxpLBSglDKFMRriuGqw6ddKEv+RP1UNEw==
dependencies:
"@ethereumjs/common" "^2.3.1"
ethereumjs-util "^7.0.10"

"@ethereumjs/vm@^5.3.2":
version "5.3.2"
resolved "https://registry.yarnpkg.com/@ethereumjs/vm/-/vm-5.3.2.tgz#b4d83a3d50a7ad22d6d412cc21bbde221b3e2871"
Expand Down Expand Up @@ -7532,7 +7573,7 @@ github-from-package@0.0.0:
resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce"
integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=

glob-parent@^5.1.0, glob-parent@^5.1.1, glob-parent@~5.1.0:
glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@^5.1.1, glob-parent@~5.1.0:
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
Expand Down Expand Up @@ -7866,6 +7907,59 @@ hardhat@^2.3.0:
uuid "^3.3.2"
ws "^7.2.1"

hardhat@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.4.0.tgz#b0db7a6e07fa72414665634ced149bbb10252499"
integrity sha512-IMh7Ws/7fIO5RRkm4nhqS2JWEct0690K35BcFVuIOoIRMcDLKc/7+JSxhey3RkXc5M4qUvdxfQI0LRQx4aqBZw==
dependencies:
"@ethereumjs/block" "^3.3.0"
"@ethereumjs/blockchain" "^5.3.0"
"@ethereumjs/common" "^2.3.1"
"@ethereumjs/tx" "^3.2.1"
"@ethereumjs/vm" "^5.3.2"
"@ethersproject/abi" "^5.1.2"
"@sentry/node" "^5.18.1"
"@solidity-parser/parser" "^0.11.0"
"@types/bn.js" "^5.1.0"
"@types/lru-cache" "^5.1.0"
abort-controller "^3.0.0"
adm-zip "^0.4.16"
ansi-escapes "^4.3.0"
chalk "^2.4.2"
chokidar "^3.4.0"
ci-info "^2.0.0"
debug "^4.1.1"
enquirer "^2.3.0"
env-paths "^2.2.0"
eth-sig-util "^2.5.2"
ethereum-cryptography "^0.1.2"
ethereumjs-abi "^0.6.8"
ethereumjs-util "^7.0.10"
find-up "^2.1.0"
fp-ts "1.19.3"
fs-extra "^7.0.1"
glob "^7.1.3"
https-proxy-agent "^5.0.0"
immutable "^4.0.0-rc.12"
io-ts "1.10.4"
lodash "^4.17.11"
merkle-patricia-tree "^4.2.0"
mnemonist "^0.38.0"
mocha "^7.1.2"
node-fetch "^2.6.0"
qs "^6.7.0"
raw-body "^2.4.1"
resolve "1.17.0"
semver "^6.3.0"
slash "^3.0.0"
solc "0.7.3"
source-map-support "^0.5.13"
stacktrace-parser "^0.1.10"
"true-case-path" "^2.2.1"
tsort "0.0.1"
uuid "^3.3.2"
ws "^7.4.6"

has-ansi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
Expand Down Expand Up @@ -9841,6 +9935,19 @@ merkle-patricia-tree@^4.0.0, merkle-patricia-tree@^4.1.0:
rlp "^2.2.3"
semaphore-async-await "^1.5.1"

merkle-patricia-tree@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-4.2.0.tgz#a204b9041be5c25e8d14f0ff47021de090e811a1"
integrity sha512-0sBVXs7z1Q1/kxzWZ3nPnxSPiaHKF/f497UQzt9O7isRcS10tel9jM/4TivF6Jv7V1yFq4bWyoATxbDUOen5vQ==
dependencies:
"@types/levelup" "^4.3.0"
ethereumjs-util "^7.0.10"
level-mem "^5.0.1"
level-ws "^2.0.0"
readable-stream "^3.6.0"
rlp "^2.2.4"
semaphore-async-await "^1.5.1"

merkletreejs@^0.2.12, merkletreejs@^0.2.18:
version "0.2.18"
resolved "https://registry.yarnpkg.com/merkletreejs/-/merkletreejs-0.2.18.tgz#205cc4f79e134c9bc887bdbd440b9e78787c4823"
Expand Down Expand Up @@ -15084,6 +15191,11 @@ ws@^7.2.1:
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.4.tgz#383bc9742cb202292c9077ceab6f6047b17f2d59"
integrity sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw==

ws@^7.4.6:
version "7.5.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.0.tgz#0033bafea031fb9df041b2026fc72a571ca44691"
integrity sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==

xhr-request-promise@^0.1.2:
version "0.1.3"
resolved "https://registry.yarnpkg.com/xhr-request-promise/-/xhr-request-promise-0.1.3.tgz#2d5f4b16d8c6c893be97f1a62b0ed4cf3ca5f96c"
Expand Down