From 7a82da5c88859900999a246de9e99adf0ef7dbac Mon Sep 17 00:00:00 2001 From: Harzu Date: Wed, 1 Nov 2017 18:40:36 +0200 Subject: [PATCH] add numFromHash --- .gitignore | 1 + DApps/TestDApp/client.js | 3 ++- package.json | 2 +- public/static/meta/head_meta.html | 8 ++++---- public/static/meta/manifest.json | 4 ++-- public/static/meta/manifest.webapp | 4 ++-- public/static/meta/yandex-browser-manifest.json | 2 +- src/app.config.js | 3 +++ src/model/DApps/DApps.js | 9 ++++++++- 9 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 89f2f25..917bdd1 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ publisher.json /coverage # production +/public/static/meta /dist /build /builds diff --git a/DApps/TestDApp/client.js b/DApps/TestDApp/client.js index d547180..760a848 100644 --- a/DApps/TestDApp/client.js +++ b/DApps/TestDApp/client.js @@ -18,7 +18,8 @@ window.MyDApp = (function(){ var Roll = function(user_bet, user_num, random_hash){ let profit = -user_bet - const random_num = DCLib.Utils.bigInt(random_hash,16).divmod(65536).remainder.value + const random_num = DCLib.numFromHash(random_hash, 0, 65536) + console.log(random_num) if (user_num > random_num) { profit = (user_bet * (65536 - 1310) / user_num) - user_bet diff --git a/package.json b/package.json index 56e22a3..13d42af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "BankRollerApp", - "version": "0.2.1", + "version": "0.2.2", "description": "Dao.Casino app for bankroller", "author": "Dao Casino ", "repository": { diff --git a/public/static/meta/head_meta.html b/public/static/meta/head_meta.html index 6645cfb..cf36673 100644 --- a/public/static/meta/head_meta.html +++ b/public/static/meta/head_meta.html @@ -1,10 +1,10 @@ - BankRollerApp App + BankRollerApp - + @@ -16,12 +16,12 @@ - - + + diff --git a/public/static/meta/manifest.json b/public/static/meta/manifest.json index 0bb3d9a..9d7faa7 100644 --- a/public/static/meta/manifest.json +++ b/public/static/meta/manifest.json @@ -1,6 +1,6 @@ { - "name": "BankRollerApp App", - "short_name": "BankRollerApp App", + "name": "BankRollerApp", + "short_name": "BankRollerApp", "description": "Dao.Casino app for bankroller", "dir": "auto", "lang": "en-US", diff --git a/public/static/meta/manifest.webapp b/public/static/meta/manifest.webapp index a28bd7a..29e3343 100644 --- a/public/static/meta/manifest.webapp +++ b/public/static/meta/manifest.webapp @@ -1,6 +1,6 @@ { - "version": "0.1.3", - "name": "BankRollerApp App", + "version": "0.2.1", + "name": "BankRollerApp", "description": "Dao.Casino app for bankroller", "icons": { "60": "public/static/meta/firefox_app_60x60.png", diff --git a/public/static/meta/yandex-browser-manifest.json b/public/static/meta/yandex-browser-manifest.json index b91f309..e44656b 100644 --- a/public/static/meta/yandex-browser-manifest.json +++ b/public/static/meta/yandex-browser-manifest.json @@ -1,5 +1,5 @@ { - "version": "0.1.3", + "version": "0.2.1", "api_version": 1, "layout": { "logo": "public/static/meta/yandex-browser-50x50.png", diff --git a/src/app.config.js b/src/app.config.js index a3ef153..bd4bcd1 100644 --- a/src/app.config.js +++ b/src/app.config.js @@ -45,6 +45,9 @@ const networks = { let current_network = 'ropsten' if (process.env.NODE_ENV !== 'server' && window && window.localStorage.current_network) { current_network = window.localStorage.current_network + if(!networks[current_network]){ + current_network = 'ropsten' + } if (current_network=='custom') { networks.custom.rpc_url = window.localStorage.custom_network_url diff --git a/src/model/DApps/DApps.js b/src/model/DApps/DApps.js index e1994de..4c27111 100644 --- a/src/model/DApps/DApps.js +++ b/src/model/DApps/DApps.js @@ -53,9 +53,16 @@ class _DCLib { this.Account = Account this.web3 = web3 this.Utils = Utils - this.DApp = DApp } + + numFromHash(random_hash, min=0, max=100) { + if (min > max) { let c = min; min = max; max = c } + if (min==max) return max + + max++ + return Utils.bigInt(random_hash,16).divmod(max-min).remainder.value + min + } }