@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
@@ -15,25 +15,53 @@ 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';
19
24
  import type {
20
25
  DeployableOptions,
21
26
  GenericDeployableParams,
22
27
  } from '../Deployable/Deployable';
23
28
  import { DeployableTarget } from '../Deployable/DeployableTarget';
29
+ import { type ClaimPayload, prepareClaimPayload } from '../claiming';
24
30
  import {
25
- type ClaimPayload,
26
- type ERC20VariableIncentivePayload,
27
31
  type GenericLog,
28
32
  type ReadParams,
29
33
  RegistryType,
30
34
  type WriteParams,
31
- prepareClaimPayload,
32
- prepareERC20VariableIncentivePayload,
33
35
  } from '../utils';
34
36
 
35
37
  export { erc20VariableIncentiveAbi };
36
- export type { ERC20VariableIncentivePayload };
38
+ /**
39
+ * The object representation of a `ERC20VariableIncentivePayload.InitPayload`
40
+ *
41
+ * @export
42
+ * @interface ERC20VariableIncentivePayload
43
+ * @typedef {ERC20VariableIncentivePayload}
44
+ */
45
+ export interface ERC20VariableIncentivePayload {
46
+ /**
47
+ * The address of the incentivized asset.
48
+ *
49
+ * @type {Address}
50
+ */
51
+ asset: Address;
52
+ /**
53
+ * The amount of the asset to distribute.
54
+ *
55
+ * @type {bigint}
56
+ */
57
+ reward: bigint;
58
+ /**
59
+ * How many times can this incentive be claimed.
60
+ *
61
+ * @type {bigint}
62
+ */
63
+ limit: bigint;
64
+ }
37
65
 
38
66
  /**
39
67
  * A generic `viem.Log` event with support for `ERC20VariableIncentive` event types.
@@ -92,7 +120,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
92
120
  public async owner(
93
121
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'owner'>,
94
122
  ) {
95
- return readErc20VariableIncentiveOwner(this._config, {
123
+ return await readErc20VariableIncentiveOwner(this._config, {
96
124
  address: this.assertValidAddress(),
97
125
  args: [],
98
126
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -111,7 +139,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
111
139
  public async totalClaimed(
112
140
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'totalClaimed'>,
113
141
  ) {
114
- return readErc20VariableIncentiveTotalClaimed(this._config, {
142
+ return await readErc20VariableIncentiveTotalClaimed(this._config, {
115
143
  address: this.assertValidAddress(),
116
144
  args: [],
117
145
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -130,7 +158,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
130
158
  public async currentReward(
131
159
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'currentReward'>,
132
160
  ) {
133
- return readErc20VariableIncentiveCurrentReward(this._config, {
161
+ return await readErc20VariableIncentiveCurrentReward(this._config, {
134
162
  address: this.assertValidAddress(),
135
163
  args: [],
136
164
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -149,7 +177,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
149
177
  public async claims(
150
178
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claims'>,
151
179
  ) {
152
- return readErc20VariableIncentiveClaims(this._config, {
180
+ return await readErc20VariableIncentiveClaims(this._config, {
153
181
  address: this.assertValidAddress(),
154
182
  args: [],
155
183
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -170,7 +198,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
170
198
  address: Address,
171
199
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claimed'>,
172
200
  ) {
173
- return readErc20VariableIncentiveClaimed(this._config, {
201
+ return await readErc20VariableIncentiveClaimed(this._config, {
174
202
  address: this.assertValidAddress(),
175
203
  args: [address],
176
204
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -189,7 +217,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
189
217
  public async asset(
190
218
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'asset'>,
191
219
  ) {
192
- return readErc20VariableIncentiveAsset(this._config, {
220
+ return await readErc20VariableIncentiveAsset(this._config, {
193
221
  address: this.assertValidAddress(),
194
222
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
195
223
  ...(params as any),
@@ -207,7 +235,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
207
235
  public async reward(
208
236
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'reward'>,
209
237
  ) {
210
- return readErc20VariableIncentiveReward(this._config, {
238
+ return await readErc20VariableIncentiveReward(this._config, {
211
239
  address: this.assertValidAddress(),
212
240
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
213
241
  ...(params as any),
@@ -225,7 +253,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
225
253
  public async limit(
226
254
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'limit'>,
227
255
  ) {
228
- return readErc20VariableIncentiveLimit(this._config, {
256
+ return await readErc20VariableIncentiveLimit(this._config, {
229
257
  address: this.assertValidAddress(),
230
258
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
231
259
  ...(params as any),
@@ -241,11 +269,11 @@ export class ERC20VariableIncentive extends DeployableTarget<
241
269
  * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
242
270
  * @returns {Promise<boolean>} - Returns true if successfully claimed
243
271
  */
