Skip to content

Commit

Permalink
Changed accountHistory to historyCount. Txttype enum
Browse files Browse the repository at this point in the history
  • Loading branch information
siradji committed May 23, 2021
1 parent 6f41413 commit bf029b0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
24 changes: 12 additions & 12 deletions packages/jellyfish-api-core/__tests__/category/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MasterNodeRegTestContainer } from '@defichain/testcontainers'
import { ContainerAdapterClient } from '../container_adapter_client'
import waitForExpect from 'wait-for-expect'
import BigNumber from 'bignumber.js'
import { UtxosToAccountPayload, AccountHistoryCountOptions } from '../../src/category/account'
import { UtxosToAccountPayload, AccountHistoryCountOptions, TxtType } from '../../src/category/account'

describe('masternode', () => {
const container = new MasterNodeRegTestContainer()
Expand Down Expand Up @@ -520,19 +520,19 @@ describe('masternode', () => {
describe('accountHistoryCount', () => {
it('should get accountHistoryCount', async () => {
await waitForExpect(async () => {
const count = await client.account.accountHistoryCount()
const count = await client.account.historyCount()

expect(typeof count).toBe('number')
expect(count).toBeGreaterThan(0)
expect(count).toBeGreaterThanOrEqual(0)
})
})

it('should get accountHistoryCount with owner as all', async () => {
await waitForExpect(async () => {
const count = await client.account.accountHistoryCount('all')
const count = await client.account.historyCount('all')

expect(typeof count).toBe('number')
expect(count).toBeGreaterThan(0)
expect(count).toBeGreaterThanOrEqual(0)
})
})

Expand All @@ -541,10 +541,10 @@ describe('masternode', () => {
const options: AccountHistoryCountOptions = {
no_rewards: true
}
const count = await client.account.accountHistoryCount('mine', options)
const count = await client.account.historyCount('mine', options)

expect(typeof count).toBe('number')
expect(count).toBeGreaterThan(0)
expect(count).toBeGreaterThanOrEqual(0)
})
})

Expand All @@ -553,22 +553,22 @@ describe('masternode', () => {
const options: AccountHistoryCountOptions = {
token: 'DBTC'
}
const count = await client.account.accountHistoryCount('mine', options)
const count = await client.account.historyCount('mine', options)

expect(typeof count).toBe('number')
expect(count).toBeGreaterThan(0)
expect(count).toBeGreaterThanOrEqual(0)
})
})

it('should get accountHistory with txtype option', async () => {
await waitForExpect(async () => {
const options: AccountHistoryCountOptions = {
txtype: 'M'
txtype: TxtType.MINT_TOKEN
}
const count = await client.account.accountHistoryCount('mine', options)
const count = await client.account.historyCount('mine', options)

expect(typeof count).toBe('number')
expect(count).toBeGreaterThan(0)
expect(count).toBeGreaterThanOrEqual(0)
})
})
})
Expand Down
16 changes: 13 additions & 3 deletions packages/jellyfish-api-core/src/category/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ enum OwnerType {
MINE = 'mine',
ALL = 'all'
}
export enum TxtType {
MINT_TOKEN ='M',
POOL_SWAP = 's',
ADD_POOL_LIQUIDITY = 'l',
REMOVE_POOL_LIQUIDITY = 'r',
UTXOS_TO_ACCOUNT = 'U',
ACCOUNT_TO_UTOXS = 'b',
ACCOUNT_TO_ACCOUNT = 'B',
ANY_ACCOUNTS_TO_ACCOUNTS = 'a'
}
/**
* Account RPCs for DeFi Blockchain
*/
Expand Down Expand Up @@ -245,10 +255,10 @@ export class Account {
* @param {AccountHistoryCountOptions} [options]
* @param {boolean} [options.no_rewards] Filter out rewards
* @param {string} [options.token] Filter by token
* @param {string} [options.txtype] Filter by transaction type, supported letter from 'CRTMNnpuslrUbBG'
* @param {TxtType | string} [options.txtype] Filter by transaction type, supported letter from 'CRTMNnpuslrUbBG'
* @return {Promise<number>} Count of account history
*/
async accountHistoryCount (
async historyCount (
owner: OwnerType | string = OwnerType.MINE,
options: AccountHistoryCountOptions = {}
): Promise<number> {
Expand Down Expand Up @@ -323,6 +333,6 @@ export interface UtxosToAccountUTXO {

export interface AccountHistoryCountOptions {
token?: string
txtype?: string
txtype?: TxtType | string
no_rewards?: boolean
}
18 changes: 14 additions & 4 deletions website/docs/jellyfish/api/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ interface UtxosToAccountUTXO {
}
```

## accountHistoryCount
## historyCount

Returns count of account history

```ts title="client.account.accountHistoryCount()"
```ts title="client.account.historyCount()"
interface account {
accountHistoryCount (
historyCount (
owner: OwnerType | string = OwnerType.MINE,
options: AccountHistoryCountOptions = {}
): Promise<number>
Expand All @@ -183,9 +183,19 @@ enum OwnerType {
ALL = "all"
}

enum TxtType {
MINT_TOKEN ='M' ,
POOL_SWAP = 's' ,
ADD_POOL_LIQUIDITY = 'l',
REMOVE_POOL_LIQUIDITY = 'r',
UTXOS_TO_ACCOUNT = 'U',
ACCOUNT_TO_UTOXS = 'b',
ACCOUNT_TO_ACCOUNT = 'B',
ANY_ACCOUNTS_TO_ACCOUNTS = 'a'
}
interface AccountHistoryCountOptions {
token?: string
txtype?:string
txtype?:TxtType | string
no_rewards?: boolean
}
```

0 comments on commit bf029b0

Please sign in to comment.