예제 #1
0
        public static object Main(string operation, params object[] args)
        {
            object result = false;

            NeoVersionedAppUser AppVAU = NeoVersionedAppUser.New("NPC.mwherman2000.NeoExpenses1.Contract", 1, 1, 1, "7074acf3f06dd3f456e11053ebf61c5b04b07ebc".AsByteArray()); // DEBUG ONLY

            if (NeoTrace.TESTING)
            {
                NeoVersionedAppUser.LogExt("AppVAU", AppVAU);
            }

            NPCNEP5Base tokenBase = NPCNEP5Base.New("My Meetup Token", "MMT", 8, 1000000);

            if (NeoTrace.VERBOSE)
            {
                NPCNEP5Base.Log("tokenBase", tokenBase);
            }

            result = ProcessOperation(AppVAU, tokenBase, operation, args);

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("result", result);
            }

            return(result);
        }
예제 #2
0
        public static NPCNEP5LedgerEntry UpdateLedger(NPCNEP5Base tokenBase)
        {
            NPCNEP5LedgerEntry e = new NPCNEP5LedgerEntry();

            throw new NotImplementedException();

            return(e);
        }
 // Factory methods // Template: NPCLevel1Part2_cs.txt
 private static NPCNEP5Base _Initialize(NPCNEP5Base e)
 {
     e._name  = ""; e._symbol = ""; e._decimals = 0; e._totalSupply = 0;
     e._state = NeoEntityModel.EntityState.NULL;
     if (NeoTrace.RUNTIME)
     {
         LogExt("_Initialize(e).NPCNEP5Base", e);
     }
     return(e);
 }
        public static NPCNEP5Base New()
        {
            NPCNEP5Base e = new NPCNEP5Base();

            _Initialize(e);
            if (NeoTrace.RUNTIME)
            {
                LogExt("New().NPCNEP5Base", e);
            }
            return(e);
        }
예제 #5
0
        public static byte decimals(NPCNEP5Base tokenBase)
        {
            byte decimals = (byte)NPCNEP5Base.GetDecimals(tokenBase);

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

            return(decimals);
        }
예제 #6
0
        public static string symbol(NPCNEP5Base tokenBase)
        {
            string symbol = NPCNEP5Base.GetSymbol(tokenBase);

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

            return(symbol);
        }
예제 #7
0
        public static string name(NPCNEP5Base tokenBase)
        {
            string name = NPCNEP5Base.GetName(tokenBase);

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

            return(name);
        }
예제 #8
0
        public static BigInteger totalSupply(NPCNEP5Base tokenBase)
        {
            BigInteger totalSupply = NPCNEP5Base.GetTotalSupply(tokenBase);

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("totalSupply():entered$INT", totalSupply);
            }

            return(totalSupply);
        }
        public static NPCNEP5Base New(string Name, string Symbol, Int32 Decimals, BigInteger TotalSupply)
        {
            NPCNEP5Base e = new NPCNEP5Base();

            e._name  = Name; e._symbol = Symbol; e._decimals = Decimals; e._totalSupply = TotalSupply;
            e._state = NeoEntityModel.EntityState.INIT;
            if (NeoTrace.RUNTIME)
            {
                LogExt("New(.,.).NPCNEP5Base", e);
            }
            return(e);
        }
예제 #10
0
        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 string GetName(NPCNEP5Base e)
 {
     return(e._name);
 }
