@namehash/ens-referrals 1.6.0 → 1.8.0
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/v1/index.cjs +3938 -1589
- package/dist/v1/index.cjs.map +1 -1
- package/dist/v1/index.d.cts +380 -161
- package/dist/v1/index.d.ts +380 -161
- package/dist/v1/index.js +3939 -1590
- package/dist/v1/index.js.map +1 -1
- package/package.json +3 -3
package/dist/v1/index.d.ts
CHANGED
|
@@ -49,6 +49,12 @@ interface BaseReferralProgramRules {
|
|
|
49
49
|
* @example new URL("https://ensawards.org/ens-holiday-awards-rules")
|
|
50
50
|
*/
|
|
51
51
|
rulesUrl: URL;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the awards for this edition have been distributed.
|
|
54
|
+
*
|
|
55
|
+
* When `true` and `now > endTime`, the status transitions from `AwardsReview` to `Closed`.
|
|
56
|
+
*/
|
|
57
|
+
areAwardsDistributed: boolean;
|
|
52
58
|
}
|
|
53
59
|
/**
|
|
54
60
|
* Rules for a referral program edition whose `awardModel` is not recognized by this client version.
|
|
@@ -95,7 +101,7 @@ interface ReferralProgramRulesPieSplit extends BaseReferralProgramRules {
|
|
|
95
101
|
maxQualifiedReferrers: number;
|
|
96
102
|
}
|
|
97
103
|
declare const validateReferralProgramRulesPieSplit: (rules: ReferralProgramRulesPieSplit) => void;
|
|
98
|
-
declare const buildReferralProgramRulesPieSplit: (totalAwardPoolValue: PriceUsdc, maxQualifiedReferrers: number, startTime: UnixTimestamp, endTime: UnixTimestamp, subregistryId: AccountId, rulesUrl: URL) => ReferralProgramRulesPieSplit;
|
|
104
|
+
declare const buildReferralProgramRulesPieSplit: (totalAwardPoolValue: PriceUsdc, maxQualifiedReferrers: number, startTime: UnixTimestamp, endTime: UnixTimestamp, subregistryId: AccountId, rulesUrl: URL, areAwardsDistributed: boolean) => ReferralProgramRulesPieSplit;
|
|
99
105
|
|
|
100
106
|
/**
|
|
101
107
|
* An admin-imposed disqualification entry of a specific referrer in an edition.
|
|
@@ -153,7 +159,7 @@ interface ReferralProgramRulesRevShareLimit extends BaseReferralProgramRules {
|
|
|
153
159
|
disqualifications: ReferralProgramEditionDisqualification[];
|
|
154
160
|
}
|
|
155
161
|
declare const validateReferralProgramRulesRevShareLimit: (rules: ReferralProgramRulesRevShareLimit) => void;
|
|
156
|
-
declare const buildReferralProgramRulesRevShareLimit: (totalAwardPoolValue: PriceUsdc, minQualifiedRevenueContribution: PriceUsdc, qualifiedRevenueShare: number, startTime: UnixTimestamp, endTime: UnixTimestamp, subregistryId: AccountId, rulesUrl: URL, disqualifications?: ReferralProgramEditionDisqualification[]) => ReferralProgramRulesRevShareLimit;
|
|
162
|
+
declare const buildReferralProgramRulesRevShareLimit: (totalAwardPoolValue: PriceUsdc, minQualifiedRevenueContribution: PriceUsdc, qualifiedRevenueShare: number, startTime: UnixTimestamp, endTime: UnixTimestamp, subregistryId: AccountId, rulesUrl: URL, areAwardsDistributed: boolean, disqualifications?: ReferralProgramEditionDisqualification[]) => ReferralProgramRulesRevShareLimit;
|
|
157
163
|
/**
|
|
158
164
|
* Determine if a referrer is qualified under rev-share-limit rules.
|
|
159
165
|
*
|
|
@@ -194,6 +200,13 @@ type ReferralProgramRules = ReferralProgramRulesPieSplit | ReferralProgramRulesR
|
|
|
194
200
|
* @example "holiday-special" // Custom named edition
|
|
195
201
|
*/
|
|
196
202
|
type ReferralProgramEditionSlug = string;
|
|
203
|
+
/**
|
|
204
|
+
* Regex pattern that all {@link ReferralProgramEditionSlug} values must match.
|
|
205
|
+
*
|
|
206
|
+
* Allows lowercase letters (a-z), digits (0-9), and hyphens (-).
|
|
207
|
+
* Must not start or end with a hyphen.
|
|
208
|
+
*/
|
|
209
|
+
declare const REFERRAL_PROGRAM_EDITION_SLUG_PATTERN: RegExp;
|
|
197
210
|
/**
|
|
198
211
|
* Represents a referral program edition configuration.
|
|
199
212
|
*/
|
|
@@ -475,54 +488,88 @@ declare const validateAggregatedReferrerMetricsPieSplit: (metrics: AggregatedRef
|
|
|
475
488
|
declare const buildAggregatedReferrerMetricsPieSplit: (referrers: RankedReferrerMetricsPieSplit[], rules: ReferralProgramRulesPieSplit) => AggregatedReferrerMetricsPieSplit;
|
|
476
489
|
|
|
477
490
|
/**
|
|
478
|
-
* The type of
|
|
491
|
+
* The type of referrer edition metrics data.
|
|
479
492
|
*/
|
|
480
|
-
declare const
|
|
481
|
-
/**
|
|
482
|
-
* Represents a referral program that has been announced, but hasn't started yet.
|
|
483
|
-
*/
|
|
484
|
-
readonly Scheduled: "Scheduled";
|
|
493
|
+
declare const ReferrerEditionMetricsTypeIds: {
|
|
485
494
|
/**
|
|
486
|
-
* Represents a
|
|
495
|
+
* Represents a referrer who is ranked on the leaderboard.
|
|
487
496
|
*/
|
|
488
|
-
readonly
|
|
497
|
+
readonly Ranked: "ranked";
|
|
489
498
|
/**
|
|
490
|
-
* Represents a
|
|
499
|
+
* Represents a referrer who is not ranked on the leaderboard.
|
|
491
500
|
*/
|
|
492
|
-
readonly
|
|
501
|
+
readonly Unranked: "unranked";
|
|
493
502
|
};
|
|
494
503
|
/**
|
|
495
|
-
* The derived string union of possible {@link
|
|
504
|
+
* The derived string union of possible {@link ReferrerEditionMetricsTypeIds}.
|
|
496
505
|
*/
|
|
497
|
-
type
|
|
506
|
+
type ReferrerEditionMetricsTypeId = (typeof ReferrerEditionMetricsTypeIds)[keyof typeof ReferrerEditionMetricsTypeIds];
|
|
498
507
|
/**
|
|
499
|
-
*
|
|
500
|
-
* and program's timeframe available in its rules.
|
|
508
|
+
* Referrer edition metrics for an edition whose `awardModel` is not recognized by this client version.
|
|
501
509
|
*
|
|
502
|
-
* @
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
510
|
+
* @remarks
|
|
511
|
+
* This is a **client-side forward-compatibility** type only. It is never serialized or processed
|
|
512
|
+
* by business logic on the backend. When the server introduces a new award model type, older
|
|
513
|
+
* clients preserve the metrics rather than throwing, and downstream code that encounters this type
|
|
514
|
+
* should handle it gracefully rather than crashing.
|
|
506
515
|
*/
|
|
507
|
-
|
|
516
|
+
interface ReferrerEditionMetricsUnrecognized {
|
|
517
|
+
/**
|
|
518
|
+
* Discriminant — always `"unrecognized"`.
|
|
519
|
+
*/
|
|
520
|
+
awardModel: typeof ReferralProgramAwardModels.Unrecognized;
|
|
521
|
+
/**
|
|
522
|
+
* The original, unrecognized `awardModel` string received from the server.
|
|
523
|
+
*
|
|
524
|
+
* @remarks Preserved for logging and debugging. Never used for business logic.
|
|
525
|
+
*/
|
|
526
|
+
originalAwardModel: string;
|
|
527
|
+
}
|
|
508
528
|
|
|
509
529
|
/**
|
|
510
|
-
* The type of
|
|
530
|
+
* The type of referral program edition's status.
|
|
511
531
|
*/
|
|
512
|
-
declare const
|
|
532
|
+
declare const ReferralProgramEditionStatuses: {
|
|
513
533
|
/**
|
|
514
|
-
* Represents a
|
|
534
|
+
* Represents a referral program edition that has been announced, but hasn't started yet.
|
|
515
535
|
*/
|
|
516
|
-
readonly
|
|
536
|
+
readonly Scheduled: "Scheduled";
|
|
517
537
|
/**
|
|
518
|
-
* Represents a
|
|
538
|
+
* Represents a currently ongoing referral program edition.
|
|
519
539
|
*/
|
|
520
|
-
readonly
|
|
540
|
+
readonly Active: "Active";
|
|
541
|
+
/**
|
|
542
|
+
* Represents a referral program edition that is still within its active window
|
|
543
|
+
* but whose award pool has been fully consumed.
|
|
544
|
+
*
|
|
545
|
+
* @note Not all award models may support this status.
|
|
546
|
+
*/
|
|
547
|
+
readonly Exhausted: "Exhausted";
|
|
548
|
+
/**
|
|
549
|
+
* Represents a referral program edition that has passed its end time but whose awards have not yet
|
|
550
|
+
* been distributed. The edition is in a review window before full closure.
|
|
551
|
+
*
|
|
552
|
+
* Transitions to {@link ReferralProgramEditionStatuses.Closed} once `areAwardsDistributed` is set to `true`.
|
|
553
|
+
*/
|
|
554
|
+
readonly AwardsReview: "AwardsReview";
|
|
555
|
+
/**
|
|
556
|
+
* Represents a referral program edition that has already ended and whose awards have been distributed.
|
|
557
|
+
*/
|
|
558
|
+
readonly Closed: "Closed";
|
|
521
559
|
};
|
|
522
560
|
/**
|
|
523
|
-
* The derived string union of possible {@link
|
|
561
|
+
* The derived string union of possible {@link ReferralProgramEditionStatuses}.
|
|
524
562
|
*/
|
|
525
|
-
type
|
|
563
|
+
type ReferralProgramEditionStatusId = (typeof ReferralProgramEditionStatuses)[keyof typeof ReferralProgramEditionStatuses];
|
|
564
|
+
/**
|
|
565
|
+
* Calculate the base status of a referral program edition using only its rules and
|
|
566
|
+
* the current time (makes no consideration of the awards possibly being exhausted).
|
|
567
|
+
*
|
|
568
|
+
* @param rules - Related referral program's rules containing program's start/end date and
|
|
569
|
+
* `areAwardsDistributed` flag.
|
|
570
|
+
* @param now - Current date in {@link UnixTimestamp} format.
|
|
571
|
+
*/
|
|
572
|
+
declare const calcBaseReferralProgramEditionStatus: (rules: BaseReferralProgramRules, now: UnixTimestamp) => ReferralProgramEditionStatusId;
|
|
526
573
|
|
|
527
574
|
/**
|
|
528
575
|
* Referrer edition metrics data for a specific referrer address on the pie-split leaderboard.
|
|
@@ -562,10 +609,10 @@ interface ReferrerEditionMetricsRankedPieSplit {
|
|
|
562
609
|
*/
|
|
563
610
|
aggregatedMetrics: AggregatedReferrerMetricsPieSplit;
|
|
564
611
|
/**
|
|
565
|
-
* The status of the referral program
|
|
612
|
+
* The status of the referral program edition
|
|
566
613
|
* calculated based on the program's timing relative to {@link accurateAsOf}.
|
|
567
614
|
*/
|
|
568
|
-
status:
|
|
615
|
+
status: ReferralProgramEditionStatusId;
|
|
569
616
|
/**
|
|
570
617
|
* The {@link UnixTimestamp} of when the data used to build the {@link ReferrerEditionMetricsRankedPieSplit} was accurate as of.
|
|
571
618
|
*/
|
|
@@ -608,15 +655,68 @@ interface ReferrerEditionMetricsUnrankedPieSplit {
|
|
|
608
655
|
*/
|
|
609
656
|
aggregatedMetrics: AggregatedReferrerMetricsPieSplit;
|
|
610
657
|
/**
|
|
611
|
-
* The status of the referral program
|
|
658
|
+
* The status of the referral program edition
|
|
612
659
|
* calculated based on the program's timing relative to {@link accurateAsOf}.
|
|
613
660
|
*/
|
|
614
|
-
status:
|
|
661
|
+
status: ReferralProgramEditionStatusId;
|
|
615
662
|
/**
|
|
616
663
|
* The {@link UnixTimestamp} of when the data used to build the {@link ReferrerEditionMetricsUnrankedPieSplit} was accurate as of.
|
|
617
664
|
*/
|
|
618
665
|
accurateAsOf: UnixTimestamp;
|
|
619
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* All referrer edition metrics variants for the pie-split award model.
|
|
669
|
+
*
|
|
670
|
+
* Use `type` to determine if the referrer is ranked or unranked.
|
|
671
|
+
*/
|
|
672
|
+
type ReferrerEditionMetricsPieSplit = ReferrerEditionMetricsRankedPieSplit | ReferrerEditionMetricsUnrankedPieSplit;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Base fields shared by all edition summary variants.
|
|
676
|
+
*/
|
|
677
|
+
interface BaseReferralProgramEditionSummary {
|
|
678
|
+
/**
|
|
679
|
+
* Discriminant: identifies the award model for this edition.
|
|
680
|
+
*
|
|
681
|
+
* @invariant Always equals `rules.awardModel`.
|
|
682
|
+
*/
|
|
683
|
+
awardModel: ReferralProgramAwardModel;
|
|
684
|
+
/**
|
|
685
|
+
* Unique slug identifier for the edition.
|
|
686
|
+
*/
|
|
687
|
+
slug: ReferralProgramEditionSlug;
|
|
688
|
+
/**
|
|
689
|
+
* Human-readable display name for the edition.
|
|
690
|
+
*/
|
|
691
|
+
displayName: string;
|
|
692
|
+
/**
|
|
693
|
+
* The current runtime status of the edition.
|
|
694
|
+
*/
|
|
695
|
+
status: ReferralProgramEditionStatusId;
|
|
696
|
+
/**
|
|
697
|
+
* The rules for this edition. Per-model subtypes narrow this to their specific rules type.
|
|
698
|
+
*/
|
|
699
|
+
rules: BaseReferralProgramRules;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Edition summary for an edition whose `awardModel` is not recognized by this client version.
|
|
703
|
+
*
|
|
704
|
+
* @remarks
|
|
705
|
+
* This is a **client-side forward-compatibility** type only. It is never serialized or produced
|
|
706
|
+
* by the server. When the server sends a new award model, older clients preserve the edition
|
|
707
|
+
* summary rather than crashing, and downstream code should handle it gracefully.
|
|
708
|
+
*/
|
|
709
|
+
interface ReferralProgramEditionSummaryUnrecognized extends BaseReferralProgramEditionSummary {
|
|
710
|
+
/**
|
|
711
|
+
* Discriminant — always `"unrecognized"`.
|
|
712
|
+
*/
|
|
713
|
+
awardModel: typeof ReferralProgramAwardModels.Unrecognized;
|
|
714
|
+
/**
|
|
715
|
+
* The unrecognized rules — preserves `originalAwardModel` for logging/debugging.
|
|
716
|
+
*/
|
|
717
|
+
rules: ReferralProgramRulesUnrecognized;
|
|
718
|
+
}
|
|
719
|
+
declare const validateBaseReferralProgramEditionSummary: (summary: BaseReferralProgramEditionSummary) => void;
|
|
620
720
|
|
|
621
721
|
/**
|
|
622
722
|
* Represents a leaderboard with the pie-split award model for any number of referrers.
|
|
@@ -657,6 +757,28 @@ interface ReferrerLeaderboardPieSplit {
|
|
|
657
757
|
}
|
|
658
758
|
declare const buildReferrerLeaderboardPieSplit: (allReferrers: ReferrerMetrics[], rules: ReferralProgramRulesPieSplit, accurateAsOf: UnixTimestamp) => ReferrerLeaderboardPieSplit;
|
|
659
759
|
|
|
760
|
+
/**
|
|
761
|
+
* Edition summary for a `pie-split` referral program edition.
|
|
762
|
+
*/
|
|
763
|
+
interface ReferralProgramEditionSummaryPieSplit extends BaseReferralProgramEditionSummary {
|
|
764
|
+
/**
|
|
765
|
+
* Discriminant — always `"pie-split"`.
|
|
766
|
+
*
|
|
767
|
+
* @invariant Always equals `rules.awardModel` ({@link ReferralProgramAwardModels.PieSplit}).
|
|
768
|
+
*/
|
|
769
|
+
awardModel: typeof ReferralProgramAwardModels.PieSplit;
|
|
770
|
+
/**
|
|
771
|
+
* The pie-split rules for this edition.
|
|
772
|
+
*/
|
|
773
|
+
rules: ReferralProgramRulesPieSplit;
|
|
774
|
+
}
|
|
775
|
+
declare const validateEditionSummaryPieSplit: (summary: ReferralProgramEditionSummaryPieSplit) => void;
|
|
776
|
+
/**
|
|
777
|
+
* Build a {@link ReferralProgramEditionSummaryPieSplit} from a pie-split edition config and the
|
|
778
|
+
* edition's leaderboard.
|
|
779
|
+
*/
|
|
780
|
+
declare function buildEditionSummaryPieSplit(slug: ReferralProgramEditionSlug, displayName: string, rules: ReferralProgramRulesPieSplit, leaderboard: ReferrerLeaderboardPieSplit): ReferralProgramEditionSummaryPieSplit;
|
|
781
|
+
|
|
660
782
|
/**
|
|
661
783
|
* Extends {@link ReferrerMetrics} with computed base revenue contribution.
|
|
662
784
|
*/
|
|
@@ -814,15 +936,10 @@ interface ReferralEvent {
|
|
|
814
936
|
/**
|
|
815
937
|
* Registrar action ID.
|
|
816
938
|
*
|
|
817
|
-
*
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
* this event. Encodes all ordering-relevant properties:
|
|
822
|
-
* `blockTimestamp → chainId → blockNumber → transactionIndex → eventType → eventIndex`
|
|
823
|
-
*
|
|
824
|
-
* This field alone is sufficient to establish a total chronological ordering over
|
|
825
|
-
* all referral events.
|
|
939
|
+
* @invariant Deterministic and globally unique identifier for the "logical registrar action"
|
|
940
|
+
* associated with this ReferralEvent.
|
|
941
|
+
* @invariant Sorting by this value achieves a chronological ordering of each registrar action
|
|
942
|
+
* by the order they were executed onchain.
|
|
826
943
|
*/
|
|
827
944
|
id: string;
|
|
828
945
|
/**
|
|
@@ -976,15 +1093,35 @@ interface BaseReferrerLeaderboardPage {
|
|
|
976
1093
|
*/
|
|
977
1094
|
pageContext: ReferrerLeaderboardPageContext;
|
|
978
1095
|
/**
|
|
979
|
-
* The status of the referral program
|
|
980
|
-
* calculated based on the program's timing relative to {@link accurateAsOf}.
|
|
1096
|
+
* The status of the referral program edition.
|
|
981
1097
|
*/
|
|
982
|
-
status:
|
|
1098
|
+
status: ReferralProgramEditionStatusId;
|
|
983
1099
|
/**
|
|
984
1100
|
* The {@link UnixTimestamp} of when the data used to build this page was accurate as of.
|
|
985
1101
|
*/
|
|
986
1102
|
accurateAsOf: UnixTimestamp;
|
|
987
1103
|
}
|
|
1104
|
+
/**
|
|
1105
|
+
* A leaderboard page whose `awardModel` is not recognized by this client version.
|
|
1106
|
+
*
|
|
1107
|
+
* @remarks
|
|
1108
|
+
* This is a **client-side forward-compatibility** type only. It is never serialized or processed
|
|
1109
|
+
* by business logic on the backend. When the server introduces a new award model type, older
|
|
1110
|
+
* clients preserve the page rather than throwing, and downstream code that encounters this type
|
|
1111
|
+
* should handle it gracefully rather than crashing.
|
|
1112
|
+
*/
|
|
1113
|
+
interface ReferrerLeaderboardPageUnrecognized extends BaseReferrerLeaderboardPage {
|
|
1114
|
+
/**
|
|
1115
|
+
* Discriminant — always `"unrecognized"`.
|
|
1116
|
+
*/
|
|
1117
|
+
awardModel: typeof ReferralProgramAwardModels.Unrecognized;
|
|
1118
|
+
/**
|
|
1119
|
+
* The original, unrecognized `awardModel` string received from the server.
|
|
1120
|
+
*
|
|
1121
|
+
* @remarks Preserved for logging and debugging. Never used for business logic.
|
|
1122
|
+
*/
|
|
1123
|
+
originalAwardModel: string;
|
|
1124
|
+
}
|
|
988
1125
|
/**
|
|
989
1126
|
* Extracts the referrers for the current page from a fully-ranked Map.
|
|
990
1127
|
* Generic over the referrer type so each model variant retains its specific type.
|
|
@@ -1072,6 +1209,16 @@ interface SerializedReferrerEditionMetricsUnrankedPieSplit extends Omit<Referrer
|
|
|
1072
1209
|
referrer: SerializedUnrankedReferrerMetricsPieSplit;
|
|
1073
1210
|
aggregatedMetrics: SerializedAggregatedReferrerMetricsPieSplit;
|
|
1074
1211
|
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Serialized representation of {@link ReferrerEditionMetricsPieSplit}.
|
|
1214
|
+
*/
|
|
1215
|
+
type SerializedReferrerEditionMetricsPieSplit = SerializedReferrerEditionMetricsRankedPieSplit | SerializedReferrerEditionMetricsUnrankedPieSplit;
|
|
1216
|
+
/**
|
|
1217
|
+
* Serialized representation of {@link ReferralProgramEditionSummaryPieSplit}.
|
|
1218
|
+
*/
|
|
1219
|
+
interface SerializedReferralProgramEditionSummaryPieSplit extends Omit<ReferralProgramEditionSummaryPieSplit, "rules"> {
|
|
1220
|
+
rules: SerializedReferralProgramRulesPieSplit;
|
|
1221
|
+
}
|
|
1075
1222
|
|
|
1076
1223
|
/**
|
|
1077
1224
|
* Referrer edition metrics data for a specific referrer on a rev-share-limit leaderboard.
|
|
@@ -1107,10 +1254,10 @@ interface ReferrerEditionMetricsRankedRevShareLimit {
|
|
|
1107
1254
|
*/
|
|
1108
1255
|
aggregatedMetrics: AggregatedReferrerMetricsRevShareLimit;
|
|
1109
1256
|
/**
|
|
1110
|
-
* The status of the referral program
|
|
1257
|
+
* The status of the referral program edition
|
|
1111
1258
|
* calculated based on the program's timing relative to {@link accurateAsOf}.
|
|
1112
1259
|
*/
|
|
1113
|
-
status:
|
|
1260
|
+
status: ReferralProgramEditionStatusId;
|
|
1114
1261
|
/**
|
|
1115
1262
|
* The {@link UnixTimestamp} of when the data used to build the {@link ReferrerEditionMetricsRankedRevShareLimit} was accurate as of.
|
|
1116
1263
|
*/
|
|
@@ -1149,15 +1296,53 @@ interface ReferrerEditionMetricsUnrankedRevShareLimit {
|
|
|
1149
1296
|
*/
|
|
1150
1297
|
aggregatedMetrics: AggregatedReferrerMetricsRevShareLimit;
|
|
1151
1298
|
/**
|
|
1152
|
-
* The status of the referral program
|
|
1299
|
+
* The status of the referral program edition
|
|
1153
1300
|
* calculated based on the program's timing relative to {@link accurateAsOf}.
|
|
1154
1301
|
*/
|
|
1155
|
-
status:
|
|
1302
|
+
status: ReferralProgramEditionStatusId;
|
|
1156
1303
|
/**
|
|
1157
1304
|
* The {@link UnixTimestamp} of when the data used to build the {@link ReferrerEditionMetricsUnrankedRevShareLimit} was accurate as of.
|
|
1158
1305
|
*/
|
|
1159
1306
|
accurateAsOf: UnixTimestamp;
|
|
1160
1307
|
}
|
|
1308
|
+
/**
|
|
1309
|
+
* All referrer edition metrics variants for the rev-share-limit award model.
|
|
1310
|
+
*
|
|
1311
|
+
* Use `type` to determine if the referrer is ranked or unranked.
|
|
1312
|
+
*/
|
|
1313
|
+
type ReferrerEditionMetricsRevShareLimit = ReferrerEditionMetricsRankedRevShareLimit | ReferrerEditionMetricsUnrankedRevShareLimit;
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Edition summary for a `rev-share-limit` referral program edition.
|
|
1317
|
+
*
|
|
1318
|
+
* Includes `awardPoolRemaining` so consumers can display pool exhaustion state
|
|
1319
|
+
* without needing to fetch the full leaderboard.
|
|
1320
|
+
*/
|
|
1321
|
+
interface ReferralProgramEditionSummaryRevShareLimit extends BaseReferralProgramEditionSummary {
|
|
1322
|
+
/**
|
|
1323
|
+
* Discriminant — always `"rev-share-limit"`.
|
|
1324
|
+
*
|
|
1325
|
+
* @invariant Always equals `rules.awardModel` ({@link ReferralProgramAwardModels.RevShareLimit}).
|
|
1326
|
+
*/
|
|
1327
|
+
awardModel: typeof ReferralProgramAwardModels.RevShareLimit;
|
|
1328
|
+
/**
|
|
1329
|
+
* The rev-share-limit rules for this edition.
|
|
1330
|
+
*/
|
|
1331
|
+
rules: ReferralProgramRulesRevShareLimit;
|
|
1332
|
+
/**
|
|
1333
|
+
* The remaining award pool after sequential race processing.
|
|
1334
|
+
*
|
|
1335
|
+
* When `0n`, the edition's status will be {@link ReferralProgramEditionStatuses.Exhausted}
|
|
1336
|
+
* if the edition is still within its active window.
|
|
1337
|
+
*/
|
|
1338
|
+
awardPoolRemaining: PriceUsdc;
|
|
1339
|
+
}
|
|
1340
|
+
declare const validateEditionSummaryRevShareLimit: (summary: ReferralProgramEditionSummaryRevShareLimit) => void;
|
|
1341
|
+
/**
|
|
1342
|
+
* Build a {@link ReferralProgramEditionSummaryRevShareLimit} from a rev-share-limit edition
|
|
1343
|
+
* config and the edition's leaderboard.
|
|
1344
|
+
*/
|
|
1345
|
+
declare function buildEditionSummaryRevShareLimit(slug: ReferralProgramEditionSlug, displayName: string, rules: ReferralProgramRulesRevShareLimit, leaderboard: ReferrerLeaderboardRevShareLimit): ReferralProgramEditionSummaryRevShareLimit;
|
|
1161
1346
|
|
|
1162
1347
|
/**
|
|
1163
1348
|
* A page of referrers from the rev-share-limit referrer leaderboard.
|
|
@@ -1246,45 +1431,62 @@ interface SerializedReferrerEditionMetricsUnrankedRevShareLimit extends Omit<Ref
|
|
|
1246
1431
|
referrer: SerializedUnrankedReferrerMetricsRevShareLimit;
|
|
1247
1432
|
aggregatedMetrics: SerializedAggregatedReferrerMetricsRevShareLimit;
|
|
1248
1433
|
}
|
|
1249
|
-
|
|
1250
1434
|
/**
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
* Use `awardModel` to narrow the specific model variant at runtime.
|
|
1435
|
+
* Serialized representation of {@link ReferrerEditionMetricsRevShareLimit}.
|
|
1254
1436
|
*/
|
|
1255
|
-
type
|
|
1437
|
+
type SerializedReferrerEditionMetricsRevShareLimit = SerializedReferrerEditionMetricsRankedRevShareLimit | SerializedReferrerEditionMetricsUnrankedRevShareLimit;
|
|
1256
1438
|
/**
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1259
|
-
* Use `awardModel` to narrow the specific model variant at runtime.
|
|
1439
|
+
* Serialized representation of {@link ReferralProgramEditionSummaryRevShareLimit}.
|
|
1260
1440
|
*/
|
|
1261
|
-
|
|
1441
|
+
interface SerializedReferralProgramEditionSummaryRevShareLimit extends Omit<ReferralProgramEditionSummaryRevShareLimit, "rules" | "awardPoolRemaining"> {
|
|
1442
|
+
rules: SerializedReferralProgramRulesRevShareLimit;
|
|
1443
|
+
awardPoolRemaining: SerializedPriceUsdc;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1262
1446
|
/**
|
|
1263
1447
|
* Referrer edition metrics data for a specific referrer address.
|
|
1264
1448
|
*
|
|
1265
|
-
* Use `
|
|
1266
|
-
*
|
|
1449
|
+
* Use `awardModel` to narrow the award model variant, then `type` to narrow ranked vs unranked.
|
|
1450
|
+
* When `awardModel` is `"unrecognized"`, the data was produced by a server running a newer
|
|
1451
|
+
* version — use {@link ReferrerEditionMetricsUnrecognized} to access `originalAwardModel`.
|
|
1267
1452
|
*/
|
|
1268
|
-
type ReferrerEditionMetrics =
|
|
1453
|
+
type ReferrerEditionMetrics = ReferrerEditionMetricsPieSplit | ReferrerEditionMetricsRevShareLimit | ReferrerEditionMetricsUnrecognized;
|
|
1269
1454
|
/**
|
|
1270
1455
|
* Get the edition metrics for a specific referrer from the leaderboard.
|
|
1271
1456
|
*
|
|
1272
|
-
* Returns a {@link
|
|
1273
|
-
*
|
|
1457
|
+
* Returns a {@link ReferrerEditionMetricsPieSplit} or {@link ReferrerEditionMetricsRevShareLimit}
|
|
1458
|
+
* with `type: "ranked"` if the referrer is on the leaderboard, or `type: "unranked"` otherwise.
|
|
1274
1459
|
*
|
|
1275
1460
|
* @param referrer - The referrer address to look up
|
|
1276
1461
|
* @param leaderboard - The referrer leaderboard to query
|
|
1277
|
-
* @returns The appropriate {@link ReferrerEditionMetrics}
|
|
1462
|
+
* @returns The appropriate {@link ReferrerEditionMetrics}
|
|
1278
1463
|
*/
|
|
1279
1464
|
declare const getReferrerEditionMetrics: (referrer: Address, leaderboard: ReferrerLeaderboard) => ReferrerEditionMetrics;
|
|
1280
1465
|
|
|
1466
|
+
/**
|
|
1467
|
+
* Runtime summary of a referral program edition, enriched with current status and pool data.
|
|
1468
|
+
*
|
|
1469
|
+
* Use `awardModel` to discriminate between variants at runtime.
|
|
1470
|
+
*/
|
|
1471
|
+
type ReferralProgramEditionSummary = ReferralProgramEditionSummaryPieSplit | ReferralProgramEditionSummaryRevShareLimit | ReferralProgramEditionSummaryUnrecognized;
|
|
1472
|
+
/**
|
|
1473
|
+
* Build a runtime edition summary from an edition config and the edition's leaderboard.
|
|
1474
|
+
* Dispatches to the appropriate per-model builder based on `leaderboard.awardModel`.
|
|
1475
|
+
*
|
|
1476
|
+
* @param config - The edition configuration (provides `slug` and `displayName`).
|
|
1477
|
+
* @param leaderboard - The resolved leaderboard for this edition.
|
|
1478
|
+
*/
|
|
1479
|
+
declare function buildEditionSummary(config: ReferralProgramEditionConfig, leaderboard: ReferrerLeaderboard): ReferralProgramEditionSummary;
|
|
1480
|
+
|
|
1281
1481
|
/**
|
|
1282
1482
|
* A page of referrers from the referrer leaderboard.
|
|
1283
1483
|
*
|
|
1284
1484
|
* Use `awardModel` to narrow the specific variant at runtime. Within each variant,
|
|
1285
1485
|
* `rules`, `referrers`, and `aggregatedMetrics` are all guaranteed to be from the same model.
|
|
1486
|
+
* When `awardModel` is `"unrecognized"`, the page was produced by a server running a newer
|
|
1487
|
+
* version — use {@link ReferrerLeaderboardPageUnrecognized} to access `originalAwardModel`.
|
|
1286
1488
|
*/
|
|
1287
|
-
type ReferrerLeaderboardPage = ReferrerLeaderboardPagePieSplit | ReferrerLeaderboardPageRevShareLimit;
|
|
1489
|
+
type ReferrerLeaderboardPage = ReferrerLeaderboardPagePieSplit | ReferrerLeaderboardPageRevShareLimit | ReferrerLeaderboardPageUnrecognized;
|
|
1288
1490
|
declare const getReferrerLeaderboardPage: (pageParams: ReferrerLeaderboardPageParams, leaderboard: ReferrerLeaderboard) => ReferrerLeaderboardPage;
|
|
1289
1491
|
|
|
1290
1492
|
/**
|
|
@@ -1395,51 +1597,51 @@ type ReferrerMetricsEditionsResponseError = {
|
|
|
1395
1597
|
*/
|
|
1396
1598
|
type ReferrerMetricsEditionsResponse = ReferrerMetricsEditionsResponseOk | ReferrerMetricsEditionsResponseError;
|
|
1397
1599
|
/**
|
|
1398
|
-
* A status code for referral program edition
|
|
1600
|
+
* A status code for referral program edition summaries API responses.
|
|
1399
1601
|
*/
|
|
1400
|
-
declare const
|
|
1602
|
+
declare const ReferralProgramEditionSummariesResponseCodes: {
|
|
1401
1603
|
/**
|
|
1402
|
-
* Represents that the edition
|
|
1604
|
+
* Represents that the edition summaries are available.
|
|
1403
1605
|
*/
|
|
1404
1606
|
readonly Ok: "ok";
|
|
1405
1607
|
/**
|
|
1406
|
-
* Represents that the edition
|
|
1608
|
+
* Represents that the edition summaries are not available.
|
|
1407
1609
|
*/
|
|
1408
1610
|
readonly Error: "error";
|
|
1409
1611
|
};
|
|
1410
1612
|
/**
|
|
1411
|
-
* The derived string union of possible {@link
|
|
1613
|
+
* The derived string union of possible {@link ReferralProgramEditionSummariesResponseCodes}.
|
|
1412
1614
|
*/
|
|
1413
|
-
type
|
|
1615
|
+
type ReferralProgramEditionSummariesResponseCode = (typeof ReferralProgramEditionSummariesResponseCodes)[keyof typeof ReferralProgramEditionSummariesResponseCodes];
|
|
1414
1616
|
/**
|
|
1415
|
-
* The data payload containing edition
|
|
1617
|
+
* The data payload containing edition summaries.
|
|
1416
1618
|
* Editions are sorted in descending order by start timestamp.
|
|
1417
1619
|
*/
|
|
1418
|
-
type
|
|
1419
|
-
editions:
|
|
1620
|
+
type ReferralProgramEditionSummariesData = {
|
|
1621
|
+
editions: ReferralProgramEditionSummary[];
|
|
1420
1622
|
};
|
|
1421
1623
|
/**
|
|
1422
|
-
* A successful response containing
|
|
1624
|
+
* A successful response containing edition summaries.
|
|
1423
1625
|
*/
|
|
1424
|
-
type
|
|
1425
|
-
responseCode: typeof
|
|
1426
|
-
data:
|
|
1626
|
+
type ReferralProgramEditionSummariesResponseOk = {
|
|
1627
|
+
responseCode: typeof ReferralProgramEditionSummariesResponseCodes.Ok;
|
|
1628
|
+
data: ReferralProgramEditionSummariesData;
|
|
1427
1629
|
};
|
|
1428
1630
|
/**
|
|
1429
|
-
* An edition
|
|
1631
|
+
* An edition summaries response when an error occurs.
|
|
1430
1632
|
*/
|
|
1431
|
-
type
|
|
1432
|
-
responseCode: typeof
|
|
1633
|
+
type ReferralProgramEditionSummariesResponseError = {
|
|
1634
|
+
responseCode: typeof ReferralProgramEditionSummariesResponseCodes.Error;
|
|
1433
1635
|
error: string;
|
|
1434
1636
|
errorMessage: string;
|
|
1435
1637
|
};
|
|
1436
1638
|
/**
|
|
1437
|
-
* A referral program edition
|
|
1639
|
+
* A referral program edition summaries API response.
|
|
1438
1640
|
*
|
|
1439
1641
|
* Use the `responseCode` field to determine the specific type interpretation
|
|
1440
1642
|
* at runtime.
|
|
1441
1643
|
*/
|
|
1442
|
-
type
|
|
1644
|
+
type ReferralProgramEditionSummariesResponse = ReferralProgramEditionSummariesResponseOk | ReferralProgramEditionSummariesResponseError;
|
|
1443
1645
|
|
|
1444
1646
|
/**
|
|
1445
1647
|
* Serialized representation of {@link ReferralProgramRules}.
|
|
@@ -1450,17 +1652,9 @@ type SerializedReferralProgramRules = SerializedReferralProgramRulesPieSplit | S
|
|
|
1450
1652
|
*/
|
|
1451
1653
|
type SerializedReferrerLeaderboardPage = SerializedReferrerLeaderboardPagePieSplit | SerializedReferrerLeaderboardPageRevShareLimit;
|
|
1452
1654
|
/**
|
|
1453
|
-
* Serialized representation of {@link
|
|
1454
|
-
*/
|
|
1455
|
-
type SerializedReferrerEditionMetricsRanked = SerializedReferrerEditionMetricsRankedPieSplit | SerializedReferrerEditionMetricsRankedRevShareLimit;
|
|
1456
|
-
/**
|
|
1457
|
-
* Serialized representation of {@link ReferrerEditionMetricsUnranked}.
|
|
1655
|
+
* Serialized representation of {@link ReferrerEditionMetrics}.
|
|
1458
1656
|
*/
|
|
1459
|
-
type
|
|
1460
|
-
/**
|
|
1461
|
-
* Serialized representation of {@link ReferrerEditionMetrics} (union of ranked and unranked).
|
|
1462
|
-
*/
|
|
1463
|
-
type SerializedReferrerEditionMetrics = SerializedReferrerEditionMetricsRanked | SerializedReferrerEditionMetricsUnranked;
|
|
1657
|
+
type SerializedReferrerEditionMetrics = SerializedReferrerEditionMetricsPieSplit | SerializedReferrerEditionMetricsRevShareLimit;
|
|
1464
1658
|
/**
|
|
1465
1659
|
* Serialized representation of {@link ReferrerLeaderboardPageResponseError}.
|
|
1466
1660
|
*
|
|
@@ -1478,11 +1672,9 @@ interface SerializedReferrerLeaderboardPageResponseOk extends Omit<ReferrerLeade
|
|
|
1478
1672
|
*/
|
|
1479
1673
|
type SerializedReferrerLeaderboardPageResponse = SerializedReferrerLeaderboardPageResponseOk | SerializedReferrerLeaderboardPageResponseError;
|
|
1480
1674
|
/**
|
|
1481
|
-
* Serialized representation of {@link
|
|
1675
|
+
* Serialized representation of {@link ReferralProgramEditionSummary}.
|
|
1482
1676
|
*/
|
|
1483
|
-
|
|
1484
|
-
rules: SerializedReferralProgramRules;
|
|
1485
|
-
}
|
|
1677
|
+
type SerializedReferralProgramEditionSummary = SerializedReferralProgramEditionSummaryPieSplit | SerializedReferralProgramEditionSummaryRevShareLimit;
|
|
1486
1678
|
/**
|
|
1487
1679
|
* Serialized representation of referrer metrics data for requested editions.
|
|
1488
1680
|
* Uses Partial because TypeScript cannot know at compile time which specific edition
|
|
@@ -1507,27 +1699,27 @@ type SerializedReferrerMetricsEditionsResponseError = ReferrerMetricsEditionsRes
|
|
|
1507
1699
|
*/
|
|
1508
1700
|
type SerializedReferrerMetricsEditionsResponse = SerializedReferrerMetricsEditionsResponseOk | SerializedReferrerMetricsEditionsResponseError;
|
|
1509
1701
|
/**
|
|
1510
|
-
* Serialized representation of {@link
|
|
1702
|
+
* Serialized representation of {@link ReferralProgramEditionSummariesData}.
|
|
1511
1703
|
*/
|
|
1512
|
-
interface
|
|
1513
|
-
editions:
|
|
1704
|
+
interface SerializedReferralProgramEditionSummariesData extends Omit<ReferralProgramEditionSummariesData, "editions"> {
|
|
1705
|
+
editions: SerializedReferralProgramEditionSummary[];
|
|
1514
1706
|
}
|
|
1515
1707
|
/**
|
|
1516
|
-
* Serialized representation of {@link
|
|
1708
|
+
* Serialized representation of {@link ReferralProgramEditionSummariesResponseOk}.
|
|
1517
1709
|
*/
|
|
1518
|
-
interface
|
|
1519
|
-
data:
|
|
1710
|
+
interface SerializedReferralProgramEditionSummariesResponseOk extends Omit<ReferralProgramEditionSummariesResponseOk, "data"> {
|
|
1711
|
+
data: SerializedReferralProgramEditionSummariesData;
|
|
1520
1712
|
}
|
|
1521
1713
|
/**
|
|
1522
|
-
* Serialized representation of {@link
|
|
1714
|
+
* Serialized representation of {@link ReferralProgramEditionSummariesResponseError}.
|
|
1523
1715
|
*
|
|
1524
1716
|
* Note: All fields are already serializable, so this type is identical to the source type.
|
|
1525
1717
|
*/
|
|
1526
|
-
type
|
|
1718
|
+
type SerializedReferralProgramEditionSummariesResponseError = ReferralProgramEditionSummariesResponseError;
|
|
1527
1719
|
/**
|
|
1528
|
-
* Serialized representation of {@link
|
|
1720
|
+
* Serialized representation of {@link ReferralProgramEditionSummariesResponse}.
|
|
1529
1721
|
*/
|
|
1530
|
-
type
|
|
1722
|
+
type SerializedReferralProgramEditionSummariesResponse = SerializedReferralProgramEditionSummariesResponseOk | SerializedReferralProgramEditionSummariesResponseError;
|
|
1531
1723
|
|
|
1532
1724
|
/**
|
|
1533
1725
|
* Deserialize a {@link ReferrerLeaderboardPageResponse} object.
|
|
@@ -1542,9 +1734,9 @@ declare function deserializeReferrerMetricsEditionsResponse(maybeResponse: Seria
|
|
|
1542
1734
|
*/
|
|
1543
1735
|
declare function deserializeReferralProgramEditionConfigSetArray(maybeArray: unknown, valueLabel?: string): ReferralProgramEditionConfig[];
|
|
1544
1736
|
/**
|
|
1545
|
-
* Deserialize a {@link
|
|
1737
|
+
* Deserialize a {@link ReferralProgramEditionSummariesResponse} object.
|
|
1546
1738
|
*/
|
|
1547
|
-
declare function
|
|
1739
|
+
declare function deserializeReferralProgramEditionSummariesResponse(maybeResponse: SerializedReferralProgramEditionSummariesResponse, valueLabel?: string): ReferralProgramEditionSummariesResponse;
|
|
1548
1740
|
|
|
1549
1741
|
/**
|
|
1550
1742
|
* Serializes a {@link ReferralProgramRules} object.
|
|
@@ -1554,9 +1746,12 @@ declare function deserializeReferralProgramEditionConfigSetResponse(maybeRespons
|
|
|
1554
1746
|
*/
|
|
1555
1747
|
declare function serializeReferralProgramRules(rules: ReferralProgramRules): SerializedReferralProgramRules;
|
|
1556
1748
|
/**
|
|
1557
|
-
* Serializes a {@link
|
|
1749
|
+
* Serializes a {@link ReferralProgramEditionSummary} object.
|
|
1750
|
+
*
|
|
1751
|
+
* @throws if called with a {@link ReferralProgramEditionSummaryUnrecognized} — unrecognized
|
|
1752
|
+
* summaries are client-side forward-compatibility placeholders and must never be serialized.
|
|
1558
1753
|
*/
|
|
1559
|
-
declare function
|
|
1754
|
+
declare function serializeReferralProgramEditionSummary(summary: ReferralProgramEditionSummary): SerializedReferralProgramEditionSummary;
|
|
1560
1755
|
/**
|
|
1561
1756
|
* Serialize a {@link ReferrerLeaderboardPageResponse} object.
|
|
1562
1757
|
*/
|
|
@@ -1566,9 +1761,9 @@ declare function serializeReferrerLeaderboardPageResponse(response: ReferrerLead
|
|
|
1566
1761
|
*/
|
|
1567
1762
|
declare function serializeReferrerMetricsEditionsResponse(response: ReferrerMetricsEditionsResponse): SerializedReferrerMetricsEditionsResponse;
|
|
1568
1763
|
/**
|
|
1569
|
-
* Serialize a {@link
|
|
1764
|
+
* Serialize a {@link ReferralProgramEditionSummariesResponse} object.
|
|
1570
1765
|
*/
|
|
1571
|
-
declare function
|
|
1766
|
+
declare function serializeReferralProgramEditionSummariesResponse(response: ReferralProgramEditionSummariesResponse): SerializedReferralProgramEditionSummariesResponse;
|
|
1572
1767
|
|
|
1573
1768
|
/**
|
|
1574
1769
|
* Calculate the score of a referrer based on the total incremental duration
|
|
@@ -1582,6 +1777,29 @@ declare function serializeReferralProgramEditionConfigSetResponse(response: Refe
|
|
|
1582
1777
|
*/
|
|
1583
1778
|
declare const calcReferrerScorePieSplit: (totalIncrementalDuration: Duration) => ReferrerScore;
|
|
1584
1779
|
|
|
1780
|
+
/**
|
|
1781
|
+
* Calculate the status of a `pie-split` referral program.
|
|
1782
|
+
*
|
|
1783
|
+
* Delegates entirely to {@link calcBaseReferralProgramEditionStatus} — pie-split has no additional
|
|
1784
|
+
* runtime conditions that affect status beyond the time-based lifecycle.
|
|
1785
|
+
*
|
|
1786
|
+
* @param rules - The pie-split rules for the edition.
|
|
1787
|
+
* @param now - Current date in {@link UnixTimestamp} format.
|
|
1788
|
+
*/
|
|
1789
|
+
declare const calcReferralProgramEditionStatusPieSplit: (rules: ReferralProgramRulesPieSplit, now: UnixTimestamp) => ReferralProgramEditionStatusId;
|
|
1790
|
+
|
|
1791
|
+
/**
|
|
1792
|
+
* Calculate the status of a `rev-share-limit` referral program.
|
|
1793
|
+
*
|
|
1794
|
+
* Returns `Exhausted` when the program is `Active` but its award pool has been fully consumed
|
|
1795
|
+
* (`awardPoolRemaining.amount === 0n`). Otherwise delegates to {@link calcBaseReferralProgramEditionStatus}.
|
|
1796
|
+
*
|
|
1797
|
+
* @param rules - The rev-share-limit rules for the edition.
|
|
1798
|
+
* @param now - Current date in {@link UnixTimestamp} format.
|
|
1799
|
+
* @param aggregatedMetrics - The aggregated leaderboard metrics, used to check `awardPoolRemaining`.
|
|
1800
|
+
*/
|
|
1801
|
+
declare const calcReferralProgramEditionStatusRevShareLimit: (rules: ReferralProgramRulesRevShareLimit, now: UnixTimestamp, aggregatedMetrics: AggregatedReferrerMetricsRevShareLimit) => ReferralProgramEditionStatusId;
|
|
1802
|
+
|
|
1585
1803
|
/**
|
|
1586
1804
|
* Default ENSNode API endpoint URL
|
|
1587
1805
|
*/
|
|
@@ -1661,12 +1879,13 @@ declare class ENSReferralsClient {
|
|
|
1661
1879
|
* @param request.recordsPerPage - Number of records per page (default: 25, max: 100)
|
|
1662
1880
|
* @returns {ReferrerLeaderboardPageResponse}
|
|
1663
1881
|
*
|
|
1882
|
+
* @remarks If the server returns a leaderboard page whose `awardModel` is not recognized by
|
|
1883
|
+
* this client version, it is preserved as {@link ReferrerLeaderboardPageUnrecognized}. Callers
|
|
1884
|
+
* should check `response.data.awardModel` and handle the `"unrecognized"` case accordingly.
|
|
1885
|
+
*
|
|
1664
1886
|
* @throws if the ENSNode request fails
|
|
1665
1887
|
* @throws if the ENSNode API returns an error response
|
|
1666
1888
|
* @throws if the ENSNode response breaks required invariants
|
|
1667
|
-
* @throws if the requested edition uses an award model not recognized by this version of
|
|
1668
|
-
* the client. Call {@link getEditionConfigSet} first to verify the edition's `awardModel`
|
|
1669
|
-
* is supported before requesting its leaderboard.
|
|
1670
1889
|
*
|
|
1671
1890
|
* @example
|
|
1672
1891
|
* ```typescript
|
|
@@ -1674,17 +1893,16 @@ declare class ENSReferralsClient {
|
|
|
1674
1893
|
* const editionSlug = "2025-12";
|
|
1675
1894
|
* const response = await client.getReferrerLeaderboardPage({ edition: editionSlug });
|
|
1676
1895
|
* if (response.responseCode === ReferrerLeaderboardPageResponseCodes.Ok) {
|
|
1677
|
-
* const {
|
|
1678
|
-
*
|
|
1679
|
-
*
|
|
1680
|
-
*
|
|
1681
|
-
*
|
|
1682
|
-
*
|
|
1683
|
-
*
|
|
1684
|
-
*
|
|
1685
|
-
*
|
|
1686
|
-
*
|
|
1687
|
-
* console.log(`Page ${pageContext.page} of ${pageContext.totalPages}`);
|
|
1896
|
+
* const { awardModel, pageContext, accurateAsOf } = response.data;
|
|
1897
|
+
* if (awardModel === ReferralProgramAwardModels.Unrecognized) {
|
|
1898
|
+
* console.log(`Unrecognized award model: ${response.data.originalAwardModel} — skipping`);
|
|
1899
|
+
* } else {
|
|
1900
|
+
* const { aggregatedMetrics, referrers, rules } = response.data;
|
|
1901
|
+
* console.log(`Edition: ${editionSlug}`);
|
|
1902
|
+
* console.log(`Subregistry: ${rules.subregistryId}`);
|
|
1903
|
+
* console.log(`Total Referrers: ${pageContext.totalRecords}`);
|
|
1904
|
+
* console.log(`Page ${pageContext.page} of ${pageContext.totalPages}`);
|
|
1905
|
+
* }
|
|
1688
1906
|
* }
|
|
1689
1907
|
* ```
|
|
1690
1908
|
*
|
|
@@ -1717,22 +1935,17 @@ declare class ENSReferralsClient {
|
|
|
1717
1935
|
* referral program editions. Returns a record mapping each requested edition slug
|
|
1718
1936
|
* to the referrer's metrics for that edition.
|
|
1719
1937
|
*
|
|
1720
|
-
* The response data maps edition slugs to referrer metrics. Each edition's
|
|
1721
|
-
* discriminated union
|
|
1722
|
-
*
|
|
1723
|
-
* **For referrers on the leaderboard** (`ReferrerEditionMetricsRanked`):
|
|
1724
|
-
* - `type`: {@link ReferrerEditionMetricsTypeIds.Ranked}
|
|
1725
|
-
* - `referrer`: The `AwardedReferrerMetrics` with rank, qualification status, and award share
|
|
1726
|
-
* - `rules`: The referral program rules for this edition
|
|
1727
|
-
* - `aggregatedMetrics`: Aggregated metrics for all referrers on the leaderboard
|
|
1728
|
-
* - `accurateAsOf`: Unix timestamp indicating when the data was last updated
|
|
1938
|
+
* The response data maps edition slugs to referrer metrics. Each edition's entry is a
|
|
1939
|
+
* {@link ReferrerEditionMetrics} discriminated union. Narrow on `awardModel` first to
|
|
1940
|
+
* exclude unrecognized models, then on `type` to distinguish ranked from unranked:
|
|
1729
1941
|
*
|
|
1730
|
-
*
|
|
1731
|
-
*
|
|
1732
|
-
* -
|
|
1733
|
-
* - `
|
|
1734
|
-
*
|
|
1735
|
-
* - `
|
|
1942
|
+
* - `awardModel: "unrecognized"` ({@link ReferrerEditionMetricsUnrecognized}): the server
|
|
1943
|
+
* returned an award model this client does not recognize. Only `originalAwardModel` is
|
|
1944
|
+
* available; no model-specific fields are present.
|
|
1945
|
+
* - `type: "ranked"` ({@link ReferrerEditionMetricsTypeIds.Ranked}): the referrer appears on
|
|
1946
|
+
* the leaderboard. `referrer` contains rank, qualification status, and award share.
|
|
1947
|
+
* - `type: "unranked"` ({@link ReferrerEditionMetricsTypeIds.Unranked}): the referrer has no
|
|
1948
|
+
* activity in this edition. `referrer` contains zero-value placeholders.
|
|
1736
1949
|
*
|
|
1737
1950
|
* **Note:** This endpoint does not allow partial success. When `responseCode === Ok`,
|
|
1738
1951
|
* all requested editions are guaranteed to be present in the response data. If any
|
|
@@ -1743,11 +1956,13 @@ declare class ENSReferralsClient {
|
|
|
1743
1956
|
* @param request The referrer address and edition slugs to query
|
|
1744
1957
|
* @returns {ReferrerMetricsEditionsResponse} Returns the referrer metrics for requested editions
|
|
1745
1958
|
*
|
|
1959
|
+
* @remarks If the server returns metrics for an edition whose `awardModel` is not recognized by
|
|
1960
|
+
* this client version, that edition's entry in `response.data` is preserved as
|
|
1961
|
+
* {@link ReferrerEditionMetricsUnrecognized}. Callers should check each edition's `awardModel`
|
|
1962
|
+
* and handle the `"unrecognized"` case accordingly.
|
|
1963
|
+
*
|
|
1746
1964
|
* @throws if the ENSNode request fails
|
|
1747
1965
|
* @throws if the response data is malformed
|
|
1748
|
-
* @throws if any of the requested editions use an award model not recognized by this
|
|
1749
|
-
* version of the client. Call {@link getEditionConfigSet} first to verify each
|
|
1750
|
-
* edition's `awardModel` is supported before requesting metrics.
|
|
1751
1966
|
*
|
|
1752
1967
|
* @example
|
|
1753
1968
|
* ```typescript
|
|
@@ -1760,6 +1975,10 @@ declare class ENSReferralsClient {
|
|
|
1760
1975
|
* // All requested editions are present in response.data
|
|
1761
1976
|
* for (const [editionSlug, detail] of Object.entries(response.data)) {
|
|
1762
1977
|
* console.log(`Edition: ${editionSlug}`);
|
|
1978
|
+
* if (detail.awardModel === ReferralProgramAwardModels.Unrecognized) {
|
|
1979
|
+
* console.log(`Unrecognized award model: ${detail.originalAwardModel} — skipping`);
|
|
1980
|
+
* continue;
|
|
1981
|
+
* }
|
|
1763
1982
|
* console.log(`Type: ${detail.type}`);
|
|
1764
1983
|
* if (detail.type === ReferrerEditionMetricsTypeIds.Ranked) {
|
|
1765
1984
|
* console.log(`Rank: ${detail.referrer.rank}`);
|
|
@@ -1777,12 +1996,12 @@ declare class ENSReferralsClient {
|
|
|
1777
1996
|
* editions: ["2025-12"]
|
|
1778
1997
|
* });
|
|
1779
1998
|
* if (response.responseCode === ReferrerMetricsEditionsResponseCodes.Ok) {
|
|
1780
|
-
* const
|
|
1781
|
-
* if (
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
1784
|
-
*
|
|
1785
|
-
*
|
|
1999
|
+
* const detail = response.data["2025-12"];
|
|
2000
|
+
* if (detail && detail.awardModel === ReferralProgramAwardModels.Unrecognized) {
|
|
2001
|
+
* console.log(`Unrecognized award model: ${detail.originalAwardModel} — skipping`);
|
|
2002
|
+
* } else if (detail && detail.type === ReferrerEditionMetricsTypeIds.Ranked) {
|
|
2003
|
+
* console.log(`Edition 2025-12 Rank: ${detail.referrer.rank}`);
|
|
2004
|
+
* } else if (detail) {
|
|
1786
2005
|
* console.log("Referrer is not on the leaderboard for 2025-12");
|
|
1787
2006
|
* }
|
|
1788
2007
|
* }
|
|
@@ -1804,22 +2023,22 @@ declare class ENSReferralsClient {
|
|
|
1804
2023
|
*/
|
|
1805
2024
|
getReferrerMetricsEditions(request: ReferrerMetricsEditionsRequest): Promise<ReferrerMetricsEditionsResponse>;
|
|
1806
2025
|
/**
|
|
1807
|
-
* Get the currently configured referral program edition
|
|
2026
|
+
* Get the currently configured referral program edition summaries.
|
|
1808
2027
|
* Editions are sorted in descending order by start timestamp (most recent first).
|
|
1809
2028
|
*
|
|
1810
|
-
* @returns A response containing
|
|
2029
|
+
* @returns A response containing edition summaries, or an error response if unavailable.
|
|
1811
2030
|
*
|
|
1812
2031
|
* @remarks Editions whose `rules.awardModel` is not recognized by this client version are
|
|
1813
|
-
* preserved as {@link
|
|
1814
|
-
* editions — recognized and unrecognized alike. Callers should check `
|
|
2032
|
+
* preserved as {@link ReferralProgramEditionSummaryUnrecognized}. The returned response includes all
|
|
2033
|
+
* editions — recognized and unrecognized alike. Callers should check `edition.awardModel`
|
|
1815
2034
|
* and skip editions with `"unrecognized"` as appropriate. At least one edition of any kind must
|
|
1816
2035
|
* be present, otherwise deserialization throws.
|
|
1817
2036
|
*
|
|
1818
2037
|
* @example
|
|
1819
2038
|
* ```typescript
|
|
1820
|
-
* const response = await client.
|
|
2039
|
+
* const response = await client.getEditionSummaries();
|
|
1821
2040
|
*
|
|
1822
|
-
* if (response.responseCode ===
|
|
2041
|
+
* if (response.responseCode === ReferralProgramEditionSummariesResponseCodes.Ok) {
|
|
1823
2042
|
* console.log(`Found ${response.data.editions.length} editions`);
|
|
1824
2043
|
* for (const edition of response.data.editions) {
|
|
1825
2044
|
* console.log(`${edition.slug}: ${edition.displayName}`);
|
|
@@ -1830,15 +2049,15 @@ declare class ENSReferralsClient {
|
|
|
1830
2049
|
* @example
|
|
1831
2050
|
* ```typescript
|
|
1832
2051
|
* // Handle error response
|
|
1833
|
-
* const response = await client.
|
|
2052
|
+
* const response = await client.getEditionSummaries();
|
|
1834
2053
|
*
|
|
1835
|
-
* if (response.responseCode ===
|
|
2054
|
+
* if (response.responseCode === ReferralProgramEditionSummariesResponseCodes.Error) {
|
|
1836
2055
|
* console.error(response.error);
|
|
1837
2056
|
* console.error(response.errorMessage);
|
|
1838
2057
|
* }
|
|
1839
2058
|
* ```
|
|
1840
2059
|
*/
|
|
1841
|
-
|
|
2060
|
+
getEditionSummaries(): Promise<ReferralProgramEditionSummariesResponse>;
|
|
1842
2061
|
}
|
|
1843
2062
|
|
|
1844
2063
|
/**
|
|
@@ -1876,4 +2095,4 @@ declare const SECONDS_PER_YEAR: Duration;
|
|
|
1876
2095
|
declare function isValidDuration(duration: Duration): boolean;
|
|
1877
2096
|
declare function validateDuration(duration: Duration): void;
|
|
1878
2097
|
|
|
1879
|
-
export { type AggregatedReferrerMetricsPieSplit, type AggregatedReferrerMetricsRevShareLimit, type AwardedReferrerMetricsPieSplit, type AwardedReferrerMetricsRevShareLimit, BASE_REVENUE_CONTRIBUTION_PER_YEAR, type BaseReferralProgramRules, type BaseReferrerLeaderboardPage, type ClientOptions, DEFAULT_ENSNODE_API_URL, ENSReferralsClient, MAX_EDITIONS_PER_REQUEST, REFERRERS_PER_LEADERBOARD_PAGE_DEFAULT, REFERRERS_PER_LEADERBOARD_PAGE_MAX, type RankedReferrerMetricsPieSplit, type RankedReferrerMetricsRevShareLimit, type ReferralEvent, type ReferralProgramAwardModel, ReferralProgramAwardModels, type ReferralProgramEditionConfig, type ReferralProgramEditionConfigSet, type
|
|
2098
|
+
export { type AggregatedReferrerMetricsPieSplit, type AggregatedReferrerMetricsRevShareLimit, type AwardedReferrerMetricsPieSplit, type AwardedReferrerMetricsRevShareLimit, BASE_REVENUE_CONTRIBUTION_PER_YEAR, type BaseReferralProgramEditionSummary, type BaseReferralProgramRules, type BaseReferrerLeaderboardPage, type ClientOptions, DEFAULT_ENSNODE_API_URL, ENSReferralsClient, MAX_EDITIONS_PER_REQUEST, REFERRAL_PROGRAM_EDITION_SLUG_PATTERN, REFERRERS_PER_LEADERBOARD_PAGE_DEFAULT, REFERRERS_PER_LEADERBOARD_PAGE_MAX, type RankedReferrerMetricsPieSplit, type RankedReferrerMetricsRevShareLimit, type ReferralEvent, type ReferralProgramAwardModel, ReferralProgramAwardModels, type ReferralProgramEditionConfig, type ReferralProgramEditionConfigSet, type ReferralProgramEditionDisqualification, type ReferralProgramEditionSlug, type ReferralProgramEditionStatusId, ReferralProgramEditionStatuses, type ReferralProgramEditionSummariesData, type ReferralProgramEditionSummariesResponse, type ReferralProgramEditionSummariesResponseCode, ReferralProgramEditionSummariesResponseCodes, type ReferralProgramEditionSummariesResponseError, type ReferralProgramEditionSummariesResponseOk, type ReferralProgramEditionSummary, type ReferralProgramEditionSummaryPieSplit, type ReferralProgramEditionSummaryRevShareLimit, type ReferralProgramEditionSummaryUnrecognized, type ReferralProgramRules, type ReferralProgramRulesPieSplit, type ReferralProgramRulesRevShareLimit, type ReferralProgramRulesUnrecognized, type ReferrerEditionMetrics, type ReferrerEditionMetricsPieSplit, type ReferrerEditionMetricsRankedPieSplit, type ReferrerEditionMetricsRankedRevShareLimit, type ReferrerEditionMetricsRevShareLimit, type ReferrerEditionMetricsTypeId, ReferrerEditionMetricsTypeIds, type ReferrerEditionMetricsUnrankedPieSplit, type ReferrerEditionMetricsUnrankedRevShareLimit, type ReferrerEditionMetricsUnrecognized, type ReferrerLeaderboard, type ReferrerLeaderboardPage, type ReferrerLeaderboardPageContext, type ReferrerLeaderboardPageParams, type ReferrerLeaderboardPagePieSplit, type ReferrerLeaderboardPageRequest, type ReferrerLeaderboardPageResponse, type ReferrerLeaderboardPageResponseCode, ReferrerLeaderboardPageResponseCodes, type ReferrerLeaderboardPageResponseError, type ReferrerLeaderboardPageResponseOk, type ReferrerLeaderboardPageRevShareLimit, type ReferrerLeaderboardPageUnrecognized, type ReferrerLeaderboardPieSplit, type ReferrerLeaderboardRevShareLimit, type ReferrerMetrics, type ReferrerMetricsEditionsData, type ReferrerMetricsEditionsRequest, type ReferrerMetricsEditionsResponse, type ReferrerMetricsEditionsResponseCode, ReferrerMetricsEditionsResponseCodes, type ReferrerMetricsEditionsResponseError, type ReferrerMetricsEditionsResponseOk, type ReferrerMetricsForComparison, type ReferrerMetricsRevShareLimit, type ReferrerRank, type ReferrerScore, SECONDS_PER_YEAR, type ScoredReferrerMetricsPieSplit, type SerializedAggregatedReferrerMetricsPieSplit, type SerializedAggregatedReferrerMetricsRevShareLimit, type SerializedAwardedReferrerMetricsPieSplit, type SerializedAwardedReferrerMetricsRevShareLimit, type SerializedReferralProgramEditionSummariesData, type SerializedReferralProgramEditionSummariesResponse, type SerializedReferralProgramEditionSummariesResponseError, type SerializedReferralProgramEditionSummariesResponseOk, type SerializedReferralProgramEditionSummary, type SerializedReferralProgramEditionSummaryPieSplit, type SerializedReferralProgramEditionSummaryRevShareLimit, type SerializedReferralProgramRules, type SerializedReferralProgramRulesPieSplit, type SerializedReferralProgramRulesRevShareLimit, type SerializedReferrerEditionMetrics, type SerializedReferrerEditionMetricsPieSplit, type SerializedReferrerEditionMetricsRankedPieSplit, type SerializedReferrerEditionMetricsRankedRevShareLimit, type SerializedReferrerEditionMetricsRevShareLimit, type SerializedReferrerEditionMetricsUnrankedPieSplit, type SerializedReferrerEditionMetricsUnrankedRevShareLimit, type SerializedReferrerLeaderboardPage, type SerializedReferrerLeaderboardPagePieSplit, type SerializedReferrerLeaderboardPageResponse, type SerializedReferrerLeaderboardPageResponseError, type SerializedReferrerLeaderboardPageResponseOk, type SerializedReferrerLeaderboardPageRevShareLimit, type SerializedReferrerMetricsEditionsData, type SerializedReferrerMetricsEditionsResponse, type SerializedReferrerMetricsEditionsResponseError, type SerializedReferrerMetricsEditionsResponseOk, type SerializedUnrankedReferrerMetricsPieSplit, type SerializedUnrankedReferrerMetricsRevShareLimit, type UnrankedReferrerMetricsPieSplit, type UnrankedReferrerMetricsRevShareLimit, buildAggregatedReferrerMetricsPieSplit, buildAggregatedReferrerMetricsRevShareLimit, buildAwardedReferrerMetricsPieSplit, buildAwardedReferrerMetricsRevShareLimit, buildEditionSummary, buildEditionSummaryPieSplit, buildEditionSummaryRevShareLimit, buildEnsReferralUrl, buildLeaderboardPagePieSplit, buildLeaderboardPageRevShareLimit, buildRankedReferrerMetricsPieSplit, buildRankedReferrerMetricsRevShareLimit, buildReferralProgramEditionConfigSet, buildReferralProgramRulesPieSplit, buildReferralProgramRulesRevShareLimit, buildReferrerLeaderboardPageContext, buildReferrerLeaderboardPageParams, buildReferrerLeaderboardPieSplit, buildReferrerLeaderboardRevShareLimit, buildReferrerMetrics, buildReferrerMetricsRevShareLimit, buildScoredReferrerMetricsPieSplit, buildUnrankedReferrerMetricsPieSplit, buildUnrankedReferrerMetricsRevShareLimit, calcBaseReferralProgramEditionStatus, calcReferralProgramEditionStatusPieSplit, calcReferralProgramEditionStatusRevShareLimit, calcReferrerAwardPoolSharePieSplit, calcReferrerScorePieSplit, compareReferrerMetrics, deserializeReferralProgramEditionConfigSetArray, deserializeReferralProgramEditionSummariesResponse, deserializeReferrerLeaderboardPageResponse, deserializeReferrerMetricsEditionsResponse, getDefaultReferralProgramEditionConfigSet, getReferrerEditionMetrics, getReferrerLeaderboardPage, isFiniteNonNegativeNumber, isInteger, isNonNegativeInteger, isPositiveInteger, isReferrerQualifiedRevShareLimit, isValidDuration, isValidReferrerScore, normalizeAddress, serializeReferralProgramEditionSummariesResponse, serializeReferralProgramEditionSummary, serializeReferralProgramRules, serializeReferrerLeaderboardPageResponse, serializeReferrerMetricsEditionsResponse, sliceReferrers, sortReferrerMetrics, validateAggregatedReferrerMetricsPieSplit, validateAggregatedReferrerMetricsRevShareLimit, validateAwardedReferrerMetricsPieSplit, validateAwardedReferrerMetricsRevShareLimit, validateBaseReferralProgramEditionSummary, validateBaseReferralProgramRules, validateDuration, validateEditionSummaryPieSplit, validateEditionSummaryRevShareLimit, validateLowercaseAddress, validateNonNegativeInteger, validateRankedReferrerMetricsPieSplit, validateRankedReferrerMetricsRevShareLimit, validateReferralProgramEditionConfigSet, validateReferralProgramRulesPieSplit, validateReferralProgramRulesRevShareLimit, validateReferrerLeaderboardPageContext, validateReferrerMetrics, validateReferrerMetricsRevShareLimit, validateReferrerRank, validateReferrerScore, validateScoredReferrerMetricsPieSplit, validateUnixTimestamp, validateUnrankedReferrerMetricsPieSplit, validateUnrankedReferrerMetricsRevShareLimit };
|