@boostxyz/sdk 0.0.0-alpha.8 → 1.1.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) 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 +7 -7
  4. package/dist/Actions/ContractAction.d.ts +57 -14
  5. package/dist/Actions/ContractAction.d.ts.map +1 -1
  6. package/dist/Actions/ERC721MintAction.d.ts +50 -23
  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 +420 -45
  11. package/dist/Actions/EventAction.d.ts.map +1 -1
  12. package/dist/Actions/EventAction.js +15 -225
  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 +123 -39
  25. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  26. package/dist/AllowLists/SimpleAllowList.js +75 -76
  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 +234 -13
  31. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  32. package/dist/AllowLists/SimpleDenyList.js +11 -200
  33. package/dist/AllowLists/SimpleDenyList.js.map +1 -1
  34. package/dist/Auth/PassthroughAuth.cjs +1 -1
  35. package/dist/Auth/PassthroughAuth.cjs.map +1 -1
  36. package/dist/Auth/PassthroughAuth.js +4 -4
  37. package/dist/Auth/PassthroughAuth.js.map +1 -1
  38. package/dist/Boost.cjs +1 -1
  39. package/dist/Boost.cjs.map +1 -1
  40. package/dist/Boost.d.ts +105 -14
  41. package/dist/Boost.d.ts.map +1 -1
  42. package/dist/Boost.js +137 -5
  43. package/dist/Boost.js.map +1 -1
  44. package/dist/BoostCore-BVZExPPu.js +1462 -0
  45. package/dist/BoostCore-BVZExPPu.js.map +1 -0
  46. package/dist/BoostCore-D-E-cnGI.cjs +3 -0
  47. package/dist/BoostCore-D-E-cnGI.cjs.map +1 -0
  48. package/dist/BoostCore.cjs +1 -2
  49. package/dist/BoostCore.cjs.map +1 -1
  50. package/dist/BoostCore.d.ts +759 -82
  51. package/dist/BoostCore.d.ts.map +1 -1
  52. package/dist/BoostCore.js +29 -1148
  53. package/dist/BoostCore.js.map +1 -1
  54. package/dist/BoostRegistry.cjs +1 -1
  55. package/dist/BoostRegistry.cjs.map +1 -1
  56. package/dist/BoostRegistry.d.ts +83 -28
  57. package/dist/BoostRegistry.d.ts.map +1 -1
  58. package/dist/BoostRegistry.js +170 -93
  59. package/dist/BoostRegistry.js.map +1 -1
  60. package/dist/Budgets/Budget.cjs +1 -1
  61. package/dist/Budgets/Budget.cjs.map +1 -1
  62. package/dist/Budgets/Budget.d.ts.map +1 -1
  63. package/dist/Budgets/Budget.js +2 -2
  64. package/dist/Budgets/Budget.js.map +1 -1
  65. package/dist/Budgets/ManagedBudget.cjs +1 -1
  66. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  67. package/dist/Budgets/ManagedBudget.d.ts +112 -192
  68. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  69. package/dist/Budgets/ManagedBudget.js +89 -290
  70. package/dist/Budgets/ManagedBudget.js.map +1 -1
  71. package/dist/Budgets/VestingBudget.d.ts +277 -91
  72. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  73. package/dist/Deployable/Contract.cjs +1 -1
  74. package/dist/Deployable/Contract.cjs.map +1 -1
  75. package/dist/Deployable/Contract.d.ts +4 -5
  76. package/dist/Deployable/Contract.d.ts.map +1 -1
  77. package/dist/Deployable/Contract.js +6 -8
  78. package/dist/Deployable/Contract.js.map +1 -1
  79. package/dist/Deployable/Deployable.cjs.map +1 -1
  80. package/dist/Deployable/Deployable.d.ts +1 -1
  81. package/dist/Deployable/Deployable.d.ts.map +1 -1
  82. package/dist/Deployable/Deployable.js +3 -5
  83. package/dist/Deployable/Deployable.js.map +1 -1
  84. package/dist/Deployable/DeployableTarget.cjs +1 -1
  85. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  86. package/dist/Deployable/DeployableTarget.d.ts +13 -13
  87. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  88. package/dist/Deployable/DeployableTarget.js +30 -27
  89. package/dist/Deployable/DeployableTarget.js.map +1 -1
  90. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  91. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  92. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
  93. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  94. package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
  95. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  96. package/dist/EventAction-BZt5cjbe.cjs +2 -0
  97. package/dist/EventAction-BZt5cjbe.cjs.map +1 -0
  98. package/dist/EventAction-C_-hJXWm.js +1541 -0
  99. package/dist/EventAction-C_-hJXWm.js.map +1 -0
  100. package/dist/Incentive-BhHaK3PZ.cjs +2 -0
  101. package/dist/Incentive-BhHaK3PZ.cjs.map +1 -0
  102. package/dist/Incentive-Cqg1w6wD.js +312 -0
  103. package/dist/Incentive-Cqg1w6wD.js.map +1 -0
  104. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  105. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  106. package/dist/Incentives/AllowListIncentive.d.ts +73 -21
  107. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  108. package/dist/Incentives/AllowListIncentive.js +61 -36
  109. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  110. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  111. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  112. package/dist/Incentives/CGDAIncentive.d.ts +323 -26
  113. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  114. package/dist/Incentives/CGDAIncentive.js +73 -39
  115. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  116. package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
  117. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  118. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  119. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  120. package/dist/Incentives/ERC20Incentive.d.ts +278 -33
  121. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  122. package/dist/Incentives/ERC20Incentive.js +79 -47
  123. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  124. package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +346 -420
  125. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  126. package/dist/Incentives/ERC20VariableIncentive.d.ts +271 -32
  127. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  128. package/dist/Incentives/Incentive.cjs +1 -1
  129. package/dist/Incentives/Incentive.cjs.map +1 -1
  130. package/dist/Incentives/Incentive.d.ts +4 -4
  131. package/dist/Incentives/Incentive.d.ts.map +1 -1
  132. package/dist/Incentives/Incentive.js +16 -280
  133. package/dist/Incentives/Incentive.js.map +1 -1
  134. package/dist/Incentives/PointsIncentive.cjs +1 -1
  135. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  136. package/dist/Incentives/PointsIncentive.d.ts +89 -23
  137. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  138. package/dist/Incentives/PointsIncentive.js +66 -36
  139. package/dist/Incentives/PointsIncentive.js.map +1 -1
  140. package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
  141. package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
  142. package/dist/SimpleDenyList-CGaWjuld.js +132 -0
  143. package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
  144. package/dist/Validators/SignerValidator.cjs +1 -1
  145. package/dist/Validators/SignerValidator.cjs.map +1 -1
  146. package/dist/Validators/SignerValidator.d.ts +310 -17
  147. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  148. package/dist/Validators/SignerValidator.js +164 -36
  149. package/dist/Validators/SignerValidator.js.map +1 -1
  150. package/dist/Validators/Validator.cjs +1 -1
  151. package/dist/Validators/Validator.cjs.map +1 -1
  152. package/dist/Validators/Validator.d.ts +1 -1
  153. package/dist/Validators/Validator.js +2 -2
  154. package/dist/Validators/Validator.js.map +1 -1
  155. package/dist/claiming.cjs +2 -0
  156. package/dist/claiming.cjs.map +1 -0
  157. package/dist/claiming.d.ts +43 -0
  158. package/dist/claiming.d.ts.map +1 -0
  159. package/dist/claiming.js +17 -0
  160. package/dist/claiming.js.map +1 -0
  161. package/dist/componentInterfaces-BBCFkrZv.js +14 -0
  162. package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
  163. package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
  164. package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
  165. package/dist/deployments-DVXioW2i.cjs +2 -0
  166. package/dist/deployments-DVXioW2i.cjs.map +1 -0
  167. package/dist/deployments-oykLv3_Z.js +43 -0
  168. package/dist/deployments-oykLv3_Z.js.map +1 -0
  169. package/dist/deployments.json +44 -0
  170. package/dist/errors.cjs +1 -1
  171. package/dist/errors.cjs.map +1 -1
  172. package/dist/errors.d.ts +257 -21
  173. package/dist/errors.d.ts.map +1 -1
  174. package/dist/errors.js +183 -26
  175. package/dist/errors.js.map +1 -1
  176. package/dist/{generated-Cbv8zFkf.js → generated-CKt2yCQd.js} +3615 -1868
  177. package/dist/generated-CKt2yCQd.js.map +1 -0
  178. package/dist/generated-CyTNlOwM.cjs +3 -0
  179. package/dist/generated-CyTNlOwM.cjs.map +1 -0
  180. package/dist/index.cjs +1 -1
  181. package/dist/index.d.ts +9 -4
  182. package/dist/index.d.ts.map +1 -1
  183. package/dist/index.js +143 -126
  184. package/dist/index.js.map +1 -1
  185. package/dist/transfers.cjs +2 -0
  186. package/dist/transfers.cjs.map +1 -0
  187. package/dist/transfers.d.ts +198 -0
  188. package/dist/transfers.d.ts.map +1 -0
  189. package/dist/transfers.js +84 -0
  190. package/dist/transfers.js.map +1 -0
  191. package/dist/utils.cjs +1 -1
  192. package/dist/utils.cjs.map +1 -1
  193. package/dist/utils.d.ts +25 -1380
  194. package/dist/utils.d.ts.map +1 -1
  195. package/dist/utils.js +36 -648
  196. package/dist/utils.js.map +1 -1
  197. package/package.json +34 -10
  198. package/src/Actions/Action.test.ts +19 -17
  199. package/src/Actions/ContractAction.test.ts +14 -16
  200. package/src/Actions/ContractAction.ts +84 -22
  201. package/src/Actions/ERC721MintAction.test.ts +8 -8
  202. package/src/Actions/ERC721MintAction.ts +83 -30
  203. package/src/Actions/EventAction.test.ts +759 -113
  204. package/src/Actions/EventAction.ts +991 -116
  205. package/src/AllowLists/AllowList.test.ts +7 -7
  206. package/src/AllowLists/AllowList.ts +5 -3
  207. package/src/AllowLists/OpenAllowList.test.ts +40 -0
  208. package/src/AllowLists/OpenAllowList.ts +45 -0
  209. package/src/AllowLists/SimpleAllowList.test.ts +4 -4
  210. package/src/AllowLists/SimpleAllowList.ts +86 -65
  211. package/src/AllowLists/SimpleDenyList.test.ts +4 -4
  212. package/src/AllowLists/SimpleDenyList.ts +87 -126
  213. package/src/Auth/PassthroughAuth.test.ts +1 -1
  214. package/src/Auth/PassthroughAuth.ts +1 -1
  215. package/src/Boost.ts +147 -15
  216. package/src/BoostCore.test.ts +326 -278
  217. package/src/BoostCore.ts +425 -242
  218. package/src/BoostRegistry.test.ts +53 -0
  219. package/src/BoostRegistry.ts +168 -50
  220. package/src/Budgets/Budget.test.ts +2 -2
  221. package/src/Budgets/Budget.ts +1 -2
  222. package/src/Budgets/ManagedBudget.test.ts +82 -19
  223. package/src/Budgets/ManagedBudget.ts +106 -315
  224. package/src/Budgets/VestingBudget.test.ts +7 -7
  225. package/src/Budgets/VestingBudget.ts +110 -112
  226. package/src/Deployable/Contract.ts +5 -6
  227. package/src/Deployable/Deployable.ts +1 -1
  228. package/src/Deployable/DeployableTarget.ts +32 -21
  229. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  230. package/src/Incentives/AllowListIncentive.test.ts +7 -10
  231. package/src/Incentives/AllowListIncentive.ts +88 -30
  232. package/src/Incentives/CGDAIncentive.test.ts +11 -12
  233. package/src/Incentives/CGDAIncentive.ts +161 -37
  234. package/src/Incentives/ERC1155Incentive.test.ts +5 -16
  235. package/src/Incentives/ERC1155Incentive.ts +132 -51
  236. package/src/Incentives/ERC20Incentive.test.ts +15 -23
  237. package/src/Incentives/ERC20Incentive.ts +131 -46
  238. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  239. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
  240. package/src/Incentives/ERC20VariableIncentive.test.ts +12 -35
  241. package/src/Incentives/ERC20VariableIncentive.ts +118 -43
  242. package/src/Incentives/Incentive.test.ts +5 -2
  243. package/src/Incentives/Incentive.ts +7 -6
  244. package/src/Incentives/PointsIncentive.test.ts +26 -30
  245. package/src/Incentives/PointsIncentive.ts +110 -34
  246. package/src/Validators/SignerValidator.test.ts +9 -13
  247. package/src/Validators/SignerValidator.ts +437 -26
  248. package/src/Validators/Validator.test.ts +2 -2
  249. package/src/Validators/Validator.ts +1 -1
  250. package/src/claiming.ts +56 -0
  251. package/src/errors.ts +346 -22
  252. package/src/index.test.ts +118 -36
  253. package/src/index.ts +15 -7
  254. package/src/transfers.ts +284 -0
  255. package/src/utils.test.ts +2 -2
  256. package/src/utils.ts +61 -2061
  257. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  258. package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
  259. package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
  260. package/dist/componentInterfaces-DYkaxBda.js +0 -13
  261. package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
  262. package/dist/generated-BzszviNp.cjs +0 -3
  263. package/dist/generated-BzszviNp.cjs.map +0 -1
  264. package/dist/generated-Cbv8zFkf.js.map +0 -1
  265. package/src/Budgets/SimpleBudget.test.ts +0 -152
  266. package/src/Budgets/SimpleBudget.ts +0 -521
