@boostxyz/sdk 0.0.0-alpha.2 → 0.0.0-alpha.20

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 (271) hide show
  1. package/dist/Actions/Action.cjs +2 -1
  2. package/dist/Actions/Action.cjs.map +1 -0
  3. package/dist/Actions/Action.d.ts +1 -1
  4. package/dist/Actions/Action.d.ts.map +1 -1
  5. package/dist/Actions/Action.js +14 -12
  6. package/dist/Actions/Action.js.map +1 -0
  7. package/dist/Actions/ContractAction.d.ts +57 -14
  8. package/dist/Actions/ContractAction.d.ts.map +1 -1
  9. package/dist/Actions/ERC721MintAction.d.ts +50 -23
  10. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  11. package/dist/Actions/EventAction.cjs +2 -1
  12. package/dist/Actions/EventAction.cjs.map +1 -0
  13. package/dist/Actions/EventAction.d.ts +405 -36
  14. package/dist/Actions/EventAction.d.ts.map +1 -1
  15. package/dist/Actions/EventAction.js +15 -209
  16. package/dist/Actions/EventAction.js.map +1 -0
  17. package/dist/AllowLists/AllowList.cjs +2 -1
  18. package/dist/AllowLists/AllowList.cjs.map +1 -0
  19. package/dist/AllowLists/AllowList.d.ts +6 -5
  20. package/dist/AllowLists/AllowList.d.ts.map +1 -1
  21. package/dist/AllowLists/AllowList.js +46 -22
  22. package/dist/AllowLists/AllowList.js.map +1 -0
  23. package/dist/AllowLists/OpenAllowList.d.ts +423 -0
  24. package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
  25. package/dist/AllowLists/SimpleAllowList.cjs +2 -1
  26. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  27. package/dist/AllowLists/SimpleAllowList.d.ts +124 -40
  28. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  29. package/dist/AllowLists/SimpleAllowList.js +77 -77
  30. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  31. package/dist/AllowLists/SimpleDenyList.cjs +2 -1
  32. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  33. package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
  34. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  35. package/dist/AllowLists/SimpleDenyList.js +12 -200
  36. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  37. package/dist/Auth/Auth.cjs +1 -0
  38. package/dist/Auth/Auth.cjs.map +1 -0
  39. package/dist/Auth/Auth.js +1 -0
  40. package/dist/Auth/Auth.js.map +1 -0
  41. package/dist/Auth/PassthroughAuth.cjs +2 -1
  42. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  43. package/dist/Auth/PassthroughAuth.js +5 -4
  44. package/dist/Auth/PassthroughAuth.js.map +1 -0
  45. package/dist/Boost.cjs +2 -1
  46. package/dist/Boost.cjs.map +1 -0
  47. package/dist/Boost.d.ts +111 -1
  48. package/dist/Boost.d.ts.map +1 -1
  49. package/dist/Boost.js +140 -5
  50. package/dist/Boost.js.map +1 -0
  51. package/dist/BoostCore-3-U1xTQN.cjs +3 -0
  52. package/dist/BoostCore-3-U1xTQN.cjs.map +1 -0
  53. package/dist/BoostCore-DVGBUr2y.js +1477 -0
  54. package/dist/BoostCore-DVGBUr2y.js.map +1 -0
  55. package/dist/BoostCore.cjs +2 -2
  56. package/dist/BoostCore.cjs.map +1 -0
  57. package/dist/BoostCore.d.ts +166 -43
  58. package/dist/BoostCore.d.ts.map +1 -1
  59. package/dist/BoostCore.js +30 -1103
  60. package/dist/BoostCore.js.map +1 -0
  61. package/dist/BoostRegistry.cjs +2 -1
  62. package/dist/BoostRegistry.cjs.map +1 -0
  63. package/dist/BoostRegistry.d.ts +64 -23
  64. package/dist/BoostRegistry.d.ts.map +1 -1
  65. package/dist/BoostRegistry.js +162 -88
  66. package/dist/BoostRegistry.js.map +1 -0
  67. package/dist/Budgets/Budget.cjs +2 -1
  68. package/dist/Budgets/Budget.cjs.map +1 -0
  69. package/dist/Budgets/Budget.d.ts +1 -1
  70. package/dist/Budgets/Budget.d.ts.map +1 -1
  71. package/dist/Budgets/Budget.js +15 -13
  72. package/dist/Budgets/Budget.js.map +1 -0
  73. package/dist/Budgets/ManagedBudget.cjs +2 -1
  74. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  75. package/dist/Budgets/ManagedBudget.d.ts +78 -188
  76. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  77. package/dist/Budgets/ManagedBudget.js +86 -286
  78. package/dist/Budgets/ManagedBudget.js.map +1 -0
  79. package/dist/Budgets/VestingBudget.d.ts +243 -87
  80. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  81. package/dist/Deployable/Contract.cjs +2 -1
  82. package/dist/Deployable/Contract.cjs.map +1 -0
  83. package/dist/Deployable/Contract.d.ts +4 -5
  84. package/dist/Deployable/Contract.d.ts.map +1 -1
  85. package/dist/Deployable/Contract.js +7 -8
  86. package/dist/Deployable/Contract.js.map +1 -0
  87. package/dist/Deployable/Deployable.cjs +1 -0
  88. package/dist/Deployable/Deployable.cjs.map +1 -0
  89. package/dist/Deployable/Deployable.d.ts +9 -3
  90. package/dist/Deployable/Deployable.d.ts.map +1 -1
  91. package/dist/Deployable/Deployable.js +10 -5
  92. package/dist/Deployable/Deployable.js.map +1 -0
  93. package/dist/Deployable/DeployableTarget.cjs +2 -1
  94. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  95. package/dist/Deployable/DeployableTarget.d.ts +16 -15
  96. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  97. package/dist/Deployable/DeployableTarget.js +49 -42
  98. package/dist/Deployable/DeployableTarget.js.map +1 -0
  99. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  100. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  101. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
  102. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  103. package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
  104. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  105. package/dist/EventAction-CIPqmAoP.js +1450 -0
  106. package/dist/EventAction-CIPqmAoP.js.map +1 -0
  107. package/dist/EventAction-d-oeqZQs.cjs +2 -0
  108. package/dist/EventAction-d-oeqZQs.cjs.map +1 -0
  109. package/dist/Incentive-Bp8Sez7M.js +298 -0
  110. package/dist/Incentive-Bp8Sez7M.js.map +1 -0
  111. package/dist/Incentive-Djnzseoj.cjs +2 -0
  112. package/dist/Incentive-Djnzseoj.cjs.map +1 -0
  113. package/dist/Incentives/AllowListIncentive.cjs +2 -1
  114. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  115. package/dist/Incentives/AllowListIncentive.d.ts +49 -19
  116. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  117. package/dist/Incentives/AllowListIncentive.js +50 -34
  118. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  119. package/dist/Incentives/CGDAIncentive.cjs +2 -1
  120. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  121. package/dist/Incentives/CGDAIncentive.d.ts +118 -22
  122. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  123. package/dist/Incentives/CGDAIncentive.js +67 -42
  124. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  125. package/dist/Incentives/ERC1155Incentive.d.ts +99 -38
  126. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  127. package/dist/Incentives/ERC20Incentive.cjs +2 -1
  128. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  129. package/dist/Incentives/ERC20Incentive.d.ts +73 -29
  130. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  131. package/dist/Incentives/ERC20Incentive.js +71 -48
  132. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  133. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +523 -0
  134. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  135. package/dist/Incentives/ERC20VariableIncentive.d.ts +65 -28
  136. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  137. package/dist/Incentives/Incentive.cjs +2 -1
  138. package/dist/Incentives/Incentive.cjs.map +1 -0
  139. package/dist/Incentives/Incentive.d.ts +4 -7
  140. package/dist/Incentives/Incentive.d.ts.map +1 -1
  141. package/dist/Incentives/Incentive.js +17 -278
  142. package/dist/Incentives/Incentive.js.map +1 -0
  143. package/dist/Incentives/PointsIncentive.cjs +2 -1
  144. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  145. package/dist/Incentives/PointsIncentive.d.ts +65 -21
  146. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  147. package/dist/Incentives/PointsIncentive.js +57 -36
  148. package/dist/Incentives/PointsIncentive.js.map +1 -0
  149. package/dist/SimpleDenyList-BwfNjRsg.cjs +2 -0
  150. package/dist/SimpleDenyList-BwfNjRsg.cjs.map +1 -0
  151. package/dist/SimpleDenyList-Cn5WpNn0.js +132 -0
  152. package/dist/SimpleDenyList-Cn5WpNn0.js.map +1 -0
  153. package/dist/Validators/SignerValidator.cjs +2 -1
  154. package/dist/Validators/SignerValidator.cjs.map +1 -0
  155. package/dist/Validators/SignerValidator.d.ts +310 -17
  156. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  157. package/dist/Validators/SignerValidator.js +165 -36
  158. package/dist/Validators/SignerValidator.js.map +1 -0
  159. package/dist/Validators/Validator.cjs +2 -1
  160. package/dist/Validators/Validator.cjs.map +1 -0
  161. package/dist/Validators/Validator.d.ts +2 -2
  162. package/dist/Validators/Validator.d.ts.map +1 -1
  163. package/dist/Validators/Validator.js +12 -10
  164. package/dist/Validators/Validator.js.map +1 -0
  165. package/dist/claiming.cjs +2 -0
  166. package/dist/claiming.cjs.map +1 -0
  167. package/dist/claiming.d.ts +43 -0
  168. package/dist/claiming.d.ts.map +1 -0
  169. package/dist/claiming.js +17 -0
  170. package/dist/claiming.js.map +1 -0
  171. package/dist/componentInterfaces-D09mhzxO.cjs +2 -0
  172. package/dist/componentInterfaces-D09mhzxO.cjs.map +1 -0
  173. package/dist/componentInterfaces-RXBMI5yH.js +14 -0
  174. package/dist/componentInterfaces-RXBMI5yH.js.map +1 -0
  175. package/dist/deployments-BM42vImE.js +43 -0
  176. package/dist/deployments-BM42vImE.js.map +1 -0
  177. package/dist/deployments-CMdF5uEC.cjs +2 -0
  178. package/dist/deployments-CMdF5uEC.cjs.map +1 -0
  179. package/dist/deployments.json +41 -0
  180. package/dist/errors.cjs +2 -1
  181. package/dist/errors.cjs.map +1 -0
  182. package/dist/errors.d.ts +403 -1
  183. package/dist/errors.d.ts.map +1 -1
  184. package/dist/errors.js +285 -39
  185. package/dist/errors.js.map +1 -0
  186. package/dist/generated-B0tk-c9b.cjs +3 -0
  187. package/dist/generated-B0tk-c9b.cjs.map +1 -0
  188. package/dist/{generated-x_abr3Yv.js → generated-B7VaSah4.js} +2058 -2541
  189. package/dist/generated-B7VaSah4.js.map +1 -0
  190. package/dist/index.cjs +2 -1
  191. package/dist/index.cjs.map +1 -0
  192. package/dist/index.d.ts +10 -9
  193. package/dist/index.d.ts.map +1 -1
  194. package/dist/index.js +143 -1353
  195. package/dist/index.js.map +1 -0
  196. package/dist/transfers.cjs +2 -0
  197. package/dist/transfers.cjs.map +1 -0
  198. package/dist/transfers.d.ts +198 -0
  199. package/dist/transfers.d.ts.map +1 -0
  200. package/dist/transfers.js +84 -0
  201. package/dist/transfers.js.map +1 -0
  202. package/dist/utils.cjs +2 -1
  203. package/dist/utils.cjs.map +1 -0
  204. package/dist/utils.d.ts +26 -1350
  205. package/dist/utils.d.ts.map +1 -1
  206. package/dist/utils.js +38 -636
  207. package/dist/utils.js.map +1 -0
  208. package/package.json +37 -11
  209. package/src/Actions/Action.test.ts +79 -0
  210. package/src/Actions/Action.ts +61 -0
  211. package/src/Actions/ContractAction.test.ts +197 -0
  212. package/src/Actions/ContractAction.ts +300 -0
  213. package/src/Actions/ERC721MintAction.test.ts +112 -0
  214. package/src/Actions/ERC721MintAction.ts +291 -0
  215. package/src/Actions/EventAction.test.ts +787 -0
  216. package/src/Actions/EventAction.ts +1214 -0
  217. package/src/AllowLists/AllowList.test.ts +64 -0
  218. package/src/AllowLists/AllowList.ts +62 -0
  219. package/src/AllowLists/OpenAllowList.test.ts +40 -0
  220. package/src/AllowLists/OpenAllowList.ts +45 -0
  221. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  222. package/src/AllowLists/SimpleAllowList.ts +262 -0
  223. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  224. package/src/AllowLists/SimpleDenyList.ts +250 -0
  225. package/src/Auth/Auth.ts +11 -0
  226. package/src/Auth/PassthroughAuth.test.ts +12 -0
  227. package/src/Auth/PassthroughAuth.ts +80 -0
  228. package/src/Boost.ts +309 -0
  229. package/src/BoostCore.test.ts +827 -0
  230. package/src/BoostCore.ts +1447 -0
  231. package/src/BoostRegistry.ts +543 -0
  232. package/src/Budgets/Budget.test.ts +27 -0
  233. package/src/Budgets/Budget.ts +60 -0
  234. package/src/Budgets/ManagedBudget.test.ts +217 -0
  235. package/src/Budgets/ManagedBudget.ts +534 -0
  236. package/src/Budgets/VestingBudget.test.ts +123 -0
  237. package/src/Budgets/VestingBudget.ts +530 -0
  238. package/src/Deployable/Contract.ts +228 -0
  239. package/src/Deployable/Deployable.ts +250 -0
  240. package/src/Deployable/DeployableTarget.ts +234 -0
  241. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  242. package/src/Incentives/AllowListIncentive.test.ts +143 -0
  243. package/src/Incentives/AllowListIncentive.ts +336 -0
  244. package/src/Incentives/CGDAIncentive.test.ts +132 -0
  245. package/src/Incentives/CGDAIncentive.ts +470 -0
  246. package/src/Incentives/ERC1155Incentive.test.ts +87 -0
  247. package/src/Incentives/ERC1155Incentive.ts +465 -0
  248. package/src/Incentives/ERC20Incentive.test.ts +130 -0
  249. package/src/Incentives/ERC20Incentive.ts +484 -0
  250. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  251. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
  252. package/src/Incentives/ERC20VariableIncentive.test.ts +136 -0
  253. package/src/Incentives/ERC20VariableIncentive.ts +422 -0
  254. package/src/Incentives/Incentive.test.ts +92 -0
  255. package/src/Incentives/Incentive.ts +86 -0
  256. package/src/Incentives/PointsIncentive.test.ts +139 -0
  257. package/src/Incentives/PointsIncentive.ts +367 -0
  258. package/src/Validators/SignerValidator.test.ts +159 -0
  259. package/src/Validators/SignerValidator.ts +683 -0
  260. package/src/Validators/Validator.test.ts +21 -0
  261. package/src/Validators/Validator.ts +55 -0
  262. package/src/claiming.ts +56 -0
  263. package/src/errors.ts +844 -0
  264. package/src/index.test.ts +122 -0
  265. package/src/index.ts +58 -0
  266. package/src/transfers.ts +284 -0
  267. package/src/utils.test.ts +44 -0
  268. package/src/utils.ts +247 -0
  269. package/dist/Budgets/SimpleBudget.d.ts +0 -793
  270. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  271. package/dist/generated-BaaleHW-.cjs +0 -2
