-
Notifications
You must be signed in to change notification settings - Fork 54
feat(rs-sdk-ffi): expose SDK protocol version pinning #3734
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
Closed
thepastaclaw
wants to merge
9
commits into
dashpay:v3.1-dev
from
thepastaclaw:feature/ffi-sdk-protocol-version
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
22365d9
feat(ffi): expose SDK protocol version pinning
thepastaclaw ef353c1
fix(rs-sdk-ffi): address SDK protocol pinning review
thepastaclaw db8a8db
fix(rs-sdk-ffi): align sdk builder config paths
thepastaclaw 687508c
fix(rs-sdk-ffi): address remaining PR3734 review feedback
thepastaclaw 35b6d40
fix(rs-sdk-ffi): pin protocol version via extended config
thepastaclaw 05bdc9e
Merge branch 'v3.1-dev' into feature/ffi-sdk-protocol-version
lklimek 24eb5df
fix(rs-sdk-ffi): pin protocol version via separate constructors
thepastaclaw 6c448d8
refactor(rs-sdk-ffi): delegate callbacks helper directly to extended …
thepastaclaw 5657829
docs(rs-sdk-ffi): fix protocol pinning examples
thepastaclaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,16 +76,24 @@ Build for your target platform using the appropriate Rust target. | |
| // Initialize the SDK | ||
| dash_sdk_init(); | ||
|
|
||
| // Create SDK configuration | ||
| // Create SDK configuration. | ||
| // | ||
| // `skip_asset_lock_proof_verification`, despite its name, currently toggles | ||
| // Platform state-proof verification for *all* SDK requests (it is wired to | ||
| // `SdkBuilder::with_proofs`). Leave it `false` in production; set it to | ||
| // `true` only for testing or in trusted-context flows where proof | ||
| // verification is not desired. | ||
| DashSDKConfig config = { | ||
| .network = DASH_SDK_NETWORK_TESTNET, | ||
| .dapi_addresses = "seed-1.testnet.networks.dash.org", | ||
| .dapi_addresses = "https://seed-1.testnet.networks.dash.org:1443", | ||
| .skip_asset_lock_proof_verification = false, | ||
| .request_retry_count = 3, | ||
| .request_timeout_ms = 30000 | ||
| }; | ||
|
|
||
| // Create SDK instance | ||
| DashSDKResult result = dash_sdk_create(&config); | ||
| // Create SDK instance pinned to Platform protocol version 11. | ||
| // Pass 0 to keep the default auto-detect behavior. | ||
| DashSDKResult result = dash_sdk_create_with_protocol_version(&config, 11); | ||
| if (result.error) { | ||
| // Handle error | ||
| dash_sdk_error_free(result.error); | ||
|
|
@@ -106,28 +114,11 @@ dash_sdk_destroy(sdk); | |
| // Initialize the SDK | ||
| dash_sdk_init() | ||
|
|
||
| // Create SDK configuration | ||
| var config = DashSDKConfig( | ||
| network: DashSDKNetwork.testnet, | ||
| dapi_addresses: "seed-1.testnet.networks.dash.org".cString(using: .utf8), | ||
| request_retry_count: 3, | ||
| request_timeout_ms: 30000 | ||
| ) | ||
|
|
||
| // Create SDK instance | ||
| let result = dash_sdk_create(&config) | ||
| if let error = result.error { | ||
| // Handle error | ||
| dash_sdk_error_free(error) | ||
| return | ||
| } | ||
| // Default behavior auto-detects the protocol version. | ||
| let sdk = try SDK(network: .testnet) | ||
|
|
||
| let sdk = result.data | ||
|
|
||
| // Use the SDK... | ||
|
|
||
| // Clean up | ||
| dash_sdk_destroy(sdk) | ||
| // Pass 11 to pin Platform protocol version 11 instead. | ||
| let pinnedSDK = try SDK(network: .testnet, protocolVersion: 11) | ||
| ``` | ||
|
|
||
| ### Python Usage Example | ||
|
|
@@ -147,19 +138,22 @@ class DashSDKConfig(Structure): | |
| _fields_ = [ | ||
| ("network", c_int), | ||
| ("dapi_addresses", c_char_p), | ||
| ("skip_asset_lock_proof_verification", c_bool), | ||
| ("request_retry_count", c_uint32), | ||
| ("request_timeout_ms", c_uint64) | ||
| ] | ||
|
|
||
| config = DashSDKConfig( | ||
| network=1, # Testnet | ||
| dapi_addresses=b"seed-1.testnet.networks.dash.org", | ||
| dapi_addresses=b"https://seed-1.testnet.networks.dash.org:1443", | ||
| skip_asset_lock_proof_verification=False, | ||
| request_retry_count=3, | ||
| request_timeout_ms=30000 | ||
| ) | ||
|
Comment on lines
146
to
152
Collaborator
Author
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. Addressed in |
||
|
|
||
| # Create SDK instance | ||
| result = lib.dash_sdk_create(byref(config)) | ||
| # Create SDK instance pinned to protocol version 11. | ||
| # Pass 0 to keep the default auto-detect behavior. | ||
| result = lib.dash_sdk_create_with_protocol_version(byref(config), 11) | ||
| # ... handle result and use SDK | ||
| ``` | ||
|
|
||
|
|
@@ -170,6 +164,13 @@ result = lib.dash_sdk_create(byref(config)) | |
| #### Core Functions | ||
| - `dash_sdk_init()` - Initialize the FFI library | ||
| - `dash_sdk_create()` - Create an SDK instance | ||
| - `dash_sdk_create_with_protocol_version()` - Create an SDK instance with an optional Platform protocol-version pin (pass `0` to auto-detect) | ||
| - `dash_sdk_create_extended()` - Create an SDK instance with extended configuration (context provider, callbacks) | ||
| - `dash_sdk_create_extended_with_protocol_version()` - Like `dash_sdk_create_extended` plus an optional protocol-version pin | ||
| - `dash_sdk_create_trusted()` - Create an SDK instance with a trusted context provider | ||
| - `dash_sdk_create_trusted_with_protocol_version()` - Like `dash_sdk_create_trusted` plus an optional protocol-version pin | ||
| - `dash_sdk_create_with_callbacks()` - Create an SDK instance with per-instance context callbacks | ||
| - `dash_sdk_create_with_callbacks_and_protocol_version()` - Like `dash_sdk_create_with_callbacks` plus an optional protocol-version pin | ||
| - `dash_sdk_destroy()` - Destroy an SDK instance | ||
| - `dash_sdk_version()` - Get the SDK version | ||
|
|
||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in
5657829897: the C example now uses a full DAPI URI with scheme and port:https://seed-1.testnet.networks.dash.org:1443.