aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-02-04 13:12:18 +0800
committerDan Finlay <dan@danfinlay.com>2017-02-04 13:12:18 +0800
commit4dc71ed57bab3e8310d37e2fb2a4c495ed3ca5d0 (patch)
treeee2d62c89070c3b8eca913f4b58c260b7aa9f4b3 /app
parent13ee92909cce93b37eec2092757e4aab174a970e (diff)
downloadtangerine-wallet-browser-4dc71ed57bab3e8310d37e2fb2a4c495ed3ca5d0.tar
tangerine-wallet-browser-4dc71ed57bab3e8310d37e2fb2a4c495ed3ca5d0.tar.gz
tangerine-wallet-browser-4dc71ed57bab3e8310d37e2fb2a4c495ed3ca5d0.tar.bz2
tangerine-wallet-browser-4dc71ed57bab3e8310d37e2fb2a4c495ed3ca5d0.tar.lz
tangerine-wallet-browser-4dc71ed57bab3e8310d37e2fb2a4c495ed3ca5d0.tar.xz
tangerine-wallet-browser-4dc71ed57bab3e8310d37e2fb2a4c495ed3ca5d0.tar.zst
tangerine-wallet-browser-4dc71ed57bab3e8310d37e2fb2a4c495ed3ca5d0.zip
Got ShapeShiftController back to working
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/controllers/shapeshift.js19
-rw-r--r--app/scripts/migrations/010.js36
2 files changed, 43 insertions, 12 deletions
diff --git a/app/scripts/lib/controllers/shapeshift.js b/app/scripts/lib/controllers/shapeshift.js
index 6c02dc3eb..bcfe3e14c 100644
--- a/app/scripts/lib/controllers/shapeshift.js
+++ b/app/scripts/lib/controllers/shapeshift.js
@@ -9,8 +9,9 @@ class ShapeshiftController {
constructor (opts = {}) {
const initState = extend({
shapeShiftTxList: [],
- }, opts)
+ }, opts.initState)
this.store = new ObservableStore(initState)
+ this.pollForUpdates()
}
//
@@ -19,19 +20,12 @@ class ShapeshiftController {
getShapeShiftTxList () {
const shapeShiftTxList = this.store.getState().shapeShiftTxList
-
- shapeShiftTxList.forEach((tx) => {
- if (tx.response.status === 'no_deposits') {
- this.updateTx(tx)
- }
- })
- console.dir({shapeShiftTxList})
return shapeShiftTxList
}
getPendingTxs () {
const txs = this.getShapeShiftTxList()
- const pending = txs.filter(tx => tx.response.status !== 'complete')
+ const pending = txs.filter(tx => tx.response && tx.response.status !== 'complete')
return pending
}
@@ -47,7 +41,7 @@ class ShapeshiftController {
}))
.then((results) => {
results.forEach(tx => this.saveTx(tx))
- setTimeout(this.pollForUpdates.bind(this), POLLING_INTERVAL)
+ this.timeout = setTimeout(this.pollForUpdates.bind(this), POLLING_INTERVAL)
})
}
@@ -55,7 +49,9 @@ class ShapeshiftController {
const url = `https://shapeshift.io/txStat/${tx.depositAddress}`
return fetch(url)
.then((response) => {
- tx.response = response.json()
+ return response.json()
+ }).then((json) => {
+ tx.response = json
if (tx.response.status === 'complete') {
tx.time = new Date().getTime()
}
@@ -89,7 +85,6 @@ class ShapeshiftController {
} else {
shapeShiftTxList.push(shapeShiftTx)
}
- console.dir({ shapeShiftTxList })
this.store.updateState({ shapeShiftTxList })
this.pollForUpdates()
diff --git a/app/scripts/migrations/010.js b/app/scripts/migrations/010.js
new file mode 100644
index 000000000..d41c63fcd
--- /dev/null
+++ b/app/scripts/migrations/010.js
@@ -0,0 +1,36 @@
+const version = 10
+
+/*
+
+This migration breaks out the CurrencyController substate
+
+*/
+
+const merge = require('deep-extend')
+
+module.exports = {
+ version,
+
+ migrate: function (versionedData) {
+ versionedData.meta.version = version
+ try {
+ const state = versionedData.data
+ const newState = transformState(state)
+ versionedData.data = newState
+ } catch (err) {
+ console.warn(`MetaMask Migration #${version}` + err.stack)
+ }
+ return Promise.resolve(versionedData)
+ },
+}
+
+function transformState (state) {
+ const newState = merge({}, state, {
+ ShapeShiftController: {
+ shapeShiftTxList: state.shapeShiftTxList || [],
+ },
+ })
+ delete newState.shapeShiftTxList
+
+ return newState
+}