@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
@@ -2,22 +2,21 @@ import { selectors as eventSelectors } from "@boostxyz/signatures/events";
2
2
  import { selectors as funcSelectors } from "@boostxyz/signatures/functions";
3
3
  import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
4
4
  import {
5
- type AbiEvent,
5
+ AbiEvent,
6
+ AbiFunction,
6
7
  type Address,
7
- type GetLogsReturnType,
8
8
  type Hex,
9
- type Log,
10
9
  isAddress,
11
- pad,
10
+ isAddressEqual,
12
11
  parseEther,
13
12
  toHex,
14
13
  zeroAddress,
15
14
  zeroHash,
16
- } from 'viem';
17
- import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
18
- import type { MockERC20 } from '@boostxyz/test/MockERC20';
19
- import type { MockERC721 } from '@boostxyz/test/MockERC721';
20
- import { accounts } from '@boostxyz/test/accounts';
15
+ } from "viem";
16
+ import { beforeAll, beforeEach, describe, expect, test } from "vitest";
17
+ import type { MockERC20 } from "@boostxyz/test/MockERC20";
18
+ import type { MockERC721 } from "@boostxyz/test/MockERC721";
19
+ import { accounts } from "@boostxyz/test/accounts";
21
20
  import {
22
21
  type Fixtures,
23
22
  type StringEmitterFixtures,
@@ -26,7 +25,7 @@ import {
26
25
  fundErc20,
27
26
  deployStringEmitterMock,
28
27
  fundErc721,
29
- } from '@boostxyz/test/helpers';
28
+ } from "@boostxyz/test/helpers";
30
29
  import {
31
30
  EventAction,
32
31
  type EventLogs,
@@ -36,7 +35,9 @@ import {
36
35
  SignatureType,
37
36
  Criteria,
38
37
  anyActionParameter,
38
+ transactionSenderClaimant,
39
39
  } from "./EventAction";
40
+ import { allKnownSignatures } from "@boostxyz/test/allKnownSignatures";
40
41
 
41
42
  let fixtures: Fixtures,
42
43
  erc721: MockERC721,
@@ -83,14 +84,18 @@ function basicErc721TransferAction(
83
84
  }
84
85
 
85
86
  function basicErc721TransferActionWithEmptyActionParameter(erc721: MockERC721) {
86
- const eventActionPayload = basicErc721TransferAction(erc721)
87
+ const eventActionPayload = basicErc721TransferAction(erc721);
87
88
  if (eventActionPayload.actionSteps[0]?.actionParameter) {
88
- eventActionPayload.actionSteps[0].actionParameter = anyActionParameter()
89
+ eventActionPayload.actionSteps[0].actionParameter = anyActionParameter();
89
90
  }
90
- return eventActionPayload
91
+ return eventActionPayload;
91
92
  }
92
93
 
93
- function cloneEventAction(fixtures: Fixtures, erc721: MockERC721, eventActionPayload = basicErc721TransferAction(erc721)) {
94
+ function cloneEventAction(
95
+ fixtures: Fixtures,
96
+ erc721: MockERC721,
97
+ eventActionPayload = basicErc721TransferAction(erc721),
98
+ ) {
94
99
  return function cloneEventAction() {
95
100
  return fixtures.registry.initialize(
96
101
  crypto.randomUUID(),
@@ -129,11 +134,11 @@ function basicErc721MintFuncAction(
129
134
  }
130
135
 
131
136
  function basicErc721MintFuncActionWithEmptyActionParameter(erc721: MockERC721) {
132
- const eventActionPayload = basicErc721MintFuncAction(erc721)
137
+ const eventActionPayload = basicErc721MintFuncAction(erc721);
133
138
  if (eventActionPayload.actionSteps[0]?.actionParameter) {
134
- eventActionPayload.actionSteps[0].actionParameter = anyActionParameter()
139
+ eventActionPayload.actionSteps[0].actionParameter = anyActionParameter();
135
140
  }
136
- return eventActionPayload
141
+ return eventActionPayload;
137
142
  }
138
143
 
139
144
  function basicErc20MintFuncAction(erc20: MockERC20): EventActionPayloadSimple {
@@ -245,14 +250,15 @@ function cloneFunctionAction20(fixtures: Fixtures, erc20: MockERC20) {
245
250
  };
246
251
  }
247
252
 
248
- function cloneFunctionAction(fixtures: Fixtures, erc721: MockERC721, eventActionPayload = basicErc721MintFuncAction(erc721)) {
253
+ function cloneFunctionAction(
254
+ fixtures: Fixtures,
255
+ erc721: MockERC721,
256
+ eventActionPayload = basicErc721MintFuncAction(erc721),
257
+ ) {
249
258
  return function cloneFunctionAction() {
250
259
  return fixtures.registry.clone(
251
260
  crypto.randomUUID(),
252
- new fixtures.bases.EventAction(
253
- defaultOptions,
254
- eventActionPayload
255
- ),
261
+ new fixtures.bases.EventAction(defaultOptions, eventActionPayload),
256
262
  );
257
263
  };
258
264
  }
@@ -273,7 +279,7 @@ function createMockCriteria(
273
279
  filterType: FilterType,
274
280
  fieldType: PrimitiveType,
275
281
  filterData: Hex,
276
- fieldIndex: number = 0
282
+ fieldIndex: number = 0,
277
283
  ): Criteria {
278
284
  return {
279
285
  filterType,
@@ -413,12 +419,23 @@ describe("EventAction Event Selector", () => {
413
419
  const action = await loadFixture(cloneEventAction(fixtures, erc721));
414
420
  const recipient = accounts[1].account;
415
421
  await erc721.approve(recipient, 1n);
416
- const { hash } = await erc721.transferFromRaw(defaultOptions.account.address, recipient, 1n);
417
- expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
422
+ const { hash } = await erc721.transferFromRaw(
423
+ defaultOptions.account.address,
424
+ recipient,
425
+ 1n,
426
+ );
427
+ expect(
428
+ await action.validateActionSteps({
429
+ hash,
430
+ chainId,
431
+ knownSignatures: allKnownSignatures,
432
+ }),
433
+ ).toBe(true);
418
434
  });
419
435
 
420
436
  test("can supply your own logs to validate against", async () => {
421
- const hash = "0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5"
437
+ const hash =
438
+ "0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5";
422
439
  const logs: EventLogs = [
423
440
  {
424
441
  eventName: "Transfer",
@@ -446,7 +463,14 @@ describe("EventAction Event Selector", () => {
446
463
  },
447
464
  ];
448
465
  const action = await loadFixture(cloneEventAction(fixtures, erc721));
449
- expect(await action.validateActionSteps({ hash, chainId, logs })).toBe(true);
466
+ expect(
467
+ await action.validateActionSteps({
468
+ hash,
469
+ chainId,
470
+ logs,
471
+ knownSignatures: allKnownSignatures,
472
+ }),
473
+ ).toBe(true);
450
474
  });
451
475
 
452
476
  describe("string event actions", () => {
@@ -463,10 +487,15 @@ describe("EventAction Event Selector", () => {
463
487
  ),
464
488
  );
465
489
 
466
- const hash = await stringEmitterFixtures.emitIndexedString("Hello world");
467
- await expect(() => action.validateActionSteps({ hash, chainId })).rejects.toThrowError(
468
- /Parameter is not transparently stored onchain/,
469
- );
490
+ const hash =
491
+ await stringEmitterFixtures.emitIndexedString("Hello world");
492
+ await expect(() =>
493
+ action.validateActionSteps({
494
+ hash,
495
+ chainId,
496
+ knownSignatures: allKnownSignatures,
497
+ }),
498
+ ).rejects.toThrowError(/Parameter is not transparently stored onchain/);
470
499
  });
471
500
  test("can parse and validate contains for an emitted string event", async () => {
472
501
  const action = await loadFixture(
@@ -481,7 +510,13 @@ describe("EventAction Event Selector", () => {
481
510
  ),
482
511
  );
483
512
  const hash = await stringEmitterFixtures.emitString("Hello world");
484
- expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
513
+ expect(
514
+ await action.validateActionSteps({
515
+ hash,
516
+ chainId,
517
+ knownSignatures: allKnownSignatures,
518
+ }),
519
+ ).toBe(true);
485
520
  });
486
521
  test("can parse and validate regex for an emitted string event", async () => {
487
522
  const action = await loadFixture(
@@ -497,20 +532,63 @@ describe("EventAction Event Selector", () => {
497
532
  );
498
533
 
499
534
  const hash = await stringEmitterFixtures.emitString("Hello world");
500
- expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
535
+ expect(
536
+ await action.validateActionSteps({
537
+ hash,
538
+ chainId,
539
+ knownSignatures: allKnownSignatures,
540
+ }),
541
+ ).toBe(true);
501
542
  });
502
543
  });
503
544
 
545
+ test("can derive a transaction sender claimant from an event action", async () => {
546
+ const action = await loadFixture(
547
+ cloneEventAction(fixtures, erc721, {
548
+ ...basicErc721TransferAction(erc721),
549
+ actionClaimant: transactionSenderClaimant(),
550
+ }),
551
+ );
552
+ const recipient = accounts[1].account;
553
+ await erc721.approve(recipient, 1n);
554
+ const { hash } = await erc721.transferFromRaw(
555
+ defaultOptions.account.address,
556
+ recipient,
557
+ 1n,
558
+ );
559
+ expect(
560
+ isAddressEqual(
561
+ (await action.deriveActionClaimantFromTransaction(
562
+ await action.getActionClaimant(),
563
+ {
564
+ hash,
565
+ chainId,
566
+ knownSignatures: allKnownSignatures,
567
+ },
568
+ ))!,
569
+ defaultOptions.account.address,
570
+ ),
571
+ ).toBe(true);
572
+ });
573
+
504
574
  test("can derive the claimant from an event action", async () => {
505
575
  const action = await loadFixture(cloneEventAction(fixtures, erc721));
506
576
  const recipient = accounts[1].account;
507
577
  await erc721.approve(recipient, 1n);
508
- const { hash } = await erc721.transferFromRaw(defaultOptions.account.address, recipient, 1n);
578
+ const { hash } = await erc721.transferFromRaw(
579
+ defaultOptions.account.address,
580
+ recipient,
581
+ 1n,
582
+ );
509
583
  expect(
510
- await action.deriveActionClaimantFromTransaction(await action.getActionClaimant(), {
511
- hash,
512
- chainId,
513
- }),
584
+ await action.deriveActionClaimantFromTransaction(
585
+ await action.getActionClaimant(),
586
+ {
587
+ hash,
588
+ chainId,
589
+ knownSignatures: allKnownSignatures,
590
+ },
591
+ ),
514
592
  ).toBe(recipient);
515
593
  });
516
594
 
@@ -522,148 +600,310 @@ describe("EventAction Event Selector", () => {
522
600
  });
523
601
 
524
602
  expect(
525
- await action.deriveActionClaimantFromTransaction(await action.getActionClaimant(), {
526
- hash,
527
- chainId,
528
- }),
603
+ await action.deriveActionClaimantFromTransaction(
604
+ await action.getActionClaimant(),
605
+ {
606
+ hash,
607
+ chainId,
608
+ knownSignatures: allKnownSignatures,
609
+ },
610
+ ),
529
611
  ).toBe(recipient);
530
612
  });
531
613
 
532
- test('validates empty actionParameter', async () => {
533
- const action = await loadFixture(cloneEventAction(fixtures, erc721, basicErc721TransferActionWithEmptyActionParameter(erc721)))
614
+ test("validates empty actionParameter", async () => {
615
+ const action = await loadFixture(
616
+ cloneEventAction(
617
+ fixtures,
618
+ erc721,
619
+ basicErc721TransferActionWithEmptyActionParameter(erc721),
620
+ ),
621
+ );
534
622
  const recipient = accounts[1].account;
535
623
  await erc721.approve(recipient, 1n);
536
- const { hash } = await erc721.transferFromRaw(defaultOptions.account.address, recipient, 1n);
537
- expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
538
- })
624
+ const { hash } = await erc721.transferFromRaw(
625
+ defaultOptions.account.address,
626
+ recipient,
627
+ 1n,
628
+ );
629
+ expect(
630
+ await action.validateActionSteps({
631
+ hash,
632
+ chainId,
633
+ knownSignatures: allKnownSignatures,
634
+ }),
635
+ ).toBe(true);
636
+ });
539
637
  });
540
638
  });
541
639
 
542
640
  describe("validateFieldAgainstCriteria unit tests", () => {
543
- let action: EventAction
641
+ let action: EventAction;
544
642
  beforeAll(async () => {
545
643
  action = await loadFixture(cloneEventAction(fixtures, erc721));
546
644
  });
547
- const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
548
- const mockInput = { decodedArgs: ['not used'] };
549
-
550
- test('should return true for EQUAL filter type with ADDRESS field type', () => {
551
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.ADDRESS, mockAddress);
552
- const result = action.validateFieldAgainstCriteria(mockCriteria, mockAddress, mockInput);
645
+ const mockAddress = "0x1234567890abcdef1234567890abcdef12345678";
646
+ const mockInput = { decodedArgs: ["not used"] };
647
+
648
+ test("should return true for EQUAL filter type with ADDRESS field type", () => {
649
+ const mockCriteria = createMockCriteria(
650
+ FilterType.EQUAL,
651
+ PrimitiveType.ADDRESS,
652
+ mockAddress,
653
+ );
654
+ const result = action.validateFieldAgainstCriteria(
655
+ mockCriteria,
656
+ mockAddress,
657
+ mockInput,
658
+ );
553
659
  expect(result).toBe(true);
554
660
  });
555
661
 
556
- test('should return true for EQUAL filter type with UINT field type', () => {
557
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.UINT, '0xc8');
558
- const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
662
+ test("should return true for EQUAL filter type with UINT field type", () => {
663
+ const mockCriteria = createMockCriteria(
664
+ FilterType.EQUAL,
665
+ PrimitiveType.UINT,
666
+ "0xc8",
667
+ );
668
+ const result = action.validateFieldAgainstCriteria(
669
+ mockCriteria,
670
+ 200n,
671
+ mockInput,
672
+ );
559
673
  expect(result).toBe(true);
560
674
  });
561
- test('should return true for EQUAL filter type with STRING field type when values match', () => {
675
+ test("should return true for EQUAL filter type with STRING field type when values match", () => {
562
676
  // Decoded value: 'hello'
563
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.STRING, '0x68656c6c6f');
564
- const result = action.validateFieldAgainstCriteria(mockCriteria, 'hello', mockInput);
677
+ const mockCriteria = createMockCriteria(
678
+ FilterType.EQUAL,
679
+ PrimitiveType.STRING,
680
+ "0x68656c6c6f",
681
+ );
682
+ const result = action.validateFieldAgainstCriteria(
683
+ mockCriteria,
684
+ "hello",
685
+ mockInput,
686
+ );
565
687
  expect(result).toBe(true);
566
688
  });
567
689
 
568
- test('should return false for EQUAL filter type with STRING field type when values do not match', () => {
690
+ test("should return false for EQUAL filter type with STRING field type when values do not match", () => {
569
691
  // Decoded value: 'hello'
570
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.STRING, '0x68656c6c6f');
571
- const result = action.validateFieldAgainstCriteria(mockCriteria, 'world', mockInput);
692
+ const mockCriteria = createMockCriteria(
693
+ FilterType.EQUAL,
694
+ PrimitiveType.STRING,
695
+ "0x68656c6c6f",
696
+ );
697
+ const result = action.validateFieldAgainstCriteria(
698
+ mockCriteria,
699
+ "world",
700
+ mockInput,
701
+ );
572
702
  expect(result).toBe(false);
573
703
  });
574
704
 
575
- test('should return true for EQUAL filter type with BYTES field type when values match', () => {
705
+ test("should return true for EQUAL filter type with BYTES field type when values match", () => {
576
706
  // Decoded value: '0x68656c6c6f' (hex for 'hello')
577
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.BYTES, '0x68656c6c6f');
578
- const result = action.validateFieldAgainstCriteria(mockCriteria, '0x68656c6c6f', mockInput);
707
+ const mockCriteria = createMockCriteria(
708
+ FilterType.EQUAL,
709
+ PrimitiveType.BYTES,
710
+ "0x68656c6c6f",
711
+ );
712
+ const result = action.validateFieldAgainstCriteria(
713
+ mockCriteria,
714
+ "0x68656c6c6f",
715
+ mockInput,
716
+ );
579
717
  expect(result).toBe(true);
580
718
  });
581
719
 
582
- test('should return false for EQUAL filter type with BYTES field type when values do not match', () => {
720
+ test("should return false for EQUAL filter type with BYTES field type when values do not match", () => {
583
721
  // Decoded value: '0x68656c6c6f' (hex for 'hello')
584
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.BYTES, '0x68656c6c6f');
585
- const result = action.validateFieldAgainstCriteria(mockCriteria, '0x776f726c64', mockInput); // hex for 'world'
722
+ const mockCriteria = createMockCriteria(
723
+ FilterType.EQUAL,
724
+ PrimitiveType.BYTES,
725
+ "0x68656c6c6f",
726
+ );
727
+ const result = action.validateFieldAgainstCriteria(
728
+ mockCriteria,
729
+ "0x776f726c64",
730
+ mockInput,
731
+ ); // hex for 'world'
586
732
  expect(result).toBe(false);
587
733
  });
588
734
 
589
- test('should return false for NOT_EQUAL filter type with ADDRESS field type', () => {
590
- const mockCriteria = createMockCriteria(FilterType.NOT_EQUAL, PrimitiveType.ADDRESS, mockAddress);
591
- const result = action.validateFieldAgainstCriteria(mockCriteria, zeroAddress, mockInput);
735
+ test("should return false for NOT_EQUAL filter type with ADDRESS field type", () => {
736
+ const mockCriteria = createMockCriteria(
737
+ FilterType.NOT_EQUAL,
738
+ PrimitiveType.ADDRESS,
739
+ mockAddress,
740
+ );
741
+ const result = action.validateFieldAgainstCriteria(
742
+ mockCriteria,
743
+ zeroAddress,
744
+ mockInput,
745
+ );
592
746
  expect(result).toBe(true);
593
747
  });
594
748
 
595
- test('should return true for NOT_EQUAL filter type with UINT field type', () => {
596
- const mockCriteria = createMockCriteria(FilterType.NOT_EQUAL, PrimitiveType.UINT, '0xc9');
597
- const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
749
+ test("should return true for NOT_EQUAL filter type with UINT field type", () => {
750
+ const mockCriteria = createMockCriteria(
751
+ FilterType.NOT_EQUAL,
752
+ PrimitiveType.UINT,
753
+ "0xc9",
754
+ );
755
+ const result = action.validateFieldAgainstCriteria(
756
+ mockCriteria,
757
+ 200n,
758
+ mockInput,
759
+ );
598
760
  expect(result).toBe(true);
599
761
  });
600
762
 
601
- test('should throw InvalidNumericalCriteriaError for GREATER_THAN filter type with non-uint field type', () => {
602
- const mockCriteria = createMockCriteria(FilterType.GREATER_THAN, PrimitiveType.STRING, '0x100');
603
- expect(() => action.validateFieldAgainstCriteria(mockCriteria, '200', mockInput)).toThrow('non-numerical criteria');
763
+ test("should throw InvalidNumericalCriteriaError for GREATER_THAN filter type with non-uint field type", () => {
764
+ const mockCriteria = createMockCriteria(
765
+ FilterType.GREATER_THAN,
766
+ PrimitiveType.STRING,
767
+ "0x100",
768
+ );
769
+ expect(() =>
770
+ action.validateFieldAgainstCriteria(mockCriteria, "200", mockInput),
771
+ ).toThrow("non-numerical criteria");
604
772
  });
605
773
 
606
- test('should return true for GREATER_THAN filter type with UINT field type', () => {
607
- const mockCriteria = createMockCriteria(FilterType.GREATER_THAN, PrimitiveType.UINT, '0x64');
608
- const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
774
+ test("should return true for GREATER_THAN filter type with UINT field type", () => {
775
+ const mockCriteria = createMockCriteria(
776
+ FilterType.GREATER_THAN,
777
+ PrimitiveType.UINT,
778
+ "0x64",
779
+ );
780
+ const result = action.validateFieldAgainstCriteria(
781
+ mockCriteria,
782
+ 200n,
783
+ mockInput,
784
+ );
609
785
  expect(result).toBe(true);
610
786
  });
611
787
 
612
- test('should return true for CONTAINS filter type with STRING field type', () => {
788
+ test("should return true for CONTAINS filter type with STRING field type", () => {
613
789
  // Decoded value: 'hello'
614
- const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.STRING, '0x68656c6c6f');
615
- const result = action.validateFieldAgainstCriteria(mockCriteria, 'hello world', mockInput);
790
+ const mockCriteria = createMockCriteria(
791
+ FilterType.CONTAINS,
792
+ PrimitiveType.STRING,
793
+ "0x68656c6c6f",
794
+ );
795
+ const result = action.validateFieldAgainstCriteria(
796
+ mockCriteria,
797
+ "hello world",
798
+ mockInput,
799
+ );
616
800
  expect(result).toBe(true);
617
801
  });
618
802
 
619
- test('should return true for CONTAINS filter type with BYTES field type', () => {
620
- const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.BYTES, '0xbeef');
621
- const result = action.validateFieldAgainstCriteria(mockCriteria, '0xdeadbeef', mockInput);
803
+ test("should return true for CONTAINS filter type with BYTES field type", () => {
804
+ const mockCriteria = createMockCriteria(
805
+ FilterType.CONTAINS,
806
+ PrimitiveType.BYTES,
807
+ "0xbeef",
808
+ );
809
+ const result = action.validateFieldAgainstCriteria(
810
+ mockCriteria,
811
+ "0xdeadbeef",
812
+ mockInput,
813
+ );
622
814
  expect(result).toBe(true);
623
815
  });
624
816
 
625
- test('should throw FieldValueNotComparableError for CONTAINS filter type with non-string/bytes field type', () => {
817
+ test("should throw FieldValueNotComparableError for CONTAINS filter type with non-string/bytes field type", () => {
626
818
  // Decoded value: 123
627
- const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.UINT, '0x7b');
628
- expect(() => action.validateFieldAgainstCriteria(mockCriteria, 123n, mockInput)).toThrow(/only .* bytes or string/);
819
+ const mockCriteria = createMockCriteria(
820
+ FilterType.CONTAINS,
821
+ PrimitiveType.UINT,
822
+ "0x7b",
823
+ );
824
+ expect(() =>
825
+ action.validateFieldAgainstCriteria(mockCriteria, 123n, mockInput),
826
+ ).toThrow(/only .* bytes or string/);
629
827
  });
630
828
 
631
- test('should throw UnrecognizedFilterTypeError for unrecognized filter type', () => {
632
- const mockCriteria = createMockCriteria(6 as FilterType, PrimitiveType.STRING, '0x74657374'); // Decoded value: 'test'
633
- expect(() => action.validateFieldAgainstCriteria(mockCriteria, 'test', mockInput)).toThrow('Invalid FilterType');
829
+ test("should throw UnrecognizedFilterTypeError for unrecognized filter type", () => {
830
+ const mockCriteria = createMockCriteria(
831
+ 6 as FilterType,
832
+ PrimitiveType.STRING,
833
+ "0x74657374",
834
+ ); // Decoded value: 'test'
835
+ expect(() =>
836
+ action.validateFieldAgainstCriteria(mockCriteria, "test", mockInput),
837
+ ).toThrow("Invalid FilterType");
634
838
  });
635
839
 
636
- test('should return true for LESS_THAN filter type with UINT field type', () => {
840
+ test("should return true for LESS_THAN filter type with UINT field type", () => {
637
841
  // Decoded value: 200
638
- const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.UINT, '0xc8');
639
- const result = action.validateFieldAgainstCriteria(mockCriteria, 100n, mockInput);
842
+ const mockCriteria = createMockCriteria(
843
+ FilterType.LESS_THAN,
844
+ PrimitiveType.UINT,
845
+ "0xc8",
846
+ );
847
+ const result = action.validateFieldAgainstCriteria(
848
+ mockCriteria,
849
+ 100n,
850
+ mockInput,
851
+ );
640
852
  expect(result).toBe(true);
641
853
  });
642
854
 
643
- test('should return false for LESS_THAN filter type with UINT field type when value is greater', () => {
855
+ test("should return false for LESS_THAN filter type with UINT field type when value is greater", () => {
644
856
  // Decoded value: 100
645
- const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.UINT, '0x64');
646
- const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
857
+ const mockCriteria = createMockCriteria(
858
+ FilterType.LESS_THAN,
859
+ PrimitiveType.UINT,
860
+ "0x64",
861
+ );
862
+ const result = action.validateFieldAgainstCriteria(
863
+ mockCriteria,
864
+ 200n,
865
+ mockInput,
866
+ );
647
867
  expect(result).toBe(false);
648
868
  });
649
869
 
650
- test('should throw InvalidNumericalCriteriaError for LESS_THAN filter type with non-uint field type', () => {
870
+ test("should throw InvalidNumericalCriteriaError for LESS_THAN filter type with non-uint field type", () => {
651
871
  // Decoded value: 100
652
- const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.STRING, '0x64');
653
- expect(() => action.validateFieldAgainstCriteria(mockCriteria, '50', mockInput)).toThrow('non-numerical');
872
+ const mockCriteria = createMockCriteria(
873
+ FilterType.LESS_THAN,
874
+ PrimitiveType.STRING,
875
+ "0x64",
876
+ );
877
+ expect(() =>
878
+ action.validateFieldAgainstCriteria(mockCriteria, "50", mockInput),
879
+ ).toThrow("non-numerical");
654
880
  });
655
881
 
656
- test('should throw InvalidNumericalCriteriaError for LESS_THAN filter type with ADDRESS field type', () => {
657
- const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.ADDRESS, '0x1234567890abcdef1234567890abcdef12345678');
658
- expect(() => action.validateFieldAgainstCriteria(mockCriteria, '0x1234567890abcdef1234567890abcdef12345678', mockInput)).toThrow('non-numerical');
882
+ test("should throw InvalidNumericalCriteriaError for LESS_THAN filter type with ADDRESS field type", () => {
883
+ const mockCriteria = createMockCriteria(
884
+ FilterType.LESS_THAN,
885
+ PrimitiveType.ADDRESS,
886
+ "0x1234567890abcdef1234567890abcdef12345678",
887
+ );
888
+ expect(() =>
889
+ action.validateFieldAgainstCriteria(
890
+ mockCriteria,
891
+ "0x1234567890abcdef1234567890abcdef12345678",
892
+ mockInput,
893
+ ),
894
+ ).toThrow("non-numerical");
659
895
  });
660
896
 
661
- test('should return true for anyActionParameter', async () => {
662
- const mockCriteria = anyActionParameter()
663
- const result = action.validateFieldAgainstCriteria(mockCriteria, zeroHash, mockInput)
664
- expect(result).toBe(true)
665
- })
666
- })
897
+ test("should return true for anyActionParameter", async () => {
898
+ const mockCriteria = anyActionParameter();
899
+ const result = action.validateFieldAgainstCriteria(
900
+ mockCriteria,
901
+ zeroHash,
902
+ mockInput,
903
+ );
904
+ expect(result).toBe(true);
905
+ });
906
+ });
667
907
 
668
908
  describe("EventAction Func Selector", () => {
669
909
  beforeEach(async () => {
@@ -683,21 +923,25 @@ describe("EventAction Func Selector", () => {
683
923
  test("validates function action step with correct hash", async () => {
684
924
  const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
685
925
  const actionSteps = await action.getActionSteps();
686
- const actionStep = actionSteps[0]!
926
+ const actionStep = actionSteps[0]!;
687
927
  const recipient = accounts[1].account;
688
928
  const { hash } = await erc721.mintRaw(recipient, {
689
929
  value: parseEther(".1"),
690
930
  });
691
931
 
692
932
  expect(
693
- await action.isActionStepValid(actionStep, { hash, chainId })
933
+ await action.isActionStepValid(actionStep, {
934
+ hash,
935
+ chainId,
936
+ knownSignatures: allKnownSignatures,
937
+ }),
694
938
  ).toBe(true);
695
939
  });
696
940
 
697
941
  test("validates function step with EQUAL filter", async () => {
698
942
  const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
699
943
  const actionSteps = await action.getActionSteps();
700
- const actionStep = actionSteps[0]!
944
+ const actionStep = actionSteps[0]!;
701
945
  const recipient = accounts[1].account;
702
946
  const { hash } = await erc721.mintRaw(recipient, {
703
947
  value: parseEther(".1"),
@@ -706,6 +950,7 @@ describe("EventAction Func Selector", () => {
706
950
  const criteriaMatch = await action.isActionStepValid(actionStep, {
707
951
  hash,
708
952
  chainId,
953
+ knownSignatures: allKnownSignatures,
709
954
  });
710
955
 
711
956
  expect(criteriaMatch).toBe(true);
@@ -727,7 +972,11 @@ describe("EventAction Func Selector", () => {
727
972
  });
728
973
 
729
974
  try {
730
- await action.isActionStepValid(invalidStep, { hash, chainId });
975
+ await action.isActionStepValid(invalidStep, {
976
+ hash,
977
+ chainId,
978
+ knownSignatures: allKnownSignatures,
979
+ });
731
980
  } catch (e) {
732
981
  expect(e).toBeInstanceOf(Error);
733
982
  expect((e as Error).message).toContain(
@@ -736,15 +985,27 @@ describe("EventAction Func Selector", () => {
736
985
  }
737
986
  });
738
987
 
739
- test('validates empty actionParameter', async () => {
740
- const action = await loadFixture(cloneFunctionAction(fixtures, erc721, basicErc721MintFuncActionWithEmptyActionParameter(erc721)))
988
+ test("validates empty actionParameter", async () => {
989
+ const action = await loadFixture(
990
+ cloneFunctionAction(
991
+ fixtures,
992
+ erc721,
993
+ basicErc721MintFuncActionWithEmptyActionParameter(erc721),
994
+ ),
995
+ );
741
996
  const recipient = accounts[1].account;
742
997
  const { hash } = await erc721.mintRaw(recipient, {
743
998
  value: parseEther(".1"),
744
999
  });
745
1000
 
746
- expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
747
- })
1001
+ expect(
1002
+ await action.validateActionSteps({
1003
+ hash,
1004
+ chainId,
1005
+ knownSignatures: allKnownSignatures,
1006
+ }),
1007
+ ).toBe(true);
1008
+ });
748
1009
 
749
1010
  test("validates against NOT_EQUAL filter criteria", async () => {
750
1011
  const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
@@ -760,6 +1021,7 @@ describe("EventAction Func Selector", () => {
760
1021
  await action.isActionStepValid(actionStep, {
761
1022
  hash,
762
1023
  chainId,
1024
+ knownSignatures: allKnownSignatures,
763
1025
  }),
764
1026
  ).toBe(true);
765
1027
  });
@@ -784,6 +1046,7 @@ describe("EventAction Func Selector", () => {
784
1046
  await action.isActionStepValid(actionStep, {
785
1047
  hash,
786
1048
  chainId,
1049
+ knownSignatures: allKnownSignatures,
787
1050
  }),
788
1051
  ).toBe(true);
789
1052
  });
@@ -807,6 +1070,7 @@ describe("EventAction Func Selector", () => {
807
1070
  await action.isActionStepValid(actionStep, {
808
1071
  hash,
809
1072
  chainId,
1073
+ knownSignatures: allKnownSignatures,
810
1074
  }),
811
1075
  ).toBe(true);
812
1076
  });
@@ -822,6 +1086,7 @@ describe("EventAction Func Selector", () => {
822
1086
  await action.validateActionSteps({
823
1087
  hash,
824
1088
  chainId,
1089
+ knownSignatures: allKnownSignatures,
825
1090
  }),
826
1091
  ).toBe(true);
827
1092
  });