Skip to content

Commit

Permalink
Merge pull request bitpay#9227 from rastajpa/fix/shapeshift-01
Browse files Browse the repository at this point in the history
FIX: Link that explains the reason of authentication and fixes
  • Loading branch information
cmgustavo committed Oct 23, 2018
2 parents c26fe6a + e736a1c commit 5f74c3e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 35 deletions.
3 changes: 3 additions & 0 deletions src/pages/integrations/shapeshift/shapeshift.html
Expand Up @@ -38,6 +38,9 @@ <h4 translate>The Safest, Fastest Asset Exchange on Earth</h4>
to ShapeShift Account' | translate}}</button>
</form>
</div>
<button ion-button clear small color="light" class="bottom-position" (click)="openExternalLink('https://info.shapeshift.io/blog/2018/09/04/introducing-shapeshift-membership/')">
{{'Why does this require authentication?' | translate}} &rarr;
</button>
</div>
</div>

Expand Down
5 changes: 5 additions & 0 deletions src/pages/integrations/shapeshift/shapeshift.scss
Expand Up @@ -11,6 +11,7 @@ page-shapeshift {
font-weight: 300;
margin-bottom: 30px;
}
position: relative;
height: 100%;
display: flex;
flex-direction: column;
Expand All @@ -19,6 +20,10 @@ page-shapeshift {
text-align: center;
background: url('../assets/img/shapeshift/shapeshift_background.jpg') center
center no-repeat #28394d;
.bottom-position {
position: absolute;
bottom: 10px;
}
}
.main-header {
padding: 25px 0;
Expand Down
28 changes: 14 additions & 14 deletions src/pages/integrations/shapeshift/shapeshift.ts
Expand Up @@ -188,7 +188,7 @@ export class ShapeshiftPage {
}

public openShiftModal(ssData) {
let modal = this.modalCtrl.create(ShapeshiftDetailsPage, { ssData });
const modal = this.modalCtrl.create(ShapeshiftDetailsPage, { ssData });

modal.present();

Expand All @@ -207,19 +207,19 @@ export class ShapeshiftPage {

public openAuthenticateWindow(): void {
this.showOauthForm = true;
let oauthUrl = this.shapeshiftProvider.getOauthCodeUrl();
const oauthUrl = this.shapeshiftProvider.getOauthCodeUrl();
this.externalLinkProvider.open(oauthUrl);
}

private openShafeShiftWindow(): void {
let url = 'https://portal.shapeshift.io/me/fox/dashboard';
let optIn = true;
let title = this.translate.instant('Unverified Account');
let message = this.translate.instant(
const url = 'https://portal.shapeshift.io/me/fox/dashboard';
const optIn = true;
const title = this.translate.instant('Unverified Account');
const message = this.translate.instant(
'Do you want to verify your account now?'
);
let okText = this.translate.instant('Verify Account');
let cancelText = this.translate.instant('Cancel');
const okText = this.translate.instant('Verify Account');
const cancelText = this.translate.instant('Cancel');
this.externalLinkProvider
.open(url, optIn, title, message, okText, cancelText)
.then(() => {
Expand All @@ -228,13 +228,13 @@ export class ShapeshiftPage {
}

public openSignupWindow(): void {
let url = this.shapeshiftProvider.getSignupUrl();
let optIn = true;
let title = 'Sign Up for ShapeShift';
let message =
const url = this.shapeshiftProvider.getSignupUrl();
const optIn = true;
const title = 'Sign Up for ShapeShift';
const message =
'This will open shapeshift.io, where you can create an account.';
let okText = 'Go to ShapeShift';
let cancelText = 'Back';
const okText = 'Go to ShapeShift';
const cancelText = 'Back';
this.externalLinkProvider.open(
url,
optIn,
Expand Down
43 changes: 22 additions & 21 deletions src/providers/shapeshift/shapeshift.ts
Expand Up @@ -33,7 +33,7 @@ export class ShapeshiftProvider {
) {
return;
}
var shapeshift = this.appProvider.servicesInfo.shapeshift;
const shapeshift = this.appProvider.servicesInfo.shapeshift;

/*
* Development: 'testnet'
Expand All @@ -59,15 +59,15 @@ export class ShapeshiftProvider {
}

public shift(data, cb) {
let dataSrc = {
const dataSrc = {
withdrawal: data.withdrawal,
pair: data.pair,
returnAddress: data.returnAddress,
apiKey: this.credentials.API_KEY
};

let url = this.credentials.API_URL + '/shift';
let headers = new HttpHeaders({
const url = this.credentials.API_URL + '/shift';
const headers = new HttpHeaders({
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: 'Bearer ' + data.token
Expand All @@ -86,7 +86,7 @@ export class ShapeshiftProvider {
}

public saveShapeshift(data, opts, cb): void {
let network = this.getNetwork();
const network = this.getNetwork();
this.persistenceProvider
.getShapeshift(network)
.then(oldData => {
Expand Down Expand Up @@ -116,7 +116,7 @@ export class ShapeshiftProvider {
}

public getShapeshift(cb) {
let network = this.getNetwork();
const network = this.getNetwork();
this.persistenceProvider
.getShapeshift(network)
.then(ss => {
Expand Down Expand Up @@ -167,7 +167,7 @@ export class ShapeshiftProvider {
}

public getStatus(addr: string, token: string, cb) {
let headers = new HttpHeaders({
const headers = new HttpHeaders({
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: 'Bearer ' + token
Expand Down Expand Up @@ -225,8 +225,8 @@ export class ShapeshiftProvider {
}

public getToken(code, cb) {
let url = this.credentials.HOST + '/oauth/token';
let data = {
const url = this.credentials.HOST + '/oauth/token';
const data = {
grant_type: 'authorization_code',
code,
client_id: this.credentials.CLIENT_ID,
Expand All @@ -245,13 +245,14 @@ export class ShapeshiftProvider {
this._afterTokenReceived(data, cb);
},
data => {
const error =
data && data.error && data.error.error_description
? data.error.error_description
: data.statusText;
this.logger.error(
'ShapeShift: GET Access Token: ERROR ' +
data.status +
'. ' +
data.statusText
'ShapeShift: GET Access Token: ERROR ' + data.status + '. ' + error
);
return cb(data.message);
return cb(error);
}
);
}
Expand Down Expand Up @@ -300,8 +301,8 @@ export class ShapeshiftProvider {
private getAccessTokenDetails(token, cb) {
if (!token) return cb('Invalid Token');

let url = this.credentials.HOST + '/oauth/token/details';
let headers = {
const url = this.credentials.HOST + '/oauth/token/details';
const headers = {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: 'Bearer ' + token
Expand All @@ -327,8 +328,8 @@ export class ShapeshiftProvider {
public getAccount(token, cb) {
if (!token) return cb('Invalid Token');

let url = this.credentials.HOST + '/api/v1/users/me';
let headers = {
const url = this.credentials.HOST + '/api/v1/users/me';
const headers = {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: 'Bearer ' + token
Expand All @@ -352,9 +353,9 @@ export class ShapeshiftProvider {
}

public revokeAccessToken(token) {
let url = this.credentials.HOST + '/oauth/token/revoke';
let data = new HttpParams().set('token', token);
let headers = new HttpHeaders({
const url = this.credentials.HOST + '/oauth/token/revoke';
const data = new HttpParams().set('token', token);
const headers = new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded',
Authorization:
'Basic ' +
Expand Down

0 comments on commit 5f74c3e

Please sign in to comment.