viem 2.7.2 → 2.7.3

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 (66) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/_cjs/actions/public/call.js +69 -6
  3. package/_cjs/actions/public/call.js.map +1 -1
  4. package/_cjs/actions/public/multicall.js +2 -1
  5. package/_cjs/actions/public/multicall.js.map +1 -1
  6. package/_cjs/errors/contract.js +6 -2
  7. package/_cjs/errors/contract.js.map +1 -1
  8. package/_cjs/errors/data.js +15 -1
  9. package/_cjs/errors/data.js.map +1 -1
  10. package/_cjs/errors/stateOverride.js +58 -0
  11. package/_cjs/errors/stateOverride.js.map +1 -0
  12. package/_cjs/errors/version.js +1 -1
  13. package/_cjs/index.js +7 -4
  14. package/_cjs/index.js.map +1 -1
  15. package/_cjs/types/eip1193.js.map +1 -1
  16. package/_cjs/types/stateOverride.js +3 -0
  17. package/_cjs/types/stateOverride.js.map +1 -0
  18. package/_esm/actions/public/call.js +65 -5
  19. package/_esm/actions/public/call.js.map +1 -1
  20. package/_esm/actions/public/multicall.js +2 -1
  21. package/_esm/actions/public/multicall.js.map +1 -1
  22. package/_esm/errors/contract.js +6 -2
  23. package/_esm/errors/contract.js.map +1 -1
  24. package/_esm/errors/data.js +13 -0
  25. package/_esm/errors/data.js.map +1 -1
  26. package/_esm/errors/stateOverride.js +51 -0
  27. package/_esm/errors/stateOverride.js.map +1 -0
  28. package/_esm/errors/version.js +1 -1
  29. package/_esm/index.js +1 -0
  30. package/_esm/index.js.map +1 -1
  31. package/_esm/types/eip1193.js.map +1 -1
  32. package/_esm/types/stateOverride.js +2 -0
  33. package/_esm/types/stateOverride.js.map +1 -0
  34. package/_types/actions/public/call.d.ts +15 -2
  35. package/_types/actions/public/call.d.ts.map +1 -1
  36. package/_types/actions/public/multicall.d.ts +1 -1
  37. package/_types/actions/public/multicall.d.ts.map +1 -1
  38. package/_types/actions/public/readContract.d.ts +1 -1
  39. package/_types/actions/public/readContract.d.ts.map +1 -1
  40. package/_types/errors/contract.d.ts +1 -1
  41. package/_types/errors/contract.d.ts.map +1 -1
  42. package/_types/errors/data.d.ts +11 -0
  43. package/_types/errors/data.d.ts.map +1 -1
  44. package/_types/errors/stateOverride.d.ts +21 -0
  45. package/_types/errors/stateOverride.d.ts.map +1 -0
  46. package/_types/errors/version.d.ts +1 -1
  47. package/_types/index.d.ts +3 -1
  48. package/_types/index.d.ts.map +1 -1
  49. package/_types/types/eip1193.d.ts +5 -0
  50. package/_types/types/eip1193.d.ts.map +1 -1
  51. package/_types/types/rpc.d.ts +21 -0
  52. package/_types/types/rpc.d.ts.map +1 -1
  53. package/_types/types/stateOverride.d.ts +20 -0
  54. package/_types/types/stateOverride.d.ts.map +1 -0
  55. package/actions/public/call.ts +105 -6
  56. package/actions/public/multicall.ts +3 -1
  57. package/actions/public/readContract.ts +1 -1
  58. package/errors/contract.ts +7 -1
  59. package/errors/data.ts +22 -0
  60. package/errors/stateOverride.ts +50 -0
  61. package/errors/version.ts +1 -1
  62. package/index.ts +13 -0
  63. package/package.json +1 -1
  64. package/types/eip1193.ts +6 -0
  65. package/types/rpc.ts +24 -0
  66. package/types/stateOverride.ts +26 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.7.2",
4
+ "version": "2.7.3",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/types/eip1193.ts CHANGED
@@ -2,6 +2,7 @@ import type { Address } from 'abitype'
2
2
 
3
3
  import type { BlockTag } from './block.js'
4
4
  import type { Hash, Hex, LogTopic } from './misc.js'
5
+ import type { RpcStateOverride } from './rpc.js'
5
6
  import type {
6
7
  Quantity,
7
8
  RpcBlock as Block,
@@ -232,6 +233,11 @@ export type PublicRpcSchema = [
232
233
  transaction: Partial<TransactionRequest>,
233
234
  block: BlockNumber | BlockTag | BlockIdentifier,
234
235
  ]
236
+ | [
237
+ transaction: Partial<TransactionRequest>,
238
+ block: BlockNumber | BlockTag | BlockIdentifier,
239
+ stateOverrideSet: RpcStateOverride,
240
+ ]
235
241
  ReturnType: Hex
236
242
  },
237
243
  /**
package/types/rpc.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Address } from 'abitype'
1
2
  import type {
2
3
  Block,
3
4
  BlockIdentifier,
@@ -7,6 +8,7 @@ import type {
7
8
  } from './block.js'
8
9
  import type { FeeHistory, FeeValues } from './fee.js'
9
10
  import type { Log } from './log.js'
11
+ import type { Hex } from './misc.js'
10
12
  import type { Proof } from './proof.js'
11
13
  import type {
12
14
  TransactionEIP1559,
@@ -103,3 +105,25 @@ export type RpcResponse<TResult = any, TError = any> = {
103
105
  | ErrorResult<TError>
104
106
  | Subscription<TResult, TError>
105
107
  )
108
+
109
+ /** A key-value mapping of slot and storage values (supposedly 32 bytes each) */
110
+ export type RpcStateMapping = {
111
+ [slots: Hex]: Hex
112
+ }
113
+
114
+ export type RpcAccountStateOverride = {
115
+ /** Fake balance to set for the account before executing the call. <32 bytes */
116
+ balance?: Hex
117
+ /** Fake nonce to set for the account before executing the call. <8 bytes */
118
+ nonce?: Hex
119
+ /** Fake EVM bytecode to inject into the account before executing the call. */
120
+ code?: Hex
121
+ /** Fake key-value mapping to override all slots in the account storage before executing the call. */
122
+ state?: RpcStateMapping
123
+ /** Fake key-value mapping to override individual slots in the account storage before executing the call. */
124
+ stateDiff?: RpcStateMapping
125
+ }
126
+
127
+ export type RpcStateOverride = {
128
+ [address: Address]: RpcAccountStateOverride
129
+ }
@@ -0,0 +1,26 @@
1
+ import type { Address } from 'abitype'
2
+ import type { Hex } from './misc.js'
3
+ import type { OneOf } from './utils.js'
4
+
5
+ export type StateMapping = Array<{
6
+ slot: Hex
7
+ value: Hex
8
+ }>
9
+
10
+ export type StateOverride = Array<
11
+ {
12
+ address: Address
13
+ balance?: bigint
14
+ nonce?: number
15
+ code?: Hex
16
+ } & OneOf<
17
+ | {
18
+ /** Fake key-value mapping to override all slots in the account storage before executing the call. */
19
+ state?: StateMapping
20
+ }
21
+ | {
22
+ /** Fake key-value mapping to override individual slots in the account storage before executing the call. */
23
+ stateDiff?: StateMapping
24
+ }
25
+ >
26
+ >