I'm trying to use @walletconnect/web3-provider package from npm in ClojureScript, and when I call a function I get an error: TypeError: $jscomp$generator$this.send is not a function
Here is JavaScript code which is used, the problem is in 4th line: return this.send(payload);
:
class WalletConnectProvider extends ProviderEngine {
request(payload) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.send(payload);
});
}
send(payload, callback) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (typeof payload === "string") {
const method = payload;
let params = callback;
if (method === "personal_sign") {
params = utils_1.parsePersonalSign(params);
}
return this.sendAsyncPromise(method, params);
}
payload = Object.assign({ id: utils_1.payloadId(), jsonrpc: "2.0" }, payload);
if (payload.method === "personal_sign") {
payload.params = utils_1.parsePersonalSign(payload.params);
}
if (callback) {
this.sendAsync(payload, callback);
return;
}
return this.sendAsyncPromise(payload.method, payload.params);
});
}
Here is ClojureScript code which causes error described above when I call (.getAccounts (.-eth web3))
(ns woodenstaking-ui.components.connect-btn
(:require [re-frame.core :as rf]
["web3" :as web3-js]
["web3modal" :default web3-modal]
["@walletconnect/web3-provider" :default wallet-connect-provider]
["fortmatic" :as fortmatic]
[cljs.core.async :refer [go]]
[cljs.core.async.interop :refer-macros [<p!]]
(def web3modal
(new web3-modal #js {:cacheProvider false,
:providerOptions #js
{:walletconnect #js
{:package wallet-connect-provider,
:options #js {:infuraId infura-id}}
:fortmatic #js
{:package fortmatic
:options #js {:key fortmatic-key}}}}))
(defn open-modal
[]
(go
(let [provider (<p! (.connect web3modal))
web3 (new web3-js provider)
account (<p! (.getAccounts (.-eth web3)))])))
This code works with MetaMask and Fortmatic web3 providers and fails with WalletConnect only. The same error I get with WalletConnect when I call any smart contract method.