From ae5686ff9d51c9cc06f97784224fb12028e86ff1 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 3 Jan 2024 16:10:40 +0100 Subject: [PATCH 1/7] fix matomo --- apps/remix-ide/src/app/tabs/settings-tab.tsx | 2 -- apps/remix-ide/src/assets/js/loader.js | 7 ++----- .../app/src/lib/remix-app/components/modals/matomo.tsx | 2 -- libs/remix-ui/app/src/lib/remix-app/remix-app.tsx | 2 +- libs/remix-ui/settings/src/lib/settingsAction.ts | 6 ++++-- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/settings-tab.tsx b/apps/remix-ide/src/app/tabs/settings-tab.tsx index 3950e72a47..63a2b89979 100644 --- a/apps/remix-ide/src/app/tabs/settings-tab.tsx +++ b/apps/remix-ide/src/app/tabs/settings-tab.tsx @@ -92,11 +92,9 @@ module.exports = class SettingsTab extends ViewPlugin { this.config.set('settings/matomo-analytics', isChecked) this.useMatomoAnalytics = isChecked if (!isChecked) { - _paq.push(['optUserOut']) // revoke tracking consent _paq.push(['forgetConsentGiven']); } else { - _paq.push(['forgetUserOptOut']) // user has given consent to process their data _paq.push(['setConsentGiven']); } diff --git a/apps/remix-ide/src/assets/js/loader.js b/apps/remix-ide/src/assets/js/loader.js index 5938aeaf9c..4abdfc6526 100644 --- a/apps/remix-ide/src/assets/js/loader.js +++ b/apps/remix-ide/src/assets/js/loader.js @@ -18,17 +18,14 @@ if (domains[window.location.hostname]) { _paq.push(["setExcludedQueryParams", ["code","gist"]]); _paq.push(["setExcludedReferrers", ["etherscan.io"]]); _paq.push(['enableJSErrorTracking']); - // require user tracking consent before processing data - _paq.push(['requireConsent']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); _paq.push(['enableHeartBeatTimer']); if (!window.localStorage.getItem('config-v0.8:.remix.config') || (window.localStorage.getItem('config-v0.8:.remix.config') && !window.localStorage.getItem('config-v0.8:.remix.config').includes('settings/matomo-analytics'))) { - _paq.push(['optUserOut']) - + // require user tracking consent before processing data + _paq.push(['requireConsent']); } else { - _paq.push(['forgetUserOptOut']) // user has given consent to process their data _paq.push(['setConsentGiven']) } diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/matomo.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/matomo.tsx index 59391d1e09..8148602796 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/modals/matomo.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/matomo.tsx @@ -61,14 +61,12 @@ const MatomoDialog = (props: MatomoDialogProps) => { const declineModal = async () => { settings.updateMatomoAnalyticsChoice(false) - _paq.push(['optUserOut']) // revoke tracking consent _paq.push(['forgetConsentGiven']); setVisible(false) } const handleModalOkClick = async () => { - _paq.push(['forgetUserOptOut']) // user has given consent to process their data _paq.push(['setConsentGiven']); settings.updateMatomoAnalyticsChoice(true) diff --git a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx index aed01704a0..d646f75e49 100644 --- a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx @@ -123,7 +123,7 @@ const RemixApp = (props: IRemixAppUi) => { break } case UsageTypes.Advance: { - _paq.push(['trackEvent', 'enterDialog', 'usageType', 'tutor']) + _paq.push(['trackEvent', 'enterDialog', 'usageType', 'advanced']) break } case UsageTypes.Prototyper: { diff --git a/libs/remix-ui/settings/src/lib/settingsAction.ts b/libs/remix-ui/settings/src/lib/settingsAction.ts index cc5b096ee0..6e59d25ffb 100644 --- a/libs/remix-ui/settings/src/lib/settingsAction.ts +++ b/libs/remix-ui/settings/src/lib/settingsAction.ts @@ -43,9 +43,11 @@ export const useMatomoAnalytics = (config, checked, dispatch) => { config.set('settings/matomo-analytics', checked) dispatch({ type: 'useMatomoAnalytics', payload: { isChecked: checked, textClass: checked ? textDark : textSecondary } }) if (checked) { - _paq.push(['forgetUserOptOut']) + // user has given consent to process their data + _paq.push(['setConsentGiven']); } else { - _paq.push(['optUserOut']) + // revoke tracking consent + _paq.push(['forgetConsentGiven']); } } From 45f1dd160657705645a750e0ede8d131c88fcb37 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 6 Dec 2023 14:39:10 +0100 Subject: [PATCH 2/7] v2.1.6 changes to UI --- .../src/app/components/configurations.tsx | 5 ++++- .../src/app/services/circomPluginClient.ts | 22 ++++++++++++------- apps/circuit-compiler/src/app/types/index.ts | 2 +- package.json | 2 +- yarn.lock | 8 +++---- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/apps/circuit-compiler/src/app/components/configurations.tsx b/apps/circuit-compiler/src/app/components/configurations.tsx index 34b5075b69..c42a86cc35 100644 --- a/apps/circuit-compiler/src/app/components/configurations.tsx +++ b/apps/circuit-compiler/src/app/components/configurations.tsx @@ -14,7 +14,7 @@ export function Configurations ({primeValue, setPrimeValue}: ConfigurationsProps placement={"auto"} tooltipId="circuitPrimeLabelTooltip" tooltipClasses="text-nowrap" - tooltipText={{'To choose the prime number to use to generate the circuit. Receives the name of the curve (bn128, bls12381, goldilocks) [default: bn128]'}} + tooltipText={{'To choose the prime number to use to generate the circuit. Receives the name of the curve (bn128, bls12381, goldilocks, grumpkin, pallas, vesta)'}} >
diff --git a/apps/circuit-compiler/src/app/services/circomPluginClient.ts b/apps/circuit-compiler/src/app/services/circomPluginClient.ts index 0eccddb281..86f5bc3e19 100644 --- a/apps/circuit-compiler/src/app/services/circomPluginClient.ts +++ b/apps/circuit-compiler/src/app/services/circomPluginClient.ts @@ -2,14 +2,16 @@ import { PluginClient } from '@remixproject/plugin' import { createClient } from '@remixproject/plugin-webview' import EventManager from 'events' import pathModule from 'path' -import { parse, compile, generate_witness, generate_r1cs, compiler_list } from 'circom_wasm' +import { compiler_list } from 'circom_wasm' +import compilerV216 from 'circom_wasm/v2.1.6' +import compilerV215 from 'circom_wasm/v2.1.5' import { extractNameFromKey, extractParentFromKey } from '@remix-ui/helper' import { CompilationConfig, CompilerReport, ResolverOutput } from '../types' export class CircomPluginClient extends PluginClient { public internalEvents: EventManager private _compilationConfig: CompilationConfig = { - version: "2.1.5", + version: "2.1.6", prime: "bn128" } private lastCompiledCircuitPath: string = '' @@ -38,7 +40,8 @@ export class CircomPluginClient extends PluginClient { fileContent = await this.call('fileManager', 'readFile', path) } this.lastParsedFiles = await this.resolveDependencies(path, fileContent, { [path]: { content: fileContent, parent: null } }) - const parsedOutput = parse(path, this.lastParsedFiles) + const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216 + const parsedOutput = compiler.parse(path, this.lastParsedFiles) try { const result: CompilerReport[] = JSON.parse(parsedOutput.report()) @@ -122,12 +125,13 @@ export class CircomPluginClient extends PluginClient { if (compilationConfig) { const { prime, version } = compilationConfig - if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks")) throw new Error('Invalid prime value') + if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta")) throw new Error('Invalid prime value') if (!compiler_list.versions.includes(version)) throw new Error("Unsupported compiler version") this._compilationConfig.prime = prime this._compilationConfig.version = version } - const circuitApi = compile(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) + const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216 + const circuitApi = compiler.compile(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) const circuitProgram = circuitApi.program() if (circuitProgram.length < 1) { @@ -172,12 +176,13 @@ export class CircomPluginClient extends PluginClient { if (compilationConfig) { const { prime, version } = compilationConfig - if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks")) throw new Error('Invalid prime value') + if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta")) throw new Error('Invalid prime value') if (!compiler_list.versions.includes(version)) throw new Error("Unsupported compiler version") this._compilationConfig.prime = prime this._compilationConfig.version = version } - const r1csApi = generate_r1cs(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) + const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216 + const r1csApi = compiler.generate_r1cs(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) const r1csProgram = r1csApi.program() if (r1csProgram.length < 1) { @@ -202,7 +207,8 @@ export class CircomPluginClient extends PluginClient { // @ts-ignore const buffer: any = await this.call('fileManager', 'readFile', wasmPath, { encoding: null }) const dataRead = new Uint8Array(buffer) - const witness = await generate_witness(dataRead, input) + const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216 + const witness = await compiler.generate_witness(dataRead, input) // @ts-ignore await this.call('fileManager', 'writeFile', wasmPath.replace('.wasm', '.wtn'), witness, true) this.internalEvents.emit('circuit_computing_witness_done') diff --git a/apps/circuit-compiler/src/app/types/index.ts b/apps/circuit-compiler/src/app/types/index.ts index 71e1dbfced..41ca140ae0 100644 --- a/apps/circuit-compiler/src/app/types/index.ts +++ b/apps/circuit-compiler/src/app/types/index.ts @@ -45,7 +45,7 @@ export type CompilationConfig = { version: string } -export type PrimeValue = "bn128" | "bls12381" | "goldilocks" +export type PrimeValue = "bn128" | "bls12381" | "goldilocks" | "grumpkin" | "pallas" | "vesta" export type CompilerFeedbackProps = { feedback: string | CompilerReport[], diff --git a/package.json b/package.json index 3ad91b7184..e1b2053021 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,7 @@ "brace": "^0.8.0", "change-case": "^4.1.1", "chokidar": "^2.1.8", - "circom_wasm": "^0.1.0", + "circom_wasm": "0.2.2-alpha", "color-support": "^1.1.3", "commander": "^9.4.1", "core-js": "^3.6.5", diff --git a/yarn.lock b/yarn.lock index e75886fbe1..0f008633f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10062,10 +10062,10 @@ circom_runtime@0.1.22: dependencies: ffjavascript "0.2.57" -circom_wasm@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/circom_wasm/-/circom_wasm-0.1.0.tgz#dda76c7ae9046ea6f1e1cd3754c017ad753bd5c1" - integrity sha512-F7ihfVGjfSz+01yFXLHjKocQFm8j9KBageqMw5+olFWB6+7CXHLjnUaFuU6u+7T0FsL7+JuP18jdcAVQEXoQgw== +circom_wasm@0.2.2-alpha: + version "0.2.2-alpha" + resolved "https://registry.yarnpkg.com/circom_wasm/-/circom_wasm-0.2.2-alpha.tgz#ab21d63105e46ed9d6a91173208c4b0d06da5124" + integrity sha512-TMmypDJUEZ+VX3TS6CpooK6uVdA/scgv1yQ6UlDr9Asmbhd/If3OUcQbE3bAU0Ao4mKFL9AhExJIyZAEeF+kTQ== circular-json@^0.3.0: version "0.3.3" From 77861e208a23f32d88b2e061b3eb0b9ea846a4f6 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 7 Dec 2023 13:25:29 +0100 Subject: [PATCH 3/7] Use setters for compiler version and prime --- .../src/app/services/circomPluginClient.ts | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/apps/circuit-compiler/src/app/services/circomPluginClient.ts b/apps/circuit-compiler/src/app/services/circomPluginClient.ts index 86f5bc3e19..b4c3ecc9ad 100644 --- a/apps/circuit-compiler/src/app/services/circomPluginClient.ts +++ b/apps/circuit-compiler/src/app/services/circomPluginClient.ts @@ -3,10 +3,10 @@ import { createClient } from '@remixproject/plugin-webview' import EventManager from 'events' import pathModule from 'path' import { compiler_list } from 'circom_wasm' -import compilerV216 from 'circom_wasm/v2.1.6' -import compilerV215 from 'circom_wasm/v2.1.5' +import * as compilerV216 from 'circom_wasm/v2.1.6' +import * as compilerV215 from 'circom_wasm/v2.1.5' import { extractNameFromKey, extractParentFromKey } from '@remix-ui/helper' -import { CompilationConfig, CompilerReport, ResolverOutput } from '../types' +import { CompilationConfig, CompilerReport, PrimeValue, ResolverOutput } from '../types' export class CircomPluginClient extends PluginClient { public internalEvents: EventManager @@ -17,6 +17,7 @@ export class CircomPluginClient extends PluginClient { private lastCompiledCircuitPath: string = '' private lastParsedFiles: Record = {} private lastCompiledFile: string = '' + private compiler: typeof compilerV215 | typeof compilerV216 = compilerV216 constructor() { super() @@ -34,14 +35,26 @@ export class CircomPluginClient extends PluginClient { this.internalEvents.emit('circom_activated') } + set compilerVersion (version: string) { + if (!compiler_list.versions.includes(version)) throw new Error("Unsupported compiler version") + this._compilationConfig.version = version + if (version === '2.1.5') this.compiler = compilerV215 + else if (version === '2.1.6') this.compiler = compilerV216 + } + + set compilerPrime (prime: PrimeValue) { + if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (this._compilationConfig.version === '2.1.5')) throw new Error('Invalid prime value') + if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta") && (this._compilationConfig.version === '2.1.6')) throw new Error('Invalid prime value') + this._compilationConfig.prime = prime + } + async parse(path: string, fileContent?: string): Promise<[CompilerReport[], Record]> { if (!fileContent) { // @ts-ignore fileContent = await this.call('fileManager', 'readFile', path) } this.lastParsedFiles = await this.resolveDependencies(path, fileContent, { [path]: { content: fileContent, parent: null } }) - const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216 - const parsedOutput = compiler.parse(path, this.lastParsedFiles) + const parsedOutput = this.compiler.parse(path, this.lastParsedFiles) try { const result: CompilerReport[] = JSON.parse(parsedOutput.report()) @@ -125,13 +138,10 @@ export class CircomPluginClient extends PluginClient { if (compilationConfig) { const { prime, version } = compilationConfig - if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta")) throw new Error('Invalid prime value') - if (!compiler_list.versions.includes(version)) throw new Error("Unsupported compiler version") - this._compilationConfig.prime = prime - this._compilationConfig.version = version + this.compilerVersion = version + this.compilerPrime = prime } - const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216 - const circuitApi = compiler.compile(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) + const circuitApi = this.compiler.compile(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) const circuitProgram = circuitApi.program() if (circuitProgram.length < 1) { @@ -176,13 +186,10 @@ export class CircomPluginClient extends PluginClient { if (compilationConfig) { const { prime, version } = compilationConfig - if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta")) throw new Error('Invalid prime value') - if (!compiler_list.versions.includes(version)) throw new Error("Unsupported compiler version") - this._compilationConfig.prime = prime - this._compilationConfig.version = version + this.compilerVersion = version + this.compilerPrime = prime } - const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216 - const r1csApi = compiler.generate_r1cs(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) + const r1csApi = this.compiler.generate_r1cs(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) const r1csProgram = r1csApi.program() if (r1csProgram.length < 1) { @@ -207,8 +214,7 @@ export class CircomPluginClient extends PluginClient { // @ts-ignore const buffer: any = await this.call('fileManager', 'readFile', wasmPath, { encoding: null }) const dataRead = new Uint8Array(buffer) - const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216 - const witness = await compiler.generate_witness(dataRead, input) + const witness = await this.compiler.generate_witness(dataRead, input) // @ts-ignore await this.call('fileManager', 'writeFile', wasmPath.replace('.wasm', '.wtn'), witness, true) this.internalEvents.emit('circuit_computing_witness_done') From cfd0c411bce9bcf3e3c21e06d7cb4393c1c80b5f Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 7 Dec 2023 13:37:58 +0100 Subject: [PATCH 4/7] Update prime values in UI on compiler change --- .../src/app/components/configurations.tsx | 27 +++++++++++++------ .../src/app/components/container.tsx | 6 +++-- apps/circuit-compiler/src/app/types/index.ts | 3 ++- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/apps/circuit-compiler/src/app/components/configurations.tsx b/apps/circuit-compiler/src/app/components/configurations.tsx index c42a86cc35..a9583c093a 100644 --- a/apps/circuit-compiler/src/app/components/configurations.tsx +++ b/apps/circuit-compiler/src/app/components/configurations.tsx @@ -1,8 +1,8 @@ -import { CustomTooltip } from "@remix-ui/helper" +import { CustomTooltip, RenderIf } from "@remix-ui/helper" import { FormattedMessage } from "react-intl" import { ConfigurationsProps, PrimeValue } from "../types" -export function Configurations ({primeValue, setPrimeValue}: ConfigurationsProps) { +export function Configurations ({primeValue, setPrimeValue, versionValue}: ConfigurationsProps) { return (
@@ -25,12 +25,23 @@ export function Configurations ({primeValue, setPrimeValue}: ConfigurationsProps pointerEvents: 'auto' }} > - - - - - - + + <> + + + + + + + <> + + + + + + + +
diff --git a/apps/circuit-compiler/src/app/components/container.tsx b/apps/circuit-compiler/src/app/components/container.tsx index d56036e44d..fa7467f69c 100644 --- a/apps/circuit-compiler/src/app/components/container.tsx +++ b/apps/circuit-compiler/src/app/components/container.tsx @@ -29,6 +29,7 @@ export function Container () { } const handleVersionSelect = (version: string) => { + circuitApp.plugin.compilerVersion = version circuitApp.dispatch({ type: 'SET_COMPILER_VERSION', payload: version }) } @@ -44,7 +45,8 @@ export function Container () { } } - const handlePrimeChange = (value: string) => { + const handlePrimeChange = (value: PrimeValue) => { + circuitApp.plugin.compilerPrime = value circuitApp.dispatch({ type: 'SET_PRIME_VALUE', payload: value as PrimeValue }) } @@ -75,7 +77,7 @@ export function Container () { - + 0}> diff --git a/apps/circuit-compiler/src/app/types/index.ts b/apps/circuit-compiler/src/app/types/index.ts index 41ca140ae0..3b6f7a57b4 100644 --- a/apps/circuit-compiler/src/app/types/index.ts +++ b/apps/circuit-compiler/src/app/types/index.ts @@ -76,7 +76,8 @@ export type FeedbackAlertProps = { export type ConfigurationsProps = { setPrimeValue: (prime: PrimeValue) => void, - primeValue: PrimeValue + primeValue: PrimeValue, + versionValue: string } export type CompileOptionsProps = { From 173c234f3541c1dec7a32f9a4a29ce4c2625f8ab Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 7 Dec 2023 13:45:21 +0100 Subject: [PATCH 5/7] Update circom_wasm version --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e1b2053021..060938addd 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,7 @@ "brace": "^0.8.0", "change-case": "^4.1.1", "chokidar": "^2.1.8", - "circom_wasm": "0.2.2-alpha", + "circom_wasm": "^0.2.0", "color-support": "^1.1.3", "commander": "^9.4.1", "core-js": "^3.6.5", diff --git a/yarn.lock b/yarn.lock index 0f008633f9..9272764444 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10062,10 +10062,10 @@ circom_runtime@0.1.22: dependencies: ffjavascript "0.2.57" -circom_wasm@0.2.2-alpha: - version "0.2.2-alpha" - resolved "https://registry.yarnpkg.com/circom_wasm/-/circom_wasm-0.2.2-alpha.tgz#ab21d63105e46ed9d6a91173208c4b0d06da5124" - integrity sha512-TMmypDJUEZ+VX3TS6CpooK6uVdA/scgv1yQ6UlDr9Asmbhd/If3OUcQbE3bAU0Ao4mKFL9AhExJIyZAEeF+kTQ== +circom_wasm@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/circom_wasm/-/circom_wasm-0.2.0.tgz#c35537f0b1f5bfd3d88898306f46c3a3457e5589" + integrity sha512-eqDCbAXJQkKnrAg0Ow3bdaGciGTooRKL20941JGzX8IcqgHoGiZxaSLATkYy97dbmJFrxe8Wr+mOGnvdbqN9bw== circular-json@^0.3.0: version "0.3.3" From 75d388ab67e1df622c35bee5b940047c34e42945 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 7 Dec 2023 13:49:38 +0100 Subject: [PATCH 6/7] Fix e2e --- apps/remix-ide-e2e/src/tests/circom.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/circom.test.ts b/apps/remix-ide-e2e/src/tests/circom.test.ts index 0cad3052f3..6f57533b3e 100644 --- a/apps/remix-ide-e2e/src/tests/circom.test.ts +++ b/apps/remix-ide-e2e/src/tests/circom.test.ts @@ -107,7 +107,7 @@ module.exports = { .waitForElementPresent('[data-id="circuit_feedback"]') .waitForElementVisible('[data-id="circuit_feedback"]') .assert.hasClass('[data-id="circuit_feedback"]', 'alert-warning') - .waitForElementContainsText('[data-id="circuit_feedback"]', 'File circuits/simple.circom does not include pragma version. Assuming pragma version (2, 1, 5)') + .waitForElementContainsText('[data-id="circuit_feedback"]', 'File circuits/simple.circom does not include pragma version. Assuming pragma version (2, 1, 6)') }, 'Should hide/show warnings for compiled circuit #group4': function (browser: NightwatchBrowser) { browser @@ -115,7 +115,7 @@ module.exports = { .waitForElementNotPresent('[data-id="circuit_feedback"]') .click('[data-id="hide_circuit_warnings_checkbox_input"]') .waitForElementVisible('[data-id="circuit_feedback"]') - .waitForElementContainsText('[data-id="circuit_feedback"]', 'File circuits/simple.circom does not include pragma version. Assuming pragma version (2, 1, 5)') + .waitForElementContainsText('[data-id="circuit_feedback"]', 'File circuits/simple.circom does not include pragma version. Assuming pragma version (2, 1, 6)') }, 'Should display error for invalid circuit #group4': function (browser: NightwatchBrowser) { browser From 69fe2e08c5869aa1f3f6c77354610c3356a43ea9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 8 Dec 2023 13:32:23 +0100 Subject: [PATCH 7/7] add custom endpoint --- .../suggestion-service/copilot-suggestion.ts | 21 +++++++++++++++++-- .../lib/providers/inlineCompletionProvider.ts | 6 +++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts b/apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts index f58b76888d..2edcd81cee 100644 --- a/apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts +++ b/apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts @@ -1,18 +1,20 @@ import {Plugin} from '@remixproject/engine' import {SuggestionService, SuggestOptions} from './suggestion-service' +import axios, {AxiosResponse} from 'axios' const _paq = (window._paq = window._paq || []) //eslint-disable-line const profile = { name: 'copilot-suggestion', displayName: 'copilot-suggestion', description: 'Get Solidity suggestions in editor', - methods: ['suggest', 'init', 'uninstall', 'status', 'isActivate'], + methods: ['suggest', 'init', 'uninstall', 'status', 'isActivate', 'useRemoteService', 'discardRemoteService'], version: '0.1.0-alpha', maintainedBy: "Remix" } export class CopilotSuggestion extends Plugin { service: SuggestionService + remoteService: string context: string ready: boolean constructor() { @@ -29,6 +31,14 @@ export class CopilotSuggestion extends Plugin { }) } + useRemoteService(service: string) { + this.remoteService = service + } + + discardRemoteService() { + this.remoteService = null + } + status () { return this.ready } @@ -53,7 +63,14 @@ export class CopilotSuggestion extends Plugin { temperature: temperature || 0, max_new_tokens: max_new_tokens || 0 } - return this.service.suggest(this.context ? this.context + '\n\n' + content : content, options) + + if (this.remoteService) { + const {data} = await axios.post(this.remoteService, {context: content, max_new_words: options.max_new_tokens, temperature: options.temperature}) + const parsedData = JSON.parse(data).trimStart() + return {output: [{generated_text: parsedData}]} + } else { + return this.service.suggest(this.context ? this.context + '\n\n' + content : content, options) + } } async loadModeContent() { diff --git a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts index 56a3c9c61a..7f047833e1 100644 --- a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts @@ -70,7 +70,11 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli const generatedText = (result as any).output[0].generated_text as string // the generated text remove a space from the context... - const clean = generatedText.replace('@custom:dev-run-script', '@custom:dev-run-script ').replace(word, '') + let clean = generatedText + if (generatedText.indexOf('@custom:dev-run-script./') !== -1) { + clean = generatedText.replace('@custom:dev-run-script', '@custom:dev-run-script ') + } + clean = clean.replace(word, '') const item: monacoTypes.languages.InlineCompletion = { insertText: clean };