Skip to content

Commit 35a847e

Browse files
committed
Added txhashinternal
1 parent 6f118cb commit 35a847e

File tree

2 files changed

+138
-4
lines changed

2 files changed

+138
-4
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import * as request from 'request-promise-native'
2+
import { Address } from '../entities/Address'
3+
import { ApiKey } from '../entities/Apikey'
4+
import { IClientAccountTxlistInternalTxhash } from '../interfaces/Account'
5+
import { requestBuilder } from '../requestBuilder'
6+
import { ClientBase } from './ClientBase'
7+
8+
/**
9+
* Client for the account balance
10+
*/
11+
export class ClientAccountTxlistinternalTxhash extends ClientBase implements IClientAccountTxlistInternalTxhash {
12+
/**
13+
* Api key to send with the request
14+
*/
15+
apiKey: ApiKey
16+
/**
17+
* Hash of the transaction
18+
*/
19+
txhash: string
20+
/**
21+
* module of the etherscan api to request
22+
*/
23+
module: string
24+
/**
25+
* action of the etherscan api to request
26+
*/
27+
action: string
28+
/**
29+
* Block to start reading data
30+
*/
31+
startblock: string
32+
/**
33+
* Read data to
34+
*/
35+
endblock: string
36+
/**
37+
* Sort
38+
*/
39+
sort?: string
40+
/**
41+
* Page
42+
*/
43+
page?: string
44+
/**
45+
* startpage
46+
*/
47+
offset?: string
48+
49+
constructor(
50+
apiKey: ApiKey,
51+
module: string,
52+
action: string,
53+
txhash: string,
54+
startblock: string,
55+
endblock: string,
56+
sort?: string,
57+
page?: string,
58+
offset?: string) {
59+
super()
60+
this.apiKey = apiKey
61+
this.module = module
62+
this.action = action
63+
this.txhash = txhash
64+
this.startblock = startblock
65+
this.endblock = endblock
66+
this.sort = sort
67+
this.page = page
68+
this.offset = offset
69+
}
70+
/**
71+
* Returns the serice url
72+
* @returns url
73+
*/
74+
toUrl(): string {
75+
76+
let params = {
77+
apiKey: this.apiKey.toString(),
78+
endblock: this.endblock.toString(),
79+
startblock: this.startblock.toString(),
80+
txhash: this.txhash.toString(),
81+
}
82+
83+
if (this.sort) {
84+
params = Object.assign(params, {
85+
sort: this.sort,
86+
})
87+
}
88+
89+
if (this.page) {
90+
params = Object.assign(params, {
91+
page: this.page,
92+
})
93+
}
94+
95+
if (this.offset) {
96+
params = Object.assign(params, {
97+
offset: this.offset,
98+
})
99+
}
100+
return requestBuilder(this.module, this.action, params)
101+
}
102+
/**
103+
* Dies the actual request to the server
104+
*/
105+
async request(): Promise<any> {
106+
const options = {
107+
uri: this.toUrl(),
108+
}
109+
const res = await request.get(options)
110+
return this.processResult(res)
111+
}
112+
}

src/interfaces/Account.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface IClientAccountBalanceMultiRequest extends IClientRequest {
3030
}
3131

3232
/**
33-
* Interface to Account/txlist
33+
* Interface to Account/txlist and Txlistinternal
3434
*/
3535
export interface IClientAccountTxlistRequest extends IClientRequest {
3636
/**
@@ -59,12 +59,34 @@ export interface IClientAccountTxlistRequest extends IClientRequest {
5959
sort?: string
6060
}
6161

62-
/*
63-
64-
export interface IClientAccountTxlistInternalRequest extends IClientAccountTxlistRequest {
62+
export interface IClientAccountTxlistInternalTxhash extends IClientRequest {
63+
/**
64+
* Block to start reading data
65+
*/
66+
startblock: string
67+
/**
68+
* hash of the transaction
69+
*/
6570
txhash: string
71+
/**
72+
* Read data to
73+
*/
74+
endblock: string
75+
/**
76+
* Paging actual page
77+
*/
78+
page?: string
79+
/**
80+
* Paging start
81+
*/
82+
offset?: string
83+
/**
84+
* Sort Parameter
85+
*/
86+
sort?: string
6687
}
6788

89+
/*
6890
export interface IClientAccountTokentx extends IClientRequest {
6991
contractaddress: string
7092
startblock?: string

0 commit comments

Comments
 (0)