Skip to content

Commit

Permalink
add changes for mining
Browse files Browse the repository at this point in the history
  • Loading branch information
thedoublejay committed May 19, 2021
1 parent 88ab495 commit d385530
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { RegTestContainer, MasterNodeRegTestContainer } from '@defichain/testcon
import { ContainerAdapterClient } from '../container_adapter_client'
import waitForExpect from 'wait-for-expect'
import { wallet } from '../../src'
import { EstimateMode } from '../../src/category/mining'

describe('non masternode', () => {
const container = new RegTestContainer()
Expand Down Expand Up @@ -145,7 +146,7 @@ describe('estimatesmartfees', () => {
}
})

const result = await client.mining.estimateSmartFee(6, 'ECONOMICAL')
const result = await client.mining.estimateSmartFee(6, EstimateMode.ECONOMICAL)
expect(result.errors).toBeUndefined()
expect(result.blocks).toBeGreaterThan(0)
expect(result.feerate).toBeGreaterThan(0)
Expand Down
10 changes: 7 additions & 3 deletions packages/jellyfish-api-core/src/category/mining.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ApiClient } from '../.'

export enum EstimateMode {
UNSET = 'UNSET',
ECONOMICAL = 'ECONOMICAL',
CONSERVATIVE = 'CONSERVATIVE'
}

/**
* Mining RPCs for DeFi Blockchain
*/
Expand Down Expand Up @@ -44,7 +50,7 @@ export class Mining {
* @param {EstimateMode} [estimateMode='CONSERVATIVE'] estimateMode of fees.
* @returns {Promise<SmartFeeEstimation>}
*/
async estimateSmartFee (confirmationTarget: number, estimateMode: EstimateMode = 'CONSERVATIVE'): Promise<SmartFeeEstimation> {
async estimateSmartFee (confirmationTarget: number, estimateMode: EstimateMode = EstimateMode.CONSERVATIVE): Promise<SmartFeeEstimation> {
return await this.client.call('estimatesmartfee', [confirmationTarget, estimateMode], 'number')
}
}
Expand Down Expand Up @@ -102,5 +108,3 @@ export interface SmartFeeEstimation {
errors?: string[]
blocks: number
}

type EstimateMode = 'UNSET' | 'ECONOMICAL' | 'CONSERVATIVE'
6 changes: 5 additions & 1 deletion website/docs/jellyfish/api/mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,9 @@ interface SmartFeeEstimation {
blocks: number
}

type EstimateMode = 'UNSET' | 'ECONOMICAL' | 'CONSERVATIVE';
enum EstimateMode {
UNSET = 'UNSET',
ECONOMICAL = 'ECONOMICAL',
CONSERVATIVE = 'CONSERVATIVE'
}
```

0 comments on commit d385530

Please sign in to comment.