Repository navigation
feat(documents): recognise indexOnly document types and delete their entries by values - #1108
Claudius-Maginificent wants to merge 102 commits into
Conversation
Pin dash-sdk, rs-sdk-trusted-context-provider, platform-wallet and platform-wallet-storage to dashpay/platform#4764 head 4d1db8a5, which contains the full v4.3-dev branch plus the available-signer key selection fix DET relies on for HASH160 DashPay profile keys. This commit alone does not compile: protocol version 14 API changes are adapted in follow-up commits on this branch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Make DET compile against dashpay/platform v4.3-dev without hiding the new variants behind catch-alls: - same_key compares identity public keys of either version through one identity tuple. disabled_at, total_budget and expires_at are state that Platform moves (disable, IdentityKeyLimitsUpdate); whether a key has a budget or an expiry is fixed for its life and still identifies it. A V1 key without limits equals its V0 wire form. - Key info shows contract-group bounds. - PlatformWalletError::TokenOperationFailed is classified through the normal SDK error mapping; an otherwise unclassified failure becomes the new TaskError::TokenOperationFailed, which names the operation. - StateTransitionCreationOptions carries no action fee agreement from the signing-override helper; document transitions add their own. - Tests and fixtures cover the new enum variants. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…igning keys Protocol version 14 lets an authentication key carry a lifetime budget and an expiry (IdentityPublicKey::V1) and be bound to a contract, a document type or a contract group. Choosing a signing key by purpose, security level and key type alone could pick a key Platform refuses. - model::identity_key_usability holds the pure rules, mirroring upstream platform-wallet key selection: skip disabled and expired keys, keep a contract-bound key to its contract (never on a transition outside a batch), never auto-pick a contract-group bound key, and prefer an unlimited key over a limited one. - Every automatic signing-key pick (identity transfer and withdrawal, contract register and update, add key, DPNS, document actions, token screens, DashPay) goes through it with the right signing scope. - Manual key choosers still offer limited, expired and out-of-bounds keys, tagged in the list, with a warning under the chooser saying what the network will do. - Key info shows the spending limit with what is left of it (new IdentityTask::FetchKeyRemainingBudgets over the getIdentityKeysRemaining Budgets query) and the expiry; the key list marks expired and limited keys. - Tests pin the selection rules, the manual-selection caveats, decoding of a real v0.9.3 identity blob (V0 keys, contactRequest bounds) and the round trip of V1 keys and contract-group bounds. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Protocol version 14 adds a token distribution that pays every identity a fixed amount exactly once (TokenDistributionRules::V1). - View: token details state whether and how much each identity can claim. - Create: the token creator offers the distribution with a validated amount (1..=i64::MAX, model::token). Without it the rules stay version 0, the only format older networks accept; with it they become version 1. The option is gated on the connected protocol version (new FeatureGate::TokenOncePerIdentityDistribution) and the registration fee estimate includes its surcharge, priced from the connected network's fee table (AppContext::connected_platform_version). - Claim: the claim screen offers the distribution, pre-selects the only distribution a token has, and explains what the claim pays. - Platform has no query for "has this identity claimed", so DET keeps a per-identity hint in the app k/v store, written when a claim succeeds or is refused as already taken (new TaskError::TokenOncePerIdentityAlready Claimed). The claim screen shows when the claim was taken and disables claiming. - FeatureGate::IdentityKeyLimits is added alongside for the key limits UI. - Tests cover amount validation, V0/V1 rule building, stored token config round trips for both rule versions, the claim hint, the error mapping, the protocol gates and the creator refusing the option below protocol 14. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Protocol version 14 lets a document type charge a fee per action, split
between the contract owner and its moderators, and every transition paying
one must carry the fee agreement the user signed.
- model: `document_action_fee_quote` prices a declared fee at the current
fee multiplier and builds the agreement; the multiplier increase the user
accepts is the named constant
`ACTION_FEE_MULTIPLIER_INCREASE_TOLERANCE_PERCENT` (20%).
- documents screen: shows the contract fee next to the estimated fee and
asks for confirmation naming the total, the owner/moderator split and the
most that can be charged ("up to N DASH"); the confirmed agreement is the
one broadcast.
- documents screen: an optional token cost can be left out; the action then
pays its gas in credits.
- backend: the six mutating `DocumentTask` variants carry the agreement and
fall back to one priced at the cached multiplier for non-UI callers.
- platform info: restore the live `ExtendedEpochInfo::fetch_current` fetch
(dashpay/platform#4231 is in the pin), so fee agreements are signed
against the network's multiplier; a failed fetch keeps the last known one
and says so.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…rrors Each new rejection DET flows can hit gets a dedicated `TaskError` variant with the SDK error as its source and a message saying what happened and what to do: - signing keys: expired, budget exhausted, budget exceeded, used outside its contract bounds, contract-bound key on a non-batch action; - document action fees: agreement missing, agreement mismatch, fee multiplier rose past the agreed tolerance; - contract moderation: identity banned, identity suspended (until when); - gas sponsorship: sponsor balance too low, payer not offered, mixed payers in one batch; - contract authoring: immutable property changed, deletable reference to a non-deletable type, moderator fees without moderation, invalid once-per-identity amount, pre-programmed distribution over the limit. Also note in the withdrawal history that a failed withdrawal's credits are not returned, and log an overflowing shielded balance total at warn. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Protocol version 14 lets an authentication key below MASTER carry a total spending budget and an expiry, raised later by a key limits update. - model: `identity_key_limits` holds the pure rules Platform enforces (who may carry limits, non-zero budget, future expiry, raise-only updates, an expired key must be extended before it is only topped up) plus the choice of signer (MASTER, else an unlimited unbound CRITICAL key), so a refused - and still charged - request never leaves DET. - Add Key screen: optional spending limit and "expires after N days" for keys that may carry them; disabled with an explanation on networks without key limits. - Key Info screen: "Raise Limits" adds to the spending limit and/or extends the expiry, then shows the stored key and its new remaining budget. - backend: `IdentityTask::RaiseKeyLimits` computes absolute limits from the key as Platform holds it and calls `update_key_limits`; adding a key with limits is gated on protocol version 14 and validated first. - errors: typed variants for the key limits consensus rejections. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Document action fees collect in a contract's owner pot and moderators pot (protocol version 14); a recipient pays a pot out once per epoch. - Contracts screen: "Fee Pots" (shown where the network keeps them) lists both pots of a loaded contract with their last payout, and lets an identity that receives a pot claim it. - backend: `ContractTask::FetchContractFeePots` and `ClaimContractFees` (signed by a CRITICAL key not bound to a contract, chosen up front); the claimant's new balance is stored. - gate: `FeatureGate::ContractFeePots` on upstream's `CONTRACT_FEE_CLAIM_INITIAL_PROTOCOL_VERSION`. - errors: typed variants for claims that are not allowed, already made this epoch, or have nothing to pay. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…n stories IDN-022..024 (key spending limits and expiry, raising them, signing-key choice), TOK-019 (once-per-identity distribution), DOC-010..012 (document action fee agreement, optional token cost, contract fee pots). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
21d70b3c restores the IdentitySettersV0 import that the v4.3-dev merge in dashpay/platform#4764 dropped; 4d1db8a5 did not compile. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
sdk_error_user_message() does not exist; the SDK error mapping lives in the From<SdkError> impl. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
c5c4d316 is the head of dashpay/platform#4764 (fix/dashpay-available-signer): 21d70b3c plus signer-aware identity key selection in platform-wallet (277b5356, 088499f4). The pin still sits on an unmerged PR branch; re-pin to v4.3-dev once #4764 merges. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Automatic key selection preferred an unlimited key without asking whether this device holds its private half, so an identity imported with only a delegated limited key (the protocol version 14 application-key case) failed to sign although a usable key was there. Selection now mirrors upstream platform-wallet's signer-aware `usable_authentication_key`: qualifying unlimited keys first, then limited ones, and the first this device can sign with wins. Callers go through `QualifiedIdentity::signing_key_now`, which checks `can_sign_with`; availability never widens eligibility. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signing-key selection now requires the private half on this device; the test identity holds its keys, and a new case pins that a held limited key beats an unlimited key held elsewhere. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The chooser listed the copy of each key stored next to its private half. After a limits raise that copy is stale, so an extended key still showed as expired and a raised budget kept its old amount, and the stale copy was handed to the backend. `QualifiedIdentity::live_public_key` resolves a stored copy to the live key (same key, limits may differ); the chooser labels, warns about and selects the live key, and refreshes a stale selection. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Protocol version 14 (contract bounds validation v2) admits AUTHENTICATION keys below MASTER bound to a contract or document type, with or without limits - the typical delegated application key. The Add Key screen only offered bound ENCRYPTION/DECRYPTION keys and hid the limits when bounds were on. - gate `ContractBoundAuthenticationKeys`, keyed on upstream's `validate_identity_public_key_contract_bounds` version (>= 2) of the connected platform version; - model `contract_bounds_allowed`; the backend refuses a bound authentication key where the network does not admit one; - Add Key offers AUTHENTICATION (CRITICAL/HIGH/MEDIUM) with bounds where admitted, and limits whenever the purpose and level allow them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
With no agreement passed, the document tasks derived one from the cached fee multiplier and signed it, so any caller that skipped the confirmation would pay a contract fee the user never saw. `checked_action_fee_agreement` (model) now requires the caller's agreement whenever the document type charges a fee for the action, and refuses an agreement to another fee (the contract changed after confirmation) before anything is signed. Typed `ActionFeeAgreementError` via `TaskError::ActionFeeAgreement`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… exactly - A refusal because network fees rose past the agreed tolerance carries the multiplier the network charges now; the document task adopts it, so the retry quotes and agrees to the current fee instead of failing again on a stale one. The message says the fee was updated and to try again (the pointer to a non-existent "network status" control is gone). - The confirmation reads the pricing from the agreement, so a tiny multiplier-priced fee whose tolerance rounds away is no longer called fixed, and it is built from complete sentences with named placeholders (owner-only, moderators-only and split variants). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- Record the hint only from a successful claim, whose result is proof-backed, at the block time of the proved claim document (the local clock when it carries none). An "already claimed" refusal is an unproven node error and upstream offers no proved claim-status query, so it no longer marks an entitlement as spent on this device. - The Claim screen warns that the identity may have already claimed but never disables Claim, and the user can dismiss the note. - `RegisterTokenContract` refuses version 1 distribution rules (a once-per-identity distribution) where the network does not accept them, as the authoritative backend check. - Tests for every hint branch and the backend gate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…es exactly
- Messages for a changed immutable property, a non-deletable document
reference and moderator fees without moderation no longer interpolate
names decoded from the node's (unproven) consensus error; the names stay
in the variant for Debug and logs only, so a hostile node cannot inject
text into a trusted banner.
- Upstream names a failed token operation only by a `&'static str` label.
Every label it uses is mapped; an unknown one is logged at warn and kept
as `TokenOperationKind::Unrecognized { label }` (Debug only) instead of
being silently folded into a generic kind.
- Raising key limits for an identity the network does not hold reports
`IdentityMissingOnNetwork`, not "not found in your local wallet".
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…shown Raising a key's limits widens its spending authority and is signed with the identity's master (or unlimited critical) key, but went out on one click, and the backend recomputed the new limits from the key as Platform held it - so a key raised elsewhere meanwhile got a total the user never saw. - `KeyLimitsRaise` (model) carries the limits the user saw, the absolute limits to set and the signing key. - Raise Limits opens a confirmation naming the resulting total spending limit and expiry and the signing key; confirming dispatches exactly that. - The backend sends it unchanged. If Platform's limits differ from the reviewed ones, nothing is signed: the live key replaces the local copy and the raise is refused (`LimitsChanged`), so the screen quotes again. The signing key must still be the reviewed one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- The pots are read with the response metadata, whose epoch is the current one; a pot already paid out in it shows Claim disabled with an explanation instead of sending a paid refusal. - The Claim gating (recipients, selected identity, empty pot, epoch, claim in flight) is a pure `claim_blocked_reason`, covered by tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The platform pin sits on fix/dashpay-available-signer (dashpay/platform#4764), which carries all of v4.3-dev plus the available-signer fix DET depends on, so it is not yet an ancestor of any release line. The wallet-storage migration fingerprint is unchanged (18 files). Temporary: once #4764 merges, re-pin to a commit on v4.3-dev, set the target branch to v4.3-dev and rerun --update. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Pins the key chooser's view: a stale stored copy of an expired key is resolved to the live, extended key before its caveats are computed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Bound authentication keys (IDN-022), raise confirmation (IDN-023), signer-aware key choice (IDN-024), advisory once-per-identity note (TOK-019), fee retry and changed-fee handling (DOC-010), per-epoch fee pot claims (DOC-012). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…m#4764 merges Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The withdraw screen's Check Owner Key / Check Payout Address Key buttons (and the transfer screen's Manage Transfer Key) render exactly when this device cannot sign, so a signer-aware lookup left them dead. They now use QualifiedIdentity::matching_key_now, an informational lookup that ignores private-key availability. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…a refusal The multiplier a fee refusal names comes from the broadcasting node and is unproven, so it no longer feeds the app-wide fee cache. The refusal now only triggers a proved ExtendedEpochInfo refresh (AppContext::refresh_current_epoch, shared with Platform Info), whose multiplier is adopted. If that refresh fails, the cache keeps its value and the new DocumentActionFeeMultiplierNotRefreshed error says the fee was not updated. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Keeps clippy's result_large_err quiet for AppContext::refresh_current_epoch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…k for a new review The backend used to require the signer the screen reviewed to be Platform's first choice, so a stale local key set produced a false "import a master key" refusal. It now accepts the reviewed signer while Platform still accepts it (enabled MASTER, or unlimited and unbound CRITICAL, held here). Otherwise nothing is signed and no other key is picked: the live keys are stored locally and KeyLimitsError::SignerChanged asks the user to review the change again. The key info screen already reloads the identity on a refused raise, so the next review quotes the live signer. NoKeyLimitsSigningKey remains only for an identity with no usable signer at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Mark where each deferred feature would land with a TODO pointing to the issue that tracks it: the DPNS username marketplace (#1103), DashPay invitations and withdrawals to a contact (#1104), and moving credits between identities and the shielded pool (#1105). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #1099 and the other base changes up to 4c38d4c. Conflict in src/sdk_wrapper.rs, both sides kept: the base moves the request settings into a shared request_settings() helper and adds a test that pins how a proof read sent before the masternode list is ready bans the node. This branch keeps the SDK unpinned, seeded from a carried protocol version (sdk_seed), instead of default_platform_version. initialize_sdk now uses the helper with this branch's signature, and the test module holds both sides' tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moves dash-sdk, rs-sdk-trusted-context-provider, platform-wallet and platform-wallet-storage from a0d7b6f to 132ae31 (5.0.0-rc.8). Only the 31 Platform packages move in Cargo.lock; rust-dashcore, GroveDB and every other dependency stay where they were. No migration under rs-platform-wallet-storage changes in this range, so the recorded fingerprint is unchanged and only the recorded pin moves. The range versions the non-unique public key hash identity lookup: the SDK sends the V0 request, whose proved answer carries separate index and identity proofs, until the network has proven a protocol version that serves V1. It also verifies operation proofs signed by older and newer protocol versions. DET's NonUniquePublicKeyHashQuery callers need no change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fier 5.0.0-rc.8 adds verify_full_identity_by_non_unique_public_key_hash_two_proofs to the protocol 13 verify table, at version 0. It checks the two-proof answer to a version 0 identity lookup, the shape protocol 13 nodes send. The field is additive and every other protocol 13 table is unchanged, so the snapshot is re-recorded. The guard's note now says that #5515 brings back the response field 2 that #5361 removed, and that only a live check against mainnet nodes shows the SDK accepts their proofs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…entries by values Protocol 14 indexOnly document types keep only index entries. Platform rebuilds their rows from those entries, and a delete has to name the entry by the values it was created with, not by id. - model/index_only_document: detection, protocol gate, values <-> JSON, and typed pre-sign checks that mirror the SDK's index_only_delete_document refusals. - DocumentTask::DeleteIndexOnlyDocument builds the delete with DocumentDeleteTransitionBuilder::from_values and keeps the token payment, options and action-fee agreement. Delete-by-id, replace, transfer, purchase and set-price refuse indexOnly types up front (IndexOnlyDocumentReadOnly). - New TaskError variants: IndexOnlyDeleteNotSupported, IndexOnlyDocumentReadOnly, IndexOnlyDeleteRefused. - FeatureGate::IndexOnlyDocumentDelete, derived from the platform version's indexOnly-delete serialization bounds. - Document action screen: indexOnly entries are labelled read-only. Delete fetches your entries, prefills their values as editable JSON, and confirms with a warning that a mismatched value is refused after the fee is paid. - The documents browser labels indexOnly results. - DOC-013 user story. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. Comment |
|
🕓 Review not started yet because this PR is a draft.
Commit 3f87059. Normal review starts when eligible; priority review starts as soon as a slot is available. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
The implementation correctly adds value-based index-only deletion and preserves fee, token-payment, and protocol-gating behavior, but two blocking state and encoding defects can cause a valid-looking delete to be refused after the fee is charged. Two additional user-facing consistency issues should also be corrected. The Test Suite and Clippy checks passed; the Platform pin guard failed during checkout before its validation steps and does not appear related to the code changes.
🔴 2 blocking | 🟡 2 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Clear the selected index-only entry when the identity changes
src/ui/contracts_documents/document_action_screen.rs:384-387
The identity selector clears fetched_documents but leaves index_only_entry and index_only_values_input intact. After identity A selects an entry, switching to identity B leaves the delete form broadcastable with A's entry while create_index_only_delete_task uses B as the owner and signer. The backend validation does not detect this owner/value mismatch, so Platform can refuse the transition after the action fee is charged. Clear the selected entry whenever the identity changes, just as the contract/document-type scope change already does.
self.fetched_documents.clear();
self.clear_index_only_entry();
source: gpt-6.1-sol (phase2-reviewer: rust-quality)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff substantially changes document deletion and state-transition construction in src/backend_task/document.rs, including signing and fee-bearing funds movement, so it directly affects a critical funds-movement and signature surface. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/ui/contracts_documents/document_action_screen.rs`:
- [BLOCKING] src/ui/contracts_documents/document_action_screen.rs:384-387: Clear the selected index-only entry when the identity changes
The identity selector clears `fetched_documents` but leaves `index_only_entry` and `index_only_values_input` intact. After identity A selects an entry, switching to identity B leaves the delete form broadcastable with A's entry while `create_index_only_delete_task` uses B as the owner and signer. The backend validation does not detect this owner/value mismatch, so Platform can refuse the transition after the action fee is charged. Clear the selected entry whenever the identity changes, just as the contract/document-type scope change already does.
In `src/model/index_only_document.rs`:
- [BLOCKING] src/model/index_only_document.rs:112-143: Preserve byte-array values across the JSON editor round-trip
`to_json()` serializes `Value::Bytes` as a base64 string, while `from_json()` restores that string as `Value::Text`. The pinned Platform sanitizer then tries hexadecimal decoding before base64 decoding. For an unconstrained byte array such as `69 b7 1d 69 b7 1d`, whose base64 representation is `abcdabcd`, the editor round-trip changes the value to `ab cd ab cd`. The same conversion is repeated while building the delete transition, so an unchanged auto-filled entry can pass the local required-field checks but refer to different index values and be refused after the fee is charged. Encode byte arrays in an unambiguous schema-aware form, such as JSON numeric byte arrays, and add coverage for an unconstrained or otherwise ambiguous byte-array schema.
- [SUGGESTION] src/model/index_only_document.rs:55-56: Make the non-deletable error actionable
`IndexOnlyDeleteError::NotDeletable` is displayed directly by the delete screen, but its message only states that deletion is impossible and gives the user no way forward. This path is reachable for an index-only type whose `canBeDeleted` flag is disabled. Tell the user to select a different document type and try again.
In `src/ui/contracts_documents/contracts_documents_screen.rs`:
- [SUGGESTION] src/ui/contracts_documents/contracts_documents_screen.rs:877-880: Do not promise index-only deletion on unsupported networks
The browser notice unconditionally says that index-only entries can be deleted, but the action screen disables deletion when `FeatureGate::IndexOnlyDocumentDelete` is unavailable. On older protocol networks, the browser therefore promises an operation that the next screen refuses. Qualify the notice so it states that deletion is available only on networks supporting index-only deletion, or make the notice conditional on the same capability gate.
| pub fn to_json(&self) -> String { | ||
| let mut object = serde_json::Map::new(); | ||
| for (name, value) in &self.values { | ||
| // A platform value always has a JSON form; one that could not be | ||
| // shown is left out, and the check reports it if it is required. | ||
| if let Ok(json) = serde_json::to_value(value) { | ||
| object.insert(name.clone(), json); | ||
| } | ||
| } | ||
| if let Some(created_at) = self.created_at { | ||
| object.insert(CREATED_AT.to_string(), created_at.into()); | ||
| } | ||
| serde_json::to_string_pretty(&serde_json::Value::Object(object)).unwrap_or_default() | ||
| } | ||
|
|
||
| /// Parses values edited as JSON, splitting `$createdAt` off. Identifiers | ||
| /// and byte arrays may stay in their text form: the delete converts them | ||
| /// with the document type's schema, like a create does. | ||
| pub fn from_json(json: &str) -> Result<Self, IndexOnlyDeleteError> { | ||
| let parsed: serde_json::Value = serde_json::from_str(json) | ||
| .map_err(|source| IndexOnlyDeleteError::InvalidJson { source })?; | ||
| let mut values: BTreeMap<String, Value> = serde_json::from_value(parsed) | ||
| .map_err(|source| IndexOnlyDeleteError::NotAnObject { source })?; | ||
| let created_at = values | ||
| .remove(CREATED_AT) | ||
| .map(|value| { | ||
| value | ||
| .to_integer::<TimestampMillis>() | ||
| .map_err(|_| IndexOnlyDeleteError::InvalidCreatedAt) | ||
| }) | ||
| .transpose()?; | ||
| Ok(Self { values, created_at }) |
There was a problem hiding this comment.
🔴 Blocking: Preserve byte-array values across the JSON editor round-trip
to_json() serializes Value::Bytes as a base64 string, while from_json() restores that string as Value::Text. The pinned Platform sanitizer then tries hexadecimal decoding before base64 decoding. For an unconstrained byte array such as 69 b7 1d 69 b7 1d, whose base64 representation is abcdabcd, the editor round-trip changes the value to ab cd ab cd. The same conversion is repeated while building the delete transition, so an unchanged auto-filled entry can pass the local required-field checks but refer to different index values and be refused after the fee is charged. Encode byte arrays in an unambiguous schema-aware form, such as JSON numeric byte arrays, and add coverage for an unconstrained or otherwise ambiguous byte-array schema.
source: gpt-6.1-sol (phase2-reviewer: general, rust-quality)
| fn index_only_results_notice(document_type: &DocumentType) -> Option<&'static str> { | ||
| is_index_only(document_type.as_ref()).then_some( | ||
| "Entries of this document type are rebuilt from the network's indexes. They are read-only: they can be deleted, but not edited, replaced or transferred. Their IDs are computed from the entry and do not identify a stored document.", | ||
| ) |
There was a problem hiding this comment.
🟡 Suggestion: Do not promise index-only deletion on unsupported networks
The browser notice unconditionally says that index-only entries can be deleted, but the action screen disables deletion when FeatureGate::IndexOnlyDocumentDelete is unavailable. On older protocol networks, the browser therefore promises an operation that the next screen refuses. Qualify the notice so it states that deletion is available only on networks supporting index-only deletion, or make the notice conditional on the same capability gate.
| fn index_only_results_notice(document_type: &DocumentType) -> Option<&'static str> { | |
| is_index_only(document_type.as_ref()).then_some( | |
| "Entries of this document type are rebuilt from the network's indexes. They are read-only: they can be deleted, but not edited, replaced or transferred. Their IDs are computed from the entry and do not identify a stored document.", | |
| ) | |
| "Entries of this document type are rebuilt from the network's indexes. They are read-only. On networks that support index-only deletion, you can delete them by their values, but not edit, replace or transfer them. Their IDs are computed from the entry and do not identify a stored document.", |
source: gpt-6.1-sol (phase2-reviewer: general, rust-quality)
| #[error("Entries of this document type cannot be deleted.")] | ||
| NotDeletable, |
There was a problem hiding this comment.
🟡 Suggestion: Make the non-deletable error actionable
IndexOnlyDeleteError::NotDeletable is displayed directly by the delete screen, but its message only states that deletion is impossible and gives the user no way forward. This path is reachable for an index-only type whose canBeDeleted flag is disabled. Tell the user to select a different document type and try again.
| #[error("Entries of this document type cannot be deleted.")] | |
| NotDeletable, | |
| #[error("Entries of this document type cannot be deleted. Select a different document type, then try again.")] | |
| NotDeletable, |
source: gpt-6.1-sol (phase2-reviewer: rust-quality)
On protocol 14 a document type can charge an action fee. A fee quote holds the declared owner and moderator parts at the fee multiplier the user saw and the most it can become; its agreement tolerates a 20% multiplier rise for a multiplier-priced fee. The backend never agrees on the user's behalf: an action whose agreement is missing or names another fee is refused before signing. A refusal for a risen multiplier refreshes the multiplier from a proved epoch, so trying again quotes the current fee; if that refresh fails the user is told the fee could not be updated. A protocol 13 guard checks that a fee agreement is refused locally there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map a missing or mismatched fee agreement, a changed contract fee and a multiplier risen past the tolerance to dedicated TaskError variants, plus one for a multiplier that could not be refreshed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
… action The estimated-fee panel shows the contract fee split between owner and moderators. Sending asks for confirmation naming the fee, the ceiling and the tolerance (or that the fee is fixed); confirming sends the action built when the dialog opened. An optional token cost can be skipped, the gas then being paid in credits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The optional token cost (the "Pay the token cost" option, DOC-011) moves to its own branch, so every document action builds its token payment as before and this branch only adds the contract action fee agreement. The network's refusals of a missing or changed fee agreement now show the same text as the app's own check, which tells the user to reload the contract first, since either way the local copy may be out of date. The fee estimation imports sit in the file's top import block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…ment action fee branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Loading a contract that is already stored keeps the stored copy, so the fee agreement refusals and DOC-010 now tell the user to remove the contract on the Contracts screen and load it again, an action the app offers, instead of an unnamed reload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Conflicts: platform_info.rs doc comment (kept base wording); protocol_13_transitions.rs deleted upstream, deletion kept. This PR's test there (a_fee_agreement_is_refused_on_protocol_13) exercised the SDK's protocol-13 encoding guard, not DET logic, so it is dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…tion-fees Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…t-action-fees Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Restack #1108 off the stale chore/bump-platform-v4.3 base onto #1122, itself on #1117. The resolution starts from #1122's tree (its Platform pin and everything #1117 and v1.0-dev changed) and reapplies only this branch's own commit, 0d29892. What the v4.3 base brought and v1.0-dev or #1117 supersedes (its Platform pin, contract fee pots) is dropped. Conflicts: - src/backend_task/error.rs: keep only the indexOnly variants; the contract fee pot variants came from the v4.3 base. - src/context/feature_gate.rs: the IndexOnlyDocumentDelete capability reads the proven protocol version and fails closed like #1117's capabilities; platform_protocol_version() no longer exists. Its tests join #1117's per-gate and unknown-version tests. - src/ui/contracts_documents/contracts_documents_screen.rs: drop the v4.3 FeatureGate import; put the misplaced doc comment back on doc_to_filtered_string. - src/ui/contracts_documents/document_action_screen.rs: keep #1122's fields and tests and add this branch's. The optional token cost toggle belongs to #1124, so the indexOnly delete charges a token cost like #1122's delete by id; tests prove the protocol version instead of setting it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…documents Stack #1108 on #1124 as well as #1122. Both build on #1117, so the Platform pin stays #1117's. Conflicts (both sides added next to each other; kept both): - docs/user-stories.md: DOC-010 (#1122), DOC-011 (#1124), DOC-013 (this branch), in order. - src/ui/contracts_documents/document_action_screen.rs: #1122's fee confirmation fields and #1124's pay_optional_token_cost; #1124's token_payment beside #1122's PendingActionFeeConfirmation; #1122's action_fee_quote beside #1124's token_payment_for; all three branches' tests. The indexOnly delete now charges its token cost through token_payment_for, so an optional deletion cost the user chose not to pay is not carried, as for every other action. Its form shows #1124's "Pay the token cost" option already. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The kept-cost half of the indexOnly delete test compared the result with the helper that builds it. Assert the concrete payment instead: the token at position 0, capped at the cost's amount. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
TL;DR: Protocol 14 adds document types that exist only as index entries. Dash Evo Tool now recognises them, marks their entries read-only so you are not offered edit, transfer or sale, and lets you delete your own entries by the exact values they were created with. Older networks don't get the option.
User story
As a Platform developer, I want to see and delete my entries of index-only document types, so that I can manage data in protocol 14 contracts without paying for actions the network will always refuse.
Scenario
Actual behavior
Index-only entries look like ordinary documents. Replace, transfer, purchase and set-price are offered but always refused by the network after the fee is paid, and delete by ID cannot work because these entries are addressed by their values, not an ID.
Expected behavior
Index-only entries are labelled read-only. Delete fills in the entry's values, checks them before anything is signed, and warns that a value differing from the original entry makes the network refuse the delete while still charging the fee.
Detailed discussion
Stacked atop #1124 (
feat/document-optional-token-cost, the PR base) and #1122 (feat/document-action-fees), both on #1117 (fix/protocol14-signing-key-selection). Merge #1117, #1122 and #1124 first. The Platform pin is #1117's (v5.1-dev575d961); this PR has none of its own.DocumentTypeV2Getters::index_only(); the delete is available only where the platform version definesdocument_index_only_delete_state_transition(protocol 14). NewFeatureGate::IndexOnlyDocumentDelete. Like fix(identity): choose signing keys Platform accepts on protocol 14 #1117's capabilities, it reads the network's proven protocol version and fails closed both before one is proven and for a version newer than this build knows.src/model/index_only_document.rswith values extraction, JSON round-trip ($createdAtsplit off) andvalidate_index_only_delete, returning a typedIndexOnlyDeleteErrorwith the same checks and order as the SDK.DocumentTask::DeleteIndexOnlyDocumentbuilds the transition with the SDK'sDocumentDeleteTransitionBuilder::from_valuesand DET's identity signer, through a sharedsend_document_deletehelper, so token payment, options and action-fee agreement match the by-ID delete. Its token payment follows feat(documents): let the user skip an optional token cost #1124's "Pay the token cost" choice, and its action-fee agreement comes from feat(documents): agree to document action fees before broadcasting #1122's confirmation. The platform-walletdelete_document_by_values_with_signerwrapper is not used: it cannot carry token payment or fee agreement, needs anIdentityWalletthat key-imported identities lack, and reports refusals as strings. Replace, transfer, purchase, set-price and by-ID delete refuse index-only types before any fetch or signing.TaskError::IndexOnlyDeleteNotSupported,IndexOnlyDocumentReadOnly,IndexOnlyDeleteRefused.Known limitations
$ownerIdcannot list your entries, so it has no delete from the UI.AppContext::platform_version()(the screen's value check) and the SDK's version (the backend). They agree in normal operation. If they ever diverge, the backend refuses withIndexOnlyDeleteNotSupportedbefore anything is signed. This is not new in this PR.Testing
--all-features --lib --tests -- -D warningsclean; document, index-only and feature-gate library tests pass (83); contract screen kittest passes.🤖 Co-authored by Claudius the Magnificent AI Agent
🤖 Generated with Claude Code
https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q