Skip to content

Commit

Permalink
Merge branch 'master' into pastedCodeSafety
Browse files Browse the repository at this point in the history
  • Loading branch information
LianaHus authored Jan 16, 2025
2 parents 135e11a + 214768a commit def0f7d
Show file tree
Hide file tree
Showing 28 changed files with 135 additions and 126 deletions.
2 changes: 1 addition & 1 deletion apps/remix-dapp/src/locales/en/udapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"udapp.contractOptionsTitle2": "Select a compiled contract to deploy or to use with At Address.",
"udapp.contractOptionsTitle3": "Select and compile *.sol file to deploy or access a contract.",
"udapp.contractOptionsTitle4": "When there is a compiled .sol file, choose the contract to deploy or to use with At Address.",
"udapp.checkSumWarning": "It seems you are not using a checksumed address.A checksummed address is an address that contains uppercase letters, as specified in {a}.Checksummed addresses are meant to help prevent users from sending transactions to the wrong address.",
"udapp.checkSumWarning": "It seems you are not using a checksummed address.A checksummed address is an address that contains uppercase letters, as specified in {a}.Checksummed addresses are meant to help prevent users from sending transactions to the wrong address.",
"udapp.isOverSizePromptEip170": "Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fail if the current network has activated the eip 170. More info: {a}",
"udapp.isOverSizePromptEip3860": "Contract creation init code exceeds the allowed max code size of 49152 bytes. The deployment will likely fail if the current network has activated the eip 3860. More info: {a}",
"udapp.thisContractMayBeAbstract": "This contract may be abstract, it may not implement an abstract parent's methods completely or it may not invoke an inherited contract's constructor correctly.",
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-dapp/src/locales/zh/udapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"udapp.contractOptionsTitle2": "选择要部署或与 At Address 一起使用的已编译合约。",
"udapp.contractOptionsTitle3": "选择并编译 *.sol 文件以部署或访问合约。",
"udapp.contractOptionsTitle4": "当有编译的 .sol 文件时,选择 {br} 合约进行部署或与 AtAddress 一起使用。",
"udapp.checkSumWarning": "您似乎没有使用 checksumed address 。{br} checksumed address 是包含大写字母的地址,如 {a} 中所指定。{br} checksumed address 旨在帮助防止用户将交易发送到错误地址。",
"udapp.checkSumWarning": "您似乎没有使用 checksummed address 。{br} checksummed address 是包含大写字母的地址,如 {a} 中所指定。{br} checksummed address 旨在帮助防止用户将交易发送到错误地址。",
"udapp.isOverSizePromptEip170": "合约创建初始化返回长度超过24576字节的数据。部署可能会失败。 {br}更多信息:{a}",
"udapp.isOverSizePromptEip3860": "合约创建初始化代码超出了允许的最大代码大小 49152 字节。如果当前网络已激活 eip 3860,则部署可能会失败。更多信息:{a}",
"udapp.thisContractMayBeAbstract": "这个合约可能是抽象的,它可能没有完全实现抽象父类的方法,或者它可能没有正确调用继承合约的构造函数。",
Expand Down
17 changes: 6 additions & 11 deletions apps/remix-ide-e2e/src/commands/selectContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ import EventEmitter from 'events'
const selector = '.udapp_contractNames'

class SelectContract extends EventEmitter {
command (this: NightwatchBrowser, contractName: string): NightwatchBrowser {
this.api.waitForElementVisible(selector).perform((done) => {
selectContract(this.api, contractName, () => {
done()
this.emit('complete')
})
})
command(this: NightwatchBrowser, contractName: string): NightwatchBrowser {
this.api
.waitForElementVisible(selector)
.waitForElementPresent(`${selector} option[value="${contractName}"]`)
.click(`${selector} option[value="${contractName}"]`)
.perform(() => this.emit('complete'))
return this
}
}

function selectContract (browser: NightwatchBrowser, contractName: string, callback: VoidFunction) {
browser.click(`${selector} option[value="${contractName}"]`).perform(() => callback())
}

module.exports = SelectContract
18 changes: 8 additions & 10 deletions apps/remix-ide-e2e/src/tests/terminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,16 @@ module.exports = {
.createContract('')
.getAddressAtPosition(0, (address) => {
addressRef = address
})
.perform((done) => {
browser.addFile('scripts/test_filtering_event.ts', { content: test_filtering_event.replace('<ADDRESS>', addressRef) })
.perform(() => done())
.executeScriptInTerminal('remix.execute(\'scripts/test_filtering_event.ts\')')
.pause(1000)
.waitForElementContainsText('*[data-id="terminalJournal"]', '1')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'true')
.executeScriptInTerminal('remix.execute(\'scripts/test_filtering_event.ts\')') // re-emit the event
.waitForElementContainsText('*[data-id="terminalJournal"]', '2')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'false')
})
.executeScriptInTerminal('remix.execute(\'scripts/test_filtering_event.ts\')')
.pause(1000)
.waitForElementContainsText('*[data-id="terminalJournal"]', '1')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'true')
.executeScriptInTerminal('remix.execute(\'scripts/test_filtering_event.ts\')') // re-emit the event
.waitForElementContainsText('*[data-id="terminalJournal"]', '2')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'false')

},

'Should display auto-complete menu #group4': function (browser: NightwatchBrowser) {
Expand Down
122 changes: 78 additions & 44 deletions apps/remix-ide/src/app.js → apps/remix-ide/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ import { WalkthroughService } from './walkthroughService'

import { OffsetToLineColumnConverter, CompilerMetadata, CompilerArtefacts, FetchAndCompile, CompilerImports, GistHandler } from '@remix-project/core-plugin'

import {Registry} from '@remix-project/remix-lib'
import {ConfigPlugin} from './app/plugins/config'
import {StoragePlugin} from './app/plugins/storage'
import {Layout} from './app/panels/layout'
import {NotificationPlugin} from './app/plugins/notification'
import {Blockchain} from './blockchain/blockchain'
import {MergeVMProvider, LondonVMProvider, BerlinVMProvider, ShanghaiVMProvider, CancunVMProvider} from './app/providers/vm-provider'
import {MainnetForkVMProvider} from './app/providers/mainnet-vm-fork-provider'
import {SepoliaForkVMProvider} from './app/providers/sepolia-vm-fork-provider'
import {GoerliForkVMProvider} from './app/providers/goerli-vm-fork-provider'
import {CustomForkVMProvider} from './app/providers/custom-vm-fork-provider'
import {HardhatProvider} from './app/providers/hardhat-provider'
import {GanacheProvider} from './app/providers/ganache-provider'
import {FoundryProvider} from './app/providers/foundry-provider'
import {ExternalHttpProvider} from './app/providers/external-http-provider'
import { Registry } from '@remix-project/remix-lib'
import { ConfigPlugin } from './app/plugins/config'
import { StoragePlugin } from './app/plugins/storage'
import { Layout } from './app/panels/layout'
import { NotificationPlugin } from './app/plugins/notification'
import { Blockchain } from './blockchain/blockchain'
import { MergeVMProvider, LondonVMProvider, BerlinVMProvider, ShanghaiVMProvider, CancunVMProvider } from './app/providers/vm-provider'
import { MainnetForkVMProvider } from './app/providers/mainnet-vm-fork-provider'
import { SepoliaForkVMProvider } from './app/providers/sepolia-vm-fork-provider'
import { GoerliForkVMProvider } from './app/providers/goerli-vm-fork-provider'
import { CustomForkVMProvider } from './app/providers/custom-vm-fork-provider'
import { HardhatProvider } from './app/providers/hardhat-provider'
import { GanacheProvider } from './app/providers/ganache-provider'
import { FoundryProvider } from './app/providers/foundry-provider'
import { ExternalHttpProvider } from './app/providers/external-http-provider'
import { EnvironmentExplorer } from './app/providers/environment-explorer'
import { FileDecorator } from './app/plugins/file-decorator'
import { CodeFormat } from './app/plugins/code-format'
Expand All @@ -58,7 +58,7 @@ import { xtermPlugin } from './app/plugins/electron/xtermPlugin'
import { ripgrepPlugin } from './app/plugins/electron/ripgrepPlugin'
import { compilerLoaderPlugin, compilerLoaderPluginDesktop } from './app/plugins/electron/compilerLoaderPlugin'
import { appUpdaterPlugin } from './app/plugins/electron/appUpdaterPlugin'
import { remixAIDesktopPlugin } from './app/plugins/electron/remixAIDesktopPlugin'
import { remixAIDesktopPlugin } from './app/plugins/electron/remixAIDesktopPlugin'
import { RemixAIPlugin } from './app/plugins/remixAIPlugin'
import { SlitherHandleDesktop } from './app/plugins/electron/slitherPlugin'
import { SlitherHandle } from './app/files/slither-handle'
Expand All @@ -72,37 +72,37 @@ import { Matomo } from './app/plugins/matomo'

import { TemplatesSelectionPlugin } from './app/plugins/templates-selection/templates-selection-plugin'

const isElectron = require('is-electron')
import isElectron from 'is-electron'

const remixLib = require('@remix-project/remix-lib')
import * as remixLib from '@remix-project/remix-lib'

import { QueryParams } from '@remix-project/remix-lib'
import { SearchPlugin } from './app/tabs/search'
import { ScriptRunnerUIPlugin } from './app/tabs/script-runner-ui'
import { ElectronProvider } from './app/files/electronProvider'

const Storage = remixLib.Storage
const RemixDProvider = require('./app/files/remixDProvider')
const Config = require('./config')
import RemixDProvider from './app/files/remixDProvider'
import Config from './config'

const FileManager = require('./app/files/fileManager')
import FileManager from './app/files/fileManager'
import FileProvider from "./app/files/fileProvider"
import { appPlatformTypes } from '@remix-ui/app'

const DGitProvider = require('./app/files/dgitProvider')
const WorkspaceFileProvider = require('./app/files/workspaceFileProvider')
import DGitProvider from './app/files/dgitProvider'
import WorkspaceFileProvider from './app/files/workspaceFileProvider'

const PluginManagerComponent = require('./app/components/plugin-manager-component')
import PluginManagerComponent from './app/components/plugin-manager-component'

const CompileTab = require('./app/tabs/compile-tab')
const SettingsTab = require('./app/tabs/settings-tab')
const AnalysisTab = require('./app/tabs/analysis-tab')
const { DebuggerTab } = require('./app/tabs/debugger-tab')
const TestTab = require('./app/tabs/test-tab')
const FilePanel = require('./app/panels/file-panel')
const Editor = require('./app/editor/editor')
const Terminal = require('./app/panels/terminal')
const { TabProxy } = require('./app/panels/tab-proxy.js')
import CompileTab from './app/tabs/compile-tab'
import SettingsTab from './app/tabs/settings-tab'
import AnalysisTab from './app/tabs/analysis-tab'
import DebuggerTab from './app/tabs/debugger-tab'
import TestTab from './app/tabs/test-tab'
import Filepanel from './app/panels/file-panel'
import Editor from './app/editor/editor'
import Terminal from './app/panels/terminal'
import TabProxy from './app/panels/tab-proxy.js'

const _paq = (window._paq = window._paq || [])

Expand All @@ -115,16 +115,49 @@ export class platformApi {
}
}

type Components = {
filesProviders: {
browser?: any
localhost?: any
workspace?: any
electron?: any
}
}

class AppComponent {
appManager: RemixAppManager
queryParams: QueryParams
private _components: Components
panels: any
workspace: any
engine: RemixEngine
matomoConfAlreadySet: any
matomoCurrentSetting: any
showMatomo: boolean
walkthroughService: WalkthroughService
platform: 'desktop' | 'web'
gistHandler: GistHandler
themeModule: ThemeModule
localeModule: LocaleModule
notification: NotificationPlugin
layout: Layout
mainview: any
menuicons: VerticalIcons
sidePanel: SidePanel
hiddenPanel: HiddenPanel
pinnedPanel: PinnedPanel
popupPanel: PopupPanel
statusBar: StatusBar
settings: SettingsTab
constructor() {
const PlatFormAPi = new platformApi()
Registry.getInstance().put({
api: PlatFormAPi,
name: 'platform'
})
this.appManager = new RemixAppManager({})
this.appManager = new RemixAppManager()
this.queryParams = new QueryParams()
this._components = {}
this._components = {} as Components
// setup storage
const configStorage = new Storage('config-v0.8:')

Expand Down Expand Up @@ -161,7 +194,6 @@ class AppComponent {
name: 'fileproviders'
})


}

async run() {
Expand All @@ -184,7 +216,7 @@ class AppComponent {
this.matomoConfAlreadySet = Registry.getInstance().get('config').api.exists('settings/matomo-analytics')
this.matomoCurrentSetting = Registry.getInstance().get('config').api.get('settings/matomo-analytics')

let electronTracking = window.electronAPI ? await window.electronAPI.canTrackMatomo() : false
const electronTracking = (window as any).electronAPI ? await (window as any).electronAPI.canTrackMatomo() : false

const lastMatomoCheck = window.localStorage.getItem('matomo-analytics-consent')
const sixMonthsAgo = new Date();
Expand All @@ -193,11 +225,11 @@ class AppComponent {
const e2eforceMatomoToShow = window.localStorage.getItem('showMatomo') && window.localStorage.getItem('showMatomo') === 'true'
const contextShouldShowMatomo = matomoDomains[window.location.hostname] || e2eforceMatomoToShow || electronTracking
const shouldRenewConsent = this.matomoCurrentSetting === false && (!lastMatomoCheck || new Date(Number(lastMatomoCheck)) < sixMonthsAgo) // it is set to false for more than 6 months.
this.showMatomo = contextShouldShowMatomo && (!this.matomoConfAlreadySet || shouldRenewConsent)
this.showMatomo = contextShouldShowMatomo && (!this.matomoConfAlreadySet || shouldRenewConsent)

if (this.showMatomo && shouldRenewConsent) {
_paq.push(['trackEvent', 'Matomo', 'refreshMatomoPermissions']);
}
}

this.walkthroughService = new WalkthroughService(appManager)

Expand Down Expand Up @@ -387,7 +419,7 @@ class AppComponent {
ganacheProvider,
foundryProvider,
externalHttpProvider,
environmentExplorer,
environmentExplorer,
this.walkthroughService,
search,
solidityumlgen,
Expand Down Expand Up @@ -456,10 +488,10 @@ class AppComponent {
this.popupPanel = new PopupPanel()

const pluginManagerComponent = new PluginManagerComponent(appManager, this.engine)
const filePanel = new FilePanel(appManager, contentImport)
const filePanel = new Filepanel(appManager, contentImport)
this.statusBar = new StatusBar(filePanel, this.menuicons)
const landingPage = new LandingPage(appManager, this.menuicons, fileManager, filePanel, contentImport)
this.settings = new SettingsTab(Registry.getInstance().get('config').api, editor, appManager)
this.settings = new SettingsTab(Registry.getInstance().get('config').api, editor)//, appManager)

this.engine.register([this.menuicons, landingPage, this.hiddenPanel, this.sidePanel, this.statusBar, filePanel, pluginManagerComponent, this.settings, this.pinnedPanel, this.popupPanel])

Expand Down Expand Up @@ -514,7 +546,7 @@ class AppComponent {

async activate() {
const queryParams = new QueryParams()
const params = queryParams.get()
const params: any = queryParams.get()

try {
this.engine.register(await this.appManager.registeredPlugins())
Expand Down Expand Up @@ -610,10 +642,11 @@ class AppComponent {
}

if (params.call) {
const callDetails = params.call.split('//')
const callDetails: any = params.call.split('//')
if (callDetails.length > 1) {
this.appManager.call('notification', 'toast', `initiating ${callDetails[0]} and calling "${callDetails[1]}" ...`)
// @todo(remove the timeout when activatePlugin is on 0.3.0)
//@ts-ignore
await this.appManager.call(...callDetails).catch(console.error)
}
}
Expand All @@ -629,6 +662,7 @@ class AppComponent {

// @todo(remove the timeout when activatePlugin is on 0.3.0)
try {
//@ts-ignore
await this.appManager.call(...callDetails)
} catch (e) {
console.error(e)
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/components/main-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const profile = {
export class MainPanel extends AbstractPanel {
element: HTMLDivElement
dispatch: React.Dispatch<any> = () => {}
constructor(config) {
constructor(config = null) {
super(profile)
this.element = document.createElement('div')
this.element.setAttribute('data-id', 'mainPanelPluginsContainer')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const profile = {
maintainedBy: "Remix"
}

class PluginManagerComponent extends ViewPlugin {
export default class PluginManagerComponent extends ViewPlugin {
constructor (appManager, engine) {
super(profile)
this.appManager = appManager
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/components/popup-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class PopupPanel extends AbstractPanel {
dispatch: React.Dispatch<any> = () => { }
appStateDispatch: React.Dispatch<AppAction> = () => { }

constructor(config) {
constructor(config = null) {
super(profile)
this.event = new EventEmitter()
}
Expand Down
12 changes: 5 additions & 7 deletions apps/remix-ide/src/app/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const profile = {
methods: ['highlight', 'discardHighlight', 'clearAnnotations', 'addLineText', 'discardLineTexts', 'addAnnotation', 'gotoLine', 'revealRange', 'getCursorPosition', 'open', 'addModel','addErrorMarker', 'clearErrorMarkers', 'getText', 'getPositionAt', 'openReadOnly'],
}

class Editor extends Plugin {
export default class Editor extends Plugin {
constructor () {
super(profile)

Expand Down Expand Up @@ -90,7 +90,7 @@ class Editor extends Plugin {
}

render () {
return <div ref={(element)=>{
return <div ref={(element)=>{
this.ref = element
this.ref.currentContent = () => this.currentContent() // used by e2e test
this.ref.setCurrentContent = (value) => {
Expand All @@ -102,7 +102,7 @@ class Editor extends Plugin {
this.ref.gotoLine = (line, column) => this.gotoLine(line, column || 0)
this.ref.getCursorPosition = () => this.getCursorPosition()
this.ref.addDecoration = (marker, filePath, typeOfDecoration) => this.addDecoration(marker, filePath, typeOfDecoration)
this.ref.clearDecorationsByPlugin = (filePath, plugin, typeOfDecoration) => this.clearDecorationsByPlugin(filePath, plugin, typeOfDecoration)
this.ref.clearDecorationsByPlugin = (filePath, plugin, typeOfDecoration) => this.clearDecorationsByPlugin(filePath, plugin, typeOfDecoration)
this.ref.keepDecorationsFor = (name, typeOfDecoration) => this.keepDecorationsFor(name, typeOfDecoration)
}} id='editorView'>
<PluginViewWrapper plugin={this} />
Expand Down Expand Up @@ -249,7 +249,7 @@ class Editor extends Plugin {
*/
async _createSession (path, content, mode, readOnly) {
if (!this.activated) return

this.emit('addModel', content, mode, path, readOnly || this.readOnlySessions[path])
return {
path,
Expand Down Expand Up @@ -548,7 +548,7 @@ class Editor extends Plugin {
decoration.from = from

const { currentDecorations, registeredDecorations } = this.api.addDecoration(decoration, path, typeOfDecoration)
if (!this.registeredDecorations[typeOfDecoration][filePath]) this.registeredDecorations[typeOfDecoration][filePath] = []
if (!this.registeredDecorations[typeOfDecoration][filePath]) this.registeredDecorations[typeOfDecoration][filePath] = []
this.registeredDecorations[typeOfDecoration][filePath].push(...registeredDecorations)
if (!this.currentDecorations[typeOfDecoration][filePath]) this.currentDecorations[typeOfDecoration][filePath] = []
this.currentDecorations[typeOfDecoration][filePath].push(...currentDecorations)
Expand Down Expand Up @@ -601,5 +601,3 @@ class Editor extends Plugin {
return this.api.getPositionAt(offset)
}
}

module.exports = Editor
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/files/dgitProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const profile: LibraryProfile = {
, 'getGitHubUser', 'remotebranches', 'remotecommits', 'repositories', 'getCommitChanges', 'compareBranches'],
kind: 'file-system'
}
class DGitProvider extends Plugin<any, CustomRemixApi> {
export default class DGitProvider extends Plugin<any, CustomRemixApi> {
constructor() {
super(profile)
}
Expand Down
Loading

0 comments on commit def0f7d

Please sign in to comment.