Skip to content

Commit

Permalink
Process deploy param ref only when non-empty (#5730)
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
kumaryash90 committed Dec 13, 2024
1 parent 77c8d0e commit 8761fe6
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions packages/thirdweb/src/extensions/prebuilts/deploy-published.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,35 @@ export async function deployContractfromDeployMetadata(
salt,
} = options;

const processedImplParams: Record<string, string | string[]> = {};
for (const key in implementationConstructorParams) {
processedImplParams[key] = await processRefDeployments({
client,
account,
chain,
paramValue: implementationConstructorParams[key] as
| string
| ImplementationConstructorParam,
});
let processedImplParams: Record<string, string | string[]> | undefined;
let processedInitializeParams: Record<string, string | string[]> | undefined;

if (implementationConstructorParams) {
processedImplParams = {};
for (const key in implementationConstructorParams) {
processedImplParams[key] = await processRefDeployments({
client,
account,
chain,
paramValue: implementationConstructorParams[key] as
| string
| ImplementationConstructorParam,
});
}
}

const processedInitializeParams: Record<string, string | string[]> = {};
for (const key in initializeParams) {
processedInitializeParams[key] = await processRefDeployments({
client,
account,
chain,
paramValue: initializeParams[key] as
| string
| ImplementationConstructorParam,
});
if (initializeParams) {
processedInitializeParams = {};
for (const key in initializeParams) {
processedInitializeParams[key] = await processRefDeployments({
client,
account,
chain,
paramValue: initializeParams[key] as
| string
| ImplementationConstructorParam,
});
}
}

switch (deployMetadata?.deployType) {
Expand Down

0 comments on commit 8761fe6

Please sign in to comment.