From 7b96c70ac1568829c5f3e95c833cdd9bb89f49d6 Mon Sep 17 00:00:00 2001 From: TheDude Date: Thu, 11 Jan 2024 14:55:02 +0000 Subject: [PATCH] Fixed issue with investor waiting for founder signatures (#34) * Moved call to javascript module to after render * Removed unused first render * Replaced writing to console with logging --- src/Angor/Client/Pages/Invest.razor | 33 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Angor/Client/Pages/Invest.razor b/src/Angor/Client/Pages/Invest.razor index 2e0ac748..5f918d6e 100644 --- a/src/Angor/Client/Pages/Invest.razor +++ b/src/Angor/Client/Pages/Invest.razor @@ -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 { @@ -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()