Skip to content

Commit 130f6bf

Browse files
committed
UI fixes for verify message page
1 parent 1d4f3cf commit 130f6bf

File tree

5 files changed

+72
-66
lines changed

5 files changed

+72
-66
lines changed

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/pages/broadcast-tx/broadcast-tx.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, Injectable } from '@angular/core';
22
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
33
import { Http } from '@angular/http';
44
import { IonicPage, NavParams, ToastController } from 'ionic-angular';
5-
import { ApiProvider } from '../../providers/api/api';
5+
import { ApiProvider, ChainNetwork } from '../../providers/api/api';
66
import { CurrencyProvider } from '../../providers/currency/currency';
77
import { Logger } from '../../providers/logger/logger';
88
import { PriceProvider } from '../../providers/price/price';
@@ -23,6 +23,7 @@ export class BroadcastTxPage {
2323
public txForm: FormGroup;
2424
private status: string;
2525
private toast: any;
26+
private chainNetwork: ChainNetwork;
2627

2728
constructor(
2829
private toastCtrl: ToastController,
@@ -34,9 +35,17 @@ export class BroadcastTxPage {
3435
private priceProvider: PriceProvider,
3536
private currencyProvider: CurrencyProvider
3637
) {
37-
const chain: string = this.apiProvider.getConfig().chain;
38-
const network: string = this.apiProvider.getConfig().network;
39-
this.apiProvider.changeNetwork({ chain, network });
38+
const chain: string =
39+
navParams.get('chain') || this.apiProvider.getConfig().chain;
40+
const network: string =
41+
navParams.get('network') || this.apiProvider.getConfig().network;
42+
43+
this.chainNetwork = {
44+
chain,
45+
network
46+
};
47+
48+
this.apiProvider.changeNetwork(this.chainNetwork);
4049
this.currencyProvider.setCurrency();
4150
this.priceProvider.setCurrency();
4251

@@ -66,7 +75,7 @@ export class BroadcastTxPage {
6675
private presentToast(success: boolean, response: any): void {
6776
const message: string = success
6877
? 'Transaction successfully broadcast. Trasaction id: ' +
69-
JSON.parse(response._body).txid
78+
JSON.parse(response._body).txid
7079
: 'An error occurred: ' + response._body;
7180
if (this.toast) {
7281
this.toast.dismiss();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PriceProvider } from '../../providers/price/price';
88
@Injectable()
99
@IonicPage({
1010
name: 'home',
11-
segment: 'home/:chain/:network'
11+
segment: ':chain/:network/home'
1212
})
1313
@Component({
1414
selector: 'page-home',
Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,41 @@
11
<head-nav></head-nav>
22
<ion-content>
33
<ion-grid fixed>
4-
<div class="page-content">
5-
<h1>Verify Message</h1>
6-
<ion-card>
7-
<ion-card-content>
8-
Bitcoin comes with a way of signing arbitrary messages. <br>
9-
This form can be used to verify that a message comes from a specific Bitcoin address.
10-
</ion-card-content>
11-
</ion-card>
12-
<ion-row>
13-
<ion-col col-md-8 push-md-2>
14-
<form [formGroup]="messageForm">
15-
<ion-list>
16-
<ion-item>
17-
<ion-label staked>Address</ion-label>
18-
<ion-input type="text" formControlName="address" [value]="messageForm.value.address" clearInput></ion-input>
19-
</ion-item>
4+
<div class="page-content">
5+
<h1>Verify Message</h1>
6+
<form [formGroup]="messageForm">
7+
<ion-list>
8+
<ion-item>
9+
<p>Bitcoin comes with a way of signing arbitrary messages. <br>
10+
This form can be used to verify that a message comes from a specific Bitcoin address.</p>
11+
</ion-item>
2012

21-
<ion-item>
22-
<ion-label staked>Signature</ion-label>
23-
<ion-input type="text" formControlName="signature" clearInput></ion-input>
24-
</ion-item>
13+
<ion-item>
14+
<ion-label floating>Address</ion-label>
15+
<ion-input type="text" formControlName="address" [value]="messageForm.value.address"></ion-input>
16+
</ion-item>
17+
<ion-item>
18+
<ion-label floating>Signature</ion-label>
19+
<ion-input type="text" formControlName="signature"></ion-input>
20+
</ion-item>
21+
<ion-item>
22+
<ion-label floating>Message</ion-label>
23+
<ion-input type="text" formControlName="message"></ion-input>
24+
</ion-item>
2525

26-
<ion-item>
27-
<ion-label staked>Message</ion-label>
28-
<ion-input type="text" formControlName="message" clearInput></ion-input>
29-
</ion-item>
30-
</ion-list>
26+
<ion-item *ngIf="success">
27+
<p ion-text color="primary" *ngIf="success">{{ success }}</p>
28+
</ion-item>
29+
<ion-item *ngIf="error">
30+
<p ion-text color="danger" *ngIf="error"> {{ error }}</p>
31+
</ion-item>
3132

32-
<p ion-text color="primary" *ngIf="success">{{ success }}</p>
33-
<p ion-text color="danger" *ngIf="error"> {{ error }}</p>
34-
35-
<ion-row>
36-
<ion-col push-md-8 col-md-4>
37-
<button ion-button block (click)="verify()" [disabled]="messageForm.invalid">
38-
Verify
39-
</button>
40-
</ion-col>
41-
</ion-row>
42-
</form>
43-
</ion-col>
44-
</ion-row>
45-
</div>
33+
<ion-item>
34+
<button ion-button outline (click)="verify()" [disabled]="messageForm.invalid">Verify</button>
35+
</ion-item>
36+
</ion-list>
37+
</form>
38+
</div>
4639
</ion-grid>
4740
</ion-content>
48-
<footer [chainNetwork]="chainNetwork"></footer>
41+
<footer [chainNetwork]="chainNetwork"></footer>

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

Lines changed: 23 additions & 18 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';
@@ -18,7 +18,7 @@ import * as bitcoreLibCash from 'bitcore-lib-cash';
1818
@Injectable()
1919
@IonicPage({
2020
name: 'messages',
21-
segment: ':chain/:network/messages/verify',
21+
segment: ':chain/:network/verify-message',
2222
defaultHistory: ['home']
2323
})
2424
@Component({
@@ -51,11 +51,15 @@ 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-
'',
58-
Validators.compose([Validators.minLength(1), Validators.required])
57+
'',
58+
Validators.compose([
59+
Validators.pattern(/^[0-9A-Fa-f]+$/),
60+
Validators.minLength(1),
61+
Validators.required
62+
])
5963
],
6064
signature: [
6165
'',
@@ -76,7 +80,8 @@ export class MessagesPage {
7680
return;
7781
}
7882

79-
const bitcore = this.chainNetwork.chain === 'BTC' ? bitcoreLib : bitcoreLibCash;
83+
const bitcore =
84+
this.chainNetwork.chain === 'BTC' ? bitcoreLib : bitcoreLibCash;
8085
const message = new bitcore.Message(values.message);
8186

8287
try {
@@ -85,17 +90,17 @@ export class MessagesPage {
8590
} else {
8691
this.error = message.error;
8792
}
88-
} catch(e) {
93+
} catch (e) {
8994
this.error = e.message;
9095
this.logger.error(e.message);
91-
};
96+
}
9297
}
9398

9499
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;
100+
const bitcore =
101+
this.chainNetwork.chain === 'BTC' ? bitcoreLib : bitcoreLibCash;
102+
return !!bitcore.Address.isValid(addr, this.chainNetwork.network)
103+
? true
104+
: false;
99105
}
100-
101106
}

0 commit comments

Comments
 (0)