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

feat(cli): add a RPC batch option to cli #2322

Merged
merged 8 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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/angry-buses-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/cli": minor
---

Added an `--rpcBatch` option to `mud deploy` command to batch RPC calls for rate limited RPCs.
1 change: 1 addition & 0 deletions docs/pages/cli/deploy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ These are the command line options you can specify on `mud deploy`:
| `--saveDeployment | Save the deployment info to a file | boolean | `true` |
| `--profile` | The foundry profile to use | string | `local` |
| `--rpc`<sup>1</sup> | The RPC URL to use | string | RPC url from `foundry.toml` |
| `--rpcBatch` | Enable batch processing of RPC requests | boolean | `false` |
| `--worldAddress` | Deploy to an existing World at the given address | string | Empty, deploy new `World` |
| `--srcDir` | Source directory | string | Foundry `src` directory |
| `--skipBuild` | Skip rebuilding the contracts before deploying | boolean | `false` |
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/dev-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const commandModule: CommandModule<typeof devOptions, InferredOptionTypes<typeof
...opts,
configPath,
rpc,
rpcBatch: false,
skipBuild: false,
printConfig: false,
profile: undefined,
Expand Down
13 changes: 12 additions & 1 deletion packages/cli/src/runDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const deployOptions = {
profile: { type: "string", desc: "The foundry profile to use" },
saveDeployment: { type: "boolean", desc: "Save the deployment info to a file", default: true },
rpc: { type: "string", desc: "The RPC URL to use. Defaults to the RPC url from the local foundry.toml" },
rpcBatch: {
type: "boolean",
desc: "Enable batch processing of RPC requests in viem client (defaults to batch size of 100 and wait of 1s)",
},
deployerAddress: {
type: "string",
desc: "Deploy using an existing deterministic deployer (https://github.com/Arachnid/deterministic-deployment-proxy)",
Expand Down Expand Up @@ -85,7 +89,14 @@ in your contracts directory to use the default anvil private key.`,
const resolvedConfig = resolveConfig({ config, forgeSourceDir: srcDir, forgeOutDir: outDir });

const client = createWalletClient({
transport: http(rpc),
transport: http(rpc, {
batch: opts.rpcBatch
? {
batchSize: 100,
wait: 1000,
}
: undefined,
}),
account: privateKeyToAccount(privateKey),
});
console.log("Deploying from", client.account.address);
Expand Down
Loading