Show icons for setup export

pull/5370/head
ioedeveloper 4 months ago
parent d1abc1e999
commit fe0be68463
  1. 1
      apps/circuit-compiler/src/app/app.tsx
  2. 4
      apps/circuit-compiler/src/app/components/container.tsx
  3. 3
      apps/circuit-compiler/src/app/components/setupExports.tsx
  4. 9
      apps/circuit-compiler/src/app/components/toggler.tsx
  5. 2
      apps/circuit-compiler/src/app/components/witness.tsx
  6. 7
      apps/circuit-compiler/src/app/reducers/state.ts
  7. 6
      apps/circuit-compiler/src/app/types/index.ts

@ -81,6 +81,7 @@ function App() {
if (appState.autoCompile) await compileCircuit(plugin, appState) if (appState.autoCompile) await compileCircuit(plugin, appState)
})() })()
setIsContentChanged(false) setIsContentChanged(false)
if (appState.setupExportStatus === 'done') dispatch({ type: 'SET_SETUP_EXPORT_STATUS', payload: 'update' })
} }
}, [appState.autoCompile, isContentChanged]) }, [appState.autoCompile, isContentChanged])

@ -121,7 +121,7 @@ export function Container () {
<CompilerFeedback feedback={circuitApp.appState.compilerFeedback} filePathToId={circuitApp.appState.filePathToId} openErrorLocation={handleOpenErrorLocation} hideWarnings={circuitApp.appState.hideWarnings} askGPT={askGPT} /> <CompilerFeedback feedback={circuitApp.appState.compilerFeedback} filePathToId={circuitApp.appState.filePathToId} openErrorLocation={handleOpenErrorLocation} hideWarnings={circuitApp.appState.hideWarnings} askGPT={askGPT} />
</RenderIf> </RenderIf>
<RenderIf condition={circuitApp.appState.signalInputs.length > 0}> <RenderIf condition={circuitApp.appState.signalInputs.length > 0}>
<Toggler title='circuit.setupExports' dataId='setup_exports_toggler' show={true}> <Toggler title='circuit.setupExports' dataId='setup_exports_toggler' show={!circuitApp.appState.setupExportStatus} icon={ circuitApp.appState.setupExportStatus === 'done' ? 'fas fa-check-circle text-success' : circuitApp.appState.setupExportStatus === 'update' ? 'fas fa-exclamation-triangle text-warning' : null }>
<> <>
<SetupExports /> <SetupExports />
<RenderIf condition={circuitApp.appState.status !== 'exporting'}> <RenderIf condition={circuitApp.appState.status !== 'exporting'}>
@ -131,7 +131,7 @@ export function Container () {
</Toggler> </Toggler>
</RenderIf> </RenderIf>
<RenderIf condition={circuitApp.appState.signalInputs.length > 0}> <RenderIf condition={circuitApp.appState.signalInputs.length > 0}>
<Toggler title='circuit.computeWitness' dataId='witness_toggler'> <Toggler title='circuit.computeWitness' dataId='witness_toggler' show={!!circuitApp.appState.setupExportStatus}>
<> <>
<WitnessSection plugin={circuitApp.plugin} signalInputs={circuitApp.appState.signalInputs} status={circuitApp.appState.status} /> <WitnessSection plugin={circuitApp.plugin} signalInputs={circuitApp.appState.signalInputs} status={circuitApp.appState.status} />
<RenderIf condition={circuitApp.appState.status !== 'computing'}> <RenderIf condition={circuitApp.appState.status !== 'computing'}>

@ -21,6 +21,7 @@ export function SetupExports () {
circuitApp.dispatch({ type: 'SET_COMPILER_STATUS', payload: 'exporting' }) circuitApp.dispatch({ type: 'SET_COMPILER_STATUS', payload: 'exporting' })
await runSetupAndExport(circuitApp.plugin, circuitApp.appState) await runSetupAndExport(circuitApp.plugin, circuitApp.appState)
circuitApp.dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' }) circuitApp.dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' })
circuitApp.dispatch({ type: 'SET_SETUP_EXPORT_STATUS', payload: 'done' })
} catch (e) { } catch (e) {
circuitApp.dispatch({ type: 'SET_COMPILER_STATUS', payload: 'errored' }) circuitApp.dispatch({ type: 'SET_COMPILER_STATUS', payload: 'errored' })
circuitApp.dispatch({ type: 'SET_SETUP_EXPORT_FEEDBACK', payload: e.message }) circuitApp.dispatch({ type: 'SET_SETUP_EXPORT_FEEDBACK', payload: e.message })
@ -44,6 +45,7 @@ export function SetupExports () {
onClick={() => circuitApp.dispatch({ type: 'SET_PROVING_SCHEME', payload: 'groth16' })} onClick={() => circuitApp.dispatch({ type: 'SET_PROVING_SCHEME', payload: 'groth16' })}
value='groth16' value='groth16'
checked={circuitApp.appState.provingScheme === 'groth16'} checked={circuitApp.appState.provingScheme === 'groth16'}
readOnly
/> />
<label className="form-check-label custom-control-label" htmlFor="groth16ProvingScheme" style={{ paddingTop: '0.125rem' }}> <label className="form-check-label custom-control-label" htmlFor="groth16ProvingScheme" style={{ paddingTop: '0.125rem' }}>
Groth16 Groth16
@ -58,6 +60,7 @@ export function SetupExports () {
onClick={() => circuitApp.dispatch({ type: 'SET_PROVING_SCHEME', payload: 'plonk' })} onClick={() => circuitApp.dispatch({ type: 'SET_PROVING_SCHEME', payload: 'plonk' })}
value='plonk' value='plonk'
checked={circuitApp.appState.provingScheme === 'plonk'} checked={circuitApp.appState.provingScheme === 'plonk'}
readOnly
/> />
<label className="form-check-label custom-control-label" htmlFor="plonkProvingScheme" style={{ paddingTop: '0.125rem' }}> <label className="form-check-label custom-control-label" htmlFor="plonkProvingScheme" style={{ paddingTop: '0.125rem' }}>
Plonk Plonk

@ -1,10 +1,14 @@
import { useState } from "react" import { useEffect, useState } from "react"
import { FormattedMessage } from "react-intl" import { FormattedMessage } from "react-intl"
import { RenderIf, RenderIfNot } from "@remix-ui/helper" import { RenderIf, RenderIfNot } from "@remix-ui/helper"
export function Toggler ({ children, title, dataId, show = false }: { children: JSX.Element, title: string, dataId: string, show?: boolean }) { export function Toggler ({ children, title, dataId, show = false, icon }: { children: JSX.Element, title: string, dataId: string, show?: boolean, icon?: string }) {
const [toggleExpander, setToggleExpander] = useState<boolean>(show) const [toggleExpander, setToggleExpander] = useState<boolean>(show)
useEffect(() => {
setToggleExpander(show)
}, [show])
const toggleConfigurations = () => { const toggleConfigurations = () => {
setToggleExpander(!toggleExpander) setToggleExpander(!toggleExpander)
} }
@ -15,6 +19,7 @@ export function Toggler ({ children, title, dataId, show = false }: { children:
<div className="d-flex"> <div className="d-flex">
<label className="mt-1 circuit_config_section"> <label className="mt-1 circuit_config_section">
<FormattedMessage id={title} /> <FormattedMessage id={title} />
{ icon && <span className={`${icon} border-0 p-0 ml-2`} aria-hidden="true"></span> }
</label> </label>
</div> </div>
<div> <div>

@ -34,7 +34,6 @@ export function WitnessSection ({ plugin, signalInputs, status }: {plugin: Circo
} }
return ( return (
<div className="border-bottom flex-column">
<div className="flex-column d-flex"> <div className="flex-column d-flex">
<RenderIf condition={signalInputs.length > 0}> <RenderIf condition={signalInputs.length > 0}>
<> <>
@ -62,6 +61,5 @@ export function WitnessSection ({ plugin, signalInputs, status }: {plugin: Circo
</> </>
</RenderIf> </RenderIf>
</div> </div>
</div>
) )
} }

@ -14,6 +14,7 @@ export const appInitialState: AppState = {
compilerFeedback: null, compilerFeedback: null,
computeFeedback: null, computeFeedback: null,
setupExportFeedback: null, setupExportFeedback: null,
setupExportStatus: null,
provingScheme: 'groth16', provingScheme: 'groth16',
ptauList: [ ptauList: [
{ {
@ -142,6 +143,12 @@ export const appReducer = (state = appInitialState, action: Actions): AppState =
exportVerificationKey: action.payload exportVerificationKey: action.payload
} }
case 'SET_SETUP_EXPORT_STATUS':
return {
...state,
setupExportStatus: action.payload
}
default: default:
throw new Error() throw new Error()
} }

@ -6,6 +6,8 @@ export type CompilerStatus = "compiling" | "computing" | "idle" | "errored" | "w
export type ProvingScheme = 'groth16' | 'plonk' export type ProvingScheme = 'groth16' | 'plonk'
export type SetupExportStatus = 'done' | 'update'
export type PtauFile = { export type PtauFile = {
name: string, name: string,
power: number, power: number,
@ -36,7 +38,8 @@ export interface ActionPayloadTypes {
// SET_RANDOM_TEXT: string, // SET_RANDOM_TEXT: string,
// SET_RANDOM_BEACON: string // SET_RANDOM_BEACON: string
SET_EXPORT_VERIFICATION_CONTRACT: boolean, SET_EXPORT_VERIFICATION_CONTRACT: boolean,
SET_EXPORT_VERIFICATION_KEY: boolean SET_EXPORT_VERIFICATION_KEY: boolean,
SET_SETUP_EXPORT_STATUS: SetupExportStatus
} }
export interface Action<T extends keyof ActionPayloadTypes> { export interface Action<T extends keyof ActionPayloadTypes> {
type: T type: T
@ -58,6 +61,7 @@ export interface AppState {
compilerFeedback: string | CompilerReport[], compilerFeedback: string | CompilerReport[],
computeFeedback: string | CompilerReport[], computeFeedback: string | CompilerReport[],
setupExportFeedback: string | CompilerReport[], setupExportFeedback: string | CompilerReport[],
setupExportStatus: SetupExportStatus,
provingScheme: ProvingScheme, provingScheme: ProvingScheme,
ptauList: Array<PtauFile>, ptauList: Array<PtauFile>,
ptauValue: string, ptauValue: string,

Loading…
Cancel
Save