feat: shapeshift terms and some fixes

This commit is contained in:
Gabriel Masclef 2018-01-11 16:43:14 -03:00
parent 0929866673
commit a6ac577fa3
No known key found for this signature in database
GPG Key ID: DD6D7EAADE12280D
9 changed files with 106 additions and 14 deletions

View File

@ -91,7 +91,17 @@
</ion-item> </ion-item>
<ion-item> <ion-item>
Limit Deposit Min
<ion-note item-end>
<span *ngIf="!limit">...</span>
<span *ngIf="limit">
{{limit.minimum}} {{fromWallet.coin | uppercase}}
</span>
</ion-note>
</ion-item>
<ion-item>
Deposit Max
<ion-note item-end> <ion-note item-end>
<span *ngIf="!limit">...</span> <span *ngIf="!limit">...</span>
<span *ngIf="limit"> <span *ngIf="limit">
@ -101,20 +111,32 @@
</ion-item> </ion-item>
<ion-item> <ion-item>
Minimum Miner fee
<ion-note item-end> <ion-note item-end>
<span *ngIf="!limit">...</span> <span *ngIf="!limit">...</span>
<span *ngIf="limit"> <span *ngIf="limit">
{{limit.min}} {{fromWallet.coin | uppercase}} {{limit.minerFee}} {{fromWallet.coin | uppercase}}
</span> </span>
</ion-note> </ion-note>
</ion-item> </ion-item>
</ion-list> </ion-list>
<div class="agree-to-terms">
<ion-item color="light" text-wrap>
<ion-checkbox class="check" [(ngModel)]="termsAccepted"></ion-checkbox>
</ion-item>
<div class="terms">
<p translate>
I agree to the
<a (click)="openTerms()"> Terms </a>
and certify that I am the beneficial owner of the input assets and the destination address.
</p>
</div>
</div>
<div class="buttons-container"> <div class="buttons-container">
<!-- TODO: noLowFee --> <!-- TODO: noLowFee -->
<button ion-button type="button" *ngIf="fromWallets.length > 0 && toWallets.length > 0" [disabled]="!fromWallet || !toWallet" <button ion-button type="button" *ngIf="fromWallets.length > 0 && toWallets.length > 0" [disabled]="!fromWallet || !toWallet || !termsAccepted"
(click)="setAmount()"> (click)="setAmount()">
Continue Continue
</button> </button>

View File

@ -20,4 +20,31 @@ page-shapeshift-shift {
display: block; display: block;
} }
} }
.agree-to-terms {
position: relative;
ion-item {
height: 6rem;
.check {
margin: 9px 15px 9px 4px !important;
}
}
.terms {
display: flex;
align-items: center;
height: 6rem;
position: absolute;
top: 0;
left: 5rem;
padding: 0rem;
margin: 0rem;
p {
padding-right: 1rem;
font-size: 12px;
}
a {
font-weight: bold;
cursor: pointer;
}
}
}
} }

View File

