aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-11-18 05:49:46 +0800
committerDan Finlay <dan@danfinlay.com>2016-11-18 05:49:46 +0800
commitf229d32442f34859be169e38a42ffecdfb8fc48a (patch)
tree274a190850635a4e3e82b07de7da4f74248e9dea /app/scripts/lib
parent161ff62fdcf6f76f7243a1e865dd0cccbc89121f (diff)
downloadtangerine-wallet-browser-f229d32442f34859be169e38a42ffecdfb8fc48a.tar
tangerine-wallet-browser-f229d32442f34859be169e38a42ffecdfb8fc48a.tar.gz
tangerine-wallet-browser-f229d32442f34859be169e38a42ffecdfb8fc48a.tar.bz2
tangerine-wallet-browser-f229d32442f34859be169e38a42ffecdfb8fc48a.tar.lz
tangerine-wallet-browser-f229d32442f34859be169e38a42ffecdfb8fc48a.tar.xz
tangerine-wallet-browser-f229d32442f34859be169e38a42ffecdfb8fc48a.tar.zst
tangerine-wallet-browser-f229d32442f34859be169e38a42ffecdfb8fc48a.zip
Replace old random-id code with incrementing id generator
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/inpage-provider.js11
-rw-r--r--app/scripts/lib/random-id.js9
2 files changed, 10 insertions, 10 deletions
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