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

feat(frontend): Add btc pending transactions store #2635

Merged
merged 5 commits into from
Oct 4, 2024

Conversation

lmuntaner
Copy link
Contributor

Motivation

We will disable sending BTC tokens while the user has pending transaction. Pending transactions will come from Oisy backend.

In this PR, I created a store to save the pending transactions per address.

Changes

  • New store pendingTransactionsStore.

Tests

  • Test new store.

@lmuntaner lmuntaner marked this pull request as ready for review October 3, 2024 14:21
@lmuntaner lmuntaner requested a review from a team as a code owner October 3, 2024 14:21
@lmuntaner
Copy link
Contributor Author

@AntonioVentilii-DFINITY @peterpeterparker please review

type Address = string;
type BtcPendingTransactionsStoreData = Record<Address, Array<PendingTransaction>>;

interface BtcPendingTransactionsStore extends Readable<BtcPendingTransactionsStoreData> {
Copy link
Member

Choose a reason for hiding this comment

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

Should the data hold in the store contains the information if those are certified or not? extending for example CertifiedData and CertifiedStore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will always be certified. This endpoint can't be called with a query. The endpoint also prunes outdated pending transactions.

This way I didn't need to implement a background tasks updating them.

I added a comment because it's not obvious. Good point.

Copy link
Member

Choose a reason for hiding this comment

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

Instead of a comment, what do you think of using the CertifiedData type, excluding certified and replacing it with certified: false as type. That way even code wise it's specified that it's always certified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean setting certified: true always?

Sure I can do that as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean setting certified: true always?

Yes sorry, stupid typo.

Copy link
Member

Choose a reason for hiding this comment

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

Cool. So what I meant is also the following:

type AlwaysCertifiedData<T> = Omit<CertifiedData<T>, "certified"> & {certified: true};
type BtcPendingTransactionsStoreData = Record<Address, AlwaysCertifiedData<Array<PendingTransaction>>>;

Maybe AlwaysCertifiedData can even find place in the same module as CertifiedData?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, sorry, for the confusion. Done!

Copy link
Member

Choose a reason for hiding this comment

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

I mean, my bad, I started with a typo ;)

@lmuntaner
Copy link
Contributor Author

@peterpeterparker ready for another review

1 similar comment
@lmuntaner
Copy link
Contributor Author

@peterpeterparker ready for another review

Copy link
Member

@peterpeterparker peterpeterparker left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@lmuntaner lmuntaner merged commit f8d5a96 into main Oct 4, 2024
10 checks passed
@lmuntaner lmuntaner deleted the lm-pending-transactions branch October 4, 2024 07:58
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.

2 participants