Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@solana/wallet-adapter-react
Advanced tools
Readme
@solana/wallet-adapter-react
This package exports a series of hooks that you can use to create custom wallet connection buttons. They manage the state of the wallet connection for you, and return helper methods that you can attach to your event handlers.
What follows is the documentation for useWalletMultiButton()
.
no-wallet
wallets
, then call onSelectWallet()
with the name of the wallet they chose.has-wallet
onConnect()
when clicked.disconnecting
connected
publicKey
and an onDisconnect()
method that you can call to disconnect from the wallet. At any time you can call onSelectWallet()
to change wallets.connecting
onConnect
has-wallet
state.onDisconnect
has-wallet
, connected
, and connecting
states.onSelectWallet()
onSelectWallet()
function that you supplied as config to useWalletMultiButton
. That function receives the list of wallets
and offers you an onSelectWallet()
callback that you can call with the name of the wallet to switch to.function CustomConnectButton() {
const [walletModalConfig, setWalletModalConfig] = useState<Readonly<{
onSelectWallet(walletName: WalletName): void;
wallets: Wallet[];
}> | null>(null);
const { buttonState, onConnect, onDisconnect, onSelectWallet } = useWalletMultiButton({
onSelectWallet: setWalletModalConfig,
});
let label;
switch (buttonState) {
case 'connected':
label = 'Disconnect';
break;
case 'connecting':
label = 'Connecting';
break;
case 'disconnecting':
label = 'Disconnecting';
break;
case 'has-wallet':
label = 'Connect';
break;
case 'no-wallet':
label = 'Select Wallet';
break;
}
const handleClick = useCallback(() => {
switch (buttonState) {
case 'connected':
return onDisconnect;
case 'connecting':
case 'disconnecting':
break;
case 'has-wallet':
return onConnect;
case 'no-wallet':
return onSelectWallet;
break;
}
}, [buttonState, onDisconnect, onConnect, onSelectWallet]);
return (
<>
<button disabled={buttonState === 'connecting' || buttonState === 'disconnecting'} onClick={handleClick}>
{label}
</button>
{walletModalConfig ? (
<Modal>
{walletModalConfig.wallets.map((wallet) => (
<button
key={wallet.adapter.name}
onClick={() => {
walletModalConfig.onSelectWallet(wallet.adapter.name);
setWalletModalConfig(null);
}}
>
{wallet.adapter.name}
</button>
))}
</Modal>
) : null}
</>
);
}
FAQs
## Creating a custom connect button
The npm package @solana/wallet-adapter-react receives a total of 32,315 weekly downloads. As such, @solana/wallet-adapter-react popularity was classified as popular.
We found that @solana/wallet-adapter-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.