增加sth
This commit is contained in:
parent
8f1001d240
commit
cbac329433
@ -69,6 +69,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||||||
jsb_run_script("js/jcwallet.js");
|
jsb_run_script("js/jcwallet.js");
|
||||||
jsb_run_script("js/platform.js");
|
jsb_run_script("js/platform.js");
|
||||||
jsb_run_script("js/main.js");
|
jsb_run_script("js/main.js");
|
||||||
|
jsb_run_script("js/wallet.js");
|
||||||
Application::getInstance()->setKeyMaster("1111");
|
Application::getInstance()->setKeyMaster("1111");
|
||||||
se->addAfterCleanupHook([]() {
|
se->addAfterCleanupHook([]() {
|
||||||
JSBClassType::destroy();
|
JSBClassType::destroy();
|
||||||
|
@ -11,13 +11,23 @@
|
|||||||
#include "platform/CCApplication.h"
|
#include "platform/CCApplication.h"
|
||||||
#include "base/CCScheduler.h"
|
#include "base/CCScheduler.h"
|
||||||
#include "scrypt/native-crypto.h"
|
#include "scrypt/native-crypto.h"
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||||
#include "AppDelegate.h"
|
#include "AppDelegate.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
|
|
||||||
|
#ifndef COM_JC_JCFW_CLASS_NAME
|
||||||
|
#define COM_JC_JCFW_CLASS_NAME com_jc_jcfw_JcSDK
|
||||||
|
#endif
|
||||||
|
#define JNI_JCFW(FUNC) JNI_METHOD1(COM_JC_JCFW_CLASS_NAME,FUNC)
|
||||||
|
|
||||||
|
#define JNI_IMP_LOG_TAG "JcWallet"
|
||||||
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,JNI_IMP_LOG_TAG,__VA_ARGS__)
|
||||||
|
|
||||||
cocos2d::Application *cocos_android_app_init(int width, int height);
|
cocos2d::Application *cocos_android_app_init(int width, int height);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -140,7 +150,7 @@ NS_CC_BEGIN
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *JcWallet::runJsMethod(std::shared_ptr<JSMethodParam> data) {
|
char *JcWallet::runJsMethod(std::shared_ptr<JSMethodParam> data) {
|
||||||
cocos2d::log("thread: %ld call method %s", uv_thread_self(), data->methodName.c_str());
|
cocos2d::log("thread: %ld call method %s params: %d", uv_thread_self(), data->methodName.c_str(), data->args.size());
|
||||||
se::Value value;
|
se::Value value;
|
||||||
bool ok = cocos2d::runGlobalMethod(data->methodName.c_str(), data->args, &value);
|
bool ok = cocos2d::runGlobalMethod(data->methodName.c_str(), data->args, &value);
|
||||||
static std::string result;
|
static std::string result;
|
||||||
@ -217,6 +227,25 @@ NS_CC_BEGIN
|
|||||||
});
|
});
|
||||||
return result == 0 ? 1 : 0;
|
return result == 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
|
JNIEXPORT jint JNICALL JNI_JCFW(runJS)(JNIEnv *env, jclass clazz, jstring jfunId, jstring jmethodName, jstring jparams) {
|
||||||
|
std::string funId = JniHelper::jstring2string(jfunId);
|
||||||
|
std::string methodName = JniHelper::jstring2string(jmethodName);
|
||||||
|
LOGD("jni call %s | %s", methodName.c_str(), funId.c_str());
|
||||||
|
JSMethodParam *data = new JSMethodParam();
|
||||||
|
data->methodName = methodName;
|
||||||
|
data->funId = funId;
|
||||||
|
data->paramCount = 1;
|
||||||
|
addToArgArray(&data->args, funId.c_str());
|
||||||
|
std::string sstr = JniHelper::jstring2string(jparams);
|
||||||
|
addToArgArray(&data->args, sstr.c_str());
|
||||||
|
std::shared_ptr<JSMethodParam> params(data);
|
||||||
|
int result = schedule_task_into_server_thread_task_queue(&gasync, [=](){
|
||||||
|
JcWallet::getInstance()->runJsMethod(params);
|
||||||
|
});
|
||||||
|
return result == 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
@ -263,3 +292,5 @@ bool jsb_register_walletevent_modules(se::Object* global) {
|
|||||||
__jsbObj->defineFunction("jcCallback", _SE(jsb_wallet_callback));
|
__jsbObj->defineFunction("jcCallback", _SE(jsb_wallet_callback));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
android:name=".MainApplication"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
@ -136,4 +136,6 @@ dependencies {
|
|||||||
implementation project(path: ':libcocos2dx')
|
implementation project(path: ':libcocos2dx')
|
||||||
implementation 'net.openid:appauth:0.11.1'
|
implementation 'net.openid:appauth:0.11.1'
|
||||||
implementation "com.squareup.okio:okio:2.10.0"
|
implementation "com.squareup.okio:okio:2.10.0"
|
||||||
|
implementation 'com.android.volley:volley:1.2.1'
|
||||||
|
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||||
}
|
}
|
5
app/src/com/fitchgc/jcwallet/Constants.java
Normal file
5
app/src/com/fitchgc/jcwallet/Constants.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package com.fitchgc.jcwallet;
|
||||||
|
|
||||||
|
public class Constants {
|
||||||
|
public static final String PREF_NAME = "jcwallet";
|
||||||
|
}
|
@ -416,6 +416,7 @@ public class MainActivity extends Activity
|
|||||||
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
|
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
Log.w(TAG, "already login: " + account.getIdToken());
|
Log.w(TAG, "already login: " + account.getIdToken());
|
||||||
|
runOnUiThread(() -> verifyGoogleIDToken(account.getIdToken()));
|
||||||
} else {
|
} else {
|
||||||
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
|
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
|
||||||
startActivityForResult(signInIntent, RC_SIGN_IN);
|
startActivityForResult(signInIntent, RC_SIGN_IN);
|
||||||
@ -434,6 +435,7 @@ public class MainActivity extends Activity
|
|||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "already login, accessToken not expired");
|
Log.w(TAG, "already login, accessToken not expired");
|
||||||
Log.w(TAG, "id token : " + state.getIdToken());
|
Log.w(TAG, "id token : " + state.getIdToken());
|
||||||
|
runOnUiThread(() -> verifyGoogleIDToken(state.getIdToken()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mExecutor.submit(this::doAuth);
|
mExecutor.submit(this::doAuth);
|
||||||
@ -452,7 +454,8 @@ public class MainActivity extends Activity
|
|||||||
try {
|
try {
|
||||||
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
|
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
|
||||||
Log.w(TAG, "signIn success: ");
|
Log.w(TAG, "signIn success: ");
|
||||||
Log.w(TAG, "app auth idToken: " + account.getIdToken());
|
Log.w(TAG, "gsa idToken: " + account.getIdToken());
|
||||||
|
runOnUiThread(() -> verifyGoogleIDToken(account.getIdToken()));
|
||||||
// Signed in successfully, show authenticated UI.
|
// Signed in successfully, show authenticated UI.
|
||||||
} catch (ApiException e) {
|
} catch (ApiException e) {
|
||||||
// The ApiException status code indicates the detailed failure reason.
|
// The ApiException status code indicates the detailed failure reason.
|
||||||
@ -708,7 +711,12 @@ public class MainActivity extends Activity
|
|||||||
Log.d(TAG, "login success, auth state: " + state.isAuthorized());
|
Log.d(TAG, "login success, auth state: " + state.isAuthorized());
|
||||||
Log.d(TAG, "app auth idToken: " + state.getIdToken());
|
Log.d(TAG, "app auth idToken: " + state.getIdToken());
|
||||||
mAuthStateManager.replace(state);
|
mAuthStateManager.replace(state);
|
||||||
|
runOnUiThread(() -> verifyGoogleIDToken(state.getIdToken()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@MainThread
|
||||||
|
private void verifyGoogleIDToken(String idToken) {
|
||||||
|
JcSDK.googleOauthCb(this.funId, null, idToken);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
15
app/src/com/fitchgc/jcwallet/MainApplication.java
Normal file
15
app/src/com/fitchgc/jcwallet/MainApplication.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package com.fitchgc.jcwallet;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
public class MainApplication extends Application {
|
||||||
|
public static MainApplication application;
|
||||||
|
public static SharedPreferences _pref;
|
||||||
|
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
application = this;
|
||||||
|
_pref = getSharedPreferences(Constants.PREF_NAME, 0);
|
||||||
|
}
|
||||||
|
}
|
@ -8,10 +8,14 @@ import android.util.Log;
|
|||||||
import com.fitchgc.jcwallet.MainActivity;
|
import com.fitchgc.jcwallet.MainActivity;
|
||||||
|
|
||||||
import org.cocos2dx.lib.CocosJSHelper;
|
import org.cocos2dx.lib.CocosJSHelper;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class JcSDK {
|
public class JcSDK {
|
||||||
private static final String TAG = JcSDK.class.getSimpleName();
|
private static final String TAG = JcSDK.class.getSimpleName();
|
||||||
private static UnityCallback commonCB;
|
private static UnityCallback commonCB;
|
||||||
|
private static native int runJS(final String funId, final String methodName, final String params);
|
||||||
|
|
||||||
public static void initCommonCB(UnityCallback callBack) {
|
public static void initCommonCB(UnityCallback callBack) {
|
||||||
Log.i(TAG, "call init common callback from unity");
|
Log.i(TAG, "call init common callback from unity");
|
||||||
commonCB = callBack;
|
commonCB = callBack;
|
||||||
@ -34,7 +38,7 @@ public class JcSDK {
|
|||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
public static void csCallback(String funId, String msg) {
|
public static void csCallback(String funId, String msg) {
|
||||||
if (funId.indexOf("js_") == 0) {
|
if (funId != "" && funId.indexOf("js_") == 0) {
|
||||||
commonCB.nativeCallback(funId, msg, 1);
|
commonCB.nativeCallback(funId, msg, 1);
|
||||||
} else {
|
} else {
|
||||||
commonCB.nativeCallback(funId, msg, 0);
|
commonCB.nativeCallback(funId, msg, 0);
|
||||||
@ -74,6 +78,24 @@ public class JcSDK {
|
|||||||
|
|
||||||
public static void signOutGoogle(String funid) {
|
public static void signOutGoogle(String funid) {
|
||||||
MainActivity.app.signOutGoogle(funid);
|
MainActivity.app.signOutGoogle(funid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void googleOauthCb(String funId, String error, String idToken) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (error != "" && null != error) {
|
||||||
|
result.put("errocde", 1);
|
||||||
|
result.put("errmessage", error);
|
||||||
|
} else {
|
||||||
|
result.put("errocde", 0);
|
||||||
|
result.put("data", idToken);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
String methodName = "jniCallback";
|
||||||
|
JcSDK.runJS(funId, methodName, result.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
150
js/main.js
150
js/main.js
@ -1,19 +1,18 @@
|
|||||||
console.log(">>begin load wallet main file");
|
console.log(">>begin load wallet main file");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化钱包, 所有操作进行前, 必须调用此方法
|
* init wallet, must call this before all other method
|
||||||
* @param {string} type: 钱包类型, 0: 内置钱包, 1: 第三方钱包
|
* @param {string} type: wallet type, 0: internal wallet, 1: third party wallet
|
||||||
* @param {string} password: 用于加密钱包数据的密码
|
|
||||||
*/
|
*/
|
||||||
function initWallet(funId, type, password) {
|
function initWallet(funId, type) {
|
||||||
type = 1;
|
type = 0;
|
||||||
try {
|
try {
|
||||||
var wallet;
|
var wallet;
|
||||||
if (!window.jc || !jc.wallet) {
|
if (!window.jc || !jc.wallet) {
|
||||||
wallet = new jcwallet.default({
|
wallet = new jcwallet.default({
|
||||||
chain: 322,
|
chain: 322,
|
||||||
type,
|
type
|
||||||
password,
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
wallet = jc.wallet;
|
wallet = jc.wallet;
|
||||||
@ -26,47 +25,32 @@ function initWallet(funId, type, password) {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("walletconnect connect success");
|
console.log("walletconnect connect success");
|
||||||
var account = jc.wallet.currentAccount();
|
var account = jc.wallet.currentAccount();
|
||||||
jsb.jcCallback(
|
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: account}));
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: account,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log("walletconnect connect error: " + JSON.stringify(err));
|
console.log("walletconnect connect error: " + JSON.stringify(err));
|
||||||
jsb.jcCallback(
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let address = jc.wallet.currentAccount().address;
|
wallet.initInternalWallet()
|
||||||
jsb.jcCallback(
|
.then(() => {
|
||||||
funId,
|
console.log("internal init success");
|
||||||
JSON.stringify({
|
var address = jc.wallet.nativeAccount;
|
||||||
errcode: 0,
|
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: address}));
|
||||||
data: address,
|
|
||||||
})
|
})
|
||||||
);
|
.catch((err) => {
|
||||||
|
console.log("internal wallet error: " + JSON.stringify(err));
|
||||||
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("wallet init with error: " + JSON.stringify(err));
|
console.error("wallet init with error: " + JSON.stringify(err));
|
||||||
jsb.jcCallback(
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 钱包当前激活的帐号的详细信息
|
* current account for internal wallet
|
||||||
*/
|
*/
|
||||||
function currentAccount(funId) {
|
function currentAccount(funId) {
|
||||||
try {
|
try {
|
||||||
@ -83,7 +67,7 @@ function currentAccount(funId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取当前链所有帐号列表
|
* all account for internal wallet
|
||||||
*/
|
*/
|
||||||
function accountList(funId) {
|
function accountList(funId) {
|
||||||
try {
|
try {
|
||||||
@ -100,7 +84,7 @@ function accountList(funId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取所有支持的链的列表
|
* all chain list we supported
|
||||||
*/
|
*/
|
||||||
function chainList(funId) {
|
function chainList(funId) {
|
||||||
try {
|
try {
|
||||||
@ -117,7 +101,7 @@ function chainList(funId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 当前链的信息
|
* chain active
|
||||||
*/
|
*/
|
||||||
function currentChain(funId) {
|
function currentChain(funId) {
|
||||||
try {
|
try {
|
||||||
@ -134,8 +118,7 @@ function currentChain(funId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* [BOTH]切换当前链
|
* [BOTH]change chain
|
||||||
* 切换链需要调用currentAccount方法, 以刷新界面显示
|
|
||||||
*/
|
*/
|
||||||
function changeChain(funId, chainId) {
|
function changeChain(funId, chainId) {
|
||||||
// chainId = parseInt(chainId);
|
// chainId = parseInt(chainId);
|
||||||
@ -162,9 +145,9 @@ function changeChain(funId, chainId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* [BOTH]获取当前帐户的登录签名
|
* [BOTH] get sign for login
|
||||||
* @param {string} nonce: 从服务端获取的nonce
|
* @param {string} nonce: nonce from server
|
||||||
* @param {string} tips: 签名时的提示
|
* @param {string} tips: tips message when sign
|
||||||
*/
|
*/
|
||||||
function loginSign(funId, nonce, tips) {
|
function loginSign(funId, nonce, tips) {
|
||||||
jc.wallet
|
jc.wallet
|
||||||
@ -189,8 +172,8 @@ function loginSign(funId, nonce, tips) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 创建一个新帐号, 并将新建帐号设为当前激活帐号
|
* add one new account, then active this account
|
||||||
* @return {string} 当前激活帐户的地址
|
* @return {string} account actived
|
||||||
*/
|
*/
|
||||||
function createAccount(funId) {
|
function createAccount(funId) {
|
||||||
try {
|
try {
|
||||||
@ -207,8 +190,8 @@ function createAccount(funId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 用导入一个密钥, 并将导入的帐号设为当前激活帐号
|
* import account with private key
|
||||||
* @return {string} 当前激活帐户的地址
|
* @return {string} account actived
|
||||||
*/
|
*/
|
||||||
function importAccount(funId, privateKey) {
|
function importAccount(funId, privateKey) {
|
||||||
try {
|
try {
|
||||||
@ -225,7 +208,7 @@ function importAccount(funId, privateKey) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 将一个帐号地址设为当前激活帐号
|
* active one account
|
||||||
*/
|
*/
|
||||||
function selectAccount(funId, address) {
|
function selectAccount(funId, address) {
|
||||||
try {
|
try {
|
||||||
@ -242,9 +225,9 @@ function selectAccount(funId, address) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取当前链上基础代币的余额
|
* get balance of ETH
|
||||||
* @param {string} address: 待查询的帐户地址
|
* @param {string} address: account
|
||||||
* 不传的话, 则获取当前帐户的余额
|
* if account is null, we`ll query for current account of wallet
|
||||||
*/
|
*/
|
||||||
function getEthBalance(funId, address) {
|
function getEthBalance(funId, address) {
|
||||||
jc.wallet
|
jc.wallet
|
||||||
@ -269,9 +252,9 @@ function getEthBalance(funId, address) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 将当前帐户里的基础代币转账给别人
|
* send ETH from current account
|
||||||
* @param {string} to: 转账目标地址
|
* @param {string} to: target account
|
||||||
* @param {string} amount: 转账数量
|
* @param {string} amount:
|
||||||
*/
|
*/
|
||||||
function sendEth(funId, to, amount) {
|
function sendEth(funId, to, amount) {
|
||||||
jc.wallet
|
jc.wallet
|
||||||
@ -297,9 +280,9 @@ function sendEth(funId, to, amount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [BOTH]生成hash图片
|
* [BOTH] generate ICON with hashed message
|
||||||
* @param {string} msg: 要生成图片的内容
|
* @param {string} msg:
|
||||||
* @param {string} diameter: 图片尺寸
|
* @param {string} diameter: size of icon
|
||||||
*/
|
*/
|
||||||
function generateIcon(funId, msg, diameter) {
|
function generateIcon(funId, msg, diameter) {
|
||||||
try {
|
try {
|
||||||
@ -318,9 +301,8 @@ function generateIcon(funId, msg, diameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取ERC20代币的基本信息, 包括symbol和decimal
|
* get symbol and decimal of ERC20, symbol and decimal
|
||||||
* 这些信息一般都不会变化, 客户端需缓存这些信息
|
* @param {string} address: address of ERC20
|
||||||
* @param {string} address: 代币的地址initThirdPartyWallet
|
|
||||||
*/
|
*/
|
||||||
function erc20Info(funId, address) {
|
function erc20Info(funId, address) {
|
||||||
jc.wallet
|
jc.wallet
|
||||||
@ -345,9 +327,9 @@ function erc20Info(funId, address) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取erc20代币的余额
|
* get balance of ERC20
|
||||||
* @param {string} address: 代币地址
|
* @param {string} address:
|
||||||
* @param {string} account: 所属帐户的地址, 不传该参数的话, 获取当前钱包激活帐户的余额
|
* @param {string} account:
|
||||||
*/
|
*/
|
||||||
function erc20Balance(funId, address, account) {
|
function erc20Balance(funId, address, account) {
|
||||||
jc.wallet
|
jc.wallet
|
||||||
@ -422,29 +404,29 @@ function scanQRCode(funId, title) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function signWithGoogle(funId) {
|
function signWithGoogle(funId) {
|
||||||
try {
|
jc.wallet.nativeSvr.signWithGoogle(funId)
|
||||||
jsb.signWithGoogle(funId);
|
.then(res => {
|
||||||
} catch (err) {
|
console.log(`google sign result: ${typeof res}`)
|
||||||
return JSON.stringify({
|
console.log(res)
|
||||||
errcode: 1,
|
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: res}));
|
||||||
errmsg: err,
|
})
|
||||||
});
|
.catch(err => {
|
||||||
}
|
console.log('google sign error: ' + err);
|
||||||
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function signOutGoogle(funId) {
|
function signOutGoogle(funId) {
|
||||||
try {
|
jc.wallet.nativeSvr.signOutGoogle(funId)
|
||||||
jsb.signOutGoogle(funId);
|
then(res => {
|
||||||
return JSON.stringify({
|
console.log(`google sign out result: ${typeof res}`)
|
||||||
errcode: 0,
|
console.log(res)
|
||||||
data: "success",
|
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: res}));
|
||||||
});
|
})
|
||||||
} catch (err) {
|
.catch(err => {
|
||||||
return JSON.stringify({
|
console.log('google sign out error: ' + err);
|
||||||
errcode: 1,
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
errmsg: err,
|
})
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//function toWalletJNI(funId, url) {
|
//function toWalletJNI(funId, url) {
|
||||||
|
4
js/wallet.js
Normal file
4
js/wallet.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function jniCallback(...args) {
|
||||||
|
console.log(`jniCallback: ${args[0]}`)
|
||||||
|
jc.wallet.nativeSvr.handleNativeCallback(...args);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user