@boostxyz/sdk 0.0.0-alpha.2 → 0.0.0-alpha.21

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 (271) hide show
  1. package/dist/Actions/Action.cjs +2 -1
  2. package/dist/Actions/Action.cjs.map +1 -0
  3. package/dist/Actions/Action.d.ts +1 -1
  4. package/dist/Actions/Action.d.ts.map +1 -1
  5. package/dist/Actions/Action.js +14 -12
  6. package/dist/Actions/Action.js.map +1 -0
  7. package/dist/Actions/ContractAction.d.ts +57 -14
  8. package/dist/Actions/ContractAction.d.ts.map +1 -1
  9. package/dist/Actions/ERC721MintAction.d.ts +50 -23
  10. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  11. package/dist/Actions/EventAction.cjs +2 -1
  12. package/dist/Actions/EventAction.cjs.map +1 -0
  13. package/dist/Actions/EventAction.d.ts +405 -36
  14. package/dist/Actions/EventAction.d.ts.map +1 -1
  15. package/dist/Actions/EventAction.js +15 -209
  16. package/dist/Actions/EventAction.js.map +1 -0
  17. package/dist/AllowLists/AllowList.cjs +2 -1
  18. package/dist/AllowLists/AllowList.cjs.map +1 -0
  19. package/dist/AllowLists/AllowList.d.ts +6 -5
  20. package/dist/AllowLists/AllowList.d.ts.map +1 -1
  21. package/dist/AllowLists/AllowList.js +46 -22
  22. package/dist/AllowLists/AllowList.js.map +1 -0
  23. package/dist/AllowLists/OpenAllowList.d.ts +423 -0
  24. package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
  25. package/dist/AllowLists/SimpleAllowList.cjs +2 -1
  26. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  27. package/dist/AllowLists/SimpleAllowList.d.ts +124 -40
  28. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  29. package/dist/AllowLists/SimpleAllowList.js +76 -76
  30. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  31. package/dist/AllowLists/SimpleDenyList.cjs +2 -1
  32. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  33. package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
  34. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  35. package/dist/AllowLists/SimpleDenyList.js +12 -200
  36. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  37. package/dist/Auth/Auth.cjs +1 -0
  38. package/dist/Auth/Auth.cjs.map +1 -0
  39. package/dist/Auth/Auth.js +1 -0
  40. package/dist/Auth/Auth.js.map +1 -0
  41. package/dist/Auth/PassthroughAuth.cjs +2 -1
  42. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  43. package/dist/Auth/PassthroughAuth.js +5 -4
  44. package/dist/Auth/PassthroughAuth.js.map +1 -0
  45. package/dist/Boost.cjs +2 -1
  46. package/dist/Boost.cjs.map +1 -0
  47. package/dist/Boost.d.ts +105 -14
  48. package/dist/Boost.d.ts.map +1 -1
  49. package/dist/Boost.js +138 -5
  50. package/dist/Boost.js.map +1 -0
  51. package/dist/BoostCore-DolmDuXW.cjs +3 -0
  52. package/dist/BoostCore-DolmDuXW.cjs.map +1 -0
  53. package/dist/BoostCore-Z97KVu4V.js +1448 -0
  54. package/dist/BoostCore-Z97KVu4V.js.map +1 -0
  55. package/dist/BoostCore.cjs +2 -2
  56. package/dist/BoostCore.cjs.map +1 -0
  57. package/dist/BoostCore.d.ts +788 -79
  58. package/dist/BoostCore.d.ts.map +1 -1
  59. package/dist/BoostCore.js +30 -1103
  60. package/dist/BoostCore.js.map +1 -0
  61. package/dist/BoostRegistry.cjs +2 -1
  62. package/dist/BoostRegistry.cjs.map +1 -0
  63. package/dist/BoostRegistry.d.ts +95 -26
  64. package/dist/BoostRegistry.d.ts.map +1 -1
  65. package/dist/BoostRegistry.js +183 -89
  66. package/dist/BoostRegistry.js.map +1 -0
  67. package/dist/Budgets/Budget.cjs +2 -1
  68. package/dist/Budgets/Budget.cjs.map +1 -0
  69. package/dist/Budgets/Budget.d.ts +1 -1
  70. package/dist/Budgets/Budget.d.ts.map +1 -1
  71. package/dist/Budgets/Budget.js +15 -13
  72. package/dist/Budgets/Budget.js.map +1 -0
  73. package/dist/Budgets/ManagedBudget.cjs +2 -1
  74. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  75. package/dist/Budgets/ManagedBudget.d.ts +112 -192
  76. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  77. package/dist/Budgets/ManagedBudget.js +91 -291
  78. package/dist/Budgets/ManagedBudget.js.map +1 -0
  79. package/dist/Budgets/VestingBudget.d.ts +277 -91
  80. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  81. package/dist/Deployable/Contract.cjs +2 -1
  82. package/dist/Deployable/Contract.cjs.map +1 -0
  83. package/dist/Deployable/Contract.d.ts +4 -5
  84. package/dist/Deployable/Contract.d.ts.map +1 -1
  85. package/dist/Deployable/Contract.js +7 -8
  86. package/dist/Deployable/Contract.js.map +1 -0
  87. package/dist/Deployable/Deployable.cjs +1 -0
  88. package/dist/Deployable/Deployable.cjs.map +1 -0
  89. package/dist/Deployable/Deployable.d.ts +9 -3
  90. package/dist/Deployable/Deployable.d.ts.map +1 -1
  91. package/dist/Deployable/Deployable.js +10 -5
  92. package/dist/Deployable/Deployable.js.map +1 -0
  93. package/dist/Deployable/DeployableTarget.cjs +2 -1
  94. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  95. package/dist/Deployable/DeployableTarget.d.ts +16 -15
  96. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  97. package/dist/Deployable/DeployableTarget.js +49 -42
  98. package/dist/Deployable/DeployableTarget.js.map +1 -0
  99. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  100. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  101. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
  102. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  103. package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
  104. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  105. package/dist/EventAction-CBKzuNoN.cjs +2 -0
  106. package/dist/EventAction-CBKzuNoN.cjs.map +1 -0
  107. package/dist/EventAction-DWuuc_Qy.js +1528 -0
  108. package/dist/EventAction-DWuuc_Qy.js.map +1 -0
  109. package/dist/Incentive-BxzEtN26.js +298 -0
  110. package/dist/Incentive-BxzEtN26.js.map +1 -0
  111. package/dist/Incentive-CrF3-ayL.cjs +2 -0
  112. package/dist/Incentive-CrF3-ayL.cjs.map +1 -0
  113. package/dist/Incentives/AllowListIncentive.cjs +2 -1
  114. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  115. package/dist/Incentives/AllowListIncentive.d.ts +65 -21
  116. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  117. package/dist/Incentives/AllowListIncentive.js +52 -36
  118. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  119. package/dist/Incentives/CGDAIncentive.cjs +2 -1
  120. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  121. package/dist/Incentives/CGDAIncentive.d.ts +315 -26
  122. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  123. package/dist/Incentives/CGDAIncentive.js +64 -39
  124. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  125. package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
  126. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  127. package/dist/Incentives/ERC20Incentive.cjs +2 -1
  128. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  129. package/dist/Incentives/ERC20Incentive.d.ts +270 -33
  130. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  131. package/dist/Incentives/ERC20Incentive.js +69 -46
  132. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  133. package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +338 -421
  134. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  135. package/dist/Incentives/ERC20VariableIncentive.d.ts +262 -32
  136. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  137. package/dist/Incentives/Incentive.cjs +2 -1
  138. package/dist/Incentives/Incentive.cjs.map +1 -0
  139. package/dist/Incentives/Incentive.d.ts +5 -8
  140. package/dist/Incentives/Incentive.d.ts.map +1 -1
  141. package/dist/Incentives/Incentive.js +17 -278
  142. package/dist/Incentives/Incentive.js.map +1 -0
  143. package/dist/Incentives/PointsIncentive.cjs +2 -1
  144. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  145. package/dist/Incentives/PointsIncentive.d.ts +81 -23
  146. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  147. package/dist/Incentives/PointsIncentive.js +57 -36
  148. package/dist/Incentives/PointsIncentive.js.map +1 -0
  149. package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
  150. package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
  151. package/dist/SimpleDenyList-CGaWjuld.js +132 -0
  152. package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
  153. package/dist/Validators/SignerValidator.cjs +2 -1
  154. package/dist/Validators/SignerValidator.cjs.map +1 -0
  155. package/dist/Validators/SignerValidator.d.ts +310 -17
  156. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  157. package/dist/Validators/SignerValidator.js +165 -36
  158. package/dist/Validators/SignerValidator.js.map +1 -0
  159. package/dist/Validators/Validator.cjs +2 -1
  160. package/dist/Validators/Validator.cjs.map +1 -0
  161. package/dist/Validators/Validator.d.ts +2 -2
  162. package/dist/Validators/Validator.d.ts.map +1 -1
  163. package/dist/Validators/Validator.js +10 -8
  164. package/dist/Validators/Validator.js.map +1 -0
  165. package/dist/claiming.cjs +2 -0
  166. package/dist/claiming.cjs.map +1 -0
  167. package/dist/claiming.d.ts +43 -0
  168. package/dist/claiming.d.ts.map +1 -0
  169. package/dist/claiming.js +17 -0
  170. package/dist/claiming.js.map +1 -0
  171. package/dist/componentInterfaces-BBCFkrZv.js +14 -0
  172. package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
  173. package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
  174. package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
  175. package/dist/deployments-DVXioW2i.cjs +2 -0
  176. package/dist/deployments-DVXioW2i.cjs.map +1 -0
  177. package/dist/deployments-oykLv3_Z.js +43 -0
  178. package/dist/deployments-oykLv3_Z.js.map +1 -0
  179. package/dist/deployments.json +44 -0
  180. package/dist/errors.cjs +2 -1
  181. package/dist/errors.cjs.map +1 -0
  182. package/dist/errors.d.ts +421 -1
  183. package/dist/errors.d.ts.map +1 -1
  184. package/dist/errors.js +297 -39
  185. package/dist/errors.js.map +1 -0
  186. package/dist/{generated-x_abr3Yv.js → generated-CKt2yCQd.js} +3143 -3002
  187. package/dist/generated-CKt2yCQd.js.map +1 -0
  188. package/dist/generated-CyTNlOwM.cjs +3 -0
  189. package/dist/generated-CyTNlOwM.cjs.map +1 -0
  190. package/dist/index.cjs +2 -1
  191. package/dist/index.cjs.map +1 -0
  192. package/dist/index.d.ts +10 -9
  193. package/dist/index.d.ts.map +1 -1
  194. package/dist/index.js +144 -1353
  195. package/dist/index.js.map +1 -0
  196. package/dist/transfers.cjs +2 -0
  197. package/dist/transfers.cjs.map +1 -0
  198. package/dist/transfers.d.ts +198 -0
  199. package/dist/transfers.d.ts.map +1 -0
  200. package/dist/transfers.js +84 -0
  201. package/dist/transfers.js.map +1 -0
  202. package/dist/utils.cjs +2 -1
  203. package/dist/utils.cjs.map +1 -0
  204. package/dist/utils.d.ts +26 -1350
  205. package/dist/utils.d.ts.map +1 -1
  206. package/dist/utils.js +38 -636
  207. package/dist/utils.js.map +1 -0
  208. package/package.json +37 -11
  209. package/src/Actions/Action.test.ts +79 -0
  210. package/src/Actions/Action.ts +61 -0
  211. package/src/Actions/ContractAction.test.ts +197 -0
  212. package/src/Actions/ContractAction.ts +300 -0
  213. package/src/Actions/ERC721MintAction.test.ts +112 -0
  214. package/src/Actions/ERC721MintAction.ts +291 -0
  215. package/src/Actions/EventAction.test.ts +787 -0
  216. package/src/Actions/EventAction.ts +1218 -0
  217. package/src/AllowLists/AllowList.test.ts +64 -0
  218. package/src/AllowLists/AllowList.ts +62 -0
  219. package/src/AllowLists/OpenAllowList.test.ts +40 -0
  220. package/src/AllowLists/OpenAllowList.ts +45 -0
  221. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  222. package/src/AllowLists/SimpleAllowList.ts +262 -0
  223. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  224. package/src/AllowLists/SimpleDenyList.ts +250 -0
  225. package/src/Auth/Auth.ts +11 -0
  226. package/src/Auth/PassthroughAuth.test.ts +12 -0
  227. package/src/Auth/PassthroughAuth.ts +80 -0
  228. package/src/Boost.ts +287 -0
  229. package/src/BoostCore.test.ts +894 -0
  230. package/src/BoostCore.ts +1438 -0
  231. package/src/BoostRegistry.test.ts +53 -0
  232. package/src/BoostRegistry.ts +588 -0
  233. package/src/Budgets/Budget.test.ts +27 -0
  234. package/src/Budgets/Budget.ts +60 -0
  235. package/src/Budgets/ManagedBudget.test.ts +217 -0
  236. package/src/Budgets/ManagedBudget.ts +534 -0
  237. package/src/Budgets/VestingBudget.test.ts +123 -0
  238. package/src/Budgets/VestingBudget.ts +530 -0
  239. package/src/Deployable/Contract.ts +228 -0
  240. package/src/Deployable/Deployable.ts +250 -0
  241. package/src/Deployable/DeployableTarget.ts +234 -0
  242. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  243. package/src/Incentives/AllowListIncentive.test.ts +143 -0
  244. package/src/Incentives/AllowListIncentive.ts +336 -0
  245. package/src/Incentives/CGDAIncentive.test.ts +135 -0
  246. package/src/Incentives/CGDAIncentive.ts +476 -0
  247. package/src/Incentives/ERC1155Incentive.test.ts +87 -0
  248. package/src/Incentives/ERC1155Incentive.ts +465 -0
  249. package/src/Incentives/ERC20Incentive.test.ts +133 -0
  250. package/src/Incentives/ERC20Incentive.ts +490 -0
  251. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  252. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
  253. package/src/Incentives/ERC20VariableIncentive.test.ts +139 -0
  254. package/src/Incentives/ERC20VariableIncentive.ts +428 -0
  255. package/src/Incentives/Incentive.test.ts +95 -0
  256. package/src/Incentives/Incentive.ts +86 -0
  257. package/src/Incentives/PointsIncentive.test.ts +138 -0
  258. package/src/Incentives/PointsIncentive.ts +367 -0
  259. package/src/Validators/SignerValidator.test.ts +159 -0
  260. package/src/Validators/SignerValidator.ts +683 -0
  261. package/src/Validators/Validator.test.ts +21 -0
  262. package/src/Validators/Validator.ts +55 -0
  263. package/src/claiming.ts +56 -0
  264. package/src/errors.ts +866 -0
  265. package/src/index.test.ts +122 -0
  266. package/src/index.ts +58 -0
  267. package/src/transfers.ts +284 -0
  268. package/src/utils.test.ts +44 -0
  269. package/src/utils.ts +247 -0
  270. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  271. package/dist/generated-BaaleHW-.cjs +0 -2
