Skip to content

Commit

Permalink
Moved call to javascript module to after render
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGershony committed Jan 10, 2024
1 parent aa08a41 commit 01fcd5c
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 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 (firstRender || javascriptNostrToolsModule == null)
{
try
{
Expand All @@ -301,6 +286,20 @@
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 01fcd5c

Please sign in to comment.