Chore/base configurations
This commit is contained in:
5
.cspell.json
Normal file
5
.cspell.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "0.1",
|
||||
"import": ["@generalprotocols/cspell-dictionary/cspell.json"],
|
||||
"words": ["nonfungible", "lockscript"]
|
||||
}
|
||||
@@ -4,7 +4,7 @@ root = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
max_line_length = 150
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
**/build/
|
||||
**/node_modules/
|
||||
@@ -1,52 +0,0 @@
|
||||
{
|
||||
"extends": ["@generalprotocols/eslint-config/typescript", "plugin:prettier/recommended"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"project": "./tsconfig.json",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
"argsIgnorePattern": "^_",
|
||||
"destructuredArrayIgnorePattern": "^_"
|
||||
}
|
||||
],
|
||||
"import/extensions": [
|
||||
"error",
|
||||
{
|
||||
"js": "always"
|
||||
}
|
||||
],
|
||||
"import/no-internal-modules": [
|
||||
"error",
|
||||
{
|
||||
"allow": ["**/*"]
|
||||
}
|
||||
],
|
||||
"max-len": [
|
||||
"error",
|
||||
{
|
||||
"code": 150,
|
||||
"ignoreUrls": true,
|
||||
"ignoreStrings": true,
|
||||
"ignoreTemplateLiterals": true,
|
||||
"ignoreComments": true
|
||||
}
|
||||
],
|
||||
"no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
"argsIgnorePattern": "^_",
|
||||
"destructuredArrayIgnorePattern": "^_"
|
||||
}
|
||||
],
|
||||
"object-curly-newline": [
|
||||
"error",
|
||||
{
|
||||
"multiline": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,11 +1,14 @@
|
||||
.vscode/
|
||||
build/
|
||||
build/**
|
||||
dist/
|
||||
dist/**
|
||||
node_modules/
|
||||
yarn.lock
|
||||
yarn-error.log
|
||||
|
||||
.DS_Store
|
||||
public/
|
||||
docs/
|
||||
coverage/
|
||||
|
||||
*.js
|
||||
*.js.map
|
||||
@@ -14,8 +17,8 @@ yarn-error.log
|
||||
*.tsbuildinfo
|
||||
|
||||
# Generated files
|
||||
src/parser/xo-template.schema.json
|
||||
src/parser/ajv/validate-xo-template.js
|
||||
source/parser/xo-template.schema.json
|
||||
source/parser/ajv/validate-xo-template.js
|
||||
|
||||
# Exception: include generate-schema.js
|
||||
!scripts/generate-schema.js
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"printWidth": 150,
|
||||
"useTabs": false,
|
||||
"tabWidth": 4,
|
||||
"singleQuote": true,
|
||||
"semi": true
|
||||
}
|
||||
23
.prettierrc.mjs
Normal file
23
.prettierrc.mjs
Normal file
@@ -0,0 +1,23 @@
|
||||
// Prettier configuration aligned with @xo-cash/eslint-config
|
||||
export default {
|
||||
// Matches @stylistic/max-len': [ 'warn', 150, ...]
|
||||
printWidth: 150,
|
||||
|
||||
// Matches @stylistic/no-tabs': [ 'error' ]
|
||||
useTabs: false,
|
||||
|
||||
// Matches @stylistic/indent': [ 'error', 4, ...]
|
||||
tabWidth: 4,
|
||||
|
||||
// Matches @stylistic/array-bracket-spacing': [ 'error', 'always', ...]
|
||||
bracketSpacing: true,
|
||||
|
||||
// Matches @stylistic/quotes: ['error', 'single', { avoidEscape: true }], from @chalp/eslint-airbnb/base/stylistic.js
|
||||
singleQuote: true,
|
||||
|
||||
// Matches @stylistic/semi: ['error', 'always'], from @chalp/eslint-airbnb/base/stylistic.js
|
||||
semi: true,
|
||||
|
||||
// Matches @stylistic/arrow-parens: ['error', 'always'], from @chalp/eslint-airbnb/base/stylistic.js
|
||||
arrowParens: 'always',
|
||||
};
|
||||
8
eslint.config.mjs
Normal file
8
eslint.config.mjs
Normal file
@@ -0,0 +1,8 @@
|
||||
import baseConfig from '@xo-cash/eslint-config';
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: [ 'source/parser/ajv/validate-xo-template.js', 'docs/**' ],
|
||||
},
|
||||
...baseConfig,
|
||||
];
|
||||
19631
package-lock.json
generated
19631
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
@@ -3,24 +3,26 @@
|
||||
"version": "0.0.1",
|
||||
"description": "XO Cash utilities",
|
||||
"type": "module",
|
||||
"types": "./dist/index.d.mts",
|
||||
"source": "./source/index.ts",
|
||||
"module": "./dist/index.mjs",
|
||||
"exports": {
|
||||
".": "./build/index.js"
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"types": "./build/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "npm run clean && tsc",
|
||||
"clean": "del-cli ./build",
|
||||
"analyze": "tsdown --clean --no-fixed-extension --sourcemap source/index.ts && esbuild-analyzer dist/",
|
||||
"build": "tsdown --clean --sourcemap source/index.ts",
|
||||
"docs": "typedoc --hideGenerator --categorizeByGroup",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"lint:fix": "eslint . --ext .ts --fix",
|
||||
"prettier": "prettier --write .",
|
||||
"format": "prettier --write . && eslint --fix",
|
||||
"prebuild": "node scripts/generate-schema.js",
|
||||
"prepublishOnly": "npm run build",
|
||||
"syntax": "tsc --noEmit"
|
||||
"spellcheck": "cspell 'source/**' 'test/**' 'playground/**'",
|
||||
"style": "eslint",
|
||||
"syntax": "tsc --noEmit",
|
||||
"test": "vitest --dir test/ --test-timeout=15000 --passWithNoTests --run --coverage"
|
||||
},
|
||||
"files": [
|
||||
"build"
|
||||
"dist"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -41,18 +43,25 @@
|
||||
"@xo-cash/types": "0.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@generalprotocols/eslint-config": "^1.0.1",
|
||||
"@types/node": "^20.10.0",
|
||||
"ajv-cli": "^5.0.0",
|
||||
"del-cli": "^7.0.0",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"@chalp/eslint-airbnb": "^1.3.0",
|
||||
"@generalprotocols/cspell-dictionary": "^1.0.1",
|
||||
"@stylistic/eslint-plugin": "^5.7.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
||||
"@typescript-eslint/parser": "^8.53.1",
|
||||
"@vitest/coverage-v8": "^4.0.17",
|
||||
"@viz-kit/esbuild-analyzer": "^1.0.0",
|
||||
"@xo-cash/eslint-config": "1.0.1",
|
||||
"cspell": "^9.6.0",
|
||||
"eslint": "^9.39.2",
|
||||
"prettier": "^3.6.2",
|
||||
"ts-json-schema-generator": "^2.4.0",
|
||||
"typedoc": "^0.28.15",
|
||||
"tsdown": "^0.20.0-beta.4",
|
||||
"typedoc": "^0.28.16",
|
||||
"typedoc-plugin-coverage": "^4.0.2",
|
||||
"typescript": "^5.3.2"
|
||||
"typescript": "^5.3.2",
|
||||
"typescript-eslint": "^8.53.1",
|
||||
"vitest": "^4.0.17",
|
||||
"ajv-cli": "^5.0.0",
|
||||
"ts-json-schema-generator": "^2.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
|
||||
@@ -10,22 +10,23 @@ const __dirname = dirname(__filename);
|
||||
const rootDir = join(__dirname, '..');
|
||||
|
||||
// exec helper
|
||||
function exec(command, options = {}) {
|
||||
const exec = (command, options = {}) => {
|
||||
const defaultOptions = {
|
||||
stdio: 'inherit',
|
||||
cwd: rootDir,
|
||||
shell: true,
|
||||
...options,
|
||||
};
|
||||
|
||||
return execSync(command, defaultOptions);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
const schemaPath = join(rootDir, 'src/parser/xo-template.schema.json');
|
||||
const validatorPath = join(rootDir, 'src/parser/ajv/validate-xo-template.js');
|
||||
const schemaPath = join(rootDir, 'source/parser/xo-template.schema.json');
|
||||
const validatorPath = join(rootDir, 'source/parser/ajv/validate-xo-template.js');
|
||||
const tsconfigPath = join(rootDir, 'tsconfig.json');
|
||||
// Point directly to the dist file - the type is exported at the end via barrel export
|
||||
const templatePath = join(rootDir, 'node_modules/@xo-cash/types/dist/index.d.mts');
|
||||
const templatePath = join(rootDir, 'node_modules/@xo-cash/types/dist/index.d.ts');
|
||||
|
||||
// Generate schema JSON (write to file directly instead of shell redirection)
|
||||
// Using --no-type-check to skip type checking and --expose all to find types exported via barrel exports
|
||||
|
||||
5
source/index.ts
Normal file
5
source/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './errors.ts';
|
||||
export * from './parser/ajv/ajv-utils.ts';
|
||||
export * from './parser/xo-template.ts';
|
||||
export * from './script.ts';
|
||||
export * from './templates.ts';
|
||||
@@ -24,9 +24,9 @@ export type AjvValidator<T = unknown> = {
|
||||
data: unknown,
|
||||
dataCxt?: {
|
||||
instancePath?: string;
|
||||
parentData: any;
|
||||
parentDataProperty: any;
|
||||
rootData?: any;
|
||||
parentData: unknown;
|
||||
parentDataProperty: unknown;
|
||||
rootData?: unknown;
|
||||
},
|
||||
): data is T;
|
||||
errors?: XOAjvError[] | null;
|
||||
@@ -3,8 +3,8 @@
|
||||
*/
|
||||
|
||||
import { lossyNormalize } from '@bitauth/libauth';
|
||||
import type { AjvValidator, XOAjvError } from './ajv-types.js';
|
||||
import { FailedToParseTemplateError } from '../../errors.js';
|
||||
import type { AjvValidator, XOAjvError } from './ajv-types.ts';
|
||||
import { FailedToParseTemplateError } from '../../errors.ts';
|
||||
|
||||
const errorsToDescription = (errors: XOAjvError[]): string => {
|
||||
// TODO: translate instancePath and make errors more descriptive.
|
||||
@@ -4,9 +4,9 @@
|
||||
*/
|
||||
|
||||
import type { XOTemplate } from '@xo-cash/types';
|
||||
import type { AjvValidator } from './ajv/ajv-types.js';
|
||||
import { parseJson, validateSchema } from './ajv/ajv-utils.js';
|
||||
import { InvalidTemplateError } from '../errors.js';
|
||||
import type { AjvValidator } from './ajv/ajv-types.ts';
|
||||
import { parseJson, validateSchema } from './ajv/ajv-utils.ts';
|
||||
import { InvalidTemplateError } from '../errors.ts';
|
||||
import xoTemplateValidator from './ajv/validate-xo-template.js';
|
||||
|
||||
/**
|
||||
@@ -1,9 +1,9 @@
|
||||
import { binToHex, sha256 } from '@bitauth/libauth';
|
||||
|
||||
/**
|
||||
* Converts a script to a scripthash.
|
||||
* Converts a script to a scriptHash.
|
||||
* @param {Uint8Array} script - The script to convert.
|
||||
* @returns {string} The scripthash as a hexadecimal string.
|
||||
* @returns {string} The scriptHash as a hexadecimal string.
|
||||
*/
|
||||
export const scriptToScriptHash = (script: Uint8Array): string => {
|
||||
const hash = sha256.hash(script);
|
||||
@@ -8,7 +8,7 @@ import type { XOTemplate } from '@xo-cash/types';
|
||||
* @returns The template identifier for the template.
|
||||
*/
|
||||
export const generateTemplateIdentifier = (template: XOTemplate): string => {
|
||||
// TODO: Finalise on the stringify method and ensure unique identifier generation is sufficient.
|
||||
// TODO: Finalize on the stringify method and ensure unique identifier generation is sufficient.
|
||||
|
||||
return binToHex(sha256.hash(utf8ToBin(stringify(template))));
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
export * from './errors.js';
|
||||
export * from './parser/ajv/ajv-utils.js';
|
||||
export * from './parser/xo-template.js';
|
||||
export * from './script.js';
|
||||
export * from './templates.js';
|
||||
@@ -1,26 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"rootDir": "src",
|
||||
"outDir": "build",
|
||||
"incremental": true,
|
||||
"tsBuildInfoFile": "./build/.tsbuildinfo",
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"module": "es2022",
|
||||
"target": "es2022",
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"allowJs": true,
|
||||
"strictPropertyInitialization": false,
|
||||
"traceResolution": false,
|
||||
"listEmittedFiles": false,
|
||||
"listFiles": false,
|
||||
"pretty": true
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"noEmit": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true
|
||||
},
|
||||
"exclude": ["node_modules", "build", "scripts"],
|
||||
"compileOnSave": false
|
||||
"exclude": ["node_modules/**/*", "dist/**/*"]
|
||||
}
|
||||
|
||||
17
typedoc.json
Normal file
17
typedoc.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"entryPoints": ["source/index.ts"],
|
||||
"out": "public/",
|
||||
"plugin": ["typedoc-plugin-coverage"],
|
||||
"maxTypeConversionDepth": 2,
|
||||
"visibilityFilters": {
|
||||
"protected": false,
|
||||
"private": false,
|
||||
"inherited": false,
|
||||
"external": false
|
||||
},
|
||||
"groupOrder": ["Classes", "Interfaces", "Events", "*"],
|
||||
"navigation": {
|
||||
"includeCategories": false,
|
||||
"includeGroups": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user