Skip to content

Commit

Permalink
Merge branch 'master' into fe-hoverIcons
Browse files Browse the repository at this point in the history
  • Loading branch information
LianaHus authored Jan 16, 2024
2 parents 7f742b4 + c83b154 commit 57cb76f
Show file tree
Hide file tree
Showing 26 changed files with 170 additions and 139 deletions.
6 changes: 4 additions & 2 deletions apps/circuit-compiler/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ function App() {
dispatch({ type: 'SET_FILE_PATH_TO_ID', payload: filePathToId })
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: null })
})
plugin.internalEvents.on('circuit_parsing_errored', (report) => {
plugin.internalEvents.on('circuit_parsing_errored', (report, filePathToId) => {
dispatch({ type: 'SET_FILE_PATH_TO_ID', payload: filePathToId })
dispatch({ type: 'SET_COMPILER_STATUS', payload: 'errored' })
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: report })
})
plugin.internalEvents.on('circuit_parsing_warning', (report) => {
plugin.internalEvents.on('circuit_parsing_warning', (report, filePathToId) => {
dispatch({ type: 'SET_FILE_PATH_TO_ID', payload: filePathToId })
dispatch({ type: 'SET_COMPILER_STATUS', payload: 'warning' })
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: report })
})
Expand Down
9 changes: 8 additions & 1 deletion apps/circuit-compiler/src/app/components/witness.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ export function WitnessSection ({ plugin, signalInputs, status }: {plugin: Circo
const [witnessValues, setWitnessValues] = useState<Record<string, string>>({})

const handleSignalInput = (e: any) => {
let value = e.target.value

try {
value = JSON.parse(value)
} catch (e) {
// do nothing
}
setWitnessValues({
...witnessValues,
[e.target.name]: e.target.value
[e.target.name]: value
})
}

Expand Down
117 changes: 70 additions & 47 deletions apps/circuit-compiler/src/app/services/circomPluginClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class CircomPluginClient extends PluginClient {
// @ts-ignore
fileContent = await this.call('fileManager', 'readFile', path)
}
this.lastParsedFiles = await this.resolveDependencies(path, fileContent, { [path]: { content: fileContent, parent: null } })
this.lastParsedFiles = await this.resolveDependencies(path, fileContent)
const parsedOutput = this.compiler.parse(path, this.lastParsedFiles)

try {
Expand Down Expand Up @@ -127,10 +127,10 @@ export class CircomPluginClient extends PluginClient {

if (parseErrors && (parseErrors.length > 0)) {
if (parseErrors[0].type === 'Error') {
this.internalEvents.emit('circuit_parsing_errored', parseErrors)
this.internalEvents.emit('circuit_parsing_errored', parseErrors, filePathToId)
return
} else if (parseErrors[0].type === 'Warning') {
this.internalEvents.emit('circuit_parsing_warning', parseErrors)
this.internalEvents.emit('circuit_parsing_warning', parseErrors, filePathToId)
}
} else {
this.internalEvents.emit('circuit_parsing_done', parseErrors, filePathToId)
Expand Down Expand Up @@ -220,15 +220,17 @@ export class CircomPluginClient extends PluginClient {
this.internalEvents.emit('circuit_computing_witness_done')
}

async resolveDependencies(filePath: string, fileContent: string, output: ResolverOutput = {}, depPath: string = '', parent: string = ''): Promise<Record<string, string>> {
async resolveDependencies(filePath: string, fileContent: string, output?: Record<string, string>, depPath: string = '', blackPath: string[] = []): Promise<Record<string, string>> {
if (!output) output = { [filePath]: fileContent }
// extract all includes
const includes = (fileContent.match(/include ['"].*['"]/g) || []).map((include) => include.replace(/include ['"]/g, '').replace(/['"]/g, ''))

await Promise.all(
includes.map(async (include) => {
// fix for endless recursive includes
if (blackPath.includes(include)) return
let dependencyContent = ''
let path = include
let path = include.replace(/(\.\.\/)+/g, '')
// @ts-ignore
const pathExists = await this.call('fileManager', 'exists', path)

Expand All @@ -248,23 +250,35 @@ export class CircomPluginClient extends PluginClient {

if (relativePathExists) {
// fetch file content if include import exists as a relative path
path = relativePath
dependencyContent = await this.call('fileManager', 'readFile', relativePath)
} else {
if (include.startsWith('circomlib')) {
// try to resolve include import from github if it is a circomlib dependency
const splitInclude = include.split('/')
const version = splitInclude[1].match(/v[0-9]+.[0-9]+.[0-9]+/g)

if (version && version[0]) {
path = `https://raw.githubusercontent.com/iden3/circomlib/${version[0]}/circuits/${splitInclude.slice(2).join('/')}`
dependencyContent = await this.call('contentImport', 'resolveAndSave', path, null)
} else {
path = `https://raw.githubusercontent.com/iden3/circomlib/master/circuits/${splitInclude.slice(1).join('/')}`
dependencyContent = await this.call('contentImport', 'resolveAndSave', path, null)
try {
// try to resolve include import from .deps folder
if (version && version[0]) {
path = `.deps/https/raw.githubusercontent.com/iden3/circomlib/${version[0]}/${splitInclude.slice(2).join('/')}`
dependencyContent = await this.call('contentImport', 'resolveAndSave', path, null)
} else {
path = `.deps/https/raw.githubusercontent.com/iden3/circomlib/master/${splitInclude.slice(1).join('/')}`
dependencyContent = await this.call('contentImport', 'resolveAndSave', path, null)
}
} catch (e) {
// try to resolve include import from github if it is a circomlib dependency
if (version && version[0]) {
path = `https://raw.githubusercontent.com/iden3/circomlib/${version[0]}/${splitInclude.slice(2).join('/')}`
dependencyContent = await this.call('contentImport', 'resolveAndSave', path, null)
} else {
path = `https://raw.githubusercontent.com/iden3/circomlib/master/${splitInclude.slice(1).join('/')}`
dependencyContent = await this.call('contentImport', 'resolveAndSave', path, null)
}
}
} else {
if (depPath) {
// if depPath is provided, try to resolve include import from './deps' folder in remix
// resolves relative dependecies for .deps folder
path = pathModule.resolve(depPath.slice(0, depPath.lastIndexOf('/')), include)
path = path.replace('https:/', 'https://')
if (path.indexOf('/') === 0) path = path.slice(1)
Expand All @@ -276,43 +290,52 @@ export class CircomPluginClient extends PluginClient {
}
}
}
const fileNameToInclude = extractNameFromKey(include)
const similarFile = Object.keys(output).find(path => {
return path.indexOf(fileNameToInclude) > -1
})
const isDuplicateContent = similarFile && output[similarFile] ? output[similarFile].content === dependencyContent : false

if (output[include] && output[include].parent) {
// if include import already exists, remove the include import from the parent file
const regexPattern = new RegExp(`include ['"]${include}['"];`, 'g')

output[output[include].parent].content = output[output[include].parent].content.replace(regexPattern, "")
} else if (isDuplicateContent) {
// if include import has the same content as another file, replace the include import with the file name of the other file (similarFile)
if (output[similarFile].parent) output[output[similarFile].parent].content = output[output[similarFile].parent].content.replace(similarFile, include)
if (include !== similarFile) {
output[include] = output[similarFile]
delete output[similarFile]
}
if (path.indexOf('https://') === 0) {
// Regular expression to match include statements and make deps imports uniform
const includeRegex = /include "(.+?)";/g
const replacement = 'include "circomlib/circuits/$1";'

dependencyContent = dependencyContent.replace(includeRegex, replacement)
} else {
// extract all includes from the dependency content
const dependencyIncludes = (dependencyContent.match(/include ['"].*['"]/g) || []).map((include) => include.replace(/include ['"]/g, '').replace(/['"]/g, ''))

output[include] = {
content: dependencyContent,
parent
if (!include.startsWith('circomlib') && !pathModule.isAbsolute(filePath) && !pathModule.isAbsolute(path)) {
// if include is not absolute, resolve it using the parent path of the current file opened in editor
const absIncludePath = pathModule.resolve('/' + filePath.slice(0, filePath.lastIndexOf('/')), '/' + path)

output[filePath] = output[filePath].replace(`${include}`, `${absIncludePath}`)
include = absIncludePath
}
// recursively resolve all dependencies of the dependency
if (dependencyIncludes.length > 0) await this.resolveDependencies(filePath, dependencyContent, output, path, include)
}
// extract all includes from the dependency content
const dependencyIncludes = (dependencyContent.match(/include ['"].*['"]/g) || []).map((childInclude) => {
const includeName = childInclude.replace(/include ['"]/g, '').replace(/['"]/g, '')
let absFilePath = pathModule.resolve(include.slice(0, include.lastIndexOf('/')), includeName)

absFilePath = include.startsWith('circomlib') ? absFilePath.substring(1) : absFilePath
if (!blackPath.includes(absFilePath)) {
if(!includeName.startsWith('circomlib')) {
dependencyContent = dependencyContent.replace(`${includeName}`, `${absFilePath}`)
return absFilePath
}
return includeName
} else {
// if include already exists in output, remove it from the dependency content
const includePattern = new RegExp(`include "\\s*${includeName}\\s*";`, 'g')

dependencyContent = dependencyContent.replace(includePattern, '')
return
}
}).filter((childInclude) => childInclude)
blackPath.push(include)
// recursively resolve all dependencies of the dependency
if (dependencyIncludes.length > 0) {
await this.resolveDependencies(filePath, dependencyContent, output, path, blackPath)
output[include] = dependencyContent
} else {
output[include] = dependencyContent
}
})
)
const result: Record<string, string> = {}

Object.keys(output).forEach((key) => {
result[key] = output[key].content
})
return result
return output
}

async resolveReportPath (path: string): Promise<string> {
Expand All @@ -335,9 +358,9 @@ export class CircomPluginClient extends PluginClient {
const version = splitInclude[1].match(/v[0-9]+.[0-9]+.[0-9]+/g)

if (version && version[0]) {
path = `/.deps/https/raw.githubusercontent.com/iden3/circomlib/${version[0]}/circuits/${splitInclude.slice(2).join('/')}`
path = `/.deps/https/raw.githubusercontent.com/iden3/circomlib/${version[0]}/${splitInclude.slice(2).join('/')}`
} else {
path = `/.deps/https/raw.githubusercontent.com/iden3/circomlib/master/circuits/${splitInclude.slice(1).join('/')}`
path = `/.deps/https/raw.githubusercontent.com/iden3/circomlib/master/${splitInclude.slice(1).join('/')}`
}
// @ts-ignore
const exists = await this.call('fileManager', 'exists', path)
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/meetings.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ RemixProject/IDE
## browser test

a PR (https://github.com/ethereum/remix-ide/pull/1961) is waiting for merging @yann
It iwll be followed by other PRs, aiming to improve process of writting browser tests.
It will be followed by other PRs, aiming to improve process of writing browser tests.

## desktop version

Expand Down
8 changes: 7 additions & 1 deletion apps/remix-ide/src/app/files/workspaceFileProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ class WorkspaceFileProvider extends FileProvider {

try {
// make sure "code-sample" has been removed
window.remixFileSystem.unlink(this.workspacesPath + '/code-sample')
window.remixFileSystem.exists(this.workspacesPath + '/code-sample').then((exist) => {
if (exist) window.remixFileSystem.unlink(this.workspacesPath + '/code-sample').catch((e) => {
console.log(e)
})
}).catch((e) => {
console.log(e)
})
} catch (e) {
// we don't need to log error if this throws an error
}
Expand Down
1 change: 0 additions & 1 deletion apps/remix-ide/src/app/plugins/remixd-handle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class RemixdHandle extends WebsocketPlugin {
}

async activate() {
console.trace('activate remixd')
this.connectToLocalhost()
return true
}
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/tabs/locales/en/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"search.displayName": "Search in files",
"search.replace": "Replace",
"search.replaceAll": "Replace All",
"search.placeholder1": "Search ( Enter to search )",
"search.placeholder1": "Type to search",
"search.placeholder2": "Include ie *.sol ( Enter to include )",
"search.placeholder3": "Exclude ie .git/**/* ( Enter to exclude )",
"search.matchCase": "Match Case",
Expand Down
1 change: 1 addition & 0 deletions apps/remix-ide/src/app/tabs/locales/en/terminal.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"terminal.listen": "listen on all transactions",
"terminal.listenVM": "Listen on all transactions is disabled for VM environment",
"terminal.listenTitle": "If checked Remix will listen on all transactions mined in the current environment and not only transactions created by you",
"terminal.search": "Search with transaction hash or address",
"terminal.used": "used",
Expand Down
6 changes: 6 additions & 0 deletions apps/remix-ide/src/app/tabs/network-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ export class NetworkModule extends Plugin {
constructor (blockchain) {
super(profile)
this.blockchain = blockchain

// TODO: See with remix-lib to make sementic coherent
this.blockchain.event.register('contextChanged', (provider) => {
this.emit('providerChanged', provider)
})
}

onActivation () {
// emit the initial provider type
this.emit('providerChanged', this.blockchain.getProvider)
}

/** Return the current network provider (web3, vm, injected) */
getNetworkProvider () {
return this.blockchain.getProvider()
Expand Down
4 changes: 3 additions & 1 deletion apps/remix-ide/src/remixAppManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ let requiredModules = [ // services + layout views + system views
'openaigpt',
'home',
'doc-viewer',
'doc-gen'
'doc-gen',
'copilot-suggestion',
'remix-templates'
]


Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/team-best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Before starting coding, we should ensure all devs / contributors are aware of:
Your feedback will often be better received if you pose it in the form of a question.

- Pull request should be reviewed to comply to coding best practices.
- You should take the responsability of the PR you are reviewing.
- You should take the responsibility of the PR you are reviewing.
- You should make sure the app is viable after the PR is being merged.
- You should make sure the PR is correctly tested (e2e tests, unit tests)
- Ideally You should have enough knowledge to be able to fix related bugs.
Expand Down
2 changes: 1 addition & 1 deletion libs/remix-debug/src/solidity-decoder/types/Mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Mapping extends RefType {
}

function getMappingLocation (key, position) {
// mapping storage location decribed at http://solidity.readthedocs.io/en/develop/miscellaneous.html#layout-of-state-variables-in-storage
// mapping storage location described at http://solidity.readthedocs.io/en/develop/miscellaneous.html#layout-of-state-variables-in-storage
// > the value corresponding to a mapping key k is located at keccak256(k . p) where . is concatenation.

// key should be a hex string, and position an int
Expand Down
2 changes: 1 addition & 1 deletion libs/remix-debug/src/storage/mappingPreimages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { sub } from '../solidity-decoder/types/util'
*
* @param {Object} storage - storage given by storage Viewer (basically a mapping hashedkey : {key, value})
* @param {Array} corrections - used in case the calculated sha3 has been modifyed before SSTORE (notably used for struct in mapping).
* @param {Function} callback - calback
* @param {Function} callback - callback
* @return {Map} - solidity mapping location (e.g { "<mapping_slot>" : { "<mapping-key1>": preimageOf1 }, { "<mapping-key2>": preimageOf2 }, ... })
*/
export async function decodeMappingsKeys (web3, storage, corrections) {
Expand Down
6 changes: 3 additions & 3 deletions libs/remix-tests/src/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

/**
* @dev Get function name using method signature
* @param signature siganture
* @param signature signature
* @param methodIdentifiers Object containing all methods identifier
*/

Expand Down Expand Up @@ -72,7 +72,7 @@ function isNodeTypeIn (node: AstNode, typesList: string[]): boolean {

/**
* @dev Get overrided sender provided using natspec
* @param userdoc method user documentaion
* @param userdoc method user documentation
* @param signature signature
* @param methodIdentifiers Object containing all methods identifier
*/
Expand All @@ -86,7 +86,7 @@ function getOverridedSender (userdoc: UserDocumentation, signature: string, meth

/**
* @dev Get value provided using natspec
* @param userdoc method user documentaion
* @param userdoc method user documentation
* @param signature signature
* @param methodIdentifiers Object containing all methods identifier
*/
Expand Down
4 changes: 2 additions & 2 deletions libs/remix-ui/home-tab/src/lib/components/homeTabTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function HomeTabTitle() {
openLink('https://twitter.com/EthereumRemix')
_paq.push(['trackEvent', 'hometab', 'socialMedia', 'twitter'])
}}
className="border-0 px-1 h-100 btn fab fa-twitter"
className="border-0 px-1 h-100 btn fab fa-x-twitter"
></button>
</CustomTooltip>
<CustomTooltip
Expand All @@ -106,7 +106,7 @@ function HomeTabTitle() {
openLink('https://www.linkedin.com/company/ethereum-remix/')
_paq.push(['trackEvent', 'hometab', 'socialmedia', 'linkedin'])
}}
className="border-0 px-1 h-100 btn fa fa-linkedin"
className="border-0 px-1 h-100 btn fab fa-linkedin"
></button>
</CustomTooltip>
<CustomTooltip
Expand Down
4 changes: 2 additions & 2 deletions libs/remix-ui/search/src/lib/components/Find.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const Find = () => {
>
<div
data-id="search_case_sensitive"
className={`monaco-custom-checkbox codicon codicon-case-sensitive ${state.casesensitive ? 'checked' : ''}`}
className={`monaco-custom-checkbox codicon codicon-case-sensitive mx-2 ${state.casesensitive ? 'checked' : ''}`}
role="checkbox"
aria-checked="false"
aria-label="Match Case"
Expand All @@ -70,7 +70,7 @@ export const Find = () => {
>
<div
data-id="search_whole_word"
className={`monaco-custom-checkbox codicon codicon-whole-word ${state.matchWord ? 'checked' : ''}`}
className={`monaco-custom-checkbox codicon codicon-whole-word mr-2 ${state.matchWord ? 'checked' : ''}`}
role="checkbox"
aria-checked="false"
aria-label="Match Whole Word"
Expand Down
Loading

0 comments on commit 57cb76f

Please sign in to comment.