@prb/effect-evm 1.0.0-beta.5 → 1.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/constants/index.d.ts +0 -4
  2. package/dist/constants/index.d.ts.map +1 -1
  3. package/dist/constants/index.js +1 -5
  4. package/dist/constants/index.js.map +1 -1
  5. package/dist/contract/pipeline/internal/core.d.ts +2 -2
  6. package/dist/contract/pipeline/internal/core.d.ts.map +1 -1
  7. package/dist/contract/pipeline/internal/core.js.map +1 -1
  8. package/dist/contract/pipeline/internal/receipt.d.ts +2 -2
  9. package/dist/contract/pipeline/internal/receipt.d.ts.map +1 -1
  10. package/dist/contract/pipeline/internal/receipt.js +1 -1
  11. package/dist/contract/pipeline/internal/receipt.js.map +1 -1
  12. package/dist/contract/pipeline/service.d.ts +3 -3
  13. package/dist/contract/pipeline/service.d.ts.map +1 -1
  14. package/dist/contract/pipeline/service.js.map +1 -1
  15. package/dist/contract/pipeline/types.d.ts +2 -2
  16. package/dist/contract/pipeline/types.d.ts.map +1 -1
  17. package/dist/contract/pipeline/types.js.map +1 -1
  18. package/dist/contract/pipeline/write-and-track.d.ts.map +1 -1
  19. package/dist/contract/pipeline/write-and-track.js +5 -6
  20. package/dist/contract/pipeline/write-and-track.js.map +1 -1
  21. package/dist/contract/pipeline/write-and-wait.d.ts +1 -1
  22. package/dist/contract/pipeline/write-and-wait.d.ts.map +1 -1
  23. package/dist/core/errors/transaction.d.ts +7 -7
  24. package/dist/core/errors/transaction.d.ts.map +1 -1
  25. package/dist/core/errors/transaction.js +2 -2
  26. package/dist/core/errors/transaction.js.map +1 -1
  27. package/dist/core/errors/viem-mapper.d.ts +3 -3
  28. package/dist/core/errors/viem-mapper.d.ts.map +1 -1
  29. package/dist/core/errors/viem-mapper.js +3 -3
  30. package/dist/core/errors/viem-mapper.js.map +1 -1
  31. package/dist/deploy/service.d.ts +3 -3
  32. package/dist/deploy/service.d.ts.map +1 -1
  33. package/dist/deploy/service.js.map +1 -1
  34. package/dist/eip7702/errors.d.ts +3 -3
  35. package/dist/eip7702/errors.d.ts.map +1 -1
  36. package/dist/eip7702/errors.js +1 -1
  37. package/dist/eip7702/errors.js.map +1 -1
  38. package/dist/eip7702/service.d.ts +8 -8
  39. package/dist/eip7702/service.d.ts.map +1 -1
  40. package/dist/eip7702/service.js +2 -2
  41. package/dist/eip7702/service.js.map +1 -1
  42. package/dist/react-hooks/index.d.ts +0 -4
  43. package/dist/react-hooks/index.d.ts.map +1 -1
  44. package/dist/react-hooks/index.js +0 -4
  45. package/dist/react-hooks/index.js.map +1 -1
  46. package/dist/subscriptions/pending-tx.d.ts +1 -1
  47. package/dist/subscriptions/pending-tx.d.ts.map +1 -1
  48. package/dist/subscriptions/pending-tx.js +1 -1
  49. package/dist/subscriptions/pending-tx.js.map +1 -1
  50. package/dist/subscriptions/service.d.ts +2 -2
  51. package/dist/subscriptions/service.d.ts.map +1 -1
  52. package/dist/subscriptions/service.js +4 -4
  53. package/dist/subscriptions/service.js.map +1 -1
  54. package/dist/testing-kit/mock-subscription-service.d.ts +2 -2
  55. package/dist/testing-kit/mock-subscription-service.d.ts.map +1 -1
  56. package/dist/testing-kit/mock-subscription-service.js +5 -5
  57. package/dist/testing-kit/mock-subscription-service.js.map +1 -1
  58. package/dist/testing-kit/mock-transfer-service.d.ts +3 -3
  59. package/dist/testing-kit/mock-transfer-service.d.ts.map +1 -1
  60. package/dist/testing-kit/mock-transfer-service.js.map +1 -1
  61. package/dist/transfer/service.d.ts +3 -3
  62. package/dist/transfer/service.d.ts.map +1 -1
  63. package/dist/transfer/service.js +3 -3
  64. package/dist/transfer/service.js.map +1 -1
  65. package/dist/tx/manager.d.ts +3 -2
  66. package/dist/tx/manager.d.ts.map +1 -1
  67. package/dist/tx/manager.js +232 -216
  68. package/dist/tx/manager.js.map +1 -1
  69. package/dist/tx/manager.test.integration.js +25 -5
  70. package/dist/tx/manager.test.integration.js.map +1 -1
  71. package/dist/tx/policy.d.ts +0 -1
  72. package/dist/tx/policy.d.ts.map +1 -1
  73. package/dist/tx/policy.js.map +1 -1
  74. package/dist/tx/replacement.d.ts +3 -3
  75. package/dist/tx/replacement.d.ts.map +1 -1
  76. package/dist/tx/replacement.js +3 -3
  77. package/dist/tx/replacement.js.map +1 -1
  78. package/dist/tx/tracker.d.ts +6 -6
  79. package/dist/tx/tracker.d.ts.map +1 -1
  80. package/dist/tx/tracker.js +9 -9
  81. package/dist/tx/tracker.js.map +1 -1
  82. package/dist/types/params.d.ts +1 -1
  83. package/dist/types/params.d.ts.map +1 -1
  84. package/dist/types/params.js.map +1 -1
  85. package/dist/wallet/errors.d.ts +3 -3
  86. package/dist/wallet/errors.d.ts.map +1 -1
  87. package/dist/wallet/errors.js +1 -1
  88. package/dist/wallet/errors.js.map +1 -1
  89. package/dist/wallet/operations.d.ts +2 -2
  90. package/dist/wallet/operations.d.ts.map +1 -1
  91. package/dist/wallet/operations.js +2 -2
  92. package/dist/wallet/operations.js.map +1 -1
  93. package/dist/wallet/service.d.ts +2 -2
  94. package/dist/wallet/service.d.ts.map +1 -1
  95. package/dist/wallet/service.js.map +1 -1
  96. package/package.json +1 -6
  97. package/dist/react-hooks/safe-app-origins.d.ts +0 -8
  98. package/dist/react-hooks/safe-app-origins.d.ts.map +0 -1
  99. package/dist/react-hooks/safe-app-origins.js +0 -124
  100. package/dist/react-hooks/safe-app-origins.js.map +0 -1
  101. package/dist/react-hooks/use-is-host-safe-app.d.ts +0 -2
  102. package/dist/react-hooks/use-is-host-safe-app.d.ts.map +0 -1
  103. package/dist/react-hooks/use-is-host-safe-app.js +0 -16
  104. package/dist/react-hooks/use-is-host-safe-app.js.map +0 -1
  105. package/dist/react-hooks/use-is-safe-app-context.d.ts +0 -2
  106. package/dist/react-hooks/use-is-safe-app-context.d.ts.map +0 -1
  107. package/dist/react-hooks/use-is-safe-app-context.js +0 -41
  108. package/dist/react-hooks/use-is-safe-app-context.js.map +0 -1
  109. package/dist/react-hooks/use-is-safe-multisig-wallet.d.ts +0 -2
  110. package/dist/react-hooks/use-is-safe-multisig-wallet.d.ts.map +0 -1
  111. package/dist/react-hooks/use-is-safe-multisig-wallet.js +0 -24
  112. package/dist/react-hooks/use-is-safe-multisig-wallet.js.map +0 -1
  113. package/dist/safe/adapter.d.ts +0 -9
  114. package/dist/safe/adapter.d.ts.map +0 -1
  115. package/dist/safe/adapter.js +0 -13
  116. package/dist/safe/adapter.js.map +0 -1
  117. package/dist/safe/detection.d.ts +0 -26
  118. package/dist/safe/detection.d.ts.map +0 -1
  119. package/dist/safe/detection.js +0 -102
  120. package/dist/safe/detection.js.map +0 -1
  121. package/dist/safe/detection.test.integration.d.ts +0 -2
  122. package/dist/safe/detection.test.integration.d.ts.map +0 -1
  123. package/dist/safe/detection.test.integration.js +0 -92
  124. package/dist/safe/detection.test.integration.js.map +0 -1
  125. package/dist/safe/errors.d.ts +0 -79
  126. package/dist/safe/errors.d.ts.map +0 -1
  127. package/dist/safe/errors.js +0 -34
  128. package/dist/safe/errors.js.map +0 -1
  129. package/dist/safe/index.d.ts +0 -8
  130. package/dist/safe/index.d.ts.map +0 -1
  131. package/dist/safe/index.js +0 -6
  132. package/dist/safe/index.js.map +0 -1
  133. package/dist/safe/live.d.ts +0 -8
  134. package/dist/safe/live.d.ts.map +0 -1
  135. package/dist/safe/live.js +0 -250
  136. package/dist/safe/live.js.map +0 -1
  137. package/dist/safe/service.d.ts +0 -26
  138. package/dist/safe/service.d.ts.map +0 -1
  139. package/dist/safe/service.js +0 -4
  140. package/dist/safe/service.js.map +0 -1
  141. package/dist/safe/service.test.integration.d.ts +0 -2
  142. package/dist/safe/service.test.integration.d.ts.map +0 -1
  143. package/dist/safe/service.test.integration.js +0 -171
  144. package/dist/safe/service.test.integration.js.map +0 -1
  145. package/dist/safe/simulation/abis.d.ts +0 -73
  146. package/dist/safe/simulation/abis.d.ts.map +0 -1
  147. package/dist/safe/simulation/abis.js +0 -61
  148. package/dist/safe/simulation/abis.js.map +0 -1
  149. package/dist/safe/simulation/addresses.d.ts +0 -4
  150. package/dist/safe/simulation/addresses.d.ts.map +0 -1
  151. package/dist/safe/simulation/addresses.js +0 -54
  152. package/dist/safe/simulation/addresses.js.map +0 -1
  153. package/dist/safe/simulation/encoding.d.ts +0 -16
  154. package/dist/safe/simulation/encoding.d.ts.map +0 -1
  155. package/dist/safe/simulation/encoding.js +0 -36
  156. package/dist/safe/simulation/encoding.js.map +0 -1
  157. package/dist/safe/simulation/errors.d.ts +0 -56
  158. package/dist/safe/simulation/errors.d.ts.map +0 -1
  159. package/dist/safe/simulation/errors.js +0 -37
  160. package/dist/safe/simulation/errors.js.map +0 -1
  161. package/dist/safe/simulation/index.d.ts +0 -7
  162. package/dist/safe/simulation/index.d.ts.map +0 -1
  163. package/dist/safe/simulation/index.js +0 -6
  164. package/dist/safe/simulation/index.js.map +0 -1
  165. package/dist/safe/simulation/internal/calldata/calldata.d.ts +0 -5
  166. package/dist/safe/simulation/internal/calldata/calldata.d.ts.map +0 -1
  167. package/dist/safe/simulation/internal/calldata/calldata.js +0 -17
  168. package/dist/safe/simulation/internal/calldata/calldata.js.map +0 -1
  169. package/dist/safe/simulation/internal/calldata/index.d.ts +0 -2
  170. package/dist/safe/simulation/internal/calldata/index.d.ts.map +0 -1
  171. package/dist/safe/simulation/internal/calldata/index.js +0 -2
  172. package/dist/safe/simulation/internal/calldata/index.js.map +0 -1
  173. package/dist/safe/simulation/internal/contracts/contracts.d.ts +0 -5
  174. package/dist/safe/simulation/internal/contracts/contracts.d.ts.map +0 -1
  175. package/dist/safe/simulation/internal/contracts/contracts.js +0 -25
  176. package/dist/safe/simulation/internal/contracts/contracts.js.map +0 -1
  177. package/dist/safe/simulation/internal/contracts/index.d.ts +0 -2
  178. package/dist/safe/simulation/internal/contracts/index.d.ts.map +0 -1
  179. package/dist/safe/simulation/internal/contracts/index.js +0 -2
  180. package/dist/safe/simulation/internal/contracts/index.js.map +0 -1
  181. package/dist/safe/simulation/internal/evaluation/evaluation.d.ts +0 -6
  182. package/dist/safe/simulation/internal/evaluation/evaluation.d.ts.map +0 -1
  183. package/dist/safe/simulation/internal/evaluation/evaluation.js +0 -20
  184. package/dist/safe/simulation/internal/evaluation/evaluation.js.map +0 -1
  185. package/dist/safe/simulation/internal/evaluation/index.d.ts +0 -2
  186. package/dist/safe/simulation/internal/evaluation/index.d.ts.map +0 -1
  187. package/dist/safe/simulation/internal/evaluation/index.js +0 -2
  188. package/dist/safe/simulation/internal/evaluation/index.js.map +0 -1
  189. package/dist/safe/simulation/internal/execution/execution.d.ts +0 -9
  190. package/dist/safe/simulation/internal/execution/execution.d.ts.map +0 -1
  191. package/dist/safe/simulation/internal/execution/execution.js +0 -65
  192. package/dist/safe/simulation/internal/execution/execution.js.map +0 -1
  193. package/dist/safe/simulation/internal/execution/index.d.ts +0 -2
  194. package/dist/safe/simulation/internal/execution/index.d.ts.map +0 -1
  195. package/dist/safe/simulation/internal/execution/index.js +0 -2
  196. package/dist/safe/simulation/internal/execution/index.js.map +0 -1
  197. package/dist/safe/simulation/internal/limits/index.d.ts +0 -2
  198. package/dist/safe/simulation/internal/limits/index.d.ts.map +0 -1
  199. package/dist/safe/simulation/internal/limits/index.js +0 -2
  200. package/dist/safe/simulation/internal/limits/index.js.map +0 -1
  201. package/dist/safe/simulation/internal/limits/limits.d.ts +0 -5
  202. package/dist/safe/simulation/internal/limits/limits.d.ts.map +0 -1
  203. package/dist/safe/simulation/internal/limits/limits.js +0 -18
  204. package/dist/safe/simulation/internal/limits/limits.js.map +0 -1
  205. package/dist/safe/simulation/internal/types/index.d.ts +0 -2
  206. package/dist/safe/simulation/internal/types/index.d.ts.map +0 -1
  207. package/dist/safe/simulation/internal/types/index.js +0 -2
  208. package/dist/safe/simulation/internal/types/index.js.map +0 -1
  209. package/dist/safe/simulation/internal/types/types.d.ts +0 -11
  210. package/dist/safe/simulation/internal/types/types.d.ts.map +0 -1
  211. package/dist/safe/simulation/internal/types/types.js +0 -2
  212. package/dist/safe/simulation/internal/types/types.js.map +0 -1
  213. package/dist/safe/simulation/internal/validation/index.d.ts +0 -2
  214. package/dist/safe/simulation/internal/validation/index.d.ts.map +0 -1
  215. package/dist/safe/simulation/internal/validation/index.js +0 -2
  216. package/dist/safe/simulation/internal/validation/index.js.map +0 -1
  217. package/dist/safe/simulation/internal/validation/validation.d.ts +0 -5
  218. package/dist/safe/simulation/internal/validation/validation.d.ts.map +0 -1
  219. package/dist/safe/simulation/internal/validation/validation.js +0 -27
  220. package/dist/safe/simulation/internal/validation/validation.js.map +0 -1
  221. package/dist/safe/simulation/service.d.ts +0 -14
  222. package/dist/safe/simulation/service.d.ts.map +0 -1
  223. package/dist/safe/simulation/service.js +0 -25
  224. package/dist/safe/simulation/service.js.map +0 -1
  225. package/dist/safe/simulation/types.d.ts +0 -20
  226. package/dist/safe/simulation/types.d.ts.map +0 -1
  227. package/dist/safe/simulation/types.js +0 -2
  228. package/dist/safe/simulation/types.js.map +0 -1
  229. package/dist/safe/types.d.ts +0 -61
  230. package/dist/safe/types.d.ts.map +0 -1
  231. package/dist/safe/types.js +0 -2
  232. package/dist/safe/types.js.map +0 -1
