Ethereum Unity3D Boilerplate Questions

Yes. In the YouTube video introducing the boilerplate, you mentioned that Example can be safely removed/not imported while the others are required. However, at the moment this is not the case.

From the looks of it those contents should be in the DLLs folder.

Apart from UniTask, no, I added a bunch of asmdefs myself because the code I work with uses them extensively.

Specifically, I added an asmdef in each of these folders: Moralis, WalletConnectSharp\WalletConnectSharp.Core, WalletConnectSharp.Unity.
I’m also aware of the one in the location you provided because I was linking each of these asmdefs up that way.

EDIT: at the moment I’ve put an asmdef at the root of the MoralisWeb3ApiSdk folder and linked up the required inner asmdefs correctly. For the purpose of my code, I can use this now, without modifying any of the scripts (except for deleting the duplicate script from WalletConnectSharp.Unity\EditorTools – I prefer following the Unity convention of using Editor instead).

My point was that WalletSelectItem was being referenced by WalletConnectSharp.Unity from Moralis which doesn’t make sense from a modular standpoint.

I’m trying to make a UPM package for local use which incorporates the Moralis boilerplate minus the Example and its scenes (UPM does not support putting scenes in packages), with a bunch of asmdefs for linking with the rest of my codebase.

Other Issues

BTW does the boilerplate package make changes to TextMeshPro? I see that it is included along with the rest of the package contents, which is expected because Unity packages all dependencies together.

I’m also seeing some .cs.bak files in the project, unsure if that should be kept around?

Is it possible to currently work with IL2CPP with this project? I found this GitHub issue about not being able to find HttpUtility when using .NET Framework 4.x.

I can make a pull request if you need it!

1 Like

Hi David,
I’m currently trying out the webGL build of the demo from commit 7138dfb97bbe32984bb3222470a318590a74c460
and it looks like it’s doing the same kind of “flow” as on PC - i.e. asking to scan the QR code. Is that how it’s supposed to work? I would assume the webGL build would connect (or ask to connect) to metamask or some other browser wallet plugin?

2 Likes

I will add an issue to Github for the dependancies in Examples to be moved out of Examples.

It does not. TextMeshPro is used as is.

No. I will add an entry to .gitignore.

The Unity uses IL2CPP for the WebGL to yes. The HttpUtility reference will be removed as it is used in only one place and seems to cause a lot issues for users.

Thak you for you help.

Regards,

David

1 Like

I saw that the Liberation Sans font of TextMeshPro gets modified by the one present in the package.

1 Like

I apologize for any frustration this is causing. This is the default behaviour provided by the Wallet Connect Unity package. I do have a modification in the works so that WebGL calls the browser wallet but honestly it is still in early development.

Regards,

David

1 Like

@Vivraan,

Could you provide the locaion of this change? I do not recall modifying TextMeshPro.

Thank you,

David

It should be the Liberation Sans SDF asset itself. The colour is changed to yellow?

For 1.0.2 of course.

1 Like

Ah, The color was changed in the properties of the menu object in the demo scene. This change is for the demo only. Removing this change may change the way the demo looks but will not change the way the demo works. Feel free to change this in your app.

Regards,

David

1 Like

How exactly should I parse objects returned by cloud functions?

Currently I’m doing something like this:

try
{
    return await MoralisInterface.GetClient().Cloud
        .RunAsync<PutRequestResponse>(
            CfNamePutWalletWasActiveInInterval,
            new Dictionary<string, object>
                { ["signal"] = wasActive })
        .AsUniTask();
}
catch (MoralisFailureException e)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
    Debug.LogError($"Moralis SDK encountered an error: {e}");
#endif
    throw;
}

where

[Serializable]
protected struct PutRequestResponse
{
    public bool valid;
}

is the response object’s type.

However I just want the function to return true or false, not a JSON key-value pair?

In the current case I’m expecting that my response must look like

return {
    "valid": true
};

in the JS.

1 Like

Also, when I’m passing the validation requireUser: true to a cloud function, what exactly gets stored in request.user?

1 Like

@vivraan,

The Cloud.RunAsync will return T. So you can do a couple of things.

  1. Change the current code from:
return await MoralisInterface.GetClient().Cloud
        .RunAsync<PutRequestResponse> ... ;

to

PutRequestResponse resp = await MoralisInterface.GetClient().Cloud
        .RunAsync<PutRequestResponse> ... ;
return resp.valid;
  1. If you own the Cloud Function change it to return the bool directly and change the code to:
 return await MoralisInterface.GetClient().Cloud
        .RunAsync<bool> ... ;

Thoughts?

David

The second thing makes perfect sense. I’ll do just that and be more careful of bombarding you with questions next time! :sweat_smile:

1 Like

Under the hood the user.sessionToken is automatically being sent with the cloud function request as a header (X-Parse-Session-Token). The backend takes this and passes it to the cloud funtion.

Parse uses this to retrieve the user object to pass to the cloud function.

Please see the docs section for Cloud functions for more information.

Regards,

David

No worries. Glad you are using the SDK and I want everyone who does to be successful. I want to make this as easy to use and as bullet proof as I can. It has been challenging and there is a way to go yet. Every problem reported / question asked helps to reach the goal faster and let me know what to concentrate on.

Keep up the good work!

David

1 Like

Is there a way in VS Code to get type information of all the required SDK entities?

I see that there are a few Typescript examples around that I can use, but is it possible with JS too?

Most of my questions are related to data types of parameters and their contents, so a user manual would be greatly helpful: I’m having trouble autocompleting Moralis functions on VS Code, and so far I don’t think I’ve got the IDE to understand that moralis is already installed via npm install -g moralis. Somehow, npm install --save-dev moralis returns an error saying it couldn’t install Logger?

1 Like

For industry standardization and centralization, I suggest the following paths for all files in the Moralis unity package.

  • \Assets\3rdParty\Moralis\MoralisSDK\
  • \Assets\3rdParty\Moralis\MoralisSDKExamples\
1 Like

That worked great, thanks!

1 Like

Where can I find this interface?

1 Like

I Need Help I am getting this error from Unity SDK Assets\MoralisWeb3ApiSdk\Moralis\Moralis.Web3Api\Client\ApiClient.cs(120,20): error CS0103: The name ‘HttpUtility’ does not exist in the current context and Assets\MoralisWeb3ApiSdk\Moralis\Moralis.WebGL\Moralis.Web3Api\Client\ApiClient.cs(157,20): error CS0103: The name ‘HttpUtility’ does not exist in the current context ( I’m using Unity 2020.3.24f1 )
it only works with .net Standerd 2.0

1 Like

That feature is planned to be replaced in the upcoming updates precisely because it trips up a lot of people.
For now, use .NET Standard 2.0, or try to include System.Web.dll somehow. There also an issue posted for this very problem in the Unity boilerplate repo.

2 Likes