@boostxyz/sdk 1.1.0-alpha.23 → 2.0.0-alpha.25

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 (134) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.js +7 -7
  3. package/dist/Actions/EventAction.cjs +1 -1
  4. package/dist/Actions/EventAction.cjs.map +1 -1
  5. package/dist/Actions/EventAction.d.ts +32 -5
  6. package/dist/Actions/EventAction.d.ts.map +1 -1
  7. package/dist/Actions/EventAction.js +164 -137
  8. package/dist/Actions/EventAction.js.map +1 -1
  9. package/dist/AllowLists/AllowList.cjs +1 -1
  10. package/dist/AllowLists/AllowList.js +10 -10
  11. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  12. package/dist/AllowLists/SimpleAllowList.js +10 -10
  13. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  14. package/dist/AllowLists/SimpleDenyList.js +3 -3
  15. package/dist/Auth/PassthroughAuth.cjs +1 -1
  16. package/dist/Auth/PassthroughAuth.js +1 -1
  17. package/dist/BoostCore.cjs +2 -1
  18. package/dist/BoostCore.cjs.map +1 -1
  19. package/dist/BoostCore.d.ts +564 -1
  20. package/dist/BoostCore.d.ts.map +1 -1
  21. package/dist/BoostCore.js +1322 -29
  22. package/dist/BoostCore.js.map +1 -1
  23. package/dist/BoostRegistry.cjs +1 -1
  24. package/dist/BoostRegistry.js +27 -27
  25. package/dist/Budgets/Budget.cjs +1 -1
  26. package/dist/Budgets/Budget.js +2 -2
  27. package/dist/Budgets/ManagedBudget.cjs +1 -1
  28. package/dist/Budgets/ManagedBudget.js +23 -23
  29. package/dist/Deployable/DeployableTarget.cjs +1 -1
  30. package/dist/Deployable/DeployableTarget.js +1 -1
  31. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  32. package/dist/Deployable/DeployableTargetWithRBAC.js +23 -23
  33. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  34. package/dist/Incentives/AllowListIncentive.js +8 -8
  35. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  36. package/dist/Incentives/CGDAIncentive.js +12 -12
  37. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  38. package/dist/Incentives/ERC20Incentive.js +16 -16
  39. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +2 -0
  40. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs.map +1 -0
  41. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +42 -15
  42. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
  43. package/dist/Incentives/ERC20VariableCriteriaIncentive.js +188 -0
  44. package/dist/Incentives/ERC20VariableCriteriaIncentive.js.map +1 -0
  45. package/dist/Incentives/ERC20VariableIncentive.cjs +2 -0
  46. package/dist/Incentives/ERC20VariableIncentive.cjs.map +1 -0
  47. package/dist/Incentives/ERC20VariableIncentive.d.ts +7 -5
  48. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  49. package/dist/{Incentive-rM5nKznp.js → Incentives/ERC20VariableIncentive.js} +42 -67
  50. package/dist/Incentives/ERC20VariableIncentive.js.map +1 -0
  51. package/dist/Incentives/Incentive.cjs +1 -1
  52. package/dist/Incentives/Incentive.cjs.map +1 -1
  53. package/dist/Incentives/Incentive.d.ts +552 -3
  54. package/dist/Incentives/Incentive.d.ts.map +1 -1
  55. package/dist/Incentives/Incentive.js +40 -16
  56. package/dist/Incentives/Incentive.js.map +1 -1
  57. package/dist/Incentives/PointsIncentive.cjs +1 -1
  58. package/dist/Incentives/PointsIncentive.js +8 -8
  59. package/dist/{SimpleDenyList-DNj5qDWM.cjs → SimpleDenyList-BdlpZdDz.cjs} +2 -2
  60. package/dist/{SimpleDenyList-DNj5qDWM.cjs.map → SimpleDenyList-BdlpZdDz.cjs.map} +1 -1
  61. package/dist/{SimpleDenyList-BDXpY74P.js → SimpleDenyList-D0cyVUVv.js} +16 -16
  62. package/dist/{SimpleDenyList-BDXpY74P.js.map → SimpleDenyList-D0cyVUVv.js.map} +1 -1
  63. package/dist/Validators/LimitedSignerValidator.cjs +2 -0
  64. package/dist/Validators/LimitedSignerValidator.cjs.map +1 -0
  65. package/dist/Validators/LimitedSignerValidator.d.ts +806 -0
  66. package/dist/Validators/LimitedSignerValidator.d.ts.map +1 -0
  67. package/dist/Validators/LimitedSignerValidator.js +299 -0
  68. package/dist/Validators/LimitedSignerValidator.js.map +1 -0
  69. package/dist/Validators/SignerValidator.cjs +1 -1
  70. package/dist/Validators/SignerValidator.cjs.map +1 -1
  71. package/dist/Validators/SignerValidator.d.ts +2 -2
  72. package/dist/Validators/SignerValidator.js +5 -5
  73. package/dist/Validators/SignerValidator.js.map +1 -1
  74. package/dist/Validators/Validator.cjs +1 -1
  75. package/dist/Validators/Validator.cjs.map +1 -1
  76. package/dist/Validators/Validator.d.ts +22 -2
  77. package/dist/Validators/Validator.d.ts.map +1 -1
  78. package/dist/Validators/Validator.js +26 -17
  79. package/dist/Validators/Validator.js.map +1 -1
  80. package/dist/{componentInterfaces-BBCFkrZv.js → componentInterfaces-bIVo8eyA.js} +9 -9
  81. package/dist/componentInterfaces-bIVo8eyA.js.map +1 -0
  82. package/dist/{deployments-fJsWblwS.js → deployments-Ccx1MtoK.js} +5 -5
  83. package/dist/deployments-Ccx1MtoK.js.map +1 -0
  84. package/dist/{generated-CsNyWPKA.js → generated-BAKNSOjJ.js} +661 -381
  85. package/dist/generated-BAKNSOjJ.js.map +1 -0
  86. package/dist/generated-Cqn4wS01.cjs +3 -0
  87. package/dist/generated-Cqn4wS01.cjs.map +1 -0
  88. package/dist/index.cjs +1 -1
  89. package/dist/index.d.ts +1 -0
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +145 -132
  92. package/dist/index.js.map +1 -1
  93. package/dist/utils.cjs +1 -1
  94. package/dist/utils.cjs.map +1 -1
  95. package/dist/utils.d.ts +10 -0
  96. package/dist/utils.d.ts.map +1 -1
  97. package/dist/utils.js +27 -26
  98. package/dist/utils.js.map +1 -1
  99. package/package.json +21 -5
  100. package/src/Actions/EventAction.test.ts +381 -122
  101. package/src/Actions/EventAction.ts +85 -23
  102. package/src/BoostCore.test.ts +3 -3
  103. package/src/BoostCore.ts +51 -5
  104. package/src/Incentives/AllowListIncentive.test.ts +19 -21
  105. package/src/Incentives/CGDAIncentive.test.ts +20 -22
  106. package/src/Incentives/ERC1155Incentive.test.ts +14 -15
  107. package/src/Incentives/ERC20Incentive.test.ts +17 -19
  108. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +62 -10
  109. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +79 -37
  110. package/src/Incentives/ERC20VariableIncentive.test.ts +16 -18
  111. package/src/Incentives/ERC20VariableIncentive.ts +16 -8
  112. package/src/Incentives/Incentive.ts +4 -1
  113. package/src/Incentives/PointsIncentive.test.ts +3 -5
  114. package/src/Validators/LimitedSignerValidator.test.ts +223 -0
  115. package/src/Validators/LimitedSignerValidator.ts +707 -0
  116. package/src/Validators/SignerValidator.test.ts +21 -22
  117. package/src/Validators/SignerValidator.ts +2 -2
  118. package/src/Validators/Validator.test.ts +7 -1
  119. package/src/Validators/Validator.ts +30 -3
  120. package/src/index.test.ts +2 -0
  121. package/src/index.ts +1 -0
  122. package/src/utils.ts +11 -0
  123. package/dist/BoostCore-Btl5BdAs.cjs +0 -3
  124. package/dist/BoostCore-Btl5BdAs.cjs.map +0 -1
  125. package/dist/BoostCore-CD56zbYX.js +0 -2641
  126. package/dist/BoostCore-CD56zbYX.js.map +0 -1
  127. package/dist/Incentive-CcnOIc8L.cjs +0 -2
  128. package/dist/Incentive-CcnOIc8L.cjs.map +0 -1
  129. package/dist/Incentive-rM5nKznp.js.map +0 -1
  130. package/dist/componentInterfaces-BBCFkrZv.js.map +0 -1
  131. package/dist/deployments-fJsWblwS.js.map +0 -1
  132. package/dist/generated-CsNyWPKA.js.map +0 -1
  133. package/dist/generated-DHerxf1y.cjs +0 -3
  134. package/dist/generated-DHerxf1y.cjs.map +0 -1
