pull/3321/head^2
Joseph Izang 2 years ago committed by Aniket
parent 6021284454
commit 157b680ddd
  1. 17
      libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx

@ -4,6 +4,10 @@ import { ContractSelectionProps } from './types'
import { PublishToStorage } from '@remix-ui/publish-to-storage' // eslint-disable-line import { PublishToStorage } from '@remix-ui/publish-to-storage' // eslint-disable-line
import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line
import { CopyToClipboard } from '@remix-ui/clipboard' // eslint-disable-line import { CopyToClipboard } from '@remix-ui/clipboard' // eslint-disable-line
import { convertAST2UmlClasses } from 'sol2uml/lib/converterAST2Classes'
const parser = (window as any).SolidityParser
import { convertUmlClasses2Dot } from 'sol2uml/lib/converterClasses2Dot'
import vizRenderStringSync from '@aduh95/viz.js/sync'
import './css/style.css' import './css/style.css'
import { CustomTooltip } from '@remix-ui/helper' import { CustomTooltip } from '@remix-ui/helper'
@ -194,6 +198,17 @@ export const ContractSelection = (props: ContractSelectionProps) => {
return copyContractProperty('bytecode') return copyContractProperty('bytecode')
} }
const generateUML = async () => {
try {
const currentFile = api.currentFile
const ast = parser.parse(api.getCompilationResult().source.sources[currentFile].content)
const svgResult = vizRenderStringSync(convertUmlClasses2Dot(convertAST2UmlClasses(ast, currentFile)))
console.log({ svgResult })
} catch (error) {
console.log({ error })
}
}
return ( return (
// define swarm logo // define swarm logo
<> <>
@ -207,6 +222,8 @@ export const ContractSelection = (props: ContractSelectionProps) => {
</select> </select>
</div> </div>
<article className="mt-2 pb-0"> <article className="mt-2 pb-0">
<button onClick={generateUML} className="btn btn-primary btn-block mt-2"> Flatten {api.currentFile}</button>
<button onClick={generateUML} className="btn btn-primary btn-block mt-2"> Generate UML Diagram</button>
<button id="publishOnIpfs" className="btn btn-secondary btn-block" onClick={() => { handlePublishToStorage('ipfs') }}> <button id="publishOnIpfs" className="btn btn-secondary btn-block" onClick={() => { handlePublishToStorage('ipfs') }}>
<CustomTooltip <CustomTooltip
placement="right-start" placement="right-start"

Loading…
Cancel
Save