From e77932d5184f785ac1c9d4aeb47decf0c61b5ce6 Mon Sep 17 00:00:00 2001 From: UtkarshBhardwaj007 Date: Mon, 20 Apr 2026 21:21:37 +0100 Subject: [PATCH] fix(deploy): only pass user address to availability preflight in phone mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In dev mode bulletin-deploy signs DotNS with its built-in DEFAULT_MNEMONIC, so the on-chain owner of a previously-deployed domain is the dev account, not the user. Passing `userSigner.address` as the ownership reference made the preflight mis-report re-deploys as `taken by ` whenever the user also had a `dot init` phone session. Gate `ownerSs58Address` on `mode === "phone"` at both call sites. In dev mode we skip the preflight ownership check entirely and let bulletin-deploy's own preflight (run with the right signer during `deploy()`) classify the re-deploy. The apparent casing mismatch in the error was unrelated — bulletin-deploy already does a case-insensitive owner compare. --- .changeset/fix-redeploy-owner-mismatch.md | 7 +++++++ src/commands/deploy/DeployScreen.tsx | 7 ++++++- src/commands/deploy/index.ts | 11 ++++++++++- src/utils/deploy/availability.ts | 22 +++++++++++++++++----- 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 .changeset/fix-redeploy-owner-mismatch.md diff --git a/.changeset/fix-redeploy-owner-mismatch.md b/.changeset/fix-redeploy-owner-mismatch.md new file mode 100644 index 0000000..9e6d8c8 --- /dev/null +++ b/.changeset/fix-redeploy-owner-mismatch.md @@ -0,0 +1,7 @@ +--- +"playground-cli": patch +--- + +Fix `dot deploy` reporting "already registered" on re-deploys made in dev mode when a phone session was also present. + +The domain-availability preflight was passing the logged-in user's SS58 address as the reference owner for the on-chain ownership check regardless of signer mode. In dev mode bulletin-deploy signs DotNS with its built-in `DEFAULT_MNEMONIC`, so the domain is owned by the dev account — not the user — and the preflight incorrectly reported the re-deploy as taken by a different account. We now only pass the user's address when `--signer phone` (where bulletin-deploy actually uses the user's signer). In dev mode we skip the ownership check and let bulletin-deploy's own preflight classify the re-deploy with the right signer. diff --git a/src/commands/deploy/DeployScreen.tsx b/src/commands/deploy/DeployScreen.tsx index eab0e6b..f126570 100644 --- a/src/commands/deploy/DeployScreen.tsx +++ b/src/commands/deploy/DeployScreen.tsx @@ -203,7 +203,12 @@ export function DeployScreen({ {stage.kind === "validate-domain" && ( { setDomain(result.fullDomain); setPlan(result.plan); diff --git a/src/commands/deploy/index.ts b/src/commands/deploy/index.ts index 0bafee0..06b455c 100644 --- a/src/commands/deploy/index.ts +++ b/src/commands/deploy/index.ts @@ -227,10 +227,19 @@ async function runHeadless(ctx: { // Check availability BEFORE we build + upload, so CI fails fast on a // Reserved / already-taken name without wasting a chunk upload. + // + // `ownerSs58Address` MUST match whoever will actually sign the DotNS + // `register()` extrinsic — otherwise the preflight reports "taken" on a + // re-deploy. In phone mode bulletin-deploy uses the user's signer, so + // passing the user's address is correct. In dev mode bulletin-deploy + // falls back to its built-in DEFAULT_MNEMONIC, so the user's H160 does + // NOT match the on-chain owner — we omit the address and let + // bulletin-deploy's own preflight (run with the right signer during + // `deploy()`) do the comparison. process.stdout.write(`\nChecking availability of ${domain.replace(/\.dot$/, "") + ".dot"}…\n`); const availability = await checkDomainAvailability(domain, { env: ctx.env, - ownerSs58Address: ctx.userSigner?.address, + ownerSs58Address: mode === "phone" ? ctx.userSigner?.address : undefined, }); if (availability.status !== "available") { throw new Error(formatAvailability(availability)); diff --git a/src/utils/deploy/availability.ts b/src/utils/deploy/availability.ts index c1de4c6..9e78b61 100644 --- a/src/utils/deploy/availability.ts +++ b/src/utils/deploy/availability.ts @@ -90,11 +90,23 @@ export interface CheckAvailabilityOptions { /** Optional timeout in ms. Each RPC call has its own internal timeout. */ timeoutMs?: number; /** - * The deploying account's SS58 address. When provided we derive its H160 - * via `ss58ToH160` and treat "owned by you" as an update path rather than - * a `taken` block. Omit in dev-mode-without-signer and we skip the - * ownership check entirely (bulletin-deploy's own preflight is the - * ultimate source of truth when the real signer is used). + * SS58 address of the account that will SIGN the DotNS `register()` / + * `setContenthash` extrinsics — NOT necessarily the currently logged-in + * user. When provided we derive its H160 via `ss58ToH160` and treat + * "owned by you" as an update path rather than a `taken` block. + * + * Must match whoever bulletin-deploy will use as its DotNS signer: + * - Phone mode → user's signer address. + * - Dev mode → omit entirely (bulletin-deploy falls back to its + * built-in `DEFAULT_MNEMONIC`, and we have no easy way to derive + * that H160 without replicating bulletin-deploy internals). When + * omitted we skip the preflight ownership check; bulletin-deploy's + * own preflight during `deploy()` is run with the right signer and + * classifies the re-deploy correctly. + * + * Passing the wrong address (e.g. the phone session's H160 in dev mode) + * mis-reports re-deploys as `taken` because the on-chain owner is the + * dev account, not the user. */ ownerSs58Address?: string; }