Esempio n. 1
0
        //查询需要赎回余额
        async Task test_balanceOfRedeem()
        {
            var result = await sar_common.api_InvokeScript(sar_common.sc_sar, "balanceOfRedeem", "(addr)" + this.address);

            sar_common.ResultItem item = result.value;

            Console.WriteLine(item.subItem[0].AsInteger());
        }
Esempio n. 2
0
        //查询需要赎回余额
        async Task test_getBondGlobal()
        {
            var result = await sar_common.api_InvokeScript(Config.sar4c, "getBondGlobal");

            sar_common.ResultItem item = result.value;

            Console.WriteLine(item.subItem[0].AsInteger());
        }
Esempio n. 3
0
        async Task test_getAllSAR4C()
        {
            //查询所有状态为1的SAR
            DateTime dt = DateTime.Now;

            Console.WriteLine("Start time:" + dt);

            byte[] postdata;
            var    url = Helper.MakeRpcUrlPost(Config.api, "getsar4CListByType", out postdata,
                                               new JsonNode_ValueNumber(1),
                                               new JsonNode_ValueNumber(1000),
                                               new JsonNode_ValueNumber(1));
            var result = await Helper.HttpPost(url, postdata);

            List <string> list = new List <string>();

            MyJson.JsonNode_Object json = MyJson.Parse(result) as MyJson.JsonNode_Object;
            JsonNode_Array         arrs = json["result"].AsList();

            foreach (JsonNode_Object ob in arrs)
            {
                string addr = ob["addr"].AsString();

                Console.WriteLine("addr" + addr);

                //查询旧合约SAR
                var result2 = await sar_common.api_InvokeScript(Config.sar4c, "getSAR4C", "(addr)" + addr);

                sar_common.ResultItem   item  = result2.value;
                sar_common.ResultItem[] items = item.subItem[0].subItem;

                if (items != null)
                {
                    string     owner     = ThinNeo.Helper.GetAddressFromScriptHash(items[0].AsHash160());
                    string     txid      = items[1].AsHashString();
                    BigInteger locked    = items[2].AsInteger();
                    BigInteger hasDrawed = items[3].AsInteger();
                    string     assetType = items[4].AsString();
                    BigInteger status    = items[5].AsInteger();

                    Console.WriteLine("###############");
                    Console.WriteLine("from:" + owner);
                    Console.WriteLine("txid:" + txid);
                    Console.WriteLine("locked:" + locked);
                    Console.WriteLine("hasDrawed:" + hasDrawed);
                    Console.WriteLine("assetType:" + assetType);
                    Console.WriteLine("status:" + status);
                    //Console.WriteLine("bondLocked:" + items[6].AsInteger());
                    //Console.WriteLine("bondDrawed:" + items[7].AsInteger());
                }
            }
            DateTime end = DateTime.Now;

            Console.WriteLine("End time:" + end);
        }
Esempio n. 4
0
        //查询配置信息
        async Task test_getConfig()
        {
            Console.WriteLine("Input config key:");
            string key = Console.ReadLine();

            var result = await sar_common.api_InvokeScript(sar_common.sc_sar, "getConfig", "(str)" + key);

            sar_common.ResultItem item = result.value;

            Console.WriteLine(item.subItem[0].AsInteger());
        }
Esempio n. 5
0
        //查询配置信息
        async Task test_getConfig()
        {
            //Console.WriteLine("Input config key:");
            //string key = Console.ReadLine();

            var result = await sar_common.api_InvokeScript(Config.sar4c, "getConfig", "(str)sar_state");

            sar_common.ResultItem item = result.value;

            Console.WriteLine(item.subItem[0].AsInteger());
        }
Esempio n. 6
0
        async Task test_getRescue()
        {
            Console.WriteLine("Input asset type:");
            var assetType = Console.ReadLine();
            var result    = await sar_common.api_InvokeScript(Config.sar4c, "getRescue",
                                                              "(str)" + assetType,
                                                              "(addr)" + this.address);

            sar_common.ResultItem item = result.value;

            Console.WriteLine(item.subItem[0].AsInteger());
        }
