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
4 changes: 4 additions & 0 deletions packages/multichain-network-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/multichain-network-controller/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 24 additions & 1 deletion packages/multichain-network-controller/src/constants.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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
Expand Down Expand Up @@ -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,
},
};

/**
Expand All @@ -111,6 +125,7 @@ export const NON_EVM_TESTNET_IDS: CaipChainId[] = [
SolScope.Devnet,
TrxScope.Nile,
TrxScope.Shasta,
XlmScope.Testnet,
];

/**
Expand All @@ -129,6 +144,10 @@ export const NETWORKS_METADATA: Record<string, MultichainNetworkMetadata> = {
features: [],
status: NetworkStatus.Available,
},
[XlmScope.Pubnet]: {
features: [],
status: NetworkStatus.Available,
},
};

/**
Expand Down Expand Up @@ -195,6 +214,8 @@ export const MULTICHAIN_NETWORK_TICKER: Record<CaipChainId, string> = {
[TrxScope.Mainnet]: 'TRX',
[TrxScope.Nile]: 'tTRX',
[TrxScope.Shasta]: 'sTRX',
[XlmScope.Pubnet]: 'XLM',
[XlmScope.Testnet]: 'tXLM',
} as const;

/**
Expand All @@ -213,4 +234,6 @@ export const MULTICHAIN_NETWORK_DECIMAL_PLACES: Record<CaipChainId, number> = {
[TrxScope.Mainnet]: 6,
[TrxScope.Nile]: 6,
[TrxScope.Shasta]: 6,
[XlmScope.Pubnet]: 7,
[XlmScope.Testnet]: 7,
} as const;
5 changes: 4 additions & 1 deletion packages/multichain-network-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -43,7 +44,9 @@ export type SupportedCaipChainId =
| SolScope.Devnet
| TrxScope.Mainnet
| TrxScope.Nile
| TrxScope.Shasta;
| TrxScope.Shasta
| XlmScope.Pubnet
| XlmScope.Testnet;

export type CommonNetworkConfiguration = {
/**
Expand Down
9 changes: 8 additions & 1 deletion packages/multichain-network-controller/src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand All @@ -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', () => {
Expand Down