@@ -0,0 +1,543 @@
1
+ import {
2
+ boostRegistryAbi,
3
+ readBoostRegistryGetBaseImplementation,
4
+ readBoostRegistryGetCloneIdentifier,
5
+ readBoostRegistryGetClones,
6
+ simulateBoostRegistryDeployClone,
7
+ simulateBoostRegistryRegister,
8
+ writeBoostRegistryDeployClone,
9
+ writeBoostRegistryRegister,
10
+ } from '@boostxyz/evm';
11
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/BoostRegistry.sol/BoostRegistry.json';
12
+ import {
13
+ type Address,
14
+ type ContractEventName,
15
+ type Hex,
16
+ isAddress,
17
+ zeroAddress,
18
+ } from 'viem';
19
+ import { BoostRegistry as BoostRegistryBases } from '../dist/deployments.json';
20
+ import {
21
+ Deployable,
22
+ type DeployableOptions,
23
+ type GenericDeployableParams,
24
+ } from './Deployable/Deployable';
25
+ import type { DeployableTarget } from './Deployable/DeployableTarget';
26
+ import {
27
+ type GenericLog,
28
+ type HashAndSimulatedResult,
29
+ type ReadParams,
30
+ type RegistryType,
31
+ type WriteParams,
32
+ assertValidAddressByChainId,
33
+ } from './utils';
34
+
35
+ /**
36
+ * The ABI of the BoostRegistry contract, if needed for low level operations
37
+ *
38
+ * @type {typeof boostRegistryAbi}
39
+ */
40
+ export { boostRegistryAbi };
41
+
42
+ /**
43
+ * The address of the deployed `BoostRegistry` instance. In prerelease mode, this will be its sepolia address
44
+ *
45
+ * @type {Address}
46
+ */
47
+ export const BOOST_REGISTRY_ADDRESS =
48
+ (BoostRegistryBases as Record<string, Address>)[__DEFAULT_CHAIN_ID__] ||
49
+ zeroAddress;
50
+
51
+ /**
52
+ * The fixed addresses for the deployed Boost Registry.
53
+ * By default, `new BoostRegistry` will use the address deployed to the currently connected chain, or `BOOST_REGISTRY_ADDRESS` if not provided.
54
+ *
55
+ * @type {Record<number, Address>}
56
+ */
57
+ export const BOOST_REGISTRY_ADDRESSES: Record<number, Address> = {
58
+ ...(BoostRegistryBases as Record<number, Address>),
59
+ 31337: import.meta.env.VITE_BOOST_REGISTRY_ADDRESS,
60
+ };
61
+
62
+ /**
63
+ * A record of `BoostRegistry` event names to `AbiEvent` objects for use with `getLogs`
64
+ *
65
+ * @export
66
+ * @typedef {BoostRegistryLog}
67
+ * @template {ContractEventName<typeof boostRegistryAbi>} [event=ContractEventName<
68
+ * typeof boostRegistryAbi
69
+ * >]
70
+ */
71
+ export type BoostRegistryLog<
72
+ event extends ContractEventName<typeof boostRegistryAbi> = ContractEventName<
73
+ typeof boostRegistryAbi
74
+ >,
75
+ > = GenericLog<typeof boostRegistryAbi, event>;
76
+
77
+ /**
78
+ * Instantiation options for a previously deployed Boost Registry
79
+ *
80
+ * @export
81
+ * @interface BoostRegistryDeployedOptions
82
+ * @typedef {BoostRegistryDeployedOptions}
83
+ * @extends {DeployableOptions}
84
+ */
85
+ export interface BoostRegistryDeployedOptions extends DeployableOptions {
86
+ /**
87
+ * The address for a Boost Registry, if different than `BOOST_REGISTRY_ADDRESS`
88
+ *
89
+ * @type {?Address}
90
+ */
91
+ address?: Address;
92
+ }
93
+
94
+ /**
95
+ * A typeguard to determine if instantiation is using a custom address.
96
+ *
97
+ * @param {*} opts
98
+ * @returns {opts is BoostRegistryDeployedOptions}
99
+ */
100
+ function isBoostRegistryDeployed(
101
+ // biome-ignore lint/suspicious/noExplicitAny: type guard
102
+ opts: any,
103
+ ): opts is BoostRegistryDeployedOptions {
104
+ return opts.address && isAddress(opts.address);
105
+ }
106
+
107
+ /**
108
+ * The Boost Registry does not take any construction arguments, so if you'd like to deploy a new Boost Registry, pass an explicit null to the `address` field.
109
+ *
110
+ * @export
111
+ * @interface BoostRegistryOptionsWithPayload
112
+ * @typedef {BoostRegistryOptionsWithPayload}
113
+ * @extends {DeployableOptions}
114
+ */
115
+ export interface BoostRegistryOptionsWithPayload extends DeployableOptions {
116
+ /**
117
+ *
118
+ * @type {null}
119
+ */
120
+ address: null;
121
+ }
122
+
123
+ /**
124
+ * A typeguard to determine if the user is intending to deploy a new Boost Registry before usage
125
+ *
126
+ * @param {*} opts
127
+ * @returns {opts is BoostRegistryOptionsWithPayload}
128
+ */
129
+ function isBoostRegistryDeployable(
130
+ // biome-ignore lint/suspicious/noExplicitAny: type guard
131
+ opts: any,
132
+ ): opts is BoostRegistryOptionsWithPayload {
133
+ return opts.address === null;
134
+ }
135
+
136
+ /**
137
+ * Instantiation options for a Boost Registry.
138
+ *
139
+ * @example
140
+ * To target Boost's Registry, omit the address field.
141
+ * Otherwise, supply a custom address to a previously deployed custom Boost Registry.
142
+ * You can also pass `{ address: null }` if you are intending to deploy a new Boost Registry.
143
+ * ```ts
144
+ * let registry = new BoostRegistry({ config, account })
145
+ * // or
146
+ * registry = new BoostRegistry({ config, account, address: CUSTOM_ADDRESS })
147
+ * // or
148
+ * registry = new BoostRegistry({ config, account, address: null })
149
+ * await registry.deploy()
150
+ * ```
151
+ *
152
+ * @export
153
+ * @typedef {BoostRegistryConfig}
154
+ */
155
+ export type BoostRegistryConfig =
156
+ | BoostRegistryDeployedOptions
157
+ | BoostRegistryOptionsWithPayload;
158
+
159
+ /**
160
+ * Constructs a new Boost Registry. A registry for base implementations and cloned instances.
161
+ * This contract is used to register base implementations and deploy new instances of those implementations for use within the Boost protocol.
162
+ *
163
+ * @see {@link BoostRegistryConfig}
164
+ * @export
165
+ * @class BoostRegistry
166
+ * @typedef {BoostRegistry}
167
+ * @extends {Deployable<never[]>}
168
+ */
169
+ export class BoostRegistry extends Deployable<
170
+ never[],
171
+ typeof boostRegistryAbi
172
+ > {
173
+ /**
174
+ * A static property representing a map of stringified chain ID's to the address of the deployed implementation on chain
175
+ *
176
+ * @static
177
+ * @readonly
178
+ * @type {Record<string, Address>}
179
+ */
180
+ static readonly addresses: Record<number, Address> = BOOST_REGISTRY_ADDRESSES;
181
+
182
+ /**
183
+ * A getter that will return Boost registry's static addresses by numerical chain ID
184
+ *
185
+ * @public
186
+ * @readonly
187
+ * @type {Record<number, Address>}
188
+ */
189
+ public get addresses(): Record<number, Address> {
190
+ return (this.constructor as typeof BoostRegistry).addresses;
191
+ }
192
+
193
+ /**
194
+ * Creates an instance of BoostRegistry.
195
+ *
196
+ * @see {@link BoostRegistryConfig}
197
+ * @constructor
198
+ * @param {BoostRegistryConfig} param0
199
+ * @param {Config} param0.config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)
200
+ * @param {?Account} [param0.account] - [Viem Local Account](https://viem.sh/docs/accounts/local)
201
+ * @param {({ address?: Address; } | {})} param0....options
202
+ */
203
+ constructor({ config, account, ...options }: BoostRegistryConfig) {
204
+ if (isBoostRegistryDeployed(options) && options.address) {
205
+ super({ account, config }, options.address);
206
+ } else if (isBoostRegistryDeployable(options)) {
207
+ super({ account, config }, []);
208
+ } else {
209
+ const { address } = assertValidAddressByChainId(
210
+ config,
211
+ BOOST_REGISTRY_ADDRESSES,
212
+ );
213
+ super({ account, config }, address);
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Register a new base implementation of a given type
219
+ *
220
+ * @public
221
+ * @async
222
+ * @param {RegistryType} registryType - The base type for the implementation
223
+ * @param {string} name - A name for the implementation (must be unique within the given type)
224
+ * @param {Address} implementation - The address of the implementation contract
225
+ * @param {?WriteParams} [params] - Optional params to provide the underlying Viem contract call
226
+ * @returns {Promise<void>}
227
+ * @example
228
+ * ```ts
229
+ * await registry.register(ContractAction.registryType, 'ContractAction', ContractAction.base)
230
+ * ```
231
+ */
232
+ public async register(
233
+ registryType: RegistryType,
234
+ name: string,
235
+ implementation: Address,
236
+ params?: WriteParams<typeof boostRegistryAbi, 'register'>,
237
+ ) {
238
+ return await this.awaitResult(
239
+ this.registerRaw(registryType, name, implementation, params),
240
+ );
241
+ }
242
+
243
+ /**
244
+ * @see {@link register}
245
+ * @public
246
+ * @async
247
+ * @param {RegistryType} registryType
248
+ * @param {string} name
249
+ * @param {Address} implementation
250
+ * @param {?WriteParams} [params]
251
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
252
+ */
253
+ public async registerRaw(
254
+ registryType: RegistryType,
255
+ name: string,
256
+ implementation: Address,
257
+ params?: WriteParams<typeof boostRegistryAbi, 'register'>,
258
+ ) {
259
+ const { request, result } = await simulateBoostRegistryRegister(
260
+ this._config,
261
+ {
262
+ ...assertValidAddressByChainId(
263
+ this._config,
264
+ this.addresses,
265
+ params?.chain?.id || params?.chainId,
266
+ ),
267
+ args: [registryType, name, implementation],
268
+ ...this.optionallyAttachAccount(),
269
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
270
+ ...(params as any),
271
+ },
272
+ );
273
+ const hash = await writeBoostRegistryRegister(this._config, request);
274
+ return { hash, result };
275
+ }
276
+
277
+ /**
278
+ * Initialize a new instance of a registered base implementation, returning the provided target with a new address set on it.
279
+ * This method is the same as `clone`, but serves to make its function more obvious as to why you'd need to use it.
280
+ *
281
+ * @public
282
+ * @async
283
+ * @template {DeployableTarget} Target
284
+ * @param {string} displayName - The display name for the clone
285
+ * @param {Target} target - An instance of a target contract to clone and initialize
286
+ * @param {?WriteParams} [params]
287
+ * @returns {Promise<Target>} - The provided instance, but with a new address attached.
288
+ * biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
289
+ */
290
+ public initialize<Target extends DeployableTarget<any, any>>(
291
+ displayName: string,
292
+ target: Target,
293
+ params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
294
+ ): Promise<Target> {
295
+ return this.clone(displayName, target, params);
296
+ }
297
+
298
+ /**
299
+ * Deploy a new instance of a registered base implementation, returning the provided target with a new address set on it.
300
+ *
301
+ * @public
302
+ * @async
303
+ * @template {DeployableTarget} Target
304
+ * @param {string} displayName - The display name for the clone
305
+ * @param {Target} target - An instance of a target contract to clone and initialize
306
+ * @param {?WriteParams} [params]
307
+ * @returns {Promise<Target>} - The provided instance, but with a new address attached.
308
+ * biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
309
+ */
310
+ public async clone<Target extends DeployableTarget<any, any>>(
311
+ displayName: string,
312
+ target: Target,
313
+ params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
314
+ ): Promise<Target> {
315
+ const instance = await this.deployClone(displayName, target, params);
316
+ return target.at(instance);
317
+ }
318
+
319
+ /**
320
+ *
321
+ * @see {@link clone}
322
+ * @public
323
+ * @async
324
+ * @template {DeployableTarget} Target
325
+ * @param {string} displayName
326
+ * @param {Target} target
327
+ * @param {?WriteParams} [params]
328
+ * @returns {Promise<Address>}
329
+ * biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
330
+ */
331
+ public async deployClone<Target extends DeployableTarget<any, any>>(
332
+ displayName: string,
333
+ target: Target,
334
+ params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
335
+ ): Promise<Address> {
336
+ return await this.awaitResult(
337
+ this.deployCloneRaw(displayName, target, params),
338
+ );
339
+ }
340
+
341
+ /**
342
+ * @see {@link clone}
343
+ * @public
344
+ * @async
345
+ * @param {string} displayName
346
+ * @param {DeployableTarget} target
347
+ * @param {?WriteParams} [params]
348
+ * @returns {Promise<{ hash: Hex, result: Address }>} - The transaction hash
349
+ * biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
350
+ */
351
+ public async deployCloneRaw<Target extends DeployableTarget<any, any>>(
352
+ displayName: string,
353
+ target: Target,
354
+ params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
355
+ ): Promise<HashAndSimulatedResult<Address>> {
356
+ const payload = target.buildParameters(undefined, {
357
+ config: this._config,
358
+ account: this._account,
359
+ });
360
+ const { address: baseAddress } = assertValidAddressByChainId(
361
+ this._config,
362
+ target.bases,
363
+ params?.chain?.id || params?.chainId,
364
+ );
365
+ const { request, result } = await simulateBoostRegistryDeployClone(
366
+ this._config,
367
+ {
368
+ ...assertValidAddressByChainId(
369
+ this._config,
370
+ this.addresses,
371
+ params?.chain?.id || params?.chainId,
372
+ ),
373
+ args: [target.registryType, baseAddress, displayName, payload.args[0]],
374
+ ...this.optionallyAttachAccount(),
375
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
376
+ ...(params as any),
377
+ },
378
+ );
379
+ const hash = await writeBoostRegistryDeployClone(this._config, request);
380
+ return { hash, result };
381
+ }
382
+
383
+ /**
384
+ * Get the address of a registered base implementation.
385
+ * This function will revert if the implementation is not registered
386
+ *
387
+ * @public
388
+ * @async
389
+ * @param {Hex} identifier - The unique identifier for the implementation (see {getIdentifier})
390
+ * @param {?ReadParams} [params]
391
+ * @returns {Promise<Address>} - The address of the implementation
392
+ */
393
+ public async getBaseImplementation(
394
+ identifier: Hex,
395
+ params?: ReadParams<typeof boostRegistryAbi, 'getBaseImplementation'>,
396
+ ) {
397
+ return await readBoostRegistryGetBaseImplementation(this._config, {
398
+ ...assertValidAddressByChainId(
399
+ this._config,
400
+ this.addresses,
401
+ params?.chainId,
402
+ ),
403
+ args: [identifier],
404
+ ...this.optionallyAttachAccount(),
405
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
406
+ ...(params as any),
407
+ });
408
+ }
409
+
410
+ /**
411
+ * Get the address of a deployed clone by its identifier
412
+ *
413
+ * @public
414
+ * @async
415
+ * @param {Hex} identifier - The unique identifier for the deployed clone (see {getCloneIdentifier})
416
+ * @param {?ReadParams} [params]
417
+ * @returns {Promise<Address>} - The address of the deployed clone
418
+ */
419
+ public async getClone(
420
+ identifier: Hex,
421
+ params?: ReadParams<typeof boostRegistryAbi, 'getClone'>,
422
+ ) {
423
+ return await readBoostRegistryGetBaseImplementation(this._config, {
424
+ ...assertValidAddressByChainId(
425
+ this._config,
426
+ this.addresses,
427
+ params?.chainId,
428
+ ),
429
+ args: [identifier],
430
+ ...this.optionallyAttachAccount(),
431
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
432
+ ...(params as any),
433
+ });
434
+ }
435
+
436
+ /**
437
+ * Get the list of identifiers of deployed clones for a given deployer
438
+ *
439
+ * @public
440
+ * @async
441
+ * @param {Address} deployer - The address of the deployer
442
+ * @param {?ReadParams} [params]
443
+ * @returns {Promise<Hex[]>} - The list of deployed clones for the given deployer
444
+ */
445
+ public async getClones(
446
+ deployer: Address,
447
+ params?: ReadParams<typeof boostRegistryAbi, 'getClones'>,
448
+ ) {
449
+ return await readBoostRegistryGetClones(this._config, {
450
+ ...assertValidAddressByChainId(
451
+ this._config,
452
+ this.addresses,
453
+ params?.chainId,
454
+ ),
455
+ args: [deployer],
456
+ ...this.optionallyAttachAccount(),
457
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
458
+ ...(params as any),
459
+ });
460
+ }
461
+
462
+ /**
463
+ * Build the identifier for a clone of a base implementation
464
+ *
465
+ * @public
466
+ * @async
467
+ * @param {RegistryType} registryType - The base type for the implementation
468
+ * @param {Address} base - The address of the base implementation
469
+ * @param {Address} deployer - The address of the deployer
470
+ * @param {string} displayName - The display name of the clone
471
+ * @param {?ReadParams} [params]
472
+ * @returns {Promise<Hex>} - The unique identifier for the clone
473
+ */
474
+ public async getCloneIdentifier(
475
+ registryType: RegistryType,
476
+ base: Address,
477
+ deployer: Address,
478
+ displayName: string,
479
+ params?: ReadParams<typeof boostRegistryAbi, 'getCloneIdentifier'>,
480
+ ) {
481
+ return await readBoostRegistryGetCloneIdentifier(this._config, {
482
+ ...assertValidAddressByChainId(
483
+ this._config,
484
+ this.addresses,
485
+ params?.chainId,
486
+ ),
487
+ args: [registryType, base, deployer, displayName],
488
+ ...this.optionallyAttachAccount(),
489
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
490
+ ...(params as any),
491
+ });
492
+ }
493
+
494
+ /**
495
+ * Build the identifier for a base implementation
496
+ *
497
+ * @public
498
+ * @async
499
+ * @param {RegistryType} registryType - The base type for the implementation
500
+ * @param {string} displayName - The name of the implementation
501
+ * @param {?ReadParams} [params]
502
+ * @returns {Promise<Hex>} - The unique identifier for the implementation
503
+ */
504
+ public async getIdentifier(
505
+ registryType: RegistryType,
506
+ displayName: string,
507
+ params?: ReadParams<typeof boostRegistryAbi, 'getIdentifier'>,
508
+ ) {
509
+ return await readBoostRegistryGetCloneIdentifier(this._config, {
510
+ ...assertValidAddressByChainId(
511
+ this._config,
512
+ this.addresses,
513
+ params?.chainId,
514
+ ),
515
+ args: [registryType, displayName],
516
+ ...this.optionallyAttachAccount(),
517
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
518
+ ...(params as any),
519
+ });
520
+ }
521
+
522
+ /**
523
+ * @inheritdoc
524
+ *
525
+ * @public
526
+ * @param {?never[]} [_payload]
527
+ * @param {?DeployableOptions} [_options]
528
+ * @returns {GenericDeployableParams}
529
+ */
530
+ public override buildParameters(
531
+ _payload?: never[],
532
+ _options?: DeployableOptions,
533
+ ): GenericDeployableParams {
534
+ const [, options] = this.validateDeploymentConfig([], _options);
535
+ return {
536
+ abi: boostRegistryAbi,
537
+ bytecode: bytecode as Hex,
538
+ // biome-ignore lint/suspicious/noExplicitAny: Registry doesn't construct or initialize
539
+ args: [] as any,
540
+ ...this.optionallyAttachAccount(options.account),
541
+ };
542
+ }
543
+ }
@@ -0,0 +1,27 @@
1
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
2
+ import { beforeAll, describe, expect, test } from 'vitest';
3
+ import {
4
+ type Fixtures,
5
+ defaultOptions,
6
+ deployFixtures,
7
+ freshManagedBudget,
8
+ } from '@boostxyz/test/helpers';
9
+ import { budgetFromAddress } from './Budget';
10
+ import { ManagedBudget } from './ManagedBudget';
11
+
12
+ let fixtures: Fixtures;
13
+
14
+ beforeAll(async () => {
15
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
16
+ });
17
+
18
+ describe('Budget', () => {
19
+ test('can automatically instantiate ManagedBudget given an address', async () => {
20
+ const budget = await loadFixture(
21
+ freshManagedBudget(defaultOptions, fixtures),
22
+ );
23
+ expect(
24
+ await budgetFromAddress(defaultOptions, budget.assertValidAddress()),
25
+ ).toBeInstanceOf(ManagedBudget);
26
+ });
27
+ });
@@ -0,0 +1,60 @@
1
+ import { aBudgetAbi } from '@boostxyz/evm';
2
+ import { AManagedBudget } from '@boostxyz/evm/deploys/componentInterfaces.json';
3
+ import { readContract } from '@wagmi/core';
4
+ import type { Address, Hex } from 'viem';
5
+ import type { DeployableOptions } from '../Deployable/Deployable';
6
+ import { InvalidComponentInterfaceError } from '../errors';
7
+ import { ManagedBudget } from './ManagedBudget';
8
+
9
+ export {
10
+ // VestingBudget,
11
+ ManagedBudget,
12
+ };
13
+
14
+ /**
15
+ * A union type representing all valid protocol Budget implementations
16
+ *
17
+ * @export
18
+ * @typedef {Budget}
19
+ */
20
+ export type Budget = ManagedBudget; // | VestingBudget
21
+
22
+ /**
23
+ * A map of Budget component interfaces to their constructors.
24
+ *
25
+ * @type {{ "0xa0109882": typeof ManagedBudget; }}
26
+ */
27
+ export const BudgetByComponentInterface = {
28
+ // ['0x64683da1']: VestingBudget,
29
+ // ['0x2929d19c']: SimpleBudget,
30
+ [AManagedBudget as Hex]: ManagedBudget,
31
+ };
32
+
33
+ /**
34
+ * A function that will read a contract's component interface using `getComponentInterface` and return the correct instantiated instance.
35
+ *
36
+ * @export
37
+ * @async
38
+ * @param {DeployableOptions} options
39
+ * @param {Address} address
40
+ * @returns {Promise<ManagedBudget>}
41
+ * @throws {@link InvalidComponentInterfaceError}
42
+ */
43
+ export async function budgetFromAddress(
44
+ options: DeployableOptions,
45
+ address: Address,
46
+ ) {
47
+ const interfaceId = (await readContract(options.config, {
48
+ abi: aBudgetAbi,
49
+ functionName: 'getComponentInterface',
50
+ address,
51
+ })) as keyof typeof BudgetByComponentInterface;
52
+ const Ctor = BudgetByComponentInterface[interfaceId];
53
+ if (!Ctor) {
54
+ throw new InvalidComponentInterfaceError(
55
+ Object.keys(BudgetByComponentInterface) as Hex[],
56
+ interfaceId as Hex,
57
+ );
58
+ }
59
+ return new Ctor(options, address);
60
+ }