Fix shapeshift, remove the cancelTx. Remove the timer with the getStatus
This commit is contained in:
parent
a295c03b2e
commit
9420b63728
2 changed files with 19 additions and 21 deletions
|
|
@ -487,12 +487,16 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ionicLoading.hide();
|
shapeshiftService.shiftIt(vm.originWallet.coin, toWallet.coin, withdrawalAddr, returnAddr, function onShiftIt(err, shapeshiftData) {
|
||||||
shapeshiftService.shiftIt(vm.originWallet.coin, toWallet.coin, withdrawalAddr, returnAddr, function onShiftIt(shapeshiftData) {
|
if (err && err != null) {
|
||||||
vm.memo = 'ShapeShift Order:\nhttps://www.shapeshift.io/#/status/' + shapeshiftData.orderId;
|
$ionicLoading.hide();
|
||||||
tx.toAddress = shapeshiftData.toAddress;
|
popupService.showAlert(gettextCatalog.getString('Shapeshift Error'), err.toString());
|
||||||
vm.destination.address = toAddress;
|
} else {
|
||||||
vm.destination.kind = 'shapeshift';
|
vm.memo = 'ShapeShift Order:\nhttps://www.shapeshift.io/#/status/' + shapeshiftData.orderId;
|
||||||
|
tx.toAddress = shapeshiftData.toAddress;
|
||||||
|
vm.destination.address = toAddress;
|
||||||
|
vm.destination.kind = 'shapeshift';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ angular.module('copayApp.services').factory('shapeshiftService', function ($http
|
||||||
};
|
};
|
||||||
|
|
||||||
function checkForError(data) {
|
function checkForError(data) {
|
||||||
if (data.error) return true;
|
if (data.err) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,8 +55,7 @@ angular.module('copayApp.services').factory('shapeshiftService', function ($http
|
||||||
root.returnAddress = returnAddress;
|
root.returnAddress = returnAddress;
|
||||||
root.coinIn = coinIn;
|
root.coinIn = coinIn;
|
||||||
root.coinOut = coinOut;
|
root.coinOut = coinOut;
|
||||||
var validate = shapeshiftApiService.ValidateAddress(withdrawalAddress, coinOut);
|
shapeshiftApiService.ValidateAddress(withdrawalAddress, coinOut).then(function (valid) {
|
||||||
validate.then(function (valid) {
|
|
||||||
var tx = ShapeShift();
|
var tx = ShapeShift();
|
||||||
var coin;
|
var coin;
|
||||||
console.log("Starting");
|
console.log("Starting");
|
||||||
|
|
@ -64,7 +63,7 @@ angular.module('copayApp.services').factory('shapeshiftService', function ($http
|
||||||
console.log("Got txData", txData);
|
console.log("Got txData", txData);
|
||||||
if (txData['fixedTxData']) {
|
if (txData['fixedTxData']) {
|
||||||
txData = txData.fixedTxData;
|
txData = txData.fixedTxData;
|
||||||
if (checkForError(txData)) return;
|
if (checkForError(txData)) return cb(txData.err);
|
||||||
//console.log(txData)
|
//console.log(txData)
|
||||||
var coinPair = txData.pair.split('_');
|
var coinPair = txData.pair.split('_');
|
||||||
txData.depositType = coinPair[0].toUpperCase();
|
txData.depositType = coinPair[0].toUpperCase();
|
||||||
|
|
@ -76,20 +75,17 @@ angular.module('copayApp.services').factory('shapeshiftService', function ($http
|
||||||
root.txFixedPending = true;
|
root.txFixedPending = true;
|
||||||
|
|
||||||
} else if (txData['normalTxData']) {
|
} else if (txData['normalTxData']) {
|
||||||
|
|
||||||
txData = txData.normalTxData;
|
txData = txData.normalTxData;
|
||||||
if (checkForError(txData)) return;
|
if (checkForError(txData)) return cb(txData.err);
|
||||||
coin = root.coins[txData.depositType.toUpperCase()].name.toLowerCase();
|
coin = root.coins[txData.depositType.toUpperCase()].name.toLowerCase();
|
||||||
txData.depositQR = coin + ":" + txData.deposit;
|
txData.depositQR = coin + ":" + txData.deposit;
|
||||||
|
|
||||||
} else if (txData['cancelTxData']) {
|
} else if (txData['cancelTxData']) {
|
||||||
|
txData = txData.cancelTxData;
|
||||||
if (checkForError(txData.cancelTxData)) return;
|
if (checkForError(txData)) return cb(txData.err);
|
||||||
if (root.txFixedPending) {
|
if (root.txFixedPending) {
|
||||||
root.txFixedPending = false;
|
root.txFixedPending = false;
|
||||||
}
|
}
|
||||||
root.ShiftState = 'Shift';
|
root.ShiftState = 'Shift';
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
root.depositInfo = txData;
|
root.depositInfo = txData;
|
||||||
//console.log(root.marketData);
|
//console.log(root.marketData);
|
||||||
|
|
@ -101,8 +97,8 @@ angular.module('copayApp.services').factory('shapeshiftService', function ($http
|
||||||
ongoingProcess.set('connectingShapeshift', false);
|
ongoingProcess.set('connectingShapeshift', false);
|
||||||
|
|
||||||
root.ShiftState = 'Cancel';
|
root.ShiftState = 'Cancel';
|
||||||
root.GetStatus();
|
//root.GetStatus();
|
||||||
root.txInterval=$interval(root.GetStatus, 8000);
|
//root.txInterval=$interval(root.GetStatus, 8000);
|
||||||
|
|
||||||
var shapeshiftData = {
|
var shapeshiftData = {
|
||||||
coinIn: coinIn,
|
coinIn: coinIn,
|
||||||
|
|
@ -118,14 +114,12 @@ angular.module('copayApp.services').factory('shapeshiftService', function ($http
|
||||||
ongoingProcess.set('connectingShapeshift', false);
|
ongoingProcess.set('connectingShapeshift', false);
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
cb(shapeshiftData);
|
cb(null, shapeshiftData);
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
function ShapeShift() {
|
function ShapeShift() {
|
||||||
if (root.ShiftState === 'Cancel') return shapeshiftApiService.CancelTx(root);
|
|
||||||
if (parseFloat(root.amount) > 0) return shapeshiftApiService.FixedAmountTx(root);
|
if (parseFloat(root.amount) > 0) return shapeshiftApiService.FixedAmountTx(root);
|
||||||
return shapeshiftApiService.NormalTx(root);
|
return shapeshiftApiService.NormalTx(root);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue