示例#1
0
        /// <summary>
        /// Collectible methods (NPC Level 4)
        /// </summary>
        /// <param name="e">e</param>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>bool</returns>
        public static bool PutElement(UserCredentials e, NeoVersionedAppUser vau, byte[] domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(false);
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            //byte[] bkey;
            e._state = NeoEntityModel.EntityState.PUTTED;
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA), e._state.AsBigInteger());

            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bEncodedUsername), e._encodedUsername); // Template: NPCLevel4APutElement_cs.txt

            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bEncodedPassword), e._encodedPassword); // Template: NPCLevel4APutElement_cs.txt

            if (NeoTrace.RUNTIME)
            {
                LogExt("PutElement(vau,i).UserCredentials", e);                   // Template: NPCLevel4BGetElement_cs.txt
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>NPCContributor</returns>
        public static NPCContributor GetElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            NPCContributor e;

            //byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(bkey).NPCContributor.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = NPCContributor.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = NPCContributor.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new NPCContributor();
                    string Name = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bName)).AsString();                  // Template: NPCLevel4CGetElement_cs.txt

                    string Title = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bTitle)).AsString();                // Template: NPCLevel4CGetElement_cs.txt

                    byte[] ApproverScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bApproverScriptHash)); // Template: NPCLevel4CGetElement_cs.txt

                    byte[] ReqPublicKey = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bReqPublicKey));             // Template: NPCLevel4CGetElement_cs.txt

                    e._name  = Name; e._title = Title; e._approverScriptHash = ApproverScriptHash; e._reqPublicKey = ReqPublicKey;                                      // NPCLevel4DBuryElement_cs.txt
                    e._state = sta;
                    e._state = NeoEntityModel.EntityState.GETTED;                                                                                                       /* OVERRIDE */
                }
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(bkey).NPCContributor.e", e);
            }
            return(e);
        }
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>Point</returns>
        public static Point GetElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            Point e;

            //byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(bkey).Point.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = Point.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = Point.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new Point();
                    BigInteger X = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bX)).AsBigInteger(); // Template: NPCLevel4CGetElement_cs.txt

                    BigInteger Y = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bY)).AsBigInteger(); // Template: NPCLevel4CGetElement_cs.txt

                    e._x     = X; e._y = Y;                                                                                                              // NPCLevel4DBuryElement_cs.txt
                    e._state = sta;
                    e._state = NeoEntityModel.EntityState.GETTED;                                                                                        /* OVERRIDE */
                }
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(bkey).Point.e", e);
            }
            return(e);
        }
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>MeetupAttendee</returns>
        public static MeetupAttendee GetElement(NeoVersionedAppUser vau, byte[] domain, int index)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            MeetupAttendee e;

            //byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(bkey).MeetupAttendee.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = MeetupAttendee.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = MeetupAttendee.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new MeetupAttendee();
                    string AttendeeName = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttendeeName)).AsString();                                                               // Template: NPCLevel4CGetElement_cs.txt

                    string AttendeeID = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttendeeID)).AsString();                                                                   // Template: NPCLevel4CGetElement_cs.txt

                    string AttendeeUrl = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttendeeUrl)).AsString();                                                                 // Template: NPCLevel4CGetElement_cs.txt

                    string AttendeePhotoUrl = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttendeePhotoUrl)).AsString();                                                       // Template: NPCLevel4CGetElement_cs.txt

                    string MeetingID = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bMeetingID)).AsString();                                                                     // Template: NPCLevel4CGetElement_cs.txt

                    string MeetingUrl = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bMeetingUrl)).AsString();                                                                   // Template: NPCLevel4CGetElement_cs.txt

                    BigInteger Attended = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttended)).AsBigInteger();                                                               // Template: NPCLevel4CGetElement_cs.txt

                    e._attendeeName = AttendeeName; e._attendeeID = AttendeeID; e._attendeeUrl = AttendeeUrl; e._attendeePhotoUrl = AttendeePhotoUrl; e._meetingID = MeetingID; e._meetingUrl = MeetingUrl; e._attended = Attended; // NPCLevel4DBuryElement_cs.txt
                    e._state        = sta;
                    e._state        = NeoEntityModel.EntityState.GETTED;                                                                                                                                                            /* OVERRIDE */
                }
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(bkey).MeetupAttendee.e", e);
            }
            return(e);
        }
