remove base type, keep primitive type and make hints as unknown optional

This commit is contained in:
Kuldeep
2026-09-11 05:21:16 +00:00
parent 32eca1e016
commit a9d96d7a0d
8 changed files with 492 additions and 541 deletions
+7 -13
View File
@@ -1,5 +1,5 @@
/* eslint-disable @stylistic/newline-per-chained-call */
import { BchVmVersions, XOTemplateBaseTypes, XOTemplatePrimitiveTypes, XOTemplateLockingTypes, XOTemplateNftCapabilities } from '@xo-cash/types';
import { BchVmVersions, XOTemplatePrimitiveTypes, XOTemplateLockingTypes, XOTemplateNftCapabilities } from '@xo-cash/types';
import { z } from 'zod';
// ============================================================
@@ -58,12 +58,6 @@ export const xoTemplateNftCapabilitySchema = z.enum(XOTemplateNftCapabilities);
*/
export const xoTemplateLockingTypeSchema = z.enum(XOTemplateLockingTypes);
/**
* Validation schema for a base type identifier.
* Accepts values from XOTemplateBaseTypes for the `type` field on constants, variables, and data.
*/
export const xoTemplateBaseTypeSchema = z.enum(XOTemplateBaseTypes);
/**
* Validation schema for a primitive type identifier.
* Accepts values from XOTemplatePrimitiveTypes for the `hint` field on constants, variables, and data.
@@ -743,9 +737,9 @@ export const xoTemplateTransactionSchema = xoTemplateViewPropertiesSchema
*/
export const xoTemplateConstantSchema = xoTemplateViewPropertiesSchema
.extend({
type: xoTemplateBaseTypeSchema.describe('The data type of this constant.'),
type: xoTemplatePrimitiveTypeSchema.describe('The data type of this constant.'),
value: z.unknown().describe('The value of this constant.'),
hint: xoTemplatePrimitiveTypeSchema.optional().describe('An optional hint to help apps and users understand what this constant represents.'),
hint: z.unknown().optional().describe('An optional hint to help apps and users understand what this constant represents.'),
})
.strict();
@@ -762,9 +756,9 @@ export const xoTemplateConstantSchema = xoTemplateViewPropertiesSchema
*/
export const xoTemplateDataSchema = z
.object({
type: xoTemplateBaseTypeSchema.describe('The data type of this data field.'),
type: xoTemplatePrimitiveTypeSchema.describe('The data type of this data field.'),
value: z.unknown().describe('The value for this data field.'),
hint: xoTemplatePrimitiveTypeSchema.optional().describe('An optional hint to help apps and users understand this data field.'),
hint: z.unknown().optional().describe('An optional hint to help apps and users understand this data field.'),
})
.strict();
@@ -800,8 +794,8 @@ export const xoTemplateImportDefaultValueSchema = xoTemplateIntentSchema
*/
export const xoTemplateVariableSchema = xoTemplateViewPropertiesSchema
.extend({
type: xoTemplateBaseTypeSchema.optional().describe('The data type of this variable.'),
hint: xoTemplatePrimitiveTypeSchema.optional().describe('A hint to help users understand what value to provide.'),
type: xoTemplatePrimitiveTypeSchema.optional().describe('The data type of this variable.'),
hint: z.unknown().optional().describe('A hint to help users understand what value to provide.'),
// A neutral intent that the engine uses to populate the default value for this variable.
// View properties (name, description, icon) may contain CashASM expressions that the