// Factory methods // Template: NPCLevel1Part2_cs.txt
 private static NPCEnvironment _Initialize(NPCEnvironment e)
 {
     e._callerAccountScriptHash = NeoEntityModel.NullByteArray; e._executingScriptHash = NeoEntityModel.NullByteArray; e._blockTimestamp = 0;
     e._state = NeoEntityModel.EntityState.NULL;
     if (NeoTrace.RUNTIME)
     {
         LogExt("_Initialize(e).NPCEnvironment", e);
     }
     return(e);
 }
        public static NPCEnvironment New()
        {
            NPCEnvironment e = new NPCEnvironment();

            _Initialize(e);
            if (NeoTrace.RUNTIME)
            {
                LogExt("New().NPCEnvironment", e);
            }
            return(e);
        }
        public static NPCEnvironment New(byte[] CallerAccountScriptHash, byte[] ExecutingScriptHash, BigInteger BlockTimestamp)
        {
            NPCEnvironment e = new NPCEnvironment();

            e._callerAccountScriptHash = CallerAccountScriptHash; e._executingScriptHash = ExecutingScriptHash; e._blockTimestamp = BlockTimestamp;
            e._state = NeoEntityModel.EntityState.INIT;
            if (NeoTrace.RUNTIME)
            {
                LogExt("New(.,.).NPCEnvironment", e);
            }
            return(e);
        }
Example #4
0
        public static void Initialize(NPCEnvironment e)
        {
            e._callerAccountScriptHash = NeoEntityModel.NullByteArray;
            Transaction tx = (Transaction)ExecutionEngine.ScriptContainer;

            TransactionOutput[] outputs = tx.GetOutputs();
            if (outputs.Length >= 1)
            {
                e._callerAccountScriptHash = outputs[0].ScriptHash;
            }

            e._executingScriptHash = ExecutionEngine.ExecutingScriptHash;

            Header header = Blockchain.GetHeader(Blockchain.GetHeight());

            e._blockTimestamp = header.Timestamp;
        }
        public static bool deploy(NPCNEP5Base tokenbase)
        {
            bool result = false;

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("deploy():entered");
            }

            NPCEnvironment env = NPCEnvironment.New();

            NPCEnvironment.Initialize(env);

            NPCNEP5LedgerEntry ownerLedgerEntry = NPCNEP5LedgerEntry.Get(OwnerAccountScriptHash);

            if (NeoTrace.VERBOSE)
            {
                NPCNEP5LedgerEntry.Log("deploy().ownerLedgerEntry", ownerLedgerEntry);
            }
            if (NPCNEP5LedgerEntry.IsMissing(ownerLedgerEntry))
            {
                if (NeoTrace.VERBOSE)
                {
                    NeoTrace.Trace("ownerLedgerEntry is Missing");
                }
                NPCNEP5LedgerEntry.Set(ownerLedgerEntry,
                                       NPCEnvironment.GetBlockTimestamp(env), 0, NPCNEP5Base.GetTotalSupply(tokenbase));
                NPCNEP5LedgerEntry.Put(ownerLedgerEntry, OwnerAccountScriptHash);
                if (NeoTrace.VERBOSE)
                {
                    NPCNEP5LedgerEntry.Log("deploy().ownerLedgerEntry", ownerLedgerEntry);
                }
                result = true;
            }

            return(result);
        }
 public static void Set(NPCEnvironment e, byte[] CallerAccountScriptHash, byte[] ExecutingScriptHash, BigInteger BlockTimestamp) // Template: NPCLevel1Set_cs.txt
 {
     e._callerAccountScriptHash = CallerAccountScriptHash; e._executingScriptHash = ExecutingScriptHash; e._blockTimestamp = BlockTimestamp;  e._state = NeoEntityModel.EntityState.SET;
 }
 public static BigInteger GetBlockTimestamp(NPCEnvironment e)
 {
     return(e._blockTimestamp);
 }
 public static void SetBlockTimestamp(NPCEnvironment e, BigInteger value) // Template: NPCLevel1SetXGetX_cs.txt
 {
     e._blockTimestamp = value; e._state = NeoEntityModel.EntityState.SET;
 }
 public static byte[] GetExecutingScriptHash(NPCEnvironment e)
 {
     return(e._executingScriptHash);
 }
 public static void SetExecutingScriptHash(NPCEnvironment e, byte[] value) // Template: NPCLevel1SetXGetX_cs.txt
 {
     e._executingScriptHash = value; e._state = NeoEntityModel.EntityState.SET;
 }
 public static byte[] GetCallerAccountScriptHash(NPCEnvironment e)
 {
     return(e._callerAccountScriptHash);
 }
        // Accessors

        public static void SetCallerAccountScriptHash(NPCEnvironment e, byte[] value) // Template: NPCLevel1SetXGetX_cs.txt
        {
            e._callerAccountScriptHash = value; e._state = NeoEntityModel.EntityState.SET;
        }
 public static void LogExt(string label, NPCEnvironment e)
 {
     TraceRuntime(label, e._callerAccountScriptHash, e._executingScriptHash, e._blockTimestamp, e._state);
 }
 // EntityState wrapper methods
 public static bool IsNull(NPCEnvironment e)
 {
     return(e._state == NeoEntityModel.EntityState.NULL);
 }