@ -7,6 +7,7 @@ import * as _ from 'lodash';
import { AmountPage } from './../../../send/amount/amount'; import { AmountPage } from './../../../send/amount/amount';
// Providers // Providers
import { ExternalLinkProvider } from '../../../../providers/external-link/external-link';
import { PopupProvider } from '../../../../providers/popup/popup'; import { PopupProvider } from '../../../../providers/popup/popup';
import { ProfileProvider } from '../../../../providers/profile/profile'; import { ProfileProvider } from '../../../../providers/profile/profile';
import { ShapeshiftProvider } from '../../../../providers/shapeshift/shapeshift'; import { ShapeshiftProvider } from '../../../../providers/shapeshift/shapeshift';
@ -29,9 +30,11 @@ export class ShapeshiftShiftPage {
public network: string; public network: string;
public fromWalletSelectorTitle: string; public fromWalletSelectorTitle: string;
public toWalletSelectorTitle: string; public toWalletSelectorTitle: string;
public termsAccepted: boolean;
constructor( constructor(
private events: Events, private events: Events,
private externalLinkProvider: ExternalLinkProvider,
private logger: Logger, private logger: Logger,
private navCtrl: NavController, private navCtrl: NavController,
private popupProvider: PopupProvider, private popupProvider: PopupProvider,
@ -42,6 +45,7 @@ export class ShapeshiftShiftPage {
this.walletsBch = []; this.walletsBch = [];
this.fromWalletSelectorTitle = 'From'; this.fromWalletSelectorTitle = 'From';
this.toWalletSelectorTitle = 'To'; this.toWalletSelectorTitle = 'To';
this.termsAccepted = false;
this.network = this.shapeshiftProvider.getNetwork(); this.network = this.shapeshiftProvider.getNetwork();
this.walletsBtc = this.profileProvider.getWallets({ this.walletsBtc = this.profileProvider.getWallets({
@ -62,8 +66,9 @@ export class ShapeshiftShiftPage {
} }
this.fromWallets = _.filter(this.walletsBtc.concat(this.walletsBch), (w: any) => { this.fromWallets = _.filter(this.walletsBtc.concat(this.walletsBch), (w: any) => {
// Available balance and 1-signature wallet // Available cached funds
return w.status.balance.availableAmount > 0 && w.credentials.m == 1; let hasCachedFunds = w.cachedBalance.match(/0\.00 /gi) ? false : true;
return hasCachedFunds;
}); });
this.onFromWalletSelect(this.fromWallets[0]); this.onFromWalletSelect(this.fromWallets[0]);
@ -73,6 +78,11 @@ export class ShapeshiftShiftPage {
this.logger.info('ionViewDidLoad ShapeshiftShiftPage'); this.logger.info('ionViewDidLoad ShapeshiftShiftPage');
} }
public openTerms() {
let url = "https://info.shapeshift.io/sites/default/files/ShapeShift_Terms_Conditions%20v1.1.pdf";
this.externalLinkProvider.open(url);
}
private showErrorAndBack(title: string, msg: any): void { private showErrorAndBack(title: string, msg: any): void {
title = title ? title : 'Error'; // TODO: gettextCatalog title = title ? title : 'Error'; // TODO: gettextCatalog
this.logger.error(msg); this.logger.error(msg);
@ -90,7 +100,7 @@ export class ShapeshiftShiftPage {
this.shapeshiftProvider.getRate(pair, (err: any, rate: number) => { this.shapeshiftProvider.getRate(pair, (err: any, rate: number) => {
this.rate = rate; this.rate = rate;
}); });
this.shapeshiftProvider.getLimit(pair, (err: any, limit: any) => { this.shapeshiftProvider.getMarketInfo(pair, (err: any, limit: any) => {
this.limit = limit; this.limit = limit;
}); });
} }
@ -105,6 +115,9 @@ export class ShapeshiftShiftPage {
} }
public setAmount(): void { public setAmount(): void {
if (!this.termsAccepted) {
return;
}
this.navCtrl.push(AmountPage, { this.navCtrl.push(AmountPage, {
nextPage: 'ShapeshiftConfirmPage', nextPage: 'ShapeshiftConfirmPage',
fixedUnit: true, fixedUnit: true,
@ -113,7 +126,7 @@ export class ShapeshiftShiftPage {
toWalletId: this.toWallet.id, toWalletId: this.toWallet.id,
currency: this.fromWallet.coin.toUpperCase(), currency: this.fromWallet.coin.toUpperCase(),
shiftMax: this.limit.limit + ' ' + this.fromWallet.coin.toUpperCase(), shiftMax: this.limit.limit + ' ' + this.fromWallet.coin.toUpperCase(),
shiftMin: this.limit.min + ' ' + this.fromWallet.coin.toUpperCase() shiftMin: this.limit.minimum + ' ' + this.fromWallet.coin.toUpperCase()
}); });
} }

View File

@ -31,7 +31,15 @@
</div> </div>
<ion-list class="shift"> <ion-list class="shift">
<button ion-item no-low-fee (click)="goTo('Shift')"> <ion-item-divider class="help" color="light">
<div>
<span>Having problems with a ShapeShift?</span>
<a (click)="openExternalLink('https://shapeshift.zendesk.com/hc/en-us/requests/new')">
Contact the ShapeShift support team.
</a>
</div>
</ion-item-divider>
<button class="shift-btn" ion-item no-low-fee (click)="goTo('Shift')">
<img src="assets/img/shapeshift/icon-shapeshift.svg"> <img src="assets/img/shapeshift/icon-shapeshift.svg">
<span>Shift</span> <span>Shift</span>
</button> </button>
@ -58,4 +66,4 @@
</div> </div>
</button> </button>
</ion-list> </ion-list>
</ion-content> </ion-content>

View File

@ -49,9 +49,17 @@ page-shapeshift {
img { img {
width: 30px; width: 30px;
} }
ion-label { &-btn .label {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.help .label {
text-align: center;
white-space: normal;
font-size: 12px;
span {
margin-right: 0.6rem;
}
}
} }
} }

View File

@ -41,7 +41,7 @@
<span translate>Amount</span> <span translate>Amount</span>
</div> </div>
<div *ngIf="shiftMin && shiftMax"> <div *ngIf="shiftMin && shiftMax" class="shapeshift-values">
<div>Min: {{shiftMin}}</div> <div>Min: {{shiftMin}}</div>
<div>Max: {{shiftMax}}</div> <div>Max: {{shiftMax}}</div>
</div> </div>
@ -92,4 +92,4 @@
</div> </div>
</div> </div>
</div> </div>
</ion-content> </ion-content>

View File

@ -4,6 +4,9 @@ page-amount {
padding: 18px 16px 0; padding: 18px 16px 0;
font-size: 18px; font-size: 18px;
} }
.shapeshift-values {
padding: 1.7rem;
}
.amount-content { .amount-content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -20,6 +20,7 @@ export class OnGoingProcessProvider {
'calculatingFee': 'Calculating fee', 'calculatingFee': 'Calculating fee',
'connectingCoinbase': 'Connecting to Coinbase...', 'connectingCoinbase': 'Connecting to Coinbase...',
'connectingGlidera': 'Connecting to Glidera...', 'connectingGlidera': 'Connecting to Glidera...',
'connectingShapeshift': 'Connecting to Shapeshift...',
'creatingTx': 'Creating transaction', 'creatingTx': 'Creating transaction',
'creatingWallet': 'Creating Wallet...', 'creatingWallet': 'Creating Wallet...',
'deletingWallet': 'Deleting Wallet...', 'deletingWallet': 'Deleting Wallet...',

View File

@ -134,6 +134,16 @@ export class ShapeshiftProvider {
}); });
} }
public getMarketInfo(pair: string, cb) {
this.http.get(this.credentials.API_URL + '/marketinfo/' + pair).subscribe((data: any) => {
this.logger.info('Shapeshift MARKET INFO: SUCCESS');
return cb(null, data);
}, (data: any) => {
this.logger.error('Shapeshift MARKET INFO ERROR', data.error.message);
return cb(data);
});
}
public getStatus(addr: string, cb) { public getStatus(addr: string, cb) {
this.http.get(this.credentials.API_URL + '/txStat/' + addr).subscribe((data: any) => { this.http.get(this.credentials.API_URL + '/txStat/' + addr).subscribe((data: any) => {
this.logger.info('Shapeshift STATUS: SUCCESS'); this.logger.info('Shapeshift STATUS: SUCCESS');