Skip to content
Open
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
14 changes: 2 additions & 12 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1222,19 +1222,14 @@
"count": 1
},
"no-restricted-globals": {
"count": 27
"count": 25
}
},
"packages/stellar-wallet-snap/src/handlers/accountResolver.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
}
},
"packages/stellar-wallet-snap/src/handlers/asset/assets.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
}
},
"packages/stellar-wallet-snap/src/handlers/clientRequest/api.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
Expand Down Expand Up @@ -1428,12 +1423,7 @@
},
"packages/stellar-wallet-snap/src/services/price/PriceService.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 4
}
},
"packages/stellar-wallet-snap/src/services/price/__mocks__/price.fixtures.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
"count": 2
}
},
"packages/stellar-wallet-snap/src/services/price/price-api/PriceApiClient.test.ts": {
Expand Down
6 changes: 0 additions & 6 deletions packages/stellar-wallet-snap/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ SECURITY_ALERTS_API_BASE_URL=https://security-alerts.api.cx.metamask.io
# Cache TTL Milliseconds for spot prices
#STELLAR_SPOT_PRICES_TTL_MILLISECONDS=

# Cache TTL Milliseconds for fiat exchange rates
#STELLAR_FIAT_EXCHANGE_RATES_TTL_MILLISECONDS=

# Cache TTL Milliseconds for historical prices
#STELLAR_HISTORICAL_PRICES_TTL_MILLISECONDS=

# Inclusion fee multiplier (applied to Stellar network base fee per operation)
#STELLAR_BASE_FEE_MULTIPLIER=

Expand Down
4 changes: 4 additions & 0 deletions packages/stellar-wallet-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **BREAKING** Bump `@metamask/keyring-snap-sdk` from `^9.2.1` to `^10.0.0` ([#214](https://github.com/MetaMask/internal-snaps/pull/214))
- **BREAKING** Bump `@metamask/snaps-sdk` from `^11.2.0` to `^12.0.1` ([#214](https://github.com/MetaMask/internal-snaps/pull/214))

### Removed

- **BREAKING** Remove the deprecated `asset` cluster of handlers: `onAssetHistoricalPrice`, `onAssetsConversion`, `onAssetsLookup` and `onAssetsMarketData` ([#262](https://github.com/MetaMask/internal-snaps/pull/262))

### Fixed

- Fill contract-based receive transactions in history instead of marking them as unknown ([#255](https://github.com/MetaMask/internal-snaps/pull/255))
Expand Down
1 change: 0 additions & 1 deletion packages/stellar-wallet-snap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ High-level layout of `packages/snap` (nested implementation folders like `servic
| `docs/misc/synchronization/` | Background sync flow and component details |
| `src/api/` | Shared types and Superstruct validators (CAIP, XDR, amounts, …) |
| `src/handlers/` | Snap RPC / lifecycle entry handlers; orchestrates use cases |
| `src/handlers/asset/` | `onAssets*` lookups, conversion, market data, historical price |
| `src/handlers/clientRequest/` | SIP-31 client methods (send, trustline, fees, …) |
| `src/handlers/cronjob/` | Background sync, transaction tracking, confirmation refresh |
| `src/handlers/keyring/` | Keyring API (accounts, sign tx / message / auth entry) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Asset metadata catalog refresh from the token API.

Triggered by the `synchronizeAssets` cron (see [syncAssets.md](../../use-cases/cron-job/syncAssets.md)). Always uses **mainnet** scope — asset metadata is only available there, regardless of the user's selected network.

Wire format: [SIP-29 Snap Assets API](https://metamask.github.io/SIPs/SIPS/sip-29) (lookup handlers read from the persisted catalog).
Wire format: [SIP-29 Snap Assets API](https://metamask.github.io/SIPs/SIPS/sip-29).

## Step-by-step

Expand Down Expand Up @@ -53,13 +53,11 @@ sequenceDiagram

## Data source

| Data | Source |
| ----------------------------------------- | ------------------------------------------------ |
| Asset catalog (symbol, decimals, icon, …) | **Token API** → persisted in **snap state** |
| On-demand lookup (`onAssetsLookup`) | Snap state catalog (fetch + persist missing ids) |
| Data | Source |
| ----------------------------------------- | ------------------------------------------- |
| Asset catalog (symbol, decimals, icon, …) | **Token API** → persisted in **snap state** |

## Related

- [syncAssets.md](../../use-cases/cron-job/syncAssets.md) — cron entry
- [assets.md](../../use-cases/assets/assets.md) — `onAssets*` handlers
- [transaction.md](./transaction.md) — SEP-41 metadata used during tx mapping
6 changes: 0 additions & 6 deletions packages/stellar-wallet-snap/docs/use-cases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ Account management is summarized in one place; SEP-43 signing methods have their
| Sign message | `signMessage` | [signMessage.md](./keyring/signMessage.md) |
| Sign Soroban auth entry | `signAuthEntry` | [signAuthEntry.md](./keyring/signAuthEntry.md) |

## Assets (`endowment:assets`)

| Use case | Entry method | Doc |
| ----------------------------------- | --------------- | ------------------------------- |
| Assets overview (lookup, prices, …) | `AssetsHandler` | [assets.md](./assets/assets.md) |

## User input (`onUserInput`)

| Use case | Entry method | Doc |
Expand Down
33 changes: 0 additions & 33 deletions packages/stellar-wallet-snap/docs/use-cases/assets/assets.md

This file was deleted.

4 changes: 0 additions & 4 deletions packages/stellar-wallet-snap/snap.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ const config: SnapConfig = {
PRICE_API_BASE_URL: process.env.PRICE_API_BASE_URL ?? '',
SECURITY_ALERTS_API_BASE_URL:
process.env.SECURITY_ALERTS_API_BASE_URL ?? '',
STELLAR_FIAT_EXCHANGE_RATES_TTL_MILLISECONDS:
process.env.STELLAR_FIAT_EXCHANGE_RATES_TTL_MILLISECONDS ?? '',
STELLAR_HISTORICAL_PRICES_TTL_MILLISECONDS:
process.env.STELLAR_HISTORICAL_PRICES_TTL_MILLISECONDS ?? '',
STELLAR_SPOT_PRICES_TTL_MILLISECONDS:
process.env.STELLAR_SPOT_PRICES_TTL_MILLISECONDS ?? '',
STELLAR_BASE_FEE_TTL_MILLISECONDS:
Expand Down
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": "0NhnLQaV7sW0XW5aSbSQMtx4aImB3rToaZugqGZUc9w=",
"shasum": "Cgwhcxj5mugH3EzB2dR6BDqtc2AnL+RSCkUEbjgAwic=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
20 changes: 0 additions & 20 deletions packages/stellar-wallet-snap/src/api/asset.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { assert, StructError } from '@metamask/superstruct';

import {
FiatCaipAssetStruct,
KnownCaip19ClassicAssetStruct,
KnownCaip19Sep41AssetStruct,
KnownCaip19Slip44IdStruct,
Expand Down Expand Up @@ -41,25 +40,6 @@ describe('KnownCaip19Sep41AssetStruct', () => {
});
});

describe('FiatCaipAssetStruct', () => {
it.each(['swift:0/iso4217:USD', 'swift:0/iso4217:eur'])(
'accepts a valid fiat CAIP-19 asset id',
(assetId) => {
expect(() => assert(assetId, FiatCaipAssetStruct)).not.toThrow();
},
);

it.each([
'stellar:pubnet/slip44:148',
'eip155:1/swift:0/iso4217:USD',
'swift:0/iso4217:US',
'swift:0/iso4217:USDC',
'eip155:1/notswift:0/iso4217:USD',
])('rejects a non-fiat CAIP-19 asset id', (assetId) => {
expect(() => assert(assetId, FiatCaipAssetStruct)).toThrow(StructError);
});
});

describe('KnownCaip19Slip44IdStruct', () => {
it('accepts a valid CAIP-19 asset', () => {
expect(() =>
Expand Down
14 changes: 0 additions & 14 deletions packages/stellar-wallet-snap/src/api/asset.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Infer } from '@metamask/superstruct';
import { union } from '@metamask/superstruct';
import type { CaipAssetType } from '@metamask/utils';
import { definePattern } from '@metamask/utils';

import { STELLAR_COIN_TYPE } from '../constants';
Expand Down Expand Up @@ -48,26 +47,13 @@ export const KnownCaip19Sep41AssetStruct =
/^stellar:(?:pubnet|testnet)\/sep41:C[A-Z2-7]{55}$/u,
);

/**
* Fiat asset id in SWIFT / ISO 4217 form only: `swift:0/iso4217:{code}` (3-letter code).
*
* @see https://github.com/MetaMask/core/blob/main/packages/assets-controllers/src/MultichainAssetsRatesController/constant.ts#L44
*/
export const FiatCaipAssetStruct = definePattern<CaipAssetType>(
'FiatCaipAsset',
/^swift:0\/iso4217:[A-Za-z]{3}$/u,
);

/** Validation struct for a known Stellar CAIP-19 asset id or slip44 id. */
export const KnownCaip19AssetIdOrSlip44IdStruct = union([
KnownCaip19Sep41AssetStruct,
KnownCaip19ClassicAssetStruct,
KnownCaip19Slip44IdStruct,
]);

/** Fiat CAIP-19 asset id (SWIFT / ISO 4217). */
export type FiatCaipAssetId = Infer<typeof FiatCaipAssetStruct>;

/** CAIP-19 Sep41 asset ID */
export type KnownCaip19Sep41AssetId = Infer<typeof KnownCaip19Sep41AssetStruct>;

Expand Down
8 changes: 0 additions & 8 deletions packages/stellar-wallet-snap/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ const ConfigStruct = object({
// 1 hour
spotPrices: parseIntegerStruct(1000, 60 * 60 * 1000 * 1),
// 1 hour
fiatExchangeRates: parseIntegerStruct(1000, 60 * 60 * 1000 * 1),
// 1 hour
historicalPrices: parseIntegerStruct(1000, 60 * 60 * 1000 * 1),
// 1 hour
baseFee: parseIntegerStruct(1000, 60 * 60 * 1000 * 1),
// 10 minutes (Horizon account payload; aligns with on-chain account cache usage)
loadOnChainAccount: parseIntegerStruct(1000, 10 * 60 * 1000 * 1),
Expand Down Expand Up @@ -258,10 +254,6 @@ export const AppConfig = create(
cache: {
ttlMilliseconds: {
spotPrices: process.env.STELLAR_SPOT_PRICES_TTL_MILLISECONDS,
fiatExchangeRates:
process.env.STELLAR_FIAT_EXCHANGE_RATES_TTL_MILLISECONDS,
historicalPrices:
process.env.STELLAR_HISTORICAL_PRICES_TTL_MILLISECONDS,
baseFee: process.env.STELLAR_BASE_FEE_TTL_MILLISECONDS,
loadOnChainAccount:
process.env.STELLAR_LOAD_ON_CHAIN_ACCOUNT_TTL_MILLISECONDS,
Expand Down
9 changes: 0 additions & 9 deletions packages/stellar-wallet-snap/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { assert, object } from '@metamask/superstruct';
import { AppConfig } from './config';
import { KeyringHandler, CronjobHandler, UserInputHandler } from './handlers';
import { AccountResolver } from './handlers/accountResolver';
import { AssetsHandler } from './handlers/asset/assets';
import type { IClientRequestHandler } from './handlers/clientRequest';
import {
ChangeTrustOptHandler,
Expand Down Expand Up @@ -247,13 +246,6 @@ const cronjobHandler = new CronjobHandler({
handlers: cronjobMethodHandlers,
});

/** ------------------------------ Asset Handler ------------------------------ */
const assetsHandler = new AssetsHandler({
logger,
assetMetadataService,
priceService,
});

/** ------------------------------ Client Request Handlers ------------------------------ */
const changeTrustOptHandler = new ChangeTrustOptHandler({
logger,
Expand Down Expand Up @@ -320,7 +312,6 @@ const clientRequestHandler = new ClientRequestHandler({
export {
clientRequestHandler,
cronjobHandler,
assetsHandler,
keyringHandler,
userInputHandler,
signTransactionHandler,
Expand Down
30 changes: 0 additions & 30 deletions packages/stellar-wallet-snap/src/handlers/asset/api.test.ts

This file was deleted.

17 changes: 0 additions & 17 deletions packages/stellar-wallet-snap/src/handlers/asset/api.ts

This file was deleted.

Loading