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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/dist/Actions/Action.cjs +2 -1
  2. package/dist/Actions/Action.cjs.map +1 -0
  3. package/dist/Actions/Action.d.ts +1 -1
  4. package/dist/Actions/Action.d.ts.map +1 -1
  5. package/dist/Actions/Action.js +14 -12
  6. package/dist/Actions/Action.js.map +1 -0
  7. package/dist/Actions/ContractAction.d.ts +57 -14
  8. package/dist/Actions/ContractAction.d.ts.map +1 -1
  9. package/dist/Actions/ERC721MintAction.d.ts +50 -23
  10. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  11. package/dist/Actions/EventAction.cjs +2 -1
  12. package/dist/Actions/EventAction.cjs.map +1 -0
  13. package/dist/Actions/EventAction.d.ts +405 -36
  14. package/dist/Actions/EventAction.d.ts.map +1 -1
  15. package/dist/Actions/EventAction.js +15 -209
  16. package/dist/Actions/EventAction.js.map +1 -0
  17. package/dist/AllowLists/AllowList.cjs +2 -1
  18. package/dist/AllowLists/AllowList.cjs.map +1 -0
  19. package/dist/AllowLists/AllowList.d.ts +6 -5
  20. package/dist/AllowLists/AllowList.d.ts.map +1 -1
  21. package/dist/AllowLists/AllowList.js +46 -22
  22. package/dist/AllowLists/AllowList.js.map +1 -0
  23. package/dist/AllowLists/OpenAllowList.d.ts +423 -0
  24. package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
  25. package/dist/AllowLists/SimpleAllowList.cjs +2 -1
  26. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  27. package/dist/AllowLists/SimpleAllowList.d.ts +124 -40
  28. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  29. package/dist/AllowLists/SimpleAllowList.js +76 -76
  30. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  31. package/dist/AllowLists/SimpleDenyList.cjs +2 -1
  32. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  33. package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
  34. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  35. package/dist/AllowLists/SimpleDenyList.js +12 -200
  36. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  37. package/dist/Auth/Auth.cjs +1 -0
  38. package/dist/Auth/Auth.cjs.map +1 -0
  39. package/dist/Auth/Auth.js +1 -0
  40. package/dist/Auth/Auth.js.map +1 -0
  41. package/dist/Auth/PassthroughAuth.cjs +2 -1
  42. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  43. package/dist/Auth/PassthroughAuth.js +5 -4
  44. package/dist/Auth/PassthroughAuth.js.map +1 -0
  45. package/dist/Boost.cjs +2 -1
  46. package/dist/Boost.cjs.map +1 -0
  47. package/dist/Boost.d.ts +105 -14
  48. package/dist/Boost.d.ts.map +1 -1
  49. package/dist/Boost.js +138 -5
  50. package/dist/Boost.js.map +1 -0
  51. package/dist/BoostCore-DolmDuXW.cjs +3 -0
  52. package/dist/BoostCore-DolmDuXW.cjs.map +1 -0
  53. package/dist/BoostCore-Z97KVu4V.js +1448 -0
  54. package/dist/BoostCore-Z97KVu4V.js.map +1 -0
  55. package/dist/BoostCore.cjs +2 -2
  56. package/dist/BoostCore.cjs.map +1 -0
  57. package/dist/BoostCore.d.ts +788 -79
  58. package/dist/BoostCore.d.ts.map +1 -1
  59. package/dist/BoostCore.js +30 -1103
  60. package/dist/BoostCore.js.map +1 -0
  61. package/dist/BoostRegistry.cjs +2 -1
  62. package/dist/BoostRegistry.cjs.map +1 -0
  63. package/dist/BoostRegistry.d.ts +95 -26
  64. package/dist/BoostRegistry.d.ts.map +1 -1
  65. package/dist/BoostRegistry.js +183 -89
  66. package/dist/BoostRegistry.js.map +1 -0
  67. package/dist/Budgets/Budget.cjs +2 -1
  68. package/dist/Budgets/Budget.cjs.map +1 -0
  69. package/dist/Budgets/Budget.d.ts +1 -1
  70. package/dist/Budgets/Budget.d.ts.map +1 -1
  71. package/dist/Budgets/Budget.js +15 -13
  72. package/dist/Budgets/Budget.js.map +1 -0
  73. package/dist/Budgets/ManagedBudget.cjs +2 -1
  74. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  75. package/dist/Budgets/ManagedBudget.d.ts +112 -192
  76. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  77. package/dist/Budgets/ManagedBudget.js +91 -291
  78. package/dist/Budgets/ManagedBudget.js.map +1 -0
  79. package/dist/Budgets/VestingBudget.d.ts +277 -91
  80. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  81. package/dist/Deployable/Contract.cjs +2 -1
  82. package/dist/Deployable/Contract.cjs.map +1 -0
  83. package/dist/Deployable/Contract.d.ts +4 -5
  84. package/dist/Deployable/Contract.d.ts.map +1 -1
  85. package/dist/Deployable/Contract.js +7 -8
  86. package/dist/Deployable/Contract.js.map +1 -0
  87. package/dist/Deployable/Deployable.cjs +1 -0
  88. package/dist/Deployable/Deployable.cjs.map +1 -0
  89. package/dist/Deployable/Deployable.d.ts +9 -3
  90. package/dist/Deployable/Deployable.d.ts.map +1 -1
  91. package/dist/Deployable/Deployable.js +10 -5
  92. package/dist/Deployable/Deployable.js.map +1 -0
  93. package/dist/Deployable/DeployableTarget.cjs +2 -1
  94. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  95. package/dist/Deployable/DeployableTarget.d.ts +16 -15
  96. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  97. package/dist/Deployable/DeployableTarget.js +49 -42
  98. package/dist/Deployable/DeployableTarget.js.map +1 -0
  99. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  100. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  101. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
  102. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  103. package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
  104. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  105. package/dist/EventAction-CBKzuNoN.cjs +2 -0
  106. package/dist/EventAction-CBKzuNoN.cjs.map +1 -0
  107. package/dist/EventAction-DWuuc_Qy.js +1528 -0
  108. package/dist/EventAction-DWuuc_Qy.js.map +1 -0
  109. package/dist/Incentive-BxzEtN26.js +298 -0
  110. package/dist/Incentive-BxzEtN26.js.map +1 -0
  111. package/dist/Incentive-CrF3-ayL.cjs +2 -0
  112. package/dist/Incentive-CrF3-ayL.cjs.map +1 -0
  113. package/dist/Incentives/AllowListIncentive.cjs +2 -1
  114. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  115. package/dist/Incentives/AllowListIncentive.d.ts +65 -21
  116. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  117. package/dist/Incentives/AllowListIncentive.js +52 -36
  118. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  119. package/dist/Incentives/CGDAIncentive.cjs +2 -1
  120. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  121. package/dist/Incentives/CGDAIncentive.d.ts +315 -26
  122. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  123. package/dist/Incentives/CGDAIncentive.js +64 -39
  124. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  125. package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
  126. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  127. package/dist/Incentives/ERC20Incentive.cjs +2 -1
  128. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  129. package/dist/Incentives/ERC20Incentive.d.ts +270 -33
  130. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  131. package/dist/Incentives/ERC20Incentive.js +69 -46
  132. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  133. package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +338 -421
  134. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  135. package/dist/Incentives/ERC20VariableIncentive.d.ts +262 -32
  136. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  137. package/dist/Incentives/Incentive.cjs +2 -1
  138. package/dist/Incentives/Incentive.cjs.map +1 -0
  139. package/dist/Incentives/Incentive.d.ts +5 -8
  140. package/dist/Incentives/Incentive.d.ts.map +1 -1
  141. package/dist/Incentives/Incentive.js +17 -278
  142. package/dist/Incentives/Incentive.js.map +1 -0
  143. package/dist/Incentives/PointsIncentive.cjs +2 -1
  144. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  145. package/dist/Incentives/PointsIncentive.d.ts +81 -23
  146. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  147. package/dist/Incentives/PointsIncentive.js +57 -36
  148. package/dist/Incentives/PointsIncentive.js.map +1 -0
  149. package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
  150. package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
  151. package/dist/SimpleDenyList-CGaWjuld.js +132 -0
  152. package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
  153. package/dist/Validators/SignerValidator.cjs +2 -1
  154. package/dist/Validators/SignerValidator.cjs.map +1 -0
  155. package/dist/Validators/SignerValidator.d.ts +310 -17
  156. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  157. package/dist/Validators/SignerValidator.js +165 -36
  158. package/dist/Validators/SignerValidator.js.map +1 -0
  159. package/dist/Validators/Validator.cjs +2 -1
  160. package/dist/Validators/Validator.cjs.map +1 -0
  161. package/dist/Validators/Validator.d.ts +2 -2
  162. package/dist/Validators/Validator.d.ts.map +1 -1
  163. package/dist/Validators/Validator.js +10 -8
  164. package/dist/Validators/Validator.js.map +1 -0
  165. package/dist/claiming.cjs +2 -0
  166. package/dist/claiming.cjs.map +1 -0
  167. package/dist/claiming.d.ts +43 -0
  168. package/dist/claiming.d.ts.map +1 -0
  169. package/dist/claiming.js +17 -0
  170. package/dist/claiming.js.map +1 -0
  171. package/dist/componentInterfaces-BBCFkrZv.js +14 -0
  172. package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
  173. package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
  174. package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
  175. package/dist/deployments-DVXioW2i.cjs +2 -0
  176. package/dist/deployments-DVXioW2i.cjs.map +1 -0
  177. package/dist/deployments-oykLv3_Z.js +43 -0
  178. package/dist/deployments-oykLv3_Z.js.map +1 -0
  179. package/dist/deployments.json +44 -0
  180. package/dist/errors.cjs +2 -1
  181. package/dist/errors.cjs.map +1 -0
  182. package/dist/errors.d.ts +421 -1
  183. package/dist/errors.d.ts.map +1 -1
  184. package/dist/errors.js +297 -39
  185. package/dist/errors.js.map +1 -0
  186. package/dist/{generated-x_abr3Yv.js → generated-CKt2yCQd.js} +3143 -3002
  187. package/dist/generated-CKt2yCQd.js.map +1 -0
  188. package/dist/generated-CyTNlOwM.cjs +3 -0
  189. package/dist/generated-CyTNlOwM.cjs.map +1 -0
  190. package/dist/index.cjs +2 -1
  191. package/dist/index.cjs.map +1 -0
  192. package/dist/index.d.ts +10 -9
  193. package/dist/index.d.ts.map +1 -1
  194. package/dist/index.js +144 -1353
  195. package/dist/index.js.map +1 -0
  196. package/dist/transfers.cjs +2 -0
  197. package/dist/transfers.cjs.map +1 -0
  198. package/dist/transfers.d.ts +198 -0
  199. package/dist/transfers.d.ts.map +1 -0
  200. package/dist/transfers.js +84 -0
  201. package/dist/transfers.js.map +1 -0
  202. package/dist/utils.cjs +2 -1
  203. package/dist/utils.cjs.map +1 -0
  204. package/dist/utils.d.ts +26 -1350
  205. package/dist/utils.d.ts.map +1 -1
  206. package/dist/utils.js +38 -636
  207. package/dist/utils.js.map +1 -0
  208. package/package.json +37 -11
  209. package/src/Actions/Action.test.ts +79 -0
  210. package/src/Actions/Action.ts +61 -0
  211. package/src/Actions/ContractAction.test.ts +197 -0
  212. package/src/Actions/ContractAction.ts +300 -0
  213. package/src/Actions/ERC721MintAction.test.ts +112 -0
  214. package/src/Actions/ERC721MintAction.ts +291 -0
  215. package/src/Actions/EventAction.test.ts +787 -0
  216. package/src/Actions/EventAction.ts +1218 -0
  217. package/src/AllowLists/AllowList.test.ts +64 -0
  218. package/src/AllowLists/AllowList.ts +62 -0
  219. package/src/AllowLists/OpenAllowList.test.ts +40 -0
  220. package/src/AllowLists/OpenAllowList.ts +45 -0
  221. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  222. package/src/AllowLists/SimpleAllowList.ts +262 -0
  223. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  224. package/src/AllowLists/SimpleDenyList.ts +250 -0
  225. package/src/Auth/Auth.ts +11 -0
  226. package/src/Auth/PassthroughAuth.test.ts +12 -0
  227. package/src/Auth/PassthroughAuth.ts +80 -0
  228. package/src/Boost.ts +287 -0
  229. package/src/BoostCore.test.ts +894 -0
  230. package/src/BoostCore.ts +1438 -0
  231. package/src/BoostRegistry.test.ts +53 -0
  232. package/src/BoostRegistry.ts +588 -0
  233. package/src/Budgets/Budget.test.ts +27 -0
  234. package/src/Budgets/Budget.ts +60 -0
  235. package/src/Budgets/ManagedBudget.test.ts +217 -0
  236. package/src/Budgets/ManagedBudget.ts +534 -0
  237. package/src/Budgets/VestingBudget.test.ts +123 -0
  238. package/src/Budgets/VestingBudget.ts +530 -0
  239. package/src/Deployable/Contract.ts +228 -0
  240. package/src/Deployable/Deployable.ts +250 -0
  241. package/src/Deployable/DeployableTarget.ts +234 -0
  242. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  243. package/src/Incentives/AllowListIncentive.test.ts +143 -0
  244. package/src/Incentives/AllowListIncentive.ts +336 -0
  245. package/src/Incentives/CGDAIncentive.test.ts +135 -0
  246. package/src/Incentives/CGDAIncentive.ts +476 -0
  247. package/src/Incentives/ERC1155Incentive.test.ts +87 -0
  248. package/src/Incentives/ERC1155Incentive.ts +465 -0
  249. package/src/Incentives/ERC20Incentive.test.ts +133 -0
  250. package/src/Incentives/ERC20Incentive.ts +490 -0
  251. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  252. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
  253. package/src/Incentives/ERC20VariableIncentive.test.ts +139 -0
  254. package/src/Incentives/ERC20VariableIncentive.ts +428 -0
  255. package/src/Incentives/Incentive.test.ts +95 -0
  256. package/src/Incentives/Incentive.ts +86 -0
  257. package/src/Incentives/PointsIncentive.test.ts +138 -0
  258. package/src/Incentives/PointsIncentive.ts +367 -0
  259. package/src/Validators/SignerValidator.test.ts +159 -0
  260. package/src/Validators/SignerValidator.ts +683 -0
  261. package/src/Validators/Validator.test.ts +21 -0
  262. package/src/Validators/Validator.ts +55 -0
  263. package/src/claiming.ts +56 -0
  264. package/src/errors.ts +866 -0
  265. package/src/index.test.ts +122 -0
  266. package/src/index.ts +58 -0
  267. package/src/transfers.ts +284 -0
  268. package/src/utils.test.ts +44 -0
  269. package/src/utils.ts +247 -0
  270. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  271. package/dist/generated-BaaleHW-.cjs +0 -2
