@berachain/berajs 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BeraError-D1HS_rbb.d.cts → BeraError-_mQdkanr.d.cts} +35 -10
- package/dist/{BeraError-D1HS_rbb.d.ts → BeraError-_mQdkanr.d.ts} +35 -10
- package/dist/HoneyConfigProvider-CK6mOKFH.d.ts +390 -0
- package/dist/HoneyConfigProvider-Ca3ouozs.d.cts +390 -0
- package/dist/{RequestError-D8AE6xnI.d.cts → RequestError-A8XJ6QR9.d.cts} +1 -1
- package/dist/{RequestError-m4jxyM7D.d.ts → RequestError-Dk97z8rm.d.ts} +1 -1
- package/dist/abi/exports.cjs +2 -0
- package/dist/abi/exports.cjs.map +1 -0
- package/dist/abi/{index.d.cts → exports.d.cts} +12369 -9122
- package/dist/abi/{index.d.ts → exports.d.ts} +12369 -9122
- package/dist/abi/exports.mjs +2 -0
- package/dist/abi/exports.mjs.map +1 -0
- package/dist/actions/exports.cjs +2 -0
- package/dist/actions/exports.cjs.map +1 -0
- package/dist/actions/{index.d.cts → exports.d.cts} +80 -107
- package/dist/actions/{index.d.ts → exports.d.ts} +80 -107
- package/dist/actions/exports.mjs +2 -0
- package/dist/actions/exports.mjs.map +1 -0
- package/dist/chunk-575OK77P.mjs +2 -0
- package/dist/chunk-575OK77P.mjs.map +1 -0
- package/dist/chunk-7GWTHOLO.mjs +2 -0
- package/dist/chunk-7GWTHOLO.mjs.map +1 -0
- package/dist/chunk-7SC4VD3U.cjs +2 -0
- package/dist/chunk-7SC4VD3U.cjs.map +1 -0
- package/dist/chunk-BHNQX4XC.mjs +2 -0
- package/dist/chunk-BHNQX4XC.mjs.map +1 -0
- package/dist/chunk-BOYZVULX.cjs +2 -0
- package/dist/chunk-BOYZVULX.cjs.map +1 -0
- package/dist/chunk-C3FHGFLK.mjs +2 -0
- package/dist/chunk-C3FHGFLK.mjs.map +1 -0
- package/dist/chunk-C3G5KXCH.mjs +2 -0
- package/dist/chunk-C3G5KXCH.mjs.map +1 -0
- package/dist/chunk-CYKCYPFR.cjs +2 -0
- package/dist/chunk-CYKCYPFR.cjs.map +1 -0
- package/dist/chunk-F4BKSBEM.mjs +2 -0
- package/dist/chunk-F4BKSBEM.mjs.map +1 -0
- package/dist/chunk-FL2N3XHK.cjs +2 -0
- package/dist/chunk-FL2N3XHK.cjs.map +1 -0
- package/dist/chunk-G6NA6NSM.mjs +4 -0
- package/dist/chunk-G6NA6NSM.mjs.map +1 -0
- package/dist/chunk-H2QSRMVS.mjs +2 -0
- package/dist/chunk-H2QSRMVS.mjs.map +1 -0
- package/dist/chunk-IJM76AWK.cjs +4 -0
- package/dist/chunk-IJM76AWK.cjs.map +1 -0
- package/dist/chunk-MTS5SZLA.mjs +2 -0
- package/dist/chunk-MTS5SZLA.mjs.map +1 -0
- package/dist/chunk-MUNAP5TM.cjs +2 -0
- package/dist/chunk-MUNAP5TM.cjs.map +1 -0
- package/dist/chunk-NAXAZJJY.mjs +2 -0
- package/dist/chunk-NAXAZJJY.mjs.map +1 -0
- package/dist/chunk-OGJMSGB2.mjs +2 -0
- package/dist/chunk-OGJMSGB2.mjs.map +1 -0
- package/dist/chunk-OIYXOKTT.cjs +2 -0
- package/dist/chunk-OIYXOKTT.cjs.map +1 -0
- package/dist/chunk-OS5AJMYJ.cjs +2 -0
- package/dist/chunk-OS5AJMYJ.cjs.map +1 -0
- package/dist/chunk-Q3SCM6WL.mjs +2 -0
- package/dist/chunk-Q3SCM6WL.mjs.map +1 -0
- package/dist/chunk-SWMJQOH6.cjs +2 -0
- package/dist/chunk-SWMJQOH6.cjs.map +1 -0
- package/dist/chunk-TEBJWAVU.mjs +2 -0
- package/dist/chunk-TEBJWAVU.mjs.map +1 -0
- package/dist/chunk-TJWKS54T.mjs +2 -0
- package/dist/chunk-TJWKS54T.mjs.map +1 -0
- package/dist/chunk-UQUWMHVF.cjs +2 -0
- package/dist/chunk-UQUWMHVF.cjs.map +1 -0
- package/dist/chunk-UXUWSRVV.cjs +2 -0
- package/dist/chunk-UXUWSRVV.cjs.map +1 -0
- package/dist/chunk-VP7XUOSI.cjs +2 -0
- package/dist/chunk-VP7XUOSI.cjs.map +1 -0
- package/dist/chunk-VXL2ZZ4X.cjs +2 -0
- package/dist/chunk-VXL2ZZ4X.cjs.map +1 -0
- package/dist/chunk-WRFDB3QJ.cjs +2 -0
- package/dist/chunk-WRFDB3QJ.cjs.map +1 -0
- package/dist/chunk-WTCBORPB.cjs +2 -0
- package/dist/chunk-WTCBORPB.cjs.map +1 -0
- package/dist/chunk-XNJLSA6P.cjs +2 -0
- package/dist/chunk-XNJLSA6P.cjs.map +1 -0
- package/dist/chunk-YQGZMWDT.mjs +2 -0
- package/dist/chunk-YQGZMWDT.mjs.map +1 -0
- package/dist/chunk-YXLFOEZN.mjs +2 -0
- package/dist/chunk-YXLFOEZN.mjs.map +1 -0
- package/dist/chunk-ZAKA4TGK.cjs +2 -0
- package/dist/chunk-ZAKA4TGK.cjs.map +1 -0
- package/dist/chunk-ZQRACIGR.mjs +2 -0
- package/dist/chunk-ZQRACIGR.mjs.map +1 -0
- package/dist/contexts/exports.cjs +2 -0
- package/dist/contexts/exports.cjs.map +1 -0
- package/dist/contexts/{index.d.ts → exports.d.cts} +19 -28
- package/dist/contexts/{index.d.cts → exports.d.ts} +19 -28
- package/dist/contexts/exports.mjs +2 -0
- package/dist/contexts/exports.mjs.map +1 -0
- package/dist/contracts-CQIPk0Jc.d.cts +74 -0
- package/dist/contracts-CQIPk0Jc.d.ts +74 -0
- package/dist/{defaultFlags-V-tJs2K8.d.cts → defaultFlags-d0kPbT0i.d.cts} +1 -1
- package/dist/{defaultFlags-V-tJs2K8.d.ts → defaultFlags-d0kPbT0i.d.ts} +1 -1
- package/dist/dex-C_BB0b0O.d.cts +37 -0
- package/dist/dex-C_BB0b0O.d.ts +37 -0
- package/dist/enum/exports.cjs +2 -0
- package/dist/enum/exports.cjs.map +1 -0
- package/dist/enum/exports.d.cts +24 -0
- package/dist/enum/exports.d.ts +24 -0
- package/dist/enum/exports.mjs +2 -0
- package/dist/enum/exports.mjs.map +1 -0
- package/dist/errors/exports.cjs +2 -0
- package/dist/errors/exports.cjs.map +1 -0
- package/dist/errors/exports.d.cts +385 -0
- package/dist/errors/exports.d.ts +385 -0
- package/dist/errors/exports.mjs +2 -0
- package/dist/{getValidatorQueuedOperatorAddress-9xY2RUGe.d.cts → getValidatorQueuedOperatorAddress-BX35p2Lv.d.ts} +125 -15
- package/dist/{getValidatorQueuedOperatorAddress-Ne2zoiiV.d.ts → getValidatorQueuedOperatorAddress-It0GsdvQ.d.cts} +125 -15
- package/dist/global.d-Ba-NIojH.d.cts +474 -0
- package/dist/global.d-By70bEv2.d.ts +474 -0
- package/dist/honey-CYm0RWf4.d.cts +14 -0
- package/dist/honey-CYm0RWf4.d.ts +14 -0
- package/dist/hooks/exports.cjs +4 -0
- package/dist/hooks/exports.cjs.map +1 -0
- package/dist/hooks/{index.d.cts → exports.d.cts} +223 -173
- package/dist/hooks/{index.d.ts → exports.d.ts} +223 -173
- package/dist/hooks/exports.mjs +4 -0
- package/dist/hooks/exports.mjs.map +1 -0
- package/dist/{BexStatusProvider-nS3NcdxI.d.cts → transactionStore-BvStaXf3.d.ts} +41 -1
- package/dist/{BexStatusProvider-nS3NcdxI.d.ts → transactionStore-CQrGYSY2.d.cts} +41 -1
- package/dist/{txnEnum-BQKDfaeH.d.cts → txnEnum-BYNbCxla.d.cts} +1 -0
- package/dist/{txnEnum-BQKDfaeH.d.ts → txnEnum-BYNbCxla.d.ts} +1 -0
- package/dist/types/exports.cjs +1 -0
- package/dist/types/exports.cjs.map +1 -0
- package/dist/types/exports.d.cts +58 -0
- package/dist/types/exports.d.ts +58 -0
- package/dist/types/exports.mjs +1 -0
- package/dist/{useHoneySwapState-C-9BV4VB.d.cts → useHoneySwapState-B-vmIP1b.d.cts} +1 -1
- package/dist/{useHoneySwapState-CUY5Sm1b.d.ts → useHoneySwapState-D1DKG_Of.d.ts} +1 -1
- package/dist/utils/exports.cjs +2 -0
- package/dist/utils/exports.cjs.map +1 -0
- package/dist/utils/{index.d.cts → exports.d.cts} +83 -20
- package/dist/utils/{index.d.ts → exports.d.ts} +83 -20
- package/dist/utils/exports.mjs +2 -0
- package/dist/utils/exports.mjs.map +1 -0
- package/package.json +16 -17
- package/src/abi/{index.ts → exports.ts} +3 -0
- package/src/abi/pol/LSTStakerVault.ts +2032 -0
- package/src/abi/utils/openChainErrors.ts +71 -30
- package/src/abi/utils/thirdwebMinimalAccount.ts +616 -0
- package/src/actions/clients/BeraApolloClient.ts +8 -6
- package/src/actions/dex/__tests__/aggregators.unit.test.ts +2 -5
- package/src/actions/dex/aggregators/base.ts +74 -16
- package/src/actions/dex/aggregators/bex.ts +54 -74
- package/src/actions/dex/aggregators/bgt.ts +31 -8
- package/src/actions/dex/aggregators/{enso.ts → enso/enso.ts} +18 -14
- package/src/actions/dex/aggregators/enso/ensoErc4626.debug.test.ts +37 -0
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +176 -0
- package/src/actions/dex/aggregators/erc4626.ts +122 -0
- package/src/actions/dex/aggregators/fly.ts +59 -53
- package/src/actions/dex/aggregators/haiku.ts +52 -54
- package/src/actions/dex/aggregators/honey.ts +54 -45
- package/src/actions/dex/aggregators/kyberswap.ts +41 -39
- package/src/actions/dex/aggregators/oogabooga.ts +47 -46
- package/src/actions/dex/aggregators/openOcean.ts +51 -46
- package/src/actions/dex/aggregators/wbera.ts +54 -42
- package/src/actions/dex/b-sdk.ts +5 -2
- package/src/actions/dex/getIsTokenExploited.ts +2 -2
- package/src/actions/enso/{zap.ts → getEnsoSwapBundle.ts} +4 -5
- package/src/actions/enso/getEnsoUserTokensWithBalances.debug.test.ts +73 -0
- package/src/actions/enso/{getEnsoUserToken.ts → getEnsoUserTokensWithBalances.ts} +42 -30
- package/src/actions/enso/util.ts +1 -1
- package/src/actions/{index.ts → exports.ts} +5 -0
- package/src/actions/governance/__tests__/checkProposalField.unit.test.ts +1 -1
- package/src/actions/governance/__tests__/getQuorum.integration.test.ts +1 -1
- package/src/actions/governance/checkProposalField.ts +1 -1
- package/src/actions/governance/computeActualStatus.ts +1 -1
- package/src/actions/governance/getBodyErrors.ts +1 -1
- package/src/actions/governance/getDecodedFunctionData.ts +1 -4
- package/src/actions/governance/getProposalDetails.ts +2 -2
- package/src/actions/governance/getProposalFromTx.ts +1 -2
- package/src/actions/governance/getProposalParams.ts +7 -8
- package/src/actions/governance/getQuorum.ts +1 -2
- package/src/actions/honey/getCollateralWeights.ts +1 -1
- package/src/actions/honey/getHoneyCollaterals.ts +1 -0
- package/src/actions/honey/getHoneyVaultsBalance.ts +51 -55
- package/src/actions/honey/getSwapPayload.ts +37 -35
- package/src/actions/honey/tests/pyth.integration.test.ts +0 -1
- package/src/actions/pol/__tests__/getAllValidators.integration.test.ts +1 -1
- package/src/actions/pol/getEarnedStakedBeraVault.ts +31 -0
- package/src/actions/pol/getGlobalData.ts +14 -13
- package/src/actions/pol/getLSTStakeConfig.ts +67 -0
- package/src/actions/pol/getMarkets.ts +1 -1
- package/src/actions/pol/getRewardProofsByValidator.ts +1 -1
- package/src/actions/pol/getRewardVaultIncentives.ts +3 -5
- package/src/actions/pol/getRewardVaults.ts +2 -3
- package/src/actions/pol/getSWBeraVaultMetadata.ts +7 -5
- package/src/actions/pol/getSWBeraWithdrawal.ts +41 -27
- package/src/actions/pol/getStakeWithdrawalCooldown.ts +5 -7
- package/src/actions/pol/getStakingDailyAssets.ts +21 -0
- package/src/actions/pol/getStakingTokenInformation.ts +3 -4
- package/src/actions/pol/getTotalStakedAmount.ts +47 -0
- package/src/actions/pol/getUserClaimableIncentives.ts +1 -1
- package/src/actions/pol/getUserVaults.ts +8 -6
- package/src/actions/pol/getUserVaultsBalance.ts +4 -16
- package/src/actions/prices/getTokenCurrentPrices.ts +8 -3
- package/src/actions/tokens/getAllowances.ts +68 -41
- package/src/actions/tokens/getTokenInformation.ts +4 -1
- package/src/actions/tokens/getTokens.ts +1 -1
- package/src/actions/tokens/getUnderlyingToken.ts +53 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +53 -14
- package/src/actions/tokens/getWalletBalances.ts +69 -43
- package/src/actions/transactions/beraWriteContract.integration.test.ts +18 -6
- package/src/actions/transactions/beraWriteContract.ts +3 -3
- package/src/actions/validators/getUserActiveValidators.ts +2 -3
- package/src/actions/validators/getUserBoostsOnValidator.ts +2 -3
- package/src/contexts/BeraFlags/defaultFlags.ts +4 -0
- package/src/contexts/SwrFallback.tsx +13 -3
- package/src/contexts/TokensProvider.tsx +35 -8
- package/src/{hooks/transactions → contexts}/TransactionStoreContext.tsx +32 -4
- package/src/contexts/block-time-provider.tsx +1 -1
- package/src/contexts/{index.ts → exports.ts} +1 -1
- package/src/data/contracts.ts +16 -1
- package/src/enum/contracts.ts +13 -0
- package/src/enum/dex.ts +29 -0
- package/src/enum/{index.ts → exports.ts} +3 -0
- package/src/enum/governance.ts +61 -0
- package/src/enum/honey.ts +12 -0
- package/src/enum/txnEnum.ts +1 -0
- package/src/errors/BeraError.ts +50 -11
- package/src/errors/BeraMonitoring.ts +66 -0
- package/src/errors/BeraTracing.ts +79 -0
- package/src/errors/BeraTracing.unit.test.ts +198 -0
- package/src/errors/RequestError.ts +2 -2
- package/src/errors/assert.ts +4 -2
- package/src/errors/assert.unit.test.ts +6 -2
- package/src/errors/errorMap.ts +16 -6
- package/src/errors/{index.ts → exports.ts} +7 -0
- package/src/errors/getErrorMessage.ts +22 -3
- package/src/errors/getRevertReason.integration.test.ts +17 -5
- package/src/errors/getRevertReason.ts +41 -2
- package/src/errors/initBeraError.ts +52 -7
- package/src/errors/parseViemError.ts +114 -27
- package/src/errors/severity.ts +12 -0
- package/src/hooks/bend/useGetConvertToAssets.ts +3 -2
- package/src/hooks/dex/useAggregatorsQuotes.ts +126 -365
- package/src/hooks/dex/useAllUserPools.ts +1 -1
- package/src/hooks/dex/useApiPool.ts +1 -1
- package/src/hooks/dex/useCreatePool.ts +6 -5
- package/src/hooks/dex/useExploitedTokens.ts +1 -1
- package/src/hooks/dex/useLiquidityMismatch.ts +2 -5
- package/src/hooks/dex/useLpPosition.ts +21 -20
- package/src/hooks/dex/useMultipleTokenApprovalsWithSlippage.ts +40 -29
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +1 -1
- package/src/hooks/dex/usePoolEvents.ts +1 -1
- package/src/hooks/dex/usePools.ts +1 -1
- package/src/hooks/dex/usePriceImpact.ts +40 -0
- package/src/hooks/dex/useSingleAggregatorQuote.ts +350 -0
- package/src/hooks/enso/useBendZapSupply.ts +216 -0
- package/src/hooks/enso/useEnsoSwapBundle.ts +107 -0
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +43 -0
- package/src/hooks/enso/useZapStakeBera.ts +113 -0
- package/src/hooks/{index.ts → exports.ts} +18 -7
- package/src/hooks/governance/useCreateProposal.ts +8 -8
- package/src/hooks/governance/usePollAllProposals.ts +1 -1
- package/src/hooks/governance/usePollProposal.ts +1 -1
- package/src/hooks/governance/usePollProposalThreshold.ts +1 -1
- package/src/hooks/governance/usePollUserDelegates.ts +1 -1
- package/src/hooks/governance/useProposalState.ts +2 -2
- package/src/hooks/honey/useCappedGlobally.ts +2 -1
- package/src/hooks/honey/useCappedRelatively.ts +1 -1
- package/src/hooks/honey/useCollateralWeights.ts +2 -1
- package/src/hooks/honey/useHoneyAlerts.ts +11 -11
- package/src/hooks/honey/useHoneyBalances.ts +7 -3
- package/src/hooks/honey/useHoneyGlobalData.ts +2 -1
- package/src/hooks/honey/useHoneySwapState.ts +2 -1
- package/src/hooks/honey/useHoneyVaultsBalance.ts +1 -1
- package/src/hooks/honey/useIsBadCollateralAsset.ts +2 -1
- package/src/hooks/honey/useIsBasketModeEnabled.ts +1 -1
- package/src/hooks/honey/usePythLatestPrices.ts +1 -1
- package/src/hooks/pol/useOnChainRewardVault.ts +3 -2
- package/src/hooks/pol/usePollGlobalData.ts +1 -1
- package/src/hooks/pol/usePollMarkets.ts +1 -1
- package/src/hooks/pol/useQueuedBeraUnlock.ts +17 -15
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +6 -3
- package/src/hooks/pol/useRewardVault.ts +1 -1
- package/src/hooks/pol/useRewardVaults.ts +1 -1
- package/src/hooks/pol/useSWBeraVaultMetadata.ts +35 -0
- package/src/hooks/pol/useStakedAPR.ts +38 -0
- package/src/hooks/pol/useStakedData.ts +117 -0
- package/src/hooks/pol/useStakedSnapshots.ts +52 -0
- package/src/hooks/pol/useTotalStakedAmount.ts +30 -0
- package/src/hooks/pol/useUserVaultInfo.ts +1 -1
- package/src/hooks/pol/useVaultValidators.ts +1 -1
- package/src/hooks/tokens/useMultipleTokenInformation.ts +15 -6
- package/src/hooks/tokens/usePollAllowances.ts +15 -19
- package/src/hooks/tokens/usePollBalance.ts +8 -4
- package/src/hooks/tokens/usePollWalletBalances.ts +14 -11
- package/src/hooks/tokens/useStakingTokenInformation.ts +2 -1
- package/src/hooks/tokens/useTokenCurrentPrice.ts +4 -2
- package/src/hooks/tokens/useTokenCurrentPrices.ts +92 -13
- package/src/hooks/tokens/useTokenInformation.ts +11 -6
- package/src/hooks/tokens/useTokenPrice.ts +21 -0
- package/src/hooks/tokens/useTokenPrices.ts +133 -0
- package/src/hooks/tokens/useTokens.ts +1 -0
- package/src/hooks/tokens/useUnderlyingAsset.ts +23 -0
- package/src/hooks/transactions/transactionStore.ts +86 -65
- package/src/hooks/transactions/transactionStore.unit.test.ts +54 -1
- package/src/hooks/transactions/useAddRecentTransaction.ts +1 -1
- package/src/hooks/transactions/useRecentTransactions.ts +1 -1
- package/src/hooks/transactions/useSetTransactionStatus.ts +31 -0
- package/src/hooks/useContractWrite/useBeraContractWrite.ts +2 -1
- package/src/hooks/validators/useAllValidators.ts +1 -1
- package/src/hooks/validators/useApiValidator.ts +1 -1
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -1
- package/src/hooks/validators/useManagedValidatorByAccount.ts +1 -1
- package/src/hooks/validators/useManagedValidatorRole.ts +1 -1
- package/src/hooks/validators/useOnChainValidator.ts +1 -1
- package/src/hooks/validators/useStakingPoolBatch.ts +1 -1
- package/src/hooks/validators/useUserActiveValidators.ts +1 -1
- package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -1
- package/src/hooks/validators/useUserClaimableIncentives.ts +8 -8
- package/src/hooks/validators/useValidator.ts +1 -1
- package/src/hooks/validators/useValidatorAnalytics.ts +1 -1
- package/src/hooks/validators/useValidatorCommission.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedCommission.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +1 -1
- package/src/hooks/validators/useValidatorRewardAllocation.ts +1 -1
- package/src/types/{dex.ts → dex.d.ts} +96 -67
- package/src/types/{enso.ts → enso.d.ts} +1 -1
- package/src/types/exports.ts +8 -0
- package/src/types/{global.ts → global.d.ts} +1 -30
- package/src/types/{governance.ts → governance.d.ts} +2 -64
- package/src/types/{honeySwap.ts → honeySwap.d.ts} +1 -13
- package/src/types/{pol.ts → pol.d.ts} +12 -1
- package/src/types/staking.d.ts +22 -0
- package/src/utils/createEmitter.ts +122 -0
- package/src/utils/createEmitter.unit.test.ts +149 -0
- package/src/utils/{index.ts → exports.ts} +3 -2
- package/src/utils/filter.ts +34 -0
- package/src/utils/formatNumber.ts +1 -1
- package/src/utils/formatNumber.unit.test.ts +2 -1
- package/src/utils/formatTokenList.ts +4 -10
- package/src/utils/getHoneySwapMessage.test.ts +1 -2
- package/src/utils/getServerSideClient.ts +4 -5
- package/src/utils/isDifferenceExceedingThreshold.ts +1 -1
- package/src/utils/layerZeroScan.ts +122 -0
- package/src/utils/math.ts +1 -1
- package/src/utils/parseWhiskToken.ts +15 -0
- package/src/utils/poolNamings.ts +1 -1
- package/src/utils/tokens.ts +23 -7
- package/dist/HoneyConfigProvider-6PXZJMSU.d.cts +0 -562
- package/dist/HoneyConfigProvider-CwDFrt02.d.ts +0 -562
- package/dist/abi/index.cjs +0 -2
- package/dist/abi/index.cjs.map +0 -1
- package/dist/abi/index.mjs +0 -2
- package/dist/actions/index.cjs +0 -2
- package/dist/actions/index.cjs.map +0 -1
- package/dist/actions/index.mjs +0 -2
- package/dist/aggregatorsRouter-Cny4B_MB.d.cts +0 -593
- package/dist/aggregatorsRouter-Cny4B_MB.d.ts +0 -593
- package/dist/chunk-22MQVFHP.cjs +0 -2
- package/dist/chunk-22MQVFHP.cjs.map +0 -1
- package/dist/chunk-3TKSVFZ3.mjs +0 -2
- package/dist/chunk-3TKSVFZ3.mjs.map +0 -1
- package/dist/chunk-6VF3RF53.cjs +0 -3
- package/dist/chunk-6VF3RF53.cjs.map +0 -1
- package/dist/chunk-6W22TFYA.mjs +0 -2
- package/dist/chunk-6W22TFYA.mjs.map +0 -1
- package/dist/chunk-AMRJ4B36.mjs +0 -2
- package/dist/chunk-AMRJ4B36.mjs.map +0 -1
- package/dist/chunk-DS2ZDVKU.mjs +0 -2
- package/dist/chunk-DS2ZDVKU.mjs.map +0 -1
- package/dist/chunk-ED43NYSE.cjs +0 -2
- package/dist/chunk-ED43NYSE.cjs.map +0 -1
- package/dist/chunk-EU4WFADK.cjs +0 -2
- package/dist/chunk-EU4WFADK.cjs.map +0 -1
- package/dist/chunk-HCTFDGXL.mjs +0 -2
- package/dist/chunk-HCTFDGXL.mjs.map +0 -1
- package/dist/chunk-IOSYBHKU.mjs +0 -2
- package/dist/chunk-IOSYBHKU.mjs.map +0 -1
- package/dist/chunk-JMKLDDKY.cjs +0 -2
- package/dist/chunk-JMKLDDKY.cjs.map +0 -1
- package/dist/chunk-KMKUXP2S.mjs +0 -3
- package/dist/chunk-KMKUXP2S.mjs.map +0 -1
- package/dist/chunk-OJXJ6CZ4.mjs +0 -4
- package/dist/chunk-OJXJ6CZ4.mjs.map +0 -1
- package/dist/chunk-PHIOKO3A.mjs +0 -2
- package/dist/chunk-PHIOKO3A.mjs.map +0 -1
- package/dist/chunk-QCK474XD.cjs +0 -2
- package/dist/chunk-QCK474XD.cjs.map +0 -1
- package/dist/chunk-REDXXUK7.cjs +0 -2
- package/dist/chunk-REDXXUK7.cjs.map +0 -1
- package/dist/chunk-S74ZMG2G.cjs +0 -2
- package/dist/chunk-S74ZMG2G.cjs.map +0 -1
- package/dist/chunk-TOAXF4YW.cjs +0 -2
- package/dist/chunk-TOAXF4YW.cjs.map +0 -1
- package/dist/chunk-UZ5CB33M.cjs +0 -2
- package/dist/chunk-UZ5CB33M.cjs.map +0 -1
- package/dist/chunk-VYWYJR63.mjs +0 -2
- package/dist/chunk-VYWYJR63.mjs.map +0 -1
- package/dist/chunk-XFPTQMAK.cjs +0 -4
- package/dist/chunk-XFPTQMAK.cjs.map +0 -1
- package/dist/chunk-YK4NINF5.mjs +0 -2
- package/dist/chunk-YK4NINF5.mjs.map +0 -1
- package/dist/contexts/index.cjs +0 -2
- package/dist/contexts/index.cjs.map +0 -1
- package/dist/contexts/index.mjs +0 -2
- package/dist/contexts/index.mjs.map +0 -1
- package/dist/enum/index.cjs +0 -2
- package/dist/enum/index.cjs.map +0 -1
- package/dist/enum/index.d.cts +0 -31
- package/dist/enum/index.d.ts +0 -31
- package/dist/enum/index.mjs +0 -2
- package/dist/enum/index.mjs.map +0 -1
- package/dist/errors/index.cjs +0 -2
- package/dist/errors/index.cjs.map +0 -1
- package/dist/errors/index.d.cts +0 -204
- package/dist/errors/index.d.ts +0 -204
- package/dist/errors/index.mjs +0 -2
- package/dist/errors/index.mjs.map +0 -1
- package/dist/hooks/index.cjs +0 -4
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.mjs +0 -4
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/staking-F9Nx9TKD.d.ts +0 -246
- package/dist/staking-f4BpYH7l.d.cts +0 -246
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.cts +0 -56
- package/dist/types/index.d.ts +0 -56
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +0 -1
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.mjs +0 -2
- package/dist/utils/index.mjs.map +0 -1
- package/src/actions/dex/getTransactionCount.ts +0 -29
- package/src/actions/enso/bend.ts +0 -143
- package/src/actions/enso/getEnsoUserToken.debug.test.ts +0 -57
- package/src/contexts/berajsProvider/context.tsx +0 -49
- package/src/contexts/berajsProvider/index.ts +0 -2
- package/src/contexts/berajsProvider/useBeraJs.ts +0 -18
- package/src/hooks/dex/usePollVaultIsPaused.ts +0 -30
- package/src/hooks/enso/useBendTransactionRequests.ts +0 -247
- package/src/hooks/enso/useEnsoZap.ts +0 -166
- package/src/hooks/enso/useZapTransactionRequests.ts +0 -81
- package/src/hooks/pol/useEarnedStakedBeraVault.ts +0 -59
- package/src/hooks/pol/useStakedBeraSnapshots.ts +0 -27
- package/src/hooks/validators/validatorRoleManager.ts +0 -0
- package/src/types/index.ts +0 -8
- package/src/types/staking.ts +0 -7
- package/src/utils/formatAggregatorsQuotes.ts +0 -57
- package/src/utils/formatAggregatorsQuotes.unit.test.ts +0 -191
- package/src/utils/sentryBeforeSend.ts +0 -52
- /package/dist/{abi/index.mjs.map → errors/exports.mjs.map} +0 -0
- /package/dist/{actions/index.mjs.map → types/exports.mjs.map} +0 -0
- /package/src/actions/dex/{__tests__ → aggregators}/haiku.integration.test.ts +0 -0
- /package/src/types/{bribe-boost.ts → bribe-boost.d.ts} +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createEmitter, type EmitterMixin } from "~/utils/createEmitter";
|
|
2
|
+
import type { BeraError } from "./BeraError";
|
|
3
|
+
import type { SeverityLevel } from "./severity";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Context passed alongside captured exceptions.
|
|
7
|
+
* Mirrors the subset of Sentry's CaptureContext that berajs actually uses.
|
|
8
|
+
*/
|
|
9
|
+
export interface CaptureContext {
|
|
10
|
+
level: SeverityLevel;
|
|
11
|
+
extra?: Record<string, unknown>;
|
|
12
|
+
tags?: Record<string, string | number | boolean | null | undefined>;
|
|
13
|
+
fingerprint?: string[];
|
|
14
|
+
data?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ErrorEvent {
|
|
18
|
+
exception: BeraError;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const _emitter = createEmitter<{ exception: (event: ErrorEvent) => void }>();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A generic error reporter for berajs.
|
|
26
|
+
*
|
|
27
|
+
* Instead of calling Sentry.captureException directly, berajs calls
|
|
28
|
+
* `BeraMonitoring.captureException()`. Consumer apps subscribe via `.on()` and
|
|
29
|
+
* forward events to their monitoring provider (Sentry, Datadog, etc.).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* // In berajs code:
|
|
34
|
+
* import { BeraMonitoring } from "~/errors/BeraMonitoring";
|
|
35
|
+
* BeraMonitoring.captureExceptionException(error);
|
|
36
|
+
*
|
|
37
|
+
* // In app instrumentation:
|
|
38
|
+
* import { BeraMonitoring } from "@berachain/berajs/errors";
|
|
39
|
+
* BeraMonitoring.on((event) => {
|
|
40
|
+
* if (event.type === "exception") {
|
|
41
|
+
* Sentry.captureException(event.exception);
|
|
42
|
+
* }
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export const BeraMonitoring: {
|
|
47
|
+
captureException: (exception: BeraError) => void;
|
|
48
|
+
} & EmitterMixin<{ exception: (event: ErrorEvent) => void }> = {
|
|
49
|
+
/**
|
|
50
|
+
* Capture an exception. Notifies all subscribers.
|
|
51
|
+
*/
|
|
52
|
+
captureException(exception: BeraError): void {
|
|
53
|
+
const event: ErrorEvent = {
|
|
54
|
+
exception,
|
|
55
|
+
timestamp: Date.now(),
|
|
56
|
+
};
|
|
57
|
+
_emitter.emit("exception", event);
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Subscribe to error events.
|
|
61
|
+
* @returns An unsubscribe function.
|
|
62
|
+
*/
|
|
63
|
+
on(...args) {
|
|
64
|
+
return _emitter.on(...args);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Unsubscribe } from "~/utils/createEmitter";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Span context passed to tracing handlers.
|
|
5
|
+
* Compatible with Sentry's StartSpanOptions (name, op, attributes).
|
|
6
|
+
*/
|
|
7
|
+
export type SpanContext = {
|
|
8
|
+
name: string;
|
|
9
|
+
op: string;
|
|
10
|
+
attributes: Record<string, string | number | boolean | undefined>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A function that wraps a callback in a tracing span.
|
|
15
|
+
* Compatible with Sentry.startSpan's signature.
|
|
16
|
+
*/
|
|
17
|
+
type StartSpanFn = <T>(
|
|
18
|
+
context: SpanContext,
|
|
19
|
+
callback: () => Promise<T>,
|
|
20
|
+
) => Promise<T>;
|
|
21
|
+
|
|
22
|
+
const _handlers: StartSpanFn[] = [];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A generic span-tracing module for berajs.
|
|
26
|
+
*
|
|
27
|
+
* Instead of calling Sentry.startSpan directly, berajs calls
|
|
28
|
+
* `BeraTracing.startSpan()`. Consumer apps subscribe via `.on("span", handler)`
|
|
29
|
+
* and forward spans to their tracing provider (Sentry, Datadog, etc.).
|
|
30
|
+
*
|
|
31
|
+
* Multiple handlers are supported and chain in registration order:
|
|
32
|
+
* the first registered handler is the outermost wrapper.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* // In berajs code:
|
|
37
|
+
* import { BeraTracing } from "~/errors/BeraTracing";
|
|
38
|
+
* const result = await BeraTracing.startSpan(
|
|
39
|
+
* { name: "GraphQL query", op: "graphql.query", attributes: {} },
|
|
40
|
+
* () => executeQuery(),
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* // In app instrumentation:
|
|
44
|
+
* import { BeraTracing } from "@berachain/berajs/errors";
|
|
45
|
+
* BeraTracing.addSpanHandler(Sentry.startSpan);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export const BeraTracing = {
|
|
49
|
+
/**
|
|
50
|
+
* Execute a callback, wrapping it in all registered span handlers.
|
|
51
|
+
*
|
|
52
|
+
* Handlers chain so each wraps the next. First registered = outermost wrapper.
|
|
53
|
+
* If no handlers are registered, the callback is executed directly.
|
|
54
|
+
*/
|
|
55
|
+
startSpan<T>(context: SpanContext, callback: () => Promise<T>): Promise<T> {
|
|
56
|
+
if (_handlers.length === 0) return callback();
|
|
57
|
+
|
|
58
|
+
// Chain: h1(ctx, () => h2(ctx, () => h3(ctx, () => callback())))
|
|
59
|
+
return _handlers.reduceRight<() => Promise<T>>(
|
|
60
|
+
(next, handler) => () => handler(context, next),
|
|
61
|
+
callback,
|
|
62
|
+
)();
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Register a span tracing handler.
|
|
67
|
+
*
|
|
68
|
+
* @param _event - Must be "span". Exists for API consistency with BeraMonitoring.
|
|
69
|
+
* @param handler - A StartSpanFn, e.g. Sentry.startSpan.
|
|
70
|
+
* @returns An unsubscribe function to remove the handler.
|
|
71
|
+
*/
|
|
72
|
+
addSpanHandler(handler: StartSpanFn): Unsubscribe {
|
|
73
|
+
_handlers.push(handler);
|
|
74
|
+
return () => {
|
|
75
|
+
const idx = _handlers.indexOf(handler);
|
|
76
|
+
if (idx !== -1) _handlers.splice(idx, 1);
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { BeraTracing } from "./BeraTracing.js";
|
|
4
|
+
|
|
5
|
+
describe("BeraTracing", () => {
|
|
6
|
+
describe("startSpan with no handlers", () => {
|
|
7
|
+
it("executes the callback directly", async () => {
|
|
8
|
+
const callback = vi.fn().mockResolvedValue("result");
|
|
9
|
+
const result = await BeraTracing.startSpan(
|
|
10
|
+
{ name: "test", op: "test.op", attributes: {} },
|
|
11
|
+
callback,
|
|
12
|
+
);
|
|
13
|
+
expect(result).toBe("result");
|
|
14
|
+
expect(callback).toHaveBeenCalledTimes(1);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("startSpan with a single handler", () => {
|
|
19
|
+
it("wraps the callback in the handler", async () => {
|
|
20
|
+
const order: string[] = [];
|
|
21
|
+
|
|
22
|
+
const handler = vi.fn(async (context: any, callback: any) => {
|
|
23
|
+
order.push("handler-start");
|
|
24
|
+
const result = await callback();
|
|
25
|
+
order.push("handler-end");
|
|
26
|
+
return result;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const unsub = BeraTracing.addSpanHandler(handler);
|
|
30
|
+
|
|
31
|
+
const result = await BeraTracing.startSpan(
|
|
32
|
+
{ name: "test", op: "test.op", attributes: { key: "value" } },
|
|
33
|
+
async () => {
|
|
34
|
+
order.push("callback");
|
|
35
|
+
return 42;
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
expect(result).toBe(42);
|
|
40
|
+
expect(order).toEqual(["handler-start", "callback", "handler-end"]);
|
|
41
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
42
|
+
expect(handler.mock.calls[0][0]).toEqual({
|
|
43
|
+
name: "test",
|
|
44
|
+
op: "test.op",
|
|
45
|
+
attributes: { key: "value" },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
unsub();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("startSpan with multiple handlers", () => {
|
|
53
|
+
it("chains handlers so first registered is outermost", async () => {
|
|
54
|
+
const order: string[] = [];
|
|
55
|
+
|
|
56
|
+
const handler1 = async (_ctx: any, cb: () => Promise<any>) => {
|
|
57
|
+
order.push("h1-start");
|
|
58
|
+
const r = await cb();
|
|
59
|
+
order.push("h1-end");
|
|
60
|
+
return r;
|
|
61
|
+
};
|
|
62
|
+
const handler2 = async (_ctx: any, cb: () => Promise<any>) => {
|
|
63
|
+
order.push("h2-start");
|
|
64
|
+
const r = await cb();
|
|
65
|
+
order.push("h2-end");
|
|
66
|
+
return r;
|
|
67
|
+
};
|
|
68
|
+
const handler3 = async (_ctx: any, cb: () => Promise<any>) => {
|
|
69
|
+
order.push("h3-start");
|
|
70
|
+
const r = await cb();
|
|
71
|
+
order.push("h3-end");
|
|
72
|
+
return r;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const unsub1 = BeraTracing.addSpanHandler(handler1);
|
|
76
|
+
const unsub2 = BeraTracing.addSpanHandler(handler2);
|
|
77
|
+
const unsub3 = BeraTracing.addSpanHandler(handler3);
|
|
78
|
+
|
|
79
|
+
await BeraTracing.startSpan(
|
|
80
|
+
{ name: "test", op: "test.op", attributes: {} },
|
|
81
|
+
async () => {
|
|
82
|
+
order.push("callback");
|
|
83
|
+
return "done";
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// h1 wraps h2 wraps h3 wraps callback
|
|
88
|
+
expect(order).toEqual([
|
|
89
|
+
"h1-start",
|
|
90
|
+
"h2-start",
|
|
91
|
+
"h3-start",
|
|
92
|
+
"callback",
|
|
93
|
+
"h3-end",
|
|
94
|
+
"h2-end",
|
|
95
|
+
"h1-end",
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
unsub1();
|
|
99
|
+
unsub2();
|
|
100
|
+
unsub3();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe("on() returns unsubscribe", () => {
|
|
105
|
+
it("removes the handler when unsubscribe is called", async () => {
|
|
106
|
+
const handler = vi.fn(async (_ctx: any, cb: any) => cb());
|
|
107
|
+
const unsub = BeraTracing.addSpanHandler(handler);
|
|
108
|
+
|
|
109
|
+
await BeraTracing.startSpan(
|
|
110
|
+
{ name: "test", op: "test.op", attributes: {} },
|
|
111
|
+
async () => "a",
|
|
112
|
+
);
|
|
113
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
114
|
+
|
|
115
|
+
unsub();
|
|
116
|
+
|
|
117
|
+
await BeraTracing.startSpan(
|
|
118
|
+
{ name: "test", op: "test.op", attributes: {} },
|
|
119
|
+
async () => "b",
|
|
120
|
+
);
|
|
121
|
+
// Handler should not have been called again
|
|
122
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("is idempotent (double-unsubscribe does not throw)", () => {
|
|
126
|
+
const handler = vi.fn(async (_ctx: any, cb: any) => cb());
|
|
127
|
+
const unsub = BeraTracing.addSpanHandler(handler);
|
|
128
|
+
|
|
129
|
+
unsub();
|
|
130
|
+
expect(() => unsub()).not.toThrow();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe("error propagation", () => {
|
|
135
|
+
it("propagates errors from the callback through handlers", async () => {
|
|
136
|
+
const handler = async (_ctx: any, cb: () => Promise<any>) => cb();
|
|
137
|
+
const unsub = BeraTracing.addSpanHandler(handler);
|
|
138
|
+
|
|
139
|
+
await expect(
|
|
140
|
+
BeraTracing.startSpan(
|
|
141
|
+
{ name: "test", op: "test.op", attributes: {} },
|
|
142
|
+
async () => {
|
|
143
|
+
throw new Error("callback error");
|
|
144
|
+
},
|
|
145
|
+
),
|
|
146
|
+
).rejects.toThrow("callback error");
|
|
147
|
+
|
|
148
|
+
unsub();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("propagates errors from a handler", async () => {
|
|
152
|
+
const handler = async () => {
|
|
153
|
+
throw new Error("handler error");
|
|
154
|
+
};
|
|
155
|
+
const unsub = BeraTracing.addSpanHandler(handler);
|
|
156
|
+
|
|
157
|
+
await expect(
|
|
158
|
+
BeraTracing.startSpan(
|
|
159
|
+
{ name: "test", op: "test.op", attributes: {} },
|
|
160
|
+
async () => "ok",
|
|
161
|
+
),
|
|
162
|
+
).rejects.toThrow("handler error");
|
|
163
|
+
|
|
164
|
+
unsub();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
describe("Sentry.startSpan compatibility", () => {
|
|
169
|
+
it("works with a handler that accepts (options, callback) like Sentry.startSpan", async () => {
|
|
170
|
+
// Sentry.startSpan signature: <T>(options, callback: (span) => T) => T
|
|
171
|
+
// When callback returns Promise<T>, the return is Promise<T>
|
|
172
|
+
const mockSentryStartSpan = <T>(
|
|
173
|
+
_options: { name: string },
|
|
174
|
+
callback: (span: unknown) => T,
|
|
175
|
+
): T => {
|
|
176
|
+
// Sentry passes a span object to the callback; our callbacks ignore it
|
|
177
|
+
return callback({ spanId: "mock-span" });
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const unsub = BeraTracing.addSpanHandler(
|
|
181
|
+
mockSentryStartSpan as typeof BeraTracing.startSpan,
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const result = await BeraTracing.startSpan(
|
|
185
|
+
{
|
|
186
|
+
name: "GraphQL TestQuery",
|
|
187
|
+
op: "BeraApolloClient.query",
|
|
188
|
+
attributes: {},
|
|
189
|
+
},
|
|
190
|
+
async () => ({ data: { value: 1 } }),
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
expect(result).toEqual({ data: { value: 1 } });
|
|
194
|
+
|
|
195
|
+
unsub();
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ErrorLike } from "@apollo/client";
|
|
2
2
|
|
|
3
|
-
import mainnet from "@berachain/config/mainnet";
|
|
3
|
+
import { mainnet } from "@berachain/config/mainnet";
|
|
4
4
|
|
|
5
5
|
import { BeraError, type IBeraErrorArgs } from "./BeraError";
|
|
6
6
|
import { errorMsgMap } from "./errorMap";
|
|
@@ -31,7 +31,7 @@ export class RequestError extends BeraError {
|
|
|
31
31
|
*/
|
|
32
32
|
private queryRichfulDomains = [
|
|
33
33
|
mainnet.bex.aggregatorsProxyUrl,
|
|
34
|
-
"https://api.
|
|
34
|
+
"https://api.fly.trade/aggregator/quote",
|
|
35
35
|
"https://open-api.openocean.finance/v4/bera/swap",
|
|
36
36
|
// vercel internal proxy
|
|
37
37
|
"/api/aggregators?aggregator",
|
package/src/errors/assert.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GetPublicClientReturnType } from "@wagmi/core";
|
|
1
2
|
import { type Address, isAddress, type PublicClient } from "viem";
|
|
2
3
|
|
|
3
4
|
import { InvalidArgumentError } from "./InvalidArgumentError";
|
|
@@ -83,7 +84,8 @@ export function assertPublicClient(
|
|
|
83
84
|
/**
|
|
84
85
|
* The value to assert.
|
|
85
86
|
*/
|
|
86
|
-
value:
|
|
87
|
+
value: // it's important to have both types here because it helps with typescript build performance
|
|
88
|
+
PublicClient | GetPublicClientReturnType | undefined,
|
|
87
89
|
/**
|
|
88
90
|
* The property name.
|
|
89
91
|
*/
|
|
@@ -101,7 +103,7 @@ export function assertAddress(
|
|
|
101
103
|
/**
|
|
102
104
|
* The value to assert.
|
|
103
105
|
*/
|
|
104
|
-
value: string | undefined,
|
|
106
|
+
value: string | undefined | null,
|
|
105
107
|
/**
|
|
106
108
|
* The property name.
|
|
107
109
|
*/
|
|
@@ -61,8 +61,12 @@ describe("assertAddress", () => {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it("throws InvalidArgumentError for non-string", () => {
|
|
64
|
-
expect(() => assertAddress(123, "addr")).toThrow(
|
|
65
|
-
|
|
64
|
+
expect(() => assertAddress(123 as unknown as string, "addr")).toThrow(
|
|
65
|
+
InvalidArgumentError,
|
|
66
|
+
);
|
|
67
|
+
expect(() => assertAddress({} as unknown as string, "addr")).toThrow(
|
|
68
|
+
InvalidArgumentError,
|
|
69
|
+
);
|
|
66
70
|
});
|
|
67
71
|
|
|
68
72
|
it("throws InvalidArgumentError for invalid address string", () => {
|
package/src/errors/errorMap.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface ErrorCategory {
|
|
|
17
17
|
[key: string]: ErrorType;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
interface ErrorMessages {
|
|
21
21
|
[key: string]: ErrorCategory | string;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -94,10 +94,10 @@ export const errorMsgMap = {
|
|
|
94
94
|
errorMSG:
|
|
95
95
|
"It seems an RPC error has occurred. Please try your request one more later.",
|
|
96
96
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
NOT_ENOUGH_GAS: {
|
|
98
|
+
keywords: ["insufficient funds for gas * price + value:"],
|
|
99
|
+
errorMSG: "Gas balance is insufficient to cover the transaction cost.",
|
|
100
|
+
},
|
|
101
101
|
HASH: {
|
|
102
102
|
keywords: ["hash"],
|
|
103
103
|
|
|
@@ -120,6 +120,16 @@ export const errorMsgMap = {
|
|
|
120
120
|
"Wallet seems to be on the wrong chain, please refresh the page and try again.",
|
|
121
121
|
},
|
|
122
122
|
},
|
|
123
|
+
EIP7702: {
|
|
124
|
+
SESSION_KEY_EXPIRED: {
|
|
125
|
+
reasons: ["SessionKeyExpired"],
|
|
126
|
+
errorMSG: "Session key has expired. Please create a new one.",
|
|
127
|
+
},
|
|
128
|
+
CALL_POLICY_VIOLATED: {
|
|
129
|
+
reasons: ["CallPolicyViolated"],
|
|
130
|
+
errorMSG: "Call policy violated. Please check your call policies.",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
123
133
|
HONEY: {
|
|
124
134
|
BLACKLISTED_WALLET: {
|
|
125
135
|
reasons: ["BlacklistedWallet", "0x265693b4"],
|
|
@@ -136,7 +146,7 @@ export const errorMsgMap = {
|
|
|
136
146
|
// NOTE: descriptions are generated by GPT where not available.
|
|
137
147
|
BEX: {
|
|
138
148
|
SLIPPAGE_EXCEEDED: {
|
|
139
|
-
reasons: ["SlippageExceeded"],
|
|
149
|
+
reasons: ["SlippageExceeded", "TooMuchSlippage"],
|
|
140
150
|
errorMSG:
|
|
141
151
|
"Price changed while executing the transaction and exceeded the allowed slippage.",
|
|
142
152
|
},
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
export * from "./assert";
|
|
2
2
|
export * from "./BeraError";
|
|
3
|
+
export {
|
|
4
|
+
BeraMonitoring,
|
|
5
|
+
type CaptureContext,
|
|
6
|
+
type ErrorEvent,
|
|
7
|
+
} from "./BeraMonitoring";
|
|
8
|
+
export { BeraTracing, type SpanContext } from "./BeraTracing";
|
|
3
9
|
export * from "./getErrorMessage";
|
|
4
10
|
export * from "./InvalidArgumentError";
|
|
5
11
|
export * from "./initBeraError";
|
|
6
12
|
export * from "./NotFoundError";
|
|
7
13
|
export * from "./RequestError";
|
|
14
|
+
export type { SeverityLevel } from "./severity";
|
|
8
15
|
export * from "./TransactionFailedError";
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { type ErrorCategory, errorMsgMap, GENERAL_ERROR } from "./errorMap";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a user-friendly displayMessage by matching `reason` and `message` against `errorMap.ts`.
|
|
5
|
+
*
|
|
6
|
+
* This is the bridge between the automatic reason detection pipeline (parseViemError) and
|
|
7
|
+
* the user-facing error messages. Called by the BeraError constructor.
|
|
8
|
+
*
|
|
9
|
+
* ## Matching priority:
|
|
10
|
+
* 1. **Exact reason match** (preferred): checks `errorType.reasons` for an exact string match.
|
|
11
|
+
* This is the most reliable path — contract revert reasons like "NotEnoughBalance" or "BAL#508"
|
|
12
|
+
* are matched deterministically.
|
|
13
|
+
* 2. **Keyword fallback**: checks `errorType.keywords` for substring matches in `message`.
|
|
14
|
+
* Use sparingly — keyword matching can cause false positives (e.g. "InsufficientBalance"
|
|
15
|
+
* keyword would also match "InsufficientBalanceToPayPythFee").
|
|
16
|
+
* 3. **GENERAL_ERROR fallback**: "Something went wrong. Please try again later."
|
|
17
|
+
*
|
|
18
|
+
* To ensure new contract errors get good displayMessages, add their reason to `errorMap.ts`.
|
|
19
|
+
* The reason is auto-detected by parseViemError — you only need to map it to a message here.
|
|
20
|
+
*/
|
|
3
21
|
export function getErrorMessage({
|
|
4
22
|
reason,
|
|
5
23
|
message,
|
|
@@ -7,16 +25,14 @@ export function getErrorMessage({
|
|
|
7
25
|
reason?: string | null;
|
|
8
26
|
message?: string;
|
|
9
27
|
}): string {
|
|
10
|
-
// Check against defined categories
|
|
11
28
|
for (const category in errorMsgMap) {
|
|
12
|
-
// Just for type safety
|
|
13
29
|
const categoryKey = category as keyof typeof errorMsgMap;
|
|
14
|
-
|
|
15
30
|
const errors = errorMsgMap[categoryKey] as ErrorCategory;
|
|
16
31
|
|
|
17
32
|
for (const type in errors) {
|
|
18
33
|
const errorType = errors[type];
|
|
19
34
|
|
|
35
|
+
// Priority 1: Exact reason match (deterministic, preferred for contract revert reasons)
|
|
20
36
|
if (reason) {
|
|
21
37
|
if (
|
|
22
38
|
errorType?.reasons?.some((r) => {
|
|
@@ -26,6 +42,8 @@ export function getErrorMessage({
|
|
|
26
42
|
return errorType.errorMSG;
|
|
27
43
|
}
|
|
28
44
|
}
|
|
45
|
+
|
|
46
|
+
// Priority 2: Keyword substring match on message (fallback, use carefully)
|
|
29
47
|
if (
|
|
30
48
|
errorType?.keywords?.some((keyword) => {
|
|
31
49
|
return message?.includes(keyword.toLowerCase().trim());
|
|
@@ -36,5 +54,6 @@ export function getErrorMessage({
|
|
|
36
54
|
}
|
|
37
55
|
}
|
|
38
56
|
|
|
57
|
+
// Priority 3: No match found — return generic fallback
|
|
39
58
|
return GENERAL_ERROR;
|
|
40
59
|
}
|
|
@@ -17,18 +17,21 @@ import { mnemonicToAccount } from "viem/accounts";
|
|
|
17
17
|
import { assert, describe, expect, it } from "vitest";
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
|
+
appConfig,
|
|
20
21
|
ChainId,
|
|
21
22
|
defaultChainId,
|
|
22
23
|
getRpcUrls,
|
|
23
24
|
} from "@berachain/config/internal";
|
|
24
25
|
|
|
25
|
-
import {
|
|
26
|
+
import { getConfig } from "@berachain/wagmi/config";
|
|
26
27
|
|
|
27
28
|
import { metaMorphoAbi } from "~/abi/bend/metaMorpho";
|
|
28
29
|
import { bgtAbi } from "~/abi/pol/bgt";
|
|
29
30
|
import { rewardVaultAbi } from "~/abi/pol/rewardVault";
|
|
30
31
|
import { beraWriteContract } from "~/actions/transactions/beraWriteContract";
|
|
32
|
+
import { ContractName } from "~/enum/contracts";
|
|
31
33
|
import { TransactionActionType } from "~/enum/txnEnum";
|
|
34
|
+
import type { IContractWrite } from "~/types/global";
|
|
32
35
|
import { getServerSidePublicClient } from "~/utils/getServerSideClient";
|
|
33
36
|
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
34
37
|
import { anvilMnemonic } from "~/utils/test-utils";
|
|
@@ -95,7 +98,6 @@ const expectedRevertReasons = [
|
|
|
95
98
|
describe.skipIf(defaultChainId !== ChainId.MAINNET)("getRevertReason", () => {
|
|
96
99
|
const publicClient = getServerSidePublicClient();
|
|
97
100
|
const { config } = parseBaseArgs({});
|
|
98
|
-
|
|
99
101
|
const errors = [
|
|
100
102
|
{
|
|
101
103
|
tx: "0x9c24d3fd3680411c0fada23ed5d1a11df86ea2f452eb9270bbe9cc701199511e",
|
|
@@ -407,6 +409,14 @@ describe("eip5972 transactions", () => {
|
|
|
407
409
|
account: anvilMockAccount,
|
|
408
410
|
chain: publicClient.chain!,
|
|
409
411
|
});
|
|
412
|
+
const beraWagmiConfig = getConfig({
|
|
413
|
+
transports: {
|
|
414
|
+
[publicClient.chain!.id]: http(getRpcUrls().publicJsonRpcUrl),
|
|
415
|
+
},
|
|
416
|
+
defaultChain: publicClient.chain!,
|
|
417
|
+
thirdweb: { clientId: appConfig.apiKeys.public.thirdweb },
|
|
418
|
+
});
|
|
419
|
+
const wagmiConfig = beraWagmiConfig.wagmi;
|
|
410
420
|
|
|
411
421
|
it.concurrent.each(expectedRevertReasons)(
|
|
412
422
|
"should return the expected revert reason on sendCalls for $functionName to be $revertReason",
|
|
@@ -420,16 +430,18 @@ describe("eip5972 transactions", () => {
|
|
|
420
430
|
calls: [
|
|
421
431
|
{
|
|
422
432
|
address: config.tokens.wbera,
|
|
433
|
+
contractName: ContractName.ERC20,
|
|
434
|
+
abi: erc20Abi,
|
|
423
435
|
functionName: "approve",
|
|
424
436
|
params: [zeroAddress, 0n],
|
|
425
|
-
|
|
426
|
-
},
|
|
437
|
+
} as NonNullable<IContractWrite["calls"]>[number],
|
|
427
438
|
{
|
|
439
|
+
contractName: ContractName.ERC20,
|
|
428
440
|
address: "0x47a9E3A4b5a26eEDD0E53BC468bae31c24c9B158",
|
|
429
441
|
abi: testErrorContractAbi,
|
|
430
442
|
functionName,
|
|
431
443
|
params: "args" in rest ? rest.args : undefined,
|
|
432
|
-
},
|
|
444
|
+
} as NonNullable<IContractWrite["calls"]>[number],
|
|
433
445
|
],
|
|
434
446
|
message: "test",
|
|
435
447
|
actionType: TransactionActionType.REDEEM_BGT,
|