Skip to content
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

feat: check if the validator address belongs to the validator committee #8178

Merged
Merged
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
99bd3b1
feat: modify name column by delegationId
cpl121 Mar 7, 2024
7e930ae
feat: rename "address" column header to "delegated to"
cpl121 Mar 7, 2024
afcf76b
feat: rename epoch by epochs
cpl121 Mar 7, 2024
84bbf60
feat: update epochs logic
cpl121 Mar 7, 2024
a12bf27
Merge branches 'feat/improve-delegation-list-header' and 'develop-iot…
cpl121 Mar 8, 2024
552497d
feat: check if the validator address belongs to the validator committee
cpl121 Mar 8, 2024
d24b44e
Merge branches 'feat/improve-delegation-list-header' and 'develop-iot…
cpl121 Mar 8, 2024
053a29e
Merge branches 'feat/check-validator-address-belongs-to-comittee' and…
cpl121 Mar 8, 2024
90ddd91
Merge branches 'feat/improve-delegation-list-header' and 'develop-iot…
cpl121 Mar 11, 2024
3c4805c
feat: improve delegation list
cpl121 Mar 11, 2024
59cce37
Merge branches 'feat/check-validator-address-belongs-to-comittee' and…
cpl121 Mar 11, 2024
0da2383
fix: error to show PingingBadge
cpl121 Mar 11, 2024
c65507b
Merge branches 'feat/check-validator-address-belongs-to-comittee' and…
cpl121 Mar 12, 2024
8ce6059
Merge branch 'develop-iota2.0' into feat/check-validator-address-belo…
cpl121 Mar 12, 2024
2f54ef4
Merge branches 'feat/check-validator-address-belongs-to-comittee' and…
cpl121 Mar 12, 2024
a3e467e
Merge branch 'develop-iota2.0' into feat/check-validator-address-belo…
cpl121 Mar 14, 2024
8a9a28f
Merge branch 'develop-iota2.0' into feat/check-validator-address-belo…
cpl121 Mar 19, 2024
9fedef6
Merge branches 'feat/check-validator-address-belongs-to-comittee' and…
cpl121 Mar 19, 2024
4ddca93
Merge branch 'develop-iota2.0' into feat/check-validator-address-belo…
cpl121 Mar 20, 2024
a0778ed
Merge branch 'develop-iota2.0' into feat/check-validator-address-belo…
begonaalvarezd Mar 21, 2024
c7a2020
chore: rename var
begonaalvarezd Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions packages/desktop/views/dashboard/delegation/Delegation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ButtonSize,
CopyableBox,
BoxedIconWithText,
PingingBadge,
TextHintVariant,
} from '@ui'
import { activeProfile, checkActiveProfileAuth } from '@core/profile'
Expand All @@ -35,6 +36,7 @@

let delegationData: IDelegationTable[] = []
let currentEpoch = 0
let committeeAddress: string[] = []

enum Header {
DelegationId = 'delegationId',
Expand All @@ -56,7 +58,7 @@

$: delegationOutputs =
$selectedWallet?.walletUnspentOutputs?.filter((output) => output?.output?.type === OutputType.Delegation) || []
$: delegationOutputs?.length > 0 && setCurrentEpoch()
$: delegationOutputs?.length > 0 && setCurrentEpochAndCommittee()
$: delegationOutputs?.length > 0 && currentEpoch && buildMappedDelegationData(delegationOutputs)
$: ({ baseCoin } = $selectedWalletAssets[$activeProfile?.network.id])

Expand Down Expand Up @@ -92,9 +94,10 @@
delegationData = await Promise.all(result)
}

async function setCurrentEpoch(): Promise<void> {
const committee = await getCommitteeInfo()
currentEpoch = committee.epoch
async function setCurrentEpochAndCommittee(): Promise<void> {
const committeeResponse = await getCommitteeInfo()
currentEpoch = committeeResponse?.epoch
committeeAddress = committeeResponse?.committee?.map((committee) => committee.address) || []
}

function handleDelegate(): void {
Expand Down Expand Up @@ -126,7 +129,7 @@
})
}

function renderCellValue(value: any, header: string): { component: any; props: any; text?: string } {
function renderCellValue(value: any, header: string): { component: any; props: any; text?: string; slot?: any } {
switch (header as Header) {
case Header.DelegationId:
return {
Expand Down Expand Up @@ -180,7 +183,19 @@
isCopyable: true,
clearBoxPadding: true,
clearBackground: true,
classes: 'text-gray-600 dark:text-white text-xs font-medium',
classes: 'flex flex-row items-center text-gray-600 dark:text-white text-xs font-medium gap-2',
},
slot: {
component: PingingBadge,
evavirseda marked this conversation as resolved.
Show resolved Hide resolved
props: {
classes: 'relative',
innerColor: committeeAddress?.some((address) => address === value)
? 'green-600'
: 'red-500',
outerColor: committeeAddress?.some((address) => address === value)
? 'green-400'
: 'red-300',
},
},
text: truncateString(value, 5, 5, 3),
}
Expand Down Expand Up @@ -262,6 +277,12 @@
<td class="text-start flex-1">
{#if renderCell.text}
<svelte:component this={renderCell.component} {...renderCell.props}>
{#if renderCell.slot}
<svelte:component
this={renderCell.slot.component}
{...renderCell.slot.props}
/>
{/if}
{renderCell.text}
</svelte:component>
{:else}
Expand Down
Loading