Repository navigation
refactor(tokens)!: send token actions through platform-wallet - #1128
Claudius-Maginificent wants to merge 51 commits into
Conversation
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 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Protocol version 14 adds a once-per-identity distribution: every identity may claim a fixed amount of a token exactly once. - The token creator offers the distribution with the amount each identity can claim, gated on a new OncePerIdentityDistribution capability. Without it the rules stay version 0, the format older networks accept. The creator and the backend both refuse it on a network that does not accept it, before anything is signed. The registration estimate prices every term, including the distribution's extra fee, from the fee table of the network's confirmed protocol version. - The Claim screen and My Tokens show the distribution. The claim confirmation names the distribution (and, for this one, the amount), and confirming sends exactly the claim that was shown. - A successful claim records an advisory hint per identity and token, at the proved claim's block time. The Claim screen shows it without ever blocking a claim, and dismissing it is saved through a backend task. A node's unproven "already claimed" refusal is never recorded. A claim that succeeded but could not be recorded is reported as made, so the user is not invited to claim again. - Platform's refusals (already claimed, invalid amount) map to dedicated, actionable errors. - A protocol 13 guard checks the distribution is never silently dropped when encoded for protocol 13. - User story TOK-019. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 once-per-identity refusals and the moderation, gas sponsorship and distribution limit refusals each keep their variants, match arms and test cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
… protocol 13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
After the network refuses a second once-per-identity claim, the Claim screen turns Claim off for that distribution while it is open and says why, so a retry is not charged again. The refusal is unproven node output, so it is never saved as the claim hint. The token creator's registration estimate moves into model::fee_estimation, the local refusal and the disabled-checkbox hint reuse TaskError::TokenOncePerIdentityNotSupported's text, and the claim reuses its token id instead of computing it twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…identity branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…able one Both refusals describe the same situation, a network below protocol 14, so they now open the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
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 <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 SDK picks each transition's encoding from the platform version DET passes in, so these tests checked dpp's version tables rather than DET. The mainnet start version and the contest fund cap stay covered by the platform_info and fee_estimation tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK at this pin already tracks the version the network has proven: it records the version of every response whose proof and quorum signature it verified, and a rebuilt connection is a new SDK that starts from nothing. DET's own copy, raised from proved epochs and DPNS reads and reset on every rebuild, duplicated that state. The app now reads the current SDK's verified version; capabilities still stay closed before a version is proven and for one this build does not define, and network info shows the proven number or says none is confirmed. Proved epochs still set the fee multiplier, in epoch order and only on the current connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A connection rebuild never changes the chain, the multiplier changes once per epoch and feeds only fee estimates, so ordering epoch reads and dropping those begun before a rebuild guarded against nothing worth the machinery. A proved epoch read sets the multiplier directly again; an unavailable epoch still keeps the last known value and labels it as such. A rebuild still reads the epoch, so the new SDK proves the network's version again. 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
A released protocol's tables and each network's minimum version are upstream's to keep fixed; DET's start is covered by platform_version_starts_at_the_network_minimum. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The proof verifier asks for contracts at the version it verifies with, which can be newer than the SDK's. System contracts were already served at that version; a saved user contract was decoded at the SDK's version instead, dropping newer-protocol settings such as action fees. The fallback now decodes it at the version asked for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…king Building the recoverable-signature envelope returns an error upstream; it is now reported as the existing message-signing failure, with the detail logged, instead of aborting the signing path. 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
…identity Keeps #1114's deletion of protocol_13_transitions.rs and drops this branch's once-per-identity protocol 13 encoding test with it: that encoding is upstream's to test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
|
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. |
|
🕓 Review not started yet because this PR is a draft.
Commit 8197f9d. Normal review starts when eligible; priority review starts as soon as a slot is available. |
Co-signing a group token action is a token transaction, so the Group Actions screen now gives an identity no wallet in the app holds the same treatment as the other token entry points: the reason is shown above the actions and each "Take Action" button is disabled with it as a tooltip. Availability is read once per selected identity, not per frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Storing an identity needs the wallet backend, so the test uses wired_test_app_context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pins dash-sdk, rs-sdk-trusted-context-provider, platform-wallet and platform-wallet-storage to dashpay/platform#5584 (13c52566, on v5.1-dev 88c31c2b), where ConfigUpdateResult::GroupActionWithDocument holds an Option<Document>: Drive proves a group config update that stays open without the history document, which the SDK used to report as a proof error although Platform accepted it. Only Platform packages move in Cargo.lock; the wallet-storage migrations are unchanged, so the expected fingerprint stays. The pin is not yet on v5.1-dev, so the pin-ancestry guard fails until #5584 lands. DET now treats a settings update without the document as a recorded proposal: it succeeds and keeps the stored token settings until the group closes the action, instead of re-fetching a contract that has not changed. 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 13c52566 to 93776caa, the PR's new head (refactor only: the config-update proof mapping is a TryFrom impl; the public ConfigUpdateResult is unchanged). Only Platform source lines move in Cargo.lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Next steps: still blocked on dashpay/platform#5584 ( 🤖 Co-authored by Claudius the Magnificent AI Agent |
Saved contracts must survive every dashpay/platform bump. The existing round-trip tests encode and decode with the same dpp, so they cannot see a decoder that stops reading bytes an earlier build wrote. Pin the bytes DET writes today (dpp of platform 575d961fe0) for a user contract and the DPNS, DashPay and token-history contracts at protocol 10 to 15, and check each still decodes to the same contract and re-encodes byte for byte at every later protocol version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Move dash-sdk, rs-sdk-trusted-context-provider, platform-wallet and platform-wallet-storage from 575d961fe0 to 0d91c133f0, which adds: - platform#5584: an active group config update proposal is reported as success by the SDK. DET's config update task broadcasts through `broadcast_and_wait::<StateTransitionProofResult>` and never matched `ConfigUpdateResult`, so no call site changes. - platform#5578: the stored contract format with compiled document types. DET keeps writing format version 0/1 and reads with the untrusted decoder, which reads a version 2 contract from its schemas; the pinned-bytes test shows contracts saved before the bump still load. - platform#4740: platform-wallet rescans DashPay contact accounts from the contact request height. No API change for DET. - platform#5602: dashmate only. Cargo.lock changes only the platform git source; the wallet-storage migration fingerprint is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Refresh expected-migration-fingerprint.txt with check-pin-ancestry.sh --update: the fingerprint is unchanged, only the recorded pin moves. List 0d91c133 among the platform revisions that leave the wallet-storage migrations untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The pinned saved-contract bytes covered only a minimal user contract. Contracts users actually save carry more, and a decode break there would make them silently disappear from the app. Add a user contract with a group, mixed-case keywords, a description, `$defs` with a `$ref`, a contested unique index, and a token with group-controlled rules, perpetual and pre-programmed distribution. Its bytes for protocol 10 to 15 were written by the dpp of platform 575d961fe0 (the previous pin), the same way as the existing fixtures, which are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…orm-wallet Restack #1128 on #1153, which brings v1.0-dev ff59f84 and pins Platform to v5.1-dev 0d91c133, the merge of dashpay/platform#5584. This branch drops its own side pin (93776caa): Cargo.toml, Cargo.lock and the migration guards are taken from #1153 as they are. The merged #5584 keeps `ConfigUpdateResult::GroupActionWithDocument(_, Option<Document>)`, so the settings-update code needs no change. #1119 reached v1.0-dev as a squash, so this branch's unsquashed copy of it conflicted. The resolution starts from #1153's tree and reapplies this branch's own changes since ea0485e. Conflicts: - Cargo.toml, Cargo.lock: #1153's pin. - docs/user-stories.md: both sides added TOK-020. v1.0-dev keeps it for non-transferable tokens; this branch's story becomes TOK-021. - src/backend_task/error.rs: keep v1.0-dev's NonTransferableTokenNotSupported and this branch's TokenOperationFailed docs. - src/ui/tokens/token_action_screen.rs: v1.0-dev draws the page heading per branch (#1129); the wallet-availability notice now draws it too. - tests/kittest/tokens_screen.rs: keep v1.0-dev's tests and append this branch's. - claim_tokens.rs, tokens/mod.rs, feature_gate.rs, fee_estimation.rs, model/token.rs, claim_tokens_screen.rs, tokens_screen/mod.rs, token_creator.rs: v1.0-dev's #1119 squash with this branch's changes reapplied cleanly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The token action layout test from v1.0-dev (#1129) used an identity no wallet holds. Token actions now go through the holding wallet, so the scaffold shows why instead of the form, and the test found no form. Register a wallet and link the identity to it before opening the screens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
|
Unblocked: dashpay/platform#5584 is merged into v5.1-dev ( 🤖 Co-authored by Claudius the Magnificent AI Agent |
|
To do here, handed over from #1136: move 🤖 Co-authored by Claudius the Magnificent AI Agent |
TL;DR: Every token action now goes through the upstream
platform-wallettoken API of the wallet that holds the identity, and DET no longer builds or signs token transitions itself. Identities that no wallet in the app holds can still see their tokens, but can no longer act on them; the screens say why. Along the way: rejected token actions now name the action, the mint confirmation names the identity that actually gets the tokens, and the fee shown before an action matches the one reported after it.User story
As a token holder or issuer, I want token transactions to go through the same wallet runtime as the rest of my wallet, so that signing, broadcasting and error reporting behave the same everywhere. I also want to be told up front when an identity can't act.
Scenario
Actual behavior
platform-wallet.Expected behavior
platform-walletusing the holding wallet'sIdentityWallet.Detailed discussion
Token actions via platform-wallet
src/wallet_backend/tokens.rs.WalletBackend::token_actorresolves the holding wallet from the identity's DET wallet link.TokenActorexposes one method per action and callsIdentityWallet::token_*_with_signer._with_signer, not_with_external_signer, so DET still signs with the key the user chose and passesstate_transition_options()(the Developer signing override and the action-fee agreement). The external-signer variants pick the key themselves, drop the options and fetch the contract again.TaskError::TokenActionNeedsWallet, raised before anything is signed.WalletNotLoaded/WalletLockedNotLoadederrors.sign+broadcast_and_wait::<StateTransitionProofResult>path, which also removes thesign(..., version)lines refactor: build Platform types with their upstream constructors #1126 touches.Error mapping
TaskError::from_token_operation(kind, source). The existingfrom_token_operation_failure(label, …)now delegates to it.TokenOperationFailed;TokenOperationRejected, with its own wording per action.TokenOncePerIdentityAlreadyClaimed), unconfirmed results, and logged proof failures.UI: view-only identities
AppContext::token_action_availabilityis the shared check. It is read once when a screen is built or refreshed, not every frame.Mint recipient
model::token::MintRecipientapplies the token's destination rules, the same way Platform and upstream do.Fees
estimate_token_transition().Dependency pin
Cargo.lockand the migration guards come from chore(deps): bump dashpay/platform to v5.1-dev 6323a430 #1153 (v5.1-dev0d91c133, which includes fix(sdk)!: report active group config update proposals as success platform#5584). Group settings updates rely on #5584'sConfigUpdateResult::GroupActionWithDocument(_, Option<Document>).Breaking change
Identities that no wallet in this app holds — masternode/evonode identities and identities imported only by keys — can no longer send token transactions from DET. This was an accepted product decision: actions go through the holding wallet's
IdentityWallet. It's recorded as user story TOK-021 and indocs/ai-design/2026-10-26-tokens-via-platform-wallet/.Known gaps / follow-ups (not in this PR)
amountas the identity's balance;Testing
cargo test --lib --all-features):MintRecipientandTokenActionAvailabilitytruth tables;cargo clippy --all-features --all-targets -- -D warningsandcargo fmt --allare clean.tests/backend-e2e/token_tasks.rs. CI doesn't run it, and it's the only end-to-end check of the switch from the raw broadcast path to typed results for pause/resume/destroy/settings update. Its shared identity belongs to a registered wallet, so the tests need no changes.Breaking Changes
Token actions are refused for identities that no wallet in this app holds (see above).
Checklist
token_tasks.rsrun against testnet🤖 Co-authored by Claudius the Magnificent AI Agent
🤖 Generated with Claude Code
https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q