Пример #1
0
        private IList <Asset> GetAssetList(ProgramOptions options)
        {
            var assetList = new List <Asset>();

            if (options.Mode == Mode.All)
            {
                assetList = _assetService.GetAllAssets().Result.AssetList;
            }
            else if (options.Mode == Mode.Account)
            {
                _transfers = _assetService.GetAssetTransfers(AssetIdOrAccountId.ByAccountId(options.Id.ToString()), includeAssetInfo: false).Result.Transfers;
                _trades    = _assetService.GetTrades(AssetIdOrAccountId.ByAccountId(options.Id.ToString()), includeAssetInfo: false).Result.Trades;

                var assetIds = _transfers.Select(transfer => transfer.AssetId).Union(_trades.Select(trade => trade.AssetId)).Distinct();

                assetList = _assetService.GetAssets(assetIds).Result.AssetList;
            }
            else if (options.Mode == Mode.Asset)
            {
                assetList = new List <Asset> {
                    _assetService.GetAsset(options.Id).Result
                };
            }
            return(assetList);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var transactionId = GetTransactionIdFromArguments(args);
            var attachment    = GetTransactionAttachment(transactionId);

            _asset = AssetService.GetAsset(attachment.AssetId, true).Result;
            var decimalMultiplier = (decimal)Math.Pow(10, _asset.Decimals);
            var assetOwners       = GetOwners(attachment.Height).Where(FilterOwners()).OrderByDescending(d => d.QuantityQnt).ToList();
            var totalSpent        = Amount.CreateAmountFromNqt(assetOwners.Sum(o => o.QuantityQnt) * attachment.AmountPerQnt.Nqt);

            Console.WriteLine("Using dividend transaction: {0}", transactionId);
            Console.WriteLine("Fetching dividend payments for asset: {0} ({1})", _asset.Name, _asset.AssetId);
            Console.WriteLine("Total in dividend: {0} NXT", totalSpent.Nxt);
            Console.WriteLine("Per share: {0} NXT", attachment.AmountPerQnt.Nxt * decimalMultiplier);
            Console.WriteLine("Number of shareholders at height {0}: {1}", attachment.Height, assetOwners.Count);
            Console.WriteLine("----------------------------------------------------------------");

            foreach (var assetOwner in assetOwners)
            {
                var quantityQnt    = assetOwner.QuantityQnt;
                var amountRecieved = Amount.CreateAmountFromNqt(quantityQnt * attachment.AmountPerQnt.Nqt);
                Console.WriteLine("Account: {0}, Shares: {1}, Amount: {2} NXT",
                                  assetOwner.AccountRs, assetOwner.QuantityQnt / decimalMultiplier, amountRecieved.Nxt);
            }

            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("Press any key to exit.");
            Console.ReadLine();
        }
Пример #3
0
        public void List(ulong transactionId)
        {
            var transaction = _transactionService.GetTransaction(GetTransactionLocator.ByTransactionId(transactionId)).Result;
            var attachment  = (ColoredCoinsDividendPaymentAttachment)transaction.Attachment;

            _asset = _assetService.GetAsset(attachment.AssetId, true).Result;
            var decimalMultiplier = (decimal)Math.Pow(10, _asset.Decimals);
            var assetOwners       = GetOwners(attachment.Height).Where(FilterOwners()).OrderByDescending(d => d.QuantityQnt).ToList();
            var totalSpent        = Amount.CreateAmountFromNqt(assetOwners.Sum(o => o.QuantityQnt) * attachment.AmountPerQnt.Nqt);

            Console.WriteLine($"Using dividend transaction: {transactionId} ({transaction.BlockTimestamp?.ToString("yyyy-MM-dd HH:mm")})");
            Console.WriteLine("Fetching dividend payments for asset: {0} ({1})", _asset.Name, _asset.AssetId);
            Console.WriteLine("Total in dividend: {0} NXT", totalSpent.Nxt);
            Console.WriteLine("Per share: {0} NXT", attachment.AmountPerQnt.Nxt * decimalMultiplier);
            Console.WriteLine("Number of shareholders at height {0}: {1}", attachment.Height, assetOwners.Count());
            Console.WriteLine("----------------------------------------------------------------");

            foreach (var assetOwner in assetOwners)
            {
                var quantityQnt    = assetOwner.QuantityQnt;
                var amountRecieved = Amount.CreateAmountFromNqt(quantityQnt * attachment.AmountPerQnt.Nqt);
                Console.WriteLine("Account: {0}, Shares: {1}, Amount: {2} NXT",
                                  assetOwner.AccountRs, assetOwner.QuantityQnt / decimalMultiplier, amountRecieved.Nxt);
            }

            Console.WriteLine("----------------------------------------------------------------");
        }
Пример #4
0
 private void AssetDecimals(MessagingPollCreationAttachment attachment, GetPollResultReply getPollResult)
 {
     if (attachment.MinBalanceModel == MinBalanceModel.Asset)
     {
         var assetReply = _assetExchangeService.GetAsset(attachment.HoldingId).Result;
         AssertEquals(assetReply.Decimals, getPollResult.Decimals, "Decimals");
     }
     else if (attachment.MinBalanceModel == MinBalanceModel.Currency)
     {
         var currency = _monetarySystemService.GetCurrency(CurrencyLocator.ByCurrencyId(attachment.HoldingId)).Result;
         AssertEquals(currency.Decimals, getPollResult.Decimals, "Decimals");
     }
 }
Пример #5
0
        public async Task <NxtAsset> GetAsset(TransferableConfig assetConfig)
        {
            var asset = await assetExchangeService.GetAsset(assetConfig.Id);

            return(new NxtAsset(asset, assetConfig.RecipientMessage, assetConfig.Monikers, assetConfig.Reactions));
        }