@boostxyz/sdk 0.0.0-alpha.20 → 0.0.0-alpha.21
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 +3 -3
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +3 -3
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +3 -3
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.js +13 -13
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.js +3 -3
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/Boost.cjs +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +5 -24
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +42 -44
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore-DolmDuXW.cjs +3 -0
- package/dist/BoostCore-DolmDuXW.cjs.map +1 -0
- package/dist/BoostCore-Z97KVu4V.js +1448 -0
- package/dist/BoostCore-Z97KVu4V.js.map +1 -0
- package/dist/BoostCore.cjs +1 -1
- package/dist/BoostCore.d.ts +633 -47
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +6 -6
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.cjs.map +1 -1
- package/dist/BoostRegistry.d.ts +31 -3
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +68 -48
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +34 -4
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +45 -45
- package/dist/Budgets/VestingBudget.d.ts +34 -4
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.js +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.js +17 -17
- package/dist/EventAction-CBKzuNoN.cjs +2 -0
- package/dist/EventAction-CBKzuNoN.cjs.map +1 -0
- package/dist/{EventAction-CIPqmAoP.js → EventAction-DWuuc_Qy.js} +295 -217
- package/dist/EventAction-DWuuc_Qy.js.map +1 -0
- package/dist/Incentive-BxzEtN26.js +298 -0
- package/dist/Incentive-BxzEtN26.js.map +1 -0
- package/dist/Incentive-CrF3-ayL.cjs +2 -0
- package/dist/Incentive-CrF3-ayL.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +16 -2
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +13 -13
- 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 +197 -4
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +31 -31
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +192 -5
- 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 +197 -4
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +17 -17
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +189 -2
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.d.ts +197 -4
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.d.ts +1 -1
- package/dist/Incentives/Incentive.js +3 -3
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts +16 -2
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +8 -8
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/{SimpleDenyList-BwfNjRsg.cjs → SimpleDenyList-BUR17Tt1.cjs} +2 -2
- package/dist/{SimpleDenyList-BwfNjRsg.cjs.map → SimpleDenyList-BUR17Tt1.cjs.map} +1 -1
- package/dist/{SimpleDenyList-Cn5WpNn0.js → SimpleDenyList-CGaWjuld.js} +15 -15
- package/dist/{SimpleDenyList-Cn5WpNn0.js.map → SimpleDenyList-CGaWjuld.js.map} +1 -1
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.js +3 -3
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.js +6 -6
- 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 +16 -13
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +18 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +16 -4
- package/dist/errors.js.map +1 -1
- package/dist/{generated-B7VaSah4.js → generated-CKt2yCQd.js} +1071 -447
- 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.js +79 -78
- package/package.json +4 -4
- package/src/Actions/EventAction.ts +24 -20
- package/src/Boost.ts +5 -27
- package/src/BoostCore.test.ts +113 -46
- package/src/BoostCore.ts +162 -171
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +48 -3
- package/src/Budgets/ManagedBudget.test.ts +7 -7
- package/src/Incentives/CGDAIncentive.test.ts +4 -1
- package/src/Incentives/CGDAIncentive.ts +6 -0
- package/src/Incentives/ERC20Incentive.test.ts +3 -0
- package/src/Incentives/ERC20Incentive.ts +6 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +3 -0
- package/src/Incentives/ERC20VariableIncentive.ts +6 -0
- package/src/Incentives/Incentive.test.ts +3 -0
- package/src/Incentives/Incentive.ts +1 -1
- package/src/Incentives/PointsIncentive.test.ts +1 -2
- package/src/errors.ts +22 -0
- package/dist/BoostCore-3-U1xTQN.cjs +0 -3
- package/dist/BoostCore-3-U1xTQN.cjs.map +0 -1
- package/dist/BoostCore-DVGBUr2y.js +0 -1477
- package/dist/BoostCore-DVGBUr2y.js.map +0 -1
- package/dist/EventAction-CIPqmAoP.js.map +0 -1
- package/dist/EventAction-d-oeqZQs.cjs +0 -2
- package/dist/EventAction-d-oeqZQs.cjs.map +0 -1
- package/dist/Incentive-Bp8Sez7M.js +0 -298
- package/dist/Incentive-Bp8Sez7M.js.map +0 -1
- package/dist/Incentive-Djnzseoj.cjs +0 -2
- package/dist/Incentive-Djnzseoj.cjs.map +0 -1
- package/dist/componentInterfaces-D09mhzxO.cjs +0 -2
- package/dist/componentInterfaces-D09mhzxO.cjs.map +0 -1
- package/dist/componentInterfaces-RXBMI5yH.js +0 -14
- package/dist/componentInterfaces-RXBMI5yH.js.map +0 -1
- package/dist/deployments-BM42vImE.js +0 -43
- package/dist/deployments-BM42vImE.js.map +0 -1
- package/dist/deployments-CMdF5uEC.cjs +0 -2
- package/dist/deployments-CMdF5uEC.cjs.map +0 -1
- package/dist/generated-B0tk-c9b.cjs +0 -3
- package/dist/generated-B0tk-c9b.cjs.map +0 -1
- package/dist/generated-B7VaSah4.js.map +0 -1
package/src/BoostCore.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
boostCoreAbi,
|
|
3
3
|
type iAuthAbi,
|
|
4
|
-
readBoostCoreClaimFee,
|
|
5
4
|
readBoostCoreCreateBoostAuth,
|
|
6
5
|
readBoostCoreGetBoost,
|
|
7
6
|
readBoostCoreGetBoostCount,
|
|
@@ -10,12 +9,11 @@ import {
|
|
|
10
9
|
readIAuthIsAuthorized,
|
|
11
10
|
simulateBoostCoreClaimIncentive,
|
|
12
11
|
simulateBoostCoreClaimIncentiveFor,
|
|
13
|
-
|
|
12
|
+
simulateBoostCoreCreateBoost,
|
|
14
13
|
simulateBoostCoreSetCreateBoostAuth,
|
|
15
14
|
simulateBoostCoreSetProtocolFeeReceiver,
|
|
16
15
|
writeBoostCoreClaimIncentive,
|
|
17
16
|
writeBoostCoreClaimIncentiveFor,
|
|
18
|
-
writeBoostCoreSetClaimFee,
|
|
19
17
|
writeBoostCoreSetCreateBoostAuth,
|
|
20
18
|
writeBoostCoreSetProtocolFeeReceiver,
|
|
21
19
|
} from '@boostxyz/evm';
|
|
@@ -26,6 +24,7 @@ import {
|
|
|
26
24
|
getTransactionReceipt,
|
|
27
25
|
waitForTransactionReceipt,
|
|
28
26
|
} from '@wagmi/core';
|
|
27
|
+
import type { SimulateContractReturnType } from '@wagmi/core/actions';
|
|
29
28
|
import { createWriteContract } from '@wagmi/core/codegen';
|
|
30
29
|
import {
|
|
31
30
|
type Address,
|
|
@@ -53,6 +52,7 @@ import { type Auth, PassthroughAuth } from './Auth/Auth';
|
|
|
53
52
|
import {
|
|
54
53
|
Boost,
|
|
55
54
|
type BoostPayload,
|
|
55
|
+
type RawBoost,
|
|
56
56
|
type Target,
|
|
57
57
|
prepareBoostPayload,
|
|
58
58
|
} from './Boost';
|
|
@@ -100,6 +100,7 @@ import {
|
|
|
100
100
|
import { type Validator, validatorFromAddress } from './Validators/Validator';
|
|
101
101
|
import {
|
|
102
102
|
BoostCoreNoIdentifierEmitted,
|
|
103
|
+
BoostNotFoundError,
|
|
103
104
|
BudgetMustAuthorizeBoostCore,
|
|
104
105
|
DeployableUnknownOwnerProvidedError,
|
|
105
106
|
IncentiveNotCloneableError,
|
|
@@ -246,7 +247,6 @@ export type CreateBoostPayload = {
|
|
|
246
247
|
allowList: AllowList;
|
|
247
248
|
incentives: Array<Incentive>;
|
|
248
249
|
protocolFee?: bigint;
|
|
249
|
-
referralFee?: bigint;
|
|
250
250
|
maxParticipants?: bigint;
|
|
251
251
|
owner?: Address;
|
|
252
252
|
};
|
|
@@ -310,13 +310,14 @@ export class BoostCore extends Deployable<
|
|
|
310
310
|
//@ts-expect-error I can't set this property on the class because for some reason it takes super out of constructor scope?
|
|
311
311
|
this.abi = boostCoreAbi;
|
|
312
312
|
}
|
|
313
|
+
|
|
313
314
|
/**
|
|
314
315
|
* Create a new Boost.
|
|
315
316
|
*
|
|
316
317
|
* @public
|
|
317
318
|
* @async
|
|
318
319
|
* @param {CreateBoostPayload} _boostPayload
|
|
319
|
-
* @param {?DeployableOptions} [
|
|
320
|
+
* @param {?DeployableOptions} [_params]
|
|
320
321
|
* @returns {Promise<Boost>}
|
|
321
322
|
*/
|
|
322
323
|
public async createBoost(
|
|
@@ -333,45 +334,122 @@ export class BoostCore extends Deployable<
|
|
|
333
334
|
desiredChainId,
|
|
334
335
|
);
|
|
335
336
|
|
|
336
|
-
let {
|
|
337
|
-
budget,
|
|
338
|
-
action,
|
|
339
|
-
validator,
|
|
340
|
-
allowList,
|
|
341
|
-
incentives,
|
|
342
|
-
protocolFee = 0n,
|
|
343
|
-
referralFee = 0n,
|
|
344
|
-
maxParticipants = 0n,
|
|
345
|
-
owner,
|
|
346
|
-
} = payload;
|
|
347
|
-
|
|
348
337
|
const boostFactory = createWriteContract({
|
|
349
338
|
abi: boostCoreAbi,
|
|
350
339
|
functionName: 'createBoost',
|
|
351
340
|
address: coreAddress,
|
|
352
341
|
});
|
|
353
342
|
|
|
354
|
-
|
|
355
|
-
|
|
343
|
+
const onChainPayload = await this.prepareCreateBoostPayload(
|
|
344
|
+
coreAddress,
|
|
345
|
+
chainId,
|
|
346
|
+
payload,
|
|
347
|
+
options,
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
const boostHash = await boostFactory(options.config, {
|
|
351
|
+
...this.optionallyAttachAccount(options.account),
|
|
352
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
353
|
+
...(_params as any),
|
|
354
|
+
chainId,
|
|
355
|
+
args: [prepareBoostPayload(onChainPayload)],
|
|
356
|
+
});
|
|
357
|
+
const receipt = await waitForTransactionReceipt(options.config, {
|
|
358
|
+
hash: boostHash,
|
|
359
|
+
});
|
|
360
|
+
const boostCreatedLog = parseEventLogs({
|
|
361
|
+
abi: boostCoreAbi,
|
|
362
|
+
eventName: 'BoostCreated',
|
|
363
|
+
logs: receipt.logs,
|
|
364
|
+
}).at(0);
|
|
365
|
+
let boostId = 0n;
|
|
366
|
+
if (!boostCreatedLog) throw new BoostCoreNoIdentifierEmitted();
|
|
367
|
+
boostId = boostCreatedLog?.args.boostId;
|
|
368
|
+
const boost = await this.readBoost(boostId);
|
|
369
|
+
return new Boost({
|
|
370
|
+
id: boostId,
|
|
371
|
+
budget: payload.budget.at(boost.budget),
|
|
372
|
+
action: payload.action.at(boost.action),
|
|
373
|
+
validator: payload.validator!.at(boost.validator),
|
|
374
|
+
allowList: payload.allowList.at(boost.allowList),
|
|
375
|
+
incentives: payload.incentives.map((incentive, i) =>
|
|
376
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
377
|
+
incentive.at(boost.incentives.at(i)!),
|
|
378
|
+
),
|
|
379
|
+
protocolFee: boost.protocolFee,
|
|
380
|
+
maxParticipants: boost.maxParticipants,
|
|
381
|
+
owner: boost.owner,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Returns a simulated Boost creation.
|
|
387
|
+
*
|
|
388
|
+
* @public
|
|
389
|
+
* @async
|
|
390
|
+
* @param {CreateBoostPayload} _boostPayload
|
|
391
|
+
* @param {?DeployableOptions} [_params]
|
|
392
|
+
* @returns {Promise<SimulateContractReturnType>}
|
|
393
|
+
*/
|
|
394
|
+
public async simulateCreateBoost(
|
|
395
|
+
_boostPayload: CreateBoostPayload,
|
|
396
|
+
_params?: DeployableOptions &
|
|
397
|
+
WriteParams<typeof boostCoreAbi, 'createBoost'>,
|
|
398
|
+
) {
|
|
399
|
+
const [payload, options] =
|
|
400
|
+
this.validateDeploymentConfig<CreateBoostPayload>(_boostPayload, _params);
|
|
401
|
+
const desiredChainId = _params?.chain?.id || _params?.chainId;
|
|
402
|
+
const { chainId, address: coreAddress } = assertValidAddressByChainId(
|
|
403
|
+
options.config,
|
|
404
|
+
this.addresses,
|
|
405
|
+
desiredChainId,
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
const onChainPayload = await this.prepareCreateBoostPayload(
|
|
409
|
+
coreAddress,
|
|
410
|
+
chainId,
|
|
411
|
+
payload,
|
|
412
|
+
options,
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
return await simulateBoostCoreCreateBoost(this._config, {
|
|
416
|
+
...this.optionallyAttachAccount(),
|
|
417
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
418
|
+
...(_params as any),
|
|
419
|
+
address: coreAddress,
|
|
420
|
+
chainId,
|
|
421
|
+
args: [prepareBoostPayload(onChainPayload)],
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// This function mutates payload, which isn't awesome but it's fine
|
|
426
|
+
private async prepareCreateBoostPayload(
|
|
427
|
+
coreAddress: Address,
|
|
428
|
+
chainId: number,
|
|
429
|
+
payload: CreateBoostPayload,
|
|
430
|
+
options: DeployableOptions,
|
|
431
|
+
): Promise<BoostPayload> {
|
|
432
|
+
if (!payload.owner) {
|
|
433
|
+
payload.owner =
|
|
356
434
|
this._account?.address ||
|
|
357
435
|
getAccount(options.config).address ||
|
|
358
436
|
zeroAddress;
|
|
359
|
-
if (owner === zeroAddress) {
|
|
437
|
+
if (payload.owner === zeroAddress) {
|
|
360
438
|
throw new DeployableUnknownOwnerProvidedError();
|
|
361
439
|
}
|
|
362
440
|
}
|
|
363
441
|
|
|
364
|
-
if (!validator) {
|
|
365
|
-
validator = this.SignerValidator({
|
|
366
|
-
signers: [owner],
|
|
442
|
+
if (!payload.validator) {
|
|
443
|
+
payload.validator = this.SignerValidator({
|
|
444
|
+
signers: [payload.owner],
|
|
367
445
|
validatorCaller: coreAddress,
|
|
368
446
|
});
|
|
369
447
|
}
|
|
370
448
|
|
|
371
449
|
let budgetPayload: BoostPayload['budget'] = zeroAddress;
|
|
372
|
-
if (budget.address) {
|
|
373
|
-
budgetPayload = budget.address;
|
|
374
|
-
if (!(await budget.isAuthorized(coreAddress))) {
|
|
450
|
+
if (payload.budget.address) {
|
|
451
|
+
budgetPayload = payload.budget.address;
|
|
452
|
+
if (!(await payload.budget.isAuthorized(coreAddress))) {
|
|
375
453
|
throw new BudgetMustAuthorizeBoostCore(coreAddress);
|
|
376
454
|
}
|
|
377
455
|
} else {
|
|
@@ -385,21 +463,23 @@ export class BoostCore extends Deployable<
|
|
|
385
463
|
isBase: true,
|
|
386
464
|
parameters: zeroHash,
|
|
387
465
|
};
|
|
388
|
-
if (action.address) {
|
|
389
|
-
const isBase = action.isBase;
|
|
466
|
+
if (payload.action.address) {
|
|
467
|
+
const isBase = payload.action.isBase;
|
|
390
468
|
actionPayload = {
|
|
391
469
|
isBase: isBase,
|
|
392
|
-
instance: action.address,
|
|
470
|
+
instance: payload.action.address,
|
|
393
471
|
parameters: isBase
|
|
394
|
-
? action.buildParameters(undefined, options).args.at(0) ||
|
|
472
|
+
? payload.action.buildParameters(undefined, options).args.at(0) ||
|
|
473
|
+
zeroHash
|
|
395
474
|
: zeroHash,
|
|
396
475
|
};
|
|
397
476
|
} else {
|
|
398
477
|
actionPayload.parameters =
|
|
399
|
-
action.buildParameters(undefined, options).args.at(0) ||
|
|
478
|
+
payload.action.buildParameters(undefined, options).args.at(0) ||
|
|
479
|
+
zeroHash;
|
|
400
480
|
actionPayload.instance = assertValidAddressByChainId(
|
|
401
481
|
options.config,
|
|
402
|
-
action.bases,
|
|
482
|
+
payload.action.bases,
|
|
403
483
|
chainId,
|
|
404
484
|
).address;
|
|
405
485
|
}
|
|
@@ -409,21 +489,23 @@ export class BoostCore extends Deployable<
|
|
|
409
489
|
isBase: true,
|
|
410
490
|
parameters: zeroHash,
|
|
411
491
|
};
|
|
412
|
-
if (validator.address) {
|
|
413
|
-
const isBase = validator.isBase;
|
|
492
|
+
if (payload.validator.address) {
|
|
493
|
+
const isBase = payload.validator.isBase;
|
|
414
494
|
validatorPayload = {
|
|
415
495
|
isBase: isBase,
|
|
416
|
-
instance: validator.address,
|
|
496
|
+
instance: payload.validator.address,
|
|
417
497
|
parameters: isBase
|
|
418
|
-
? validator.buildParameters(undefined, options).args.at(0) ||
|
|
498
|
+
? payload.validator.buildParameters(undefined, options).args.at(0) ||
|
|
499
|
+
zeroHash
|
|
419
500
|
: zeroHash,
|
|
420
501
|
};
|
|
421
502
|
} else {
|
|
422
503
|
validatorPayload.parameters =
|
|
423
|
-
validator.buildParameters(undefined, options).args.at(0) ||
|
|
504
|
+
payload.validator.buildParameters(undefined, options).args.at(0) ||
|
|
505
|
+
zeroHash;
|
|
424
506
|
validatorPayload.instance = assertValidAddressByChainId(
|
|
425
507
|
options.config,
|
|
426
|
-
validator.bases,
|
|
508
|
+
payload.validator.bases,
|
|
427
509
|
chainId,
|
|
428
510
|
).address;
|
|
429
511
|
}
|
|
@@ -433,33 +515,34 @@ export class BoostCore extends Deployable<
|
|
|
433
515
|
isBase: true,
|
|
434
516
|
parameters: zeroHash,
|
|
435
517
|
};
|
|
436
|
-
if (allowList.address) {
|
|
437
|
-
const isBase = allowList.isBase;
|
|
518
|
+
if (payload.allowList.address) {
|
|
519
|
+
const isBase = payload.allowList.isBase;
|
|
438
520
|
allowListPayload = {
|
|
439
521
|
isBase: isBase,
|
|
440
|
-
instance: allowList.address,
|
|
522
|
+
instance: payload.allowList.address,
|
|
441
523
|
parameters: isBase
|
|
442
524
|
? zeroHash // allowList.buildParameters(undefined, options).args.at(0) || zeroHash
|
|
443
525
|
: zeroHash,
|
|
444
526
|
};
|
|
445
527
|
} else {
|
|
446
528
|
allowListPayload.parameters =
|
|
447
|
-
allowList.buildParameters(undefined, options).args.at(0) ||
|
|
529
|
+
payload.allowList.buildParameters(undefined, options).args.at(0) ||
|
|
530
|
+
zeroHash;
|
|
448
531
|
allowListPayload.instance = assertValidAddressByChainId(
|
|
449
532
|
options.config,
|
|
450
|
-
allowList.bases,
|
|
533
|
+
payload.allowList.bases,
|
|
451
534
|
chainId,
|
|
452
535
|
).address;
|
|
453
536
|
}
|
|
454
537
|
|
|
455
|
-
const incentivesPayloads: Array<Target> = incentives.map(() => ({
|
|
538
|
+
const incentivesPayloads: Array<Target> = payload.incentives.map(() => ({
|
|
456
539
|
instance: zeroAddress,
|
|
457
540
|
isBase: true,
|
|
458
541
|
parameters: zeroHash,
|
|
459
542
|
}));
|
|
460
|
-
for (let i = 0; i < incentives.length; i++) {
|
|
543
|
+
for (let i = 0; i < payload.incentives.length; i++) {
|
|
461
544
|
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
462
|
-
const incentive = incentives.at(i)!;
|
|
545
|
+
const incentive = payload.incentives.at(i)!;
|
|
463
546
|
if (incentive.address) {
|
|
464
547
|
const isBase = incentive.isBase;
|
|
465
548
|
if (!isBase) throw new IncentiveNotCloneableError(incentive);
|
|
@@ -490,46 +573,12 @@ export class BoostCore extends Deployable<
|
|
|
490
573
|
validator: validatorPayload,
|
|
491
574
|
allowList: allowListPayload,
|
|
492
575
|
incentives: incentivesPayloads,
|
|
493
|
-
protocolFee,
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
owner,
|
|
576
|
+
protocolFee: payload.protocolFee || 0n,
|
|
577
|
+
maxParticipants: payload.maxParticipants || 0n,
|
|
578
|
+
owner: payload.owner,
|
|
497
579
|
};
|
|
498
580
|
|
|
499
|
-
|
|
500
|
-
...this.optionallyAttachAccount(options.account),
|
|
501
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
502
|
-
...(_params as any),
|
|
503
|
-
chainId,
|
|
504
|
-
args: [prepareBoostPayload(onChainPayload)],
|
|
505
|
-
});
|
|
506
|
-
const receipt = await waitForTransactionReceipt(options.config, {
|
|
507
|
-
hash: boostHash,
|
|
508
|
-
});
|
|
509
|
-
const boostCreatedLog = parseEventLogs({
|
|
510
|
-
abi: boostCoreAbi,
|
|
511
|
-
eventName: 'BoostCreated',
|
|
512
|
-
logs: receipt.logs,
|
|
513
|
-
}).at(0);
|
|
514
|
-
let boostId = 0n;
|
|
515
|
-
if (!boostCreatedLog) throw new BoostCoreNoIdentifierEmitted();
|
|
516
|
-
boostId = boostCreatedLog?.args.boostIndex;
|
|
517
|
-
const boost = await this.readBoost(boostId);
|
|
518
|
-
return new Boost({
|
|
519
|
-
id: boostId,
|
|
520
|
-
budget: budget.at(boost.budget),
|
|
521
|
-
action: action.at(boost.action),
|
|
522
|
-
validator: validator.at(boost.validator),
|
|
523
|
-
allowList: allowList.at(boost.allowList),
|
|
524
|
-
incentives: incentives.map((incentive, i) =>
|
|
525
|
-
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
526
|
-
incentive.at(boost.incentives.at(i)!),
|
|
527
|
-
),
|
|
528
|
-
protocolFee: boost.protocolFee,
|
|
529
|
-
referralFee: boost.referralFee,
|
|
530
|
-
maxParticipants: boost.maxParticipants,
|
|
531
|
-
owner: boost.owner,
|
|
532
|
-
});
|
|
581
|
+
return onChainPayload;
|
|
533
582
|
}
|
|
534
583
|
|
|
535
584
|
/**
|
|
@@ -670,21 +719,37 @@ export class BoostCore extends Deployable<
|
|
|
670
719
|
*
|
|
671
720
|
* @public
|
|
672
721
|
* @async
|
|
673
|
-
* @param {bigint} id
|
|
722
|
+
* @param {bigint | string} id
|
|
674
723
|
* @param {?ReadParams} [params]
|
|
675
724
|
* @returns {Promise<RawBoost>}
|
|
725
|
+
* @throws {@link BoostNotFoundError}
|
|
676
726
|
*/
|
|
677
727
|
public async readBoost(
|
|
678
|
-
|
|
728
|
+
_id: string | bigint,
|
|
679
729
|
params?: ReadParams<typeof boostCoreAbi, 'getBoost'>,
|
|
680
|
-
) {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
730
|
+
): Promise<RawBoost> {
|
|
731
|
+
try {
|
|
732
|
+
let id: bigint;
|
|
733
|
+
if (typeof _id === 'string') {
|
|
734
|
+
id = BigInt(_id);
|
|
735
|
+
} else id = _id;
|
|
736
|
+
return await readBoostCoreGetBoost(this._config, {
|
|
737
|
+
...assertValidAddressByChainId(
|
|
738
|
+
this._config,
|
|
739
|
+
this.addresses,
|
|
740
|
+
params?.chainId,
|
|
741
|
+
),
|
|
742
|
+
args: [id],
|
|
743
|
+
...this.optionallyAttachAccount(),
|
|
744
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
745
|
+
...(params as any),
|
|
746
|
+
});
|
|
747
|
+
// biome-ignore lint/suspicious/noExplicitAny: unknown error
|
|
748
|
+
} catch (e: any) {
|
|
749
|
+
if (e?.message?.includes('bounds'))
|
|
750
|
+
throw new BoostNotFoundError(String(_id));
|
|
751
|
+
throw e;
|
|
752
|
+
}
|
|
688
753
|
}
|
|
689
754
|
|
|
690
755
|
/**
|
|
@@ -695,6 +760,7 @@ export class BoostCore extends Deployable<
|
|
|
695
760
|
* @param {(string | bigint)} _id
|
|
696
761
|
* @param {?ReadParams} [params]
|
|
697
762
|
* @returns {Promise<Boost>}
|
|
763
|
+
* @throws {@link BoostNotFoundError}
|
|
698
764
|
*/
|
|
699
765
|
public async getBoost(
|
|
700
766
|
_id: string | bigint,
|
|
@@ -704,13 +770,8 @@ export class BoostCore extends Deployable<
|
|
|
704
770
|
if (typeof _id === 'string') {
|
|
705
771
|
id = BigInt(_id);
|
|
706
772
|
} else id = _id;
|
|
707
|
-
const {
|
|
708
|
-
|
|
709
|
-
referralFee,
|
|
710
|
-
maxParticipants,
|
|
711
|
-
owner,
|
|
712
|
-
...boostPayload
|
|
713
|
-
} = await this.readBoost(id, params);
|
|
773
|
+
const { protocolFee, maxParticipants, owner, ...boostPayload } =
|
|
774
|
+
await this.readBoost(id, params);
|
|
714
775
|
const options: DeployableOptions = {
|
|
715
776
|
config: this._config,
|
|
716
777
|
account: this._account,
|
|
@@ -735,7 +796,6 @@ export class BoostCore extends Deployable<
|
|
|
735
796
|
allowList,
|
|
736
797
|
incentives,
|
|
737
798
|
protocolFee,
|
|
738
|
-
referralFee,
|
|
739
799
|
maxParticipants,
|
|
740
800
|
owner,
|
|
741
801
|
});
|
|
@@ -967,75 +1027,6 @@ export class BoostCore extends Deployable<
|
|
|
967
1027
|
return { hash, result };
|
|
968
1028
|
}
|
|
969
1029
|
|
|
970
|
-
/**
|
|
971
|
-
* Get the claim fee.
|
|
972
|
-
*
|
|
973
|
-
* @public
|
|
974
|
-
* @async
|
|
975
|
-
* @param {?ReadParams} [params]
|
|
976
|
-
* @returns {Promise<bigint>}
|
|
977
|
-
*/
|
|
978
|
-
public async claimFee(params?: ReadParams<typeof boostCoreAbi, 'claimFee'>) {
|
|
979
|
-
return await readBoostCoreClaimFee(this._config, {
|
|
980
|
-
...assertValidAddressByChainId(
|
|
981
|
-
this._config,
|
|
982
|
-
this.addresses,
|
|
983
|
-
params?.chainId,
|
|
984
|
-
),
|
|
985
|
-
args: [],
|
|
986
|
-
...this.optionallyAttachAccount(),
|
|
987
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
988
|
-
...(params as any),
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
/**
|
|
993
|
-
* Sets the claim fee.
|
|
994
|
-
*
|
|
995
|
-
* @public
|
|
996
|
-
* @async
|
|
997
|
-
* @param {bigint} claimFee
|
|
998
|
-
* @param {?WriteParams} [params]
|
|
999
|
-
* @returns {Promise<void>}
|
|
1000
|
-
*/
|
|
1001
|
-
public async setClaimFee(
|
|
1002
|
-
claimFee: bigint,
|
|
1003
|
-
params?: WriteParams<typeof boostCoreAbi, 'setClaimFee'>,
|
|
1004
|
-
) {
|
|
1005
|
-
return await this.awaitResult(this.setClaimFeeRaw(claimFee, params));
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* Sets the claim fee.
|
|
1010
|
-
*
|
|
1011
|
-
* @public
|
|
1012
|
-
* @async
|
|
1013
|
-
* @param {bigint} claimFee
|
|
1014
|
-
* @param {?WriteParams} [params]
|
|
1015
|
-
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
1016
|
-
*/
|
|
1017
|
-
public async setClaimFeeRaw(
|
|
1018
|
-
claimFee: bigint,
|
|
1019
|
-
params?: WriteParams<typeof boostCoreAbi, 'setClaimFee'>,
|
|
1020
|
-
) {
|
|
1021
|
-
const { request, result } = await simulateBoostCoreSetClaimFee(
|
|
1022
|
-
this._config,
|
|
1023
|
-
{
|
|
1024
|
-
...assertValidAddressByChainId(
|
|
1025
|
-
this._config,
|
|
1026
|
-
this.addresses,
|
|
1027
|
-
params?.chainId,
|
|
1028
|
-
),
|
|
1029
|
-
args: [claimFee],
|
|
1030
|
-
...this.optionallyAttachAccount(),
|
|
1031
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
1032
|
-
...(params as any),
|
|
1033
|
-
},
|
|
1034
|
-
);
|
|
1035
|
-
const hash = await writeBoostCoreSetClaimFee(this._config, request);
|
|
1036
|
-
return { hash, result };
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
1030
|
/**
|
|
1040
1031
|
* Retrieves the claim information from a transaction receipt.
|
|
1041
1032
|
*
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { loadFixture } from '@nomicfoundation/hardhat-toolbox-viem/network-helpers';
|
|
2
|
+
import { pad, parseEther, zeroAddress, isAddress } from 'viem';
|
|
3
|
+
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
4
|
+
import {
|
|
5
|
+
type BudgetFixtures,
|
|
6
|
+
type Fixtures,
|
|
7
|
+
defaultOptions,
|
|
8
|
+
deployFixtures,
|
|
9
|
+
freshBoost,
|
|
10
|
+
fundBudget,
|
|
11
|
+
makeMockEventActionPayload,
|
|
12
|
+
} from '@boostxyz/test/helpers';
|
|
13
|
+
import { ContractAction } from './Actions/ContractAction';
|
|
14
|
+
import type { ERC20Incentive } from './Incentives/ERC20Incentive';
|
|
15
|
+
import { StrategyType } from './claiming';
|
|
16
|
+
import { BoostNotFoundError, IncentiveNotCloneableError } from './errors';
|
|
17
|
+
import { bytes4, RegistryType } from './utils';
|
|
18
|
+
import { BOOST_CORE_CLAIM_FEE } from './BoostCore';
|
|
19
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
20
|
+
import { SimpleAllowList } from './AllowLists/SimpleAllowList';
|
|
21
|
+
|
|
22
|
+
let fixtures: Fixtures, budgets: BudgetFixtures;
|
|
23
|
+
|
|
24
|
+
describe('BoostRegistry', () => {
|
|
25
|
+
beforeAll(async () => {
|
|
26
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('can initialize a new component', async () => {
|
|
30
|
+
const { registry, core } = fixtures;
|
|
31
|
+
const allowlist = await registry.initialize('NewAllowList', core.SimpleAllowList({
|
|
32
|
+
owner: zeroAddress,
|
|
33
|
+
allowed: []
|
|
34
|
+
}))
|
|
35
|
+
expect(isAddress(allowlist.assertValidAddress())).toBe(true)
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('can use a clones identifier to get the clone', async () => {
|
|
39
|
+
const { registry, bases } = fixtures;
|
|
40
|
+
const id = await registry.getCloneIdentifier(
|
|
41
|
+
RegistryType.ALLOW_LIST,
|
|
42
|
+
bases.SimpleAllowList.bases[31337]!,
|
|
43
|
+
defaultOptions.account.address,
|
|
44
|
+
'NewAllowList'
|
|
45
|
+
)
|
|
46
|
+
expect(await registry.getClone(id)).toMatchObject({
|
|
47
|
+
baseType: RegistryType.ALLOW_LIST,
|
|
48
|
+
instance: expect.any(String),
|
|
49
|
+
deployer: defaultOptions.account.address,
|
|
50
|
+
name: 'NewAllowList'
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
});
|
package/src/BoostRegistry.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
boostRegistryAbi,
|
|
3
3
|
readBoostRegistryGetBaseImplementation,
|
|
4
|
+
readBoostRegistryGetClone,
|
|
4
5
|
readBoostRegistryGetCloneIdentifier,
|
|
5
6
|
readBoostRegistryGetClones,
|
|
6
7
|
simulateBoostRegistryDeployClone,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
} from '@boostxyz/evm';
|
|
11
12
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/BoostRegistry.sol/BoostRegistry.json';
|
|
12
13
|
import {
|
|
14
|
+
type Abi,
|
|
13
15
|
type Address,
|
|
14
16
|
type ContractEventName,
|
|
15
17
|
type Hex,
|
|
@@ -74,6 +76,24 @@ export type BoostRegistryLog<
|
|
|
74
76
|
>,
|
|
75
77
|
> = GenericLog<typeof boostRegistryAbi, event>;
|
|
76
78
|
|
|
79
|
+
/**
|
|
80
|
+
* An interface representing an on-chain Clone
|
|
81
|
+
*
|
|
82
|
+
* @export
|
|
83
|
+
* @interface Clone
|
|
84
|
+
* @typedef {Clone}
|
|
85
|
+
*/
|
|
86
|
+
export interface Clone {
|
|
87
|
+
// The clone's component type'
|
|
88
|
+
baseType: RegistryType;
|
|
89
|
+
// The address of the initialized clone.
|
|
90
|
+
instance: Address;
|
|
91
|
+
// The deployer of the clone.
|
|
92
|
+
deployer: Address;
|
|
93
|
+
// The display name of the clone
|
|
94
|
+
name: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
77
97
|
/**
|
|
78
98
|
* Instantiation options for a previously deployed Boost Registry
|
|
79
99
|
*
|
|
@@ -295,6 +315,31 @@ export class BoostRegistry extends Deployable<
|
|
|
295
315
|
return this.clone(displayName, target, params);
|
|
296
316
|
}
|
|
297
317
|
|
|
318
|
+
/**
|
|
319
|
+
* Initialize a new instance of a registered base implementation, returning a transaction hash, resulting address from simulated transaction, and the given target bound to the resulting address.
|
|
320
|
+
* This method is the same as `deployCloneRaw`, but serves to make its function more obvious as to why you'd need to use it.
|
|
321
|
+
*
|
|
322
|
+
* @public
|
|
323
|
+
* @async
|
|
324
|
+
* @template {DeployableTarget} Target
|
|
325
|
+
* @param {string} displayName - The display name for the clone
|
|
326
|
+
* @param {Target} target - An instance of a target contract to clone and initialize
|
|
327
|
+
* @param {?WriteParams} [params]
|
|
328
|
+
* @returns {Promise<HashAndSimulatedResult<Address> & { target: Target } >} - The transaction hash, simulated return address, and given target bound to simulated return address
|
|
329
|
+
*/
|
|
330
|
+
public async initializeRaw<Target extends DeployableTarget<unknown, Abi>>(
|
|
331
|
+
displayName: string,
|
|
332
|
+
target: Target,
|
|
333
|
+
params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
|
|
334
|
+
): Promise<HashAndSimulatedResult<Address> & { target: Target }> {
|
|
335
|
+
const { hash, result } = await this.deployCloneRaw(
|
|
336
|
+
displayName,
|
|
337
|
+
target,
|
|
338
|
+
params,
|
|
339
|
+
);
|
|
340
|
+
return { hash, result, target: target.at(result) };
|
|
341
|
+
}
|
|
342
|
+
|
|
298
343
|
/**
|
|
299
344
|
* Deploy a new instance of a registered base implementation, returning the provided target with a new address set on it.
|
|
300
345
|
*
|
|
@@ -414,13 +459,13 @@ export class BoostRegistry extends Deployable<
|
|
|
414
459
|
* @async
|
|
415
460
|
* @param {Hex} identifier - The unique identifier for the deployed clone (see {getCloneIdentifier})
|
|
416
461
|
* @param {?ReadParams} [params]
|
|
417
|
-
* @returns {Promise<
|
|
462
|
+
* @returns {Promise<Clone>} - The on-chain representation of the clone
|
|
418
463
|
*/
|
|
419
464
|
public async getClone(
|
|
420
465
|
identifier: Hex,
|
|
421
466
|
params?: ReadParams<typeof boostRegistryAbi, 'getClone'>,
|
|
422
|
-
) {
|
|
423
|
-
return await
|
|
467
|
+
): Promise<Clone> {
|
|
468
|
+
return await readBoostRegistryGetClone(this._config, {
|
|
424
469
|
...assertValidAddressByChainId(
|
|
425
470
|
this._config,
|
|
426
471
|
this.addresses,
|