@boostxyz/sdk 0.0.0-alpha.7 → 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 (191) 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 -11
  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.d.ts +2 -2
  15. package/dist/AllowLists/AllowList.js +1 -1
  16. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  17. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  18. package/dist/AllowLists/SimpleAllowList.d.ts +33 -4
  19. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  20. package/dist/AllowLists/SimpleAllowList.js +52 -37
  21. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  22. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  23. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
  24. package/dist/AllowLists/SimpleDenyList.d.ts +31 -2
  25. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  26. package/dist/AllowLists/SimpleDenyList.js +41 -129
  27. package/dist/AllowLists/SimpleDenyList.js.map +1 -1
  28. package/dist/Auth/PassthroughAuth.cjs +1 -1
  29. package/dist/Auth/PassthroughAuth.cjs.map +1 -1
  30. package/dist/Auth/PassthroughAuth.js +4 -4
  31. package/dist/Auth/PassthroughAuth.js.map +1 -1
  32. package/dist/Boost.cjs +1 -1
  33. package/dist/Boost.cjs.map +1 -1
  34. package/dist/Boost.d.ts +93 -1
  35. package/dist/Boost.d.ts.map +1 -1
  36. package/dist/Boost.js +151 -5
  37. package/dist/Boost.js.map +1 -1
  38. package/dist/BoostCore.cjs +2 -2
  39. package/dist/BoostCore.cjs.map +1 -1
  40. package/dist/BoostCore.d.ts +45 -7
  41. package/dist/BoostCore.d.ts.map +1 -1
  42. package/dist/BoostCore.js +352 -305
  43. package/dist/BoostCore.js.map +1 -1
  44. package/dist/BoostRegistry.cjs +1 -1
  45. package/dist/BoostRegistry.cjs.map +1 -1
  46. package/dist/BoostRegistry.d.ts +18 -4
  47. package/dist/BoostRegistry.d.ts.map +1 -1
  48. package/dist/BoostRegistry.js +36 -25
  49. package/dist/BoostRegistry.js.map +1 -1
  50. package/dist/Budgets/Budget.cjs +1 -1
  51. package/dist/Budgets/Budget.js +1 -1
  52. package/dist/Budgets/ManagedBudget.cjs +1 -1
  53. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  54. package/dist/Budgets/ManagedBudget.d.ts +40 -2
  55. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  56. package/dist/Budgets/ManagedBudget.js +53 -36
  57. package/dist/Budgets/ManagedBudget.js.map +1 -1
  58. package/dist/Budgets/SimpleBudget.d.ts +33 -2
  59. package/dist/Budgets/SimpleBudget.d.ts.map +1 -1
  60. package/dist/Budgets/VestingBudget.d.ts +54 -2
  61. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  62. package/dist/Deployable/Contract.cjs +1 -1
  63. package/dist/Deployable/Contract.cjs.map +1 -1
  64. package/dist/Deployable/Contract.js +1 -1
  65. package/dist/Deployable/Contract.js.map +1 -1
  66. package/dist/Deployable/Deployable.cjs.map +1 -1
  67. package/dist/Deployable/Deployable.d.ts +8 -2
  68. package/dist/Deployable/Deployable.d.ts.map +1 -1
  69. package/dist/Deployable/Deployable.js +6 -0
  70. package/dist/Deployable/Deployable.js.map +1 -1
  71. package/dist/Deployable/DeployableTarget.cjs +1 -1
  72. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  73. package/dist/Deployable/DeployableTarget.d.ts +4 -3
  74. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  75. package/dist/Deployable/DeployableTarget.js +31 -28
  76. package/dist/Deployable/DeployableTarget.js.map +1 -1
  77. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  78. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  79. package/dist/Incentives/AllowListIncentive.d.ts +35 -5
  80. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  81. package/dist/Incentives/AllowListIncentive.js +33 -21
  82. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  83. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  84. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  85. package/dist/Incentives/CGDAIncentive.d.ts +89 -5
  86. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  87. package/dist/Incentives/CGDAIncentive.js +44 -23
  88. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  89. package/dist/Incentives/ERC1155Incentive.d.ts +67 -6
  90. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  91. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  92. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  93. package/dist/Incentives/ERC20Incentive.d.ts +49 -5
  94. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  95. package/dist/Incentives/ERC20Incentive.js +46 -27
  96. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  97. package/dist/Incentives/ERC20VariableIncentive.d.ts +42 -5
  98. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  99. package/dist/Incentives/Incentive.cjs +1 -1
  100. package/dist/Incentives/Incentive.cjs.map +1 -1
  101. package/dist/Incentives/Incentive.js +48 -32
  102. package/dist/Incentives/Incentive.js.map +1 -1
  103. package/dist/Incentives/PointsIncentive.cjs +1 -1
  104. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  105. package/dist/Incentives/PointsIncentive.d.ts +49 -5
  106. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  107. package/dist/Incentives/PointsIncentive.js +38 -21
  108. package/dist/Incentives/PointsIncentive.js.map +1 -1
  109. package/dist/Validators/SignerValidator.cjs +1 -1
  110. package/dist/Validators/SignerValidator.cjs.map +1 -1
  111. package/dist/Validators/SignerValidator.d.ts +298 -5
  112. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  113. package/dist/Validators/SignerValidator.js +151 -26
  114. package/dist/Validators/SignerValidator.js.map +1 -1
  115. package/dist/Validators/Validator.cjs +1 -1
  116. package/dist/Validators/Validator.js +1 -1
  117. package/dist/claiming.cjs +2 -0
  118. package/dist/claiming.cjs.map +1 -0
  119. package/dist/claiming.d.ts +43 -0
  120. package/dist/claiming.d.ts.map +1 -0
  121. package/dist/claiming.js +17 -0
  122. package/dist/claiming.js.map +1 -0
  123. package/dist/errors.cjs +1 -1
  124. package/dist/errors.cjs.map +1 -1
  125. package/dist/errors.d.ts +15 -1
  126. package/dist/errors.d.ts.map +1 -1
  127. package/dist/errors.js +30 -21
  128. package/dist/errors.js.map +1 -1
  129. package/dist/{generated-DGpIVcv5.js → generated-57_Kffpz.js} +293 -282
  130. package/dist/generated-57_Kffpz.js.map +1 -0
  131. package/dist/{generated-Cd-Fe7W7.cjs → generated-wKBNvm48.cjs} +3 -3
  132. package/dist/generated-wKBNvm48.cjs.map +1 -0
  133. package/dist/index.cjs +1 -1
  134. package/dist/index.d.ts +4 -4
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +108 -124
  137. package/dist/transfers.cjs +2 -0
  138. package/dist/transfers.cjs.map +1 -0
  139. package/dist/transfers.d.ts +198 -0
  140. package/dist/transfers.d.ts.map +1 -0
  141. package/dist/transfers.js +84 -0
  142. package/dist/transfers.js.map +1 -0
  143. package/dist/utils.cjs +1 -1
  144. package/dist/utils.cjs.map +1 -1
  145. package/dist/utils.d.ts +2 -1371
  146. package/dist/utils.d.ts.map +1 -1
  147. package/dist/utils.js +26 -653
  148. package/dist/utils.js.map +1 -1
  149. package/package.json +17 -3
  150. package/src/Actions/Action.test.ts +5 -4
  151. package/src/Actions/ContractAction.test.ts +4 -6
  152. package/src/Actions/ContractAction.ts +73 -10
  153. package/src/Actions/ERC721MintAction.test.ts +2 -2
  154. package/src/Actions/ERC721MintAction.ts +70 -16
  155. package/src/Actions/EventAction.test.ts +43 -17
  156. package/src/Actions/EventAction.ts +451 -26
  157. package/src/AllowLists/SimpleAllowList.ts +51 -7
  158. package/src/AllowLists/SimpleDenyList.ts +47 -109
  159. package/src/Auth/PassthroughAuth.ts +1 -1
  160. package/src/Boost.ts +136 -1
  161. package/src/BoostCore.test.ts +4 -11
  162. package/src/BoostCore.ts +114 -45
  163. package/src/BoostRegistry.ts +39 -21
  164. package/src/Budgets/ManagedBudget.ts +69 -16
  165. package/src/Budgets/SimpleBudget.ts +57 -14
  166. package/src/Budgets/VestingBudget.ts +79 -9
  167. package/src/Deployable/Contract.ts +1 -1
  168. package/src/Deployable/Deployable.ts +8 -2
  169. package/src/Deployable/DeployableTarget.ts +19 -6
  170. package/src/Incentives/AllowListIncentive.test.ts +2 -5
  171. package/src/Incentives/AllowListIncentive.ts +59 -15
  172. package/src/Incentives/CGDAIncentive.test.ts +3 -7
  173. package/src/Incentives/CGDAIncentive.ts +123 -19
  174. package/src/Incentives/ERC1155Incentive.test.ts +2 -13
  175. package/src/Incentives/ERC1155Incentive.ts +104 -22
  176. package/src/Incentives/ERC20Incentive.test.ts +6 -17
  177. package/src/Incentives/ERC20Incentive.ts +86 -21
  178. package/src/Incentives/ERC20VariableIncentive.test.ts +4 -24
  179. package/src/Incentives/ERC20VariableIncentive.ts +71 -19
  180. package/src/Incentives/Incentive.test.ts +1 -1
  181. package/src/Incentives/PointsIncentive.test.ts +3 -6
  182. package/src/Incentives/PointsIncentive.ts +79 -17
  183. package/src/Validators/SignerValidator.test.ts +3 -7
  184. package/src/Validators/SignerValidator.ts +422 -13
  185. package/src/claiming.ts +56 -0
  186. package/src/errors.ts +19 -1
  187. package/src/index.ts +10 -7
  188. package/src/transfers.ts +284 -0
  189. package/src/utils.ts +3 -2052
  190. package/dist/generated-Cd-Fe7W7.cjs.map +0 -1
  191. package/dist/generated-DGpIVcv5.js.map +0 -1
