Recommendation #brendon :)
This commit is contained in:
parent
2d6a1528c1
commit
98e6e8ac75
3 changed files with 37 additions and 22 deletions
|
|
@ -3874,3 +3874,23 @@ msgstr ""
|
||||||
#: www/views/includes/incomingDataMenu.html:90
|
#: www/views/includes/incomingDataMenu.html:90
|
||||||
msgid "Open in web browser"
|
msgid "Open in web browser"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/js/services/shapeshift.service.js.html:90
|
||||||
|
msgid "Invalid address"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/js/services/shapeshift.service.js.html:90
|
||||||
|
msgid "Amount is not defined"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/js/services/shapeshift.service.js.html:90
|
||||||
|
msgid "Amount is below the minimun"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/js/services/shapeshift.service.js.html:90
|
||||||
|
msgid "Amount is above the limit"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/js/services/shapeshift.service.js.html:90
|
||||||
|
msgid "Invalid response from Shapeshift"
|
||||||
|
msgstr ""
|
||||||
|
|
@ -525,11 +525,11 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
} else {
|
} else {
|
||||||
|
vm.destination.kind = 'shapeshift';
|
||||||
|
vm.destination.address = toAddress;
|
||||||
|
tx.toAddress = shapeshiftData.toAddress;
|
||||||
vm.memo = 'ShapeShift Order:\nhttps://www.shapeshift.io/#/status/' + shapeshiftData.orderId;
|
vm.memo = 'ShapeShift Order:\nhttps://www.shapeshift.io/#/status/' + shapeshiftData.orderId;
|
||||||
vm.memoExpanded = !!vm.memo;
|
vm.memoExpanded = !!vm.memo;
|
||||||
tx.toAddress = shapeshiftData.toAddress;
|
|
||||||
vm.destination.address = toAddress;
|
|
||||||
vm.destination.kind = 'shapeshift';
|
|
||||||
ongoingProcess.set('connectingShapeshift', false);
|
ongoingProcess.set('connectingShapeshift', false);
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ angular
|
||||||
.module('bitcoincom.services')
|
.module('bitcoincom.services')
|
||||||
.factory('shapeshiftService', shapeshiftService);
|
.factory('shapeshiftService', shapeshiftService);
|
||||||
|
|
||||||
function shapeshiftService(shapeshiftApiService) {
|
function shapeshiftService(shapeshiftApiService, gettext) {
|
||||||
|
|
||||||
var service = {
|
var service = {
|
||||||
// Variables
|
// Variables
|
||||||
|
|
@ -30,13 +30,9 @@ angular
|
||||||
|
|
||||||
function handleError(response, defaultMessage, cb) {
|
function handleError(response, defaultMessage, cb) {
|
||||||
if (!response || !response.error || !response.error.message) {
|
if (!response || !response.error || !response.error.message) {
|
||||||
if (cb) {
|
cb(new Error(defaultMessage));
|
||||||
cb(new Error(defaultMessage));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (cb) {
|
cb(new Error(response.error.message));
|
||||||
cb(new Error(response.error.message));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,17 +47,19 @@ angular
|
||||||
} else {
|
} else {
|
||||||
service.marketData = response;
|
service.marketData = response;
|
||||||
service.rateString = service.marketData.rate.toString() + ' ' + coinOut.toUpperCase() + '/' + coinIn.toUpperCase();
|
service.rateString = service.marketData.rate.toString() + ' ' + coinOut.toUpperCase() + '/' + coinIn.toUpperCase();
|
||||||
if (cb) {
|
cb(null, response);
|
||||||
cb(null, response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function shiftIt(coinIn, coinOut, withdrawalAddress, returnAddress, amount, cb) {
|
function shiftIt(coinIn, coinOut, withdrawalAddress, returnAddress, amount, cb) {
|
||||||
// Test if the amount is correct depending on the min and max
|
// Test if the amount is correct depending on the min and max
|
||||||
if (!amount || typeof amount !== 'number' || amount < service.marketData.minimum || amount > service.marketData.maxLimit) {
|
if (!amount || typeof amount !== 'number') {
|
||||||
cb(new Error('Invalid amount'));
|
cb(new Error(gettext('Amount is not defined'))));
|
||||||
|
} else if (amount < service.marketData.minimum) {
|
||||||
|
cb(new Error(gettext('Amount is below the minimun')));
|
||||||
|
} else if (amount > service.marketData.maxLimit) {
|
||||||
|
cb(new Error(gettext('Amount is above the limit')));
|
||||||
} else {
|
} else {
|
||||||
// Init service data
|
// Init service data
|
||||||
service.withdrawalAddress = withdrawalAddress;
|
service.withdrawalAddress = withdrawalAddress;
|
||||||
|
|
@ -75,20 +73,17 @@ angular
|
||||||
.ValidateAddress(withdrawalAddress, coinOut)
|
.ValidateAddress(withdrawalAddress, coinOut)
|
||||||
.then(function onSuccess(response) {
|
.then(function onSuccess(response) {
|
||||||
if (response && response.isvalid) {
|
if (response && response.isvalid) {
|
||||||
|
|
||||||
// Prepare the transaction shapeshift side
|
// Prepare the transaction shapeshift side
|
||||||
shapeshiftApiService.NormalTx(service).then(function onResponse(response) {
|
shapeshiftApiService.NormalTx(service).then(function onResponse(response) {
|
||||||
// If error, return it
|
// If error, return it
|
||||||
if (!response || response.error) {
|
if (!response || response.error) {
|
||||||
handleError(response, 'Invalid response', cb);
|
handleError(response, gettext('Invalid response from Shapeshift'), cb);
|
||||||
} else {
|
} else {
|
||||||
var txData = response;
|
var txData = response;
|
||||||
|
|
||||||
// If the content is not that it was expected, get back an error
|
// If the content is not that it was expected, get back an error
|
||||||
if (!txData || !txData.orderId || !txData.deposit) {
|
if (!txData || !txData.orderId || !txData.deposit) {
|
||||||
if (cb) {
|
cb(new Error(gettext('Invalid response from Shapeshift')));
|
||||||
cb(new Error('Invalid response'));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Get back the data
|
// Get back the data
|
||||||
service.depositInfo = txData;
|
service.depositInfo = txData;
|
||||||
|
|
@ -105,8 +100,8 @@ angular
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (cb) {
|
} else {
|
||||||
cb(new Error('Invalid address or coin'));
|
cb(new Error(gettext('Invalid address')));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue