@@ -32,6 +32,7 @@ export function ContractGUI(props: ContractGUIProps) {
3232 const multiFields = useRef < Array < HTMLInputElement | null > > ( [ ] )
3333 const initializeFields = useRef < Array < HTMLInputElement | null > > ( [ ] )
3434 const basicInputRef = useRef < HTMLInputElement > ( )
35+ const [ baseTitleForDataId , setBaseTitleForDataId ] = useState < string > ( '' )
3536
3637 const intl = useIntl ( )
3738 useEffect ( ( ) => {
@@ -42,19 +43,34 @@ export function ContractGUI(props: ContractGUIProps) {
4243 } , [ props . deployOption ] )
4344
4445 useEffect ( ( ) => {
46+ let newTitle = ''
47+ let newBaseTitle = ''
48+
4549 if ( props . title ) {
46- setTitle ( props . title )
50+ newTitle = props . title
4751 } else if ( props . funcABI . name ) {
48- setTitle ( props . funcABI . name )
52+ newTitle = props . funcABI . name
4953 } else {
50- setTitle ( props . funcABI . type === 'receive' ? '(receive)' : '(fallback)' )
54+ newTitle = props . funcABI . type === 'receive' ? '(receive)' : '(fallback)'
5155 }
56+
57+ if ( props . isDeploy ) {
58+ newBaseTitle = intl . formatMessage ( { id : 'udapp.deploy' , defaultMessage : 'Deploy' } )
59+ } else if ( props . funcABI . name ) {
60+ newBaseTitle = props . funcABI . name
61+ } else {
62+ newBaseTitle = props . funcABI . type === 'receive' ? '(receive)' : '(fallback)'
63+ }
64+
65+ setTitle ( newTitle )
66+ setBaseTitleForDataId ( newBaseTitle )
67+
5268 setBasicInput ( '' )
5369 // we have the reset the fields before resetting the previous references.
5470 basicInputRef . current . value = ''
5571 multiFields . current . filter ( ( el ) => el !== null && el !== undefined ) . forEach ( ( el ) => ( el . value = '' ) )
5672 multiFields . current = [ ]
57- } , [ props . title , props . funcABI ] )
73+ } , [ props . title , props . funcABI , props . isDeploy , intl ] )
5874
5975 useEffect ( ( ) => {
6076 if ( props . lookupOnly ) {
@@ -63,26 +79,26 @@ export function ContractGUI(props: ContractGUIProps) {
6379 title : title + ' - call' ,
6480 content : 'call' ,
6581 classList : 'btn-primary' ,
66- dataId : title + ' - call'
82+ dataId : baseTitleForDataId + ' - call'
6783 } )
6884 } else if ( props . funcABI . stateMutability === 'payable' || props . funcABI . payable ) {
6985 // // transact. stateMutability = payable
7086 setButtonOptions ( {
7187 title : title + ' - transact (payable)' ,
7288 content : 'transact' ,
7389 classList : 'btn-danger' ,
74- dataId : title + ' - transact (payable)'
90+ dataId : baseTitleForDataId + ' - transact (payable)'
7591 } )
7692 } else {
7793 // // transact. stateMutability = nonpayable
7894 setButtonOptions ( {
7995 title : title + ' - transact (not payable)' ,
8096 content : 'transact' ,
8197 classList : 'btn-warning' ,
82- dataId : title + ' - transact (not payable)'
98+ dataId : baseTitleForDataId + ' - transact (not payable)'
8399 } )
84100 }
85- } , [ props . lookupOnly , props . funcABI , title ] )
101+ } , [ props . lookupOnly , props . funcABI , title , baseTitleForDataId ] )
86102
87103 const getEncodedCall = ( ) => {
88104 const multiString = getMultiValsString ( multiFields . current )
@@ -305,7 +321,7 @@ export function ContractGUI(props: ContractGUIProps) {
305321 ( props . funcABI . inputs && props . funcABI . inputs . length > 0 ) || props . funcABI . type === 'fallback' || props . funcABI . type === 'receive' ? 'udapp_hasArgs' : ''
306322 } `}
307323 >
308- < div className = "udapp_contractActionsContainerSingle pt-2 " style = { { display : toggleContainer ? 'none' : 'flex' } } >
324+ < div className = "udapp_contractActionsContainerSingle" style = { { display : toggleContainer ? 'none' : 'flex' } } >
309325 < CustomTooltip
310326 delay = { 0 }
311327 placement = { 'auto-end' }
0 commit comments