@boostxyz/sdk 0.0.0-alpha.11 → 0.0.0-alpha.12
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.js +1 -1
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +115 -31
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +306 -122
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.js +2 -2
- package/dist/AllowLists/SimpleAllowList.js +1 -1
- package/dist/AllowLists/SimpleDenyList.js +2 -2
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.js +2 -2
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.js +1 -1
- package/dist/Budgets/Budget.js +1 -1
- package/dist/Budgets/ManagedBudget.js +1 -1
- package/dist/Deployable/DeployableTarget.js +1 -1
- package/dist/Incentives/AllowListIncentive.js +2 -2
- package/dist/Incentives/CGDAIncentive.js +1 -1
- package/dist/Incentives/ERC20Incentive.js +1 -1
- package/dist/Incentives/Incentive.js +12 -12
- package/dist/Incentives/PointsIncentive.js +1 -1
- package/dist/{SimpleDenyList-4PtOPXTc.js → SimpleDenyList-IJ9Ipya7.js} +2 -2
- package/dist/{SimpleDenyList-4PtOPXTc.js.map → SimpleDenyList-IJ9Ipya7.js.map} +1 -1
- package/dist/Validators/SignerValidator.js +1 -1
- package/dist/Validators/Validator.js +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +116 -20
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +106 -52
- package/dist/errors.js.map +1 -1
- package/dist/{generated-BDeDiaCK.js → generated-HGddZXHJ.js} +21 -21
- package/dist/{generated-BDeDiaCK.js.map → generated-HGddZXHJ.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +58 -55
- package/package.json +8 -5
- package/src/Actions/Action.test.ts +8 -4
- package/src/Actions/EventAction.test.ts +528 -100
- package/src/Actions/EventAction.ts +296 -58
- package/src/errors.ts +160 -20
package/src/errors.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type AbiEvent,
|
|
3
|
+
type AbiFunction,
|
|
2
4
|
type Hex,
|
|
3
5
|
type Log,
|
|
4
6
|
type WaitForTransactionReceiptReturnType,
|
|
5
7
|
zeroHash,
|
|
6
8
|
} from 'viem';
|
|
7
9
|
import type { Criteria } from './Actions/EventAction';
|
|
10
|
+
import type { EventLogs } from './Actions/EventAction';
|
|
8
11
|
import type { BoostRegistry } from './BoostRegistry';
|
|
9
12
|
import type { Incentive } from './Incentives/Incentive';
|
|
10
13
|
|
|
@@ -248,6 +251,44 @@ export class InvalidComponentInterfaceError extends Error {
|
|
|
248
251
|
}
|
|
249
252
|
}
|
|
250
253
|
|
|
254
|
+
/**
|
|
255
|
+
* This error is thrown when a param is not transparently stored onchain
|
|
256
|
+
*
|
|
257
|
+
* @export
|
|
258
|
+
* @class UnparseableAbiParamError
|
|
259
|
+
* @typedef {UnparseableAbiParamError}
|
|
260
|
+
* @extends {Error}
|
|
261
|
+
*/
|
|
262
|
+
export class UnparseableAbiParamError extends Error {
|
|
263
|
+
/**
|
|
264
|
+
* the param index that is unparseable
|
|
265
|
+
*
|
|
266
|
+
* @type {number}
|
|
267
|
+
*/
|
|
268
|
+
input_param_idx: number;
|
|
269
|
+
/**
|
|
270
|
+
* The given event that contains the unparseable param
|
|
271
|
+
*
|
|
272
|
+
* @type {AbiEvent}
|
|
273
|
+
*/
|
|
274
|
+
event: AbiEvent;
|
|
275
|
+
/**
|
|
276
|
+
* Creates an instance of UnknownTransferPayloadSupplied.
|
|
277
|
+
*
|
|
278
|
+
* @constructor
|
|
279
|
+
* @param {number} input_param_idx
|
|
280
|
+
* @param {AbiEvent} event
|
|
281
|
+
*/
|
|
282
|
+
constructor(input_param_idx: number, event: AbiEvent) {
|
|
283
|
+
super(
|
|
284
|
+
`Parameter is not transparently stored onchain. Parameter ${input_param_idx} in event ${event.name} cannot be used in an action`,
|
|
285
|
+
{ cause: event },
|
|
286
|
+
);
|
|
287
|
+
this.event = event;
|
|
288
|
+
this.input_param_idx = input_param_idx;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
251
292
|
/**
|
|
252
293
|
* This error is thrown when attempting a Budget transfer and arguments aren't of the type `FungibleTransferPayload` or `ERC1155TransferPayload`
|
|
253
294
|
*
|
|
@@ -380,6 +421,28 @@ export class TooManyEventActionStepsProvidedError extends Error {
|
|
|
380
421
|
}
|
|
381
422
|
}
|
|
382
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Function action validation context to help debug other validation errors
|
|
426
|
+
*
|
|
427
|
+
* @interface FunctionActionValidationMeta
|
|
428
|
+
* @typedef {FunctionActionValidationMeta}
|
|
429
|
+
*/
|
|
430
|
+
interface FunctionActionValidationMeta {
|
|
431
|
+
decodedArgs: readonly (string | bigint)[];
|
|
432
|
+
/**
|
|
433
|
+
* The value pulled off the log being validated against
|
|
434
|
+
*
|
|
435
|
+
* @type {*}
|
|
436
|
+
* biome-ignore lint/suspicious/noExplicitAny: this can be a few different types based on what the log emits
|
|
437
|
+
*/
|
|
438
|
+
fieldValue: any;
|
|
439
|
+
/**
|
|
440
|
+
* The criteria being used to compare during validation
|
|
441
|
+
*
|
|
442
|
+
* @type {Criteria}
|
|
443
|
+
*/
|
|
444
|
+
criteria: Criteria;
|
|
445
|
+
}
|
|
383
446
|
/**
|
|
384
447
|
* Event action validation context to help debug other validation errors
|
|
385
448
|
*
|
|
@@ -392,7 +455,7 @@ interface EventActionValidationMeta {
|
|
|
392
455
|
*
|
|
393
456
|
* @type {Log}
|
|
394
457
|
*/
|
|
395
|
-
log
|
|
458
|
+
log?: EventLogs[0];
|
|
396
459
|
/**
|
|
397
460
|
* The value pulled off the log being validated against
|
|
398
461
|
*
|
|
@@ -413,17 +476,23 @@ interface EventActionValidationMeta {
|
|
|
413
476
|
* Instantiated with relevent context data for more in depth debugging.
|
|
414
477
|
*
|
|
415
478
|
* @export
|
|
416
|
-
* @class
|
|
417
|
-
* @typedef {
|
|
479
|
+
* @class FieldActionValidationError
|
|
480
|
+
* @typedef {FieldActionValidationError}
|
|
418
481
|
* @extends {Error}
|
|
419
482
|
*/
|
|
420
|
-
export class
|
|
483
|
+
export class FieldActionValidationError extends Error {
|
|
484
|
+
/**
|
|
485
|
+
* The function input arguments being validated against
|
|
486
|
+
*
|
|
487
|
+
* @type {decodedArgs}
|
|
488
|
+
*/
|
|
489
|
+
decodedArgs?: readonly (string | bigint)[];
|
|
421
490
|
/**
|
|
422
491
|
* The viem log being validated against
|
|
423
492
|
*
|
|
424
493
|
* @type {Log}
|
|
425
494
|
*/
|
|
426
|
-
log
|
|
495
|
+
log?: EventLogs[0];
|
|
427
496
|
/**
|
|
428
497
|
* The value pulled off the log being validated against
|
|
429
498
|
*
|
|
@@ -438,7 +507,7 @@ export class EventActionValidationError extends Error {
|
|
|
438
507
|
*/
|
|
439
508
|
criteria: Criteria;
|
|
440
509
|
/**
|
|
441
|
-
* Creates an instance of
|
|
510
|
+
* Creates an instance of FieldActionValidationError.
|
|
442
511
|
*
|
|
443
512
|
* @constructor
|
|
444
513
|
* @param {string} message
|
|
@@ -449,12 +518,48 @@ export class EventActionValidationError extends Error {
|
|
|
449
518
|
*/
|
|
450
519
|
constructor(
|
|
451
520
|
message: string,
|
|
452
|
-
{
|
|
521
|
+
{
|
|
522
|
+
fieldValue,
|
|
523
|
+
criteria,
|
|
524
|
+
...args
|
|
525
|
+
}: EventActionValidationMeta | FunctionActionValidationMeta,
|
|
453
526
|
) {
|
|
454
527
|
super(message);
|
|
455
528
|
this.fieldValue = fieldValue;
|
|
456
529
|
this.criteria = criteria;
|
|
457
|
-
|
|
530
|
+
|
|
531
|
+
switch (true) {
|
|
532
|
+
case 'log' in args:
|
|
533
|
+
this.log = args.log;
|
|
534
|
+
break;
|
|
535
|
+
case 'decodedArgs' in args:
|
|
536
|
+
this.decodedArgs = args.decodedArgs;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Thrown when abi-decoded args on log is undefined
|
|
543
|
+
*
|
|
544
|
+
* @export
|
|
545
|
+
* @class FieldValueUndefinedError
|
|
546
|
+
* @typedef {FieldValueUndefinedError}
|
|
547
|
+
* @extends {FieldActionValidationError}
|
|
548
|
+
*/
|
|
549
|
+
export class DecodedArgsMalformedError extends FieldActionValidationError {
|
|
550
|
+
/**
|
|
551
|
+
* Creates an instance of DecodedArgsUndefinedError.
|
|
552
|
+
*
|
|
553
|
+
* @constructor
|
|
554
|
+
* @param {DecodedArgsMalformedError} metadata
|
|
555
|
+
*/
|
|
556
|
+
constructor(
|
|
557
|
+
metadata: EventActionValidationMeta | FunctionActionValidationMeta,
|
|
558
|
+
) {
|
|
559
|
+
super(
|
|
560
|
+
'Decoded Args are malformed; Check which params are indexed',
|
|
561
|
+
metadata,
|
|
562
|
+
);
|
|
458
563
|
}
|
|
459
564
|
}
|
|
460
565
|
|
|
@@ -464,16 +569,18 @@ export class EventActionValidationError extends Error {
|
|
|
464
569
|
* @export
|
|
465
570
|
* @class FieldValueUndefinedError
|
|
466
571
|
* @typedef {FieldValueUndefinedError}
|
|
467
|
-
* @extends {
|
|
572
|
+
* @extends {FieldActionValidationError}
|
|
468
573
|
*/
|
|
469
|
-
export class FieldValueUndefinedError extends
|
|
574
|
+
export class FieldValueUndefinedError extends FieldActionValidationError {
|
|
470
575
|
/**
|
|
471
576
|
* Creates an instance of FieldValueUndefinedError.
|
|
472
577
|
*
|
|
473
578
|
* @constructor
|
|
474
579
|
* @param {EventActionValidationMeta} metadata
|
|
475
580
|
*/
|
|
476
|
-
constructor(
|
|
581
|
+
constructor(
|
|
582
|
+
metadata: EventActionValidationMeta | FunctionActionValidationMeta,
|
|
583
|
+
) {
|
|
477
584
|
super('Field value is undefined', metadata);
|
|
478
585
|
}
|
|
479
586
|
}
|
|
@@ -484,16 +591,18 @@ export class FieldValueUndefinedError extends EventActionValidationError {
|
|
|
484
591
|
* @export
|
|
485
592
|
* @class InvalidNumericalCriteriaError
|
|
486
593
|
* @typedef {InvalidNumericalCriteriaError}
|
|
487
|
-
* @extends {
|
|
594
|
+
* @extends {FieldActionValidationError}
|
|
488
595
|
*/
|
|
489
|
-
export class InvalidNumericalCriteriaError extends
|
|
596
|
+
export class InvalidNumericalCriteriaError extends FieldActionValidationError {
|
|
490
597
|
/**
|
|
491
598
|
* Creates an instance of InvalidNumericalCriteria.
|
|
492
599
|
*
|
|
493
600
|
* @constructor
|
|
494
601
|
* @param {EventActionValidationMeta} metadata
|
|
495
602
|
*/
|
|
496
|
-
constructor(
|
|
603
|
+
constructor(
|
|
604
|
+
metadata: EventActionValidationMeta | FunctionActionValidationMeta,
|
|
605
|
+
) {
|
|
497
606
|
super(
|
|
498
607
|
'Numerical comparisons cannot be used with non-numerical criteria',
|
|
499
608
|
metadata,
|
|
@@ -501,22 +610,51 @@ export class InvalidNumericalCriteriaError extends EventActionValidationError {
|
|
|
501
610
|
}
|
|
502
611
|
}
|
|
503
612
|
|
|
613
|
+
/**
|
|
614
|
+
* Thrown when decoding function data fails.
|
|
615
|
+
*
|
|
616
|
+
* @export
|
|
617
|
+
* @class FunctionDataDecodeError
|
|
618
|
+
* @typedef {FunctionDataDecodeError}
|
|
619
|
+
* @extends {Error}
|
|
620
|
+
*/
|
|
621
|
+
export class FunctionDataDecodeError extends Error {
|
|
622
|
+
public abi: AbiFunction[];
|
|
623
|
+
public originalError: Error;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Creates an instance of FunctionDataDecodeError.
|
|
627
|
+
*
|
|
628
|
+
* @constructor
|
|
629
|
+
* @param {AbiFunction[]} abi - The ABI of the function.
|
|
630
|
+
* @param {Error} originalError - The original error that was thrown.
|
|
631
|
+
*/
|
|
632
|
+
constructor(abi: AbiFunction[], originalError: Error) {
|
|
633
|
+
super(`Failed to decode function data: ${originalError.message}`);
|
|
634
|
+
this.name = 'FunctionDataDecodeError';
|
|
635
|
+
this.abi = abi;
|
|
636
|
+
this.originalError = originalError;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
504
640
|
/**
|
|
505
641
|
* Thrown when an the log's field value is being compared a field type that isn't bytes or string during event action validation
|
|
506
642
|
*
|
|
507
643
|
* @export
|
|
508
644
|
* @class FieldValueNotComparableError
|
|
509
645
|
* @typedef {FieldValueNotComparableError}
|
|
510
|
-
* @extends {
|
|
646
|
+
* @extends {FieldActionValidationError}
|
|
511
647
|
*/
|
|
512
|
-
export class FieldValueNotComparableError extends
|
|
648
|
+
export class FieldValueNotComparableError extends FieldActionValidationError {
|
|
513
649
|
/**
|
|
514
650
|
* Creates an instance of FieldValueNotComparableError.
|
|
515
651
|
*
|
|
516
652
|
* @constructor
|
|
517
653
|
* @param {EventActionValidationMeta} metadata
|
|
518
654
|
*/
|
|
519
|
-
constructor(
|
|
655
|
+
constructor(
|
|
656
|
+
metadata: EventActionValidationMeta | FunctionActionValidationMeta,
|
|
657
|
+
) {
|
|
520
658
|
super('Filter can only be used with bytes or string field type', metadata);
|
|
521
659
|
}
|
|
522
660
|
}
|
|
@@ -527,16 +665,18 @@ export class FieldValueNotComparableError extends EventActionValidationError {
|
|
|
527
665
|
* @export
|
|
528
666
|
* @class UnrecognizedFilterTypeError
|
|
529
667
|
* @typedef {UnrecognizedFilterTypeError}
|
|
530
|
-
* @extends {
|
|
668
|
+
* @extends {FieldActionValidationError}
|
|
531
669
|
*/
|
|
532
|
-
export class UnrecognizedFilterTypeError extends
|
|
670
|
+
export class UnrecognizedFilterTypeError extends FieldActionValidationError {
|
|
533
671
|
/**
|
|
534
672
|
* Creates an instance of UnrecognizedFilterTypeError.
|
|
535
673
|
*
|
|
536
674
|
* @constructor
|
|
537
675
|
* @param {EventActionValidationMeta} metadata
|
|
538
676
|
*/
|
|
539
|
-
constructor(
|
|
677
|
+
constructor(
|
|
678
|
+
metadata: EventActionValidationMeta | FunctionActionValidationMeta,
|
|
679
|
+
) {
|
|
540
680
|
super('Invalid FilterType provided', metadata);
|
|
541
681
|
}
|
|
542
682
|
}
|