Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CronosPlayUnreal.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"FileVersion": 3,
"FriendlyName": "Cronos Play for Unreal Engine",
"Version": 1,
"VersionName": "v0.0.17-alpha",
"EngineVersion": "5.2.0",
"VersionName": "v0.0.18-alpha",
"EngineVersion": "5.3.0",
"Description": "Cronos labs",
"Category": "Programming",
"CreatedBy": "Cronos labs",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ UNAME := $(shell uname)
PWD = $(shell pwd)

# Set the play cpp sdk version
PLAYCPPSDK=v0.0.23-alpha
PLAYCPPSDK=v0.0.24-alpha
# Set the play-cpp-sdk cache path
PLAYCPPSDK_CACHE_DIR=./install/$(PLAYCPPSDK)
# Set the play-cpp-sdk target path
Expand Down
8 changes: 8 additions & 0 deletions Source/CronosPlayUnreal/CronosPlayUnreal.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,13 @@ public CronosPlayUnreal(ReadOnlyTargetRules Target) : base(Target) {
"AndroidPlugin",
System.IO.Path.Combine(PluginPath, "Android.xml"));
}
if (Target.Platform == UnrealTargetPlatform.Mac) {
// Add frameworks for macOS
PublicFrameworks.AddRange(new string[] {
"Security",
"CoreFoundation",
"SystemConfiguration"
});
}
}
}
3 changes: 2 additions & 1 deletion Source/CronosPlayUnreal/Private/PlayCppSdkActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,10 @@ void APlayCppSdkActor::SendEip155Transaction(
::std::array<::std::uint8_t, 20> dstaddress;
for (int i = 0; i < address.Num(); i++) {
dstaddress[i] = address[i];
}
}

WalletConnectTxEip155 myinfo;
myinfo.from= TCHAR_TO_UTF8(*info.from);
myinfo.to = TCHAR_TO_UTF8(*info.to);
myinfo.common.gas_limit = TCHAR_TO_UTF8(*info.gas);
myinfo.common.gas_price = TCHAR_TO_UTF8(*info.gas_price);
Expand Down
3 changes: 3 additions & 0 deletions Source/CronosPlayUnreal/Public/PlayCppSdkActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ struct FWalletConnectTxEip155 {
GENERATED_USTRUCT_BODY()
/** hexstring, "0x..." */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PlayCppSdk")
FString from;
/** hexstring, "0x..." */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PlayCppSdk")
FString to;
/** gas limit in decimal string */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PlayCppSdk")
Expand Down
103 changes: 51 additions & 52 deletions Source/ThirdParty/PlayCppSdkLibrary/Include/android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,77 +12,76 @@ namespace org {
namespace defi_wallet_core {

int secureStorageSetJavaEnv(JNIEnv *userenv) {
g_env = userenv;
return 1;
g_env = userenv;
return 1;
}

jclass getSecureStorageClass(JNIEnv *env) {
string secureStorageClass = SECURE_STORAGE_CLASS;
jclass kotlinClass = env->FindClass(secureStorageClass.c_str());
return kotlinClass;
string secureStorageClass = SECURE_STORAGE_CLASS;
jclass kotlinClass = env->FindClass(secureStorageClass.c_str());
return kotlinClass;
}
jobject getContext(JNIEnv *env) {
jclass activityThreadClass = env->FindClass("android/app/ActivityThread");
jmethodID currentActivityThreadMethod =
env->GetStaticMethodID(activityThreadClass, "currentActivityThread",
"()Landroid/app/ActivityThread;");
jobject activityThread = env->CallStaticObjectMethod(
activityThreadClass, currentActivityThreadMethod);
jmethodID getApplicationMethod = env->GetMethodID(
activityThreadClass, "getApplication", "()Landroid/app/Application;");
jobject context =
env->CallObjectMethod(activityThread, getApplicationMethod);
return context;
jclass activityThreadClass = env->FindClass("android/app/ActivityThread");
jmethodID currentActivityThreadMethod =
env->GetStaticMethodID(activityThreadClass, "currentActivityThread",
"()Landroid/app/ActivityThread;");
jobject activityThread = env->CallStaticObjectMethod(
activityThreadClass, currentActivityThreadMethod);
jmethodID getApplicationMethod = env->GetMethodID(
activityThreadClass, "getApplication", "()Landroid/app/Application;");
jobject context = env->CallObjectMethod(activityThread, getApplicationMethod);
return context;
}
int secureStorageWriteBasic(JNIEnv *env, string userkey, string uservalue) {

jobject context = getContext(env);
jclass secureStorageClass = getSecureStorageClass(env);
jmethodID functionMethod = env->GetStaticMethodID(
secureStorageClass, "writeSecureStorage",
"(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)I");
jstring key = env->NewStringUTF(userkey.c_str());
jstring value = env->NewStringUTF(uservalue.c_str());
jint ret = env->CallStaticIntMethod(secureStorageClass, functionMethod,
context, key, value);
jobject context = getContext(env);
jclass secureStorageClass = getSecureStorageClass(env);
jmethodID functionMethod = env->GetStaticMethodID(
secureStorageClass, "writeSecureStorage",
"(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)I");
jstring key = env->NewStringUTF(userkey.c_str());
jstring value = env->NewStringUTF(uservalue.c_str());
jint ret = env->CallStaticIntMethod(secureStorageClass, functionMethod,
context, key, value);

return (int)ret;
return (int)ret;
}

string secureStorageReadBasic(JNIEnv *env, string userkey) {
jobject context = getContext(env);
jclass secureStorageClass = getSecureStorageClass(env);
jmethodID functionMethod = env->GetStaticMethodID(
secureStorageClass, "readSecureStorage",
"(Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;");
jstring userkeyarg = env->NewStringUTF(userkey.c_str());
jobject ret = env->CallStaticObjectMethod(
secureStorageClass, functionMethod, context, userkeyarg);
string retstring = string(env->GetStringUTFChars((jstring)ret, 0));
jobject context = getContext(env);
jclass secureStorageClass = getSecureStorageClass(env);
jmethodID functionMethod = env->GetStaticMethodID(
secureStorageClass, "readSecureStorage",
"(Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;");
jstring userkeyarg = env->NewStringUTF(userkey.c_str());
jobject ret = env->CallStaticObjectMethod(secureStorageClass, functionMethod,
context, userkeyarg);
string retstring = string(env->GetStringUTFChars((jstring)ret, 0));

return retstring;
return retstring;
}

int secureStorageWrite(rust::String userkey, rust::String uservalue) {
try {
JNIEnv *env = g_env;
string userkeystring = userkey.c_str();
string uservaluestring = uservalue.c_str();
int ret = secureStorageWriteBasic(env, userkeystring, uservaluestring);
return ret;
} catch (exception &e) {
return 0; // fail
}
try {
JNIEnv *env = g_env;
string userkeystring = userkey.c_str();
string uservaluestring = uservalue.c_str();
int ret = secureStorageWriteBasic(env, userkeystring, uservaluestring);
return ret;
} catch (exception &e) {
return 0; // fail
}
}

rust::String secureStorageRead(rust::String userkey) {
try {
JNIEnv *env = g_env;
string ret = secureStorageReadBasic(env, userkey.c_str());
return rust::String(ret.c_str());
} catch (exception &e) {
return rust::String(""); // fail
}
try {
JNIEnv *env = g_env;
string ret = secureStorageReadBasic(env, userkey.c_str());
return rust::String(ret.c_str());
} catch (exception &e) {
return rust::String(""); // fail
}
}

} // namespace defi_wallet_core
Expand Down
Loading