@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
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { Abi } from 'viem';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Severity levels for error reporting.
|
|
5
|
-
* Mirrors Sentry's SeverityLevel for compatibility, but owned by berajs
|
|
6
|
-
* so we don't depend on @sentry/nextjs.
|
|
7
|
-
*/
|
|
8
|
-
type SeverityLevel = "fatal" | "error" | "warning" | "log" | "info" | "debug";
|
|
9
|
-
|
|
10
|
-
interface IBeraErrorArgs {
|
|
11
|
-
message?: string;
|
|
12
|
-
displayMessage?: string;
|
|
13
|
-
cause?: unknown;
|
|
14
|
-
reason?: string;
|
|
15
|
-
chainId?: number;
|
|
16
|
-
fingerprint?: string[];
|
|
17
|
-
/**
|
|
18
|
-
* The level of the error to be used for error reporting.
|
|
19
|
-
*/
|
|
20
|
-
level?: SeverityLevel;
|
|
21
|
-
tags?: {
|
|
22
|
-
[key in TagsKey]?: Primitive;
|
|
23
|
-
};
|
|
24
|
-
extra?: Record<string, unknown>;
|
|
25
|
-
/**
|
|
26
|
-
* Optional ABI to be used to parse the error.
|
|
27
|
-
*/
|
|
28
|
-
abi?: Abi;
|
|
29
|
-
}
|
|
30
|
-
type Primitive = number | string | boolean | bigint | symbol | null | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* An helper type to make sure we only use the allowed tags. Sync this with docs/errors.md
|
|
33
|
-
*/
|
|
34
|
-
type TagsKey = "wallet.chain" | "wallet.connector" | "wallet.address" | "error.reason" | "operation.type" | "operation.key" | "operation.txn.functionName" | "operation.txn.to" | "operation.txn.status" | "operation.source.url" | "operation.source.name" | "operation.source.queryName" | "operation.source.type";
|
|
35
|
-
/**
|
|
36
|
-
* Base error class for the entire berajs SDK.
|
|
37
|
-
*
|
|
38
|
-
* All errors should be a BeraError or one of its subclasses. Unknown errors should be
|
|
39
|
-
* normalized via `initBeraError({ cause })`.
|
|
40
|
-
*
|
|
41
|
-
* Key design: the constructor runs an **automatic reason detection pipeline** when `reason`
|
|
42
|
-
* is not explicitly provided. It calls `parseViemError` on the `cause` to extract a
|
|
43
|
-
* machine-readable reason code (e.g. "NotEnoughBalance", "BAL#508", "UserRejectedRequestError").
|
|
44
|
-
* That reason is then matched against `errorMap.ts` to resolve a user-friendly `displayMessage`.
|
|
45
|
-
*
|
|
46
|
-
* This means: for most viem errors, you only need to pass `cause` and everything else
|
|
47
|
-
* (reason, displayMessage, level) is derived automatically.
|
|
48
|
-
*
|
|
49
|
-
* @see parseViemError — the reason extraction engine
|
|
50
|
-
* @see errorMap.ts — reason → displayMessage mapping
|
|
51
|
-
* @see initBeraError — normalizes any error into a BeraError (preferred entry point)
|
|
52
|
-
*/
|
|
53
|
-
declare class BeraError extends Error {
|
|
54
|
-
/**
|
|
55
|
-
* A human-readable message that can be displayed to end user.
|
|
56
|
-
*
|
|
57
|
-
* In berachain dapps, this is shown in the error pop-up.
|
|
58
|
-
*/
|
|
59
|
-
displayMessage: string;
|
|
60
|
-
/**
|
|
61
|
-
* The cause of the error.
|
|
62
|
-
*
|
|
63
|
-
* This is typically the error that was thrown.
|
|
64
|
-
*/
|
|
65
|
-
cause: unknown;
|
|
66
|
-
/**
|
|
67
|
-
* The chain id of the error.
|
|
68
|
-
*/
|
|
69
|
-
chainId?: number;
|
|
70
|
-
/**
|
|
71
|
-
* The code for the reason for the error.
|
|
72
|
-
*
|
|
73
|
-
* This is typically the error code can be found in the errorMap.ts file. I.e. NotEnoughBalance or BAL#508
|
|
74
|
-
*/
|
|
75
|
-
reason: string | null;
|
|
76
|
-
/**
|
|
77
|
-
* The fingerprint for the error.
|
|
78
|
-
*
|
|
79
|
-
* This is typically used to group errors in Sentry.
|
|
80
|
-
*/
|
|
81
|
-
fingerprint: string[] | undefined;
|
|
82
|
-
private _tags;
|
|
83
|
-
set tags(tags: {
|
|
84
|
-
[key: string | TagsKey]: Primitive;
|
|
85
|
-
});
|
|
86
|
-
get tags(): {
|
|
87
|
-
[key: string | TagsKey]: Primitive;
|
|
88
|
-
};
|
|
89
|
-
level: SeverityLevel;
|
|
90
|
-
extra: Record<string, unknown>;
|
|
91
|
-
constructor({ message: m, displayMessage: dm, cause, reason, level, abi, tags, chainId, fingerprint, }: IBeraErrorArgs);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { BeraError as B, type IBeraErrorArgs as I, type SeverityLevel as S };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { Dispatch, SetStateAction, PropsWithChildren } from 'react';
|
|
4
|
-
import { Hex } from 'viem';
|
|
5
|
-
import { EdgeConfigSchema } from '@berachain/config/internal/edge-config';
|
|
6
|
-
|
|
7
|
-
type FactoryStatus = {
|
|
8
|
-
/**
|
|
9
|
-
* If the composable stable factory is enabled
|
|
10
|
-
*/
|
|
11
|
-
composableStable: "paused" | "enabled";
|
|
12
|
-
/**
|
|
13
|
-
* If the weighted factory is enabled
|
|
14
|
-
*/
|
|
15
|
-
weighted: "paused" | "enabled";
|
|
16
|
-
};
|
|
17
|
-
interface BexStatusProviderProps {
|
|
18
|
-
isVaultPaused: boolean;
|
|
19
|
-
pool?: {
|
|
20
|
-
id: Hex;
|
|
21
|
-
isInRecoveryMode: boolean;
|
|
22
|
-
isPaused: boolean;
|
|
23
|
-
};
|
|
24
|
-
factories: FactoryStatus;
|
|
25
|
-
labels?: NonNullable<EdgeConfigSchema["bex"]>["emergencyLabels"];
|
|
26
|
-
}
|
|
27
|
-
declare const BexStateContext: react.Context<{
|
|
28
|
-
protocol: {
|
|
29
|
-
isPaused: boolean;
|
|
30
|
-
factories: FactoryStatus & {
|
|
31
|
-
allPaused: boolean;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
onPoolChange: Dispatch<SetStateAction<BexStatusProviderProps["pool"]>>;
|
|
35
|
-
pool?: {
|
|
36
|
-
id: Hex;
|
|
37
|
-
isInRecoveryMode: boolean;
|
|
38
|
-
isPaused: boolean;
|
|
39
|
-
disablePoolWithdrawals: boolean;
|
|
40
|
-
disablePoolDeposits: boolean;
|
|
41
|
-
};
|
|
42
|
-
labels?: NonNullable<EdgeConfigSchema["bex"]>["emergencyLabels"];
|
|
43
|
-
}>;
|
|
44
|
-
/**
|
|
45
|
-
* @description Determines the status of a pool or vault and returns the appropriate messages and flags to disable functionality.
|
|
46
|
-
* More information here https://www.notion.so/berachain/BEX-RecoveryMode-and-Pause-explained-17c6120abced80e0985dd589b57ff018
|
|
47
|
-
*
|
|
48
|
-
* @returns status flags to enable/disable/notify users across the BEX
|
|
49
|
-
*
|
|
50
|
-
**/
|
|
51
|
-
declare function useBexStatus(): {
|
|
52
|
-
protocol: {
|
|
53
|
-
isPaused: boolean;
|
|
54
|
-
factories: FactoryStatus & {
|
|
55
|
-
allPaused: boolean;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
onPoolChange: Dispatch<SetStateAction<BexStatusProviderProps["pool"]>>;
|
|
59
|
-
pool?: {
|
|
60
|
-
id: Hex;
|
|
61
|
-
isInRecoveryMode: boolean;
|
|
62
|
-
isPaused: boolean;
|
|
63
|
-
disablePoolWithdrawals: boolean;
|
|
64
|
-
disablePoolDeposits: boolean;
|
|
65
|
-
};
|
|
66
|
-
labels?: NonNullable<EdgeConfigSchema["bex"]>["emergencyLabels"];
|
|
67
|
-
};
|
|
68
|
-
declare function BexStatusProvider({ children, isVaultPaused, labels, factories, }: PropsWithChildren<BexStatusProviderProps>): react_jsx_runtime.JSX.Element;
|
|
69
|
-
|
|
70
|
-
export { BexStateContext as B, BexStatusProvider as a, type BexStatusProviderProps as b, useBexStatus as u };
|
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { Address, PublicClient, Abi, Hex } from 'viem';
|
|
4
|
-
import { Token as Token$1 } from '@berachain/graphql/pol/api';
|
|
5
|
-
import { SwapKind } from '@berachain-foundation/berancer-sdk';
|
|
6
|
-
import { H as HoneySwapAction } from './honey-CYm0RWf4.cjs';
|
|
7
|
-
|
|
8
|
-
interface CollateralRates {
|
|
9
|
-
mintFee: number;
|
|
10
|
-
redeemFee: number;
|
|
11
|
-
}
|
|
12
|
-
interface HoneyFeeMap {
|
|
13
|
-
single: Record<Address, CollateralRates>;
|
|
14
|
-
basket: CollateralRates;
|
|
15
|
-
}
|
|
16
|
-
interface CollateralRatesArgs extends BeraJS.BaseFunctionArgs {
|
|
17
|
-
client: PublicClient;
|
|
18
|
-
collateralList: Token$1[];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Fetches the mint and redeem rates for all collateral tokens and calculates the weighted basket rates
|
|
22
|
-
* @param {Object} params - The parameters object
|
|
23
|
-
* @param {PublicClient} params.client - The Viem public client instance
|
|
24
|
-
* @param {Address[]} params.collateralList - Array of collateral token addresses
|
|
25
|
-
* @returns {Promise<HoneyFeeMap | undefined>} Object containing individual collateral rates and weighted basket rates,
|
|
26
|
-
* or undefined if the operation fails
|
|
27
|
-
*/
|
|
28
|
-
declare function getHoneyFees({ client, collateralList, ...args }: CollateralRatesArgs): Promise<HoneyFeeMap>;
|
|
29
|
-
|
|
30
|
-
type MinimalERC20 = {
|
|
31
|
-
address: Address;
|
|
32
|
-
decimals: number;
|
|
33
|
-
symbol: string;
|
|
34
|
-
name: string;
|
|
35
|
-
chainId: number;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type TokenWithMetadata = MinimalERC20 & {
|
|
39
|
-
tags?: string[];
|
|
40
|
-
base64?: string;
|
|
41
|
-
logoURI?: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
type Token = TokenWithMetadata & {
|
|
45
|
-
totalSupply?: string;
|
|
46
|
-
weight?: number | string | null;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
interface TokenPriceInfo {
|
|
50
|
-
price: number;
|
|
51
|
-
updatedAt: number;
|
|
52
|
-
chainId: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type TokenCurrentPriceMap = Record<
|
|
56
|
-
Lowercase<Address> | string,
|
|
57
|
-
TokenPriceInfo | undefined
|
|
58
|
-
>;
|
|
59
|
-
|
|
60
|
-
interface TokenWithAmount extends Token {
|
|
61
|
-
amount: string;
|
|
62
|
-
exceeding?: boolean;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface TokenWithPrice extends Token {
|
|
66
|
-
price: number;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface BalanceToken extends Token {
|
|
70
|
-
balance: {
|
|
71
|
-
/**
|
|
72
|
-
* This is the string representation of the balance in wei.
|
|
73
|
-
*
|
|
74
|
-
* It can be safely parsed to a bigint, but we're returning it as a string to avoid serialization issues.
|
|
75
|
-
*
|
|
76
|
-
* @example "1200000000000000000"
|
|
77
|
-
*/
|
|
78
|
-
raw: string;
|
|
79
|
-
/**
|
|
80
|
-
* This is the formatted representation of the balance in the token's decimals.
|
|
81
|
-
*
|
|
82
|
-
* @example "1.2"
|
|
83
|
-
*/
|
|
84
|
-
formatted: string;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Price of the token in USD.
|
|
88
|
-
*/
|
|
89
|
-
price?: number;
|
|
90
|
-
/**
|
|
91
|
-
* Balance value in USD.
|
|
92
|
-
* Calculated as balance * price.
|
|
93
|
-
*/
|
|
94
|
-
usdValue?: number;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
interface SwapRequest {
|
|
98
|
-
tokenIn: Address;
|
|
99
|
-
tokenOut: Address;
|
|
100
|
-
tokenInDecimals: number;
|
|
101
|
-
tokenOutDecimals: number;
|
|
102
|
-
amount: string;
|
|
103
|
-
wberaIsBera: boolean;
|
|
104
|
-
swapKind: SwapKind;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Object with properties to check the allowance of a token.
|
|
109
|
-
*/
|
|
110
|
-
interface AllowanceQueryItem {
|
|
111
|
-
token: MinimalERC20;
|
|
112
|
-
/**
|
|
113
|
-
* The amount of the token to approve.
|
|
114
|
-
*/
|
|
115
|
-
amount: {
|
|
116
|
-
raw: string;
|
|
117
|
-
formatted: string;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* The address to approve the tokens to.
|
|
121
|
-
*/
|
|
122
|
-
spender: Address;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
interface AllowanceToken extends AllowanceQueryItem {
|
|
126
|
-
/**
|
|
127
|
-
* The current allowance of the token.
|
|
128
|
-
*/
|
|
129
|
-
allowance: {
|
|
130
|
-
raw: string;
|
|
131
|
-
formatted: string;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Whether the allowance is needed to perform the transaction.
|
|
135
|
-
*/
|
|
136
|
-
needsApproval: boolean;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
interface IUserPosition {
|
|
140
|
-
lpBalance?: BalanceToken;
|
|
141
|
-
tokenBalances?: Omit<BalanceToken, "chainId">[];
|
|
142
|
-
userSharePercentage?: number;
|
|
143
|
-
stakedBalance?: Pick<BalanceToken, "address" | "balance" | "usdValue">;
|
|
144
|
-
/**
|
|
145
|
-
* Just a utility to detect if there is a price for the LP token.
|
|
146
|
-
*/
|
|
147
|
-
lpTokenPrice?: number;
|
|
148
|
-
}
|
|
149
|
-
type BexStatus = {
|
|
150
|
-
protocol: {
|
|
151
|
-
/**
|
|
152
|
-
* If the whole protocol is paused (i.e. ~the~ vault contract) disable any functionality except withdrawing proportional
|
|
153
|
-
* liquidity (provided that pool's recovery mode is enabled). Specifically we disable swaps and pool creation.
|
|
154
|
-
*/
|
|
155
|
-
isPaused: boolean;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Pool is undefined if pool status is still loading if no pool address was provided.
|
|
159
|
-
*/
|
|
160
|
-
pool?: {
|
|
161
|
-
/**
|
|
162
|
-
* Pool should be put into recovery mode if tx are reverting on-chain to do with fee computation or pool exits.
|
|
163
|
-
* It reduces the computation needed to withdraw liquidity and does not charge protocol fees on exits while enabled.
|
|
164
|
-
*
|
|
165
|
-
* NOTE: that you can potentially still do regular exits/joins/etc in recovery mode, but if the flag is true will only
|
|
166
|
-
* present the safe exit option to the user in FE.
|
|
167
|
-
*/
|
|
168
|
-
isInRecoveryMode: boolean;
|
|
169
|
-
/**
|
|
170
|
-
* If the pool is paused you cannot do anything unless you also enable recovery mode (then you can withdraw safely).
|
|
171
|
-
*/
|
|
172
|
-
isPaused: boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Disable withdrawals for a pool due to a combination of pool and vault statuses.
|
|
175
|
-
*/
|
|
176
|
-
disablePoolWithdrawals: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* Disable deposits for a pool due to a combination of pool and vault statuses.
|
|
179
|
-
*/
|
|
180
|
-
disablePoolDeposits: boolean;
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
type IAggregatorArgs = {
|
|
185
|
-
tokenIn: MinimalERC20;
|
|
186
|
-
tokenOut: MinimalERC20;
|
|
187
|
-
/**
|
|
188
|
-
* Amount of tokenIn to swap in wei.
|
|
189
|
-
*/
|
|
190
|
-
amount: string;
|
|
191
|
-
slippage: number;
|
|
192
|
-
account?: Address;
|
|
193
|
-
publicClient?: PublicClient;
|
|
194
|
-
aggregatorsFeeBps?: number;
|
|
195
|
-
proxyAggregatorsThroughVercel?: boolean;
|
|
196
|
-
referrer?: SwapReferrer;
|
|
197
|
-
/**
|
|
198
|
-
* If provided, the aggregator will swap to the underlying token and deposit it into the vault (tokenOut).
|
|
199
|
-
*
|
|
200
|
-
* The aggregator won't check if the tokenOut is an ERC4626 vault, so this needs to be asserted by the caller.
|
|
201
|
-
* This is used for Staked BERA/iBera and Bend Vaults.
|
|
202
|
-
*/
|
|
203
|
-
underlyingToken?: MinimalERC20 | null;
|
|
204
|
-
/**
|
|
205
|
-
* If provided, the aggregator will stake into the reward vault after the swap.
|
|
206
|
-
*/
|
|
207
|
-
rewardVault?: Address;
|
|
208
|
-
/**
|
|
209
|
-
* Only needed by the honey mint/redeem aggregator.
|
|
210
|
-
*/
|
|
211
|
-
honeyNativeState?: Pick<HoneyConfigContextReturn, "collateralList">;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
type Calldata = {
|
|
215
|
-
params?: readonly unknown[] | undefined;
|
|
216
|
-
functionName?: string;
|
|
217
|
-
abi?: Abi;
|
|
218
|
-
address: Address;
|
|
219
|
-
data?: Hex;
|
|
220
|
-
value: bigint;
|
|
221
|
-
gasLimit?: bigint;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
type IRawAggregatorQuote = {
|
|
225
|
-
amountOut: string;
|
|
226
|
-
amountIn: string;
|
|
227
|
-
name: Aggregators;
|
|
228
|
-
allowanceRequirements: AllowanceQueryItem[];
|
|
229
|
-
/**
|
|
230
|
-
* True if it's bera wrap/unwrap or bgt redeem.
|
|
231
|
-
*/
|
|
232
|
-
isNativeSwap?: boolean;
|
|
233
|
-
priceImpactPercentage?: number | null;
|
|
234
|
-
swapFeeBps: number;
|
|
235
|
-
getCalldata?: ({ account }: { account: Address }) => Calldata;
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
type IAggregatorQuote =
|
|
239
|
-
// no need to force to swapAndStake as type check is done on each getQuote
|
|
240
|
-
IRawAggregatorQuote & {
|
|
241
|
-
amountOut: string;
|
|
242
|
-
amountOutUsd: string;
|
|
243
|
-
amountIn: string;
|
|
244
|
-
amountInUsd: string;
|
|
245
|
-
priceImpactPercentage: number;
|
|
246
|
-
exchangeRate: number;
|
|
247
|
-
relativeLossPercentage: number;
|
|
248
|
-
isBest?: boolean;
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Interface representing the latest Pyth price updates
|
|
253
|
-
* @interface PythLatestUpdates
|
|
254
|
-
* @property {`0x${string}`[]} calldata - Array of hex-encoded calldata for price updates
|
|
255
|
-
* @property {string[]} prices - Array of formatted price strings
|
|
256
|
-
*/
|
|
257
|
-
interface PythLatestUpdates {
|
|
258
|
-
calldata: `0x${string}`[];
|
|
259
|
-
prices: string[];
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Fetches the latest price updates from Pyth Network's Hermes service
|
|
263
|
-
* @param {Object} params - The parameters object
|
|
264
|
-
* @param {string[]} params.priceFeedId - Array of Pyth price feed IDs to fetch updates for
|
|
265
|
-
* @returns {Promise<PythLatestUpdates>} Promise resolving to the latest price updates
|
|
266
|
-
* @example
|
|
267
|
-
* ```ts
|
|
268
|
-
* const updates = await getPythLatestPrices({
|
|
269
|
-
* priceFeedId: ["0x123...", "0x456..."]
|
|
270
|
-
* });
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
declare function getPythLatestPrices({ priceFeedId, }: {
|
|
274
|
-
priceFeedId: string[];
|
|
275
|
-
}): Promise<PythLatestUpdates>;
|
|
276
|
-
|
|
277
|
-
declare enum HoneyPreviewMethod {
|
|
278
|
-
Mint = "previewMintHoney",
|
|
279
|
-
MintWithPrice = "previewMintHoneyWithPrices",
|
|
280
|
-
RequiredCollateral = "previewMintCollaterals",
|
|
281
|
-
RequiredCollateralWithPrice = "previewMintCollateralsWithPrices",
|
|
282
|
-
Redeem = "previewRedeemCollaterals",
|
|
283
|
-
RedeemWithPrice = "previewRedeemCollateralsWithPrices",
|
|
284
|
-
HoneyToRedeem = "previewRedeemHoney",
|
|
285
|
-
HoneyToRedeemWithPrice = "previewRedeemHoneyWithPrices"
|
|
286
|
-
}
|
|
287
|
-
interface HoneyPreviewArgs extends BeraJS.BaseFunctionArgs {
|
|
288
|
-
client: PublicClient;
|
|
289
|
-
collateral: Token;
|
|
290
|
-
collateralList: TokenWithOrder[];
|
|
291
|
-
amount: string;
|
|
292
|
-
method: HoneyPreviewMethod;
|
|
293
|
-
latestPrices?: PythLatestUpdates;
|
|
294
|
-
isPythWrapperEnabled: boolean;
|
|
295
|
-
}
|
|
296
|
-
interface HoneyPreviewResult {
|
|
297
|
-
collaterals: Record<Address, bigint>;
|
|
298
|
-
honey: bigint;
|
|
299
|
-
}
|
|
300
|
-
interface HoneyPreviewReadResult {
|
|
301
|
-
collaterals: bigint[];
|
|
302
|
-
honey: bigint;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Calculates preview amounts for Honey protocol operations including minting and redeeming.
|
|
306
|
-
* This function handles different preview methods to calculate either the amount of Honey tokens
|
|
307
|
-
* that can be minted with given collateral or the amount of collateral needed to mint/redeem Honey tokens.
|
|
308
|
-
*
|
|
309
|
-
* @param {Object} params - The parameters for the preview calculation
|
|
310
|
-
* @param {PublicClient} params.client - The Viem public client for blockchain interaction
|
|
311
|
-
* @param {Token} params.collateral - The primary collateral token being used
|
|
312
|
-
* @param {Address[]} params.collateralList - List of all supported collateral tokens
|
|
313
|
-
* @param {string} params.amount - The amount to calculate preview for (in token units)
|
|
314
|
-
* @param {HoneyPreviewMethod} params.method - The type of preview calculation to perform
|
|
315
|
-
* @param {PythLatestUpdates | undefined} params.latestPrices - Optional latest price updates from Pyth oracle
|
|
316
|
-
*
|
|
317
|
-
* @returns {Promise<HoneyPreviewResult | undefined>} An object containing:
|
|
318
|
-
* - collaterals: Record mapping collateral token addresses to their respective amounts
|
|
319
|
-
* - honey: The amount of Honey tokens involved in the operation
|
|
320
|
-
*
|
|
321
|
-
* @throws {Error} If there's an error during the contract interaction or calculation
|
|
322
|
-
*/
|
|
323
|
-
declare function getHoneyPreview({ client, collateral, collateralList, amount, method, latestPrices, isPythWrapperEnabled, ...baseArgs }: HoneyPreviewArgs): Promise<HoneyPreviewResult | undefined>;
|
|
324
|
-
|
|
325
|
-
type PythPriceFeedMap = Record<Address, Hex>;
|
|
326
|
-
|
|
327
|
-
type HoneySwapActions =
|
|
328
|
-
| { type: HoneySwapAction.RESET_AMOUNTS }
|
|
329
|
-
| { type: HoneySwapAction.ACTION_TYPE_CHANGE; value: "mint" | "redeem" }
|
|
330
|
-
| { type: HoneySwapAction.COLLATERALS_CHANGE; value: TokenWithOrder[] }
|
|
331
|
-
| { type: HoneySwapAction.FROM_AMOUNT_CHANGE; index: number; value: string }
|
|
332
|
-
| { type: HoneySwapAction.TO_AMOUNT_CHANGE; index: number; value: string }
|
|
333
|
-
| {
|
|
334
|
-
type: HoneySwapAction.PREVIEW_CHANGE;
|
|
335
|
-
value: HoneyPreviewResult;
|
|
336
|
-
changedAsset: Address;
|
|
337
|
-
}
|
|
338
|
-
| { type: HoneySwapAction.IS_BASKET_MODE_ENABLED_CHANGE; value: boolean }
|
|
339
|
-
| { type: HoneySwapAction.IS_TYPING_CHANGE; value: boolean }
|
|
340
|
-
| { type: HoneySwapAction.IS_SUBMITTING_CHANGE; value: boolean }
|
|
341
|
-
| { type: HoneySwapAction.IS_LOADING_CHANGE; value: boolean };
|
|
342
|
-
|
|
343
|
-
declare const HoneyConfigContext: react.Context<HoneyConfigContextReturn | undefined>;
|
|
344
|
-
type TokenWithOrder = TokenWithMetadata & {
|
|
345
|
-
order: number;
|
|
346
|
-
};
|
|
347
|
-
interface HoneyConfigContextReturn {
|
|
348
|
-
/**
|
|
349
|
-
* Map of the Pyth price feed ids for each collateral
|
|
350
|
-
*/
|
|
351
|
-
priceFeedMap: PythPriceFeedMap;
|
|
352
|
-
/**
|
|
353
|
-
* This is the list of all the collaterals that are supported by the Honey protocol
|
|
354
|
-
*/
|
|
355
|
-
collateralList: TokenWithOrder[];
|
|
356
|
-
/**
|
|
357
|
-
* This is the main collateral that is used to calculate the relative cap limit
|
|
358
|
-
*/
|
|
359
|
-
referenceCollateral: TokenWithOrder;
|
|
360
|
-
/**
|
|
361
|
-
* An object that maps the redeem/mint rate for each collateral and the weighted rates for the basket mode
|
|
362
|
-
*/
|
|
363
|
-
feeMap: HoneyFeeMap;
|
|
364
|
-
flags: {
|
|
365
|
-
/**
|
|
366
|
-
* If true, mint/redeem will also update pyth prices
|
|
367
|
-
*/
|
|
368
|
-
isPythWrapperEnabled: boolean;
|
|
369
|
-
};
|
|
370
|
-
/**
|
|
371
|
-
* Honey protocol configs
|
|
372
|
-
*/
|
|
373
|
-
protocol: {
|
|
374
|
-
/**
|
|
375
|
-
* Honey protocol paused state
|
|
376
|
-
*/
|
|
377
|
-
isPaused: boolean;
|
|
378
|
-
/**
|
|
379
|
-
* The label for the Honey protocol paused message
|
|
380
|
-
*/
|
|
381
|
-
pausedBannerLabel?: string;
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
interface HoneyConfigProviderProps extends HoneyConfigContextReturn {
|
|
385
|
-
children: React.ReactNode;
|
|
386
|
-
}
|
|
387
|
-
declare function HoneyConfigProvider({ children, ...props }: HoneyConfigProviderProps): react_jsx_runtime.JSX.Element;
|
|
388
|
-
declare function useHoneyConfig(): HoneyConfigContextReturn;
|
|
389
|
-
|
|
390
|
-
export { type AllowanceQueryItem as A, type BalanceToken as B, type CollateralRates as C, type TokenWithPrice as D, type HoneySwapActions as H, type IAggregatorArgs as I, type MinimalERC20 as M, type PythLatestUpdates as P, type SwapRequest as S, type TokenWithOrder as T, type TokenWithMetadata as a, type Token as b, HoneyConfigContext as c, type HoneyConfigContextReturn as d, HoneyConfigProvider as e, type HoneyConfigProviderProps as f, type IRawAggregatorQuote as g, type PythPriceFeedMap as h, type TokenCurrentPriceMap as i, type AllowanceToken as j, type CollateralRatesArgs as k, type HoneyFeeMap as l, type HoneyPreviewArgs as m, HoneyPreviewMethod as n, type HoneyPreviewReadResult as o, type HoneyPreviewResult as p, getHoneyFees as q, getHoneyPreview as r, getPythLatestPrices as s, type TokenWithAmount as t, useHoneyConfig as u, type IUserPosition as v, type Calldata as w, type TokenPriceInfo as x, type BexStatus as y, type IAggregatorQuote as z };
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { ErrorLike } from '@apollo/client';
|
|
2
|
-
import { B as BeraError, I as IBeraErrorArgs } from './BeraError-_mQdkanr.cjs';
|
|
3
|
-
|
|
4
|
-
interface EventsMap {
|
|
5
|
-
[event: string]: any;
|
|
6
|
-
}
|
|
7
|
-
interface DefaultEvents extends EventsMap {
|
|
8
|
-
[event: string]: (...args: any) => void;
|
|
9
|
-
}
|
|
10
|
-
type Unsubscribe = () => void;
|
|
11
|
-
/**
|
|
12
|
-
* An interface for mixins that expose the `on` function (without the emitter
|
|
13
|
-
* bound to `this`)
|
|
14
|
-
*
|
|
15
|
-
* ```js
|
|
16
|
-
* import { createEmitter } from '~utils/createEmitter'
|
|
17
|
-
*
|
|
18
|
-
* class Ticker implements EmitterMixin<Events> {
|
|
19
|
-
* constructor() {
|
|
20
|
-
* this.emitter = createEmitter()
|
|
21
|
-
* }
|
|
22
|
-
* on(...args) {
|
|
23
|
-
* return this.emitter.on(...args)
|
|
24
|
-
* }
|
|
25
|
-
* tick() {
|
|
26
|
-
* this.emitter.emit('tick')
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
interface EmitterMixin<Events extends EventsMap = DefaultEvents> {
|
|
32
|
-
on<K extends keyof Events>(event: K, cb: Events[K]): Unsubscribe;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Span context passed to tracing handlers.
|
|
37
|
-
* Compatible with Sentry's StartSpanOptions (name, op, attributes).
|
|
38
|
-
*/
|
|
39
|
-
type SpanContext = {
|
|
40
|
-
name: string;
|
|
41
|
-
op: string;
|
|
42
|
-
attributes: Record<string, string | number | boolean | undefined>;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* A function that wraps a callback in a tracing span.
|
|
46
|
-
* Compatible with Sentry.startSpan's signature.
|
|
47
|
-
*/
|
|
48
|
-
type StartSpanFn = <T>(context: SpanContext, callback: () => Promise<T>) => Promise<T>;
|
|
49
|
-
/**
|
|
50
|
-
* A generic span-tracing module for berajs.
|
|
51
|
-
*
|
|
52
|
-
* Instead of calling Sentry.startSpan directly, berajs calls
|
|
53
|
-
* `BeraTracing.startSpan()`. Consumer apps subscribe via `.on("span", handler)`
|
|
54
|
-
* and forward spans to their tracing provider (Sentry, Datadog, etc.).
|
|
55
|
-
*
|
|
56
|
-
* Multiple handlers are supported and chain in registration order:
|
|
57
|
-
* the first registered handler is the outermost wrapper.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* // In berajs code:
|
|
62
|
-
* import { BeraTracing } from "./BeraTracing";
|
|
63
|
-
* const result = await BeraTracing.startSpan(
|
|
64
|
-
* { name: "GraphQL query", op: "graphql.query", attributes: {} },
|
|
65
|
-
* () => executeQuery(),
|
|
66
|
-
* );
|
|
67
|
-
*
|
|
68
|
-
* // In app instrumentation:
|
|
69
|
-
* import { BeraTracing } from "@berachain/berajs/errors";
|
|
70
|
-
* BeraTracing.addSpanHandler(Sentry.startSpan);
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
declare const BeraTracing: {
|
|
74
|
-
/**
|
|
75
|
-
* Execute a callback, wrapping it in all registered span handlers.
|
|
76
|
-
*
|
|
77
|
-
* Handlers chain so each wraps the next. First registered = outermost wrapper.
|
|
78
|
-
* If no handlers are registered, the callback is executed directly.
|
|
79
|
-
*/
|
|
80
|
-
startSpan<T>(context: SpanContext, callback: () => Promise<T>): Promise<T>;
|
|
81
|
-
/**
|
|
82
|
-
* Register a span tracing handler.
|
|
83
|
-
*
|
|
84
|
-
* @param _event - Must be "span". Exists for API consistency with BeraMonitoring.
|
|
85
|
-
* @param handler - A StartSpanFn, e.g. Sentry.startSpan.
|
|
86
|
-
* @returns An unsubscribe function to remove the handler.
|
|
87
|
-
*/
|
|
88
|
-
addSpanHandler(handler: StartSpanFn): Unsubscribe;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* This is an error class that should be used to handle errors from fetch requests.
|
|
93
|
-
*/
|
|
94
|
-
declare class RequestError extends BeraError {
|
|
95
|
-
/**
|
|
96
|
-
* The error response from the request.
|
|
97
|
-
*/
|
|
98
|
-
response: Response | ErrorLike | undefined;
|
|
99
|
-
static isCorsError(error: Error): boolean;
|
|
100
|
-
/**
|
|
101
|
-
* The endpoint that was requested.
|
|
102
|
-
*/
|
|
103
|
-
endpoint: {
|
|
104
|
-
name?: string;
|
|
105
|
-
url: string;
|
|
106
|
-
type?: "rest" | "graphql" | "rpc";
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* A list of domains that should have their query params removed.
|
|
110
|
-
*/
|
|
111
|
-
private queryRichfulDomains;
|
|
112
|
-
statusCode: number | undefined;
|
|
113
|
-
payload?: object;
|
|
114
|
-
static readonly REASON_MAP: {
|
|
115
|
-
readonly 429: "RATE_LIMITED_429";
|
|
116
|
-
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
117
|
-
readonly CORS_ERROR: "CORS";
|
|
118
|
-
};
|
|
119
|
-
constructor(args: IBeraErrorArgs & {
|
|
120
|
-
response: Response | ErrorLike | undefined;
|
|
121
|
-
/**
|
|
122
|
-
* The payload sent to the request.
|
|
123
|
-
*/
|
|
124
|
-
payload?: object;
|
|
125
|
-
endpoint: string | URL | {
|
|
126
|
-
name?: string;
|
|
127
|
-
url: string | URL;
|
|
128
|
-
type: "rest" | "graphql" | "rpc";
|
|
129
|
-
};
|
|
130
|
-
statusCode?: number;
|
|
131
|
-
});
|
|
132
|
-
setEndpoint(endpoint: string | URL | {
|
|
133
|
-
name?: string;
|
|
134
|
-
url: string | URL;
|
|
135
|
-
type?: "rest" | "graphql" | "rpc";
|
|
136
|
-
}): {
|
|
137
|
-
name?: string;
|
|
138
|
-
url: string;
|
|
139
|
-
type?: "rest" | "graphql" | "rpc";
|
|
140
|
-
};
|
|
141
|
-
private tryMatchNetworkError;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export { BeraTracing as B, type EmitterMixin as E, RequestError as R, type SpanContext as S };
|