@boostxyz/sdk 0.0.0-alpha.9 → 1.1.0-alpha.23

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 (254) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.cjs.map +1 -1
  3. package/dist/Actions/Action.js +2 -2
  4. package/dist/Actions/ContractAction.d.ts +11 -11
  5. package/dist/Actions/ContractAction.d.ts.map +1 -1
  6. package/dist/Actions/ERC721MintAction.d.ts +14 -14
  7. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  8. package/dist/Actions/EventAction.cjs +1 -1
  9. package/dist/Actions/EventAction.cjs.map +1 -1
  10. package/dist/Actions/EventAction.d.ts +174 -41
  11. package/dist/Actions/EventAction.d.ts.map +1 -1
  12. package/dist/Actions/EventAction.js +557 -129
  13. package/dist/Actions/EventAction.js.map +1 -1
  14. package/dist/AllowLists/AllowList.cjs +1 -1
  15. package/dist/AllowLists/AllowList.cjs.map +1 -1
  16. package/dist/AllowLists/AllowList.d.ts +6 -4
  17. package/dist/AllowLists/AllowList.d.ts.map +1 -1
  18. package/dist/AllowLists/AllowList.js +45 -23
  19. package/dist/AllowLists/AllowList.js.map +1 -1
  20. package/dist/AllowLists/OpenAllowList.d.ts +423 -0
  21. package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
  22. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  23. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  24. package/dist/AllowLists/SimpleAllowList.d.ts +92 -37
  25. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  26. package/dist/AllowLists/SimpleAllowList.js +60 -75
  27. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  28. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  29. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
  30. package/dist/AllowLists/SimpleDenyList.d.ts +203 -11
  31. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  32. package/dist/AllowLists/SimpleDenyList.js +11 -112
  33. package/dist/AllowLists/SimpleDenyList.js.map +1 -1
  34. package/dist/Auth/PassthroughAuth.cjs +1 -1
  35. package/dist/Auth/PassthroughAuth.js +1 -1
  36. package/dist/Boost.cjs +1 -1
  37. package/dist/Boost.cjs.map +1 -1
  38. package/dist/Boost.d.ts +20 -21
  39. package/dist/Boost.d.ts.map +1 -1
  40. package/dist/Boost.js +43 -57
  41. package/dist/Boost.js.map +1 -1
  42. package/dist/BoostCore-Btl5BdAs.cjs +3 -0
  43. package/dist/BoostCore-Btl5BdAs.cjs.map +1 -0
  44. package/dist/BoostCore-CD56zbYX.js +2641 -0
  45. package/dist/BoostCore-CD56zbYX.js.map +1 -0
  46. package/dist/BoostCore.cjs +1 -2
  47. package/dist/BoostCore.cjs.map +1 -1
  48. package/dist/BoostCore.d.ts +749 -78
  49. package/dist/BoostCore.d.ts.map +1 -1
  50. package/dist/BoostCore.js +29 -1150
  51. package/dist/BoostCore.js.map +1 -1
  52. package/dist/BoostRegistry.cjs +1 -1
  53. package/dist/BoostRegistry.cjs.map +1 -1
  54. package/dist/BoostRegistry.d.ts +80 -25
  55. package/dist/BoostRegistry.d.ts.map +1 -1
  56. package/dist/BoostRegistry.js +164 -82
  57. package/dist/BoostRegistry.js.map +1 -1
  58. package/dist/Budgets/Budget.cjs +1 -1
  59. package/dist/Budgets/Budget.cjs.map +1 -1
  60. package/dist/Budgets/Budget.d.ts.map +1 -1
  61. package/dist/Budgets/Budget.js +2 -2
  62. package/dist/Budgets/Budget.js.map +1 -1
  63. package/dist/Budgets/ManagedBudget.cjs +1 -1
  64. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  65. package/dist/Budgets/ManagedBudget.d.ts +103 -221
  66. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  67. package/dist/Budgets/ManagedBudget.js +81 -298
  68. package/dist/Budgets/ManagedBudget.js.map +1 -1
  69. package/dist/Budgets/VestingBudget.d.ts +223 -89
  70. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  71. package/dist/Deployable/Contract.cjs +1 -1
  72. package/dist/Deployable/Contract.cjs.map +1 -1
  73. package/dist/Deployable/Contract.d.ts +4 -5
  74. package/dist/Deployable/Contract.d.ts.map +1 -1
  75. package/dist/Deployable/Contract.js +5 -7
  76. package/dist/Deployable/Contract.js.map +1 -1
  77. package/dist/Deployable/Deployable.cjs.map +1 -1
  78. package/dist/Deployable/Deployable.d.ts +1 -1
  79. package/dist/Deployable/Deployable.d.ts.map +1 -1
  80. package/dist/Deployable/Deployable.js +3 -5
  81. package/dist/Deployable/Deployable.js.map +1 -1
  82. package/dist/Deployable/DeployableTarget.cjs +1 -1
  83. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  84. package/dist/Deployable/DeployableTarget.d.ts +13 -13
  85. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  86. package/dist/Deployable/DeployableTarget.js +28 -25
  87. package/dist/Deployable/DeployableTarget.js.map +1 -1
  88. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  89. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  90. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +248 -0
  91. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  92. package/dist/Deployable/DeployableTargetWithRBAC.js +320 -0
  93. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  94. package/dist/Incentive-CcnOIc8L.cjs +2 -0
  95. package/dist/Incentive-CcnOIc8L.cjs.map +1 -0
  96. package/dist/Incentive-rM5nKznp.js +313 -0
  97. package/dist/Incentive-rM5nKznp.js.map +1 -0
  98. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  99. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  100. package/dist/Incentives/AllowListIncentive.d.ts +38 -16
  101. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  102. package/dist/Incentives/AllowListIncentive.js +43 -29
  103. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  104. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  105. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  106. package/dist/Incentives/CGDAIncentive.d.ts +234 -21
  107. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  108. package/dist/Incentives/CGDAIncentive.js +46 -32
  109. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  110. package/dist/Incentives/ERC1155Incentive.d.ts +224 -37
  111. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  112. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  113. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  114. package/dist/Incentives/ERC20Incentive.d.ts +234 -30
  115. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  116. package/dist/Incentives/ERC20Incentive.js +62 -46
  117. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  118. package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +333 -438
  119. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  120. package/dist/Incentives/ERC20VariableIncentive.d.ts +231 -29
  121. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  122. package/dist/Incentives/Incentive.cjs +1 -1
  123. package/dist/Incentives/Incentive.cjs.map +1 -1
  124. package/dist/Incentives/Incentive.d.ts +4 -4
  125. package/dist/Incentives/Incentive.d.ts.map +1 -1
  126. package/dist/Incentives/Incentive.js +16 -296
  127. package/dist/Incentives/Incentive.js.map +1 -1
  128. package/dist/Incentives/PointsIncentive.cjs +1 -1
  129. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  130. package/dist/Incentives/PointsIncentive.d.ts +40 -18
  131. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  132. package/dist/Incentives/PointsIncentive.js +38 -24
  133. package/dist/Incentives/PointsIncentive.js.map +1 -1
  134. package/dist/SimpleDenyList-BDXpY74P.js +133 -0
  135. package/dist/SimpleDenyList-BDXpY74P.js.map +1 -0
  136. package/dist/SimpleDenyList-DNj5qDWM.cjs +2 -0
  137. package/dist/SimpleDenyList-DNj5qDWM.cjs.map +1 -0
  138. package/dist/Validators/SignerValidator.cjs +1 -1
  139. package/dist/Validators/SignerValidator.cjs.map +1 -1
  140. package/dist/Validators/SignerValidator.d.ts +16 -16
  141. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  142. package/dist/Validators/SignerValidator.js +32 -28
  143. package/dist/Validators/SignerValidator.js.map +1 -1
  144. package/dist/Validators/Validator.cjs +1 -1
  145. package/dist/Validators/Validator.cjs.map +1 -1
  146. package/dist/Validators/Validator.d.ts +1 -1
  147. package/dist/Validators/Validator.js +2 -2
  148. package/dist/Validators/Validator.js.map +1 -1
  149. package/dist/claiming.cjs.map +1 -1
  150. package/dist/claiming.d.ts +1 -1
  151. package/dist/claiming.js.map +1 -1
  152. package/dist/componentInterfaces-BBCFkrZv.js +14 -0
  153. package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
  154. package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
  155. package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
  156. package/dist/deployments-DF_6-7hH.cjs +2 -0
  157. package/dist/deployments-DF_6-7hH.cjs.map +1 -0
  158. package/dist/deployments-fJsWblwS.js +56 -0
  159. package/dist/deployments-fJsWblwS.js.map +1 -0
  160. package/dist/deployments.json +58 -0
  161. package/dist/errors.cjs +1 -1
  162. package/dist/errors.cjs.map +1 -1
  163. package/dist/errors.d.ts +256 -20
  164. package/dist/errors.d.ts.map +1 -1
  165. package/dist/errors.js +183 -26
  166. package/dist/errors.js.map +1 -1
  167. package/dist/{generated-57_Kffpz.js → generated-CsNyWPKA.js} +3843 -2084
  168. package/dist/generated-CsNyWPKA.js.map +1 -0
  169. package/dist/generated-DHerxf1y.cjs +3 -0
  170. package/dist/generated-DHerxf1y.cjs.map +1 -0
  171. package/dist/index.cjs +1 -1
  172. package/dist/index.d.ts +5 -0
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/index.js +142 -108
  175. package/dist/index.js.map +1 -1
  176. package/dist/transfers.cjs.map +1 -1
  177. package/dist/transfers.d.ts +1 -1
  178. package/dist/transfers.js.map +1 -1
  179. package/dist/utils.cjs +1 -1
  180. package/dist/utils.cjs.map +1 -1
  181. package/dist/utils.d.ts +26 -12
  182. package/dist/utils.d.ts.map +1 -1
  183. package/dist/utils.js +38 -23
  184. package/dist/utils.js.map +1 -1
  185. package/package.json +20 -10
  186. package/src/Actions/Action.test.ts +14 -13
  187. package/src/Actions/ContractAction.test.ts +10 -10
  188. package/src/Actions/ContractAction.ts +11 -12
  189. package/src/Actions/ERC721MintAction.test.ts +6 -6
  190. package/src/Actions/ERC721MintAction.ts +14 -15
  191. package/src/Actions/EventAction.test.ts +735 -109
  192. package/src/Actions/EventAction.ts +527 -88
  193. package/src/AllowLists/AllowList.test.ts +7 -7
  194. package/src/AllowLists/AllowList.ts +5 -3
  195. package/src/AllowLists/OpenAllowList.test.ts +40 -0
  196. package/src/AllowLists/OpenAllowList.ts +45 -0
  197. package/src/AllowLists/SimpleAllowList.test.ts +4 -4
  198. package/src/AllowLists/SimpleAllowList.ts +40 -61
  199. package/src/AllowLists/SimpleDenyList.test.ts +4 -4
  200. package/src/AllowLists/SimpleDenyList.ts +41 -17
  201. package/src/Auth/PassthroughAuth.test.ts +1 -1
  202. package/src/Boost.ts +21 -24
  203. package/src/BoostCore.test.ts +361 -306
  204. package/src/BoostCore.ts +403 -220
  205. package/src/BoostRegistry.test.ts +53 -0
  206. package/src/BoostRegistry.ts +161 -40
  207. package/src/Budgets/Budget.test.ts +2 -2
  208. package/src/Budgets/Budget.ts +1 -2
  209. package/src/Budgets/ManagedBudget.test.ts +106 -19
  210. package/src/Budgets/ManagedBudget.ts +49 -321
  211. package/src/Budgets/VestingBudget.test.ts +7 -7
  212. package/src/Budgets/VestingBudget.ts +36 -106
  213. package/src/Deployable/Contract.ts +4 -5
  214. package/src/Deployable/Deployable.ts +1 -1
  215. package/src/Deployable/DeployableTarget.ts +30 -19
  216. package/src/Deployable/DeployableTargetWithRBAC.test.ts +103 -0
  217. package/src/Deployable/DeployableTargetWithRBAC.ts +447 -0
  218. package/src/Incentives/AllowListIncentive.test.ts +12 -12
  219. package/src/Incentives/AllowListIncentive.ts +30 -15
  220. package/src/Incentives/CGDAIncentive.test.ts +9 -6
  221. package/src/Incentives/CGDAIncentive.ts +39 -18
  222. package/src/Incentives/ERC1155Incentive.test.ts +3 -3
  223. package/src/Incentives/ERC1155Incentive.ts +30 -29
  224. package/src/Incentives/ERC20Incentive.test.ts +9 -6
  225. package/src/Incentives/ERC20Incentive.ts +54 -27
  226. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  227. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +325 -0
  228. package/src/Incentives/ERC20VariableIncentive.test.ts +8 -11
  229. package/src/Incentives/ERC20VariableIncentive.ts +50 -26
  230. package/src/Incentives/Incentive.test.ts +4 -1
  231. package/src/Incentives/Incentive.ts +7 -6
  232. package/src/Incentives/PointsIncentive.test.ts +24 -25
  233. package/src/Incentives/PointsIncentive.ts +32 -17
  234. package/src/Validators/SignerValidator.test.ts +6 -6
  235. package/src/Validators/SignerValidator.ts +20 -17
  236. package/src/Validators/Validator.test.ts +2 -2
  237. package/src/Validators/Validator.ts +1 -1
  238. package/src/claiming.ts +1 -1
  239. package/src/errors.ts +345 -21
  240. package/src/index.test.ts +118 -36
  241. package/src/index.ts +5 -0
  242. package/src/transfers.ts +1 -1
  243. package/src/utils.test.ts +2 -2
  244. package/src/utils.ts +61 -12
  245. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  246. package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
  247. package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
  248. package/dist/componentInterfaces-DYkaxBda.js +0 -13
  249. package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
  250. package/dist/generated-57_Kffpz.js.map +0 -1
  251. package/dist/generated-wKBNvm48.cjs +0 -3
  252. package/dist/generated-wKBNvm48.cjs.map +0 -1
  253. package/src/Budgets/SimpleBudget.test.ts +0 -152
  254. package/src/Budgets/SimpleBudget.ts +0 -564
