aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorFrankie <frankie.pangilinan@consensys.net>2016-08-26 05:17:29 +0800
committerFrankie <frankie.pangilinan@consensys.net>2016-08-26 05:17:29 +0800
commit11c6c63d76e7533c80b7352e10de3842c1b30ee6 (patch)
tree1d9467c98097bfd9836c4926c33e9048a477c7b0 /app/scripts
parentdf824c0c45f9ae569192b1eb0f3ba2177aad7cc1 (diff)
parentbbb684309e04030dbf288f3e933222b3d27d9b54 (diff)
downloadtangerine-wallet-browser-11c6c63d76e7533c80b7352e10de3842c1b30ee6.tar
tangerine-wallet-browser-11c6c63d76e7533c80b7352e10de3842c1b30ee6.tar.gz
tangerine-wallet-browser-11c6c63d76e7533c80b7352e10de3842c1b30ee6.tar.bz2
tangerine-wallet-browser-11c6c63d76e7533c80b7352e10de3842c1b30ee6.tar.lz
tangerine-wallet-browser-11c6c63d76e7533c80b7352e10de3842c1b30ee6.tar.xz
tangerine-wallet-browser-11c6c63d76e7533c80b7352e10de3842c1b30ee6.tar.zst
tangerine-wallet-browser-11c6c63d76e7533c80b7352e10de3842c1b30ee6.zip
Merge branch 'master' into i#563forgotPassword
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/inpage.js2
-rw-r--r--app/scripts/lib/config-manager.js10
-rw-r--r--app/scripts/lib/inpage-provider.js30
-rw-r--r--app/scripts/metamask-controller.js1
4 files changed, 38 insertions, 5 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index 7c508c66f..28a1223ac 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -54,7 +54,7 @@ var __define
function cleanContextForImports () {
__define = global.define
try {
- delete global.define
+ global.define = undefined
} catch (_) {
console.warn('MetaMask - global.define could not be deleted.')
}
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index 6f5cb3a4a..715efb42e 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -5,6 +5,7 @@ const rp = require('request-promise')
const TESTNET_RPC = MetamaskConfig.network.testnet
const MAINNET_RPC = MetamaskConfig.network.mainnet
+const txLimit = 40
/* The config-manager is a convenience object
* wrapping a pojo-migrator.
@@ -15,6 +16,8 @@ const MAINNET_RPC = MetamaskConfig.network.mainnet
*/
module.exports = ConfigManager
function ConfigManager (opts) {
+ this.txLimit = txLimit
+
// ConfigManager is observable and will emit updates
this._subs = []
@@ -181,6 +184,9 @@ ConfigManager.prototype._saveTxList = function (txList) {
ConfigManager.prototype.addTx = function (tx) {
var transactions = this.getTxList()
+ while (transactions.length > this.txLimit - 1) {
+ transactions.shift()
+ }
transactions.push(tx)
this._saveTxList(transactions)
}
@@ -294,9 +300,10 @@ ConfigManager.prototype.updateConversionRate = function () {
this.setConversionPrice(0)
this.setConversionDate('N/A')
})
+
}
-ConfigManager.prototype.setConversionPrice = function(price) {
+ConfigManager.prototype.setConversionPrice = function (price) {
var data = this.getData()
data.conversionRate = Number(price)
this.setData(data)
@@ -366,4 +373,3 @@ ConfigManager.prototype.createShapeShiftTx = function (depositAddress, depositTy
}
this.setData(data)
}
-
diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js
index b3ed3d9e2..65354cd3d 100644
--- a/app/scripts/lib/inpage-provider.js
+++ b/app/scripts/lib/inpage-provider.js
@@ -33,8 +33,16 @@ function MetamaskInpageProvider (connectionStream) {
})
asyncProvider.on('error', console.error.bind(console))
self.asyncProvider = asyncProvider
- // overwrite own sendAsync method
- self.sendAsync = asyncProvider.sendAsync.bind(asyncProvider)
+ // handle sendAsync requests via asyncProvider
+ self.sendAsync = function(payload, cb){
+ // rewrite request ids
+ var request = jsonrpcMessageTransform(payload, (message) => {
+ message.id = createRandomId()
+ return message
+ })
+ // forward to asyncProvider
+ asyncProvider.sendAsync(request, cb)
+ }
}
MetamaskInpageProvider.prototype.send = function (payload) {
@@ -92,3 +100,21 @@ function remoteStoreWithLocalStorageCache (storageKey) {
return store
}
+
+function createRandomId(){
+ const extraDigits = 3
+ // 13 time digits
+ const datePart = new Date().getTime() * Math.pow(10, extraDigits)
+ // 3 random digits
+ const extraPart = Math.floor(Math.random() * Math.pow(10, extraDigits))
+ // 16 digits
+ return datePart + extraPart
+}
+
+function jsonrpcMessageTransform(payload, transformFn){
+ if (Array.isArray(payload)) {
+ return payload.map(transformFn)
+ } else {
+ return transformFn(payload)
+ }
+} \ No newline at end of file
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 218f1f72a..d53094e43 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -208,6 +208,7 @@ module.exports = class MetamaskController {
newUnsignedMessage (msgParams, cb) {
var state = this.idStore.getState()
if (!state.isUnlocked) {
+ this.idStore.addUnconfirmedMessage(msgParams, cb)
this.opts.unlockAccountMessage()
} else {
this.addUnconfirmedMessage(msgParams, cb)