|
|
|
@ -29,6 +29,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
|
const [loadedContractData, setLoadedContractData] = useState<ContractData>(null) |
|
|
|
|
const [constructorInterface, setConstructorInterface] = useState<FuncABI>(null) |
|
|
|
|
const [constructorInputs, setConstructorInputs] = useState(null) |
|
|
|
|
const [addressIsValid, setaddressIsValid] = useState(true) |
|
|
|
|
const [compilerName, setCompilerName] = useState<string>('') |
|
|
|
|
const contractsRef = useRef<HTMLSelectElement>(null) |
|
|
|
|
const atAddressValue = useRef<HTMLInputElement>(null) |
|
|
|
@ -201,12 +202,19 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
|
|
|
|
|
|
const loadFromAddress = () => { |
|
|
|
|
let address = loadedAddress |
|
|
|
|
|
|
|
|
|
if (address == '') return |
|
|
|
|
try { |
|
|
|
|
if (!ethJSUtil.isValidChecksumAddress(address)) { |
|
|
|
|
props.tooltip(checkSumWarning()) |
|
|
|
|
address = ethJSUtil.toChecksumAddress(address) |
|
|
|
|
} |
|
|
|
|
props.loadAddress(loadedContractData, address) |
|
|
|
|
} catch(e) { |
|
|
|
|
console.log("Invalid Address input: ", e) |
|
|
|
|
setaddressIsValid(false) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
setaddressIsValid(true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleCheckedIPFS = () => { |
|
|
|
@ -268,13 +276,17 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
|
evmVersion = JSON.parse(loadedContractData.metadata).settings.evmVersion |
|
|
|
|
} catch (err) {} |
|
|
|
|
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 align-items-end"> |
|
|
|
|
<label className="udapp_settingsLabel pr-1"> |
|
|
|
|
<FormattedMessage id='udapp.contract' /> |
|
|
|
|
</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> |
|
|
|
|
{props.remixdActivated ? |
|
|
|
|
(<CustomTooltip |
|
|
|
@ -302,7 +314,14 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
|
tooltipText={contractOptions.title} |
|
|
|
|
> |
|
|
|
|
<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) => { |
|
|
|
|
return <option key={index} value={contract.alias}> |
|
|
|
|
{contract.alias} - {contract.file} |
|
|
|
@ -321,12 +340,13 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
|
<FormattedMessage id='udapp.warningEvmVersion' values={{ evmVersion }}/> |
|
|
|
|
</span>} |
|
|
|
|
> |
|
|
|
|
<span className='udapp_evmVersion badge badge-secondary'>evm version: {evmVersion}</span> |
|
|
|
|
</CustomTooltip> } |
|
|
|
|
<span className='udapp_evmVersion badge alert-warning'>evm version: {evmVersion}</span> |
|
|
|
|
</CustomTooltip> |
|
|
|
|
} |
|
|
|
|
<div> |
|
|
|
|
<div className="udapp_deployDropdown"> |
|
|
|
|
{((contractList[currentFile] && contractList[currentFile].filter(contract => contract)) || []).length <= 0 ? intl.formatMessage({ id: 'udapp.noCompiledContracts' }) |
|
|
|
|
: loadedContractData ? <div> |
|
|
|
|
{(((contractList[currentFile] && contractList[currentFile].filter(contract => contract)) || []).length > 0 && loadedContractData) && |
|
|
|
|
<div> |
|
|
|
|
<ContractGUI |
|
|
|
|
title={intl.formatMessage({ id: 'udapp.deploy' })} |
|
|
|
|
isDeploy={true} |
|
|
|
@ -368,13 +388,11 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
|
</label> |
|
|
|
|
</CustomTooltip> |
|
|
|
|
</div> |
|
|
|
|
</div> : '' |
|
|
|
|
} |
|
|
|
|
</div> |
|
|
|
|
<div className="udapp_orLabel mt-2" style={{ display: loadType === 'abi' && !isContractFile(currentFile) ? 'none' : 'block' }}> |
|
|
|
|
<FormattedMessage id='udapp.or' /> |
|
|
|
|
} |
|
|
|
|
</div> |
|
|
|
|
<div className="udapp_button udapp_atAddressSect "> |
|
|
|
|
<div className="pt-2 d-flex flex-column sudapp_button udapp_atAddressSect"> |
|
|
|
|
<div className='d-flex flex-row'> |
|
|
|
|
<CustomTooltip |
|
|
|
|
placement={'top-end'} |
|
|
|
|
tooltipClasses="text-wrap text-left" |
|
|
|
@ -382,7 +400,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
|
tooltipText={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' /> |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
@ -395,12 +413,14 @@ export function ContractDropdownUI (props: ContractDropdownProps) { |
|
|
|
|
> |
|
|
|
|
<input |
|
|
|
|
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' })} |
|
|
|
|
onChange={atAddressChanged} |
|
|
|
|
/> |
|
|
|
|
</CustomTooltip> |
|
|
|
|
</div> |
|
|
|
|
{ !addressIsValid && <span className='text-danger text-right'>The address is not valid</span> } |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
) |
|
|
|
|