diff --git a/.idea/dictionaries/zhl.xml b/.idea/dictionaries/zhl.xml new file mode 100644 index 0000000..9aabb48 --- /dev/null +++ b/.idea/dictionaries/zhl.xml @@ -0,0 +1,12 @@ + + + + errcode + errmsg + jcfw + jcwallet + ljava + walletconnect + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 9104cc3..244ee80 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -95,11 +95,6 @@ android.applicationVariants.all { variant -> include "bin/**" into outputDir } - -// copy { -// from "${sourceDir}/main.js" -// into outputDir -// } } } diff --git a/app/src/com/jc/jcfw/JcSDK.java b/app/src/com/jc/jcfw/JcSDK.java index 6d49500..132bcac 100644 --- a/app/src/com/jc/jcfw/JcSDK.java +++ b/app/src/com/jc/jcfw/JcSDK.java @@ -16,15 +16,36 @@ public class JcSDK { Log.i(TAG, "call init common callback from unity"); commonCB = callBack; } - // 不使用该方法, 直接由unity调用cpp方法 + + /** + * 不使用该方法, 直接由unity调用cpp方法 + * @param password + */ public static void initWallet(String password) { Log.i(TAG, "call init wallet from unity with password: " + password); CocosJSHelper.initWallet(password); commonCB.stringCallback("wallet init success"); } - public static void connectwallet(String url){ -// String url = "https://metamask.app.link/wc?uri="+ExampleApplication.config.toWCUri(); +// public static void connectwallet(String url){ +// Uri uri = Uri.parse(url); +// Log.i(TAG, url); +// Intent intent = new Intent(Intent.ACTION_VIEW, uri); +// try { +// MainActivity.app.startActivity(intent); +// } catch (ActivityNotFoundException e) { +// Intent i = new Intent(Intent.ACTION_VIEW); +// i.setData(Uri.parse("https://metamask.io/download/")); +// MainActivity.app.startActivity(i); +// } +// } + /** + * check if metamask installed and jump to metamask + * @param url + * sample: "https://metamask.app.link/wc?uri="+ExampleApplication.config.toWCUri(); + */ + + public static void toWallet(String url) { Uri uri = Uri.parse(url); Log.i(TAG, url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); @@ -36,10 +57,4 @@ public class JcSDK { MainActivity.app.startActivity(i); } } - - public static void toWallet(String url) { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(url)); - MainActivity.app.startActivity(intent); - } } diff --git a/js/main.js b/js/main.js index 0df71db..d3d5085 100644 --- a/js/main.js +++ b/js/main.js @@ -15,15 +15,15 @@ function initWallet(funId, type, password) { } type = parseInt(type); if (type === 1) { - console.log('wallet inited, begin connect') + console.log('wallet init success, begin connect') wallet.initThirdPartyWallet() .then(() => { - console.log('walletconnect inited') + console.log('walletconnect connect success') var account = jc.wallet.currentAccount(); jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: account})); }) .catch(err =>{ - console.log('walletconnect inited error: ' + JSON.stringify(err)); + console.log('walletconnect connect error: ' + JSON.stringify(err)); jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); }) } else { @@ -31,7 +31,7 @@ function initWallet(funId, type, password) { jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: address})); } } catch(err) { - console.error('error init wallet: ' + JSON.stringify(err)); + console.error('wallet init with error: ' + JSON.stringify(err)); jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); } } diff --git a/js/platform.js b/js/platform.js index 6418d21..ae84c3e 100644 --- a/js/platform.js +++ b/js/platform.js @@ -1,16 +1,16 @@ if (window.JavascriptJavaBridge) { - console.log('regist android jsb.reflection') + console.log('register android jsb.reflection') jsb.reflection = new JavascriptJavaBridge(); } else if (window.JavaScriptObjCBridge) { jsb.reflection = new JavaScriptObjCBridge(); } window.jumpToWallet = function(url) { - console.log(url); - jsb.reflection.callStaticMethod( - 'com/jc/jcfw/JcSDK', - 'toWallet', - '(Ljava/lang/String;)V', - url || 'wc://' - ) + console.log(url); + jsb.reflection.callStaticMethod( + 'com/jc/jcfw/JcSDK', + 'toWallet', + '(Ljava/lang/String;)V', + url || 'wc://' + ) } \ No newline at end of file