Skip to content
Closed
39 changes: 14 additions & 25 deletions packages/rs-sdk-ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ dash_sdk_init();
DashSDKConfig config = {
.network = DASH_SDK_NETWORK_TESTNET,
.dapi_addresses = "seed-1.testnet.networks.dash.org",
.skip_asset_lock_proof_verification = false,
.request_retry_count = 3,
.request_timeout_ms = 30000
};
Comment on lines 86 to 92
Comment on lines 86 to 92
Copy link
Copy Markdown
Collaborator Author

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.


// 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);
Expand All @@ -106,28 +108,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
Expand All @@ -147,19 +132,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",
skip_asset_lock_proof_verification=False,
request_retry_count=3,
request_timeout_ms=30000
)
Comment on lines 146 to 152
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 5657829897: the Python example now uses the same full DAPI URI form (https://seed-1.testnet.networks.dash.org:1443) so it satisfies AddressList::from_str parsing.


# 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)
Comment on lines +154 to +156
# ... handle result and use SDK
```

Expand All @@ -170,6 +158,7 @@ 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 optional protocol-version pinning
- `dash_sdk_destroy()` - Destroy an SDK instance
- `dash_sdk_version()` - Get the SDK version

Expand Down
Loading
Loading