@bananapus/nana-sdk-react 10.0.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -394,17 +394,6 @@ import { requestBendystraw } from "@bananapus/nana-sdk-core";
394
394
  import { useQuery as useQuery3 } from "@tanstack/react-query";
395
395
  import { analyzeDocument } from "graphql-request";
396
396
 
397
- // src/lib/bendystraw/getBendystrawUrl.ts
398
- import { arbitrum, base, mainnet as mainnet2, optimism } from "viem/chains";
399
- var bendystrawUrl = "https://bendystraw.xyz";
400
- var testnetBendystrawUrl = "https://testnet.bendystraw.xyz";
401
- function getBendystrawUrl(chainId, config) {
402
- const { url, apiKey } = config;
403
- if (url) return `${url}/${apiKey}`;
404
- const isMainnet = [mainnet2, base, arbitrum, optimism].some((c) => c.id === chainId);
405
- return `${isMainnet ? bendystrawUrl : testnetBendystrawUrl}${apiKey !== "" ? `/${apiKey}` : ""}`;
406
- }
407
-
408
397
  // src/contexts/JBProjectProvider/JBProjectProvider.tsx
409
398
  import { createContext as createContext7, useContext as useContext7 } from "react";
410
399
 
@@ -654,21 +643,31 @@ function useBendystrawConfig() {
654
643
  return useContext7(JBProjectContext)?.bendystraw;
655
644
  }
656
645
 
646
+ // src/lib/bendystraw/getBendystrawUrl.ts
647
+ import { arbitrum, base, mainnet as mainnet2, optimism } from "viem/chains";
648
+ var bendystrawUrl = "https://bendystraw.xyz";
649
+ var testnetBendystrawUrl = "https://testnet.bendystraw.xyz";
650
+ function getBendystrawUrl(chainId, config) {
651
+ const { url, apiKey } = config;
652
+ if (url) return `${url}/${apiKey}`;
653
+ const isMainnet = [mainnet2, base, arbitrum, optimism].some((c) => c.id === chainId);
654
+ return `${isMainnet ? bendystrawUrl : testnetBendystrawUrl}${apiKey !== "" ? `/${apiKey}` : ""}`;
655
+ }
656
+
657
657
  // src/lib/bendystraw/useBendystrawQuery.ts
658
658
  function useBendystrawQuery(document, ...[variables, options]) {
659
659
  const chainId = useJBChainId();
660
660
  const config = useBendystrawConfig();
661
661
  const url = chainId && config ? getBendystrawUrl(chainId, config) : void 0;
662
+ const { expression, operationName } = analyzeDocument(document);
663
+ if (!operationName) {
664
+ throw new Error("Bendystraw operations must have a name.");
665
+ }
662
666
  return useQuery3({
663
- queryKey: [
664
- document.definitions[0].name.value,
665
- chainId,
666
- url,
667
- variables
668
- ],
667
+ queryKey: [operationName, chainId, url, variables],
669
668
  queryFn: async () => requestBendystraw(
670
669
  `${url}/graphql`,
671
- analyzeDocument(document).expression,
670
+ expression,
672
671
  variables
673
672
  ),
674
673
  enabled: options?.enabled !== false && !!chainId && !!url,