From 66669736c72d871eb05c186e0c480a99f3ba1650 Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Tue, 27 Aug 2024 09:04:11 -0500 Subject: [PATCH] Add hash record type --- .../xns/plugins/record/src/Hash/Payload.ts | 23 +++++++++++++++++++ .../xns/plugins/record/src/Hash/index.ts | 1 + .../packages/xns/plugins/record/src/index.ts | 1 + 3 files changed, 25 insertions(+) create mode 100644 packages/payload/packages/xns/plugins/record/src/Hash/Payload.ts create mode 100644 packages/payload/packages/xns/plugins/record/src/Hash/index.ts diff --git a/packages/payload/packages/xns/plugins/record/src/Hash/Payload.ts b/packages/payload/packages/xns/plugins/record/src/Hash/Payload.ts new file mode 100644 index 000000000..4e64f9959 --- /dev/null +++ b/packages/payload/packages/xns/plugins/record/src/Hash/Payload.ts @@ -0,0 +1,23 @@ +import type { Hash } from '@xylabs/hex' +import type { Payload, WithMeta } from '@xyo-network/payload-model' +import { isPayloadOfSchemaType } from '@xyo-network/payload-model' + +import type { DomainFields } from '../Domain/index.ts' + +export type HashRecordSchema = 'network.xyo.ns.record.hash' +export const HashRecordSchema: HashRecordSchema = 'network.xyo.ns.record.hash' + +export interface HashRecordFields extends DomainFields { + /** + * The hash the record points to + */ + hash: Hash[] +} + +/** + * An hash record points a domain to an hash + */ +export type HashRecord = Payload + +export const isHashRecord = isPayloadOfSchemaType(HashRecordSchema) +export const isHashRecordWithMeta = isPayloadOfSchemaType>(HashRecordSchema) diff --git a/packages/payload/packages/xns/plugins/record/src/Hash/index.ts b/packages/payload/packages/xns/plugins/record/src/Hash/index.ts new file mode 100644 index 000000000..de1113db1 --- /dev/null +++ b/packages/payload/packages/xns/plugins/record/src/Hash/index.ts @@ -0,0 +1 @@ +export * from './Payload.ts' diff --git a/packages/payload/packages/xns/plugins/record/src/index.ts b/packages/payload/packages/xns/plugins/record/src/index.ts index 64b286c29..b7bc834dc 100644 --- a/packages/payload/packages/xns/plugins/record/src/index.ts +++ b/packages/payload/packages/xns/plugins/record/src/index.ts @@ -4,3 +4,4 @@ export * from './DNS/index.ts' export * from './Domain/index.ts' export * from './DomainRegistration/index.ts' export * from './Duration/index.ts' +export * from './Hash/index.ts'