Skip to content

Commit

Permalink
Removed nostr tags that are not right
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGershony committed Aug 16, 2024
1 parent 9edff62 commit 0c68035
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 32 deletions.
1 change: 0 additions & 1 deletion src/Angor/Client/Pages/Investor.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
@inject IRelayService _RelayService
@inject ISignService _SignService
@inject ISerializer serializer
@inject ISignService _SignService
@inject IEncryptionService _encryptionService

@inject IJSRuntime JS
Expand Down
3 changes: 2 additions & 1 deletion src/Angor/Shared/Services/IRelayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace Angor.Shared.Services;
public interface IRelayService
{
Task<string> AddProjectAsync(ProjectInfo project, string nsec,Action<NostrOkResponse> action);
Task<string> CreateNostrProfileAsync(NostrMetadata metadata, string nsec,Action<NostrOkResponse> action);
Task<string> CreateNostrProfileAsync(NostrMetadata metadata, string nsec,
Action<NostrOkResponse> action);
Task<string> DeleteProjectAsync(string eventId, string hexPrivateKey);
void LookupProjectsInfoByPubKeys<T>(Action<T> responseDataAction, Action? OnEndOfStreamAction,
params string[] nostrPubKey);
Expand Down
20 changes: 3 additions & 17 deletions src/Angor/Shared/Services/RelayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public Task LookupSignaturesDirectMessagesForPubKeyAsync(string nostrPubKey, Dat
{
P = new[] { nostrPubKey },
Kinds = new[] { NostrKind.EncryptedDm },
A = new []{ NostrCoordinatesIdentifierTag(nostrPubKey)},
Since = since,
Limit = limit
}));
Expand Down Expand Up @@ -176,11 +175,6 @@ public string SendDirectMessagesForPubKeyAsync(string senderNosterPrivateKey, st
return signed.Id!;
}

private string NostrCoordinatesIdentifierTag(string nostrPubKey)
{
return $"{(int)NostrKind.ApplicationSpecificData}:{nostrPubKey}:AngorApp";
}

public void CloseConnection()
{
_subscriptionsHandling.Dispose();
Expand All @@ -207,7 +201,7 @@ public Task<string> AddProjectAsync(ProjectInfo project, string hexPrivateKey, A
return Task.FromResult(signed.Id);
}

public Task<string> CreateNostrProfileAsync(NostrMetadata metadata, string hexPrivateKey,Action<NostrOkResponse> action)
public Task<string> CreateNostrProfileAsync(NostrMetadata metadata, string hexPrivateKey, Action<NostrOkResponse> action)
{
var key = NostrPrivateKey.FromHex(hexPrivateKey);

Expand All @@ -217,11 +211,7 @@ public Task<string> CreateNostrProfileAsync(NostrMetadata metadata, string hexPr
{
Kind = NostrKind.Metadata,
CreatedAt = DateTime.UtcNow,
Content = content,
Tags = new NostrEventTags( //TODO need to find the correct tags for the event
new NostrEventTag("d", "AngorApp", "Create a new project event"),
new NostrEventTag("L", "#projectInfo"),
new NostrEventTag("l", "ProjectDeclaration", "#projectInfo"))
Content = content
}.Sign(key);

_subscriptionsHandling.TryAddOKAction(signed.Id,action);
Expand Down Expand Up @@ -257,11 +247,7 @@ private static NostrEvent GetNip78NostrEvent( string content)
{
Kind = NostrKind.ApplicationSpecificData,
CreatedAt = DateTime.UtcNow,
Content = content,
Tags = new NostrEventTags( //TODO need to find the correct tags for the event
new NostrEventTag("d", "AngorApp", "Create a new project event"),
new NostrEventTag("L", "#projectInfo"),
new NostrEventTag("l", "ProjectDeclaration", "#projectInfo"))
Content = content
};
return ev;
}
Expand Down
18 changes: 5 additions & 13 deletions src/Angor/Shared/Services/SignService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public SignService(INostrCommunicationFactory communicationFactory, INetworkServ
CreatedAt = DateTime.UtcNow,
Content = signRecoveryRequest.EncryptedContent,
Tags = new NostrEventTags(
NostrEventTag.Profile(signRecoveryRequest.NostrPubKey),
new NostrEventTag(NostrEventTag.CoordinatesIdentifier, NostrCoordinatesIdentifierTag(signRecoveryRequest.NostrPubKey)))
NostrEventTag.Profile(signRecoveryRequest.NostrPubKey),
new NostrEventTag("subject","Investment offer"))
};

// Blazor does not support AES so it needs to be done manually in javascript
Expand Down Expand Up @@ -68,7 +68,6 @@ public void LookupSignatureForInvestmentRequest(string investorNostrPubKey, stri
Kinds = new[] { NostrKind.EncryptedDm },
Since = sigRequestSentTime,
E = new [] { sigRequestEventId },
//A = new[] { NostrCoordinatesIdentifierTag(projectNostrPubKey) }, //Only signature requests
Limit = 1,
}));
}
Expand Down Expand Up @@ -97,7 +96,6 @@ public Task LookupInvestmentRequestsAsync(string nostrPubKey, DateTime? since, A
{
P = new[] { nostrPubKey }, //To founder
Kinds = new[] { NostrKind.EncryptedDm },
A = new []{ NostrCoordinatesIdentifierTag(nostrPubKey)}, //Only signature requests
Since = since
}));

Expand Down Expand Up @@ -127,8 +125,7 @@ public void LookupInvestmentRequestApprovals(string nostrPubKey, Action<string,
nostrClient.Send(new NostrRequest(subscriptionKey, new NostrFilter
{
Authors = new[] { nostrPubKey }, //From founder
Kinds = new[] { NostrKind.EncryptedDm },
A = new[] { NostrCoordinatesIdentifierTag(nostrPubKey) } //Only signature requests
Kinds = new[] { NostrKind.EncryptedDm }
}));
}

Expand All @@ -144,8 +141,8 @@ public DateTime SendSignaturesToInvestor(string encryptedSignatureInfo, string n
Tags = new NostrEventTags(new []
{
NostrEventTag.Profile(investorNostrPubKey),
new NostrEventTag(NostrEventTag.CoordinatesIdentifier,NostrCoordinatesIdentifierTag(nostrPrivateKey.DerivePublicKey().Hex)),
NostrEventTag.Event(eventId)
NostrEventTag.Event(eventId),
new NostrEventTag("subject","Re:Investment offer"),
})
};

Expand All @@ -161,10 +158,5 @@ public void CloseConnection()
{
_subscriptionsHanding.Dispose();
}

private string NostrCoordinatesIdentifierTag(string nostrPubKey)
{
return $"{(int)NostrKind.ApplicationSpecificData}:{nostrPubKey}:AngorApp";
}
}
}

0 comments on commit 0c68035

Please sign in to comment.