@boostxyz/sdk 1.1.0-alpha.22 → 1.1.0-alpha.23

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.
Files changed (150) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.cjs.map +1 -1
  3. package/dist/Actions/Action.js +6 -6
  4. package/dist/Actions/EventAction.cjs +1 -1
  5. package/dist/Actions/EventAction.cjs.map +1 -1
  6. package/dist/Actions/EventAction.d.ts +9 -6
  7. package/dist/Actions/EventAction.d.ts.map +1 -1
  8. package/dist/Actions/EventAction.js +820 -15
  9. package/dist/Actions/EventAction.js.map +1 -1
  10. package/dist/AllowLists/AllowList.cjs +1 -1
  11. package/dist/AllowLists/AllowList.js +2 -2
  12. package/dist/AllowLists/OpenAllowList.d.ts +28 -28
  13. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  14. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  15. package/dist/AllowLists/SimpleAllowList.d.ts +28 -28
  16. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  17. package/dist/AllowLists/SimpleAllowList.js +11 -10
  18. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  19. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  20. package/dist/AllowLists/SimpleDenyList.d.ts +28 -28
  21. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  22. package/dist/AllowLists/SimpleDenyList.js +3 -3
  23. package/dist/Auth/PassthroughAuth.cjs +1 -1
  24. package/dist/Auth/PassthroughAuth.js +1 -1
  25. package/dist/BoostCore-Btl5BdAs.cjs +3 -0
  26. package/dist/BoostCore-Btl5BdAs.cjs.map +1 -0
  27. package/dist/{BoostCore-BVZExPPu.js → BoostCore-CD56zbYX.js} +1678 -499
  28. package/dist/BoostCore-CD56zbYX.js.map +1 -0
  29. package/dist/BoostCore.cjs +1 -1
  30. package/dist/BoostCore.d.ts +7 -7
  31. package/dist/BoostCore.d.ts.map +1 -1
  32. package/dist/BoostCore.js +6 -6
  33. package/dist/BoostRegistry.cjs +1 -1
  34. package/dist/BoostRegistry.cjs.map +1 -1
  35. package/dist/BoostRegistry.d.ts +6 -6
  36. package/dist/BoostRegistry.d.ts.map +1 -1
  37. package/dist/BoostRegistry.js +50 -50
  38. package/dist/BoostRegistry.js.map +1 -1
  39. package/dist/Budgets/Budget.cjs +1 -1
  40. package/dist/Budgets/Budget.js +1 -1
  41. package/dist/Budgets/ManagedBudget.cjs +1 -1
  42. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  43. package/dist/Budgets/ManagedBudget.d.ts +28 -28
  44. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  45. package/dist/Budgets/ManagedBudget.js +30 -29
  46. package/dist/Budgets/ManagedBudget.js.map +1 -1
  47. package/dist/Budgets/VestingBudget.d.ts +28 -28
  48. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  49. package/dist/Deployable/DeployableTarget.cjs +1 -1
  50. package/dist/Deployable/DeployableTarget.js +1 -1
  51. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  52. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -1
  53. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +92 -23
  54. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -1
  55. package/dist/Deployable/DeployableTargetWithRBAC.js +145 -47
  56. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -1
  57. package/dist/{Incentive-BhHaK3PZ.cjs → Incentive-CcnOIc8L.cjs} +2 -2
  58. package/dist/{Incentive-BhHaK3PZ.cjs.map → Incentive-CcnOIc8L.cjs.map} +1 -1
  59. package/dist/{Incentive-Cqg1w6wD.js → Incentive-rM5nKznp.js} +30 -29
  60. package/dist/{Incentive-Cqg1w6wD.js.map → Incentive-rM5nKznp.js.map} +1 -1
  61. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  62. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  63. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  64. package/dist/Incentives/AllowListIncentive.js +11 -10
  65. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  66. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  67. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  68. package/dist/Incentives/CGDAIncentive.d.ts +28 -28
  69. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  70. package/dist/Incentives/CGDAIncentive.js +12 -11
  71. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  72. package/dist/Incentives/ERC1155Incentive.d.ts +28 -28
  73. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  74. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  75. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  76. package/dist/Incentives/ERC20Incentive.d.ts +34 -31
  77. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  78. package/dist/Incentives/ERC20Incentive.js +30 -27
  79. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  80. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +28 -28
  81. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
  82. package/dist/Incentives/ERC20VariableIncentive.d.ts +28 -28
  83. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  84. package/dist/Incentives/Incentive.cjs +1 -1
  85. package/dist/Incentives/Incentive.js +2 -2
  86. package/dist/Incentives/PointsIncentive.cjs +1 -1
  87. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  88. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  89. package/dist/Incentives/PointsIncentive.js +12 -11
  90. package/dist/Incentives/PointsIncentive.js.map +1 -1
  91. package/dist/{SimpleDenyList-CGaWjuld.js → SimpleDenyList-BDXpY74P.js} +18 -17
  92. package/dist/SimpleDenyList-BDXpY74P.js.map +1 -0
  93. package/dist/{SimpleDenyList-BUR17Tt1.cjs → SimpleDenyList-DNj5qDWM.cjs} +2 -2
  94. package/dist/SimpleDenyList-DNj5qDWM.cjs.map +1 -0
  95. package/dist/Validators/SignerValidator.cjs +1 -1
  96. package/dist/Validators/SignerValidator.cjs.map +1 -1
  97. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  98. package/dist/Validators/SignerValidator.js +13 -12
  99. package/dist/Validators/SignerValidator.js.map +1 -1
  100. package/dist/Validators/Validator.cjs +1 -1
  101. package/dist/Validators/Validator.js +1 -1
  102. package/dist/deployments-DF_6-7hH.cjs +2 -0
  103. package/dist/deployments-DF_6-7hH.cjs.map +1 -0
  104. package/dist/deployments-fJsWblwS.js +56 -0
  105. package/dist/deployments-fJsWblwS.js.map +1 -0
  106. package/dist/deployments.json +26 -12
  107. package/dist/{generated-CKt2yCQd.js → generated-CsNyWPKA.js} +458 -443
  108. package/dist/generated-CsNyWPKA.js.map +1 -0
  109. package/dist/generated-DHerxf1y.cjs +3 -0
  110. package/dist/generated-DHerxf1y.cjs.map +1 -0
  111. package/dist/index.cjs +1 -1
  112. package/dist/index.js +33 -33
  113. package/package.json +4 -4
  114. package/src/Actions/EventAction.test.ts +19 -13
  115. package/src/Actions/EventAction.ts +16 -35
  116. package/src/AllowLists/SimpleAllowList.ts +1 -0
  117. package/src/AllowLists/SimpleDenyList.ts +1 -0
  118. package/src/BoostCore.test.ts +78 -78
  119. package/src/BoostCore.ts +19 -13
  120. package/src/BoostRegistry.ts +10 -10
  121. package/src/Budgets/ManagedBudget.test.ts +41 -17
  122. package/src/Budgets/ManagedBudget.ts +1 -11
  123. package/src/Budgets/VestingBudget.ts +3 -1
  124. package/src/Deployable/DeployableTargetWithRBAC.test.ts +103 -0
  125. package/src/Deployable/DeployableTargetWithRBAC.ts +160 -36
  126. package/src/Incentives/AllowListIncentive.test.ts +7 -7
  127. package/src/Incentives/AllowListIncentive.ts +1 -0
  128. package/src/Incentives/CGDAIncentive.ts +1 -0
  129. package/src/Incentives/ERC1155Incentive.ts +3 -1
  130. package/src/Incentives/ERC20Incentive.ts +10 -3
  131. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +1 -0
  132. package/src/Incentives/ERC20VariableIncentive.ts +1 -0
  133. package/src/Incentives/PointsIncentive.ts +1 -0
  134. package/src/Validators/SignerValidator.ts +1 -0
  135. package/dist/BoostCore-BVZExPPu.js.map +0 -1
  136. package/dist/BoostCore-D-E-cnGI.cjs +0 -3
  137. package/dist/BoostCore-D-E-cnGI.cjs.map +0 -1
  138. package/dist/EventAction-BZt5cjbe.cjs +0 -2
  139. package/dist/EventAction-BZt5cjbe.cjs.map +0 -1
  140. package/dist/EventAction-C_-hJXWm.js +0 -1541
  141. package/dist/EventAction-C_-hJXWm.js.map +0 -1
  142. package/dist/SimpleDenyList-BUR17Tt1.cjs.map +0 -1
  143. package/dist/SimpleDenyList-CGaWjuld.js.map +0 -1
  144. package/dist/deployments-DVXioW2i.cjs +0 -2
  145. package/dist/deployments-DVXioW2i.cjs.map +0 -1
  146. package/dist/deployments-oykLv3_Z.js +0 -43
  147. package/dist/deployments-oykLv3_Z.js.map +0 -1
  148. package/dist/generated-CKt2yCQd.js.map +0 -1
  149. package/dist/generated-CyTNlOwM.cjs +0 -3
  150. package/dist/generated-CyTNlOwM.cjs.map +0 -1
