@boostxyz/sdk 1.1.0-alpha.24 → 2.0.0-alpha.25
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.
- package/dist/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.js +7 -7
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +7 -7
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +153 -152
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +10 -10
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.js +10 -10
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.js +3 -3
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/BoostCore.cjs +2 -1
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +564 -1
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +1322 -29
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.js +27 -27
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.js +23 -23
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.js +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.js +23 -23
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.js +8 -8
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.js +12 -12
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.js +16 -16
- package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +2 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs.map +1 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +42 -15
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.js +188 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.js.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.cjs +2 -0
- package/dist/Incentives/ERC20VariableIncentive.cjs.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +7 -5
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/{Incentive-rM5nKznp.js → Incentives/ERC20VariableIncentive.js} +42 -67
- package/dist/Incentives/ERC20VariableIncentive.js.map +1 -0
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.cjs.map +1 -1
- package/dist/Incentives/Incentive.d.ts +552 -3
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +40 -16
- package/dist/Incentives/Incentive.js.map +1 -1
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.js +8 -8
- package/dist/{SimpleDenyList-DNj5qDWM.cjs → SimpleDenyList-BdlpZdDz.cjs} +2 -2
- package/dist/{SimpleDenyList-DNj5qDWM.cjs.map → SimpleDenyList-BdlpZdDz.cjs.map} +1 -1
- package/dist/{SimpleDenyList-BDXpY74P.js → SimpleDenyList-D0cyVUVv.js} +16 -16
- package/dist/{SimpleDenyList-BDXpY74P.js.map → SimpleDenyList-D0cyVUVv.js.map} +1 -1
- package/dist/Validators/LimitedSignerValidator.cjs +2 -0
- package/dist/Validators/LimitedSignerValidator.cjs.map +1 -0
- package/dist/Validators/LimitedSignerValidator.d.ts +806 -0
- package/dist/Validators/LimitedSignerValidator.d.ts.map +1 -0
- package/dist/Validators/LimitedSignerValidator.js +299 -0
- package/dist/Validators/LimitedSignerValidator.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +2 -2
- package/dist/Validators/SignerValidator.js +5 -5
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.cjs.map +1 -1
- package/dist/Validators/Validator.d.ts +22 -2
- package/dist/Validators/Validator.d.ts.map +1 -1
- package/dist/Validators/Validator.js +26 -17
- package/dist/Validators/Validator.js.map +1 -1
- package/dist/{componentInterfaces-BBCFkrZv.js → componentInterfaces-bIVo8eyA.js} +9 -9
- package/dist/componentInterfaces-bIVo8eyA.js.map +1 -0
- package/dist/{deployments-fJsWblwS.js → deployments-Ccx1MtoK.js} +5 -5
- package/dist/deployments-Ccx1MtoK.js.map +1 -0
- package/dist/{generated-CsNyWPKA.js → generated-BAKNSOjJ.js} +661 -381
- package/dist/generated-BAKNSOjJ.js.map +1 -0
- package/dist/generated-Cqn4wS01.cjs +3 -0
- package/dist/generated-Cqn4wS01.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +150 -138
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +27 -26
- package/dist/utils.js.map +1 -1
- package/package.json +21 -5
- package/src/Actions/EventAction.ts +29 -27
- package/src/BoostCore.test.ts +3 -3
- package/src/BoostCore.ts +51 -5
- package/src/Incentives/AllowListIncentive.test.ts +19 -21
- package/src/Incentives/CGDAIncentive.test.ts +20 -22
- package/src/Incentives/ERC1155Incentive.test.ts +14 -15
- package/src/Incentives/ERC20Incentive.test.ts +17 -19
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +62 -10
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +79 -37
- package/src/Incentives/ERC20VariableIncentive.test.ts +16 -18
- package/src/Incentives/ERC20VariableIncentive.ts +16 -8
- package/src/Incentives/Incentive.ts +4 -1
- package/src/Incentives/PointsIncentive.test.ts +3 -5
- package/src/Validators/LimitedSignerValidator.test.ts +223 -0
- package/src/Validators/LimitedSignerValidator.ts +707 -0
- package/src/Validators/SignerValidator.test.ts +21 -22
- package/src/Validators/SignerValidator.ts +2 -2
- package/src/Validators/Validator.test.ts +7 -1
- package/src/Validators/Validator.ts +30 -3
- package/src/index.test.ts +2 -0
- package/src/index.ts +1 -0
- package/src/utils.ts +11 -0
- package/dist/BoostCore-Btl5BdAs.cjs +0 -3
- package/dist/BoostCore-Btl5BdAs.cjs.map +0 -1
- package/dist/BoostCore-CD56zbYX.js +0 -2641
- package/dist/BoostCore-CD56zbYX.js.map +0 -1
- package/dist/Incentive-CcnOIc8L.cjs +0 -2
- package/dist/Incentive-CcnOIc8L.cjs.map +0 -1
- package/dist/Incentive-rM5nKznp.js.map +0 -1
- package/dist/componentInterfaces-BBCFkrZv.js.map +0 -1
- package/dist/deployments-fJsWblwS.js.map +0 -1
- package/dist/generated-CsNyWPKA.js.map +0 -1
- package/dist/generated-DHerxf1y.cjs +0 -3
- package/dist/generated-DHerxf1y.cjs.map +0 -1
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
import {
|
|
2
|
+
limitedSignerValidatorAbi,
|
|
3
|
+
readLimitedSignerValidatorHashSignerData,
|
|
4
|
+
readLimitedSignerValidatorSigners,
|
|
5
|
+
simulateLimitedSignerValidatorSetAuthorized,
|
|
6
|
+
simulateLimitedSignerValidatorSetValidatorCaller,
|
|
7
|
+
simulateLimitedSignerValidatorValidate,
|
|
8
|
+
writeLimitedSignerValidatorSetAuthorized,
|
|
9
|
+
writeLimitedSignerValidatorSetValidatorCaller,
|
|
10
|
+
writeLimitedSignerValidatorValidate,
|
|
11
|
+
} from '@boostxyz/evm';
|
|
12
|
+
import { bytecode } from '@boostxyz/evm/artifacts/contracts/validators/LimitedSignerValidator.sol/LimitedSignerValidator.json';
|
|
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';
|
|
21
|
+
// TODO
|
|
22
|
+
//import { LimitedSignerValidator as SignerValidatorBases } from '../../dist/deployments.json';
|
|
23
|
+
import { SignerValidator as SignerValidatorBases } from '../../dist/deployments.json';
|
|
24
|
+
import type {
|
|
25
|
+
DeployableOptions,
|
|
26
|
+
GenericDeployableParams,
|
|
27
|
+
} from '../Deployable/Deployable';
|
|
28
|
+
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
29
|
+
import {
|
|
30
|
+
type GenericLog,
|
|
31
|
+
type ReadParams,
|
|
32
|
+
RegistryType,
|
|
33
|
+
type WriteParams,
|
|
34
|
+
} from '../utils';
|
|
35
|
+
|
|
36
|
+
export { limitedSignerValidatorAbi };
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Object reprentation of a {@link LimitedSignerValidator} initialization payload
|
|
40
|
+
*
|
|
41
|
+
* @export
|
|
42
|
+
* @interface LimitedSignerValidatorPayload
|
|
43
|
+
* @typedef {LimitedSignerValidatorPayload}
|
|
44
|
+
*/
|
|
45
|
+
export interface LimitedSignerValidatorPayload {
|
|
46
|
+
/**
|
|
47
|
+
* The list of authorized signers. The first address in the list will be the initial owner of the contract.
|
|
48
|
+
*
|
|
49
|
+
* @type {Address[]}
|
|
50
|
+
*/
|
|
51
|
+
signers: Address[];
|
|
52
|
+
/**
|
|
53
|
+
* The authorized caller of the {@link prepareSignerValidator} function
|
|
54
|
+
* @type {Address}
|
|
55
|
+
*/
|
|
56
|
+
validatorCaller: Address;
|
|
57
|
+
/**
|
|
58
|
+
* The max quantity of claims a user can make for a given incentive,
|
|
59
|
+
* regardless of how many valid transactions they have
|
|
60
|
+
* @type {number}
|
|
61
|
+
*/
|
|
62
|
+
maxClaimCount: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Description placeholder
|
|
67
|
+
*
|
|
68
|
+
* @export
|
|
69
|
+
* @interface LimitedSignerValidatorValidatePayload
|
|
70
|
+
* @typedef {LimitedSignerValidatorValidatePayload}
|
|
71
|
+
*/
|
|
72
|
+
export interface LimitedSignerValidatorValidatePayload {
|
|
73
|
+
/**
|
|
74
|
+
* The ID of the boost.
|
|
75
|
+
*
|
|
76
|
+
* @type {bigint}
|
|
77
|
+
*/
|
|
78
|
+
boostId: bigint;
|
|
79
|
+
/**
|
|
80
|
+
* The ID of the incentive.
|
|
81
|
+
*
|
|
82
|
+
* @type {bigint}
|
|
83
|
+
*/
|
|
84
|
+
incentiveId: bigint;
|
|
85
|
+
/**
|
|
86
|
+
* The address of the claimant.
|
|
87
|
+
*
|
|
88
|
+
* @type {Address}
|
|
89
|
+
*/
|
|
90
|
+
claimant: Address;
|
|
91
|
+
/**
|
|
92
|
+
* The claim data.
|
|
93
|
+
*
|
|
94
|
+
* @type {Hex}
|
|
95
|
+
*/
|
|
96
|
+
claimData: Hex;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Object reprentation of a {@link LimitedSignerValidator} initialization payload
|
|
101
|
+
*
|
|
102
|
+
* @export
|
|
103
|
+
* @interface LimitedSignerValidatorPayload
|
|
104
|
+
* @typedef {LimitedSignerValidatorPayload}
|
|
105
|
+
*/
|
|
106
|
+
export interface LimitedSignerValidatorPayload {
|
|
107
|
+
/**
|
|
108
|
+
* The list of authorized signers. The first address in the list will be the initial owner of the contract.
|
|
109
|
+
*
|
|
110
|
+
* @type {Address[]}
|
|
111
|
+
*/
|
|
112
|
+
signers: Address[];
|
|
113
|
+
/**
|
|
114
|
+
* The authorized caller of the {@link prepareSignerValidator} function
|
|
115
|
+
* @type {Address}
|
|
116
|
+
*/
|
|
117
|
+
validatorCaller: Address;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Description placeholder
|
|
122
|
+
*
|
|
123
|
+
* @export
|
|
124
|
+
* @interface LimitedSignerValidatorValidatePayload
|
|
125
|
+
* @typedef {LimitedSignerValidatorValidatePayload}
|
|
126
|
+
*/
|
|
127
|
+
export interface LimitedSignerValidatorValidatePayload {
|
|
128
|
+
/**
|
|
129
|
+
* The ID of the boost.
|
|
130
|
+
*
|
|
131
|
+
* @type {bigint}
|
|
132
|
+
*/
|
|
133
|
+
boostId: bigint;
|
|
134
|
+
/**
|
|
135
|
+
* The ID of the incentive.
|
|
136
|
+
*
|
|
137
|
+
* @type {bigint}
|
|
138
|
+
*/
|
|
139
|
+
incentiveId: bigint;
|
|
140
|
+
/**
|
|
141
|
+
* The address of the claimant.
|
|
142
|
+
*
|
|
143
|
+
* @type {Address}
|
|
144
|
+
*/
|
|
145
|
+
claimant: Address;
|
|
146
|
+
/**
|
|
147
|
+
* The claim data.
|
|
148
|
+
*
|
|
149
|
+
* @type {Hex}
|
|
150
|
+
*/
|
|
151
|
+
claimData: Hex;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Signer Validator Claim Data Payload
|
|
156
|
+
*
|
|
157
|
+
* @export
|
|
158
|
+
* @interface LimitedSignerValidatorClaimDataParams
|
|
159
|
+
* @typedef {LimitedSignerValidatorClaimDataParams}
|
|
160
|
+
*/
|
|
161
|
+
export interface LimitedSignerValidatorClaimDataParams {
|
|
162
|
+
/**
|
|
163
|
+
* The signer with which to sign the input
|
|
164
|
+
*
|
|
165
|
+
* @type {{
|
|
166
|
+
* account: Address;
|
|
167
|
+
* key: Hex;
|
|
168
|
+
* privateKey: PrivateKeyAccount;
|
|
169
|
+
* }}
|
|
170
|
+
*/
|
|
171
|
+
signer: {
|
|
172
|
+
account: Address;
|
|
173
|
+
key: Hex;
|
|
174
|
+
privateKey: PrivateKeyAccount;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* The encoded data to provide the underlying incentive. You can use {@link prepareAllowListIncentivePayload}, {@link prepareCGDAIncentivePayload}, {@link prepareERC20IncentivePayload}, {@link prepareERC1155IncentivePayload}, or {@link preparePointsIncentivePayload}
|
|
178
|
+
*
|
|
179
|
+
* @type {Hex}
|
|
180
|
+
*/
|
|
181
|
+
incentiveData: Hex;
|
|
182
|
+
/**
|
|
183
|
+
* The chain id to target
|
|
184
|
+
*
|
|
185
|
+
* @type {number}
|
|
186
|
+
*/
|
|
187
|
+
chainId: number;
|
|
188
|
+
/**
|
|
189
|
+
* The address of the validator
|
|
190
|
+
*
|
|
191
|
+
* @type {Address}
|
|
192
|
+
*/
|
|
193
|
+
validator: Address;
|
|
194
|
+
/**
|
|
195
|
+
* The incentive quantity.
|
|
196
|
+
*
|
|
197
|
+
* @type {number}
|
|
198
|
+
*/
|
|
199
|
+
incentiveQuantity: number;
|
|
200
|
+
/**
|
|
201
|
+
* The address of the claimant
|
|
202
|
+
*
|
|
203
|
+
* @type {Address}
|
|
204
|
+
*/
|
|
205
|
+
claimant: Address;
|
|
206
|
+
/**
|
|
207
|
+
* The ID of the boost
|
|
208
|
+
*
|
|
209
|
+
* @type {bigint}
|
|
210
|
+
*/
|
|
211
|
+
boostId: bigint;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Object representation of a {@link LimitedSignerValidatorInputParams} initialization payload
|
|
216
|
+
*
|
|
217
|
+
* @export
|
|
218
|
+
* @interface LimitedSignerValidatorInputParams
|
|
219
|
+
* @typedef {LimitedSignerValidatorInputParams}
|
|
220
|
+
*/
|
|
221
|
+
export interface LimitedSignerValidatorInputParams {
|
|
222
|
+
/**
|
|
223
|
+
* The signer address.
|
|
224
|
+
*
|
|
225
|
+
* @type {Address}
|
|
226
|
+
*/
|
|
227
|
+
signer: Address;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The signature data.
|
|
231
|
+
*
|
|
232
|
+
* @type {string}
|
|
233
|
+
*/
|
|
234
|
+
signature: Hex;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The incentive quantity.
|
|
238
|
+
*
|
|
239
|
+
* @type {number}
|
|
240
|
+
*/
|
|
241
|
+
incentiveQuantity: number;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Object representing the payload for signing before validaton.
|
|
246
|
+
*
|
|
247
|
+
* @export
|
|
248
|
+
* @interface LimitedSignerValidatorSignaturePayload
|
|
249
|
+
* @typedef {LimitedSignerValidatorSignaturePayload}
|
|
250
|
+
*/
|
|
251
|
+
export interface LimitedSignerValidatorSignaturePayload {
|
|
252
|
+
/**
|
|
253
|
+
* The ID of the boost.
|
|
254
|
+
*
|
|
255
|
+
* @type {bigint}
|
|
256
|
+
*/
|
|
257
|
+
boostId: bigint;
|
|
258
|
+
/**
|
|
259
|
+
* The ID of the incentive.
|
|
260
|
+
*
|
|
261
|
+
* @type {number}
|
|
262
|
+
*/
|
|
263
|
+
incentiveQuantity: number;
|
|
264
|
+
/**
|
|
265
|
+
* The address of the claimant.
|
|
266
|
+
*
|
|
267
|
+
* @type {Address}
|
|
268
|
+
*/
|
|
269
|
+
claimant: Address;
|
|
270
|
+
/**
|
|
271
|
+
* The claim data.
|
|
272
|
+
*
|
|
273
|
+
* @type {Hex}
|
|
274
|
+
*/
|
|
275
|
+
incentiveData: Hex;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* A generic `viem.Log` event with support for `BoostCore` event types.
|
|
280
|
+
*
|
|
281
|
+
* @export
|
|
282
|
+
* @typedef {LimitedSignerValidatorLog}
|
|
283
|
+
* @template {ContractEventName<
|
|
284
|
+
* typeof limitedSignerValidatorAbi
|
|
285
|
+
* >} [event=ContractEventName<typeof limitedSignerValidatorAbi>]
|
|
286
|
+
*/
|
|
287
|
+
export type LimitedSignerValidatorLog<
|
|
288
|
+
event extends ContractEventName<
|
|
289
|
+
typeof limitedSignerValidatorAbi
|
|
290
|
+
> = ContractEventName<typeof limitedSignerValidatorAbi>,
|
|
291
|
+
> = GenericLog<typeof limitedSignerValidatorAbi, event>;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* A simple implementation of a Validator that verifies a given signature and checks the recovered address against a set of authorized signers
|
|
295
|
+
*
|
|
296
|
+
* @export
|
|
297
|
+
* @class SignerValidator
|
|
298
|
+
* @typedef {SignerValidator}
|
|
299
|
+
* @extends {DeployableTarget<SignerValidatorPayload>}
|
|
300
|
+
*/
|
|
301
|
+
export class LimitedSignerValidator extends DeployableTarget<
|
|
302
|
+
LimitedSignerValidatorPayload,
|
|
303
|
+
typeof limitedSignerValidatorAbi
|
|
304
|
+
> {
|
|
305
|
+
/**
|
|
306
|
+
* @inheritdoc
|
|
307
|
+
*
|
|
308
|
+
* @public
|
|
309
|
+
* @readonly
|
|
310
|
+
* @type {*}
|
|
311
|
+
*/
|
|
312
|
+
public override readonly abi = limitedSignerValidatorAbi;
|
|
313
|
+
/**
|
|
314
|
+
* @inheritdoc
|
|
315
|
+
*
|
|
316
|
+
* @public
|
|
317
|
+
* @static
|
|
318
|
+
* @type {Record<number, Address>}
|
|
319
|
+
*/
|
|
320
|
+
public static override bases: Record<number, Address> = {
|
|
321
|
+
31337: import.meta.env.VITE_LIMITED_SIGNER_VALIDATOR_BASE,
|
|
322
|
+
...(SignerValidatorBases as Record<number, Address>),
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* @inheritdoc
|
|
326
|
+
*
|
|
327
|
+
* @public
|
|
328
|
+
* @static
|
|
329
|
+
* @type {RegistryType}
|
|
330
|
+
*/
|
|
331
|
+
public static override registryType: RegistryType = RegistryType.VALIDATOR;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* The set of authorized signers
|
|
335
|
+
*
|
|
336
|
+
* @public
|
|
337
|
+
* @async
|
|
338
|
+
* @param {Address} address
|
|
339
|
+
* @param {?ReadParams} [params]
|
|
340
|
+
* @returns {Promise<boolean>}
|
|
341
|
+
*/
|
|
342
|
+
public async signers(
|
|
343
|
+
address: Address,
|
|
344
|
+
params?: ReadParams<typeof limitedSignerValidatorAbi, 'signers'>,
|
|
345
|
+
) {
|
|
346
|
+
return await readLimitedSignerValidatorSigners(this._config, {
|
|
347
|
+
address: this.assertValidAddress(),
|
|
348
|
+
args: [address],
|
|
349
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
350
|
+
...(params as any),
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Retrieve the hash and signer data for a given hash
|
|
356
|
+
*
|
|
357
|
+
* @public
|
|
358
|
+
* @async
|
|
359
|
+
* @param {SignerValidatorSignaturePayload} payload
|
|
360
|
+
* @param {?ReadParams} [params]
|
|
361
|
+
* @returns {Promise<Hex>}
|
|
362
|
+
*/
|
|
363
|
+
public async hashSignerData(
|
|
364
|
+
payload: LimitedSignerValidatorSignaturePayload,
|
|
365
|
+
params?: ReadParams<typeof limitedSignerValidatorAbi, 'hashSignerData'>,
|
|
366
|
+
) {
|
|
367
|
+
return await readLimitedSignerValidatorHashSignerData(this._config, {
|
|
368
|
+
address: this.assertValidAddress(),
|
|
369
|
+
args: [
|
|
370
|
+
payload.boostId,
|
|
371
|
+
payload.incentiveQuantity,
|
|
372
|
+
payload.claimant,
|
|
373
|
+
payload.incentiveData,
|
|
374
|
+
],
|
|
375
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
376
|
+
...(params as any),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* 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.
|
|
382
|
+
*
|
|
383
|
+
* @public
|
|
384
|
+
* @async
|
|
385
|
+
* @param {SignerValidatorValidatePayload} payload
|
|
386
|
+
* @param {?WriteParams} [params]
|
|
387
|
+
* @returns {Promise<boolean>} - True if the action has been validated based on the data payload
|
|
388
|
+
*/
|
|
389
|
+
protected async validate(
|
|
390
|
+
payload: LimitedSignerValidatorValidatePayload,
|
|
391
|
+
params?: WriteParams<typeof limitedSignerValidatorAbi, 'validate'>,
|
|
392
|
+
) {
|
|
393
|
+
return await this.awaitResult(this.validateRaw(payload, params));
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* 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.
|
|
398
|
+
*
|
|
399
|
+
* @public
|
|
400
|
+
* @async
|
|
401
|
+
* @param {SignerValidatorValidatePayload} payload
|
|
402
|
+
* @param {?WriteParams} [params]
|
|
403
|
+
* @returns {Promise<boolean>} - True if the action has been validated based on the data payload
|
|
404
|
+
*/
|
|
405
|
+
protected async validateRaw(
|
|
406
|
+
payload: LimitedSignerValidatorValidatePayload,
|
|
407
|
+
params?: ReadParams<typeof limitedSignerValidatorAbi, 'validate'>,
|
|
408
|
+
) {
|
|
409
|
+
const { request, result } = await simulateLimitedSignerValidatorValidate(
|
|
410
|
+
this._config,
|
|
411
|
+
{
|
|
412
|
+
address: this.assertValidAddress(),
|
|
413
|
+
args: [
|
|
414
|
+
payload.boostId,
|
|
415
|
+
payload.incentiveId,
|
|
416
|
+
payload.claimant,
|
|
417
|
+
payload.claimData,
|
|
418
|
+
],
|
|
419
|
+
...this.optionallyAttachAccount(),
|
|
420
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
421
|
+
...(params as any),
|
|
422
|
+
},
|
|
423
|
+
);
|
|
424
|
+
const hash = await writeLimitedSignerValidatorValidate(
|
|
425
|
+
this._config,
|
|
426
|
+
request,
|
|
427
|
+
);
|
|
428
|
+
return { hash, result };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Set the authorized status of a signer
|
|
433
|
+
*
|
|
434
|
+
* @public
|
|
435
|
+
* @async
|
|
436
|
+
* @param {Address[]} addresses - The list of signers to update
|
|
437
|
+
* @param {boolean[]} allowed - The authorized status of each signer
|
|
438
|
+
* @param {?WriteParams} [params]
|
|
439
|
+
* @returns {Promise<void>}
|
|
440
|
+
*/
|
|
441
|
+
public async setAuthorized(
|
|
442
|
+
addresses: Address[],
|
|
443
|
+
allowed: boolean[],
|
|
444
|
+
params?: WriteParams<typeof limitedSignerValidatorAbi, 'setAuthorized'>,
|
|
445
|
+
) {
|
|
446
|
+
return await this.awaitResult(
|
|
447
|
+
this.setAuthorizedRaw(addresses, allowed, params),
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Set the authorized status of a signer
|
|
453
|
+
*
|
|
454
|
+
* @public
|
|
455
|
+
* @async
|
|
456
|
+
* @param {Address[]} addresses - The list of signers to update
|
|
457
|
+
* @param {boolean[]} allowed - The authorized status of each signer
|
|
458
|
+
* @param {?WriteParams} [params]
|
|
459
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
460
|
+
*/
|
|
461
|
+
public async setAuthorizedRaw(
|
|
462
|
+
addresses: Address[],
|
|
463
|
+
allowed: boolean[],
|
|
464
|
+
params?: WriteParams<typeof limitedSignerValidatorAbi, 'setAuthorized'>,
|
|
465
|
+
) {
|
|
466
|
+
const { request, result } =
|
|
467
|
+
await simulateLimitedSignerValidatorSetAuthorized(this._config, {
|
|
468
|
+
address: this.assertValidAddress(),
|
|
469
|
+
args: [addresses, allowed],
|
|
470
|
+
...this.optionallyAttachAccount(),
|
|
471
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
472
|
+
...(params as any),
|
|
473
|
+
});
|
|
474
|
+
const hash = await writeLimitedSignerValidatorSetAuthorized(
|
|
475
|
+
this._config,
|
|
476
|
+
request,
|
|
477
|
+
);
|
|
478
|
+
return { hash, result };
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Update the authorized caller of the validator function
|
|
483
|
+
*
|
|
484
|
+
* @public
|
|
485
|
+
* @async
|
|
486
|
+
* @param {Address} address
|
|
487
|
+
* @param {?WriteParams} [params]
|
|
488
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
489
|
+
*/
|
|
490
|
+
public async setValidatorCallerRaw(
|
|
491
|
+
address: Address,
|
|
492
|
+
params?: WriteParams<
|
|
493
|
+
typeof limitedSignerValidatorAbi,
|
|
494
|
+
'setValidatorCaller'
|
|
495
|
+
>,
|
|
496
|
+
) {
|
|
497
|
+
const { request, result } =
|
|
498
|
+
await simulateLimitedSignerValidatorSetValidatorCaller(this._config, {
|
|
499
|
+
address: this.assertValidAddress(),
|
|
500
|
+
args: [address],
|
|
501
|
+
...this.optionallyAttachAccount(),
|
|
502
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
503
|
+
...(params as any),
|
|
504
|
+
});
|
|
505
|
+
const hash = await writeLimitedSignerValidatorSetValidatorCaller(
|
|
506
|
+
this._config,
|
|
507
|
+
request,
|
|
508
|
+
);
|
|
509
|
+
return { hash, result };
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Update the authorized caller of the validator function
|
|
514
|
+
*
|
|
515
|
+
* @public
|
|
516
|
+
* @async
|
|
517
|
+
* @param {Address} address
|
|
518
|
+
* @param {?WriteParams} [params]
|
|
519
|
+
* @returns {Promise<void>}
|
|
520
|
+
*/
|
|
521
|
+
public async setValidatorCaller(
|
|
522
|
+
address: Address,
|
|
523
|
+
params?: WriteParams<
|
|
524
|
+
typeof limitedSignerValidatorAbi,
|
|
525
|
+
'setValidatorCaller'
|
|
526
|
+
>,
|
|
527
|
+
) {
|
|
528
|
+
return await this.awaitResult(this.setValidatorCallerRaw(address, params));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Properly encodes the data needed to claim
|
|
533
|
+
*
|
|
534
|
+
* @public
|
|
535
|
+
* @async
|
|
536
|
+
* @param {SignerValidatorClaimDataParams} params
|
|
537
|
+
* @returns {Promise<Hex>}
|
|
538
|
+
*/
|
|
539
|
+
public async encodeClaimData(
|
|
540
|
+
params: Omit<LimitedSignerValidatorClaimDataParams, 'validator'>,
|
|
541
|
+
): Promise<Hex> {
|
|
542
|
+
return await prepareLimitedSignerValidatorClaimDataPayload({
|
|
543
|
+
...params,
|
|
544
|
+
validator: this.assertValidAddress(),
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* @inheritdoc
|
|
550
|
+
*
|
|
551
|
+
* @public
|
|
552
|
+
* @param {?SignerValidatorPayload} [_payload]
|
|
553
|
+
* @param {?DeployableOptions} [_options]
|
|
554
|
+
* @returns {GenericDeployableParams}
|
|
555
|
+
*/
|
|
556
|
+
public override buildParameters(
|
|
557
|
+
_payload?: LimitedSignerValidatorPayload,
|
|
558
|
+
_options?: DeployableOptions,
|
|
559
|
+
): GenericDeployableParams {
|
|
560
|
+
const [payload, options] = this.validateDeploymentConfig(
|
|
561
|
+
_payload,
|
|
562
|
+
_options,
|
|
563
|
+
);
|
|
564
|
+
return {
|
|
565
|
+
abi: limitedSignerValidatorAbi,
|
|
566
|
+
bytecode: bytecode as Hex,
|
|
567
|
+
args: [prepareLimitedSignerValidatorPayload(payload)],
|
|
568
|
+
...this.optionallyAttachAccount(options.account),
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Signer Validator Claim Data Payload Preparation
|
|
575
|
+
*
|
|
576
|
+
* @export
|
|
577
|
+
* @async
|
|
578
|
+
* @param {SignerValidatorClaimDataParams} param0
|
|
579
|
+
* @param {{ account: Address; key: Hex; privateKey: PrivateKeyAccount; }} param0.signer
|
|
580
|
+
* @param {Hex} param0.incentiveData
|
|
581
|
+
* @param {number} param0.chainId
|
|
582
|
+
* @param {Address} param0.validator
|
|
583
|
+
* @param {number} param0.incentiveQuantity
|
|
584
|
+
* @param {Address} param0.claimant
|
|
585
|
+
* @param {bigint} param0.boostId
|
|
586
|
+
* @returns {Promise<Hex>}
|
|
587
|
+
*/
|
|
588
|
+
export async function prepareLimitedSignerValidatorClaimDataPayload({
|
|
589
|
+
signer,
|
|
590
|
+
incentiveData,
|
|
591
|
+
chainId,
|
|
592
|
+
validator,
|
|
593
|
+
incentiveQuantity,
|
|
594
|
+
claimant,
|
|
595
|
+
boostId,
|
|
596
|
+
}: LimitedSignerValidatorClaimDataParams): Promise<Hex> {
|
|
597
|
+
const domain = {
|
|
598
|
+
name: 'LimitedSignerValidator',
|
|
599
|
+
version: '1',
|
|
600
|
+
chainId: chainId,
|
|
601
|
+
verifyingContract: validator,
|
|
602
|
+
};
|
|
603
|
+
const typedData = {
|
|
604
|
+
domain,
|
|
605
|
+
types: {
|
|
606
|
+
SignerValidatorData: [
|
|
607
|
+
{ name: 'boostId', type: 'uint256' },
|
|
608
|
+
{ name: 'incentiveQuantity', type: 'uint8' },
|
|
609
|
+
{ name: 'claimant', type: 'address' },
|
|
610
|
+
{ name: 'incentiveData', type: 'bytes' },
|
|
611
|
+
],
|
|
612
|
+
},
|
|
613
|
+
primaryType: 'SignerValidatorData' as const,
|
|
614
|
+
message: {
|
|
615
|
+
boostId,
|
|
616
|
+
incentiveQuantity,
|
|
617
|
+
claimant,
|
|
618
|
+
incentiveData: incentiveData,
|
|
619
|
+
},
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
const trustedSignature = await signTypedData({
|
|
623
|
+
...typedData,
|
|
624
|
+
privateKey: signer.key,
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
// Prepare the claim data payload using the new helper
|
|
628
|
+
const validatorData = prepareLimitedSignerValidatorInputParams({
|
|
629
|
+
signer: signer.account,
|
|
630
|
+
signature: trustedSignature,
|
|
631
|
+
incentiveQuantity, // Adjust incentive quantity as necessary
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
const boostClaimDataPayload = encodeAbiParameters(
|
|
635
|
+
[
|
|
636
|
+
{
|
|
637
|
+
type: 'tuple',
|
|
638
|
+
name: 'BoostClaimData',
|
|
639
|
+
components: [
|
|
640
|
+
{ type: 'bytes', name: 'validatorData' },
|
|
641
|
+
{ type: 'bytes', name: 'incentiveData' },
|
|
642
|
+
],
|
|
643
|
+
},
|
|
644
|
+
],
|
|
645
|
+
[{ validatorData, incentiveData }],
|
|
646
|
+
);
|
|
647
|
+
|
|
648
|
+
return boostClaimDataPayload;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Given a {@link SignerValidatorInputParams}, properly encode the initialization payload.
|
|
653
|
+
*
|
|
654
|
+
* @param {SignerValidatorInputParams} param0
|
|
655
|
+
* @param {Address} param0.signer
|
|
656
|
+
* @param {Hex} param0.signature
|
|
657
|
+
* @param {number} param0.incentiveQuantity
|
|
658
|
+
* @returns {Hex}
|
|
659
|
+
*/
|
|
660
|
+
export function prepareLimitedSignerValidatorInputParams({
|
|
661
|
+
signer,
|
|
662
|
+
signature,
|
|
663
|
+
incentiveQuantity,
|
|
664
|
+
}: LimitedSignerValidatorInputParams) {
|
|
665
|
+
return encodeAbiParameters(
|
|
666
|
+
[
|
|
667
|
+
{
|
|
668
|
+
type: 'tuple',
|
|
669
|
+
name: 'SignerValidatorInputParams',
|
|
670
|
+
components: [
|
|
671
|
+
{ type: 'address', name: 'signer' },
|
|
672
|
+
{ type: 'bytes', name: 'signature' },
|
|
673
|
+
{ type: 'uint8', name: 'incentiveQuantity' },
|
|
674
|
+
],
|
|
675
|
+
},
|
|
676
|
+
],
|
|
677
|
+
[{ signer, signature, incentiveQuantity }],
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Given a {@link SignerValidatorPayload}, properly encode the initialization payload.
|
|
683
|
+
*
|
|
684
|
+
* @param {SignerValidatorPayload} param0
|
|
685
|
+
SignerValidator: class TSignerValidator extends SignerValidator {
|
|
686
|
+
public static override bases: Record<number, Address> = {
|
|
687
|
+
[chainId]: signerValidatorBase,
|
|
688
|
+
};
|
|
689
|
+
},
|
|
690
|
+
* @param {Address[]} param0.signers
|
|
691
|
+
* @param {Address} param0.validatorCaller
|
|
692
|
+
* @returns {Hex}
|
|
693
|
+
*/
|
|
694
|
+
export function prepareLimitedSignerValidatorPayload({
|
|
695
|
+
signers,
|
|
696
|
+
validatorCaller,
|
|
697
|
+
maxClaimCount,
|
|
698
|
+
}: LimitedSignerValidatorPayload) {
|
|
699
|
+
return encodeAbiParameters(
|
|
700
|
+
[
|
|
701
|
+
{ type: 'address[]', name: 'signers' },
|
|
702
|
+
{ type: 'address', name: 'validatorCaller' },
|
|
703
|
+
{ type: 'uint256', name: 'maxClaimCount' },
|
|
704
|
+
],
|
|
705
|
+
[signers, validatorCaller, BigInt(maxClaimCount)],
|
|
706
|
+
);
|
|
707
|
+
}
|