186 lines
5.2 KiB
C#
186 lines
5.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class WalletTestPanel : MonoBehaviour
|
|
{
|
|
private static string TAG = "JCWalletPanel";
|
|
|
|
private static ILogger logger = Debug.unityLogger;
|
|
[SerializeField]
|
|
private Text textView;
|
|
[SerializeField]
|
|
private ScrollRect scrollControl;
|
|
|
|
// Start is called before the first frame update
|
|
void Start(){
|
|
Debug.Log(Application.persistentDataPath);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update(){
|
|
}
|
|
|
|
public void writeTxt(string msg) {
|
|
textView.text += "\n" + msg;
|
|
scrollToBottom();
|
|
}
|
|
IEnumerator scrollToBottom()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
scrollControl.verticalNormalizedPosition = 0f;
|
|
}
|
|
|
|
public void initWalletEnv()
|
|
{
|
|
#if UNITY_ANDROID || UNITY_IOS || UNITY_IPHONE
|
|
WalletPanel.initWalletEnv(delegate (string jsonStr){
|
|
logger.Log(TAG, "wallet env inited.");
|
|
});
|
|
#endif
|
|
}
|
|
|
|
public void testInitWallet(){
|
|
WalletPanel.callWalletMethod("initWallet",
|
|
new [] { "1", "80001" },
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "initWallet result: " + jsonStr);
|
|
writeTxt("initWallet result: " + jsonStr);
|
|
testSignLogin();
|
|
});
|
|
}
|
|
|
|
public void testGoogleLogin() {
|
|
WalletPanel.callWalletMethod("initWallet",
|
|
new [] { "0", "80001", "0" },
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "google init result: " + jsonStr);
|
|
writeTxt("google result: " + jsonStr);
|
|
testSignLogin();
|
|
});
|
|
}
|
|
|
|
public void testAppleLogin() {
|
|
WalletPanel.callWalletMethod("initWallet",
|
|
new [] { "0", "80001", "1" },
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "apple result: " + jsonStr);
|
|
writeTxt("apple result: " + jsonStr);
|
|
testSignLogin();
|
|
});
|
|
}
|
|
public void testTiktokLogin() {
|
|
WalletPanel.callWalletMethod("initWallet",
|
|
new [] { "0", "80001", "2" },
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "tiktok result: " + jsonStr);
|
|
writeTxt("tiktok result: " + jsonStr);
|
|
testSignLogin();
|
|
});
|
|
}
|
|
|
|
public void testSignLogin(){
|
|
WalletPanel.callWalletMethod("loginSign",
|
|
new [] { "123455", "login request" },
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "loginSign result: " + jsonStr);
|
|
writeTxt("loginSign result: " + jsonStr);
|
|
});
|
|
}
|
|
// export wallet private key
|
|
public void testAddAccount(){
|
|
WalletPanel.callWalletMethod("exportWalletSecKey",
|
|
new string[0],
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "wallet private key: " + jsonStr);
|
|
writeTxt("wallet private key: " + jsonStr);
|
|
});
|
|
}
|
|
|
|
public void testImportAccount(){
|
|
//string key =
|
|
// "53ba1beb03bd29e25fcb22430e26a03aa6c48b82e60bb0612f02e2888c90bc51";
|
|
//WalletPanel.callWalletMethod("importAccount",
|
|
// new [] { key },
|
|
// delegate (string jsonStr){
|
|
// logger.Log(TAG, "importAccount result: " + jsonStr);
|
|
// writeTxt("importAccount result: " + jsonStr);
|
|
// });
|
|
string address = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
|
|
//string address = "0xed670fed2e18bfed381313d82b45a28c1d3ecb1f";
|
|
WalletPanel.callWalletMethod("sendEth",
|
|
new [] {address, "0.01", "0"},
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "sendEth result: " + jsonStr);
|
|
writeTxt("sendEth result: " + jsonStr);
|
|
});
|
|
}
|
|
|
|
public void testCreateIcon()
|
|
{
|
|
string address = "0xb59f7DE6B6544a1d12df90a317dC3b1E037AF9A3";
|
|
string width = "100";
|
|
WalletPanel
|
|
.callWalletMethod("generateIcon",
|
|
new [] { address, width },
|
|
delegate (string jsonStr)
|
|
{
|
|
logger.Log (TAG, jsonStr);
|
|
writeTxt("create icon result: " + jsonStr);
|
|
});
|
|
}
|
|
|
|
public void testShowQR() {
|
|
string address = "0xb59f7DE6B6544a1d12df90a317dC3b1E037AF9A3";
|
|
WalletPanel
|
|
.callWalletMethod("showQRCode",
|
|
new [] { address },
|
|
delegate (string jsonStr)
|
|
{
|
|
logger.Log (TAG, jsonStr);
|
|
writeTxt("show qr result: " + jsonStr);
|
|
});
|
|
|
|
|
|
}
|
|
|
|
public void testGetEthBalance(){
|
|
string address = "0x9981b97dAB4A1e74D65b50eFf47Ac6c5D9Bb2919";
|
|
WalletPanel.callWalletMethod("getEthBalance",
|
|
new [] { address },
|
|
delegate (string jsonStr){
|
|
logger.Log (TAG, "balance:: " + jsonStr);
|
|
writeTxt("get balance result: " + jsonStr);
|
|
});
|
|
}
|
|
|
|
public void testChangeChain() {
|
|
WalletPanel.callWalletMethod("changeChain",
|
|
new [] {"97"},
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "result:: " + jsonStr);
|
|
writeTxt("change chain result: " + jsonStr);
|
|
});
|
|
}
|
|
public void testScanQR() {
|
|
WalletPanel.callWalletMethod("scanQRCode",
|
|
new [] {"扫码"},
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "result:: " + jsonStr);
|
|
writeTxt("sign result: " + jsonStr);
|
|
});
|
|
}
|
|
|
|
|
|
public void testGoogleLogout() {
|
|
WalletPanel.callWalletMethod("signOutGoogle",
|
|
new string[0],
|
|
delegate (string jsonStr){
|
|
logger.Log(TAG, "result:: " + jsonStr);
|
|
writeTxt("login out result: " + jsonStr);
|
|
});
|
|
}
|
|
|
|
}
|