public static bool Put(NEP5LedgerEntry e, byte[] key)
        {
            if (key.Length == 0)
            {
                return(false);
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            byte[] _bkeyTag = Helper.Concat(key, _bclassKeyTag);

            // no readonly fields byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bSTA));
            // no readonly fields if (NeoTrace.RUNTIME) TraceRuntime("Put(bkey).bsta", bsta.Length, bsta);
            // no readonly fields bool isMissing = false; if (bsta.Length == 0) isMissing = true;

            e._state = NeoEntityModel.EntityState.PUTTED;
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, Helper.Concat(_bkeyTag, _bSTA), e._state.AsBigInteger());

            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, Helper.Concat(_bkeyTag, _bTimestamp), e._timestamp);                 // Template: NPCLevel2CPut_cs.txt
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, Helper.Concat(_bkeyTag, _bDecription), e._decription);               // Template: NPCLevel2CPut_cs.txt
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, Helper.Concat(_bkeyTag, _bDebitCreditAmount), e._debitCreditAmount); // Template: NPCLevel2CPut_cs.txt
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, Helper.Concat(_bkeyTag, _bBalance), e._balance);                     // Template: NPCLevel2CPut_cs.txt
            if (NeoTrace.RUNTIME)
            {
                LogExt("Put(bkey).NEP5LedgerEntry", e);                   // Template: NPCLevel2DPut_cs.txt
            }
            return(true);
        }
示例#2
0
        public static NEP5LedgerEntry Main()
        {
            // Use case 0
            NEP5LedgerEntry entry0 = NEP5LedgerEntry.New();

            NEP5LedgerEntry.LogExt("entry0", entry0);
            if (NEP5LedgerEntry.IsNull(entry0))
            {
                NeoTrace.Trace("entry0 is null", entry0);
            }
            else
            {
                NeoTrace.Trace("entry0 is not null", entry0);
            }

            // Use case 1
            NEP5LedgerEntry entry1 = NEP5LedgerEntry.New(12345678, "Initial balance", +100, 100);

            NEP5LedgerEntry.LogExt("entry1", entry1);
            if (NEP5LedgerEntry.IsNull(entry1))
            {
                NeoTrace.Trace("entry1 is null", entry1);
            }
            else
            {
                NeoTrace.Trace("entry1 is not null", entry1);
            }

            // Use case 2
            NEP5LedgerEntry.Put(entry1, _NEOAccountScriptHash);

            // Use case 3
            NEP5LedgerEntry entry3 = NEP5LedgerEntry.Get(_NEOAccountScriptHash);

            NEP5LedgerEntry.LogExt("entry3", entry3);
            if (NEP5LedgerEntry.IsMissing(entry3))
            {
                NeoTrace.Trace("entry3 is missing", entry3);
            }
            else
            {
                NeoTrace.Trace("entry3 is not missing", entry3);
            }

            // Use case 4
            NEP5LedgerEntry entry4 = NEP5LedgerEntry.Get(_NEOAccountScriptHash_Nonexistent);

            NEP5LedgerEntry.LogExt("entry4", entry4);
            if (NEP5LedgerEntry.IsMissing(entry4))
            {
                NeoTrace.Trace("entry4 is missing", entry4);
            }
            else
            {
                NeoTrace.Trace("entry4 is not missing", entry4);
            }

            return(entry3);
        }
示例#3
0
 // Factory methods // Template: NPCLevel1Part2_cs.txt
 private static NEP5LedgerEntry _Initialize(NEP5LedgerEntry e)
 {
     e._timestamp = 0; e._decription = ""; e._debitCreditAmount = 0; e._balance = 0;
     e._state     = NeoEntityModel.EntityState.NULL;
     if (NeoTrace.RUNTIME)
     {
         LogExt("_Initialize(e).NEP5LedgerEntry", e);
     }
     return(e);
 }
示例#4
0
        public static NEP5LedgerEntry New()
        {
            NEP5LedgerEntry e = new NEP5LedgerEntry();

            _Initialize(e);
            if (NeoTrace.RUNTIME)
            {
                LogExt("New().NEP5LedgerEntry", e);
            }
            return(e);
        }
        public static NEP5LedgerEntry Missing()
        {
            NEP5LedgerEntry e = new NEP5LedgerEntry();

            e._timestamp = 0; e._decription = ""; e._debitCreditAmount = 0; e._balance = 0;
            e._state     = NeoEntityModel.EntityState.MISSING;
            if (NeoTrace.RUNTIME)
            {
                LogExt("Missing().NEP5LedgerEntry", e);
            }
            return(e);
        }
