mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-23 10:27:55 +00:00
971df8edba
- Remove all 3rd party parachain configurations from endpoints: - productionRelayPolkadot.ts: Keep only system parachains - productionRelayDicle.ts: Keep only system parachains - testingRelayZagros.ts: Keep only system parachains - testingRelayTeyrChain.ts: Keep only system parachains - Update domain references: - polkadot.js.org → pezkuwichain.app - wiki.polkadot.network → wiki.pezkuwichain.io - dotapps.io → pezkuwichain.app - statement.polkadot.network → docs.pezkuwichain.io/statement - support.polkadot.network → docs.pezkuwichain.io - Update repository references: - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap - Rename system parachains to Pezkuwi ecosystem: - PolkadotAssetHub → PezkuwiAssetHub - polkadotBridgeHub → pezkuwiBridgeHub - polkadotCollectives → pezkuwiCollectives - polkadotCoretime → pezkuwiCoretime - polkadotPeople → pezkuwiPeople - Update network name in claims utility: - Polkadot → Pezkuwi
86 lines
3.5 KiB
TypeScript
86 lines
3.5 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/test-support authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiPromise } from '@pezkuwi/api';
|
|
import type { KeyringPair } from '@pezkuwi/keyring/types';
|
|
|
|
import { execute } from '@pezkuwi/test-support/transaction';
|
|
import { BN } from '@pezkuwi/util';
|
|
|
|
import { waitForBountyState, waitForClaim } from './bountyWaitFunctions.js';
|
|
import { FUNDING_TIME, PAYOUT_TIME } from './constants.js';
|
|
import { extractHashesFromProposals, extractIndexesFromProposals, fillTreasury, multiAcceptMotion, multiGetMotion, multiProposeMotion } from './helpers.js';
|
|
|
|
export async function multiProposeBounty (api: ApiPromise, numberOfBounties: number, signer: KeyringPair): Promise<number[]> {
|
|
const initialIndex = await api.query.bounties.bountyCount();
|
|
|
|
const arr = Array.from({ length: numberOfBounties }, (_, i) => api.tx.bounties.proposeBounty(new BN(500_000_000_000_000), `new bounty no ${i}`));
|
|
|
|
await execute(
|
|
api.tx.utility.batch(arr),
|
|
signer
|
|
);
|
|
const endIndex = await api.query.bounties.bountyCount();
|
|
|
|
if ((endIndex.sub(initialIndex)).toNumber() !== numberOfBounties) {
|
|
throw new Error('Multi Propose Failed');
|
|
}
|
|
|
|
return Array.from({ length: numberOfBounties }, (_, i) => i + initialIndex.toNumber());
|
|
}
|
|
|
|
export async function multiApproveBounty (api: ApiPromise, bountyIndexes: number[], signer: KeyringPair): Promise<void> {
|
|
const extrinsicArray = bountyIndexes.map((index) => api.tx.bounties.approveBounty(index));
|
|
|
|
await multiProposeMotion(api, extrinsicArray, signer);
|
|
|
|
const bountyProposals = await multiGetMotion(api, bountyIndexes);
|
|
|
|
await fillTreasury(api, signer);
|
|
await multiAcceptMotion(api, extractHashesFromProposals(bountyProposals), extractIndexesFromProposals(bountyProposals));
|
|
}
|
|
|
|
export async function multiWaitForBountyFunded (api: ApiPromise, bountyIndexes: number[]): Promise<void> {
|
|
const waitFunctions = bountyIndexes.map((bountyIndex) =>
|
|
waitForBountyState(api, 'isFunded', bountyIndex, { interval: 2000, timeout: FUNDING_TIME }));
|
|
|
|
await Promise.all(waitFunctions);
|
|
}
|
|
|
|
export async function multiProposeCurator (api: ApiPromise, bountyIndexes: number[], signer: KeyringPair): Promise<void> {
|
|
const extrinsicArray = bountyIndexes.map((index) => api.tx.bounties.proposeCurator(index, signer.address, 10));
|
|
|
|
await multiProposeMotion(api, extrinsicArray, signer);
|
|
|
|
const bountyProposals = await multiGetMotion(api, bountyIndexes);
|
|
|
|
await multiAcceptMotion(api, extractHashesFromProposals(bountyProposals), extractIndexesFromProposals(bountyProposals));
|
|
}
|
|
|
|
export async function multiAcceptCurator (api: ApiPromise, bountyIndexes: number[], signer: KeyringPair): Promise<void> {
|
|
await execute(
|
|
api.tx.utility.batch(bountyIndexes.map((bountyIndex) => api.tx.bounties.acceptCurator(bountyIndex))),
|
|
signer
|
|
);
|
|
}
|
|
|
|
export async function multiAwardBounty (api: ApiPromise, bountyIndexes: number[], signer: KeyringPair): Promise<void> {
|
|
await execute(
|
|
api.tx.utility.batch(bountyIndexes.map((bountyIndex) => api.tx.bounties.awardBounty(bountyIndex, signer.address))),
|
|
signer
|
|
);
|
|
}
|
|
|
|
export async function multiWaitForClaim (api: ApiPromise, bountyIndexes: number[]): Promise<void> {
|
|
for (const index of bountyIndexes) {
|
|
await waitForClaim(api, index, { interval: 2000, timeout: PAYOUT_TIME });
|
|
}
|
|
}
|
|
|
|
export async function multiClaimBounty (api: ApiPromise, bountyIndexes: number[], signer: KeyringPair): Promise<void> {
|
|
await execute(
|
|
api.tx.utility.batch(bountyIndexes.map((bountyIndex) => api.tx.bounties.claimBounty(bountyIndex))),
|
|
signer
|
|
);
|
|
}
|