The template ships a hardcoded contract package name (@rps/leaderboard). On the
shared registry that name is already owned by the original deployer's signer, so
the first thing a modder hits on `pg deploy` is:
✖ CDM package "@rps/leaderboard" is already owned by 0x…, but the selected
signer maps to 0x…. Update the Cargo.toml package value to a name you own…
The error points at renaming, but every *predictable* replacement (@rps-<x>,
@<handle>-rps, …) tends to be taken too, so people collide repeatedly. The real
fix is to stop shipping a guessable name.
- scripts/new-contract-name.mjs (`npm run name:new`): generate a high-entropy,
unowned name (@rps-<8hex>/leaderboard) and rewrite cdm.json +
contracts/leaderboard/Cargo.toml. Pass an explicit name to override.
- src/utils.ts: derive the package name from cdm.json instead of hardcoding it in
three places, so there is a single source of truth and the rename only has to
touch cdm.json + Cargo.toml (no silent frontend resolve failures).
- README: document `npm run name:new` as the first step of modding.
Contract-agnostic — no change to contract logic or the deploy pipeline.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Problem
The template ships a hardcoded contract package name (
@rps/leaderboard). On the shared registry that name is already owned by the original deployer's signer, so the first thing anyone modding this app hits onpg deploy(ornpm run deploy) is:The error leads with "rename it," but every predictable replacement (
@rps-<x>,@<handle>-rps,@<repo-id>/…) tends to already be owned too — so modders (and coding agents) collide repeatedly, renaming under the same signer each time. The root issue is shipping a guessable name with no way to verify ownership before signing.Fix
Stop shipping a guessable name; make claiming a fresh one one command.
scripts/new-contract-name.mjs(npm run name:new) — generates a high-entropy, effectively-unowned name (@rps-<8hex>/leaderboard) and rewrites it incdm.json+contracts/leaderboard/Cargo.toml. Pass your own to override:npm run name:new @me/scoreboard.src/utils.ts— derive the package name fromcdm.jsoninstead of hardcoding it in three string literals, so there's a single source of truth. A miss when hand-syncing the name previously surfaced as a silent runtime resolve failure, not a build error.npm run name:newas the first step of modding.Why this shape
fs,crypto).getOwnerrequired — a random name sidesteps the (currently unverifiable) ownership check entirely.Verification
npm run name:newrewrites both files correctly and is idempotent/guarded (rejects invalid or unchanged names).tsc -bpasses with theutils.tschange.Follow-up (not in this PR)
An offline dev mode (
?mockbacked by an in-memory leaderboard) lets a modder verify register/play/leaderboard with no chain, phone, or deploy — closing the "you can only discover problems by doing an irreversible deploy" loop. Happy to open that as a separate PR if of interest.