Skip to content

Commit

Permalink
Updated master (#137)
Browse files Browse the repository at this point in the history
* optional timeout introduced

* clover to mrg renaming

* Mirage NFT usage example (#131)

* mirage nft example finished

* minor renaming

* remove unused method

* post review changes

* remove unused using statement

* Webgl build errors fixes (#132)

* webgl updates wip

* webgl wip

* minor renamings + webgl template change

* build errors fixes wip

* webgl websocket fixes

* meta file small update

* change dlls meta settings

* remove unused dlls

* integrate webgl websocket

* log assets with extension

* minor typo fix

* webgl template updates

* Nethereum source note added

* meta files

* minor safety improvement + reformat

* template updated (#133)

* turn off il2cpp for standalone builds because QRCoder does not compile well in this case

* WebGL WalletConnect WebSocket bugfixes + updates to recent version of Unity WebGL (#135)

* websocket bug fixes for webgl

* triple s typo fix

* single quotes

* reformat and cleanup jslib

* turn off il2cpp for standalone builds because QRCoder does not compile well in this case

* WebGLConnect refactoring and interface generalization with WalletConnect (#136)

* webgl connect interface generalization

* webgl generalization

* webgl generalization finished

* platform related compile errors fixed

* settings update

* default wallet to none

* Pointer_stringify changed to UTFToString

* turn off debug mode

* webgl hardcoded value moved to variable

* Revert "Dev to Master (#134)"

This reverts commit 293e57e.

# Conflicts:
#	ProjectSettings/ProjectSettings.asset

---------

Co-authored-by: alekseeveg <alekseev@ankr.com>
Co-authored-by: Anton VIkharev <anton@mirage.xyz>
  • Loading branch information
3 people authored Jun 9, 2023
1 parent 2a87646 commit b60c94f
Show file tree
Hide file tree
Showing 60 changed files with 807 additions and 689 deletions.
14 changes: 7 additions & 7 deletions Assets/MirageSDK/Examples/Scripts/UI/ConnectionController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using MirageSDK.Utils;
using MirageSDK.WalletConnectSharp.Core;
using MirageSDK.WalletConnectSharp.Unity.Events;
using MirageSDK.WalletConnectSharp.Core.StatusEvents;
using TMPro;
using UnityEngine.Events;
using UnityEngine.UI;
Expand Down Expand Up @@ -30,7 +30,7 @@ private void OnEnable()
SubscribeToWalletEvents();
UpdateLoginButtonState();
}

private UnityAction GetLoginAction()
{
if (!Application.isEditor)
Expand All @@ -43,7 +43,7 @@ private UnityAction GetLoginAction()
return WalletConnect.OpenDeepLink;
}
}

return () =>
{
_qrCodeImage.UpdateQRCode(WalletConnect.ConnectURL);
Expand Down Expand Up @@ -74,21 +74,21 @@ private void SessionStatusUpdated(WalletConnectTransitionBase walletConnectTrans
private void UpdateLoginButtonState()
{
var status = WalletConnect.Status;

if (status == WalletConnectStatus.Uninitialized)
{
return;
}

var walletConnected = status == WalletConnectStatus.WalletConnected;
_sceneChooser.SetActive(walletConnected);
_chooseWalletScreen.SetActive(!walletConnected);

bool waitingForLoginInput = status == WalletConnectStatus.SessionRequestSent;

_loginButton.gameObject.SetActive(waitingForLoginInput);
_stateText.gameObject.SetActive(!waitingForLoginInput && !walletConnected);

_qrCodeImage.SetImageActive(false);

if (!waitingForLoginInput)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using MirageSDK.Utils;
using MirageSDK.WalletConnectSharp.Core;
using MirageSDK.WalletConnectSharp.Unity.Events;
using Cysharp.Threading.Tasks;
using MirageSDK.WalletConnectSharp.Core.StatusEvents;
using UnityEngine;
using UnityEngine.UI;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"WalletConnectSharp",
"WalletConnectSharp.Core",
"WalletConnectSharp.VersionShared",
"Unity.TextMeshPro"
"Unity.TextMeshPro",
"WalletConnectSharp.Unity"
],
"includePlatforms": [
"Editor",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using MirageSDK.Data;
using MirageSDK.WalletConnectSharp.Core.StatusEvents;
using MirageSDK.WebGL;
using UnityEngine;

Expand Down Expand Up @@ -33,8 +34,7 @@ private void Awake()
{
if (WebGLConnect != null)
{
WebGLConnect.OnLoginPanelRequested += ActivatePanel;
WebGLConnect.OnConnect += HandleConnect;
WebGLConnect.SessionStatusUpdated += OnSessionStatusUpdated;
_webGlLoginManager.NetworkChosen += OnNetworkChosen;
_webGlLoginManager.WalletChosen += OnWalletChosen;
}
Expand All @@ -58,8 +58,7 @@ private void OnDisable()
var webGlConnect = WebGLConnect;
if (webGlConnect != null)
{
webGlConnect.OnLoginPanelRequested -= ActivatePanel;
webGlConnect.OnConnect -= HandleConnect;
WebGLConnect.SessionStatusUpdated -= OnSessionStatusUpdated;
}

if (_webGlLoginManager != null)
Expand All @@ -69,15 +68,22 @@ private void OnDisable()
}
}

private void ActivatePanel()
private void OnSessionStatusUpdated(WalletConnectTransitionBase obj)
{
_webGlLoginManager.ShowPanel();
}

private void HandleConnect(WebGLWrapper provider)
{
_webGlLoginManager.HidePanel();
_sceneChooser.SetActive(true);
switch (obj)
{
case TransportConnectedTransition transition:
{
_webGlLoginManager.ShowPanel();
break;
}
case WalletConnectedTransition transition:
{
_webGlLoginManager.HidePanel();
_sceneChooser.SetActive(true);
break;
}
}
}

private void OnNetworkChosen(NetworkName network)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/MirageSDK/Plugins/Nethereum/Nethereum.ABI.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/MirageSDK/Plugins/Nethereum/Nethereum.Hex.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/MirageSDK/Plugins/Nethereum/Nethereum.RLP.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/MirageSDK/Plugins/Nethereum/Nethereum.RPC.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/MirageSDK/Plugins/Nethereum/Nethereum.Util.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/MirageSDK/Plugins/Nethereum/Nethereum.Web3.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using System;
using Cysharp.Threading.Tasks;
using UnityEngine;

namespace MirageSDK.WalletConnect.VersionShared
{
public interface IWalletConnectable
{
string WalletName { get; }
UniTask<string> GetDefaultAccount(string network = null);
event Action<string[]> OnAccountChanged;
string SettingsFilename { get; }
void Initialize(ScriptableObject settings);
UniTask Connect();
UniTask CloseSession(bool connectNewSession = true);
UniTask<string> ReconnectSession();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public interface IWalletConnectCommunicator
UniTask<string> WalletSwitchEthChain(EthChain chainData);
UniTask<string> WalletUpdateEthChain(EthUpdateChainData chainData);
UniTask<BigInteger> EthChainId();
string GetDefaultAccount(string network);

UniTask<TResponse> Send<TRequest, TResponse>(TRequest request)
where TRequest : IIdentifiable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using MirageSDK.WalletConnectSharp.Core.StatusEvents;

namespace MirageSDK.WalletConnectSharp.Core
{
public interface IWalletConnectStatusHolder
{
event Action<WalletConnectTransitionBase> SessionStatusUpdated;
WalletConnectStatus Status { get; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using MirageSDK.WalletConnectSharp.Core.Network;
using Cysharp.Threading.Tasks;

namespace MirageSDK.WalletConnectSharp.Unity.Network
namespace MirageSDK.WalletConnectSharp.Core.Network
{
public class WebGlAESCipher : ICipher
{
Expand All @@ -29,7 +29,7 @@ public UniTask<EncryptedPayload> EncryptWithKey(byte[] key, string message, Enco
cipher.Mode = CipherMode.CBC;
cipher.Padding = PaddingMode.PKCS7;
cipher.KeySize = 256;

var iv = cipher.IV;

using (var cs = new CryptoStream(ms, cipher.CreateEncryptor(key, iv),
Expand All @@ -43,15 +43,15 @@ public UniTask<EncryptedPayload> EncryptWithKey(byte[] key, string message, Enco
using (var hmac = new HMACSHA256(key))
{
hmac.Initialize();

var toSign = new byte[iv.Length + encryptedContent.Length];

//copy our 2 array into one
Buffer.BlockCopy(encryptedContent, 0, toSign, 0,encryptedContent.Length);
Buffer.BlockCopy(iv, 0, toSign, encryptedContent.Length, iv.Length);

var signature = hmac.ComputeHash(toSign);

var ivHex = iv.ToHex();
var dataHex = encryptedContent.ToHex();
var hmacHex = signature.ToHex();
Expand Down Expand Up @@ -83,11 +83,11 @@ public UniTask<string> DecryptWithKey(byte[] key, EncryptedPayload encryptedData
hmac.Initialize();

var toSign = new byte[iv.Length + rawData.Length];

//copy our 2 array into one
Buffer.BlockCopy(rawData, 0, toSign, 0,rawData.Length);
Buffer.BlockCopy(iv, 0, toSign, rawData.Length, iv.Length);

var signature = hmac.ComputeHash(toSign);

if (!signature.SequenceEqual(hmacReceived))
Expand Down Expand Up @@ -118,7 +118,7 @@ public UniTask<string> DecryptWithKey(byte[] key, EncryptedPayload encryptedData
do
{
read = cs.Read(buffer, 0, buffer.Length);

if (read > 0)
{
sink.Write(buffer, 0, read);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using MirageSDK.WalletConnect.VersionShared.Infrastructure;
using MirageSDK.WalletConnectSharp.Core;

namespace MirageSDK.WalletConnectSharp.Unity.Events
namespace MirageSDK.WalletConnectSharp.Core.StatusEvents
{
public class SessionCreatedTransition : WalletConnectTransitionBase
{
public SessionCreatedTransition(IWalletConnectTransitionDataProvider transitionDataProvider, WalletConnectStatus previousStatus, WalletConnectStatus newStatus)
: base(transitionDataProvider, previousStatus, newStatus)
{

}
}
}
Loading

0 comments on commit b60c94f

Please sign in to comment.