Skip to content

Commit

Permalink
Added listCommunityBalances RPC (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
izzycsy authored Jun 23, 2021
1 parent 118aa73 commit cd2603e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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()
})
})
22 changes: 21 additions & 1 deletion packages/jellyfish-api-core/src/category/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -334,6 +334,15 @@ export class Account {
): Promise<string> {
return await this.client.call('sendtokenstoaddress', [from, to, options.selectionMode], 'number')
}

/**
* Returns information about current anchor bonus, incentive funding, burnt token(s)
*
* @return {Promise<CommunityBalanceData>}
*/
async listCommunityBalances (): Promise<CommunityBalanceData> {
return await this.client.call('listcommunitybalances', [], 'bignumber')
}
}

export interface AccountPagination {
Expand Down Expand Up @@ -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
}
21 changes: 21 additions & 0 deletions website/docs/jellyfish/api/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<CommunityBalanceData>
}

interface CommunityBalanceData {
AnchorReward: BigNumber
IncentiveFunding?: BigNumber
Burnt: BigNumber
Swap?: BigNumber
Futures?: BigNumber
Options?: BigNumber
Unallocated?: BigNumber
Unknown?: BigNumber
}
```

0 comments on commit cd2603e

Please sign in to comment.