@@ -73,6 +73,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory {
7373 private readonly epochAdjustment : Observable < number > ;
7474 private readonly networkProperties : Observable < NetworkConfiguration > ;
7575 private readonly networkCurrencies : Observable < NetworkCurrencies > ;
76+ private readonly nodePublicKey : Observable < string | undefined > ;
7677 /**
7778 * Constructor
7879 * @param url the server url.
@@ -93,13 +94,14 @@ export class RepositoryFactoryHttp implements RepositoryFactory {
9394 } ) ,
9495 ) ,
9596 ) ;
96- this . generationHash = configs ?. generationHash
97- ? observableOf ( configs . generationHash )
98- : this . cache ( ( ) =>
99- this . createNodeRepository ( )
100- . getNodeInfo ( )
101- . pipe ( map ( ( b ) => b . networkGenerationHashSeed ) ) ,
102- ) ;
97+ if ( configs ?. generationHash && configs ?. nodePublicKey ) {
98+ this . generationHash = observableOf ( configs . generationHash ) ;
99+ this . nodePublicKey = observableOf ( configs . nodePublicKey ) ;
100+ } else {
101+ const nodeInfoObservable = this . createNodeRepository ( ) . getNodeInfo ( ) ;
102+ this . generationHash = this . cache ( ( ) => nodeInfoObservable . pipe ( map ( ( b ) => b . networkGenerationHashSeed ) ) ) ;
103+ this . nodePublicKey = this . cache ( ( ) => nodeInfoObservable . pipe ( map ( ( b ) => b . nodePublicKey ) ) ) ;
104+ }
103105 this . websocketUrl = configs ?. websocketUrl ? configs ?. websocketUrl : `${ url . replace ( / \/ $ / , '' ) } /ws` ;
104106 this . websocketInjected = configs ?. websocketInjected ;
105107 this . networkCurrencies = configs ?. networkCurrencies
@@ -198,4 +200,10 @@ export class RepositoryFactoryHttp implements RepositoryFactory {
198200 getCurrencies ( ) : Observable < NetworkCurrencies > {
199201 return this . networkCurrencies ;
200202 }
203+ /**
204+ * @returns the node public key
205+ */
206+ getNodePublicKey ( ) : Observable < string | undefined > {
207+ return this . nodePublicKey ;
208+ }
201209}
0 commit comments