Example #1
0
        private TransferInfo ToNep5TransferInfo(Nep5TransactionEntity entity)
        {
            return(new TransferInfo()
            {
                BlockHeight = entity.BlockHeight,
                TxId = UInt256.Parse(entity.TxId),
                From = entity.From != null?UInt160.Parse(entity.From.Address) : null,
                           To = UInt160.Parse(entity.To.Address),
                           Amount = new BigInteger(entity.Amount),
                           Asset = UInt160.Parse(entity.Asset.Asset),

                           TimeStamp = entity.Time.AsUtcTime().ToTimestampMS(),
            });
        }
Example #2
0
        /// <summary>
        /// will save after call <see cref="Commit"/> method
        /// </summary>
        /// <param name="newTransaction"></param>
        public void AddTransfer(TransferInfo newTransaction)
        {
            var from  = GetOrCreateAddress(newTransaction.From);
            var to    = GetOrCreateAddress(newTransaction.To);
            var asset = GetOrCreateAsset(newTransaction.AssetInfo);

            var tran = new Nep5TransactionEntity
            {
                BlockHeight = newTransaction.BlockHeight,
                TxId        = newTransaction.TxId.ToBigEndianHex(),
                FromId      = from?.Id,
                ToId        = to.Id,

                Amount  = newTransaction.Amount.ToByteArray(),
                AssetId = asset.Id,
                Time    = newTransaction.TimeStamp.FromTimestampMS(),
            };

            _sqldb.Nep5Transactions.Add(tran);
        }