access js/window.web3 in advanced-safe way

This commit is contained in:
Martin Klepsch 2018-03-23 13:52:15 +01:00 committed by Tetiana Churikova
parent 3465e66683
commit ec2f87e621
3 changed files with 9 additions and 5 deletions

View File

@ -2,10 +2,14 @@
(:require [reagent.core :as r]
[re-frame.core :as rf]
[clojure.string :as str]
[goog.object :as gobj]
[goog.date.relative]
[goog.i18n.DateTimePatterns :as DateTimePatterns])
(:import (goog.i18n DateTimeFormat)))
(defn web3 []
(gobj/get js/window "web3"))
(defn input [val-ratom props]
(fn []
[:input

View File

@ -12,7 +12,8 @@
[akiroz.re-frame.storage
:as rf-storage
:refer [reg-co-fx!]]
[commiteth.ui-model :as ui-model]))
[commiteth.ui-model :as ui-model]
[commiteth.common :as common]))
(rf-storage/reg-co-fx! :commiteth-sob {:fx :store
@ -49,7 +50,7 @@
(reg-event-fx
:initialize-web3
(fn [{:keys [db]} [_]]
(let [injected-web3 (-> js/window .-web3)
(let [injected-web3 (common/web3)
w3 (when (boolean injected-web3)
(do
(println "Using injected Web3 constructor with current provider")

View File

@ -78,10 +78,9 @@
[:container
[:div.ui.active.inverted.dimmer
[:div.ui.text.loader "Loading"]]]
(let [web3 (.-web3 js/window)
bounties (vals @owner-bounties)]
(let [bounties (vals @owner-bounties)]
[:div.ui.container
(when (nil? web3)
(when (nil? (common/web3))
[:div.ui.warning.message
[:i.warning.icon]
"To sign off claims, please view Status Open Bounty in Status, Mist or Metamask"])