コード例 #1
0
        public async Task CompleteAsync(Guid transferId)
        {
            var transfer = await _transfersRepository.GetByIdAsync(transferId);

            if (transfer == null)
            {
                throw new TransferNotFoundException();
            }

            var additionalData = _encoderService.EncodeAcceptData(transfer.SpendRuleId, transfer.Id);

            var acceptResponse = await _privateBlockchainFacadeClient.OperationsApi.AddGenericOperationAsync(
                new GenericOperationRequest
            {
                Data          = additionalData,
                SourceAddress = _settingsService.GetMasterWalletAddress(),
                TargetAddress = _settingsService.GetContractAddress()
            });

            transfer.Status = TransferStatus.Completed;
            await _transfersRepository.UpdateAsync(transfer);

            await _operationsService.ProcessTransferAndAcceptOperationsAsync(transferId, acceptResponse.OperationId);

            _log.Info("Transfer completed.", context:
                      $"transferId: {transfer.Id}; customerId: {transfer.CustomerId}; spendRuleId: {transfer.SpendRuleId}; operationId: {acceptResponse.OperationId}");
        }