├── src ├── assets │ ├── .gitkeep │ ├── icon-48x48.png │ └── icon-256x256.png ├── favicon.ico ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── blazor │ └── dapp-wasm │ │ ├── dapp-wasm │ │ ├── Pages │ │ │ ├── Index.razor │ │ │ ├── GenerateAddresses.razor │ │ │ ├── ParseData.razor │ │ │ ├── SignMessage.razor │ │ │ └── FetchData.razor │ │ ├── wwwroot │ │ │ ├── favicon.png │ │ │ ├── icon-192.png │ │ │ ├── css │ │ │ │ ├── open-iconic │ │ │ │ │ ├── font │ │ │ │ │ │ ├── fonts │ │ │ │ │ │ │ ├── open-iconic.eot │ │ │ │ │ │ │ ├── open-iconic.otf │ │ │ │ │ │ │ ├── open-iconic.ttf │ │ │ │ │ │ │ └── open-iconic.woff │ │ │ │ │ │ └── css │ │ │ │ │ │ │ └── open-iconic-bootstrap.min.css │ │ │ │ │ ├── ICON-LICENSE │ │ │ │ │ ├── README.md │ │ │ │ │ └── FONT-LICENSE │ │ │ │ └── app.css │ │ │ ├── sample-data │ │ │ │ └── weather.json │ │ │ └── index.html │ │ ├── Networks │ │ │ ├── CityMain.cs │ │ │ ├── Networks.cs │ │ │ ├── BitcoinMain.cs │ │ │ └── StraxMain.cs │ │ ├── Data │ │ │ ├── BlockData.cs │ │ │ ├── ToStringJsonConverter.cs │ │ │ ├── BtcDecimalJsonConverter.cs │ │ │ └── TransactionModel.cs │ │ ├── _Imports.razor │ │ ├── Shared │ │ │ ├── MainLayout.razor │ │ │ ├── NavMenu.razor.css │ │ │ ├── MainLayout.razor.css │ │ │ └── NavMenu.razor │ │ ├── Program.cs │ │ ├── App.razor │ │ ├── dapp-wasm.csproj │ │ └── Properties │ │ │ └── launchSettings.json │ │ ├── Blockcore.MetaMask │ │ ├── _Imports.razor │ │ ├── Exceptions │ │ │ ├── NoMetaMaskException.cs │ │ │ └── UserDeniedException.cs │ │ ├── ServiceCollectionExtensions.cs │ │ ├── Enums │ │ │ └── Chain.cs │ │ ├── Extensions │ │ │ ├── HexExtensions.cs │ │ │ └── SendTransactionExtensions.cs │ │ ├── Blockcore.MetaMask.csproj │ │ ├── Models │ │ │ └── TypedDataPayload.cs │ │ ├── IMetaMaskService.cs │ │ ├── Metamask.razor │ │ ├── wwwroot │ │ │ └── metaMask.js │ │ ├── MetaMaskService.cs │ │ └── Metamask.razor.cs │ │ ├── Blockcore.AtomicSwaps.BlockcoreDns │ │ ├── _Imports.razor │ │ ├── Models │ │ │ ├── NsResult.cs │ │ │ ├── DnsServices.cs │ │ │ └── DnsResult.cs │ │ ├── ServiceCollectionExtensions.cs │ │ ├── IBlockcoreDnsService.cs │ │ ├── Blockcore.AtomicSwaps.BlockcoreDns.csproj │ │ ├── Toolkit │ │ │ └── JsonToolKit.cs │ │ ├── BlockcoreDns.razor │ │ ├── BlockcoreDns.razor.cs │ │ └── BlockcoreDnsService.cs │ │ ├── Blockcore.AtomicSwaps.BlockcoreWallet │ │ ├── _Imports.razor │ │ ├── Exceptions │ │ │ ├── UserDeniedException.cs │ │ │ └── NoBlockcoreWalletException.cs │ │ ├── ServiceCollectionExtensions.cs │ │ ├── Blockcore.AtomicSwaps.BlockcoreWallet.csproj │ │ ├── IBlockcoreWalletConnector.cs │ │ ├── BlockcoreWallet.razor │ │ ├── BlockcoreWallet.razor.cs │ │ ├── wwwroot │ │ │ └── blockcoreWallet.js │ │ ├── BlockcoreWalletModels.cs │ │ └── BlockcoreWalletConnector.cs │ │ └── dapp-wasm.sln ├── styles.css ├── webpack.config.js ├── app │ ├── app-routing.module.ts │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.module.ts │ └── app.component.ts ├── main.ts ├── styles.scss ├── index.html ├── test.ts └── polyfills.ts ├── .vscode ├── extensions.json ├── launch.json └── tasks.json ├── tsconfig.app.json ├── .editorconfig ├── tsconfig.spec.json ├── .browserslistrc ├── .github └── workflows │ └── gh-pages.yml ├── tsconfig.json ├── LICENSE ├── .gitignore ├── karma.conf.js ├── package.json ├── README.md └── angular.json /src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/favicon.ico -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/assets/icon-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/assets/icon-48x48.png -------------------------------------------------------------------------------- /src/assets/icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/assets/icon-256x256.png -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Index 4 | 5 |

