diff options
author | Frankie <frankie.pangilinan@consensys.net> | 2016-08-19 01:40:35 +0800 |
---|---|---|
committer | Frankie <frankie.pangilinan@consensys.net> | 2016-08-19 02:04:28 +0800 |
commit | 752d16f6c072b0dd54eb245209881a25ff06cb8e (patch) | |
tree | 942ce682425b2811c5143028d842e02095712c46 /app | |
parent | 9b1a3fd7f36adfacd46de78f4f60e26eca6edd16 (diff) | |
download | tangerine-wallet-browser-752d16f6c072b0dd54eb245209881a25ff06cb8e.tar tangerine-wallet-browser-752d16f6c072b0dd54eb245209881a25ff06cb8e.tar.gz tangerine-wallet-browser-752d16f6c072b0dd54eb245209881a25ff06cb8e.tar.bz2 tangerine-wallet-browser-752d16f6c072b0dd54eb245209881a25ff06cb8e.tar.lz tangerine-wallet-browser-752d16f6c072b0dd54eb245209881a25ff06cb8e.tar.xz tangerine-wallet-browser-752d16f6c072b0dd54eb245209881a25ff06cb8e.tar.zst tangerine-wallet-browser-752d16f6c072b0dd54eb245209881a25ff06cb8e.zip |
WIP: ShapeShift tx
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/config-manager.js | 33 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 1 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 6 |
3 files changed, 40 insertions, 0 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index d14d3afc3..8e59d02f3 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -284,3 +284,36 @@ ConfigManager.prototype.getShouldntShowWarning = function () { var data = this.getData() return ('isEthConfirmed' in data) && data.isEthConfirmed } + +ConfigManager.prototype.getShapeShiftTxList = function () { + var data = this.getData() + var shapeShiftTxList = data.shapeShiftTxList ? data.shapeShiftTxList : [] + shapeShiftTxList.forEach((tx) => { + if (tx.response.status !== 'complete'){ + var requestListner = function (request) { + tx.response = JSON.parse(this.responseText) + if (tx.status === 'complete') { + tx.completeTime = new Date().getTime() + } + } + + var shapShiftReq = new XMLHttpRequest() + shapShiftReq.addEventListener('load', requestListner) + shapShiftReq.open('GET', `https://shapeshift.io/txStat/${tx.depositAddress}`, true) + shapShiftReq.send() + } + }) + return shapeShiftTxList +} + +ConfigManager.prototype.createShapeShiftTx = function (depositAddress, depositType) { + var data = this.getData() + + var shapeShiftTx = {depositAddress, depositType, key: 'shapeshift', time: new Date().getTime(), response: {}} + if(!data.shapeShiftTxList) { + data.shapeShiftTxList = [shapeShiftTx] + } else { + data.shapeShiftTxList.push(shapeShiftTx) + } + this.setData(data) +} diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index f63e03ec6..55d5e5e61 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -100,6 +100,7 @@ IdentityStore.prototype.getState = function () { unconfMsgs: messageManager.unconfirmedMsgs(), messages: messageManager.getMsgList(), selectedAddress: configManager.getSelectedAccount(), + shapeShiftTxList: configManager.getShapeShiftTxList(), })) } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 2c141a402..d34f594d7 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -59,6 +59,8 @@ module.exports = class MetamaskController { recoverSeed: idStore.recoverSeed.bind(idStore), // coinbase buyEth: this.buyEth.bind(this), + // shapeshift + createShapeShiftTx : this.createShapeShiftTx.bind(this), } } @@ -287,6 +289,10 @@ module.exports = class MetamaskController { }) } + createShapeShiftTx (depositAddress, depositType) { + this.configManager.createShapeShiftTx(depositAddress, depositType) + } + } function noop () {} |