@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
|
@@ -12,25 +12,62 @@ import {
|
|
|
12
12
|
writePointsIncentiveClaim,
|
|
13
13
|
} from '@boostxyz/evm';
|
|
14
14
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/PointsIncentive.sol/PointsIncentive.json';
|
|
15
|
-
import
|
|
15
|
+
import {
|
|
16
|
+
type Address,
|
|
17
|
+
type ContractEventName,
|
|
18
|
+
type Hex,
|
|
19
|
+
encodeAbiParameters,
|
|
20
|
+
zeroHash,
|
|
21
|
+
} from 'viem';
|
|
22
|
+
import { PointsIncentive as PointsIncentiveBases } from '../../dist/deployments.json';
|
|
16
23
|
import type {
|
|
17
24
|
DeployableOptions,
|
|
18
25
|
GenericDeployableParams,
|
|
19
26
|
} from '../Deployable/Deployable';
|
|
20
27
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
28
|
+
import { type ClaimPayload, prepareClaimPayload } from '../claiming';
|
|
21
29
|
import {
|
|
22
|
-
type ClaimPayload,
|
|
23
30
|
type GenericLog,
|
|
24
|
-
type PointsIncentivePayload,
|
|
25
31
|
type ReadParams,
|
|
26
32
|
RegistryType,
|
|
27
33
|
type WriteParams,
|
|
28
|
-
prepareClaimPayload,
|
|
29
|
-
preparePointsIncentivePayload,
|
|
30
34
|
} from '../utils';
|
|
31
35
|
|
|
32
36
|
export { pointsIncentiveAbi };
|
|
33
|
-
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The object representation of a `PointsIncentive.InitPayload`
|
|
40
|
+
*
|
|
41
|
+
* @export
|
|
42
|
+
* @interface PointsIncentivePayload
|
|
43
|
+
* @typedef {PointsIncentivePayload}
|
|
44
|
+
*/
|
|
45
|
+
export interface PointsIncentivePayload {
|
|
46
|
+
/**
|
|
47
|
+
* The address of the points contract
|
|
48
|
+
*
|
|
49
|
+
* @type {Address}
|
|
50
|
+
*/
|
|
51
|
+
venue: Address;
|
|
52
|
+
/**
|
|
53
|
+
* The selector for the issuance function on the points contract
|
|
54
|
+
*
|
|
55
|
+
* @type {Hex}
|
|
56
|
+
*/
|
|
57
|
+
selector: Hex;
|
|
58
|
+
/**
|
|
59
|
+
* The reward amount issued for each claim
|
|
60
|
+
*
|
|
61
|
+
* @type {bigint}
|
|
62
|
+
*/
|
|
63
|
+
reward: bigint;
|
|
64
|
+
/**
|
|
65
|
+
* The maximum number of claims that can be made (one per address)
|
|
66
|
+
*
|
|
67
|
+
* @type {bigint}
|
|
68
|
+
*/
|
|
69
|
+
limit: bigint;
|
|
70
|
+
}
|
|
34
71
|
|
|
35
72
|
/**
|
|
36
73
|
* A generic `viem.Log` event with support for `PointsIncentive` event types.
|
|
@@ -70,10 +107,11 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
70
107
|
*
|
|
71
108
|
* @public
|
|
72
109
|
* @static
|
|
73
|
-
* @type {Address}
|
|
110
|
+
* @type {Record<number, Address>}
|
|
74
111
|
*/
|
|
75
|
-
public static override
|
|
76
|
-
|
|
112
|
+
public static override bases: Record<number, Address> = {
|
|
113
|
+
...(PointsIncentiveBases as Record<number, Address>),
|
|
114
|
+
};
|
|
77
115
|
/**
|
|
78
116
|
* @inheritdoc
|
|
79
117
|
*
|
|
@@ -88,13 +126,13 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
88
126
|
*
|
|
89
127
|
* @public
|
|
90
128
|
* @async
|
|
91
|
-
* @param {?ReadParams
|
|
129
|
+
* @param {?ReadParams} [params]
|
|
92
130
|
* @returns {Promise<bigint>}
|
|
93
131
|
*/
|
|
94
132
|
public async claims(
|
|
95
133
|
params?: ReadParams<typeof pointsIncentiveAbi, 'claims'>,
|
|
96
134
|
) {
|
|
97
|
-
return readPointsIncentiveClaims(this._config, {
|
|
135
|
+
return await readPointsIncentiveClaims(this._config, {
|
|
98
136
|
address: this.assertValidAddress(),
|
|
99
137
|
args: [],
|
|
100
138
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -107,13 +145,13 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
107
145
|
*
|
|
108
146
|
* @public
|
|
109
147
|
* @async
|
|
110
|
-
* @param {?ReadParams
|
|
148
|
+
* @param {?ReadParams} [params]
|
|
111
149
|
* @returns {Promise<bigint>} - The current reward
|
|
112
150
|
*/
|
|
113
151
|
public async currentReward(
|
|
114
152
|
params?: ReadParams<typeof pointsIncentiveAbi, 'currentReward'>,
|
|
115
153
|
) {
|
|
116
|
-
return readPointsIncentiveCurrentReward(this._config, {
|
|
154
|
+
return await readPointsIncentiveCurrentReward(this._config, {
|
|
117
155
|
address: this.assertValidAddress(),
|
|
118
156
|
args: [],
|
|
119
157
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -126,13 +164,13 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
126
164
|
*
|
|
127
165
|
* @public
|
|
128
166
|
* @async
|
|
129
|
-
* @param {?ReadParams
|
|
130
|
-
* @returns {
|
|
167
|
+
* @param {?ReadParams} [params]
|
|
168
|
+
* @returns {Promise<bigint>} The reward amount issued for each claim
|
|
131
169
|
*/
|
|
132
170
|
public async reward(
|
|
133
171
|
params?: ReadParams<typeof pointsIncentiveAbi, 'reward'>,
|
|
134
172
|
) {
|
|
135
|
-
return readPointsIncentiveReward(this._config, {
|
|
173
|
+
return await readPointsIncentiveReward(this._config, {
|
|
136
174
|
address: this.assertValidAddress(),
|
|
137
175
|
args: [],
|
|
138
176
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -146,14 +184,14 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
146
184
|
* @public
|
|
147
185
|
* @async
|
|
148
186
|
* @param {Address} address
|
|
149
|
-
* @param {?ReadParams
|
|
150
|
-
* @returns {
|
|
187
|
+
* @param {?ReadParams} [params]
|
|
188
|
+
* @returns {Promise<boolean>}
|
|
151
189
|
*/
|
|
152
190
|
public async claimed(
|
|
153
191
|
address: Address,
|
|
154
192
|
params?: ReadParams<typeof pointsIncentiveAbi, 'claimed'>,
|
|
155
193
|
) {
|
|
156
|
-
return readPointsIncentiveClaimed(this._config, {
|
|
194
|
+
return await readPointsIncentiveClaimed(this._config, {
|
|
157
195
|
address: this.assertValidAddress(),
|
|
158
196
|
args: [address],
|
|
159
197
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -166,11 +204,11 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
166
204
|
*
|
|
167
205
|
* @public
|
|
168
206
|
* @async
|
|
169
|
-
* @param {?ReadParams
|
|
170
|
-
* @returns {
|
|
207
|
+
* @param {?ReadParams} [params]
|
|
208
|
+
* @returns {Promise<Address>}
|
|
171
209
|
*/
|
|
172
210
|
public async venue(params?: ReadParams<typeof pointsIncentiveAbi, 'venue'>) {
|
|
173
|
-
return readPointsIncentiveVenue(this._config, {
|
|
211
|
+
return await readPointsIncentiveVenue(this._config, {
|
|
174
212
|
address: this.assertValidAddress(),
|
|
175
213
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
176
214
|
...(params as any),
|
|
@@ -182,11 +220,11 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
182
220
|
*
|
|
183
221
|
* @public
|
|
184
222
|
* @async
|
|
185
|
-
* @param {?ReadParams
|
|
223
|
+
* @param {?ReadParams} [params]
|
|
186
224
|
* @returns {Promise<bigint>}
|
|
187
225
|
*/
|
|
188
226
|
public async limit(params?: ReadParams<typeof pointsIncentiveAbi, 'limit'>) {
|
|
189
|
-
return readPointsIncentiveLimit(this._config, {
|
|
227
|
+
return await readPointsIncentiveLimit(this._config, {
|
|
190
228
|
address: this.assertValidAddress(),
|
|
191
229
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
192
230
|
...(params as any),
|
|
@@ -198,13 +236,13 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
198
236
|
*
|
|
199
237
|
* @public
|
|
200
238
|
* @async
|
|
201
|
-
* @param {?ReadParams
|
|
239
|
+
* @param {?ReadParams} [params]
|
|
202
240
|
* @returns {Promise<Hex>}
|
|
203
241
|
*/
|
|
204
242
|
public async selector(
|
|
205
243
|
params?: ReadParams<typeof pointsIncentiveAbi, 'selector'>,
|
|
206
244
|
) {
|
|
207
|
-
return readPointsIncentiveSelector(this._config, {
|
|
245
|
+
return await readPointsIncentiveSelector(this._config, {
|
|
208
246
|
address: this.assertValidAddress(),
|
|
209
247
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
210
248
|
...(params as any),
|
|
@@ -217,14 +255,14 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
217
255
|
* @public
|
|
218
256
|
* @async
|
|
219
257
|
* @param {ClaimPayload} payload
|
|
220
|
-
* @param {?WriteParams
|
|
258
|
+
* @param {?WriteParams} [params]
|
|
221
259
|
* @returns {Promise<boolean>} - True if the incentive was successfully claimed
|
|
222
260
|
*/
|
|
223
|
-
|
|
261
|
+
protected async claim(
|
|
224
262
|
payload: ClaimPayload,
|
|
225
263
|
params?: WriteParams<typeof pointsIncentiveAbi, 'claim'>,
|
|
226
264
|
) {
|
|
227
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
265
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
228
266
|
}
|
|
229
267
|
|
|
230
268
|
/**
|
|
@@ -233,10 +271,10 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
233
271
|
* @public
|
|
234
272
|
* @async
|
|
235
273
|
* @param {ClaimPayload} payload
|
|
236
|
-
* @param {?WriteParams
|
|
237
|
-
* @returns {Promise<boolean>} - True if the incentive was successfully claimed
|
|
274
|
+
* @param {?WriteParams} [params]
|
|
275
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the incentive was successfully claimed
|
|
238
276
|
*/
|
|
239
|
-
|
|
277
|
+
protected async claimRaw(
|
|
240
278
|
payload: ClaimPayload,
|
|
241
279
|
params?: WriteParams<typeof pointsIncentiveAbi, 'claim'>,
|
|
242
280
|
) {
|
|
@@ -262,14 +300,14 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
262
300
|
* @public
|
|
263
301
|
* @async
|
|
264
302
|
* @param {ClaimPayload} payload
|
|
265
|
-
* @param {?ReadParams
|
|
303
|
+
* @param {?ReadParams} [params]
|
|
266
304
|
* @returns {Promise<boolean>} - True if the incentive is claimable based on the data payload
|
|
267
305
|
*/
|
|
268
306
|
public async isClaimable(
|
|
269
307
|
payload: ClaimPayload,
|
|
270
308
|
params?: ReadParams<typeof pointsIncentiveAbi, 'isClaimable'>,
|
|
271
309
|
) {
|
|
272
|
-
return readPointsIncentiveIsClaimable(this._config, {
|
|
310
|
+
return await readPointsIncentiveIsClaimable(this._config, {
|
|
273
311
|
address: this.assertValidAddress(),
|
|
274
312
|
args: [prepareClaimPayload(payload)],
|
|
275
313
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -300,4 +338,42 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
300
338
|
...this.optionallyAttachAccount(options.account),
|
|
301
339
|
};
|
|
302
340
|
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Builds the claim data for the PointsIncentive.
|
|
344
|
+
*
|
|
345
|
+
* @public
|
|
346
|
+
* @returns {Hash} A `zeroHash`, as PointsIncentive doesn't require specific claim data.
|
|
347
|
+
* @description This function returns `zeroHash` because PointsIncentive doesn't use any specific claim data.
|
|
348
|
+
*/
|
|
349
|
+
public buildClaimData() {
|
|
350
|
+
return zeroHash;
|
|
351
|
+
}
|
|
303
352
|
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Given a {@link PointsIncentivePayload}, properly encode a `PointsIncentive.InitPayload` for use with {@link PointsIncentive} initialization.
|
|
356
|
+
*
|
|
357
|
+
* @param {PointsIncentivePayload} param0
|
|
358
|
+
* @param {Address} param0.venue - The address of the points contract
|
|
359
|
+
* @param {Hex} param0.selector - The selector for the issuance function on the points contract
|
|
360
|
+
* @param {bigint} param0.reward - The reward amount issued for each claim
|
|
361
|
+
* @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
|
|
362
|
+
* @returns {*}
|
|
363
|
+
*/
|
|
364
|
+
export const preparePointsIncentivePayload = ({
|
|
365
|
+
venue,
|
|
366
|
+
selector,
|
|
367
|
+
reward,
|
|
368
|
+
limit,
|
|
369
|
+
}: PointsIncentivePayload) => {
|
|
370
|
+
return encodeAbiParameters(
|
|
371
|
+
[
|
|
372
|
+
{ type: 'address', name: 'venue' },
|
|
373
|
+
{ type: 'bytes4', name: 'selector' },
|
|
374
|
+
{ type: 'uint256', name: 'reward' },
|
|
375
|
+
{ type: 'uint256', name: 'limit' },
|
|
376
|
+
],
|
|
377
|
+
[venue, selector, reward, limit],
|
|
378
|
+
);
|
|
379
|
+
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
2
2
|
import { isAddress, pad } from 'viem';
|
|
3
3
|
import { beforeAll, describe, expect, test } from 'vitest';
|
|
4
|
-
import { accounts } from '
|
|
4
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
5
5
|
import {
|
|
6
6
|
type Fixtures,
|
|
7
7
|
defaultOptions,
|
|
8
8
|
deployFixtures,
|
|
9
|
-
} from '
|
|
10
|
-
import { testAccount } from '
|
|
11
|
-
import { prepareSignerValidatorClaimDataPayload } from '../utils';
|
|
9
|
+
} from '@boostxyz/test/helpers';
|
|
10
|
+
import { testAccount } from '@boostxyz/test/viem';
|
|
12
11
|
import { SignerValidator } from './SignerValidator';
|
|
13
12
|
|
|
14
13
|
let fixtures: Fixtures;
|
|
@@ -17,9 +16,9 @@ function freshValidator(fixtures: Fixtures) {
|
|
|
17
16
|
return function freshValidator() {
|
|
18
17
|
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
19
18
|
const account = accounts.at(1)!.account;
|
|
20
|
-
return fixtures.registry.
|
|
19
|
+
return fixtures.registry.initialize(
|
|
21
20
|
crypto.randomUUID(),
|
|
22
|
-
|
|
21
|
+
fixtures.core.SignerValidator({
|
|
23
22
|
signers: [defaultOptions.account.address, account],
|
|
24
23
|
validatorCaller: testAccount.address,
|
|
25
24
|
}),
|
|
@@ -29,7 +28,7 @@ function freshValidator(fixtures: Fixtures) {
|
|
|
29
28
|
|
|
30
29
|
describe('SignerValidator', () => {
|
|
31
30
|
beforeAll(async () => {
|
|
32
|
-
fixtures = await loadFixture(deployFixtures);
|
|
31
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
test('can successfully be deployed', async () => {
|
|
@@ -65,21 +64,19 @@ describe('SignerValidator', () => {
|
|
|
65
64
|
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
66
65
|
const untrustedSigner = accounts.at(2)!;
|
|
67
66
|
|
|
68
|
-
const claimDataPayload = await
|
|
67
|
+
const claimDataPayload = await validator.encodeClaimData({
|
|
69
68
|
signer: trustedSigner,
|
|
70
69
|
incentiveData,
|
|
71
70
|
chainId: defaultOptions.config.chains[0].id,
|
|
72
|
-
validator: validator.assertValidAddress(),
|
|
73
71
|
incentiveQuantity,
|
|
74
72
|
claimant,
|
|
75
73
|
boostId: boostId,
|
|
76
74
|
});
|
|
77
75
|
|
|
78
|
-
const badClaimDataPayload = await
|
|
76
|
+
const badClaimDataPayload = await validator.encodeClaimData({
|
|
79
77
|
signer: untrustedSigner,
|
|
80
78
|
incentiveData,
|
|
81
79
|
chainId: defaultOptions.config.chains[0].id,
|
|
82
|
-
validator: validator.assertValidAddress(),
|
|
83
80
|
incentiveQuantity,
|
|
84
81
|
claimant,
|
|
85
82
|
boostId: boostId,
|
|
@@ -120,11 +117,10 @@ describe('SignerValidator', () => {
|
|
|
120
117
|
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
121
118
|
const trustedSigner = accounts.at(0)!;
|
|
122
119
|
|
|
123
|
-
const claimDataPayload = await
|
|
120
|
+
const claimDataPayload = await validator.encodeClaimData({
|
|
124
121
|
signer: trustedSigner,
|
|
125
122
|
incentiveData,
|
|
126
123
|
chainId: defaultOptions.config.chains[0].id,
|
|
127
|
-
validator: validator.assertValidAddress(),
|
|
128
124
|
incentiveQuantity,
|
|
129
125
|
claimant,
|
|
130
126
|
boostId: boostId,
|