aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2016-11-18 06:27:18 +0800
committerGitHub <noreply@github.com>2016-11-18 06:27:18 +0800
commit37d836fa72c75945d436bd94feadb65aa95d7e5f (patch)
tree975275cc991cdc4f2a0b8decd2db4f429e2f9096 /app
parentb0ccde66f62ae69c5818ddd43e22fb517f8f13e2 (diff)
parent8eb91e89bf62fd835d5e59bd01ac54e0df7c22ed (diff)
downloadtangerine-wallet-browser-37d836fa72c75945d436bd94feadb65aa95d7e5f.tar
tangerine-wallet-browser-37d836fa72c75945d436bd94feadb65aa95d7e5f.tar.gz
tangerine-wallet-browser-37d836fa72c75945d436bd94feadb65aa95d7e5f.tar.bz2
tangerine-wallet-browser-37d836fa72c75945d436bd94feadb65aa95d7e5f.tar.lz
tangerine-wallet-browser-37d836fa72c75945d436bd94feadb65aa95d7e5f.tar.xz
tangerine-wallet-browser-37d836fa72c75945d436bd94feadb65aa95d7e5f.tar.zst
tangerine-wallet-browser-37d836fa72c75945d436bd94feadb65aa95d7e5f.zip
Merge pull request #819 from MetaMask/i791-FixLosingConnection
Increment tx ids to avoid collisions
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/idStore.js2
-rw-r--r--app/scripts/lib/inpage-provider.js11
-rw-r--r--app/scripts/lib/random-id.js9
3 files changed, 11 insertions, 11 deletions
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index 65b8c7029..ccd5efe69 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -7,7 +7,7 @@ const EthQuery = require('eth-query')
const KeyStore = require('eth-lightwallet').keystore
const clone = require('clone')
const extend = require('xtend')
-const createId = require('web3-provider-engine/util/random-id')
+const createId = require('./random-id')
const ethBinToOps = require('eth-bin-to-ops')
const autoFaucet = require('./auto-faucet')
const messageManager = require('./message-manager')
diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js
index 052a8f5fe..f1ba2e0ed 100644
--- a/app/scripts/lib/inpage-provider.js
+++ b/app/scripts/lib/inpage-provider.js
@@ -2,6 +2,7 @@ const Streams = require('mississippi')
const StreamProvider = require('web3-stream-provider')
const ObjectMultiplex = require('./obj-multiplex')
const RemoteStore = require('./remote-store.js').RemoteStore
+const createRandomId = require('./random-id')
module.exports = MetamaskInpageProvider
@@ -119,16 +120,6 @@ 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 eachJsonMessage(payload, transformFn){
if (Array.isArray(payload)) {
return payload.map(transformFn)
diff --git a/app/scripts/lib/random-id.js b/app/scripts/lib/random-id.js
new file mode 100644
index 000000000..3c5ae5600
--- /dev/null
+++ b/app/scripts/lib/random-id.js
@@ -0,0 +1,9 @@
+const MAX = 1000000000
+
+let idCounter = Math.round( Math.random() * MAX )
+function createRandomId() {
+ idCounter = idCounter % MAX
+ return idCounter++
+}
+
+module.exports = createRandomId