Skip to content

chore: narrow findByIds and fetchNewTransactionsForAccount types#251

Merged
ulissesferreira merged 1 commit into
mainfrom
chore/narrow-findbyids-types
Mar 23, 2026
Merged

chore: narrow findByIds and fetchNewTransactionsForAccount types#251
ulissesferreira merged 1 commit into
mainfrom
chore/narrow-findbyids-types

Conversation

@ulissesferreira

Copy link
Copy Markdown
Contributor

Summary

  • AccountsRepository.findByIds / AccountsService.findByIds now return TronKeyringAccount[] (never null); missing IDs are simply omitted from the result.
  • TransactionsService.fetchNewTransactionsForAccount accepts TronKeyringAccount instead of generic KeyringAccount; remove redundant cast when mapping transactions.
  • CronHandler: use accounts.length === 0 / accounts.length > 0 instead of falsy checks on findByIds results.
  • Rename ethAddresshexAddress where computeAddress output is converted for Tron.

Motivation

The previous | null return type was misleading (filter always produced an array). Narrowing types reduces impossible states and simplifies callers.

Test plan

  • yarn lint:fix
  • yarn test
  • yarn build:prod

No user-facing behavior change.

@ulissesferreira ulissesferreira force-pushed the chore/narrow-findbyids-types branch from 27c13b9 to 2622103 Compare March 23, 2026 15:37

@Julink-eth Julink-eth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

@ulissesferreira ulissesferreira merged commit 2298b1a into main Mar 23, 2026
11 checks passed
@ulissesferreira ulissesferreira deleted the chore/narrow-findbyids-types branch March 23, 2026 16:00
ulissesferreira added a commit that referenced this pull request Mar 23, 2026
## Summary

- Add optional `limit` to
`TrongridApiClient.getTransactionInfoByAddress` (passed as query param).
- Add `TransactionsService.checkAddressActivity(scope, address)` — uses
`limit: 1` to detect any history without downloading full pages.
- `discoverAccounts` uses `checkAddressActivity` instead of
`fetchNewTransactionsForAccount`.

## Motivation

Account discovery only needs to know if an address has ever been used; a
single-transaction probe is cheaper than a full incremental fetch.

## Dependencies

**Merge after**
[`chore/narrow-findByIds...`](#251)
(this branch is based on that commit). Rebase onto `main` after PR 251
lands if needed.

## Changelog

Updates `packages/snap/CHANGELOG.md` under **[Unreleased] → Changed**.

## Test plan

- [x] `yarn test` — includes `checkAddressActivity` true / false / error
propagation
- [x] `keyring` `discoverAccounts` tests mock `checkAddressActivity`
- [x] `yarn build:prod`
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.

2 participants