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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.cjs.map +1 -1
  3. package/dist/Actions/Action.js +7 -7
  4. package/dist/Actions/ContractAction.d.ts +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 +171 -41
  11. package/dist/Actions/EventAction.d.ts.map +1 -1
  12. package/dist/Actions/EventAction.js +15 -392
  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 +55 -71
  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-BVZExPPu.js +1462 -0
  43. package/dist/BoostCore-BVZExPPu.js.map +1 -0
  44. package/dist/BoostCore-D-E-cnGI.cjs +3 -0
  45. package/dist/BoostCore-D-E-cnGI.cjs.map +1 -0
  46. package/dist/BoostCore.cjs +1 -2
  47. package/dist/BoostCore.cjs.map +1 -1
  48. package/dist/BoostCore.d.ts +748 -77
  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 +165 -83
  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 +75 -193
  66. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  67. package/dist/Budgets/ManagedBudget.js +80 -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 +179 -0
  91. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  92. package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
  93. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  94. package/dist/EventAction-BZt5cjbe.cjs +2 -0
  95. package/dist/EventAction-BZt5cjbe.cjs.map +1 -0
  96. package/dist/EventAction-C_-hJXWm.js +1541 -0
  97. package/dist/EventAction-C_-hJXWm.js.map +1 -0
  98. package/dist/Incentive-BhHaK3PZ.cjs +2 -0
  99. package/dist/Incentive-BhHaK3PZ.cjs.map +1 -0
  100. package/dist/Incentive-Cqg1w6wD.js +312 -0
  101. package/dist/Incentive-Cqg1w6wD.js.map +1 -0
  102. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  103. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  104. package/dist/Incentives/AllowListIncentive.d.ts +38 -16
  105. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  106. package/dist/Incentives/AllowListIncentive.js +42 -29
  107. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  108. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  109. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  110. package/dist/Incentives/CGDAIncentive.d.ts +234 -21
  111. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  112. package/dist/Incentives/CGDAIncentive.js +45 -32
  113. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  114. package/dist/Incentives/ERC1155Incentive.d.ts +224 -37
  115. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  116. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  117. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  118. package/dist/Incentives/ERC20Incentive.d.ts +230 -29
  119. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  120. package/dist/Incentives/ERC20Incentive.js +56 -43
  121. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  122. package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +335 -440
  123. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  124. package/dist/Incentives/ERC20VariableIncentive.d.ts +231 -29
  125. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  126. package/dist/Incentives/Incentive.cjs +1 -1
  127. package/dist/Incentives/Incentive.cjs.map +1 -1
  128. package/dist/Incentives/Incentive.d.ts +4 -4
  129. package/dist/Incentives/Incentive.d.ts.map +1 -1
  130. package/dist/Incentives/Incentive.js +16 -296
  131. package/dist/Incentives/Incentive.js.map +1 -1
  132. package/dist/Incentives/PointsIncentive.cjs +1 -1
  133. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  134. package/dist/Incentives/PointsIncentive.d.ts +40 -18
  135. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  136. package/dist/Incentives/PointsIncentive.js +37 -24
  137. package/dist/Incentives/PointsIncentive.js.map +1 -1
  138. package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
  139. package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
  140. package/dist/SimpleDenyList-CGaWjuld.js +132 -0
  141. package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
  142. package/dist/Validators/SignerValidator.cjs +1 -1
  143. package/dist/Validators/SignerValidator.cjs.map +1 -1
  144. package/dist/Validators/SignerValidator.d.ts +16 -16
  145. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  146. package/dist/Validators/SignerValidator.js +30 -27
  147. package/dist/Validators/SignerValidator.js.map +1 -1
  148. package/dist/Validators/Validator.cjs +1 -1
  149. package/dist/Validators/Validator.cjs.map +1 -1
  150. package/dist/Validators/Validator.d.ts +1 -1
  151. package/dist/Validators/Validator.js +2 -2
  152. package/dist/Validators/Validator.js.map +1 -1
  153. package/dist/claiming.cjs.map +1 -1
  154. package/dist/claiming.d.ts +1 -1
  155. package/dist/claiming.js.map +1 -1
  156. package/dist/componentInterfaces-BBCFkrZv.js +14 -0
  157. package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
  158. package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
  159. package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
  160. package/dist/deployments-DVXioW2i.cjs +2 -0
  161. package/dist/deployments-DVXioW2i.cjs.map +1 -0
  162. package/dist/deployments-oykLv3_Z.js +43 -0
  163. package/dist/deployments-oykLv3_Z.js.map +1 -0
  164. package/dist/deployments.json +44 -0
  165. package/dist/errors.cjs +1 -1
  166. package/dist/errors.cjs.map +1 -1
  167. package/dist/errors.d.ts +256 -20
  168. package/dist/errors.d.ts.map +1 -1
  169. package/dist/errors.js +183 -26
  170. package/dist/errors.js.map +1 -1
  171. package/dist/{generated-57_Kffpz.js → generated-CKt2yCQd.js} +3613 -1869
  172. package/dist/generated-CKt2yCQd.js.map +1 -0
  173. package/dist/generated-CyTNlOwM.cjs +3 -0
  174. package/dist/generated-CyTNlOwM.cjs.map +1 -0
  175. package/dist/index.cjs +1 -1
  176. package/dist/index.d.ts +5 -0
  177. package/dist/index.d.ts.map +1 -1
  178. package/dist/index.js +142 -108
  179. package/dist/index.js.map +1 -1
  180. package/dist/transfers.cjs.map +1 -1
  181. package/dist/transfers.d.ts +1 -1
  182. package/dist/transfers.js.map +1 -1
  183. package/dist/utils.cjs +1 -1
  184. package/dist/utils.cjs.map +1 -1
  185. package/dist/utils.d.ts +26 -12
  186. package/dist/utils.d.ts.map +1 -1
  187. package/dist/utils.js +38 -23
  188. package/dist/utils.js.map +1 -1
  189. package/package.json +20 -10
  190. package/src/Actions/Action.test.ts +14 -13
  191. package/src/Actions/ContractAction.test.ts +10 -10
  192. package/src/Actions/ContractAction.ts +11 -12
  193. package/src/Actions/ERC721MintAction.test.ts +6 -6
  194. package/src/Actions/ERC721MintAction.ts +14 -15
  195. package/src/Actions/EventAction.test.ts +729 -109
  196. package/src/Actions/EventAction.ts +542 -84
  197. package/src/AllowLists/AllowList.test.ts +7 -7
  198. package/src/AllowLists/AllowList.ts +5 -3
  199. package/src/AllowLists/OpenAllowList.test.ts +40 -0
  200. package/src/AllowLists/OpenAllowList.ts +45 -0
  201. package/src/AllowLists/SimpleAllowList.test.ts +4 -4
  202. package/src/AllowLists/SimpleAllowList.ts +39 -61
  203. package/src/AllowLists/SimpleDenyList.test.ts +4 -4
  204. package/src/AllowLists/SimpleDenyList.ts +40 -17
  205. package/src/Auth/PassthroughAuth.test.ts +1 -1
  206. package/src/Boost.ts +21 -24
  207. package/src/BoostCore.test.ts +323 -268
  208. package/src/BoostCore.ts +396 -219
  209. package/src/BoostRegistry.test.ts +53 -0
  210. package/src/BoostRegistry.ts +161 -40
  211. package/src/Budgets/Budget.test.ts +2 -2
  212. package/src/Budgets/Budget.ts +1 -2
  213. package/src/Budgets/ManagedBudget.test.ts +82 -19
  214. package/src/Budgets/ManagedBudget.ts +48 -310
  215. package/src/Budgets/VestingBudget.test.ts +7 -7
  216. package/src/Budgets/VestingBudget.ts +34 -106
  217. package/src/Deployable/Contract.ts +4 -5
  218. package/src/Deployable/Deployable.ts +1 -1
  219. package/src/Deployable/DeployableTarget.ts +30 -19
  220. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  221. package/src/Incentives/AllowListIncentive.test.ts +5 -5
  222. package/src/Incentives/AllowListIncentive.ts +29 -15
  223. package/src/Incentives/CGDAIncentive.test.ts +9 -6
  224. package/src/Incentives/CGDAIncentive.ts +38 -18
  225. package/src/Incentives/ERC1155Incentive.test.ts +3 -3
  226. package/src/Incentives/ERC1155Incentive.ts +28 -29
  227. package/src/Incentives/ERC20Incentive.test.ts +9 -6
  228. package/src/Incentives/ERC20Incentive.ts +46 -26
  229. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  230. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
  231. package/src/Incentives/ERC20VariableIncentive.test.ts +8 -11
  232. package/src/Incentives/ERC20VariableIncentive.ts +49 -26
  233. package/src/Incentives/Incentive.test.ts +4 -1
  234. package/src/Incentives/Incentive.ts +7 -6
  235. package/src/Incentives/PointsIncentive.test.ts +24 -25
  236. package/src/Incentives/PointsIncentive.ts +31 -17
  237. package/src/Validators/SignerValidator.test.ts +6 -6
  238. package/src/Validators/SignerValidator.ts +19 -17
  239. package/src/Validators/Validator.test.ts +2 -2
  240. package/src/Validators/Validator.ts +1 -1
  241. package/src/claiming.ts +1 -1
  242. package/src/errors.ts +345 -21
  243. package/src/index.test.ts +118 -36
  244. package/src/index.ts +5 -0
  245. package/src/transfers.ts +1 -1
  246. package/src/utils.test.ts +2 -2
  247. package/src/utils.ts +61 -12
  248. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  249. package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
  250. package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
  251. package/dist/componentInterfaces-DYkaxBda.js +0 -13
  252. package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
  253. package/dist/generated-57_Kffpz.js.map +0 -1
  254. package/dist/generated-wKBNvm48.cjs +0 -3
  255. package/dist/generated-wKBNvm48.cjs.map +0 -1
  256. package/src/Budgets/SimpleBudget.test.ts +0 -152
  257. package/src/Budgets/SimpleBudget.ts +0 -564
