@metamask/multichain-network-controller
Version:
Multichain network controller
195 lines • 6.04 kB
JavaScript
import { BtcScope, SolScope, TrxScope } from "@metamask/keyring-api";
import { NetworkStatus } from "@metamask/network-controller";
export const BTC_NATIVE_ASSET = `${BtcScope.Mainnet}/slip44:0`;
export const BTC_TESTNET_NATIVE_ASSET = `${BtcScope.Testnet}/slip44:0`;
export const BTC_TESTNET4_NATIVE_ASSET = `${BtcScope.Testnet4}/slip44:0`;
export const BTC_SIGNET_NATIVE_ASSET = `${BtcScope.Signet}/slip44:0`;
export const BTC_REGTEST_NATIVE_ASSET = `${BtcScope.Regtest}/slip44:0`;
export const SOL_NATIVE_ASSET = `${SolScope.Mainnet}/slip44:501`;
export const SOL_TESTNET_NATIVE_ASSET = `${SolScope.Testnet}/slip44:501`;
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`;
/**
* Supported networks by the MultichainNetworkController
*/
export const AVAILABLE_MULTICHAIN_NETWORK_CONFIGURATIONS = {
[]: {
chainId: BtcScope.Mainnet,
name: 'Bitcoin',
nativeCurrency: BTC_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: BtcScope.Testnet,
name: 'Bitcoin Testnet',
nativeCurrency: BTC_TESTNET_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: BtcScope.Testnet4,
name: 'Bitcoin Testnet4',
nativeCurrency: BTC_TESTNET4_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: BtcScope.Signet,
name: 'Bitcoin Mutinynet',
nativeCurrency: BTC_SIGNET_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: BtcScope.Regtest,
name: 'Bitcoin Regtest',
nativeCurrency: BTC_REGTEST_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: SolScope.Mainnet,
name: 'Solana',
nativeCurrency: SOL_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: SolScope.Testnet,
name: 'Solana Testnet',
nativeCurrency: SOL_TESTNET_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: SolScope.Devnet,
name: 'Solana Devnet',
nativeCurrency: SOL_DEVNET_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: TrxScope.Mainnet,
name: 'Tron',
nativeCurrency: TRX_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: TrxScope.Nile,
name: 'Tron Nile',
nativeCurrency: TRX_NILE_NATIVE_ASSET,
isEvm: false,
},
[]: {
chainId: TrxScope.Shasta,
name: 'Tron Shasta',
nativeCurrency: TRX_SHASTA_NATIVE_ASSET,
isEvm: false,
},
};
/**
* Array of all the Non-EVM chain IDs.
* This is a temporary mention until we develop
* a more robust solution to identify testnet networks.
*/
export const NON_EVM_TESTNET_IDS = [
BtcScope.Testnet,
BtcScope.Testnet4,
BtcScope.Signet,
BtcScope.Regtest,
SolScope.Testnet,
SolScope.Devnet,
TrxScope.Nile,
TrxScope.Shasta,
];
/**
* Metadata for the supported networks.
*/
export const NETWORKS_METADATA = {
[]: {
features: [],
status: NetworkStatus.Available,
},
[]: {
features: [],
status: NetworkStatus.Available,
},
[]: {
features: [],
status: NetworkStatus.Available,
},
};
/**
* Default state of the {@link MultichainNetworkController}.
*
* @returns The default state of the {@link MultichainNetworkController}.
*/
export const getDefaultMultichainNetworkControllerState = () => ({
multichainNetworkConfigurationsByChainId: AVAILABLE_MULTICHAIN_NETWORK_CONFIGURATIONS,
selectedMultichainNetworkChainId: SolScope.Mainnet,
isEvmSelected: true,
networksWithTransactionActivity: {},
});
/**
* {@link MultichainNetworkController}'s metadata.
*
* This allows us to choose if fields of the state should be persisted or not
* using the `persist` flag; and if they can be sent to Sentry or not, using
* the `anonymous` flag.
*/
export const MULTICHAIN_NETWORK_CONTROLLER_METADATA = {
multichainNetworkConfigurationsByChainId: {
includeInStateLogs: true,
persist: true,
includeInDebugSnapshot: true,
usedInUi: true,
},
selectedMultichainNetworkChainId: {
includeInStateLogs: true,
persist: true,
includeInDebugSnapshot: true,
usedInUi: true,
},
isEvmSelected: {
includeInStateLogs: true,
persist: true,
includeInDebugSnapshot: true,
usedInUi: true,
},
networksWithTransactionActivity: {
includeInStateLogs: true,
persist: true,
includeInDebugSnapshot: true,
usedInUi: true,
},
};
/**
* Multichain network ticker for the supported networks.
* TODO: This should be part of the assets-controllers or the snap itself.
*/
export const MULTICHAIN_NETWORK_TICKER = {
[]: 'BTC',
[]: 'tBTC',
[]: 'tBTC',
[]: 'sBTC',
[]: 'rBTC',
[]: 'SOL',
[]: 'tSOL',
[]: 'dSOL',
[]: 'TRX',
[]: 'tTRX',
[]: 'sTRX',
};
/**
* Multichain network asset decimals for the supported networks.
* TODO: This should be part of the assets-controllers or the snap itself.
*/
export const MULTICHAIN_NETWORK_DECIMAL_PLACES = {
[]: 8,
[]: 8,
[]: 8,
[]: 8,
[]: 8,
[]: 5,
[]: 5,
[]: 5,
[]: 6,
[]: 6,
[]: 6,
};
//# sourceMappingURL=constants.mjs.map