@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
@@ -18,7 +18,14 @@ import {
18
18
  writeErc20IncentiveDrawRaffle,
19
19
  } from '@boostxyz/evm';
20
20
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20Incentive.sol/ERC20Incentive.json';
21
- import type { Address, ContractEventName, Hex } from 'viem';
21
+ import {
22
+ type Address,
23
+ type ContractEventName,
24
+ type Hex,
25
+ encodeAbiParameters,
26
+ zeroHash,
27
+ } from 'viem';
28
+ import { ERC20Incentive as ERC20IncentiveBases } from '../../dist/deployments.json';
22
29
  import type {
23
30
  DeployableOptions,
24
31
  GenericDeployableParams,
@@ -26,18 +33,57 @@ import type {
26
33
  import { DeployableTarget } from '../Deployable/DeployableTarget';
27
34
  import {
28
35
  type ClaimPayload,
29
- type ERC20IncentivePayload,
36
+ type StrategyType,
37
+ prepareClaimPayload,
38
+ } from '../claiming';
39
+ import {
30
40
  type GenericLog,
31
41
  type ReadParams,
32
42
  RegistryType,
33
- type StrategyType,
34
43
  type WriteParams,
35
- prepareClaimPayload,
36
- prepareERC20IncentivePayload,
37
44
  } from '../utils';
38
45
 
39
46
  export { erc20IncentiveAbi };
40
- export type { ERC20IncentivePayload };
47
+
48
+ /**
49
+ * The object representation of a `ERC20Incentive.InitPayload`
50
+ *
51
+ * @export
52
+ * @interface ERC20IncentivePayload
53
+ * @typedef {ERC20IncentivePayload}
54
+ */
55
+ export interface ERC20IncentivePayload {
56
+ /**
57
+ * The address of the incentivized asset.
58
+ *
59
+ * @type {Address}
60
+ */
61
+ asset: Address;
62
+ /**
63
+ * The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
64
+ *
65
+ * @type {StrategyType}
66
+ */
67
+ strategy: StrategyType;
68
+ /**
69
+ * The amount of the asset to distribute.
70
+ *
71
+ * @type {bigint}
72
+ */
73
+ reward: bigint;
74
+ /**
75
+ * How many times can this incentive be claimed.
76
+ *
77
+ * @type {bigint}
78
+ */
79
+ limit: bigint;
80
+ /**
81
+ * The entity that can `clawback` funds
82
+ *
83
+ * @type {Address}
84
+ */
85
+ manager: Address;
86
+ }
41
87
 
42
88
  /**
43
89
  * A generic `viem.Log` event with support for `ERC20Incentive` event types.
@@ -72,10 +118,11 @@ export class ERC20Incentive extends DeployableTarget<
72
118
  *
73
119
  * @public
74
120
  * @static
75
- * @type {Address}
121
+ * @type {Record<number, Address>}
76
122
  */
77
- public static override base: Address = import.meta.env
78
- .VITE_ERC20_INCENTIVE_BASE;
123
+ public static override bases: Record<number, Address> = {
124
+ ...(ERC20IncentiveBases as Record<number, Address>),
125
+ };
79
126
  /**
80
127
  * @inheritdoc
81
128
  *
@@ -90,11 +137,11 @@ export class ERC20Incentive extends DeployableTarget<
90
137
  *
91
138
  * @public
92
139
  * @async
93
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'owner'>} [params]
94
- * @returns {unknown}
140
+ * @param {?ReadParams} [params]
141
+ * @returns {Promise<Address>}
95
142
  */
96
143
  public async owner(params?: ReadParams<typeof erc20IncentiveAbi, 'owner'>) {
97
- return readErc20IncentiveOwner(this._config, {
144
+ return await readErc20IncentiveOwner(this._config, {
98
145
  address: this.assertValidAddress(),
99
146
  args: [],
100
147
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -107,13 +154,13 @@ export class ERC20Incentive extends DeployableTarget<
107
154
  *
108
155
  * @public
109
156
  * @async
110
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'currentReward'>} [params]
157
+ * @param {?ReadParams} [params]
111
158
  * @returns {Promise<bigint>} - The current reward
112
159
  */
113
160
  public async currentReward(
114
161
  params?: ReadParams<typeof erc20IncentiveAbi, 'currentReward'>,
115
162
  ) {
116
- return readErc20IncentiveCurrentReward(this._config, {
163
+ return await readErc20IncentiveCurrentReward(this._config, {
117
164
  address: this.assertValidAddress(),
118
165
  args: [],
119
166
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -126,11 +173,11 @@ export class ERC20Incentive extends DeployableTarget<
126
173
  *
127
174
  * @public
128
175
  * @async
129
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'claims'>} [params]
176
+ * @param {?ReadParams} [params]
130
177
  * @returns {Promise<bigint>}
131
178
  */
132
179
  public async claims(params?: ReadParams<typeof erc20IncentiveAbi, 'claims'>) {
133
- return readErc20IncentiveClaims(this._config, {
180
+ return await readErc20IncentiveClaims(this._config, {
134
181
  address: this.assertValidAddress(),
135
182
  args: [],
136
183
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -144,14 +191,14 @@ export class ERC20Incentive extends DeployableTarget<
144
191
  * @public
145
192
  * @async
146
193
  * @param {Address} address
147
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'claimed'>} [params]
194
+ * @param {?ReadParams} [params]
148
195
  * @returns {Promise<boolean>}
149
196
  */
150
197
  public async claimed(
151
198
  address: Address,
152
199
  params?: ReadParams<typeof erc20IncentiveAbi, 'claimed'>,
153
200
  ) {
154
- return readErc20IncentiveClaimed(this._config, {
201
+ return await readErc20IncentiveClaimed(this._config, {
155
202
  address: this.assertValidAddress(),
156
203
  args: [address],
157
204
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -164,11 +211,11 @@ export class ERC20Incentive extends DeployableTarget<
164
211
  *
165
212
  * @public
166
213
  * @async
167
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'asset'>} [params]
214
+ * @param {?ReadParams} [params]
168
215
  * @returns {Promise<Address>}
169
216
  */
170
217
  public async asset(params?: ReadParams<typeof erc20IncentiveAbi, 'asset'>) {
171
- return readErc20IncentiveAsset(this._config, {
218
+ return await readErc20IncentiveAsset(this._config, {
172
219
  address: this.assertValidAddress(),
173
220
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
174
221
  ...(params as any),
@@ -180,10 +227,10 @@ export class ERC20Incentive extends DeployableTarget<
180
227
  *
181
228
  * @public
182
229
  * @async
183
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'strategy'>} [params]
230
+ * @param {?ReadParams} [params]
184
231
  * @returns {Promise<StrategyType>}
185
232
  */
186
- public async strategy(
233
+ public strategy(
187
234
  params?: ReadParams<typeof erc20IncentiveAbi, 'strategy'>,
188
235
  ): Promise<StrategyType> {
189
236
  return readErc20IncentiveStrategy(this._config, {
@@ -198,11 +245,11 @@ export class ERC20Incentive extends DeployableTarget<
198
245
  *
199
246
  * @public
200
247
  * @async
201
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'reward'>} [params]
248
+ * @param {?ReadParams} [params]
202
249
  * @returns {Promise<bigint>}
203
250
  */
204
251
  public async reward(params?: ReadParams<typeof erc20IncentiveAbi, 'reward'>) {
205
- return readErc20IncentiveReward(this._config, {
252
+ return await readErc20IncentiveReward(this._config, {
206
253
  address: this.assertValidAddress(),
207
254
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
208
255
  ...(params as any),
@@ -214,11 +261,11 @@ export class ERC20Incentive extends DeployableTarget<
214
261
  *
215
262
  * @public
216
263
  * @async
217
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'limit'>} [params]
218
- * @returns {unknown}
264
+ * @param {?ReadParams} [params]
265
+ * @returns {Promise<bigint>}
219
266
  */
220
267
  public async limit(params?: ReadParams<typeof erc20IncentiveAbi, 'limit'>) {
221
- return readErc20IncentiveLimit(this._config, {
268
+ return await readErc20IncentiveLimit(this._config, {
222
269
  address: this.assertValidAddress(),
223
270
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
224
271
  ...(params as any),
@@ -231,14 +278,14 @@ export class ERC20Incentive extends DeployableTarget<
231
278
  * @public
232
279
  * @async
233
280
  * @param {bigint} i - Index of address
234
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'entries'>} [params]
281
+ * @param {?ReadParams} [params]
235
282
  * @returns {Promise<Address>}
236
283
  */
237
284
  public async entries(
238
285
  i: bigint,
239
286
  params?: ReadParams<typeof erc20IncentiveAbi, 'entries'>,
240
287
  ) {
241
- return readErc20IncentiveEntries(this._config, {
288
+ return await readErc20IncentiveEntries(this._config, {
242
289
  address: this.assertValidAddress(),
243
290
  args: [i],
244
291
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -252,14 +299,14 @@ export class ERC20Incentive extends DeployableTarget<
252
299
  * @public
253
300
  * @async
254
301
  * @param {ClaimPayload} payload
255
- * @param {?WriteParams<typeof erc20IncentiveAbi, 'claim'>} [params]
302
+ * @param {?WriteParams} [params]
256
303
  * @returns {Promise<boolean>} - Returns true if successfully claimed
257
304
  */
258
- public async claim(
305
+ protected async claim(
259
306
  payload: ClaimPayload,
260
307
  params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
261
308
  ) {
262
- return this.awaitResult(this.claimRaw(payload, params));
309
+ return await this.awaitResult(this.claimRaw(payload, params));
263
310
  }
264
311
 
265
312
  /**
@@ -268,10 +315,10 @@ export class ERC20Incentive extends DeployableTarget<
268
315
  * @public
269
316
  * @async
270
317
  * @param {ClaimPayload} payload
271
- * @param {?WriteParams<typeof erc20IncentiveAbi, 'claim'>} [params]
272
- * @returns {Promise<boolean>} - Returns true if successfully claimed
318
+ * @param {?WriteParams} [params]
319
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns true if successfully claimed
273
320
  */
274
- public async claimRaw(
321
+ protected async claimRaw(
275
322
  payload: ClaimPayload,
276
323
  params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
277
324
  ) {
@@ -295,14 +342,14 @@ export class ERC20Incentive extends DeployableTarget<
295
342
  * @public
296
343
  * @async
297
344
  * @param {ClaimPayload} payload
298
- * @param {?WriteParams<typeof erc20IncentiveAbi, 'clawback'>} [params]
345
+ * @param {?WriteParams} [params]
299
346
  * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
300
347
  */
301
348
  public async clawback(
302
349
  payload: ClaimPayload,
303
350
  params?: WriteParams<typeof erc20IncentiveAbi, 'clawback'>,
304
351
  ) {
305
- return this.awaitResult(this.clawbackRaw(payload, params));
352
+ return await this.awaitResult(this.clawbackRaw(payload, params));
306
353
  }
307
354
 
308
355
  /**
@@ -311,8 +358,8 @@ export class ERC20Incentive extends DeployableTarget<
311
358
  * @public
312
359
  * @async
313
360
  * @param {ClaimPayload} payload
314
- * @param {?WriteParams<typeof erc20IncentiveAbi, 'clawback'>} [params]
315
- * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
361
+ * @param {?WriteParams} [params]
362
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the assets were successfully clawbacked
316
363
  */
317
364
  public async clawbackRaw(
318
365
  payload: ClaimPayload,
@@ -338,14 +385,14 @@ export class ERC20Incentive extends DeployableTarget<
338
385
  * @public
339
386
  * @async
340
387
  * @param {ClaimPayload} payload
341
- * @param {?ReadParams<typeof erc20IncentiveAbi, 'isClaimable'>} [params]
342
- * @returns {unknown} = True if the incentive is claimable based on the data payload
388
+ * @param {?ReadParams} [params]
389
+ * @returns {Promise<boolean>} = True if the incentive is claimable based on the data payload
343
390
  */
344
391
  public async isClaimable(
345
392
  payload: ClaimPayload,
346
393
  params?: ReadParams<typeof erc20IncentiveAbi, 'isClaimable'>,
347
394
  ) {
348
- return readErc20IncentiveIsClaimable(this._config, {
395
+ return await readErc20IncentiveIsClaimable(this._config, {
349
396
  address: this.assertValidAddress(),
350
397
  args: [prepareClaimPayload(payload)],
351
398
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -358,13 +405,13 @@ export class ERC20Incentive extends DeployableTarget<
358
405
  *
359
406
  * @public
360
407
  * @async
361
- * @param {?WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>} [params]
408
+ * @param {?WriteParams} [params]
362
409
  * @returns {Promise<void>}
363
410
  */
364
411
  public async drawRaffle(
365
412
  params?: WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>,
366
413
  ) {
367
- return this.awaitResult(this.drawRaffleRaw(params));
414
+ return await this.awaitResult(this.drawRaffleRaw(params));
368
415
  }
369
416
 
370
417
  /**
@@ -372,8 +419,8 @@ export class ERC20Incentive extends DeployableTarget<
372
419
  *
373
420
  * @public
374
421
  * @async
375
- * @param {?WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>} [params]
376
- * @returns {Promise<void>}
422
+ * @param {?WriteParams} [params]
423
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
377
424
  */
378
425
  public async drawRaffleRaw(
379
426
  params?: WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>,
@@ -414,4 +461,42 @@ export class ERC20Incentive extends DeployableTarget<
414
461
  ...this.optionallyAttachAccount(options.account),
415
462
  };
416
463
  }
464
+
465
+ /**
466
+ * Builds the claim data for the ERC20Incentive.
467
+ *
468
+ * @public
469
+ * @returns {Hash} A `zeroHash`, as ERC20Incentive doesn't require specific claim data.
470
+ * @description This function returns `zeroHash` because ERC20Incentive doesn't use any specific claim data.
471
+ */
472
+ public buildClaimData() {
473
+ return zeroHash;
474
+ }
475
+ }
476
+
477
+ /**
478
+ * Given a {@link ERC20IncentivePayload}, properly encode a `ERC20Incentive.InitPayload` for use with {@link ERC20Incentive} initialization.
479
+ *
480
+ * @param {ERC20IncentivePayload} param0
481
+ * @param {Address} param0.asset - The address of the incentivized asset.
482
+ * @param {StrategyType} param0.strategy - The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
483
+ * @param {bigint} param0.reward - The amount of the asset to distribute.
484
+ * @param {bigint} param0.limit - How many times can this incentive be claimed.
485
+ * @returns {Hex}
486
+ */
487
+ export function prepareERC20IncentivePayload({
488
+ asset,
489
+ strategy,
490
+ reward,
491
+ limit,
492
+ }: ERC20IncentivePayload) {
493
+ return encodeAbiParameters(
494
+ [
495
+ { type: 'address', name: 'asset' },
496
+ { type: 'uint8', name: 'strategy' },
497
+ { type: 'uint256', name: 'reward' },
498
+ { type: 'uint256', name: 'limit' },
499
+ ],
500
+ [asset, strategy, reward, limit],
501
+ );
417
502
  }
@@ -0,0 +1,184 @@
1
+ import { Mock } from 'node:test';
2
+ import { selectors as eventSelectors } from '@boostxyz/signatures/events';
3
+ import { selectors as funcSelectors } from '@boostxyz/signatures/functions';
4
+ import type { MockERC20 } from '@boostxyz/test/MockERC20';
5
+ import type { MockERC721 } from '@boostxyz/test/MockERC721';
6
+ import { accounts } from '@boostxyz/test/accounts';
7
+ import {
8
+ type BudgetFixtures,
9
+ type Fixtures,
10
+ defaultOptions,
11
+ deployFixtures,
12
+ freshBoost,
13
+ fundBudget,
14
+ fundErc20,
15
+ fundErc721,
16
+ } from '@boostxyz/test/helpers';
17
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
18
+ import { type Hex, isAddress, parseEther } from 'viem';
19
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
20
+ import { SignatureType } from '../Actions/EventAction';
21
+ import type { Boost } from '../Boost';
22
+ import type {
23
+ ERC20VariableCriteriaIncentive,
24
+ ERC20VariableCriteriaIncentivePayload,
25
+ IncentiveCriteria,
26
+ } from './ERC20VariableCriteriaIncentive';
27
+
28
+ /**
29
+ * A basic ERC721 mint scalar criteria for testing
30
+ *
31
+ * @param {MockERC721} erc721 - The ERC721 contract
32
+ * @returns {IncentiveCriteria} - Returns a basic incentive criteria
33
+ */
34
+ export function basicErc721TransferScalarCriteria(
35
+ erc721: MockERC721,
36
+ ): IncentiveCriteria {
37
+ return {
38
+ criteriaType: SignatureType.FUNC,
39
+ signature: funcSelectors['transferFrom(address,address,uint256)'] as Hex, // Function selector for mint
40
+ fieldIndex: 2, // Field where the scalar value resides
41
+ targetContract: erc721.assertValidAddress(),
42
+ };
43
+ }
44
+
45
+ /**
46
+ * A basic ERC721 mint scalar criteria for testing
47
+ *
48
+ * @param {MockERC721} erc721 - The ERC721 contract
49
+ * @returns {IncentiveCriteria} - Returns a basic incentive criteria
50
+ */
51
+ export function basicErc721MintScalarCriteria(
52
+ erc721: MockERC721,
53
+ ): IncentiveCriteria {
54
+ return {
55
+ criteriaType: SignatureType.EVENT,
56
+ signature: eventSelectors[
57
+ 'Transfer(address indexed,address indexed,uint256 indexed)'
58
+ ] as Hex, // Function selector for mint
59
+ fieldIndex: 2, // Field where the scalar value resides
60
+ targetContract: erc721.assertValidAddress(),
61
+ };
62
+ }
63
+
64
+ /**
65
+ * A basic ERC721 mint scalar payload for testing
66
+ *
67
+ * @param {MockERC721} erc721 - The ERC721 contract
68
+ * @returns {ERC20VariableCriteriaIncentivePayload} - Returns a full variable criteria incentive payload
69
+ */
70
+ export function basicErc721TransferScalarPayload(
71
+ erc721: MockERC721,
72
+ ): ERC20VariableCriteriaIncentivePayload {
73
+ return {
74
+ asset: erc721.assertValidAddress(),
75
+ reward: 1n,
76
+ limit: 1n,
77
+ criteria: basicErc721TransferScalarCriteria(erc721),
78
+ };
79
+ }
80
+
81
+ let fixtures: Fixtures,
82
+ erc20: MockERC20,
83
+ erc721: MockERC721,
84
+ erc20Incentive: ERC20VariableCriteriaIncentive,
85
+ budgets: BudgetFixtures,
86
+ boost: Boost;
87
+
88
+ describe('ERC20VariableCriteriaIncentive', () => {
89
+ beforeAll(async () => {
90
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
91
+ });
92
+
93
+ beforeEach(async () => {
94
+ budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
95
+ erc20 = await loadFixture(fundErc20(defaultOptions));
96
+ erc721 = await loadFixture(fundErc721(defaultOptions));
97
+ erc20Incentive = fixtures.core.ERC20VariableCriteriaIncentive({
98
+ asset: budgets.erc20.assertValidAddress(),
99
+ reward: 1n,
100
+ limit: 1n,
101
+ criteria: basicErc721TransferScalarCriteria(erc721),
102
+ });
103
+
104
+ boost = await freshBoost(fixtures, {
105
+ budget: budgets.budget,
106
+ incentives: [erc20Incentive],
107
+ });
108
+ expect(isAddress(boost.incentives[0]!.assertValidAddress())).toBe(true);
109
+ });
110
+
111
+ describe('getIncentiveCriteria', () => {
112
+ test('should fetch incentive criteria successfully', async () => {
113
+ const incentive = boost.incentives[0] as ERC20VariableCriteriaIncentive;
114
+ const criteria = await incentive.getIncentiveCriteria();
115
+ expect(criteria).toMatchObject({
116
+ criteriaType: SignatureType.FUNC,
117
+ signature: expect.any(String),
118
+ fieldIndex: expect.any(Number),
119
+ targetContract: expect.any(String),
120
+ });
121
+ });
122
+ });
123
+
124
+ describe('getIncentiveScalar', () => {
125
+ test('should return a valid scalar for function-based criteria', async () => {
126
+ const recipient = accounts[1].account;
127
+
128
+ const { hash } = await erc721.transferFromRaw(
129
+ accounts[0].account,
130
+ recipient,
131
+ 1n,
132
+ );
133
+ const scalar = await erc20Incentive.getIncentiveScalar({ hash });
134
+
135
+ expect(scalar).toBe(1n);
136
+ });
137
+
138
+ test('should return a valid scalar for event-based criteria', async () => {
139
+ erc20Incentive = fixtures.core.ERC20VariableCriteriaIncentive({
140
+ asset: budgets.erc20.assertValidAddress(),
141
+ reward: 1n,
142
+ limit: 1n,
143
+ criteria: basicErc721MintScalarCriteria(erc721),
144
+ });
145
+
146
+ boost = await freshBoost(fixtures, {
147
+ budget: budgets.budget,
148
+ incentives: [erc20Incentive],
149
+ });
150
+ const recipient = accounts[1].account;
151
+ const { hash } = await erc721.transferFromRaw(
152
+ accounts[0].account,
153
+ recipient,
154
+ 1n,
155
+ );
156
+ const scalar = await erc20Incentive.getIncentiveScalar({ hash });
157
+
158
+ expect(scalar).toBe(1n);
159
+ });
160
+
161
+ test('should throw NoMatchingLogsError for event criteria with no matching logs', async () => {
162
+ const recipient = accounts[1].account;
163
+
164
+ const { hash } = await erc20.mintRaw(recipient, parseEther('100'));
165
+
166
+ try {
167
+ await erc20Incentive.getIncentiveScalar({ hash });
168
+ } catch (e) {
169
+ expect((e as Error).name).toBe('DecodedArgsError');
170
+ }
171
+ });
172
+
173
+ test('should throw DecodedArgsError for invalid function-based data', async () => {
174
+ const recipient = accounts[1].account;
175
+ const { hash } = await erc20.mintRaw(recipient, parseEther('100'));
176
+
177
+ try {
178
+ await erc20Incentive.getIncentiveScalar({ hash });
179
+ } catch (e) {
180
+ expect((e as Error).name).toBe('DecodedArgsError');
181
+ }
182
+ });
183
+ });
184
+ });