pastedCodeSafety
STetsing 4 weeks ago
parent 41300bf9e3
commit 54bba0d5b0
  1. 1
      apps/remix-ide/src/app/tabs/locales/en/editor.json
  2. 8
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx

@ -28,6 +28,7 @@
"editor.explainFunctionByAI": "```\n{content}\n```\nExplain the function {currentFunction}",
"editor.explainFunctionByAISol": "```\n{content}\n```\nExplain the function {currentFunction}",
"editor.ExplainPipeMessage": "```\n {content}\n```\nExplain the snipped above",
"editor.PastedCodeSafety": "```\n {content}\n```\n\nReply in a short maner: Does this code contain major security vulenerabilities leading to a scam or loss of funds?",
"editor.executeFreeFunction": "Run a free function",
"editor.executeFreeFunction2": "Run the free function \"{name}\"",
"editor.toastText1": "This can only execute free function",

@ -660,7 +660,7 @@ export const EditorUI = (props: EditorUIProps) => {
}
})
editor.onDidPaste((e) => {
editor.onDidPaste(async (e) => {
if (!pasteCodeRef.current && e && e.range && e.range.startLineNumber >= 0 && e.range.endLineNumber >= 0 && e.range.endLineNumber - e.range.startLineNumber > 10) {
const modalContent: AlertModal = {
id: 'newCodePasted',
@ -697,9 +697,15 @@ export const EditorUI = (props: EditorUIProps) => {
</div>
),
}
const pastedCode = editor.getModel().getValueInRange(e.range)
const pastedCodePrompt = intl.formatMessage({ id: 'editor.PastedCodeSafety' }, { content:pastedCode })
// props.plugin.call('remixAI', 'chatPipe', 'solidity_answer', pastedCodePrompt)
const result = props.plugin.call('remixAI', 'solidity_answer', pastedCodePrompt)
props.plugin.call('notification', 'alert', modalContent)
pasteCodeRef.current = true
_paq.push(['trackEvent', 'editor', 'onDidPaste', 'more_than_10_lines'])
console.log('result test:', await result)
}
})

Loading…
Cancel
Save