@exodus/web3-ethereum 12.21.3 → 12.22.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { InvalidInputError } from '@exodus/web3-errors';
2
2
  import { parseAndValidateTypedData as _parseAndValidateTypedData } from './validator.js';
3
+ import { validateSeaportMessage as _validateSeaportMessage } from './validator.js';
3
4
  export function convertChainIdToHex(chainId) {
4
5
  if (typeof chainId !== 'string') {
5
6
  throw new Error(`'chainId' should be a string, got: ${typeof chainId}`);
@@ -26,18 +27,15 @@ export function parseAndValidateTypedData(typedData, { chainId: activeChainId })
26
27
  }
27
28
  const allowedFieldsSet = new Set(parsedTypedData.types[parsedTypedData.primaryType].map(({ name }) => name));
28
29
  // Handle cases where the message includes fields that doesn't belong to the primary type.
29
- const isFieldExempted = (field) => {
30
+ if (parsedTypedData.primaryType === 'OrderComponents') {
30
31
  // Handle OpenSea case. See: https://github.com/status-im/status-mobile/issues/13769
31
- if (field === 'totalOriginalConsiderationItems' &&
32
- parsedTypedData.primaryType === 'OrderComponents' &&
33
- parsedTypedData.message['consideration']) {
34
- return true;
35
- }
36
- return false;
37
- };
38
- for (const field in parsedTypedData.message) {
39
- if (!allowedFieldsSet.has(field) && !isFieldExempted(field)) {
40
- throw new InvalidInputError(`field '${field}' is not defined in the primary type definition`);
32
+ _validateSeaportMessage(parsedTypedData.message);
33
+ }
34
+ else {
35
+ for (const field in parsedTypedData.message) {
36
+ if (!allowedFieldsSet.has(field)) {
37
+ throw new InvalidInputError(`field '${field}' is not defined in the primary type definition`);
38
+ }
41
39
  }
42
40
  }
43
41
  // Security: checking if the requested chain matches the active chain ID.
@@ -1,3 +1,4 @@
1
1
  import type { UnknownFunction } from '@exodus/web3-types';
2
2
  export declare const validateRequest: UnknownFunction;
3
3
  export declare const parseAndValidateTypedData: UnknownFunction;
4
+ export declare const validateSeaportMessage: UnknownFunction;