Skip to content

Commit

Permalink
fix: add missing react-query provider
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Sep 3, 2024
1 parent 75a335c commit 7ef1ed5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 54 deletions.
7 changes: 3 additions & 4 deletions packages/sats-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
},
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
"react-dom": ">=18",
"@tanstack/react-query": ">=5.0.0"
},
"devDependencies": {
"@types/async-retry": "^1.4.8",
Expand All @@ -56,8 +57,6 @@
"bitcoinjs-lib": "^6.1.5",
"bs58check": "^2.1.2",
"sats-connect": "^1.1.2",
"@uidotdev/usehooks": "^2.4.1",
"@tanstack/react-query": "^5.35.1",
"@tanstack/react-query-devtools": "^5.35.1"
"@uidotdev/usehooks": "^2.4.1"
}
}
12 changes: 8 additions & 4 deletions packages/sats-wagmi/src/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Network as BitcoinNetwork } from 'bitcoin-address-validation';
import { FC, ReactNode, createContext, useCallback, useContext, useEffect, useState } from 'react';
import { useLocalStorage } from '@uidotdev/usehooks';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

import { LeatherConnector, MMSnapConnector, UnisatConnector, XverseConnector } from './connectors';
import { SatsConnector } from './connectors/base';
Expand Down Expand Up @@ -34,9 +35,10 @@ const useSatsWagmi = (): SatsConfigData => {
type SatsWagmiConfigProps = {
children: ReactNode;
network?: BitcoinNetwork;
queryClient: QueryClient;
};

const SatsWagmiConfig: FC<SatsWagmiConfigProps> = ({ children, network = BitcoinNetwork.mainnet }) => {
const SatsWagmiConfig: FC<SatsWagmiConfigProps> = ({ children, queryClient, network = BitcoinNetwork.mainnet }) => {
const [connectors, setConnectors] = useState<SatsConnector[]>([]);
const [connector, setCurrentConnector] = useState<SatsConnector>();

Expand Down Expand Up @@ -107,9 +109,11 @@ const SatsWagmiConfig: FC<SatsWagmiConfigProps> = ({ children, network = Bitcoin
}, [connectors]);

return (
<SatsWagmiContext.Provider value={{ connectors, connector, setConnector, network }}>
{children}
</SatsWagmiContext.Provider>
<QueryClientProvider client={queryClient}>
<SatsWagmiContext.Provider value={{ connectors, connector, setConnector, network }}>
{children}
</SatsWagmiContext.Provider>
</QueryClientProvider>
);
};

Expand Down
47 changes: 1 addition & 46 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7ef1ed5

Please sign in to comment.