@boostxyz/sdk 0.0.0-alpha.3 → 0.0.0-alpha.6

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 (176) 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 +15 -13
  6. package/dist/Actions/Action.js.map +1 -0
  7. package/dist/Actions/EventAction.cjs +1 -0
  8. package/dist/Actions/EventAction.cjs.map +1 -0
  9. package/dist/Actions/EventAction.js +1 -0
  10. package/dist/Actions/EventAction.js.map +1 -0
  11. package/dist/AllowLists/AllowList.cjs +2 -1
  12. package/dist/AllowLists/AllowList.cjs.map +1 -0
  13. package/dist/AllowLists/AllowList.d.ts +1 -2
  14. package/dist/AllowLists/AllowList.d.ts.map +1 -1
  15. package/dist/AllowLists/AllowList.js +16 -14
  16. package/dist/AllowLists/AllowList.js.map +1 -0
  17. package/dist/AllowLists/SimpleAllowList.cjs +1 -0
  18. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  19. package/dist/AllowLists/SimpleAllowList.js +1 -0
  20. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  21. package/dist/AllowLists/SimpleDenyList.cjs +1 -0
  22. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  23. package/dist/AllowLists/SimpleDenyList.js +1 -0
  24. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  25. package/dist/Auth/Auth.cjs +1 -0
  26. package/dist/Auth/Auth.cjs.map +1 -0
  27. package/dist/Auth/Auth.js +1 -0
  28. package/dist/Auth/Auth.js.map +1 -0
  29. package/dist/Auth/PassthroughAuth.cjs +1 -0
  30. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  31. package/dist/Auth/PassthroughAuth.js +1 -0
  32. package/dist/Auth/PassthroughAuth.js.map +1 -0
  33. package/dist/Boost.cjs +1 -0
  34. package/dist/Boost.cjs.map +1 -0
  35. package/dist/Boost.js +1 -0
  36. package/dist/Boost.js.map +1 -0
  37. package/dist/BoostCore.cjs +1 -0
  38. package/dist/BoostCore.cjs.map +1 -0
  39. package/dist/BoostCore.js +1 -0
  40. package/dist/BoostCore.js.map +1 -0
  41. package/dist/BoostRegistry.cjs +1 -0
  42. package/dist/BoostRegistry.cjs.map +1 -0
  43. package/dist/BoostRegistry.js +1 -0
  44. package/dist/BoostRegistry.js.map +1 -0
  45. package/dist/Budgets/Budget.cjs +2 -1
  46. package/dist/Budgets/Budget.cjs.map +1 -0
  47. package/dist/Budgets/Budget.d.ts +1 -1
  48. package/dist/Budgets/Budget.d.ts.map +1 -1
  49. package/dist/Budgets/Budget.js +14 -12
  50. package/dist/Budgets/Budget.js.map +1 -0
  51. package/dist/Budgets/ManagedBudget.cjs +1 -0
  52. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  53. package/dist/Budgets/ManagedBudget.js +1 -0
  54. package/dist/Budgets/ManagedBudget.js.map +1 -0
  55. package/dist/Deployable/Contract.cjs +1 -0
  56. package/dist/Deployable/Contract.cjs.map +1 -0
  57. package/dist/Deployable/Contract.js +1 -0
  58. package/dist/Deployable/Contract.js.map +1 -0
  59. package/dist/Deployable/Deployable.cjs +1 -0
  60. package/dist/Deployable/Deployable.cjs.map +1 -0
  61. package/dist/Deployable/Deployable.js +1 -0
  62. package/dist/Deployable/Deployable.js.map +1 -0
  63. package/dist/Deployable/DeployableTarget.cjs +1 -0
  64. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  65. package/dist/Deployable/DeployableTarget.js +1 -0
  66. package/dist/Deployable/DeployableTarget.js.map +1 -0
  67. package/dist/Incentives/AllowListIncentive.cjs +1 -0
  68. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  69. package/dist/Incentives/AllowListIncentive.js +1 -0
  70. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  71. package/dist/Incentives/CGDAIncentive.cjs +1 -0
  72. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  73. package/dist/Incentives/CGDAIncentive.js +1 -0
  74. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  75. package/dist/Incentives/ERC20Incentive.cjs +1 -0
  76. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  77. package/dist/Incentives/ERC20Incentive.js +1 -0
  78. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  79. package/dist/Incentives/Incentive.cjs +2 -1
  80. package/dist/Incentives/Incentive.cjs.map +1 -0
  81. package/dist/Incentives/Incentive.d.ts +1 -4
  82. package/dist/Incentives/Incentive.d.ts.map +1 -1
  83. package/dist/Incentives/Incentive.js +39 -36
  84. package/dist/Incentives/Incentive.js.map +1 -0
  85. package/dist/Incentives/PointsIncentive.cjs +1 -0
  86. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  87. package/dist/Incentives/PointsIncentive.js +1 -0
  88. package/dist/Incentives/PointsIncentive.js.map +1 -0
  89. package/dist/Validators/SignerValidator.cjs +1 -0
  90. package/dist/Validators/SignerValidator.cjs.map +1 -0
  91. package/dist/Validators/SignerValidator.js +1 -0
  92. package/dist/Validators/SignerValidator.js.map +1 -0
  93. package/dist/Validators/Validator.cjs +2 -1
  94. package/dist/Validators/Validator.cjs.map +1 -0
  95. package/dist/Validators/Validator.d.ts +1 -1
  96. package/dist/Validators/Validator.d.ts.map +1 -1
  97. package/dist/Validators/Validator.js +9 -7
  98. package/dist/Validators/Validator.js.map +1 -0
  99. package/dist/componentInterfaces-CKCBwG16.cjs +2 -0
  100. package/dist/componentInterfaces-CKCBwG16.cjs.map +1 -0
  101. package/dist/componentInterfaces-DYkaxBda.js +13 -0
  102. package/dist/componentInterfaces-DYkaxBda.js.map +1 -0
  103. package/dist/errors.cjs +1 -0
  104. package/dist/errors.cjs.map +1 -0
  105. package/dist/errors.js +1 -0
  106. package/dist/errors.js.map +1 -0
  107. package/dist/generated-Cd-Fe7W7.cjs +1 -0
  108. package/dist/generated-Cd-Fe7W7.cjs.map +1 -0
  109. package/dist/generated-DGpIVcv5.js +1 -0
  110. package/dist/generated-DGpIVcv5.js.map +1 -0
  111. package/dist/index.cjs +1 -0
  112. package/dist/index.cjs.map +1 -0
  113. package/dist/index.js +1 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/utils.cjs +1 -0
  116. package/dist/utils.cjs.map +1 -0
  117. package/dist/utils.d.ts +1 -1
  118. package/dist/utils.d.ts.map +1 -1
  119. package/dist/utils.js +1 -0
  120. package/dist/utils.js.map +1 -0
  121. package/package.json +5 -3
  122. package/src/Actions/Action.test.ts +77 -0
  123. package/src/Actions/Action.ts +61 -0
  124. package/src/Actions/ContractAction.test.ts +199 -0
  125. package/src/Actions/ContractAction.ts +238 -0
  126. package/src/Actions/ERC721MintAction.test.ts +112 -0
  127. package/src/Actions/ERC721MintAction.ts +238 -0
  128. package/src/Actions/EventAction.test.ts +182 -0
  129. package/src/Actions/EventAction.ts +382 -0
  130. package/src/AllowLists/AllowList.test.ts +64 -0
  131. package/src/AllowLists/AllowList.ts +60 -0
  132. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  133. package/src/AllowLists/SimpleAllowList.ts +240 -0
  134. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  135. package/src/AllowLists/SimpleDenyList.ts +289 -0
  136. package/src/Auth/Auth.ts +11 -0
  137. package/src/Auth/PassthroughAuth.test.ts +12 -0
  138. package/src/Auth/PassthroughAuth.ts +80 -0
  139. package/src/Boost.ts +155 -0
  140. package/src/BoostCore.test.ts +846 -0
  141. package/src/BoostCore.ts +1192 -0
  142. package/src/BoostRegistry.ts +449 -0
  143. package/src/Budgets/Budget.test.ts +27 -0
  144. package/src/Budgets/Budget.ts +61 -0
  145. package/src/Budgets/ManagedBudget.test.ts +154 -0
  146. package/src/Budgets/ManagedBudget.ts +743 -0
  147. package/src/Budgets/SimpleBudget.test.ts +152 -0
  148. package/src/Budgets/SimpleBudget.ts +521 -0
  149. package/src/Budgets/VestingBudget.test.ts +123 -0
  150. package/src/Budgets/VestingBudget.ts +532 -0
  151. package/src/Deployable/Contract.ts +229 -0
  152. package/src/Deployable/Deployable.ts +244 -0
  153. package/src/Deployable/DeployableTarget.ts +210 -0
  154. package/src/Incentives/AllowListIncentive.test.ts +146 -0
  155. package/src/Incentives/AllowListIncentive.ts +290 -0
  156. package/src/Incentives/CGDAIncentive.test.ts +136 -0
  157. package/src/Incentives/CGDAIncentive.ts +364 -0
  158. package/src/Incentives/ERC1155Incentive.test.ts +98 -0
  159. package/src/Incentives/ERC1155Incentive.ts +384 -0
  160. package/src/Incentives/ERC20Incentive.test.ts +141 -0
  161. package/src/Incentives/ERC20Incentive.ts +417 -0
  162. package/src/Incentives/ERC20VariableIncentive.test.ts +156 -0
  163. package/src/Incentives/ERC20VariableIncentive.ts +368 -0
  164. package/src/Incentives/Incentive.test.ts +92 -0
  165. package/src/Incentives/Incentive.ts +85 -0
  166. package/src/Incentives/PointsIncentive.test.ts +142 -0
  167. package/src/Incentives/PointsIncentive.ts +303 -0
  168. package/src/Validators/SignerValidator.test.ts +163 -0
  169. package/src/Validators/SignerValidator.ts +272 -0
  170. package/src/Validators/Validator.test.ts +21 -0
  171. package/src/Validators/Validator.ts +55 -0
  172. package/src/errors.ts +524 -0
  173. package/src/index.test.ts +40 -0
  174. package/src/index.ts +50 -0
  175. package/src/utils.test.ts +44 -0
  176. package/src/utils.ts +2247 -0