@@ -0,0 +1,787 @@
1
+ import { selectors as eventSelectors } from "@boostxyz/signatures/events";
2
+ import { selectors as funcSelectors } from "@boostxyz/signatures/functions";
3
+ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
4
+ import {
5
+ type AbiEvent,
6
+ type Address,
7
+ type GetLogsReturnType,
8
+ type Hex,
9
+ type Log,
10
+ isAddress,
11
+ pad,
12
+ parseEther,
13
+ toHex,
14
+ zeroAddress,
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';
20
+ import {
21
+ type Fixtures,
22
+ type StringEmitterFixtures,
23
+ defaultOptions,
24
+ deployFixtures,
25
+ fundErc20,
26
+ deployStringEmitterMock,
27
+ fundErc721,
28
+ } from '@boostxyz/test/helpers';
29
+ import {
30
+ EventAction,
31
+ type EventLogs,
32
+ type EventActionPayloadSimple,
33
+ FilterType,
34
+ PrimitiveType,
35
+ SignatureType,
36
+ Criteria,
37
+ } from "./EventAction";
38
+
39
+ let fixtures: Fixtures,
40
+ erc721: MockERC721,
41
+ erc20: MockERC20,
42
+ stringEmitterFixtures: StringEmitterFixtures;
43
+ let chainId: number;
44
+
45
+ beforeAll(async () => {
46
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
47
+ stringEmitterFixtures = await loadFixture(deployStringEmitterMock);
48
+ chainId = defaultOptions.config.chains[0].id;
49
+ });
50
+
51
+ function basicErc721TransferAction(
52
+ erc721: MockERC721,
53
+ ): EventActionPayloadSimple {
54
+ return {
55
+ actionClaimant: {
56
+ signatureType: SignatureType.EVENT,
57
+ signature: eventSelectors[
58
+ "Transfer(address indexed,address indexed,uint256 indexed)"
59
+ ] as Hex,
60
+ fieldIndex: 1,
61
+ targetContract: erc721.assertValidAddress(),
62
+ chainid: chainId,
63
+ },
64
+ actionSteps: [
65
+ {
66
+ signature: eventSelectors[
67
+ "Transfer(address indexed,address indexed,uint256 indexed)"
68
+ ] as Hex,
69
+ signatureType: SignatureType.EVENT,
70
+ targetContract: erc721.assertValidAddress(),
71
+ chainid: chainId,
72
+ actionParameter: {
73
+ filterType: FilterType.EQUAL,
74
+ fieldType: PrimitiveType.ADDRESS,
75
+ fieldIndex: 1,
76
+ filterData: accounts[1].account,
77
+ },
78
+ },
79
+ ],
80
+ };
81
+ }
82
+
83
+ function cloneEventAction(fixtures: Fixtures, erc721: MockERC721) {
84
+ return function cloneEventAction() {
85
+ return fixtures.registry.initialize(
86
+ crypto.randomUUID(),
87
+ fixtures.core.EventAction(basicErc721TransferAction(erc721)),
88
+ );
89
+ };
90
+ }
91
+
92
+ function basicErc721MintFuncAction(
93
+ erc721: MockERC721,
94
+ ): EventActionPayloadSimple {
95
+ return {
96
+ actionClaimant: {
97
+ signatureType: SignatureType.FUNC,
98
+ signature: funcSelectors["mint(address)"] as Hex,
99
+ fieldIndex: 0,
100
+ targetContract: erc721.assertValidAddress(),
101
+ chainid: chainId,
102
+ },
103
+ actionSteps: [
104
+ {
105
+ signature: funcSelectors["mint(address)"] as Hex,
106
+ signatureType: SignatureType.FUNC,
107
+ actionType: 0,
108
+ targetContract: erc721.assertValidAddress(),
109
+ chainid: chainId,
110
+ actionParameter: {
111
+ filterType: FilterType.EQUAL,
112
+ fieldType: PrimitiveType.ADDRESS,
113
+ fieldIndex: 0,
114
+ filterData: accounts[1].account,
115
+ },
116
+ },
117
+ ],
118
+ };
119
+ }
120
+
121
+ function basicErc20MintFuncAction(erc20: MockERC20): EventActionPayloadSimple {
122
+ return {
123
+ actionClaimant: {
124
+ signatureType: SignatureType.FUNC,
125
+ signature: funcSelectors["mint(address to, uint256 amount)"] as Hex,
126
+ fieldIndex: 0,
127
+ targetContract: erc20.assertValidAddress(),
128
+ chainid: chainId,
129
+ },
130
+ actionSteps: [
131
+ {
132
+ signature: funcSelectors["mint(address to, uint256 amount)"] as Hex,
133
+ signatureType: SignatureType.FUNC,
134
+ actionType: 0,
135
+ targetContract: erc20.assertValidAddress(),
136
+ chainid: chainId,
137
+ actionParameter: {
138
+ filterType: FilterType.EQUAL,
139
+ fieldType: PrimitiveType.ADDRESS,
140
+ fieldIndex: 0,
141
+ filterData: accounts[1].account,
142
+ },
143
+ },
144
+ ],
145
+ };
146
+ }
147
+
148
+ function indexedStringErc721TransferAction(
149
+ filterType: FilterType,
150
+ data: Hex,
151
+ stringEmitterAddress: Address,
152
+ erc721: MockERC721,
153
+ ): EventActionPayloadSimple {
154
+ return {
155
+ actionClaimant: {
156
+ signatureType: SignatureType.EVENT,
157
+ signature: eventSelectors[
158
+ "Transfer(address indexed,address indexed,uint256 indexed)"
159
+ ] as Hex,
160
+ fieldIndex: 1,
161
+ targetContract: erc721.assertValidAddress(),
162
+ chainid: chainId,
163
+ },
164
+ actionSteps: [
165
+ {
166
+ signature: eventSelectors[
167
+ "InfoIndexed(address indexed,string indexed)"
168
+ ] as Hex,
169
+ signatureType: SignatureType.EVENT,
170
+ actionType: 0,
171
+ targetContract: stringEmitterAddress,
172
+ chainid: chainId,
173
+ actionParameter: {
174
+ filterType,
175
+ fieldType: PrimitiveType.STRING,
176
+ fieldIndex: 1,
177
+ filterData: data,
178
+ },
179
+ },
180
+ ],
181
+ };
182
+ }
183
+
184
+ function stringErc721TransferAction(
185
+ filterType: FilterType,
186
+ data: Hex,
187
+ stringEmitterAddress: Address,
188
+ erc721: MockERC721,
189
+ ): EventActionPayloadSimple {
190
+ return {
191
+ actionClaimant: {
192
+ signatureType: SignatureType.EVENT,
193
+ signature: eventSelectors[
194
+ "Transfer(address indexed,address indexed,uint256 indexed)"
195
+ ] as Hex,
196
+ fieldIndex: 1,
197
+ targetContract: erc721.assertValidAddress(),
198
+ chainid: chainId,
199
+ },
200
+ actionSteps: [
201
+ {
202
+ signature: eventSelectors["Info(address,string)"] as Hex,
203
+ signatureType: SignatureType.EVENT,
204
+ actionType: 0,
205
+ targetContract: stringEmitterAddress,
206
+ chainid: chainId,
207
+ actionParameter: {
208
+ filterType,
209
+ fieldType: PrimitiveType.STRING,
210
+ fieldIndex: 1,
211
+ filterData: data,
212
+ },
213
+ },
214
+ ],
215
+ };
216
+ }
217
+
218
+ function cloneFunctionAction20(fixtures: Fixtures, erc20: MockERC20) {
219
+ return function cloneFunctionAction20() {
220
+ return fixtures.registry.clone(
221
+ crypto.randomUUID(),
222
+ new fixtures.bases.EventAction(
223
+ defaultOptions,
224
+ basicErc20MintFuncAction(erc20),
225
+ ),
226
+ );
227
+ };
228
+ }
229
+
230
+ function cloneFunctionAction(fixtures: Fixtures, erc721: MockERC721) {
231
+ return function cloneFunctionAction() {
232
+ return fixtures.registry.clone(
233
+ crypto.randomUUID(),
234
+ new fixtures.bases.EventAction(
235
+ defaultOptions,
236
+ basicErc721MintFuncAction(erc721),
237
+ ),
238
+ );
239
+ };
240
+ }
241
+
242
+ function cloneStringEventAction(
243
+ fixtures: Fixtures,
244
+ actionParams: EventActionPayloadSimple,
245
+ ) {
246
+ return function loadFixtureCallback() {
247
+ return fixtures.registry.clone(
248
+ crypto.randomUUID(),
249
+ new fixtures.bases.EventAction(defaultOptions, actionParams),
250
+ );
251
+ };
252
+ }
253
+
254
+ function createMockCriteria(
255
+ filterType: FilterType,
256
+ fieldType: PrimitiveType,
257
+ filterData: Hex,
258
+ fieldIndex: number = 0
259
+ ): Criteria {
260
+ return {
261
+ filterType,
262
+ fieldType,
263
+ filterData,
264
+ fieldIndex,
265
+ };
266
+ }
267
+
268
+ describe("EventAction Event Selector", () => {
269
+ beforeEach(async () => {
270
+ erc721 = await loadFixture(fundErc721(defaultOptions));
271
+ });
272
+
273
+ describe("basic transfer event", () => {
274
+ test("can successfully be deployed", async () => {
275
+ const action = new EventAction(
276
+ defaultOptions,
277
+ basicErc721TransferAction(erc721),
278
+ );
279
+ await action.deploy();
280
+ expect(isAddress(action.assertValidAddress())).toBe(true);
281
+ });
282
+
283
+ test("can get an action step", async () => {
284
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
285
+ const step = await action.getActionStep(0);
286
+ if (!step)
287
+ throw new Error("there should be an action step at this index");
288
+ step.targetContract = step.targetContract.toUpperCase() as Hex;
289
+ step.actionParameter.filterData =
290
+ step.actionParameter.filterData.toUpperCase() as Hex;
291
+ expect(step).toMatchObject({
292
+ signature: eventSelectors[
293
+ "Transfer(address indexed,address indexed,uint256 indexed)"
294
+ ] as Hex,
295
+ signatureType: SignatureType.EVENT,
296
+ actionType: 0,
297
+ targetContract: erc721.assertValidAddress().toUpperCase(),
298
+ actionParameter: {
299
+ filterType: FilterType.EQUAL,
300
+ fieldType: PrimitiveType.ADDRESS,
301
+ fieldIndex: 1,
302
+ filterData: accounts[1].account.toUpperCase(),
303
+ },
304
+ });
305
+ });
306
+
307
+ test("can get all action steps", async () => {
308
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
309
+ const steps = await action.getActionSteps();
310
+ expect(steps.length).toBe(1);
311
+ const step = steps[0]!;
312
+ step.targetContract = step.targetContract.toUpperCase() as Hex;
313
+ step.actionParameter.filterData =
314
+ step.actionParameter.filterData.toUpperCase() as Hex;
315
+ expect(step).toMatchObject({
316
+ signature: eventSelectors[
317
+ "Transfer(address indexed,address indexed,uint256 indexed)"
318
+ ] as Hex,
319
+ signatureType: SignatureType.EVENT,
320
+ actionType: 0,
321
+ targetContract: erc721.assertValidAddress().toUpperCase(),
322
+ actionParameter: {
323
+ filterType: FilterType.EQUAL,
324
+ fieldType: PrimitiveType.ADDRESS,
325
+ fieldIndex: 1,
326
+ filterData: accounts[1].account.toUpperCase(),
327
+ },
328
+ });
329
+ });
330
+
331
+ test("can get the total number of action steps", async () => {
332
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
333
+ const count = await action.getActionStepsCount();
334
+ expect(count).toBe(1);
335
+ });
336
+
337
+ test("can get the action claimant", async () => {
338
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
339
+ const claimant = await action.getActionClaimant();
340
+ claimant.targetContract = claimant.targetContract.toUpperCase() as Hex;
341
+ expect(claimant).toMatchObject({
342
+ signatureType: SignatureType.EVENT,
343
+ signature: eventSelectors[
344
+ "Transfer(address indexed,address indexed,uint256 indexed)"
345
+ ] as Hex,
346
+ fieldIndex: 1,
347
+ });
348
+ });
349
+
350
+ test("can get all action steps", async () => {
351
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
352
+ const steps = await action.getActionSteps();
353
+ expect(steps.length).toBe(1);
354
+ const step = steps[0]!;
355
+ step.targetContract = step.targetContract.toUpperCase() as Hex;
356
+ step.actionParameter.filterData =
357
+ step.actionParameter.filterData.toUpperCase() as Hex;
358
+ expect(step).toMatchObject({
359
+ signature: eventSelectors[
360
+ "Transfer(address indexed,address indexed,uint256 indexed)"
361
+ ] as Hex,
362
+ signatureType: SignatureType.EVENT,
363
+ actionType: 0,
364
+ targetContract: erc721.assertValidAddress().toUpperCase(),
365
+ actionParameter: {
366
+ filterType: FilterType.EQUAL,
367
+ fieldType: PrimitiveType.ADDRESS,
368
+ fieldIndex: 1,
369
+ filterData: accounts[1].account.toUpperCase(),
370
+ },
371
+ });
372
+ });
373
+
374
+ test("can get the total number of action steps", async () => {
375
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
376
+ const count = await action.getActionStepsCount();
377
+ expect(count).toBe(1);
378
+ });
379
+
380
+ test("can get the action claimant", async () => {
381
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
382
+ const claimant = await action.getActionClaimant();
383
+ claimant.targetContract = claimant.targetContract.toUpperCase() as Hex;
384
+ expect(claimant).toMatchObject({
385
+ signatureType: SignatureType.EVENT,
386
+ signature: eventSelectors[
387
+ "Transfer(address indexed,address indexed,uint256 indexed)"
388
+ ] as Hex,
389
+ fieldIndex: 1,
390
+ targetContract: erc721.assertValidAddress().toUpperCase(),
391
+ });
392
+ });
393
+
394
+ test("with a correct log, validates", async () => {
395
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
396
+ const recipient = accounts[1].account;
397
+ await erc721.approve(recipient, 1n);
398
+ const { hash } = await erc721.transferFromRaw(defaultOptions.account.address, recipient, 1n);
399
+ expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
400
+ });
401
+
402
+ test("can supply your own logs to validate against", async () => {
403
+ const hash = "0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5"
404
+ const logs: EventLogs = [
405
+ {
406
+ eventName: "Transfer",
407
+ args: [
408
+ "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
409
+ "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
410
+ 1n,
411
+ ],
412
+ address: erc721.assertValidAddress(),
413
+ blockHash:
414
+ "0xbf602f988260519805d032be46d6ff97fbefbee6924b21097074d6d0bc34eced",
415
+ blockNumber: 1203n,
416
+ data: "0x",
417
+ logIndex: 0,
418
+ removed: false,
419
+ topics: [
420
+ "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
421
+ "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266",
422
+ "0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8",
423
+ "0x0000000000000000000000000000000000000000000000000000000000000001",
424
+ ],
425
+ transactionHash:
426
+ "0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5",
427
+ transactionIndex: 0,
428
+ },
429
+ ];
430
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
431
+ expect(await action.validateActionSteps({ hash, chainId, logs })).toBe(true);
432
+ });
433
+
434
+ describe("string event actions", () => {
435
+ test("cannot parse and validate contains for an emitted string event with an indexed param", async () => {
436
+ const action = await loadFixture(
437
+ cloneStringEventAction(
438
+ fixtures,
439
+ indexedStringErc721TransferAction(
440
+ FilterType.CONTAINS,
441
+ toHex("ello"),
442
+ stringEmitterFixtures.address,
443
+ erc721,
444
+ ),
445
+ ),
446
+ );
447
+
448
+ const hash = await stringEmitterFixtures.emitIndexedString("Hello world");
449
+ await expect(() => action.validateActionSteps({ hash, chainId })).rejects.toThrowError(
450
+ /Parameter is not transparently stored onchain/,
451
+ );
452
+ });
453
+ test("can parse and validate contains for an emitted string event", async () => {
454
+ const action = await loadFixture(
455
+ cloneStringEventAction(
456
+ fixtures,
457
+ stringErc721TransferAction(
458
+ FilterType.CONTAINS,
459
+ toHex("ello"),
460
+ stringEmitterFixtures.address,
461
+ erc721,
462
+ ),
463
+ ),
464
+ );
465
+ const hash = await stringEmitterFixtures.emitString("Hello world");
466
+ expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
467
+ });
468
+ test("can parse and validate regex for an emitted string event", async () => {
469
+ const action = await loadFixture(
470
+ cloneStringEventAction(
471
+ fixtures,
472
+ stringErc721TransferAction(
473
+ FilterType.REGEX,
474
+ toHex("[hH]ello"),
475
+ stringEmitterFixtures.address,
476
+ erc721,
477
+ ),
478
+ ),
479
+ );
480
+
481
+ const hash = await stringEmitterFixtures.emitString("Hello world");
482
+ expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
483
+ });
484
+ });
485
+
486
+ test("can derive the claimant from an event action", async () => {
487
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
488
+ const recipient = accounts[1].account;
489
+ await erc721.approve(recipient, 1n);
490
+ const { hash } = await erc721.transferFromRaw(defaultOptions.account.address, recipient, 1n);
491
+ expect(
492
+ await action.deriveActionClaimantFromTransaction(await action.getActionClaimant(), {
493
+ hash,
494
+ chainId,
495
+ }),
496
+ ).toBe(recipient);
497
+ });
498
+
499
+ test("can derive the claimant from a function action", async () => {
500
+ const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
501
+ const recipient = accounts[1].account;
502
+ const { hash } = await erc721.mintRaw(recipient, {
503
+ value: parseEther(".1"),
504
+ });
505
+
506
+ expect(
507
+ await action.deriveActionClaimantFromTransaction(await action.getActionClaimant(), {
508
+ hash,
509
+ chainId,
510
+ }),
511
+ ).toBe(recipient);
512
+ });
513
+ });
514
+ });
515
+
516
+ describe("validateFieldAgainstCriteria unit tests", () => {
517
+ let action: EventAction
518
+ beforeAll(async () => {
519
+ action = await loadFixture(cloneEventAction(fixtures, erc721));
520
+ });
521
+ const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
522
+ const mockInput = { decodedArgs: ['not used'] };
523
+
524
+ test('should return true for EQUAL filter type with ADDRESS field type', () => {
525
+ const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.ADDRESS, mockAddress);
526
+ const result = action.validateFieldAgainstCriteria(mockCriteria, mockAddress, mockInput);
527
+ expect(result).toBe(true);
528
+ });
529
+
530
+ test('should return true for EQUAL filter type with UINT field type', () => {
531
+ const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.UINT, '0xc8');
532
+ const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
533
+ expect(result).toBe(true);
534
+ });
535
+ test('should return true for EQUAL filter type with STRING field type when values match', () => {
536
+ // Decoded value: 'hello'
537
+ const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.STRING, '0x68656c6c6f');
538
+ const result = action.validateFieldAgainstCriteria(mockCriteria, 'hello', mockInput);
539
+ expect(result).toBe(true);
540
+ });
541
+
542
+ test('should return false for EQUAL filter type with STRING field type when values do not match', () => {
543
+ // Decoded value: 'hello'
544
+ const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.STRING, '0x68656c6c6f');
545
+ const result = action.validateFieldAgainstCriteria(mockCriteria, 'world', mockInput);
546
+ expect(result).toBe(false);
547
+ });
548
+
549
+ test('should return true for EQUAL filter type with BYTES field type when values match', () => {
550
+ // Decoded value: '0x68656c6c6f' (hex for 'hello')
551
+ const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.BYTES, '0x68656c6c6f');
552
+ const result = action.validateFieldAgainstCriteria(mockCriteria, '0x68656c6c6f', mockInput);
553
+ expect(result).toBe(true);
554
+ });
555
+
556
+ test('should return false for EQUAL filter type with BYTES field type when values do not match', () => {
557
+ // Decoded value: '0x68656c6c6f' (hex for 'hello')
558
+ const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.BYTES, '0x68656c6c6f');
559
+ const result = action.validateFieldAgainstCriteria(mockCriteria, '0x776f726c64', mockInput); // hex for 'world'
560
+ expect(result).toBe(false);
561
+ });
562
+
563
+ test('should return false for NOT_EQUAL filter type with ADDRESS field type', () => {
564
+ const mockCriteria = createMockCriteria(FilterType.NOT_EQUAL, PrimitiveType.ADDRESS, mockAddress);
565
+ const result = action.validateFieldAgainstCriteria(mockCriteria, zeroAddress, mockInput);
566
+ expect(result).toBe(true);
567
+ });
568
+
569
+ test('should return true for NOT_EQUAL filter type with UINT field type', () => {
570
+ const mockCriteria = createMockCriteria(FilterType.NOT_EQUAL, PrimitiveType.UINT, '0xc9');
571
+ const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
572
+ expect(result).toBe(true);
573
+ });
574
+
575
+ test('should throw InvalidNumericalCriteriaError for GREATER_THAN filter type with non-uint field type', () => {
576
+ const mockCriteria = createMockCriteria(FilterType.GREATER_THAN, PrimitiveType.STRING, '0x100');
577
+ expect(() => action.validateFieldAgainstCriteria(mockCriteria, '200', mockInput)).toThrow('non-numerical criteria');
578
+ });
579
+
580
+ test('should return true for GREATER_THAN filter type with UINT field type', () => {
581
+ const mockCriteria = createMockCriteria(FilterType.GREATER_THAN, PrimitiveType.UINT, '0x64');
582
+ const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
583
+ expect(result).toBe(true);
584
+ });
585
+
586
+ test('should return true for CONTAINS filter type with STRING field type', () => {
587
+ // Decoded value: 'hello'
588
+ const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.STRING, '0x68656c6c6f');
589
+ const result = action.validateFieldAgainstCriteria(mockCriteria, 'hello world', mockInput);
590
+ expect(result).toBe(true);
591
+ });
592
+
593
+ test('should return true for CONTAINS filter type with BYTES field type', () => {
594
+ const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.BYTES, '0xbeef');
595
+ const result = action.validateFieldAgainstCriteria(mockCriteria, '0xdeadbeef', mockInput);
596
+ expect(result).toBe(true);
597
+ });
598
+
599
+ test('should throw FieldValueNotComparableError for CONTAINS filter type with non-string/bytes field type', () => {
600
+ // Decoded value: 123
601
+ const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.UINT, '0x7b');
602
+ expect(() => action.validateFieldAgainstCriteria(mockCriteria, 123n, mockInput)).toThrow(/only .* bytes or string/);
603
+ });
604
+
605
+ test('should throw UnrecognizedFilterTypeError for unrecognized filter type', () => {
606
+ const mockCriteria = createMockCriteria(6 as FilterType, PrimitiveType.STRING, '0x74657374'); // Decoded value: 'test'
607
+ expect(() => action.validateFieldAgainstCriteria(mockCriteria, 'test', mockInput)).toThrow('Invalid FilterType');
608
+ });
609
+
610
+ test('should return true for LESS_THAN filter type with UINT field type', () => {
611
+ // Decoded value: 200
612
+ const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.UINT, '0xc8');
613
+ const result = action.validateFieldAgainstCriteria(mockCriteria, 100n, mockInput);
614
+ expect(result).toBe(true);
615
+ });
616
+
617
+ test('should return false for LESS_THAN filter type with UINT field type when value is greater', () => {
618
+ // Decoded value: 100
619
+ const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.UINT, '0x64');
620
+ const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
621
+ expect(result).toBe(false);
622
+ });
623
+
624
+ test('should throw InvalidNumericalCriteriaError for LESS_THAN filter type with non-uint field type', () => {
625
+ // Decoded value: 100
626
+ const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.STRING, '0x64');
627
+ expect(() => action.validateFieldAgainstCriteria(mockCriteria, '50', mockInput)).toThrow('non-numerical');
628
+ });
629
+
630
+ test('should throw InvalidNumericalCriteriaError for LESS_THAN filter type with ADDRESS field type', () => {
631
+ const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.ADDRESS, '0x1234567890abcdef1234567890abcdef12345678');
632
+ expect(() => action.validateFieldAgainstCriteria(mockCriteria, '0x1234567890abcdef1234567890abcdef12345678', mockInput)).toThrow('non-numerical');
633
+ });
634
+
635
+ })
636
+
637
+ describe("EventAction Func Selector", () => {
638
+ beforeEach(async () => {
639
+ erc721 = await loadFixture(fundErc721(defaultOptions));
640
+ erc20 = await loadFixture(fundErc20(defaultOptions));
641
+ });
642
+
643
+ test("can be deployed successfully", async () => {
644
+ const action = new EventAction(
645
+ defaultOptions,
646
+ basicErc721MintFuncAction(erc721),
647
+ );
648
+ await action.deploy();
649
+ expect(isAddress(action.assertValidAddress())).toBe(true);
650
+ });
651
+
652
+ test("validates function action step with correct hash", async () => {
653
+ const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
654
+ const actionSteps = await action.getActionSteps();
655
+ const actionStep = actionSteps[0]!
656
+ const recipient = accounts[1].account;
657
+ const { hash } = await erc721.mintRaw(recipient, {
658
+ value: parseEther(".1"),
659
+ });
660
+
661
+ expect(
662
+ await action.isActionStepValid(actionStep, { hash, chainId })
663
+ ).toBe(true);
664
+ });
665
+
666
+ test("validates function step with EQUAL filter", async () => {
667
+ const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
668
+ const actionSteps = await action.getActionSteps();
669
+ const actionStep = actionSteps[0]!
670
+ const recipient = accounts[1].account;
671
+ const { hash } = await erc721.mintRaw(recipient, {
672
+ value: parseEther(".1"),
673
+ });
674
+
675
+ const criteriaMatch = await action.isActionStepValid(actionStep, {
676
+ hash,
677
+ chainId,
678
+ });
679
+
680
+ expect(criteriaMatch).toBe(true);
681
+ });
682
+
683
+ test("fails validation with incorrect function signature", async () => {
684
+ const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
685
+ const actionSteps = await action.getActionSteps();
686
+ const actionStep = actionSteps[0]!;
687
+ const recipient = accounts[1].account;
688
+
689
+ const invalidStep = {
690
+ ...actionStep,
691
+ signature: funcSelectors["mint(address to, uint256 amount)"] as Hex, // Intentional mismatch
692
+ };
693
+
694
+ const { hash } = await erc721.mintRaw(recipient, {
695
+ value: parseEther(".1"),
696
+ });
697
+
698
+ try {
699
+ await action.isActionStepValid(invalidStep, { hash, chainId });
700
+ } catch (e) {
701
+ expect(e).toBeInstanceOf(Error);
702
+ expect((e as Error).message).toContain(
703
+ 'Failed to decode function data: Encoded function signature "0x6a627842"',
704
+ );
705
+ }
706
+ });
707
+
708
+ test("validates against NOT_EQUAL filter criteria", async () => {
709
+ const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
710
+ const actionSteps = await action.getActionSteps();
711
+ const actionStep = actionSteps[0]!;
712
+ actionStep.actionParameter.filterType = FilterType.NOT_EQUAL;
713
+ const recipient = accounts[2].account;
714
+ const { hash } = await erc721.mintRaw(recipient, {
715
+ value: parseEther(".1"),
716
+ });
717
+
718
+ expect(
719
+ await action.isActionStepValid(actionStep, {
720
+ hash,
721
+ chainId,
722
+ }),
723
+ ).toBe(true);
724
+ });
725
+
726
+ test("validates GREATER_THAN criteria for numeric values", async () => {
727
+ const action = await loadFixture(cloneFunctionAction20(fixtures, erc20));
728
+ const actionSteps = await action.getActionSteps();
729
+ const actionStep = actionSteps[0]!;
730
+
731
+ actionStep.actionParameter = {
732
+ filterType: FilterType.GREATER_THAN,
733
+ fieldType: PrimitiveType.UINT,
734
+ fieldIndex: 1,
735
+ filterData: toHex("1"),
736
+ };
737
+
738
+ const address = accounts[1].account;
739
+ const value = 400n;
740
+ const { hash } = await erc20.mintRaw(address, value);
741
+
742
+ expect(
743
+ await action.isActionStepValid(actionStep, {
744
+ hash,
745
+ chainId,
746
+ }),
747
+ ).toBe(true);
748
+ });
749
+
750
+ test("validates LESS_THAN criteria for numeric values", async () => {
751
+ const action = await loadFixture(cloneFunctionAction20(fixtures, erc20));
752
+ const actionSteps = await action.getActionSteps();
753
+ const actionStep = actionSteps[0]!;
754
+ actionStep.actionParameter = {
755
+ filterType: FilterType.LESS_THAN,
756
+ fieldType: PrimitiveType.UINT,
757
+ fieldIndex: 1,
758
+ filterData: toHex("5"),
759
+ };
760
+
761
+ const address = accounts[1].account;
762
+ const value = 4n;
763
+ const { hash } = await erc20.mintRaw(address, value);
764
+
765
+ expect(
766
+ await action.isActionStepValid(actionStep, {
767
+ hash,
768
+ chainId,
769
+ }),
770
+ ).toBe(true);
771
+ });
772
+
773
+ test("validates entire flow of function action", async () => {
774
+ const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
775
+ const recipient = accounts[1].account;
776
+ const { hash } = await erc721.mintRaw(recipient, {
777
+ value: parseEther(".1"),
778
+ });
779
+
780
+ expect(
781
+ await action.validateActionSteps({
782
+ hash,
783
+ chainId,
784
+ }),
785
+ ).toBe(true);
786
+ });
787
+ });