Exemplo n.º 1
0
 protected StackItem OnPersist(ApplicationEngine engine, VMArray args)
 {
     if (engine.Trigger != TriggerType.System)
     {
         return(false);
     }
     return(OnPersist(engine));
 }
Exemplo n.º 2
0
        protected StackItem Transfer(ApplicationEngine engine, VMArray args)
        {
            UInt160    from   = new UInt160(args[0].GetByteArray());
            UInt160    to     = new UInt160(args[1].GetByteArray());
            BigInteger amount = args[2].GetBigInteger();

            return(Transfer(engine, from, to, amount));
        }
Exemplo n.º 3
0
        private StackItem SetFeePerByte(ApplicationEngine engine, VMArray args)
        {
            if (!CheckValidators(engine))
            {
                return(false);
            }
            long        value   = (long)args[0].GetBigInteger();
            StorageItem storage = engine.Snapshot.Storages.GetAndChange(CreateStorageKey(Prefix_FeePerByte));

            storage.Value = BitConverter.GetBytes(value);
            return(true);
        }
Exemplo n.º 4
0
        private StackItem SetMaxTransactionsPerBlock(ApplicationEngine engine, VMArray args)
        {
            if (!CheckValidators(engine))
            {
                return(false);
            }
            uint        value   = (uint)args[0].GetBigInteger();
            StorageItem storage = engine.Snapshot.Storages.GetAndChange(CreateStorageKey(Prefix_MaxTransactionsPerBlock));

            storage.Value = BitConverter.GetBytes(value);
            return(true);
        }
Exemplo n.º 5
0
        private StackItem SetMaxBlockSize(ApplicationEngine engine, VMArray args)
        {
            if (!CheckValidators(engine))
            {
                return(false);
            }
            uint value = (uint)args[0].GetBigInteger();

            if (Network.P2P.Message.PayloadMaxSize <= value)
            {
                return(false);
            }
            StorageItem storage = engine.Snapshot.Storages.GetAndChange(CreateStorageKey(Prefix_MaxBlockSize));

            storage.Value = BitConverter.GetBytes(value);
            return(true);
        }
Exemplo n.º 6
0
        internal bool Invoke(ApplicationEngine engine)
        {
            if (!engine.CurrentScriptHash.Equals(Hash))
            {
                return(false);
            }
            string  operation = engine.CurrentContext.EvaluationStack.Pop().GetString();
            VMArray args      = (VMArray)engine.CurrentContext.EvaluationStack.Pop();

            if (!methods.TryGetValue(operation, out ContractMethodMetadata method))
            {
                return(false);
            }
            StackItem result = method.Delegate(engine, args);

            engine.CurrentContext.EvaluationStack.Push(result);
            return(true);
        }
Exemplo n.º 7
0
        private StackItem UnblockAccount(ApplicationEngine engine, VMArray args)
        {
            if (!CheckValidators(engine))
            {
                return(false);
            }
            UInt160           account  = new UInt160(args[0].GetByteArray());
            StorageKey        key      = CreateStorageKey(Prefix_BlockedAccounts);
            StorageItem       storage  = engine.Snapshot.Storages[key];
            HashSet <UInt160> accounts = new HashSet <UInt160>(storage.Value.AsSerializableArray <UInt160>());

            if (!accounts.Remove(account))
            {
                return(false);
            }
            storage       = engine.Snapshot.Storages.GetAndChange(key);
            storage.Value = accounts.ToArray().ToByteArray();
            return(true);
        }
Exemplo n.º 8
0
 private StackItem GetFeePerByte(ApplicationEngine engine, VMArray args)
 {
     return(GetFeePerByte(engine.Snapshot));
 }
Exemplo n.º 9
0
 private StackItem GetMaxBlockSize(ApplicationEngine engine, VMArray args)
 {
     return(GetMaxBlockSize(engine.Snapshot));
 }
Exemplo n.º 10
0
 private StackItem GetMaxTransactionsPerBlock(ApplicationEngine engine, VMArray args)
 {
     return(GetMaxTransactionsPerBlock(engine.Snapshot));
 }
Exemplo n.º 11
0
 protected StackItem NameMethod(ApplicationEngine engine, VMArray args)
 {
     return(Name);
 }
Exemplo n.º 12
0
 private StackItem GetBlockedAccounts(ApplicationEngine engine, VMArray args)
 {
     return(GetBlockedAccounts(engine.Snapshot).Select(p => (StackItem)p.ToArray()).ToList());
 }
Exemplo n.º 13
0
 protected StackItem BalanceOf(ApplicationEngine engine, VMArray args)
 {
     return(BalanceOf(engine.Snapshot, new UInt160(args[0].GetByteArray())));
 }
Exemplo n.º 14
0
 protected StackItem TotalSupply(ApplicationEngine engine, VMArray args)
 {
     return(TotalSupply(engine.Snapshot));
 }
Exemplo n.º 15
0
 protected StackItem DecimalsMethod(ApplicationEngine engine, VMArray args)
 {
     return((uint)Decimals);
 }
Exemplo n.º 16
0
 protected StackItem SymbolMethod(ApplicationEngine engine, VMArray args)
 {
     return(Symbol);
 }
Exemplo n.º 17
0
 protected StackItem SupportedStandardsMethod(ApplicationEngine engine, VMArray args)
 {
     return(SupportedStandards.Select(p => (StackItem)p).ToList());
 }
Exemplo n.º 18
0
        private StackItem GetSysFeeAmount(ApplicationEngine engine, VMArray args)
        {
            uint index = (uint)args[0].GetBigInteger();

            return(GetSysFeeAmount(engine.Snapshot, index));
        }