@@ -0,0 +1,323 @@
1
+ import {
2
+ rbacAbi,
3
+ readRbacHasAllRoles,
4
+ readRbacHasAnyRole,
5
+ readRbacIsAuthorized,
6
+ readRbacRolesOf,
7
+ simulateRbacGrantRoles,
8
+ simulateRbacRevokeRoles,
9
+ simulateRbacSetAuthorized,
10
+ writeRbacGrantRoles,
11
+ writeRbacRevokeRoles,
12
+ writeRbacSetAuthorized,
13
+ } from '@boostxyz/evm';
14
+ import type { Abi, Address, ContractEventName } from 'viem';
15
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
16
+ import type { GenericLog, ReadParams, WriteParams } from '../utils';
17
+ export { rbacAbi };
18
+
19
+ /**
20
+ * Enum representing available roles for use with the `RBAC` authorization scheme.
21
+ * `MANAGER` has lowest level of write permissions, for specific implementations, see Budgets and ALlowLists
22
+ * `ADMIN` can additionally manage authorized users on the contract.
23
+ *
24
+ * @export
25
+ * @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}
26
+ * @enum {bigint}
27
+ */
28
+ export enum Roles {
29
+ //@ts-expect-error ts doesn't like bigint enum values
30
+ MANAGER = 1n,
31
+ //@ts-expect-error ts doesn't like bigint enum values
32
+ ADMIN = 2n,
33
+ }
34
+
35
+ /**
36
+ * A generic `viem.Log` event with support for `Rbac` event types.
37
+ *
38
+ * @export
39
+ * @typedef {RBACLog}
40
+ * @template {ContractEventName<typeof rbacAbi>} [event=ContractEventName<
41
+ * typeof rbacAbi
42
+ * >]
43
+ */
44
+ export type RBACLog<
45
+ event extends ContractEventName<typeof rbacAbi> = ContractEventName<
46
+ typeof rbacAbi
47
+ >,
48
+ > = GenericLog<typeof rbacAbi, event>;
49
+
50
+ /**
51
+ * A minimal RBAC implementation that offers MANAGER and ADMIN roles, and
52
+ * Budgets and allowlists support this auth scheme
53
+ *
54
+ * @export
55
+ * @class DeployableTargetWithRBAC
56
+ * @typedef {DeployableTargetWithRBAC}
57
+ * @extends {DeployableTarget<RbacPayload>}
58
+ */
59
+ export class DeployableTargetWithRBAC<
60
+ Payload,
61
+ ABI extends Abi,
62
+ > extends DeployableTarget<Payload, ABI> {
63
+ /**
64
+ * Set the authorized status of the given accounts
65
+ * The mechanism for managing authorization is left to the implementing contract
66
+ *
67
+ * @public
68
+ * @async
69
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
70
+ * @param {boolean[]} allowed - The authorization status for the given accounts
71
+ * @param {?WriteParams} [params]
72
+ * @returns {Promise<void>}
73
+ */
74
+ public async setAuthorized(
75
+ addresses: Address[],
76
+ allowed: boolean[],
77
+ params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,
78
+ ) {
79
+ return await this.awaitResult(
80
+ this.setAuthorizedRaw(addresses, allowed, params),
81
+ );
82
+ }
83
+
84
+ /**
85
+ * Set the authorized status of the given accounts
86
+ * The mechanism for managing authorization is left to the implementing contract
87
+ *
88
+ * @public
89
+ * @async
90
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
91
+ * @param {boolean[]} allowed - The authorization status for the given accounts
92
+ * @param {?WriteParams} [params]
93
+ * @returns {Promise<void>}
94
+ */
95
+ public async setAuthorizedRaw(
96
+ addresses: Address[],
97
+ allowed: boolean[],
98
+ params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,
99
+ ) {
100
+ const { request, result } = await simulateRbacSetAuthorized(this._config, {
101
+ address: this.assertValidAddress(),
102
+ args: [addresses, allowed],
103
+ ...this.optionallyAttachAccount(),
104
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
105
+ ...(params as any),
106
+ });
107
+ const hash = await writeRbacSetAuthorized(this._config, request);
108
+ return { hash, result };
109
+ }
110
+
111
+ /**
112
+ * Grant many accounts permissions on the rbac.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * await rbac.grantRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])
117
+ * ```
118
+ * @public
119
+ * @async
120
+ * @param {Address[]} addresses
121
+ * @param {RbacRoles[]} roles
122
+ * @param {?WriteParams} [params]
123
+ * @returns {Promise<void>}
124
+ */
125
+ public async grantRoles(
126
+ addresses: Address[],
127
+ roles: Roles[],
128
+ params?: WriteParams<typeof rbacAbi, 'grantRoles'>,
129
+ ) {
130
+ return await this.awaitResult(this.grantRolesRaw(addresses, roles, params));
131
+ }
132
+
133
+ /**
134
+ * Grant many accounts permissions on the rbac.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * await rbac.grantRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
139
+ *
140
+ * @public
141
+ * @async
142
+ * @param {Address[]} addresses
143
+ * @param {RbacRoles[]} roles
144
+ * @param {?WriteParams} [params]
145
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
146
+ */
147
+ public async grantRolesRaw(
148
+ addresses: Address[],
149
+ roles: Roles[],
150
+ params?: WriteParams<typeof rbacAbi, 'grantRoles'>,
151
+ ) {
152
+ const { request, result } = await simulateRbacGrantRoles(this._config, {
153
+ address: this.assertValidAddress(),
154
+ args: [addresses, roles],
155
+ ...this.optionallyAttachAccount(),
156
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
157
+ ...(params as any),
158
+ });
159
+ const hash = await writeRbacGrantRoles(
160
+ this._config,
161
+ // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
162
+ request as any,
163
+ );
164
+ return { hash, result };
165
+ }
166
+
167
+ /**
168
+ * Revoke many accounts' permissions on the rbac.
169
+ *
170
+ * @example
171
+ * ```ts
172
+ * await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])
173
+ *
174
+ * @public
175
+ * @async
176
+ * @param {Address[]} addresses
177
+ * @param {RbacRoles[]} roles
178
+ * @param {?WriteParams} [params]
179
+ * @returns {Promise<void>}
180
+ */
181
+ public async revokeRoles(
182
+ addresses: Address[],
183
+ roles: Roles[],
184
+ params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,
185
+ ) {
186
+ return await this.awaitResult(
187
+ this.revokeRolesRaw(addresses, roles, params),
188
+ );
189
+ }
190
+
191
+ /**
192
+ * Revoke many accounts' permissions on the rbac.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])
197
+ * @public
198
+ * @async
199
+ * @param {Address[]} addresses
200
+ * @param {RbacRoles[]} roles
201
+ * @param {?WriteParams} [params]
202
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
203
+ */
204
+ public async revokeRolesRaw(
205
+ addresses: Address[],
206
+ roles: Roles[],
207
+ params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,
208
+ ) {
209
+ const { request, result } = await simulateRbacRevokeRoles(this._config, {
210
+ address: this.assertValidAddress(),
211
+ args: [addresses, roles],
212
+ ...this.optionallyAttachAccount(),
213
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
214
+ ...(params as any),
215
+ });
216
+ const hash = await writeRbacRevokeRoles(
217
+ this._config,
218
+ // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
219
+ request as any,
220
+ );
221
+ return { hash, result };
222
+ }
223
+
224
+ /**
225
+ * Return an array of the roles assigned to the given account.
226
+ * @example
227
+ * ```ts
228
+ * (await rbac.rolesOf(0xfoo)).includes(RbacRoles.ADMIN)
229
+ * @public
230
+ * @param {Address} account
231
+ * @param {?ReadParams} [params]
232
+ * @returns {Promise<Array<RbacRoles>>}
233
+ */
234
+ public async rolesOf(
235
+ account: Address,
236
+ params?: ReadParams<typeof rbacAbi, 'rolesOf'>,
237
+ ) {
238
+ const roles = await readRbacRolesOf(this._config, {
239
+ address: this.assertValidAddress(),
240
+ args: [account],
241
+ ...this.optionallyAttachAccount(),
242
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
243
+ ...(params as any),
244
+ });
245
+ return ([Roles.MANAGER, Roles.ADMIN] as unknown as Array<bigint>).filter(
246
+ (role) => (roles & role) === role,
247
+ ) as unknown as Roles[];
248
+ }
249
+
250
+ /**
251
+ * Returns whether given account has any of the provided roles bitmap.
252
+ *
253
+ * @example
254
+ * ```ts
255
+ * await rbac.hasAnyRole(0xfoo, RbacRoles.ADMIN | RbacRoles.MANAGER)
256
+ * @public
257
+ * @param {Address} account
258
+ * @param {RbacRoles} roles
259
+ * @param {?ReadParams} [params]
260
+ * @returns {Promise<boolean>}
261
+ */
262
+ public hasAnyRole(
263
+ account: Address,
264
+ roles: Roles,
265
+ params?: ReadParams<typeof rbacAbi, 'hasAnyRole'>,
266
+ ) {
267
+ return readRbacHasAnyRole(this._config, {
268
+ address: this.assertValidAddress(),
269
+ args: [account, roles],
270
+ ...this.optionallyAttachAccount(),
271
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
272
+ ...(params as any),
273
+ });
274
+ }
275
+
276
+ /**
277
+ * Returns whether given account has all of the provided roles bitmap.
278
+ *
279
+ * @example
280
+ * ```ts
281
+ * await rbac.hasAllRoles(0xfoo, RbacRoles.ADMIN & RbacRoles.MANAGER)
282
+ *
283
+ * @public
284
+ * @param {Address} account
285
+ * @param {RbacRoles} roles
286
+ * @param {?ReadParams} [params]
287
+ * @returns {Promise<boolean>}
288
+ */
289
+ public hasAllRoles(
290
+ account: Address,
291
+ roles: Roles,
292
+ params?: ReadParams<typeof rbacAbi, 'hasAllRoles'>,
293
+ ) {
294
+ return readRbacHasAllRoles(this._config, {
295
+ address: this.assertValidAddress(),
296
+ args: [account, roles],
297
+ ...this.optionallyAttachAccount(),
298
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
299
+ ...(params as any),
300
+ });
301
+ }
302
+
303
+ /**
304
+ * Check if the given account is authorized to use the rbac
305
+ *
306
+ * @public
307
+ * @param {Address} account
308
+ * @param {?ReadParams} [params]
309
+ * @returns {Promise<boolean>} - True if the account is authorized
310
+ */
311
+ public isAuthorized(
312
+ account: Address,
313
+ params?: ReadParams<typeof rbacAbi, 'isAuthorized'>,
314
+ ) {
315
+ return readRbacIsAuthorized(this._config, {
316
+ address: this.assertValidAddress(),
317
+ args: [account],
318
+ ...this.optionallyAttachAccount(),
319
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
320
+ ...(params as any),
321
+ });
322
+ }
323
+ }
@@ -1,24 +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';
10
+ } from '@boostxyz/test/helpers';
11
11
  import { LIST_MANAGER_ROLE } from '../AllowLists/SimpleAllowList';
