public async Task <VaspContractInfo> GetVaspContractInfoAync(string vaspSmartContracAddress)
        {
            var pathToAbi = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VASP.abi");
            var abi       = File.ReadAllText(pathToAbi);
            var contract  = _web3.Eth.GetContract(abi, vaspSmartContracAddress);

            var name = await contract.GetFunction("name").CallAsync <string>();

            var vaspCode = await contract.GetFunction("code").CallAsync <byte[]>();

            var handshakeKey = await contract.GetFunction("handshakeKey").CallAsync <string>();

            var signingKey = await contract.GetFunction("signingKey").CallAsync <string>();

            var postalAddress = await contract.GetFunction("postalAddress").CallDeserializingToObjectAsync <PostalAddressDTO>();

            Country.List.TryGetValue(postalAddress.Country, out var country);

            var vaspSmartContractInfo = new VaspContractInfo()
            {
                Name         = name,
                VaspCode     = VaspCode.Create(vaspCode.ToHex()),
                HandshakeKey = handshakeKey,
                Address      = new PostalAddress(
                    postalAddress.StreetName,
                    int.Parse(postalAddress.BuildingNumber),
                    postalAddress.AddressLine,
                    postalAddress.PostCode,
                    postalAddress.Town,
                    country),
                SigningKey   = signingKey,
                Channgels    = null,
                Email        = null,
                OwnerAddress = null,
                Website      = null
            };

            return(vaspSmartContractInfo);
        }
예제 #2
0
        /// <summary>
        /// C-tor
        /// </summary>
        public TransactionsManager(
            VaspCode vaspCode,
            string handshakePrivateKeyHex,
            string signaturePrivateKeyHex,
            IEthereumRpc ethereumRpc,
            ISignService signService,
            IEnsProvider ensProvider,
            ITransportClient transportClient,
            ITransactionDataService transactionDataService,
            ISessionsRepository sessionsRepository,
            ITransactionsRepository transactionsRepository,
            IVaspCodeManager vaspCodeManager,
            VaspInformation vaspInformation,
            ILoggerFactory loggerFactory)
        {
            _vaspClient = VaspClient.Create(
                vaspCode,
                handshakePrivateKeyHex,
                signaturePrivateKeyHex,
                ethereumRpc,
                ensProvider,
                signService,
                transportClient,
                loggerFactory);

            _vaspClient.SessionRequestMessageReceived       += SessionRequestMessageReceivedAsync;
            _vaspClient.SessionReplyMessageReceived         += SessionReplyMessageReceivedAsync;
            _vaspClient.TransferReplyMessageReceived        += TransferReplyMessageReceivedAsync;
            _vaspClient.TransferConfirmationMessageReceived += TransferConfirmationMessageReceivedAsync;
            _vaspClient.TransferRequestMessageReceived      += TransferRequestMessageReceivedAsync;
            _vaspClient.TransferDispatchMessageReceived     += TransferDispatchMessageReceivedAsync;
            _vaspClient.BeneficiarySessionCreated           += BeneficiarySessionCreatedAsync;

            _transactionDataService = transactionDataService;
            _sessionsRepository     = sessionsRepository;
            _transactionsRepository = transactionsRepository;
            _vaspCodeManager        = vaspCodeManager;
            _vaspInformation        = vaspInformation;
        }
예제 #3
0
        public Task <string> GetContractAddressByVaspCodeAsync(VaspCode vaspCode)
        {
            _addressDictionary.TryGetValue(vaspCode.Code.ToLower(CultureInfo.InvariantCulture), out var result);

            return(Task.FromResult(result));
        }