Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            var walletId  = Environment.GetEnvironmentVariable("WALLET_ID") ?? Configuration["WALLET_ID"] ?? "mediator";
            var walletKey = Environment.GetEnvironmentVariable("WALLET_KEY") ?? Configuration["WALLET_KEY"] ?? "MyWalletKey";
            //var endpointUrl = Environment.GetEnvironmentVariable("ENDPOINT_HOST") ?? Configuration["ENDPOINT_HOST"] ?? "http://mediator";
            var endpointUrl = Environment.GetEnvironmentVariable("ENDPOINT_HOST") ?? Configuration["ENDPOINT_HOST"] ?? "http://localhost:5004";
            var genesisUrl  = Environment.GetEnvironmentVariable("GENESIS_URL") ?? Configuration["GENESIS_URL"] ?? Path.GetFullPath("pool_genesis.txn");

            var storageConfig = new WalletStorageConfiguration();

            storageConfig.Path = Path.Combine(Environment.CurrentDirectory, "wallet");

            services.AddAriesFramework(builder =>
            {
                builder.RegisterMediatorAgent(options =>
                {
                    // Agent endpoint. Use fully qualified endpoint.
                    options.EndpointUri = endpointUrl;
                    // The path to the genesis transaction file.
                    options.GenesisFilename = genesisUrl;
                    // The identifier of the wallet
                    options.WalletConfiguration = new WalletConfiguration {
                        Id = walletId, StorageConfiguration = storageConfig
                    };
                    // Secret key used to open the wallet.
                    options.WalletCredentials = new WalletCredentials {
                        Key = walletKey
                    };
                });
            });

            services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, "key")));
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();

            // Register agent framework dependency services and handlers
            var agentName   = Environment.GetEnvironmentVariable("AGENT_NAME") ?? Configuration["AGENT_NAME"] ?? "Krung Thai Bank";
            var walletId    = Environment.GetEnvironmentVariable("WALLET_ID") ?? Configuration["WALLET_ID"] ?? "ktb";
            var walletKey   = Environment.GetEnvironmentVariable("WALLET_KEY") ?? Configuration["WALLET_KEY"] ?? "MyWalletKey";
            var endpointUrl = Environment.GetEnvironmentVariable("ENDPOINT_HOST") ?? Configuration["ENDPOINT_HOST"] ?? "http://host.docker.internal:5000";
            // var genesisUrl = Environment.GetEnvironmentVariable("GENESIS_URL") ?? Configuration["GENESIS_URL"] ?? Path.GetFullPath("pool_genesis_local.txn");
            var genesisUrl = Environment.GetEnvironmentVariable("GENESIS_URL") ?? Configuration["GENESIS_URL"] ?? Path.GetFullPath("pool_genesis.txn");
            var poolName   = Environment.GetEnvironmentVariable("POOL_NAME") ?? Configuration["POOL_NAME"] ?? "KTBPool";

            var args = Environment.GetCommandLineArgs();

            if (args.Count() >= 4)
            {
                agentName   = args[1];
                walletId    = args[2];
                endpointUrl = args[3];
            }
            var imageUrl = Environment.GetEnvironmentVariable("IMAGE_URL") ?? Configuration["IMAGE_URL"] ?? $"{endpointUrl}/images/{walletId}.png";

            var storageConfig = new WalletStorageConfiguration();

            storageConfig.Path = Path.Combine(Environment.CurrentDirectory, "wallet");

            services.AddAriesFramework(builder => {
                builder.RegisterAgent <SimpleWebAgent>(c => {
                    c.AgentName = agentName;
                    // c.AgentImageUri = imageUrl;
                    c.EndpointUri         = endpointUrl;
                    c.WalletConfiguration = new WalletConfiguration {
                        Id = walletId, StorageConfiguration = storageConfig
                    };
                    c.WalletCredentials = new WalletCredentials {
                        Key = walletKey
                    };
                    c.GenesisFilename = genesisUrl;
                    c.PoolName        = poolName;
                });
            });

            services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, "key")));

            // Register custom handlers with DI pipeline
            services.AddSingleton <BasicMessageHandler>();
            services.AddSingleton <TrustPingMessageHandler>();
        }
Example #3
0
        private IHostBuilder CreateHostBuilder(string walletId, string agentName, string imageUrl, string endpointUri) =>
        Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder()
        .ConfigureServices((hostContext, services) =>
        {
            services.AddAriesFramework(builder =>
            {
                builder.RegisterEdgeAgent(options =>
                {
                    var storageConfig  = new WalletStorageConfiguration();
                    storageConfig.Path = Path.Combine(Environment.CurrentDirectory, "wallet");

                    options.AgentName = agentName;
                    // options.AgentImageUri = imageUrl;
                    options.EndpointUri         = endpointUri;
                    options.WalletConfiguration = new WalletConfiguration {
                        Id = walletId, StorageConfiguration = storageConfig
                    };
                });
            });
        });
Example #4
0
 public WalletConfiguration()
 {
     StorageConfiguration = new WalletStorageConfiguration();
     StorageCredential    = new WalletStorageCredential();
 }