public IActionResult GetCapabilities(string blockchainType) { 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.") )); } var isPublicAddressExtensionRequired = _blockchainExtensionsService.IsPublicAddressExtensionRequired(blockchainType); return(Ok(new CapabilititesResponce { IsPublicAddressExtensionRequired = isPublicAddressExtensionRequired.HasValue ? isPublicAddressExtensionRequired.Value : false })); }
public string Merge(string blockchainType, string baseAddress, string addressExtension) { string mergedAddress = null; if (string.IsNullOrEmpty(baseAddress)) { throw new OperationException("Base address is empty", OperationErrorCode.BaseAddressIsEmpty); } var constants = _blockchainExtensionsService.TryGetAddressExtensionConstants(blockchainType); if (baseAddress.Contains(constants.Separator)) { throw new OperationException($"Base address should not contain a separator({constants.Separator})", OperationErrorCode.BaseAddressShouldNotContainSeparator); } if (!string.IsNullOrEmpty(addressExtension)) { var capabilityQueryResult = _blockchainExtensionsService.IsPublicAddressExtensionRequired(blockchainType); if (!capabilityQueryResult.HasValue) { throw new InvalidOperationException($"API service for blockchain type [{blockchainType}] is not currently available."); } if (!capabilityQueryResult.Value) { throw new NotSupportedException($"Blockchain type [{blockchainType}] is not supported."); } if (addressExtension.Contains(constants.Separator)) { throw new OperationException($"Extension address should not contain a separator({constants.Separator})", OperationErrorCode.ExtensionAddressShouldNotContainSeparator); } mergedAddress = $"{baseAddress}{constants.Separator}{addressExtension}"; } else { mergedAddress = baseAddress; } return(mergedAddress); }