UNPKG

@ordao/privy-react-orclient

Version:

"Helpers for using orclient with privy and react"

18 lines (17 loc) 793 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useUserWallet = useUserWallet; const react_auth_1 = require("@privy-io/react-auth"); const react_1 = require("react"); function useUserWallet() { const { ready: privyReady, user, authenticated, } = (0, react_auth_1.usePrivy)(); const conWallets = (0, react_auth_1.useWallets)(); // TODO: should figure out how to deal with multiple wallets. // User should be able to select one of them. const userWallet = (0, react_1.useMemo)(() => { if (privyReady && authenticated && conWallets && conWallets.ready) { return conWallets.wallets.find(w => w.address === user?.wallet?.address); } }, [user, conWallets, privyReady, authenticated]); return userWallet; }