예제 #1
0
        public async Task <CommandHandlingResult> Handle(StartOneToManyOutputsExecutionCommand command, IEventPublisher publisher)
        {
            var asset = await _assetsService.TryGetAssetAsync(command.AssetId);

            if (asset == null)
            {
                throw new InvalidOperationException("Asset not found");
            }

            if (string.IsNullOrWhiteSpace(asset.BlockchainIntegrationLayerId))
            {
                throw new InvalidOperationException("BlockchainIntegrationLayerId of the asset is not configured");
            }

            if (string.IsNullOrWhiteSpace(asset.BlockchainIntegrationLayerAssetId))
            {
                throw new InvalidOperationException("BlockchainIntegrationLayerAssetId of the asset is not configured");
            }

            publisher.PublishEvent
            (
                new OperationExecutionStartedEvent
            {
                OperationId            = command.OperationId,
                FromAddress            = command.FromAddress,
                Outputs                = command.Outputs,
                BlockchainType         = asset.BlockchainIntegrationLayerId,
                BlockchainAssetId      = asset.BlockchainIntegrationLayerAssetId,
                AssetId                = command.AssetId,
                IncludeFee             = command.IncludeFee,
                EndpointsConfiguration = OperationExecutionEndpointsConfiguration.OneToMany
            }
            );

            return(CommandHandlingResult.Ok());
        }
예제 #2
0
 private bool CheckStartOneToManyOutputsExecutionCommand(StartOneToManyOutputsExecutionCommand command)
 {
     return(command.Outputs.Length == 2 && command.Outputs.FirstOrDefault().Amount == 3);
 }