Skip to content

feat(documents): let the user skip an optional token cost - #1124

Merged
lklimek merged 128 commits into
v1.0-devfrom
feat/document-optional-token-cost
Nov 28, 2026
Merged

lklimek merged 128 commits into
v1.0-devfrom
feat/document-optional-token-cost

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: When a contract marks a document action's token cost as optional (protocol 14), the document action screen offers "Pay the token cost". With it turned off, the action carries no token payment and the identity pays the network fee in credits. A required token cost is always paid, as before.

Stacked atop #1117.

User story

As a user, when a document action's token cost is optional, I want to choose not to pay it, so that I can pay the network fee in credits instead (DOC-011).

Scenario

Base flow

  1. Connect to a protocol 14 network. Open a document action whose document type declares an optional token cost for that action.
  2. Turn off "Pay the token cost" and send the action.

Actual

The screen always attached the token payment. An optional token cost could not be left out.

Expected

  • "Pay the token cost" appears under the token cost only when that cost is optional. It is on by default, so nothing changes unless the user turns it off.
  • With it off, the action carries no token payment. The identity pays the network fee in credits, and no gas sponsorship applies.
  • A required token cost is always paid, whatever the option was set to for another document type.

Detailed discussion

  • Token payment (src/ui/contracts_documents/document_action_screen.rs):
    • token_payment builds the token payment for a cost. It returns none without a cost, and none for an optional cost the user chose not to pay.
    • All six document actions (create, delete, purchase, replace, set price, transfer) build their token payment through it, instead of six copies of the same construction.
  • Option: pay_optional_token_cost backs the "Pay the token cost" checkbox in render_token_cost_info. It resets to on whenever the selected action has no token cost.
  • Protocol: DocumentActionTokenCost::optional comes from the Platform pin in chore(deps)!: update Platform to v5.1-dev 063589bf and follow the network's protocol version #1114. Only protocol 14 contracts can declare it, so the option never appears for older contracts and needs no capability gate.
  • Docs: user story DOC-011.
  • Scope: split out of the document action fees PR (feat(documents): agree to document action fees before broadcasting #1122). The two touch the same document actions but are independent; either can merge first.

Testing

  • New unit test: ui::contracts_documents::document_action_screen::tests::an_optional_token_cost_is_paid_only_when_the_user_chooses_to. A required cost is always paid; an optional cost only while the option is on; no cost means no payment.
  • document_action_screen tests: 8 passed.
  • cargo clippy --all-features --lib --tests -- -D warnings and cargo fmt --all pass.
  • No live network or GUI flows were run.

🤖 Co-authored by Claudius the Magnificent AI Agent

🤖 Generated with Claude Code

https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q

PR Hygiene · 8af761e

  • Bots — coderabbitai ✓ · thepastaclaw ✓
  • Self-review — not asked of a bot author
  • Build green
  • Approvals
    • files with no dedicated owner (docs/user-stories.md, src/ui/contracts_documents/document_action_screen.rs) — approved by lklimek

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

Summary by CodeRabbit

  • New Features
    • Added an option to skip optional token costs for document actions. When skipped, no token payment is included, and network fees are paid from identity credits.
    • Required token costs remain payable regardless of the option. Token-cost details appear only when a payment will be made.
    • The choice resets when the form is cleared or the contract or document type changes, and is retained when retrying after a failed broadcast.
  • Documentation
    • Documented the option to skip optional token costs.

lklimek and others added 25 commits October 24, 2026 18:21
Pin dash-sdk, rs-sdk-trusted-context-provider, platform-wallet and
platform-wallet-storage to dashpay/platform v5.1-dev 063589bf
(5.0.0-rc.8). The lockfile moves only the Platform packages.

The upstream V019 wallet-storage migration adds a nullable asset-lock
operation id; V001-V018 are unchanged. The compatibility bridge gets the
033ecae destination snapshot it compares against, and the pin guard
records the new revision with an unchanged migration fingerprint.

BREAKING CHANGE: the wallet storage upgrade to V019 is forward only. An
older build cannot open upgraded storage; going back needs a copy of the
data directory taken before the upgrade.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new rust-dashcore wraps secp256k1 keys in EcdsaSecretKey and
EcdsaPublicKey, returns secret bytes as Zeroizing, and drops the
Secp256k1 context argument. Signers, single-key wallets, DashPay
derivation, address and QR handling, migrations and their tests follow
the new types. Signing stays on the non-grinding dpp::secp256k1 path,
and a parity test pins the BLS signature bytes the previous SDK made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Handle the dpp and SDK types the new pin adds, keeping today's behaviour:

- Document replace keeps moderated_at and moderated_by; new documents
  start without them.
- The document editor refuses typed-array fields instead of dropping
  their contents, and keeps referenced key ids as numbers.
- Shielded token events show read-only in group actions, and the
  shielded pool token settings are refused before anything is signed.
- Contested document creation states the protocol's base contest fund,
  so the SDK never auto-quotes a larger one.
- Masternode vote reads use ResourceVoteWithCount, the SDK's new vote
  type; the vote count is not used yet.
- New query fields, wallet events, wallet error variants and asset-lock
  funding modes are handled where the SDK now requires them.
- Entropy-only document ids are documented as placeholders from
  protocol 14, and deferred upstream features link to their issues.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK was pinned to the protocol 13 table, so it could not build any
protocol 14 transition or follow the versioned identity lookup. It now
starts at upstream's per-network minimum and ratchets to what proven
responses report.

- System contracts are cached per protocol version and served through
  accessors. The context provider serves them at the version the proof
  verifier asks for and fails rather than serve another version's.
- A proved epoch sets the fee multiplier and raises the protocol version.
  An older epoch than the adopted one is ignored.
- Rebuilding the connection resets the protocol version, fee multiplier
  and adopted epoch under one lock before the new SDK is published, and
  drops reads begun on the old connection.
- Capabilities read the network's version through a helper that stays
  closed for a version this build does not define.
- Contest timing reads the live version; retired vote schedules keep the
  protocol 13 notice window they were created under.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Compare the protocol 13 client tables with a recorded snapshot, so an
upstream change to them is reviewed, and check that keys and documents
DET builds on a protocol 13 network use encodings protocol 13 decodes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map the refusals the new protocol adds to flows DET already offers to
dedicated TaskError variants: a full username contest, a vote choice the
contest does not allow, a name someone else asked for first, a token
that cannot be moved, a changed immutable document field, a reference to
a document type that cannot be deleted, and a moderators' fee on a
contract without moderation. Names supplied by the node stay in the
typed source only, never in the message.

Token operations that fail inside the wallet runtime keep their SDK
cause, so they are classified like any SDK error; an unclassified one
names the operation that did not complete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Add a dated design note for the pin, the protocol version sources, the
connection state rules and the protocol 13 guards, and point AGENTS.md
at From<SdkError> for TaskError as the SDK error reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Automatic key choice keeps only keys that are live (not disabled, not
expired), held on this device, in scope for the action's contract or
document type, and at a security level the action accepts. Among those
it prefers a key without limits, and a document type takes a stronger
key than the one it requires when that is all the identity holds.

Keys are judged as the identity holds them now: a key whose limits were
raised on the network is still the same key, so its stored private half
stays matched to it, while a key that gains or loses a limit is not.

An explicitly chosen DPNS key may have expired; the chooser warns and
Platform decides by network time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map the refusals Platform gives for a signing key that expired, used up
its spending limit, cannot pay for the action, or is bound to another
contract or to batch actions only, to dedicated TaskError variants with
a message that says what to do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…t that holds it

Every screen and backend task that picks a signing key now asks for the
action's scope: the contract or document type for document and token
actions, none for identity and contract transitions. DashPay documents
use the levels each document type accepts.

The manual key chooser leaves out keys bound to another contract or
document type, keeps expired and limited keys with a warning, and judges
the key the identity holds now. A document action with no usable key
says why the form stops. The wallet to unlock, and the owner of an
identity stored without a wallet link, follow the key that is actually
used. Lookups that only point the user at a key, such as Check Owner
Key, do not require the private half on this device.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…it refusals

Protocol version 14 refusals that flows already in DET can hit get
dedicated, actionable messages, each keeping the SDK error as its source:

- an identity banned or suspended (until when) on a moderated contract;
- a gas sponsor short of credits, a gas payer the document type does not
  offer, and mixed gas payers in one batch;
- pre-programmed token distributions of one time over the limit.

An overflowing shielded note total is logged at warn: it means corrupt or
hostile sync data, not routine noise.

Tests cover contracts saved at protocol 12 loading unchanged at 13 and 14,
and contracts saved at 14 decoding at 13 and in full again at 14.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…efusals from the Platform bump

Merges 74695e7 from chore/bump-platform-063589bf. The conflict in
src/backend_task/error.rs keeps both sides: the signing key refusals and
the moderation and gas sponsorship refusals each keep their own section,
match arms and test cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A lookup at another version, as the proof verifier makes at a response's
version, swapped out the app's set, so each such lookup reloaded the
system contracts and the next app read reloaded them again. Each
version now keeps its own set; the app's reads keep the set they last
got for a failed reload.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…poch

When the epoch cannot be read, the proved DPNS fallback confirmed the
SDK's version, which starts at the network's upstream minimum (14 on
devnet), as the network's. It now confirms the version of the responses
the SDK verified, and nothing before any.

Restores the completed-withdrawal status list with the reason sending
FAILED to a protocol 13 network is safe, and its test, now comparing the
protocol 13 schema with the latest one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The derived key DET signs with is copied into secp256k1's own type,
which keeps its bytes after use. Wrap it so it is erased on drop, as the
derived key it comes from would be; signatures stay byte-identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new refusals sent users to another document editor or token client.
They now say the app cannot edit this field type, sign this action or
change this token setting yet, in one wording, and the shielded setting
refusal sits with the token contract errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Also corrects the platform compatibility fixtures README: no code reads
e3cd7cf.sql any more; it is the V001-V018 checksum reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The username screen offered the unlock, and gated paying, on the wallet
of the automatically picked key, although a key chosen under Advanced
signs the registration. The wallet now follows the key the registration
is signed with, and is picked again when that key changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The document action and DashPay selectors offered every accepted level
at once, so a CRITICAL key could sign where a key at the required level
was held. Every document key is now chosen like the username key: each
accepted level from the weakest up, unlimited keys first within a level.

Also puts the scope and wallet doc comments of the document action
screen back on their functions, and builds its test keys and identities
from the shared test helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Each key chooser entry with a caveat is one complete template instead
of a label plus a concatenated tag. The spending limit warning no longer
points at a remaining budget the key details do not show, and IDN-024
names the key chooser, not the key list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
When a document type marks an action's token cost as optional (protocol
version 14), the document action screen offers "Pay the token cost".
With it off, the action carries no token payment and the identity pays
the network fee in credits; a required token cost is always paid. Adds
user story DOC-011.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The document action screen adds a default-enabled option to pay optional token costs. When declined, the screen omits token payment information and indicates that network fees are paid from identity credits. Required costs remain payable. The change applies to all six document actions.

