@boostxyz/sdk 0.0.0-alpha.8 → 1.1.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.cjs.map +1 -1
- package/dist/Actions/Action.js +7 -7
- package/dist/Actions/ContractAction.d.ts +57 -14
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +50 -23
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +420 -45
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -225
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.cjs.map +1 -1
- package/dist/AllowLists/AllowList.d.ts +6 -4
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +45 -23
- package/dist/AllowLists/AllowList.js.map +1 -1
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +123 -39
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +75 -76
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +11 -200
- package/dist/AllowLists/SimpleDenyList.js.map +1 -1
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.cjs.map +1 -1
- package/dist/Auth/PassthroughAuth.js +4 -4
- package/dist/Auth/PassthroughAuth.js.map +1 -1
- package/dist/Boost.cjs +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +105 -14
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +137 -5
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore-BVZExPPu.js +1462 -0
- package/dist/BoostCore-BVZExPPu.js.map +1 -0
- package/dist/BoostCore-D-E-cnGI.cjs +3 -0
- package/dist/BoostCore-D-E-cnGI.cjs.map +1 -0
- package/dist/BoostCore.cjs +1 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +759 -82
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1148
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.cjs.map +1 -1
- package/dist/BoostRegistry.d.ts +83 -28
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +170 -93
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.cjs.map +1 -1
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/Budget.js.map +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +112 -192
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +89 -290
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +277 -91
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +1 -1
- package/dist/Deployable/Contract.cjs.map +1 -1
- package/dist/Deployable/Contract.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +6 -8
- package/dist/Deployable/Contract.js.map +1 -1
- package/dist/Deployable/Deployable.cjs.map +1 -1
- package/dist/Deployable/Deployable.d.ts +1 -1
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +3 -5
- package/dist/Deployable/Deployable.js.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -1
- package/dist/Deployable/DeployableTarget.d.ts +13 -13
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +30 -27
- package/dist/Deployable/DeployableTarget.js.map +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
- package/dist/EventAction-BZt5cjbe.cjs +2 -0
- package/dist/EventAction-BZt5cjbe.cjs.map +1 -0
- package/dist/EventAction-C_-hJXWm.js +1541 -0
- package/dist/EventAction-C_-hJXWm.js.map +1 -0
- package/dist/Incentive-BhHaK3PZ.cjs +2 -0
- package/dist/Incentive-BhHaK3PZ.cjs.map +1 -0
- package/dist/Incentive-Cqg1w6wD.js +312 -0
- package/dist/Incentive-Cqg1w6wD.js.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +73 -21
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +61 -36
- package/dist/Incentives/AllowListIncentive.js.map +1 -1
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
- package/dist/Incentives/CGDAIncentive.d.ts +323 -26
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +73 -39
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.d.ts +278 -33
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +79 -47
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +346 -420
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +271 -32
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.cjs.map +1 -1
- package/dist/Incentives/Incentive.d.ts +4 -4
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +16 -280
- package/dist/Incentives/Incentive.js.map +1 -1
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts +89 -23
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +66 -36
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
- package/dist/SimpleDenyList-CGaWjuld.js +132 -0
- package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +310 -17
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +164 -36
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.cjs.map +1 -1
- package/dist/Validators/Validator.d.ts +1 -1
- package/dist/Validators/Validator.js +2 -2
- package/dist/Validators/Validator.js.map +1 -1
- package/dist/claiming.cjs +2 -0
- package/dist/claiming.cjs.map +1 -0
- package/dist/claiming.d.ts +43 -0
- package/dist/claiming.d.ts.map +1 -0
- package/dist/claiming.js +17 -0
- package/dist/claiming.js.map +1 -0
- package/dist/componentInterfaces-BBCFkrZv.js +14 -0
- package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
- package/dist/deployments-DVXioW2i.cjs +2 -0
- package/dist/deployments-DVXioW2i.cjs.map +1 -0
- package/dist/deployments-oykLv3_Z.js +43 -0
- package/dist/deployments-oykLv3_Z.js.map +1 -0
- package/dist/deployments.json +44 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +257 -21
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +183 -26
- package/dist/errors.js.map +1 -1
- package/dist/{generated-Cbv8zFkf.js → generated-CKt2yCQd.js} +3615 -1868
- package/dist/generated-CKt2yCQd.js.map +1 -0
- package/dist/generated-CyTNlOwM.cjs +3 -0
- package/dist/generated-CyTNlOwM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -126
- package/dist/index.js.map +1 -1
- package/dist/transfers.cjs +2 -0
- package/dist/transfers.cjs.map +1 -0
- package/dist/transfers.d.ts +198 -0
- package/dist/transfers.d.ts.map +1 -0
- package/dist/transfers.js +84 -0
- package/dist/transfers.js.map +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +25 -1380
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +36 -648
- package/dist/utils.js.map +1 -1
- package/package.json +34 -10
- package/src/Actions/Action.test.ts +19 -17
- package/src/Actions/ContractAction.test.ts +14 -16
- package/src/Actions/ContractAction.ts +84 -22
- package/src/Actions/ERC721MintAction.test.ts +8 -8
- package/src/Actions/ERC721MintAction.ts +83 -30
- package/src/Actions/EventAction.test.ts +759 -113
- package/src/Actions/EventAction.ts +991 -116
- package/src/AllowLists/AllowList.test.ts +7 -7
- package/src/AllowLists/AllowList.ts +5 -3
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +4 -4
- package/src/AllowLists/SimpleAllowList.ts +86 -65
- package/src/AllowLists/SimpleDenyList.test.ts +4 -4
- package/src/AllowLists/SimpleDenyList.ts +87 -126
- package/src/Auth/PassthroughAuth.test.ts +1 -1
- package/src/Auth/PassthroughAuth.ts +1 -1
- package/src/Boost.ts +147 -15
- package/src/BoostCore.test.ts +326 -278
- package/src/BoostCore.ts +425 -242
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +168 -50
- package/src/Budgets/Budget.test.ts +2 -2
- package/src/Budgets/Budget.ts +1 -2
- package/src/Budgets/ManagedBudget.test.ts +82 -19
- package/src/Budgets/ManagedBudget.ts +106 -315
- package/src/Budgets/VestingBudget.test.ts +7 -7
- package/src/Budgets/VestingBudget.ts +110 -112
- package/src/Deployable/Contract.ts +5 -6
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +32 -21
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +7 -10
- package/src/Incentives/AllowListIncentive.ts +88 -30
- package/src/Incentives/CGDAIncentive.test.ts +11 -12
- package/src/Incentives/CGDAIncentive.ts +161 -37
- package/src/Incentives/ERC1155Incentive.test.ts +5 -16
- package/src/Incentives/ERC1155Incentive.ts +132 -51
- package/src/Incentives/ERC20Incentive.test.ts +15 -23
- package/src/Incentives/ERC20Incentive.ts +131 -46
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +12 -35
- package/src/Incentives/ERC20VariableIncentive.ts +118 -43
- package/src/Incentives/Incentive.test.ts +5 -2
- package/src/Incentives/Incentive.ts +7 -6
- package/src/Incentives/PointsIncentive.test.ts +26 -30
- package/src/Incentives/PointsIncentive.ts +110 -34
- package/src/Validators/SignerValidator.test.ts +9 -13
- package/src/Validators/SignerValidator.ts +437 -26
- package/src/Validators/Validator.test.ts +2 -2
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +56 -0
- package/src/errors.ts +346 -22
- package/src/index.test.ts +118 -36
- package/src/index.ts +15 -7
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +2 -2
- package/src/utils.ts +61 -2061
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
- package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
- package/dist/componentInterfaces-DYkaxBda.js +0 -13
- package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
- package/dist/generated-BzszviNp.cjs +0 -3
- package/dist/generated-BzszviNp.cjs.map +0 -1
- package/dist/generated-Cbv8zFkf.js.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -521
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
type Fixtures,
|
|
5
5
|
defaultOptions,
|
|
6
6
|
deployFixtures,
|
|
7
|
-
} from '
|
|
7
|
+
} from '@boostxyz/test/helpers';
|
|
8
8
|
import {
|
|
9
9
|
SimpleAllowList,
|
|
10
10
|
SimpleDenyList,
|
|
@@ -14,14 +14,14 @@ import {
|
|
|
14
14
|
let fixtures: Fixtures;
|
|
15
15
|
|
|
16
16
|
beforeAll(async () => {
|
|
17
|
-
fixtures = await loadFixture(deployFixtures);
|
|
17
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
function freshAllowList(fixtures: Fixtures) {
|
|
21
21
|
return function freshAllowList() {
|
|
22
|
-
return fixtures.registry.
|
|
22
|
+
return fixtures.registry.initialize(
|
|
23
23
|
crypto.randomUUID(),
|
|
24
|
-
|
|
24
|
+
fixtures.core.SimpleAllowList({
|
|
25
25
|
owner: defaultOptions.account.address,
|
|
26
26
|
allowed: [defaultOptions.account.address],
|
|
27
27
|
}),
|
|
@@ -31,9 +31,9 @@ function freshAllowList(fixtures: Fixtures) {
|
|
|
31
31
|
|
|
32
32
|
function freshDenyList(fixtures: Fixtures) {
|
|
33
33
|
return function freshDenyList() {
|
|
34
|
-
return fixtures.registry.
|
|
34
|
+
return fixtures.registry.initialize(
|
|
35
35
|
crypto.randomUUID(),
|
|
36
|
-
|
|
36
|
+
fixtures.core.SimpleDenyList({
|
|
37
37
|
owner: defaultOptions.account.address,
|
|
38
38
|
denied: [defaultOptions.account.address],
|
|
39
39
|
}),
|
|
@@ -52,7 +52,7 @@ describe('AllowList', () => {
|
|
|
52
52
|
).toBeInstanceOf(SimpleAllowList);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
test('can automatically instantiate
|
|
55
|
+
test('can automatically instantiate SimpleDenyList given an address', async () => {
|
|
56
56
|
const _allowList = await loadFixture(freshDenyList(fixtures));
|
|
57
57
|
expect(
|
|
58
58
|
await allowListFromAddress(
|
|
@@ -7,10 +7,11 @@ import { readContract } from '@wagmi/core';
|
|
|
7
7
|
import type { Address, Hex } from 'viem';
|
|
8
8
|
import type { DeployableOptions } from '../Deployable/Deployable';
|
|
9
9
|
import { InvalidComponentInterfaceError } from '../errors';
|
|
10
|
+
import { OpenAllowList } from './OpenAllowList';
|
|
10
11
|
import { SimpleAllowList } from './SimpleAllowList';
|
|
11
12
|
import { SimpleDenyList } from './SimpleDenyList';
|
|
12
13
|
|
|
13
|
-
export { SimpleAllowList, SimpleDenyList };
|
|
14
|
+
export { OpenAllowList, SimpleAllowList, SimpleDenyList };
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* A union type representing all valid protocol AllowList implementations
|
|
@@ -18,7 +19,7 @@ export { SimpleAllowList, SimpleDenyList };
|
|
|
18
19
|
* @export
|
|
19
20
|
* @typedef {AllowList}
|
|
20
21
|
*/
|
|
21
|
-
export type AllowList = SimpleAllowList | SimpleDenyList;
|
|
22
|
+
export type AllowList = OpenAllowList | SimpleAllowList | SimpleDenyList;
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* A map of AllowList component interfaces to their constructors.
|
|
@@ -32,6 +33,7 @@ export const AllowListByComponentInterface = {
|
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* A function that will read a contract's component interface using `getComponentInterface` and return the correct instantiated instance.
|
|
36
|
+
* This function will never return an instance of {@link OpenAllowList} because it has the same component interface as {@link SimpleDenyList}
|
|
35
37
|
*
|
|
36
38
|
* @export
|
|
37
39
|
* @async
|
|
@@ -56,5 +58,5 @@ export async function allowListFromAddress(
|
|
|
56
58
|
interfaceId as Hex,
|
|
57
59
|
);
|
|
58
60
|
}
|
|
59
|
-
return new Ctor(options, address);
|
|
61
|
+
return new Ctor(options, address) as SimpleDenyList | SimpleAllowList;
|
|
60
62
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
2
|
+
import { isAddress, zeroAddress } from 'viem';
|
|
3
|
+
import { beforeAll, describe, expect, test } from 'vitest';
|
|
4
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
5
|
+
import {
|
|
6
|
+
type Fixtures,
|
|
7
|
+
defaultOptions,
|
|
8
|
+
deployFixtures,
|
|
9
|
+
} from '@boostxyz/test/helpers';
|
|
10
|
+
import { OpenAllowList } from './OpenAllowList';
|
|
11
|
+
|
|
12
|
+
let fixtures: Fixtures;
|
|
13
|
+
|
|
14
|
+
beforeAll(async () => {
|
|
15
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function freshOpenAllowList(fixtures: Fixtures) {
|
|
19
|
+
return function freshOpenAllowList() {
|
|
20
|
+
return fixtures.registry.initialize(
|
|
21
|
+
crypto.randomUUID(),
|
|
22
|
+
new fixtures.bases.OpenAllowList(defaultOptions),
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('OpenAllowList', () => {
|
|
28
|
+
test('can successfully be deployed', async () => {
|
|
29
|
+
const denyList = new OpenAllowList(defaultOptions);
|
|
30
|
+
await denyList.deploy();
|
|
31
|
+
expect(isAddress(denyList.assertValidAddress())).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('allows anyone', async () => {
|
|
35
|
+
const denyList = await loadFixture(freshOpenAllowList(fixtures));
|
|
36
|
+
expect(await denyList.isAllowed(defaultOptions.account.address)).toBe(true);
|
|
37
|
+
expect(await denyList.isAllowed(zeroAddress)).toBe(true);
|
|
38
|
+
expect(await denyList.isAllowed(accounts.at(1)!.account)).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { simpleDenyListAbi } from '@boostxyz/evm';
|
|
2
|
+
import { bytecode } from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleDenyList.sol/SimpleDenyList.json';
|
|
3
|
+
import { type Hex, zeroAddress } from 'viem';
|
|
4
|
+
import type {
|
|
5
|
+
DeployableOptions,
|
|
6
|
+
GenericDeployableParams,
|
|
7
|
+
} from '../Deployable/Deployable';
|
|
8
|
+
import {
|
|
9
|
+
SimpleDenyList,
|
|
10
|
+
type SimpleDenyListPayload,
|
|
11
|
+
prepareSimpleDenyListPayload,
|
|
12
|
+
} from './SimpleDenyList';
|
|
13
|
+
|
|
14
|
+
export const openAllowListAbi = simpleDenyListAbi;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A simple AllowList, extending {@link DenyList}, that is ownerless and allows anyone to claim.
|
|
18
|
+
*
|
|
19
|
+
* @export
|
|
20
|
+
* @class OpenAllowList
|
|
21
|
+
* @typedef {OpenAllowList}
|
|
22
|
+
* @extends {DeployableTarget<OpenAllowListPayload>}
|
|
23
|
+
*/
|
|
24
|
+
export class OpenAllowList extends SimpleDenyList<undefined> {
|
|
25
|
+
/**
|
|
26
|
+
* @inheritdoc
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
* @param {?SimpleDenyListPayload} [_payload]
|
|
30
|
+
* @param {?DeployableOptions} [_options]
|
|
31
|
+
* @returns {GenericDeployableParams}
|
|
32
|
+
*/
|
|
33
|
+
public override buildParameters(
|
|
34
|
+
_payload?: SimpleDenyListPayload,
|
|
35
|
+
_options?: DeployableOptions,
|
|
36
|
+
): GenericDeployableParams {
|
|
37
|
+
const [_, options] = this.validateDeploymentConfig({}, _options);
|
|
38
|
+
return {
|
|
39
|
+
abi: openAllowListAbi,
|
|
40
|
+
bytecode: bytecode as Hex,
|
|
41
|
+
args: [prepareSimpleDenyListPayload({ owner: zeroAddress, denied: [] })],
|
|
42
|
+
...this.optionallyAttachAccount(options.account),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -5,20 +5,20 @@ import {
|
|
|
5
5
|
type Fixtures,
|
|
6
6
|
defaultOptions,
|
|
7
7
|
deployFixtures,
|
|
8
|
-
} from '
|
|
8
|
+
} from '@boostxyz/test/helpers';
|
|
9
9
|
import { SimpleAllowList } from './SimpleAllowList';
|
|
10
10
|
|
|
11
11
|
let fixtures: Fixtures;
|
|
12
12
|
|
|
13
13
|
beforeAll(async () => {
|
|
14
|
-
fixtures = await loadFixture(deployFixtures);
|
|
14
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
function freshAllowList(fixtures: Fixtures) {
|
|
18
18
|
return function freshAllowList() {
|
|
19
|
-
return fixtures.registry.
|
|
19
|
+
return fixtures.registry.initialize(
|
|
20
20
|
crypto.randomUUID(),
|
|
21
|
-
|
|
21
|
+
fixtures.core.SimpleAllowList({
|
|
22
22
|
owner: defaultOptions.account.address,
|
|
23
23
|
allowed: [defaultOptions.account.address],
|
|
24
24
|
}),
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readSimpleAllowListIsAllowed,
|
|
3
|
+
readSimpleAllowListOwner,
|
|
3
4
|
simpleAllowListAbi,
|
|
4
|
-
simulateSimpleAllowListGrantRoles,
|
|
5
5
|
simulateSimpleAllowListSetAllowed,
|
|
6
|
-
writeSimpleAllowListGrantRoles,
|
|
7
6
|
writeSimpleAllowListSetAllowed,
|
|
8
7
|
} from '@boostxyz/evm';
|
|
9
8
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleAllowList.sol/SimpleAllowList.json';
|
|
@@ -12,26 +11,50 @@ import {
|
|
|
12
11
|
type Address,
|
|
13
12
|
type ContractEventName,
|
|
14
13
|
type Hex,
|
|
14
|
+
encodeAbiParameters,
|
|
15
15
|
zeroAddress,
|
|
16
16
|
zeroHash,
|
|
17
17
|
} from 'viem';
|
|
18
|
+
import { SimpleAllowList as SimpleAllowListBases } from '../../dist/deployments.json';
|
|
18
19
|
import type {
|
|
19
20
|
DeployableOptions,
|
|
20
21
|
GenericDeployableParams,
|
|
21
22
|
} from '../Deployable/Deployable';
|
|
22
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
DeployableTargetWithRBAC,
|
|
25
|
+
Roles,
|
|
26
|
+
} from '../Deployable/DeployableTargetWithRBAC';
|
|
23
27
|
import { DeployableUnknownOwnerProvidedError } from '../errors';
|
|
24
28
|
import {
|
|
25
29
|
type GenericLog,
|
|
26
30
|
type ReadParams,
|
|
27
31
|
RegistryType,
|
|
28
|
-
type SimpleAllowListPayload,
|
|
29
32
|
type WriteParams,
|
|
30
|
-
prepareSimpleAllowListPayload,
|
|
31
33
|
} from '../utils';
|
|
32
34
|
|
|
33
35
|
export { simpleAllowListAbi };
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Object representation of a {@link SimpleAllowList} initialization payload.
|
|
39
|
+
*
|
|
40
|
+
* @export
|
|
41
|
+
* @interface SimpleAllowListPayload
|
|
42
|
+
* @typedef {SimpleAllowListPayload}
|
|
43
|
+
*/
|
|
44
|
+
export interface SimpleAllowListPayload {
|
|
45
|
+
/**
|
|
46
|
+
* The allow list's owner, given the {@link LIST_MANAGER_ROLE} role.
|
|
47
|
+
*
|
|
48
|
+
* @type {Address}
|
|
49
|
+
*/
|
|
50
|
+
owner: Address;
|
|
51
|
+
/**
|
|
52
|
+
* List of allowed addresses.
|
|
53
|
+
*
|
|
54
|
+
* @type {Address[]}
|
|
55
|
+
*/
|
|
56
|
+
allowed: Address[];
|
|
57
|
+
}
|
|
35
58
|
|
|
36
59
|
/**
|
|
37
60
|
* A generic `viem.Log` event with support for `SimpleAllowList` event types.
|
|
@@ -51,18 +74,19 @@ export type SimpleAllowListLog<
|
|
|
51
74
|
/**
|
|
52
75
|
* A constant representing the list manager's role
|
|
53
76
|
*
|
|
54
|
-
* @
|
|
77
|
+
* @deprecated use {@link Roles} instead
|
|
78
|
+
* @type {1n}
|
|
55
79
|
*/
|
|
56
|
-
export const LIST_MANAGER_ROLE =
|
|
80
|
+
export const LIST_MANAGER_ROLE = Roles.MANAGER;
|
|
57
81
|
/**
|
|
58
82
|
* A simple implementation of an AllowList that checks if a user is authorized based on a list of allowed addresses
|
|
59
83
|
*
|
|
60
84
|
* @export
|
|
61
85
|
* @class SimpleAllowList
|
|
62
86
|
* @typedef {SimpleAllowList}
|
|
63
|
-
* @extends {
|
|
87
|
+
* @extends {DeployableTargetWithRBAC<SimpleAllowListPayload>}
|
|
64
88
|
*/
|
|
65
|
-
export class SimpleAllowList extends
|
|
89
|
+
export class SimpleAllowList extends DeployableTargetWithRBAC<
|
|
66
90
|
SimpleAllowListPayload,
|
|
67
91
|
typeof simpleAllowListAbi
|
|
68
92
|
> {
|
|
@@ -72,10 +96,11 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
72
96
|
*
|
|
73
97
|
* @public
|
|
74
98
|
* @static
|
|
75
|
-
* @type {Address}
|
|
99
|
+
* @type {Record<number, Address>}
|
|
76
100
|
*/
|
|
77
|
-
public static override
|
|
78
|
-
|
|
101
|
+
public static override bases: Record<number, Address> = {
|
|
102
|
+
...(SimpleAllowListBases as Record<number, Address>),
|
|
103
|
+
};
|
|
79
104
|
/**
|
|
80
105
|
* @inheritdoc
|
|
81
106
|
*
|
|
@@ -85,13 +110,33 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
85
110
|
*/
|
|
86
111
|
public static override registryType: RegistryType = RegistryType.ALLOW_LIST;
|
|
87
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Retrieves the owner
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
* @async
|
|
118
|
+
* @param {?ReadParams} [params]
|
|
119
|
+
* @returns {Promise<Address>} - The address of the owner
|
|
120
|
+
*/
|
|
121
|
+
public async owner(
|
|
122
|
+
params?: ReadParams<typeof simpleAllowListAbi, 'owner'>,
|
|
123
|
+
): Promise<Address> {
|
|
124
|
+
return await readSimpleAllowListOwner(this._config, {
|
|
125
|
+
...this.optionallyAttachAccount(),
|
|
126
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
127
|
+
...(params as any),
|
|
128
|
+
address: this.assertValidAddress(),
|
|
129
|
+
args: [],
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
88
133
|
/**
|
|
89
134
|
* Check if a user is authorized.
|
|
90
135
|
*
|
|
91
136
|
* @public
|
|
92
137
|
* @async
|
|
93
138
|
* @param {Address} address - The address of the user
|
|
94
|
-
* @param {?ReadParams
|
|
139
|
+
* @param {?ReadParams} [params]
|
|
95
140
|
* @returns {Promise<boolean>} - True if the user is authorized
|
|
96
141
|
*/
|
|
97
142
|
public async isAllowed(
|
|
@@ -115,7 +160,7 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
115
160
|
* @async
|
|
116
161
|
* @param {Address[]} addresses - The list of users to update
|
|
117
162
|
* @param {boolean[]} allowed - The allowed status of each user
|
|
118
|
-
* @param {?ReadParams
|
|
163
|
+
* @param {?ReadParams} [params]
|
|
119
164
|
* @returns {Promise<void>}
|
|
120
165
|
*/
|
|
121
166
|
public async setAllowed(
|
|
@@ -123,7 +168,9 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
123
168
|
allowed: boolean[],
|
|
124
169
|
params?: WriteParams<typeof simpleAllowListAbi, 'setAllowed'>,
|
|
125
170
|
) {
|
|
126
|
-
return this.awaitResult(
|
|
171
|
+
return await this.awaitResult(
|
|
172
|
+
this.setAllowedRaw(addresses, allowed, params),
|
|
173
|
+
);
|
|
127
174
|
}
|
|
128
175
|
|
|
129
176
|
/**
|
|
@@ -134,8 +181,8 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
134
181
|
* @async
|
|
135
182
|
* @param {Address[]} addresses - The list of users to update
|
|
136
183
|
* @param {boolean[]} allowed - The allowed status of each user
|
|
137
|
-
* @param {?ReadParams
|
|
138
|
-
* @returns {Promise<void>}
|
|
184
|
+
* @param {?ReadParams} [params]
|
|
185
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
139
186
|
*/
|
|
140
187
|
public async setAllowedRaw(
|
|
141
188
|
addresses: Address[],
|
|
@@ -156,53 +203,6 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
156
203
|
return { hash, result };
|
|
157
204
|
}
|
|
158
205
|
|
|
159
|
-
/**
|
|
160
|
-
* Allows the owner to grant `user` `roles`.
|
|
161
|
-
*
|
|
162
|
-
* @public
|
|
163
|
-
* @async
|
|
164
|
-
* @param {Address} address
|
|
165
|
-
* @param {bigint} role
|
|
166
|
-
* @param {?ReadParams<typeof simpleAllowListAbi, 'grantRoles'>} [params]
|
|
167
|
-
* @returns {Promise<void>}
|
|
168
|
-
*/
|
|
169
|
-
public async grantRoles(
|
|
170
|
-
address: Address,
|
|
171
|
-
role: bigint,
|
|
172
|
-
params?: WriteParams<typeof simpleAllowListAbi, 'grantRoles'>,
|
|
173
|
-
) {
|
|
174
|
-
return this.awaitResult(this.grantRolesRaw(address, role, params));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Allows the owner to grant `user` `roles`.
|
|
179
|
-
*
|
|
180
|
-
* @public
|
|
181
|
-
* @async
|
|
182
|
-
* @param {Address} address
|
|
183
|
-
* @param {bigint} role
|
|
184
|
-
* @param {?ReadParams<typeof simpleAllowListAbi, 'grantRoles'>} [params]
|
|
185
|
-
* @returns {Promise<void>}
|
|
186
|
-
*/
|
|
187
|
-
public async grantRolesRaw(
|
|
188
|
-
address: Address,
|
|
189
|
-
role: bigint,
|
|
190
|
-
params?: ReadParams<typeof simpleAllowListAbi, 'grantRoles'>,
|
|
191
|
-
) {
|
|
192
|
-
const { request, result } = await simulateSimpleAllowListGrantRoles(
|
|
193
|
-
this._config,
|
|
194
|
-
{
|
|
195
|
-
address: this.assertValidAddress(),
|
|
196
|
-
args: [address, role],
|
|
197
|
-
...this.optionallyAttachAccount(),
|
|
198
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
199
|
-
...(params as any),
|
|
200
|
-
},
|
|
201
|
-
);
|
|
202
|
-
const hash = await writeSimpleAllowListGrantRoles(this._config, request);
|
|
203
|
-
return { hash, result };
|
|
204
|
-
}
|
|
205
|
-
|
|
206
206
|
/**
|
|
207
207
|
* @inheritdoc
|
|
208
208
|
*
|
|
@@ -239,3 +239,24 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Given a {@link SimpleAllowListPayload}, properly encode the initialization payload.
|
|
245
|
+
*
|
|
246
|
+
* @param {SimpleAllowListPayload} param0
|
|
247
|
+
* @param {Address} param0.owner - The allow list's owner, given the {@link LIST_MANAGER_ROLE} role.
|
|
248
|
+
* @param {Address[]} param0.allowed - List of allowed addresses.
|
|
249
|
+
* @returns {Hex}
|
|
250
|
+
*/
|
|
251
|
+
export function prepareSimpleAllowListPayload({
|
|
252
|
+
owner,
|
|
253
|
+
allowed,
|
|
254
|
+
}: SimpleAllowListPayload) {
|
|
255
|
+
return encodeAbiParameters(
|
|
256
|
+
[
|
|
257
|
+
{ type: 'address', name: 'owner' },
|
|
258
|
+
{ type: 'address[]', name: 'allowed' },
|
|
259
|
+
],
|
|
260
|
+
[owner, allowed],
|
|
261
|
+
);
|
|
262
|
+
}
|
|
@@ -5,20 +5,20 @@ import {
|
|
|
5
5
|
type Fixtures,
|
|
6
6
|
defaultOptions,
|
|
7
7
|
deployFixtures,
|
|
8
|
-
} from '
|
|
8
|
+
} from '@boostxyz/test/helpers';
|
|
9
9
|
import { SimpleDenyList } from './SimpleDenyList';
|
|
10
10
|
|
|
11
11
|
let fixtures: Fixtures;
|
|
12
12
|
|
|
13
13
|
beforeAll(async () => {
|
|
14
|
-
fixtures = await loadFixture(deployFixtures);
|
|
14
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
function freshDenyList(fixtures: Fixtures) {
|
|
18
18
|
return function freshDenyList() {
|
|
19
|
-
return fixtures.registry.
|
|
19
|
+
return fixtures.registry.initialize(
|
|
20
20
|
crypto.randomUUID(),
|
|
21
|
-
|
|
21
|
+
fixtures.core.SimpleDenyList({
|
|
22
22
|
owner: defaultOptions.account.address,
|
|
23
23
|
denied: [defaultOptions.account.address],
|
|
24
24
|
}),
|