@berachain/berajs 0.2.8-beta.4 → 0.2.8-beta.7

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.
Files changed (181) hide show
  1. package/dist/abi/exports.cjs +1 -4452
  2. package/dist/abi/exports.cjs.map +1 -1
  3. package/dist/abi/exports.mjs +1 -4452
  4. package/dist/abi/exports.mjs.map +1 -1
  5. package/dist/actions/exports.cjs +1 -918
  6. package/dist/actions/exports.cjs.map +1 -1
  7. package/dist/actions/exports.d.cts +95 -50
  8. package/dist/actions/exports.d.ts +95 -50
  9. package/dist/actions/exports.mjs +1 -918
  10. package/dist/actions/exports.mjs.map +1 -1
  11. package/dist/chunk-3MZ7MLKF.mjs +2 -0
  12. package/dist/{chunk-PBCE7JTE.mjs.map → chunk-3MZ7MLKF.mjs.map} +1 -1
  13. package/dist/chunk-53TSJM6P.cjs +2 -0
  14. package/dist/chunk-53TSJM6P.cjs.map +1 -0
  15. package/dist/chunk-575OK77P.mjs +2 -0
  16. package/dist/{chunk-GLWPRM33.mjs.map → chunk-575OK77P.mjs.map} +1 -1
  17. package/dist/chunk-5W7UKRHX.mjs +2 -0
  18. package/dist/{chunk-J6EHBYSV.mjs.map → chunk-5W7UKRHX.mjs.map} +1 -1
  19. package/dist/chunk-6K252BGM.mjs +2 -0
  20. package/dist/{chunk-CYBZH6U3.mjs.map → chunk-6K252BGM.mjs.map} +1 -1
  21. package/dist/chunk-CWKDFUFR.mjs +2 -0
  22. package/dist/{chunk-OWUI3VPI.mjs.map → chunk-CWKDFUFR.mjs.map} +1 -1
  23. package/dist/chunk-D6L7LTA2.cjs +2 -0
  24. package/dist/chunk-D6L7LTA2.cjs.map +1 -0
  25. package/dist/chunk-DDEQFR3M.cjs +2 -0
  26. package/dist/chunk-DDEQFR3M.cjs.map +1 -0
  27. package/dist/chunk-DKY4QPWU.cjs +2 -0
  28. package/dist/chunk-DKY4QPWU.cjs.map +1 -0
  29. package/dist/chunk-DTBJO6VT.cjs +2 -0
  30. package/dist/chunk-DTBJO6VT.cjs.map +1 -0
  31. package/dist/chunk-ESAVA5OD.mjs +2 -0
  32. package/dist/{chunk-ALPEMPZI.mjs.map → chunk-ESAVA5OD.mjs.map} +1 -1
  33. package/dist/chunk-JDZGYU5T.mjs +2 -0
  34. package/dist/{chunk-WEULAXBE.mjs.map → chunk-JDZGYU5T.mjs.map} +1 -1
  35. package/dist/chunk-JLFBRMOF.cjs +2 -0
  36. package/dist/chunk-JLFBRMOF.cjs.map +1 -0
  37. package/dist/chunk-KT6L4K4K.cjs +2 -0
  38. package/dist/chunk-KT6L4K4K.cjs.map +1 -0
  39. package/dist/chunk-MASD43N5.mjs +4 -0
  40. package/dist/chunk-MASD43N5.mjs.map +1 -0
  41. package/dist/chunk-MGGPHKA2.cjs +4 -0
  42. package/dist/chunk-MGGPHKA2.cjs.map +1 -0
  43. package/dist/chunk-MK5NS5B5.mjs +2 -0
  44. package/dist/{chunk-7TFV6UKF.mjs.map → chunk-MK5NS5B5.mjs.map} +1 -1
  45. package/dist/chunk-NAXAZJJY.mjs +2 -0
  46. package/dist/{chunk-ZCEFC2TK.mjs.map → chunk-NAXAZJJY.mjs.map} +1 -1
  47. package/dist/chunk-NLVWRMGD.mjs +2 -0
  48. package/dist/{chunk-GWSTVITN.mjs.map → chunk-NLVWRMGD.mjs.map} +1 -1
  49. package/dist/chunk-OGBD5YOG.mjs +2 -0
  50. package/dist/{chunk-JA4DHMTG.mjs.map → chunk-OGBD5YOG.mjs.map} +1 -1
  51. package/dist/chunk-OGJMSGB2.mjs +2 -0
  52. package/dist/{chunk-KL6YZ5VR.mjs.map → chunk-OGJMSGB2.mjs.map} +1 -1
  53. package/dist/chunk-OIYXOKTT.cjs +2 -0
  54. package/dist/chunk-OIYXOKTT.cjs.map +1 -0
  55. package/dist/chunk-OUD27MU7.cjs +2 -0
  56. package/dist/chunk-OUD27MU7.cjs.map +1 -0
  57. package/dist/chunk-QFLDL4UV.cjs +2 -0
  58. package/dist/chunk-QFLDL4UV.cjs.map +1 -0
  59. package/dist/chunk-RSDCKN4Q.mjs +2 -0
  60. package/dist/chunk-RSDCKN4Q.mjs.map +1 -0
  61. package/dist/chunk-RWOICHRW.cjs +2 -0
  62. package/dist/chunk-RWOICHRW.cjs.map +1 -0
  63. package/dist/chunk-SSPFPAWX.mjs +2 -0
  64. package/dist/{chunk-WAFQFAI7.mjs.map → chunk-SSPFPAWX.mjs.map} +1 -1
  65. package/dist/chunk-UENDEN3M.mjs +2 -0
  66. package/dist/{chunk-MKS6W5NI.mjs.map → chunk-UENDEN3M.mjs.map} +1 -1
  67. package/dist/chunk-UFIM7WQ4.cjs +2 -0
  68. package/dist/chunk-UFIM7WQ4.cjs.map +1 -0
  69. package/dist/chunk-WRFDB3QJ.cjs +2 -0
  70. package/dist/chunk-WRFDB3QJ.cjs.map +1 -0
  71. package/dist/chunk-XNJLSA6P.cjs +2 -0
  72. package/dist/chunk-XNJLSA6P.cjs.map +1 -0
  73. package/dist/chunk-ZYXVUXFQ.cjs +2 -0
  74. package/dist/chunk-ZYXVUXFQ.cjs.map +1 -0
  75. package/dist/contexts/exports.cjs +1 -82
  76. package/dist/contexts/exports.cjs.map +1 -1
  77. package/dist/contexts/exports.mjs +1 -82
  78. package/dist/contexts/exports.mjs.map +1 -1
  79. package/dist/enum/exports.cjs +1 -58
  80. package/dist/enum/exports.cjs.map +1 -1
  81. package/dist/enum/exports.d.cts +1 -1
  82. package/dist/enum/exports.d.ts +1 -1
  83. package/dist/enum/exports.mjs +1 -58
  84. package/dist/enum/exports.mjs.map +1 -1
  85. package/dist/errors/exports.cjs +1 -38
  86. package/dist/errors/exports.cjs.map +1 -1
  87. package/dist/errors/exports.mjs +1 -38
  88. package/dist/{getValidatorQueuedOperatorAddress-DUZOmxLV.d.ts → getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts} +2 -2
  89. package/dist/{getValidatorQueuedOperatorAddress-BQXkSFd9.d.cts → getValidatorQueuedOperatorAddress-Cql_D50j.d.cts} +2 -2
  90. package/dist/{global.d-SU9Epq0M.d.ts → global.d-5w_lvl2J.d.ts} +1 -1
  91. package/dist/{global.d-6aSWIkV_.d.cts → global.d-B7IeayVX.d.cts} +1 -1
  92. package/dist/hooks/exports.cjs +3 -8327
  93. package/dist/hooks/exports.cjs.map +1 -1
  94. package/dist/hooks/exports.d.cts +4 -4
  95. package/dist/hooks/exports.d.ts +4 -4
  96. package/dist/hooks/exports.mjs +3 -8327
  97. package/dist/hooks/exports.mjs.map +1 -1
  98. package/dist/{txnEnum-CCuQUFlh.d.cts → txnEnum-7_o92X3N.d.cts} +2 -0
  99. package/dist/{txnEnum-CCuQUFlh.d.ts → txnEnum-7_o92X3N.d.ts} +2 -0
  100. package/dist/types/exports.d.cts +2 -2
  101. package/dist/types/exports.d.ts +2 -2
  102. package/dist/utils/exports.cjs +1 -786
  103. package/dist/utils/exports.cjs.map +1 -1
  104. package/dist/utils/exports.mjs +1 -786
  105. package/dist/utils/exports.mjs.map +1 -1
  106. package/package.json +5 -5
  107. package/src/actions/clients/getApolloClient.ts +11 -4
  108. package/src/actions/dex/aggregators/base.ts +1 -3
  109. package/src/actions/dex/getOnChainPool.ts +1 -1
  110. package/src/actions/enso/getBendMultiplyBundle.ts +9 -2
  111. package/src/actions/enso/util.ts +6 -8
  112. package/src/actions/governance/checkProposalField.ts +108 -54
  113. package/src/actions/governance/computeActualStatus.ts +7 -3
  114. package/src/actions/governance/getAllProposals.ts +15 -8
  115. package/src/actions/governance/getBodyErrors.ts +13 -5
  116. package/src/actions/governance/getDecodedFunctionData.ts +31 -27
  117. package/src/actions/governance/getProposalDetails.ts +8 -4
  118. package/src/actions/governance/getProposalFromTx.ts +19 -10
  119. package/src/actions/governance/getProposalParams.ts +17 -17
  120. package/src/actions/governance/getProposalVotes.ts +7 -3
  121. package/src/actions/governance/getQuorum.ts +7 -7
  122. package/src/actions/governance/parseProposalBody.ts +19 -9
  123. package/src/actions/pol/getRewardVaultIncentives.ts +2 -2
  124. package/src/actions/tokens/getTokenInformation.ts +8 -15
  125. package/src/actions/tokens/getUnderlyingToken.ts +1 -3
  126. package/src/enum/txnEnum.ts +2 -0
  127. package/src/errors/BeraError.ts +7 -2
  128. package/src/hooks/dex/usePoolHistoricalData.ts +1 -1
  129. package/src/hooks/enso/useBendZapSupply.ts +1 -1
  130. package/src/hooks/perps/usePythUpdateFee.ts +1 -1
  131. package/src/hooks/validators/useValidatorRewardAllocation.ts +1 -1
  132. package/dist/chunk-24HMIYTN.cjs +0 -36
  133. package/dist/chunk-24HMIYTN.cjs.map +0 -1
  134. package/dist/chunk-2LL77B3T.cjs +0 -135
  135. package/dist/chunk-2LL77B3T.cjs.map +0 -1
  136. package/dist/chunk-3LXVARBJ.cjs +0 -417
  137. package/dist/chunk-3LXVARBJ.cjs.map +0 -1
  138. package/dist/chunk-4HDIUUSV.cjs +0 -130
  139. package/dist/chunk-4HDIUUSV.cjs.map +0 -1
  140. package/dist/chunk-7ONKBHXY.cjs +0 -169
  141. package/dist/chunk-7ONKBHXY.cjs.map +0 -1
  142. package/dist/chunk-7TFV6UKF.mjs +0 -24
  143. package/dist/chunk-A4FPM7U3.cjs +0 -63
  144. package/dist/chunk-A4FPM7U3.cjs.map +0 -1
  145. package/dist/chunk-A7P3JVU7.cjs +0 -4694
  146. package/dist/chunk-A7P3JVU7.cjs.map +0 -1
  147. package/dist/chunk-ALPEMPZI.mjs +0 -417
  148. package/dist/chunk-BEHP54S3.cjs +0 -24
  149. package/dist/chunk-BEHP54S3.cjs.map +0 -1
  150. package/dist/chunk-CYBZH6U3.mjs +0 -135
  151. package/dist/chunk-EWBKSMPG.cjs +0 -13
  152. package/dist/chunk-EWBKSMPG.cjs.map +0 -1
  153. package/dist/chunk-GLWPRM33.mjs +0 -13
  154. package/dist/chunk-GWSTVITN.mjs +0 -572
  155. package/dist/chunk-H3Z37RYU.cjs +0 -15
  156. package/dist/chunk-H3Z37RYU.cjs.map +0 -1
  157. package/dist/chunk-HCC4FJTD.cjs +0 -97
  158. package/dist/chunk-HCC4FJTD.cjs.map +0 -1
  159. package/dist/chunk-J6EHBYSV.mjs +0 -97
  160. package/dist/chunk-JA4DHMTG.mjs +0 -15
  161. package/dist/chunk-KL6YZ5VR.mjs +0 -63
  162. package/dist/chunk-MILSHCKW.cjs +0 -168
  163. package/dist/chunk-MILSHCKW.cjs.map +0 -1
  164. package/dist/chunk-MKS6W5NI.mjs +0 -403
  165. package/dist/chunk-MXWPP6MS.cjs +0 -572
  166. package/dist/chunk-MXWPP6MS.cjs.map +0 -1
  167. package/dist/chunk-OWUI3VPI.mjs +0 -169
  168. package/dist/chunk-PBCE7JTE.mjs +0 -36
  169. package/dist/chunk-QISQSMCV.cjs +0 -1843
  170. package/dist/chunk-QISQSMCV.cjs.map +0 -1
  171. package/dist/chunk-SYWYIMY7.mjs +0 -4694
  172. package/dist/chunk-SYWYIMY7.mjs.map +0 -1
  173. package/dist/chunk-TDW5SPXR.cjs +0 -244
  174. package/dist/chunk-TDW5SPXR.cjs.map +0 -1
  175. package/dist/chunk-TGHG6Q3C.cjs +0 -403
  176. package/dist/chunk-TGHG6Q3C.cjs.map +0 -1
  177. package/dist/chunk-WAFQFAI7.mjs +0 -130
  178. package/dist/chunk-WEULAXBE.mjs +0 -168
  179. package/dist/chunk-ZCEFC2TK.mjs +0 -244
  180. package/dist/chunk-ZV7DCQQY.mjs +0 -1843
  181. package/dist/chunk-ZV7DCQQY.mjs.map +0 -1
