Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Fix Web3 connected detection
Browse files Browse the repository at this point in the history
Getting to know if Web3 provider (this case WebsocketProvider) is
connected, needs different property:
https://github.com/ChainSafe/web3.js/blob/0d3805093558722f50f25edf40f72c8f50026c40/packages/web3-providers-ws/src/index.js#L82-L84
  • Loading branch information
madis committed Aug 30, 2022
1 parent 221bb84 commit eda0572
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 242 deletions.
12 changes: 6 additions & 6 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{:paths ["src" "test"]
{:paths ["src"]
:mvn/repos {"central" {:url "https://repo1.maven.org/maven2/"}
"clojars" {:url "https://clojars.org/repo"}}
:deps
{thheller/shadow-cljs {:mvn/version "2.18.0"}
{thheller/shadow-cljs {:mvn/version "2.19.8"}
org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/clojurescript {:mvn/version "1.11.4"}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20220301"}
org.clojure/clojurescript {:mvn/version "1.11.60"}

camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.0"}
district0x/bignumber {:mvn/version "1.0.3"}
binaryage/oops {:mvn/version "0.7.2"}}
:aliases
{:dev
{:extra-deps
{:extra-paths ["test"]
:extra-deps
{org.clojure/data.json {:mvn/version "0.2.6"},
org.clojure/clojure {:mvn/version "1.10.3"},
org.clojure/clojure {:mvn/version "1.11.1"}
day8.re-frame/test {:mvn/version "0.1.5"},
day8.re-frame/http-fx {:mvn/version "0.1.4"},
day8.re-frame/async-flow-fx {:mvn/version "0.0.8"},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"karma": "^6.3.17",
"karma-chrome-launcher": "^3.1.1",
"karma-cljs-test": "^0.1.0",
"shadow-cljs": "2.19.3",
"shadow-cljs": "2.19.8",
"web3": "1.7.3"
}
}
5 changes: 4 additions & 1 deletion src/cljs_web3_next/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
(ocall+ provider "extend" (web3-helpers/cljkk->js {:property property
:methods methods})))
(defn connected? [provider]
(oget provider "currentProvider" "isConnected"))
(oget provider "currentProvider" "connected"))

(defn disconnect [provider]
(ocall (oget provider "currentProvider") "disconnect"))

(defn connect [provider]
(ocall (oget provider "currentProvider") "connect"))

; MetaMask provider only offers 'connect' and 'disconnect' events
; https://docs.metamask.io/guide/ethereum-provider.html#events
(defn on-connect [provider & [callback]]
Expand Down
Loading

0 comments on commit eda0572

Please sign in to comment.