@@ -7,15 +7,16 @@ import {
7
7
  type Address,
8
8
  type Hex,
9
9
  isAddress,
10
+ isAddressEqual,
10
11
  parseEther,
11
12
  toHex,
12
13
  zeroAddress,
13
14
  zeroHash,
14
- } from 'viem';
15
- import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
16
- import type { MockERC20 } from '@boostxyz/test/MockERC20';
17
- import type { MockERC721 } from '@boostxyz/test/MockERC721';
18
- 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";
19
20
  import {
20
21
  type Fixtures,
21
22
  type StringEmitterFixtures,
@@ -24,7 +25,7 @@ import {
24
25
  fundErc20,
25
26
  deployStringEmitterMock,
26
27
  fundErc721,
27
- } from '@boostxyz/test/helpers';
28
+ } from "@boostxyz/test/helpers";
28
29
  import {
29
30
  EventAction,
30
31
  type EventLogs,
@@ -34,6 +35,7 @@ import {
34
35
  SignatureType,
35
36
  Criteria,
36
37
  anyActionParameter,
38
+ transactionSenderClaimant,
37
39
  } from "./EventAction";
38
40
  import { allKnownSignatures } from "@boostxyz/test/allKnownSignatures";
39
41
 
@@ -82,14 +84,18 @@ function basicErc721TransferAction(
82
84
  }
83
85
 
84
86
  function basicErc721TransferActionWithEmptyActionParameter(erc721: MockERC721) {
85
- const eventActionPayload = basicErc721TransferAction(erc721)
87
+ const eventActionPayload = basicErc721TransferAction(erc721);
86
88
  if (eventActionPayload.actionSteps[0]?.actionParameter) {
87
- eventActionPayload.actionSteps[0].actionParameter = anyActionParameter()
89
+ eventActionPayload.actionSteps[0].actionParameter = anyActionParameter();
88
90
  }
89
- return eventActionPayload
91
+ return eventActionPayload;
90
92
  }
91
93
 
92
- function cloneEventAction(fixtures: Fixtures, erc721: MockERC721, eventActionPayload = basicErc721TransferAction(erc721)) {
94
+ function cloneEventAction(
95
+ fixtures: Fixtures,
96
+ erc721: MockERC721,
97
+ eventActionPayload = basicErc721TransferAction(erc721),
98
+ ) {
93
99
  return function cloneEventAction() {
94
100
  return fixtures.registry.initialize(
95
101
  crypto.randomUUID(),
@@ -128,11 +134,11 @@ function basicErc721MintFuncAction(
128
134
  }
129
135
 
130
136
  function basicErc721MintFuncActionWithEmptyActionParameter(erc721: MockERC721) {
131
- const eventActionPayload = basicErc721MintFuncAction(erc721)
137
+ const eventActionPayload = basicErc721MintFuncAction(erc721);
132
138
  if (eventActionPayload.actionSteps[0]?.actionParameter) {
133
- eventActionPayload.actionSteps[0].actionParameter = anyActionParameter()
139
+ eventActionPayload.actionSteps[0].actionParameter = anyActionParameter();
134
140
  }
135
- return eventActionPayload
141
+ return eventActionPayload;
136
142
  }
137
143
 
138
144
  function basicErc20MintFuncAction(erc20: MockERC20): EventActionPayloadSimple {
@@ -244,14 +250,15 @@ function cloneFunctionAction20(fixtures: Fixtures, erc20: MockERC20) {
244
250
  };
245
251
  }
246
252
 
247
- function cloneFunctionAction(fixtures: Fixtures, erc721: MockERC721, eventActionPayload = basicErc721MintFuncAction(erc721)) {
253
+ function cloneFunctionAction(
254
+ fixtures: Fixtures,
255
+ erc721: MockERC721,
256
+ eventActionPayload = basicErc721MintFuncAction(erc721),
257
+ ) {
248
258
  return function cloneFunctionAction() {
249
259
  return fixtures.registry.clone(
250
260
  crypto.randomUUID(),
251
- new fixtures.bases.EventAction(
252
- defaultOptions,
253
- eventActionPayload
254
- ),
261
+ new fixtures.bases.EventAction(defaultOptions, eventActionPayload),
255
262
  );
256
263
  };
257
264
  }
@@ -272,7 +279,7 @@ function createMockCriteria(
272
279
  filterType: FilterType,
273
280
  fieldType: PrimitiveType,
274
281
  filterData: Hex,
275
- fieldIndex: number = 0
282
+ fieldIndex: number = 0,
276
283
  ): Criteria {
277
284
  return {
278
285
  filterType,
@@ -412,12 +419,23 @@ describe("EventAction Event Selector", () => {
412
419
  const action = await loadFixture(cloneEventAction(fixtures, erc721));
413
420
  const recipient = accounts[1].account;
414
421
  await erc721.approve(recipient, 1n);
415
- const { hash } = await erc721.transferFromRaw(defaultOptions.account.address, recipient, 1n);
416
- expect(await action.validateActionSteps({ hash, chainId, knownSignatures: allKnownSignatures })).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);
417
434
  });
418
435
 
419
436
  test("can supply your own logs to validate against", async () => {
420
- const hash = "0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5"
437
+ const hash =
438
+ "0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5";
421
439
  const logs: EventLogs = [
422
440
  {
423
441
  eventName: "Transfer",
@@ -445,7 +463,14 @@ describe("EventAction Event Selector", () => {
445
463
  },
446
464
  ];
447
465
  const action = await loadFixture(cloneEventAction(fixtures, erc721));
448
- expect(await action.validateActionSteps({ hash, chainId, logs, knownSignatures: allKnownSignatures })).toBe(true);
466
+ expect(
467
+ await action.validateActionSteps({
468
+ hash,
469
+ chainId,
470
+ logs,
471
+ knownSignatures: allKnownSignatures,
472
+ }),
473
+ ).toBe(true);
449
474
  });
450
475
 
451
476
  describe("string event actions", () => {
@@ -462,10 +487,15 @@ describe("EventAction Event Selector", () => {
462
487
  ),
463
488
  );
464
489
 
465
- const hash = await stringEmitterFixtures.emitIndexedString("Hello world");
466
- await expect(() => action.validateActionSteps({ hash, chainId, knownSignatures: allKnownSignatures })).rejects.toThrowError(
467
- /Parameter is not transparently stored onchain/,
468
- );
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/);
469
499
  });
470
500
  test("can parse and validate contains for an emitted string event", async () => {
471
501
  const action = await loadFixture(
@@ -480,7 +510,13 @@ describe("EventAction Event Selector", () => {
480
510
  ),
481
511
  );
482
512
  const hash = await stringEmitterFixtures.emitString("Hello world");
483
- expect(await action.validateActionSteps({ hash, chainId, knownSignatures: allKnownSignatures })).toBe(true);
513
+ expect(
514
+ await action.validateActionSteps({
515
+ hash,
516
+ chainId,
517
+ knownSignatures: allKnownSignatures,
518
+ }),
519
+ ).toBe(true);
484
520
  });
485
521
  test("can parse and validate regex for an emitted string event", async () => {
486
522
  const action = await loadFixture(
@@ -496,21 +532,63 @@ describe("EventAction Event Selector", () => {
496
532
  );
497
533
 
498
534
  const hash = await stringEmitterFixtures.emitString("Hello world");
499
- expect(await action.validateActionSteps({ hash, chainId, knownSignatures: allKnownSignatures })).toBe(true);
535
+ expect(
536
+ await action.validateActionSteps({
537
+ hash,
538
+ chainId,
539
+ knownSignatures: allKnownSignatures,
540
+ }),
541
+ ).toBe(true);
500
542
  });
501
543
  });
502
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
+
503
574
  test("can derive the claimant from an event action", async () => {
504
575
  const action = await loadFixture(cloneEventAction(fixtures, erc721));
505
576
  const recipient = accounts[1].account;
506
577
  await erc721.approve(recipient, 1n);
507
- 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
+ );
508
583
  expect(
509
- await action.deriveActionClaimantFromTransaction(await action.getActionClaimant(), {
510
- hash,
511
- chainId,
512
- knownSignatures: allKnownSignatures
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,149 +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
- knownSignatures: allKnownSignatures
529
- }),
603
+ await action.deriveActionClaimantFromTransaction(
604
+ await action.getActionClaimant(),
605
+ {
606
+ hash,
607
+ chainId,
608
+ knownSignatures: allKnownSignatures,
609
+ },
610
+ ),
530
611
  ).toBe(recipient);
531
612
  });
532
613
 
533
- test('validates empty actionParameter', async () => {
534
- 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
+ );
535
622
  const recipient = accounts[1].account;
536
623
  await erc721.approve(recipient, 1n);
537
- const { hash } = await erc721.transferFromRaw(defaultOptions.account.address, recipient, 1n);
538
- expect(await action.validateActionSteps({ hash, chainId, knownSignatures: allKnownSignatures })).toBe(true);
539
- })
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
+ });
540
637
  });
541
638
  });
542
639
 
543
640
  describe("validateFieldAgainstCriteria unit tests", () => {
544
- let action: EventAction
641
+ let action: EventAction;
545
642
  beforeAll(async () => {
546
643
  action = await loadFixture(cloneEventAction(fixtures, erc721));
547
644
  });
548
- const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
549
- const mockInput = { decodedArgs: ['not used'] };
550
-
551
- test('should return true for EQUAL filter type with ADDRESS field type', () => {
552
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.ADDRESS, mockAddress);
553
- 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
+ );
554
659
  expect(result).toBe(true);
555
660
  });
556
661
 
557
- test('should return true for EQUAL filter type with UINT field type', () => {
558
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.UINT, '0xc8');
559
- 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
+ );
560
673
  expect(result).toBe(true);
561
674
  });
