@namehash/ens-referrals 1.9.0 → 1.10.1
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/README.md +20 -22
- package/dist/index.cjs +2398 -819
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1532 -424
- package/dist/index.d.ts +1532 -424
- package/dist/index.js +2385 -816
- package/dist/index.js.map +1 -1
- package/package.json +4 -13
- package/dist/v1/index.cjs +0 -20902
- package/dist/v1/index.cjs.map +0 -1
- package/dist/v1/index.d.cts +0 -2098
- package/dist/v1/index.d.ts +0 -2098
- package/dist/v1/index.js +0 -20879
- package/dist/v1/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Utilities for working with ENS Referrals data. This package is intended for developers who want to build referral dashboards, stats pages, or other integrations on top of ENS Referrals APIs.
|
|
4
4
|
|
|
5
|
-
The main entry point today is [`v1`](https://github.com/namehash/ensnode/tree/main/packages/ens-referrals/src/v1), which includes the current client and response types for the latest ENS Referrals program format.
|
|
6
|
-
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
9
7
|
```bash
|
|
@@ -12,19 +10,14 @@ npm install @namehash/ens-referrals viem
|
|
|
12
10
|
|
|
13
11
|
## Quick Start
|
|
14
12
|
|
|
15
|
-
`v1` is the recommended version for new integrations.
|
|
16
|
-
|
|
17
|
-
- [`v1`](https://github.com/namehash/ensnode/tree/main/packages/ens-referrals/src/v1) is the actively supported version that reflects the current ENS Referrals program rules and awards.
|
|
18
|
-
- The root [`@namehash/ens-referrals`](https://github.com/namehash/ensnode/tree/main/packages/ens-referrals/src/client.ts) import is deprecated and is planned to be removed soon.
|
|
19
|
-
|
|
20
13
|
### Set up `ENSReferralsClient`
|
|
21
14
|
|
|
22
15
|
`ENSReferralsClient` is the main way to read referral data from ENSNode.
|
|
23
16
|
|
|
24
17
|
```typescript
|
|
25
|
-
import { ENSReferralsClient } from "@namehash/ens-referrals
|
|
18
|
+
import { ENSReferralsClient } from "@namehash/ens-referrals";
|
|
26
19
|
|
|
27
|
-
// Create a client with the default ENSNode
|
|
20
|
+
// Create a client with the default ENSNode URL
|
|
28
21
|
const client = new ENSReferralsClient();
|
|
29
22
|
```
|
|
30
23
|
|
|
@@ -36,7 +29,7 @@ const client = new ENSReferralsClient({
|
|
|
36
29
|
});
|
|
37
30
|
```
|
|
38
31
|
|
|
39
|
-
## Use ENS Referrals API
|
|
32
|
+
## Use ENS Referrals API
|
|
40
33
|
|
|
41
34
|
### Get all referral program editions → `getEditionSummaries()`
|
|
42
35
|
|
|
@@ -56,7 +49,7 @@ if (response.responseCode === ReferralProgramEditionSummariesResponseCodes.Ok) {
|
|
|
56
49
|
}
|
|
57
50
|
```
|
|
58
51
|
|
|
59
|
-
More examples are available in [`packages/ens-referrals/src/
|
|
52
|
+
More examples are available in [`packages/ens-referrals/src/client.ts`](https://github.com/namehash/ensnode/tree/main/packages/ens-referrals/src/client.ts).
|
|
60
53
|
|
|
61
54
|
### Get a referrer leaderboard page → `getReferrerLeaderboardPage()`
|
|
62
55
|
|
|
@@ -96,20 +89,20 @@ if (response.responseCode === ReferrerLeaderboardPageResponseCodes.Ok) {
|
|
|
96
89
|
);
|
|
97
90
|
}
|
|
98
91
|
|
|
99
|
-
if (leaderboardPage.awardModel === ReferralProgramAwardModels.
|
|
92
|
+
if (leaderboardPage.awardModel === ReferralProgramAwardModels.RevShareCap) {
|
|
100
93
|
console.log(
|
|
101
|
-
`Min
|
|
94
|
+
`Min Base Revenue Contribution: ${leaderboardPage.rules.minBaseRevenueContribution}`,
|
|
102
95
|
);
|
|
103
|
-
console.log(`
|
|
96
|
+
console.log(`Max Base Revenue Share: ${leaderboardPage.rules.maxBaseRevenueShare}`);
|
|
104
97
|
console.log(
|
|
105
|
-
`Tentative award for the
|
|
98
|
+
`Tentative award for the top ranked referrer: ${firstReferrer !== null ? firstReferrer.cappedAward : noReferrersFallback}`,
|
|
106
99
|
);
|
|
107
100
|
}
|
|
108
101
|
}
|
|
109
102
|
}
|
|
110
103
|
```
|
|
111
104
|
|
|
112
|
-
More examples are available in [`packages/ens-referrals/src/
|
|
105
|
+
More examples are available in [`packages/ens-referrals/src/client.ts`](https://github.com/namehash/ensnode/tree/main/packages/ens-referrals/src/client.ts).
|
|
113
106
|
|
|
114
107
|
### Get a referrer's metrics across editions → `getReferrerMetricsEditions()`
|
|
115
108
|
|
|
@@ -118,7 +111,7 @@ Returns referrer metrics for a specified referrer across one or more editions.
|
|
|
118
111
|
```typescript
|
|
119
112
|
const response = await client.getReferrerMetricsEditions({
|
|
120
113
|
referrer: "0x1234567890123456789012345678901234567890",
|
|
121
|
-
editions: ["2025-12", "2026-
|
|
114
|
+
editions: ["2025-12", "2026-04"],
|
|
122
115
|
});
|
|
123
116
|
|
|
124
117
|
if (response.responseCode === ReferrerMetricsEditionsResponseCodes.Ok) {
|
|
@@ -142,25 +135,30 @@ if (response.responseCode === ReferrerMetricsEditionsResponseCodes.Ok) {
|
|
|
142
135
|
console.log(`Referrer's Award Pool Share: ${detail.referrer.awardPoolShare * 100}%`);
|
|
143
136
|
}
|
|
144
137
|
|
|
145
|
-
if (detail.awardModel === ReferralProgramAwardModels.
|
|
138
|
+
if (detail.awardModel === ReferralProgramAwardModels.RevShareCap) {
|
|
146
139
|
console.log(
|
|
147
140
|
`Referrer's total base revenue contribution: ${detail.referrer.totalBaseRevenueContribution}`,
|
|
148
141
|
);
|
|
149
|
-
console.log(`Referrer's
|
|
142
|
+
console.log(`Referrer's uncapped award value: ${detail.referrer.uncappedAward}`);
|
|
150
143
|
}
|
|
151
144
|
}
|
|
152
145
|
}
|
|
153
146
|
```
|
|
154
147
|
|
|
155
|
-
More examples are available in [`packages/ens-referrals/src/
|
|
148
|
+
More examples are available in [`packages/ens-referrals/src/client.ts`](https://github.com/namehash/ensnode/tree/main/packages/ens-referrals/src/client.ts).
|
|
149
|
+
|
|
150
|
+
## See how current Referral Program Editions are configured
|
|
151
|
+
|
|
152
|
+
Check out [`production-editions.json`](https://ensawards.org/production-editions.json) — the live config file powering our production deployment.
|
|
153
|
+
|
|
156
154
|
|
|
157
155
|
## Other Utilities
|
|
158
156
|
|
|
159
157
|
The package also includes helpers for building referral links.
|
|
160
158
|
|
|
161
159
|
```typescript
|
|
162
|
-
import { buildEnsReferralUrl } from "@namehash/ens-referrals
|
|
163
|
-
import type { Address } from "
|
|
160
|
+
import { buildEnsReferralUrl } from "@namehash/ens-referrals";
|
|
161
|
+
import type { Address } from "enssdk";
|
|
164
162
|
|
|
165
163
|
const referrerAddress: Address = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045";
|
|
166
164
|
|