From 74090950d81c6713d981806af5c1197e804b56bf Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 9 Jan 2025 02:49:39 -0800 Subject: [PATCH] feat(cli): allow deploy salt to be a string (#3432) --- .changeset/seven-ducks-complain.md | 9 +++++++++ packages/cli/src/runDeploy.ts | 7 ++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .changeset/seven-ducks-complain.md diff --git a/.changeset/seven-ducks-complain.md b/.changeset/seven-ducks-complain.md new file mode 100644 index 0000000000..a5fe828408 --- /dev/null +++ b/.changeset/seven-ducks-complain.md @@ -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 +``` diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts index b2c1ce4c0d..a0a99acc4c 100644 --- a/packages/cli/src/runDeploy.ts +++ b/packages/cli/src/runDeploy.ts @@ -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"; @@ -63,10 +63,7 @@ export type DeployOptions = InferredOptionTypes; * This is used by the deploy, test, and dev-contracts CLI commands. */ export async function runDeploy(opts: DeployOptions): Promise { - 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;