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: use paging to fail all pending user transactions #2825

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

chmanie
Copy link
Member

@chmanie chmanie commented Aug 1, 2024

Description

There was a problem with pending transactions not being put into a failed state properly. This usually happens when a proper user wallet is initialized.

This PR uses Apollo paging to put all pending transactions into a failed state.

image

Testing

  1. Stop your dev environment
  2. Apply this patch (it will create 120 pending transactions during the create-data script.
diff --git a/scripts/create-data.js b/scripts/create-data.js
index f0ed7968e..f0a528dd9 100644
--- a/scripts/create-data.js
+++ b/scripts/create-data.js
@@ -300,6 +300,27 @@ const addTxToDb = async ({
   return graphqlRequest(createTransaction, { input }, GRAPHQL_URI, API_KEY);
 };
 
+const create120Transactions = async (userAddress, colonyAddress) => {
+  const domainBatchKey = 'createDomain';
+  for(let i=0; i<120; i++) {
+    const domainGroupId = nanoid();
+    console.log(`Adding pending transaction number ${i} with id ${domainGroupId}`);
+    await addTxToDb({
+      colonyAddress,
+      context: ClientType.ColonyClient,
+      groupId: domainGroupId,
+      groupIndex: 0,
+      groupKey: domainBatchKey,
+      hash: '0xdeadcafe',
+      methodName: 'addDomain(uint256,uint256,uint256)',
+      params: [1],
+      status: 'PENDING',
+      userAddress,
+    });
+    await delay(5);
+  }
+}
+
 /*
  * User
  */
@@ -1715,6 +1736,8 @@ const createUserAndColonyData = async () => {
     validatedTokensOwner
   );
 
+  await create120Transactions(leelaWallet.address, Object.keys(availableColonies)[0]);
+
   if (reputationMining) {
     console.log(
       "Reputation mining should now be disabled. Make sure you check this manually, otherwise you'll get chain time skips",
  1. Restart your dev environment
  2. Run the create-data script
  3. Open the CDapp and see 120 failed transactions

Diffs

Changes 🏗

  • Use paging to fail pending transactions on refresh

@chmanie chmanie marked this pull request as ready for review August 1, 2024 14:40
@chmanie chmanie requested review from a team as code owners August 1, 2024 14:40
@chmanie chmanie self-assigned this Aug 1, 2024
@chmanie chmanie added the bug Something isn't working label Aug 1, 2024
Copy link
Collaborator

@jakubcolony jakubcolony left a comment

Choose a reason for hiding this comment

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

Works great! Thanks for such a quick turnaround 👍

Screen.Recording.2024-08-01.at.23.58.17.mov

Comment on lines +31 to +35
getTransactionsByUserAndStatus(
from: { eq: $userAddress }
status: PENDING
nextToken: $nextToken
) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could also pass an increased limit here to override the default 100 items

Copy link
Contributor

@bassgeta bassgeta left a comment

Choose a reason for hiding this comment

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

Code changes look sane and the infinite scroll works!
image
image
Let's go 😎

Copy link
Member

@rdig rdig left a comment

Choose a reason for hiding this comment

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

Tested this and can confirm it's working as expected.

The patch to the create data script added the pending tx's correctly:

Screenshot from 2024-08-02 15-20-35
Screenshot from 2024-08-02 15-23-09

I also disabled the failPendingTransactions method, so that I can view the pending tx's in the UI:

Screenshot from 2024-08-02 15-25-45

And once I re-enabled it, the all changed their status to Failed, as expected:

Screenshot from 2024-08-02 15-26-16

Nicely done Chris!

@chmanie chmanie merged commit a93d256 into master Aug 6, 2024
4 of 6 checks passed
@chmanie chmanie deleted the fix/fail-pending-transactions branch August 6, 2024 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants