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

added transaction tracking #51

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

DanutIlie
Copy link

@DanutIlie DanutIlie commented Dec 19, 2024

Feature

added transaction tracking

Contains breaking changes

[x] No

[] Yes

Updated CHANGELOG

[x] Yes

Testing

[x] User testing
[] Unit tests

export interface TrackedTransactionsSliceType {
[sessionId: string]: {
transactions: SignedTransactionType[];
status?: TransactionBatchStatusesEnum;

Choose a reason for hiding this comment

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

TransactionBatchStatusesEnum | TransactionServerStatusesEnum

Copy link
Author

Choose a reason for hiding this comment

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

done

@@ -55,6 +56,19 @@ export class TransactionManager {
}
};

public track = async (
signedTransactions: Transaction[],
options?: { enableToasts: boolean }
Copy link
Collaborator

Choose a reason for hiding this comment

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

disableToasts boolean default undefined ?

Copy link
Author

Choose a reason for hiding this comment

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

i change it to default {enableToasts:true}


export async function checkTransactionStatus(
props: TransactionsTrackerType & {
shouldRefreshBalance?: boolean;
}
) {
const { pendingSessions } = getPendingStoreTransactions();
const { pendingTrackedSessions: pendingSessions } =
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not keep sessions, since we don't have any other sessions

const recheckStatus = () => {
checkTransactionStatus({
shouldRefreshBalance: isWebsocketCompleted,
getTransactionsByHash,
...props
getTransactionsByHash: getTransactionsByHashes
Copy link
Collaborator

Choose a reason for hiding this comment

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

strange name difference. & why not use it as a default in checkTransactionStatus and allow optional override

Copy link
Author

Choose a reason for hiding this comment

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

removed it and used as default in checkTransactionStatus

) => {
getStore().setState(({ toasts: state }) => {
const toastId =
currentToastId || `custom-toast-${state.customToasts.length + 1}`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

add toast 0 --> custom-toast-1
add toast 1 --> custom-toast-2
delete toast 0
add toast --> custom-toast-2 => you will have duplicates of custom-toast-2
solution state.customToasts --> get last toast index and increase it by one

Copy link
Author

Choose a reason for hiding this comment

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

done

type: ToastsEnum.transaction,
startTimestamp: getUnixTimestamp(),
toastId:
toastId || `transaction-toast-${state.transactionToasts.length + 1}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

check vulenrability here if there is one

Copy link
Author

Choose a reason for hiding this comment

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

i did the same thing as in custom case

@@ -0,0 +1,11 @@
import { StoreType } from 'store/store.types';

export const networkSliceSelector = ({ network }: StoreType) => network;
Copy link
Collaborator

Choose a reason for hiding this comment

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

duplicate

Copy link
Author

Choose a reason for hiding this comment

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

removed

import { TransactionServerStatusesEnum } from 'types/enums.types';
import { SignedTransactionType } from 'types/transactions.types';

export const transactionsSliceSelector = ({ trackedTransactions }: StoreType) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

trackedTransactionsSliceSelector

Copy link
Author

Choose a reason for hiding this comment

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

done

*
* **⚠️ Warning**: Toasts with components will not be persisted on page reload because React components are not serializable
*/
component: (() => JSX.Element) | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this used? since we are no longer in React

Copy link
Author

Choose a reason for hiding this comment

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

i removed for now all the custom types and let only the generic one

@@ -0,0 +1,82 @@
import { JSX } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we have react in the project?

Copy link
Author

Choose a reason for hiding this comment

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

removed

@arhtudormorar arhtudormorar merged commit 5d746e7 into development Dec 20, 2024
1 check passed
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