From ebb6fc473f0c88fe2cf7bf29384677ce1c6a8c5f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:44:33 +0000 Subject: [PATCH 001/138] Bump undici from 5.27.2 to 5.28.3 Bumps [undici](https://github.com/nodejs/undici) from 5.27.2 to 5.28.3. - [Release notes](https://github.com/nodejs/undici/releases) - [Commits](https://github.com/nodejs/undici/compare/v5.27.2...v5.28.3) --- updated-dependencies: - dependency-name: undici dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 93a208eb2c..cc6ab1becf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28787,9 +28787,9 @@ undici-types@~5.26.4: integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== undici@^5.14.0: - version "5.27.2" - resolved "https://registry.yarnpkg.com/undici/-/undici-5.27.2.tgz#a270c563aea5b46cc0df2550523638c95c5d4411" - integrity sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ== + version "5.28.3" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.3.tgz#a731e0eff2c3fcfd41c1169a869062be222d1e5b" + integrity sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA== dependencies: "@fastify/busboy" "^2.0.0" From ac761a212d8cb47c13993fb906745801bac50ed2 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Feb 2024 23:43:03 +0100 Subject: [PATCH 002/138] add .vy as a supported file in tooltip --- apps/remix-ide/src/app/tabs/locales/en/remixUiTabs.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/tabs/locales/en/remixUiTabs.json b/apps/remix-ide/src/app/tabs/locales/en/remixUiTabs.json index 1c60e9592d..df7628736a 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/remixUiTabs.json +++ b/apps/remix-ide/src/app/tabs/locales/en/remixUiTabs.json @@ -1,7 +1,7 @@ { "remixUiTabs.tooltipText1": "Run script (CTRL + SHIFT + S)", "remixUiTabs.tooltipText2": "Compile CTRL + S", - "remixUiTabs.tooltipText3": "Select .sol or .yul file to compile or a .ts or .js file and run it", + "remixUiTabs.tooltipText3": "Select .sol, .vy or .yul file to compile or a .ts or .js file and run it", "remixUiTabs.zoomOut": "Zoom out", "remixUiTabs.zoomIn": "Zoom in" } From 040c640fec16fc90b6ba8f6a3081dbb4a70fb6c4 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Feb 2024 23:43:27 +0100 Subject: [PATCH 003/138] make action nullable --- apps/vyper/src/app/utils/remix-client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/vyper/src/app/utils/remix-client.tsx b/apps/vyper/src/app/utils/remix-client.tsx index 4f0c45a09b..ae4b0cab94 100644 --- a/apps/vyper/src/app/utils/remix-client.tsx +++ b/apps/vyper/src/app/utils/remix-client.tsx @@ -42,7 +42,7 @@ export class RemixClient extends PluginClient { this.eventEmitter.emit('resetCompilerState', {}) } - async vyperCompileCustomAction(action: customAction) { + async vyperCompileCustomAction(action?: customAction) { //read selected contract from file explorer and create contract type const contract = await this.getContract() //compile contract From 0070fe69e87f00f357fef8d5c2f4e073819d68a2 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Feb 2024 23:43:42 +0100 Subject: [PATCH 004/138] update play button logic --- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx index 6ea63767d3..b11d1306ae 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -169,7 +169,7 @@ export const TabsUI = (props: TabsUIProps) => { -
-
- setEnvironment('remote')} label="Remote Compiler" className={`${state.environment === 'remote' ? 'd-flex mr-4' : 'd-flex mr-4 cursor-status'}`} - /> - setEnvironment('local')} label="Local Compiler" - className={`${state.environment === 'local' ? '' : `cursor-status`}`}/> -
-
+ + + + + Advanced Compiler Settings + + + +
+
+ setEnvironment('remote')} label="Remote Compiler" className={`${state.environment === 'remote' ? 'd-flex mr-4' : 'd-flex mr-4 cursor-status'}`} + /> + setEnvironment('local')} label="Local Compiler" + className={`${state.environment === 'local' ? '' : `cursor-status`}`}/> +
+
+
+
+
+
+
Specify the compiler version & EVM version in the .vy file
diff --git a/package.json b/package.json index 80aa2b75a0..f68fdcec48 100644 --- a/package.json +++ b/package.json @@ -287,6 +287,7 @@ "@types/node": "18.16.1", "@types/react": "^18.2.0", "@types/react-beautiful-dnd": "^13.1.2", + "@types/react-bootstrap": "^0.32.35", "@types/react-dom": "^18.2.0", "@types/react-image-magnifiers": "^1.3.2", "@types/react-router-dom": "^5.3.3", diff --git a/yarn.lock b/yarn.lock index cc6ab1becf..11dc76ec57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6518,6 +6518,13 @@ dependencies: "@types/react" "*" +"@types/react-bootstrap@^0.32.35": + version "0.32.35" + resolved "https://registry.yarnpkg.com/@types/react-bootstrap/-/react-bootstrap-0.32.35.tgz#78ed1c861e426a1675c6013d3fc7a8a91f51ba30" + integrity sha512-NI5oZZSo0Z+MEELS2X8f4PzIK3GPxNeRsv/q8KREEeCvFxK33+8izMB4Uchy7EuxE1V9Ed4+0dc0T5dtWzOogA== + dependencies: + "@types/react" "*" + "@types/react-dom@^18.0.0": version "18.0.7" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.7.tgz#ee7cf8ec4e6977e3f0a7b1d38bd89c75aa2aec28" From e13f0e0b615bff6674eeebe23762eec1668b3154 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Feb 2024 11:09:35 +0100 Subject: [PATCH 044/138] fix accordion --- apps/vyper/src/app/app.tsx | 41 ++++++++++--------- .../app/components/AccordionContextToggle.tsx | 24 +++++++++++ 2 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 apps/vyper/src/app/components/AccordionContextToggle.tsx diff --git a/apps/vyper/src/app/app.tsx b/apps/vyper/src/app/app.tsx index 0731d068bb..4fdb65b535 100644 --- a/apps/vyper/src/app/app.tsx +++ b/apps/vyper/src/app/app.tsx @@ -38,6 +38,7 @@ const App = () => { environment: 'remote', localUrl: 'http://localhost:8000/', }) + const [toggleAccordion, setToggleAccordion] = useState(false) useEffect(() => { async function start() { @@ -99,6 +100,9 @@ const App = () => { function resetCompilerResultState() { setOutput(remixClient.compilerOutput) } + const toggleAccordionHandler = () => { + setToggleAccordion(!toggleAccordion) + } return (
@@ -110,25 +114,24 @@ const App = () => {
- - - - - Advanced Compiler Settings - - - -
-
- setEnvironment('remote')} label="Remote Compiler" className={`${state.environment === 'remote' ? 'd-flex mr-4' : 'd-flex mr-4 cursor-status'}`} - /> - setEnvironment('local')} label="Local Compiler" - className={`${state.environment === 'local' ? '' : `cursor-status`}`}/> -
-
-
-
-
+ + + + Advanced Compiler Settings + + + + +
+
+ setEnvironment('remote')} label="Remote Compiler" className={`${state.environment === 'remote' ? 'd-flex mr-4' : 'd-flex mr-4 cursor-status'}`} + /> + setEnvironment('local')} label="Local Compiler" + className={`${state.environment === 'local' ? '' : `cursor-status`}`}/> +
+
+
+
Specify the compiler version & EVM version in the .vy file diff --git a/apps/vyper/src/app/components/AccordionContextToggle.tsx b/apps/vyper/src/app/components/AccordionContextToggle.tsx new file mode 100644 index 0000000000..937020e699 --- /dev/null +++ b/apps/vyper/src/app/components/AccordionContextToggle.tsx @@ -0,0 +1,24 @@ +import React, { useContext } from 'react' +import { AccordionContext } from 'react-bootstrap' +import { useAccordionToggle } from 'react-bootstrap/AccordionToggle' + +function ContextAwareToggle({ children, eventKey, callback }) { + const currentEventKey = useContext(AccordionContext) + + const decoratedOnClick = useAccordionToggle( + eventKey, + () => callback && callback(eventKey), + ); + + const isCurrentEventKey = currentEventKey === eventKey; + + return ( + + ); +} From bb31970a5c3a066bf353de9f78f4e555655b1f39 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Feb 2024 13:58:28 +0100 Subject: [PATCH 045/138] add cursor style to accordion --- apps/vyper/src/app/app.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/vyper/src/app/app.css b/apps/vyper/src/app/app.css index 57b85f6dba..5bfd46cee0 100644 --- a/apps/vyper/src/app/app.css +++ b/apps/vyper/src/app/app.css @@ -230,3 +230,11 @@ html, body, #root, main { .cursor-status :hover { cursor: pointer; } + +.accordion-background { + background-color: var(--body-bg); +} + +.accordion-background:hover { + cursor: pointer; +} From ac310f4a4f75c2925072e441c19350193fd7d53a Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Feb 2024 13:58:43 +0100 Subject: [PATCH 046/138] add custom toggle component --- apps/vyper/src/app/app.tsx | 29 ++++++++++--------- .../app/components/AccordionContextToggle.tsx | 24 --------------- .../app/components/CustomAccordionToggle.tsx | 27 +++++++++++++++++ 3 files changed, 43 insertions(+), 37 deletions(-) delete mode 100644 apps/vyper/src/app/components/AccordionContextToggle.tsx create mode 100644 apps/vyper/src/app/components/CustomAccordionToggle.tsx diff --git a/apps/vyper/src/app/app.tsx b/apps/vyper/src/app/app.tsx index 4fdb65b535..adfb54d021 100644 --- a/apps/vyper/src/app/app.tsx +++ b/apps/vyper/src/app/app.tsx @@ -18,6 +18,7 @@ import './app.css' import {CustomTooltip} from '@remix-ui/helper' import { Form} from 'react-bootstrap' import {CompileErrorCard} from './components/CompileErrorCard' +import CustomAccordionToggle from './components/CustomAccordionToggle' interface AppState { status: 'idle' | 'inProgress' @@ -38,7 +39,6 @@ const App = () => { environment: 'remote', localUrl: 'http://localhost:8000/', }) - const [toggleAccordion, setToggleAccordion] = useState(false) useEffect(() => { async function start() { @@ -100,9 +100,9 @@ const App = () => { function resetCompilerResultState() { setOutput(remixClient.compilerOutput) } - const toggleAccordionHandler = () => { - setToggleAccordion(!toggleAccordion) - } + + const [toggleAccordion, setToggleAccordion] = useState(false) + return (
@@ -114,14 +114,17 @@ const App = () => { - - - - Advanced Compiler Settings - - + +
+
+ + Advanced Compiler Settings + + {/* */} + +
- +
setEnvironment('remote')} label="Remote Compiler" className={`${state.environment === 'remote' ? 'd-flex mr-4' : 'd-flex mr-4 cursor-status'}`} @@ -130,9 +133,9 @@ const App = () => { className={`${state.environment === 'local' ? '' : `cursor-status`}`}/>
- +
- +
Specify the compiler version & EVM version in the .vy file diff --git a/apps/vyper/src/app/components/AccordionContextToggle.tsx b/apps/vyper/src/app/components/AccordionContextToggle.tsx deleted file mode 100644 index 937020e699..0000000000 --- a/apps/vyper/src/app/components/AccordionContextToggle.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React, { useContext } from 'react' -import { AccordionContext } from 'react-bootstrap' -import { useAccordionToggle } from 'react-bootstrap/AccordionToggle' - -function ContextAwareToggle({ children, eventKey, callback }) { - const currentEventKey = useContext(AccordionContext) - - const decoratedOnClick = useAccordionToggle( - eventKey, - () => callback && callback(eventKey), - ); - - const isCurrentEventKey = currentEventKey === eventKey; - - return ( - - ); -} diff --git a/apps/vyper/src/app/components/CustomAccordionToggle.tsx b/apps/vyper/src/app/components/CustomAccordionToggle.tsx new file mode 100644 index 0000000000..c4a5ce98b5 --- /dev/null +++ b/apps/vyper/src/app/components/CustomAccordionToggle.tsx @@ -0,0 +1,27 @@ +import React, { useContext, useState } from 'react' +import { AccordionContext } from 'react-bootstrap' +import { useAccordionToggle } from 'react-bootstrap/AccordionToggle' + +export type CustomAccordionToggleProps = { + children: React.ReactNode + eventKey: string + callback?: any +} + +export default function CustomAccordionToggle({ children, eventKey }: CustomAccordionToggleProps) { + const [toggleAccordion, setToggleAccordion] = useState(false) + // + + const decoratedOnClick = useAccordionToggle(eventKey, () => + setToggleAccordion(!toggleAccordion) + ) + + + return ( +
+ {children} +
+ ) +} From b38871608f1fecab07c917b46bf385f114dac335 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Feb 2024 16:03:23 +0100 Subject: [PATCH 047/138] fix and add chevron for advanced config --- apps/vyper/src/app/app.tsx | 8 ++++---- apps/vyper/src/app/components/CustomAccordionToggle.tsx | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/apps/vyper/src/app/app.tsx b/apps/vyper/src/app/app.tsx index adfb54d021..4b7a69c2e0 100644 --- a/apps/vyper/src/app/app.tsx +++ b/apps/vyper/src/app/app.tsx @@ -114,14 +114,14 @@ const App = () => { +
-
+
Advanced Compiler Settings - {/* */} - + {/* */}
@@ -137,7 +137,7 @@ const App = () => {
- Specify the compiler version & EVM version in the .vy file + Specify the compiler version & EVM version in the .vy file.
setOutput({...output, [name]: update})} resetCompilerState={resetCompilerResultState} /> diff --git a/apps/vyper/src/app/components/CustomAccordionToggle.tsx b/apps/vyper/src/app/components/CustomAccordionToggle.tsx index c4a5ce98b5..edaf6a16de 100644 --- a/apps/vyper/src/app/components/CustomAccordionToggle.tsx +++ b/apps/vyper/src/app/components/CustomAccordionToggle.tsx @@ -1,5 +1,4 @@ -import React, { useContext, useState } from 'react' -import { AccordionContext } from 'react-bootstrap' +import React, { useState } from 'react' import { useAccordionToggle } from 'react-bootstrap/AccordionToggle' export type CustomAccordionToggleProps = { @@ -10,18 +9,17 @@ export type CustomAccordionToggleProps = { export default function CustomAccordionToggle({ children, eventKey }: CustomAccordionToggleProps) { const [toggleAccordion, setToggleAccordion] = useState(false) - // const decoratedOnClick = useAccordionToggle(eventKey, () => setToggleAccordion(!toggleAccordion) ) - return (
{children} +
) } From a5b38d3d61627b5b4bd1b55edd0b5cf88ca79653 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Feb 2024 16:03:46 +0100 Subject: [PATCH 048/138] update results section --- apps/vyper/src/app/components/VyperResult.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/vyper/src/app/components/VyperResult.tsx b/apps/vyper/src/app/components/VyperResult.tsx index 3234ef0cdc..a1f799cfb0 100644 --- a/apps/vyper/src/app/components/VyperResult.tsx +++ b/apps/vyper/src/app/components/VyperResult.tsx @@ -59,7 +59,7 @@ function VyperResult({ output, plugin }: VyperResultProps) { return ( <>
-
+
+ +
+
+
+
+
+ ) +} diff --git a/libs/remix-ui/settings/src/types/index.ts b/libs/remix-ui/settings/src/types/index.ts index f14027f886..3b25907d20 100644 --- a/libs/remix-ui/settings/src/types/index.ts +++ b/libs/remix-ui/settings/src/types/index.ts @@ -23,3 +23,16 @@ export interface EtherscanSettingsProps { setUnpersistedProperty: (key: string, value: string) => void } } + +export interface SindriSettingsProps { + saveToken: (sindriToken: string) => void, + removeToken: () => void, + config: { + exists: (key: string) => boolean, + get: (key: string) => string, + set: (key: string, content: string) => void, + clear: () => void, + getUnpersistedProperty: (key: string) => void, + setUnpersistedProperty: (key: string, value: string) => void + } +} diff --git a/projects.json b/projects.json index 33a1d79d2f..da979d3749 100644 --- a/projects.json +++ b/projects.json @@ -8112,6 +8112,14 @@ "npm:react-intl" ] }, + { + "file": "libs/remix-ui/settings/src/lib/sindri-settings.tsx", + "hash": "f25473fcac87f3e7aa8be1828ea446b1b261fc66", + "deps": [ + "npm:react", + "npm:react-intl" + ] + }, { "file": "libs/remix-ui/settings/src/lib/remix-ui-settings.css", "hash": "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391" From 7d99eee45df8b710b8fdeb05261a224eb918eba4 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sun, 11 Feb 2024 12:12:40 -0600 Subject: [PATCH 085/138] Use the API key from settings. --- .../src/script-templates/sindri/sindri.ts | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts b/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts index 881699c329..803c052570 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts @@ -1,5 +1,19 @@ import client from 'sindri' +const authorize = async () => { + try { + const apiKey = await remix.call('settings', 'get', 'settings/sindri-access-token') + if (!apiKey) { + throw new Error('Missing API key.') + } + client.authorize({apiKey}) + } catch { + const message = 'No Sindri API key found. Please add your API key in the settings tab.' + await remix.call('notification', 'toast', message) + throw new Error(message) + } +} + const getSindriManifest = async () => { const sindriJson = await remix.call('fileManager', 'readFile', `sindri.json`) return JSON.parse(sindriJson) @@ -14,12 +28,11 @@ const normalizePath = (path: string): string => { /** * Compile the given circuit - * @param {string} apiKey - sindri API key * @returns {Circuit} compiled circuit */ -export const createCircuit = async (apiKey: string) => { +export const createCircuit = async () => { + authorize() const sindriManifest = await getSindriManifest() - client.authorize({apiKey}) // Create a map from file paths to `File` objects for all files in the workspace. const filesByPath: {[path: string]: File} = {} @@ -50,7 +63,7 @@ export const createCircuit = async (apiKey: string) => { }) } - console.log(`creating circuit "${entryPoint}"...`) + console.log(`creating circuit "${sindriManifest.name}"...`) const files = Object.values(filesByPath) const circuitProject = await client.createCircuit(files) console.log(`circuit created ${circuitProject.circuit_id}`) @@ -60,12 +73,11 @@ export const createCircuit = async (apiKey: string) => { /** * Generate a proof against the given circuit * @param {Object} signals - input signals - * @param {string} apiKey - sindri API key * @returns {Proof} generated proof */ -export const proveCircuit = async (signals: {[id: string]: string}, apiKey: string) => { +export const proveCircuit = async (signals: {[id: string]: string}) => { + authorize() const sindriManifest = await getSindriManifest() - client.authorize({apiKey}) const circuitName = sindriManifest.name console.log(`proving circuit "${circuitName}"...`) From 14a1e0b13927bd77a00e94d3d89e27e7b6040586 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sun, 11 Feb 2024 12:16:09 -0600 Subject: [PATCH 086/138] Set the client log-level. --- libs/remix-ws-templates/src/script-templates/sindri/sindri.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts b/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts index 803c052570..4d5f3dcaeb 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts @@ -1,5 +1,7 @@ import client from 'sindri' +client.logLevel = 'info' + const authorize = async () => { try { const apiKey = await remix.call('settings', 'get', 'settings/sindri-access-token') From c89497f20f327ceb44fe607e547abf3dfc39d3ca Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sun, 11 Feb 2024 12:29:58 -0600 Subject: [PATCH 087/138] Clean up some of the documentation. --- .../src/script-templates/sindri/sindri.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts b/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts index 4d5f3dcaeb..33383ca5e5 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts @@ -1,6 +1,7 @@ -import client from 'sindri' +import sindriClient from 'sindri' +import type {CircuitInfoResponse, ProofInfoResponse} from 'sindri' -client.logLevel = 'info' +sindriClient.logLevel = 'info' const authorize = async () => { try { @@ -8,7 +9,7 @@ const authorize = async () => { if (!apiKey) { throw new Error('Missing API key.') } - client.authorize({apiKey}) + sindriClient.authorize({apiKey}) } catch { const message = 'No Sindri API key found. Please add your API key in the settings tab.' await remix.call('notification', 'toast', message) @@ -29,10 +30,12 @@ const normalizePath = (path: string): string => { } /** - * Compile the given circuit - * @returns {Circuit} compiled circuit + * Compile the circuit. + * + * @param {string | string[] | null} tags - The tag or tags to use when compiling the circuit. + * @returns {CircuitInfoResponse} compiled circuit */ -export const createCircuit = async () => { +export const compile = async (tags: string | string[] | null = ['latest']): CircuitInfoResponse => { authorize() const sindriManifest = await getSindriManifest() @@ -67,23 +70,24 @@ export const createCircuit = async () => { console.log(`creating circuit "${sindriManifest.name}"...`) const files = Object.values(filesByPath) - const circuitProject = await client.createCircuit(files) + const circuitProject = await sindriClient.createCircuit(files, tags) console.log(`circuit created ${circuitProject.circuit_id}`) return circuitProject } /** - * Generate a proof against the given circuit - * @param {Object} signals - input signals - * @returns {Proof} generated proof + * Generate a proof against the circuit. + * + * @param {Object} signals - Input signals for the circuit. + * @returns {ProofInfoResponse} The generated proof. */ -export const proveCircuit = async (signals: {[id: string]: string}) => { +export const proveCircuit = async (signals: {[id: string]: string}): ProofInfoResponse => { authorize() const sindriManifest = await getSindriManifest() const circuitName = sindriManifest.name console.log(`proving circuit "${circuitName}"...`) - const proof = await client.proveCircuit(circuitName, JSON.stringify(signals)) + const proof = await sindriClient.proveCircuit(circuitName, JSON.stringify(signals)) console.log(`proof id: ${proof.proof_id}`) return proof } From c28985eeb785f06b6f0f814b66e5b2bb15a03d92 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sun, 11 Feb 2024 12:31:57 -0600 Subject: [PATCH 088/138] Rename `sindri.ts` to `utils.ts`. --- libs/remix-ws-templates/src/script-templates/sindri/index.ts | 4 ++-- .../src/script-templates/sindri/{sindri.ts => utils.ts} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename libs/remix-ws-templates/src/script-templates/sindri/{sindri.ts => utils.ts} (100%) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index 19e671a2f8..f4c2073f29 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -1,8 +1,8 @@ export const sindriScripts = async (plugin) => { await plugin.call('fileManager', 'writeFile', - 'scripts/sindri/index.ts' , + 'scripts/sindri/utils.ts' , // @ts-ignore - (await import('!!raw-loader!./sindri.ts')).default) + (await import('!!raw-loader!./utils.ts')).default) const existingFiles = await plugin.call('fileManager', 'readdir', '') diff --git a/libs/remix-ws-templates/src/script-templates/sindri/sindri.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts similarity index 100% rename from libs/remix-ws-templates/src/script-templates/sindri/sindri.ts rename to libs/remix-ws-templates/src/script-templates/sindri/utils.ts From cd69ee7cd129dd25ff9a9f8131594791c0a2ba00 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sun, 11 Feb 2024 13:23:46 -0600 Subject: [PATCH 089/138] Add basic proof/compile scripts. --- .../src/script-templates/sindri/index.ts | 10 +++++ .../script-templates/sindri/run_compile.ts | 7 ++++ .../src/script-templates/sindri/run_prove.ts | 15 ++++++++ .../src/script-templates/sindri/utils.ts | 37 ++++++++++++++----- 4 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 libs/remix-ws-templates/src/script-templates/sindri/run_compile.ts create mode 100644 libs/remix-ws-templates/src/script-templates/sindri/run_prove.ts diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index f4c2073f29..e26f495589 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -4,6 +4,16 @@ export const sindriScripts = async (plugin) => { // @ts-ignore (await import('!!raw-loader!./utils.ts')).default) + await plugin.call('fileManager', 'writeFile', + 'scripts/sindri/run_compile.ts' , + // @ts-ignore + (await import('!!raw-loader!./run_compile.ts')).default) + + await plugin.call('fileManager', 'writeFile', + 'scripts/sindri/run_prove.ts' , + // @ts-ignore + (await import('!!raw-loader!./run_prove.ts')).default) + const existingFiles = await plugin.call('fileManager', 'readdir', '') // Only write out the `.sindriignore` file if it doesn't already exist. diff --git a/libs/remix-ws-templates/src/script-templates/sindri/run_compile.ts b/libs/remix-ws-templates/src/script-templates/sindri/run_compile.ts new file mode 100644 index 0000000000..40a2bb42ad --- /dev/null +++ b/libs/remix-ws-templates/src/script-templates/sindri/run_compile.ts @@ -0,0 +1,7 @@ +import {compile} from './utils' + +const main = async () => { + const circuit = await compile() +} + +main() diff --git a/libs/remix-ws-templates/src/script-templates/sindri/run_prove.ts b/libs/remix-ws-templates/src/script-templates/sindri/run_prove.ts new file mode 100644 index 0000000000..98e2ea43d7 --- /dev/null +++ b/libs/remix-ws-templates/src/script-templates/sindri/run_prove.ts @@ -0,0 +1,15 @@ +import {prove} from './utils' + +// You must modify the input signals to include the data you're trying to generate a proof for. +const signals: {[name: string]: number | string} = {} + +const main = async () => { + if (Object.keys(signals).length === 0) { + console.error("You must modify the input signals to include the data you're trying to generate a proof for.") + return + } + const proofResponse = await prove(signals) + console.log('Proof:\n', JSON.stringify(proofResponse.proof, null, 2)) +} + +main() diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 33383ca5e5..642582e651 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -68,11 +68,15 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ }) } - console.log(`creating circuit "${sindriManifest.name}"...`) + console.log(`Compiling circuit "${sindriManifest.name}"...`) const files = Object.values(filesByPath) - const circuitProject = await sindriClient.createCircuit(files, tags) - console.log(`circuit created ${circuitProject.circuit_id}`) - return circuitProject + const circuitResponse = await sindriClient.createCircuit(files, tags) + if (circuitResponse.status === 'Ready') { + console.log(`Circuit compiled successfully, circuit id: ${circuitResponse.circuit_id}`) + } else { + console.error('Circuit compilation failed:', circuitResponse.error || 'Unknown error') + } + return circuitResponse } /** @@ -81,13 +85,28 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ * @param {Object} signals - Input signals for the circuit. * @returns {ProofInfoResponse} The generated proof. */ -export const proveCircuit = async (signals: {[id: string]: string}): ProofInfoResponse => { +export const prove = async (signals: {[id: string]: number | string}): ProofInfoResponse => { authorize() const sindriManifest = await getSindriManifest() const circuitName = sindriManifest.name - console.log(`proving circuit "${circuitName}"...`) - const proof = await sindriClient.proveCircuit(circuitName, JSON.stringify(signals)) - console.log(`proof id: ${proof.proof_id}`) - return proof + console.log(`Proving circuit "${circuitName}"...`) + try { + const proofResponse = await sindriClient.proveCircuit(circuitName, JSON.stringify(signals)) + if (proofResponse.status === 'Ready') { + console.log(`Proof generated successfully, proof id: ${proofResponse.proof_id}`) + } else { + console.error('Proof generation failed:', proofResponse.error || 'Unknown error') + } + return proofResponse + } catch (error) { + if ('status' in error && error.status === 404) { + const message = `No compiled circuit "${circuitName}" found, have you successfully compiled the circuit?` + console.error(message) + throw new Error(message) + } else { + console.error('Unknown error occurred.') + throw error + } + } } From e33c32aa7e1ee069d7b447111dfbbe1966c38e99 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sun, 11 Feb 2024 13:35:01 -0600 Subject: [PATCH 090/138] Convert absolute imports to relative ones. --- libs/remix-ws-templates/src/script-templates/sindri/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 642582e651..13f20cbaae 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -62,8 +62,10 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ const circuitPath = normalizePath(sindriManifest.circuitPath || 'circuit.circom') const circuitContent = await remix.call('fileManager', 'readFile', circuitPath) const dependencies: {[path: string]: string} = await remix.call('circuit-compiler' as any, 'resolveDependencies', circuitPath, circuitContent) - Object.entries(dependencies).forEach(([rawPath, content]) => { + Object.entries(dependencies).forEach(([rawPath, rawContent]) => { + // Convert absolute file paths to paths relative to the project root. const path = normalizePath(rawPath) + const content = path.endsWith('.circom') ? rawContent.replace(/^\s*include\s+"\/([^"]+)"\s*;\s*$/gm, 'include "$1";') : rawContent filesByPath[path] = new File([content], path) }) } From d631dec1cefb6f170d982a73c2e671e7de7ad1e1 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sun, 11 Feb 2024 18:15:38 -0600 Subject: [PATCH 091/138] Fix the include rewriting regex. --- libs/remix-ws-templates/src/script-templates/sindri/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 13f20cbaae..1b061a9639 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -65,7 +65,8 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ Object.entries(dependencies).forEach(([rawPath, rawContent]) => { // Convert absolute file paths to paths relative to the project root. const path = normalizePath(rawPath) - const content = path.endsWith('.circom') ? rawContent.replace(/^\s*include\s+"\/([^"]+)"\s*;\s*$/gm, 'include "$1";') : rawContent + // Removes any leading `/`s from Circom `include` paths to make them relative to the root. + const content = path.endsWith('.circom') ? rawContent.replace(/^\s*include\s+"\/+([^"]+)"\s*;\s*$/gm, 'include "$1";') : rawContent filesByPath[path] = new File([content], path) }) } From 3e749e55f1a18abf9ababe1201df4f0477d00209 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sun, 11 Feb 2024 18:17:33 -0600 Subject: [PATCH 092/138] Make the toast error more detailed. --- libs/remix-ws-templates/src/script-templates/sindri/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 1b061a9639..13d5dd7b26 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -11,7 +11,7 @@ const authorize = async () => { } sindriClient.authorize({apiKey}) } catch { - const message = 'No Sindri API key found. Please add your API key in the settings tab.' + const message = 'No Sindri API key found. Please click the gear in the lower left corner to open the settings page, and add your API key under "Sindri Credentials".' await remix.call('notification', 'toast', message) throw new Error(message) } From 97f510f238feded7776e808d48bc744b80ea4639 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Mon, 12 Feb 2024 10:08:19 -0600 Subject: [PATCH 093/138] Improve error reporting around authorization. --- .../src/script-templates/sindri/utils.ts | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 13d5dd7b26..3f8245cf68 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -36,7 +36,7 @@ const normalizePath = (path: string): string => { * @returns {CircuitInfoResponse} compiled circuit */ export const compile = async (tags: string | string[] | null = ['latest']): CircuitInfoResponse => { - authorize() + await authorize() const sindriManifest = await getSindriManifest() // Create a map from file paths to `File` objects for all files in the workspace. @@ -73,13 +73,24 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ console.log(`Compiling circuit "${sindriManifest.name}"...`) const files = Object.values(filesByPath) - const circuitResponse = await sindriClient.createCircuit(files, tags) - if (circuitResponse.status === 'Ready') { - console.log(`Circuit compiled successfully, circuit id: ${circuitResponse.circuit_id}`) - } else { - console.error('Circuit compilation failed:', circuitResponse.error || 'Unknown error') + try { + const circuitResponse = await sindriClient.createCircuit(files, tags) + if (circuitResponse.status === 'Ready') { + console.log(`Circuit compiled successfully, circuit id: ${circuitResponse.circuit_id}`) + } else { + console.error('Circuit compilation failed:', circuitResponse.error || 'Unknown error') + } + return circuitResponse + } catch (error) { + if ('status' in error && error.status === 401) { + const message = 'Sindri API key authentication failed, please check that your key is correct in the settings.' + console.error(message) + throw new Error(message) + } else { + console.error('Unknown error occurred.') + throw error + } } - return circuitResponse } /** @@ -89,7 +100,7 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ * @returns {ProofInfoResponse} The generated proof. */ export const prove = async (signals: {[id: string]: number | string}): ProofInfoResponse => { - authorize() + await authorize() const sindriManifest = await getSindriManifest() const circuitName = sindriManifest.name @@ -103,7 +114,11 @@ export const prove = async (signals: {[id: string]: number | string}): ProofInfo } return proofResponse } catch (error) { - if ('status' in error && error.status === 404) { + if ('status' in error && error.status === 401) { + const message = 'Sindri API key authentication failed, please check that your key is correct in the settings.' + console.error(message) + throw new Error(message) + } else if ('status' in error && error.status === 404) { const message = `No compiled circuit "${circuitName}" found, have you successfully compiled the circuit?` console.error(message) throw new Error(message) From 7bf5d600aa501666bc278985b00230ec40c9ed85 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Tue, 13 Feb 2024 13:47:50 -0600 Subject: [PATCH 094/138] Remove translations of the settings strings. --- apps/remix-ide/src/app/tabs/locales/es/settings.json | 3 --- apps/remix-ide/src/app/tabs/locales/fr/settings.json | 3 --- apps/remix-ide/src/app/tabs/locales/it/settings.json | 3 --- apps/remix-ide/src/app/tabs/locales/zh/settings.json | 3 --- 4 files changed, 12 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/locales/es/settings.json b/apps/remix-ide/src/app/tabs/locales/es/settings.json index a3b8bfcb9c..899e2787cc 100644 --- a/apps/remix-ide/src/app/tabs/locales/es/settings.json +++ b/apps/remix-ide/src/app/tabs/locales/es/settings.json @@ -17,9 +17,6 @@ "settings.etherscanTokenTitle": "Token de Acceso de EtherScan", "settings.etherscanAccessTokenText": "Administra la clave api usada para interactuar con Etherscan.", "settings.etherscanAccessTokenText2": "Vaya a la página de claves api de Etherscan (enlace abajo) para crear una nueva clave api y guardarla en Remix.", - "settings.sindriAccessTokenTitle": "Credenciales de Sindri", - "settings.sindriAccessTokenText": "El token de acceso se utiliza para compilar circuitos ZKP y generar pruebas con Sindri.", - "settings.sindriAccessTokenText2":"Vaya a la página de creación de cuentas de Sindri (enlace abajo) para crear un nuevo token y guardarlo en Remix.", "settings.save": "Guardar", "settings.remove": "Eliminar", "settings.themes": "Temas", diff --git a/apps/remix-ide/src/app/tabs/locales/fr/settings.json b/apps/remix-ide/src/app/tabs/locales/fr/settings.json index fe5160fb16..5d1859dfe9 100644 --- a/apps/remix-ide/src/app/tabs/locales/fr/settings.json +++ b/apps/remix-ide/src/app/tabs/locales/fr/settings.json @@ -17,9 +17,6 @@ "settings.etherscanTokenTitle": "Token d'accés Etherscan", "settings.etherscanAccessTokenText": "Gérer la clé api utilisée pour interagir avec Etherscan.", "settings.etherscanAccessTokenText2": "Allez sur la page de clé Etherscan api (lien ci-dessous) pour créer une nouvelle clé api et l'enregistrer dans Remix.", - "settings.sindriAccessTokenTitle": "Identifiants Sindri", - "settings.sindriAccessTokenText": "Le jeton d'accès est utilisé pour compiler les circuits ZKP et générer des preuves avec Sindri.", - "settings.sindriAccessTokenText2":"Allez à la page de création de compte Sindri (lien ci-dessous) pour créer un nouveau jeton et l'enregistrer dans Remix.", "settings.save": "Sauvegarder", "settings.remove": "Supprimer", "settings.themes": "Thèmes", diff --git a/apps/remix-ide/src/app/tabs/locales/it/settings.json b/apps/remix-ide/src/app/tabs/locales/it/settings.json index 61c4c89ad3..416f338b64 100644 --- a/apps/remix-ide/src/app/tabs/locales/it/settings.json +++ b/apps/remix-ide/src/app/tabs/locales/it/settings.json @@ -17,9 +17,6 @@ "settings.etherscanTokenTitle": "Token di accesso a Etherscan", "settings.etherscanAccessTokenText": "Gestione della chiave api utilizzata per interagire con Etherscan.", "settings.etherscanAccessTokenText2": "Vai alla pagina delle chiavi api di Etherscan (link in basso) per creare una nuova chiave api e salvarla in Remix.", - "settings.sindriAccessTokenTitle": "Credenziali Sindri", - "settings.sindriAccessTokenText": "Il token di accesso è utilizzato per compilare circuiti ZKP e generare prove con Sindri.", - "settings.sindriAccessTokenText2":"Vai alla pagina di creazione dell'account Sindri (link qui sotto) per creare un nuovo token e salvarlo in Remix.", "settings.save": "Salva", "settings.remove": "Rimuovi", "settings.themes": "Temi", diff --git a/apps/remix-ide/src/app/tabs/locales/zh/settings.json b/apps/remix-ide/src/app/tabs/locales/zh/settings.json index 3b363801c7..5504874efd 100644 --- a/apps/remix-ide/src/app/tabs/locales/zh/settings.json +++ b/apps/remix-ide/src/app/tabs/locales/zh/settings.json @@ -17,9 +17,6 @@ "settings.etherscanTokenTitle": "EtherScan 访问 Token", "settings.etherscanAccessTokenText": "管理用于与Etherscan交互的api密钥.", "settings.etherscanAccessTokenText2": "前往 Etherscan api 密钥页面 (参见下方链接),创建一个新的api密钥并保存到Remix中.", - "settings.sindriAccessTokenTitle": "Sindri 凭证", - "settings.sindriAccessTokenText": "访问令牌用于使用 Sindri 编译 ZKP 电路和生成证明。", - "settings.sindriAccessTokenText2":"转到 Sindri 账户创建页面(下方链接),创建新令牌并将其保存在 Remix 中。", "settings.save": "保存", "settings.remove": "删除", "settings.themes": "主题", From dc93285c5ed3230a19ea9658e868fdffd82fa85c Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 13:26:17 -0600 Subject: [PATCH 095/138] Remove `.sindriignore` from the Circom templates. --- .../src/templates/hashchecker/.sindriignore | 4 ---- libs/remix-ws-templates/src/templates/hashchecker/index.ts | 4 +--- libs/remix-ws-templates/src/templates/rln/.sindriignore | 4 ---- libs/remix-ws-templates/src/templates/rln/index.ts | 4 +--- libs/remix-ws-templates/src/templates/semaphore/.sindriignore | 4 ---- libs/remix-ws-templates/src/templates/semaphore/index.ts | 4 +--- 6 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 libs/remix-ws-templates/src/templates/hashchecker/.sindriignore delete mode 100644 libs/remix-ws-templates/src/templates/rln/.sindriignore delete mode 100644 libs/remix-ws-templates/src/templates/semaphore/.sindriignore diff --git a/libs/remix-ws-templates/src/templates/hashchecker/.sindriignore b/libs/remix-ws-templates/src/templates/hashchecker/.sindriignore deleted file mode 100644 index 382e53dfd3..0000000000 --- a/libs/remix-ws-templates/src/templates/hashchecker/.sindriignore +++ /dev/null @@ -1,4 +0,0 @@ -# Files to exclude from Sindri circuit uploads (uses `.gitignore` syntax). -/.deps/ -/scripts/ -/templates/ diff --git a/libs/remix-ws-templates/src/templates/hashchecker/index.ts b/libs/remix-ws-templates/src/templates/hashchecker/index.ts index 223ea39df4..bed5f13e7f 100644 --- a/libs/remix-ws-templates/src/templates/hashchecker/index.ts +++ b/libs/remix-ws-templates/src/templates/hashchecker/index.ts @@ -11,8 +11,6 @@ export default async () => { // @ts-ignore 'README.md': (await import('raw-loader!./README.md')).default, // @ts-ignore - '.sindriignore': (await import('raw-loader!./.sindriignore')).default, - // @ts-ignore 'sindri.json': (await import('./sindri.json.raw!=!raw-loader!./sindri.json')).default, } -} \ No newline at end of file +} diff --git a/libs/remix-ws-templates/src/templates/rln/.sindriignore b/libs/remix-ws-templates/src/templates/rln/.sindriignore deleted file mode 100644 index 382e53dfd3..0000000000 --- a/libs/remix-ws-templates/src/templates/rln/.sindriignore +++ /dev/null @@ -1,4 +0,0 @@ -# Files to exclude from Sindri circuit uploads (uses `.gitignore` syntax). -/.deps/ -/scripts/ -/templates/ diff --git a/libs/remix-ws-templates/src/templates/rln/index.ts b/libs/remix-ws-templates/src/templates/rln/index.ts index a56c2844c0..6da6c5e7f3 100644 --- a/libs/remix-ws-templates/src/templates/rln/index.ts +++ b/libs/remix-ws-templates/src/templates/rln/index.ts @@ -19,8 +19,6 @@ export default async () => { // @ts-ignore 'README.md': (await import('raw-loader!./README.md')).default, // @ts-ignore - '.sindriignore': (await import('raw-loader!./.sindriignore')).default, - // @ts-ignore 'sindri.json': (await import('./sindri.json.raw!=!raw-loader!./sindri.json')).default, } -} \ No newline at end of file +} diff --git a/libs/remix-ws-templates/src/templates/semaphore/.sindriignore b/libs/remix-ws-templates/src/templates/semaphore/.sindriignore deleted file mode 100644 index 382e53dfd3..0000000000 --- a/libs/remix-ws-templates/src/templates/semaphore/.sindriignore +++ /dev/null @@ -1,4 +0,0 @@ -# Files to exclude from Sindri circuit uploads (uses `.gitignore` syntax). -/.deps/ -/scripts/ -/templates/ diff --git a/libs/remix-ws-templates/src/templates/semaphore/index.ts b/libs/remix-ws-templates/src/templates/semaphore/index.ts index adabb9e65c..5deeec74e6 100644 --- a/libs/remix-ws-templates/src/templates/semaphore/index.ts +++ b/libs/remix-ws-templates/src/templates/semaphore/index.ts @@ -15,8 +15,6 @@ export default async () => { // @ts-ignore 'README.md': (await import('raw-loader!./README.md')).default, // @ts-ignore - '.sindriignore': (await import('raw-loader!./.sindriignore')).default, - // @ts-ignore 'sindri.json': (await import('./sindri.json.raw!=!raw-loader!./sindri.json')).default, } -} \ No newline at end of file +} From d1b4f999dc66a4871cf9f88b8f91c0fae8cfb6d8 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 15:06:54 -0600 Subject: [PATCH 096/138] Remove `sindri.json` from the Circom templates. --- .../src/templates/hashchecker/index.ts | 2 -- .../src/templates/hashchecker/sindri.json | 9 --------- libs/remix-ws-templates/src/templates/rln/index.ts | 2 -- libs/remix-ws-templates/src/templates/rln/sindri.json | 9 --------- libs/remix-ws-templates/src/templates/semaphore/index.ts | 4 ---- .../src/templates/semaphore/sindri.json | 9 --------- 6 files changed, 35 deletions(-) delete mode 100644 libs/remix-ws-templates/src/templates/hashchecker/sindri.json delete mode 100644 libs/remix-ws-templates/src/templates/rln/sindri.json delete mode 100644 libs/remix-ws-templates/src/templates/semaphore/sindri.json diff --git a/libs/remix-ws-templates/src/templates/hashchecker/index.ts b/libs/remix-ws-templates/src/templates/hashchecker/index.ts index bed5f13e7f..5f7945ed8b 100644 --- a/libs/remix-ws-templates/src/templates/hashchecker/index.ts +++ b/libs/remix-ws-templates/src/templates/hashchecker/index.ts @@ -10,7 +10,5 @@ export default async () => { 'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default, // @ts-ignore 'README.md': (await import('raw-loader!./README.md')).default, - // @ts-ignore - 'sindri.json': (await import('./sindri.json.raw!=!raw-loader!./sindri.json')).default, } } diff --git a/libs/remix-ws-templates/src/templates/hashchecker/sindri.json b/libs/remix-ws-templates/src/templates/hashchecker/sindri.json deleted file mode 100644 index c23c7d37e7..0000000000 --- a/libs/remix-ws-templates/src/templates/hashchecker/sindri.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://sindri.app/api/v1/sindri-manifest-schema.json", - "name": "hashchecker", - "circuitPath": "./circuits/calculate_hash.circom", - "circuitType": "circom", - "curve": "bn254", - "provingScheme": "groth16", - "witnessCompiler": "wasm" -} diff --git a/libs/remix-ws-templates/src/templates/rln/index.ts b/libs/remix-ws-templates/src/templates/rln/index.ts index 6da6c5e7f3..9b8d77372e 100644 --- a/libs/remix-ws-templates/src/templates/rln/index.ts +++ b/libs/remix-ws-templates/src/templates/rln/index.ts @@ -18,7 +18,5 @@ export default async () => { 'LICENSE-MIT': (await import('!!raw-loader!./LICENSE-MIT')).default, // @ts-ignore 'README.md': (await import('raw-loader!./README.md')).default, - // @ts-ignore - 'sindri.json': (await import('./sindri.json.raw!=!raw-loader!./sindri.json')).default, } } diff --git a/libs/remix-ws-templates/src/templates/rln/sindri.json b/libs/remix-ws-templates/src/templates/rln/sindri.json deleted file mode 100644 index bf7d105b15..0000000000 --- a/libs/remix-ws-templates/src/templates/rln/sindri.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://sindri.app/api/v1/sindri-manifest-schema.json", - "name": "rln", - "circuitPath": "./circuits/rln.circom", - "circuitType": "circom", - "curve": "bn254", - "provingScheme": "groth16", - "witnessCompiler": "wasm" -} diff --git a/libs/remix-ws-templates/src/templates/semaphore/index.ts b/libs/remix-ws-templates/src/templates/semaphore/index.ts index 5deeec74e6..3c8889362e 100644 --- a/libs/remix-ws-templates/src/templates/semaphore/index.ts +++ b/libs/remix-ws-templates/src/templates/semaphore/index.ts @@ -12,9 +12,5 @@ export default async () => { 'scripts/run_verification.ts': (await import('!!raw-loader!./scripts/run_verification.ts')).default, // @ts-ignore 'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default, - // @ts-ignore - 'README.md': (await import('raw-loader!./README.md')).default, - // @ts-ignore - 'sindri.json': (await import('./sindri.json.raw!=!raw-loader!./sindri.json')).default, } } diff --git a/libs/remix-ws-templates/src/templates/semaphore/sindri.json b/libs/remix-ws-templates/src/templates/semaphore/sindri.json deleted file mode 100644 index b2d001ec87..0000000000 --- a/libs/remix-ws-templates/src/templates/semaphore/sindri.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://sindri.app/api/v1/sindri-manifest-schema.json", - "name": "semaphore", - "circuitPath": "./circuits/semaphore.circom", - "circuitType": "circom", - "curve": "bn254", - "provingScheme": "groth16", - "witnessCompiler": "wasm" -} From a1cdaf8c37ac5dad171490dfd3607a20fa6fa55f Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 15:20:52 -0600 Subject: [PATCH 097/138] Refactor the workspace loading into a function. --- .../src/script-templates/sindri/utils.ts | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 3f8245cf68..21016b6abe 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -22,24 +22,14 @@ const getSindriManifest = async () => { return JSON.parse(sindriJson) } -const normalizePath = (path: string): string => { - while (path.startsWith('/') || path.startsWith('./')) { - path = path.replace(/^(\.\/|\/)/, '') - } - return path -} - /** - * Compile the circuit. + * Create a map of file paths to `File` objects for either all or a subset of files in the workspace. * - * @param {string | string[] | null} tags - The tag or tags to use when compiling the circuit. - * @returns {CircuitInfoResponse} compiled circuit + * @param {RegExp | null} pathRegex - A regular expression to limit the included files to those + * whose paths match. If not specified, then all paths are included. + * @returns {Promise<{[path: string]: File}>} A map of file paths to `File` objects. */ -export const compile = async (tags: string | string[] | null = ['latest']): CircuitInfoResponse => { - await authorize() - const sindriManifest = await getSindriManifest() - - // Create a map from file paths to `File` objects for all files in the workspace. +export const getWorkspaceFilesByPath = async (pathRegex: RegExp | null = null): Promise<{[path: string]: File}> => { const filesByPath: {[path: string]: File} = {} interface Workspace { children?: Workspace @@ -49,13 +39,35 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ const childQueue: Array<[string, Workspace]> = Object.entries(workspace) while (childQueue.length > 0) { const [path, child] = childQueue.pop() - if ('content' in child) { + if ('content' in child && (pathRegex === null || pathRegex.test(path))) { filesByPath[path] = new File([child.content], path) } if ('children' in child) { childQueue.push(...Object.entries(child.children)) } } + return filesByPath +} + +const normalizePath = (path: string): string => { + while (path.startsWith('/') || path.startsWith('./')) { + path = path.replace(/^(\.\/|\/)/, '') + } + return path +} + +/** + * Compile the circuit. + * + * @param {string | string[] | null} tags - The tag or tags to use when compiling the circuit. + * @returns {CircuitInfoResponse} compiled circuit + */ +export const compile = async (tags: string | string[] | null = ['latest']): CircuitInfoResponse => { + await authorize() + const sindriManifest = await getSindriManifest() + + // Create a map from file paths to `File` objects for all files in the workspace. + const filesByPath = getWorkspaceFilesByPath() // Merge any of the circuit's resolved dependencies into the files at their expected import paths. if (sindriManifest.circuitType === 'circom') { From b461723aaef6a9f34c13deec5fce2c7663c26b90 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 15:23:12 -0600 Subject: [PATCH 098/138] Rough cut of modifying sindri.json when adding it. --- .../src/script-templates/sindri/index.ts | 109 +++++++++++++----- 1 file changed, 81 insertions(+), 28 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index e26f495589..8ffe1b1298 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -1,36 +1,89 @@ -export const sindriScripts = async (plugin) => { - await plugin.call('fileManager', 'writeFile', - 'scripts/sindri/utils.ts' , - // @ts-ignore - (await import('!!raw-loader!./utils.ts')).default) +const getWorkspaceFilesByPath = async (plugin: any, pathRegex: RegExp | null = null): Promise<{[path: string]: File}> => { + const filesByPath: {[path: string]: File} = {} + interface Workspace { + children?: Workspace + content?: string + } + const workspace: Workspace = await plugin.call('fileManager', 'copyFolderToJson', '/') + const childQueue: Array<[string, Workspace]> = Object.entries(workspace) + while (childQueue.length > 0) { + const [path, child] = childQueue.pop() + if ('content' in child && (pathRegex === null || pathRegex.test(path))) { + filesByPath[path] = new File([child.content], path) + } + if ('children' in child) { + childQueue.push(...Object.entries(child.children)) + } + } + return filesByPath +} - await plugin.call('fileManager', 'writeFile', - 'scripts/sindri/run_compile.ts' , - // @ts-ignore - (await import('!!raw-loader!./run_compile.ts')).default) +export const sindriScripts = async (plugin: any) => { + // Load in all of the Sindri or Circom-related files in the workspace. + const existingFilesByPath = await getWorkspaceFilesByPath(plugin, /sindri|\.circom$/i) + const writeIfNotExists = async (path: string, content: string) => { + if (!(path in existingFilesByPath)) { + await plugin.call('fileManager', 'writeFile', path, content) + } + } - await plugin.call('fileManager', 'writeFile', - 'scripts/sindri/run_prove.ts' , + // Write out all of the static files if they don't exist. + // @ts-ignore + await writeIfNotExists('scripts/.sindriignore', (await import('!!raw-loader!./.sindriignore')).default) + // @ts-ignore + await writeIfNotExists('scripts/sindri/utils.ts', (await import('!!raw-loader!./utils.ts')).default) + // @ts-ignore + await writeIfNotExists('scripts/sindri/run_compile.ts', (await import('!!raw-loader!./run_compile.ts')).default) + // @ts-ignore + await writeIfNotExists('scripts/sindri/run_prove.ts', (await import('!!raw-loader!./run_prove.ts')).default) + + // Only write out the `sindri.json` file if it doesn't already exist. + if (!('sindri.json' in existingFilesByPath)) { // @ts-ignore - (await import('!!raw-loader!./run_prove.ts')).default) + const sindriManifest = (await import('./sindri.json')).default - const existingFiles = await plugin.call('fileManager', 'readdir', '') + // Infer manifest properties from the existing files in the workspace. + switch (sindriManifest.circuitType) { + case 'circom': + // Try to find the best `.circom` source file to use as the main component. + // First, we limit ourselves to `.circom` files. + const circomPathsAndContents = await Promise.all( + Object.entries(existingFilesByPath) + .filter(([path]) => /\.circom$/i.test(path)) + .map(async ([path, file]) => [path, await file.text()]) + ) + // Now we apply some heuristics to find the "best" file. + const circomCircuitPath = + circomPathsAndContents + .map(([path, content]) => ({ + content, + hasMainComponent: !!/^[ \t\f]*component[ \t\f]+main[^\n\r]*;[ \t\f]*$/m.test(content), + // These files are the entrypoints to the Remix Circom templates, so we give them a boost if there are multiple main components. + isTemplateEntrypoint: !!['calculate_hash.circom', 'rln.circom', 'semaphore.circom'].includes(path.split('/').pop() ?? ''), + path, + })) + .sort((a, b) => { + if (a.hasMainComponent !== b.hasMainComponent) return +b.hasMainComponent - +a.hasMainComponent + if (a.isTemplateEntrypoint !== b.isTemplateEntrypoint) return +b.isTemplateEntrypoint - +a.isTemplateEntrypoint + return a.path.localeCompare(b.path) + }) + .map(({path}) => path)[0] || './circuit.circom' - // Only write out the `.sindriignore` file if it doesn't already exist. - if (!('.sindriignore' in existingFiles)) { - await plugin.call('fileManager', 'writeFile', - '.sindriignore', - // @ts-ignore - (await import('raw-loader!./.sindriignore')).default) - } + // Use the basename of the circuit path as the circuit name. + const circomCircuitName = + circomCircuitPath + .split('/') + .pop() + .replace(/\.circom$/i, '') || 'my-circom-circuit' + sindriManifest.name = circomCircuitName + sindriManifest.circuitPath = circomCircuitPath + break + } - // Only write out the `sindri.json` file if it doesn't already exist. - if (!('sindri.json' in existingFiles)) { - await plugin.call('fileManager', 'writeFile', - 'sindri.json', - // @ts-ignore - (await import('./sindri.json.raw!=!raw-loader!./sindri.json')).default) - } + // Remove any unsupported characters from the circuit name. + sindriManifest.name = (sindriManifest.name || '').replace(/[^-a-zA-Z0-9_]+/g, '-') - await plugin.call('fileManager', 'open', 'scripts/sindri/sindri.ts') + // Write out the modified manifest file. + writeIfNotExists('sindri.json', JSON.stringify(sindriManifest, null, 2)) + } } From 7a6e89e60b790c3aa6317ede1dd7e0f79d12ce50 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 15:28:55 -0600 Subject: [PATCH 099/138] Use the wrokspace name to determine the circuit name. --- .../src/script-templates/sindri/index.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index 8ffe1b1298..a15f1c3438 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -68,18 +68,17 @@ export const sindriScripts = async (plugin: any) => { return a.path.localeCompare(b.path) }) .map(({path}) => path)[0] || './circuit.circom' - - // Use the basename of the circuit path as the circuit name. - const circomCircuitName = - circomCircuitPath - .split('/') - .pop() - .replace(/\.circom$/i, '') || 'my-circom-circuit' - sindriManifest.name = circomCircuitName sindriManifest.circuitPath = circomCircuitPath break } + const {name: workspaceName} = await plugin.call('filePanel', 'getCurrentWorkspace') + sindriManifest.name = + workspaceName + .replace(/\s*-+\s*\d*$/, '') + .replace(/[^a-zA-Z0-9]+/g, '-') + .replace(/^[^a-zA-Z]+/, '') || `my-${sindriManifest.circuitType}-circuit` + // Remove any unsupported characters from the circuit name. sindriManifest.name = (sindriManifest.name || '').replace(/[^-a-zA-Z0-9_]+/g, '-') From 8d777e64d850d742d8e254eb036c3edb283f722c Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 15:33:46 -0600 Subject: [PATCH 100/138] Add a note about only supporting Circom. --- libs/remix-ws-templates/src/script-templates/sindri/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index a15f1c3438..c6d0f64420 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -19,7 +19,7 @@ const getWorkspaceFilesByPath = async (plugin: any, pathRegex: RegExp | null = n } export const sindriScripts = async (plugin: any) => { - // Load in all of the Sindri or Circom-related files in the workspace. + // Load in all of the Sindri or circuit-related files in the workspace. const existingFilesByPath = await getWorkspaceFilesByPath(plugin, /sindri|\.circom$/i) const writeIfNotExists = async (path: string, content: string) => { if (!(path in existingFilesByPath)) { @@ -42,6 +42,9 @@ export const sindriScripts = async (plugin: any) => { // @ts-ignore const sindriManifest = (await import('./sindri.json')).default + // TODO: We can try to infer the circuit framework here from the project contents. + // For now, we only support Circom. + // Infer manifest properties from the existing files in the workspace. switch (sindriManifest.circuitType) { case 'circom': From 8372e6dee063e0b689d9b3dd166b0e8ab93752e6 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 15:38:41 -0600 Subject: [PATCH 101/138] Fix: missing await. --- libs/remix-ws-templates/src/script-templates/sindri/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 21016b6abe..99bc82dea1 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -67,7 +67,7 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ const sindriManifest = await getSindriManifest() // Create a map from file paths to `File` objects for all files in the workspace. - const filesByPath = getWorkspaceFilesByPath() + const filesByPath = await getWorkspaceFilesByPath() // Merge any of the circuit's resolved dependencies into the files at their expected import paths. if (sindriManifest.circuitType === 'circom') { From 82b1a2f2bfcf54effc6f2a85e27b1c214f10fd32 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 15:38:49 -0600 Subject: [PATCH 102/138] Lowercase the circuit name. --- .../src/script-templates/sindri/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index c6d0f64420..45e323706d 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -75,15 +75,14 @@ export const sindriScripts = async (plugin: any) => { break } + // Derive the circuit name from the workspace name. const {name: workspaceName} = await plugin.call('filePanel', 'getCurrentWorkspace') sindriManifest.name = workspaceName .replace(/\s*-+\s*\d*$/, '') .replace(/[^a-zA-Z0-9]+/g, '-') - .replace(/^[^a-zA-Z]+/, '') || `my-${sindriManifest.circuitType}-circuit` - - // Remove any unsupported characters from the circuit name. - sindriManifest.name = (sindriManifest.name || '').replace(/[^-a-zA-Z0-9_]+/g, '-') + .replace(/^[^a-zA-Z]+/, '') + .toLowerCase() || `my-${sindriManifest.circuitType}-circuit` // Write out the modified manifest file. writeIfNotExists('sindri.json', JSON.stringify(sindriManifest, null, 2)) From 552fdb885b5f1ab72cb94c763652fee10c9dfd93 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 16:19:08 -0600 Subject: [PATCH 103/138] Maybe fix linting. --- .../src/script-templates/sindri/index.ts | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index 45e323706d..347b6610a6 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -46,33 +46,31 @@ export const sindriScripts = async (plugin: any) => { // For now, we only support Circom. // Infer manifest properties from the existing files in the workspace. - switch (sindriManifest.circuitType) { - case 'circom': - // Try to find the best `.circom` source file to use as the main component. - // First, we limit ourselves to `.circom` files. - const circomPathsAndContents = await Promise.all( - Object.entries(existingFilesByPath) - .filter(([path]) => /\.circom$/i.test(path)) - .map(async ([path, file]) => [path, await file.text()]) - ) - // Now we apply some heuristics to find the "best" file. - const circomCircuitPath = - circomPathsAndContents - .map(([path, content]) => ({ - content, - hasMainComponent: !!/^[ \t\f]*component[ \t\f]+main[^\n\r]*;[ \t\f]*$/m.test(content), - // These files are the entrypoints to the Remix Circom templates, so we give them a boost if there are multiple main components. - isTemplateEntrypoint: !!['calculate_hash.circom', 'rln.circom', 'semaphore.circom'].includes(path.split('/').pop() ?? ''), - path, - })) - .sort((a, b) => { - if (a.hasMainComponent !== b.hasMainComponent) return +b.hasMainComponent - +a.hasMainComponent - if (a.isTemplateEntrypoint !== b.isTemplateEntrypoint) return +b.isTemplateEntrypoint - +a.isTemplateEntrypoint - return a.path.localeCompare(b.path) - }) - .map(({path}) => path)[0] || './circuit.circom' - sindriManifest.circuitPath = circomCircuitPath - break + if (sindriManifest.circuitType === 'circom') { + // Try to find the best `.circom` source file to use as the main component. + // First, we limit ourselves to `.circom` files. + const circomPathsAndContents = await Promise.all( + Object.entries(existingFilesByPath) + .filter(([path]) => /\.circom$/i.test(path)) + .map(async ([path, file]) => [path, await file.text()]) + ) + // Now we apply some heuristics to find the "best" file. + const circomCircuitPath = + circomPathsAndContents + .map(([path, content]) => ({ + content, + hasMainComponent: !!/^[ \t\f]*component[ \t\f]+main[^\n\r]*;[ \t\f]*$/m.test(content), + // These files are the entrypoints to the Remix Circom templates, so we give them a boost if there are multiple main components. + isTemplateEntrypoint: !!['calculate_hash.circom', 'rln.circom', 'semaphore.circom'].includes(path.split('/').pop() ?? ''), + path, + })) + .sort((a, b) => { + if (a.hasMainComponent !== b.hasMainComponent) return +b.hasMainComponent - +a.hasMainComponent + if (a.isTemplateEntrypoint !== b.isTemplateEntrypoint) return +b.isTemplateEntrypoint - +a.isTemplateEntrypoint + return a.path.localeCompare(b.path) + }) + .map(({path}) => path)[0] || './circuit.circom' + sindriManifest.circuitPath = circomCircuitPath } // Derive the circuit name from the workspace name. From fb7b26c0f3b332e515d7401dde2ed60e92f95c5a Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 17:59:32 -0600 Subject: [PATCH 104/138] Manually exclude everything in `.deps` for now. --- .../src/script-templates/sindri/utils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 99bc82dea1..41a7c30736 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -25,11 +25,12 @@ const getSindriManifest = async () => { /** * Create a map of file paths to `File` objects for either all or a subset of files in the workspace. * - * @param {RegExp | null} pathRegex - A regular expression to limit the included files to those + * @param {RegExp | null} includeRegex - A regular expression to limit the included files to those * whose paths match. If not specified, then all paths are included. + * @param {RegExp | null} excludeRegex - A regular expression to exclude files whose paths match. * @returns {Promise<{[path: string]: File}>} A map of file paths to `File` objects. */ -export const getWorkspaceFilesByPath = async (pathRegex: RegExp | null = null): Promise<{[path: string]: File}> => { +const getWorkspaceFilesByPath = async (includeRegex: RegExp | null = null, excludeRegex: RegExp | null = null): Promise<{[path: string]: File}> => { const filesByPath: {[path: string]: File} = {} interface Workspace { children?: Workspace @@ -39,7 +40,7 @@ export const getWorkspaceFilesByPath = async (pathRegex: RegExp | null = null): const childQueue: Array<[string, Workspace]> = Object.entries(workspace) while (childQueue.length > 0) { const [path, child] = childQueue.pop() - if ('content' in child && (pathRegex === null || pathRegex.test(path))) { + if ('content' in child && (includeRegex === null || includeRegex.test(path)) && (excludeRegex === null || !excludeRegex.test(path))) { filesByPath[path] = new File([child.content], path) } if ('children' in child) { @@ -67,7 +68,7 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ const sindriManifest = await getSindriManifest() // Create a map from file paths to `File` objects for all files in the workspace. - const filesByPath = await getWorkspaceFilesByPath() + const filesByPath = await getWorkspaceFilesByPath(null, /^\.deps\//) // Merge any of the circuit's resolved dependencies into the files at their expected import paths. if (sindriManifest.circuitType === 'circom') { From b230a41b247580b7c40a99affb0bf342499dcf06 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 18:38:03 -0600 Subject: [PATCH 105/138] Add better error handling for when `circuitPath` is set wrong. --- .../src/script-templates/sindri/utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 41a7c30736..82030a0df7 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -73,7 +73,12 @@ export const compile = async (tags: string | string[] | null = ['latest']): Circ // Merge any of the circuit's resolved dependencies into the files at their expected import paths. if (sindriManifest.circuitType === 'circom') { const circuitPath = normalizePath(sindriManifest.circuitPath || 'circuit.circom') - const circuitContent = await remix.call('fileManager', 'readFile', circuitPath) + let circuitContent: string + try { + circuitContent = await remix.call('fileManager', 'readFile', circuitPath) + } catch (error) { + console.error(`No circuit file found at "${circuitPath}", try setting "circuitPath" in "sindri.json".`) + } const dependencies: {[path: string]: string} = await remix.call('circuit-compiler' as any, 'resolveDependencies', circuitPath, circuitContent) Object.entries(dependencies).forEach(([rawPath, rawContent]) => { // Convert absolute file paths to paths relative to the project root. From 9c3b8451dab20850408d204da3a74f0dfdf01dae Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Wed, 14 Feb 2024 18:47:59 -0600 Subject: [PATCH 106/138] Clean up the last vestiges of changes to the circom templates. --- libs/remix-ws-templates/src/templates/hashchecker/index.ts | 4 ++-- libs/remix-ws-templates/src/templates/rln/index.ts | 4 ++-- libs/remix-ws-templates/src/templates/semaphore/index.ts | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/remix-ws-templates/src/templates/hashchecker/index.ts b/libs/remix-ws-templates/src/templates/hashchecker/index.ts index 5f7945ed8b..b119c6d251 100644 --- a/libs/remix-ws-templates/src/templates/hashchecker/index.ts +++ b/libs/remix-ws-templates/src/templates/hashchecker/index.ts @@ -9,6 +9,6 @@ export default async () => { // @ts-ignore 'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default, // @ts-ignore - 'README.md': (await import('raw-loader!./README.md')).default, + 'README.md': (await import('raw-loader!./README.md')).default } -} +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/rln/index.ts b/libs/remix-ws-templates/src/templates/rln/index.ts index 9b8d77372e..92e290ccc3 100644 --- a/libs/remix-ws-templates/src/templates/rln/index.ts +++ b/libs/remix-ws-templates/src/templates/rln/index.ts @@ -17,6 +17,6 @@ export default async () => { // @ts-ignore 'LICENSE-MIT': (await import('!!raw-loader!./LICENSE-MIT')).default, // @ts-ignore - 'README.md': (await import('raw-loader!./README.md')).default, + 'README.md': (await import('raw-loader!./README.md')).default } -} +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/semaphore/index.ts b/libs/remix-ws-templates/src/templates/semaphore/index.ts index 3c8889362e..3c63bc8327 100644 --- a/libs/remix-ws-templates/src/templates/semaphore/index.ts +++ b/libs/remix-ws-templates/src/templates/semaphore/index.ts @@ -12,5 +12,7 @@ export default async () => { 'scripts/run_verification.ts': (await import('!!raw-loader!./scripts/run_verification.ts')).default, // @ts-ignore 'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default, + // @ts-ignore + 'README.md': (await import('raw-loader!./README.md')).default } -} +} \ No newline at end of file From 2a26a0ac8c37593f38457b17002ea231548dc962 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Thu, 15 Feb 2024 07:51:31 -0600 Subject: [PATCH 107/138] Inline getting the workspace paths. --- .../src/script-templates/sindri/utils.ts | 49 ++++++++----------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts index 82030a0df7..8905d037da 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/utils.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/utils.ts @@ -22,15 +22,28 @@ const getSindriManifest = async () => { return JSON.parse(sindriJson) } +const normalizePath = (path: string): string => { + while (path.startsWith('/') || path.startsWith('./')) { + path = path.replace(/^(\.\/|\/)/, '') + } + return path +} + /** - * Create a map of file paths to `File` objects for either all or a subset of files in the workspace. + * Compile the circuit. * - * @param {RegExp | null} includeRegex - A regular expression to limit the included files to those - * whose paths match. If not specified, then all paths are included. - * @param {RegExp | null} excludeRegex - A regular expression to exclude files whose paths match. - * @returns {Promise<{[path: string]: File}>} A map of file paths to `File` objects. + * @param {string | string[] | null} tags - The tag or tags to use when compiling the circuit. + * @returns {CircuitInfoResponse} compiled circuit */ -const getWorkspaceFilesByPath = async (includeRegex: RegExp | null = null, excludeRegex: RegExp | null = null): Promise<{[path: string]: File}> => { +export const compile = async (tags: string | string[] | null = ['latest']): CircuitInfoResponse => { + await authorize() + const sindriManifest = await getSindriManifest() + + // Create a map from file paths to `File` objects for (almost) all files in the workspace. + // We exclude `.deps/` files because these are resolved to more intuitive locations so they can + // be used by the circuit without specifying a complex import path. We'll merge the dependencies + // into the files at their expected import paths in a later step. + const excludeRegex = /^\.deps\// const filesByPath: {[path: string]: File} = {} interface Workspace { children?: Workspace @@ -40,35 +53,13 @@ const getWorkspaceFilesByPath = async (includeRegex: RegExp | null = null, exclu const childQueue: Array<[string, Workspace]> = Object.entries(workspace) while (childQueue.length > 0) { const [path, child] = childQueue.pop() - if ('content' in child && (includeRegex === null || includeRegex.test(path)) && (excludeRegex === null || !excludeRegex.test(path))) { + if ('content' in child && !excludeRegex.test(path)) { filesByPath[path] = new File([child.content], path) } if ('children' in child) { childQueue.push(...Object.entries(child.children)) } } - return filesByPath -} - -const normalizePath = (path: string): string => { - while (path.startsWith('/') || path.startsWith('./')) { - path = path.replace(/^(\.\/|\/)/, '') - } - return path -} - -/** - * Compile the circuit. - * - * @param {string | string[] | null} tags - The tag or tags to use when compiling the circuit. - * @returns {CircuitInfoResponse} compiled circuit - */ -export const compile = async (tags: string | string[] | null = ['latest']): CircuitInfoResponse => { - await authorize() - const sindriManifest = await getSindriManifest() - - // Create a map from file paths to `File` objects for all files in the workspace. - const filesByPath = await getWorkspaceFilesByPath(null, /^\.deps\//) // Merge any of the circuit's resolved dependencies into the files at their expected import paths. if (sindriManifest.circuitType === 'circom') { From 7423e4e3f3716c6b50d0fff397813558125e17f5 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Thu, 15 Feb 2024 12:22:23 -0600 Subject: [PATCH 108/138] Add a README to `sindri/scripts/`. --- .../src/script-templates/sindri/README.md | 120 ++++++++++++++++++ .../src/script-templates/sindri/index.ts | 8 +- 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 libs/remix-ws-templates/src/script-templates/sindri/README.md diff --git a/libs/remix-ws-templates/src/script-templates/sindri/README.md b/libs/remix-ws-templates/src/script-templates/sindri/README.md new file mode 100644 index 0000000000..141c7f7935 --- /dev/null +++ b/libs/remix-ws-templates/src/script-templates/sindri/README.md @@ -0,0 +1,120 @@ +# Sindri Scripts + +The `sindri/scripts/` directory contains scripts for compiling circuits and generating Zero-Knowledge Proofs remotely using [Sindri](https://sindri.app). +This README file will walk you through all of the steps necessary to compile your circuit and generate proofs. +As you read through it, you might also find it helpful to refer to external documentation: + +- [Circom 2 Documentation](https://docs.circom.io/) +- [Sindri Documentation](https://sindri.app/docs/) + +## Add the Sindri ZK Scripts + +If you're seeing this README, then you've probably already figured out this step on your own! +You can add the Sindri ZK scripts and related project files to your workspace by clicking the hamburger icon in the upper left corner of the **File Explorer** and selecting **Add Sindri ZK scripts**. +This will automatically add this README file, several TypeScript files, a `sindri.json` project manifest, and a `.sindriignore` file to your workspace. +We'll cover these files in more detail below. + +## API Key + +To interact with the Sindri API, you will first need to create a Sindri account, generate an API key, and add it to your Remix IDE settings. +This only needs to be done once, your credentials will be shared across all of your current and future workspaces once you've added your API key. + +1. Visit [The Sindri Homepage](https://sindri.app/) and request a demo to create your account. +2. Follow the instructions in the [Access Management](https://sindri.app/docs/topic-guides/access-management/#api-key-creation-and-management) documentation to generate an API key. +3. Open the **Settings** panel by clicking on the gear icon at the very bottom of the icon panel on the left side of the Remix IDE (see the [Remix IDE Settings](https://remix-ide.readthedocs.io/en/latest/settings.html) documentation if you're having trouble finding it. +4. Navigate to the **Sindri Credentials** section of the **Settings** panel, enter your Sindri API key under **Token**, and click the **Save** button. + +## Customize `sindri.json` _(Optional)_ + +A `sindri.json` file was added to the root of your workspace, and automatically customized to fit your project layout. +This file is the **Sindri Manifest** and is required for all projects deployed to Sindri. +It's also used by the [Sindri CLI](https://github.com/Sindri-Labs/sindri-js) for local circuit operations which don't require a Sindri account. + +If the automatic customization missed something, or if you'd like to make further customizations, then you'll need to edit this file yourself. +When editing `sindri.json` in the Remix IDE, you should get in-editor diagnostics and documentation about the format of the file. +You can mouse over the different properties and their values to view their documentation and any potential errors with the values. + +The fields that you're most likely to want to customize are: + +- `name` - This is a unique project identifier for your circuit. + You can think of it as being analogous to a GitHub project name or a DockerHub image name. + Every time you compile a circuit with Sindri, the compiled circuit will be associated with the project and one or more tags (`latest` by default). + We guessed this based on your workspace name, but you can change this to something else if you don't like that name. +- `circuitPath` - This defines the entrypoint for a Circom circuit (_i.e_ the `.circom` source file which contains your `main` component). + We did our best to guess this as well, but you'll need to update this manually if you refactor your circuit files or the wrong entrypoint was detected. + +## Customize `.sindriignore` _(Optional)_ + +A `.sindriignore` file was automatically added to the root of your workspace when you added the ZK scripts. +This file can be used to exclude files and directories from your circuit package when deploying it to Sindri, and it follows the [`.gitignore` Format](https://git-scm.com/docs/gitignore). +The generated file includes some sane defaults, but you can feel free to customize it as you see fit. +This is particularly useful if you want to exclude files that contain sensitive information like credentials or secret keys. +Excluding irrelevant files will also have a positive impact on the performance of compiling and generating proofs because less data needs to be transferred. + +## Compile the Circuit + +The `scripts/sindri/run_compile.ts` script can be used to compile a new version of your circuit. +To run it, you can open the script from the **File Explorer**, then either click the play button icon in the upper left corner of the editor panel or press `CTRL + SHIFT + S`. +After running it, you should see something like + +``` +Compiling circuit "multiplier2"... +Circuit compiled successfully, circuit id: f593a775-723c-4c57-8d75-196aa8c22aa0 +``` + +indicating that the circuit compiled successfully. + +By default, this newly compiled circuit will be assigned a tag of `latest` and replace any previous circuit with that tag. +If you would like to use alternative tags, you can modify the script to pass an array of tags to the `compile()` function call in the script. +We recommend starting out with the default of `latest` as you're getting started, and then moving towards tighter tag management once you're closer to productionizing your circuit. + +## Generate a Proof + +Once you've compiled your circuit, you're almost ready to use the `scripts/sindri/run_prove.ts` script to generate a proof. +You'll first need to modify this file to pass in the input signals that you would like to generate a proof for when calling `prove(signals)` (see Circom's [Signals & Variables](https://docs.circom.io/circom-language/signals/) documentation if you need a refresher on circuit signals). +Towards the top of the script, you'll see where the `signals` variable is defined. + +```typescript +const signals: {[name: string]: number | string} = {} +``` + +You'll need to modify this object to include a map from your circuit's signal names to the values you would like to generate a proof with. +If the signals aren't set correctly, then you'll get an error when you try to generate a proof, so make sure you don't skip this step. + +While the `scripts/sindri/run_prove.ts` script is open in the editor, you can click the play icon or press `CTRL + SHIFT + S` to run the script. +If proof generation is successful, you should see an output like this. + +``` +Proving circuit "multiplier2"... +Proof generated successfully, proof id: 8c457574-99cd-4042-a598-0514ee83ea28 +Proof: +{ + "pi_a": [ + "6067132175610399619979395342154926888794311761598436094198046058376456187483", + "12601521866404307402196517712981356634013036480344794909770435164414221099781", + "1" + ], + "pi_b": [ + [ + "4834637265002576910303922443793957462767968914058257618737938706178679757759", + "9112483377654285712375849001111771826297690938023943203596780715231459796539" + ], + [ + "10769047435756102293620257834720404252539733306406452142820929656229947907912", + "13357635314682194333795190402038393873064494630028726306217246944693858036728" + ], + [ + "1", + "0" + ] + ], + "pi_c": [ + "14880777940364750676687351211095959384403767617776048892575602333362895582325", + "16991336882479219442414889002846661737157620156103416755440340170710340617407", + "1" + ], + "protocol": "groth16" +} +``` + +You can either manually copy the proof to wherever you would like to use it, or modify the script to save it to a dedicated location. diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index 347b6610a6..229f92098b 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -31,11 +31,13 @@ export const sindriScripts = async (plugin: any) => { // @ts-ignore await writeIfNotExists('scripts/.sindriignore', (await import('!!raw-loader!./.sindriignore')).default) // @ts-ignore - await writeIfNotExists('scripts/sindri/utils.ts', (await import('!!raw-loader!./utils.ts')).default) + await writeIfNotExists('scripts/sindri/README.md', (await import('!!raw-loader!./README.md')).default) // @ts-ignore await writeIfNotExists('scripts/sindri/run_compile.ts', (await import('!!raw-loader!./run_compile.ts')).default) // @ts-ignore await writeIfNotExists('scripts/sindri/run_prove.ts', (await import('!!raw-loader!./run_prove.ts')).default) + // @ts-ignore + await writeIfNotExists('scripts/sindri/utils.ts', (await import('!!raw-loader!./utils.ts')).default) // Only write out the `sindri.json` file if it doesn't already exist. if (!('sindri.json' in existingFilesByPath)) { @@ -85,4 +87,8 @@ export const sindriScripts = async (plugin: any) => { // Write out the modified manifest file. writeIfNotExists('sindri.json', JSON.stringify(sindriManifest, null, 2)) } + + // Open the README file in the editor. + await plugin.call('doc-viewer' as any, 'viewDocs', ["scripts/sindri/README.md"]) + plugin.call('tabs' as any, 'focus', 'doc-viewer') } From 0a3ef6bc0d69824bc7808d626b24c58138884d15 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Fri, 16 Feb 2024 10:07:00 -0600 Subject: [PATCH 109/138] Fix `.sindriignore` file location. --- libs/remix-ws-templates/src/script-templates/sindri/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/script-templates/sindri/index.ts b/libs/remix-ws-templates/src/script-templates/sindri/index.ts index 229f92098b..fdc58bfad1 100644 --- a/libs/remix-ws-templates/src/script-templates/sindri/index.ts +++ b/libs/remix-ws-templates/src/script-templates/sindri/index.ts @@ -29,7 +29,7 @@ export const sindriScripts = async (plugin: any) => { // Write out all of the static files if they don't exist. // @ts-ignore - await writeIfNotExists('scripts/.sindriignore', (await import('!!raw-loader!./.sindriignore')).default) + await writeIfNotExists('.sindriignore', (await import('!!raw-loader!./.sindriignore')).default) // @ts-ignore await writeIfNotExists('scripts/sindri/README.md', (await import('!!raw-loader!./README.md')).default) // @ts-ignore From 2123c00ddda97bfff431e9485ce88cf9d4578bc2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 26 Feb 2024 18:25:00 +0100 Subject: [PATCH 110/138] Update workspace.ts --- libs/remix-ui/workspace/src/lib/actions/workspace.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index fd5b09e9b0..047975301d 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -872,7 +872,7 @@ export const createSlitherGithubAction = async () => { export const createHelperScripts = async (script: string) => { if (!templates[script]) return await templates[script](plugin) - plugin.call('notification', 'toast', 'scripts added in the "scripts" folder') + plugin.call('notification', 'toast', `'${script}' added to the workspace.`) } export const updateGitSubmodules = async () => { From 49c3cf6924f30c959ecfa7ad14e6bff2c6e99675 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 27 Feb 2024 11:34:38 +0100 Subject: [PATCH 111/138] fix label && alert --- apps/remix-ide/src/app/tabs/locales/es/filePanel.json | 2 +- apps/remix-ide/src/app/tabs/locales/fr/filePanel.json | 2 +- apps/remix-ide/src/app/tabs/locales/it/filePanel.json | 2 +- apps/remix-ide/src/app/tabs/locales/zh/filePanel.json | 2 +- libs/remix-core-plugin/src/lib/gist-handler.ts | 7 +++++-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/locales/es/filePanel.json b/apps/remix-ide/src/app/tabs/locales/es/filePanel.json index 7e4c76a90c..ca6da409aa 100644 --- a/apps/remix-ide/src/app/tabs/locales/es/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/es/filePanel.json @@ -86,7 +86,7 @@ "filePanel.copyFolderFailed": "Copia de Carpeta Fallida", "filePanel.copyFolderFailedMsg": "Error inesperado al copiar la carpeta: {src}", "filePanel.runScriptFailed": "Error al ejecutar el script", - "filePanel.createPublicGist": "Crear una lista pública", + "filePanel.createPublicGist": "Publicar una lista pública", "filePanel.createPublicGistMsg1": "¿Está seguro que desea empujar cambios al archivo gist remoto en github.com?", "filePanel.createPublicGistMsg2": "¿Estás seguro que quieres publicar todos tus archivos de forma anónima en la carpeta {path} como un gist público en github.com?", "filePanel.createPublicGistMsg3": "¿Estás seguro de que quieres publicar de forma anónima el archivo {path} como una gist público en github.com?", diff --git a/apps/remix-ide/src/app/tabs/locales/fr/filePanel.json b/apps/remix-ide/src/app/tabs/locales/fr/filePanel.json index 1a72cc82cd..b38d0682b9 100644 --- a/apps/remix-ide/src/app/tabs/locales/fr/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/fr/filePanel.json @@ -86,7 +86,7 @@ "filePanel.copyFolderFailed": "Échec de la copie du dossier", "filePanel.copyFolderFailedMsg": "Erreur inattendue lors de la copie du fichier : {src}", "filePanel.runScriptFailed": "Échec de l'exécution du script", - "filePanel.createPublicGist": "Créer un gist public", + "filePanel.createPublicGist": "Publier un gist public", "filePanel.createPublicGistMsg1": "Êtes-vous sûr de vouloir envoyer les changements dans le fichier gist distant sur github.com?", "filePanel.createPublicGistMsg2": "Êtes-vous sûr de vouloir publier anonymement tous vos fichiers dans le dossier {path} en tant que gist public sur github.com?", "filePanel.createPublicGistMsg3": "Êtes-vous sûr de vouloir publier anonymement tous vos fichiers dans le dossier {path} en tant que gist public sur github.com?", diff --git a/apps/remix-ide/src/app/tabs/locales/it/filePanel.json b/apps/remix-ide/src/app/tabs/locales/it/filePanel.json index 994dedf5c6..fa8728fa68 100644 --- a/apps/remix-ide/src/app/tabs/locales/it/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/it/filePanel.json @@ -86,7 +86,7 @@ "filePanel.copyFolderFailed": "Copia Cartella Non Riuscita", "filePanel.copyFolderFailedMsg": "Errore inatteso durante la copia della cartella: {src}", "filePanel.runScriptFailed": "Esecuzione dello script non riuscita", - "filePanel.createPublicGist": "Crea Gist Pubblico", + "filePanel.createPublicGist": "Pubblicare Gist Pubblico", "filePanel.createPublicGistMsg1": "Sei sicuro di voler inviare le modifiche al file gist remoto su github.com?", "filePanel.createPublicGistMsg2": "Sei sicuro di voler pubblicare in modo anonimo tutti i tuoi file nella cartella {path} come gist pubblico su github.com?", "filePanel.createPublicGistMsg3": "Sei sicuro di voler pubblicare in modo anonimo tutti i tuoi file nella cartella {path} come gist pubblico su github.com?", diff --git a/apps/remix-ide/src/app/tabs/locales/zh/filePanel.json b/apps/remix-ide/src/app/tabs/locales/zh/filePanel.json index 4d1ea78fa7..6f74fdae19 100644 --- a/apps/remix-ide/src/app/tabs/locales/zh/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/zh/filePanel.json @@ -86,7 +86,7 @@ "filePanel.copyFolderFailed": "复制文件夹失败", "filePanel.copyFolderFailedMsg": "复制文件夹时出现意外错误:{src}", "filePanel.runScriptFailed": "执行脚本失败", - "filePanel.createPublicGist": "创建一个公开的 gist", + "filePanel.createPublicGist": "发布到公共 gist", "filePanel.createPublicGistMsg1": "您确定要将更改推送到 github.com 上的远程 gist 文件吗?", "filePanel.createPublicGistMsg2": "您确定要在 github.com 上以匿名方式将 {path} 文件夹中的所有文件发布为公开的 gist?", "filePanel.createPublicGistMsg3": "您确定要将 {path} 文件匿名发布为 github.com 上的公开 gist?", diff --git a/libs/remix-core-plugin/src/lib/gist-handler.ts b/libs/remix-core-plugin/src/lib/gist-handler.ts index c3a53a75f1..f2f4b3d7fc 100644 --- a/libs/remix-core-plugin/src/lib/gist-handler.ts +++ b/libs/remix-core-plugin/src/lib/gist-handler.ts @@ -117,8 +117,11 @@ export class GistHandler extends Plugin { const gistIdWorkspace = 'gist ' + gistId const workspaces = await this.call('filePanel', 'getWorkspaces') const found = workspaces.find((workspace) => workspace.name === gistIdWorkspace) - if (found) { - await this.call('notification', 'alert', `workspace "${gistIdWorkspace}" already exist`) + if (found) { + await this.call('notification', 'alert', { + id: 'gistAlert', + message: `workspace "${gistIdWorkspace}" already exist`, + }) return } await this.call('filePanel', 'createWorkspace', 'gist ' + gistId, '', true) From c2d6bdec3b4c7fd46708888f6fe5c208b1c5a8eb Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 27 Feb 2024 11:46:19 +0100 Subject: [PATCH 112/138] Update label gist --- apps/remix-ide/src/app/tabs/locales/en/filePanel.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json index 57b7951f64..fd217f921f 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json @@ -96,7 +96,7 @@ "filePanel.copyFolderFailed": "Copy Folder Failed", "filePanel.copyFolderFailedMsg": "Unexpected error while copying folder: {src}", "filePanel.runScriptFailed": "Run script failed", - "filePanel.createPublicGist": "Create a public gist", + "filePanel.createPublicGist": "Publish to a public gist", "filePanel.createPublicGistMsg1": "Are you sure you want to push changes to remote gist file on github.com?", "filePanel.createPublicGistMsg2": "Are you sure you want to anonymously publish all your files in the {path} folder as a public gist on github.com?", "filePanel.createPublicGistMsg3": "Are you sure you want to anonymously publish {path} file as a public gist on github.com?", From 44b40c651e0d32d777c6d292655cb130d4a87d89 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 27 Feb 2024 12:12:25 +0100 Subject: [PATCH 113/138] Update gist-handler.ts --- libs/remix-core-plugin/src/lib/gist-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-core-plugin/src/lib/gist-handler.ts b/libs/remix-core-plugin/src/lib/gist-handler.ts index f2f4b3d7fc..83c932d4c6 100644 --- a/libs/remix-core-plugin/src/lib/gist-handler.ts +++ b/libs/remix-core-plugin/src/lib/gist-handler.ts @@ -120,7 +120,7 @@ export class GistHandler extends Plugin { if (found) { await this.call('notification', 'alert', { id: 'gistAlert', - message: `workspace "${gistIdWorkspace}" already exist`, + message: `workspace "${gistIdWorkspace}" already exists`, }) return } From d08019670b3095207b262dac71c55d8467a81f85 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 27 Feb 2024 16:37:03 +0530 Subject: [PATCH 114/138] improve UI for saved contracts --- apps/remix-ide/src/app/tabs/locales/en/udapp.json | 2 +- .../run-tab/src/lib/components/instanceContainerUI.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/locales/en/udapp.json b/apps/remix-ide/src/app/tabs/locales/en/udapp.json index 2117fc9aab..274bae99ad 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/udapp.json +++ b/apps/remix-ide/src/app/tabs/locales/en/udapp.json @@ -71,7 +71,7 @@ "udapp.tooltipText6": "Autogenerated generic user interfaces for interaction with deployed contracts", "udapp.savedContracts": "Saved Contracts", - "udapp.NoSavedInstanceText": "Currently you have no saved contracts to interact with.", + "udapp.NoSavedInstanceText": "No saved contracts found.", "udapp.tooltipTextUnsave": "Unsave & move to Deployed Contracts list", "udapp.savedOn": "Saved On", "udapp.filePath": "File Path", diff --git a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx index 2b73b5c948..4af506a691 100644 --- a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx @@ -36,7 +36,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) { return (
{ env.current && env.current === 'injected' ? ( -
+
}>
) : ( - + ) ) : null } -
+
}>