public IActionResult ParseAddress(string blockchainType, string address)
        {
            if (string.IsNullOrEmpty(blockchainType))
            {
                return(BadRequest
                       (
                           BlockchainWalletsErrorResponse.Create($"{nameof(blockchainType)} should not be null or empty.")
                       ));
            }

            if (!_blockchainIntegrationService.BlockchainIsSupported(blockchainType))
            {
                return(BadRequest
                       (
                           BlockchainWalletsErrorResponse.Create($"Blockchain type [{blockchainType}] is not supported.")
                       ));
            }

            if (string.IsNullOrEmpty(address))
            {
                return(BadRequest
                       (
                           BlockchainWalletsErrorResponse.Create($"{nameof(address)} should not be null or empty.")
                       ));
            }

            var parseResult = _addressParser.ExtractAddressParts(blockchainType, address);

            return(Ok(new AddressParseResultResponce
            {
                IsPublicAddressExtensionRequired = parseResult.IsPublicAddressExtensionRequired,
                AddressExtension = parseResult.AddressExtension,
                BaseAddress = parseResult.BaseAddress
            }));
        }
예제 #2
0
        private WalletWithAddressExtensionDto ConvertWalletToWalletWithAddressExtension(
            WalletDto walletDto)
        {
            if (walletDto == null)
            {
                return(null);
            }

            var parseAddressResult = _addressParser.ExtractAddressParts(walletDto.BlockchainType, walletDto.Address);

            return(new WalletWithAddressExtensionDto
            {
                Address = walletDto.Address,
                AddressExtension = parseAddressResult.AddressExtension,
                AssetId = walletDto.AssetId,
                BaseAddress = parseAddressResult.BaseAddress,
                BlockchainType = walletDto.BlockchainType,
                ClientId = walletDto.ClientId,
                CreatorType = walletDto.CreatorType
            });
        }