Skip to content

Commit

Permalink
Merge branch 'master' into cancel-metamask-connection
Browse files Browse the repository at this point in the history
  • Loading branch information
LianaHus authored Dec 9, 2024
2 parents 7cdf946 + be2459e commit 84582ad
Show file tree
Hide file tree
Showing 18 changed files with 433 additions and 8 deletions.
3 changes: 3 additions & 0 deletions apps/noir-compiler/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.json",
}
67 changes: 67 additions & 0 deletions apps/noir-compiler/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "noir-compiler",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/noir-compiler/src",
"projectType": "application",
"implicitDependencies": [],
"targets": {
"build": {
"executor": "@nrwl/webpack:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "development",
"options": {
"compiler": "babel",
"outputPath": "dist/apps/noir-compiler",
"index": "apps/noir-compiler/src/index.html",
"baseHref": "./",
"main": "apps/noir-compiler/src/main.tsx",
"polyfills": "apps/noir-compiler/src/polyfills.ts",
"tsConfig": "apps/noir-compiler/tsconfig.app.json",
"assets": ["apps/noir-compiler/src/profile.json", "apps/noir-compiler/src/snarkjs.min.js"],
"styles": ["apps/noir-compiler/src/css/app.css"],
"scripts": [],
"webpackConfig": "apps/noir-compiler/webpack.config.js"
},
"configurations": {
"development": {
},
"production": {
"fileReplacements": [
{
"replace": "apps/noir-compiler/src/environments/environment.ts",
"with": "apps/noir-compiler/src/environments/environment.prod.ts"
}
]
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/noir-compiler/**/*.ts"],
"eslintConfig": "apps/noir-compiler/.eslintrc"
}
},
"serve": {
"executor": "@nrwl/webpack:dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "noir-compiler:build",
"hmr": true,
"baseHref": "/"
},
"configurations": {
"development": {
"buildTarget": "noir-compiler:build:development",
"port": 2023
},
"production": {
"buildTarget": "noir-compiler:build:production"
}
}
}
},
"tags": []
}

23 changes: 23 additions & 0 deletions apps/noir-compiler/src/app/services/noirPluginClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { PluginClient } from '@remixproject/plugin'
import { createClient } from '@remixproject/plugin-webview'
import EventManager from 'events'

export class NoirPluginClient extends PluginClient {
public internalEvents: EventManager

constructor() {
super()
this.methods = ['init']
createClient(this)
this.internalEvents = new EventManager()
this.onload()
}

init(): void {
console.log('initializing noir plugin...')
}

onActivation(): void {
this.internalEvents.emit('noir_activated')
}
}
22 changes: 22 additions & 0 deletions apps/noir-compiler/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Noir - Compiler</title>
<base href="./" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous"/> -->
<!-- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"> -->
<link rel="stylesheet" integrity="ha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf"
crossorigin="anonymous" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
</head>
<body>
<script>
var global = window
</script>
<div id="root"></div>
<script src="snarkjs.min.js"> </script>
<script src="https://kit.fontawesome.com/41dd021e94.js" crossorigin="anonymous"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions apps/noir-compiler/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { createRoot } from 'react-dom/client'

const container = document.getElementById('root')

if (container) {
createRoot(container).render(<></>)
}
7 changes: 7 additions & 0 deletions apps/noir-compiler/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Polyfill stable language features. These imports will be optimized by `@babel/preset-env`.
*
* See: https://github.com/zloirock/core-js#babel
*/
import 'core-js/stable';
import 'regenerator-runtime/runtime';
17 changes: 17 additions & 0 deletions apps/noir-compiler/src/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "noir-compiler",
"kind": "provider",
"displayName": "Noir Compiler",
"events": [],
"version": "2.0.0",
"methods": ["init", "parse"],
"canActivate": [],
"url": "",
"description": "Enables support for noir circuit compilation",
"icon": "assets/img/circom-icon-bw-800b.webp",
"location": "sidePanel",
"documentation": "",
"repo": "https://github.com/ethereum/remix-project/tree/master/apps/noir-compiler",
"maintainedBy": "Remix",
"authorContact": ""
}
9 changes: 9 additions & 0 deletions apps/noir-compiler/src/snarkjs.min.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions apps/noir-compiler/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"]
},
"files": [
"../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
"../../node_modules/@nrwl/react/typings/image.d.ts"
],
"exclude": [
"jest.config.ts",
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}

17 changes: 17 additions & 0 deletions apps/noir-compiler/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
}
]
}

92 changes: 92 additions & 0 deletions apps/noir-compiler/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
const { composePlugins, withNx } = require('@nrwl/webpack')
const webpack = require('webpack')
const TerserPlugin = require("terser-webpack-plugin")
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin")

// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
// Update the webpack config as needed here.
// e.g. `config.plugins.push(new MyPlugin())`
// add fallback for node modules
config.resolve.fallback = {
...config.resolve.fallback,
"crypto": require.resolve("crypto-browserify"),
"stream": require.resolve("stream-browserify"),
"path": require.resolve("path-browserify"),
"http": require.resolve("stream-http"),
"https": require.resolve("https-browserify"),
"constants": require.resolve("constants-browserify"),
"os": false, //require.resolve("os-browserify/browser"),
"timers": false, // require.resolve("timers-browserify"),
"zlib": require.resolve("browserify-zlib"),
"fs": false,
"module": false,
"tls": false,
"net": false,
"readline": false,
"child_process": false,
"buffer": require.resolve("buffer/"),
"vm": require.resolve('vm-browserify'),
}


// add externals
config.externals = {
...config.externals,
solc: 'solc',
}

// add public path
config.output.publicPath = './'

// add copy & provide plugin
config.plugins.push(
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
url: ['url', 'URL'],
process: 'process/browser',
})
)

// set the define plugin to load the WALLET_CONNECT_PROJECT_ID
config.plugins.push(
new webpack.DefinePlugin({
WALLET_CONNECT_PROJECT_ID: JSON.stringify(process.env.WALLET_CONNECT_PROJECT_ID),
})
)

// souce-map loader
config.module.rules.push({
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
})

config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings


// set minimizer
config.optimization.minimizer = [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 2015,
compress: false,
mangle: false,
format: {
comments: false,
},
},
extractComments: false,
}),
new CssMinimizerPlugin(),
];

config.watchOptions = {
ignored: /node_modules/
}

config.experiments.syncWebAssembly = true

return config;
});
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Editor extends Plugin {
ts: 'typescript',
move: 'move',
circom: 'circom',
nr: 'rust',
nr: 'noir',
toml: 'toml'
}

Expand Down
4 changes: 2 additions & 2 deletions apps/remixdesktop/TEST.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# How run and write tests for Remix Desktop
# How to run and write tests for Remix Desktop


### Basic procedure of local testing
Expand Down Expand Up @@ -107,7 +107,7 @@ module.exports = {

Always use this, it avoids trouble:
```
rowser.hideToolTips()
browser.hideToolTips()
```


Expand Down
4 changes: 2 additions & 2 deletions libs/remix-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Example to understand the use of special methods can be found [here in tests](te

#### Use a different sender `msg.sender`

It is quite common that a contract need to be tested in different situation.
It is quite common that a contract needs to be tested in different situation.
Especially being able to set before hand the sender account (`msg.sender`) used for a specific tests suite enable quite a lot a new test use cases.
please checkout this [test contract](tests/various_sender/sender_and_value_test.sol) for an example.
Note that `TestsAccounts` is filled with all the accounts available in `web3.eth.accounts()`.
Expand Down Expand Up @@ -208,7 +208,7 @@ Loading remote solc version v0.7.4+commit.3f05b770 ...
returned: 1
```

:point_right: remix-test can also be used for continuous integration testing. See example [Su Squares contract](https://github.com/su-squares/ethereum-contract/tree/e542f37d4f8f6c7b07d90a6554424268384a4186) and [Travis build](https://travis-ci.org/su-squares/ethereum-contract/builds/446186067)
:point_right: remix-test can also be used for continuous integration testing. See an example [Su Squares contract](https://github.com/su-squares/ethereum-contract/tree/e542f37d4f8f6c7b07d90a6554424268384a4186) and [Travis build](https://travis-ci.org/su-squares/ethereum-contract/builds/446186067)

#### As a Library for development

Expand Down
8 changes: 8 additions & 0 deletions libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { RemixDefinitionProvider } from './providers/definitionProvider'
import { RemixCodeActionProvider } from './providers/codeActionProvider'
import './remix-ui-editor.css'
import { circomLanguageConfig, circomTokensProvider } from './syntaxes/circom'
import { noirLanguageConfig, noirTokensProvider } from './syntaxes/noir'
import { IPosition } from 'monaco-editor'
import { RemixInLineCompletionProvider } from './providers/inlineCompletionProvider'
import { providers } from 'ethers'
Expand Down Expand Up @@ -248,6 +249,7 @@ export const EditorUI = (props: EditorUIProps) => {
{ token: 'keyword.selfdestruct', foreground: blueColor },
{ token: 'keyword.type ', foreground: blueColor },
{ token: 'keyword.gasleft', foreground: blueColor },
{ token: 'function', foreground: blueColor, fontStyle: 'bold' },

// specials
{ token: 'keyword.super', foreground: infoColor },
Expand Down Expand Up @@ -365,6 +367,8 @@ export const EditorUI = (props: EditorUIProps) => {
monacoRef.current.editor.setModelLanguage(file.model, 'remix-circom')
} else if (file.language === 'toml') {
monacoRef.current.editor.setModelLanguage(file.model, 'remix-toml')
} else if (file.language === 'noir') {
monacoRef.current.editor.setModelLanguage(file.model, 'remix-noir')
}
}, [props.currentFile, props.isDiff])

Expand Down Expand Up @@ -994,6 +998,7 @@ export const EditorUI = (props: EditorUIProps) => {
monacoRef.current.languages.register({ id: 'remix-move' })
monacoRef.current.languages.register({ id: 'remix-circom' })
monacoRef.current.languages.register({ id: 'remix-toml' })
monacoRef.current.languages.register({ id: 'remix-noir' })

// Allow JSON schema requests
monacoRef.current.languages.json.jsonDefaults.setDiagnosticsOptions({ enableSchemaRequest: true })
Expand All @@ -1020,6 +1025,9 @@ export const EditorUI = (props: EditorUIProps) => {
monacoRef.current.languages.setMonarchTokensProvider('remix-toml', tomlTokenProvider as any)
monacoRef.current.languages.setLanguageConfiguration('remix-toml', tomlLanguageConfig as any)

monacoRef.current.languages.setMonarchTokensProvider('remix-noir', noirTokensProvider as any)
monacoRef.current.languages.setLanguageConfiguration('remix-noir', noirLanguageConfig as any)

monacoRef.current.languages.registerDefinitionProvider('remix-solidity', new RemixDefinitionProvider(props, monaco))
monacoRef.current.languages.registerDocumentHighlightProvider('remix-solidity', new RemixHighLightProvider(props, monaco))
monacoRef.current.languages.registerReferenceProvider('remix-solidity', new RemixReferenceProvider(props, monaco))
Expand Down
Loading

0 comments on commit 84582ad

Please sign in to comment.