|
|
@ -1,13 +1,10 @@ |
|
|
|
import { CopyToClipboard } from '@remix-ui/clipboard' |
|
|
|
import { CopyToClipboard } from '@remix-ui/clipboard' |
|
|
|
import { CustomTooltip } from '@remix-ui/helper' |
|
|
|
import JSONTree, { ThemeKeys, ThemeObject } from '@microlink/react-json-view' |
|
|
|
import JSONTree, { ThemeKeys } from 'react-json-view' |
|
|
|
|
|
|
|
import React, { useState } from 'react' |
|
|
|
import React, { useState } from 'react' |
|
|
|
// import { Tabs, Tab, Button } from 'react-bootstrap'
|
|
|
|
|
|
|
|
import { useIntl } from 'react-intl' |
|
|
|
import { useIntl } from 'react-intl' |
|
|
|
import Tabs from 'react-bootstrap/Tabs' |
|
|
|
import Tabs from 'react-bootstrap/Tabs' |
|
|
|
import Tab from 'react-bootstrap/Tab' |
|
|
|
import Tab from 'react-bootstrap/Tab' |
|
|
|
import Button from 'react-bootstrap/Button' |
|
|
|
import Button from 'react-bootstrap/Button' |
|
|
|
import { TreeView, TreeViewItem } from '@remix-ui/tree-view' |
|
|
|
|
|
|
|
import { ABIDescription } from '@remixproject/plugin-api' |
|
|
|
import { ABIDescription } from '@remixproject/plugin-api' |
|
|
|
const _paq = (window._paq = window._paq || []) |
|
|
|
const _paq = (window._paq = window._paq || []) |
|
|
|
|
|
|
|
|
|
|
@ -22,70 +19,69 @@ export interface VyperCompilationResult { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface VyperCompileProps { |
|
|
|
|
|
|
|
result: VyperCompilationResult |
|
|
|
|
|
|
|
theme?: ThemeKeys | ThemeObject |
|
|
|
|
|
|
|
themeStyle?: any |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function VyperCompile(props: VyperCompilationResult) { |
|
|
|
export default function VyperCompile({result, theme, themeStyle}: VyperCompileProps) { |
|
|
|
const intl = useIntl() |
|
|
|
const intl = useIntl() |
|
|
|
// const downloadFn = () => {
|
|
|
|
|
|
|
|
// _paq.push(['trackEvent', 'compiler', 'compilerDetails', 'download'])
|
|
|
|
|
|
|
|
// saveAs(new Blob([JSON.stringify(contractProperties, null, '\t')]), `${selectedContract}_compData.json`)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
const [active, setActive] = useState<keyof VyperCompilationResult>('abi') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [active, setActive] = useState<keyof VyperCompilationResult>('abi') |
|
|
|
|
|
|
|
console.log(theme, themeStyle) |
|
|
|
const tabContent = [ |
|
|
|
const tabContent = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
tabHeadingText: 'ABI', |
|
|
|
tabHeadingText: 'ABI', |
|
|
|
tabPayload: props.abi, //Object.values(props)[0]['abi'],
|
|
|
|
tabPayload: result.abi, |
|
|
|
tabMemberType: 'abi', |
|
|
|
tabMemberType: 'abi', |
|
|
|
tabButtonText: () => 'Copy ABI', |
|
|
|
tabButtonText: () => 'Copy ABI', |
|
|
|
eventKey: 'abi' |
|
|
|
eventKey: 'abi' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
tabHeadingText: 'Bytecode', |
|
|
|
tabHeadingText: 'Bytecode', |
|
|
|
tabPayload: props.bytecode, //Object.values(props)[0]['bytecode'].object.toString(),
|
|
|
|
tabPayload: result.bytecode, |
|
|
|
tabMemberType: 'bytecode', |
|
|
|
tabMemberType: 'bytecode', |
|
|
|
tabButtonText: () => 'Copy Bytecode', |
|
|
|
tabButtonText: () => 'Copy Bytecode', |
|
|
|
eventKey: 'bytecode' |
|
|
|
eventKey: 'bytecode' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
tabHeadingText: 'Runtime Bytecode', |
|
|
|
tabHeadingText: 'Runtime Bytecode', |
|
|
|
tabPayload: props.bytecodeRuntime,// Object.values(props)[0]['runtimeBytecode'].object.toString(),
|
|
|
|
tabPayload: result.bytecodeRuntime, |
|
|
|
tabMemberType: 'bytecode_runtime', |
|
|
|
tabMemberType: 'bytecode_runtime', |
|
|
|
tabButtonText: () => 'Copy Runtime Bytecode', |
|
|
|
tabButtonText: () => 'Copy Runtime Bytecode', |
|
|
|
eventKey: 'bytecode_runtime' |
|
|
|
eventKey: 'bytecode_runtime' |
|
|
|
} |
|
|
|
} |
|
|
|
// {
|
|
|
|
|
|
|
|
// tabHeadingText: 'LLL',
|
|
|
|
|
|
|
|
// tabPayload: Object.values(contractProperties)[0]['ir'] ? '' : '',
|
|
|
|
|
|
|
|
// tabMemberType: 'ir',
|
|
|
|
|
|
|
|
// tabButtonText: () => Object.values(contractProperties)[0]['ir'] ? 'Copy LLL Code' : 'Nothing to copy yet',
|
|
|
|
|
|
|
|
// eventKey: 'ir'
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
] |
|
|
|
] |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
{/* <div className="d-flex justify-content-between align-items-center mr-1"> |
|
|
|
|
|
|
|
<span className="lead">{selectedContract}</span> |
|
|
|
|
|
|
|
<CustomTooltip tooltipText={intl.formatMessage({id: 'solidity.compileDetails'})}> |
|
|
|
|
|
|
|
<span className="btn btn-outline-success border-success mr-1" onClick={downloadFn}>Download</span> |
|
|
|
|
|
|
|
</CustomTooltip> |
|
|
|
|
|
|
|
</div> */} |
|
|
|
|
|
|
|
<Tabs id="result" activeKey={active} onSelect={(key: any) => setActive(key)} justify> |
|
|
|
<Tabs id="result" activeKey={active} onSelect={(key: any) => setActive(key)} justify> |
|
|
|
{tabContent.map((content, index) => ( |
|
|
|
{tabContent.map((content, index) => ( |
|
|
|
<Tab eventKey={content.eventKey} title={content.tabHeadingText} as={'span'} key={`${index}-${content.eventKey}`}> |
|
|
|
<Tab eventKey={content.eventKey} title={content.tabHeadingText} as={'span'} key={`${index}-${content.eventKey}`}> |
|
|
|
<CopyToClipboard getContent={() => content.eventKey !== 'abi' ? content.tabPayload : JSON.stringify(Object.values(props)[0]['abi'])}> |
|
|
|
<div className="d-flex flex-column w-75 justify-content-center mx-auto rounded-2"> |
|
|
|
<Button variant="info" className="copy" data-id={content.eventKey === 'abi' ? "copy-abi" : ''}> |
|
|
|
<CopyToClipboard getContent={() => (content.eventKey !== 'abi' ? content.tabPayload : JSON.stringify(Object.values(result)[0]['abi']))}> |
|
|
|
|
|
|
|
<Button variant="info" className="copy mt-3 ml-2" data-id={content.eventKey === 'abi' ? 'copy-abi' : ''}> |
|
|
|
|
|
|
|
<span className="far fa-copy mr-2"></span> |
|
|
|
{content.tabButtonText()} |
|
|
|
{content.tabButtonText()} |
|
|
|
</Button> |
|
|
|
</Button> |
|
|
|
</CopyToClipboard> |
|
|
|
</CopyToClipboard> |
|
|
|
{ |
|
|
|
{content.eventKey === 'abi' ? ( |
|
|
|
content.eventKey === 'abi' ? <JSONTree src={content.tabPayload as ABIDescription[]} theme={{} as any}/> : ( |
|
|
|
<div className="my-3"> |
|
|
|
<textarea defaultValue={content.tabPayload as string}></textarea> |
|
|
|
<JSONTree |
|
|
|
) |
|
|
|
src={content.tabPayload as ABIDescription[]} |
|
|
|
} |
|
|
|
theme={theme} |
|
|
|
{/* <Button> |
|
|
|
style={themeStyle} |
|
|
|
{content.tabButtonText()} |
|
|
|
/> |
|
|
|
</Button> */} |
|
|
|
</div> |
|
|
|
</Tab>))} |
|
|
|
) : ( |
|
|
|
|
|
|
|
<div className="w-100 mt-2 p-2 mx-auto"> |
|
|
|
|
|
|
|
<textarea className="form-control rounded-2" defaultValue={content.tabPayload as string} rows={15}></textarea> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</Tab> |
|
|
|
|
|
|
|
))} |
|
|
|
</Tabs> |
|
|
|
</Tabs> |
|
|
|
</> |
|
|
|
</> |
|
|
|
) |
|
|
|
) |
|
|
|