Alexis Hernandez
7 years ago
3 changed files with 62 additions and 0 deletions
@ -0,0 +1,36 @@ |
|||
|
|||
|
|||
export class BlockDetails { |
|||
block: Block; |
|||
rewards: BlockRewards; |
|||
} |
|||
|
|||
class Block { |
|||
hash: string; |
|||
previousBlockhash: string; |
|||
nextBlockhash: string; |
|||
merkleRoot: string; |
|||
transactions: string[]; |
|||
confirmations: number; |
|||
size: number; |
|||
height: number; |
|||
version: number; |
|||
time: number; |
|||
medianTime: number; |
|||
nonce: number; |
|||
bits: string; |
|||
chainwork: string; |
|||
difficulty: number; |
|||
tposContract: string; |
|||
} |
|||
|
|||
class BlockRewards { |
|||
reward: BlockReward; |
|||
coinstake: BlockReward; |
|||
masternode: BlockReward; |
|||
} |
|||
|
|||
class BlockReward { |
|||
address: string; |
|||
value: number; |
|||
} |
@ -0,0 +1,24 @@ |
|||
import { Injectable } from '@angular/core'; |
|||
import { HttpClient, HttpHeaders } from '@angular/common/http'; |
|||
import { Observable } from 'rxjs/Observable'; |
|||
|
|||
import { environment } from '../../environments/environment'; |
|||
|
|||
import { BlockDetails } from '../models/block'; |
|||
|
|||
const httpOptions = { |
|||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }) |
|||
}; |
|||
|
|||
@Injectable() |
|||
export class BlocksService { |
|||
|
|||
private baseUrl = environment.api.url + '/blocks'; |
|||
|
|||
constructor(private http: HttpClient) { } |
|||
|
|||
get(blockhash: string): Observable<BlockDetails> { |
|||
const url = `${this.baseUrl}/${blockhash}`; |
|||
return this.http.get<BlockDetails>(url); |
|||
} |
|||
} |
Loading…
Reference in new issue