-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem: missing dynamic contract (fix #226) #230
Conversation
files under CronosPlayUnreal can be reviewed other files are automatically generated |
checking ci issues |
investigating unreal error |
ddb449f
to
a011629
Compare
@damoncro fixed in play-cpp-sdk, will upgrade play-cpp-sdk shortly |
for linux, back to use clang 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few unrelated linter errors (/Source/CronosPlayUnreal/Private/DefiWalletCoreActor.cpp:20:13 [modernize-use-trailing-return-type] use a trailing return type for this function; /Source/CronosPlayUnreal/Private/DefiWalletCoreActor.cpp:28:21 [cppcoreguidelines-init-variables] variable 'ret' is not initialized etc.)
--
besides that, can the API in Unreal be split into contract object construction (to be done once by the developer) and function calling (that could be done multiple times) to match C++ bindings?
void ADefiWalletCoreActor::SendDynamicContract( | ||
FString contractAddress, int32 walletindex, FString abiJson, | ||
FString functionName, FString functionArgs, | ||
FDynamicContractSendDelegate Out) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these all be under defiwalletcoreactor? or could there be a "contract actor" or something like that that one will initialize once with the common params (contract address, abijson, rpc address) and then just call a function on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's possible. i'll refactor
* @param walletindex wallet index which starts from 0 | ||
* @param abiJson abi json | ||
* @param functionName function name | ||
* @param functionArgs function args injson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the function args, it'll be good to give an example, because the format is not obvious just from the description... maybe using doxygen's \code ... \endcode
command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i'll add an example , so that user can refer to it
ok, working on the feedback |
350b2f7
to
768d127
Compare
yes, that's possible. |
working now~ |
|
b89c127
to
c8804ff
Compare
rebased |
df622d6
to
24b48a8
Compare
uninitialize error : using default constructor doesn't work, applied NOLINT fixed trailing return warning |
1e956ea
to
1771298
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the actor be instantiated multiple times (if one wanted to use different dynamic contracts at the same time)?
@@ -0,0 +1,241 @@ | |||
// Fill out your copyright notice in the Description page of Project Settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this comment should be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i'll remove it
// Set this actor to call Tick() every frame. You can turn this off to | ||
// improve performance if you don't need it. | ||
PrimaryActorTick.bCanEverTick = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
// improve performance if you don't need it. | ||
PrimaryActorTick.bCanEverTick = true; | ||
defiWallet = NULL; | ||
_coreContract = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it will only allow one contract globally? or can one instantiate multiple actors that have different contracts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can be multiple
@@ -0,0 +1,161 @@ | |||
// Fill out your copyright notice in the Description page of Project Settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably to be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i'll remove it
/** | ||
* @param cronosrpc cronos rpc server endpoint | ||
* @param contractaddress contract address | ||
* @param abijson contract abi json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it should specify that it should be the abi json text/content... someone may be confused and put e.g. a file path to abi json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
* simple json example: Address, String | ||
* [{"Address":{"data":"0x00"}},{"Str":{"data":"my"}}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for these examples, maybe it'll be also good to write Solidity function signature, so it's more obvious what t hat sample corresponds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
CI does not run. |
working on feedback, and will check ci |
19ea96d
to
5d1eb5b
Compare
updated changelog |
Any reason to create a new Actor instead of putting it into DefiWalletCoreActor? Common things like cronosrpc can be shared inside DefiWalletCoreActor. |
|
6ce0536
to
2e3eb3f
Compare
How about |
working on it |
58148b9
to
38eca15
Compare
ready to review |
38eca15
to
e885e31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one main question is why *_coreContract
is public? I guess *defiWallet
needs to be public, so that it can be set/accessed from a blueprint? or could it be private and have blueprint getter/setter?
FString abijson, bool &success, | ||
FString &output_message) { | ||
UDynamicContractObject *ret = NewObject<UDynamicContractObject>(); | ||
ret->defiWallet = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok for ret->defiWallet
to be accessed concurrently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raw pointer is not protected, but defiWallet is marked as "UPROPERTY" , and managed by unreal garbage collector.
and like unity3d, for unreal engine,engine related apis are all in the single thread(game thread), so concurrency safe. only ue4 engine apis can be called in that thread.
rendering, networking are in other threads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_coreContract can be private, i'll change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm double checking with unreal engine document
// restored back | ||
rust::cxxbridge1::Box<org::defi_wallet_core::EthContract> tmpwallet = | ||
rust::cxxbridge1::Box<org::defi_wallet_core::EthContract>::from_raw( | ||
_coreContract); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed? for deallocating that contract object in Rust?
nit: var name perhaps can be tmpcontract
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c++ pointer is earned by "into_raw" , so give ownership back to rust box, remove elegantly.
i'll change the name
#include "PlayCppSdkLibrary/Include/defi-wallet-core-cpp/src/ethereum.rs.h" | ||
#include "DynamicContractObject.generated.h" | ||
|
||
using namespace std; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are some linter warnings:
variable 'namespace' is non-const and globally accessible, consider making it const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i'll check linting errors
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CronosPlayUnreal") | ||
ADefiWalletCoreActor *defiWallet; | ||
|
||
org::defi_wallet_core::EthContract *_coreContract; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why to have this internal field in public:
and not private:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_coreContract can be private, i'll change
fixed c++ linting errors |
e885e31
to
264a125
Compare
checked UPROERTY and raw pointer document is a little ambiguous |
Please update CHANGELOG.md. |
ok |
update play-cpp-sdk ok add encode add call adding send send working add read json add comment format back format rebase specify ubuntu version use ubuntu-20.04 fix signing upgrade play-cpp-sdk compiles send ok read json as static add comment add json example add example fix typo restore Problem: missing dynamic contract (fix #226) update play-cpp-sdk ok add encode add call adding send send working add read json add comment format back format rebase specify ubuntu version use ubuntu-20.04 fix signing upgrade play-cpp-sdk compiles send ok read json as static add comment add json example add example fix typo restore check lint update play-cpp-sdk change header not run in every frame json string clear comment add function sig add changelog add dynamic-contract uobject works add log add log remove contract actor add comment add comment add json example add json comment make private change variable name fix lint nolint changelog update
264a125
to
04813a8
Compare
Solution: add dynamic contract