@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
|
@@ -18,7 +18,14 @@ import {
|
|
|
18
18
|
writeErc20IncentiveDrawRaffle,
|
|
19
19
|
} from '@boostxyz/evm';
|
|
20
20
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20Incentive.sol/ERC20Incentive.json';
|
|
21
|
-
import
|
|
21
|
+
import {
|
|
22
|
+
type Address,
|
|
23
|
+
type ContractEventName,
|
|
24
|
+
type Hex,
|
|
25
|
+
encodeAbiParameters,
|
|
26
|
+
zeroHash,
|
|
27
|
+
} from 'viem';
|
|
28
|
+
import { ERC20Incentive as ERC20IncentiveBases } from '../../dist/deployments.json';
|
|
22
29
|
import type {
|
|
23
30
|
DeployableOptions,
|
|
24
31
|
GenericDeployableParams,
|
|
@@ -26,18 +33,57 @@ import type {
|
|
|
26
33
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
27
34
|
import {
|
|
28
35
|
type ClaimPayload,
|
|
29
|
-
type
|
|
36
|
+
type StrategyType,
|
|
37
|
+
prepareClaimPayload,
|
|
38
|
+
} from '../claiming';
|
|
39
|
+
import {
|
|
30
40
|
type GenericLog,
|
|
31
41
|
type ReadParams,
|
|
32
42
|
RegistryType,
|
|
33
|
-
type StrategyType,
|
|
34
43
|
type WriteParams,
|
|
35
|
-
prepareClaimPayload,
|
|
36
|
-
prepareERC20IncentivePayload,
|
|
37
44
|
} from '../utils';
|
|
38
45
|
|
|
39
46
|
export { erc20IncentiveAbi };
|
|
40
|
-
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The object representation of a `ERC20Incentive.InitPayload`
|
|
50
|
+
*
|
|
51
|
+
* @export
|
|
52
|
+
* @interface ERC20IncentivePayload
|
|
53
|
+
* @typedef {ERC20IncentivePayload}
|
|
54
|
+
*/
|
|
55
|
+
export interface ERC20IncentivePayload {
|
|
56
|
+
/**
|
|
57
|
+
* The address of the incentivized asset.
|
|
58
|
+
*
|
|
59
|
+
* @type {Address}
|
|
60
|
+
*/
|
|
61
|
+
asset: Address;
|
|
62
|
+
/**
|
|
63
|
+
* The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
64
|
+
*
|
|
65
|
+
* @type {StrategyType}
|
|
66
|
+
*/
|
|
67
|
+
strategy: StrategyType;
|
|
68
|
+
/**
|
|
69
|
+
* The amount of the asset to distribute.
|
|
70
|
+
*
|
|
71
|
+
* @type {bigint}
|
|
72
|
+
*/
|
|
73
|
+
reward: bigint;
|
|
74
|
+
/**
|
|
75
|
+
* How many times can this incentive be claimed.
|
|
76
|
+
*
|
|
77
|
+
* @type {bigint}
|
|
78
|
+
*/
|
|
79
|
+
limit: bigint;
|
|
80
|
+
/**
|
|
81
|
+
* The entity that can `clawback` funds
|
|
82
|
+
*
|
|
83
|
+
* @type {Address}
|
|
84
|
+
*/
|
|
85
|
+
manager: Address;
|
|
86
|
+
}
|
|
41
87
|
|
|
42
88
|
/**
|
|
43
89
|
* A generic `viem.Log` event with support for `ERC20Incentive` event types.
|
|
@@ -72,10 +118,11 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
72
118
|
*
|
|
73
119
|
* @public
|
|
74
120
|
* @static
|
|
75
|
-
* @type {Address}
|
|
121
|
+
* @type {Record<number, Address>}
|
|
76
122
|
*/
|
|
77
|
-
public static override
|
|
78
|
-
|
|
123
|
+
public static override bases: Record<number, Address> = {
|
|
124
|
+
...(ERC20IncentiveBases as Record<number, Address>),
|
|
125
|
+
};
|
|
79
126
|
/**
|
|
80
127
|
* @inheritdoc
|
|
81
128
|
*
|
|
@@ -90,11 +137,11 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
90
137
|
*
|
|
91
138
|
* @public
|
|
92
139
|
* @async
|
|
93
|
-
* @param {?ReadParams
|
|
94
|
-
* @returns {
|
|
140
|
+
* @param {?ReadParams} [params]
|
|
141
|
+
* @returns {Promise<Address>}
|
|
95
142
|
*/
|
|
96
143
|
public async owner(params?: ReadParams<typeof erc20IncentiveAbi, 'owner'>) {
|
|
97
|
-
return readErc20IncentiveOwner(this._config, {
|
|
144
|
+
return await readErc20IncentiveOwner(this._config, {
|
|
98
145
|
address: this.assertValidAddress(),
|
|
99
146
|
args: [],
|
|
100
147
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -107,13 +154,13 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
107
154
|
*
|
|
108
155
|
* @public
|
|
109
156
|
* @async
|
|
110
|
-
* @param {?ReadParams
|
|
157
|
+
* @param {?ReadParams} [params]
|
|
111
158
|
* @returns {Promise<bigint>} - The current reward
|
|
112
159
|
*/
|
|
113
160
|
public async currentReward(
|
|
114
161
|
params?: ReadParams<typeof erc20IncentiveAbi, 'currentReward'>,
|
|
115
162
|
) {
|
|
116
|
-
return readErc20IncentiveCurrentReward(this._config, {
|
|
163
|
+
return await readErc20IncentiveCurrentReward(this._config, {
|
|
117
164
|
address: this.assertValidAddress(),
|
|
118
165
|
args: [],
|
|
119
166
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -126,11 +173,11 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
126
173
|
*
|
|
127
174
|
* @public
|
|
128
175
|
* @async
|
|
129
|
-
* @param {?ReadParams
|
|
176
|
+
* @param {?ReadParams} [params]
|
|
130
177
|
* @returns {Promise<bigint>}
|
|
131
178
|
*/
|
|
132
179
|
public async claims(params?: ReadParams<typeof erc20IncentiveAbi, 'claims'>) {
|
|
133
|
-
return readErc20IncentiveClaims(this._config, {
|
|
180
|
+
return await readErc20IncentiveClaims(this._config, {
|
|
134
181
|
address: this.assertValidAddress(),
|
|
135
182
|
args: [],
|
|
136
183
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -144,14 +191,14 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
144
191
|
* @public
|
|
145
192
|
* @async
|
|
146
193
|
* @param {Address} address
|
|
147
|
-
* @param {?ReadParams
|
|
194
|
+
* @param {?ReadParams} [params]
|
|
148
195
|
* @returns {Promise<boolean>}
|
|
149
196
|
*/
|
|
150
197
|
public async claimed(
|
|
151
198
|
address: Address,
|
|
152
199
|
params?: ReadParams<typeof erc20IncentiveAbi, 'claimed'>,
|
|
153
200
|
) {
|
|
154
|
-
return readErc20IncentiveClaimed(this._config, {
|
|
201
|
+
return await readErc20IncentiveClaimed(this._config, {
|
|
155
202
|
address: this.assertValidAddress(),
|
|
156
203
|
args: [address],
|
|
157
204
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -164,11 +211,11 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
164
211
|
*
|
|
165
212
|
* @public
|
|
166
213
|
* @async
|
|
167
|
-
* @param {?ReadParams
|
|
214
|
+
* @param {?ReadParams} [params]
|
|
168
215
|
* @returns {Promise<Address>}
|
|
169
216
|
*/
|
|
170
217
|
public async asset(params?: ReadParams<typeof erc20IncentiveAbi, 'asset'>) {
|
|
171
|
-
return readErc20IncentiveAsset(this._config, {
|
|
218
|
+
return await readErc20IncentiveAsset(this._config, {
|
|
172
219
|
address: this.assertValidAddress(),
|
|
173
220
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
174
221
|
...(params as any),
|
|
@@ -180,10 +227,10 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
180
227
|
*
|
|
181
228
|
* @public
|
|
182
229
|
* @async
|
|
183
|
-
* @param {?ReadParams
|
|
230
|
+
* @param {?ReadParams} [params]
|
|
184
231
|
* @returns {Promise<StrategyType>}
|
|
185
232
|
*/
|
|
186
|
-
public
|
|
233
|
+
public strategy(
|
|
187
234
|
params?: ReadParams<typeof erc20IncentiveAbi, 'strategy'>,
|
|
188
235
|
): Promise<StrategyType> {
|
|
189
236
|
return readErc20IncentiveStrategy(this._config, {
|
|
@@ -198,11 +245,11 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
198
245
|
*
|
|
199
246
|
* @public
|
|
200
247
|
* @async
|
|
201
|
-
* @param {?ReadParams
|
|
248
|
+
* @param {?ReadParams} [params]
|
|
202
249
|
* @returns {Promise<bigint>}
|
|
203
250
|
*/
|
|
204
251
|
public async reward(params?: ReadParams<typeof erc20IncentiveAbi, 'reward'>) {
|
|
205
|
-
return readErc20IncentiveReward(this._config, {
|
|
252
|
+
return await readErc20IncentiveReward(this._config, {
|
|
206
253
|
address: this.assertValidAddress(),
|
|
207
254
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
208
255
|
...(params as any),
|
|
@@ -214,11 +261,11 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
214
261
|
*
|
|
215
262
|
* @public
|
|
216
263
|
* @async
|
|
217
|
-
* @param {?ReadParams
|
|
218
|
-
* @returns {
|
|
264
|
+
* @param {?ReadParams} [params]
|
|
265
|
+
* @returns {Promise<bigint>}
|
|
219
266
|
*/
|
|
220
267
|
public async limit(params?: ReadParams<typeof erc20IncentiveAbi, 'limit'>) {
|
|
221
|
-
return readErc20IncentiveLimit(this._config, {
|
|
268
|
+
return await readErc20IncentiveLimit(this._config, {
|
|
222
269
|
address: this.assertValidAddress(),
|
|
223
270
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
224
271
|
...(params as any),
|
|
@@ -231,14 +278,14 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
231
278
|
* @public
|
|
232
279
|
* @async
|
|
233
280
|
* @param {bigint} i - Index of address
|
|
234
|
-
* @param {?ReadParams
|
|
281
|
+
* @param {?ReadParams} [params]
|
|
235
282
|
* @returns {Promise<Address>}
|
|
236
283
|
*/
|
|
237
284
|
public async entries(
|
|
238
285
|
i: bigint,
|
|
239
286
|
params?: ReadParams<typeof erc20IncentiveAbi, 'entries'>,
|
|
240
287
|
) {
|
|
241
|
-
return readErc20IncentiveEntries(this._config, {
|
|
288
|
+
return await readErc20IncentiveEntries(this._config, {
|
|
242
289
|
address: this.assertValidAddress(),
|
|
243
290
|
args: [i],
|
|
244
291
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -252,14 +299,14 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
252
299
|
* @public
|
|
253
300
|
* @async
|
|
254
301
|
* @param {ClaimPayload} payload
|
|
255
|
-
* @param {?WriteParams
|
|
302
|
+
* @param {?WriteParams} [params]
|
|
256
303
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
257
304
|
*/
|
|
258
|
-
|
|
305
|
+
protected async claim(
|
|
259
306
|
payload: ClaimPayload,
|
|
260
307
|
params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
|
|
261
308
|
) {
|
|
262
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
309
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
263
310
|
}
|
|
264
311
|
|
|
265
312
|
/**
|
|
@@ -268,10 +315,10 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
268
315
|
* @public
|
|
269
316
|
* @async
|
|
270
317
|
* @param {ClaimPayload} payload
|
|
271
|
-
* @param {?WriteParams
|
|
272
|
-
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
318
|
+
* @param {?WriteParams} [params]
|
|
319
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns true if successfully claimed
|
|
273
320
|
*/
|
|
274
|
-
|
|
321
|
+
protected async claimRaw(
|
|
275
322
|
payload: ClaimPayload,
|
|
276
323
|
params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
|
|
277
324
|
) {
|
|
@@ -295,14 +342,14 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
295
342
|
* @public
|
|
296
343
|
* @async
|
|
297
344
|
* @param {ClaimPayload} payload
|
|
298
|
-
* @param {?WriteParams
|
|
345
|
+
* @param {?WriteParams} [params]
|
|
299
346
|
* @returns {Promise<boolean>} - True if the assets were successfully clawbacked
|
|
300
347
|
*/
|
|
301
348
|
public async clawback(
|
|
302
349
|
payload: ClaimPayload,
|
|
303
350
|
params?: WriteParams<typeof erc20IncentiveAbi, 'clawback'>,
|
|
304
351
|
) {
|
|
305
|
-
return this.awaitResult(this.clawbackRaw(payload, params));
|
|
352
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
306
353
|
}
|
|
307
354
|
|
|
308
355
|
/**
|
|
@@ -311,8 +358,8 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
311
358
|
* @public
|
|
312
359
|
* @async
|
|
313
360
|
* @param {ClaimPayload} payload
|
|
314
|
-
* @param {?WriteParams
|
|
315
|
-
* @returns {Promise<boolean>} - True if the assets were successfully clawbacked
|
|
361
|
+
* @param {?WriteParams} [params]
|
|
362
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the assets were successfully clawbacked
|
|
316
363
|
*/
|
|
317
364
|
public async clawbackRaw(
|
|
318
365
|
payload: ClaimPayload,
|
|
@@ -338,14 +385,14 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
338
385
|
* @public
|
|
339
386
|
* @async
|
|
340
387
|
* @param {ClaimPayload} payload
|
|
341
|
-
* @param {?ReadParams
|
|
342
|
-
* @returns {
|
|
388
|
+
* @param {?ReadParams} [params]
|
|
389
|
+
* @returns {Promise<boolean>} = True if the incentive is claimable based on the data payload
|
|
343
390
|
*/
|
|
344
391
|
public async isClaimable(
|
|
345
392
|
payload: ClaimPayload,
|
|
346
393
|
params?: ReadParams<typeof erc20IncentiveAbi, 'isClaimable'>,
|
|
347
394
|
) {
|
|
348
|
-
return readErc20IncentiveIsClaimable(this._config, {
|
|
395
|
+
return await readErc20IncentiveIsClaimable(this._config, {
|
|
349
396
|
address: this.assertValidAddress(),
|
|
350
397
|
args: [prepareClaimPayload(payload)],
|
|
351
398
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -358,13 +405,13 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
358
405
|
*
|
|
359
406
|
* @public
|
|
360
407
|
* @async
|
|
361
|
-
* @param {?WriteParams
|
|
408
|
+
* @param {?WriteParams} [params]
|
|
362
409
|
* @returns {Promise<void>}
|
|
363
410
|
*/
|
|
364
411
|
public async drawRaffle(
|
|
365
412
|
params?: WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>,
|
|
366
413
|
) {
|
|
367
|
-
return this.awaitResult(this.drawRaffleRaw(params));
|
|
414
|
+
return await this.awaitResult(this.drawRaffleRaw(params));
|
|
368
415
|
}
|
|
369
416
|
|
|
370
417
|
/**
|
|
@@ -372,8 +419,8 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
372
419
|
*
|
|
373
420
|
* @public
|
|
374
421
|
* @async
|
|
375
|
-
* @param {?WriteParams
|
|
376
|
-
* @returns {Promise<void>}
|
|
422
|
+
* @param {?WriteParams} [params]
|
|
423
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
377
424
|
*/
|
|
378
425
|
public async drawRaffleRaw(
|
|
379
426
|
params?: WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>,
|
|
@@ -414,4 +461,42 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
414
461
|
...this.optionallyAttachAccount(options.account),
|
|
415
462
|
};
|
|
416
463
|
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Builds the claim data for the ERC20Incentive.
|
|
467
|
+
*
|
|
468
|
+
* @public
|
|
469
|
+
* @returns {Hash} A `zeroHash`, as ERC20Incentive doesn't require specific claim data.
|
|
470
|
+
* @description This function returns `zeroHash` because ERC20Incentive doesn't use any specific claim data.
|
|
471
|
+
*/
|
|
472
|
+
public buildClaimData() {
|
|
473
|
+
return zeroHash;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Given a {@link ERC20IncentivePayload}, properly encode a `ERC20Incentive.InitPayload` for use with {@link ERC20Incentive} initialization.
|
|
479
|
+
*
|
|
480
|
+
* @param {ERC20IncentivePayload} param0
|
|
481
|
+
* @param {Address} param0.asset - The address of the incentivized asset.
|
|
482
|
+
* @param {StrategyType} param0.strategy - The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
483
|
+
* @param {bigint} param0.reward - The amount of the asset to distribute.
|
|
484
|
+
* @param {bigint} param0.limit - How many times can this incentive be claimed.
|
|
485
|
+
* @returns {Hex}
|
|
486
|
+
*/
|
|
487
|
+
export function prepareERC20IncentivePayload({
|
|
488
|
+
asset,
|
|
489
|
+
strategy,
|
|
490
|
+
reward,
|
|
491
|
+
limit,
|
|
492
|
+
}: ERC20IncentivePayload) {
|
|
493
|
+
return encodeAbiParameters(
|
|
494
|
+
[
|
|
495
|
+
{ type: 'address', name: 'asset' },
|
|
496
|
+
{ type: 'uint8', name: 'strategy' },
|
|
497
|
+
{ type: 'uint256', name: 'reward' },
|
|
498
|
+
{ type: 'uint256', name: 'limit' },
|
|
499
|
+
],
|
|
500
|
+
[asset, strategy, reward, limit],
|
|
501
|
+
);
|
|
417
502
|
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Mock } from 'node:test';
|
|
2
|
+
import { selectors as eventSelectors } from '@boostxyz/signatures/events';
|
|
3
|
+
import { selectors as funcSelectors } from '@boostxyz/signatures/functions';
|
|
4
|
+
import type { MockERC20 } from '@boostxyz/test/MockERC20';
|
|
5
|
+
import type { MockERC721 } from '@boostxyz/test/MockERC721';
|
|
6
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
7
|
+
import {
|
|
8
|
+
type BudgetFixtures,
|
|
9
|
+
type Fixtures,
|
|
10
|
+
defaultOptions,
|
|
11
|
+
deployFixtures,
|
|
12
|
+
freshBoost,
|
|
13
|
+
fundBudget,
|
|
14
|
+
fundErc20,
|
|
15
|
+
fundErc721,
|
|
16
|
+
} from '@boostxyz/test/helpers';
|
|
17
|
+
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
18
|
+
import { type Hex, isAddress, parseEther } from 'viem';
|
|
19
|
+
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
20
|
+
import { SignatureType } from '../Actions/EventAction';
|
|
21
|
+
import type { Boost } from '../Boost';
|
|
22
|
+
import type {
|
|
23
|
+
ERC20VariableCriteriaIncentive,
|
|
24
|
+
ERC20VariableCriteriaIncentivePayload,
|
|
25
|
+
IncentiveCriteria,
|
|
26
|
+
} from './ERC20VariableCriteriaIncentive';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A basic ERC721 mint scalar criteria for testing
|
|
30
|
+
*
|
|
31
|
+
* @param {MockERC721} erc721 - The ERC721 contract
|
|
32
|
+
* @returns {IncentiveCriteria} - Returns a basic incentive criteria
|
|
33
|
+
*/
|
|
34
|
+
export function basicErc721TransferScalarCriteria(
|
|
35
|
+
erc721: MockERC721,
|
|
36
|
+
): IncentiveCriteria {
|
|
37
|
+
return {
|
|
38
|
+
criteriaType: SignatureType.FUNC,
|
|
39
|
+
signature: funcSelectors['transferFrom(address,address,uint256)'] as Hex, // Function selector for mint
|
|
40
|
+
fieldIndex: 2, // Field where the scalar value resides
|
|
41
|
+
targetContract: erc721.assertValidAddress(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A basic ERC721 mint scalar criteria for testing
|
|
47
|
+
*
|
|
48
|
+
* @param {MockERC721} erc721 - The ERC721 contract
|
|
49
|
+
* @returns {IncentiveCriteria} - Returns a basic incentive criteria
|
|
50
|
+
*/
|
|
51
|
+
export function basicErc721MintScalarCriteria(
|
|
52
|
+
erc721: MockERC721,
|
|
53
|
+
): IncentiveCriteria {
|
|
54
|
+
return {
|
|
55
|
+
criteriaType: SignatureType.EVENT,
|
|
56
|
+
signature: eventSelectors[
|
|
57
|
+
'Transfer(address indexed,address indexed,uint256 indexed)'
|
|
58
|
+
] as Hex, // Function selector for mint
|
|
59
|
+
fieldIndex: 2, // Field where the scalar value resides
|
|
60
|
+
targetContract: erc721.assertValidAddress(),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A basic ERC721 mint scalar payload for testing
|
|
66
|
+
*
|
|
67
|
+
* @param {MockERC721} erc721 - The ERC721 contract
|
|
68
|
+
* @returns {ERC20VariableCriteriaIncentivePayload} - Returns a full variable criteria incentive payload
|
|
69
|
+
*/
|
|
70
|
+
export function basicErc721TransferScalarPayload(
|
|
71
|
+
erc721: MockERC721,
|
|
72
|
+
): ERC20VariableCriteriaIncentivePayload {
|
|
73
|
+
return {
|
|
74
|
+
asset: erc721.assertValidAddress(),
|
|
75
|
+
reward: 1n,
|
|
76
|
+
limit: 1n,
|
|
77
|
+
criteria: basicErc721TransferScalarCriteria(erc721),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let fixtures: Fixtures,
|
|
82
|
+
erc20: MockERC20,
|
|
83
|
+
erc721: MockERC721,
|
|
84
|
+
erc20Incentive: ERC20VariableCriteriaIncentive,
|
|
85
|
+
budgets: BudgetFixtures,
|
|
86
|
+
boost: Boost;
|
|
87
|
+
|
|
88
|
+
describe('ERC20VariableCriteriaIncentive', () => {
|
|
89
|
+
beforeAll(async () => {
|
|
90
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
beforeEach(async () => {
|
|
94
|
+
budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
|
|
95
|
+
erc20 = await loadFixture(fundErc20(defaultOptions));
|
|
96
|
+
erc721 = await loadFixture(fundErc721(defaultOptions));
|
|
97
|
+
erc20Incentive = fixtures.core.ERC20VariableCriteriaIncentive({
|
|
98
|
+
asset: budgets.erc20.assertValidAddress(),
|
|
99
|
+
reward: 1n,
|
|
100
|
+
limit: 1n,
|
|
101
|
+
criteria: basicErc721TransferScalarCriteria(erc721),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
boost = await freshBoost(fixtures, {
|
|
105
|
+
budget: budgets.budget,
|
|
106
|
+
incentives: [erc20Incentive],
|
|
107
|
+
});
|
|
108
|
+
expect(isAddress(boost.incentives[0]!.assertValidAddress())).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('getIncentiveCriteria', () => {
|
|
112
|
+
test('should fetch incentive criteria successfully', async () => {
|
|
113
|
+
const incentive = boost.incentives[0] as ERC20VariableCriteriaIncentive;
|
|
114
|
+
const criteria = await incentive.getIncentiveCriteria();
|
|
115
|
+
expect(criteria).toMatchObject({
|
|
116
|
+
criteriaType: SignatureType.FUNC,
|
|
117
|
+
signature: expect.any(String),
|
|
118
|
+
fieldIndex: expect.any(Number),
|
|
119
|
+
targetContract: expect.any(String),
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('getIncentiveScalar', () => {
|
|
125
|
+
test('should return a valid scalar for function-based criteria', async () => {
|
|
126
|
+
const recipient = accounts[1].account;
|
|
127
|
+
|
|
128
|
+
const { hash } = await erc721.transferFromRaw(
|
|
129
|
+
accounts[0].account,
|
|
130
|
+
recipient,
|
|
131
|
+
1n,
|
|
132
|
+
);
|
|
133
|
+
const scalar = await erc20Incentive.getIncentiveScalar({ hash });
|
|
134
|
+
|
|
135
|
+
expect(scalar).toBe(1n);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('should return a valid scalar for event-based criteria', async () => {
|
|
139
|
+
erc20Incentive = fixtures.core.ERC20VariableCriteriaIncentive({
|
|
140
|
+
asset: budgets.erc20.assertValidAddress(),
|
|
141
|
+
reward: 1n,
|
|
142
|
+
limit: 1n,
|
|
143
|
+
criteria: basicErc721MintScalarCriteria(erc721),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
boost = await freshBoost(fixtures, {
|
|
147
|
+
budget: budgets.budget,
|
|
148
|
+
incentives: [erc20Incentive],
|
|
149
|
+
});
|
|
150
|
+
const recipient = accounts[1].account;
|
|
151
|
+
const { hash } = await erc721.transferFromRaw(
|
|
152
|
+
accounts[0].account,
|
|
153
|
+
recipient,
|
|
154
|
+
1n,
|
|
155
|
+
);
|
|
156
|
+
const scalar = await erc20Incentive.getIncentiveScalar({ hash });
|
|
157
|
+
|
|
158
|
+
expect(scalar).toBe(1n);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('should throw NoMatchingLogsError for event criteria with no matching logs', async () => {
|
|
162
|
+
const recipient = accounts[1].account;
|
|
163
|
+
|
|
164
|
+
const { hash } = await erc20.mintRaw(recipient, parseEther('100'));
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
await erc20Incentive.getIncentiveScalar({ hash });
|
|
168
|
+
} catch (e) {
|
|
169
|
+
expect((e as Error).name).toBe('DecodedArgsError');
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('should throw DecodedArgsError for invalid function-based data', async () => {
|
|
174
|
+
const recipient = accounts[1].account;
|
|
175
|
+
const { hash } = await erc20.mintRaw(recipient, parseEther('100'));
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
await erc20Incentive.getIncentiveScalar({ hash });
|
|
179
|
+
} catch (e) {
|
|
180
|
+
expect((e as Error).name).toBe('DecodedArgsError');
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|