@berachain/berajs 0.2.8-beta.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BeraError-_mQdkanr.d.cts → BeraError-7-A5JYy_.d.ts} +31 -2
- package/dist/{HoneyConfigProvider-DVP_9KZn.d.ts → HoneyConfigProvider-Dkj-_a5x.d.ts} +1 -1
- package/dist/RequestError-DBOIV65x.d.ts +144 -0
- package/dist/abi/exports.mjs +3 -4
- package/dist/actions/clients/exports.d.ts +2 -0
- package/dist/actions/clients/exports.mjs +12 -0
- package/dist/actions/exports.d.ts +108 -187
- package/dist/actions/exports.mjs +97 -158
- package/dist/actions/governance/exports.d.ts +140 -0
- package/dist/actions/governance/exports.mjs +226 -0
- package/dist/actions/server/exports.d.ts +13 -0
- package/dist/actions/server/exports.mjs +27 -0
- package/dist/{chunk-VA3BQ34H.mjs → chunk-3EARVV7K.mjs} +20 -9
- package/dist/chunk-4Z4AK6SH.mjs +211 -0
- package/dist/chunk-75M6TF7M.mjs +25 -0
- package/dist/chunk-AFN4CVD3.mjs +326 -0
- package/dist/{chunk-7TFV6UKF.mjs → chunk-BGMRHTBQ.mjs} +0 -1
- package/dist/{chunk-3M47ZRXT.mjs → chunk-CDFWPU2R.mjs} +73 -17
- package/dist/{chunk-GWSTVITN.mjs → chunk-CDK4YV3D.mjs} +0 -1
- package/dist/{chunk-KL6YZ5VR.mjs → chunk-DKMAIU74.mjs} +0 -1
- package/dist/chunk-EXIUPSFN.mjs +86 -0
- package/dist/{chunk-VA5L5FDG.mjs → chunk-FFB5LFDW.mjs} +2 -3
- package/dist/{chunk-ZCEFC2TK.mjs → chunk-HQCOU6GY.mjs} +0 -1
- package/dist/{chunk-SGZP4O6R.mjs → chunk-HSSJKHZ4.mjs} +11 -11
- package/dist/{chunk-7QKRRIHI.mjs → chunk-J5I45WGQ.mjs} +77 -152
- package/dist/chunk-KQUMKB66.mjs +89 -0
- package/dist/{chunk-JA4DHMTG.mjs → chunk-NBYLMO2L.mjs} +0 -1
- package/dist/{chunk-4GFN4LEP.mjs → chunk-NPBQLVL3.mjs} +4 -21
- package/dist/{chunk-I3FTWD6I.mjs → chunk-O2NQFKJK.mjs} +1 -1
- package/dist/{chunk-2R73G2PO.mjs → chunk-QJIXTYTZ.mjs} +121 -765
- package/dist/{chunk-GLWPRM33.mjs → chunk-SGIJVHZO.mjs} +0 -1
- package/dist/chunk-SZ5C44L5.mjs +35 -0
- package/dist/{chunk-5NMATIH4.mjs → chunk-WXXOISTU.mjs} +1 -35
- package/dist/chunk-XIYN6AL6.mjs +160 -0
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +11 -9
- package/dist/enum/exports.d.ts +1 -1
- package/dist/enum/exports.mjs +3 -16
- package/dist/enum/governance/exports.d.ts +60 -0
- package/dist/enum/governance/exports.mjs +14 -0
- package/dist/errors/exports.d.ts +5 -90
- package/dist/errors/exports.mjs +19 -10
- package/dist/exports-BcUTGFUb.d.ts +40 -0
- package/dist/{getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts → getValidatorQueuedOperatorAddress-Dw5KN5sh.d.ts} +2 -2
- package/dist/{global.d-5w_lvl2J.d.ts → global.d-BuGDKh4k.d.ts} +4 -240
- package/dist/hooks/exports.d.ts +80 -236
- package/dist/hooks/exports.mjs +609 -1508
- package/dist/hooks/governance/exports.d.ts +181 -0
- package/dist/hooks/governance/exports.mjs +888 -0
- package/dist/pol.d-CqPA9K6m.d.ts +142 -0
- package/dist/{txnEnum-7_o92X3N.d.cts → txnEnum-ByI5dtDi.d.ts} +2 -60
- package/dist/types/exports.d.ts +9 -9
- package/dist/types/exports.mjs +0 -1
- package/dist/types/governance/exports.d.ts +109 -0
- package/dist/types/governance/exports.mjs +0 -0
- package/dist/{useHoneySwapState-B494PQDl.d.ts → useHoneySwapState-vFmuFF0g.d.ts} +1 -1
- package/dist/utils/exports.d.ts +24 -7
- package/dist/utils/exports.mjs +49 -11
- package/package.json +60 -13
- package/src/actions/__test/transports.ts +61 -0
- package/src/actions/clients/BeraApolloClient.ts +9 -0
- package/src/actions/clients/exports.ts +4 -0
- package/src/actions/clients/getApolloClient.ts +70 -25
- package/src/actions/clients/getEnsoClient.ts +20 -9
- package/src/actions/dex/aggregators/base.ts +1 -1
- package/src/actions/dex/aggregators/enso/enso.ts +27 -17
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +2 -2
- package/src/actions/dex/aggregators/kyberswap.ts +18 -23
- package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
- package/src/actions/exports.ts +5 -10
- package/src/actions/governance/exports.ts +9 -0
- package/src/actions/governance/getAllProposals.ts +10 -65
- package/src/actions/governance/getProposalDetails.ts +6 -33
- package/src/actions/governance/getProposalVotes.ts +8 -15
- package/src/actions/honey/getChartData.ts +27 -21
- package/src/actions/honey/getHoney24hVolume.ts +27 -0
- package/src/actions/pol/getAutoclaimedIncentives.ts +30 -0
- package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
- package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +35 -0
- package/src/actions/pol/getEarnedStakedBeraVault.ts +15 -9
- package/src/actions/pol/getGlobalData.ts +1 -0
- package/src/actions/pol/getHeroEarnVaults.ts +62 -0
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +19 -38
- package/src/actions/pol/getSWBeraVaultMetadata.ts +1 -1
- package/src/actions/pol/getStakingDailyAssets.ts +11 -8
- package/src/actions/server/exports.ts +1 -0
- package/src/actions/server/getDailyValidatorBlockStats.ts +33 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
- package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
- package/src/actions/validators/getDailyValidatorBlockStats.ts +25 -24
- package/src/actions/validators/getValidatorAnalytics.ts +20 -21
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +33 -0
- package/src/data/contracts.ts +5 -0
- package/src/enum/contracts.ts +1 -0
- package/src/enum/exports.ts +0 -1
- package/src/enum/governance/exports.ts +1 -0
- package/src/errors/BeraError.ts +47 -7
- package/src/errors/BeraTracing.unit.test.ts +65 -0
- package/src/errors/RequestError.ts +15 -2
- package/src/errors/exports.ts +5 -0
- package/src/errors/getRevertReason.integration.test.ts +3 -3
- package/src/errors/spanStatus.ts +78 -0
- package/src/errors/spanStatus.unit.test.ts +62 -0
- package/src/hooks/dex/useCreatePool.ts +1 -88
- package/src/hooks/dex/useOnChainPoolData.ts +27 -2
- package/src/hooks/dex/usePriceImpact.ts +12 -5
- package/src/hooks/enso/useBendDemultiply.ts +9 -1
- package/src/hooks/enso/useBendMultiply.ts +9 -1
- package/src/hooks/enso/useBendZapSupply.ts +26 -7
- package/src/hooks/enso/useEnsoSwapBundle.ts +17 -3
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -2
- package/src/hooks/exports.ts +3 -16
- package/src/hooks/governance/exports.ts +14 -0
- package/src/hooks/honey/useHoney24hVolume.ts +16 -0
- package/src/hooks/pol/useAutoclaimedIncentives.ts +49 -0
- package/src/hooks/pol/useStakedAPR.ts +2 -2
- package/src/hooks/pol/useStakedSnapshots.ts +5 -9
- package/src/hooks/validators/useValidator.ts +2 -0
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
- package/src/types/bribe-boost.d.ts +8 -0
- package/src/types/exports.ts +0 -1
- package/src/types/governance/exports.ts +1 -0
- package/src/utils/beraFetch.ts +76 -15
- package/src/utils/exports.ts +1 -0
- package/src/utils/getServerSideClient.ts +4 -2
- package/src/utils/sanitizeRpcUrl.ts +22 -0
- package/src/utils/tracedTransport.ts +35 -0
- package/dist/BeraError-_mQdkanr.d.ts +0 -94
- package/dist/BexStatusProvider-DRymVlQf.d.cts +0 -70
- package/dist/HoneyConfigProvider-DfkjmzEf.d.cts +0 -390
- package/dist/RequestError-A8XJ6QR9.d.cts +0 -57
- package/dist/RequestError-Dk97z8rm.d.ts +0 -57
- package/dist/abi/exports.cjs +0 -4453
- package/dist/abi/exports.cjs.map +0 -1
- package/dist/abi/exports.d.cts +0 -6574
- package/dist/abi/exports.mjs.map +0 -1
- package/dist/actions/exports.cjs +0 -914
- package/dist/actions/exports.cjs.map +0 -1
- package/dist/actions/exports.d.cts +0 -1644
- package/dist/actions/exports.mjs.map +0 -1
- package/dist/chunk-2R73G2PO.mjs.map +0 -1
- package/dist/chunk-3M47ZRXT.mjs.map +0 -1
- package/dist/chunk-4GFN4LEP.mjs.map +0 -1
- package/dist/chunk-5N7QQS55.cjs +0 -130
- package/dist/chunk-5N7QQS55.cjs.map +0 -1
- package/dist/chunk-5NMATIH4.mjs.map +0 -1
- package/dist/chunk-7QKRRIHI.mjs.map +0 -1
- package/dist/chunk-7TFV6UKF.mjs.map +0 -1
- package/dist/chunk-A4FPM7U3.cjs +0 -63
- package/dist/chunk-A4FPM7U3.cjs.map +0 -1
- package/dist/chunk-BDHINMWQ.cjs +0 -417
- package/dist/chunk-BDHINMWQ.cjs.map +0 -1
- package/dist/chunk-BEHP54S3.cjs +0 -24
- package/dist/chunk-BEHP54S3.cjs.map +0 -1
- package/dist/chunk-EGDXV2PT.cjs +0 -36
- package/dist/chunk-EGDXV2PT.cjs.map +0 -1
- package/dist/chunk-EWBKSMPG.cjs +0 -13
- package/dist/chunk-EWBKSMPG.cjs.map +0 -1
- package/dist/chunk-F6ZW7ZDD.cjs +0 -403
- package/dist/chunk-F6ZW7ZDD.cjs.map +0 -1
- package/dist/chunk-FTXTRUYT.cjs +0 -170
- package/dist/chunk-FTXTRUYT.cjs.map +0 -1
- package/dist/chunk-GLWPRM33.mjs.map +0 -1
- package/dist/chunk-GWSTVITN.mjs.map +0 -1
- package/dist/chunk-H3Z37RYU.cjs +0 -15
- package/dist/chunk-H3Z37RYU.cjs.map +0 -1
- package/dist/chunk-I3FTWD6I.mjs.map +0 -1
- package/dist/chunk-JA4DHMTG.mjs.map +0 -1
- package/dist/chunk-KL6YZ5VR.mjs.map +0 -1
- package/dist/chunk-MXWPP6MS.cjs +0 -572
- package/dist/chunk-MXWPP6MS.cjs.map +0 -1
- package/dist/chunk-SGZP4O6R.mjs.map +0 -1
- package/dist/chunk-TDW5SPXR.cjs +0 -244
- package/dist/chunk-TDW5SPXR.cjs.map +0 -1
- package/dist/chunk-TGK3IXDN.cjs +0 -169
- package/dist/chunk-TGK3IXDN.cjs.map +0 -1
- package/dist/chunk-TJEW6YCJ.cjs +0 -97
- package/dist/chunk-TJEW6YCJ.cjs.map +0 -1
- package/dist/chunk-VA3BQ34H.mjs.map +0 -1
- package/dist/chunk-VA5L5FDG.mjs.map +0 -1
- package/dist/chunk-XSGCRLSD.cjs +0 -1844
- package/dist/chunk-XSGCRLSD.cjs.map +0 -1
- package/dist/chunk-XV3GG3HC.cjs +0 -135
- package/dist/chunk-XV3GG3HC.cjs.map +0 -1
- package/dist/chunk-Y5B224UX.cjs +0 -4698
- package/dist/chunk-Y5B224UX.cjs.map +0 -1
- package/dist/chunk-ZBTRKBSI.mjs +0 -169
- package/dist/chunk-ZBTRKBSI.mjs.map +0 -1
- package/dist/chunk-ZCEFC2TK.mjs.map +0 -1
- package/dist/contexts/exports.cjs +0 -83
- package/dist/contexts/exports.cjs.map +0 -1
- package/dist/contexts/exports.d.cts +0 -66
- package/dist/contexts/exports.mjs.map +0 -1
- package/dist/defaultFlags-D6KfkTZx.d.cts +0 -10
- package/dist/dex-C_BB0b0O.d.cts +0 -37
- package/dist/enum/exports.cjs +0 -59
- package/dist/enum/exports.cjs.map +0 -1
- package/dist/enum/exports.d.cts +0 -23
- package/dist/enum/exports.mjs.map +0 -1
- package/dist/errors/exports.cjs +0 -39
- package/dist/errors/exports.cjs.map +0 -1
- package/dist/errors/exports.d.cts +0 -413
- package/dist/errors/exports.mjs.map +0 -1
- package/dist/getValidatorQueuedOperatorAddress-Cql_D50j.d.cts +0 -562
- package/dist/global.d-B7IeayVX.d.cts +0 -474
- package/dist/honey-CYm0RWf4.d.cts +0 -14
- package/dist/hooks/exports.cjs +0 -8333
- package/dist/hooks/exports.cjs.map +0 -1
- package/dist/hooks/exports.d.cts +0 -1748
- package/dist/hooks/exports.mjs.map +0 -1
- package/dist/polling-BKnyavLI.d.cts +0 -8
- package/dist/txnEnum-7_o92X3N.d.ts +0 -164
- package/dist/types/exports.cjs +0 -1
- package/dist/types/exports.cjs.map +0 -1
- package/dist/types/exports.d.cts +0 -90
- package/dist/types/exports.mjs.map +0 -1
- package/dist/useHoneySwapState-D6vpv19r.d.cts +0 -32
- package/dist/utils/exports.cjs +0 -787
- package/dist/utils/exports.cjs.map +0 -1
- package/dist/utils/exports.d.cts +0 -412
- package/dist/utils/exports.mjs.map +0 -1
- package/src/actions/dex/getIsTokenExploited.ts +0 -63
- package/src/actions/honey/getHoneyGlobalData.ts +0 -21
- package/src/hooks/dex/useExploitedTokens.ts +0 -57
- package/src/hooks/honey/useHoneyGlobalData.ts +0 -23
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertPublicClient
|
|
3
|
+
} from "./chunk-KQUMKB66.mjs";
|
|
4
|
+
|
|
5
|
+
// src/actions/governance/checkProposalField.ts
|
|
6
|
+
import { isAddress, isHex } from "viem";
|
|
7
|
+
function checkProposalField({
|
|
8
|
+
fieldOrType,
|
|
9
|
+
value,
|
|
10
|
+
required = true,
|
|
11
|
+
baseUrl,
|
|
12
|
+
components
|
|
13
|
+
}) {
|
|
14
|
+
const notRequiredAbiTypes = ["bool", "string"];
|
|
15
|
+
if (!notRequiredAbiTypes.includes(fieldOrType) && required && (value === void 0 || value === null || value === "")) {
|
|
16
|
+
return "Required" /* REQUIRED */;
|
|
17
|
+
}
|
|
18
|
+
if (fieldOrType.startsWith("uint") || fieldOrType.startsWith("int")) {
|
|
19
|
+
if (typeof value !== "string") {
|
|
20
|
+
return "Invalid amount" /* INVALID_AMOUNT */;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const valueBN = BigInt(value);
|
|
24
|
+
if (fieldOrType.startsWith("uint")) {
|
|
25
|
+
if (valueBN < 0n) {
|
|
26
|
+
return "Negative amount" /* NEGATIVE_AMOUNT */;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} catch {
|
|
30
|
+
return "Invalid amount" /* INVALID_AMOUNT */;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
switch (fieldOrType) {
|
|
35
|
+
case "string":
|
|
36
|
+
if (value !== void 0 && typeof value !== "string") {
|
|
37
|
+
return "Invalid amount" /* INVALID_AMOUNT */;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
case "bool":
|
|
41
|
+
if (typeof value !== "boolean") {
|
|
42
|
+
return "Invalid amount" /* INVALID_AMOUNT */;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
case "title":
|
|
46
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
47
|
+
return "Required" /* REQUIRED */;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
case "description":
|
|
51
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
52
|
+
return "Required" /* REQUIRED */;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
case "forumLink": {
|
|
56
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
57
|
+
return "Required" /* REQUIRED */;
|
|
58
|
+
}
|
|
59
|
+
if (!URL.canParse(value)) {
|
|
60
|
+
return "Invalid address" /* INVALID_ADDRESS */;
|
|
61
|
+
}
|
|
62
|
+
const base = new URL(baseUrl);
|
|
63
|
+
if (!value.startsWith(base.toString())) {
|
|
64
|
+
return "Must be a berachain forum link" /* INVALID_BASEPATH */;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
case "address":
|
|
69
|
+
if (typeof value !== "string" || !isAddress(value, { strict: true })) {
|
|
70
|
+
return "Invalid address" /* INVALID_ADDRESS */;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
case "hex":
|
|
74
|
+
if (typeof value !== "string" || !isHex(value, { strict: true })) {
|
|
75
|
+
return "Invalid address" /* INVALID_ADDRESS */;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
case "abi":
|
|
79
|
+
if (typeof value !== "string") {
|
|
80
|
+
return "Invalid ABI" /* INVALID_ABI */;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
JSON.parse(value);
|
|
84
|
+
} catch {
|
|
85
|
+
return "Invalid ABI" /* INVALID_ABI */;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
case "action":
|
|
89
|
+
if (typeof value !== "string" || !isAddress(value, { strict: true })) {
|
|
90
|
+
return "Invalid address" /* INVALID_ADDRESS */;
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
case "tuple":
|
|
94
|
+
if (typeof value === "object" && Array.isArray(components)) {
|
|
95
|
+
const errors = {};
|
|
96
|
+
for (const component of components) {
|
|
97
|
+
const abiParam = component;
|
|
98
|
+
const name = abiParam.name;
|
|
99
|
+
errors[name] = checkProposalField({
|
|
100
|
+
fieldOrType: abiParam.type,
|
|
101
|
+
value: value[name],
|
|
102
|
+
components: abiParam.components
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (Object.values(errors).every((v) => v === null)) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return errors;
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
case "tuple[]":
|
|
112
|
+
if (Array.isArray(value)) {
|
|
113
|
+
const errors = value.map(
|
|
114
|
+
(v) => checkProposalField({
|
|
115
|
+
fieldOrType: "tuple",
|
|
116
|
+
value: v,
|
|
117
|
+
components
|
|
118
|
+
})
|
|
119
|
+
);
|
|
120
|
+
if (errors.every((v) => v === null)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return errors;
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
case "logoURI": {
|
|
127
|
+
if (value === void 0 || value === "") {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
if (typeof value !== "string" || !URL.canParse(value) || new URL(value).protocol !== "https:") {
|
|
131
|
+
return "Must be HTTPS or IPFS" /* MUST_BE_HTTPS_OR_IPFS */;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
case "url": {
|
|
136
|
+
if (value === void 0 || value === "") {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
if (typeof value !== "string" || !URL.canParse(value) || new URL(value).protocol !== "https:") {
|
|
140
|
+
return "Must be HTTPS" /* MUST_BE_HTTPS */;
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
default:
|
|
145
|
+
console.error(`Invalid field or type: ${fieldOrType}`);
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/actions/governance/getAllProposals.ts
|
|
151
|
+
async function getAllProposals(_args) {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/actions/governance/getBodyErrors.ts
|
|
156
|
+
function getBodyErrors({
|
|
157
|
+
proposal,
|
|
158
|
+
currentTopic
|
|
159
|
+
}) {
|
|
160
|
+
const e = {};
|
|
161
|
+
e.title = checkProposalField({
|
|
162
|
+
fieldOrType: "title",
|
|
163
|
+
value: proposal.title
|
|
164
|
+
});
|
|
165
|
+
e.description = checkProposalField({
|
|
166
|
+
fieldOrType: "description",
|
|
167
|
+
value: proposal.description
|
|
168
|
+
});
|
|
169
|
+
e.forumLink = checkProposalField({
|
|
170
|
+
fieldOrType: "forumLink",
|
|
171
|
+
value: proposal.forumLink,
|
|
172
|
+
baseUrl: currentTopic.forumLink
|
|
173
|
+
});
|
|
174
|
+
return e;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/actions/governance/getProposalDetails.ts
|
|
178
|
+
async function getProposalDetails(_args) {
|
|
179
|
+
return void 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/actions/governance/parseProposalBody.ts
|
|
183
|
+
import graymatter from "gray-matter";
|
|
184
|
+
function parseLegacyBody(s) {
|
|
185
|
+
const pattern = /#(?:([\w-]+)# )?(.+)\n([\s\S]*)/;
|
|
186
|
+
const match = s.match(pattern);
|
|
187
|
+
if (match) {
|
|
188
|
+
const type = match[1] || null;
|
|
189
|
+
const title = match[2];
|
|
190
|
+
const content = match[3].replace("\n", "<br />");
|
|
191
|
+
return {
|
|
192
|
+
type,
|
|
193
|
+
title,
|
|
194
|
+
content
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
throw new Error("Invalid proposal body");
|
|
198
|
+
}
|
|
199
|
+
function parseProposalBody(proposal) {
|
|
200
|
+
if (!proposal) {
|
|
201
|
+
return {
|
|
202
|
+
isFrontMatter: false,
|
|
203
|
+
data: { title: "Loading..." },
|
|
204
|
+
content: "",
|
|
205
|
+
matter: "",
|
|
206
|
+
language: "",
|
|
207
|
+
orig: "",
|
|
208
|
+
stringify: () => ""
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const body = proposal?.description ?? "";
|
|
212
|
+
if (graymatter.test(body)) {
|
|
213
|
+
return { ...graymatter(body), isFrontMatter: true };
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const legacyBody = parseLegacyBody(body);
|
|
217
|
+
return {
|
|
218
|
+
isFrontMatter: false,
|
|
219
|
+
data: { title: legacyBody.title },
|
|
220
|
+
content: legacyBody.content,
|
|
221
|
+
matter: "",
|
|
222
|
+
language: "",
|
|
223
|
+
orig: body,
|
|
224
|
+
stringify: () => body
|
|
225
|
+
};
|
|
226
|
+
} catch {
|
|
227
|
+
return {
|
|
228
|
+
isFrontMatter: false,
|
|
229
|
+
data: {
|
|
230
|
+
title: proposal?.description?.split("\n")[0].slice(0, 100)
|
|
231
|
+
},
|
|
232
|
+
content: body,
|
|
233
|
+
matter: "",
|
|
234
|
+
language: "",
|
|
235
|
+
orig: body,
|
|
236
|
+
stringify: () => body
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// src/actions/governance/getProposalFromTx.ts
|
|
242
|
+
import {
|
|
243
|
+
parseEventLogs
|
|
244
|
+
} from "viem";
|
|
245
|
+
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
246
|
+
import {
|
|
247
|
+
ProposalStatus
|
|
248
|
+
} from "@berachain/graphql/governance";
|
|
249
|
+
async function getProposalFromTx(args) {
|
|
250
|
+
assertPublicClient(args.publicClient);
|
|
251
|
+
let tx;
|
|
252
|
+
if ("tx" in args) {
|
|
253
|
+
tx = args.tx;
|
|
254
|
+
} else {
|
|
255
|
+
tx = await args.publicClient.getTransactionReceipt({ hash: args.txHash });
|
|
256
|
+
}
|
|
257
|
+
const creationEvent = tx?.logs ? parseEventLogs({
|
|
258
|
+
abi: governanceAbi,
|
|
259
|
+
logs: tx.logs,
|
|
260
|
+
eventName: "ProposalCreated"
|
|
261
|
+
})?.at(0) : void 0;
|
|
262
|
+
if (!tx || !creationEvent) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
const block = await args.publicClient.getBlock({
|
|
266
|
+
blockNumber: tx.blockNumber
|
|
267
|
+
});
|
|
268
|
+
const fm = parseProposalBody({
|
|
269
|
+
description: creationEvent?.args.description
|
|
270
|
+
});
|
|
271
|
+
return {
|
|
272
|
+
id: String(creationEvent.args.proposalId),
|
|
273
|
+
proposalId: String(creationEvent?.args.proposalId),
|
|
274
|
+
createdAt: block.timestamp.toString(),
|
|
275
|
+
title: fm.data.title,
|
|
276
|
+
createdAtBlock: block.timestamp.toString(),
|
|
277
|
+
voteStartAt: String(creationEvent?.args.voteStart),
|
|
278
|
+
voteEndAt: String(creationEvent?.args.voteEnd),
|
|
279
|
+
proposer: creationEvent?.args.proposer,
|
|
280
|
+
description: fm.content,
|
|
281
|
+
unverifiedForumLink: fm.data.forumLink,
|
|
282
|
+
pollResult: {
|
|
283
|
+
for: "0",
|
|
284
|
+
forVotersCount: 0,
|
|
285
|
+
forPercentage: "0",
|
|
286
|
+
against: "0",
|
|
287
|
+
againstVotersCount: 0,
|
|
288
|
+
againstPercentage: "0",
|
|
289
|
+
abstain: "0",
|
|
290
|
+
abstainVotersCount: 0,
|
|
291
|
+
abstainPercentage: "0",
|
|
292
|
+
total: "0",
|
|
293
|
+
totalVotersCount: 0,
|
|
294
|
+
totalTowardsQuorum: "0"
|
|
295
|
+
},
|
|
296
|
+
status: ProposalStatus.Pending,
|
|
297
|
+
quorum: null,
|
|
298
|
+
topics: fm.data.topics,
|
|
299
|
+
votes: [],
|
|
300
|
+
executableCalls: creationEvent?.args.targets.map(
|
|
301
|
+
(target, index) => ({
|
|
302
|
+
__typename: "ExecutableCall",
|
|
303
|
+
id: `${tx.transactionHash}-${index}`,
|
|
304
|
+
target,
|
|
305
|
+
value: String(creationEvent?.args.values[index]),
|
|
306
|
+
calldata: creationEvent?.args.calldatas[index]
|
|
307
|
+
})
|
|
308
|
+
),
|
|
309
|
+
timelock: void 0
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// src/actions/governance/getProposalVotes.ts
|
|
314
|
+
async function getProposalVotes(_args) {
|
|
315
|
+
return { data: { votes: [] } };
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export {
|
|
319
|
+
checkProposalField,
|
|
320
|
+
getAllProposals,
|
|
321
|
+
getBodyErrors,
|
|
322
|
+
getProposalDetails,
|
|
323
|
+
parseProposalBody,
|
|
324
|
+
getProposalFromTx,
|
|
325
|
+
getProposalVotes
|
|
326
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BeraTracing
|
|
3
|
+
} from "./chunk-SZ5C44L5.mjs";
|
|
1
4
|
import {
|
|
2
5
|
RequestError
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XIYN6AL6.mjs";
|
|
4
7
|
|
|
5
8
|
// src/utils/getErrorResponse.ts
|
|
6
9
|
async function getErrorResponse(response) {
|
|
@@ -20,26 +23,79 @@ async function getErrorResponse(response) {
|
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
// src/utils/sanitizeRpcUrl.ts
|
|
27
|
+
function sanitizeRpcUrl(url) {
|
|
28
|
+
if (!url) return "";
|
|
29
|
+
try {
|
|
30
|
+
const parsed = new URL(url);
|
|
31
|
+
if (parsed.hostname.endsWith(".quiknode.pro")) {
|
|
32
|
+
parsed.pathname = "/";
|
|
33
|
+
parsed.search = "";
|
|
34
|
+
return parsed.toString();
|
|
35
|
+
}
|
|
36
|
+
return url;
|
|
37
|
+
} catch {
|
|
38
|
+
return url;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
// src/utils/beraFetch.ts
|
|
24
|
-
async function beraFetch(endpoint, options) {
|
|
43
|
+
async function beraFetch(endpoint, options, spanContext) {
|
|
25
44
|
try {
|
|
26
|
-
|
|
27
|
-
typeof endpoint === "string" || endpoint instanceof URL ? endpoint : endpoint.url
|
|
45
|
+
let spanUrl = sanitizeRpcUrl(
|
|
46
|
+
typeof endpoint === "string" || endpoint instanceof URL ? endpoint.toString() : endpoint.url.toString()
|
|
47
|
+
).replace(/0x[a-fA-F0-9]{40}/g, ":address");
|
|
48
|
+
if (spanContext?.keepQueryParams !== true && URL.canParse(spanUrl)) {
|
|
49
|
+
const queryParams = new URL(spanUrl).searchParams;
|
|
50
|
+
if (Array.isArray(spanContext?.keepQueryParams)) {
|
|
51
|
+
const searchParams = new URLSearchParams();
|
|
52
|
+
for (const param of spanContext.keepQueryParams) {
|
|
53
|
+
searchParams.set(param, queryParams.get(param) ?? "");
|
|
54
|
+
}
|
|
55
|
+
const newUrl = new URL(spanUrl);
|
|
56
|
+
newUrl.search = searchParams.toString();
|
|
57
|
+
spanUrl = newUrl.toString();
|
|
58
|
+
} else {
|
|
59
|
+
const newUrl = new URL(spanUrl);
|
|
60
|
+
newUrl.search = "";
|
|
61
|
+
spanUrl = newUrl.toString();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const endpointName = typeof endpoint === "string" || endpoint instanceof URL ? void 0 : endpoint.name;
|
|
65
|
+
return await BeraTracing.startSpan(
|
|
28
66
|
{
|
|
29
|
-
|
|
67
|
+
op: "beraFetch",
|
|
68
|
+
name: endpointName ? `beraFetch ${endpointName}` : "beraFetch",
|
|
69
|
+
attributes: typeof endpoint === "string" || endpoint instanceof URL ? {
|
|
70
|
+
"operation.source.url": spanUrl,
|
|
71
|
+
...spanContext?.attributes
|
|
72
|
+
} : {
|
|
73
|
+
"operation.source.url": spanUrl,
|
|
74
|
+
"operation.source.type": endpoint.type,
|
|
75
|
+
"operation.source.name": endpoint.name,
|
|
76
|
+
...spanContext?.attributes
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
async () => {
|
|
80
|
+
const response = await fetch(
|
|
81
|
+
typeof endpoint === "string" || endpoint instanceof URL ? endpoint : endpoint.url,
|
|
82
|
+
{
|
|
83
|
+
...options
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
const error = await getErrorResponse(response);
|
|
88
|
+
throw new RequestError({
|
|
89
|
+
cause: error,
|
|
90
|
+
// @to-do import getErrorResponse logic in this function
|
|
91
|
+
// when it's removed from other places
|
|
92
|
+
response,
|
|
93
|
+
endpoint
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return response;
|
|
30
97
|
}
|
|
31
98
|
);
|
|
32
|
-
if (!response.ok) {
|
|
33
|
-
const error = await getErrorResponse(response);
|
|
34
|
-
throw new RequestError({
|
|
35
|
-
cause: error,
|
|
36
|
-
// @to-do import getErrorResponse logic in this function
|
|
37
|
-
// when it's removed from other places
|
|
38
|
-
response,
|
|
39
|
-
endpoint
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return response;
|
|
43
99
|
} catch (error) {
|
|
44
100
|
if (error instanceof RequestError) {
|
|
45
101
|
throw error;
|
|
@@ -383,6 +439,7 @@ function getTestClient(chainId = defaultChainId) {
|
|
|
383
439
|
export {
|
|
384
440
|
bignumber_js_default,
|
|
385
441
|
getErrorResponse,
|
|
442
|
+
sanitizeRpcUrl,
|
|
386
443
|
beraFetch,
|
|
387
444
|
beraFetchJson,
|
|
388
445
|
CAP_LIMIT_BUFFER,
|
|
@@ -414,4 +471,3 @@ export {
|
|
|
414
471
|
truncateDecimal,
|
|
415
472
|
getTestClient
|
|
416
473
|
};
|
|
417
|
-
//# sourceMappingURL=chunk-3M47ZRXT.mjs.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RequestError
|
|
3
|
+
} from "./chunk-XIYN6AL6.mjs";
|
|
4
|
+
import {
|
|
5
|
+
BeraError,
|
|
6
|
+
parseViemError
|
|
7
|
+
} from "./chunk-J5I45WGQ.mjs";
|
|
8
|
+
|
|
9
|
+
// src/errors/initBeraError.ts
|
|
10
|
+
import { BaseError } from "viem";
|
|
11
|
+
function initBeraError({
|
|
12
|
+
cause: error,
|
|
13
|
+
level
|
|
14
|
+
}) {
|
|
15
|
+
if (error instanceof BaseError) {
|
|
16
|
+
const parsed = parseViemError({
|
|
17
|
+
error,
|
|
18
|
+
revertIfUnknown: false
|
|
19
|
+
});
|
|
20
|
+
if (parsed.isRequestError && parsed.rootCause instanceof BaseError && "url" in parsed.rootCause && typeof parsed.rootCause.url === "string") {
|
|
21
|
+
return new RequestError({
|
|
22
|
+
cause: parsed.rootCause,
|
|
23
|
+
response: void 0,
|
|
24
|
+
endpoint: {
|
|
25
|
+
url: parsed.rootCause.url,
|
|
26
|
+
type: "rpc"
|
|
27
|
+
},
|
|
28
|
+
level
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const err = error instanceof BeraError ? error : new BeraError({
|
|
33
|
+
cause: error,
|
|
34
|
+
level
|
|
35
|
+
});
|
|
36
|
+
return err;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/utils/createEmitter.ts
|
|
40
|
+
function createEmitter() {
|
|
41
|
+
const events = {};
|
|
42
|
+
return {
|
|
43
|
+
emit(event, ...args) {
|
|
44
|
+
for (const callback of events[event] || []) {
|
|
45
|
+
callback(...args);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
events,
|
|
49
|
+
on(event, cb) {
|
|
50
|
+
if (!events[event]) {
|
|
51
|
+
events[event] = [];
|
|
52
|
+
}
|
|
53
|
+
events[event].push(cb);
|
|
54
|
+
return () => {
|
|
55
|
+
events[event] = events[event]?.filter((i) => cb !== i);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/errors/BeraMonitoring.ts
|
|
62
|
+
var _emitter = createEmitter();
|
|
63
|
+
var BeraMonitoring = {
|
|
64
|
+
/**
|
|
65
|
+
* Capture an exception. Notifies all subscribers.
|
|
66
|
+
*/
|
|
67
|
+
captureException(exception) {
|
|
68
|
+
const event = {
|
|
69
|
+
exception,
|
|
70
|
+
timestamp: Date.now()
|
|
71
|
+
};
|
|
72
|
+
_emitter.emit("exception", event);
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Subscribe to error events.
|
|
76
|
+
* @returns An unsubscribe function.
|
|
77
|
+
*/
|
|
78
|
+
on(...args) {
|
|
79
|
+
return _emitter.on(...args);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
initBeraError,
|
|
85
|
+
BeraMonitoring
|
|
86
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bignumber_js_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CDFWPU2R.mjs";
|
|
4
4
|
import {
|
|
5
5
|
isToken,
|
|
6
6
|
wBeraToken
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NPBQLVL3.mjs";
|
|
8
8
|
|
|
9
9
|
// src/utils/tokenWrapping.ts
|
|
10
10
|
function wrapNativeToken(token) {
|
|
@@ -33,4 +33,3 @@ export {
|
|
|
33
33
|
wrapNativeTokens,
|
|
34
34
|
computePriceImpact
|
|
35
35
|
};
|
|
36
|
-
//# sourceMappingURL=chunk-VA5L5FDG.mjs.map
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
multicall3Abi
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HQCOU6GY.mjs";
|
|
4
4
|
import {
|
|
5
5
|
assertAddress,
|
|
6
6
|
assertDefined,
|
|
7
7
|
assertPublicClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KQUMKB66.mjs";
|
|
9
|
+
import {
|
|
10
|
+
isToken
|
|
11
|
+
} from "./chunk-NPBQLVL3.mjs";
|
|
9
12
|
import {
|
|
10
|
-
isToken,
|
|
11
13
|
parseBaseArgs
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-75M6TF7M.mjs";
|
|
13
15
|
|
|
14
16
|
// src/actions/clients/getEnsoClient.ts
|
|
15
17
|
import { EnsoClient } from "@ensofinance/sdk";
|
|
16
18
|
import { appConfig } from "@berachain/config/internal";
|
|
17
19
|
var isProduction = process.env.NODE_ENV !== "development" && process.env.NODE_ENV !== "test";
|
|
18
20
|
function getEnsoClient({
|
|
19
|
-
|
|
21
|
+
baseURL,
|
|
20
22
|
...args
|
|
21
23
|
} = {}) {
|
|
22
24
|
const { config } = parseBaseArgs(args);
|
|
25
|
+
const resolvedBaseURL = baseURL !== void 0 ? baseURL : isProduction ? `${config.bex.aggregatorsProxyUrl}/enso/api/v1/` : void 0;
|
|
23
26
|
return new EnsoClient({
|
|
24
|
-
baseURL:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
""
|
|
28
|
-
) : appConfig.apiKeys.public.enso
|
|
27
|
+
baseURL: resolvedBaseURL,
|
|
28
|
+
// no API key when routing through a proxy — the proxy handles auth
|
|
29
|
+
apiKey: resolvedBaseURL ? "" : appConfig.apiKeys.public.enso
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -132,4 +133,3 @@ export {
|
|
|
132
133
|
getBalanceCall,
|
|
133
134
|
getWalletBalances
|
|
134
135
|
};
|
|
135
|
-
//# sourceMappingURL=chunk-SGZP4O6R.mjs.map
|