Skip to content

Commit

Permalink
refactor: streamline garden configuration retrieval in GardenProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
ManiReddyt committed Nov 9, 2024
1 parent 57f6739 commit e0b324c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/react-hooks/src/lib/context/GardenProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,17 @@ export const GardenProvider: FC<GardenProviderProps> = ({
[secretManager, garden, auth, pendingOrders],
);

const gardenConfig = useMemo(
() => getConfigForNetwork(config.environment),
[config.environment],
);
if (!gardenConfig) throw new Error('Invalid bitcoin network config');

const { orderBookUrl, quoteUrl, bitcoinRPCUrl, blockNumberFetcherUrl } =
useMemo(() => {
const gardenConfig = getConfigForNetwork(config.environment);
return {
orderBookUrl: config.orderBookUrl || gardenConfig.orderBookUrl,
quoteUrl: config.quoteUrl || gardenConfig.quoteUrl,
bitcoinRPCUrl: config.bitcoinRPCUrl || gardenConfig.bitcoinRPCUrl,
blockNumberFetcherUrl:
config.blockNumberFetcherUrl || gardenConfig.blockNumberFetcherUrl,
};
}, [config, gardenConfig]);
}, [config]);

const quote = useMemo(() => new Quote(quoteUrl), [quoteUrl]);
const blockNumberFetcher = useMemo(() => {
Expand Down

0 comments on commit e0b324c

Please sign in to comment.