Skip to content

Commit

Permalink
feat: simulateCalls (#3326)
Browse files Browse the repository at this point in the history
* feat: `simulateCalls`

* chore: changeset
  • Loading branch information
jxom authored Feb 9, 2025
1 parent f68da13 commit 5c06bfa
Show file tree
Hide file tree
Showing 19 changed files with 1,485 additions and 184 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-jeans-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": minor
---

Added `simulateCalls` Action. [Docs](https://viem.sh/docs/actions/public/simulateCalls)
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@
{
"name": "import * from 'viem' (esm)",
"path": "./src/_esm/index.js",
"limit": "66.5 kB",
"limit": "69 kB",
"import": "*"
},
{
"name": "const viem = require('viem') (cjs)",
"path": "./src/_cjs/index.js",
"limit": "78 kB"
"limit": "83 kB"
},
{
"name": "import { createClient, http } from 'viem'",
Expand Down Expand Up @@ -151,7 +151,7 @@
{
"name": "import * from 'viem/actions'",
"path": "./src/_esm/actions/index.js",
"limit": "51 kB",
"limit": "54 kB",
"import": "*"
},
{
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description: Simulates a set of calls on block(s).
---

# simulate
# simulateBlocks

Simulates a set of calls on block(s) with optional block and state overrides. Internally uses the [`eth_simulateV1` JSON-RPC method](https://github.com/ethereum/execution-apis/pull/484).

Expand All @@ -14,7 +14,7 @@ Simulates a set of calls on block(s) with optional block and state overrides. In
import { parseEther } from 'viem'
import { client } from './config'

const result = await client.simulate({
const result = await client.simulateBlocks({
blocks: [{
blockOverrides: {
number: 69420n,
Expand Down Expand Up @@ -66,7 +66,7 @@ const abi = parseAbi([
'function transferFrom(address, address, uint256) returns (bool)',
])

const result = await client.simulate({ // [!code focus:99]
const result = await client.simulateBlocks({ // [!code focus:99]
blocks: [{
calls: [
{
Expand Down Expand Up @@ -114,7 +114,7 @@ export const client = createPublicClient({

## Return Value

`simulateReturnType`
`SimulateBlocksReturnType`

Simulation results.

Expand All @@ -133,7 +133,7 @@ Calls to simulate. Each call can consist of transaction request properties.
```ts twoslash
import { client } from './config'
// ---cut---
const result = await client.simulate({
const result = await client.simulateBlocks({
blocks: [{
blockOverrides: {
number: 69420n,
Expand Down Expand Up @@ -167,7 +167,7 @@ Values to override on the block.
```ts twoslash
import { client } from './config'
// ---cut---
const result = await client.simulate({
const result = await client.simulateBlocks({
blocks: [{
blockOverrides: { // [!code focus]
number: 69420n, // [!code focus]
Expand Down Expand Up @@ -201,7 +201,7 @@ State overrides.
```ts twoslash
import { client } from './config'
// ---cut---
const result = await client.simulate({
const result = await client.simulateBlocks({
blocks: [{
blockOverrides: {
number: 69420n,
Expand Down Expand Up @@ -235,7 +235,7 @@ Whether to return the full transactions.
```ts twoslash
import { client } from './config'
// ---cut---
const result = await client.simulate({
const result = await client.simulateBlocks({
blocks: [{
blockOverrides: {
number: 69420n,
Expand Down Expand Up @@ -270,7 +270,7 @@ Whether to trace transfers.
```ts twoslash
import { client } from './config'
// ---cut---
const result = await client.simulate({
const result = await client.simulateBlocks({
blocks: [{
blockOverrides: {
number: 69420n,
Expand Down Expand Up @@ -305,7 +305,7 @@ Whether to enable validation mode.
```ts twoslash
import { client } from './config'
// ---cut---
const result = await client.simulate({
const result = await client.simulateBlocks({
blocks: [{
blockOverrides: {
number: 69420n,
Expand Down
Loading

0 comments on commit 5c06bfa

Please sign in to comment.