Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/solana-wallet-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Hardcode Solana fungible asset reads through `AssetsProvider` / `mapControllerAsset` (no migration-stage or remote feature-flag routing). Disable Snap fungible tracking in `fetch`/`save`/`saveMany` and account sync; Snap-owned NFT assets still use `SnapAssetsAdapter`.
- Remove Snap-owned asset tracking (`AssetsRepository`, `SnapAssetsAdapter`, `assetEntities` state). `AssetsService` now reads exclusively from `AssetsProvider` / `mapControllerAsset`.
- Hardcode Solana fungible asset reads through `AssetsProvider` / `mapControllerAsset` (no migration-stage or remote feature-flag routing).
- Wire Core messenger plumbing (`endowment:messenger`, `AssetsProvider`) into the Solana snap.
- Extract Snap-owned balance fetch/persist/read logic into `SnapAssetsAdapter`; `AssetsService` delegates account asset reads and saves through the adapter (no Core routing yet). ([#121](https://github.com/MetaMask/internal-snaps/pull/121))
- Align `AssetsService` read API with `snap-networks-utils` / AssetsController shapes by adding `getAccountAssetByID`, `getAccountAssetsByIDs`, `getAccountAssetsByScope`, and `getAccountAssetsForAllActiveScopes`, and routing Keyring, Send, send render, and `refreshSend` through them (still Snap-owned storage). ([#120](https://github.com/MetaMask/internal-snaps/pull/120))
Expand Down
2 changes: 1 addition & 1 deletion packages/solana-wallet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/internal-snaps.git"
},
"source": {
"shasum": "8pC/CUT1b2BVxIsPy6IWJQ8SMrFeW13nBhWeWKriNUs=",
"shasum": "0IUwopMf3Y3cIYkZa2ROWzoWPWQU0QI33uM0CW/g7A4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
accountsService,
assetsService,
configProvider,
priceApiClient,
state,
} from '../../../../snapContext';
Expand Down Expand Up @@ -43,10 +42,7 @@ jest.mock('../../../../snapContext', () => ({
getAll: jest.fn(),
},
assetsService: {
getAccountAssetsByScope: jest.fn(),
},
configProvider: {
getActiveNetworks: jest.fn(),
getAccountAssetsForAllActiveScopes: jest.fn(),
},
priceApiClient: {
getMultipleSpotPrices: jest.fn(),
Expand All @@ -65,10 +61,9 @@ const setupTest = () => {
(accountsService.getAll as jest.Mock).mockResolvedValue([
{ id: 'account-1' },
]);
(configProvider.getActiveNetworks as jest.Mock).mockResolvedValue([
'solana:mainnet',
]);
(assetsService.getAccountAssetsByScope as jest.Mock).mockResolvedValue([
(
assetsService.getAccountAssetsForAllActiveScopes as jest.Mock
).mockResolvedValue([
{
assetType: KnownCaip19Id.SolMainnet,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { DEFAULT_SEND_CONTEXT } from '../../../../features/send/render';
import { Send } from '../../../../features/send/Send';
import type { SendContext } from '../../../../features/send/types';
import {
accountsService,
assetsService,
configProvider,
priceApiClient,
state,
accountsService,
} from '../../../../snapContext';
import type { UnencryptedStateValue } from '../../../services/state/State';
import { trackError } from '../../../utils/errors';
Expand All @@ -25,10 +24,9 @@ export const refreshSend: OnCronjobHandler = async () => {

logger.info(`Background event triggered`);

const [accounts, activeNetworks, mapInterfaceNameToId, preferences] =
const [keyringAccounts, mapInterfaceNameToId, preferences] =
await Promise.all([
accountsService.getAll(),
configProvider.getActiveNetworks(),
state.getKey<UnencryptedStateValue['mapInterfaceNameToId']>(
'mapInterfaceNameToId',
),
Expand All @@ -37,10 +35,8 @@ export const refreshSend: OnCronjobHandler = async () => {

const assets = (
await Promise.all(
accounts.flatMap((account) =>
activeNetworks.map((network) =>
assetsService.getAccountAssetsByScope(network, account.id),
),
keyringAccounts.map((account) =>
assetsService.getAccountAssetsForAllActiveScopes(account.id),
),
)
).flat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,8 @@ describe('SolanaKeyring', () => {
});

mockAssetsService = {
fetch: jest.fn().mockResolvedValue(MOCK_ASSET_ENTITIES),
saveMany: jest.fn(),
getAccountAssetsForAllActiveScopes: jest.fn(),
getAccountAssetsByIDs: jest.fn(),
getNativeAssetTypes: jest
.fn()
.mockReturnValue([KnownCaip19Id.SolMainnet]),
} as unknown as AssetsService;

mockWalletService = {
Expand Down Expand Up @@ -349,7 +344,7 @@ describe('SolanaKeyring', () => {
} as unknown as AssetEntity;

jest.spyOn(mockAssetsService, 'getAccountAssetsByIDs').mockResolvedValue({
[KnownCaip19Id.SolMainnet]: invalidAsset,
[invalidAsset.assetType]: invalidAsset,
});

await expect(
Expand Down

This file was deleted.

Loading
Loading