@boostxyz/sdk 0.0.0-alpha.8 → 0.0.0-alpha.9

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 (180) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.js +1 -1
  3. package/dist/Actions/ContractAction.d.ts +46 -3
  4. package/dist/Actions/ContractAction.d.ts.map +1 -1
  5. package/dist/Actions/ERC721MintAction.d.ts +37 -10
  6. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  7. package/dist/Actions/EventAction.cjs +1 -1
  8. package/dist/Actions/EventAction.cjs.map +1 -1
  9. package/dist/Actions/EventAction.d.ts +257 -12
  10. package/dist/Actions/EventAction.d.ts.map +1 -1
  11. package/dist/Actions/EventAction.js +249 -82
  12. package/dist/Actions/EventAction.js.map +1 -1
  13. package/dist/AllowLists/AllowList.cjs +1 -1
  14. package/dist/AllowLists/AllowList.js +1 -1
  15. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  16. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  17. package/dist/AllowLists/SimpleAllowList.d.ts +31 -2
  18. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  19. package/dist/AllowLists/SimpleAllowList.js +52 -37
  20. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  21. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  22. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
  23. package/dist/AllowLists/SimpleDenyList.d.ts +31 -2
  24. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  25. package/dist/AllowLists/SimpleDenyList.js +41 -129
  26. package/dist/AllowLists/SimpleDenyList.js.map +1 -1
  27. package/dist/Auth/PassthroughAuth.cjs +1 -1
  28. package/dist/Auth/PassthroughAuth.cjs.map +1 -1
  29. package/dist/Auth/PassthroughAuth.js +4 -4
  30. package/dist/Auth/PassthroughAuth.js.map +1 -1
  31. package/dist/Boost.cjs +1 -1
  32. package/dist/Boost.cjs.map +1 -1
  33. package/dist/Boost.d.ts +93 -1
  34. package/dist/Boost.d.ts.map +1 -1
  35. package/dist/Boost.js +151 -5
  36. package/dist/Boost.js.map +1 -1
  37. package/dist/BoostCore.cjs +2 -2
  38. package/dist/BoostCore.cjs.map +1 -1
  39. package/dist/BoostCore.d.ts +12 -6
  40. package/dist/BoostCore.d.ts.map +1 -1
  41. package/dist/BoostCore.js +168 -166
  42. package/dist/BoostCore.js.map +1 -1
  43. package/dist/BoostRegistry.cjs +1 -1
  44. package/dist/BoostRegistry.cjs.map +1 -1
  45. package/dist/BoostRegistry.d.ts +4 -4
  46. package/dist/BoostRegistry.d.ts.map +1 -1
  47. package/dist/BoostRegistry.js +19 -24
  48. package/dist/BoostRegistry.js.map +1 -1
  49. package/dist/Budgets/Budget.cjs +1 -1
  50. package/dist/Budgets/Budget.js +1 -1
  51. package/dist/Budgets/ManagedBudget.cjs +1 -1
  52. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  53. package/dist/Budgets/ManagedBudget.d.ts +40 -2
  54. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  55. package/dist/Budgets/ManagedBudget.js +53 -36
  56. package/dist/Budgets/ManagedBudget.js.map +1 -1
  57. package/dist/Budgets/SimpleBudget.d.ts +33 -2
  58. package/dist/Budgets/SimpleBudget.d.ts.map +1 -1
  59. package/dist/Budgets/VestingBudget.d.ts +54 -2
  60. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  61. package/dist/Deployable/Contract.cjs +1 -1
  62. package/dist/Deployable/Contract.cjs.map +1 -1
  63. package/dist/Deployable/Contract.js +1 -1
  64. package/dist/Deployable/Contract.js.map +1 -1
  65. package/dist/Deployable/DeployableTarget.cjs +1 -1
  66. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  67. package/dist/Deployable/DeployableTarget.js +3 -3
  68. package/dist/Deployable/DeployableTarget.js.map +1 -1
  69. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  70. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  71. package/dist/Incentives/AllowListIncentive.d.ts +35 -5
  72. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  73. package/dist/Incentives/AllowListIncentive.js +33 -21
  74. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  75. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  76. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  77. package/dist/Incentives/CGDAIncentive.d.ts +89 -5
  78. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  79. package/dist/Incentives/CGDAIncentive.js +44 -23
  80. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  81. package/dist/Incentives/ERC1155Incentive.d.ts +67 -6
  82. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  83. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  84. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  85. package/dist/Incentives/ERC20Incentive.d.ts +49 -5
  86. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  87. package/dist/Incentives/ERC20Incentive.js +46 -27
  88. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  89. package/dist/Incentives/ERC20VariableIncentive.d.ts +42 -5
  90. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  91. package/dist/Incentives/Incentive.cjs +1 -1
  92. package/dist/Incentives/Incentive.cjs.map +1 -1
  93. package/dist/Incentives/Incentive.js +48 -32
  94. package/dist/Incentives/Incentive.js.map +1 -1
  95. package/dist/Incentives/PointsIncentive.cjs +1 -1
  96. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  97. package/dist/Incentives/PointsIncentive.d.ts +49 -5
  98. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  99. package/dist/Incentives/PointsIncentive.js +38 -21
  100. package/dist/Incentives/PointsIncentive.js.map +1 -1
  101. package/dist/Validators/SignerValidator.cjs +1 -1
  102. package/dist/Validators/SignerValidator.cjs.map +1 -1
  103. package/dist/Validators/SignerValidator.d.ts +298 -5
  104. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  105. package/dist/Validators/SignerValidator.js +151 -26
  106. package/dist/Validators/SignerValidator.js.map +1 -1
  107. package/dist/Validators/Validator.cjs +1 -1
  108. package/dist/Validators/Validator.js +1 -1
  109. package/dist/claiming.cjs +2 -0
  110. package/dist/claiming.cjs.map +1 -0
  111. package/dist/claiming.d.ts +43 -0
  112. package/dist/claiming.d.ts.map +1 -0
  113. package/dist/claiming.js +17 -0
  114. package/dist/claiming.js.map +1 -0
  115. package/dist/errors.cjs.map +1 -1
  116. package/dist/errors.d.ts +1 -1
  117. package/dist/errors.d.ts.map +1 -1
  118. package/dist/errors.js.map +1 -1
  119. package/dist/{generated-Cbv8zFkf.js → generated-57_Kffpz.js} +8 -5
  120. package/dist/generated-57_Kffpz.js.map +1 -0
  121. package/dist/{generated-BzszviNp.cjs → generated-wKBNvm48.cjs} +2 -2
  122. package/dist/generated-wKBNvm48.cjs.map +1 -0
  123. package/dist/index.cjs +1 -1
  124. package/dist/index.d.ts +4 -4
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +108 -125
  127. package/dist/transfers.cjs +2 -0
  128. package/dist/transfers.cjs.map +1 -0
  129. package/dist/transfers.d.ts +198 -0
  130. package/dist/transfers.d.ts.map +1 -0
  131. package/dist/transfers.js +84 -0
  132. package/dist/transfers.js.map +1 -0
  133. package/dist/utils.cjs +1 -1
  134. package/dist/utils.cjs.map +1 -1
  135. package/dist/utils.d.ts +2 -1371
  136. package/dist/utils.d.ts.map +1 -1
  137. package/dist/utils.js +26 -653
  138. package/dist/utils.js.map +1 -1
  139. package/package.json +17 -3
  140. package/src/Actions/Action.test.ts +5 -4
  141. package/src/Actions/ContractAction.test.ts +4 -6
  142. package/src/Actions/ContractAction.ts +73 -10
  143. package/src/Actions/ERC721MintAction.test.ts +2 -2
  144. package/src/Actions/ERC721MintAction.ts +70 -16
  145. package/src/Actions/EventAction.test.ts +43 -17
  146. package/src/Actions/EventAction.ts +452 -35
  147. package/src/AllowLists/SimpleAllowList.ts +48 -5
  148. package/src/AllowLists/SimpleDenyList.ts +47 -109
  149. package/src/Auth/PassthroughAuth.ts +1 -1
  150. package/src/Boost.ts +136 -1
  151. package/src/BoostCore.test.ts +4 -11
  152. package/src/BoostCore.ts +39 -33
  153. package/src/BoostRegistry.ts +19 -22
  154. package/src/Budgets/ManagedBudget.ts +69 -16
  155. package/src/Budgets/SimpleBudget.ts +57 -14
  156. package/src/Budgets/VestingBudget.ts +79 -9
  157. package/src/Deployable/Contract.ts +1 -1
  158. package/src/Deployable/DeployableTarget.ts +2 -2
  159. package/src/Incentives/AllowListIncentive.test.ts +2 -5
  160. package/src/Incentives/AllowListIncentive.ts +59 -15
  161. package/src/Incentives/CGDAIncentive.test.ts +3 -7
  162. package/src/Incentives/CGDAIncentive.ts +123 -19
  163. package/src/Incentives/ERC1155Incentive.test.ts +2 -13
  164. package/src/Incentives/ERC1155Incentive.ts +104 -22
  165. package/src/Incentives/ERC20Incentive.test.ts +6 -17
  166. package/src/Incentives/ERC20Incentive.ts +86 -21
  167. package/src/Incentives/ERC20VariableIncentive.test.ts +4 -24
  168. package/src/Incentives/ERC20VariableIncentive.ts +71 -19
  169. package/src/Incentives/Incentive.test.ts +1 -1
  170. package/src/Incentives/PointsIncentive.test.ts +3 -6
  171. package/src/Incentives/PointsIncentive.ts +79 -17
  172. package/src/Validators/SignerValidator.test.ts +3 -7
  173. package/src/Validators/SignerValidator.ts +422 -13
  174. package/src/claiming.ts +56 -0
  175. package/src/errors.ts +1 -1
  176. package/src/index.ts +10 -7
  177. package/src/transfers.ts +284 -0
  178. package/src/utils.ts +3 -2052
  179. package/dist/generated-BzszviNp.cjs.map +0 -1
  180. package/dist/generated-Cbv8zFkf.js.map +0 -1
