@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,226 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkProposalField,
|
|
3
|
+
getAllProposals,
|
|
4
|
+
getBodyErrors,
|
|
5
|
+
getProposalDetails,
|
|
6
|
+
getProposalFromTx,
|
|
7
|
+
getProposalVotes,
|
|
8
|
+
parseProposalBody
|
|
9
|
+
} from "../../chunk-AFN4CVD3.mjs";
|
|
10
|
+
import "../../chunk-DKMAIU74.mjs";
|
|
11
|
+
import "../../chunk-KQUMKB66.mjs";
|
|
12
|
+
import "../../chunk-J5I45WGQ.mjs";
|
|
13
|
+
|
|
14
|
+
// src/actions/governance/computeActualStatus.ts
|
|
15
|
+
import {
|
|
16
|
+
ProposalStatus
|
|
17
|
+
} from "@berachain/graphql/governance";
|
|
18
|
+
var GOVERNANCE_ACCELERATE_PROPOSAL = false;
|
|
19
|
+
var MOCKED_PROPOSAL_STATUSES = [
|
|
20
|
+
ProposalStatus.Active,
|
|
21
|
+
ProposalStatus.PendingQueue,
|
|
22
|
+
ProposalStatus.PendingExecution,
|
|
23
|
+
ProposalStatus.Defeated,
|
|
24
|
+
ProposalStatus.QuorumNotReached
|
|
25
|
+
];
|
|
26
|
+
function computeActualStatus(proposal, proposalOnChainState) {
|
|
27
|
+
const timestampInSeconds = Date.now() / 1e3;
|
|
28
|
+
if (proposalOnChainState !== void 0) {
|
|
29
|
+
if (proposal.status === ProposalStatus.CanceledByGuardian) {
|
|
30
|
+
return ProposalStatus.CanceledByGuardian;
|
|
31
|
+
}
|
|
32
|
+
if (proposalOnChainState === 2 /* Canceled */) {
|
|
33
|
+
if (Number(proposal.voteStartAt) < timestampInSeconds)
|
|
34
|
+
return ProposalStatus.CanceledByUser;
|
|
35
|
+
return ProposalStatus.CanceledByGuardian;
|
|
36
|
+
}
|
|
37
|
+
if (proposalOnChainState === 3 /* Defeated */) {
|
|
38
|
+
if (!proposal.pollResult) {
|
|
39
|
+
return ProposalStatus.QuorumNotReached;
|
|
40
|
+
}
|
|
41
|
+
if (
|
|
42
|
+
// Quorum might be null if no votes were cast.
|
|
43
|
+
!proposal.quorum || BigInt(proposal.quorum) > BigInt(proposal.pollResult.totalTowardsQuorum)
|
|
44
|
+
) {
|
|
45
|
+
return ProposalStatus.QuorumNotReached;
|
|
46
|
+
}
|
|
47
|
+
return ProposalStatus.Defeated;
|
|
48
|
+
}
|
|
49
|
+
if (proposalOnChainState === 4 /* Succeeded */) {
|
|
50
|
+
return ProposalStatus.PendingQueue;
|
|
51
|
+
}
|
|
52
|
+
if (proposalOnChainState === 5 /* Queued */) {
|
|
53
|
+
if (Number(proposal.queueEnd) < Date.now() / 1e3) {
|
|
54
|
+
return ProposalStatus.PendingExecution;
|
|
55
|
+
}
|
|
56
|
+
return ProposalStatus.InQueue;
|
|
57
|
+
}
|
|
58
|
+
if (proposalOnChainState === 6 /* Expired */) {
|
|
59
|
+
console.warn("Unexpected expired state on proposal id: ", proposal.id);
|
|
60
|
+
return ProposalStatus.Defeated;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (proposal.status === ProposalStatus.InQueue) {
|
|
64
|
+
if (Number(proposal.queueEnd) < Date.now() / 1e3) {
|
|
65
|
+
return ProposalStatus.PendingExecution;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (GOVERNANCE_ACCELERATE_PROPOSAL && proposalOnChainState === 1 /* Active */ && proposal.quorum && BigInt(proposal.quorum) < BigInt(proposal.pollResult.totalTowardsQuorum) && Number(proposal.pollResult.forPercentage) > Number(proposal.pollResult.againstPercentage)) {
|
|
69
|
+
return ProposalStatus.PendingQueue;
|
|
70
|
+
}
|
|
71
|
+
if (proposal.status === ProposalStatus.Pending) {
|
|
72
|
+
if (Number(proposal.voteStartAt) < timestampInSeconds && Number(proposal.voteEndAt) > timestampInSeconds) {
|
|
73
|
+
return ProposalStatus.Active;
|
|
74
|
+
}
|
|
75
|
+
if (Number(proposal.voteEndAt) < timestampInSeconds) {
|
|
76
|
+
if (!proposal.pollResult) {
|
|
77
|
+
return ProposalStatus.QuorumNotReached;
|
|
78
|
+
}
|
|
79
|
+
if (!proposal.quorum || BigInt(proposal.quorum) > BigInt(proposal.pollResult.totalTowardsQuorum)) {
|
|
80
|
+
return ProposalStatus.QuorumNotReached;
|
|
81
|
+
}
|
|
82
|
+
if (proposal.pollResult?.against > proposal.pollResult?.for) {
|
|
83
|
+
return ProposalStatus.Defeated;
|
|
84
|
+
}
|
|
85
|
+
return ProposalStatus.PendingQueue;
|
|
86
|
+
}
|
|
87
|
+
return ProposalStatus.Pending;
|
|
88
|
+
}
|
|
89
|
+
if (proposal.status === ProposalStatus.Active && Number(proposal.voteEndAt) < timestampInSeconds) {
|
|
90
|
+
if (!proposal.quorum || BigInt(proposal.quorum) > BigInt(proposal.pollResult.totalTowardsQuorum)) {
|
|
91
|
+
return ProposalStatus.QuorumNotReached;
|
|
92
|
+
}
|
|
93
|
+
if (BigInt(proposal.pollResult?.against ?? 0n) > BigInt(proposal.pollResult?.for ?? 0n)) {
|
|
94
|
+
return ProposalStatus.Defeated;
|
|
95
|
+
}
|
|
96
|
+
return ProposalStatus.PendingQueue;
|
|
97
|
+
}
|
|
98
|
+
if (proposal.status === ProposalStatus.InQueue) {
|
|
99
|
+
if (Number(proposal.queueEnd) < Date.now() / 1e3) {
|
|
100
|
+
return ProposalStatus.PendingExecution;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return proposal.status;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/actions/governance/getDecodedFunctionData.ts
|
|
107
|
+
import {
|
|
108
|
+
decodeFunctionData,
|
|
109
|
+
erc20Abi,
|
|
110
|
+
pad,
|
|
111
|
+
toFunctionSignature,
|
|
112
|
+
trim
|
|
113
|
+
} from "viem";
|
|
114
|
+
import { appConfig, defaultChainId } from "@berachain/config/internal";
|
|
115
|
+
import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
|
|
116
|
+
import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
|
|
117
|
+
function isProxyABI(abi) {
|
|
118
|
+
return abi.some((item) => {
|
|
119
|
+
const i = item;
|
|
120
|
+
return i.name === "implementation" || i.name === "proxyType" || i.type === "constructor" && i.inputs?.[0]?.name === "implementation";
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async function _getAbi({
|
|
124
|
+
contractAddress,
|
|
125
|
+
chainId,
|
|
126
|
+
publicClient
|
|
127
|
+
}) {
|
|
128
|
+
const url = `https://api.etherscan.io/v2/api?module=contract&action=getabi&address=${contractAddress}&apikey=${appConfig.apiKeys.private.etherscan}&chainId=${chainId}`;
|
|
129
|
+
const response = await fetch(url);
|
|
130
|
+
if (!response.ok) {
|
|
131
|
+
throw new Error(`Failed to fetch ABI: ${response.statusText}`);
|
|
132
|
+
}
|
|
133
|
+
const data = await response.json();
|
|
134
|
+
if (data.status === "0") throw new Error(data.result);
|
|
135
|
+
const abi = JSON.parse(data.result);
|
|
136
|
+
if (!isProxyABI(abi)) return abi;
|
|
137
|
+
const implementationResult = await publicClient.getStorageAt({
|
|
138
|
+
address: contractAddress,
|
|
139
|
+
// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)).
|
|
140
|
+
slot: "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"
|
|
141
|
+
});
|
|
142
|
+
if (!implementationResult || trim(implementationResult) === "0x00")
|
|
143
|
+
return abi;
|
|
144
|
+
const implementationAddress = pad(trim(implementationResult), { size: 20 });
|
|
145
|
+
return _getAbi({
|
|
146
|
+
contractAddress: implementationAddress,
|
|
147
|
+
chainId,
|
|
148
|
+
publicClient
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async function _getAbiForCallData({
|
|
152
|
+
address,
|
|
153
|
+
callData,
|
|
154
|
+
knownAbi,
|
|
155
|
+
chainId,
|
|
156
|
+
publicClient
|
|
157
|
+
}) {
|
|
158
|
+
try {
|
|
159
|
+
if (decodeFunctionData({ data: callData, abi: knownAbi })) {
|
|
160
|
+
return knownAbi;
|
|
161
|
+
}
|
|
162
|
+
} catch {
|
|
163
|
+
}
|
|
164
|
+
return _getAbi({ contractAddress: address, chainId, publicClient }).catch(
|
|
165
|
+
() => void 0
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
function _decodeCallData(callData, abi) {
|
|
169
|
+
try {
|
|
170
|
+
return decodeFunctionData({ data: callData, abi });
|
|
171
|
+
} catch {
|
|
172
|
+
return void 0;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function _findAbiItem(abi, functionName) {
|
|
176
|
+
return abi.find(
|
|
177
|
+
(a) => a.type === "function" && a.name === functionName
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
function _getFunctionSignature(abiItem) {
|
|
181
|
+
if (!abiItem) return;
|
|
182
|
+
try {
|
|
183
|
+
return toFunctionSignature(abiItem);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
console.error(error);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async function getDecodedFunctionData({
|
|
189
|
+
address,
|
|
190
|
+
callData,
|
|
191
|
+
chainId = defaultChainId,
|
|
192
|
+
publicClient
|
|
193
|
+
}) {
|
|
194
|
+
const knownAbi = [...beraChefAbi, ...rewardVaultAbi, ...erc20Abi];
|
|
195
|
+
const abi = await _getAbiForCallData({
|
|
196
|
+
address,
|
|
197
|
+
callData,
|
|
198
|
+
knownAbi,
|
|
199
|
+
chainId,
|
|
200
|
+
publicClient
|
|
201
|
+
});
|
|
202
|
+
const decodedData = _decodeCallData(callData, abi);
|
|
203
|
+
if (!abi || !decodedData) {
|
|
204
|
+
return { args: [] };
|
|
205
|
+
}
|
|
206
|
+
const abiItem = _findAbiItem(abi, decodedData.functionName);
|
|
207
|
+
const functionSignature = _getFunctionSignature(abiItem);
|
|
208
|
+
return {
|
|
209
|
+
abiItem,
|
|
210
|
+
functionSignature,
|
|
211
|
+
functionName: decodedData.functionName,
|
|
212
|
+
args: decodedData.args
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
export {
|
|
216
|
+
MOCKED_PROPOSAL_STATUSES,
|
|
217
|
+
checkProposalField,
|
|
218
|
+
computeActualStatus,
|
|
219
|
+
getAllProposals,
|
|
220
|
+
getBodyErrors,
|
|
221
|
+
getDecodedFunctionData,
|
|
222
|
+
getProposalDetails,
|
|
223
|
+
getProposalFromTx,
|
|
224
|
+
getProposalVotes,
|
|
225
|
+
parseProposalBody
|
|
226
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { GetValidatorBlockStatsQuery } from '@berachain/graphql/pol/subgraph';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Server-only RSC variant. Goes directly to the pol subgraph upstream
|
|
6
|
+
* (no auth required) through the shared Apollo client factory.
|
|
7
|
+
*/
|
|
8
|
+
declare function getDailyValidatorBlockStats({ pubKey, first, ...args }: BeraJS.BaseFunctionArgs & {
|
|
9
|
+
pubKey: Address;
|
|
10
|
+
first?: number;
|
|
11
|
+
}): Promise<GetValidatorBlockStatsQuery | undefined>;
|
|
12
|
+
|
|
13
|
+
export { getDailyValidatorBlockStats };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getApolloClient
|
|
3
|
+
} from "../../chunk-4Z4AK6SH.mjs";
|
|
4
|
+
import "../../chunk-75M6TF7M.mjs";
|
|
5
|
+
import "../../chunk-SZ5C44L5.mjs";
|
|
6
|
+
import "../../chunk-XIYN6AL6.mjs";
|
|
7
|
+
import "../../chunk-J5I45WGQ.mjs";
|
|
8
|
+
|
|
9
|
+
// src/actions/server/getDailyValidatorBlockStats.ts
|
|
10
|
+
import {
|
|
11
|
+
GetValidatorBlockStats
|
|
12
|
+
} from "@berachain/graphql/pol/subgraph";
|
|
13
|
+
async function getDailyValidatorBlockStats({
|
|
14
|
+
pubKey,
|
|
15
|
+
first = 1,
|
|
16
|
+
...args
|
|
17
|
+
}) {
|
|
18
|
+
const client = getApolloClient("pol.subgraph", args);
|
|
19
|
+
const result = await client.query({
|
|
20
|
+
query: GetValidatorBlockStats,
|
|
21
|
+
variables: { pubKey, first }
|
|
22
|
+
});
|
|
23
|
+
return result.data;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
getDailyValidatorBlockStats
|
|
27
|
+
};
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getBalanceCall,
|
|
3
3
|
getEnsoClient
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HSSJKHZ4.mjs";
|
|
5
5
|
import {
|
|
6
6
|
BeraMonitoring,
|
|
7
7
|
initBeraError
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EXIUPSFN.mjs";
|
|
9
9
|
import {
|
|
10
10
|
defaultFlags
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BGMRHTBQ.mjs";
|
|
12
12
|
import {
|
|
13
13
|
beraToken,
|
|
14
|
-
isToken
|
|
14
|
+
isToken
|
|
15
|
+
} from "./chunk-NPBQLVL3.mjs";
|
|
16
|
+
import {
|
|
15
17
|
parseBaseArgs
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-75M6TF7M.mjs";
|
|
17
19
|
import {
|
|
18
20
|
BeraError,
|
|
19
21
|
InvalidArgumentError
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-J5I45WGQ.mjs";
|
|
21
23
|
|
|
22
24
|
// src/contexts/BeraFlags/BeraFlags.tsx
|
|
23
25
|
import { createContext, useContext } from "react";
|
|
@@ -272,15 +274,25 @@ async function getEnsoUserTokensWithBalances({
|
|
|
272
274
|
function useEnsoUserTokensWithBalances({ chainId } = {}, options) {
|
|
273
275
|
const { address: fromAddress } = useBeraWallet();
|
|
274
276
|
const wagmiConfig = useConfig();
|
|
277
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
278
|
+
"proxyAggregatorsThroughVercel"
|
|
279
|
+
);
|
|
275
280
|
const isEnabled = !!fromAddress && (options?.opts?.isEnabled ?? true);
|
|
276
|
-
const QUERY_KEY = isEnabled && wagmiConfig ? [
|
|
281
|
+
const QUERY_KEY = isEnabled && wagmiConfig ? [
|
|
282
|
+
"useEnsoUserTokensWithBalances",
|
|
283
|
+
fromAddress,
|
|
284
|
+
chainId,
|
|
285
|
+
proxyAggregatorsThroughVercel ?? false
|
|
286
|
+
] : null;
|
|
277
287
|
const swrResponse = useSWR(
|
|
278
288
|
QUERY_KEY,
|
|
279
289
|
async ([, fromAddress2, chainId2]) => getEnsoUserTokensWithBalances({
|
|
280
290
|
account: fromAddress2,
|
|
281
291
|
wagmiConfig,
|
|
282
292
|
chainId: chainId2 ?? "all",
|
|
283
|
-
ensoClient: getEnsoClient(
|
|
293
|
+
ensoClient: getEnsoClient({
|
|
294
|
+
baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : void 0
|
|
295
|
+
})
|
|
284
296
|
}),
|
|
285
297
|
{
|
|
286
298
|
refreshInterval: 1e5 /* NORMAL */,
|
|
@@ -400,4 +412,3 @@ export {
|
|
|
400
412
|
TokenContext,
|
|
401
413
|
TokensProvider
|
|
402
414
|
};
|
|
403
|
-
//# sourceMappingURL=chunk-VA3BQ34H.mjs.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseBaseArgs
|
|
3
|
+
} from "./chunk-75M6TF7M.mjs";
|
|
4
|
+
import {
|
|
5
|
+
BeraTracing
|
|
6
|
+
} from "./chunk-SZ5C44L5.mjs";
|
|
7
|
+
import {
|
|
8
|
+
RequestError
|
|
9
|
+
} from "./chunk-XIYN6AL6.mjs";
|
|
10
|
+
import {
|
|
11
|
+
BeraError
|
|
12
|
+
} from "./chunk-J5I45WGQ.mjs";
|
|
13
|
+
|
|
14
|
+
// src/actions/clients/BeraApolloClient.ts
|
|
15
|
+
import {
|
|
16
|
+
ApolloClient,
|
|
17
|
+
ServerError
|
|
18
|
+
} from "@apollo/client";
|
|
19
|
+
import { appConfig } from "@berachain/config/internal";
|
|
20
|
+
var BeraApolloClient = class extends ApolloClient {
|
|
21
|
+
/**
|
|
22
|
+
* The URL of the endpoint. Used for error reporting only.
|
|
23
|
+
*/
|
|
24
|
+
url;
|
|
25
|
+
serviceName;
|
|
26
|
+
constructor(options) {
|
|
27
|
+
super(options);
|
|
28
|
+
this.url = options.url;
|
|
29
|
+
this.serviceName = options.name;
|
|
30
|
+
}
|
|
31
|
+
async query(options) {
|
|
32
|
+
const queryName = getQueryName(options.query);
|
|
33
|
+
const endpoint = {
|
|
34
|
+
url: this.url,
|
|
35
|
+
type: "graphql",
|
|
36
|
+
name: this.serviceName
|
|
37
|
+
};
|
|
38
|
+
const tags = {
|
|
39
|
+
"operation.type": "query",
|
|
40
|
+
"operation.source.name": endpoint.name,
|
|
41
|
+
"operation.source.url": endpoint.url,
|
|
42
|
+
"operation.source.type": endpoint.type,
|
|
43
|
+
"operation.source.queryName": queryName
|
|
44
|
+
};
|
|
45
|
+
try {
|
|
46
|
+
const executeQuery = () => super.query(
|
|
47
|
+
options
|
|
48
|
+
);
|
|
49
|
+
const res = await BeraTracing.startSpan(
|
|
50
|
+
{
|
|
51
|
+
name: `GraphQL ${queryName}`,
|
|
52
|
+
op: "BeraApolloClient.query",
|
|
53
|
+
attributes: tags
|
|
54
|
+
},
|
|
55
|
+
executeQuery
|
|
56
|
+
);
|
|
57
|
+
if (res.error || res.data === void 0) {
|
|
58
|
+
throw new BeraError({
|
|
59
|
+
level: "fatal",
|
|
60
|
+
tags,
|
|
61
|
+
message: "Bera Apollo Client: No data returned from query, but error should be thrown since errorPolicy is none"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return { data: res.data };
|
|
65
|
+
} catch (error) {
|
|
66
|
+
!appConfig.env.isProduction && console.error("BeraApolloClient error", error);
|
|
67
|
+
if (ServerError.is(error)) {
|
|
68
|
+
throw new RequestError({
|
|
69
|
+
// reason: error,
|
|
70
|
+
response: error.response,
|
|
71
|
+
cause: error,
|
|
72
|
+
statusCode: error.statusCode,
|
|
73
|
+
endpoint,
|
|
74
|
+
tags
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (error instanceof TypeError) {
|
|
78
|
+
throw new RequestError({
|
|
79
|
+
level: "fatal",
|
|
80
|
+
reason: "TypeError",
|
|
81
|
+
response: error,
|
|
82
|
+
cause: error,
|
|
83
|
+
endpoint,
|
|
84
|
+
tags
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
throw new RequestError({
|
|
88
|
+
response: error,
|
|
89
|
+
tags,
|
|
90
|
+
cause: error,
|
|
91
|
+
endpoint
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
function getQueryName(queryDefinition) {
|
|
97
|
+
const likelyNode = queryDefinition.definitions.find(
|
|
98
|
+
(def) => def.kind === "OperationDefinition"
|
|
99
|
+
);
|
|
100
|
+
return likelyNode?.name?.value;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/actions/clients/getApolloClient.ts
|
|
104
|
+
import { InMemoryCache } from "@apollo/client";
|
|
105
|
+
import { HttpLink } from "@apollo/client/link/http";
|
|
106
|
+
import { getUriFromLink } from "@berachain/config";
|
|
107
|
+
import { currentDapp, goldskyBaseUrl } from "@berachain/config/internal";
|
|
108
|
+
import apiResults from "@berachain/graphql/dex/api";
|
|
109
|
+
import { gql } from "@apollo/client";
|
|
110
|
+
function applyStellateClientName(url) {
|
|
111
|
+
const headers = typeof url === "string" ? void 0 : url.headers;
|
|
112
|
+
const isDapp = !!currentDapp;
|
|
113
|
+
const isTest = process.env.VERCEL_ENV === "test";
|
|
114
|
+
const uri = getUriFromLink(url);
|
|
115
|
+
const name = typeof url === "string" ? "unknown" : url.name;
|
|
116
|
+
return {
|
|
117
|
+
uri,
|
|
118
|
+
name,
|
|
119
|
+
headers: {
|
|
120
|
+
...headers,
|
|
121
|
+
"x-graphql-client-name": `berachain.${isDapp ? "dapps" : isTest ? "test" : (
|
|
122
|
+
// this tracks usage of the berajs package in other packages
|
|
123
|
+
"berajs"
|
|
124
|
+
)}`,
|
|
125
|
+
"x-graphql-client-version": `${process.env.VERCEL_TARGET_ENV}.${process.env.VERCEL_GIT_COMMIT_SHA}`
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function getClient(endpoint, {
|
|
130
|
+
ssrMode,
|
|
131
|
+
inMemoryCacheOptions
|
|
132
|
+
} = {}) {
|
|
133
|
+
const url = getUriFromLink(endpoint);
|
|
134
|
+
const headers = typeof endpoint === "string" ? void 0 : endpoint.headers;
|
|
135
|
+
let name = typeof endpoint === "string" ? void 0 : endpoint.name;
|
|
136
|
+
if (!name && url.includes(goldskyBaseUrl)) {
|
|
137
|
+
name = url.replace(goldskyBaseUrl, "").replace("/gn", "");
|
|
138
|
+
}
|
|
139
|
+
return new BeraApolloClient({
|
|
140
|
+
url,
|
|
141
|
+
name: name ?? "unknown",
|
|
142
|
+
link: new HttpLink({
|
|
143
|
+
uri: url,
|
|
144
|
+
headers
|
|
145
|
+
}),
|
|
146
|
+
defaultOptions: {
|
|
147
|
+
query: {
|
|
148
|
+
// With the default none error policy, an error causes the promise to reject.
|
|
149
|
+
errorPolicy: "none",
|
|
150
|
+
fetchPolicy: "no-cache"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
cache: new InMemoryCache(inMemoryCacheOptions),
|
|
154
|
+
ssrMode
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
var SUBGRAPH_CLIENTS = [
|
|
158
|
+
"honey.subgraph",
|
|
159
|
+
"pol.subgraph"
|
|
160
|
+
];
|
|
161
|
+
function isSubgraphClient(name) {
|
|
162
|
+
return SUBGRAPH_CLIENTS.includes(name);
|
|
163
|
+
}
|
|
164
|
+
var clientCache = /* @__PURE__ */ new Map();
|
|
165
|
+
function store(cacheKey, client) {
|
|
166
|
+
if (cacheKey) clientCache.set(cacheKey, client);
|
|
167
|
+
return client;
|
|
168
|
+
}
|
|
169
|
+
function getApolloClient(clientName, { ...args }) {
|
|
170
|
+
if (typeof window !== "undefined" && isSubgraphClient(clientName)) {
|
|
171
|
+
throw new BeraError({
|
|
172
|
+
message: "Subgraph Apollo client is server-only",
|
|
173
|
+
level: "error"
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
const { config, chainId } = parseBaseArgs(args);
|
|
177
|
+
const cacheKey = args.config ? null : `${chainId}:${clientName}`;
|
|
178
|
+
if (cacheKey) {
|
|
179
|
+
const cached = clientCache.get(cacheKey);
|
|
180
|
+
if (cached) return cached;
|
|
181
|
+
}
|
|
182
|
+
switch (clientName) {
|
|
183
|
+
case "api":
|
|
184
|
+
return store(
|
|
185
|
+
cacheKey,
|
|
186
|
+
getClient(applyStellateClientName(config.api), {
|
|
187
|
+
inMemoryCacheOptions: {
|
|
188
|
+
possibleTypes: apiResults.possibleTypes
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
);
|
|
192
|
+
case "bend.whisk":
|
|
193
|
+
if (!config.bend.whiskApi) {
|
|
194
|
+
throw new BeraError({
|
|
195
|
+
message: "Bend whisk API is not configured on this chain",
|
|
196
|
+
level: "error"
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return store(cacheKey, getClient(config.bend.whiskApi));
|
|
200
|
+
case "honey.subgraph":
|
|
201
|
+
return store(cacheKey, getClient(config.honey.subgraph));
|
|
202
|
+
case "pol.subgraph":
|
|
203
|
+
return store(cacheKey, getClient(config.pol.subgraph));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export {
|
|
208
|
+
BeraApolloClient,
|
|
209
|
+
getApolloClient,
|
|
210
|
+
gql
|
|
211
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InvalidArgumentError
|
|
3
|
+
} from "./chunk-J5I45WGQ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/utils/parseBaseArgs.ts
|
|
6
|
+
import {
|
|
7
|
+
chainConfigs,
|
|
8
|
+
defaultChainId
|
|
9
|
+
} from "@berachain/config/internal";
|
|
10
|
+
function parseBaseArgs(args) {
|
|
11
|
+
const chainId = args.chainId ?? defaultChainId;
|
|
12
|
+
const config = args.config ?? chainConfigs[chainId];
|
|
13
|
+
if (args.chainId && args.chainId !== config.chainId) {
|
|
14
|
+
throw new InvalidArgumentError({
|
|
15
|
+
property: "chainId",
|
|
16
|
+
value: chainId,
|
|
17
|
+
expected: `config.chainId: ${config.chainId}`
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return { config, chainId: config.chainId };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
parseBaseArgs
|
|
25
|
+
};
|