@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
|
@@ -16,7 +16,13 @@ import {
|
|
|
16
16
|
writeErc1155IncentiveClawback,
|
|
17
17
|
} from '@boostxyz/evm';
|
|
18
18
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC1155Incentive.sol/ERC1155Incentive.json';
|
|
19
|
-
import
|
|
19
|
+
import {
|
|
20
|
+
type Address,
|
|
21
|
+
type ContractEventName,
|
|
22
|
+
type Hex,
|
|
23
|
+
encodeAbiParameters,
|
|
24
|
+
parseAbiParameters,
|
|
25
|
+
} from 'viem';
|
|
20
26
|
import type {
|
|
21
27
|
DeployableOptions,
|
|
22
28
|
GenericDeployableParams,
|
|
@@ -24,19 +30,68 @@ import type {
|
|
|
24
30
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
25
31
|
import {
|
|
26
32
|
type ClaimPayload,
|
|
27
|
-
type
|
|
28
|
-
|
|
33
|
+
type StrategyType,
|
|
34
|
+
prepareClaimPayload,
|
|
35
|
+
} from '../claiming';
|
|
36
|
+
import {
|
|
29
37
|
type GenericLog,
|
|
30
38
|
type ReadParams,
|
|
31
39
|
RegistryType,
|
|
32
|
-
type StrategyType,
|
|
33
40
|
type WriteParams,
|
|
34
|
-
prepareClaimPayload,
|
|
35
|
-
prepareERC1155IncentivePayload,
|
|
36
41
|
} from '../utils';
|
|
37
42
|
|
|
38
|
-
export {
|
|
39
|
-
|
|
43
|
+
export { erc1155IncentiveAbi };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Enum representing inventive disbursement strategies for {@link ERC1155Incentive}
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
* @enum {number}
|
|
50
|
+
*/
|
|
51
|
+
export enum ERC1155StrategyType {
|
|
52
|
+
POOL = 0,
|
|
53
|
+
MINT = 1,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The object representation of a `ERC1155Incentive.InitPayload`
|
|
58
|
+
*
|
|
59
|
+
* @export
|
|
60
|
+
* @interface ERC1155IncentivePayload
|
|
61
|
+
* @typedef {ERC1155IncentivePayload}
|
|
62
|
+
*/
|
|
63
|
+
export interface ERC1155IncentivePayload {
|
|
64
|
+
/**
|
|
65
|
+
* The address of the `ERC1155` asset
|
|
66
|
+
*
|
|
67
|
+
* @type {Address}
|
|
68
|
+
*/
|
|
69
|
+
asset: Address;
|
|
70
|
+
/**
|
|
71
|
+
* Should be `Strategy.POOL`
|
|
72
|
+
*
|
|
73
|
+
* @type {ERC1155StrategyType}
|
|
74
|
+
*/
|
|
75
|
+
strategy: ERC1155StrategyType;
|
|
76
|
+
/**
|
|
77
|
+
* The token ID to target
|
|
78
|
+
*
|
|
79
|
+
* @type {bigint}
|
|
80
|
+
*/
|
|
81
|
+
tokenId: bigint;
|
|
82
|
+
/**
|
|
83
|
+
* The maximum number of claims that can be made (one per address)
|
|
84
|
+
*
|
|
85
|
+
* @type {bigint}
|
|
86
|
+
*/
|
|
87
|
+
limit: bigint;
|
|
88
|
+
/**
|
|
89
|
+
* Any extra data to accompany the claim, if applicable.
|
|
90
|
+
*
|
|
91
|
+
* @type {Hex}
|
|
92
|
+
*/
|
|
93
|
+
extraData: Hex;
|
|
94
|
+
}
|
|
40
95
|
|
|
41
96
|
/**
|
|
42
97
|
* A generic `viem.Log` event with support for `ERC1155Incentive` event types.
|
|
@@ -96,7 +151,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
96
151
|
public async claims(
|
|
97
152
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'claims'>,
|
|
98
153
|
) {
|
|
99
|
-
return readErc1155IncentiveClaims(this._config, {
|
|
154
|
+
return await readErc1155IncentiveClaims(this._config, {
|
|
100
155
|
address: this.assertValidAddress(),
|
|
101
156
|
args: [],
|
|
102
157
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -115,7 +170,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
115
170
|
public async reward(
|
|
116
171
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'reward'>,
|
|
117
172
|
) {
|
|
118
|
-
return readErc1155IncentiveReward(this._config, {
|
|
173
|
+
return await readErc1155IncentiveReward(this._config, {
|
|
119
174
|
address: this.assertValidAddress(),
|
|
120
175
|
args: [],
|
|
121
176
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -136,7 +191,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
136
191
|
address: Address,
|
|
137
192
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'claimed'>,
|
|
138
193
|
) {
|
|
139
|
-
return readErc1155IncentiveClaimed(this._config, {
|
|
194
|
+
return await readErc1155IncentiveClaimed(this._config, {
|
|
140
195
|
address: this.assertValidAddress(),
|
|
141
196
|
args: [address],
|
|
142
197
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -153,7 +208,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
153
208
|
* @returns {unknown}
|
|
154
209
|
*/
|
|
155
210
|
public async asset(params?: ReadParams<typeof erc1155IncentiveAbi, 'asset'>) {
|
|
156
|
-
return readErc1155IncentiveAsset(this._config, {
|
|
211
|
+
return await readErc1155IncentiveAsset(this._config, {
|
|
157
212
|
address: this.assertValidAddress(),
|
|
158
213
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
159
214
|
...(params as any),
|
|
@@ -168,7 +223,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
168
223
|
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'strategy'>} [params]
|
|
169
224
|
* @returns {Promise<StrategyType>}
|
|
170
225
|
*/
|
|
171
|
-
public
|
|
226
|
+
public strategy(
|
|
172
227
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'strategy'>,
|
|
173
228
|
): Promise<StrategyType> {
|
|
174
229
|
return readErc1155IncentiveStrategy(this._config, {
|
|
@@ -187,7 +242,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
187
242
|
* @returns {unknown}
|
|
188
243
|
*/
|
|
189
244
|
public async limit(params?: ReadParams<typeof erc1155IncentiveAbi, 'limit'>) {
|
|
190
|
-
return readErc1155IncentiveLimit(this._config, {
|
|
245
|
+
return await readErc1155IncentiveLimit(this._config, {
|
|
191
246
|
address: this.assertValidAddress(),
|
|
192
247
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
193
248
|
...(params as any),
|
|
@@ -205,7 +260,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
205
260
|
public async tokenId(
|
|
206
261
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'tokenId'>,
|
|
207
262
|
) {
|
|
208
|
-
return readErc1155IncentiveTokenId(this._config, {
|
|
263
|
+
return await readErc1155IncentiveTokenId(this._config, {
|
|
209
264
|
address: this.assertValidAddress(),
|
|
210
265
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
211
266
|
...(params as any),
|
|
@@ -223,7 +278,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
223
278
|
public async extraData(
|
|
224
279
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'extraData'>,
|
|
225
280
|
) {
|
|
226
|
-
return readErc1155IncentiveExtraData(this._config, {
|
|
281
|
+
return await readErc1155IncentiveExtraData(this._config, {
|
|
227
282
|
address: this.assertValidAddress(),
|
|
228
283
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
229
284
|
...(params as any),
|
|
@@ -239,11 +294,11 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
239
294
|
* @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
|
|
240
295
|
* @returns {unknown}
|
|
241
296
|
*/
|
|
242
|
-
|
|
297
|
+
protected async claim(
|
|
243
298
|
payload: ClaimPayload,
|
|
244
299
|
params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
|
|
245
300
|
) {
|
|
246
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
301
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
247
302
|
}
|
|
248
303
|
|
|
249
304
|
/**
|
|
@@ -255,7 +310,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
255
310
|
* @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
|
|
256
311
|
* @returns {unknown}
|
|
257
312
|
*/
|
|
258
|
-
|
|
313
|
+
protected async claimRaw(
|
|
259
314
|
payload: ClaimPayload,
|
|
260
315
|
params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
|
|
261
316
|
) {
|
|
@@ -286,7 +341,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
286
341
|
payload: ClaimPayload,
|
|
287
342
|
params?: WriteParams<typeof erc1155IncentiveAbi, 'clawback'>,
|
|
288
343
|
) {
|
|
289
|
-
return this.awaitResult(this.clawbackRaw(payload, params));
|
|
344
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
290
345
|
}
|
|
291
346
|
|
|
292
347
|
/**
|
|
@@ -329,7 +384,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
329
384
|
payload: ClaimPayload,
|
|
330
385
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'isClaimable'>,
|
|
331
386
|
) {
|
|
332
|
-
return readErc1155IncentiveIsClaimable(this._config, {
|
|
387
|
+
return await readErc1155IncentiveIsClaimable(this._config, {
|
|
333
388
|
address: this.assertValidAddress(),
|
|
334
389
|
args: [prepareClaimPayload(payload)],
|
|
335
390
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -350,7 +405,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
350
405
|
data: ERC1155IncentivePayload,
|
|
351
406
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'preflight'>,
|
|
352
407
|
) {
|
|
353
|
-
return readErc1155IncentivePreflight(this._config, {
|
|
408
|
+
return await readErc1155IncentivePreflight(this._config, {
|
|
354
409
|
address: this.assertValidAddress(),
|
|
355
410
|
args: [prepareERC1155IncentivePayload(data)],
|
|
356
411
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -382,3 +437,30 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
382
437
|
};
|
|
383
438
|
}
|
|
384
439
|
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Given a {@link ERC1155IncentivePayload}, properly encode a `ERC1155Incentive.InitPayload` for use with {@link ERC1155Incentive} initialization.
|
|
443
|
+
*
|
|
444
|
+
* @param {ERC1155IncentivePayload} param0
|
|
445
|
+
* @param {Address} param0.asset - The address of the `ERC1155` asset
|
|
446
|
+
* @param {ERC1155StrategyType} param0.strategy - Should be `Strategy.POOL`
|
|
447
|
+
* @param {bigint} param0.tokenId - The token ID to target
|
|
448
|
+
* @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
|
|
449
|
+
* @param {Hex} param0.extraData - Any extra data to accompany the claim, if applicable.
|
|
450
|
+
* @returns {Hex}
|
|
451
|
+
*/
|
|
452
|
+
export const prepareERC1155IncentivePayload = ({
|
|
453
|
+
asset,
|
|
454
|
+
strategy,
|
|
455
|
+
tokenId,
|
|
456
|
+
limit,
|
|
457
|
+
extraData,
|
|
458
|
+
}: ERC1155IncentivePayload) => {
|
|
459
|
+
return encodeAbiParameters(
|
|
460
|
+
parseAbiParameters([
|
|
461
|
+
'InitPayload payload',
|
|
462
|
+
'struct InitPayload { address asset; uint8 strategy; uint256 tokenId; uint256 limit; bytes extraData; }',
|
|
463
|
+
]),
|
|
464
|
+
[{ asset, strategy, tokenId, limit, extraData }],
|
|
465
|
+
);
|
|
466
|
+
};
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { readMockErc20BalanceOf } from '@boostxyz/evm';
|
|
2
2
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
encodePacked,
|
|
6
|
-
isAddress,
|
|
7
|
-
keccak256,
|
|
8
|
-
pad,
|
|
9
|
-
parseEther,
|
|
10
|
-
zeroAddress,
|
|
11
|
-
} from 'viem';
|
|
3
|
+
import { isAddress, pad, parseEther, zeroAddress } from 'viem';
|
|
12
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
13
5
|
import { accounts } from '../../test/accounts';
|
|
14
6
|
import {
|
|
@@ -19,11 +11,10 @@ import {
|
|
|
19
11
|
freshBoost,
|
|
20
12
|
fundBudget,
|
|
21
13
|
} from '../../test/helpers';
|
|
22
|
-
import {
|
|
14
|
+
import { BOOST_CORE_CLAIM_FEE } from '../BoostCore';
|
|
15
|
+
import { StrategyType } from '../claiming';
|
|
23
16
|
import { ERC20Incentive } from './ERC20Incentive';
|
|
24
17
|
|
|
25
|
-
const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
|
|
26
|
-
|
|
27
18
|
let fixtures: Fixtures, budgets: BudgetFixtures;
|
|
28
19
|
|
|
29
20
|
describe('ERC20Incentive', () => {
|
|
@@ -65,11 +56,10 @@ describe('ERC20Incentive', () => {
|
|
|
65
56
|
const claimant = trustedSigner.account;
|
|
66
57
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
67
58
|
const incentiveQuantity = 1;
|
|
68
|
-
const claimDataPayload = await
|
|
59
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
69
60
|
signer: trustedSigner,
|
|
70
61
|
incentiveData,
|
|
71
62
|
chainId: defaultOptions.config.chains[0].id,
|
|
72
|
-
validator: boost.validator.assertValidAddress(),
|
|
73
63
|
incentiveQuantity,
|
|
74
64
|
claimant,
|
|
75
65
|
boostId: boost.id,
|
|
@@ -109,11 +99,10 @@ describe('ERC20Incentive', () => {
|
|
|
109
99
|
const claimant = trustedSigner.account;
|
|
110
100
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
111
101
|
const incentiveQuantity = 1;
|
|
112
|
-
const claimDataPayload = await
|
|
102
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
113
103
|
signer: trustedSigner,
|
|
114
104
|
incentiveData,
|
|
115
105
|
chainId: defaultOptions.config.chains[0].id,
|
|
116
|
-
validator: boost.validator.assertValidAddress(),
|
|
117
106
|
incentiveQuantity,
|
|
118
107
|
claimant,
|
|
119
108
|
boostId: boost.id,
|
|
@@ -124,7 +113,7 @@ describe('ERC20Incentive', () => {
|
|
|
124
113
|
0n,
|
|
125
114
|
referrer,
|
|
126
115
|
claimDataPayload,
|
|
127
|
-
{ value:
|
|
116
|
+
{ value: BOOST_CORE_CLAIM_FEE },
|
|
128
117
|
);
|
|
129
118
|
try {
|
|
130
119
|
await fixtures.core.claimIncentive(
|
|
@@ -18,7 +18,12 @@ 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
|
+
} from 'viem';
|
|
22
27
|
import type {
|
|
23
28
|
DeployableOptions,
|
|
24
29
|
GenericDeployableParams,
|
|
@@ -26,18 +31,51 @@ import type {
|
|
|
26
31
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
27
32
|
import {
|
|
28
33
|
type ClaimPayload,
|
|
29
|
-
type
|
|
34
|
+
type StrategyType,
|
|
35
|
+
prepareClaimPayload,
|
|
36
|
+
} from '../claiming';
|
|
37
|
+
import {
|
|
30
38
|
type GenericLog,
|
|
31
39
|
type ReadParams,
|
|
32
40
|
RegistryType,
|
|
33
|
-
type StrategyType,
|
|
34
41
|
type WriteParams,
|
|
35
|
-
prepareClaimPayload,
|
|
36
|
-
prepareERC20IncentivePayload,
|
|
37
42
|
} from '../utils';
|
|
38
43
|
|
|
39
44
|
export { erc20IncentiveAbi };
|
|
40
|
-
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The object representation of a `ERC20Incentive.InitPayload`
|
|
48
|
+
*
|
|
49
|
+
* @export
|
|
50
|
+
* @interface ERC20IncentivePayload
|
|
51
|
+
* @typedef {ERC20IncentivePayload}
|
|
52
|
+
*/
|
|
53
|
+
export interface ERC20IncentivePayload {
|
|
54
|
+
/**
|
|
55
|
+
* The address of the incentivized asset.
|
|
56
|
+
*
|
|
57
|
+
* @type {Address}
|
|
58
|
+
*/
|
|
59
|
+
asset: Address;
|
|
60
|
+
/**
|
|
61
|
+
* The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
62
|
+
*
|
|
63
|
+
* @type {StrategyType}
|
|
64
|
+
*/
|
|
65
|
+
strategy: StrategyType;
|
|
66
|
+
/**
|
|
67
|
+
* The amount of the asset to distribute.
|
|
68
|
+
*
|
|
69
|
+
* @type {bigint}
|
|
70
|
+
*/
|
|
71
|
+
reward: bigint;
|
|
72
|
+
/**
|
|
73
|
+
* How many times can this incentive be claimed.
|
|
74
|
+
*
|
|
75
|
+
* @type {bigint}
|
|
76
|
+
*/
|
|
77
|
+
limit: bigint;
|
|
78
|
+
}
|
|
41
79
|
|
|
42
80
|
/**
|
|
43
81
|
* A generic `viem.Log` event with support for `ERC20Incentive` event types.
|
|
@@ -94,7 +132,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
94
132
|
* @returns {unknown}
|
|
95
133
|
*/
|
|
96
134
|
public async owner(params?: ReadParams<typeof erc20IncentiveAbi, 'owner'>) {
|
|
97
|
-
return readErc20IncentiveOwner(this._config, {
|
|
135
|
+
return await readErc20IncentiveOwner(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
|
|
@@ -113,7 +151,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
113
151
|
public async currentReward(
|
|
114
152
|
params?: ReadParams<typeof erc20IncentiveAbi, 'currentReward'>,
|
|
115
153
|
) {
|
|
116
|
-
return readErc20IncentiveCurrentReward(this._config, {
|
|
154
|
+
return await readErc20IncentiveCurrentReward(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
|
|
@@ -130,7 +168,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
130
168
|
* @returns {Promise<bigint>}
|
|
131
169
|
*/
|
|
132
170
|
public async claims(params?: ReadParams<typeof erc20IncentiveAbi, 'claims'>) {
|
|
133
|
-
return readErc20IncentiveClaims(this._config, {
|
|
171
|
+
return await readErc20IncentiveClaims(this._config, {
|
|
134
172
|
address: this.assertValidAddress(),
|
|
135
173
|
args: [],
|
|
136
174
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -151,7 +189,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
151
189
|
address: Address,
|
|
152
190
|
params?: ReadParams<typeof erc20IncentiveAbi, 'claimed'>,
|
|
153
191
|
) {
|
|
154
|
-
return readErc20IncentiveClaimed(this._config, {
|
|
192
|
+
return await readErc20IncentiveClaimed(this._config, {
|
|
155
193
|
address: this.assertValidAddress(),
|
|
156
194
|
args: [address],
|
|
157
195
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -168,7 +206,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
168
206
|
* @returns {Promise<Address>}
|
|
169
207
|
*/
|
|
170
208
|
public async asset(params?: ReadParams<typeof erc20IncentiveAbi, 'asset'>) {
|
|
171
|
-
return readErc20IncentiveAsset(this._config, {
|
|
209
|
+
return await readErc20IncentiveAsset(this._config, {
|
|
172
210
|
address: this.assertValidAddress(),
|
|
173
211
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
174
212
|
...(params as any),
|
|
@@ -183,7 +221,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
183
221
|
* @param {?ReadParams<typeof erc20IncentiveAbi, 'strategy'>} [params]
|
|
184
222
|
* @returns {Promise<StrategyType>}
|
|
185
223
|
*/
|
|
186
|
-
public
|
|
224
|
+
public strategy(
|
|
187
225
|
params?: ReadParams<typeof erc20IncentiveAbi, 'strategy'>,
|
|
188
226
|
): Promise<StrategyType> {
|
|
189
227
|
return readErc20IncentiveStrategy(this._config, {
|
|
@@ -202,7 +240,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
202
240
|
* @returns {Promise<bigint>}
|
|
203
241
|
*/
|
|
204
242
|
public async reward(params?: ReadParams<typeof erc20IncentiveAbi, 'reward'>) {
|
|
205
|
-
return readErc20IncentiveReward(this._config, {
|
|
243
|
+
return await readErc20IncentiveReward(this._config, {
|
|
206
244
|
address: this.assertValidAddress(),
|
|
207
245
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
208
246
|
...(params as any),
|
|
@@ -218,7 +256,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
218
256
|
* @returns {unknown}
|
|
219
257
|
*/
|
|
220
258
|
public async limit(params?: ReadParams<typeof erc20IncentiveAbi, 'limit'>) {
|
|
221
|
-
return readErc20IncentiveLimit(this._config, {
|
|
259
|
+
return await readErc20IncentiveLimit(this._config, {
|
|
222
260
|
address: this.assertValidAddress(),
|
|
223
261
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
224
262
|
...(params as any),
|
|
@@ -238,7 +276,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
238
276
|
i: bigint,
|
|
239
277
|
params?: ReadParams<typeof erc20IncentiveAbi, 'entries'>,
|
|
240
278
|
) {
|
|
241
|
-
return readErc20IncentiveEntries(this._config, {
|
|
279
|
+
return await readErc20IncentiveEntries(this._config, {
|
|
242
280
|
address: this.assertValidAddress(),
|
|
243
281
|
args: [i],
|
|
244
282
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -255,11 +293,11 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
255
293
|
* @param {?WriteParams<typeof erc20IncentiveAbi, 'claim'>} [params]
|
|
256
294
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
257
295
|
*/
|
|
258
|
-
|
|
296
|
+
protected async claim(
|
|
259
297
|
payload: ClaimPayload,
|
|
260
298
|
params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
|
|
261
299
|
) {
|
|
262
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
300
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
263
301
|
}
|
|
264
302
|
|
|
265
303
|
/**
|
|
@@ -271,7 +309,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
271
309
|
* @param {?WriteParams<typeof erc20IncentiveAbi, 'claim'>} [params]
|
|
272
310
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
273
311
|
*/
|
|
274
|
-
|
|
312
|
+
protected async claimRaw(
|
|
275
313
|
payload: ClaimPayload,
|
|
276
314
|
params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
|
|
277
315
|
) {
|
|
@@ -302,7 +340,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
302
340
|
payload: ClaimPayload,
|
|
303
341
|
params?: WriteParams<typeof erc20IncentiveAbi, 'clawback'>,
|
|
304
342
|
) {
|
|
305
|
-
return this.awaitResult(this.clawbackRaw(payload, params));
|
|
343
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
306
344
|
}
|
|
307
345
|
|
|
308
346
|
/**
|
|
@@ -345,7 +383,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
345
383
|
payload: ClaimPayload,
|
|
346
384
|
params?: ReadParams<typeof erc20IncentiveAbi, 'isClaimable'>,
|
|
347
385
|
) {
|
|
348
|
-
return readErc20IncentiveIsClaimable(this._config, {
|
|
386
|
+
return await readErc20IncentiveIsClaimable(this._config, {
|
|
349
387
|
address: this.assertValidAddress(),
|
|
350
388
|
args: [prepareClaimPayload(payload)],
|
|
351
389
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -364,7 +402,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
364
402
|
public async drawRaffle(
|
|
365
403
|
params?: WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>,
|
|
366
404
|
) {
|
|
367
|
-
return this.awaitResult(this.drawRaffleRaw(params));
|
|
405
|
+
return await this.awaitResult(this.drawRaffleRaw(params));
|
|
368
406
|
}
|
|
369
407
|
|
|
370
408
|
/**
|
|
@@ -415,3 +453,30 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
415
453
|
};
|
|
416
454
|
}
|
|
417
455
|
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Given a {@link ERC20IncentivePayload}, properly encode a `ERC20Incentive.InitPayload` for use with {@link ERC20Incentive} initialization.
|
|
459
|
+
*
|
|
460
|
+
* @param {ERC20IncentivePayload} param0
|
|
461
|
+
* @param {Address} param0.asset - The address of the incentivized asset.
|
|
462
|
+
* @param {StrategyType} param0.strategy - The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
463
|
+
* @param {bigint} param0.reward - The amount of the asset to distribute.
|
|
464
|
+
* @param {bigint} param0.limit - How many times can this incentive be claimed.
|
|
465
|
+
* @returns {*}
|
|
466
|
+
*/
|
|
467
|
+
export function prepareERC20IncentivePayload({
|
|
468
|
+
asset,
|
|
469
|
+
strategy,
|
|
470
|
+
reward,
|
|
471
|
+
limit,
|
|
472
|
+
}: ERC20IncentivePayload) {
|
|
473
|
+
return encodeAbiParameters(
|
|
474
|
+
[
|
|
475
|
+
{ type: 'address', name: 'asset' },
|
|
476
|
+
{ type: 'uint8', name: 'strategy' },
|
|
477
|
+
{ type: 'uint256', name: 'reward' },
|
|
478
|
+
{ type: 'uint256', name: 'limit' },
|
|
479
|
+
],
|
|
480
|
+
[asset, strategy, reward, limit],
|
|
481
|
+
);
|
|
482
|
+
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
readMockErc20BalanceOf,
|
|
3
|
-
readMockErc20TotalSupply,
|
|
4
|
-
} from '@boostxyz/evm';
|
|
1
|
+
import { readMockErc20BalanceOf } from '@boostxyz/evm';
|
|
5
2
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
encodeAbiParameters,
|
|
9
|
-
encodePacked,
|
|
10
|
-
isAddress,
|
|
11
|
-
keccak256,
|
|
12
|
-
pad,
|
|
13
|
-
parseEther,
|
|
14
|
-
zeroAddress,
|
|
15
|
-
} from 'viem';
|
|
16
|
-
import { toHex } from 'viem';
|
|
3
|
+
import { encodeAbiParameters, isAddress, parseEther, zeroAddress } from 'viem';
|
|
17
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
18
5
|
import { accounts } from '../../test/accounts';
|
|
19
6
|
import {
|
|
@@ -24,11 +11,6 @@ import {
|
|
|
24
11
|
freshBoost,
|
|
25
12
|
fundBudget,
|
|
26
13
|
} from '../../test/helpers';
|
|
27
|
-
import {
|
|
28
|
-
StrategyType,
|
|
29
|
-
prepareClaimPayload,
|
|
30
|
-
prepareSignerValidatorClaimDataPayload,
|
|
31
|
-
} from '../utils';
|
|
32
14
|
import { ERC20VariableIncentive } from './ERC20VariableIncentive';
|
|
33
15
|
|
|
34
16
|
const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
|
|
@@ -74,14 +56,13 @@ describe('ERC20VariableIncentive', () => {
|
|
|
74
56
|
|
|
75
57
|
const claimant = trustedSigner.account;
|
|
76
58
|
const incentiveQuantity = 1;
|
|
77
|
-
const claimDataPayload = await
|
|
59
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
78
60
|
signer: trustedSigner,
|
|
79
61
|
incentiveData: encodeAbiParameters(
|
|
80
62
|
[{ name: '', type: 'uint256' }],
|
|
81
63
|
[parseEther('1')],
|
|
82
64
|
),
|
|
83
65
|
chainId: defaultOptions.config.chains[0].id,
|
|
84
|
-
validator: boost.validator.assertValidAddress(),
|
|
85
66
|
incentiveQuantity,
|
|
86
67
|
claimant,
|
|
87
68
|
boostId: boost.id,
|
|
@@ -121,14 +102,13 @@ describe('ERC20VariableIncentive', () => {
|
|
|
121
102
|
|
|
122
103
|
const claimant = trustedSigner.account;
|
|
123
104
|
const incentiveQuantity = 1;
|
|
124
|
-
const claimDataPayload = await
|
|
105
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
125
106
|
signer: trustedSigner,
|
|
126
107
|
incentiveData: encodeAbiParameters(
|
|
127
108
|
[{ name: '', type: 'uint256' }],
|
|
128
109
|
[parseEther('1')],
|
|
129
110
|
),
|
|
130
111
|
chainId: defaultOptions.config.chains[0].id,
|
|
131
|
-
validator: boost.validator.assertValidAddress(),
|
|
132
112
|
incentiveQuantity,
|
|
133
113
|
claimant,
|
|
134
114
|
boostId: boost.id,
|