示例#5
0
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>UserCredentials</returns>
        public static UserCredentials GetElement(NeoVersionedAppUser vau, string domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, "UserCredentials");

            UserCredentials e;

            byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bSTA));
            NeoTrace.Trace("Get(bkey).UserCredentials.bsta", bsta.Length, bsta);
            if (bsta.Length == 0)
            {
                e = UserCredentials.Missing();
            }
            else // not MISSING
            {
                /*EXT*/
                byte[] bext = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEXT));
                int    ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = UserCredentials.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new UserCredentials();
                    byte[] EncodedUsername = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEncodedUsername)); // Template: NPCLevel4CGetElement_cs.txt
                    byte[] EncodedPassword = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEncodedPassword)); // Template: NPCLevel4CGetElement_cs.txt
                    e._encodedUsername = EncodedUsername; e._encodedPassword = EncodedPassword;                                                                          // NPCLevel4DBuryElement_cs.txt
                    e._state           = sta;
                    e._state           = NeoEntityModel.EntityState.GETTED;                                                                                              /* OVERRIDE */
                }
            }
            LogExt("Get(bkey).UserCredentials.e", e);
            return(e);
        }
示例#6
0
        /// <summary>
        /// Bury an element of an array of entities in Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>UserCredentials</returns>
        public static UserCredentials BuryElement(NeoVersionedAppUser vau, string domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau)) // TODO - create NeoEntityModel.EntityState.BADKEY?
            {
                return(UserCredentials.Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, "UserCredentials");

            byte[]          bkey;
            UserCredentials e;

            /*STA*/
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bSTA));
            NeoTrace.Trace("Bury(vau,index).UserCredentials.bsta", bsta.Length, bsta);
            if (bsta.Length == 0)
            {
                e = UserCredentials.Missing();
            }
            else // not MISSING - bury it
            {
                e = UserCredentials.Tombstone(); // TODO - should Bury() preserve the exist field values or re-initialize them? Preserve is cheaper but not as private
                Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bSTA), e._state.AsBigInteger());

                Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEncodedUsername), e._encodedUsername); // NPCLevel4EBuryElement_cs.txt
                Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEncodedPassword), e._encodedPassword); // NPCLevel4EBuryElement_cs.txt
            } // Template: NPCLevel4Part2_cs.txt
            LogExt("Bury(vau,i).UserCredentials", e);
            return(e);
        }
示例#7
0
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>Line</returns>
        public static Line GetElement(NeoVersionedAppUser vau, string domain, int index)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, "Line");

            Line e;

            byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bSTA));
            NeoTrace.Trace("Get(bkey).Line.bsta", bsta.Length, bsta);
            if (bsta.Length == 0)
            {
                e = Line.Missing();
            }
            else // not MISSING
            {
                /*EXT*/
                byte[] bext = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bEXT));
                int    ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = Line.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new Line();
                    byte[] BKeyP1 = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bBKeyP1)); // Template: NPCLevel4CGetElement_cs.txt
                    byte[] BKeyP2 = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bBKeyP2)); // Template: NPCLevel4CGetElement_cs.txt
                    e._bKeyP1 = BKeyP1; e._bKeyP2 = BKeyP2;                                                                                           // NPCLevel4DBuryElement_cs.txt
                    e._state  = sta;
                    e._state  = NeoEntityModel.EntityState.GETTED;                                                                                    /* OVERRIDE */
                }
            }
            LogExt("Get(bkey).Line.e", e);
            return(e);
        }
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>NPCNEP5Requisition</returns>
        public static NPCNEP5Requisition GetElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            NPCNEP5Requisition e;

            //byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(bkey).NPCNEP5Requisition.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = NPCNEP5Requisition.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = NPCNEP5Requisition.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new NPCNEP5Requisition();
                    byte[] FromScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bFromScriptHash));                    // Template: NPCLevel4CGetElement_cs.txt

                    byte[] ToScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bToScriptHash));                        // Template: NPCLevel4CGetElement_cs.txt

                    string EncryptedBlobURI = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bEncryptedBlobURI)).AsString();     // Template: NPCLevel4CGetElement_cs.txt

                    Int32 WorkflowState = (Int32)Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bWorkflowState)).AsBigInteger(); // Template: NPCLevel4CGetElement_cs.txt

                    e._fromScriptHash = FromScriptHash; e._toScriptHash = ToScriptHash; e._encryptedBlobURI = EncryptedBlobURI; e._workflowState = WorkflowState;                  // NPCLevel4DBuryElement_cs.txt
                    e._state          = sta;
                    e._state          = NeoEntityModel.EntityState.GETTED;                                                                                                         /* OVERRIDE */
                }
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(bkey).NPCNEP5Requisition.e", e);
            }
            return(e);
        }
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>NFT</returns>
        public static NFT GetElement(NeoVersionedAppUser vau, byte[] domain, int index)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            NFT e;

            //byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(bkey).NFT.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = NFT.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = NFT.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new NFT();
                    string Uri = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bUri)).AsString();             // Template: NPCLevel4CGetElement_cs.txt

                    string FirstName = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bFirstName)).AsString(); // Template: NPCLevel4CGetElement_cs.txt

                    string LastName = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bLastName)).AsString();   // Template: NPCLevel4CGetElement_cs.txt

                    e._uri   = Uri; e._firstName = FirstName; e._lastName = LastName;                                                                           // NPCLevel4DBuryElement_cs.txt
                    e._state = sta;
                    e._state = NeoEntityModel.EntityState.GETTED;                                                                                               /* OVERRIDE */
                }
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(bkey).NFT.e", e);
            }
            return(e);
        }
