@ensnode/datasources 0.28.0 → 0.29.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/README.md CHANGED
@@ -38,7 +38,7 @@ const vitaliksResolverAddress = await publicClient.readContract({
38
38
 
39
39
  ## Documentation
40
40
 
41
- ### getDatasource(namespace: ENSNamespace, datasourceName: DatasourceName)
41
+ ### getDatasource(namespaceId: ENSNamespaceId, datasourceName: DatasourceName)
42
42
 
43
43
  The primary export of `@ensnode/datasources` is `getDatasource` which returns a selected `Datasource` within the selected ENS namespace.
44
44
 
@@ -55,7 +55,7 @@ const { chain, contracts } = getDatasource('holesky', 'ensroot');
55
55
  const { chain, contracts } = getDatasource('mainnet', 'threedns-base');
56
56
  ```
57
57
 
58
- The available `ENSNamespace`s are:
58
+ The available `ENSNamespaceId`s are:
59
59
  - `mainnet`
60
60
  - `sepolia`
61
61
  - `holesky`
@@ -66,11 +66,11 @@ The available `ENSNamespace`s are:
66
66
  Each ENS namespace my provide **Datasource** entries for any of the possible **DatasourceName**s:
67
67
 
68
68
  The available `DatasourceName`s are:
69
- - `ensroot` — ENS Root Contracts
70
- - `basenames` — Basenames
71
- - `lineanames` — Linea Names
72
- - `threedns-optimism` — 3DNS (on Optimism)
73
- - `threedns-base` — 3DNS (on Base)
69
+ - `ensroot` — ENS Root Contracts, guaranteed to exist
70
+ - `basenames` — Basenames, optional
71
+ - `lineanames` — Linea Names, optional
72
+ - `threedns-optimism` — 3DNS (on Optimism), optional
73
+ - `threedns-base` — 3DNS (on Base), optional
74
74
 
75
75
  A `Datasource` will only be available within an ENS namespace if it is defined, and typescript will enforce that a valid DatasourceName is used within `getDatasource(...)`.
76
76
 
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as viem from 'viem';
4
4
  import { Chain, Abi, Address } from 'viem';
5
5
 
6
6
  /**
7
- * ENSNamespaces encodes the set of well-known ENS namespaces.
7
+ * ENSNamespaceIds encodes the set of identifiers for well-known ENS namespaces.
8
8
  *
9
9
  * Each ENS namespace is a single, unified set of ENS names with a distinct onchain root
10
10
  * Registry (the ensroot Datasource) and the capability of spanning from that root Registry across
@@ -29,16 +29,16 @@ import { Chain, Abi, Address } from 'viem';
29
29
  * protocol changes, running deterministic test suites, and local development.
30
30
  * https://github.com/ensdomains/ens-test-env
31
31
  */
32
- declare const ENSNamespaces: {
32
+ declare const ENSNamespaceIds: {
33
33
  readonly Mainnet: "mainnet";
34
34
  readonly Sepolia: "sepolia";
35
35
  readonly Holesky: "holesky";
36
36
  readonly EnsTestEnv: "ens-test-env";
37
37
  };
38
38
  /**
39
- * ENSNamespace is the derived string union of possible ENSNamespace values.
39
+ * ENSNamespaceId is the derived string union of possible ENS namespace identifiers.
40
40
  */
41
- type ENSNamespace = (typeof ENSNamespaces)[keyof typeof ENSNamespaces];
41
+ type ENSNamespaceId = (typeof ENSNamespaceIds)[keyof typeof ENSNamespaceIds];
42
42
  /**
43
43
  * A Datasource describes a set of contracts on a given chain that interact with the ENS protocol.
44
44
  */
@@ -87,14 +87,16 @@ type ContractConfig = {
87
87
  readonly startBlock: number;
88
88
  };
89
89
  /**
90
- * DatasourceMap encodes the set of known Datasources within an ENS namespace, keyed by DatasourceName.
91
- * The ENSRoot Datasource is required, and all others are optional.
90
+ * ENSNamespace encodes a set of known Datasources associated with the same ENS namespace.
91
+ *
92
+ * The ENSRoot Datasource is required (this formally defines an ENS namespace). All other Datasources
93
+ * within the ENSNamespace are optional.
92
94
  */
93
- type DatasourceMap = {
95
+ type ENSNamespace = {
94
96
  [DatasourceNames.ENSRoot]: Datasource;
95
97
  } & Partial<Record<Exclude<DatasourceName, "ensroot">, Datasource>>;
96
98
 
97
- declare const ENSNamespaceToDatasourceMap: {
99
+ declare const ENSNamespacesById: {
98
100
  readonly mainnet: {
99
101
  ensroot: {
100
102
  chain: {
@@ -35596,23 +35598,23 @@ declare const ENSNamespaceToDatasourceMap: {
35596
35598
  };
35597
35599
  };
35598
35600
  /**
35599
- * Returns the DatasourceMap within the specified namespace.
35601
+ * Returns the ENSNamespace for a specified `namespaceId`.
35600
35602
  *
35601
- * @param namespace - The ENSNamespace identifier (e.g. 'mainnet', 'sepolia', 'holesky', 'ens-test-env')
35602
- * @returns The DatasourceMap for the specified namespace
35603
+ * @param namespaceId - The ENSNamespace identifier (e.g. 'mainnet', 'sepolia', 'holesky', 'ens-test-env')
35604
+ * @returns the ENSNamespace
35603
35605
  */
35604
- declare const getDatasourceMap: <T extends ENSNamespace>(namespace: T) => (typeof ENSNamespaceToDatasourceMap)[T];
35606
+ declare const getENSNamespace: <T extends ENSNamespaceId>(namespaceId: T) => (typeof ENSNamespacesById)[T];
35605
35607
  /**
35606
- * Returns the `datasourceName` Datasource within the specified `namespace` namespace.
35608
+ * Returns the `datasourceName` Datasource within the specified `namespaceId` namespace.
35607
35609
  *
35608
35610
  * NOTE: the typescript typechecker _will_ enforce validity. i.e. using an invalid `datasourceName`
35609
- * within the specified `namespace` will be a type error.
35611
+ * within the specified `namespaceId` will be a type error.
35610
35612
  *
35611
- * @param namespace - The ENSNamespace identifier (e.g. 'mainnet', 'sepolia', 'holesky', 'ens-test-env')
35613
+ * @param namespaceId - The ENSNamespace identifier (e.g. 'mainnet', 'sepolia', 'holesky', 'ens-test-env')
35612
35614
  * @param datasourceName - The name of the Datasource to retrieve
35613
35615
  * @returns The Datasource object for the given name within the specified namespace
35614
35616
  */
35615
- declare const getDatasource: <N extends ENSNamespace, D extends keyof ReturnType<typeof getDatasourceMap<N>>>(namespace: N, datasourceName: D) => {
35617
+ declare const getDatasource: <N extends ENSNamespaceId, D extends keyof ReturnType<typeof getENSNamespace<N>>>(namespaceId: N, datasourceName: D) => {
35616
35618
  readonly mainnet: {
35617
35619
  ensroot: {
35618
35620
  chain: {
@@ -71118,6 +71120,6 @@ declare const getDatasource: <N extends ENSNamespace, D extends keyof ReturnType
71118
71120
  *
71119
71121
  * @returns the chain ID that hosts the ENS Root
71120
71122
  */
71121
- declare const getENSRootChainId: (namespace: ENSNamespace) => number;
71123
+ declare const getENSRootChainId: (namespaceId: ENSNamespaceId) => number;
71122
71124
 
71123
- export { type ContractConfig, type Datasource, type DatasourceMap, type DatasourceName, DatasourceNames, type ENSNamespace, ENSNamespaces, type EventFilter, getDatasource, getDatasourceMap, getENSRootChainId };
71125
+ export { type ContractConfig, type Datasource, type DatasourceName, DatasourceNames, type ENSNamespace, type ENSNamespaceId, ENSNamespaceIds, type EventFilter, getDatasource, getENSNamespace, getENSRootChainId };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/lib/types.ts
2
- var ENSNamespaces = {
2
+ var ENSNamespaceIds = {
3
3
  Mainnet: "mainnet",
4
4
  Sepolia: "sepolia",
5
5
  Holesky: "holesky",
@@ -4997,7 +4997,7 @@ var deploymentAddresses = getENSTestEnvDeploymentAddresses();
4997
4997
  var EMPTY_ADDRESS = "";
4998
4998
  var ens_test_env_default = {
4999
4999
  /**
5000
- * Root Datasource
5000
+ * ENSRoot Datasource
5001
5001
  *
5002
5002
  * Addresses and Start Blocks from ens-test-env
5003
5003
  * https://github.com/ensdomains/ens-test-env/
@@ -5053,7 +5053,7 @@ var ens_test_env_default = {
5053
5053
  import { holesky } from "viem/chains";
5054
5054
  var holesky_default = {
5055
5055
  /**
5056
- * Root Datasource
5056
+ * ENSRoot Datasource
5057
5057
  *
5058
5058
  * Addresses and Start Blocks from ENS Holesky Subgraph Manifest
5059
5059
  * https://ipfs.io/ipfs/Qmd94vseLpkUrSFvJ3GuPubJSyHz8ornhNrwEAt6pjcbex
@@ -9043,7 +9043,7 @@ var ThreeDNSToken = [
9043
9043
  // src/mainnet.ts
9044
9044
  var mainnet_default = {
9045
9045
  /**
9046
- * Root Datasource
9046
+ * ENSRoot Datasource
9047
9047
  *
9048
9048
  * Addresses and Start Blocks from ENS Mainnet Subgraph Manifest
9049
9049
  * https://ipfs.io/ipfs/Qmd94vseLpkUrSFvJ3GuPubJSyHz8ornhNrwEAt6pjcbex
@@ -9238,7 +9238,7 @@ var mainnet_default = {
9238
9238
  import { baseSepolia, lineaSepolia, sepolia } from "viem/chains";
9239
9239
  var sepolia_default = {
9240
9240
  /**
9241
- * Root Datasource
9241
+ * ENSRoot Datasource
9242
9242
  *
9243
9243
  * Addresses and Start Blocks from ENS Sepolia Subgraph Manifest
9244
9244
  * https://ipfs.io/ipfs/QmdDtoN9QCRsBUsyoiiUUMQPPmPp5jimUQe81828UyWLtg
@@ -9389,20 +9389,20 @@ var sepolia_default = {
9389
9389
  };
9390
9390
 
9391
9391
  // src/index.ts
9392
- var ENSNamespaceToDatasourceMap = {
9392
+ var ENSNamespacesById = {
9393
9393
  mainnet: mainnet_default,
9394
9394
  sepolia: sepolia_default,
9395
9395
  holesky: holesky_default,
9396
9396
  "ens-test-env": ens_test_env_default
9397
9397
  };
9398
- var getDatasourceMap = (namespace) => ENSNamespaceToDatasourceMap[namespace];
9399
- var getDatasource = (namespace, datasourceName) => getDatasourceMap(namespace)[datasourceName];
9400
- var getENSRootChainId = (namespace) => getDatasource(namespace, DatasourceNames.ENSRoot).chain.id;
9398
+ var getENSNamespace = (namespaceId) => ENSNamespacesById[namespaceId];
9399
+ var getDatasource = (namespaceId, datasourceName) => getENSNamespace(namespaceId)[datasourceName];
9400
+ var getENSRootChainId = (namespaceId) => getDatasource(namespaceId, DatasourceNames.ENSRoot).chain.id;
9401
9401
  export {
9402
9402
  DatasourceNames,
9403
- ENSNamespaces,
9403
+ ENSNamespaceIds,
9404
9404
  getDatasource,
9405
- getDatasourceMap,
9405
+ getENSNamespace,
9406
9406
  getENSRootChainId
9407
9407
  };
9408
9408
  //# sourceMappingURL=index.js.map