Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 13 additions & 28 deletions packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,13 @@ public final class SDK: @unchecked Sendable {
/// This is suitable for mobile applications where proof verification would be resource-intensive.
///
/// `platformVersion`:
/// - `0` (default) — pick a network-appropriate version: PV 11 for the
/// public networks still on pre-v3.1 drive-abci (mainnet, testnet),
/// PV 12 (latest) for the leading-edge networks (devnet, regtest).
/// This avoids the V0/V1 `getDocuments` wire-format mismatch that
/// would otherwise make Platform queries fail with
/// `"decoding error: could not decode data contracts query"` on the
/// public networks until they roll forward. Override by passing an
/// explicit non-zero value.
/// - `0` (default) — let the Rust SDK seed at the per-network minimum
/// protocol version (mainnet 11, testnet/devnet/regtest 12) with
/// auto-detect on, ratcheting up as the network reports newer
/// versions. The per-network floor encodes the V0/V1 `getDocuments`
/// wire format (mainnet floor 11 = V0 until mainnet upgrades;
/// testnet floor 12 = V1), so this picks the right wire without a
/// Swift-side network→version map.
/// - non-zero — pin the SDK to this exact `PlatformVersion`.
public init(network: Network, platformVersion: UInt32 = 0) throws {
var config = DashSDKConfig()
Expand All @@ -264,26 +263,12 @@ public final class SDK: @unchecked Sendable {
config.skip_asset_lock_proof_verification = false
config.request_retry_count = 1
config.request_timeout_ms = 8000 // 8 seconds
let resolvedPlatformVersion: UInt32
if platformVersion != 0 {
resolvedPlatformVersion = platformVersion
} else {
switch network {
case .mainnet, .testnet:
// TODO(platform-version-bump): bump mainnet/testnet to 12
// (or whatever PV is current) once drive-abci 3.1+ has
// rolled out on those networks and the new
// `getDocuments` V1 wire format is on by default. The
// trigger is: a HardFork shipping the V1 wire format
// becomes active on mainnet/testnet. Until then, pinning
// 11 keeps the SDK speaking the V0 protocol the active
// tenderdash quorums understand.
resolvedPlatformVersion = 11
case .devnet, .regtest:
resolvedPlatformVersion = 12
}
}
config.platform_version = resolvedPlatformVersion
// `0` is passed straight through: the FFI `apply_version(builder, 0)`
// returns the builder unchanged, so `SdkBuilder::build()` seeds at the
// per-network `min_protocol_version` floor with auto-detect on
// (version_pinned=false) and ratchets up as the network reports newer
// versions. A non-zero value is an explicit pin via `with_version`.
config.platform_version = platformVersion

// Create SDK with trusted setup. DAPI / quorum-URL overrides come from
// UserDefaults and apply on:
Expand Down
Loading