Skip to content

Commit

Permalink
Merge pull request #69 from oasisprotocol/ml/amend-vote-loading-flow
Browse files Browse the repository at this point in the history
Show loading screen, after user confirms vote tx
  • Loading branch information
lubej authored Apr 2, 2024
2 parents 5ee209e + 92b0d53 commit c4f09f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 5 additions & 3 deletions frontend/src/pages/HomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const HomePage: FC = () => {
const {
state: { isConnected, account },
vote,
getTransaction,
canVoteOnPoll,
} = useWeb3()
const {
Expand Down Expand Up @@ -90,15 +91,16 @@ export const HomePage: FC = () => {
setIsLoading(true)

try {
setPageStatus('loading')

const canVote = await handleCanVoteOnPoll()
if (canVote === null) {
setIsLoading(false)
return
}

await vote(selectedChoice)
const txResponse = (await vote(selectedChoice))!
setPageStatus('loading')
await getTransaction(txResponse.hash)

setPreviousVoteForCurrentWallet(selectedChoice)

setPageStatus('success')
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/providers/Web3Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ export const Web3ContextProvider: FC<PropsWithChildren> = ({ children }) => {
unsignedTx.gasLimit = MAX_GAS_LIMIT
unsignedTx.value = 0n

const txResponse = await signer.sendTransaction(unsignedTx).catch(handleKnownEthersErrors)

return await getTransaction(txResponse.hash)
return await signer.sendTransaction(unsignedTx).catch(handleKnownEthersErrors)
}

const getVoteCounts = async () => {
Expand Down

0 comments on commit c4f09f2

Please sign in to comment.