Skip to content

Commit 4c3b219

Browse files
committed
Merge remote-tracking branch 'origin/v2.1-dev' into refactor/dapi-rewrite-to-rust
2 parents 57c2925 + 4e31884 commit 4c3b219

File tree

9 files changed

+534
-35
lines changed

9 files changed

+534
-35
lines changed

.github/workflows/swift-sdk-build.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ jobs:
2323
- name: Checkout repository
2424
uses: actions/checkout@v4
2525

26-
- name: Select Xcode 16
27-
uses: maxim-lobanov/setup-xcode@v1
28-
with:
29-
xcode-version: '16.*'
30-
31-
- name: Show Xcode and Swift versions
26+
- name: Show Xcode and Swift versions (use default on self-hosted runner)
3227
run: |
3328
xcodebuild -version
3429
swift --version
@@ -98,12 +93,19 @@ jobs:
9893
shell: bash
9994
run: |
10095
set -euo pipefail
101-
# Use the same rust-dashcore revision as rs-dpp (parse single-line dep)
102-
REV=$(grep -E '^[[:space:]]*dashcore[[:space:]]*=[[:space:]]*\{.*rev[[:space:]]*=' packages/rs-dpp/Cargo.toml \
103-
| sed -E 's/.*rev[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/' \
96+
# Use the same rust-dashcore revision/tag as rs-dpp
97+
# Try to find tag first (preferred format)
98+
REV=$(grep -E '^[[:space:]]*dashcore[[:space:]]*=[[:space:]]*\{.*tag[[:space:]]*=' packages/rs-dpp/Cargo.toml \
99+
| sed -E 's/.*tag[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/' \
104100
| head -n1 || true)
101+
# If no tag found, try rev format
102+
if [ -z "${REV:-}" ]; then
103+
REV=$(grep -E '^[[:space:]]*dashcore[[:space:]]*=[[:space:]]*\{.*rev[[:space:]]*=' packages/rs-dpp/Cargo.toml \
104+
| sed -E 's/.*rev[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/' \
105+
| head -n1 || true)
106+
fi
105107
if [ -z "${REV:-}" ]; then
106-
echo "Failed to determine rust-dashcore revision from Cargo.toml" >&2
108+
echo "Failed to determine rust-dashcore revision or tag from Cargo.toml" >&2
107109
exit 1
108110
fi
109111
echo "rev=$REV" >> "$GITHUB_OUTPUT"

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/js-evo-sdk/src/sdk.ts

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ export interface ConnectionOptions {
2929
export interface EvoSDKOptions extends ConnectionOptions {
3030
network?: 'testnet' | 'mainnet';
3131
trusted?: boolean;
32+
// Custom masternode addresses. When provided, network and trusted options are ignored.
33+
// Example: ['https://127.0.0.1:1443', 'https://192.168.1.100:1443']
34+
addresses?: string[];
3235
}
3336

3437
export class EvoSDK {
3538
private wasmSdk?: wasm.WasmSdk;
36-
private options: Required<Pick<EvoSDKOptions, 'network' | 'trusted'>> & ConnectionOptions;
39+
private options: Required<Pick<EvoSDKOptions, 'network' | 'trusted'>> & ConnectionOptions & { addresses?: string[] };
3740

3841
public documents!: DocumentsFacade;
3942
public identities!: IdentitiesFacade;
@@ -47,8 +50,8 @@ export class EvoSDK {
4750
public voting!: VotingFacade;
4851
constructor(options: EvoSDKOptions = {}) {
4952
// Apply defaults while preserving any future connection options
50-
const { network = 'testnet', trusted = false, ...connection } = options;
51-
this.options = { network, trusted, ...connection };
53+
const { network = 'testnet', trusted = false, addresses, ...connection } = options;
54+
this.options = { network, trusted, addresses, ...connection };
5255

5356
this.documents = new DocumentsFacade(this);
5457
this.identities = new IdentitiesFacade(this);
@@ -80,10 +83,20 @@ export class EvoSDK {
8083
if (this.wasmSdk) return; // idempotent
8184
await initWasm();
8285

83-
const { network, trusted, version, proofs, settings, logs } = this.options;
86+
const { network, trusted, version, proofs, settings, logs, addresses } = this.options;
8487

8588
let builder: wasm.WasmSdkBuilder;
86-
if (network === 'mainnet') {
89+
90+
// If specific addresses are provided, use them instead of network presets
91+
if (addresses && addresses.length > 0) {
92+
// Prefetch trusted quorums for the network before creating builder with addresses
93+
if (network === 'mainnet') {
94+
await wasm.WasmSdk.prefetchTrustedQuorumsMainnet();
95+
} else if (network === 'testnet') {
96+
await wasm.WasmSdk.prefetchTrustedQuorumsTestnet();
97+
}
98+
builder = wasm.WasmSdkBuilder.withAddresses(addresses, network);
99+
} else if (network === 'mainnet') {
87100
await wasm.WasmSdk.prefetchTrustedQuorumsMainnet();
88101

89102
builder = trusted ? wasm.WasmSdkBuilder.mainnetTrusted() : wasm.WasmSdkBuilder.mainnet();
@@ -131,6 +144,24 @@ export class EvoSDK {
131144
static mainnet(options: ConnectionOptions = {}): EvoSDK { return new EvoSDK({ network: 'mainnet', ...options }); }
132145
static testnetTrusted(options: ConnectionOptions = {}): EvoSDK { return new EvoSDK({ network: 'testnet', trusted: true, ...options }); }
133146
static mainnetTrusted(options: ConnectionOptions = {}): EvoSDK { return new EvoSDK({ network: 'mainnet', trusted: true, ...options }); }
147+
148+
/**
149+
* Create an EvoSDK instance configured with specific masternode addresses.
150+
*
151+
* @param addresses - Array of HTTPS URLs to masternodes (e.g., ['https://127.0.0.1:1443'])
152+
* @param network - Network identifier: 'mainnet', 'testnet' (default: 'testnet')
153+
* @param options - Additional connection options
154+
* @returns A configured EvoSDK instance (not yet connected - call .connect() to establish connection)
155+
*
156+
* @example
157+
* ```typescript
158+
* const sdk = EvoSDK.withAddresses(['https://52.12.176.90:1443'], 'testnet');
159+
* await sdk.connect();
160+
* ```
161+
*/
162+
static withAddresses(addresses: string[], network: 'mainnet' | 'testnet' = 'testnet', options: ConnectionOptions = {}): EvoSDK {
163+
return new EvoSDK({ addresses, network, ...options });
164+
}
134165
}
135166

136167
export { DocumentsFacade } from './documents/facade.js';

0 commit comments

Comments
 (0)