Skip to content

Commit

Permalink
Temporary typecasting to Bounty type
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Jan 9, 2025
1 parent c44b757 commit 831619a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
29 changes: 19 additions & 10 deletions packages/page-bounties/src/Bounties.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion packages/page-bounties/src/Bounties.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -46,7 +48,10 @@ function Bounties ({ className }: Props): React.ReactElement {
{sorted && bestNumber && sorted.map(({ bounty, description, index, proposals }) => (
<Bounty
bestNumber={bestNumber}
bounty={bounty}
// TODO: The bounty type here is now expected as PalletBountiesBounty type in the latest substrate release.
// This will require forward and backwards compatibility with the older Bounty type and the newer lookup type.
// ref: https://github.com/polkadot-js/apps/issues/11192
bounty={bounty as unknown as BountyType}
description={description}
index={index}
key={index.toNumber()}
Expand Down
8 changes: 5 additions & 3 deletions packages/test-support/src/creation/bounties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import type { ApiPromise } from '@polkadot/api';
import type { BountyIndex, BountyStatus } from '@polkadot/types/interfaces';
import type { PalletBountiesBounty } from '@polkadot/types/lookup';
import type { PalletBountiesBounty, PalletBountiesBountyStatus } from '@polkadot/types/lookup';
import type { Registry } from '@polkadot/types/types';

import { balanceOf } from './balance.js';
Expand Down Expand Up @@ -39,8 +39,10 @@ export class BountyFactory {
};

public bountyWith = ({ status = 'Proposed', value = 1 } = {}): PalletBountiesBounty =>
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> = {}): 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> = {}): PalletBountiesBounty =>
this.#registry.createType<PalletBountiesBounty>('Bounty', { fee, status, value });
}

0 comments on commit 831619a

Please sign in to comment.