UNPKG

1inch-agent-kit

Version:

AI Agent Kit for 1inch - Connect any LLM to 1inch DeFi protocols

63 lines 2.72 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.tron = tron; const child_process_1 = require("child_process"); const path_1 = __importDefault(require("path")); /** * Execute cross-chain atomic swaps between Ethereum and Tron networks * This function handles ETH to TRON swaps using 1inch Fusion+ protocol */ async function tron(params) { const { ethAmount, tronAmount, action = "swap" } = params; console.log(`🚀 Initiating ${action} for ${ethAmount} ETH to TRON swap...`); return new Promise((resolve) => { // Get the path to the fusionplustron directory - go up from frontend to project root const projectRoot = path_1.default.join(process.cwd(), ".."); const workingDir = path_1.default.join(projectRoot, "agentkit", "src", "functions", "tron", "fusionplustron"); const command = "npx hardhat run scripts/demo/test-complete-atomic-swap.ts --network sepolia"; console.log(`📂 Working directory: ${workingDir}`); console.log(`🔧 Executing command: ${command}`); // Use exec to run the command (0, child_process_1.exec)(command, { cwd: workingDir, timeout: 300000, // 5 minutes timeout maxBuffer: 1024 * 1024 * 10 // 10MB buffer }, (error, stdout, stderr) => { const output = stdout + stderr; console.log("📤 Command output:", output); if (error) { console.error("❌ Command execution error:", error); resolve({ success: false, message: `❌ Failed to execute ${action} for ${ethAmount} ETH to TRON swap`, ethAmount, tronAmount, action, error: error.message, output: output, command, workingDirectory: workingDir }); } else { resolve({ success: true, message: `✅ Successfully executed ${action} for ${ethAmount} ETH to TRON swap!`, ethAmount, tronAmount: tronAmount || "calculated", action, transactionDetails: { status: "completed" }, output: output, command, workingDirectory: workingDir }); } }); }); } //# sourceMappingURL=index.js.map