Esempio n. 7
0
        //查询交易信息
        async Task test_getTXInfo()
        {
            Console.WriteLine("Input txid:");
            string txid   = Console.ReadLine();
            var    result = await sar_common.api_InvokeScript(sar_common.sc_sar, "getTXInfo", "(hex256)" + txid);

            sar_common.ResultItem   item  = result.value;
            sar_common.ResultItem[] items = item.subItem[0].subItem;

            //查询交易详细信息
            Console.WriteLine("from:" + ThinNeo.Helper.GetAddressFromScriptHash(items[0].AsHash160()));
            Console.WriteLine("to:" + ThinNeo.Helper.GetAddressFromScriptHash(items[1].AsHash160()));
            Console.WriteLine("value:" + items[2].AsInteger());
        }
Esempio n. 8
0
        //查询SAR信息
        async Task test_getSAR()
        {
            Console.WriteLine("Current address:" + this.address);
            Console.WriteLine("Input address:");
            string addr = Console.ReadLine();

            if (addr == null || addr == "")
            {
                addr = address;
            }
            var result = await sar_common.api_InvokeScript(Config.sar4c, "getSAR4C", "(addr)" + addr);

            sar_common.ResultItem   item  = result.value;
            sar_common.ResultItem[] items = item.subItem[0].subItem;

            if (items != null)
            {
                var result2 = await datacenter_common.api_InvokeScript(Config.oracle, "getTypeB", "(str)sneo_price");

                datacenter_common.ResultItem item2 = result2.value;
                Console.WriteLine("sneo_price:" + item2.subItem[0].AsInteger());

                Console.WriteLine("from:" + ThinNeo.Helper.GetAddressFromScriptHash(items[0].AsHash160()));
                Console.WriteLine("txid:" + items[1].AsHashString());
                Console.WriteLine("locked:" + items[2].AsInteger());
                Console.WriteLine("hasDrawed:" + items[3].AsInteger());
                Console.WriteLine("assetType:" + items[4].AsString());
                Console.WriteLine("status:" + items[5].AsInteger());
                Console.WriteLine("bondLocked:" + items[6].AsInteger());
                Console.WriteLine("bondDrawed:" + items[7].AsInteger());
                Console.WriteLine("lastHeight:" + items[8].AsInteger());
                Console.WriteLine("fee:" + items[9].AsInteger());
                Console.WriteLine("sdsFee:" + items[10].AsInteger());
            }
            else
            {
                Console.WriteLine("no sar exists");
            }
        }
Esempio n. 9
0
        //查询SAR信息
        async Task test_getSAR()
        {
            Console.WriteLine("Input address:");
            string address = Console.ReadLine();
            var    result  = await sar_common.api_InvokeScript(sar_common.sc_sar, "getSAR4C", "(addr)" + address);

            sar_common.ResultItem   item  = result.value;
            sar_common.ResultItem[] items = item.subItem[0].subItem;

            if (items != null)
            {
                Console.WriteLine("from:" + ThinNeo.Helper.GetAddressFromScriptHash(items[0].AsHash160()));
                Console.WriteLine("txid:" + items[1].AsHashString());
                Console.WriteLine("locked:" + items[2].AsInteger());
                Console.WriteLine("hasDrawed:" + items[3].AsInteger());
                Console.WriteLine("assetType:" + items[4].AsString());
                Console.WriteLine("status:" + items[5].AsInteger());
            }
            else
            {
                Console.WriteLine("no sar exists");
            }
        }
Esempio n. 10
0
        //查询SAR详细交易信息
        async Task test_getSARTxInfo()
        {
            Console.WriteLine("Input txid:");
            string txid   = Console.ReadLine();
            var    result = await sar_common.api_InvokeScript(sar_common.sc_sar, "getSARTxInfo", "(hex256)" + txid);

            sar_common.ResultItem   item  = result.value;
            sar_common.ResultItem[] items = item.subItem[0].subItem;

            if (items != null)
            {
                Console.WriteLine("from:" + ThinNeo.Helper.GetAddressFromScriptHash(items[0].AsHash160()));
                Console.WriteLine("cdpTxid:" + items[1].AsHashString());
                Console.WriteLine("txid:" + items[2].AsHashString());
                Console.WriteLine("operated:" + items[3].AsInteger());
                Console.WriteLine("hasLocked:" + items[4].AsInteger() + " PNEO");
                Console.WriteLine("hasDrawed:" + items[5].AsInteger() + " SDUSD");
                Console.WriteLine("type:" + items[6].AsInteger());
            }
            else
            {
                Console.WriteLine("no txInfo exists");
            }
        }