Blockcore blazor dapps examples

6 | 7 | 8 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/blazor/dapp-wasm/dapp-wasm/wwwroot/favicon.png -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Networks/CityMain.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/blazor/dapp-wasm/dapp-wasm/Networks/CityMain.cs -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/wwwroot/icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/blazor/dapp-wasm/dapp-wasm/wwwroot/icon-192.png -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template", "esbenp.prettier-vscode"] 4 | } 5 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | html, body { height: 100%; } 4 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } 5 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Data/BlockData.cs: -------------------------------------------------------------------------------- 1 | namespace Data; 2 | 3 | public class BlockData 4 | { 5 | public string blockHash { get; set; } 6 | 7 | public int blockIndex { get; set; } 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/blazor/dapp-wasm/dapp-wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/blazor/dapp-wasm/dapp-wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/blazor/dapp-wasm/dapp-wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/super-devninja/dapp-sample/HEAD/src/blazor/dapp-wasm/dapp-wasm/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /src/webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | resolve: { 3 | fallback: { 4 | // buffer: require.resolve("buffer/"), 5 | stream: require.resolve("stream-browserify"), 6 | // crypto: require.resolve("crypto-browserify"), 7 | }, 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | 4 | const routes: Routes = []; 5 | 6 | @NgModule({ 7 | imports: [RouterModule.forRoot(routes)], 8 | exports: [RouterModule] 9 | }) 10 | export class AppRoutingModule { } 11 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | max_line_length = 240 11 | 12 | [*.ts] 13 | quote_type = single 14 | 15 | [*.md] 16 | max_line_length = off 17 | trim_trailing_whitespace = false 18 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.MetaMask/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/Models/NsResult.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Blockcore.AtomicSwaps.BlockcoreDns.Models 9 | { 10 | public class NsResult 11 | { 12 | [JsonProperty("url")] 13 | public string Url { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using dapp_wasm 10 | @using dapp_wasm.Shared 11 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/Models/DnsServices.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Blockcore.AtomicSwaps.BlockcoreDns.Models 9 | { 10 | public class DnsServices 11 | { 12 | public string Url { get; set; } 13 | public List DnsResults { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Blockcore.AtomicSwaps.BlockcoreDns 4 | { 5 | public static class ServiceCollectionExtensions 6 | { 7 | public static void AddBlockcoreDns(this IServiceCollection services) 8 | { 9 | services.AddScoped(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.MetaMask/Exceptions/NoMetaMaskException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Blockcore.AtomicSwaps.MetaMask.Exceptions 8 | { 9 | public class NoMetaMaskException : ApplicationException 10 | { 11 | public NoMetaMaskException() : base("MetaMask is not installed.") 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.MetaMask/Exceptions/UserDeniedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Blockcore.AtomicSwaps.MetaMask.Exceptions 8 | { 9 | public class UserDeniedException : ApplicationException 10 | { 11 | public UserDeniedException() : base("User denied access to MetaMask.") 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.MetaMask/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.JSInterop; 3 | 4 | namespace Blockcore.AtomicSwaps.MetaMask 5 | { 6 | public static class ServiceCollectionExtensions 7 | { 8 | public static void AddMetaMask(this IServiceCollection services) 9 | { 10 | services.AddScoped(sp => new MetaMaskService(sp.GetRequiredService())); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/Exceptions/UserDeniedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Blockcore.AtomicSwaps.BlockcoreWallet.Exceptions 8 | { 9 | public class UserDeniedException : ApplicationException 10 | { 11 | public UserDeniedException() : base("User denied access to BlockcoreWallet.") 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | html, 4 | body { 5 | height: 100%; 6 | } 7 | body { 8 | margin: 0; 9 | background-color: #303030; 10 | font-family: Roboto, "Helvetica Neue", sans-serif; 11 | } 12 | 13 | .page { 14 | max-width: 1200px; 15 | margin-left: auto; 16 | margin-right: auto; 17 | padding-left: 1em; 18 | padding-right: 1em; 19 | } 20 | 21 | a { 22 | color: white; 23 | } 24 | 25 | a:hover { 26 | color: silver; 27 | } -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/Exceptions/NoBlockcoreWalletException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Blockcore.AtomicSwaps.BlockcoreWallet.Exceptions 8 | { 9 | public class NoBlockcoreWalletException : ApplicationException 10 | { 11 | public NoBlockcoreWalletException() : base("BlockcoreWallet is not installed.") 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/Models/DnsResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Blockcore.AtomicSwaps.BlockcoreDns.Models 8 | { 9 | public class DnsResult 10 | { 11 | public string Domain { get; set; } 12 | public string Symbol { get; set; } 13 | public string Service { get; set; } 14 | public int Ttl { get; set; } 15 | public bool Online { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.JSInterop; 3 | 4 | namespace Blockcore.AtomicSwaps.BlockcoreWallet 5 | { 6 | public static class ServiceCollectionExtensions 7 | { 8 | public static void AddBlockcoreWallet(this IServiceCollection services) 9 | { 10 | services.AddScoped(sp => new BlockcoreWalletConnector(sp.GetRequiredService())); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "pwa-chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Program.cs: -------------------------------------------------------------------------------- 1 | using Blockcore.AtomicSwaps.MetaMask; 2 | using dapp_wasm; 3 | using Microsoft.AspNetCore.Components.Web; 4 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 5 | 6 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 7 | builder.RootComponents.Add("#app"); 8 | builder.RootComponents.Add("head::after"); 9 | 10 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 11 | 12 | builder.Services.AddMetaMask(); 13 | 14 | await builder.Build().RunAsync(); 15 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/wwwroot/sample-data/weather.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "date": "2022-01-06", 4 | "temperatureC": 1, 5 | "summary": "Freezing" 6 | }, 7 | { 8 | "date": "2022-01-07", 9 | "temperatureC": 14, 10 | "summary": "Bracing" 11 | }, 12 | { 13 | "date": "2022-01-08", 14 | "temperatureC": -13, 15 | "summary": "Freezing" 16 | }, 17 | { 18 | "date": "2022-01-09", 19 | "temperatureC": -16, 20 | "summary": "Balmy" 21 | }, 22 | { 23 | "date": "2022-01-10", 24 | "temperatureC": -2, 25 | "summary": "Chilly" 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.MetaMask/Enums/Chain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Blockcore.AtomicSwaps.MetaMask.Enums 8 | { 9 | /// 10 | /// https://docs.metamask.io/guide/ethereum-provider.html#chain-ids 11 | /// 12 | public enum Chain 13 | { 14 | Mainnet = 1, 15 | Ropsten = 3, 16 | Rinkeby = 4, 17 | Goerli = 5, 18 | Kovan = 42, 19 | BinanceSmartChain = 56, 20 | BinanceTestnet = 97 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/App.razor: -------------------------------------------------------------------------------- 1 | @using Blockcore.MetaMask 2 | 6 | 7 | 8 | 9 | 10 | 11 | Not found 12 | 13 |

Sorry, there's nothing at this address.

14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | .example-spacer { 2 | width: 50px; 3 | } 4 | 5 | .logo { 6 | margin-left: auto; 7 | margin-right: auto; 8 | width: 100%; 9 | max-width: 256px; 10 | } 11 | 12 | .actions button { 13 | margin-right: 0.6em; 14 | margin-bottom: 0.6em; 15 | } 16 | 17 | .input-full-width { 18 | width: 100%; 19 | } 20 | 21 | .card { 22 | margin-bottom: 1em; 23 | } 24 | 25 | .long { 26 | word-wrap: break-word; 27 | } 28 | 29 | .blockcore-logo { 30 | margin: 0 4px 3px 0; 31 | height: 48px; 32 | vertical-align: middle; 33 | } 34 | .fill-remaining-space { 35 | flex: 1 1 auto; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Blockcore DApp Sample 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/IBlockcoreDnsService.cs: -------------------------------------------------------------------------------- 1 | 2 | using Blockcore.AtomicSwaps.BlockcoreDns.Models; 3 | using System.Collections.Generic; 4 | using System.Net; 5 | using System.Threading.Tasks; 6 | 7 | namespace Blockcore.AtomicSwaps.BlockcoreDns 8 | { 9 | public interface IBlockcoreDnsService 10 | { 11 | string GetDnsServiceUrl(); 12 | ValueTask> GetNsServices(string url); 13 | ValueTask> GetServicesByType(string type); 14 | ValueTask> GetServicesByNetwork(string network); 15 | ValueTask> GetServicesByTypeAndNetwork(string type, string network); 16 | } 17 | } -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/dapp-wasm.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | (id: string): T; 13 | keys(): string[]; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | ); 22 | 23 | // Then we find all the tests. 24 | const context = require.context('./', true, /\.spec\.ts$/); 25 | // And load the modules. 26 | context.keys().forEach(context); 27 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Data/ToStringJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace Blockcore.Controllers.Converters 5 | { 6 | public class ToStringJsonConverter : JsonConverter 7 | { 8 | public override bool CanConvert(Type objectType) 9 | { 10 | return true; 11 | } 12 | 13 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 14 | { 15 | writer.WriteValue(value.ToString()); 16 | } 17 | 18 | public override bool CanRead 19 | { 20 | get { return false; } 21 | } 22 | 23 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/Blockcore.AtomicSwaps.BlockcoreWallet.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | nullable 7 | True 8 | True 9 | Blockcore 10 | 1.0.0 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /.github/workflows/gh-pages.yml: -------------------------------------------------------------------------------- 1 | name: github pages 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | jobs: 10 | deploy: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | 15 | - name: Setup Node 16 | uses: actions/setup-node@v1 17 | with: 18 | node-version: '18.x' 19 | 20 | - name: Cache dependencies 21 | uses: actions/cache@v1 22 | with: 23 | path: ~/.npm 24 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 25 | restore-keys: | 26 | ${{ runner.os }}-node- 27 | - run: npm ci 28 | - run: npm run build 29 | 30 | - name: Deploy 31 | uses: peaceiris/actions-gh-pages@v3 32 | with: 33 | github_token: ${{ secrets.GITHUB_TOKEN }} 34 | publish_dir: ./dist/dapp-sample 35 | cname: dapp.blockcore.net -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.MetaMask/Extensions/HexExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Numerics; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Blockcore.AtomicSwaps.MetaMask.Extensions 9 | { 10 | public static class HexExtensions 11 | { 12 | public static long HexToInt(this string hexString) 13 | { 14 | if (hexString.StartsWith("0x")) 15 | hexString = hexString[2..]; 16 | 17 | return long.Parse(hexString, System.Globalization.NumberStyles.HexNumber); 18 | } 19 | public static BigInteger HexToBigInteger(this string hexString) 20 | { 21 | if (hexString.StartsWith("0x")) 22 | hexString = hexString[2..]; 23 | 24 | return BigInteger.Parse(hexString, System.Globalization.NumberStyles.HexNumber); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/Blockcore.AtomicSwaps.BlockcoreDns.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | True 6 | True 7 | Blockcore 8 | 1.0.0 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.MetaMask/Blockcore.MetaMask.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | nullable 7 | True 8 | True 9 | Blockcore 10 | 1.0.0 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitOverride": true, 10 | "noPropertyAccessFromIndexSignature": true, 11 | "noImplicitReturns": true, 12 | "noFallthroughCasesInSwitch": true, 13 | "sourceMap": true, 14 | "declaration": false, 15 | "downlevelIteration": true, 16 | "experimentalDecorators": true, 17 | "moduleResolution": "node", 18 | "importHelpers": true, 19 | "target": "es2020", 20 | "module": "es2020", 21 | "lib": [ 22 | "es2020", 23 | "dom" 24 | ] 25 | }, 26 | "angularCompilerOptions": { 27 | "enableI18nLegacyMessageIdFormat": false, 28 | "strictInjectionParameters": true, 29 | "strictInputAccessModifiers": true, 30 | "strictTemplates": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:1072", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "http": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 16 | "applicationUrl": "http://localhost:5152", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | dapp-wasm 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 |
22 |
23 | 24 |
25 | An unhandled error has occurred. 26 | Reload 27 | 🗙 28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Blockcore 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async () => { 7 | await TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | }); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'dapp-sample'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('dapp-sample'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement as HTMLElement; 33 | expect(compiled.querySelector('.content span')?.textContent).toContain('dapp-sample app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Networks/Networks.cs: -------------------------------------------------------------------------------- 1 | using Blockcore.Networks.Bitcoin; 2 | using Blockcore.Networks.Strax; 3 | 4 | namespace Blockcore.Networks 5 | { 6 | public static class Networks 7 | { 8 | public static Dictionary NetworkItems { get; } = new() 9 | { 10 | { "STRAX", Blockcore.Networks.Networks.Strax.Mainnet() }, 11 | { "CITY", Blockcore.Networks.Networks.City.Mainnet() }, 12 | { "BTC", Blockcore.Networks.Networks.Bitcoin.Mainnet() }, 13 | }; 14 | 15 | public static NetworksSelector Bitcoin 16 | { 17 | get 18 | { 19 | return new NetworksSelector(() => new BitcoinMain(), () => null, () => null); 20 | } 21 | } 22 | 23 | public static NetworksSelector Strax 24 | { 25 | get 26 | { 27 | return new NetworksSelector(() => new StraxMain(), () => null, () => null); 28 | } 29 | } 30 | 31 | public static NetworksSelector City 32 | { 33 | get 34 | { 35 | return new NetworksSelector(() => new City.Networks.CityMain(), () => null, () => null); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/Toolkit/JsonToolKit.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Linq; 6 | using System.Net.Http; 7 | using System.Text; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | 11 | 12 | namespace Blockcore.AtomicSwaps.BlockcoreDns.Toolkit 13 | { 14 | public class JsonToolKit where T : class 15 | { 16 | public T ConverJsonToObject(string json) 17 | { 18 | var result = JsonConvert.DeserializeObject(json); 19 | return result; 20 | } 21 | 22 | public async Task DownloadAndConverJsonToObjectAsync(string Url) 23 | { 24 | try 25 | { 26 | using (var httpClient = new HttpClient()) 27 | { 28 | Uri uri = new Uri(Url); 29 | var json = await httpClient.GetStringAsync(uri); 30 | var result = JsonConvert.DeserializeObject(json); 31 | return result; 32 | } 33 | } 34 | catch 35 | { 36 | return null; 37 | } 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | /src/blazor/dapp-wasm/.vs/dapp-wasm 44 | /src/blazor/dapp-wasm/dapp-wasm/obj 45 | /src/blazor/dapp-wasm/.vs/ProjectEvaluation 46 | /src/blazor/dapp-wasm/dapp-wasm/bin/Debug/net7.0 47 | /src/blazor/dapp-wasm/Blockcore.MetaMask/bin 48 | /src/blazor/dapp-wasm/Blockcore.MetaMask/obj 49 | /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/obj 50 | /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/obj 51 | /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/Script/node_modules/.bin 52 | /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/Script/node_modules 53 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreDns/BlockcoreDns.razor: -------------------------------------------------------------------------------- 1 | @page "/blockcoredns" 2 | @using Blockcore.AtomicSwaps.BlockcoreDns 3 | @using Microsoft.JSInterop 4 | @inject IJSRuntime JSRuntime; 5 | 6 | Blockcore Dns 7 | 8 |

Blockcore Dns!

9 | 10 | 11 |
@blockcoreDnsUrl
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |
22 | @if (services != null) 23 | { 24 | foreach (var ns in services) 25 | { 26 |

@ns.Url

27 | @foreach (var dr in ns.DnsResults) 28 | { 29 |
    30 | @if (!dr.Online) 31 | { 32 | textColor = "text-danger"; 33 | } 34 | else{ 35 | textColor = "text-success"; 36 | } 37 |
  • 38 | @dr.Domain 39 |
  • 40 |
41 | } 42 | } 43 | } 44 | 45 |
46 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/IBlockcoreWalletConnector.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.JSInterop; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Numerics; 5 | using System.Threading.Tasks; 6 | 7 | namespace Blockcore.AtomicSwaps.BlockcoreWallet 8 | { 9 | public interface IBlockcoreWalletConnector 10 | { 11 | 12 | ValueTask ConnectBlockcoreWallet(); 13 | ValueTask DisposeAsync(); 14 | ValueTask HasBlockcoreWallet(); 15 | ValueTask IsSiteConnected(); 16 | ValueTask SignMessageAnyAccount(string value); 17 | ValueTask GetWallet(string? key = null); 18 | ValueTask GetSwapKey(string key, string walletId, string accountId, bool includePrivateKey); 19 | ValueTask GetSwapSecret(string key, string walletId, string accountId, string message); 20 | ValueTask SignMessageAnyAccountJson(string value); 21 | ValueTask PaymentRequest(string network, string amount); 22 | ValueTask DIDSupportedMethods(); 23 | ValueTask DIDRequest(string[] methods); 24 | ValueTask SignMessage(string msg); 25 | ValueTask SendCoins(BlockcoreWalletSendFunds data); 26 | ValueTask SwapCoins(BlockcoreWalletSwapCoins data); 27 | } 28 | } -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 7 | import { MatToolbarModule } from '@angular/material/toolbar'; 8 | import { MatIconModule } from '@angular/material/icon'; 9 | import { MatButtonModule } from '@angular/material/button'; 10 | import { MatCommonModule } from '@angular/material/core'; 11 | import { MatCardModule } from '@angular/material/card'; 12 | import { MatInputModule } from '@angular/material/input'; 13 | import { MatFormFieldModule } from '@angular/material/form-field'; 14 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 15 | import { MatSelectModule } from '@angular/material/select'; 16 | import { MatTabsModule } from '@angular/material/tabs'; 17 | 18 | @NgModule({ 19 | declarations: [AppComponent], 20 | imports: [ 21 | BrowserModule, 22 | FormsModule, 23 | MatTabsModule, 24 | ReactiveFormsModule, 25 | AppRoutingModule, 26 | BrowserAnimationsModule, 27 | MatCommonModule, 28 | MatSelectModule, 29 | MatToolbarModule, 30 | MatIconModule, 31 | MatButtonModule, 32 | MatCardModule, 33 | MatInputModule, 34 | MatFormFieldModule, 35 | ], 36 | providers: [], 37 | bootstrap: [AppComponent], 38 | }) 39 | export class AppModule {} 40 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Pages/GenerateAddresses.razor: -------------------------------------------------------------------------------- 1 | @page "/generateaddresses" 2 | 3 | Blockcore Atomic Swaps 4 | 5 |

Blockcore Atomic Swaps

6 | 7 | Welcome to your new app.

8 | 9 | @**@ 10 | 11 |

@address

12 |

@address1

13 |

@address2

14 |

@address3

15 | 16 | 17 | 18 | 19 | @code { 20 | private string address = ""; 21 | private string address1 = ""; 22 | private string address2 = ""; 23 | private string address3 = ""; 24 | private void IncrementCount() 25 | { 26 | var netwrok = Blockcore.Networks.Networks.Strax.Mainnet(); 27 | var netwrok1 = Blockcore.Networks.Networks.Bitcoin.Mainnet(); 28 | var netwrok2 = Blockcore.Networks.Networks.City.Mainnet(); 29 | 30 | var key = new NBitcoin.Key(); 31 | address = netwrok.Name + " : " + key.PubKey.GetSegwitAddress(netwrok).ToString() + " - " + key.PubKey.GetAddress(netwrok).ToString(); 32 | address1 = netwrok1.Name + " : " + key.PubKey.GetSegwitAddress(netwrok1).ToString() + " - " + key.PubKey.GetAddress(netwrok1).ToString(); 33 | address2 = netwrok2.Name + " : " + key.PubKey.GetSegwitAddress(netwrok2).ToString() + " - " + key.PubKey.GetAddress(netwrok2).ToString(); 34 | 35 | 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | 63 | .nav-scrollable { 64 | /* Allow sidebar to scroll for tall menus */ 65 | height: calc(100vh - 3.5rem); 66 | overflow-y: auto; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/dapp-sample'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.MetaMask/Models/TypedDataPayload.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Numerics; 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace Blockcore.AtomicSwaps.MetaMask.Models 7 | { 8 | public record struct Message(string contents); 9 | 10 | 11 | public class TypedDataPayload 12 | { 13 | public Dictionary Types { get; set; } = new(); 14 | public string? PrimaryType { get; set; } 15 | public Domain? Domain { get; set; } 16 | public T? Message { get; set; } 17 | 18 | 19 | public string ToJson() 20 | { 21 | var serializerSettings = new JsonSerializerSettings 22 | { 23 | ContractResolver = new CamelCasePropertyNamesContractResolver() 24 | { 25 | NamingStrategy = new CamelCaseNamingStrategy() 26 | { 27 | ProcessDictionaryKeys = false 28 | } 29 | }, 30 | 31 | DefaultValueHandling = DefaultValueHandling.Ignore 32 | }; 33 | return JsonConvert.SerializeObject(this, serializerSettings); 34 | } 35 | } 36 | 37 | public class Domain 38 | { 39 | public string? Name { get; set; } 40 | public string? Version { get; set; } 41 | public BigInteger? ChainId { get; set; } 42 | } 43 | 44 | public class TypeMemberValue 45 | { 46 | public string? Name { get; set; } 47 | public string? Type { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dapp-sample", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "^14.2.0", 14 | "@angular/cdk": "^14.2.6", 15 | "@angular/common": "^14.2.0", 16 | "@angular/compiler": "^14.2.0", 17 | "@angular/core": "^14.2.0", 18 | "@angular/forms": "^14.2.0", 19 | "@angular/material": "^14.2.6", 20 | "@angular/platform-browser": "^14.2.0", 21 | "@angular/platform-browser-dynamic": "^14.2.0", 22 | "@angular/router": "^14.2.0", 23 | "@blockcore/did-resolver": "^0.0.3", 24 | "@blockcore/provider": "^0.0.12", 25 | "@noble/hashes": "^1.1.5", 26 | "@noble/secp256k1": "^1.7.0", 27 | "bitcoinjs-message": "^2.2.0", 28 | "did-resolver": "^4.0.1", 29 | "rxjs": "~7.5.0", 30 | "stream-browserify": "^3.0.0", 31 | "tslib": "^2.3.0", 32 | "uuid": "^9.0.0", 33 | "zone.js": "~0.11.4" 34 | }, 35 | "devDependencies": { 36 | "@angular-builders/custom-webpack": "^14.0.1", 37 | "@angular-devkit/build-angular": "^14.2.7", 38 | "@angular/cli": "~14.2.7", 39 | "@angular/compiler-cli": "^14.2.0", 40 | "@types/jasmine": "~4.0.0", 41 | "jasmine-core": "~4.3.0", 42 | "karma": "~6.4.0", 43 | "karma-chrome-launcher": "~3.1.0", 44 | "karma-coverage": "~2.2.0", 45 | "karma-jasmine": "~5.1.0", 46 | "karma-jasmine-html-reporter": "~2.0.0", 47 | "typescript": "~4.7.2" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blockcore DApp Sample 2 | 3 | Decentralized application (DApp) that demonstrates interaction from third party apps and Blockcore ecosystem 4 | 5 | ## Resources 6 | 7 | [Verifiable Credentials Data Model v2.0](https://w3c.github.io/vc-data-model/) 8 | 9 | [Verifiable Credentials Implementation Guidelines 1.0](https://w3c.github.io/vc-imp-guide/) 10 | 11 | ## Inspiration 12 | 13 | This app will have similar features as the E2E Test Dapp for MetaMask: [https://metamask.github.io/test-dapp/](https://metamask.github.io/test-dapp/) 14 | 15 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.2.7. 16 | 17 | ## Development server 18 | 19 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. 20 | 21 | ## Code scaffolding 22 | 23 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 24 | 25 | ## Build 26 | 27 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 28 | 29 | ## Running unit tests 30 | 31 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 32 | 33 | ## Running end-to-end tests 34 | 35 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 36 | 37 | ## Further help 38 | 39 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 40 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row:not(.auth) { 41 | display: none; 42 | } 43 | 44 | .top-row.auth { 45 | justify-content: space-between; 46 | } 47 | 48 | .top-row ::deep a, .top-row ::deep .btn-link { 49 | margin-left: 0; 50 | } 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .page { 55 | flex-direction: row; 56 | } 57 | 58 | .sidebar { 59 | width: 250px; 60 | height: 100vh; 61 | position: sticky; 62 | top: 0; 63 | } 64 | 65 | .top-row { 66 | position: sticky; 67 | top: 0; 68 | z-index: 1; 69 | } 70 | 71 | .top-row.auth ::deep a:first-child { 72 | flex: 1; 73 | text-align: right; 74 | width: 0; 75 | } 76 | 77 | .top-row, article { 78 | padding-left: 2rem !important; 79 | padding-right: 1.5rem !important; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Pages/ParseData.razor: -------------------------------------------------------------------------------- 1 | @page "/parsedata" 2 | @using System.Text.Json 3 | @using Blockcore.Controllers.Models 4 | @using Blockcore.Networks 5 | 6 | Parse Data 7 | 8 |

Parse Data

9 | 10 |

Transaction Hex

11 | 12 | 27 | 28 |

@error

29 | 30 | @code { 31 | public string TransactionHex { get; set; } = string.Empty; 32 | string error; 33 | 34 | 35 | public string Result { get; set; } = string.Empty; 36 | 37 | List NetworkList; 38 | Network network; 39 | string selectedNetwork; 40 | 41 | protected override async Task OnInitializedAsync() 42 | { 43 | NetworkList = Networks.NetworkItems.Keys.ToList(); 44 | } 45 | 46 | 47 | 48 | private void ParseTransaction() 49 | { 50 | if (string.IsNullOrEmpty(TransactionHex)) 51 | { 52 | error = "set trx hex"; 53 | return; 54 | } 55 | 56 | network = Networks.NetworkItems[selectedNetwork]; 57 | 58 | var trx = network.Consensus.ConsensusFactory.CreateTransaction(TransactionHex); 59 | 60 | var parsed = new TransactionVerboseModel(trx, network); 61 | Result = JsonSerializer.Serialize(parsed, new JsonSerializerOptions { WriteIndented = true, }); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/Blockcore.AtomicSwaps.BlockcoreWallet/BlockcoreWallet.razor: -------------------------------------------------------------------------------- 1 | @page "/blockcorewallet" 2 | @using Microsoft.JSInterop 3 | @inject IJSRuntime JSRuntime; 4 | 5 | Blockcore Wallet 6 | 7 |

Blockcore Wallet!

8 | @if (!HasBlockcoreWallet) 9 | { 10 |

No Blockcore Wallet detected. Please install Blockcore Wallet.

11 | } 12 | else 13 | { 14 | 15 |
16 |
17 |

@SignedMessage

18 |
19 | 20 |
21 | 22 | 23 |
24 |
25 |

@SignedMessageAnyAccount

26 |
27 | 28 |
29 | 30 | 31 |
32 |
33 |

@SignedMessageAnyAccountJson

34 |
35 | 36 |
37 | 38 | 39 |
40 |
41 |

@PaymentRequestResult

42 |
43 | 44 |
45 | 46 | 47 |
48 |
49 |

@DIDSupportedMethodsResult

50 |
51 | 52 |
53 | 54 | 55 |
56 |
57 |

@DIDRequestResult

58 |
59 | 60 | 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/blazor/dapp-wasm/dapp-wasm/Pages/SignMessage.razor: -------------------------------------------------------------------------------- 1 | @page "/signmessage" 2 | @using Blockcore.Networks 3 | 4 | Message Signing 5 | 6 |

Message Signing

7 | 8 |

Private key

9 | 10 |