Skip to content

chore(js-ts): Convert transaction reducer and action module to TypeScript#968

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
chore/js-ts-transaction-reducer-561
Open

chore(js-ts): Convert transaction reducer and action module to TypeScript#968
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
chore/js-ts-transaction-reducer-561

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Workstream 4: types the transaction reducer + its action module and removes transaction: any from RootState.

The reducer state is modeled to match the transactionState shape already declared in app/core/GasPolling/types.ts (the de-facto consumer contract). Key modeling decision: the nested transaction object mixes representations — getTxData() produces BN amounts while callers like setTransactionValue(maxTransactionValueHex) and dappTransactions pass hex string/BN — so amount fields are typed string | BN:

export interface TransactionObject {
  data?: string; from?: string; to?: string;
  gas?: string | BN; gasPrice?: string | BN; value?: string | BN;
  maxFeePerGas?: string | BN; maxPriorityFeePerGas?: string | BN;
}
export interface TransactionState {
  selectedAsset: SelectedAsset;            // Record<string, unknown>
  transaction: TransactionObject;
  securityAlertResponses: Record<string, SecurityAlertResponse>;
  useMax: boolean; /* ...optional metadata fields... */
}

SecurityAlertResponse is imported from BlockaidBanner.types (not @metamask/transaction-controller) because that is the type the consumers (TransactionBlockaidBanner, ppom-util, confirmTransaction selector) actually use.

Action module now exports a discriminated-union TransactionAction (incl. a RehydrateAction so the REHYDRATE case type-checks) with typed creators.

Cascade fixes (consumers previously hidden behind any)

  • selectors/confirmTransaction.ts: guard id === undefined before indexing securityAlertResponses.
  • lib/ppom/ppom-util.ts: transactionId as string (matches existing cast in the same file).
  • AssetOverview.tsx / WalletActions.tsx: cast asset args to SelectedAsset (getEther() is JSDoc-typed object; TokenI needs as unknown as).
  • Test fixtures (AccountInfoCard, BrowserTab, Confirm, TransactionBlockaidBanner): align transaction mocks with the typed shape (selectedAsset: {}) or cast legacy-shaped fixtures.

Validation

  • yarn tsc — 0 errors
  • yarn lint (changed files) — 0 errors
  • yarn jest on reducer + all cascade-affected suites — 13 suites / 102 tests pass

Pre-existing fork CI failures (yarn install 404 on the dead aprock/react-native-tcp git dep, CLABot, label bots) are unrelated to this change.

Link to Devin session: https://app.devin.ai/sessions/150060d9c6a14a1b9ee04e5a407b3f8b
Requested by: @WesternConcrete


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Open in Devin Review (Staging)

Co-Authored-By: Wes Convery <2wconvery@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants