Skip to content

Commit 9bbc7e9

Browse files
sirtimidclaude
andcommitted
refactor(ocap-kernel): use ifDefined utility in RPC handler
Replace inline Object.fromEntries filter with the existing ifDefined utility from @metamask/kernel-utils, as suggested in PR review. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent db629f9 commit 9bbc7e9

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

packages/ocap-kernel/src/rpc/kernel-control/init-remote-comms.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { MethodSpec, Handler } from '@metamask/kernel-rpc-methods';
2+
import { ifDefined } from '@metamask/kernel-utils';
23
import {
34
object,
45
literal,
@@ -59,13 +60,11 @@ export const initRemoteCommsHandler: Handler<
5960
...initRemoteCommsSpec,
6061
hooks: { kernel: true },
6162
implementation: async ({ kernel }, params): Promise<null> => {
62-
// Build options from only the defined RPC params. Superstruct has
63-
// already validated the shape; stripping undefined keeps the bag sparse.
64-
// Note: sensitive fields like `mnemonic` and internal fields like
65-
// `directTransports` are intentionally excluded from the RPC struct.
66-
const options: RemoteCommsOptions = Object.fromEntries(
67-
Object.entries(params).filter(([, value]) => value !== undefined),
68-
);
63+
// Strip undefined values so the options bag is sparse. Superstruct has
64+
// already validated the shape. Sensitive fields like `mnemonic` and
65+
// internal fields like `directTransports` are intentionally excluded
66+
// from the RPC struct.
67+
const options: RemoteCommsOptions = ifDefined(params);
6968
await kernel.initRemoteComms(options);
7069
return null;
7170
},

0 commit comments

Comments
 (0)