@boostxyz/sdk 0.0.0-alpha.9 → 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 (254) 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 +2 -2
  4. package/dist/Actions/ContractAction.d.ts +11 -11
  5. package/dist/Actions/ContractAction.d.ts.map +1 -1
  6. package/dist/Actions/ERC721MintAction.d.ts +14 -14
  7. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  8. package/dist/Actions/EventAction.cjs +1 -1
  9. package/dist/Actions/EventAction.cjs.map +1 -1
  10. package/dist/Actions/EventAction.d.ts +174 -41
  11. package/dist/Actions/EventAction.d.ts.map +1 -1
  12. package/dist/Actions/EventAction.js +557 -129
  13. package/dist/Actions/EventAction.js.map +1 -1
  14. package/dist/AllowLists/AllowList.cjs +1 -1
  15. package/dist/AllowLists/AllowList.cjs.map +1 -1
  16. package/dist/AllowLists/AllowList.d.ts +6 -4
  17. package/dist/AllowLists/AllowList.d.ts.map +1 -1
  18. package/dist/AllowLists/AllowList.js +45 -23
  19. package/dist/AllowLists/AllowList.js.map +1 -1
  20. package/dist/AllowLists/OpenAllowList.d.ts +423 -0
  21. package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
  22. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  23. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  24. package/dist/AllowLists/SimpleAllowList.d.ts +92 -37
  25. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  26. package/dist/AllowLists/SimpleAllowList.js +60 -75
  27. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  28. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  29. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
  30. package/dist/AllowLists/SimpleDenyList.d.ts +203 -11
  31. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  32. package/dist/AllowLists/SimpleDenyList.js +11 -112
  33. package/dist/AllowLists/SimpleDenyList.js.map +1 -1
  34. package/dist/Auth/PassthroughAuth.cjs +1 -1
  35. package/dist/Auth/PassthroughAuth.js +1 -1
  36. package/dist/Boost.cjs +1 -1
  37. package/dist/Boost.cjs.map +1 -1
  38. package/dist/Boost.d.ts +20 -21
  39. package/dist/Boost.d.ts.map +1 -1
  40. package/dist/Boost.js +43 -57
  41. package/dist/Boost.js.map +1 -1
  42. package/dist/BoostCore-Btl5BdAs.cjs +3 -0
  43. package/dist/BoostCore-Btl5BdAs.cjs.map +1 -0
  44. package/dist/BoostCore-CD56zbYX.js +2641 -0
  45. package/dist/BoostCore-CD56zbYX.js.map +1 -0
  46. package/dist/BoostCore.cjs +1 -2
  47. package/dist/BoostCore.cjs.map +1 -1
  48. package/dist/BoostCore.d.ts +749 -78
  49. package/dist/BoostCore.d.ts.map +1 -1
  50. package/dist/BoostCore.js +29 -1150
  51. package/dist/BoostCore.js.map +1 -1
  52. package/dist/BoostRegistry.cjs +1 -1
  53. package/dist/BoostRegistry.cjs.map +1 -1
  54. package/dist/BoostRegistry.d.ts +80 -25
  55. package/dist/BoostRegistry.d.ts.map +1 -1
  56. package/dist/BoostRegistry.js +164 -82
  57. package/dist/BoostRegistry.js.map +1 -1
  58. package/dist/Budgets/Budget.cjs +1 -1
  59. package/dist/Budgets/Budget.cjs.map +1 -1
  60. package/dist/Budgets/Budget.d.ts.map +1 -1
  61. package/dist/Budgets/Budget.js +2 -2
  62. package/dist/Budgets/Budget.js.map +1 -1
  63. package/dist/Budgets/ManagedBudget.cjs +1 -1
  64. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  65. package/dist/Budgets/ManagedBudget.d.ts +103 -221
  66. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  67. package/dist/Budgets/ManagedBudget.js +81 -298
  68. package/dist/Budgets/ManagedBudget.js.map +1 -1
  69. package/dist/Budgets/VestingBudget.d.ts +223 -89
  70. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  71. package/dist/Deployable/Contract.cjs +1 -1
  72. package/dist/Deployable/Contract.cjs.map +1 -1
  73. package/dist/Deployable/Contract.d.ts +4 -5
  74. package/dist/Deployable/Contract.d.ts.map +1 -1
  75. package/dist/Deployable/Contract.js +5 -7
  76. package/dist/Deployable/Contract.js.map +1 -1
  77. package/dist/Deployable/Deployable.cjs.map +1 -1
  78. package/dist/Deployable/Deployable.d.ts +1 -1
  79. package/dist/Deployable/Deployable.d.ts.map +1 -1
  80. package/dist/Deployable/Deployable.js +3 -5
  81. package/dist/Deployable/Deployable.js.map +1 -1
  82. package/dist/Deployable/DeployableTarget.cjs +1 -1
  83. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  84. package/dist/Deployable/DeployableTarget.d.ts +13 -13
  85. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  86. package/dist/Deployable/DeployableTarget.js +28 -25
  87. package/dist/Deployable/DeployableTarget.js.map +1 -1
  88. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  89. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  90. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +248 -0
  91. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  92. package/dist/Deployable/DeployableTargetWithRBAC.js +320 -0
  93. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  94. package/dist/Incentive-CcnOIc8L.cjs +2 -0
  95. package/dist/Incentive-CcnOIc8L.cjs.map +1 -0
  96. package/dist/Incentive-rM5nKznp.js +313 -0
  97. package/dist/Incentive-rM5nKznp.js.map +1 -0
  98. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  99. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  100. package/dist/Incentives/AllowListIncentive.d.ts +38 -16
  101. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  102. package/dist/Incentives/AllowListIncentive.js +43 -29
  103. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  104. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  105. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  106. package/dist/Incentives/CGDAIncentive.d.ts +234 -21
  107. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  108. package/dist/Incentives/CGDAIncentive.js +46 -32
  109. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  110. package/dist/Incentives/ERC1155Incentive.d.ts +224 -37
  111. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  112. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  113. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  114. package/dist/Incentives/ERC20Incentive.d.ts +234 -30
  115. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  116. package/dist/Incentives/ERC20Incentive.js +62 -46
  117. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  118. package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +333 -438
  119. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  120. package/dist/Incentives/ERC20VariableIncentive.d.ts +231 -29
  121. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  122. package/dist/Incentives/Incentive.cjs +1 -1
  123. package/dist/Incentives/Incentive.cjs.map +1 -1
  124. package/dist/Incentives/Incentive.d.ts +4 -4
  125. package/dist/Incentives/Incentive.d.ts.map +1 -1
  126. package/dist/Incentives/Incentive.js +16 -296
  127. package/dist/Incentives/Incentive.js.map +1 -1
  128. package/dist/Incentives/PointsIncentive.cjs +1 -1
  129. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  130. package/dist/Incentives/PointsIncentive.d.ts +40 -18
  131. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  132. package/dist/Incentives/PointsIncentive.js +38 -24
  133. package/dist/Incentives/PointsIncentive.js.map +1 -1
  134. package/dist/SimpleDenyList-BDXpY74P.js +133 -0
  135. package/dist/SimpleDenyList-BDXpY74P.js.map +1 -0
  136. package/dist/SimpleDenyList-DNj5qDWM.cjs +2 -0
  137. package/dist/SimpleDenyList-DNj5qDWM.cjs.map +1 -0
  138. package/dist/Validators/SignerValidator.cjs +1 -1
  139. package/dist/Validators/SignerValidator.cjs.map +1 -1
  140. package/dist/Validators/SignerValidator.d.ts +16 -16
  141. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  142. package/dist/Validators/SignerValidator.js +32 -28
  143. package/dist/Validators/SignerValidator.js.map +1 -1
  144. package/dist/Validators/Validator.cjs +1 -1
  145. package/dist/Validators/Validator.cjs.map +1 -1
  146. package/dist/Validators/Validator.d.ts +1 -1
  147. package/dist/Validators/Validator.js +2 -2
  148. package/dist/Validators/Validator.js.map +1 -1
  149. package/dist/claiming.cjs.map +1 -1
  150. package/dist/claiming.d.ts +1 -1
  151. package/dist/claiming.js.map +1 -1
  152. package/dist/componentInterfaces-BBCFkrZv.js +14 -0
  153. package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
  154. package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
  155. package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
  156. package/dist/deployments-DF_6-7hH.cjs +2 -0
  157. package/dist/deployments-DF_6-7hH.cjs.map +1 -0
  158. package/dist/deployments-fJsWblwS.js +56 -0
  159. package/dist/deployments-fJsWblwS.js.map +1 -0
  160. package/dist/deployments.json +58 -0
  161. package/dist/errors.cjs +1 -1
  162. package/dist/errors.cjs.map +1 -1
  163. package/dist/errors.d.ts +256 -20
  164. package/dist/errors.d.ts.map +1 -1
  165. package/dist/errors.js +183 -26
  166. package/dist/errors.js.map +1 -1
  167. package/dist/{generated-57_Kffpz.js → generated-CsNyWPKA.js} +3843 -2084
  168. package/dist/generated-CsNyWPKA.js.map +1 -0
  169. package/dist/generated-DHerxf1y.cjs +3 -0
  170. package/dist/generated-DHerxf1y.cjs.map +1 -0
  171. package/dist/index.cjs +1 -1
  172. package/dist/index.d.ts +5 -0
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/index.js +142 -108
  175. package/dist/index.js.map +1 -1
  176. package/dist/transfers.cjs.map +1 -1
  177. package/dist/transfers.d.ts +1 -1
  178. package/dist/transfers.js.map +1 -1
  179. package/dist/utils.cjs +1 -1
  180. package/dist/utils.cjs.map +1 -1
  181. package/dist/utils.d.ts +26 -12
  182. package/dist/utils.d.ts.map +1 -1
  183. package/dist/utils.js +38 -23
  184. package/dist/utils.js.map +1 -1
  185. package/package.json +20 -10
  186. package/src/Actions/Action.test.ts +14 -13
  187. package/src/Actions/ContractAction.test.ts +10 -10
  188. package/src/Actions/ContractAction.ts +11 -12
  189. package/src/Actions/ERC721MintAction.test.ts +6 -6
  190. package/src/Actions/ERC721MintAction.ts +14 -15
  191. package/src/Actions/EventAction.test.ts +735 -109
  192. package/src/Actions/EventAction.ts +527 -88
  193. package/src/AllowLists/AllowList.test.ts +7 -7
  194. package/src/AllowLists/AllowList.ts +5 -3
  195. package/src/AllowLists/OpenAllowList.test.ts +40 -0
  196. package/src/AllowLists/OpenAllowList.ts +45 -0
  197. package/src/AllowLists/SimpleAllowList.test.ts +4 -4
  198. package/src/AllowLists/SimpleAllowList.ts +40 -61
  199. package/src/AllowLists/SimpleDenyList.test.ts +4 -4
  200. package/src/AllowLists/SimpleDenyList.ts +41 -17
  201. package/src/Auth/PassthroughAuth.test.ts +1 -1
  202. package/src/Boost.ts +21 -24
  203. package/src/BoostCore.test.ts +361 -306
  204. package/src/BoostCore.ts +403 -220
  205. package/src/BoostRegistry.test.ts +53 -0
  206. package/src/BoostRegistry.ts +161 -40
  207. package/src/Budgets/Budget.test.ts +2 -2
  208. package/src/Budgets/Budget.ts +1 -2
  209. package/src/Budgets/ManagedBudget.test.ts +106 -19
  210. package/src/Budgets/ManagedBudget.ts +49 -321
  211. package/src/Budgets/VestingBudget.test.ts +7 -7
  212. package/src/Budgets/VestingBudget.ts +36 -106
  213. package/src/Deployable/Contract.ts +4 -5
  214. package/src/Deployable/Deployable.ts +1 -1
  215. package/src/Deployable/DeployableTarget.ts +30 -19
  216. package/src/Deployable/DeployableTargetWithRBAC.test.ts +103 -0
  217. package/src/Deployable/DeployableTargetWithRBAC.ts +447 -0
  218. package/src/Incentives/AllowListIncentive.test.ts +12 -12
  219. package/src/Incentives/AllowListIncentive.ts +30 -15
  220. package/src/Incentives/CGDAIncentive.test.ts +9 -6
  221. package/src/Incentives/CGDAIncentive.ts +39 -18
  222. package/src/Incentives/ERC1155Incentive.test.ts +3 -3
  223. package/src/Incentives/ERC1155Incentive.ts +30 -29
  224. package/src/Incentives/ERC20Incentive.test.ts +9 -6
  225. package/src/Incentives/ERC20Incentive.ts +54 -27
  226. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  227. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +325 -0
  228. package/src/Incentives/ERC20VariableIncentive.test.ts +8 -11
  229. package/src/Incentives/ERC20VariableIncentive.ts +50 -26
  230. package/src/Incentives/Incentive.test.ts +4 -1
  231. package/src/Incentives/Incentive.ts +7 -6
  232. package/src/Incentives/PointsIncentive.test.ts +24 -25
  233. package/src/Incentives/PointsIncentive.ts +32 -17
  234. package/src/Validators/SignerValidator.test.ts +6 -6
  235. package/src/Validators/SignerValidator.ts +20 -17
  236. package/src/Validators/Validator.test.ts +2 -2
  237. package/src/Validators/Validator.ts +1 -1
  238. package/src/claiming.ts +1 -1
  239. package/src/errors.ts +345 -21
  240. package/src/index.test.ts +118 -36
  241. package/src/index.ts +5 -0
  242. package/src/transfers.ts +1 -1
  243. package/src/utils.test.ts +2 -2
  244. package/src/utils.ts +61 -12
  245. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  246. package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
  247. package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
  248. package/dist/componentInterfaces-DYkaxBda.js +0 -13
  249. package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
  250. package/dist/generated-57_Kffpz.js.map +0 -1
  251. package/dist/generated-wKBNvm48.cjs +0 -3
  252. package/dist/generated-wKBNvm48.cjs.map +0 -1
  253. package/src/Budgets/SimpleBudget.test.ts +0 -152
  254. package/src/Budgets/SimpleBudget.ts +0 -564
