hide faucet when in mainnet, show different in renkeby

This commit is contained in:
Roman Volosovskyi 2017-10-10 14:37:51 +02:00
parent 7133c4a655
commit 50919c8eb8
3 changed files with 90 additions and 58 deletions

View File

@ -493,17 +493,35 @@ var phoneConfig = {
status.response(phoneConfig);
status.command(phoneConfig);
var faucets = [
/*{
name: "Ethereum Ropsten Faucet",
url: "http://faucet.ropsten.be:3001"
},*/
var ropstenNetworkId = 3;
var rinkebyNetworkId = 4;
var ropstenFaucets = [
{
name: "Status Testnet Faucet",
url: "http://46.101.129.137:3001",
}
];
var rinkebyFaucets = [
{
name: "Status Rinkeby Faucet",
url: "not specified yet",
}
];
function getFaucets(networkId) {
if (networkId == ropstenNetworkId) {
return ropstenFaucets;
} else if (networkId == rinkebyNetworkId) {
return rinkebyFaucets;
} else {
return [];
}
}
var faucets = getFaucets(status.ethereumNetworkId);
function faucetSuggestions(params) {
var suggestions = faucets.map(function (entry) {
return status.components.touchable(
@ -535,7 +553,8 @@ function faucetSuggestions(params) {
return {markup: view};
}
status.command({
var faucetCommandConfig =
{
name: "faucet",
title: I18n.t('faucet_title'),
description: I18n.t('faucet_description'),
@ -577,7 +596,12 @@ status.command({
return {markup: error};
}
}
});
}
;
if (faucets.length > 0) {
status.command(faucetCommandConfig);
}
function debugSuggestions(params) {
var suggestions = ["On", "Off"].map(function (entry) {

View File

@ -75,13 +75,18 @@
(hash file))
(defn parse-commands!
[_ [{{:keys [whisper-identity]} :contact
[{:networks/keys [networks]
:keys [network]
:as db}
[{{:keys [whisper-identity]} :contact
:keys [callback]}
file]]
(let [data (local-storage/get-data whisper-identity)
local-storage-js (js-res/local-storage-data data)]
local-storage-js (js-res/local-storage-data data)
network-id (get-in networks [network :raw-config :NetworkId])
ethereum-id-js (js-res/network-id network-id)]
(status/parse-jail
whisper-identity (str local-storage-js file)
whisper-identity (str local-storage-js ethereum-id-js file)
(fn [result]
(let [{:keys [error result]} (json->clj result)]
(log/debug "Parsing commands results: " error result)

View File

@ -49,3 +49,6 @@
(defn local-storage-data [data]
(str "var localStorageData = " (or data "{}") ";"))
(defn network-id [id]
(str "status.ethereumNetworkId = " (or id "null") "; "))