예제 #12
0
        public static object ProcessOperation(NeoVersionedAppUser AppVAU, NPCNEP5Base tokenBase, string operation, object[] args)
        {
            object result = false;

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("operation", operation);
            }

            if (operation == "deploy")
            {
                result = deploy(tokenBase);
            }
            else if (operation == "ping")
            {
                result = ping();
            }

            else if (operation == "name")
            {
                result = name(tokenBase);
            }
            else if (operation == "symbol")
            {
                result = symbol(tokenBase);
            }
            else if (operation == "decimals")
            {
                result = decimals(tokenBase);
            }
            else if (operation == "totalSupply")
            {
                result = totalSupply(tokenBase);
            }
            else if (operation == "balanceOf")
            {
                byte[] account = (byte[])args[0];
                if (NeoTrace.TESTING && account[0] == 0x0) // DEBUGGING
                {
                    account = OwnerAccountScriptHash;
                    if (NeoTrace.VERBOSE)
                    {
                        NeoTrace.Trace("DEBUGGING:from", account);
                    }
                }
                result = balanceOf(account);
            }
            else if (operation == "transfer")
            {
                if (args.Length == 3)
                {
                    // https://github.com/neo-project/examples-csharp/blob/master/ICO_Template/ICO_Template.cs#L59
                    byte[]     from   = (byte[])args[0];
                    byte[]     to     = (byte[])args[1];
                    BigInteger amount = (BigInteger)args[2];
                    if (NeoTrace.TESTING && from[0] == 0x0) // DEBUGGING
                    {
                        from = OwnerAccountScriptHash;
                        if (NeoTrace.VERBOSE)
                        {
                            NeoTrace.Trace("DEBUGGING:from", from);
                        }
                    }
                    result = transfer(from, to, amount);
                }
            }
            else if (operation == "allowance")
            {
                byte[] from = (byte[])args[0];
                byte[] to   = (byte[])args[1];
                if (NeoTrace.TESTING && from[0] == 0x0) // DEBUGGING
                {
                    from = OwnerAccountScriptHash;
                    if (NeoTrace.VERBOSE)
                    {
                        NeoTrace.Trace("DEBUGGING:from", from);
                    }
                }
                result = allowance(from, to); // optional
            }
            else if (operation == "transferFrom")
            {
                byte[]     originator = OwnerAccountScriptHash;
                byte[]     from       = (byte[])args[0];
                byte[]     to         = (byte[])args[1];
                BigInteger amount     = (BigInteger)args[2];
                if (NeoTrace.TESTING && originator[0] == 0x0) // DEBUGGING
                {
                    originator = OwnerAccountScriptHash;
                    if (NeoTrace.VERBOSE)
                    {
                        NeoTrace.Trace("DEBUGGING:originator", originator);
                    }
                }
                result = transferFrom(originator, from, to, amount); // optional
            }
            else if (operation == "approve")
            {
                byte[]     originator = OwnerAccountScriptHash;
                byte[]     to         = (byte[])args[0];
                BigInteger amount     = (BigInteger)args[1];
                if (NeoTrace.TESTING && originator[0] == 0x0) // DEBUGGING
                {
                    originator = OwnerAccountScriptHash;
                    if (NeoTrace.VERBOSE)
                    {
                        NeoTrace.Trace("DEBUGGING:originator", originator);
                    }
                }
                result = approve(originator, to, amount); // optional
            }
            else if (operation == "createUser")
            {
                result = UserCredentials.CreateUser(AppVAU, args);
            }
            else if (operation == "getUser")
            {
                result = UserCredentials.GetUser(AppVAU, args);
            }
            //else if (operation == "getUsers")
            //{
            //    result = UserCredentials.GetUsers(AppVAU, args);
            //}
            else if (operation == "CreateContributor")
            {
                result = NPCContributor.CreateContributor(AppVAU, args);
            }
            else if (operation == "getContributor")
            {
                result = NPCContributor.GetContributor(AppVAU, args);
            }
            //else if (operation == "getContributors")
            //{
            //    result = NPCContributor.GetContributors(AppVAU, args);
            //}
            else if (operation == "createRequisition")
            {
                result = NPCNEP5Requisition.CreateRequisition(AppVAU, args);
            }
            else if (operation == "submitRequisition")
            {
                result = NPCNEP5Requisition.SubmitRequisition(AppVAU, args);
            }
            else if (operation == "getContributorRequisitions")
            {
                result = NPCNEP5Requisition.GetContributorRequisitions(AppVAU, args);
            }
            else if (operation == "updateRequisition")
            {
                result = NPCNEP5Requisition.UpdateRequisition(AppVAU, args);
            }
            else if (operation == "payRequisition")
            {
                result = NPCNEP5Requisition.PayRequisition(AppVAU, args);
            }
            else
            {
                if (NeoTrace.INFO)
                {
                    NeoTrace.Trace("Unknown operation", operation);
                }
                string message = "unknown operation '" + operation + "'";
                if (NeoTrace.ERROR)
                {
                    NeoTrace.Trace("**ERROR** operation", message);
                }
                result = false;
            }

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("result", result);
            }

            return(result);
        }
 public static BigInteger GetTotalSupply(NPCNEP5Base e)
 {
     return(e._totalSupply);
 }
 public static void Set(NPCNEP5Base e, string Name, string Symbol, Int32 Decimals, BigInteger TotalSupply) // Template: NPCLevel1Set_cs.txt
 {
     e._name = Name; e._symbol = Symbol; e._decimals = Decimals; e._totalSupply = TotalSupply;  e._state = NeoEntityModel.EntityState.SET;
 }
 public static Int32 GetDecimals(NPCNEP5Base e)
 {
     return(e._decimals);
 }
 public static void SetTotalSupply(NPCNEP5Base e, BigInteger value) // Template: NPCLevel1SetXGetX_cs.txt
 {
     e._totalSupply = value; e._state = NeoEntityModel.EntityState.SET;
 }
 public static void SetDecimals(NPCNEP5Base e, Int32 value) // Template: NPCLevel1SetXGetX_cs.txt
 {
     e._decimals = value; e._state = NeoEntityModel.EntityState.SET;
 }
 public static string GetSymbol(NPCNEP5Base e)
 {
     return(e._symbol);
 }
 public static void SetSymbol(NPCNEP5Base e, string value) // Template: NPCLevel1SetXGetX_cs.txt
 {
     e._symbol = value; e._state = NeoEntityModel.EntityState.SET;
 }
 // EntityState wrapper methods
 public static bool IsNull(NPCNEP5Base e)
 {
     return(e._state == NeoEntityModel.EntityState.NULL);
 }
 public static void LogExt(string label, NPCNEP5Base e)
 {
     TraceRuntime(label, e._name, e._symbol, e._decimals, e._totalSupply, e._state);
 }