public static object addPauser(byte[] invoker, byte[] account)
        {
            BasicMethods.assert(Runtime.CheckWitness(invoker), "Checkwitness failed");
            // make sure the invoker is one effective pauser

            Map <byte[], bool> pausers = new Map <byte[], bool>();

            byte[] pauserBs = Storage.Get(Storage.CurrentContext, PauserKey);
            if (pauserBs.Length > 0)
            {
                pausers = Helper.Deserialize(pauserBs) as Map <byte[], bool>;
            }
            byte[] admin = BasicMethods.getAdmin();
            if (!invoker.Equals(admin))
            {
                BasicMethods.assert(pausers.HasKey(invoker), "invoker is not one pauser");
                BasicMethods.assert(pausers[invoker], "invoker is an effective pauser");
            }

            // update the pausers map
            pausers[account] = true;
            Storage.Put(Storage.CurrentContext, PauserKey, Helper.Serialize(pausers));
            PauserAdded(account);
            return(true);
        }
示例#2
0
        public static object init()
        {
            BasicMethods.assert(totalSupply() == 0, "contract has already been initilaized");
            BigInteger supply = Factor * InitialSupply;

            Storage.Put(Storage.CurrentContext, TotalSupplyKey, supply);
            Storage.Put(Storage.CurrentContext, BalancePrefix.Concat(BasicMethods.getAdmin()), supply);
            Transferred(null, BasicMethods.getAdmin(), supply);
            return(true);
        }
        public static object init(byte[] reversedNEP5Hash, BigInteger decimals, byte[] reversedCelerWalletHash)
        {
            BasicMethods.assert(BasicMethods._isLegalAddress(reversedNEP5Hash), "nep5 contract hash illegal");
            BasicMethods.assert(decimals >= 0, "decimals is less than 0");
            BasicMethods.assert(BasicMethods._isLegalAddress(reversedCelerWalletHash), "celer wallet contract hash illegal");

            BasicMethods.assert(Runtime.CheckWitness(BasicMethods.getAdmin()), "is not initialized by admin");

            Storage.Put(Storage.CurrentContext, NEP5HashKey, reversedNEP5Hash);
            Storage.Put(Storage.CurrentContext, DecimalsKey, decimals);
            Storage.Put(Storage.CurrentContext, CelerWalletHashKey, reversedCelerWalletHash);

            //TODO notify the event
            return(true);
        }
 private static bool onlyOwner()
 {
     return(Runtime.CheckWitness(BasicMethods.getAdmin()));
 }