reown-com / appkit

The full stack toolkit to build onchain app UX
https://reown.com/appkit
Apache License 2.0
4.93k stars 1.41k forks source link

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

Open majinbot opened 1 month ago

majinbot commented 1 month ago

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"
}
TudorEsan commented 1 month ago

same issue here

tipanazar commented 1 month ago

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

majinbot commented 1 month ago

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

tipanazar commented 1 month ago

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

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

DobromirKirovLime commented 1 month ago

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!