@@ -6,6 +6,7 @@ import config from 'configs/app';
6
6
import { Image } from 'toolkit/chakra/image' ;
7
7
import { Link } from 'toolkit/chakra/link' ;
8
8
import { Skeleton } from 'toolkit/chakra/skeleton' ;
9
+ import { HEX_REGEXP_WITH_0X } from 'toolkit/utils/regexp' ;
9
10
import TextSeparator from 'ui/shared/TextSeparator' ;
10
11
11
12
const feature = config . features . saveOnGas ;
@@ -26,9 +27,9 @@ const AddressSaveOnGas = ({ gasUsed, address }: Props) => {
26
27
const gasUsedNumber = Number ( gasUsed ) ;
27
28
28
29
const query = useQuery ( {
29
- queryKey : [ 'gas_hawk_saving_potential' , { address } ] ,
30
+ queryKey : [ 'external: gas_hawk_saving_potential' , { address } ] ,
30
31
queryFn : async ( ) => {
31
- if ( ! feature . isEnabled ) {
32
+ if ( ! feature . isEnabled || ! HEX_REGEXP_WITH_0X . test ( address ) ) {
32
33
return ;
33
34
}
34
35
@@ -40,7 +41,7 @@ const AddressSaveOnGas = ({ gasUsed, address }: Props) => {
40
41
const parsedResponse = v . safeParse ( responseSchema , response ) ;
41
42
42
43
if ( ! parsedResponse . success ) {
43
- throw Error ( 'Invalid response schema' ) ;
44
+ throw Error ( ERROR_NAME ) ;
44
45
}
45
46
46
47
return parsedResponse . output ;
@@ -52,12 +53,12 @@ const AddressSaveOnGas = ({ gasUsed, address }: Props) => {
52
53
const errorMessage = query . error && 'message' in query . error ? query . error . message : undefined ;
53
54
54
55
React . useEffect ( ( ) => {
55
- if ( errorMessage === ERROR_NAME ) {
56
+ if ( feature . isEnabled && ERROR_NAME === errorMessage ) {
56
57
fetch ( '/node-api/monitoring/invalid-api-schema' , {
57
58
method : 'POST' ,
58
59
body : JSON . stringify ( {
59
- resource : 'gas_hawk_saving_potential' ,
60
- url : feature . isEnabled ? feature . apiUrlTemplate . replace ( '<address>' , address ) : undefined ,
60
+ resource : 'external: gas_hawk_saving_potential' ,
61
+ url : feature . isEnabled && HEX_REGEXP_WITH_0X . test ( address ) ? feature . apiUrlTemplate . replace ( '<address>' , address ) : undefined ,
61
62
} ) ,
62
63
} ) ;
63
64
}
0 commit comments