Changes: Document action token payment

Layer / File(s) Summary
Token-cost choice and display
src/ui/contracts_documents/document_action_screen.rs
The screen tracks the optional-cost choice, resets it after selection changes or form resets, and updates the cost summary based on the resulting payment.
Document actions and validation
src/ui/contracts_documents/document_action_screen.rs, docs/user-stories.md
All six document actions use the selected payment information. Tests cover payment rules, resets, retry behavior, and cost-summary updates. The user story documents the option.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Suggested reviewers: lklimek, pauldelucia, thepastaclaw

Merge Risk: Minimal · up to 8af76

This adds an opt-out for optional token costs on document actions. Required costs are still paid, and older contracts do not show the option. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: a user can skip an optional token cost for document actions. The changeset adds a default-on "Pay the token cost" option in DocumentActionScreen, which omits token pay…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a user can skip an optional token cost for document actions. The changeset adds a default-on "Pay the token cost" option in DocumentActionScreen, which omits token payment when unchecked and shows that network fees are paid in credits. The title is specific, concise, and matches the primary objective in the PR summary.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1633868 and 8af761e.

Files selected for processing: 2

  • docs/user-stories.md
  • src/ui/contracts_documents/document_action_screen.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@thepastaclaw

thepastaclaw commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 8af761e) · triage: normal · Phase 2 only (no Phase 1 for this repository)

