Skip to content

Commit

Permalink
feat(cli): allow deploy salt to be a string (#3432)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Jan 9, 2025
1 parent 971ffed commit 7409095
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .changeset/seven-ducks-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@latticexyz/cli": patch
---

In addition to a hex `--salt`, deploy commands now accept a string salt for world deployment, which will get converted to a hex.

```
pnpm mud deploy --salt hello
```
7 changes: 2 additions & 5 deletions packages/cli/src/runDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "node:path";
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { InferredOptionTypes, Options } from "yargs";
import { deploy } from "./deploy/deploy";
import { createWalletClient, http, Hex, isHex } from "viem";
import { createWalletClient, http, Hex, isHex, stringToHex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { loadConfig, resolveConfigPath } from "@latticexyz/config/node";
import { World as WorldConfig } from "@latticexyz/world";
Expand Down Expand Up @@ -63,10 +63,7 @@ export type DeployOptions = InferredOptionTypes<typeof deployOptions>;
* This is used by the deploy, test, and dev-contracts CLI commands.
*/
export async function runDeploy(opts: DeployOptions): Promise<WorldDeploy> {
const salt = opts.salt;
if (salt != null && !isHex(salt)) {
throw new MUDError("Expected hex string for salt");
}
const salt = opts.salt != null ? (isHex(opts.salt) ? opts.salt : stringToHex(opts.salt)) : undefined;

const profile = opts.profile ?? process.env.FOUNDRY_PROFILE;

Expand Down

0 comments on commit 7409095

Please sign in to comment.