@boostxyz/sdk 0.0.0-alpha.8 → 1.1.0-alpha.22

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 (266) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.cjs.map +1 -1
  3. package/dist/Actions/Action.js +7 -7
  4. package/dist/Actions/ContractAction.d.ts +57 -14
  5. package/dist/Actions/ContractAction.d.ts.map +1 -1
  6. package/dist/Actions/ERC721MintAction.d.ts +50 -23
  7. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  8. package/dist/Actions/EventAction.cjs +1 -1
  9. package/dist/Actions/EventAction.cjs.map +1 -1
  10. package/dist/Actions/EventAction.d.ts +420 -45
  11. package/dist/Actions/EventAction.d.ts.map +1 -1
  12. package/dist/Actions/EventAction.js +15 -225
  13. package/dist/Actions/EventAction.js.map +1 -1
  14. package/dist/AllowLists/AllowList.cjs +1 -1
  15. package/dist/AllowLists/AllowList.cjs.map +1 -1
  16. package/dist/AllowLists/AllowList.d.ts +6 -4
  17. package/dist/AllowLists/AllowList.d.ts.map +1 -1
  18. package/dist/AllowLists/AllowList.js +45 -23
  19. package/dist/AllowLists/AllowList.js.map +1 -1
  20. package/dist/AllowLists/OpenAllowList.d.ts +423 -0
  21. package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
  22. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  23. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  24. package/dist/AllowLists/SimpleAllowList.d.ts +123 -39
  25. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  26. package/dist/AllowLists/SimpleAllowList.js +75 -76
  27. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  28. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  29. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
  30. package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
  31. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  32. package/dist/AllowLists/SimpleDenyList.js +11 -200
  33. package/dist/AllowLists/SimpleDenyList.js.map +1 -1
  34. package/dist/Auth/PassthroughAuth.cjs +1 -1
  35. package/dist/Auth/PassthroughAuth.cjs.map +1 -1
  36. package/dist/Auth/PassthroughAuth.js +4 -4
  37. package/dist/Auth/PassthroughAuth.js.map +1 -1
  38. package/dist/Boost.cjs +1 -1
  39. package/dist/Boost.cjs.map +1 -1
  40. package/dist/Boost.d.ts +105 -14
  41. package/dist/Boost.d.ts.map +1 -1
  42. package/dist/Boost.js +137 -5
  43. package/dist/Boost.js.map +1 -1
  44. package/dist/BoostCore-BVZExPPu.js +1462 -0
  45. package/dist/BoostCore-BVZExPPu.js.map +1 -0
  46. package/dist/BoostCore-D-E-cnGI.cjs +3 -0
  47. package/dist/BoostCore-D-E-cnGI.cjs.map +1 -0
  48. package/dist/BoostCore.cjs +1 -2
  49. package/dist/BoostCore.cjs.map +1 -1
  50. package/dist/BoostCore.d.ts +759 -82
  51. package/dist/BoostCore.d.ts.map +1 -1
  52. package/dist/BoostCore.js +29 -1148
  53. package/dist/BoostCore.js.map +1 -1
  54. package/dist/BoostRegistry.cjs +1 -1
  55. package/dist/BoostRegistry.cjs.map +1 -1
  56. package/dist/BoostRegistry.d.ts +83 -28
  57. package/dist/BoostRegistry.d.ts.map +1 -1
  58. package/dist/BoostRegistry.js +170 -93
  59. package/dist/BoostRegistry.js.map +1 -1
  60. package/dist/Budgets/Budget.cjs +1 -1
  61. package/dist/Budgets/Budget.cjs.map +1 -1
  62. package/dist/Budgets/Budget.d.ts.map +1 -1
  63. package/dist/Budgets/Budget.js +2 -2
  64. package/dist/Budgets/Budget.js.map +1 -1
  65. package/dist/Budgets/ManagedBudget.cjs +1 -1
  66. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  67. package/dist/Budgets/ManagedBudget.d.ts +112 -192
  68. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  69. package/dist/Budgets/ManagedBudget.js +89 -290
  70. package/dist/Budgets/ManagedBudget.js.map +1 -1
  71. package/dist/Budgets/VestingBudget.d.ts +277 -91
  72. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  73. package/dist/Deployable/Contract.cjs +1 -1
  74. package/dist/Deployable/Contract.cjs.map +1 -1
  75. package/dist/Deployable/Contract.d.ts +4 -5
  76. package/dist/Deployable/Contract.d.ts.map +1 -1
  77. package/dist/Deployable/Contract.js +6 -8
  78. package/dist/Deployable/Contract.js.map +1 -1
  79. package/dist/Deployable/Deployable.cjs.map +1 -1
  80. package/dist/Deployable/Deployable.d.ts +1 -1
  81. package/dist/Deployable/Deployable.d.ts.map +1 -1
  82. package/dist/Deployable/Deployable.js +3 -5
  83. package/dist/Deployable/Deployable.js.map +1 -1
  84. package/dist/Deployable/DeployableTarget.cjs +1 -1
  85. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  86. package/dist/Deployable/DeployableTarget.d.ts +13 -13
  87. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  88. package/dist/Deployable/DeployableTarget.js +30 -27
  89. package/dist/Deployable/DeployableTarget.js.map +1 -1
  90. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  91. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  92. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
  93. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  94. package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
  95. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  96. package/dist/EventAction-BZt5cjbe.cjs +2 -0
  97. package/dist/EventAction-BZt5cjbe.cjs.map +1 -0
  98. package/dist/EventAction-C_-hJXWm.js +1541 -0
  99. package/dist/EventAction-C_-hJXWm.js.map +1 -0
  100. package/dist/Incentive-BhHaK3PZ.cjs +2 -0
  101. package/dist/Incentive-BhHaK3PZ.cjs.map +1 -0
  102. package/dist/Incentive-Cqg1w6wD.js +312 -0
  103. package/dist/Incentive-Cqg1w6wD.js.map +1 -0
  104. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  105. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  106. package/dist/Incentives/AllowListIncentive.d.ts +73 -21
  107. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  108. package/dist/Incentives/AllowListIncentive.js +61 -36
  109. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  110. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  111. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  112. package/dist/Incentives/CGDAIncentive.d.ts +323 -26
  113. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  114. package/dist/Incentives/CGDAIncentive.js +73 -39
  115. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  116. package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
  117. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  118. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  119. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  120. package/dist/Incentives/ERC20Incentive.d.ts +278 -33
  121. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  122. package/dist/Incentives/ERC20Incentive.js +79 -47
  123. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  124. package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +346 -420
  125. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  126. package/dist/Incentives/ERC20VariableIncentive.d.ts +271 -32
  127. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  128. package/dist/Incentives/Incentive.cjs +1 -1
  129. package/dist/Incentives/Incentive.cjs.map +1 -1
  130. package/dist/Incentives/Incentive.d.ts +4 -4
  131. package/dist/Incentives/Incentive.d.ts.map +1 -1
  132. package/dist/Incentives/Incentive.js +16 -280
  133. package/dist/Incentives/Incentive.js.map +1 -1
  134. package/dist/Incentives/PointsIncentive.cjs +1 -1
  135. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  136. package/dist/Incentives/PointsIncentive.d.ts +89 -23
  137. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  138. package/dist/Incentives/PointsIncentive.js +66 -36
  139. package/dist/Incentives/PointsIncentive.js.map +1 -1
  140. package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
  141. package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
  142. package/dist/SimpleDenyList-CGaWjuld.js +132 -0
  143. package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
  144. package/dist/Validators/SignerValidator.cjs +1 -1
  145. package/dist/Validators/SignerValidator.cjs.map +1 -1
  146. package/dist/Validators/SignerValidator.d.ts +310 -17
  147. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  148. package/dist/Validators/SignerValidator.js +164 -36
  149. package/dist/Validators/SignerValidator.js.map +1 -1
  150. package/dist/Validators/Validator.cjs +1 -1
  151. package/dist/Validators/Validator.cjs.map +1 -1
  152. package/dist/Validators/Validator.d.ts +1 -1
  153. package/dist/Validators/Validator.js +2 -2
  154. package/dist/Validators/Validator.js.map +1 -1
  155. package/dist/claiming.cjs +2 -0
  156. package/dist/claiming.cjs.map +1 -0
  157. package/dist/claiming.d.ts +43 -0
  158. package/dist/claiming.d.ts.map +1 -0
  159. package/dist/claiming.js +17 -0
  160. package/dist/claiming.js.map +1 -0
  161. package/dist/componentInterfaces-BBCFkrZv.js +14 -0
  162. package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
  163. package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
  164. package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
  165. package/dist/deployments-DVXioW2i.cjs +2 -0
  166. package/dist/deployments-DVXioW2i.cjs.map +1 -0
  167. package/dist/deployments-oykLv3_Z.js +43 -0
  168. package/dist/deployments-oykLv3_Z.js.map +1 -0
  169. package/dist/deployments.json +44 -0
  170. package/dist/errors.cjs +1 -1
  171. package/dist/errors.cjs.map +1 -1
  172. package/dist/errors.d.ts +257 -21
  173. package/dist/errors.d.ts.map +1 -1
  174. package/dist/errors.js +183 -26
  175. package/dist/errors.js.map +1 -1
  176. package/dist/{generated-Cbv8zFkf.js → generated-CKt2yCQd.js} +3615 -1868
  177. package/dist/generated-CKt2yCQd.js.map +1 -0
  178. package/dist/generated-CyTNlOwM.cjs +3 -0
  179. package/dist/generated-CyTNlOwM.cjs.map +1 -0
  180. package/dist/index.cjs +1 -1
  181. package/dist/index.d.ts +9 -4
  182. package/dist/index.d.ts.map +1 -1
  183. package/dist/index.js +143 -126
  184. package/dist/index.js.map +1 -1
  185. package/dist/transfers.cjs +2 -0
  186. package/dist/transfers.cjs.map +1 -0
  187. package/dist/transfers.d.ts +198 -0
  188. package/dist/transfers.d.ts.map +1 -0
  189. package/dist/transfers.js +84 -0
  190. package/dist/transfers.js.map +1 -0
  191. package/dist/utils.cjs +1 -1
  192. package/dist/utils.cjs.map +1 -1
  193. package/dist/utils.d.ts +25 -1380
  194. package/dist/utils.d.ts.map +1 -1
  195. package/dist/utils.js +36 -648
  196. package/dist/utils.js.map +1 -1
  197. package/package.json +34 -10
  198. package/src/Actions/Action.test.ts +19 -17
  199. package/src/Actions/ContractAction.test.ts +14 -16
  200. package/src/Actions/ContractAction.ts +84 -22
  201. package/src/Actions/ERC721MintAction.test.ts +8 -8
  202. package/src/Actions/ERC721MintAction.ts +83 -30
  203. package/src/Actions/EventAction.test.ts +759 -113
  204. package/src/Actions/EventAction.ts +991 -116
  205. package/src/AllowLists/AllowList.test.ts +7 -7
  206. package/src/AllowLists/AllowList.ts +5 -3
  207. package/src/AllowLists/OpenAllowList.test.ts +40 -0
  208. package/src/AllowLists/OpenAllowList.ts +45 -0
  209. package/src/AllowLists/SimpleAllowList.test.ts +4 -4
  210. package/src/AllowLists/SimpleAllowList.ts +86 -65
  211. package/src/AllowLists/SimpleDenyList.test.ts +4 -4
  212. package/src/AllowLists/SimpleDenyList.ts +87 -126
  213. package/src/Auth/PassthroughAuth.test.ts +1 -1
  214. package/src/Auth/PassthroughAuth.ts +1 -1
  215. package/src/Boost.ts +147 -15
  216. package/src/BoostCore.test.ts +326 -278
  217. package/src/BoostCore.ts +425 -242
  218. package/src/BoostRegistry.test.ts +53 -0
  219. package/src/BoostRegistry.ts +168 -50
  220. package/src/Budgets/Budget.test.ts +2 -2
  221. package/src/Budgets/Budget.ts +1 -2
  222. package/src/Budgets/ManagedBudget.test.ts +82 -19
  223. package/src/Budgets/ManagedBudget.ts +106 -315
  224. package/src/Budgets/VestingBudget.test.ts +7 -7
  225. package/src/Budgets/VestingBudget.ts +110 -112
  226. package/src/Deployable/Contract.ts +5 -6
  227. package/src/Deployable/Deployable.ts +1 -1
  228. package/src/Deployable/DeployableTarget.ts +32 -21
  229. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  230. package/src/Incentives/AllowListIncentive.test.ts +7 -10
  231. package/src/Incentives/AllowListIncentive.ts +88 -30
  232. package/src/Incentives/CGDAIncentive.test.ts +11 -12
  233. package/src/Incentives/CGDAIncentive.ts +161 -37
  234. package/src/Incentives/ERC1155Incentive.test.ts +5 -16
  235. package/src/Incentives/ERC1155Incentive.ts +132 -51
  236. package/src/Incentives/ERC20Incentive.test.ts +15 -23
  237. package/src/Incentives/ERC20Incentive.ts +131 -46
  238. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  239. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
  240. package/src/Incentives/ERC20VariableIncentive.test.ts +12 -35
  241. package/src/Incentives/ERC20VariableIncentive.ts +118 -43
  242. package/src/Incentives/Incentive.test.ts +5 -2
  243. package/src/Incentives/Incentive.ts +7 -6
  244. package/src/Incentives/PointsIncentive.test.ts +26 -30
  245. package/src/Incentives/PointsIncentive.ts +110 -34
  246. package/src/Validators/SignerValidator.test.ts +9 -13
  247. package/src/Validators/SignerValidator.ts +437 -26
  248. package/src/Validators/Validator.test.ts +2 -2
  249. package/src/Validators/Validator.ts +1 -1
  250. package/src/claiming.ts +56 -0
  251. package/src/errors.ts +346 -22
  252. package/src/index.test.ts +118 -36
  253. package/src/index.ts +15 -7
  254. package/src/transfers.ts +284 -0
  255. package/src/utils.test.ts +2 -2
  256. package/src/utils.ts +61 -2061
  257. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  258. package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
  259. package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
  260. package/dist/componentInterfaces-DYkaxBda.js +0 -13
  261. package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
  262. package/dist/generated-BzszviNp.cjs +0 -3
  263. package/dist/generated-BzszviNp.cjs.map +0 -1
  264. package/dist/generated-Cbv8zFkf.js.map +0 -1
  265. package/src/Budgets/SimpleBudget.test.ts +0 -152
  266. package/src/Budgets/SimpleBudget.ts +0 -521
@@ -0,0 +1,324 @@
1
+ import {
2
+ erc20VariableCriteriaIncentiveAbi,
3
+ readErc20VariableCriteriaIncentiveGetIncentiveCriteria,
4
+ } from '@boostxyz/evm';
5
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableCriteriaIncentive.sol/ERC20VariableCriteriaIncentive.json';
6
+ import events from '@boostxyz/signatures/events';
7
+ import functions from '@boostxyz/signatures/functions';
8
+ import { getTransaction, getTransactionReceipt } from '@wagmi/core';
9
+ import {
10
+ type AbiEvent,
11
+ type AbiFunction,
12
+ type Address,
13
+ type Hex,
14
+ type Log,
15
+ decodeFunctionData,
16
+ encodeAbiParameters,
17
+ parseEventLogs,
18
+ } from 'viem';
19
+ import { ERC20VariableCriteriaIncentive as ERC20VariableCriteriaIncentiveBases } from '../../dist/deployments.json';
20
+ import { SignatureType } from '../Actions/EventAction';
21
+ import type {
22
+ DeployableOptions,
23
+ GenericDeployableParams,
24
+ } from '../Deployable/Deployable';
25
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
26
+ import {
27
+ DecodedArgsError,
28
+ FieldActionValidationError,
29
+ IncentiveCriteriaNotFoundError,
30
+ InvalidCriteriaTypeError,
31
+ NoMatchingLogsError,
32
+ } from '../errors';
33
+ import type { ReadParams } from '../utils';
34
+ import { ERC20VariableIncentive } from './ERC20VariableIncentive';
35
+
36
+ export interface ERC20VariableCriteriaIncentivePayload {
37
+ /**
38
+ * The address of the incentivized asset.
39
+ *
40
+ * @type {Address}
41
+ */
42
+ asset: Address;
43
+ /**
44
+ * The amount of the asset to distribute as reward.
45
+ *
46
+ * @type {bigint}
47
+ */
48
+ reward: bigint;
49
+ /**
50
+ * The total spending limit of the asset that will be distributed.
51
+ *
52
+ * @type {bigint}
53
+ */
54
+ limit: bigint;
55
+ /**
56
+ * The criteria for the incentive that determines how the reward is distributed.
57
+ *
58
+ * @type {IncentiveCriteria}
59
+ */
60
+ criteria: IncentiveCriteria;
61
+ }
62
+
63
+ export interface IncentiveCriteria {
64
+ /**
65
+ * The type of criteria used, either function signature or event signature.
66
+ *
67
+ * @type {SignatureType}
68
+ */
69
+ criteriaType: SignatureType;
70
+ /**
71
+ * The function or event signature used for criteria matching.
72
+ *
73
+ * @type {Hex}
74
+ */
75
+ signature: Hex;
76
+ /**
77
+ * The index of the field from where the scalar value is extracted.
78
+ *
79
+ * @type {number}
80
+ */
81
+ fieldIndex: number;
82
+ /**
83
+ * The address of the contract where the event/function is called/emitted.
84
+ *
85
+ * @type {Address}
86
+ */
87
+ targetContract: Address;
88
+ }
89
+
90
+ export interface ReadIncentiveCriteriaParams
91
+ extends ReadParams<
92
+ typeof erc20VariableCriteriaIncentiveAbi,
93
+ 'getIncentiveCriteria'
94
+ > {}
95
+
96
+ export interface GetIncentiveScalarParams {
97
+ hash: Hex;
98
+ }
99
+
100
+ /**
101
+ * Extended ERC20 Variable Criteria Incentive class that fetches incentive criteria and scalar
102
+ */
103
+ export class ERC20VariableCriteriaIncentive extends DeployableTarget<
104
+ ERC20VariableCriteriaIncentivePayload,
105
+ typeof erc20VariableCriteriaIncentiveAbi
106
+ > {
107
+ public override readonly abi = erc20VariableCriteriaIncentiveAbi;
108
+ /**
109
+ * @inheritdoc
110
+ *
111
+ * @public
112
+ * @static
113
+ * @type {Record<number, Address>}
114
+ */
115
+ public static override bases: Record<number, Address> = {
116
+ ...(ERC20VariableCriteriaIncentiveBases as Record<number, Address>),
117
+ };
118
+
119
+ /**
120
+ *Functions from the ERC20VariableIncentive contract
121
+ */
122
+
123
+ /**
124
+ * Fetches the IncentiveCriteria struct from the contract
125
+ *
126
+ * @returns {Promise<IncentiveCriteria>} Incentive criteria structure
127
+ * @throws {IncentiveCriteriaNotFoundError}
128
+ */
129
+ public async getIncentiveCriteria(): Promise<IncentiveCriteria> {
130
+ try {
131
+ const criteria =
132
+ await readErc20VariableCriteriaIncentiveGetIncentiveCriteria(
133
+ this._config,
134
+ {
135
+ address: this.assertValidAddress(),
136
+ },
137
+ );
138
+
139
+ return criteria;
140
+ } catch (e) {
141
+ throw new IncentiveCriteriaNotFoundError(e as Error);
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Fetches the incentive scalar from a transaction hash
147
+ *
148
+ * @param {GetIncentiveScalarParams} params
149
+ * @returns {Promise<bigint>}
150
+ * @throws {InvalidCriteriaTypeError | NoMatchingLogsError | DecodedArgsError}
151
+ */
152
+ public async getIncentiveScalar({
153
+ hash,
154
+ }: GetIncentiveScalarParams): Promise<bigint> {
155
+ const criteria = await this.getIncentiveCriteria();
156
+ const transaction = await getTransaction(this._config, {
157
+ hash,
158
+ });
159
+ if (criteria.criteriaType === SignatureType.EVENT) {
160
+ const transactionReceipt = await getTransactionReceipt(this._config, {
161
+ hash,
162
+ });
163
+
164
+ const logs = transactionReceipt.logs;
165
+
166
+ if (logs.length === 0) {
167
+ throw new NoMatchingLogsError(
168
+ `No logs found for event signature ${criteria.signature}`,
169
+ );
170
+ }
171
+
172
+ // Decode the event log
173
+ try {
174
+ // Decode function data
175
+ const eventAbi = (events.abi as Record<Hex, AbiEvent>)[
176
+ criteria.signature
177
+ ] as AbiEvent;
178
+ const decodedEvents = parseEventLogs({
179
+ abi: [eventAbi],
180
+ logs,
181
+ });
182
+ if (decodedEvents == undefined || decodedEvents.length === 0) {
183
+ throw new NoMatchingLogsError(
184
+ `No logs found for event signature ${criteria.signature}`,
185
+ );
186
+ }
187
+ const scalarValue = (decodedEvents[0]?.args as string[])[
188
+ criteria.fieldIndex
189
+ ];
190
+
191
+ if (scalarValue === undefined) {
192
+ throw new DecodedArgsError(
193
+ `Decoded argument at index ${criteria.fieldIndex} is undefined`,
194
+ );
195
+ }
196
+ return BigInt(scalarValue);
197
+ } catch (e) {
198
+ throw new DecodedArgsError(
199
+ `Failed to decode event log for signature ${criteria.signature}: ${(e as Error).message}`,
200
+ );
201
+ }
202
+ } else if (criteria.criteriaType === SignatureType.FUNC) {
203
+ // Fetch the transaction data
204
+ try {
205
+ // Decode function data
206
+ const func = (functions.abi as Record<Hex, AbiFunction>)[
207
+ criteria.signature
208
+ ] as AbiFunction;
209
+
210
+ const decodedFunction = decodeFunctionData({
211
+ abi: [func],
212
+ data: transaction.input,
213
+ });
214
+ const scalarValue = decodedFunction.args[criteria.fieldIndex] as string;
215
+ if (scalarValue === undefined || scalarValue === null) {
216
+ throw new DecodedArgsError(
217
+ `Decoded argument at index ${criteria.fieldIndex} is undefined`,
218
+ );
219
+ }
220
+ return BigInt(scalarValue);
221
+ } catch (e) {
222
+ throw new DecodedArgsError(
223
+ `Failed to decode function data for signature ${criteria.signature}: ${(e as Error).message}`,
224
+ );
225
+ }
226
+ } else {
227
+ throw new InvalidCriteriaTypeError(
228
+ `Invalid criteria type ${criteria.criteriaType}`,
229
+ );
230
+ }
231
+ }
232
+ /**
233
+ * @inheritdoc
234
+ *
235
+ * @public
236
+ * @param {?ERC20VariableCriteriaIncentivePayload} [_payload]
237
+ * @param {?DeployableOptions} [_options]
238
+ * @returns {GenericDeployableParams}
239
+ */
240
+ public override buildParameters(
241
+ _payload?: ERC20VariableCriteriaIncentivePayload,
242
+ _options?: DeployableOptions,
243
+ ): GenericDeployableParams {
244
+ const [payload, options] = this.validateDeploymentConfig(
245
+ _payload,
246
+ _options,
247
+ );
248
+ return {
249
+ abi: erc20VariableCriteriaIncentiveAbi,
250
+ bytecode: bytecode as Hex,
251
+ args: [prepareERC20VariableCriteriaIncentivePayload(payload)],
252
+ ...this.optionallyAttachAccount(options.account),
253
+ };
254
+ }
255
+
256
+ /**
257
+ * Builds the claim data for the ERC20VariableCriteriaIncentive.
258
+ *
259
+ * @public
260
+ * @param {bigint} rewardAmount
261
+ * @returns {Hex} Returns the encoded claim data
262
+ * @description This function returns the encoded claim data for the ERC20VariableCriteriaIncentive.
263
+ */
264
+ public buildClaimData(rewardAmount: bigint) {
265
+ return encodeAbiParameters(
266
+ [{ type: 'uint256', name: 'rewardAmount' }],
267
+ [rewardAmount],
268
+ );
269
+ }
270
+ }
271
+
272
+ /**
273
+ *
274
+ *
275
+ * @param {InitPayloadExtended} param0
276
+ * @param {Address} param0.asset - The address of the ERC20 asset to incentivize.
277
+ * @param {bigint} param0.reward - The reward amount to distribute per action.
278
+ * @param {bigint} param0.limit - The total limit of the asset distribution.
279
+ * @param {IncentiveCriteria} param0.criteria - The incentive criteria for reward distribution.
280
+ * @returns {Hex}
281
+ */
282
+ export function prepareERC20VariableCriteriaIncentivePayload({
283
+ asset,
284
+ reward,
285
+ limit,
286
+ criteria,
287
+ }: ERC20VariableCriteriaIncentivePayload) {
288
+ return encodeAbiParameters(
289
+ [
290
+ {
291
+ type: 'tuple',
292
+ name: 'initPayloadExtended',
293
+ components: [
294
+ { type: 'address', name: 'asset' },
295
+ { type: 'uint256', name: 'reward' },
296
+ { type: 'uint256', name: 'limit' },
297
+ {
298
+ type: 'tuple',
299
+ name: 'criteria',
300
+ components: [
301
+ { type: 'uint8', name: 'criteriaType' },
302
+ { type: 'bytes32', name: 'signature' },
303
+ { type: 'uint8', name: 'fieldIndex' },
304
+ { type: 'address', name: 'targetContract' },
305
+ ],
306
+ },
307
+ ],
308
+ },
309
+ ],
310
+ [
311
+ {
312
+ asset: asset,
313
+ reward: reward,
314
+ limit: limit,
315
+ criteria: {
316
+ criteriaType: criteria.criteriaType,
317
+ signature: criteria.signature,
318
+ fieldIndex: criteria.fieldIndex,
319
+ targetContract: criteria.targetContract,
320
+ },
321
+ },
322
+ ],
323
+ );
324
+ }
@@ -1,21 +1,8 @@
1
- import {
2
- readMockErc20BalanceOf,
3
- readMockErc20TotalSupply,
4
- } from '@boostxyz/evm';
1
+ import { readMockErc20BalanceOf } from '@boostxyz/evm';
5
2
  import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
6
- import { signMessage } from '@wagmi/core';
7
- import {
8
- encodeAbiParameters,
9
- encodePacked,
10
- isAddress,
11
- keccak256,
12
- pad,
13
- parseEther,
14
- zeroAddress,
15
- } from 'viem';
16
- import { toHex } from 'viem';
3
+ import { encodeAbiParameters, isAddress, parseEther, zeroAddress } from 'viem';
17
4
  import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
18
- import { accounts } from '../../test/accounts';
5
+ import { accounts } from '@boostxyz/test/accounts';
19
6
  import {
20
7
  type BudgetFixtures,
21
8
  type Fixtures,
@@ -23,12 +10,7 @@ import {
23
10
  deployFixtures,
24
11
  freshBoost,
25
12
  fundBudget,
26
- } from '../../test/helpers';
27
- import {
28
- StrategyType,
29
- prepareClaimPayload,
30
- prepareSignerValidatorClaimDataPayload,
31
- } from '../utils';
13
+ } from '@boostxyz/test/helpers';
32
14
  import { ERC20VariableIncentive } from './ERC20VariableIncentive';
33
15
 
34
16
  const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
@@ -37,7 +19,7 @@ let fixtures: Fixtures, budgets: BudgetFixtures;
37
19
 
38
20
  describe('ERC20VariableIncentive', () => {
39
21
  beforeAll(async () => {
40
- fixtures = await loadFixture(deployFixtures);
22
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
41
23
  });
42
24
 
43
25
  beforeEach(async () => {
@@ -49,6 +31,7 @@ describe('ERC20VariableIncentive', () => {
49
31
  asset: zeroAddress,
50
32
  reward: 1n,
51
33
  limit: 1n,
34
+ manager: zeroAddress,
52
35
  });
53
36
  await action.deploy();
54
37
  expect(isAddress(action.assertValidAddress())).toBe(true);
@@ -65,6 +48,7 @@ describe('ERC20VariableIncentive', () => {
65
48
  asset: budgets.erc20.assertValidAddress(),
66
49
  reward: 1n,
67
50
  limit: 1n,
51
+ manager: zeroAddress,
68
52
  },
69
53
  );
70
54
  const boost = await freshBoost(fixtures, {
@@ -74,14 +58,10 @@ describe('ERC20VariableIncentive', () => {
74
58
 
75
59
  const claimant = trustedSigner.account;
76
60
  const incentiveQuantity = 1;
77
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
61
+ const claimDataPayload = await boost.validator.encodeClaimData({
78
62
  signer: trustedSigner,
79
- incentiveData: encodeAbiParameters(
80
- [{ name: '', type: 'uint256' }],
81
- [parseEther('1')],
82
- ),
63
+ incentiveData: erc20VariableIncentive.buildClaimData(parseEther('1')),
83
64
  chainId: defaultOptions.config.chains[0].id,
84
- validator: boost.validator.assertValidAddress(),
85
65
  incentiveQuantity,
86
66
  claimant,
87
67
  boostId: boost.id,
@@ -112,6 +92,7 @@ describe('ERC20VariableIncentive', () => {
112
92
  asset: budgets.erc20.assertValidAddress(),
113
93
  reward: 1n,
114
94
  limit: 1n,
95
+ manager: zeroAddress,
115
96
  },
116
97
  );
117
98
  const boost = await freshBoost(fixtures, {
@@ -121,14 +102,10 @@ describe('ERC20VariableIncentive', () => {
121
102
 
122
103
  const claimant = trustedSigner.account;
123
104
  const incentiveQuantity = 1;
124
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
105
+ const claimDataPayload = await boost.validator.encodeClaimData({
125
106
  signer: trustedSigner,
126
- incentiveData: encodeAbiParameters(
127
- [{ name: '', type: 'uint256' }],
128
- [parseEther('1')],
129
- ),
107
+ incentiveData: erc20VariableIncentive.buildClaimData(parseEther('1')),
130
108
  chainId: defaultOptions.config.chains[0].id,
131
- validator: boost.validator.assertValidAddress(),
132
109
  incentiveQuantity,
133
110
  claimant,
134
111
  boostId: boost.id,