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

Added a warning icon if transfer cost is higher than token market value #236

Merged
merged 7 commits into from
Dec 14, 2021

Conversation

DaniSomoza
Copy link
Contributor

@DaniSomoza DaniSomoza commented Dec 9, 2021

What it solves

Resolves #164

How this PR fixes it

Added a Warning Icon & Tooltip if transfer cost is higher than token market value.
Also Added a new CurrencyCell Component

How to test it

Screenshots

Captura de pantalla 2021-12-09 a las 14 23 57

@github-actions
Copy link

github-actions bot commented Dec 9, 2021

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Dec 9, 2021

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 1 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

github-actions bot commented Dec 9, 2021

@@ -108,13 +114,52 @@ const App: React.FC = () => {
}
}, [balancesError]);

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about creating a useWeb3 hook? for avoid passing down props to de final CurrencyCell. You can gather the chains.ts info there as well as we are going to remove it later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that it's a good idea to create a useWeb3 hook, but I think that we should keep it in the App.tsx because we only want instantiate web3 and call getGasPrice only once and not in each CurrencyCell.

Copy link
Member

Choose a reason for hiding this comment

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

+1 for a separate hook, I find that it vastly improves readability

Copy link
Member

Choose a reason for hiding this comment

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

Could perhaps be a separate ticket @dasanra ? as TX Builder and Drain Safe can share the same hook and as @DaniSomoza mentioned me offline, we will need a context provider as well for avoid instance recreation.

Copy link
Member

Choose a reason for hiding this comment

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

Why would we want to avoid it? In the drain-safe app, it's only used in one component and then passed down via props. To me, it looks like just moving it to a separate file

Copy link
Member

Choose a reason for hiding this comment

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

For avoid the prop to only exist to be sent down. In this case in the Balances I think

Copy link
Member

Choose a reason for hiding this comment

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

but the context is fine isn't it ? I mean, a context for the web3 instance and a hook to instantiate it using our getChainInfo populated with RPC url (task in progress) could be helpful for retrieving it in any level of the component tree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done! Added useWeb3.js hook

[key in CHAINS]: null | ((token?: string) => string);
} = {
[CHAINS.MAINNET]: (token) => `https://mainnet.infura.io/v3/${token}`,
[CHAINS.MORDEN]: null,
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to include chains to this enum if we don't support them?

Copy link
Contributor

Choose a reason for hiding this comment

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

We are doing a copy 1:1 of what we have on TX-Builder. This is to be deprecated with #235 in both apps

@@ -108,13 +114,52 @@ const App: React.FC = () => {
}
}, [balancesError]);

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

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

+1 for a separate hook, I find that it vastly improves readability

<Balances
ethFiatPrice={ethFiatPrice}
gasPrice={gasPrice}
web3={web3}
Copy link
Member

Choose a reason for hiding this comment

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

With the useWeb3 new hook you don't really need to pass it down right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I decided to keep the const { web3 } = useWeb3(); and setGasPrice useState + useEffect in the App.tsx, But maybe makes sense to declare it directly in the Balances Component

Copy link
Member

Choose a reason for hiding this comment

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

Really in CurrencyCell. In Balances you don't need i think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but as we talked in the other thread we will need a context provider for avoid instance recreation. And we will address it in a different ticket.

Copy link
Member

Choose a reason for hiding this comment

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

ahh right 😂 ... so let's improve it later

@JagoFigueroa
Copy link
Contributor

Tested and verified, top job my good Dani

@DaniSomoza DaniSomoza merged commit cb5feb8 into development Dec 14, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2021
@dasanra dasanra deleted the feature/drain-safe-warn-low-value-tokens branch January 17, 2022 13:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Drain Safe] Warn for those tokens with really low amount or USD value
5 participants