@@ -6,33 +6,46 @@ import {
6
6
  writeEventActionExecute,
7
7
  } from '@boostxyz/evm';
8
8
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/EventAction.sol/EventAction.json';
9
- import events from '@boostxyz/signatures/events';
9
+ import { getTransaction, getTransactionReceipt } from '@wagmi/core';
10
+ import { match } from 'ts-pattern';
10
11
  import {
11
- type Abi,
12
12
  type AbiEvent,
13
+ type AbiFunction,
14
+ AbiItem,
13
15
  type Address,
14
- type ContractEventName,
16
+ type ContractFunctionName,
17
+ type GetLogsReturnType,
15
18
  type Hex,
16
19
  type Log,
20
+ type PublicClient,
21
+ type Transaction,
22
+ decodeEventLog,
23
+ decodeFunctionData,
17
24
  encodeAbiParameters,
25
+ fromHex,
26
+ isAddress,
18
27
  isAddressEqual,
28
+ zeroHash,
19
29
  } from 'viem';
20
- import { getLogs } from 'viem/actions';
30
+ import { EventAction as EventActionBases } from '../../dist/deployments.json';
21
31
  import type {
22
32
  DeployableOptions,
23
33
  GenericDeployableParams,
24
34
  } from '../Deployable/Deployable';
