增加wallet env 准备好后的通知
This commit is contained in:
parent
06ff4317c7
commit
f3161c8340
@ -72,7 +72,6 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||||||
se->addAfterCleanupHook([]() {
|
se->addAfterCleanupHook([]() {
|
||||||
JSBClassType::destroy();
|
JSBClassType::destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +107,7 @@ NS_CC_BEGIN
|
|||||||
EventDispatcher::init();
|
EventDispatcher::init();
|
||||||
g_app->start();
|
g_app->start();
|
||||||
_isStarted = true;
|
_isStarted = true;
|
||||||
|
WalletEvent::Emit("wallet_init_event", "{}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ NS_CC_BEGIN
|
|||||||
result = "";
|
result = "";
|
||||||
}
|
}
|
||||||
cocos2d::log("method: %s ::result: %s", data->methodName.c_str(), result.c_str());
|
cocos2d::log("method: %s ::result: %s", data->methodName.c_str(), result.c_str());
|
||||||
WalletEvent::Emit("wallet_inited", result.c_str());
|
WalletEvent::Emit(data->funId.c_str(), result.c_str());
|
||||||
return const_cast<char *>(result.c_str());
|
return const_cast<char *>(result.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
58
js/main.js
58
js/main.js
@ -1,36 +1,76 @@
|
|||||||
console.log('>>hi tiny wallet3')
|
console.log('>>hi tiny wallet3')
|
||||||
|
|
||||||
function initWallet(password) {
|
function initWallet(password) {
|
||||||
if (typeof jc === 'undefined' || typeof jc.wwallet === 'undefined') {
|
try {
|
||||||
|
if ( !window.jc || !jc.wwallet ) {
|
||||||
var wallet = new jcwallet.default(password);
|
var wallet = new jcwallet.default(password);
|
||||||
}
|
}
|
||||||
return jc.wallet.currentAccount().address;
|
let address = jc.wallet.currentAccount().address
|
||||||
|
return JSON.stringify({errcode: 0, data: address});
|
||||||
|
} catch(err) {
|
||||||
|
return JSON.stringify({errcode: 1, errmsg: err});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function currentAccount() {
|
function currentAccount() {
|
||||||
return jc.wallet.currentAccount().address;
|
try {
|
||||||
|
let address = jc.wallet.currentAccount().address
|
||||||
|
return JSON.stringify({errcode: 0, data: address});
|
||||||
|
} catch(err) {
|
||||||
|
return JSON.stringify({errcode: 1, errmsg: err});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loginSign(nonce, tips) {
|
function loginSign(nonce, tips) {
|
||||||
return jc.wallet.loginSign(nonce, tips);
|
try {
|
||||||
|
let result = jc.wallet.loginSign(nonce, tips);
|
||||||
|
return JSON.stringify({errcode: 0, data: result});
|
||||||
|
} catch(err) {
|
||||||
|
return JSON.stringify({errcode: 1, errmsg: err});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createAccount() {
|
function createAccount() {
|
||||||
return jc.wallet.createAccount();
|
try {
|
||||||
|
let result = jc.wallet.createAccount();
|
||||||
|
return JSON.stringify({errcode: 0, data: result});
|
||||||
|
} catch(err) {
|
||||||
|
return JSON.stringify({errcode: 1, errmsg: err});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function importAccount(privateKey) {
|
function importAccount(privateKey) {
|
||||||
return jc.wallet.importAccount(privateKey);
|
try {
|
||||||
|
let address = jc.wallet.importAccount(privateKey)
|
||||||
|
return JSON.stringify({errcode: 0, data: address});
|
||||||
|
} catch(err) {
|
||||||
|
return JSON.stringify({errcode: 1, errmsg: err});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAccount(address) {
|
function selectAccount(address) {
|
||||||
return jc.wallet.selectAccount(address);
|
try {
|
||||||
|
let result = jc.wallet.selectAccount(address);
|
||||||
|
return JSON.stringify({errcode: 0, data: result});
|
||||||
|
} catch(err) {
|
||||||
|
return JSON.stringify({errcode: 1, errmsg: err});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBalance(address) {
|
function getBalance(address) {
|
||||||
return jc.wallet.getBalance(address);
|
try {
|
||||||
|
let result = jc.wallet.getBalance(address);
|
||||||
|
return JSON.stringify({errcode: 0, data: result});
|
||||||
|
} catch(err) {
|
||||||
|
return JSON.stringify({errcode: 1, errmsg: err});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendEth(to, amount) {
|
function sendEth(to, amount) {
|
||||||
jc.wallet.sendEth(to, amount);
|
try {
|
||||||
|
let result = jc.wallet.sendEth(to, amount);
|
||||||
|
return JSON.stringify({errcode: 0, data: result});
|
||||||
|
} catch(err) {
|
||||||
|
return JSON.stringify({errcode: 1, errmsg: err});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user