|
|
@ -29,6 +29,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
const [loadedContractData, setLoadedContractData] = useState<ContractData>(null) |
|
|
|
const [loadedContractData, setLoadedContractData] = useState<ContractData>(null) |
|
|
|
const [constructorInterface, setConstructorInterface] = useState<FuncABI>(null) |
|
|
|
const [constructorInterface, setConstructorInterface] = useState<FuncABI>(null) |
|
|
|
const [constructorInputs, setConstructorInputs] = useState(null) |
|
|
|
const [constructorInputs, setConstructorInputs] = useState(null) |
|
|
|
|
|
|
|
const [addressIsValid, setaddressIsValid] = useState(true) |
|
|
|
const [compilerName, setCompilerName] = useState<string>('') |
|
|
|
const [compilerName, setCompilerName] = useState<string>('') |
|
|
|
const contractsRef = useRef<HTMLSelectElement>(null) |
|
|
|
const contractsRef = useRef<HTMLSelectElement>(null) |
|
|
|
const atAddressValue = useRef<HTMLInputElement>(null) |
|
|
|
const atAddressValue = useRef<HTMLInputElement>(null) |
|
|
@ -201,12 +202,19 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
|
|
|
|
|
|
|
|
const loadFromAddress = () => { |
|
|
|
const loadFromAddress = () => { |
|
|
|
let address = loadedAddress |
|
|
|
let address = loadedAddress |
|
|
|
|
|
|
|
if (address == '') return |
|
|
|
if (!ethJSUtil.isValidChecksumAddress(address)) { |
|
|
|
try { |
|
|
|
props.tooltip(checkSumWarning()) |
|
|
|
if (!ethJSUtil.isValidChecksumAddress(address)) { |
|
|
|
address = ethJSUtil.toChecksumAddress(address) |
|
|
|
props.tooltip(checkSumWarning()) |
|
|
|
|
|
|
|
address = ethJSUtil.toChecksumAddress(address) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
props.loadAddress(loadedContractData, address) |
|
|
|
|
|
|
|
} catch(e) { |
|
|
|
|
|
|
|
console.log("Invalid Address input: ", e) |
|
|
|
|
|
|
|
setaddressIsValid(false) |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
props.loadAddress(loadedContractData, address) |
|
|
|
setaddressIsValid(true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleCheckedIPFS = () => { |
|
|
|
const handleCheckedIPFS = () => { |
|
|
@ -268,13 +276,17 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
evmVersion = JSON.parse(loadedContractData.metadata).settings.evmVersion |
|
|
|
evmVersion = JSON.parse(loadedContractData.metadata).settings.evmVersion |
|
|
|
} catch (err) {} |
|
|
|
} catch (err) {} |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="udapp_container" data-id="contractDropdownContainer"> |
|
|
|
<div className="udapp_container mb-2" data-id="contractDropdownContainer"> |
|
|
|
<div className='d-flex justify-content-between'> |
|
|
|
<div className='d-flex justify-content-between'> |
|
|
|
<div className="d-flex justify-content-between align-items-end"> |
|
|
|
<div className="d-flex justify-content-between align-items-end"> |
|
|
|
<label className="udapp_settingsLabel pr-1"> |
|
|
|
<label className="udapp_settingsLabel pr-1"> |
|
|
|
<FormattedMessage id='udapp.contract' /> |
|
|
|
<FormattedMessage id='udapp.contract' /> |
|
|
|
</label> |
|
|
|
</label> |
|
|
|
{compilerName && compilerName !== '' && <label className='udapp_settingsCompiledBy badge badge-secondary' data-id="udappCompiledBy"><FormattedMessage id='udapp.compiledBy' values={{ compilerName: <span className="text-capitalize"> {compilerName}</span> }} /></label>} |
|
|
|
{compilerName && compilerName !== '' &&
|
|
|
|
|
|
|
|
<label className='udapp_settingsCompiledBy badge badge-secondary' data-id="udappCompiledBy"> |
|
|
|
|
|
|
|
<FormattedMessage id='udapp.compiledBy' values={{ compilerName: <span className="text-capitalize">{compilerName}</span> }} /> |
|
|
|
|
|
|
|
</label> |
|
|
|
|
|
|
|
} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{props.remixdActivated ? |
|
|
|
{props.remixdActivated ? |
|
|
|
(<CustomTooltip |
|
|
|
(<CustomTooltip |
|
|
@ -292,7 +304,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
<i style={{ cursor: 'pointer' }} className="fa fa-refresh mr-2 mt-2" aria-hidden="true"></i> |
|
|
|
<i style={{ cursor: 'pointer' }} className="fa fa-refresh mr-2 mt-2" aria-hidden="true"></i> |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
</CustomTooltip>) |
|
|
|
</CustomTooltip>) |
|
|
|
: null} |
|
|
|
: null} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="udapp_subcontainer"> |
|
|
|
<div className="udapp_subcontainer"> |
|
|
|
<CustomTooltip |
|
|
|
<CustomTooltip |
|
|
@ -302,7 +314,14 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
tooltipText={contractOptions.title} |
|
|
|
tooltipText={contractOptions.title} |
|
|
|
> |
|
|
|
> |
|
|
|
<div id="udappcontractNamesWrapper" className="w-100"> |
|
|
|
<div id="udappcontractNamesWrapper" className="w-100"> |
|
|
|
<select ref={contractsRef} value={currentContract} onChange={handleContractChange} className="udapp_contractNames custom-select" disabled={contractOptions.disabled} style={{ display: loadType === 'abi' && !isContractFile(currentFile) ? 'none' : 'block', pointerEvents: contractOptions.disabled ? 'none' : 'auto' }}> |
|
|
|
<select ref={contractsRef} |
|
|
|
|
|
|
|
value={currentContract} |
|
|
|
|
|
|
|
onChange={handleContractChange} |
|
|
|
|
|
|
|
className="udapp_contractNames custom-select" |
|
|
|
|
|
|
|
disabled={contractOptions.disabled} |
|
|
|
|
|
|
|
style={{ display: loadType === 'abi' && !isContractFile(currentFile) ? 'none' : 'block', pointerEvents: contractOptions.disabled ? 'none' : 'auto' }} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<option value='' disabled hidden>No compiled contracts</option> |
|
|
|
{(contractList[currentFile] || []).map((contract, index) => { |
|
|
|
{(contractList[currentFile] || []).map((contract, index) => { |
|
|
|
return <option key={index} value={contract.alias}> |
|
|
|
return <option key={index} value={contract.alias}> |
|
|
|
{contract.alias} - {contract.file} |
|
|
|
{contract.alias} - {contract.file} |
|
|
@ -314,19 +333,20 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
<span className="py-1" style={{ display: abiLabel.display }}>{abiLabel.content}</span> |
|
|
|
<span className="py-1" style={{ display: abiLabel.display }}>{abiLabel.content}</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{ evmVersion && loadedContractData && <CustomTooltip |
|
|
|
{ evmVersion && loadedContractData && <CustomTooltip |
|
|
|
placement={'right'} |
|
|
|
placement={'right'} |
|
|
|
tooltipClasses="text-wrap text-left" |
|
|
|
tooltipClasses="text-wrap text-left" |
|
|
|
tooltipId="info-evm-version-warn" |
|
|
|
tooltipId="info-evm-version-warn" |
|
|
|
tooltipText={<span className="text-left"> |
|
|
|
tooltipText={<span className="text-left"> |
|
|
|
<FormattedMessage id='udapp.warningEvmVersion' values={{ evmVersion }}/> |
|
|
|
<FormattedMessage id='udapp.warningEvmVersion' values={{ evmVersion }}/> |
|
|
|
</span>} |
|
|
|
</span>} |
|
|
|
> |
|
|
|
> |
|
|
|
<span className='udapp_evmVersion badge badge-secondary'>evm version: {evmVersion}</span> |
|
|
|
<span className='udapp_evmVersion badge alert-warning'>evm version: {evmVersion}</span> |
|
|
|
</CustomTooltip> } |
|
|
|
</CustomTooltip> |
|
|
|
|
|
|
|
} |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<div className="udapp_deployDropdown"> |
|
|
|
<div className="udapp_deployDropdown"> |
|
|
|
{((contractList[currentFile] && contractList[currentFile].filter(contract => contract)) || []).length <= 0 ? intl.formatMessage({ id: 'udapp.noCompiledContracts' }) |
|
|
|
{(((contractList[currentFile] && contractList[currentFile].filter(contract => contract)) || []).length > 0 && loadedContractData) && |
|
|
|
: loadedContractData ? <div> |
|
|
|
<div> |
|
|
|
<ContractGUI |
|
|
|
<ContractGUI |
|
|
|
title={intl.formatMessage({ id: 'udapp.deploy' })} |
|
|
|
title={intl.formatMessage({ id: 'udapp.deploy' })} |
|
|
|
isDeploy={true} |
|
|
|
isDeploy={true} |
|
|
@ -368,38 +388,38 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
</label> |
|
|
|
</label> |
|
|
|
</CustomTooltip> |
|
|
|
</CustomTooltip> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> : '' |
|
|
|
</div> |
|
|
|
} |
|
|
|
} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="udapp_orLabel mt-2" style={{ display: loadType === 'abi' && !isContractFile(currentFile) ? 'none' : 'block' }}> |
|
|
|
<div className="pt-2 d-flex flex-column sudapp_button udapp_atAddressSect"> |
|
|
|
<FormattedMessage id='udapp.or' /> |
|
|
|
<div className='d-flex flex-row'> |
|
|
|
</div> |
|
|
|
<CustomTooltip |
|
|
|
<div className="udapp_button udapp_atAddressSect "> |
|
|
|
placement={'top-end'} |
|
|
|
<CustomTooltip |
|
|
|
tooltipClasses="text-wrap text-left" |
|
|
|
placement={'top-end'} |
|
|
|
tooltipId="runAndDeployAddresstooltip" |
|
|
|
tooltipClasses="text-wrap text-left" |
|
|
|
tooltipText={atAddressOptions.title} |
|
|
|
tooltipId="runAndDeployAddresstooltip" |
|
|
|
|
|
|
|
tooltipText={atAddressOptions.title} |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<div id="runAndDeployAtAdressButtonContainer" onClick={loadFromAddress} data-title={atAddressOptions.title}> |
|
|
|
<div id="runAndDeployAtAdressButtonContainer" onClick={loadFromAddress} data-title={atAddressOptions.title}> |
|
|
|
<button className="udapp_atAddress btn btn-sm btn-primary" id="runAndDeployAtAdressButton" disabled={atAddressOptions.disabled} style={{ pointerEvents: 'none' }} onClick={loadFromAddress} data-title={atAddressOptions.title}> |
|
|
|
<button className="udapp_atAddress btn-sm py-2 btn-primary" id="runAndDeployAtAdressButton" disabled={atAddressOptions.disabled} style={{ pointerEvents: 'none' }} onClick={loadFromAddress} data-title={atAddressOptions.title}> |
|
|
|
<FormattedMessage id='udapp.atAddress' /> |
|
|
|
<FormattedMessage id='udapp.atAddress' /> |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</CustomTooltip> |
|
|
|
</CustomTooltip> |
|
|
|
<CustomTooltip |
|
|
|
<CustomTooltip |
|
|
|
placement={'top-end'} |
|
|
|
placement={'top-end'} |
|
|
|
tooltipClasses="text-wrap text-left" |
|
|
|
tooltipClasses="text-wrap text-left" |
|
|
|
tooltipId="runAndDeployAddressInputtooltip" |
|
|
|
tooltipId="runAndDeployAddressInputtooltip" |
|
|
|
tooltipText={<FormattedMessage id='udapp.addressOfContract' />} |
|
|
|
tooltipText={<FormattedMessage id='udapp.addressOfContract' />} |
|
|
|
> |
|
|
|
> |
|
|
|
<input |
|
|
|
<input |
|
|
|
ref={atAddressValue} |
|
|
|
ref={atAddressValue} |
|
|
|
className="udapp_input udapp_ataddressinput ataddressinput form-control" |
|
|
|
className={(!addressIsValid ? "border border-danger" : "border-0") + " h-100 udapp_input udapp_ataddressinput ataddressinput form-control"} |
|
|
|
placeholder={intl.formatMessage({ id: 'udapp.loadContractFromAddress' })} |
|
|
|
placeholder={intl.formatMessage({ id: 'udapp.loadContractFromAddress' })} |
|
|
|
onChange={atAddressChanged} |
|
|
|
onChange={atAddressChanged} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</CustomTooltip> |
|
|
|
</CustomTooltip> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
{ !addressIsValid && <span className='text-danger text-right'>The address is not valid</span> } |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|