562
- 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", () => {
563
676
  // Decoded value: 'hello'
564
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.STRING, '0x68656c6c6f');
565
- 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
+ );
566
687
  expect(result).toBe(true);
567
688
  });
568
689
 
569
- 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", () => {
570
691
  // Decoded value: 'hello'
571
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.STRING, '0x68656c6c6f');
572
- 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
+ );
573
702
  expect(result).toBe(false);
574
703
  });
575
704
 
576
- 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", () => {
577
706
  // Decoded value: '0x68656c6c6f' (hex for 'hello')
578
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.BYTES, '0x68656c6c6f');
579
- 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
+ );
580
717
  expect(result).toBe(true);
581
718
  });
582
719
 
583
- 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", () => {
584
721
  // Decoded value: '0x68656c6c6f' (hex for 'hello')
585
- const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.BYTES, '0x68656c6c6f');
586
- 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'
587
732
  expect(result).toBe(false);
588
733
  });
589
734
 
590
- test('should return false for NOT_EQUAL filter type with ADDRESS field type', () => {
591
- const mockCriteria = createMockCriteria(FilterType.NOT_EQUAL, PrimitiveType.ADDRESS, mockAddress);
592
- 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
+ );
593
746
  expect(result).toBe(true);
594
747
  });
595
748
 
