feat: show what a document costs, in Dash and dollars, per index - #4
Merged
Merged
Conversation
@dashevo/evo-sdk is built without dpp's validation feature, so DataContract.fromJSON(json, true, 14) runs the contract parser but not the document meta-schema or the parser checks gated behind that feature. The README, the examples registry and the validation script claimed more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A "GroveDB layout" button in the inspector opens every tree and element Drive writes for the selected document type: the documents by id (and revisions), and for each index the property and value trees down to the [0] where it ends, with each layer's element (count, sum, ranked, ...), its zero-contribution wrapper, the indexes that use it, conditions (the null fallback of a unique index, skipIfAbsent, preallocated, time window overlap) and a link to that kind of layer in the GroveDB structure viewer. The layout comes from documentTypeLayout in @dashevo/evo-sdk (dashpay/platform#5153), so it follows Drive's own rules. It is feature-detected: with an SDK that predates it, the panel says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dashpay/platform#5153 merged with a review fix: a unique index's null fallback no longer repeats the terminal's indexes and notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Selecting a document type shows about what one of its documents costs; Cost opens the breakdown, computed by Drive (documentCreateCost in @dashevo/evo-sdk, dashpay/platform#5159): the first document with a set of index values and a later one with the same values; the storage of the document itself and of each index on its own (the part it shares with other indexes, paid once, and its own); prepaid trees and a ttl type's expiration entry; the processing (exact parts marked, the rest estimated for a number of stored documents, a key type and a fee increase); the contract's action fee, token cost and contest fund; and the refund on delete. "Adjust the document" gives an on/off switch per optional field and a length per variable-size one; fixed-size fields need no input. The Dash price comes from CoinGecko (Coinbase if that fails), kept five minutes, and can be typed in. Feature-detected: with an SDK that predates documentCreateCost the inspector says so. The layout and cost loaders share one local SDK module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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 |
Brings in the inspector's JSON view (#5). The conflicts were both-sides additions: EntityView takes both onShowLayout and version, the README lists both layout.ts and jsonTokens.ts, and styles.css keeps both blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in main's inspector JSON view (#5) through the layout branch. The conflicts were both-sides additions: EntityView takes the layout, cost and version props, the README lists cost.ts and jsonTokens.ts, and styles.css keeps both blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QuantumExplorer
changed the base branch from
feat/document-type-layout
to
main
September 29, 2026 01:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Basic explanation
What this does: Select a document type and the inspector shows about what creating one of its documents costs, in Dash and dollars. Cost (or details) opens the full breakdown:
ttltype's expiration entry;Where the numbers come from: Drive computes them (
documentCreateCost, added by dashpay/platform#5159), with the fee rules it charges by; its tests hold the storage to what Drive charges on real inserts, byte for byte. The Dash price comes from CoinGecko (Coinbase if that fails; both allow browser requests), kept five minutes, and you can type your own.Needs an SDK release: like the GroveDB layout (#3, which this branch builds on),
documentCreateCostis not in the evo-sdk this repo pins. The inspector checks for it and says the estimate arrives with the next SDK release until the dependency is bumped. This PR's base is #3's branch.Before and after
DPNS
domain, in the inspector:DashPay
contactRequest, the storage table of the panel (values new / values stored):DPNS
domainalso lists "Contest fund: 0.1 DASH ($6.43) when the value of parentNameAndLabel is contested", and "In the same epoch: 0.000278 DASH, a year later: 0.000264 DASH" as its refund. The marketplacelisting(ttl) is priced by its lifetime, 136 credits a byte instead of 27,000, with its cleanup prepay and no refund.With the SDK this repo pins today, the inspector says:
What was done?
src/components/CostPanel.tsx(new): the breakdown, the price line with your own price, the assumptions (stored documents, key type, fee increase) and the field controls. It recomputes shortly after each change.src/components/CostLine.tsx(new): the inspector's line with the approximate cost for a document of middle sizes, and a link to the details.src/model/cost.ts(new): the typesdocumentCreateCostreturns, conversion to Dash and dollars, the formatting, each index on its own (sharedBytes + ownBytes), and which fields get a control.src/price.tsandsrc/components/useDashPrice.ts(new): the Dash price from CoinGecko then Coinbase, kept five minutes, and a typed-in price remembered in this browser.src/sdk/cost.ts(new) andsrc/sdk/local.ts(new): the cost call, feature-detected. The layout and cost loaders now share the SDK loading and contract building (src/sdk/layout.tsuses it).src/App.tsx,src/components/InspectorPanel.tsx: the inspector gets the cost line and a Cost button beside GroveDB layout; in compare mode the head's version is priced (the base's when the type was removed), as for the layout.How Has This Been Tested?
npx vitest run: 99 passed. New:src/model/cost.test.tsruns against costs that an SDK built from feat(drive): compute what creating a document costs for the SDKs platform#5159 computed for three examples (src/model/fixtures/document-create-costs.json): marketplacelisting, DPNSdomain, Yappr likestip. It covers the formatting, the credit rate, the ttl pricing, the contest fund, each index on its own adding up to all the storage, and the fields offered a control.src/price.test.tscovers CoinGecko, the fallback to Coinbase, no price and the five minute cache.tscclean,npm run buildclean.node_modules(not committed):listing, DPNSdomainand DashPaycontactRequestshow the inspector line and the panel, with the live CoinGecko price;titleto 120 characters and turningskuoff changes the storage by the expected 43 bytes;🤖 Generated with Claude Code