@berachain/berajs 0.2.8-beta.10 → 0.2.8-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/{BeraError-_mQdkanr.d.cts → BeraError-7-A5JYy_.d.cts} +31 -2
  2. package/dist/{BeraError-_mQdkanr.d.ts → BeraError-7-A5JYy_.d.ts} +31 -2
  3. package/dist/{RequestError-DSUzJ1Iy.d.cts → RequestError-02juqN-5.d.cts} +1 -1
  4. package/dist/{RequestError-BRIiJgHk.d.ts → RequestError-DBOIV65x.d.ts} +1 -1
  5. package/dist/abi/exports.cjs.map +1 -1
  6. package/dist/abi/exports.mjs +1 -1
  7. package/dist/actions/exports.cjs +1 -1
  8. package/dist/actions/exports.cjs.map +1 -1
  9. package/dist/actions/exports.d.cts +2 -2
  10. package/dist/actions/exports.d.ts +2 -2
  11. package/dist/actions/exports.mjs +1 -1
  12. package/dist/actions/governance/exports.cjs +1 -1
  13. package/dist/actions/governance/exports.cjs.map +1 -1
  14. package/dist/actions/governance/exports.mjs +1 -1
  15. package/dist/chunk-2A347ZVN.mjs +2 -0
  16. package/dist/{chunk-NXXMW2O7.mjs.map → chunk-2A347ZVN.mjs.map} +1 -1
  17. package/dist/{chunk-WLJHFHKF.mjs → chunk-2VO2D4QO.mjs} +2 -2
  18. package/dist/chunk-5FVW5XU3.mjs +2 -0
  19. package/dist/chunk-5FVW5XU3.mjs.map +1 -0
  20. package/dist/{chunk-GXV2JA36.mjs → chunk-5SIQ7BKT.mjs} +2 -2
  21. package/dist/chunk-5SIQ7BKT.mjs.map +1 -0
  22. package/dist/{chunk-ENT2OSXT.mjs → chunk-5XOEJ6XX.mjs} +2 -2
  23. package/dist/{chunk-ZW2N63FI.mjs → chunk-A5BNPBXN.mjs} +2 -2
  24. package/dist/{chunk-4TALWNXE.cjs → chunk-COSP3YIF.cjs} +2 -2
  25. package/dist/chunk-COSP3YIF.cjs.map +1 -0
  26. package/dist/chunk-D6L7LTA2.cjs.map +1 -1
  27. package/dist/{chunk-JXM5S4IU.mjs → chunk-DA7GK43B.mjs} +2 -2
  28. package/dist/chunk-DDEQFR3M.cjs.map +1 -1
  29. package/dist/{chunk-6JJIZCVY.cjs → chunk-DKZGCMH4.cjs} +2 -2
  30. package/dist/chunk-DKZGCMH4.cjs.map +1 -0
  31. package/dist/{chunk-Y2FETC6T.cjs → chunk-F4V5B6F7.cjs} +2 -2
  32. package/dist/chunk-F4V5B6F7.cjs.map +1 -0
  33. package/dist/{chunk-QVIAMSZ6.cjs → chunk-FDEUAXET.cjs} +2 -2
  34. package/dist/chunk-FDEUAXET.cjs.map +1 -0
  35. package/dist/{chunk-33XNWMPP.cjs → chunk-FQSOUEIJ.cjs} +2 -2
  36. package/dist/chunk-FQSOUEIJ.cjs.map +1 -0
  37. package/dist/{chunk-XZC34BHM.cjs → chunk-GEIY554A.cjs} +2 -2
  38. package/dist/chunk-GEIY554A.cjs.map +1 -0
  39. package/dist/{chunk-KUQEX7H3.mjs → chunk-JHUVLM54.mjs} +2 -2
  40. package/dist/{chunk-RCWM55DE.cjs → chunk-JZL5JPDJ.cjs} +2 -2
  41. package/dist/chunk-JZL5JPDJ.cjs.map +1 -0
  42. package/dist/{chunk-H6ZO4SLB.mjs → chunk-LUNZGZWN.mjs} +2 -2
  43. package/dist/{chunk-RJN36GBU.mjs → chunk-OCAMR6XC.mjs} +2 -2
  44. package/dist/chunk-OIYXOKTT.cjs.map +1 -1
  45. package/dist/chunk-OUD27MU7.cjs.map +1 -1
  46. package/dist/{chunk-JIPSTWKO.mjs → chunk-OYF32BQQ.mjs} +2 -2
  47. package/dist/{chunk-54BTOQE3.cjs → chunk-PFUVKW6F.cjs} +2 -2
  48. package/dist/chunk-PFUVKW6F.cjs.map +1 -0
  49. package/dist/{chunk-JSTCUTXP.cjs → chunk-QHCLZTCK.cjs} +2 -2
  50. package/dist/chunk-QHCLZTCK.cjs.map +1 -0
  51. package/dist/chunk-RWOICHRW.cjs.map +1 -1
  52. package/dist/{chunk-CHFETMC6.cjs → chunk-S2TNHMSV.cjs} +3 -3
  53. package/dist/chunk-S2TNHMSV.cjs.map +1 -0
  54. package/dist/chunk-S4CDSVLK.cjs.map +1 -1
  55. package/dist/{chunk-5QAFKFM5.mjs → chunk-TU63NRNL.mjs} +2 -2
  56. package/dist/{chunk-REWME3FY.cjs → chunk-W4JE2NIN.cjs} +2 -2
  57. package/dist/chunk-W4JE2NIN.cjs.map +1 -0
  58. package/dist/chunk-WRFDB3QJ.cjs.map +1 -1
  59. package/dist/chunk-XB2SEO4Y.cjs +2 -0
  60. package/dist/chunk-XB2SEO4Y.cjs.map +1 -0
  61. package/dist/chunk-XCVDZUEF.mjs +2 -0
  62. package/dist/{chunk-K5L2B4DU.mjs.map → chunk-XCVDZUEF.mjs.map} +1 -1
  63. package/dist/chunk-XNJLSA6P.cjs.map +1 -1
  64. package/dist/chunk-YYUSCGVI.cjs +2 -0
  65. package/dist/chunk-YYUSCGVI.cjs.map +1 -0
  66. package/dist/contexts/exports.cjs +1 -1
  67. package/dist/contexts/exports.cjs.map +1 -1
  68. package/dist/contexts/exports.mjs +1 -1
  69. package/dist/enum/exports.cjs.map +1 -1
  70. package/dist/enum/governance/exports.cjs.map +1 -1
  71. package/dist/errors/exports.cjs +1 -1
  72. package/dist/errors/exports.cjs.map +1 -1
  73. package/dist/errors/exports.d.cts +4 -3
  74. package/dist/errors/exports.d.ts +4 -3
  75. package/dist/errors/exports.mjs +1 -1
  76. package/dist/{global.d-D8byjWYx.d.ts → global.d-C4FnE4cz.d.ts} +2 -2
  77. package/dist/{global.d-B2WavzCY.d.cts → global.d-CicOIudf.d.cts} +2 -2
  78. package/dist/hooks/exports.cjs +2 -2
  79. package/dist/hooks/exports.cjs.map +1 -1
  80. package/dist/hooks/exports.d.cts +3 -3
  81. package/dist/hooks/exports.d.ts +3 -3
  82. package/dist/hooks/exports.mjs +2 -2
  83. package/dist/hooks/governance/exports.cjs +1 -1
  84. package/dist/hooks/governance/exports.cjs.map +1 -1
  85. package/dist/hooks/governance/exports.d.cts +2 -2
  86. package/dist/hooks/governance/exports.d.ts +2 -2
  87. package/dist/hooks/governance/exports.mjs +1 -1
  88. package/dist/types/exports.cjs.map +1 -1
  89. package/dist/types/exports.d.cts +2 -2
  90. package/dist/types/exports.d.ts +2 -2
  91. package/dist/types/governance/exports.cjs.map +1 -1
  92. package/dist/utils/exports.cjs +1 -1
  93. package/dist/utils/exports.cjs.map +1 -1
  94. package/dist/utils/exports.d.cts +13 -4
  95. package/dist/utils/exports.d.ts +13 -4
  96. package/dist/utils/exports.mjs +1 -1
  97. package/dist/utils/exports.mjs.map +1 -1
  98. package/package.json +57 -19
  99. package/src/actions/__test/transports.ts +61 -0
  100. package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
  101. package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
  102. package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
  103. package/src/data/contracts.ts +5 -0
  104. package/src/errors/BeraError.ts +27 -0
  105. package/src/errors/BeraTracing.unit.test.ts +65 -0
  106. package/src/errors/RequestError.ts +12 -0
  107. package/src/errors/exports.ts +5 -0
  108. package/src/errors/getRevertReason.integration.test.ts +3 -3
  109. package/src/errors/spanStatus.ts +78 -0
  110. package/src/errors/spanStatus.unit.test.ts +62 -0
  111. package/src/utils/beraFetch.ts +9 -3
  112. package/src/utils/exports.ts +1 -0
  113. package/src/utils/getServerSideClient.ts +4 -2
  114. package/src/utils/sanitizeRpcUrl.ts +22 -0
  115. package/src/utils/tracedTransport.ts +35 -0
  116. package/dist/chunk-33XNWMPP.cjs.map +0 -1
  117. package/dist/chunk-4TALWNXE.cjs.map +0 -1
  118. package/dist/chunk-54BTOQE3.cjs.map +0 -1
  119. package/dist/chunk-6DIA6PXV.cjs +0 -2
  120. package/dist/chunk-6DIA6PXV.cjs.map +0 -1
  121. package/dist/chunk-6JJIZCVY.cjs.map +0 -1
  122. package/dist/chunk-BE6B4PQF.cjs +0 -2
  123. package/dist/chunk-BE6B4PQF.cjs.map +0 -1
  124. package/dist/chunk-CHFETMC6.cjs.map +0 -1
  125. package/dist/chunk-GXV2JA36.mjs.map +0 -1
  126. package/dist/chunk-JDDRTHFG.mjs +0 -2
  127. package/dist/chunk-JDDRTHFG.mjs.map +0 -1
  128. package/dist/chunk-JSTCUTXP.cjs.map +0 -1
  129. package/dist/chunk-K5L2B4DU.mjs +0 -2
  130. package/dist/chunk-NXXMW2O7.mjs +0 -2
  131. package/dist/chunk-QVIAMSZ6.cjs.map +0 -1
  132. package/dist/chunk-RCWM55DE.cjs.map +0 -1
  133. package/dist/chunk-REWME3FY.cjs.map +0 -1
  134. package/dist/chunk-XZC34BHM.cjs.map +0 -1
  135. package/dist/chunk-Y2FETC6T.cjs.map +0 -1
  136. /package/dist/{chunk-WLJHFHKF.mjs.map → chunk-2VO2D4QO.mjs.map} +0 -0
  137. /package/dist/{chunk-ENT2OSXT.mjs.map → chunk-5XOEJ6XX.mjs.map} +0 -0
  138. /package/dist/{chunk-ZW2N63FI.mjs.map → chunk-A5BNPBXN.mjs.map} +0 -0
  139. /package/dist/{chunk-JXM5S4IU.mjs.map → chunk-DA7GK43B.mjs.map} +0 -0
  140. /package/dist/{chunk-KUQEX7H3.mjs.map → chunk-JHUVLM54.mjs.map} +0 -0
  141. /package/dist/{chunk-H6ZO4SLB.mjs.map → chunk-LUNZGZWN.mjs.map} +0 -0
  142. /package/dist/{chunk-RJN36GBU.mjs.map → chunk-OCAMR6XC.mjs.map} +0 -0
  143. /package/dist/{chunk-JIPSTWKO.mjs.map → chunk-OYF32BQQ.mjs.map} +0 -0
  144. /package/dist/{chunk-5QAFKFM5.mjs.map → chunk-TU63NRNL.mjs.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/chunk-S2TNHMSV.cjs","../src/actions/governance/checkProposalField.ts","../src/actions/governance/parseProposalBody.ts","../src/actions/governance/getProposalVotes.ts"],"names":["checkProposalField","fieldOrType","value","required","baseUrl","components","valueBN","base","isAddress","isHex","errors","component","abiParam","name","v"],"mappings":"AAAA,y0BAAwC,wDAAyC,4BCA7B,SAyEpCA,CAAAA,CAAmB,CACjC,WAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CAAW,CAAA,CAAA,CACX,OAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CACF,CAAA,CAAwD,CAGtD,EAAA,CACE,CAH0B,CAAC,MAAA,CAAQ,QAAQ,CAAA,CAGtB,QAAA,CAASJ,CAAW,CAAA,EACzCE,CAAAA,EAAAA,CACwBD,CAAAA,EAAU,IAAA,EAAQA,CAAAA,GAAU,EAAA,CAAA,CAEpD,MAAA,UAAA,CAGF,EAAA,CAAID,CAAAA,CAAY,UAAA,CAAW,MAAM,CAAA,EAAKA,CAAAA,CAAY,UAAA,CAAW,KAAK,CAAA,CAAG,CACnE,EAAA,CAAI,OAAOC,CAAAA,EAAU,QAAA,CACnB,MAAA,gBAAA,CAGF,GAAI,CACF,IAAMI,CAAAA,CAAU,MAAA,CAAOJ,CAAK,CAAA,CAC5B,EAAA,CAAID,CAAAA,CAAY,UAAA,CAAW,MAAM,CAAA,EAC3BK,CAAAA,CAAU,EAAA,CACZ,MAAA,iBAGN,CAAA,UAAQ,CACN,MAAA,gBACF,CACA,OAAO,IACT,CAEA,MAAA,CAAQL,CAAAA,CAAa,CACnB,IAAK,QAAA,CACH,OAAIC,CAAAA,GAAU,KAAA,CAAA,EAAa,OAAOA,CAAAA,EAAU,QAAA,CAAA,gBAAA,CAGrC,IAAA,CAET,IAAK,MAAA,CACH,OAAI,OAAOA,CAAAA,EAAU,SAAA,CAAA,gBAAA,CAGd,IAAA,CAET,IAAK,OAAA,CACH,OAAI,OAAOA,CAAAA,EAAU,QAAA,EAAYA,CAAAA,CAAM,MAAA,GAAW,CAAA,CAAA,UAAA,CAG3C,IAAA,CAET,IAAK,aAAA,CACH,OAAI,OAAOA,CAAAA,EAAU,QAAA,EAAYA,CAAAA,CAAM,MAAA,GAAW,CAAA,CAAA,UAAA,CAG3C,IAAA,CAET,IAAK,WAAA,CAAa,CAChB,EAAA,CAAI,OAAOA,CAAAA,EAAU,QAAA,EAAYA,CAAAA,CAAM,MAAA,GAAW,CAAA,CAChD,MAAA,UAAA,CAGF,EAAA,CAAI,CAAC,GAAA,CAAI,QAAA,CAASA,CAAK,CAAA,CACrB,MAAA,iBAAA,CAGF,IAAMK,CAAAA,CAAO,IAAI,GAAA,CAAIH,CAAQ,CAAA,CAI7B,OAAKF,CAAAA,CAAM,UAAA,CAAWK,CAAAA,CAAK,QAAA,CAAS,CAAC,CAAA,CAI9B,IAAA,CAAA,gCACT,CAEA,IAAK,SAAA,CACH,OAAI,OAAOL,CAAAA,EAAU,QAAA,EAAY,CAACM,6BAAAA,CAAUN,CAAO,CAAE,MAAA,CAAQ,CAAA,CAAK,CAAC,CAAA,CAAA,iBAAA,CAI5D,IAAA,CAET,IAAK,KAAA,CACH,OAAI,OAAOA,CAAAA,EAAU,QAAA,EAAY,CAACO,yBAAAA,CAAMP,CAAO,CAAE,MAAA,CAAQ,CAAA,CAAK,CAAC,CAAA,CAAA,iBAAA,CAGxD,IAAA,CAET,IAAK,KAAA,CACH,EAAA,CAAI,OAAOA,CAAAA,EAAU,QAAA,CACnB,MAAA,aAAA,CAEF,GAAI,CACF,IAAA,CAAK,KAAA,CAAMA,CAAK,CAClB,CAAA,UAAQ,CACN,MAAA,aACF,CACA,OAAO,IAAA,CAET,IAAK,QAAA,CACH,OAAI,OAAOA,CAAAA,EAAU,QAAA,EAAY,CAACM,6BAAAA,CAAUN,CAAO,CAAE,MAAA,CAAQ,CAAA,CAAK,CAAC,CAAA,CAAA,iBAAA,CAG5D,IAAA,CAET,IAAK,OAAA,CACH,EAAA,CAAI,OAAOA,CAAAA,EAAU,QAAA,EAAY,KAAA,CAAM,OAAA,CAAQG,CAAU,CAAA,CAAG,CAC1D,IAAMK,CAAAA,CAAmD,CAAC,CAAA,CAE1D,GAAA,CAAA,IAAWC,EAAAA,GAAaN,CAAAA,CAAY,CAGlC,IAAMO,CAAAA,CAAWD,CAAAA,CAGXE,CAAAA,CAAOD,CAAAA,CAAS,IAAA,CAItBF,CAAAA,CAAOG,CAAI,CAAA,CAAIb,CAAAA,CAAmB,CAChC,WAAA,CAAaY,CAAAA,CAAS,IAAA,CACtB,KAAA,CAAQV,CAAAA,CAAkCW,CAAI,CAAA,CAC9C,UAAA,CAAYD,CAAAA,CAAS,UACvB,CAAC,CACH,CAEA,OAAI,MAAA,CAAO,MAAA,CAAOF,CAAM,CAAA,CAAE,KAAA,CAAOI,CAAAA,EAAMA,CAAAA,GAAM,IAAI,CAAA,CACxC,IAAA,CAGFJ,CACT,CAEA,OAAO,IAAA,CAET,IAAK,SAAA,CACH,EAAA,CAAI,KAAA,CAAM,OAAA,CAAQR,CAAK,CAAA,CAAG,CACxB,IAAMQ,CAAAA,CAASR,CAAAA,CAAM,GAAA,CAAKY,CAAAA,EACxBd,CAAAA,CAAmB,CACjB,WAAA,CAAa,OAAA,CACb,KAAA,CAAOc,CAAAA,CACP,UAAA,CAAAT,CACF,CAAC,CACH,CAAA,CAEA,OAAIK,CAAAA,CAAO,KAAA,CAAOI,CAAAA,EAAMA,CAAAA,GAAM,IAAI,CAAA,CACzB,IAAA,CAKFJ,CACT,CAEA,OAAO,IAAA,CAET,IAAK,SAAA,CACH,OAAIR,CAAAA,GAAU,KAAA,CAAA,EAAaA,CAAAA,GAAU,EAAA,CAC5B,IAAA,CAGP,OAAOA,CAAAA,EAAU,QAAA,EACjB,CAAC,GAAA,CAAI,QAAA,CAASA,CAAK,CAAA,EACnB,IAAI,GAAA,CAAIA,CAAK,CAAA,CAAE,QAAA,GAAa,QAAA,CAAA,uBAAA,CAIvB,IAAA,CAET,IAAK,KAAA,CACH,OAAIA,CAAAA,GAAU,KAAA,CAAA,EAAaA,CAAAA,GAAU,EAAA,CAC5B,IAAA,CAGP,OAAOA,CAAAA,EAAU,QAAA,EACjB,CAAC,GAAA,CAAI,QAAA,CAASA,CAAK,CAAA,EACnB,IAAI,GAAA,CAAIA,CAAK,CAAA,CAAE,QAAA,GAAa,QAAA,CAAA,eAAA,CAIvB,IAAA,CAET,OAAA,CACE,OAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,uBAAA,EAA0BD,CAAW,CAAA,CAAA;AC5Lb;AClD5C","file":"/Users/pong/coding/monobera/packages/berajs/dist/chunk-S2TNHMSV.cjs","sourcesContent":[null,"import { type AbiParameter, isAddress, isHex } from \"viem\";\n\nimport { ProposalErrorCodes } from \"../../enum/governance\";\n\ntype CheckProposalFieldResultMinimal = ProposalErrorCodes | null;\n\ntype CheckProposalFieldResult =\n | ProposalErrorCodes\n | null\n | CheckProposalFieldResultMinimal[]\n | Record<string, CheckProposalFieldResultMinimal>;\n\n/**\n * Internal implementation arg covering the full union of all valid fieldOrType\n * values. The public overloads below provide the narrowed return types.\n */\ninterface CheckProposalFieldImplArg {\n fieldOrType:\n | \"address\"\n | \"hex\"\n | \"abi\"\n | \"string\"\n | \"bool\"\n | `uint${string}`\n | `int${string}`\n | \"action\"\n | \"title\"\n | \"forumLink\"\n | \"description\"\n | \"logoURI\"\n | \"url\"\n | \"tuple[]\"\n | \"tuple\";\n value: unknown;\n required?: boolean;\n baseUrl?: string;\n components?: readonly (AbiParameter | readonly AbiParameter[])[];\n}\n\n/**\n * Validates a single proposal field or ABI-typed value.\n * Returns `null` if valid, or a `ProposalErrorCodes` value describing the problem.\n */\nexport function checkProposalField(arg: {\n fieldOrType:\n | \"address\"\n | \"hex\"\n | \"abi\"\n | \"string\"\n | \"bool\"\n | `uint${string}`\n | `int${string}`\n | \"action\"\n | \"title\"\n | \"forumLink\"\n | \"description\"\n | \"logoURI\"\n | \"url\";\n value: unknown;\n required?: boolean;\n baseUrl?: string;\n components?: readonly (AbiParameter | readonly AbiParameter[])[];\n}): CheckProposalFieldResultMinimal;\n/**\n * For tuple/tuple[] types, may return nested error structures.\n */\nexport function checkProposalField(arg: {\n fieldOrType: \"tuple[]\" | \"tuple\";\n value: unknown;\n required?: boolean;\n baseUrl?: string;\n components?: readonly (AbiParameter | readonly AbiParameter[])[];\n}): CheckProposalFieldResult;\nexport function checkProposalField({\n fieldOrType,\n value,\n required = true,\n baseUrl,\n components,\n}: CheckProposalFieldImplArg): CheckProposalFieldResult {\n const notRequiredAbiTypes = [\"bool\", \"string\"];\n\n if (\n !notRequiredAbiTypes.includes(fieldOrType) &&\n required &&\n (value === undefined || value === null || value === \"\")\n ) {\n return ProposalErrorCodes.REQUIRED;\n }\n\n if (fieldOrType.startsWith(\"uint\") || fieldOrType.startsWith(\"int\")) {\n if (typeof value !== \"string\") {\n return ProposalErrorCodes.INVALID_AMOUNT;\n }\n\n try {\n const valueBN = BigInt(value);\n if (fieldOrType.startsWith(\"uint\")) {\n if (valueBN < 0n) {\n return ProposalErrorCodes.NEGATIVE_AMOUNT;\n }\n }\n } catch {\n return ProposalErrorCodes.INVALID_AMOUNT;\n }\n return null;\n }\n\n switch (fieldOrType) {\n case \"string\":\n if (value !== undefined && typeof value !== \"string\") {\n return ProposalErrorCodes.INVALID_AMOUNT;\n }\n return null;\n\n case \"bool\":\n if (typeof value !== \"boolean\") {\n return ProposalErrorCodes.INVALID_AMOUNT;\n }\n return null;\n\n case \"title\":\n if (typeof value !== \"string\" || value.length === 0) {\n return ProposalErrorCodes.REQUIRED;\n }\n return null;\n\n case \"description\":\n if (typeof value !== \"string\" || value.length === 0) {\n return ProposalErrorCodes.REQUIRED;\n }\n return null;\n\n case \"forumLink\": {\n if (typeof value !== \"string\" || value.length === 0) {\n return ProposalErrorCodes.REQUIRED;\n }\n\n if (!URL.canParse(value)) {\n return ProposalErrorCodes.INVALID_ADDRESS;\n }\n\n const base = new URL(baseUrl!);\n\n // base.pathname = \"/c/\";\n\n if (!value.startsWith(base.toString())) {\n return ProposalErrorCodes.INVALID_BASEPATH;\n }\n\n return null;\n }\n\n case \"address\":\n if (typeof value !== \"string\" || !isAddress(value, { strict: true })) {\n return ProposalErrorCodes.INVALID_ADDRESS;\n }\n\n return null;\n\n case \"hex\":\n if (typeof value !== \"string\" || !isHex(value, { strict: true })) {\n return ProposalErrorCodes.INVALID_ADDRESS;\n }\n return null;\n\n case \"abi\":\n if (typeof value !== \"string\") {\n return ProposalErrorCodes.INVALID_ABI;\n }\n try {\n JSON.parse(value);\n } catch {\n return ProposalErrorCodes.INVALID_ABI;\n }\n return null;\n\n case \"action\":\n if (typeof value !== \"string\" || !isAddress(value, { strict: true })) {\n return ProposalErrorCodes.INVALID_ADDRESS;\n }\n return null;\n\n case \"tuple\":\n if (typeof value === \"object\" && Array.isArray(components)) {\n const errors: Record<string, CheckProposalFieldResult> = {};\n\n for (const component of components) {\n // Intersect with components? to access the field safely;\n // it only exists on tuple AbiParameter variants\n const abiParam = component as AbiParameter & {\n components?: readonly AbiParameter[];\n };\n const name = abiParam.name!;\n // fieldOrType is cast to \"tuple\" | \"tuple[]\" to satisfy overload 2\n // (returns CheckProposalFieldResult). The actual runtime type dispatches\n // to the correct branch.\n errors[name] = checkProposalField({\n fieldOrType: abiParam.type as \"tuple\" | \"tuple[]\",\n value: (value as Record<string, unknown>)[name],\n components: abiParam.components,\n });\n }\n\n if (Object.values(errors).every((v) => v === null)) {\n return null;\n }\n\n return errors as Record<string, CheckProposalFieldResultMinimal>;\n }\n\n return null;\n\n case \"tuple[]\":\n if (Array.isArray(value)) {\n const errors = value.map((v) =>\n checkProposalField({\n fieldOrType: \"tuple\",\n value: v,\n components,\n }),\n );\n\n if (errors.every((v) => v === null)) {\n return null;\n }\n\n // errors contains tuple results (null | Record<string, ...>);\n // cast is intentional — the type definition predates nested support\n return errors as unknown as CheckProposalFieldResultMinimal[];\n }\n\n return null;\n\n case \"logoURI\": {\n if (value === undefined || value === \"\") {\n return null;\n }\n if (\n typeof value !== \"string\" ||\n !URL.canParse(value) ||\n new URL(value).protocol !== \"https:\"\n ) {\n return ProposalErrorCodes.MUST_BE_HTTPS_OR_IPFS;\n }\n return null;\n }\n case \"url\": {\n if (value === undefined || value === \"\") {\n return null;\n }\n if (\n typeof value !== \"string\" ||\n !URL.canParse(value) ||\n new URL(value).protocol !== \"https:\"\n ) {\n return ProposalErrorCodes.MUST_BE_HTTPS;\n }\n return null;\n }\n default:\n console.error(`Invalid field or type: ${fieldOrType}`);\n return null;\n }\n}\n","import graymatter from \"gray-matter\";\n\nimport type { ProposalSelectionFragment } from \"@berachain/graphql/governance\";\n\nexport type ParseProposalBodyResult = graymatter.GrayMatterFile<string> & {\n /** Whether the body uses YAML front-matter (true) or legacy heading format (false) */\n isFrontMatter: boolean;\n};\n\nfunction parseLegacyBody(s: string): {\n type: string | null;\n title: string;\n content: string;\n} {\n const pattern = /#(?:([\\w-]+)# )?(.+)\\n([\\s\\S]*)/;\n const match = s.match(pattern);\n\n if (match) {\n const type = match[1] || null;\n const title = match[2];\n const content = match[3].replace(\"\\n\", \"<br />\");\n return {\n type,\n title,\n content,\n };\n }\n\n throw new Error(\"Invalid proposal body\");\n}\n\n/**\n * Parses the body of a governance proposal into structured front-matter and content.\n * Supports YAML front-matter format and a legacy heading-based format.\n * Falls back to raw description on parse failure.\n */\nexport function parseProposalBody(\n proposal?: Pick<ProposalSelectionFragment, \"description\">,\n): ParseProposalBodyResult {\n if (!proposal) {\n return {\n isFrontMatter: false,\n data: { title: \"Loading...\" },\n content: \"\",\n matter: \"\",\n language: \"\",\n orig: \"\",\n stringify: () => \"\",\n };\n }\n\n const body = proposal?.description ?? \"\";\n\n if (graymatter.test(body)) {\n return { ...graymatter(body), isFrontMatter: true };\n }\n\n try {\n const legacyBody = parseLegacyBody(body);\n\n return {\n isFrontMatter: false,\n data: { title: legacyBody.title },\n content: legacyBody.content,\n matter: \"\",\n language: \"\",\n orig: body,\n stringify: () => body,\n };\n } catch {\n return {\n isFrontMatter: false,\n data: {\n title: proposal?.description?.split(\"\\n\")[0].slice(0, 100),\n },\n content: body,\n matter: \"\",\n language: \"\",\n orig: body,\n stringify: () => body,\n };\n }\n}\n","import {\n GetProposalVotes,\n type GetProposalVotesQuery,\n type GetProposalVotesQueryVariables,\n} from \"@berachain/graphql/governance\";\n\nimport { getApolloClient } from \"../clients/getApolloClient\";\n\nexport type GetProposalVotesArgs = BeraJS.BaseFunctionArgs & {\n /** GraphQL variables forwarded to the GetProposalVotes query */\n variables: GetProposalVotesQueryVariables;\n};\n\n/** Fetches the votes for a proposal from the subgraph */\nexport async function getProposalVotes({\n variables,\n ...args\n}: GetProposalVotesArgs) {\n const governanceClient = getApolloClient(\"governance.subgraph\", args);\n return governanceClient.query<GetProposalVotesQuery>({\n query: GetProposalVotes,\n variables,\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors/BeraTracing.ts"],"names":["_handlers","BeraTracing","context","callback","next","handler","idx"],"mappings":"AAqBA,6EAAMA,CAAAA,CAA2B,CAAC,CAAA,CA0BrBC,CAAAA,aAAc,CAOzB,SAAA,CAAaC,CAAAA,CAAsBC,CAAAA,CAAwC,CACzE,OAAIH,CAAAA,CAAU,MAAA,GAAW,CAAA,CAAUG,CAAAA,CAAS,CAAA,CAGrCH,CAAAA,CAAU,WAAA,CACf,CAACI,CAAAA,CAAMC,CAAAA,CAAAA,EAAY,CAAA,CAAA,EAAMA,CAAAA,CAAQH,CAAAA,CAASE,CAAI,CAAA,CAC9CD,CACF,CAAA,CAAE,CACJ,CAAA,CASA,cAAA,CAAeE,CAAAA,CAAmC,CAChD,OAAAL,CAAAA,CAAU,IAAA,CAAKK,CAAO,CAAA,CACf,CAAA,CAAA,EAAM,CACX,IAAMC,CAAAA,CAAMN,CAAAA,CAAU,OAAA,CAAQK,CAAO,CAAA,CACjCC,CAAAA,GAAQ,CAAA,CAAA,EAAIN,CAAAA,CAAU,MAAA,CAAOM,CAAAA,CAAK,CAAC,CACzC,CACF,CACF,CAAA,CAAA,cAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/chunk-S4CDSVLK.cjs","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 \"./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"]}