@@ -1,417 +0,0 @@
1
- import {
2
- RequestError
3
- } from "./chunk-ZV7DCQQY.mjs";
4
-
5
- // src/utils/getErrorResponse.ts
6
- async function getErrorResponse(response) {
7
- const contentType = response.headers.get("content-type");
8
- if (contentType?.includes("application/json")) {
9
- return response.json();
10
- } else {
11
- const text = await response.text();
12
- try {
13
- return JSON.parse(text);
14
- } catch {
15
- return {
16
- message: "Unknown error, can't decode response into JSON",
17
- cause: text
18
- };
19
- }
20
- }
21
- }
22
-
23
- // src/utils/beraFetch.ts
24
- async function beraFetch(endpoint, options) {
25
- try {
26
- const response = await fetch(
27
- typeof endpoint === "string" || endpoint instanceof URL ? endpoint : endpoint.url,
28
- {
29
- ...options
30
- }
31
- );
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
- } catch (error) {
44
- if (error instanceof RequestError) {
45
- throw error;
46
- }
47
- throw new RequestError({
48
- cause: error,
49
- endpoint,
50
- response: void 0
51
- });
52
- }
53
- }
54
- async function beraFetchJson(endpoint, options) {
55
- const response = await beraFetch(endpoint, {
56
- ...options,
57
- headers: {
58
- Accept: "application/json",
59
- ...options?.headers
60
- }
61
- });
62
- return response.json();
63
- }
64
-
65
- // src/utils/constants.ts
66
- import { parseEther } from "viem";
67
- var CAP_LIMIT_BUFFER = parseEther("0.005");
68
- var MAX_CUSTOM_DEADLINE = 1e5;
69
- var MIN_CUSTOM_DEADLINE = 1;
70
- var MIN_CUSTOM_SLIPPAGE = 0.1;
71
- var MAX_CUSTOM_SLIPPAGE = 50;
72
- var DEFAULT_METAMASK_GAS_LIMIT = 7920027n;
73
-
74
- // src/utils/pythHoneyUtils.ts
75
- var getPythDefaultUpdateFee = (tokenListLength) => {
76
- return 2n * BigInt(tokenListLength);
77
- };
78
-
79
- // src/utils/time.ts
80
- function msToSeconds(ms) {
81
- return Math.floor(ms / 1e3);
82
- }
83
- function seconds(seconds2) {
84
- return seconds2 * 1e3;
85
- }
86
- function minutes(minutes2) {
87
- return minutes2 * seconds(60);
88
- }
89
- function minutesInSeconds(minutes2) {
90
- return minutes2 * 60;
91
- }
92
- function hours(hours2) {
93
- return hours2 * minutes(60);
94
- }
95
- function hoursInSeconds(hours2) {
96
- return hours2 * minutesInSeconds(60);
97
- }
98
- function days(days2) {
99
- return days2 * hours(24);
100
- }
101
- function daysInSeconds(days2) {
102
- return days2 * hoursInSeconds(24);
103
- }
104
- function weeks(weeks2) {
105
- return weeks2 * days(7);
106
- }
107
- function weeksInSeconds(weeks2) {
108
- return weeks2 * daysInSeconds(7);
109
- }
110
- function months(months2) {
111
- return months2 * days(30);
112
- }
113
- function monthsInSeconds(months2) {
114
- return months2 * daysInSeconds(30);
115
- }
116
- function years(years2) {
117
- return years2 * days(365);
118
- }
119
- function yearsInSeconds(years2) {
120
- return years2 * daysInSeconds(365);
121
- }
122
-
123
- // src/utils/formatTimestamps.ts
124
- function calculateTimestampFromDays(daysRange) {
125
- const currentDate = /* @__PURE__ */ new Date();
126
- return currentDate.setDate(currentDate.getDate() - daysRange) * 1e3;
127
- }
128
- var monthNames = [
129
- "January",
130
- "February",
131
- "March",
132
- "April",
133
- "May",
134
- "June",
135
- "July",
136
- "August",
137
- "September",
138
- "October",
139
- "November",
140
- "December"
141
- ];
142
- var shortMonthNames = [
143
- "Jan",
144
- "Feb",
145
- "Mar",
146
- "Apr",
147
- "May",
148
- "Jun",
149
- "Jul",
150
- "Aug",
151
- "Sep",
152
- "Oct",
153
- "Nov",
154
- "Dec"
155
- ];
156
- function formatUnixTimestamp(unixTimestamp, isShort) {
157
- const date = new Date(unixTimestamp * 1e3);
158
- const day = date.getDate();
159
- let daySuffix = "th";
160
- if (day === 1 || day === 21 || day === 31) {
161
- daySuffix = "st";
162
- } else if (day === 2 || day === 22) {
163
- daySuffix = "nd";
164
- } else if (day === 3 || day === 23) {
165
- daySuffix = "rd";
166
- }
167
- if (isShort) {
168
- return `${shortMonthNames[date.getMonth()]} ${day}`;
169
- }
170
- return `${monthNames[date.getMonth()]} ${day}${daySuffix}, ${date.getFullYear()}`;
171
- }
172
- function formatTimeLeft(...args) {
173
- const timeLeftInSeconds = args[0];
174
- let condensed;
175
- let showDays;
176
- let showMinutes;
177
- let showSeconds;
178
- if (typeof args[1] !== "object") {
179
- condensed = args[1] ?? false;
180
- showDays = args[2] ?? false;
181
- showSeconds = args[3] ?? false;
182
- showMinutes = true;
183
- } else {
184
- const opts = args[1];
185
- condensed = opts.condensed ?? false;
186
- const greaterUnit = opts.greaterUnit ?? "hours";
187
- if (greaterUnit === "days") {
188
- showDays = true;
189
- showMinutes = true;
190
- } else if (greaterUnit === "hours") {
191
- showDays = false;
192
- showMinutes = true;
193
- showSeconds = false;
194
- } else {
195
- showDays = false;
196
- showMinutes = true;
197
- }
198
- showSeconds = opts.showSeconds ?? false;
199
- }
200
- let days2 = Math.floor(timeLeftInSeconds / (3600 * 24));
201
- let hours2 = Math.floor(timeLeftInSeconds % (3600 * 24) / 3600);
202
- const minutes2 = Math.floor(timeLeftInSeconds % 3600 / 60);
203
- const seconds2 = timeLeftInSeconds % 60;
204
- if (!showDays) {
205
- hours2 += days2 * 24;
206
- days2 = 0;
207
- }
208
- if (days2 === 0 && hours2 === 0 && minutes2 === 0) {
209
- return condensed ? "< 1 M" : "less than a minute";
210
- }
211
- const daysDisplay = days2 > 0 ? `${days2}${condensed ? "D" : " day"}${!condensed && days2 !== 1 ? "s" : ""}` : "";
212
- const hoursDisplay = hours2 > 0 ? `${hours2}${condensed ? "H" : " hour"}${!condensed && hours2 !== 1 ? "s" : ""}` : "";
213
- const minutesDisplay = minutes2 > 0 && showMinutes || !days2 && !hours2 ? `${minutes2}${condensed ? "M" : " minute"}${!condensed && minutes2 !== 1 ? "s" : ""}` : "";
214
- const secondsDisplay = seconds2 > 0 && showSeconds ? `${seconds2}${condensed ? "S" : " second"}${!condensed && seconds2 !== 1 ? "s" : ""}` : "";
215
- return [daysDisplay, hoursDisplay, minutesDisplay, secondsDisplay].filter(Boolean).join(condensed ? " " : ", ");
216
- }
217
-
218
- // ../utils/src/pkg/bignumber.js.ts
219
- import BigNumber from "bignumber.js";
220
- BigNumber.set({
221
- // The EXPONENTIAL_AT option defines the exponent value(s) at which toString returns exponential notation.
222
- // - Single number: the exponent magnitude at and above which exponential notation is used (e.g., `1e9` here disables it for almost all values).
223
- // - 1e9 is the maximum value supported by BigNumber.js.
224
- // See: https://mikemcl.github.io/bignumber.js/#exponential-at
225
- EXPONENTIAL_AT: 1e9
226
- });
227
- var bignumber_js_default = BigNumber;
228
-
229
- // src/utils/formatNumber.ts
230
- var POSTFIXES = ["", "K", "M", "B", "T", "P", "E", "Z", "Y"];
231
- function valueToBigNumber(amount) {
232
- if (amount instanceof bignumber_js_default) return amount;
233
- return new bignumber_js_default(amount);
234
- }
235
- function normalizeBN(n, decimals) {
236
- return valueToBigNumber(n).shiftedBy(decimals * -1);
237
- }
238
- function formatNumber(value, options = {}) {
239
- if (typeof options === "number") {
240
- const decimals2 = options;
241
- if (value === void 0 || value === null) {
242
- return "";
243
- }
244
- if (typeof value === "object") {
245
- throw new Error("Value must be a number if using deprecated version");
246
- }
247
- let formatted = Number(value).toFixed(decimals2);
248
- formatted = formatted.replace(/(\.\d*?[1-9])0+$|\.0*$/, "$1");
249
- return formatted;
250
- }
251
- const {
252
- visibleDecimals,
253
- compact = true,
254
- percent = false,
255
- roundDown = false,
256
- roundUp = false,
257
- compactThreshold,
258
- maxValue,
259
- symbol,
260
- prefixText = "",
261
- suffixText = "",
262
- showIsSmallerThanMin = true,
263
- ifNullish = ""
264
- } = options || {};
265
- if (value === void 0 || value === null) {
266
- return ifNullish;
267
- }
268
- const number = percent ? Number(value) * 100 : Number(value);
269
- if (Number.isNaN(number)) {
270
- return "NaN";
271
- }
272
- if (number === Number.POSITIVE_INFINITY) {
273
- return "Infinity";
274
- }
275
- if (number === Number.NEGATIVE_INFINITY) {
276
- return "-Infinity";
277
- }
278
- let decimals = visibleDecimals ?? 0;
279
- if (number === 0) {
280
- decimals = 0;
281
- } else if (visibleDecimals === void 0) {
282
- if (Math.abs(number) > 1 || percent || symbol === "USD") {
283
- decimals = 2;
284
- } else {
285
- decimals = 7;
286
- }
287
- }
288
- const minValue = 10 ** -decimals;
289
- const isSmallerThanMin = number !== 0 && Math.abs(number) < Math.abs(minValue);
290
- const isNegative = number < 0;
291
- const isBiggerThanMax = maxValue ? Math.abs(number) > maxValue : false;
292
- let formattedNumber = isSmallerThanMin ? minValue : number;
293
- const forceCompact = compact && (!compactThreshold || Math.abs(number) > compactThreshold);
294
- if (roundDown && !forceCompact) {
295
- formattedNumber = Math.trunc(Number(formattedNumber) * 10 ** decimals) / 10 ** decimals;
296
- } else if (roundUp && !forceCompact) {
297
- formattedNumber = Math.ceil(Number(formattedNumber) * 10 ** decimals) / 10 ** decimals;
298
- }
299
- let formattedValue;
300
- if (isBiggerThanMax) {
301
- formattedValue = number > maxValue ? "\u221E" : "-\u221E";
302
- } else if (!forceCompact) {
303
- const absFormatted = new Intl.NumberFormat("en-US", {
304
- maximumFractionDigits: decimals,
305
- minimumFractionDigits: decimals
306
- }).format(Math.abs(formattedNumber));
307
- formattedValue = `${isNegative ? "-" : ""}${absFormatted}`;
308
- } else {
309
- const bnValue = valueToBigNumber(formattedNumber);
310
- let integerPlaces = bnValue.abs().toFixed(0).length;
311
- if (compactThreshold && Math.abs(number) <= compactThreshold) {
312
- integerPlaces = 0;
313
- }
314
- const significantDigitsGroup = Math.min(
315
- Math.floor(integerPlaces ? (integerPlaces - 1) / 3 : 0),
316
- POSTFIXES.length - 1
317
- );
318
- const postfix = POSTFIXES[significantDigitsGroup];
319
- let compactValue = normalizeBN(
320
- bnValue,
321
- 3 * significantDigitsGroup
322
- ).toNumber();
323
- if (roundDown) {
324
- compactValue = Math.trunc(Number(compactValue) * 10 ** decimals) / 10 ** decimals;
325
- } else if (roundUp) {
326
- compactValue = Math.ceil(Number(compactValue) * 10 ** decimals) / 10 ** decimals;
327
- }
328
- const prefix = new Intl.NumberFormat("en-US", {
329
- maximumFractionDigits: decimals,
330
- minimumFractionDigits: decimals
331
- }).format(compactValue);
332
- formattedValue = `${prefix}${postfix}`;
333
- }
334
- const parts = [];
335
- if (prefixText) {
336
- parts.push(prefixText);
337
- }
338
- if (isSmallerThanMin && showIsSmallerThanMin) {
339
- parts.push(number < 0 ? ">" : "<");
340
- }
341
- if (symbol?.toLowerCase() === "usd" && !percent) {
342
- parts.push("$");
343
- }
344
- parts.push(formattedValue);
345
- if (percent) {
346
- parts.push("%");
347
- }
348
- if (symbol?.toLowerCase() !== "usd" && typeof symbol !== "undefined") {
349
- parts.push(" ", symbol);
350
- }
351
- if (suffixText) {
352
- parts.push(suffixText);
353
- }
354
- return parts.join("");
355
- }
356
- var getSafeNumber = (value) => {
357
- if (!value) return 0;
358
- return Number(value) > Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : Number(value) ?? 0;
359
- };
360
- var truncateDecimal = (value, maxDecimal) => {
361
- if (!value) return "0";
362
- const [integerPart = "0", decimalPart = "0"] = `${value}`.split(".");
363
- return `${integerPart}.${decimalPart.substring(0, maxDecimal)}`;
364
- };
365
-
366
- // src/utils/getTestClient.ts
367
- import { createTestClient, http } from "viem";
368
- import {
369
- defaultChainId,
370
- getRpcUrls
371
- } from "@berachain/config/internal";
372
- function getTestClient(chainId = defaultChainId) {
373
- const rpc = getRpcUrls(chainId);
374
- if (!rpc.isAnvil) {
375
- throw new Error("No anvil RPC URL found");
376
- }
377
- return createTestClient({
378
- mode: "anvil",
379
- transport: http(rpc.jsonRpcUrl)
380
- });
381
- }
382
-
383
- export {
384
- bignumber_js_default,
385
- getErrorResponse,
386
- beraFetch,
387
- beraFetchJson,
388
- CAP_LIMIT_BUFFER,
389
- MAX_CUSTOM_DEADLINE,
390
- MIN_CUSTOM_DEADLINE,
391
- MIN_CUSTOM_SLIPPAGE,
392
- MAX_CUSTOM_SLIPPAGE,
393
- DEFAULT_METAMASK_GAS_LIMIT,
394
- getPythDefaultUpdateFee,
395
- msToSeconds,
396
- seconds,
397
- minutes,
398
- minutesInSeconds,
399
- hours,
400
- hoursInSeconds,
401
- days,
402
- daysInSeconds,
403
- weeks,
404
- weeksInSeconds,
405
- months,
406
- monthsInSeconds,
407
- years,
408
- yearsInSeconds,
409
- calculateTimestampFromDays,
410
- formatUnixTimestamp,
411
- formatTimeLeft,
412
- formatNumber,
413
- getSafeNumber,
414
- truncateDecimal,
415
- getTestClient
416
- };
417
- //# sourceMappingURL=chunk-ALPEMPZI.mjs.map
@@ -1,24 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/contexts/BeraFlags/defaultFlags.ts
2
- var defaultFlags = {
3
- isGovernanceEnabled: true,
4
- enableEip5792: false,
5
- proxyAggregatorsThroughVercel: false,
6
- isEmbeddedWalletsEnabled: true,
7
- sponsorGas: false,
8
- enableSimulateCalls: false,
9
- isBendVaultDataHourly: true,
10
- isBendLoopingEnabled: false,
11
- isMultiChainZapBendEnabled: false,
12
- isZapStakeBeraEnabled: false,
13
- mockValidatorOperator: false,
14
- mockValidatorRewardAllocator: false,
15
- isBgtPolRewardToken: true,
16
- mockRewardDurationManager: false,
17
- mockIncentiveManager: false,
18
- isHoneyPythWrapperEnabled: true
19
- };
20
-
21
-
22
-
23
- exports.defaultFlags = defaultFlags;
24
- //# sourceMappingURL=chunk-BEHP54S3.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/chunk-BEHP54S3.cjs","../src/contexts/BeraFlags/defaultFlags.ts"],"names":[],"mappings":"AAAA;ACgCO,IAAM,aAAA,EAA0B;AAAA,EACrC,mBAAA,EAAqB,IAAA;AAAA,EACrB,aAAA,EAAe,KAAA;AAAA,EACf,6BAAA,EAA+B,KAAA;AAAA,EAC/B,wBAAA,EAA0B,IAAA;AAAA,EAC1B,UAAA,EAAY,KAAA;AAAA,EACZ,mBAAA,EAAqB,KAAA;AAAA,EACrB,qBAAA,EAAuB,IAAA;AAAA,EACvB,oBAAA,EAAsB,KAAA;AAAA,EACtB,0BAAA,EAA4B,KAAA;AAAA,EAC5B,qBAAA,EAAuB,KAAA;AAAA,EACvB,qBAAA,EAAuB,KAAA;AAAA,EACvB,4BAAA,EAA8B,KAAA;AAAA,EAC9B,mBAAA,EAAqB,IAAA;AAAA,EACrB,yBAAA,EAA2B,KAAA;AAAA,EAC3B,oBAAA,EAAsB,KAAA;AAAA,EACtB,yBAAA,EAA2B;AAC7B,CAAA;AD9BA;AACA;AACE;AACF,oCAAC","file":"/Users/pong/coding/monobera/packages/berajs/dist/chunk-BEHP54S3.cjs","sourcesContent":[null,"import type { flags } from \"@berachain/config/internal/flags\";\n\ntype ClientSideFlags = keyof typeof flags;\n\nexport type BeraFlags = Record<\n Extract<\n ClientSideFlags,\n // We don't want to have all flags on the context. Just the ones that cannot be used server side only\n // this is because we generally should prefer server side flags, also according to flag-sdk docs\n | \"isGovernanceEnabled\"\n | \"enableEip5792\"\n | \"proxyAggregatorsThroughVercel\"\n | \"isEmbeddedWalletsEnabled\"\n | \"sponsorGas\"\n | \"enableSimulateCalls\"\n | \"isBendVaultDataHourly\"\n | \"isBendLoopingEnabled\"\n | \"isMultiChainZapBendEnabled\"\n | \"isZapStakeBeraEnabled\"\n | \"mockValidatorOperator\"\n | \"mockValidatorRewardAllocator\"\n | \"isBgtPolRewardToken\"\n | \"mockRewardDurationManager\"\n | \"mockIncentiveManager\"\n | \"isHoneyPythWrapperEnabled\"\n >,\n boolean | undefined\n>;\n\n/**\n * @private\n */\nexport const defaultFlags: BeraFlags = {\n isGovernanceEnabled: true,\n enableEip5792: false,\n proxyAggregatorsThroughVercel: false,\n isEmbeddedWalletsEnabled: true,\n sponsorGas: false,\n enableSimulateCalls: false,\n isBendVaultDataHourly: true,\n isBendLoopingEnabled: false,\n isMultiChainZapBendEnabled: false,\n isZapStakeBeraEnabled: false,\n mockValidatorOperator: false,\n mockValidatorRewardAllocator: false,\n isBgtPolRewardToken: true,\n mockRewardDurationManager: false,\n mockIncentiveManager: false,\n isHoneyPythWrapperEnabled: true,\n};\n"]}
@@ -1,135 +0,0 @@
1
- import {
2
- multicall3Abi
3
- } from "./chunk-ZCEFC2TK.mjs";
4
- import {
5
- assertAddress,
6
- assertDefined,
7
- assertPublicClient
8
- } from "./chunk-OWUI3VPI.mjs";
9
- import {
10
- isToken,
11
- parseBaseArgs
12
- } from "./chunk-J6EHBYSV.mjs";
13
-
14
- // src/actions/clients/getEnsoClient.ts
15
- import { EnsoClient } from "@ensofinance/sdk";
16
- import { appConfig } from "@berachain/config/internal";
17
- var isProduction = process.env.NODE_ENV !== "development" && process.env.NODE_ENV !== "test";
18
- function getEnsoClient({
19
- useProxy = isProduction,
20
- ...args
21
- } = {}) {
22
- const { config } = parseBaseArgs(args);
23
- return new EnsoClient({
24
- baseURL: useProxy ? `${config.bex.aggregatorsProxyUrl}/enso/api/v1/` : void 0,
25
- apiKey: useProxy ? (
26
- // no API key since proxy has CORS for .berachain.com domains
27
- ""
28
- ) : appConfig.apiKeys.public.enso
29
- });
30
- }
31
-
32
- // src/actions/tokens/getWalletBalances.ts
33
- import { getChainId, getPublicClient } from "@wagmi/core";
34
- import {
35
- erc20Abi,
36
- formatUnits,
37
- isAddress
38
- } from "viem";
39
- function getBalanceCall({
40
- token,
41
- account,
42
- multicallAddress
43
- }) {
44
- if (isToken(token, "BERA") || isToken(token, "ETH")) {
45
- return {
46
- address: multicallAddress,
47
- abi: multicall3Abi,
48
- functionName: "getEthBalance",
49
- args: [account]
50
- };
51
- }
52
- return {
53
- address: token.address,
54
- abi: erc20Abi,
55
- functionName: "balanceOf",
56
- args: [account]
57
- };
58
- }
59
- async function getWalletBalances({
60
- account,
61
- tokenList,
62
- wagmiConfig: config
63
- }) {
64
- assertDefined(config, "config");
65
- if (!account || !tokenList)
66
- throw new Error("account or tokenList is not defined");
67
- assertAddress(account, "account");
68
- const filteredTokenList = tokenList.filter(
69
- (token) => isAddress(token.address)
70
- );
71
- const tokensByChainId = Object.groupBy(
72
- filteredTokenList,
73
- (token) => token.chainId ?? getChainId(config)
74
- );
75
- const res = await Promise.allSettled(
76
- Object.entries(tokensByChainId).map(async ([chainId, tokens]) => {
77
- assertDefined(tokens, "tokens");
78
- const publicClient = getPublicClient(config, {
79
- chainId: Number(chainId)
80
- });
81
- assertPublicClient(publicClient, `publicClient ${chainId}`);
82
- assertDefined(publicClient.chain, "publicClient.chain");
83
- assertDefined(
84
- publicClient.chain.contracts,
85
- "publicClient.chain.contracts"
86
- );
87
- assertDefined(
88
- publicClient.chain.contracts.multicall3,
89
- "publicClient.chain.contracts.multicall3"
90
- );
91
- const { multicall3 } = publicClient.chain.contracts;
92
- const multicall3Address = typeof multicall3 === "string" ? multicall3 : multicall3.address;
93
- assertAddress(multicall3Address, "multicall3Address");
94
- const call = tokens.map(
95
- (token) => getBalanceCall({
96
- token,
97
- account,
98
- multicallAddress: multicall3Address
99
- })
100
- );
101
- const result = await publicClient.multicall({
102
- contracts: call
103
- });
104
- return result.map((item, index) => {
105
- const token = tokens[index];
106
- if (item.error) {
107
- return { ...token, balance: { raw: "0", formatted: "0" } };
108
- }
109
- const formattedBalance = formatUnits(
110
- item.result,
111
- token?.decimals || 18
112
- );
113
- const resultBalanceToken = {
114
- ...token,
115
- balance: {
116
- raw: item.result.toString(),
117
- // TODO: this was done 10 months ago, i'm not sure it's a good solution.
118
- formatted: formattedBalance.includes("e") ? "0" : formattedBalance
119
- }
120
- };
121
- return resultBalanceToken;
122
- });
123
- })
124
- );
125
- return res.flatMap(
126
- (result) => result.status === "fulfilled" ? result.value : []
127
- );
128
- }
129
-
130
- export {
131
- getEnsoClient,
132
- getBalanceCall,
133
- getWalletBalances
134
- };
135
- //# sourceMappingURL=chunk-CYBZH6U3.mjs.map
@@ -1,13 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/enum/polling.ts
2
- var POLLING = /* @__PURE__ */ ((POLLING2) => {
3
- POLLING2[POLLING2["FAST"] = 1e4] = "FAST";
4
- POLLING2[POLLING2["NORMAL"] = 1e5] = "NORMAL";
5
- POLLING2[POLLING2["SLOW"] = 18e4] = "SLOW";
6
- POLLING2[POLLING2["REFRESH_BLOCK_INTERVAL"] = 1e4] = "REFRESH_BLOCK_INTERVAL";
7
- return POLLING2;
8
- })(POLLING || {});
9
-
10
-
11
-
12
- exports.POLLING = POLLING;
13
- //# sourceMappingURL=chunk-EWBKSMPG.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/chunk-EWBKSMPG.cjs","../src/enum/polling.ts"],"names":["POLLING"],"mappings":"AAAA;ACAA,IAAK,QAAA,kBAAL,CAAA,CAAKA,QAAAA,EAAAA,GAAL;AACE,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,MAAA,EAAA,EAAO,GAAA,EAAA,EAAP,MAAA;AACA,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,QAAA,EAAA,EAAS,GAAA,EAAA,EAAT,QAAA;AACA,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,MAAA,EAAA,EAAO,IAAA,EAAA,EAAP,MAAA;AACA,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,wBAAA,EAAA,EAAyB,GAAA,EAAA,EAAzB,wBAAA;AAJG,EAAA,OAAAA,QAAAA;AAAA,CAAA,CAAA,CAAA,QAAA,GAAA,CAAA,CAAA,CAAA;ADQL;AACA;AACE;AACF,0BAAC","file":"/Users/pong/coding/monobera/packages/berajs/dist/chunk-EWBKSMPG.cjs","sourcesContent":[null,"enum POLLING {\n FAST = 10000, // 10 sec\n NORMAL = 100000, // 100 sec\n SLOW = 180000, // 3 min\n REFRESH_BLOCK_INTERVAL = 10000, // 10 sec\n}\n\nexport { POLLING };\n"]}
@@ -1,13 +0,0 @@
1
- // src/enum/polling.ts
2
- var POLLING = /* @__PURE__ */ ((POLLING2) => {
3
- POLLING2[POLLING2["FAST"] = 1e4] = "FAST";
4
- POLLING2[POLLING2["NORMAL"] = 1e5] = "NORMAL";
5
- POLLING2[POLLING2["SLOW"] = 18e4] = "SLOW";
6
- POLLING2[POLLING2["REFRESH_BLOCK_INTERVAL"] = 1e4] = "REFRESH_BLOCK_INTERVAL";
7
- return POLLING2;
8
- })(POLLING || {});
9
-
10
- export {
11
- POLLING
12
- };
13
- //# sourceMappingURL=chunk-GLWPRM33.mjs.map