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

refactor: Fetch allowances for vault only once in join flow #3642

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

garethfuller
Copy link
Collaborator

@garethfuller garethfuller commented Jul 6, 2023

Description

Previously we were refetching vault allowances everytime the the user changed amounts in the join form, this was a side-effect of re-constructing approval actions required in the preview modal. This PR makes that allowance fetching optional for the get actions function and adds a separate function to ensure allowances are updated for a given spender. Then in the join pool provider, onBeforeMount, we just fetch allowances for the vault and skip the fetching for reconstructing the approval actions as token amounts are changed.

Type of change

  • Code refactor / cleanup

How should this be tested?

  • Test approvals work in join flows and there is no longer excessive allowance fetching.

Checklist:

  • I have performed a self-review of my own code
  • I have requested at least 1 review (If the PR is significant enough, use best judgement here)
  • I have commented my code where relevant, particularly in hard-to-understand areas
  • If package-lock.json has changes, it was intentional.
  • The base of this PR is master if hotfix, develop if not

@vercel
Copy link

vercel bot commented Jul 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
beta-app-v2 ✅ Ready (Inspect) Visit Preview Jul 6, 2023 0:49am
1 Ignored Deployment
Name Status Preview Updated (UTC)
app-v2 ⬜️ Ignored (Inspect) Jul 6, 2023 0:49am

@@ -90,12 +91,19 @@ export default function useTokenApprovalActions() {
}
}

async function updateAllowancesFor(spender: string): Promise<void> {
await injectSpenders([spender]);
await refetchAllowances();
Copy link
Collaborator

Choose a reason for hiding this comment

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

cannot be in Promise.all?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, seems not

@garethfuller garethfuller merged commit bd9a333 into develop Jul 6, 2023
@garethfuller garethfuller deleted the refactor/join-allowance-updates branch July 6, 2023 15:00
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