@@ -29,6 +29,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
2929 const [ loadedContractData , setLoadedContractData ] = useState < ContractData > ( null )
3030 const [ constructorInterface , setConstructorInterface ] = useState < FuncABI > ( null )
3131 const [ constructorInputs , setConstructorInputs ] = useState ( null )
32+ const [ addressIsValid , setaddressIsValid ] = useState ( true )
3233 const [ compilerName , setCompilerName ] = useState < string > ( '' )
3334 const contractsRef = useRef < HTMLSelectElement > ( null )
3435 const atAddressValue = useRef < HTMLInputElement > ( null )
@@ -201,12 +202,19 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
201202
202203 const loadFromAddress = ( ) => {
203204 let address = loadedAddress
204-
205- if ( ! ethJSUtil . isValidChecksumAddress ( address ) ) {
206- props . tooltip ( checkSumWarning ( ) )
207- address = ethJSUtil . toChecksumAddress ( address )
205+ if ( address == '' ) return
206+ try {
207+ if ( ! ethJSUtil . isValidChecksumAddress ( address ) ) {
208+ props . tooltip ( checkSumWarning ( ) )
209+ address = ethJSUtil . toChecksumAddress ( address )
210+ }
211+ props . loadAddress ( loadedContractData , address )
212+ } catch ( e ) {
213+ console . log ( "Invalid Address input: " , e )
214+ setaddressIsValid ( false )
215+ return
208216 }
209- props . loadAddress ( loadedContractData , address )
217+ setaddressIsValid ( true )
210218 }
211219
212220 const handleCheckedIPFS = ( ) => {
@@ -268,13 +276,17 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
268276 evmVersion = JSON . parse ( loadedContractData . metadata ) . settings . evmVersion
269277 } catch ( err ) { }
270278 return (
271- < div className = "udapp_container" data-id = "contractDropdownContainer" >
279+ < div className = "udapp_container mb-2 " data-id = "contractDropdownContainer" >
272280 < div className = 'd-flex justify-content-between' >
273281 < div className = "d-flex justify-content-between align-items-end" >
274282 < label className = "udapp_settingsLabel pr-1" >
275283 < FormattedMessage id = 'udapp.contract' />
276284 </ label >
277- { 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 > }
285+ { compilerName && compilerName !== '' &&
286+ < label className = 'udapp_settingsCompiledBy badge badge-secondary' data-id = "udappCompiledBy" >
287+ < FormattedMessage id = 'udapp.compiledBy' values = { { compilerName : < span className = "text-capitalize" > { compilerName } </ span > } } />
288+ </ label >
289+ }
278290 </ div >
279291 { props . remixdActivated ?
280292 ( < CustomTooltip
@@ -292,7 +304,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
292304 < i style = { { cursor : 'pointer' } } className = "fa fa-refresh mr-2 mt-2" aria-hidden = "true" > </ i >
293305 </ button >
294306 </ CustomTooltip > )
295- : null }
307+ : null }
296308 </ div >
297309 < div className = "udapp_subcontainer" >
298310 < CustomTooltip
@@ -302,7 +314,14 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
302314 tooltipText = { contractOptions . title }
303315 >
304316 < div id = "udappcontractNamesWrapper" className = "w-100" >
305- < 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' } } >
317+ < select ref = { contractsRef }
318+ value = { currentContract }
319+ onChange = { handleContractChange }
320+ className = "udapp_contractNames custom-select"
321+ disabled = { contractOptions . disabled }
322+ style = { { display : loadType === 'abi' && ! isContractFile ( currentFile ) ? 'none' : 'block' , pointerEvents : contractOptions . disabled ? 'none' : 'auto' } }
323+ >
324+ < option value = '' disabled hidden > No compiled contracts</ option >
306325 { ( contractList [ currentFile ] || [ ] ) . map ( ( contract , index ) => {
307326 return < option key = { index } value = { contract . alias } >
308327 { contract . alias } - { contract . file }
@@ -314,19 +333,20 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
314333 < span className = "py-1" style = { { display : abiLabel . display } } > { abiLabel . content } </ span >
315334 </ div >
316335 { evmVersion && loadedContractData && < CustomTooltip
317- placement = { 'right' }
318- tooltipClasses = "text-wrap text-left"
319- tooltipId = "info-evm-version-warn"
320- tooltipText = { < span className = "text-left" >
321- < FormattedMessage id = 'udapp.warningEvmVersion' values = { { evmVersion } } />
322- </ span > }
323- >
324- < span className = 'udapp_evmVersion badge badge-secondary' > evm version: { evmVersion } </ span >
325- </ CustomTooltip > }
336+ placement = { 'right' }
337+ tooltipClasses = "text-wrap text-left"
338+ tooltipId = "info-evm-version-warn"
339+ tooltipText = { < span className = "text-left" >
340+ < FormattedMessage id = 'udapp.warningEvmVersion' values = { { evmVersion } } />
341+ </ span > }
342+ >
343+ < span className = 'udapp_evmVersion badge alert-warning' > evm version: { evmVersion } </ span >
344+ </ CustomTooltip >
345+ }
326346 < div >
327347 < div className = "udapp_deployDropdown" >
328- { ( ( contractList [ currentFile ] && contractList [ currentFile ] . filter ( contract => contract ) ) || [ ] ) . length <= 0 ? intl . formatMessage ( { id : 'udapp.noCompiledContracts' } )
329- : loadedContractData ? < div >
348+ { ( ( ( contractList [ currentFile ] && contractList [ currentFile ] . filter ( contract => contract ) ) || [ ] ) . length > 0 && loadedContractData ) &&
349+ < div >
330350 < ContractGUI
331351 title = { intl . formatMessage ( { id : 'udapp.deploy' } ) }
332352 isDeploy = { true }
@@ -368,38 +388,38 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
368388 </ label >
369389 </ CustomTooltip >
370390 </ div >
371- </ div > : ''
391+ </ div >
372392 }
373393 </ div >
374- < div className = "udapp_orLabel mt-2" style = { { display : loadType === 'abi' && ! isContractFile ( currentFile ) ? 'none' : 'block' } } >
375- < FormattedMessage id = 'udapp.or' />
376- </ div >
377- < div className = "udapp_button udapp_atAddressSect " >
378- < CustomTooltip
379- placement = { 'top-end' }
380- tooltipClasses = "text-wrap text-left"
381- tooltipId = "runAndDeployAddresstooltip"
382- tooltipText = { atAddressOptions . title }
394+ < div className = "pt-2 d-flex flex-column sudapp_button udapp_atAddressSect" >
395+ < div className = 'd-flex flex-row' >
396+ < CustomTooltip
397+ placement = { 'top-end' }
398+ tooltipClasses = "text-wrap text-left"
399+ tooltipId = "runAndDeployAddresstooltip"
400+ tooltipText = { atAddressOptions . title }
383401 >
384402 < div id = "runAndDeployAtAdressButtonContainer" onClick = { loadFromAddress } data-title = { atAddressOptions . title } >
385- < button className = "udapp_atAddress btn btn -sm btn-primary" id = "runAndDeployAtAdressButton" disabled = { atAddressOptions . disabled } style = { { pointerEvents : 'none' } } onClick = { loadFromAddress } data-title = { atAddressOptions . title } >
403+ < button className = "udapp_atAddress btn-sm py-2 btn-primary" id = "runAndDeployAtAdressButton" disabled = { atAddressOptions . disabled } style = { { pointerEvents : 'none' } } onClick = { loadFromAddress } data-title = { atAddressOptions . title } >
386404 < FormattedMessage id = 'udapp.atAddress' />
387405 </ button >
388406 </ div >
389- </ CustomTooltip >
390- < CustomTooltip
391- placement = { 'top-end' }
392- tooltipClasses = "text-wrap text-left"
393- tooltipId = "runAndDeployAddressInputtooltip"
394- tooltipText = { < FormattedMessage id = 'udapp.addressOfContract' /> }
395- >
396- < input
397- ref = { atAddressValue }
398- className = "udapp_input udapp_ataddressinput ataddressinput form-control"
399- placeholder = { intl . formatMessage ( { id : 'udapp.loadContractFromAddress' } ) }
400- onChange = { atAddressChanged }
401- />
402- </ CustomTooltip >
407+ </ CustomTooltip >
408+ < CustomTooltip
409+ placement = { 'top-end' }
410+ tooltipClasses = "text-wrap text-left"
411+ tooltipId = "runAndDeployAddressInputtooltip"
412+ tooltipText = { < FormattedMessage id = 'udapp.addressOfContract' /> }
413+ >
414+ < input
415+ ref = { atAddressValue }
416+ className = { ( ! addressIsValid ? "border border-danger" : "border-0" ) + " h-100 udapp_input udapp_ataddressinput ataddressinput form-control" }
417+ placeholder = { intl . formatMessage ( { id : 'udapp.loadContractFromAddress' } ) }
418+ onChange = { atAddressChanged }
419+ />
420+ </ CustomTooltip >
421+ </ div >
422+ { ! addressIsValid && < span className = 'text-danger text-right' > The address is not valid</ span > }
403423 </ div >
404424 </ div >
405425 </ div >
0 commit comments