Skip to content

Commit cd7f779

Browse files
committed
salt for ref contract
1 parent 03c82b4 commit cd7f779

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

apps/dashboard/src/components/contract-components/contract-publish-form/ref-input.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,27 @@ export const RefContractInput: React.FC<RefContractInputProps> = ({
121121
</Select>
122122
</Skeleton>
123123
</FormControl>
124+
125+
<FormControl
126+
as={Flex}
127+
flexDir="column"
128+
gap={1}
129+
isInvalid={
130+
!!form.getFieldState(
131+
`constructorParams.${param.name ? param.name : "*"}.dynamicValue.refContracts.${index}.salt`,
132+
form.formState,
133+
).error
134+
}
135+
>
136+
<FormLabel textTransform="capitalize">Salt</FormLabel>
137+
<Input
138+
placeholder="Salt (optional)"
139+
{...form.register(
140+
`constructorParams.${param.name ? param.name : "*"}.dynamicValue.refContracts.${index}.salt`,
141+
)}
142+
/>
143+
</FormControl>
144+
124145
<IconButton
125146
icon={<Icon as={TrashIcon} boxSize={5} />}
126147
aria-label="Remove row"

packages/thirdweb/src/extensions/prebuilts/deploy-published.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ interface DynamicParams {
135135
publisherAddress: string;
136136
version: string;
137137
contractId: string;
138+
salt?: string;
138139
}[];
139140
}
140141

@@ -169,6 +170,10 @@ async function processRefDeployments(
169170
const contracts = dynamicValue.refContracts;
170171

171172
if (dynamicValue.type === "address") {
173+
const salt =
174+
contracts[0]?.salt && contracts[0]?.salt.length > 0
175+
? contracts[0]?.salt
176+
: undefined;
172177
// Call the fetchAndDeployContract function with the ref data
173178
const addr = await deployPublishedContract({
174179
client,
@@ -177,6 +182,7 @@ async function processRefDeployments(
177182
contractId: contracts[0]?.contractId as string,
178183
publisher: contracts[0]?.publisherAddress,
179184
version: contracts[0]?.version,
185+
salt,
180186
});
181187

182188
return addr;
@@ -186,6 +192,8 @@ async function processRefDeployments(
186192
const addressArray = [];
187193

188194
for (const c of contracts) {
195+
const salt = c?.salt && c?.salt.length > 0 ? c?.salt : undefined;
196+
189197
addressArray.push(
190198
await deployPublishedContract({
191199
client,
@@ -194,6 +202,7 @@ async function processRefDeployments(
194202
contractId: c.contractId,
195203
publisher: c.publisherAddress,
196204
version: c.version,
205+
salt,
197206
}),
198207
);
199208
}

packages/thirdweb/src/utils/any-evm/deploy-metadata.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,16 @@ type DynamicParams = {
167167
contractId: string;
168168
publisherAddress: string;
169169
version: string;
170+
salt?: string;
170171
}>;
171172

172173
// use for bytes
173174
decodedBytes?: Array<
174-
Record<
175-
string,
176-
{
177-
defaultValue?: string;
178-
dynamicValue?: DynamicParams; // can have address type which may need ref
179-
}
180-
>
175+
Array<{
176+
type: string;
177+
defaultValue?: string;
178+
dynamicValue?: DynamicParams; // can have address type which may need ref
179+
}>
181180
>;
182181
};
183182

0 commit comments

Comments
 (0)