Skip to content

Commit ac1a296

Browse files
handle deployment from file
Signed-off-by: Agustín Ramiro Díaz <agustin.ramiro.diaz@gmail.com>
1 parent a5efece commit ac1a296

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

packages/plugin-genlayer/src/actions/deployContract.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import {
66
State,
77
elizaLogger,
88
} from "@ai16z/eliza";
9+
import fs from "fs";
910
import { DeployContractParams } from "../types";
1011
import { ClientProvider } from "../providers/client";
1112
import { getParamsWithLLM } from "../utils/llm";
1213

1314
const deployContractTemplate = `
14-
# Task: Determine the contract code and constructor arguments for deploying a contract.
15+
# Task: Determine the contract code file path and constructor arguments for deploying a contract.
1516
1617
# Instructions: The user is requesting to deploy a contract to the GenLayer protocol.
1718
@@ -21,7 +22,7 @@ Here is the user's request:
2122
# Your response must be formatted as a JSON block with this structure:
2223
\`\`\`json
2324
{
24-
"code": "<Contract Code>",
25+
"code_file": "<Contract Code File Path>",
2526
"args": [<Constructor Args>],
2627
"leaderOnly": <true/false>
2728
}
@@ -61,21 +62,23 @@ export const deployContractAction: Action = {
6162
elizaLogger.debug("Parsed parameters:", options);
6263
elizaLogger.info(
6364
"Deploying contract with code length:",
64-
options.code.length
65+
options.code_file.length
6566
);
6667

68+
const code = await fs.readFileSync(options.code_file, "utf8");
69+
6770
const result = await clientProvider.client.deployContract({
68-
code: options.code,
71+
code: code,
6972
args: options.args,
7073
leaderOnly: options.leaderOnly,
7174
});
7275

7376
elizaLogger.success(
74-
`Successfully deployed contract at address: ${result}`
77+
`Successfully sent contract for deployment. Transaction hash: ${result}`
7578
);
7679
await callback(
7780
{
78-
text: `Successfully deployed contract at address: ${result}`,
81+
text: `Successfully sent contract for deployment. Transaction hash: ${result}`,
7982
},
8083
[]
8184
);

packages/plugin-genlayer/src/actions/getTransaction.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const getTransactionAction: Action = {
4242
});
4343

4444
elizaLogger.success("Successfully retrieved transaction details");
45-
elizaLogger.success("Transaction details:", result);
45+
elizaLogger.debug("Transaction details:", result);
4646
await callback(
4747
{
4848
text: `Transaction details: ${JSON.stringify(

packages/plugin-genlayer/src/types/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface WriteContractParams {
2121
}
2222

2323
export interface DeployContractParams {
24-
code: string;
24+
code_file: string;
2525
args: CalldataEncodable[];
2626
leaderOnly?: boolean;
2727
}

0 commit comments

Comments
 (0)