diff --git a/apps/remix-ide/src/app/tabs/locales/en/editor.json b/apps/remix-ide/src/app/tabs/locales/en/editor.json index 6f0f367555..45805618c4 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/editor.json +++ b/apps/remix-ide/src/app/tabs/locales/en/editor.json @@ -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", diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index ab8de7ec34..795e274a11 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -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) => { ), } + + 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) } })