@@ -29,11 +29,14 @@ export interface ConnectionOptions {
2929export 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
3437export 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
136167export { DocumentsFacade } from './documents/facade.js' ;
0 commit comments