@berachain/berajs 0.2.4 → 0.2.6-patch.1
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/README.md +0 -0
- package/dist/abi/exports.cjs +1 -1
- package/dist/abi/exports.cjs.map +1 -1
- package/dist/abi/exports.d.cts +17 -1
- package/dist/abi/exports.d.ts +17 -1
- package/dist/abi/exports.mjs +1 -1
- package/dist/abi/exports.mjs.map +1 -1
- package/dist/actions/exports.cjs +1 -1
- package/dist/actions/exports.cjs.map +1 -1
- package/dist/actions/exports.d.cts +9 -38
- package/dist/actions/exports.d.ts +9 -38
- package/dist/actions/exports.mjs +1 -1
- package/dist/actions/exports.mjs.map +1 -1
- package/dist/chunk-2YBHAMDV.cjs +2 -0
- package/dist/chunk-2YBHAMDV.cjs.map +1 -0
- package/dist/chunk-57RINXU6.cjs +2 -0
- package/dist/chunk-57RINXU6.cjs.map +1 -0
- package/dist/{chunk-AX2YQQFQ.mjs → chunk-74QD4JAH.mjs} +2 -2
- package/dist/chunk-74QD4JAH.mjs.map +1 -0
- package/dist/chunk-74WA35RI.cjs +2 -0
- package/dist/chunk-74WA35RI.cjs.map +1 -0
- package/dist/{chunk-7WRTK7RJ.mjs → chunk-BEKH5EYT.mjs} +2 -2
- package/dist/chunk-BEKH5EYT.mjs.map +1 -0
- package/dist/{chunk-FCWDGE62.cjs → chunk-CF3LFNXG.cjs} +2 -2
- package/dist/chunk-CF3LFNXG.cjs.map +1 -0
- package/dist/chunk-COMMLZ3O.mjs +2 -0
- package/dist/chunk-COMMLZ3O.mjs.map +1 -0
- package/dist/chunk-DDEQFR3M.cjs +2 -0
- package/dist/chunk-DDEQFR3M.cjs.map +1 -0
- package/dist/{chunk-6LDOG5RL.cjs → chunk-DK42F2ZM.cjs} +2 -2
- package/dist/chunk-DK42F2ZM.cjs.map +1 -0
- package/dist/{chunk-7SMWQ6SN.mjs → chunk-FM3WDBFH.mjs} +2 -2
- package/dist/chunk-FM3WDBFH.mjs.map +1 -0
- package/dist/chunk-HWOGQSNL.cjs +4 -0
- package/dist/chunk-HWOGQSNL.cjs.map +1 -0
- package/dist/chunk-I7M43BB4.cjs +2 -0
- package/dist/chunk-I7M43BB4.cjs.map +1 -0
- package/dist/chunk-IBJOI5SN.mjs +4 -0
- package/dist/chunk-IBJOI5SN.mjs.map +1 -0
- package/dist/chunk-IDFMLLDY.mjs +2 -0
- package/dist/chunk-IDFMLLDY.mjs.map +1 -0
- package/dist/{chunk-YZV5LKIP.cjs → chunk-LNVR4BW6.cjs} +2 -2
- package/dist/chunk-LNVR4BW6.cjs.map +1 -0
- package/dist/chunk-MJZHJFZO.mjs +2 -0
- package/dist/{chunk-YNO7BCCM.mjs.map → chunk-MJZHJFZO.mjs.map} +1 -1
- package/dist/chunk-MK5NS5B5.mjs +2 -0
- package/dist/chunk-MK5NS5B5.mjs.map +1 -0
- package/dist/{chunk-C6ZGUO4H.cjs → chunk-NMH7LHPW.cjs} +2 -2
- package/dist/chunk-NMH7LHPW.cjs.map +1 -0
- package/dist/chunk-NVHV2LDK.cjs +2 -0
- package/dist/chunk-NVHV2LDK.cjs.map +1 -0
- package/dist/chunk-OGBD5YOG.mjs +2 -0
- package/dist/chunk-OGBD5YOG.mjs.map +1 -0
- package/dist/chunk-OIYXOKTT.cjs.map +1 -1
- package/dist/chunk-OUD27MU7.cjs.map +1 -1
- package/dist/chunk-PLIH6KQM.mjs +2 -0
- package/dist/chunk-PLIH6KQM.mjs.map +1 -0
- package/dist/chunk-QRAIGQF2.mjs +2 -0
- package/dist/chunk-QRAIGQF2.mjs.map +1 -0
- package/dist/chunk-RWOICHRW.cjs +2 -0
- package/dist/chunk-RWOICHRW.cjs.map +1 -0
- package/dist/chunk-T5FSQ3YE.mjs +2 -0
- package/dist/chunk-T5FSQ3YE.mjs.map +1 -0
- package/dist/chunk-WRFDB3QJ.cjs.map +1 -1
- package/dist/chunk-XNJLSA6P.cjs.map +1 -1
- package/dist/contexts/exports.cjs +1 -1
- package/dist/contexts/exports.cjs.map +1 -1
- package/dist/contexts/exports.d.cts +1 -1
- package/dist/contexts/exports.d.ts +1 -1
- package/dist/contexts/exports.mjs +1 -1
- package/dist/contexts/exports.mjs.map +1 -1
- package/dist/{defaultFlags-d0kPbT0i.d.cts → defaultFlags-D6KfkTZx.d.cts} +1 -1
- package/dist/{defaultFlags-d0kPbT0i.d.ts → defaultFlags-D6KfkTZx.d.ts} +1 -1
- package/dist/enum/exports.cjs +1 -1
- package/dist/enum/exports.cjs.map +1 -1
- package/dist/enum/exports.d.cts +1 -1
- package/dist/enum/exports.d.ts +1 -1
- package/dist/enum/exports.mjs +1 -1
- package/dist/errors/exports.cjs +1 -1
- package/dist/errors/exports.cjs.map +1 -1
- package/dist/errors/exports.d.cts +8 -3
- package/dist/errors/exports.d.ts +8 -3
- package/dist/errors/exports.mjs +1 -1
- package/dist/{getValidatorQueuedOperatorAddress-DZgrPmZ2.d.cts → getValidatorQueuedOperatorAddress-BdDYHycN.d.cts} +15 -4
- package/dist/{getValidatorQueuedOperatorAddress-CqR6cyqC.d.ts → getValidatorQueuedOperatorAddress-CmiPJmsr.d.ts} +15 -4
- package/dist/{global.d-BeYWDreg.d.ts → global.d-3GQMgC9k.d.ts} +1 -1
- package/dist/{global.d-DghRxpHd.d.cts → global.d-CwT1Phzf.d.cts} +1 -1
- package/dist/hooks/exports.cjs +3 -3
- package/dist/hooks/exports.cjs.map +1 -1
- package/dist/hooks/exports.d.cts +54 -75
- package/dist/hooks/exports.d.ts +54 -75
- package/dist/hooks/exports.mjs +3 -3
- package/dist/hooks/exports.mjs.map +1 -1
- package/dist/{txnEnum-DxPRHSJt.d.cts → txnEnum-CCuQUFlh.d.cts} +7 -0
- package/dist/{txnEnum-DxPRHSJt.d.ts → txnEnum-CCuQUFlh.d.ts} +7 -0
- package/dist/types/exports.cjs.map +1 -1
- package/dist/types/exports.d.cts +37 -4
- package/dist/types/exports.d.ts +37 -4
- package/dist/utils/exports.cjs +1 -1
- package/dist/utils/exports.cjs.map +1 -1
- package/dist/utils/exports.d.cts +2 -2
- package/dist/utils/exports.d.ts +2 -2
- package/dist/utils/exports.mjs +1 -1
- package/dist/utils/exports.mjs.map +1 -1
- package/package.json +25 -25
- package/src/abi/enso/ensoWalletV2Factory.ts +9 -0
- package/src/abi/exports.ts +1 -0
- package/src/abi/pyth/pyth.ts +0 -0
- package/src/actions/clients/BeraApolloClient.ts +3 -3
- package/src/actions/clients/getApolloClient.ts +5 -5
- package/src/actions/clients/getEnsoClient.ts +1 -1
- package/src/actions/dex/__tests__/aggregators.unit.test.ts +3 -3
- package/src/actions/dex/__tests__/getOnChainPool.unit.test.ts +1 -1
- package/src/actions/dex/aggregators/base.ts +12 -8
- package/src/actions/dex/aggregators/bex.ts +8 -8
- package/src/actions/dex/aggregators/bgt.ts +4 -4
- package/src/actions/dex/aggregators/enso/enso.ts +28 -20
- package/src/actions/dex/aggregators/enso/ensoErc4626.debug.test.ts +1 -1
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +7 -4
- package/src/actions/dex/aggregators/erc4626.ts +10 -6
- package/src/actions/dex/aggregators/fly.ts +9 -5
- package/src/actions/dex/aggregators/haiku.integration.test.ts +3 -3
- package/src/actions/dex/aggregators/haiku.ts +9 -5
- package/src/actions/dex/aggregators/honey.ts +15 -15
- package/src/actions/dex/aggregators/kyberswap.ts +8 -4
- package/src/actions/dex/aggregators/oogabooga.ts +8 -4
- package/src/actions/dex/aggregators/openOcean.ts +12 -8
- package/src/actions/dex/aggregators/wbera.ts +8 -4
- package/src/actions/dex/b-sdk.ts +2 -2
- package/src/actions/dex/getAllPools.ts +2 -2
- package/src/actions/dex/getApiPool.ts +2 -2
- package/src/actions/dex/getGlobalLiquidityAndSwapVolume.ts +2 -2
- package/src/actions/dex/getIsTokenExploited.ts +1 -1
- package/src/actions/dex/getOnChainPool.ts +3 -3
- package/src/actions/dex/getPoolEvents.ts +2 -2
- package/src/actions/dex/getPoolHistoricalData.ts +2 -2
- package/src/actions/dex/getVaultPausedState.ts +1 -1
- package/src/actions/enso/__tests__/getBendDemultiplyBundle.action.unit.test.ts +175 -0
- package/src/actions/enso/__tests__/getBendDemultiplyBundle.unit.test.ts +150 -0
- package/src/actions/enso/__tests__/getBendMultiplyBundle.action.unit.test.ts +138 -0
- package/src/actions/enso/__tests__/getBendMultiplyBundle.unit.test.ts +194 -0
- package/src/actions/enso/{getEnsoUserTokensWithBalances.debug.test.ts → __tests__/getEnsoUserTokensWithBalances.debug.test.ts} +3 -3
- package/src/actions/enso/__tests__/helpers.ts +42 -0
- package/src/actions/enso/__tests__/util.unit.test.ts +95 -0
- package/src/actions/enso/flashloan.ts +127 -0
- package/src/actions/enso/getBendDemultiplyBundle.ts +325 -0
- package/src/actions/enso/getBendMultiplyBundle.ts +348 -0
- package/src/actions/enso/getEnsoSwapBundle.ts +2 -2
- package/src/actions/enso/getEnsoUserTokensWithBalances.ts +5 -5
- package/src/actions/enso/util.ts +150 -5
- package/src/actions/exports.ts +0 -2
- package/src/actions/governance/__tests__/checkProposalField.unit.test.ts +2 -2
- package/src/actions/governance/__tests__/getDecodedFunctionData.integration.test.ts +2 -2
- package/src/actions/governance/__tests__/getQuorum.integration.test.ts +2 -2
- package/src/actions/governance/checkProposalField.ts +1 -1
- package/src/actions/governance/computeActualStatus.ts +1 -1
- package/src/actions/governance/getAllProposals.ts +1 -1
- package/src/actions/governance/getBodyErrors.ts +1 -1
- package/src/actions/governance/getProposalDetails.ts +1 -1
- package/src/actions/governance/getProposalFromTx.ts +1 -1
- package/src/actions/governance/getProposalParams.ts +3 -3
- package/src/actions/governance/getProposalVotes.ts +1 -1
- package/src/actions/governance/getQuorum.ts +2 -2
- package/src/actions/honey/getCollateralWeights.ts +2 -2
- package/src/actions/honey/getGlobalCapLimit.ts +4 -4
- package/src/actions/honey/getHoneyCollaterals.ts +5 -5
- package/src/actions/honey/getHoneyFees.ts +1 -1
- package/src/actions/honey/getHoneyPausedState.ts +1 -1
- package/src/actions/honey/getHoneyPreview.ts +3 -3
- package/src/actions/honey/getHoneyRootPriceOracle.ts +1 -1
- package/src/actions/honey/getHoneyVaultsBalance.ts +2 -2
- package/src/actions/honey/getRelativeCapLimit.ts +3 -3
- package/src/actions/honey/getSharesWithoutFees.ts +1 -1
- package/src/actions/honey/getSwapPayload.ts +6 -6
- package/src/actions/honey/isBadCollateralAsset.ts +2 -2
- package/src/actions/honey/isBasketModeEnabled.ts +2 -2
- package/src/actions/honey/tests/pyth.integration.test.ts +3 -3
- package/src/actions/misc/getBlockTimestamp.ts +2 -2
- package/src/actions/pol/__tests__/getAllValidators.integration.test.ts +2 -2
- package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +1 -1
- package/src/actions/pol/getBGTGlobalInfo.ts +2 -2
- package/src/actions/pol/getBgtAprSimulation.ts +1 -1
- package/src/actions/pol/getBgtAprSimultaion.unit.test.ts +1 -1
- package/src/actions/pol/getBgtTokenTotalBoosts.ts +2 -2
- package/src/actions/pol/getBgtTokenTotalSupply.ts +2 -2
- package/src/actions/pol/getBlockTime.debug.test.ts +13 -0
- package/src/actions/pol/getBlockTime.ts +14 -23
- package/src/actions/pol/getEarnedStakedBeraVault.ts +3 -3
- package/src/actions/pol/getGlobalCuttingBoard.ts +0 -0
- package/src/actions/pol/getGlobalData.ts +2 -2
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +4 -4
- package/src/actions/pol/getLSTStakeConfig.ts +5 -5
- package/src/actions/pol/getMarkets.ts +2 -2
- package/src/actions/pol/getRewardProofsByValidator.ts +4 -4
- package/src/actions/pol/getRewardTokenToBeraRate.ts +1 -1
- package/src/actions/pol/getRewardVault.ts +3 -3
- package/src/actions/pol/getRewardVaultBeaconImplementation.integration.test.ts +1 -1
- package/src/actions/pol/getRewardVaultBeaconImplementation.ts +3 -3
- package/src/actions/pol/getRewardVaultDurationConstants.integration.test.ts +1 -1
- package/src/actions/pol/getRewardVaultDurationConstants.ts +1 -1
- package/src/actions/pol/getRewardVaultFromToken.ts +1 -1
- package/src/actions/pol/getRewardVaultIncentives.ts +2 -2
- package/src/actions/pol/getRewardVaultRewards.ts +1 -1
- package/src/actions/pol/getRewardVaults.ts +1 -1
- package/src/actions/pol/getSWBeraVaultMetadata.ts +20 -22
- package/src/actions/pol/getSWBeraWithdrawal.ts +4 -4
- package/src/actions/pol/getStakedBeraAPR.ts +2 -2
- package/src/actions/pol/getStakedBeraSnapshots.ts +2 -2
- package/src/actions/pol/getStakingDailyAssets.ts +3 -3
- package/src/actions/pol/getStakingTokenInformation.ts +2 -2
- package/src/actions/pol/getTotalStakedAmount.ts +1 -1
- package/src/actions/pol/getUserClaimableIncentives.ts +4 -4
- package/src/actions/pol/getUserVaultInfo.ts +1 -1
- package/src/actions/pol/getUserVaults.ts +4 -4
- package/src/actions/pol/getUserVaultsBalance.ts +1 -1
- package/src/actions/pol/getUserVaultsReward.ts +0 -0
- package/src/actions/pol/getVaultHistory.ts +2 -2
- package/src/actions/pol/getVaultValidators.ts +1 -1
- package/src/actions/pol/getVaultsSupply.ts +0 -0
- package/src/actions/prices/__tests__/prices.integration.test.ts +2 -2
- package/src/actions/prices/getTokenCurrentPrices.ts +5 -5
- package/src/actions/pyth/getHoneyPythFeeds.ts +2 -2
- package/src/actions/pyth/getUpdateFee.ts +2 -2
- package/src/actions/tokens/getAllowances.ts +2 -2
- package/src/actions/tokens/getTokenInformation.ts +2 -2
- package/src/actions/tokens/getTokens.ts +3 -3
- package/src/actions/tokens/getUnderlyingToken.ts +4 -4
- package/src/actions/tokens/getWalletBalances.integration.test.ts +1 -1
- package/src/actions/tokens/getWalletBalances.ts +4 -4
- package/src/actions/transactions/beraWriteContract.integration.test.ts +6 -6
- package/src/actions/transactions/beraWriteContract.ts +12 -12
- package/src/actions/validators/getActiveBoostAndCommissionChangeDelay.integration.test.ts +1 -1
- package/src/actions/validators/getActiveBoostAndCommissionChangeDelay.ts +1 -1
- package/src/actions/validators/getAllValidators.ts +2 -2
- package/src/actions/validators/getApiValidator.ts +2 -2
- package/src/actions/validators/getBaselineRewardAllocation.ts +1 -1
- package/src/actions/validators/getDailyValidatorBlockStats.ts +1 -1
- package/src/actions/validators/getDefaultRewardAllocation.ts +1 -1
- package/src/actions/validators/getUserActiveValidators.ts +31 -33
- package/src/actions/validators/getUserBoosts.ts +12 -8
- package/src/actions/validators/getUserBoostsOnValidator.ts +15 -3
- package/src/actions/validators/getUserStakingPositions.ts +1 -1
- package/src/actions/validators/getValidatorAnalytics.ts +2 -2
- package/src/actions/validators/getValidatorCommission.ts +1 -1
- package/src/actions/validators/getValidatorEstimatedBgtPerYear.ts +1 -1
- package/src/actions/validators/getValidatorOperatorAddress.ts +1 -1
- package/src/actions/validators/getValidatorQueuedCommission.ts +1 -1
- package/src/actions/validators/getValidatorQueuedOperatorAddress.ts +1 -1
- package/src/actions/validators/getValidatorQueuedRewardAllocation.ts +1 -1
- package/src/actions/validators/getValidatorRewardAllocation.ts +1 -1
- package/src/actions/validators/getValidatorRewardAllocatorAddress.ts +1 -1
- package/src/actions/validators/utils/__tests__/validatorUtils.integration.test.ts +4 -4
- package/src/contexts/BeraFlags/defaultFlags.ts +4 -0
- package/src/contexts/BexStatusProvider.tsx +1 -1
- package/src/contexts/HoneyConfigProvider.tsx +3 -3
- package/src/contexts/SwrFallback.tsx +2 -2
- package/src/contexts/TokensProvider.tsx +3 -3
- package/src/contexts/block-time-provider.tsx +1 -1
- package/src/contexts/exports.ts +0 -0
- package/src/data/contracts.ts +10 -0
- package/src/enum/exports.ts +0 -0
- package/src/enum/polling.ts +0 -0
- package/src/enum/txnEnum.ts +9 -0
- package/src/errors/BeraMonitoring.ts +2 -2
- package/src/errors/BeraTracing.ts +2 -2
- package/src/errors/RequestError.ts +1 -1
- package/src/errors/assert.ts +18 -0
- package/src/errors/getErrorMessage.ts +0 -0
- package/src/errors/getRevertReason.integration.test.ts +7 -7
- package/src/errors/getRevertReason.ts +1 -1
- package/src/errors/parseViemError.ts +1 -1
- package/src/hooks/bend/useGetConvertToAssets.ts +4 -4
- package/src/hooks/dex/useAggregatorsQuotes.ts +19 -19
- package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +2 -2
- package/src/hooks/dex/useAllUserPools.ts +3 -3
- package/src/hooks/dex/useApiPool.ts +3 -3
- package/src/hooks/dex/useBexStatus.ts +1 -1
- package/src/hooks/dex/useCreatePool.ts +9 -9
- package/src/hooks/dex/useExploitedTokens.ts +3 -3
- package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +1 -1
- package/src/hooks/dex/useLiquidityMismatch.ts +3 -3
- package/src/hooks/dex/useLpPosition.ts +7 -4
- package/src/hooks/dex/useMultipleTokenApprovalsWithSlippage.ts +4 -4
- package/src/hooks/dex/useOnChainPoolData.ts +3 -3
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +3 -3
- package/src/hooks/dex/usePool.ts +7 -40
- package/src/hooks/dex/usePoolEvents.ts +2 -2
- package/src/hooks/dex/usePoolHistoricalData.ts +6 -3
- package/src/hooks/dex/usePools.ts +3 -3
- package/src/hooks/dex/usePriceImpact.ts +2 -2
- package/src/hooks/dex/useSingleAggregatorQuote.ts +13 -13
- package/src/hooks/enso/useBendDemultiply.ts +158 -0
- package/src/hooks/enso/useBendMultiply.ts +163 -0
- package/src/hooks/enso/useBendZapSupply.ts +7 -7
- package/src/hooks/enso/useEnsoSwapBundle.ts +6 -6
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +5 -5
- package/src/hooks/enso/useEnsoWalletV2Address.ts +38 -0
- package/src/hooks/enso/useIsBendAuthorized.ts +47 -0
- package/src/hooks/enso/useZapStakeBera.ts +4 -4
- package/src/hooks/exports.ts +4 -3
- package/src/hooks/governance/useCreateProposal.ts +3 -3
- package/src/hooks/governance/useGetPastVotes.ts +2 -2
- package/src/hooks/governance/useHasVoted.ts +2 -2
- package/src/hooks/governance/useIsCanceller.ts +4 -4
- package/src/hooks/governance/usePollAllProposals.ts +3 -3
- package/src/hooks/governance/usePollProposal.ts +7 -4
- package/src/hooks/governance/usePollProposalThreshold.ts +3 -3
- package/src/hooks/governance/usePollProposalVotes.ts +1 -1
- package/src/hooks/governance/usePollUserDelegates.ts +7 -4
- package/src/hooks/governance/useProposalFromTx.ts +1 -1
- package/src/hooks/governance/useProposalSnapshot.ts +2 -2
- package/src/hooks/governance/useProposalState.ts +2 -2
- package/src/hooks/governance/useProposalTimelockState.ts +2 -2
- package/src/hooks/governance/useQuorum.ts +1 -1
- package/src/hooks/honey/useCappedGlobally.ts +8 -5
- package/src/hooks/honey/useCappedRelatively.ts +7 -4
- package/src/hooks/honey/useCollateralWeights.ts +8 -5
- package/src/hooks/honey/useHoneyAlerts.ts +5 -5
- package/src/hooks/honey/useHoneyBalances.ts +7 -7
- package/src/hooks/honey/useHoneyChartData.ts +1 -1
- package/src/hooks/honey/useHoneySwapState.ts +4 -4
- package/src/hooks/honey/useHoneyVaultsBalance.ts +8 -5
- package/src/hooks/honey/useIsBadCollateralAsset.ts +9 -6
- package/src/hooks/honey/useIsBasketModeEnabled.ts +8 -5
- package/src/hooks/honey/usePythLatestPrices.ts +4 -4
- package/src/hooks/perps/usePythUpdateFee.ts +4 -4
- package/src/hooks/pol/useBgtAprSimulation.ts +1 -1
- package/src/hooks/pol/useBgtUnstakedBalance.ts +7 -4
- package/src/hooks/pol/useClaimableFees.ts +4 -4
- package/src/hooks/pol/useOnChainRewardVault.ts +7 -7
- package/src/hooks/pol/usePollGlobalData.ts +9 -3
- package/src/hooks/pol/usePollMarkets.ts +5 -2
- package/src/hooks/pol/useQueuedBeraUnlock.ts +4 -4
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +4 -4
- package/src/hooks/pol/useRewardVault.ts +5 -2
- package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +2 -2
- package/src/hooks/pol/useRewardVaultFromToken.ts +2 -2
- package/src/hooks/pol/useRewardVaultIncentives.ts +2 -2
- package/src/hooks/pol/useRewardVaultRewards.ts +3 -3
- package/src/hooks/pol/useRewardVaults.ts +2 -2
- package/src/hooks/pol/useStakedAPR.ts +3 -3
- package/src/hooks/pol/useStakedData.ts +10 -10
- package/src/hooks/pol/useStakedSnapshots.ts +3 -3
- package/src/hooks/pol/useStakingVaultsMetadata.ts +40 -0
- package/src/hooks/pol/useTotalStakedAmount.ts +2 -2
- package/src/hooks/pol/useUserVaultInfo.ts +8 -5
- package/src/hooks/pol/useUserVaults.ts +7 -4
- package/src/hooks/pol/useVaultAddress.ts +2 -2
- package/src/hooks/pol/useVaultHistory.ts +2 -2
- package/src/hooks/pol/useVaultValidators.ts +5 -2
- package/src/hooks/tokens/useBeraCurrentPrice.ts +1 -1
- package/src/hooks/tokens/useMultipleTokenInformation.ts +7 -4
- package/src/hooks/tokens/usePollAllowances.ts +7 -4
- package/src/hooks/tokens/usePollBalance.ts +8 -5
- package/src/hooks/tokens/usePollWalletBalances.ts +8 -5
- package/src/hooks/tokens/useStakingTokenInformation.ts +7 -4
- package/src/hooks/tokens/useTokenCurrentPrice.ts +1 -1
- package/src/hooks/tokens/useTokenCurrentPrices.ts +6 -6
- package/src/hooks/tokens/useTokenInformation.ts +8 -5
- package/src/hooks/tokens/useTokenPrice.ts +1 -1
- package/src/hooks/tokens/useTokenPrices.ts +4 -4
- package/src/hooks/tokens/useTokens.ts +3 -3
- package/src/hooks/tokens/useTotalSupply.ts +1 -1
- package/src/hooks/tokens/useUnderlyingAsset.ts +3 -3
- package/src/hooks/useBlockToTimestamp.ts +5 -5
- package/src/hooks/useContractWrite/index.ts +0 -0
- package/src/hooks/useContractWrite/stateReducer.ts +0 -0
- package/src/hooks/useContractWrite/types.ts +2 -2
- package/src/hooks/useContractWrite/useBeraContractWrite.ts +5 -6
- package/src/hooks/useGetVerifiedAbi.ts +1 -1
- package/src/hooks/usePrevious.ts +0 -0
- package/src/hooks/validators/useAllValidators.ts +7 -4
- package/src/hooks/validators/useApiEnrichedAllocation.ts +2 -2
- package/src/hooks/validators/useApiValidator.ts +5 -2
- package/src/hooks/validators/useBaselineRewardAllocation.ts +2 -2
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +3 -3
- package/src/hooks/validators/useDefaultRewardAllocation.ts +4 -4
- package/src/hooks/validators/useManagedValidatorRole.ts +8 -5
- package/src/hooks/validators/useOnChainValidator.ts +6 -3
- package/src/hooks/validators/useStakingPoolBatch.ts +7 -4
- package/src/hooks/validators/useUserActiveValidators.ts +6 -3
- package/src/hooks/validators/useUserBoostsOnValidator.ts +3 -3
- package/src/hooks/validators/useUserClaimableIncentives.ts +9 -9
- package/src/hooks/validators/useUserStakingPositions.ts +1 -1
- package/src/hooks/validators/useValidator.ts +1 -1
- package/src/hooks/validators/useValidatorAnalytics.ts +3 -3
- package/src/hooks/validators/useValidatorCommission.ts +5 -2
- package/src/hooks/validators/useValidatorEstimatedBgtPerYear.ts +3 -3
- package/src/hooks/validators/useValidatorQueuedCommission.ts +6 -3
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +5 -2
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +6 -3
- package/src/hooks/validators/useValidatorRewardAllocation.ts +2 -2
- package/src/types/dex.d.ts +1 -1
- package/src/types/enso.d.ts +34 -0
- package/src/types/exports.ts +0 -0
- package/src/types/global.d.ts +3 -3
- package/src/types/governance.d.ts +1 -1
- package/src/types/honeySwap.d.ts +3 -3
- package/src/types/staking.d.ts +0 -0
- package/src/utils/beraFetch.ts +1 -1
- package/src/utils/createEmitter.ts +1 -1
- package/src/utils/exports.ts +0 -0
- package/src/utils/filter.ts +0 -0
- package/src/utils/formatIncentivesTokenMap.ts +1 -1
- package/src/utils/formatInputTokenValue.ts +0 -0
- package/src/utils/formatNumber.ts +0 -0
- package/src/utils/getContractName.ts +1 -1
- package/src/utils/getHoneySwapMessage.test.ts +1 -1
- package/src/utils/getHoneySwapMessage.ts +1 -1
- package/src/utils/parseBaseArgs.ts +1 -1
- package/src/utils/parseBaseArgs.unit.test.ts +1 -1
- package/src/utils/parseWhiskToken.ts +1 -1
- package/src/utils/poolNamings.ts +1 -1
- package/src/utils/tokens.ts +2 -2
- package/src/utils/tokens.unit.test.ts +1 -1
- package/src/utils/truncateHash.ts +0 -0
- package/.claude/skills/berajs/SKILL.md +0 -222
- package/.claude/skills/berajs/references/dex.md +0 -235
- package/.claude/skills/berajs/references/pol.md +0 -194
- package/.claude/skills/berajs/references/staking.md +0 -198
- package/.claude/skills/berajs/references/tokens.md +0 -170
- package/LICENSE +0 -21
- package/dist/chunk-22J3YJDN.cjs +0 -2
- package/dist/chunk-22J3YJDN.cjs.map +0 -1
- package/dist/chunk-2LL3P5PN.mjs +0 -2
- package/dist/chunk-2LL3P5PN.mjs.map +0 -1
- package/dist/chunk-4GU2O2OW.cjs +0 -4
- package/dist/chunk-4GU2O2OW.cjs.map +0 -1
- package/dist/chunk-55L7STYD.mjs +0 -2
- package/dist/chunk-55L7STYD.mjs.map +0 -1
- package/dist/chunk-5XWELBWR.mjs +0 -2
- package/dist/chunk-5XWELBWR.mjs.map +0 -1
- package/dist/chunk-6LDOG5RL.cjs.map +0 -1
- package/dist/chunk-7LNBSOVV.cjs +0 -2
- package/dist/chunk-7LNBSOVV.cjs.map +0 -1
- package/dist/chunk-7SMWQ6SN.mjs.map +0 -1
- package/dist/chunk-7WRTK7RJ.mjs.map +0 -1
- package/dist/chunk-AX2YQQFQ.mjs.map +0 -1
- package/dist/chunk-BS6K7HGH.cjs +0 -2
- package/dist/chunk-BS6K7HGH.cjs.map +0 -1
- package/dist/chunk-C3FHGFLK.mjs +0 -2
- package/dist/chunk-C3FHGFLK.mjs.map +0 -1
- package/dist/chunk-C6ZGUO4H.cjs.map +0 -1
- package/dist/chunk-FCWDGE62.cjs.map +0 -1
- package/dist/chunk-RW3JFPED.mjs +0 -4
- package/dist/chunk-RW3JFPED.mjs.map +0 -1
- package/dist/chunk-S3EAKCVM.cjs +0 -2
- package/dist/chunk-S3EAKCVM.cjs.map +0 -1
- package/dist/chunk-SWMJQOH6.cjs +0 -2
- package/dist/chunk-SWMJQOH6.cjs.map +0 -1
- package/dist/chunk-THATXCJK.mjs +0 -2
- package/dist/chunk-THATXCJK.mjs.map +0 -1
- package/dist/chunk-VXL2ZZ4X.cjs +0 -2
- package/dist/chunk-VXL2ZZ4X.cjs.map +0 -1
- package/dist/chunk-YNO7BCCM.mjs +0 -2
- package/dist/chunk-YXLFOEZN.mjs +0 -2
- package/dist/chunk-YXLFOEZN.mjs.map +0 -1
- package/dist/chunk-YZV5LKIP.cjs.map +0 -1
- package/src/actions/dex/getSubgraphPool.ts +0 -30
- package/src/actions/validators/getManagedValidatorByAccount.ts +0 -32
- package/src/hooks/pol/useSWBeraVaultMetadata.ts +0 -35
- package/src/hooks/validators/useManagedValidatorByAccount.ts +0 -40
- package/src/hooks/validators/useSubgraphUserValidators.ts +0 -36
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/getErrorResponse.ts","../src/utils/beraFetch.ts","../src/utils/constants.ts","../src/utils/pythHoneyUtils.ts","../src/utils/time.ts","../src/utils/formatTimestamps.ts","../src/utils/formatNumber.ts","../src/utils/getTestClient.ts","../src/utils/isSubgraphStale.ts"],"sourcesContent":["/**\n * @deprecated use beraFetch instead\n */\nexport async function getErrorResponse(response: Response) {\n const contentType = response.headers.get(\"content-type\");\n\n if (contentType?.includes(\"application/json\")) {\n return await response.json();\n } else {\n const text = await response.text();\n try {\n return JSON.parse(text);\n } catch {\n return {\n message: \"Unknown error, can't decode response into JSON\",\n cause: text,\n };\n }\n }\n}\n","import { RequestError } from \"~/errors/RequestError\";\nimport { getErrorResponse } from \"./getErrorResponse\";\n\ntype RequestOptions = RequestInit;\n\nexport async function beraFetch(\n endpoint: ConstructorParameters<typeof RequestError>[0][\"endpoint\"],\n options?: RequestOptions,\n) {\n try {\n const response = await fetch(\n typeof endpoint === \"string\" || endpoint instanceof URL\n ? endpoint\n : endpoint.url,\n {\n ...options,\n },\n );\n if (!response.ok) {\n const error = await getErrorResponse(response);\n throw new RequestError({\n cause: error,\n // @to-do import getErrorResponse logic in this function\n // when it's removed from other places\n response: response,\n endpoint,\n });\n }\n return response;\n } catch (error) {\n if (error instanceof RequestError) {\n throw error;\n }\n\n throw new RequestError({\n cause: error,\n endpoint,\n response: undefined,\n });\n }\n}\n\nexport async function beraFetchJson<T>(\n endpoint: ConstructorParameters<typeof RequestError>[0][\"endpoint\"],\n options?: RequestOptions,\n) {\n const response = await beraFetch(endpoint, {\n ...options,\n headers: {\n Accept: \"application/json\",\n ...options?.headers,\n },\n });\n return response.json() as Promise<T>;\n}\n","import { parseEther } from \"viem\";\n\n// the buffer of the cap limit, if the user gets close to 10% of the cap limit\n// they should be warned\nexport const CAP_LIMIT_BUFFER = parseEther(\"0.005\");\n\n/**\n * Maximum allowed input for a custom deadline in seconds.\n * @type {number}\n */\nexport const MAX_CUSTOM_DEADLINE = 100000;\n\n/**\n * Minimum allowed input for a custom deadline in seconds.\n * @type {number}\n */\nexport const MIN_CUSTOM_DEADLINE = 1;\n\n/**\n * Minimum allowed input for a custom slippage tolerance percentage.\n * @type {number}\n */\nexport const MIN_CUSTOM_SLIPPAGE = 0.1;\n\n/**\n * Maximum allowed input for a custom slippage tolerance percentage.\n * @type {number}\n */\nexport const MAX_CUSTOM_SLIPPAGE = 50;\n\n/**\n * Default gas limit used by MetaMask\n * @see {@link https://github.com/MetaMask/metamask-extension/blob/06cf7459b963e26d0ae60312d4f9a342d07ab89d/ui/pages/confirmations/send/send.constants.js#L8}\n */\nexport const DEFAULT_METAMASK_GAS_LIMIT = 7920027n;\n","export const getPythDefaultUpdateFee = (tokenListLength: number) => {\n return 2n * BigInt(tokenListLength);\n};\n","/**\n * Convert milliseconds to seconds\n */\nexport function msToSeconds(ms: number): number {\n return Math.floor(ms / 1000);\n}\n\n/**\n * Time utility functions for converting between different time units.\n *\n * This utility file provides functions to convert between seconds, minutes, hours, and days.\n * Note on naming conventions: We use \"seconds\" instead of \"secondsToMs\" because JavaScript\n * is typically based in milliseconds, so the conversion to milliseconds is the more common\n * and expected operation. We use \"xxxInSeconds\" when converting to second-based units.\n */\n\n/**\n * Convert seconds to milliseconds\n */\nexport function seconds(seconds: number): number {\n return seconds * 1000;\n}\n\n/**\n * Convert minutes to milliseconds\n */\nexport function minutes(minutes: number): number {\n return minutes * seconds(60);\n}\n\n/**\n * Convert minutes to seconds\n */\nexport function minutesInSeconds(minutes: number): number {\n return minutes * 60;\n}\n\n/**\n * Convert hours to milliseconds\n */\nexport function hours(hours: number): number {\n return hours * minutes(60);\n}\n\n/**\n * Convert hours to seconds\n */\nexport function hoursInSeconds(hours: number): number {\n return hours * minutesInSeconds(60);\n}\n\n/**\n * Convert days to milliseconds\n */\nexport function days(days: number): number {\n return days * hours(24);\n}\n\n/**\n * Convert days to seconds\n */\nexport function daysInSeconds(days: number): number {\n return days * hoursInSeconds(24);\n}\n\n/**\n * Convert weeks to milliseconds\n */\nexport function weeks(weeks: number): number {\n return weeks * days(7);\n}\n\n/**\n * Convert weeks to seconds\n */\nexport function weeksInSeconds(weeks: number): number {\n return weeks * daysInSeconds(7);\n}\n\n/**\n * Convert months to milliseconds using 30 days per month\n */\nexport function months(months: number): number {\n return months * days(30);\n}\n\n/**\n * Convert months to seconds using 30 days per month\n */\nexport function monthsInSeconds(months: number): number {\n return months * daysInSeconds(30);\n}\n\n/**\n * Convert years to milliseconds using 365 days per year\n */\nexport function years(years: number): number {\n return years * days(365);\n}\n\n/**\n * Convert years to seconds using 365 days per year\n */\nexport function yearsInSeconds(years: number): number {\n return years * daysInSeconds(365);\n}\n","export function calculateTimestampFromDays(daysRange: number): number {\n const currentDate = new Date();\n return currentDate.setDate(currentDate.getDate() - daysRange) * 1000;\n}\n\nconst monthNames = [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\",\n];\n\nconst shortMonthNames = [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\",\n];\n\nexport function formatUnixTimestamp(unixTimestamp: number, isShort?: boolean) {\n const date = new Date(unixTimestamp * 1000);\n\n const day = date.getDate();\n let daySuffix = \"th\";\n\n if (day === 1 || day === 21 || day === 31) {\n daySuffix = \"st\";\n } else if (day === 2 || day === 22) {\n daySuffix = \"nd\";\n } else if (day === 3 || day === 23) {\n daySuffix = \"rd\";\n }\n\n if (isShort) {\n return `${shortMonthNames[date.getMonth()]} ${day}`;\n }\n\n return `${\n monthNames[date.getMonth()]\n } ${day}${daySuffix}, ${date.getFullYear()}`;\n}\n\ntype LegacyArgs = [number, boolean?, boolean?, boolean?];\ntype FormatTimeLeftArgs = [\n number,\n {\n condensed?: boolean;\n greaterUnit?: \"days\" | \"hours\" | \"minutes\";\n showSeconds?: boolean;\n },\n];\n\n/**\n * Formats the time left into a string like \"8 hours, 23 minutes\".\n *\n * @param timeLeftInSeconds - The time left in seconds.\n * @returns A formatted string representing the time left.\n */\nexport function formatTimeLeft(\n ...args: FormatTimeLeftArgs | LegacyArgs\n): string {\n const timeLeftInSeconds = args[0];\n let condensed: boolean;\n\n let showDays: boolean;\n\n let showMinutes: boolean;\n let showSeconds: boolean;\n\n if (typeof args[1] !== \"object\") {\n condensed = args[1] ?? false;\n showDays = args[2] ?? false;\n showSeconds = args[3] ?? false;\n showMinutes = true;\n } else {\n const opts = args[1];\n condensed = opts.condensed ?? false;\n const greaterUnit = opts.greaterUnit ?? \"hours\";\n\n if (greaterUnit === \"days\") {\n showDays = true;\n showMinutes = true;\n } else if (greaterUnit === \"hours\") {\n showDays = false;\n showMinutes = true;\n showSeconds = false;\n } else {\n // minutes is the default\n showDays = false;\n showMinutes = true;\n }\n showSeconds = opts.showSeconds ?? false;\n }\n\n let days = Math.floor(timeLeftInSeconds / (3600 * 24));\n let hours = Math.floor((timeLeftInSeconds % (3600 * 24)) / 3600);\n const minutes = Math.floor((timeLeftInSeconds % 3600) / 60);\n const seconds = timeLeftInSeconds % 60;\n\n // If showDays=false, roll days into hours\n if (!showDays) {\n hours += days * 24;\n days = 0;\n }\n\n if (days === 0 && hours === 0 && minutes === 0) {\n return condensed ? \"< 1 M\" : \"less than a minute\";\n }\n\n const daysDisplay =\n days > 0\n ? `${days}${condensed ? \"D\" : \" day\"}${\n !condensed && days !== 1 ? \"s\" : \"\"\n }`\n : \"\";\n\n const hoursDisplay =\n hours > 0\n ? `${hours}${condensed ? \"H\" : \" hour\"}${\n !condensed && hours !== 1 ? \"s\" : \"\"\n }`\n : \"\";\n\n const minutesDisplay =\n (minutes > 0 && showMinutes) || (!days && !hours)\n ? `${minutes}${condensed ? \"M\" : \" minute\"}${\n !condensed && minutes !== 1 ? \"s\" : \"\"\n }`\n : \"\";\n const secondsDisplay =\n seconds > 0 && showSeconds\n ? `${seconds}${condensed ? \"S\" : \" second\"}${\n !condensed && seconds !== 1 ? \"s\" : \"\"\n }`\n : \"\";\n return [daysDisplay, hoursDisplay, minutesDisplay, secondsDisplay]\n .filter(Boolean)\n .join(condensed ? \" \" : \", \");\n}\n","import BigNumber from \"@berachain/utils/pkg/bignumber.js\";\n\nexport type BigNumberValue = string | number | BigNumber;\n\nexport interface FormatNumberOptions {\n /** Number of visible decimal places */\n visibleDecimals?: number;\n /** Whether to use compact notation (K, M, B, etc.) */\n compact?: boolean;\n /** Show as percentage */\n percent?: boolean;\n /** Round down instead of normal rounding */\n roundDown?: boolean;\n /** Round up instead of normal rounding */\n roundUp?: boolean;\n /** Threshold above which compact notation is used */\n compactThreshold?: number;\n /** Maximum value to display (shows ∞ if exceeded) */\n maxValue?: number;\n /** Currency symbol (e.g., \"USD\" for $) */\n symbol?: string;\n /** Prefix text */\n prefixText?: string;\n /** Suffix text */\n suffixText?: string;\n /** Show \"< min\" or \"> min\" indicators for very small values */\n showIsSmallerThanMin?: boolean;\n /** Text to show if value is null/undefined */\n ifNullish?: string;\n}\n\nconst POSTFIXES = [\"\", \"K\", \"M\", \"B\", \"T\", \"P\", \"E\", \"Z\", \"Y\"];\n\nfunction valueToBigNumber(amount: BigNumberValue): BigNumber {\n if (amount instanceof BigNumber) return amount;\n return new BigNumber(amount);\n}\n\nfunction normalizeBN(n: BigNumberValue, decimals: number): BigNumber {\n return valueToBigNumber(n).shiftedBy(decimals * -1);\n}\n\nexport function formatNumber(\n value: BigNumberValue | undefined | null,\n options: FormatNumberOptions | number = {},\n): string {\n if (typeof options === \"number\") {\n const decimals = options;\n if (value === undefined || value === null) {\n return \"\";\n }\n\n if (typeof value === \"object\") {\n throw new Error(\"Value must be a number if using deprecated version\");\n }\n\n // Convert to string with up to 8 decimal places\n let formatted = Number(value).toFixed(decimals);\n // Remove trailing zeros and decimal point if not needed\n formatted = formatted.replace(/(\\.\\d*?[1-9])0+$|\\.0*$/, \"$1\");\n return formatted;\n }\n\n const {\n visibleDecimals,\n compact = true,\n percent = false,\n roundDown = false,\n roundUp = false,\n compactThreshold,\n maxValue,\n symbol,\n prefixText = \"\",\n suffixText = \"\",\n showIsSmallerThanMin = true,\n ifNullish = \"\",\n } = options || {};\n\n // Handle null/undefined values\n if (value === undefined || value === null) {\n return ifNullish;\n }\n\n const number = percent ? Number(value) * 100 : Number(value);\n\n // Handle special numeric values\n if (Number.isNaN(number)) {\n return \"NaN\";\n }\n if (number === Number.POSITIVE_INFINITY) {\n return \"Infinity\";\n }\n if (number === Number.NEGATIVE_INFINITY) {\n return \"-Infinity\";\n }\n\n // Determine decimal places\n let decimals: number = visibleDecimals ?? 0;\n if (number === 0) {\n decimals = 0;\n } else if (visibleDecimals === undefined) {\n if (Math.abs(number) > 1 || percent || symbol === \"USD\") {\n decimals = 2;\n } else {\n decimals = 7;\n }\n }\n\n const minValue = 10 ** -(decimals as number);\n const isSmallerThanMin =\n number !== 0 && Math.abs(number) < Math.abs(minValue);\n const isNegative = number < 0;\n const isBiggerThanMax = maxValue ? Math.abs(number) > maxValue : false;\n\n let formattedNumber = isSmallerThanMin ? minValue : number;\n const forceCompact =\n compact && (!compactThreshold || Math.abs(number) > compactThreshold);\n\n // Apply rounding for non-compact numbers\n if (roundDown && !forceCompact) {\n formattedNumber =\n Math.trunc(Number(formattedNumber) * 10 ** decimals) / 10 ** decimals;\n } else if (roundUp && !forceCompact) {\n formattedNumber =\n Math.ceil(Number(formattedNumber) * 10 ** decimals) / 10 ** decimals;\n }\n\n let formattedValue: string;\n\n if (isBiggerThanMax) {\n formattedValue = number > maxValue! ? \"∞\" : \"-∞\";\n } else if (!forceCompact) {\n const absFormatted = new Intl.NumberFormat(\"en-US\", {\n maximumFractionDigits: decimals,\n minimumFractionDigits: decimals,\n }).format(Math.abs(formattedNumber));\n formattedValue = `${isNegative ? \"-\" : \"\"}${absFormatted}`;\n } else {\n // Compact number formatting\n const bnValue = valueToBigNumber(formattedNumber);\n let integerPlaces = bnValue.abs().toFixed(0).length;\n if (compactThreshold && Math.abs(number) <= compactThreshold) {\n integerPlaces = 0;\n }\n\n const significantDigitsGroup = Math.min(\n Math.floor(integerPlaces ? (integerPlaces - 1) / 3 : 0),\n POSTFIXES.length - 1,\n );\n\n const postfix = POSTFIXES[significantDigitsGroup];\n let compactValue = normalizeBN(\n bnValue,\n 3 * significantDigitsGroup,\n ).toNumber();\n\n if (roundDown) {\n compactValue =\n Math.trunc(Number(compactValue) * 10 ** decimals) / 10 ** decimals;\n } else if (roundUp) {\n compactValue =\n Math.ceil(Number(compactValue) * 10 ** decimals) / 10 ** decimals;\n }\n\n const prefix = new Intl.NumberFormat(\"en-US\", {\n maximumFractionDigits: decimals,\n minimumFractionDigits: decimals,\n }).format(compactValue);\n\n formattedValue = `${prefix}${postfix}`;\n }\n\n // Build the final formatted string\n const parts: string[] = [];\n\n // Add prefix text\n if (prefixText) {\n parts.push(prefixText);\n }\n\n // Add smaller than indicator\n if (isSmallerThanMin && showIsSmallerThanMin) {\n parts.push(number < 0 ? \">\" : \"<\");\n }\n\n // Add USD symbol\n if (symbol?.toLowerCase() === \"usd\" && !percent) {\n parts.push(\"$\");\n }\n\n // Add the formatted number\n parts.push(formattedValue);\n\n // Add percentage symbol\n if (percent) {\n parts.push(\"%\");\n }\n\n // Add other symbols\n if (symbol?.toLowerCase() !== \"usd\" && typeof symbol !== \"undefined\") {\n parts.push(\" \", symbol);\n }\n\n // Add suffix text\n if (suffixText) {\n parts.push(suffixText);\n }\n\n return parts.join(\"\");\n}\nexport const getSafeNumber = (value: string | undefined): number => {\n if (!value) return 0;\n return Number(value) > Number.MAX_SAFE_INTEGER\n ? Number.MAX_SAFE_INTEGER\n : (Number(value) ?? 0);\n};\n\nexport const truncateDecimal = (\n value: string | number | undefined,\n maxDecimal: number,\n): string => {\n if (!value) return \"0\";\n const [integerPart = \"0\", decimalPart = \"0\"] = `${value}`.split(\".\");\n return `${integerPart}.${decimalPart.substring(0, maxDecimal)}`;\n};\n","import { createTestClient, http } from \"viem\";\n\nimport {\n type ChainId,\n defaultChainId,\n getRpcUrls,\n} from \"@berachain/config/internal\";\n\nexport function getTestClient(chainId: ChainId = defaultChainId) {\n const rpc = getRpcUrls(chainId);\n\n if (!rpc.isAnvil) {\n throw new Error(\"No anvil RPC URL found\");\n }\n return createTestClient({\n mode: \"anvil\",\n transport: http(rpc.jsonRpcUrl),\n });\n}\n","export function isSubgraphStale({\n lastBlockTimestamp,\n blockTime,\n}: {\n lastBlockTimestamp: number | null | undefined;\n blockTime: number;\n}) {\n if (!lastBlockTimestamp) return true;\n return lastBlockTimestamp < Date.now() / 1000 - blockTime * 10;\n}\n"],"mappings":"yCAGA,eAAsBA,EAAiBC,EAAoB,CAGzD,GAFoBA,EAAS,QAAQ,IAAI,cAAc,GAEtC,SAAS,kBAAkB,EAC1C,OAAO,MAAMA,EAAS,KAAK,EACtB,CACL,IAAMC,EAAO,MAAMD,EAAS,KAAK,EACjC,GAAI,CACF,OAAO,KAAK,MAAMC,CAAI,CACxB,MAAQ,CACN,MAAO,CACL,QAAS,iDACT,MAAOA,CACT,CACF,CACF,CACF,CCdA,eAAsBC,EACpBC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,EAGG,CACD,OAAKD,EACEA,EAAqB,KAAK,IAAI,EAAI,IAAOC,EAAY,GAD5B,EAElC","names":["getErrorResponse","response","text","beraFetch","endpoint","options","response","error","getErrorResponse","RequestError","beraFetchJson","parseEther","CAP_LIMIT_BUFFER","MAX_CUSTOM_DEADLINE","MIN_CUSTOM_DEADLINE","MIN_CUSTOM_SLIPPAGE","MAX_CUSTOM_SLIPPAGE","DEFAULT_METAMASK_GAS_LIMIT","getPythDefaultUpdateFee","tokenListLength","msToSeconds","ms","seconds","minutes","minutesInSeconds","hours","hoursInSeconds","days","daysInSeconds","weeks","weeksInSeconds","months","monthsInSeconds","years","yearsInSeconds","calculateTimestampFromDays","daysRange","currentDate","monthNames","shortMonthNames","formatUnixTimestamp","unixTimestamp","isShort","date","day","daySuffix","formatTimeLeft","args","timeLeftInSeconds","condensed","showDays","showMinutes","showSeconds","opts","greaterUnit","days","hours","minutes","seconds","daysDisplay","hoursDisplay","minutesDisplay","secondsDisplay","BigNumber","POSTFIXES","valueToBigNumber","amount","normalizeBN","n","decimals","formatNumber","value","options","formatted","visibleDecimals","compact","percent","roundDown","roundUp","compactThreshold","maxValue","symbol","prefixText","suffixText","showIsSmallerThanMin","ifNullish","number","minValue","isSmallerThanMin","isNegative","isBiggerThanMax","formattedNumber","forceCompact","formattedValue","bnValue","integerPlaces","significantDigitsGroup","postfix","compactValue","absFormatted","parts","getSafeNumber","truncateDecimal","maxDecimal","integerPart","decimalPart","createTestClient","http","defaultChainId","getRpcUrls","getTestClient","chainId","rpc","isSubgraphStale","lastBlockTimestamp","blockTime"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/chunk-6LDOG5RL.cjs","../src/errors/BeraTracing.ts","../src/errors/NotFoundError.ts","../src/errors/TransactionFailedError.ts"],"names":["_handlers","BeraTracing","context","callback","next","handler","idx","NotFoundError","BeraError","args","TransactionFailedError"],"mappings":"AAAA,iPA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ACV,IAAA,CAAK,IAAA,CAAO,wBAAA,CACZ,IAAA,CAAK,MAAA,CAASA,CAAAA,CAAK,MAAA,EAAU,IAAA,CAC7B,IAAA,CAAK,OAAA,CAAUA,CAAAA,CAAK,OAAA,EAAW,IAAA,CAC/B,IAAA,CAAK,EAAA,CAAKA,CAAAA,CAAK,EAAA,CACf,IAAA,CAAK,YAAA,CAAeA,CAAAA,CAAK,YAAA,CACzB,IAAA,CAAK,WAAA,kBAAcA,CAAAA,CAAK,WAAA,SAAe,MAAA,CACvC,IAAA,CAAK,KAAA,CAAQA,CAAAA,CAAK,KAAA,CAEd,IAAA,CAAK,OAAA,CAEP,IAAA,CAAK,OAAA,CAAU,CAAA,0CAAA,EAA6C,IAAA,CAAK,MAAM,CAAA,CAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/chunk-6LDOG5RL.cjs","sourcesContent":[null,"import type { Unsubscribe } from \"~/utils/createEmitter\";\n\n/**\n * Span context passed to tracing handlers.\n * Compatible with Sentry's StartSpanOptions (name, op, attributes).\n */\nexport type SpanContext = {\n name: string;\n op: string;\n attributes: Record<string, string | number | boolean | undefined>;\n};\n\n/**\n * A function that wraps a callback in a tracing span.\n * Compatible with Sentry.startSpan's signature.\n */\ntype StartSpanFn = <T>(\n context: SpanContext,\n callback: () => Promise<T>,\n) => Promise<T>;\n\nconst _handlers: StartSpanFn[] = [];\n\n/**\n * A generic span-tracing module for berajs.\n *\n * Instead of calling Sentry.startSpan directly, berajs calls\n * `BeraTracing.startSpan()`. Consumer apps subscribe via `.on(\"span\", handler)`\n * and forward spans to their tracing provider (Sentry, Datadog, etc.).\n *\n * Multiple handlers are supported and chain in registration order:\n * the first registered handler is the outermost wrapper.\n *\n * @example\n * ```ts\n * // In berajs code:\n * import { BeraTracing } from \"~/errors/BeraTracing\";\n * const result = await BeraTracing.startSpan(\n * { name: \"GraphQL query\", op: \"graphql.query\", attributes: {} },\n * () => executeQuery(),\n * );\n *\n * // In app instrumentation:\n * import { BeraTracing } from \"@berachain/berajs/errors\";\n * BeraTracing.addSpanHandler(Sentry.startSpan);\n * ```\n */\nexport const BeraTracing = {\n /**\n * Execute a callback, wrapping it in all registered span handlers.\n *\n * Handlers chain so each wraps the next. First registered = outermost wrapper.\n * If no handlers are registered, the callback is executed directly.\n */\n startSpan<T>(context: SpanContext, callback: () => Promise<T>): Promise<T> {\n if (_handlers.length === 0) return callback();\n\n // Chain: h1(ctx, () => h2(ctx, () => h3(ctx, () => callback())))\n return _handlers.reduceRight<() => Promise<T>>(\n (next, handler) => () => handler(context, next),\n callback,\n )();\n },\n\n /**\n * Register a span tracing handler.\n *\n * @param _event - Must be \"span\". Exists for API consistency with BeraMonitoring.\n * @param handler - A StartSpanFn, e.g. Sentry.startSpan.\n * @returns An unsubscribe function to remove the handler.\n */\n addSpanHandler(handler: StartSpanFn): Unsubscribe {\n _handlers.push(handler);\n return () => {\n const idx = _handlers.indexOf(handler);\n if (idx !== -1) _handlers.splice(idx, 1);\n };\n },\n};\n","import { BeraError, type IBeraErrorArgs } from \"./BeraError\";\n\nexport interface INotFoundErrorArgs extends IBeraErrorArgs {\n resource: string;\n id: string;\n chainId: number;\n}\n\n/**\n * Error thrown when a resource is not found.\n */\nexport class NotFoundError extends BeraError {\n /**\n * The name of the resource that was not found.\n *\n * @example \"Reward vault\"\n */\n resource: string;\n /**\n * The id of the resource that was not found.\n *\n * @example \"0x1234567890123456789012345678901234567890\"\n */\n id: string;\n\n constructor(args: INotFoundErrorArgs) {\n super(args);\n this.name = \"NotFoundError\";\n this.level = args.level ?? \"info\";\n this.message = `Resource ${args.resource} with id ${args.id} not found`;\n this.resource = args.resource;\n this.id = args.id;\n }\n}\n","import type { Hex } from \"@berachain-foundation/berancer-sdk\";\nimport type { Address, TransactionReceipt } from \"viem\";\n\nimport { BeraError, type IBeraErrorArgs } from \"./BeraError\";\n\n/**\n * This error is generally thrown by beraWriteContract when a transaction or simulation fails.\n */\nexport class TransactionFailedError extends BeraError {\n /**\n * The hash of the transaction that failed.\n *\n * Null if the error is due to a simulation failure.\n */\n txHash: string | null;\n\n /**\n * The receipt of the transaction that failed.\n *\n * Null if the error is due to a simulation failure.\n */\n receipt: TransactionReceipt | null;\n\n /**\n * The address of the contract that was called.\n */\n to: Address | undefined;\n\n /**\n * The data of the transaction that failed.\n */\n callData: Hex | undefined;\n\n /**\n * The block number of the transaction that failed.\n */\n blockNumber: bigint | null = null;\n\n /**\n * The input of the transaction that failed.\n */\n input: object;\n\n /**\n * The function name of the transaction that failed.\n */\n functionName: string | undefined;\n\n constructor(\n args: IBeraErrorArgs & {\n txHash?: string;\n receipt?: TransactionReceipt;\n to?: Address;\n blockNumber?: bigint;\n functionName?: string;\n input: object;\n },\n ) {\n super(args);\n this.name = \"TransactionFailedError\";\n this.txHash = args.txHash || null;\n this.receipt = args.receipt || null;\n this.to = args.to;\n this.functionName = args.functionName;\n this.blockNumber = args.blockNumber ?? null;\n this.input = args.input;\n\n if (this.receipt) {\n // If we have a receipt, transaction reverted on chain\n this.message = `Transaction reverted on chain for reason: ${this.reason}`;\n } else if (this.txHash) {\n // If we have a tx hash, transaction reverted after being broadcasted but we never got a receipt\n // Might happen for network reasons\n this.message = `Transaction reverted after being broadcasted for reason: ${this.reason}`;\n } else {\n this.message = `${this.reason}: ${this.message}`;\n }\n\n this.tags = {\n ...this.tags,\n \"operation.txn.status\": args.txHash ? \"execution\" : \"simulation\",\n ...args.tags,\n };\n\n if (this.to) {\n this.tags[\"operation.txn.to\"] = this.to;\n }\n\n if (this.functionName) {\n this.tags[\"operation.txn.functionName\"] = this.functionName;\n }\n }\n}\n"]}
|
package/dist/chunk-7LNBSOVV.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkC6ZGUO4Hcjs = require('./chunk-C6ZGUO4H.cjs');var _viem = require('viem');function k({cause:e,level:t}){if(e instanceof _viem.BaseError){let n=_chunkC6ZGUO4Hcjs.e.call(void 0, {error:e,revertIfUnknown:!1});if(n.isRequestError&&n.rootCause instanceof _viem.BaseError&&"url"in n.rootCause&&typeof n.rootCause.url=="string")return new (0, _chunkC6ZGUO4Hcjs.g)({cause:n.rootCause,response:void 0,endpoint:{url:n.rootCause.url,type:"rpc"},level:t})}return e instanceof _chunkC6ZGUO4Hcjs.f?e:new (0, _chunkC6ZGUO4Hcjs.f)({cause:e,level:t})}function c(e){return e!=null}function x({value:e,property:t,fn:r}){let n=r(e);if(!n.isValid)throw new (0, _chunkC6ZGUO4Hcjs.h)({property:t,value:e,expected:n.expectedType})}function s({value:e,property:t,fn:r}){x({value:e,property:t,fn:n=>{let l=c(n),{isValid:E,expectedType:v}=r(n);return{expectedType:v,isValid:l&&E}}})}function y(e,t){s({value:e,property:t,fn:r=>({expectedType:"defined",isValid:c(r)})})}function D(e,t="publicClient"){y(e,t)}function K(e,t){s({value:e,property:t,fn:r=>({expectedType:"Address",isValid:typeof r=="string"&&_viem.isAddress.call(void 0, r)})})}function M(e,t){s({value:e,property:t,fn:r=>({expectedType:"number",isValid:(typeof r=="string"||typeof r=="number")&&Number(r)>0})})}function f(){let e={};return{emit(t,...r){for(let n of e[t]||[])n(...r)},events:e,on(t,r){return e[t]||(e[t]=[]),e[t].push(r),()=>{e[t]=_optionalChain([e, 'access', _2 => _2[t], 'optionalAccess', _3 => _3.filter, 'call', _4 => _4(n=>r!==n)])}}}}var d=f(),_= exports.f ={captureException(e){let t={exception:e,timestamp:Date.now()};d.emit("exception",t)},on(...e){return d.on(...e)}};exports.a = k; exports.b = y; exports.c = D; exports.d = K; exports.e = M; exports.f = _;
|
|
2
|
-
//# sourceMappingURL=chunk-7LNBSOVV.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/chunk-7LNBSOVV.cjs","../src/errors/initBeraError.ts","../src/errors/assert.ts","../src/utils/createEmitter.ts","../src/errors/BeraMonitoring.ts"],"names":["initBeraError","error","level","BaseError","parsed","parseViemError","RequestError","BeraError","_isDefined","value","_assert","property","fn","result","InvalidArgumentError","_assertDefined","isDefined","isValid","expectedType","assertDefined","assertPublicClient","assertAddress","isAddress","assertAmount","createEmitter","events","event","args","callback","cb","i","_emitter","BeraMonitoring","exception"],"mappings":"AAAA,qoBAA6D,4BCAnC,SAyCVA,CAAAA,CAAc,CAC5B,KAAA,CAAOC,CAAAA,CACP,KAAA,CAAAC,CACF,CAAA,CAMc,CAIZ,EAAA,CAAID,EAAAA,WAAiBE,eAAAA,CAAW,CAC9B,IAAMC,CAAAA,CAASC,iCAAAA,CACb,KAAA,CAAAJ,CAAAA,CACA,eAAA,CAAiB,CAAA,CACnB,CAAC,CAAA,CACD,EAAA,CACEG,CAAAA,CAAO,cAAA,EACPA,CAAAA,CAAO,UAAA,WAAqBD,eAAAA,EAC5B,KAAA,GAASC,CAAAA,CAAO,SAAA,EAChB,OAAOA,CAAAA,CAAO,SAAA,CAAU,GAAA,EAAQ,QAAA,CAIhC,OAAO,IAAIE,wBAAAA,CAAa,CACtB,KAAA,CAAOF,CAAAA,CAAO,SAAA,CACd,QAAA,CAAU,KAAA,CAAA,CACV,QAAA,CAAU,CACR,GAAA,CAAKA,CAAAA,CAAO,SAAA,CAAU,GAAA,CACtB,IAAA,CAAM,KACR,CAAA,CACA,KAAA,CAAAF,CACF,CAAC,CAEL,CAYA,OAPED,EAAAA,WAAiBM,mBAAAA,CACbN,CAAAA,CACA,IAAIM,wBAAAA,CAAU,CACZ,KAAA,CAAON,CAAAA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A,CAAOC,CAAK,CAAA,iBAAID,CAAAA,qBAAOC,CAAK,CAAA,6BAAG,MAAA,mBAAQI,CAAAA,EAAMD,CAAAA,GAAOC,CAAC,GACvD,CACF,CACF,CACF,CCpGA,IAAMC,CAAAA,CAAWP,CAAAA,CAA0D,CAAA,CAwB9DQ,CAAAA,aAEkD,CAI7D,gBAAA,CAAiBC,CAAAA,CAA4B,CAC3C,IAAMP,CAAAA,CAAoB,CACxB,SAAA,CAAAO,CAAAA,CACA,SAAA,CAAW,IAAA,CAAK,GAAA,CAAI,CACtB,CAAA,CACAF,CAAAA,CAAS,IAAA,CAAK,WAAA,CAAaL,CAAK,CAClC,CAAA,CAKA,EAAA,CAAA,GAAMC,CAAAA,CAAM,CACV,OAAOI,CAAAA,CAAS,EAAA,CAAG,GAAGJ,CAAI,CAC5B,CACF,CAAA,CAAA,yFAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/chunk-7LNBSOVV.cjs","sourcesContent":[null,"import { BaseError } from \"viem\";\n\nimport { BeraError } from \"./BeraError\";\nimport { parseViemError } from \"./parseViemError\";\nimport { RequestError } from \"./RequestError\";\nimport type { SeverityLevel } from \"./severity\";\n\n/**\n * The preferred way to normalize any unknown error into a BeraError.\n *\n * This function acts as a smart factory that picks the correct BeraError subclass:\n *\n * 1. If `cause` is already a `BeraError`, returns it as-is (no double-wrapping).\n * 2. If `cause` is a viem `BaseError`, runs `parseViemError` to classify it:\n * - If the root cause is an `HttpRequestError` (RPC transport failure), wraps it\n * in a `RequestError` with the endpoint URL extracted from the error.\n * 3. Otherwise, wraps in a new `BeraError` — which triggers the automatic reason\n * detection pipeline in the BeraError constructor (parseViemError → errorMap → displayMessage).\n *\n * **Use this instead of `new BeraError({ cause })` when you don't know the error type.**\n * It ensures RequestErrors are correctly classified (important for Sentry filtering\n * and fingerprinting — RequestErrors are skipped from transaction error grouping).\n *\n * @example\n * ```ts\n * try {\n * await someOperation();\n * } catch (error) {\n * // Normalizes to the right subclass, reason auto-detected\n * throw initBeraError({ cause: error });\n * }\n * ```\n *\n * @example\n * ```ts\n * // Reporting to Sentry without rethrowing\n * catch (error) {\n * captureException(initBeraError({ cause: error }));\n * }\n * ```\n */\nexport function initBeraError({\n cause: error,\n level,\n}: {\n cause: unknown;\n /**\n * The severity level of the error, only used if the error is not a BeraError.\n */\n level?: SeverityLevel;\n}): BeraError {\n // ── Step 1: Check if it's a viem BaseError that wraps an RPC transport failure ──\n // parseViemError with revertIfUnknown=false won't throw — it returns { reason: undefined }\n // if the error chain doesn't match any known type.\n if (error instanceof BaseError) {\n const parsed = parseViemError({\n error,\n revertIfUnknown: false,\n });\n if (\n parsed.isRequestError &&\n parsed.rootCause instanceof BaseError &&\n \"url\" in parsed.rootCause &&\n typeof parsed.rootCause.url === \"string\"\n ) {\n // RPC transport failure (e.g. HTTP 502 from the RPC endpoint).\n // Wrapping in RequestError gives it proper endpoint tagging and level=\"warning\".\n return new RequestError({\n cause: parsed.rootCause,\n response: undefined,\n endpoint: {\n url: parsed.rootCause.url as string,\n type: \"rpc\",\n },\n level,\n });\n }\n }\n\n // ── Step 2: Return as-is if already a BeraError, otherwise wrap ──────────\n // The BeraError constructor will run automatic reason detection on the cause.\n const err =\n error instanceof BeraError\n ? error\n : new BeraError({\n cause: error,\n level,\n });\n\n return err;\n}\n","import type { GetPublicClientReturnType } from \"@wagmi/core\";\nimport { type Address, isAddress, type PublicClient } from \"viem\";\n\nimport { InvalidArgumentError } from \"./InvalidArgumentError\";\n\nfunction _isDefined<T>(value: T): value is NonNullable<T> {\n return value !== undefined && value !== null;\n}\n\ntype _AssertFn<T> = (value: T) => { expectedType: string; isValid: boolean };\n\n/**\n * Internal assertion function.\n * @throws An InvalidArgumentError if the value is not valid.\n */\nfunction _assert<T>({\n value,\n property,\n fn,\n}: {\n value: T;\n property: string;\n fn: _AssertFn<T>;\n}) {\n const result = fn(value);\n if (!result.isValid) {\n throw new InvalidArgumentError({\n property,\n value,\n expected: result.expectedType,\n });\n }\n}\n\nfunction _assertDefined<T>({\n value,\n property,\n fn,\n}: {\n value: T;\n property: string;\n fn: (value: T) => { expectedType: string; isValid: boolean };\n}) {\n _assert({\n value,\n property,\n fn: (value) => {\n const isDefined = _isDefined(value);\n const { isValid, expectedType } = fn(value);\n return {\n expectedType,\n isValid: isDefined && isValid,\n };\n },\n });\n}\n\n/**\n * Asserts that a value is defined.\n * @throws An InvalidArgumentError if the value is undefined or null.\n */\nexport function assertDefined<T>(\n /**\n * The value to assert.\n */\n value: T,\n /**\n * The property name.\n */\n property: string,\n): asserts value is NonNullable<T> {\n _assertDefined({\n value,\n property,\n fn: (value) => ({ expectedType: \"defined\", isValid: _isDefined(value) }),\n });\n}\n\n/**\n * Asserts that a value is a PublicClient.\n * @throws An InvalidArgumentError if the value is undefined or not a PublicClient.\n */\nexport function assertPublicClient(\n /**\n * The value to assert.\n */\n value: // it's important to have both types here because it helps with typescript build performance\n PublicClient | GetPublicClientReturnType | undefined,\n /**\n * The property name.\n */\n property: string = \"publicClient\",\n): asserts value is PublicClient {\n // there's no current way to check if a value is a PublicClient, so we just assert it's defined and `value: PublicClient` will do the rest\n assertDefined(value, property);\n}\n\n/**\n * Asserts that a value is an address (20 bytes).\n * @throws An InvalidArgumentError if the value is undefined, null, not a string, or not an address.\n */\nexport function assertAddress(\n /**\n * The value to assert.\n */\n value: string | undefined | null,\n /**\n * The property name.\n */\n property: string,\n): asserts value is Address {\n _assertDefined({\n value,\n property,\n fn: (value) => ({\n expectedType: \"Address\",\n isValid: typeof value === \"string\" && isAddress(value),\n }),\n });\n}\n\n/**\n * Asserts that a value is a number greater than 0.\n * @throws An InvalidArgumentError if the value is undefined, null, not a string or number, or not a number greater than 0.\n */\nexport function assertAmount(\n /**\n * The value to assert.\n */\n value: unknown,\n /**\n * The property name.\n */\n property: string,\n): asserts value is string | number {\n _assertDefined({\n value,\n property,\n fn: (value) => ({\n expectedType: \"number\",\n isValid:\n (typeof value === \"string\" || typeof value === \"number\") &&\n Number(value) > 0,\n }),\n });\n}\n","interface EventsMap {\n [event: string]: any;\n}\n\ninterface DefaultEvents extends EventsMap {\n [event: string]: (...args: any) => void;\n}\n\nexport type Unsubscribe = () => void;\n\nexport interface Emitter<Events extends EventsMap = DefaultEvents> {\n /**\n * Calls each of the listeners registered for a given event.\n *\n * ```js\n * ee.emit('tick', tickType, tickDuration)\n * ```\n *\n * @param event The event name.\n * @param args The arguments for listeners.\n */\n emit<K extends keyof Events>(event: K, ...args: Parameters<Events[K]>): void;\n\n /**\n * Add a listener for a given event.\n *\n * ```js\n * const unbind = ee.on('tick', (tickType, tickDuration) => {\n * count += 1\n * })\n *\n * disable () {\n * unbind()\n * }\n * ```\n *\n * @param event The event name.\n * @param cb The listener function.\n * @returns Unbind listener from event.\n */\n on<K extends keyof Events>(event: K, cb: Events[K]): Unsubscribe;\n events: Partial<{ [E in keyof Events]: Events[E][] }>;\n}\n\n/**\n * An interface for mixins that expose the `on` function (without the emitter\n * bound to `this`)\n *\n * ```js\n * import { createEmitter } from '~utils/createEmitter'\n *\n * class Ticker implements EmitterMixin<Events> {\n * constructor() {\n * this.emitter = createEmitter()\n * }\n * on(...args) {\n * return this.emitter.on(...args)\n * }\n * tick() {\n * this.emitter.emit('tick')\n * }\n * }\n * ```\n */\nexport interface EmitterMixin<Events extends EventsMap = DefaultEvents> {\n on<K extends keyof Events>(event: K, cb: Events[K]): Unsubscribe;\n}\n\n/**\n * Create event emitter.\n *\n * ```js\n * import { createEmitter } from '~/utils/createEmitter'\n *\n * class Ticker {\n * constructor() {\n * this.emitter = createEmitter()\n * }\n * on(...args) {\n * return this.emitter.on(...args)\n * }\n * tick() {\n * this.emitter.emit('tick')\n * }\n * }\n * ```\n *\n * Inspired by {@link https://github.com/ai/nanoevents}\n */\nexport function createEmitter<\n Events extends EventsMap = DefaultEvents,\n>(): Emitter<Events> {\n /**\n * Event names in keys and arrays with listeners in values.\n *\n * ```js\n * emitter1.events = emitter2.events\n * emitter2.events = { }\n * ```\n */\n const events: Partial<{ [E in keyof Events]: Events[E][] }> = {};\n\n return {\n emit(event, ...args) {\n for (const callback of events[event] || []) {\n callback(...args);\n }\n },\n events,\n on(event, cb) {\n if (!events[event]) {\n events[event] = [];\n }\n\n events[event].push(cb);\n\n return () => {\n events[event] = events[event]?.filter((i) => cb !== i);\n };\n },\n };\n}\n","import { createEmitter, type EmitterMixin } from \"~/utils/createEmitter\";\nimport type { BeraError } from \"./BeraError\";\nimport type { SeverityLevel } from \"./severity\";\n\n/**\n * Context passed alongside captured exceptions.\n * Mirrors the subset of Sentry's CaptureContext that berajs actually uses.\n */\nexport interface CaptureContext {\n level: SeverityLevel;\n extra?: Record<string, unknown>;\n tags?: Record<string, string | number | boolean | null | undefined>;\n fingerprint?: string[];\n data?: Record<string, unknown>;\n}\n\nexport interface ErrorEvent {\n exception: BeraError;\n timestamp: number;\n}\n\nconst _emitter = createEmitter<{ exception: (event: ErrorEvent) => void }>();\n\n/**\n * A generic error reporter for berajs.\n *\n * Instead of calling Sentry.captureException directly, berajs calls\n * `BeraMonitoring.captureException()`. Consumer apps subscribe via `.on()` and\n * forward events to their monitoring provider (Sentry, Datadog, etc.).\n *\n * @example\n * ```ts\n * // In berajs code:\n * import { BeraMonitoring } from \"~/errors/BeraMonitoring\";\n * BeraMonitoring.captureExceptionException(error);\n *\n * // In app instrumentation:\n * import { BeraMonitoring } from \"@berachain/berajs/errors\";\n * BeraMonitoring.on((event) => {\n * if (event.type === \"exception\") {\n * Sentry.captureException(event.exception);\n * }\n * });\n * ```\n */\nexport const BeraMonitoring: {\n captureException: (exception: BeraError) => void;\n} & EmitterMixin<{ exception: (event: ErrorEvent) => void }> = {\n /**\n * Capture an exception. Notifies all subscribers.\n */\n captureException(exception: BeraError): void {\n const event: ErrorEvent = {\n exception,\n timestamp: Date.now(),\n };\n _emitter.emit(\"exception\", event);\n },\n /**\n * Subscribe to error events.\n * @returns An unsubscribe function.\n */\n on(...args) {\n return _emitter.on(...args);\n },\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/actions/clients/getEnsoClient.ts","../src/actions/tokens/getWalletBalances.ts"],"sourcesContent":["import { EnsoClient } from \"@ensofinance/sdk\";\n\nimport { appConfig } from \"@berachain/config/internal\";\n\nimport { parseBaseArgs } from \"~/utils/parseBaseArgs\";\n\nconst isProduction =\n process.env.NODE_ENV !== \"development\" && process.env.NODE_ENV !== \"test\";\n\nexport function getEnsoClient({\n useProxy = isProduction,\n ...args\n}: BeraJS.BaseFunctionArgs & { useProxy?: boolean } = {}) {\n const { config } = parseBaseArgs(args);\n return new EnsoClient({\n baseURL: useProxy\n ? `${config.bex.aggregatorsProxyUrl}/enso/api/v1/`\n : undefined,\n apiKey: useProxy\n ? // no API key since proxy has CORS for .berachain.com domains\n \"\"\n : appConfig.apiKeys.public.enso,\n });\n}\n","import { type Config, getChainId, getPublicClient } from \"@wagmi/core\";\nimport {\n type Address,\n type ContractFunctionParameters,\n erc20Abi,\n formatUnits,\n isAddress,\n} from \"viem\";\n\nimport { multicall3Abi } from \"~/abi/utils/multicall3\";\nimport {\n assertAddress,\n assertDefined,\n assertPublicClient,\n} from \"~/errors/assert\";\nimport type { BalanceToken, Token } from \"~/types/dex\";\nimport { isToken } from \"~/utils/tokens\";\n\nexport interface GetWalletBalances {\n account: string | undefined;\n tokenList: Token[] | undefined;\n wagmiConfig: Config | undefined;\n}\n\n/**\n * Returns the payload for the balanceOf call for a given token and account.\n *\n * @internal\n * @returns\n */\nexport function getBalanceCall({\n token,\n account,\n multicallAddress,\n}: {\n token: Token;\n account: Address;\n multicallAddress: Address;\n}) {\n if (isToken(token, \"BERA\") || isToken(token, \"ETH\")) {\n return {\n address: multicallAddress,\n abi: multicall3Abi,\n functionName: \"getEthBalance\",\n args: [account],\n } as const satisfies ContractFunctionParameters<\n typeof multicall3Abi,\n \"view\",\n \"getEthBalance\"\n >;\n }\n return {\n address: token.address as Address,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [account],\n } as const satisfies ContractFunctionParameters<\n typeof erc20Abi,\n \"view\",\n \"balanceOf\"\n >;\n}\n\n/**\n * fetch the balances of a given wallet address\n */\nexport async function getWalletBalances({\n account,\n tokenList,\n wagmiConfig: config,\n}: GetWalletBalances): Promise<BalanceToken[] | undefined> {\n assertDefined(config, \"config\");\n if (!account || !tokenList)\n throw new Error(\"account or tokenList is not defined\");\n\n assertAddress(account, \"account\");\n\n const filteredTokenList = tokenList.filter((token) =>\n isAddress(token.address),\n );\n\n const tokensByChainId = Object.groupBy(\n filteredTokenList,\n (token) => token.chainId ?? getChainId(config),\n );\n\n const res = await Promise.allSettled(\n Object.entries(tokensByChainId).map(async ([chainId, tokens]) => {\n assertDefined(tokens, \"tokens\");\n const publicClient = getPublicClient(config, {\n chainId: Number(chainId),\n });\n assertPublicClient(publicClient, `publicClient ${chainId}`);\n assertDefined(publicClient.chain, \"publicClient.chain\");\n assertDefined(\n publicClient.chain.contracts,\n \"publicClient.chain.contracts\",\n );\n assertDefined(\n publicClient.chain.contracts.multicall3,\n \"publicClient.chain.contracts.multicall3\",\n );\n\n const { multicall3 } = publicClient.chain.contracts;\n\n const multicall3Address =\n typeof multicall3 === \"string\" ? multicall3 : multicall3.address;\n\n assertAddress(multicall3Address, \"multicall3Address\");\n\n const call = tokens.map((token: Token) =>\n getBalanceCall({\n token,\n account,\n multicallAddress: multicall3Address,\n }),\n );\n\n const result = await publicClient.multicall({\n contracts: call,\n });\n\n return result.map((item, index) => {\n const token = tokens[index];\n if (item.error) {\n return { ...token, balance: { raw: \"0\", formatted: \"0\" } };\n }\n const formattedBalance = formatUnits(\n item.result,\n token?.decimals || 18,\n );\n\n const resultBalanceToken: BalanceToken = {\n ...token,\n balance: {\n raw: item.result.toString(),\n // TODO: this was done 10 months ago, i'm not sure it's a good solution.\n formatted: formattedBalance.includes(\"e\") ? \"0\" : formattedBalance,\n },\n } satisfies BalanceToken;\n return resultBalanceToken;\n });\n }),\n );\n\n return res.flatMap((result) =>\n result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AM,IAAM,CAC/DP,EAAcO,EAAQ,QAAQ,EAC9B,IAAMC,EAAeC,EAAgBV,EAAQ,CAC3C,QAAS,OAAOO,CAAO,CACzB,CAAC,EACDI,EAAmBF,EAAc,gBAAgBF,CAAO,EAAE,EAC1DN,EAAcQ,EAAa,MAAO,oBAAoB,EACtDR,EACEQ,EAAa,MAAM,UACnB,8BACF,EACAR,EACEQ,EAAa,MAAM,UAAU,WAC7B,yCACF,EAEA,GAAM,CAAE,WAAAG,CAAW,EAAIH,EAAa,MAAM,UAEpCI,EACJ,OAAOD,GAAe,SAAWA,EAAaA,EAAW,QAE3DV,EAAcW,EAAmB,mBAAmB,EAEpD,IAAMC,EAAON,EAAO,IAAKhB,GACvBD,EAAe,CACb,MAAAC,EACA,QAAAC,EACA,iBAAkBoB,CACpB,CAAC,CACH,EAMA,OAJe,MAAMJ,EAAa,UAAU,CAC1C,UAAWK,CACb,CAAC,GAEa,IAAI,CAACC,EAAMC,IAAU,CACjC,IAAMxB,EAAQgB,EAAOQ,CAAK,EAC1B,GAAID,EAAK,MACP,MAAO,CAAE,GAAGvB,EAAO,QAAS,CAAE,IAAK,IAAK,UAAW,GAAI,CAAE,EAE3D,IAAMyB,EAAmBC,EACvBH,EAAK,OACLvB,GAAO,UAAY,EACrB,EAUA,MARyC,CACvC,GAAGA,EACH,QAAS,CACP,IAAKuB,EAAK,OAAO,SAAS,EAE1B,UAAWE,EAAiB,SAAS,GAAG,EAAI,IAAMA,CACpD,CACF,CAEF,CAAC,CACH,CAAC,CACH,GAEW,QAASE,GAClBA,EAAO,SAAW,YAAcA,EAAO,MAAQ,CAAC,CAClD,CACF","names":["EnsoClient","appConfig","isProduction","getEnsoClient","useProxy","args","config","parseBaseArgs","EnsoClient","appConfig","getChainId","getPublicClient","erc20Abi","formatUnits","isAddress","getBalanceCall","token","account","multicallAddress","isToken","multicall3Abi","erc20Abi","getWalletBalances","tokenList","config","assertDefined","assertAddress","filteredTokenList","isAddress","tokensByChainId","getChainId","chainId","tokens","publicClient","getPublicClient","assertPublicClient","multicall3","multicall3Address","call","item","index","formattedBalance","formatUnits","result"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors/BeraTracing.ts","../src/errors/NotFoundError.ts","../src/errors/TransactionFailedError.ts"],"sourcesContent":["import type { Unsubscribe } from \"~/utils/createEmitter\";\n\n/**\n * Span context passed to tracing handlers.\n * Compatible with Sentry's StartSpanOptions (name, op, attributes).\n */\nexport type SpanContext = {\n name: string;\n op: string;\n attributes: Record<string, string | number | boolean | undefined>;\n};\n\n/**\n * A function that wraps a callback in a tracing span.\n * Compatible with Sentry.startSpan's signature.\n */\ntype StartSpanFn = <T>(\n context: SpanContext,\n callback: () => Promise<T>,\n) => Promise<T>;\n\nconst _handlers: StartSpanFn[] = [];\n\n/**\n * A generic span-tracing module for berajs.\n *\n * Instead of calling Sentry.startSpan directly, berajs calls\n * `BeraTracing.startSpan()`. Consumer apps subscribe via `.on(\"span\", handler)`\n * and forward spans to their tracing provider (Sentry, Datadog, etc.).\n *\n * Multiple handlers are supported and chain in registration order:\n * the first registered handler is the outermost wrapper.\n *\n * @example\n * ```ts\n * // In berajs code:\n * import { BeraTracing } from \"~/errors/BeraTracing\";\n * const result = await BeraTracing.startSpan(\n * { name: \"GraphQL query\", op: \"graphql.query\", attributes: {} },\n * () => executeQuery(),\n * );\n *\n * // In app instrumentation:\n * import { BeraTracing } from \"@berachain/berajs/errors\";\n * BeraTracing.addSpanHandler(Sentry.startSpan);\n * ```\n */\nexport const BeraTracing = {\n /**\n * Execute a callback, wrapping it in all registered span handlers.\n *\n * Handlers chain so each wraps the next. First registered = outermost wrapper.\n * If no handlers are registered, the callback is executed directly.\n */\n startSpan<T>(context: SpanContext, callback: () => Promise<T>): Promise<T> {\n if (_handlers.length === 0) return callback();\n\n // Chain: h1(ctx, () => h2(ctx, () => h3(ctx, () => callback())))\n return _handlers.reduceRight<() => Promise<T>>(\n (next, handler) => () => handler(context, next),\n callback,\n )();\n },\n\n /**\n * Register a span tracing handler.\n *\n * @param _event - Must be \"span\". Exists for API consistency with BeraMonitoring.\n * @param handler - A StartSpanFn, e.g. Sentry.startSpan.\n * @returns An unsubscribe function to remove the handler.\n */\n addSpanHandler(handler: StartSpanFn): Unsubscribe {\n _handlers.push(handler);\n return () => {\n const idx = _handlers.indexOf(handler);\n if (idx !== -1) _handlers.splice(idx, 1);\n };\n },\n};\n","import { BeraError, type IBeraErrorArgs } from \"./BeraError\";\n\nexport interface INotFoundErrorArgs extends IBeraErrorArgs {\n resource: string;\n id: string;\n chainId: number;\n}\n\n/**\n * Error thrown when a resource is not found.\n */\nexport class NotFoundError extends BeraError {\n /**\n * The name of the resource that was not found.\n *\n * @example \"Reward vault\"\n */\n resource: string;\n /**\n * The id of the resource that was not found.\n *\n * @example \"0x1234567890123456789012345678901234567890\"\n */\n id: string;\n\n constructor(args: INotFoundErrorArgs) {\n super(args);\n this.name = \"NotFoundError\";\n this.level = args.level ?? \"info\";\n this.message = `Resource ${args.resource} with id ${args.id} not found`;\n this.resource = args.resource;\n this.id = args.id;\n }\n}\n","import type { Hex } from \"@berachain-foundation/berancer-sdk\";\nimport type { Address, TransactionReceipt } from \"viem\";\n\nimport { BeraError, type IBeraErrorArgs } from \"./BeraError\";\n\n/**\n * This error is generally thrown by beraWriteContract when a transaction or simulation fails.\n */\nexport class TransactionFailedError extends BeraError {\n /**\n * The hash of the transaction that failed.\n *\n * Null if the error is due to a simulation failure.\n */\n txHash: string | null;\n\n /**\n * The receipt of the transaction that failed.\n *\n * Null if the error is due to a simulation failure.\n */\n receipt: TransactionReceipt | null;\n\n /**\n * The address of the contract that was called.\n */\n to: Address | undefined;\n\n /**\n * The data of the transaction that failed.\n */\n callData: Hex | undefined;\n\n /**\n * The block number of the transaction that failed.\n */\n blockNumber: bigint | null = null;\n\n /**\n * The input of the transaction that failed.\n */\n input: object;\n\n /**\n * The function name of the transaction that failed.\n */\n functionName: string | undefined;\n\n constructor(\n args: IBeraErrorArgs & {\n txHash?: string;\n receipt?: TransactionReceipt;\n to?: Address;\n blockNumber?: bigint;\n functionName?: string;\n input: object;\n },\n ) {\n super(args);\n this.name = \"TransactionFailedError\";\n this.txHash = args.txHash || null;\n this.receipt = args.receipt || null;\n this.to = args.to;\n this.functionName = args.functionName;\n this.blockNumber = args.blockNumber ?? null;\n this.input = args.input;\n\n if (this.receipt) {\n // If we have a receipt, transaction reverted on chain\n this.message = `Transaction reverted on chain for reason: ${this.reason}`;\n } else if (this.txHash) {\n // If we have a tx hash, transaction reverted after being broadcasted but we never got a receipt\n // Might happen for network reasons\n this.message = `Transaction reverted after being broadcasted for reason: ${this.reason}`;\n } else {\n this.message = `${this.reason}: ${this.message}`;\n }\n\n this.tags = {\n ...this.tags,\n \"operation.txn.status\": args.txHash ? \"execution\" : \"simulation\",\n ...args.tags,\n };\n\n if (this.to) {\n this.tags[\"operation.txn.to\"] = this.to;\n }\n\n if (this.functionName) {\n this.tags[\"operation.txn.functionName\"] = this.functionName;\n }\n }\n}\n"],"mappings":"yCAqBA,IAAMA,EAA2B,CAAC,EA0BrBC,EAAc,CAOzB,UAAaC,EAAsBC,EAAwC,CACzE,OAAIH,EAAU,SAAW,EAAUG,EAAS,EAGrCH,EAAU,YACf,CAACI,EAAMC,IAAY,IAAMA,EAAQH,EAASE,CAAI,EAC9CD,CACF,EAAE,CACJ,EASA,eAAeE,EAAmC,CAChD,OAAAL,EAAU,KAAKK,CAAO,EACf,IAAM,CACX,IAAMC,EAAMN,EAAU,QAAQK,CAAO,EACjCC,IAAQ,IAAIN,EAAU,OAAOM,EAAK,CAAC,CACzC,CACF,CACF,ECnEO,IAAMC,EAAN,cAA4BC,CAAU,CAM3C,SAMA,GAEA,YAAYC,EAA0B,CACpC,MAAMA,CAAI,EACV,KAAK,KAAO,gBACZ,KAAK,MAAQA,EAAK,OAAS,OAC3B,KAAK,QAAU,YAAYA,EAAK,QAAQ,YAAYA,EAAK,EAAE,aAC3D,KAAK,SAAWA,EAAK,SACrB,KAAK,GAAKA,EAAK,EACjB,CACF,ECzBO,IAAMC,EAAN,cAAqCC,CAAU,CAMpD,OAOA,QAKA,GAKA,SAKA,YAA6B,KAK7B,MAKA,aAEA,YACEC,EAQA,CACA,MAAMA,CAAI,EACV,KAAK,KAAO,yBACZ,KAAK,OAASA,EAAK,QAAU,KAC7B,KAAK,QAAUA,EAAK,SAAW,KAC/B,KAAK,GAAKA,EAAK,GACf,KAAK,aAAeA,EAAK,aACzB,KAAK,YAAcA,EAAK,aAAe,KACvC,KAAK,MAAQA,EAAK,MAEd,KAAK,QAEP,KAAK,QAAU,6CAA6C,KAAK,MAAM,GAC9D,KAAK,OAGd,KAAK,QAAU,4DAA4D,KAAK,MAAM,GAEtF,KAAK,QAAU,GAAG,KAAK,MAAM,KAAK,KAAK,OAAO,GAGhD,KAAK,KAAO,CACV,GAAG,KAAK,KACR,uBAAwBA,EAAK,OAAS,YAAc,aACpD,GAAGA,EAAK,IACV,EAEI,KAAK,KACP,KAAK,KAAK,kBAAkB,EAAI,KAAK,IAGnC,KAAK,eACP,KAAK,KAAK,4BAA4B,EAAI,KAAK,aAEnD,CACF","names":["_handlers","BeraTracing","context","callback","next","handler","idx","NotFoundError","BeraError","args","TransactionFailedError","BeraError","args"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors/errorMap.ts","../src/errors/getErrorMessage.ts","../src/errors/BeraError.ts","../src/errors/parseViemError.ts","../src/abi/utils/bundler3errors.ts","../src/abi/utils/erc20errors.ts","../src/abi/utils/openChainErrors.ts","../src/abi/utils/commonAbiErrors.ts","../src/errors/RequestError.ts","../src/errors/InvalidArgumentError.ts"],"sourcesContent":["export interface ErrorType {\n /**\n * Keywords to match in the error message. Use carefully. Do not use this for contract revert reasons\n * as they might match to other error messages.\n *\n * For instance InsufficientBalance might match to InsufficientBalanceToPayPythFee if used as keyword.\n */\n keywords?: string[];\n /**\n * The exact error code or contract revert reason.\n */\n reasons?: string[];\n errorMSG: string;\n}\n\nexport interface ErrorCategory {\n [key: string]: ErrorType;\n}\n\ninterface ErrorMessages {\n [key: string]: ErrorCategory | string;\n}\n\nexport const GENERAL_ERROR = \"Something went wrong. Please try again later.\";\n\nexport const errorMsgMap = {\n ERC20: {\n NOT_ENOUGH_BALANCE: {\n reasons: [\"NotEnoughBalance\"],\n errorMSG: \"You do not have enough balance to perform this action.\",\n },\n InsufficientBalance: {\n reasons: [\"InsufficientBalance\"],\n errorMSG: \"Insufficient token balance\",\n },\n INSUFFICIENT_ALLOWANCE: {\n reasons: [\n \"0x13be252b\",\n \"InsufficientAllowance\",\n \"ERC20InsufficientAllowance\",\n ],\n errorMSG: \"You do not have enough allowance to perform this action.\",\n },\n SIGNATURE_EXPIRED: {\n reasons: [\"SignatureExpired\"],\n errorMSG: \"Transaction took too long to complete. Please try again.\",\n },\n },\n HTTP: {\n RATE_LIMITED_429: {\n reasons: [\"429\"],\n errorMSG: \"Too many requests. Please try again later.\",\n },\n },\n ENSO: {\n COULD_NOT_BUILD_SHORTCUT: {\n keywords: [\n \"Could not build shortcuts for route\",\n \"Could not quote shortcuts for route\",\n ],\n\n errorMSG:\n \"There was an error building the zap route. Try with lower amounts.\",\n },\n NOT_ENOUGH_LIQUIDITY: {\n keywords: [\n \"Swap not found for a required underlying of defi route, please make sure your amountIn is within an acceptable range\",\n ],\n\n errorMSG:\n \"The amount you’re trying to swap might be too high. Please make sure that your amount is within an acceptable range.\",\n },\n NO_ROUTE_FOUND: {\n keywords: [\"No route found from\"],\n errorMSG: \"No swap route found for the given tokens.\",\n },\n },\n RPC: {\n NOT_ENOUGH_GAS_TOKEN: {\n reasons: [\"InsufficientFundsError\"],\n keywords: [\n \"insufficient funds for gas * price + value:\",\n \"The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account.\",\n ],\n errorMSG: \"Insufficient BERA balance to perform this action.\",\n },\n NONCE_TOO_LOW: {\n keywords: [\"nonce too low: next nonce\"],\n errorMSG:\n \"Nonce is too low. Your wallet might have unconfirmed transactions.\",\n },\n GAS_PRICE: {\n keywords: [\"gasLimit\"],\n errorMSG:\n \"It seems an RPC error has occurred while estimating gas. Please try your request later.\",\n },\n JSON_RPC: {\n keywords: [\"JSON-RPC\"],\n\n errorMSG:\n \"It seems an RPC error has occurred. Please try your request one more later.\",\n },\n HASH: {\n keywords: [\"hash\"],\n errorMSG:\n \"It seems an RPC error has occurred. Please check if your transaction was finalized. If not, please try again.\",\n },\n USER_REJECTION: {\n reasons: [\"UserRejectedRequestError\"],\n keywords: [\"User denied transaction signature\"],\n errorMSG: \"You rejected the transaction.\",\n },\n SMART_UPGRADE_REJECTION: {\n reasons: [\"AtomicReadyWalletRejectedUpgradeError\"],\n errorMSG:\n \"You've declined to upgrade to batch transactions for now, try again for the traditional method.\",\n },\n CHAIN_MISMATCH: {\n reasons: [\"ChainMismatchError\"],\n errorMSG:\n \"Wallet seems to be on the wrong chain, please refresh the page and try again.\",\n },\n },\n EIP7702: {\n SESSION_KEY_EXPIRED: {\n reasons: [\"SessionKeyExpired\"],\n errorMSG: \"Session key has expired. Please create a new one.\",\n },\n CALL_POLICY_VIOLATED: {\n reasons: [\"CallPolicyViolated\"],\n errorMSG: \"Call policy violated. Please check your call policies.\",\n },\n },\n HONEY: {\n BLACKLISTED_WALLET: {\n reasons: [\"BlacklistedWallet\", \"0x265693b4\"],\n errorMSG: \"Your wallet is blacklisted from minting or redeeming HONEY.\",\n },\n LIQUIDITY_ERROR: {\n reasons: [\"0x4656425a\"],\n errorMSG:\n \"You are trying to redeem more than the liquidity available in the vault.\",\n },\n },\n // NOTE: these codes are from https://github.com/balancer/balancer-v2-monorepo/blob/master/pkg/balancer-js/src/utils/errors.ts\n // ... and additionally from https://docs.balancer.fi/reference/contracts/error-codes.html\n // NOTE: descriptions are generated by GPT where not available.\n BEX: {\n SLIPPAGE_EXCEEDED: {\n reasons: [\"SlippageExceeded\", \"TooMuchSlippage\"],\n errorMSG:\n \"Price changed while executing the transaction and exceeded the allowed slippage.\",\n },\n // math\n BAL000: {\n reasons: [\"BAL#000\"],\n errorMSG: \"Addition overflow occurred during calculation. (BEX#000)\",\n },\n BAL001: {\n reasons: [\"BAL#001\"],\n errorMSG: \"Subtraction overflow occurred during calculation. (BEX#001)\",\n },\n BAL002: {\n reasons: [\"BAL#002\"],\n errorMSG: \"Subtraction underflow occurred during calculation. (BEX#002)\",\n },\n BAL003: {\n reasons: [\"BAL#003\"],\n errorMSG:\n \"Multiplication overflow occurred during calculation. (BEX#003)\",\n },\n BAL004: {\n reasons: [\"BAL#004\"],\n errorMSG: \"Attempted division by zero. (BEX#004)\",\n },\n BAL005: {\n reasons: [\"BAL#005\"],\n errorMSG: \"Multiplication overflow during FixedPoint Division. (BEX#005)\",\n },\n BAL006: {\n reasons: [\"BAL#006\"],\n errorMSG: \"Invalid x in ExpMath.pow(x, y). (BEX#006)\",\n },\n BAL007: {\n reasons: [\"BAL#007\"],\n errorMSG: \"Invalid y in ExpMath.pow(x, y). (BEX#007)\",\n },\n BAL008: {\n reasons: [\"BAL#008\"],\n errorMSG:\n \"In LogExpMath.pow(x, y), error computing x^y as exp(y * ln(x)). (BEX#008)\",\n },\n BAL009: {\n reasons: [\"BAL#009\"],\n errorMSG: \"In LogExpMath.exp(x) = e^x; x out of bounds. (BEX#009)\",\n },\n // Input\n BAL100: {\n reasons: [\"BAL#100\"],\n errorMSG: \"Value is out of acceptable bounds. (BEX#100)\",\n },\n BAL101: {\n reasons: [\"BAL#101\"],\n errorMSG:\n \"Tokens must be sorted in address order on pool registration. (BEX#101)\",\n },\n BAL102: {\n reasons: [\"BAL#102\"],\n errorMSG:\n \"Tokens must be sorted in address order on pool registration. (BEX#102)\",\n },\n BAL103: {\n reasons: [\"BAL#103\"],\n errorMSG: \"Parallel array inputs must have the same length. (BEX#103)\",\n },\n BAL104: {\n reasons: [\"BAL#104\"],\n errorMSG: \"Address to be interpreted as a token cannot be 0. (BEX#104)\",\n },\n BAL105: {\n reasons: [\"BAL#105\"],\n errorMSG: \"Insufficient byte length. (BEX#105)\",\n },\n // Shared Pools\n BAL200: {\n reasons: [\"BAL#200\"],\n errorMSG: \"All pools must contain at least two tokens. (BEX#200)\",\n },\n BAL201: {\n reasons: [\"BAL#201\"],\n errorMSG:\n \"Token count exceeds the maximum for a given pool type. (BEX#201)\",\n },\n BAL202: {\n reasons: [\"BAL#202\"],\n errorMSG: \"Swap fee percentage exceeds the maximum allowed. (BEX#202)\",\n },\n BAL203: {\n reasons: [\"BAL#203\"],\n errorMSG: \"Swap fee percentage is below the minimum allowed. (BEX#203)\",\n },\n BAL204: {\n reasons: [\"BAL#204\"],\n errorMSG:\n \"Pool initialization failed: a small amount of BPT is minted to the zero address to maintain mathematical consistency. If initial balances are too low, the initialization process may fail. (BEX#204)\",\n },\n BAL205: {\n reasons: [\"BAL#205\"],\n errorMSG:\n \"User attempted to execute a callback intended for the vault contract. (BEX#205)\",\n },\n BAL206: {\n reasons: [\"BAL#206\"],\n errorMSG:\n \"Pools must be initialized with a special 'Init' join, before they can be joined by LPs. (BEX#206)\",\n },\n BAL207: {\n reasons: [\"BAL#207\"],\n errorMSG:\n \"Slippage/front-running protection check failed on a pool exit. (BEX#207)\",\n },\n BAL208: {\n reasons: [\"BAL#208\"],\n errorMSG: \"Minimum BPT output amount not met. (BEX#208)\",\n },\n BAL209: {\n reasons: [\"BAL#209\"],\n errorMSG:\n \"Slippage/front-running protection check failed on a pool join. (BEX#209)\",\n },\n BAL210: {\n reasons: [\"BAL#210\"],\n errorMSG:\n \"Pools with oracles are limited to two tokens. A pool with the TWO_TOKEN specialization must have exactly two tokens. (BEX#210)\",\n },\n BAL211: {\n reasons: [\"BAL#211\"],\n errorMSG:\n \"The pool factory is disabled and new pools cannot be created at this time. (BEX#211)\",\n },\n // Pools\n BAL300: {\n reasons: [\"BAL#300\"],\n errorMSG:\n \"The amplification parameter is below the minimum allowed. (BEX#300)\",\n },\n BAL301: {\n reasons: [\"BAL#301\"],\n errorMSG:\n \"The amplification parameter exceeds the maximum allowed. (BEX#301)\",\n },\n BAL302: {\n reasons: [\"BAL#302\"],\n errorMSG: \"The weight parameter is below the minimum allowed. (BEX#302)\",\n },\n BAL303: {\n reasons: [\"BAL#303\"],\n errorMSG:\n \"The number of stable tokens exceeds the maximum allowed. (BEX#303)\",\n },\n BAL304: {\n reasons: [\"BAL#304\"],\n errorMSG: \"The amount of tokens in would unbalance the pool. (BEX#304)\",\n },\n BAL305: {\n reasons: [\"BAL#305\"],\n errorMSG: \"The amount of tokens out would unbalance the pool. (BEX#305)\",\n },\n BAL306: {\n reasons: [\"BAL#306\"],\n errorMSG:\n \"Disproportionate pool exit would unbalance the pool. (BEX#306)\",\n },\n BAL307: {\n reasons: [\"BAL#307\"],\n errorMSG:\n \"Disproportionate pool join would unbalance the pool. (BEX#307)\",\n },\n BAL308: {\n reasons: [\"BAL#308\"],\n errorMSG: \"Normalized weights do not add to 1.0 exactly. (BEX#308)\",\n },\n BAL309: {\n reasons: [\"BAL#309\"],\n errorMSG: \"Invalid token provided for operation. (BEX#309)\",\n },\n BAL310: {\n reasons: [\"BAL#310\"],\n errorMSG: \"Unhandled pool join operation for this pool type. (BEX#310)\",\n },\n BAL311: {\n reasons: [\"BAL#311\"],\n errorMSG: \"Pool balances must be > 0. (BEX#311)\",\n },\n BAL312: {\n reasons: [\"BAL#312\"],\n errorMSG:\n \"Invalid query for oracle data ('ago' timestamp was not in the past). (BEX#312)\",\n },\n BAL313: {\n reasons: [\"BAL#313\"],\n errorMSG: \"Oracle has no data to query. (BEX#313)\",\n },\n BAL314: {\n reasons: [\"BAL#314\"],\n errorMSG:\n \"Oracle query data is before its earliest data sample. (BEX#314)\",\n },\n BAL315: {\n reasons: [\"BAL#315\"],\n errorMSG:\n \"Cannot query an oracle sample outside the buffer of 1024. (BEX#315)\",\n },\n BAL316: {\n reasons: [\"BAL#316\"],\n errorMSG: \"Oracle query window must have non-zero duration. (BEX#316)\",\n },\n BAL317: {\n reasons: [\"BAL#317\"],\n errorMSG:\n \"Amplification parameter change has less than the minimum duration. (BEX#317)\",\n },\n BAL318: {\n reasons: [\"BAL#318\"],\n errorMSG:\n \"Cannot start an amplification parameter update if one is already ongoing. (BEX#318)\",\n },\n BAL319: {\n reasons: [\"BAL#319\"],\n errorMSG:\n \"The requested amplification parameter change is too fast (cannot halve or double over less than a day). (BEX#319)\",\n },\n BAL320: {\n reasons: [\"BAL#320\"],\n errorMSG:\n \"Cannot cancel an update if there isn't one already ongoing. (BEX#320)\",\n },\n BAL321: {\n reasons: [\"BAL#321\"],\n errorMSG: \"Stable pool invariant calculation did not converge. (BEX#321)\",\n },\n BAL322: {\n reasons: [\"BAL#322\"],\n errorMSG: \"Stable pool balance calculation did not converge. (BEX#322)\",\n },\n BAL323: {\n reasons: [\"BAL#323\"],\n errorMSG: \"Relayer must be a valid contract. (BEX#323)\",\n },\n BAL324: {\n reasons: [\"BAL#324\"],\n errorMSG: \"Base pool relayer was not called correctly. (BEX#324)\",\n },\n BAL325: {\n reasons: [\"BAL#325\"],\n errorMSG:\n \"Rebalancing relayer operation re-entered unexpectedly. (BEX#325)\",\n },\n BAL326: {\n reasons: [\"BAL#326\"],\n errorMSG:\n \"Detected time travel in gradual updates (start > end time in a gradual weights update). (BEX#326)\",\n },\n BAL327: {\n reasons: [\"BAL#327\"],\n errorMSG: \"Swaps are disabled for this pool. (BEX#327)\",\n },\n BAL328: {\n reasons: [\"BAL#328\"],\n errorMSG: \"Caller is not the owner of the LBP. (BEX#328)\",\n },\n BAL329: {\n reasons: [\"BAL#329\"],\n errorMSG:\n \"Rate returned from a rateProvider must fit within 128 bits. (BEX#329)\",\n },\n BAL330: {\n reasons: [\"BAL#330\"],\n errorMSG:\n \"Investment pools only allow proportional joins and exits when swaps are disabled (to prevent unbalancing the pool). (BEX#330)\",\n },\n BAL331: {\n reasons: [\"BAL#331\"],\n errorMSG:\n \"Gradual weight update duration too short (minimum 1 day). (BEX#331)\",\n },\n BAL332: {\n reasons: [\"BAL#332\"],\n errorMSG: \"Invalid Linear Pool operating range. (BEX#332)\",\n },\n BAL333: {\n reasons: [\"BAL#333\"],\n errorMSG: \"Linear Pool max balance must fit in 112 bits. (BEX#333)\",\n },\n BAL334: {\n reasons: [\"BAL#334\"],\n errorMSG:\n \"Unhandled pool join/exit operation for linear pool type. (BEX#334)\",\n },\n BAL335: {\n reasons: [\"BAL#335\"],\n errorMSG:\n \"Cannot reset Linear Pool targets if pool is unbalanced. (BEX#335)\",\n },\n BAL336: {\n reasons: [\"BAL#336\"],\n errorMSG: \"Unhandled pool exit operation for this pool type. (BEX#336)\",\n },\n BAL337: {\n reasons: [\"BAL#337\"],\n errorMSG:\n \"Management fees can only be collected by the pool owner. (BEX#337)\",\n },\n BAL338: {\n reasons: [\"BAL#338\"],\n errorMSG:\n \"Management swap fee percentage exceeded the maximum. (BEX#338)\",\n },\n BAL339: {\n reasons: [\"BAL#339\"],\n errorMSG:\n \"Unhandled pool join/exit operation for managed pool type. (BEX#339)\",\n },\n BAL340: {\n reasons: [\"BAL#340\"],\n errorMSG:\n \"Unhandled pool join/exit operation for phantom pool type. (BEX#340)\",\n },\n BAL341: {\n reasons: [\"BAL#341\"],\n errorMSG: \"Token does not have a valid rate provider. (BEX#341)\",\n },\n BAL342: {\n reasons: [\"BAL#342\"],\n errorMSG: \"Invalid pool initialization parameters provided. (BEX#342)\",\n },\n BAL343: {\n reasons: [\"BAL#343\"],\n errorMSG:\n \"Value is out of the new target range for the operation. (BEX#343)\",\n },\n BAL344: {\n reasons: [\"BAL#344\"],\n errorMSG: \"This feature is currently disabled. (BEX#344)\",\n },\n BAL345: {\n reasons: [\"BAL#345\"],\n errorMSG: \"The pool controller is uninitialized. (BEX#345)\",\n },\n BAL346: {\n reasons: [\"BAL#346\"],\n errorMSG: \"Cannot set swap fee during an ongoing fee change. (BEX#346)\",\n },\n BAL347: {\n reasons: [\"BAL#347\"],\n errorMSG: \"Cannot set swap fee during pending fee changes. (BEX#347)\",\n },\n BAL348: {\n reasons: [\"BAL#348\"],\n errorMSG: \"Cannot change tokens during a weight change. (BEX#348)\",\n },\n BAL349: {\n reasons: [\"BAL#349\"],\n errorMSG: \"Cannot change tokens during pending weight changes. (BEX#349)\",\n },\n BAL350: {\n reasons: [\"BAL#350\"],\n errorMSG: \"Weight parameter exceeds the maximum allowed. (BEX#350)\",\n },\n BAL351: {\n reasons: [\"BAL#351\"],\n errorMSG: \"Unauthorized join operation. (BEX#351)\",\n },\n BAL352: {\n reasons: [\"BAL#352\"],\n errorMSG:\n \"Management AUM fee percentage exceeded the maximum allowed. (BEX#352)\",\n },\n BAL353: {\n reasons: [\"BAL#353\"],\n errorMSG: \"Fractional target values are not supported. (BEX#353)\",\n },\n BAL354: {\n reasons: [\"BAL#354\"],\n errorMSG:\n \"Adding or removing BPT is not allowed in this context. (BEX#354)\",\n },\n BAL355: {\n reasons: [\"BAL#355\"],\n errorMSG: \"Invalid circuit breaker bounds configuration. (BEX#355)\",\n },\n BAL356: {\n reasons: [\"BAL#356\"],\n errorMSG: \"The circuit breaker has been triggered. (BEX#356)\",\n },\n BAL357: {\n reasons: [\"BAL#357\"],\n errorMSG: \"Malicious query detected and reverted. (BEX#357)\",\n },\n BAL358: {\n reasons: [\"BAL#358\"],\n errorMSG:\n \"Joins and exits are currently disabled for this pool. (BEX#358)\",\n },\n // Lib\n BAL400: {\n reasons: [\"BAL#400\"],\n errorMSG: \"Reentrancy detected. (BEX#400)\",\n },\n BAL401: {\n reasons: [\"BAL#401\"],\n errorMSG: \"The sender is not allowed to perform this action. (BEX#401)\",\n },\n BAL402: {\n reasons: [\"BAL#402\"],\n errorMSG: \"The contract is currently paused. (BEX#402)\",\n },\n BAL403: {\n reasons: [\"BAL#403\"],\n errorMSG: \"The pause window has expired. (BEX#403)\",\n },\n BAL404: {\n reasons: [\"BAL#404\"],\n errorMSG:\n \"The maximum pause window duration has been exceeded. (BEX#404)\",\n },\n BAL405: {\n reasons: [\"BAL#405\"],\n errorMSG:\n \"The maximum buffer period duration has been exceeded. (BEX#405)\",\n },\n BAL406: {\n reasons: [\"BAL#406\"],\n errorMSG: \"The account has insufficient balance. (BEX#406)\",\n },\n BAL407: {\n reasons: [\"BAL#407\"],\n errorMSG: \"The account has insufficient allowance. (BEX#407)\",\n },\n BAL408: {\n reasons: [\"BAL#408\"],\n errorMSG: \"ERC20: Transfer from zero address. (BEX#408)\",\n },\n BAL409: {\n reasons: [\"BAL#409\"],\n errorMSG: \"ERC20: Transfer to zero address. (BEX#409)\",\n },\n BAL410: {\n reasons: [\"BAL#410\"],\n errorMSG: \"ERC20: Mint to zero address. (BEX#410)\",\n },\n BAL411: {\n reasons: [\"BAL#411\"],\n errorMSG: \"ERC20: Burn from zero address. (BEX#411)\",\n },\n BAL412: {\n reasons: [\"BAL#412\"],\n errorMSG: \"ERC20: Approve from zero address. (BEX#412)\",\n },\n BAL413: {\n reasons: [\"BAL#413\"],\n errorMSG: \"ERC20: Approve to zero address. (BEX#413)\",\n },\n BAL414: {\n reasons: [\"BAL#414\"],\n errorMSG: \"ERC20: Transfer exceeds allowance. (BEX#414)\",\n },\n BAL415: {\n reasons: [\"BAL#415\"],\n errorMSG: \"ERC20: Decreased allowance below zero. (BEX#415)\",\n },\n BAL416: {\n reasons: [\"BAL#416\"],\n errorMSG: \"ERC20: Transfer exceeds balance. (BEX#416)\",\n },\n BAL417: {\n reasons: [\"BAL#417\"],\n errorMSG: \"ERC20: Burn exceeds allowance. (BEX#417)\",\n },\n BAL418: {\n reasons: [\"BAL#418\"],\n errorMSG: \"SafeERC20: Call failed. (BEX#418)\",\n },\n BAL419: {\n reasons: [\"BAL#419\"],\n errorMSG: \"Address has insufficient balance. (BEX#419)\",\n },\n BAL420: {\n reasons: [\"BAL#420\"],\n errorMSG: \"Address cannot send value. (BEX#420)\",\n },\n BAL421: {\n reasons: [\"BAL#421\"],\n errorMSG: \"SafeCast: Value cannot fit into int256. (BEX#421)\",\n },\n BAL422: {\n reasons: [\"BAL#422\"],\n errorMSG: \"AccessControl: Grant sender is not an admin. (BEX#422)\",\n },\n BAL423: {\n reasons: [\"BAL#423\"],\n errorMSG: \"AccessControl: Revoke sender is not an admin. (BEX#423)\",\n },\n BAL424: {\n reasons: [\"BAL#424\"],\n errorMSG:\n \"AccessControl: Renounce sender not allowed for accounts other than self. (BEX#424)\",\n },\n BAL425: {\n reasons: [\"BAL#425\"],\n errorMSG: \"Buffer period has expired. (BEX#425)\",\n },\n BAL426: {\n reasons: [\"BAL#426\"],\n errorMSG: \"Caller is not the owner. (BEX#426)\",\n },\n BAL427: {\n reasons: [\"BAL#427\"],\n errorMSG: \"New owner cannot be zero address. (BEX#427)\",\n },\n BAL428: {\n reasons: [\"BAL#428\"],\n errorMSG: \"Code deployment failed. (BEX#428)\",\n },\n BAL429: {\n reasons: [\"BAL#429\"],\n errorMSG: \"Call to non-contract address. (BEX#429)\",\n },\n BAL430: {\n reasons: [\"BAL#430\"],\n errorMSG: \"Low-level call failed. (BEX#430)\",\n },\n BAL431: {\n reasons: [\"BAL#431\"],\n errorMSG: \"The contract is not paused. (BEX#431)\",\n },\n BAL432: {\n reasons: [\"BAL#432\"],\n errorMSG: \"Address is already allowlisted. (BEX#432)\",\n },\n BAL433: {\n reasons: [\"BAL#433\"],\n errorMSG: \"Address is not allowlisted. (BEX#433)\",\n },\n BAL434: {\n reasons: [\"BAL#434\"],\n errorMSG: \"ERC20: Burn exceeds balance. (BEX#434)\",\n },\n BAL435: {\n reasons: [\"BAL#435\"],\n errorMSG: \"Invalid operation. (BEX#435)\",\n },\n BAL436: {\n reasons: [\"BAL#436\"],\n errorMSG: \"Codec overflow detected. (BEX#436)\",\n },\n BAL437: {\n reasons: [\"BAL#437\"],\n errorMSG: \"The system is in recovery mode. (BEX#437)\",\n },\n BAL438: {\n reasons: [\"BAL#438\"],\n errorMSG: \"The system is not in recovery mode. (BEX#438)\",\n },\n BAL439: {\n reasons: [\"BAL#439\"],\n errorMSG: \"Induced failure. (BEX#439)\",\n },\n BAL440: {\n reasons: [\"BAL#440\"],\n errorMSG: \"Expired signature. (BEX#440)\",\n },\n BAL441: {\n reasons: [\"BAL#441\"],\n errorMSG: \"Malformed signature. (BEX#441)\",\n },\n BAL442: {\n reasons: [\"BAL#442\"],\n errorMSG: \"SafeCast: Value cannot fit into uint64. (BEX#442)\",\n },\n BAL443: {\n reasons: [\"BAL#443\"],\n errorMSG: \"Unhandled fee type. (BEX#443)\",\n },\n BAL444: {\n reasons: [\"BAL#444\"],\n errorMSG: \"ERC20: Burn from zero address. (BEX#444)\",\n },\n // Vault\n BAL500: {\n reasons: [\"BAL#500\"],\n errorMSG: \"Invalid pool ID. (BEX#500)\",\n },\n BAL501: {\n reasons: [\"BAL#501\"],\n errorMSG: \"Caller is not the pool. (BEX#501)\",\n },\n BAL502: {\n reasons: [\"BAL#502\"],\n errorMSG: \"Sender is not the asset manager. (BEX#502)\",\n },\n BAL503: {\n reasons: [\"BAL#503\"],\n errorMSG: \"User does not allow the relayer. (BEX#503)\",\n },\n BAL504: {\n reasons: [\"BAL#504\"],\n errorMSG: \"Invalid signature. (BEX#504)\",\n },\n BAL505: {\n reasons: [\"BAL#505\"],\n errorMSG: \"Exit would yield fewer than the minimum tokens out. (BEX#505)\",\n },\n BAL506: {\n reasons: [\"BAL#506\"],\n errorMSG: \"Join would cost more than the maximum tokens in. (BEX#506)\",\n },\n BAL507: {\n reasons: [\"BAL#507\"],\n errorMSG: \"Swap violates user-supplied limits. (BEX#507)\",\n },\n BAL508: {\n reasons: [\"BAL#508\"],\n errorMSG: \"Swap transaction not mined within the deadline. (BEX#508)\",\n },\n BAL509: {\n reasons: [\"BAL#509\"],\n errorMSG: \"Cannot swap the same token. (BEX#509)\",\n },\n BAL510: {\n reasons: [\"BAL#510\"],\n errorMSG: \"Unknown amount in the first swap of a batch. (BEX#510)\",\n },\n BAL511: {\n reasons: [\"BAL#511\"],\n errorMSG: \"Malconstructed multihop swap. (BEX#511)\",\n },\n BAL512: {\n reasons: [\"BAL#512\"],\n errorMSG: \"Internal balance overflow. (BEX#512)\",\n },\n BAL513: {\n reasons: [\"BAL#513\"],\n errorMSG: \"Insufficient internal balance. (BEX#513)\",\n },\n BAL514: {\n reasons: [\"BAL#514\"],\n errorMSG: \"Invalid BERA internal balance. (BEX#514)\",\n },\n BAL515: {\n reasons: [\"BAL#515\"],\n errorMSG:\n \"Flashloan must repay the loan in the same transaction. (BEX#515)\",\n },\n BAL516: {\n reasons: [\"BAL#516\"],\n errorMSG: \"Insufficient BERA balance. (BEX#516)\",\n },\n BAL517: {\n reasons: [\"BAL#517\"],\n errorMSG: \"Unallocated BERA. (BEX#517)\",\n },\n BAL518: {\n reasons: [\"BAL#518\"],\n errorMSG:\n \"Relayers cannot receive BERA directly (only through the Vault). (BEX#518)\",\n },\n BAL519: {\n reasons: [\"BAL#519\"],\n errorMSG: \"Cannot use BERA sentinel for internal balance. (BEX#519)\",\n },\n BAL520: {\n reasons: [\"BAL#520\"],\n errorMSG: \"Tokens mismatch. (BEX#520)\",\n },\n BAL521: {\n reasons: [\"BAL#521\"],\n errorMSG: \"Token is not registered. (BEX#521)\",\n },\n BAL522: {\n reasons: [\"BAL#522\"],\n errorMSG: \"Token is already registered. (BEX#522)\",\n },\n BAL523: {\n reasons: [\"BAL#523\"],\n errorMSG: \"Tokens are already set. (BEX#523)\",\n },\n BAL524: {\n reasons: [\"BAL#524\"],\n errorMSG: \"Tokens length must be 2. (BEX#524)\",\n },\n BAL525: {\n reasons: [\"BAL#525\"],\n errorMSG: \"Nonzero token balance detected. (BEX#525)\",\n },\n BAL526: {\n reasons: [\"BAL#526\"],\n errorMSG: \"Balance total overflow detected. (BEX#526)\",\n },\n BAL527: {\n reasons: [\"BAL#527\"],\n errorMSG: \"Pool has no tokens. (BEX#527)\",\n },\n BAL528: {\n reasons: [\"BAL#528\"],\n errorMSG: \"Insufficient flash loan balance. (BEX#528)\",\n },\n // Fees\n BAL600: {\n reasons: [\"BAL#600\"],\n errorMSG: \"Swap fee percentage is too high. (BEX#600)\",\n },\n BAL601: {\n reasons: [\"BAL#601\"],\n errorMSG: \"Flash loan fee percentage is too high. (BEX#601)\",\n },\n BAL602: {\n reasons: [\"BAL#602\"],\n errorMSG: \"Insufficient flash loan fee amount. (BEX#602)\",\n },\n // FeeSplitter\n BAL700: {\n reasons: [\"BAL#700\"],\n errorMSG: \"Splitter fee percentage is too high. (BEX#700)\",\n },\n // Misc\n BAL998: {\n reasons: [\"BAL#998\"],\n errorMSG: \"Unimplemented functionality. (BEX#998)\",\n },\n BAL999: {\n reasons: [\"BAL#999\"],\n errorMSG: \"An unexpected error occurred. (BEX#999)\",\n },\n // SoR swap paths\n NO_SWAP_PATHS: {\n keywords: [\"No swap paths returned\"],\n errorMSG: \"No swap paths were found.\",\n },\n },\n AGGREGATOR: {\n NOT_ENOUGH_LIQUIDITY: {\n keywords: [\"Not enough liquidity\"],\n errorMSG: \"Not enough liquidity. Try a lower amount.\",\n },\n },\n POL: {\n REWARD_VAULT_FACTORY: {\n reasons: [\"VaultAlreadyExists\"],\n errorMSG:\n \"Failed to create action. An action already exists with this staking token.\",\n },\n NOT_REWARD_VAULT_MANAGER: {\n reasons: [\"NotRewardVaultManager\"],\n errorMSG: \"You are not the manager of this action.\",\n },\n NOT_INCENTIVE_MANAGER: {\n reasons: [\"NotIncentiveManager\"],\n errorMSG: \"You are not the incentive manager of this token.\",\n },\n DURATION_CHANGE_NOT_ALLOWED: {\n reasons: [\"DurationChangeNotAllowed\"],\n errorMSG: \"You cannot change the duration of this action.\",\n },\n INVALID_PROOF: {\n reasons: [\"InvalidProof\"],\n errorMSG: \"Tokens already claimed or invalid proof.\",\n },\n CONTRACT_PAUSED: {\n reasons: [\"EnforcedPause\"],\n errorMSG: \"The contract you're interacting with is temporarily paused.\",\n },\n DISTRIBUTION_PAUSED: {\n reasons: [\"DistributionEnforcedPause\"],\n errorMSG: \"Distribution is temporarily paused.\",\n },\n INVALID_VALIDATOR_COMMISSION: {\n reasons: [\"InvalidCommissionValue\"],\n errorMSG: \"Invalid commission percentage.\",\n },\n NOT_REWARD_ALLOCATOR: {\n reasons: [\"NotRewardAllocator\"],\n errorMSG: \"You are not the reward allocator of this validator.\",\n },\n NOT_OPERATOR: {\n reasons: [\"NotOperator\"],\n errorMSG: \"You are not the operator of this validator.\",\n },\n INVALID_REWARD_ALLOCATION: {\n reasons: [\"InvalidRewardAllocationWeights\"],\n errorMSG: \"Invalid reward allocation weights.\",\n },\n NOT_REWARD_DURATION_MANAGER: {\n reasons: [\"NotRewardDurationManager\"],\n errorMSG: \"You are not the reward duration manager of this validator.\",\n },\n },\n BEND: {\n INSUFFICIENT_POSITION: {\n keywords: [\"insufficient position\"],\n errorMSG: \"Insufficient position\",\n },\n INSUFFICIENT_LIQUIDITY: {\n keywords: [\"insufficient liquidity on market\"],\n errorMSG: \"Insufficient liquidity on market.\",\n },\n ALL_CAPS_REACHED: {\n reasons: [\"AllCapsReached\"],\n errorMSG: \"All caps reached on vault.\",\n },\n AboveMaxTimelock: {\n reasons: [\"AboveMaxTimelock\"],\n errorMSG: \"Above max timelock\",\n },\n AddressEmptyCode: {\n reasons: [\"AddressEmptyCode\"],\n errorMSG: \"Address empty code\",\n },\n AddressInsufficientBalance: {\n reasons: [\"AddressInsufficientBalance\"],\n errorMSG: \"Address insufficient balance\",\n },\n AllCapsReached: {\n reasons: [\"AllCapsReached\"],\n errorMSG: \"All caps reached\",\n },\n AlreadyPending: {\n reasons: [\"AlreadyPending\"],\n errorMSG: \"Already pending\",\n },\n AlreadySet: {\n reasons: [\"AlreadySet\"],\n errorMSG: \"Already set\",\n },\n BelowMinTimelock: {\n reasons: [\"BelowMinTimelock\"],\n errorMSG: \"Below min timelock\",\n },\n DuplicateMarket: {\n reasons: [\"DuplicateMarket\"],\n errorMSG: \"Duplicate market\",\n },\n ECDSAInvalidSignature: {\n reasons: [\"ECDSAInvalidSignature\"],\n errorMSG: \"Invalid ECDSA signature\",\n },\n ECDSAInvalidSignatureLength: {\n reasons: [\"ECDSAInvalidSignatureLength\"],\n errorMSG: \"Invalid ECDSA signature length\",\n },\n ECDSAInvalidSignatureS: {\n reasons: [\"ECDSAInvalidSignatureS\"],\n errorMSG: \"Invalid ECDSA signature S value\",\n },\n ERC20InsufficientBalance: {\n reasons: [\"ERC20InsufficientBalance\"],\n errorMSG: \"ERC20 insufficient balance\",\n },\n ERC20InvalidApprover: {\n reasons: [\"ERC20InvalidApprover\"],\n errorMSG: \"ERC20 invalid approver\",\n },\n ERC20InvalidReceiver: {\n reasons: [\"ERC20InvalidReceiver\"],\n errorMSG: \"ERC20 invalid receiver\",\n },\n ERC20InvalidSender: {\n reasons: [\"ERC20InvalidSender\"],\n errorMSG: \"ERC20 invalid sender\",\n },\n ERC20InvalidSpender: {\n reasons: [\"ERC20InvalidSpender\"],\n errorMSG: \"ERC20 invalid spender\",\n },\n ERC2612ExpiredSignature: {\n reasons: [\"ERC2612ExpiredSignature\"],\n errorMSG: \"ERC2612 expired signature\",\n },\n ERC2612InvalidSigner: {\n reasons: [\"ERC2612InvalidSigner\"],\n errorMSG: \"ERC2612 invalid signer\",\n },\n ERC4626ExceededMaxDeposit: {\n reasons: [\"ERC4626ExceededMaxDeposit\"],\n errorMSG: \"ERC4626 exceeded max deposit\",\n },\n ERC4626ExceededMaxMint: {\n reasons: [\"ERC4626ExceededMaxMint\"],\n errorMSG: \"ERC4626 exceeded max mint\",\n },\n ERC4626ExceededMaxRedeem: {\n reasons: [\"ERC4626ExceededMaxRedeem\"],\n errorMSG: \"ERC4626 exceeded max redeem\",\n },\n ERC4626ExceededMaxWithdraw: {\n reasons: [\"ERC4626ExceededMaxWithdraw\"],\n errorMSG: \"ERC4626 exceeded max withdraw\",\n },\n FailedInnerCall: {\n reasons: [\"FailedInnerCall\"],\n errorMSG: \"Failed inner call\",\n },\n InconsistentAsset: {\n reasons: [\"InconsistentAsset\"],\n errorMSG: \"Inconsistent asset\",\n },\n InconsistentReallocation: {\n reasons: [\"InconsistentReallocation\"],\n errorMSG: \"Inconsistent reallocation\",\n },\n InvalidAccountNonce: {\n reasons: [\"InvalidAccountNonce\"],\n errorMSG: \"Invalid account nonce\",\n },\n InvalidMarketRemovalNonZeroCap: {\n reasons: [\"InvalidMarketRemovalNonZeroCap\"],\n errorMSG: \"Invalid market removal (non-zero cap)\",\n },\n InvalidMarketRemovalNonZeroSupply: {\n reasons: [\"InvalidMarketRemovalNonZeroSupply\"],\n errorMSG: \"Invalid market removal (non-zero supply)\",\n },\n InvalidMarketRemovalTimelockNotElapsed: {\n reasons: [\"InvalidMarketRemovalTimelockNotElapsed\"],\n errorMSG: \"Invalid market removal (timelock not elapsed)\",\n },\n InvalidShortString: {\n reasons: [\"InvalidShortString\"],\n errorMSG: \"Invalid short string\",\n },\n MarketNotCreated: {\n reasons: [\"MarketNotCreated\"],\n errorMSG: \"Market not created\",\n },\n MarketNotEnabled: {\n reasons: [\"MarketNotEnabled\"],\n errorMSG: \"Market not enabled\",\n },\n MathOverflowedMulDiv: {\n reasons: [\"MathOverflowedMulDiv\"],\n errorMSG: \"Math overflow\",\n },\n MaxFeeExceeded: {\n reasons: [\"MaxFeeExceeded\"],\n errorMSG: \"Max fee exceeded\",\n },\n MaxQueueLengthExceeded: {\n reasons: [\"MaxQueueLengthExceeded\"],\n errorMSG: \"Max queue length exceeded\",\n },\n NoPendingValue: {\n reasons: [\"NoPendingValue\"],\n errorMSG: \"No pending value\",\n },\n NonZeroCap: {\n reasons: [\"NonZeroCap\"],\n errorMSG: \"Non-zero cap\",\n },\n NotAllocatorRole: {\n reasons: [\"NotAllocatorRole\"],\n errorMSG: \"Not allocator role\",\n },\n NotCuratorNorGuardianRole: {\n reasons: [\"NotCuratorNorGuardianRole\"],\n errorMSG: \"Not curator or guardian role\",\n },\n NotCuratorRole: {\n reasons: [\"NotCuratorRole\"],\n errorMSG: \"Not curator role\",\n },\n NotEnoughLiquidity: {\n reasons: [\"NotEnoughLiquidity\"],\n errorMSG: \"Not enough liquidity\",\n },\n NotGuardianRole: {\n reasons: [\"NotGuardianRole\"],\n errorMSG: \"Not guardian role\",\n },\n OwnableInvalidOwner: {\n reasons: [\"OwnableInvalidOwner\"],\n errorMSG: \"Invalid owner\",\n },\n OwnableUnauthorizedAccount: {\n reasons: [\"OwnableUnauthorizedAccount\"],\n errorMSG: \"Unauthorized account\",\n },\n PendingCap: {\n reasons: [\"PendingCap\"],\n errorMSG: \"Pending cap\",\n },\n PendingRemoval: {\n reasons: [\"PendingRemoval\"],\n errorMSG: \"Pending removal\",\n },\n SafeCastOverflowedUintDowncast: {\n reasons: [\"SafeCastOverflowedUintDowncast\"],\n errorMSG: \"SafeCast overflow\",\n },\n SafeERC20FailedOperation: {\n reasons: [\"SafeERC20FailedOperation\"],\n errorMSG: \"SafeERC20 failed operation\",\n },\n StringTooLong: {\n reasons: [\"StringTooLong\"],\n errorMSG: \"String too long\",\n },\n SupplyCapExceeded: {\n reasons: [\"SupplyCapExceeded\"],\n errorMSG: \"Supply cap exceeded\",\n },\n TimelockNotElapsed: {\n reasons: [\"TimelockNotElapsed\"],\n errorMSG: \"Timelock not elapsed\",\n },\n UnauthorizedMarket: {\n reasons: [\"UnauthorizedMarket\"],\n errorMSG: \"Unauthorized market\",\n },\n ZeroAddress: {\n reasons: [\"ZeroAddress\"],\n errorMSG: \"Zero address\",\n },\n ZeroFeeRecipient: {\n reasons: [\"ZeroFeeRecipient\"],\n errorMSG: \"Zero fee recipient\",\n },\n },\n} as const satisfies ErrorMessages;\n","import { type ErrorCategory, errorMsgMap, GENERAL_ERROR } from \"./errorMap\";\n\nexport interface MatchedError {\n /** The error key in the errorMap (e.g. \"NOT_ENOUGH_GAS_TOKEN\") */\n key: string;\n /** The category in the errorMap (e.g. \"RPC\", \"BEX\") */\n category: string;\n /** The user-friendly display message */\n errorMSG: string;\n /** Whether the match was by exact reason (true) or keyword (false) */\n matchedByReason: boolean;\n}\n\n/**\n * Finds the matching error entry in errorMap by reason or message.\n *\n * ## Matching priority:\n * 1. **Exact reason match** (preferred): checks `errorType.reasons` for an exact string match.\n * 2. **Keyword fallback**: checks `errorType.keywords` for case-insensitive substring matches in `message`.\n *\n * @returns The matched error entry with key and category, or null if no match found.\n */\nexport function findMatchingError({\n reason,\n message,\n}: {\n reason?: string | null;\n message?: string;\n}): MatchedError | null {\n for (const category in errorMsgMap) {\n const categoryKey = category as keyof typeof errorMsgMap;\n const errors = errorMsgMap[categoryKey] as ErrorCategory;\n\n for (const type in errors) {\n const errorType = errors[type];\n\n // Priority 1: Exact reason match (deterministic, preferred for contract revert reasons)\n if (reason) {\n if (\n errorType?.reasons?.some((r) => {\n return r === reason;\n })\n ) {\n return {\n key: type,\n category,\n errorMSG: errorType.errorMSG,\n matchedByReason: true,\n };\n }\n }\n\n // Priority 2: Keyword substring match on message (case-insensitive fallback, use carefully)\n if (\n errorType?.keywords?.some((keyword) => {\n return message?.toLowerCase().includes(keyword.toLowerCase().trim());\n })\n ) {\n return {\n key: type,\n category,\n errorMSG: errorType.errorMSG,\n matchedByReason: false,\n };\n }\n }\n }\n\n return null;\n}\n\n/**\n * Resolves a user-friendly displayMessage by matching `reason` and `message` against `errorMap.ts`.\n *\n * This is the bridge between the automatic reason detection pipeline (parseViemError) and\n * the user-facing error messages. Called by the BeraError constructor.\n *\n * ## Matching priority:\n * 1. **Exact reason match** (preferred): checks `errorType.reasons` for an exact string match.\n * This is the most reliable path — contract revert reasons like \"NotEnoughBalance\" or \"BAL#508\"\n * are matched deterministically.\n * 2. **Keyword fallback**: checks `errorType.keywords` for case-insensitive substring matches in `message`.\n * Use sparingly — keyword matching can cause false positives (e.g. \"InsufficientBalance\"\n * keyword would also match \"InsufficientBalanceToPayPythFee\").\n * 3. **GENERAL_ERROR fallback**: \"Something went wrong. Please try again later.\"\n *\n * To ensure new contract errors get good displayMessages, add their reason to `errorMap.ts`.\n * The reason is auto-detected by parseViemError — you only need to map it to a message here.\n */\nexport function getErrorMessage({\n reason,\n message,\n}: {\n reason?: string | null;\n message?: string;\n}): string {\n return findMatchingError({ reason, message })?.errorMSG ?? GENERAL_ERROR;\n}\n","import { type Abi, BaseError } from \"viem\";\n\nimport { appConfig } from \"@berachain/config/internal\";\n\nimport { GENERAL_ERROR } from \"./errorMap\";\nimport { findMatchingError } from \"./getErrorMessage\";\nimport { parseViemError, rpcErrorToReason } from \"./parseViemError\";\nimport type { SeverityLevel } from \"./severity\";\n\nexport interface IBeraErrorArgs {\n message?: string;\n displayMessage?: string;\n cause?: unknown;\n reason?: string;\n chainId?: number;\n fingerprint?: string[];\n /**\n * The level of the error to be used for error reporting.\n */\n level?: SeverityLevel;\n tags?: {\n [key in TagsKey]?: Primitive;\n };\n extra?: Record<string, unknown>;\n /**\n * Optional ABI to be used to parse the error.\n */\n abi?: Abi;\n}\n\ntype Primitive = number | string | boolean | bigint | symbol | null | undefined;\n\n/**\n * An helper type to make sure we only use the allowed tags. Sync this with docs/errors.md\n */\ntype TagsKey =\n | \"wallet.chain\"\n | \"wallet.connector\"\n | \"wallet.address\"\n | \"error.reason\"\n | \"operation.type\"\n | \"operation.key\"\n | \"operation.txn.functionName\"\n | \"operation.txn.to\"\n | \"operation.txn.status\"\n | \"operation.source.url\"\n | \"operation.source.name\"\n | \"operation.source.queryName\"\n | \"operation.source.type\";\n\n/**\n * Base error class for the entire berajs SDK.\n *\n * All errors should be a BeraError or one of its subclasses. Unknown errors should be\n * normalized via `initBeraError({ cause })`.\n *\n * Key design: the constructor runs an **automatic reason detection pipeline** when `reason`\n * is not explicitly provided. It calls `parseViemError` on the `cause` to extract a\n * machine-readable reason code (e.g. \"NotEnoughBalance\", \"BAL#508\", \"UserRejectedRequestError\").\n * That reason is then matched against `errorMap.ts` to resolve a user-friendly `displayMessage`.\n *\n * This means: for most viem errors, you only need to pass `cause` and everything else\n * (reason, displayMessage, level) is derived automatically.\n *\n * @see parseViemError — the reason extraction engine\n * @see errorMap.ts — reason → displayMessage mapping\n * @see initBeraError — normalizes any error into a BeraError (preferred entry point)\n */\nexport class BeraError extends Error {\n /**\n * A human-readable message that can be displayed to end user.\n *\n * In berachain dapps, this is shown in the error pop-up.\n */\n displayMessage: string;\n\n /**\n * The cause of the error.\n *\n * This is typically the error that was thrown.\n */\n cause: unknown;\n\n /**\n * The chain id of the error.\n */\n chainId?: number;\n\n /**\n * The code for the reason for the error.\n *\n * This is typically the error code can be found in the errorMap.ts file. I.e. NotEnoughBalance or BAL#508\n */\n reason: string | null = null;\n\n /**\n * The fingerprint for the error.\n *\n * This is typically used to group errors in Sentry.\n */\n fingerprint: string[] | undefined;\n\n private _tags: {\n [key: string | TagsKey]: Primitive;\n } = {};\n\n set tags(tags: {\n [key: string | TagsKey]: Primitive;\n }) {\n this._tags = tags;\n }\n\n get tags(): {\n [key: string | TagsKey]: Primitive;\n } {\n return {\n ...this._tags,\n \"error.displayMessage\": this.displayMessage,\n \"error.reason\": this.reason,\n \"error.level\": this.level,\n };\n }\n\n level: SeverityLevel = \"error\";\n\n extra: Record<string, unknown> = {};\n\n constructor({\n message: m,\n displayMessage: dm,\n cause,\n reason,\n level,\n abi,\n tags,\n chainId,\n fingerprint,\n }: IBeraErrorArgs) {\n let message = m;\n\n if (!message) {\n if (cause instanceof BaseError) {\n // Using shortMesage as it doesn't include the payload.\n message = cause.shortMessage;\n } else if (cause instanceof Error) {\n message = cause.message;\n } else if (\n typeof cause === \"object\" &&\n cause !== null &&\n \"message\" in cause &&\n typeof cause.message === \"string\"\n ) {\n // this covers responses from HTTP requests\n message = cause.message;\n }\n }\n super(message, {\n cause,\n });\n\n this.name = \"BeraError\";\n\n this.fingerprint = fingerprint;\n\n this.cause = cause;\n\n this.chainId = chainId;\n\n // ── Automatic reason detection ──────────────────────────────────────\n // If `reason` was provided explicitly, use it directly.\n // Otherwise, attempt to extract it from the `cause` by unwrapping the viem error chain.\n // parseViemError walks nested errors (ContractFunctionExecutionError →\n // ContractFunctionRevertedError → RpcRequestError) and decodes revert data using ABI.\n // The extracted reason (e.g. \"NotEnoughBalance\", \"BAL#508\") is the key that drives\n // displayMessage resolution and Sentry fingerprinting.\n if (reason) {\n this.reason = reason;\n } else if (cause instanceof Error) {\n try {\n const parsed = parseViemError({\n error: cause,\n revertIfUnknown: true,\n abi,\n });\n\n this.reason = parsed?.reason ?? null;\n } catch {\n // parseViemError throws when it can't identify the error type and revertIfUnknown=true.\n // In that case, reason stays null and displayMessage falls back to GENERAL_ERROR.\n }\n }\n\n // ── Level inference ─────────────────────────────────────────────────\n // User rejections are \"info\" (not actionable by devs), everything else defaults to \"error\".\n if (level) {\n this.level = level;\n } else if (this.reason === rpcErrorToReason(\"UserRejectedRequestError\")) {\n this.level = \"info\";\n } else {\n this.level = \"error\";\n }\n\n // ── displayMessage resolution ─────────────────────────────────────────\n // Priority:\n // 1. Explicit `displayMessage` passed by caller\n // 2. Cascaded from a BeraError cause (if it has a non-generic message)\n // 3. Looked up from errorMap.ts using the detected `reason` and `message`\n // 4. GENERAL_ERROR fallback: \"Something went wrong. Please try again later.\"\n let displayMessage = dm;\n\n if (\n this.cause instanceof BeraError &&\n this.cause.displayMessage !== GENERAL_ERROR\n ) {\n // Cascade: inner BeraError already resolved a good displayMessage, reuse it\n displayMessage = this.cause.displayMessage;\n }\n\n if (!displayMessage) {\n // Match reason (exact) or message (keyword) against errorMap.ts\n const matched = findMatchingError(this);\n displayMessage = matched?.errorMSG;\n\n // ── Reason normalization ──────────────────────────────────────────\n // If the reason was resolved from a raw error message (e.g. \"insufficient funds for\n // gas * price + value: have X want Y\") rather than a stable key (e.g. \"InsufficientFundsError\"),\n // normalize it to the matched errorMap key (e.g. \"NOT_ENOUGH_GAS\") for stable Sentry fingerprinting.\n if (matched && !matched.matchedByReason && this.reason) {\n this.reason = matched.key;\n }\n }\n\n this.displayMessage = displayMessage ?? GENERAL_ERROR;\n\n this.tags = {\n ...this.tags,\n ...tags,\n };\n // Useful for debugging in development or on vercel preview links\n if (!appConfig.env.isProduction && process.env.NODE_ENV !== \"test\") {\n console.group(\"BeraError thrown\");\n console.debug(\"Level\", this.level);\n console.debug(\"Reason\", this.reason);\n console.debug(\"Message\", this.message);\n console.debug(\"Display Message\", this.displayMessage);\n console.debug(\"Cause\", this.cause);\n console.groupEnd();\n }\n }\n}\n","import {\n type Abi,\n AtomicReadyWalletRejectedUpgradeError,\n BaseError,\n ContractFunctionExecutionError,\n ContractFunctionRevertedError,\n type DecodeErrorResultReturnType,\n decodeErrorResult,\n HttpRequestError,\n type ProviderRpcErrorCode,\n RpcRequestError,\n TransactionExecutionError,\n UserRejectedRequestError,\n} from \"viem\";\n\nimport { commonAbiErrors } from \"~/abi/utils/commonAbiErrors\";\n\n/**\n * Duck-type check for viem's BaseError.\n *\n * We can't always rely on `instanceof BaseError` because viem errors may originate\n * from a different version of the `viem` package (e.g. in dependency tree mismatches).\n * The duck-type fallback checks for the structural shape that all viem errors share:\n * `shortMessage`, `message`, and `details`.\n */\nfunction isBaseError(error: unknown): error is BaseError {\n if (error instanceof BaseError) {\n return true;\n }\n\n if (\n error instanceof Error &&\n \"shortMessage\" in error &&\n \"message\" in error &&\n \"details\" in error\n ) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Type-guard for specific viem error types.\n *\n * Uses both `instanceof` and `error.name` to handle cases where the error\n * was created by a different viem version (name-based fallback).\n */\nfunction isViemError<T extends Error>(\n error: Error,\n name: T[\"name\"],\n shouldBeInstanceOf: new (...args: any[]) => T,\n): error is T {\n if (error instanceof shouldBeInstanceOf) {\n return true;\n }\n\n if (error.name === name) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Extracts a human-readable reason string from a decoded Solidity error.\n *\n * Solidity has two kinds of revert errors:\n * - `revert(\"some message\")` → decoded as `Error(string)` where the message is in `args[0]`.\n * In this case we return the string argument (e.g. `\"BAL#508\"`).\n * - `revert CustomError(...)` → decoded as `CustomError(...)` where `errorName` is the\n * custom error name. In this case we return `errorName` (e.g. `\"NotEnoughBalance\"`).\n *\n * The returned string is used as the `reason` field in BeraError and is matched against\n * `errorMap.ts` to resolve a user-friendly `displayMessage`.\n */\nexport function parseDecodedError<const abi extends Abi | readonly unknown[]>(\n error: DecodeErrorResultReturnType<abi>,\n): string | undefined {\n if (\n error.errorName === \"Error\" &&\n Array.isArray(error.args) &&\n error.args?.at(0)\n ) {\n // Solidity `revert(\"message\")` — the message string is the reason\n return error.args?.at(0) as string;\n }\n\n // Custom error `revert CustomError(...)` — the error name is the reason\n return error.errorName;\n}\n\n/**\n * The reason extraction engine — recursively unwraps viem error chains to extract\n * a machine-readable `reason` string.\n *\n * This function is the core of the automatic reason detection system. It is called by:\n * - `BeraError` constructor (when `reason` is not manually provided)\n * - `initBeraError` (to detect if the error is a RequestError)\n * - `getRevertReason` (after replaying a failed on-chain transaction)\n *\n * ## Viem error chain structure\n *\n * Viem errors are deeply nested. The typical chains look like:\n *\n * **From `simulateContract`:**\n * ```\n * ContractFunctionExecutionError ← wrapper, skipped\n * └── ContractFunctionRevertedError ← reason extracted here (cause.reason / cause.signature)\n * ```\n *\n * **From `publicClient.call` (raw call):**\n * ```\n * CallExecutionError ← wrapper, skipped\n * └── ExecutionRevertedError ← wrapper, skipped\n * └── RpcRequestError ← reason decoded from cause.data using ABI\n * ```\n *\n * **From `writeContract` / `sendTransaction`:**\n * ```\n * TransactionExecutionError ← checked for special wallet errors\n * └── UserRejectedRequestError ← \"UserRejectedRequestError\"\n * └── AtomicReadyWalletRejectedUpgradeError ← \"AtomicReadyWalletRejectedUpgradeError\"\n * ```\n *\n * **From RPC transport failures:**\n * ```\n * ContractFunctionExecutionError ← wrapper, skipped\n * └── HttpRequestError ← \"HttpRequestError(status:<code>)\", isRequestError=true\n * ```\n *\n * The function walks `cause.cause` in a while loop until it finds an error type it can\n * extract a reason from, or runs out of nested causes.\n *\n * ## Parameters\n *\n * @param error - Any Error instance (typically a viem BaseError).\n * @param abi - Optional contract ABI. Merged with `commonAbiErrors` to decode revert data.\n * Passing the correct ABI enables decoding custom error names (e.g. \"SlippageExceeded\")\n * instead of falling back to hex selectors (e.g. \"0xa3b1e29f\").\n * @param revertIfUnknown - If true, throws when the error doesn't match any known pattern.\n * The BeraError constructor calls with `true`; `initBeraError` calls with `false`.\n *\n * @returns `{ reason, rootCause, isRequestError? }` where:\n * - `reason` is the extracted error code/name (matched against errorMap.ts for displayMessage)\n * - `rootCause` is the deepest error in the chain that was identified\n * - `isRequestError` is true if the error is an HTTP/RPC transport failure\n */\nexport function parseViemError({\n error,\n abi,\n revertIfUnknown = true,\n}: {\n error: Error;\n abi?: Abi;\n revertIfUnknown: boolean;\n}): {\n reason: string | undefined;\n rootCause: unknown;\n isRequestError?: boolean;\n} {\n // If it's not a viem-shaped error, either rethrow or return the message as-is\n if (!isBaseError(error)) {\n if (revertIfUnknown) {\n throw error;\n }\n\n if (error instanceof BaseError) {\n return { reason: error.shortMessage, rootCause: error };\n }\n\n return { reason: error.message, rootCause: error };\n }\n\n // Begin unwrapping the nested error chain\n let cause: unknown = error;\n\n // Walk the nested viem error chain from outermost to innermost.\n // Each iteration checks for known error types and either extracts the reason or\n // skips the wrapper to go deeper into `cause.cause`.\n while (isBaseError(cause)) {\n // ── Step 1: Skip wrapper errors that don't carry reason data ────────────\n // ContractFunctionExecutionError is a top-level wrapper from simulateContract/writeContract.\n // The actual revert info is in its nested cause.\n if (\n isViemError(\n cause,\n \"ContractFunctionExecutionError\",\n ContractFunctionExecutionError,\n )\n ) {\n cause = cause.cause;\n continue;\n }\n\n // ── Step 2: Check for wallet-level errors ──────────────────────────────\n // TransactionExecutionError wraps errors from wallet interactions (sendTransaction).\n // Check for EIP-7702 smart wallet upgrade rejection specifically.\n if (\n isViemError(cause, \"TransactionExecutionError\", TransactionExecutionError)\n ) {\n if (cause.cause instanceof AtomicReadyWalletRejectedUpgradeError) {\n return {\n reason: \"AtomicReadyWalletRejectedUpgradeError\",\n rootCause: cause.cause,\n };\n }\n }\n\n // ── Step 3: RpcRequestError — from raw `publicClient.call` ─────────────\n // Error chain: CallExecutionError → ExecutionRevertedError → RpcRequestError\n // The revert data is in `cause.data` as raw hex bytes.\n // We decode it using the provided ABI + commonAbiErrors to get the error name.\n if (isViemError(cause, \"RpcRequestError\", RpcRequestError)) {\n if (!cause.data) {\n // No revert data available — check if there's a nested message (special RPC cases)\n if (\n typeof cause.cause === \"object\" &&\n cause.cause &&\n \"message\" in cause.cause &&\n typeof cause.cause.message === \"string\"\n ) {\n return { reason: cause.cause.message, rootCause: cause.cause };\n }\n\n throw new Error(\"No data\", { cause });\n }\n\n // Decode the raw revert bytes into a structured error using ABI.\n // commonAbiErrors includes Error(string) and Panic(uint256) so standard reverts\n // are always decodable even without a user-provided ABI.\n const decodedError = decodeErrorResult({\n data: cause.data as `0x${string}`,\n abi: [...commonAbiErrors, ...(abi ?? [])],\n });\n\n return {\n reason: parseDecodedError(decodedError) ?? cause.shortMessage,\n rootCause: cause,\n };\n }\n\n // ── Step 4: ContractFunctionRevertedError — from `simulateContract` ────\n // Error chain: ContractFunctionExecutionError → ContractFunctionRevertedError\n // Viem already decoded the revert using the ABI passed to simulateContract.\n // `cause.reason` is the decoded error name (e.g. \"NotEnoughBalance\").\n // `cause.signature` is the 4-byte selector fallback (e.g. \"0x13be252b\").\n // `cause.data?.errorName` is another fallback from the decoded data.\n if (\n isViemError(\n cause,\n \"ContractFunctionRevertedError\",\n ContractFunctionRevertedError,\n )\n ) {\n return {\n reason:\n cause.reason ??\n cause.signature ??\n cause.data?.errorName ??\n cause.shortMessage,\n rootCause: cause,\n };\n }\n\n // ── Step 5: UserRejectedRequestError — wallet popup dismissed ──────────\n // The user clicked \"Reject\" in their wallet. Level is set to \"info\" by BeraError constructor.\n if (\n isViemError(cause, \"UserRejectedRequestError\", UserRejectedRequestError)\n ) {\n return { reason: \"UserRejectedRequestError\", rootCause: cause };\n }\n\n // ── Step 6: HttpRequestError — RPC transport failure ───────────────────\n // The RPC endpoint returned an HTTP error (e.g. 502, 503).\n // Flagged as isRequestError so initBeraError can wrap it in a RequestError.\n if (isViemError(cause, \"HttpRequestError\", HttpRequestError)) {\n return {\n reason: `HttpRequestError(status:${cause.status})`,\n rootCause: cause,\n isRequestError: true,\n };\n }\n\n // ── Step 7: End of chain — no deeper cause to unwrap ───────────────────\n if (!cause.cause) {\n return { reason: cause.name, rootCause: cause };\n }\n\n // Keep unwrapping\n cause = cause.cause;\n }\n\n if (!revertIfUnknown) {\n return { reason: undefined, rootCause: cause };\n }\n\n // Cannot use BeraError here because of circular dependency\n throw new Error(\"UnknownErrorInGetRevertReason\", {\n cause: cause,\n });\n}\n\n/**\n * Returns the error code thrown by RpcError.\n *\n * @see {@link RpcError}\n * @param errCode - The error code to get the name for.\n * @returns The name of the error code.\n */\nexport function rpcErrorToReason(\n errCode:\n | number\n | ProviderRpcErrorCode\n // Here we add errors for which we know the code\n | \"UserRejectedRequestError\",\n): string {\n switch (errCode) {\n // Actually this should not get here if UserRejectedRequestError is thrown\n case \"UserRejectedRequestError\":\n case 4001:\n return \"UserRejectedRequestError\";\n default:\n return `RPC_ERROR_${errCode}`;\n }\n}\n","export const bundler3errorsAbi = [\n { inputs: [], name: \"AlreadyInitiated\", type: \"error\" },\n { inputs: [], name: \"EmptyBundle\", type: \"error\" },\n { inputs: [], name: \"IncorrectReenterHash\", type: \"error\" },\n { inputs: [], name: \"MissingExpectedReenter\", type: \"error\" },\n] as const;\n","/**\n * A list of ERC20 error codes according to eip-6093 and solady.\n *\n * This is needed since viem erc20Abi does not include error codes.\n */\nexport const erc20errorsAbi = [\n { inputs: [], name: \"AllowanceOverflow\", type: \"error\" },\n { inputs: [], name: \"AllowanceUnderflow\", type: \"error\" },\n { inputs: [], name: \"ETHTransferFailed\", type: \"error\" },\n { inputs: [], name: \"InsufficientAllowance\", type: \"error\" },\n { inputs: [], name: \"InsufficientBalance\", type: \"error\" },\n { inputs: [], name: \"InvalidPermit\", type: \"error\" },\n { inputs: [], name: \"Permit2AllowanceIsFixedAtInfinity\", type: \"error\" },\n { inputs: [], name: \"PermitExpired\", type: \"error\" },\n { inputs: [], name: \"TotalSupplyOverflow\", type: \"error\" },\n { name: \"AllowanceOverflow\", type: \"error\", inputs: [] },\n { name: \"AllowanceUnderflow\", type: \"error\", inputs: [] },\n { name: \"InsufficientAllowance\", type: \"error\", inputs: [] },\n { name: \"InsufficientBalance\", type: \"error\", inputs: [] },\n { name: \"InvalidPermit\", type: \"error\", inputs: [] },\n { name: \"Permit2AllowanceIsFixedAtInfinity\", type: \"error\", inputs: [] },\n { name: \"PermitExpired\", type: \"error\", inputs: [] },\n { name: \"TotalSupplyOverflow\", type: \"error\", inputs: [] },\n { name: \"ECDSAInvalidSignature\", type: \"error\", inputs: [] },\n {\n name: \"ECDSAInvalidSignatureLength\",\n type: \"error\",\n inputs: [{ type: \"uint256\" }],\n },\n {\n name: \"ECDSAInvalidSignatureS\",\n type: \"error\",\n inputs: [{ type: \"bytes32\" }],\n },\n {\n name: \"ERC20InsufficientAllowance\",\n type: \"error\",\n inputs: [{ type: \"address\" }, { type: \"uint256\" }, { type: \"uint256\" }],\n },\n {\n name: \"ERC20InsufficientBalance\",\n type: \"error\",\n inputs: [{ type: \"address\" }, { type: \"uint256\" }, { type: \"uint256\" }],\n },\n {\n name: \"ERC20InvalidApprover\",\n type: \"error\",\n inputs: [{ type: \"address\" }],\n },\n {\n name: \"ERC20InvalidReceiver\",\n type: \"error\",\n inputs: [{ type: \"address\" }],\n },\n { name: \"ERC20InvalidSender\", type: \"error\", inputs: [{ type: \"address\" }] },\n { name: \"ERC20InvalidSpender\", type: \"error\", inputs: [{ type: \"address\" }] },\n {\n name: \"ERC2612ExpiredSignature\",\n type: \"error\",\n inputs: [{ type: \"uint256\" }],\n },\n {\n name: \"ERC2612InvalidSigner\",\n type: \"error\",\n inputs: [{ type: \"address\" }, { type: \"address\" }],\n },\n {\n name: \"InvalidAccountNonce\",\n type: \"error\",\n inputs: [{ type: \"address\" }, { type: \"uint256\" }],\n },\n { name: \"InvalidShortString\", type: \"error\", inputs: [] },\n { name: \"StringTooLong\", type: \"error\", inputs: [{ type: \"string\" }] },\n] as const;\n","export const openChainErrorsAbi = [\n {\n name: \"AllowanceExpired\",\n type: \"error\",\n inputs: [\n {\n type: \"uint256\",\n },\n ],\n },\n {\n name: \"AssetNotRegistered\",\n type: \"error\",\n inputs: [\n {\n type: \"address\",\n },\n ],\n },\n {\n name: \"ERC20InsufficientAllowance\",\n type: \"error\",\n inputs: [\n {\n type: \"address\",\n },\n {\n type: \"uint256\",\n },\n {\n type: \"uint256\",\n },\n ],\n },\n {\n name: \"ERC4626ExceededMaxWithdraw\",\n type: \"error\",\n inputs: [\n {\n type: \"address\",\n },\n {\n type: \"uint256\",\n },\n {\n type: \"uint256\",\n },\n ],\n },\n {\n name: \"ERC721NonexistentToken\",\n type: \"error\",\n inputs: [\n {\n type: \"uint256\",\n },\n ],\n },\n {\n name: \"ExecutionFailed\",\n type: \"error\",\n inputs: [\n {\n type: \"uint256\",\n },\n {\n type: \"address\",\n },\n {\n type: \"string\",\n },\n ],\n },\n {\n name: \"ExpiredTransaction\",\n type: \"error\",\n inputs: [],\n },\n {\n name: \"FailedToCallFunction\",\n type: \"error\",\n inputs: [\n {\n type: \"bytes\",\n },\n ],\n },\n {\n name: \"InsufficientAmountOut\",\n type: \"error\",\n inputs: [],\n },\n {\n name: \"MinimalOutputBalanceViolation\",\n type: \"error\",\n inputs: [\n {\n type: \"address\",\n },\n {\n type: \"uint256\",\n },\n ],\n },\n {\n name: \"NotPegged\",\n type: \"error\",\n inputs: [\n {\n type: \"address\",\n },\n ],\n },\n {\n name: \"RedeemMoreThanMax\",\n type: \"error\",\n inputs: [],\n },\n {\n name: \"SignatureExpired\",\n type: \"error\",\n inputs: [\n {\n type: \"uint256\",\n },\n ],\n },\n {\n name: \"SlippageExceeded\",\n type: \"error\",\n inputs: [\n {\n type: \"uint256\",\n },\n {\n type: \"uint256\",\n },\n ],\n },\n {\n name: \"SlippageExceeded\",\n type: \"error\",\n inputs: [],\n },\n {\n name: \"StalePrice\",\n type: \"error\",\n inputs: [],\n },\n {\n name: \"TooMuchSlippage\",\n type: \"error\",\n inputs: [\n {\n type: \"address\",\n },\n {\n type: \"uint256\",\n },\n {\n type: \"uint256\",\n },\n ],\n },\n {\n name: \"TransferFromFailed\",\n type: \"error\",\n inputs: [],\n },\n {\n name: \"UnexpectedBasketModeStatus\",\n type: \"error\",\n inputs: [],\n },\n {\n name: \"zeroAmountRequired\",\n type: \"error\",\n inputs: [],\n },\n] as const;\n","import { bundler3errorsAbi } from \"./bundler3errors\";\nimport { erc20errorsAbi } from \"./erc20errors\";\nimport { openChainErrorsAbi } from \"./openChainErrors\";\n\nexport const commonAbiErrors = [\n ...erc20errorsAbi,\n ...bundler3errorsAbi,\n ...openChainErrorsAbi,\n] as const;\n","import type { ErrorLike } from \"@apollo/client\";\n\nimport { mainnet } from \"@berachain/config/mainnet\";\n\nimport { BeraError, type IBeraErrorArgs } from \"./BeraError\";\nimport { errorMsgMap } from \"./errorMap\";\n\n/**\n * This is an error class that should be used to handle errors from fetch requests.\n */\nexport class RequestError extends BeraError {\n /**\n * The error response from the request.\n */\n response: Response | ErrorLike | undefined;\n\n static isCorsError(error: Error) {\n return error.cause instanceof Response && error.cause.type === \"cors\";\n }\n /**\n * The endpoint that was requested.\n */\n endpoint: {\n name?: string;\n url: string;\n type?: \"rest\" | \"graphql\" | \"rpc\";\n };\n\n /**\n * A list of domains that should have their query params removed.\n */\n private queryRichfulDomains = [\n mainnet.bex.aggregatorsProxyUrl,\n \"https://api.fly.trade/aggregator/quote\",\n \"https://open-api.openocean.finance/v4/bera/swap\",\n // vercel internal proxy\n \"/api/aggregators?aggregator\",\n // bonder endpoints have date-based query params (e.g. ?start=2025-11-28)\n mainnet.bonder,\n ];\n\n statusCode: number | undefined;\n\n payload?: object;\n\n static readonly REASON_MAP = {\n 429: \"RATE_LIMITED_429\",\n NETWORK_ERROR: \"NETWORK_ERROR\",\n CORS_ERROR: \"CORS\",\n } as const;\n\n constructor(\n args: IBeraErrorArgs & {\n response: Response | ErrorLike | undefined;\n /**\n * The payload sent to the request.\n */\n payload?: object;\n endpoint:\n | string\n | URL\n | {\n name?: string;\n url: string | URL;\n type: \"rest\" | \"graphql\" | \"rpc\";\n };\n statusCode?: number;\n },\n ) {\n super(args);\n this.name = \"RequestError\";\n this.response = args.response;\n this.payload = args.payload;\n this.endpoint = this.setEndpoint(args.endpoint);\n\n if (\n !this.message &&\n typeof this.cause === \"object\" &&\n this.cause !== null\n ) {\n if (\"error\" in this.cause && typeof this.cause.error === \"string\") {\n // haiku returns the error in the response as { error: string }\n this.message = this.cause.error;\n }\n }\n\n if (args.statusCode) {\n this.statusCode = args.statusCode;\n } else if (this.response instanceof Response) {\n this.statusCode = this.response.status;\n }\n\n if (this.statusCode === 429) {\n this.reason = RequestError.REASON_MAP[429];\n this.displayMessage = errorMsgMap.HTTP.RATE_LIMITED_429.errorMSG;\n this.level = args.level ?? \"warning\";\n } else {\n const networkError = this.tryMatchNetworkError();\n if (networkError) {\n this.reason = this.reason ?? networkError.reason;\n this.level = args.level ?? \"warning\";\n this.endpoint.url = this.endpoint.url ?? networkError.url;\n }\n }\n\n this.tags = {\n ...this.tags,\n \"error.statusCode\": this.statusCode,\n \"operation.type\": \"query\",\n ...args.tags,\n };\n\n let message = \"\";\n\n if (this.reason) {\n message += `${this.reason} – `;\n } else if (this.statusCode && this.statusCode >= 400) {\n message += `HTTP ${this.statusCode} – `;\n }\n\n const endpointLabel = this.endpoint.type\n ? `${this.endpoint.type}(${this.endpoint.url})`\n : this.endpoint.url;\n this.message = `${message}${endpointLabel}: ${this.message}`;\n }\n\n setEndpoint(\n endpoint:\n | string\n | URL\n | {\n name?: string;\n url: string | URL;\n type?: \"rest\" | \"graphql\" | \"rpc\";\n },\n ) {\n if (typeof endpoint === \"string\" || endpoint instanceof URL) {\n this.endpoint = {\n url: typeof endpoint === \"string\" ? endpoint : endpoint.toString(),\n };\n } else {\n this.endpoint = {\n ...this.endpoint,\n ...endpoint,\n url: endpoint.url.toString(),\n };\n }\n\n if (\n this.queryRichfulDomains.some((domain) =>\n this.endpoint.url.includes(domain),\n )\n ) {\n // remove query params if it's an aggregator url\n try {\n const url = new URL(this.endpoint.url);\n url.search = \"\";\n this.endpoint.url = url.toString();\n } catch {}\n }\n this.tags = {\n ...this.tags,\n \"operation.source.url\": this.endpoint.url,\n \"operation.source.name\": this.endpoint.name,\n \"operation.source.type\": this.endpoint.type,\n };\n\n return this.endpoint;\n }\n\n private tryMatchNetworkError():\n | false\n | {\n reason: string;\n message: string;\n url: string;\n } {\n if (\n (this.cause instanceof Error &&\n \"message\" in this.cause &&\n typeof this.cause.message === \"string\") ||\n this.cause instanceof TypeError\n ) {\n const message = this.cause.message as string;\n\n if (message.startsWith(\"Network Error\")) {\n return {\n reason: RequestError.REASON_MAP.NETWORK_ERROR,\n message: message,\n url: this.endpoint.url,\n };\n }\n\n // this matches standard error messages as they're returned by browser fetch when they either:\n // - have a network error\n // - have CORS errors\n // the list is empirically collected from sentry error logs.\n const failedToFetchMatch = message.match(\n /^(?:NetworkError when attempting to fetch resource\\.|Failed to fetch|Load failed) \\(([a-z0-9-.]+)\\)$/,\n );\n if (failedToFetchMatch) {\n return {\n reason: RequestError.REASON_MAP.NETWORK_ERROR,\n message: message,\n url: failedToFetchMatch[1],\n };\n }\n }\n\n if (\n typeof this.cause === \"object\" &&\n this.cause !== null &&\n \"message\" in this.cause &&\n typeof this.cause.message === \"string\"\n ) {\n const message = this.cause.message as string;\n // this is a postgres error message. found in some bonder errors.\n if (\n message.startsWith(\n \"error: canceling statement due to lock timeout occurred in\",\n )\n ) {\n return {\n reason: RequestError.REASON_MAP.NETWORK_ERROR,\n message: message,\n url: this.endpoint.url,\n };\n }\n }\n\n return false;\n }\n}\n","import { BeraError, type IBeraErrorArgs } from \"./BeraError\";\n\nexport interface IInvalidArgumentErrorArgs extends IBeraErrorArgs {\n /**\n * The name of the argument that is invalid.\n */\n property: string;\n /**\n * The value of the argument that is invalid.\n */\n value: unknown;\n\n /**\n * The expected type of the value as a string, eg. string, number, boolean, etc.\n */\n expected: string;\n}\n\n/**\n * Error thrown when argument validation fails. (e.g. an argument is missing or invalid)\n *\n * Default level is \"warning\".\n *\n * @example ```ts\n * if (!publicClient) {\n * throw new InvalidArgumentError({\n * property: \"publicClient\",\n * value: publicClient,\n * expected: \"PublicClient\",\n * });\n * }\n * if (!address || !isAddress(address)) {\n * throw new InvalidArgumentError({\n * property: \"address\",\n * value: address,\n * expected: \"Address\",\n * });\n * }\n * ```\n *\n */\nexport class InvalidArgumentError extends BeraError {\n /**\n * The name of the argument that is invalid.\n */\n property: string;\n /**\n * The value of the argument that is invalid.\n */\n value: unknown;\n\n /**\n * The expected value of the argument.\n */\n expected: string;\n\n constructor(args: IInvalidArgumentErrorArgs) {\n super(args);\n this.level = args.level ?? \"warning\";\n this.name = \"InvalidArgumentError\";\n this.property = args.property;\n this.value = args.value;\n this.expected = args.expected;\n this.message = `Invalid argument: ${this.property} ${this.isMissing ? \"is missing\" : `is invalid, expected ${this.expected}`}`;\n\n if (!args.reason) {\n this.reason = `${this.name}.${this.property}.${this.isInvalid ? \"invalid\" : \"missing\"}`;\n }\n }\n\n get isMissing(): boolean {\n return this.value === undefined;\n }\n\n /**\n * Whether the argument is defined but invalid.\n */\n get isInvalid(): boolean {\n return this.value !== undefined;\n }\n}\n"],"mappings":"AAuBO,IAAMA,EAAgB,gDAEhBC,EAAc,CACzB,MAAO,CACL,mBAAoB,CAClB,QAAS,CAAC,kBAAkB,EAC5B,SAAU,wDACZ,EACA,oBAAqB,CACnB,QAAS,CAAC,qBAAqB,EAC/B,SAAU,4BACZ,EACA,uBAAwB,CACtB,QAAS,CACP,aACA,wBACA,4BACF,EACA,SAAU,0DACZ,EACA,kBAAmB,CACjB,QAAS,CAAC,kBAAkB,EAC5B,SAAU,0DACZ,CACF,EACA,KAAM,CACJ,iBAAkB,CAChB,QAAS,CAAC,KAAK,EACf,SAAU,4CACZ,CACF,EACA,KAAM,CACJ,yBAA0B,CACxB,SAAU,CACR,sCACA,qCACF,EAEA,SACE,oEACJ,EACA,qBAAsB,CACpB,SAAU,CACR,sHACF,EAEA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E,KAAM,sBACN,KAAM,QACN,OAAQ,CAAC,CAAE,KAAM,SAAU,EAAG,CAAE,KAAM,SAAU,CAAC,CACnD,EACA,CAAE,KAAM,qBAAsB,KAAM,QAAS,OAAQ,CAAC,CAAE,EACxD,CAAE,KAAM,gBAAiB,KAAM,QAAS,OAAQ,CAAC,CAAE,KAAM,QAAS,CAAC,CAAE,CACvE,ECzEO,IAAMC,EAAqB,CAChC,CACE,KAAM,mBACN,KAAM,QACN,OAAQ,CACN,CACE,KAAM,SACR,CACF,CACF,EACA,CACE,KAAM,qBACN,KAAM,QACN,OAAQ,CACN,CACE,KAAM,SACR,CACF,CACF,EACA,CACE,KAAM,6BACN,KAAM,QACN,OAAQ,CACN,CACE,KAAM,SACR,EACA,CACE,KAAM,SACR,EACA,CACE,KAAM,SACR,CACF,CACF,EACA,CACE,KAAM,6BACN,KAAM,QACN,OAAQ,CACN,CACE,KAAM,SACR,EACA,CACE,KAAM,SACR,EACA,CACE,KAAM,SACR,CACF,CACF,EACA,CACE,KAAM,yBACN,KAAM,QACN,OAAQ,CACN,CACE,KAAM,SACR,CACF,CACF,EACA,CACE,KAAM,kBACN,KAAM,QACN,OAAQ,CACN,CACE,KAAM,SACR,EACA,CACE,KAAM,SACR,EACA,CACE,KAAM,QACR,CACF,CACF,EACA,CACE,KAAM,qBACN,KAAM,QACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,uBACN,KAAM,QACN,OAAQ,CACN,CACE,KAAM,OACR,CACF,CACF,EACA,CACE,KAAM,wBACN,KAAM,QACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,gCACN,KAAM,QACN,OAAQ,CACN,CACE,KAAM,SACR,EACA,CACE,KAAM,SACR,CACF,CACF,EACA,CACE,KAAM,YACN,KAAM,QACN,OAAQ,CACN,CACE,KAAM,SACR,CACF,CACF,EACA,CACE,KAAM,oBACN,KAAM,QACN,OAAQ,CAAC,CACX,EACA,CACE,KAAM,mBACN,KAAM,QACN,OAAQ,CACN,CACE,K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","findMatchingError","reason","message","category","errorMsgMap","errors","type","errorType","r","keyword","getErrorMessage","GENERAL_ERROR","BaseError","appConfig","AtomicReadyWalletRejectedUpgradeError","BaseError","ContractFunctionExecutionError","ContractFunctionRevertedError","decodeErrorResult","HttpRequestError","RpcRequestError","TransactionExecutionError","UserRejectedRequestError","bundler3errorsAbi","erc20errorsAbi","openChainErrorsAbi","commonAbiErrors","erc20errorsAbi","bundler3errorsAbi","openChainErrorsAbi","isBaseError","error","BaseError","isViemError","name","shouldBeInstanceOf","parseDecodedError","parseViemError","abi","revertIfUnknown","cause","ContractFunctionExecutionError","TransactionExecutionError","AtomicReadyWalletRejectedUpgradeError","RpcRequestError","decodedError","decodeErrorResult","commonAbiErrors","ContractFunctionRevertedError","UserRejectedRequestError","HttpRequestError","rpcErrorToReason","errCode","BeraError","_BeraError","tags","m","dm","cause","reason","level","abi","chainId","fingerprint","message","BaseError","parsed","parseViemError","rpcErrorToReason","displayMessage","GENERAL_ERROR","matched","findMatchingError","appConfig","mainnet","RequestError","_RequestError","BeraError","error","mainnet","args","errorMsgMap","networkError","message","endpointLabel","endpoint","domain","url","failedToFetchMatch","InvalidArgumentError","BeraError","args"]}
|
package/dist/chunk-BS6K7HGH.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk22J3YJDNcjs = require('./chunk-22J3YJDN.cjs');function m(e){return{...e,..._chunk22J3YJDNcjs.e.call(void 0, e,"BERA")&&_chunk22J3YJDNcjs.c}}function d(e){return e.map(r=>m(r))}var _bignumberjs = require('@berachain/utils/pkg/bignumber.js'); var _bignumberjs2 = _interopRequireDefault(_bignumberjs);var g=(e,r,i,o)=>{if(!e||!r||!i||!o)return 0;let t=new (0, _bignumberjs2.default)(e).times(i),n=new (0, _bignumberjs2.default)(r).times(o);if(t.lt(.01)||n.lt(.01)||t.isZero()||n.isZero())return 0;let u=n.div(t);return Number(new (0, _bignumberjs2.default)(1).minus(u).toFixed())};exports.a = m; exports.b = d; exports.c = g;
|
|
2
|
-
//# sourceMappingURL=chunk-BS6K7HGH.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/chunk-BS6K7HGH.cjs","../src/utils/tokenWrapping.ts","../src/utils/math.ts"],"names":["wrapNativeToken","token","isToken","wBeraToken","wrapNativeTokens","tokens","computePriceImpact","tokenInPrice","tokenOutPrice","inAmount","outAmount","usdIn","BigNumber","usdOut","ratio"],"mappings":"AAAA,iOAA+C,SCM/BA,CAAAA,CAAqCC,CAAAA,CAAa,CAChE,MAAO,CACL,GAAGA,CAAAA,CACH,GAAIC,iCAAAA,CAAQD,CAAO,MAAM,CAAA,EAAKE,mBAChC,CACF,CAEO,SAASC,CAAAA,CAAsCC,CAAAA,CAAkB,CACtE,OAAOA,CAAAA,CAAO,GAAA,CAAKJ,CAAAA,EAAUD,CAAAA,CAAgBC,CAAK,CAAC,CACrD,CCfA,0HAAsB,IAUTK,CAAAA,CAAqB,CAChCC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAAAA,EACW,CACX,EAAA,CAAI,CAACH,CAAAA,EAAgB,CAACC,CAAAA,EAAiB,CAACC,CAAAA,EAAY,CAACC,CAAAA,CAAW,OAAO,CAAA,CAEvE,IAAMC,CAAAA,CAAQ,IAAIC,0BAAAA,CAAUL,CAAY,CAAA,CAAE,KAAA,CAAME,CAAQ,CAAA,CAClDI,CAAAA,CAAS,IAAID,0BAAAA,CAAUJ,CAAa,CAAA,CAAE,KAAA,CAAME,CAAS,CAAA,CAI3D,EAAA,CADIC,CAAAA,CAAM,EAAA,CAAG,GAAI,CAAA,EAAKE,CAAAA,CAAO,EAAA,CAAG,GAAI,CAAA,EAChCF,CAAAA,CAAM,MAAA,CAAO,CAAA,EAAKE,CAAAA,CAAO,MAAA,CAAO,CAAA,CAAG,OAAO,CAAA,CAE9C,IAAMC,CAAAA,CAAQD,CAAAA,CAAO,GAAA,CAAIF,CAAK,CAAA,CAC9B,OAAO,MAAA,CAAO,IAAIC,0BAAAA,CAAU,CAAC,CAAA,CAAE,KAAA,CAAME,CAAK,CAAA,CAAE,OAAA,CAAQ,CAAC,CACvD,CAAA,CAAA,4CAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/chunk-BS6K7HGH.cjs","sourcesContent":[null,"import { isToken, wBeraToken } from \"./tokens\";\n\ntype BaseToken = {\n address: string;\n};\n\nexport function wrapNativeToken<T extends BaseToken>(token: T): T {\n return {\n ...token,\n ...(isToken(token, \"BERA\") && wBeraToken),\n };\n}\n\nexport function wrapNativeTokens<T extends BaseToken>(tokens: T[]): T[] {\n return tokens.map((token) => wrapNativeToken(token));\n}\n","import BigNumber from \"@berachain/utils/pkg/bignumber.js\";\n\n/**\n * Compute the price impact of a swap\n * @param {string} tokenInPrice - The price of the input token\n * @param {string} tokenOutPrice - The price of the output token\n * @param {string} inAmount - The amount of the input token\n * @param {string} outAmount - The amount of the output token\n * @returns {number} The price impact of the swap\n */\nexport const computePriceImpact = (\n tokenInPrice: string,\n tokenOutPrice: string,\n inAmount: string,\n outAmount: string,\n): number => {\n if (!tokenInPrice || !tokenOutPrice || !inAmount || !outAmount) return 0;\n\n const usdIn = new BigNumber(tokenInPrice).times(inAmount);\n const usdOut = new BigNumber(tokenOutPrice).times(outAmount);\n\n // is the amount is close to 0, return 0\n if (usdIn.lt(0.01) || usdOut.lt(0.01)) return 0;\n if (usdIn.isZero() || usdOut.isZero()) return 0;\n\n const ratio = usdOut.div(usdIn);\n return Number(new BigNumber(1).minus(ratio).toFixed());\n};\n"]}
|
package/dist/chunk-C3FHGFLK.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var a={isGovernanceEnabled:!0,enableEip5792:!1,proxyAggregatorsThroughVercel:!1,isEmbeddedWalletsEnabled:!0,sponsorGas:!1,enableSimulateCalls:!1,isBendVaultDataHourly:!0,isMultiChainZapBendEnabled:!1,isZapStakeBeraEnabled:!1,mockValidatorOperator:!1,mockValidatorRewardAllocator:!1,mockRewardDurationManager:!1,mockIncentiveManager:!1,isHoneyPythWrapperEnabled:!0};export{a};
|
|
2
|
-
//# sourceMappingURL=chunk-C3FHGFLK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contexts/BeraFlags/defaultFlags.ts"],"sourcesContent":["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 | \"isMultiChainZapBendEnabled\"\n | \"isZapStakeBeraEnabled\"\n | \"mockValidatorOperator\"\n | \"mockValidatorRewardAllocator\"\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 isMultiChainZapBendEnabled: false,\n isZapStakeBeraEnabled: false,\n mockValidatorOperator: false,\n mockValidatorRewardAllocator: false,\n mockRewardDurationManager: false,\n mockIncentiveManager: false,\n isHoneyPythWrapperEnabled: true,\n};\n"],"mappings":"AA8BO,IAAMA,EAA0B,CACrC,oBAAqB,GACrB,cAAe,GACf,8BAA+B,GAC/B,yBAA0B,GAC1B,WAAY,GACZ,oBAAqB,GACrB,sBAAuB,GACvB,2BAA4B,GAC5B,sBAAuB,GACvB,sBAAuB,GACvB,6BAA8B,GAC9B,0BAA2B,GAC3B,qBAAsB,GACtB,0BAA2B,EAC7B","names":["defaultFlags"]}
|