Skip to content

Commit

Permalink
Merge pull request #277 from wearekickback/dev
Browse files Browse the repository at this point in the history
Added warning when not logged in (#276)
  • Loading branch information
makoto authored Jan 31, 2020
2 parents b7f9d90 + 1e8a105 commit 5513b01
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/api/resolvers/tokenResolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,15 @@ const resolvers = {
const balance = await web3.eth.getBalance(account)
return {
balance,
account,
allowance: balance
}
}

const contract = getTokenContract(web3, tokenAddress, detailedERC20ABI)
const allowance = await contract.allowance(account, partyAddress).call()
const balance = await contract.balanceOf(account).call()
return { allowance, balance }
return { allowance, balance, account }
} catch (err) {
console.log('Failed to fetch tokenAllowance', err)
return { allowance: null }
Expand Down
9 changes: 8 additions & 1 deletion src/components/SingleEvent/Approve.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ const Approve = ({
decimals,
isAllowed,
hasBalance,
refetch
refetch,
account
}) => {
const canRSVP = isAllowed && hasBalance

if (canRSVP) {
return <Going>You can now RSVP</Going>
} else if (!account) {
return (
<WarningBox>
We cannot read your wallet balance. Please Sign in first.
</WarningBox>
)
} else if (!hasBalance) {
return (
<WarningBox>
Expand Down
7 changes: 5 additions & 2 deletions src/components/SingleEvent/EventCTA.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class EventCTA extends Component {
>
{({
data: {
tokenAllowance: { allowance, balance }
tokenAllowance: { allowance, balance, account }
},
loading,
refetch
Expand All @@ -142,6 +142,7 @@ class EventCTA extends Component {
balance,
isAllowed,
hasBalance,
account,
refetch
})
}}
Expand Down Expand Up @@ -170,7 +171,8 @@ class EventCTA extends Component {
isAllowed,
hasBalance,
balance,
refetch
refetch,
account
}) {
return (
<>
Expand Down Expand Up @@ -204,6 +206,7 @@ class EventCTA extends Component {
isAllowed={isAllowed}
hasBalance={hasBalance}
refetch={refetch}
account={account}
/>
<RSVP
tokenAddress={tokenAddress}
Expand Down

0 comments on commit 5513b01

Please sign in to comment.