From f85d9c0b76bd530fa034ba8623665fcc13ec23bf Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Thu, 6 Aug 2026 19:31:09 +0200 Subject: [PATCH 1/7] chore(tron-wallet-snap): add changelog entry --- packages/tron-wallet-snap/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/tron-wallet-snap/CHANGELOG.md b/packages/tron-wallet-snap/CHANGELOG.md index 4cc38345f..e8ad1094c 100644 --- a/packages/tron-wallet-snap/CHANGELOG.md +++ b/packages/tron-wallet-snap/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add Core messenger plumbing (`getMessenger`, `RemoteFeatureFlagsProvider`, `AssetsProvider`) for upcoming AssetsController migration ([#95](https://github.com/MetaMask/internal-snaps/pull/95)) +### Fixed + +- Scope `bip44:discover` activity checks and account creation to the networks declared in the snap manifest, preventing unnecessary calls to testnet APIs during discovery ([#XXX](https://github.com/MetaMask/internal-snaps/pull/XXX)) + ## [3.0.0] ### Added From ca10d337ed8524b6fa521bc495b1ca46cfa057d9 Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Thu, 6 Aug 2026 19:32:02 +0200 Subject: [PATCH 2/7] chore(tron-wallet-snap): update shasum --- packages/tron-wallet-snap/snap.manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tron-wallet-snap/snap.manifest.json b/packages/tron-wallet-snap/snap.manifest.json index 30ac1291a..fb598e459 100644 --- a/packages/tron-wallet-snap/snap.manifest.json +++ b/packages/tron-wallet-snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/internal-snaps.git" }, "source": { - "shasum": "B9kqmuUcYgPAD3ojseIm2HymqK77Q4NEzULU876+5Wc=", + "shasum": "EgEqYUc0rxfj1vJAqmTcC6MLOOmWDLhoace0dq+uehQ=", "location": { "npm": { "filePath": "dist/bundle.js", From 4749e4c9bd0b696a97c5d00549037b46e0848765 Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Thu, 6 Aug 2026 19:32:37 +0200 Subject: [PATCH 3/7] fix(tron-wallet-snap): use scopes from the snap manifest for discovery & account creation --- .../services/accounts/AccountsService.test.ts | 31 +++++++++---------- .../src/services/accounts/AccountsService.ts | 12 ++++--- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/packages/tron-wallet-snap/src/services/accounts/AccountsService.test.ts b/packages/tron-wallet-snap/src/services/accounts/AccountsService.test.ts index e8bdd0a74..7e755937e 100644 --- a/packages/tron-wallet-snap/src/services/accounts/AccountsService.test.ts +++ b/packages/tron-wallet-snap/src/services/accounts/AccountsService.test.ts @@ -12,7 +12,6 @@ import { AccountCreationType, KeyringEvent, TrxAccountType, - TrxScope, } from '@metamask/keyring-api'; import { emitSnapKeyringEvent, @@ -30,7 +29,7 @@ import type { ConfigProvider } from '../config'; import type { Config } from '../config/ConfigProvider'; import type { TransactionsService } from '../transactions/TransactionsService'; import type { AccountsRepository } from './AccountsRepository'; -import { AccountsService } from './AccountsService'; +import { AccountsService, SUPPORTED_SCOPES } from './AccountsService'; jest.mock('@metamask/keyring-snap-sdk', () => ({ emitSnapKeyringEvent: jest.fn(), @@ -333,7 +332,7 @@ describe('AccountsService', () => { derivationPath: "m/44'/195'/0'/0/0", index: 0, type: TrxAccountType.Eoa, - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES, methods: ['signMessage', 'signTransaction'], }); expect(result.id).toBeDefined(); @@ -483,7 +482,7 @@ describe('AccountsService', () => { index: 0, type: TrxAccountType.Eoa, address: 'TConcurrent0', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: {}, methods: ['signMessage', 'signTransaction'], }; @@ -516,7 +515,7 @@ describe('AccountsService', () => { index: 0, type: TrxAccountType.Eoa, address: 'TExisting0', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: {}, methods: ['signMessage', 'signTransaction'], }; @@ -527,7 +526,7 @@ describe('AccountsService', () => { index: 1, type: TrxAccountType.Eoa, address: 'TExisting1', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: {}, methods: ['signMessage', 'signTransaction'], }; @@ -636,9 +635,7 @@ describe('AccountsService', () => { mockAccountsRepository, mockTransactionsService, }) => { - mockTransactionsService.checkAddressActivity - .mockResolvedValueOnce(false) - .mockResolvedValueOnce(true); + mockTransactionsService.checkAddressActivity.mockResolvedValueOnce(true); const result = await accountsService.createAccounts({ type: AccountCreationType.Bip44Discover, @@ -673,7 +670,7 @@ describe('AccountsService', () => { index: 0, type: TrxAccountType.Eoa, address: 'TTestAddress1234567890123456789', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: { entropy: { type: 'mnemonic', @@ -716,7 +713,7 @@ describe('AccountsService', () => { index: 0, type: TrxAccountType.Eoa, address: 'TExistingDefault0', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: {}, methods: ['signMessage', 'signTransaction'], }; @@ -733,7 +730,7 @@ describe('AccountsService', () => { index: 1, type: TrxAccountType.Eoa, address: 'TDefaultCreate1', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: { entropy: { type: 'mnemonic', @@ -769,7 +766,7 @@ describe('AccountsService', () => { index: 0, type: TrxAccountType.Eoa, address: 'TExisting123456789012345678901', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: {}, methods: ['signMessage', 'signTransaction'], }; @@ -804,7 +801,7 @@ describe('AccountsService', () => { index: 0, type: TrxAccountType.Eoa, address: 'TRollback12345678901234567890', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: { entropy: { type: 'mnemonic', @@ -849,7 +846,7 @@ describe('AccountsService', () => { index: 0, type: TrxAccountType.Eoa, address: 'TRollback12345678901234567890', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: { entropy: { type: 'mnemonic', @@ -892,7 +889,7 @@ describe('AccountsService', () => { index: 0, type: TrxAccountType.Eoa, address: 'TMeta1234567890123456789012', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: {}, methods: ['signMessage', 'signTransaction'], }); @@ -921,7 +918,7 @@ describe('AccountsService', () => { index: 0, type: TrxAccountType.Eoa, address: 'TConflict12345678901234567890', - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: {}, methods: ['signMessage', 'signTransaction'], }; diff --git a/packages/tron-wallet-snap/src/services/accounts/AccountsService.ts b/packages/tron-wallet-snap/src/services/accounts/AccountsService.ts index 3d9bd1b71..3f2674fe8 100644 --- a/packages/tron-wallet-snap/src/services/accounts/AccountsService.ts +++ b/packages/tron-wallet-snap/src/services/accounts/AccountsService.ts @@ -9,7 +9,6 @@ import { assertCreateAccountOptionIsSupported, KeyringEvent, TrxAccountType, - TrxScope, } from '@metamask/keyring-api'; import { emitSnapKeyringEvent, @@ -21,6 +20,7 @@ import { hexToBytes } from '@metamask/utils'; import { computeAddress } from 'ethers'; import { TronWeb } from 'tronweb'; +import snapManifest from '../../../snap.manifest.json'; import type { SnapClient } from '../../clients/snap/SnapClient'; import { Network } from '../../constants'; import { asStrictKeyringAccount } from '../../entities/keyring-account'; @@ -47,6 +47,10 @@ const CURVE = 'secp256k1' as const; */ const MAX_BIP44_ACCOUNT_INDEX = 0x7fffffff; +export const SUPPORTED_SCOPES = snapManifest.initialPermissions[ + 'endowment:keyring' +].capabilities.scopes as readonly Network[]; + /** * Range of inclusive account indices to create. * @@ -217,7 +221,7 @@ export class AccountsService { index, type: TrxAccountType.Eoa, address, - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: { entropy: { type: 'mnemonic', @@ -357,7 +361,7 @@ export class AccountsService { index: groupIndex, }); const activityChecks = await Promise.all( - Object.values(Network).map((scope) => + SUPPORTED_SCOPES.map((scope) => this.#transactionsService.checkAddressActivity( scope, derivedAccount.address, @@ -418,7 +422,7 @@ export class AccountsService { index: groupIndex, type: TrxAccountType.Eoa, address, - scopes: [TrxScope.Mainnet, TrxScope.Nile, TrxScope.Shasta], + scopes: SUPPORTED_SCOPES as unknown as Network[], options: { entropy: { type: 'mnemonic', From 59ac551707c537fcef1dd7c9f56e9a12fd48b800 Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Thu, 6 Aug 2026 19:53:29 +0200 Subject: [PATCH 4/7] chore(tron-wallet-snap): add pr number to changelog entry --- packages/tron-wallet-snap/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tron-wallet-snap/CHANGELOG.md b/packages/tron-wallet-snap/CHANGELOG.md index e8ad1094c..2509a5c7a 100644 --- a/packages/tron-wallet-snap/CHANGELOG.md +++ b/packages/tron-wallet-snap/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Scope `bip44:discover` activity checks and account creation to the networks declared in the snap manifest, preventing unnecessary calls to testnet APIs during discovery ([#XXX](https://github.com/MetaMask/internal-snaps/pull/XXX)) +- Scope `bip44:discover` activity checks and account creation to the networks declared in the snap manifest, preventing unnecessary calls to testnet APIs during discovery ([#135](https://github.com/MetaMask/internal-snaps/pull/135)) ## [3.0.0] From f8d194bba4cd425ae80e987c501f6c3b3b128bd5 Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Fri, 7 Aug 2026 04:14:59 +0200 Subject: [PATCH 5/7] trigger ci From affaec5bdfc618f87de2f6163a73dfd10771ead4 Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Fri, 7 Aug 2026 04:18:06 +0200 Subject: [PATCH 6/7] chore(tron-wallet-snap): update shasum --- packages/tron-wallet-snap/snap.manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tron-wallet-snap/snap.manifest.json b/packages/tron-wallet-snap/snap.manifest.json index fb598e459..6a08ba2b5 100644 --- a/packages/tron-wallet-snap/snap.manifest.json +++ b/packages/tron-wallet-snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/internal-snaps.git" }, "source": { - "shasum": "EgEqYUc0rxfj1vJAqmTcC6MLOOmWDLhoace0dq+uehQ=", + "shasum": "C13HWdtafD3wHLxY5EH6CQlnUuu8RQoe1YcaTX+P+rE=", "location": { "npm": { "filePath": "dist/bundle.js", From 563752ca1931ec77df98e7a769999daae98821b0 Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Fri, 7 Aug 2026 04:18:56 +0200 Subject: [PATCH 7/7] fix(tron-wallet-snap): lint fix --- .../src/services/accounts/AccountsService.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/tron-wallet-snap/src/services/accounts/AccountsService.test.ts b/packages/tron-wallet-snap/src/services/accounts/AccountsService.test.ts index 7e755937e..d9b467ad1 100644 --- a/packages/tron-wallet-snap/src/services/accounts/AccountsService.test.ts +++ b/packages/tron-wallet-snap/src/services/accounts/AccountsService.test.ts @@ -635,7 +635,9 @@ describe('AccountsService', () => { mockAccountsRepository, mockTransactionsService, }) => { - mockTransactionsService.checkAddressActivity.mockResolvedValueOnce(true); + mockTransactionsService.checkAddressActivity.mockResolvedValueOnce( + true, + ); const result = await accountsService.createAccounts({ type: AccountCreationType.Bip44Discover,