Skip to content

Commit

Permalink
Rewards/MyRewards: add etherscan link - store link on per-user basis
Browse files Browse the repository at this point in the history
  • Loading branch information
e18r committed Nov 27, 2019
1 parent fdb017c commit 4a3de81
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/rewards/app/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class App extends React.Component {
}

claimReward = reward => {
// TODO
this.props.api.claimReward(reward.rewardId + reward.claims).toPromise()
}

Expand Down
9 changes: 6 additions & 3 deletions apps/rewards/app/components/Content/MyRewards.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types'
import React from 'react'
import React, { useState } from 'react'
import styled from 'styled-components'
import {
ContextMenu,
Expand All @@ -21,7 +21,7 @@ import {
} from '../../utils/constants'
import { Empty } from '../Card'
import Metrics from './Metrics'
import { useAppState, useNetwork } from '@aragon/api-react'
import { useAppState, useAragonApi, useNetwork } from '@aragon/api-react'
import BigNumber from 'bignumber.js'
import { displayCurrency, getStatus, getStatusId } from '../../utils/helpers'

Expand All @@ -34,10 +34,13 @@ const MyRewards = ({
}) => {
const network = useNetwork()
const rewardsEmpty = myRewards.length === 0
const { api } = useAragonApi()
const [ user, setUser ] = useState()
api.accounts().subscribe(accounts => setUser(accounts[0]))

const getEtherscanLink = reward => {
const networkChunk = network.id === 1 ? '' : `${network.type}.`
const claimHash = claimHashes[reward.rewardId]
const claimHash = claimHashes[reward.rewardId][user]
const link = `https://${networkChunk}etherscan.io/tx/${claimHash}`
return link
}
Expand Down
5 changes: 4 additions & 1 deletion apps/rewards/app/store/reward.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export async function onRewardClaimed(

let { claimsByToken = [], totalClaimsMade = 0, claimHashes = {}, } = claims

claimHashes[rewardId] = transactionHash
claimHashes[rewardId] = {
...claimHashes[rewardId],
[claimant]: transactionHash
}

const tokenIndex = claimsByToken.findIndex(token => addressesEqual(token.address, rewards[rewardId].rewardToken))

Expand Down

0 comments on commit 4a3de81

Please sign in to comment.