Repository navigation
feat(sentinel-api-service): add getNetwork method - #10676
Merged
Merged
Conversation
This was referenced Oct 5, 2026
matthewwalsh0
marked this pull request as ready for review
October 5, 2026 15:59
rarquevaux
approved these changes
Oct 5, 2026
| * How long the single network configuration (`/network`) response is | ||
| * considered fresh. The configuration is stable, so caching it avoids | ||
| * re-fetching on every request. | ||
| */ |
Contributor
There was a problem hiding this comment.
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.
Member
Author
There was a problem hiding this comment.
The cache invalidates after 5 minutes so any property can still be configured remotely and live after that timeframe 👍
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
SentinelApiServiceonly exposes the/networksregistry, so consumers can only read a chain's flags from that list. Sentinel also serves a per-network/networkendpoint that returns the full configuration for one chain, includingcubistSignersandsimulationIncludeFees.getNetwork(chainId)and theSentinelApiService:getNetworkaction. They look up the chain's subdomain in the registry, then fetch and validate its/networkconfiguration, caching responses for 5 minutes per chain.SentinelChainNotSupportedErrorif the chain is not in the registry.cubistSignersandsimulationIncludeFeesproperties returned by the API toSentinelNetwork.References
Checklist
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)andSentinelApiService:getNetworkso 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 throwSentinelChainNotSupportedError.SentinelNetworkand validation now includecubistSignersandsimulationIncludeFees. The former private registry lookup#getNetworkis renamed#getRegistryEntryso it doesn’t clash with the new public API. Tests cover caching, staleness, auth headers, and messenger invocation;getNetworksgains 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.