596
- test('should return true for NOT_EQUAL filter type with UINT field type', () => {
597
- const mockCriteria = createMockCriteria(FilterType.NOT_EQUAL, PrimitiveType.UINT, '0xc9');
598
- 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
+ );
599
760
  expect(result).toBe(true);
600
761
  });
601
762
 
602
- test('should throw InvalidNumericalCriteriaError for GREATER_THAN filter type with non-uint field type', () => {
603
- const mockCriteria = createMockCriteria(FilterType.GREATER_THAN, PrimitiveType.STRING, '0x100');
604
- 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");
605
772
  });
606
773
 
607
- test('should return true for GREATER_THAN filter type with UINT field type', () => {
608
- const mockCriteria = createMockCriteria(FilterType.GREATER_THAN, PrimitiveType.UINT, '0x64');
609
- 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
+ );
610
785
  expect(result).toBe(true);
611
786
  });
612
787
 
613
- 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", () => {
614
789
  // Decoded value: 'hello'
615
- const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.STRING, '0x68656c6c6f');
616
- 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
+ );
617
800
  expect(result).toBe(true);
618
801
  });
619
802
 
620
- test('should return true for CONTAINS filter type with BYTES field type', () => {
621
- const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.BYTES, '0xbeef');
622
- 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
+ );
623
814
  expect(result).toBe(true);
