Skip to content

Commit 8761fe6

Browse files
committed
Process deploy param ref only when non-empty (#5730)
PROT-935 <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the handling of `implementationConstructorParams` and `initializeParams` by adding null checks to ensure that they are defined before processing. This improves the robustness of the code. ### Detailed summary - Changed `processedImplParams` and `processedInitializeParams` from constants to `undefined` initially. - Added checks to confirm that `implementationConstructorParams` and `initializeParams` are defined before processing. - Retained the logic for processing parameters using `processRefDeployments`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 77c8d0e commit 8761fe6

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

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

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,28 +150,35 @@ export async function deployContractfromDeployMetadata(
150150
salt,
151151
} = options;
152152

153-
const processedImplParams: Record<string, string | string[]> = {};
154-
for (const key in implementationConstructorParams) {
155-
processedImplParams[key] = await processRefDeployments({
156-
client,
157-
account,
158-
chain,
159-
paramValue: implementationConstructorParams[key] as
160-
| string
161-
| ImplementationConstructorParam,
162-
});
153+
let processedImplParams: Record<string, string | string[]> | undefined;
154+
let processedInitializeParams: Record<string, string | string[]> | undefined;
155+
156+
if (implementationConstructorParams) {
157+
processedImplParams = {};
158+
for (const key in implementationConstructorParams) {
159+
processedImplParams[key] = await processRefDeployments({
160+
client,
161+
account,
162+
chain,
163+
paramValue: implementationConstructorParams[key] as
164+
| string
165+
| ImplementationConstructorParam,
166+
});
167+
}
163168
}
164169

165-
const processedInitializeParams: Record<string, string | string[]> = {};
166-
for (const key in initializeParams) {
167-
processedInitializeParams[key] = await processRefDeployments({
168-
client,
169-
account,
170-
chain,
171-
paramValue: initializeParams[key] as
172-
| string
173-
| ImplementationConstructorParam,
174-
});
170+
if (initializeParams) {
171+
processedInitializeParams = {};
172+
for (const key in initializeParams) {
173+
processedInitializeParams[key] = await processRefDeployments({
174+
client,
175+
account,
176+
chain,
177+
paramValue: initializeParams[key] as
178+
| string
179+
| ImplementationConstructorParam,
180+
});
181+
}
175182
}
176183

177184
switch (deployMetadata?.deployType) {

0 commit comments

Comments
 (0)