-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathRelayerV2ResultUserDecrypt.ts
More file actions
43 lines (41 loc) · 1.48 KB
/
RelayerV2ResultUserDecrypt.ts
File metadata and controls
43 lines (41 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import type { RelayerV2ResultUserDecrypt } from '../types';
import {
assertRecordBytesHexNo0xProperty,
assertRecordBytesHexProperty,
} from '@base/bytes';
import { assertRecordArrayProperty } from '@base/record';
/**
* Assertion function that validates a value is a valid `RelayerV2ResultUserDecrypt` object.
* Validates the structure returned from the relayer for user decryption operations.
* Throws an `InvalidPropertyError` if validation fails.
*
* @param value - The value to validate (can be any type)
* @param name - The name of the value being validated (used in error messages)
* @throws {InvalidPropertyError} When any required property is missing or has an invalid format
* @throws {never} No other errors are thrown
*/
export function assertIsRelayerV2ResultUserDecrypt(
value: unknown,
name: string,
): asserts value is RelayerV2ResultUserDecrypt {
type T = RelayerV2ResultUserDecrypt;
type ResultItem = T['result'][number];
assertRecordArrayProperty(value, 'result' satisfies keyof T, name);
for (let i = 0; i < value.result.length; ++i) {
assertRecordBytesHexNo0xProperty(
value.result[i],
'payload' satisfies keyof ResultItem,
`${name}.result[${i}]`,
);
assertRecordBytesHexNo0xProperty(
value.result[i],
'signature' satisfies keyof ResultItem,
`${name}.result[${i}]`,
);
assertRecordBytesHexProperty(
value.result[i],
'extraData' satisfies keyof ResultItem,
`${name}.result[${i}]`,
);
}
}