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

Switch out app utilities with AragonUI utilities #1166

Closed

Conversation

ECWireless
Copy link
Contributor

@ECWireless ECWireless commented Jun 15, 2020

Fixes #1156

This PR is a work in progress.

Utilities to import from AragonUI:

  • shortenAddress()
  • addressesEqual()
  • formatTokenAmount() in place of formatNumber()

facuspagnuolo and others added 30 commits April 16, 2019 21:11
* Copy improvements

* More specific copy

* Reverting controversial change
* Change confusing token manager copy
* voting: fetch active account votes in script

* Move connectedAccount out of the store and cache

* Add comment about using strings over symbols

* Move functions to helpers

* Update comments

Co-Authored-By: 2color <[email protected]>

* Add newline
Improve the filters layout:

- Move TransfersFilters to its own component.
- Make the layout work at all sizes.
- Update the download button so it looks like the other icon buttons.
- Update some labels:
  - “Date range” => “Period”
  - “Transfer type” => “Type” (since it is already below the “Transfers” title).
- Select the last 90 days (rolling) by default.
* Voting: fix bug with votes not loading initially

* Add comment
Fixes aragon/client#734.

With aragon/aragon.js#277 we now get the actual errors back from the RPC when a call goes wrong (e.g. naive `token.symbol()` on DAI) and we need to handle these explicitly.

This PR converts a lot of the token fallback-related bits into simpler Promise-based code and adds explicit handlers for their error cases.
* TransferFilters: remove duplicate margin rules

* DatePicker: update today border color

* DateRangePicker: update to allow null values on dates

* Transfers: refactor to no default date selection

* DateRangeInput: fix font family declaration

Co-Authored-By: AquiGorka <[email protected]>

* Transfers: recover non-breaking space

* DateRangeInput: improve placeholder logic and add input placeholder for screen readers

* DateRangeInput: improve on placeholder for accesibility
…ragon#822)

* feat(Payroll): small SLOAD optimizations to _transferTokensAmount

* fix: put back accidentally deleted line from merge conflict
)

Votes can sometimes be created in the same block, and so will have the same start (and end time) attached.

In this case, we should use their `voteId`s for sorting, so that the vote numbers still look correct (as you would expect a "newer" vote, with a larger `voteId`, to have a later end date).
Prevents the app to crash on the current Firefox Nightly.
* VotingCard: update informative to question

* Math utils: refactor scale values set to use bn

* Add jest and babel-jest deps for tests

* babelrc: add env tests presets

* Add math utils tests
Noticeable improvement: the side panels transition should be smoother.

Changes:

- Move panels in their own components, so that the rendering of
  SidePanel can be skipped entirely.

- Memoize the object returned by usePanel(), so that it can be compared
  using a strict equality.

- Move the voting panel actions in their own component fetching their
  data, so that the panel component doesn’t need to render that much
  anymore.

- Don’t recreate `votes` every second, instead only do it if any
  “opened” status has changed.
sohkai and others added 5 commits June 16, 2020 12:41
* Upgrade aragonOS dependency

For Vault, Agent and Finance. To fix Istanbul related issues.
See https://github.com/aragon/aragonOS/releases/tag/v4.3.0 for more context.

* payroll: fix gas values in tests

* agent: fix tests

`isValidSignature` was calling the `bytes` version due to overloading
issue with Truffle.

* Fix CI, address PR aragon#1172 comments
- Also, remove addressesEqual() from web3-utils.js
- Also, remove addressesEqual() from web3-utils.js
@ECWireless
Copy link
Contributor Author

@sohkai These are the only duplicated utilities I could find, but let me know if there are others I can add to the list!

Also, I couldn't find any way to install the Survey app (?), so I've skipped replacing formatAmount()in that app for these commits.

@ECWireless ECWireless marked this pull request as ready for review June 18, 2020 18:08
@auto-assign auto-assign bot requested review from bpierre and Evalir June 18, 2020 18:08
@sohkai
Copy link
Contributor

sohkai commented Jun 19, 2020

Also, I couldn't find any way to install the Survey app (?), so I've skipped replacing formatAmount()in that app for these commits.

No worries, we are removing the Survey app from this repo soon anyway :). Thanks for doing this!

Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

Looking really good @ECWireless! Perhaps @bpierre or @Evalir can do a quick scan to check if we have any other utilities that can be deduped, but otherwise this is great!

I've also left a few comments for us to work out and hopefully get this merged soon!

@@ -1,8 +1,7 @@
import React from 'react'
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, sorry for the rework—we are likely to have a conflict here against #1113.

We'll merge that one first, and then it should be pretty easy to rollback these changes against Voting here to solve any conflicts :).

@@ -1,6 +1,6 @@
import Aragon, { events } from '@aragon/api'
import { addressesEqual } from '@aragon/ui'
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah... this may be a problem @bpierre.

This is still run in the context of a browser, but I think we should aim for this script to be runnable in a node / etc. environment. AFAIK nothing else used by the script should cause an issue.

From what I remember, importing @aragon/ui may force a browser context?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be fine, aragonUI is now compatible with non-DOM environments: https://github.com/aragon/aragon-ui/pull/699

But another thing to take care of would be to ensure that the entire library doesn’t get included in script.js. That would require using --experimental-scope-hoisting, but we were having issues with it IIRC.

What would you guys think of inlining the function in every script.js using it, until we move to Parcel 2 or another bundler with a good support for tree shaking? https://github.com/aragon/aragon-ui/blob/master/src/utils/web3.js#L82-L92

apps/token-manager/app/src/screens/Holders.js Outdated Show resolved Hide resolved
@Evalir Evalir force-pushed the ecwireless-add-aragonui-utilities branch from 6c5d3f2 to 548a172 Compare June 26, 2020 01:20
Copy link
Contributor

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

Looking awesome @ECWireless ! Checked for any utilities left and didn't see any that we could move for now. Did some QA over the apps and everything seems to be consistent. Added 2 commits for:

  • Bumping Voting's @aragon/ui version to 1.4.2, as the previous one didn't include formatTokenAmount and was thus breaking the app. (Will be added by Voting: use BN.js everywhere #1113 as well)
  • Re-adding date formatting changes added in a previous commit by another contributor. This was probably due to switching branches on a commit that didn't have them!
  • Fixing some small typos. :)

Pretty confident this should be good to go now, but if you have any time @bpierre you can take a look! We will still have to wait for #1113 though.

@coveralls
Copy link

coveralls commented Jun 26, 2020

Coverage Status

Coverage remained the same at 97.642% when pulling 77234e2 on ECWireless:ecwireless-add-aragonui-utilities into 41ac706 on aragon:master.

@@ -6,7 +6,7 @@ import {
Incoming,
Outgoing,
} from '../transfer-types'
import { addressesEqual } from '../lib/web3-utils'
import { addressesEqual} from '@aragon/ui'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { addressesEqual} from '@aragon/ui'
import { addressesEqual } from '@aragon/ui'

@@ -1,6 +1,6 @@
import Aragon, { events } from '@aragon/api'
import { addressesEqual } from '@aragon/ui'
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be fine, aragonUI is now compatible with non-DOM environments: https://github.com/aragon/aragon-ui/pull/699

But another thing to take care of would be to ensure that the entire library doesn’t get included in script.js. That would require using --experimental-scope-hoisting, but we were having issues with it IIRC.

What would you guys think of inlining the function in every script.js using it, until we move to Parcel 2 or another bundler with a good support for tree shaking? https://github.com/aragon/aragon-ui/blob/master/src/utils/web3.js#L82-L92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: prefer utilities provided by aragonUI