@@ -2,7 +2,10 @@ import { Flex, FormControl, InputGroup } from "@chakra-ui/react";
22import { SolidityInput } from "contract-ui/components/solidity-inputs" ;
33import { FormErrorMessage , FormHelperText , FormLabel } from "tw-components" ;
44import { Fieldset } from "./common" ;
5- import type { CustomContractDeploymentForm } from "./custom-contract" ;
5+ import type {
6+ CustomContractDeploymentForm ,
7+ DynamicValue ,
8+ } from "./custom-contract" ;
69
710interface TrustedForwardersFieldsetProps {
811 form : CustomContractDeploymentForm ;
@@ -11,56 +14,65 @@ interface TrustedForwardersFieldsetProps {
1114export const TrustedForwardersFieldset : React . FC <
1215 TrustedForwardersFieldsetProps
1316> = ( { form } ) => {
17+ const isDynamicValue = ( val : string | DynamicValue ) : val is DynamicValue => {
18+ return typeof val === "object" && val !== null && "dynamicValue" in val ;
19+ } ;
20+
21+ const value = form . watch ( "deployParams._trustedForwarders" ) ;
1422 return (
15- < Fieldset legend = "Gasless" >
16- < FormControl
17- isRequired
18- isInvalid = {
19- ! ! form . getFieldState (
20- "deployParams._trustedForwarders" ,
21- form . formState ,
22- ) . error
23- }
24- >
25- < div className = "flex items-center justify-between gap-6" >
26- { /* left */ }
27- < div >
28- < FormLabel > Trusted Forwarders</ FormLabel >
23+ < >
24+ { ! isDynamicValue ( value ) && (
25+ < Fieldset legend = "Gasless" >
26+ < FormControl
27+ isRequired
28+ isInvalid = {
29+ ! ! form . getFieldState (
30+ "deployParams._trustedForwarders" ,
31+ form . formState ,
32+ ) . error
33+ }
34+ >
35+ < div className = "flex items-center justify-between gap-6" >
36+ { /* left */ }
37+ < div >
38+ < FormLabel > Trusted Forwarders</ FormLabel >
2939
30- < FormHelperText className = "!text-sm text-muted-foreground" >
31- < span className = "mb-1 block text-muted-foreground text-sm" >
32- Trusted forwarder addresses to enable ERC-2771 transactions
33- (i.e. gasless).
34- </ span >
40+ < FormHelperText className = "!text-sm text-muted-foreground" >
41+ < span className = "mb-1 block text-muted-foreground text-sm" >
42+ Trusted forwarder addresses to enable ERC-2771 transactions
43+ (i.e. gasless).
44+ </ span >
3545
36- < span className = "block text-muted-foreground text-sm" >
37- You can provide your own forwarder.
38- </ span >
39- </ FormHelperText >
40- </ div >
41- </ div >
46+ < span className = "block text-muted-foreground text-sm" >
47+ You can provide your own forwarder.
48+ </ span >
49+ </ FormHelperText >
50+ </ div >
51+ </ div >
4252
43- < div className = "fade-in-0 block animate-in pt-3 duration-400" >
44- < InputGroup size = "md" >
45- < Flex flexDir = "column" w = "full" >
46- < SolidityInput
47- value = { form . watch ( "deployParams._trustedForwarders" ) as string }
48- solidityType = "address[]"
49- { ...form . register ( "deployParams._trustedForwarders" ) }
50- />
51- </ Flex >
52- </ InputGroup >
53+ < div className = "fade-in-0 block animate-in pt-3 duration-400" >
54+ < InputGroup size = "md" >
55+ < Flex flexDir = "column" w = "full" >
56+ < SolidityInput
57+ value = { value }
58+ solidityType = "address[]"
59+ { ...form . register ( "deployParams._trustedForwarders" ) }
60+ />
61+ </ Flex >
62+ </ InputGroup >
5363
54- < FormErrorMessage >
55- {
56- form . getFieldState (
57- "deployParams._trustedForwarders" ,
58- form . formState ,
59- ) . error ?. message
60- }
61- </ FormErrorMessage >
62- </ div >
63- </ FormControl >
64- </ Fieldset >
64+ < FormErrorMessage >
65+ {
66+ form . getFieldState (
67+ "deployParams._trustedForwarders" ,
68+ form . formState ,
69+ ) . error ?. message
70+ }
71+ </ FormErrorMessage >
72+ </ div >
73+ </ FormControl >
74+ </ Fieldset >
75+ ) }
76+ </ >
6577 ) ;
6678} ;
0 commit comments