Files
pezkuwi-apps/packages/test-support/src/creation/treasury.ts
T

40 lines
1.1 KiB
TypeScript

// Copyright 2017-2026 @pezkuwi/test-support authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiPromise } from '@pezkuwi/api';
import type { SubmittableExtrinsic } from '@pezkuwi/api/types';
import type { DeriveCollectiveProposal } from '@pezkuwi/api-derive/types';
import { BN_ONE, BN_ZERO } from '@pezkuwi/util';
import { alice, bob } from '../keyring/addresses.js';
import { balanceOf } from './balance.js';
import { aHash } from './hashes.js';
export interface ProposalFactory {
aProposal: (extrinsic: SubmittableExtrinsic<'promise'>, ayes?: string[], nays?: string[]) => DeriveCollectiveProposal
}
export function proposalFactory (api: ApiPromise): ProposalFactory {
const registry = api.registry;
return {
aProposal: (extrinsic, ayes = [alice], nays = [bob]) => ({
hash: aHash(),
proposal: registry.createType('Proposal', extrinsic),
votes: registry.createType('Votes', {
ayes,
index: 0,
nays,
threshold: 4
})
})
};
}
export const defaultTreasury = {
burn: BN_ONE,
spendPeriod: BN_ZERO,
value: balanceOf(1)
};