@@ -0,0 +1,384 @@
1
+ import {
2
+ erc1155IncentiveAbi,
3
+ readErc1155IncentiveAsset,
4
+ readErc1155IncentiveClaimed,
5
+ readErc1155IncentiveClaims,
6
+ readErc1155IncentiveExtraData,
7
+ readErc1155IncentiveIsClaimable,
8
+ readErc1155IncentiveLimit,
9
+ readErc1155IncentivePreflight,
10
+ readErc1155IncentiveReward,
11
+ readErc1155IncentiveStrategy,
12
+ readErc1155IncentiveTokenId,
13
+ simulateErc1155IncentiveClaim,
14
+ simulateErc1155IncentiveClawback,
15
+ writeErc1155IncentiveClaim,
16
+ writeErc1155IncentiveClawback,
17
+ } from '@boostxyz/evm';
18
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC1155Incentive.sol/ERC1155Incentive.json';
19
+ import type { Address, ContractEventName, Hex } from 'viem';
20
+ import type {
21
+ DeployableOptions,
22
+ GenericDeployableParams,
23
+ } from '../Deployable/Deployable';
24
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
25
+ import {
26
+ type ClaimPayload,
27
+ type ERC1155IncentivePayload,
28
+ ERC1155StrategyType,
29
+ type GenericLog,
30
+ type ReadParams,
31
+ RegistryType,
32
+ type StrategyType,
33
+ type WriteParams,
34
+ prepareClaimPayload,
35
+ prepareERC1155IncentivePayload,
36
+ } from '../utils';
37
+
38
+ export { ERC1155StrategyType, erc1155IncentiveAbi };
39
+ export type { ERC1155IncentivePayload };
40
+
41
+ /**
42
+ * A generic `viem.Log` event with support for `ERC1155Incentive` event types.
43
+ *
44
+ * @export
45
+ * @typedef {ERC1155IncentiveLog}
46
+ * @template {ContractEventName<
47
+ * typeof erc1155IncentiveAbi
48
+ * >} [event=ContractEventName<typeof erc1155IncentiveAbi>]
49
+ */
50
+ export type ERC1155IncentiveLog<
51
+ event extends ContractEventName<
52
+ typeof erc1155IncentiveAbi
53
+ > = ContractEventName<typeof erc1155IncentiveAbi>,
54
+ > = GenericLog<typeof erc1155IncentiveAbi, event>;
55
+
56
+ /**
57
+ * This is currently not exported due to a mysterious abi encoding issue
58
+ *
59
+ * @experimental
60
+ * @export
61
+ * @class ERC1155Incentive
62
+ * @typedef {ERC1155Incentive}
63
+ * @extends {DeployableTarget<ERC1155IncentivePayload>}
64
+ */
65
+ export class ERC1155Incentive extends DeployableTarget<
66
+ ERC1155IncentivePayload,
67
+ typeof erc1155IncentiveAbi
68
+ > {
69
+ public override readonly abi = erc1155IncentiveAbi;
70
+ /**
71
+ * @inheritdoc
72
+ *
73
+ * @public
74
+ * @static
75
+ * @type {Address}
76
+ */
77
+ public static override base: Address = import.meta.env
78
+ .VITE_ERC1155_INCENTIVE_BASE;
79
+ /**
80
+ * @inheritdoc
81
+ *
82
+ * @public
83
+ * @static
84
+ * @type {RegistryType}
85
+ */
86
+ public static override registryType: RegistryType = RegistryType.INCENTIVE;
87
+
88
+ /**
89
+ * Description placeholder
90
+ *
91
+ * @public
92
+ * @async
93
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'claims'>} [params]
94
+ * @returns {unknown}
95
+ */
96
+ public async claims(
97
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'claims'>,
98
+ ) {
99
+ return readErc1155IncentiveClaims(this._config, {
100
+ address: this.assertValidAddress(),
101
+ args: [],
102
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
103
+ ...(params as any),
104
+ });
105
+ }
106
+
107
+ /**
108
+ * Description placeholder
109
+ *
110
+ * @public
111
+ * @async
112
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'reward'>} [params]
113
+ * @returns {unknown}
114
+ */
115
+ public async reward(
116
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'reward'>,
117
+ ) {
118
+ return readErc1155IncentiveReward(this._config, {
119
+ address: this.assertValidAddress(),
120
+ args: [],
121
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
122
+ ...(params as any),
123
+ });
124
+ }
125
+
126
+ /**
127
+ * Description placeholder
128
+ *
129
+ * @public
130
+ * @async
131
+ * @param {Address} address
132
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'claimed'>} [params]
133
+ * @returns {unknown}
134
+ */
135
+ public async claimed(
136
+ address: Address,
137
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'claimed'>,
138
+ ) {
139
+ return readErc1155IncentiveClaimed(this._config, {
140
+ address: this.assertValidAddress(),
141
+ args: [address],
142
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
143
+ ...(params as any),
144
+ });
145
+ }
146
+
147
+ /**
148
+ * Description placeholder
149
+ *
150
+ * @public
151
+ * @async
152
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'asset'>} [params]
153
+ * @returns {unknown}
154
+ */
155
+ public async asset(params?: ReadParams<typeof erc1155IncentiveAbi, 'asset'>) {
156
+ return readErc1155IncentiveAsset(this._config, {
157
+ address: this.assertValidAddress(),
158
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
159
+ ...(params as any),
160
+ });
161
+ }
162
+
163
+ /**
164
+ * Description placeholder
165
+ *
166
+ * @public
167
+ * @async
168
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'strategy'>} [params]
169
+ * @returns {Promise<StrategyType>}
170
+ */
171
+ public async strategy(
172
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'strategy'>,
173
+ ): Promise<StrategyType> {
174
+ return readErc1155IncentiveStrategy(this._config, {
175
+ address: this.assertValidAddress(),
176
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
177
+ ...(params as any),
178
+ }) as Promise<StrategyType>;
179
+ }
180
+
181
+ /**
182
+ * Description placeholder
183
+ *
184
+ * @public
185
+ * @async
186
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'limit'>} [params]
187
+ * @returns {unknown}
188
+ */
189
+ public async limit(params?: ReadParams<typeof erc1155IncentiveAbi, 'limit'>) {
190
+ return readErc1155IncentiveLimit(this._config, {
191
+ address: this.assertValidAddress(),
192
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
193
+ ...(params as any),
194
+ });
195
+ }
196
+
197
+ /**
198
+ * Description placeholder
199
+ *
200
+ * @public
201
+ * @async
202
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'tokenId'>} [params]
203
+ * @returns {unknown}
204
+ */
205
+ public async tokenId(
206
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'tokenId'>,
207
+ ) {
208
+ return readErc1155IncentiveTokenId(this._config, {
209
+ address: this.assertValidAddress(),
210
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
211
+ ...(params as any),
212
+ });
213
+ }
214
+
215
+ /**
216
+ * Description placeholder
217
+ *
218
+ * @public
219
+ * @async
220
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'extraData'>} [params]
221
+ * @returns {unknown}
222
+ */
223
+ public async extraData(
224
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'extraData'>,
225
+ ) {
226
+ return readErc1155IncentiveExtraData(this._config, {
227
+ address: this.assertValidAddress(),
228
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
229
+ ...(params as any),
230
+ });
231
+ }
232
+
233
+ /**
234
+ * Description placeholder
235
+ *
236
+ * @public
237
+ * @async
238
+ * @param {ClaimPayload} payload
239
+ * @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
240
+ * @returns {unknown}
241
+ */
242
+ public async claim(
243
+ payload: ClaimPayload,
244
+ params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
245
+ ) {
246
+ return this.awaitResult(this.claimRaw(payload, params));
247
+ }
248
+
249
+ /**
250
+ * Description placeholder
251
+ *
252
+ * @public
253
+ * @async
254
+ * @param {ClaimPayload} payload
255
+ * @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
256
+ * @returns {unknown}
257
+ */
258
+ public async claimRaw(
259
+ payload: ClaimPayload,
260
+ params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
261
+ ) {
262
+ const { request, result } = await simulateErc1155IncentiveClaim(
263
+ this._config,
264
+ {
265
+ address: this.assertValidAddress(),
266
+ args: [prepareClaimPayload(payload)],
267
+ ...this.optionallyAttachAccount(),
268
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
269
+ ...(params as any),
270
+ },
271
+ );
272
+ const hash = await writeErc1155IncentiveClaim(this._config, request);
273
+ return { hash, result };
274
+ }
275
+
276
+ /**
277
+ * Description placeholder
278
+ *
279
+ * @public
280
+ * @async
281
+ * @param {ClaimPayload} payload
282
+ * @param {?WriteParams<typeof erc1155IncentiveAbi, 'clawback'>} [params]
283
+ * @returns {unknown}
284
+ */
285
+ public async clawback(
286
+ payload: ClaimPayload,
287
+ params?: WriteParams<typeof erc1155IncentiveAbi, 'clawback'>,
288
+ ) {
289
+ return this.awaitResult(this.clawbackRaw(payload, params));
290
+ }
291
+
292
+ /**
293
+ * Description placeholder
294
+ *
295
+ * @public
296
+ * @async
297
+ * @param {ClaimPayload} payload
298
+ * @param {?WriteParams<typeof erc1155IncentiveAbi, 'clawback'>} [params]
299
+ * @returns {unknown}
300
+ */
301
+ public async clawbackRaw(
302
+ payload: ClaimPayload,
303
+ params?: WriteParams<typeof erc1155IncentiveAbi, 'clawback'>,
304
+ ) {
305
+ const { request, result } = await simulateErc1155IncentiveClawback(
306
+ this._config,
307
+ {
308
+ address: this.assertValidAddress(),
309
+ args: [prepareClaimPayload(payload)],
310
+ ...this.optionallyAttachAccount(),
311
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
312
+ ...(params as any),
313
+ },
314
+ );
315
+ const hash = await writeErc1155IncentiveClawback(this._config, request);
316
+ return { hash, result };
317
+ }
318
+
319
+ /**
320
+ * Description placeholder
321
+ *
322
+ * @public
323
+ * @async
324
+ * @param {ClaimPayload} payload
325
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'isClaimable'>} [params]
326
+ * @returns {unknown}
327
+ */
328
+ public async isClaimable(
329
+ payload: ClaimPayload,
330
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'isClaimable'>,
331
+ ) {
332
+ return readErc1155IncentiveIsClaimable(this._config, {
333
+ address: this.assertValidAddress(),
334
+ args: [prepareClaimPayload(payload)],
335
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
336
+ ...(params as any),
337
+ });
338
+ }
339
+
340
+ /**
341
+ * Description placeholder
342
+ *
343
+ * @public
344
+ * @async
345
+ * @param {ERC1155IncentivePayload} data
346
+ * @param {?ReadParams<typeof erc1155IncentiveAbi, 'preflight'>} [params]
347
+ * @returns {unknown}
348
+ */
349
+ public async preflight(
350
+ data: ERC1155IncentivePayload,
351
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'preflight'>,
352
+ ) {
353
+ return readErc1155IncentivePreflight(this._config, {
354
+ address: this.assertValidAddress(),
355
+ args: [prepareERC1155IncentivePayload(data)],
356
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
357
+ ...(params as any),
358
+ });
359
+ }
360
+
361
+ /**
362
+ * @inheritdoc
363
+ *
364
+ * @public
365
+ * @param {?ERC1155IncentivePayload} [_payload]
366
+ * @param {?DeployableOptions} [_options]
367
+ * @returns {GenericDeployableParams}
368
+ */
369
+ public override buildParameters(
370
+ _payload?: ERC1155IncentivePayload,
371
+ _options?: DeployableOptions,
372
+ ): GenericDeployableParams {
373
+ const [payload, options] = this.validateDeploymentConfig(
374
+ _payload,
375
+ _options,
376
+ );
377
+ return {
378
+ abi: erc1155IncentiveAbi,
379
+ bytecode: bytecode as Hex,
380
+ args: [prepareERC1155IncentivePayload(payload)],
381
+ ...this.optionallyAttachAccount(options.account),
382
+ };
383
+ }
384
+ }
@@ -0,0 +1,141 @@
1
+ import { readMockErc20BalanceOf } from '@boostxyz/evm';
2
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
+ import { signMessage } from '@wagmi/core';
4
+ import {
5
+ encodePacked,
6
+ isAddress,
7
+ keccak256,
8
+ pad,
9
+ parseEther,
10
+ zeroAddress,
11
+ } from 'viem';
12
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
13
+ import { accounts } from '../../test/accounts';
14
+ import {
15
+ type BudgetFixtures,
16
+ type Fixtures,
17
+ defaultOptions,
18
+ deployFixtures,
19
+ freshBoost,
20
+ fundBudget,
21
+ } from '../../test/helpers';
22
+ import { StrategyType, prepareSignerValidatorClaimDataPayload } from '../utils';
23
+ import { ERC20Incentive } from './ERC20Incentive';
24
+
25
+ const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
26
+
27
+ let fixtures: Fixtures, budgets: BudgetFixtures;
28
+
29
+ describe('ERC20Incentive', () => {
30
+ beforeAll(async () => {
31
+ fixtures = await loadFixture(deployFixtures);
32
+ });
33
+
34
+ beforeEach(async () => {
35
+ budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
36
+ });
37
+
38
+ test('can successfully be deployed', async () => {
39
+ const action = new ERC20Incentive(defaultOptions, {
40
+ asset: zeroAddress,
41
+ strategy: StrategyType.POOL,
42
+ reward: 1n,
43
+ limit: 1n,
44
+ });
45
+ await action.deploy();
46
+ expect(isAddress(action.assertValidAddress())).toBe(true);
47
+ });
48
+
49
+ test('can claim', async () => {
50
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
51
+ const referrer = accounts.at(1)!.account!,
52
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
53
+ trustedSigner = accounts.at(0)!;
54
+ const erc20Incentive = new fixtures.bases.ERC20Incentive(defaultOptions, {
55
+ asset: budgets.erc20.assertValidAddress(),
56
+ strategy: StrategyType.POOL,
57
+ reward: 1n,
58
+ limit: 1n,
59
+ });
60
+ const boost = await freshBoost(fixtures, {
61
+ budget: budgets.budget,
62
+ incentives: [erc20Incentive],
63
+ });
64
+
65
+ const claimant = trustedSigner.account;
66
+ const incentiveData = pad('0xdef456232173821931823712381232131391321934');
67
+ const incentiveQuantity = 1;
68
+ const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
69
+ signer: trustedSigner,
70
+ incentiveData,
71
+ chainId: defaultOptions.config.chains[0].id,
72
+ validator: boost.validator.assertValidAddress(),
73
+ incentiveQuantity,
74
+ claimant,
75
+ boostId: boost.id,
76
+ });
77
+
78
+ await fixtures.core.claimIncentive(
79
+ boost.id,
80
+ 0n,
81
+ referrer,
82
+ claimDataPayload,
83
+ { value: BOOST_CORE_CLAIM_FEE },
84
+ );
85
+ expect(
86
+ await readMockErc20BalanceOf(defaultOptions.config, {
87
+ address: budgets.erc20.assertValidAddress(),
88
+ args: [defaultOptions.account.address],
89
+ }),
90
+ ).toBe(1n);
91
+ });
92
+
93
+ test('cannot claim twice', async () => {
94
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
95
+ const referrer = accounts.at(1)!.account!;
96
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
97
+ const trustedSigner = accounts.at(0)!;
98
+ const erc20Incentive = new fixtures.bases.ERC20Incentive(defaultOptions, {
99
+ asset: budgets.erc20.assertValidAddress(),
100
+ strategy: StrategyType.POOL,
101
+ reward: 1n,
102
+ limit: 1n,
103
+ });
104
+ const boost = await freshBoost(fixtures, {
105
+ budget: budgets.budget,
106
+ incentives: [erc20Incentive],
107
+ });
108
+
109
+ const claimant = trustedSigner.account;
110
+ const incentiveData = pad('0xdef456232173821931823712381232131391321934');
111
+ const incentiveQuantity = 1;
112
+ const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
113
+ signer: trustedSigner,
114
+ incentiveData,
115
+ chainId: defaultOptions.config.chains[0].id,
116
+ validator: boost.validator.assertValidAddress(),
117
+ incentiveQuantity,
118
+ claimant,
119
+ boostId: boost.id,
120
+ });
121
+
122
+ await fixtures.core.claimIncentive(
123
+ boost.id,
124
+ 0n,
125
+ referrer,
126
+ claimDataPayload,
127
+ { value: parseEther('0.000075') },
128
+ );
129
+ try {
130
+ await fixtures.core.claimIncentive(
131
+ boost.id,
132
+ 0n,
133
+ referrer,
134
+ claimDataPayload,
135
+ { value: parseEther('0.000075') },
136
+ );
137
+ } catch (e) {
138
+ expect(e).toBeInstanceOf(Error);
139
+ }
140
+ });
141
+ });