Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/stellar-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": "df2jwrVqYLs741TWeyLYKABatgBkFCEDWJdwpnNwiXw=",
"shasum": "76h1Htpk8MNnwqlMdjcCrmimVkqw4hMSRxksHa5BGC0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
11 changes: 3 additions & 8 deletions packages/stellar-wallet-snap/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { State } from '@metamask/snap-networks-utils';
import { assert, object } from '@metamask/superstruct';

import { AppConfig } from './config';
Expand Down Expand Up @@ -45,7 +46,7 @@ import {
OnChainAccountService,
} from './services/on-chain-account';
import { PriceService } from './services/price';
import { State } from './services/state';
import { DEFAULT_UNENCRYPTED_STATE } from './services/state/stateTypes';
import { SynchronizeService } from './services/sync/SynchronizeService';
import {
TransactionBuilder,
Expand All @@ -64,13 +65,7 @@ assert(AppConfig, object());

const state = new State({
encrypted: false,
defaultState: {
keyringAccounts: {},
assets: {},
transactions: {},
lastScanTokens: {},
onChainAccounts: {},
},
defaultState: DEFAULT_UNENCRYPTED_STATE,
});

const accountsRepository = new AccountsRepository(state);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IStateManager } from '@metamask/snap-networks-utils';
import { cloneDeep } from 'lodash';

import type { KnownCaip2ChainId } from '../../api';
import { isSameStr } from '../../utils/assert';
import type { IStateManager } from '../state/IStateManager';
import type { KeyringAccountState, StellarKeyringAccount } from './api';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { InMemoryState } from '@metamask/snap-networks-utils';

import { KnownCaip2ChainId } from '../../../api';
import { KEYRING_ACCOUNT_TYPE } from '../../../constants';
import { MultichainMethod } from '../../../handlers/keyring/api';
import { logger } from '../../../utils/logger';
import { State } from '../../state/State';
import { WalletService, getDerivationPath } from '../../wallet';
import { generateStellarAddress } from '../../wallet/__mocks__/wallet.fixtures';
import { AccountService } from '../AccountService';
Expand Down Expand Up @@ -54,12 +55,9 @@ export const generateMockStellarKeyringAccounts = (
*/
export const mockAccountService = () => {
const walletService = new WalletService();
const state = new State({
encrypted: false,
defaultState: {
keyringAccounts: {},
onChainAccounts: {},
},
const state = new InMemoryState({
keyringAccounts: {},
onChainAccounts: {},
});
const accountService = new AccountService({
logger,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IStateManager } from '@metamask/snap-networks-utils';
import { cloneDeep } from 'lodash';

import { AssetType, KnownCaip2ChainId } from '../../api';
import type { KnownCaip19AssetId } from '../../api';
import type { IStateManager } from '../state/IStateManager';
import { AssetType, KnownCaip2ChainId } from '../../api';
import type { AssetMetadataState, StellarAssetMetadata } from './api';
import { AssetMetadataRepository } from './AssetMetadataRepository';

Expand Down Expand Up @@ -46,11 +46,13 @@ function createMockStateManager(
return undefined;
},
setKey: jest.fn(async () => Promise.resolve()),
setKeyWith: jest.fn(async () => Promise.resolve()),
update: async (updater) => {
state = updater(cloneDeep(state));
return cloneDeep(state);
},
deleteKey: jest.fn(async () => Promise.resolve()),
deleteKeys: jest.fn(async () => Promise.resolve()),
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { IStateManager } from '@metamask/snap-networks-utils';
import { cloneDeep } from 'lodash';

import type {
AssetType,
KnownCaip19AssetId,
KnownCaip2ChainId,
} from '../../api';
import type { IStateManager } from '../state/IStateManager';
import type {
AssetMetadataByAssetId,
AssetMetadataState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { InMemoryState } from '@metamask/snap-networks-utils';

import type { KnownCaip19AssetIdOrSlip44Id } from '../../../api';
import { AssetType, KnownCaip2ChainId } from '../../../api';
import { NATIVE_ASSET_NAME, NATIVE_ASSET_SYMBOL } from '../../../constants';
import { getSlip44AssetId } from '../../../utils/caip';
import { logger, noOpLogger } from '../../../utils/logger';
import { InMemoryCache } from '../../cache';
import { NetworkService } from '../../network';
import { State } from '../../state';
import type { AssetMetadataByAssetId, StellarAssetMetadata } from '../api';
import { AssetMetadataRepository } from '../AssetMetadataRepository';
import { AssetMetadataService } from '../AssetMetadataService';
Expand Down Expand Up @@ -79,9 +80,8 @@ export const createMockAssetMetadataService = () => {
cache: new InMemoryCache(noOpLogger),
}),
assetMetadataRepository: new AssetMetadataRepository(
new State({
encrypted: false,
defaultState: { assets: generateMockStellarAssetMetadata() },
new InMemoryState({
assets: generateMockStellarAssetMetadata(),
}),
),
logger,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable jest/prefer-strict-equal */

import { InMemoryState } from '@metamask/snap-networks-utils';
import type { IStateManager } from '@metamask/snap-networks-utils';

import { logger } from '../../utils/logger';
import type { IStateManager } from '../state';
import { InMemoryState } from './InMemoryState';
import type { StateValue } from './StateCache';
import { StateCache } from './StateCache';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { Logger, Serializable } from '@metamask/snap-networks-utils';
import type {
IStateManager,
Logger,
Serializable,
} from '@metamask/snap-networks-utils';
import { assert } from '@metamask/utils';

import type { IStateManager } from '../state/IStateManager';
import type { ICache, CacheEntry } from './api';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IStateManager } from '@metamask/snap-networks-utils';
import { cloneDeep } from 'lodash';

import type { KnownCaip2ChainId } from '../../api';
import type { IStateManager } from '../state/IStateManager';
import type {
OnChainAccountSnapshotsByKeyringId,
OnChainAccountState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { InMemoryState } from '@metamask/snap-networks-utils';
import type { Horizon } from '@stellar/stellar-sdk';
import { Account } from '@stellar/stellar-sdk';

Expand All @@ -8,7 +9,6 @@ import { AccountService } from '../../account/AccountService';
import { AccountsRepository } from '../../account/AccountsRepository';
import { InMemoryCache } from '../../cache';
import { NetworkService } from '../../network';
import { State } from '../../state/State';
import { WalletService } from '../../wallet';
import { OnChainAccount } from '../OnChainAccount';
import { OnChainAccountRepository } from '../OnChainAccountRepository';
Expand Down Expand Up @@ -158,12 +158,9 @@ export const createMockAccountWithBalances = (
*/
export function mockOnChainAccountService() {
const walletService = new WalletService();
const state = new State({
encrypted: false,
defaultState: {
keyringAccounts: {},
onChainAccounts: {},
},
const state = new InMemoryState({
keyringAccounts: {},
onChainAccounts: {},
});
const accountService = new AccountService({
logger,
Expand Down

This file was deleted.

Loading