/// <summary>
 /// 设置合约管理员
 /// </summary>
 /// <param name="admin"></param>
 /// <returns></returns>
 public static bool SetAdmin(UInt160 admin)
 {
     Assert(admin.IsAddress(), "Invalid Address");
     Assert(Runtime.CheckWitness(GetAdmin()), "Forbidden");
     StoragePut(AdminKey, admin);
     return(true);
 }
Exemple #2
0
        /// <summary>
        /// 检查<see cref="callScript"/>是否为router合约
        /// </summary>
        /// <param name="callScript"></param>
        /// <returns></returns>
        public static bool CheckIsRouter(UInt160 callScript)
        {
            Assert(callScript.IsAddress(), "Invalid CallScript Address");
            var whiteList = GetWhiteListContract();

            return((bool)Contract.Call(whiteList, "checkRouter", CallFlags.ReadOnly, new object[] { callScript }));
        }
Exemple #3
0
 /// <summary>
 /// 设置WhiteListContract地址
 /// </summary>
 /// <param name="whiteList"></param>
 /// <returns></returns>
 public static bool SetWhiteListContract(UInt160 whiteList)
 {
     Assert(Runtime.CheckWitness(GetAdmin()), "Forbidden");
     Assert(whiteList.IsAddress(), "Invalid Address");
     StoragePut(WhiteListContractKey, whiteList);
     return(true);
 }
Exemple #4
0
        /// <summary>
        /// 删除nep17资产的exchange合约映射
        /// </summary>
        /// <param name="tokenA"></param>
        /// <param name="tokenB"></param>
        /// <returns></returns>
        public static bool RemoveExchangePair(UInt160 tokenA, UInt160 tokenB)
        {
            Assert(tokenA.IsAddress() && tokenB.IsAddress(), "Invalid Address");
            Assert(Runtime.CheckWitness(GetAdmin()), "Forbidden");
            var key   = GetPairKey(tokenA, tokenB);
            var value = StorageGet(key);

            if (value?.Length > 0)
            {
                StorageDelete(key);
                onRemoveExchange(tokenA, tokenB);
            }
            return(true);
        }
Exemple #5
0
        /// <summary>
        /// 增加nep17资产的exchange合约映射
        /// </summary>
        /// <param name="tokenA">Nep5 tokenA</param>
        /// <param name="tokenB">Nep5 tokenB</param>
        /// <param name="exchangeContractHash"></param>
        /// <returns></returns>
        public static bool CreateExchangePair(UInt160 tokenA, UInt160 tokenB, UInt160 exchangeContractHash)
        {
            Assert(Runtime.CheckWitness(GetAdmin()), "Forbidden");
            Assert(tokenA.IsAddress() && tokenB.IsAddress(), "Invalid Address");
            Assert(tokenA != tokenB, "Identical Address", tokenA);
            var key   = GetPairKey(tokenA, tokenB);
            var value = StorageGet(key);

            Assert(value == null || value.Length == 0, "Exchange Already Existed");

            StoragePut(key, exchangeContractHash);
            onCreateExchange(tokenA, tokenB, exchangeContractHash);
            return(true);
        }