ghost-portal/packages/test-support/src/creation/treasury/proposalFactory.ts
Jaco e976ab4838
Remove jsx-runtime alias for React 18 (#7431)
* Remove jsx-runtime alias for React 18

* Adjust lint
2022-04-23 09:57:44 +03:00

31 lines
976 B
TypeScript

// Copyright 2017-2022 @polkadot/test-support authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import { ApiPromise } from '@polkadot/api';
import { SubmittableExtrinsic } from '@polkadot/api/types';
import { aHash } from '@polkadot/test-support/creation/hashes';
import { alice, bob } from '@polkadot/test-support/keyring/addresses';
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
})
})
};
}