示例#6
0
        public static NEP5LedgerEntry New(BigInteger Timestamp, string Decription, BigInteger DebitCreditAmount, BigInteger Balance)
        {
            NEP5LedgerEntry e = new NEP5LedgerEntry();

            e._timestamp = Timestamp; e._decription = Decription; e._debitCreditAmount = DebitCreditAmount; e._balance = Balance;
            e._state     = NeoEntityModel.EntityState.INIT;
            if (NeoTrace.RUNTIME)
            {
                LogExt("New(.,.).NEP5LedgerEntry", e);
            }
            return(e);
        }
        public static NEP5LedgerEntry Get(string key)
        {
            if (key.Length == 0)
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            string _skeyTag = key + _classKeyTag;

            NEP5LedgerEntry e;

            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sSTA);
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(skey).NEP5LedgerEntry.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = NEP5LedgerEntry.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                e = new NEP5LedgerEntry();

                BigInteger Timestamp         = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sTimestamp).AsBigInteger();         //NPCLevel2IGet_cs.txt
                string     Decription        = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sDecription).AsString();            //NPCLevel2IGet_cs.txt
                BigInteger DebitCreditAmount = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sDebitCreditAmount).AsBigInteger(); //NPCLevel2IGet_cs.txt
                BigInteger Balance           = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sBalance).AsBigInteger();           //NPCLevel2IGet_cs.txt
                if (NeoTrace.RUNTIME)
                {
                    TraceRuntime("Get(skey).e._timestamp, e._decription, e._debitCreditAmount, e._balance", e._timestamp, e._decription, e._debitCreditAmount, e._balance);                   // Template: NPCLevel2Part2_cs.txt
                }
                e._timestamp = Timestamp; e._decription = Decription; e._debitCreditAmount = DebitCreditAmount; e._balance = Balance;
                e._state     = sta;
                e._state     = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(skey).NEP5LedgerEntry", e);
            }
            return(e);
        }
        public static bool Put(NEP5LedgerEntry e, string key)
        {
            if (key.Length == 0)
            {
                return(false);
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Put(skey).NEP5LedgerEntry", e);
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            string _skeyTag = key + _classKeyTag;

            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Put(skey)._skeyTag", _skeyTag);
            }

            // no readonly fields byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sSTA);
            // no readonly fields if (NeoTrace.RUNTIME) TraceRuntime("Put(skey).bsta", bsta.Length, bsta);
            // no readonly fields bool isMissing = false; if (bsta.Length == 0) isMissing = true;

            e._state = NeoEntityModel.EntityState.PUTTED;
            BigInteger bis = e._state.AsBigInteger();

            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Put(skey).bis", bis);
            }
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sSTA, bis);
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sTimestamp, e._timestamp);                 // Template: NPCLevel2EPut_cs.txt
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sDecription, e._decription);               // Template: NPCLevel2EPut_cs.txt
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sDebitCreditAmount, e._debitCreditAmount); // Template: NPCLevel2EPut_cs.txt
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sBalance, e._balance);                     // Template: NPCLevel2EPut_cs.txt
            if (NeoTrace.RUNTIME)
            {
                LogExt("Put(skey).NEP5LedgerEntry", e);                   // Template: NPCLevel2FGet_cs.txt
            }
            return(true);
        }
        public static NEP5LedgerEntry Get(byte[] key)
        {
            if (key.Length == 0)
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            byte[] _bkeyTag = Helper.Concat(key, _bclassKeyTag);

            NEP5LedgerEntry e;

            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(bkey).bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = NEP5LedgerEntry.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                e = new NEP5LedgerEntry();

                BigInteger Timestamp         = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bTimestamp)).AsBigInteger();         //NPCLevel2GGet_cs.txt
                string     Decription        = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bDecription)).AsString();            //NPCLevel2GGet_cs.txt
                BigInteger DebitCreditAmount = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bDebitCreditAmount)).AsBigInteger(); //NPCLevel2GGet_cs.txt
                BigInteger Balance           = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bBalance)).AsBigInteger();           //NPCLevel2GGet_cs.txt
                e._timestamp = Timestamp; e._decription = Decription; e._debitCreditAmount = DebitCreditAmount; e._balance = Balance;                                  // Template: NPCLevel2HGet_cs.txt
                e._state     = sta;
                e._state     = NeoEntityModel.EntityState.GETTED;                                                                                                      /* OVERRIDE */
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(bkey).NEP5LedgerEntry", e);
            }
            return(e);
        }
 // Persistable methods
 public static bool IsMissing(NEP5LedgerEntry e)
 {
     return(e._state == NeoEntityModel.EntityState.MISSING);
 }
示例#11
0
 public static void SetDecription(NEP5LedgerEntry e, string value) // Template: NPCLevel1SetXGetX_cs.txt
 {
     e._decription = value; e._state = NeoEntityModel.EntityState.SET;
 }
示例#12
0
 public static void Set(NEP5LedgerEntry e, BigInteger Timestamp, string Decription, BigInteger DebitCreditAmount, BigInteger Balance) // Template: NPCLevel1Set_cs.txt
 {
     { e._timestamp = Timestamp; e._decription = Decription; e._debitCreditAmount = DebitCreditAmount; e._balance = Balance;  e._state = NeoEntityModel.EntityState.SET; }
 }
示例#13
0
 // EntityState wrapper methods
 public static bool IsNull(NEP5LedgerEntry e)
 {
     return(e._state == NeoEntityModel.EntityState.NULL);
 }
示例#14
0
 public static void SetBalance(NEP5LedgerEntry e, BigInteger value) // Template: NPCLevel1SetXGetX_cs.txt
 {
     e._balance = value; e._state = NeoEntityModel.EntityState.SET;
 }
示例#15
0
 public static BigInteger GetBalance(NEP5LedgerEntry e)
 {
     return(e._balance);
 }
示例#16
0
 public static BigInteger GetDebitCreditAmount(NEP5LedgerEntry e)
 {
     return(e._debitCreditAmount);
 }
示例#17
0
 public static void SetDebitCreditAmount(NEP5LedgerEntry e, BigInteger value) // Template: NPCLevel1SetXGetX_cs.txt
 {
     e._debitCreditAmount = value; e._state = NeoEntityModel.EntityState.SET;
 }
示例#18
0
 public static string GetDecription(NEP5LedgerEntry e)
 {
     return(e._decription);
 }
示例#19
0
 public static void LogExt(string label, NEP5LedgerEntry e)
 {
     TraceRuntime(label, e._timestamp, e._decription, e._debitCreditAmount, e._balance, e._state);
 }
示例#20
0
 public static BigInteger GetTimestamp(NEP5LedgerEntry e)
 {
     return(e._timestamp);
 }