Repository navigation
feat(cli): add escrow redeem and report the release phase - #312
Conversation
The escrow lets a previous holder take a released name back inside the redeem window, and keeps the name unavailable to others for that long; the CLI had no way to call it. - escrow redeem returns a released name to its previous holder. Before the write it refuses when the name is not released, the signer is not the previous holder, the window has closed (naming when), or the deposit was withdrawn, which forfeits redemption. - escrow status and positions report the release phase with the time it changes: held, redeemable, awaiting (deposit withdrawn inside the window), reclaimable. The phases mirror the escrow's own predicates. - release reuses the phase text when refusing an already released name.
CI Summary
Release - PassedTest this PR Download artifact (GitHub CLI required): gh run download 37267053241 -n cli-release-0.0.0-pr.312 -R paritytech/dotns-sdkInstall globally: npm install -g ./parity-dotns-cli-0.0.0-pr.312.tgzVerify: dotns --helpDeploy Example — Passed
Labelspkg: cli, type: docs, type: test, dependencies Test - Passed380 passed, 0 failed across 380 tests. |
The release phase helpers sit with the other position-to-text helpers in commands/escrow.ts, the time utilities in utils/formatting.ts, and the two time-dependent asserts take nowSeconds like the rest of the file.
The two types listed the same seven struct fields by hand.
Version stays 0.10.0 over main's 0.9.5.
| status: formatPositionStatus(position, nowSeconds), | ||
| cooldownSeconds: cooldownRemainingSeconds(position, nowSeconds).toString(), | ||
| redeemableUntil: position.redeemableUntil.toString(), | ||
| phase: releasePhase(position, now), |
There was a problem hiding this comment.
The positions table shows when the deposit can be withdrawn, and it leaves out whether the name itself can still be taken back.
fix: lease also add phase to the default table at
dotns-sdk/packages/cli/src/cli/views/escrow.ts
Lines 24 to 28 in 78349c0
const rows = positions.map((position) => ({
name: position.domain,
deposit: `${formatWeiAsEther(position.amount)} PAS`,
phase: releasePhase(position, nowSeconds),
status: formatPositionStatus(position, nowSeconds),
}));
const phaseWidth = Math.max("PHASE".length, ...rows.map((row) => row.phase.length));
const header = `${chalk.bold("NAME".padEnd(nameWidth))} ${chalk.bold("DEPOSIT".padEnd(depositWidth))} ${chalk.bold("PHASE".padEnd(phaseWidth))} ${chalk.bold("STATUS")}`;
// each row: name, deposit, phase, status| const phase = | ||
| nowSeconds() < n.position.redeemableUntil | ||
| nowSeconds < n.position.redeemableUntil | ||
| ? `redeemable by the previous holder until ${until}` |
There was a problem hiding this comment.
inside the window with claimed === true, releasePhase is awaiting and redeem refuses, but this error still says the previous holder may redeem. So we should check on n.position.claimed too. Add a test for the fix once applied.
There was a problem hiding this comment.
same gap here: while the deposit is withdrawn and the window is still open, available stays false, but the text still says the name is reserved for the previous holder. So we should check on n.position.claimed too. Add a test for the fix once applied.
The table reported only the deposit clock, not whether the name itself could still be taken back.
The deposit and release-phase helpers are time-gated rules with no chain access, used by the commands, the display layer and the preflight asserts alike; one module gives them a single definition each.
…ster Inside the window with the deposit withdrawn, the release refusal still offered redemption and the register message still called the name reserved for its previous holder. Both now branch on releasePhase.
Version stays 0.10.0 over main's 0.9.6; the positions table keeps both the chain token symbol and the phase column.
Description
The escrow lets a previous holder take a released name back inside the redeem window, and
availablestays false for others that whole time, but the CLI had no way to callredeem. A holder who released a name had a 24 hour right they could not exercise.escrow redeem <name>returns a released name to its previous holder. Before the write,assertRedeemablerefuses when the name is not released, the signer is not the previous holder, the window has closed (naming when), or the deposit was withdrawn, which forfeits redemption.escrow statusandescrow positionsreport the release phase with the time it changes: held, redeemable, awaiting (deposit withdrawn inside the window), reclaimable.releasePhasemirrors the escrow's ownredeemandisReclaimablepredicates.releasereuses the phase text when refusing an already released name.closes paritytech/dotns#252
Misc
releasePhase,formatReleasePhase, and the pre-existing deposit helpersformatPositionStatus,cooldownRemainingSeconds,formatCooldown,isRefundableDeposit,totalEscrowAmount) moved out ofcommands/escrow.tsintocommands/escrowStatus.ts, so the commands, the display layer and the preflight asserts read one definition of each state. No behaviour change.Type
Package
@parity/dotns-cliTesting
380 pass. Five new cases for
redeemassert each refusal fires with zero writes plus the happy path; four pinreleasePhaseagainst the contract predicates; two pin the withdrawn-deposit wording in release and register; the positions table test checks the phase column.Version bumped to 0.10.0.