Skip to content

Commit

Permalink
types(snaps-utils): Explicit type for CronjobRpcRequestStruct
Browse files Browse the repository at this point in the history
Lifted from dist
  • Loading branch information
legobeat committed Aug 30, 2023
1 parent a596bee commit 844a91c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/snaps-utils/src/cronjob.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Json } from '@metamask/utils';
import { JsonRpcRequestStruct } from '@metamask/utils';
import { parseExpression } from 'cron-parser';
import type { Infer } from 'superstruct';
import type { Infer, Struct } from 'superstruct';
import {
array,
assign,
Expand All @@ -15,7 +16,20 @@ import {
string,
} from 'superstruct';

export const CronjobRpcRequestStruct = assign(
export const CronjobRpcRequestStruct: Struct<
{
method: string;
params?: Record<string, Json> | Json[] | undefined;
id?: string | number | null | undefined;
jsonrpc?: '2.0' | undefined;
},
{
params: Struct<Record<string, Json> | Json[] | undefined, null>;
method: Struct<string, null>;
id: Struct<string | number | null | undefined>;
jsonrpc: Struct<'2.0' | undefined>;
}
> = assign(
partial(pick(JsonRpcRequestStruct, ['id', 'jsonrpc'])),
omit(JsonRpcRequestStruct, ['id', 'jsonrpc']),
);
Expand Down

0 comments on commit 844a91c

Please sign in to comment.