@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
@@ -15,25 +15,60 @@ import {
15
15
  writeErc20VariableIncentiveClawback,
16
16
  } from '@boostxyz/evm';
17
17
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableIncentive.sol/ERC20VariableIncentive.json';
18
- import type { Address, ContractEventName, Hex } from 'viem';
18
+ import {
19
+ type Address,
20
+ type ContractEventName,
21
+ type Hex,
22
+ encodeAbiParameters,
23
+ } from 'viem';
24
+ import { ERC20VariableIncentive as ERC20VariableIncentiveBases } from '../../dist/deployments.json';
19
25
  import type {
20
26
  DeployableOptions,
21
27
  GenericDeployableParams,
22
28
  } from '../Deployable/Deployable';
23
29
  import { DeployableTarget } from '../Deployable/DeployableTarget';
30
+ import { type ClaimPayload, prepareClaimPayload } from '../claiming';
24
31
  import {
25
- type ClaimPayload,
26
- type ERC20VariableIncentivePayload,
27
32
  type GenericLog,
28
33
  type ReadParams,
29
34
  RegistryType,
30
35
  type WriteParams,
31
- prepareClaimPayload,
32
- prepareERC20VariableIncentivePayload,
33
36
  } from '../utils';
34
37
 
35
38
  export { erc20VariableIncentiveAbi };
36
- export type { ERC20VariableIncentivePayload };
39
+ /**
40
+ * The object representation of a `ERC20VariableIncentivePayload.InitPayload`
41
+ *
42
+ * @export
43
+ * @interface ERC20VariableIncentivePayload
44
+ * @typedef {ERC20VariableIncentivePayload}
45
+ */
46
+ export interface ERC20VariableIncentivePayload {
47
+ /**
48
+ * The address of the incentivized asset.
49
+ *
50
+ * @type {Address}
51
+ */
52
+ asset: Address;
53
+ /**
54
+ * The amount of the asset to distribute.
55
+ *
56
+ * @type {bigint}
57
+ */
58
+ reward: bigint;
59
+ /**
60
+ * The total spending limit of the asset that will be distributed.
61
+ *
62
+ * @type {bigint}
63
+ */
64
+ limit: bigint;
65
+ /**
66
+ * The entity that can `clawback` funds
67
+ *
68
+ * @type {Address}
69
+ */
70
+ manager: Address;
71
+ }
37
72
 
38
73
  /**
39
74
  * A generic `viem.Log` event with support for `ERC20VariableIncentive` event types.
@@ -51,7 +86,7 @@ export type ERC20VariableIncentiveLog<
51
86
  > = GenericLog<typeof erc20VariableIncentiveAbi, event>;
52
87
 
53
88
  /**
54
- * A simple ERC20 incentive implementation that allows claiming of tokens
89
+ * A modified ERC20 incentive implementation that allows claiming of variable token amounts with a spending limit
55
90
  *
56
91
  * @export
57
92
  * @class ERC20VariableIncentive
@@ -68,10 +103,11 @@ export class ERC20VariableIncentive extends DeployableTarget<
68
103
  *
69
104
  * @public
70
105
  * @static
71
- * @type {Address}
106
+ * @type {Record<number, Address>}
72
107
  */
73
- public static override base: Address = import.meta.env
74
- .VITE_ERC20_VARIABLE_INCENTIVE_BASE;
108
+ public static override bases: Record<number, Address> = {
109
+ ...(ERC20VariableIncentiveBases as Record<number, Address>),
110
+ };
75
111
  /**
76
112
  * @inheritdoc
77
113
  *
@@ -86,13 +122,13 @@ export class ERC20VariableIncentive extends DeployableTarget<
86
122
  *
87
123
  * @public
88
124
  * @async
89
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'owner'>} [params]
90
- * @returns {unknown}
125
+ * @param {?ReadParams} [params]
126
+ * @returns {Promise<Address>}
91
127
  */
92
128
  public async owner(
93
129
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'owner'>,
94
130
  ) {
95
- return readErc20VariableIncentiveOwner(this._config, {
131
+ return await readErc20VariableIncentiveOwner(this._config, {
96
132
  address: this.assertValidAddress(),
97
133
  args: [],
98
134
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -101,17 +137,17 @@ export class ERC20VariableIncentive extends DeployableTarget<
101
137
  }
102
138
 
103
139
  /**
104
- * The current reward
140
+ * The total amount of rewards claimed
105
141
  *
106
142
  * @public
107
143
  * @async
108
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'currentReward'>} [params]
109
- * @returns {Promise<bigint>} - The current reward
144
+ * @param {?ReadParams} [params]
145
+ * @returns {Promise<bigint>}
110
146
  */
111
147
  public async totalClaimed(
112
148
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'totalClaimed'>,
113
149
  ) {
114
- return readErc20VariableIncentiveTotalClaimed(this._config, {
150
+ return await readErc20VariableIncentiveTotalClaimed(this._config, {
115
151
  address: this.assertValidAddress(),
116
152
  args: [],
117
153
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -124,13 +160,13 @@ export class ERC20VariableIncentive extends DeployableTarget<
124
160
  *
125
161
  * @public
126
162
  * @async
127
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'currentReward'>} [params]
163
+ * @param {?ReadParams} [params]
128
164
  * @returns {Promise<bigint>} - The current reward
129
165
  */
130
166
  public async currentReward(
131
167
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'currentReward'>,
132
168
  ) {
133
- return readErc20VariableIncentiveCurrentReward(this._config, {
169
+ return await readErc20VariableIncentiveCurrentReward(this._config, {
134
170
  address: this.assertValidAddress(),
135
171
  args: [],
136
172
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -143,13 +179,13 @@ export class ERC20VariableIncentive extends DeployableTarget<
143
179
  *
144
180
  * @public
145
181
  * @async
146
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'claims'>} [params]
182
+ * @param {?ReadParams} [params]
147
183
  * @returns {Promise<bigint>}
148
184
  */
149
185
  public async claims(
150
186
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claims'>,
151
187
  ) {
152
- return readErc20VariableIncentiveClaims(this._config, {
188
+ return await readErc20VariableIncentiveClaims(this._config, {
153
189
  address: this.assertValidAddress(),
154
190
  args: [],
155
191
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -163,14 +199,14 @@ export class ERC20VariableIncentive extends DeployableTarget<
163
199
  * @public
164
200
  * @async
165
201
  * @param {Address} address
166
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'claimed'>} [params]
202
+ * @param {?ReadParams} [params]
167
203
  * @returns {Promise<boolean>}
168
204
  */
169
205
  public async claimed(
170
206
  address: Address,
171
207
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claimed'>,
172
208
  ) {
173
- return readErc20VariableIncentiveClaimed(this._config, {
209
+ return await readErc20VariableIncentiveClaimed(this._config, {
174
210
  address: this.assertValidAddress(),
175
211
  args: [address],
176
212
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -183,13 +219,13 @@ export class ERC20VariableIncentive extends DeployableTarget<
183
219
  *
184
220
  * @public
185
221
  * @async
186
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'asset'>} [params]
222
+ * @param {?ReadParams} [params]
187
223
  * @returns {Promise<Address>}
188
224
  */
189
225
  public async asset(
190
226
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'asset'>,
191
227
  ) {
192
- return readErc20VariableIncentiveAsset(this._config, {
228
+ return await readErc20VariableIncentiveAsset(this._config, {
193
229
  address: this.assertValidAddress(),
194
230
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
195
231
  ...(params as any),
@@ -201,13 +237,13 @@ export class ERC20VariableIncentive extends DeployableTarget<
201
237
  *
202
238
  * @public
203
239
  * @async
204
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'reward'>} [params]
240
+ * @param {?ReadParams} [params]
205
241
  * @returns {Promise<bigint>}
206
242
  */
207
243
  public async reward(
208
244
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'reward'>,
209
245
  ) {
210
- return readErc20VariableIncentiveReward(this._config, {
246
+ return await readErc20VariableIncentiveReward(this._config, {
211
247
  address: this.assertValidAddress(),
212
248
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
213
249
  ...(params as any),
@@ -219,13 +255,13 @@ export class ERC20VariableIncentive extends DeployableTarget<
219
255
  *
220
256
  * @public
221
257
  * @async
222
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'limit'>} [params]
223
- * @returns {unknown}
258
+ * @param {?ReadParams} [params]
259
+ * @returns {Promise<bigint>}
224
260
  */
225
261
  public async limit(
226
262
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'limit'>,
227
263
  ) {
228
- return readErc20VariableIncentiveLimit(this._config, {
264
+ return await readErc20VariableIncentiveLimit(this._config, {
229
265
  address: this.assertValidAddress(),
230
266
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
231
267
  ...(params as any),
@@ -238,14 +274,14 @@ export class ERC20VariableIncentive extends DeployableTarget<
238
274
  * @public
239
275
  * @async
240
276
  * @param {ClaimPayload} payload
241
- * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
277
+ * @param {?WriteParams} [params]
242
278
  * @returns {Promise<boolean>} - Returns true if successfully claimed
243
279
  */
244
- public async claim(
280
+ protected async claim(
245
281
  payload: ClaimPayload,
246
282
  params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
247
283
  ) {
248
- return this.awaitResult(this.claimRaw(payload, params));
284
+ return await this.awaitResult(this.claimRaw(payload, params));
249
285
  }
250
286
 
251
287
  /**
@@ -254,10 +290,10 @@ export class ERC20VariableIncentive extends DeployableTarget<
254
290
  * @public
255
291
  * @async
256
292
  * @param {ClaimPayload} payload
257
- * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
258
- * @returns {Promise<boolean>} - Returns true if successfully claimed
293
+ * @param {?WriteParams} [params]
294
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns true if successfully claimed
259
295
  */
260
- public async claimRaw(
296
+ protected async claimRaw(
261
297
  payload: ClaimPayload,
262
298
  params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
263
299
  ) {
@@ -281,14 +317,14 @@ export class ERC20VariableIncentive extends DeployableTarget<
281
317
  * @public
282
318
  * @async
283
319
  * @param {ClaimPayload} payload
284
- * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>} [params]
320
+ * @param {?WriteParams} [params]
285
321
  * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
286
322
  */
287
323
  public async clawback(
288
324
  payload: ClaimPayload,
289
325
  params?: WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>,
290
326
  ) {
291
- return this.awaitResult(this.clawbackRaw(payload, params));
327
+ return await this.awaitResult(this.clawbackRaw(payload, params));
292
328
  }
293
329
 
294
330
  /**
@@ -297,8 +333,8 @@ export class ERC20VariableIncentive extends DeployableTarget<
297
333
  * @public
298
334
  * @async
299
335
  * @param {ClaimPayload} payload
300
- * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>} [params]
301
- * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
336
+ * @param {?WriteParams} [params]
337
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the assets were successfully clawbacked
302
338
  */
303
339
  public async clawbackRaw(
304
340
  payload: ClaimPayload,
@@ -327,14 +363,14 @@ export class ERC20VariableIncentive extends DeployableTarget<
327
363
  * @public
328
364
  * @async
329
365
  * @param {ClaimPayload} payload
330
- * @param {?ReadParams<typeof erc20VariableIncentiveAbi, 'isClaimable'>} [params]
331
- * @returns {unknown} = True if the incentive is claimable based on the data payload
366
+ * @param {?ReadParams} [params]
367
+ * @returns {Promise<boolean>} = True if the incentive is claimable based on the data payload
332
368
  */
333
369
  public async isClaimable(
334
370
  payload: ClaimPayload,
335
371
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'isClaimable'>,
336
372
  ) {
337
- return readErc20VariableIncentiveIsClaimable(this._config, {
373
+ return await readErc20VariableIncentiveIsClaimable(this._config, {
338
374
  address: this.assertValidAddress(),
339
375
  args: [prepareClaimPayload(payload)],
340
376
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -342,6 +378,21 @@ export class ERC20VariableIncentive extends DeployableTarget<
342
378
  });
343
379
  }
344
380
 
381
+ /**
382
+ * Builds the claim data for the ERC20VariableIncentive.
383
+ *
384
+ * @public
385
+ * @param {bigint} rewardAmount
386
+ * @returns {Hex} Returns the encoded claim data
387
+ * @description This function returns the encoded claim data for the ERC20VariableIncentive.
388
+ */
389
+ public buildClaimData(rewardAmount: bigint) {
390
+ return encodeAbiParameters(
391
+ [{ type: 'uint256', name: 'rewardAmount' }],
392
+ [rewardAmount],
393
+ );
394
+ }
395
+
345
396
  /**
346
397
  * @inheritdoc
347
398
  *
@@ -366,3 +417,27 @@ export class ERC20VariableIncentive extends DeployableTarget<
366
417
  };
367
418
  }
368
419
  }
420
+
421
+ /**
422
+ * Given a {@link ERC20VariableIncentivePayload}, properly encode a ` ERC20VariableIncentive.InitPayload` for use with {@link ERC20VariableIncentive} initialization.
423
+ *
424
+ * @param {ERC20VariableIncentivePayload} param0
425
+ * @param {Address} param0.asset - The address of the incentivized asset.
426
+ * @param {bigint} param0.reward - The amount of the asset to distribute.
427
+ * @param {bigint} param0.limit - How many times can this incentive be claimed.
428
+ * @returns {Hex}
429
+ */
430
+ export function prepareERC20VariableIncentivePayload({
431
+ asset,
432
+ reward,
433
+ limit,
434
+ }: ERC20VariableIncentivePayload) {
435
+ return encodeAbiParameters(
436
+ [
437
+ { type: 'address', name: 'asset' },
438
+ { type: 'uint256', name: 'reward' },
439
+ { type: 'uint256', name: 'limit' },
440
+ ],
441
+ [asset, reward, limit],
442
+ );
443
+ }
@@ -1,7 +1,7 @@
1
1
  import { zeroAddress } from 'viem';
2
2
  import { describe, expect, test } from 'vitest';
3
- import { defaultOptions } from '../../test/helpers';
4
- import { StrategyType } from '../utils';
3
+ import { defaultOptions } from '@boostxyz/test/helpers';
4
+ import { StrategyType } from '../claiming';
5
5
  import {
6
6
  AllowListIncentive,
7
7
  CGDAIncentive,
@@ -49,6 +49,7 @@ describe('Incentive', () => {
49
49
  totalBudget: 10n,
50
50
  rewardBoost: 1n,
51
51
  rewardDecay: 1n,
52
+ manager: zeroAddress,
52
53
  });
53
54
  await incentive.deploy();
54
55
  expect(
@@ -65,6 +66,7 @@ describe('Incentive', () => {
65
66
  strategy: StrategyType.POOL,
66
67
  reward: 1n,
67
68
  limit: 10n,
69
+ manager: zeroAddress,
68
70
  });
69
71
  await incentive.deploy();
70
72
  expect(
@@ -80,6 +82,7 @@ describe('Incentive', () => {
80
82
  asset: zeroAddress,
81
83
  reward: 1n,
82
84
  limit: 10n,
85
+ manager: zeroAddress,
83
86
  });
84
87
  await incentive.deploy();
85
88
  expect(
@@ -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,19 +39,19 @@ 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.
45
47
  *
46
- * @type {{ "0xc5b24b8e": typeof PointsIncentive; "0x8c901437": typeof ERC20Incentive; "0x0a466e6f": typeof AllowListIncentive; "0xa39e44d9": typeof CGDAIncentive; "0x6060409d": typeof ERC20VariableIncentive }}
48
+ * @type {{ "0xc5b24b8e": typeof PointsIncentive; "0x8c901437": typeof ERC20Incentive; "0x4414fbb4": typeof AllowListIncentive; "0xa39e44d9": typeof CGDAIncentive; "0xa8e4af1e": typeof ERC20VariableIncentive }}
47
49
  */
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,35 +1,34 @@
1
- import { readPointsBalanceOf, writePointsGrantRoles } from '@boostxyz/evm';
2
- import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
- import { signMessage } from '@wagmi/core';
4
- import { isAddress, pad, parseEther, zeroAddress } from 'viem';
5
- import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
6
- import type { MockPoints } from '../../test/MockPoints';
7
- import { accounts } from '../../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";
8
7
  import {
9
8
  type Fixtures,
10
9
  defaultOptions,
11
10
  deployFixtures,
12
11
  freshBoost,
13
12
  freshPoints,
14
- } from '../../test/helpers';
15
- import { bytes4, prepareSignerValidatorClaimDataPayload } from '../utils';
16
- import { PointsIncentive } from './PointsIncentive';
13
+ } from "@boostxyz/test/helpers";
14
+ import { bytes4 } from "../utils";
15
+ import { PointsIncentive } from "./PointsIncentive";
17
16
 
18
17
  let fixtures: Fixtures, points: MockPoints;
19
18
 
20
- describe('PointsIncentive', () => {
19
+ describe("PointsIncentive", () => {
21
20
  beforeAll(async () => {
22
- fixtures = await loadFixture(deployFixtures);
21
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
23
22
  });
24
23
 
25
24
  beforeEach(async () => {
26
25
  points = await loadFixture(freshPoints);
27
26
  });
28
27
 
29
- test('can successfully be deployed', async () => {
28
+ test("can successfully be deployed", async () => {
30
29
  const action = new PointsIncentive(defaultOptions, {
31
30
  venue: zeroAddress,
32
- selector: '0xdeadb33f',
31
+ selector: "0xdeadb33f",
33
32
  reward: 1n,
34
33
  limit: 1n,
35
34
  });
@@ -37,14 +36,14 @@ describe('PointsIncentive', () => {
37
36
  expect(isAddress(action.assertValidAddress())).toBe(true);
38
37
  });
39
38
 
40
- test('can claim', async () => {
39
+ test("can claim", async () => {
41
40
  // biome-ignore lint/style/noNonNullAssertion: we know this is defined
42
41
  const referrer = accounts.at(1)!.account!;
43
42
  // biome-ignore lint/style/noNonNullAssertion: we know this is defined
44
43
  const trustedSigner = accounts.at(0)!;
45
- const pointsIncentive = new fixtures.bases.PointsIncentive(defaultOptions, {
44
+ const pointsIncentive = fixtures.core.PointsIncentive({
46
45
  venue: points.assertValidAddress(),
47
- selector: bytes4('issue(address,uint256)'),
46
+ selector: bytes4("issue(address,uint256)"),
48
47
  reward: 1n,
49
48
  limit: 10n,
50
49
  });
@@ -53,13 +52,12 @@ describe('PointsIncentive', () => {
53
52
  });
54
53
 
55
54
  const claimant = trustedSigner.account;
56
- const incentiveData = pad('0xdef456232173821931823712381232131391321934');
55
+ const incentiveData = pad("0xdef456232173821931823712381232131391321934");
57
56
  const incentiveQuantity = 1;
58
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
57
+ const claimDataPayload = await boost.validator.encodeClaimData({
59
58
  signer: trustedSigner,
60
59
  incentiveData,
61
60
  chainId: defaultOptions.config.chains[0].id,
62
- validator: boost.validator.assertValidAddress(),
63
61
  incentiveQuantity,
64
62
  claimant,
65
63
  boostId: boost.id,
@@ -74,8 +72,7 @@ describe('PointsIncentive', () => {
74
72
  boost.id,
75
73
  0n,
76
74
  referrer,
77
- claimDataPayload,
78
- { value: parseEther('0.000075') },
75
+ claimDataPayload
79
76
  );
80
77
  expect(
81
78
  await readPointsBalanceOf(defaultOptions.config, {
@@ -85,16 +82,16 @@ describe('PointsIncentive', () => {
85
82
  ).toBe(1n);
86
83
  });
87
84
 
88
- test('cannot claim twice', async () => {
85
+ test("cannot claim twice", async () => {
89
86
  const reward = 1n;
90
87
  // biome-ignore lint/style/noNonNullAssertion: we know this is defined
91
88
  const referrer = accounts.at(1)!.account!;
92
89
  // biome-ignore lint/style/noNonNullAssertion: we know this is defined
93
90
  const trustedSigner = accounts.at(0)!;
94
91
 
95
- const pointsIncentive = new fixtures.bases.PointsIncentive(defaultOptions, {
92
+ const pointsIncentive = fixtures.core.PointsIncentive({
96
93
  venue: points.assertValidAddress(),
97
- selector: bytes4('issue(address,uint256)'),
94
+ selector: bytes4("issue(address,uint256)"),
98
95
  reward,
99
96
  limit: 10n,
100
97
  });
@@ -103,13 +100,12 @@ describe('PointsIncentive', () => {
103
100
  });
104
101
 
105
102
  const claimant = trustedSigner.account;
106
- const incentiveData = pad('0xdef456232173821931823712381232131391321934');
103
+ const incentiveData = pad("0xdef456232173821931823712381232131391321934");
107
104
  const incentiveQuantity = 1;
108
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
105
+ const claimDataPayload = await boost.validator.encodeClaimData({
109
106
  signer: trustedSigner,
110
107
  incentiveData,
111
108
  chainId: defaultOptions.config.chains[0].id,
112
- validator: boost.validator.assertValidAddress(),
113
109
  incentiveQuantity,
114
110
  claimant,
115
111
  boostId: boost.id,
@@ -125,7 +121,7 @@ describe('PointsIncentive', () => {
125
121
  0n,
126
122
  referrer,
127
123
  claimDataPayload,
128
- { value: parseEther('0.000075') },
124
+ { value: parseEther("0.000075") },
129
125
  );
130
126
  try {
131
127
  await fixtures.core.claimIncentive(
@@ -133,7 +129,7 @@ describe('PointsIncentive', () => {
133
129
  0n,
134
130
  referrer,
135
131
  claimDataPayload,
136
- { value: parseEther('0.000075') },
132
+ { value: parseEther("0.000075") },
137
133
  );
138
134
  } catch (e) {
139
135
  expect(e).toBeInstanceOf(Error);