diff --git a/.gitignore b/.gitignore index 48697ac7dd..006ec003be 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,8 @@ apps/remixdesktop/build* apps/remixdesktop/reports apps/remixdesktop/logs/ apps/remixdesktop/bin/ +apps/remixdesktop/circom-windows-amd64.exe +apps/remixdesktop/circom-macos-amd64 +apps/remixdesktop/circom-linux-amd64 +apps/remixdesktop/log_input_signals.txt logs diff --git a/apps/circuit-compiler/src/app/components/versions.tsx b/apps/circuit-compiler/src/app/components/versions.tsx index 4b129d8225..f9f9e55884 100644 --- a/apps/circuit-compiler/src/app/components/versions.tsx +++ b/apps/circuit-compiler/src/app/components/versions.tsx @@ -1,26 +1,186 @@ -import { RenderIf } from "@remix-ui/helper"; import { AppState } from "../types"; +import { Dropdown } from "react-bootstrap"; +import React, { Ref } from "react"; export function VersionList ({ currentVersion, versionList, setVersion }: { versionList: AppState['versionList'], currentVersion: string, setVersion: (version: string) => void }) { const versionListKeys = Object.keys(versionList) - return ( - + + +
+ { versionList[currentVersion].name } +
+
+ + + { + versionListKeys.map((version, index) => ( + { + setVersion(version) + }}> +
+
+ { versionList[version].name } +
+
+
+ )) + } +
+
) } + +const CircomVersionMenuToggle = React.forwardRef( + ( + { + children, + onClick, + className = '' + }: { + children: React.ReactNode + onClick: (e) => void + className: string + }, + ref: Ref + ) => ( + + ) +) + +const CircomVersionMenu = React.forwardRef( + ( + { + children, + style, + 'data-id': dataId, + className, + 'aria-labelledby': labeledBy + }: { + 'children': React.ReactNode + 'style'?: React.CSSProperties + 'data-id'?: string + 'className': string + 'aria-labelledby'?: string + }, + ref: Ref + ) => { + const height = window.innerHeight * 0.6 + return ( +
+
    + {children} +
+
+ ) + } +) + +// export const CompilerDropdown = (props: compilerDropdownProps) => { +// const online = useContext(onLineContext) +// const platform = useContext(platformContext) +// const { customVersions, selectedVersion, defaultVersion, allversions, handleLoadVersion, _shouldBeAdded, onlyDownloaded } = props +// return ( +// +// +//
+//
+// {customVersions.map((url, i) => { +// if (selectedVersion === url) return (custom) +// })} +// {allversions.map((build, i) => { + +// if ((selectedVersion || defaultVersion) === build.path) { +// return ({build.longVersion}) +// } +// })} +//
+//
+//
+ +// +// {allversions.length <= 0 && ( +// {}} +// > +//
+// {selectedVersion === defaultVersion ? : null} +//
+//
+// {defaultVersion} +//
+//
+//
+//
+// )} +// {allversions.length <= 0 && ( +// {}} +// > +//
+// {selectedVersion === "builtin" ? : null} +//
+//
+// builtin +//
+//
+//
+//
+// )} +// {customVersions.map((url, i) => ( +// handleLoadVersion(url)} +// > +//
+// {selectedVersion === url ? : null} +//
+//
+// custom: {url} +//
+//
+//
+//
+// ))} +// {allversions.map((build, i) => { +// if (onlyDownloaded && !build.isDownloaded) return null +// return _shouldBeAdded(build.longVersion) ? ( +// handleLoadVersion(build.path)} +// > +//
+// {selectedVersion === build.path ? : null} +//
+//
+// {build.longVersion} +//
+//
+// {platform == appPlatformTypes.desktop ? (build.isDownloaded ?
:
) : null} +//
+//
+// ) : null +// })} +//
+//
+// ); diff --git a/apps/circuit-compiler/src/app/services/circomPluginClient.ts b/apps/circuit-compiler/src/app/services/circomPluginClient.ts index 14de5b44c6..083a2100b9 100644 --- a/apps/circuit-compiler/src/app/services/circomPluginClient.ts +++ b/apps/circuit-compiler/src/app/services/circomPluginClient.ts @@ -142,20 +142,16 @@ export class CircomPluginClient extends PluginClient { // @ts-ignore this.call('terminal', 'log', { type: 'log', value: 'Compiling ' + path }) // @ts-ignore - await this.call('circom', 'run', path, { - prime: this._compilationConfig.prime, - wasm: "" - }) - // const fileContent = this.lastParsedFiles[path] - // const searchComponentName = fileContent.match(/component\s+main\s*(?:{[^{}]*})?\s*=\s*([A-Za-z_]\w*)\s*\(.*\)/) + const { stdout, stderr } = await this.call('circom', 'run', path, { prime: this._compilationConfig.prime, wasm: "", inputs: "" }) + const fileName = extractNameFromKey(path) - // if (searchComponentName) { - // const componentName = searchComponentName[1] - // const signals = circuitApi.input_signals(componentName) + this.lastCompiledCircuitPath = extractParentFromKey(path) + "/.bin/" + fileName.replace('.circom', '_js') + "/" + fileName.replace('circom', 'wasm') + if (stderr) this.call('terminal', 'log', { type: 'error', value: stderr }) + if (stdout) this.call('terminal', 'log', { type: 'log', value: stdout }) + // @ts-ignore + const signals = await this.call('circom', 'getInputs') - // this.internalEvents.emit('circuit_compiling_done', signals) - // } else { - this.internalEvents.emit('circuit_compiling_done', []) + this.internalEvents.emit('circuit_compiling_done', signals) this.emit('statusChanged', { key: 'succeed', title: 'circuit compiled successfully', type: 'success' }) // } } else { @@ -287,7 +283,7 @@ export class CircomPluginClient extends PluginClient { const dataRead = new Uint8Array(buffer) const witness = this.compiler ? await this.compiler.generate_witness(dataRead, input) : await generate_witness(dataRead, input) // @ts-ignore - await this.call('fileManager', 'writeFile', wasmPath.replace('.wasm', '.wtn'), witness, true) + await this.call('fileManager', 'writeFile', wasmPath.replace('.wasm', '.wtn'), witness, { encoding: null }) this._paq.push(['trackEvent', 'circuit-compiler', 'computeWitness', 'compiler.generate_witness', wasmPath.replace('.wasm', '.wtn')]) this.internalEvents.emit('circuit_computing_witness_done') this.emit('statusChanged', { key: 'succeed', title: 'witness computed successfully', type: 'success' })