Skip to content

Conversation

defispartan
Copy link
Collaborator

@defispartan defispartan commented Nov 18, 2022

General Changes

approvepermitflow

  • Adds toggle menu for approve and permit selection which is persisted through modals/sessions with localStorage

Developer Notes

  • Moves tryPermit flag to decide whether permit is available for a market/asset pair to poolSlice
  • The wallet preference for approve vs permit is handled in walletSlice
  • Uses feat: add default gas estimation for permit actions aave-utilities#461 to generate default gas estimation for permit actions
  • Standardizes permitConfig file and it's usage to always use lowercase

Author Checklist

Please ensure you, the author, have gone through this checklist to ensure there is an efficient workflow for the reviewers.

  • The base branch is set to main
  • The title is using Conventional Commit formatting
  • The Github issue has been linked to the PR in the Development section
  • The General Changes section has been filled out
  • Developer Notes have been added (optional)

If the PR is ready for review:

  • The PR is in Open state and not in Draft mode
  • The Ready for Dev Review label has been added

Reviewer Checklist

Please ensure you, as the reviewer(s), have gone through this checklist to ensure that the code changes are ready to ship safely and to help mitigate any downstream issues that may occur.

  • End-to-end tests are passing without any errors
  • Code style generally follows existing patterns
  • Code changes do not significantly increase the application bundle size
  • If there are new 3rd-party packages, they do not introduce potential security threats
  • If there are new environment variables being added, they have been added to the .env.example file as well as the pertinant .github/actions/* files
  • There are no CI changes, or they have been approved by the DevOps and Engineering team(s)
  • Code changes have been quality checked in the ephemeral URL
  • QA verification has been completed
  • There are two or more approvals from the core team
  • Squash and merge has been checked

@defispartan defispartan changed the title chore/permit modifications chore: permit modifications Nov 18, 2022
handleApproval={() => approval({ amount: amountToRepay, underlyingAsset: poolAddress })}
actionText={<Trans>Repay {symbol}</Trans>}
actionInProgressText={<Trans>Repaying {symbol}</Trans>}
approvalFallback={
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you elaborate on why this is needed now? don't really understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Permit+Approve

In the updated design, the retryWithApproval is no longer a separate state in the modal, it's a button which is always available inside the TxActionsWrapper, so this component needs to be able to trigger both an approve and permit, but the handleApproval function is only handling one at a time.

The other option I considered is adding a parameter to the handleApproval function which specifies this override, but this gets very complicated because the function is passed as a parameter through SupplyActions -> TxActionsWrapper -> useTransactionHandler

handleAction={action}
handleApproval={() => approval()}
handleApproval={() =>
approval({ amount: repayAmount, underlyingAsset: poolReserve.aTokenAddress })
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Need to test this to figure out why the current version is working with blank parameters

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason this works is that these params are only used by permit, added them anyways so it will support in the future

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it clean it up if we had a permit function and an approval function in useTransactionHandler? That way it'd be clear when/why these parameters are needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This probably doesn't make sense to modify until changes to aave-utilities are finished. These two prs (456 and 458) combine the steps of building approve and permit, which would make these parameters completely unnecessary. The same params are used to build both approve and permit, so it doesn't make much sense to have them duplicated

@github-actions
Copy link

@github-actions
Copy link

github-actions bot commented Nov 18, 2022

📦 Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 472.35 KB (🟡 +936 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Two Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/governance 62.38 KB (-3 B) 534.73 KB
/staking 20.52 KB (🟡 +26 B) 492.87 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@github-actions
Copy link

@defispartan defispartan added the Ready for QA Review Ready for QA engineer reviews label Nov 22, 2022
@sakulstra
Copy link
Collaborator

I generally think this is an improvement for wallets not supporting permit.
That said i think the implementation/ux of that is pretty weird.

The path for "doing approval" instead of permit is a link ... which acts like a button?
Which at least for me is kinda unexpected and very non-obvious.

Why isn't there just a switch or sth to switch between the two methods?
image

Wdyt?

@bojanaave bojanaave added QC Passed and removed Ready for QA Review Ready for QA engineer reviews labels Nov 23, 2022
@bojanaave
Copy link
Contributor

LGTM
Screen Shot 2022-11-23 at 11 45 24

@iamanastasia
Copy link
Contributor

@sakulstra My 5 cents on that:

  • it's not a button not to confuse users with 3 buttons (in case if we just put an approve button on top). My guess here, most of users are giving permissions with signed messages just fine. So it's a help link on the bottom to reference when there is a problem.
  • it's not a switch, partially because a button is more preferable imho, and because it requires some space and more UI changes. Also it's 2 clicks versus 1 click. Thus, to make a quick fix it's a link for now. I'm in favour of making a bigger change here in terms of UI, more clear messages and different states, but I also see people struggling here and now.

@iamanastasia
Copy link
Contributor

I would add a question to 'Approval doesn't work?' and redirect users to this article instead to learn more details (Learn more link in the tooltip)

@github-actions
Copy link


const tryPermit =
currentMarketData.v3 &&
permitByChainAndToken[chainId]?.[utils.getAddress(poolAddress).toLowerCase()];
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed this doesn't work on forks because of a different chainId. We could move this to a helper in the store and handle the fork logic in there as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, this belongs in the store anyways

});

// set use permit to false to retry with normal approval
setUsePermit(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there's some cleanup we could do in here now. I don't think we need usePermit as state and we can just use the param passed in. It's also being returned from this hook, but doesn't look like it's used anywhere.

@defispartan defispartan marked this pull request as ready for review December 14, 2022 05:54
@defispartan defispartan added Ready for QA Review Ready for QA engineer reviews Ready for Dev Review Read for frontend engineer reviews labels Dec 14, 2022
@github-actions
Copy link

@iamanastasia
Copy link
Contributor

great job! @defispartan

@bojanaave
Copy link
Contributor

LGTM
Screen Shot 2022-12-14 at 12 12 35
Screen Shot 2022-12-14 at 12 11 32
Screen Shot 2022-12-14 at 12 11 16

@bojanaave bojanaave added QC Passed and removed Ready for QA Review Ready for QA engineer reviews labels Dec 14, 2022
@github-actions
Copy link

<SvgIcon>{currentMethod === ApprovalMethod.APPROVE && <CheckIcon />}</SvgIcon>
</ListItemIcon>
</MenuItem>
</Menu>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could these menu item components be simplified? They look identical other than the ApprovalMethod.VALUE

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would end up with more code to split to separate component and pass currentMethod, buttonMethod, setMethod, and handleClose as props so I think it's fine to leave as is

Copy link
Contributor

@drewcook drewcook left a comment

Choose a reason for hiding this comment

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

In all the useRootStore(state => ...), much like we do with our other store slices, using an object destructrue syntax can simplify it and just could use useRootStore().

@github-actions
Copy link

@github-actions
Copy link

@github-actions
Copy link

@defispartan defispartan merged commit d538b12 into main Dec 14, 2022
@defispartan defispartan deleted the chore/permit-modifications branch December 14, 2022 20:15
grothem pushed a commit that referenced this pull request Dec 16, 2022
* feat: use updated permit function

* chore: bump package for proper export

* chore: standardize permitConfig casing

* chore: small styling changes to approval flow

* chore: remove approval component which was replaced with tooltip

* chore: remove retry with approval text placements

* chore: modify approval function for explicit parmeters and allow force overview of permit

* fix: build errors on handleApproval

* chore: run i18n

* chore: revert permit utility modification

* chore rework approval fallback params

* chore: update actions components approval params

* chore: update text and link

* chore: cleanup unused state

* feat: move tryPermit logic to zustand store

* feat: add approval tx to gas estimation

* chore: remove unused import

* feat: design updates for new approve/permit flow

* feat: add wallet approval preferences to walletSlice

* feat: add approval preference button

* feat: apply approval method toggle in TxActionsWrapper

* chore: rework params for approval toggle

* chore: bump utils package to include permit gas estimations

* feat: use wallet approval preference in tx handler

* chor: bump icon size

* chore: handle edge case with already approved action

* chore: rename variable for consistency

* test(fix): fix e-mode for polygon

* chore: review

* chore: review

* fix: localStorage override with multiple wallets

Co-authored-by: bojank93 <[email protected]>
Co-authored-by: NikitaY <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QC Passed Ready for Dev Review Read for frontend engineer reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants