#!/usr/bin/env node
/**
* Validation script for Smithery deployment
*/
import fs from 'fs';
import path from 'path';
console.log('π Validating Smithery deployment configuration...\n');
const checks = [];
// Check required files
const requiredFiles = [
'smithery.yaml',
'package.json',
'build/smithery-server.js',
'build/smithery.yaml',
'build/erc20-contracts-rootstock.json'
];
console.log('π Checking required files...');
for (const file of requiredFiles) {
const exists = fs.existsSync(file);
console.log(` ${exists ? 'β
' : 'β'} ${file}`);
checks.push({ name: `File: ${file}`, passed: exists });
}
// Check smithery.yaml structure
console.log('\nπ Validating smithery.yaml...');
try {
const smitheryConfig = fs.readFileSync('smithery.yaml', 'utf8');
const hasERC20Tools = smitheryConfig.includes('deploy_erc20_token') &&
smitheryConfig.includes('get_token_info') &&
smitheryConfig.includes('mint_tokens');
console.log(` ${hasERC20Tools ? 'β
' : 'β'} ERC20 tools defined`);
checks.push({ name: 'ERC20 tools in smithery.yaml', passed: hasERC20Tools });
const hasCategories = smitheryConfig.includes('categories:') &&
smitheryConfig.includes('- tokens') &&
smitheryConfig.includes('- erc20');
console.log(` ${hasCategories ? 'β
' : 'β'} ERC20 categories defined`);
checks.push({ name: 'ERC20 categories in smithery.yaml', passed: hasCategories });
const hasKeywords = smitheryConfig.includes('- erc20') &&
smitheryConfig.includes('- token') &&
smitheryConfig.includes('- token-deployment');
console.log(` ${hasKeywords ? 'β
' : 'β'} ERC20 keywords defined`);
checks.push({ name: 'ERC20 keywords in smithery.yaml', passed: hasKeywords });
} catch (error) {
console.log(` β Error reading smithery.yaml: ${error.message}`);
checks.push({ name: 'smithery.yaml readable', passed: false });
}
// Check package.json
console.log('\nπ¦ Validating package.json...');
try {
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const hasSmitheryScript = packageJson.scripts && packageJson.scripts['build:smithery'];
console.log(` ${hasSmitheryScript ? 'β
' : 'β'} build:smithery script`);
checks.push({ name: 'build:smithery script', passed: hasSmitheryScript });
const hasEthers = packageJson.dependencies && packageJson.dependencies['ethers'];
console.log(` ${hasEthers ? 'β
' : 'β'} ethers.js dependency`);
checks.push({ name: 'ethers.js dependency', passed: hasEthers });
} catch (error) {
console.log(` β Error reading package.json: ${error.message}`);
checks.push({ name: 'package.json readable', passed: false });
}
// Check build artifacts
console.log('\nποΈ Validating build artifacts...');
try {
const indexJs = fs.readFileSync('build/smithery-server.js', 'utf8');
const hasERC20Tools = indexJs.includes('deploy_erc20_token') &&
indexJs.includes('get_token_info') &&
indexJs.includes('mint_tokens');
console.log(` ${hasERC20Tools ? 'β
' : 'β'} ERC20 tools in build`);
checks.push({ name: 'ERC20 tools in build', passed: hasERC20Tools });
const hasExplorerLinks = indexJs.includes('getExplorerUrl') &&
indexJs.includes('Transaction Explorer:');
console.log(` ${hasExplorerLinks ? 'β
' : 'β'} Explorer links in build`);
checks.push({ name: 'Explorer links in build', passed: hasExplorerLinks });
} catch (error) {
console.log(` β Error reading build/smithery-server.js: ${error.message}`);
checks.push({ name: 'build/smithery-server.js readable', passed: false });
}
// Check ERC20 contracts
console.log('\nπͺ Validating ERC20 contracts...');
try {
const contracts = JSON.parse(fs.readFileSync('build/erc20-contracts-rootstock.json', 'utf8'));
const hasSimpleERC20 = contracts.simpleERC20 && contracts.simpleERC20.bytecode;
console.log(` ${hasSimpleERC20 ? 'β
' : 'β'} SimpleERC20 contract`);
checks.push({ name: 'SimpleERC20 contract', passed: hasSimpleERC20 });
const hasMintableERC20 = contracts.mintableERC20 && contracts.mintableERC20.bytecode;
console.log(` ${hasMintableERC20 ? 'β
' : 'β'} MintableERC20 contract`);
checks.push({ name: 'MintableERC20 contract', passed: hasMintableERC20 });
} catch (error) {
console.log(` β Error reading ERC20 contracts: ${error.message}`);
checks.push({ name: 'ERC20 contracts readable', passed: false });
}
// Summary
console.log('\nπ Validation Summary');
console.log('=' .repeat(50));
const passed = checks.filter(c => c.passed).length;
const total = checks.length;
console.log(`β
Passed: ${passed}/${total} checks`);
if (passed === total) {
console.log('\nπ All checks passed! Ready for Smithery deployment.');
console.log('\nπ To deploy:');
console.log(' 1. smithery login');
console.log(' 2. smithery deploy');
console.log('\nπ Your ERC20 tools will be available at:');
console.log(' - deploy_erc20_token');
console.log(' - get_token_info');
console.log(' - mint_tokens');
} else {
console.log('\nβ Some checks failed. Please fix the issues above.');
console.log('\nFailed checks:');
checks.filter(c => !c.passed).forEach(c => {
console.log(` - ${c.name}`);
});
process.exit(1);
}
console.log('\nπ Documentation:');
console.log(' - SMITHERY.md (deployment guide)');
console.log(' - README.md (general usage)');
console.log(' - smithery.yaml (tool definitions)');