Merge branch 'master' of https://github.com/ethereum/remix-project into terminalwrapper
commit
7491afa8d4
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@ |
|||||||
{ |
{ |
||||||
"remixUiTabs.tooltipText1": "Run script (CTRL + SHIFT + S)", |
"remixUiTabs.tooltipText1": "Run script (CTRL + SHIFT + S)", |
||||||
"remixUiTabs.tooltipText2": "Compile CTRL + S", |
"remixUiTabs.tooltipText2": "Compile CTRL + S", |
||||||
"remixUiTabs.tooltipText3": "Select .sol or .yul file to compile or a .ts or .js file and run it", |
"remixUiTabs.tooltipText3": "Select .sol, .vy or .yul file to compile or a .ts or .js file and run it", |
||||||
"remixUiTabs.zoomOut": "Zoom out", |
"remixUiTabs.zoomOut": "Zoom out", |
||||||
"remixUiTabs.zoomIn": "Zoom in" |
"remixUiTabs.zoomIn": "Zoom in" |
||||||
} |
} |
||||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,26 @@ |
|||||||
|
import React, { useState } from 'react' |
||||||
|
import { useAccordionToggle } from 'react-bootstrap/AccordionToggle' |
||||||
|
|
||||||
|
export type CustomAccordionToggleProps = { |
||||||
|
children: React.ReactNode |
||||||
|
eventKey: string |
||||||
|
callback?: any |
||||||
|
} |
||||||
|
|
||||||
|
export default function CustomAccordionToggle({ children, eventKey }: CustomAccordionToggleProps) { |
||||||
|
const [toggleAccordion, setToggleAccordion] = useState(false) |
||||||
|
|
||||||
|
const decoratedOnClick = useAccordionToggle(eventKey, () => |
||||||
|
setToggleAccordion(!toggleAccordion) |
||||||
|
) |
||||||
|
|
||||||
|
return ( |
||||||
|
<div |
||||||
|
onClick={decoratedOnClick} |
||||||
|
className="d-flex flex-row justify-content-between align-items-center mx-3" |
||||||
|
> |
||||||
|
{children} |
||||||
|
<i className={toggleAccordion ? 'far fa-angle-down' : 'far fa-angle-right'}></i> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
@ -0,0 +1,67 @@ |
|||||||
|
export const fetchContractFromBlockscout = async (plugin, endpoint, contractAddress, targetPath, shouldSetFile = true) => { |
||||||
|
let data |
||||||
|
const compilationTargets = {} |
||||||
|
|
||||||
|
try { |
||||||
|
data = await fetch('https://' + endpoint + '/api?module=contract&action=getsourcecode&address=' + contractAddress) |
||||||
|
data = await data.json() |
||||||
|
console.log(data) |
||||||
|
// blockscout api doc https://blockscout.com/poa/core/api-docs
|
||||||
|
if (data.message === 'OK' && data.status === "1") { |
||||||
|
if (data.result.length) { |
||||||
|
if (!data.result[0].SourceCode || data.result[0].SourceCode === '') { |
||||||
|
throw new Error(`contract not verified on Blockscout ${endpoint} network`) |
||||||
|
} |
||||||
|
} |
||||||
|
} else throw new Error('unable to retrieve contract data ' + data.message) |
||||||
|
} catch (e) { |
||||||
|
throw new Error('unable to retrieve contract data: ' + e.message) |
||||||
|
} |
||||||
|
|
||||||
|
if (!data || !data.result) { |
||||||
|
return null |
||||||
|
} |
||||||
|
|
||||||
|
if (data.result[0].FileName === '') { |
||||||
|
const fileName = `${targetPath}/${data.result[0].ContractName}.sol` |
||||||
|
if (shouldSetFile) await plugin.call('fileManager', 'setFile', fileName, data.result[0].SourceCode) |
||||||
|
compilationTargets[fileName] = { content: data.result[0].SourceCode } |
||||||
|
} else { |
||||||
|
const sources = {} |
||||||
|
sources[data.result[0].FileName] = data.result[0].SourceCode |
||||||
|
if (data.result[0].AdditionalSources && Array.isArray(data.result[0].AdditionalSources)) { |
||||||
|
for (const object of data.result[0].AdditionalSources) { |
||||||
|
sources[object.Filename] = object.SourceCode |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
for (let [file, source] of Object.entries(sources)) { // eslint-disable-line
|
||||||
|
file = file.replace('browser/', '') // should be fixed in the remix IDE end.
|
||||||
|
file = file.replace(/^\//g, '') // remove first slash.
|
||||||
|
if (await plugin.call('contentImport', 'isExternalUrl', file)) { |
||||||
|
// nothing to do, the compiler callback will handle those
|
||||||
|
} else { |
||||||
|
const path = `${targetPath}/${file}` |
||||||
|
const content = source |
||||||
|
if (shouldSetFile) await plugin.call('fileManager', 'setFile', path, content) |
||||||
|
compilationTargets[path] = { content } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
let runs = 0 |
||||||
|
try { |
||||||
|
runs = parseInt(data.result[0].OptimizationRuns) |
||||||
|
} catch (e) { } |
||||||
|
const settings = { |
||||||
|
version: data.result[0].CompilerVersion.replace(/^v/, ''), |
||||||
|
language: 'Solidity', |
||||||
|
evmVersion: data.result[0].EVMVersion.toLowerCase(), |
||||||
|
optimize: data.result[0].OptimizationUsed === 'true', |
||||||
|
runs |
||||||
|
} |
||||||
|
return { |
||||||
|
settings, |
||||||
|
compilationTargets |
||||||
|
} |
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue