-
Notifications
You must be signed in to change notification settings - Fork 2
/
Simple.cs
92 lines (83 loc) · 2.52 KB
/
Simple.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using io.nebulas.api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using io.nebulas.model;
using io.nebulas.utils;
public class Simple : MonoBehaviour
{
public Toggle toggleMainnet;
public InputField inputQueryTransfer;
public Button btnQueryTransfer;
public Button btnCallTransfer;
public StringEvent TransferStatusHandler;
public StringEvent TransferStatusErrorHandler;
/// <summary>
/// Update is called every frame, if the MonoBehaviour is enabled.
/// </summary>
void Update()
{
SmartContracts.isMainnet = toggleMainnet.isOn;
}
public void CallTransfer()
{
var gmol = new GoodsModel();
var serialNumber = Util.getRandomCode(32);
SmartContracts.Call(gmol, "vote", inputQueryTransfer.text, (Util.OnNAS * 0.000001).ToString("F0"), new string[] { "霸王别姬" }, serialNumber);
StartCoroutine(TransferStatusCoroutine(serialNumber));
}
public IEnumerator TransferStatusCoroutine(string serialNumber)
{
yield return new WaitForSeconds(1);
yield return SmartContracts.QueryTransferStatus(serialNumber, (success) =>
{
Debug.Log(success);
TransferStatusHandler.Invoke(success);
}, (fail) =>
{
Debug.LogError(fail);
TransferStatusErrorHandler.Invoke(fail);
});
}
public void SimulationCall()
{
this.StartCoroutine(
SmartContracts.SimulationCall("n1NrqHkmuFAHsifysfBh6gombgeg6wJrfnB", "n1j2Q5E9SU1JnpqbyQLVRM8D2jPeefDXKau", "info", null, (success) =>
{
Debug.Log(success);
TransferStatusHandler.Invoke(success);
}, (fail) =>
{
Debug.LogError(fail);
TransferStatusErrorHandler.Invoke(fail);
})
);
}
public void QueryTransferStatus()
{
this.StartCoroutine(
SmartContracts.QueryTransferStatus(inputQueryTransfer.text, (success) =>
{
Debug.Log(success);
}, (fail) =>
{
Debug.LogError(fail);
}));
}
public void GetTransactionReceipt()
{
this.StartCoroutine(
SmartContracts.GetTransactionReceipt(inputQueryTransfer.text, (success) =>
{
Debug.Log(success);
}, (fail) =>
{
Debug.LogError(fail);
}));
}
}
[System.Serializable]
public class StringEvent : UnityEngine.Events.UnityEvent<string>
{
}