Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/block-core/angor
Browse files Browse the repository at this point in the history
  • Loading branch information
dangershony committed Dec 11, 2023
2 parents a2eb60c + feefd90 commit d633504
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 48 deletions.
26 changes: 11 additions & 15 deletions src/Angor/Client/Pages/Browse.razor
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,25 @@
}
else
{
foreach (var project in projects) //TODO set order (block created ?)
foreach (var project in projects.OrderByDescending(project => project.CreatedOnBlock))
{
<div class="card mb-3">
<div class="card-body">
<h5 class="card-title">@project.ProjectIdentifier</h5>
<p class="card-text">Nostr ID: <a href="/" target="_blank">@(NostrPublicKey.FromHex(project.NostrPubKey).Bech32)</a></p>
@if (SessionStorage.IsProjectInStorageById(project.ProjectIdentifier))
{
<button @onclick="() => ViewProjectDetails(project.ProjectIdentifier)" class="btn btn-primary">View</button>
}
else
{
if (searchInProgress)
@if (SessionStorage.IsProjectInStorageById(project.ProjectIdentifier)) //TODO should we show that projects exist but the user needs to add the right relay?
{
<div class="card mb-3">
<div class="card-body">
<h5 class="card-title">@project.ProjectIdentifier</h5>
<p class="card-text">Nostr ID: <a href="/" target="_blank">@(NostrPublicKey.FromHex(project.NostrPubKey).Bech32)</a></p>
@if(searchInProgress)
{
<div class="loader"></div>
}
else
{
<p class="text-warning">The project information was not found on the relay</p>
<button @onclick="() => ViewProjectDetails(project.ProjectIdentifier)" class="btn btn-primary">View</button>
}
}
</div>
</div>
</div>
}
}
}
</div>
Expand Down
46 changes: 24 additions & 22 deletions src/Angor/Client/Pages/Invest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -217,48 +217,50 @@

protected override async Task OnInitializedAsync()
{
if (hasWallet)
if (!hasWallet)
{
var signatures = storage.GetSignaturess();
NavigationManager.NavigateTo($"/wallet");
}

var signatures = storage.GetSignaturess();

var findProject = storage.GetInvestmentProjects().FirstOrDefault(p => p.ProjectIdentifier == ProjectId);
var findProject = storage.GetInvestmentProjects().FirstOrDefault(p => p.ProjectIdentifier == ProjectId);

if (findProject != null)
{
project = findProject;

recoverySigs = signatures?.FirstOrDefault(_ => _.ProjectIdentifier == project.ProjectIdentifier);
invested = recoverySigs?.Signatures.Any() ?? false;
}
else
{
findProject = storage.GetFounderProjects().FirstOrDefault(p => p.ProjectInfo.ProjectIdentifier == ProjectId)?.ProjectInfo;

if (findProject != null)
{
founder = true;
project = findProject;

recoverySigs = signatures?.FirstOrDefault(_ => _.ProjectIdentifier == project.ProjectIdentifier);
invested = recoverySigs?.Signatures.Any() ?? false;
}
else
{
findProject = storage.GetFounderProjects().FirstOrDefault(p => p.ProjectInfo.ProjectIdentifier == ProjectId)?.ProjectInfo;

if (findProject != null)
{
founder = true;
project = findProject;
}
else
{
project = SessionStorage.GetProjectById(ProjectId);
}
project = SessionStorage.GetProjectById(ProjectId);
}
}

await CheckIfSeederTimeHasPassed();

UpdateStagesBreakdown(new ChangeEventArgs { Value = Investment.InvestmentAmount });


if (project != null && recoverySigs?.Signatures.Any() ==false)

if (project != null && recoverySigs?.Signatures.Any() == false)
{
var accountInfo = storage.GetAccountInfo(_networkConfiguration.GetNetwork().Name);

var nostrPrivateKey = _derivationOperations.DeriveProjectNostrPrivateKey(_walletStorage.GetWallet(), accountInfo.InvestmentsCount + 1);

var nostrPrivateKeyHex = Encoders.Hex.EncodeData(nostrPrivateKey.ToBytes());
var nostrPrivateKeyHex = Encoders.Hex.EncodeData(nostrPrivateKey.ToBytes());

_SignService.LookupSignatureForInvestmentRequest(
NostrPrivateKey.FromHex(nostrPrivateKeyHex).DerivePublicKey().Hex
, project.NostrPubKey, recoverySigs.TimeOfRequestForSigning,
Expand Down
14 changes: 4 additions & 10 deletions src/Angor/Client/Pages/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
<div class="container mt-4">
<h3>View Project</h3>

@if (!hasWallet)
{
NavigationManager.NavigateTo($"/wallet");
return;
}

<NotificationComponent @ref="notificationComponent" />

@if (project == null)
Expand Down Expand Up @@ -226,8 +220,6 @@

protected override Task OnInitializedAsync()
{
if (hasWallet)
{
var findProject = storage.GetInvestmentProjects().FirstOrDefault(p => p.ProjectIdentifier == ProjectId);

if (findProject != null)
Expand Down Expand Up @@ -264,7 +256,6 @@
{
projectExplorerLink = _NetworkConfiguration.GetExplorerUrl().Url + $"/transaction/{project.CreationTransactionId}";
}
}

return Task.CompletedTask;
}
Expand All @@ -285,7 +276,10 @@

private async Task InvestInProject()
{
NavigationManager.NavigateTo($"/invest/{ProjectId}");
if (hasWallet)
NavigationManager.NavigateTo($"/invest/{ProjectId}");
else
notificationComponent.ShowNotificationMessage("You must create a wallet if you want to invest");
}


Expand Down
3 changes: 2 additions & 1 deletion src/Angor/Shared/Services/IndexerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class ProjectIndexerData
{
public string FounderKey { get; set; }
public string ProjectIdentifier { get; set; }
public string TrxId { get; set; }

public long CreatedOnBlock { get; set; }
public string NostrPubKey { get; set; }
}

Expand Down

0 comments on commit d633504

Please sign in to comment.