@@ -1,122 +1,113 @@
1
- import { loadFixture } from '@nomicfoundation/hardhat-toolbox-viem/network-helpers';
2
- import { parseEther, zeroAddress } from 'viem';
3
- import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
1
+ import { accounts } from '@boostxyz/test/accounts';
4
2
  import {
5
3
  type BudgetFixtures,
6
4
  type Fixtures,
7
5
  defaultOptions,
8
6
  deployFixtures,
7
+ freshBoost,
9
8
  fundBudget,
10
9
  makeMockEventActionPayload,
11
- } from '../test/helpers';
10
+ } from '@boostxyz/test/helpers';
11
+ import { loadFixture } from '@nomicfoundation/hardhat-toolbox-viem/network-helpers';
12
+ import { pad, parseEther, zeroAddress } from 'viem';
13
+ import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
12
14
  import { ContractAction } from './Actions/ContractAction';
13
- import { BoostCore } from './BoostCore';
15
+ import { BOOST_CORE_CLAIM_FEE } from './BoostCore';
14
16
  import type { ERC20Incentive } from './Incentives/ERC20Incentive';
15
- import { ERC1155StrategyType } from './Incentives/ERC1155Incentive';
16
17
  import { StrategyType } from './claiming';
17
- import { IncentiveNotCloneableError } from './errors';
18
+ import { BoostNotFoundError, IncentiveNotCloneableError } from './errors';
18
19
  import { bytes4 } from './utils';
19
20
 
20
21
  let fixtures: Fixtures, budgets: BudgetFixtures;
21
22
 
