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: listen for the transfer success event #1490

Merged
merged 6 commits into from
Jan 14, 2025

Conversation

euharrison
Copy link
Collaborator

@euharrison euharrison commented Jan 9, 2025

Listen for the transfer Success event and apply it to the notifications and transaction page

Also, enable the watcher for cases where the transaction delays and the user closes the browser

Closes #1428
Closes #1485

Screen.Recording.2025-01-09.at.15.27.14.mov

@euharrison euharrison changed the title feat: listen for the transfer complete event feat: listen for the transfer success event Jan 9, 2025
};
}, deps);
}, [event]);
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 lost many hours debugging until realizing this dependencies was the issue 😢

Maybe we should enable the "react-hooks/exhaustive-deps": "warn" and, if you don't want to use, at least you need to add the lint ignore comment

What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Daaaamn

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we concatenate this [event] with the former deps array, if it's not empty?

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 don't need the deps anymore, because the function is saved on the ref, so you are free to pass anything, even a new function everytime

hash: string
): Promise<WrapperTransaction> => {
// indexer only accepts the hash as lowercase
return (await api.apiV1ChainWrapperTxIdGet(hash.toLowerCase())).data;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've created a small utility function that might be useful here :) utils/address.ts@sanitizeAddress

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cool thanks!

};
}, deps);
}, [event]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Daaaamn

};
}, deps);
}, [event]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we concatenate this [event] with the former deps array, if it's not empty?

clearPendingNotifications(id);
const storedTx = searchAllStoredTxByHash(tx.hash);
const storedTx = searchAllStoredTxByHash(e.detail.tx[0].hash);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please check if what you want is not the tx[0].innerTxHashes[0]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Validated. The tx[0].hash is correct. We don't have the innerTxHashes on the event object, and we are creating the stored tx with the txs[0].hash from response, not the txs[0].innerTxHashes[0]

Screenshot 2025-01-14 at 11 50 50

Screenshot 2025-01-14 at 11 51 04

@euharrison euharrison merged commit 41b7158 into main Jan 14, 2025
7 checks passed
@euharrison euharrison deleted the feat/transfer-complete-state branch January 14, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants