UNPKG

@ensnode/ensnode-schema

Version:
1,432 lines (1,427 loc) 48.4 kB
// src/schemas/protocol-acceleration.schema.ts import { onchainTable, primaryKey, relations } from "ponder"; var reverseNameRecord = onchainTable( "reverse_name_records", (t) => ({ // keyed by (address, coinType) address: t.hex().notNull(), coinType: t.bigint().notNull(), /** * Represents the ENSIP-19 Reverse Name Record for a given (address, coinType). * * The value of this field is guaranteed to be a non-empty-string normalized ENS name (see * `interpretNameRecordValue` for additional context and specific guarantees). Unnormalized * names and empty string values are interpreted as a deletion of the associated Reverse Name * Record entity (represented in the schema as the _absence_ of a relevant Reverse Name Record * entity). */ value: t.text().notNull() }), (t) => ({ pk: primaryKey({ columns: [t.address, t.coinType] }) }) ); var nodeResolverRelation = onchainTable( "node_resolver_relations", (t) => ({ // keyed by (chainId, registry, node) chainId: t.integer().notNull(), registry: t.hex().notNull(), node: t.hex().notNull(), /** * The Address of the Resolver contract this `node` has set (via Registry#NewResolver) within * the Registry on `chainId`. */ resolver: t.hex().notNull() }), (t) => ({ pk: primaryKey({ columns: [t.chainId, t.registry, t.node] }) }) ); var resolverRecords = onchainTable( "resolver_records", (t) => ({ // keyed by (chainId, resolver, node) chainId: t.integer().notNull(), resolver: t.hex().notNull(), node: t.hex().notNull(), /** * Represents the value of the reverse-resolution (ENSIP-3) name() record, used for Reverse Resolution. * * The emitted record values are interpreted according to `interpretNameRecordValue` — unnormalized * names and empty string values are interpreted as a deletion of the associated record (represented * here as `null`). * * If set, the value of this field is guaranteed to be a non-empty-string normalized ENS name * (see `interpretNameRecordValue` for additional context and specific guarantees). */ name: t.text() }), (t) => ({ pk: primaryKey({ columns: [t.chainId, t.resolver, t.node] }) }) ); var resolverRecords_relations = relations(resolverRecords, ({ many }) => ({ // resolverRecord has many address records addressRecords: many(resolverAddressRecord), // resolverRecord has many text records textRecords: many(resolverTextRecord) })); var resolverAddressRecord = onchainTable( "resolver_address_records", (t) => ({ // keyed by ((chainId, resolver, node), coinType) chainId: t.integer().notNull(), resolver: t.hex().notNull(), node: t.hex().notNull(), coinType: t.bigint().notNull(), /** * Represents the value of the Addresss Record specified by ((chainId, resolver, node), coinType). * * The value of this field is interpreted by `interpretAddressRecordValue` — see its implementation * for additional context and specific guarantees. */ address: t.text().notNull() }), (t) => ({ pk: primaryKey({ columns: [t.chainId, t.resolver, t.node, t.coinType] }) }) ); var resolverAddressRecordRelations = relations(resolverAddressRecord, ({ one }) => ({ // belongs to resolverRecord resolver: one(resolverRecords, { fields: [ resolverAddressRecord.chainId, resolverAddressRecord.resolver, resolverAddressRecord.node ], references: [resolverRecords.chainId, resolverRecords.resolver, resolverRecords.node] }) })); var resolverTextRecord = onchainTable( "resolver_trecords", (t) => ({ // keyed by ((chainId, resolver, node), key) chainId: t.integer().notNull(), resolver: t.hex().notNull(), node: t.hex().notNull(), key: t.text().notNull(), /** * Represents the value of the Text Record specified by ((chainId, resolver, node), key). * * The value of this field is interpreted by `interpretTextRecordValue` — see its implementation * for additional context and specific guarantees. */ value: t.text().notNull() }), (t) => ({ pk: primaryKey({ columns: [t.chainId, t.resolver, t.node, t.key] }) }) ); var resolverTextRecordRelations = relations(resolverTextRecord, ({ one }) => ({ // belongs to resolverRecord resolver: one(resolverRecords, { fields: [resolverTextRecord.chainId, resolverTextRecord.resolver, resolverTextRecord.node], references: [resolverRecords.chainId, resolverRecords.resolver, resolverRecords.node] }) })); var migratedNode = onchainTable("migrated_nodes", (t) => ({ node: t.hex().primaryKey() })); // src/schemas/registrars.schema.ts import { index, onchainEnum, onchainTable as onchainTable2, relations as relations2, uniqueIndex } from "ponder"; var subregistries = onchainTable2( "subregistries", (t) => ({ /** * Subregistry ID * * Identifies the chainId and address of the smart contract associated * with the subregistry. * * Guaranteed to be a fully lowercase string formatted according to * the CAIP-10 standard. * * @see https://chainagnostic.org/CAIPs/caip-10 */ subregistryId: t.text().primaryKey(), /** * The node (namehash) of the name the subregistry manages subnames of. * Example subregistry managed names: * - `eth` * - `base.eth` * - `linea.eth` * * Guaranteed to be a fully lowercase hex string representation of 32-bytes. */ node: t.hex().notNull() }), (t) => ({ uniqueNode: uniqueIndex().on(t.node) }) ); var registrationLifecycles = onchainTable2( "registration_lifecycles", (t) => ({ /** * The node (namehash) of the FQDN of the domain the registration lifecycle * is associated with. * * Guaranteed to be a subname of the node (namehash) of the subregistry * identified by `subregistryId`. * * Guaranteed to be a fully lowercase hex string representation of 32-bytes. */ node: t.hex().primaryKey(), /** * Subregistry ID * * Identifies the chainId and address of the subregistry smart contract * that manages the registration lifecycle. * * Guaranteed to be a fully lowercase string formatted according to * the CAIP-10 standard. * * @see https://chainagnostic.org/CAIPs/caip-10 */ subregistryId: t.text().notNull(), /** * Expires at * * Unix timestamp when the Registration Lifecycle is scheduled to expire. */ expiresAt: t.bigint().notNull() }), (t) => ({ bySubregistry: index().on(t.subregistryId) }) ); var registrarActionType = onchainEnum("registrar_action_type", [ "registration", "renewal" ]); var registrarActions = onchainTable2( "registrar_actions", (t) => ({ /** * "Logical registrar action" ID * * The `id` value is a deterministic and globally unique identifier for * the "logical registrar action". * * The `id` value represents the *initial* onchain event associated with * the "logical registrar action", but the full state of * the "logical registrar action" is an aggregate across each of * the onchain events referenced in the `eventIds` field. * * Guaranteed to be the very first element in `eventIds` array. */ id: t.text().primaryKey(), /** * The type of the "logical registrar action". */ type: registrarActionType().notNull(), /** * Subregistry ID * * The ID of the subregistry the "logical registrar action" was taken on. * * Identifies the chainId and address of the associated subregistry smart * contract. * * Guaranteed to be a fully lowercase string formatted according to * the CAIP-10 standard. * * @see https://chainagnostic.org/CAIPs/caip-10 */ subregistryId: t.text().notNull(), /** * The node (namehash) of the FQDN of the domain associated with * the "logical registrar action". * * Guaranteed to be a fully lowercase hex string representation of 32-bytes. */ node: t.hex().notNull(), /** * Incremental Duration * * If `type` is "registration": * - Represents the duration between `blockTimestamp` and * the initial `expiresAt` value that the associated * "registration lifecycle" will be initialized with. * If `type` is "renewal": * - Represents the incremental increase in duration made to * the `expiresAt` value in the associated "registration lifecycle". * * A "registration lifecycle" may be extended via renewal even after it * expires if it is still within its grace period. * * Consider the following scenario: * * The "registration lifecycle" of a direct subname of .eth is scheduled to * expire on Jan 1, midnight UTC. It is currently 30 days after this * expiration time. Therefore, there are currently another 60 days of grace * period remaining for this name. Anyone can still make a renewal to * extend the "registration lifecycle" of this name. * * Given this scenario, consider the following examples: * * 1. If a renewal is made with 10 days incremental duration, * the "registration lifecycle" for this name will remain in * an "expired" state, but it will now have another 70 days of * grace period remaining. * * 2. If a renewal is made with 50 days incremental duration, * the "registration lifecycle" for this name will no longer be * "expired" and will become "active", but the "registration lifecycle" * will now be scheduled to expire again in 20 days. * * After the "registration lifecycle" for a name becomes expired by more * than its grace period, it can no longer be renewed by anyone and is * considered "released". The name must first be registered again, starting * a new "registration lifecycle" of * active / expired / grace period / released. * * May be 0. * * Guaranteed to be a non-negative bigint value. */ incrementalDuration: t.bigint().notNull(), /** * Base cost * * Base cost (before any `premium`) of Ether measured in units of Wei * paid to execute the "logical registrar action". * * May be 0. * * Guaranteed to be: * 1) null if and only if `total` is null. * 2) Otherwise, a non-negative bigint value. */ baseCost: t.bigint(), /** * Premium * * "premium" cost (in excesses of the `baseCost`) of Ether measured in * units of Wei paid to execute the "logical registrar action". * * May be 0. * * Guaranteed to be: * 1) null if and only if `total` is null. * 2) Otherwise, zero when `type` is `renewal`. * 3) Otherwise, a non-negative bigint value. */ premium: t.bigint(), /** * Total * * Total cost of Ether measured in units of Wei paid to execute * the "logical registrar action". * * May be 0. * * Guaranteed to be: * 1) null if and only if both `baseCost` and `premium` are null. * 2) Otherwise, a non-negative bigint value, equal to the sum of * `baseCost` and `premium`. */ total: t.bigint(), /** * Registrant * * Identifies the address that initiated the "logical registrar action" and * is paying the `total` cost (if applicable). * * It may not be the owner of the name: * 1. When a name is registered, the initial owner of the name may be * distinct from the registrant. * 2. There are no restrictions on who may renew a name. * Therefore the owner of the name may be distinct from the registrant. * * * The "chainId" of this address is the same as is referenced in `subregistryId`. * * Guaranteed to be a fully lowercase address */ registrant: t.hex().notNull(), /** * Encoded Referrer * * Represents the "raw" 32-byte "referrer" value emitted onchain in * association with the registrar action. * * Guaranteed to be: * 1) null if the emitted `eventIds` contain no information about a referrer. * 2) Otherwise, a fully lowercase hex string representation of 32-bytes. */ encodedReferrer: t.hex(), /** * Decoded referrer * * Decoded referrer according to the subjective interpretation of * `encodedReferrer` defined for ENS Holiday Awards. * * Identifies the interpreted address of the referrer. * The "chainId" of this address is the same as is referenced in * `subregistryId`. * * Guaranteed to be: * 1) null if `encodedReferrer` is null. * 2) Otherwise, a fully lowercase address. * 3) May be the "zero address" to represent that an `encodedReferrer` is * defined but that it is interpreted as no referrer. */ decodedReferrer: t.hex(), /** * Number of the block that includes the "logical registrar action". * * The "chainId" of this block is the same as is referenced in * `subregistryId`. * * Guaranteed to be a non-negative bigint value. */ blockNumber: t.bigint().notNull(), /** * Unix timestamp of the block referenced by `blockNumber` that includes * the "logical registrar action". */ timestamp: t.bigint().notNull(), /** * Transaction hash of the transaction associated with * the "logical registrar action". * * The "chainId" of this transaction is the same as is referenced in * `subregistryId`. * * Note that a single transaction may be associated with any number of * "logical registrar actions". * * Guaranteed to be a fully lowercase hex string representation of 32-bytes. */ transactionHash: t.hex().notNull(), /** * Event IDs * * Array of the eventIds that have contributed to the state of * the "logical registrar action" record. * * Each eventId is a deterministic and globally unique onchain event * identifier. * * Guarantees: * - Each eventId is of events that occurred within the block * referenced by `blockNumber`. * - At least 1 eventId. * - Ordered chronologically (ascending) by logIndex within `blockNumber`. * - The first element in the array is equal to the `id` of * the overall "logical registrar action" record. * * The following ideas are not generalized for ENS overall but happen to * be a characteristic of the scope of our current indexing logic: * 1. These id's always reference events emitted by * a related "BaseRegistrar" contract. * 2. These id's optionally reference events emitted by * a related "Registrar Controller" contract. This is because our * current indexing logic doesn't guarantee to index * all "Registrar Controller" contracts. */ eventIds: t.text().array().notNull() }), (t) => ({ byDecodedReferrer: index().on(t.decodedReferrer), byTimestamp: index().on(t.timestamp) }) ); var internal_registrarActionMetadata = onchainTable2( "_ensindexer_registrar_action_metadata", (t) => ({ /** * Logical Event Key * * A fully lowercase string formatted as: * `{chainId}:{subregistryAddress}:{node}:{transactionHash}` */ logicalEventKey: t.text().primaryKey(), /** * Logical Event ID * * A string holding the `id` value of the existing "logical registrar action" * record that is currently being built as an aggregation of onchain events. * * May be used by subsequent event handlers to identify which * "logical registrar action" to aggregate additional indexed state into. */ logicalEventId: t.text().notNull() }) ); var subregistryRelations = relations2(subregistries, ({ many }) => ({ registrationLifecycle: many(registrationLifecycles) })); var registrationLifecycleRelations = relations2( registrationLifecycles, ({ one, many }) => ({ subregistry: one(subregistries, { fields: [registrationLifecycles.subregistryId], references: [subregistries.subregistryId] }), registrarAction: many(registrarActions) }) ); var registrarActionRelations = relations2(registrarActions, ({ one }) => ({ registrationLifecycle: one(registrationLifecycles, { fields: [registrarActions.node], references: [registrationLifecycles.node] }) })); // src/schemas/subgraph.schema.ts import { index as index2, onchainTable as onchainTable3, relations as relations3 } from "ponder"; // src/lib/collate.ts function monkeypatchCollate(col, collation) { col.getSQLType = function() { return `${Object.getPrototypeOf(this).getSQLType.call(this)} COLLATE ${collation}`; }; return col; } // src/schemas/subgraph.schema.ts var subgraph_domain = onchainTable3( "subgraph_domains", (t) => ({ // The namehash of the name id: t.hex().primaryKey(), /** * The ENS Name that this Domain represents. * * If {@link ENSIndexerConfig#isSubgraphCompatible}, this value is guaranteed to be either: * a) null (in the case of the root node), or * b) a Subgraph Interpreted Name. * * @see https://ensnode.io/docs/reference/terminology#subgraph-indexability--labelname-interpretation * * Otherwise, this value is guaranteed to be an Interpreted Name, which is either: * a) a normalized Name, or * b) a Name entirely consisting of Interpreted Labels. * * Note that the type of the column will remain string | null, for legacy subgraph compatibility, * but in practice will never be null. The Root node's name will be '' (empty string). * * @see https://ensnode.io/docs/reference/terminology#interpreted-name */ name: t.text(), /** * The Label associated with the Domain. * * If {@link ENSIndexerConfig#isSubgraphCompatible}, this value is guaranteed to be either: * a) null, in the case of the root Node or a name whose childmost label is subgraph-unindexable, or * b) a subgraph-indexable Subgraph Interpreted Label (i.e. a Literal Label of undefined normalization). * * @see https://ensnode.io/docs/reference/terminology#subgraph-indexability--labelname-interpretation * * Otherwise, this value is guaranteed to be an Interpreted Label which is either: * a) null, exclusively in the case of the root Node, * b) a normalized Label, or * c) an Encoded LabelHash, which encodes either * i. in the case of an Unknown Label, the LabelHash emitted onchain, or * ii. in the case of an Unnormalized Label, the LabelHash of the Literal Label value found onchain. * * @see https://ensnode.io/docs/reference/terminology#interpreted-label */ labelName: t.text(), // keccak256(labelName) labelhash: t.hex(), // The namehash (id) of the parent name parentId: t.hex(), // The number of subdomains subdomainCount: t.integer().notNull().default(0), // Address logged from current resolver, if any resolvedAddressId: t.hex(), // The resolver that controls the domain's settings resolverId: t.text(), // The time-to-live (TTL) value of the domain's records ttl: t.bigint(), // Indicates whether the domain has been migrated to a new registrar isMigrated: t.boolean().notNull().default(false), // The time when the domain was created createdAt: t.bigint().notNull(), // The account that owns the domain ownerId: t.hex().notNull(), // The account that owns the ERC721 NFT for the domain registrantId: t.hex(), // The account that owns the wrapped domain wrappedOwnerId: t.hex(), // The expiry date for the domain, from either the registration, or the wrapped domain if PCC is burned expiryDate: t.bigint() }), (t) => ({ byLabelhash: index2().on(t.labelhash), byParentId: index2().on(t.parentId), byOwnerId: index2().on(t.ownerId), byRegistrantId: index2().on(t.registrantId), byWrappedOwnerId: index2().on(t.wrappedOwnerId) }) ); monkeypatchCollate(subgraph_domain.name, '"C"'); monkeypatchCollate(subgraph_domain.labelName, '"C"'); var subgraph_domainRelations = relations3(subgraph_domain, ({ one, many }) => ({ resolvedAddress: one(subgraph_account, { fields: [subgraph_domain.resolvedAddressId], references: [subgraph_account.id] }), owner: one(subgraph_account, { fields: [subgraph_domain.ownerId], references: [subgraph_account.id] }), parent: one(subgraph_domain, { fields: [subgraph_domain.parentId], references: [subgraph_domain.id] }), resolver: one(subgraph_resolver, { fields: [subgraph_domain.resolverId], references: [subgraph_resolver.id] }), subdomains: many(subgraph_domain, { relationName: "parent" }), registrant: one(subgraph_account, { fields: [subgraph_domain.registrantId], references: [subgraph_account.id] }), wrappedOwner: one(subgraph_account, { fields: [subgraph_domain.wrappedOwnerId], references: [subgraph_account.id] }), wrappedDomain: one(subgraph_wrappedDomain, { fields: [subgraph_domain.id], references: [subgraph_wrappedDomain.domainId] }), registration: one(subgraph_registration, { fields: [subgraph_domain.id], references: [subgraph_registration.domainId] }), // event relations transfers: many(subgraph_transfer), newOwners: many(subgraph_newOwner), newResolvers: many(subgraph_newResolver), newTTLs: many(subgraph_newTTL), wrappedTransfers: many(subgraph_wrappedTransfer), nameWrappeds: many(subgraph_nameWrapped), nameUnwrappeds: many(subgraph_nameUnwrapped), fusesSets: many(subgraph_fusesSet), expiryExtendeds: many(subgraph_expiryExtended) })); var subgraph_account = onchainTable3("subgraph_accounts", (t) => ({ id: t.hex().primaryKey() })); var subgraph_accountRelations = relations3(subgraph_account, ({ many }) => ({ domains: many(subgraph_domain), wrappedDomains: many(subgraph_wrappedDomain), registrations: many(subgraph_registration) })); var subgraph_resolver = onchainTable3( "subgraph_resolvers", (t) => ({ // The unique identifier for this resolver, which is a concatenation of the domain namehash and the resolver address id: t.text().primaryKey(), // The domain that this resolver is associated with domainId: t.hex().notNull(), // The address of the resolver contract address: t.hex().notNull().$type(), // The current value of the 'addr' record for this resolver, as determined by the associated events addrId: t.hex(), // The content hash for this resolver, in binary format contentHash: t.text(), // The set of observed text record keys for this resolver // NOTE: we avoid .notNull.default([]) to match subgraph behavior texts: t.text().array(), // The set of observed SLIP-44 coin types for this resolver // NOTE: we avoid .notNull.default([]) to match subgraph behavior coinTypes: t.bigint().array() }), (t) => ({ byDomainId: index2().on(t.domainId) }) ); var subgraph_resolverRelations = relations3(subgraph_resolver, ({ one, many }) => ({ addr: one(subgraph_account, { fields: [subgraph_resolver.addrId], references: [subgraph_account.id] }), domain: one(subgraph_domain, { fields: [subgraph_resolver.domainId], references: [subgraph_domain.id] }), // event relations addrChangeds: many(subgraph_addrChanged), multicoinAddrChangeds: many(subgraph_multicoinAddrChanged), nameChangeds: many(subgraph_nameChanged), abiChangeds: many(subgraph_abiChanged), pubkeyChangeds: many(subgraph_pubkeyChanged), textChangeds: many(subgraph_textChanged), contenthashChangeds: many(subgraph_contenthashChanged), interfaceChangeds: many(subgraph_interfaceChanged), authorisationChangeds: many(subgraph_authorisationChanged), versionChangeds: many(subgraph_versionChanged) })); var subgraph_registration = onchainTable3( "subgraph_registrations", (t) => ({ // The unique identifier of the registration id: t.hex().primaryKey(), // The domain name associated with the registration domainId: t.hex().notNull(), // The registration date of the domain registrationDate: t.bigint().notNull(), // The expiry date of the domain expiryDate: t.bigint().notNull(), // The cost associated with the domain registration cost: t.bigint(), // The account that registered the domain registrantId: t.hex().notNull(), /** * The Label associated with the domain registration. * * If {@link ENSIndexerConfig#isSubgraphCompatible}, this value is guaranteed to be either: * a) null, in the case of the root Node or a Domain whose label is subgraph-unindexable, or * b) a subgraph-indexable Subgraph Interpreted Label (i.e. a Literal Label of undefined normalization). * * @see https://ensnode.io/docs/reference/terminology#subgraph-indexability--labelname-interpretation * * Otherwise, this value is guaranteed to be an Interpreted Label which is either: * a) a normalized Label, or * b) in the case of an Unnormalized Label, an Encoded LabelHash of the Literal Label value found onchain. * * Note that the type of the column will remain string | null, for legacy subgraph compatibility. * In practice however, because there is no Registration entity for the root Node (the only Node * with a null labelName) this field will never be null. * * @see https://ensnode.io/docs/reference/terminology#interpreted-label */ labelName: t.text() }), (t) => ({ byDomainId: index2().on(t.domainId), byRegistrationDate: index2().on(t.registrationDate) }) ); var subgraph_registrationRelations = relations3(subgraph_registration, ({ one, many }) => ({ domain: one(subgraph_domain, { fields: [subgraph_registration.domainId], references: [subgraph_domain.id] }), registrant: one(subgraph_account, { fields: [subgraph_registration.registrantId], references: [subgraph_account.id] }), // event relations nameRegistereds: many(subgraph_nameRegistered), nameReneweds: many(subgraph_nameRenewed), nameTransferreds: many(subgraph_nameTransferred) })); var subgraph_wrappedDomain = onchainTable3( "subgraph_wrapped_domains", (t) => ({ // The unique identifier for each instance of the WrappedDomain entity id: t.hex().primaryKey(), // The domain that is wrapped by this WrappedDomain domainId: t.hex().notNull(), // The expiry date of the wrapped domain expiryDate: t.bigint().notNull(), // The number of fuses remaining on the wrapped domain fuses: t.integer().notNull(), // The account that owns this WrappedDomain ownerId: t.hex().notNull(), /** * The Name that this WrappedDomain represents. Names are emitted by the NameWrapper contract as * DNS-Encoded Names which may be malformed, which will result in this field being `null`. * * If {@link ENSIndexerConfig#isSubgraphCompatible}, this value is guaranteed to be either: * a) null (in the case of a DNS-Encoded Name that is malformed or contains subgraph-unindexable labels), or * b) a subgraph-indexable Subgraph Interpreted Label (i.e. a Literal Label of undefined normalization). * * @see https://ensnode.io/docs/reference/terminology#subgraph-indexability--labelname-interpretation * * Otherwise, this value is guaranteed to be either: * a) null (in the case of a malformed DNS-Encoded Name), * b) an Interpreted Name. * * @see https://ensnode.io/docs/reference/terminology#interpreted-name */ name: t.text() }), (t) => ({ byDomainId: index2().on(t.domainId) }) ); var subgraph_wrappedDomainRelations = relations3(subgraph_wrappedDomain, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_wrappedDomain.domainId], references: [subgraph_domain.id] }), owner: one(subgraph_account, { fields: [subgraph_wrappedDomain.ownerId], references: [subgraph_account.id] }) })); var sharedEventColumns = (t) => ({ id: t.text().primaryKey(), blockNumber: t.integer().notNull(), transactionID: t.hex().notNull() }); var domainEvent = (t) => ({ ...sharedEventColumns(t), domainId: t.hex().notNull() }); var domainEventIndex = (t) => ({ // primary reverse lookup idx: index2().on(t.domainId), // sorting index idx_compound: index2().on(t.domainId, t.id) }); var subgraph_transfer = onchainTable3( "subgraph_transfers", (t) => ({ ...domainEvent(t), ownerId: t.hex().notNull() }), domainEventIndex ); var subgraph_newOwner = onchainTable3( "subgraph_new_owners", (t) => ({ ...domainEvent(t), ownerId: t.hex().notNull(), parentDomainId: t.hex().notNull() }), domainEventIndex ); var subgraph_newResolver = onchainTable3( "subgraph_new_resolvers", (t) => ({ ...domainEvent(t), resolverId: t.text().notNull() }), domainEventIndex ); var subgraph_newTTL = onchainTable3( "subgraph_new_ttls", (t) => ({ ...domainEvent(t), ttl: t.bigint().notNull() }), domainEventIndex ); var subgraph_wrappedTransfer = onchainTable3( "subgraph_wrapped_transfers", (t) => ({ ...domainEvent(t), ownerId: t.hex().notNull() }), domainEventIndex ); var subgraph_nameWrapped = onchainTable3( "subgraph_name_wrapped", (t) => ({ ...domainEvent(t), name: t.text(), fuses: t.integer().notNull(), ownerId: t.hex().notNull(), expiryDate: t.bigint().notNull() }), domainEventIndex ); var subgraph_nameUnwrapped = onchainTable3( "subgraph_name_unwrapped", (t) => ({ ...domainEvent(t), ownerId: t.hex().notNull() }), domainEventIndex ); var subgraph_fusesSet = onchainTable3( "subgraph_fuses_set", (t) => ({ ...domainEvent(t), fuses: t.integer().notNull() }), domainEventIndex ); var subgraph_expiryExtended = onchainTable3( "subgraph_expiry_extended", (t) => ({ ...domainEvent(t), expiryDate: t.bigint().notNull() }), domainEventIndex ); var registrationEvent = (t) => ({ ...sharedEventColumns(t), registrationId: t.hex().notNull() }); var registrationEventIndex = (t) => ({ // primary reverse lookup idx: index2().on(t.registrationId), // sorting index idx_compound: index2().on(t.registrationId, t.id) }); var subgraph_nameRegistered = onchainTable3( "subgraph_name_registered", (t) => ({ ...registrationEvent(t), registrantId: t.hex().notNull(), expiryDate: t.bigint().notNull() }), registrationEventIndex ); var subgraph_nameRenewed = onchainTable3( "subgraph_name_renewed", (t) => ({ ...registrationEvent(t), expiryDate: t.bigint().notNull() }), registrationEventIndex ); var subgraph_nameTransferred = onchainTable3( "subgraph_name_transferred", (t) => ({ ...registrationEvent(t), newOwnerId: t.hex().notNull() }), registrationEventIndex ); var resolverEvent = (t) => ({ ...sharedEventColumns(t), resolverId: t.text().notNull() }); var resolverEventIndex = (t) => ({ // primary reverse lookup idx: index2().on(t.resolverId), // sorting index idx_compound: index2().on(t.resolverId, t.id) }); var subgraph_addrChanged = onchainTable3( "subgraph_addr_changed", (t) => ({ ...resolverEvent(t), addrId: t.hex().notNull() }), resolverEventIndex ); var subgraph_multicoinAddrChanged = onchainTable3( "subgraph_multicoin_addr_changed", (t) => ({ ...resolverEvent(t), coinType: t.bigint().notNull(), addr: t.hex().notNull() }), resolverEventIndex ); var subgraph_nameChanged = onchainTable3( "subgraph_name_changed", (t) => ({ ...resolverEvent(t), name: t.text().notNull() }), resolverEventIndex ); var subgraph_abiChanged = onchainTable3( "subgraph_abi_changed", (t) => ({ ...resolverEvent(t), contentType: t.bigint().notNull() }), resolverEventIndex ); var subgraph_pubkeyChanged = onchainTable3( "subgraph_pubkey_changed", (t) => ({ ...resolverEvent(t), x: t.hex().notNull(), y: t.hex().notNull() }), resolverEventIndex ); var subgraph_textChanged = onchainTable3( "subgraph_text_changed", (t) => ({ ...resolverEvent(t), key: t.text().notNull(), value: t.text() }), resolverEventIndex ); var subgraph_contenthashChanged = onchainTable3( "subgraph_contenthash_changed", (t) => ({ ...resolverEvent(t), hash: t.hex().notNull() }), resolverEventIndex ); var subgraph_interfaceChanged = onchainTable3( "subgraph_interface_changed", (t) => ({ ...resolverEvent(t), interfaceID: t.hex().notNull(), implementer: t.hex().notNull() }), resolverEventIndex ); var subgraph_authorisationChanged = onchainTable3( "subgraph_authorisation_changed", (t) => ({ ...resolverEvent(t), owner: t.hex().notNull(), target: t.hex().notNull(), isAuthorized: t.boolean().notNull() }), resolverEventIndex ); var subgraph_versionChanged = onchainTable3( "subgraph_version_changed", (t) => ({ ...resolverEvent(t), version: t.bigint().notNull() }), resolverEventIndex ); var subgraph_transferRelations = relations3(subgraph_transfer, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_transfer.domainId], references: [subgraph_domain.id] }), owner: one(subgraph_account, { fields: [subgraph_transfer.ownerId], references: [subgraph_account.id] }) })); var subgraph_newOwnerRelations = relations3(subgraph_newOwner, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_newOwner.domainId], references: [subgraph_domain.id] }), owner: one(subgraph_account, { fields: [subgraph_newOwner.ownerId], references: [subgraph_account.id] }), parentDomain: one(subgraph_domain, { fields: [subgraph_newOwner.parentDomainId], references: [subgraph_domain.id] }) })); var subgraph_newResolverRelations = relations3(subgraph_newResolver, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_newResolver.domainId], references: [subgraph_domain.id] }), resolver: one(subgraph_resolver, { fields: [subgraph_newResolver.resolverId], references: [subgraph_resolver.id] }) })); var subgraph_newTTLRelations = relations3(subgraph_newTTL, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_newTTL.domainId], references: [subgraph_domain.id] }) })); var subgraph_wrappedTransferRelations = relations3(subgraph_wrappedTransfer, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_wrappedTransfer.domainId], references: [subgraph_domain.id] }), owner: one(subgraph_account, { fields: [subgraph_wrappedTransfer.ownerId], references: [subgraph_account.id] }) })); var subgraph_nameWrappedRelations = relations3(subgraph_nameWrapped, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_nameWrapped.domainId], references: [subgraph_domain.id] }), owner: one(subgraph_account, { fields: [subgraph_nameWrapped.ownerId], references: [subgraph_account.id] }) })); var subgraph_nameUnwrappedRelations = relations3(subgraph_nameUnwrapped, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_nameUnwrapped.domainId], references: [subgraph_domain.id] }), owner: one(subgraph_account, { fields: [subgraph_nameUnwrapped.ownerId], references: [subgraph_account.id] }) })); var subgraph_fusesSetRelations = relations3(subgraph_fusesSet, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_fusesSet.domainId], references: [subgraph_domain.id] }) })); var subgraph_expiryExtendedRelations = relations3(subgraph_expiryExtended, ({ one }) => ({ domain: one(subgraph_domain, { fields: [subgraph_expiryExtended.domainId], references: [subgraph_domain.id] }) })); var subgraph_nameRegisteredRelations = relations3(subgraph_nameRegistered, ({ one }) => ({ registration: one(subgraph_registration, { fields: [subgraph_nameRegistered.registrationId], references: [subgraph_registration.id] }), registrant: one(subgraph_account, { fields: [subgraph_nameRegistered.registrantId], references: [subgraph_account.id] }) })); var subgraph_nameRenewedRelations = relations3(subgraph_nameRenewed, ({ one }) => ({ registration: one(subgraph_registration, { fields: [subgraph_nameRenewed.registrationId], references: [subgraph_registration.id] }) })); var subgraph_nameTransferredRelations = relations3(subgraph_nameTransferred, ({ one }) => ({ registration: one(subgraph_registration, { fields: [subgraph_nameTransferred.registrationId], references: [subgraph_registration.id] }), newOwner: one(subgraph_account, { fields: [subgraph_nameTransferred.newOwnerId], references: [subgraph_account.id] }) })); var subgraph_addrChangedRelations = relations3(subgraph_addrChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_addrChanged.resolverId], references: [subgraph_resolver.id] }), addr: one(subgraph_account, { fields: [subgraph_addrChanged.addrId], references: [subgraph_account.id] }) })); var subgraph_multicoinAddrChangedRelations = relations3( subgraph_multicoinAddrChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_multicoinAddrChanged.resolverId], references: [subgraph_resolver.id] }) }) ); var subgraph_nameChangedRelations = relations3(subgraph_nameChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_nameChanged.resolverId], references: [subgraph_resolver.id] }) })); var subgraph_abiChangedRelations = relations3(subgraph_abiChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_abiChanged.resolverId], references: [subgraph_resolver.id] }) })); var subgraph_pubkeyChangedRelations = relations3(subgraph_pubkeyChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_pubkeyChanged.resolverId], references: [subgraph_resolver.id] }) })); var subgraph_textChangedRelations = relations3(subgraph_textChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_textChanged.resolverId], references: [subgraph_resolver.id] }) })); var subgraph_contenthashChangedRelations = relations3( subgraph_contenthashChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_contenthashChanged.resolverId], references: [subgraph_resolver.id] }) }) ); var subgraph_interfaceChangedRelations = relations3( subgraph_interfaceChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_interfaceChanged.resolverId], references: [subgraph_resolver.id] }) }) ); var subgraph_authorisationChangedRelations = relations3( subgraph_authorisationChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_authorisationChanged.resolverId], references: [subgraph_resolver.id] }) }) ); var subgraph_versionChangedRelations = relations3(subgraph_versionChanged, ({ one }) => ({ resolver: one(subgraph_resolver, { fields: [subgraph_versionChanged.resolverId], references: [subgraph_resolver.id] }) })); // src/schemas/tokenscope.schema.ts import { index as index3, onchainTable as onchainTable4 } from "ponder"; var nameSales = onchainTable4( "name_sales", (t) => ({ /** * Unique and deterministic identifier of the onchain event associated with the sale. * * Composite key format: "{chainId}-{blockNumber}-{logIndex}" (e.g., "1-1234567-5") */ id: t.text().primaryKey(), /** * The chain where the sale occurred. */ chainId: t.integer().notNull(), /** * The block number on chainId where the sale occurred. */ blockNumber: t.bigint().notNull(), /** * The log index position of the sale event within blockNumber. */ logIndex: t.integer().notNull(), /** * The EVM transaction hash on chainId associated with the sale. */ transactionHash: t.hex().notNull(), /** * The Seaport order hash. */ orderHash: t.hex().notNull(), /** * The address of the contract on chainId that manages tokenId. */ contractAddress: t.hex().notNull(), /** * The tokenId managed by contractAddress that was sold. * * In a general context (outside of TokenScope) ERC1155 NFTs may have * multiple copies, however TokenScope guarantees that all indexed NFTs * never have an amount / balance > 1. */ tokenId: t.bigint().notNull(), /** * The CAIP-19 Asset Namespace of the token that was sold. Either `erc721` or `erc1155`. * * @see https://chainagnostic.org/CAIPs/caip-19 */ assetNamespace: t.text().notNull(), /** * The CAIP-19 Asset ID of token that was sold. This is a globally unique reference to the * specific asset in question. * * @see https://chainagnostic.org/CAIPs/caip-19 */ assetId: t.text().notNull(), /** * The namehash (Node) of the ENS domain that was sold. */ domainId: t.hex().notNull(), /** * The account that bought the token controlling ownership of domainId from * the seller for the amount of currency associated with the sale. */ buyer: t.hex().notNull(), /** * The account that sold the token controlling ownership of domainId to * buyer for the amount of currency associated with the sale. */ seller: t.hex().notNull(), /** * Currency of the payment (ETH, USDC or DAI) from buyer to seller in exchange for tokenId. */ currency: t.text().notNull(), /** * The amount of currency paid from buyer to seller in exchange for tokenId. * * Denominated in the smallest unit of currency. * * Amount interpretation depends on currency: * - ETH/WETH: Amount in wei (1 ETH = 10^18 wei) * - USDC: Amount in micro-units (1 USDC = 10^6 units) * - DAI: Amount in wei-equivalent (1 DAI = 10^18 units) */ amount: t.bigint().notNull(), /** * Unix timestamp of the block timestamp when the sale occurred. */ timestamp: t.bigint().notNull() }), (t) => ({ idx_domainId: index3().on(t.domainId), idx_assetId: index3().on(t.assetId), idx_buyer: index3().on(t.buyer), idx_seller: index3().on(t.seller), idx_timestamp: index3().on(t.timestamp) }) ); var nameTokens = onchainTable4( "name_tokens", (t) => ({ /** * The CAIP-19 Asset ID of the token. * * This is a globally unique reference to the token. * * @see https://chainagnostic.org/CAIPs/caip-19 */ id: t.text().primaryKey(), /** * The namehash (Node) of the ENS name associated with the token. * * Note: An ENS name may have more than one distinct token across time. It is * also possible for multiple distinct tokens for an ENS name to have * a mintStatus of `minted` at the same time. For example: * - When a direct subname of .eth is wrapped by the NameWrapper. This state * has one minted token for the name managed by the BaseRegistrar (this * token will be owned by the NameWrapper) and another minted token for * the name managed by the NameWrapper (owned by the effective owner of * the name). * - When a direct subname of .eth is wrapped by the NameWrapper and then * unwrapped. This state has one minted token (managed by the BaseRegistrar) * and another burned token (managed by the NameWrapper). */ domainId: t.hex().notNull(), /** * The chain that manages the token. */ chainId: t.integer().notNull(), /** * The address of the contract on chainId that manages the token. */ contractAddress: t.hex().notNull(), /** * The tokenId of the token managed by contractAddress. * * In a general context (outside of TokenScope) ERC1155 NFTs may have * multiple copies, however TokenScope guarantees that all indexed NFTs * never have an amount / balance > 1. */ tokenId: t.bigint().notNull(), /** * The CAIP-19 Asset Namespace of the token. Either `erc721` or `erc1155`. * * @see https://chainagnostic.org/CAIPs/caip-19 */ assetNamespace: t.text().notNull(), /** * The account that owns the token. * * Value is zeroAddress if and only if mintStatus is `burned`. * * Note: The owner of the token for a given domainId may differ from the * owner of the associated node in the registry. For example: * - Consider the case where address X owns the ENS name `foo.eth` in * both the BaseRegistrar and the Registry. If X sends a request directly * to the Registry to transfer ownership to Y, ownership of `foo.eth` will * be transferred to Y in the Registry but not in the BaseRegistrar. * - ... for the case above, the BaseRegistrar implements a `reclaim` * allowing the owner of the name in the BaseRegistrar to reclaim ownership * of the name in the Registry. * * Note: When a name is wrapped by the NameWrapper, the owner of the token * in the BaseRegistrar is the NameWrapper, while a new token for the name is * minted by the NameWrapper and owned by the effective owner of the name. */ owner: t.hex().notNull(), /** * The mint status of the token. Either `minted` or `burned`. * * After we index a NFT we never delete it from our index. Instead, when an * indexed NFT is burned onchain we retain its record and update its mint * status as `burned`. If a NFT is minted again after it is burned its mint * status is updated to `minted`. */ mintStatus: t.text().notNull() }), (t) => ({ idx_domainId: index3().on(t.domainId), idx_owner: index3().on(t.owner) }) ); export { internal_registrarActionMetadata, migratedNode, nameSales, nameTokens, nodeResolverRelation, registrarActionRelations, registrarActionType, registrarActions, registrationLifecycleRelations, registrationLifecycles, resolverAddressRecord, resolverAddressRecordRelations, resolverRecords, resolverRecords_relations, resolverTextRecord, resolverTextRecordRelations, reverseNameRecord, subgraph_abiChanged, subgraph_abiChangedRelations, subgraph_account, subgraph_accountRelations, subgraph_addrChanged, subgraph_addrChangedRelations, subgraph_authorisationChanged, subgraph_authorisationChangedRelations, subgraph_contenthashChanged, subgraph_contenthashChangedRelations, subgraph_domain, subgraph_domainRelations, subgraph_expiryExtended, subgraph_expiryExtendedRelations, subgraph_fusesSet, subgraph_fusesSetRelations, subgraph_interfaceChanged, subgraph_interfaceChangedRelations, subgraph_multicoinAddrChanged, subgraph_multicoinAddrChangedRelations, subgraph_nameChanged, subgraph_nameChangedRelations, subgraph_nameRegistered, subgraph_nameRegisteredRelations, subgraph_nameRenewed, subgraph_nameRenewedRelations, subgraph_nameTransferred, subgraph_nameTransferredRelations, subgraph_nameUnwrapped, subgraph_nameUnwrappedRelations, subgraph_nameWrapped, subgraph_nameWrappedRelations, subgraph_newOwner, subgraph_newOwnerRelations, subgraph_newResolver, subgraph_newResolverRelations, subgraph_newTTL, subgraph_newTTLRelations, subgraph_pubkeyChanged, subgraph_pubkeyChangedRelations, subgraph_registration, subgraph_registrationRelations, subgraph_resolver, subgraph_resolverRelations, subgraph_textChanged, subgraph_textChangedRelations, subgraph_transfer, subgraph_transferRelations, subgraph_versionChanged, subgraph_versionChangedRelations, subgraph_wrappedDomain, subgraph_wrappedDomainRelations, subgraph_wrappedTransfer, subgraph_wrappedTransferRelations, subregistries, subregistryRelations }; //# sourceMappingURL=ponder.schema.js.map