@@ -10,7 +10,14 @@ import {
10
10
  writeSignerValidatorValidate,
11
11
  } from '@boostxyz/evm';
12
12
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/validators/SignerValidator.sol/SignerValidator.json';
13
- import type { Address, ContractEventName, Hex } from 'viem';
13
+ import {
14
+ type Address,
15
+ type ContractEventName,
16
+ type Hex,
17
+ type PrivateKeyAccount,
18
+ encodeAbiParameters,
19
+ } from 'viem';
20
+ import { signTypedData } from 'viem/accounts';
14
21
  import type {
15
22
  DeployableOptions,
16
23
  GenericDeployableParams,
@@ -20,15 +27,244 @@ import {
20
27
  type GenericLog,
21
28
  type ReadParams,
22
29
  RegistryType,
23
- type SignerValidatorPayload,
24
- type SignerValidatorSignaturePayload,
25
- type SignerValidatorValidatePayload,
26
30
  type WriteParams,
27
- prepareSignerValidatorPayload,
28
31
  } from '../utils';
29
32
 
30
33
  export { signerValidatorAbi };
31
- export type { SignerValidatorPayload };
34
+
35
+ /**
36
+ * Object reprentation of a {@link SignerValidator} initialization payload
37
+ *
38
+ * @export
39
+ * @interface SignerValidatorPayload
40
+ * @typedef {SignerValidatorPayload}
41
+ */
42
+ export interface SignerValidatorPayload {
43
+ /**
44
+ * The list of authorized signers. The first address in the list will be the initial owner of the contract.
45
+ *
46
+ * @type {Address[]}
47
+ */
48
+ signers: Address[];
49
+ /**
50
+ * The authorized caller of the {@link prepareSignerValidator} function
51
+ * @type {Address}
52
+ */
53
+ validatorCaller: Address;
54
+ }
55
+
56
+ /**
57
+ * Description placeholder
58
+ *
59
+ * @export
60
+ * @interface SignerValidatorValidatePayload
61
+ * @typedef {SignerValidatorValidatePayload}
62
+ */
63
+ export interface SignerValidatorValidatePayload {
64
+ /**
65
+ * The ID of the boost.
66
+ *
67
+ * @type {bigint}
68
+ */
69
+ boostId: bigint;
70
+ /**
71
+ * The ID of the incentive.
72
+ *
73
+ * @type {bigint}
74
+ */
75
+ incentiveId: bigint;
76
+ /**
77
+ * The address of the claimant.
78
+ *
79
+ * @type {Address}
80
+ */
81
+ claimant: Address;
82
+ /**
83
+ * The claim data.
84
+ *
85
+ * @type {Hex}
86
+ */
87
+ claimData: Hex;
88
+ }
89
+
90
+ /**
91
+ * Object reprentation of a {@link SignerValidator} initialization payload
92
+ *
93
+ * @export
94
+ * @interface SignerValidatorPayload
95
+ * @typedef {SignerValidatorPayload}
96
+ */
97
+ export interface SignerValidatorPayload {
98
+ /**
99
+ * The list of authorized signers. The first address in the list will be the initial owner of the contract.
100
+ *
101
+ * @type {Address[]}
102
+ */
103
+ signers: Address[];
104
+ /**
105
+ * The authorized caller of the {@link prepareSignerValidator} function
106
+ * @type {Address}
107
+ */
108
+ validatorCaller: Address;
109
+ }
110
+
111
+ /**
112
+ * Description placeholder
113
+ *
114
+ * @export
115
+ * @interface SignerValidatorValidatePayload
116
+ * @typedef {SignerValidatorValidatePayload}
117
+ */
118
+ export interface SignerValidatorValidatePayload {
119
+ /**
120
+ * The ID of the boost.
121
+ *
122
+ * @type {bigint}
123
+ */
124
+ boostId: bigint;
125
+ /**
126
+ * The ID of the incentive.
127
+ *
128
+ * @type {bigint}
129
+ */
130
+ incentiveId: bigint;
131
+ /**
132
+ * The address of the claimant.
133
+ *
134
+ * @type {Address}
135
+ */
136
+ claimant: Address;
137
+ /**
138
+ * The claim data.
139
+ *
140
+ * @type {Hex}
141
+ */
142
+ claimData: Hex;
143
+ }
144
+
145
+ /**
146
+ * Signer Validator Claim Data Payload
147
+ *
148
+ * @export
149
+ * @interface SignerValidatorClaimDataParams
150
+ * @typedef {SignerValidatorClaimDataParams}
151
+ */
152
+ export interface SignerValidatorClaimDataParams {
153
+ /**
154
+ * The signer with which to sign the input
155
+ *
156
+ * @type {{
157
+ * account: Address;
158
+ * key: Hex;
159
+ * privateKey: PrivateKeyAccount;
160
+ * }}
161
+ */
162
+ signer: {
163
+ account: Address;
164
+ key: Hex;
165
+ privateKey: PrivateKeyAccount;
166
+ };
167
+ /**
168
+ * The encoded data to provide the underlying incentive. You can use {@link prepareAllowListIncentivePayload}, {@link prepareCGDAIncentivePayload}, {@link prepareERC20IncentivePayload}, {@link prepareERC1155IncentivePayload}, or {@link preparePointsIncentivePayload}
169
+ *
170
+ * @type {Hex}
171
+ */
172
+ incentiveData: Hex;
173
+ /**
174
+ * The chain id to target
175
+ *
176
+ * @type {number}
177
+ */
178
+ chainId: number;
179
+ /**
180
+ * The address of the validator
181
+ *
182
+ * @type {Address}
183
+ */
184
+ validator: Address;
185
+ /**
186
+ * The incentive quantity.
187
+ *
188
+ * @type {number}
189
+ */
190
+ incentiveQuantity: number;
191
+ /**
192
+ * The address of the claimant
193
+ *
194
+ * @type {Address}
195
+ */
196
+ claimant: Address;
197
+ /**
198
+ * The ID of the boost
199
+ *
200
+ * @type {bigint}
201
+ */
202
+ boostId: bigint;
203
+ }
204
+
205
+ /**
206
+ * Object representation of a {@link SignerValidatorInputParams} initialization payload
207
+ *
208
+ * @export
209
+ * @interface SignerValidatorInputParams
210
+ * @typedef {SignerValidatorInputParams}
211
+ */
212
+ export interface SignerValidatorInputParams {
213
+ /**
214
+ * The signer address.
215
+ *
216
+ * @type {Address}
217
+ */
218
+ signer: Address;
219
+
220
+ /**
221
+ * The signature data.
222
+ *
223
+ * @type {string}
224
+ */
225
+ signature: Hex;
226
+
227
+ /**
228
+ * The incentive quantity.
229
+ *
230
+ * @type {number}
231
+ */
232
+ incentiveQuantity: number;
233
+ }
234
+
235
+ /**
236
+ * Object representing the payload for signing before validaton.
237
+ *
238
+ * @export
239
+ * @interface SignerValidatorSignaturePayload
240
+ * @typedef {SignerValidatorSignaturePayload}
241
+ */
242
+ export interface SignerValidatorSignaturePayload {
243
+ /**
244
+ * The ID of the boost.
245
+ *
246
+ * @type {bigint}
247
+ */
248
+ boostId: bigint;
249
+ /**
250
+ * The ID of the incentive.
251
+ *
252
+ * @type {number}
253
+ */
254
+ incentiveQuantity: number;
255
+ /**
256
+ * The address of the claimant.
257
+ *
258
+ * @type {Address}
259
+ */
260
+ claimant: Address;
261
+ /**
262
+ * The claim data.
263
+ *
264
+ * @type {Hex}
265
+ */
266
+ incentiveData: Hex;
267
+ }
32
268
 
33
269
  /**
34
270
  * A generic `viem.Log` event with support for `BoostCore` event types.
@@ -57,6 +293,13 @@ export class SignerValidator extends DeployableTarget<
57
293
  SignerValidatorPayload,
58
294
  typeof signerValidatorAbi
59
295
  > {
296
+ /**
297
+ * @inheritdoc
298
+ *
299
+ * @public
300
+ * @readonly
301
+ * @type {*}
302
+ */
60
303
  public override readonly abi = signerValidatorAbi;
61
304
  /**
62
305
  * @inheritdoc
@@ -89,7 +332,7 @@ export class SignerValidator extends DeployableTarget<
89
332
  address: Address,
90
333
  params?: ReadParams<typeof signerValidatorAbi, 'signers'>,
91
334
  ) {
92
- return readSignerValidatorSigners(this._config, {
335
+ return await readSignerValidatorSigners(this._config, {
93
336
  address: this.assertValidAddress(),
94
337
  args: [address],
95
338
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -110,7 +353,7 @@ export class SignerValidator extends DeployableTarget<
110
353
  payload: SignerValidatorSignaturePayload,
111
354
  params?: ReadParams<typeof signerValidatorAbi, 'hashSignerData'>,
112
355
  ) {
113
- return readSignerValidatorHashSignerData(this._config, {
356
+ return await readSignerValidatorHashSignerData(this._config, {
114
357
  address: this.assertValidAddress(),
115
358
  args: [
116
359
  payload.boostId,
@@ -132,11 +375,11 @@ export class SignerValidator extends DeployableTarget<
132
375
  * @param {?WriteParams<typeof signerValidatorAbi, 'validate'>} [params]
133
376
  * @returns {Promise<boolean>} - True if the action has been validated based on the data payload
134
377
  */
135
- public async validate(
378
+ protected async validate(
136
379
  payload: SignerValidatorValidatePayload,
137
380
  params?: WriteParams<typeof signerValidatorAbi, 'validate'>,
138
381
  ) {
139
- return this.awaitResult(this.validateRaw(payload, params));
382
+ return await this.awaitResult(this.validateRaw(payload, params));
140
383
  }
141
384
 
142
385
  /**
@@ -148,7 +391,7 @@ export class SignerValidator extends DeployableTarget<
148
391
  * @param {?WriteParams<typeof signerValidatorAbi, 'validate'>} [params]
149
392
  * @returns {Promise<boolean>} - True if the action has been validated based on the data payload
150
393
  */
151
- public async validateRaw(
394
+ protected async validateRaw(
152
395
  payload: SignerValidatorValidatePayload,
153
396
  params?: ReadParams<typeof signerValidatorAbi, 'validate'>,
154
397
  ) {
@@ -186,7 +429,9 @@ export class SignerValidator extends DeployableTarget<
186
429
  allowed: boolean[],
187
430
  params?: WriteParams<typeof signerValidatorAbi, 'setAuthorized'>,
188
431
  ) {
189
- return this.awaitResult(this.setAuthorizedRaw(addresses, allowed, params));
432
+ return await this.awaitResult(
433
+ this.setAuthorizedRaw(addresses, allowed, params),
434
+ );
190
435
  }
191
436
 
192
437
  /**
@@ -218,6 +463,15 @@ export class SignerValidator extends DeployableTarget<
218
463
  return { hash, result };
219
464
  }
220
465
 
466
+ /**
467
+ * Update the authorized caller of the validator function
468
+ *
469
+ * @public
470
+ * @async
471
+ * @param {Address} address
472
+ * @param {?WriteParams<typeof signerValidatorAbi, 'setValidatorCaller'>} [params]
473
+ * @returns {unknown}
474
+ */
221
475
  public async setValidatorCallerRaw(
222
476
  address: Address,
223
477
  params?: WriteParams<typeof signerValidatorAbi, 'setValidatorCaller'>,
@@ -239,11 +493,37 @@ export class SignerValidator extends DeployableTarget<
239
493
  return { hash, result };
240
494
  }
241
495
 
496
+ /**
497
+ * Update the authorized caller of the validator function
498
+ *
499
+ * @public
500
+ * @async
501
+ * @param {Address} address
502
+ * @param {?WriteParams<typeof signerValidatorAbi, 'setValidatorCaller'>} [params]
503
+ * @returns {unknown}
504
+ */
242
505
  public async setValidatorCaller(
243
506
  address: Address,
244
507
  params?: WriteParams<typeof signerValidatorAbi, 'setValidatorCaller'>,
245
508
  ) {
246
- return this.awaitResult(this.setValidatorCallerRaw(address, params));
509
+ return await this.awaitResult(this.setValidatorCallerRaw(address, params));
510
+ }
511
+
512
+ /**
513
+ * Properly encodes the data needed to claim
514
+ *
515
+ * @public
516
+ * @async
517
+ * @param {SignerValidatorClaimDataParams} params
518
+ * @returns {Promise<Hex>}
519
+ */
520
+ public async encodeClaimData(
521
+ params: Omit<SignerValidatorClaimDataParams, 'validator'>,
522
+ ): Promise<Hex> {
523
+ return await prepareSignerValidatorClaimDataPayload({
524
+ ...params,
525
+ validator: this.assertValidAddress(),
526
+ });
247
527
  }
248
528
 
249
529
  /**
@@ -270,3 +550,132 @@ export class SignerValidator extends DeployableTarget<
270
550
  };
271
551
  }
272
552
  }
553
+
554
+ /**
555
+ * Signer Validator Claim Data Payload Preparation
556
+ *
557
+ * @export
558
+ * @async
559
+ * @param {SignerValidatorClaimDataParams} param0
560
+ * @param {{ account: Address; key: Hex; privateKey: PrivateKeyAccount; }} param0.signer
561
+ * @param {Hex} param0.incentiveData
562
+ * @param {number} param0.chainId
563
+ * @param {Address} param0.validator
564
+ * @param {number} param0.incentiveQuantity
565
+ * @param {Address} param0.claimant
566
+ * @param {bigint} param0.boostId
567
+ * @returns {Promise<Hex>}
568
+ */
569
+ export async function prepareSignerValidatorClaimDataPayload({
570
+ signer,
571
+ incentiveData,
572
+ chainId,
573
+ validator,
574
+ incentiveQuantity,
575
+ claimant,
576
+ boostId,
577
+ }: SignerValidatorClaimDataParams): Promise<Hex> {
578
+ const domain = {
579
+ name: 'SignerValidator',
580
+ version: '1',
581
+ chainId: chainId,
582
+ verifyingContract: validator,
583
+ };
584
+ const typedData = {
585
+ domain,
586
+ types: {
587
+ SignerValidatorData: [
588
+ { name: 'boostId', type: 'uint256' },
589
+ { name: 'incentiveQuantity', type: 'uint8' },
590
+ { name: 'claimant', type: 'address' },
591
+ { name: 'incentiveData', type: 'bytes' },
592
+ ],
593
+ },
594
+ primaryType: 'SignerValidatorData' as const,
595
+ message: {
596
+ boostId,
597
+ incentiveQuantity,
598
+ claimant,
599
+ incentiveData: incentiveData,
600
+ },
601
+ };
602
+
603
+ const trustedSignature = await signTypedData({
604
+ ...typedData,
605
+ privateKey: signer.key,
606
+ });
607
+
608
+ // Prepare the claim data payload using the new helper
609
+ const validatorData = prepareSignerValidatorInputParams({
610
+ signer: signer.account,
611
+ signature: trustedSignature,
612
+ incentiveQuantity, // Adjust incentive quantity as necessary
613
+ });
614
+
615
+ const boostClaimDataPayload = encodeAbiParameters(
616
+ [
617
+ {
618
+ type: 'tuple',
619
+ name: 'BoostClaimData',
620
+ components: [
621
+ { type: 'bytes', name: 'validatorData' },
622
+ { type: 'bytes', name: 'incentiveData' },
623
+ ],
624
+ },
625
+ ],
626
+ [{ validatorData, incentiveData }],
627
+ );
628
+
629
+ return boostClaimDataPayload;
630
+ }
631
+
632
+ /**
633
+ * Given a {@link SignerValidatorInputParams}, properly encode the initialization payload.
634
+ *
635
+ * @param {SignerValidatorInputParams} param0
636
+ * @param {Address} param0.signer
637
+ * @param {Hex} param0.signature
638
+ * @param {number} param0.incentiveQuantity
639
+ * @returns {Hex}
640
+ */
641
+ export function prepareSignerValidatorInputParams({
642
+ signer,
643
+ signature,
644
+ incentiveQuantity,
645
+ }: SignerValidatorInputParams) {
646
+ return encodeAbiParameters(
647
+ [
648
+ {
649
+ type: 'tuple',
650
+ name: 'SignerValidatorInputParams',
651
+ components: [
652
+ { type: 'address', name: 'signer' },
653
+ { type: 'bytes', name: 'signature' },
654
+ { type: 'uint8', name: 'incentiveQuantity' },
655
+ ],
656
+ },
657
+ ],
658
+ [{ signer, signature, incentiveQuantity }],
659
+ );
660
+ }
661
+
662
+ /**
663
+ * Given a {@link SignerValidatorPayload}, properly encode the initialization payload.
664
+ *
665
+ * @param {SignerValidatorPayload} param0
666
+ * @param {Address[]} param0.signers
667
+ * @param {Address} param0.validatorCaller
668
+ * @returns {Hex}
669
+ */
670
+ export function prepareSignerValidatorPayload({
671
+ signers,
672
+ validatorCaller,
673
+ }: SignerValidatorPayload) {
674
+ return encodeAbiParameters(
675
+ [
676
+ { type: 'address[]', name: 'signers' },
677
+ { type: 'address', name: 'validatorCaller' },
678
+ ],
679
+ [signers, validatorCaller],
680
+ );
681
+ }
@@ -0,0 +1,56 @@
1
+ import { type Address, type Hex, encodeAbiParameters, zeroHash } from 'viem';
2
+
3
+ /**
4
+ * Enum representing incentive disbursement strategies.
5
+ *
6
+ * @export
7
+ * @enum {number}
8
+ */
9
+ export enum StrategyType {
10
+ POOL = 0,
11
+ MINT = 1,
12
+ RAFFLE = 2,
13
+ }
14
+
15
+ /**
16
+ * The object representation of an `Incentive.ClaimPayload`
17
+ *
18
+ * @export
19
+ * @interface ClaimPayload
20
+ * @typedef {ClaimPayload}
21
+ */
22
+ export interface ClaimPayload {
23
+ /**
24
+ * The address of the recipient
25
+ *
26
+ * @type {Address}
27
+ */
28
+ target: Address;
29
+ /**
30
+ * The implementation-specific data for the claim, if needed
31
+ *
32
+ * @type {?Hex}
33
+ */
34
+ data?: Hex;
35
+ }
36
+
37
+ /**
38
+ * Given a valid {@link ClaimPayload}, encode the payload for use with Incentive operations.
39
+ *
40
+ * @param {ClaimPayload} param0
41
+ * @param {Address} param0.target - The address of the recipient
42
+ * @param {Hex} [param0.data=zeroHash] - The implementation-specific data for the claim, if needed
43
+ * @returns {*}
44
+ */
45
+ export const prepareClaimPayload = ({
46
+ target,
47
+ data = zeroHash,
48
+ }: ClaimPayload) => {
49
+ return encodeAbiParameters(
50
+ [
51
+ { type: 'address', name: 'target' },
52
+ { type: 'bytes', name: 'data' },
53
+ ],
54
+ [target, data],
55
+ );
56
+ };
package/src/errors.ts CHANGED
@@ -4,8 +4,9 @@ import {
4
4
  type WaitForTransactionReceiptReturnType,
5
5
  zeroHash,
6
6
  } from 'viem';
7
+ import type { Criteria } from './Actions/EventAction';
8
+ import type { BoostRegistry } from './BoostRegistry';
7
9
  import type { Incentive } from './Incentives/Incentive';
8
- import type { Criteria } from './utils';
9
10
 
10
11
  /**
11
12
  * This error is thrown during Boost creation if no `BoostCreated` event was emitted.
@@ -301,6 +302,23 @@ export class BudgetMustAuthorizeBoostCore extends Error {
301
302
  }
302
303
  }
303
304
 
305
+ /**
306
+ * Because this contract is a base implementation, it should not be initialized through the constructor. Instead, it should be cloned and initialized using the {@link BoostRegistry}
307
+ *
308
+ * @export
309
+ * @class MustInitializeBudgetError
310
+ * @typedef {MustInitializeBudgetError}
311
+ * @extends {Error}
312
+ */
313
+ export class MustInitializeBudgetError extends Error {
314
+ /**
315
+ * Creates an instance of MustInitializeBudgetError.
316
+ */
317
+ constructor() {
318
+ super(`Budgets must be preinitialized before being used with a new Boost`);
319
+ }
320
+ }
321
+
304
322
  /**
305
323
  * The error is thrown when trying to reuse an existing deployed Incentive that isn't a base implementation.
306
324
  * The protocol doesn't allow this.
package/src/index.ts CHANGED
@@ -1,13 +1,6 @@
1
1
  export * from './BoostRegistry';
2
2
  export * from './BoostCore';
3
3
  export * from './Boost';
4
- export * from './errors';
5
- export * from './utils';
6
-
7
- // Auth
8
-
9
- export * from './Auth/Auth';
10
- export * from './Auth/PassthroughAuth';
11
4
 
12
5
  // Actions
13
6
 
@@ -48,3 +41,13 @@ export * from './Incentives/PointsIncentive';
48
41
 
49
42
  export * from './Validators/SignerValidator';
50
43
  export * from './Validators/Validator';
44
+
45
+ // Extra
46
+
47
+ export * from './errors';
48
+ export * from './utils';
49
+
50
+ // Auth
51
+
52
+ export * from './Auth/Auth';
53
+ export * from './Auth/PassthroughAuth';