1
- import { Component } from '@angular/core' ;
1
+ import { Component , OnInit } from '@angular/core' ;
2
2
import { Input } from '@angular/core' ;
3
3
import { NavController } from 'ionic-angular' ;
4
- import { CurrencyProvider } from '../../providers/currency/currency' ;
5
- import { TxsProvider , ApiCoin } from '../../providers/transactions/transactions' ;
6
4
import { ApiProvider } from '../../providers/api/api' ;
5
+ import { CurrencyProvider } from '../../providers/currency/currency' ;
6
+ import { ApiCoin , TxsProvider } from '../../providers/transactions/transactions' ;
7
7
8
8
/**
9
9
* Generated class for the TransactionComponent component.
@@ -15,19 +15,19 @@ import { ApiProvider } from '../../providers/api/api';
15
15
selector : 'transaction' ,
16
16
templateUrl : 'transaction.html'
17
17
} )
18
- export class TransactionComponent {
19
- private COIN : number = 100000000 ;
18
+ export class TransactionComponent implements OnInit {
19
+ private COIN = 100000000 ;
20
20
21
- public expanded : boolean = false ;
21
+ public expanded = false ;
22
22
@Input ( ) public tx : any = { } ;
23
- @Input ( ) public showCoins ?: boolean = false ;
23
+ @Input ( ) public showCoins = false ;
24
24
25
25
constructor (
26
26
private navCtrl : NavController ,
27
27
public currency : CurrencyProvider ,
28
28
public apiProvider : ApiProvider ,
29
29
public txProvider : TxsProvider
30
- ) { }
30
+ ) { }
31
31
32
32
public ngOnInit ( ) : void {
33
33
if ( this . showCoins ) {
@@ -56,36 +56,36 @@ export class TransactionComponent {
56
56
this . navCtrl . push ( 'transaction' , {
57
57
chain : this . apiProvider . networkSettings . value . selectedNetwork . chain ,
58
58
network : this . apiProvider . networkSettings . value . selectedNetwork . network ,
59
- txId : txId
59
+ txId
60
60
} ) ;
61
61
}
62
62
63
63
public goToAddress ( addrStr : string ) : void {
64
64
this . navCtrl . push ( 'address' , {
65
65
chain : this . apiProvider . networkSettings . value . selectedNetwork . chain ,
66
66
network : this . apiProvider . networkSettings . value . selectedNetwork . network ,
67
- addrStr : addrStr
67
+ addrStr
68
68
} ) ;
69
69
}
70
70
71
71
public toggleExpanded ( ) : void {
72
72
this . expanded = ! this . expanded ;
73
73
}
74
74
75
- public aggregateItems ( items : Array < any > ) : Array < any > {
76
- if ( ! items ) return [ ] ;
75
+ public aggregateItems ( items : any [ ] ) : any [ ] {
76
+ if ( ! items ) { return [ ] ; }
77
77
78
- let l : number = items . length ;
78
+ const l : number = items . length ;
79
79
80
- let ret : Array < any > = [ ] ;
81
- let tmp : any = { } ;
82
- let u : number = 0 ;
80
+ const ret : any [ ] = [ ] ;
81
+ const tmp : any = { } ;
82
+ let u = 0 ;
83
83
84
- for ( let i : number = 0 ; i < l ; i ++ ) {
85
- let notAddr : boolean = false ;
84
+ for ( let i = 0 ; i < l ; i ++ ) {
85
+ let notAddr = false ;
86
86
// non standard input
87
- if ( items [ i ] . scriptSig && ! items [ i ] . addr ) {
88
- items [ i ] . addr = 'Unparsed address [' + u ++ + ']' ;
87
+ if ( items [ i ] . scriptSig && ! items [ i ] . address ) {
88
+ items [ i ] . address = 'Unparsed address [' + u ++ + ']' ;
89
89
items [ i ] . notAddr = true ;
90
90
notAddr = true ;
91
91
}
@@ -99,36 +99,36 @@ export class TransactionComponent {
99
99
100
100
// multiple addr at output
101
101
if ( items [ i ] . scriptPubKey && items [ i ] . scriptPubKey . addresses . length > 1 ) {
102
- items [ i ] . addr = items [ i ] . scriptPubKey . addresses . join ( ',' ) ;
102
+ items [ i ] . address = items [ i ] . scriptPubKey . addresses . join ( ',' ) ;
103
103
ret . push ( items [ i ] ) ;
104
104
continue ;
105
105
}
106
106
107
- let addr : string = items [ i ] . addr || ( items [ i ] . scriptPubKey && items [ i ] . scriptPubKey . addresses [ 0 ] ) ;
107
+ const address : string = items [ i ] . address || ( items [ i ] . scriptPubKey && items [ i ] . scriptPubKey . addresses [ 0 ] ) ;
108
108
109
- if ( ! tmp [ addr ] ) {
110
- tmp [ addr ] = { } ;
111
- tmp [ addr ] . valueSat = 0 ;
112
- tmp [ addr ] . count = 0 ;
113
- tmp [ addr ] . addr = addr ;
114
- tmp [ addr ] . items = [ ] ;
109
+ if ( ! tmp [ address ] ) {
110
+ tmp [ address ] = { } ;
111
+ tmp [ address ] . valueSat = 0 ;
112
+ tmp [ address ] . count = 0 ;
113
+ tmp [ address ] . address = address ;
114
+ tmp [ address ] . items = [ ] ;
115
115
}
116
- tmp [ addr ] . isSpent = items [ i ] . spentTxId ;
116
+ tmp [ address ] . isSpent = items [ i ] . spentTxId ;
117
117
118
- tmp [ addr ] . doubleSpentTxID = tmp [ addr ] . doubleSpentTxID || items [ i ] . doubleSpentTxID ;
119
- tmp [ addr ] . doubleSpentIndex = tmp [ addr ] . doubleSpentIndex || items [ i ] . doubleSpentIndex ;
120
- tmp [ addr ] . dbError = tmp [ addr ] . dbError || items [ i ] . dbError ;
121
- tmp [ addr ] . valueSat += Math . round ( items [ i ] . value * this . COIN ) ;
122
- tmp [ addr ] . items . push ( items [ i ] ) ;
123
- tmp [ addr ] . notAddr = notAddr ;
118
+ tmp [ address ] . doubleSpentTxID = tmp [ address ] . doubleSpentTxID || items [ i ] . doubleSpentTxID ;
119
+ tmp [ address ] . doubleSpentIndex = tmp [ address ] . doubleSpentIndex || items [ i ] . doubleSpentIndex ;
120
+ tmp [ address ] . dbError = tmp [ address ] . dbError || items [ i ] . dbError ;
121
+ tmp [ address ] . valueSat += Math . round ( items [ i ] . value * this . COIN ) ;
122
+ tmp [ address ] . items . push ( items [ i ] ) ;
123
+ tmp [ address ] . notAddr = notAddr ;
124
124
125
- if ( items [ i ] . unconfirmedInput ) tmp [ addr ] . unconfirmedInput = true ;
125
+ if ( items [ i ] . unconfirmedInput ) { tmp [ address ] . unconfirmedInput = true ; }
126
126
127
- tmp [ addr ] . count ++ ;
127
+ tmp [ address ] . count ++ ;
128
128
}
129
129
130
- for ( let v in tmp ) {
131
- let obj : any = tmp [ v ] ;
130
+ for ( const v in tmp ) {
131
+ const obj : any = tmp [ v ] ;
132
132
obj . value = obj . value || parseInt ( obj . valueSat ) / this . COIN ;
133
133
ret . push ( obj ) ;
134
134
}
0 commit comments