Skip to content

Conversation

@dearlordylord
Copy link

In mine and some other codebases, immutability goes by default.

The adapter doesn't like it, so the type like const wallets: readonly [PhantomWalletAdapter, SolflareWalletAdapter] won't work:

const useWallets = () => {
  const phantomWallet = new PhantomWalletAdapter();
  const solflareWallet = new SolflareWalletAdapter();
  return useMemo(() => [phantomWallet, solflareWallet] as const, [phantomWallet, solflareWallet]);
}

...

const wallets = useWallets();
<WalletProvider wallets={wallets}/>

I have to either cast or re-construct <WalletProvider wallets={[...wallets]}/>, which is undesirable.

This PR allows readonly arrays as wallets prop, as well as keeps mutable arrays backwards-compatible.

}: WalletProviderProps) {
const { connection } = useConnection();
const adaptersWithStandardAdapters = useStandardWalletAdapters(adapters);
const adaptersWithStandardAdapters = useStandardWalletAdapters(adapters as Adapter[]);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would require same improvement for useStandardWalletAdapters of @solana/wallet-standard-wallet-adapter-react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant