Skip to content

Commit 56a0feb

Browse files
committed
Added blocktypes
1 parent d0f1718 commit 56a0feb

File tree

9 files changed

+39
-9
lines changed

9 files changed

+39
-9
lines changed

src/Client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class Client {
3030
const oAddress = new Address(address)
3131
return new ClientAccountBalance(this.apiKey, 'account', action, oAddress, tag)
3232
},
33-
balancemulti(address: string[], tag: string) {
33+
balancemulti(address: string[], tag: string): ClientAccountBalancemulti {
3434
const oAddress = address.map((addresString) => new Address(addresString))
3535
return new ClientAccountBalancemulti(this.apiKey, 'account', action, oAddress, tag)
3636
},

src/entities/Blocktypes.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
import { IEntity } from '../interfaces/Entity'
3+
import { blocktypes } from '../parameters/blocktypes'
4+
import { EntityBase } from './EntityBase'
5+
6+
/**
7+
* Blocktypes: blocks or uncles
8+
*/
9+
export class Blocktypes extends EntityBase implements IEntity {
10+
/**
11+
* Error message to display when the value is invalid
12+
*/
13+
errorMessage: string = 'invalid'
14+
15+
constructor(sortParam: string) {
16+
super(sortParam)
17+
18+
}
19+
/**
20+
* Validates if the error is invalid
21+
*/
22+
valid(): boolean {
23+
return blocktypes.uncles === this.value || blocktypes.blocks === this.value
24+
}
25+
}

src/parameters/blocktypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export enum blocktypes {blocks = 'blocks', uncles = 'uncles'}

test/clients/ClientAccountTxlistinternalTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava'
2-
import { ClientAccountTxlistinternal } from '../../src/client/ClientTxlistinternal'
2+
import { ClientAccountTxlistinternal } from '../../src/client/ClientAccountTxlistinternal'
33
import { Address } from '../../src/entities/Address'
44
import { ApiKey } from '../../src/entities/Apikey'
55
import { decode } from 'querystring'

test/clients/ClientAccountTxlistinternalTxhashTest.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava'
2-
import { ClientAccountTxlistinternalTxhash } from '../../src/client/ClientTxlistinternalTxhash'
2+
import { ClientAccountTxlistinternalTxhash } from '../../src/client/ClientAccountTxlistinternalTxhash'
33
import { Address } from '../../src/entities/Address'
44
import { ApiKey } from '../../src/entities/Apikey'
55
import { decode } from 'querystring'
@@ -26,7 +26,6 @@ test('can be instantiated', t => {
2626
t.pass()
2727
})
2828

29-
3029
test('generates the right url', t => {
3130

3231
const oApiKey = new ApiKey(apiKey)
@@ -38,8 +37,3 @@ test('generates the right url', t => {
3837

3938
t.is(parsedUrl.txhash, parsedExpectedUrl.txhash)
4039
})
41-
42-
/*
43-
44-
45-
*/

test/fixtures/account/getminedblocks/address-blocktype.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

test/parametersTest.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import test from 'ava'
22
import { sort } from '../src/parameters/sort'
33
import { operand } from '../src/parameters/operand'
4+
import { blocktypes } from '../src/parameters/blocktypes'
45

56
test('sort asc exists', t => {
67
t.truthy(sort.asc)
@@ -17,3 +18,11 @@ test('operand and', t => {
1718
test('operand or', t => {
1819
t.is(operand.or, 'or')
1920
})
21+
22+
test('blocktypes blocks', t => {
23+
t.is(blocktypes.blocks, 'blocks')
24+
})
25+
26+
test('blocktypes uncles', t => {
27+
t.is(blocktypes.uncles, 'uncles')
28+
})

0 commit comments

Comments
 (0)