Moved transaction code from transaction-list to transaction component
This commit is contained in:
parent
736b85e9df
commit
b656fb55d5
@ -7,12 +7,10 @@ import { SplashScreen } from '@ionic-native/splash-screen';
|
|||||||
import { InsightApp } from './app.component';
|
import { InsightApp } from './app.component';
|
||||||
import { PagesModule, BlocksPage, BroadcastTxPage, NodeStatusPage, VerifyMessagePage } from '../pages';
|
import { PagesModule, BlocksPage, BroadcastTxPage, NodeStatusPage, VerifyMessagePage } from '../pages';
|
||||||
import { BlocksService, StorageService } from '../services';
|
import { BlocksService, StorageService } from '../services';
|
||||||
import { TransactionComponent } from '../components/transaction/transaction';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
InsightApp,
|
InsightApp
|
||||||
TransactionComponent
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
|||||||
@ -1,48 +1,5 @@
|
|||||||
<div>
|
<div>
|
||||||
<div *ngFor="let tx of transactions.txs" style="border: 1px solid purple">
|
<div *ngFor="let tx of transactions.txs" style="border: 1px solid purple">
|
||||||
<p><a (click)="goToTx(tx.txid)">{{ tx.txid }}</a></p>
|
<transaction [tx]="tx"></transaction>
|
||||||
<div [hidden]="!tx.firstSeenTs">
|
|
||||||
<span translate>first seen at</span>
|
|
||||||
<time>{{tx.firstSeenTs * 1000 | date:'medium'}}</time>
|
|
||||||
</div>
|
|
||||||
<div [hidden]="!tx.blocktime && tx.firstSeenTs">
|
|
||||||
<span translate>mined</span>
|
|
||||||
<time>{{tx.time * 1000 | date:'medium'}}</time>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div [hidden]="!tx.isCoinBase">
|
|
||||||
<div *ngFor="let vin of tx.vin">
|
|
||||||
<div>
|
|
||||||
<span translate>No Inputs (Newly Generated Coins)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngFor="let vout of tx.vout">
|
|
||||||
<div>
|
|
||||||
<p><a (click)="goToAddress(getAddress(vout))">{{ getAddress(vout) }}</a> {{ vout.value + ' BTC' }} <span [hidden]="!vout.spentTxId">(S)</span><span [hidden]="vout.spentTxId">(U)</span></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div [hidden]="tx.isCoinBase">
|
|
||||||
<div *ngFor="let vin of tx.vin">
|
|
||||||
<div><a (click)="goToAddress(vin.addr)">{{ vin.addr }}</a></div>
|
|
||||||
<p>{{ vin.value + ' BTC' }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngFor="let vout of tx.vout">
|
|
||||||
<div>
|
|
||||||
<p><a (click)="goToAddress(getAddress(vout))">{{ getAddress(vout) }}</a> {{ vout.value + ' BTC' }} <span [hidden]="!vout.spentTxId">(S)</span><span [hidden]="vout.spentTxId">(U)</span></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { IonicModule } from 'ionic-angular';
|
import { IonicModule } from 'ionic-angular';
|
||||||
import { TransactionListComponent } from './transaction-list';
|
import { TransactionListComponent } from './transaction-list';
|
||||||
|
import { TransactionComponentModule } from '../transaction/transaction.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
TransactionListComponent
|
TransactionListComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
IonicModule
|
IonicModule,
|
||||||
|
TransactionComponentModule
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
TransactionListComponent
|
TransactionListComponent
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { Input } from '@angular/core';
|
import { Input } from '@angular/core';
|
||||||
import { NavController } from 'ionic-angular';
|
|
||||||
import { Http } from '@angular/http';
|
import { Http } from '@angular/http';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +19,7 @@ export class TransactionListComponent {
|
|||||||
@Input() public queryValue: string;
|
@Input() public queryValue: string;
|
||||||
public transactions: any = [];
|
public transactions: any = [];
|
||||||
|
|
||||||
constructor(private navCtrl: NavController, private http: Http) {
|
constructor(private http: Http) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ngOnInit(): void {
|
private ngOnInit(): void {
|
||||||
@ -43,24 +42,4 @@ export class TransactionListComponent {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAddress(vout: any): string {
|
|
||||||
if (vout.scriptPubKey && vout.scriptPubKey.addresses) {
|
|
||||||
return vout.scriptPubKey.addresses[0];
|
|
||||||
} else {
|
|
||||||
return 'Unparsed address';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public goToTx(txId: string): void {
|
|
||||||
this.navCtrl.push('transaction', {
|
|
||||||
'txId': txId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public goToAddress(addrStr: string): void {
|
|
||||||
this.navCtrl.push('address', {
|
|
||||||
'addrStr': addrStr
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,46 @@
|
|||||||
<!-- Generated template for the TransactionComponent component -->
|
|
||||||
<div>
|
<div>
|
||||||
{{text}}
|
<p><a (click)="goToTx(tx.txid)">{{ tx.txid }}</a></p>
|
||||||
|
<div [hidden]="!tx.firstSeenTs">
|
||||||
|
<span translate>first seen at</span>
|
||||||
|
<time>{{tx.firstSeenTs * 1000 | date:'medium'}}</time>
|
||||||
|
</div>
|
||||||
|
<div [hidden]="!tx.blocktime && tx.firstSeenTs">
|
||||||
|
<span translate>mined</span>
|
||||||
|
<time>{{tx.time * 1000 | date:'medium'}}</time>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div [hidden]="!tx.isCoinBase">
|
||||||
|
<div *ngFor="let vin of tx.vin">
|
||||||
|
<div>
|
||||||
|
<span translate>No Inputs (Newly Generated Coins)</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div *ngFor="let vout of tx.vout">
|
||||||
|
<div>
|
||||||
|
<p><a (click)="goToAddress(getAddress(vout))">{{ getAddress(vout) }}</a> {{ vout.value + ' BTC' }} <span [hidden]="!vout.spentTxId">(S)</span><span [hidden]="vout.spentTxId">(U)</span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div [hidden]="tx.isCoinBase">
|
||||||
|
<div *ngFor="let vin of tx.vin">
|
||||||
|
<div><a (click)="goToAddress(vin.addr)">{{ vin.addr }}</a></div>
|
||||||
|
<p>{{ vin.value + ' BTC' }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div *ngFor="let vout of tx.vout">
|
||||||
|
<div>
|
||||||
|
<p><a (click)="goToAddress(getAddress(vout))">{{ getAddress(vout) }}</a> {{ vout.value + ' BTC' }} <span [hidden]="!vout.spentTxId">(S)</span><span [hidden]="vout.spentTxId">(U)</span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
import { Input } from '@angular/core';
|
||||||
|
import { NavController } from 'ionic-angular';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated class for the TransactionComponent component.
|
* Generated class for the TransactionComponent component.
|
||||||
@ -12,11 +14,28 @@ import { Component } from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class TransactionComponent {
|
export class TransactionComponent {
|
||||||
|
|
||||||
text: string;
|
@Input() public tx: any = {};
|
||||||
|
|
||||||
constructor() {
|
constructor(private navCtrl: NavController) {
|
||||||
console.log('Hello TransactionComponent Component');
|
|
||||||
this.text = 'Hello World';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getAddress(vout: any): string {
|
||||||
|
if (vout.scriptPubKey && vout.scriptPubKey.addresses) {
|
||||||
|
return vout.scriptPubKey.addresses[0];
|
||||||
|
} else {
|
||||||
|
return 'Unparsed address';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public goToTx(txId: string): void {
|
||||||
|
this.navCtrl.push('transaction', {
|
||||||
|
'txId': txId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public goToAddress(addrStr: string): void {
|
||||||
|
this.navCtrl.push('address', {
|
||||||
|
'addrStr': addrStr
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user