From 831619a4ea368ed95816e99d9c4114dec3d6d5e4 Mon Sep 17 00:00:00 2001 From: tarikgul Date: Thu, 9 Jan 2025 13:03:49 -0500 Subject: [PATCH] Temporary typecasting to Bounty type --- packages/page-bounties/src/Bounties.spec.ts | 29 ++++++++++++------- packages/page-bounties/src/Bounties.tsx | 7 ++++- .../test-support/src/creation/bounties.ts | 8 +++-- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/packages/page-bounties/src/Bounties.spec.ts b/packages/page-bounties/src/Bounties.spec.ts index afc04cb516f..9e2758a0231 100644 --- a/packages/page-bounties/src/Bounties.spec.ts +++ b/packages/page-bounties/src/Bounties.spec.ts @@ -9,7 +9,7 @@ import type { ApiPromise } from '@polkadot/api'; import type { SubmittableExtrinsic } from '@polkadot/api/types'; import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types'; import type { BountyIndex, BountyStatus } from '@polkadot/types/interfaces'; -import type { PalletBountiesBounty } from '@polkadot/types/lookup'; +import type { PalletBountiesBounty, PalletBountiesBountyStatus } from '@polkadot/types/lookup'; import { fireEvent } from '@testing-library/react'; @@ -347,7 +347,8 @@ describe('Bounties', () => { describe('Reject curator modal', () => { it('creates extrinsic', async () => { - const bounty = aBounty({ status: bountyStatusWith({ curator: bob, status: 'CuratorProposed' }) }); + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + const bounty = aBounty({ status: bountyStatusWith({ curator: bob, status: 'CuratorProposed' }) as unknown as PalletBountiesBountyStatus }); bountiesPage.renderOne(bounty); @@ -358,7 +359,8 @@ describe('Bounties', () => { }); it('shows options for all roles', async () => { - const bounty = aBounty({ status: bountyStatusWith({ curator: bob, status: 'Active' }) }); + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + const bounty = aBounty({ status: bountyStatusWith({ curator: bob, status: 'Active' }) as unknown as PalletBountiesBountyStatus }); bountiesPage.renderOne(bounty); @@ -372,7 +374,8 @@ describe('Bounties', () => { it('creates extrinsic', async () => { const bounty = aBounty({ fee: balanceOf(20), - status: bountyStatusWith({ curator: bob, status: 'CuratorProposed' }) + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + status: bountyStatusWith({ curator: bob, status: 'CuratorProposed' }) as unknown as PalletBountiesBountyStatus }); bountiesPage.renderOne(bounty); @@ -390,7 +393,8 @@ describe('Bounties', () => { describe('extend bounty expiry action modal', () => { it('queues extend bounty expiry extrinsic on submit', async () => { - const bounty = aBounty({ status: bountyStatusWith({ curator: alice }) }); + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + const bounty = aBounty({ status: bountyStatusWith({ curator: alice }) as unknown as PalletBountiesBountyStatus }); bountiesPage.renderOne(bounty); await bountiesPage.openExtendExpiry(); @@ -405,7 +409,8 @@ describe('Bounties', () => { describe('give up curator modal', () => { it('gives up on the Curator role of an Active bounty', async () => { - const bounty = aBounty({ status: bountyStatusWith({ curator: alice }) }); + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + const bounty = aBounty({ status: bountyStatusWith({ curator: alice }) as unknown as PalletBountiesBountyStatus }); bountiesPage.renderOne(bounty); await bountiesPage.openGiveUpCuratorsRole(); @@ -434,7 +439,8 @@ describe('Bounties', () => { describe('award beneficiary action modal', () => { it('awards the beneficiary', async () => { - const bounty = aBounty({ status: bountyStatusWith({ curator: alice }) }); + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + const bounty = aBounty({ status: bountyStatusWith({ curator: alice }) as unknown as PalletBountiesBountyStatus }); bountiesPage.renderOne(bounty); @@ -454,7 +460,8 @@ describe('Bounties', () => { curator: alice, status: 'Active', updateDue: defaultBountyUpdatePeriod.muln(BLOCKS_PERCENTAGE_LEFT_TO_SHOW_WARNING).divn(100).toNumber() - 1 - }) }); + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + }) as unknown as PalletBountiesBountyStatus }); bountiesPage.renderOne(bounty); @@ -467,7 +474,8 @@ describe('Bounties', () => { curator: alice, status: 'Active', updateDue: mockBountyHooks.bountyApi.bestNumber?.toNumber() - }) }); + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + }) as unknown as PalletBountiesBountyStatus }); bountiesPage.renderOne(bounty); @@ -503,7 +511,8 @@ describe('Bounties', () => { curator: alice, status: 'Active', updateDue: defaultBountyUpdatePeriod.muln(BLOCKS_PERCENTAGE_LEFT_TO_SHOW_WARNING).divn(100).toNumber() + 1 - }) }); + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + }) as unknown as PalletBountiesBountyStatus }); bountiesPage.renderOne(bounty); await bountiesPage.rendered(); diff --git a/packages/page-bounties/src/Bounties.tsx b/packages/page-bounties/src/Bounties.tsx index 0aeffa2d9ba..f47b3714f03 100644 --- a/packages/page-bounties/src/Bounties.tsx +++ b/packages/page-bounties/src/Bounties.tsx @@ -1,6 +1,8 @@ // Copyright 2017-2025 @polkadot/app-bounties authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { Bounty as BountyType } from '@polkadot/types/interfaces'; + import React, { useMemo, useRef } from 'react'; import { Button, styled, Table } from '@polkadot/react-components'; @@ -46,7 +48,10 @@ function Bounties ({ className }: Props): React.ReactElement { {sorted && bestNumber && sorted.map(({ bounty, description, index, proposals }) => ( - this.aBounty({ status: this.aBountyStatus(status), value: balanceOf(value) }); + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + this.aBounty({ status: this.aBountyStatus(status) as unknown as PalletBountiesBountyStatus, value: balanceOf(value) }); - public aBounty = ({ fee = balanceOf(10), status = this.aBountyStatus('Proposed'), value = balanceOf(500) }: Partial = {}): PalletBountiesBounty => + // FIXME: https://github.com/polkadot-js/apps/issues/11192 + public aBounty = ({ fee = balanceOf(10), status = this.aBountyStatus('Proposed') as unknown as PalletBountiesBountyStatus, value = balanceOf(500) }: Partial = {}): PalletBountiesBounty => this.#registry.createType('Bounty', { fee, status, value }); }