@boostxyz/sdk 0.0.0-alpha.16 → 0.0.0-alpha.18

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 (223) 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 +7 -7
  4. package/dist/Actions/ContractAction.d.ts +9 -9
  5. package/dist/Actions/ContractAction.d.ts.map +1 -1
  6. package/dist/Actions/ERC721MintAction.d.ts +12 -12
  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 +32 -49
  11. package/dist/Actions/EventAction.d.ts.map +1 -1
  12. package/dist/Actions/EventAction.js +13 -779
  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.js +3 -3
  17. package/dist/AllowLists/OpenAllowList.d.ts +183 -0
  18. package/dist/AllowLists/OpenAllowList.d.ts.map +1 -1
  19. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  20. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  21. package/dist/AllowLists/SimpleAllowList.d.ts +82 -36
  22. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  23. package/dist/AllowLists/SimpleAllowList.js +44 -80
  24. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  25. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  26. package/dist/AllowLists/SimpleDenyList.d.ts +192 -9
  27. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  28. package/dist/AllowLists/SimpleDenyList.js +5 -5
  29. package/dist/Auth/PassthroughAuth.cjs +1 -1
  30. package/dist/Auth/PassthroughAuth.js +1 -1
  31. package/dist/Boost.cjs.map +1 -1
  32. package/dist/Boost.d.ts +18 -0
  33. package/dist/Boost.d.ts.map +1 -1
  34. package/dist/Boost.js.map +1 -1
  35. package/dist/BoostCore-BiPwp6SR.cjs +3 -0
  36. package/dist/BoostCore-BiPwp6SR.cjs.map +1 -0
  37. package/dist/BoostCore-C00iqvks.js +1477 -0
  38. package/dist/BoostCore-C00iqvks.js.map +1 -0
  39. package/dist/BoostCore.cjs +1 -2
  40. package/dist/BoostCore.cjs.map +1 -1
  41. package/dist/BoostCore.d.ts +80 -35
  42. package/dist/BoostCore.d.ts.map +1 -1
  43. package/dist/BoostCore.js +29 -1273
  44. package/dist/BoostCore.js.map +1 -1
  45. package/dist/BoostRegistry.cjs +1 -1
  46. package/dist/BoostRegistry.cjs.map +1 -1
  47. package/dist/BoostRegistry.d.ts +18 -18
  48. package/dist/BoostRegistry.js +36 -36
  49. package/dist/BoostRegistry.js.map +1 -1
  50. package/dist/Budgets/Budget.cjs +1 -1
  51. package/dist/Budgets/Budget.cjs.map +1 -1
  52. package/dist/Budgets/Budget.d.ts.map +1 -1
  53. package/dist/Budgets/Budget.js +2 -2
  54. package/dist/Budgets/Budget.js.map +1 -1
  55. package/dist/Budgets/ManagedBudget.cjs +1 -1
  56. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  57. package/dist/Budgets/ManagedBudget.d.ts +24 -174
  58. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  59. package/dist/Budgets/ManagedBudget.js +76 -298
  60. package/dist/Budgets/ManagedBudget.js.map +1 -1
  61. package/dist/Budgets/VestingBudget.d.ts +181 -77
  62. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  63. package/dist/Deployable/Contract.cjs +1 -1
  64. package/dist/Deployable/Contract.cjs.map +1 -1
  65. package/dist/Deployable/Contract.d.ts +4 -5
  66. package/dist/Deployable/Contract.d.ts.map +1 -1
  67. package/dist/Deployable/Contract.js +4 -5
  68. package/dist/Deployable/Contract.js.map +1 -1
  69. package/dist/Deployable/Deployable.cjs.map +1 -1
  70. package/dist/Deployable/Deployable.d.ts +1 -1
  71. package/dist/Deployable/Deployable.js +1 -1
  72. package/dist/Deployable/Deployable.js.map +1 -1
  73. package/dist/Deployable/DeployableTarget.cjs +1 -1
  74. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  75. package/dist/Deployable/DeployableTarget.d.ts +5 -5
  76. package/dist/Deployable/DeployableTarget.js +10 -10
  77. package/dist/Deployable/DeployableTarget.js.map +1 -1
  78. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  79. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  80. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
  81. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  82. package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
  83. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  84. package/dist/EventAction-BO5WI_5s.js +1355 -0
  85. package/dist/EventAction-BO5WI_5s.js.map +1 -0
  86. package/dist/EventAction-DBDRaG4A.cjs +2 -0
  87. package/dist/EventAction-DBDRaG4A.cjs.map +1 -0
  88. package/dist/{Incentive-CtuAJAjG.js → Incentive-CF7kaz_9.js} +67 -68
  89. package/dist/Incentive-CF7kaz_9.js.map +1 -0
  90. package/dist/{Incentive-CqX3fYEd.cjs → Incentive-Djnzseoj.cjs} +2 -2
  91. package/dist/Incentive-Djnzseoj.cjs.map +1 -0
  92. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  93. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  94. package/dist/Incentives/AllowListIncentive.d.ts +12 -12
  95. package/dist/Incentives/AllowListIncentive.js +26 -26
  96. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  97. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  98. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  99. package/dist/Incentives/CGDAIncentive.d.ts +15 -15
  100. package/dist/Incentives/CGDAIncentive.js +25 -25
  101. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  102. package/dist/Incentives/ERC1155Incentive.d.ts +30 -30
  103. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  104. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  105. package/dist/Incentives/ERC20Incentive.d.ts +23 -23
  106. package/dist/Incentives/ERC20Incentive.js +45 -45
  107. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  108. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +523 -0
  109. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  110. package/dist/Incentives/ERC20VariableIncentive.d.ts +19 -19
  111. package/dist/Incentives/Incentive.cjs +1 -1
  112. package/dist/Incentives/Incentive.d.ts +3 -3
  113. package/dist/Incentives/Incentive.d.ts.map +1 -1
  114. package/dist/Incentives/Incentive.js +3 -3
  115. package/dist/Incentives/PointsIncentive.cjs +1 -1
  116. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  117. package/dist/Incentives/PointsIncentive.d.ts +14 -14
  118. package/dist/Incentives/PointsIncentive.js +20 -20
  119. package/dist/Incentives/PointsIncentive.js.map +1 -1
  120. package/dist/SimpleDenyList-BwfNjRsg.cjs +2 -0
  121. package/dist/SimpleDenyList-BwfNjRsg.cjs.map +1 -0
  122. package/dist/SimpleDenyList-D9i4rw_F.js +132 -0
  123. package/dist/SimpleDenyList-D9i4rw_F.js.map +1 -0
  124. package/dist/Validators/SignerValidator.cjs +1 -1
  125. package/dist/Validators/SignerValidator.cjs.map +1 -1
  126. package/dist/Validators/SignerValidator.d.ts +14 -14
  127. package/dist/Validators/SignerValidator.js +25 -25
  128. package/dist/Validators/SignerValidator.js.map +1 -1
  129. package/dist/Validators/Validator.cjs +1 -1
  130. package/dist/Validators/Validator.cjs.map +1 -1
  131. package/dist/Validators/Validator.d.ts +1 -1
  132. package/dist/Validators/Validator.js +6 -6
  133. package/dist/Validators/Validator.js.map +1 -1
  134. package/dist/claiming.cjs.map +1 -1
  135. package/dist/claiming.d.ts +1 -1
  136. package/dist/claiming.js.map +1 -1
  137. package/dist/componentInterfaces-D09mhzxO.cjs +2 -0
  138. package/dist/componentInterfaces-D09mhzxO.cjs.map +1 -0
  139. package/dist/componentInterfaces-RXBMI5yH.js +14 -0
  140. package/dist/componentInterfaces-RXBMI5yH.js.map +1 -0
  141. package/dist/deployments-BM42vImE.js +43 -0
  142. package/dist/deployments-BM42vImE.js.map +1 -0
  143. package/dist/deployments-CMdF5uEC.cjs +2 -0
  144. package/dist/deployments-CMdF5uEC.cjs.map +1 -0
  145. package/dist/deployments.json +15 -12
  146. package/dist/errors.cjs +1 -1
  147. package/dist/errors.cjs.map +1 -1
  148. package/dist/errors.d.ts +132 -0
  149. package/dist/errors.d.ts.map +1 -1
  150. package/dist/errors.js +122 -36
  151. package/dist/errors.js.map +1 -1
  152. package/dist/generated-B0tk-c9b.cjs +3 -0
  153. package/dist/generated-B0tk-c9b.cjs.map +1 -0
  154. package/dist/{generated-DLMdMwD1.js → generated-B8VWObPa.js} +2350 -1290
  155. package/dist/generated-B8VWObPa.js.map +1 -0
  156. package/dist/index.cjs +1 -1
  157. package/dist/index.d.ts +2 -0
  158. package/dist/index.d.ts.map +1 -1
  159. package/dist/index.js +134 -122
  160. package/dist/index.js.map +1 -1
  161. package/dist/transfers.cjs.map +1 -1
  162. package/dist/transfers.d.ts +1 -1
  163. package/dist/transfers.js.map +1 -1
  164. package/dist/utils.cjs.map +1 -1
  165. package/dist/utils.d.ts +1 -1
  166. package/dist/utils.js.map +1 -1
  167. package/package.json +12 -5
  168. package/src/Actions/ContractAction.ts +9 -10
  169. package/src/Actions/ERC721MintAction.ts +12 -13
  170. package/src/Actions/EventAction.test.ts +182 -53
  171. package/src/Actions/EventAction.ts +128 -107
  172. package/src/AllowLists/SimpleAllowList.ts +14 -59
  173. package/src/AllowLists/SimpleDenyList.ts +12 -9
  174. package/src/Boost.ts +19 -0
  175. package/src/BoostCore.test.ts +117 -1
  176. package/src/BoostCore.ts +113 -54
  177. package/src/BoostRegistry.ts +18 -18
  178. package/src/Budgets/Budget.ts +1 -2
  179. package/src/Budgets/ManagedBudget.ts +21 -295
  180. package/src/Budgets/VestingBudget.ts +26 -97
  181. package/src/Deployable/Contract.ts +4 -5
  182. package/src/Deployable/Deployable.ts +1 -1
  183. package/src/Deployable/DeployableTarget.ts +5 -5
  184. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  185. package/src/Incentives/AllowListIncentive.ts +12 -12
  186. package/src/Incentives/CGDAIncentive.ts +15 -15
  187. package/src/Incentives/ERC1155Incentive.ts +26 -26
  188. package/src/Incentives/ERC20Incentive.ts +23 -23
  189. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  190. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
  191. package/src/Incentives/ERC20VariableIncentive.ts +19 -19
  192. package/src/Incentives/Incentive.ts +6 -5
  193. package/src/Incentives/PointsIncentive.test.ts +21 -21
  194. package/src/Incentives/PointsIncentive.ts +14 -14
  195. package/src/Validators/SignerValidator.ts +14 -14
  196. package/src/Validators/Validator.ts +1 -1
  197. package/src/claiming.ts +1 -1
  198. package/src/errors.ts +165 -0
  199. package/src/index.test.ts +3 -4
  200. package/src/index.ts +2 -0
  201. package/src/transfers.ts +1 -1
  202. package/src/utils.ts +1 -1
  203. package/dist/Budgets/SimpleBudget.d.ts +0 -824
  204. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  205. package/dist/Incentive-CqX3fYEd.cjs.map +0 -1
  206. package/dist/Incentive-CtuAJAjG.js.map +0 -1
  207. package/dist/SimpleDenyList-9UIxZZKP.cjs +0 -2
  208. package/dist/SimpleDenyList-9UIxZZKP.cjs.map +0 -1
  209. package/dist/SimpleDenyList-DGPNc7ov.js +0 -132
  210. package/dist/SimpleDenyList-DGPNc7ov.js.map +0 -1
  211. package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
  212. package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
  213. package/dist/componentInterfaces-Cmg8tUxq.js +0 -13
  214. package/dist/componentInterfaces-Cmg8tUxq.js.map +0 -1
  215. package/dist/deployments-BvFcK_eR.js +0 -40
  216. package/dist/deployments-BvFcK_eR.js.map +0 -1
  217. package/dist/deployments-Ho4PnGCS.cjs +0 -2
  218. package/dist/deployments-Ho4PnGCS.cjs.map +0 -1
  219. package/dist/generated-BLg7yPgI.cjs +0 -3
  220. package/dist/generated-BLg7yPgI.cjs.map +0 -1
  221. package/dist/generated-DLMdMwD1.js.map +0 -1
  222. package/src/Budgets/SimpleBudget.test.ts +0 -152
  223. package/src/Budgets/SimpleBudget.ts +0 -563
