I’m a ClojureScript beginner and I am trying to connect my app to Metamask wallet.
In the past I successfully did it on a pure JS project with the following code:
import Web3 from "web3";
import detectEthereumProvider from "@metamask/detect-provider";
window.addEventListener("load", async function () {
const provider = await detectEthereumProvider();
if (provider !== window.ethereum) {
reject("Failed to connect");
}
await provider.request({ method: "eth_requestAccounts" });
if (provider) {
const web3 = new Web3(provider);
}
})
So I’m trying to translate this into ClojureScript. Here is what I’ve started to do:
(ns token-stream.views
(:require
[re-frame.core :as re-frame]
[web3 :as web3]
["@metamask/detect-provider" :as detectEthereumProvider]))
(detectEthereumProvider/detectEthereumProvider)
Any idea how I could translate the JS code?
Please note that I want to interop web3.js library (no use of cljs-web3).
Thanks
I used
cljs-web3:Deps:
Code: