@boostxyz/sdk 0.0.0-alpha.16 → 0.0.0-alpha.18

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 (223) 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 +9 -9
  5. package/dist/Actions/ContractAction.d.ts.map +1 -1
  6. package/dist/Actions/ERC721MintAction.d.ts +12 -12
  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 +32 -49
  11. package/dist/Actions/EventAction.d.ts.map +1 -1
  12. package/dist/Actions/EventAction.js +13 -779
  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.js +3 -3
  17. package/dist/AllowLists/OpenAllowList.d.ts +183 -0
  18. package/dist/AllowLists/OpenAllowList.d.ts.map +1 -1
  19. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  20. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  21. package/dist/AllowLists/SimpleAllowList.d.ts +82 -36
  22. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  23. package/dist/AllowLists/SimpleAllowList.js +44 -80
  24. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  25. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  26. package/dist/AllowLists/SimpleDenyList.d.ts +192 -9
  27. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  28. package/dist/AllowLists/SimpleDenyList.js +5 -5
  29. package/dist/Auth/PassthroughAuth.cjs +1 -1
  30. package/dist/Auth/PassthroughAuth.js +1 -1
  31. package/dist/Boost.cjs.map +1 -1
  32. package/dist/Boost.d.ts +18 -0
  33. package/dist/Boost.d.ts.map +1 -1
  34. package/dist/Boost.js.map +1 -1
  35. package/dist/BoostCore-BiPwp6SR.cjs +3 -0
  36. package/dist/BoostCore-BiPwp6SR.cjs.map +1 -0
  37. package/dist/BoostCore-C00iqvks.js +1477 -0
  38. package/dist/BoostCore-C00iqvks.js.map +1 -0
  39. package/dist/BoostCore.cjs +1 -2
  40. package/dist/BoostCore.cjs.map +1 -1
  41. package/dist/BoostCore.d.ts +80 -35
  42. package/dist/BoostCore.d.ts.map +1 -1
  43. package/dist/BoostCore.js +29 -1273
  44. package/dist/BoostCore.js.map +1 -1
  45. package/dist/BoostRegistry.cjs +1 -1
  46. package/dist/BoostRegistry.cjs.map +1 -1
  47. package/dist/BoostRegistry.d.ts +18 -18
  48. package/dist/BoostRegistry.js +36 -36
  49. package/dist/BoostRegistry.js.map +1 -1
  50. package/dist/Budgets/Budget.cjs +1 -1
  51. package/dist/Budgets/Budget.cjs.map +1 -1
  52. package/dist/Budgets/Budget.d.ts.map +1 -1
  53. package/dist/Budgets/Budget.js +2 -2
  54. package/dist/Budgets/Budget.js.map +1 -1
  55. package/dist/Budgets/ManagedBudget.cjs +1 -1
  56. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  57. package/dist/Budgets/ManagedBudget.d.ts +24 -174
  58. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  59. package/dist/Budgets/ManagedBudget.js +76 -298
  60. package/dist/Budgets/ManagedBudget.js.map +1 -1
  61. package/dist/Budgets/VestingBudget.d.ts +181 -77
  62. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  63. package/dist/Deployable/Contract.cjs +1 -1
  64. package/dist/Deployable/Contract.cjs.map +1 -1
  65. package/dist/Deployable/Contract.d.ts +4 -5
  66. package/dist/Deployable/Contract.d.ts.map +1 -1
  67. package/dist/Deployable/Contract.js +4 -5
  68. package/dist/Deployable/Contract.js.map +1 -1
  69. package/dist/Deployable/Deployable.cjs.map +1 -1
  70. package/dist/Deployable/Deployable.d.ts +1 -1
  71. package/dist/Deployable/Deployable.js +1 -1
  72. package/dist/Deployable/Deployable.js.map +1 -1
  73. package/dist/Deployable/DeployableTarget.cjs +1 -1
  74. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  75. package/dist/Deployable/DeployableTarget.d.ts +5 -5
  76. package/dist/Deployable/DeployableTarget.js +10 -10
  77. package/dist/Deployable/DeployableTarget.js.map +1 -1
  78. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  79. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  80. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
  81. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  82. package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
  83. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  84. package/dist/EventAction-BO5WI_5s.js +1355 -0
  85. package/dist/EventAction-BO5WI_5s.js.map +1 -0
  86. package/dist/EventAction-DBDRaG4A.cjs +2 -0
  87. package/dist/EventAction-DBDRaG4A.cjs.map +1 -0
  88. package/dist/{Incentive-CtuAJAjG.js → Incentive-CF7kaz_9.js} +67 -68
  89. package/dist/Incentive-CF7kaz_9.js.map +1 -0
  90. package/dist/{Incentive-CqX3fYEd.cjs → Incentive-Djnzseoj.cjs} +2 -2
  91. package/dist/Incentive-Djnzseoj.cjs.map +1 -0
  92. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  93. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  94. package/dist/Incentives/AllowListIncentive.d.ts +12 -12
  95. package/dist/Incentives/AllowListIncentive.js +26 -26
  96. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  97. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  98. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  99. package/dist/Incentives/CGDAIncentive.d.ts +15 -15
  100. package/dist/Incentives/CGDAIncentive.js +25 -25
  101. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  102. package/dist/Incentives/ERC1155Incentive.d.ts +30 -30
  103. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  104. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  105. package/dist/Incentives/ERC20Incentive.d.ts +23 -23
  106. package/dist/Incentives/ERC20Incentive.js +45 -45
  107. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  108. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +523 -0
  109. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  110. package/dist/Incentives/ERC20VariableIncentive.d.ts +19 -19
  111. package/dist/Incentives/Incentive.cjs +1 -1
  112. package/dist/Incentives/Incentive.d.ts +3 -3
  113. package/dist/Incentives/Incentive.d.ts.map +1 -1
  114. package/dist/Incentives/Incentive.js +3 -3
  115. package/dist/Incentives/PointsIncentive.cjs +1 -1
  116. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  117. package/dist/Incentives/PointsIncentive.d.ts +14 -14
  118. package/dist/Incentives/PointsIncentive.js +20 -20
  119. package/dist/Incentives/PointsIncentive.js.map +1 -1
  120. package/dist/SimpleDenyList-BwfNjRsg.cjs +2 -0
  121. package/dist/SimpleDenyList-BwfNjRsg.cjs.map +1 -0
  122. package/dist/SimpleDenyList-D9i4rw_F.js +132 -0
  123. package/dist/SimpleDenyList-D9i4rw_F.js.map +1 -0
  124. package/dist/Validators/SignerValidator.cjs +1 -1
  125. package/dist/Validators/SignerValidator.cjs.map +1 -1
  126. package/dist/Validators/SignerValidator.d.ts +14 -14
  127. package/dist/Validators/SignerValidator.js +25 -25
  128. package/dist/Validators/SignerValidator.js.map +1 -1
  129. package/dist/Validators/Validator.cjs +1 -1
  130. package/dist/Validators/Validator.cjs.map +1 -1
  131. package/dist/Validators/Validator.d.ts +1 -1
  132. package/dist/Validators/Validator.js +6 -6
  133. package/dist/Validators/Validator.js.map +1 -1
  134. package/dist/claiming.cjs.map +1 -1
  135. package/dist/claiming.d.ts +1 -1
  136. package/dist/claiming.js.map +1 -1
  137. package/dist/componentInterfaces-D09mhzxO.cjs +2 -0
  138. package/dist/componentInterfaces-D09mhzxO.cjs.map +1 -0
  139. package/dist/componentInterfaces-RXBMI5yH.js +14 -0
  140. package/dist/componentInterfaces-RXBMI5yH.js.map +1 -0
  141. package/dist/deployments-BM42vImE.js +43 -0
  142. package/dist/deployments-BM42vImE.js.map +1 -0
  143. package/dist/deployments-CMdF5uEC.cjs +2 -0
  144. package/dist/deployments-CMdF5uEC.cjs.map +1 -0
  145. package/dist/deployments.json +15 -12
  146. package/dist/errors.cjs +1 -1
  147. package/dist/errors.cjs.map +1 -1
  148. package/dist/errors.d.ts +132 -0
  149. package/dist/errors.d.ts.map +1 -1
  150. package/dist/errors.js +122 -36
  151. package/dist/errors.js.map +1 -1
  152. package/dist/generated-B0tk-c9b.cjs +3 -0
  153. package/dist/generated-B0tk-c9b.cjs.map +1 -0
  154. package/dist/{generated-DLMdMwD1.js → generated-B8VWObPa.js} +2350 -1290
  155. package/dist/generated-B8VWObPa.js.map +1 -0
  156. package/dist/index.cjs +1 -1
  157. package/dist/index.d.ts +2 -0
  158. package/dist/index.d.ts.map +1 -1
  159. package/dist/index.js +134 -122
  160. package/dist/index.js.map +1 -1
  161. package/dist/transfers.cjs.map +1 -1
  162. package/dist/transfers.d.ts +1 -1
  163. package/dist/transfers.js.map +1 -1
  164. package/dist/utils.cjs.map +1 -1
  165. package/dist/utils.d.ts +1 -1
  166. package/dist/utils.js.map +1 -1
  167. package/package.json +12 -5
  168. package/src/Actions/ContractAction.ts +9 -10
  169. package/src/Actions/ERC721MintAction.ts +12 -13
  170. package/src/Actions/EventAction.test.ts +182 -53
  171. package/src/Actions/EventAction.ts +128 -107
  172. package/src/AllowLists/SimpleAllowList.ts +14 -59
  173. package/src/AllowLists/SimpleDenyList.ts +12 -9
  174. package/src/Boost.ts +19 -0
  175. package/src/BoostCore.test.ts +117 -1
  176. package/src/BoostCore.ts +113 -54
  177. package/src/BoostRegistry.ts +18 -18
  178. package/src/Budgets/Budget.ts +1 -2
  179. package/src/Budgets/ManagedBudget.ts +21 -295
  180. package/src/Budgets/VestingBudget.ts +26 -97
  181. package/src/Deployable/Contract.ts +4 -5
  182. package/src/Deployable/Deployable.ts +1 -1
  183. package/src/Deployable/DeployableTarget.ts +5 -5
  184. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  185. package/src/Incentives/AllowListIncentive.ts +12 -12
  186. package/src/Incentives/CGDAIncentive.ts +15 -15
  187. package/src/Incentives/ERC1155Incentive.ts +26 -26
  188. package/src/Incentives/ERC20Incentive.ts +23 -23
  189. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  190. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
  191. package/src/Incentives/ERC20VariableIncentive.ts +19 -19
  192. package/src/Incentives/Incentive.ts +6 -5
  193. package/src/Incentives/PointsIncentive.test.ts +21 -21
  194. package/src/Incentives/PointsIncentive.ts +14 -14
  195. package/src/Validators/SignerValidator.ts +14 -14
  196. package/src/Validators/Validator.ts +1 -1
  197. package/src/claiming.ts +1 -1
  198. package/src/errors.ts +165 -0
  199. package/src/index.test.ts +3 -4
  200. package/src/index.ts +2 -0
  201. package/src/transfers.ts +1 -1
  202. package/src/utils.ts +1 -1
  203. package/dist/Budgets/SimpleBudget.d.ts +0 -824
  204. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  205. package/dist/Incentive-CqX3fYEd.cjs.map +0 -1
  206. package/dist/Incentive-CtuAJAjG.js.map +0 -1
  207. package/dist/SimpleDenyList-9UIxZZKP.cjs +0 -2
  208. package/dist/SimpleDenyList-9UIxZZKP.cjs.map +0 -1
  209. package/dist/SimpleDenyList-DGPNc7ov.js +0 -132
  210. package/dist/SimpleDenyList-DGPNc7ov.js.map +0 -1
  211. package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
  212. package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
  213. package/dist/componentInterfaces-Cmg8tUxq.js +0 -13
  214. package/dist/componentInterfaces-Cmg8tUxq.js.map +0 -1
  215. package/dist/deployments-BvFcK_eR.js +0 -40
  216. package/dist/deployments-BvFcK_eR.js.map +0 -1
  217. package/dist/deployments-Ho4PnGCS.cjs +0 -2
  218. package/dist/deployments-Ho4PnGCS.cjs.map +0 -1
  219. package/dist/generated-BLg7yPgI.cjs +0 -3
  220. package/dist/generated-BLg7yPgI.cjs.map +0 -1
  221. package/dist/generated-DLMdMwD1.js.map +0 -1
  222. package/src/Budgets/SimpleBudget.test.ts +0 -152
  223. package/src/Budgets/SimpleBudget.ts +0 -563
@@ -0,0 +1,309 @@
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
+ /**
258
+ *
259
+ *
260
+ * @param {InitPayloadExtended} param0
261
+ * @param {Address} param0.asset - The address of the ERC20 asset to incentivize.
262
+ * @param {bigint} param0.reward - The reward amount to distribute per action.
263
+ * @param {bigint} param0.limit - The total limit of the asset distribution.
264
+ * @param {IncentiveCriteria} param0.criteria - The incentive criteria for reward distribution.
265
+ * @returns {Hex}
266
+ */
267
+ export function prepareERC20VariableCriteriaIncentivePayload({
268
+ asset,
269
+ reward,
270
+ limit,
271
+ criteria,
272
+ }: ERC20VariableCriteriaIncentivePayload) {
273
+ return encodeAbiParameters(
274
+ [
275
+ {
276
+ type: 'tuple',
277
+ name: 'initPayloadExtended',
278
+ components: [
279
+ { type: 'address', name: 'asset' },
280
+ { type: 'uint256', name: 'reward' },
281
+ { type: 'uint256', name: 'limit' },
282
+ {
283
+ type: 'tuple',
284
+ name: 'criteria',
285
+ components: [
286
+ { type: 'uint8', name: 'criteriaType' },
287
+ { type: 'bytes32', name: 'signature' },
288
+ { type: 'uint8', name: 'fieldIndex' },
289
+ { type: 'address', name: 'targetContract' },
290
+ ],
291
+ },
292
+ ],
293
+ },
294
+ ],
295
+ [
296
+ {
297
+ asset: asset,
298
+ reward: reward,
299
+ limit: limit,
300
+ criteria: {
301
+ criteriaType: criteria.criteriaType,
302
+ signature: criteria.signature,
303
+ fieldIndex: criteria.fieldIndex,
304
+ targetContract: criteria.targetContract,
305
+ },
306
+ },
307
+ ],
308
+ );
309
+ }
@@ -116,8 +116,8 @@ export class ERC20VariableIncentive extends DeployableTarget<
116
116
  *
117
117
  * @public
118
118
  * @async
119
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'owner'>} [params]
120
- * @returns {unknown}
119
+ * @param {?ReadParams} [params]
120
+ * @returns {Promise<Address>}
121
121
  */
122
122
  public async owner(
123
123
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'owner'>,
@@ -135,7 +135,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
135
135
  *
136
136
  * @public
137
137
  * @async
138
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'totalClaimed'>} [params]
138
+ * @param {?ReadParams} [params]
139
139
  * @returns {Promise<bigint>}
140
140
  */
141
141
  public async totalClaimed(
@@ -154,7 +154,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
154
154
  *
155
155
  * @public
156
156
  * @async
157
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'currentReward'>} [params]
157
+ * @param {?ReadParams} [params]
158
158
  * @returns {Promise<bigint>} - The current reward
159
159
  */
160
160
  public async currentReward(
@@ -173,7 +173,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
173
173
  *
174
174
  * @public
175
175
  * @async
176
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'claims'>} [params]
176
+ * @param {?ReadParams} [params]
177
177
  * @returns {Promise<bigint>}
178
178
  */
179
179
  public async claims(
@@ -193,7 +193,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
193
193
  * @public
194
194
  * @async
195
195
  * @param {Address} address
196
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'claimed'>} [params]
196
+ * @param {?ReadParams} [params]
197
197
  * @returns {Promise<boolean>}
198
198
  */
199
199
  public async claimed(
@@ -213,7 +213,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
213
213
  *
214
214
  * @public
215
215
  * @async
216
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'asset'>} [params]
216
+ * @param {?ReadParams} [params]
217
217
  * @returns {Promise<Address>}
218
218
  */
219
219
  public async asset(
@@ -231,7 +231,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
231
231
  *
232
232
  * @public
233
233
  * @async
234
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'reward'>} [params]
234
+ * @param {?ReadParams} [params]
235
235
  * @returns {Promise<bigint>}
236
236
  */
237
237
  public async reward(
@@ -249,8 +249,8 @@ export class ERC20VariableIncentive extends DeployableTarget<
249
249
  *
250
250
  * @public
251
251
  * @async
252
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'limit'>} [params]
253
- * @returns {unknown}
252
+ * @param {?ReadParams} [params]
253
+ * @returns {Promise<bigint>}
254
254
  */
255
255
  public async limit(
256
256
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'limit'>,
@@ -268,7 +268,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
268
268
  * @public
269
269
  * @async
270
270
  * @param {ClaimPayload} payload
271
- * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
271
+ * @param {?WriteParams} [params]
272
272
  * @returns {Promise<boolean>} - Returns true if successfully claimed
273
273
  */
274
274
  protected async claim(
@@ -284,8 +284,8 @@ export class ERC20VariableIncentive extends DeployableTarget<
284
284
  * @public
285
285
  * @async
286
286
  * @param {ClaimPayload} payload
287
- * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
288
- * @returns {Promise<boolean>} - Returns true if successfully claimed
287
+ * @param {?WriteParams} [params]
288
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns true if successfully claimed
289
289
  */
290
290
  protected async claimRaw(
291
291
  payload: ClaimPayload,
@@ -311,7 +311,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
311
311
  * @public
312
312
  * @async
313
313
  * @param {ClaimPayload} payload
314
- * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>} [params]
314
+ * @param {?WriteParams} [params]
315
315
  * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
316
316
  */
317
317
  public async clawback(
@@ -327,8 +327,8 @@ export class ERC20VariableIncentive extends DeployableTarget<
327
327
  * @public
328
328
  * @async
329
329
  * @param {ClaimPayload} payload
330
- * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>} [params]
331
- * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
330
+ * @param {?WriteParams} [params]
331
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the assets were successfully clawbacked
332
332
  */
333
333
  public async clawbackRaw(
334
334
  payload: ClaimPayload,
@@ -357,8 +357,8 @@ export class ERC20VariableIncentive extends DeployableTarget<
357
357
  * @public
358
358
  * @async
359
359
  * @param {ClaimPayload} payload
360
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'isClaimable'>} [params]
361
- * @returns {unknown} = True if the incentive is claimable based on the data payload
360
+ * @param {?ReadParams} [params]
361
+ * @returns {Promise<boolean>} = True if the incentive is claimable based on the data payload
362
362
  */
363
363
  public async isClaimable(
364
364
  payload: ClaimPayload,
@@ -404,7 +404,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
404
404
  * @param {Address} param0.asset - The address of the incentivized asset.
405
405
  * @param {bigint} param0.reward - The amount of the asset to distribute.
406
406
  * @param {bigint} param0.limit - How many times can this incentive be claimed.
407
- * @returns {*}
407
+ * @returns {Hex}
408
408
  */
409
409
  export function prepareERC20VariableIncentivePayload({
410
410
  asset,
@@ -13,6 +13,7 @@ import { InvalidComponentInterfaceError } from '../errors';
13
13
  import { AllowListIncentive } from './AllowListIncentive';
14
14
  import { CGDAIncentive } from './CGDAIncentive';
15
15
  import { ERC20Incentive } from './ERC20Incentive';
16
+ import type { ERC20VariableCriteriaIncentive } from './ERC20VariableCriteriaIncentive';
16
17
  import { ERC20VariableIncentive } from './ERC20VariableIncentive';
17
18
  // import { ERC1155Incentive } from './ERC1155Incentive';
18
19
  import { PointsIncentive } from './PointsIncentive';
@@ -38,7 +39,8 @@ export type Incentive =
38
39
  | ERC20Incentive
39
40
  // | ERC1155Incentive
40
41
  | PointsIncentive
41
- | ERC20VariableIncentive;
42
+ | ERC20VariableIncentive
43
+ | ERC20VariableCriteriaIncentive;
42
44
 
43
45
  /**
44
46
  * A map of Incentive component interfaces to their constructors.
@@ -48,9 +50,8 @@ export type Incentive =
48
50
  export const IncentiveByComponentInterface = {
49
51
  [APointsIncentive as Hex]: PointsIncentive,
50
52
  [AERC20Incentive as Hex]: ERC20Incentive,
51
- // TODO: figure out why evm generates bad bytes4 here
52
- ['0x0a466e6f']: AllowListIncentive,
53
- // [APointsIncentive as Hex]: ERC1155Incentive,
53
+ [AAllowListIncentive]: AllowListIncentive,
54
+ // [AERC1155Incentive as Hex]: ERC1155Incentive,
54
55
  [ACGDAIncentive as Hex]: CGDAIncentive,
55
56
  [AERC20VariableIncentive as Hex]: ERC20VariableIncentive,
56
57
  };
@@ -62,7 +63,7 @@ export const IncentiveByComponentInterface = {
62
63
  * @async
63
64
  * @param {DeployableOptions} options
64
65
  * @param {Address} address
65
- * @returns {unknown}
66
+ * @returns {Incentive}
66
67
  * @throws {@link InvalidComponentInterfaceError}
67
68
  */
68
69
  export async function incentiveFromAddress(
@@ -1,22 +1,22 @@
1
- import { readPointsBalanceOf, writePointsGrantRoles } from '@boostxyz/evm';
2
- import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
- import { isAddress, pad, parseEther, zeroAddress } from 'viem';
4
- import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
5
- import type { MockPoints } from '@boostxyz/test/MockPoints';
6
- import { accounts } from '@boostxyz/test/accounts';
1
+ import { readPointsBalanceOf, writePointsGrantRoles } from "@boostxyz/evm";
2
+ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
3
+ import { isAddress, pad, parseEther, zeroAddress } from "viem";
4
+ import { beforeAll, beforeEach, describe, expect, test } from "vitest";
5
+ import type { MockPoints } from "@boostxyz/test/MockPoints";
6
+ import { accounts } from "@boostxyz/test/accounts";
7
7
  import {
8
8
  type Fixtures,
9
9
  defaultOptions,
10
10
  deployFixtures,
11
11
  freshBoost,
12
12
  freshPoints,
13
- } from '@boostxyz/test/helpers';
14
- import { bytes4 } from '../utils';
15
- import { PointsIncentive } from './PointsIncentive';
13
+ } from "@boostxyz/test/helpers";
14
+ import { bytes4 } from "../utils";
15
+ import { PointsIncentive } from "./PointsIncentive";
16
16
 
17
17
  let fixtures: Fixtures, points: MockPoints;
18
18
 
19
- describe('PointsIncentive', () => {
19
+ describe("PointsIncentive", () => {
20
20
  beforeAll(async () => {
21
21
  fixtures = await loadFixture(deployFixtures(defaultOptions));
22
22
  });
@@ -25,10 +25,10 @@ describe('PointsIncentive', () => {
25
25
  points = await loadFixture(freshPoints);
26
26
  });
27
27
 
28
- test('can successfully be deployed', async () => {
28
+ test("can successfully be deployed", async () => {
29
29
  const action = new PointsIncentive(defaultOptions, {
30
30
  venue: zeroAddress,
31
- selector: '0xdeadb33f',
31
+ selector: "0xdeadb33f",
32
32
  reward: 1n,
33
33
  limit: 1n,
34
34
  });
@@ -36,14 +36,14 @@ describe('PointsIncentive', () => {
36
36
  expect(isAddress(action.assertValidAddress())).toBe(true);
37
37
  });
38
38
 
39
- test('can claim', async () => {
39
+ test("can claim", async () => {
40
40
  // biome-ignore lint/style/noNonNullAssertion: we know this is defined
41
41
  const referrer = accounts.at(1)!.account!;
42
42
  // biome-ignore lint/style/noNonNullAssertion: we know this is defined
43
43
  const trustedSigner = accounts.at(0)!;
44
44
  const pointsIncentive = fixtures.core.PointsIncentive({
45
45
  venue: points.assertValidAddress(),
46
- selector: bytes4('issue(address,uint256)'),
46
+ selector: bytes4("issue(address,uint256)"),
47
47
  reward: 1n,
48
48
  limit: 10n,
49
49
  });
@@ -52,7 +52,7 @@ describe('PointsIncentive', () => {
52
52
  });
53
53
 
54
54
  const claimant = trustedSigner.account;
55
- const incentiveData = pad('0xdef456232173821931823712381232131391321934');
55
+ const incentiveData = pad("0xdef456232173821931823712381232131391321934");
56
56
  const incentiveQuantity = 1;
57
57
  const claimDataPayload = await boost.validator.encodeClaimData({
58
58
  signer: trustedSigner,
@@ -73,7 +73,7 @@ describe('PointsIncentive', () => {
73
73
  0n,
74
74
  referrer,
75
75
  claimDataPayload,
76
- { value: parseEther('0.000075') },
76
+ { value: parseEther("0.000075") },
77
77
  );
78
78
  expect(
79
79
  await readPointsBalanceOf(defaultOptions.config, {
@@ -83,7 +83,7 @@ describe('PointsIncentive', () => {
83
83
  ).toBe(1n);
84
84
  });
85
85
 
86
- test('cannot claim twice', async () => {
86
+ test("cannot claim twice", async () => {
87
87
  const reward = 1n;
88
88
  // biome-ignore lint/style/noNonNullAssertion: we know this is defined
89
89
  const referrer = accounts.at(1)!.account!;
@@ -92,7 +92,7 @@ describe('PointsIncentive', () => {
92
92
 
93
93
  const pointsIncentive = fixtures.core.PointsIncentive({
94
94
  venue: points.assertValidAddress(),
95
- selector: bytes4('issue(address,uint256)'),
95
+ selector: bytes4("issue(address,uint256)"),
96
96
  reward,
97
97
  limit: 10n,
98
98
  });
@@ -101,7 +101,7 @@ describe('PointsIncentive', () => {
101
101
  });
102
102
 
103
103
  const claimant = trustedSigner.account;
104
- const incentiveData = pad('0xdef456232173821931823712381232131391321934');
104
+ const incentiveData = pad("0xdef456232173821931823712381232131391321934");
105
105
  const incentiveQuantity = 1;
106
106
  const claimDataPayload = await boost.validator.encodeClaimData({
107
107
  signer: trustedSigner,
@@ -122,7 +122,7 @@ describe('PointsIncentive', () => {
122
122
  0n,
123
123
  referrer,
124
124
  claimDataPayload,
125
- { value: parseEther('0.000075') },
125
+ { value: parseEther("0.000075") },
126
126
  );
127
127
  try {
128
128
  await fixtures.core.claimIncentive(
@@ -130,7 +130,7 @@ describe('PointsIncentive', () => {
130
130
  0n,
131
131
  referrer,
132
132
  claimDataPayload,
133
- { value: parseEther('0.000075') },
133
+ { value: parseEther("0.000075") },
134
134
  );
135
135
  } catch (e) {
136
136
  expect(e).toBeInstanceOf(Error);
@@ -125,7 +125,7 @@ export class PointsIncentive extends DeployableTarget<
125
125
  *
126
126
  * @public
127
127
  * @async
128
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'claims'>} [params]
128
+ * @param {?ReadParams} [params]
129
129
  * @returns {Promise<bigint>}
130
130
  */
131
131
  public async claims(
@@ -144,7 +144,7 @@ export class PointsIncentive extends DeployableTarget<
144
144
  *
145
145
  * @public
146
146
  * @async
147
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'currentReward'>} [params]
147
+ * @param {?ReadParams} [params]
148
148
  * @returns {Promise<bigint>} - The current reward
149
149
  */
150
150
  public async currentReward(
@@ -163,8 +163,8 @@ export class PointsIncentive extends DeployableTarget<
163
163
  *
164
164
  * @public
165
165
  * @async
166
- * @param {?ReadParams<typeof pointsIncentiveAbi, 'reward'>} [params]
167
- * @returns {unknown}
166
+ * @param {?ReadParams} [params]
167
+ * @returns {Promise<bigint>} The reward amount issued for each claim
168
168
  */
169
169
  public async reward(
170
170
  params?: ReadParams<typeof pointsIncentiveAbi, 'reward'>,
@@ -183,8 +183,8 @@ export class PointsIncentive extends DeployableTarget<
183
183
  * @public
184
184
  * @async
185
185
  * @param {Address} address
186
- * @param {?ReadParams<typeof pointsIncentiveAbi, 'claimed'>} [params]
187
- * @returns {unknown}
186
+ * @param {?ReadParams} [params]
187
+ * @returns {Promise<boolean>}
188
188
  */
189
189
  public async claimed(
190
190
  address: Address,
@@ -203,8 +203,8 @@ export class PointsIncentive extends DeployableTarget<
203
203
  *
204
204
  * @public
205
205
  * @async
206
- * @param {?ReadParams<typeof pointsIncentiveAbi, 'venue'>} [params]
207
- * @returns {unknown}
206
+ * @param {?ReadParams} [params]
207
+ * @returns {Promise<Address>}
208
208
  */
209
209
  public async venue(params?: ReadParams<typeof pointsIncentiveAbi, 'venue'>) {
210
210
  return await readPointsIncentiveVenue(this._config, {
@@ -219,7 +219,7 @@ export class PointsIncentive extends DeployableTarget<
219
219
  *
220
220
  * @public
221
221
  * @async
222
- * @param {?ReadParams<typeof pointsIncentiveAbi, 'limit'>} [params]
222
+ * @param {?ReadParams} [params]
223
223
  * @returns {Promise<bigint>}
224
224
  */
225
225
  public async limit(params?: ReadParams<typeof pointsIncentiveAbi, 'limit'>) {
@@ -235,7 +235,7 @@ export class PointsIncentive extends DeployableTarget<
235
235
  *
236
236
  * @public
237
237
  * @async
238
- * @param {?ReadParams<typeof pointsIncentiveAbi, 'selector'>} [params]
238
+ * @param {?ReadParams} [params]
239
239
  * @returns {Promise<Hex>}
240
240
  */
241
241
  public async selector(
@@ -254,7 +254,7 @@ export class PointsIncentive extends DeployableTarget<
254
254
  * @public
255
255
  * @async
256
256
  * @param {ClaimPayload} payload
257
- * @param {?WriteParams<typeof pointsIncentiveAbi, 'claim'>} [params]
257
+ * @param {?WriteParams} [params]
258
258
  * @returns {Promise<boolean>} - True if the incentive was successfully claimed
259
259
  */
260
260
  protected async claim(
@@ -270,8 +270,8 @@ export class PointsIncentive extends DeployableTarget<
270
270
  * @public
271
271
  * @async
272
272
  * @param {ClaimPayload} payload
273
- * @param {?WriteParams<typeof pointsIncentiveAbi, 'claim'>} [params]
274
- * @returns {Promise<boolean>} - True if the incentive was successfully claimed
273
+ * @param {?WriteParams} [params]
274
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the incentive was successfully claimed
275
275
  */
276
276
  protected async claimRaw(
277
277
  payload: ClaimPayload,
@@ -299,7 +299,7 @@ export class PointsIncentive extends DeployableTarget<
299
299
  * @public
300
300
  * @async
301
301
  * @param {ClaimPayload} payload
302
- * @param {?ReadParams<typeof pointsIncentiveAbi, 'isClaimable'>} [params]
302
+ * @param {?ReadParams} [params]
303
303
  * @returns {Promise<boolean>} - True if the incentive is claimable based on the data payload
304
304
  */
305
305
  public async isClaimable(