25
35
  import { DeployableTarget } from '../Deployable/DeployableTarget';
26
36
  import {
37
+ DecodedArgsMalformedError,
27
38
  FieldValueNotComparableError,
28
39
  FieldValueUndefinedError,
40
+ FunctionDataDecodeError,
29
41
  InvalidNumericalCriteriaError,
30
42
  NoEventActionStepsProvidedError,
31
43
  TooManyEventActionStepsProvidedError,
44
+ UnparseableAbiParamError,
32
45
  UnrecognizedFilterTypeError,
46
+ ValidationAbiMissingError,
33
47
  } from '../errors';
34
48
  import {
35
- type GetLogsParams,
36
49
  type Overwrite,
37
50
  type ReadParams,
38
51
  RegistryType,
@@ -55,6 +68,7 @@ export enum FilterType {
55
68
  GREATER_THAN = 2,
56
69
  LESS_THAN = 3,
57
70
  CONTAINS = 4,
71
+ REGEX = 5,
58
72
  }
59
73
 
60
74
  /**
@@ -198,6 +212,22 @@ export interface ActionStep {
198
212
  */
199
213
  actionParameter: Criteria;
200
214
  }
215
+
216
+ /**
217
+ * Parameters for validating an action step.
218
+ *
219
+ * @typedef {Object} ValidateActionStepParams
220
+ * @property {Record<Hex, AbiEvent | AbiFunction>} [knownSignatures] - Record of known events, keyed by 32 byte selectors. You can use [@boostxyz/signatures](https://www.npmjs.com/package/@boostxyz/signatures) to assemble this parameter.
221
+ * @property {AbiEvent | AbiFunction} [abiItem] - Optional ABI item definition.
222
+ * @property {EventLogs} [logs] - Event logs to validate against. Required if 'hash' is not provided.
223
+ * @property {Hex} [hash] - Transaction hash to validate against. Required if 'logs' is not provided.
224
+ * @property {number} [chainId] - Chain ID for the transaction. Required if 'hash' is provided.
225
+ */
226
+ export type ValidateActionStepParams = {
227
+ knownSignatures: Record<Hex, AbiEvent | AbiFunction>;
228
+ abiItem?: AbiEvent | AbiFunction;
229
+ } & ({ logs: EventLogs } | { hash: Hex; chainId: number });
230
+
201
231
  /**
202
232
  * You can either supply a simplified version of the payload, or one that explicitly declares action steps.
203
233
  *
@@ -280,6 +310,24 @@ export interface EventActionPayloadRaw {
280
310
  actionStepFour: ActionStep;
281
311
  }
282
312
 
313
+ /**
314
+ * Array of event logs to pass into TxParams
315
+ * @export
316
+ * @typedef {EventLogs}
317
+ */
318
+ export type EventLogs = GetLogsReturnType<AbiEvent, AbiEvent[], true>;
319
+
320
+ /**
321
+ * Getter params from the event action contract
322
+ *
323
+ * @export
324
+ * @typedef {ReadEventActionParams}
325
+ * @param {fnName} fnName - The getter function name
326
+ */
327
+ export type ReadEventActionParams<
328
+ fnName extends ContractFunctionName<typeof eventActionAbi, 'pure' | 'view'>,
329
+ > = ReadParams<typeof eventActionAbi, fnName>;
330
+
283
331
  /**
284
332
  * A generic event action
285
333
  *
@@ -305,9 +353,12 @@ export class EventAction extends DeployableTarget<
305
353
  *
306
354
  * @public
307
355
  * @static
308
- * @type {Address}
356
+ * @type {Record<number, Address>}
309
357
  */
