-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1775 from kleros/feat/new-stake-flow
feat(web): new-stake-flow
- Loading branch information
Showing
21 changed files
with
1,046 additions
and
579 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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)], | ||
}); | ||
|
||
const { data: allowance, refetch: refetchAllowance } = useReadPnkAllowance({ | ||
query: queryConfig, | ||
args: [address ?? "0x", klerosCoreAddress[DEFAULT_CHAIN]], | ||
}); | ||
|
||
return { balance, jurorBalance, allowance, refetchAllowance }; | ||
}; |
This file contains 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 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.