增加一个调用wallet方法的通用方法
This commit is contained in:
parent
c4c56cd7bc
commit
cd31627c87
@ -17,7 +17,6 @@ NS_CC_BEGIN
|
||||
|
||||
cocos2d::Application *g_app = nullptr;
|
||||
JcWallet *JcWallet::_instance = nullptr;
|
||||
static std::string result;
|
||||
bool _isStarted = false;
|
||||
|
||||
JcWallet::JcWallet() {
|
||||
@ -46,8 +45,10 @@ NS_CC_BEGIN
|
||||
char* JcWallet::initWallet() {
|
||||
se::Value value;
|
||||
jsb_run_code("jc.wallet.currentAccount().address", &value);
|
||||
result = value.toString();
|
||||
WalletEvent::Emit("wallet_inited", "{}");
|
||||
static std::string result = value.toString();
|
||||
WalletEvent::Emit("wallet_inited", "{1}");
|
||||
WalletEvent::Emit("wallet_inited", "{2}");
|
||||
WalletEvent::Emit("wallet_inited", "{3}");
|
||||
return const_cast<char*>(result.c_str());
|
||||
}
|
||||
|
||||
@ -57,14 +58,14 @@ NS_CC_BEGIN
|
||||
std::string jsCode = "jc.wallet.loginSign('" + nonce + "','" + tips + "')";
|
||||
se::Value value;
|
||||
jsb_run_code(jsCode, &value);
|
||||
result = value.toString();
|
||||
static std::string result = value.toString();
|
||||
return const_cast<char*>(result.c_str());
|
||||
}
|
||||
|
||||
char* JcWallet::createAccount() {
|
||||
se::Value value;
|
||||
jsb_run_code("jc.wallet.createAccount()", &value);
|
||||
result = value.toString();
|
||||
static std::string result = value.toString();
|
||||
return const_cast<char*>(result.c_str());
|
||||
}
|
||||
|
||||
@ -73,10 +74,19 @@ NS_CC_BEGIN
|
||||
std::string jsCode = "jc.wallet.importAccount('" + key + "')";
|
||||
se::Value value;
|
||||
jsb_run_code(jsCode, &value);
|
||||
result = value.toString();
|
||||
static std::string result = value.toString();
|
||||
return const_cast<char*>(result.c_str());
|
||||
}
|
||||
|
||||
char* runMethod(const char *methodName, const char *params) {
|
||||
std::string methodStr(methodName);
|
||||
std::string paramsStr(params);
|
||||
std::string jsCode = "jc.wallet."+methodStr+"('" + paramsStr + "')";
|
||||
se::Value value;
|
||||
jsb_run_code(jsCode, &value);
|
||||
static std::string result = value.toString();
|
||||
return const_cast<char*>(result.c_str());
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -93,6 +103,9 @@ NS_CC_BEGIN
|
||||
char* importAccount(const char *privateKey) {
|
||||
return JcWallet::getInstance()->importAccount(privateKey);
|
||||
}
|
||||
char* runWalletMethod(const char *methodName, const char *params) {
|
||||
return JcWallet::getInstance()->runMethod(methodName, params);
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
@ -11,6 +11,7 @@ public:
|
||||
char* signLogin(const char *nonceChar, const char *tipChar);
|
||||
char* createAccount();
|
||||
char* importAccount(const char *privateKey);
|
||||
char* runMethod(const char *methodName, const char *params);
|
||||
private:
|
||||
static JcWallet* _instance;
|
||||
};
|
||||
|
Binary file not shown.
@ -30,8 +30,8 @@
|
||||
filePath = "Classes_cocos/JcWallet.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "55"
|
||||
endingLineNumber = "55"
|
||||
startingLineNumber = "56"
|
||||
endingLineNumber = "56"
|
||||
landmarkName = "JcWallet::signLogin(nonceChar, tipChar)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -46,8 +46,8 @@
|
||||
filePath = "Classes_cocos/JcWallet.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "65"
|
||||
endingLineNumber = "65"
|
||||
startingLineNumber = "66"
|
||||
endingLineNumber = "66"
|
||||
landmarkName = "JcWallet::createAccount()"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
|
Loading…
x
Reference in New Issue
Block a user