use crate::xcm_config::XcmConfig; use frame_support::parameter_types; use pallet_evm_precompile_assets_erc20::Erc20AssetsPrecompileSet; use pallet_evm_precompile_assets_factory::AssetsFactoryPrecompile; use pallet_evm_precompile_balances_erc20::{Erc20BalancesPrecompile, Erc20Metadata}; use pallet_evm_precompile_batch::BatchPrecompile; use pallet_evm_precompile_blake2::Blake2F; use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing}; use pallet_evm_precompile_modexp::Modexp; use pallet_evm_precompile_parachain_staking::ParachainStakingPrecompile; use pallet_evm_precompile_peaq_did::PeaqDIDPrecompile; use pallet_evm_precompile_peaq_rbac::PeaqRbacPrecompile; use pallet_evm_precompile_peaq_storage::PeaqStoragePrecompile; use pallet_evm_precompile_sha3fips::Sha3FIPS256; use pallet_evm_precompile_simple::{ECRecover, ECRecoverPublicKey, Identity, Ripemd160, Sha256}; use pallet_evm_precompile_vesting::VestingPrecompile; use pallet_evm_precompile_xcm_utils::XcmUtilsPrecompile; use pallet_evm_precompile_xtokens::XtokensPrecompile; use precompile_utils::precompile_set::*; type EthereumPrecompilesChecks = (AcceptDelegateCall, CallableByContract, CallableByPrecompile); const ASSET_PRECOMPILE_ADDRESS_PREFIX: &[u8] = &[255u8; 4]; parameter_types! { pub EVMAssetPrefix: &'static [u8] = ASSET_PRECOMPILE_ADDRESS_PREFIX; } /// ERC20 metadata for the native token. pub struct NativeErc20Metadata; impl Erc20Metadata for NativeErc20Metadata { /// Returns the name of the token. fn name() -> &'static str { "peaq token" } /// Returns the symbol of the token. fn symbol() -> &'static str { "PEAQ" } /// Returns the decimals places of the token. fn decimals() -> u8 { 18 } /// Must return `true` only if it represents the main native currency of /// the network. It must be the currency used in `pallet_evm`. fn is_native_currency() -> bool { true } } /// The following distribution has been decided for the precompiles /// 0-1023: Ethereum Mainnet Precompiles /// 1024-2047 Precompiles that are not in Ethereum Mainnet but are neither Peaq specific pub type PeaqPrecompiles = PrecompileSetBuilder< R, ( // Skip precompiles if out of range. PrecompilesInRangeInclusive< (AddressU64<1>, AddressU64<4095>), ( // Ethereum precompiles: // We allow DELEGATECALL to stay compliant with Ethereum behavior. PrecompileAt, ECRecover, EthereumPrecompilesChecks>, PrecompileAt, Sha256, EthereumPrecompilesChecks>, PrecompileAt, Ripemd160, EthereumPrecompilesChecks>, PrecompileAt, Identity, EthereumPrecompilesChecks>, PrecompileAt, Modexp, EthereumPrecompilesChecks>, PrecompileAt, Bn128Add, EthereumPrecompilesChecks>, PrecompileAt, Bn128Mul, EthereumPrecompilesChecks>, PrecompileAt, Bn128Pairing, EthereumPrecompilesChecks>, PrecompileAt, Blake2F, EthereumPrecompilesChecks>, // Non-Moonbeam specific nor Ethereum precompiles : PrecompileAt< AddressU64<1024>, Sha3FIPS256, (CallableByContract, CallableByPrecompile), >, // PrecompileAt, Dispatch>, PrecompileAt< AddressU64<1026>, ECRecoverPublicKey, (CallableByContract, CallableByPrecompile), >, PrecompileAt< AddressU64<2048>, PeaqDIDPrecompile, (CallableByPrecompile, CallableByContract), >, PrecompileAt< AddressU64<2049>, PeaqStoragePrecompile, (CallableByPrecompile, CallableByContract), >, PrecompileAt< AddressU64<2050>, PeaqRbacPrecompile, (CallableByPrecompile, CallableByContract), >, PrecompileAt< AddressU64<2051>, XtokensPrecompile, (SubcallWithMaxNesting<1>, CallableByPrecompile, CallableByContract), >, PrecompileAt< AddressU64<2052>, XcmUtilsPrecompile, CallableByContract< pallet_evm_precompile_xcm_utils::AllExceptXcmExecute, >, >, PrecompileAt< AddressU64<2053>, BatchPrecompile, ( SubcallWithMaxNesting<2>, // Batch is the only precompile allowed to call Batch. CallableByPrecompile>>, ), >, PrecompileAt< AddressU64<2054>, AssetsFactoryPrecompile, (CallableByPrecompile, CallableByContract), >, PrecompileAt< AddressU64<2055>, ParachainStakingPrecompile, (CallableByPrecompile, CallableByContract), >, PrecompileAt< AddressU64<2056>, VestingPrecompile, (CallableByPrecompile, CallableByContract), >, PrecompileAt< AddressU64<2057>, Erc20BalancesPrecompile, (CallableByPrecompile, CallableByContract), >, ), >, PrecompileSetStartingWith< EVMAssetPrefix, Erc20AssetsPrecompileSet, (CallableByContract, CallableByPrecompile), >, ), >;