@solana-wallets/core
Advanced tools
Comparing version 0.8.3 to 0.8.4
{ | ||
"name": "@solana-wallets/core", | ||
"version": "0.8.3", | ||
"version": "0.8.4", | ||
"description": "Example hello world package in the solana-wallets repository.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -131,2 +131,7 @@ import { Wallet } from "@wallet-standard/base" | ||
export function dispatchGetAvailableWallets() { | ||
const getAvailableWalletsEvent = new CustomEvent(WalletEvent.GET_AVAILABLE_WALLETS) | ||
window.dispatchEvent(getAvailableWalletsEvent) | ||
} | ||
export const WalletEvent = { | ||
@@ -138,2 +143,3 @@ CONNECT: "unified:connect", | ||
AVAILABLE_WALLETS_CHANGED: "unified:available-wallets-changed", | ||
GET_AVAILABLE_WALLETS: "unified:get-available-wallets", | ||
} as const |
@@ -589,2 +589,15 @@ import { WalletAccount, type Wallet as StandardWallet } from "@wallet-standard/base" | ||
function availableWalletsHandler() { | ||
const wallets = Object.values($walletsMap.get()) | ||
dispatchAvailableWalletsChanged({ wallets }) | ||
} | ||
function loadAvailableWalletsHandler() { | ||
window.addEventListener(WalletEvent.GET_AVAILABLE_WALLETS, availableWalletsHandler) | ||
} | ||
function cleanupAvailableWalletsHandler() { | ||
window.removeEventListener(WalletEvent.GET_AVAILABLE_WALLETS, availableWalletsHandler) | ||
} | ||
async function connect(name: string): Promise<void> { | ||
@@ -653,2 +666,3 @@ const existingName = $wallet.get()?.wallet.name | ||
onMountAutoConnect() | ||
loadAvailableWalletsHandler() | ||
return () => { | ||
@@ -658,2 +672,3 @@ cleanup() | ||
cleanupConnectHandlers() | ||
cleanupAvailableWalletsHandler() | ||
} | ||
@@ -660,0 +675,0 @@ } |
47563
1128