Skip to content

Commit

Permalink
fix: add subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
shuffledex committed Jul 21, 2020
1 parent 5c19b5c commit 720a6b9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Governance.ts
Expand Up @@ -4,6 +4,7 @@ import { Identity, Proposal } from '~/api/entities';
import { createProposal, CreateProposalParams } from '~/api/procedures';
import { TransactionQueue } from '~/base';
import { Context } from '~/context';
import { SubCallback, UnsubCallback } from '~/types';
import { balanceToBigNumber, identityIdToString } from '~/utils';

/**
Expand Down Expand Up @@ -51,8 +52,16 @@ export class Governance {

/**
* Get the minimum amount of POLYX to be used as a deposit for create a public referendum proposal
*
* @note can be subscribed to
*/
public async minimumProposalDeposit(): Promise<BigNumber> {
public async minimumProposalDeposit(): Promise<BigNumber>;
public async minimumProposalDeposit(callback: SubCallback<BigNumber>): Promise<UnsubCallback>;

// eslint-disable-next-line require-jsdoc
public async minimumProposalDeposit(
callback?: SubCallback<BigNumber>
): Promise<BigNumber | UnsubCallback> {
const {
context: {
polymeshApi: {
Expand All @@ -61,6 +70,12 @@ export class Governance {
},
} = this;

if (callback) {
return pips.minimumProposalDeposit(res => {
callback(balanceToBigNumber(res));
});
}

const minimumProposalDeposit = await pips.minimumProposalDeposit();

return balanceToBigNumber(minimumProposalDeposit);
Expand Down

0 comments on commit 720a6b9

Please sign in to comment.