x修改包名

This commit is contained in:
cebgcontract 2022-10-18 16:19:13 +08:00
parent 83e4a7140a
commit 8a5a002430
10 changed files with 151 additions and 138 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@
/.idea/assetWizardSettings.xml /.idea/assetWizardSettings.xml
.DS_Store .DS_Store
/build /build
/app/debug
/captures /captures
.externalNativeBuild .externalNativeBuild
.cxx .cxx

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.fitchgc.headlesscocos"> package="com.fitchgc.jcwallet">
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -13,7 +13,7 @@
<!-- Tell Cocos2dxActivity the name of our .so --> <!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data android:name="android.app.lib_name" <meta-data android:name="android.app.lib_name"
android:value="cocos2djs" /> android:value="cocos2djs" />
<activity android:name=".MainActivity" <activity android:name="MainActivity"
android:screenOrientation="sensorLandscape" android:screenOrientation="sensorLandscape"
android:exported="true" android:exported="true"
> >
@ -51,7 +51,7 @@
<action android:name="android.intent.action.VIEW"/> <action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/> <category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="com.googleusercontent.apps.112636549810-l5cp5mhm6hq4ejh3g8o4q4gbnbnkvouc"/> <data android:scheme="com.googleusercontent.apps.165555585193-glmtnb94s3kkq906hal72ppiuoqpjjc5"/>
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name ="com.youme.voiceengine.VoiceEngineService"> <service android:name ="com.youme.voiceengine.VoiceEngineService">

View File

@ -1,4 +1,4 @@
package com.fitchgc.headlesscocos; package com.fitchgc.jcwallet;
import android.Manifest; import android.Manifest;
import android.app.Activity; import android.app.Activity;
@ -23,7 +23,6 @@ import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.api.ApiException; import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.Scope;
import com.google.android.gms.tasks.Task; import com.google.android.gms.tasks.Task;
import com.jc.jcfw.JcSDK; import com.jc.jcfw.JcSDK;
import com.jc.jcfw.appauth.AuthStateManager; import com.jc.jcfw.appauth.AuthStateManager;
@ -138,7 +137,7 @@ public class MainActivity extends Activity
// begin of google sign // begin of google sign
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id)) .requestIdToken(getString(R.string.default_web_client_id))
.requestScopes(new Scope("https://www.googleapis.com/auth/drive.appdata")) // .requestScopes(new Scope("https://www.googleapis.com/auth/drive.appdata"))
.build(); .build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso); mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
// end of google sign // end of google sign

View File

@ -5,7 +5,7 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.util.Log; import android.util.Log;
import com.fitchgc.headlesscocos.MainActivity; import com.fitchgc.jcwallet.MainActivity;
import org.cocos2dx.lib.CocosJSHelper; import org.cocos2dx.lib.CocosJSHelper;

View File

@ -7,7 +7,7 @@ import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import com.fitchgc.headlesscocos.R; import com.fitchgc.jcwallet.R;
import net.openid.appauth.connectivity.ConnectionBuilder; import net.openid.appauth.connectivity.ConnectionBuilder;
import net.openid.appauth.connectivity.DefaultConnectionBuilder; import net.openid.appauth.connectivity.DefaultConnectionBuilder;

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
console.log('>>begin load wallet main file'); console.log('>>begin load wallet main file')
/** /**
* 初始化钱包, 所有操作进行前, 必须调用此方法 * 初始化钱包, 所有操作进行前, 必须调用此方法
@ -6,33 +6,35 @@ console.log('>>begin load wallet main file');
* @param {string} password: 用于加密钱包数据的密码 * @param {string} password: 用于加密钱包数据的密码
*/ */
function initWallet(funId, type, password) { function initWallet(funId, type, password) {
type = 0
try { try {
var wallet; var wallet
if ( !window.jc || !jc.wallet ) { if (!window.jc || !jc.wallet) {
wallet = new jcwallet.default({chain: 322, type, password}); wallet = new jcwallet.default({ chain: 322, type, password })
} else { } else {
wallet = jc.wallet; wallet = jc.wallet
} }
type = parseInt(type); type = parseInt(type)
if (type === 1) { if (type === 1) {
console.log('wallet init success, begin connect') console.log('wallet init success, begin connect')
wallet.initThirdPartyWallet() wallet
.then(() => { .initThirdPartyWallet()
console.log('walletconnect connect success') .then(() => {
var account = jc.wallet.currentAccount(); console.log('walletconnect connect success')
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: account})); var account = jc.wallet.currentAccount()
}) jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: account }))
.catch(err =>{ })
console.log('walletconnect connect error: ' + JSON.stringify(err)); .catch((err) => {
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); console.log('walletconnect connect error: ' + JSON.stringify(err))
}) jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
})
} else { } else {
let address = jc.wallet.currentAccount().address let address = jc.wallet.currentAccount().address
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: address})); jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: address }))
} }
} catch(err) { } catch (err) {
console.error('wallet init with error: ' + JSON.stringify(err)); console.error('wallet init with error: ' + JSON.stringify(err))
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
} }
} }
/** /**
@ -40,10 +42,10 @@ function initWallet(funId, type, password) {
*/ */
function currentAccount(funId) { function currentAccount(funId) {
try { try {
let data = jc.wallet.currentAccountData; let data = jc.wallet.currentAccountData
return JSON.stringify({errcode: 0, data}); return JSON.stringify({ errcode: 0, data })
} catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
/** /**
@ -51,10 +53,10 @@ function currentAccount(funId) {
*/ */
function accountList(funId) { function accountList(funId) {
try { try {
let data = jc.wallet.accounts; let data = jc.wallet.accounts
return JSON.stringify({errcode: 0, data}); return JSON.stringify({ errcode: 0, data })
}catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
/** /**
@ -62,10 +64,10 @@ function accountList(funId) {
*/ */
function chainList(funId) { function chainList(funId) {
try { try {
let data = jc.wallet.chainList; let data = jc.wallet.chainList
return JSON.stringify({errcode: 0, data}); return JSON.stringify({ errcode: 0, data })
}catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
/** /**
@ -73,27 +75,27 @@ function chainList(funId) {
*/ */
function currentChain(funId) { function currentChain(funId) {
try { try {
let data = jc.wallet.currentChain; let data = jc.wallet.currentChain
return JSON.stringify({errcode: 0, data}); return JSON.stringify({ errcode: 0, data })
}catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
/** /**
* [BOTH]切换当前链 * [BOTH]切换当前链
* 切换链需要调用currentAccount方法, 以刷新界面显示 * 切换链需要调用currentAccount方法, 以刷新界面显示
*/ */
function changeChain(funId, chainId) { function changeChain(funId, chainId) {
// chainId = parseInt(chainId); // chainId = parseInt(chainId);
chainId = 80001; chainId = 80001
jc.wallet.updateCurrentChain(chainId) jc.wallet
.then(result => { .updateCurrentChain(chainId)
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result})); .then((result) => {
}) jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
.catch(err => { })
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); .catch((err) => {
}) jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
})
} }
/** /**
* [BOTH]获取当前帐户的登录签名 * [BOTH]获取当前帐户的登录签名
@ -101,13 +103,14 @@ function changeChain(funId, chainId) {
* @param {string} tips: 签名时的提示 * @param {string} tips: 签名时的提示
*/ */
function loginSign(funId, nonce, tips) { function loginSign(funId, nonce, tips) {
jc.wallet.loginSign(nonce, tips) jc.wallet
.then(result => { .loginSign(nonce, tips)
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result})); .then((result) => {
}) jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
.catch(err => { })
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); .catch((err) => {
}) jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
})
} }
/** /**
* 创建一个新帐号, 并将新建帐号设为当前激活帐号 * 创建一个新帐号, 并将新建帐号设为当前激活帐号
@ -115,10 +118,10 @@ function loginSign(funId, nonce, tips) {
*/ */
function createAccount(funId) { function createAccount(funId) {
try { try {
let result = jc.wallet.createAccount(); let result = jc.wallet.createAccount()
return JSON.stringify({errcode: 0, data: result}); return JSON.stringify({ errcode: 0, data: result })
} catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
/** /**
@ -128,9 +131,9 @@ function createAccount(funId) {
function importAccount(funId, privateKey) { function importAccount(funId, privateKey) {
try { try {
let address = jc.wallet.importAccount(privateKey) let address = jc.wallet.importAccount(privateKey)
return JSON.stringify({errcode: 0, data: address}); return JSON.stringify({ errcode: 0, data: address })
} catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
/** /**
@ -138,10 +141,10 @@ function importAccount(funId, privateKey) {
*/ */
function selectAccount(funId, address) { function selectAccount(funId, address) {
try { try {
let result = jc.wallet.selectAccount(address); let result = jc.wallet.selectAccount(address)
return JSON.stringify({errcode: 0, data: result}); return JSON.stringify({ errcode: 0, data: result })
} catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
/** /**
@ -150,11 +153,13 @@ function selectAccount(funId, address) {
* 不传的话, 则获取当前帐户的余额 * 不传的话, 则获取当前帐户的余额
*/ */
function getEthBalance(funId, address) { function getEthBalance(funId, address) {
jc.wallet.getBalance(address) jc.wallet
.then(result => { .getBalance(address)
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result})); .then((result) => {
}).catch(err => { jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); })
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
}) })
} }
/** /**
@ -163,11 +168,13 @@ function getEthBalance(funId, address) {
* @param {string} amount: 转账数量 * @param {string} amount: 转账数量
*/ */
function sendEth(funId, to, amount) { function sendEth(funId, to, amount) {
jc.wallet.sendEth(to, amount) jc.wallet
.then(result => { .sendEth(to, amount)
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result})); .then((result) => {
}).catch(err => { jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); })
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
}) })
} }
@ -178,11 +185,11 @@ function sendEth(funId, to, amount) {
*/ */
function generateIcon(funId, msg, diameter) { function generateIcon(funId, msg, diameter) {
try { try {
diameter = parseFloat(diameter); diameter = parseFloat(diameter)
let result = jc.wallet.generateIconData(msg, diameter); let result = jc.wallet.generateIconData(msg, diameter)
return JSON.stringify({errcode: 0, data: result}); return JSON.stringify({ errcode: 0, data: result })
} catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
@ -192,11 +199,13 @@ function generateIcon(funId, msg, diameter) {
* @param {string} address: 代币的地址 * @param {string} address: 代币的地址
*/ */
function erc20Info(funId, address) { function erc20Info(funId, address) {
jc.wallet.erc20Info(address) jc.wallet
.then(result => { .erc20Info(address)
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result})); .then((result) => {
}).catch(err => { jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); })
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
}) })
} }
/** /**
@ -205,54 +214,58 @@ function erc20Info(funId, address) {
* @param {string} account: 所属帐户的地址, 不传该参数的话, 获取当前钱包激活帐户的余额 * @param {string} account: 所属帐户的地址, 不传该参数的话, 获取当前钱包激活帐户的余额
*/ */
function erc20Balance(funId, address, account) { function erc20Balance(funId, address, account) {
jc.wallet.erc20Balance(address, account) jc.wallet
.then(result => { .erc20Balance(address, account)
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result})); .then((result) => {
}).catch(err => { jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); })
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
}) })
} }
function sendErc20(funId, address, to, amount) { function sendErc20(funId, address, to, amount) {
jc.wallet.sendErc20(address, to, amount) jc.wallet
.then(result => { .sendErc20(address, to, amount)
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result})); .then((result) => {
}).catch(err => { jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err})); })
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
}) })
} }
function restoreFromMnemonic(funId, mnemonic, password) { function restoreFromMnemonic(funId, mnemonic, password) {
try { try {
let result = jc.wallet.restoreFromMnemonic(mnemonic, password); let result = jc.wallet.restoreFromMnemonic(mnemonic, password)
return JSON.stringify({errcode: 0, data: result}); return JSON.stringify({ errcode: 0, data: result })
} catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
function scanQRCode(funId, title) { function scanQRCode(funId, title) {
try { try {
jsb.scanQRCode(funId, title); jsb.scanQRCode(funId, title)
} catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
function signWithGoogle(funId) { function signWithGoogle(funId) {
try { try {
jsb.signWithGoogle(funId); jsb.signWithGoogle(funId)
} catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
function signOutGoogle(funId) { function signOutGoogle(funId) {
try { try {
jsb.signOutGoogle(funId); jsb.signOutGoogle(funId)
return JSON.stringify({errcode: 0, data: 'success'}); return JSON.stringify({ errcode: 0, data: 'success' })
} catch(err) { } catch (err) {
return JSON.stringify({errcode: 1, errmsg: err}); return JSON.stringify({ errcode: 1, errmsg: err })
} }
} }
@ -264,4 +277,3 @@ function signOutGoogle(funId) {
// return JSON.stringify({errcode: 1, errmsg: err}); // return JSON.stringify({errcode: 1, errmsg: err});
// } // }
//} //}

View File

@ -1,22 +1,23 @@
if (window.JavascriptJavaBridge) { if (window.JavascriptJavaBridge) {
console.log('register android jsb.reflection') console.log('register android jsb.reflection')
jsb.reflection = new JavascriptJavaBridge(); jsb.reflection = new JavascriptJavaBridge()
} else if (window.JavaScriptObjCBridge) { } else if (window.JavaScriptObjCBridge) {
jsb.reflection = new JavaScriptObjCBridge(); jsb.reflection = new JavaScriptObjCBridge()
} }
window.jumpToWallet = function(url) { window.jumpToWallet = function (url) {
url = url || 'wc://'; url = url || 'wc://'
console.log('jumpToWallet: ' + url); console.log('jumpToWallet: ' + url)
url = 'metamask://wc?uri='+url url = 'metamask://wc?uri=' + url
jsb.toWallet(url); // url = 'imtokenv2://wc?uri='+url
// jsb.reflection.callStaticMethod( jsb.toWallet(url)
// 'com/jc/jcfw/JcSDK', // jsb.reflection.callStaticMethod(
// 'toWallet', // 'com/jc/jcfw/JcSDK',
// '(Ljava/lang/String;)V', // 'toWallet',
// url || 'wc://' // '(Ljava/lang/String;)V',
// ) // url || 'wc://'
// )
} }
function nativeCallback(funId, msg) { function nativeCallback(funId, msg) {
console.log(`native call back:: funid: ${funId} msg: ${msg}`) console.log(`native call back:: funid: ${funId} msg: ${msg}`)
} }

Binary file not shown.

View File

@ -1,8 +1,8 @@
{ {
"client_id": "112636549810-l5cp5mhm6hq4ejh3g8o4q4gbnbnkvouc.apps.googleusercontent.com", "client_id": "165555585193-glmtnb94s3kkq906hal72ppiuoqpjjc5.apps.googleusercontent.com",
"redirect_uri": "com.googleusercontent.apps.112636549810-l5cp5mhm6hq4ejh3g8o4q4gbnbnkvouc:/oauth2redirect", "redirect_uri": "com.googleusercontent.apps.165555585193-glmtnb94s3kkq906hal72ppiuoqpjjc5:/oauth2redirect",
"end_session_redirect_uri": "com.googleusercontent.apps.112636549810-l5cp5mhm6hq4ejh3g8o4q4gbnbnkvouc:/oauth2redirect", "end_session_redirect_uri": "com.googleusercontent.apps.165555585193-glmtnb94s3kkq906hal72ppiuoqpjjc5:/oauth2redirect",
"authorization_scope": "openid email profile https://www.googleapis.com/auth/drive.appdata", "authorization_scope": "openid email profile",
"discovery_uri": "https://accounts.google.com/.well-known/openid-configuration", "discovery_uri": "https://accounts.google.com/.well-known/openid-configuration",
"authorization_endpoint_uri": "", "authorization_endpoint_uri": "",
"token_endpoint_uri": "", "token_endpoint_uri": "",