update sth

This commit is contained in:
cebgcontract 2022-08-31 13:31:01 +08:00
parent 6bf8e47827
commit 633987fb25
5 changed files with 48 additions and 26 deletions

12
.idea/dictionaries/zhl.xml generated Normal file
View File

@ -0,0 +1,12 @@
<component name="ProjectDictionaryState">
<dictionary name="zhl">
<words>
<w>errcode</w>
<w>errmsg</w>
<w>jcfw</w>
<w>jcwallet</w>
<w>ljava</w>
<w>walletconnect</w>
</words>
</dictionary>
</component>

View File

@ -95,11 +95,6 @@ android.applicationVariants.all { variant ->
include "bin/**"
into outputDir
}
// copy {
// from "${sourceDir}/main.js"
// into outputDir
// }
}
}

View File

@ -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);
}
}

View File

@ -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}));
}
}

View File

@ -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://'
)
}