示例#10
0
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>UserLedgerEntry</returns>
        public static UserLedgerEntry GetElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            UserLedgerEntry e;

            //byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(bkey).UserLedgerEntry.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = UserLedgerEntry.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = UserLedgerEntry.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new UserLedgerEntry();
                    byte[] UserScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bUserScriptHash));             // Template: NPCLevel4CGetElement_cs.txt

                    byte[] PassphraseScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bPassphraseScriptHash)); // Template: NPCLevel4CGetElement_cs.txt

                    e._userScriptHash = UserScriptHash; e._passphraseScriptHash = PassphraseScriptHash;                                                                     // NPCLevel4DBuryElement_cs.txt
                    e._state          = sta;
                    e._state          = NeoEntityModel.EntityState.GETTED;                                                                                                  /* OVERRIDE */
                }
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(bkey).UserLedgerEntry.e", e);
            }
            return(e);
        }
示例#11
0
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>NeoCounter</returns>
        public static NeoCounter GetElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, "NeoCounter");

            NeoCounter e;

            byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bSTA));
            NeoTrace.Trace("Get(bkey).NeoCounter.bsta", bsta.Length, bsta);
            if (bsta.Length == 0)
            {
                e = NeoCounter.Missing();
            }
            else // not MISSING
            {
                /*EXT*/
                byte[] bext = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEXT));
                int    ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = NeoCounter.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new NeoCounter();
                    BigInteger CurrentNumber = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bCurrentNumber)).AsBigInteger(); // Template: NPCLevel4CGetElement_cs.txt
                    e._currentNumber = CurrentNumber;                                                                                                                                   // NPCLevel4DBuryElement_cs.txt
                    e._state         = sta;
                    e._state         = NeoEntityModel.EntityState.GETTED;                                                                                                               /* OVERRIDE */
                }
            }
            LogExt("Get(bkey).NeoCounter.e", e);
            return(e);
        }
示例#12
0
        /// <summary>
        /// Bury an element of an array of entities in Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>Point</returns>
        public static Point BuryElement(NeoVersionedAppUser vau, int index)
        {
            if (NeoVersionedAppUser.IsNull(vau)) // TODO - create NeoEntityModel.EntityState.BADKEY?
            {
                return(Point.Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, "Point");

            byte[] bkey;
            Point  p;

            /*STA*/
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bSTA));
            NeoTrace.Trace("Bury(vau,index).bs", bsta.Length, bsta);
            if (bsta.Length == 0)
            {
                p = Point.Missing();
            }
            else // not MISSING - bury it
            {
                p = Point.Tombstone(); // TODO - should Bury() preserve the exist field values or re-initialize them? Preserve is cheaper but not as private
                Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bSTA), p._state.AsBigInteger());
                Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bX), p._x);
                Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bY), p._y);
            }
            LogExt("Bury(vau,i).p", p);
            return(p);
        }
示例#13
0
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>Point</returns>
        public static Point GetElement(NeoVersionedAppUser vau, int index)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, "Point");

            Point p;

            byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bSTA));
            NeoTrace.Trace("Get(kb).bs", bsta.Length, bsta);
            if (bsta.Length == 0)
            {
                p = Point.Missing();
            }
            else // not MISSING
            {
                /*EXT*/
                byte[] bext = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bEXT));
                int    ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    p = Point.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    p = new Point();
                    BigInteger x = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bX)).AsBigInteger();
                    BigInteger y = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bY)).AsBigInteger();
                    p._x     = x; p._y = y;
                    p._state = sta;
                    p._state = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */
                }
            }
            LogExt("Get(kb).p", p);
            return(p);
        }