aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/config-manager.js33
-rw-r--r--app/scripts/lib/idStore.js1
-rw-r--r--app/scripts/metamask-controller.js6
3 files changed, 40 insertions, 0 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index c56f52e48..d6d10c8f2 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -332,3 +332,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 3272f2d1a..7ac71e409 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(),
currentFiat: configManager.getCurrentFiat(),
conversionRate: configManager.getConversionRate(),
conversionDate: configManager.getConversionDate(),
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index d21eb5fc1..0b1d40148 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -64,6 +64,8 @@ module.exports = class MetamaskController {
recoverSeed: idStore.recoverSeed.bind(idStore),
// coinbase
buyEth: this.buyEth.bind(this),
+ // shapeshift
+ createShapeShiftTx : this.createShapeShiftTx.bind(this),
}
}
@@ -317,6 +319,10 @@ module.exports = class MetamaskController {
})
}
+ createShapeShiftTx (depositAddress, depositType) {
+ this.configManager.createShapeShiftTx(depositAddress, depositType)
+ }
+
}
function noop () {}