Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into track_selection
Browse files Browse the repository at this point in the history
  • Loading branch information
uDaiko committed Oct 16, 2024
2 parents cbad08a + 3bef517 commit 70a08f3
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 132 deletions.
4 changes: 2 additions & 2 deletions .papi/polkadot-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"metadata": ".papi/metadata/ksm.scale"
},
"fastWestend": {
"wsUrl": "wss://rpc-test-network-1.novasamatech.org",
"wsUrl": "wss://rpc-test-network-1.novasama-tech.org",
"metadata": ".papi/metadata/fastWestend.scale"
},
"westend": {
Expand All @@ -31,4 +31,4 @@
"metadata": ".papi/metadata/westendPeople.scale"
}
}
}
}
2 changes: 1 addition & 1 deletion src/assets/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
"options": ["testnet"],
"nodes": [
{
"url": "wss://rpc-test-network-1.novasamatech.org",
"url": "wss://rpc-test-network-1.novasama-tech.org",
"name": "Development node"
}
],
Expand Down
11 changes: 6 additions & 5 deletions src/components/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
import { AlertCircle } from 'lucide-react'
import { AlertCircle, InfoIcon } from 'lucide-react'

interface Props {
title: string
message: string
title?: string
message: string | React.ReactNode
variant?: 'default' | 'destructive' | null
}

export const AlertNote = ({ title, message, variant = 'default' }: Props) => (
<Alert variant={variant}>
<AlertCircle className="h-4 w-4" />
<AlertTitle>{title}</AlertTitle>
{variant === 'destructive' && <AlertCircle className="h-4 w-4" />}
{variant === 'default' && <InfoIcon className="h-4 w-4" />}
{title && <AlertTitle>{title}</AlertTitle>}
<AlertDescription>{message}</AlertDescription>
</Alert>
)
52 changes: 2 additions & 50 deletions src/components/LocksCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { planckToUnit } from '@polkadot-ui/utils'
import { Button } from './ui/button'
import { Title } from './ui/title'
import { ContentReveal } from './ui/content-reveal'
import { BadgeCent, Clock2, Info, LockKeyholeOpen, Vote } from 'lucide-react'
import { BadgeCent, Clock2, Info, LockKeyholeOpen } from 'lucide-react'
import { Badge } from './ui/badge'
import { useAccounts } from '@/contexts/AccountsContext'
import {
Expand All @@ -30,7 +30,6 @@ export const LocksCard = () => {
const [expectedBlockTime, setExpectedBlockTime] = useState(0)
const { api, assetInfo } = useNetwork()
const { voteLocks, delegationLocks } = useLocks()
const [ongoingVoteLocks, setOngoingVoteLocks] = useState<VoteLock[]>([])
const [freeLocks, setFreeLocks] = useState<Array<VoteLock | DelegationLock>>(
[],
)
Expand All @@ -47,14 +46,11 @@ export const LocksCard = () => {
useEffect(() => {
if (!currentBlock) return

const tempOngoingLocks: VoteLock[] = []
const tempFree: Array<VoteLock | DelegationLock> = []
const tempCurrent: VoteLock[] = []

voteLocks.forEach((voteLocks) => {
if (voteLocks.isOngoing) {
tempOngoingLocks.push(voteLocks)
} else if (voteLocks.endBlock <= currentBlock) {
if (voteLocks.endBlock <= currentBlock) {
tempFree.push(voteLocks)
} else {
tempCurrent.push(voteLocks)
Expand All @@ -74,7 +70,6 @@ export const LocksCard = () => {
}
})

setOngoingVoteLocks(tempOngoingLocks)
setFreeLocks(tempFree)
setCurrentLocks(tempCurrent)
setCurrentDelegationLocks(tempDelegationLocks)
Expand Down Expand Up @@ -273,49 +268,6 @@ export const LocksCard = () => {
</>
</ContentReveal>
</Card>
<Card className="h-max border-2 p-2 px-4">
<div className="flex gap-x-2">
<Title variant="h4">Votes</Title>
<Popover>
<PopoverTrigger>
<Info className="h-3 w-3 text-gray-500" />
</PopoverTrigger>
<PopoverContent>
<p className="max-w-[15rem]">
Votes casted on a referendum that is still in deciding
phase.
</p>
</PopoverContent>
</Popover>
</div>
<div className="font-unbounded text-5xl font-bold">
{ongoingVoteLocks.length}
<Vote className="ml-1 inline-block h-8 w-8 text-gray-200" />
</div>
{
<ContentReveal hidden={!ongoingVoteLocks.length}>
{ongoingVoteLocks.map(({ amount, refId, trackId }) => {
return (
<div key={refId}>
<ul>
<li>
<Badge>#{refId}</Badge>{' '}
<span className="ml-2 border-l-2 pl-2 text-xs font-semibold text-slate-400">
{trackId}
</span>
<div>
<BadgeCent className="inline-block h-4 w-4 text-gray-500" />{' '}
{planckToUnit(amount, assetInfo.precision)}{' '}
{assetInfo.symbol}
</div>
</li>
</ul>
</div>
)
})}
</ContentReveal>
}
</Card>
</>
)}
</div>
Expand Down
19 changes: 1 addition & 18 deletions src/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,7 @@ export const Header = () => {
</SheetContent>
</Sheet>
<div className="flex w-full justify-between">
<div>
{/* TODO: split submenu based on routes
<Menubar>
<MenubarMenu>
<MenubarTrigger>File</MenubarTrigger>
<MenubarContent>
<MenubarItem>
New Tab <MenubarShortcut>⌘T</MenubarShortcut>
</MenubarItem>
<MenubarItem>New Window</MenubarItem>
<MenubarSeparator />
<MenubarItem>Share</MenubarItem>
<MenubarSeparator />
<MenubarItem>Print</MenubarItem>
</MenubarContent>
</MenubarMenu>
</Menubar>*/}
</div>
<div></div>
<div className="flex">
<DropdownMenu>
<DropdownMenuTrigger asChild>
Expand Down
12 changes: 7 additions & 5 deletions src/hooks/useGetDelegateTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ export const useGetDelegateTx = () => {
>[] = []

Object.values(delegations || {}).forEach((delegation) => {
delegation.map(({ trackId }) => {
removeDelegationsTxs.push(
api.tx.ConvictionVoting.undelegate({ class: trackId }),
)
})
delegation
.filter(({ trackId }) => tracks.includes(trackId))
.map(({ trackId }) => {
removeDelegationsTxs.push(
api.tx.ConvictionVoting.undelegate({ class: trackId }),
)
})
})

const delegationTxs = tracks.map((trackId) =>
Expand Down
8 changes: 8 additions & 0 deletions src/hooks/useGetSubsquareRefUrl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useNetwork } from '@/contexts/NetworkContext'

export const useGetSubsquareRefUrl = () => {
const { network } = useNetwork()

return (refId: number) =>
`https://${network}.subsquare.io/referenda/${refId.toString()}`
}
5 changes: 2 additions & 3 deletions src/pages/Delegate/MultiTransactionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,8 @@ export const MultiTransactionDialog = ({
<DialogDescription>
<div className="my-4">
{step === 1 &&
'The delegation process is in 2 parts. First, please sign a transaction to remove current votes and delegations.'}
{step === 2 &&
'Votes and delegation are removed. You are now ready to sign a transaction to delegate.'}
"First, let's clear previous votes or delegations."}
{step === 2 && 'Now, we are ready to delegate.'}
</div>
<div className="text-end">
<Button
Expand Down
Loading

0 comments on commit 70a08f3

Please sign in to comment.