22
23
  describe('BoostCore', () => {
23
24
  beforeAll(async () => {
24
- fixtures = await loadFixture(deployFixtures);
25
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
25
26
  });
26
27
  beforeEach(async () => {
27
28
  budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
28
29
  });
29
30
 
30
31
  test('can get the total number of boosts', async () => {
31
- const { core, bases } = fixtures;
32
- const client = new BoostCore({
33
- ...defaultOptions,
34
- address: core.assertValidAddress(),
35
- });
32
+ const { core } = fixtures;
36
33
 
37
- // to whom it may concern, this syntax is only used because we need to use test classes
38
- // that are preconfigured with the dynamic base addresses generated at test time.
39
- // normally you would use the follow api for brevity
40
- // budget: client.SimpleBudget({} | '0xaddress')
41
34
  const { budget, erc20 } = budgets;
42
- await client.createBoost({
43
- protocolFee: 1n,
44
- referralFee: 2n,
35
+ await core.createBoost({
36
+ protocolFee: 0n,
45
37
  maxParticipants: 100n,
46
38
  budget: budget,
47
- action: new bases.EventAction(
48
- defaultOptions,
39
+ action: core.EventAction(
49
40
  makeMockEventActionPayload(
50
41
  core.assertValidAddress(),
51
42
  erc20.assertValidAddress(),
52
43
  ),
53
44
  ),
54
- validator: new bases.SignerValidator(defaultOptions, {
45
+ validator: core.SignerValidator({
55
46
  signers: [defaultOptions.account.address],
56
47
  validatorCaller: defaultOptions.account.address,
57
48
  }),
58
- allowList: new bases.SimpleAllowList(defaultOptions, {
49
+ allowList: core.SimpleAllowList({
59
50
  owner: defaultOptions.account.address,
60
51
  allowed: [defaultOptions.account.address],
61
52
  }),
62
53
  incentives: [
63
- new bases.ERC20Incentive(defaultOptions, {
54
+ core.ERC20Incentive({
64
55
  asset: erc20.assertValidAddress(),
65
56
  reward: parseEther('1'),
66
57
  limit: 100n,
67
58
  strategy: StrategyType.POOL,
59
+ manager: budget.assertValidAddress(),
68
60
  }),
69
61
  ],
70
62
  });
71
- expect(await client.getBoostCount()).toBe(1n);
63
+ expect(await core.getBoostCount()).toBe(1n);
72
64
  });
73
65
 
74
- test('can successfully create a boost using all base contract implementations', async () => {
75
- const { core, bases } = fixtures;
76
- const client = new BoostCore({
77
- ...defaultOptions,
78
- address: core.assertValidAddress(),
79
- });
66
+ test('throws a typed error if no boost exists', async () => {
67
+ const { core } = fixtures;
68
+ try {
69
+ await core.getBoost(1000n)
70
+ } catch(e) {
71
+ expect(e instanceof BoostNotFoundError).toBe(true)
72
+ expect(e.id).toBe('1000')
73
+ }
74
+ })
80
75
 
81
- // to whom it may concern, this syntax is only used because we need to use test classes
82
- // that are preconfigured with the dynamic base addresses generated at test time.
83
- // normally you would use the follow api for brevity
84
- // budget: client.SimpleBudget({} | '0xaddress')
76
+ test('can successfully create a boost using all base contract implementations', async () => {
77
+ const { core } = fixtures;
85
78
  const { budget, erc20 } = budgets;
86
- const boost = await client.createBoost({
79
+ const boost = await core.createBoost({
87
80
  protocolFee: 1n,
88
- referralFee: 2n,
89
81
  maxParticipants: 100n,
90
82
  budget: budget,
91
- action: new bases.EventAction(
92
- defaultOptions,
83
+ action: core.EventAction(
93
84
  makeMockEventActionPayload(
94
85
  core.assertValidAddress(),
95
86
  erc20.assertValidAddress(),
96
87
  ),
97
88
  ),
98
- validator: new bases.SignerValidator(defaultOptions, {
89
+ validator: core.SignerValidator({
99
90
  signers: [defaultOptions.account.address],
100
91
  validatorCaller: defaultOptions.account.address,
101
92
  }),
102
- allowList: new bases.SimpleAllowList(defaultOptions, {
93
+ allowList: core.SimpleAllowList({
103
94
  owner: defaultOptions.account.address,
104
95
  allowed: [defaultOptions.account.address],
105
96
  }),
106
97
  incentives: [
107
- new bases.ERC20Incentive(defaultOptions, {
98
+ core.ERC20Incentive({
108
99
  asset: erc20.assertValidAddress(),
109
100
  reward: parseEther('1'),
110
101
  limit: 100n,
111
102
  strategy: StrategyType.POOL,
103
+ manager: budget.assertValidAddress(),
112
104
  }),
113
105
  ],
114
106
  });
115
- const onChainBoost = await client.readBoost(boost.id);
107
+ const onChainBoost = await core.readBoost(boost.id);
116
108
 
117
109
  expect(boost.owner).toBe(onChainBoost.owner);
118
110
  expect(boost.protocolFee).toBe(onChainBoost.protocolFee);
119
- expect(boost.referralFee).toBe(onChainBoost.referralFee);
120
111
  expect(boost.maxParticipants).toBe(onChainBoost.maxParticipants);
121
112
 
122
113
  expect(boost.action.address).toBe(onChainBoost.action);
@@ -165,49 +156,38 @@ describe('BoostCore', () => {
165
156
  });
166
157
 
167
158
  test('can read the raw on chain representation of a boost', async () => {
168
- const { core, bases } = fixtures;
169
- const client = new BoostCore({
170
- ...defaultOptions,
171
- address: core.assertValidAddress(),
172
- });
173
-
174
- // to whom it may concern, this syntax is only used because we need to use test classes
175
- // that are preconfigured with the dynamic base addresses generated at test time.
176
- // normally you would use the follow api for brevity
177
- // budget: client.SimpleBudget({} | '0xaddress')
159
+ const { core } = fixtures;
178
160
  const { budget, erc20 } = budgets;
179
- const _boost = await client.createBoost({
161
+ const _boost = await core.createBoost({
180
162
  protocolFee: 1n,
181
- referralFee: 2n,
182
163
  maxParticipants: 100n,
183
164
  budget: budget,
184
- action: new bases.EventAction(
185
- defaultOptions,
165
+ action: core.EventAction(
186
166
  makeMockEventActionPayload(
187
167
  core.assertValidAddress(),
188
168
  erc20.assertValidAddress(),
189
169
  ),
190
170
  ),
191
- validator: new bases.SignerValidator(defaultOptions, {
171
+ validator: core.SignerValidator({
192
172
  signers: [defaultOptions.account.address],
193
173
  validatorCaller: defaultOptions.account.address,
194
174
  }),
195
- allowList: new bases.SimpleAllowList(defaultOptions, {
175
+ allowList: core.SimpleAllowList({
196
176
  owner: defaultOptions.account.address,
197
177
  allowed: [defaultOptions.account.address],
198
178
  }),
199
179
  incentives: [
200
- new bases.ERC20Incentive(defaultOptions, {
180
+ core.ERC20Incentive({
201
181
  asset: erc20.assertValidAddress(),
202
182
  reward: parseEther('1'),
203
183
  limit: 100n,
204
184
  strategy: StrategyType.POOL,
185
+ manager: budget.assertValidAddress(),
205
186
  }),
206
187
  ],
207
188
  });
208
- const boost = await client.readBoost(_boost.id);
189
+ const boost = await core.readBoost(_boost.id);
209
190
  expect(boost.protocolFee).toBe(1001n);
210
- expect(boost.referralFee).toBe(1002n);
211
191
  expect(boost.maxParticipants).toBe(100n);
212
192
  expect(boost.budget).toBe(_boost.budget.assertValidAddress());
213
193
  expect(boost.action).toBe(_boost.action.assertValidAddress());
@@ -218,302 +198,321 @@ describe('BoostCore', () => {
218
198
  );
219
199
  });
220
200
 
221
- test('can reuse an existing action', async () => {
222
- const { core, bases } = fixtures;
223
- const client = new BoostCore({
224
- ...defaultOptions,
225
- address: core.assertValidAddress(),
201
+ test('can optionally supply a validator', async () => {
202
+ const { core } = fixtures;
203
+ const { budget, erc20 } = budgets;
204
+ const _boost = await core.createBoost({
205
+ protocolFee: 1n,
206
+ maxParticipants: 100n,
207
+ budget: budget,
208
+ action: core.EventAction(
209
+ makeMockEventActionPayload(
210
+ core.assertValidAddress(),
211
+ erc20.assertValidAddress(),
212
+ ),
213
+ ),
214
+ allowList: core.SimpleAllowList({
215
+ owner: defaultOptions.account.address,
216
+ allowed: [defaultOptions.account.address],
217
+ }),
218
+ incentives: [
219
+ core.ERC20Incentive({
220
+ asset: erc20.assertValidAddress(),
221
+ reward: parseEther('1'),
222
+ limit: 100n,
223
+ strategy: StrategyType.POOL,
224
+ manager: budget.assertValidAddress(),
225
+ }),
226
+ ],
226
227
  });
228
+ const boost = await core.readBoost(_boost.id);
229
+ expect(boost.validator).toBe(_boost.validator.assertValidAddress());
230
+ });
227
231
 
228
- // to whom it may concern, this syntax is only used because we need to use test classes
229
- // that are preconfigured with the dynamic base addresses generated at test time.
230
- // normally you would use the follow api for brevity
231
- // budget: client.SimpleBudget({} | '0xaddress')
232
+ test('can simulate a boost creation', async () => {
233
+ const { core } = fixtures;
234
+ const { budget, erc20 } = budgets;
235
+ const simulated = await core.simulateCreateBoost({
236
+ protocolFee: 1n,
237
+ maxParticipants: 100n,
238
+ budget: budget,
239
+ action: core.EventAction(
240
+ makeMockEventActionPayload(
241
+ core.assertValidAddress(),
242
+ erc20.assertValidAddress(),
243
+ ),
244
+ ),
245
+ allowList: core.SimpleAllowList({
246
+ owner: defaultOptions.account.address,
247
+ allowed: [defaultOptions.account.address],
248
+ }),
249
+ incentives: [
250
+ core.ERC20Incentive({
251
+ asset: erc20.assertValidAddress(),
252
+ reward: parseEther('1'),
253
+ limit: 100n,
254
+ strategy: StrategyType.POOL,
255
+ manager: budget.assertValidAddress(),
256
+ }),
257
+ ],
258
+ });
259
+ expect(simulated.request.__mode).toBe('prepared')
260
+ });
261
+
262
+ test('can reuse an existing action', async () => {
263
+ const { core } = fixtures;
232
264
  const { budget, erc20 } = budgets;
233
265
 
234
266
  // allocate more funds to the budget
235
- await erc20.mint(defaultOptions.account.address, parseEther('100'));
236
- await erc20.approve(budget.assertValidAddress(), parseEther('100'));
267
+ await erc20.mint(defaultOptions.account.address, parseEther('110'));
268
+ await erc20.approve(budget.assertValidAddress(), parseEther('110'));
237
269
  await budget.allocate({
238
- amount: parseEther('100'),
270
+ amount: parseEther('110'),
239
271
  asset: erc20.assertValidAddress(),
240
272
  target: defaultOptions.account.address,
241
273
  });
242
274
 
243
- const _boost = await client.createBoost({
275
+ const _boost = await core.createBoost({
244
276
  budget: budget,
245
- action: new bases.EventAction(
246
- defaultOptions,
277
+ action: core.EventAction(
247
278
  makeMockEventActionPayload(
248
279
  core.assertValidAddress(),
249
280
  erc20.assertValidAddress(),
250
281
  ),
251
282
  ),
252
- validator: new bases.SignerValidator(defaultOptions, {
283
+ validator: core.SignerValidator({
253
284
  signers: [defaultOptions.account.address],
254
285
  validatorCaller: defaultOptions.account.address,
255
286
  }),
256
- allowList: new bases.SimpleAllowList(defaultOptions, {
287
+ allowList: core.SimpleAllowList({
257
288
  owner: defaultOptions.account.address,
258
289
  allowed: [defaultOptions.account.address],
259
290
  }),
260
291
  incentives: [
261
- new bases.ERC20Incentive(defaultOptions, {
292
+ core.ERC20Incentive({
262
293
  asset: erc20.assertValidAddress(),
263
294
  reward: parseEther('1'),
264
295
  limit: 100n,
265
296
  strategy: StrategyType.POOL,
297
+ manager: budget.assertValidAddress(),
266
298
  }),
267
299
  ],
268
300
  });
269
- const boost = await client.createBoost({
301
+ const boost = await core.createBoost({
270
302
  budget: budget,
271
- action: new bases.EventAction(
272
- defaultOptions,
273
- _boost.action.assertValidAddress(),
274
- false,
275
- ),
276
- validator: new bases.SignerValidator(defaultOptions, {
303
+ action: core.EventAction(_boost.action.assertValidAddress(), false),
304
+ validator: core.SignerValidator({
277
305
  signers: [defaultOptions.account.address],
278
306
  validatorCaller: defaultOptions.account.address,
279
307
  }),
280
- allowList: new bases.SimpleAllowList(defaultOptions, {
308
+ allowList: core.SimpleAllowList({
281
309
  owner: defaultOptions.account.address,
282
310
  allowed: [defaultOptions.account.address],
283
311
  }),
284
312
  incentives: [
285
- new bases.ERC20Incentive(defaultOptions, {
313
+ core.ERC20Incentive({
286
314
  asset: erc20.assertValidAddress(),
287
315
  reward: parseEther('1'),
288
316
  limit: 100n,
289
317
  strategy: StrategyType.POOL,
318
+ manager: budget.assertValidAddress(),
290
319
  }),
291
320
  ],
292
321
  });
293
- const onChainBoost = await client.readBoost(boost.id);
322
+ const onChainBoost = await core.readBoost(boost.id);
294
323
  expect(onChainBoost.action).toBe(_boost.action.assertValidAddress());
295
324
  });
296
325
 
297
326
  test('can reuse an existing validator', async () => {
298
- const { core, bases } = fixtures;
299
- const client = new BoostCore({
300
- ...defaultOptions,
301
- address: core.assertValidAddress(),
302
- });
303
-
304
- // to whom it may concern, this syntax is only used because we need to use test classes
305
- // that are preconfigured with the dynamic base addresses generated at test time.
306
- // normally you would use the follow api for brevity
307
- // budget: client.SimpleBudget({} | '0xaddress')
327
+ const { core } = fixtures;
308
328
  const { budget, erc20 } = budgets;
309
329
 
310
330
  // allocate more erc20 funds to the budget from the owning accound
311
- await erc20.mint(defaultOptions.account.address, parseEther('100'));
312
- await erc20.approve(budget.assertValidAddress(), parseEther('100'));
331
+ await erc20.mint(defaultOptions.account.address, parseEther('110'));
332
+ await erc20.approve(budget.assertValidAddress(), parseEther('110'));
313
333
  await budget.allocate({
314
- amount: parseEther('100'),
334
+ amount: parseEther('110'),
315
335
  asset: erc20.assertValidAddress(),
316
336
  target: defaultOptions.account.address,
317
337
  });
318
338
 
319
- const _boost = await client.createBoost({
339
+ const _boost = await core.createBoost({
320
340
  budget: budget,
321
- action: new bases.EventAction(
322
- defaultOptions,
341
+ action: core.EventAction(
323
342
  makeMockEventActionPayload(
324
343
  core.assertValidAddress(),
325
344
  erc20.assertValidAddress(),
326
345
  ),
327
346
  ),
328
- validator: new bases.SignerValidator(defaultOptions, {
347
+ validator: core.SignerValidator({
329
348
  signers: [defaultOptions.account.address],
330
349
  validatorCaller: defaultOptions.account.address,
331
350
  }),
332
- allowList: new bases.SimpleAllowList(defaultOptions, {
351
+ allowList: core.SimpleAllowList({
333
352
  owner: defaultOptions.account.address,
334
353
  allowed: [defaultOptions.account.address],
335
354
  }),
336
355
  incentives: [
337
- new bases.ERC20Incentive(defaultOptions, {
356
+ core.ERC20Incentive({
338
357
  asset: erc20.assertValidAddress(),
339
358
  reward: parseEther('1'),
340
359
  limit: 100n,
341
360
  strategy: StrategyType.POOL,
361
+ manager: budget.assertValidAddress(),
342
362
  }),
343
363
  ],
344
364
  });
345
- const boost = await client.createBoost({
365
+ const boost = await core.createBoost({
346
366
  budget: budget,
347
- action: new bases.EventAction(
348
- defaultOptions,
367
+ action: core.EventAction(
349
368
  makeMockEventActionPayload(
350
369
  core.assertValidAddress(),
351
370
  erc20.assertValidAddress(),
352
371
  ),
353
372
  ),
354
- validator: new bases.SignerValidator(
355
- defaultOptions,
373
+ validator: core.SignerValidator(
356
374
  _boost.validator.assertValidAddress(),
357
375
  false,
358
376
  ),
359
- allowList: new bases.SimpleAllowList(defaultOptions, {
377
+ allowList: core.SimpleAllowList({
360
378
  owner: defaultOptions.account.address,
361
379
  allowed: [defaultOptions.account.address],
362
380
  }),
363
381
  incentives: [
364
- new bases.ERC20Incentive(defaultOptions, {
382
+ core.ERC20Incentive({
365
383
  asset: erc20.assertValidAddress(),
366
384
  reward: parseEther('1'),
367
385
  limit: 100n,
368
386
  strategy: StrategyType.POOL,
387
+ manager: budget.assertValidAddress(),
369
388
  }),
370
389
  ],
371
390
  });
372
- const onChainBoost = await client.readBoost(boost.id);
391
+ const onChainBoost = await core.readBoost(boost.id);
373
392
  expect(onChainBoost.validator).toBe(_boost.validator.assertValidAddress());
374
393
  });
375
394
 
376
395
  test('can reuse an existing allowlist', async () => {
377
- const { core, bases } = fixtures;
378
- const client = new BoostCore({
379
- ...defaultOptions,
380
- address: core.assertValidAddress(),
381
- });
382
-
383
- // to whom it may concern, this syntax is only used because we need to use test classes
384
- // that are preconfigured with the dynamic base addresses generated at test time.
385
- // normally you would use the follow api for brevity
386
- // budget: client.SimpleBudget({} | '0xaddress')
396
+ const { core } = fixtures;
387
397
  const { budget, erc20 } = budgets;
388
398
 
389
399
  // allocate more erc20 funds to the budget from the owning accound
390
- await erc20.mint(defaultOptions.account.address, parseEther('100'));
391
- await erc20.approve(budget.assertValidAddress(), parseEther('100'));
400
+ await erc20.mint(defaultOptions.account.address, parseEther('110'));
401
+ await erc20.approve(budget.assertValidAddress(), parseEther('110'));
392
402
  await budget.allocate({
393
- amount: parseEther('100'),
403
+ amount: parseEther('110'),
394
404
  asset: erc20.assertValidAddress(),
395
405
  target: defaultOptions.account.address,
396
406
  });
397
407
 
398
- const _boost = await client.createBoost({
408
+ const _boost = await core.createBoost({
399
409
  budget: budget,
400
- action: new bases.EventAction(
401
- defaultOptions,
410
+ action: core.EventAction(
402
411
  makeMockEventActionPayload(
403
412
  core.assertValidAddress(),
404
413
  erc20.assertValidAddress(),
405
414
  ),
406
415
  ),
407
- validator: new bases.SignerValidator(defaultOptions, {
416
+ validator: core.SignerValidator({
408
417
  signers: [defaultOptions.account.address],
409
418
  validatorCaller: defaultOptions.account.address,
410
419
  }),
411
- allowList: new bases.SimpleAllowList(defaultOptions, {
420
+ allowList: core.SimpleAllowList({
412
421
  owner: defaultOptions.account.address,
413
422
  allowed: [defaultOptions.account.address],
414
423
  }),
415
424
  incentives: [
416
- new bases.ERC20Incentive(defaultOptions, {
425
+ core.ERC20Incentive({
417
426
  asset: erc20.assertValidAddress(),
418
427
  reward: parseEther('1'),
419
428
  limit: 100n,
420
429
  strategy: StrategyType.POOL,
430
+ manager: budget.assertValidAddress(),
421
431
  }),
422
432
  ],
423
433
  });
424
- const boost = await client.createBoost({
434
+ const boost = await core.createBoost({
425
435
  budget: budget,
426
- action: new bases.EventAction(
427
- defaultOptions,
436
+ action: core.EventAction(
428
437
  makeMockEventActionPayload(
429
438
  core.assertValidAddress(),
430
439
  erc20.assertValidAddress(),
431
440
  ),
432
441
  ),
433
- validator: new bases.SignerValidator(defaultOptions, {
442
+ validator: core.SignerValidator({
434
443
  signers: [defaultOptions.account.address],
435
444
  validatorCaller: defaultOptions.account.address,
436
445
  }),
437
- allowList: new bases.SimpleAllowList(
438
- defaultOptions,
446
+ allowList: core.SimpleAllowList(
439
447
  _boost.allowList.assertValidAddress(),
440
448
  false,
441
449
  ),
442
450
  incentives: [
443
- new bases.ERC20Incentive(defaultOptions, {
451
+ core.ERC20Incentive({
444
452
  asset: erc20.assertValidAddress(),
445
453
  reward: parseEther('1'),
446
454
  limit: 100n,
447
455
  strategy: StrategyType.POOL,
456
+ manager: budget.assertValidAddress(),
448
457
  }),
449
458
  ],
450
459
  });
451
- const onChainBoost = await client.readBoost(boost.id);
460
+ const onChainBoost = await core.readBoost(boost.id);
452
461
  expect(onChainBoost.allowList).toBe(_boost.allowList.assertValidAddress());
453
462
  });
454
463
 
455
464
  test('cannot reuse an existing incentive', async () => {
456
- const { core, bases } = fixtures;
457
- const client = new BoostCore({
458
- ...defaultOptions,
459
- address: core.assertValidAddress(),
460
- });
461
-
462
- // to whom it may concern, this syntax is only used because we need to use test classes
463
- // that are preconfigured with the dynamic base addresses generated at test time.
464
- // normally you would use the follow api for brevity
465
- // budget: client.SimpleBudget({} | '0xaddress')
465
+ const { core } = fixtures;
466
466
  const { budget, erc20 } = budgets;
467
467
 
468
468
  // allocate more erc20 funds to the budget from the owning accound
469
- await erc20.mint(defaultOptions.account.address, parseEther('100'));
470
- await erc20.approve(budget.assertValidAddress(), parseEther('100'));
469
+ await erc20.mint(defaultOptions.account.address, parseEther('110'));
470
+ await erc20.approve(budget.assertValidAddress(), parseEther('110'));
471
471
  await budget.allocate({
472
- amount: parseEther('100'),
472
+ amount: parseEther('110'),
473
473
  asset: erc20.assertValidAddress(),
474
474
  target: defaultOptions.account.address,
475
475
  });
476
476
 
477
- const incentive = new bases.ERC20Incentive(defaultOptions, {
477
+ const incentive = core.ERC20Incentive({
478
478
  asset: erc20.assertValidAddress(),
479
479
  reward: parseEther('1'),
480
480
  limit: 100n,
481
481
  strategy: StrategyType.POOL,
482
+ manager: budget.assertValidAddress(),
482
483
  });
483
- const _boost = await client.createBoost({
484
+ const _boost = await core.createBoost({
484
485
  budget: budget,
485
- action: new bases.EventAction(
486
- defaultOptions,
486
+ action: core.EventAction(
487
487
  makeMockEventActionPayload(
488
488
  core.assertValidAddress(),
489
489
  erc20.assertValidAddress(),
490
490
  ),
491
491
  ),
492
- validator: new bases.SignerValidator(defaultOptions, {
492
+ validator: core.SignerValidator({
493
493
  signers: [defaultOptions.account.address],
494
494
  validatorCaller: defaultOptions.account.address,
495
495
  }),
496
- allowList: new bases.SimpleAllowList(defaultOptions, {
496
+ allowList: core.SimpleAllowList({
497
497
  owner: defaultOptions.account.address,
498
498
  allowed: [defaultOptions.account.address],
499
499
  }),
500
500
  incentives: [incentive],
501
501
  });
502
502
  try {
503
- await client.createBoost({
503
+ await core.createBoost({
504
504
  budget: budget,
505
- action: new bases.EventAction(
506
- defaultOptions,
505
+ action: core.EventAction(
507
506
  makeMockEventActionPayload(
508
507
  core.assertValidAddress(),
509
508
  erc20.assertValidAddress(),
510
509
  ),
511
510
  ),
512
- validator: new bases.SignerValidator(defaultOptions, {
511
+ validator: core.SignerValidator({
513
512
  signers: [defaultOptions.account.address],
514
513
  validatorCaller: defaultOptions.account.address,
515
514
  }),
516
- allowList: new bases.SimpleAllowList(defaultOptions, {
515
+ allowList: core.SimpleAllowList({
517
516
  owner: defaultOptions.account.address,
518
517
  allowed: [defaultOptions.account.address],
519
518
  }),
@@ -525,79 +524,66 @@ describe('BoostCore', () => {
525
524
  });
526
525
 
527
526
  test('can offer multiple incentives', async () => {
528
- const { registry, core, bases } = fixtures;
529
- const client = new BoostCore({
530
- ...defaultOptions,
531
- address: core.assertValidAddress(),
532
- });
533
-
534
- // to whom it may concern, this syntax is only used because we need to use test classes
535
- // that are preconfigured with the dynamic base addresses generated at test time.
536
- // normally you would use the follow api for brevity
537
- // budget: client.SimpleBudget({} | '0xaddress')
527
+ const { registry, core } = fixtures;
538
528
  const { budget, erc20, points, erc1155 } = budgets;
539
- const allowList = await registry.clone(
529
+ const allowList = await registry.initialize(
540
530
  'SharedAllowList',
541
- new bases.SimpleAllowList(defaultOptions, {
531
+ core.SimpleAllowList({
542
532
  owner: defaultOptions.account.address,
543
533
  allowed: [defaultOptions.account.address],
544
534
  }),
545
535
  );
546
536
 
547
- const erc20Incentive = new bases.ERC20Incentive(defaultOptions, {
537
+ const erc20Incentive = core.ERC20Incentive({
548
538
  asset: erc20.assertValidAddress(),
549
539
  reward: 1n,
550
540
  limit: 10n,
551
541
  strategy: StrategyType.POOL,
542
+ manager: budget.assertValidAddress(),
552
543
  });
553
- const erc1155Incentive = new bases.ERC1155Incentive(defaultOptions, {
554
- asset: erc1155.assertValidAddress(),
555
- strategy: ERC1155StrategyType.POOL,
556
- limit: 1n,
557
- tokenId: 1n,
558
- extraData: '0x',
559
- });
560
- const cgdaIncentive = new bases.CGDAIncentive(defaultOptions, {
544
+ // const erc1155Incentive = core.ERC1155Incentive({
545
+ // asset: erc1155.assertValidAddress(),
546
+ // strategy: ERC1155StrategyType.POOL,
547
+ // limit: 1n,
548
+ // tokenId: 1n,
549
+ // extraData: '0x',
550
+ // });
551
+ const cgdaIncentive = core.CGDAIncentive({
561
552
  asset: erc20.assertValidAddress(),
562
553
  initialReward: 1n,
563
554
  totalBudget: 10n,
564
555
  rewardBoost: 1n,
565
556
  rewardDecay: 1n,
557
+ manager: budget.assertValidAddress(),
566
558
  });
567
- const allowListIncentive = new bases.AllowListIncentive(defaultOptions, {
559
+ const allowListIncentive = core.AllowListIncentive({
568
560
  allowList: allowList.assertValidAddress(),
569
561
  limit: 5n,
570
562
  });
571
- const pointsIncentive = new bases.PointsIncentive(defaultOptions, {
563
+ const pointsIncentive = core.PointsIncentive({
572
564
  venue: points.assertValidAddress(),
573
565
  selector: bytes4('issue(address,uint256)'),
574
566
  reward: 1n,
575
567
  limit: 10n,
576
568
  });
577
569
 
578
- await client.createBoost({
570
+ await core.createBoost({
579
571
  protocolFee: 1n,
580
- referralFee: 2n,
581
572
  maxParticipants: 100n,
582
573
  budget: budget,
583
- action: new bases.EventAction(
584
- defaultOptions,
574
+ action: core.EventAction(
585
575
  makeMockEventActionPayload(
586
576
  core.assertValidAddress(),
587
577
  erc20.assertValidAddress(),
588
578
  ),
589
579
  ),
590
- validator: new bases.SignerValidator(defaultOptions, {
580
+ validator: core.SignerValidator({
591
581
  signers: [defaultOptions.account.address],
592
582
  validatorCaller: defaultOptions.account.address,
593
583
  }),
594
- allowList: new bases.SimpleAllowList(
595
- defaultOptions,
596
- allowList.assertValidAddress(),
597
- false,
598
- ),
584
+ allowList: core.SimpleAllowList(allowList.assertValidAddress()),
599
585
  incentives: [
600
- erc1155Incentive,
586
+ // erc1155Incentive,
601
587
  erc20Incentive,
602
588
  cgdaIncentive,
603
589
  allowListIncentive,
@@ -622,58 +608,24 @@ describe('BoostCore', () => {
622
608
 
623
609
  test('can get the protocol fee', async () => {
624
610
  const { core } = fixtures;
625
- const client = new BoostCore({
626
- ...defaultOptions,
627
- address: core.assertValidAddress(),
628
- });
629
611
 
630
- expect(await client.protocolFee()).toBe(1000n);
612
+ expect(await core.protocolFee()).toBe(1000n);
631
613
  });
632
614
 
633
615
  test('can get the protocol fee receiver', async () => {
634
616
  const { core } = fixtures;
635
- const client = new BoostCore({
636
- ...defaultOptions,
637
- address: core.assertValidAddress(),
638
- });
639
617
 
640
- expect(await client.protocolFeeReceiver()).toBe(
618
+ expect(await core.protocolFeeReceiver()).toBe(
641
619
  defaultOptions.account.address,
642
620
  );
643
621
  });
644
622
 
645
623
  test('can set the protocol fee receiver', async () => {
646
624
  const { core } = fixtures;
647
- const client = new BoostCore({
648
- ...defaultOptions,
649
- address: core.assertValidAddress(),
650
- });
651
-
652
- await client.setProcolFeeReceiver(zeroAddress);
653
-
654
- expect(await client.protocolFeeReceiver()).toBe(zeroAddress);
655
- });
656
-
657
- test('can get the claim fee', async () => {
658
- const { core } = fixtures;
659
- const client = new BoostCore({
660
- ...defaultOptions,
661
- address: core.assertValidAddress(),
662
- });
663
-
664
- expect(await client.claimFee()).toBe(75000000000000n);
665
- });
666
-
667
- test('can set the claim fee', async () => {
668
- const { core } = fixtures;
669
- const client = new BoostCore({
670
- ...defaultOptions,
671
- address: core.assertValidAddress(),
672
- });
673
625
 
674
- await client.setClaimFee(100n);
626
+ await core.setProcolFeeReceiver(zeroAddress);
675
627
 
676
- expect(await client.claimFee()).toBe(100n);
628
+ expect(await core.protocolFeeReceiver()).toBe(zeroAddress);
677
629
  });
678
630
 
679
631
  test('binds all actions, budgets, allowlists, incentives, and validators to reuse core options and account', () => {
@@ -724,6 +676,7 @@ describe('BoostCore', () => {
724
676
  rewardDecay: 0n,
725
677
  rewardBoost: 0n,
726
678
  totalBudget: 0n,
679
+ manager: zeroAddress,
727
680
  });
728
681
  expect(cgdaIncentive._config).toEqual(defaultOptions.config);
729
682
  expect(cgdaIncentive._account).toEqual(defaultOptions.account);
@@ -772,44 +725,34 @@ describe('BoostCore', () => {
772
725
  test('can subscribe to contract events', async () => {
773
726
  const subscription = vi.fn();
774
727
 
775
- const { core, bases } = fixtures;
776
- const client = new BoostCore({
777
- ...defaultOptions,
778
- address: core.assertValidAddress(),
779
- });
780
- client.subscribe(subscription, { pollingInterval: 100 });
781
-
782
- // to whom it may concern, this syntax is only used because we need to use test classes
783
- // that are preconfigured with the dynamic base addresses generated at test time.
784
- // normally you would use the follow api for brevity
785
- // budget: client.SimpleBudget({} | '0xaddress')
728
+ const { core } = fixtures;
729
+ core.subscribe(subscription, { pollingInterval: 100 });
786
730
  const { budget, erc20 } = budgets;
787
- await client.createBoost({
731
+ await core.createBoost({
788
732
  protocolFee: 1n,
789
- referralFee: 2n,
790
733
  maxParticipants: 100n,
791
734
  budget: budget,
792
- action: new bases.EventAction(
793
- defaultOptions,
735
+ action: core.EventAction(
794
736
  makeMockEventActionPayload(
795
737
  core.assertValidAddress(),
796
738
  erc20.assertValidAddress(),
797
739
  ),
798
740
  ),
799
- validator: new bases.SignerValidator(defaultOptions, {
741
+ validator: core.SignerValidator({
800
742
  signers: [defaultOptions.account.address],
801
743
  validatorCaller: defaultOptions.account.address,
802
744
  }),
803
- allowList: new bases.SimpleAllowList(defaultOptions, {
745
+ allowList: core.SimpleAllowList({
804
746
  owner: defaultOptions.account.address,
805
747
  allowed: [defaultOptions.account.address],
806
748
  }),
807
749
  incentives: [
808
- new bases.ERC20Incentive(defaultOptions, {
750
+ core.ERC20Incentive({
809
751
  asset: erc20.assertValidAddress(),
810
752
  reward: parseEther('1'),
811
753
  limit: 100n,
812
754
  strategy: StrategyType.POOL,
755
+ manager: budget.assertValidAddress(),
813
756
  }),
814
757
  ],
815
758
  });
@@ -823,17 +766,129 @@ describe('BoostCore', () => {
823
766
 
824
767
  test('can set a passthrough auth scheme', async () => {
825
768
  const { core } = fixtures;
826
- const client = new BoostCore({
827
- ...defaultOptions,
828
- address: core.assertValidAddress(),
829
- });
830
769
 
831
- const auth = client.PassthroughAuth();
770
+ const auth = core.PassthroughAuth();
832
771
  await auth.deploy();
833
- await client.setCreateBoostAuth(auth);
834
- expect((await client.createBoostAuth()).toLowerCase()).toBe(
772
+ await core.setCreateBoostAuth(auth);
773
+ expect((await core.createBoostAuth()).toLowerCase()).toBe(
835
774
  auth.assertValidAddress(),
836
775
  );
837
- expect(await client.isAuthorized(zeroAddress)).toBe(true);
776
+ expect(await core.isAuthorized(zeroAddress)).toBe(true);
777
+ });
778
+
779
+ test('uses the provided validator when one is specified', async () => {
780
+ const { core } = fixtures;
781
+ const { budget, erc20 } = budgets;
782
+ const customValidator = core.SignerValidator({
783
+ signers: [budget.assertValidAddress()],
784
+ validatorCaller: core.assertValidAddress(),
785
+ });
786
+ const boost = await core.createBoost({
787
+ maxParticipants: 100n,
788
+ budget: budget,
789
+ action: core.EventAction(
790
+ makeMockEventActionPayload(
791
+ core.assertValidAddress(),
792
+ erc20.assertValidAddress(),
793
+ ),
794
+ ),
795
+ validator: customValidator,
796
+ allowList: core.SimpleAllowList({
797
+ owner: defaultOptions.account.address,
798
+ allowed: [defaultOptions.account.address],
799
+ }),
800
+ incentives: [
801
+ core.ERC20Incentive({
802
+ asset: erc20.assertValidAddress(),
803
+ reward: parseEther('1'),
804
+ limit: 100n,
805
+ strategy: StrategyType.POOL,
806
+ manager: budget.assertValidAddress(),
807
+ }),
808
+ ],
809
+ });
810
+
811
+ expect(boost.validator).toBe(customValidator);
812
+ const signers = await boost.validator.signers(budget.assertValidAddress());
813
+ expect(signers).toBe(true);
814
+ });
815
+
816
+ test('creates a boost with a default validator when none is provided', async () => {
817
+ const { core } = fixtures;
818
+ const { budget, erc20 } = budgets;
819
+ const boost = await core.createBoost({
820
+ maxParticipants: 100n,
821
+ budget: budget,
822
+ action: core.EventAction(
823
+ makeMockEventActionPayload(
824
+ core.assertValidAddress(),
825
+ erc20.assertValidAddress(),
826
+ ),
827
+ ),
828
+ allowList: core.OpenAllowList(),
829
+ incentives: [
830
+ core.ERC20Incentive({
831
+ asset: erc20.assertValidAddress(),
832
+ reward: parseEther('1'),
833
+ limit: 100n,
834
+ strategy: StrategyType.POOL,
835
+ manager: budget.assertValidAddress(),
836
+ }),
837
+ ],
838
+ });
839
+
840
+ const validator = boost.validator;
841
+
842
+ // expect boostCore to be a validatorCaller
843
+ expect(validator.payload?.validatorCaller).toBe(core.assertValidAddress());
844
+
845
+ // expect current account to be a signer
846
+ const signer = await validator.signers(defaultOptions.account.address);
847
+ expect(signer).toBeDefined();
848
+ expect(signer).toBe(true);
849
+ });
850
+
851
+ test('can retrieve the BoostClaimed event from a transaction hash', async () => {
852
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
853
+ const referrer = accounts.at(1)!.account!,
854
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
855
+ trustedSigner = accounts.at(0)!;
856
+ const erc20Incentive = fixtures.core.ERC20Incentive({
857
+ asset: budgets.erc20.assertValidAddress(),
858
+ strategy: StrategyType.POOL,
859
+ reward: 1n,
860
+ limit: 1n,
861
+ manager: budgets.budget.assertValidAddress(),
862
+ });
863
+ const boost = await freshBoost(fixtures, {
864
+ budget: budgets.budget,
865
+ incentives: [erc20Incentive],
866
+ });
867
+
868
+ const claimant = trustedSigner.account;
869
+ const incentiveData = pad('0xdef456232173821931823712381232131391321934');
870
+ const incentiveQuantity = 1;
871
+ const claimDataPayload = await boost.validator.encodeClaimData({
872
+ signer: trustedSigner,
873
+ incentiveData,
874
+ chainId: defaultOptions.config.chains[0].id,
875
+ incentiveQuantity,
876
+ claimant,
877
+ boostId: boost.id,
878
+ });
879
+
880
+ const { hash } = await fixtures.core.claimIncentiveRaw(
881
+ boost.id,
882
+ 0n,
883
+ referrer,
884
+ claimDataPayload,
885
+ { value: BOOST_CORE_CLAIM_FEE },
886
+ );
887
+
888
+ const claimInfo = await fixtures.core.getClaimFromTransaction({ hash });
889
+ expect(claimInfo).toBeDefined();
890
+ expect(claimInfo?.claimant).toBe(claimant);
891
+ expect(typeof claimInfo?.boostId).toBe('bigint');
892
+ expect(claimInfo?.referrer).toBe(referrer);
838
893
  });
839
894
  });