Skip to content

Commit

Permalink
Add sample for Nostr getRelays
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreb committed Dec 16, 2022
1 parent 877fd70 commit 0c57828
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@

<mat-card class="card">
<mat-card-header>
<mat-card-title>Nostr:PublicKey</mat-card-title>
<mat-card-title>Nostr PublicKey</mat-card-title>
</mat-card-header>
<mat-card-content>
<p *ngIf="nostrPublicKey">Public Key: {{ nostrPublicKey }}</p>
Expand All @@ -251,7 +251,7 @@

<mat-card class="card">
<mat-card-header>
<mat-card-title>Nostr:SignEvent</mat-card-title>
<mat-card-title>Nostr SignEvent</mat-card-title>
</mat-card-header>
<mat-card-content>
<p *ngIf="nostrSignedEvent">
Expand All @@ -264,6 +264,18 @@
<button mat-flat-button color="primary" (click)="nostrSignEvent(nostrEvent)">Nostr - Sign Event</button>
</mat-card-actions>
</mat-card>

<mat-card class="card">
<mat-card-header>
<mat-card-title>Nostr Get Relays</mat-card-title>
</mat-card-header>
<mat-card-content>
<p *ngIf="nostrRelays">Relays: {{ nostrRelays }}</p>
</mat-card-content>
<mat-card-actions>
<button mat-flat-button color="primary" (click)="getNostrPublicRelays()">Nostr - Get Public Relays</button>
</mat-card-actions>
</mat-card>

<router-outlet></router-outlet>
</div>
Expand Down
7 changes: 7 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class AppComponent implements OnInit {
wallet: any;
nostrPublicKey = '';
nostrSignedEvent = '';
nostrRelays?: string[];

nostrEvent = {
created_at: Date.now(),
Expand Down Expand Up @@ -109,6 +110,12 @@ export class AppComponent implements OnInit {
}
}

async getNostrPublicRelays() {
const gt = globalThis as any;
const relays = await gt.nostr.getRelays();
this.nostrRelays = relays;
}

async signMessageAnyAccount(value: string) {
const result: any = await this.provider!.request({
method: 'signMessage',
Expand Down

0 comments on commit 0c57828

Please sign in to comment.