File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ const order: MarketOrderSpec = Object.freeze({
2525 } ,
2626 } ,
2727} as const ) ;
28+
29+ const identity = {
30+ identity : "0x0123456789" ,
31+ role : "test-role" ,
32+ name : "test-name" ,
33+ } ;
34+
2835const mockMarket = mock ( MarketModuleImpl ) ;
2936const mockPayment = mock ( PaymentModuleImpl ) ;
3037const mockActivity = mock ( ActivityModuleImpl ) ;
@@ -54,6 +61,7 @@ afterEach(() => {
5461beforeEach ( ( ) => {
5562 when ( mockStorageProvider . close ( ) ) . thenResolve ( ) ;
5663 when ( mockYagna . disconnect ( ) ) . thenResolve ( ) ;
64+ when ( mockYagna . connect ( ) ) . thenResolve ( identity ) ;
5765} ) ;
5866
5967function getGolemNetwork ( ) {
Original file line number Diff line number Diff line change @@ -254,6 +254,7 @@ export class GolemNetwork {
254254 */
255255 private cleanupTasks : ( ( ) => Promise < void > | void ) [ ] = [ ] ;
256256
257+ private identity ?: string ;
257258 private registeredPlugins : GolemPluginRegistration [ ] = [ ] ;
258259
259260 constructor ( options : Partial < GolemNetworkOptions > = { } ) {
@@ -367,7 +368,7 @@ export class GolemNetwork {
367368 */
368369 async connect ( ) {
369370 try {
370- await this . yagna . connect ( ) ;
371+ this . identity = ( await this . yagna . connect ( ) ) . identity ;
371372 await this . services . paymentApi . connect ( ) ;
372373 await this . storageProvider . init ( ) ;
373374 await this . connectPlugins ( ) ;
@@ -694,6 +695,17 @@ export class GolemNetwork {
694695 return this . hasConnection ;
695696 }
696697
698+ /**
699+ * Yagna Node Id used by the requester.
700+ * It depends on the Yagny Api Key used and reflects the user's eth wallet address.
701+ */
702+ getIdentity ( ) : string {
703+ if ( ! this . isConnected ( ) || ! this . identity ) {
704+ throw new GolemUserError ( "To obtain an identity, you must first connect to the Golem Network." ) ;
705+ }
706+ return this . identity ;
707+ }
708+
697709 /**
698710 * Creates a new logical network within the Golem VPN infrastructure.
699711 * Allows communication between network nodes using standard network mechanisms,
You can’t perform that action at this time.
0 commit comments