-
Notifications
You must be signed in to change notification settings - Fork 49
feat(web): new-stake-flow #1775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,046
−579
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4bf724d
feat(web): new-stake-flow-v1
tractorss d5c9c27
refactor(web): downgrade-viem-and-sonar-feedback
tractorss 5b50c73
refactor(web): refactor-new-stake-flow
tractorss bfcb020
refactor(web): steps-state
tractorss d59478b
refactor(web): rabbit-feedback
tractorss cba2c6c
Merge branch 'dev' into feat/new-stake-flow
tractorss 64da137
fix(web): react-tanstack-query-error-catch
tractorss d2581e5
chore: remove-kleros-app-from-workspace
tractorss 364ad1f
fix: wrap-set-stake-refetch-in-retriable-function
tractorss e3da0f1
refactor(web): refactor-logic
tractorss cc50fd3
Merge branch 'dev' into feat/new-stake-flow
alcercu 40fa153
chore: remove-build-command-from-netlfiy-toml
tractorss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,7 @@ | |
"web-devtools", | ||
"eslint-config", | ||
"prettier-config", | ||
"tsconfig", | ||
"kleros-app" | ||
"tsconfig" | ||
], | ||
"packageManager": "[email protected]", | ||
"volta": { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import styled, { keyframes } from "styled-components"; | ||
|
||
import SpinnerIcon from "svgs/icons/spinner.svg"; | ||
|
||
const rotating = keyframes` | ||
0%{ | ||
transform: rotate(0deg); | ||
} | ||
50%{ | ||
transform: rotate(180deg); | ||
} | ||
100%{ | ||
transform: rotate(360deg); | ||
} | ||
`; | ||
|
||
const Spinner = styled(SpinnerIcon)` | ||
path { | ||
fill: ${({ theme }) => theme.primaryBlue}; | ||
} | ||
width: 16px; | ||
height: 16px; | ||
margin-right: 4px; | ||
animation: ${rotating} 2s ease-in-out infinite normal; | ||
`; | ||
|
||
export default Spinner; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useMemo } from "react"; | ||
import styled from "styled-components"; | ||
|
||
import NewTabIcon from "svgs/icons/new-tab.svg"; | ||
|
||
import { DEFAULT_CHAIN, getChain } from "consts/chains"; | ||
|
||
import { ExternalLink } from "./ExternalLink"; | ||
|
||
const TxnLabel = styled.label<{ variant: string }>` | ||
display: flex; | ||
gap: 4px; | ||
color: ${({ theme, variant }) => (variant === "pending" ? theme.primaryBlue : theme[variant])}; | ||
cursor: pointer; | ||
path { | ||
fill: ${({ theme, variant }) => (variant === "pending" ? theme.primaryBlue : theme[variant])}; | ||
} | ||
`; | ||
|
||
interface ITxnHash { | ||
hash: `0x${string}`; | ||
variant: "success" | "error" | "pending"; | ||
} | ||
const TxnHash: React.FC<ITxnHash> = ({ hash, variant }) => { | ||
const transactionExplorerLink = useMemo(() => { | ||
return `${getChain(DEFAULT_CHAIN)?.blockExplorers?.default.url}/tx/${hash}`; | ||
}, [hash]); | ||
|
||
return ( | ||
<ExternalLink to={transactionExplorerLink} rel="noopener noreferrer" target="_blank"> | ||
<TxnLabel {...{ variant }}> | ||
{" "} | ||
<span>{hash.substring(0, 6) + "..." + hash.substring(hash.length - 4)}</span> | ||
<NewTabIcon /> | ||
</TxnLabel> | ||
</ExternalLink> | ||
); | ||
}; | ||
|
||
export default TxnHash; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ const courtDetailsQuery = graphql(` | |
paidPNK | ||
timesPerPeriod | ||
feeForJuror | ||
name | ||
} | ||
} | ||
`); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useAccount } from "wagmi"; | ||
|
||
import { DEFAULT_CHAIN } from "consts/chains"; | ||
|
||
import { REFETCH_INTERVAL } from "src/consts"; | ||
import { isUndefined } from "src/utils"; | ||
|
||
import { | ||
klerosCoreAddress, | ||
useReadPnkAllowance, | ||
useReadPnkBalanceOf, | ||
useReadSortitionModuleGetJurorBalance, | ||
} from "./contracts/generated"; | ||
|
||
interface UsePnkDataParams { | ||
courtId?: string; | ||
} | ||
|
||
/** | ||
* @description hook to provide user's pnk data. (pnk balance, pnk allowance, jurorBalance for provided courtId) | ||
* @param param0 optional court Id to fetch juror balance for. Defaults to 0 | ||
*/ | ||
export const usePnkData = ({ courtId = "0" }: UsePnkDataParams) => { | ||
const { address } = useAccount(); | ||
const queryConfig = { | ||
enabled: !isUndefined(address), | ||
refetchInterval: REFETCH_INTERVAL, | ||
}; | ||
|
||
const { data: balance } = useReadPnkBalanceOf({ | ||
query: queryConfig, | ||
args: [address!], | ||
}); | ||
|
||
const { data: jurorBalance } = useReadSortitionModuleGetJurorBalance({ | ||
query: queryConfig, | ||
args: [address ?? "0x", BigInt(courtId)], | ||
}); | ||
tractorss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const { data: allowance, refetch: refetchAllowance } = useReadPnkAllowance({ | ||
query: queryConfig, | ||
args: [address ?? "0x", klerosCoreAddress[DEFAULT_CHAIN]], | ||
}); | ||
|
||
return { balance, jurorBalance, allowance, refetchAllowance }; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.