diff options
author | Chi Kei Chan <chikeichan@gmail.com> | 2017-09-26 05:51:49 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-21 12:51:37 +0800 |
commit | 5cbbb476b3eb7a5fd70b014b2a1a83fea7092b58 (patch) | |
tree | 17e4223f56f3a73944b60be5ec28e8bc98c8eefd /ui/app/actions.js | |
parent | 5aaa2d679b00a7a78338b9b72fa72397ad945b35 (diff) | |
download | tangerine-wallet-browser-5cbbb476b3eb7a5fd70b014b2a1a83fea7092b58.tar tangerine-wallet-browser-5cbbb476b3eb7a5fd70b014b2a1a83fea7092b58.tar.gz tangerine-wallet-browser-5cbbb476b3eb7a5fd70b014b2a1a83fea7092b58.tar.bz2 tangerine-wallet-browser-5cbbb476b3eb7a5fd70b014b2a1a83fea7092b58.tar.lz tangerine-wallet-browser-5cbbb476b3eb7a5fd70b014b2a1a83fea7092b58.tar.xz tangerine-wallet-browser-5cbbb476b3eb7a5fd70b014b2a1a83fea7092b58.tar.zst tangerine-wallet-browser-5cbbb476b3eb7a5fd70b014b2a1a83fea7092b58.zip |
ShapeShift Integration
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r-- | ui/app/actions.js | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index eb066a0e7..6a5a31bfb 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -138,6 +138,7 @@ var actions = { BUY_ETH: 'BUY_ETH', buyEth: buyEth, buyEthView: buyEthView, + buyWithShapeShift, BUY_ETH_VIEW: 'BUY_ETH_VIEW', COINBASE_SUBVIEW: 'COINBASE_SUBVIEW', coinBaseSubview: coinBaseSubview, @@ -977,6 +978,18 @@ function coinShiftRquest (data, marketData) { } } +function buyWithShapeShift (data) { + return dispatch => new Promise((resolve, reject) => { + shapeShiftRequest('shift', { method: 'POST', data}, (response) => { + if (response.error) { + return reject(response.error) + } + background.createShapeShiftTx(response.deposit, response.depositType) + return resolve(response) + }) + }) +} + function showQrView (data, message) { return { type: actions.SHOW_QR_VIEW, @@ -1010,9 +1023,14 @@ function shapeShiftRequest (query, options, cb) { options.method ? method = options.method : method = 'GET' var requestListner = function (request) { - queryResponse = JSON.parse(this.responseText) - cb ? cb(queryResponse) : null - return queryResponse + try { + queryResponse = JSON.parse(this.responseText) + cb ? cb(queryResponse) : null + return queryResponse + } catch (e) { + cb ? cb({error: e}) : null + return e + } } var shapShiftReq = new XMLHttpRequest() |