Skip to content

Commit ea28058

Browse files
committed
fix confirmation label
1 parent 1d4f3cf commit ea28058

File tree

7 files changed

+57
-37
lines changed

7 files changed

+57
-37
lines changed

packages/insight-previous/CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
77

88
**Note:** Version bump only for package @bitpay/insight-previous
99

10-
11-
12-
13-
1410
# [8.0.0](https://github.com/bitpay/bitcore/compare/v5.0.0-beta.44...v8.0.0) (2019-02-27)

packages/insight-previous/src/components/footer/footer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export class FooterComponent {
1111
@Input()
1212
private chainNetwork: ChainNetwork;
1313

14-
constructor(public nav: Nav) {
15-
}
14+
constructor(public nav: Nav) {}
1615

1716
public openPage(page: string): void {
1817
this.nav.push(page, {

packages/insight-previous/src/components/transaction/transaction.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@
2626

2727
<ion-row align-items-end class="small" *ngIf="!showCoins">
2828
<ion-col col-12 text-right text-uppercase>
29-
<ion-chip item-end color="danger" *ngIf="tx.confirmations === 0">
29+
<ion-chip item-end color="danger" *ngIf="confirmations < 0">
3030
<ion-label>
3131
Unconfirmed
3232
</ion-label>
3333
</ion-chip>
34-
<ion-chip item-end color="warning" *ngIf="tx.confirmations === 1">
34+
<ion-chip item-end color="warning" *ngIf="confirmations === 1">
3535
<ion-label>
3636
1 Confirmation
3737
</ion-label>
3838
</ion-chip>
39-
<ion-chip item-end color="primary" *ngIf="tx.confirmations > 1">
39+
<ion-chip item-end color="primary" *ngIf="confirmations > 1">
4040
<ion-label>
41-
{{ tx.confirmations | number }} Confirmations
41+
{{ confirmations }} Confirmations
4242
</ion-label>
4343
</ion-chip>
4444
<ion-chip item-end color="brand">
@@ -148,14 +148,14 @@
148148
</div>
149149
</ion-col>
150150
<ion-col col-6 text-right>
151-
<ion-chip color="danger" *ngIf="tx.confirmations === 0">
151+
<ion-chip color="danger" *ngIf="confirmations < 0">
152152
<ion-label>Unconfirmed</ion-label>
153153
</ion-chip>
154-
<ion-chip color="warning" *ngIf="tx.confirmations === 1">
154+
<ion-chip color="warning" *ngIf="confirmations === 1">
155155
<ion-label>1 Confirmation</ion-label>
156156
</ion-chip>
157-
<ion-chip color="primary" *ngIf="tx.confirmations > 1">
158-
<ion-label>{{ tx.confirmations | number }} Confirmations
157+
<ion-chip color="primary" *ngIf="confirmations > 1">
158+
<ion-label>{{ confirmations }} Confirmations
159159
</ion-label>
160160
</ion-chip>
161161
<ion-chip color="brand">

packages/insight-previous/src/components/transaction/transaction.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, Input, OnInit } from '@angular/core';
22
import { ApiProvider } from '../../providers/api/api';
3+
import { BlocksProvider } from '../../providers/blocks/blocks';
34
import { CurrencyProvider } from '../../providers/currency/currency';
45
import { RedirProvider } from '../../providers/redir/redir';
56
import {
@@ -25,18 +26,18 @@ export class TransactionComponent implements OnInit {
2526
public tx: any = {};
2627
@Input()
2728
public showCoins = false;
29+
public confirmations: number;
2830

2931
constructor(
3032
public currencyProvider: CurrencyProvider,
3133
public apiProvider: ApiProvider,
3234
public txProvider: TxsProvider,
33-
public redirProvider: RedirProvider
35+
public redirProvider: RedirProvider,
36+
public blocksProvider: BlocksProvider
3437
) {}
3538

3639
public ngOnInit(): void {
37-
if (this.showCoins) {
38-
this.getCoins();
39-
}
40+
this.showCoins ? this.getCoins() : this.getConfirmations();
4041
}
4142

4243
public getCoins(): void {
@@ -45,6 +46,7 @@ export class TransactionComponent implements OnInit {
4546
this.tx.vout = data.outputs;
4647
this.tx.fee = this.txProvider.getFee(this.tx);
4748
this.tx.valueOut = data.outputs.reduce((a, b) => a + b.value, 0);
49+
this.getConfirmations();
4850
});
4951
}
5052

@@ -56,6 +58,15 @@ export class TransactionComponent implements OnInit {
5658
return vout.address;
5759
}
5860

61+
public getConfirmations() {
62+
this.blocksProvider.getCurrentHeight().subscribe(height => {
63+
this.confirmations =
64+
this.tx.blockheight > 0
65+
? height - this.tx.blockheight + 1
66+
: this.tx.blockheight;
67+
});
68+
}
69+
5970
public goToTx(txId: string, vout?: number, fromVout?: boolean): void {
6071
this.redirProvider.redir('transaction', {
6172
txId,

packages/insight-previous/src/pages/messages/messages.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Component, Injectable } from '@angular/core';
2-
import {
3-
AbstractControl,
4-
FormBuilder,
5-
FormGroup,
6-
ValidationErrors,
7-
Validators
2+
import {
3+
AbstractControl,
4+
FormBuilder,
5+
FormGroup,
6+
ValidationErrors,
7+
Validators
88
} from '@angular/forms';
99
import { IonicPage, NavParams } from 'ionic-angular';
1010
import { ApiProvider, ChainNetwork } from '../../providers/api/api';
@@ -51,10 +51,10 @@ export class MessagesPage {
5151
this.apiProvider.changeNetwork(this.chainNetwork);
5252
this.currencyProvider.setCurrency();
5353
this.priceProvider.setCurrency();
54-
54+
5555
this.messageForm = formBuilder.group({
5656
address: [
57-
'',
57+
'',
5858
Validators.compose([Validators.minLength(1), Validators.required])
5959
],
6060
signature: [
@@ -76,7 +76,8 @@ export class MessagesPage {
7676
return;
7777
}
7878

79-
const bitcore = this.chainNetwork.chain === 'BTC' ? bitcoreLib : bitcoreLibCash;
79+
const bitcore =
80+
this.chainNetwork.chain === 'BTC' ? bitcoreLib : bitcoreLibCash;
8081
const message = new bitcore.Message(values.message);
8182

8283
try {
@@ -85,17 +86,17 @@ export class MessagesPage {
8586
} else {
8687
this.error = message.error;
8788
}
88-
} catch(e) {
89+
} catch (e) {
8990
this.error = e.message;
9091
this.logger.error(e.message);
91-
};
92+
}
9293
}
9394

9495
private isAddressValid(addr): boolean {
95-
const bitcore = this.chainNetwork.chain === 'BTC' ? bitcoreLib : bitcoreLibCash;
96-
return !!bitcore.Address.isValid(addr, this.chainNetwork.network) ?
97-
true :
98-
false;
96+
const bitcore =
97+
this.chainNetwork.chain === 'BTC' ? bitcoreLib : bitcoreLibCash;
98+
return !!bitcore.Address.isValid(addr, this.chainNetwork.network)
99+
? true
100+
: false;
99101
}
100-
101102
}

packages/insight-previous/src/pages/transaction/transaction.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h2>Summary</h2>
3939
{{ tx.time * 1000 | date:'medium' }}
4040
</ion-note>
4141
</ion-item>
42-
<ion-item *ngIf="tx.confirmations !== 0">
42+
<ion-item *ngIf="confirmations > 0">
4343
Mined Time
4444
<ion-note item-end>
4545
{{ tx.blocktime * 1000 | date:'medium' }}
@@ -50,7 +50,7 @@ <h2>Summary</h2>
5050
<ion-note item-end>
5151
<a (click)="goToBlock(tx.blockhash)">{{ tx.blockhash }}</a>
5252
</ion-note>
53-
<ion-note *ngIf="tx.confirmations === 0" item-end>
53+
<ion-note *ngIf="confirmations < 0" item-end>
5454
Unconfirmed
5555
</ion-note>
5656
</ion-item>

packages/insight-previous/src/pages/transaction/transaction.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, Injectable } from '@angular/core';
22
import { IonicPage, NavParams } from 'ionic-angular';
33
import { ApiProvider, ChainNetwork } from '../../providers/api/api';
4+
import { BlocksProvider } from '../../providers/blocks/blocks';
45
import { CurrencyProvider } from '../../providers/currency/currency';
56
import { Logger } from '../../providers/logger/logger';
67
import { PriceProvider } from '../../providers/price/price';
@@ -24,6 +25,7 @@ export class TransactionPage {
2425
public tx: any = {};
2526
public vout: number;
2627
public fromVout: boolean;
28+
public confirmations: number;
2729

2830
constructor(
2931
public navParams: NavParams,
@@ -32,7 +34,8 @@ export class TransactionPage {
3234
public currencyProvider: CurrencyProvider,
3335
private logger: Logger,
3436
private priceProvider: PriceProvider,
35-
public redirProvider: RedirProvider
37+
public redirProvider: RedirProvider,
38+
private blocksProvider: BlocksProvider
3639
) {
3740
this.txId = navParams.get('txId');
3841
this.vout = navParams.get('vout');
@@ -57,6 +60,7 @@ export class TransactionPage {
5760
data => {
5861
this.tx = data.tx;
5962
this.loading = false;
63+
this.getConfirmations();
6064
// Be aware that the tx component is loading data into the tx object
6165
},
6266
err => {
@@ -66,6 +70,15 @@ export class TransactionPage {
6670
);
6771
}
6872

73+
public getConfirmations() {
74+
this.blocksProvider.getCurrentHeight().subscribe(height => {
75+
this.confirmations =
76+
this.tx.blockheight > 0
77+
? height - this.tx.blockheight + 1
78+
: this.tx.blockheight;
79+
});
80+
}
81+
6982
public goToBlock(blockHash: string): void {
7083
this.redirProvider.redir('block-detail', {
7184
blockHash,

0 commit comments

Comments
 (0)