Files
safe-wallet/packages/store/scripts/check-auto-generated-sync.ts
6dd96b331d chore: regenerate CGW schema and types (#7738)
Pick up latest CGW schema changes: drop unused contractAddresses from
Chain, add safeTxHash to relay endpoint, add createdAt/updatedAt to
SpaceAddressBookItemDto. Update test mocks to match the new shapes.

Also fix the check-sync script under Node 22: swap the ESM import.meta.url
pathname for __dirname and pin ts-node to CommonJS so the auto-generated
sync test stops failing with ERR_UNKNOWN_FILE_EXTENSION.

Co-authored-by: Hanzo Dev <[email protected]>
2026-04-24 14:15:53 +02:00

45 lines
1.2 KiB
TypeScript

import { createHash } from 'crypto'
import { readFileSync } from 'fs'
import { resolve } from 'path'
const SCRIPTS_DIR = __dirname
const SCHEMA_PATH = resolve(SCRIPTS_DIR, 'api-schema/schema.json')
const HASH_FILE_PATH = resolve(SCRIPTS_DIR, '../src/gateway/AUTO_GENERATED/.schema-hash')
function computeSchemaHash(): string {
const contents = readFileSync(SCHEMA_PATH)
return createHash('sha256').update(contents).digest('hex')
}
function readStoredHash(): string | null {
try {
return readFileSync(HASH_FILE_PATH, 'utf-8').trim()
} catch {
return null
}
}
const currentHash = computeSchemaHash()
const storedHash = readStoredHash()
if (storedHash === null) {
console.error(
'AUTO_GENERATED/.schema-hash not found.\n' +
'Run `yarn workspace @safe-global/store build:dev` to regenerate AUTO_GENERATED files and update the hash.',
)
process.exit(1)
}
if (currentHash !== storedHash) {
console.error(
'AUTO_GENERATED files may be out of date.\n' +
`Schema hash: ${currentHash}\n` +
`Stored hash: ${storedHash}\n` +
'Run `yarn workspace @safe-global/store build:dev` to regenerate.',
)
process.exit(1)
}
console.log('AUTO_GENERATED files are in sync with schema.json.')
process.exit(0)