1
+ {"version":3,"sources":["../src/errors/BeraTracing.ts"],"names":["_handlers","BeraTracing","context","callback","next","handler","idx"],"mappings":"AAqBA,6EAAMA,CAAAA,CAA2B,CAAC,CAAA,CA0BrBC,CAAAA,aAAc,CAOzB,SAAA,CAAaC,CAAAA,CAAsBC,CAAAA,CAAwC,CACzE,OAAIH,CAAAA,CAAU,MAAA,GAAW,CAAA,CAAUG,CAAAA,CAAS,CAAA,CAGrCH,CAAAA,CAAU,WAAA,CACf,CAACI,CAAAA,CAAMC,CAAAA,CAAAA,EAAY,CAAA,CAAA,EAAMA,CAAAA,CAAQH,CAAAA,CAASE,CAAI,CAAA,CAC9CD,CACF,CAAA,CAAE,CACJ,CAAA,CASA,cAAA,CAAeE,CAAAA,CAAmC,CAChD,OAAAL,CAAAA,CAAU,IAAA,CAAKK,CAAO,CAAA,CACf,CAAA,CAAA,EAAM,CACX,IAAMC,CAAAA,CAAMN,CAAAA,CAAU,OAAA,CAAQK,CAAO,CAAA,CACjCC,CAAAA,GAAQ,CAAA,CAAA,EAAIN,CAAAA,CAAU,MAAA,CAAOM,CAAAA,CAAK,CAAC,CACzC,CACF,CACF,CAAA,CAAA,cAAA","file":"/Users/pong/coding/monobera/packages/berajs/dist/chunk-S4CDSVLK.cjs","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 \"./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"]}
@@ -1,2 +1,2 @@
1
- import{h as s}from"./chunk-GXV2JA36.mjs";import{isAddress as l}from"viem";function o(e){return e!=null}function f({value:e,property:t,fn:i}){let n=i(e);if(!n.isValid)throw new s({property:t,value:e,expected:n.expectedType})}function r({value:e,property:t,fn:i}){f({value:e,property:t,fn:n=>{let d=o(n),{isValid:p,expectedType:u}=i(n);return{expectedType:u,isValid:d&&p}}})}function c(e,t){r({value:e,property:t,fn:i=>({expectedType:"defined",isValid:o(i)})})}function b(e,t="publicClient"){c(e,t)}function y(e,t){r({value:e,property:t,fn:i=>({expectedType:"Address",isValid:typeof i=="string"&&l(i)})})}function g(e,t){if(!(typeof e=="bigint"?e>0n:Number(e)>0))throw new s({property:t,value:e,expected:"positive amount"})}function m(e,t){r({value:e,property:t,fn:i=>({expectedType:"number",isValid:(typeof i=="string"||typeof i=="number")&&Number(i)>0})})}export{c as a,b,y as c,g as d,m as e};
2
- //# sourceMappingURL=chunk-5QAFKFM5.mjs.map
1
+ import{j as s}from"./chunk-5SIQ7BKT.mjs";import{isAddress as l}from"viem";function o(e){return e!=null}function f({value:e,property:t,fn:i}){let n=i(e);if(!n.isValid)throw new s({property:t,value:e,expected:n.expectedType})}function r({value:e,property:t,fn:i}){f({value:e,property:t,fn:n=>{let d=o(n),{isValid:p,expectedType:u}=i(n);return{expectedType:u,isValid:d&&p}}})}function c(e,t){r({value:e,property:t,fn:i=>({expectedType:"defined",isValid:o(i)})})}function b(e,t="publicClient"){c(e,t)}function y(e,t){r({value:e,property:t,fn:i=>({expectedType:"Address",isValid:typeof i=="string"&&l(i)})})}function g(e,t){if(!(typeof e=="bigint"?e>0n:Number(e)>0))throw new s({property:t,value:e,expected:"positive amount"})}function m(e,t){r({value:e,property:t,fn:i=>({expectedType:"number",isValid:(typeof i=="string"||typeof i=="number")&&Number(i)>0})})}export{c as a,b,y as c,g as d,m as e};
2
+ //# sourceMappingURL=chunk-TU63NRNL.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;var _chunk6JJIZCVYcjs = require('./chunk-6JJIZCVY.cjs');var i=class extends _chunk6JJIZCVYcjs.f{constructor(t){super(t),this.name="NotFoundError",this.level=_nullishCoalesce(t.level, () => ("info")),this.message=`Resource ${t.resource} with id ${t.id} not found`,this.resource=t.resource,this.id=t.id}};var r= (_class =class extends _chunk6JJIZCVYcjs.f{__init() {this.blockNumber=null}constructor(t){super(t);_class.prototype.__init.call(this);,this.name="TransactionFailedError",this.txHash=t.txHash||null,this.receipt=t.receipt||null,this.to=t.to,this.functionName=t.functionName,this.blockNumber=_nullishCoalesce(t.blockNumber, () => (null)),this.input=t.input,this.receipt?this.message=`Transaction reverted on chain for reason: ${this.reason}`:this.txHash?this.message=`Transaction reverted after being broadcasted for reason: ${this.reason}`:this.message=`${this.reason}: ${this.message}`,this.tags={...this.tags,"operation.txn.status":t.txHash?"execution":"simulation",...t.tags},this.to&&(this.tags["operation.txn.to"]=this.to),this.functionName&&(this.tags["operation.txn.functionName"]=this.functionName)}}, _class);exports.a = i; exports.b = r;
2
- //# sourceMappingURL=chunk-REWME3FY.cjs.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;var _chunkDKZGCMH4cjs = require('./chunk-DKZGCMH4.cjs');var i=class extends _chunkDKZGCMH4cjs.h{constructor(t){super(t),this.name="NotFoundError",this.level=_nullishCoalesce(t.level, () => ("info")),this.message=`Resource ${t.resource} with id ${t.id} not found`,this.resource=t.resource,this.id=t.id}};var r= (_class =class extends _chunkDKZGCMH4cjs.h{__init() {this.blockNumber=null}constructor(t){super(t);_class.prototype.__init.call(this);,this.name="TransactionFailedError",this.txHash=t.txHash||null,this.receipt=t.receipt||null,this.to=t.to,this.functionName=t.functionName,this.blockNumber=_nullishCoalesce(t.blockNumber, () => (null)),this.input=t.input,this.receipt?this.message=`Transaction reverted on chain for reason: ${this.reason}`:this.txHash?this.message=`Transaction reverted after being broadcasted for reason: ${this.reason}`:this.message=`${this.reason}: ${this.message}`,this.tags={...this.tags,"operation.txn.status":t.txHash?"execution":"simulation",...t.tags},this.to&&(this.tags["operation.txn.to"]=this.to),this.functionName&&(this.tags["operation.txn.functionName"]=this.functionName)}}, _class);exports.a = i; exports.b = r;
2
+ //# sourceMappingURL=chunk-W4JE2NIN.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/chunk-W4JE2NIN.cjs","../src/errors/NotFoundError.ts","../src/errors/TransactionFailedError.ts"],"names":["NotFoundError","BeraError","args","TransactionFailedError"],"mappings":"AAAA,iPAAwC,ICW3BA,CAAAA,CAAN,MAAA,QAA4BC,mBAAU,CAM3C,WAQA,CAAYC,CAAAA,CAA0B,CACpC,KAAA,CAAMA,CAAI,CAAA,CACV,IAAA,CAAK,IAAA,CAAO,eAAA,CACZ,IAAA,CAAK,KAAA,kBAAQA,CAAAA,CAAK,KAAA,SAAS,QAAA,CAC3B,IAAA,CAAK,OAAA,CAAU,CAAA,SAAA,EAAYA,CAAAA,CAAK,QAAQ,CAAA,SAAA,EAAYA,CAAAA,CAAK,EAAE,CAAA,UAAA,CAAA,CAC3D,IAAA,CAAK,QAAA,CAAWA,CAAAA,CAAK,QAAA,CACrB,IAAA,CAAK,EAAA,CAAKA,CAAAA,CAAK,EACjB,CACF,CAAA,CCzBO,IAAMC,CAAAA,WAAN,MAAA,QAAqCF,mBAAU,CAMpD,eAsBA,WAAA,CAA6B,KAAA,WAY7B,CACEC,CAAAA,CAQA,CACA,KAAA,CAAMA,CAAI,qCAAA,CACV,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/pong/coding/monobera/packages/berajs/dist/chunk-W4JE2NIN.cjs","sourcesContent":[null,"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"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/enum/governance.ts"],"names":["ProposalState","VoteEnum","ProposalErrorCodes","ProposalTypeEnum","VoteColorMap"],"mappings":"AAMO,6EAAKA,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAAA,CAAAA,CAAA,OAAA,CAAU,CAAA,CAAA,CAAV,SAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,MAAA,CAAS,CAAA,CAAA,CAAT,QAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,QAAA,CAAW,CAAA,CAAA,CAAX,UAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,QAAA,CAAW,CAAA,CAAA,CAAX,UAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,SAAA,CAAY,CAAA,CAAA,CAAZ,WAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,MAAA,CAAS,CAAA,CAAA,CAAT,QAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,OAAA,CAAU,CAAA,CAAA,CAAV,SAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,QAAA,CAAW,CAAA,CAAA,CAAX,UAAA,CARUA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAUAC,CAAAA,aAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,OAAA,CAAU,IAAA,CACVA,CAAAA,CAAA,GAAA,CAAM,KAAA,CACNA,CAAAA,CAAA,OAAA,CAAU,SAAA,CAHAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAMAC,CAAAA,aAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,QAAA,CAAW,UAAA,CACXA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,eAAA,CAAkB,iBAAA,CAClBA,CAAAA,CAAA,eAAA,CAAkB,iBAAA,CAClBA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,WAAA,CAAc,aAAA,CACdA,CAAAA,CAAA,aAAA,CAAgB,eAAA,CAChBA,CAAAA,CAAA,qBAAA,CAAwB,uBAAA,CACxBA,CAAAA,CAAA,gBAAA,CAAmB,gCAAA,CAInBA,CAAAA,CAAA,gBAAA,CAAmB,8BAAA,CAbTA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAgBAC,CAAAA,aAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,eAAA,CAAkB,eAAA,CAClBA,CAAAA,CAAA,sBAAA,CAAyB,wBAAA,CACzBA,CAAAA,CAAA,sBAAA,CAAyB,wBAAA,CACzBA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,gCAAA,CAAmC,kCAAA,CALzBA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAQCC,CAAAA,aAAe,CAC1B,GAAA,CAAK,SAAA,CACL,CAAA,CAAG,SAAA,CACH,EAAA,CAAI,SAAA,CACJ,CAAA,CAAG,SAAA,CACH,IAAA,CAAM,SAAA,CACN,CAAA,CAAG,SAAA,CACH,OAAA,CAAS,SAAA,CACT,CAAA,CAAG,SAAA,CACH,aAAA,CAAe,SAAA,CACf,YAAA,CAAc,SAAA,CACd,cAAA,CAAgB,SAAA,CAChB,iBAAA,CAAmB,SAAA,CACnB,OAAA,CAAS,SACX,CAAA,CAAA,0EAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/chunk-WRFDB3QJ.cjs","sourcesContent":["/**\n * Maps the proposal state from the governor contract to a more human-readable format.\n * Don't edit this enum manually, it's synced with the governor contract.\n *\n * @see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/IGovernor.sol\n */\nexport enum ProposalState {\n Pending = 0,\n Active = 1,\n Canceled = 2,\n Defeated = 3,\n Succeeded = 4,\n Queued = 5,\n Expired = 6,\n Executed = 7,\n}\nexport enum VoteEnum {\n AGAINST = \"no\",\n FOR = \"yes\",\n ABSTAIN = \"abstain\",\n}\n\nexport enum ProposalErrorCodes {\n REQUIRED = \"Required\",\n INVALID_AMOUNT = \"Invalid amount\",\n NEGATIVE_AMOUNT = \"Negative amount\",\n INVALID_ADDRESS = \"Invalid address\",\n INVALID_ACTION = \"Invalid action\",\n INVALID_ABI = \"Invalid ABI\",\n MUST_BE_HTTPS = \"Must be HTTPS\",\n MUST_BE_HTTPS_OR_IPFS = \"Must be HTTPS or IPFS\",\n INVALID_BASEPATH = \"Must be a berachain forum link\",\n /**\n * Mainly used when it's not a reward vault\n */\n INVALID_CONTRACT = \"This is not a valid contract\",\n}\n\nexport enum ProposalTypeEnum {\n CUSTOM_PROPOSAL = \"custom-action\",\n WHITELIST_REWARD_VAULT = \"whitelist-reward-vault\",\n BLACKLIST_REWARD_VAULT = \"blacklist-reward-vault\",\n ERC20_TRANSFER = \"erc20-transfer\",\n WHITELIST_REWARD_VAULT_INCENTIVE = \"whitelist-reward-vault-incentive\",\n}\n\nexport const VoteColorMap = {\n yes: \"#059669\",\n 1: \"#059669\",\n no: \"#DC2629\",\n 2: \"#DC2629\",\n veto: \"#0284C7\",\n 4: \"#0284C7\",\n abstain: \"#78716c\",\n 3: \"#78716c\",\n yes_secondary: \"#ECFDF5\",\n no_secondary: \"#FEF2F2\",\n veto_secondary: \"#F0F9FF\",\n abstain_secondary: \"#E7E5E4\",\n default: \"#57534e\",\n} as const;\n"]}
1
+ {"version":3,"sources":["../src/enum/governance.ts"],"names":["ProposalState","VoteEnum","ProposalErrorCodes","ProposalTypeEnum","VoteColorMap"],"mappings":"AAMO,6EAAKA,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAAA,CAAAA,CAAA,OAAA,CAAU,CAAA,CAAA,CAAV,SAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,MAAA,CAAS,CAAA,CAAA,CAAT,QAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,QAAA,CAAW,CAAA,CAAA,CAAX,UAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,QAAA,CAAW,CAAA,CAAA,CAAX,UAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,SAAA,CAAY,CAAA,CAAA,CAAZ,WAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,MAAA,CAAS,CAAA,CAAA,CAAT,QAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,OAAA,CAAU,CAAA,CAAA,CAAV,SAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,QAAA,CAAW,CAAA,CAAA,CAAX,UAAA,CARUA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAUAC,CAAAA,aAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,OAAA,CAAU,IAAA,CACVA,CAAAA,CAAA,GAAA,CAAM,KAAA,CACNA,CAAAA,CAAA,OAAA,CAAU,SAAA,CAHAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAMAC,CAAAA,aAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,QAAA,CAAW,UAAA,CACXA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,eAAA,CAAkB,iBAAA,CAClBA,CAAAA,CAAA,eAAA,CAAkB,iBAAA,CAClBA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,WAAA,CAAc,aAAA,CACdA,CAAAA,CAAA,aAAA,CAAgB,eAAA,CAChBA,CAAAA,CAAA,qBAAA,CAAwB,uBAAA,CACxBA,CAAAA,CAAA,gBAAA,CAAmB,gCAAA,CAInBA,CAAAA,CAAA,gBAAA,CAAmB,8BAAA,CAbTA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAgBAC,CAAAA,aAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,eAAA,CAAkB,eAAA,CAClBA,CAAAA,CAAA,sBAAA,CAAyB,wBAAA,CACzBA,CAAAA,CAAA,sBAAA,CAAyB,wBAAA,CACzBA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,gCAAA,CAAmC,kCAAA,CALzBA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAQCC,CAAAA,aAAe,CAC1B,GAAA,CAAK,SAAA,CACL,CAAA,CAAG,SAAA,CACH,EAAA,CAAI,SAAA,CACJ,CAAA,CAAG,SAAA,CACH,IAAA,CAAM,SAAA,CACN,CAAA,CAAG,SAAA,CACH,OAAA,CAAS,SAAA,CACT,CAAA,CAAG,SAAA,CACH,aAAA,CAAe,SAAA,CACf,YAAA,CAAc,SAAA,CACd,cAAA,CAAgB,SAAA,CAChB,iBAAA,CAAmB,SAAA,CACnB,OAAA,CAAS,SACX,CAAA,CAAA,0EAAA","file":"/Users/pong/coding/monobera/packages/berajs/dist/chunk-WRFDB3QJ.cjs","sourcesContent":["/**\n * Maps the proposal state from the governor contract to a more human-readable format.\n * Don't edit this enum manually, it's synced with the governor contract.\n *\n * @see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/IGovernor.sol\n */\nexport enum ProposalState {\n Pending = 0,\n Active = 1,\n Canceled = 2,\n Defeated = 3,\n Succeeded = 4,\n Queued = 5,\n Expired = 6,\n Executed = 7,\n}\nexport enum VoteEnum {\n AGAINST = \"no\",\n FOR = \"yes\",\n ABSTAIN = \"abstain\",\n}\n\nexport enum ProposalErrorCodes {\n REQUIRED = \"Required\",\n INVALID_AMOUNT = \"Invalid amount\",\n NEGATIVE_AMOUNT = \"Negative amount\",\n INVALID_ADDRESS = \"Invalid address\",\n INVALID_ACTION = \"Invalid action\",\n INVALID_ABI = \"Invalid ABI\",\n MUST_BE_HTTPS = \"Must be HTTPS\",\n MUST_BE_HTTPS_OR_IPFS = \"Must be HTTPS or IPFS\",\n INVALID_BASEPATH = \"Must be a berachain forum link\",\n /**\n * Mainly used when it's not a reward vault\n */\n INVALID_CONTRACT = \"This is not a valid contract\",\n}\n\nexport enum ProposalTypeEnum {\n CUSTOM_PROPOSAL = \"custom-action\",\n WHITELIST_REWARD_VAULT = \"whitelist-reward-vault\",\n BLACKLIST_REWARD_VAULT = \"blacklist-reward-vault\",\n ERC20_TRANSFER = \"erc20-transfer\",\n WHITELIST_REWARD_VAULT_INCENTIVE = \"whitelist-reward-vault-incentive\",\n}\n\nexport const VoteColorMap = {\n yes: \"#059669\",\n 1: \"#059669\",\n no: \"#DC2629\",\n 2: \"#DC2629\",\n veto: \"#0284C7\",\n 4: \"#0284C7\",\n abstain: \"#78716c\",\n 3: \"#78716c\",\n yes_secondary: \"#ECFDF5\",\n no_secondary: \"#FEF2F2\",\n veto_secondary: \"#F0F9FF\",\n abstain_secondary: \"#E7E5E4\",\n default: \"#57534e\",\n} as const;\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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 _chunkS4CDSVLKcjs = require('./chunk-S4CDSVLK.cjs');var _chunkDKZGCMH4cjs = require('./chunk-DKZGCMH4.cjs');async function $(e){if(_optionalChain([e, 'access', _2 => _2.headers, 'access', _3 => _3.get, 'call', _4 => _4("content-type"), 'optionalAccess', _5 => _5.includes, 'call', _6 => _6("application/json")]))return e.json();{let t=await e.text();try{return JSON.parse(t)}catch (e2){return{message:"Unknown error, can't decode response into JSON",cause:t}}}}function R(e){if(!e)return"";try{let n=new URL(e);return n.hostname.endsWith(".quiknode.pro")?(n.pathname="/",n.search="",n.toString()):e}catch (e3){return e}}async function V(e,n,t){try{let r=R(typeof e=="string"||e instanceof URL?e.toString():e.url.toString()).replace(/0x[a-fA-F0-9]{40}/g,":address");if(_optionalChain([t, 'optionalAccess', _7 => _7.keepQueryParams])!==!0&&URL.canParse(r)){let i=new URL(r).searchParams;if(Array.isArray(_optionalChain([t, 'optionalAccess', _8 => _8.keepQueryParams]))){let a=new URLSearchParams;for(let m of t.keepQueryParams)a.set(m,_nullishCoalesce(i.get(m), () => ("")));let c=new URL(r);c.search=a.toString(),r=c.toString()}else{let a=new URL(r);a.search="",r=a.toString()}}let s=typeof e=="string"||e instanceof URL?void 0:e.name;return await _chunkS4CDSVLKcjs.a.startSpan({op:"beraFetch",name:s?`beraFetch ${s}`:"beraFetch",attributes:typeof e=="string"||e instanceof URL?{"operation.source.url":r,..._optionalChain([t, 'optionalAccess', _9 => _9.attributes])}:{"operation.source.url":r,"operation.source.type":e.type,"operation.source.name":e.name,..._optionalChain([t, 'optionalAccess', _10 => _10.attributes])}},async()=>{let i=await fetch(typeof e=="string"||e instanceof URL?e:e.url,{...n});if(!i.ok){let a=await $(i);throw new (0, _chunkDKZGCMH4cjs.i)({cause:a,response:i,endpoint:e})}return i})}catch(r){throw r instanceof _chunkDKZGCMH4cjs.i?r:new (0, _chunkDKZGCMH4cjs.i)({cause:r,endpoint:e,response:void 0})}}async function ae(e,n){return(await V(e,{...n,headers:{Accept:"application/json",..._optionalChain([n, 'optionalAccess', _11 => _11.headers])}})).json()}var _viem = require('viem');var ce=_viem.parseEther.call(void 0, "0.005"),me= exports.g =1e5,fe= exports.h =1,le= exports.i =.1,be= exports.j =50,pe= exports.k =7920027n;var de=e=>2n*BigInt(e);function ye(e){return Math.floor(e/1e3)}function k(e){return e*1e3}function q(e){return e*k(60)}function J(e){return e*60}function G(e){return e*q(60)}function X(e){return e*J(60)}function I(e){return e*G(24)}function w(e){return e*X(24)}function Ne(e){return e*I(7)}function xe(e){return e*w(7)}function Se(e){return e*I(30)}function Me(e){return e*w(30)}function Te(e){return e*I(365)}function Ie(e){return e*w(365)}function Ue(e){let n=new Date;return n.setDate(n.getDate()-e)*1e3}var Q=["January","February","March","April","May","June","July","August","September","October","November","December"],Y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function De(e,n){let t=new Date(e*1e3),r=t.getDate(),s="th";return r===1||r===21||r===31?s="st":r===2||r===22?s="nd":(r===3||r===23)&&(s="rd"),n?`${Y[t.getMonth()]} ${r}`:`${Q[t.getMonth()]} ${r}${s}, ${t.getFullYear()}`}function Fe(...e){let n=e[0],t,r,s,i;if(typeof e[1]!="object")t=_nullishCoalesce(e[1], () => (!1)),r=_nullishCoalesce(e[2], () => (!1)),i=_nullishCoalesce(e[3], () => (!1)),s=!0;else{let u=e[1];t=_nullishCoalesce(u.condensed, () => (!1));let o=_nullishCoalesce(u.greaterUnit, () => ("hours"));o==="days"?(r=!0,s=!0):o==="hours"?(r=!1,s=!0,i=!1):(r=!1,s=!0),i=_nullishCoalesce(u.showSeconds, () => (!1))}let a=Math.floor(n/(3600*24)),c=Math.floor(n%(3600*24)/3600),m=Math.floor(n%3600/60),f=n%60;if(r||(c+=a*24,a=0),a===0&&c===0&&m===0)return t?"< 1 M":"less than a minute";let g=a>0?`${a}${t?"D":" day"}${!t&&a!==1?"s":""}`:"",y=c>0?`${c}${t?"H":" hour"}${!t&&c!==1?"s":""}`:"",S=m>0&&s||!a&&!c?`${m}${t?"M":" minute"}${!t&&m!==1?"s":""}`:"",M=f>0&&i?`${f}${t?"S":" second"}${!t&&f!==1?"s":""}`:"";return[g,y,S,M].filter(Boolean).join(t?" ":", ")}var _bignumberjs = require('bignumber.js'); var _bignumberjs2 = _interopRequireDefault(_bignumberjs);_bignumberjs2.default.set({EXPONENTIAL_AT:1e9});var U=_bignumberjs2.default;var P=["","K","M","B","T","P","E","Z","Y"];function _(e){return e instanceof U?e:new U(e)}function z(e,n){return _(e).shiftedBy(n*-1)}function Le(e,n={}){if(typeof n=="number"){let h=n;if(e==null)return"";if(typeof e=="object")throw new Error("Value must be a number if using deprecated version");let b=Number(e).toFixed(h);return b=b.replace(/(\.\d*?[1-9])0+$|\.0*$/,"$1"),b}let{visibleDecimals:t,compact:r=!0,percent:s=!1,roundDown:i=!1,roundUp:a=!1,compactThreshold:c,maxValue:m,symbol:f,prefixText:g="",suffixText:y="",showIsSmallerThanMin:S=!0,ifNullish:M=""}=n||{};if(e==null)return M;let u=s?Number(e)*100:Number(e);if(Number.isNaN(u))return"NaN";if(u===Number.POSITIVE_INFINITY)return"Infinity";if(u===Number.NEGATIVE_INFINITY)return"-Infinity";let o=_nullishCoalesce(t, () => (0));u===0?o=0:t===void 0&&(Math.abs(u)>1||s||f==="USD"?o=2:o=7);let D=10**-o,F=u!==0&&Math.abs(u)<Math.abs(D),B=u<0,O=m?Math.abs(u)>m:!1,p=F?D:u,T=r&&(!c||Math.abs(u)>c);i&&!T?p=Math.trunc(Number(p)*10**o)/10**o:a&&!T&&(p=Math.ceil(Number(p)*10**o)/10**o);let N;if(O)N=u>m?"\u221E":"-\u221E";else if(T){let h=_(p),b=h.abs().toFixed(0).length;c&&Math.abs(u)<=c&&(b=0);let A=Math.min(Math.floor(b?(b-1)/3:0),P.length-1),C=P[A],d=z(h,3*A).toNumber();i?d=Math.trunc(Number(d)*10**o)/10**o:a&&(d=Math.ceil(Number(d)*10**o)/10**o),N=`${new Intl.NumberFormat("en-US",{maximumFractionDigits:o,minimumFractionDigits:o}).format(d)}${C}`}else{let h=new Intl.NumberFormat("en-US",{maximumFractionDigits:o,minimumFractionDigits:o}).format(Math.abs(p));N=`${B?"-":""}${h}`}let l=[];return g&&l.push(g),F&&S&&l.push(u<0?">":"<"),_optionalChain([f, 'optionalAccess', _12 => _12.toLowerCase, 'call', _13 => _13()])==="usd"&&!s&&l.push("$"),l.push(N),s&&l.push("%"),_optionalChain([f, 'optionalAccess', _14 => _14.toLowerCase, 'call', _15 => _15()])!=="usd"&&typeof f<"u"&&l.push(" ",f),y&&l.push(y),l.join("")}var Pe=e=>e?Number(e)>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:_nullishCoalesce(Number(e), () => (0)):0,_e= exports.F =(e,n)=>{if(!e)return"0";let[t="0",r="0"]=`${e}`.split(".");return`${t}.${r.substring(0,n)}`};var _internal = require('@berachain/config/internal');function Ve(e=_internal.defaultChainId){let n=_internal.getRpcUrls.call(void 0, e);if(!n.isAnvil)throw new Error("No anvil RPC URL found");return _viem.createTestClient.call(void 0, {mode:"anvil",transport:_viem.http.call(void 0, n.jsonRpcUrl)})}exports.a = U; exports.b = $; exports.c = R; exports.d = V; exports.e = ae; exports.f = ce; exports.g = me; exports.h = fe; exports.i = le; exports.j = be; exports.k = pe; exports.l = de; exports.m = ye; exports.n = k; exports.o = q; exports.p = J; exports.q = G; exports.r = X; exports.s = I; exports.t = w; exports.u = Ne; exports.v = xe; exports.w = Se; exports.x = Me; exports.y = Te; exports.z = Ie; exports.A = Ue; exports.B = De; exports.C = Fe; exports.D = Le; exports.E = Pe; exports.F = _e; exports.G = Ve;
2
+ //# sourceMappingURL=chunk-XB2SEO4Y.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/chunk-XB2SEO4Y.cjs","../src/utils/getErrorResponse.ts","../src/utils/sanitizeRpcUrl.ts","../src/utils/beraFetch.ts"],"names":["getErrorResponse","response","text","sanitizeRpcUrl","url","parsed","beraFetch","endpoint","options","spanContext","spanUrl","queryParams","searchParams","param","newUrl","endpointName","BeraTracing"],"mappings":"AAAA,y0BAAwC,wDAAyC,MCGjF,SAAsBA,CAAAA,CAAiBC,CAAAA,CAAoB,CAGzD,EAAA,iBAFoBA,CAAAA,qBAAS,OAAA,qBAAQ,GAAA,mBAAI,cAAc,CAAA,6BAEtC,QAAA,mBAAS,kBAAkB,GAAA,CAC1C,OAAOA,CAAAA,CAAS,IAAA,CAAK,CAAA,CAChB,CACL,IAAMC,CAAAA,CAAO,MAAMD,CAAAA,CAAS,IAAA,CAAK,CAAA,CACjC,GAAI,CACF,OAAO,IAAA,CAAK,KAAA,CAAMC,CAAI,CACxB,CAAA,UAAQ,CACN,MAAO,CACL,OAAA,CAAS,gDAAA,CACT,KAAA,CAAOA,CACT,CACF,CACF,CACF,CCXO,SAASC,CAAAA,CAAeC,CAAAA,CAAiC,CAC9D,EAAA,CAAI,CAACA,CAAAA,CAAK,MAAO,EAAA,CACjB,GAAI,CACF,IAAMC,CAAAA,CAAS,IAAI,GAAA,CAAID,CAAG,CAAA,CAC1B,OAAIC,CAAAA,CAAO,QAAA,CAAS,QAAA,CAAS,eAAe,CAAA,CAAA,CAC1CA,CAAAA,CAAO,QAAA,CAAW,GAAA,CAClBA,CAAAA,CAAO,MAAA,CAAS,EAAA,CACTA,CAAAA,CAAO,QAAA,CAAS,CAAA,CAAA,CAElBD,CACT,CAAA,UAAQ,CACN,OAAOA,CACT,CACF,CCdA,MAAA,SAAsBE,CAAAA,CACpBC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CASA,CACA,GAAI,CACF,IAAIC,CAAAA,CAAUP,CAAAA,CACZ,OAAOI,CAAAA,EAAa,QAAA,EAAYA,EAAAA,WAAoB,GAAA,CAChDA,CAAAA,CAAS,QAAA,CAAS,CAAA,CAClBA,CAAAA,CAAS,GAAA,CAAI,QAAA,CAAS,CAC5B,CAAA,CAAE,OAAA,CAAQ,oBAAA,CAAsB,UAAU,CAAA,CAE1C,EAAA,iBAAIE,CAAAA,6BAAa,iBAAA,GAAoB,CAAA,CAAA,EAAQ,GAAA,CAAI,QAAA,CAASC,CAAO,CAAA,CAAG,CAClE,IAAMC,CAAAA,CAAc,IAAI,GAAA,CAAID,CAAO,CAAA,CAAE,YAAA,CACrC,EAAA,CAAI,KAAA,CAAM,OAAA,iBAAQD,CAAAA,6BAAa,iBAAe,CAAA,CAAG,CAC/C,IAAMG,CAAAA,CAAe,IAAI,eAAA,CAEzB,GAAA,CAAA,IAAWC,EAAAA,GAASJ,CAAAA,CAAY,eAAA,CAC9BG,CAAAA,CAAa,GAAA,CAAIC,CAAAA,kBAAOF,CAAAA,CAAY,GAAA,CAAIE,CAAK,CAAA,SAAK,IAAE,CAAA,CAGtD,IAAMC,CAAAA,CAAS,IAAI,GAAA,CAAIJ,CAAO,CAAA,CAC9BI,CAAAA,CAAO,MAAA,CAASF,CAAAA,CAAa,QAAA,CAAS,CAAA,CACtCF,CAAAA,CAAUI,CAAAA,CAAO,QAAA,CAAS,CAC5B,CAAA,IAAO,CACL,IAAMA,CAAAA,CAAS,IAAI,GAAA,CAAIJ,CAAO,CAAA,CAC9BI,CAAAA,CAAO,MAAA,CAAS,EAAA,CAChBJ,CAAAA,CAAUI,CAAAA,CAAO,QAAA,CAAS,CAC5B,CACF,CAEA,IAAMC,CAAAA,CACJ,OAAOR,CAAAA,EAAa,QAAA,EAAYA,EAAAA,WAAoB,GAAA,CAChD,KAAA,CAAA,CACAA,CAAAA,CAAS,IAAA,CAEf,OAAO,MAAMS,mBAAAA,CAAY,SAAA,CACvB,CACE,EAAA,CAAI,WAAA,CACJ,IAAA,CAAMD,CAAAA,CAAe,CAAA,UAAA,EAAaA,CAAY,CAAA,CAAA","file":"/Users/pong/coding/monobera/packages/berajs/dist/chunk-XB2SEO4Y.cjs","sourcesContent":[null,"/**\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 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","/**\n * Strips secret tokens from RPC URLs for safe use in span attributes and logs.\n *\n * QuickNode URLs embed API keys as path segments, e.g.:\n * https://polished-morning-sun.bera-mainnet.quiknode.pro/abc123def/\n * This function trims the subpath, producing:\n * https://polished-morning-sun.bera-mainnet.quiknode.pro/\n */\nexport function sanitizeRpcUrl(url: string | undefined): string {\n if (!url) return \"\";\n try {\n const parsed = new URL(url);\n if (parsed.hostname.endsWith(\".quiknode.pro\")) {\n parsed.pathname = \"/\";\n parsed.search = \"\";\n return parsed.toString();\n }\n return url;\n } catch {\n return url;\n }\n}\n","import { BeraTracing, type SpanContext } from \"../errors/BeraTracing\";\nimport { RequestError } from \"../errors/RequestError\";\nimport { getErrorResponse } from \"./getErrorResponse\";\nimport { sanitizeRpcUrl } from \"./sanitizeRpcUrl\";\n\ntype RequestOptions = RequestInit;\n\nexport async function beraFetch(\n endpoint: ConstructorParameters<typeof RequestError>[0][\"endpoint\"],\n options?: RequestOptions,\n spanContext?: SpanContext & {\n /**\n * If true, keep all query params in the span URL.\n * If an array of strings, keep only the query params in the array.\n * If false, remove all query params from the span URL.\n * If not provided, remove all query params from the span URL.\n */\n keepQueryParams?: boolean | string[];\n },\n) {\n try {\n let spanUrl = sanitizeRpcUrl(\n typeof endpoint === \"string\" || endpoint instanceof URL\n ? endpoint.toString()\n : endpoint.url.toString(),\n ).replace(/0x[a-fA-F0-9]{40}/g, \":address\");\n\n if (spanContext?.keepQueryParams !== true && URL.canParse(spanUrl)) {\n const queryParams = new URL(spanUrl).searchParams;\n if (Array.isArray(spanContext?.keepQueryParams)) {\n const searchParams = new URLSearchParams();\n\n for (const param of spanContext.keepQueryParams) {\n searchParams.set(param, queryParams.get(param) ?? \"\");\n }\n\n const newUrl = new URL(spanUrl);\n newUrl.search = searchParams.toString();\n spanUrl = newUrl.toString();\n } else {\n const newUrl = new URL(spanUrl);\n newUrl.search = \"\";\n spanUrl = newUrl.toString();\n }\n }\n\n const endpointName =\n typeof endpoint === \"string\" || endpoint instanceof URL\n ? undefined\n : endpoint.name;\n\n return await BeraTracing.startSpan(\n {\n op: \"beraFetch\",\n name: endpointName ? `beraFetch ${endpointName}` : \"beraFetch\",\n attributes:\n typeof endpoint === \"string\" || endpoint instanceof URL\n ? {\n \"operation.source.url\": spanUrl,\n ...spanContext?.attributes,\n }\n : ({\n \"operation.source.url\": spanUrl,\n \"operation.source.type\": endpoint.type,\n \"operation.source.name\": endpoint.name,\n ...spanContext?.attributes,\n } satisfies SpanContext[\"attributes\"]),\n },\n async () => {\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 },\n );\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"]}
@@ -0,0 +1,2 @@
1
+ import{d}from"./chunk-2VO2D4QO.mjs";import{a as b}from"./chunk-NAXAZJJY.mjs";import{a as p}from"./chunk-JHUVLM54.mjs";import{a as r,b as g,c as u}from"./chunk-TU63NRNL.mjs";import{EnsoClient as h}from"@ensofinance/sdk";import{appConfig as k}from"@berachain/config/internal";var T=process.env.NODE_ENV!=="development"&&process.env.NODE_ENV!=="test";function U({useProxy:e=T,...n}={}){let{config:a}=p(n);return new h({baseURL:e?`${a.bex.aggregatorsProxyUrl}/enso/api/v1/`:void 0,apiKey:e?"":k.apiKeys.public.enso})}import{getChainId as w,getPublicClient as E}from"@wagmi/core";import{erc20Abi as P,formatUnits as v,isAddress as x}from"viem";function N({token:e,account:n,multicallAddress:a}){return d(e,"BERA")||d(e,"ETH")?{address:a,abi:b,functionName:"getEthBalance",args:[n]}:{address:e.address,abi:P,functionName:"balanceOf",args:[n]}}async function _({account:e,tokenList:n,wagmiConfig:a}){if(r(a,"config"),!e||!n)throw new Error("account or tokenList is not defined");u(e,"account");let C=n.filter(t=>x(t.address)),B=Object.groupBy(C,t=>t.chainId??w(a));return(await Promise.allSettled(Object.entries(B).map(async([t,o])=>{r(o,"tokens");let s=E(a,{chainId:Number(t)});g(s,`publicClient ${t}`),r(s.chain,"publicClient.chain"),r(s.chain.contracts,"publicClient.chain.contracts"),r(s.chain.contracts.multicall3,"publicClient.chain.contracts.multicall3");let{multicall3:c}=s.chain.contracts,f=typeof c=="string"?c:c.address;u(f,"multicall3Address");let A=o.map(i=>N({token:i,account:e,multicallAddress:f}));return(await s.multicall({contracts:A})).map((i,y)=>{let l=o[y];if(i.error)return{...l,balance:{raw:"0",formatted:"0"}};let m=v(i.result,l?.decimals||18);return{...l,balance:{raw:i.result.toString(),formatted:m.includes("e")?"0":m}}})}))).flatMap(t=>t.status==="fulfilled"?t.value:[])}export{U as a,N as b,_ as c};
2
+ //# sourceMappingURL=chunk-XCVDZUEF.mjs.map
@@ -1 +1 @@
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.status === \"fulfilled\" ? result.value : [],\n );\n}\n"],"mappings":"wKAAA,OAAS,cAAAA,MAAkB,mBAE3B,OAAS,aAAAC,MAAiB,6BAI1B,IAAMC,EACJ,QAAQ,IAAI,WAAa,eAAiB,QAAQ,IAAI,WAAa,OAE9D,SAASC,EAAc,CAC5B,SAAAC,EAAWF,EACX,GAAGG,CACL,EAAsD,CAAC,EAAG,CACxD,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAcF,CAAI,EACrC,OAAO,IAAIG,EAAW,CACpB,QAASJ,EACL,GAAGE,EAAO,IAAI,mBAAmB,gBACjC,OACJ,OAAQF,EAEJ,GACAK,EAAU,QAAQ,OAAO,IAC/B,CAAC,CACH,CCvBA,OAAsB,cAAAC,EAAY,mBAAAC,MAAuB,cACzD,OAGE,YAAAC,EACA,eAAAC,EACA,aAAAC,MACK,OAuBA,SAASC,EAAe,CAC7B,MAAAC,EACA,QAAAC,EACA,iBAAAC,CACF,EAIG,CACD,OAAIC,EAAQH,EAAO,MAAM,GAAKG,EAAQH,EAAO,KAAK,EACzC,CACL,QAASE,EACT,IAAKE,EACL,aAAc,gBACd,KAAM,CAACH,CAAO,CAChB,EAMK,CACL,QAASD,EAAM,QACf,IAAKK,EACL,aAAc,YACd,KAAM,CAACJ,CAAO,CAChB,CAKF,CAKA,eAAsBK,EAAkB,CACtC,QAAAL,EACA,UAAAM,EACA,YAAaC,CACf,EAA2D,CAEzD,GADAC,EAAcD,EAAQ,QAAQ,EAC1B,CAACP,GAAW,CAACM,EACf,MAAM,IAAI,MAAM,qCAAqC,EAEvDG,EAAcT,EAAS,SAAS,EAEhC,IAAMU,EAAoBJ,EAAU,OAAQP,GAC1CY,EAAUZ,EAAM,OAAO,CACzB,EAEMa,EAAkB,OAAO,QAC7BF,EACCX,GAAUA,EAAM,SAAWc,EAAWN,CAAM,CAC/C,EA6DA,OA3DY,MAAM,QAAQ,WACxB,OAAO,QAAQK,CAAe,EAAE,IAAI,MAAO,CAACE,EAASC,CAAM,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
+ {"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.status === \"fulfilled\" ? result.value : [],\n );\n}\n"],"mappings":"6KAAA,OAAS,cAAAA,MAAkB,mBAE3B,OAAS,aAAAC,MAAiB,6BAI1B,IAAMC,EACJ,QAAQ,IAAI,WAAa,eAAiB,QAAQ,IAAI,WAAa,OAE9D,SAASC,EAAc,CAC5B,SAAAC,EAAWF,EACX,GAAGG,CACL,EAAsD,CAAC,EAAG,CACxD,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAcF,CAAI,EACrC,OAAO,IAAIG,EAAW,CACpB,QAASJ,EACL,GAAGE,EAAO,IAAI,mBAAmB,gBACjC,OACJ,OAAQF,EAEJ,GACAK,EAAU,QAAQ,OAAO,IAC/B,CAAC,CACH,CCvBA,OAAsB,cAAAC,EAAY,mBAAAC,MAAuB,cACzD,OAGE,YAAAC,EACA,eAAAC,EACA,aAAAC,MACK,OAuBA,SAASC,EAAe,CAC7B,MAAAC,EACA,QAAAC,EACA,iBAAAC,CACF,EAIG,CACD,OAAIC,EAAQH,EAAO,MAAM,GAAKG,EAAQH,EAAO,KAAK,EACzC,CACL,QAASE,EACT,IAAKE,EACL,aAAc,gBACd,KAAM,CAACH,CAAO,CAChB,EAMK,CACL,QAASD,EAAM,QACf,IAAKK,EACL,aAAc,YACd,KAAM,CAACJ,CAAO,CAChB,CAKF,CAKA,eAAsBK,EAAkB,CACtC,QAAAL,EACA,UAAAM,EACA,YAAaC,CACf,EAA2D,CAEzD,GADAC,EAAcD,EAAQ,QAAQ,EAC1B,CAACP,GAAW,CAACM,EACf,MAAM,IAAI,MAAM,qCAAqC,EAEvDG,EAAcT,EAAS,SAAS,EAEhC,IAAMU,EAAoBJ,EAAU,OAAQP,GAC1CY,EAAUZ,EAAM,OAAO,CACzB,EAEMa,EAAkB,OAAO,QAC7BF,EACCX,GAAUA,EAAM,SAAWc,EAAWN,CAAM,CAC/C,EA6DA,OA3DY,MAAM,QAAQ,WACxB,OAAO,QAAQK,CAAe,EAAE,IAAI,MAAO,CAACE,EAASC,CAAM,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 +1 @@
1
- {"version":3,"sources":["../src/enum/polling.ts"],"names":["POLLING"],"mappings":"AAAA,6EAAKA,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACHA,CAAAA,CAAAA,CAAAA,CAAA,IAAA,CAAO,GAAA,CAAA,CAAP,MAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,MAAA,CAAS,GAAA,CAAA,CAAT,QAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,IAAA,CAAO,IAAA,CAAA,CAAP,MAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,sBAAA,CAAyB,GAAA,CAAA,CAAzB,wBAAA,CAJGA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAAA,cAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/chunk-XNJLSA6P.cjs","sourcesContent":["enum POLLING {\n FAST = 10000, // 10 sec\n NORMAL = 100000, // 100 sec\n SLOW = 180000, // 3 min\n REFRESH_BLOCK_INTERVAL = 10000, // 10 sec\n}\n\nexport { POLLING };\n"]}
1
+ {"version":3,"sources":["../src/enum/polling.ts"],"names":["POLLING"],"mappings":"AAAA,6EAAKA,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACHA,CAAAA,CAAAA,CAAAA,CAAA,IAAA,CAAO,GAAA,CAAA,CAAP,MAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,MAAA,CAAS,GAAA,CAAA,CAAT,QAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,IAAA,CAAO,IAAA,CAAA,CAAP,MAAA,CACAA,CAAAA,CAAAA,CAAAA,CAAA,sBAAA,CAAyB,GAAA,CAAA,CAAzB,wBAAA,CAJGA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAAA,cAAA","file":"/Users/pong/coding/monobera/packages/berajs/dist/chunk-XNJLSA6P.cjs","sourcesContent":["enum POLLING {\n FAST = 10000, // 10 sec\n NORMAL = 100000, // 100 sec\n SLOW = 180000, // 3 min\n REFRESH_BLOCK_INTERVAL = 10000, // 10 sec\n}\n\nexport { POLLING };\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXB2SEO4Ycjs = require('./chunk-XB2SEO4Y.cjs');var _chunkPFUVKW6Fcjs = require('./chunk-PFUVKW6F.cjs');function m(e){return{...e,..._chunkPFUVKW6Fcjs.d.call(void 0, e,"BERA")&&_chunkPFUVKW6Fcjs.b}}function d(e){return e.map(r=>m(r))}var g=(e,r,i,o)=>{if(!e||!r||!i||!o)return 0;let n=new (0, _chunkXB2SEO4Ycjs.a)(e).times(i),s=new (0, _chunkXB2SEO4Ycjs.a)(r).times(o);if(n.lt(.01)||s.lt(.01)||n.isZero()||s.isZero())return 0;let u=s.div(n);return Number(new (0, _chunkXB2SEO4Ycjs.a)(1).minus(u).toFixed())};exports.a = m; exports.b = d; exports.c = g;
2
+ //# sourceMappingURL=chunk-YYUSCGVI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/chunk-YYUSCGVI.cjs","../src/utils/tokenWrapping.ts","../src/utils/math.ts"],"names":["wrapNativeToken","token","isToken","wBeraToken","wrapNativeTokens","tokens","computePriceImpact","tokenInPrice","tokenOutPrice","inAmount","outAmount","usdIn","bignumber_js_default","usdOut","ratio"],"mappings":"AAAA,iIAAwC,wDAAgD,SCMxEA,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,CCLO,IAAMK,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,wBAAAA,CAAUL,CAAY,CAAA,CAAE,KAAA,CAAME,CAAQ,CAAA,CAClDI,CAAAA,CAAS,IAAID,wBAAAA,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,wBAAAA,CAAU,CAAC,CAAA,CAAE,KAAA,CAAME,CAAK,CAAA,CAAE,OAAA,CAAQ,CAAC,CACvD,CAAA,CAAA,4CAAA","file":"/Users/pong/coding/monobera/packages/berajs/dist/chunk-YYUSCGVI.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"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";var _chunkRCWM55DEcjs = require('../chunk-RCWM55DE.cjs');require('../chunk-XZC34BHM.cjs');require('../chunk-OIYXOKTT.cjs');var _chunkY2FETC6Tcjs = require('../chunk-Y2FETC6T.cjs');require('../chunk-33XNWMPP.cjs');require('../chunk-XNJLSA6P.cjs');require('../chunk-DDEQFR3M.cjs');require('../chunk-54BTOQE3.cjs');require('../chunk-QVIAMSZ6.cjs');var _chunk6JJIZCVYcjs = require('../chunk-6JJIZCVY.cjs');var _react = require('react');var _swr = require('swr');var _jsxruntime = require('react/jsx-runtime');function k({fallback:r,children:n}){return _react.useEffect.call(void 0, ()=>{Object.entries(r).some(([e,o])=>e?!1:(console.warn("SWRFallback",e,o),_chunkY2FETC6Tcjs.b.captureException(new (0, _chunk6JJIZCVYcjs.f)({message:"Empty key in SWRFallback. This will lead to wrong query returns when key is null. Should be reported to SWR.",level:"warning",extra:{key:e,value:o}})),!0))},[r]),_jsxruntime.jsx.call(void 0, _swr.SWRConfig,{value:{fallback:r},children:n})}exports.BeraFlagsProvider = _chunkRCWM55DEcjs.a; exports.BexStateContext = _chunkRCWM55DEcjs.d; exports.BexStatusProvider = _chunkRCWM55DEcjs.f; exports.BlockTimeContext = _chunkRCWM55DEcjs.h; exports.BlockTimeProvider = _chunkRCWM55DEcjs.i; exports.HoneyConfigContext = _chunkRCWM55DEcjs.j; exports.HoneyConfigProvider = _chunkRCWM55DEcjs.k; exports.SWRFallback = k; exports.TokenContext = _chunkRCWM55DEcjs.n; exports.TokensProvider = _chunkRCWM55DEcjs.o; exports.useBeraFlag = _chunkRCWM55DEcjs.c; exports.useBeraFlags = _chunkRCWM55DEcjs.b; exports.useBexStatus = _chunkRCWM55DEcjs.e; exports.useBlockTime = _chunkRCWM55DEcjs.g; exports.useHoneyConfig = _chunkRCWM55DEcjs.l;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";var _chunkJZL5JPDJcjs = require('../chunk-JZL5JPDJ.cjs');require('../chunk-DDEQFR3M.cjs');require('../chunk-GEIY554A.cjs');require('../chunk-PFUVKW6F.cjs');require('../chunk-XNJLSA6P.cjs');var _chunkF4V5B6F7cjs = require('../chunk-F4V5B6F7.cjs');require('../chunk-OIYXOKTT.cjs');require('../chunk-FDEUAXET.cjs');require('../chunk-FQSOUEIJ.cjs');var _chunkDKZGCMH4cjs = require('../chunk-DKZGCMH4.cjs');var _react = require('react');var _swr = require('swr');var _jsxruntime = require('react/jsx-runtime');function k({fallback:r,children:n}){return _react.useEffect.call(void 0, ()=>{Object.entries(r).some(([e,o])=>e?!1:(console.warn("SWRFallback",e,o),_chunkF4V5B6F7cjs.b.captureException(new (0, _chunkDKZGCMH4cjs.h)({message:"Empty key in SWRFallback. This will lead to wrong query returns when key is null. Should be reported to SWR.",level:"warning",extra:{key:e,value:o}})),!0))},[r]),_jsxruntime.jsx.call(void 0, _swr.SWRConfig,{value:{fallback:r},children:n})}exports.BeraFlagsProvider = _chunkJZL5JPDJcjs.a; exports.BexStateContext = _chunkJZL5JPDJcjs.d; exports.BexStatusProvider = _chunkJZL5JPDJcjs.f; exports.BlockTimeContext = _chunkJZL5JPDJcjs.h; exports.BlockTimeProvider = _chunkJZL5JPDJcjs.i; exports.HoneyConfigContext = _chunkJZL5JPDJcjs.j; exports.HoneyConfigProvider = _chunkJZL5JPDJcjs.k; exports.SWRFallback = k; exports.TokenContext = _chunkJZL5JPDJcjs.n; exports.TokensProvider = _chunkJZL5JPDJcjs.o; exports.useBeraFlag = _chunkJZL5JPDJcjs.c; exports.useBeraFlags = _chunkJZL5JPDJcjs.b; exports.useBexStatus = _chunkJZL5JPDJcjs.e; exports.useBlockTime = _chunkJZL5JPDJcjs.g; exports.useHoneyConfig = _chunkJZL5JPDJcjs.l;
2
2
  //# sourceMappingURL=exports.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/contexts/exports.cjs","../../src/contexts/SwrFallback.tsx"],"names":["SWRFallback","fallback","children","useEffect","key","value","BeraMonitoring","BeraError","jsx","SWRConfig"],"mappings":"AAAA,qFAAY,CAAC,yDAAoI,iCAA8B,iCAA8B,yDAA0C,iCAA8B,iCAA8B,iCAA8B,iCAA8B,iCAA8B,yDAA0C,8BCC7Z,0BACA,+CAiCtB,SA5BYA,CAAAA,CAAY,CAC1B,QAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CACF,CAAA,CAGG,CACD,OAAAC,8BAAAA,CAAU,CAAA,EAAM,CACd,MAAA,CAAO,OAAA,CAAQF,CAAQ,CAAA,CAAE,IAAA,CAAK,CAAC,CAACG,CAAAA,CAAKC,CAAK,CAAA,CAAA,EACnCD,CAAAA,CAcS,CAAA,CAAA,CAAA,CAbZ,OAAA,CAAQ,IAAA,CAAK,aAAA,CAAeA,CAAAA,CAAKC,CAAK,CAAA,CACtCC,mBAAAA,CAAe,gBAAA,CACb,IAAIC,wBAAAA,CAAU,CACZ,OAAA,CACE,8GAAA,CACF,KAAA,CAAO,SAAA,CACP,KAAA,CAAO,CACL,GAAA,CAAAH,CAAAA,CACA,KAAA,CAAAC,CACF,CACF,CAAC,CACH,CAAA,CACO,CAAA,CAAA,CAEV,CACH,CAAA,CAAG,CAACJ,CAAQ,CAAC,CAAA,CAGXO,6BAAAA,cAACC,CAAA,CACC,KAAA,CAAO,CACL,QAAA,CAAAR,CACF,CAAA,CAEC,QAAA,CAAAC,CAAAA,CACH,CAEJ,CAAA,sqBAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/contexts/exports.cjs","sourcesContent":[null,"import type React from \"react\";\nimport { useEffect } from \"react\";\nimport { SWRConfig } from \"swr\";\n\nimport { BeraError } from \"../errors/BeraError\";\nimport { BeraMonitoring } from \"../errors/BeraMonitoring\";\n\nexport function SWRFallback({\n fallback,\n children,\n}: {\n fallback: Record<string, any>;\n children: React.ReactNode;\n}) {\n useEffect(() => {\n Object.entries(fallback).some(([key, value]) => {\n if (!key) {\n console.warn(\"SWRFallback\", key, value);\n BeraMonitoring.captureException(\n new BeraError({\n message:\n \"Empty key in SWRFallback. This will lead to wrong query returns when key is null. Should be reported to SWR.\",\n level: \"warning\",\n extra: {\n key,\n value,\n },\n }),\n );\n return true;\n } else return false;\n });\n }, [fallback]);\n\n return (\n <SWRConfig\n value={{\n fallback,\n }}\n >\n {children}\n </SWRConfig>\n );\n}\n"]}
1
+ {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/contexts/exports.cjs","../../src/contexts/SwrFallback.tsx"],"names":["SWRFallback","fallback","children","useEffect","key","value","BeraMonitoring","BeraError","jsx","SWRConfig"],"mappings":"AAAA,qFAAY,CAAC,yDAAoI,iCAA8B,iCAA8B,iCAA8B,iCAA8B,yDAA0C,iCAA8B,iCAA8B,iCAA8B,yDAA0C,8BCC7Z,0BACA,+CAiCtB,SA5BYA,CAAAA,CAAY,CAC1B,QAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CACF,CAAA,CAGG,CACD,OAAAC,8BAAAA,CAAU,CAAA,EAAM,CACd,MAAA,CAAO,OAAA,CAAQF,CAAQ,CAAA,CAAE,IAAA,CAAK,CAAC,CAACG,CAAAA,CAAKC,CAAK,CAAA,CAAA,EACnCD,CAAAA,CAcS,CAAA,CAAA,CAAA,CAbZ,OAAA,CAAQ,IAAA,CAAK,aAAA,CAAeA,CAAAA,CAAKC,CAAK,CAAA,CACtCC,mBAAAA,CAAe,gBAAA,CACb,IAAIC,wBAAAA,CAAU,CACZ,OAAA,CACE,8GAAA,CACF,KAAA,CAAO,SAAA,CACP,KAAA,CAAO,CACL,GAAA,CAAAH,CAAAA,CACA,KAAA,CAAAC,CACF,CACF,CAAC,CACH,CAAA,CACO,CAAA,CAAA,CAEV,CACH,CAAA,CAAG,CAACJ,CAAQ,CAAC,CAAA,CAGXO,6BAAAA,cAACC,CAAA,CACC,KAAA,CAAO,CACL,QAAA,CAAAR,CACF,CAAA,CAEC,QAAA,CAAAC,CAAAA,CACH,CAEJ,CAAA,sqBAAA","file":"/Users/pong/coding/monobera/packages/berajs/dist/contexts/exports.cjs","sourcesContent":[null,"import type React from \"react\";\nimport { useEffect } from \"react\";\nimport { SWRConfig } from \"swr\";\n\nimport { BeraError } from \"../errors/BeraError\";\nimport { BeraMonitoring } from \"../errors/BeraMonitoring\";\n\nexport function SWRFallback({\n fallback,\n children,\n}: {\n fallback: Record<string, any>;\n children: React.ReactNode;\n}) {\n useEffect(() => {\n Object.entries(fallback).some(([key, value]) => {\n if (!key) {\n console.warn(\"SWRFallback\", key, value);\n BeraMonitoring.captureException(\n new BeraError({\n message:\n \"Empty key in SWRFallback. This will lead to wrong query returns when key is null. Should be reported to SWR.\",\n level: \"warning\",\n extra: {\n key,\n value,\n },\n }),\n );\n return true;\n } else return false;\n });\n }, [fallback]);\n\n return (\n <SWRConfig\n value={{\n fallback,\n }}\n >\n {children}\n </SWRConfig>\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- "use client";import{a as i,b as l,c as m,d as c,e as u,f as g,g as R,h as x,i as d,j as F,k as S,l as w,n as B,o as W}from"../chunk-JIPSTWKO.mjs";import"../chunk-K5L2B4DU.mjs";import"../chunk-NAXAZJJY.mjs";import{b as a}from"../chunk-ZW2N63FI.mjs";import"../chunk-5QAFKFM5.mjs";import"../chunk-575OK77P.mjs";import"../chunk-MK5NS5B5.mjs";import"../chunk-WLJHFHKF.mjs";import"../chunk-KUQEX7H3.mjs";import{f as t}from"../chunk-GXV2JA36.mjs";import{useEffect as p}from"react";import{SWRConfig as f}from"swr";import{jsx as s}from"react/jsx-runtime";function k({fallback:r,children:n}){return p(()=>{Object.entries(r).some(([e,o])=>e?!1:(console.warn("SWRFallback",e,o),a.captureException(new t({message:"Empty key in SWRFallback. This will lead to wrong query returns when key is null. Should be reported to SWR.",level:"warning",extra:{key:e,value:o}})),!0))},[r]),s(f,{value:{fallback:r},children:n})}export{i as BeraFlagsProvider,c as BexStateContext,g as BexStatusProvider,x as BlockTimeContext,d as BlockTimeProvider,F as HoneyConfigContext,S as HoneyConfigProvider,k as SWRFallback,B as TokenContext,W as TokensProvider,m as useBeraFlag,l as useBeraFlags,u as useBexStatus,R as useBlockTime,w as useHoneyConfig};
1
+ "use client";import{a as i,b as l,c as m,d as c,e as u,f as g,g as R,h as x,i as d,j as F,k as S,l as w,n as B,o as W}from"../chunk-OYF32BQQ.mjs";import"../chunk-MK5NS5B5.mjs";import"../chunk-XCVDZUEF.mjs";import"../chunk-2VO2D4QO.mjs";import"../chunk-575OK77P.mjs";import{b as a}from"../chunk-A5BNPBXN.mjs";import"../chunk-NAXAZJJY.mjs";import"../chunk-JHUVLM54.mjs";import"../chunk-TU63NRNL.mjs";import{h as t}from"../chunk-5SIQ7BKT.mjs";import{useEffect as p}from"react";import{SWRConfig as f}from"swr";import{jsx as s}from"react/jsx-runtime";function k({fallback:r,children:n}){return p(()=>{Object.entries(r).some(([e,o])=>e?!1:(console.warn("SWRFallback",e,o),a.captureException(new t({message:"Empty key in SWRFallback. This will lead to wrong query returns when key is null. Should be reported to SWR.",level:"warning",extra:{key:e,value:o}})),!0))},[r]),s(f,{value:{fallback:r},children:n})}export{i as BeraFlagsProvider,c as BexStateContext,g as BexStatusProvider,x as BlockTimeContext,d as BlockTimeProvider,F as HoneyConfigContext,S as HoneyConfigProvider,k as SWRFallback,B as TokenContext,W as TokensProvider,m as useBeraFlag,l as useBeraFlags,u as useBexStatus,R as useBlockTime,w as useHoneyConfig};
2
2
  //# sourceMappingURL=exports.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/enum/exports.cjs","../../src/enum/slippage.ts"],"names":["DEFAULT_SLIPPAGE","SLIPPAGE_DEGEN_VALUE","DEFAULT_DEADLINE","SLIPPAGE_MODE","TRANSACTION_MODE"],"mappings":"AAAA,kIAA0F,yDAA0C,ICAvHA,CAAAA,CAAmB,EAAA,CACnBC,CAAAA,gCAAuB,EAAA,CAKvBC,CAAAA,4BAAmB,EAAA,CAEpBC,CAAAA,yBAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,IAAA,CAAO,MAAA,CACPA,CAAAA,CAAA,MAAA,CAAS,QAAA,CACTA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CAHEA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAMAC,CAAAA,4BAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,IAAA,CAAO,MAAA,CACPA,CAAAA,CAAA,MAAA,CAAS,QAAA,CACTA,CAAAA,CAAA,QAAA,CAAW,UAAA,CAHDA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAAA,gjBAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/enum/exports.cjs","sourcesContent":[null,"export const DEFAULT_SLIPPAGE = 0.5 as const; // 2%\nexport const SLIPPAGE_DEGEN_VALUE = 25 as const; // 25%\n\n/**\n * Default\n */\nexport const DEFAULT_DEADLINE = 60 as const; // seconds\n\nexport enum SLIPPAGE_MODE {\n AUTO = \"auto\",\n CUSTOM = \"custom\",\n DEGEN = \"degen\",\n}\n\nexport enum TRANSACTION_MODE {\n AUTO = \"auto\",\n CUSTOM = \"custom\",\n INFINITY = \"infinity\",\n}\n"]}
1
+ {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/enum/exports.cjs","../../src/enum/slippage.ts"],"names":["DEFAULT_SLIPPAGE","SLIPPAGE_DEGEN_VALUE","DEFAULT_DEADLINE","SLIPPAGE_MODE","TRANSACTION_MODE"],"mappings":"AAAA,kIAA0F,yDAA0C,ICAvHA,CAAAA,CAAmB,EAAA,CACnBC,CAAAA,gCAAuB,EAAA,CAKvBC,CAAAA,4BAAmB,EAAA,CAEpBC,CAAAA,yBAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,IAAA,CAAO,MAAA,CACPA,CAAAA,CAAA,MAAA,CAAS,QAAA,CACTA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CAHEA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAMAC,CAAAA,4BAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,IAAA,CAAO,MAAA,CACPA,CAAAA,CAAA,MAAA,CAAS,QAAA,CACTA,CAAAA,CAAA,QAAA,CAAW,UAAA,CAHDA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAAA,gjBAAA","file":"/Users/pong/coding/monobera/packages/berajs/dist/enum/exports.cjs","sourcesContent":[null,"export const DEFAULT_SLIPPAGE = 0.5 as const; // 2%\nexport const SLIPPAGE_DEGEN_VALUE = 25 as const; // 25%\n\n/**\n * Default\n */\nexport const DEFAULT_DEADLINE = 60 as const; // seconds\n\nexport enum SLIPPAGE_MODE {\n AUTO = \"auto\",\n CUSTOM = \"custom\",\n DEGEN = \"degen\",\n}\n\nexport enum TRANSACTION_MODE {\n AUTO = \"auto\",\n CUSTOM = \"custom\",\n INFINITY = \"infinity\",\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/enum/governance/exports.cjs"],"names":[],"mappings":"AAAA,qIAAwE,kOAAyG","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/enum/governance/exports.cjs"}
1
+ {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/enum/governance/exports.cjs"],"names":[],"mappings":"AAAA,qIAAwE,kOAAyG","file":"/Users/pong/coding/monobera/packages/berajs/dist/enum/governance/exports.cjs"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkREWME3FYcjs = require('../chunk-REWME3FY.cjs');var _chunkY2FETC6Tcjs = require('../chunk-Y2FETC6T.cjs');var _chunk33XNWMPPcjs = require('../chunk-33XNWMPP.cjs');var _chunkS4CDSVLKcjs = require('../chunk-S4CDSVLK.cjs');var _chunk6JJIZCVYcjs = require('../chunk-6JJIZCVY.cjs');exports.BeraError = _chunk6JJIZCVYcjs.f; exports.BeraMonitoring = _chunkY2FETC6Tcjs.b; exports.BeraTracing = _chunkS4CDSVLKcjs.a; exports.InvalidArgumentError = _chunk6JJIZCVYcjs.h; exports.NotFoundError = _chunkREWME3FYcjs.a; exports.RequestError = _chunk6JJIZCVYcjs.g; exports.TransactionFailedError = _chunkREWME3FYcjs.b; exports.assertAddress = _chunk33XNWMPPcjs.c; exports.assertAmount = _chunk33XNWMPPcjs.e; exports.assertDefined = _chunk33XNWMPPcjs.a; exports.assertPositive = _chunk33XNWMPPcjs.d; exports.assertPublicClient = _chunk33XNWMPPcjs.b; exports.findMatchingError = _chunk6JJIZCVYcjs.a; exports.getErrorMessage = _chunk6JJIZCVYcjs.b; exports.initBeraError = _chunkY2FETC6Tcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkW4JE2NINcjs = require('../chunk-W4JE2NIN.cjs');var _chunkF4V5B6F7cjs = require('../chunk-F4V5B6F7.cjs');var _chunkS4CDSVLKcjs = require('../chunk-S4CDSVLK.cjs');var _chunkFQSOUEIJcjs = require('../chunk-FQSOUEIJ.cjs');var _chunkDKZGCMH4cjs = require('../chunk-DKZGCMH4.cjs');exports.BeraError = _chunkDKZGCMH4cjs.h; exports.BeraMonitoring = _chunkF4V5B6F7cjs.b; exports.BeraTracing = _chunkS4CDSVLKcjs.a; exports.InvalidArgumentError = _chunkDKZGCMH4cjs.j; exports.NotFoundError = _chunkW4JE2NINcjs.a; exports.RequestError = _chunkDKZGCMH4cjs.i; exports.TransactionFailedError = _chunkW4JE2NINcjs.b; exports.assertAddress = _chunkFQSOUEIJcjs.c; exports.assertAmount = _chunkFQSOUEIJcjs.e; exports.assertDefined = _chunkFQSOUEIJcjs.a; exports.assertPositive = _chunkFQSOUEIJcjs.d; exports.assertPublicClient = _chunkFQSOUEIJcjs.b; exports.findMatchingError = _chunkDKZGCMH4cjs.a; exports.getErrorMessage = _chunkDKZGCMH4cjs.b; exports.httpStatusToSpanStatus = _chunkDKZGCMH4cjs.f; exports.initBeraError = _chunkF4V5B6F7cjs.a; exports.reasonToSpanStatus = _chunkDKZGCMH4cjs.g;
2
2
  //# sourceMappingURL=exports.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/errors/exports.cjs"],"names":[],"mappings":"AAAA,kIAAgD,yDAAiD,yDAAsE,yDAA0C,yDAAsE,urBAA0T","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/errors/exports.cjs"}
1
+ {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/errors/exports.cjs"],"names":[],"mappings":"AAAA,kIAAgD,yDAAiD,yDAA0C,yDAAsE,yDAAoF,+xBAA8W","file":"/Users/pong/coding/monobera/packages/berajs/dist/errors/exports.cjs"}
@@ -1,8 +1,9 @@
1
1
  import { GetPublicClientReturnType } from '@wagmi/core';
2
2
  import { Address, PublicClient, TransactionReceipt } from 'viem';
3
- import { B as BeraError, S as SeverityLevel, I as IBeraErrorArgs } from '../BeraError-_mQdkanr.cjs';
4
- import { E as EmitterMixin } from '../RequestError-DSUzJ1Iy.cjs';
5
- export { B as BeraTracing, R as RequestError, S as SpanContext } from '../RequestError-DSUzJ1Iy.cjs';
3
+ import { B as BeraError, S as SeverityLevel, I as IBeraErrorArgs } from '../BeraError-7-A5JYy_.cjs';
4
+ export { a as SpanStatusType, h as httpStatusToSpanStatus, r as reasonToSpanStatus } from '../BeraError-7-A5JYy_.cjs';
5
+ import { E as EmitterMixin } from '../RequestError-02juqN-5.cjs';
6
+ export { B as BeraTracing, R as RequestError, S as SpanContext } from '../RequestError-02juqN-5.cjs';
6
7
  import { Hex } from '@berachain-foundation/berancer-sdk';
7
8
  import '@apollo/client';
8
9
 
@@ -1,8 +1,9 @@
1
1
  import { GetPublicClientReturnType } from '@wagmi/core';
2
2
  import { Address, PublicClient, TransactionReceipt } from 'viem';
3
- import { B as BeraError, S as SeverityLevel, I as IBeraErrorArgs } from '../BeraError-_mQdkanr.js';
4
- import { E as EmitterMixin } from '../RequestError-BRIiJgHk.js';
5
- export { B as BeraTracing, R as RequestError, S as SpanContext } from '../RequestError-BRIiJgHk.js';
3
+ import { B as BeraError, S as SeverityLevel, I as IBeraErrorArgs } from '../BeraError-7-A5JYy_.js';
4
+ export { a as SpanStatusType, h as httpStatusToSpanStatus, r as reasonToSpanStatus } from '../BeraError-7-A5JYy_.js';
5
+ import { E as EmitterMixin } from '../RequestError-DBOIV65x.js';
6
+ export { B as BeraTracing, R as RequestError, S as SpanContext } from '../RequestError-DBOIV65x.js';
6
7
  import { Hex } from '@berachain-foundation/berancer-sdk';
7
8
  import '@apollo/client';
8
9
 
@@ -1,2 +1,2 @@
1
- import{a as C,b as g}from"../chunk-RJN36GBU.mjs";import{a as m,b as e}from"../chunk-ZW2N63FI.mjs";import{a as n,b as y,c as a,d as i,e as v}from"../chunk-5QAFKFM5.mjs";import{a as r}from"../chunk-PRLVZIKD.mjs";import{a as o,b as t,f as p,g as x,h as f}from"../chunk-GXV2JA36.mjs";export{p as BeraError,e as BeraMonitoring,r as BeraTracing,f as InvalidArgumentError,C as NotFoundError,x as RequestError,g as TransactionFailedError,a as assertAddress,v as assertAmount,n as assertDefined,i as assertPositive,y as assertPublicClient,o as findMatchingError,t as getErrorMessage,m as initBeraError};
1
+ import{a as v,b as T}from"../chunk-OCAMR6XC.mjs";import{a as n,b as e}from"../chunk-A5BNPBXN.mjs";import{a as o}from"../chunk-PRLVZIKD.mjs";import{a as S,b as y,c as s,d as i,e as u}from"../chunk-TU63NRNL.mjs";import{a as p,b as x,f as t,g as r,h as a,i as f,j as m}from"../chunk-5SIQ7BKT.mjs";export{a as BeraError,e as BeraMonitoring,o as BeraTracing,m as InvalidArgumentError,v as NotFoundError,f as RequestError,T as TransactionFailedError,s as assertAddress,u as assertAmount,S as assertDefined,i as assertPositive,y as assertPublicClient,p as findMatchingError,x as getErrorMessage,t as httpStatusToSpanStatus,n as initBeraError,r as reasonToSpanStatus};
2
2
  //# sourceMappingURL=exports.mjs.map
@@ -1,9 +1,9 @@
1
1
  import { Config, GetWalletClientReturnType } from '@wagmi/core';
2
- import { SWRConfiguration, SWRResponse } from 'swr';
2
+ import { SWRResponse, SWRConfiguration } from 'swr';
3
3
  import { Abi, ContractFunctionName, ContractFunctionArgs, TransactionReceipt, WalletCallReceipt, Hex, Account, Address } from 'viem';
4
4
  import { ChainId, BeraConfig } from '@berachain/config';
5
5
  import { T as TransactionActionType, C as ContractName } from './txnEnum-CwAJN4zV.js';
6
- import { B as BeraError } from './BeraError-_mQdkanr.js';
6
+ import { B as BeraError } from './BeraError-7-A5JYy_.js';
7
7
 
8
8
  interface UseContractWriteApi {
9
9
  isLoading: boolean;
@@ -1,9 +1,9 @@
1
1
  import { Config, GetWalletClientReturnType } from '@wagmi/core';
2
- import { SWRConfiguration, SWRResponse } from 'swr';
2
+ import { SWRResponse, SWRConfiguration } from 'swr';
3
3
  import { Abi, ContractFunctionName, ContractFunctionArgs, TransactionReceipt, WalletCallReceipt, Hex, Account, Address } from 'viem';
4
4
  import { ChainId, BeraConfig } from '@berachain/config';
5
5
  import { T as TransactionActionType, C as ContractName } from './txnEnum-CwAJN4zV.cjs';
6
- import { B as BeraError } from './BeraError-_mQdkanr.cjs';
6
+ import { B as BeraError } from './BeraError-7-A5JYy_.cjs';
7
7
 
8
8
  interface UseContractWriteApi {
9
9
  isLoading: boolean;