@@ -0,0 +1,336 @@
1
+ import {
2
+ allowListIncentiveAbi,
3
+ readAllowListIncentiveAllowList,
4
+ readAllowListIncentiveClaimed,
5
+ readAllowListIncentiveClaims,
6
+ readAllowListIncentiveIsClaimable,
7
+ readAllowListIncentiveLimit,
8
+ readAllowListIncentiveOwner,
9
+ readAllowListIncentiveReward,
10
+ simulateAllowListIncentiveClaim,
11
+ writeAllowListIncentiveClaim,
12
+ } from '@boostxyz/evm';
13
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/AllowListIncentive.sol/AllowListIncentive.json';
14
+ import {
15
+ type Address,
16
+ type ContractEventName,
17
+ type Hex,
18
+ encodeAbiParameters,
19
+ } from 'viem';
20
+ import { AllowListIncentive as AllowListIncentiveBases } from '../../dist/deployments.json';
21
+ import { SimpleAllowList } from '../AllowLists/AllowList';
22
+ import type {
23
+ DeployableOptions,
24
+ GenericDeployableParams,
25
+ } from '../Deployable/Deployable';
26
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
27
+ import { type ClaimPayload, prepareClaimPayload } from '../claiming';
28
+ import {
29
+ type GenericLog,
30
+ type ReadParams,
31
+ RegistryType,
32
+ type WriteParams,
33
+ } from '../utils';
34
+
35
+ export { allowListIncentiveAbi };
36
+
37
+ /**
38
+ * The object representation of a `AllowListIncentive.InitPayload`
39
+ *
40
+ * @export
41
+ * @interface AllowListIncentivePayload
42
+ * @typedef {AllowListIncentivePayload}
43
+ */
44
+ export interface AllowListIncentivePayload {
45
+ /**
46
+ * The address to the allowlist to add claimers to.
47
+ *
48
+ * @type {Address}
49
+ */
50
+ allowList: Address;
51
+ /**
52
+ * The maximum number of claims that can be made (one per address)
53
+ *
54
+ * @type {bigint}
55
+ */
56
+ limit: bigint;
57
+ }
58
+
59
+ /**
60
+ * A generic `viem.Log` event with support for `AllowListIncentive` event types.
61
+ *
62
+ * @export
63
+ * @typedef {AllowListIncentiveLog}
64
+ * @template {ContractEventName<
65
+ * typeof allowListIncentiveAbi
66
+ * >} [event=ContractEventName<typeof allowListIncentiveAbi>]
67
+ */
68
+ export type AllowListIncentiveLog<
69
+ event extends ContractEventName<
70
+ typeof allowListIncentiveAbi
71
+ > = ContractEventName<typeof allowListIncentiveAbi>,
72
+ > = GenericLog<typeof allowListIncentiveAbi, event>;
73
+
74
+ /**
75
+ * An incentive implementation that grants the claimer a slot on an {SimpleAllowList}
76
+ * In order for any claim to be successful:
77
+ * - The claimer must not already be on the allow list; and
78
+ * - The maximum number of claims must not have been reached; and
79
+ * - This contract must be authorized to modify the allow list
80
+ *
81
+ * @export
82
+ * @class AllowListIncentive
83
+ * @typedef {AllowListIncentive}
84
+ * @extends {DeployableTarget<AllowListIncentivePayload>}
85
+ */
86
+ export class AllowListIncentive extends DeployableTarget<
87
+ AllowListIncentivePayload,
88
+ typeof allowListIncentiveAbi
89
+ > {
90
+ public override readonly abi = allowListIncentiveAbi;
91
+ /**
92
+ * @inheritdoc
93
+ *
94
+ * @public
95
+ * @static
96
+ * @type {Record<number, Address>}
97
+ */
98
+ public static override bases: Record<number, Address> = {
99
+ ...(AllowListIncentiveBases as Record<number, Address>),
100
+ };
101
+ /**
102
+ * @inheritdoc
103
+ *
104
+ * @public
105
+ * @static
106
+ * @type {RegistryType}
107
+ */
108
+ public static override registryType: RegistryType = RegistryType.INCENTIVE;
109
+
110
+ /**
111
+ * The owner of the allowList
112
+ *
113
+ * @public
114
+ * @async
115
+ * @param {?ReadParams} [params]
116
+ * @returns {Promise<Address>}
117
+ */
118
+ public async owner(
119
+ params?: ReadParams<typeof allowListIncentiveAbi, 'owner'>,
120
+ ) {
121
+ return await readAllowListIncentiveOwner(this._config, {
122
+ address: this.assertValidAddress(),
123
+ args: [],
124
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
125
+ ...(params as any),
126
+ });
127
+ }
128
+
129
+ /**
130
+ * The number of claims that have been made
131
+ *
132
+ * @public
133
+ * @async
134
+ * @param {?ReadParams} [params]
135
+ * @returns {Promise<bigint>}
136
+ */
137
+ public async claims(
138
+ params?: ReadParams<typeof allowListIncentiveAbi, 'claims'>,
139
+ ) {
140
+ return await readAllowListIncentiveClaims(this._config, {
141
+ address: this.assertValidAddress(),
142
+ args: [],
143
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
144
+ ...(params as any),
145
+ });
146
+ }
147
+
148
+ /**
149
+ * The reward amount issued for each claim
150
+ *
151
+ * @public
152
+ * @async
153
+ * @param {?ReadParams} [params]
154
+ * @returns {Promise<bigint>}
155
+ */
156
+ public async reward(
157
+ params?: ReadParams<typeof allowListIncentiveAbi, 'reward'>,
158
+ ) {
159
+ return await readAllowListIncentiveReward(this._config, {
160
+ address: this.assertValidAddress(),
161
+ args: [],
162
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
163
+ ...(params as any),
164
+ });
165
+ }
166
+
167
+ /**
168
+ * Get the claim status for a user
169
+ *
170
+ * @public
171
+ * @async
172
+ * @param {Address} address
173
+ * @param {?ReadParams} [params]
174
+ * @returns {Promise<boolean>}
175
+ */
176
+ public async claimed(
177
+ address: Address,
178
+ params?: ReadParams<typeof allowListIncentiveAbi, 'claimed'>,
179
+ ) {
180
+ return await readAllowListIncentiveClaimed(this._config, {
181
+ address: this.assertValidAddress(),
182
+ args: [address],
183
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
184
+ ...(params as any),
185
+ });
186
+ }
187
+
188
+ /**
189
+ * The {@link SimpleAllowList} contract
190
+ *
191
+ * @public
192
+ * @async
193
+ * @param {?ReadParams} [params]
194
+ * @returns {Promise<SimpleAllowList>}
195
+ */
196
+ public async allowList(
197
+ params?: ReadParams<typeof allowListIncentiveAbi, 'allowList'>,
198
+ ): Promise<SimpleAllowList> {
199
+ const address = await readAllowListIncentiveAllowList(this._config, {
200
+ address: this.assertValidAddress(),
201
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
202
+ ...(params as any),
203
+ });
204
+ return new SimpleAllowList(
205
+ { config: this._config, account: this._account },
206
+ address,
207
+ );
208
+ }
209
+
210
+ /**
211
+ * The maximum number of claims that can be made (one per address)
212
+ *
213
+ * @public
214
+ * @async
215
+ * @param {?ReadParams} [params]
216
+ * @returns {Promise<bigint>}
217
+ */
218
+ public async limit(
219
+ params?: ReadParams<typeof allowListIncentiveAbi, 'limit'>,
220
+ ) {
221
+ return await readAllowListIncentiveLimit(this._config, {
222
+ address: this.assertValidAddress(),
223
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
224
+ ...(params as any),
225
+ });
226
+ }
227
+
228
+ /**
229
+ * Claim a slot on the {@link SimpleAllowList}
230
+ *
231
+ * @public
232
+ * @async
233
+ * @param {Pick<ClaimPayload, 'target'>} payload
234
+ * @param {?WriteParams} [params]
235
+ * @returns {Promise<true>} - return true if successful, otherwise revert
236
+ */
237
+ protected async claim(
238
+ payload: Pick<ClaimPayload, 'target'>,
239
+ params?: WriteParams<typeof allowListIncentiveAbi, 'claim'>,
240
+ ) {
241
+ return await this.awaitResult(this.claimRaw(payload, params));
242
+ }
243
+
244
+ /**
245
+ * Claim a slot on the {@link SimpleAllowList}
246
+ *
247
+ * @public
248
+ * @async
249
+ * @param {Pick<ClaimPayload, 'target'>} payload
250
+ * @param {?WriteParams} [params]
251
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - return true if successful, otherwise revert
252
+ */
253
+ protected async claimRaw(
254
+ payload: Pick<ClaimPayload, 'target'>,
255
+ params?: WriteParams<typeof allowListIncentiveAbi, 'claim'>,
256
+ ) {
257
+ const { request, result } = await simulateAllowListIncentiveClaim(
258
+ this._config,
259
+ {
260
+ address: this.assertValidAddress(),
261
+ args: [prepareClaimPayload(payload)],
262
+ ...this.optionallyAttachAccount(),
263
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
264
+ ...(params as any),
265
+ },
266
+ );
267
+ const hash = await writeAllowListIncentiveClaim(this._config, request);
268
+ return { hash, result };
269
+ }
270
+
271
+ /**
272
+ * Check if an incentive is claimable
273
+ *
274
+ * @public
275
+ * @async
276
+ * @param {Pick<ClaimPayload, 'target'>} payload
277
+ * @param {?ReadParams} [params]
278
+ * @returns {Promise<boolean>} - True if the incentive is claimable based on the data payload
279
+ */
280
+ public async isClaimable(
281
+ payload: Pick<ClaimPayload, 'target'>,
282
+ params?: ReadParams<typeof allowListIncentiveAbi, 'isClaimable'>,
283
+ ) {
284
+ return await readAllowListIncentiveIsClaimable(this._config, {
285
+ address: this.assertValidAddress(),
286
+ args: [prepareClaimPayload(payload)],
287
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
288
+ ...(params as any),
289
+ });
290
+ }
291
+
292
+ /**
293
+ * @inheritdoc
294
+ *
295
+ * @public
296
+ * @param {?AllowListIncentivePayload} [_payload]
297
+ * @param {?DeployableOptions} [_options]
298
+ * @returns {GenericDeployableParams}
299
+ */
300
+ public override buildParameters(
301
+ _payload?: AllowListIncentivePayload,
302
+ _options?: DeployableOptions,
303
+ ): GenericDeployableParams {
304
+ const [payload, options] = this.validateDeploymentConfig(
305
+ _payload,
306
+ _options,
307
+ );
308
+ return {
309
+ abi: allowListIncentiveAbi,
310
+ bytecode: bytecode as Hex,
311
+ args: [prepareAllowListIncentivePayload(payload)],
312
+ ...this.optionallyAttachAccount(options.account),
313
+ };
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Given a {@link AllowListIncentivePayload}, properly encode a `AllowListIncentive.InitPayload` for use with {@link AllowListIncentive} initialization.
319
+ *
320
+ * @param {AllowListIncentivePayload} param0
321
+ * @param {Address} param0.allowList - The address to the allowlist to add claimers to.
322
+ * @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
323
+ * @returns {Hex}
324
+ */
325
+ export const prepareAllowListIncentivePayload = ({
326
+ allowList,
327
+ limit,
328
+ }: AllowListIncentivePayload) => {
329
+ return encodeAbiParameters(
330
+ [
331
+ { type: 'address', name: 'allowList' },
332
+ { type: 'uint256', name: 'limit' },
333
+ ],
334
+ [allowList, limit],
335
+ );
336
+ };
@@ -0,0 +1,135 @@
1
+ import { readMockErc20BalanceOf } 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 { accounts } from '@boostxyz/test/accounts';
6
+ import {
7
+ type BudgetFixtures,
8
+ type Fixtures,
9
+ defaultOptions,
10
+ deployFixtures,
11
+ freshBoost,
12
+ fundBudget,
13
+ } from '@boostxyz/test/helpers';
14
+ import { CGDAIncentive } from './CGDAIncentive';
15
+
16
+ let fixtures: Fixtures, budgets: BudgetFixtures;
17
+
18
+ describe('CGDAIncentive', () => {
19
+ beforeAll(async () => {
20
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
21
+ });
22
+
23
+ beforeEach(async () => {
24
+ budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
25
+ });
26
+
27
+ test('can successfully be deployed', async () => {
28
+ const action = new CGDAIncentive(defaultOptions, {
29
+ asset: budgets.erc20.assertValidAddress(),
30
+ initialReward: 1n,
31
+ totalBudget: 10n,
32
+ rewardBoost: 1n,
33
+ rewardDecay: 1n,
34
+ manager: budgets.budget.address || zeroAddress
35
+ });
36
+ await action.deploy();
37
+ expect(isAddress(action.assertValidAddress())).toBe(true);
38
+ });
39
+
40
+ test('can claim', async () => {
41
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
42
+ const referrer = accounts.at(1)!.account!;
43
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
44
+ const trustedSigner = accounts.at(0)!;
45
+ const erc20Incentive = fixtures.core.CGDAIncentive({
46
+ asset: budgets.erc20.assertValidAddress(),
47
+ initialReward: 1n,
48
+ totalBudget: 10n,
49
+ rewardBoost: 1n,
50
+ rewardDecay: 1n,
51
+ manager: budgets.budget.assertValidAddress(),
52
+ });
53
+ const boost = await freshBoost(fixtures, {
54
+ budget: budgets.budget,
55
+ incentives: [erc20Incentive],
56
+ });
57
+
58
+ const claimant = trustedSigner.account;
59
+ const incentiveData = pad('0xdef456232173821931823712381232131391321934');
60
+
61
+ const incentiveQuantity = 1;
62
+ const claimDataPayload = await boost.validator.encodeClaimData({
63
+ signer: trustedSigner,
64
+ incentiveData,
65
+ chainId: defaultOptions.config.chains[0].id,
66
+ incentiveQuantity,
67
+ claimant,
68
+ boostId: boost.id,
69
+ });
70
+
71
+ await fixtures.core.claimIncentive(
72
+ boost.id,
73
+ 0n,
74
+ referrer,
75
+ claimDataPayload,
76
+ { value: parseEther('0.000075') },
77
+ );
78
+ expect(
79
+ await readMockErc20BalanceOf(defaultOptions.config, {
80
+ address: budgets.erc20.assertValidAddress(),
81
+ args: [defaultOptions.account.address],
82
+ }),
83
+ ).toBe(1n);
84
+ });
85
+
86
+ test('cannot claim twice', async () => {
87
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
88
+ const referrer = accounts.at(1)!.account!;
89
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
90
+ const trustedSigner = accounts.at(0)!;
91
+ const erc20Incentive = fixtures.core.CGDAIncentive({
92
+ asset: budgets.erc20.assertValidAddress(),
93
+ initialReward: 1n,
94
+ totalBudget: 10n,
95
+ rewardBoost: 1n,
96
+ rewardDecay: 1n,
97
+ manager: budgets.budget.address || zeroAddress
98
+ });
99
+ const boost = await freshBoost(fixtures, {
100
+ budget: budgets.budget,
101
+ incentives: [erc20Incentive],
102
+ });
103
+
104
+ const claimant = trustedSigner.account;
105
+ const incentiveData = pad('0xdef456232173821931823712381232131391321934');
106
+ const incentiveQuantity = 1;
107
+ const claimDataPayload = await boost.validator.encodeClaimData({
108
+ signer: trustedSigner,
109
+ incentiveData,
110
+ chainId: defaultOptions.config.chains[0].id,
111
+ incentiveQuantity,
112
+ claimant,
113
+ boostId: boost.id,
114
+ });
115
+
116
+ await fixtures.core.claimIncentive(
117
+ boost.id,
118
+ 0n,
119
+ referrer,
120
+ claimDataPayload,
121
+ { value: parseEther('0.000075') },
122
+ );
123
+ try {
124
+ await fixtures.core.claimIncentive(
125
+ boost.id,
126
+ 0n,
127
+ referrer,
128
+ claimDataPayload,
129
+ { value: parseEther('0.000075') },
130
+ );
131
+ } catch (e) {
132
+ expect(e).toBeInstanceOf(Error);
133
+ }
134
+ });
135
+ });