@boostxyz/sdk 0.0.0-alpha.10

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 (242) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +7 -0
  3. package/dist/Actions/Action.cjs +2 -0
  4. package/dist/Actions/Action.cjs.map +1 -0
  5. package/dist/Actions/Action.d.ts +31 -0
  6. package/dist/Actions/Action.d.ts.map +1 -0
  7. package/dist/Actions/Action.js +29 -0
  8. package/dist/Actions/Action.js.map +1 -0
  9. package/dist/Actions/ContractAction.d.ts +370 -0
  10. package/dist/Actions/ContractAction.d.ts.map +1 -0
  11. package/dist/Actions/ERC721MintAction.d.ts +513 -0
  12. package/dist/Actions/ERC721MintAction.d.ts.map +1 -0
  13. package/dist/Actions/EventAction.cjs +2 -0
  14. package/dist/Actions/EventAction.cjs.map +1 -0
  15. package/dist/Actions/EventAction.d.ts +694 -0
  16. package/dist/Actions/EventAction.d.ts.map +1 -0
  17. package/dist/Actions/EventAction.js +491 -0
  18. package/dist/Actions/EventAction.js.map +1 -0
  19. package/dist/AllowLists/AllowList.cjs +2 -0
  20. package/dist/AllowLists/AllowList.cjs.map +1 -0
  21. package/dist/AllowLists/AllowList.d.ts +32 -0
  22. package/dist/AllowLists/AllowList.d.ts.map +1 -0
  23. package/dist/AllowLists/AllowList.js +30 -0
  24. package/dist/AllowLists/AllowList.js.map +1 -0
  25. package/dist/AllowLists/SimpleAllowList.cjs +2 -0
  26. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  27. package/dist/AllowLists/SimpleAllowList.d.ts +481 -0
  28. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -0
  29. package/dist/AllowLists/SimpleAllowList.js +154 -0
  30. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  31. package/dist/AllowLists/SimpleDenyList.cjs +2 -0
  32. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  33. package/dist/AllowLists/SimpleDenyList.d.ts +335 -0
  34. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -0
  35. package/dist/AllowLists/SimpleDenyList.js +115 -0
  36. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  37. package/dist/Auth/Auth.cjs +2 -0
  38. package/dist/Auth/Auth.cjs.map +1 -0
  39. package/dist/Auth/Auth.d.ts +10 -0
  40. package/dist/Auth/Auth.d.ts.map +1 -0
  41. package/dist/Auth/Auth.js +5 -0
  42. package/dist/Auth/Auth.js.map +1 -0
  43. package/dist/Auth/PassthroughAuth.cjs +2 -0
  44. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  45. package/dist/Auth/PassthroughAuth.d.ts +51 -0
  46. package/dist/Auth/PassthroughAuth.d.ts.map +1 -0
  47. package/dist/Auth/PassthroughAuth.js +39 -0
  48. package/dist/Auth/PassthroughAuth.js.map +1 -0
  49. package/dist/Boost.cjs +2 -0
  50. package/dist/Boost.cjs.map +1 -0
  51. package/dist/Boost.d.ts +234 -0
  52. package/dist/Boost.d.ts.map +1 -0
  53. package/dist/Boost.js +162 -0
  54. package/dist/Boost.js.map +1 -0
  55. package/dist/BoostCore.cjs +3 -0
  56. package/dist/BoostCore.cjs.map +1 -0
  57. package/dist/BoostCore.d.ts +498 -0
  58. package/dist/BoostCore.d.ts.map +1 -0
  59. package/dist/BoostCore.js +1153 -0
  60. package/dist/BoostCore.js.map +1 -0
  61. package/dist/BoostRegistry.cjs +2 -0
  62. package/dist/BoostRegistry.cjs.map +1 -0
  63. package/dist/BoostRegistry.d.ts +243 -0
  64. package/dist/BoostRegistry.d.ts.map +1 -0
  65. package/dist/BoostRegistry.js +262 -0
  66. package/dist/BoostRegistry.js.map +1 -0
  67. package/dist/Budgets/Budget.cjs +2 -0
  68. package/dist/Budgets/Budget.cjs.map +1 -0
  69. package/dist/Budgets/Budget.d.ts +31 -0
  70. package/dist/Budgets/Budget.d.ts.map +1 -0
  71. package/dist/Budgets/Budget.js +29 -0
  72. package/dist/Budgets/Budget.js.map +1 -0
  73. package/dist/Budgets/ManagedBudget.cjs +2 -0
  74. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  75. package/dist/Budgets/ManagedBudget.d.ts +1103 -0
  76. package/dist/Budgets/ManagedBudget.d.ts.map +1 -0
  77. package/dist/Budgets/ManagedBudget.js +516 -0
  78. package/dist/Budgets/ManagedBudget.js.map +1 -0
  79. package/dist/Budgets/SimpleBudget.d.ts +824 -0
  80. package/dist/Budgets/SimpleBudget.d.ts.map +1 -0
  81. package/dist/Budgets/VestingBudget.d.ts +778 -0
  82. package/dist/Budgets/VestingBudget.d.ts.map +1 -0
  83. package/dist/Deployable/Contract.cjs +2 -0
  84. package/dist/Deployable/Contract.cjs.map +1 -0
  85. package/dist/Deployable/Contract.d.ts +125 -0
  86. package/dist/Deployable/Contract.d.ts.map +1 -0
  87. package/dist/Deployable/Contract.js +150 -0
  88. package/dist/Deployable/Contract.js.map +1 -0
  89. package/dist/Deployable/Deployable.cjs +2 -0
  90. package/dist/Deployable/Deployable.cjs.map +1 -0
  91. package/dist/Deployable/Deployable.d.ts +161 -0
  92. package/dist/Deployable/Deployable.d.ts.map +1 -0
  93. package/dist/Deployable/Deployable.js +131 -0
  94. package/dist/Deployable/Deployable.js.map +1 -0
  95. package/dist/Deployable/DeployableTarget.cjs +2 -0
  96. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  97. package/dist/Deployable/DeployableTarget.d.ts +116 -0
  98. package/dist/Deployable/DeployableTarget.d.ts.map +1 -0
  99. package/dist/Deployable/DeployableTarget.js +132 -0
  100. package/dist/Deployable/DeployableTarget.js.map +1 -0
  101. package/dist/Incentives/AllowListIncentive.cjs +2 -0
  102. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  103. package/dist/Incentives/AllowListIncentive.d.ts +513 -0
  104. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -0
  105. package/dist/Incentives/AllowListIncentive.js +201 -0
  106. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  107. package/dist/Incentives/CGDAIncentive.cjs +2 -0
  108. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  109. package/dist/Incentives/CGDAIncentive.d.ts +644 -0
  110. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -0
  111. package/dist/Incentives/CGDAIncentive.js +271 -0
  112. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  113. package/dist/Incentives/ERC1155Incentive.d.ts +713 -0
  114. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -0
  115. package/dist/Incentives/ERC20Incentive.cjs +2 -0
  116. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  117. package/dist/Incentives/ERC20Incentive.d.ts +666 -0
  118. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -0
  119. package/dist/Incentives/ERC20Incentive.js +312 -0
  120. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  121. package/dist/Incentives/ERC20VariableIncentive.d.ts +582 -0
  122. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -0
  123. package/dist/Incentives/Incentive.cjs +2 -0
  124. package/dist/Incentives/Incentive.cjs.map +1 -0
  125. package/dist/Incentives/Incentive.d.ts +36 -0
  126. package/dist/Incentives/Incentive.d.ts.map +1 -0
  127. package/dist/Incentives/Incentive.js +299 -0
  128. package/dist/Incentives/Incentive.js.map +1 -0
  129. package/dist/Incentives/PointsIncentive.cjs +2 -0
  130. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  131. package/dist/Incentives/PointsIncentive.d.ts +659 -0
  132. package/dist/Incentives/PointsIncentive.d.ts.map +1 -0
  133. package/dist/Incentives/PointsIncentive.js +215 -0
  134. package/dist/Incentives/PointsIncentive.js.map +1 -0
  135. package/dist/Validators/SignerValidator.cjs +2 -0
  136. package/dist/Validators/SignerValidator.cjs.map +1 -0
  137. package/dist/Validators/SignerValidator.d.ts +745 -0
  138. package/dist/Validators/SignerValidator.d.ts.map +1 -0
  139. package/dist/Validators/SignerValidator.js +293 -0
  140. package/dist/Validators/SignerValidator.js.map +1 -0
  141. package/dist/Validators/Validator.cjs +2 -0
  142. package/dist/Validators/Validator.cjs.map +1 -0
  143. package/dist/Validators/Validator.d.ts +31 -0
  144. package/dist/Validators/Validator.d.ts.map +1 -0
  145. package/dist/Validators/Validator.js +27 -0
  146. package/dist/Validators/Validator.js.map +1 -0
  147. package/dist/claiming.cjs +2 -0
  148. package/dist/claiming.cjs.map +1 -0
  149. package/dist/claiming.d.ts +43 -0
  150. package/dist/claiming.d.ts.map +1 -0
  151. package/dist/claiming.js +17 -0
  152. package/dist/claiming.js.map +1 -0
  153. package/dist/componentInterfaces-CKCBwG16.cjs +2 -0
  154. package/dist/componentInterfaces-CKCBwG16.cjs.map +1 -0
  155. package/dist/componentInterfaces-DYkaxBda.js +13 -0
  156. package/dist/componentInterfaces-DYkaxBda.js.map +1 -0
  157. package/dist/errors.cjs +2 -0
  158. package/dist/errors.cjs.map +1 -0
  159. package/dist/errors.d.ts +441 -0
  160. package/dist/errors.d.ts.map +1 -0
  161. package/dist/errors.js +262 -0
  162. package/dist/errors.js.map +1 -0
  163. package/dist/generated-BDeDiaCK.js +4625 -0
  164. package/dist/generated-BDeDiaCK.js.map +1 -0
  165. package/dist/generated-wKBNvm48.cjs +3 -0
  166. package/dist/generated-wKBNvm48.cjs.map +1 -0
  167. package/dist/index.cjs +2 -0
  168. package/dist/index.cjs.map +1 -0
  169. package/dist/index.d.ts +25 -0
  170. package/dist/index.d.ts.map +1 -0
  171. package/dist/index.js +113 -0
  172. package/dist/index.js.map +1 -0
  173. package/dist/transfers.cjs +2 -0
  174. package/dist/transfers.cjs.map +1 -0
  175. package/dist/transfers.d.ts +198 -0
  176. package/dist/transfers.d.ts.map +1 -0
  177. package/dist/transfers.js +84 -0
  178. package/dist/transfers.js.map +1 -0
  179. package/dist/utils.cjs +2 -0
  180. package/dist/utils.cjs.map +1 -0
  181. package/dist/utils.d.ts +116 -0
  182. package/dist/utils.d.ts.map +1 -0
  183. package/dist/utils.js +30 -0
  184. package/dist/utils.js.map +1 -0
  185. package/package.json +211 -0
  186. package/src/Actions/Action.test.ts +75 -0
  187. package/src/Actions/Action.ts +61 -0
  188. package/src/Actions/ContractAction.test.ts +197 -0
  189. package/src/Actions/ContractAction.ts +301 -0
  190. package/src/Actions/ERC721MintAction.test.ts +112 -0
  191. package/src/Actions/ERC721MintAction.ts +292 -0
  192. package/src/Actions/EventAction.test.ts +205 -0
  193. package/src/Actions/EventAction.ts +811 -0
  194. package/src/AllowLists/AllowList.test.ts +64 -0
  195. package/src/AllowLists/AllowList.ts +60 -0
  196. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  197. package/src/AllowLists/SimpleAllowList.ts +284 -0
  198. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  199. package/src/AllowLists/SimpleDenyList.ts +227 -0
  200. package/src/Auth/Auth.ts +11 -0
  201. package/src/Auth/PassthroughAuth.test.ts +12 -0
  202. package/src/Auth/PassthroughAuth.ts +80 -0
  203. package/src/Boost.ts +290 -0
  204. package/src/BoostCore.test.ts +773 -0
  205. package/src/BoostCore.ts +1261 -0
  206. package/src/BoostRegistry.ts +467 -0
  207. package/src/Budgets/Budget.test.ts +27 -0
  208. package/src/Budgets/Budget.ts +61 -0
  209. package/src/Budgets/ManagedBudget.test.ts +154 -0
  210. package/src/Budgets/ManagedBudget.ts +796 -0
  211. package/src/Budgets/SimpleBudget.test.ts +152 -0
  212. package/src/Budgets/SimpleBudget.ts +564 -0
  213. package/src/Budgets/VestingBudget.test.ts +123 -0
  214. package/src/Budgets/VestingBudget.ts +602 -0
  215. package/src/Deployable/Contract.ts +229 -0
  216. package/src/Deployable/Deployable.ts +250 -0
  217. package/src/Deployable/DeployableTarget.ts +223 -0
  218. package/src/Incentives/AllowListIncentive.test.ts +143 -0
  219. package/src/Incentives/AllowListIncentive.ts +334 -0
  220. package/src/Incentives/CGDAIncentive.test.ts +132 -0
  221. package/src/Incentives/CGDAIncentive.ts +468 -0
  222. package/src/Incentives/ERC1155Incentive.test.ts +87 -0
  223. package/src/Incentives/ERC1155Incentive.ts +466 -0
  224. package/src/Incentives/ERC20Incentive.test.ts +130 -0
  225. package/src/Incentives/ERC20Incentive.ts +482 -0
  226. package/src/Incentives/ERC20VariableIncentive.test.ts +136 -0
  227. package/src/Incentives/ERC20VariableIncentive.ts +420 -0
  228. package/src/Incentives/Incentive.test.ts +92 -0
  229. package/src/Incentives/Incentive.ts +85 -0
  230. package/src/Incentives/PointsIncentive.test.ts +139 -0
  231. package/src/Incentives/PointsIncentive.ts +365 -0
  232. package/src/Validators/SignerValidator.test.ts +159 -0
  233. package/src/Validators/SignerValidator.ts +681 -0
  234. package/src/Validators/Validator.test.ts +21 -0
  235. package/src/Validators/Validator.ts +55 -0
  236. package/src/claiming.ts +56 -0
  237. package/src/errors.ts +542 -0
  238. package/src/index.test.ts +40 -0
  239. package/src/index.ts +53 -0
  240. package/src/transfers.ts +284 -0
  241. package/src/utils.test.ts +44 -0
  242. package/src/utils.ts +198 -0
