Example #1
0
        protected internal void CallNativeContract(string name)
        {
            NativeContract contract = NativeContract.GetContract(name);

            if (contract is null || contract.ActiveBlockIndex > Snapshot.PersistingBlock.Index)
            {
                throw new InvalidOperationException();
            }
            contract.Invoke(this);
        }
        protected internal void CallNativeContract(int id)
        {
            NativeContract contract = NativeContract.GetContract(id);

            if (contract is null || contract.ActiveBlockIndex > Snapshot.Height)
            {
                throw new InvalidOperationException();
            }
            contract.Invoke(this);
        }
Example #3
0
        protected internal void CallNativeContract(byte version)
        {
            NativeContract contract = NativeContract.GetContract(CurrentScriptHash);

            if (contract is null)
            {
                throw new InvalidOperationException("It is not allowed to use \"System.Contract.CallNative\" directly.");
            }
            contract.Invoke(this, version);
        }
Example #4
0
        protected internal void CallNativeContract(byte version)
        {
            NativeContract contract = NativeContract.GetContract(CurrentScriptHash);

            if (contract is null)
            {
                throw new InvalidOperationException("It is not allowed to use \"System.Contract.CallNative\" directly.");
            }
            uint activeIndex = ProtocolSettings.NativeUpdateHistory[contract.Name][0];

            if (activeIndex > NativeContract.Ledger.CurrentIndex(Snapshot))
            {
                throw new InvalidOperationException($"The native contract {contract.Name} is not active.");
            }
            contract.Invoke(this, version);
        }