Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for issue 139 #197

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

fix for issue 139 #197

wants to merge 3 commits into from

Conversation

itailiors
Copy link
Collaborator

to be tested

@@ -847,6 +849,21 @@

try
{
// Check if the FounderKey is in use and get the total keys used
var keyCheckResult = await FounderKeyService.CheckFounderKeyAsync(project.ProjectInfo.FounderKey);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting this in the CreatProjectTransaction is probably not the right thing to do, we must know much before this point if the key was already used

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do rescan before creating,
But there's a scenario this scenario.

  1. Logged on browser A, B.
  2. start create browser A.
  3. Start create browser B.
  4. Create browser B.
  5. Create Browser A.

unless you put a rescan when creating, you won't know that there's another project created on the same key.
but also now that i think of it we will need to refresh the data in the create a project. (almost everything except project info no?)

I know that this is an edge case that is not expected (especially when we suspect that per user there will be probably only 1 project), but still this should be addressed in some way because we cannot have any loophole of over riding a project.

Copy link
Collaborator

@DavidGershony DavidGershony Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to have a meeting about trusting the relays for knowing if the project was created or only look at the indexer to see if a transaciton exists
Bare in mind that we keep the nostr event id on the transaction so it is not possible to show false data there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then i'll wait with this PR until we do that,
We should align on how much we trust the relays, and on which instances we can trust it.

Also, according to that we should check if there are other places in angor that trust the relay instead of the indexer?

Copy link
Member

@dangershony dangershony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must be review by @DavidGershony for the Nostr calls.
But also I am sure we do the check in the right place

@(scanningForProjects ? "Scanning..." : "Create Project")
</span>
</button>
<div class="tooltip-container" data-bs-toggle="tooltip" title="@GetCreateButtonTooltip()">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make a separate pr just for issue 166?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,
but there's also a check that is a corelated to 166 in createtransaction that checks how many keys are already existing, and if there are more than 15 then fail.

(because of an issue like listed above)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll also add that its needed because disabling the button in founder.razor isn't good enough,
because people can "hack" and change the URL.
so there needs to be check in the createtransaction (or a check on oninitiallized in create.razor that doesn't show the create module if you have more than 15.)


public async Task<bool> IsFounderKeyInUseAsync(string founderKey)
{
var keys = _walletStorage.GetFounderKeys();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the relay is the right place to check, we need to check with the indexer if the transaction exists.

Kinds = new[] { NostrKind.ApplicationSpecificData, NostrKind.Metadata },
}));

await tcs.Task; // Wait for the end of stream
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we awaiting the tcs and not just allowing the callback thread to perfome the action we need?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it because of this
https://learn.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/implementing-the-task-based-asynchronous-pattern

why shouldnt we need TaskCompletionSource to wait for end of steam?

either way copilot removed it 😉


if (keyCheckResult.IsKeyInUse)
{
notificationComponent.ShowErrorMessage("The FounderKey is already in use. Please use a different key.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we need to "fix" the data in the local storage because the user can't select a founder key to use, perhaps add a message to rescan or wipe the storage and recover the wallet again.

}


public class FounderKeyCheckResult
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class should be in the models folder

@itailiors itailiors changed the title fix for issues 166 and 139 fix for issue 139 Dec 15, 2024
@itailiors
Copy link
Collaborator Author

created by copilot, pretty neat.

The pull request #197 titled "fix for issue 139" includes the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants