Skip to content

Commit bb572ac

Browse files
ioedeveloperyann300
authored andcommitted
Load compiler license for circom
1 parent 7962143 commit bb572ac

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

apps/circuit-compiler/src/app/components/container.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,25 @@ import { WitnessToggler } from './witnessToggler'
1111
import { WitnessSection } from './witness'
1212
import { CompilerFeedback } from './feedback'
1313
import { PrimeValue } from '../types'
14+
import { CompilerLicense } from '../constants/license'
1415

1516
export function Container () {
1617
const circuitApp = useContext(CircuitAppContext)
1718

18-
const showCompilerLicense = (message = 'License not available') => {
19-
// @ts-ignore
20-
circuitApp.plugin.call('notification', 'modal', { id: 'modal_circuit_compiler_license', title: 'Compiler License', message })
19+
const showCompilerLicense = async (message = 'License not available') => {
20+
try {
21+
const response = await fetch('https://raw.githubusercontent.com/iden3/circom/master/COPYING')
22+
if (!response.ok) {
23+
throw new Error(`HTTP error! status: ${response.status}`)
24+
}
25+
const content = await response.text()
26+
// @ts-ignore
27+
circuitApp.plugin.call('notification', 'modal', { id: 'modal_circuit_compiler_license', title: 'Compiler License', message: content })
28+
} catch (e) {
29+
console.log('error: ', e)
30+
// @ts-ignore
31+
circuitApp.plugin.call('notification', 'modal', { id: 'modal_circuit_compiler_license', title: 'Compiler License', message })
32+
}
2133
}
2234

2335
const handleVersionSelect = (version: string) => {
@@ -62,7 +74,7 @@ export function Container () {
6274
tooltipClasses="text-nowrap"
6375
tooltipText='See compiler license'
6476
>
65-
<span className="far fa-file-certificate border-0 p-0 ml-2" onClick={() => showCompilerLicense()}></span>
77+
<span className="far fa-file-certificate border-0 p-0 ml-2" onClick={() => showCompilerLicense(CompilerLicense)}></span>
6678
</CustomTooltip>
6779
<VersionList setVersion={handleVersionSelect} versionList={circuitApp.appState.versionList} currentVersion={circuitApp.appState.version} />
6880
<CompileOptions setCircuitAutoCompile={handleCircuitAutoCompile} setCircuitHideWarnings={handleCircuitHideWarnings} autoCompile={circuitApp.appState.autoCompile} hideWarnings={circuitApp.appState.hideWarnings} />

0 commit comments

Comments
 (0)