244
- public async claim(
272
+ protected async claim(
245
273
  payload: ClaimPayload,
246
274
  params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
247
275
  ) {
248
- return this.awaitResult(this.claimRaw(payload, params));
276
+ return await this.awaitResult(this.claimRaw(payload, params));
249
277
  }
250
278
 
251
279
  /**
@@ -257,7 +285,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
257
285
  * @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
258
286
  * @returns {Promise<boolean>} - Returns true if successfully claimed
259
287
  */
260
- public async claimRaw(
288
+ protected async claimRaw(
261
289
  payload: ClaimPayload,
262
290
  params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
263
291
  ) {
@@ -288,7 +316,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
288
316
  payload: ClaimPayload,
289
317
  params?: WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>,
290
318
  ) {
291
- return this.awaitResult(this.clawbackRaw(payload, params));
319
+ return await this.awaitResult(this.clawbackRaw(payload, params));
292
320
  }
293
321
 
294
322
  /**
@@ -334,7 +362,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
334
362
  payload: ClaimPayload,
335
363
  params?: ReadParams<typeof erc20VariableIncentiveAbi, 'isClaimable'>,
336
364
  ) {
337
- return readErc20VariableIncentiveIsClaimable(this._config, {
365
+ return await readErc20VariableIncentiveIsClaimable(this._config, {
338
366
  address: this.assertValidAddress(),
339
367
  args: [prepareClaimPayload(payload)],
340
368
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -366,3 +394,27 @@ export class ERC20VariableIncentive extends DeployableTarget<
366
394
  };
367
395
  }
368
396
  }
397
+
398
+ /**
399
+ * Given a {@link ERC20VariableIncentivePayload}, properly encode a ` ERC20VariableIncentive.InitPayload` for use with {@link ERC20VariableIncentive} initialization.
400
+ *
401
+ * @param {ERC20VariableIncentivePayload} param0
402
+ * @param {Address} param0.asset - The address of the incentivized asset.
403
+ * @param {bigint} param0.reward - The amount of the asset to distribute.
404
+ * @param {bigint} param0.limit - How many times can this incentive be claimed.
405
+ * @returns {*}
406
+ */
407
+ export function prepareERC20VariableIncentivePayload({
408
+ asset,
409
+ reward,
410
+ limit,
411
+ }: ERC20VariableIncentivePayload) {
412
+ return encodeAbiParameters(
413
+ [
414
+ { type: 'address', name: 'asset' },
415
+ { type: 'uint256', name: 'reward' },
416
+ { type: 'uint256', name: 'limit' },
417
+ ],
418
+ [asset, reward, limit],
419
+ );
420
+ }
@@ -1,7 +1,7 @@
1
1
  import { zeroAddress } from 'viem';
2
2
  import { describe, expect, test } from 'vitest';
3
3
  import { defaultOptions } from '../../test/helpers';
4
- import { StrategyType } from '../utils';
4
+ import { StrategyType } from '../claiming';
5
5
  import {
6
6
  AllowListIncentive,
7
7
  CGDAIncentive,
@@ -1,6 +1,5 @@
1
1
  import { readPointsBalanceOf, writePointsGrantRoles } from '@boostxyz/evm';
2
2
  import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
- import { signMessage } from '@wagmi/core';
4
3
  import { isAddress, pad, parseEther, zeroAddress } from 'viem';
5
4
  import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
6
5
  import type { MockPoints } from '../../test/MockPoints';
@@ -12,7 +11,7 @@ import {
12
11
  freshBoost,
13
12
  freshPoints,
14
13
  } from '../../test/helpers';
15
- import { bytes4, prepareSignerValidatorClaimDataPayload } from '../utils';
14
+ import { bytes4 } from '../utils';
16
15
  import { PointsIncentive } from './PointsIncentive';
17
16
 
18
17
  let fixtures: Fixtures, points: MockPoints;
@@ -55,11 +54,10 @@ describe('PointsIncentive', () => {
55
54
  const claimant = trustedSigner.account;
56
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,
@@ -105,11 +103,10 @@ describe('PointsIncentive', () => {
105
103
  const claimant = trustedSigner.account;
106
104
  const incentiveData = pad('0xdef456232173821931823712381232131391321934');
107
105
  const incentiveQuantity = 1;
108
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
106
+ const claimDataPayload = await boost.validator.encodeClaimData({
109
107
  signer: trustedSigner,
110
108
  incentiveData,
111
109
  chainId: defaultOptions.config.chains[0].id,
112
- validator: boost.validator.assertValidAddress(),
113
110
  incentiveQuantity,
114
111
  claimant,
115
112
  boostId: boost.id,
@@ -12,25 +12,60 @@ import {
12
12
  writePointsIncentiveClaim,
13
13
  } from '@boostxyz/evm';
14
14
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/PointsIncentive.sol/PointsIncentive.json';
15
- import type { Address, ContractEventName, Hex } from 'viem';
15
+ import {
16
+ type Address,
17
+ type ContractEventName,
18
+ type Hex,
19
+ encodeAbiParameters,
20
+ } from 'viem';
16
21
  import type {
17
22
  DeployableOptions,
18
23
  GenericDeployableParams,
19
24
  } from '../Deployable/Deployable';
20
25
  import { DeployableTarget } from '../Deployable/DeployableTarget';
26
+ import { type ClaimPayload, prepareClaimPayload } from '../claiming';
21
27
  import {
22
- type ClaimPayload,
23
28
  type GenericLog,
24
- type PointsIncentivePayload,
25
29
  type ReadParams,
26
30
  RegistryType,
27
31
  type WriteParams,
28
- prepareClaimPayload,
29
- preparePointsIncentivePayload,
30
32
  } from '../utils';
31
33
 
32
34
  export { pointsIncentiveAbi };
33
- export type { PointsIncentivePayload };
35
+
36
+ /**
37
+ * The object representation of a `PointsIncentive.InitPayload`
38
+ *
39
+ * @export
40
+ * @interface PointsIncentivePayload
41
+ * @typedef {PointsIncentivePayload}
42
+ */
43
+ export interface PointsIncentivePayload {
44
+ /**
45
+ * The address of the points contract
46
+ *
47
+ * @type {Address}
48
+ */
49
+ venue: Address;
50
+ /**
51
+ * The selector for the issuance function on the points contract
52
+ *
53
+ * @type {Hex}
54
+ */
55
+ selector: Hex;
56
+ /**
57
+ * The reward amount issued for each claim
58
+ *
59
+ * @type {bigint}
60
+ */
61
+ reward: bigint;
62
+ /**
63
+ * The maximum number of claims that can be made (one per address)
64
+ *
65
+ * @type {bigint}
66
+ */
67
+ limit: bigint;
68
+ }
34
69
 
35
70
  /**
36
71
  * A generic `viem.Log` event with support for `PointsIncentive` event types.
@@ -94,7 +129,7 @@ export class PointsIncentive extends DeployableTarget<
94
129
  public async claims(
95
130
  params?: ReadParams<typeof pointsIncentiveAbi, 'claims'>,
96
131
  ) {
97
- return readPointsIncentiveClaims(this._config, {
132
+ return await readPointsIncentiveClaims(this._config, {
98
133
  address: this.assertValidAddress(),
99
134
  args: [],
100
135
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -113,7 +148,7 @@ export class PointsIncentive extends DeployableTarget<
113
148
  public async currentReward(
114
149
  params?: ReadParams<typeof pointsIncentiveAbi, 'currentReward'>,
115
150
  ) {
116
- return readPointsIncentiveCurrentReward(this._config, {
151
+ return await readPointsIncentiveCurrentReward(this._config, {
117
152
  address: this.assertValidAddress(),
118
153
  args: [],
119
154
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -132,7 +167,7 @@ export class PointsIncentive extends DeployableTarget<
132
167
  public async reward(
133
168
  params?: ReadParams<typeof pointsIncentiveAbi, 'reward'>,
134
169
  ) {
135
- return readPointsIncentiveReward(this._config, {
170
+ return await readPointsIncentiveReward(this._config, {
136
171
  address: this.assertValidAddress(),
137
172
  args: [],
138
173
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -153,7 +188,7 @@ export class PointsIncentive extends DeployableTarget<
153
188
  address: Address,
154
189
  params?: ReadParams<typeof pointsIncentiveAbi, 'claimed'>,
155
190
  ) {
156
- return readPointsIncentiveClaimed(this._config, {
191
+ return await readPointsIncentiveClaimed(this._config, {
157
192
  address: this.assertValidAddress(),
158
193
  args: [address],
159
194
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -170,7 +205,7 @@ export class PointsIncentive extends DeployableTarget<
170
205
  * @returns {unknown}
171
206
  */
172
207
  public async venue(params?: ReadParams<typeof pointsIncentiveAbi, 'venue'>) {
173
- return readPointsIncentiveVenue(this._config, {
208
+ return await readPointsIncentiveVenue(this._config, {
174
209
  address: this.assertValidAddress(),
175
210
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
176
211
  ...(params as any),
@@ -186,7 +221,7 @@ export class PointsIncentive extends DeployableTarget<
186
221
  * @returns {Promise<bigint>}
187
222
  */
188
223
  public async limit(params?: ReadParams<typeof pointsIncentiveAbi, 'limit'>) {
189
- return readPointsIncentiveLimit(this._config, {
224
+ return await readPointsIncentiveLimit(this._config, {
190
225
  address: this.assertValidAddress(),
191
226
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
192
227
  ...(params as any),
@@ -204,7 +239,7 @@ export class PointsIncentive extends DeployableTarget<
204
239
  public async selector(
205
240
  params?: ReadParams<typeof pointsIncentiveAbi, 'selector'>,
206
241
  ) {
207
- return readPointsIncentiveSelector(this._config, {
242
+ return await readPointsIncentiveSelector(this._config, {
208
243
  address: this.assertValidAddress(),
209
244
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
210
245
  ...(params as any),
@@ -220,11 +255,11 @@ export class PointsIncentive extends DeployableTarget<
220
255
  * @param {?WriteParams<typeof pointsIncentiveAbi, 'claim'>} [params]
221
256
  * @returns {Promise<boolean>} - True if the incentive was successfully claimed
222
257
  */
223
- public async claim(
258
+ protected async claim(
224
259
  payload: ClaimPayload,
225
260
  params?: WriteParams<typeof pointsIncentiveAbi, 'claim'>,
226
261
  ) {
227
- return this.awaitResult(this.claimRaw(payload, params));
262
+ return await this.awaitResult(this.claimRaw(payload, params));
228
263
  }
229
264
 
230
265
  /**
@@ -236,7 +271,7 @@ export class PointsIncentive extends DeployableTarget<
236
271
  * @param {?WriteParams<typeof pointsIncentiveAbi, 'claim'>} [params]
237
272
  * @returns {Promise<boolean>} - True if the incentive was successfully claimed
238
273
  */
239
- public async claimRaw(
274
+ protected async claimRaw(
240
275
  payload: ClaimPayload,
241
276
  params?: WriteParams<typeof pointsIncentiveAbi, 'claim'>,
242
277
  ) {
@@ -269,7 +304,7 @@ export class PointsIncentive extends DeployableTarget<
269
304
  payload: ClaimPayload,
270
305
  params?: ReadParams<typeof pointsIncentiveAbi, 'isClaimable'>,
271
306
  ) {
272
- return readPointsIncentiveIsClaimable(this._config, {
307
+ return await readPointsIncentiveIsClaimable(this._config, {
273
308
  address: this.assertValidAddress(),
274
309
  args: [prepareClaimPayload(payload)],
275
310
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -301,3 +336,30 @@ export class PointsIncentive extends DeployableTarget<
301
336
  };
302
337
  }
303
338
  }
339
+
340
+ /**
341
+ * Given a {@link PointsIncentivePayload}, properly encode a `PointsIncentive.InitPayload` for use with {@link PointsIncentive} initialization.
342
+ *
343
+ * @param {PointsIncentivePayload} param0
344
+ * @param {Address} param0.venue - The address of the points contract
345
+ * @param {Hex} param0.selector - The selector for the issuance function on the points contract
346
+ * @param {bigint} param0.reward - The reward amount issued for each claim
347
+ * @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
348
+ * @returns {*}
349
+ */
350
+ export const preparePointsIncentivePayload = ({
351
+ venue,
352
+ selector,
353
+ reward,
354
+ limit,
355
+ }: PointsIncentivePayload) => {
356
+ return encodeAbiParameters(
357
+ [
358
+ { type: 'address', name: 'venue' },
359
+ { type: 'bytes4', name: 'selector' },
360
+ { type: 'uint256', name: 'reward' },
361
+ { type: 'uint256', name: 'limit' },
362
+ ],
363
+ [venue, selector, reward, limit],
364
+ );
365
+ };
@@ -8,7 +8,6 @@ import {
8
8
  deployFixtures,
9
9
  } from '../../test/helpers';
10
10
  import { testAccount } from '../../test/viem';
11
- import { prepareSignerValidatorClaimDataPayload } from '../utils';
12
11
  import { SignerValidator } from './SignerValidator';
13
12
 
14
13
  let fixtures: Fixtures;
@@ -65,21 +64,19 @@ describe('SignerValidator', () => {
65
64
  // biome-ignore lint/style/noNonNullAssertion: this will never be undefined
66
65
  const untrustedSigner = accounts.at(2)!;
67
66
 
68
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
67
+ const claimDataPayload = await validator.encodeClaimData({
69
68
  signer: trustedSigner,
70
69
  incentiveData,
71
70
  chainId: defaultOptions.config.chains[0].id,
72
- validator: validator.assertValidAddress(),
73
71
  incentiveQuantity,
74
72
  claimant,
75
73
  boostId: boostId,
76
74
  });
77
75
 
78
- const badClaimDataPayload = await prepareSignerValidatorClaimDataPayload({
76
+ const badClaimDataPayload = await validator.encodeClaimData({
79
77
  signer: untrustedSigner,
80
78
  incentiveData,
81
79
  chainId: defaultOptions.config.chains[0].id,
82
- validator: validator.assertValidAddress(),
83
80
  incentiveQuantity,
84
81
  claimant,
85
82
  boostId: boostId,
@@ -120,11 +117,10 @@ describe('SignerValidator', () => {
120
117
  // biome-ignore lint/style/noNonNullAssertion: this will never be undefined
121
118
  const trustedSigner = accounts.at(0)!;
122
119
 
123
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
120
+ const claimDataPayload = await validator.encodeClaimData({
124
121
  signer: trustedSigner,
125
122
  incentiveData,
126
123
  chainId: defaultOptions.config.chains[0].id,
127
- validator: validator.assertValidAddress(),
128
124
  incentiveQuantity,
129
125
  claimant,
130
126
  boostId: boostId,