Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
dangershony committed Dec 13, 2023
2 parents 3cde90e + 64d33db commit c6763d2
Show file tree
Hide file tree
Showing 23 changed files with 486 additions and 442 deletions.
1 change: 1 addition & 0 deletions src/Angor/Client/Angor.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.5" PrivateAssets="all" />
<PackageReference Include="NBitcoin" Version="7.0.25" />
<PackageReference Include="Nostr.Client" Version="1.4.3" />
<PackageReference Include="QRCoder" Version="1.4.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/Angor/Client/Components/FounderProjectItem.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

protected override async Task OnInitializedAsync()
{
await RelayService.ConnectToRelaysAsync();

await RelayService.LookupDirectMessagesForPubKeyAsync(FounderProject.ProjectInfo.NostrPubKey, FounderProject.LastRequestForSignaturesTime, 1,
_ =>
{
Expand Down
58 changes: 58 additions & 0 deletions src/Angor/Client/Components/ShowQrCode.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@using Angor.Shared.Services
@using Angor.Client.Models
@using Nostr.Client.Messages
@using Nostr.Client.Messages.Metadata
@using QRCoder


<div class="col-lg-6">
<h4 class="card-title">QR Code</h4>
@if (!string.IsNullOrEmpty(base64qrcode))
{
<img src="data:image /png;base64,@base64qrcode" class="card-img-top qrcode" alt="QR Code"/>
}
</div>

@code {

[Parameter]
public string Data { get; set; }

private static string lastqrcode;
private static string lastaddress;
private string base64qrcode;

protected override async Task OnInitializedAsync()
{
GenerateQRCode(Data);
}

public Task GenerateQRCode(string newData)
{
Data = newData;

if (lastaddress == Data)
{
base64qrcode = lastqrcode;
return Task.CompletedTask;
}

return Task.Run(() =>
{
base64qrcode = GenerateQRCodeInternal(Data);
lastqrcode = base64qrcode;
lastaddress = Data;

StateHasChanged();

});
}

public static string GenerateQRCodeInternal(string content)
{
using QRCodeGenerator qrGenerator = new QRCodeGenerator();
using QRCodeData qrCodeData = qrGenerator.CreateQrCode(content, QRCodeGenerator.ECCLevel.Q);
using PngByteQRCode pngByteQRCode = new PngByteQRCode(qrCodeData);
return Convert.ToBase64String(pngByteQRCode.GetGraphic(10));
}
}
2 changes: 0 additions & 2 deletions src/Angor/Client/Pages/Browse.razor
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@

protected override async Task OnInitializedAsync()
{
await _RelayService.ConnectToRelaysAsync();

projects = SessionStorage.GetProjectIndexerData() ?? new();
}

Expand Down
2 changes: 0 additions & 2 deletions src/Angor/Client/Pages/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
project.NostrPubKey = projectsKeys.NostrPubKey;
}

await _RelayService.ConnectToRelaysAsync();

_RelayService.RequestProjectCreateEventsByPubKey(_ => //TODO change the state to be storage driven and not event driven
{
nostrProfileCreated = _.Kind == NostrKind.Metadata;
Expand Down
6 changes: 3 additions & 3 deletions src/Angor/Client/Pages/Founder.razor
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
private async Task LookupProjectKeysOnIndexerAsync()
{
scanningForProjects = true;
await RelayService.ConnectToRelaysAsync();

var keys = storage.GetFounderKeys();

Expand All @@ -124,14 +123,15 @@
case { Kind: NostrKind.Metadata }:
var nostrMetadata = JsonSerializer.Deserialize<ProjectMetadata>(e.Content, Angor.Shared.Services.RelayService.settings);
var founderProject = founderProjects.FirstOrDefault(_ => _.ProjectInfo.NostrPubKey == e.Pubkey);
if (founderProject != null)
if (founderProject != null && founderProject.Metadata is null)
founderProject.Metadata = nostrMetadata;
else
notificationComponent.ShowNotificationMessage($"Couldn't find the project details for the project {nostrMetadata.Name} try adding the missing relay."); //TODO
break;
case { Kind: NostrKind.ApplicationSpecificData }:
var projectInfo = JsonSerializer.Deserialize<ProjectInfo>(e.Content, Angor.Shared.Services.RelayService.settings);
founderProjects.Add(new FounderProject { ProjectInfo = projectInfo });
if(founderProjects.All(_ => _.ProjectInfo.NostrPubKey != e.Pubkey)) //Getting events from multiple relays
founderProjects.Add(new FounderProject { ProjectInfo = projectInfo });
break;
}
},
Expand Down
3 changes: 3 additions & 0 deletions src/Angor/Client/Pages/Invest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@

private async Task HandleSignatureReceivedAsync(string? nostrPrivateKeyHex, string _)
{
if (recoverySigs?.Signatures.Any() ?? false) //multiple relays for the same message
return;

var signatureJson = await javascriptNostrToolsModule.InvokeAsync<string>(
"decryptNostr", nostrPrivateKeyHex, project.NostrPubKey, _);

Expand Down
5 changes: 0 additions & 5 deletions src/Angor/Client/Pages/Penalties.razor
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
@page "/penalties"
@using Angor.Shared
@using Angor.Client.Storage
@using Angor.Shared.Models
@using Angor.Client.Services
@using Blockcore.Consensus.ScriptInfo
@using Blockcore.NBitcoin

@inject HttpClient Http
@inject IDerivationOperations _derivationOperations
@inject IWalletStorage _walletStorage;
@inject IClientStorage storage;
@inject NavigationManager NavigationManager
@inject INetworkConfiguration _NetworkConfiguration
@inject IIndexerService _IndexerService

@inherits BaseComponent
Expand Down
4 changes: 3 additions & 1 deletion src/Angor/Client/Pages/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<thead>
<tr>
<th>Link</th>
<th>Name</th>
<th>Status</th>
<th>Default</th>
<th></th>
Expand All @@ -96,7 +97,8 @@
{
<tr>
<td><a href="@relay.Url" target="_blank">@relay.Url</a></td>
<td style="color: @(relay.Status == UrlStatus.Online ? "green" : relay.Status == UrlStatus.NotReady ? "yellow" : "red");">@relay.Status.ToString()</td>
<td>@relay.Name</td>
<td style="color: @(relay.Status == UrlStatus.Online ? "green" : relay.Status == UrlStatus.NotReady ? "yellow" : "red");">@relay.Status.ToString()</td>
<td>
@if (relay.IsPrimary)
{
Expand Down
Loading

0 comments on commit c6763d2

Please sign in to comment.