@boostxyz/sdk 1.1.0-alpha.22 → 1.1.0-alpha.24

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 (150) 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 +6 -6
  4. package/dist/Actions/EventAction.cjs +1 -1
  5. package/dist/Actions/EventAction.cjs.map +1 -1
  6. package/dist/Actions/EventAction.d.ts +36 -6
  7. package/dist/Actions/EventAction.d.ts.map +1 -1
  8. package/dist/Actions/EventAction.js +846 -15
  9. package/dist/Actions/EventAction.js.map +1 -1
  10. package/dist/AllowLists/AllowList.cjs +1 -1
  11. package/dist/AllowLists/AllowList.js +2 -2
  12. package/dist/AllowLists/OpenAllowList.d.ts +28 -28
  13. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  14. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  15. package/dist/AllowLists/SimpleAllowList.d.ts +28 -28
  16. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  17. package/dist/AllowLists/SimpleAllowList.js +11 -10
  18. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  19. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  20. package/dist/AllowLists/SimpleDenyList.d.ts +28 -28
  21. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  22. package/dist/AllowLists/SimpleDenyList.js +3 -3
  23. package/dist/Auth/PassthroughAuth.cjs +1 -1
  24. package/dist/Auth/PassthroughAuth.js +1 -1
  25. package/dist/BoostCore-Btl5BdAs.cjs +3 -0
  26. package/dist/BoostCore-Btl5BdAs.cjs.map +1 -0
  27. package/dist/{BoostCore-BVZExPPu.js → BoostCore-CD56zbYX.js} +1678 -499
  28. package/dist/BoostCore-CD56zbYX.js.map +1 -0
  29. package/dist/BoostCore.cjs +1 -1
  30. package/dist/BoostCore.d.ts +7 -7
  31. package/dist/BoostCore.d.ts.map +1 -1
  32. package/dist/BoostCore.js +6 -6
  33. package/dist/BoostRegistry.cjs +1 -1
  34. package/dist/BoostRegistry.cjs.map +1 -1
  35. package/dist/BoostRegistry.d.ts +6 -6
  36. package/dist/BoostRegistry.d.ts.map +1 -1
  37. package/dist/BoostRegistry.js +50 -50
  38. package/dist/BoostRegistry.js.map +1 -1
  39. package/dist/Budgets/Budget.cjs +1 -1
  40. package/dist/Budgets/Budget.js +1 -1
  41. package/dist/Budgets/ManagedBudget.cjs +1 -1
  42. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  43. package/dist/Budgets/ManagedBudget.d.ts +28 -28
  44. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  45. package/dist/Budgets/ManagedBudget.js +30 -29
  46. package/dist/Budgets/ManagedBudget.js.map +1 -1
  47. package/dist/Budgets/VestingBudget.d.ts +28 -28
  48. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  49. package/dist/Deployable/DeployableTarget.cjs +1 -1
  50. package/dist/Deployable/DeployableTarget.js +1 -1
  51. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  52. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -1
  53. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +92 -23
  54. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -1
  55. package/dist/Deployable/DeployableTargetWithRBAC.js +145 -47
  56. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -1
  57. package/dist/{Incentive-BhHaK3PZ.cjs → Incentive-CcnOIc8L.cjs} +2 -2
  58. package/dist/{Incentive-BhHaK3PZ.cjs.map → Incentive-CcnOIc8L.cjs.map} +1 -1
  59. package/dist/{Incentive-Cqg1w6wD.js → Incentive-rM5nKznp.js} +30 -29
  60. package/dist/{Incentive-Cqg1w6wD.js.map → Incentive-rM5nKznp.js.map} +1 -1
  61. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  62. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  63. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  64. package/dist/Incentives/AllowListIncentive.js +11 -10
  65. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  66. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  67. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  68. package/dist/Incentives/CGDAIncentive.d.ts +28 -28
  69. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  70. package/dist/Incentives/CGDAIncentive.js +12 -11
  71. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  72. package/dist/Incentives/ERC1155Incentive.d.ts +28 -28
  73. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  74. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  75. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  76. package/dist/Incentives/ERC20Incentive.d.ts +34 -31
  77. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  78. package/dist/Incentives/ERC20Incentive.js +30 -27
  79. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  80. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +28 -28
  81. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
  82. package/dist/Incentives/ERC20VariableIncentive.d.ts +28 -28
  83. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  84. package/dist/Incentives/Incentive.cjs +1 -1
  85. package/dist/Incentives/Incentive.js +2 -2
  86. package/dist/Incentives/PointsIncentive.cjs +1 -1
  87. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  88. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  89. package/dist/Incentives/PointsIncentive.js +12 -11
  90. package/dist/Incentives/PointsIncentive.js.map +1 -1
  91. package/dist/{SimpleDenyList-CGaWjuld.js → SimpleDenyList-BDXpY74P.js} +18 -17
  92. package/dist/SimpleDenyList-BDXpY74P.js.map +1 -0
  93. package/dist/{SimpleDenyList-BUR17Tt1.cjs → SimpleDenyList-DNj5qDWM.cjs} +2 -2
  94. package/dist/SimpleDenyList-DNj5qDWM.cjs.map +1 -0
  95. package/dist/Validators/SignerValidator.cjs +1 -1
  96. package/dist/Validators/SignerValidator.cjs.map +1 -1
  97. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  98. package/dist/Validators/SignerValidator.js +13 -12
  99. package/dist/Validators/SignerValidator.js.map +1 -1
  100. package/dist/Validators/Validator.cjs +1 -1
  101. package/dist/Validators/Validator.js +1 -1
  102. package/dist/deployments-DF_6-7hH.cjs +2 -0
  103. package/dist/deployments-DF_6-7hH.cjs.map +1 -0
  104. package/dist/deployments-fJsWblwS.js +56 -0
  105. package/dist/deployments-fJsWblwS.js.map +1 -0
  106. package/dist/deployments.json +26 -12
  107. package/dist/{generated-CKt2yCQd.js → generated-CsNyWPKA.js} +458 -443
  108. package/dist/generated-CsNyWPKA.js.map +1 -0
  109. package/dist/generated-DHerxf1y.cjs +3 -0
  110. package/dist/generated-DHerxf1y.cjs.map +1 -0
  111. package/dist/index.cjs +1 -1
  112. package/dist/index.js +116 -115
  113. package/package.json +4 -4
  114. package/src/Actions/EventAction.test.ts +384 -119
  115. package/src/Actions/EventAction.ts +76 -35
  116. package/src/AllowLists/SimpleAllowList.ts +1 -0
  117. package/src/AllowLists/SimpleDenyList.ts +1 -0
  118. package/src/BoostCore.test.ts +78 -78
  119. package/src/BoostCore.ts +19 -13
  120. package/src/BoostRegistry.ts +10 -10
  121. package/src/Budgets/ManagedBudget.test.ts +41 -17
  122. package/src/Budgets/ManagedBudget.ts +1 -11
  123. package/src/Budgets/VestingBudget.ts +3 -1
  124. package/src/Deployable/DeployableTargetWithRBAC.test.ts +103 -0
  125. package/src/Deployable/DeployableTargetWithRBAC.ts +160 -36
  126. package/src/Incentives/AllowListIncentive.test.ts +7 -7
  127. package/src/Incentives/AllowListIncentive.ts +1 -0
  128. package/src/Incentives/CGDAIncentive.ts +1 -0
  129. package/src/Incentives/ERC1155Incentive.ts +3 -1
  130. package/src/Incentives/ERC20Incentive.ts +10 -3
  131. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +1 -0
  132. package/src/Incentives/ERC20VariableIncentive.ts +1 -0
  133. package/src/Incentives/PointsIncentive.ts +1 -0
  134. package/src/Validators/SignerValidator.ts +1 -0
  135. package/dist/BoostCore-BVZExPPu.js.map +0 -1
  136. package/dist/BoostCore-D-E-cnGI.cjs +0 -3
  137. package/dist/BoostCore-D-E-cnGI.cjs.map +0 -1
  138. package/dist/EventAction-BZt5cjbe.cjs +0 -2
  139. package/dist/EventAction-BZt5cjbe.cjs.map +0 -1
  140. package/dist/EventAction-C_-hJXWm.js +0 -1541
  141. package/dist/EventAction-C_-hJXWm.js.map +0 -1
  142. package/dist/SimpleDenyList-BUR17Tt1.cjs.map +0 -1
  143. package/dist/SimpleDenyList-CGaWjuld.js.map +0 -1
  144. package/dist/deployments-DVXioW2i.cjs +0 -2
  145. package/dist/deployments-DVXioW2i.cjs.map +0 -1
  146. package/dist/deployments-oykLv3_Z.js +0 -43
  147. package/dist/deployments-oykLv3_Z.js.map +0 -1
  148. package/dist/generated-CKt2yCQd.js.map +0 -1
  149. package/dist/generated-CyTNlOwM.cjs +0 -3
  150. package/dist/generated-CyTNlOwM.cjs.map +0 -1
