Esempio n. 1
0
        public static bool AddSubMinter(UInt160 minterAccount, UInt160 subMinterAccount, BigInteger amount)
        {
            if (IsPaused())
            {
                Error("System is paused.");
                return(false);
            }
            if (amount <= 0)
            {
                Error("The parameter amount MUST be greater than 0.");
                return(false);
            }
            if (!IsMinter() || !Runtime.CheckWitness(minterAccount))
            {
                Error("No authorization.");
                return(false);
            }
            if (IsBlacklisted(minterAccount))
            {
                Error("Argument account is in blacklist.");
                return(false);
            }
            if (MinterStorage.Exist(subMinterAccount))
            {
                Error("Minter already exists.");
                return(false);
            }
            var allowance = GetAllowance(minterAccount);

            if (allowance < amount)
            {
                Error("Insufficient allowance.");
                return(false);
            }

            MinterStorage.ReduceAllowance(minterAccount, amount);
            MinterStorage.IncreaseAllowance(subMinterAccount, amount);
            MinterStorage.Add(subMinterAccount, amount);

            MinterChanged(minterAccount, allowance - amount);
            MinterChanged(subMinterAccount, amount);
            return(true);
        }
Esempio n. 2
0
        public static bool Mint(UInt160 minterAccount, BigInteger amount)
        {
            if (IsPaused())
            {
                Error("System is paused.");
                return(false);
            }
            if (amount <= 0)
            {
                Error("The parameter amount MUST be greater than 0.");
                return(false);
            }
            if (!IsMinter() || !Runtime.CheckWitness(minterAccount))
            {
                Error("No authorization.");
                return(false);
            }
            if (IsBlacklisted(minterAccount))
            {
                Error("Argument account is in blacklist.");
                return(false);
            }
            var allowance = GetAllowance(minterAccount);

            if (allowance < amount)
            {
                Error("Insufficient allowance.");
                return(false);
            }

            TotalSupplyStorage.Increase(amount);

            TotalAllowanceStorage.Reduce(amount);

            AssetStorage.Increase(minterAccount, amount);

            MinterStorage.ReduceAllowance(minterAccount, amount);

            Transferred(null, minterAccount, amount);

            return(true);
        }
Esempio n. 3
0
 public static bool IsMinter(UInt160 minterAccount) => MinterStorage.Exist(minterAccount);
Esempio n. 4
0
 private static bool IsMinter() => MinterStorage.IncludeWitness();
Esempio n. 5
0
 public static bool Initialize()
 {
     BlacklistStorage.Initialize();
     MinterStorage.Initialize();
     return(true);
 }
Esempio n. 6
0
 public static BigInteger GetAllowance(UInt160 minterAccount) => MinterStorage.Get(minterAccount);