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