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.
- package/CHANGELOG.md +8 -0
- package/_cjs/actions/public/call.js +69 -6
- package/_cjs/actions/public/call.js.map +1 -1
- package/_cjs/actions/public/multicall.js +2 -1
- package/_cjs/actions/public/multicall.js.map +1 -1
- package/_cjs/errors/contract.js +6 -2
- package/_cjs/errors/contract.js.map +1 -1
- package/_cjs/errors/data.js +15 -1
- package/_cjs/errors/data.js.map +1 -1
- package/_cjs/errors/stateOverride.js +58 -0
- package/_cjs/errors/stateOverride.js.map +1 -0
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +7 -4
- package/_cjs/index.js.map +1 -1
- package/_cjs/types/eip1193.js.map +1 -1
- package/_cjs/types/stateOverride.js +3 -0
- package/_cjs/types/stateOverride.js.map +1 -0
- package/_esm/actions/public/call.js +65 -5
- package/_esm/actions/public/call.js.map +1 -1
- package/_esm/actions/public/multicall.js +2 -1
- package/_esm/actions/public/multicall.js.map +1 -1
- package/_esm/errors/contract.js +6 -2
- package/_esm/errors/contract.js.map +1 -1
- package/_esm/errors/data.js +13 -0
- package/_esm/errors/data.js.map +1 -1
- package/_esm/errors/stateOverride.js +51 -0
- package/_esm/errors/stateOverride.js.map +1 -0
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/types/eip1193.js.map +1 -1
- package/_esm/types/stateOverride.js +2 -0
- package/_esm/types/stateOverride.js.map +1 -0
- package/_types/actions/public/call.d.ts +15 -2
- package/_types/actions/public/call.d.ts.map +1 -1
- package/_types/actions/public/multicall.d.ts +1 -1
- package/_types/actions/public/multicall.d.ts.map +1 -1
- package/_types/actions/public/readContract.d.ts +1 -1
- package/_types/actions/public/readContract.d.ts.map +1 -1
- package/_types/errors/contract.d.ts +1 -1
- package/_types/errors/contract.d.ts.map +1 -1
- package/_types/errors/data.d.ts +11 -0
- package/_types/errors/data.d.ts.map +1 -1
- package/_types/errors/stateOverride.d.ts +21 -0
- package/_types/errors/stateOverride.d.ts.map +1 -0
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +3 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/types/eip1193.d.ts +5 -0
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/types/rpc.d.ts +21 -0
- package/_types/types/rpc.d.ts.map +1 -1
- package/_types/types/stateOverride.d.ts +20 -0
- package/_types/types/stateOverride.d.ts.map +1 -0
- package/actions/public/call.ts +105 -6
- package/actions/public/multicall.ts +3 -1
- package/actions/public/readContract.ts +1 -1
- package/errors/contract.ts +7 -1
- package/errors/data.ts +22 -0
- package/errors/stateOverride.ts +50 -0
- package/errors/version.ts +1 -1
- package/index.ts +13 -0
- package/package.json +1 -1
- package/types/eip1193.ts +6 -0
- package/types/rpc.ts +24 -0
- package/types/stateOverride.ts +26 -0
package/package.json
CHANGED
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
|
+
>
|