@@ -0,0 +1,227 @@
1
+ import {
2
+ readSimpleDenyListIsAllowed,
3
+ simpleDenyListAbi,
4
+ simulateSimpleDenyListSetDenied,
5
+ writeSimpleDenyListSetDenied,
6
+ } from '@boostxyz/evm';
7
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleDenyList.sol/SimpleDenyList.json';
8
+ import { getAccount } from '@wagmi/core';
9
+ import {
10
+ type Address,
11
+ type ContractEventName,
12
+ type Hex,
13
+ encodeAbiParameters,
14
+ zeroAddress,
15
+ zeroHash,
16
+ } from 'viem';
17
+ import type {
18
+ DeployableOptions,
19
+ GenericDeployableParams,
20
+ } from '../Deployable/Deployable';
21
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
22
+ import { DeployableUnknownOwnerProvidedError } from '../errors';
23
+ import {
24
+ type GenericLog,
25
+ type ReadParams,
26
+ RegistryType,
27
+ type WriteParams,
28
+ } from '../utils';
29
+
30
+ export { simpleDenyListAbi };
31
+
32
+ /**
33
+ * Object representation of a {@link SimpleDenyList} initialization payload.
34
+ *
35
+ * @export
36
+ * @interface SimpleDenyListPayload
37
+ * @typedef {SimpleDenyListPayload}
38
+ */
39
+ export interface SimpleDenyListPayload {
40
+ /**
41
+ * The allow list's owner
42
+ *
43
+ * @type {Address}
44
+ */
45
+ owner: Address;
46
+ /**
47
+ * List of denied addresses.
48
+ *
49
+ * @type {Address[]}
50
+ */
51
+ denied: Address[];
52
+ }
53
+
54
+ /**
55
+ * A generic `viem.Log` event with support for `SimpleDenyList` event types.
56
+ *
57
+ * @export
58
+ * @typedef {SimpleDenyListLog}
59
+ * @template {ContractEventName<typeof simpleDenyListAbi>} [event=ContractEventName<
60
+ * typeof simpleDenyListAbi
61
+ * >]
62
+ */
63
+ export type SimpleDenyListLog<
64
+ event extends ContractEventName<typeof simpleDenyListAbi> = ContractEventName<
65
+ typeof simpleDenyListAbi
66
+ >,
67
+ > = GenericLog<typeof simpleDenyListAbi, event>;
68
+
69
+ /**
70
+ * A simple implementation of an AllowList that implicitly allows all addresses except those explicitly added to the deny list
71
+ *
72
+ * @export
73
+ * @class SimpleDenyList
74
+ * @typedef {SimpleDenyList}
75
+ * @extends {DeployableTarget<SimpleDenyListPayload>}
76
+ */
77
+ export class SimpleDenyList extends DeployableTarget<
78
+ SimpleDenyListPayload,
79
+ typeof simpleDenyListAbi
80
+ > {
81
+ public override readonly abi = simpleDenyListAbi;
82
+ /**
83
+ * @inheritdoc
84
+ *
85
+ * @public
86
+ * @static
87
+ * @type {Address}
88
+ */
89
+ public static override base: Address = import.meta.env
90
+ .VITE_SIMPLE_DENYLIST_BASE;
91
+ /**
92
+ * @inheritdoc
93
+ *
94
+ * @public
95
+ * @static
96
+ * @type {RegistryType}
97
+ */
98
+ public static override registryType: RegistryType = RegistryType.ALLOW_LIST;
99
+
100
+ /**
101
+ * Check if a user is authorized (i.e. not denied)
102
+ *
103
+ * @public
104
+ * @async
105
+ * @param {Address} address - The address of the user
106
+ * @param {?ReadParams<typeof simpleDenyListAbi, 'isAllowed'>} [params]
107
+ * @returns {Promise<boolean>} - True if the user is authorized
108
+ */
109
+ public async isAllowed(
110
+ address: Address,
111
+ params?: ReadParams<typeof simpleDenyListAbi, 'isAllowed'>,
112
+ ): Promise<boolean> {
113
+ return await readSimpleDenyListIsAllowed(this._config, {
114
+ address: this.assertValidAddress(),
115
+ args: [address, zeroHash],
116
+ ...this.optionallyAttachAccount(),
117
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
118
+ ...(params as any),
119
+ });
120
+ }
121
+
122
+ /**
123
+ * Set the denied status of a user. The length of the `users_` and `denied_` arrays must be the same. This function can only be called by the owner
124
+ *
125
+ * @public
126
+ * @async
127
+ * @param {Address[]} addresses - The list of users to update
128
+ * @param {boolean[]} allowed - The denied status of each user
129
+ * @param {?WriteParams<typeof simpleDenyListAbi, 'setDenied'>} [params]
130
+ * @returns {unknown}
131
+ */
132
+ public async setDenied(
133
+ addresses: Address[],
134
+ allowed: boolean[],
135
+ params?: WriteParams<typeof simpleDenyListAbi, 'setDenied'>,
136
+ ) {
137
+ return await this.awaitResult(
138
+ this.setDeniedRaw(addresses, allowed, params),
139
+ );
140
+ }
141
+
142
+ /**
143
+ * Set the denied status of a user. The length of the `users_` and `denied_` arrays must be the same. This function can only be called by the owner
144
+ *
145
+ * @public
146
+ * @async
147
+ * @param {Address[]} addresses - The list of users to update
148
+ * @param {boolean[]} allowed - The denied status of each user
149
+ * @param {?WriteParams<typeof simpleDenyListAbi, 'setDenied'>} [params]
150
+ * @returns {unknown}
151
+ */
152
+ public async setDeniedRaw(
153
+ addresses: Address[],
154
+ allowed: boolean[],
155
+ params?: WriteParams<typeof simpleDenyListAbi, 'setDenied'>,
156
+ ) {
157
+ const { request, result } = await simulateSimpleDenyListSetDenied(
158
+ this._config,
159
+ {
160
+ address: this.assertValidAddress(),
161
+ args: [addresses, allowed],
162
+ ...this.optionallyAttachAccount(),
163
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
164
+ ...(params as any),
165
+ },
166
+ );
167
+ const hash = await writeSimpleDenyListSetDenied(this._config, request);
168
+ return { hash, result };
169
+ }
170
+
171
+ /**
172
+ * @inheritdoc
173
+ *
174
+ * @public
175
+ * @param {?SimpleDenyListPayload} [_payload]
176
+ * @param {?DeployableOptions} [_options]
177
+ * @returns {GenericDeployableParams}
178
+ */
179
+ public override buildParameters(
180
+ _payload?: SimpleDenyListPayload,
181
+ _options?: DeployableOptions,
182
+ ): GenericDeployableParams {
183
+ const [payload, options] = this.validateDeploymentConfig(
184
+ _payload,
185
+ _options,
186
+ );
187
+ if (!payload.owner || payload.owner === zeroAddress) {
188
+ const owner = options.account
189
+ ? options.account.address
190
+ : options.config
191
+ ? getAccount(options.config).address
192
+ : this._account?.address;
193
+ if (owner) {
194
+ payload.owner = owner;
195
+ } else {
196
+ throw new DeployableUnknownOwnerProvidedError();
197
+ }
198
+ }
199
+ return {
200
+ abi: simpleDenyListAbi,
201
+ bytecode: bytecode as Hex,
202
+ args: [prepareSimpleDenyListPayload(payload)],
203
+ ...this.optionallyAttachAccount(options.account),
204
+ };
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Given a {@link SimpleDenyListPayload}, properly encode the initialization payload.
210
+ *
211
+ * @param {SimpleDenyListPayload} param0
212
+ * @param {Address} param0.owner - The allow list's owner
213
+ * @param {Address[]} param0.denied - List of denied addresses.
214
+ * @returns {Hex}
215
+ */
216
+ export function prepareSimpleDenyListPayload({
217
+ owner,
218
+ denied,
219
+ }: SimpleDenyListPayload) {
220
+ return encodeAbiParameters(
221
+ [
222
+ { type: 'address', name: 'owner' },
223
+ { type: 'address[]', name: 'denied' },
224
+ ],
225
+ [owner, denied],
226
+ );
227
+ }
@@ -0,0 +1,11 @@
1
+ import { PassthroughAuth } from './PassthroughAuth';
2
+
3
+ export { PassthroughAuth };
4
+
5
+ /**
6
+ * A union type representing all valid protocol Auth implementations
7
+ *
8
+ * @export
9
+ * @typedef {Auth}
10
+ */
11
+ export type Auth = PassthroughAuth;
@@ -0,0 +1,12 @@
1
+ import { zeroAddress } from 'viem';
2
+ import { describe, expect, test } from 'vitest';
3
+ import { defaultOptions } from '../../test/helpers';
4
+ import { PassthroughAuth } from './PassthroughAuth';
5
+
6
+ describe('PassthroughAuth', () => {
7
+ test('can successfully be deployed', async () => {
8
+ const auth = new PassthroughAuth(defaultOptions);
9
+ await auth.deploy();
10
+ expect(await auth.isAuthorized(zeroAddress)).toBe(true);
11
+ });
12
+ });
@@ -0,0 +1,80 @@
1
+ import {
2
+ passthroughAuthAbi,
3
+ readPassthroughAuthIsAuthorized,
4
+ } from '@boostxyz/evm';
5
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/auth/PassthroughAuth.sol/PassthroughAuth.json';
6
+ import type { Address, ContractEventName, Hex } from 'viem';
7
+ import {
8
+ Deployable,
9
+ type DeployableOptions,
10
+ type GenericDeployableParams,
11
+ } from '../Deployable/Deployable';
12
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
13
+ import type { GenericLog, ReadParams } from '../utils';
14
+
15
+ export { passthroughAuthAbi };
16
+
17
+ /**
18
+ * A generic `viem.Log` event with support for `PassthroughAuth` event types.
19
+ *
20
+ * @export
21
+ * @typedef {PassthroughAuthLog}
22
+ * @template {ContractEventName<
23
+ * typeof passthroughAuthAbi
24
+ * >} [event=ContractEventName<typeof passthroughAuthAbi>]
25
+ */
26
+ export type PassthroughAuthLog<
27
+ event extends ContractEventName<
28
+ typeof passthroughAuthAbi
29
+ > = ContractEventName<typeof passthroughAuthAbi>,
30
+ > = GenericLog<typeof passthroughAuthAbi, event>;
31
+
32
+ /**
33
+ * A simple implementation of a Validator that verifies a given signature and checks the recovered address against a set of authorized signers
34
+ *
35
+ * @export
36
+ * @class PassthroughAuth
37
+ * @typedef {PassthroughAuth}
38
+ * @extends {DeployableTarget<PassthroughAuthPayload>}
39
+ */
40
+ export class PassthroughAuth extends Deployable<
41
+ // biome-ignore lint/suspicious/noExplicitAny: takes no parameters
42
+ any,
43
+ typeof passthroughAuthAbi
44
+ > {
45
+ public override readonly abi = passthroughAuthAbi;
46
+
47
+ public async isAuthorized(
48
+ address: Address,
49
+ params?: ReadParams<typeof passthroughAuthAbi, 'isAuthorized'>,
50
+ ) {
51
+ return await readPassthroughAuthIsAuthorized(this._config, {
52
+ address: this.assertValidAddress(),
53
+ args: [address],
54
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
55
+ ...(params as any),
56
+ });
57
+ }
58
+
59
+ /**
60
+ * @inheritdoc
61
+ *
62
+ * @public
63
+ * @param {?PassthroughAuthPayload} [_payload]
64
+ * @param {?DeployableOptions} [_options]
65
+ * @returns {GenericDeployableParams}
66
+ */
67
+ public override buildParameters(
68
+ _payload?: never,
69
+ _options?: DeployableOptions,
70
+ ): GenericDeployableParams {
71
+ const [_, options] = this.validateDeploymentConfig({}, _options);
72
+ return {
73
+ abi: passthroughAuthAbi,
74
+ bytecode: bytecode as Hex,
75
+ // biome-ignore lint/suspicious/noExplicitAny: <takes no payload>
76
+ args: [] as any,
77
+ ...this.optionallyAttachAccount(options.account),
78
+ };
79
+ }
80
+ }
package/src/Boost.ts ADDED
@@ -0,0 +1,290 @@
1
+ import { LibZip } from 'solady';
2
+ import {
3
+ type Address,
4
+ type Hex,
5
+ encodeAbiParameters,
6
+ parseAbiParameters,
7
+ zeroAddress,
8
+ } from 'viem';
9
+ import type { Action } from './Actions/Action';
10
+ import type { AllowList } from './AllowLists/AllowList';
11
+ import type { Budget } from './Budgets/Budget';
12
+ import type { Incentive } from './Incentives/Incentive';
13
+ import type { Validator } from './Validators/Validator';
14
+
15
+ /**
16
+ * Configuration used to instantiate a `Boost` instance.
17
+ *
18
+ * @export
19
+ * @interface BoostPayload
20
+ * @typedef {BoostPayload}
21
+ */
22
+ export interface BoostConfig {
23
+ /**
24
+ *
25
+ * @type {bigint}
26
+ */
27
+ id: bigint;
28
+ /**
29
+ *
30
+ * @type {Budget}
31
+ */
32
+ budget: Budget;
33
+ /**
34
+ *
35
+ * @type {Action}
36
+ */
37
+ action: Action;
38
+ /**
39
+ *
40
+ * @type {Validator}
41
+ */
42
+ validator: Validator;
43
+ /**
44
+ *
45
+ * @type {AllowList}
46
+ */
47
+ allowList: AllowList;
48
+ /**
49
+ *
50
+ * @type {Array<Incentive>}
51
+ */
52
+ incentives: Array<Incentive>;
53
+ /**
54
+ *
55
+ * @type {?bigint}
56
+ */
57
+ protocolFee?: bigint;
58
+ /**
59
+ *
60
+ * @type {?bigint}
61
+ */
62
+ referralFee?: bigint;
63
+ /**
64
+ *
65
+ * @type {?bigint}
66
+ */
67
+ maxParticipants?: bigint;
68
+ /**
69
+ *
70
+ * @type {?Address}
71
+ */
72
+ owner?: Address;
73
+ }
74
+
75
+ /**
76
+ * A struct representing a single Boost. Typically you would not construct this directly, rather get an instance from `BoostCore.createBoost` or `BoostCore.getBoost`
77
+ *
78
+ * @export
79
+ * @class Boost
80
+ * @typedef {Boost}
81
+ */
82
+ export class Boost {
83
+ /**
84
+ *
85
+ * @readonly
86
+ * @type {bigint}
87
+ */
88
+ readonly id: bigint;
89
+ /**
90
+ *
91
+ * @readonly
92
+ * @type {Budget}
93
+ */
94
+ readonly budget: Budget;
95
+ /**
96
+ *
97
+ * @readonly
98
+ * @type {Action}
99
+ */
100
+ readonly action: Action;
101
+ /**
102
+ *
103
+ * @readonly
104
+ * @type {Validator}
105
+ */
106
+ readonly validator: Validator;
107
+ /**
108
+ *
109
+ * @readonly
110
+ * @type {AllowList}
111
+ */
112
+ readonly allowList: AllowList;
113
+ /**
114
+ *
115
+ * @readonly
116
+ * @type {Array<Incentive>}
117
+ */
118
+ readonly incentives: Array<Incentive>;
119
+ /**
120
+ *
121
+ * @readonly
122
+ * @type {bigint}
123
+ */
124
+ readonly protocolFee: bigint;
125
+ /**
126
+ *
127
+ * @readonly
128
+ * @type {bigint}
129
+ */
130
+ readonly referralFee: bigint;
131
+ /**
132
+ *
133
+ * @readonly
134
+ * @type {bigint}
135
+ */
136
+ readonly maxParticipants: bigint;
137
+ /**
138
+ *
139
+ * @readonly
140
+ * @type {Address}
141
+ */
142
+ readonly owner: Address;
143
+
144
+ /**
145
+ * Creates an instance of Boost.
146
+ *
147
+ * @constructor
148
+ * @param {BoostConfig} config
149
+ */
150
+ constructor(config: BoostConfig) {
151
+ this.id = config.id;
152
+ this.budget = config.budget;
153
+ this.action = config.action;
154
+ this.validator = config.validator;
155
+ this.allowList = config.allowList;
156
+ this.incentives = config.incentives;
157
+ this.protocolFee = config.protocolFee || 0n;
158
+ this.referralFee = config.referralFee || 0n;
159
+ this.maxParticipants = config.maxParticipants || 0n;
160
+ this.owner = config.owner || zeroAddress;
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Object representation of `BoostLib.Target` struct. Used for low level Boost creation operations.
166
+ * This is used to pass the base contract and its initialization parameters in an efficient manner
167
+ *
168
+ * @export
169
+ * @typedef {Target}
170
+ */
171
+ export type Target = {
172
+ isBase: boolean;
173
+ instance: Address;
174
+ parameters: Hex;
175
+ };
176
+
177
+ /**
178
+ * Object representation of `BoostCore.InitPayload` struct.
179
+ *
180
+ * @export
181
+ * @interface BoostPayload
182
+ * @typedef {BoostPayload}
183
+ */
184
+ export interface BoostPayload {
185
+ /**
186
+ * Address to valid budget.
187
+ *
188
+ * @type {Address}
189
+ */
190
+ budget: Address;
191
+ /**
192
+ * Target for existing action, or base with initialization payload.
193
+ *
194
+ * @type {Target}
195
+ */
196
+ action: Target;
197
+ /**
198
+ * Target for existing validator, or base with initialization payload.
199
+ *
200
+ * @type {Target}
201
+ */
202
+ validator: Target;
203
+ /**
204
+ * Target for existing allowList, or base with initialization payload.
205
+ *
206
+ * @type {Target}
207
+ */
208
+ allowList: Target;
209
+ /**
210
+ * Targets for new incentives, with initialization payloads.
211
+ *
212
+ * @type {Target[]}
213
+ */
214
+ incentives: Target[];
215
+ /**
216
+ * The base protocol fee (in bps)
217
+ *
218
+ * @type {?bigint}
219
+ */
220
+ protocolFee?: bigint;
221
+ /**
222
+ * The base referral fee (in bps)
223
+ *
224
+ * @type {?bigint}
225
+ */
226
+ referralFee?: bigint;
227
+ /**
228
+ * Optional maximum amount of participants in the Boost.
229
+ *
230
+ * @type {?bigint}
231
+ */
232
+ maxParticipants?: bigint;
233
+ /**
234
+ * The owner of the Boost.
235
+ *
236
+ * @type {Address}
237
+ */
238
+ owner: Address;
239
+ }
240
+
241
+ /**
242
+ * Given a valid {@link BoostPayload}, properly encode and compress the payload for use with `createBoost`
243
+ *
244
+ * @export
245
+ * @param {BoostPayload} param0
246
+ * @param {Address} param0.budget - Address to valid budget.
247
+ * @param {Target} param0.action - Target for existing action, or base with initialization payload.
248
+ * @param {Target} param0.validator - Target for existing validator, or base with initialization payload.
249
+ * @param {Target} param0.allowList - Target for existing allowList, or base with initialization payload.
250
+ * @param {Target[]} param0.incentives - Targets for new incentives, with initialization payloads.
251
+ * @param {bigint} [param0.protocolFee=0n] - The base protocol fee (in bps)
252
+ * @param {bigint} [param0.referralFee=0n] - The base referral fee (in bps)
253
+ * @param {bigint} [param0.maxParticipants=0n] - Optional maximum amount of participants in the Boost.
254
+ * @param {Address} param0.owner - The owner of the Boost.
255
+ * @returns {Hex}
256
+ */
257
+ export function prepareBoostPayload({
258
+ budget,
259
+ action,
260
+ validator,
261
+ allowList,
262
+ incentives,
263
+ protocolFee = 0n,
264
+ referralFee = 0n,
265
+ maxParticipants = 0n,
266
+ owner,
267
+ }: BoostPayload): Hex {
268
+ return LibZip.cdCompress(
269
+ encodeAbiParameters(
270
+ parseAbiParameters([
271
+ 'BoostPayload payload',
272
+ 'struct BoostPayload { address budget; Target action; Target validator; Target allowList; Target[] incentives; uint64 protocolFee; uint64 referralFee; uint256 maxParticipants; address owner; }',
273
+ 'struct Target { bool isBase; address instance; bytes parameters; }',
274
+ ]),
275
+ [
276
+ {
277
+ budget,
278
+ action,
279
+ validator,
280
+ allowList,
281
+ incentives,
282
+ protocolFee,
283
+ referralFee,
284
+ maxParticipants,
285
+ owner,
286
+ },
287
+ ],
288
+ ),
289
+ ) as Hex;
290
+ }