示例#1
0
 public TransferNotificationRecord(UInt160 asset, UInt160 from, UInt160 to, BigInteger amount, ReadOnlyMemory <byte> tokenId, NotificationRecord notification)
 {
     Asset        = asset;
     From         = from;
     To           = to;
     TokenId      = tokenId;
     Amount       = amount;
     Notification = notification;
 }
示例#2
0
        public static TransferNotificationRecord?Create(NotificationRecord notification)
        {
            if (notification.State.Count < 3)
            {
                return(null);
            }

            var from = ParseAddress(notification.State[0]);

            if (from == null)
            {
                return(null);
            }
            var to = ParseAddress(notification.State[1]);

            if (to == null)
            {
                return(null);
            }
            if (from == UInt160.Zero && to == UInt160.Zero)
            {
                return(null);
            }

            var amountItem = notification.State[2];

            if (amountItem is not ByteString && amountItem is not Integer)
            {
                return(null);
            }
            var amount = amountItem.GetInteger();

            var asset = notification.ScriptHash;

            return(notification.State.Count switch
            {
                3 => new TransferNotificationRecord(asset, from, to, amount, default, notification),