12
- import { prepareSignerValidatorClaimDataPayload } from '../utils';
13
12
  import { PointsIncentive } from './PointsIncentive';
14
13
 
15
14
  let fixtures: Fixtures;
16
15
 
17
16
  function freshAllowList(fixtures: Fixtures) {
18
17
  return function freshAllowList() {
19
- return fixtures.registry.clone(
18
+ return fixtures.registry.initialize(
20
19
  crypto.randomUUID(),
21
- new fixtures.bases.SimpleAllowList(defaultOptions, {
20
+ fixtures.core.SimpleAllowList({
22
21
  owner: defaultOptions.account.address,
23
22
  allowed: [],
24
23
  }),
@@ -28,7 +27,7 @@ function freshAllowList(fixtures: Fixtures) {
28
27
 
29
28
  describe('AllowListIncentive', () => {
30
29
  beforeAll(async () => {
31
- fixtures = await loadFixture(deployFixtures);
30
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
32
31
  });
33
32
 
34
33
  test('can successfully be deployed', async () => {
@@ -68,11 +67,10 @@ describe('AllowListIncentive', () => {
68
67
  console.log(claimant);
69
68
 
70
69
  const incentiveQuantity = 1;
71
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
70
+ const claimDataPayload = await boost.validator.encodeClaimData({
72
71
  signer: trustedSigner,
73
72
  incentiveData,
74
73
  chainId: defaultOptions.config.chains[0].id,
75
- validator: boost.validator.assertValidAddress(),
76
74
  incentiveQuantity,
77
75
  claimant,
78
76
  boostId: boost.id,
@@ -114,11 +112,10 @@ describe('AllowListIncentive', () => {
114
112
  const incentiveData = pad('0xdef456232173821931823712381232131391321934');
115
113
  console.log(claimant);
116
114
 
117
- const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
115
+ const claimDataPayload = await boost.validator.encodeClaimData({
118
116
  signer: trustedSigner,
119
117
  incentiveData,
120
118
  chainId: defaultOptions.config.chains[0].id,
121
- validator: boost.validator.assertValidAddress(),
122
119
  incentiveQuantity,
123
120
  claimant,
124
121
  boostId: boost.id,
@@ -11,26 +11,51 @@ import {
11
11
  writeAllowListIncentiveClaim,
12
12
  } from '@boostxyz/evm';
13
13
  import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/AllowListIncentive.sol/AllowListIncentive.json';
14
- import type { Address, ContractEventName, Hex } from 'viem';
14
+ import {
15
+ type Address,
16
+ type ContractEventName,
17
+ type Hex,
18
+ encodeAbiParameters,
19
+ zeroHash,
20
+ } from 'viem';
21
+ import { AllowListIncentive as AllowListIncentiveBases } from '../../dist/deployments.json';
15
22
  import { SimpleAllowList } from '../AllowLists/AllowList';
16
23
  import type {
17
24
  DeployableOptions,
18
25
  GenericDeployableParams,
19
26
  } from '../Deployable/Deployable';
20
27
  import { DeployableTarget } from '../Deployable/DeployableTarget';
28
+ import { type ClaimPayload, prepareClaimPayload } from '../claiming';
21
29
  import {
22
- type AllowListIncentivePayload,
23
- type ClaimPayload,
24
30
  type GenericLog,
25
31
  type ReadParams,
26
32
  RegistryType,
27
33
  type WriteParams,
28
- prepareAllowListIncentivePayload,
29
- prepareClaimPayload,
30
34
  } from '../utils';
31
35
 
32
36
  export { allowListIncentiveAbi };
33
- export type { AllowListIncentivePayload };
37
+
38
+ /**
39
+ * The object representation of a `AllowListIncentive.InitPayload`
40
+ *
41
+ * @export
42
+ * @interface AllowListIncentivePayload
43
+ * @typedef {AllowListIncentivePayload}
44
+ */
45
+ export interface AllowListIncentivePayload {
46
+ /**
47
+ * The address to the allowlist to add claimers to.
48
+ *
49
+ * @type {Address}
50
+ */
51
+ allowList: Address;
52
+ /**
53
+ * The maximum number of claims that can be made (one per address)
54
+ *
55
+ * @type {bigint}
56
+ */
57
+ limit: bigint;
58
+ }
34
59
 
35
60
  /**
36
61
  * A generic `viem.Log` event with support for `AllowListIncentive` event types.
@@ -69,10 +94,11 @@ export class AllowListIncentive extends DeployableTarget<
69
94
  *
70
95
  * @public
71
96
  * @static
72
- * @type {Address}
97
+ * @type {Record<number, Address>}
73
98
  */
74
- public static override base: Address = import.meta.env
75
- .VITE_ALLOWLIST_INCENTIVE_BASE;
99
+ public static override bases: Record<number, Address> = {
100
+ ...(AllowListIncentiveBases as Record<number, Address>),
101
+ };
76
102
  /**
77
103
  * @inheritdoc
78
104
  *
@@ -87,13 +113,13 @@ export class AllowListIncentive extends DeployableTarget<
87
113
  *
88
114
  * @public
89
115
  * @async
90
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'owner'>} [params]
91
- * @returns {unknown}
116
+ * @param {?ReadParams} [params]
117
+ * @returns {Promise<Address>}
92
118
  */
93
119
  public async owner(
94
120
  params?: ReadParams<typeof allowListIncentiveAbi, 'owner'>,
95
121
  ) {
96
- return readAllowListIncentiveOwner(this._config, {
122
+ return await readAllowListIncentiveOwner(this._config, {
97
123
  address: this.assertValidAddress(),
98
124
  args: [],
99
125
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -106,13 +132,13 @@ export class AllowListIncentive extends DeployableTarget<
106
132
  *
107
133
  * @public
108
134
  * @async
109
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'claims'>} [params]
135
+ * @param {?ReadParams} [params]
110
136
  * @returns {Promise<bigint>}
111
137
  */
112
138
  public async claims(
113
139
  params?: ReadParams<typeof allowListIncentiveAbi, 'claims'>,
114
140
  ) {
115
- return readAllowListIncentiveClaims(this._config, {
141
+ return await readAllowListIncentiveClaims(this._config, {
116
142
  address: this.assertValidAddress(),
117
143
  args: [],
118
144
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -125,13 +151,13 @@ export class AllowListIncentive extends DeployableTarget<
125
151
  *
126
152
  * @public
127
153
  * @async
128
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'reward'>} [params]
154
+ * @param {?ReadParams} [params]
129
155
  * @returns {Promise<bigint>}
130
156
  */
131
157
  public async reward(
132
158
  params?: ReadParams<typeof allowListIncentiveAbi, 'reward'>,
133
159
  ) {
134
- return readAllowListIncentiveReward(this._config, {
160
+ return await readAllowListIncentiveReward(this._config, {
135
161
  address: this.assertValidAddress(),
136
162
  args: [],
137
163
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -145,14 +171,14 @@ export class AllowListIncentive extends DeployableTarget<
145
171
  * @public
146
172
  * @async
147
173
  * @param {Address} address
148
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'claimed'>} [params]
174
+ * @param {?ReadParams} [params]
149
175
  * @returns {Promise<boolean>}
150
176
  */
151
177
  public async claimed(
152
178
  address: Address,
153
179
  params?: ReadParams<typeof allowListIncentiveAbi, 'claimed'>,
154
180
  ) {
155
- return readAllowListIncentiveClaimed(this._config, {
181
+ return await readAllowListIncentiveClaimed(this._config, {
156
182
  address: this.assertValidAddress(),
157
183
  args: [address],
158
184
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -165,7 +191,7 @@ export class AllowListIncentive extends DeployableTarget<
165
191
  *
166
192
  * @public
167
193
  * @async
168
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'allowList'>} [params]
194
+ * @param {?ReadParams} [params]
169
195
  * @returns {Promise<SimpleAllowList>}
170
196
  */
171
197
  public async allowList(
@@ -187,13 +213,13 @@ export class AllowListIncentive extends DeployableTarget<
187
213
  *
188
214
  * @public
189
215
  * @async
190
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'limit'>} [params]
191
- * @returns {unknown}
216
+ * @param {?ReadParams} [params]
217
+ * @returns {Promise<bigint>}
192
218
  */
193
219
  public async limit(
194
220
  params?: ReadParams<typeof allowListIncentiveAbi, 'limit'>,
195
221
  ) {
196
- return readAllowListIncentiveLimit(this._config, {
222
+ return await readAllowListIncentiveLimit(this._config, {
197
223
  address: this.assertValidAddress(),
198
224
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
199
225
  ...(params as any),
@@ -206,14 +232,14 @@ export class AllowListIncentive extends DeployableTarget<
206
232
  * @public
207
233
  * @async
208
234
  * @param {Pick<ClaimPayload, 'target'>} payload
209
- * @param {?WriteParams<typeof allowListIncentiveAbi, 'claim'>} [params]
235
+ * @param {?WriteParams} [params]
210
236
  * @returns {Promise<true>} - return true if successful, otherwise revert
211
237
  */
212
- public async claim(
238
+ protected async claim(
213
239
  payload: Pick<ClaimPayload, 'target'>,
214
240
  params?: WriteParams<typeof allowListIncentiveAbi, 'claim'>,
215
241
  ) {
216
- return this.awaitResult(this.claimRaw(payload, params));
242
+ return await this.awaitResult(this.claimRaw(payload, params));
217
243
  }
218
244
 
219
245
  /**
@@ -222,10 +248,10 @@ export class AllowListIncentive extends DeployableTarget<
222
248
  * @public
223
249
  * @async
224
250
  * @param {Pick<ClaimPayload, 'target'>} payload
225
- * @param {?WriteParams<typeof allowListIncentiveAbi, 'claim'>} [params]
226
- * @returns {Promise<true>} - return true if successful, otherwise revert
251
+ * @param {?WriteParams} [params]
252
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - return true if successful, otherwise revert
227
253
  */
228
- public async claimRaw(
254
+ protected async claimRaw(
229
255
  payload: Pick<ClaimPayload, 'target'>,
230
256
  params?: WriteParams<typeof allowListIncentiveAbi, 'claim'>,
231
257
  ) {
@@ -249,14 +275,14 @@ export class AllowListIncentive extends DeployableTarget<
249
275
  * @public
250
276
  * @async
251
277
  * @param {Pick<ClaimPayload, 'target'>} payload
252
- * @param {?ReadParams<typeof allowListIncentiveAbi, 'isClaimable'>} [params]
278
+ * @param {?ReadParams} [params]
253
279
  * @returns {Promise<boolean>} - True if the incentive is claimable based on the data payload
254
280
  */
255
281
  public async isClaimable(
256
282
  payload: Pick<ClaimPayload, 'target'>,
257
283
  params?: ReadParams<typeof allowListIncentiveAbi, 'isClaimable'>,
258
284
  ) {
259
- return readAllowListIncentiveIsClaimable(this._config, {
285
+ return await readAllowListIncentiveIsClaimable(this._config, {
260
286
  address: this.assertValidAddress(),
261
287
  args: [prepareClaimPayload(payload)],
262
288
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
@@ -287,4 +313,36 @@ export class AllowListIncentive extends DeployableTarget<
287
313
  ...this.optionallyAttachAccount(options.account),
288
314
  };
289
315
  }
316
+
317
+ /**
318
+ * Builds the claim data for the AllowListIncentive.
319
+ *
320
+ * @public
321
+ * @returns {Hash} A `zeroHash`, as AllowListIncentive doesn't require specific claim data.
322
+ * @description This function returns `zeroHash` because AllowListIncentive doesn't use any specific claim data.
323
+ */
324
+ public buildClaimData() {
325
+ return zeroHash;
326
+ }
290
327
  }
328
+
329
+ /**
330
+ * Given a {@link AllowListIncentivePayload}, properly encode a `AllowListIncentive.InitPayload` for use with {@link AllowListIncentive} initialization.
331
+ *
332
+ * @param {AllowListIncentivePayload} param0
333
+ * @param {Address} param0.allowList - The address to the allowlist to add claimers to.
334
+ * @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
335
+ * @returns {Hex}
336
+ */
337
+ export const prepareAllowListIncentivePayload = ({
338
+ allowList,
339
+ limit,
340
+ }: AllowListIncentivePayload) => {
341
+ return encodeAbiParameters(
342
+ [
343
+ { type: 'address', name: 'allowList' },
344
+ { type: 'uint256', name: 'limit' },
345
+ ],
346
+ [allowList, limit],
347
+ );
348
+ };