@berachain/berajs 0.2.8-beta.8 → 0.2.9
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/{BeraError-_mQdkanr.d.cts → BeraError-7-A5JYy_.d.ts} +31 -2
- package/dist/{HoneyConfigProvider-DVP_9KZn.d.ts → HoneyConfigProvider-Dkj-_a5x.d.ts} +1 -1
- package/dist/RequestError-DBOIV65x.d.ts +144 -0
- package/dist/abi/exports.mjs +3 -4
- package/dist/actions/clients/exports.d.ts +2 -0
- package/dist/actions/clients/exports.mjs +12 -0
- package/dist/actions/exports.d.ts +108 -187
- package/dist/actions/exports.mjs +97 -158
- package/dist/actions/governance/exports.d.ts +140 -0
- package/dist/actions/governance/exports.mjs +226 -0
- package/dist/actions/server/exports.d.ts +13 -0
- package/dist/actions/server/exports.mjs +27 -0
- package/dist/{chunk-VA3BQ34H.mjs → chunk-3EARVV7K.mjs} +20 -9
- package/dist/chunk-4Z4AK6SH.mjs +211 -0
- package/dist/chunk-75M6TF7M.mjs +25 -0
- package/dist/chunk-AFN4CVD3.mjs +326 -0
- package/dist/{chunk-7TFV6UKF.mjs → chunk-BGMRHTBQ.mjs} +0 -1
- package/dist/{chunk-3M47ZRXT.mjs → chunk-CDFWPU2R.mjs} +73 -17
- package/dist/{chunk-GWSTVITN.mjs → chunk-CDK4YV3D.mjs} +0 -1
- package/dist/{chunk-KL6YZ5VR.mjs → chunk-DKMAIU74.mjs} +0 -1
- package/dist/chunk-EXIUPSFN.mjs +86 -0
- package/dist/{chunk-VA5L5FDG.mjs → chunk-FFB5LFDW.mjs} +2 -3
- package/dist/{chunk-ZCEFC2TK.mjs → chunk-HQCOU6GY.mjs} +0 -1
- package/dist/{chunk-SGZP4O6R.mjs → chunk-HSSJKHZ4.mjs} +11 -11
- package/dist/{chunk-7QKRRIHI.mjs → chunk-J5I45WGQ.mjs} +77 -152
- package/dist/chunk-KQUMKB66.mjs +89 -0
- package/dist/{chunk-JA4DHMTG.mjs → chunk-NBYLMO2L.mjs} +0 -1
- package/dist/{chunk-4GFN4LEP.mjs → chunk-NPBQLVL3.mjs} +4 -21
- package/dist/{chunk-I3FTWD6I.mjs → chunk-O2NQFKJK.mjs} +1 -1
- package/dist/{chunk-2R73G2PO.mjs → chunk-QJIXTYTZ.mjs} +121 -765
- package/dist/{chunk-GLWPRM33.mjs → chunk-SGIJVHZO.mjs} +0 -1
- package/dist/chunk-SZ5C44L5.mjs +35 -0
- package/dist/{chunk-5NMATIH4.mjs → chunk-WXXOISTU.mjs} +1 -35
- package/dist/chunk-XIYN6AL6.mjs +160 -0
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +11 -9
- package/dist/enum/exports.d.ts +1 -1
- package/dist/enum/exports.mjs +3 -16
- package/dist/enum/governance/exports.d.ts +60 -0
- package/dist/enum/governance/exports.mjs +14 -0
- package/dist/errors/exports.d.ts +5 -90
- package/dist/errors/exports.mjs +19 -10
- package/dist/exports-BcUTGFUb.d.ts +40 -0
- package/dist/{getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts → getValidatorQueuedOperatorAddress-Dw5KN5sh.d.ts} +2 -2
- package/dist/{global.d-5w_lvl2J.d.ts → global.d-BuGDKh4k.d.ts} +4 -240
- package/dist/hooks/exports.d.ts +80 -236
- package/dist/hooks/exports.mjs +609 -1508
- package/dist/hooks/governance/exports.d.ts +181 -0
- package/dist/hooks/governance/exports.mjs +888 -0
- package/dist/pol.d-CqPA9K6m.d.ts +142 -0
- package/dist/{txnEnum-7_o92X3N.d.cts → txnEnum-ByI5dtDi.d.ts} +2 -60
- package/dist/types/exports.d.ts +9 -9
- package/dist/types/exports.mjs +0 -1
- package/dist/types/governance/exports.d.ts +109 -0
- package/dist/types/governance/exports.mjs +0 -0
- package/dist/{useHoneySwapState-B494PQDl.d.ts → useHoneySwapState-vFmuFF0g.d.ts} +1 -1
- package/dist/utils/exports.d.ts +24 -7
- package/dist/utils/exports.mjs +49 -11
- package/package.json +60 -13
- package/src/actions/__test/transports.ts +61 -0
- package/src/actions/clients/BeraApolloClient.ts +9 -0
- package/src/actions/clients/exports.ts +4 -0
- package/src/actions/clients/getApolloClient.ts +70 -25
- package/src/actions/clients/getEnsoClient.ts +20 -9
- package/src/actions/dex/aggregators/base.ts +1 -1
- package/src/actions/dex/aggregators/enso/enso.ts +27 -17
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +2 -2
- package/src/actions/dex/aggregators/kyberswap.ts +18 -23
- package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
- package/src/actions/exports.ts +5 -10
- package/src/actions/governance/exports.ts +9 -0
- package/src/actions/governance/getAllProposals.ts +10 -65
- package/src/actions/governance/getProposalDetails.ts +6 -33
- package/src/actions/governance/getProposalVotes.ts +8 -15
- package/src/actions/honey/getChartData.ts +27 -21
- package/src/actions/honey/getHoney24hVolume.ts +27 -0
- package/src/actions/pol/getAutoclaimedIncentives.ts +30 -0
- package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
- package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +35 -0
- package/src/actions/pol/getEarnedStakedBeraVault.ts +15 -9
- package/src/actions/pol/getGlobalData.ts +1 -0
- package/src/actions/pol/getHeroEarnVaults.ts +62 -0
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +19 -38
- package/src/actions/pol/getSWBeraVaultMetadata.ts +1 -1
- package/src/actions/pol/getStakingDailyAssets.ts +11 -8
- package/src/actions/server/exports.ts +1 -0
- package/src/actions/server/getDailyValidatorBlockStats.ts +33 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
- package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
- package/src/actions/validators/getDailyValidatorBlockStats.ts +25 -24
- package/src/actions/validators/getValidatorAnalytics.ts +20 -21
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +33 -0
- package/src/data/contracts.ts +5 -0
- package/src/enum/contracts.ts +1 -0
- package/src/enum/exports.ts +0 -1
- package/src/enum/governance/exports.ts +1 -0
- package/src/errors/BeraError.ts +47 -7
- package/src/errors/BeraTracing.unit.test.ts +65 -0
- package/src/errors/RequestError.ts +15 -2
- package/src/errors/exports.ts +5 -0
- package/src/errors/getRevertReason.integration.test.ts +3 -3
- package/src/errors/spanStatus.ts +78 -0
- package/src/errors/spanStatus.unit.test.ts +62 -0
- package/src/hooks/dex/useCreatePool.ts +1 -88
- package/src/hooks/dex/useOnChainPoolData.ts +27 -2
- package/src/hooks/dex/usePriceImpact.ts +12 -5
- package/src/hooks/enso/useBendDemultiply.ts +9 -1
- package/src/hooks/enso/useBendMultiply.ts +9 -1
- package/src/hooks/enso/useBendZapSupply.ts +26 -7
- package/src/hooks/enso/useEnsoSwapBundle.ts +17 -3
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -2
- package/src/hooks/exports.ts +3 -16
- package/src/hooks/governance/exports.ts +14 -0
- package/src/hooks/honey/useHoney24hVolume.ts +16 -0
- package/src/hooks/pol/useAutoclaimedIncentives.ts +49 -0
- package/src/hooks/pol/useStakedAPR.ts +2 -2
- package/src/hooks/pol/useStakedSnapshots.ts +5 -9
- package/src/hooks/validators/useValidator.ts +2 -0
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
- package/src/types/bribe-boost.d.ts +8 -0
- package/src/types/exports.ts +0 -1
- package/src/types/governance/exports.ts +1 -0
- package/src/utils/beraFetch.ts +76 -15
- package/src/utils/exports.ts +1 -0
- package/src/utils/getServerSideClient.ts +4 -2
- package/src/utils/sanitizeRpcUrl.ts +22 -0
- package/src/utils/tracedTransport.ts +35 -0
- package/dist/BeraError-_mQdkanr.d.ts +0 -94
- package/dist/BexStatusProvider-DRymVlQf.d.cts +0 -70
- package/dist/HoneyConfigProvider-DfkjmzEf.d.cts +0 -390
- package/dist/RequestError-A8XJ6QR9.d.cts +0 -57
- package/dist/RequestError-Dk97z8rm.d.ts +0 -57
- package/dist/abi/exports.cjs +0 -4453
- package/dist/abi/exports.cjs.map +0 -1
- package/dist/abi/exports.d.cts +0 -6574
- package/dist/abi/exports.mjs.map +0 -1
- package/dist/actions/exports.cjs +0 -914
- package/dist/actions/exports.cjs.map +0 -1
- package/dist/actions/exports.d.cts +0 -1644
- package/dist/actions/exports.mjs.map +0 -1
- package/dist/chunk-2R73G2PO.mjs.map +0 -1
- package/dist/chunk-3M47ZRXT.mjs.map +0 -1
- package/dist/chunk-4GFN4LEP.mjs.map +0 -1
- package/dist/chunk-5N7QQS55.cjs +0 -130
- package/dist/chunk-5N7QQS55.cjs.map +0 -1
- package/dist/chunk-5NMATIH4.mjs.map +0 -1
- package/dist/chunk-7QKRRIHI.mjs.map +0 -1
- package/dist/chunk-7TFV6UKF.mjs.map +0 -1
- package/dist/chunk-A4FPM7U3.cjs +0 -63
- package/dist/chunk-A4FPM7U3.cjs.map +0 -1
- package/dist/chunk-BDHINMWQ.cjs +0 -417
- package/dist/chunk-BDHINMWQ.cjs.map +0 -1
- package/dist/chunk-BEHP54S3.cjs +0 -24
- package/dist/chunk-BEHP54S3.cjs.map +0 -1
- package/dist/chunk-EGDXV2PT.cjs +0 -36
- package/dist/chunk-EGDXV2PT.cjs.map +0 -1
- package/dist/chunk-EWBKSMPG.cjs +0 -13
- package/dist/chunk-EWBKSMPG.cjs.map +0 -1
- package/dist/chunk-F6ZW7ZDD.cjs +0 -403
- package/dist/chunk-F6ZW7ZDD.cjs.map +0 -1
- package/dist/chunk-FTXTRUYT.cjs +0 -170
- package/dist/chunk-FTXTRUYT.cjs.map +0 -1
- package/dist/chunk-GLWPRM33.mjs.map +0 -1
- package/dist/chunk-GWSTVITN.mjs.map +0 -1
- package/dist/chunk-H3Z37RYU.cjs +0 -15
- package/dist/chunk-H3Z37RYU.cjs.map +0 -1
- package/dist/chunk-I3FTWD6I.mjs.map +0 -1
- package/dist/chunk-JA4DHMTG.mjs.map +0 -1
- package/dist/chunk-KL6YZ5VR.mjs.map +0 -1
- package/dist/chunk-MXWPP6MS.cjs +0 -572
- package/dist/chunk-MXWPP6MS.cjs.map +0 -1
- package/dist/chunk-SGZP4O6R.mjs.map +0 -1
- package/dist/chunk-TDW5SPXR.cjs +0 -244
- package/dist/chunk-TDW5SPXR.cjs.map +0 -1
- package/dist/chunk-TGK3IXDN.cjs +0 -169
- package/dist/chunk-TGK3IXDN.cjs.map +0 -1
- package/dist/chunk-TJEW6YCJ.cjs +0 -97
- package/dist/chunk-TJEW6YCJ.cjs.map +0 -1
- package/dist/chunk-VA3BQ34H.mjs.map +0 -1
- package/dist/chunk-VA5L5FDG.mjs.map +0 -1
- package/dist/chunk-XSGCRLSD.cjs +0 -1844
- package/dist/chunk-XSGCRLSD.cjs.map +0 -1
- package/dist/chunk-XV3GG3HC.cjs +0 -135
- package/dist/chunk-XV3GG3HC.cjs.map +0 -1
- package/dist/chunk-Y5B224UX.cjs +0 -4698
- package/dist/chunk-Y5B224UX.cjs.map +0 -1
- package/dist/chunk-ZBTRKBSI.mjs +0 -169
- package/dist/chunk-ZBTRKBSI.mjs.map +0 -1
- package/dist/chunk-ZCEFC2TK.mjs.map +0 -1
- package/dist/contexts/exports.cjs +0 -83
- package/dist/contexts/exports.cjs.map +0 -1
- package/dist/contexts/exports.d.cts +0 -66
- package/dist/contexts/exports.mjs.map +0 -1
- package/dist/defaultFlags-D6KfkTZx.d.cts +0 -10
- package/dist/dex-C_BB0b0O.d.cts +0 -37
- package/dist/enum/exports.cjs +0 -59
- package/dist/enum/exports.cjs.map +0 -1
- package/dist/enum/exports.d.cts +0 -23
- package/dist/enum/exports.mjs.map +0 -1
- package/dist/errors/exports.cjs +0 -39
- package/dist/errors/exports.cjs.map +0 -1
- package/dist/errors/exports.d.cts +0 -413
- package/dist/errors/exports.mjs.map +0 -1
- package/dist/getValidatorQueuedOperatorAddress-Cql_D50j.d.cts +0 -562
- package/dist/global.d-B7IeayVX.d.cts +0 -474
- package/dist/honey-CYm0RWf4.d.cts +0 -14
- package/dist/hooks/exports.cjs +0 -8333
- package/dist/hooks/exports.cjs.map +0 -1
- package/dist/hooks/exports.d.cts +0 -1748
- package/dist/hooks/exports.mjs.map +0 -1
- package/dist/polling-BKnyavLI.d.cts +0 -8
- package/dist/txnEnum-7_o92X3N.d.ts +0 -164
- package/dist/types/exports.cjs +0 -1
- package/dist/types/exports.cjs.map +0 -1
- package/dist/types/exports.d.cts +0 -90
- package/dist/types/exports.mjs.map +0 -1
- package/dist/useHoneySwapState-D6vpv19r.d.cts +0 -32
- package/dist/utils/exports.cjs +0 -787
- package/dist/utils/exports.cjs.map +0 -1
- package/dist/utils/exports.d.cts +0 -412
- package/dist/utils/exports.mjs.map +0 -1
- package/src/actions/dex/getIsTokenExploited.ts +0 -63
- package/src/actions/honey/getHoneyGlobalData.ts +0 -21
- package/src/hooks/dex/useExploitedTokens.ts +0 -57
- package/src/hooks/honey/useHoneyGlobalData.ts +0 -23
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { fallback, http } from "viem";
|
|
2
|
+
import {
|
|
3
|
+
arbitrum,
|
|
4
|
+
avalanche,
|
|
5
|
+
base,
|
|
6
|
+
bsc,
|
|
7
|
+
mainnet,
|
|
8
|
+
optimism,
|
|
9
|
+
polygon,
|
|
10
|
+
} from "viem/chains";
|
|
11
|
+
|
|
12
|
+
import { publicJsonRpcUrl } from "@berachain/config/internal";
|
|
13
|
+
import { defaultChain } from "@berachain/config/internal/wagmi";
|
|
14
|
+
|
|
15
|
+
const transportOptions = {
|
|
16
|
+
batch: { wait: 35 },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const externalTransportOptions = {
|
|
20
|
+
batch: { wait: 15 },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const urls = [publicJsonRpcUrl].filter(Boolean) as string[];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Thirdweb RPC URLs have a rate limit of 3 RPS.
|
|
27
|
+
* http() uses default viem transport which varies based on the chain definition.
|
|
28
|
+
*
|
|
29
|
+
* Quicknode RPC URLs are CORS restricted to *.berachain.com, *.berachain-staging.com. They have a 100rpm rate limit.
|
|
30
|
+
*/
|
|
31
|
+
export const testTransports = {
|
|
32
|
+
[defaultChain.id]: fallback(urls.map((url) => http(url, transportOptions))),
|
|
33
|
+
[mainnet.id]: fallback([
|
|
34
|
+
http("https://1.rpc.thirdweb.com/", externalTransportOptions),
|
|
35
|
+
http(),
|
|
36
|
+
]),
|
|
37
|
+
[polygon.id]: fallback([
|
|
38
|
+
http("https://137.rpc.thirdweb.com/", externalTransportOptions),
|
|
39
|
+
http(),
|
|
40
|
+
]),
|
|
41
|
+
[optimism.id]: fallback([
|
|
42
|
+
http("https://10.rpc.thirdweb.com/", externalTransportOptions),
|
|
43
|
+
http(),
|
|
44
|
+
]),
|
|
45
|
+
[base.id]: fallback([
|
|
46
|
+
http("https://8453.rpc.thirdweb.com/", externalTransportOptions),
|
|
47
|
+
http(),
|
|
48
|
+
]),
|
|
49
|
+
[bsc.id]: fallback([
|
|
50
|
+
http("https://56.rpc.thirdweb.com/", externalTransportOptions),
|
|
51
|
+
http(),
|
|
52
|
+
]),
|
|
53
|
+
[avalanche.id]: fallback([
|
|
54
|
+
http("https://43114.rpc.thirdweb.com/", externalTransportOptions),
|
|
55
|
+
http(),
|
|
56
|
+
]),
|
|
57
|
+
[arbitrum.id]: fallback([
|
|
58
|
+
http("https://42161.rpc.thirdweb.com/", externalTransportOptions),
|
|
59
|
+
http(),
|
|
60
|
+
]),
|
|
61
|
+
};
|
|
@@ -24,16 +24,22 @@ export class BeraApolloClient extends ApolloClient {
|
|
|
24
24
|
*/
|
|
25
25
|
protected url: string;
|
|
26
26
|
|
|
27
|
+
protected serviceName: string;
|
|
27
28
|
constructor(
|
|
28
29
|
options: ApolloClient.Options & {
|
|
29
30
|
/**
|
|
30
31
|
* The URL of the endpoint. Used for error reporting only.
|
|
31
32
|
*/
|
|
32
33
|
url: string;
|
|
34
|
+
/**
|
|
35
|
+
* The name of the graphql service. Used for error reporting only.
|
|
36
|
+
*/
|
|
37
|
+
name: string;
|
|
33
38
|
},
|
|
34
39
|
) {
|
|
35
40
|
super(options);
|
|
36
41
|
this.url = options.url;
|
|
42
|
+
this.serviceName = options.name;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
async query<
|
|
@@ -47,13 +53,16 @@ export class BeraApolloClient extends ApolloClient {
|
|
|
47
53
|
data: TData;
|
|
48
54
|
}> {
|
|
49
55
|
const queryName = getQueryName(options.query);
|
|
56
|
+
|
|
50
57
|
const endpoint = {
|
|
51
58
|
url: this.url,
|
|
52
59
|
type: "graphql",
|
|
60
|
+
name: this.serviceName,
|
|
53
61
|
} as const;
|
|
54
62
|
|
|
55
63
|
const tags = {
|
|
56
64
|
"operation.type": "query",
|
|
65
|
+
"operation.source.name": endpoint.name,
|
|
57
66
|
"operation.source.url": endpoint.url,
|
|
58
67
|
"operation.source.type": endpoint.type,
|
|
59
68
|
"operation.source.queryName": queryName,
|
|
@@ -3,7 +3,7 @@ import { HttpLink } from "@apollo/client/link/http";
|
|
|
3
3
|
|
|
4
4
|
import type { HttpLink as BeraConfigHttpLink } from "@berachain/config";
|
|
5
5
|
import { getUriFromLink } from "@berachain/config";
|
|
6
|
-
import { currentDapp } from "@berachain/config/internal";
|
|
6
|
+
import { currentDapp, goldskyBaseUrl } from "@berachain/config/internal";
|
|
7
7
|
|
|
8
8
|
import apiResults from "@berachain/graphql/dex/api";
|
|
9
9
|
|
|
@@ -20,8 +20,12 @@ function applyStellateClientName(url: BeraConfigHttpLink): BeraConfigHttpLink {
|
|
|
20
20
|
const isDapp = !!currentDapp;
|
|
21
21
|
const isTest = process.env.VERCEL_ENV === "test";
|
|
22
22
|
|
|
23
|
+
const uri = getUriFromLink(url);
|
|
24
|
+
const name = typeof url === "string" ? "unknown" : url.name;
|
|
25
|
+
|
|
23
26
|
return {
|
|
24
|
-
uri
|
|
27
|
+
uri,
|
|
28
|
+
name,
|
|
25
29
|
headers: {
|
|
26
30
|
...headers,
|
|
27
31
|
"x-graphql-client-name": `berachain.${
|
|
@@ -51,9 +55,15 @@ function getClient(
|
|
|
51
55
|
) {
|
|
52
56
|
const url = getUriFromLink(endpoint);
|
|
53
57
|
const headers = typeof endpoint === "string" ? undefined : endpoint.headers;
|
|
58
|
+
let name = typeof endpoint === "string" ? undefined : endpoint.name;
|
|
59
|
+
|
|
60
|
+
if (!name && url.includes(goldskyBaseUrl)) {
|
|
61
|
+
name = url.replace(goldskyBaseUrl, "").replace("/gn", "");
|
|
62
|
+
}
|
|
54
63
|
|
|
55
64
|
return new BeraApolloClient({
|
|
56
65
|
url,
|
|
66
|
+
name: name ?? "unknown",
|
|
57
67
|
link: new HttpLink({
|
|
58
68
|
uri: url,
|
|
59
69
|
headers,
|
|
@@ -70,28 +80,68 @@ function getClient(
|
|
|
70
80
|
});
|
|
71
81
|
}
|
|
72
82
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Browser-reachable Apollo client factory for `api` and Bend's `whisk`
|
|
85
|
+
* endpoints. Subgraph clients (honey/pol) are server-only; browser data
|
|
86
|
+
* access goes through the typed `/api/honey/*` and `/api/pol/*` REST
|
|
87
|
+
* endpoints. Same auth shape as bend.whiskApi — non-public env values only
|
|
88
|
+
* resolve server-side.
|
|
89
|
+
*/
|
|
90
|
+
type GraphqlClient = "api" | "bend.whisk" | "honey.subgraph" | "pol.subgraph";
|
|
91
|
+
|
|
92
|
+
const SUBGRAPH_CLIENTS = [
|
|
93
|
+
"honey.subgraph",
|
|
94
|
+
"pol.subgraph",
|
|
95
|
+
] as const satisfies readonly GraphqlClient[];
|
|
96
|
+
|
|
97
|
+
type SubgraphClient = (typeof SUBGRAPH_CLIENTS)[number];
|
|
98
|
+
|
|
99
|
+
function isSubgraphClient(name: GraphqlClient): name is SubgraphClient {
|
|
100
|
+
return SUBGRAPH_CLIENTS.includes(name as SubgraphClient);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const clientCache = new Map<string, BeraApolloClient>();
|
|
104
|
+
|
|
105
|
+
function store(
|
|
106
|
+
cacheKey: string | null,
|
|
107
|
+
client: BeraApolloClient,
|
|
108
|
+
): BeraApolloClient {
|
|
109
|
+
if (cacheKey) clientCache.set(cacheKey, client);
|
|
110
|
+
return client;
|
|
111
|
+
}
|
|
81
112
|
|
|
82
113
|
export function getApolloClient(
|
|
83
114
|
clientName: GraphqlClient,
|
|
84
115
|
{ ...args }: BeraJS.BaseFunctionArgs,
|
|
85
116
|
): BeraApolloClient {
|
|
86
|
-
|
|
117
|
+
if (typeof window !== "undefined" && isSubgraphClient(clientName)) {
|
|
118
|
+
throw new BeraError({
|
|
119
|
+
message: "Subgraph Apollo client is server-only",
|
|
120
|
+
level: "error",
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const { config, chainId } = parseBaseArgs(args);
|
|
125
|
+
|
|
126
|
+
// Caller-supplied configs are treated as unique (may override URLs/headers),
|
|
127
|
+
// so they bypass the cache. The common path (chainId-only) is memoized.
|
|
128
|
+
const cacheKey = args.config ? null : `${chainId}:${clientName}`;
|
|
129
|
+
|
|
130
|
+
if (cacheKey) {
|
|
131
|
+
const cached = clientCache.get(cacheKey);
|
|
132
|
+
if (cached) return cached;
|
|
133
|
+
}
|
|
87
134
|
|
|
88
135
|
switch (clientName) {
|
|
89
136
|
case "api":
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
137
|
+
return store(
|
|
138
|
+
cacheKey,
|
|
139
|
+
getClient(applyStellateClientName(config.api), {
|
|
140
|
+
inMemoryCacheOptions: {
|
|
141
|
+
possibleTypes: apiResults.possibleTypes,
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
);
|
|
95
145
|
|
|
96
146
|
case "bend.whisk":
|
|
97
147
|
if (!config.bend.whiskApi) {
|
|
@@ -100,17 +150,12 @@ export function getApolloClient(
|
|
|
100
150
|
level: "error",
|
|
101
151
|
});
|
|
102
152
|
}
|
|
103
|
-
return getClient(config.bend.whiskApi);
|
|
153
|
+
return store(cacheKey, getClient(config.bend.whiskApi));
|
|
104
154
|
|
|
105
155
|
case "honey.subgraph":
|
|
106
|
-
return getClient(config.honey.subgraph);
|
|
156
|
+
return store(cacheKey, getClient(config.honey.subgraph));
|
|
157
|
+
|
|
107
158
|
case "pol.subgraph":
|
|
108
|
-
return getClient(config.pol.subgraph);
|
|
109
|
-
case "pol.fees":
|
|
110
|
-
return getClient(config.pol.feesSubgraph);
|
|
111
|
-
case "governance.subgraph":
|
|
112
|
-
return getClient(config.governance.subgraph);
|
|
113
|
-
case "bex.subgraph":
|
|
114
|
-
return getClient(config.bex.subgraph);
|
|
159
|
+
return store(cacheKey, getClient(config.pol.subgraph));
|
|
115
160
|
}
|
|
116
161
|
}
|
|
@@ -8,17 +8,28 @@ const isProduction =
|
|
|
8
8
|
process.env.NODE_ENV !== "development" && process.env.NODE_ENV !== "test";
|
|
9
9
|
|
|
10
10
|
export function getEnsoClient({
|
|
11
|
-
|
|
11
|
+
baseURL,
|
|
12
12
|
...args
|
|
13
|
-
}: BeraJS.BaseFunctionArgs & {
|
|
13
|
+
}: BeraJS.BaseFunctionArgs & {
|
|
14
|
+
/**
|
|
15
|
+
* Override the Enso API base URL.
|
|
16
|
+
*
|
|
17
|
+
* - Omit (or pass `undefined`) → external proxy in production, direct in dev/test
|
|
18
|
+
* - Pass a URL string (e.g. `"/api/enso"`) → route through that proxy
|
|
19
|
+
*/
|
|
20
|
+
baseURL?: string;
|
|
21
|
+
} = {}) {
|
|
14
22
|
const { config } = parseBaseArgs(args);
|
|
23
|
+
const resolvedBaseURL =
|
|
24
|
+
baseURL !== undefined
|
|
25
|
+
? baseURL
|
|
26
|
+
: isProduction
|
|
27
|
+
? `${config.bex.aggregatorsProxyUrl}/enso/api/v1/`
|
|
28
|
+
: undefined;
|
|
29
|
+
|
|
15
30
|
return new EnsoClient({
|
|
16
|
-
baseURL:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
apiKey: useProxy
|
|
20
|
-
? // no API key since proxy has CORS for .berachain.com domains
|
|
21
|
-
""
|
|
22
|
-
: appConfig.apiKeys.public.enso,
|
|
31
|
+
baseURL: resolvedBaseURL,
|
|
32
|
+
// no API key when routing through a proxy — the proxy handles auth
|
|
33
|
+
apiKey: resolvedBaseURL ? "" : appConfig.apiKeys.public.enso,
|
|
23
34
|
});
|
|
24
35
|
}
|
|
@@ -49,25 +49,35 @@ class EnsoAggregator extends BaseAggregator {
|
|
|
49
49
|
aggregatorsFeeBps,
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
+
// Enso rejects a zero-address `refundReceiver` with 400 Bad Request, so
|
|
53
|
+
// when no wallet is connected (or the account hasn't hydrated yet) fall
|
|
54
|
+
// back to the executor. Only matters for quotes — on execution the user's
|
|
55
|
+
// real address is always set.
|
|
56
|
+
const refundReceiver =
|
|
57
|
+
account === zeroAddress
|
|
58
|
+
? this.config.bex.aggregatorsRouterExecutor
|
|
59
|
+
: account;
|
|
60
|
+
|
|
61
|
+
const params = new URLSearchParams({
|
|
62
|
+
fromAddress: this.config.bex.aggregatorsRouterExecutor,
|
|
63
|
+
receiver: this.config.bex.aggregatorsRouterExecutor,
|
|
64
|
+
spender: this.config.bex.aggregatorsRouterExecutor,
|
|
65
|
+
amountIn: inputAmountAfterFees,
|
|
66
|
+
tokenIn: tokenInAddress,
|
|
67
|
+
tokenOut: tokenOutAddress,
|
|
68
|
+
chainId: ChainId.MAINNET.toString(),
|
|
69
|
+
slippage: (Number(slippage) * 100).toString(),
|
|
70
|
+
refundReceiver,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Build the URL via string concat — the `new URL(relative)` constructor
|
|
74
|
+
// throws on relative paths like `/api/aggregators?...`, which silently
|
|
75
|
+
// breaks the Vercel-proxy path.
|
|
52
76
|
this.url = proxyAggregatorsThroughVercel
|
|
53
|
-
? `/api/aggregators?aggregator=enso`
|
|
54
|
-
: `${this.config.bex.aggregatorsProxyUrl}/enso/api/v1/shortcuts/route
|
|
77
|
+
? `/api/aggregators?aggregator=enso&${params.toString()}`
|
|
78
|
+
: `${this.config.bex.aggregatorsProxyUrl}/enso/api/v1/shortcuts/route?${params.toString()}`;
|
|
55
79
|
|
|
56
|
-
const
|
|
57
|
-
url.searchParams.set(
|
|
58
|
-
"fromAddress",
|
|
59
|
-
this.config.bex.aggregatorsRouterExecutor,
|
|
60
|
-
);
|
|
61
|
-
url.searchParams.set("receiver", this.config.bex.aggregatorsRouterExecutor);
|
|
62
|
-
url.searchParams.set("spender", this.config.bex.aggregatorsRouterExecutor);
|
|
63
|
-
url.searchParams.set("amountIn", inputAmountAfterFees);
|
|
64
|
-
url.searchParams.set("tokenIn", tokenInAddress);
|
|
65
|
-
url.searchParams.set("tokenOut", tokenOutAddress);
|
|
66
|
-
url.searchParams.set("chainId", ChainId.MAINNET.toString());
|
|
67
|
-
url.searchParams.set("slippage", (Number(slippage) * 100).toString());
|
|
68
|
-
url.searchParams.set("refundReceiver", account);
|
|
69
|
-
|
|
70
|
-
const response = await this.fetch(url);
|
|
80
|
+
const response = await this.fetch(this.url);
|
|
71
81
|
|
|
72
82
|
const quote = await response.json();
|
|
73
83
|
|
|
@@ -39,7 +39,7 @@ class EnsoErc4626Aggregator extends BaseAggregator {
|
|
|
39
39
|
assertAddress(account, "account");
|
|
40
40
|
|
|
41
41
|
const ensoClient = getEnsoClient({
|
|
42
|
-
|
|
42
|
+
baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : undefined,
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
if (tokenIn.address === zeroAddress) tokenIn.address = ethAddress;
|
|
@@ -148,7 +148,7 @@ class EnsoErc4626Aggregator extends BaseAggregator {
|
|
|
148
148
|
|
|
149
149
|
const amountOut =
|
|
150
150
|
// @ts-expect-error enso has not typed this but is returned sometimes from API.
|
|
151
|
-
bundle.minAmountsOut[tokenOutAddress] ??
|
|
151
|
+
bundle.minAmountsOut?.[tokenOutAddress] ??
|
|
152
152
|
bundle.amountsOut[tokenOutAddress] ??
|
|
153
153
|
"0";
|
|
154
154
|
|
|
@@ -41,20 +41,23 @@ class KyberSwapAggregator extends BaseAggregator {
|
|
|
41
41
|
aggregatorsFeeBps,
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
:
|
|
44
|
+
const params = new URLSearchParams({
|
|
45
|
+
tokenIn: tokenInAddress,
|
|
46
|
+
tokenOut: tokenOutAddress,
|
|
47
|
+
amountIn: inputAmountAfterFees,
|
|
48
|
+
slippageTolerance: (slippage / 100).toString(),
|
|
49
|
+
to: this.config.bex.aggregatorsRouterExecutor,
|
|
50
|
+
clientData: JSON.stringify({ source: "berachain" }),
|
|
51
|
+
});
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
url
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
url.searchParams.set("to", this.config.bex.aggregatorsRouterExecutor);
|
|
55
|
-
url.searchParams.set("clientData", JSON.stringify({ source: "berachain" }));
|
|
53
|
+
// Build URLs via string concat — the `new URL(relative)` constructor
|
|
54
|
+
// throws on relative paths like `/api/aggregators?...`, which silently
|
|
55
|
+
// breaks the Vercel-proxy path.
|
|
56
|
+
this.url = proxyAggregatorsThroughVercel
|
|
57
|
+
? `/api/aggregators?aggregator=kyberswapRoutes&${params.toString()}`
|
|
58
|
+
: `${this.config.bex.aggregatorsProxyUrl}/kyberswap/berachain/api/v1/routes?${params.toString()}`;
|
|
56
59
|
|
|
57
|
-
const routeResponse = await this.fetch(url);
|
|
60
|
+
const routeResponse = await this.fetch(this.url);
|
|
58
61
|
|
|
59
62
|
const routeData = await routeResponse.json();
|
|
60
63
|
const formattedQuote = {
|
|
@@ -79,17 +82,9 @@ class KyberSwapAggregator extends BaseAggregator {
|
|
|
79
82
|
source: "berachain",
|
|
80
83
|
};
|
|
81
84
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
proxyAggregatorsThroughVercel
|
|
86
|
-
? `/api/aggregators?aggregator=kyberswapBuild`
|
|
87
|
-
: `${this.config.bex.aggregatorsProxyUrl}/kyberswap/berachain/api/v1/route/build`,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
for (const [key, value] of params) {
|
|
91
|
-
buildUrl.searchParams.set(key, value);
|
|
92
|
-
}
|
|
85
|
+
const buildUrl = proxyAggregatorsThroughVercel
|
|
86
|
+
? `/api/aggregators?aggregator=kyberswapBuild&${params.toString()}`
|
|
87
|
+
: `${this.config.bex.aggregatorsProxyUrl}/kyberswap/berachain/api/v1/route/build?${params.toString()}`;
|
|
93
88
|
|
|
94
89
|
const buildRouteResponse = await this.fetch(buildUrl, {
|
|
95
90
|
method: "POST",
|
|
@@ -9,15 +9,12 @@ import {
|
|
|
9
9
|
} from "vitest";
|
|
10
10
|
|
|
11
11
|
import { appConfig } from "@berachain/config/internal";
|
|
12
|
-
import {
|
|
13
|
-
defaultChain,
|
|
14
|
-
externalChains,
|
|
15
|
-
transports,
|
|
16
|
-
} from "@berachain/config/internal/wagmi";
|
|
12
|
+
import { defaultChain, externalChains } from "@berachain/config/internal/wagmi";
|
|
17
13
|
|
|
18
14
|
import { getConfig } from "@berachain/wagmi/config";
|
|
19
15
|
|
|
20
16
|
import { BeraMonitoring } from "../../../errors/BeraMonitoring";
|
|
17
|
+
import { testTransports } from "../../__test/transports";
|
|
21
18
|
import { getEnsoClient } from "../../clients/getEnsoClient";
|
|
22
19
|
import { getEnsoUserTokensWithBalances } from "../getEnsoUserTokensWithBalances";
|
|
23
20
|
|
|
@@ -41,7 +38,7 @@ describe("getEnsoUserTokensWithBalances", () => {
|
|
|
41
38
|
const ensoClient = getEnsoClient();
|
|
42
39
|
|
|
43
40
|
const beraWagmiConfig = getConfig({
|
|
44
|
-
transports,
|
|
41
|
+
transports: testTransports,
|
|
45
42
|
defaultChain,
|
|
46
43
|
chains: externalChains,
|
|
47
44
|
thirdweb: { clientId: appConfig.apiKeys.public.thirdweb },
|
package/src/actions/exports.ts
CHANGED
|
@@ -25,21 +25,12 @@ export * from "./dex/getPoolHistoricalData";
|
|
|
25
25
|
export * from "./dex/getPoolPausedState";
|
|
26
26
|
export * from "./dex/getPoolWithState";
|
|
27
27
|
export * from "./dex/getVaultPausedState";
|
|
28
|
-
export * from "./governance/checkProposalField";
|
|
29
|
-
export * from "./governance/computeActualStatus";
|
|
30
|
-
export * from "./governance/getAllProposals";
|
|
31
|
-
export * from "./governance/getBodyErrors";
|
|
32
|
-
export * from "./governance/getDecodedFunctionData";
|
|
33
|
-
export * from "./governance/getProposalDetails";
|
|
34
|
-
export * from "./governance/getProposalFromTx";
|
|
35
|
-
export * from "./governance/getProposalVotes";
|
|
36
|
-
export * from "./governance/parseProposalBody";
|
|
37
28
|
export * from "./honey/getChartData";
|
|
38
29
|
export * from "./honey/getCollateralWeights";
|
|
39
30
|
export * from "./honey/getGlobalCapLimit";
|
|
31
|
+
export * from "./honey/getHoney24hVolume";
|
|
40
32
|
export * from "./honey/getHoneyCollaterals";
|
|
41
33
|
export * from "./honey/getHoneyFees";
|
|
42
|
-
export * from "./honey/getHoneyGlobalData";
|
|
43
34
|
export * from "./honey/getHoneyPausedState";
|
|
44
35
|
export * from "./honey/getHoneyPreview";
|
|
45
36
|
export * from "./honey/getHoneyPythPriceOracle";
|
|
@@ -51,10 +42,14 @@ export * from "./honey/getSwapPayload";
|
|
|
51
42
|
export * from "./honey/isBadCollateralAsset";
|
|
52
43
|
export * from "./honey/isBasketModeEnabled";
|
|
53
44
|
export * from "./misc/getBlockTimestamp";
|
|
45
|
+
export * from "./pol/getAutoclaimedIncentives";
|
|
46
|
+
export * from "./pol/getBeraTokenTotalSupply";
|
|
54
47
|
export * from "./pol/getBgtAprSimulation";
|
|
48
|
+
export * from "./pol/getBgtIncentiveDistributorPaused";
|
|
55
49
|
export * from "./pol/getBlockTime";
|
|
56
50
|
export * from "./pol/getEarnedStakedBeraVault";
|
|
57
51
|
export * from "./pol/getGlobalData";
|
|
52
|
+
export * from "./pol/getHeroEarnVaults";
|
|
58
53
|
export * from "./pol/getIncentiveFeeClaimStats";
|
|
59
54
|
export * from "./pol/getLSTStakeConfig";
|
|
60
55
|
export * from "./pol/getMarkets";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./checkProposalField";
|
|
2
|
+
export * from "./computeActualStatus";
|
|
3
|
+
export * from "./getAllProposals";
|
|
4
|
+
export * from "./getBodyErrors";
|
|
5
|
+
export * from "./getDecodedFunctionData";
|
|
6
|
+
export * from "./getProposalDetails";
|
|
7
|
+
export * from "./getProposalFromTx";
|
|
8
|
+
export * from "./getProposalVotes";
|
|
9
|
+
export * from "./parseProposalBody";
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type Proposal_Filter,
|
|
7
|
-
type Proposal_OrderBy,
|
|
8
|
-
type ProposalSelectionFragment,
|
|
9
|
-
SearchProposals,
|
|
10
|
-
type SearchProposalsQuery,
|
|
11
|
-
type SearchProposalsQueryVariables,
|
|
1
|
+
import type {
|
|
2
|
+
OrderDirection,
|
|
3
|
+
Proposal_Filter,
|
|
4
|
+
Proposal_OrderBy,
|
|
5
|
+
ProposalSelectionFragment,
|
|
12
6
|
} from "@berachain/graphql/governance";
|
|
13
7
|
|
|
14
|
-
import { getApolloClient } from "../clients/getApolloClient";
|
|
15
|
-
import { computeActualStatus } from "./computeActualStatus";
|
|
16
|
-
|
|
17
8
|
export type GetAllProposalsArgs = BeraJS.BaseFunctionArgs & {
|
|
18
9
|
/** Subgraph filter applied to the proposals query */
|
|
19
10
|
where: Proposal_Filter;
|
|
@@ -28,55 +19,9 @@ export type GetAllProposalsArgs = BeraJS.BaseFunctionArgs & {
|
|
|
28
19
|
};
|
|
29
20
|
|
|
30
21
|
/** Fetches a paginated list of governance proposals from the subgraph */
|
|
31
|
-
export async function getAllProposals(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
perPage = 20,
|
|
37
|
-
text,
|
|
38
|
-
...args
|
|
39
|
-
}: GetAllProposalsArgs): Promise<ProposalSelectionFragment[] | undefined> {
|
|
40
|
-
try {
|
|
41
|
-
if (perPage > 1000) {
|
|
42
|
-
throw new Error("perPage must be less than 1000");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const governanceClient = getApolloClient("governance.subgraph", args);
|
|
46
|
-
const [response] = await Promise.all([
|
|
47
|
-
text
|
|
48
|
-
? governanceClient.query<
|
|
49
|
-
SearchProposalsQuery,
|
|
50
|
-
SearchProposalsQueryVariables
|
|
51
|
-
>({
|
|
52
|
-
query: SearchProposals,
|
|
53
|
-
variables: {
|
|
54
|
-
offset,
|
|
55
|
-
limit: perPage,
|
|
56
|
-
where,
|
|
57
|
-
text,
|
|
58
|
-
},
|
|
59
|
-
})
|
|
60
|
-
: governanceClient.query<GetProposalsQuery, GetProposalsQueryVariables>(
|
|
61
|
-
{
|
|
62
|
-
query: GetProposals,
|
|
63
|
-
variables: {
|
|
64
|
-
offset,
|
|
65
|
-
limit: perPage,
|
|
66
|
-
where,
|
|
67
|
-
orderBy,
|
|
68
|
-
orderDirection,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
),
|
|
72
|
-
]);
|
|
73
|
-
|
|
74
|
-
return response.data.proposals.map((p) => ({
|
|
75
|
-
...p,
|
|
76
|
-
status: computeActualStatus(p),
|
|
77
|
-
}));
|
|
78
|
-
} catch (e) {
|
|
79
|
-
console.error("getAllProposals:", e);
|
|
80
|
-
throw e;
|
|
81
|
-
}
|
|
22
|
+
export async function getAllProposals(
|
|
23
|
+
_args: GetAllProposalsArgs,
|
|
24
|
+
): Promise<ProposalSelectionFragment[] | undefined> {
|
|
25
|
+
// Governance subgraph not live — return empty until indexer is available
|
|
26
|
+
return [];
|
|
82
27
|
}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { PublicClient } from "viem";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
GetProposal,
|
|
5
|
-
type GetProposalQuery,
|
|
6
|
-
type GetProposalQueryVariables,
|
|
7
|
-
type ProposalWithVotesFragment,
|
|
8
|
-
} from "@berachain/graphql/governance";
|
|
9
|
-
|
|
10
|
-
import { getApolloClient } from "../clients/getApolloClient";
|
|
11
|
-
import { computeActualStatus } from "./computeActualStatus";
|
|
3
|
+
import type { ProposalWithVotesFragment } from "@berachain/graphql/governance";
|
|
12
4
|
|
|
13
5
|
export type GetProposalDetailsArgs = BeraJS.BaseFunctionArgs & {
|
|
14
6
|
/** On-chain proposal ID */
|
|
@@ -17,28 +9,9 @@ export type GetProposalDetailsArgs = BeraJS.BaseFunctionArgs & {
|
|
|
17
9
|
};
|
|
18
10
|
|
|
19
11
|
/** Fetches a single proposal with its vote data from the subgraph */
|
|
20
|
-
export async function getProposalDetails(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const res = await governanceClient.query<
|
|
27
|
-
GetProposalQuery,
|
|
28
|
-
GetProposalQueryVariables
|
|
29
|
-
>({
|
|
30
|
-
query: GetProposal,
|
|
31
|
-
variables: {
|
|
32
|
-
id: proposalId,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if (!res.data.proposal) {
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
...res.data.proposal,
|
|
42
|
-
status: computeActualStatus(res.data.proposal),
|
|
43
|
-
} as ProposalWithVotesFragment;
|
|
12
|
+
export async function getProposalDetails(
|
|
13
|
+
_args: GetProposalDetailsArgs,
|
|
14
|
+
): Promise<ProposalWithVotesFragment | undefined> {
|
|
15
|
+
// Governance subgraph not live — return undefined until indexer is available
|
|
16
|
+
return undefined;
|
|
44
17
|
}
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type GetProposalVotesQueryVariables,
|
|
1
|
+
import type {
|
|
2
|
+
GetProposalVotesQuery,
|
|
3
|
+
GetProposalVotesQueryVariables,
|
|
5
4
|
} from "@berachain/graphql/governance";
|
|
6
5
|
|
|
7
|
-
import { getApolloClient } from "../clients/getApolloClient";
|
|
8
|
-
|
|
9
6
|
export type GetProposalVotesArgs = BeraJS.BaseFunctionArgs & {
|
|
10
7
|
/** GraphQL variables forwarded to the GetProposalVotes query */
|
|
11
8
|
variables: GetProposalVotesQueryVariables;
|
|
12
9
|
};
|
|
13
10
|
|
|
14
11
|
/** Fetches the votes for a proposal from the subgraph */
|
|
15
|
-
export async function getProposalVotes(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return governanceClient.query<GetProposalVotesQuery>({
|
|
21
|
-
query: GetProposalVotes,
|
|
22
|
-
variables,
|
|
23
|
-
});
|
|
12
|
+
export async function getProposalVotes(
|
|
13
|
+
_args: GetProposalVotesArgs,
|
|
14
|
+
): Promise<{ data: GetProposalVotesQuery }> {
|
|
15
|
+
// Governance subgraph not live — return empty until indexer is available
|
|
16
|
+
return { data: { votes: [] } };
|
|
24
17
|
}
|