Skip to content

feat(sentinel-api-service): add getNetwork method - #10676

Merged
matthewwalsh0 merged 2 commits into
mainfrom
feat/sentinel-api-get-network
Oct 6, 2026
Merged

matthewwalsh0 merged 2 commits into
mainfrom
feat/sentinel-api-get-network

Conversation

@matthewwalsh0

@matthewwalsh0 matthewwalsh0 commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Explanation

SentinelApiService only exposes the /networks registry, so consumers can only read a chain's flags from that list. Sentinel also serves a per-network /network endpoint that returns the full configuration for one chain, including cubistSigners and simulationIncludeFees.

  • Adds getNetwork(chainId) and the SentinelApiService:getNetwork action. They look up the chain's subdomain in the registry, then fetch and validate its /network configuration, caching responses for 5 minutes per chain.
  • Throws SentinelChainNotSupportedError if the chain is not in the registry.
  • Adds the cubistSigners and simulationIncludeFees properties returned by the API to SentinelNetwork.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Additive API and types with caching and validation aligned to existing getNetworks; internal rename only affects private helpers.

Overview
Adds getNetwork(chainId) and SentinelApiService:getNetwork so clients can load per-chain Sentinel config from /network (not just capability flags from /networks). The service resolves the chain’s subdomain from the cached registry, validates the response, and caches it 5 minutes per chain; unsupported chains still throw SentinelChainNotSupportedError.

SentinelNetwork and validation now include cubistSigners and simulationIncludeFees. The former private registry lookup #getNetwork is renamed #getRegistryEntry so it doesn’t clash with the new public API. Tests cover caching, staleness, auth headers, and messenger invocation; getNetworks gains a stale-cache refetch test.

Reviewed by Cursor Bugbot for commit b34f4a1. Bugbot is set up for automated code reviews on this repo. Configure here.

* How long the single network configuration (`/network`) response is
* considered fresh. The configuration is stable, so caching it avoids
* re-fetching on every request.
*/

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.

Just a note to mention that there is one caveat to that which is smartTransaction. This one can be disabled by the backend (same for the newly added gasless flags). For now, it's still STX controller that fetches it separately under the "liveness" naming. I was planning to move that call to sentinel-api-service as well so not an issue here, just mentioning for context.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The cache invalidates after 5 minutes so any property can still be configured remotely and live after that timeframe 👍

@matthewwalsh0
matthewwalsh0 added this pull request to the merge queue Oct 6, 2026
Merged via the queue into main with commit a3cab98 Oct 6, 2026
52 checks passed
@matthewwalsh0
matthewwalsh0 deleted the feat/sentinel-api-get-network branch October 6, 2026 08:52
github-merge-queue Bot pushed a commit to MetaMask/metamask-extension that referenced this pull request Oct 14, 2026
## **Description**

The Sentinel utils (`sentinel-api.ts` and `transaction-relay.ts`) call
the Sentinel API directly, duplicating the URL building, auth headers
and caching that `SentinelApiService` already provides.

- The utils keep their existing exports and signatures, but call
`SentinelApiService` through a messenger that the service init registers
with `setSentinelApiMessenger`.
- Single-chain lookups (`getSentinelNetworkFlags`,
`isSendBundleSupported`, `isRelaySupported`) use `getNetwork`, which
caches the `/network` response for 5 minutes per chain.
`getSendBundleSupportedChains` uses `getNetworks`.
- Relay submission and status polling use `submitRelayTransaction` and
`getSmartTransaction`. The relay types are derived from the service
types.
- The `setSentinelApiAuth` wiring is removed, since the service handles
authentication.
- E2E Sentinel mocks now also cover the `/network` endpoint.

Depends on MetaMask/core#10676.
`@metamask/sentinel-api-service` needs bumping to a release that
includes `getNetwork` before this can merge, so type checks will fail
until then.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes:

Refs: MetaMask/core#10676

## **Manual testing steps**

1. On a chain that supports relay, submit an EIP-7702 transaction that
pays gas with a token, and confirm it submits and confirms.
2. On a chain that supports smart transactions, confirm smart
transactions and send bundle are still available.
3. On an unsupported chain, confirm the relay and send bundle options
are not offered.

## **Screenshots/Recordings**

### **Before**

### **After**

