@boostxyz/sdk 8.0.0-canary.3 → 8.0.0-canary.5

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 (165) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.js +2 -2
  3. package/dist/Actions/EventAction.cjs +1 -1
  4. package/dist/Actions/EventAction.cjs.map +1 -1
  5. package/dist/Actions/EventAction.d.ts.map +1 -1
  6. package/dist/Actions/EventAction.js +184 -181
  7. package/dist/Actions/EventAction.js.map +1 -1
  8. package/dist/{AllowList-DQf-8HQC.js → AllowList-CTRuUBCQ.js} +41 -41
  9. package/dist/{AllowList-DQf-8HQC.js.map → AllowList-CTRuUBCQ.js.map} +1 -1
  10. package/dist/{AllowList-DaX239DR.cjs → AllowList-GEmUfOR1.cjs} +2 -2
  11. package/dist/{AllowList-DaX239DR.cjs.map → AllowList-GEmUfOR1.cjs.map} +1 -1
  12. package/dist/AllowLists/AllowList.cjs +1 -1
  13. package/dist/AllowLists/AllowList.js +4 -4
  14. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  15. package/dist/AllowLists/SimpleAllowList.js +7 -7
  16. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  17. package/dist/AllowLists/SimpleDenyList.js +3 -3
  18. package/dist/Auth/PassthroughAuth.cjs +1 -1
  19. package/dist/Auth/PassthroughAuth.js +2 -2
  20. package/dist/BoostCore.cjs +2 -2
  21. package/dist/BoostCore.cjs.map +1 -1
  22. package/dist/BoostCore.d.ts +137 -2
  23. package/dist/BoostCore.d.ts.map +1 -1
  24. package/dist/BoostCore.js +336 -206
  25. package/dist/BoostCore.js.map +1 -1
  26. package/dist/BoostRegistry.cjs +1 -1
  27. package/dist/BoostRegistry.js +21 -21
  28. package/dist/{Budget-LnAQ_Slw.js → Budget-BH0s7Bxu.js} +52 -52
  29. package/dist/{Budget-LnAQ_Slw.js.map → Budget-BH0s7Bxu.js.map} +1 -1
  30. package/dist/{Budget-WIB8IJoM.cjs → Budget-CwNhsa3m.cjs} +2 -2
  31. package/dist/{Budget-WIB8IJoM.cjs.map → Budget-CwNhsa3m.cjs.map} +1 -1
  32. package/dist/Budgets/Budget.cjs +1 -1
  33. package/dist/Budgets/Budget.js +3 -3
  34. package/dist/Budgets/ManagedBudget.cjs +1 -1
  35. package/dist/Budgets/ManagedBudget.js +26 -26
  36. package/dist/Deployable/DeployableTarget.cjs +1 -1
  37. package/dist/Deployable/DeployableTarget.js +1 -1
  38. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  39. package/dist/Deployable/DeployableTargetWithRBAC.js +17 -17
  40. package/dist/{Incentive-gT7z-4v3.cjs → Incentive-B2ZBE5LU.cjs} +2 -2
  41. package/dist/{Incentive-gT7z-4v3.cjs.map → Incentive-B2ZBE5LU.cjs.map} +1 -1
  42. package/dist/{Incentive-D_IBex5V.js → Incentive-BCSV7OtF.js} +41 -41
  43. package/dist/{Incentive-D_IBex5V.js.map → Incentive-BCSV7OtF.js.map} +1 -1
  44. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  45. package/dist/Incentives/AllowListIncentive.js +17 -17
  46. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  47. package/dist/Incentives/CGDAIncentive.js +14 -14
  48. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  49. package/dist/Incentives/ERC20Incentive.js +13 -13
  50. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.cjs +1 -1
  51. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.js +71 -71
  52. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs +1 -1
  53. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js +35 -35
  54. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +1 -1
  55. package/dist/Incentives/ERC20VariableCriteriaIncentive.js +9 -9
  56. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs +1 -1
  57. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js +12 -12
  58. package/dist/Incentives/ERC20VariableIncentive.cjs +1 -1
  59. package/dist/Incentives/ERC20VariableIncentive.js +8 -8
  60. package/dist/Incentives/Incentive.cjs +1 -1
  61. package/dist/Incentives/Incentive.js +3 -3
  62. package/dist/Incentives/PointsIncentive.cjs +1 -1
  63. package/dist/Incentives/PointsIncentive.js +28 -28
  64. package/dist/{SimpleDenyList-D5AoBdVi.cjs → SimpleDenyList-6_sxnZB0.cjs} +2 -2
  65. package/dist/{SimpleDenyList-D5AoBdVi.cjs.map → SimpleDenyList-6_sxnZB0.cjs.map} +1 -1
  66. package/dist/{SimpleDenyList-CtdXM49y.js → SimpleDenyList-CrjjFnn5.js} +17 -17
  67. package/dist/{SimpleDenyList-CtdXM49y.js.map → SimpleDenyList-CrjjFnn5.js.map} +1 -1
  68. package/dist/Validators/LimitedSignerValidator.cjs +1 -1
  69. package/dist/Validators/LimitedSignerValidator.cjs.map +1 -1
  70. package/dist/Validators/LimitedSignerValidator.d.ts +9 -9
  71. package/dist/Validators/LimitedSignerValidator.d.ts.map +1 -1
  72. package/dist/Validators/LimitedSignerValidator.js +19 -19
  73. package/dist/Validators/LimitedSignerValidator.js.map +1 -1
  74. package/dist/Validators/LimitedSignerValidatorV2.cjs +2 -0
  75. package/dist/Validators/LimitedSignerValidatorV2.cjs.map +1 -0
  76. package/dist/Validators/LimitedSignerValidatorV2.d.ts +842 -0
  77. package/dist/Validators/LimitedSignerValidatorV2.d.ts.map +1 -0
  78. package/dist/Validators/LimitedSignerValidatorV2.js +301 -0
  79. package/dist/Validators/LimitedSignerValidatorV2.js.map +1 -0
  80. package/dist/Validators/PayableLimitedSignerValidator.cjs +2 -0
  81. package/dist/Validators/PayableLimitedSignerValidator.cjs.map +1 -0
  82. package/dist/Validators/PayableLimitedSignerValidator.d.ts.map +1 -1
  83. package/dist/{Validator-BEUqV28V.js → Validators/PayableLimitedSignerValidator.js} +56 -102
  84. package/dist/Validators/PayableLimitedSignerValidator.js.map +1 -0
  85. package/dist/Validators/PayableLimitedSignerValidatorV2.cjs +2 -0
  86. package/dist/Validators/PayableLimitedSignerValidatorV2.cjs.map +1 -0
  87. package/dist/Validators/PayableLimitedSignerValidatorV2.d.ts +855 -0
  88. package/dist/Validators/PayableLimitedSignerValidatorV2.d.ts.map +1 -0
  89. package/dist/Validators/PayableLimitedSignerValidatorV2.js +372 -0
  90. package/dist/Validators/PayableLimitedSignerValidatorV2.js.map +1 -0
  91. package/dist/Validators/SignerValidator.cjs +1 -1
  92. package/dist/Validators/SignerValidator.cjs.map +1 -1
  93. package/dist/Validators/SignerValidator.d.ts +4 -2
  94. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  95. package/dist/Validators/SignerValidator.js +12 -12
  96. package/dist/Validators/SignerValidator.js.map +1 -1
  97. package/dist/Validators/SignerValidatorV2.cjs +2 -0
  98. package/dist/Validators/SignerValidatorV2.cjs.map +1 -0
  99. package/dist/Validators/SignerValidatorV2.d.ts +728 -0
  100. package/dist/Validators/SignerValidatorV2.d.ts.map +1 -0
  101. package/dist/Validators/SignerValidatorV2.js +299 -0
  102. package/dist/Validators/SignerValidatorV2.js.map +1 -0
  103. package/dist/Validators/Validator.cjs +1 -1
  104. package/dist/Validators/Validator.cjs.map +1 -1
  105. package/dist/Validators/Validator.d.ts +19 -4
  106. package/dist/Validators/Validator.d.ts.map +1 -1
  107. package/dist/Validators/Validator.js +79 -14
  108. package/dist/Validators/Validator.js.map +1 -1
  109. package/dist/componentInterfaces-43ygGrVO.js +28 -0
  110. package/dist/componentInterfaces-43ygGrVO.js.map +1 -0
  111. package/dist/componentInterfaces-JU4NBkEc.cjs +2 -0
  112. package/dist/componentInterfaces-JU4NBkEc.cjs.map +1 -0
  113. package/dist/{deployments-Dw5Suk_D.js → deployments-COm00j8v.js} +48 -39
  114. package/dist/{deployments-Dw5Suk_D.js.map → deployments-COm00j8v.js.map} +1 -1
  115. package/dist/deployments-uLDgrxCp.cjs +2 -0
  116. package/dist/deployments-uLDgrxCp.cjs.map +1 -0
  117. package/dist/deployments.json +30 -21
  118. package/dist/generated-CkZm1EVH.cjs +3 -0
  119. package/dist/generated-CkZm1EVH.cjs.map +1 -0
  120. package/dist/{generated-krkFnwbV.js → generated-DRbljODL.js} +2314 -1284
  121. package/dist/generated-DRbljODL.js.map +1 -0
  122. package/dist/index.cjs +1 -1
  123. package/dist/index.d.ts +3 -0
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +185 -165
  126. package/dist/index.js.map +1 -1
  127. package/package.json +25 -1
  128. package/src/Actions/EventAction.ts +24 -5
  129. package/src/BoostCore.test.ts +77 -11
  130. package/src/BoostCore.ts +165 -4
  131. package/src/Budgets/ManagedBudgetWithFees.test.ts +14 -14
  132. package/src/Budgets/ManagedBudgetWithFeesV2.test.ts +3 -3
  133. package/src/Incentives/AllowListIncentive.test.ts +5 -5
  134. package/src/Incentives/CGDAIncentive.test.ts +6 -6
  135. package/src/Incentives/ERC1155Incentive.test.ts +2 -2
  136. package/src/Incentives/ERC20Incentive.test.ts +6 -6
  137. package/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.test.ts +5 -5
  138. package/src/Incentives/ERC20VariableCriteriaIncentiveV2.test.ts +5 -5
  139. package/src/Incentives/ERC20VariableIncentive.test.ts +7 -8
  140. package/src/Incentives/PointsIncentive.test.ts +5 -5
  141. package/src/Validators/LimitedSignerValidator.test.ts +1 -1
  142. package/src/Validators/LimitedSignerValidator.ts +9 -10
  143. package/src/Validators/LimitedSignerValidatorV2.test.ts +231 -0
  144. package/src/Validators/LimitedSignerValidatorV2.ts +707 -0
  145. package/src/Validators/PayableLimitedSignerValidator.test.ts +1 -1
  146. package/src/Validators/PayableLimitedSignerValidator.ts +0 -1
  147. package/src/Validators/PayableLimitedSignerValidatorV2.test.ts +202 -0
  148. package/src/Validators/PayableLimitedSignerValidatorV2.ts +688 -0
  149. package/src/Validators/SignerValidator.ts +4 -2
  150. package/src/Validators/SignerValidatorV2.test.ts +163 -0
  151. package/src/Validators/SignerValidatorV2.ts +635 -0
  152. package/src/Validators/Validator.ts +45 -2
  153. package/src/index.ts +3 -0
  154. package/dist/Validator-BEUqV28V.js.map +0 -1
  155. package/dist/Validator-FxcxYKhR.cjs +0 -2
  156. package/dist/Validator-FxcxYKhR.cjs.map +0 -1
  157. package/dist/componentInterfaces-BZ3fSNkT.cjs +0 -2
  158. package/dist/componentInterfaces-BZ3fSNkT.cjs.map +0 -1
  159. package/dist/componentInterfaces-D2s6AXlV.js +0 -25
  160. package/dist/componentInterfaces-D2s6AXlV.js.map +0 -1
  161. package/dist/deployments-DimWVnA4.cjs +0 -2
  162. package/dist/deployments-DimWVnA4.cjs.map +0 -1
  163. package/dist/generated-Cf82M-QP.cjs +0 -3
  164. package/dist/generated-Cf82M-QP.cjs.map +0 -1
  165. package/dist/generated-krkFnwbV.js.map +0 -1