@@ -9,14 +9,14 @@ import {
9
9
  type Fixtures,
10
10
  defaultOptions,
11
11
  deployFixtures,
12
- freshBudget,
13
12
  freshManagedBudget,
14
13
  fundErc20,
15
14
  fundErc1155,
16
15
  fundManagedBudget,
17
16
  } from '@boostxyz/test/helpers';
18
17
  import { testAccount } from '@boostxyz/test/viem';
19
- import { ManagedBudget, ManagedBudgetRoles } from './ManagedBudget';
18
+ import { ManagedBudget } from './ManagedBudget';
19
+ import { Roles } from '../Deployable/DeployableTargetWithRBAC';
20
20
 
21
21
  let fixtures: Fixtures,
22
22
  budget: ManagedBudget,
@@ -45,51 +45,75 @@ describe('ManagedBudget', () => {
45
45
  const one = accounts[1].account;
46
46
  const two = accounts[2].account;
47
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(
48
+ expect(await budget.hasAllRoles(one, Roles.ADMIN)).toBe(false);
49
+ expect(await budget.hasAllRoles(one, Roles.MANAGER)).toBe(
50
50
  true,
51
51
  );
52
- expect(await budget.hasAllRoles(two, ManagedBudgetRoles.MANAGER)).toBe(
52
+ expect(await budget.hasAllRoles(two, Roles.MANAGER)).toBe(
53
53
  true,
54
54
  );
55
55
  });
56
56
 
57
- test('can grant roles', async () => {
57
+ test('can grant role', async () => {
58
+ const budget = await loadFixture(
59
+ freshManagedBudget(defaultOptions, fixtures),
60
+ );
61
+ const manager = accounts[1].account;
62
+ await budget.grantRoles(manager, Roles.MANAGER);
63
+ expect(await budget.hasAllRoles(manager, Roles.ADMIN)).toBe(false);
64
+ expect(await budget.hasAllRoles(manager, Roles.MANAGER)).toBe(true);
65
+ });
66
+
67
+ test('can revoke role', async () => {
68
+ const budget = await loadFixture(
69
+ freshManagedBudget(defaultOptions, fixtures),
70
+ );
71
+ const manager = accounts[1].account;
72
+ await budget.grantRoles(manager, Roles.MANAGER);
73
+ await budget.grantRoles(manager, Roles.ADMIN);
74
+ await budget.revokeRoles(manager, Roles.MANAGER);
75
+ expect(await budget.hasAllRoles(manager, Roles.MANAGER)).toBe(false);
76
+ expect(await budget.hasAllRoles(manager, Roles.ADMIN)).toBe(true);
77
+ await budget.revokeRoles(manager, Roles.ADMIN);
78
+ expect(await budget.hasAllRoles(manager, Roles.ADMIN)).toBe(false);
79
+ });
80
+
81
+ test('can grant many roles', async () => {
58
82
  const budget = await loadFixture(
59
83
  freshManagedBudget(defaultOptions, fixtures),
60
84
  );
61
85
  const admin = accounts[1].account;
62
86
  const manager = accounts[2].account;
63
- await budget.grantRoles(
87
+ await budget.grantManyRoles(
64
88
  [admin, manager],
65
- [ManagedBudgetRoles.ADMIN, ManagedBudgetRoles.MANAGER],
89
+ [Roles.ADMIN, Roles.MANAGER],
66
90
  );
67
- expect(await budget.hasAllRoles(admin, ManagedBudgetRoles.ADMIN)).toBe(
91
+ expect(await budget.hasAllRoles(admin, Roles.ADMIN)).toBe(
68
92
  true,
69
93
  );
70
- expect(await budget.hasAllRoles(manager, ManagedBudgetRoles.MANAGER)).toBe(
94
+ expect(await budget.hasAllRoles(manager, Roles.MANAGER)).toBe(
71
95
  true,
72
96
  );
73
97
  });
74
98
 
75
- test('can revoke roles', async () => {
99
+ test('can revoke many roles', async () => {
76
100
  const budget = await loadFixture(
77
101
  freshManagedBudget(defaultOptions, fixtures),
78
102
  );
79
103
  const admin = accounts[1].account;
80
104
  const manager = accounts[2].account;
81
- await budget.grantRoles(
105
+ await budget.grantManyRoles(
82
106
  [admin, manager],
83
- [ManagedBudgetRoles.ADMIN, ManagedBudgetRoles.MANAGER],
107
+ [Roles.ADMIN, Roles.MANAGER],
84
108
  );
85
- await budget.revokeRoles(
109
+ await budget.revokeManyRoles(
86
110
  [admin, manager],
87
- [ManagedBudgetRoles.ADMIN, ManagedBudgetRoles.MANAGER],
111
+ [Roles.ADMIN, Roles.MANAGER],
88
112
  );
89
- expect(await budget.hasAllRoles(admin, ManagedBudgetRoles.ADMIN)).toBe(
113
+ expect(await budget.hasAllRoles(admin, Roles.ADMIN)).toBe(
90
114
  false,
91
115
  );
92
- expect(await budget.hasAllRoles(manager, ManagedBudgetRoles.MANAGER)).toBe(
116
+ expect(await budget.hasAllRoles(manager, Roles.MANAGER)).toBe(
93
117
  false,
94
118
  );
95
119
  });
@@ -2,26 +2,16 @@ import {
2
2
  managedBudgetAbi,
3
3
  readManagedBudgetAvailable,
4
4
  readManagedBudgetDistributed,
5
- readManagedBudgetHasAllRoles,
6
- readManagedBudgetHasAnyRole,
7
- readManagedBudgetIsAuthorized,
8
5
  readManagedBudgetOwner,
9
- readManagedBudgetRolesOf,
10
6
  readManagedBudgetTotal,
11
7
  simulateManagedBudgetAllocate,
12
8
  simulateManagedBudgetClawback,
13
9
  simulateManagedBudgetDisburse,
14
10
  simulateManagedBudgetDisburseBatch,
15
- simulateManagedBudgetGrantRoles,
16
- simulateManagedBudgetRevokeRoles,
17
- simulateManagedBudgetSetAuthorized,
18
11
  writeManagedBudgetAllocate,
19
12
  writeManagedBudgetClawback,
20
13
  writeManagedBudgetDisburse,
21
14
  writeManagedBudgetDisburseBatch,
22
- writeManagedBudgetGrantRoles,
23
- writeManagedBudgetRevokeRoles,
24
- writeManagedBudgetSetAuthorized,
25
15
  } from '@boostxyz/evm';
26
16
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/ManagedBudget.sol/ManagedBudget.json';
27
17
  import { getAccount } from '@wagmi/core';
@@ -38,7 +28,6 @@ import type {
38
28
  DeployableOptions,
39
29
  GenericDeployableParams,
40
30
  } from '../Deployable/Deployable';
41
- import { DeployableTarget } from '../Deployable/DeployableTarget';
42
31
  import { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';
43
32
  import {
44
33
  DeployableUnknownOwnerProvidedError,
@@ -193,6 +182,7 @@ export class ManagedBudget extends DeployableTargetWithRBAC<
193
182
  * @type {Record<number, Address>}
194
183
  */
195
184
  public static override bases: Record<number, Address> = {
185
+ 31337: import.meta.env.VITE_MANAGED_BUDGET_BASE,
196
186
  ...(ManagedBudgetBases as Record<number, Address>),
197
187
  };
198
188
  /**
@@ -129,7 +129,9 @@ export class VestingBudget extends DeployableTargetWithRBAC<
129
129
  * @static
130
130
  * @type {Record<number, Address>}
131
131
  */
132
- public static override bases: Record<number, Address> = {};
132
+ public static override bases: Record<number, Address> = {
133
+ 31337: import.meta.env.VITE_VESTING_BUDGET_BASE,
134
+ };
133
135
  /**
134
136
  * @inheritdoc
135
137
  *
@@ -0,0 +1,103 @@
1
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
2
+ import { beforeAll, describe, expect, test } from 'vitest';
3
+ import { accounts } from '@boostxyz/test/accounts';
4
+ import {
5
+ type Fixtures,
6
+ defaultOptions,
7
+ deployFixtures,
8
+ freshManagedBudget,
9
+ } from '@boostxyz/test/helpers';
10
+ import { Roles } from './DeployableTargetWithRBAC';
11
+
12
+ let fixtures: Fixtures;
13
+
14
+ beforeAll(async () => {
15
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
16
+ });
17
+
18
+ describe('RBAC', () => {
19
+ test('can grant roles', async () => {
20
+ const budget = await loadFixture(freshManagedBudget(defaultOptions, fixtures));
21
+ const manager = accounts[0].account;
22
+ expect(await budget.rolesOf(manager)).not.toContain(Roles.MANAGER);
23
+ await budget.grantRoles(manager, Roles.MANAGER);
24
+ expect(await budget.rolesOf(manager)).toContain(Roles.MANAGER);
25
+ });
26
+
27
+ test('can revoke roles', async () => {
28
+ const budget = await loadFixture(freshManagedBudget(defaultOptions, fixtures));
29
+ const admin = accounts[1].account;
30
+ await budget.grantRoles(admin, Roles.ADMIN);
31
+ expect(await budget.rolesOf(admin)).toContain(Roles.ADMIN);
32
+ await budget.revokeRoles(admin, Roles.ADMIN);
33
+ expect(await budget.rolesOf(admin)).not.toContain(Roles.ADMIN);
34
+ });
35
+
36
+ test('can grant many roles', async () => {
37
+ const budget = await loadFixture(freshManagedBudget(defaultOptions, fixtures));
38
+ const admin = accounts[2].account;
39
+ const manager = accounts[3].account;
40
+ await budget.grantManyRoles(
41
+ [admin, manager],
42
+ [Roles.ADMIN, Roles.MANAGER],
43
+ );
44
+ expect(await budget.hasAllRoles(admin, Roles.ADMIN)).toBe(true);
45
+ expect(await budget.hasAllRoles(manager, Roles.MANAGER)).toBe(true);
46
+ });
47
+
48
+ test('can revoke many roles', async () => {
49
+ const budget = await loadFixture(freshManagedBudget(defaultOptions, fixtures));
50
+ const admin = accounts[4].account;
51
+ const manager = accounts[5].account;
52
+ await budget.grantManyRoles(
53
+ [admin, manager],
54
+ [Roles.ADMIN, Roles.MANAGER],
55
+ );
56
+ expect(await budget.hasAllRoles(admin, Roles.ADMIN)).toBe(true);
57
+ expect(await budget.hasAllRoles(manager, Roles.MANAGER)).toBe(true);
58
+ await budget.revokeManyRoles(
59
+ [admin, manager],
60
+ [Roles.ADMIN, Roles.MANAGER],
61
+ );
62
+ expect(await budget.hasAllRoles(admin, Roles.ADMIN)).toBe(false);
63
+ expect(await budget.hasAllRoles(manager, Roles.MANAGER)).toBe(false);
64
+ });
65
+
66
+ test('can check for any role', async () => {
67
+ const budget = await loadFixture(freshManagedBudget(defaultOptions, fixtures));
68
+ const user = accounts[6].account;
69
+ expect(await budget.hasAnyRole(user, Roles.MANAGER | Roles.ADMIN)).toBe(false);
70
+ await budget.grantRoles(user, Roles.MANAGER);
71
+ expect(await budget.hasAnyRole(user, Roles.MANAGER | Roles.ADMIN)).toBe(true);
72
+ });
73
+
74
+ test('can check for all roles', async () => {
75
+ const budget = await loadFixture(freshManagedBudget(defaultOptions, fixtures));
76
+ const user = accounts[7].account;
77
+ await budget.grantRoles(user, Roles.MANAGER);
78
+ expect(await budget.hasAllRoles(user, Roles.MANAGER | Roles.ADMIN)).toBe(false);
79
+ await budget.grantRoles(user, Roles.ADMIN);
80
+ expect(await budget.hasAllRoles(user, Roles.MANAGER | Roles.ADMIN)).toBe(true);
81
+ });
82
+
83
+ test('can get roles of an account', async () => {
84
+ const budget = await loadFixture(freshManagedBudget(defaultOptions, fixtures));
85
+ const user = accounts[8].account;
86
+ await budget.grantRoles(user, Roles.MANAGER | Roles.ADMIN);
87
+ const roles = await budget.rolesOf(user);
88
+ expect(roles).toContain(Roles.MANAGER);
89
+ expect(roles).toContain(Roles.ADMIN);
90
+ });
91
+
92
+ test('can set and check authorization', async () => {
93
+ const budget = await loadFixture(freshManagedBudget(defaultOptions, fixtures));
94
+ const user = accounts[9].account;
95
+ expect(await budget.rolesOf(user)).not.toContain(Roles.MANAGER);
96
+ await budget.setAuthorized([user], [true]);
97
+ expect(await budget.isAuthorized(user)).toBe(true);
98
+ expect(await budget.rolesOf(user)).toContain(Roles.MANAGER);
99
+ await budget.setAuthorized([user], [false]);
100
+ expect(await budget.isAuthorized(user)).toBe(false);
101
+ expect(await budget.rolesOf(user)).not.toContain(Roles.MANAGER);
102
+ });
103
+ });
@@ -4,10 +4,14 @@ import {
4
4
  readRbacHasAnyRole,
5
5
  readRbacIsAuthorized,
6
6
  readRbacRolesOf,
7
+ simulateRbacGrantManyRoles,
7
8
  simulateRbacGrantRoles,
9
+ simulateRbacRevokeManyRoles,
8
10
  simulateRbacRevokeRoles,
9
11
  simulateRbacSetAuthorized,
12
+ writeRbacGrantManyRoles,
10
13
  writeRbacGrantRoles,
14
+ writeRbacRevokeManyRoles,
11
15
  writeRbacRevokeRoles,
12
16
  writeRbacSetAuthorized,
13
17
  } from '@boostxyz/evm';
@@ -109,49 +113,49 @@ export class DeployableTargetWithRBAC<
109
113
  }
110
114
 
111
115
  /**
112
- * Grant many accounts permissions on the rbac.
116
+ * Grant permissions for a user on the rbac.
113
117
  *
114
118
  * @example
115
119
  * ```ts
116
- * await rbac.grantRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])
120
+ * await rbac.grantRoles('0xfoo', Roles.MANAGER)
117
121
  * ```
118
122
  * @public
119
123
  * @async
120
- * @param {Address[]} addresses
121
- * @param {RbacRoles[]} roles
122
- * @param {?WriteParams} [params]
124
+ * @param {Address} address
125
+ * @param {Roles} role
126
+ * @param {?WriteParams<typeof rbacAbi, 'grantRoles'>} [params]
123
127
  * @returns {Promise<void>}
124
128
  */
125
129
  public async grantRoles(
126
- addresses: Address[],
127
- roles: Roles[],
130
+ address: Address,
131
+ role: Roles,
128
132
  params?: WriteParams<typeof rbacAbi, 'grantRoles'>,
129
133
  ) {
130
- return await this.awaitResult(this.grantRolesRaw(addresses, roles, params));
134
+ return await this.awaitResult(this.grantRolesRaw(address, role, params));
131
135
  }
132
136
 
133
137
  /**
134
- * Grant many accounts permissions on the rbac.
138
+ * Grant permissions for a user on the rbac.
135
139
  *
136
140
  * @example
137
141
  * ```ts
138
- * await rbac.grantRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
139
- *
142
+ * await rbac.grantRoles('0xfoo', Roles.MANAGER)
143
+ * ```
140
144
  * @public
141
145
  * @async
142
- * @param {Address[]} addresses
143
- * @param {RbacRoles[]} roles
146
+ * @param {Address} address
147
+ * @param {Roles} role
144
148
  * @param {?WriteParams} [params]
145
149
  * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
146
150
  */
147
151
  public async grantRolesRaw(
148
- addresses: Address[],
149
- roles: Roles[],
152
+ address: Address,
153
+ role: Roles,
150
154
  params?: WriteParams<typeof rbacAbi, 'grantRoles'>,
151
155
  ) {
152
156
  const { request, result } = await simulateRbacGrantRoles(this._config, {
153
157
  address: this.assertValidAddress(),
154
- args: [addresses, roles],
158
+ args: [address, role],
155
159
  ...this.optionallyAttachAccount(),
156
160
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
157
161
  ...(params as any),
@@ -165,55 +169,173 @@ export class DeployableTargetWithRBAC<
165
169
  }
166
170
 
167
171
  /**
168
- * Revoke many accounts' permissions on the rbac.
172
+ * Revoke permissions for a user on the rbac.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * await rbac.revokeRoles('0xfoo', Roles.MANAGER)
177
+ * ```
178
+ * @public
179
+ * @async
180
+ * @param {Address} address
181
+ * @param {Roles} role
182
+ * @param {?WriteParams} [params]
183
+ * @returns {Promise<void>}
184
+ */
185
+ public async revokeRoles(
186
+ address: Address,
187
+ role: Roles,
188
+ params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,
189
+ ) {
190
+ return await this.awaitResult(this.revokeRolesRaw(address, role, params));
191
+ }
192
+
193
+ /**
194
+ * Revoke permissions for a user on the rbac.
169
195
  *
170
196
  * @example
171
197
  * ```ts
172
- * await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])
198
+ * await rbac.revokeRoles('0xfoo', Roles.MANAGER)
199
+ * ```
200
+ * @public
201
+ * @async
202
+ * @param {Address} address
203
+ * @param {Roles} role
204
+ * @param {?WriteParams} [params]
205
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
206
+ */
207
+ public async revokeRolesRaw(
208
+ address: Address,
209
+ role: Roles,
210
+ params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,
211
+ ) {
212
+ const { request, result } = await simulateRbacRevokeRoles(this._config, {
213
+ address: this.assertValidAddress(),
214
+ args: [address, role],
215
+ ...this.optionallyAttachAccount(),
216
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
217
+ ...(params as any),
218
+ });
219
+ const hash = await writeRbacRevokeRoles(
220
+ this._config,
221
+ // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
222
+ request as any,
223
+ );
224
+ return { hash, result };
225
+ }
226
+
227
+ /**
228
+ * Grant many accounts permissions on the rbac.
173
229
  *
230
+ * @example
231
+ * ```ts
232
+ * await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
233
+ * ```
174
234
  * @public
175
235
  * @async
176
236
  * @param {Address[]} addresses
177
- * @param {RbacRoles[]} roles
237
+ * @param {Roles[]} roles
178
238
  * @param {?WriteParams} [params]
179
239
  * @returns {Promise<void>}
180
240
  */
181
- public async revokeRoles(
241
+ public async grantManyRoles(
182
242
  addresses: Address[],
183
243
  roles: Roles[],
184
- params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,
244
+ params?: WriteParams<typeof rbacAbi, 'grantManyRoles'>,
185
245
  ) {
186
246
  return await this.awaitResult(
187
- this.revokeRolesRaw(addresses, roles, params),
247
+ this.grantManyRolesRaw(addresses, roles, params),
188
248
  );
189
249
  }
190
250
 
191
251
  /**
192
- * Revoke many accounts' permissions on the rbac.
252
+ * Grant many accounts permissions on the rbac.
193
253
  *
194
254
  * @example
195
255
  * ```ts
196
- * await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])
256
+ * await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
257
+ * ```
197
258
  * @public
198
259
  * @async
199
260
  * @param {Address[]} addresses
200
- * @param {RbacRoles[]} roles
261
+ * @param {Roles[]} roles
201
262
  * @param {?WriteParams} [params]
202
263
  * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
203
264
  */
204
- public async revokeRolesRaw(
265
+ public async grantManyRolesRaw(
205
266
  addresses: Address[],
206
267
  roles: Roles[],
207
- params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,
268
+ params?: WriteParams<typeof rbacAbi, 'grantManyRoles'>,
208
269
  ) {
209
- const { request, result } = await simulateRbacRevokeRoles(this._config, {
270
+ const { request, result } = await simulateRbacGrantManyRoles(this._config, {
210
271
  address: this.assertValidAddress(),
211
272
  args: [addresses, roles],
212
273
  ...this.optionallyAttachAccount(),
213
274
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
214
275
  ...(params as any),
215
276
  });
216
- const hash = await writeRbacRevokeRoles(
277
+ const hash = await writeRbacGrantManyRoles(
278
+ this._config,
279
+ // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
280
+ request as any,
281
+ );
282
+ return { hash, result };
283
+ }
284
+
285
+ /**
286
+ * Revoke many accounts' permissions on the rbac.
287
+ *
288
+ * @example
289
+ * ```ts
290
+ * await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
291
+ * ```
292
+ * @public
293
+ * @async
294
+ * @param {Address[]} addresses
295
+ * @param {Roles[]} roles
296
+ * @param {?WriteParams} [params]
297
+ * @returns {Promise<void>}
298
+ */
299
+ public async revokeManyRoles(
300
+ addresses: Address[],
301
+ roles: Roles[],
302
+ params?: WriteParams<typeof rbacAbi, 'revokeManyRoles'>,
303
+ ) {
304
+ return await this.awaitResult(
305
+ this.revokeManyRolesRaw(addresses, roles, params),
306
+ );
307
+ }
308
+
309
+ /**
310
+ * Revoke many accounts' permissions on the rbac.
311
+ *
312
+ * @example
313
+ * ```ts
314
+ * await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
315
+ * ```
316
+ * @public
317
+ * @async
318
+ * @param {Address[]} addresses
319
+ * @param {Roles[]} roles
320
+ * @param {?WriteParams} [params]
321
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
322
+ */
323
+ public async revokeManyRolesRaw(
324
+ addresses: Address[],
325
+ roles: Roles[],
326
+ params?: WriteParams<typeof rbacAbi, 'revokeManyRoles'>,
327
+ ) {
328
+ const { request, result } = await simulateRbacRevokeManyRoles(
329
+ this._config,
330
+ {
331
+ address: this.assertValidAddress(),
332
+ args: [addresses, roles],
333
+ ...this.optionallyAttachAccount(),
334
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
335
+ ...(params as any),
336
+ },
337
+ );
338
+ const hash = await writeRbacRevokeManyRoles(
217
339
  this._config,
218
340
  // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
219
341
  request as any,
@@ -225,11 +347,12 @@ export class DeployableTargetWithRBAC<
225
347
  * Return an array of the roles assigned to the given account.
226
348
  * @example
227
349
  * ```ts
228
- * (await rbac.rolesOf(0xfoo)).includes(RbacRoles.ADMIN)
350
+ * (await rbac.rolesOf(0xfoo)).includes(Roles.ADMIN)
351
+ * ```
229
352
  * @public
230
353
  * @param {Address} account
231
354
  * @param {?ReadParams} [params]
232
- * @returns {Promise<Array<RbacRoles>>}
355
+ * @returns {Promise<Array<Roles>>}
233
356
  */
234
357
  public async rolesOf(
235
358
  account: Address,
@@ -252,10 +375,11 @@ export class DeployableTargetWithRBAC<
252
375
  *
253
376
  * @example
254
377
  * ```ts
255
- * await rbac.hasAnyRole(0xfoo, RbacRoles.ADMIN | RbacRoles.MANAGER)
378
+ * await rbac.hasAnyRole(0xfoo, Roles.ADMIN | Roles.MANAGER)
379
+ * ```
256
380
  * @public
257
381
  * @param {Address} account
258
- * @param {RbacRoles} roles
382
+ * @param {Roles} roles
259
383
  * @param {?ReadParams} [params]
260
384
  * @returns {Promise<boolean>}
261
385
  */
@@ -278,11 +402,11 @@ export class DeployableTargetWithRBAC<
278
402
  *
279
403
  * @example
280
404
  * ```ts
281
- * await rbac.hasAllRoles(0xfoo, RbacRoles.ADMIN & RbacRoles.MANAGER)
282
- *
405
+ * await rbac.hasAllRoles(0xfoo, Roles.ADMIN | Roles.MANAGER)
406
+ * ```
283
407
  * @public
284
408
  * @param {Address} account
285
- * @param {RbacRoles} roles
409
+ * @param {Roles} roles
286
410
  * @param {?ReadParams} [params]
287
411
  * @returns {Promise<boolean>}
288
412
  */
@@ -8,8 +8,8 @@ import {
8
8
  deployFixtures,
9
9
  freshBoost,
10
10
  } from '@boostxyz/test/helpers';
11
- import { LIST_MANAGER_ROLE } from '../AllowLists/SimpleAllowList';
12
11
  import { PointsIncentive } from './PointsIncentive';
12
+ import { Roles } from '../Deployable/DeployableTargetWithRBAC';
13
13
 
14
14
  let fixtures: Fixtures;
15
15
 
@@ -57,9 +57,9 @@ describe('AllowListIncentive', () => {
57
57
  const boost = await freshBoost(fixtures, {
58
58
  incentives: [allowListIncentive],
59
59
  });
60
- await allowList.grantRoles(
61
- allowListIncentive.assertValidAddress(),
62
- LIST_MANAGER_ROLE,
60
+ await allowList.grantManyRoles(
61
+ [allowListIncentive.assertValidAddress()],
62
+ [Roles.MANAGER],
63
63
  );
64
64
 
65
65
  const claimant = trustedSigner.account;
@@ -103,9 +103,9 @@ describe('AllowListIncentive', () => {
103
103
  const boost = await freshBoost(fixtures, {
104
104
  incentives: [allowListIncentive],
105
105
  });
106
- await allowList.grantRoles(
107
- allowListIncentive.assertValidAddress(),
108
- LIST_MANAGER_ROLE,
106
+ await allowList.grantManyRoles(
107
+ [allowListIncentive.assertValidAddress()],
108
+ [Roles.MANAGER],
109
109
  );
110
110
  const incentiveQuantity = 1;
111
111
  const claimant = trustedSigner.account;
@@ -97,6 +97,7 @@ export class AllowListIncentive extends DeployableTarget<
97
97
  * @type {Record<number, Address>}
98
98
  */
99
99
  public static override bases: Record<number, Address> = {
100
+ 31337: import.meta.env.VITE_ALLOWLIST_INCENTIVE_BASE,
100
101
  ...(AllowListIncentiveBases as Record<number, Address>),
101
102
  };
102
103
  /**
@@ -155,6 +155,7 @@ export class CGDAIncentive extends DeployableTarget<
155
155
  * @type {Record<number, Address>}
156
156
  */
157
157
  public static override bases: Record<number, Address> = {
158
+ 31337: import.meta.env.VITE_CGDA_INCENTIVE_BASE,
158
159
  ...(CGDAIncentiveBases as Record<number, Address>),
159
160
  };
160
161
  /**
@@ -129,7 +129,9 @@ export class ERC1155Incentive extends DeployableTarget<
129
129
  * @static
130
130
  * @type {Record<number, Address>}
131
131
  */
132
- public static override bases: Record<number, Address> = {};
132
+ public static override bases: Record<number, Address> = {
133
+ 31337: import.meta.env.VITE_ERC1155_INCENTIVE_BASE,
134
+ };
133
135
  /**
134
136
  * @inheritdoc
135
137
  *