mirror of
https://github.com/luxfi/safe-wallet.git
synced 2026-10-30 15:19:21 +00:00
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]>
45 lines
1.2 KiB
TypeScript
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)
|