@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
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
|
|
15
15
|
import { getEnsoClient } from "../../actions/clients/getEnsoClient";
|
|
16
16
|
import { getBendMultiplyBundle } from "../../actions/enso/getBendMultiplyBundle";
|
|
17
|
+
import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
|
|
17
18
|
import { POLLING } from "../../enum/polling";
|
|
18
19
|
import { assertPublicClient } from "../../errors/assert";
|
|
19
20
|
import type { Token } from "../../types/dex";
|
|
@@ -65,6 +66,9 @@ export function useBendMultiply(
|
|
|
65
66
|
primaryAddress,
|
|
66
67
|
ensoWalletV2Address,
|
|
67
68
|
});
|
|
69
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
70
|
+
"proxyAggregatorsThroughVercel",
|
|
71
|
+
);
|
|
68
72
|
|
|
69
73
|
const QUERY_KEY =
|
|
70
74
|
collateralToken &&
|
|
@@ -99,6 +103,7 @@ export function useBendMultiply(
|
|
|
99
103
|
formattedCollateralPriceInLoanAsset,
|
|
100
104
|
ensoWalletV2Address,
|
|
101
105
|
isAuthorized,
|
|
106
|
+
proxyAggregatorsThroughVercel ?? false,
|
|
102
107
|
] as const)
|
|
103
108
|
: null;
|
|
104
109
|
|
|
@@ -120,6 +125,7 @@ export function useBendMultiply(
|
|
|
120
125
|
formattedCollateralPriceInLoanAsset,
|
|
121
126
|
ensoWalletV2Address,
|
|
122
127
|
isAuthorized,
|
|
128
|
+
proxyAggregatorsThroughVercel,
|
|
123
129
|
]) => {
|
|
124
130
|
assertPublicClient(publicClient);
|
|
125
131
|
|
|
@@ -146,7 +152,9 @@ export function useBendMultiply(
|
|
|
146
152
|
marketId,
|
|
147
153
|
primaryAddress,
|
|
148
154
|
chainId,
|
|
149
|
-
ensoClient: getEnsoClient(
|
|
155
|
+
ensoClient: getEnsoClient({
|
|
156
|
+
baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : undefined,
|
|
157
|
+
}),
|
|
150
158
|
slippage,
|
|
151
159
|
leverageMultiplier,
|
|
152
160
|
publicClient,
|
|
@@ -8,6 +8,7 @@ import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
|
8
8
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
9
9
|
|
|
10
10
|
import { ensoErc4626 } from "../../actions/dex/aggregators/enso/ensoErc4626";
|
|
11
|
+
import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
|
|
11
12
|
import { POLLING } from "../../enum/polling";
|
|
12
13
|
import {
|
|
13
14
|
assertAddress,
|
|
@@ -86,17 +87,24 @@ export function useBendZapSupply(
|
|
|
86
87
|
options,
|
|
87
88
|
);
|
|
88
89
|
|
|
89
|
-
const {
|
|
90
|
+
const {
|
|
91
|
+
data: zapSupplyAmount,
|
|
92
|
+
isLoading: isZapSupplyAmountLoading,
|
|
93
|
+
error: zapSupplyAmountError,
|
|
94
|
+
} = useGetConvertToAssets({
|
|
90
95
|
sharesAmount: BigInt(swrResponse.data?.amountOut ?? 0),
|
|
91
96
|
vaultAddress: bendVault.address,
|
|
97
|
+
vaultChainId: bendVault.chainId,
|
|
92
98
|
});
|
|
93
99
|
|
|
94
|
-
const { data: priceImpact } = usePriceImpact(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
const { data: priceImpact, isLoading: isPriceImpactLoading } = usePriceImpact(
|
|
101
|
+
{
|
|
102
|
+
tokenIn: tokenIn,
|
|
103
|
+
tokenOut: loanToken,
|
|
104
|
+
formattedAmountIn: amount,
|
|
105
|
+
formattedAmountOut: zapSupplyAmount?.formatted ?? "0",
|
|
106
|
+
},
|
|
107
|
+
);
|
|
100
108
|
|
|
101
109
|
const isCrossChain = tokenIn?.chainId && tokenIn.chainId !== berachainChainId;
|
|
102
110
|
|
|
@@ -135,7 +143,10 @@ export function useBendZapSupply(
|
|
|
135
143
|
return {
|
|
136
144
|
...swrResponse,
|
|
137
145
|
zapSupplyAmount,
|
|
146
|
+
zapSupplyAmountError,
|
|
147
|
+
isZapSupplyAmountLoading,
|
|
138
148
|
priceImpact,
|
|
149
|
+
isPriceImpactLoading,
|
|
139
150
|
hasInsufficientNativeBalance,
|
|
140
151
|
isCrossChain,
|
|
141
152
|
nativeFee,
|
|
@@ -157,8 +168,12 @@ export function useBendZapSupplyHelper(
|
|
|
157
168
|
options?: DefaultHookOptions,
|
|
158
169
|
) {
|
|
159
170
|
const { address: fromAddress } = useBeraWallet();
|
|
171
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
172
|
+
"proxyAggregatorsThroughVercel",
|
|
173
|
+
);
|
|
160
174
|
|
|
161
175
|
const isEnabled =
|
|
176
|
+
(options?.opts?.isEnabled ?? true) &&
|
|
162
177
|
!!tokenIn &&
|
|
163
178
|
!!loanToken &&
|
|
164
179
|
!!bendVault &&
|
|
@@ -173,12 +188,14 @@ export function useBendZapSupplyHelper(
|
|
|
173
188
|
const QUERY_KEY = isEnabled
|
|
174
189
|
? ([
|
|
175
190
|
"useBendZapSupply",
|
|
191
|
+
fromAddress,
|
|
176
192
|
tokenIn,
|
|
177
193
|
loanToken,
|
|
178
194
|
bendVault,
|
|
179
195
|
rewardVault,
|
|
180
196
|
amount,
|
|
181
197
|
slippage,
|
|
198
|
+
proxyAggregatorsThroughVercel ?? false,
|
|
182
199
|
] as const)
|
|
183
200
|
: null;
|
|
184
201
|
|
|
@@ -186,6 +203,7 @@ export function useBendZapSupplyHelper(
|
|
|
186
203
|
QUERY_KEY,
|
|
187
204
|
async ([
|
|
188
205
|
,
|
|
206
|
+
fromAddress,
|
|
189
207
|
tokenIn,
|
|
190
208
|
loanToken,
|
|
191
209
|
bendVault,
|
|
@@ -206,6 +224,7 @@ export function useBendZapSupplyHelper(
|
|
|
206
224
|
slippage,
|
|
207
225
|
account: fromAddress,
|
|
208
226
|
rewardVault,
|
|
227
|
+
proxyAggregatorsThroughVercel,
|
|
209
228
|
});
|
|
210
229
|
},
|
|
211
230
|
{
|
|
@@ -10,6 +10,7 @@ import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
|
|
|
10
10
|
|
|
11
11
|
import { getEnsoClient } from "../../actions/clients/getEnsoClient";
|
|
12
12
|
import { getEnsoSwapBundle } from "../../actions/enso/getEnsoSwapBundle";
|
|
13
|
+
import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
|
|
13
14
|
import { POLLING } from "../../enum/polling";
|
|
14
15
|
import {
|
|
15
16
|
assertAddress,
|
|
@@ -45,7 +46,12 @@ export function useEnsoSwapBundle({
|
|
|
45
46
|
}) {
|
|
46
47
|
const { address: fromAddress } = useBeraWallet();
|
|
47
48
|
const wagmiConfig = useConfig();
|
|
48
|
-
const
|
|
49
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
50
|
+
"proxyAggregatorsThroughVercel",
|
|
51
|
+
);
|
|
52
|
+
const ensoClient = getEnsoClient({
|
|
53
|
+
baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : undefined,
|
|
54
|
+
});
|
|
49
55
|
|
|
50
56
|
const { refresh: refreshBalances } = usePollWalletBalances();
|
|
51
57
|
|
|
@@ -59,12 +65,20 @@ export function useEnsoSwapBundle({
|
|
|
59
65
|
!!tokenIn.chainId;
|
|
60
66
|
|
|
61
67
|
const QUERY_KEY = isEnabled
|
|
62
|
-
? ([
|
|
68
|
+
? ([
|
|
69
|
+
"useEnsoSwapBundle",
|
|
70
|
+
fromAddress,
|
|
71
|
+
tokenIn,
|
|
72
|
+
tokenOut,
|
|
73
|
+
amount,
|
|
74
|
+
slippage,
|
|
75
|
+
proxyAggregatorsThroughVercel ?? false,
|
|
76
|
+
] as const)
|
|
63
77
|
: null;
|
|
64
78
|
|
|
65
79
|
const swrResponse = useSWR(
|
|
66
80
|
QUERY_KEY,
|
|
67
|
-
async ([, tokenIn, tokenOut, amount, slippage]) => {
|
|
81
|
+
async ([, fromAddress, tokenIn, tokenOut, amount, slippage]) => {
|
|
68
82
|
assertAddress(fromAddress, "fromAddress");
|
|
69
83
|
assertAddress(tokenIn?.address, "tokenInAddress");
|
|
70
84
|
assertDefined(tokenIn?.chainId, "tokenInChainId");
|
|
@@ -4,6 +4,7 @@ import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
|
|
|
4
4
|
|
|
5
5
|
import { getEnsoClient } from "../../actions/clients/getEnsoClient";
|
|
6
6
|
import { getEnsoUserTokensWithBalances } from "../../actions/enso/getEnsoUserTokensWithBalances";
|
|
7
|
+
import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
|
|
7
8
|
import { POLLING } from "../../enum/polling";
|
|
8
9
|
import type { BalanceToken } from "../../types/dex";
|
|
9
10
|
import type { DefaultHookOptions } from "../../types/global";
|
|
@@ -14,11 +15,19 @@ export function useEnsoUserTokensWithBalances(
|
|
|
14
15
|
) {
|
|
15
16
|
const { address: fromAddress } = useBeraWallet();
|
|
16
17
|
const wagmiConfig = useConfig();
|
|
18
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
19
|
+
"proxyAggregatorsThroughVercel",
|
|
20
|
+
);
|
|
17
21
|
const isEnabled = !!fromAddress && (options?.opts?.isEnabled ?? true);
|
|
18
22
|
|
|
19
23
|
const QUERY_KEY =
|
|
20
24
|
isEnabled && wagmiConfig
|
|
21
|
-
? ([
|
|
25
|
+
? ([
|
|
26
|
+
"useEnsoUserTokensWithBalances",
|
|
27
|
+
fromAddress,
|
|
28
|
+
chainId,
|
|
29
|
+
proxyAggregatorsThroughVercel ?? false,
|
|
30
|
+
] as const)
|
|
22
31
|
: null;
|
|
23
32
|
|
|
24
33
|
const swrResponse = useSWR(
|
|
@@ -28,7 +37,9 @@ export function useEnsoUserTokensWithBalances(
|
|
|
28
37
|
account: fromAddress,
|
|
29
38
|
wagmiConfig,
|
|
30
39
|
chainId: chainId ?? "all",
|
|
31
|
-
ensoClient: getEnsoClient(
|
|
40
|
+
ensoClient: getEnsoClient({
|
|
41
|
+
baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : undefined,
|
|
42
|
+
}),
|
|
32
43
|
}),
|
|
33
44
|
{
|
|
34
45
|
refreshInterval: POLLING.NORMAL,
|
package/src/hooks/exports.ts
CHANGED
|
@@ -13,7 +13,6 @@ export * from "./dex/useAllUserPools";
|
|
|
13
13
|
export * from "./dex/useApiPool";
|
|
14
14
|
export * from "./dex/useBexStatus";
|
|
15
15
|
export * from "./dex/useCreatePool";
|
|
16
|
-
export * from "./dex/useExploitedTokens";
|
|
17
16
|
export { useGlobalLiquidityAndSwapVolume } from "./dex/useGlobalLiquidityAndSwapVolume";
|
|
18
17
|
export * from "./dex/useLiquidityMismatch";
|
|
19
18
|
export * from "./dex/useLpPosition";
|
|
@@ -36,33 +35,20 @@ export * from "./enso/useBendZapSupply";
|
|
|
36
35
|
export * from "./enso/useEnsoSwapBundle";
|
|
37
36
|
export * from "./enso/useEnsoUserTokensWithBalances";
|
|
38
37
|
export * from "./enso/useZapStakeBera";
|
|
39
|
-
export { useCreateProposal } from "./governance/useCreateProposal";
|
|
40
|
-
export * from "./governance/useGetPastVotes";
|
|
41
|
-
export * from "./governance/useHasVoted";
|
|
42
|
-
export * from "./governance/useIsCanceller";
|
|
43
|
-
export * from "./governance/usePollAllProposals";
|
|
44
|
-
export * from "./governance/usePollProposal";
|
|
45
|
-
export * from "./governance/usePollProposalThreshold";
|
|
46
|
-
export * from "./governance/usePollProposalVotes";
|
|
47
|
-
export * from "./governance/usePollUserDelegates";
|
|
48
|
-
export * from "./governance/useProposalFromTx";
|
|
49
|
-
export * from "./governance/useProposalSnapshot";
|
|
50
|
-
export * from "./governance/useProposalState";
|
|
51
|
-
export * from "./governance/useProposalTimelockState";
|
|
52
|
-
export * from "./governance/useQuorum";
|
|
53
38
|
export * from "./honey/useCappedGlobally";
|
|
54
39
|
export * from "./honey/useCappedRelatively";
|
|
55
40
|
export * from "./honey/useCollateralWeights";
|
|
41
|
+
export * from "./honey/useHoney24hVolume";
|
|
56
42
|
export * from "./honey/useHoneyAlerts";
|
|
57
43
|
export * from "./honey/useHoneyBalances";
|
|
58
44
|
export * from "./honey/useHoneyChartData";
|
|
59
|
-
export * from "./honey/useHoneyGlobalData";
|
|
60
45
|
export * from "./honey/useHoneySwapState";
|
|
61
46
|
export * from "./honey/useHoneyVaultsBalance";
|
|
62
47
|
export * from "./honey/useIsBadCollateralAsset";
|
|
63
48
|
export * from "./honey/useIsBasketModeEnabled";
|
|
64
49
|
export * from "./honey/usePythLatestPrices";
|
|
65
50
|
export * from "./perps/usePythUpdateFee";
|
|
51
|
+
export { useAutoclaimedIncentives } from "./pol/useAutoclaimedIncentives";
|
|
66
52
|
export * from "./pol/useBgtAprSimulation";
|
|
67
53
|
export { useBgtUnstakedBalance } from "./pol/useBgtUnstakedBalance";
|
|
68
54
|
export { useClaimableFees } from "./pol/useClaimableFees";
|
|
@@ -126,6 +112,7 @@ export * from "./validators/useValidator";
|
|
|
126
112
|
export { useValidatorAnalytics } from "./validators/useValidatorAnalytics";
|
|
127
113
|
export { useValidatorCommission } from "./validators/useValidatorCommission";
|
|
128
114
|
export { useValidatorEstimatedBgtPerYear } from "./validators/useValidatorEstimatedBgtPerYear";
|
|
115
|
+
export { useValidatorIncentiveDistribution } from "./validators/useValidatorIncentiveDistribution";
|
|
129
116
|
export { useValidatorQueuedCommission } from "./validators/useValidatorQueuedCommission";
|
|
130
117
|
export { useValidatorQueuedOperatorAddress } from "./validators/useValidatorQueuedOperatorAddress";
|
|
131
118
|
export { useValidatorQueuedRewardAllocation } from "./validators/useValidatorQueuedRewardAllocation";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { useCreateProposal } from "./useCreateProposal";
|
|
2
|
+
export * from "./useGetPastVotes";
|
|
3
|
+
export * from "./useHasVoted";
|
|
4
|
+
export * from "./useIsCanceller";
|
|
5
|
+
export * from "./usePollAllProposals";
|
|
6
|
+
export * from "./usePollProposal";
|
|
7
|
+
export * from "./usePollProposalThreshold";
|
|
8
|
+
export * from "./usePollProposalVotes";
|
|
9
|
+
export * from "./usePollUserDelegates";
|
|
10
|
+
export * from "./useProposalFromTx";
|
|
11
|
+
export * from "./useProposalSnapshot";
|
|
12
|
+
export * from "./useProposalState";
|
|
13
|
+
export * from "./useProposalTimelockState";
|
|
14
|
+
export * from "./useQuorum";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
|
|
3
|
+
import { getHoney24hVolume } from "../../actions/honey/getHoney24hVolume";
|
|
4
|
+
import { POLLING } from "../../enum/polling";
|
|
5
|
+
|
|
6
|
+
export function useHoney24hVolume() {
|
|
7
|
+
const response = useSWR(["useHoney24hVolume"], () => getHoney24hVolume(), {
|
|
8
|
+
refreshInterval: POLLING.SLOW,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
...response,
|
|
13
|
+
|
|
14
|
+
refresh: () => response.mutate(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
|
|
3
|
+
import { useBeraWallet } from "@berachain/wagmi/hooks";
|
|
4
|
+
|
|
5
|
+
import { getAutoclaimedIncentives } from "../../actions/pol/getAutoclaimedIncentives";
|
|
6
|
+
import { BeraError } from "../../errors/BeraError";
|
|
7
|
+
import type { AutoclaimedIncentivesResponse } from "../../types/bribe-boost";
|
|
8
|
+
import type { DefaultHookReturnType } from "../../types/global";
|
|
9
|
+
|
|
10
|
+
interface UseAutoclaimedIncentivesArgs {
|
|
11
|
+
// Hard gate: when false the SWR key is null, so the API is never called.
|
|
12
|
+
// The banner consumer flips this to true only after both `!isBgtPolRewardToken`
|
|
13
|
+
// and `bgtIncentiveDistributor.paused() === true` have been verified.
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function useAutoclaimedIncentives({
|
|
18
|
+
enabled,
|
|
19
|
+
}: UseAutoclaimedIncentivesArgs): DefaultHookReturnType<AutoclaimedIncentivesResponse | null> {
|
|
20
|
+
const { address: account } = useBeraWallet();
|
|
21
|
+
|
|
22
|
+
const QUERY_KEY =
|
|
23
|
+
enabled && account
|
|
24
|
+
? (["useAutoclaimedIncentives", account] as const)
|
|
25
|
+
: null;
|
|
26
|
+
|
|
27
|
+
const swrResponse = useSWR(
|
|
28
|
+
QUERY_KEY,
|
|
29
|
+
async ([, account]) => {
|
|
30
|
+
if (!account) {
|
|
31
|
+
throw new BeraError({
|
|
32
|
+
message: "useAutoclaimedIncentives needs a logged in account",
|
|
33
|
+
level: "error",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return await getAutoclaimedIncentives({ account });
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
revalidateOnFocus: false,
|
|
40
|
+
revalidateOnReconnect: false,
|
|
41
|
+
revalidateIfStale: false,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
...swrResponse,
|
|
47
|
+
refresh: () => swrResponse?.mutate?.(),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -7,7 +7,7 @@ import type { DefaultHookReturnType } from "../../types/global";
|
|
|
7
7
|
import { dailyResolution } from "../../utils/filter";
|
|
8
8
|
|
|
9
9
|
type UseStakedAPR = {
|
|
10
|
-
|
|
10
|
+
timestamp: number;
|
|
11
11
|
apr: string;
|
|
12
12
|
}[];
|
|
13
13
|
export function useStakedAPR({
|
|
@@ -26,7 +26,7 @@ export function useStakedAPR({
|
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
return sortedStakedBeraSnapshots.map((item) => ({
|
|
29
|
-
|
|
29
|
+
timestamp: item.timestamp,
|
|
30
30
|
apr: item.apr,
|
|
31
31
|
}));
|
|
32
32
|
});
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import useSWR from "swr";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
3
|
|
|
4
|
+
import type { VaultStatsByDayResponse } from "@berachain/graphql/api";
|
|
5
|
+
|
|
4
6
|
import { getStakingDailyAssets } from "../../actions/pol/getStakingDailyAssets";
|
|
5
7
|
import type { DefaultHookReturnType } from "../../types/global";
|
|
6
8
|
import { dailyResolution } from "../../utils/filter";
|
|
7
9
|
|
|
8
|
-
type UseStakedBeraSnapshot = Record<
|
|
9
|
-
Address,
|
|
10
|
-
{
|
|
11
|
-
_timestamp: number;
|
|
12
|
-
total_assets: string;
|
|
13
|
-
}[]
|
|
14
|
-
>;
|
|
10
|
+
type UseStakedBeraSnapshot = Record<Address, VaultStatsByDayResponse>;
|
|
15
11
|
export function useStakedSnapshots({
|
|
16
12
|
range,
|
|
17
13
|
addresses,
|
|
@@ -30,7 +26,7 @@ export function useStakedSnapshots({
|
|
|
30
26
|
range,
|
|
31
27
|
});
|
|
32
28
|
const sortedStakingDailyAssets = dailyResolution(
|
|
33
|
-
unstakingDailyAssets.sort((a, b) => a.
|
|
29
|
+
unstakingDailyAssets.sort((a, b) => a.timestamp - b.timestamp),
|
|
34
30
|
);
|
|
35
31
|
return {
|
|
36
32
|
[address]: sortedStakingDailyAssets,
|
|
@@ -41,7 +37,7 @@ export function useStakedSnapshots({
|
|
|
41
37
|
// Merge all address data into a single object
|
|
42
38
|
return sortedStakingDailyAssetsArray.reduce(
|
|
43
39
|
(acc, addressData) => ({ ...acc, ...addressData }),
|
|
44
|
-
{} as
|
|
40
|
+
{} as UseStakedBeraSnapshot,
|
|
45
41
|
);
|
|
46
42
|
});
|
|
47
43
|
|
|
@@ -56,6 +56,8 @@ export function useValidator(
|
|
|
56
56
|
lastDayDistributedBGTAmount:
|
|
57
57
|
indexerValidator?.dynamicData?.lastDayDistributedBGTAmount ??
|
|
58
58
|
"",
|
|
59
|
+
lastDayProposedBlockCount:
|
|
60
|
+
indexerValidator?.dynamicData?.lastDayProposedBlockCount ?? 0,
|
|
59
61
|
activeBoostAmountRank:
|
|
60
62
|
indexerValidator?.dynamicData?.activeBoostAmountRank ?? 0,
|
|
61
63
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
|
|
4
|
+
import type { GetValidatorIncentiveDistributionQuery } from "@berachain/graphql/pol/subgraph";
|
|
5
|
+
|
|
6
|
+
import { getValidatorIncentiveDistribution } from "../../actions/validators/getValidatorIncentiveDistribution";
|
|
7
|
+
import { POLLING } from "../../enum/polling";
|
|
8
|
+
import type { DefaultHookReturnType } from "../../types/global";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Historical per-validator incentive distribution. Split from
|
|
12
|
+
* `useValidatorAnalytics` so the IncentivesEarned chart can switch data
|
|
13
|
+
* sources independently of the other charts that still consume the umbrella
|
|
14
|
+
* `GetValidatorAnalytics` query.
|
|
15
|
+
*/
|
|
16
|
+
export function useValidatorIncentiveDistribution({
|
|
17
|
+
pubkey,
|
|
18
|
+
dayRange,
|
|
19
|
+
}: {
|
|
20
|
+
pubkey: Address | undefined;
|
|
21
|
+
dayRange: number;
|
|
22
|
+
}): DefaultHookReturnType<GetValidatorIncentiveDistributionQuery> {
|
|
23
|
+
const QUERY_KEY =
|
|
24
|
+
pubkey && dayRange
|
|
25
|
+
? (["useValidatorIncentiveDistribution", pubkey, dayRange] as const)
|
|
26
|
+
: null;
|
|
27
|
+
|
|
28
|
+
const swrResponse = useSWR(
|
|
29
|
+
QUERY_KEY,
|
|
30
|
+
async ([, pubkey, dayRange]) => {
|
|
31
|
+
return await getValidatorIncentiveDistribution({ pubkey, dayRange });
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
refreshInterval: POLLING.SLOW,
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
39
|
+
}
|
|
@@ -32,6 +32,14 @@ export interface BribeBoostRewardProof {
|
|
|
32
32
|
| null;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// Response shape of GET /api/v1/wallets/:wallet/autoclaimed:
|
|
36
|
+
// { [wallet]: { [validatorPubkey]: { [tokenAddress]: rawAmount (stringified bigint) } } }
|
|
37
|
+
// Top-level wallet key is the lowercase wallet address that was queried.
|
|
38
|
+
export type AutoclaimedIncentivesResponse = Record<
|
|
39
|
+
Address,
|
|
40
|
+
Record<Address, Record<Address, string>>
|
|
41
|
+
>;
|
|
42
|
+
|
|
35
43
|
export interface BribeBoostValidatorApr {
|
|
36
44
|
id: string;
|
|
37
45
|
boost_total_bgt: string;
|
package/src/types/exports.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../governance.d";
|
package/src/utils/beraFetch.ts
CHANGED
|
@@ -1,32 +1,93 @@
|
|
|
1
|
+
import { BeraTracing, type SpanContext } from "../errors/BeraTracing";
|
|
1
2
|
import { RequestError } from "../errors/RequestError";
|
|
2
3
|
import { getErrorResponse } from "./getErrorResponse";
|
|
4
|
+
import { sanitizeRpcUrl } from "./sanitizeRpcUrl";
|
|
3
5
|
|
|
4
6
|
type RequestOptions = RequestInit;
|
|
5
7
|
|
|
6
8
|
export async function beraFetch(
|
|
7
9
|
endpoint: ConstructorParameters<typeof RequestError>[0]["endpoint"],
|
|
8
10
|
options?: RequestOptions,
|
|
11
|
+
spanContext?: SpanContext & {
|
|
12
|
+
/**
|
|
13
|
+
* If true, keep all query params in the span URL.
|
|
14
|
+
* If an array of strings, keep only the query params in the array.
|
|
15
|
+
* If false, remove all query params from the span URL.
|
|
16
|
+
* If not provided, remove all query params from the span URL.
|
|
17
|
+
*/
|
|
18
|
+
keepQueryParams?: boolean | string[];
|
|
19
|
+
},
|
|
9
20
|
) {
|
|
10
21
|
try {
|
|
11
|
-
|
|
22
|
+
let spanUrl = sanitizeRpcUrl(
|
|
12
23
|
typeof endpoint === "string" || endpoint instanceof URL
|
|
13
|
-
? endpoint
|
|
14
|
-
: endpoint.url,
|
|
24
|
+
? endpoint.toString()
|
|
25
|
+
: endpoint.url.toString(),
|
|
26
|
+
).replace(/0x[a-fA-F0-9]{40}/g, ":address");
|
|
27
|
+
|
|
28
|
+
if (spanContext?.keepQueryParams !== true && URL.canParse(spanUrl)) {
|
|
29
|
+
const queryParams = new URL(spanUrl).searchParams;
|
|
30
|
+
if (Array.isArray(spanContext?.keepQueryParams)) {
|
|
31
|
+
const searchParams = new URLSearchParams();
|
|
32
|
+
|
|
33
|
+
for (const param of spanContext.keepQueryParams) {
|
|
34
|
+
searchParams.set(param, queryParams.get(param) ?? "");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const newUrl = new URL(spanUrl);
|
|
38
|
+
newUrl.search = searchParams.toString();
|
|
39
|
+
spanUrl = newUrl.toString();
|
|
40
|
+
} else {
|
|
41
|
+
const newUrl = new URL(spanUrl);
|
|
42
|
+
newUrl.search = "";
|
|
43
|
+
spanUrl = newUrl.toString();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const endpointName =
|
|
48
|
+
typeof endpoint === "string" || endpoint instanceof URL
|
|
49
|
+
? undefined
|
|
50
|
+
: endpoint.name;
|
|
51
|
+
|
|
52
|
+
return await BeraTracing.startSpan(
|
|
15
53
|
{
|
|
16
|
-
|
|
54
|
+
op: "beraFetch",
|
|
55
|
+
name: endpointName ? `beraFetch ${endpointName}` : "beraFetch",
|
|
56
|
+
attributes:
|
|
57
|
+
typeof endpoint === "string" || endpoint instanceof URL
|
|
58
|
+
? {
|
|
59
|
+
"operation.source.url": spanUrl,
|
|
60
|
+
...spanContext?.attributes,
|
|
61
|
+
}
|
|
62
|
+
: ({
|
|
63
|
+
"operation.source.url": spanUrl,
|
|
64
|
+
"operation.source.type": endpoint.type,
|
|
65
|
+
"operation.source.name": endpoint.name,
|
|
66
|
+
...spanContext?.attributes,
|
|
67
|
+
} satisfies SpanContext["attributes"]),
|
|
68
|
+
},
|
|
69
|
+
async () => {
|
|
70
|
+
const response = await fetch(
|
|
71
|
+
typeof endpoint === "string" || endpoint instanceof URL
|
|
72
|
+
? endpoint
|
|
73
|
+
: endpoint.url,
|
|
74
|
+
{
|
|
75
|
+
...options,
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
const error = await getErrorResponse(response);
|
|
80
|
+
throw new RequestError({
|
|
81
|
+
cause: error,
|
|
82
|
+
// @to-do import getErrorResponse logic in this function
|
|
83
|
+
// when it's removed from other places
|
|
84
|
+
response: response,
|
|
85
|
+
endpoint,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return response;
|
|
17
89
|
},
|
|
18
90
|
);
|
|
19
|
-
if (!response.ok) {
|
|
20
|
-
const error = await getErrorResponse(response);
|
|
21
|
-
throw new RequestError({
|
|
22
|
-
cause: error,
|
|
23
|
-
// @to-do import getErrorResponse logic in this function
|
|
24
|
-
// when it's removed from other places
|
|
25
|
-
response: response,
|
|
26
|
-
endpoint,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return response;
|
|
30
91
|
} catch (error) {
|
|
31
92
|
if (error instanceof RequestError) {
|
|
32
93
|
throw error;
|
package/src/utils/exports.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
getRpcUrls,
|
|
8
8
|
} from "@berachain/config/internal";
|
|
9
9
|
|
|
10
|
+
import { tracedTransport } from "./tracedTransport";
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* This is a singleton to avoid creating a new client for each request.
|
|
12
14
|
*
|
|
@@ -31,10 +33,10 @@ export const getServerSidePublicClient = (
|
|
|
31
33
|
rpcs.publicJsonRpcUrl,
|
|
32
34
|
]
|
|
33
35
|
.filter((i) => i)
|
|
34
|
-
.map((url) => http(url));
|
|
36
|
+
.map((url) => tracedTransport(http(url)));
|
|
35
37
|
|
|
36
38
|
if (fallbackTransports.length === 0) {
|
|
37
|
-
fallbackTransports.push(http());
|
|
39
|
+
fallbackTransports.push(tracedTransport(http()));
|
|
38
40
|
}
|
|
39
41
|
const chain = chainId === ChainId.MAINNET ? berachain : berachainBepolia;
|
|
40
42
|
const client = createPublicClient({
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips secret tokens from RPC URLs for safe use in span attributes and logs.
|
|
3
|
+
*
|
|
4
|
+
* QuickNode URLs embed API keys as path segments, e.g.:
|
|
5
|
+
* https://polished-morning-sun.bera-mainnet.quiknode.pro/abc123def/
|
|
6
|
+
* This function trims the subpath, producing:
|
|
7
|
+
* https://polished-morning-sun.bera-mainnet.quiknode.pro/
|
|
8
|
+
*/
|
|
9
|
+
export function sanitizeRpcUrl(url: string | undefined): string {
|
|
10
|
+
if (!url) return "";
|
|
11
|
+
try {
|
|
12
|
+
const parsed = new URL(url);
|
|
13
|
+
if (parsed.hostname.endsWith(".quiknode.pro")) {
|
|
14
|
+
parsed.pathname = "/";
|
|
15
|
+
parsed.search = "";
|
|
16
|
+
return parsed.toString();
|
|
17
|
+
}
|
|
18
|
+
return url;
|
|
19
|
+
} catch {
|
|
20
|
+
return url;
|
|
21
|
+
}
|
|
22
|
+
}
|