624
815
  });
625
816
 
626
- 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", () => {
627
818
  // Decoded value: 123
628
- const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.UINT, '0x7b');
629
- 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/);
630
827
  });
631
828
 
632
- test('should throw UnrecognizedFilterTypeError for unrecognized filter type', () => {
633
- const mockCriteria = createMockCriteria(6 as FilterType, PrimitiveType.STRING, '0x74657374'); // Decoded value: 'test'
634
- 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");
635
838
  });
636
839
 
637
- 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", () => {
638
841
  // Decoded value: 200
639
- const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.UINT, '0xc8');
640
- 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
+ );
641
852
  expect(result).toBe(true);
642
853
  });
643
854
 
644
- 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", () => {
645
856
  // Decoded value: 100
646
- const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.UINT, '0x64');
647
- 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
+ );
648
867
  expect(result).toBe(false);
649
868
  });
650
869
 
651
- 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", () => {
652
871
  // Decoded value: 100
653
- const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.STRING, '0x64');
654
- 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");
655
880
  });
656
881
 
657
- test('should throw InvalidNumericalCriteriaError for LESS_THAN filter type with ADDRESS field type', () => {
658
- const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.ADDRESS, '0x1234567890abcdef1234567890abcdef12345678');
659
- 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");
660
895
  });
