Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/ensnode-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./internal": {
"import": {
"types": "./dist/internal.d.ts",
"default": "./dist/internal.js"
},
"require": {
"types": "./dist/internal.d.cts",
"default": "./dist/internal.cjs"
}
}
},
"main": "./dist/index.cjs",
Expand Down
56 changes: 46 additions & 10 deletions packages/ensnode-sdk/src/omnigraph-api/example-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,38 @@ const ENS_TEST_ENV_V2_ETH_REGISTRAR = maybeGetDatasourceContract(
const VITALIK_ADDRESS = toNormalizedAddress("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");

// owns sfmonicdeb*.eth (mix of v1 + v2) on sepolia-v2 and holds v2 ETHRegistry permissions
const SEPOLIA_V2_USER_ADDRESS = toNormalizedAddress("0x2f8e8b1126e75fde0b7f731e7cb5847eba2d2574");
const _SEPOLIA_V2_USER_ADDRESS = toNormalizedAddress("0x2f8e8b1126e75fde0b7f731e7cb5847eba2d2574");

const SEPOLIA_V2_ADDRESS_WITH_LOT_OF_NAMES = toNormalizedAddress(
"0x205d2686da3bf33f64c17f21462c51b5ead462cf",
);

const DEVNET_NAME_WITH_OWNED_RESOLVER = asInterpretedName("example.eth");

const SEPOLIA_V2_NAME_WITH_OWNED_RESOLVER = asInterpretedName("sfmonicdebmig.eth");
const SEPOLIA_V2_NAME_WITH_OWNED_RESOLVER = asInterpretedName("demomigration.eth");

const SEPOLIA_V2_TEST_NAME = asInterpretedName("test-name.eth");

export const GRAPHQL_API_EXAMPLE_QUERIES: Array<{
export type GraphqlApiExampleQuery = {
id: string;
query: string;
variables: NamespaceSpecificValue<Record<string, unknown>>;
}> = [
};

export function getGraphqlApiExampleQueryById(id: string): GraphqlApiExampleQuery {
const found = graphqlApiExampleQueryById.get(id);
if (!found) {
throw new Error(`Unknown GraphQL API example query id: ${id}`);
}
return found;
}

export const GRAPHQL_API_EXAMPLE_QUERIES: GraphqlApiExampleQuery[] = [
////////////////
// Hello World
////////////////
{
id: "hello-world",
query: `#
# Welcome to this interactive playground for
# ENSNode's GraphQL API!
Expand All @@ -65,6 +83,7 @@ query HelloWorld {
// Find Domains
/////////////////
{
id: "find-domains",
query: `
query FindDomains(
$name: String!
Expand All @@ -90,14 +109,15 @@ query FindDomains(
variables: {
default: { name: "vitalik", order: { by: "NAME", dir: "DESC" } },
[ENSNamespaceIds.EnsTestEnv]: { name: "c", order: { by: "NAME", dir: "DESC" } },
[ENSNamespaceIds.SepoliaV2]: { name: "sfmonic", order: { by: "NAME", dir: "DESC" } },
[ENSNamespaceIds.SepoliaV2]: { name: "test-na", order: { by: "NAME", dir: "DESC" } },
},
},

///////////////////
// Domain By Name
///////////////////
{
id: "domain-by-name",
query: `
query DomainByName($name: InterpretedName!) {
domain(by: {name: $name}) {
Expand All @@ -120,14 +140,15 @@ query DomainByName($name: InterpretedName!) {
}`,
variables: {
default: { name: "eth" },
[ENSNamespaceIds.SepoliaV2]: { name: "sfmonicdebmig.eth" },
[ENSNamespaceIds.SepoliaV2]: { name: SEPOLIA_V2_TEST_NAME },
},
},

//////////////////////
// Domain Subdomains
//////////////////////
{
id: "domain-subdomains",
query: `
query DomainSubdomains($name: InterpretedName!) {
domain(by: {name: $name}) {
Expand All @@ -148,6 +169,7 @@ query DomainSubdomains($name: InterpretedName!) {
// Domain Events
/////////////////
{
id: "domain-events",
query: `
query DomainEvents($name: InterpretedName!) {
domain(by: {name: $name}) {
Expand Down Expand Up @@ -176,6 +198,7 @@ query DomainEvents($name: InterpretedName!) {
// Account Domains
////////////////////
{
id: "domains-by-address",
query: `
query AccountDomains(
$address: Address!
Expand All @@ -194,14 +217,15 @@ query AccountDomains(
variables: {
default: { address: VITALIK_ADDRESS },
[ENSNamespaceIds.EnsTestEnv]: { address: accounts.owner.address },
[ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_USER_ADDRESS },
[ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ADDRESS_WITH_LOT_OF_NAMES },
},
},

////////////////////
// Account Events
////////////////////
{
id: "account-events",
query: `
query AccountEvents(
$address: Address!
Expand All @@ -213,14 +237,15 @@ query AccountEvents(
variables: {
default: { address: VITALIK_ADDRESS },
[ENSNamespaceIds.EnsTestEnv]: { address: accounts.deployer.address },
[ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_USER_ADDRESS },
[ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ADDRESS_WITH_LOT_OF_NAMES },
},
},

/////////////////////
// Registry Domains
/////////////////////
{
id: "registry-domains",
query: `
query RegistryDomains(
$registry: AccountIdInput!
Expand All @@ -247,6 +272,7 @@ query RegistryDomains(
// Permissions By Contract
////////////////////////////
{
id: "permissions-by-contract",
query: `
query PermissionsByContract(
$contract: AccountIdInput!
Expand Down Expand Up @@ -274,6 +300,7 @@ query PermissionsByContract(
variables: {
// TODO: same as above
default: { contract: ENS_TEST_ENV_V2_ETH_REGISTRAR },
// TODO: example response is empty for this address on Sepolia V2
[ENSNamespaceIds.SepoliaV2]: { contract: SEPOLIA_V2_V2_ETH_REGISTRAR },
},
},
Expand All @@ -282,6 +309,7 @@ query PermissionsByContract(
// Permissions By User
////////////////////////
{
id: "permissions-by-user",
query: `
query PermissionsByUser($address: Address!) {
account(by: { address: $address }) {
Expand All @@ -297,14 +325,16 @@ query PermissionsByUser($address: Address!) {
}`,
variables: {
default: { address: accounts.deployer.address },
[ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_USER_ADDRESS },
// TODO: example response is empty for this address on Sepolia V2
[ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ADDRESS_WITH_LOT_OF_NAMES },
},
},

//////////////////////////////////
// Account Resolver Permissions
//////////////////////////////////
{
id: "account-resolver-permissions",
query: `
query AccountResolverPermissions($address: Address!) {
account(by: { address: $address }) {
Expand All @@ -323,14 +353,15 @@ query AccountResolverPermissions($address: Address!) {
}`,
variables: {
default: { address: accounts.deployer.address },
[ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_USER_ADDRESS },
[ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ADDRESS_WITH_LOT_OF_NAMES },
},
},

//////////////////////////////
// Domain's Assigned Resolver
//////////////////////////////
{
id: "domain-resolver",
query: `
query DomainResolver($name: InterpretedName!) {
domain(by: { name: $name }) {
Expand All @@ -352,6 +383,7 @@ query DomainResolver($name: InterpretedName!) {
// Namegraph
//////////////
{
id: "namegraph",
query: `
query Namegraph {
root {
Expand Down Expand Up @@ -384,3 +416,7 @@ query Namegraph {
variables: { default: {} },
},
];

const graphqlApiExampleQueryById = new Map(
GRAPHQL_API_EXAMPLE_QUERIES.map((entry) => [entry.id, entry]),
);
3 changes: 2 additions & 1 deletion packages/ensnode-sdk/src/shared/datasource-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
type ENSNamespaceId,
maybeGetDatasource,
} from "@ensnode/datasources";
import { accountIdEqual } from "@ensnode/ensnode-sdk";

import { accountIdEqual } from "./account-id";

/**
* Gets the AccountId for the contract in the specified namespace, datasource, and
Expand Down
2 changes: 1 addition & 1 deletion packages/ensnode-sdk/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["src/index.ts"],
entry: ["src/index.ts", "src/internal.ts"],
platform: "neutral",
format: ["esm", "cjs"],
target: "es2022",
Expand Down
Loading