Add ECDSA signature verification and enhance ComboHandler functionality

- Integrated ECDSA for signature verification in ComboHandler.
- Updated event emissions to include additional parameters for better tracking.
- Improved gas tracking during execution of combo plans.
- Enhanced database interactions for storing and retrieving plans, including conflict resolution and status updates.
- Added new dependencies for security and database management in orchestrator.
This commit is contained in:
defiQUG
2025-11-05 16:28:48 -08:00
parent 3b09c35c47
commit f600b7b15e
48 changed files with 3381 additions and 46 deletions

View File

@@ -0,0 +1,47 @@
import { query } from "../postgres";
import fs from "fs";
import path from "path";
/**
* Run initial database schema migration
*/
export async function up() {
const schemaPath = path.join(__dirname, "../schema.sql");
const schema = fs.readFileSync(schemaPath, "utf-8");
// Split by semicolons and execute each statement
const statements = schema
.split(";")
.map((s) => s.trim())
.filter((s) => s.length > 0 && !s.startsWith("--"));
for (const statement of statements) {
try {
await query(statement);
} catch (error: any) {
// Ignore "already exists" errors
if (!error.message.includes("already exists")) {
throw error;
}
}
}
console.log("✅ Database schema migrated successfully");
}
/**
* Rollback migration (not implemented for initial schema)
*/
export async function down() {
// Drop tables in reverse order
await query("DROP TABLE IF EXISTS compliance_status CASCADE");
await query("DROP TABLE IF EXISTS users CASCADE");
await query("DROP TABLE IF EXISTS audit_logs CASCADE");
await query("DROP TABLE IF EXISTS receipts CASCADE");
await query("DROP TABLE IF EXISTS executions CASCADE");
await query("DROP TABLE IF EXISTS plans CASCADE");
await query("DROP FUNCTION IF EXISTS update_updated_at_column CASCADE");
console.log("✅ Database schema rolled back");
}

View File

@@ -0,0 +1,15 @@
import { up as up001 } from "./001_initial_schema";
/**
* Run all migrations
*/
export async function runMigration() {
try {
await up001();
console.log("✅ All migrations completed");
} catch (error) {
console.error("❌ Migration failed:", error);
throw error;
}
}