lklimek and others added 3 commits October 25, 2026 12:03
The protocol version fallback takes only a version the SDK verified, and
a mock expectation's metadata is never recorded as verified, so the three
headless refresh tests saw the version stay unconfirmed. The mock now has
the SDK accept the version from metadata treated as proved, as after a
live network's signed response, and a new test pins that a response the
SDK never verified leaves the version unconfirmed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Base automatically changed from fix/protocol14-signing-key-selection to v1.0-dev November 27, 2026 15:53
@lklimek
lklimek marked this pull request as ready for review November 27, 2026 21:11
@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Nov 27, 2026
lklimek and others added 4 commits November 27, 2026 21:24
…/document-optional-token-cost

Conflict resolution:
- src/ui/contracts_documents/document_action_screen.rs: kept the PR's optional token-cost payment (token_payment helper and its test) on top of #1117's signing-key refresh, price reads without a signing key and its tests; both test sets kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to feat/document-optional-token-cost

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

Changes requested: 2 blockers

  • Reset the optional token-cost choice when starting a new action — src/ui/contracts_documents/document_action_screen.rs:373-384 (carried)
    Impact: A user who opts out once can spend identity credits on a later action that offers fee sponsorship without opting out again.
  • Show the credit-fee outcome when an optional token cost is disabled — src/ui/contracts_documents/document_action_screen.rs:1038-1052 (thread, carried)
    Impact: A user who turns off an optional payment sponsored by the contract owner is still told the owner will pay, even though the fee is deducted from the user's identity credits.

