Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Filter by DfTxType in AccountRPCs #332

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MasterNodeRegTestContainer } from '@defichain/testcontainers'
import { ContainerAdapterClient } from '../../container_adapter_client'
import waitForExpect from 'wait-for-expect'
import { TxType } from '../../../src/category/account'

describe('Account', () => {
const container = new MasterNodeRegTestContainer()
Expand Down Expand Up @@ -175,11 +176,11 @@ describe('Account', () => {

it('should listAccountHistory with options txtype', async () => {
await waitForExpect(async () => {
const accountHistories = await client.account.listAccountHistory('mine', { txtype: 'M' })
const accountHistories = await client.account.listAccountHistory('mine', { txtype: TxType.MINT_TOKEN })
expect(accountHistories.length).toBeGreaterThan(0)
})

const accountHistories = await client.account.listAccountHistory('mine', { txtype: 'M' })
const accountHistories = await client.account.listAccountHistory('mine', { txtype: TxType.MINT_TOKEN })
for (let i = 0; i < accountHistories.length; i += 1) {
const accountHistory = accountHistories[i]
expect(accountHistory.type).toStrictEqual('MintToken')
Expand Down
8 changes: 4 additions & 4 deletions packages/jellyfish-api-core/src/category/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class Account {
* @param {number} [options.depth] Maximum depth, from the genesis block is the default
* @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 {TxType} [options.txtype] Filter by transaction type. See TxType.
* @param {number} [options.limit=100] Maximum number of records to return, 100 by default
* @return {Promise<AccountHistory[]>}
*/
Expand Down Expand Up @@ -285,7 +285,7 @@ export class Account {
* @param {AccountHistoryCountOptions} [options]
* @param {boolean} [options.no_rewards] Filter out rewards
* @param {string} [options.token] Filter by token
* @param {TxType | string} [options.txtype] Filter by transaction type, supported letter from 'CRTMNnpuslrUbBG'
* @param {TxType} [options.txtype] Filter by transaction type. See TxType.
* @return {Promise<number>} count of account history
*/
async historyCount (
Expand Down Expand Up @@ -348,7 +348,7 @@ export interface AccountHistoryOptions {
depth?: number
no_rewards?: boolean
token?: string
txtype?: string
txtype?: TxType
limit?: number
}

Expand All @@ -367,6 +367,6 @@ export interface UTXO {

export interface AccountHistoryCountOptions {
token?: string
txtype?: TxType | string
txtype?: TxType
no_rewards?: boolean
}
24 changes: 22 additions & 2 deletions website/docs/jellyfish/api/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ enum OwnerType {
ALL = "all"
}

enum TxType {
siradji marked this conversation as resolved.
Show resolved Hide resolved
MINT_TOKEN = 'M',
POOL_SWAP = 's',
ADD_POOL_LIQUIDITY = 'l',
REMOVE_POOL_LIQUIDITY = 'r',
UTXOS_TO_ACCOUNT = 'U',
ACCOUNT_TO_UTXOS = 'b',
ACCOUNT_TO_ACCOUNT = 'B',
ANY_ACCOUNTS_TO_ACCOUNTS = 'a',
CREATE_MASTERNODE = 'C',
RESIGN_MASTERNODE = 'R',
CREATE_TOKEN = 'T',
UPDATE_TOKEN = 'N',
UPDATE_TOKEN_ANY = 'n',
CREATE_POOL_PAIR = 'p',
UPDATE_POOL_PAIR = 'u',
SET_GOV_VARIABLE = 'G',
AUTO_AUTH_PREP = 'A'
}

interface AccountHistory {
owner: string
blockHeight: number
Expand All @@ -141,7 +161,7 @@ interface AccountHistoryOptions {
depth?: number
no_rewards?: boolean
token?: string
txtype?: string
txtype?: TxType
limit?: number
}
```
Expand Down Expand Up @@ -233,7 +253,7 @@ enum TxType {

interface AccountHistoryCountOptions {
token?: string
txtype?: TxType | string
txtype?: TxType
no_rewards?: boolean
}
```