Here I would like to allow calling a method of my smart contract from a ethers provider that uses WalletConnect.
I proceed as follows to connect a user to WalletConnect :
(ns my.project
(:require
["@walletconnect/client" :default WalletConnect]
["@walletconnect/qrcode-modal" :as QRCodeModal]
["ethers" :as ethers]))
(defn create-connector []
(let [connector (WalletConnect.
#js{ "bridge" "https://bridge.walletconnect.org"
"qrcodeModal" QRCodeModal})]
(-> (.createSession connector)
(.then
#(.on connector "connect" #(my-function connector DATAS))))))
Once the user is connected I launch the my-function method that calls the contract method:
(defn my-function [connector DATAS]
(let [{:keys [abi address params]} DATAS
provider connector
signer (.getSigner provider)
contract (ethers/Contract. address abi signer)
contract (.connect contract signer)]
(-> (.contract-method contract params)
(.then
#(println "SUCCESS CALL.")))))
The connection to the account goes well, I am redirected correctly on my wallet app (Metamask iOS), however at the time of the call to the contract method nothing happens at the level of my mobile wallet application.
I tried another way to create my provider, in this way but without any results either:
(let [...
provider (ethers/providers.Web3Provider. connector)
...]
...
)
Note that when I try on desktop my call to the method using this provider, it works perfectly, my Metamask extension is well called:
(let [...
provider (ethers/providers.Web3Provider. (object/get js/window "ethereum"))
...]
...
)
What would be useful here is to be able to retrieve the signature from the walletconnect client.