diff --git a/packages/jellyfish-api-core/__tests__/category/account/listCommunityBalances.test.ts b/packages/jellyfish-api-core/__tests__/category/account/listCommunityBalances.test.ts new file mode 100644 index 0000000000..11c1df3b1c --- /dev/null +++ b/packages/jellyfish-api-core/__tests__/category/account/listCommunityBalances.test.ts @@ -0,0 +1,31 @@ +import { MasterNodeRegTestContainer } from '@defichain/testcontainers' +import { ContainerAdapterClient } from '../../container_adapter_client' +import BigNumber from 'bignumber.js' + +describe('Account', () => { + const container = new MasterNodeRegTestContainer() + const client = new ContainerAdapterClient(container) + + beforeAll(async () => { + await container.start() + await container.waitForReady() + await container.waitForWalletCoinbaseMaturity() + }) + + afterAll(async () => { + await container.stop() + }) + + it('should listCommunityBalances', async () => { + const data = await client.account.listCommunityBalances() + + expect(data.AnchorReward instanceof BigNumber).toStrictEqual(true) + expect(data.IncentiveFunding instanceof BigNumber).toStrictEqual(true) + expect(data.Burnt instanceof BigNumber).toStrictEqual(true) + expect(data.Swap).toBeUndefined() + expect(data.Futures).toBeUndefined() + expect(data.Options).toBeUndefined() + expect(data.Unallocated).toBeUndefined() + expect(data.Unknown).toBeUndefined() + }) +}) diff --git a/packages/jellyfish-api-core/src/category/account.ts b/packages/jellyfish-api-core/src/category/account.ts index 0a28c8f22b..2f11cb5884 100644 --- a/packages/jellyfish-api-core/src/category/account.ts +++ b/packages/jellyfish-api-core/src/category/account.ts @@ -12,7 +12,7 @@ export enum OwnerType { } export enum DfTxType { - MINT_TOKEN ='M', + MINT_TOKEN = 'M', POOL_SWAP = 's', ADD_POOL_LIQUIDITY = 'l', REMOVE_POOL_LIQUIDITY = 'r', @@ -334,6 +334,15 @@ export class Account { ): Promise { return await this.client.call('sendtokenstoaddress', [from, to, options.selectionMode], 'number') } + + /** + * Returns information about current anchor bonus, incentive funding, burnt token(s) + * + * @return {Promise} + */ + async listCommunityBalances (): Promise { + return await this.client.call('listcommunitybalances', [], 'bignumber') + } } export interface AccountPagination { @@ -418,3 +427,14 @@ export interface AddressBalances { export interface SendTokensOptions { selectionMode: SelectionModeType } + +export interface CommunityBalanceData { + AnchorReward: BigNumber + IncentiveFunding?: BigNumber + Burnt: BigNumber + Swap?: BigNumber + Futures?: BigNumber + Options?: BigNumber + Unallocated?: BigNumber + Unknown?: BigNumber +} diff --git a/website/docs/jellyfish/api/account.md b/website/docs/jellyfish/api/account.md index ba40809b9f..7305e92338 100644 --- a/website/docs/jellyfish/api/account.md +++ b/website/docs/jellyfish/api/account.md @@ -313,3 +313,24 @@ interface SendTokensOptions { selectionMode: SelectionModeType } ``` + +## listCommunityBalances + +Returns information about current anchor bonus, incentive funding, burnt token(s) + +```ts title="client.account.listCommunityBalances()" +interface account { + listCommunityBalances (): Promise +} + +interface CommunityBalanceData { + AnchorReward: BigNumber + IncentiveFunding?: BigNumber + Burnt: BigNumber + Swap?: BigNumber + Futures?: BigNumber + Options?: BigNumber + Unallocated?: BigNumber + Unknown?: BigNumber +} +```