nft-faucet/NftFaucet/Program.cs

120 lines
5.0 KiB
C#
Raw Normal View History

2022-08-02 15:24:07 -05:00
using Ethereum.MetaMask.Blazor;
2022-03-31 19:55:58 +02:00
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
2022-03-31 22:16:43 +02:00
using NftFaucet.Options;
using NftFaucet.Services;
2022-09-29 23:11:55 -05:00
using NftFaucet;
2022-10-02 13:30:56 -05:00
using NftFaucet.Domain.Services;
using NftFaucet.Infrastructure.Models.State;
using NftFaucet.Infrastructure.Repositories;
using NftFaucet.Infrastructure.Services;
2022-09-29 23:11:55 -05:00
using Radzen;
using TG.Blazor.IndexedDB;
2022-03-31 19:55:58 +02:00
var builder = WebAssemblyHostBuilder.CreateDefault(args);
2022-03-31 22:16:43 +02:00
2022-09-29 23:11:55 -05:00
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
2022-03-31 22:16:43 +02:00
var settings = new Settings();
builder.Configuration.Bind(settings);
builder.Services.AddSingleton(settings);
2022-09-29 23:11:55 -05:00
builder.Services.AddScoped(sp => new HttpClient {BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)});
builder.Services.AddSingleton<PluginLoader>();
builder.Services.AddSingleton<Mapper>();
2022-10-02 13:30:56 -05:00
builder.Services.AddScoped<ITokenMetadataGenerator, TokenMetadataGenerator>();
builder.Services.AddScoped<IInitializationService, InitializationService>();
builder.Services.AddScoped<IStateRepository, StateRepository>();
2022-03-31 22:16:43 +02:00
builder.Services.AddScoped<ScopedAppState>();
builder.Services.AddScoped<RefreshMediator>();
2022-10-02 13:30:56 -05:00
// add Radzen components
2022-09-29 23:11:55 -05:00
builder.Services.AddScoped<DialogService>();
builder.Services.AddScoped<NotificationService>();
builder.Services.AddScoped<TooltipService>();
builder.Services.AddScoped<ContextMenuService>();
2022-10-02 13:30:56 -05:00
2022-03-31 21:05:03 +02:00
builder.Services.AddMetaMaskBlazor();
2022-03-31 19:55:58 +02:00
2022-09-29 23:11:55 -05:00
builder.Services.AddIndexedDB(dbStore =>
{
dbStore.DbName = "NftFaucet";
2022-09-30 05:44:25 -05:00
dbStore.Version = 1;
2022-09-29 23:11:55 -05:00
dbStore.Stores.Add(new StoreSchema
{
Name = "AppState",
PrimaryKey = new IndexSpec { Name = "id", KeyPath = "id", Auto = true },
Indexes = new List<IndexSpec>
{
new IndexSpec {Name = "selectedNetwork", KeyPath = "selectedNetwork", Auto = false},
2022-10-02 20:55:07 -05:00
new IndexSpec {Name = "selectedWallet", KeyPath = "selectedWallet", Auto = false},
2022-09-29 23:11:55 -05:00
new IndexSpec {Name = "selectedContract", KeyPath = "selectedContract", Auto = false},
new IndexSpec {Name = "selectedToken", KeyPath = "selectedToken", Auto = false},
new IndexSpec {Name = "selectedUploadLocation", KeyPath = "selectedUploadLocation", Auto = false},
new IndexSpec {Name = "destinationAddress", KeyPath = "destinationAddress", Auto = false},
new IndexSpec {Name = "tokenAmount", KeyPath = "tokenAmount", Auto = false},
}
});
dbStore.Stores.Add(new StoreSchema
{
Name = "Tokens",
PrimaryKey = new IndexSpec { Name = "id", KeyPath = "id", Auto = true },
Indexes = new List<IndexSpec>
{
new IndexSpec {Name = "name", KeyPath = "name", Auto = false},
new IndexSpec {Name = "description", KeyPath = "description", Auto = false},
new IndexSpec {Name = "createdAt", KeyPath = "createdAt", Auto = false},
2022-09-30 04:51:30 -05:00
new IndexSpec {Name = "mainFileName", KeyPath = "mainFileName", Auto = false},
new IndexSpec {Name = "mainFileType", KeyPath = "mainFileType", Auto = false},
new IndexSpec {Name = "mainFileData", KeyPath = "mainFileData", Auto = false},
new IndexSpec {Name = "mainFileSize", KeyPath = "mainFileSize", Auto = false},
new IndexSpec {Name = "coverFileName", KeyPath = "coverFileName", Auto = false},
new IndexSpec {Name = "coverFileType", KeyPath = "coverFileType", Auto = false},
new IndexSpec {Name = "coverFileData", KeyPath = "coverFileData", Auto = false},
new IndexSpec {Name = "coverFileSize", KeyPath = "coverFileSize", Auto = false},
2022-09-29 23:11:55 -05:00
}
});
dbStore.Stores.Add(new StoreSchema
{
Name = "UploadLocations",
PrimaryKey = new IndexSpec { Name = "id", KeyPath = "id", Auto = true },
Indexes = new List<IndexSpec>
{
new IndexSpec {Name = "tokenId", KeyPath = "tokenId", Auto = false},
new IndexSpec {Name = "name", KeyPath = "name", Auto = false},
new IndexSpec {Name = "location", KeyPath = "location", Auto = false},
new IndexSpec {Name = "createdAt", KeyPath = "createdAt", Auto = false},
new IndexSpec {Name = "uploaderId", KeyPath = "uploaderId", Auto = false},
}
});
dbStore.Stores.Add(new StoreSchema
{
2022-10-02 20:55:07 -05:00
Name = "WalletStates",
2022-09-29 23:11:55 -05:00
PrimaryKey = new IndexSpec { Name = "id", KeyPath = "id", Auto = true },
Indexes = new List<IndexSpec>
{
new IndexSpec {Name = "state", KeyPath = "state", Auto = false},
}
});
dbStore.Stores.Add(new StoreSchema
{
Name = "UploaderStates",
PrimaryKey = new IndexSpec { Name = "id", KeyPath = "id", Auto = true },
Indexes = new List<IndexSpec>
{
new IndexSpec {Name = "state", KeyPath = "state", Auto = false},
}
});
});
var app = builder.Build();
2022-10-02 13:30:56 -05:00
var initializationService = app.Services.GetRequiredService<IInitializationService>();
2022-09-29 23:11:55 -05:00
await initializationService.Initialize();
await app.RunAsync();