## **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/main/.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
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes how relay submission, smart-transaction polling, and chain
capability checks reach Sentinel (now via the centralized service),
which could affect EIP-7702 relay, send-bundle, and Shield sponsorship
paths if init or error handling diverges from the old direct HTTP
behavior.
> 
> **Overview**
> **Routes Sentinel network and relay traffic through
`SentinelApiService` instead of duplicating HTTP in extension utils.**
> 
> Legacy helpers in `sentinel-api.ts` and `transaction-relay.ts` keep
their public APIs but now call the service via a messenger registered at
`SentinelApiService` init (`setSentinelApiMessenger`). Network flags,
send-bundle checks, and cubist signers use `getNetwork` / `getNetworks`;
relay submit and smart-transaction polling use `submitRelayTransaction`
and `getSmartTransaction`. Direct fetch/JSON-RPC, URL building, and
`setSentinelApiAuth` in `MetaMaskController` are removed in favor of
service-owned auth and caching.
> 
> `@metamask/sentinel-api-service` is bumped to **^2.1.0** (needs
`getNetwork` from core). Unit tests mock the messenger; Shield
subscription tests mock `isSendBundleSupported`. E2E Sentinel mocks add
per-chain **`/network`** responses alongside `/networks`. LavaMoat
webpack policies are updated for the new dependency graph.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1ae1683. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Poovarasan-Sandhanam pushed a commit to Poovarasan-Sandhanam/metamask-mobile that referenced this pull request Oct 19, 2026
## **Description**

<!-- mms-check: type=text required=true -->

The Sentinel utils (`sentinel-api.ts` and `transaction-relay.ts`) call
the Sentinel API directly, duplicating the URL building, auth headers
and caching that `SentinelApiService` already provides.

- The utils keep their existing exports and signatures, but call
`SentinelApiService` through a messenger that the service init registers
with `setSentinelApiMessenger`. Errors keep the `Sentinel: ` prefix, and
unsupported chains still return `undefined`.
- Single-chain lookups (`getSentinelNetworkFlags`,
`isSendBundleSupported`, `isRelaySupported`) use `getNetwork`, which
caches the `/network` response for 5 minutes per chain.
`getSendBundleSupportedChains` uses `getNetworks`.
- Relay submission and status polling use `submitRelayTransaction` and
`getSmartTransaction`. The relay types are derived from the service
types.
- The Sentinel auth wiring in the smart transactions controller init is
removed, since the service handles authentication.
- The E2E and component-view Sentinel mocks now also cover the
`/network` endpoint. Component-view tests use a real
`SentinelApiService` instance.

Depends on MetaMask/core#10676.
`@metamask/sentinel-api-service` needs bumping to a release that
includes `getNetwork` before this can merge, so type checks will fail
until then.

## **Changelog**

<!-- mms-check: type=changelog required=true blocking=true -->

CHANGELOG entry: null

## **Related issues**

<!-- mms-check: type=issue-link required=true -->

Refs: MetaMask/core#10676

## **Manual testing steps**

<!-- mms-check: type=manual-testing required=true -->

```gherkin
Feature: Sentinel network lookups via SentinelApiService

  Scenario: user submits a gasless EIP-7702 transaction
    Given the selected chain supports transaction relay

    When user confirms a transaction paying gas with a token
    Then the transaction is relayed and confirms

  Scenario: user transacts on a smart transactions chain
    Given the selected chain supports smart transactions and send bundle

    When user opens a confirmation
    Then smart transaction and send bundle features remain available
```

## **Screenshots/Recordings**

<!-- mms-check: type=screenshot required=true -->

N/A

### **Before**

### **After**

## **Pre-merge author checklist**

<!-- mms-check: type=checklist required=true -->

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

#### Performance checks (if applicable)

- [ ] I've tested on Android
  - Ideally on a mid-range device; emulator is acceptable
- [ ] I've tested with a power user scenario
- Use these [power-user
SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example

For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches gasless relay, smart transactions, and send-bundle eligibility
paths; behavior should match the service but init order (messenger must
be set) and auth now depend on SentinelApiService.
> 
> **Overview**
> **Routes legacy Sentinel helpers through
`@metamask/sentinel-api-service` (^2.1.0)** instead of bespoke `fetch`,
URL building, in-memory network caching, and bearer-token header wiring.
> 
> `sentinel-api.ts` and `transaction-relay.ts` keep their public APIs
but call `SentinelApiService` via a messenger registered at init
(`setSentinelApiMessenger` in `sentinel-api-service-init`). Network
flags, send-bundle checks, relay submit, and smart-transaction polling
use `getNetwork` / `getNetworks` / `submitRelayTransaction` /
`getSmartTransaction`. **Sentinel auth setup is removed from
smart-transactions controller init** (the service owns auth).
> 
> Unit tests mock the messenger; **E2E and component-view mocks add
per-chain `/network` responses** and shared helpers
(`mockTxSentinelNetworks`, `setupSimulationEnabledNetworksMocks`).
Component-view tests spin up a real `SentinelApiService` with nock.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
5d2a8a6. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

This branch was successfully deployed

1 active deployment
default-branch — b34f4a1f Deployed Oct 5, 2026 by matthewwalsh0 via Determine whether this PR is a release PR #5133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants