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
.DS_Store
/build
/app/debug
/captures
.externalNativeBuild
.cxx

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.fitchgc.headlesscocos">
package="com.fitchgc.jcwallet">
<application
android:allowBackup="true"
@ -13,7 +13,7 @@
<!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="cocos2djs" />
<activity android:name=".MainActivity"
<activity android:name="MainActivity"
android:screenOrientation="sensorLandscape"
android:exported="true"
>
@ -51,7 +51,7 @@
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<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>
</activity>
<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.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.GoogleApiAvailability;
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.jc.jcfw.JcSDK;
import com.jc.jcfw.appauth.AuthStateManager;
@ -138,7 +137,7 @@ public class MainActivity extends Activity
// begin of google sign
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.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();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
// end of google sign

View File

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

View File

@ -7,7 +7,7 @@ import android.content.res.Resources;
import android.net.Uri;
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.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: 用于加密钱包数据的密码
*/
function initWallet(funId, type, password) {
type = 0
try {
var wallet;
var wallet
if (!window.jc || !jc.wallet) {
wallet = new jcwallet.default({chain: 322, type, password});
wallet = new jcwallet.default({ chain: 322, type, password })
} else {
wallet = jc.wallet;
wallet = jc.wallet
}
type = parseInt(type);
type = parseInt(type)
if (type === 1) {
console.log('wallet init success, begin connect')
wallet.initThirdPartyWallet()
wallet
.initThirdPartyWallet()
.then(() => {
console.log('walletconnect connect success')
var account = jc.wallet.currentAccount();
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));
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
.catch((err) => {
console.log('walletconnect connect error: ' + JSON.stringify(err))
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
})
} else {
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) {
console.error('wallet init with error: ' + JSON.stringify(err));
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
console.error('wallet init with error: ' + JSON.stringify(err))
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
}
}
/**
@ -40,10 +42,10 @@ function initWallet(funId, type, password) {
*/
function currentAccount(funId) {
try {
let data = jc.wallet.currentAccountData;
return JSON.stringify({errcode: 0, data});
let data = jc.wallet.currentAccountData
return JSON.stringify({ errcode: 0, data })
} 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) {
try {
let data = jc.wallet.accounts;
return JSON.stringify({errcode: 0, data});
let data = jc.wallet.accounts
return JSON.stringify({ errcode: 0, data })
} 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) {
try {
let data = jc.wallet.chainList;
return JSON.stringify({errcode: 0, data});
let data = jc.wallet.chainList
return JSON.stringify({ errcode: 0, data })
} catch (err) {
return JSON.stringify({errcode: 1, errmsg: err});
return JSON.stringify({ errcode: 1, errmsg: err })
}
}
/**
@ -73,12 +75,11 @@ function chainList(funId) {
*/
function currentChain(funId) {
try {
let data = jc.wallet.currentChain;
return JSON.stringify({errcode: 0, data});
let data = jc.wallet.currentChain
return JSON.stringify({ errcode: 0, data })
} catch (err) {
return JSON.stringify({errcode: 1, errmsg: err});
return JSON.stringify({ errcode: 1, errmsg: err })
}
}
/**
* [BOTH]切换当前链
@ -86,13 +87,14 @@ function currentChain(funId) {
*/
function changeChain(funId, chainId) {
// chainId = parseInt(chainId);
chainId = 80001;
jc.wallet.updateCurrentChain(chainId)
.then(result => {
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result}));
chainId = 80001
jc.wallet
.updateCurrentChain(chainId)
.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 }))
})
}
/**
@ -101,12 +103,13 @@ function changeChain(funId, chainId) {
* @param {string} tips: 签名时的提示
*/
function loginSign(funId, nonce, tips) {
jc.wallet.loginSign(nonce, tips)
.then(result => {
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result}));
jc.wallet
.loginSign(nonce, tips)
.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) {
try {
let result = jc.wallet.createAccount();
return JSON.stringify({errcode: 0, data: result});
let result = jc.wallet.createAccount()
return JSON.stringify({ errcode: 0, data: result })
} 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) {
try {
let address = jc.wallet.importAccount(privateKey)
return JSON.stringify({errcode: 0, data: address});
return JSON.stringify({ errcode: 0, data: address })
} 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) {
try {
let result = jc.wallet.selectAccount(address);
return JSON.stringify({errcode: 0, data: result});
let result = jc.wallet.selectAccount(address)
return JSON.stringify({ errcode: 0, data: result })
} 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) {
jc.wallet.getBalance(address)
.then(result => {
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result}));
}).catch(err => {
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
jc.wallet
.getBalance(address)
.then((result) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
})
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
})
}
/**
@ -163,11 +168,13 @@ function getEthBalance(funId, address) {
* @param {string} amount: 转账数量
*/
function sendEth(funId, to, amount) {
jc.wallet.sendEth(to, amount)
.then(result => {
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result}));
}).catch(err => {
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
jc.wallet
.sendEth(to, amount)
.then((result) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
})
.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) {
try {
diameter = parseFloat(diameter);
let result = jc.wallet.generateIconData(msg, diameter);
return JSON.stringify({errcode: 0, data: result});
diameter = parseFloat(diameter)
let result = jc.wallet.generateIconData(msg, diameter)
return JSON.stringify({ errcode: 0, data: result })
} 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: 代币的地址
*/
function erc20Info(funId, address) {
jc.wallet.erc20Info(address)
.then(result => {
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result}));
}).catch(err => {
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
jc.wallet
.erc20Info(address)
.then((result) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
})
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
})
}
/**
@ -205,54 +214,58 @@ function erc20Info(funId, address) {
* @param {string} account: 所属帐户的地址, 不传该参数的话, 获取当前钱包激活帐户的余额
*/
function erc20Balance(funId, address, account) {
jc.wallet.erc20Balance(address, account)
.then(result => {
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result}));
}).catch(err => {
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
jc.wallet
.erc20Balance(address, account)
.then((result) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
})
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
})
}
function sendErc20(funId, address, to, amount) {
jc.wallet.sendErc20(address, to, amount)
.then(result => {
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: result}));
}).catch(err => {
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
jc.wallet
.sendErc20(address, to, amount)
.then((result) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }))
})
.catch((err) => {
jsb.jcCallback(funId, JSON.stringify({ errcode: 1, errmsg: err }))
})
}
function restoreFromMnemonic(funId, mnemonic, password) {
try {
let result = jc.wallet.restoreFromMnemonic(mnemonic, password);
return JSON.stringify({errcode: 0, data: result});
let result = jc.wallet.restoreFromMnemonic(mnemonic, password)
return JSON.stringify({ errcode: 0, data: result })
} catch (err) {
return JSON.stringify({errcode: 1, errmsg: err});
return JSON.stringify({ errcode: 1, errmsg: err })
}
}
function scanQRCode(funId, title) {
try {
jsb.scanQRCode(funId, title);
jsb.scanQRCode(funId, title)
} catch (err) {
return JSON.stringify({errcode: 1, errmsg: err});
return JSON.stringify({ errcode: 1, errmsg: err })
}
}
function signWithGoogle(funId) {
try {
jsb.signWithGoogle(funId);
jsb.signWithGoogle(funId)
} catch (err) {
return JSON.stringify({errcode: 1, errmsg: err});
return JSON.stringify({ errcode: 1, errmsg: err })
}
}
function signOutGoogle(funId) {
try {
jsb.signOutGoogle(funId);
return JSON.stringify({errcode: 0, data: 'success'});
jsb.signOutGoogle(funId)
return JSON.stringify({ errcode: 0, data: 'success' })
} 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});
// }
//}

View File

@ -1,15 +1,16 @@
if (window.JavascriptJavaBridge) {
console.log('register android jsb.reflection')
jsb.reflection = new JavascriptJavaBridge();
jsb.reflection = new JavascriptJavaBridge()
} else if (window.JavaScriptObjCBridge) {
jsb.reflection = new JavaScriptObjCBridge();
jsb.reflection = new JavaScriptObjCBridge()
}
window.jumpToWallet = function (url) {
url = url || 'wc://';
console.log('jumpToWallet: ' + url);
url = url || 'wc://'
console.log('jumpToWallet: ' + url)
url = 'metamask://wc?uri=' + url
jsb.toWallet(url);
// url = 'imtokenv2://wc?uri='+url
jsb.toWallet(url)
// jsb.reflection.callStaticMethod(
// 'com/jc/jcfw/JcSDK',
// 'toWallet',

Binary file not shown.

View File

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