Skip to content

Commit

Permalink
Fixed issue with investor waiting for founder signatures (#34)
Browse files Browse the repository at this point in the history
* Moved call to javascript module to after render

* Removed unused first render

* Replaced writing to console with logging
  • Loading branch information
DavidGershony authored Jan 11, 2024
1 parent 1bdb58c commit 7b96c70
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/Angor/Client/Pages/Invest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -269,26 +269,11 @@
await CheckIfSeederTimeHasPassed();

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


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());

_SignService.LookupSignatureForInvestmentRequest(
NostrPrivateKey.FromHex(nostrPrivateKeyHex).DerivePublicKey().Hex
, project.NostrPubKey, recoverySigs.TimeOfRequestForSigning.Value,
async _ => await HandleSignatureReceivedAsync(nostrPrivateKeyHex, _));
}
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
if (javascriptNostrToolsModule == null)
{
try
{
Expand All @@ -297,10 +282,24 @@
}
catch (JSException e)
{
Console.WriteLine(e);
_Logger.LogError(e,"Failed to load the nostr tools module");
notificationComponent.ShowErrorMessage(e.Message);
}
}

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());

_SignService.LookupSignatureForInvestmentRequest(
NostrPrivateKey.FromHex(nostrPrivateKeyHex).DerivePublicKey().Hex
, project.NostrPubKey, recoverySigs.TimeOfRequestForSigning.Value,
async _ => await HandleSignatureReceivedAsync(nostrPrivateKeyHex, _));
}
}

private Task CheckIfSeederTimeHasPassed()
Expand Down

0 comments on commit 7b96c70

Please sign in to comment.