-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
Overview
In the CDP SDK EVM client, some methods accept a network parameter. When network is omitted, undefined, or accidentally passed as an empty string, the SDK may proceed and fail later (or fall back to an implicit default) with an unclear error. This makes misconfiguration hard to diagnose and can cause transactions or account actions to target an unintended network.
Problem Description
Developers often build wrappers around the SDK and pass network through multiple layers. A missing value can occur due to:
- environment variable not set
- conditional branching that skips assignment
- serialization/deserialization issues in serverless setups
Without upfront validation, errors appear downstream (RPC failures, unexpected chain IDs, or ambiguous “bad request” errors).
Expected Behavior
- If
networkis required for an operation, the SDK should fail fast when it is missing/empty. - Error messages should clearly state that
networkis missing and list valid options. - No request (RPC/API) should be made when required inputs are invalid.
Steps to reproduce
- Create a CDP client and call an EVM method with
network: undefined(or omit the field). - Observe that the SDK attempts to proceed instead of throwing a clear validation error.
Example code
```ts
import { CdpClient } from "@coinbase/cdp-sdk";
async function run() {
const cdp = new CdpClient({ apiKey: process.env.CDP_API_KEY! });
// network accidentally omitted / undefined
await cdp.evm.sendTransaction({
network: undefined as any,
to: "0x0000000000000000000000000000000000000000",
value: "0",
data: "0x",
});
}
run().catch(console.error);
Proposed Solution
- Add a shared input validator for EVM client methods that require network.
- Reject undefined, empty strings, and unknown values with a descriptive error.
- Consider narrowing TypeScript types so network cannot be omitted where it is required.
Metadata
Metadata
Assignees
Labels
No labels