Skip to content

feat(swift-sdk): expose the base contested-document contest fund (and the fund to join) to apps #5510

Open

Description

@romchornyi

Expected Behavior

The Swift SDK can tell an app what a contested DPNS name (or any contested document) pays into its contest on the network it is connected to: the base contest fund for the SDK's protocol version, and ideally the fund to join a given contest right now. The app then keeps only its own headroom, presentation and confirmation logic.

Current Behavior

The SDK exposes neither value, so a wallet has to copy the consensus fee table into app code.

  • The base fund lives in vote_resolution_fund_fees.contested_document_vote_resolution_fund_required_amount (rs-platform-version). It is 0.2 DASH below protocol 14 and 0.1 DASH from 14 on. rs-dpp resolves it in required_vote_resolution_fund / required_vote_resolution_fund_to_join, and rs-sdk has Sdk::contest_fund_to_join. None of these reaches rs-sdk-ffi, rs-platform-wallet-ffi or SwiftDashSDK.
  • From Swift, the only contact point is the maxContestFund parameter on registerDpnsName and createDocument. That parameter states a maximum; it gives the app no figure to show or to fund an identity with.
  • dashwallet-ios therefore keeps a version → fund mapping of its own, ContestedUsernameFee.Amounts.forProtocolVersion (0.2 below 14, 0.1 from 14). That mapping drives the displayed cost, the amount a new identity is funded with, the existing-identity top-up, and the maxContestFund the app states. If a later protocol version changes the fund, the app still compiles and states the wrong figure.

Possible Solution

Add a getter through rs-sdk-ffi (or rs-platform-wallet-ffi) and SwiftDashSDK. It returns the base contested-document fund, required_vote_resolution_fund for the DPNS domain type, for the protocol version the SDK currently prices transitions with. An overload that takes an explicit protocol version would also work. Apps would read it the same way they read refreshProtocolVersion().

Optional, and useful for showing the real price before a user confirms: expose contest_fund_to_join for a DPNS label, i.e. the fund including the doubling past 250 contenders. That lets an app state the live price instead of having a doubled contest refused.

Alternatives Considered

  • Keep the app-side mirror. This is what dashwallet-ios#1199 does today. It works for protocols 13 and 14 but has to be updated by hand for every fee change.
  • Leave maxContestFund nil. The SDK then states the live fund to join, which is unbounded from protocol 14, so the app cannot cap the spend at what it showed.

Additional Context

Raised in the dashwallet-ios#1199 review (contested username cost follows the Platform protocol version): dashpay/dashwallet-ios#1199 (comment). Related: #5039 added the maxContestFund option. Checked against the commit dashwallet-ios pins (41b6acb39e) and against v5.1-dev (033ecaee2f); neither exposes a fund getter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions