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: 3 additions & 0 deletions packages/solana-wallet-snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@
},
"devDependencies": {
"@jest/globals": "^29.5.0",
"@metamask/assets-controller": "^13.0.0",
"@metamask/auto-changelog": "^6.1.1",
"@metamask/key-tree": "^10.1.1",
"@metamask/keyring-api": "^24.1.0",
"@metamask/keyring-snap-sdk": "^10.0.0",
"@metamask/messenger": "^2.0.0",
"@metamask/remote-feature-flag-controller": "^5.0.0",
"@metamask/snap-networks-utils": "^1.0.0",
"@metamask/snaps-cli": "^8.4.1",
"@metamask/snaps-jest": "^10.2.1",
Expand Down
10 changes: 9 additions & 1 deletion packages/solana-wallet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@
"snap_manageAccounts": {},
"snap_manageState": {},
"snap_dialog": {},
"snap_getPreferences": {}
"snap_getPreferences": {},
"endowment:messenger": {
"actions": [
"RemoteFeatureFlagController:getState",
"AssetsController:getAccountAssetByID",
"AssetsController:getAccountAssetsByIDs",
"AssetsController:getAccountAssetsByScope"
]
}
},
"platformVersion": "12.0.1",
"manifestVersion": "0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type { AccountsService } from '../accounts/AccountsService';
import type { ConfigProvider } from '../config';
import type { SolanaConnection } from '../connection';
import type { TokenPricesService } from '../token-prices/TokenPrices';
import { CoreAssetsAdapter } from './adapters/CoreAssetsAdapter';
import { SnapAssetsAdapter } from './adapters/SnapAssetsAdapter';
import type { AssetsRepository } from './AssetsRepository';
import { AssetsService } from './AssetsService';
Expand Down Expand Up @@ -101,8 +102,20 @@ describe('AssetsService', () => {
nftApiClient: mockNftApiClient,
});

const coreAdapter = new CoreAssetsAdapter({
logger: mockLogger,
getAccountAssetByID: jest.fn().mockResolvedValue(null),
getAccountAssetsByIDs: jest.fn().mockResolvedValue({}),
getAccountAssetsByScope: jest.fn().mockResolvedValue({}),
findAccountById: mockAccountsService.findById.bind(mockAccountsService),
getActiveNetworks:
mockConfigProvider.getActiveNetworks.bind(mockConfigProvider),
fetchMint: mockConnection.fetchMint.bind(mockConnection),
});

assetsService = new AssetsService({
snapAdapter: snapAssetsAdapter,
coreAdapter,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,33 @@ import type { FungibleAssetMarketData } from '@metamask/snaps-sdk';
import type { CaipAssetType, CaipChainId } from '@metamask/utils';

import type { AssetEntity, SolanaKeyringAccount } from '../../../entities';
import type { CoreAssetsAdapter } from './adapters/CoreAssetsAdapter';
import { SnapAssetsAdapter } from './adapters/SnapAssetsAdapter';
import type { AssetMetadata } from './types';

/**
* Assets domain facade. Currently delegates all behavior to SnapAssetsAdapter
* (legacy snap-owned reads/writes).
* (legacy snap-owned reads/writes). Core adapter is initialized for upcoming
* routing without changing callers.
*/
export class AssetsService {
readonly #snapAdapter: SnapAssetsAdapter;

// Initialized for upcoming Core routing; not read until the migration PR lands.
// eslint-disable-next-line no-unused-private-class-members -- reserved adapter slot
readonly #coreAdapter: CoreAssetsAdapter;

readonly cacheTtlsMilliseconds: typeof SnapAssetsAdapter.cacheTtlsMilliseconds;

constructor({ snapAdapter }: { snapAdapter: SnapAssetsAdapter }) {
constructor({
snapAdapter,
coreAdapter,
}: {
snapAdapter: SnapAssetsAdapter;
coreAdapter: CoreAssetsAdapter;
}) {
this.#snapAdapter = snapAdapter;
this.#coreAdapter = coreAdapter;
this.cacheTtlsMilliseconds = SnapAssetsAdapter.cacheTtlsMilliseconds;
}

Expand Down
Loading
Loading