@boostxyz/sdk 0.0.0-alpha.8 → 0.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.js +1 -1
- package/dist/Actions/ContractAction.d.ts +46 -3
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +37 -10
- 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 +257 -12
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +249 -82
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +31 -2
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +52 -37
- 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 +31 -2
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +41 -129
- 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 +93 -1
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +151 -5
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +12 -6
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +168 -166
- 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 +4 -4
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +19 -24
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +40 -2
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +53 -36
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/SimpleBudget.d.ts +33 -2
- package/dist/Budgets/SimpleBudget.d.ts.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +54 -2
- 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.js +1 -1
- package/dist/Deployable/Contract.js.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -1
- package/dist/Deployable/DeployableTarget.js +3 -3
- package/dist/Deployable/DeployableTarget.js.map +1 -1
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +35 -5
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +33 -21
- 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 +89 -5
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +44 -23
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +67 -6
- 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 +49 -5
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +46 -27
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.d.ts +42 -5
- 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.js +48 -32
- 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 +49 -5
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +38 -21
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +298 -5
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +151 -26
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.js +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/errors.cjs.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/{generated-Cbv8zFkf.js → generated-57_Kffpz.js} +8 -5
- package/dist/generated-57_Kffpz.js.map +1 -0
- package/dist/{generated-BzszviNp.cjs → generated-wKBNvm48.cjs} +2 -2
- package/dist/generated-wKBNvm48.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -125
- 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 +2 -1371
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +26 -653
- package/dist/utils.js.map +1 -1
- package/package.json +17 -3
- package/src/Actions/Action.test.ts +5 -4
- package/src/Actions/ContractAction.test.ts +4 -6
- package/src/Actions/ContractAction.ts +73 -10
- package/src/Actions/ERC721MintAction.test.ts +2 -2
- package/src/Actions/ERC721MintAction.ts +70 -16
- package/src/Actions/EventAction.test.ts +43 -17
- package/src/Actions/EventAction.ts +452 -35
- package/src/AllowLists/SimpleAllowList.ts +48 -5
- package/src/AllowLists/SimpleDenyList.ts +47 -109
- package/src/Auth/PassthroughAuth.ts +1 -1
- package/src/Boost.ts +136 -1
- package/src/BoostCore.test.ts +4 -11
- package/src/BoostCore.ts +39 -33
- package/src/BoostRegistry.ts +19 -22
- package/src/Budgets/ManagedBudget.ts +69 -16
- package/src/Budgets/SimpleBudget.ts +57 -14
- package/src/Budgets/VestingBudget.ts +79 -9
- package/src/Deployable/Contract.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +2 -2
- package/src/Incentives/AllowListIncentive.test.ts +2 -5
- package/src/Incentives/AllowListIncentive.ts +59 -15
- package/src/Incentives/CGDAIncentive.test.ts +3 -7
- package/src/Incentives/CGDAIncentive.ts +123 -19
- package/src/Incentives/ERC1155Incentive.test.ts +2 -13
- package/src/Incentives/ERC1155Incentive.ts +104 -22
- package/src/Incentives/ERC20Incentive.test.ts +6 -17
- package/src/Incentives/ERC20Incentive.ts +86 -21
- package/src/Incentives/ERC20VariableIncentive.test.ts +4 -24
- package/src/Incentives/ERC20VariableIncentive.ts +71 -19
- package/src/Incentives/Incentive.test.ts +1 -1
- package/src/Incentives/PointsIncentive.test.ts +3 -6
- package/src/Incentives/PointsIncentive.ts +79 -17
- package/src/Validators/SignerValidator.test.ts +3 -7
- package/src/Validators/SignerValidator.ts +422 -13
- package/src/claiming.ts +56 -0
- package/src/errors.ts +1 -1
- package/src/index.ts +10 -7
- package/src/transfers.ts +284 -0
- package/src/utils.ts +3 -2052
- package/dist/generated-BzszviNp.cjs.map +0 -1
- package/dist/generated-Cbv8zFkf.js.map +0 -1
|
@@ -15,25 +15,53 @@ import {
|
|
|
15
15
|
writeErc20VariableIncentiveClawback,
|
|
16
16
|
} from '@boostxyz/evm';
|
|
17
17
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableIncentive.sol/ERC20VariableIncentive.json';
|
|
18
|
-
import
|
|
18
|
+
import {
|
|
19
|
+
type Address,
|
|
20
|
+
type ContractEventName,
|
|
21
|
+
type Hex,
|
|
22
|
+
encodeAbiParameters,
|
|
23
|
+
} from 'viem';
|
|
19
24
|
import type {
|
|
20
25
|
DeployableOptions,
|
|
21
26
|
GenericDeployableParams,
|
|
22
27
|
} from '../Deployable/Deployable';
|
|
23
28
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
29
|
+
import { type ClaimPayload, prepareClaimPayload } from '../claiming';
|
|
24
30
|
import {
|
|
25
|
-
type ClaimPayload,
|
|
26
|
-
type ERC20VariableIncentivePayload,
|
|
27
31
|
type GenericLog,
|
|
28
32
|
type ReadParams,
|
|
29
33
|
RegistryType,
|
|
30
34
|
type WriteParams,
|
|
31
|
-
prepareClaimPayload,
|
|
32
|
-
prepareERC20VariableIncentivePayload,
|
|
33
35
|
} from '../utils';
|
|
34
36
|
|
|
35
37
|
export { erc20VariableIncentiveAbi };
|
|
36
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The object representation of a `ERC20VariableIncentivePayload.InitPayload`
|
|
40
|
+
*
|
|
41
|
+
* @export
|
|
42
|
+
* @interface ERC20VariableIncentivePayload
|
|
43
|
+
* @typedef {ERC20VariableIncentivePayload}
|
|
44
|
+
*/
|
|
45
|
+
export interface ERC20VariableIncentivePayload {
|
|
46
|
+
/**
|
|
47
|
+
* The address of the incentivized asset.
|
|
48
|
+
*
|
|
49
|
+
* @type {Address}
|
|
50
|
+
*/
|
|
51
|
+
asset: Address;
|
|
52
|
+
/**
|
|
53
|
+
* The amount of the asset to distribute.
|
|
54
|
+
*
|
|
55
|
+
* @type {bigint}
|
|
56
|
+
*/
|
|
57
|
+
reward: bigint;
|
|
58
|
+
/**
|
|
59
|
+
* How many times can this incentive be claimed.
|
|
60
|
+
*
|
|
61
|
+
* @type {bigint}
|
|
62
|
+
*/
|
|
63
|
+
limit: bigint;
|
|
64
|
+
}
|
|
37
65
|
|
|
38
66
|
/**
|
|
39
67
|
* A generic `viem.Log` event with support for `ERC20VariableIncentive` event types.
|
|
@@ -92,7 +120,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
92
120
|
public async owner(
|
|
93
121
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'owner'>,
|
|
94
122
|
) {
|
|
95
|
-
return readErc20VariableIncentiveOwner(this._config, {
|
|
123
|
+
return await readErc20VariableIncentiveOwner(this._config, {
|
|
96
124
|
address: this.assertValidAddress(),
|
|
97
125
|
args: [],
|
|
98
126
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -111,7 +139,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
111
139
|
public async totalClaimed(
|
|
112
140
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'totalClaimed'>,
|
|
113
141
|
) {
|
|
114
|
-
return readErc20VariableIncentiveTotalClaimed(this._config, {
|
|
142
|
+
return await readErc20VariableIncentiveTotalClaimed(this._config, {
|
|
115
143
|
address: this.assertValidAddress(),
|
|
116
144
|
args: [],
|
|
117
145
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -130,7 +158,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
130
158
|
public async currentReward(
|
|
131
159
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'currentReward'>,
|
|
132
160
|
) {
|
|
133
|
-
return readErc20VariableIncentiveCurrentReward(this._config, {
|
|
161
|
+
return await readErc20VariableIncentiveCurrentReward(this._config, {
|
|
134
162
|
address: this.assertValidAddress(),
|
|
135
163
|
args: [],
|
|
136
164
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -149,7 +177,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
149
177
|
public async claims(
|
|
150
178
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claims'>,
|
|
151
179
|
) {
|
|
152
|
-
return readErc20VariableIncentiveClaims(this._config, {
|
|
180
|
+
return await readErc20VariableIncentiveClaims(this._config, {
|
|
153
181
|
address: this.assertValidAddress(),
|
|
154
182
|
args: [],
|
|
155
183
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -170,7 +198,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
170
198
|
address: Address,
|
|
171
199
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claimed'>,
|
|
172
200
|
) {
|
|
173
|
-
return readErc20VariableIncentiveClaimed(this._config, {
|
|
201
|
+
return await readErc20VariableIncentiveClaimed(this._config, {
|
|
174
202
|
address: this.assertValidAddress(),
|
|
175
203
|
args: [address],
|
|
176
204
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -189,7 +217,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
189
217
|
public async asset(
|
|
190
218
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'asset'>,
|
|
191
219
|
) {
|
|
192
|
-
return readErc20VariableIncentiveAsset(this._config, {
|
|
220
|
+
return await readErc20VariableIncentiveAsset(this._config, {
|
|
193
221
|
address: this.assertValidAddress(),
|
|
194
222
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
195
223
|
...(params as any),
|
|
@@ -207,7 +235,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
207
235
|
public async reward(
|
|
208
236
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'reward'>,
|
|
209
237
|
) {
|
|
210
|
-
return readErc20VariableIncentiveReward(this._config, {
|
|
238
|
+
return await readErc20VariableIncentiveReward(this._config, {
|
|
211
239
|
address: this.assertValidAddress(),
|
|
212
240
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
213
241
|
...(params as any),
|
|
@@ -225,7 +253,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
225
253
|
public async limit(
|
|
226
254
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'limit'>,
|
|
227
255
|
) {
|
|
228
|
-
return readErc20VariableIncentiveLimit(this._config, {
|
|
256
|
+
return await readErc20VariableIncentiveLimit(this._config, {
|
|
229
257
|
address: this.assertValidAddress(),
|
|
230
258
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
231
259
|
...(params as any),
|
|
@@ -241,11 +269,11 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
241
269
|
* @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
|
|
242
270
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
243
271
|
*/
|
|
244
|
-
|
|
272
|
+
protected async claim(
|
|
245
273
|
payload: ClaimPayload,
|
|
246
274
|
params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
|
|
247
275
|
) {
|
|
248
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
276
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
249
277
|
}
|
|
250
278
|
|
|
251
279
|
/**
|
|
@@ -257,7 +285,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
257
285
|
* @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
|
|
258
286
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
259
287
|
*/
|
|
260
|
-
|
|
288
|
+
protected async claimRaw(
|
|
261
289
|
payload: ClaimPayload,
|
|
262
290
|
params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
|
|
263
291
|
) {
|
|
@@ -288,7 +316,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
288
316
|
payload: ClaimPayload,
|
|
289
317
|
params?: WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>,
|
|
290
318
|
) {
|
|
291
|
-
return this.awaitResult(this.clawbackRaw(payload, params));
|
|
319
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
292
320
|
}
|
|
293
321
|
|
|
294
322
|
/**
|
|
@@ -334,7 +362,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
334
362
|
payload: ClaimPayload,
|
|
335
363
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'isClaimable'>,
|
|
336
364
|
) {
|
|
337
|
-
return readErc20VariableIncentiveIsClaimable(this._config, {
|
|
365
|
+
return await readErc20VariableIncentiveIsClaimable(this._config, {
|
|
338
366
|
address: this.assertValidAddress(),
|
|
339
367
|
args: [prepareClaimPayload(payload)],
|
|
340
368
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -366,3 +394,27 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
366
394
|
};
|
|
367
395
|
}
|
|
368
396
|
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Given a {@link ERC20VariableIncentivePayload}, properly encode a ` ERC20VariableIncentive.InitPayload` for use with {@link ERC20VariableIncentive} initialization.
|
|
400
|
+
*
|
|
401
|
+
* @param {ERC20VariableIncentivePayload} param0
|
|
402
|
+
* @param {Address} param0.asset - The address of the incentivized asset.
|
|
403
|
+
* @param {bigint} param0.reward - The amount of the asset to distribute.
|
|
404
|
+
* @param {bigint} param0.limit - How many times can this incentive be claimed.
|
|
405
|
+
* @returns {*}
|
|
406
|
+
*/
|
|
407
|
+
export function prepareERC20VariableIncentivePayload({
|
|
408
|
+
asset,
|
|
409
|
+
reward,
|
|
410
|
+
limit,
|
|
411
|
+
}: ERC20VariableIncentivePayload) {
|
|
412
|
+
return encodeAbiParameters(
|
|
413
|
+
[
|
|
414
|
+
{ type: 'address', name: 'asset' },
|
|
415
|
+
{ type: 'uint256', name: 'reward' },
|
|
416
|
+
{ type: 'uint256', name: 'limit' },
|
|
417
|
+
],
|
|
418
|
+
[asset, reward, limit],
|
|
419
|
+
);
|
|
420
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { zeroAddress } from 'viem';
|
|
2
2
|
import { describe, expect, test } from 'vitest';
|
|
3
3
|
import { defaultOptions } from '../../test/helpers';
|
|
4
|
-
import { StrategyType } from '../
|
|
4
|
+
import { StrategyType } from '../claiming';
|
|
5
5
|
import {
|
|
6
6
|
AllowListIncentive,
|
|
7
7
|
CGDAIncentive,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readPointsBalanceOf, writePointsGrantRoles } from '@boostxyz/evm';
|
|
2
2
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
3
|
-
import { signMessage } from '@wagmi/core';
|
|
4
3
|
import { isAddress, pad, parseEther, zeroAddress } from 'viem';
|
|
5
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
6
5
|
import type { MockPoints } from '../../test/MockPoints';
|
|
@@ -12,7 +11,7 @@ import {
|
|
|
12
11
|
freshBoost,
|
|
13
12
|
freshPoints,
|
|
14
13
|
} from '../../test/helpers';
|
|
15
|
-
import { bytes4
|
|
14
|
+
import { bytes4 } from '../utils';
|
|
16
15
|
import { PointsIncentive } from './PointsIncentive';
|
|
17
16
|
|
|
18
17
|
let fixtures: Fixtures, points: MockPoints;
|
|
@@ -55,11 +54,10 @@ describe('PointsIncentive', () => {
|
|
|
55
54
|
const claimant = trustedSigner.account;
|
|
56
55
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
57
56
|
const incentiveQuantity = 1;
|
|
58
|
-
const claimDataPayload = await
|
|
57
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
59
58
|
signer: trustedSigner,
|
|
60
59
|
incentiveData,
|
|
61
60
|
chainId: defaultOptions.config.chains[0].id,
|
|
62
|
-
validator: boost.validator.assertValidAddress(),
|
|
63
61
|
incentiveQuantity,
|
|
64
62
|
claimant,
|
|
65
63
|
boostId: boost.id,
|
|
@@ -105,11 +103,10 @@ describe('PointsIncentive', () => {
|
|
|
105
103
|
const claimant = trustedSigner.account;
|
|
106
104
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
107
105
|
const incentiveQuantity = 1;
|
|
108
|
-
const claimDataPayload = await
|
|
106
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
109
107
|
signer: trustedSigner,
|
|
110
108
|
incentiveData,
|
|
111
109
|
chainId: defaultOptions.config.chains[0].id,
|
|
112
|
-
validator: boost.validator.assertValidAddress(),
|
|
113
110
|
incentiveQuantity,
|
|
114
111
|
claimant,
|
|
115
112
|
boostId: boost.id,
|
|
@@ -12,25 +12,60 @@ 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
|
+
} from 'viem';
|
|
16
21
|
import type {
|
|
17
22
|
DeployableOptions,
|
|
18
23
|
GenericDeployableParams,
|
|
19
24
|
} from '../Deployable/Deployable';
|
|
20
25
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
26
|
+
import { type ClaimPayload, prepareClaimPayload } from '../claiming';
|
|
21
27
|
import {
|
|
22
|
-
type ClaimPayload,
|
|
23
28
|
type GenericLog,
|
|
24
|
-
type PointsIncentivePayload,
|
|
25
29
|
type ReadParams,
|
|
26
30
|
RegistryType,
|
|
27
31
|
type WriteParams,
|
|
28
|
-
prepareClaimPayload,
|
|
29
|
-
preparePointsIncentivePayload,
|
|
30
32
|
} from '../utils';
|
|
31
33
|
|
|
32
34
|
export { pointsIncentiveAbi };
|
|
33
|
-
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The object representation of a `PointsIncentive.InitPayload`
|
|
38
|
+
*
|
|
39
|
+
* @export
|
|
40
|
+
* @interface PointsIncentivePayload
|
|
41
|
+
* @typedef {PointsIncentivePayload}
|
|
42
|
+
*/
|
|
43
|
+
export interface PointsIncentivePayload {
|
|
44
|
+
/**
|
|
45
|
+
* The address of the points contract
|
|
46
|
+
*
|
|
47
|
+
* @type {Address}
|
|
48
|
+
*/
|
|
49
|
+
venue: Address;
|
|
50
|
+
/**
|
|
51
|
+
* The selector for the issuance function on the points contract
|
|
52
|
+
*
|
|
53
|
+
* @type {Hex}
|
|
54
|
+
*/
|
|
55
|
+
selector: Hex;
|
|
56
|
+
/**
|
|
57
|
+
* The reward amount issued for each claim
|
|
58
|
+
*
|
|
59
|
+
* @type {bigint}
|
|
60
|
+
*/
|
|
61
|
+
reward: bigint;
|
|
62
|
+
/**
|
|
63
|
+
* The maximum number of claims that can be made (one per address)
|
|
64
|
+
*
|
|
65
|
+
* @type {bigint}
|
|
66
|
+
*/
|
|
67
|
+
limit: bigint;
|
|
68
|
+
}
|
|
34
69
|
|
|
35
70
|
/**
|
|
36
71
|
* A generic `viem.Log` event with support for `PointsIncentive` event types.
|
|
@@ -94,7 +129,7 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
94
129
|
public async claims(
|
|
95
130
|
params?: ReadParams<typeof pointsIncentiveAbi, 'claims'>,
|
|
96
131
|
) {
|
|
97
|
-
return readPointsIncentiveClaims(this._config, {
|
|
132
|
+
return await readPointsIncentiveClaims(this._config, {
|
|
98
133
|
address: this.assertValidAddress(),
|
|
99
134
|
args: [],
|
|
100
135
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -113,7 +148,7 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
113
148
|
public async currentReward(
|
|
114
149
|
params?: ReadParams<typeof pointsIncentiveAbi, 'currentReward'>,
|
|
115
150
|
) {
|
|
116
|
-
return readPointsIncentiveCurrentReward(this._config, {
|
|
151
|
+
return await readPointsIncentiveCurrentReward(this._config, {
|
|
117
152
|
address: this.assertValidAddress(),
|
|
118
153
|
args: [],
|
|
119
154
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -132,7 +167,7 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
132
167
|
public async reward(
|
|
133
168
|
params?: ReadParams<typeof pointsIncentiveAbi, 'reward'>,
|
|
134
169
|
) {
|
|
135
|
-
return readPointsIncentiveReward(this._config, {
|
|
170
|
+
return await readPointsIncentiveReward(this._config, {
|
|
136
171
|
address: this.assertValidAddress(),
|
|
137
172
|
args: [],
|
|
138
173
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -153,7 +188,7 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
153
188
|
address: Address,
|
|
154
189
|
params?: ReadParams<typeof pointsIncentiveAbi, 'claimed'>,
|
|
155
190
|
) {
|
|
156
|
-
return readPointsIncentiveClaimed(this._config, {
|
|
191
|
+
return await readPointsIncentiveClaimed(this._config, {
|
|
157
192
|
address: this.assertValidAddress(),
|
|
158
193
|
args: [address],
|
|
159
194
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -170,7 +205,7 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
170
205
|
* @returns {unknown}
|
|
171
206
|
*/
|
|
172
207
|
public async venue(params?: ReadParams<typeof pointsIncentiveAbi, 'venue'>) {
|
|
173
|
-
return readPointsIncentiveVenue(this._config, {
|
|
208
|
+
return await readPointsIncentiveVenue(this._config, {
|
|
174
209
|
address: this.assertValidAddress(),
|
|
175
210
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
176
211
|
...(params as any),
|
|
@@ -186,7 +221,7 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
186
221
|
* @returns {Promise<bigint>}
|
|
187
222
|
*/
|
|
188
223
|
public async limit(params?: ReadParams<typeof pointsIncentiveAbi, 'limit'>) {
|
|
189
|
-
return readPointsIncentiveLimit(this._config, {
|
|
224
|
+
return await readPointsIncentiveLimit(this._config, {
|
|
190
225
|
address: this.assertValidAddress(),
|
|
191
226
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
192
227
|
...(params as any),
|
|
@@ -204,7 +239,7 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
204
239
|
public async selector(
|
|
205
240
|
params?: ReadParams<typeof pointsIncentiveAbi, 'selector'>,
|
|
206
241
|
) {
|
|
207
|
-
return readPointsIncentiveSelector(this._config, {
|
|
242
|
+
return await readPointsIncentiveSelector(this._config, {
|
|
208
243
|
address: this.assertValidAddress(),
|
|
209
244
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
210
245
|
...(params as any),
|
|
@@ -220,11 +255,11 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
220
255
|
* @param {?WriteParams<typeof pointsIncentiveAbi, 'claim'>} [params]
|
|
221
256
|
* @returns {Promise<boolean>} - True if the incentive was successfully claimed
|
|
222
257
|
*/
|
|
223
|
-
|
|
258
|
+
protected async claim(
|
|
224
259
|
payload: ClaimPayload,
|
|
225
260
|
params?: WriteParams<typeof pointsIncentiveAbi, 'claim'>,
|
|
226
261
|
) {
|
|
227
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
262
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
228
263
|
}
|
|
229
264
|
|
|
230
265
|
/**
|
|
@@ -236,7 +271,7 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
236
271
|
* @param {?WriteParams<typeof pointsIncentiveAbi, 'claim'>} [params]
|
|
237
272
|
* @returns {Promise<boolean>} - True if the incentive was successfully claimed
|
|
238
273
|
*/
|
|
239
|
-
|
|
274
|
+
protected async claimRaw(
|
|
240
275
|
payload: ClaimPayload,
|
|
241
276
|
params?: WriteParams<typeof pointsIncentiveAbi, 'claim'>,
|
|
242
277
|
) {
|
|
@@ -269,7 +304,7 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
269
304
|
payload: ClaimPayload,
|
|
270
305
|
params?: ReadParams<typeof pointsIncentiveAbi, 'isClaimable'>,
|
|
271
306
|
) {
|
|
272
|
-
return readPointsIncentiveIsClaimable(this._config, {
|
|
307
|
+
return await readPointsIncentiveIsClaimable(this._config, {
|
|
273
308
|
address: this.assertValidAddress(),
|
|
274
309
|
args: [prepareClaimPayload(payload)],
|
|
275
310
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -301,3 +336,30 @@ export class PointsIncentive extends DeployableTarget<
|
|
|
301
336
|
};
|
|
302
337
|
}
|
|
303
338
|
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Given a {@link PointsIncentivePayload}, properly encode a `PointsIncentive.InitPayload` for use with {@link PointsIncentive} initialization.
|
|
342
|
+
*
|
|
343
|
+
* @param {PointsIncentivePayload} param0
|
|
344
|
+
* @param {Address} param0.venue - The address of the points contract
|
|
345
|
+
* @param {Hex} param0.selector - The selector for the issuance function on the points contract
|
|
346
|
+
* @param {bigint} param0.reward - The reward amount issued for each claim
|
|
347
|
+
* @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
|
|
348
|
+
* @returns {*}
|
|
349
|
+
*/
|
|
350
|
+
export const preparePointsIncentivePayload = ({
|
|
351
|
+
venue,
|
|
352
|
+
selector,
|
|
353
|
+
reward,
|
|
354
|
+
limit,
|
|
355
|
+
}: PointsIncentivePayload) => {
|
|
356
|
+
return encodeAbiParameters(
|
|
357
|
+
[
|
|
358
|
+
{ type: 'address', name: 'venue' },
|
|
359
|
+
{ type: 'bytes4', name: 'selector' },
|
|
360
|
+
{ type: 'uint256', name: 'reward' },
|
|
361
|
+
{ type: 'uint256', name: 'limit' },
|
|
362
|
+
],
|
|
363
|
+
[venue, selector, reward, limit],
|
|
364
|
+
);
|
|
365
|
+
};
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
deployFixtures,
|
|
9
9
|
} from '../../test/helpers';
|
|
10
10
|
import { testAccount } from '../../test/viem';
|
|
11
|
-
import { prepareSignerValidatorClaimDataPayload } from '../utils';
|
|
12
11
|
import { SignerValidator } from './SignerValidator';
|
|
13
12
|
|
|
14
13
|
let fixtures: Fixtures;
|
|
@@ -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,
|