@@ -1,9 +0,0 @@
1
- import { Effect } from "effect";
2
- import type { Address, Hex, PublicClient } from "viem";
3
- import { SafeSimulationFailedError, SimulationDecodeError } from "../../errors.js";
4
- import type { LatestBlock, SimulationDecoded } from "../types/index.js";
5
- export declare function extractRevertData(error: unknown): string | undefined;
6
- export declare function callSimulateAndExtractRevertData(client: PublicClient, safeAddress: Address, safeCalldata: Hex): Promise<string>;
7
- export declare function simulateAndDecode(client: PublicClient, safeAddress: Address, safeCalldata: Hex): Effect.Effect<SimulationDecoded, SafeSimulationFailedError | SimulationDecodeError>;
8
- export declare function fetchLatestBlock(client: PublicClient): Effect.Effect<LatestBlock, SafeSimulationFailedError>;
9
- //# sourceMappingURL=execution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/execution/execution.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAGvD,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAKxE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAiBpE;AAKD,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,OAAO,EACpB,YAAY,EAAE,GAAG,GAChB,OAAO,CAAC,MAAM,CAAC,CAejB;AAKD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,OAAO,EACpB,YAAY,EAAE,GAAG,GAChB,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,yBAAyB,GAAG,qBAAqB,CAAC,CAqBrF;AAKD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,YAAY,GACnB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,yBAAyB,CAAC,CASvD"}
@@ -1,65 +0,0 @@
1
- import { Effect } from "effect";
2
- import { BaseError as CoreError } from "viem";
3
- import { decodeSimulationData } from "../../encoding.js";
4
- import { SafeSimulationFailedError, SimulationDecodeError } from "../../errors.js";
5
- export function extractRevertData(error) {
6
- if (!(error instanceof CoreError)) {
7
- return undefined;
8
- }
9
- const revertError = error.walk((err) => {
10
- const typedErr = err;
11
- return typeof typedErr.data === "string";
12
- });
13
- if (!revertError) {
14
- return undefined;
15
- }
16
- const typedErr = revertError;
17
- const extractedData = typedErr.data;
18
- return typeof extractedData === "string" ? extractedData : undefined;
19
- }
20
- export async function callSimulateAndExtractRevertData(client, safeAddress, safeCalldata) {
21
- try {
22
- await client.call({
23
- account: safeAddress,
24
- data: safeCalldata,
25
- to: safeAddress,
26
- });
27
- throw new Error("simulateAndRevert did not revert");
28
- }
29
- catch (error) {
30
- const revertData = extractRevertData(error);
31
- if (revertData) {
32
- return revertData;
33
- }
34
- throw error;
35
- }
36
- }
37
- export function simulateAndDecode(client, safeAddress, safeCalldata) {
38
- return Effect.gen(function* () {
39
- const revertData = yield* Effect.tryPromise({
40
- catch: (error) => new SafeSimulationFailedError({
41
- cause: error,
42
- message: "Network error or unexpected behavior during simulation",
43
- }),
44
- try: () => callSimulateAndExtractRevertData(client, safeAddress, safeCalldata),
45
- });
46
- return yield* Effect.try({
47
- catch: (error) => new SimulationDecodeError({
48
- cause: error,
49
- message: "Failed to decode simulation revert data - unexpected format",
50
- revertData,
51
- }),
52
- try: () => decodeSimulationData(revertData),
53
- });
54
- });
55
- }
56
- export function fetchLatestBlock(client) {
57
- return Effect.tryPromise({
58
- catch: (e) => new SafeSimulationFailedError({
59
- cause: e,
60
- message: `Failed to fetch block: ${e}`,
61
- }),
62
- try: () => client.getBlock({ blockTag: "latest" }),
63
- });
64
- }
65
- //# sourceMappingURL=execution.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/execution/execution.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,SAAS,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAMnF,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC,EAAE,CAAC;QAClC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI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,GAAG,EAAE,CAAC,gCAAgC,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC;SAC/E,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACf,IAAI,qBAAqB,CAAC;gBACxB,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE,6DAA6D;gBACtE,UAAU;aACX,CAAC;YACJ,GAAG,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,UAAU,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAKD,MAAM,UAAU,gBAAgB,CAC9B,MAAoB;IAEpB,OAAO,MAAM,CAAC,UAAU,CAAC;QACvB,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CACX,IAAI,yBAAyB,CAAC;YAC5B,KAAK,EAAE,CAAC;YACR,OAAO,EAAE,0BAA0B,CAAC,EAAE;SACvC,CAAC;QACJ,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;KACnD,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * On-chain execution and decoding helpers for Safe simulation.\n */\nimport { Effect } from \"effect\";\nimport type { Address, Hex, PublicClient } from \"viem\";\nimport { BaseError as CoreError } from \"viem\";\nimport { decodeSimulationData } from \"../../encoding.js\";\nimport { SafeSimulationFailedError, SimulationDecodeError } from \"../../errors.js\";\nimport type { LatestBlock, SimulationDecoded } from \"../types/index.js\";\n\n/**\n * Extract revert data from a viem CoreError tree, if present.\n */\nexport function extractRevertData(error: unknown): string | undefined {\n if (!(error instanceof CoreError)) {\n return undefined;\n }\n\n const revertError = error.walk((err) => {\n const typedErr = err as unknown as Record<string, unknown>;\n return typeof typedErr.data === \"string\";\n });\n\n if (!revertError) {\n return undefined;\n }\n\n const typedErr = revertError as unknown as Record<string, unknown>;\n const extractedData = typedErr.data;\n return typeof extractedData === \"string\" ? extractedData : undefined;\n}\n\n/**\n * Execute simulateAndRevert and return the revert data payload.\n */\nexport async function callSimulateAndExtractRevertData(\n client: PublicClient,\n safeAddress: Address,\n safeCalldata: Hex\n): Promise<string> {\n try {\n await client.call({\n account: safeAddress,\n data: safeCalldata,\n to: safeAddress,\n });\n throw new Error(\"simulateAndRevert did not revert\");\n } catch (error: unknown) {\n const revertData = extractRevertData(error);\n if (revertData) {\n return revertData;\n }\n throw error;\n }\n}\n\n/**\n * Run the on-chain call and decode the revert payload into a gas estimate.\n */\nexport function simulateAndDecode(\n client: PublicClient,\n safeAddress: Address,\n safeCalldata: Hex\n): Effect.Effect<SimulationDecoded, SafeSimulationFailedError | SimulationDecodeError> {\n return Effect.gen(function* () {\n const revertData = yield* Effect.tryPromise({\n catch: (error) =>\n new SafeSimulationFailedError({\n cause: error,\n message: \"Network error or unexpected behavior during simulation\",\n }),\n try: () => callSimulateAndExtractRevertData(client, safeAddress, safeCalldata),\n });\n\n return yield* Effect.try({\n catch: (error) =>\n new SimulationDecodeError({\n cause: error,\n message: \"Failed to decode simulation revert data - unexpected format\",\n revertData,\n }),\n try: () => decodeSimulationData(revertData),\n });\n });\n}\n\n/**\n * Fetch the latest block to derive the gas threshold.\n */\nexport function fetchLatestBlock(\n client: PublicClient\n): Effect.Effect<LatestBlock, SafeSimulationFailedError> {\n return Effect.tryPromise({\n catch: (e) =>\n new SafeSimulationFailedError({\n cause: e,\n message: `Failed to fetch block: ${e}`,\n }),\n try: () => client.getBlock({ blockTag: \"latest\" }),\n });\n}\n"]}
@@ -1,2 +0,0 @@
1
- export { callSimulateAndExtractRevertData, extractRevertData, fetchLatestBlock, simulateAndDecode, } from "./execution.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC"}
@@ -1,2 +0,0 @@
1
- export { callSimulateAndExtractRevertData, extractRevertData, fetchLatestBlock, simulateAndDecode, } from "./execution.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC","sourcesContent":["export {\n callSimulateAndExtractRevertData,\n extractRevertData,\n fetchLatestBlock,\n simulateAndDecode,\n} from \"./execution.js\";\n"]}
@@ -1,2 +0,0 @@
1
- export { enforceTxSizeLimit } from "./limits.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/limits/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
@@ -1,2 +0,0 @@
1
- export { enforceTxSizeLimit } from "./limits.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/limits/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { enforceTxSizeLimit } from \"./limits.js\";\n"]}
@@ -1,5 +0,0 @@
1
- import { Effect } from "effect";
2
- import type { Hex } from "viem";
3
- import { TransactionSizeTooLargeError } from "../../errors.js";
4
- export declare function enforceTxSizeLimit(safeCalldata: Hex, txSizeLimit?: number): Effect.Effect<void, TransactionSizeTooLargeError>;
5
- //# sourceMappingURL=limits.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/limits/limits.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAK/D,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,GAAG,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,4BAA4B,CAAC,CAiBnD"}
@@ -1,18 +0,0 @@
1
- import { Effect } from "effect";
2
- import { TransactionSizeTooLargeError } from "../../errors.js";
3
- export function enforceTxSizeLimit(safeCalldata, txSizeLimit) {
4
- if (!txSizeLimit) {
5
- return Effect.void;
6
- }
7
- return Effect.gen(function* () {
8
- const sizeInBytes = (safeCalldata.length - 2) / 2;
9
- if (sizeInBytes > txSizeLimit) {
10
- return yield* Effect.fail(new TransactionSizeTooLargeError({
11
- actualSize: sizeInBytes,
12
- maxSize: txSizeLimit,
13
- message: `Transaction size (${sizeInBytes} bytes) exceeds chain limit (${txSizeLimit} bytes). Try splitting into smaller batches.`,
14
- }));
15
- }
16
- });
17
- }
18
- //# sourceMappingURL=limits.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"limits.js","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/limits/limits.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAK/D,MAAM,UAAU,kBAAkB,CAChC,YAAiB,EACjB,WAAoB;IAEpB,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzB,MAAM,WAAW,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAClD,IAAI,WAAW,GAAG,WAAW,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,IAAI,4BAA4B,CAAC;gBAC/B,UAAU,EAAE,WAAW;gBACvB,OAAO,EAAE,WAAW;gBACpB,OAAO,EAAE,qBAAqB,WAAW,gCAAgC,WAAW,8CAA8C;aACnI,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Size limit enforcement for Safe simulation calldata.\n */\nimport { Effect } from \"effect\";\nimport type { Hex } from \"viem\";\nimport { TransactionSizeTooLargeError } from \"../../errors.js\";\n\n/**\n * Enforce chain-specific transaction size constraints (if provided).\n */\nexport function enforceTxSizeLimit(\n safeCalldata: Hex,\n txSizeLimit?: number\n): Effect.Effect<void, TransactionSizeTooLargeError> {\n if (!txSizeLimit) {\n return Effect.void;\n }\n\n return Effect.gen(function* () {\n const sizeInBytes = (safeCalldata.length - 2) / 2;\n if (sizeInBytes > txSizeLimit) {\n return yield* Effect.fail(\n new TransactionSizeTooLargeError({\n actualSize: sizeInBytes,\n maxSize: txSizeLimit,\n message: `Transaction size (${sizeInBytes} bytes) exceeds chain limit (${txSizeLimit} bytes). Try splitting into smaller batches.`,\n })\n );\n }\n });\n}\n"]}
@@ -1,2 +0,0 @@
1
- export type { LatestBlock, SafeContracts, SimulationDecoded } from "./types.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type { LatestBlock, SafeContracts, SimulationDecoded } from \"./types.js\";\n"]}
@@ -1,11 +0,0 @@
1
- import type { Address, PublicClient } from "viem";
2
- export type SafeContracts = {
3
- readonly multiSendAddr: Address;
4
- readonly simulateAccessorAddr: Address;
5
- };
6
- export type SimulationDecoded = {
7
- readonly gas: bigint;
8
- readonly success: boolean;
9
- };
10
- export type LatestBlock = Awaited<ReturnType<PublicClient["getBlock"]>>;
11
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/types/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAKlD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;CACxC,CAAC;AAKF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAKF,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/types/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Shared type definitions for Safe simulation internals.\n */\nimport type { Address, PublicClient } from \"viem\";\n\n/**\n * Resolved Safe contract addresses required for simulation.\n */\nexport type SafeContracts = {\n readonly multiSendAddr: Address;\n readonly simulateAccessorAddr: Address;\n};\n\n/**\n * Decoded revert payload for simulateAndRevert.\n */\nexport type SimulationDecoded = {\n readonly gas: bigint;\n readonly success: boolean;\n};\n\n/**\n * Block type alias used by helpers to avoid re-deriving it everywhere.\n */\nexport type LatestBlock = Awaited<ReturnType<PublicClient[\"getBlock\"]>>;\n"]}
@@ -1,2 +0,0 @@
1
- export { validateSimulationParams } from "./validation.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,2 +0,0 @@
1
- export { validateSimulationParams } from "./validation.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { validateSimulationParams } from \"./validation.js\";\n"]}
@@ -1,5 +0,0 @@
1
- import { Effect } from "effect";
2
- import { InvalidGasThresholdError, SafeSimulationFailedError } from "../../errors.js";
3
- import type { SafeSimulateBatchParams } from "../../types.js";
4
- export declare function validateSimulationParams(params: SafeSimulateBatchParams): Effect.Effect<SafeSimulateBatchParams, InvalidGasThresholdError | SafeSimulationFailedError>;
5
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/validation/validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAK9D,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,uBAAuB,GAC9B,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,wBAAwB,GAAG,yBAAyB,CAAC,CAkC9F"}
@@ -1,27 +0,0 @@
1
- import { Effect } from "effect";
2
- import { zeroAddress } from "viem";
3
- import { InvalidGasThresholdError, SafeSimulationFailedError } from "../../errors.js";
4
- export function validateSimulationParams(params) {
5
- return Effect.gen(function* () {
6
- const { gasThresholdPercent, safeAddress, transactions } = params;
7
- if (transactions.length === 0) {
8
- return yield* Effect.fail(new SafeSimulationFailedError({
9
- message: "Cannot simulate empty transaction batch",
10
- }));
11
- }
12
- if (safeAddress === zeroAddress) {
13
- return yield* Effect.fail(new SafeSimulationFailedError({
14
- message: "Invalid Safe address: cannot be zero address",
15
- }));
16
- }
17
- if (gasThresholdPercent !== undefined &&
18
- (gasThresholdPercent < 1 || gasThresholdPercent > 100)) {
19
- return yield* Effect.fail(new InvalidGasThresholdError({
20
- message: "gasThresholdPercent must be between 1 and 100 (inclusive)",
21
- value: gasThresholdPercent,
22
- }));
23
- }
24
- return params;
25
- });
26
- }
27
- //# sourceMappingURL=validation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../src/safe/simulation/internal/validation/validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAMtF,MAAM,UAAU,wBAAwB,CACtC,MAA+B;IAE/B,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzB,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;QAElE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,IAAI,yBAAyB,CAAC;gBAC5B,OAAO,EAAE,yCAAyC;aACnD,CAAC,CACH,CAAC;QACJ,CAAC;QAED,IAAI,WAAW,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,IAAI,yBAAyB,CAAC;gBAC5B,OAAO,EAAE,8CAA8C;aACxD,CAAC,CACH,CAAC;QACJ,CAAC;QAED,IACE,mBAAmB,KAAK,SAAS;YACjC,CAAC,mBAAmB,GAAG,CAAC,IAAI,mBAAmB,GAAG,GAAG,CAAC,EACtD,CAAC;YACD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,IAAI,wBAAwB,CAAC;gBAC3B,OAAO,EAAE,2DAA2D;gBACpE,KAAK,EAAE,mBAAmB;aAC3B,CAAC,CACH,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Input validation for Safe batch simulation parameters.\n */\nimport { Effect } from \"effect\";\nimport { zeroAddress } from \"viem\";\nimport { InvalidGasThresholdError, SafeSimulationFailedError } from \"../../errors.js\";\nimport type { SafeSimulateBatchParams } from \"../../types.js\";\n\n/**\n * Validate user-supplied simulation inputs before any chain calls.\n */\nexport function validateSimulationParams(\n params: SafeSimulateBatchParams\n): Effect.Effect<SafeSimulateBatchParams, InvalidGasThresholdError | SafeSimulationFailedError> {\n return Effect.gen(function* () {\n const { gasThresholdPercent, safeAddress, transactions } = params;\n\n if (transactions.length === 0) {\n return yield* Effect.fail(\n new SafeSimulationFailedError({\n message: \"Cannot simulate empty transaction batch\",\n })\n );\n }\n\n if (safeAddress === zeroAddress) {\n return yield* Effect.fail(\n new SafeSimulationFailedError({\n message: \"Invalid Safe address: cannot be zero address\",\n })\n );\n }\n\n if (\n gasThresholdPercent !== undefined &&\n (gasThresholdPercent < 1 || gasThresholdPercent > 100)\n ) {\n return yield* Effect.fail(\n new InvalidGasThresholdError({\n message: \"gasThresholdPercent must be between 1 and 100 (inclusive)\",\n value: gasThresholdPercent,\n })\n );\n }\n\n return params;\n });\n}\n"]}
@@ -1,14 +0,0 @@
1
- import { Context, Effect, Layer } from "effect";
2
- import type { ClientNotFoundError } from "../../core/index.js";
3
- import { PublicClientService } from "../../core/index.js";
4
- import type { GasLimitOverflowError, InvalidGasThresholdError, SafeContractsNotDeployedError, SafeSimulationFailedError, SimulationDecodeError, TransactionSizeTooLargeError } from "./errors.js";
5
- import type { SafeSimulateBatchParams, SafeSimulationResult } from "./types.js";
6
- export type SafeSimulationServiceShape = {
7
- readonly simulateBatch: (params: SafeSimulateBatchParams) => Effect.Effect<SafeSimulationResult, ClientNotFoundError | InvalidGasThresholdError | SafeContractsNotDeployedError | TransactionSizeTooLargeError | SafeSimulationFailedError | SimulationDecodeError | GasLimitOverflowError>;
8
- };
9
- declare const SafeSimulationService_base: Context.TagClass<SafeSimulationService, "ew3/SafeSimulation", SafeSimulationServiceShape>;
10
- export declare class SafeSimulationService extends SafeSimulationService_base {
11
- }
12
- export declare const SafeSimulationServiceLive: Layer.Layer<SafeSimulationService, never, PublicClientService>;
13
- export {};
14
- //# sourceMappingURL=service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/safe/simulation/service.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,EAC7B,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC7B,MAAM,aAAa,CAAC;AAOrB,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEhF,MAAM,MAAM,0BAA0B,GAAG;IAUvC,QAAQ,CAAC,aAAa,EAAE,CACtB,MAAM,EAAE,uBAAuB,KAC5B,MAAM,CAAC,MAAM,CAChB,oBAAoB,EAClB,mBAAmB,GACnB,wBAAwB,GACxB,6BAA6B,GAC7B,4BAA4B,GAC5B,yBAAyB,GACzB,qBAAqB,GACrB,qBAAqB,CACxB,CAAC;CACH,CAAC;;AAEF,qBAAa,qBAAsB,SAAQ,0BAGxC;CAAG;AAEN,eAAO,MAAM,yBAAyB,gEAyBrC,CAAC"}
@@ -1,25 +0,0 @@
1
- import { Context, Effect, Layer } from "effect";
2
- import { PublicClientService } from "../../core/index.js";
3
- import { buildSafeCalldata } from "./internal/calldata/index.js";
4
- import { resolveSafeContracts } from "./internal/contracts/index.js";
5
- import { evaluateSimulationResult } from "./internal/evaluation/index.js";
6
- import { fetchLatestBlock, simulateAndDecode } from "./internal/execution/index.js";
7
- import { enforceTxSizeLimit } from "./internal/limits/index.js";
8
- import { validateSimulationParams } from "./internal/validation/index.js";
9
- export class SafeSimulationService extends Context.Tag("ew3/SafeSimulation")() {
10
- }
11
- export const SafeSimulationServiceLive = Layer.effect(SafeSimulationService, Effect.gen(function* () {
12
- const publicClientService = yield* PublicClientService;
13
- return SafeSimulationService.of({
14
- simulateBatch: (params) => Effect.gen(function* () {
15
- const { chainId, safeAddress, transactions, txSizeLimit, gasThresholdPercent } = yield* validateSimulationParams(params);
16
- const contracts = yield* resolveSafeContracts(chainId);
17
- const safeCalldata = buildSafeCalldata(contracts, transactions);
18
- yield* enforceTxSizeLimit(safeCalldata, txSizeLimit);
19
- const client = yield* publicClientService.get(chainId);
20
- const [result, block] = yield* Effect.all([simulateAndDecode(client, safeAddress, safeCalldata), fetchLatestBlock(client)], { concurrency: "unbounded" });
21
- return yield* evaluateSimulationResult(result, block, gasThresholdPercent);
22
- }),
23
- });
24
- }));
25
- //# sourceMappingURL=service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/safe/simulation/service.ts"],"names":[],"mappings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K,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACvD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACvC,CAAC,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,EAChF,EAAE,WAAW,EAAE,WAAW,EAAE,CAC7B,CAAC;YAEF,OAAO,KAAK,CAAC,CAAC,wBAAwB,CAAC,MAAM,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC;QAC7E,CAAC,CAAC;KACL,CAAC,CAAC;AACL,CAAC,CAAC,CACH,CAAC","sourcesContent":["/**\n * Safe batch simulation service using Effect-TS.\n *\n * Simulates Safe multisig batch transactions to estimate gas consumption before execution.\n * Uses Safe's simulateAndRevert algorithm to get accurate gas estimates.\n *\n * @see https://github.com/safe-global/safe-smart-account/blob/c4859f4/contracts/common/StorageAccessible.sol#L32-L43\n */\n\nimport { Context, Effect, Layer } from \"effect\";\nimport type { ClientNotFoundError } from \"@/src/core/index.js\";\nimport { PublicClientService } from \"@/src/core/index.js\";\nimport type {\n GasLimitOverflowError,\n InvalidGasThresholdError,\n SafeContractsNotDeployedError,\n SafeSimulationFailedError,\n SimulationDecodeError,\n TransactionSizeTooLargeError,\n} from \"./errors.js\";\nimport { buildSafeCalldata } from \"./internal/calldata/index.js\";\nimport { resolveSafeContracts } from \"./internal/contracts/index.js\";\nimport { evaluateSimulationResult } from \"./internal/evaluation/index.js\";\nimport { fetchLatestBlock, simulateAndDecode } from \"./internal/execution/index.js\";\nimport { enforceTxSizeLimit } from \"./internal/limits/index.js\";\nimport { validateSimulationParams } from \"./internal/validation/index.js\";\nimport type { SafeSimulateBatchParams, SafeSimulationResult } from \"./types.js\";\n\nexport type SafeSimulationServiceShape = {\n /**\n * Simulate a batch of transactions in Safe context.\n *\n * Uses simulateAndRevert algorithm to estimate gas consumption. This always reverts,\n * and we decode the revert data to extract the gas estimate.\n *\n * @param params - Simulation parameters including chainId, safeAddress, and transactions\n * @returns Gas estimate and success flag\n */\n readonly simulateBatch: (\n params: SafeSimulateBatchParams\n ) => Effect.Effect<\n SafeSimulationResult,\n | ClientNotFoundError\n | InvalidGasThresholdError\n | SafeContractsNotDeployedError\n | TransactionSizeTooLargeError\n | SafeSimulationFailedError\n | SimulationDecodeError\n | GasLimitOverflowError\n >;\n};\n\nexport class SafeSimulationService extends Context.Tag(\"ew3/SafeSimulation\")<\n SafeSimulationService,\n SafeSimulationServiceShape\n>() {}\n\nexport const SafeSimulationServiceLive = Layer.effect(\n SafeSimulationService,\n Effect.gen(function* () {\n const publicClientService = yield* PublicClientService;\n\n return SafeSimulationService.of({\n simulateBatch: (params: SafeSimulateBatchParams) =>\n Effect.gen(function* () {\n const { chainId, safeAddress, transactions, txSizeLimit, gasThresholdPercent } =\n yield* validateSimulationParams(params);\n const contracts = yield* resolveSafeContracts(chainId);\n const safeCalldata = buildSafeCalldata(contracts, transactions);\n\n yield* enforceTxSizeLimit(safeCalldata, txSizeLimit);\n\n const client = yield* publicClientService.get(chainId);\n const [result, block] = yield* Effect.all(\n [simulateAndDecode(client, safeAddress, safeCalldata), fetchLatestBlock(client)],\n { concurrency: \"unbounded\" }\n );\n\n return yield* evaluateSimulationResult(result, block, gasThresholdPercent);\n }),\n });\n })\n);\n"]}
@@ -1,20 +0,0 @@
1
- import type { Address, Hex } from "viem";
2
- export type SafeOperation = 0 | 1;
3
- export type SafeSimulationTransaction = {
4
- data: Hex;
5
- operation?: SafeOperation;
6
- to: Address;
7
- value: bigint;
8
- };
9
- export type SafeSimulateBatchParams = {
10
- chainId: number;
11
- safeAddress: Address;
12
- transactions: SafeSimulationTransaction[];
13
- txSizeLimit?: number;
14
- gasThresholdPercent?: number;
15
- };
16
- export type SafeSimulationResult = {
17
- estimatedGas: bigint;
18
- success: boolean;
19
- };
20
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/safe/simulation/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAGzC,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC;AAGlC,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAGF,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAE1C,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAGF,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/safe/simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Type definitions for Safe multisig gas simulation operations.\n */\nimport type { Address, Hex } from \"viem\";\n\n/** Safe transaction operation type */\nexport type SafeOperation = 0 | 1; // 0 = Call, 1 = DelegateCall\n\n/** A single transaction in a Safe batch */\nexport type SafeSimulationTransaction = {\n data: Hex;\n operation?: SafeOperation;\n to: Address;\n value: bigint;\n};\n\n/** Parameters for simulating a Safe batch */\nexport type SafeSimulateBatchParams = {\n chainId: number;\n safeAddress: Address;\n transactions: SafeSimulationTransaction[];\n /** Optional transaction size limit in bytes (for ZK chains) */\n txSizeLimit?: number;\n /** Gas threshold as percentage of block gas limit (1-100, default 95) */\n gasThresholdPercent?: number;\n};\n\n/** Result of a successful Safe simulation */\nexport type SafeSimulationResult = {\n estimatedGas: bigint;\n success: boolean;\n};\n"]}
@@ -1,61 +0,0 @@
1
- import type { Address, Hash, Hex, TransactionReceipt } from "viem";
2
- export type SafeInfo = {
3
- chainId: number;
4
- safeAddress: Address;
5
- };
6
- export type SafeMultisigTx = {
7
- data: Hex;
8
- to: Address;
9
- value?: bigint;
10
- };
11
- export type SafeTxSubmission = {
12
- chainId: number;
13
- safeAddress: Address;
14
- safeTxHash: Hash;
15
- };
16
- export type SafeTxResult = {
17
- chainId: number;
18
- onchainHash: Hash;
19
- receipt: TransactionReceipt;
20
- safeAddress: Address;
21
- safeTxHash: Hash;
22
- };
23
- export type SignTypedDataResult = {
24
- readonly _tag: "Offchain";
25
- readonly messageHash: Hex;
26
- } | {
27
- readonly _tag: "Onchain";
28
- readonly safeTxHash: Hash;
29
- };
30
- export type OffchainSignatureResult = {
31
- messageHash: Hex;
32
- signature: Hex;
33
- };
34
- export type SafeWaitPolicy = {
35
- executionTimeout?: number;
36
- pollInterval?: number;
37
- receiptPolicy?: {
38
- pollingInterval?: number;
39
- receiptTimeout?: number;
40
- };
41
- };
42
- export type OffchainSignaturePolicy = {
43
- pollInterval?: number;
44
- timeout?: number;
45
- };
46
- export type EIP712TypedData = {
47
- domain: {
48
- chainId?: number;
49
- name?: string;
50
- salt?: string;
51
- verifyingContract?: string;
52
- version?: string;
53
- };
54
- message: Record<string, unknown>;
55
- primaryType?: string;
56
- types: Record<string, Array<{
57
- name: string;
58
- type: string;
59
- }>>;
60
- };
61
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/safe/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAGnE,MAAM,MAAM,QAAQ,GAA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,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE;QACN,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;CAC9D,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/safe/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address, Hash, Hex, TransactionReceipt } from \"viem\";\n\n/** Safe info returned from SDK */\nexport type SafeInfo = {\n chainId: number;\n safeAddress: Address;\n};\n\n/** Tx to send via Safe multisig */\nexport type SafeMultisigTx = {\n data: Hex;\n to: Address;\n value?: bigint; // Converted to string at SDK boundary\n};\n\n/** Result from sendTxs */\nexport type SafeTxSubmission = {\n chainId: number;\n safeAddress: Address;\n safeTxHash: Hash;\n};\n\n/** Result from waitForTxReceipt */\nexport type SafeTxResult = {\n chainId: number;\n onchainHash: Hash;\n receipt: TransactionReceipt;\n safeAddress: Address;\n safeTxHash: Hash;\n};\n\n/** Discriminated union for signTypedData result */\nexport type SignTypedDataResult =\n | { readonly _tag: \"Offchain\"; readonly messageHash: Hex }\n | { readonly _tag: \"Onchain\"; readonly safeTxHash: Hash };\n\n/** Off-chain signature result */\nexport type OffchainSignatureResult = {\n messageHash: Hex;\n signature: Hex;\n};\n\n/** Policy for Safe tx waiting (aligns with TxPolicy from src/tx/policy.ts) */\nexport type SafeWaitPolicy = {\n /** Timeout for Safe tx execution in ms (default: 300000 = 5 min) */\n executionTimeout?: number;\n /** Poll interval for Safe gateway in ms (default: 3000) */\n pollInterval?: number;\n /** Policy passed to TxManager.waitForReceipt */\n receiptPolicy?: {\n pollingInterval?: number;\n receiptTimeout?: number;\n };\n};\n\n/** Policy for off-chain signature polling */\nexport type OffchainSignaturePolicy = {\n /** Poll interval in ms (default: 2000) */\n pollInterval?: number;\n /** Timeout in ms (default: 120000 = 2 min) */\n timeout?: number;\n};\n\n/** EIP-712 typed data structure (local definition to avoid SDK import) */\nexport type EIP712TypedData = {\n domain: {\n chainId?: number;\n name?: string;\n salt?: string;\n verifyingContract?: string;\n version?: string;\n };\n message: Record<string, unknown>;\n primaryType?: string;\n types: Record<string, Array<{ name: string; type: string }>>;\n};\n"]}