Fixes for send and confirm notifications

This commit is contained in:
Gabriel Masclef 2017-11-07 15:51:02 -03:00
parent 782f166ba9
commit f1d12b3863
No known key found for this signature in database
GPG Key ID: DD6D7EAADE12280D
3 changed files with 34 additions and 29 deletions

View File

@ -9,7 +9,6 @@
<ion-content> <ion-content>
<ion-list> <ion-list>
<ion-label>Sending</ion-label>
<ion-item *ngIf="!criticalError"> <ion-item *ngIf="!criticalError">
<!--<ion-icon ios="ios-arrow-up" md="md-arrow-up" item-left></ion-icon>--> <!--<ion-icon ios="ios-arrow-up" md="md-arrow-up" item-left></ion-icon>-->
<div class="sending-label"> <div class="sending-label">
@ -23,7 +22,15 @@
</div> </div>
</ion-item> </ion-item>
<ion-item *ngIf="!criticalError"> <ion-item *ngIf="!criticalError">
<a [hidden]="!wallet" ng-click="showWalletSelector()"> <div [hidden]="!wallet">
<span translate>To</span>
<div *ngIf="address">
<div>{{address}}</div>
</div>
</div>
</ion-item>
<ion-item *ngIf="!criticalError">
<a [hidden]="!wallet" (click)="showWalletSelector()">
<span translate>From</span> <span translate>From</span>
<div class="wallet" *ngIf="wallet"> <div class="wallet" *ngIf="wallet">
<div>{{wallet.name}}</div> <div>{{wallet.name}}</div>
@ -35,6 +42,5 @@
</a> </a>
</ion-item> </ion-item>
</ion-list> </ion-list>
<div>To: {{address}}</div> <button ion-button full (click)="approve(tx, wallet, statusChangeHandler)" [disabled]="!wallet">Send</button>
<div>Amount: {{amount}}</div>
</ion-content> </ion-content>

View File

@ -124,7 +124,7 @@ export class ConfirmPage {
// Grab stateParams // Grab stateParams
let tx: any = { let tx: any = {
toAmount: parseFloat(this.navParams.data.amount), toAmount: parseFloat(this.navParams.data.amount) * 100000000, // TODO review this line '* 100000000' convert satoshi to BTC
sendMax: this.navParams.data.useSendMax == 'true' ? true : false, sendMax: this.navParams.data.useSendMax == 'true' ? true : false,
toAddress: this.navParams.data.address, toAddress: this.navParams.data.address,
description: this.navParams.data.description, description: this.navParams.data.description,
@ -559,7 +559,7 @@ export class ConfirmPage {
let okText = 'Confirm'; // TODO gettextCatalog let okText = 'Confirm'; // TODO gettextCatalog
let cancelText = 'Cancel'; // TODO gettextCatalog let cancelText = 'Cancel'; // TODO gettextCatalog
this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok: boolean) => { this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok: boolean) => {
return reject(!ok); return resolve(!ok);
}); });
}); });
}; };
@ -580,18 +580,21 @@ export class ConfirmPage {
txid: txp.txid txid: txp.txid
}); });
} }
this.onSuccessConfirm(); // TODO review this line
}).catch((err: any) => { }).catch((err: any) => {
this.setSendError(err); this.setSendError(err);
return; return;
}); });
}; };
confirmTx().then(() => { confirmTx().then((nok: boolean) => {
publishAndSign();
}).catch((nok: boolean) => {
if (nok) { if (nok) {
this.sendStatus = ''; this.sendStatus = '';
return;
} }
publishAndSign();
}).catch((err: any) => {
this.logger.warn(err);
return; return;
}); });
}).catch((err: any) => { }).catch((err: any) => {

View File

@ -16,36 +16,32 @@ export class TxConfirmNotificationProvider {
public checkIfEnabled(txid: string): Promise<any> { public checkIfEnabled(txid: string): Promise<any> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.persistenceProvider.getTxConfirmNotification(txid).then((res: any) => { this.persistenceProvider.getTxConfirmNotification(txid).then((res: any) => {
return resolve(!!res); return resolve(!!res);
}).catch((err: any) => { }).catch((err: any) => {
this.logger.error(err); this.logger.error(err);
return reject(err); return reject(err);
});
}); });
});
}; };
public subscribe(client: any, opts: any): void { public subscribe(client: any, opts: any): void {
client.txConfirmationSubscribe(opts).then((res: any) => { client.txConfirmationSubscribe(opts, (err: any, res: any) => {
if (err) this.logger.error(err);
this.persistenceProvider.setTxConfirmNotification(opts.txid, true).catch((err: any) => { this.persistenceProvider.setTxConfirmNotification(opts.txid, true).catch((err: any) => {
this.logger.error(err); this.logger.error(err);
return; return;
}); });
}).catch((err: any) => {
this.logger.error(err);
return;
}); });
}; };
public unsubscribe(client: any, txId: string): void { public unsubscribe(client: any, txId: string): void {
client.txConfirmationUnsubscribe(txId).then((res: any) => { client.txConfirmationUnsubscribe(txId, (err: any, res: any) => {
if (err) this.logger.error(err);
this.persistenceProvider.removeTxConfirmNotification(txId).catch((err: any) => { this.persistenceProvider.removeTxConfirmNotification(txId).catch((err: any) => {
this.logger.error(err); this.logger.error(err);
return; return;
}); });
}).catch((err: any) => {
this.logger.error(err);
return;
}); });
}; };