@@ -16,7 +16,13 @@ import {
16
16
  writeErc1155IncentiveClawback,
17
17
  } from '@boostxyz/evm';
18
18
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC1155Incentive.sol/ERC1155Incentive.json';
19
- import type { Address, ContractEventName, Hex } from 'viem';
19
+ import {
20
+ type Address,
21
+ type ContractEventName,
22
+ type Hex,
23
+ encodeAbiParameters,
24
+ parseAbiParameters,
25
+ } from 'viem';
20
26
  import type {
21
27
  DeployableOptions,
22
28
  GenericDeployableParams,
@@ -24,19 +30,68 @@ import type {
24
30
  import { DeployableTarget } from '../Deployable/DeployableTarget';
25
31
  import {
26
32
  type ClaimPayload,
27
- type ERC1155IncentivePayload,
28
- ERC1155StrategyType,
33
+ type StrategyType,
34
+ prepareClaimPayload,
35
+ } from '../claiming';
36
+ import {
29
37
  type GenericLog,
30
38
  type ReadParams,
31
39
  RegistryType,
32
- type StrategyType,
33
40
  type WriteParams,
34
- prepareClaimPayload,
35
- prepareERC1155IncentivePayload,
36
41
  } from '../utils';
37
42
 
38
- export { ERC1155StrategyType, erc1155IncentiveAbi };
39
- export type { ERC1155IncentivePayload };
43
+ export { erc1155IncentiveAbi };
44
+
45
+ /**
46
+ * Enum representing inventive disbursement strategies for {@link ERC1155Incentive}
47
+ *
48
+ * @export
49
+ * @enum {number}
50
+ */
51
+ export enum ERC1155StrategyType {
52
+ POOL = 0,
53
+ MINT = 1,
54
+ }
55
+
56
+ /**
57
+ * The object representation of a `ERC1155Incentive.InitPayload`
58
+ *
59
+ * @export
60
+ * @interface ERC1155IncentivePayload
61
+ * @typedef {ERC1155IncentivePayload}
62
+ */
63
+ export interface ERC1155IncentivePayload {
64
+ /**
65
+ * The address of the `ERC1155` asset
66
+ *
67
+ * @type {Address}
68
+ */
69
+ asset: Address;
70
+ /**
71
+ * Should be `Strategy.POOL`
72
+ *
73
+ * @type {ERC1155StrategyType}
74
+ */
75
+ strategy: ERC1155StrategyType;
76
+ /**
77
+ * The token ID to target
78
+ *
79
+ * @type {bigint}
80
+ */
81
+ tokenId: bigint;
82
+ /**
83
+ * The maximum number of claims that can be made (one per address)
84
+ *
85
+ * @type {bigint}
86
+ */
87
+ limit: bigint;
88
+ /**
89
+ * Any extra data to accompany the claim, if applicable.
90
+ *
91
+ * @type {Hex}
92
+ */
93
+ extraData: Hex;
94
+ }
40
95
 
41
96
  /**
42
97
  * A generic `viem.Log` event with support for `ERC1155Incentive` event types.
@@ -96,7 +151,7 @@ export class ERC1155Incentive extends DeployableTarget<
96
151
  public async claims(
97
152
  params?: ReadParams<typeof erc1155IncentiveAbi, 'claims'>,
98
153
  ) {
99
- return readErc1155IncentiveClaims(this._config, {
154
+ return await readErc1155IncentiveClaims(this._config, {
100
155
  address: this.assertValidAddress(),
101
156
  args: [],
102
157
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -115,7 +170,7 @@ export class ERC1155Incentive extends DeployableTarget<
115
170
  public async reward(
116
171
  params?: ReadParams<typeof erc1155IncentiveAbi, 'reward'>,
117
172
  ) {
118
- return readErc1155IncentiveReward(this._config, {
173
+ return await readErc1155IncentiveReward(this._config, {
119
174
  address: this.assertValidAddress(),
120
175
  args: [],
121
176
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -136,7 +191,7 @@ export class ERC1155Incentive extends DeployableTarget<
136
191
  address: Address,
137
192
  params?: ReadParams<typeof erc1155IncentiveAbi, 'claimed'>,
138
193
  ) {
139
- return readErc1155IncentiveClaimed(this._config, {
194
+ return await readErc1155IncentiveClaimed(this._config, {
140
195
  address: this.assertValidAddress(),
141
196
  args: [address],
142
197
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -153,7 +208,7 @@ export class ERC1155Incentive extends DeployableTarget<
153
208
  * @returns {unknown}
154
209
  */
155
210
  public async asset(params?: ReadParams<typeof erc1155IncentiveAbi, 'asset'>) {
156
- return readErc1155IncentiveAsset(this._config, {
211
+ return await readErc1155IncentiveAsset(this._config, {
157
212
  address: this.assertValidAddress(),
158
213
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
159
214
  ...(params as any),
@@ -168,7 +223,7 @@ export class ERC1155Incentive extends DeployableTarget<
168
223
  * @param {?ReadParams<typeof erc1155IncentiveAbi, 'strategy'>} [params]
169
224
  * @returns {Promise<StrategyType>}
170
225
  */
171
- public async strategy(
226
+ public strategy(
172
227
  params?: ReadParams<typeof erc1155IncentiveAbi, 'strategy'>,
173
228
  ): Promise<StrategyType> {
174
229
  return readErc1155IncentiveStrategy(this._config, {
@@ -187,7 +242,7 @@ export class ERC1155Incentive extends DeployableTarget<
187
242
  * @returns {unknown}
188
243
  */
189
244
  public async limit(params?: ReadParams<typeof erc1155IncentiveAbi, 'limit'>) {
190
- return readErc1155IncentiveLimit(this._config, {
245
+ return await readErc1155IncentiveLimit(this._config, {
191
246
  address: this.assertValidAddress(),
192
247
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
193
248
  ...(params as any),
@@ -205,7 +260,7 @@ export class ERC1155Incentive extends DeployableTarget<
205
260
  public async tokenId(
206
261
  params?: ReadParams<typeof erc1155IncentiveAbi, 'tokenId'>,
207
262
  ) {
208
- return readErc1155IncentiveTokenId(this._config, {
263
+ return await readErc1155IncentiveTokenId(this._config, {
209
264
  address: this.assertValidAddress(),
210
265
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
211
266
  ...(params as any),
@@ -223,7 +278,7 @@ export class ERC1155Incentive extends DeployableTarget<
223
278
  public async extraData(
224
279
  params?: ReadParams<typeof erc1155IncentiveAbi, 'extraData'>,
225
280
  ) {
226
- return readErc1155IncentiveExtraData(this._config, {
281
+ return await readErc1155IncentiveExtraData(this._config, {
227
282
  address: this.assertValidAddress(),
228
283
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
229
284
  ...(params as any),
@@ -239,11 +294,11 @@ export class ERC1155Incentive extends DeployableTarget<
239
294
  * @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
240
295
  * @returns {unknown}
241
296
  */
242
- public async claim(
297
+ protected async claim(
243
298
  payload: ClaimPayload,
244
299
  params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
245
300
  ) {
246
- return this.awaitResult(this.claimRaw(payload, params));
301
+ return await this.awaitResult(this.claimRaw(payload, params));
247
302
  }
248
303
 
249
304
  /**
@@ -255,7 +310,7 @@ export class ERC1155Incentive extends DeployableTarget<
255
310
  * @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
256
311
  * @returns {unknown}
257
312
  */
258
- public async claimRaw(
313
+ protected async claimRaw(
259
314
  payload: ClaimPayload,
260
315
  params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
261
316
  ) {
@@ -286,7 +341,7 @@ export class ERC1155Incentive extends DeployableTarget<
286
341
  payload: ClaimPayload,
287
342
  params?: WriteParams<typeof erc1155IncentiveAbi, 'clawback'>,
288
343
  ) {
289
- return this.awaitResult(this.clawbackRaw(payload, params));
344
+ return await this.awaitResult(this.clawbackRaw(payload, params));
290
345
  }
291
346
 
292
347
  /**
@@ -329,7 +384,7 @@ export class ERC1155Incentive extends DeployableTarget<
329
384
  payload: ClaimPayload,
330
385
  params?: ReadParams<typeof erc1155IncentiveAbi, 'isClaimable'>,
331
386
  ) {
332
- return readErc1155IncentiveIsClaimable(this._config, {
387
+ return await readErc1155IncentiveIsClaimable(this._config, {
333
388
  address: this.assertValidAddress(),
334
389
  args: [prepareClaimPayload(payload)],
335
390
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -350,7 +405,7 @@ export class ERC1155Incentive extends DeployableTarget<
350
405
  data: ERC1155IncentivePayload,
351
406
  params?: ReadParams<typeof erc1155IncentiveAbi, 'preflight'>,
352
407
  ) {
353
- return readErc1155IncentivePreflight(this._config, {
408
+ return await readErc1155IncentivePreflight(this._config, {
354
409
  address: this.assertValidAddress(),
355
410
  args: [prepareERC1155IncentivePayload(data)],
356
411
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -382,3 +437,30 @@ export class ERC1155Incentive extends DeployableTarget<
382
437
  };
383
438
  }
384
439
  }
440
+
441
+ /**
442
+ * Given a {@link ERC1155IncentivePayload}, properly encode a `ERC1155Incentive.InitPayload` for use with {@link ERC1155Incentive} initialization.
443
+ *
444
+ * @param {ERC1155IncentivePayload} param0
445
+ * @param {Address} param0.asset - The address of the `ERC1155` asset
446
+ * @param {ERC1155StrategyType} param0.strategy - Should be `Strategy.POOL`
447
+ * @param {bigint} param0.tokenId - The token ID to target
448
+ * @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
449
+ * @param {Hex} param0.extraData - Any extra data to accompany the claim, if applicable.
450
+ * @returns {Hex}
451
+ */
452
+ export const prepareERC1155IncentivePayload = ({
453
+ asset,
454
+ strategy,
455
+ tokenId,
456
+ limit,
457
+ extraData,
458
+ }: ERC1155IncentivePayload) => {
459
+ return encodeAbiParameters(
460
+ parseAbiParameters([
461
+ 'InitPayload payload',
462
+ 'struct InitPayload { address asset; uint8 strategy; uint256 tokenId; uint256 limit; bytes extraData; }',
463
+ ]),
464
+ [{ asset, strategy, tokenId, limit, extraData }],
465
+ );
466
+ };
@@ -1,14 +1,6 @@
1
1
  import { readMockErc20BalanceOf } from '@boostxyz/evm';
2
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';
3
+ import { isAddress, pad, parseEther, zeroAddress } from 'viem';
12
4
  import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
13
5
  import { accounts } from '../../test/accounts';
14
6
  import {
@@ -19,11 +11,10 @@ import {
19
11
  freshBoost,
20
12
  fundBudget,
21
13
  } from '../../test/helpers';
22
- import { StrategyType, prepareSignerValidatorClaimDataPayload } from '../utils';
14
+ import { BOOST_CORE_CLAIM_FEE } from '../BoostCore';
15
+ import { StrategyType } from '../claiming';
23
16
  import { ERC20Incentive } from './ERC20Incentive';
24
17
 
25
- const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
26
-
27
18
  let fixtures: Fixtures, budgets: BudgetFixtures;
28
19
 
29
20
  describe('ERC20Incentive', () => {
@@ -65,11 +56,10 @@ describe('ERC20Incentive', () => {
65
56
  const claimant = trustedSigner.account;
66
57
  const incentiveData = pad('0xdef456232173821931823712381232131391321934');
67
58
  const incentiveQuantity = 1;
68
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
59
+ const claimDataPayload = await boost.validator.encodeClaimData({
69
60
  signer: trustedSigner,
70
61
  incentiveData,
71
62
  chainId: defaultOptions.config.chains[0].id,
72
- validator: boost.validator.assertValidAddress(),
73
63
  incentiveQuantity,
74
64
  claimant,
75
65
  boostId: boost.id,
@@ -109,11 +99,10 @@ describe('ERC20Incentive', () => {
109
99
  const claimant = trustedSigner.account;
110
100
  const incentiveData = pad('0xdef456232173821931823712381232131391321934');
111
101
  const incentiveQuantity = 1;
112
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
102
+ const claimDataPayload = await boost.validator.encodeClaimData({
113
103
  signer: trustedSigner,
114
104
  incentiveData,
115
105
  chainId: defaultOptions.config.chains[0].id,
116
- validator: boost.validator.assertValidAddress(),
117
106
  incentiveQuantity,
118
107
  claimant,
119
108
  boostId: boost.id,
@@ -124,7 +113,7 @@ describe('ERC20Incentive', () => {
124
113
  0n,
125
114
  referrer,
126
115
  claimDataPayload,
127
- { value: parseEther('0.000075') },
116
+ { value: BOOST_CORE_CLAIM_FEE },
128
117
  );
129
118
  try {
130
119
  await fixtures.core.claimIncentive(
@@ -18,7 +18,12 @@ import {
18
18
  writeErc20IncentiveDrawRaffle,
19
19
  } from '@boostxyz/evm';
20
20
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20Incentive.sol/ERC20Incentive.json';
21
- import type { Address, ContractEventName, Hex } from 'viem';
21
+ import {
22
+ type Address,
23
+ type ContractEventName,
24
+ type Hex,
25
+ encodeAbiParameters,
26
+ } from 'viem';
22
27
  import type {
23
28
  DeployableOptions,
24
29
  GenericDeployableParams,
@@ -26,18 +31,51 @@ import type {
26
31
  import { DeployableTarget } from '../Deployable/DeployableTarget';
27
32
  import {
28
33
  type ClaimPayload,
29
- type ERC20IncentivePayload,
34
+ type StrategyType,
35
+ prepareClaimPayload,
36
+ } from '../claiming';
37
+ import {
30
38
  type GenericLog,
31
39
  type ReadParams,
32
40
  RegistryType,
33
- type StrategyType,
34
41
  type WriteParams,
35
- prepareClaimPayload,
36
- prepareERC20IncentivePayload,
37
42
  } from '../utils';
38
43
 
39
44
  export { erc20IncentiveAbi };
40
- export type { ERC20IncentivePayload };
45
+
46
+ /**
47
+ * The object representation of a `ERC20Incentive.InitPayload`
48
+ *
49
+ * @export
50
+ * @interface ERC20IncentivePayload
51
+ * @typedef {ERC20IncentivePayload}
52
+ */
53
+ export interface ERC20IncentivePayload {
54
+ /**
55
+ * The address of the incentivized asset.
56
+ *
57
+ * @type {Address}
58
+ */
59
+ asset: Address;
60
+ /**
61
+ * The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
62
+ *
63
+ * @type {StrategyType}
64
+ */
65
+ strategy: StrategyType;
66
+ /**
67
+ * The amount of the asset to distribute.
68
+ *
69
+ * @type {bigint}
70
+ */
71
+ reward: bigint;
72
+ /**
73
+ * How many times can this incentive be claimed.
74
+ *
75
+ * @type {bigint}
76
+ */
77
+ limit: bigint;
78
+ }
41
79
 
42
80
  /**
43
81
  * A generic `viem.Log` event with support for `ERC20Incentive` event types.
@@ -94,7 +132,7 @@ export class ERC20Incentive extends DeployableTarget<
94
132
  * @returns {unknown}
95
133
  */
96
134
  public async owner(params?: ReadParams<typeof erc20IncentiveAbi, 'owner'>) {
97
- return readErc20IncentiveOwner(this._config, {
135
+ return await readErc20IncentiveOwner(this._config, {
98
136
  address: this.assertValidAddress(),
99
137
  args: [],
100
138
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -113,7 +151,7 @@ export class ERC20Incentive extends DeployableTarget<
113
151
  public async currentReward(
114
152
  params?: ReadParams<typeof erc20IncentiveAbi, 'currentReward'>,
115
153
  ) {
116
- return readErc20IncentiveCurrentReward(this._config, {
154
+ return await readErc20IncentiveCurrentReward(this._config, {
117
155
  address: this.assertValidAddress(),
118
156
  args: [],
119
157
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -130,7 +168,7 @@ export class ERC20Incentive extends DeployableTarget<
130
168
  * @returns {Promise<bigint>}
131
169
  */
132
170
  public async claims(params?: ReadParams<typeof erc20IncentiveAbi, 'claims'>) {
133
- return readErc20IncentiveClaims(this._config, {
171
+ return await readErc20IncentiveClaims(this._config, {
134
172
  address: this.assertValidAddress(),
135
173
  args: [],
136
174
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -151,7 +189,7 @@ export class ERC20Incentive extends DeployableTarget<
151
189
  address: Address,
152
190
  params?: ReadParams<typeof erc20IncentiveAbi, 'claimed'>,
153
191
  ) {
154
- return readErc20IncentiveClaimed(this._config, {
192
+ return await readErc20IncentiveClaimed(this._config, {
155
193
  address: this.assertValidAddress(),
156
194
  args: [address],
157
195
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -168,7 +206,7 @@ export class ERC20Incentive extends DeployableTarget<
168
206
  * @returns {Promise<Address>}
169
207
  */
170
208
  public async asset(params?: ReadParams<typeof erc20IncentiveAbi, 'asset'>) {
171
- return readErc20IncentiveAsset(this._config, {
209
+ return await readErc20IncentiveAsset(this._config, {
172
210
  address: this.assertValidAddress(),
173
211
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
174
212
  ...(params as any),
@@ -183,7 +221,7 @@ export class ERC20Incentive extends DeployableTarget<
183
221
  * @param {?ReadParams<typeof erc20IncentiveAbi, 'strategy'>} [params]
184
222
  * @returns {Promise<StrategyType>}
185
223
  */
186
- public async strategy(
224
+ public strategy(
187
225
  params?: ReadParams<typeof erc20IncentiveAbi, 'strategy'>,
188
226
  ): Promise<StrategyType> {
189
227
  return readErc20IncentiveStrategy(this._config, {
@@ -202,7 +240,7 @@ export class ERC20Incentive extends DeployableTarget<
202
240
  * @returns {Promise<bigint>}
203
241
  */
204
242
  public async reward(params?: ReadParams<typeof erc20IncentiveAbi, 'reward'>) {
205
- return readErc20IncentiveReward(this._config, {
243
+ return await readErc20IncentiveReward(this._config, {
206
244
  address: this.assertValidAddress(),
207
245
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
208
246
  ...(params as any),
@@ -218,7 +256,7 @@ export class ERC20Incentive extends DeployableTarget<
218
256
  * @returns {unknown}
219
257
  */
220
258
  public async limit(params?: ReadParams<typeof erc20IncentiveAbi, 'limit'>) {
221
- return readErc20IncentiveLimit(this._config, {
259
+ return await readErc20IncentiveLimit(this._config, {
222
260
  address: this.assertValidAddress(),
223
261
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
224
262
  ...(params as any),
@@ -238,7 +276,7 @@ export class ERC20Incentive extends DeployableTarget<
238
276
  i: bigint,
239
277
  params?: ReadParams<typeof erc20IncentiveAbi, 'entries'>,
240
278
  ) {
241
- return readErc20IncentiveEntries(this._config, {
279
+ return await readErc20IncentiveEntries(this._config, {
242
280
  address: this.assertValidAddress(),
243
281
  args: [i],
244
282
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -255,11 +293,11 @@ export class ERC20Incentive extends DeployableTarget<
255
293
  * @param {?WriteParams<typeof erc20IncentiveAbi, 'claim'>} [params]
256
294
  * @returns {Promise<boolean>} - Returns true if successfully claimed
257
295
  */
258
- public async claim(
296
+ protected async claim(
259
297
  payload: ClaimPayload,
260
298
  params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
261
299
  ) {
262
- return this.awaitResult(this.claimRaw(payload, params));
300
+ return await this.awaitResult(this.claimRaw(payload, params));
263
301
  }
264
302
 
265
303
  /**
@@ -271,7 +309,7 @@ export class ERC20Incentive extends DeployableTarget<
271
309
  * @param {?WriteParams<typeof erc20IncentiveAbi, 'claim'>} [params]
272
310
  * @returns {Promise<boolean>} - Returns true if successfully claimed
273
311
  */
274
- public async claimRaw(
312
+ protected async claimRaw(
275
313
  payload: ClaimPayload,
276
314
  params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
277
315
  ) {
@@ -302,7 +340,7 @@ export class ERC20Incentive extends DeployableTarget<
302
340
  payload: ClaimPayload,
303
341
  params?: WriteParams<typeof erc20IncentiveAbi, 'clawback'>,
304
342
  ) {
305
- return this.awaitResult(this.clawbackRaw(payload, params));
343
+ return await this.awaitResult(this.clawbackRaw(payload, params));
306
344
  }
307
345
 
308
346
  /**
@@ -345,7 +383,7 @@ export class ERC20Incentive extends DeployableTarget<
345
383
  payload: ClaimPayload,
346
384
  params?: ReadParams<typeof erc20IncentiveAbi, 'isClaimable'>,
347
385
  ) {
348
- return readErc20IncentiveIsClaimable(this._config, {
386
+ return await readErc20IncentiveIsClaimable(this._config, {
349
387
  address: this.assertValidAddress(),
350
388
  args: [prepareClaimPayload(payload)],
351
389
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -364,7 +402,7 @@ export class ERC20Incentive extends DeployableTarget<
364
402
  public async drawRaffle(
365
403
  params?: WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>,
366
404
  ) {
367
- return this.awaitResult(this.drawRaffleRaw(params));
405
+ return await this.awaitResult(this.drawRaffleRaw(params));
368
406
  }
369
407
 
370
408
  /**
@@ -415,3 +453,30 @@ export class ERC20Incentive extends DeployableTarget<
415
453
  };
416
454
  }
417
455
  }
456
+
457
+ /**
458
+ * Given a {@link ERC20IncentivePayload}, properly encode a `ERC20Incentive.InitPayload` for use with {@link ERC20Incentive} initialization.
459
+ *
460
+ * @param {ERC20IncentivePayload} param0
461
+ * @param {Address} param0.asset - The address of the incentivized asset.
462
+ * @param {StrategyType} param0.strategy - The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
463
+ * @param {bigint} param0.reward - The amount of the asset to distribute.
464
+ * @param {bigint} param0.limit - How many times can this incentive be claimed.
465
+ * @returns {*}
466
+ */
467
+ export function prepareERC20IncentivePayload({
468
+ asset,
469
+ strategy,
470
+ reward,
471
+ limit,
472
+ }: ERC20IncentivePayload) {
473
+ return encodeAbiParameters(
474
+ [
475
+ { type: 'address', name: 'asset' },
476
+ { type: 'uint8', name: 'strategy' },
477
+ { type: 'uint256', name: 'reward' },
478
+ { type: 'uint256', name: 'limit' },
479
+ ],
480
+ [asset, strategy, reward, limit],
481
+ );
482
+ }
@@ -1,19 +1,6 @@
1
- import {
2
- readMockErc20BalanceOf,
3
- readMockErc20TotalSupply,
4
- } from '@boostxyz/evm';
1
+ import { readMockErc20BalanceOf } from '@boostxyz/evm';
5
2
  import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
6
- import { signMessage } from '@wagmi/core';
7
- import {
8
- encodeAbiParameters,
9
- encodePacked,
10
- isAddress,
11
- keccak256,
12
- pad,
13
- parseEther,
14
- zeroAddress,
15
- } from 'viem';
16
- import { toHex } from 'viem';
3
+ import { encodeAbiParameters, isAddress, parseEther, zeroAddress } from 'viem';
17
4
  import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
18
5
  import { accounts } from '../../test/accounts';
19
6
  import {
@@ -24,11 +11,6 @@ import {
24
11
  freshBoost,
25
12
  fundBudget,
26
13
  } from '../../test/helpers';
27
- import {
28
- StrategyType,
29
- prepareClaimPayload,
30
- prepareSignerValidatorClaimDataPayload,
31
- } from '../utils';
32
14
  import { ERC20VariableIncentive } from './ERC20VariableIncentive';
33
15
 
34
16
  const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
@@ -74,14 +56,13 @@ describe('ERC20VariableIncentive', () => {
74
56
 
75
57
  const claimant = trustedSigner.account;
76
58
  const incentiveQuantity = 1;
77
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
59
+ const claimDataPayload = await boost.validator.encodeClaimData({
78
60
  signer: trustedSigner,
79
61
  incentiveData: encodeAbiParameters(
80
62
  [{ name: '', type: 'uint256' }],
81
63
  [parseEther('1')],
82
64
  ),
83
65
  chainId: defaultOptions.config.chains[0].id,
84
- validator: boost.validator.assertValidAddress(),
85
66
  incentiveQuantity,
86
67
  claimant,
87
68
  boostId: boost.id,
@@ -121,14 +102,13 @@ describe('ERC20VariableIncentive', () => {
121
102
 
122
103
  const claimant = trustedSigner.account;
123
104
  const incentiveQuantity = 1;
124
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
105
+ const claimDataPayload = await boost.validator.encodeClaimData({
125
106
  signer: trustedSigner,
126
107
  incentiveData: encodeAbiParameters(
127
108
  [{ name: '', type: 'uint256' }],
128
109
  [parseEther('1')],
129
110
  ),
130
111
  chainId: defaultOptions.config.chains[0].id,
131
- validator: boost.validator.assertValidAddress(),
132
112
  incentiveQuantity,
133
113
  claimant,
134
114
  boostId: boost.id,