Skip to content

Commit 7409095

Browse files
authored
feat(cli): allow deploy salt to be a string (#3432)
1 parent 971ffed commit 7409095

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.changeset/seven-ducks-complain.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@latticexyz/cli": patch
3+
---
4+
5+
In addition to a hex `--salt`, deploy commands now accept a string salt for world deployment, which will get converted to a hex.
6+
7+
```
8+
pnpm mud deploy --salt hello
9+
```

packages/cli/src/runDeploy.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from "node:path";
22
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
33
import { InferredOptionTypes, Options } from "yargs";
44
import { deploy } from "./deploy/deploy";
5-
import { createWalletClient, http, Hex, isHex } from "viem";
5+
import { createWalletClient, http, Hex, isHex, stringToHex } from "viem";
66
import { privateKeyToAccount } from "viem/accounts";
77
import { loadConfig, resolveConfigPath } from "@latticexyz/config/node";
88
import { World as WorldConfig } from "@latticexyz/world";
@@ -63,10 +63,7 @@ export type DeployOptions = InferredOptionTypes<typeof deployOptions>;
6363
* This is used by the deploy, test, and dev-contracts CLI commands.
6464
*/
6565
export async function runDeploy(opts: DeployOptions): Promise<WorldDeploy> {
66-
const salt = opts.salt;
67-
if (salt != null && !isHex(salt)) {
68-
throw new MUDError("Expected hex string for salt");
69-
}
66+
const salt = opts.salt != null ? (isHex(opts.salt) ? opts.salt : stringToHex(opts.salt)) : undefined;
7067

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

0 commit comments

Comments
 (0)