@@ -3,9 +3,6 @@ import { Address, ChainListEntry, RichListEntry, Supply, WalletListEntry } from
33
44export class Provider {
55 private baseUrl : string ;
6- private response : {
7- data : unknown | undefined ;
8- } ;
96
107 public constructor ( baseUrlOrNetwork ?: string ) {
118 baseUrlOrNetwork = baseUrlOrNetwork || 'CITY' ;
@@ -15,8 +12,6 @@ export class Provider {
1512 } else {
1613 this . baseUrl = this . getNetworkUrl ( baseUrlOrNetwork ) ;
1714 }
18-
19- this . response = { data : undefined } ;
2015 }
2116
2217 private async fetchText ( url : string ) : Promise < string > {
@@ -43,22 +38,6 @@ export class Provider {
4338 } ) ;
4439 }
4540
46- // protected async executeGet<AxiosResponse>(endpoint: string): Promise<AxiosResponse | undefined> {
47- // await axios
48- // .get(endpoint)
49- // .then((res) => {
50- // this.response = {
51- // data: res.data,
52- // error: undefined,
53- // };
54- // })
55- // .catch((error) => {
56- // this.response.error = error;
57- // });
58-
59- // return this.response as unknown as AxiosResponse;
60- // }
61-
6241 public setNetwork ( network : string ) : void {
6342 this . baseUrl = this . getNetworkUrl ( network ) ;
6443 }
@@ -103,55 +82,55 @@ export class Provider {
10382 return this . fetchJson < Address > ( `${ this . baseUrl } /api/query/address/${ address } ` ) ;
10483 }
10584
106- public async getAddressTransactions < AxiosResponse > ( address : string ) : Promise < AxiosResponse | undefined > {
107- return this . executeGet ( `${ this . baseUrl } /api/query/address/${ address } /transactions` ) ;
85+ public async getAddressTransactions ( address : string ) {
86+ return this . fetchJson ( `${ this . baseUrl } /api/query/address/${ address } /transactions` ) ;
10887 }
10988
110- public async getAddressUnconfirmedTransactions < AxiosResponse > ( address : string ) : Promise < AxiosResponse | undefined > {
111- return this . executeGet ( `${ this . baseUrl } /api/query/address/${ address } /transactions/unconfirmed` ) ;
89+ public async getAddressUnconfirmedTransactions ( address : string ) {
90+ return this . fetchJson ( `${ this . baseUrl } /api/query/address/${ address } /transactions/unconfirmed` ) ;
11291 }
11392
114- public async getAddressSpentTransactions < AxiosResponse > ( address : string ) : Promise < AxiosResponse | undefined > {
115- return this . executeGet ( `${ this . baseUrl } /api/query/address/${ address } /transactions/spent` ) ;
93+ public async getAddressSpentTransactions ( address : string ) {
94+ return this . fetchJson ( `${ this . baseUrl } /api/query/address/${ address } /transactions/spent` ) ;
11695 }
11796
118- public async getAddressUnspentTransactions < AxiosResponse > ( address : string ) : Promise < AxiosResponse | undefined > {
119- return this . executeGet ( `${ this . baseUrl } /api/query/address/${ address } /transactions/unspent` ) ;
97+ public async getAddressUnspentTransactions ( address : string ) {
98+ return this . fetchJson ( `${ this . baseUrl } /api/query/address/${ address } /transactions/unspent` ) ;
12099 }
121100
122- public async getMempoolTransactions < AxiosResponse > ( ) : Promise < AxiosResponse | undefined > {
123- return this . executeGet ( `${ this . baseUrl } /api/query/mempool/transactions` ) ;
101+ public async getMempoolTransactions ( ) {
102+ return this . fetchJson ( `${ this . baseUrl } /api/query/mempool/transactions` ) ;
124103 }
125104
126- public async getMempoolTransactionsCount < AxiosResponse > ( ) : Promise < AxiosResponse | undefined > {
127- return this . executeGet ( `${ this . baseUrl } /api/query/mempool/transactions/count` ) ;
105+ public async getMempoolTransactionsCount ( ) {
106+ return this . fetchText ( `${ this . baseUrl } /api/query/mempool/transactions/count` ) ;
128107 }
129108
130- public async getTransactionById < AxiosResponse > ( id : string ) : Promise < AxiosResponse | undefined > {
131- return this . executeGet ( `${ this . baseUrl } /api/query/transaction/${ id } ` ) ;
109+ public async getTransactionById ( id : string ) {
110+ return this . fetchJson ( `${ this . baseUrl } /api/query/transaction/${ id } ` ) ;
132111 }
133112
134- public async getBlock < AxiosResponse > ( ) : Promise < AxiosResponse | undefined > {
135- return this . executeGet ( `${ this . baseUrl } /api/query/block` ) ;
113+ public async getBlock ( ) {
114+ return this . fetchJson ( `${ this . baseUrl } /api/query/block` ) ;
136115 }
137116
138- public async getBlockTransactionsByHash < AxiosResponse > ( hash : string ) : Promise < AxiosResponse | undefined > {
139- return this . executeGet ( `${ this . baseUrl } /api/query/block/${ hash } /transactions` ) ;
117+ public async getBlockTransactionsByHash ( hash : string ) {
118+ return this . fetchJson ( `${ this . baseUrl } /api/query/block/${ hash } /transactions` ) ;
140119 }
141120
142- public async getBlockByHash < AxiosResponse > ( hash : string ) : Promise < AxiosResponse | undefined > {
143- return this . executeGet ( `${ this . baseUrl } /api/query/block/${ hash } ` ) ;
121+ public async getBlockByHash ( hash : string ) {
122+ return this . fetchJson ( `${ this . baseUrl } /api/query/block/${ hash } ` ) ;
144123 }
145124
146- public async getBlockByIndex < AxiosResponse > ( index : string ) : Promise < AxiosResponse | undefined > {
147- return this . executeGet ( `${ this . baseUrl } /api/query/block/index/${ index } ` ) ;
125+ public async getBlockByIndex ( index : string ) {
126+ return this . fetchJson ( `${ this . baseUrl } /api/query/block/index/${ index } ` ) ;
148127 }
149128
150- public async getBlockTransactionsByIndex < AxiosResponse > ( index : string ) : Promise < AxiosResponse | undefined > {
151- return this . executeGet ( `${ this . baseUrl } /api/query/block/index/${ index } /transactions` ) ;
129+ public async getBlockTransactionsByIndex ( index : string ) {
130+ return this . fetchJson ( `${ this . baseUrl } /api/query/block/index/${ index } /transactions` ) ;
152131 }
153132
154- public async getLatestBlock < AxiosResponse > ( ) : Promise < AxiosResponse | undefined > {
155- return this . executeGet ( `${ this . baseUrl } /api/query/block/latest` ) ;
133+ public async getLatestBlock ( ) {
134+ return this . fetchJson ( `${ this . baseUrl } /api/query/block/latest` ) ;
156135 }
157136}
0 commit comments