@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
@@ -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';
@@ -33,11 +23,12 @@ import {
33
23
  parseAbiParameters,
34
24
  zeroAddress,
35
25
  } from 'viem';
26
+ import { ManagedBudget as ManagedBudgetBases } from '../../dist/deployments.json';
36
27
  import type {
37
28
  DeployableOptions,
38
29
  GenericDeployableParams,
39
30
  } from '../Deployable/Deployable';
40
- import { DeployableTarget } from '../Deployable/DeployableTarget';
31
+ import { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';
41
32
  import {
42
33
  DeployableUnknownOwnerProvidedError,
43
34
  UnknownTransferPayloadSupplied,
@@ -54,7 +45,6 @@ import {
54
45
  RegistryType,
55
46
  type WriteParams,
56
47
  } from '../utils';
57
-
58
48
  export { managedBudgetAbi };
59
49
  export type { ERC1155TransferPayload, FungibleTransferPayload };
60
50
 
@@ -81,22 +71,26 @@ export interface ManagedBudgetPayload {
81
71
  /**
82
72
  * List of roles to assign to the corresponding account by index.
83
73
  *
84
- * @type {bigint[]}
74
+ * @type {ManagedBudgetRoles[]}
85
75
  */
86
- roles: bigint[];
76
+ roles: ManagedBudgetRoles[];
87
77
  }
88
78
 
89
79
  /**
90
- * Enum representing available roles for use in the `ManagedBudget`.
80
+ * Enum representing available roles for use in the `ManagedBudget`.
91
81
  * `MANAGER` can disburse funds.
92
82
  * `ADMIN` can additionally manage authorized users on the budget.
93
83
  *
84
+ * @export
94
85
  * @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}
86
+ * @enum {bigint}
95
87
  */
96
- export const ManagedBudgetRoles = {
97
- MANAGER: 1n,
98
- ADMIN: 2n,
99
- } as const;
88
+ export enum ManagedBudgetRoles {
89
+ //@ts-expect-error ts doesn't like bigint enum values
90
+ MANAGER = 1n,
91
+ //@ts-expect-error ts doesn't like bigint enum values
92
+ ADMIN = 2n,
93
+ }
100
94
 
101
95
  /**
102
96
  * A generic `viem.Log` event with support for `ManagedBudget` event types.
@@ -144,7 +138,7 @@ export function isERC1155TransferPayload(
144
138
  *
145
139
  * @export
146
140
  * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
147
- * @returns {*}
141
+ * @returns {Hex}
148
142
  * @throws {@link UnknownTransferPayloadSupplied}
149
143
  */
150
144
  export function prepareTransfer(
@@ -152,9 +146,11 @@ export function prepareTransfer(
152
146
  ) {
153
147
  if (isFungibleTransfer(transfer)) {
154
148
  return prepareFungibleTransfer(transfer);
155
- } else if (isERC1155TransferPayload(transfer)) {
149
+ }
150
+ if (isERC1155TransferPayload(transfer)) {
156
151
  return prepareERC1155Transfer(transfer);
157
- } else throw new UnknownTransferPayloadSupplied(transfer);
152
+ }
153
+ throw new UnknownTransferPayloadSupplied(transfer);
158
154
  }
159
155
 
160
156
  /**
@@ -164,9 +160,9 @@ export function prepareTransfer(
164
160
  * @export
165
161
  * @class ManagedBudget
166
162
  * @typedef {ManagedBudget}
167
- * @extends {DeployableTarget<ManagedBudgetPayload>}
163
+ * @extends {DeployableTargetWithRBAC<ManagedBudgetPayload>}
168
164
  */
169
- export class ManagedBudget extends DeployableTarget<
165
+ export class ManagedBudget extends DeployableTargetWithRBAC<
170
166
  ManagedBudgetPayload,
171
167
  typeof managedBudgetAbi
172
168
  > {
@@ -183,10 +179,12 @@ export class ManagedBudget extends DeployableTarget<
183
179
  *
184
180
  * @public
185
181
  * @static
186
- * @type {Address}
182
+ * @type {Record<number, Address>}
187
183
  */
188
- public static override base: Address = import.meta.env
189
- .VITE_MANAGED_BUDGET_BASE;
184
+ public static override bases: Record<number, Address> = {
185
+ 31337: import.meta.env.VITE_MANAGED_BUDGET_BASE,
186
+ ...(ManagedBudgetBases as Record<number, Address>),
187
+ };
190
188
  /**
191
189
  * @inheritdoc
192
190
  *
@@ -204,7 +202,7 @@ export class ManagedBudget extends DeployableTarget<
204
202
  * @public
205
203
  * @async
206
204
  * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
207
- * @param {?WriteParams<typeof managedBudgetAbi, 'allocate'>} [params]
205
+ * @param {?WriteParams} [params]
208
206
  * @returns {Promise<boolean>} - True if the allocation was successful
209
207
  */
210
208
  public async allocate(
@@ -222,8 +220,8 @@ export class ManagedBudget extends DeployableTarget<
222
220
  * @public
223
221
  * @async
224
222
  * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
225
- * @param {?WriteParams<typeof managedBudgetAbi, 'allocate'>} [params]
226
- * @returns {Promise<boolean>} - True if the allocation was successful
223
+ * @param {?WriteParams} [params]
224
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the allocation was successful
227
225
  */
228
226
  public async allocateRaw(
229
227
  transfer: FungibleTransferPayload | ERC1155TransferPayload,
@@ -252,7 +250,7 @@ export class ManagedBudget extends DeployableTarget<
252
250
  * @public
253
251
  * @async
254
252
  * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
255
- * @param {?WriteParams<typeof managedBudgetAbi, 'clawback'>} [params]
253
+ * @param {?WriteParams} [params]
256
254
  * @returns {Promise<boolean>} - True if the request was successful
257
255
  */
258
256
  public async clawback(
@@ -271,8 +269,8 @@ export class ManagedBudget extends DeployableTarget<
271
269
  * @public
272
270
  * @async
273
271
  * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
274
- * @param {?WriteParams<typeof managedBudgetAbi, 'clawback'>} [params]
275
- * @returns {Promise<boolean>} - True if the request was successful
272
+ * @param {?WriteParams} [params]
273
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the request was successful
276
274
  */
277
275
  public async clawbackRaw(
278
276
  transfer: FungibleTransferPayload | ERC1155TransferPayload,
@@ -299,7 +297,7 @@ export class ManagedBudget extends DeployableTarget<
299
297
  * @public
300
298
  * @async
301
299
  * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
302
- * @param {?WriteParams<typeof managedBudgetAbi, 'disburse'>} [params]
300
+ * @param {?WriteParams} [params]
303
301
  * @returns {Promise<boolean>} - True if the disbursement was successful
304
302
  */
305
303
  public async disburse(
@@ -316,8 +314,8 @@ export class ManagedBudget extends DeployableTarget<
316
314
  * @public
317
315
  * @async
318
316
  * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
319
- * @param {?WriteParams<typeof managedBudgetAbi, 'disburse'>} [params]
320
- * @returns {Promise<boolean>} - True if the disbursement was successful
317
+ * @param {?WriteParams} [params]
318
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the disbursement was successful
321
319
  */
322
320
  public async disburseRaw(
323
321
  transfer: FungibleTransferPayload | ERC1155TransferPayload,
@@ -343,7 +341,7 @@ export class ManagedBudget extends DeployableTarget<
343
341
  * @public
344
342
  * @async
345
343
  * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
346
- * @param {?WriteParams<typeof managedBudgetAbi, 'disburseBatch'>} [params]
344
+ * @param {?WriteParams} [params]
347
345
  * @returns {Promise<boolean>} - True if all disbursements were successful
348
346
  */
349
347
  public async disburseBatch(
@@ -359,8 +357,8 @@ export class ManagedBudget extends DeployableTarget<
359
357
  * @public
360
358
  * @async
361
359
  * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
362
- * @param {?WriteParams<typeof managedBudgetAbi, 'disburseBatch'>} [params]
363
- * @returns {Promise<boolean>} - True if all disbursements were successful
360
+ * @param {?WriteParams} [params]
361
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if all disbursements were successful
364
362
  */
365
363
  public async disburseBatchRaw(
366
364
  transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
@@ -380,281 +378,11 @@ export class ManagedBudget extends DeployableTarget<
380
378
  return { hash, result };
381
379
  }
382
380
 
383
- /**
384
- * Set the authorized status of the given accounts
385
- * The mechanism for managing authorization is left to the implementing contract
386
- *
387
- * @public
388
- * @async
389
- * @param {Address[]} addresses - The accounts to authorize or deauthorize
390
- * @param {boolean[]} allowed - The authorization status for the given accounts
391
- * @param {?WriteParams<typeof managedBudgetAbi, 'setAuthorized'>} [params]
392
- * @returns {Promise<void>}
393
- */
394
- public async setAuthorized(
395
- addresses: Address[],
396
- allowed: boolean[],
397
- params?: WriteParams<typeof managedBudgetAbi, 'setAuthorized'>,
398
- ) {
399
- return await this.awaitResult(
400
- this.setAuthorizedRaw(addresses, allowed, params),
401
- );
402
- }
403
-
404
- /**
405
- * Set the authorized status of the given accounts
406
- * The mechanism for managing authorization is left to the implementing contract
407
- *
408
- * @public
409
- * @async
410
- * @param {Address[]} addresses - The accounts to authorize or deauthorize
411
- * @param {boolean[]} allowed - The authorization status for the given accounts
412
- * @param {?WriteParams<typeof managedBudgetAbi, 'setAuthorized'>} [params]
413
- * @returns {Promise<void>}
414
- */
415
- public async setAuthorizedRaw(
416
- addresses: Address[],
417
- allowed: boolean[],
418
- params?: WriteParams<typeof managedBudgetAbi, 'setAuthorized'>,
419
- ) {
420
- const { request, result } = await simulateManagedBudgetSetAuthorized(
421
- this._config,
422
- {
423
- address: this.assertValidAddress(),
424
- args: [addresses, allowed],
425
- ...this.optionallyAttachAccount(),
426
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
427
- ...(params as any),
428
- },
429
- );
430
- const hash = await writeManagedBudgetSetAuthorized(this._config, request);
431
- return { hash, result };
432
- }
433
-
434
- /**
435
- * Grant many accounts permissions on the budget.
436
- *
437
- * @example
438
- * ```ts
439
- * await budget.grantRoles(['0xfoo', '0xbar], [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN])
440
- * ```
441
- * @public
442
- * @async
443
- * @param {Address[]} addresses
444
- * @param {bigint[]} roles
445
- * @param {?WriteParams<typeof managedBudgetAbi, 'grantRoles'>} [params]
446
- * @returns {unknown}
447
- */
448
- public async grantRoles(
449
- addresses: Address[],
450
- roles: bigint[],
451
- params?: WriteParams<typeof managedBudgetAbi, 'grantRoles'>,
452
- ) {
453
- return await this.awaitResult(this.grantRolesRaw(addresses, roles, params));
454
- }
455
-
456
- /**
457
- * Grant many accounts permissions on the budget.
458
- *
459
- * @example
460
- * ```ts
461
- * await budget.grantRoles(['0xfoo', '0xbar], [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN])
462
- *
463
- * @public
464
- * @async
465
- * @param {Address[]} addresses
466
- * @param {bigint[]} roles
467
- * @param {?WriteParams<typeof managedBudgetAbi, 'grantRoles'>} [params]
468
- * @returns {unknown}
469
- */
470
- public async grantRolesRaw(
471
- addresses: Address[],
472
- roles: bigint[],
473
- params?: WriteParams<typeof managedBudgetAbi, 'grantRoles'>,
474
- ) {
475
- const { request, result } = await simulateManagedBudgetGrantRoles(
476
- this._config,
477
- {
478
- address: this.assertValidAddress(),
479
- args: [addresses, roles],
480
- ...this.optionallyAttachAccount(),
481
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
482
- ...(params as any),
483
- },
484
- );
485
- const hash = await writeManagedBudgetGrantRoles(
486
- this._config,
487
- // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
488
- request as any,
489
- );
490
- return { hash, result };
491
- }
492
-
493
- /**
494
- * Revoke many accounts' permissions on the budget.
495
- *
496
- * @example
497
- * ```ts
498
- * await budget.revokeRoles(['0xfoo', '0xbar], [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN])
499
- *
500
- * @public
501
- * @async
502
- * @param {Address[]} addresses
503
- * @param {bigint[]} roles
504
- * @param {?WriteParams<typeof managedBudgetAbi, 'revokeRoles'>} [params]
505
- * @returns {unknown}
506
- */
507
- public async revokeRoles(
508
- addresses: Address[],
509
- roles: bigint[],
510
- params?: WriteParams<typeof managedBudgetAbi, 'revokeRoles'>,
511
- ) {
512
- return await this.awaitResult(
513
- this.revokeRolesRaw(addresses, roles, params),
514
- );
515
- }
516
-
517
- /**
518
- * Revoke many accounts' permissions on the budget.
519
- *
520
- * @example
521
- * ```ts
522
- * await budget.revokeRoles(['0xfoo', '0xbar], [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN])
523
- * @public
524
- * @async
525
- * @param {Address[]} addresses
526
- * @param {bigint[]} roles
527
- * @param {?WriteParams<typeof managedBudgetAbi, 'revokeRoles'>} [params]
528
- * @returns {unknown}
529
- */
530
- public async revokeRolesRaw(
531
- addresses: Address[],
532
- roles: bigint[],
533
- params?: WriteParams<typeof managedBudgetAbi, 'revokeRoles'>,
534
- ) {
535
- const { request, result } = await simulateManagedBudgetRevokeRoles(
536
- this._config,
537
- {
538
- address: this.assertValidAddress(),
539
- args: [addresses, roles],
540
- ...this.optionallyAttachAccount(),
541
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
542
- ...(params as any),
543
- },
544
- );
545
- const hash = await writeManagedBudgetRevokeRoles(
546
- this._config,
547
- // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
548
- request as any,
549
- );
550
- return { hash, result };
551
- }
552
-
553
- /**
554
- * Return an array of the roles assigned to the given account.
555
- * @example
556
- * ```ts
557
- * (await budget.rolesOf(0xfoo)).includes(ManagedBudgetRoles.ADMIN)
558
- * @public
559
- * @param {Address} account
560
- * @param {?ReadParams<typeof managedBudgetAbi, 'rolesOf'>} [params]
561
- * @returns {Promise<Array<bigint>>}
562
- */
563
- public async rolesOf(
564
- account: Address,
565
- params?: ReadParams<typeof managedBudgetAbi, 'rolesOf'>,
566
- ) {
567
- const roles = await readManagedBudgetRolesOf(this._config, {
568
- address: this.assertValidAddress(),
569
- args: [account],
570
- ...this.optionallyAttachAccount(),
571
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
572
- ...(params as any),
573
- });
574
- return [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN].filter(
575
- (role) => (roles & role) === role,
576
- );
577
- }
578
-
579
- /**
580
- * Returns whether given account has any of the provided roles bitmap.
581
- *
582
- * @example
583
- * ```ts
584
- * await budget.hasAnyRole(0xfoo, ManagedBudgetRoles.ADMIN | ManagedBudgetRoles.MANAGER)
585
- * @public
586
- * @param {Address} account
587
- * @param {bigint} roles
588
- * @param {?ReadParams<typeof managedBudgetAbi, 'hasAnyRole'>} [params]
589
- * @returns {Promise<boolean>}
590
- */
591
- public hasAnyRole(
592
- account: Address,
593
- roles: bigint,
594
- params?: ReadParams<typeof managedBudgetAbi, 'hasAnyRole'>,
595
- ) {
596
- return readManagedBudgetHasAnyRole(this._config, {
597
- address: this.assertValidAddress(),
598
- args: [account, roles],
599
- ...this.optionallyAttachAccount(),
600
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
601
- ...(params as any),
602
- });
603
- }
604
-
605
- /**
606
- * Returns whether given account has all of the provided roles bitmap.
607
- *
608
- * @example
609
- * ```ts
610
- * await budget.hasAllRoles(0xfoo, ManagedBudgetRoles.ADMIN & ManagedBudgetRoles.MANAGER)
611
- *
612
- * @public
613
- * @param {Address} account
614
- * @param {bigint} roles
615
- * @param {?ReadParams<typeof managedBudgetAbi, 'hasAllRoles'>} [params]
616
- * @returns {*}
617
- */
618
- public hasAllRoles(
619
- account: Address,
620
- roles: bigint,
621
- params?: ReadParams<typeof managedBudgetAbi, 'hasAllRoles'>,
622
- ) {
623
- return readManagedBudgetHasAllRoles(this._config, {
624
- address: this.assertValidAddress(),
625
- args: [account, roles],
626
- ...this.optionallyAttachAccount(),
627
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
628
- ...(params as any),
629
- });
630
- }
631
-
632
- /**
633
- * Check if the given account is authorized to use the budget
634
- *
635
- * @public
636
- * @param {Address} account
637
- * @param {?ReadParams<typeof managedBudgetAbi, 'isAuthorized'>} [params]
638
- * @returns {Promise<boolean>} - True if the account is authorized
639
- */
640
- public isAuthorized(
641
- account: Address,
642
- params?: ReadParams<typeof managedBudgetAbi, 'isAuthorized'>,
643
- ) {
644
- return readManagedBudgetIsAuthorized(this._config, {
645
- address: this.assertValidAddress(),
646
- args: [account],
647
- ...this.optionallyAttachAccount(),
648
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
649
- ...(params as any),
650
- });
651
- }
652
-
653
381
  /**
654
382
  * Get the owner of the budget
655
383
  *
656
384
  * @public
657
- * @param {?ReadParams<typeof managedBudgetAbi, 'owner'>} [params]
385
+ * @param {?ReadParams} [params]
658
386
  * @returns {Promise<Address>}
659
387
  */
660
388
  public owner(params?: ReadParams<typeof managedBudgetAbi, 'owner'>) {
@@ -671,13 +399,13 @@ export class ManagedBudget extends DeployableTarget<
671
399
  * If a tokenId is provided, get the total amount of ERC1155 assets allocated to the budget, including any that have been distributed
672
400
  *
673
401
  * @public
674
- * @param {Address} asset - The address of the asset
402
+ * @param {Address} [asset="0x0000000000000000000000000000000000000000"] - The address of the asset
675
403
  * @param {?(bigint | undefined)} [tokenId] - The ID of the token
676
- * @param {?ReadParams<typeof managedBudgetAbi, 'total'>} [params]
404
+ * @param {?ReadParams} [params]
677
405
  * @returns {Promise<bigint>} - The total amount of assets
678
406
  */
679
407
  public total(
680
- asset: Address,
408
+ asset: Address = zeroAddress,
681
409
  tokenId?: bigint | undefined,
682
410
  params?: ReadParams<typeof managedBudgetAbi, 'total'>,
683
411
  ) {
@@ -694,13 +422,13 @@ export class ManagedBudget extends DeployableTarget<
694
422
  * If a tokenId is provided, get the amount of ERC1155 assets available for distribution from the budget
695
423
  *
696
424
  * @public
697
- * @param {Address} asset
425
+ * @param {Address} [asset="0x0000000000000000000000000000000000000000"]
698
426
  * @param {?(bigint | undefined)} [tokenId]
699
- * @param {?ReadParams<typeof managedBudgetAbi, 'available'>} [params]
427
+ * @param {?ReadParams} [params]
700
428
  * @returns {Promise<bigint>} - The amount of assets available
701
429
  */
702
430
  public available(
703
- asset: Address,
431
+ asset: Address = zeroAddress,
704
432
  tokenId?: bigint | undefined,
705
433
  params?: ReadParams<typeof managedBudgetAbi, 'available'>,
706
434
  ) {
@@ -717,13 +445,13 @@ export class ManagedBudget extends DeployableTarget<
717
445
  * If a tokenId is provided, get the amount of ERC1155 assets that have been distributed from the budget
718
446
  *
719
447
  * @public
720
- * @param {Address} asset
448
+ * @param {Address} [asset="0x0000000000000000000000000000000000000000"]
721
449
  * @param {?(bigint | undefined)} [tokenId]
722
- * @param {?ReadParams<typeof managedBudgetAbi, 'distributed'>} [params]
450
+ * @param {?ReadParams} [params]
723
451
  * @returns {Promise<bigint>} - The amount of assets distributed
724
452
  */
725
453
  public distributed(
726
- asset: Address,
454
+ asset: Address = zeroAddress,
727
455
  tokenId?: bigint | undefined,
728
456
  params?: ReadParams<typeof managedBudgetAbi, 'distributed'>,
729
457
  ) {
@@ -779,7 +507,7 @@ export class ManagedBudget extends DeployableTarget<
779
507
  * @param {Address} param0.owner - The budget's owner
780
508
  * @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
781
509
  * @param {{}} param0.roles - List of roles to assign to the corresponding account by index.
782
- * @returns {*}
510
+ * @returns {Hex}
783
511
  */
784
512
  export const prepareManagedBudgetPayload = ({
785
513
  owner,
@@ -791,6 +519,6 @@ export const prepareManagedBudgetPayload = ({
791
519
  'ManagedBudgetPayload payload',
792
520
  'struct ManagedBudgetPayload { address owner; address[] authorized; uint256[] roles; }',
793
521
  ]),
794
- [{ owner, authorized, roles }],
522
+ [{ owner, authorized, roles: roles as unknown as Array<bigint> }],
795
523
  );
796
524
  };
@@ -1,7 +1,7 @@
1
1
  import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
2
2
  import { isAddress, parseEther, zeroAddress } from 'viem';
3
3
  import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
4
- import type { MockERC20 } from '../../test/MockERC20';
4
+ import type { MockERC20 } from '@boostxyz/test/MockERC20';
5
5
  import {
6
6
  type Fixtures,
7
7
  defaultOptions,
@@ -9,14 +9,14 @@ import {
9
9
  freshVestingBudget,
10
10
  fundErc20,
11
11
  fundVestingBudget,
12
- } from '../../test/helpers';
13
- import { testAccount } from '../../test/viem';
12
+ } from '@boostxyz/test/helpers';
13
+ import { testAccount } from '@boostxyz/test/viem';
14
14
  import { VestingBudget } from './VestingBudget';
15
15
 
16
16
  let fixtures: Fixtures, budget: VestingBudget, erc20: MockERC20;
17
17
 
18
18
  beforeAll(async () => {
19
- fixtures = await loadFixture(deployFixtures);
19
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
20
20
  });
21
21
 
22
22
  describe.skip('VestingBudget', () => {
@@ -53,7 +53,7 @@ describe.skip('VestingBudget', () => {
53
53
  const budget = await loadFixture(
54
54
  freshVestingBudget(defaultOptions, fixtures),
55
55
  );
56
- expect(await budget.available(zeroAddress)).toBe(0n);
56
+ expect(await budget.available()).toBe(0n);
57
57
  });
58
58
 
59
59
  describe('can allocate', () => {
@@ -73,7 +73,7 @@ describe.skip('VestingBudget', () => {
73
73
  value: parseEther('1.0'),
74
74
  },
75
75
  );
76
- expect(await budget.available(zeroAddress)).toBe(parseEther('1.0'));
76
+ expect(await budget.available()).toBe(parseEther('1.0'));
77
77
  });
78
78
 
79
79
  test('erc20', async () => {
@@ -105,7 +105,7 @@ describe.skip('VestingBudget', () => {
105
105
  target: defaultOptions.account.address,
106
106
  });
107
107
 
108
- expect(await budget.available(zeroAddress)).toBe(0n);
108
+ expect(await budget.available()).toBe(0n);
109
109
  });
110
110
 
111
111
  test('erc20 assets', async () => {