public async Task HandleAsync(
            string privateAddress,
            string publicAddress,
            BigInteger internalTransferId,
            string operationId,
            Money18 amount)
        {
            #region Validation

            if (string.IsNullOrEmpty(privateAddress))
            {
                _log.Error(message: "TransferToExternalProcessed event with missing private address",
                           context: new { operationId, internalTransferId, publicAddress, amount });
                return;
            }

            if (string.IsNullOrEmpty(publicAddress))
            {
                _log.Error(message: "TransferToExternalProcessed event with missing public address",
                           context: new { operationId, internalTransferId, privateAddress, amount });
                return;
            }


            if (string.IsNullOrEmpty(operationId))
            {
                _log.Error(message: "TransferToExternalProcessed event with missing operation Id",
                           context: new { publicAddress, privateAddress, internalTransferId, amount });
                return;
            }

            if (amount <= 0)
            {
                _log.Error(message: "TransferToExternalProcessed event with invalid amount ",
                           context: new { operationId, publicAddress, privateAddress, internalTransferId, amount });
                return;
            }

            #endregion

            var encodedData =
                _blockchainEncodingService.EncodeTransferToExternalData(privateAddress, publicAddress, internalTransferId, amount);

            await _operationsService.ExecuteOperationAsync(operationId, _settingsService.GetMasterWalletAddress(),
                                                           _settingsService.GetPublicBlockchainGatewayContractAddress(), encodedData);
        }
示例#2
0
        public override async Task Execute()
        {
            var totalSupplyInternal = await _tokenServiceForInternalNetwork.TotalSupplyQueryAsync();

            var internalSupplyInPublicNetwork = await _tokenServiceForPublicNetwork.TotalSupplyQueryAsync();

            if (internalSupplyInPublicNetwork != totalSupplyInternal)
            {
                _log.Info("Total supply in private blockchain differs from the one in public and will be synced",
                          new { totalSupplyInternal, internalSupplyInPublicNetwork });

                var encodedData = _blockchainEncodingService.EncodeSetInternalSupplyData(totalSupplyInternal);

                var operationId = Guid.NewGuid();

                await _operationsService.ExecuteOperationAsync(operationId.ToString(),
                                                               _settingsService.GetMasterWalletAddress(),
                                                               _settingsService.GetPublicBlockchainGatewayContractAddress(),
                                                               encodedData);

                _log.Info("Posted transaction to update internal supply in public", new { operationId });
            }
        }
示例#3
0
        public async Task HandleAsync(string operationId, string internalAddress, string publicAddress)
        {
            if (string.IsNullOrEmpty(operationId))
            {
                _log.Error(message: "WalletLinkingStatusChangeRequested event with missing operationId",
                           context: new { internalAddress, publicAddress });
                return;
            }

            if (string.IsNullOrEmpty(internalAddress))
            {
                _log.Error(message: "WalletLinkingStatusChangeRequested event with missing internalAddress",
                           context: new { operationId, publicAddress });
                return;
            }

            var encodedData = string.IsNullOrEmpty(publicAddress)
                ? _blockchainEncodingService.EncodeUnLinkPublicAccountData(internalAddress)
                : _blockchainEncodingService.EncodeLinkPublicAccountData(internalAddress, publicAddress);

            await _operationsService.ExecuteOperationAsync(operationId, _settingsService.GetMasterWalletAddress(),
                                                           _settingsService.GetPublicBlockchainGatewayContractAddress(), encodedData);
        }