@@ -6,24 +6,15 @@ 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';
10
- import functions from '@boostxyz/signatures/functions';
11
- import {
12
- GetTransactionReceiptParameters,
13
- getTransaction,
14
- getTransactionReceipt,
15
- } from '@wagmi/core';
9
+ import { getTransaction, getTransactionReceipt } from '@wagmi/core';
16
10
  import { match } from 'ts-pattern';
17
11
  import {
18
- type Abi,
19
12
  type AbiEvent,
20
13
  type AbiFunction,
21
14
  AbiItem,
22
15
  type Address,
23
- type ContractEventName,
24
16
  type ContractFunctionName,
25
17
  type GetLogsReturnType,
26
- type GetTransactionParameters,
27
18
  type Hex,
28
19
  type Log,
29
20
  type PublicClient,
@@ -34,6 +25,7 @@ import {
34
25
  fromHex,
35
26
  isAddress,
36
27
  isAddressEqual,
28
+ zeroAddress,
37
29
  zeroHash,
38
30
  } from 'viem';
39
31
  import { EventAction as EventActionBases } from '../../dist/deployments.json';
@@ -55,7 +47,6 @@ import {
55
47
  ValidationAbiMissingError,
56
48
  } from '../errors';
57
49
  import {
58
- type GetLogsParams,
59
50
  type Overwrite,
60
51
  type ReadParams,
61
52
  RegistryType,
@@ -227,14 +218,14 @@ export interface ActionStep {
227
218
  * Parameters for validating an action step.
228
219
  *
229
220
  * @typedef {Object} ValidateActionStepParams
230
- * @property {Record<Hex, AbiEvent | AbiFunction>} [knownSignatures] - Optional record of known events, keyed by 32 byte selectors.
221
+ * @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.
231
222
  * @property {AbiEvent | AbiFunction} [abiItem] - Optional ABI item definition.
232
223
  * @property {EventLogs} [logs] - Event logs to validate against. Required if 'hash' is not provided.
233
224
  * @property {Hex} [hash] - Transaction hash to validate against. Required if 'logs' is not provided.
234
225
  * @property {number} [chainId] - Chain ID for the transaction. Required if 'hash' is provided.
235
226
  */
236
227
  export type ValidateActionStepParams = {
237
- knownSignatures?: Record<Hex, AbiEvent | AbiFunction>;
228
+ knownSignatures: Record<Hex, AbiEvent | AbiFunction>;
238
229
  abiItem?: AbiEvent | AbiFunction;
239
230
  } & ({ logs: EventLogs } | { hash: Hex; chainId: number });
240
231
 
@@ -366,6 +357,7 @@ export class EventAction extends DeployableTarget<
366
357
  * @type {Record<number, Address>}
367
358
  */
368
359
  public static override bases: Record<number, Address> = {
360
+ 31337: import.meta.env.VITE_EVENT_ACTION_BASE,
369
361
  ...(EventActionBases as Record<number, Address>),
370
362
  };
371
363
  /**
@@ -491,6 +483,8 @@ export class EventAction extends DeployableTarget<
491
483
  /**
492
484
  * Derives the action claimant address from a transaction based on the provided ActionClaimant configuration.
493
485
  * This method supports both event-based and function-based claimant derivation.
486
+ * **Important**: The claimant is considered to be `transaction.from` when `claimant.fieldIndex` is 255.
487
+ * This may have unintended side effects for bridged transactions and SCW transactions, so these are considered unsupported use cases for the time being.
494
488
  *
495
489
  ** @example
496
490
  * // Example usage
@@ -505,8 +499,11 @@ export class EventAction extends DeployableTarget<
505
499
  * const params: ValidateActionStepParams = {
506
500
  * hash: '0x5678...',
507
501
  * chainId: 1,
508
- * knownSignatures?: {
509
- * '0x1234...': {}
502
+ * knownSignatures: {
503
+ * '0x1234...': {
504
+ * type: 'event',
505
+ * name: 'Transfer(...)'
506
+ * }
510
507
  * }
511
508
  * };
512
509
  * const claimantAddress = await eventAction.deriveActionClaimantFromTransaction(claimant, params);
@@ -521,18 +518,37 @@ export class EventAction extends DeployableTarget<
521
518
  claimant: ActionClaimant,
522
519
  params: ValidateActionStepParams,
523
520
  ): Promise<Address | undefined> {
521
+ // find message sender and return it
522
+ // WARNING: this is error prone in bridged transactions and SCW transactions, as this will return exit node
523
+ if (claimant.fieldIndex === 255) {
524
+ if ('hash' in params) {
525
+ const transaction = await getTransaction(this._config, {
526
+ hash: params.hash,
527
+ });
528
+ return transaction.from;
529
+ }
530
+ if ('logs' in params) {
531
+ for (let log of params.logs) {
532
+ if (log.transactionHash) {
533
+ const transaction = await getTransaction(this._config, {
534
+ hash: log.transactionHash,
535
+ });
536
+ return transaction.from;
537
+ }
538
+ }
539
+ }
540
+ return undefined;
541
+ }
542
+
524
543
  const signature = claimant.signature;
544
+
525
545
  if (claimant.signatureType === SignatureType.EVENT) {
526
546
  let event: AbiEvent;
527
547
  if (params.abiItem) event = params.abiItem as AbiEvent;
528
548
  else {
529
- const sigPool: Record<Hex, AbiEvent> = {
530
- ...(events.abi as Record<Hex, AbiEvent>),
531
- ...((params.knownSignatures as Record<Hex, AbiEvent>) || {}),
532
- };
549
+ const sigPool = params.knownSignatures as Record<Hex, AbiEvent>;
533
550
  event = sigPool[signature] as AbiEvent;
534
551
  }
535
-
536
552
  if (!event) {
537
553
  throw new ValidationAbiMissingError(signature);
538
554
  }
@@ -578,10 +594,7 @@ export class EventAction extends DeployableTarget<
578
594
  let func: AbiFunction;
579
595
  if (params.abiItem) func = params.abiItem as AbiFunction;
580
596
  else {
581
- const sigPool: Record<Hex, AbiFunction> = {
582
- ...(functions.abi as Record<Hex, AbiFunction>),
583
- ...((params.knownSignatures as Record<Hex, AbiFunction>) || {}),
584
- };
597
+ const sigPool = params.knownSignatures as Record<Hex, AbiFunction>;
585
598
  func = sigPool[signature] as AbiFunction;
586
599
  }
587
600
  if (!func) {
@@ -664,10 +677,7 @@ export class EventAction extends DeployableTarget<
664
677
  let event: AbiEvent;
665
678
  if (params.abiItem) event = params.abiItem as AbiEvent;
666
679
  else {
667
- const sigPool: Record<Hex, AbiEvent> = {
668
- ...(events.abi as Record<Hex, AbiEvent>),
669
- ...((params.knownSignatures as Record<Hex, AbiEvent>) || {}),
670
- };
680
+ const sigPool = params.knownSignatures as Record<Hex, AbiEvent>;
671
681
  event = sigPool[signature] as AbiEvent;
672
682
  }
673
683
 
@@ -747,7 +757,7 @@ export class EventAction extends DeployableTarget<
747
757
  * @public
748
758
  * @param {ActionStep} actionStep - The action step containing the function to validate.
749
759
  * @param {Transaction} transaction - The transaction that will be validated against.
750
- * @param {Object} [params] - Optional parameters for validation.
760
+ * @param {Object} [params] - Parameters for validation.
751
761
  * @param {AbiItem} [params.abiItem] - The ABI item for the function, if known.
752
762
  * @param {Record<Hex, AbiEvent | AbiFunction>} [params.knownSignatures] - A record of known signatures.
753
763
  * @returns {boolean} Returns true if the action function is valid, false otherwise.
@@ -757,18 +767,15 @@ export class EventAction extends DeployableTarget<
757
767
  public isActionFunctionValid(
758
768
  actionStep: ActionStep,
759
769
  transaction: Transaction,
760
- params?: Pick<ValidateActionStepParams, 'abiItem' | 'knownSignatures'>,
770
+ params: Pick<ValidateActionStepParams, 'abiItem' | 'knownSignatures'>,
761
771
  ) {
762
772
  const criteria = actionStep.actionParameter;
763
773
  let signature = actionStep.signature;
764
774
 
765
775
  let func: AbiFunction;
766
- if (params?.abiItem) func = params?.abiItem as AbiFunction;
776
+ if (params.abiItem) func = params?.abiItem as AbiFunction;
767
777
  else {
768
- const sigPool: Record<Hex, AbiFunction> = {
769
- ...(functions.abi as Record<Hex, AbiFunction>),
770
- ...((params?.knownSignatures as Record<Hex, AbiFunction>) || {}),
771
- };
778
+ const sigPool = params.knownSignatures as Record<Hex, AbiFunction>;
772
779
  func = sigPool[signature] as AbiFunction;
773
780
  }
774
781
  if (!func) {
@@ -1261,3 +1268,37 @@ export function anyActionParameter(): Criteria {
1261
1268
  filterData: zeroHash,
1262
1269
  };
1263
1270
  }
1271
+
1272
+ /**
1273
+ * Creates an ActionClaimant object that represents the transaction sender as the claimant.
1274
+ * This function is useful when you want to set up an action where the transaction sender is always considered the valid claimant,
1275
+ * regardless of the event or function parameters.
1276
+ *
1277
+ * The returned ActionClaimant has the following properties:
1278
+ * - signatureType: Set to SignatureType.EVENT (though it doesn't matter for this case)
1279
+ * - signature: Set to zeroHash (0x0000...0000)
1280
+ * - fieldIndex: Set to 255, indicating "any" field
1281
+ * - targetContract: Set to zeroAddress (0x0000...0000)
1282
+ * - chainid: Set to 0, indicating it's valid for any chain
1283
+ *
1284
+ * @returns {ActionClaimant} An ActionClaimant object representing the msg.sender
1285
+ *
1286
+ * @example
1287
+ * const eventAction = new EventAction();
1288
+ * const payload: EventActionPayload = {
1289
+ * actionClaimant: transactionSenderClaimant(),
1290
+ * actionSteps: [
1291
+ * // ... define your action steps here
1292
+ * ]
1293
+ * };
1294
+ * await eventAction.deploy(payload);
1295
+ */
1296
+ export function transactionSenderClaimant(): ActionClaimant {
1297
+ return {
1298
+ signatureType: SignatureType.EVENT,
1299
+ signature: zeroHash,
1300
+ fieldIndex: 255,
1301
+ targetContract: zeroAddress,
1302
+ chainid: 0,
1303
+ };
1304
+ }
@@ -99,6 +99,7 @@ export class SimpleAllowList extends DeployableTargetWithRBAC<
99
99
  * @type {Record<number, Address>}
100
100
  */
101
101
  public static override bases: Record<number, Address> = {
102
+ 31337: import.meta.env.VITE_SIMPLE_ALLOWLIST_BASE,
102
103
  ...(SimpleAllowListBases as Record<number, Address>),
103
104
  };
104
105
  /**
@@ -91,6 +91,7 @@ export class SimpleDenyList<
91
91
  * @type {Record<number, Address>}
92
92
  */
93
93
  public static override bases: Record<number, Address> = {
94
+ 31337: import.meta.env.VITE_SIMPLE_DENYLIST_BASE,
94
95
  ...(SimpleDenyListBases as Record<number, Address>),
95
96
  };
96
97
  /**