Skip to content

Commit

Permalink
use new recursive normalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistevam committed Jan 15, 2025
1 parent 9bd8988 commit 6ff387b
Show file tree
Hide file tree
Showing 11 changed files with 715 additions and 639 deletions.
32 changes: 24 additions & 8 deletions app/scripts/lib/ppom/ppom-util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ const SIGN_TYPED_DATA_PARAMS_MOCK_2 = {
extraField: 'should be removed',
test: { field: 'value' },
},
a: {
a: {
a: {
a: {
a: {
a: {
a: {
a: {
a: {
a: {
a: {
a: {},
},
},
},
},
},
},
},
},
},
},
},
},
};

Expand Down Expand Up @@ -327,14 +350,7 @@ describe('PPOM Utils', () => {
JSON.stringify({
...SIGN_TYPED_DATA_PARAMS_MOCK_2,
message: {
value: {
root: {
value:
'0xbb50db86866daf83b8142fb53a50e4173c67f57330f24654ab7b110c484c8918',
type: 'bytes32',
},
},
type: 'Root',
root: '0xbb50db86866daf83b8142fb53a50e4173c67f57330f24654ab7b110c484c8918',
},
}),
],
Expand Down
25 changes: 8 additions & 17 deletions app/scripts/lib/ppom/ppom-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import {
} from '../../../../shared/constants/security-provider';
import { SIGNING_METHODS } from '../../../../shared/constants/transaction';
import { AppStateController } from '../../controllers/app-state-controller';
import {
// sanitizeMessage,
sanitizeMessageRecursively,
} from '../../../../shared/modules/typed-signature';
import { sanitizeMessageRecursively } from '../../../../shared/modules/typed-signature';
import { parseTypedDataMessage } from '../../../../shared/modules/transaction.utils';
import { SecurityAlertResponse, UpdateSecurityAlertResponse } from './types';
import {
Expand Down Expand Up @@ -197,28 +194,22 @@ function sanitizeRequest(request: JsonRpcRequest): JsonRpcRequest {
request.method === METHOD_SIGN_TYPED_DATA_V3
) {
if (Array.isArray(request.params) && request.params[1]) {
// console.log('>>>>>>>> ', request.params[1].toString());
const typedMessage = parseTypedDataMessage(request.params[1].toString());
// const sanitizedMessage = sanitizeMessage(
// typedMessage.message,
// typedMessage.primaryType,
// typedMessage.types,
// );
const typedDataMessage = parseTypedDataMessage(
request.params[1].toString(),
);

const sanitizedMessageRecursively = sanitizeMessageRecursively(
typedMessage.message,
typedMessage.primaryType,
typedMessage.types,
typedDataMessage.message,
typedDataMessage.types,
typedDataMessage.primaryType,
);

// console.log('>>>>>>>> ', sanitizedMessageRecursively);

return {
...request,
params: [
request.params[0],
JSON.stringify({
...typedMessage,
...typedDataMessage,
message: sanitizedMessageRecursively,
}),
],
Expand Down
Loading

0 comments on commit 6ff387b

Please sign in to comment.