mirror of
https://github.com/status-im/status-react.git
synced 2025-02-02 06:07:33 +00:00
hide faucet when in mainnet, show different in renkeby
This commit is contained in:
parent
7133c4a655
commit
50919c8eb8
@ -493,17 +493,35 @@ var phoneConfig = {
|
|||||||
status.response(phoneConfig);
|
status.response(phoneConfig);
|
||||||
status.command(phoneConfig);
|
status.command(phoneConfig);
|
||||||
|
|
||||||
var faucets = [
|
var ropstenNetworkId = 3;
|
||||||
/*{
|
var rinkebyNetworkId = 4;
|
||||||
name: "Ethereum Ropsten Faucet",
|
|
||||||
url: "http://faucet.ropsten.be:3001"
|
var ropstenFaucets = [
|
||||||
},*/
|
|
||||||
{
|
{
|
||||||
name: "Status Testnet Faucet",
|
name: "Status Testnet Faucet",
|
||||||
url: "http://46.101.129.137:3001",
|
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) {
|
function faucetSuggestions(params) {
|
||||||
var suggestions = faucets.map(function (entry) {
|
var suggestions = faucets.map(function (entry) {
|
||||||
return status.components.touchable(
|
return status.components.touchable(
|
||||||
@ -535,49 +553,55 @@ function faucetSuggestions(params) {
|
|||||||
return {markup: view};
|
return {markup: view};
|
||||||
}
|
}
|
||||||
|
|
||||||
status.command({
|
var faucetCommandConfig =
|
||||||
name: "faucet",
|
{
|
||||||
title: I18n.t('faucet_title'),
|
name: "faucet",
|
||||||
description: I18n.t('faucet_description'),
|
title: I18n.t('faucet_title'),
|
||||||
color: "#7099e6",
|
description: I18n.t('faucet_description'),
|
||||||
registeredOnly: true,
|
color: "#7099e6",
|
||||||
params: [{
|
registeredOnly: true,
|
||||||
name: "url",
|
params: [{
|
||||||
type: status.types.TEXT,
|
name: "url",
|
||||||
suggestions: faucetSuggestions,
|
type: status.types.TEXT,
|
||||||
placeholder: I18n.t('faucet_placeholder')
|
suggestions: faucetSuggestions,
|
||||||
}],
|
placeholder: I18n.t('faucet_placeholder')
|
||||||
preview: function (params) {
|
}],
|
||||||
return {
|
preview: function (params) {
|
||||||
markup: status.components.text(
|
return {
|
||||||
{},
|
markup: status.components.text(
|
||||||
params.url
|
{},
|
||||||
)
|
params.url
|
||||||
};
|
)
|
||||||
},
|
};
|
||||||
shortPreview: function (params) {
|
},
|
||||||
return {
|
shortPreview: function (params) {
|
||||||
markup: status.components.text(
|
return {
|
||||||
{},
|
markup: status.components.text(
|
||||||
I18n.t('faucet_title') + ": " + params.url
|
{},
|
||||||
)
|
I18n.t('faucet_title') + ": " + params.url
|
||||||
};
|
)
|
||||||
},
|
};
|
||||||
validator: function (params, context) {
|
},
|
||||||
var f = faucets.map(function (entry) {
|
validator: function (params, context) {
|
||||||
return entry.url;
|
var f = faucets.map(function (entry) {
|
||||||
});
|
return entry.url;
|
||||||
|
});
|
||||||
|
|
||||||
if (f.indexOf(params.url) == -1) {
|
if (f.indexOf(params.url) == -1) {
|
||||||
var error = status.components.validationMessage(
|
var error = status.components.validationMessage(
|
||||||
I18n.t('faucet_incorrect_title'),
|
I18n.t('faucet_incorrect_title'),
|
||||||
I18n.t('faucet_incorrect_description')
|
I18n.t('faucet_incorrect_description')
|
||||||
);
|
);
|
||||||
|
|
||||||
return {markup: error};
|
return {markup: error};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
;
|
||||||
|
|
||||||
|
if (faucets.length > 0) {
|
||||||
|
status.command(faucetCommandConfig);
|
||||||
|
}
|
||||||
|
|
||||||
function debugSuggestions(params) {
|
function debugSuggestions(params) {
|
||||||
var suggestions = ["On", "Off"].map(function (entry) {
|
var suggestions = ["On", "Off"].map(function (entry) {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
[status-im.i18n :refer [label]]
|
[status-im.i18n :refer [label]]
|
||||||
[status-im.utils.homoglyph :as h]
|
[status-im.utils.homoglyph :as h]
|
||||||
[status-im.utils.js-resources :as js-res]
|
[status-im.utils.js-resources :as js-res]
|
||||||
[status-im.utils.random :as random]
|
[status-im.utils.random :as random]
|
||||||
[status-im.bots.constants :as bots-constants]
|
[status-im.bots.constants :as bots-constants]
|
||||||
[status-im.utils.datetime :as time]
|
[status-im.utils.datetime :as time]
|
||||||
[status-im.data-store.local-storage :as local-storage]
|
[status-im.data-store.local-storage :as local-storage]
|
||||||
@ -75,21 +75,26 @@
|
|||||||
(hash file))
|
(hash file))
|
||||||
|
|
||||||
(defn parse-commands!
|
(defn parse-commands!
|
||||||
[_ [{{:keys [whisper-identity]} :contact
|
[{:networks/keys [networks]
|
||||||
:keys [callback]}
|
:keys [network]
|
||||||
file]]
|
:as db}
|
||||||
|
[{{:keys [whisper-identity]} :contact
|
||||||
|
:keys [callback]}
|
||||||
|
file]]
|
||||||
(let [data (local-storage/get-data whisper-identity)
|
(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
|
(status/parse-jail
|
||||||
whisper-identity (str local-storage-js file)
|
whisper-identity (str local-storage-js ethereum-id-js file)
|
||||||
(fn [result]
|
(fn [result]
|
||||||
(let [{:keys [error result]} (json->clj result)]
|
(let [{:keys [error result]} (json->clj result)]
|
||||||
(log/debug "Parsing commands results: " error result)
|
(log/debug "Parsing commands results: " error result)
|
||||||
(if error
|
(if error
|
||||||
(dispatch [::loading-failed! whisper-identity ::error-in-jail error])
|
(dispatch [::loading-failed! whisper-identity ::error-in-jail error])
|
||||||
(do
|
(do
|
||||||
(dispatch [::add-commands whisper-identity file result])
|
(dispatch [::add-commands whisper-identity file result])
|
||||||
(when callback (callback)))))))))
|
(when callback (callback)))))))))
|
||||||
|
|
||||||
(defn validate-hash
|
(defn validate-hash
|
||||||
[db [_ file]]
|
[db [_ file]]
|
||||||
|
@ -49,3 +49,6 @@
|
|||||||
|
|
||||||
(defn local-storage-data [data]
|
(defn local-storage-data [data]
|
||||||
(str "var localStorageData = " (or data "{}") ";"))
|
(str "var localStorageData = " (or data "{}") ";"))
|
||||||
|
|
||||||
|
(defn network-id [id]
|
||||||
|
(str "status.ethereumNetworkId = " (or id "null") "; "))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user