mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-28 13:07:56 +00:00
60a800b33e
- Clone Polkadot.js Apps repository - Update package.json with Pezkuwi branding - Add Pezkuwi endpoint to production chains (wss://pezkuwichain.app:9944) - Create comprehensive README for SDK UI - Set up project structure with all packages Next steps: - Apply Kurdistan colors (Kesk, Sor, Zer, Spi + Black) to UI theme - Replace logos with Pezkuwi branding - Test build and deployment
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
// Copyright 2017-2025 @polkadot/test-support authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiPromise } from '@polkadot/api';
|
|
import type { DeriveBounty } from '@polkadot/api-derive/types';
|
|
import type { WaitOptions } from '@polkadot/test-support/types';
|
|
|
|
import { waitFor } from '@polkadot/test-support/utils';
|
|
|
|
type bStatus = 'isFunded' | 'isActive';
|
|
|
|
async function getBounty (api: ApiPromise, bountyIndex: number): Promise<DeriveBounty> {
|
|
const bounties = await api.derive.bounties.bounties();
|
|
const bounty = bounties.find((bounty) => bounty.index.toNumber() === bountyIndex);
|
|
|
|
if (!bounty) {
|
|
throw new Error('Unable to find bounty');
|
|
}
|
|
|
|
return bounty;
|
|
}
|
|
|
|
export async function waitForBountyState (api: ApiPromise, expectedState: bStatus, index: number, { interval = 500,
|
|
timeout = 10000 } = {}): Promise<boolean> {
|
|
return waitFor(async () => {
|
|
const bounty = await getBounty(api, index);
|
|
|
|
return bounty.bounty.status[expectedState];
|
|
}, { interval, timeout });
|
|
}
|
|
|
|
export async function waitForClaim (api: ApiPromise, index: number, { interval = 500, timeout = 10000 }: WaitOptions): Promise<boolean> {
|
|
return waitFor(async () => {
|
|
const bounty = await getBounty(api, index);
|
|
const unlockAt = bounty.bounty.status.asPendingPayout.unlockAt;
|
|
|
|
const bestNumber = await api.derive.chain.bestNumber();
|
|
|
|
return unlockAt.lt(bestNumber);
|
|
}, { interval, timeout });
|
|
}
|