web3modal icon indicating copy to clipboard operation
web3modal copied to clipboard

[bug] disconnect function is documented but missing in AppKit actions

Open majinbot opened this issue 1 year ago โ€ข 5 comments

Link to minimal reproducible example

n/a

Summary

In the AppKit docs for vanilla JS installs, the disconnect function is documented among the modal Actions here: https://docs.reown.com/appkit/javascript/core/actions#disconnect

However, there is no such API in the code for the latest AppKit release (1.0.2). How do we disconnect connected wallets?

List of related npm package versions

"dependencies": {
	"@coinbase/wallet-sdk": "^4.0.4",
	"@reown/appkit": "^1.0.2",
	"@reown/appkit-adapter-ethers": "^1.0.2",
	"ethers": "^6.13.2"
}

majinbot avatar Sep 20 '24 10:09 majinbot

same issue here

TudorEsan avatar Sep 22 '24 10:09 TudorEsan

Found hook in their repo:

image

You can paste this hook to your project and then you can use this hook as it supposed to by docs.

// contexts/web3modal.tsx
import { EthersAdapter } from "@reown/appkit-adapter-ethers";

export const ethersAdapter = new EthersAdapter();
// rest of your code...
// useDisconnect.tsx
import { ethersAdapter } from "@/contexts/web3Modal";

export function useDisconnect() {
  async function disconnect() {
    await ethersAdapter.disconnect();
  }

  return {
    disconnect,
  };
}

ps: probably this requires additional tests but works fine for me so far

tipanazar avatar Sep 24 '24 16:09 tipanazar

Gtk, but Vue and .tsx are not vanilla JS ๐Ÿ˜…. I am using SvelteKit more precisely

majinbot avatar Sep 25 '24 09:09 majinbot

Gtk, but Vue and .tsx are not vanilla JS ๐Ÿ˜…. I am using SvelteKit more precisely

Oops, maybe I commented in the wrong thread๐Ÿ˜ฌ๐Ÿ˜„

tipanazar avatar Sep 25 '24 10:09 tipanazar

Found hook in their repo:

image ### You can paste this hook to your project and then you can use this hook as it supposed to by docs. ``` // contexts/web3modal.tsx import { EthersAdapter } from "@reown/appkit-adapter-ethers";

export const ethersAdapter = new EthersAdapter(); // rest of your code...


// useDisconnect.tsx import { ethersAdapter } from "@/contexts/web3Modal";

export function useDisconnect() { async function disconnect() { await ethersAdapter.disconnect(); }

return { disconnect, }; }


ps: probably this requires additional tests but works fine for me so far

Thanks mate, this works!

DobromirKirovLime avatar Oct 01 '24 15:10 DobromirKirovLime

any update for this issue? web3Modal.adapter?.connectionControllerClient?.disconnect() is not working in vanilla js. web3Modal.adpater is still undefined after walletconnect connected.

linxuanweb avatar Nov 25 '24 08:11 linxuanweb

now is exposed :)

image

rtomas avatar Dec 11 '24 18:12 rtomas