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 @@ -1232,19 +1232,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 @@ -1438,12 +1433,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
5 changes: 5 additions & 0 deletions packages/stellar-wallet-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ 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 `onAssetsLookup`, `onAssetsConversion`, `onAssetHistoricalPrice`, and `onAssetsMarketData` asset handler entry points, along with the now-unused `AssetsHandler` module and the `endowment:assets` permission ([#262](https://github.com/MetaMask/internal-snaps/pull/262))
- Remove now-unused price APIs: `PriceService` `getFiatExchangeRates`, `getHistoricalPrices`, `getHistoricalPriceWithAllTimePeriods`, `getMultipleTokenConversions`, and `getMultipleTokensMarketData` methods; `PriceApiClient` fiat-exchange-rates and historical-prices endpoints and their structs; the `isFiat` and `getFiatTicker` utils; the `FiatCaipAssetStruct` struct; and the `fiatExchangeRates` and `historicalPrices` cache TTL settings ([#262](https://github.com/MetaMask/internal-snaps/pull/262))

## [0.1.0]

### Added
Expand Down
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
5 changes: 1 addition & 4 deletions 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": "eLUwFyKvzK6j3RV0am3G59i2B74yVEf2bU+wnMMcWeE=",
"shasum": "CUvTqT+aiM+mylyW1uwVjk/bS6Pit/uWYTGQnslRi5k=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down Expand Up @@ -59,9 +59,6 @@
}
}
]
},
"endowment:assets": {
"scopes": ["stellar:pubnet"]
}
},
"platformVersion": "12.0.1",
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