diff --git a/Classes_cocos/JcWallet.cpp b/Classes_cocos/JcWallet.cpp index c4b1c9b..a184932 100644 --- a/Classes_cocos/JcWallet.cpp +++ b/Classes_cocos/JcWallet.cpp @@ -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(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(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(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(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(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 diff --git a/Classes_cocos/JcWallet.h b/Classes_cocos/JcWallet.h index 6b6c05b..583058a 100644 --- a/Classes_cocos/JcWallet.h +++ b/Classes_cocos/JcWallet.h @@ -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; }; diff --git a/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate b/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate index 8f1aac6..836597b 100644 Binary files a/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate and b/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Unity-iPhone.xcodeproj/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Unity-iPhone.xcodeproj/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 6d2fdde..8642064 100644 --- a/Unity-iPhone.xcodeproj/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Unity-iPhone.xcodeproj/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -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"> @@ -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">