@@ -8,6 +8,7 @@ import {
8
8
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/EventAction.sol/EventAction.json';
9
9
  import events from '@boostxyz/signatures/events';
10
10
  import functions from '@boostxyz/signatures/functions';
11
+ import { match } from 'ts-pattern';
11
12
  import {
12
13
  type Abi,
13
14
  type AbiEvent,
@@ -20,14 +21,13 @@ import {
20
21
  type Hex,
21
22
  type Log,
22
23
  type PublicClient,
24
+ type Transaction,
25
+ decodeEventLog,
23
26
  decodeFunctionData,
24
27
  encodeAbiParameters,
25
28
  fromHex,
26
29
  isAddressEqual,
27
- pad,
28
- trim,
29
30
  } from 'viem';
30
- import { getLogs } from 'viem/actions';
31
31
  import { EventAction as EventActionBases } from '../../dist/deployments.json';
32
32
  import type {
33
33
  DeployableOptions,
@@ -44,6 +44,8 @@ import {
44
44
  TooManyEventActionStepsProvidedError,
45
45
  UnparseableAbiParamError,
46
46
  UnrecognizedFilterTypeError,
47
+ ValidationAbiMissingError,
48
+ ValidationLogsMissingError,
47
49
  } from '../errors';
48
50
  import {
49
51
  type GetLogsParams,
@@ -215,38 +217,19 @@ export interface ActionStep {
215
217
  }
216
218
 
217
219
  /**
218
- * Parameters for validating an event step.
220
+ * Parameters for validating an action step.
219
221
  *
220
- * This type omits the 'address' field from GetLogsParams and adds optional fields
221
- * for logs and known events.
222
- *
223
- * @typedef {Object} ValidateEventStepParams
224
- * @property {Log[]} [logs]
225
- * @property {Record<Hex, AbiEvent>} [knownEvents]
226
- * @property {number} [fromBlock]
227
- * @property {number} [toBlock]
228
- * @property {Hex} [blockHash]
229
- * @property {Abi} abi
230
- * @property {ContractEventName<Abi>} eventName
231
- */
232
- export type ValidateEventStepParams = Omit<
233
- GetLogsParams<Abi, ContractEventName<Abi>> & {
234
- logs?: Log[];
235
- knownEvents?: Record<Hex, AbiEvent>;
236
- },
237
- 'address'
238
- >;
239
-
240
- /**
241
- * Parameters for validating a function step.
242
- *
243
- * This type includes all parameters required to get a transaction.
244
- *
245
- * @typedef {Object} ValidateFunctionStepParams
246
- * @property {Hex} hash
247
- * @property {number} [chainId]
222
+ * @typedef {Object} ValidateActionStepParams
223
+ * @property {Record<Hex, AbiEvent>} [knownEvents] - Optional record of known events, keyed by their hex signature.
224
+ * @property {AbiEvent} [event] - Optional ABI event definition.
225
+ * @property {EventLogs} [logs] - Event logs to validate against. Required if 'hash' is not provided.
226
+ * @property {Hex} [hash] - Transaction hash to validate against. Required if 'logs' is not provided.
227
+ * @property {number} [chainId] - Chain ID for the transaction. Required if 'hash' is provided.
248
228
  */
249
- export type ValidateFunctionStepParams = GetTransactionParameters;
229
+ export type ValidateActionStepParams = {
230
+ knownEvents?: Record<Hex, AbiEvent>;
231
+ event?: AbiEvent;
232
+ } & ({ logs: EventLogs } | { hash: Hex; chainId: number });
250
233
 
251
234
  /**
252
235
  * You can either supply a simplified version of the payload, or one that explicitly declares action steps.
@@ -348,8 +331,6 @@ export type ReadEventActionParams<
348
331
  fnName extends ContractFunctionName<typeof eventActionAbi, 'pure' | 'view'>,
349
332
  > = ReadParams<typeof eventActionAbi, fnName>;
350
333
 
351
- type TxParams = ValidateEventStepParams | ValidateFunctionStepParams;
352
-
353
334
  /**
354
335
  * A generic event action
355
336
  *
@@ -466,7 +447,7 @@ export class EventAction extends DeployableTarget<
466
447
  * @public
467
448
  * @async
468
449
  * @param {Hex} data
469
- * @param {?WriteParams<typeof eventActionAbi, 'execute'>} [params]
450
+ * @param {?WriteParams} [params]
470
451
  * @returns {Promise<readonly [boolean, `0x${string}`]>}
471
452
  */
472
453
  public async execute(
@@ -482,8 +463,8 @@ export class EventAction extends DeployableTarget<
482
463
  * @public
483
464
  * @async
484
465
  * @param {Hex} data
485
- * @param {?WriteParams<typeof eventActionAbi, 'execute'>} [params]
486
- * @returns {unknown}
466
+ * @param {?WriteParams} [params]
467
+ * @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
487
468
  */
488
469
  public async executeRaw(
489
470
  data: Hex,
@@ -506,10 +487,10 @@ export class EventAction extends DeployableTarget<
506
487
  *
507
488
  * @public
508
489
  * @async
509
- * @param {?TxParams} [params]
490
+ * @param ValidateActionStepParams params
510
491
  * @returns {Promise<boolean>}
511
492
  */
512
- public async validateActionSteps(params?: TxParams) {
493
+ public async validateActionSteps(params: ValidateActionStepParams) {
513
494
  const actionSteps = await this.getActionSteps();
514
495
  for (const actionStep of actionSteps) {
515
496
  if (!(await this.isActionStepValid(actionStep, params))) {
@@ -527,21 +508,75 @@ export class EventAction extends DeployableTarget<
527
508
  * @public
528
509
  * @async
529
510
  * @param {ActionStep} actionStep - The action step to validate. Can be a function of event step.
530
- * @param {?TxParams & { chainId?: number }} [params] - Additional parameters for validation, including known events, logs, and chain ID.
511
+ * @param {ValidateActionStepParams} params - Additional parameters for validation, including hash, known events, logs, and chain ID.
531
512
  * @returns {Promise<boolean>}
532
513
  */
533
514
  public async isActionStepValid(
534
515
  actionStep: ActionStep,
535
- params?: TxParams & { chainId?: number },
516
+ params: ValidateActionStepParams,
536
517
  ) {
537
518
  if (actionStep.signatureType === SignatureType.EVENT) {
538
- return await this.isActionEventValid(actionStep, params);
519
+ const signature = actionStep.signature;
520
+ let event: AbiEvent;
521
+ // Lookup ABI based on event signature
522
+ if (params.knownEvents) {
523
+ event = params.knownEvents?.[signature] as AbiEvent;
524
+ } else {
525
+ event = (events.abi as Record<Hex, AbiEvent>)[signature] as AbiEvent;
526
+ }
527
+
528
+ if (!event) {
529
+ throw new ValidationAbiMissingError(signature);
530
+ }
531
+
532
+ if (this.isArraylikeIndexed(actionStep, event)) {
533
+ // If the field is indexed, we can't filter on it
534
+ throw new UnparseableAbiParamError(
535
+ actionStep.actionParameter.fieldIndex,
536
+ event,
537
+ );
538
+ }
539
+
540
+ params.event = event;
541
+
542
+ // Use the provided logs, no need to fetch receipt
543
+ if ('logs' in params) {
544
+ return this.isActionEventValid(actionStep, {
545
+ ...params,
546
+ });
547
+ }
548
+
549
+ const client = this._config.getClient({
550
+ chainId: params.chainId,
551
+ }) as PublicClient;
552
+ const receipt = await client.getTransactionReceipt({
553
+ hash: params.hash,
554
+ });
555
+ const decodedLogs = receipt.logs.map((log) => {
556
+ const { eventName, args } = decodeEventLog({
557
+ abi: [event],
558
+ data: log.data,
559
+ topics: log.topics,
560
+ });
561
+
562
+ return { ...log, eventName, args };
563
+ });
564
+
565
+ return this.isActionEventValid(actionStep, {
566
+ logs: decodedLogs,
567
+ ...params,
568
+ });
539
569
  }
540
570
  if (actionStep.signatureType === SignatureType.FUNC) {
541
- return await this.isActionFunctionValid(
542
- actionStep,
543
- params as ValidateFunctionStepParams,
544
- );
571
+ if ('hash' in params && 'chainId' in params) {
572
+ const client = this._config.getClient({
573
+ chainId: params.chainId,
574
+ }) as PublicClient;
575
+ const transaction = await client.getTransaction({
576
+ hash: params.hash,
577
+ });
578
+ return this.isActionFunctionValid(actionStep, transaction);
579
+ }
545
580
  }
546
581
  return false;
547
582
  }
@@ -553,88 +588,49 @@ export class EventAction extends DeployableTarget<
553
588
  * @public
554
589
  * @async
555
590
  * @param {ActionStep} actionStep - The action step containing the event to validate.
556
- * @param {?ValidateEventStepParams & { chainId?: number }} [params] - Additional parameters for validation, including known events, logs, and chain ID.
591
+ * @param {ValidateActionStepParams} params - Additional parameters for validation, including known events and logs
557
592
  * @returns {Promise<boolean>} Resolves to true if the action event is valid, throws if input is invalid, otherwise false.
558
593
  */
559
- public async isActionEventValid(
594
+ public isActionEventValid(
560
595
  actionStep: ActionStep,
561
- params?: ValidateEventStepParams & { chainId?: number },
596
+ params: ValidateActionStepParams,
562
597
  ) {
563
- const criteria = actionStep.actionParameter;
564
- const signature = actionStep.signature;
565
- let event: AbiEvent;
566
- // Lookup ABI based on event signature
567
- if (params?.knownEvents) {
568
- event = params.knownEvents[signature] as AbiEvent;
569
- } else {
570
- event = (events.abi as Record<Hex, AbiEvent>)[signature] as AbiEvent;
598
+ if (!('logs' in params)) {
599
+ throw new ValidationLogsMissingError();
571
600
  }
572
-
573
- if (!event) {
574
- throw new Error(`No known ABI for given event signature: ${signature}`);
575
- }
576
-
577
- if (this.isArraylikeIndexed(actionStep, event)) {
578
- // If the field is indexed, we can't filter on it
579
- throw new UnparseableAbiParamError(
580
- actionStep.actionParameter.fieldIndex,
581
- event,
582
- );
583
- }
584
- const targetContract = actionStep.targetContract;
585
- // Get all logs matching the event signature from the target contract
586
- const logs =
587
- params?.logs ||
588
- (await getLogs(this._config.getClient({ chainId: params?.chainId }), {
589
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
590
- ...(params as any),
591
- address: targetContract,
592
- event,
593
- }));
601
+ const criteria = actionStep.actionParameter;
602
+ const logs = params.logs;
594
603
  if (!logs.length) return false;
595
604
  for (let log of logs) {
596
- if (!this.validateLogAgainstCriteria(criteria, log as EventLogs[0])) {
597
- return false;
605
+ if (this.validateLogAgainstCriteria(criteria, log)) {
606
+ return true;
598
607
  }
599
608
  }
600
- return true;
609
+ return false;
601
610
  }
602
611
  /**
603
612
  * Validates a single action function with a given criteria against the transaction input.
604
- * If a transaction hash is provided in the optional `params` argument, then the transaction
605
- * will be fetched and decoded using the configured client.
606
613
  *
607
614
  * @public
608
615
  * @async
609
616
  * @param {ActionStep} actionStep - The action step containing the function to validate.
610
- * @param {?ValidateFunctionStepParams & { chainId?: number }} [params] - Additional parameters for validation, including known events, transaction hash, and chain ID.
617
+ * @param {Transaction} transaction - The transaction that will be validated against.
611
618
  * @returns {Promise<boolean>} Resolves to true if the action function is valid, throws if the inputs are invalid, otherwise false.
612
619
  */
613
- public async isActionFunctionValid(
620
+ public isActionFunctionValid(
614
621
  actionStep: ActionStep,
615
- params?: ValidateFunctionStepParams & { chainId?: number },
622
+ transaction: Transaction,
616
623
  ) {
617
624
  const criteria = actionStep.actionParameter;
618
625
  let signature = actionStep.signature;
619
626
 
620
- if (!params || !params?.hash) {
621
- // Should we return false in this case?
622
- throw new Error('Hash is required for function validation');
623
- }
624
- const client = this._config.getClient({
625
- chainId: params?.chainId,
626
- }) as PublicClient;
627
- // Fetch the transaction receipt and decode the function input using `viem` utilities
628
- const transaction = await client.getTransaction({ hash: params.hash });
629
627
  const func = (functions.abi as Record<Hex, AbiFunction>)[
630
628
  signature
631
629
  ] as AbiFunction;
632
-
633
630
  if (!func) {
634
- throw new Error(
635
- `No known ABI for given function signature: ${signature}`,
636
- );
631
+ throw new ValidationAbiMissingError(signature);
637
632
  }
633
+
638
634
  let decodedData;
639
635
  try {
640
636
  decodedData = decodeFunctionData({
@@ -665,7 +661,10 @@ export class EventAction extends DeployableTarget<
665
661
  * Validates a field against a given criteria.
666
662
  *
667
663
  * @param {Criteria} criteria - The criteria to validate against.
668
- * @param {string | bigint} fieldValue - The field value to validate.
664
+ * @param {string | bigint | Hex} fieldValue - The field value to validate.
665
+ * @param {Object} input - Additional context for validation.
666
+ * @param {EventLogs[0]} [input.log] - The event log, if validating an event.
667
+ * @param {readonly (string | bigint)[]} [input.decodedArgs] - The decoded function arguments, if validating a function call.
669
668
  * @returns {Promise<boolean>} - Returns true if the field passes the criteria, false otherwise.
670
669
  */
671
670
  public validateFieldAgainstCriteria(
@@ -678,13 +677,35 @@ export class EventAction extends DeployableTarget<
678
677
  // Type narrow based on criteria.filterType
679
678
  switch (criteria.filterType) {
680
679
  case FilterType.EQUAL:
681
- if (criteria.fieldType === PrimitiveType.ADDRESS) {
682
- return isAddressEqual(criteria.filterData, fieldValue as Address);
683
- }
684
- return fieldValue === criteria.filterData;
680
+ return match(criteria.fieldType)
681
+ .with(PrimitiveType.ADDRESS, () =>
682
+ isAddressEqual(criteria.filterData, fieldValue as Address),
683
+ )
684
+ .with(
685
+ PrimitiveType.UINT,
686
+ () => BigInt(fieldValue) === BigInt(criteria.filterData),
687
+ )
688
+ .with(
689
+ PrimitiveType.STRING,
690
+ () => fieldValue === fromHex(criteria.filterData, 'string'),
691
+ )
692
+ .otherwise(() => fieldValue === criteria.filterData);
685
693
 
686
694
  case FilterType.NOT_EQUAL:
687
- return fieldValue !== criteria.filterData;
695
+ return match(criteria.fieldType)
696
+ .with(
697
+ PrimitiveType.ADDRESS,
698
+ () => !isAddressEqual(criteria.filterData, fieldValue as Address),
699
+ )
700
+ .with(
701
+ PrimitiveType.UINT,
702
+ () => BigInt(fieldValue) !== BigInt(criteria.filterData),
703
+ )
704
+ .with(
705
+ PrimitiveType.STRING,
706
+ () => fieldValue !== fromHex(criteria.filterData, 'string'),
707
+ )
708
+ .otherwise(() => fieldValue !== criteria.filterData);
688
709
 
689
710
  case FilterType.GREATER_THAN:
690
711
  if (criteria.fieldType === PrimitiveType.UINT) {
@@ -2,9 +2,7 @@ import {
2
2
  readSimpleAllowListIsAllowed,
3
3
  readSimpleAllowListOwner,
4
4
  simpleAllowListAbi,
5
- simulateSimpleAllowListGrantRoles,
6
5
  simulateSimpleAllowListSetAllowed,
7
- writeSimpleAllowListGrantRoles,
8
6
  writeSimpleAllowListSetAllowed,
9
7
  } from '@boostxyz/evm';
10
8
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleAllowList.sol/SimpleAllowList.json';
@@ -22,7 +20,10 @@ import type {
22
20
  DeployableOptions,
23
21
  GenericDeployableParams,
24
22
  } from '../Deployable/Deployable';
25
- import { DeployableTarget } from '../Deployable/DeployableTarget';
23
+ import {
24
+ DeployableTargetWithRBAC,
25
+ Roles,
26
+ } from '../Deployable/DeployableTargetWithRBAC';
26
27
  import { DeployableUnknownOwnerProvidedError } from '../errors';
27
28
  import {
28
29
  type GenericLog,
@@ -73,18 +74,19 @@ export type SimpleAllowListLog<
73
74
  /**
74
75
  * A constant representing the list manager's role
75
76
  *
76
- * @type {2n}
77
+ * @deprecated use {@link Roles} instead
78
+ * @type {1n}
77
79
  */
78
- export const LIST_MANAGER_ROLE = 2n;
80
+ export const LIST_MANAGER_ROLE = Roles.MANAGER;
79
81
  /**
80
82
  * A simple implementation of an AllowList that checks if a user is authorized based on a list of allowed addresses
81
83
  *
82
84
  * @export
83
85
  * @class SimpleAllowList
84
86
  * @typedef {SimpleAllowList}
85
- * @extends {DeployableTarget<SimpleAllowListPayload>}
87
+ * @extends {DeployableTargetWithRBAC<SimpleAllowListPayload>}
86
88
  */
87
- export class SimpleAllowList extends DeployableTarget<
89
+ export class SimpleAllowList extends DeployableTargetWithRBAC<
88
90
  SimpleAllowListPayload,
89
91
  typeof simpleAllowListAbi
90
92
  > {
@@ -113,7 +115,7 @@ export class SimpleAllowList extends DeployableTarget<
113
115
  *
114
116
  * @public
115
117
  * @async
116
- * @param {?ReadParams<typeof simpleAllowListAbi, 'owner'>} [params]
118
+ * @param {?ReadParams} [params]
117
119
  * @returns {Promise<Address>} - The address of the owner
118
120
  */
119
121
  public async owner(
@@ -134,7 +136,7 @@ export class SimpleAllowList extends DeployableTarget<
134
136
  * @public
135
137
  * @async
136
138
  * @param {Address} address - The address of the user
137
- * @param {?ReadParams<typeof simpleAllowListAbi, 'setAllowed'>} [params]
139
+ * @param {?ReadParams} [params]
138
140
  * @returns {Promise<boolean>} - True if the user is authorized
139
141
  */
140
142
  public async isAllowed(
@@ -158,7 +160,7 @@ export class SimpleAllowList extends DeployableTarget<
158
160
  * @async
159
161
  * @param {Address[]} addresses - The list of users to update
160
162
  * @param {boolean[]} allowed - The allowed status of each user
161
- * @param {?ReadParams<typeof simpleAllowListAbi, 'setAllowed'>} [params]
163
+ * @param {?ReadParams} [params]
162
164
  * @returns {Promise<void>}
163
165
  */
164
166
  public async setAllowed(
@@ -179,8 +181,8 @@ export class SimpleAllowList extends DeployableTarget<
179
181
  * @async
180
182
  * @param {Address[]} addresses - The list of users to update
181
183
  * @param {boolean[]} allowed - The allowed status of each user
182
- * @param {?ReadParams<typeof simpleAllowListAbi, 'setAllowed'>} [params]
183
- * @returns {Promise<void>}
184
+ * @param {?ReadParams} [params]
185
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
184
186
  */
185
187
  public async setAllowedRaw(
186
188
  addresses: Address[],
@@ -201,53 +203,6 @@ export class SimpleAllowList extends DeployableTarget<
201
203
  return { hash, result };
202
204
  }
203
205
 
204
- /**
205
- * Allows the owner to grant `user` `roles`.
206
- *
207
- * @public
208
- * @async
209
- * @param {Address} address
210
- * @param {bigint} role
211
- * @param {?ReadParams<typeof simpleAllowListAbi, 'grantRoles'>} [params]
212
- * @returns {Promise<void>}
213
- */
214
- public async grantRoles(
215
- address: Address,
216
- role: bigint,
217
- params?: WriteParams<typeof simpleAllowListAbi, 'grantRoles'>,
218
- ) {
219
- return await this.awaitResult(this.grantRolesRaw(address, role, params));
220
- }
221
-
222
- /**
223
- * Allows the owner to grant `user` `roles`.
224
- *
225
- * @public
226
- * @async
227
- * @param {Address} address
228
- * @param {bigint} role
229
- * @param {?ReadParams<typeof simpleAllowListAbi, 'grantRoles'>} [params]
230
- * @returns {Promise<void>}
231
- */
232
- public async grantRolesRaw(
233
- address: Address,
234
- role: bigint,
235
- params?: ReadParams<typeof simpleAllowListAbi, 'grantRoles'>,
236
- ) {
237
- const { request, result } = await simulateSimpleAllowListGrantRoles(
238
- this._config,
239
- {
240
- address: this.assertValidAddress(),
241
- args: [address, role],
242
- ...this.optionallyAttachAccount(),
243
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
244
- ...(params as any),
245
- },
246
- );
247
- const hash = await writeSimpleAllowListGrantRoles(this._config, request);
248
- return { hash, result };
249
- }
250
-
251
206
  /**
252
207
  * @inheritdoc
253
208
  *
@@ -20,7 +20,7 @@ import type {
20
20
  DeployableOptions,
21
21
  GenericDeployableParams,
22
22
  } from '../Deployable/Deployable';
23
- import { DeployableTarget } from '../Deployable/DeployableTarget';
23
+ import { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';
24
24
  import { DeployableUnknownOwnerProvidedError } from '../errors';
25
25
  import {
26
26
  type GenericLog,
@@ -74,11 +74,14 @@ export type SimpleDenyListLog<
74
74
  * @export
75
75
  * @class SimpleDenyList
76
76
  * @typedef {SimpleDenyList}
77
- * @extends {DeployableTarget<SimpleDenyListPayload>}
77
+ * @extends {DeployableTargetWithRBAC<SimpleDenyListPayload>}
78
78
  */
79
79
  export class SimpleDenyList<
80
80
  Payload = SimpleDenyListPayload,
81
- > extends DeployableTarget<Payload | undefined, typeof simpleDenyListAbi> {
81
+ > extends DeployableTargetWithRBAC<
82
+ Payload | undefined,
83
+ typeof simpleDenyListAbi
84
+ > {
82
85
  public override readonly abi = simpleDenyListAbi;
83
86
  /**
84
87
  * @inheritdoc
@@ -104,7 +107,7 @@ export class SimpleDenyList<
104
107
  *
105
108
  * @public
106
109
  * @async
107
- * @param {?ReadParams<typeof simpleDenyListAbi, 'owner'>} [params]
110
+ * @param {?ReadParams} [params]
108
111
  * @returns {Promise<Address>} - The address of the owner
109
112
  */
110
113
  public async owner(
@@ -125,7 +128,7 @@ export class SimpleDenyList<
125
128
  * @public
126
129
  * @async
127
130
  * @param {Address} address - The address of the user
128
- * @param {?ReadParams<typeof simpleDenyListAbi, 'isAllowed'>} [params]
131
+ * @param {?ReadParams} [params]
129
132
  * @returns {Promise<boolean>} - True if the user is authorized
130
133
  */
131
134
  public async isAllowed(
@@ -148,8 +151,8 @@ export class SimpleDenyList<
148
151
  * @async
149
152
  * @param {Address[]} addresses - The list of users to update
150
153
  * @param {boolean[]} allowed - The denied status of each user
151
- * @param {?WriteParams<typeof simpleDenyListAbi, 'setDenied'>} [params]
152
- * @returns {unknown}
154
+ * @param {?WriteParams} [params]
155
+ * @returns {Promise<void>}
153
156
  */
154
157
  public async setDenied(
155
158
  addresses: Address[],
@@ -168,8 +171,8 @@ export class SimpleDenyList<
168
171
  * @async
169
172
  * @param {Address[]} addresses - The list of users to update
170
173
  * @param {boolean[]} allowed - The denied status of each user
171
- * @param {?WriteParams<typeof simpleDenyListAbi, 'setDenied'>} [params]
172
- * @returns {unknown}
174
+ * @param {?WriteParams} [params]
175
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
173
176
  */
174
177
  public async setDeniedRaw(
175
178
  addresses: Address[],
package/src/Boost.ts CHANGED
@@ -12,6 +12,25 @@ import type { Budget } from './Budgets/Budget';
12
12
  import type { Incentive } from './Incentives/Incentive';
13
13
  import type { Validator } from './Validators/Validator';
14
14
 
15
+ /**
16
+ * Interface representing a `BoostLib.Boost` on-chain struct
17
+ *
18
+ * @export
19
+ * @interface BoostPayload
20
+ * @typedef {BoostPayload}
21
+ */
22
+ export interface RawBoost {
23
+ action: Address;
24
+ validator: Address;
25
+ allowList: Address;
26
+ budget: Address;
27
+ incentives: readonly Address[];
28
+ protocolFee: bigint;
29
+ referralFee: bigint;
30
+ maxParticipants: bigint;
31
+ owner: Address;
32
+ }
33
+
15
34
  /**
16
35
  * Configuration used to instantiate a `Boost` instance.
17
36
  *