Beispiel #1
0
        ///// <summary>
        ///// 获得nep5资产的exchange合约映射
        ///// </summary>
        ///// <param name="tokenA"></param>
        ///// <param name="tokenB"></param>
        ///// <returns></returns>
        //public static byte[] GetExchangePair(byte[] tokenA, byte[] tokenB)
        //{
        //    return Storage.Get(GetPairKey(tokenA, tokenB));
        //}


        /// <summary>
        /// 获得nep5资产的exchange合约映射
        /// </summary>
        /// <returns></returns>
        public static ExchangePair[] GetAllExchangePair()
        {
            var iterator = Storage.Find(ExchangeMapKey);
            var result   = new ExchangePair[0];

            while (iterator.Next())
            {
                var exchangeContractHash = iterator.Value;
                if (exchangeContractHash.Length == 20)
                {
                    var keyPair = iterator.Key.AsByteArray().Last(40);
                    var tokenA  = keyPair.Take(20);
                    var tokenB  = keyPair.Last(20);
                    var item    = new ExchangePair()
                    {
                        TokenA           = tokenA,
                        TokenB           = tokenB,
                        ExchangePairHash = exchangeContractHash,
                    };
                    Append(result, item);
                }
            }
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 获得nep17资产的exchange合约映射
        /// </summary>
        /// <returns></returns>
        public static ExchangePair[] GetAllExchangePair()
        {
            var iterator = (Iterator <KeyValue>)StorageFind(ExchangeMapKey);
            var result   = new ExchangePair[0];

            while (iterator.Next())
            {
                var keyValue = iterator.Value;
                if (keyValue.Value != null)
                {
                    var exchangeContractHash = keyValue.Value;
                    var tokenA = keyValue.Key.Take(20);
                    var tokenB = keyValue.Key.Last(20);
                    var item   = new ExchangePair()
                    {
                        TokenA           = (UInt160)tokenA,
                        TokenB           = (UInt160)tokenB,
                        ExchangePairHash = exchangeContractHash,
                    };
                    Append(result, item);
                }
            }
            return(result);
        }