Skip to content

Commit ceba683

Browse files
committed
SDK: Fix process not defined error in Vite (#8280)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR addresses a `process not defined` error that occurs when using the `thirdweb/contract` import in Vite by ensuring that the `process` variable is only accessed when it is defined. ### Detailed summary - Updated `PUBLISHED_PRIVATE_KEY` export in `packages/thirdweb/src/utils/any-evm/zksync/constants.ts` to check if `process` is defined before accessing `process.env.ZKSYNC_PUBLISHED_PRIVATE_KEY`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Improved robustness of environment configuration handling to avoid runtime issues in non-Node environments. - **Bug Fixes** - Fixed a "process not defined" error that could occur when importing the library in Vite, included in a patch release. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent b33c1a3 commit ceba683

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.changeset/small-taxes-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix process not defined error when using "thirdweb/contract" import in Vite

packages/thirdweb/src/utils/any-evm/zksync/constants.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ export const ZKSYNC_SINGLETON_FACTORY =
33
export const CONTRACT_DEPLOYER_ADDRESS =
44
"0x0000000000000000000000000000000000008006" as const;
55
export const KNOWN_CODES_STORAGE = "0x0000000000000000000000000000000000008004";
6-
export const PUBLISHED_PRIVATE_KEY = process
7-
? process.env.ZKSYNC_PUBLISHED_PRIVATE_KEY
8-
: undefined;
6+
export const PUBLISHED_PRIVATE_KEY =
7+
typeof process !== "undefined" && process && process.env
8+
? process.env.ZKSYNC_PUBLISHED_PRIVATE_KEY
9+
: undefined;
910

1011
export const singletonFactoryAbi = [
1112
"function deploy(bytes32,bytes32,bytes) external payable",

0 commit comments

Comments
 (0)