Skip to content

Commit

Permalink
fix: revert breaking change to requests with null ids (#26143) (#26814
Browse files Browse the repository at this point in the history
)

## **Description**

Fixes issue introduced by:
#26143,
#26626

- Revert breaking change to requests with `null` IDs handled by
`createDupeReqFilterStream`.
- Remove outdated yarn patch for `@trezor/connect-web@9.2.2`.
- Assign type for `getInitialSendStateWithExistingTxState` param.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26814?quickstart=1)

## **Related issues**

- #26143
- #26626

## **Manual testing steps**

## **Screenshots/Recordings**

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
MajorLift authored Sep 4, 2024
1 parent 97e0030 commit 9f07ef5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 50 deletions.
43 changes: 0 additions & 43 deletions .yarn/patches/@trezor-connect-web-npm-9.2.2-a4de8e45fc.patch

This file was deleted.

7 changes: 3 additions & 4 deletions app/scripts/lib/createDupeReqFilterStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const THREE_MINUTES = MINUTE * 3;
* @returns The expiry set.
*/
const makeExpirySet = () => {
const map: Map<string | number, number> = new Map();
const map: Map<string | number | null, number> = new Map();

setInterval(() => {
const cutoffTime = Date.now() - THREE_MINUTES;
Expand All @@ -32,7 +32,7 @@ const makeExpirySet = () => {
* @param value - The value to add.
* @returns `true` if the value was added, and `false` if it already existed.
*/
add(value: string | number) {
add(value: string | number | null) {
if (!map.has(value)) {
map.set(value, Date.now());
return true;
Expand All @@ -54,8 +54,7 @@ export default function createDupeReqFilterStream() {
transform(chunk: JsonRpcRequest, _, cb) {
// JSON-RPC notifications have no ids; our only recourse is to let them through.
const hasNoId = chunk.id === undefined;
const requestNotYetSeen =
chunk.id !== null && seenRequestIds.add(chunk.id);
const requestNotYetSeen = seenRequestIds.add(chunk.id);

if (hasNoId || requestNotYetSeen) {
cb(null, chunk);
Expand Down
7 changes: 4 additions & 3 deletions test/jest/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { KeyringTypes } from '@metamask/keyring-controller';
import { v4 as uuidv4 } from 'uuid';
import { keyringTypeToName } from '@metamask/accounts-controller';
import {
DraftTransaction,
draftTransactionInitialState,
initialState,
} from '../../ui/ducks/send';
Expand Down Expand Up @@ -133,9 +134,9 @@ export const INITIAL_SEND_STATE_FOR_EXISTING_DRAFT = {
},
};

// TODO: Define the type of draftTxState
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const getInitialSendStateWithExistingTxState = (draftTxState: any) => ({
export const getInitialSendStateWithExistingTxState = (
draftTxState: DraftTransaction & { test: string },
) => ({
...INITIAL_SEND_STATE_FOR_EXISTING_DRAFT,
draftTransactions: {
'test-uuid': {
Expand Down

0 comments on commit 9f07ef5

Please sign in to comment.