310
- public static override base: Address = import.meta.env.VITE_EVENT_ACTION_BASE;
358
+ public static override bases: Record<number, Address> = {
359
+ 31337: import.meta.env.VITE_EVENT_ACTION_BASE,
360
+ ...(EventActionBases as Record<number, Address>),
361
+ };
311
362
  /**
312
363
  * @inheritdoc
313
364
  *
@@ -323,12 +374,12 @@ export class EventAction extends DeployableTarget<
323
374
  * @public
324
375
  * @async
325
376
  * @param {number} index The index of the action event to retrieve
326
- * @param {?ReadParams<typeof eventActionAbi, 'getActionStep'>} [params]
377
+ * @param {?ReadEventActionParams<'getActionStep'>} [params]
327
378
  * @returns {Promise<ActionStep>}
328
379
  */
329
380
  public async getActionStep(
330
381
  index: number,
331
- params?: ReadParams<typeof eventActionAbi, 'getActionStep'>,
382
+ params?: ReadEventActionParams<'getActionStep'>,
332
383
  ) {
333
384
  const steps = await this.getActionSteps(params);
334
385
  return steps.at(index);
@@ -339,11 +390,11 @@ export class EventAction extends DeployableTarget<
339
390
  *
340
391
  * @public
341
392
  * @async
342
- * @param {?ReadParams<typeof eventActionAbi, 'getActionSteps'>} [params]
393
+ * @param {?ReadEventActionParams<'getActionSteps'>} [params]
343
394
  * @returns {Promise<ActionStep[]>}
344
395
  */
345
396
  public async getActionSteps(
346
- params?: ReadParams<typeof eventActionAbi, 'getActionSteps'>,
397
+ params?: ReadEventActionParams<'getActionSteps'>,
347
398
  ) {
348
399
  const steps = (await readEventActionGetActionSteps(this._config, {
349
400
  address: this.assertValidAddress(),
@@ -359,11 +410,11 @@ export class EventAction extends DeployableTarget<
359
410
  *
360
411
  * @public
361
412
  * @async
362
- * @param {?ReadParams<typeof eventActionAbi, 'getActionStepsCount'>} [params]
413
+ * @param {?ReadEventActionParams<'getActionStepsCount'>} [params]
363
414
  * @returns {Promise<bigint>}
364
415
  */
365
416
  public async getActionStepsCount(
366
- params?: ReadParams<typeof eventActionAbi, 'getActionStepsCount'>,
417
+ params?: ReadEventActionParams<'getActionStepsCount'>,
367
418
  ) {
368
419
  const steps = await this.getActionSteps(params);
369
420
  return steps.length;
@@ -374,17 +425,16 @@ export class EventAction extends DeployableTarget<
374
425
  *
375
426
  * @public
376
427
  * @async
377
- * @param {?ReadParams<typeof eventActionAbi, 'getActionClaimant'>} [params]
428
+ * @param {?ReadEventActionParams<'getActionClaimant'>} [params]
378
429
  * @returns {Promise<ActionClaimant>}
379
430
  */
380
431
  public async getActionClaimant(
381
- params?: ReadParams<typeof eventActionAbi, 'getActionClaimant'>,
382
- ) {
432
+ params?: ReadEventActionParams<'getActionClaimant'>,
433
+ ): Promise<ActionClaimant> {
383
434
  const result = (await readEventActionGetActionClaimant(this._config, {
384
435
  address: this.assertValidAddress(),
385
436
  ...this.optionallyAttachAccount(),
386
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
387
- ...(params as any),
437
+ ...params,
388
438
  })) as RawActionClaimant;
389
439
  return _fromRawActionStep(result);
390
440
  }
@@ -395,7 +445,7 @@ export class EventAction extends DeployableTarget<
395
445
  * @public
396
446
  * @async
397
447
  * @param {Hex} data
398
- * @param {?WriteParams<typeof eventActionAbi, 'execute'>} [params]
448
+ * @param {?WriteParams} [params]
399
449
  * @returns {Promise<readonly [boolean, `0x${string}`]>}
400
450
  */
401
451
  public async execute(
@@ -411,8 +461,8 @@ export class EventAction extends DeployableTarget<
411
461
  * @public
412
462
  * @async
413
463
  * @param {Hex} data
414
- * @param {?WriteParams<typeof eventActionAbi, 'execute'>} [params]
415
- * @returns {unknown}
464
+ * @param {?WriteParams} [params]
465
+ * @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
416
466
  */
417
467
  public async executeRaw(
418
468
  data: Hex,
@@ -429,27 +479,150 @@ export class EventAction extends DeployableTarget<
429
479
  return { hash, result };
430
480
  }
431
481
 
482
+ /**
483
+ * Derives the action claimant address from a transaction based on the provided ActionClaimant configuration.
484
+ * This method supports both event-based and function-based claimant derivation.
485
+ *
486
+ ** @example
487
+ * // Example usage
488
+ * const eventAction = boost.action as EventAction
489
+ * const claimant = await eventAction.getActionClaimant() // {
490
+ * signatureType: SignatureType.EVENT,
491
+ * signature: '0x1234...',
492
+ * fieldIndex: 2,
493
+ * targetContract: '0xabcd...',
494
+ * chainid: 1
495
+ * };
496
+ * const params: ValidateActionStepParams = {
497
+ * hash: '0x5678...',
498
+ * chainId: 1,
499
+ * knownSignatures: {
500
+ * '0x1234...': {
501
+ * type: 'event',
502
+ * name: 'Transfer(...)'
503
+ * }
504
+ * }
505
+ * };
506
+ * const claimantAddress = await eventAction.deriveActionClaimantFromTransaction(claimant, params);
507
+ *
508
+ * @param {ActionClaimant} claimant - The configuration specifying how to derive the claimant.
509
+ * @param {ValidateActionStepParams} params - Parameters for validation, including transaction hash, known signatures, logs, and chain ID.
510
+ * @returns {Promise<Address | undefined>} The derived claimant address if found, undefined otherwise.
511
+ * @throws {ValidationAbiMissingError} If the ABI for the specified signature is not found.
512
+ * @throws {FunctionDataDecodeError} If there's an error decoding function data (for function-based derivation).
513
+ */
514
+ public async deriveActionClaimantFromTransaction(
515
+ claimant: ActionClaimant,
516
+ params: ValidateActionStepParams,
517
+ ): Promise<Address | undefined> {
518
+ const signature = claimant.signature;
519
+ if (claimant.signatureType === SignatureType.EVENT) {
520
+ let event: AbiEvent;
521
+ if (params.abiItem) event = params.abiItem as AbiEvent;
522
+ else {
523
+ const sigPool = params.knownSignatures as Record<Hex, AbiEvent>;
524
+ event = sigPool[signature] as AbiEvent;
525
+ }
526
+ if (!event) {
527
+ throw new ValidationAbiMissingError(signature);
528
+ }
529
+
530
+ let address: Address | undefined;
531
+ if ('logs' in params) {
532
+ for (let log of params.logs) {
533
+ if (!isAddressEqual(log.address, claimant.targetContract)) continue;
534
+ let addressCandidate = this.validateClaimantAgainstArgs(
535
+ claimant,
536
+ log,
537
+ );
538
+ if (addressCandidate) address = addressCandidate;
539
+ }
540
+ return address;
541
+ }
542
+ const receipt = await getTransactionReceipt(this._config, params);
543
+ const decodedLogs = receipt.logs.map((log) => {
544
+ const { eventName, args } = decodeEventLog({
545
+ abi: [event],
546
+ data: log.data,
547
+ topics: log.topics,
548
+ });
549
+ return { ...log, eventName, args };
550
+ });
551
+
552
+ for (let log of decodedLogs) {
553
+ if (!isAddressEqual(log.address, claimant.targetContract)) continue;
554
+ let addressCandidate = this.validateClaimantAgainstArgs(claimant, log);
555
+ if (addressCandidate) address = addressCandidate;
556
+ }
557
+ return address;
558
+ }
559
+ if (
560
+ claimant.signatureType === SignatureType.FUNC &&
561
+ 'hash' in params &&
562
+ 'chainId' in params
563
+ ) {
564
+ const transaction = await getTransaction(this._config, {
565
+ hash: params.hash,
566
+ });
567
+ if (!isAddressEqual(transaction.to!, claimant.targetContract)) return;
568
+ let func: AbiFunction;
569
+ if (params.abiItem) func = params.abiItem as AbiFunction;
570
+ else {
571
+ const sigPool = params.knownSignatures as Record<Hex, AbiFunction>;
572
+ func = sigPool[signature] as AbiFunction;
573
+ }
574
+ if (!func) {
575
+ throw new ValidationAbiMissingError(claimant.signature);
576
+ }
577
+ let decodedData;
578
+ try {
579
+ decodedData = decodeFunctionData({
580
+ abi: [func],
581
+ data: transaction.input,
582
+ });
583
+ } catch (e) {
584
+ throw new FunctionDataDecodeError([func], e as Error);
585
+ }
586
+ return this.validateClaimantAgainstArgs(claimant, decodedData);
587
+ }
588
+ }
589
+
590
+ /**
591
+ * Validates the action claimant against the arguments of a log or function data.
592
+ *
593
+ * @param {ActionClaimant} claimant - The action claimant to validate.
594
+ * @param {Object} [logOrFnData] - Optional object containing the arguments to validate against.
595
+ * @param {Array<any> | readonly unknown[] | Record<string, unknown>} [logOrFnData.args] - The arguments from the log or function data.
596
+ * @returns {Address | undefined} The validated address if found and valid, otherwise undefined.
597
+ */
598
+ public validateClaimantAgainstArgs(
599
+ claimant: ActionClaimant,
600
+ logOrFnData?: {
601
+ args: Array<unknown> | readonly unknown[] | Record<string, unknown>;
602
+ },
603
+ ): Address | undefined {
604
+ if (
605
+ !logOrFnData ||
606
+ !Array.isArray(logOrFnData?.args) ||
607
+ logOrFnData?.args.length <= claimant.fieldIndex
608
+ ) {
609
+ return;
610
+ }
611
+ const maybeAddress = logOrFnData.args.at(claimant.fieldIndex);
612
+ if (isAddress(maybeAddress)) return maybeAddress;
613
+ }
614
+
432
615
  /**
433
616
  * Retrieves action steps, and uses them to validate against, and optionally fetch logs that match the step's signature.
434
617
  * If logs are provided in the optional `params` argument, then those logs will be used instead of fetched with the configured client.
435
618
  *
436
619
  * @public
437
620
  * @async
438
- * @param {?ReadParams<typeof eventActionAbi, 'getActionSteps'> &
439
- * GetLogsParams<Abi, ContractEventName<Abi>> & {
440
- * knownEvents?: Record<Hex, AbiEvent>;
441
- * logs?: Log[];
442
- * }} [params]
621
+ * @param ValidateActionStepParams params
443
622
  * @returns {Promise<boolean>}
444
623
  */
445
- public async validateActionSteps(
446
- params?: ReadParams<typeof eventActionAbi, 'getActionSteps'> &
447
- GetLogsParams<Abi, ContractEventName<Abi>> & {
448
- knownEvents?: Record<Hex, AbiEvent>;
449
- logs?: Log[];
450
- },
451
- ) {
452
- const actionSteps = await this.getActionSteps(params);
624
+ public async validateActionSteps(params: ValidateActionStepParams) {
625
+ const actionSteps = await this.getActionSteps();
453
626
  for (const actionStep of actionSteps) {
454
627
  if (!(await this.isActionStepValid(actionStep, params))) {
455
628
  return false;
@@ -459,108 +632,335 @@ export class EventAction extends DeployableTarget<
459
632
  }
460
633
 
461
634
  /**
462
- * Validates a single action step with a given criteria against logs.
463
- * If logs are provided in the optional `params` argument, then those logs will be used instead of fetched with the configured client.
635
+ * Validates a single action step with a given criteria against logs or function calls.
636
+ * If logs are provided in the optional `params` argument, then those logs will be used instead of being fetched with the configured client.
637
+ * For functions a hash is required.
464
638
  *
465
639
  * @public
466
640
  * @async
467
- * @param {ActionStep} actionStep
468
- * @param {?GetLogsParams<Abi, ContractEventName<Abi>> & {
469
- * knownEvents?: Record<Hex, AbiEvent>;
470
- * logs?: Log[];
471
- * }} [params]
641
+ * @param {ActionStep} actionStep - The action step to validate. Can be a function of event step.
642
+ * @param {ValidateActionStepParams} params - Additional parameters for validation, including hash, known events, logs, and chain ID.
472
643
  * @returns {Promise<boolean>}
473
644
  */
474
645
  public async isActionStepValid(
475
646
  actionStep: ActionStep,
476
- params?: GetLogsParams<Abi, ContractEventName<Abi>> & {
477
- knownEvents?: Record<Hex, AbiEvent>;
478
- logs?: Log[];
479
- },
647
+ params: ValidateActionStepParams,
480
648
  ) {
481
- const criteria = actionStep.actionParameter;
482
- const signature = actionStep.signature;
483
- let event: AbiEvent;
484
- // Lookup ABI based on event signature
485
- if (params?.knownEvents) {
486
- event = params.knownEvents[signature] as AbiEvent;
487
- } else {
488
- event = (events.abi as Record<Hex, AbiEvent>)[signature] as AbiEvent;
649
+ if (actionStep.signatureType === SignatureType.EVENT) {
650
+ const signature = actionStep.signature;
651
+ let event: AbiEvent;
652
+ if (params.abiItem) event = params.abiItem as AbiEvent;
653
+ else {
654
+ const sigPool = params.knownSignatures as Record<Hex, AbiEvent>;
655
+ event = sigPool[signature] as AbiEvent;
656
+ }
657
+
658
+ if (!event) {
659
+ throw new ValidationAbiMissingError(signature);
660
+ }
661
+
662
+ if (this.isArraylikeIndexed(actionStep, event)) {
663
+ // If the field is indexed, we can't filter on it
664
+ throw new UnparseableAbiParamError(
665
+ actionStep.actionParameter.fieldIndex,
666
+ event,
667
+ );
668
+ }
669
+
670
+ // Use the provided logs, no need to fetch receipt
671
+ if ('logs' in params) {
672
+ return this.isActionEventValid(actionStep, params.logs);
673
+ }
674
+
675
+ const client = this._config.getClient({
676
+ chainId: params.chainId,
677
+ }) as PublicClient;
678
+ const receipt = await client.getTransactionReceipt({
679
+ hash: params.hash,
680
+ });
681
+ const decodedLogs = receipt.logs.map((log) => {
682
+ const { eventName, args } = decodeEventLog({
683
+ abi: [event],
684
+ data: log.data,
685
+ topics: log.topics,
686
+ });
687
+
688
+ return { ...log, eventName, args };
689
+ });
690
+
691
+ return this.isActionEventValid(actionStep, decodedLogs);
489
692
  }
490
- if (!event) {
491
- throw new Error(`No known ABI for given event signature: ${signature}`);
693
+ if (actionStep.signatureType === SignatureType.FUNC) {
694
+ if ('hash' in params && 'chainId' in params) {
695
+ const client = this._config.getClient({
696
+ chainId: params.chainId,
697
+ }) as PublicClient;
698
+ const transaction = await client.getTransaction({
699
+ hash: params.hash,
700
+ });
701
+ return this.isActionFunctionValid(actionStep, transaction, params);
702
+ }
492
703
  }
493
- const targetContract = actionStep.targetContract;
494
- // Get all logs matching the event signature from the target contract
495
- const logs =
496
- params?.logs ||
497
- (await getLogs(this._config.getClient({ chainId: params?.chainId }), {
498
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
499
- ...(params as any),
500
- address: targetContract,
501
- event,
502
- }));
704
+ return false;
705
+ }
706
+
707
+ /**
708
+ * Validates a single action event with a given criteria against logs.
709
+ * If logs are provided in the optional `params` argument, then those logs will be used instead of being fetched with the configured client.
710
+ *
711
+ * @public
712
+ * @async
713
+ * @param {ActionStep} actionStep - The action step containing the event to validate.
714
+ * @param {EventLogs} logs - Event logs to validate the given step against
715
+ * @returns {Promise<boolean>} Resolves to true if the action event is valid, throws if input is invalid, otherwise false.
716
+ */
717
+ public isActionEventValid(actionStep: ActionStep, logs: EventLogs) {
718
+ const criteria = actionStep.actionParameter;
503
719
  if (!logs.length) return false;
504
720
  for (let log of logs) {
505
- if (!this.validateLogAgainstCriteria(criteria, log)) {
506
- return false;
721
+ if (this.validateLogAgainstCriteria(criteria, log)) {
722
+ return true;
507
723
  }
508
724
  }
509
- return true;
725
+ return false;
510
726
  }
511
727
 
512
728
  /**
513
- * Validates a {@link Log} against a given criteria.
729
+ * Validates a single action function with a given criteria against the transaction input.
730
+ *
731
+ * @public
732
+ * @param {ActionStep} actionStep - The action step containing the function to validate.
733
+ * @param {Transaction} transaction - The transaction that will be validated against.
734
+ * @param {Object} [params] - Parameters for validation.
735
+ * @param {AbiItem} [params.abiItem] - The ABI item for the function, if known.
736
+ * @param {Record<Hex, AbiEvent | AbiFunction>} [params.knownSignatures] - A record of known signatures.
737
+ * @returns {boolean} Returns true if the action function is valid, false otherwise.
738
+ * @throws {ValidationAbiMissingError} Throws if the ABI for the function signature is not found.
739
+ * @throws {FunctionDataDecodeError} Throws if there's an error decoding the function data.
740
+ */
741
+ public isActionFunctionValid(
742
+ actionStep: ActionStep,
743
+ transaction: Transaction,
744
+ params: Pick<ValidateActionStepParams, 'abiItem' | 'knownSignatures'>,
745
+ ) {
746
+ const criteria = actionStep.actionParameter;
747
+ let signature = actionStep.signature;
748
+
749
+ let func: AbiFunction;
750
+ if (params.abiItem) func = params?.abiItem as AbiFunction;
751
+ else {
752
+ const sigPool = params.knownSignatures as Record<Hex, AbiFunction>;
753
+ func = sigPool[signature] as AbiFunction;
754
+ }
755
+ if (!func) {
756
+ throw new ValidationAbiMissingError(signature);
757
+ }
758
+
759
+ let decodedData;
760
+ try {
761
+ decodedData = decodeFunctionData({
762
+ abi: [func],
763
+ data: transaction.input,
764
+ });
765
+ } catch (e) {
766
+ throw new FunctionDataDecodeError([func], e as Error);
767
+ }
768
+
769
+ // Validate the criteria against decoded arguments using fieldIndex
770
+ const decodedArgs = decodedData.args;
771
+
772
+ if (!decodedArgs || !decodedData) return false;
773
+
774
+ if (
775
+ !this.validateFunctionAgainstCriteria(
776
+ criteria,
777
+ decodedArgs as (string | bigint)[],
778
+ )
779
+ ) {
780
+ return false;
781
+ }
782
+
783
+ return true;
784
+ }
785
+ /**
786
+ * Validates a field against a given criteria.
514
787
  *
515
788
  * @param {Criteria} criteria - The criteria to validate against.
516
- * @param {Log} log - The Viem event log.
517
- * @returns {boolean} - Returns true if the log passes the criteria, false otherwise.
789
+ * @param {string | bigint | Hex} fieldValue - The field value to validate.
790
+ * @param {Object} input - Additional context for validation.
791
+ * @param {EventLogs[0]} [input.log] - The event log, if validating an event.
792
+ * @param {readonly (string | bigint)[]} [input.decodedArgs] - The decoded function arguments, if validating a function call.
793
+ * @returns {Promise<boolean>} - Returns true if the field passes the criteria, false otherwise.
518
794
  */
519
- public validateLogAgainstCriteria(criteria: Criteria, log: Log) {
520
- const fieldValue = log.topics.at(criteria.fieldIndex);
521
- if (fieldValue === undefined) {
522
- throw new FieldValueUndefinedError({ log, criteria, fieldValue });
795
+ public validateFieldAgainstCriteria(
796
+ criteria: Criteria,
797
+ fieldValue: string | bigint | Hex,
798
+ input:
799
+ | { log: EventLogs[0] }
800
+ | { decodedArgs: readonly (string | bigint)[] },
801
+ ): boolean {
802
+ if (
803
+ criteria.filterType === FilterType.EQUAL &&
804
+ criteria.fieldType === PrimitiveType.BYTES &&
805
+ criteria.fieldIndex === 255
806
+ ) {
807
+ return true;
523
808
  }
809
+
524
810
  // Type narrow based on criteria.filterType
525
811
  switch (criteria.filterType) {
526
812
  case FilterType.EQUAL:
527
- if (criteria.fieldType === PrimitiveType.ADDRESS) {
528
- return isAddressEqual(
529
- criteria.filterData,
530
- `0x${fieldValue.slice(-40)}`,
531
- );
532
- }
533
- return fieldValue === criteria.filterData;
813
+ return match(criteria.fieldType)
814
+ .with(PrimitiveType.ADDRESS, () =>
815
+ isAddressEqual(criteria.filterData, fieldValue as Address),
816
+ )
817
+ .with(
818
+ PrimitiveType.UINT,
819
+ () => BigInt(fieldValue) === BigInt(criteria.filterData),
820
+ )
821
+ .with(
822
+ PrimitiveType.STRING,
823
+ () => fieldValue === fromHex(criteria.filterData, 'string'),
824
+ )
825
+ .otherwise(() => fieldValue === criteria.filterData);
534
826
 
535
827
  case FilterType.NOT_EQUAL:
536
- return fieldValue !== criteria.filterData;
828
+ return match(criteria.fieldType)
829
+ .with(
830
+ PrimitiveType.ADDRESS,
831
+ () => !isAddressEqual(criteria.filterData, fieldValue as Address),
832
+ )
833
+ .with(
834
+ PrimitiveType.UINT,
835
+ () => BigInt(fieldValue) !== BigInt(criteria.filterData),
836
+ )
837
+ .with(
838
+ PrimitiveType.STRING,
839
+ () => fieldValue !== fromHex(criteria.filterData, 'string'),
840
+ )
841
+ .otherwise(() => fieldValue !== criteria.filterData);
537
842
 
538
843
  case FilterType.GREATER_THAN:
539
844
  if (criteria.fieldType === PrimitiveType.UINT) {
540
845
  return BigInt(fieldValue) > BigInt(criteria.filterData);
541
846
  }
542
- throw new InvalidNumericalCriteriaError({ log, criteria, fieldValue });
847
+ throw new InvalidNumericalCriteriaError({
848
+ ...input,
849
+ criteria,
850
+ fieldValue,
851
+ });
543
852
 
544
853
  case FilterType.LESS_THAN:
545
854
  if (criteria.fieldType === PrimitiveType.UINT) {
546
855
  return BigInt(fieldValue) < BigInt(criteria.filterData);
547
856
  }
548
- throw new InvalidNumericalCriteriaError({ log, criteria, fieldValue });
857
+ throw new InvalidNumericalCriteriaError({
858
+ ...input,
859
+ criteria,
860
+ fieldValue,
861
+ });
549
862
 
550
863
  case FilterType.CONTAINS:
551
864
  if (
552
865
  criteria.fieldType === PrimitiveType.BYTES ||
553
866
  criteria.fieldType === PrimitiveType.STRING
554
867
  ) {
555
- return fieldValue.includes(criteria.filterData);
868
+ let substring;
869
+ if (criteria.fieldType === PrimitiveType.STRING) {
870
+ substring = fromHex(criteria.filterData, 'string');
871
+ } else {
872
+ // truncate the `0x` prefix
873
+ substring = criteria.filterData.slice(2);
874
+ }
875
+ return (fieldValue as string).includes(substring);
876
+ }
877
+ throw new FieldValueNotComparableError({
878
+ ...input,
879
+ criteria,
880
+ fieldValue,
881
+ });
882
+
883
+ case FilterType.REGEX:
884
+ if (typeof fieldValue !== 'string') {
885
+ throw new FieldValueNotComparableError({
886
+ ...input,
887
+ criteria,
888
+ fieldValue,
889
+ });
890
+ }
891
+
892
+ if (criteria.fieldType === PrimitiveType.STRING) {
893
+ // fieldValue is decoded by the ABI
894
+ const regexString = fromHex(criteria.filterData, 'string');
895
+ return new RegExp(regexString).test(fieldValue);
556
896
  }
557
- throw new FieldValueNotComparableError({ log, criteria, fieldValue });
558
897
 
559
898
  default:
560
- throw new UnrecognizedFilterTypeError({ log, criteria, fieldValue });
899
+ throw new UnrecognizedFilterTypeError({
900
+ ...input,
901
+ criteria,
902
+ fieldValue,
903
+ });
561
904
  }
562
905
  }
563
906
 
907
+ /**
908
+ * Validates a {@link Log} against a given criteria.
909
+ * If the criteria's fieldIndex is 255, it is reserved for anyValidation
910
+ *
911
+ * @param {Criteria} criteria - The criteria to validate against.
912
+ * @param {Log} log - The Viem event log.
913
+ * @returns {boolean} - Returns true if the log passes the criteria, false otherwise.
914
+ */
915
+ public validateLogAgainstCriteria(
916
+ criteria: Criteria,
917
+ log: EventLogs[0],
918
+ ): boolean {
919
+ if (
920
+ !Array.isArray(log.args) ||
921
+ (log.args.length <= criteria.fieldIndex && criteria.fieldIndex !== 255)
922
+ ) {
923
+ throw new DecodedArgsMalformedError({
924
+ log,
925
+ criteria,
926
+ fieldValue: undefined,
927
+ });
928
+ }
929
+
930
+ const fieldValue =
931
+ criteria.fieldIndex === 255 ? zeroHash : log.args.at(criteria.fieldIndex);
932
+
933
+ if (fieldValue === undefined) {
934
+ throw new FieldValueUndefinedError({ log, criteria, fieldValue });
935
+ }
936
+ return this.validateFieldAgainstCriteria(criteria, fieldValue, { log });
937
+ }
938
+
939
+ /**
940
+ * Validates a function's decoded arguments against a given criteria.
941
+ * If the criteria's fieldIndex is 255, it is reserved for anyValidation
942
+ *
943
+ * @param {Criteria} criteria - The criteria to validate against.
944
+ * @param {unknown[]} decodedArgs - The decoded arguments of the function call.
945
+ * @returns {Promise<boolean>} - Returns true if the decoded argument passes the criteria, false otherwise.
946
+ */
947
+ public validateFunctionAgainstCriteria(
948
+ criteria: Criteria,
949
+ decodedArgs: readonly (string | bigint)[],
950
+ ): boolean {
951
+ const fieldValue =
952
+ criteria.fieldIndex === 255 ? zeroHash : decodedArgs[criteria.fieldIndex];
953
+ if (fieldValue === undefined) {
954
+ throw new FieldValueUndefinedError({
955
+ criteria,
956
+ fieldValue,
957
+ });
958
+ }
959
+ return this.validateFieldAgainstCriteria(criteria, fieldValue, {
960
+ decodedArgs,
961
+ });
962
+ }
963
+
564
964
  /**
565
965
  * @inheritdoc
566
966
  *
@@ -609,6 +1009,17 @@ export class EventAction extends DeployableTarget<
609
1009
  ...this.optionallyAttachAccount(options.account),
610
1010
  };
611
1011
  }
1012
+
1013
+ public isArraylikeIndexed(step: ActionStep, event: AbiEvent) {
1014
+ if (
1015
+ (step.actionParameter.fieldType === PrimitiveType.STRING ||
1016
+ step.actionParameter.fieldType === PrimitiveType.BYTES) &&
1017
+ event.inputs[step.actionParameter.fieldIndex]?.indexed
1018
+ ) {
1019
+ return true;
1020
+ }
1021
+ return false;
1022
+ }
612
1023
  }
613
1024
 
614
1025
  function _dedupeActionSteps(_steps: ActionStep[]): ActionStep[] {
@@ -803,3 +1214,31 @@ export function prepareEventActionPayload({
803
1214
  ],
804
1215
  );
805
1216
  }
1217
+
1218
+ /**
1219
+ * Creates a default Criteria object that allows validation to pass. This is used if you don't care about targeting specific parameters in the action step.
1220
+ *
1221
+ * This function returns a Criteria object with the following properties:
1222
+ * - filterType: Set to EQUAL for exact matching
1223
+ * - fieldType: Set to BYTES to handle any data type
1224
+ * - fieldIndex: Set to 255, which is typically used to indicate "any" or "all" in this context
1225
+ * - filterData: Set to zeroHash (0x0000...0000)
1226
+ *
1227
+ * @returns {Criteria} A Criteria object that can be used to match any action parameter
1228
+ *
1229
+ * @example
1230
+ * const anyCriteria = anyActionParameter();
1231
+ * // Use this criteria in an ActionStep to match any parameter
1232
+ * const actionStep = {
1233
+ * // ... other properties ...
1234
+ * actionParameter: anyCriteria
1235
+ * };
1236
+ */
1237
+ export function anyActionParameter(): Criteria {
1238
+ return {
1239
+ filterType: FilterType.EQUAL,
1240
+ fieldType: PrimitiveType.BYTES,
1241
+ fieldIndex: 255,
1242
+ filterData: zeroHash,
1243
+ };
1244
+ }