661
896
 
662
- test('should return true for anyActionParameter', async () => {
663
- const mockCriteria = anyActionParameter()
664
- const result = action.validateFieldAgainstCriteria(mockCriteria, zeroHash, mockInput)
665
- expect(result).toBe(true)
666
- })
667
- })
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
+ });
668
907
 
669
908
  describe("EventAction Func Selector", () => {
670
909
  beforeEach(async () => {
@@ -684,21 +923,25 @@ describe("EventAction Func Selector", () => {
684
923
  test("validates function action step with correct hash", async () => {
685
924
  const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
686
925
  const actionSteps = await action.getActionSteps();
687
- const actionStep = actionSteps[0]!
926
+ const actionStep = actionSteps[0]!;
688
927
  const recipient = accounts[1].account;
689
928
  const { hash } = await erc721.mintRaw(recipient, {
690
929
  value: parseEther(".1"),
691
930
  });
692
931
 
693
932
  expect(
694
- await action.isActionStepValid(actionStep, { hash, chainId, knownSignatures: allKnownSignatures })
933
+ await action.isActionStepValid(actionStep, {
934
+ hash,
935
+ chainId,
936
+ knownSignatures: allKnownSignatures,
937
+ }),
695
938
  ).toBe(true);
696
939
  });
697
940
 
698
941
  test("validates function step with EQUAL filter", async () => {
699
942
  const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
700
943
  const actionSteps = await action.getActionSteps();
701
- const actionStep = actionSteps[0]!
944
+ const actionStep = actionSteps[0]!;
702
945
  const recipient = accounts[1].account;
703
946
  const { hash } = await erc721.mintRaw(recipient, {
704
947
  value: parseEther(".1"),
@@ -707,7 +950,7 @@ describe("EventAction Func Selector", () => {
707
950
  const criteriaMatch = await action.isActionStepValid(actionStep, {
708
951
  hash,
709
952
  chainId,
710
- knownSignatures: allKnownSignatures
953
+ knownSignatures: allKnownSignatures,
711
954
  });
712
955
 
713
956
  expect(criteriaMatch).toBe(true);
@@ -729,7 +972,11 @@ describe("EventAction Func Selector", () => {
729
972
  });
730
973
 
731
974
  try {
732
- await action.isActionStepValid(invalidStep, { hash, chainId, knownSignatures: allKnownSignatures });
975
+ await action.isActionStepValid(invalidStep, {
976
+ hash,
977
+ chainId,
978
+ knownSignatures: allKnownSignatures,
979
+ });
733
980
  } catch (e) {
734
981
  expect(e).toBeInstanceOf(Error);
735
982
  expect((e as Error).message).toContain(
@@ -738,15 +985,27 @@ describe("EventAction Func Selector", () => {
738
985
  }
739
986
  });
740
987
 
741
- test('validates empty actionParameter', async () => {
742
- 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
+ );
743
996
  const recipient = accounts[1].account;
744
997
  const { hash } = await erc721.mintRaw(recipient, {
745
998
  value: parseEther(".1"),
746
999
  });
747
1000
 
748
- expect(await action.validateActionSteps({ hash, chainId, knownSignatures: allKnownSignatures })).toBe(true);
749
- })
1001
+ expect(
1002
+ await action.validateActionSteps({
1003
+ hash,
1004
+ chainId,
1005
+ knownSignatures: allKnownSignatures,
1006
+ }),
1007
+ ).toBe(true);
1008
+ });
750
1009
 
751
1010
  test("validates against NOT_EQUAL filter criteria", async () => {
752
1011
  const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
@@ -762,7 +1021,7 @@ describe("EventAction Func Selector", () => {
762
1021
  await action.isActionStepValid(actionStep, {
763
1022
  hash,
764
1023
  chainId,
765
- knownSignatures: allKnownSignatures
1024
+ knownSignatures: allKnownSignatures,
766
1025
  }),
767
1026
  ).toBe(true);
768
1027
  });
@@ -787,7 +1046,7 @@ describe("EventAction Func Selector", () => {
787
1046
  await action.isActionStepValid(actionStep, {
788
1047
  hash,
789
1048
  chainId,
790
- knownSignatures: allKnownSignatures
1049
+ knownSignatures: allKnownSignatures,
791
1050
  }),
792
1051
  ).toBe(true);
793
1052
  });
@@ -811,7 +1070,7 @@ describe("EventAction Func Selector", () => {
811
1070
  await action.isActionStepValid(actionStep, {
812
1071
  hash,
813
1072
  chainId,
814
- knownSignatures: allKnownSignatures
1073
+ knownSignatures: allKnownSignatures,
815
1074
  }),
816
1075
  ).toBe(true);
817
1076
  });
@@ -827,7 +1086,7 @@ describe("EventAction Func Selector", () => {
827
1086
  await action.validateActionSteps({
828
1087
  hash,
829
1088
  chainId,
830
- knownSignatures: allKnownSignatures
1089
+ knownSignatures: allKnownSignatures,
831
1090
  }),
832
1091
  ).toBe(true);
833
1092
  });