Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying broadcast connections to use-solana #622

Merged
merged 1 commit into from Jun 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/use-solana/src/context.tsx
Expand Up @@ -18,7 +18,7 @@ import type {
ConnectionContext,
} from "./utils/useConnectionInternal";
import { useConnectionInternal } from "./utils/useConnectionInternal";
import type { UseProvider } from "./utils/useProviderInternal";
import type { UseProvider, UseProviderArgs } from "./utils/useProviderInternal";
import { useProviderInternal } from "./utils/useProviderInternal";
import type { UseWallet, UseWalletArgs } from "./utils/useWalletInternal";
import { useWalletInternal } from "./utils/useWalletInternal";
Expand All @@ -38,7 +38,8 @@ export interface UseSolanaArgs<
UseWalletArgs<WalletType>,
"onConnect" | "onDisconnect" | "storageAdapter" | "walletProviders"
>
> {
>,
Pick<UseProviderArgs, "broadcastConnections" | "confirmOptions"> {
/**
* Called when an error is thrown.
*/
Expand Down Expand Up @@ -79,6 +80,11 @@ const useSolanaInternal = <WalletType extends WalletTypeEnum<WalletType>>({
onError = defaultOnError,
storageAdapter = LOCAL_STORAGE_ADAPTER,
walletProviders = DEFAULT_WALLET_PROVIDERS as unknown as WalletProviderMap<WalletType>,

// useProvider args
broadcastConnections,
confirmOptions,

...connectionArgs
}: UseSolanaArgs<WalletType> = {}): UseSolana<WalletType> => {
const connectionCtx = useConnectionInternal({
Expand All @@ -98,6 +104,11 @@ const useSolanaInternal = <WalletType extends WalletTypeEnum<WalletType>>({
const providerCtx = useProviderInternal({
connection: connectionCtx.connection,
wallet: walletCtx.wallet,
sendConnection: connectionCtx.sendConnection,
commitment: connectionArgs.commitment,

broadcastConnections,
confirmOptions,
});

return {
Expand Down