@berachain/berajs 0.2.8-beta.9 → 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-BRIiJgHk.d.ts → RequestError-DBOIV65x.d.ts} +1 -1
- package/dist/abi/exports.mjs +4452 -2
- package/dist/actions/clients/exports.d.ts +2 -0
- package/dist/actions/clients/exports.mjs +12 -0
- package/dist/actions/exports.d.ts +104 -189
- package/dist/actions/exports.mjs +853 -2
- 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-3EARVV7K.mjs +414 -0
- package/dist/chunk-4Z4AK6SH.mjs +211 -0
- package/dist/chunk-75M6TF7M.mjs +25 -0
- package/dist/chunk-AFN4CVD3.mjs +326 -0
- package/dist/chunk-BGMRHTBQ.mjs +23 -0
- package/dist/chunk-CDFWPU2R.mjs +473 -0
- package/dist/chunk-CDK4YV3D.mjs +571 -0
- package/dist/chunk-DKMAIU74.mjs +62 -0
- package/dist/chunk-EXIUPSFN.mjs +86 -0
- package/dist/chunk-FFB5LFDW.mjs +35 -0
- package/dist/chunk-HQCOU6GY.mjs +243 -0
- package/dist/chunk-HSSJKHZ4.mjs +135 -0
- package/dist/chunk-J5I45WGQ.mjs +1769 -0
- package/dist/chunk-KQUMKB66.mjs +89 -0
- package/dist/chunk-NBYLMO2L.mjs +14 -0
- package/dist/chunk-NPBQLVL3.mjs +80 -0
- package/dist/chunk-O2NQFKJK.mjs +170 -0
- package/dist/chunk-QJIXTYTZ.mjs +4054 -0
- package/dist/chunk-SGIJVHZO.mjs +12 -0
- package/dist/chunk-SZ5C44L5.mjs +35 -0
- package/dist/chunk-WXXOISTU.mjs +96 -0
- package/dist/chunk-XIYN6AL6.mjs +160 -0
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +85 -2
- package/dist/enum/exports.d.ts +1 -1
- package/dist/enum/exports.mjs +46 -2
- package/dist/enum/governance/exports.d.ts +60 -0
- package/dist/enum/governance/exports.mjs +14 -0
- package/dist/errors/exports.d.ts +4 -3
- package/dist/errors/exports.mjs +48 -2
- 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 +69 -211
- package/dist/hooks/exports.mjs +7434 -4
- 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 +15 -6
- package/dist/utils/exports.mjs +825 -2
- package/package.json +49 -13
- package/src/actions/__test/transports.ts +61 -0
- package/src/actions/clients/exports.ts +4 -0
- package/src/actions/clients/getApolloClient.ts +58 -23
- package/src/actions/clients/getEnsoClient.ts +20 -9
- 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 +4 -9
- 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 +19 -22
- 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 +7 -11
- 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 +7 -10
- 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/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 +13 -1
- 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 +2 -15
- package/src/hooks/governance/exports.ts +14 -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 +9 -3
- 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-DSUzJ1Iy.d.cts +0 -144
- package/dist/abi/exports.cjs +0 -2
- 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 -2
- package/dist/actions/exports.cjs.map +0 -1
- package/dist/actions/exports.d.cts +0 -1650
- package/dist/actions/exports.mjs.map +0 -1
- package/dist/chunk-45HIEVNI.cjs +0 -4
- package/dist/chunk-45HIEVNI.cjs.map +0 -1
- package/dist/chunk-47ILYVHC.mjs +0 -2
- package/dist/chunk-47ILYVHC.mjs.map +0 -1
- package/dist/chunk-575OK77P.mjs +0 -2
- package/dist/chunk-575OK77P.mjs.map +0 -1
- package/dist/chunk-5NVZG5N6.mjs +0 -2
- package/dist/chunk-5NVZG5N6.mjs.map +0 -1
- package/dist/chunk-6DIA6PXV.cjs +0 -2
- package/dist/chunk-6DIA6PXV.cjs.map +0 -1
- package/dist/chunk-6JJIZCVY.cjs +0 -2
- package/dist/chunk-6JJIZCVY.cjs.map +0 -1
- package/dist/chunk-7F72ZH4Q.mjs +0 -2
- package/dist/chunk-7F72ZH4Q.mjs.map +0 -1
- package/dist/chunk-AUA42YIG.mjs +0 -4
- package/dist/chunk-AUA42YIG.mjs.map +0 -1
- package/dist/chunk-BC2WX6O6.cjs +0 -2
- package/dist/chunk-BC2WX6O6.cjs.map +0 -1
- package/dist/chunk-CJOZC5Z2.cjs +0 -2
- package/dist/chunk-CJOZC5Z2.cjs.map +0 -1
- package/dist/chunk-D6L7LTA2.cjs +0 -2
- package/dist/chunk-D6L7LTA2.cjs.map +0 -1
- package/dist/chunk-DDEQFR3M.cjs +0 -2
- package/dist/chunk-DDEQFR3M.cjs.map +0 -1
- package/dist/chunk-GXV2JA36.mjs +0 -2
- package/dist/chunk-GXV2JA36.mjs.map +0 -1
- package/dist/chunk-ISYNEDET.mjs +0 -2
- package/dist/chunk-ISYNEDET.mjs.map +0 -1
- package/dist/chunk-JDDRTHFG.mjs +0 -2
- package/dist/chunk-JDDRTHFG.mjs.map +0 -1
- package/dist/chunk-JDZGYU5T.mjs +0 -2
- package/dist/chunk-JDZGYU5T.mjs.map +0 -1
- package/dist/chunk-LVOXBZMA.cjs +0 -2
- package/dist/chunk-LVOXBZMA.cjs.map +0 -1
- package/dist/chunk-MK5NS5B5.mjs +0 -2
- package/dist/chunk-MK5NS5B5.mjs.map +0 -1
- package/dist/chunk-NAXAZJJY.mjs +0 -2
- package/dist/chunk-NAXAZJJY.mjs.map +0 -1
- package/dist/chunk-NLVWRMGD.mjs +0 -2
- package/dist/chunk-NLVWRMGD.mjs.map +0 -1
- package/dist/chunk-OGBD5YOG.mjs +0 -2
- package/dist/chunk-OGBD5YOG.mjs.map +0 -1
- package/dist/chunk-OGJMSGB2.mjs +0 -2
- package/dist/chunk-OGJMSGB2.mjs.map +0 -1
- package/dist/chunk-OIYXOKTT.cjs +0 -2
- package/dist/chunk-OIYXOKTT.cjs.map +0 -1
- package/dist/chunk-OUD27MU7.cjs +0 -2
- package/dist/chunk-OUD27MU7.cjs.map +0 -1
- package/dist/chunk-PRLVZIKD.mjs +0 -2
- package/dist/chunk-PRLVZIKD.mjs.map +0 -1
- package/dist/chunk-Q2SNRLW3.cjs +0 -2
- package/dist/chunk-Q2SNRLW3.cjs.map +0 -1
- package/dist/chunk-REWME3FY.cjs +0 -2
- package/dist/chunk-REWME3FY.cjs.map +0 -1
- package/dist/chunk-RJN36GBU.mjs +0 -2
- package/dist/chunk-RJN36GBU.mjs.map +0 -1
- package/dist/chunk-RWOICHRW.cjs +0 -2
- package/dist/chunk-RWOICHRW.cjs.map +0 -1
- package/dist/chunk-S4CDSVLK.cjs +0 -2
- package/dist/chunk-S4CDSVLK.cjs.map +0 -1
- package/dist/chunk-SFEULGSX.cjs +0 -2
- package/dist/chunk-SFEULGSX.cjs.map +0 -1
- package/dist/chunk-WBTS6KFG.mjs +0 -2
- package/dist/chunk-WBTS6KFG.mjs.map +0 -1
- package/dist/chunk-WRFDB3QJ.cjs +0 -2
- package/dist/chunk-WRFDB3QJ.cjs.map +0 -1
- package/dist/chunk-XNJLSA6P.cjs +0 -2
- package/dist/chunk-XNJLSA6P.cjs.map +0 -1
- package/dist/contexts/exports.cjs +0 -2
- 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 -2
- 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 -2
- package/dist/errors/exports.cjs.map +0 -1
- package/dist/errors/exports.d.cts +0 -327
- 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 -4
- package/dist/hooks/exports.cjs.map +0 -1
- package/dist/hooks/exports.d.cts +0 -1734
- 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 -2
- package/dist/utils/exports.cjs.map +0 -1
- package/dist/utils/exports.d.cts +0 -420
- package/dist/utils/exports.mjs.map +0 -1
- package/src/actions/dex/getIsTokenExploited.ts +0 -63
- package/src/hooks/dex/useExploitedTokens.ts +0 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@berachain/berajs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -11,37 +11,73 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@apollo/client": "4.1.6",
|
|
14
|
-
"@berachain-foundation/berancer-sdk": "1.1.
|
|
15
|
-
"@berachain/abis": "0.1.
|
|
16
|
-
"@berachain/config": "0.1.
|
|
17
|
-
"@berachain/graphql": "0.4.
|
|
18
|
-
"@ensofinance/sdk": "2.
|
|
14
|
+
"@berachain-foundation/berancer-sdk": "1.1.7",
|
|
15
|
+
"@berachain/abis": "0.1.2",
|
|
16
|
+
"@berachain/config": "0.1.16",
|
|
17
|
+
"@berachain/graphql": "0.4.17",
|
|
18
|
+
"@ensofinance/sdk": "2.3.1",
|
|
19
19
|
"@pythnetwork/hermes-client": "2.0.0",
|
|
20
20
|
"@wagmi/core": "2.22.1",
|
|
21
21
|
"gray-matter": "4.0.3",
|
|
22
22
|
"swr": "2.4.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/react-dom": "19.
|
|
26
|
-
"@types/react": "19.
|
|
25
|
+
"@types/react-dom": "19.2.3",
|
|
26
|
+
"@types/react": "19.2.14",
|
|
27
27
|
"@typescript/analyze-trace": "0.10.1",
|
|
28
28
|
"tsup": "8.5.1",
|
|
29
29
|
"typescript": "5.5.4",
|
|
30
30
|
"viem": "2.45.0",
|
|
31
31
|
"vitest": "3.2.4",
|
|
32
32
|
"@berachain/utils": "0.1.0",
|
|
33
|
-
"@berachain/wagmi": "0.4.2"
|
|
33
|
+
"@berachain/wagmi": "0.4.2-beta.6"
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
36
|
+
"./actions/*": {
|
|
37
|
+
"types": "./dist/actions/*/exports.d.ts",
|
|
38
|
+
"import": "./dist/actions/*/exports.mjs",
|
|
39
|
+
"require": "./dist/actions/*/exports.cjs",
|
|
40
|
+
"default": "./dist/actions/*/exports.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./hooks/*": {
|
|
43
|
+
"types": "./dist/hooks/*/exports.d.ts",
|
|
44
|
+
"import": "./dist/hooks/*/exports.mjs",
|
|
45
|
+
"require": "./dist/hooks/*/exports.cjs",
|
|
46
|
+
"default": "./dist/hooks/*/exports.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./enum/*": {
|
|
49
|
+
"types": "./dist/enum/*/exports.d.ts",
|
|
50
|
+
"import": "./dist/enum/*/exports.mjs",
|
|
51
|
+
"require": "./dist/enum/*/exports.cjs",
|
|
52
|
+
"default": "./dist/enum/*/exports.cjs"
|
|
53
|
+
},
|
|
54
|
+
"./types/*": {
|
|
55
|
+
"types": "./dist/types/*/exports.d.ts",
|
|
56
|
+
"import": "./dist/types/*/exports.mjs",
|
|
57
|
+
"require": "./dist/types/*/exports.cjs",
|
|
58
|
+
"default": "./dist/types/*/exports.cjs"
|
|
59
|
+
},
|
|
36
60
|
"./*": {
|
|
37
61
|
"types": "./dist/*/exports.d.ts",
|
|
38
62
|
"import": "./dist/*/exports.mjs",
|
|
39
|
-
"
|
|
63
|
+
"require": "./dist/*/exports.cjs",
|
|
40
64
|
"default": "./dist/*/exports.cjs"
|
|
41
65
|
}
|
|
42
66
|
},
|
|
43
67
|
"typesVersions": {
|
|
44
68
|
"*": {
|
|
69
|
+
"actions/*": [
|
|
70
|
+
"dist/actions/*/exports.d.ts"
|
|
71
|
+
],
|
|
72
|
+
"hooks/*": [
|
|
73
|
+
"dist/hooks/*/exports.d.ts"
|
|
74
|
+
],
|
|
75
|
+
"enum/*": [
|
|
76
|
+
"dist/enum/*/exports.d.ts"
|
|
77
|
+
],
|
|
78
|
+
"types/*": [
|
|
79
|
+
"dist/types/*/exports.d.ts"
|
|
80
|
+
],
|
|
45
81
|
"*": [
|
|
46
82
|
"dist/*/exports.d.ts"
|
|
47
83
|
]
|
|
@@ -51,7 +87,7 @@
|
|
|
51
87
|
"react": "^19.1",
|
|
52
88
|
"react-dom": "^19.1",
|
|
53
89
|
"viem": "^2.41.2",
|
|
54
|
-
"@berachain/wagmi": "0.4.2"
|
|
90
|
+
"@berachain/wagmi": "0.4.2-beta.6"
|
|
55
91
|
},
|
|
56
92
|
"peerDependenciesMeta": {
|
|
57
93
|
"react": {
|
|
@@ -65,11 +101,11 @@
|
|
|
65
101
|
}
|
|
66
102
|
},
|
|
67
103
|
"scripts": {
|
|
68
|
-
"build": "tsup",
|
|
104
|
+
"build": "NODE_OPTIONS='--max-old-space-size=8192' tsup",
|
|
69
105
|
"prebuild": "pnpm contracts:update",
|
|
70
106
|
"test": "vitest",
|
|
71
107
|
"clean": "git clean -xdf dist .turbo node_modules",
|
|
72
|
-
"check-types": "tsup --dtsOnly",
|
|
108
|
+
"check-types": "NODE_OPTIONS='--max-old-space-size=8192' tsup --dtsOnly",
|
|
73
109
|
"precheck-types": "pnpm prebuild",
|
|
74
110
|
"dev": "tsup --watch",
|
|
75
111
|
"lint": "biome lint",
|
|
@@ -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
|
+
};
|
|
@@ -80,28 +80,68 @@ function getClient(
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
+
}
|
|
91
112
|
|
|
92
113
|
export function getApolloClient(
|
|
93
114
|
clientName: GraphqlClient,
|
|
94
115
|
{ ...args }: BeraJS.BaseFunctionArgs,
|
|
95
116
|
): BeraApolloClient {
|
|
96
|
-
|
|
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
|
+
}
|
|
97
134
|
|
|
98
135
|
switch (clientName) {
|
|
99
136
|
case "api":
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
137
|
+
return store(
|
|
138
|
+
cacheKey,
|
|
139
|
+
getClient(applyStellateClientName(config.api), {
|
|
140
|
+
inMemoryCacheOptions: {
|
|
141
|
+
possibleTypes: apiResults.possibleTypes,
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
);
|
|
105
145
|
|
|
106
146
|
case "bend.whisk":
|
|
107
147
|
if (!config.bend.whiskApi) {
|
|
@@ -110,17 +150,12 @@ export function getApolloClient(
|
|
|
110
150
|
level: "error",
|
|
111
151
|
});
|
|
112
152
|
}
|
|
113
|
-
return getClient(config.bend.whiskApi);
|
|
153
|
+
return store(cacheKey, getClient(config.bend.whiskApi));
|
|
114
154
|
|
|
115
155
|
case "honey.subgraph":
|
|
116
|
-
return getClient(config.honey.subgraph);
|
|
156
|
+
return store(cacheKey, getClient(config.honey.subgraph));
|
|
157
|
+
|
|
117
158
|
case "pol.subgraph":
|
|
118
|
-
return getClient(config.pol.subgraph);
|
|
119
|
-
case "pol.fees":
|
|
120
|
-
return getClient(config.pol.feesSubgraph);
|
|
121
|
-
case "governance.subgraph":
|
|
122
|
-
return getClient(config.governance.subgraph);
|
|
123
|
-
case "bex.subgraph":
|
|
124
|
-
return getClient(config.bex.subgraph);
|
|
159
|
+
return store(cacheKey, getClient(config.pol.subgraph));
|
|
125
160
|
}
|
|
126
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,15 +25,6 @@ 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";
|
|
@@ -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
|
}
|