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