package io.novafoundation.nova.feature_wallet_impl.di.modules

import dagger.Lazy
import dagger.Module
import dagger.Provides
import io.novafoundation.nova.common.di.scope.FeatureScope
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.assets.AssetSource
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.assets.AssetSourceRegistry
import io.novafoundation.nova.feature_wallet_impl.data.network.blockchain.assets.TypeBasedAssetSourceRegistry
import io.novafoundation.nova.feature_wallet_impl.data.network.blockchain.assets.common.orml.OrmlAssetSourceFactory
import io.novafoundation.nova.feature_wallet_impl.data.network.blockchain.assets.events.evmErc20.EvmErc20EventDetectorFactory
import io.novafoundation.nova.feature_wallet_impl.data.network.blockchain.assets.events.orml.OrmlAssetEventDetectorFactory
import io.novafoundation.nova.feature_wallet_impl.data.network.blockchain.assets.events.statemine.StatemineAssetEventDetectorFactory
import io.novafoundation.nova.feature_wallet_impl.data.network.blockchain.assets.events.utility.NativeAssetEventDetector

@Module(
    includes = [
        NativeAssetsModule::class,
        StatemineAssetsModule::class,
        OrmlAssetsModule::class,
        EvmErc20AssetsModule::class,
        EvmNativeAssetsModule::class,
        EquilibriumAssetsModule::class,
        TronAssetsModule::class,
        BitcoinAssetsModule::class,
        SolanaAssetsModule::class,
        UnsupportedAssetsModule::class
    ]
)
class AssetsModule {

    @Provides
    @FeatureScope
    fun provideAssetSourceRegistry(
        @NativeAsset native: Lazy<AssetSource>,
        @StatemineAssets statemine: Lazy<AssetSource>,
        ormlFactory: Lazy<OrmlAssetSourceFactory>,
        @EvmErc20Assets evmErc20: Lazy<AssetSource>,
        @EvmNativeAssets evmNative: Lazy<AssetSource>,
        @EquilibriumAsset equilibrium: Lazy<AssetSource>,
        @TronNativeAssets tronNative: Lazy<AssetSource>,
        @Trc20Assets trc20: Lazy<AssetSource>,
        @BitcoinNativeAssets bitcoinNative: Lazy<AssetSource>,
        @SolanaNativeAssets solanaNative: Lazy<AssetSource>,
        @UnsupportedAssets unsupported: AssetSource,

        nativeAssetEventDetector: NativeAssetEventDetector,
        ormlAssetEventDetectorFactory: OrmlAssetEventDetectorFactory,
        statemineAssetEventDetectorFactory: StatemineAssetEventDetectorFactory,
        erc20EventDetectorFactory: EvmErc20EventDetectorFactory
    ): AssetSourceRegistry = TypeBasedAssetSourceRegistry(
        nativeSource = native,
        statemineSource = statemine,
        ormlSourceFactory = ormlFactory,
        evmErc20Source = evmErc20,
        evmNativeSource = evmNative,
        equilibriumAssetSource = equilibrium,
        tronNativeSource = tronNative,
        trc20Source = trc20,
        bitcoinNativeSource = bitcoinNative,
        solanaNativeSource = solanaNative,
        unsupportedBalanceSource = unsupported,

        nativeAssetEventDetector = nativeAssetEventDetector,
        ormlAssetEventDetectorFactory = ormlAssetEventDetectorFactory,
        statemineAssetEventDetectorFactory = statemineAssetEventDetectorFactory,
        erc20EventDetectorFactory = erc20EventDetectorFactory
    )
}
