Skip to content

Commit

Permalink
feat: Add tx link
Browse files Browse the repository at this point in the history
  • Loading branch information
1marcghannam committed May 25, 2023
1 parent 50c1757 commit ebd20c7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ export const RaffleCreate = () => {
<Text fontSize="lg" color="brand.gray_70" fontWeight="600">
Create dynamic or static raffle
</Text>
<Link as={RouterLink} to={Routes.FAQ} color="brand.blue">
<Link
as={RouterLink}
to={Routes.FAQ}
color="brand.blue"
textDecoration="underline">
Need help? Check out our FAQ page.
</Link>
</Center>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react'
import React from 'react'
import { useAccount } from 'wagmi'
import {
Container,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React, { useState, useEffect } from 'react'
import { Button, Text, Flex, Heading } from '@chakra-ui/react'
import { Button, Text, Flex, Heading, Link } from '@chakra-ui/react'
import { useNetwork } from 'wagmi'

import { pickWinners } from '@ui/features/raffleDetail'

export const PickWinners = ({ id, reset, asyncManager, store }) => {
const [success, setSuccess] = useState(false)
const [txHash, setTxHash] = useState(null)
const { chain } = useNetwork()

const componentDidMount = () => {
useEffect(() => {
pickWinners({
id,
asyncManager,
success: setSuccess,
update: store.update
txHash: setTxHash
})
}
useEffect(componentDidMount, [])
}, [])

return (
success && (
Expand All @@ -23,6 +25,17 @@ export const PickWinners = ({ id, reset, asyncManager, store }) => {
Pick Winners
</Heading>
<Text>Successfully picked winners for raffle id `{id}`.</Text>
{txHash && (
<Text>
<Link
href={`${chain.blockExplorers.default}${txHash}#eventlog`}
color="brand.blue"
textDecoration="underline"
isExternal>
View VRF transaction
</Link>
</Text>
)}
<Flex mt="2" justify="end">
<Button variant="default" onClick={() => reset(store)}>
Close
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const joinRaffle = async ({
}
}

export const pickWinners = async ({ id, asyncManager, success, update }) => {
export const pickWinners = async ({ id, asyncManager, success, txHash }) => {
try {
/*
* @FeatureEnhancement
Expand All @@ -90,7 +90,7 @@ export const pickWinners = async ({ id, asyncManager, success, update }) => {

const value = BigNumber.from('100000000000000000') // 0.1 LINK
const payload: contracts.ResolveRaffleParams = { id, value }
const { wait } = await contracts.resolveRaffle(payload)
const { wait, hash } = await contracts.resolveRaffle(payload)

asyncManager.waiting()

Expand All @@ -100,6 +100,8 @@ export const pickWinners = async ({ id, asyncManager, success, update }) => {

asyncManager.success()

txHash(hash)

success(true)
return true
} catch (error) {
Expand Down

0 comments on commit ebd20c7

Please sign in to comment.