@ -17,7 +17,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
title : 'address of contract' ,
title : 'address of contract' ,
disabled : true
disabled : true
} )
} )
const [ address , setAddress ] = useState < string > ( '' )
const [ lo adedA ddress, setLoaded Address ] = useState < string > ( '' )
const [ contractOptions , setContractOptions ] = useState < { title : string , disabled : boolean } > ( {
const [ contractOptions , setContractOptions ] = useState < { title : string , disabled : boolean } > ( {
title : 'Please compile *.sol file to deploy or access a contract' ,
title : 'Please compile *.sol file to deploy or access a contract' ,
disabled : true
disabled : true
@ -44,8 +44,8 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
} , [ props . exEnvironment ] )
} , [ props . exEnvironment ] )
useEffect ( ( ) = > {
useEffect ( ( ) = > {
if ( ! address || ! ethJSUtil . isValidAddress ( address ) ) enableAtAddress ( false )
if ( ! lo adFromA ddress || ! ethJSUtil . isValidAddress ( lo adedA ddress) ) enableAtAddress ( false )
} , [ address ] )
} , [ lo adedA ddress] )
useEffect ( ( ) = > {
useEffect ( ( ) = > {
if ( /.(.abi)$/ . exec ( currentFile ) ) {
if ( /.(.abi)$/ . exec ( currentFile ) ) {
@ -78,6 +78,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
useEffect ( ( ) = > {
useEffect ( ( ) = > {
if ( selectedContract ) {
if ( selectedContract ) {
console . log ( 'contractList: ' , contractList )
const contract = contractList . find ( contract = > contract . alias === selectedContract )
const contract = contractList . find ( contract = > contract . alias === selectedContract )
setLoadedContractData ( props . getSelectedContract ( selectedContract , contract . name ) )
setLoadedContractData ( props . getSelectedContract ( selectedContract , contract . name ) )
@ -93,7 +94,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
} else {
} else {
setAtAddressOptions ( {
setAtAddressOptions ( {
disabled : true ,
disabled : true ,
title : address ? '⚠ Compile *.sol file or select *.abi file.' : '⚠ Compile *.sol file or select *.abi file & then enter the address of deployed contract.'
title : lo adedA ddress ? '⚠ Compile *.sol file or select *.abi file.' : '⚠ Compile *.sol file or select *.abi file & then enter the address of deployed contract.'
} )
} )
}
}
}
}
@ -149,18 +150,23 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
if ( ! value ) {
if ( ! value ) {
enableAtAddress ( false )
enableAtAddress ( false )
} else {
} else {
if ( ( ! contractOptions . disabled && loadType === 'sol' ) ||
if ( atAddressOptions . disabled && ( loadType === 'sol' || loadType === 'abi' ) ) {
loadType === 'abi' ) {
enableAtAddress ( true )
enableAtAddress ( true )
} else {
} else {
enableAtAddress ( false )
enableAtAddress ( false )
}
}
}
}
setAddress ( value )
setLoaded Address ( value )
}
}
const loadFromAddress = ( ) = > {
const loadFromAddress = ( ) = > {
// trigger dispatchLoadAddress
let address = loadedAddress
if ( ! ethJSUtil . isValidChecksumAddress ( address ) ) {
props . tooltip ( checkSumWarning ( ) )
address = ethJSUtil . toChecksumAddress ( address )
}
props . loadAddress ( loadedContractData , address )
}
}
const handleCheckedIPFS = ( ) = > {
const handleCheckedIPFS = ( ) = > {
@ -174,6 +180,16 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
setSelectedContract ( value )
setSelectedContract ( value )
}
}
const checkSumWarning = ( ) = > {
return (
< span >
It seems you are not using a checksumed address .
< br / > A checksummed address is an address that contains uppercase letters , as specified in < a href = "https://eips.ethereum.org/EIPS/eip-55" target = "_blank" > EIP - 55 < / a > .
< br / > Checksummed addresses are meant to help prevent users from sending transactions to the wrong address .
< / span >
)
}
const isOverSizePrompt = ( ) = > {
const isOverSizePrompt = ( ) = > {
return (
return (
< div > Contract creation initialization returns data with length of more than 24576 bytes . The deployment will likely fails . < br / >
< div > Contract creation initialization returns data with length of more than 24576 bytes . The deployment will likely fails . < br / >
@ -228,7 +244,6 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
placeholder = "Load contract from Address"
placeholder = "Load contract from Address"
title = "address of contract"
title = "address of contract"
onChange = { atAddressChanged }
onChange = { atAddressChanged }
disabled = { atAddressOptions . disabled }
/ >
/ >
< / div >
< / div >
< / div >
< / div >