// Copyright 2019-2025 The DataHaven Team // This file is part of DataHaven. // DataHaven is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // DataHaven is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with DataHaven. If not, see . use crate::configs::MaxAdditionalFields; use crate::governance::councils::{TechnicalCommitteeInstance, TreasuryCouncilInstance}; use crate::governance::custom_origins::Origin; 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_call_permit::CallPermitPrecompile; use pallet_evm_precompile_collective::CollectivePrecompile; use pallet_evm_precompile_conviction_voting::ConvictionVotingPrecompile; use pallet_evm_precompile_file_system::FileSystemPrecompile; use pallet_evm_precompile_identity::IdentityPrecompile; use pallet_evm_precompile_modexp::Modexp; use pallet_evm_precompile_preimage::PreimagePrecompile; use pallet_evm_precompile_proxy::{OnlyIsProxyAndProxy, ProxyPrecompile}; use pallet_evm_precompile_referenda::ReferendaPrecompile; use pallet_evm_precompile_registry::PrecompileRegistry; use pallet_evm_precompile_sha3fips::Sha3FIPS256; use pallet_evm_precompile_simple::{ECRecover, ECRecoverPublicKey, Identity, Ripemd160, Sha256}; use precompile_utils::precompile_set::*; type EthereumPrecompilesChecks = (AcceptDelegateCall, CallableByContract, CallableByPrecompile); pub struct NativeErc20Metadata; impl Erc20Metadata for NativeErc20Metadata { fn name() -> &'static str { "HAVE" } fn symbol() -> &'static str { "HAVE" } fn decimals() -> u8 { 18 } fn is_native_currency() -> bool { true } } /// EVM precompiles available in the DataHaven Mainnet runtime. #[precompile_utils::precompile_name_from_address] type DataHavenPrecompilesAt = ( // 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-DataHaven specific nor Ethereum precompiles : PrecompileAt, Sha3FIPS256, (CallableByContract, CallableByPrecompile)>, RemovedPrecompileAt>, PrecompileAt, ECRecoverPublicKey, (CallableByContract, CallableByPrecompile)>, RemovedPrecompileAt>, // DataHaven specific precompiles: PrecompileAt< AddressU64<2050>, Erc20BalancesPrecompile, (CallableByContract, CallableByPrecompile), >, PrecompileAt< AddressU64<2056>, BatchPrecompile, ( SubcallWithMaxNesting<2>, // Batch is the only precompile allowed to call Batch. CallableByPrecompile>>, ), >, PrecompileAt< AddressU64<2058>, CallPermitPrecompile, (SubcallWithMaxNesting<0>, CallableByContract), >, PrecompileAt< AddressU64<2059>, ProxyPrecompile, ( CallableByContract>, SubcallWithMaxNesting<0>, // Batch is the only precompile allowed to call Proxy. CallableByPrecompile>>, ), >, PrecompileAt< AddressU64<2064>, CollectivePrecompile, (CallableByContract, CallableByPrecompile), >, PrecompileAt< AddressU64<2065>, ReferendaPrecompile, (CallableByContract, CallableByPrecompile), >, PrecompileAt< AddressU64<2066>, ConvictionVotingPrecompile, (CallableByContract, CallableByPrecompile), >, PrecompileAt< AddressU64<2067>, PreimagePrecompile, (CallableByContract, CallableByPrecompile), >, PrecompileAt< AddressU64<2068>, CollectivePrecompile, (CallableByContract, CallableByPrecompile), >, PrecompileAt< AddressU64<2069>, PrecompileRegistry, (CallableByContract, CallableByPrecompile), >, PrecompileAt< AddressU64<2072>, IdentityPrecompile, (CallableByContract, CallableByPrecompile), >, PrecompileAt, FileSystemPrecompile>, ); /// The PrecompileSet installed in the DataHaven runtime. /// We include the nine Istanbul precompiles /// (https://github.com/ethereum/go-ethereum/blob/3c46f557/core/vm/contracts.go#L69) /// 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 DataHaven specific /// 2048-4095 DataHaven specific precompiles pub type DataHavenPrecompiles = PrecompileSetBuilder< R, ( // Skip precompiles if out of range. PrecompilesInRangeInclusive<(AddressU64<1>, AddressU64<4095>), DataHavenPrecompilesAt>, ), >;