26 lines
821 B
TypeScript
26 lines
821 B
TypeScript
// Copyright 2017-2023 @polkadot/api authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiPromise } from '@polkadot/api';
|
|
import type { SubmittableExtrinsic } from '@polkadot/api-base/types';
|
|
import type { Proposal, ProposalIndex } from '@polkadot/types/interfaces';
|
|
import type { Registry } from '@polkadot/types/types';
|
|
|
|
export class ProposalFactory {
|
|
readonly #api: ApiPromise;
|
|
readonly #registry: Registry;
|
|
|
|
constructor (api: ApiPromise) {
|
|
this.#api = api;
|
|
this.#registry = this.#api.registry;
|
|
}
|
|
|
|
public createProposal = (method: SubmittableExtrinsic<'promise'>): Proposal => {
|
|
return this.#registry.createType('Proposal', method);
|
|
};
|
|
|
|
public proposalIndex = (index: number): ProposalIndex => {
|
|
return this.#registry.createType('ProposalIndex', index);
|
|
};
|
|
}
|