diff --git a/packages/multichain-network-controller/CHANGELOG.md b/packages/multichain-network-controller/CHANGELOG.md index 936bf61f56..1cbe3e0ba9 100644 --- a/packages/multichain-network-controller/CHANGELOG.md +++ b/packages/multichain-network-controller/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add Stellar pubnet (`stellar:pubnet`) and Stellar testnet (`stellar:testnet`) to multichain network configurations (`AVAILABLE_MULTICHAIN_NETWORK_CONFIGURATIONS`), native asset CAIP-19 constants, metadata, tickers, decimal places, and `SupportedCaipChainId`; register testnet in `NON_EVM_TESTNET_IDS` ([#TODO](https://github.com/MetaMask/core/pull/TODO)) + ## [3.1.0] ### Added diff --git a/packages/multichain-network-controller/package.json b/packages/multichain-network-controller/package.json index f5f74dbaed..0fb4eec0fa 100644 --- a/packages/multichain-network-controller/package.json +++ b/packages/multichain-network-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/multichain-network-controller", - "version": "3.1.0", + "version": "3.1.0-dev.2", "description": "Multichain network controller", "keywords": [ "Ethereum", diff --git a/packages/multichain-network-controller/src/MultichainNetworkController/MultichainNetworkController.test.ts b/packages/multichain-network-controller/src/MultichainNetworkController/MultichainNetworkController.test.ts index 240743acec..fefd952ca6 100644 --- a/packages/multichain-network-controller/src/MultichainNetworkController/MultichainNetworkController.test.ts +++ b/packages/multichain-network-controller/src/MultichainNetworkController/MultichainNetworkController.test.ts @@ -778,6 +778,18 @@ describe('MultichainNetworkController', () => { "name": "Solana Devnet", "nativeCurrency": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1/slip44:501", }, + "stellar:pubnet": { + "chainId": "stellar:pubnet", + "isEvm": false, + "name": "Stellar", + "nativeCurrency": "stellar:pubnet/slip44:148", + }, + "stellar:testnet": { + "chainId": "stellar:testnet", + "isEvm": false, + "name": "Stellar Testnet", + "nativeCurrency": "stellar:testnet/slip44:148", + }, "tron:2494104990": { "chainId": "tron:2494104990", "isEvm": false, @@ -864,6 +876,18 @@ describe('MultichainNetworkController', () => { "name": "Solana Devnet", "nativeCurrency": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1/slip44:501", }, + "stellar:pubnet": { + "chainId": "stellar:pubnet", + "isEvm": false, + "name": "Stellar", + "nativeCurrency": "stellar:pubnet/slip44:148", + }, + "stellar:testnet": { + "chainId": "stellar:testnet", + "isEvm": false, + "name": "Stellar Testnet", + "nativeCurrency": "stellar:testnet/slip44:148", + }, "tron:2494104990": { "chainId": "tron:2494104990", "isEvm": false, @@ -950,6 +974,18 @@ describe('MultichainNetworkController', () => { "name": "Solana Devnet", "nativeCurrency": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1/slip44:501", }, + "stellar:pubnet": { + "chainId": "stellar:pubnet", + "isEvm": false, + "name": "Stellar", + "nativeCurrency": "stellar:pubnet/slip44:148", + }, + "stellar:testnet": { + "chainId": "stellar:testnet", + "isEvm": false, + "name": "Stellar Testnet", + "nativeCurrency": "stellar:testnet/slip44:148", + }, "tron:2494104990": { "chainId": "tron:2494104990", "isEvm": false, @@ -1036,6 +1072,18 @@ describe('MultichainNetworkController', () => { "name": "Solana Devnet", "nativeCurrency": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1/slip44:501", }, + "stellar:pubnet": { + "chainId": "stellar:pubnet", + "isEvm": false, + "name": "Stellar", + "nativeCurrency": "stellar:pubnet/slip44:148", + }, + "stellar:testnet": { + "chainId": "stellar:testnet", + "isEvm": false, + "name": "Stellar Testnet", + "nativeCurrency": "stellar:testnet/slip44:148", + }, "tron:2494104990": { "chainId": "tron:2494104990", "isEvm": false, diff --git a/packages/multichain-network-controller/src/constants.ts b/packages/multichain-network-controller/src/constants.ts index 262e79aa6d..8fe8205881 100644 --- a/packages/multichain-network-controller/src/constants.ts +++ b/packages/multichain-network-controller/src/constants.ts @@ -1,5 +1,5 @@ import type { StateMetadata } from '@metamask/base-controller'; -import { BtcScope, SolScope, TrxScope } from '@metamask/keyring-api'; +import { BtcScope, SolScope, TrxScope, XlmScope } from '@metamask/keyring-api'; import type { CaipChainId } from '@metamask/keyring-api'; import { NetworkStatus } from '@metamask/network-controller'; @@ -21,6 +21,8 @@ export const SOL_DEVNET_NATIVE_ASSET = `${SolScope.Devnet}/slip44:501`; export const TRX_NATIVE_ASSET = `${TrxScope.Mainnet}/slip44:195`; export const TRX_NILE_NATIVE_ASSET = `${TrxScope.Nile}/slip44:195`; export const TRX_SHASTA_NATIVE_ASSET = `${TrxScope.Shasta}/slip44:195`; +export const XLM_NATIVE_ASSET = `${XlmScope.Pubnet}/slip44:148`; +export const XLM_TESTNET_NATIVE_ASSET = `${XlmScope.Testnet}/slip44:148`; /** * Supported networks by the MultichainNetworkController @@ -95,6 +97,18 @@ export const AVAILABLE_MULTICHAIN_NETWORK_CONFIGURATIONS: Record< nativeCurrency: TRX_SHASTA_NATIVE_ASSET, isEvm: false, }, + [XlmScope.Pubnet]: { + chainId: XlmScope.Pubnet, + name: 'Stellar', + nativeCurrency: XLM_NATIVE_ASSET, + isEvm: false, + }, + [XlmScope.Testnet]: { + chainId: XlmScope.Testnet, + name: 'Stellar Testnet', + nativeCurrency: XLM_TESTNET_NATIVE_ASSET, + isEvm: false, + }, }; /** @@ -111,6 +125,7 @@ export const NON_EVM_TESTNET_IDS: CaipChainId[] = [ SolScope.Devnet, TrxScope.Nile, TrxScope.Shasta, + XlmScope.Testnet, ]; /** @@ -129,6 +144,10 @@ export const NETWORKS_METADATA: Record = { features: [], status: NetworkStatus.Available, }, + [XlmScope.Pubnet]: { + features: [], + status: NetworkStatus.Available, + }, }; /** @@ -195,6 +214,8 @@ export const MULTICHAIN_NETWORK_TICKER: Record = { [TrxScope.Mainnet]: 'TRX', [TrxScope.Nile]: 'tTRX', [TrxScope.Shasta]: 'sTRX', + [XlmScope.Pubnet]: 'XLM', + [XlmScope.Testnet]: 'tXLM', } as const; /** @@ -213,4 +234,6 @@ export const MULTICHAIN_NETWORK_DECIMAL_PLACES: Record = { [TrxScope.Mainnet]: 6, [TrxScope.Nile]: 6, [TrxScope.Shasta]: 6, + [XlmScope.Pubnet]: 7, + [XlmScope.Testnet]: 7, } as const; diff --git a/packages/multichain-network-controller/src/types.ts b/packages/multichain-network-controller/src/types.ts index 6988307298..4b4b42b6d4 100644 --- a/packages/multichain-network-controller/src/types.ts +++ b/packages/multichain-network-controller/src/types.ts @@ -9,6 +9,7 @@ import type { CaipChainId, SolScope, TrxScope, + XlmScope, } from '@metamask/keyring-api'; import type { InternalAccount } from '@metamask/keyring-internal-api'; import type { Messenger } from '@metamask/messenger'; @@ -43,7 +44,9 @@ export type SupportedCaipChainId = | SolScope.Devnet | TrxScope.Mainnet | TrxScope.Nile - | TrxScope.Shasta; + | TrxScope.Shasta + | XlmScope.Pubnet + | XlmScope.Testnet; export type CommonNetworkConfiguration = { /** diff --git a/packages/multichain-network-controller/src/utils.test.ts b/packages/multichain-network-controller/src/utils.test.ts index c865fcf610..83ceaacb05 100644 --- a/packages/multichain-network-controller/src/utils.test.ts +++ b/packages/multichain-network-controller/src/utils.test.ts @@ -1,4 +1,4 @@ -import { BtcScope, SolScope, EthScope } from '@metamask/keyring-api'; +import { BtcScope, SolScope, EthScope, XlmScope } from '@metamask/keyring-api'; import type { CaipChainId } from '@metamask/keyring-api'; import type { NetworkConfiguration } from '@metamask/network-controller'; import { KnownCaipNamespace } from '@metamask/utils'; @@ -29,6 +29,11 @@ describe('utils', () => { expect(getChainIdForNonEvm(scopes)).toBe(BtcScope.Testnet); }); + it('returns Stellar chain ID for Stellar scopes', () => { + const scopes = [XlmScope.Pubnet, XlmScope.Testnet]; + expect(getChainIdForNonEvm(scopes)).toBe(XlmScope.Pubnet); + }); + it('throws error if network is not found', () => { const scopes = ['unknown:scope' as CaipChainId]; expect(() => getChainIdForNonEvm(scopes)).toThrow( @@ -41,6 +46,8 @@ describe('utils', () => { it('returns true for supported CAIP chain IDs', () => { expect(checkIfSupportedCaipChainId(SolScope.Mainnet)).toBe(true); expect(checkIfSupportedCaipChainId(BtcScope.Mainnet)).toBe(true); + expect(checkIfSupportedCaipChainId(XlmScope.Pubnet)).toBe(true); + expect(checkIfSupportedCaipChainId(XlmScope.Testnet)).toBe(true); }); it('returns false for non-CAIP IDs', () => {