@nomicfoundation/hardhat-ethers-chai-matchers 3.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +52 -0
  3. package/dist/src/index.d.ts +5 -0
  4. package/dist/src/index.d.ts.map +1 -0
  5. package/dist/src/index.js +16 -0
  6. package/dist/src/index.js.map +1 -0
  7. package/dist/src/internal/add-chai-matchers.d.ts +2 -0
  8. package/dist/src/internal/add-chai-matchers.d.ts.map +1 -0
  9. package/dist/src/internal/add-chai-matchers.js +41 -0
  10. package/dist/src/internal/add-chai-matchers.js.map +1 -0
  11. package/dist/src/internal/constants.d.ts +13 -0
  12. package/dist/src/internal/constants.d.ts.map +1 -0
  13. package/dist/src/internal/constants.js +13 -0
  14. package/dist/src/internal/constants.js.map +1 -0
  15. package/dist/src/internal/hook-handlers/network.d.ts +4 -0
  16. package/dist/src/internal/hook-handlers/network.d.ts.map +1 -0
  17. package/dist/src/internal/hook-handlers/network.js +15 -0
  18. package/dist/src/internal/hook-handlers/network.js.map +1 -0
  19. package/dist/src/internal/matchers/addressable.d.ts +2 -0
  20. package/dist/src/internal/matchers/addressable.d.ts.map +1 -0
  21. package/dist/src/internal/matchers/addressable.js +53 -0
  22. package/dist/src/internal/matchers/addressable.js.map +1 -0
  23. package/dist/src/internal/matchers/big-number.d.ts +2 -0
  24. package/dist/src/internal/matchers/big-number.d.ts.map +1 -0
  25. package/dist/src/internal/matchers/big-number.js +178 -0
  26. package/dist/src/internal/matchers/big-number.js.map +1 -0
  27. package/dist/src/internal/matchers/changeEtherBalance.d.ts +7 -0
  28. package/dist/src/internal/matchers/changeEtherBalance.d.ts.map +1 -0
  29. package/dist/src/internal/matchers/changeEtherBalance.js +77 -0
  30. package/dist/src/internal/matchers/changeEtherBalance.js.map +1 -0
  31. package/dist/src/internal/matchers/changeEtherBalances.d.ts +7 -0
  32. package/dist/src/internal/matchers/changeEtherBalances.d.ts.map +1 -0
  33. package/dist/src/internal/matchers/changeEtherBalances.js +96 -0
  34. package/dist/src/internal/matchers/changeEtherBalances.js.map +1 -0
  35. package/dist/src/internal/matchers/changeTokenBalance.d.ts +16 -0
  36. package/dist/src/internal/matchers/changeTokenBalance.d.ts.map +1 -0
  37. package/dist/src/internal/matchers/changeTokenBalance.js +148 -0
  38. package/dist/src/internal/matchers/changeTokenBalance.js.map +1 -0
  39. package/dist/src/internal/matchers/emit.d.ts +5 -0
  40. package/dist/src/internal/matchers/emit.d.ts.map +1 -0
  41. package/dist/src/internal/matchers/emit.js +122 -0
  42. package/dist/src/internal/matchers/emit.js.map +1 -0
  43. package/dist/src/internal/matchers/hexEqual.d.ts +2 -0
  44. package/dist/src/internal/matchers/hexEqual.d.ts.map +1 -0
  45. package/dist/src/internal/matchers/hexEqual.js +19 -0
  46. package/dist/src/internal/matchers/hexEqual.js.map +1 -0
  47. package/dist/src/internal/matchers/properAddress.d.ts +2 -0
  48. package/dist/src/internal/matchers/properAddress.d.ts.map +1 -0
  49. package/dist/src/internal/matchers/properAddress.js +7 -0
  50. package/dist/src/internal/matchers/properAddress.js.map +1 -0
  51. package/dist/src/internal/matchers/properHex.d.ts +2 -0
  52. package/dist/src/internal/matchers/properHex.d.ts.map +1 -0
  53. package/dist/src/internal/matchers/properHex.js +13 -0
  54. package/dist/src/internal/matchers/properHex.js.map +1 -0
  55. package/dist/src/internal/matchers/properPrivateKey.d.ts +2 -0
  56. package/dist/src/internal/matchers/properPrivateKey.d.ts.map +1 -0
  57. package/dist/src/internal/matchers/properPrivateKey.js +7 -0
  58. package/dist/src/internal/matchers/properPrivateKey.js.map +1 -0
  59. package/dist/src/internal/matchers/reverted/panic.d.ts +13 -0
  60. package/dist/src/internal/matchers/reverted/panic.d.ts.map +1 -0
  61. package/dist/src/internal/matchers/reverted/panic.js +36 -0
  62. package/dist/src/internal/matchers/reverted/panic.js.map +1 -0
  63. package/dist/src/internal/matchers/reverted/reverted.d.ts +2 -0
  64. package/dist/src/internal/matchers/reverted/reverted.d.ts.map +1 -0
  65. package/dist/src/internal/matchers/reverted/reverted.js +112 -0
  66. package/dist/src/internal/matchers/reverted/reverted.js.map +1 -0
  67. package/dist/src/internal/matchers/reverted/revertedWith.d.ts +2 -0
  68. package/dist/src/internal/matchers/reverted/revertedWith.d.ts.map +1 -0
  69. package/dist/src/internal/matchers/reverted/revertedWith.js +56 -0
  70. package/dist/src/internal/matchers/reverted/revertedWith.js.map +1 -0
  71. package/dist/src/internal/matchers/reverted/revertedWithCustomError.d.ts +5 -0
  72. package/dist/src/internal/matchers/reverted/revertedWithCustomError.d.ts.map +1 -0
  73. package/dist/src/internal/matchers/reverted/revertedWithCustomError.js +120 -0
  74. package/dist/src/internal/matchers/reverted/revertedWithCustomError.js.map +1 -0
  75. package/dist/src/internal/matchers/reverted/revertedWithPanic.d.ts +2 -0
  76. package/dist/src/internal/matchers/reverted/revertedWithPanic.d.ts.map +1 -0
  77. package/dist/src/internal/matchers/reverted/revertedWithPanic.js +74 -0
  78. package/dist/src/internal/matchers/reverted/revertedWithPanic.js.map +1 -0
  79. package/dist/src/internal/matchers/reverted/revertedWithoutReason.d.ts +2 -0
  80. package/dist/src/internal/matchers/reverted/revertedWithoutReason.d.ts.map +1 -0
  81. package/dist/src/internal/matchers/reverted/revertedWithoutReason.js +41 -0
  82. package/dist/src/internal/matchers/reverted/revertedWithoutReason.js.map +1 -0
  83. package/dist/src/internal/matchers/reverted/utils.d.ts +39 -0
  84. package/dist/src/internal/matchers/reverted/utils.d.ts.map +1 -0
  85. package/dist/src/internal/matchers/reverted/utils.js +108 -0
  86. package/dist/src/internal/matchers/reverted/utils.js.map +1 -0
  87. package/dist/src/internal/matchers/withArgs.d.ts +16 -0
  88. package/dist/src/internal/matchers/withArgs.d.ts.map +1 -0
  89. package/dist/src/internal/matchers/withArgs.js +88 -0
  90. package/dist/src/internal/matchers/withArgs.js.map +1 -0
  91. package/dist/src/internal/utils/account.d.ts +3 -0
  92. package/dist/src/internal/utils/account.d.ts.map +1 -0
  93. package/dist/src/internal/utils/account.js +15 -0
  94. package/dist/src/internal/utils/account.js.map +1 -0
  95. package/dist/src/internal/utils/asserts.d.ts +5 -0
  96. package/dist/src/internal/utils/asserts.d.ts.map +1 -0
  97. package/dist/src/internal/utils/asserts.js +73 -0
  98. package/dist/src/internal/utils/asserts.js.map +1 -0
  99. package/dist/src/internal/utils/balance.d.ts +8 -0
  100. package/dist/src/internal/utils/balance.d.ts.map +1 -0
  101. package/dist/src/internal/utils/balance.js +19 -0
  102. package/dist/src/internal/utils/balance.js.map +1 -0
  103. package/dist/src/internal/utils/bigint.d.ts +2 -0
  104. package/dist/src/internal/utils/bigint.d.ts.map +1 -0
  105. package/dist/src/internal/utils/bigint.js +4 -0
  106. package/dist/src/internal/utils/bigint.js.map +1 -0
  107. package/dist/src/internal/utils/build-assert.d.ts +19 -0
  108. package/dist/src/internal/utils/build-assert.d.ts.map +1 -0
  109. package/dist/src/internal/utils/build-assert.js +39 -0
  110. package/dist/src/internal/utils/build-assert.js.map +1 -0
  111. package/dist/src/internal/utils/ordinal.d.ts +8 -0
  112. package/dist/src/internal/utils/ordinal.d.ts.map +1 -0
  113. package/dist/src/internal/utils/ordinal.js +21 -0
  114. package/dist/src/internal/utils/ordinal.js.map +1 -0
  115. package/dist/src/internal/utils/prevent-chaining.d.ts +2 -0
  116. package/dist/src/internal/utils/prevent-chaining.d.ts.map +1 -0
  117. package/dist/src/internal/utils/prevent-chaining.js +17 -0
  118. package/dist/src/internal/utils/prevent-chaining.js.map +1 -0
  119. package/dist/src/internal/utils/ssfi.d.ts +4 -0
  120. package/dist/src/internal/utils/ssfi.d.ts.map +1 -0
  121. package/dist/src/internal/utils/ssfi.js +2 -0
  122. package/dist/src/internal/utils/ssfi.js.map +1 -0
  123. package/dist/src/internal/utils/typed.d.ts +2 -0
  124. package/dist/src/internal/utils/typed.d.ts.map +1 -0
  125. package/dist/src/internal/utils/typed.js +10 -0
  126. package/dist/src/internal/utils/typed.js.map +1 -0
  127. package/dist/src/panic.d.ts +2 -0
  128. package/dist/src/panic.d.ts.map +1 -0
  129. package/dist/src/panic.js +2 -0
  130. package/dist/src/panic.js.map +1 -0
  131. package/dist/src/type-extensions.d.ts +45 -0
  132. package/dist/src/type-extensions.d.ts.map +1 -0
  133. package/dist/src/type-extensions.js +2 -0
  134. package/dist/src/type-extensions.js.map +1 -0
  135. package/dist/src/withArgs.d.ts +2 -0
  136. package/dist/src/withArgs.d.ts.map +1 -0
  137. package/dist/src/withArgs.js +2 -0
  138. package/dist/src/withArgs.js.map +1 -0
  139. package/package.json +85 -0
  140. package/src/index.ts +21 -0
  141. package/src/internal/add-chai-matchers.ts +46 -0
  142. package/src/internal/constants.ts +13 -0
  143. package/src/internal/hook-handlers/network.ts +24 -0
  144. package/src/internal/matchers/addressable.ts +86 -0
  145. package/src/internal/matchers/big-number.ts +279 -0
  146. package/src/internal/matchers/changeEtherBalance.ts +138 -0
  147. package/src/internal/matchers/changeEtherBalances.ts +188 -0
  148. package/src/internal/matchers/changeTokenBalance.ts +295 -0
  149. package/src/internal/matchers/emit.ts +232 -0
  150. package/src/internal/matchers/hexEqual.ts +29 -0
  151. package/src/internal/matchers/properAddress.ts +12 -0
  152. package/src/internal/matchers/properHex.ts +29 -0
  153. package/src/internal/matchers/properPrivateKey.ts +12 -0
  154. package/src/internal/matchers/reverted/panic.ts +36 -0
  155. package/src/internal/matchers/reverted/reverted.ts +165 -0
  156. package/src/internal/matchers/reverted/revertedWith.ts +100 -0
  157. package/src/internal/matchers/reverted/revertedWithCustomError.ts +243 -0
  158. package/src/internal/matchers/reverted/revertedWithPanic.ts +118 -0
  159. package/src/internal/matchers/reverted/revertedWithoutReason.ts +73 -0
  160. package/src/internal/matchers/reverted/utils.ts +147 -0
  161. package/src/internal/matchers/withArgs.ts +139 -0
  162. package/src/internal/utils/account.ts +24 -0
  163. package/src/internal/utils/asserts.ts +156 -0
  164. package/src/internal/utils/balance.ts +39 -0
  165. package/src/internal/utils/bigint.ts +3 -0
  166. package/src/internal/utils/build-assert.ts +54 -0
  167. package/src/internal/utils/ordinal.ts +24 -0
  168. package/src/internal/utils/prevent-chaining.ts +33 -0
  169. package/src/internal/utils/ssfi.ts +6 -0
  170. package/src/internal/utils/typed.ts +9 -0
  171. package/src/panic.ts +1 -0
  172. package/src/type-extensions.ts +82 -0
  173. package/src/withArgs.ts +1 -0
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Nomic Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Hardhat Ethers Chai Matchers plugin
2
+
3
+ This plugin adds Ethereum-specific matchers to the [Chai](https://chaijs.com/) assertion library that integrate with [ethers.js](https://ethers.org/), making your smart contract tests easy to write and read.
4
+
5
+ ## Installation
6
+
7
+ To install this plugin, run the following command:
8
+
9
+ ```bash
10
+ npm install --save-dev @nomicfoundation/hardhat-ethers-chai-matchers@next
11
+ ```
12
+
13
+ and add the following statements to your `hardhat.config.ts` file:
14
+
15
+ ```typescript
16
+ // ...
17
+ import ethersChaiMatchersPlugin from "@nomicfoundation/hardhat-ethers-chai-matchers";
18
+
19
+ // ...
20
+
21
+ export default {
22
+ // ...
23
+ plugins: [
24
+ // ...
25
+ ethersChaiMatchersPlugin,
26
+ ],
27
+
28
+ // ...
29
+ };
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ You don't need to do anything else to use this plugin. Whenever you run your tests with Hardhat, it will automatically add the matchers.
35
+
36
+ Here is an example of using the `changeEtherBalances` matcher:
37
+
38
+ ```ts
39
+ import { expect } from "chai";
40
+
41
+ // ...
42
+ // ...
43
+
44
+ const amount = ethers.utils.parseEther("1");
45
+
46
+ await expect(() =>
47
+ sender.sendTransaction({
48
+ to: contract,
49
+ value: AMOUNT,
50
+ }),
51
+ ).to.changeEtherBalances(provider, [sender, contract], [-AMOUNT, AMOUNT]);
52
+ ```
@@ -0,0 +1,5 @@
1
+ import type { HardhatPlugin } from "hardhat/types/plugins";
2
+ import "./type-extensions.js";
3
+ declare const hardhatChaiMatchersPlugin: HardhatPlugin;
4
+ export default hardhatChaiMatchersPlugin;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,sBAAsB,CAAC;AAE9B,QAAA,MAAM,yBAAyB,EAAE,aAchC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import "./type-extensions.js";
2
+ const hardhatChaiMatchersPlugin = {
3
+ id: "hardhat-ethers-chai-matchers",
4
+ hookHandlers: {
5
+ network: import.meta.resolve("./internal/hook-handlers/network.js"),
6
+ },
7
+ npmPackage: "@nomicfoundation/hardhat-ethers-chai-matchers",
8
+ dependencies: [
9
+ async () => {
10
+ const { default: hardhatEthersPlugin } = await import("@nomicfoundation/hardhat-ethers");
11
+ return hardhatEthersPlugin;
12
+ },
13
+ ],
14
+ };
15
+ export default hardhatChaiMatchersPlugin;
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAE9B,MAAM,yBAAyB,GAAkB;IAC/C,EAAE,EAAE,8BAA8B;IAClC,YAAY,EAAE;QACZ,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,qCAAqC,CAAC;KACpE;IACD,UAAU,EAAE,+CAA+C;IAC3D,YAAY,EAAE;QACZ,KAAK,IAAI,EAAE;YACT,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM,CACnD,iCAAiC,CAClC,CAAC;YACF,OAAO,mBAAmB,CAAC;QAC7B,CAAC;KACF;CACF,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function addChaiMatchers(): void;
2
+ //# sourceMappingURL=add-chai-matchers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-chai-matchers.d.ts","sourceRoot":"","sources":["../../../src/internal/add-chai-matchers.ts"],"names":[],"mappings":"AAoBA,wBAAgB,eAAe,IAAI,IAAI,CAGtC"}
@@ -0,0 +1,41 @@
1
+ import { use } from "chai";
2
+ import chaiAsPromised from "chai-as-promised";
3
+ import { supportAddressable } from "./matchers/addressable.js";
4
+ import { supportBigNumber } from "./matchers/big-number.js";
5
+ import { supportChangeEtherBalance } from "./matchers/changeEtherBalance.js";
6
+ import { supportChangeEtherBalances } from "./matchers/changeEtherBalances.js";
7
+ import { supportChangeTokenBalance } from "./matchers/changeTokenBalance.js";
8
+ import { supportEmit } from "./matchers/emit.js";
9
+ import { supportHexEqual } from "./matchers/hexEqual.js";
10
+ import { supportProperAddress } from "./matchers/properAddress.js";
11
+ import { supportProperHex } from "./matchers/properHex.js";
12
+ import { supportProperPrivateKey } from "./matchers/properPrivateKey.js";
13
+ import { supportReverted } from "./matchers/reverted/reverted.js";
14
+ import { supportRevertedWith } from "./matchers/reverted/revertedWith.js";
15
+ import { supportRevertedWithCustomError } from "./matchers/reverted/revertedWithCustomError.js";
16
+ import { supportRevertedWithPanic } from "./matchers/reverted/revertedWithPanic.js";
17
+ import { supportRevertedWithoutReason } from "./matchers/reverted/revertedWithoutReason.js";
18
+ import { supportWithArgs } from "./matchers/withArgs.js";
19
+ export function addChaiMatchers() {
20
+ use(hardhatChaiMatchers);
21
+ use(chaiAsPromised);
22
+ }
23
+ function hardhatChaiMatchers(chai, chaiUtils) {
24
+ supportAddressable(chai.Assertion, chaiUtils);
25
+ supportBigNumber(chai.Assertion, chaiUtils);
26
+ supportEmit(chai.Assertion, chaiUtils);
27
+ supportHexEqual(chai.Assertion);
28
+ supportProperAddress(chai.Assertion);
29
+ supportProperHex(chai.Assertion);
30
+ supportProperPrivateKey(chai.Assertion);
31
+ supportChangeEtherBalance(chai.Assertion, chaiUtils);
32
+ supportChangeEtherBalances(chai.Assertion, chaiUtils);
33
+ supportChangeTokenBalance(chai.Assertion, chaiUtils);
34
+ supportReverted(chai.Assertion, chaiUtils);
35
+ supportRevertedWith(chai.Assertion, chaiUtils);
36
+ supportRevertedWithCustomError(chai.Assertion, chaiUtils);
37
+ supportRevertedWithPanic(chai.Assertion, chaiUtils);
38
+ supportRevertedWithoutReason(chai.Assertion, chaiUtils);
39
+ supportWithArgs(chai.Assertion, chaiUtils);
40
+ }
41
+ //# sourceMappingURL=add-chai-matchers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-chai-matchers.js","sourceRoot":"","sources":["../../../src/internal/add-chai-matchers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2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AAC,SAAS,CAAC,CAAC;IACrC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,yBAAyB,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACrD,0BAA0B,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACtD,yBAAyB,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACrD,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC3C,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/C,8BAA8B,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC1D,wBAAwB,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACpD,4BAA4B,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACxD,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare const ASSERTION_ABORTED = "hh-ethers-chai-matchers-assertion-aborted";
2
+ export declare const PREVIOUS_MATCHER_NAME = "previousMatcherName";
3
+ export declare const CHANGE_ETHER_BALANCE_MATCHER = "changeEtherBalance";
4
+ export declare const CHANGE_ETHER_BALANCES_MATCHER = "changeEtherBalances";
5
+ export declare const CHANGE_TOKEN_BALANCE_MATCHER = "changeTokenBalance";
6
+ export declare const CHANGE_TOKEN_BALANCES_MATCHER = "changeTokenBalances";
7
+ export declare const EMIT_MATCHER = "emit";
8
+ export declare const REVERTED_MATCHER = "reverted";
9
+ export declare const REVERTED_WITH_MATCHER = "revertedWith";
10
+ export declare const REVERTED_WITH_CUSTOM_ERROR_MATCHER = "revertedWithCustomError";
11
+ export declare const REVERTED_WITH_PANIC_MATCHER = "revertedWithPanic";
12
+ export declare const REVERTED_WITHOUT_REASON_MATCHER = "revertedWithoutReason";
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/internal/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,8CAA8C,CAAC;AAC7E,eAAO,MAAM,qBAAqB,wBAAwB,CAAC;AAE3D,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AACjE,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;AACnE,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AACjE,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;AACnE,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAC3C,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AACpD,eAAO,MAAM,kCAAkC,4BAA4B,CAAC;AAC5E,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAC/D,eAAO,MAAM,+BAA+B,0BAA0B,CAAC"}
@@ -0,0 +1,13 @@
1
+ export const ASSERTION_ABORTED = "hh-ethers-chai-matchers-assertion-aborted";
2
+ export const PREVIOUS_MATCHER_NAME = "previousMatcherName";
3
+ export const CHANGE_ETHER_BALANCE_MATCHER = "changeEtherBalance";
4
+ export const CHANGE_ETHER_BALANCES_MATCHER = "changeEtherBalances";
5
+ export const CHANGE_TOKEN_BALANCE_MATCHER = "changeTokenBalance";
6
+ export const CHANGE_TOKEN_BALANCES_MATCHER = "changeTokenBalances";
7
+ export const EMIT_MATCHER = "emit";
8
+ export const REVERTED_MATCHER = "reverted";
9
+ export const REVERTED_WITH_MATCHER = "revertedWith";
10
+ export const REVERTED_WITH_CUSTOM_ERROR_MATCHER = "revertedWithCustomError";
11
+ export const REVERTED_WITH_PANIC_MATCHER = "revertedWithPanic";
12
+ export const REVERTED_WITHOUT_REASON_MATCHER = "revertedWithoutReason";
13
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/internal/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,2CAA2C,CAAC;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAE3D,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AACjE,MAAM,CAAC,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AACnE,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AACjE,MAAM,CAAC,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AACnE,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAC3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,MAAM,CAAC,MAAM,kCAAkC,GAAG,yBAAyB,CAAC;AAC5E,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAC/D,MAAM,CAAC,MAAM,+BAA+B,GAAG,uBAAuB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { NetworkHooks } from "hardhat/types/hooks";
2
+ declare const _default: () => Promise<Partial<NetworkHooks>>;
3
+ export default _default;
4
+ //# sourceMappingURL=network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../../src/internal/hook-handlers/network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;8BAO5C,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAAvD,wBAgBE"}
@@ -0,0 +1,15 @@
1
+ import { addChaiMatchers } from "../add-chai-matchers.js";
2
+ let isInitialized = false;
3
+ export default async () => {
4
+ const handlers = {
5
+ async newConnection(context, next) {
6
+ if (!isInitialized) {
7
+ addChaiMatchers();
8
+ isInitialized = true;
9
+ }
10
+ return next(context);
11
+ },
12
+ };
13
+ return handlers;
14
+ };
15
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../../../src/internal/hook-handlers/network.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B,eAAe,KAAK,IAAoC,EAAE;IACxD,MAAM,QAAQ,GAA0B;QACtC,KAAK,CAAC,aAAa,CACjB,OAAoB,EACpB,IAAsE;YAEtE,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,eAAe,EAAE,CAAC;gBAClB,aAAa,GAAG,IAAI,CAAC;YACvB,CAAC;YAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function supportAddressable(Assertion: Chai.AssertionStatic, chaiUtils: Chai.ChaiUtils): void;
2
+ //# sourceMappingURL=addressable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addressable.d.ts","sourceRoot":"","sources":["../../../../src/internal/matchers/addressable.ts"],"names":[],"mappings":"AAKA,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,IAAI,CAAC,eAAe,EAC/B,SAAS,EAAE,IAAI,CAAC,SAAS,GACxB,IAAI,CAKN"}
@@ -0,0 +1,53 @@
1
+ import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
2
+ import { isAddress, isAddressable } from "ethers";
3
+ import { tryDereference } from "../utils/typed.js";
4
+ export function supportAddressable(Assertion, chaiUtils) {
5
+ const equalsFunction = override("eq", "equal", "not equal", chaiUtils);
6
+ Assertion.overwriteMethod("equals", equalsFunction);
7
+ Assertion.overwriteMethod("equal", equalsFunction);
8
+ Assertion.overwriteMethod("eq", equalsFunction);
9
+ }
10
+ function override(method, name, negativeName, chaiUtils) {
11
+ return (_super) => overwriteAddressableFunction(method, name, negativeName, _super, chaiUtils);
12
+ }
13
+ // ethers's Addressable have a .getAddress() that returns a Promise<string>. We don't want to deal with async here,
14
+ // so we are looking for a sync way of getting the address. If an address was recovered, it is returned as a string,
15
+ // otherwise undefined is returned.
16
+ function tryGetAddressSync(value) {
17
+ value = tryDereference(value, "address");
18
+ if (isAddressable(value)) {
19
+ if ("address" in value) {
20
+ value = value.address;
21
+ }
22
+ else {
23
+ assertHardhatInvariant("target" in value, "target property should exist in value");
24
+ value = value.target;
25
+ }
26
+ }
27
+ if (isAddress(value)) {
28
+ return value;
29
+ }
30
+ else {
31
+ return undefined;
32
+ }
33
+ }
34
+ function overwriteAddressableFunction(functionName, readableName, readableNegativeName, _super, chaiUtils) {
35
+ return function (...args) {
36
+ const [actualArg, message] = args;
37
+ const expectedFlag = chaiUtils.flag(this, "object");
38
+ if (message !== undefined) {
39
+ chaiUtils.flag(this, "message", message);
40
+ }
41
+ const actual = tryGetAddressSync(actualArg);
42
+ const expected = tryGetAddressSync(expectedFlag);
43
+ if (functionName === "eq" &&
44
+ expected !== undefined &&
45
+ actual !== undefined) {
46
+ this.assert(expected === actual, `expected '${expected}' to ${readableName} '${actual}'.`, `expected '${expected}' to ${readableNegativeName} '${actual}'.`, actual.toString(), expected.toString());
47
+ }
48
+ else {
49
+ _super.apply(this, args);
50
+ }
51
+ };
52
+ }
53
+ //# sourceMappingURL=addressable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addressable.js","sourceRoot":"","sources":["../../../../src/internal/matchers/addressable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,UAAU,kBAAkB,CAChC,SAA+B,EAC/B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I,CAAC;QAClC,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;QACjD,IACE,YAAY,KAAK,IAAI;YACrB,QAAQ,KAAK,SAAS;YACtB,MAAM,KAAK,SAAS,EACpB,CAAC;YACD,IAAI,CAAC,MAAM,CACT,QAAQ,KAAK,MAAM,EACnB,aAAa,QAAQ,QAAQ,YAAY,KAAK,MAAM,IAAI,EACxD,aAAa,QAAQ,QAAQ,oBAAoB,KAAK,MAAM,IAAI,EAChE,MAAM,CAAC,QAAQ,EAAE,EACjB,QAAQ,CAAC,QAAQ,EAAE,CACpB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function supportBigNumber(Assertion: Chai.AssertionStatic, chaiUtils: Chai.ChaiUtils): void;
2
+ //# sourceMappingURL=big-number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"big-number.d.ts","sourceRoot":"","sources":["../../../../src/internal/matchers/big-number.ts"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,IAAI,CAAC,eAAe,EAC/B,SAAS,EAAE,IAAI,CAAC,SAAS,GACxB,IAAI,CAiCN"}
@@ -0,0 +1,178 @@
1
+ import util from "node:util";
2
+ import { HardhatError } from "@nomicfoundation/hardhat-errors";
3
+ import { toBigInt } from "@nomicfoundation/hardhat-utils/bigint";
4
+ import { AssertionError } from "chai";
5
+ import deepEqual from "deep-eql";
6
+ import { isBigInt } from "../utils/bigint.js";
7
+ export function supportBigNumber(Assertion, chaiUtils) {
8
+ const equalsFunction = override("eq", "equal", "not equal", chaiUtils);
9
+ Assertion.overwriteMethod("equals", equalsFunction);
10
+ Assertion.overwriteMethod("equal", equalsFunction);
11
+ Assertion.overwriteMethod("eq", equalsFunction);
12
+ const gtFunction = override("gt", "be above", "be at most", chaiUtils);
13
+ Assertion.overwriteMethod("above", gtFunction);
14
+ Assertion.overwriteMethod("gt", gtFunction);
15
+ Assertion.overwriteMethod("greaterThan", gtFunction);
16
+ const ltFunction = override("lt", "be below", "be at least", chaiUtils);
17
+ Assertion.overwriteMethod("below", ltFunction);
18
+ Assertion.overwriteMethod("lt", ltFunction);
19
+ Assertion.overwriteMethod("lessThan", ltFunction);
20
+ const gteFunction = override("gte", "be at least", "be below", chaiUtils);
21
+ Assertion.overwriteMethod("least", gteFunction);
22
+ Assertion.overwriteMethod("gte", gteFunction);
23
+ Assertion.overwriteMethod("greaterThanOrEqual", gteFunction);
24
+ const lteFunction = override("lte", "be at most", "be above", chaiUtils);
25
+ Assertion.overwriteMethod("most", lteFunction);
26
+ Assertion.overwriteMethod("lte", lteFunction);
27
+ Assertion.overwriteMethod("lessThanOrEqual", lteFunction);
28
+ Assertion.overwriteChainableMethod(...createLengthOverride("length"));
29
+ Assertion.overwriteChainableMethod(...createLengthOverride("lengthOf"));
30
+ Assertion.overwriteMethod("within", overrideWithin(chaiUtils));
31
+ Assertion.overwriteMethod("closeTo", overrideCloseTo(chaiUtils));
32
+ Assertion.overwriteMethod("approximately", overrideCloseTo(chaiUtils));
33
+ }
34
+ function createLengthOverride(method) {
35
+ return [
36
+ method,
37
+ function (_super) {
38
+ return function (value) {
39
+ const actual = this._obj;
40
+ if (isBigInt(value)) {
41
+ const sizeOrLength = actual instanceof Map || actual instanceof Set ? "size" : "length";
42
+ const actualLength = toBigInt(actual[sizeOrLength]);
43
+ const expectedLength = toBigInt(value);
44
+ this.assert(actualLength === expectedLength, `expected #{this} to have a ${sizeOrLength} of ${expectedLength.toString()} but got ${actualLength.toString()}`, `expected #{this} not to have a ${sizeOrLength} of ${expectedLength.toString()} but got ${actualLength.toString()}`, actualLength.toString(), expectedLength.toString());
45
+ }
46
+ else {
47
+ _super.apply(this, arguments);
48
+ }
49
+ };
50
+ },
51
+ function (_super) {
52
+ return function () {
53
+ _super.apply(this, arguments);
54
+ };
55
+ },
56
+ ];
57
+ }
58
+ function override(method, name, negativeName, chaiUtils) {
59
+ return (_super) => overwriteBigNumberFunction(method, name, negativeName, _super, chaiUtils);
60
+ }
61
+ function overwriteBigNumberFunction(functionName, readableName, readableNegativeName, _super, chaiUtils) {
62
+ return function (...args) {
63
+ const [actualArg, message] = args;
64
+ const expectedFlag = chaiUtils.flag(this, "object");
65
+ if (message !== undefined) {
66
+ chaiUtils.flag(this, "message", message);
67
+ }
68
+ function compare(method, lhs, rhs) {
69
+ if (method === "eq") {
70
+ return lhs === rhs;
71
+ }
72
+ else if (method === "gt") {
73
+ return lhs > rhs;
74
+ }
75
+ else if (method === "lt") {
76
+ return lhs < rhs;
77
+ }
78
+ else if (method === "gte") {
79
+ return lhs >= rhs;
80
+ }
81
+ else if (method === "lte") {
82
+ return lhs <= rhs;
83
+ }
84
+ else {
85
+ throw new HardhatError(HardhatError.ERRORS.CHAI_MATCHERS.UNKNOWN_COMPARISON_OPERATION, {
86
+ method,
87
+ });
88
+ }
89
+ }
90
+ if (Boolean(chaiUtils.flag(this, "doLength")) && isBigInt(actualArg)) {
91
+ const sizeOrLength = expectedFlag instanceof Map || expectedFlag instanceof Set
92
+ ? "size"
93
+ : "length";
94
+ if (expectedFlag[sizeOrLength] === undefined) {
95
+ _super.apply(this, args);
96
+ return;
97
+ }
98
+ const expected = toBigInt(expectedFlag[sizeOrLength]);
99
+ const actual = toBigInt(actualArg);
100
+ this.assert(compare(functionName, expected, actual), `expected #{this} to have a ${sizeOrLength} ${readableName.replace("be ", "")} ${actual.toString()} but got ${expected}`, `expected #{this} to have a ${sizeOrLength} ${readableNegativeName} ${actual.toString()}`, expected, actual);
101
+ }
102
+ else if (functionName === "eq" && Boolean(chaiUtils.flag(this, "deep"))) {
103
+ // "ssfi" stands for "start stack function indicator", it's a chai concept
104
+ // used to control which frames are included in the stack trace
105
+ // this pattern here was taken from chai's implementation of .deep.equal
106
+ const prevLockSsfi = chaiUtils.flag(this, "lockSsfi");
107
+ chaiUtils.flag(this, "lockSsfi", true);
108
+ this.assert(deepEqual(actualArg, expectedFlag, { comparator: deepEqualComparator }), `expected ${util.inspect(expectedFlag)} to deeply equal ${util.inspect(actualArg)}`, `expected ${util.inspect(expectedFlag)} to not deeply equal ${util.inspect(actualArg)}`, null);
109
+ chaiUtils.flag(this, "lockSsfi", prevLockSsfi);
110
+ }
111
+ else if (isBigInt(expectedFlag) || isBigInt(actualArg)) {
112
+ const expected = toBigInt(expectedFlag);
113
+ const actual = toBigInt(actualArg);
114
+ this.assert(compare(functionName, expected, actual), `expected ${expected} to ${readableName} ${actual}.`, `expected ${expected} to ${readableNegativeName} ${actual}.`, actual.toString(), expected.toString());
115
+ }
116
+ else {
117
+ _super.apply(this, args);
118
+ }
119
+ };
120
+ }
121
+ function overrideWithin(chaiUtils) {
122
+ return (_super) => overwriteBigNumberWithin(_super, chaiUtils);
123
+ }
124
+ function overwriteBigNumberWithin(_super, chaiUtils) {
125
+ return function (...args) {
126
+ const [startArg, finishArg] = args;
127
+ const expectedFlag = chaiUtils.flag(this, "object");
128
+ if (isBigInt(expectedFlag) || isBigInt(startArg) || isBigInt(finishArg)) {
129
+ const expected = toBigInt(expectedFlag);
130
+ const start = toBigInt(startArg);
131
+ const finish = toBigInt(finishArg);
132
+ this.assert(start <= expected && expected <= finish, `expected ${expected} to be within ${start}..${finish}`, `expected ${expected} to not be within ${start}..${finish}`, expected, [start, finish]);
133
+ }
134
+ else {
135
+ _super.apply(this, args);
136
+ }
137
+ };
138
+ }
139
+ function overrideCloseTo(chaiUtils) {
140
+ return (_super) => overwriteBigNumberCloseTo(_super, chaiUtils);
141
+ }
142
+ function overwriteBigNumberCloseTo(_super, chaiUtils) {
143
+ return function (...args) {
144
+ const [actualArg, deltaArg] = args;
145
+ const expectedFlag = chaiUtils.flag(this, "object");
146
+ if (isBigInt(expectedFlag) ||
147
+ isBigInt(actualArg) ||
148
+ isBigInt(deltaArg) ||
149
+ typeof actualArg === "number") {
150
+ if (deltaArg === undefined) {
151
+ // eslint-disable-next-line no-restricted-syntax -- keep the original chai error structure
152
+ throw new AssertionError("the arguments to closeTo or approximately must be numbers, and a delta is required");
153
+ }
154
+ const expected = toBigInt(expectedFlag);
155
+ const actual = toBigInt(actualArg);
156
+ const delta = toBigInt(deltaArg);
157
+ function abs(i) {
158
+ return i < 0 ? BigInt(-1) * i : i;
159
+ }
160
+ this.assert(abs(expected - actual) <= delta, `expected ${expected} to be close to ${actual} +/- ${delta}`, `expected ${expected} not to be close to ${actual} +/- ${delta}`, expected, `A number between ${actual - delta} and ${actual + delta}`);
161
+ }
162
+ else {
163
+ _super.apply(this, args);
164
+ }
165
+ };
166
+ }
167
+ function deepEqualComparator(a, b) {
168
+ try {
169
+ const normalizedA = toBigInt(a);
170
+ const normalizedB = toBigInt(b);
171
+ return normalizedA === normalizedB;
172
+ }
173
+ catch (e) {
174
+ // use default comparator
175
+ return null;
176
+ }
177
+ }
178
+ //# sourceMappingURL=big-number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"big-number.js","sourceRoot":"","sources":["../../../../src/internal/matchers/big-number.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,SAAS,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,Q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CAAC,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,CAAM,EAAE,CAAM;IACzC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO,WAAW,KAAK,WAAW,CAAC;IACrC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,yBAAyB;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { BalanceChangeOptions } from "../utils/balance.js";
2
+ import type { Addressable } from "ethers/address";
3
+ import type { TransactionResponse } from "ethers/providers";
4
+ import type { EthereumProvider } from "hardhat/types/providers";
5
+ export declare function supportChangeEtherBalance(Assertion: Chai.AssertionStatic, chaiUtils: Chai.ChaiUtils): void;
6
+ export declare function getBalanceChange(provider: EthereumProvider, transaction: TransactionResponse | Promise<TransactionResponse> | (() => Promise<TransactionResponse> | TransactionResponse), account: Addressable | string, options?: BalanceChangeOptions): Promise<bigint>;
7
+ //# sourceMappingURL=changeEtherBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changeEtherBalance.d.ts","sourceRoot":"","sources":["../../../../src/internal/matchers/changeEtherBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgBhE,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,IAAI,CAAC,eAAe,EAC/B,SAAS,EAAE,IAAI,CAAC,SAAS,GACxB,IAAI,CAoDN;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,gBAAgB,EAC1B,WAAW,EACP,mBAAmB,GACnB,OAAO,CAAC,mBAAmB,CAAC,GAC5B,CAAC,MAAM,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC,EAC9D,OAAO,EAAE,WAAW,GAAG,MAAM,EAC7B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAoDjB"}
@@ -0,0 +1,77 @@
1
+ import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
2
+ import { numberToHexString } from "@nomicfoundation/hardhat-utils/hex";
3
+ import { isObject } from "@nomicfoundation/hardhat-utils/lang";
4
+ import { toBigInt } from "ethers/utils";
5
+ import { CHANGE_ETHER_BALANCE_MATCHER } from "../constants.js";
6
+ import { getAddressOf } from "../utils/account.js";
7
+ import { assertCanBeConvertedToBigint, assertIsNotNull, } from "../utils/asserts.js";
8
+ import { buildAssert } from "../utils/build-assert.js";
9
+ import { preventAsyncMatcherChaining } from "../utils/prevent-chaining.js";
10
+ export function supportChangeEtherBalance(Assertion, chaiUtils) {
11
+ Assertion.addMethod(CHANGE_ETHER_BALANCE_MATCHER, function (provider, account, balanceChange, options) {
12
+ // capture negated flag before async code executes; see buildAssert's jsdoc
13
+ const negated = this.__flags.negate;
14
+ const subject = this._obj;
15
+ preventAsyncMatcherChaining(this, CHANGE_ETHER_BALANCE_MATCHER, chaiUtils);
16
+ const checkBalanceChange = ([actualChange, address]) => {
17
+ const assert = buildAssert(negated, checkBalanceChange);
18
+ if (typeof balanceChange === "function") {
19
+ assert(balanceChange(actualChange), `Expected the ether balance change of "${address}" to satisfy the predicate, but it didn't (balance change: ${actualChange.toString()} wei)`, `Expected the ether balance change of "${address}" to NOT satisfy the predicate, but it did (balance change: ${actualChange.toString()} wei)`);
20
+ }
21
+ else {
22
+ const expectedChange = toBigInt(balanceChange);
23
+ assert(actualChange === expectedChange, `Expected the ether balance of "${address}" to change by ${balanceChange.toString()} wei, but it changed by ${actualChange.toString()} wei`, `Expected the ether balance of "${address}" NOT to change by ${balanceChange.toString()} wei, but it did`);
24
+ }
25
+ };
26
+ const derivedPromise = Promise.all([
27
+ getBalanceChange(provider, subject, account, options),
28
+ getAddressOf(account),
29
+ ]).then(checkBalanceChange);
30
+ this.then = derivedPromise.then.bind(derivedPromise);
31
+ this.catch = derivedPromise.catch.bind(derivedPromise);
32
+ this.promise = derivedPromise;
33
+ return this;
34
+ });
35
+ }
36
+ export async function getBalanceChange(provider, transaction, account, options) {
37
+ let txResponse;
38
+ if (typeof transaction === "function") {
39
+ txResponse = await transaction();
40
+ }
41
+ else {
42
+ txResponse = await transaction;
43
+ }
44
+ const txReceipt = await txResponse.wait();
45
+ assertIsNotNull(txReceipt, "txReceipt");
46
+ const txBlockNumber = txReceipt.blockNumber;
47
+ const block = await provider.request({
48
+ method: "eth_getBlockByHash",
49
+ params: [txReceipt.blockHash, false],
50
+ });
51
+ assertHardhatInvariant(isObject(block) &&
52
+ Array.isArray(block.transactions) &&
53
+ block.transactions.length === 1, "There should be only 1 transaction in the block");
54
+ const address = await getAddressOf(account);
55
+ const balanceAfterHex = await provider.request({
56
+ method: "eth_getBalance",
57
+ params: [address, numberToHexString(txBlockNumber)],
58
+ });
59
+ const balanceBeforeHex = await provider.request({
60
+ method: "eth_getBalance",
61
+ params: [address, numberToHexString(txBlockNumber - 1)],
62
+ });
63
+ assertCanBeConvertedToBigint(balanceAfterHex);
64
+ assertCanBeConvertedToBigint(balanceBeforeHex);
65
+ const balanceAfter = BigInt(balanceAfterHex);
66
+ const balanceBefore = BigInt(balanceBeforeHex);
67
+ if (options?.includeFee !== true && address === txResponse.from) {
68
+ const gasPrice = txReceipt.gasPrice;
69
+ const gasUsed = txReceipt.gasUsed;
70
+ const txFee = gasPrice * gasUsed;
71
+ return balanceAfter + txFee - balanceBefore;
72
+ }
73
+ else {
74
+ return balanceAfter - balanceBefore;
75
+ }
76
+ }
77
+ //# sourceMappingURL=changeEtherBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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jC,OAAO,YAAY,GAAG,KAAK,GAAG,aAAa,CAAC;IAC9C,CAAC;SAAM,CAAC;QACN,OAAO,YAAY,GAAG,aAAa,CAAC;IACtC,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { BalanceChangeOptions } from "../utils/balance.js";
2
+ import type { Addressable } from "ethers/address";
3
+ import type { TransactionResponse } from "ethers/providers";
4
+ import type { EthereumProvider } from "hardhat/types/providers";
5
+ export declare function supportChangeEtherBalances(Assertion: Chai.AssertionStatic, chaiUtils: Chai.ChaiUtils): void;
6
+ export declare function getBalanceChanges(provider: EthereumProvider, transaction: TransactionResponse | Promise<TransactionResponse>, accounts: Array<Addressable | string>, options?: BalanceChangeOptions): Promise<bigint[]>;
7
+ //# sourceMappingURL=changeEtherBalances.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changeEtherBalances.d.ts","sourceRoot":"","sources":["../../../../src/internal/matchers/changeEtherBalances.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAahE,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,IAAI,CAAC,eAAe,EAC/B,SAAS,EAAE,IAAI,CAAC,SAAS,GACxB,IAAI,CA2FN;AA4BD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,gBAAgB,EAC1B,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,EAC/D,QAAQ,EAAE,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,EACrC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,MAAM,EAAE,CAAC,CAmBnB"}