@@ -0,0 +1,447 @@
1
+ import {
2
+ rbacAbi,
3
+ readRbacHasAllRoles,
4
+ readRbacHasAnyRole,
5
+ readRbacIsAuthorized,
6
+ readRbacRolesOf,
7
+ simulateRbacGrantManyRoles,
8
+ simulateRbacGrantRoles,
9
+ simulateRbacRevokeManyRoles,
10
+ simulateRbacRevokeRoles,
11
+ simulateRbacSetAuthorized,
12
+ writeRbacGrantManyRoles,
13
+ writeRbacGrantRoles,
14
+ writeRbacRevokeManyRoles,
15
+ writeRbacRevokeRoles,
16
+ writeRbacSetAuthorized,
17
+ } from '@boostxyz/evm';
18
+ import type { Abi, Address, ContractEventName } from 'viem';
19
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
20
+ import type { GenericLog, ReadParams, WriteParams } from '../utils';
21
+ export { rbacAbi };
22
+
23
+ /**
24
+ * Enum representing available roles for use with the `RBAC` authorization scheme.
25
+ * `MANAGER` has lowest level of write permissions, for specific implementations, see Budgets and ALlowLists
26
+ * `ADMIN` can additionally manage authorized users on the contract.
27
+ *
28
+ * @export
29
+ * @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}
30
+ * @enum {bigint}
31
+ */
32
+ export enum Roles {
33
+ //@ts-expect-error ts doesn't like bigint enum values
34
+ MANAGER = 1n,
35
+ //@ts-expect-error ts doesn't like bigint enum values
36
+ ADMIN = 2n,
37
+ }
38
+
39
+ /**
40
+ * A generic `viem.Log` event with support for `Rbac` event types.
41
+ *
42
+ * @export
43
+ * @typedef {RBACLog}
44
+ * @template {ContractEventName<typeof rbacAbi>} [event=ContractEventName<
45
+ * typeof rbacAbi
46
+ * >]
47
+ */
48
+ export type RBACLog<
49
+ event extends ContractEventName<typeof rbacAbi> = ContractEventName<
50
+ typeof rbacAbi
51
+ >,
52
+ > = GenericLog<typeof rbacAbi, event>;
53
+
54
+ /**
55
+ * A minimal RBAC implementation that offers MANAGER and ADMIN roles, and
56
+ * Budgets and allowlists support this auth scheme
57
+ *
58
+ * @export
59
+ * @class DeployableTargetWithRBAC
60
+ * @typedef {DeployableTargetWithRBAC}
61
+ * @extends {DeployableTarget<RbacPayload>}
62
+ */
63
+ export class DeployableTargetWithRBAC<
64
+ Payload,
65
+ ABI extends Abi,
66
+ > extends DeployableTarget<Payload, ABI> {
67
+ /**
68
+ * Set the authorized status of the given accounts
69
+ * The mechanism for managing authorization is left to the implementing contract
70
+ *
71
+ * @public
72
+ * @async
73
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
74
+ * @param {boolean[]} allowed - The authorization status for the given accounts
75
+ * @param {?WriteParams} [params]
76
+ * @returns {Promise<void>}
77
+ */
78
+ public async setAuthorized(
79
+ addresses: Address[],
80
+ allowed: boolean[],
81
+ params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,
82
+ ) {
83
+ return await this.awaitResult(
84
+ this.setAuthorizedRaw(addresses, allowed, params),
85
+ );
86
+ }
87
+
88
+ /**
89
+ * Set the authorized status of the given accounts
90
+ * The mechanism for managing authorization is left to the implementing contract
91
+ *
92
+ * @public
93
+ * @async
94
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
95
+ * @param {boolean[]} allowed - The authorization status for the given accounts
96
+ * @param {?WriteParams} [params]
97
+ * @returns {Promise<void>}
98
+ */
99
+ public async setAuthorizedRaw(
100
+ addresses: Address[],
101
+ allowed: boolean[],
102
+ params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,
103
+ ) {
104
+ const { request, result } = await simulateRbacSetAuthorized(this._config, {
105
+ address: this.assertValidAddress(),
106
+ args: [addresses, allowed],
107
+ ...this.optionallyAttachAccount(),
108
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
109
+ ...(params as any),
110
+ });
111
+ const hash = await writeRbacSetAuthorized(this._config, request);
112
+ return { hash, result };
113
+ }
114
+
115
+ /**
116
+ * Grant permissions for a user on the rbac.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * await rbac.grantRoles('0xfoo', Roles.MANAGER)
121
+ * ```
122
+ * @public
123
+ * @async
124
+ * @param {Address} address
125
+ * @param {Roles} role
126
+ * @param {?WriteParams<typeof rbacAbi, 'grantRoles'>} [params]
127
+ * @returns {Promise<void>}
128
+ */
129
+ public async grantRoles(
130
+ address: Address,
131
+ role: Roles,
132
+ params?: WriteParams<typeof rbacAbi, 'grantRoles'>,
133
+ ) {
134
+ return await this.awaitResult(this.grantRolesRaw(address, role, params));
135
+ }
136
+
137
+ /**
138
+ * Grant permissions for a user on the rbac.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * await rbac.grantRoles('0xfoo', Roles.MANAGER)
143
+ * ```
144
+ * @public
145
+ * @async
146
+ * @param {Address} address
147
+ * @param {Roles} role
148
+ * @param {?WriteParams} [params]
149
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
150
+ */
151
+ public async grantRolesRaw(
152
+ address: Address,
153
+ role: Roles,
154
+ params?: WriteParams<typeof rbacAbi, 'grantRoles'>,
155
+ ) {
156
+ const { request, result } = await simulateRbacGrantRoles(this._config, {
157
+ address: this.assertValidAddress(),
158
+ args: [address, role],
159
+ ...this.optionallyAttachAccount(),
160
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
161
+ ...(params as any),
162
+ });
163
+ const hash = await writeRbacGrantRoles(
164
+ this._config,
165
+ // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
166
+ request as any,
167
+ );
168
+ return { hash, result };
169
+ }
170
+
171
+ /**
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.
195
+ *
196
+ * @example
197
+ * ```ts
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.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
233
+ * ```
234
+ * @public
235
+ * @async
236
+ * @param {Address[]} addresses
237
+ * @param {Roles[]} roles
238
+ * @param {?WriteParams} [params]
239
+ * @returns {Promise<void>}
240
+ */
241
+ public async grantManyRoles(
242
+ addresses: Address[],
243
+ roles: Roles[],
244
+ params?: WriteParams<typeof rbacAbi, 'grantManyRoles'>,
245
+ ) {
246
+ return await this.awaitResult(
247
+ this.grantManyRolesRaw(addresses, roles, params),
248
+ );
249
+ }
250
+
251
+ /**
252
+ * Grant many accounts permissions on the rbac.
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
257
+ * ```
258
+ * @public
259
+ * @async
260
+ * @param {Address[]} addresses
261
+ * @param {Roles[]} roles
262
+ * @param {?WriteParams} [params]
263
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
264
+ */
265
+ public async grantManyRolesRaw(
266
+ addresses: Address[],
267
+ roles: Roles[],
268
+ params?: WriteParams<typeof rbacAbi, 'grantManyRoles'>,
269
+ ) {
270
+ const { request, result } = await simulateRbacGrantManyRoles(this._config, {
271
+ address: this.assertValidAddress(),
272
+ args: [addresses, roles],
273
+ ...this.optionallyAttachAccount(),
274
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
275
+ ...(params as any),
276
+ });
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(
339
+ this._config,
340
+ // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
341
+ request as any,
342
+ );
343
+ return { hash, result };
344
+ }
345
+
346
+ /**
347
+ * Return an array of the roles assigned to the given account.
348
+ * @example
349
+ * ```ts
350
+ * (await rbac.rolesOf(0xfoo)).includes(Roles.ADMIN)
351
+ * ```
352
+ * @public
353
+ * @param {Address} account
354
+ * @param {?ReadParams} [params]
355
+ * @returns {Promise<Array<Roles>>}
356
+ */
357
+ public async rolesOf(
358
+ account: Address,
359
+ params?: ReadParams<typeof rbacAbi, 'rolesOf'>,
360
+ ) {
361
+ const roles = await readRbacRolesOf(this._config, {
362
+ address: this.assertValidAddress(),
363
+ args: [account],
364
+ ...this.optionallyAttachAccount(),
365
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
366
+ ...(params as any),
367
+ });
368
+ return ([Roles.MANAGER, Roles.ADMIN] as unknown as Array<bigint>).filter(
369
+ (role) => (roles & role) === role,
370
+ ) as unknown as Roles[];
371
+ }
372
+
373
+ /**
374
+ * Returns whether given account has any of the provided roles bitmap.
375
+ *
376
+ * @example
377
+ * ```ts
378
+ * await rbac.hasAnyRole(0xfoo, Roles.ADMIN | Roles.MANAGER)
379
+ * ```
380
+ * @public
381
+ * @param {Address} account
382
+ * @param {Roles} roles
383
+ * @param {?ReadParams} [params]
384
+ * @returns {Promise<boolean>}
385
+ */
386
+ public hasAnyRole(
387
+ account: Address,
388
+ roles: Roles,
389
+ params?: ReadParams<typeof rbacAbi, 'hasAnyRole'>,
390
+ ) {
391
+ return readRbacHasAnyRole(this._config, {
392
+ address: this.assertValidAddress(),
393
+ args: [account, roles],
394
+ ...this.optionallyAttachAccount(),
395
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
396
+ ...(params as any),
397
+ });
398
+ }
399
+
400
+ /**
401
+ * Returns whether given account has all of the provided roles bitmap.
402
+ *
403
+ * @example
404
+ * ```ts
405
+ * await rbac.hasAllRoles(0xfoo, Roles.ADMIN | Roles.MANAGER)
406
+ * ```
407
+ * @public
408
+ * @param {Address} account
409
+ * @param {Roles} roles
410
+ * @param {?ReadParams} [params]
411
+ * @returns {Promise<boolean>}
412
+ */
413
+ public hasAllRoles(
414
+ account: Address,
415
+ roles: Roles,
416
+ params?: ReadParams<typeof rbacAbi, 'hasAllRoles'>,
417
+ ) {
418
+ return readRbacHasAllRoles(this._config, {
419
+ address: this.assertValidAddress(),
420
+ args: [account, roles],
421
+ ...this.optionallyAttachAccount(),
422
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
423
+ ...(params as any),
424
+ });
425
+ }
426
+
427
+ /**
428
+ * Check if the given account is authorized to use the rbac
429
+ *
430
+ * @public
431
+ * @param {Address} account
432
+ * @param {?ReadParams} [params]
433
+ * @returns {Promise<boolean>} - True if the account is authorized
434
+ */
435
+ public isAuthorized(
436
+ account: Address,
437
+ params?: ReadParams<typeof rbacAbi, 'isAuthorized'>,
438
+ ) {
439
+ return readRbacIsAuthorized(this._config, {
440
+ address: this.assertValidAddress(),
441
+ args: [account],
442
+ ...this.optionallyAttachAccount(),
443
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
444
+ ...(params as any),
445
+ });
446
+ }
447
+ }
@@ -1,23 +1,23 @@
1
1
  import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
