@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
|
@@ -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,11 +11,14 @@ 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,
|
|
16
18
|
isAddress,
|
|
19
|
+
zeroAddress,
|
|
17
20
|
} from 'viem';
|
|
21
|
+
import { BoostRegistry as BoostRegistryBases } from '../dist/deployments.json';
|
|
18
22
|
import {
|
|
19
23
|
Deployable,
|
|
20
24
|
type DeployableOptions,
|
|
@@ -25,20 +29,37 @@ import {
|
|
|
25
29
|
type GenericLog,
|
|
26
30
|
type HashAndSimulatedResult,
|
|
27
31
|
type ReadParams,
|
|
28
|
-
RegistryType,
|
|
32
|
+
type RegistryType,
|
|
29
33
|
type WriteParams,
|
|
34
|
+
assertValidAddressByChainId,
|
|
30
35
|
} from './utils';
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The ABI of the BoostRegistry contract, if needed for low level operations
|
|
39
|
+
*
|
|
40
|
+
* @type {typeof boostRegistryAbi}
|
|
41
|
+
*/
|
|
42
|
+
export { boostRegistryAbi };
|
|
33
43
|
|
|
34
44
|
/**
|
|
35
|
-
* The
|
|
36
|
-
* By default, `new BoostRegistry` will use this address if not otherwise provided.
|
|
45
|
+
* The address of the deployed `BoostRegistry` instance. In prerelease mode, this will be its sepolia address
|
|
37
46
|
*
|
|
38
47
|
* @type {Address}
|
|
39
48
|
*/
|
|
40
|
-
export const BOOST_REGISTRY_ADDRESS
|
|
41
|
-
|
|
49
|
+
export const BOOST_REGISTRY_ADDRESS =
|
|
50
|
+
(BoostRegistryBases as Record<string, Address>)[__DEFAULT_CHAIN_ID__] ||
|
|
51
|
+
zeroAddress;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The fixed addresses for the deployed Boost Registry.
|
|
55
|
+
* By default, `new BoostRegistry` will use the address deployed to the currently connected chain, or `BOOST_REGISTRY_ADDRESS` if not provided.
|
|
56
|
+
*
|
|
57
|
+
* @type {Record<number, Address>}
|
|
58
|
+
*/
|
|
59
|
+
export const BOOST_REGISTRY_ADDRESSES: Record<number, Address> = {
|
|
60
|
+
...(BoostRegistryBases as Record<number, Address>),
|
|
61
|
+
31337: import.meta.env.VITE_BOOST_REGISTRY_ADDRESS,
|
|
62
|
+
};
|
|
42
63
|
|
|
43
64
|
/**
|
|
44
65
|
* A record of `BoostRegistry` event names to `AbiEvent` objects for use with `getLogs`
|
|
@@ -55,6 +76,24 @@ export type BoostRegistryLog<
|
|
|
55
76
|
>,
|
|
56
77
|
> = GenericLog<typeof boostRegistryAbi, event>;
|
|
57
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
|
+
|
|
58
97
|
/**
|
|
59
98
|
* Instantiation options for a previously deployed Boost Registry
|
|
60
99
|
*
|
|
@@ -151,6 +190,26 @@ export class BoostRegistry extends Deployable<
|
|
|
151
190
|
never[],
|
|
152
191
|
typeof boostRegistryAbi
|
|
153
192
|
> {
|
|
193
|
+
/**
|
|
194
|
+
* A static property representing a map of stringified chain ID's to the address of the deployed implementation on chain
|
|
195
|
+
*
|
|
196
|
+
* @static
|
|
197
|
+
* @readonly
|
|
198
|
+
* @type {Record<string, Address>}
|
|
199
|
+
*/
|
|
200
|
+
static readonly addresses: Record<number, Address> = BOOST_REGISTRY_ADDRESSES;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* A getter that will return Boost registry's static addresses by numerical chain ID
|
|
204
|
+
*
|
|
205
|
+
* @public
|
|
206
|
+
* @readonly
|
|
207
|
+
* @type {Record<number, Address>}
|
|
208
|
+
*/
|
|
209
|
+
public get addresses(): Record<number, Address> {
|
|
210
|
+
return (this.constructor as typeof BoostRegistry).addresses;
|
|
211
|
+
}
|
|
212
|
+
|
|
154
213
|
/**
|
|
155
214
|
* Creates an instance of BoostRegistry.
|
|
156
215
|
*
|
|
@@ -167,7 +226,11 @@ export class BoostRegistry extends Deployable<
|
|
|
167
226
|
} else if (isBoostRegistryDeployable(options)) {
|
|
168
227
|
super({ account, config }, []);
|
|
169
228
|
} else {
|
|
170
|
-
|
|
229
|
+
const { address } = assertValidAddressByChainId(
|
|
230
|
+
config,
|
|
231
|
+
BOOST_REGISTRY_ADDRESSES,
|
|
232
|
+
);
|
|
233
|
+
super({ account, config }, address);
|
|
171
234
|
}
|
|
172
235
|
}
|
|
173
236
|
|
|
@@ -179,8 +242,8 @@ export class BoostRegistry extends Deployable<
|
|
|
179
242
|
* @param {RegistryType} registryType - The base type for the implementation
|
|
180
243
|
* @param {string} name - A name for the implementation (must be unique within the given type)
|
|
181
244
|
* @param {Address} implementation - The address of the implementation contract
|
|
182
|
-
* @param {?WriteParams
|
|
183
|
-
* @returns {
|
|
245
|
+
* @param {?WriteParams} [params] - Optional params to provide the underlying Viem contract call
|
|
246
|
+
* @returns {Promise<void>}
|
|
184
247
|
* @example
|
|
185
248
|
* ```ts
|
|
186
249
|
* await registry.register(ContractAction.registryType, 'ContractAction', ContractAction.base)
|
|
@@ -192,7 +255,7 @@ export class BoostRegistry extends Deployable<
|
|
|
192
255
|
implementation: Address,
|
|
193
256
|
params?: WriteParams<typeof boostRegistryAbi, 'register'>,
|
|
194
257
|
) {
|
|
195
|
-
return this.awaitResult(
|
|
258
|
+
return await this.awaitResult(
|
|
196
259
|
this.registerRaw(registryType, name, implementation, params),
|
|
197
260
|
);
|
|
198
261
|
}
|
|
@@ -204,8 +267,8 @@ export class BoostRegistry extends Deployable<
|
|
|
204
267
|
* @param {RegistryType} registryType
|
|
205
268
|
* @param {string} name
|
|
206
269
|
* @param {Address} implementation
|
|
207
|
-
* @param {?WriteParams
|
|
208
|
-
* @returns {
|
|
270
|
+
* @param {?WriteParams} [params]
|
|
271
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
209
272
|
*/
|
|
210
273
|
public async registerRaw(
|
|
211
274
|
registryType: RegistryType,
|
|
@@ -216,7 +279,11 @@ export class BoostRegistry extends Deployable<
|
|
|
216
279
|
const { request, result } = await simulateBoostRegistryRegister(
|
|
217
280
|
this._config,
|
|
218
281
|
{
|
|
219
|
-
|
|
282
|
+
...assertValidAddressByChainId(
|
|
283
|
+
this._config,
|
|
284
|
+
this.addresses,
|
|
285
|
+
params?.chain?.id || params?.chainId,
|
|
286
|
+
),
|
|
220
287
|
args: [registryType, name, implementation],
|
|
221
288
|
...this.optionallyAttachAccount(),
|
|
222
289
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -236,11 +303,11 @@ export class BoostRegistry extends Deployable<
|
|
|
236
303
|
* @template {DeployableTarget} Target
|
|
237
304
|
* @param {string} displayName - The display name for the clone
|
|
238
305
|
* @param {Target} target - An instance of a target contract to clone and initialize
|
|
239
|
-
* @param {?WriteParams
|
|
240
|
-
* @returns {Target} - The provided instance, but with a new address attached.
|
|
306
|
+
* @param {?WriteParams} [params]
|
|
307
|
+
* @returns {Promise<Target>} - The provided instance, but with a new address attached.
|
|
241
308
|
* biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
|
|
242
309
|
*/
|
|
243
|
-
public
|
|
310
|
+
public initialize<Target extends DeployableTarget<any, any>>(
|
|
244
311
|
displayName: string,
|
|
245
312
|
target: Target,
|
|
246
313
|
params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
|
|
@@ -248,6 +315,31 @@ export class BoostRegistry extends Deployable<
|
|
|
248
315
|
return this.clone(displayName, target, params);
|
|
249
316
|
}
|
|
250
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
|
+
|
|
251
343
|
/**
|
|
252
344
|
* Deploy a new instance of a registered base implementation, returning the provided target with a new address set on it.
|
|
253
345
|
*
|
|
@@ -256,8 +348,8 @@ export class BoostRegistry extends Deployable<
|
|
|
256
348
|
* @template {DeployableTarget} Target
|
|
257
349
|
* @param {string} displayName - The display name for the clone
|
|
258
350
|
* @param {Target} target - An instance of a target contract to clone and initialize
|
|
259
|
-
* @param {?WriteParams
|
|
260
|
-
* @returns {Target} - The provided instance, but with a new address attached.
|
|
351
|
+
* @param {?WriteParams} [params]
|
|
352
|
+
* @returns {Promise<Target>} - The provided instance, but with a new address attached.
|
|
261
353
|
* biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
|
|
262
354
|
*/
|
|
263
355
|
public async clone<Target extends DeployableTarget<any, any>>(
|
|
@@ -277,8 +369,8 @@ export class BoostRegistry extends Deployable<
|
|
|
277
369
|
* @template {DeployableTarget} Target
|
|
278
370
|
* @param {string} displayName
|
|
279
371
|
* @param {Target} target
|
|
280
|
-
* @param {?WriteParams
|
|
281
|
-
* @returns {
|
|
372
|
+
* @param {?WriteParams} [params]
|
|
373
|
+
* @returns {Promise<Address>}
|
|
282
374
|
* biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
|
|
283
375
|
*/
|
|
284
376
|
public async deployClone<Target extends DeployableTarget<any, any>>(
|
|
@@ -286,7 +378,9 @@ export class BoostRegistry extends Deployable<
|
|
|
286
378
|
target: Target,
|
|
287
379
|
params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
|
|
288
380
|
): Promise<Address> {
|
|
289
|
-
return this.awaitResult(
|
|
381
|
+
return await this.awaitResult(
|
|
382
|
+
this.deployCloneRaw(displayName, target, params),
|
|
383
|
+
);
|
|
290
384
|
}
|
|
291
385
|
|
|
292
386
|
/**
|
|
@@ -295,8 +389,8 @@ export class BoostRegistry extends Deployable<
|
|
|
295
389
|
* @async
|
|
296
390
|
* @param {string} displayName
|
|
297
391
|
* @param {DeployableTarget} target
|
|
298
|
-
* @param {?WriteParams
|
|
299
|
-
* @returns {
|
|
392
|
+
* @param {?WriteParams} [params]
|
|
393
|
+
* @returns {Promise<{ hash: Hex, result: Address }>} - The transaction hash
|
|
300
394
|
* biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
|
|
301
395
|
*/
|
|
302
396
|
public async deployCloneRaw<Target extends DeployableTarget<any, any>>(
|
|
@@ -308,16 +402,20 @@ export class BoostRegistry extends Deployable<
|
|
|
308
402
|
config: this._config,
|
|
309
403
|
account: this._account,
|
|
310
404
|
});
|
|
405
|
+
const { address: baseAddress } = assertValidAddressByChainId(
|
|
406
|
+
this._config,
|
|
407
|
+
target.bases,
|
|
408
|
+
params?.chain?.id || params?.chainId,
|
|
409
|
+
);
|
|
311
410
|
const { request, result } = await simulateBoostRegistryDeployClone(
|
|
312
411
|
this._config,
|
|
313
412
|
{
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
],
|
|
413
|
+
...assertValidAddressByChainId(
|
|
414
|
+
this._config,
|
|
415
|
+
this.addresses,
|
|
416
|
+
params?.chain?.id || params?.chainId,
|
|
417
|
+
),
|
|
418
|
+
args: [target.registryType, baseAddress, displayName, payload.args[0]],
|
|
321
419
|
...this.optionallyAttachAccount(),
|
|
322
420
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
323
421
|
...(params as any),
|
|
@@ -334,15 +432,19 @@ export class BoostRegistry extends Deployable<
|
|
|
334
432
|
* @public
|
|
335
433
|
* @async
|
|
336
434
|
* @param {Hex} identifier - The unique identifier for the implementation (see {getIdentifier})
|
|
337
|
-
* @param {?ReadParams
|
|
338
|
-
* @returns {
|
|
435
|
+
* @param {?ReadParams} [params]
|
|
436
|
+
* @returns {Promise<Address>} - The address of the implementation
|
|
339
437
|
*/
|
|
340
438
|
public async getBaseImplementation(
|
|
341
439
|
identifier: Hex,
|
|
342
440
|
params?: ReadParams<typeof boostRegistryAbi, 'getBaseImplementation'>,
|
|
343
441
|
) {
|
|
344
|
-
return readBoostRegistryGetBaseImplementation(this._config, {
|
|
345
|
-
|
|
442
|
+
return await readBoostRegistryGetBaseImplementation(this._config, {
|
|
443
|
+
...assertValidAddressByChainId(
|
|
444
|
+
this._config,
|
|
445
|
+
this.addresses,
|
|
446
|
+
params?.chainId,
|
|
447
|
+
),
|
|
346
448
|
args: [identifier],
|
|
347
449
|
...this.optionallyAttachAccount(),
|
|
348
450
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -351,20 +453,24 @@ export class BoostRegistry extends Deployable<
|
|
|
351
453
|
}
|
|
352
454
|
|
|
353
455
|
/**
|
|
354
|
-
* Get the address of a deployed clone by its identifier
|
|
456
|
+
* Get the address of a deployed clone by its identifier
|
|
355
457
|
*
|
|
356
458
|
* @public
|
|
357
459
|
* @async
|
|
358
460
|
* @param {Hex} identifier - The unique identifier for the deployed clone (see {getCloneIdentifier})
|
|
359
|
-
* @param {?ReadParams
|
|
360
|
-
* @returns {Promise<
|
|
461
|
+
* @param {?ReadParams} [params]
|
|
462
|
+
* @returns {Promise<Clone>} - The on-chain representation of the clone
|
|
361
463
|
*/
|
|
362
464
|
public async getClone(
|
|
363
465
|
identifier: Hex,
|
|
364
466
|
params?: ReadParams<typeof boostRegistryAbi, 'getClone'>,
|
|
365
|
-
) {
|
|
366
|
-
return
|
|
367
|
-
|
|
467
|
+
): Promise<Clone> {
|
|
468
|
+
return await readBoostRegistryGetClone(this._config, {
|
|
469
|
+
...assertValidAddressByChainId(
|
|
470
|
+
this._config,
|
|
471
|
+
this.addresses,
|
|
472
|
+
params?.chainId,
|
|
473
|
+
),
|
|
368
474
|
args: [identifier],
|
|
369
475
|
...this.optionallyAttachAccount(),
|
|
370
476
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -378,15 +484,19 @@ export class BoostRegistry extends Deployable<
|
|
|
378
484
|
* @public
|
|
379
485
|
* @async
|
|
380
486
|
* @param {Address} deployer - The address of the deployer
|
|
381
|
-
* @param {?ReadParams
|
|
382
|
-
* @returns {Promise<
|
|
487
|
+
* @param {?ReadParams} [params]
|
|
488
|
+
* @returns {Promise<Hex[]>} - The list of deployed clones for the given deployer
|
|
383
489
|
*/
|
|
384
490
|
public async getClones(
|
|
385
491
|
deployer: Address,
|
|
386
492
|
params?: ReadParams<typeof boostRegistryAbi, 'getClones'>,
|
|
387
493
|
) {
|
|
388
|
-
return readBoostRegistryGetClones(this._config, {
|
|
389
|
-
|
|
494
|
+
return await readBoostRegistryGetClones(this._config, {
|
|
495
|
+
...assertValidAddressByChainId(
|
|
496
|
+
this._config,
|
|
497
|
+
this.addresses,
|
|
498
|
+
params?.chainId,
|
|
499
|
+
),
|
|
390
500
|
args: [deployer],
|
|
391
501
|
...this.optionallyAttachAccount(),
|
|
392
502
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -403,7 +513,7 @@ export class BoostRegistry extends Deployable<
|
|
|
403
513
|
* @param {Address} base - The address of the base implementation
|
|
404
514
|
* @param {Address} deployer - The address of the deployer
|
|
405
515
|
* @param {string} displayName - The display name of the clone
|
|
406
|
-
* @param {?ReadParams
|
|
516
|
+
* @param {?ReadParams} [params]
|
|
407
517
|
* @returns {Promise<Hex>} - The unique identifier for the clone
|
|
408
518
|
*/
|
|
409
519
|
public async getCloneIdentifier(
|
|
@@ -413,8 +523,12 @@ export class BoostRegistry extends Deployable<
|
|
|
413
523
|
displayName: string,
|
|
414
524
|
params?: ReadParams<typeof boostRegistryAbi, 'getCloneIdentifier'>,
|
|
415
525
|
) {
|
|
416
|
-
return readBoostRegistryGetCloneIdentifier(this._config, {
|
|
417
|
-
|
|
526
|
+
return await readBoostRegistryGetCloneIdentifier(this._config, {
|
|
527
|
+
...assertValidAddressByChainId(
|
|
528
|
+
this._config,
|
|
529
|
+
this.addresses,
|
|
530
|
+
params?.chainId,
|
|
531
|
+
),
|
|
418
532
|
args: [registryType, base, deployer, displayName],
|
|
419
533
|
...this.optionallyAttachAccount(),
|
|
420
534
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -429,7 +543,7 @@ export class BoostRegistry extends Deployable<
|
|
|
429
543
|
* @async
|
|
430
544
|
* @param {RegistryType} registryType - The base type for the implementation
|
|
431
545
|
* @param {string} displayName - The name of the implementation
|
|
432
|
-
* @param {?ReadParams
|
|
546
|
+
* @param {?ReadParams} [params]
|
|
433
547
|
* @returns {Promise<Hex>} - The unique identifier for the implementation
|
|
434
548
|
*/
|
|
435
549
|
public async getIdentifier(
|
|
@@ -437,8 +551,12 @@ export class BoostRegistry extends Deployable<
|
|
|
437
551
|
displayName: string,
|
|
438
552
|
params?: ReadParams<typeof boostRegistryAbi, 'getIdentifier'>,
|
|
439
553
|
) {
|
|
440
|
-
return readBoostRegistryGetCloneIdentifier(this._config, {
|
|
441
|
-
|
|
554
|
+
return await readBoostRegistryGetCloneIdentifier(this._config, {
|
|
555
|
+
...assertValidAddressByChainId(
|
|
556
|
+
this._config,
|
|
557
|
+
this.addresses,
|
|
558
|
+
params?.chainId,
|
|
559
|
+
),
|
|
442
560
|
args: [registryType, displayName],
|
|
443
561
|
...this.optionallyAttachAccount(),
|
|
444
562
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
defaultOptions,
|
|
6
6
|
deployFixtures,
|
|
7
7
|
freshManagedBudget,
|
|
8
|
-
} from '
|
|
8
|
+
} from '@boostxyz/test/helpers';
|
|
9
9
|
import { budgetFromAddress } from './Budget';
|
|
10
10
|
import { ManagedBudget } from './ManagedBudget';
|
|
11
11
|
|
|
12
12
|
let fixtures: Fixtures;
|
|
13
13
|
|
|
14
14
|
beforeAll(async () => {
|
|
15
|
-
fixtures = await loadFixture(deployFixtures);
|
|
15
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
describe('Budget', () => {
|
package/src/Budgets/Budget.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { InvalidComponentInterfaceError } from '../errors';
|
|
|
7
7
|
import { ManagedBudget } from './ManagedBudget';
|
|
8
8
|
|
|
9
9
|
export {
|
|
10
|
-
// SimpleBudget,
|
|
11
10
|
// VestingBudget,
|
|
12
11
|
ManagedBudget,
|
|
13
12
|
};
|
|
@@ -18,7 +17,7 @@ export {
|
|
|
18
17
|
* @export
|
|
19
18
|
* @typedef {Budget}
|
|
20
19
|
*/
|
|
21
|
-
export type Budget = ManagedBudget; // |
|
|
20
|
+
export type Budget = ManagedBudget; // | VestingBudget
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* A map of Budget component interfaces to their constructors.
|
|
@@ -2,8 +2,9 @@ import { writeMockErc1155SetApprovalForAll } from '@boostxyz/evm';
|
|
|
2
2
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
3
3
|
import { isAddress, parseEther, zeroAddress } from 'viem';
|
|
4
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
5
|
-
import type { MockERC20 } from '
|
|
6
|
-
import type { MockERC1155 } from '
|
|
5
|
+
import type { MockERC20 } from '@boostxyz/test/MockERC20';
|
|
6
|
+
import type { MockERC1155 } from '@boostxyz/test/MockERC1155';
|
|
7
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
7
8
|
import {
|
|
8
9
|
type Fixtures,
|
|
9
10
|
defaultOptions,
|
|
@@ -13,9 +14,9 @@ import {
|
|
|
13
14
|
fundErc20,
|
|
14
15
|
fundErc1155,
|
|
15
16
|
fundManagedBudget,
|
|
16
|
-
} from '
|
|
17
|
-
import { testAccount } from '
|
|
18
|
-
import { ManagedBudget } from './ManagedBudget';
|
|
17
|
+
} from '@boostxyz/test/helpers';
|
|
18
|
+
import { testAccount } from '@boostxyz/test/viem';
|
|
19
|
+
import { ManagedBudget, ManagedBudgetRoles } from './ManagedBudget';
|
|
19
20
|
|
|
20
21
|
let fixtures: Fixtures,
|
|
21
22
|
budget: ManagedBudget,
|
|
@@ -23,7 +24,7 @@ let fixtures: Fixtures,
|
|
|
23
24
|
erc1155: MockERC1155;
|
|
24
25
|
|
|
25
26
|
beforeAll(async () => {
|
|
26
|
-
fixtures = await loadFixture(deployFixtures);
|
|
27
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
describe('ManagedBudget', () => {
|
|
@@ -37,13 +38,73 @@ describe('ManagedBudget', () => {
|
|
|
37
38
|
expect(isAddress(action.assertValidAddress())).toBe(true);
|
|
38
39
|
});
|
|
39
40
|
|
|
41
|
+
test('can grant manager role to many users', async () => {
|
|
42
|
+
const budget = await loadFixture(
|
|
43
|
+
freshManagedBudget(defaultOptions, fixtures),
|
|
44
|
+
);
|
|
45
|
+
const one = accounts[1].account;
|
|
46
|
+
const two = accounts[2].account;
|
|
47
|
+
await budget.setAuthorized([one, two], [true, true]);
|
|
48
|
+
expect(await budget.hasAllRoles(one, ManagedBudgetRoles.ADMIN)).toBe(false);
|
|
49
|
+
expect(await budget.hasAllRoles(one, ManagedBudgetRoles.MANAGER)).toBe(
|
|
50
|
+
true,
|
|
51
|
+
);
|
|
52
|
+
expect(await budget.hasAllRoles(two, ManagedBudgetRoles.MANAGER)).toBe(
|
|
53
|
+
true,
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('can grant roles', async () => {
|
|
58
|
+
const budget = await loadFixture(
|
|
59
|
+
freshManagedBudget(defaultOptions, fixtures),
|
|
60
|
+
);
|
|
61
|
+
const admin = accounts[1].account;
|
|
62
|
+
const manager = accounts[2].account;
|
|
63
|
+
await budget.grantRoles(
|
|
64
|
+
[admin, manager],
|
|
65
|
+
[ManagedBudgetRoles.ADMIN, ManagedBudgetRoles.MANAGER],
|
|
66
|
+
);
|
|
67
|
+
expect(await budget.hasAllRoles(admin, ManagedBudgetRoles.ADMIN)).toBe(
|
|
68
|
+
true,
|
|
69
|
+
);
|
|
70
|
+
expect(await budget.hasAllRoles(manager, ManagedBudgetRoles.MANAGER)).toBe(
|
|
71
|
+
true,
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('can revoke roles', async () => {
|
|
76
|
+
const budget = await loadFixture(
|
|
77
|
+
freshManagedBudget(defaultOptions, fixtures),
|
|
78
|
+
);
|
|
79
|
+
const admin = accounts[1].account;
|
|
80
|
+
const manager = accounts[2].account;
|
|
81
|
+
await budget.grantRoles(
|
|
82
|
+
[admin, manager],
|
|
83
|
+
[ManagedBudgetRoles.ADMIN, ManagedBudgetRoles.MANAGER],
|
|
84
|
+
);
|
|
85
|
+
await budget.revokeRoles(
|
|
86
|
+
[admin, manager],
|
|
87
|
+
[ManagedBudgetRoles.ADMIN, ManagedBudgetRoles.MANAGER],
|
|
88
|
+
);
|
|
89
|
+
expect(await budget.hasAllRoles(admin, ManagedBudgetRoles.ADMIN)).toBe(
|
|
90
|
+
false,
|
|
91
|
+
);
|
|
92
|
+
expect(await budget.hasAllRoles(manager, ManagedBudgetRoles.MANAGER)).toBe(
|
|
93
|
+
false,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
40
97
|
test('can be owned', async () => {
|
|
41
|
-
const budget = await loadFixture(
|
|
98
|
+
const budget = await loadFixture(
|
|
99
|
+
freshManagedBudget(defaultOptions, fixtures),
|
|
100
|
+
);
|
|
42
101
|
expect(await budget.owner()).toBe(defaultOptions.account.address);
|
|
43
102
|
});
|
|
44
103
|
|
|
45
104
|
test('can have authorized users', async () => {
|
|
46
|
-
const budget = await loadFixture(
|
|
105
|
+
const budget = await loadFixture(
|
|
106
|
+
freshManagedBudget(defaultOptions, fixtures),
|
|
107
|
+
);
|
|
47
108
|
expect(await budget.isAuthorized(defaultOptions.account.address)).toBe(
|
|
48
109
|
true,
|
|
49
110
|
);
|
|
@@ -51,8 +112,10 @@ describe('ManagedBudget', () => {
|
|
|
51
112
|
});
|
|
52
113
|
|
|
53
114
|
test('can have no initial balance', async () => {
|
|
54
|
-
const budget = await loadFixture(
|
|
55
|
-
|
|
115
|
+
const budget = await loadFixture(
|
|
116
|
+
freshManagedBudget(defaultOptions, fixtures),
|
|
117
|
+
);
|
|
118
|
+
expect(await budget.available()).toBe(0n);
|
|
56
119
|
});
|
|
57
120
|
|
|
58
121
|
describe('can allocate', () => {
|
|
@@ -73,18 +136,18 @@ describe('ManagedBudget', () => {
|
|
|
73
136
|
value: parseEther('1.0'),
|
|
74
137
|
},
|
|
75
138
|
);
|
|
76
|
-
expect(await budget.available(
|
|
139
|
+
expect(await budget.available()).toBe(parseEther('1.0'));
|
|
77
140
|
});
|
|
78
141
|
|
|
79
142
|
test('erc20', async () => {
|
|
80
|
-
await erc20.approve(budget.assertValidAddress(), parseEther('
|
|
143
|
+
await erc20.approve(budget.assertValidAddress(), parseEther('110'));
|
|
81
144
|
await budget.allocate({
|
|
82
|
-
amount: parseEther('
|
|
145
|
+
amount: parseEther('110'),
|
|
83
146
|
asset: erc20.assertValidAddress(),
|
|
84
147
|
target: defaultOptions.account.address,
|
|
85
148
|
});
|
|
86
149
|
expect(await budget.available(erc20.assertValidAddress())).toBe(
|
|
87
|
-
parseEther('
|
|
150
|
+
parseEther('110'),
|
|
88
151
|
);
|
|
89
152
|
});
|
|
90
153
|
|
|
@@ -96,12 +159,12 @@ describe('ManagedBudget', () => {
|
|
|
96
159
|
});
|
|
97
160
|
await budget.allocate({
|
|
98
161
|
tokenId: 1n,
|
|
99
|
-
amount:
|
|
162
|
+
amount: 110n,
|
|
100
163
|
asset: erc1155.assertValidAddress(),
|
|
101
164
|
target: defaultOptions.account.address,
|
|
102
165
|
});
|
|
103
166
|
expect(await budget.available(erc1155.assertValidAddress(), 1n)).toBe(
|
|
104
|
-
|
|
167
|
+
110n,
|
|
105
168
|
);
|
|
106
169
|
});
|
|
107
170
|
});
|
|
@@ -123,7 +186,7 @@ describe('ManagedBudget', () => {
|
|
|
123
186
|
target: defaultOptions.account.address,
|
|
124
187
|
});
|
|
125
188
|
|
|
126
|
-
expect(await budget.available(
|
|
189
|
+
expect(await budget.available()).toBe(0n);
|
|
127
190
|
});
|
|
128
191
|
|
|
129
192
|
test('erc20 assets', async () => {
|
|
@@ -134,7 +197,7 @@ describe('ManagedBudget', () => {
|
|
|
134
197
|
});
|
|
135
198
|
|
|
136
199
|
expect(await budget.available(erc20.assertValidAddress())).toBe(
|
|
137
|
-
parseEther('
|
|
200
|
+
parseEther('100'),
|
|
138
201
|
);
|
|
139
202
|
});
|
|
140
203
|
|
|
@@ -147,7 +210,7 @@ describe('ManagedBudget', () => {
|
|
|
147
210
|
});
|
|
148
211
|
|
|
149
212
|
expect(await budget.available(erc1155.assertValidAddress(), 1n)).to.equal(
|
|
150
|
-
|
|
213
|
+
105n,
|
|
151
214
|
);
|
|
152
215
|
});
|
|
153
216
|
});
|