@@ -0,0 +1,635 @@
1
+ import {
2
+ readSignerValidatorV2HashSignerData,
3
+ readSignerValidatorV2Signers,
4
+ signerValidatorV2Abi,
5
+ simulateSignerValidatorV2SetAuthorized,
6
+ simulateSignerValidatorV2SetValidatorCaller,
7
+ simulateSignerValidatorV2Validate,
8
+ writeSignerValidatorV2SetAuthorized,
9
+ writeSignerValidatorV2SetValidatorCaller,
10
+ writeSignerValidatorV2Validate,
11
+ } from '@boostxyz/evm';
12
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/validators/SignerValidatorV2.sol/SignerValidatorV2.json';
13
+ import {
14
+ type Address,
15
+ type ContractEventName,
16
+ type Hex,
17
+ type PrivateKeyAccount,
18
+ encodeAbiParameters,
19
+ } from 'viem';
20
+ import { SignerValidatorV2 as SignerValidatorV2Bases } from '../../dist/deployments.json';
21
+ import type {
22
+ DeployableOptions,
23
+ GenericDeployableParams,
24
+ } from '../Deployable/Deployable';
25
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
26
+ import {
27
+ type GenericLog,
28
+ type ReadParams,
29
+ RegistryType,
30
+ type WriteParams,
31
+ } from '../utils';
32
+
33
+ export { signerValidatorV2Abi };
34
+
35
+ /**
36
+ * Object reprentation of a {@link SignerValidatorV2} initialization payload
37
+ *
38
+ * @export
39
+ * @interface SignerValidatorV2Payload
40
+ * @typedef {SignerValidatorV2Payload}
41
+ */
42
+ export interface SignerValidatorV2Payload {
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 prepareSignerValidatorV2} function
51
+ * @type {Address}
52
+ */
53
+ validatorCaller: Address;
54
+ }
55
+
56
+ /**
57
+ * Description placeholder
58
+ *
59
+ * @export
60
+ * @interface SignerValidatorV2ValidatePayload
61
+ * @typedef {SignerValidatorV2ValidatePayload}
62
+ */
63
+ export interface SignerValidatorV2ValidatePayload {
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
+ * Signer Validator Claim Data Payload
92
+ *
93
+ * @export
94
+ * @interface SignerValidatorV2ClaimDataParams
95
+ * @typedef {SignerValidatorV2ClaimDataParams}
96
+ */
97
+ export interface SignerValidatorV2ClaimDataParams {
98
+ /**
99
+ * The signer with which to sign the input
100
+ *
101
+ * @type {{
102
+ * account: Address;
103
+ * key: Hex;
104
+ * privateKey: PrivateKeyAccount;
105
+ * }}
106
+ */
107
+ signer: {
108
+ account: Address;
109
+ key: Hex;
110
+ privateKey: PrivateKeyAccount;
111
+ };
112
+ /**
113
+ * The encoded data to provide the underlying incentive. You can use {@link prepareAllowListIncentivePayload}, {@link prepareCGDAIncentivePayload}, {@link prepareERC20IncentivePayload}, {@link prepareERC1155IncentivePayload}, or {@link preparePointsIncentivePayload}
114
+ *
115
+ * @type {Hex}
116
+ */
117
+ incentiveData: Hex;
118
+ /**
119
+ * The chain id to target
120
+ *
121
+ * @type {number}
122
+ */
123
+ chainId: number;
124
+ /**
125
+ * The address of the validator
126
+ *
127
+ * @type {Address}
128
+ */
129
+ validator: Address;
130
+ /**
131
+ * The total number of incentives on the Boost
132
+ *
133
+ * @type {number}
134
+ */
135
+ incentiveQuantity: number;
136
+ /**
137
+ * The address of the claimant
138
+ *
139
+ * @type {Address}
140
+ */
141
+ claimant: Address;
142
+ /**
143
+ * The ID of the boost
144
+ *
145
+ * @type {bigint}
146
+ */
147
+ boostId: bigint;
148
+ /**
149
+ * The address of the referrer
150
+ *
151
+ * @type {?Address}
152
+ */
153
+ referrer?: Address;
154
+ }
155
+
156
+ /**
157
+ * Object representation of a {@link SignerValidatorV2InputParams} initialization payload
158
+ *
159
+ * @export
160
+ * @interface SignerValidatorV2InputParams
161
+ * @typedef {SignerValidatorV2InputParams}
162
+ */
163
+ export interface SignerValidatorV2InputParams {
164
+ /**
165
+ * The signer address.
166
+ *
167
+ * @type {Address}
168
+ */
169
+ signer: Address;
170
+
171
+ /**
172
+ * The signature data.
173
+ *
174
+ * @type {Hex}
175
+ */
176
+ signature: Hex;
177
+
178
+ /**
179
+ * The total number of incentives on the Boost
180
+ *
181
+ * @type {number}
182
+ */
183
+ incentiveQuantity: number;
184
+ }
185
+
186
+ /**
187
+ * Object representing the payload for signing before validaton.
188
+ *
189
+ * @export
190
+ * @interface SignerValidatorV2SignaturePayload
191
+ * @typedef {SignerValidatorV2SignaturePayload}
192
+ */
193
+ export interface SignerValidatorV2SignaturePayload {
194
+ /**
195
+ * The ID of the boost.
196
+ *
197
+ * @type {bigint}
198
+ */
199
+ boostId: bigint;
200
+ /**
201
+ * The ID of the incentive.
202
+ *
203
+ * @type {number}
204
+ */
205
+ incentiveQuantity: number;
206
+ /**
207
+ * The address of the claimant.
208
+ *
209
+ * @type {Address}
210
+ */
211
+ claimant: Address;
212
+ /**
213
+ * The claim data.
214
+ *
215
+ * @type {Hex}
216
+ */
217
+ incentiveData: Hex;
218
+ /**
219
+ * The address of the referrer (defaults to claimant if omitted)
220
+ *
221
+ * @type {?Address}
222
+ */
223
+ referrer?: Address;
224
+ }
225
+
226
+ /**
227
+ * A generic `viem.Log` event with support for `BoostCore` event types.
228
+ *
229
+ * @export
230
+ * @typedef {SignerValidatorV2Log}
231
+ * @template {ContractEventName<
232
+ * typeof signerValidatorV2Abi
233
+ * >} [event=ContractEventName<typeof signerValidatorV2Abi>]
234
+ */
235
+ export type SignerValidatorV2Log<
236
+ event extends ContractEventName<
237
+ typeof signerValidatorV2Abi
238
+ > = ContractEventName<typeof signerValidatorV2Abi>,
239
+ > = GenericLog<typeof signerValidatorV2Abi, event>;
240
+
241
+ /**
242
+ * A simple implementation of a Validator that verifies a given signature and checks the recovered address against a set of authorized signers
243
+ *
244
+ * @export
245
+ * @class SignerValidatorV2
246
+ * @typedef {SignerValidatorV2}
247
+ * @extends {DeployableTarget<SignerValidatorV2Payload>}
248
+ */
249
+ export class SignerValidatorV2 extends DeployableTarget<
250
+ SignerValidatorV2Payload,
251
+ typeof signerValidatorV2Abi
252
+ > {
253
+ /**
254
+ * @inheritdoc
255
+ *
256
+ * @public
257
+ * @readonly
258
+ * @type {*}
259
+ */
260
+ public override readonly abi = signerValidatorV2Abi;
261
+ /**
262
+ * @inheritdoc
263
+ *
264
+ * @public
265
+ * @static
266
+ * @type {Record<number, Address>}
267
+ */
268
+ public static override bases: Record<number, Address> = {
269
+ ...(import.meta.env?.VITE_SIGNER_VALIDATOR_BASE
270
+ ? { 31337: import.meta.env.VITE_SIGNER_VALIDATOR_BASE }
271
+ : {}),
272
+ ...(SignerValidatorV2Bases as Record<number, Address>),
273
+ };
274
+ /**
275
+ * @inheritdoc
276
+ *
277
+ * @public
278
+ * @static
279
+ * @type {RegistryType}
280
+ */
281
+ public static override registryType: RegistryType = RegistryType.VALIDATOR;
282
+
283
+ /**
284
+ * The set of authorized signers
285
+ *
286
+ * @public
287
+ * @async
288
+ * @param {Address} address
289
+ * @param {?ReadParams} [params]
290
+ * @returns {Promise<boolean>}
291
+ */
292
+ public async signers(address: Address, params?: ReadParams) {
293
+ return await readSignerValidatorV2Signers(this._config, {
294
+ address: this.assertValidAddress(),
295
+ args: [address],
296
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
297
+ ...(params as any),
298
+ });
299
+ }
300
+
301
+ /**
302
+ * Retrieve the hash and signer data for a given hash
303
+ *
304
+ * @public
305
+ * @async
306
+ * @param {SignerValidatorV2SignaturePayload} payload
307
+ * @param {?ReadParams} [params]
308
+ * @returns {Promise<Hex>}
309
+ */
310
+ public async hashSignerData(
311
+ payload: SignerValidatorV2SignaturePayload,
312
+ params?: ReadParams,
313
+ ) {
314
+ const referrer = payload.referrer ?? payload.claimant;
315
+ return await readSignerValidatorV2HashSignerData(this._config, {
316
+ address: this.assertValidAddress(),
317
+ args: [
318
+ payload.boostId,
319
+ payload.incentiveQuantity,
320
+ payload.claimant,
321
+ payload.incentiveData,
322
+ referrer,
323
+ ],
324
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
325
+ ...(params as any),
326
+ });
327
+ }
328
+
329
+ /**
330
+ * Validate that the action has been completed successfully. The data payload is expected to be a tuple of (address signer, bytes32 hash, bytes signature). The signature is expected to be a valid ECDSA or EIP-1271 signature of a unique hash by an authorized signer.
331
+ *
332
+ * @public
333
+ * @async
334
+ * @param {SignerValidatorV2ValidatePayload} payload
335
+ * @param {?WriteParams} [params]
336
+ * @returns {Promise<boolean>} - True if the action has been validated based on the data payload
337
+ */
338
+ public async validate(
339
+ payload: SignerValidatorV2ValidatePayload,
340
+ params?: WriteParams,
341
+ ) {
342
+ return await this.awaitResult(this.validateRaw(payload, params));
343
+ }
344
+
345
+ /**
346
+ * Validate that the action has been completed successfully. The data payload is expected to be a tuple of (address signer, bytes32 hash, bytes signature). The signature is expected to be a valid ECDSA or EIP-1271 signature of a unique hash by an authorized signer.
347
+ *
348
+ * @public
349
+ * @async
350
+ * @param {SignerValidatorV2ValidatePayload} payload
351
+ * @param {?WriteParams} [params]
352
+ * @returns {Promise<boolean>} - True if the action has been validated based on the data payload
353
+ */
354
+ public async validateRaw(
355
+ payload: SignerValidatorV2ValidatePayload,
356
+ params?: WriteParams,
357
+ ) {
358
+ const { request, result } = await simulateSignerValidatorV2Validate(
359
+ this._config,
360
+ {
361
+ address: this.assertValidAddress(),
362
+ args: [
363
+ payload.boostId,
364
+ payload.incentiveId,
365
+ payload.claimant,
366
+ payload.claimData,
367
+ ],
368
+ ...this.optionallyAttachAccount(),
369
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
370
+ ...(params as any),
371
+ },
372
+ );
373
+ const hash = await writeSignerValidatorV2Validate(this._config, request);
374
+ return { hash, result };
375
+ }
376
+
377
+ /**
378
+ * Set the authorized status of a signer
379
+ *
380
+ * @public
381
+ * @async
382
+ * @param {Address[]} addresses - The list of signers to update
383
+ * @param {boolean[]} allowed - The authorized status of each signer
384
+ * @param {?WriteParams} [params]
385
+ * @returns {Promise<void>}
386
+ */
387
+ public async setAuthorized(
388
+ addresses: Address[],
389
+ allowed: boolean[],
390
+ params?: WriteParams,
391
+ ) {
392
+ return await this.awaitResult(
393
+ this.setAuthorizedRaw(addresses, allowed, params),
394
+ );
395
+ }
396
+
397
+ /**
398
+ * Set the authorized status of a signer
399
+ *
400
+ * @public
401
+ * @async
402
+ * @param {Address[]} addresses - The list of signers to update
403
+ * @param {boolean[]} allowed - The authorized status of each signer
404
+ * @param {?WriteParams} [params]
405
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
406
+ */
407
+ public async setAuthorizedRaw(
408
+ addresses: Address[],
409
+ allowed: boolean[],
410
+ params?: WriteParams,
411
+ ) {
412
+ const { request, result } = await simulateSignerValidatorV2SetAuthorized(
413
+ this._config,
414
+ {
415
+ address: this.assertValidAddress(),
416
+ args: [addresses, allowed],
417
+ ...this.optionallyAttachAccount(),
418
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
419
+ ...(params as any),
420
+ },
421
+ );
422
+ const hash = await writeSignerValidatorV2SetAuthorized(
423
+ this._config,
424
+ request,
425
+ );
426
+ return { hash, result };
427
+ }
428
+
429
+ /**
430
+ * Update the authorized caller of the validator function
431
+ *
432
+ * @public
433
+ * @async
434
+ * @param {Address} address
435
+ * @param {?WriteParams} [params]
436
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
437
+ */
438
+ public async setValidatorCallerRaw(address: Address, params?: WriteParams) {
439
+ const { request, result } =
440
+ await simulateSignerValidatorV2SetValidatorCaller(this._config, {
441
+ address: this.assertValidAddress(),
442
+ args: [address],
443
+ ...this.optionallyAttachAccount(),
444
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
445
+ ...(params as any),
446
+ });
447
+ const hash = await writeSignerValidatorV2SetValidatorCaller(
448
+ this._config,
449
+ request,
450
+ );
451
+ return { hash, result };
452
+ }
453
+
454
+ /**
455
+ * Update the authorized caller of the validator function
456
+ *
457
+ * @public
458
+ * @async
459
+ * @param {Address} address
460
+ * @param {?WriteParams} [params]
461
+ * @returns {Promise<void>}
462
+ */
463
+ public async setValidatorCaller(address: Address, params?: WriteParams) {
464
+ return await this.awaitResult(this.setValidatorCallerRaw(address, params));
465
+ }
466
+
467
+ /**
468
+ * Properly encodes the data needed to claim
469
+ *
470
+ * @public
471
+ * @async
472
+ * @param {SignerValidatorV2ClaimDataParams} params
473
+ * @returns {Promise<Hex>}
474
+ */
475
+ public async encodeClaimData(
476
+ params: Omit<SignerValidatorV2ClaimDataParams, 'validator'>,
477
+ ): Promise<Hex> {
478
+ return await prepareSignerValidatorV2ClaimDataPayload({
479
+ ...params,
480
+ validator: this.assertValidAddress(),
481
+ });
482
+ }
483
+
484
+ /**
485
+ * @inheritdoc
486
+ *
487
+ * @public
488
+ * @param {?SignerValidatorV2Payload} [_payload]
489
+ * @param {?DeployableOptions} [_options]
490
+ * @returns {GenericDeployableParams}
491
+ */
492
+ public override buildParameters(
493
+ _payload?: SignerValidatorV2Payload,
494
+ _options?: DeployableOptions,
495
+ ): GenericDeployableParams {
496
+ const [payload, options] = this.validateDeploymentConfig(
497
+ _payload,
498
+ _options,
499
+ );
500
+ return {
501
+ abi: signerValidatorV2Abi,
502
+ bytecode: bytecode as Hex,
503
+ args: [prepareSignerValidatorV2Payload(payload)],
504
+ ...this.optionallyAttachAccount(options.account),
505
+ };
506
+ }
507
+ }
508
+
509
+ /**
510
+ * Signer Validator Claim Data Payload Preparation
511
+ *
512
+ * @export
513
+ * @async
514
+ * @param {SignerValidatorV2ClaimDataParams} param0
515
+ * @param {{ account: Address; key: Hex; privateKey: PrivateKeyAccount; }} param0.signer
516
+ * @param {Hex} param0.incentiveData
517
+ * @param {number} param0.chainId
518
+ * @param {Address} param0.validator
519
+ * @param {number} param0.incentiveQuantity
520
+ * @param {Address} param0.claimant
521
+ * @param {bigint} param0.boostId
522
+ * @returns {Promise<Hex>}
523
+ */
524
+ export async function prepareSignerValidatorV2ClaimDataPayload({
525
+ signer,
526
+ incentiveData,
527
+ chainId,
528
+ validator,
529
+ incentiveQuantity,
530
+ claimant,
531
+ boostId,
532
+ referrer,
533
+ }: SignerValidatorV2ClaimDataParams): Promise<Hex> {
534
+ const _referrer = referrer ?? claimant;
535
+ const trustedSignature = await signer.privateKey.signTypedData({
536
+ domain: {
537
+ name: 'SignerValidatorV2',
538
+ version: '1',
539
+ chainId: chainId,
540
+ verifyingContract: validator,
541
+ },
542
+ types: {
543
+ SignerValidatorData: [
544
+ { name: 'boostId', type: 'uint256' },
545
+ { name: 'incentiveQuantity', type: 'uint8' },
546
+ { name: 'claimant', type: 'address' },
547
+ { name: 'incentiveData', type: 'bytes' },
548
+ { name: 'referrer', type: 'address' },
549
+ ],
550
+ },
551
+ primaryType: 'SignerValidatorData' as const,
552
+ message: {
553
+ boostId,
554
+ incentiveQuantity,
555
+ claimant,
556
+ incentiveData,
557
+ referrer: _referrer,
558
+ },
559
+ });
560
+
561
+ // Prepare the claim data payload using the new helper
562
+ const validatorData = prepareSignerValidatorV2InputParams({
563
+ signer: signer.account,
564
+ signature: trustedSignature,
565
+ incentiveQuantity, // Adjust incentive quantity as necessary
566
+ });
567
+
568
+ const boostClaimDataPayload = encodeAbiParameters(
569
+ [
570
+ {
571
+ type: 'tuple',
572
+ name: 'BoostClaimDataWithReferrer',
573
+ components: [
574
+ { type: 'bytes', name: 'validatorData' },
575
+ { type: 'bytes', name: 'incentiveData' },
576
+ { type: 'address', name: 'referrer' },
577
+ ],
578
+ },
579
+ ],
580
+ [{ validatorData, incentiveData, referrer: _referrer }],
581
+ );
582
+
583
+ return boostClaimDataPayload;
584
+ }
585
+
586
+ /**
587
+ * Given a {@link SignerValidatorV2InputParams}, properly encode the initialization payload.
588
+ *
589
+ * @param {SignerValidatorV2InputParams} param0
590
+ * @param {Address} param0.signer
591
+ * @param {Hex} param0.signature
592
+ * @param {number} param0.incentiveQuantity
593
+ * @returns {Hex}
594
+ */
595
+ export function prepareSignerValidatorV2InputParams({
596
+ signer,
597
+ signature,
598
+ incentiveQuantity,
599
+ }: SignerValidatorV2InputParams) {
600
+ return encodeAbiParameters(
601
+ [
602
+ {
603
+ type: 'tuple',
604
+ name: 'SignerValidatorV2InputParams',
605
+ components: [
606
+ { type: 'address', name: 'signer' },
607
+ { type: 'bytes', name: 'signature' },
608
+ { type: 'uint8', name: 'incentiveQuantity' },
609
+ ],
610
+ },
611
+ ],
612
+ [{ signer, signature, incentiveQuantity }],
613
+ );
614
+ }
615
+
616
+ /**
617
+ * Given a {@link SignerValidatorV2Payload}, properly encode the initialization payload.
618
+ *
619
+ * @param {SignerValidatorV2Payload} param0
620
+ * @param {Address[]} param0.signers
621
+ * @param {Address} param0.validatorCaller
622
+ * @returns {Hex}
623
+ */
624
+ export function prepareSignerValidatorV2Payload({
625
+ signers,
626
+ validatorCaller,
627
+ }: SignerValidatorV2Payload) {
628
+ return encodeAbiParameters(
629
+ [
630
+ { type: 'address[]', name: 'signers' },
631
+ { type: 'address', name: 'validatorCaller' },
632
+ ],
633
+ [signers, validatorCaller],
634
+ );
635
+ }
@@ -1,8 +1,11 @@
1
1
  import { aValidatorAbi } from '@boostxyz/evm';
2
2
  import {
3
3
  ALimitedSignerValidator,
4
+ ALimitedSignerValidatorV2,
4
5
  APayableLimitedSignerValidator,
6
+ APayableLimitedSignerValidatorV2,
5
7
  ASignerValidator,
8
+ ASignerValidatorV2,
6
9
  } from '@boostxyz/evm/deploys/componentInterfaces.json';
7
10
  import { readContract } from '@wagmi/core';
8
11
  import { type Address, type Hex, decodeAbiParameters } from 'viem';
@@ -10,10 +13,20 @@ import type { DeployableOptions } from '../Deployable/Deployable';
10
13
  import { InvalidComponentInterfaceError } from '../errors';
11
14
  import type { ReadParams } from '../utils';
12
15
  import { LimitedSignerValidator } from './LimitedSignerValidator';
16
+ import { LimitedSignerValidatorV2 } from './LimitedSignerValidatorV2';
13
17
  import { PayableLimitedSignerValidator } from './PayableLimitedSignerValidator';
18
+ import { PayableLimitedSignerValidatorV2 } from './PayableLimitedSignerValidatorV2';
14
19
  import { SignerValidator } from './SignerValidator';
20
+ import { SignerValidatorV2 } from './SignerValidatorV2';
15
21
 
16
- export { SignerValidator, LimitedSignerValidator };
22
+ export {
23
+ SignerValidator,
24
+ LimitedSignerValidator,
25
+ PayableLimitedSignerValidator,
26
+ SignerValidatorV2,
27
+ LimitedSignerValidatorV2,
28
+ PayableLimitedSignerValidatorV2,
29
+ };
17
30
 
18
31
  /**
19
32
  * A union type representing all valid protocol Validator implementations
@@ -24,7 +37,10 @@ export { SignerValidator, LimitedSignerValidator };
24
37
  export type Validator =
25
38
  | SignerValidator
26
39
  | LimitedSignerValidator
27
- | PayableLimitedSignerValidator;
40
+ | PayableLimitedSignerValidator
41
+ | SignerValidatorV2
42
+ | LimitedSignerValidatorV2
43
+ | PayableLimitedSignerValidatorV2;
28
44
 
29
45
  /**
30
46
  * A map of Validator component interfaces to their constructors.
@@ -35,6 +51,9 @@ export const ValidatorByComponentInterface = {
35
51
  [ASignerValidator as Hex]: SignerValidator,
36
52
  [ALimitedSignerValidator as Hex]: LimitedSignerValidator,
37
53
  [APayableLimitedSignerValidator as Hex]: PayableLimitedSignerValidator,
54
+ [ASignerValidatorV2 as Hex]: SignerValidatorV2,
55
+ [ALimitedSignerValidatorV2 as Hex]: LimitedSignerValidatorV2,
56
+ [APayableLimitedSignerValidatorV2 as Hex]: PayableLimitedSignerValidatorV2,
38
57
  };
39
58
 
40
59
  /**
@@ -110,3 +129,27 @@ export function decodeClaimData(data: Hex) {
110
129
  data,
111
130
  )[0];
112
131
  }
132
+
133
+ /**
134
+ * Decodes a claim data hex string into its validator data, incentive data, and referrer components.
135
+ *
136
+ * @export
137
+ * @param {Hex} data - The hex-encoded claim data to decode
138
+ * @returns {{ validatorData: Hex; incentiveData: Hex, referrer: Address }} The decoded claim data components
139
+ */
140
+ export function decodeClaimDataWithReferrer(data: Hex) {
141
+ return decodeAbiParameters(
142
+ [
143
+ {
144
+ type: 'tuple',
145
+ name: 'BoostClaimDataWithReferrer',
146
+ components: [
147
+ { type: 'bytes', name: 'validatorData' },
148
+ { type: 'bytes', name: 'incentiveData' },
149
+ { type: 'address', name: 'referrer' },
150
+ ],
151
+ },
152
+ ],
153
+ data,
154
+ )[0];
155
+ }