Пример #1
0
        public static void uploadScript(string api, string path, string hash)
        {
            System.Net.WebClient wc = new MyWebClient();
            try
            {
                System.Collections.Specialized.NameValueCollection vs = new System.Collections.Specialized.NameValueCollection();
                vs["jsonrpc"] = "2.0";
                vs["id"]      = "1";
                vs["method"]  = "setcontractscript";
                MyJson.JsonNode_Array  array   = new MyJson.JsonNode_Array();
                MyJson.JsonNode_Object jsonmap = new MyJson.JsonNode_Object();
                jsonmap["hash"] = new MyJson.JsonNode_ValueString(hash);
                var avm = System.IO.File.ReadAllBytes(System.IO.Path.Combine(path, hash + ".avm"));
                var cs  = System.IO.File.ReadAllText(System.IO.Path.Combine(path, hash + ".cs"));
                var map = System.IO.File.ReadAllText(System.IO.Path.Combine(path, hash + ".map.json"));
                var abi = System.IO.File.ReadAllText(System.IO.Path.Combine(path, hash + ".abi.json"));

                jsonmap["avm"] = new MyJson.JsonNode_ValueString(ThinNeo.Helper.Bytes2HexString(avm));
                jsonmap["cs"]  = new MyJson.JsonNode_ValueString(Uri.EscapeDataString(cs));
                jsonmap["map"] = MyJson.Parse(map);
                jsonmap["abi"] = MyJson.Parse(abi);
                array.Add(new MyJson.JsonNode_ValueString(jsonmap.ToString()));
                vs["params"] = array.ToString();

                var ret = wc.UploadValues(api, vs);
                var txt = System.Text.Encoding.UTF8.GetString(ret);
                MessageBox.Show(txt);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
Пример #2
0
    IEnumerator HTTP_nel_post_tan(byte[] script, MyJson.JsonNode_Array pararms, Action <bool, WWW> call_back)
    {
        WWWForm www_getuxo_form = Helper.GetWWWFormPost("getutxo", new MyJson.JsonNode_ValueString(roleInfo.getInstance().address));
        WWW     www             = new WWW(global.api, www_getuxo_form);

        yield return(www);

        Dictionary <string, List <Utxo> > _dir = get_utxo(www.text);

        if (_dir.ContainsKey(global.id_GAS) == false)
        {
            Debug.Log("no gas");
            yield return(null);
        }

        ThinNeo.Transaction tran = null;
        {
            tran      = Helper.makeTran(_dir[global.id_GAS], roleInfo.getInstance().address, new ThinNeo.Hash256(global.id_GAS), 0);
            tran.type = ThinNeo.TransactionType.InvocationTransaction;
            var idata = new ThinNeo.InvokeTransData();
            tran.extdata = idata;
            idata.script = script;
        }

        //sign and broadcast
        var signdata = ThinNeo.Helper.Sign(tran.GetMessage(), roleInfo.getInstance().prikey);

        tran.AddWitness(signdata, roleInfo.getInstance().pubkey, roleInfo.getInstance().address);
        var trandata    = tran.GetRawData();
        var strtrandata = ThinNeo.Helper.Bytes2HexString(trandata);

        WWWForm www_form_sendraw = Helper.GetWWWFormPost("sendrawtransaction", new MyJson.JsonNode_ValueString(strtrandata));
        WWW     sendraw          = new WWW(global.api, www_form_sendraw);

        yield return(sendraw);

        var json = MyJson.Parse(sendraw.text).AsDict();

        if (json.ContainsKey("result"))
        {
            var resultv = json["result"].AsList()[0].AsDict();
            var txid    = resultv["txid"].AsString();
            if (txid.Length > 0)
            {
                //Nep55_1.lastNep5Tran = tran.GetHash();
            }
            Debug.Log("txid=" + txid);

            api_tool._instance.addUserWalletLogs(roleInfo.getInstance().uid, roleInfo.getInstance().token, txid,
                                                 global.game_id.ToString(), "", "5", pararms.ToString(), global.netType, "0",
                                                 (bool timeout1, WWW www1) => { testtool.panel_main.on_refresh_WalletListss(); });
        }
        else
        {
            Debug.Log("交易失败");
            //testtool.showNotice("交易失败");
        }
    }
Пример #3
0
    void SaveItem()
    {
        //GameObject setobj = null;//选中的对象
        //bool bUseHashName = true;//是否使用hash作为资源文件名
        //string exportResult = null;//导出结果
        //string exportPath = null;//导出路径
        //bool bUseHashTreeName = false;//是否使用hash作为导出节点名
        //string exportNodeName = "";//导出节点名称

        nodeParser.nodeParser np = new nodeParser.nodeParser();
        np.SaveNode(this.setobj);//先强制使用HashName

        if (System.IO.Directory.Exists(exportPath) == false)
        {
            System.IO.Directory.CreateDirectory(exportPath);
        }
        string respath = System.IO.Path.Combine(exportPath, "resources");

        if (System.IO.Directory.Exists(respath) == false)
        {
            System.IO.Directory.CreateDirectory(respath);
        }

        MyJson.JsonNode_Array indexfile = new MyJson.JsonNode_Array();
        foreach (var f in np.bufs)
        {
            //写入文件
            {
                var file = System.IO.Path.Combine(respath, f.Key);
                System.IO.File.WriteAllBytes(file, f.Value);
            }
            //记录索引
            MyJson.JsonNode_Object indexitem = new MyJson.JsonNode_Object();
            indexitem["Name"]   = new MyJson.JsonNode_ValueString("resources/" + f.Key);
            indexitem["Length"] = new MyJson.JsonNode_ValueNumber(f.Value.Length);
            indexfile.Add(indexitem);
        }
        indexfile.Sort((a, b) =>
        {
            return(string.Compare(a.asDict()["Name"].AsString(), b.asDict()["Name"].AsString()));
        });
        {//保存索引文件
            byte[] indexcode = System.Text.Encoding.UTF8.GetBytes(indexfile.ToString());

            exportResult = exportNodeName;
            if (bUseHashTreeName)
            {
                exportResult = ResLibTool.ComputeHashString(indexcode);
            }
            string outfile = System.IO.Path.Combine(exportPath, exportResult + ".indexlist.txt");

            System.IO.File.WriteAllBytes(outfile, indexcode);
        }
    }
Пример #4
0
    void SaveItem()
    {
        //GameObject setobj = null;//选中的对象
        //bool bUseHashName = true;//是否使用hash作为资源文件名
        //string exportResult = null;//导出结果
        //string exportPath = null;//导出路径
        //bool bUseHashTreeName = false;//是否使用hash作为导出节点名
        //string exportNodeName = "";//导出节点名称

        nodeParser.nodeParser np = new nodeParser.nodeParser();
        np.SaveNode(this.setobj);//先强制使用HashName

        if (System.IO.Directory.Exists(exportPath) == false)
            System.IO.Directory.CreateDirectory(exportPath);
        string respath = System.IO.Path.Combine(exportPath, "resources");
        if (System.IO.Directory.Exists(respath) == false)
            System.IO.Directory.CreateDirectory(respath);

        MyJson.JsonNode_Array indexfile = new MyJson.JsonNode_Array();
        foreach (var f in np.bufs)
        {
            //写入文件
            {
                var file = System.IO.Path.Combine(respath, f.Key);
                System.IO.File.WriteAllBytes(file, f.Value);
            }
            //记录索引
            MyJson.JsonNode_Object indexitem = new MyJson.JsonNode_Object();
            indexitem["Name"] = new MyJson.JsonNode_ValueString("resources/" + f.Key);
            indexitem["Length"] = new MyJson.JsonNode_ValueNumber(f.Value.Length);
            indexfile.Add(indexitem);
        }
        indexfile.Sort((a, b) =>
        {
            return string.Compare(a.asDict()["Name"].AsString(), b.asDict()["Name"].AsString());
        });
        {//保存索引文件
            byte[] indexcode = System.Text.Encoding.UTF8.GetBytes(indexfile.ToString());

            exportResult = exportNodeName;
            if (bUseHashTreeName)
            {
                exportResult = ResLibTool.ComputeHashString(indexcode);
            }
            string outfile = System.IO.Path.Combine(exportPath, exportResult + ".indexlist.txt");

            System.IO.File.WriteAllBytes(outfile, indexcode);
        }

    }
Пример #5
0
    public void refresh_list_ui(MyJson.JsonNode_Array json)
    {
        if (m_json.ToString() == json.ToString())
        {
            return;
        }

        m_json = json;
        int index = 0;

        foreach (var item in m_json)
        {
            GameObject itemclone;
            if (m_itemList.ContainsKey(item.AsDict()["id"].ToString()))
            {
                itemclone = m_itemList[item.AsDict()["id"].ToString()];
            }
            else
            {
                GameObject go = m_panel.FindChild("item_scroll/scroll_view/icon").gameObject;
                itemclone = ((GameObject)GameObject.Instantiate(go));
                m_itemList[item.AsDict()["id"].ToString()] = itemclone;

                itemclone.SetActive(true);
                itemclone.transform.SetParent(item_Parent.transform, false);
                itemclone.transform.SetSiblingIndex(index);
            }

            string txt_do = "";
            if (item.AsDict()["params"].ToString().Substring(0, 1) == "[")
            {
                txt_do = MyJson.Parse(item.AsDict()["params"].ToString()).AsList()[0].AsDict()["sbPushString"].ToString();
            }
            else
            {
                txt_do = MyJson.Parse(item.AsDict()["params"].ToString()).AsDict()["sbPushString"].ToString();
            }

            switch (item.AsDict()["type"].ToString())
            {
            case "1":
                itemclone.transform.FindChild("sgas").gameObject.SetActive(true);
                break;

            case "2":
                itemclone.transform.FindChild("sgas").gameObject.SetActive(true);
                break;

            case "3":
                itemclone.transform.FindChild("sgas").gameObject.SetActive(true);
                break;

            case "5":
                itemclone.transform.FindChild("tran").gameObject.SetActive(true);
                break;

            case "6":
                itemclone.transform.FindChild("gas").gameObject.SetActive(true);

                break;
            }

            string txt_cnt = "";
            if (item.AsDict()["cnts"].ToString() != "")
            {
                if (item.AsDict()["type"].ToString() == "1" || (item.AsDict()["type"].ToString() == "5" && item.AsDict()["type_detail"].ToString() == "2"))
                {
                    txt_cnt = "+" + item.AsDict()["cnts"].ToString();
                }
                else
                {
                    txt_cnt = "-" + item.AsDict()["cnts"].ToString();
                }
            }

            string txt_time = "";
            switch (item.AsDict()["state"].ToString())
            {
            case "0":
                txt_time = "等待...";
                break;

            case "1":
                txt_time = "成功";
                if (item.AsDict()["type"].ToString() == "2" && item.AsDict()["client_notify"].ToString() == "0")
                {
                    txt_time = "等待...";
                }
                break;

            case "2":
                txt_time = "失败";
                break;

            default:

                break;
            }

            string txt_name = "Bla Cat";
            if (item.AsDict()["name"].ToString() != "null")
            {
                txt_name = global.unicodeToStr(item.AsDict()["name"].ToString());
            }

            itemclone.transform.FindChild("text_main").GetComponent <Text>().text = txt_name;
            itemclone.transform.FindChild("text_do").GetComponent <Text>().text   = txt_do;
            itemclone.transform.FindChild("text_num").GetComponent <Text>().text  = txt_cnt;
            itemclone.transform.FindChild("text_time").GetComponent <Text>().text = txt_time;

            index++;
        }

        RectTransform con        = item_Parent.gameObject.GetComponent <RectTransform>();
        float         childSizeY = item_Parent.cellSize.y + item_Parent.spacing.y;
        Vector2       newSize    = new Vector2(con.sizeDelta.x, childSizeY * m_json.Count);

        con.sizeDelta = newSize;
    }