Skip to content

Commit

Permalink
feat: enable user to update wallet that connected with wallet connect
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuanatanielnm committed Jan 13, 2025
1 parent edfa817 commit c0d09f7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/graz/src/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { ChainInfo, OfflineAminoSigner } from "@keplr-wallet/types";
import { RECONNECT_SESSION_KEY } from "../constant";
import { grazSessionDefaultValues, useGrazInternalStore, useGrazSessionStore } from "../store";
import type { Maybe } from "../types/core";
import type { Key, WalletType } from "../types/wallet";
import type { Key } from "../types/wallet";
import { WalletType } from "../types/wallet";
import type { ChainId } from "../utils/multi-chain";
import { checkWallet, getWallet, isCapsule, isWalletConnect } from "./wallet";

Expand All @@ -24,6 +25,13 @@ export const connect = async (args?: ConnectArgs): Promise<ConnectResult> => {
try {
const { recentChainIds: recentChains, chains, walletType } = useGrazInternalStore.getState();

const walletConnectInstance = getWallet(WalletType.WALLETCONNECT);
const { disable: walletConnectDisable } = walletConnectInstance;

if (walletConnectDisable) {
void walletConnectDisable();
}

const currentWalletType = args?.walletType || walletType;
const isWalletAvailable = checkWallet(currentWalletType);
if (!isWalletAvailable) {
Expand Down Expand Up @@ -147,6 +155,14 @@ export const connect = async (args?: ConnectArgs): Promise<ConnectResult> => {
export const disconnect = (args?: { chainId?: ChainId }) => {
typeof window !== "undefined" && window.sessionStorage.removeItem(RECONNECT_SESSION_KEY);
const chainId = typeof args?.chainId === "string" ? [args.chainId] : args?.chainId;

const walletConnectInstance = getWallet(WalletType.WALLETCONNECT);
const { disable: walletConnectDisable } = walletConnectInstance;

if (walletConnectDisable) {
void walletConnectDisable();
}

if (chainId) {
const _accounts = useGrazSessionStore.getState().accounts;
chainId.forEach((x) => {
Expand Down

0 comments on commit c0d09f7

Please sign in to comment.