Skip to content

Commit d3139b2

Browse files
committed
[SDK] Fix: Remove and Prevent console.log (#5527)
CNCT-2483 <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on removing `console.log` statements from various files to clean up the code and improve maintainability. It also modifies the linter configuration to adjust rules related to console usage. ### Detailed summary - Removed `console.log` statements from multiple test and implementation files. - Adjusted linter configuration to allow specific console warnings only. - Updated `biome.json` to include new linter rules for console usage. - Cleaned up unused imports related to `DEBUG` constants. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent cedd9c8 commit d3139b2

File tree

10 files changed

+28
-55
lines changed

10 files changed

+28
-55
lines changed

packages/thirdweb/biome.json

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,39 @@
55
"rules": {
66
"nursery": {
77
"noProcessEnv": "warn"
8+
},
9+
"suspicious": {
10+
"noConsole": {
11+
"level": "error",
12+
"options": {
13+
"allow": ["error", "warn"]
14+
}
15+
}
816
}
917
}
1018
},
11-
"overrides": [{
12-
"include": ["src/**/*.test.ts","src/**/*.test.tsx", "src/stories/**"],
13-
"linter": {
14-
"rules": {
15-
"nursery": {
16-
"noProcessEnv": "off"
19+
"overrides": [
20+
{
21+
"include": ["src/**/*.test.ts", "src/**/*.test.tsx", "src/stories/**"],
22+
"linter": {
23+
"rules": {
24+
"nursery": {
25+
"noProcessEnv": "off"
26+
}
27+
}
28+
}
29+
},
30+
{
31+
"include": ["src/cli/bin.ts", "src/cli/commands/**"],
32+
"linter": {
33+
"rules": {
34+
"suspicious": {
35+
"noConsole": "off"
36+
}
1737
}
1838
}
1939
}
20-
}],
40+
],
2141
"files": {
2242
"ignore": [
2343
"src/crypto/aes/lib/md5.ts",

packages/thirdweb/src/contract/deployment/zksync/zkDeployDeterministic.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ export async function zkDeployContractDeterministic(
7979
});
8080
}
8181

82-
console.log(
83-
`deploying contract via create2 factory at: ${predictedAddress}`,
84-
);
85-
8682
// deploy with create2 factory
8783
const factory = getContract({
8884
address: create2FactoryAddress,

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,9 @@ type BuyScreenContentProps = {
156156
*/
157157
function BuyScreenContent(props: BuyScreenContentProps) {
158158
const { client, supportedDestinations, connectLocale, payOptions } = props;
159-
console.log("BuyScreenContent");
160159

161160
const activeAccount = useActiveAccount();
162161
const { payer, setPayer } = usePayerSetup();
163-
console.log("payer", payer);
164162

165163
const [screen, setScreen] = useState<SelectedScreen>({
166164
id: "main",
@@ -498,8 +496,6 @@ function BuyScreenContent(props: BuyScreenContentProps) {
498496
);
499497
}
500498

501-
console.log("SCREEN", screen.id);
502-
503499
return (
504500
<Container animate="fadein">
505501
<div>

packages/thirdweb/src/storage/upload/mobile.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ export async function uploadBatchMobile(
4343
);
4444
}, 30000);
4545

46-
xhr.upload.addEventListener("loadstart", () => {
47-
console.log(`[${Date.now()}] [IPFS] Started`);
48-
});
49-
5046
xhr.upload.addEventListener("progress", (event) => {
51-
console.log(`[IPFS] Progress Event ${event.loaded}/${event.total}`);
52-
5347
clearTimeout(timer);
5448

5549
if (event.loaded < event.total) {
@@ -61,15 +55,10 @@ export async function uploadBatchMobile(
6155
),
6256
);
6357
}, 30000);
64-
} else {
65-
console.log(
66-
`[${Date.now()}] [IPFS] Uploaded files. Waiting for response.`,
67-
);
6858
}
6959
});
7060

7161
xhr.addEventListener("load", () => {
72-
console.log(`[${Date.now()}] [IPFS] Load`);
7362
clearTimeout(timer);
7463

7564
if (xhr.status >= 200 && xhr.status < 300) {
@@ -102,7 +91,6 @@ export async function uploadBatchMobile(
10291
});
10392

10493
xhr.addEventListener("error", () => {
105-
console.log("[IPFS] Load");
10694
clearTimeout(timer);
10795

10896
if (

packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ describe("sendEip712Transaction", () => {
4949
platformFeeRecipient: TEST_ACCOUNT_A.address, // platformFeeRecipient
5050
},
5151
});
52-
console.log("deployed address", address);
5352
expect(address).toBeDefined();
5453
expect(address.length).toBe(42);
5554
});

packages/thirdweb/src/wallets/smart/lib/bundler.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
formatUserOperationReceipt,
1818
} from "../types.js";
1919
import {
20-
DEBUG,
2120
ENTRYPOINT_ADDRESS_v0_6,
2221
MANAGED_ACCOUNT_GAS_BUFFER,
2322
getDefaultBundlerUrl,
@@ -267,10 +266,6 @@ async function sendBundlerRequest(args: {
267266
}) {
268267
const { options, operation, params } = args;
269268

270-
if (DEBUG) {
271-
console.debug(`>>> sending ${operation} with payload:`, params);
272-
}
273-
274269
const bundlerUrl = options.bundlerUrl ?? getDefaultBundlerUrl(options.chain);
275270
const fetchWithHeaders = getClientFetch(options.client);
276271
const response = await fetchWithHeaders(bundlerUrl, {
@@ -301,9 +296,5 @@ Code: ${code}`,
301296
);
302297
}
303298

304-
if (DEBUG) {
305-
console.debug(`<<< ${operation} result:`, res);
306-
}
307-
308299
return res.result;
309300
}

packages/thirdweb/src/wallets/smart/lib/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import type { Chain } from "../../../chains/types.js";
22
import { getAddress } from "../../../utils/address.js";
33
import { getThirdwebDomains } from "../../../utils/domains.js";
44

5-
// dev only
6-
export const DEBUG = false;
7-
85
export const DUMMY_SIGNATURE =
96
"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
107

packages/thirdweb/src/wallets/smart/lib/paymaster.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import type {
88
UserOperationV06,
99
UserOperationV07,
1010
} from "../types.js";
11-
import {
12-
DEBUG,
13-
ENTRYPOINT_ADDRESS_v0_6,
14-
getDefaultBundlerUrl,
15-
} from "./constants.js";
11+
import { ENTRYPOINT_ADDRESS_v0_6, getDefaultBundlerUrl } from "./constants.js";
1612
import { hexlifyUserOp } from "./utils.js";
1713

1814
/**
@@ -80,10 +76,6 @@ Code: ${code}`,
8076
);
8177
}
8278

83-
if (DEBUG) {
84-
console.debug("Paymaster result:", res);
85-
}
86-
8779
if (res.result) {
8880
// some paymasters return a string, some return an object with more data
8981
if (typeof res.result === "string") {

packages/thirdweb/src/wallets/smart/smart-wallet-dev.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,10 @@ describe.runIf(process.env.TW_SECRET_KEY).skip.sequential(
7777
to: smartAccount.address,
7878
value: 0n,
7979
});
80-
81-
console.log("Sending transaction...");
8280
const receipt = await sendTransaction({
8381
transaction: tx,
8482
account: smartAccount,
8583
});
86-
console.log("Transaction sent:", receipt.transactionHash);
8784
expect(receipt.transactionHash).toBeDefined();
8885
});
8986

@@ -127,7 +124,6 @@ describe.runIf(process.env.TW_SECRET_KEY).skip.sequential(
127124
platformFeeRecipient: smartAccount.address, // platformFeeRecipient
128125
},
129126
});
130-
console.log("deployed address", address);
131127
expect(address).toBeDefined();
132128
expect(address.length).toBe(42);
133129
});

packages/thirdweb/src/wallets/smart/smart-wallet-zksync.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ describe.runIf(process.env.TW_SECRET_KEY).todo(
145145
}),
146146
account: account,
147147
});
148-
console.log(tx.transactionHash);
149148
expect(tx.transactionHash.length).toBe(66);
150149
});
151150

@@ -168,7 +167,6 @@ describe.runIf(process.env.TW_SECRET_KEY).todo(
168167
}),
169168
account: account,
170169
});
171-
console.log(tx.transactionHash);
172170
expect(tx.transactionHash.length).toBe(66);
173171
});
174172
},

0 commit comments

Comments
 (0)