2
2
  import { isAddress, pad, parseEther, zeroAddress } from 'viem';
3
3
  import { beforeAll, describe, expect, test } from 'vitest';
4
- import { accounts } from '../../test/accounts';
4
+ import { accounts } from '@boostxyz/test/accounts';
5
5
  import {
6
6
  type Fixtures,
7
7
  defaultOptions,
8
8
  deployFixtures,
9
9
  freshBoost,
10
- } from '../../test/helpers';
11
- import { LIST_MANAGER_ROLE } from '../AllowLists/SimpleAllowList';
10
+ } from '@boostxyz/test/helpers';
12
11
  import { PointsIncentive } from './PointsIncentive';
12
+ import { Roles } from '../Deployable/DeployableTargetWithRBAC';
13
13
 
14
14
  let fixtures: Fixtures;
15
15
 
16
16
  function freshAllowList(fixtures: Fixtures) {
17
17
  return function freshAllowList() {
18
- return fixtures.registry.clone(
18
+ return fixtures.registry.initialize(
19
19
  crypto.randomUUID(),
20
- new fixtures.bases.SimpleAllowList(defaultOptions, {
20
+ fixtures.core.SimpleAllowList({
21
21
  owner: defaultOptions.account.address,
22
22
  allowed: [],
23
23
  }),
@@ -27,7 +27,7 @@ function freshAllowList(fixtures: Fixtures) {
27
27
 
28
28
  describe('AllowListIncentive', () => {
29
29
  beforeAll(async () => {
30
- fixtures = await loadFixture(deployFixtures);
30
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
31
31
  });
32
32
 
33
33
  test('can successfully be deployed', async () => {
@@ -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;
@@ -16,7 +16,9 @@ import {
16
16
  type ContractEventName,
17
17
  type Hex,
18
18
  encodeAbiParameters,
19
+ zeroHash,
19
20
  } from 'viem';
21
+ import { AllowListIncentive as AllowListIncentiveBases } from '../../dist/deployments.json';
20
22
  import { SimpleAllowList } from '../AllowLists/AllowList';
21
23
  import type {
22
24
  DeployableOptions,
@@ -92,10 +94,12 @@ export class AllowListIncentive extends DeployableTarget<
92
94
  *
93
95
  * @public
94
96
  * @static
95
- * @type {Address}
97
+ * @type {Record<number, Address>}
96
98
  */
97
- public static override base: Address = import.meta.env
98
- .VITE_ALLOWLIST_INCENTIVE_BASE;
99
+ public static override bases: Record<number, Address> = {
100
+ 31337: import.meta.env.VITE_ALLOWLIST_INCENTIVE_BASE,
101
+ ...(AllowListIncentiveBases as Record<number, Address>),
102
+ };
99
103
  /**
100
104
  * @inheritdoc
101
105
  *
@@ -110,8 +114,8 @@ export class AllowListIncentive extends DeployableTarget<
110
114
  *
111
115
  * @public
112
116
  * @async
113
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'owner'>} [params]
114
- * @returns {unknown}
117
+ * @param {?ReadParams} [params]
118
+ * @returns {Promise<Address>}
115
119
  */
116
120
  public async owner(
117
121
  params?: ReadParams<typeof allowListIncentiveAbi, 'owner'>,
@@ -129,7 +133,7 @@ export class AllowListIncentive extends DeployableTarget<
129
133
  *
130
134
  * @public
131
135
  * @async
132
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'claims'>} [params]
136
+ * @param {?ReadParams} [params]
133
137
  * @returns {Promise<bigint>}
134
138
  */
135
139
  public async claims(
@@ -148,7 +152,7 @@ export class AllowListIncentive extends DeployableTarget<
148
152
  *
149
153
  * @public
150
154
  * @async
151
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'reward'>} [params]
155
+ * @param {?ReadParams} [params]
152
156
  * @returns {Promise<bigint>}
153
157
  */
154
158
  public async reward(
@@ -168,7 +172,7 @@ export class AllowListIncentive extends DeployableTarget<
168
172
  * @public
169
173
  * @async
170
174
  * @param {Address} address
171
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'claimed'>} [params]
175
+ * @param {?ReadParams} [params]
172
176
  * @returns {Promise<boolean>}
173
177
  */
174
178
  public async claimed(
@@ -188,7 +192,7 @@ export class AllowListIncentive extends DeployableTarget<
188
192
  *
189
193
  * @public
190
194
  * @async
191
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'allowList'>} [params]
195
+ * @param {?ReadParams} [params]
192
196
  * @returns {Promise<SimpleAllowList>}
193
197
  */
194
198
  public async allowList(
@@ -210,8 +214,8 @@ export class AllowListIncentive extends DeployableTarget<
210
214
  *
211
215
  * @public
212
216
  * @async
213
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'limit'>} [params]
214
- * @returns {unknown}
217
+ * @param {?ReadParams} [params]
218
+ * @returns {Promise<bigint>}
215
219
  */
216
220
  public async limit(
217
221
  params?: ReadParams<typeof allowListIncentiveAbi, 'limit'>,
@@ -229,7 +233,7 @@ export class AllowListIncentive extends DeployableTarget<
229
233
  * @public
230
234
  * @async
231
235
  * @param {Pick<ClaimPayload, 'target'>} payload
232
- * @param {?WriteParams<typeof allowListIncentiveAbi, 'claim'>} [params]
236
+ * @param {?WriteParams} [params]
233
237
  * @returns {Promise<true>} - return true if successful, otherwise revert
234
238
  */
235
239
  protected async claim(
@@ -245,8 +249,8 @@ export class AllowListIncentive extends DeployableTarget<
245
249
  * @public
246
250
  * @async
247
251
  * @param {Pick<ClaimPayload, 'target'>} payload
248
- * @param {?WriteParams<typeof allowListIncentiveAbi, 'claim'>} [params]
249
- * @returns {Promise<true>} - return true if successful, otherwise revert
252
+ * @param {?WriteParams} [params]
253
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - return true if successful, otherwise revert
250
254
  */
251
255
  protected async claimRaw(
252
256
  payload: Pick<ClaimPayload, 'target'>,
@@ -272,7 +276,7 @@ export class AllowListIncentive extends DeployableTarget<
272
276
  * @public
273
277
  * @async
274
278
  * @param {Pick<ClaimPayload, 'target'>} payload
275
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'isClaimable'>} [params]
279
+ * @param {?ReadParams} [params]
276
280
  * @returns {Promise<boolean>} - True if the incentive is claimable based on the data payload
277
281
  */
278
282
  public async isClaimable(
@@ -310,6 +314,17 @@ export class AllowListIncentive extends DeployableTarget<
310
314
  ...this.optionallyAttachAccount(options.account),
311
315
  };
312
316
  }
317
+
318
+ /**
319
+ * Builds the claim data for the AllowListIncentive.
320
+ *
321
+ * @public
322
+ * @returns {Hash} A `zeroHash`, as AllowListIncentive doesn't require specific claim data.
323
+ * @description This function returns `zeroHash` because AllowListIncentive doesn't use any specific claim data.
324
+ */
325
+ public buildClaimData() {
326
+ return zeroHash;
327
+ }
313
328
  }
314
329
 
315
330
  /**
@@ -1,8 +1,8 @@
1
1
  import { readMockErc20BalanceOf } from '@boostxyz/evm';
2
2
  import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
- import { isAddress, pad, parseEther } from 'viem';
3
+ import { isAddress, pad, parseEther, zeroAddress } from 'viem';
4
4
  import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
5
- import { accounts } from '../../test/accounts';
5
+ import { accounts } from '@boostxyz/test/accounts';
6
6
  import {
7
7
  type BudgetFixtures,
8
8
  type Fixtures,
@@ -10,14 +10,14 @@ import {
10
10
  deployFixtures,
11
11
  freshBoost,
12
12
  fundBudget,
13
- } from '../../test/helpers';
13
+ } from '@boostxyz/test/helpers';
14
14
  import { CGDAIncentive } from './CGDAIncentive';
15
15
 
16
16
  let fixtures: Fixtures, budgets: BudgetFixtures;
17
17
 
18
18
  describe('CGDAIncentive', () => {
19
19
  beforeAll(async () => {
20
- fixtures = await loadFixture(deployFixtures);
20
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
21
21
  });
22
22
 
23
23
  beforeEach(async () => {
@@ -31,6 +31,7 @@ describe('CGDAIncentive', () => {
31
31
  totalBudget: 10n,
32
32
  rewardBoost: 1n,
33
33
  rewardDecay: 1n,
34
+ manager: budgets.budget.address || zeroAddress
34
35
  });
35
36
  await action.deploy();
36
37
  expect(isAddress(action.assertValidAddress())).toBe(true);
@@ -41,12 +42,13 @@ describe('CGDAIncentive', () => {
41
42
  const referrer = accounts.at(1)!.account!;
42
43
  // biome-ignore lint/style/noNonNullAssertion: we know this is defined
43
44
  const trustedSigner = accounts.at(0)!;
44
- const erc20Incentive = new fixtures.bases.CGDAIncentive(defaultOptions, {
45
+ const erc20Incentive = fixtures.core.CGDAIncentive({
45
46
  asset: budgets.erc20.assertValidAddress(),
46
47
  initialReward: 1n,
47
48
  totalBudget: 10n,
48
49
  rewardBoost: 1n,
49
50
  rewardDecay: 1n,
51
+ manager: budgets.budget.assertValidAddress(),
50
52
  });
51
53
  const boost = await freshBoost(fixtures, {
52
54
  budget: budgets.budget,
@@ -86,12 +88,13 @@ describe('CGDAIncentive', () => {
86
88
  const referrer = accounts.at(1)!.account!;
87
89
  // biome-ignore lint/style/noNonNullAssertion: we know this is defined
88
90
  const trustedSigner = accounts.at(0)!;
89
- const erc20Incentive = new fixtures.bases.CGDAIncentive(defaultOptions, {
91
+ const erc20Incentive = fixtures.core.CGDAIncentive({
90
92
  asset: budgets.erc20.assertValidAddress(),
91
93
  initialReward: 1n,
92
94
  totalBudget: 10n,
93
95
  rewardBoost: 1n,
94
96
  rewardDecay: 1n,
97
+ manager: budgets.budget.address || zeroAddress
95
98
  });
96
99
  const boost = await freshBoost(fixtures, {
97
100
  budget: budgets.budget,