@boostxyz/sdk 0.0.0-alpha.11 → 0.0.0-alpha.13
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.
- package/dist/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.js +1 -1
- package/dist/Actions/ContractAction.d.ts +2 -2
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +2 -2
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +117 -33
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +309 -121
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +2 -2
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +2 -2
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +23 -19
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +2 -2
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +6 -5
- package/dist/AllowLists/SimpleDenyList.js.map +1 -1
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +27 -5
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +438 -347
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.cjs.map +1 -1
- package/dist/BoostRegistry.d.ts +26 -5
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +125 -64
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +2 -2
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +41 -37
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/SimpleBudget.d.ts +2 -2
- package/dist/Budgets/SimpleBudget.d.ts.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +2 -2
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -1
- package/dist/Deployable/DeployableTarget.d.ts +6 -6
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +22 -17
- package/dist/Deployable/DeployableTarget.js.map +1 -1
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +2 -2
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +17 -13
- package/dist/Incentives/AllowListIncentive.js.map +1 -1
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
- package/dist/Incentives/CGDAIncentive.d.ts +14 -2
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +27 -23
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +2 -2
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.d.ts +2 -2
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +17 -13
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.d.ts +2 -2
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.cjs.map +1 -1
- package/dist/Incentives/Incentive.js +34 -30
- package/dist/Incentives/Incentive.js.map +1 -1
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts +2 -2
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +13 -9
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/{SimpleDenyList-4PtOPXTc.js → SimpleDenyList-C21O9Yfi.js} +23 -19
- package/dist/SimpleDenyList-C21O9Yfi.js.map +1 -0
- package/dist/SimpleDenyList-DeJRKD2D.cjs +2 -0
- package/dist/{SimpleDenyList-4PtOPXTc.js.map → SimpleDenyList-DeJRKD2D.cjs.map} +1 -1
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +2 -2
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +18 -14
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.js +1 -1
- package/dist/deployments-BvFcK_eR.js +40 -0
- package/dist/deployments-BvFcK_eR.js.map +1 -0
- package/dist/deployments-Ho4PnGCS.cjs +2 -0
- package/dist/deployments-Ho4PnGCS.cjs.map +1 -0
- package/dist/deployments.json +38 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +122 -20
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +98 -28
- package/dist/errors.js.map +1 -1
- package/dist/{generated-BDeDiaCK.js → generated-LpgSHrH0.js} +150 -110
- package/dist/generated-LpgSHrH0.js.map +1 -0
- package/dist/generated-tq_HLZJ0.cjs +3 -0
- package/dist/generated-tq_HLZJ0.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +115 -108
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +25 -11
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +38 -23
- package/dist/utils.js.map +1 -1
- package/package.json +10 -6
- package/src/Actions/Action.test.ts +8 -4
- package/src/Actions/ContractAction.ts +5 -3
- package/src/Actions/ERC721MintAction.ts +5 -3
- package/src/Actions/EventAction.test.ts +528 -100
- package/src/Actions/EventAction.ts +302 -60
- package/src/AllowLists/AllowList.test.ts +1 -1
- package/src/AllowLists/SimpleAllowList.ts +6 -3
- package/src/AllowLists/SimpleDenyList.ts +6 -3
- package/src/BoostCore.test.ts +31 -91
- package/src/BoostCore.ts +137 -34
- package/src/BoostRegistry.ts +89 -21
- package/src/Budgets/ManagedBudget.ts +6 -4
- package/src/Budgets/SimpleBudget.ts +4 -3
- package/src/Budgets/VestingBudget.ts +4 -3
- package/src/Deployable/DeployableTarget.ts +22 -11
- package/src/Incentives/AllowListIncentive.ts +6 -3
- package/src/Incentives/CGDAIncentive.ts +6 -3
- package/src/Incentives/ERC1155Incentive.ts +4 -3
- package/src/Incentives/ERC20Incentive.ts +6 -3
- package/src/Incentives/ERC20VariableIncentive.ts +6 -3
- package/src/Incentives/PointsIncentive.ts +6 -3
- package/src/Validators/SignerValidator.ts +6 -3
- package/src/errors.ts +177 -21
- package/src/utils.ts +60 -11
- package/dist/SimpleDenyList-CqT0BMP7.cjs +0 -2
- package/dist/SimpleDenyList-CqT0BMP7.cjs.map +0 -1
- package/dist/generated-BDeDiaCK.js.map +0 -1
- package/dist/generated-wKBNvm48.cjs +0 -3
- package/dist/generated-wKBNvm48.cjs.map +0 -1
package/src/BoostCore.test.ts
CHANGED
|
@@ -29,13 +29,9 @@ describe('BoostCore', () => {
|
|
|
29
29
|
|
|
30
30
|
test('can get the total number of boosts', async () => {
|
|
31
31
|
const { core } = fixtures;
|
|
32
|
-
const client = new BoostCore({
|
|
33
|
-
...defaultOptions,
|
|
34
|
-
address: core.assertValidAddress(),
|
|
35
|
-
});
|
|
36
32
|
|
|
37
33
|
const { budget, erc20 } = budgets;
|
|
38
|
-
await
|
|
34
|
+
await core.createBoost({
|
|
39
35
|
protocolFee: 1n,
|
|
40
36
|
referralFee: 2n,
|
|
41
37
|
maxParticipants: 100n,
|
|
@@ -63,17 +59,13 @@ describe('BoostCore', () => {
|
|
|
63
59
|
}),
|
|
64
60
|
],
|
|
65
61
|
});
|
|
66
|
-
expect(await
|
|
62
|
+
expect(await core.getBoostCount()).toBe(1n);
|
|
67
63
|
});
|
|
68
64
|
|
|
69
65
|
test('can successfully create a boost using all base contract implementations', async () => {
|
|
70
66
|
const { core } = fixtures;
|
|
71
|
-
const client = new BoostCore({
|
|
72
|
-
...defaultOptions,
|
|
73
|
-
address: core.assertValidAddress(),
|
|
74
|
-
});
|
|
75
67
|
const { budget, erc20 } = budgets;
|
|
76
|
-
const boost = await
|
|
68
|
+
const boost = await core.createBoost({
|
|
77
69
|
protocolFee: 1n,
|
|
78
70
|
referralFee: 2n,
|
|
79
71
|
maxParticipants: 100n,
|
|
@@ -101,7 +93,7 @@ describe('BoostCore', () => {
|
|
|
101
93
|
}),
|
|
102
94
|
],
|
|
103
95
|
});
|
|
104
|
-
const onChainBoost = await
|
|
96
|
+
const onChainBoost = await core.readBoost(boost.id);
|
|
105
97
|
|
|
106
98
|
expect(boost.owner).toBe(onChainBoost.owner);
|
|
107
99
|
expect(boost.protocolFee).toBe(onChainBoost.protocolFee);
|
|
@@ -155,12 +147,8 @@ describe('BoostCore', () => {
|
|
|
155
147
|
|
|
156
148
|
test('can read the raw on chain representation of a boost', async () => {
|
|
157
149
|
const { core } = fixtures;
|
|
158
|
-
const client = new BoostCore({
|
|
159
|
-
...defaultOptions,
|
|
160
|
-
address: core.assertValidAddress(),
|
|
161
|
-
});
|
|
162
150
|
const { budget, erc20 } = budgets;
|
|
163
|
-
const _boost = await
|
|
151
|
+
const _boost = await core.createBoost({
|
|
164
152
|
protocolFee: 1n,
|
|
165
153
|
referralFee: 2n,
|
|
166
154
|
maxParticipants: 100n,
|
|
@@ -188,7 +176,7 @@ describe('BoostCore', () => {
|
|
|
188
176
|
}),
|
|
189
177
|
],
|
|
190
178
|
});
|
|
191
|
-
const boost = await
|
|
179
|
+
const boost = await core.readBoost(_boost.id);
|
|
192
180
|
expect(boost.protocolFee).toBe(1001n);
|
|
193
181
|
expect(boost.referralFee).toBe(1002n);
|
|
194
182
|
expect(boost.maxParticipants).toBe(100n);
|
|
@@ -203,10 +191,6 @@ describe('BoostCore', () => {
|
|
|
203
191
|
|
|
204
192
|
test('can reuse an existing action', async () => {
|
|
205
193
|
const { core } = fixtures;
|
|
206
|
-
const client = new BoostCore({
|
|
207
|
-
...defaultOptions,
|
|
208
|
-
address: core.assertValidAddress(),
|
|
209
|
-
});
|
|
210
194
|
const { budget, erc20 } = budgets;
|
|
211
195
|
|
|
212
196
|
// allocate more funds to the budget
|
|
@@ -218,7 +202,7 @@ describe('BoostCore', () => {
|
|
|
218
202
|
target: defaultOptions.account.address,
|
|
219
203
|
});
|
|
220
204
|
|
|
221
|
-
const _boost = await
|
|
205
|
+
const _boost = await core.createBoost({
|
|
222
206
|
budget: budget,
|
|
223
207
|
action: core.EventAction(
|
|
224
208
|
makeMockEventActionPayload(
|
|
@@ -243,7 +227,7 @@ describe('BoostCore', () => {
|
|
|
243
227
|
}),
|
|
244
228
|
],
|
|
245
229
|
});
|
|
246
|
-
const boost = await
|
|
230
|
+
const boost = await core.createBoost({
|
|
247
231
|
budget: budget,
|
|
248
232
|
action: core.EventAction(_boost.action.assertValidAddress(), false),
|
|
249
233
|
validator: core.SignerValidator({
|
|
@@ -263,16 +247,12 @@ describe('BoostCore', () => {
|
|
|
263
247
|
}),
|
|
264
248
|
],
|
|
265
249
|
});
|
|
266
|
-
const onChainBoost = await
|
|
250
|
+
const onChainBoost = await core.readBoost(boost.id);
|
|
267
251
|
expect(onChainBoost.action).toBe(_boost.action.assertValidAddress());
|
|
268
252
|
});
|
|
269
253
|
|
|
270
254
|
test('can reuse an existing validator', async () => {
|
|
271
255
|
const { core } = fixtures;
|
|
272
|
-
const client = new BoostCore({
|
|
273
|
-
...defaultOptions,
|
|
274
|
-
address: core.assertValidAddress(),
|
|
275
|
-
});
|
|
276
256
|
const { budget, erc20 } = budgets;
|
|
277
257
|
|
|
278
258
|
// allocate more erc20 funds to the budget from the owning accound
|
|
@@ -284,7 +264,7 @@ describe('BoostCore', () => {
|
|
|
284
264
|
target: defaultOptions.account.address,
|
|
285
265
|
});
|
|
286
266
|
|
|
287
|
-
const _boost = await
|
|
267
|
+
const _boost = await core.createBoost({
|
|
288
268
|
budget: budget,
|
|
289
269
|
action: core.EventAction(
|
|
290
270
|
makeMockEventActionPayload(
|
|
@@ -309,7 +289,7 @@ describe('BoostCore', () => {
|
|
|
309
289
|
}),
|
|
310
290
|
],
|
|
311
291
|
});
|
|
312
|
-
const boost = await
|
|
292
|
+
const boost = await core.createBoost({
|
|
313
293
|
budget: budget,
|
|
314
294
|
action: core.EventAction(
|
|
315
295
|
makeMockEventActionPayload(
|
|
@@ -334,16 +314,12 @@ describe('BoostCore', () => {
|
|
|
334
314
|
}),
|
|
335
315
|
],
|
|
336
316
|
});
|
|
337
|
-
const onChainBoost = await
|
|
317
|
+
const onChainBoost = await core.readBoost(boost.id);
|
|
338
318
|
expect(onChainBoost.validator).toBe(_boost.validator.assertValidAddress());
|
|
339
319
|
});
|
|
340
320
|
|
|
341
321
|
test('can reuse an existing allowlist', async () => {
|
|
342
322
|
const { core } = fixtures;
|
|
343
|
-
const client = new BoostCore({
|
|
344
|
-
...defaultOptions,
|
|
345
|
-
address: core.assertValidAddress(),
|
|
346
|
-
});
|
|
347
323
|
const { budget, erc20 } = budgets;
|
|
348
324
|
|
|
349
325
|
// allocate more erc20 funds to the budget from the owning accound
|
|
@@ -355,7 +331,7 @@ describe('BoostCore', () => {
|
|
|
355
331
|
target: defaultOptions.account.address,
|
|
356
332
|
});
|
|
357
333
|
|
|
358
|
-
const _boost = await
|
|
334
|
+
const _boost = await core.createBoost({
|
|
359
335
|
budget: budget,
|
|
360
336
|
action: core.EventAction(
|
|
361
337
|
makeMockEventActionPayload(
|
|
@@ -380,7 +356,7 @@ describe('BoostCore', () => {
|
|
|
380
356
|
}),
|
|
381
357
|
],
|
|
382
358
|
});
|
|
383
|
-
const boost = await
|
|
359
|
+
const boost = await core.createBoost({
|
|
384
360
|
budget: budget,
|
|
385
361
|
action: core.EventAction(
|
|
386
362
|
makeMockEventActionPayload(
|
|
@@ -405,16 +381,12 @@ describe('BoostCore', () => {
|
|
|
405
381
|
}),
|
|
406
382
|
],
|
|
407
383
|
});
|
|
408
|
-
const onChainBoost = await
|
|
384
|
+
const onChainBoost = await core.readBoost(boost.id);
|
|
409
385
|
expect(onChainBoost.allowList).toBe(_boost.allowList.assertValidAddress());
|
|
410
386
|
});
|
|
411
387
|
|
|
412
388
|
test('cannot reuse an existing incentive', async () => {
|
|
413
389
|
const { core } = fixtures;
|
|
414
|
-
const client = new BoostCore({
|
|
415
|
-
...defaultOptions,
|
|
416
|
-
address: core.assertValidAddress(),
|
|
417
|
-
});
|
|
418
390
|
const { budget, erc20 } = budgets;
|
|
419
391
|
|
|
420
392
|
// allocate more erc20 funds to the budget from the owning accound
|
|
@@ -432,7 +404,7 @@ describe('BoostCore', () => {
|
|
|
432
404
|
limit: 100n,
|
|
433
405
|
strategy: StrategyType.POOL,
|
|
434
406
|
});
|
|
435
|
-
const _boost = await
|
|
407
|
+
const _boost = await core.createBoost({
|
|
436
408
|
budget: budget,
|
|
437
409
|
action: core.EventAction(
|
|
438
410
|
makeMockEventActionPayload(
|
|
@@ -451,7 +423,7 @@ describe('BoostCore', () => {
|
|
|
451
423
|
incentives: [incentive],
|
|
452
424
|
});
|
|
453
425
|
try {
|
|
454
|
-
await
|
|
426
|
+
await core.createBoost({
|
|
455
427
|
budget: budget,
|
|
456
428
|
action: core.EventAction(
|
|
457
429
|
makeMockEventActionPayload(
|
|
@@ -476,10 +448,6 @@ describe('BoostCore', () => {
|
|
|
476
448
|
|
|
477
449
|
test('can offer multiple incentives', async () => {
|
|
478
450
|
const { registry, core } = fixtures;
|
|
479
|
-
const client = new BoostCore({
|
|
480
|
-
...defaultOptions,
|
|
481
|
-
address: core.assertValidAddress(),
|
|
482
|
-
});
|
|
483
451
|
const { budget, erc20, points, erc1155 } = budgets;
|
|
484
452
|
const allowList = await registry.initialize(
|
|
485
453
|
'SharedAllowList',
|
|
@@ -520,7 +488,7 @@ describe('BoostCore', () => {
|
|
|
520
488
|
limit: 10n,
|
|
521
489
|
});
|
|
522
490
|
|
|
523
|
-
await
|
|
491
|
+
await core.createBoost({
|
|
524
492
|
protocolFee: 1n,
|
|
525
493
|
referralFee: 2n,
|
|
526
494
|
maxParticipants: 100n,
|
|
@@ -562,58 +530,38 @@ describe('BoostCore', () => {
|
|
|
562
530
|
|
|
563
531
|
test('can get the protocol fee', async () => {
|
|
564
532
|
const { core } = fixtures;
|
|
565
|
-
const client = new BoostCore({
|
|
566
|
-
...defaultOptions,
|
|
567
|
-
address: core.assertValidAddress(),
|
|
568
|
-
});
|
|
569
533
|
|
|
570
|
-
expect(await
|
|
534
|
+
expect(await core.protocolFee()).toBe(1000n);
|
|
571
535
|
});
|
|
572
536
|
|
|
573
537
|
test('can get the protocol fee receiver', async () => {
|
|
574
538
|
const { core } = fixtures;
|
|
575
|
-
const client = new BoostCore({
|
|
576
|
-
...defaultOptions,
|
|
577
|
-
address: core.assertValidAddress(),
|
|
578
|
-
});
|
|
579
539
|
|
|
580
|
-
expect(await
|
|
540
|
+
expect(await core.protocolFeeReceiver()).toBe(
|
|
581
541
|
defaultOptions.account.address,
|
|
582
542
|
);
|
|
583
543
|
});
|
|
584
544
|
|
|
585
545
|
test('can set the protocol fee receiver', async () => {
|
|
586
546
|
const { core } = fixtures;
|
|
587
|
-
const client = new BoostCore({
|
|
588
|
-
...defaultOptions,
|
|
589
|
-
address: core.assertValidAddress(),
|
|
590
|
-
});
|
|
591
547
|
|
|
592
|
-
await
|
|
548
|
+
await core.setProcolFeeReceiver(zeroAddress);
|
|
593
549
|
|
|
594
|
-
expect(await
|
|
550
|
+
expect(await core.protocolFeeReceiver()).toBe(zeroAddress);
|
|
595
551
|
});
|
|
596
552
|
|
|
597
553
|
test('can get the claim fee', async () => {
|
|
598
554
|
const { core } = fixtures;
|
|
599
|
-
const client = new BoostCore({
|
|
600
|
-
...defaultOptions,
|
|
601
|
-
address: core.assertValidAddress(),
|
|
602
|
-
});
|
|
603
555
|
|
|
604
|
-
expect(await
|
|
556
|
+
expect(await core.claimFee()).toBe(75000000000000n);
|
|
605
557
|
});
|
|
606
558
|
|
|
607
559
|
test('can set the claim fee', async () => {
|
|
608
560
|
const { core } = fixtures;
|
|
609
|
-
const client = new BoostCore({
|
|
610
|
-
...defaultOptions,
|
|
611
|
-
address: core.assertValidAddress(),
|
|
612
|
-
});
|
|
613
561
|
|
|
614
|
-
await
|
|
562
|
+
await core.setClaimFee(100n);
|
|
615
563
|
|
|
616
|
-
expect(await
|
|
564
|
+
expect(await core.claimFee()).toBe(100n);
|
|
617
565
|
});
|
|
618
566
|
|
|
619
567
|
test('binds all actions, budgets, allowlists, incentives, and validators to reuse core options and account', () => {
|
|
@@ -713,13 +661,9 @@ describe('BoostCore', () => {
|
|
|
713
661
|
const subscription = vi.fn();
|
|
714
662
|
|
|
715
663
|
const { core } = fixtures;
|
|
716
|
-
|
|
717
|
-
...defaultOptions,
|
|
718
|
-
address: core.assertValidAddress(),
|
|
719
|
-
});
|
|
720
|
-
client.subscribe(subscription, { pollingInterval: 100 });
|
|
664
|
+
core.subscribe(subscription, { pollingInterval: 100 });
|
|
721
665
|
const { budget, erc20 } = budgets;
|
|
722
|
-
await
|
|
666
|
+
await core.createBoost({
|
|
723
667
|
protocolFee: 1n,
|
|
724
668
|
referralFee: 2n,
|
|
725
669
|
maxParticipants: 100n,
|
|
@@ -757,17 +701,13 @@ describe('BoostCore', () => {
|
|
|
757
701
|
|
|
758
702
|
test('can set a passthrough auth scheme', async () => {
|
|
759
703
|
const { core } = fixtures;
|
|
760
|
-
const client = new BoostCore({
|
|
761
|
-
...defaultOptions,
|
|
762
|
-
address: core.assertValidAddress(),
|
|
763
|
-
});
|
|
764
704
|
|
|
765
|
-
const auth =
|
|
705
|
+
const auth = core.PassthroughAuth();
|
|
766
706
|
await auth.deploy();
|
|
767
|
-
await
|
|
768
|
-
expect((await
|
|
707
|
+
await core.setCreateBoostAuth(auth);
|
|
708
|
+
expect((await core.createBoostAuth()).toLowerCase()).toBe(
|
|
769
709
|
auth.assertValidAddress(),
|
|
770
710
|
);
|
|
771
|
-
expect(await
|
|
711
|
+
expect(await core.isAuthorized(zeroAddress)).toBe(true);
|
|
772
712
|
});
|
|
773
713
|
});
|
package/src/BoostCore.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
zeroAddress,
|
|
32
32
|
zeroHash,
|
|
33
33
|
} from 'viem';
|
|
34
|
+
import { BoostCore as BoostCoreBases } from '../dist/deployments.json';
|
|
34
35
|
import { type Action, actionFromAddress } from './Actions/Action';
|
|
35
36
|
import { EventAction, type EventActionPayload } from './Actions/EventAction';
|
|
36
37
|
import { type AllowList, allowListFromAddress } from './AllowLists/AllowList';
|
|
@@ -95,7 +96,12 @@ import {
|
|
|
95
96
|
IncentiveNotCloneableError,
|
|
96
97
|
MustInitializeBudgetError,
|
|
97
98
|
} from './errors';
|
|
98
|
-
import
|
|
99
|
+
import {
|
|
100
|
+
type GenericLog,
|
|
101
|
+
type ReadParams,
|
|
102
|
+
type WriteParams,
|
|
103
|
+
assertValidAddressByChainId,
|
|
104
|
+
} from './utils';
|
|
99
105
|
|
|
100
106
|
export { boostCoreAbi };
|
|
101
107
|
|
|
@@ -107,13 +113,24 @@ export { boostCoreAbi };
|
|
|
107
113
|
export const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
|
|
108
114
|
|
|
109
115
|
/**
|
|
110
|
-
* The
|
|
111
|
-
* By default, `new BoostCore` will use this address if not otherwise provided.
|
|
116
|
+
* The address of the deployed BoostCore instance. In prerelease mode, this will be its sepolia address
|
|
112
117
|
*
|
|
113
118
|
* @type {Address}
|
|
114
119
|
*/
|
|
115
|
-
export const BOOST_CORE_ADDRESS
|
|
116
|
-
|
|
120
|
+
export const BOOST_CORE_ADDRESS = (BoostCoreBases as Record<string, Address>)[
|
|
121
|
+
__DEFAULT_CHAIN_ID__
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The fixed addresses for the deployed Boost Core.
|
|
126
|
+
* By default, `new BoostCore` will use the address deployed to the currently connected chain, or `BOOST_CORE_ADDRESS` if not provided.
|
|
127
|
+
*
|
|
128
|
+
* @type {Record<number, Address>}
|
|
129
|
+
*/
|
|
130
|
+
export const BOOST_CORE_ADDRESSES: Record<number, Address> = {
|
|
131
|
+
...(BoostCoreBases as Record<number, Address>),
|
|
132
|
+
31337: import.meta.env.VITE_BOOST_CORE_ADDRESS,
|
|
133
|
+
};
|
|
117
134
|
|
|
118
135
|
/**
|
|
119
136
|
* A generic `viem.Log` event with support for `BoostCore` event types.
|
|
@@ -232,6 +249,26 @@ export class BoostCore extends Deployable<
|
|
|
232
249
|
[Address, Address],
|
|
233
250
|
typeof boostCoreAbi
|
|
234
251
|
> {
|
|
252
|
+
/**
|
|
253
|
+
* A static property representing a map of stringified chain ID's to the address of the deployed implementation on chain
|
|
254
|
+
*
|
|
255
|
+
* @static
|
|
256
|
+
* @readonly
|
|
257
|
+
* @type {Record<string, Address>}
|
|
258
|
+
*/
|
|
259
|
+
static readonly addresses: Record<number, Address> = BOOST_CORE_ADDRESSES;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* A getter that will return Boost core's static addresses by numerical chain ID
|
|
263
|
+
*
|
|
264
|
+
* @public
|
|
265
|
+
* @readonly
|
|
266
|
+
* @type {Record<number, Address>}
|
|
267
|
+
*/
|
|
268
|
+
public get addresses(): Record<number, Address> {
|
|
269
|
+
return (this.constructor as typeof BoostCore).addresses;
|
|
270
|
+
}
|
|
271
|
+
|
|
235
272
|
/**
|
|
236
273
|
* Creates an instance of BoostCore.
|
|
237
274
|
*
|
|
@@ -250,7 +287,11 @@ export class BoostCore extends Deployable<
|
|
|
250
287
|
options.protocolFeeReceiver,
|
|
251
288
|
]);
|
|
252
289
|
} else {
|
|
253
|
-
|
|
290
|
+
const { address } = assertValidAddressByChainId(
|
|
291
|
+
config,
|
|
292
|
+
BOOST_CORE_ADDRESSES,
|
|
293
|
+
);
|
|
294
|
+
super({ account, config }, address);
|
|
254
295
|
}
|
|
255
296
|
//@ts-expect-error I can't set this property on the class because for some reason it takes super out of constructor scope?
|
|
256
297
|
this.abi = boostCoreAbi;
|
|
@@ -266,14 +307,17 @@ export class BoostCore extends Deployable<
|
|
|
266
307
|
*/
|
|
267
308
|
public async createBoost(
|
|
268
309
|
_boostPayload: CreateBoostPayload,
|
|
269
|
-
|
|
310
|
+
_params?: DeployableOptions &
|
|
311
|
+
WriteParams<typeof boostCoreAbi, 'createBoost'>,
|
|
270
312
|
) {
|
|
271
|
-
const coreAddress = this.assertValidAddress();
|
|
272
313
|
const [payload, options] =
|
|
273
|
-
this.validateDeploymentConfig<CreateBoostPayload>(
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
314
|
+
this.validateDeploymentConfig<CreateBoostPayload>(_boostPayload, _params);
|
|
315
|
+
const desiredChainId = _params?.chain?.id || _params?.chainId;
|
|
316
|
+
const { chainId, address: coreAddress } = assertValidAddressByChainId(
|
|
317
|
+
options.config,
|
|
318
|
+
this.addresses,
|
|
319
|
+
desiredChainId,
|
|
320
|
+
);
|
|
277
321
|
|
|
278
322
|
let {
|
|
279
323
|
budget,
|
|
@@ -290,7 +334,7 @@ export class BoostCore extends Deployable<
|
|
|
290
334
|
const boostFactory = createWriteContract({
|
|
291
335
|
abi: boostCoreAbi,
|
|
292
336
|
functionName: 'createBoost',
|
|
293
|
-
address:
|
|
337
|
+
address: coreAddress,
|
|
294
338
|
});
|
|
295
339
|
|
|
296
340
|
if (!owner) {
|
|
@@ -321,7 +365,7 @@ export class BoostCore extends Deployable<
|
|
|
321
365
|
parameters: zeroHash,
|
|
322
366
|
};
|
|
323
367
|
if (action.address) {
|
|
324
|
-
const isBase = action.
|
|
368
|
+
const isBase = action.isBase;
|
|
325
369
|
actionPayload = {
|
|
326
370
|
isBase: isBase,
|
|
327
371
|
instance: action.address,
|
|
@@ -332,7 +376,11 @@ export class BoostCore extends Deployable<
|
|
|
332
376
|
} else {
|
|
333
377
|
actionPayload.parameters =
|
|
334
378
|
action.buildParameters(undefined, options).args.at(0) || zeroHash;
|
|
335
|
-
actionPayload.instance =
|
|
379
|
+
actionPayload.instance = assertValidAddressByChainId(
|
|
380
|
+
options.config,
|
|
381
|
+
action.bases,
|
|
382
|
+
chainId,
|
|
383
|
+
).address;
|
|
336
384
|
}
|
|
337
385
|
|
|
338
386
|
let validatorPayload: BoostPayload['validator'] = {
|
|
@@ -341,7 +389,7 @@ export class BoostCore extends Deployable<
|
|
|
341
389
|
parameters: zeroHash,
|
|
342
390
|
};
|
|
343
391
|
if (validator.address) {
|
|
344
|
-
const isBase = validator.
|
|
392
|
+
const isBase = validator.isBase;
|
|
345
393
|
validatorPayload = {
|
|
346
394
|
isBase: isBase,
|
|
347
395
|
instance: validator.address,
|
|
@@ -368,7 +416,11 @@ export class BoostCore extends Deployable<
|
|
|
368
416
|
options,
|
|
369
417
|
)
|
|
370
418
|
.args.at(0) || zeroHash;
|
|
371
|
-
validatorPayload.instance =
|
|
419
|
+
validatorPayload.instance = assertValidAddressByChainId(
|
|
420
|
+
options.config,
|
|
421
|
+
validator.bases,
|
|
422
|
+
chainId,
|
|
423
|
+
).address;
|
|
372
424
|
}
|
|
373
425
|
|
|
374
426
|
let allowListPayload: BoostPayload['allowList'] = {
|
|
@@ -377,7 +429,7 @@ export class BoostCore extends Deployable<
|
|
|
377
429
|
parameters: zeroHash,
|
|
378
430
|
};
|
|
379
431
|
if (allowList.address) {
|
|
380
|
-
const isBase = allowList.
|
|
432
|
+
const isBase = allowList.isBase;
|
|
381
433
|
allowListPayload = {
|
|
382
434
|
isBase: isBase,
|
|
383
435
|
instance: allowList.address,
|
|
@@ -388,10 +440,14 @@ export class BoostCore extends Deployable<
|
|
|
388
440
|
} else {
|
|
389
441
|
allowListPayload.parameters =
|
|
390
442
|
allowList.buildParameters(undefined, options).args.at(0) || zeroHash;
|
|
391
|
-
allowListPayload.instance =
|
|
443
|
+
allowListPayload.instance = assertValidAddressByChainId(
|
|
444
|
+
options.config,
|
|
445
|
+
allowList.bases,
|
|
446
|
+
chainId,
|
|
447
|
+
).address;
|
|
392
448
|
}
|
|
393
449
|
|
|
394
|
-
|
|
450
|
+
const incentivesPayloads: Array<Target> = incentives.map(() => ({
|
|
395
451
|
instance: zeroAddress,
|
|
396
452
|
isBase: true,
|
|
397
453
|
parameters: zeroHash,
|
|
@@ -400,7 +456,7 @@ export class BoostCore extends Deployable<
|
|
|
400
456
|
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
401
457
|
const incentive = incentives.at(i)!;
|
|
402
458
|
if (incentive.address) {
|
|
403
|
-
const isBase = incentive.
|
|
459
|
+
const isBase = incentive.isBase;
|
|
404
460
|
if (!isBase) throw new IncentiveNotCloneableError(incentive);
|
|
405
461
|
incentivesPayloads[i] = {
|
|
406
462
|
isBase: isBase,
|
|
@@ -415,7 +471,11 @@ export class BoostCore extends Deployable<
|
|
|
415
471
|
incentivesPayloads[i]!.parameters =
|
|
416
472
|
incentive.buildParameters(undefined, options).args.at(0) || zeroHash;
|
|
417
473
|
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
418
|
-
incentivesPayloads[i]!.instance =
|
|
474
|
+
incentivesPayloads[i]!.instance = assertValidAddressByChainId(
|
|
475
|
+
options.config,
|
|
476
|
+
incentive.bases,
|
|
477
|
+
chainId,
|
|
478
|
+
).address;
|
|
419
479
|
}
|
|
420
480
|
}
|
|
421
481
|
|
|
@@ -432,8 +492,11 @@ export class BoostCore extends Deployable<
|
|
|
432
492
|
};
|
|
433
493
|
|
|
434
494
|
const boostHash = await boostFactory(options.config, {
|
|
435
|
-
args: [prepareBoostPayload(onChainPayload)],
|
|
436
495
|
...this.optionallyAttachAccount(options.account),
|
|
496
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
497
|
+
...(_params as any),
|
|
498
|
+
chainId,
|
|
499
|
+
args: [prepareBoostPayload(onChainPayload)],
|
|
437
500
|
});
|
|
438
501
|
const receipt = await waitForTransactionReceipt(options.config, {
|
|
439
502
|
hash: boostHash,
|
|
@@ -510,7 +573,11 @@ export class BoostCore extends Deployable<
|
|
|
510
573
|
const { request, result } = await simulateBoostCoreClaimIncentive(
|
|
511
574
|
this._config,
|
|
512
575
|
{
|
|
513
|
-
|
|
576
|
+
...assertValidAddressByChainId(
|
|
577
|
+
this._config,
|
|
578
|
+
this.addresses,
|
|
579
|
+
params?.chain?.id || params?.chainId,
|
|
580
|
+
),
|
|
514
581
|
args: [boostId, incentiveId, referrer, data],
|
|
515
582
|
...this.optionallyAttachAccount(),
|
|
516
583
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -578,7 +645,11 @@ export class BoostCore extends Deployable<
|
|
|
578
645
|
const { request, result } = await simulateBoostCoreClaimIncentiveFor(
|
|
579
646
|
this._config,
|
|
580
647
|
{
|
|
581
|
-
|
|
648
|
+
...assertValidAddressByChainId(
|
|
649
|
+
this._config,
|
|
650
|
+
this.addresses,
|
|
651
|
+
params?.chain?.id || params?.chainId,
|
|
652
|
+
),
|
|
582
653
|
args: [boostId, incentiveId, referrer, data, claimant],
|
|
583
654
|
...this.optionallyAttachAccount(),
|
|
584
655
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -677,7 +748,11 @@ export class BoostCore extends Deployable<
|
|
|
677
748
|
params?: ReadParams<typeof boostCoreAbi, 'getBoostCount'>,
|
|
678
749
|
) {
|
|
679
750
|
return await readBoostCoreGetBoostCount(this._config, {
|
|
680
|
-
|
|
751
|
+
...assertValidAddressByChainId(
|
|
752
|
+
this._config,
|
|
753
|
+
this.addresses,
|
|
754
|
+
params?.chainId,
|
|
755
|
+
),
|
|
681
756
|
args: [],
|
|
682
757
|
...this.optionallyAttachAccount(),
|
|
683
758
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -700,7 +775,7 @@ export class BoostCore extends Deployable<
|
|
|
700
775
|
params?: ReadParams<typeof boostCoreAbi, 'createBoostAuth'> &
|
|
701
776
|
ReadParams<typeof iAuthAbi, 'isAuthorized'>,
|
|
702
777
|
) {
|
|
703
|
-
const auth = await this.createBoostAuth();
|
|
778
|
+
const auth = await this.createBoostAuth(params);
|
|
704
779
|
return readIAuthIsAuthorized(this._config, {
|
|
705
780
|
address: auth,
|
|
706
781
|
args: [address],
|
|
@@ -722,7 +797,11 @@ export class BoostCore extends Deployable<
|
|
|
722
797
|
params?: ReadParams<typeof boostCoreAbi, 'createBoostAuth'>,
|
|
723
798
|
) {
|
|
724
799
|
return await readBoostCoreCreateBoostAuth(this._config, {
|
|
725
|
-
|
|
800
|
+
...assertValidAddressByChainId(
|
|
801
|
+
this._config,
|
|
802
|
+
this.addresses,
|
|
803
|
+
params?.chainId,
|
|
804
|
+
),
|
|
726
805
|
args: [],
|
|
727
806
|
...this.optionallyAttachAccount(),
|
|
728
807
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -766,7 +845,11 @@ export class BoostCore extends Deployable<
|
|
|
766
845
|
const { request, result } = await simulateBoostCoreSetCreateBoostAuth(
|
|
767
846
|
this._config,
|
|
768
847
|
{
|
|
769
|
-
|
|
848
|
+
...assertValidAddressByChainId(
|
|
849
|
+
this._config,
|
|
850
|
+
this.addresses,
|
|
851
|
+
params?.chainId,
|
|
852
|
+
),
|
|
770
853
|
args: [address],
|
|
771
854
|
...this.optionallyAttachAccount(),
|
|
772
855
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -789,7 +872,11 @@ export class BoostCore extends Deployable<
|
|
|
789
872
|
params?: ReadParams<typeof boostCoreAbi, 'protocolFee'>,
|
|
790
873
|
) {
|
|
791
874
|
return await readBoostCoreProtocolFee(this._config, {
|
|
792
|
-
|
|
875
|
+
...assertValidAddressByChainId(
|
|
876
|
+
this._config,
|
|
877
|
+
this.addresses,
|
|
878
|
+
params?.chainId,
|
|
879
|
+
),
|
|
793
880
|
args: [],
|
|
794
881
|
...this.optionallyAttachAccount(),
|
|
795
882
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -809,7 +896,11 @@ export class BoostCore extends Deployable<
|
|
|
809
896
|
params?: ReadParams<typeof boostCoreAbi, 'protocolFeeReceiver'>,
|
|
810
897
|
) {
|
|
811
898
|
return await readBoostCoreProtocolFeeReceiver(this._config, {
|
|
812
|
-
|
|
899
|
+
...assertValidAddressByChainId(
|
|
900
|
+
this._config,
|
|
901
|
+
this.addresses,
|
|
902
|
+
params?.chainId,
|
|
903
|
+
),
|
|
813
904
|
args: [],
|
|
814
905
|
...this.optionallyAttachAccount(),
|
|
815
906
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -853,7 +944,11 @@ export class BoostCore extends Deployable<
|
|
|
853
944
|
const { request, result } = await simulateBoostCoreSetProtocolFeeReceiver(
|
|
854
945
|
this._config,
|
|
855
946
|
{
|
|
856
|
-
|
|
947
|
+
...assertValidAddressByChainId(
|
|
948
|
+
this._config,
|
|
949
|
+
this.addresses,
|
|
950
|
+
params?.chainId,
|
|
951
|
+
),
|
|
857
952
|
args: [address],
|
|
858
953
|
...this.optionallyAttachAccount(),
|
|
859
954
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -877,7 +972,11 @@ export class BoostCore extends Deployable<
|
|
|
877
972
|
*/
|
|
878
973
|
public async claimFee(params?: ReadParams<typeof boostCoreAbi, 'claimFee'>) {
|
|
879
974
|
return await readBoostCoreClaimFee(this._config, {
|
|
880
|
-
|
|
975
|
+
...assertValidAddressByChainId(
|
|
976
|
+
this._config,
|
|
977
|
+
this.addresses,
|
|
978
|
+
params?.chainId,
|
|
979
|
+
),
|
|
881
980
|
args: [],
|
|
882
981
|
...this.optionallyAttachAccount(),
|
|
883
982
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -917,7 +1016,11 @@ export class BoostCore extends Deployable<
|
|
|
917
1016
|
const { request, result } = await simulateBoostCoreSetClaimFee(
|
|
918
1017
|
this._config,
|
|
919
1018
|
{
|
|
920
|
-
|
|
1019
|
+
...assertValidAddressByChainId(
|
|
1020
|
+
this._config,
|
|
1021
|
+
this.addresses,
|
|
1022
|
+
params?.chainId,
|
|
1023
|
+
),
|
|
921
1024
|
args: [claimFee],
|
|
922
1025
|
...this.optionallyAttachAccount(),
|
|
923
1026
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|