New on this head: This head brings in signing-key and document-form updates that clear stale selections and pending requests, while leaving the optional token-payment logic unchanged. The branch conflicts with the current v1.0-dev, which already includes #1117. Test Suite and Clippy were skipped, no code check reported a failure, and PR Hygiene is pending.

🔴 2 blocking

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: Reset the optional token-cost choice when starting a new action
Impact: A user who opts out once can spend identity credits on a later action that offers fee sponsorship without opting out again.
src/ui/contracts_documents/document_action_screen.rs:373-384

After creating a document with the token payment turned off, a user can click “Back to Create Document,” select a type with a sponsored optional cost, and send the next document with the old opt-out still active. reset_screen() clears the selections but not pay_optional_token_cost, and the empty form returns before the no-cost branch can restore the default. Switching directly between two optional-cost types also leaves the choice unchanged: signing_scope_changed() clears fetched state but not the checkbox. In either case, token_payment_for() omits the payment and the identity pays the network fee in credits. Restore the default on form reset and contract or type change, and cover both paths with a regression test.

source: gpt-6.2-astra (phase2-reviewer: general, rust-quality)

Still open from earlier rounds (1)

  • 🔴 Blocking: Show the credit-fee outcome when an optional token cost is disabled — src/ui/contracts_documents/document_action_screen.rs:1038-1052 (thread)
Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The full diff against v1.0-dev includes intricate changes to identity signing-key eligibility and selection in src/model/qualified_identity/mod.rs, including withdrawal_signing_key and transfer_signing_key, beyond the optional token-cost checkbox.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `src/ui/contracts_documents/document_action_screen.rs`:
- [BLOCKING] src/ui/contracts_documents/document_action_screen.rs:373-384: Reset the optional token-cost choice when starting a new action
  Impact: A user who opts out once can spend identity credits on a later action that offers fee sponsorship without opting out again.
  After creating a document with the token payment turned off, a user can click “Back to Create Document,” select a type with a sponsored optional cost, and send the next document with the old opt-out still active. `reset_screen()` clears the selections but not `pay_optional_token_cost`, and the empty form returns before the no-cost branch can restore the default. Switching directly between two optional-cost types also leaves the choice unchanged: `signing_scope_changed()` clears fetched state but not the checkbox. In either case, `token_payment_for()` omits the payment and the identity pays the network fee in credits. Restore the default on form reset and contract or type change, and cover both paths with a regression test.
