-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7f8818
commit 705cfe2
Showing
6 changed files
with
159 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { ActionHandler } from "../../types"; | ||
import { fetchData } from "../providers"; | ||
|
||
export const graphqlAction: ActionHandler = async (action, chain) => { | ||
const { query, variables } = action.payload || {}; | ||
const result = await fetchData(query, variables); | ||
const resultStr = | ||
`query: ` + query + `\n\nresult: ` + JSON.stringify(result, null, 2); | ||
return resultStr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { ActionHandler } from "../../types"; | ||
import { executeStarknetTransaction } from "../providers"; | ||
import type { CoTTransaction } from "../../types"; | ||
|
||
export const starknetTransactionAction: ActionHandler = async ( | ||
action, | ||
chain | ||
) => { | ||
const result = await executeStarknetTransaction( | ||
action.payload as CoTTransaction | ||
); | ||
return `Transaction executed successfully: ${JSON.stringify( | ||
result, | ||
null, | ||
2 | ||
)}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { ActionHandler } from "../../types"; | ||
|
||
import * as readline from "readline"; | ||
|
||
async function askUser(question: string): Promise<string> { | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
}); | ||
|
||
return new Promise((resolve) => { | ||
rl.question(`${question}\nYour response: `, (answer) => { | ||
rl.close(); | ||
resolve(answer); | ||
}); | ||
}); | ||
} | ||
|
||
export const systemPromptAction: ActionHandler = async (action, chain) => { | ||
const userResponse = await askUser(action.payload.prompt); | ||
return userResponse; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters