@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
|
@@ -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,35 +11,55 @@ 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,
|
|
21
25
|
type GenericDeployableParams,
|
|
22
26
|
} from './Deployable/Deployable';
|
|
23
27
|
import type { DeployableTarget } from './Deployable/DeployableTarget';
|
|
24
|
-
import
|
|
25
|
-
GenericLog,
|
|
26
|
-
HashAndSimulatedResult,
|
|
27
|
-
ReadParams,
|
|
28
|
-
RegistryType,
|
|
29
|
-
WriteParams,
|
|
28
|
+
import {
|
|
29
|
+
type GenericLog,
|
|
30
|
+
type HashAndSimulatedResult,
|
|
31
|
+
type ReadParams,
|
|
32
|
+
type RegistryType,
|
|
33
|
+
type WriteParams,
|
|
34
|
+
assertValidAddressByChainId,
|
|
30
35
|
} from './utils';
|
|
31
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The ABI of the BoostRegistry contract, if needed for low level operations
|
|
39
|
+
*
|
|
40
|
+
* @type {typeof boostRegistryAbi}
|
|
41
|
+
*/
|
|
32
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)
|
|
@@ -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,8 +303,8 @@ 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
310
|
public initialize<Target extends DeployableTarget<any, any>>(
|
|
@@ -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>>(
|
|
@@ -297,8 +389,8 @@ export class BoostRegistry extends Deployable<
|
|
|
297
389
|
* @async
|
|
298
390
|
* @param {string} displayName
|
|
299
391
|
* @param {DeployableTarget} target
|
|
300
|
-
* @param {?WriteParams
|
|
301
|
-
* @returns {
|
|
392
|
+
* @param {?WriteParams} [params]
|
|
393
|
+
* @returns {Promise<{ hash: Hex, result: Address }>} - The transaction hash
|
|
302
394
|
* biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
|
|
303
395
|
*/
|
|
304
396
|
public async deployCloneRaw<Target extends DeployableTarget<any, any>>(
|
|
@@ -310,11 +402,20 @@ export class BoostRegistry extends Deployable<
|
|
|
310
402
|
config: this._config,
|
|
311
403
|
account: this._account,
|
|
312
404
|
});
|
|
405
|
+
const { address: baseAddress } = assertValidAddressByChainId(
|
|
406
|
+
this._config,
|
|
407
|
+
target.bases,
|
|
408
|
+
params?.chain?.id || params?.chainId,
|
|
409
|
+
);
|
|
313
410
|
const { request, result } = await simulateBoostRegistryDeployClone(
|
|
314
411
|
this._config,
|
|
315
412
|
{
|
|
316
|
-
|
|
317
|
-
|
|
413
|
+
...assertValidAddressByChainId(
|
|
414
|
+
this._config,
|
|
415
|
+
this.addresses,
|
|
416
|
+
params?.chain?.id || params?.chainId,
|
|
417
|
+
),
|
|
418
|
+
args: [target.registryType, baseAddress, displayName, payload.args[0]],
|
|
318
419
|
...this.optionallyAttachAccount(),
|
|
319
420
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
320
421
|
...(params as any),
|
|
@@ -331,15 +432,19 @@ export class BoostRegistry extends Deployable<
|
|
|
331
432
|
* @public
|
|
332
433
|
* @async
|
|
333
434
|
* @param {Hex} identifier - The unique identifier for the implementation (see {getIdentifier})
|
|
334
|
-
* @param {?ReadParams
|
|
335
|
-
* @returns {
|
|
435
|
+
* @param {?ReadParams} [params]
|
|
436
|
+
* @returns {Promise<Address>} - The address of the implementation
|
|
336
437
|
*/
|
|
337
438
|
public async getBaseImplementation(
|
|
338
439
|
identifier: Hex,
|
|
339
440
|
params?: ReadParams<typeof boostRegistryAbi, 'getBaseImplementation'>,
|
|
340
441
|
) {
|
|
341
442
|
return await readBoostRegistryGetBaseImplementation(this._config, {
|
|
342
|
-
|
|
443
|
+
...assertValidAddressByChainId(
|
|
444
|
+
this._config,
|
|
445
|
+
this.addresses,
|
|
446
|
+
params?.chainId,
|
|
447
|
+
),
|
|
343
448
|
args: [identifier],
|
|
344
449
|
...this.optionallyAttachAccount(),
|
|
345
450
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -353,15 +458,19 @@ export class BoostRegistry extends Deployable<
|
|
|
353
458
|
* @public
|
|
354
459
|
* @async
|
|
355
460
|
* @param {Hex} identifier - The unique identifier for the deployed clone (see {getCloneIdentifier})
|
|
356
|
-
* @param {?ReadParams
|
|
357
|
-
* @returns {Promise<
|
|
461
|
+
* @param {?ReadParams} [params]
|
|
462
|
+
* @returns {Promise<Clone>} - The on-chain representation of the clone
|
|
358
463
|
*/
|
|
359
464
|
public async getClone(
|
|
360
465
|
identifier: Hex,
|
|
361
466
|
params?: ReadParams<typeof boostRegistryAbi, 'getClone'>,
|
|
362
|
-
) {
|
|
363
|
-
return await
|
|
364
|
-
|
|
467
|
+
): Promise<Clone> {
|
|
468
|
+
return await readBoostRegistryGetClone(this._config, {
|
|
469
|
+
...assertValidAddressByChainId(
|
|
470
|
+
this._config,
|
|
471
|
+
this.addresses,
|
|
472
|
+
params?.chainId,
|
|
473
|
+
),
|
|
365
474
|
args: [identifier],
|
|
366
475
|
...this.optionallyAttachAccount(),
|
|
367
476
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -375,7 +484,7 @@ export class BoostRegistry extends Deployable<
|
|
|
375
484
|
* @public
|
|
376
485
|
* @async
|
|
377
486
|
* @param {Address} deployer - The address of the deployer
|
|
378
|
-
* @param {?ReadParams
|
|
487
|
+
* @param {?ReadParams} [params]
|
|
379
488
|
* @returns {Promise<Hex[]>} - The list of deployed clones for the given deployer
|
|
380
489
|
*/
|
|
381
490
|
public async getClones(
|
|
@@ -383,7 +492,11 @@ export class BoostRegistry extends Deployable<
|
|
|
383
492
|
params?: ReadParams<typeof boostRegistryAbi, 'getClones'>,
|
|
384
493
|
) {
|
|
385
494
|
return await readBoostRegistryGetClones(this._config, {
|
|
386
|
-
|
|
495
|
+
...assertValidAddressByChainId(
|
|
496
|
+
this._config,
|
|
497
|
+
this.addresses,
|
|
498
|
+
params?.chainId,
|
|
499
|
+
),
|
|
387
500
|
args: [deployer],
|
|
388
501
|
...this.optionallyAttachAccount(),
|
|
389
502
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -400,7 +513,7 @@ export class BoostRegistry extends Deployable<
|
|
|
400
513
|
* @param {Address} base - The address of the base implementation
|
|
401
514
|
* @param {Address} deployer - The address of the deployer
|
|
402
515
|
* @param {string} displayName - The display name of the clone
|
|
403
|
-
* @param {?ReadParams
|
|
516
|
+
* @param {?ReadParams} [params]
|
|
404
517
|
* @returns {Promise<Hex>} - The unique identifier for the clone
|
|
405
518
|
*/
|
|
406
519
|
public async getCloneIdentifier(
|
|
@@ -411,7 +524,11 @@ export class BoostRegistry extends Deployable<
|
|
|
411
524
|
params?: ReadParams<typeof boostRegistryAbi, 'getCloneIdentifier'>,
|
|
412
525
|
) {
|
|
413
526
|
return await readBoostRegistryGetCloneIdentifier(this._config, {
|
|
414
|
-
|
|
527
|
+
...assertValidAddressByChainId(
|
|
528
|
+
this._config,
|
|
529
|
+
this.addresses,
|
|
530
|
+
params?.chainId,
|
|
531
|
+
),
|
|
415
532
|
args: [registryType, base, deployer, displayName],
|
|
416
533
|
...this.optionallyAttachAccount(),
|
|
417
534
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -426,7 +543,7 @@ export class BoostRegistry extends Deployable<
|
|
|
426
543
|
* @async
|
|
427
544
|
* @param {RegistryType} registryType - The base type for the implementation
|
|
428
545
|
* @param {string} displayName - The name of the implementation
|
|
429
|
-
* @param {?ReadParams
|
|
546
|
+
* @param {?ReadParams} [params]
|
|
430
547
|
* @returns {Promise<Hex>} - The unique identifier for the implementation
|
|
431
548
|
*/
|
|
432
549
|
public async getIdentifier(
|
|
@@ -435,7 +552,11 @@ export class BoostRegistry extends Deployable<
|
|
|
435
552
|
params?: ReadParams<typeof boostRegistryAbi, 'getIdentifier'>,
|
|
436
553
|
) {
|
|
437
554
|
return await readBoostRegistryGetCloneIdentifier(this._config, {
|
|
438
|
-
|
|
555
|
+
...assertValidAddressByChainId(
|
|
556
|
+
this._config,
|
|
557
|
+
this.addresses,
|
|
558
|
+
params?.chainId,
|
|
559
|
+
),
|
|
439
560
|
args: [registryType, displayName],
|
|
440
561
|
...this.optionallyAttachAccount(),
|
|
441
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
|
});
|