-
Notifications
You must be signed in to change notification settings - Fork 54
feat(rs-sdk-ffi): expose optional platform_version in DashSDKConfig #3751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,19 @@ pub struct DashSDKConfigExtended { | |||||||||||||||||||
| pub core_sdk_handle: *mut CoreSDKHandle, | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| fn apply_version(builder: SdkBuilder, platform_version: u32) -> Result<SdkBuilder, DashSDKError> { | ||||||||||||||||||||
| if platform_version == 0 { | ||||||||||||||||||||
| return Ok(builder); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| match dash_sdk::dpp::version::PlatformVersion::get(platform_version) { | ||||||||||||||||||||
| Ok(v) => Ok(builder.with_version(v)), | ||||||||||||||||||||
| Err(e) => Err(DashSDKError::new( | ||||||||||||||||||||
| DashSDKErrorCode::InvalidParameter, | ||||||||||||||||||||
| format!("Invalid platform_version {}: {}", platform_version, e), | ||||||||||||||||||||
| )), | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
lklimek marked this conversation as resolved.
Comment on lines
+34
to
+38
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 Nitpick: Redundant version number in error message STILL VALID at 4d3a565 — sdk.rs:36 still reads
Suggested change
source: ['claude', 'codex'] |
||||||||||||||||||||
| } | ||||||||||||||||||||
|
lklimek marked this conversation as resolved.
Comment on lines
+28
to
+39
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: Add coverage for the new invalid-platform-version error path STILL VALID at 4d3a565 (apply_version unchanged; no new tests in the latest delta). A small source: ['claude', 'codex'] |
||||||||||||||||||||
|
|
||||||||||||||||||||
| /// Internal SDK wrapper | ||||||||||||||||||||
| pub(crate) struct SDKWrapper { | ||||||||||||||||||||
| pub sdk: Sdk, | ||||||||||||||||||||
|
|
@@ -149,6 +162,11 @@ pub unsafe extern "C" fn dash_sdk_create(config: *const DashSDKConfig) -> DashSD | |||||||||||||||||||
| } | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| let builder = match apply_version(builder, config.platform_version) { | ||||||||||||||||||||
| Ok(b) => b, | ||||||||||||||||||||
| Err(e) => return DashSDKResult::error(e), | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Build SDK | ||||||||||||||||||||
| let sdk_result = builder.build().map_err(FFIError::from); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -257,6 +275,11 @@ pub unsafe extern "C" fn dash_sdk_create_extended( | |||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| let builder = match apply_version(builder, base_config.platform_version) { | ||||||||||||||||||||
| Ok(b) => b, | ||||||||||||||||||||
| Err(e) => return DashSDKResult::error(e), | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Build SDK | ||||||||||||||||||||
| let sdk_result = builder.build().map_err(FFIError::from); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -420,6 +443,11 @@ pub unsafe extern "C" fn dash_sdk_create_trusted(config: *const DashSDKConfig) - | |||||||||||||||||||
| info!("dash_sdk_create_trusted: adding trusted context provider to builder"); | ||||||||||||||||||||
| let builder = builder.with_context_provider(Arc::clone(&trusted_provider)); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| let builder = match apply_version(builder, config.platform_version) { | ||||||||||||||||||||
| Ok(b) => b, | ||||||||||||||||||||
| Err(e) => return DashSDKResult::error(e), | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Build SDK | ||||||||||||||||||||
| let sdk_result = builder.build().map_err(FFIError::from); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -572,6 +600,7 @@ pub unsafe extern "C" fn dash_sdk_create_with_callbacks( | |||||||||||||||||||
| skip_asset_lock_proof_verification: config_ref.skip_asset_lock_proof_verification, | ||||||||||||||||||||
| request_retry_count: config_ref.request_retry_count, | ||||||||||||||||||||
| request_timeout_ms: config_ref.request_timeout_ms, | ||||||||||||||||||||
| platform_version: config_ref.platform_version, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| context_provider: context_provider_handle, | ||||||||||||||||||||
| core_sdk_handle: std::ptr::null_mut(), | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,10 @@ pub struct DashSDKConfig { | |
| pub request_retry_count: u32, | ||
| /// Timeout for requests in milliseconds | ||
| pub request_timeout_ms: u64, | ||
| /// Pin to a specific Dash Platform protocol version. | ||
| /// `0` keeps the SDK default (auto-detect / latest); any non-zero value | ||
| /// is forwarded to `SdkBuilder::with_version` and rejected if unknown. | ||
| pub platform_version: u32, | ||
|
lklimek marked this conversation as resolved.
|
||
| } | ||
|
lklimek marked this conversation as resolved.
Comment on lines
77
to
84
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: Reword the "preserves ABI" claim — appending to a repr(C) struct is source-compatible only STILL VALID at 4d3a565 (file unchanged in the latest delta). The current doc comment on Concrete risk is low: rs-sdk-ffi ships at 3.1.0-dev.6 with no committed binary-ABI promise, the cbindgen header is regenerated and shipped with the library, the Swift bridge is updated in lockstep, and the README examples already diverge from the struct layout (omitting source: ['claude', 'codex'] |
||
|
|
||
| /// Result data type indicator for iOS | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.