DownloaderV3 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DownloaderV3 --version 1.0.0                
NuGet\Install-Package DownloaderV3 -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DownloaderV3" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DownloaderV3 --version 1.0.0                
#r "nuget: DownloaderV3, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DownloaderV3 as a Cake Addin
#addin nuget:?package=DownloaderV3&version=1.0.0

// Install DownloaderV3 as a Cake Tool
#tool nuget:?package=DownloaderV3&version=1.0.0                

DownloaderV3

DownloaderV3 is a powerful and flexible .NET library designed to download, decode, and process blockchain event data from sources like Covalent API. The project can be used to fetch blockchain logs, decode them, and store them in the destination of your choice.

Features

  • Modular design with support for multiple data sources and destination databases.
  • Extensible architecture allowing easy integration of new sources or event decoders.
  • Uses the factory pattern to create customizable documents and decoders.
  • Integrated with Entity Framework Core for managing database contexts.

Getting Started

Prerequisites

  • .NET 8.0 or later
  • Entity Framework Core 7.0 or later
  • Access to Covalent API or other blockchain data sources

Installation

Clone the repository and add it to your solution:

git clone https://github.com/The-Poolz/DownloaderV3.git

Or, if you've packaged it as a NuGet package:

dotnet add package DownloaderV3

The preferred way to use DownloaderV3 is to take advantage of .NET�s built-in dependency injection system (IServiceProvider). Here's how you can set it up:

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using DownloaderV3;
using DownloaderV3.Source.CovalentLastBlock;
using DownloaderV3.Destination;
using DownloaderV3.Source.CovalentDocument;
using DownloaderV3.Source.CovalentDocument.Document;
using DownloaderV3.Source.CovalentDocument.Document.DocumentDecoder;
using Microsoft.EntityFrameworkCore;

var services = new ServiceCollection();

// Registering required services and dependencies
services.AddLogging(config => config.AddConsole());

// Registering database context
services.AddDbContext<BaseDestination>(options =>
{
    options.UseInMemoryDatabase("InMemoryDb");
}, ServiceLifetime.Scoped);

// Registering necessary factories and classes
services.AddScoped<GetSourcePage, GetLastBlockCovalent>();
services.AddScoped<IDocumentFactory, DocumentFactory>();
services.AddScoped<IDocumentDecoderFactory, DocumentDecoderFactory>();

// Registering the main handler
services.AddScoped(typeof(DownloadHandler<>));

// Build the service provider
var serviceProvider = services.BuildServiceProvider();

// Create the DownloadHandler instance using dependency injection
var downloadHandler = serviceProvider.GetRequiredService<DownloadHandler<InputData>>();

// Start the download process
var results = await downloadHandler.HandleAsync();

// Output results
foreach (var result in results)
{
    Console.WriteLine(result.ToString());
}

Explanation

  • ServiceCollection Setup: This is where we register all the dependencies required for the DownloadHandler. This includes database contexts, factories, and the DownloadHandler itself.
  • BuildServiceProvider: Builds the service provider, which resolves dependencies at runtime.
  • HandleAsync(): Kicks off the downloading process and handles the blockchain data fetching and saving.

Key Classes

  • DownloadHandler<TData>: The main class that coordinates fetching, decoding, and saving data. It uses the IDocumentFactory to create documents, and the IDocumentDecoderFactory to process and save the data.

  • GetSourcePage: An abstract class that defines how to fetch the last block. Implementations like GetLastBlockCovalent provide the actual logic for different data sources.

  • BaseDestination: Manages the destination for storing the fetched data. This must be extended to create a custom destination that fits your specific data needs.

Example of Custom Destination

You can extend BaseDestination to create a custom destination where your data will be saved:

using DownloaderV3.Destination;
using Microsoft.EntityFrameworkCore;

public class CustomDestination : BaseDestination
{
    public CustomDestination(DbContextOptions<CustomDestination> options)
        : base(options) { }

    public DbSet<CustomEntity> CustomEntities { get; set; } = null!;
}

Contributing

We welcome contributions! Please feel free to submit issues, fork the repository, and send pull requests.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 113 10/16/2024
1.0.1 113 10/9/2024
1.0.0 107 9/26/2024

Release Notes for DownloaderV3 v1.0.1: