Skip to content

fix(account): give new sign-ups their initial testnet top-up - #857

Closed
fraseragain wants to merge 1 commit into
developfrom
fix/signup-testnet-topup
Closed

fraseragain wants to merge 1 commit into
developfrom
fix/signup-testnet-topup

Conversation

@fraseragain

Copy link
Copy Markdown
Contributor

Problem

A brand-new Studio account on production has a testnet payment account with a balance of 0 (Account 'cheqd1…' does not exist on chain), so Studio's own DID and resource calls fail with a 500 until the user requests tokens from the faucet. The sign-up top-up the docs describe never happens.

Cause

56d3f25 (in 3.18.0) made the initial top-up run only for a newly created testnet account:

const isNewTestnetAccount = !accounts.some((acc) => acc.namespace === CheqdNetwork.Testnet);

CustomerService.create already creates the customer's default testnet payment account, before bootstrap (and POST /account/create) read the accounts. So for a new sign-up the testnet account always exists, the flag is always false, and topupTestnet returns without doing anything. The existing tests only call topupTestnet directly with the flag set.

What changed

  • New isNewTestnetAccount(customerCreatedNow, hadTestnetAccount) in src/helpers/testnet-topup.ts. It is true when the call created the customer, or when the testnet account didn't exist.
  • bootstrap sets customerCreatedNow at both places it creates a customer. create sets it when there is no customer on the request.
  • Later calls for the same customer still don't top up again: the customer exists, and so does its testnet account.

How to test

  • npm run test:unit: new tests/unit/account/testnet-topup.test.ts (3 tests), including the case that was broken. All 24 suites and 216 tests pass, and tsc --noEmit exits 0.
  • On staging after deploy: sign up a new account, then GET /account/balances. The testnet balance should be 10,000 CHEQ, and faucet.quota.used should show 10,000.

Notes

  • Not covered by an automated test here: the full sign-up path needs Postgres and a LogTo webhook, so the integration tests are skipped without a database.
  • Accounts created since 3.18.0 (14 October) never got the top-up. They need a one-off top-up, or can use Balances & Faucet themselves. A read-only way to find them: customers created since 2026-10-12 with no faucetRequest row.

🤖 Generated with Claude Code

CustomerService.create also creates the customer's default testnet
payment account, so by the time bootstrap and POST /account/create read
the accounts it always exists. isNewTestnetAccount (added in 56d3f25)
was therefore false for every new sign-up and nobody was topped up.
The top-up now applies when the call created the customer.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fraseragain

Copy link
Copy Markdown
Contributor Author

Closing: we decided accounts should not be topped up automatically on sign-up, because people may want to fund an external wallet instead. New users will be told to request testnet CHEQ on the dashboard, and the sign-up top-up code is being removed instead (follow-up PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants