diff --git a/externs/web3-externs.js b/externs/web3-externs.js new file mode 100644 index 0000000..4600afa --- /dev/null +++ b/externs/web3-externs.js @@ -0,0 +1,12 @@ + +/* +externs for web3 injected into js context. needed for things to work with advanced cljs compilation + +TODO: probably not a good idea to maintain this manually in the long run*/ + +var web3 = { + eth: { + accounts: [], + sendTransaction: function() {} + } +}; diff --git a/project.clj b/project.clj index 82960ae..4fa828d 100644 --- a/project.clj +++ b/project.clj @@ -9,7 +9,7 @@ [secretary "1.2.3"] [reagent-utils "0.2.0"] [reagent "0.6.0"] - [org.clojure/clojurescript "1.9.456" :scope "provided"] + [org.clojure/clojurescript "1.9.473"] [org.clojure/clojure "1.8.0"] [selmer "1.10.5"] [markdown-clj "0.9.93"] @@ -84,12 +84,13 @@ {:source-paths ["src/cljc" "src/cljs" "env/prod/cljs"] :compiler {:output-to "target/cljsbuild/public/js/app.js" - :externs ["react/externs/react.js"] + :externs ["externs/web3-externs.js"] :optimizations :advanced :pretty-print false :closure-defines {goog.DEBUG false} :closure-warnings - {:externs-validation :off :non-standard-jsdoc :off}}}}} + {:externs-validation :off + :non-standard-jsdoc :off}}}}} :aot :all diff --git a/src/cljs/commiteth/update_address.cljs b/src/cljs/commiteth/update_address.cljs index a6183ad..14e5a47 100644 --- a/src/cljs/commiteth/update_address.cljs +++ b/src/cljs/commiteth/update_address.cljs @@ -8,35 +8,35 @@ (defn update-address-page [] (let [user (rf/subscribe [:user]) updating-address (rf/subscribe [:get-in [:updating-address]]) - web3 (.-web3 js/window) - web3-accounts (into [] (when-not (nil? web3) (-> web3 - .-eth - .-accounts - js->clj))) address (r/atom @(rf/subscribe [:get-in [:user :address]]))] (fn [] - (println "web3-accounts" web3-accounts) - [:div.ui.container.grid - [:div.ui.form.sixteen.wide.column - [:h3 "Update address"] - [:p "Placeholder text for explaining what an Ethereum address is."] - [:div.field - (if-not (empty? web3-accounts) - [dropdown {:class "address-input"} "Select address" - address - (into [] - (for [acc web3-accounts] - acc))] - [:div.ui.input.address-input - [input address {:placeholder "0x0000000000000000000000000000000000000000" - :auto-complete "off" - :auto-correct "off" - :spell-check "false" - :max-length 42}]])] - [:button.ui.button (merge {:on-click - #(rf/dispatch [:save-user-address - (:id @user) - @address])} - (when @updating-address - {:class "busy loading"})) - "Update"]]]))) + (let [web3 (.-web3 js/window) + web3-accounts (into [] (when-not (nil? web3) (-> web3 + .-eth + .-accounts + js->clj)))] + (println "web3-accounts" web3-accounts) + [:div.ui.container.grid + [:div.ui.form.sixteen.wide.column + [:h3 "Update address"] + [:p "Placeholder text for explaining what an Ethereum address is."] + [:div.field + (if-not (empty? web3-accounts) + [dropdown {:class "address-input"} "Select address" + address + (into [] + (for [acc web3-accounts] + acc))] + [:div.ui.input.address-input + [input address {:placeholder "0x0000000000000000000000000000000000000000" + :auto-complete "off" + :auto-correct "off" + :spell-check "false" + :max-length 42}]])] + [:button.ui.button (merge {:on-click + #(rf/dispatch [:save-user-address + (:id @user) + @address])} + (when @updating-address + {:class "busy loading"})) + "Update"]]]))))