- [BLOCKING] src/ui/contracts_documents/document_action_screen.rs:1038-1052: Show the credit-fee outcome when an optional token cost is disabled
  (carried; thread: https://github.com/dashpay/dash-evo-tool/pull/1124#discussion_r4381859134)

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix, 1 thread unresolved — resolve it. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Nov 27, 2026
The cost summary ignored the "Pay the token cost" choice and could still
say tokens would be paid and the contract owner would pay gas. It now
follows the same decision as the submitted action: with the optional cost
unchecked, it says no tokens will be paid and you pay the network fee in
credits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

Changes requested: 2 blockers

  • Reset the optional token-cost choice when starting a new action — src/ui/contracts_documents/document_action_screen.rs:363-386 (carried)
    Impact: A user who skips a sponsored token cost and starts another action on the same form can pay the next network fee from their identity credits without opting out for that action.
  • Show the credit-fee outcome when an optional token cost is disabled — src/ui/contracts_documents/document_action_screen.rs:1070-1084 (thread, carried)
    Impact: A user who unchecks an optional token cost sponsored by the contract owner still sees the owner named as the fee payer, but submitting the action debits the user's identity credits.

New on this head: This head retargets the optional token-cost feature to v1.0-dev after #1117 merged and picks up the signing-key refresh and wallet-unlock updates. All six document actions use the shared payment choice, and required token costs remain mandatory. Test Suite and Clippy passed; PR Hygiene and PastaClaw review are pending.

🔴 2 blocking

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: Reset the optional token-cost choice when starting a new action
Impact: A user who skips a sponsored token cost and starts another action on the same form can pay the next network fee from their identity credits without opting out for that action.
src/ui/contracts_documents/document_action_screen.rs:363-386

A new action can spend the user's credits instead of using the default token payment and its sponsorship. After creating a document with “Pay the token cost” unchecked, click “Back to Create Document” and select the same optional-cost type again. reset_screen clears the contract and type but leaves pay_optional_token_cost false. With either selection missing, render_main_content returns before the cost renderer can reset the flag. Reselecting an optional-cost type therefore shows the checkbox unchecked, and token_payment_for omits the payment on submission. Switching directly between two optional-cost types also retains the flag. Restore the default on form reset and when the contract or type changes, while preserving the choice when retrying the same draft.

source: gpt-6.2-sol (phase2-reviewer: general, rust-quality)

Still open from earlier rounds (1)

  • 🔴 Blocking: Show the credit-fee outcome when an optional token cost is disabled — src/ui/contracts_documents/document_action_screen.rs:1070-1084 (thread)
Review provenance

Source: reviewer 1: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — The behavior change is contained to one screen, where a default-on checkbox and a shared helper let users omit optional token payments while preserving required payments across all six document actions.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `src/ui/contracts_documents/document_action_screen.rs`:
- [BLOCKING] src/ui/contracts_documents/document_action_screen.rs:363-386: Reset the optional token-cost choice when starting a new action
  Impact: A user who skips a sponsored token cost and starts another action on the same form can pay the next network fee from their identity credits without opting out for that action.
  A new action can spend the user's credits instead of using the default token payment and its sponsorship. After creating a document with “Pay the token cost” unchecked, click “Back to Create Document” and select the same optional-cost type again. `reset_screen` clears the contract and type but leaves `pay_optional_token_cost` false. With either selection missing, `render_main_content` returns before the cost renderer can reset the flag. Reselecting an optional-cost type therefore shows the checkbox unchecked, and `token_payment_for` omits the payment on submission. Switching directly between two optional-cost types also retains the flag. Restore the default on form reset and when the contract or type changes, while preserving the choice when retrying the same draft.
- [BLOCKING] src/ui/contracts_documents/document_action_screen.rs:1070-1084: Show the credit-fee outcome when an optional token cost is disabled
  (carried; thread: https://github.com/dashpay/dash-evo-tool/pull/1124#discussion_r4381859134)

Skipping an optional token cost carried over to the next action on the
same form: after "Back to Create Document", or when switching to another
contract or document type, the cost stayed unpaid without the user
opting out again. The choice now returns to paying on a form reset or a
contract or type change, and is kept when retrying the same draft.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Claudius-Maginificent

Copy link
Copy Markdown
Collaborator Author

PastaClaw review item: Reset the optional token-cost choice when starting a new action (src/ui/contracts_documents/document_action_screen.rs)

Fixed in 8af761e: the choice returns to paying the token cost when the form is reset or the selected contract or document type changes, and is kept when retrying the same draft. Covered by optional_token_cost_defaults_to_pay_after_form_reset, optional_token_cost_defaults_to_pay_after_selection_change and optional_token_cost_choice_survives_failed_draft_retry.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

New on this head: Since the previous review, the follow-up resets the optional-payment flag when the form or selection changes, preserves it for retries, and makes the token-cost summary use the same payment decision as dispatch; it also adds regression coverage. At the captured CI state, the Test Suite was queued and Clippy was still in progress, with no failed code check reported.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Review provenance

Source: reviewer 1: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — This changes document-action UI state and token-payment construction across six actions, affecting fee/payment behavior but not directly changing consensus, signing, key handling, or storage.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `src/ui/contracts_documents/document_action_screen.rs`:
- [SUGGESTION] src/ui/contracts_documents/document_action_screen.rs:3289-3300: The retry test can pass even if the retried action includes a token payment
  Impact: A regression could attach a token payment when a user retries a failed optional-cost action with the checkbox unchecked, without failing this test.
  The retry test only verifies that `pay_optional_token_cost` remains false after the broadcast error and after starting another broadcast. Because the fixture starts with `BackendTask::None`, it never calls `create_document_action`, where the checkbox state is converted into `token_payment_info`, so the test would still pass if retry construction attached a token payment. Configure the fixture with an optional-cost document type and valid selections, build the retry through `create_document_action`, and assert that the resulting `DocumentTask::DeleteDocument` contains `token_payment_info: None`; this remains a local unit test with no network call.

@github-actions github-actions Bot removed the waiting-bots Waiting for the review bots to report on this head label Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: lklimek.
Full checklist in the description.

@github-actions github-actions Bot added the ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. label Nov 28, 2026
@github-actions
github-actions Bot requested a review from lklimek November 28, 2026 01:14
@lklimek lklimek added the ui-ux Improves the user interface or makes the app easier to use label Nov 28, 2026
@lklimek
lklimek enabled auto-merge (squash) November 28, 2026 08:16
@github-actions

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. label Nov 28, 2026
@lklimek
lklimek merged commit 425355d into v1.0-dev Nov 28, 2026
21 checks passed
@lklimek
lklimek deleted the feat/document-optional-token-cost branch November 28, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: medium Medium priority ui-ux Improves the user interface or makes the app easier to use

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants