@boostxyz/sdk 0.0.0-alpha.9 → 1.1.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.cjs.map +1 -1
- package/dist/Actions/Action.js +7 -7
- package/dist/Actions/ContractAction.d.ts +11 -11
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +14 -14
- 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 +171 -41
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -392
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.cjs.map +1 -1
- package/dist/AllowLists/AllowList.d.ts +6 -4
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +45 -23
- package/dist/AllowLists/AllowList.js.map +1 -1
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +92 -37
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +55 -71
- 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 +203 -11
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +11 -112
- package/dist/AllowLists/SimpleDenyList.js.map +1 -1
- 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 +20 -21
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +43 -57
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore-BVZExPPu.js +1462 -0
- package/dist/BoostCore-BVZExPPu.js.map +1 -0
- package/dist/BoostCore-D-E-cnGI.cjs +3 -0
- package/dist/BoostCore-D-E-cnGI.cjs.map +1 -0
- package/dist/BoostCore.cjs +1 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +748 -77
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1150
- 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 +80 -25
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +165 -83
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.cjs.map +1 -1
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/Budget.js.map +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +75 -193
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +80 -298
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +223 -89
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +1 -1
- package/dist/Deployable/Contract.cjs.map +1 -1
- package/dist/Deployable/Contract.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +5 -7
- package/dist/Deployable/Contract.js.map +1 -1
- package/dist/Deployable/Deployable.cjs.map +1 -1
- package/dist/Deployable/Deployable.d.ts +1 -1
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +3 -5
- package/dist/Deployable/Deployable.js.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -1
- package/dist/Deployable/DeployableTarget.d.ts +13 -13
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +28 -25
- package/dist/Deployable/DeployableTarget.js.map +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
- package/dist/EventAction-BZt5cjbe.cjs +2 -0
- package/dist/EventAction-BZt5cjbe.cjs.map +1 -0
- package/dist/EventAction-C_-hJXWm.js +1541 -0
- package/dist/EventAction-C_-hJXWm.js.map +1 -0
- package/dist/Incentive-BhHaK3PZ.cjs +2 -0
- package/dist/Incentive-BhHaK3PZ.cjs.map +1 -0
- package/dist/Incentive-Cqg1w6wD.js +312 -0
- package/dist/Incentive-Cqg1w6wD.js.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +38 -16
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +42 -29
- 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 +234 -21
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +45 -32
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +224 -37
- 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 +230 -29
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +56 -43
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +335 -440
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +231 -29
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.cjs.map +1 -1
- package/dist/Incentives/Incentive.d.ts +4 -4
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +16 -296
- 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 +40 -18
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +37 -24
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
- package/dist/SimpleDenyList-CGaWjuld.js +132 -0
- package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +16 -16
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +30 -27
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.cjs.map +1 -1
- package/dist/Validators/Validator.d.ts +1 -1
- package/dist/Validators/Validator.js +2 -2
- package/dist/Validators/Validator.js.map +1 -1
- package/dist/claiming.cjs.map +1 -1
- package/dist/claiming.d.ts +1 -1
- package/dist/claiming.js.map +1 -1
- package/dist/componentInterfaces-BBCFkrZv.js +14 -0
- package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
- package/dist/deployments-DVXioW2i.cjs +2 -0
- package/dist/deployments-DVXioW2i.cjs.map +1 -0
- package/dist/deployments-oykLv3_Z.js +43 -0
- package/dist/deployments-oykLv3_Z.js.map +1 -0
- package/dist/deployments.json +44 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +256 -20
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +183 -26
- package/dist/errors.js.map +1 -1
- package/dist/{generated-57_Kffpz.js → generated-CKt2yCQd.js} +3613 -1869
- package/dist/generated-CKt2yCQd.js.map +1 -0
- package/dist/generated-CyTNlOwM.cjs +3 -0
- package/dist/generated-CyTNlOwM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +142 -108
- package/dist/index.js.map +1 -1
- package/dist/transfers.cjs.map +1 -1
- package/dist/transfers.d.ts +1 -1
- package/dist/transfers.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +26 -12
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +38 -23
- package/dist/utils.js.map +1 -1
- package/package.json +20 -10
- package/src/Actions/Action.test.ts +14 -13
- package/src/Actions/ContractAction.test.ts +10 -10
- package/src/Actions/ContractAction.ts +11 -12
- package/src/Actions/ERC721MintAction.test.ts +6 -6
- package/src/Actions/ERC721MintAction.ts +14 -15
- package/src/Actions/EventAction.test.ts +729 -109
- package/src/Actions/EventAction.ts +542 -84
- package/src/AllowLists/AllowList.test.ts +7 -7
- package/src/AllowLists/AllowList.ts +5 -3
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +4 -4
- package/src/AllowLists/SimpleAllowList.ts +39 -61
- package/src/AllowLists/SimpleDenyList.test.ts +4 -4
- package/src/AllowLists/SimpleDenyList.ts +40 -17
- package/src/Auth/PassthroughAuth.test.ts +1 -1
- package/src/Boost.ts +21 -24
- package/src/BoostCore.test.ts +323 -268
- package/src/BoostCore.ts +396 -219
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +161 -40
- package/src/Budgets/Budget.test.ts +2 -2
- package/src/Budgets/Budget.ts +1 -2
- package/src/Budgets/ManagedBudget.test.ts +82 -19
- package/src/Budgets/ManagedBudget.ts +48 -310
- package/src/Budgets/VestingBudget.test.ts +7 -7
- package/src/Budgets/VestingBudget.ts +34 -106
- package/src/Deployable/Contract.ts +4 -5
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +30 -19
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +5 -5
- package/src/Incentives/AllowListIncentive.ts +29 -15
- package/src/Incentives/CGDAIncentive.test.ts +9 -6
- package/src/Incentives/CGDAIncentive.ts +38 -18
- package/src/Incentives/ERC1155Incentive.test.ts +3 -3
- package/src/Incentives/ERC1155Incentive.ts +28 -29
- package/src/Incentives/ERC20Incentive.test.ts +9 -6
- package/src/Incentives/ERC20Incentive.ts +46 -26
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +8 -11
- package/src/Incentives/ERC20VariableIncentive.ts +49 -26
- package/src/Incentives/Incentive.test.ts +4 -1
- package/src/Incentives/Incentive.ts +7 -6
- package/src/Incentives/PointsIncentive.test.ts +24 -25
- package/src/Incentives/PointsIncentive.ts +31 -17
- package/src/Validators/SignerValidator.test.ts +6 -6
- package/src/Validators/SignerValidator.ts +19 -17
- package/src/Validators/Validator.test.ts +2 -2
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +1 -1
- package/src/errors.ts +345 -21
- package/src/index.test.ts +118 -36
- package/src/index.ts +5 -0
- package/src/transfers.ts +1 -1
- package/src/utils.test.ts +2 -2
- package/src/utils.ts +61 -12
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
- package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
- package/dist/componentInterfaces-DYkaxBda.js +0 -13
- package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
- package/dist/generated-57_Kffpz.js.map +0 -1
- package/dist/generated-wKBNvm48.cjs +0 -3
- package/dist/generated-wKBNvm48.cjs.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -564
package/src/BoostCore.test.ts
CHANGED
|
@@ -1,122 +1,113 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parseEther, zeroAddress } from 'viem';
|
|
3
|
-
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
1
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
4
2
|
import {
|
|
5
3
|
type BudgetFixtures,
|
|
6
4
|
type Fixtures,
|
|
7
5
|
defaultOptions,
|
|
8
6
|
deployFixtures,
|
|
7
|
+
freshBoost,
|
|
9
8
|
fundBudget,
|
|
10
9
|
makeMockEventActionPayload,
|
|
11
|
-
} from '
|
|
10
|
+
} from '@boostxyz/test/helpers';
|
|
11
|
+
import { loadFixture } from '@nomicfoundation/hardhat-toolbox-viem/network-helpers';
|
|
12
|
+
import { pad, parseEther, zeroAddress } from 'viem';
|
|
13
|
+
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
12
14
|
import { ContractAction } from './Actions/ContractAction';
|
|
13
|
-
import {
|
|
15
|
+
import { BOOST_CORE_CLAIM_FEE } from './BoostCore';
|
|
14
16
|
import type { ERC20Incentive } from './Incentives/ERC20Incentive';
|
|
15
|
-
import { ERC1155StrategyType } from './Incentives/ERC1155Incentive';
|
|
16
17
|
import { StrategyType } from './claiming';
|
|
17
|
-
import { IncentiveNotCloneableError } from './errors';
|
|
18
|
+
import { BoostNotFoundError, IncentiveNotCloneableError } from './errors';
|
|
18
19
|
import { bytes4 } from './utils';
|
|
19
20
|
|
|
20
21
|
let fixtures: Fixtures, budgets: BudgetFixtures;
|
|
21
22
|
|
|
22
23
|
describe('BoostCore', () => {
|
|
23
24
|
beforeAll(async () => {
|
|
24
|
-
fixtures = await loadFixture(deployFixtures);
|
|
25
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
25
26
|
});
|
|
26
27
|
beforeEach(async () => {
|
|
27
28
|
budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
test('can get the total number of boosts', async () => {
|
|
31
|
-
const { core
|
|
32
|
-
const client = new BoostCore({
|
|
33
|
-
...defaultOptions,
|
|
34
|
-
address: core.assertValidAddress(),
|
|
35
|
-
});
|
|
32
|
+
const { core } = fixtures;
|
|
36
33
|
|
|
37
|
-
// to whom it may concern, this syntax is only used because we need to use test classes
|
|
38
|
-
// that are preconfigured with the dynamic base addresses generated at test time.
|
|
39
|
-
// normally you would use the follow api for brevity
|
|
40
|
-
// budget: client.SimpleBudget({} | '0xaddress')
|
|
41
34
|
const { budget, erc20 } = budgets;
|
|
42
|
-
await
|
|
43
|
-
protocolFee:
|
|
44
|
-
referralFee: 2n,
|
|
35
|
+
await core.createBoost({
|
|
36
|
+
protocolFee: 0n,
|
|
45
37
|
maxParticipants: 100n,
|
|
46
38
|
budget: budget,
|
|
47
|
-
action:
|
|
48
|
-
defaultOptions,
|
|
39
|
+
action: core.EventAction(
|
|
49
40
|
makeMockEventActionPayload(
|
|
50
41
|
core.assertValidAddress(),
|
|
51
42
|
erc20.assertValidAddress(),
|
|
52
43
|
),
|
|
53
44
|
),
|
|
54
|
-
validator:
|
|
45
|
+
validator: core.SignerValidator({
|
|
55
46
|
signers: [defaultOptions.account.address],
|
|
56
47
|
validatorCaller: defaultOptions.account.address,
|
|
57
48
|
}),
|
|
58
|
-
allowList:
|
|
49
|
+
allowList: core.SimpleAllowList({
|
|
59
50
|
owner: defaultOptions.account.address,
|
|
60
51
|
allowed: [defaultOptions.account.address],
|
|
61
52
|
}),
|
|
62
53
|
incentives: [
|
|
63
|
-
|
|
54
|
+
core.ERC20Incentive({
|
|
64
55
|
asset: erc20.assertValidAddress(),
|
|
65
56
|
reward: parseEther('1'),
|
|
66
57
|
limit: 100n,
|
|
67
58
|
strategy: StrategyType.POOL,
|
|
59
|
+
manager: budget.assertValidAddress(),
|
|
68
60
|
}),
|
|
69
61
|
],
|
|
70
62
|
});
|
|
71
|
-
expect(await
|
|
63
|
+
expect(await core.getBoostCount()).toBe(1n);
|
|
72
64
|
});
|
|
73
65
|
|
|
74
|
-
test('
|
|
75
|
-
const { core
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
test('throws a typed error if no boost exists', async () => {
|
|
67
|
+
const { core } = fixtures;
|
|
68
|
+
try {
|
|
69
|
+
await core.getBoost(1000n)
|
|
70
|
+
} catch(e) {
|
|
71
|
+
expect(e instanceof BoostNotFoundError).toBe(true)
|
|
72
|
+
expect(e.id).toBe('1000')
|
|
73
|
+
}
|
|
74
|
+
})
|
|
80
75
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// normally you would use the follow api for brevity
|
|
84
|
-
// budget: client.SimpleBudget({} | '0xaddress')
|
|
76
|
+
test('can successfully create a boost using all base contract implementations', async () => {
|
|
77
|
+
const { core } = fixtures;
|
|
85
78
|
const { budget, erc20 } = budgets;
|
|
86
|
-
const boost = await
|
|
79
|
+
const boost = await core.createBoost({
|
|
87
80
|
protocolFee: 1n,
|
|
88
|
-
referralFee: 2n,
|
|
89
81
|
maxParticipants: 100n,
|
|
90
82
|
budget: budget,
|
|
91
|
-
action:
|
|
92
|
-
defaultOptions,
|
|
83
|
+
action: core.EventAction(
|
|
93
84
|
makeMockEventActionPayload(
|
|
94
85
|
core.assertValidAddress(),
|
|
95
86
|
erc20.assertValidAddress(),
|
|
96
87
|
),
|
|
97
88
|
),
|
|
98
|
-
validator:
|
|
89
|
+
validator: core.SignerValidator({
|
|
99
90
|
signers: [defaultOptions.account.address],
|
|
100
91
|
validatorCaller: defaultOptions.account.address,
|
|
101
92
|
}),
|
|
102
|
-
allowList:
|
|
93
|
+
allowList: core.SimpleAllowList({
|
|
103
94
|
owner: defaultOptions.account.address,
|
|
104
95
|
allowed: [defaultOptions.account.address],
|
|
105
96
|
}),
|
|
106
97
|
incentives: [
|
|
107
|
-
|
|
98
|
+
core.ERC20Incentive({
|
|
108
99
|
asset: erc20.assertValidAddress(),
|
|
109
100
|
reward: parseEther('1'),
|
|
110
101
|
limit: 100n,
|
|
111
102
|
strategy: StrategyType.POOL,
|
|
103
|
+
manager: budget.assertValidAddress(),
|
|
112
104
|
}),
|
|
113
105
|
],
|
|
114
106
|
});
|
|
115
|
-
const onChainBoost = await
|
|
107
|
+
const onChainBoost = await core.readBoost(boost.id);
|
|
116
108
|
|
|
117
109
|
expect(boost.owner).toBe(onChainBoost.owner);
|
|
118
110
|
expect(boost.protocolFee).toBe(onChainBoost.protocolFee);
|
|
119
|
-
expect(boost.referralFee).toBe(onChainBoost.referralFee);
|
|
120
111
|
expect(boost.maxParticipants).toBe(onChainBoost.maxParticipants);
|
|
121
112
|
|
|
122
113
|
expect(boost.action.address).toBe(onChainBoost.action);
|
|
@@ -165,49 +156,38 @@ describe('BoostCore', () => {
|
|
|
165
156
|
});
|
|
166
157
|
|
|
167
158
|
test('can read the raw on chain representation of a boost', async () => {
|
|
168
|
-
const { core
|
|
169
|
-
const client = new BoostCore({
|
|
170
|
-
...defaultOptions,
|
|
171
|
-
address: core.assertValidAddress(),
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// to whom it may concern, this syntax is only used because we need to use test classes
|
|
175
|
-
// that are preconfigured with the dynamic base addresses generated at test time.
|
|
176
|
-
// normally you would use the follow api for brevity
|
|
177
|
-
// budget: client.SimpleBudget({} | '0xaddress')
|
|
159
|
+
const { core } = fixtures;
|
|
178
160
|
const { budget, erc20 } = budgets;
|
|
179
|
-
const _boost = await
|
|
161
|
+
const _boost = await core.createBoost({
|
|
180
162
|
protocolFee: 1n,
|
|
181
|
-
referralFee: 2n,
|
|
182
163
|
maxParticipants: 100n,
|
|
183
164
|
budget: budget,
|
|
184
|
-
action:
|
|
185
|
-
defaultOptions,
|
|
165
|
+
action: core.EventAction(
|
|
186
166
|
makeMockEventActionPayload(
|
|
187
167
|
core.assertValidAddress(),
|
|
188
168
|
erc20.assertValidAddress(),
|
|
189
169
|
),
|
|
190
170
|
),
|
|
191
|
-
validator:
|
|
171
|
+
validator: core.SignerValidator({
|
|
192
172
|
signers: [defaultOptions.account.address],
|
|
193
173
|
validatorCaller: defaultOptions.account.address,
|
|
194
174
|
}),
|
|
195
|
-
allowList:
|
|
175
|
+
allowList: core.SimpleAllowList({
|
|
196
176
|
owner: defaultOptions.account.address,
|
|
197
177
|
allowed: [defaultOptions.account.address],
|
|
198
178
|
}),
|
|
199
179
|
incentives: [
|
|
200
|
-
|
|
180
|
+
core.ERC20Incentive({
|
|
201
181
|
asset: erc20.assertValidAddress(),
|
|
202
182
|
reward: parseEther('1'),
|
|
203
183
|
limit: 100n,
|
|
204
184
|
strategy: StrategyType.POOL,
|
|
185
|
+
manager: budget.assertValidAddress(),
|
|
205
186
|
}),
|
|
206
187
|
],
|
|
207
188
|
});
|
|
208
|
-
const boost = await
|
|
189
|
+
const boost = await core.readBoost(_boost.id);
|
|
209
190
|
expect(boost.protocolFee).toBe(1001n);
|
|
210
|
-
expect(boost.referralFee).toBe(1002n);
|
|
211
191
|
expect(boost.maxParticipants).toBe(100n);
|
|
212
192
|
expect(boost.budget).toBe(_boost.budget.assertValidAddress());
|
|
213
193
|
expect(boost.action).toBe(_boost.action.assertValidAddress());
|
|
@@ -218,302 +198,321 @@ describe('BoostCore', () => {
|
|
|
218
198
|
);
|
|
219
199
|
});
|
|
220
200
|
|
|
221
|
-
test('can
|
|
222
|
-
const { core
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
201
|
+
test('can optionally supply a validator', async () => {
|
|
202
|
+
const { core } = fixtures;
|
|
203
|
+
const { budget, erc20 } = budgets;
|
|
204
|
+
const _boost = await core.createBoost({
|
|
205
|
+
protocolFee: 1n,
|
|
206
|
+
maxParticipants: 100n,
|
|
207
|
+
budget: budget,
|
|
208
|
+
action: core.EventAction(
|
|
209
|
+
makeMockEventActionPayload(
|
|
210
|
+
core.assertValidAddress(),
|
|
211
|
+
erc20.assertValidAddress(),
|
|
212
|
+
),
|
|
213
|
+
),
|
|
214
|
+
allowList: core.SimpleAllowList({
|
|
215
|
+
owner: defaultOptions.account.address,
|
|
216
|
+
allowed: [defaultOptions.account.address],
|
|
217
|
+
}),
|
|
218
|
+
incentives: [
|
|
219
|
+
core.ERC20Incentive({
|
|
220
|
+
asset: erc20.assertValidAddress(),
|
|
221
|
+
reward: parseEther('1'),
|
|
222
|
+
limit: 100n,
|
|
223
|
+
strategy: StrategyType.POOL,
|
|
224
|
+
manager: budget.assertValidAddress(),
|
|
225
|
+
}),
|
|
226
|
+
],
|
|
226
227
|
});
|
|
228
|
+
const boost = await core.readBoost(_boost.id);
|
|
229
|
+
expect(boost.validator).toBe(_boost.validator.assertValidAddress());
|
|
230
|
+
});
|
|
227
231
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
+
test('can simulate a boost creation', async () => {
|
|
233
|
+
const { core } = fixtures;
|
|
234
|
+
const { budget, erc20 } = budgets;
|
|
235
|
+
const simulated = await core.simulateCreateBoost({
|
|
236
|
+
protocolFee: 1n,
|
|
237
|
+
maxParticipants: 100n,
|
|
238
|
+
budget: budget,
|
|
239
|
+
action: core.EventAction(
|
|
240
|
+
makeMockEventActionPayload(
|
|
241
|
+
core.assertValidAddress(),
|
|
242
|
+
erc20.assertValidAddress(),
|
|
243
|
+
),
|
|
244
|
+
),
|
|
245
|
+
allowList: core.SimpleAllowList({
|
|
246
|
+
owner: defaultOptions.account.address,
|
|
247
|
+
allowed: [defaultOptions.account.address],
|
|
248
|
+
}),
|
|
249
|
+
incentives: [
|
|
250
|
+
core.ERC20Incentive({
|
|
251
|
+
asset: erc20.assertValidAddress(),
|
|
252
|
+
reward: parseEther('1'),
|
|
253
|
+
limit: 100n,
|
|
254
|
+
strategy: StrategyType.POOL,
|
|
255
|
+
manager: budget.assertValidAddress(),
|
|
256
|
+
}),
|
|
257
|
+
],
|
|
258
|
+
});
|
|
259
|
+
expect(simulated.request.__mode).toBe('prepared')
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test('can reuse an existing action', async () => {
|
|
263
|
+
const { core } = fixtures;
|
|
232
264
|
const { budget, erc20 } = budgets;
|
|
233
265
|
|
|
234
266
|
// allocate more funds to the budget
|
|
235
|
-
await erc20.mint(defaultOptions.account.address, parseEther('
|
|
236
|
-
await erc20.approve(budget.assertValidAddress(), parseEther('
|
|
267
|
+
await erc20.mint(defaultOptions.account.address, parseEther('110'));
|
|
268
|
+
await erc20.approve(budget.assertValidAddress(), parseEther('110'));
|
|
237
269
|
await budget.allocate({
|
|
238
|
-
amount: parseEther('
|
|
270
|
+
amount: parseEther('110'),
|
|
239
271
|
asset: erc20.assertValidAddress(),
|
|
240
272
|
target: defaultOptions.account.address,
|
|
241
273
|
});
|
|
242
274
|
|
|
243
|
-
const _boost = await
|
|
275
|
+
const _boost = await core.createBoost({
|
|
244
276
|
budget: budget,
|
|
245
|
-
action:
|
|
246
|
-
defaultOptions,
|
|
277
|
+
action: core.EventAction(
|
|
247
278
|
makeMockEventActionPayload(
|
|
248
279
|
core.assertValidAddress(),
|
|
249
280
|
erc20.assertValidAddress(),
|
|
250
281
|
),
|
|
251
282
|
),
|
|
252
|
-
validator:
|
|
283
|
+
validator: core.SignerValidator({
|
|
253
284
|
signers: [defaultOptions.account.address],
|
|
254
285
|
validatorCaller: defaultOptions.account.address,
|
|
255
286
|
}),
|
|
256
|
-
allowList:
|
|
287
|
+
allowList: core.SimpleAllowList({
|
|
257
288
|
owner: defaultOptions.account.address,
|
|
258
289
|
allowed: [defaultOptions.account.address],
|
|
259
290
|
}),
|
|
260
291
|
incentives: [
|
|
261
|
-
|
|
292
|
+
core.ERC20Incentive({
|
|
262
293
|
asset: erc20.assertValidAddress(),
|
|
263
294
|
reward: parseEther('1'),
|
|
264
295
|
limit: 100n,
|
|
265
296
|
strategy: StrategyType.POOL,
|
|
297
|
+
manager: budget.assertValidAddress(),
|
|
266
298
|
}),
|
|
267
299
|
],
|
|
268
300
|
});
|
|
269
|
-
const boost = await
|
|
301
|
+
const boost = await core.createBoost({
|
|
270
302
|
budget: budget,
|
|
271
|
-
action:
|
|
272
|
-
|
|
273
|
-
_boost.action.assertValidAddress(),
|
|
274
|
-
false,
|
|
275
|
-
),
|
|
276
|
-
validator: new bases.SignerValidator(defaultOptions, {
|
|
303
|
+
action: core.EventAction(_boost.action.assertValidAddress(), false),
|
|
304
|
+
validator: core.SignerValidator({
|
|
277
305
|
signers: [defaultOptions.account.address],
|
|
278
306
|
validatorCaller: defaultOptions.account.address,
|
|
279
307
|
}),
|
|
280
|
-
allowList:
|
|
308
|
+
allowList: core.SimpleAllowList({
|
|
281
309
|
owner: defaultOptions.account.address,
|
|
282
310
|
allowed: [defaultOptions.account.address],
|
|
283
311
|
}),
|
|
284
312
|
incentives: [
|
|
285
|
-
|
|
313
|
+
core.ERC20Incentive({
|
|
286
314
|
asset: erc20.assertValidAddress(),
|
|
287
315
|
reward: parseEther('1'),
|
|
288
316
|
limit: 100n,
|
|
289
317
|
strategy: StrategyType.POOL,
|
|
318
|
+
manager: budget.assertValidAddress(),
|
|
290
319
|
}),
|
|
291
320
|
],
|
|
292
321
|
});
|
|
293
|
-
const onChainBoost = await
|
|
322
|
+
const onChainBoost = await core.readBoost(boost.id);
|
|
294
323
|
expect(onChainBoost.action).toBe(_boost.action.assertValidAddress());
|
|
295
324
|
});
|
|
296
325
|
|
|
297
326
|
test('can reuse an existing validator', async () => {
|
|
298
|
-
const { core
|
|
299
|
-
const client = new BoostCore({
|
|
300
|
-
...defaultOptions,
|
|
301
|
-
address: core.assertValidAddress(),
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
// to whom it may concern, this syntax is only used because we need to use test classes
|
|
305
|
-
// that are preconfigured with the dynamic base addresses generated at test time.
|
|
306
|
-
// normally you would use the follow api for brevity
|
|
307
|
-
// budget: client.SimpleBudget({} | '0xaddress')
|
|
327
|
+
const { core } = fixtures;
|
|
308
328
|
const { budget, erc20 } = budgets;
|
|
309
329
|
|
|
310
330
|
// allocate more erc20 funds to the budget from the owning accound
|
|
311
|
-
await erc20.mint(defaultOptions.account.address, parseEther('
|
|
312
|
-
await erc20.approve(budget.assertValidAddress(), parseEther('
|
|
331
|
+
await erc20.mint(defaultOptions.account.address, parseEther('110'));
|
|
332
|
+
await erc20.approve(budget.assertValidAddress(), parseEther('110'));
|
|
313
333
|
await budget.allocate({
|
|
314
|
-
amount: parseEther('
|
|
334
|
+
amount: parseEther('110'),
|
|
315
335
|
asset: erc20.assertValidAddress(),
|
|
316
336
|
target: defaultOptions.account.address,
|
|
317
337
|
});
|
|
318
338
|
|
|
319
|
-
const _boost = await
|
|
339
|
+
const _boost = await core.createBoost({
|
|
320
340
|
budget: budget,
|
|
321
|
-
action:
|
|
322
|
-
defaultOptions,
|
|
341
|
+
action: core.EventAction(
|
|
323
342
|
makeMockEventActionPayload(
|
|
324
343
|
core.assertValidAddress(),
|
|
325
344
|
erc20.assertValidAddress(),
|
|
326
345
|
),
|
|
327
346
|
),
|
|
328
|
-
validator:
|
|
347
|
+
validator: core.SignerValidator({
|
|
329
348
|
signers: [defaultOptions.account.address],
|
|
330
349
|
validatorCaller: defaultOptions.account.address,
|
|
331
350
|
}),
|
|
332
|
-
allowList:
|
|
351
|
+
allowList: core.SimpleAllowList({
|
|
333
352
|
owner: defaultOptions.account.address,
|
|
334
353
|
allowed: [defaultOptions.account.address],
|
|
335
354
|
}),
|
|
336
355
|
incentives: [
|
|
337
|
-
|
|
356
|
+
core.ERC20Incentive({
|
|
338
357
|
asset: erc20.assertValidAddress(),
|
|
339
358
|
reward: parseEther('1'),
|
|
340
359
|
limit: 100n,
|
|
341
360
|
strategy: StrategyType.POOL,
|
|
361
|
+
manager: budget.assertValidAddress(),
|
|
342
362
|
}),
|
|
343
363
|
],
|
|
344
364
|
});
|
|
345
|
-
const boost = await
|
|
365
|
+
const boost = await core.createBoost({
|
|
346
366
|
budget: budget,
|
|
347
|
-
action:
|
|
348
|
-
defaultOptions,
|
|
367
|
+
action: core.EventAction(
|
|
349
368
|
makeMockEventActionPayload(
|
|
350
369
|
core.assertValidAddress(),
|
|
351
370
|
erc20.assertValidAddress(),
|
|
352
371
|
),
|
|
353
372
|
),
|
|
354
|
-
validator:
|
|
355
|
-
defaultOptions,
|
|
373
|
+
validator: core.SignerValidator(
|
|
356
374
|
_boost.validator.assertValidAddress(),
|
|
357
375
|
false,
|
|
358
376
|
),
|
|
359
|
-
allowList:
|
|
377
|
+
allowList: core.SimpleAllowList({
|
|
360
378
|
owner: defaultOptions.account.address,
|
|
361
379
|
allowed: [defaultOptions.account.address],
|
|
362
380
|
}),
|
|
363
381
|
incentives: [
|
|
364
|
-
|
|
382
|
+
core.ERC20Incentive({
|
|
365
383
|
asset: erc20.assertValidAddress(),
|
|
366
384
|
reward: parseEther('1'),
|
|
367
385
|
limit: 100n,
|
|
368
386
|
strategy: StrategyType.POOL,
|
|
387
|
+
manager: budget.assertValidAddress(),
|
|
369
388
|
}),
|
|
370
389
|
],
|
|
371
390
|
});
|
|
372
|
-
const onChainBoost = await
|
|
391
|
+
const onChainBoost = await core.readBoost(boost.id);
|
|
373
392
|
expect(onChainBoost.validator).toBe(_boost.validator.assertValidAddress());
|
|
374
393
|
});
|
|
375
394
|
|
|
376
395
|
test('can reuse an existing allowlist', async () => {
|
|
377
|
-
const { core
|
|
378
|
-
const client = new BoostCore({
|
|
379
|
-
...defaultOptions,
|
|
380
|
-
address: core.assertValidAddress(),
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
// to whom it may concern, this syntax is only used because we need to use test classes
|
|
384
|
-
// that are preconfigured with the dynamic base addresses generated at test time.
|
|
385
|
-
// normally you would use the follow api for brevity
|
|
386
|
-
// budget: client.SimpleBudget({} | '0xaddress')
|
|
396
|
+
const { core } = fixtures;
|
|
387
397
|
const { budget, erc20 } = budgets;
|
|
388
398
|
|
|
389
399
|
// allocate more erc20 funds to the budget from the owning accound
|
|
390
|
-
await erc20.mint(defaultOptions.account.address, parseEther('
|
|
391
|
-
await erc20.approve(budget.assertValidAddress(), parseEther('
|
|
400
|
+
await erc20.mint(defaultOptions.account.address, parseEther('110'));
|
|
401
|
+
await erc20.approve(budget.assertValidAddress(), parseEther('110'));
|
|
392
402
|
await budget.allocate({
|
|
393
|
-
amount: parseEther('
|
|
403
|
+
amount: parseEther('110'),
|
|
394
404
|
asset: erc20.assertValidAddress(),
|
|
395
405
|
target: defaultOptions.account.address,
|
|
396
406
|
});
|
|
397
407
|
|
|
398
|
-
const _boost = await
|
|
408
|
+
const _boost = await core.createBoost({
|
|
399
409
|
budget: budget,
|
|
400
|
-
action:
|
|
401
|
-
defaultOptions,
|
|
410
|
+
action: core.EventAction(
|
|
402
411
|
makeMockEventActionPayload(
|
|
403
412
|
core.assertValidAddress(),
|
|
404
413
|
erc20.assertValidAddress(),
|
|
405
414
|
),
|
|
406
415
|
),
|
|
407
|
-
validator:
|
|
416
|
+
validator: core.SignerValidator({
|
|
408
417
|
signers: [defaultOptions.account.address],
|
|
409
418
|
validatorCaller: defaultOptions.account.address,
|
|
410
419
|
}),
|
|
411
|
-
allowList:
|
|
420
|
+
allowList: core.SimpleAllowList({
|
|
412
421
|
owner: defaultOptions.account.address,
|
|
413
422
|
allowed: [defaultOptions.account.address],
|
|
414
423
|
}),
|
|
415
424
|
incentives: [
|
|
416
|
-
|
|
425
|
+
core.ERC20Incentive({
|
|
417
426
|
asset: erc20.assertValidAddress(),
|
|
418
427
|
reward: parseEther('1'),
|
|
419
428
|
limit: 100n,
|
|
420
429
|
strategy: StrategyType.POOL,
|
|
430
|
+
manager: budget.assertValidAddress(),
|
|
421
431
|
}),
|
|
422
432
|
],
|
|
423
433
|
});
|
|
424
|
-
const boost = await
|
|
434
|
+
const boost = await core.createBoost({
|
|
425
435
|
budget: budget,
|
|
426
|
-
action:
|
|
427
|
-
defaultOptions,
|
|
436
|
+
action: core.EventAction(
|
|
428
437
|
makeMockEventActionPayload(
|
|
429
438
|
core.assertValidAddress(),
|
|
430
439
|
erc20.assertValidAddress(),
|
|
431
440
|
),
|
|
432
441
|
),
|
|
433
|
-
validator:
|
|
442
|
+
validator: core.SignerValidator({
|
|
434
443
|
signers: [defaultOptions.account.address],
|
|
435
444
|
validatorCaller: defaultOptions.account.address,
|
|
436
445
|
}),
|
|
437
|
-
allowList:
|
|
438
|
-
defaultOptions,
|
|
446
|
+
allowList: core.SimpleAllowList(
|
|
439
447
|
_boost.allowList.assertValidAddress(),
|
|
440
448
|
false,
|
|
441
449
|
),
|
|
442
450
|
incentives: [
|
|
443
|
-
|
|
451
|
+
core.ERC20Incentive({
|
|
444
452
|
asset: erc20.assertValidAddress(),
|
|
445
453
|
reward: parseEther('1'),
|
|
446
454
|
limit: 100n,
|
|
447
455
|
strategy: StrategyType.POOL,
|
|
456
|
+
manager: budget.assertValidAddress(),
|
|
448
457
|
}),
|
|
449
458
|
],
|
|
450
459
|
});
|
|
451
|
-
const onChainBoost = await
|
|
460
|
+
const onChainBoost = await core.readBoost(boost.id);
|
|
452
461
|
expect(onChainBoost.allowList).toBe(_boost.allowList.assertValidAddress());
|
|
453
462
|
});
|
|
454
463
|
|
|
455
464
|
test('cannot reuse an existing incentive', async () => {
|
|
456
|
-
const { core
|
|
457
|
-
const client = new BoostCore({
|
|
458
|
-
...defaultOptions,
|
|
459
|
-
address: core.assertValidAddress(),
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
// to whom it may concern, this syntax is only used because we need to use test classes
|
|
463
|
-
// that are preconfigured with the dynamic base addresses generated at test time.
|
|
464
|
-
// normally you would use the follow api for brevity
|
|
465
|
-
// budget: client.SimpleBudget({} | '0xaddress')
|
|
465
|
+
const { core } = fixtures;
|
|
466
466
|
const { budget, erc20 } = budgets;
|
|
467
467
|
|
|
468
468
|
// allocate more erc20 funds to the budget from the owning accound
|
|
469
|
-
await erc20.mint(defaultOptions.account.address, parseEther('
|
|
470
|
-
await erc20.approve(budget.assertValidAddress(), parseEther('
|
|
469
|
+
await erc20.mint(defaultOptions.account.address, parseEther('110'));
|
|
470
|
+
await erc20.approve(budget.assertValidAddress(), parseEther('110'));
|
|
471
471
|
await budget.allocate({
|
|
472
|
-
amount: parseEther('
|
|
472
|
+
amount: parseEther('110'),
|
|
473
473
|
asset: erc20.assertValidAddress(),
|
|
474
474
|
target: defaultOptions.account.address,
|
|
475
475
|
});
|
|
476
476
|
|
|
477
|
-
const incentive =
|
|
477
|
+
const incentive = core.ERC20Incentive({
|
|
478
478
|
asset: erc20.assertValidAddress(),
|
|
479
479
|
reward: parseEther('1'),
|
|
480
480
|
limit: 100n,
|
|
481
481
|
strategy: StrategyType.POOL,
|
|
482
|
+
manager: budget.assertValidAddress(),
|
|
482
483
|
});
|
|
483
|
-
const _boost = await
|
|
484
|
+
const _boost = await core.createBoost({
|
|
484
485
|
budget: budget,
|
|
485
|
-
action:
|
|
486
|
-
defaultOptions,
|
|
486
|
+
action: core.EventAction(
|
|
487
487
|
makeMockEventActionPayload(
|
|
488
488
|
core.assertValidAddress(),
|
|
489
489
|
erc20.assertValidAddress(),
|
|
490
490
|
),
|
|
491
491
|
),
|
|
492
|
-
validator:
|
|
492
|
+
validator: core.SignerValidator({
|
|
493
493
|
signers: [defaultOptions.account.address],
|
|
494
494
|
validatorCaller: defaultOptions.account.address,
|
|
495
495
|
}),
|
|
496
|
-
allowList:
|
|
496
|
+
allowList: core.SimpleAllowList({
|
|
497
497
|
owner: defaultOptions.account.address,
|
|
498
498
|
allowed: [defaultOptions.account.address],
|
|
499
499
|
}),
|
|
500
500
|
incentives: [incentive],
|
|
501
501
|
});
|
|
502
502
|
try {
|
|
503
|
-
await
|
|
503
|
+
await core.createBoost({
|
|
504
504
|
budget: budget,
|
|
505
|
-
action:
|
|
506
|
-
defaultOptions,
|
|
505
|
+
action: core.EventAction(
|
|
507
506
|
makeMockEventActionPayload(
|
|
508
507
|
core.assertValidAddress(),
|
|
509
508
|
erc20.assertValidAddress(),
|
|
510
509
|
),
|
|
511
510
|
),
|
|
512
|
-
validator:
|
|
511
|
+
validator: core.SignerValidator({
|
|
513
512
|
signers: [defaultOptions.account.address],
|
|
514
513
|
validatorCaller: defaultOptions.account.address,
|
|
515
514
|
}),
|
|
516
|
-
allowList:
|
|
515
|
+
allowList: core.SimpleAllowList({
|
|
517
516
|
owner: defaultOptions.account.address,
|
|
518
517
|
allowed: [defaultOptions.account.address],
|
|
519
518
|
}),
|
|
@@ -525,79 +524,66 @@ describe('BoostCore', () => {
|
|
|
525
524
|
});
|
|
526
525
|
|
|
527
526
|
test('can offer multiple incentives', async () => {
|
|
528
|
-
const { registry, core
|
|
529
|
-
const client = new BoostCore({
|
|
530
|
-
...defaultOptions,
|
|
531
|
-
address: core.assertValidAddress(),
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
// to whom it may concern, this syntax is only used because we need to use test classes
|
|
535
|
-
// that are preconfigured with the dynamic base addresses generated at test time.
|
|
536
|
-
// normally you would use the follow api for brevity
|
|
537
|
-
// budget: client.SimpleBudget({} | '0xaddress')
|
|
527
|
+
const { registry, core } = fixtures;
|
|
538
528
|
const { budget, erc20, points, erc1155 } = budgets;
|
|
539
|
-
const allowList = await registry.
|
|
529
|
+
const allowList = await registry.initialize(
|
|
540
530
|
'SharedAllowList',
|
|
541
|
-
|
|
531
|
+
core.SimpleAllowList({
|
|
542
532
|
owner: defaultOptions.account.address,
|
|
543
533
|
allowed: [defaultOptions.account.address],
|
|
544
534
|
}),
|
|
545
535
|
);
|
|
546
536
|
|
|
547
|
-
const erc20Incentive =
|
|
537
|
+
const erc20Incentive = core.ERC20Incentive({
|
|
548
538
|
asset: erc20.assertValidAddress(),
|
|
549
539
|
reward: 1n,
|
|
550
540
|
limit: 10n,
|
|
551
541
|
strategy: StrategyType.POOL,
|
|
542
|
+
manager: budget.assertValidAddress(),
|
|
552
543
|
});
|
|
553
|
-
const erc1155Incentive =
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
});
|
|
560
|
-
const cgdaIncentive =
|
|
544
|
+
// const erc1155Incentive = core.ERC1155Incentive({
|
|
545
|
+
// asset: erc1155.assertValidAddress(),
|
|
546
|
+
// strategy: ERC1155StrategyType.POOL,
|
|
547
|
+
// limit: 1n,
|
|
548
|
+
// tokenId: 1n,
|
|
549
|
+
// extraData: '0x',
|
|
550
|
+
// });
|
|
551
|
+
const cgdaIncentive = core.CGDAIncentive({
|
|
561
552
|
asset: erc20.assertValidAddress(),
|
|
562
553
|
initialReward: 1n,
|
|
563
554
|
totalBudget: 10n,
|
|
564
555
|
rewardBoost: 1n,
|
|
565
556
|
rewardDecay: 1n,
|
|
557
|
+
manager: budget.assertValidAddress(),
|
|
566
558
|
});
|
|
567
|
-
const allowListIncentive =
|
|
559
|
+
const allowListIncentive = core.AllowListIncentive({
|
|
568
560
|
allowList: allowList.assertValidAddress(),
|
|
569
561
|
limit: 5n,
|
|
570
562
|
});
|
|
571
|
-
const pointsIncentive =
|
|
563
|
+
const pointsIncentive = core.PointsIncentive({
|
|
572
564
|
venue: points.assertValidAddress(),
|
|
573
565
|
selector: bytes4('issue(address,uint256)'),
|
|
574
566
|
reward: 1n,
|
|
575
567
|
limit: 10n,
|
|
576
568
|
});
|
|
577
569
|
|
|
578
|
-
await
|
|
570
|
+
await core.createBoost({
|
|
579
571
|
protocolFee: 1n,
|
|
580
|
-
referralFee: 2n,
|
|
581
572
|
maxParticipants: 100n,
|
|
582
573
|
budget: budget,
|
|
583
|
-
action:
|
|
584
|
-
defaultOptions,
|
|
574
|
+
action: core.EventAction(
|
|
585
575
|
makeMockEventActionPayload(
|
|
586
576
|
core.assertValidAddress(),
|
|
587
577
|
erc20.assertValidAddress(),
|
|
588
578
|
),
|
|
589
579
|
),
|
|
590
|
-
validator:
|
|
580
|
+
validator: core.SignerValidator({
|
|
591
581
|
signers: [defaultOptions.account.address],
|
|
592
582
|
validatorCaller: defaultOptions.account.address,
|
|
593
583
|
}),
|
|
594
|
-
allowList:
|
|
595
|
-
defaultOptions,
|
|
596
|
-
allowList.assertValidAddress(),
|
|
597
|
-
false,
|
|
598
|
-
),
|
|
584
|
+
allowList: core.SimpleAllowList(allowList.assertValidAddress()),
|
|
599
585
|
incentives: [
|
|
600
|
-
erc1155Incentive,
|
|
586
|
+
// erc1155Incentive,
|
|
601
587
|
erc20Incentive,
|
|
602
588
|
cgdaIncentive,
|
|
603
589
|
allowListIncentive,
|
|
@@ -622,58 +608,24 @@ describe('BoostCore', () => {
|
|
|
622
608
|
|
|
623
609
|
test('can get the protocol fee', async () => {
|
|
624
610
|
const { core } = fixtures;
|
|
625
|
-
const client = new BoostCore({
|
|
626
|
-
...defaultOptions,
|
|
627
|
-
address: core.assertValidAddress(),
|
|
628
|
-
});
|
|
629
611
|
|
|
630
|
-
expect(await
|
|
612
|
+
expect(await core.protocolFee()).toBe(1000n);
|
|
631
613
|
});
|
|
632
614
|
|
|
633
615
|
test('can get the protocol fee receiver', async () => {
|
|
634
616
|
const { core } = fixtures;
|
|
635
|
-
const client = new BoostCore({
|
|
636
|
-
...defaultOptions,
|
|
637
|
-
address: core.assertValidAddress(),
|
|
638
|
-
});
|
|
639
617
|
|
|
640
|
-
expect(await
|
|
618
|
+
expect(await core.protocolFeeReceiver()).toBe(
|
|
641
619
|
defaultOptions.account.address,
|
|
642
620
|
);
|
|
643
621
|
});
|
|
644
622
|
|
|
645
623
|
test('can set the protocol fee receiver', async () => {
|
|
646
624
|
const { core } = fixtures;
|
|
647
|
-
const client = new BoostCore({
|
|
648
|
-
...defaultOptions,
|
|
649
|
-
address: core.assertValidAddress(),
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
await client.setProcolFeeReceiver(zeroAddress);
|
|
653
|
-
|
|
654
|
-
expect(await client.protocolFeeReceiver()).toBe(zeroAddress);
|
|
655
|
-
});
|
|
656
|
-
|
|
657
|
-
test('can get the claim fee', async () => {
|
|
658
|
-
const { core } = fixtures;
|
|
659
|
-
const client = new BoostCore({
|
|
660
|
-
...defaultOptions,
|
|
661
|
-
address: core.assertValidAddress(),
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
expect(await client.claimFee()).toBe(75000000000000n);
|
|
665
|
-
});
|
|
666
|
-
|
|
667
|
-
test('can set the claim fee', async () => {
|
|
668
|
-
const { core } = fixtures;
|
|
669
|
-
const client = new BoostCore({
|
|
670
|
-
...defaultOptions,
|
|
671
|
-
address: core.assertValidAddress(),
|
|
672
|
-
});
|
|
673
625
|
|
|
674
|
-
await
|
|
626
|
+
await core.setProcolFeeReceiver(zeroAddress);
|
|
675
627
|
|
|
676
|
-
expect(await
|
|
628
|
+
expect(await core.protocolFeeReceiver()).toBe(zeroAddress);
|
|
677
629
|
});
|
|
678
630
|
|
|
679
631
|
test('binds all actions, budgets, allowlists, incentives, and validators to reuse core options and account', () => {
|
|
@@ -724,6 +676,7 @@ describe('BoostCore', () => {
|
|
|
724
676
|
rewardDecay: 0n,
|
|
725
677
|
rewardBoost: 0n,
|
|
726
678
|
totalBudget: 0n,
|
|
679
|
+
manager: zeroAddress,
|
|
727
680
|
});
|
|
728
681
|
expect(cgdaIncentive._config).toEqual(defaultOptions.config);
|
|
729
682
|
expect(cgdaIncentive._account).toEqual(defaultOptions.account);
|
|
@@ -772,44 +725,34 @@ describe('BoostCore', () => {
|
|
|
772
725
|
test('can subscribe to contract events', async () => {
|
|
773
726
|
const subscription = vi.fn();
|
|
774
727
|
|
|
775
|
-
const { core
|
|
776
|
-
|
|
777
|
-
...defaultOptions,
|
|
778
|
-
address: core.assertValidAddress(),
|
|
779
|
-
});
|
|
780
|
-
client.subscribe(subscription, { pollingInterval: 100 });
|
|
781
|
-
|
|
782
|
-
// to whom it may concern, this syntax is only used because we need to use test classes
|
|
783
|
-
// that are preconfigured with the dynamic base addresses generated at test time.
|
|
784
|
-
// normally you would use the follow api for brevity
|
|
785
|
-
// budget: client.SimpleBudget({} | '0xaddress')
|
|
728
|
+
const { core } = fixtures;
|
|
729
|
+
core.subscribe(subscription, { pollingInterval: 100 });
|
|
786
730
|
const { budget, erc20 } = budgets;
|
|
787
|
-
await
|
|
731
|
+
await core.createBoost({
|
|
788
732
|
protocolFee: 1n,
|
|
789
|
-
referralFee: 2n,
|
|
790
733
|
maxParticipants: 100n,
|
|
791
734
|
budget: budget,
|
|
792
|
-
action:
|
|
793
|
-
defaultOptions,
|
|
735
|
+
action: core.EventAction(
|
|
794
736
|
makeMockEventActionPayload(
|
|
795
737
|
core.assertValidAddress(),
|
|
796
738
|
erc20.assertValidAddress(),
|
|
797
739
|
),
|
|
798
740
|
),
|
|
799
|
-
validator:
|
|
741
|
+
validator: core.SignerValidator({
|
|
800
742
|
signers: [defaultOptions.account.address],
|
|
801
743
|
validatorCaller: defaultOptions.account.address,
|
|
802
744
|
}),
|
|
803
|
-
allowList:
|
|
745
|
+
allowList: core.SimpleAllowList({
|
|
804
746
|
owner: defaultOptions.account.address,
|
|
805
747
|
allowed: [defaultOptions.account.address],
|
|
806
748
|
}),
|
|
807
749
|
incentives: [
|
|
808
|
-
|
|
750
|
+
core.ERC20Incentive({
|
|
809
751
|
asset: erc20.assertValidAddress(),
|
|
810
752
|
reward: parseEther('1'),
|
|
811
753
|
limit: 100n,
|
|
812
754
|
strategy: StrategyType.POOL,
|
|
755
|
+
manager: budget.assertValidAddress(),
|
|
813
756
|
}),
|
|
814
757
|
],
|
|
815
758
|
});
|
|
@@ -823,17 +766,129 @@ describe('BoostCore', () => {
|
|
|
823
766
|
|
|
824
767
|
test('can set a passthrough auth scheme', async () => {
|
|
825
768
|
const { core } = fixtures;
|
|
826
|
-
const client = new BoostCore({
|
|
827
|
-
...defaultOptions,
|
|
828
|
-
address: core.assertValidAddress(),
|
|
829
|
-
});
|
|
830
769
|
|
|
831
|
-
const auth =
|
|
770
|
+
const auth = core.PassthroughAuth();
|
|
832
771
|
await auth.deploy();
|
|
833
|
-
await
|
|
834
|
-
expect((await
|
|
772
|
+
await core.setCreateBoostAuth(auth);
|
|
773
|
+
expect((await core.createBoostAuth()).toLowerCase()).toBe(
|
|
835
774
|
auth.assertValidAddress(),
|
|
836
775
|
);
|
|
837
|
-
expect(await
|
|
776
|
+
expect(await core.isAuthorized(zeroAddress)).toBe(true);
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
test('uses the provided validator when one is specified', async () => {
|
|
780
|
+
const { core } = fixtures;
|
|
781
|
+
const { budget, erc20 } = budgets;
|
|
782
|
+
const customValidator = core.SignerValidator({
|
|
783
|
+
signers: [budget.assertValidAddress()],
|
|
784
|
+
validatorCaller: core.assertValidAddress(),
|
|
785
|
+
});
|
|
786
|
+
const boost = await core.createBoost({
|
|
787
|
+
maxParticipants: 100n,
|
|
788
|
+
budget: budget,
|
|
789
|
+
action: core.EventAction(
|
|
790
|
+
makeMockEventActionPayload(
|
|
791
|
+
core.assertValidAddress(),
|
|
792
|
+
erc20.assertValidAddress(),
|
|
793
|
+
),
|
|
794
|
+
),
|
|
795
|
+
validator: customValidator,
|
|
796
|
+
allowList: core.SimpleAllowList({
|
|
797
|
+
owner: defaultOptions.account.address,
|
|
798
|
+
allowed: [defaultOptions.account.address],
|
|
799
|
+
}),
|
|
800
|
+
incentives: [
|
|
801
|
+
core.ERC20Incentive({
|
|
802
|
+
asset: erc20.assertValidAddress(),
|
|
803
|
+
reward: parseEther('1'),
|
|
804
|
+
limit: 100n,
|
|
805
|
+
strategy: StrategyType.POOL,
|
|
806
|
+
manager: budget.assertValidAddress(),
|
|
807
|
+
}),
|
|
808
|
+
],
|
|
809
|
+
});
|
|
810
|
+
|
|
811
|
+
expect(boost.validator).toBe(customValidator);
|
|
812
|
+
const signers = await boost.validator.signers(budget.assertValidAddress());
|
|
813
|
+
expect(signers).toBe(true);
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
test('creates a boost with a default validator when none is provided', async () => {
|
|
817
|
+
const { core } = fixtures;
|
|
818
|
+
const { budget, erc20 } = budgets;
|
|
819
|
+
const boost = await core.createBoost({
|
|
820
|
+
maxParticipants: 100n,
|
|
821
|
+
budget: budget,
|
|
822
|
+
action: core.EventAction(
|
|
823
|
+
makeMockEventActionPayload(
|
|
824
|
+
core.assertValidAddress(),
|
|
825
|
+
erc20.assertValidAddress(),
|
|
826
|
+
),
|
|
827
|
+
),
|
|
828
|
+
allowList: core.OpenAllowList(),
|
|
829
|
+
incentives: [
|
|
830
|
+
core.ERC20Incentive({
|
|
831
|
+
asset: erc20.assertValidAddress(),
|
|
832
|
+
reward: parseEther('1'),
|
|
833
|
+
limit: 100n,
|
|
834
|
+
strategy: StrategyType.POOL,
|
|
835
|
+
manager: budget.assertValidAddress(),
|
|
836
|
+
}),
|
|
837
|
+
],
|
|
838
|
+
});
|
|
839
|
+
|
|
840
|
+
const validator = boost.validator;
|
|
841
|
+
|
|
842
|
+
// expect boostCore to be a validatorCaller
|
|
843
|
+
expect(validator.payload?.validatorCaller).toBe(core.assertValidAddress());
|
|
844
|
+
|
|
845
|
+
// expect current account to be a signer
|
|
846
|
+
const signer = await validator.signers(defaultOptions.account.address);
|
|
847
|
+
expect(signer).toBeDefined();
|
|
848
|
+
expect(signer).toBe(true);
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
test('can retrieve the BoostClaimed event from a transaction hash', async () => {
|
|
852
|
+
// biome-ignore lint/style/noNonNullAssertion: we know this is defined
|
|
853
|
+
const referrer = accounts.at(1)!.account!,
|
|
854
|
+
// biome-ignore lint/style/noNonNullAssertion: we know this is defined
|
|
855
|
+
trustedSigner = accounts.at(0)!;
|
|
856
|
+
const erc20Incentive = fixtures.core.ERC20Incentive({
|
|
857
|
+
asset: budgets.erc20.assertValidAddress(),
|
|
858
|
+
strategy: StrategyType.POOL,
|
|
859
|
+
reward: 1n,
|
|
860
|
+
limit: 1n,
|
|
861
|
+
manager: budgets.budget.assertValidAddress(),
|
|
862
|
+
});
|
|
863
|
+
const boost = await freshBoost(fixtures, {
|
|
864
|
+
budget: budgets.budget,
|
|
865
|
+
incentives: [erc20Incentive],
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
const claimant = trustedSigner.account;
|
|
869
|
+
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
870
|
+
const incentiveQuantity = 1;
|
|
871
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
872
|
+
signer: trustedSigner,
|
|
873
|
+
incentiveData,
|
|
874
|
+
chainId: defaultOptions.config.chains[0].id,
|
|
875
|
+
incentiveQuantity,
|
|
876
|
+
claimant,
|
|
877
|
+
boostId: boost.id,
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
const { hash } = await fixtures.core.claimIncentiveRaw(
|
|
881
|
+
boost.id,
|
|
882
|
+
0n,
|
|
883
|
+
referrer,
|
|
884
|
+
claimDataPayload,
|
|
885
|
+
{ value: BOOST_CORE_CLAIM_FEE },
|
|
886
|
+
);
|
|
887
|
+
|
|
888
|
+
const claimInfo = await fixtures.core.getClaimFromTransaction({ hash });
|
|
889
|
+
expect(claimInfo).toBeDefined();
|
|
890
|
+
expect(claimInfo?.claimant).toBe(claimant);
|
|
891
|
+
expect(typeof claimInfo?.boostId).toBe('bigint');
|
|
892
|
+
expect(claimInfo?.referrer).toBe(referrer);
|
|
838
893
|
});
|
|
839
894
|
});
|