public async Task CreateVaspForBank() { var signature = new EthECKey(Settings.PersonSignaturePrivateKeyHex); var handshake = ECDH_Key.ImportKey(Settings.PersonHandshakePrivateKeyHex); var signPub = signature.GetPubKey().ToHex(prefix: true); var handshakePub = handshake.PublicKey; (VaspInformation vaspInfo, VaspContractInfo vaspContractInfo) = await VaspInformationBuilder.CreateForBankAsync( NodeClient.EthereumRpc, Settings.VaspSmartContractAddressBank, Settings.Bic); VaspClient vasp = VaspClient.Create( vaspInfo, vaspContractInfo, Settings.BankHandshakePrivateKeyHex, Settings.BankSignaturePrivateKeyHex, NodeClient.EthereumRpc, NodeClient.WhisperRpc, _fakeEnsProvider, _signService, NodeClient.TransportClient); // VASP paramaters must be derived from smart contract Assert.NotNull(vasp.VaspInfo.Name); Assert.NotNull(vasp.VaspInfo.VaspIdentity); Assert.NotNull(vasp.VaspInfo.PostalAddress); // VASP natural person parameters should be same what we pass in constructor Assert.Equal(vasp.VaspInfo.BIC, Settings.Bic); Assert.Null(vasp.VaspInfo.NaturalPersonIds); Assert.Null(vasp.VaspInfo.PlaceOfBirth); Assert.Null(vasp.VaspInfo.JuridicalPersonIds); }
protected override void Load(ContainerBuilder builder) { var ethereumRpc = new EthereumRpc(new Web3(_appSettings.EthereumRpcUri)); var vaspInformationBuilder = new VaspInformationBuilder(ethereumRpc); VaspInformation vaspInfo; VaspCode vaspCode; if (_appSettings.VaspBic != null) { (vaspInfo, vaspCode) = vaspInformationBuilder .CreateForBankAsync(_appSettings.VaspSmartContractAddress, _appSettings.VaspBic) .GetAwaiter() .GetResult(); } else if (_appSettings.VaspJuridicalIds != null) { (vaspInfo, vaspCode) = vaspInformationBuilder .CreateForJuridicalPersonAsync(_appSettings.VaspSmartContractAddress, _appSettings.VaspJuridicalIds) .GetAwaiter() .GetResult(); } else if (_appSettings.VaspNaturalIds != null) { (vaspInfo, vaspCode) = vaspInformationBuilder .CreateForNaturalPersonAsync(_appSettings.VaspSmartContractAddress, _appSettings.VaspNaturalIds, _appSettings.VaspPlaceOfBirth) .GetAwaiter() .GetResult(); } else { throw new ArgumentException("Invalid configuration."); } builder.RegisterInstance(vaspInfo); builder.RegisterInstance(vaspCode); builder.RegisterInstance(ethereumRpc) .As <IEthereumRpc>() .SingleInstance(); builder.RegisterType <WhisperMessageFormatter>() .As <IMessageFormatter>() .SingleInstance(); builder.RegisterType <WhisperRpc>() .As <IWhisperRpc>() .SingleInstance() .WithParameter(TypedParameter.From((IWeb3) new Web3(_appSettings.WhisperRpcUri))); builder.RegisterType <EnsProvider>() .As <IEnsProvider>() .SingleInstance(); builder.RegisterType <WhisperSignService>() .As <ISignService>() .SingleInstance(); builder.RegisterType <WhisperTransportClient>() .As <ITransportClient>() .SingleInstance(); builder.RegisterType <TransactionDataService>() .As <ITransactionDataService>() .SingleInstance(); builder.RegisterType <TransactionsManager>() .SingleInstance() .As <ITransactionsManager>() .AutoActivate() .WithParameter("handshakePrivateKeyHex", _appSettings.HandshakePrivateKeyHex) .WithParameter("signaturePrivateKeyHex", _appSettings.SignaturePrivateKeyHex); builder.RegisterType <VaspCodeManager>() .As <IVaspCodeManager>() .WithParameter(TypedParameter.From((IEnumerable <string>)_appSettings.AutoConfirmedVaspCodes)) .SingleInstance(); builder.RegisterInMemoryRepositories(); base.Load(builder); }