Skip to content

Commit

Permalink
Add Honey To MM button
Browse files Browse the repository at this point in the history
  • Loading branch information
famole committed Dec 5, 2020
1 parent a1dbe21 commit 92ef205
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/pages/TokenPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useState, useCallback } from 'react'
import 'feather-icons'
import { withRouter } from 'react-router-dom'
import { Text } from 'rebass'
Expand All @@ -16,6 +16,7 @@ import TokenChart from '../components/TokenChart'
import { BasicLink } from '../components/Link'
import Search from '../components/Search'
import { formattedNum, formattedPercent, getPoolLink, getSwapLink, localNumber } from '../utils'
import { addTokenToMetamask } from '../utils/addTokenToMetamask'
import { useTokenData, useTokenTransactions, useTokenPairs } from '../contexts/TokenData'
import { TYPE, ThemedBackground } from '../Theme'
import { transparentize } from 'polished'
Expand Down Expand Up @@ -109,6 +110,8 @@ function TokenPage({ address, history }) {
document.querySelector('body').scrollTo(0, 0)
}, [])

const HNY_SYMBOL = 'HNY'

// detect color from token
const backgroundColor = useColor(id, symbol)

Expand Down Expand Up @@ -167,6 +170,9 @@ function TokenPage({ address, history }) {
})
}, [])

const { ethereum } = window
const handleAddHnyToMM = useCallback((id, symbol) => addTokenToMetamask(ethereum, id, symbol), [])

return (
<PageWrapper>
<ThemedBackground backgroundColor={transparentize(0.6, backgroundColor)} />
Expand Down Expand Up @@ -222,6 +228,15 @@ function TokenPage({ address, history }) {
</RowFixed>
<span>
<RowFixed ml={below500 ? '0' : '2.5rem'} mt={below500 ? '1rem' : '0'}>
{symbol != undefined && HNY_SYMBOL === symbol && (
<ButtonDark
onClick={() => handleAddHnyToMM(id, symbol)}
style={{ marginRight: '0.4rem' }}
color={backgroundColor}
>
+ Add HNY to MetaMask
</ButtonDark>
)}
{!!!savedTokens[address] && !below800 ? (
<Hover onClick={() => addToken(address, symbol)}>
<StyledIcon>
Expand Down

0 comments on commit 92ef205

Please sign in to comment.