Skip to content

Commit 2a3d99b

Browse files
committed
fix types
1 parent 5bd53d0 commit 2a3d99b

File tree

3 files changed

+62
-50
lines changed

3 files changed

+62
-50
lines changed

apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type CustomContractDeploymentFormData = {
8080
recipients?: Recipient[];
8181
};
8282

83-
interface DynamicValue {
83+
export interface DynamicValue {
8484
dynamicValue: {
8585
type: string;
8686
refContracts?: {

apps/dashboard/src/components/contract-components/contract-deploy-form/trusted-forwarders-fieldset.tsx

Lines changed: 59 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { Flex, FormControl, InputGroup } from "@chakra-ui/react";
22
import { SolidityInput } from "contract-ui/components/solidity-inputs";
33
import { FormErrorMessage, FormHelperText, FormLabel } from "tw-components";
44
import { Fieldset } from "./common";
5-
import type { CustomContractDeploymentForm } from "./custom-contract";
5+
import type {
6+
CustomContractDeploymentForm,
7+
DynamicValue,
8+
} from "./custom-contract";
69

710
interface TrustedForwardersFieldsetProps {
811
form: CustomContractDeploymentForm;
@@ -11,56 +14,65 @@ interface TrustedForwardersFieldsetProps {
1114
export 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
};

packages/thirdweb/src/extensions/prebuilts/process-ref-deployments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function processRefDeployments(
3636
const contracts = dynamicValue.refContracts;
3737

3838
if (dynamicValue.type === "address") {
39-
if (!contracts || contracts.length === 0) {
39+
if (!contracts || contracts.length === 0 || !contracts[0]?.contractId) {
4040
throw new Error("Invalid or empty param value");
4141
}
4242
const salt =
@@ -48,7 +48,7 @@ export async function processRefDeployments(
4848
client,
4949
chain,
5050
account,
51-
contractId: contracts[0]?.contractId as string,
51+
contractId: contracts[0]?.contractId,
5252
publisher: contracts[0]?.publisherAddress,
5353
version: contracts[0]?.version,
5454
salt,

0 commit comments

Comments
 (0)