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 1bad91819b..3f38983164 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -1,6 +1,7 @@ import React, { useState, useRef, useEffect, useReducer } from 'react' // eslint-disable-line import Editor, { loader, Monaco } from '@monaco-editor/react' +import { AlertModal } from '@remix-ui/app' import { reducerActions, reducerListener, initialState } from './actions/editor' import { solidityTokensProvider, solidityLanguageConfig } from './syntaxes/solidity' import { cairoTokensProvider, cairoLanguageConfig } from './syntaxes/cairo' @@ -541,6 +542,31 @@ export const EditorUI = (props: EditorUIProps) => { } }) + editor.onDidPaste((e) => { + if (e && e.range && e.range.startLineNumber >= 0 && e.range.endLineNumber >= 0 && e.range.endLineNumber - e.range.startLineNumber > 10) { + const modalContent: AlertModal = { + id: 'newCodePasted', + title: 'New pasted code detected!', + message: ( +
+ Remix detected you have just pasted a consequent code snippet or contract in the editor. +
+ Please make sure you fully understand this new code before executing any transaction that uses it. +
+ Your wallet might be exposed and at risk if you run untrusted code. In a worst-case scenario you could loose all your money. +
+ If you don't fully understand it, please don't run this code. +
+ If you are not a smart contract developer, please ask assistance to someone you trust and has the skills to determine whether this code is safe to use. +
+
+
+ ), + } + props.plugin.call('notification', 'alert', modalContent) + } + }) + // zoomin zoomout editor.addCommand(monacoRef.current.KeyMod.CtrlCmd | (monacoRef.current.KeyCode as any).US_EQUAL, () => { editor.updateOptions({ fontSize: editor.getOption(43).fontSize + 1 })