Skip to content
Merged
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public override async Task<string> Connect()

var providerTask = _config.ProviderTask;

if (!_config.AutoLogin && providerTask != null && !providerTask.IsCompleted)
if (!_config.AutoLogin && providerTask != null)
{
var provider = await _config.ProviderTask;
var provider = await providerTask;

_coreInstance.login(new LoginParams
{
Expand Down
42 changes: 42 additions & 0 deletions Packages/io.chainsafe.web3-unity/Editor/ReadWriteProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.IO;
using System.Linq;
using ChainSafe.Gaming.UnityPackage.Connection;
using UnityEditor;
using UnityEngine;

namespace ChainSafe.GamingSdk.Editor
{
/// <summary>
/// Make connection providers read-write by moving it from packages into Assets/Resources.
/// </summary>
[InitializeOnLoad]
public class ReadWriteProvider
Comment thread
rob1997 marked this conversation as resolved.
{
static ReadWriteProvider()
{
TryMovingConnectionProviders();
}

private static void TryMovingConnectionProviders()
{
var providers = Resources.LoadAll<ConnectionProvider>(string.Empty)
.Where(p => AssetDatabase.GetAssetPath(p).Contains("io.chainsafe.web3-unity"));

foreach (var provider in providers)
{
string source = AssetDatabase.GetAssetPath(provider);

string directory = Path.Combine(Application.dataPath, nameof(Resources));

string destination = Path.Combine(directory, Path.GetFileName(source));

if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}

File.Move(source, destination);
}
}
}
}

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

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ MonoBehaviour:
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1272c3d1812e95e408d945d25da049bb, type: 3}
m_Name: HyperPlayConnectionProviderConfig
m_Script: {fileID: 11500000, guid: 73b5e9380c5275043b3558f49f807100, type: 3}
m_Name: HyperPlayConnectionProvider
m_EditorClassIdentifier:
<Name>k__BackingField: HyperPlay
<ProviderRow>k__BackingField: {fileID: 1727169539746137890, guid: 71b112e16f898d140935553a4b33ae1f, type: 3}
<ConnectButtonRow>k__BackingField: {fileID: 8599114313589093787, guid: 71b112e16f898d140935553a4b33ae1f, type: 3}
<RememberSession>k__BackingField: 1

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 @@ -9,8 +9,8 @@ MonoBehaviour:
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1272c3d1812e95e408d945d25da049bb, type: 3}
m_Name: MetamaskConnectionProviderConfig
m_Script: {fileID: 11500000, guid: 1b64d00084d2c544aa644a8a6010964d, type: 3}
m_Name: MetamaskConnectionProvider
m_EditorClassIdentifier:
<Name>k__BackingField: MetaMask
<ProviderRow>k__BackingField: {fileID: 4276990323382053958, guid: 1200437cb83a29c4fb63faa44cf63f0d, type: 3}
<Name>k__BackingField: Metamask
<ConnectButtonRow>k__BackingField: {fileID: 8599114313589093787, guid: 1200437cb83a29c4fb63faa44cf63f0d, type: 3}

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
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 582efc0fde77aab43a77ee4237ba305a, type: 3}
m_Name: WalletConnectConnectionProvider
m_EditorClassIdentifier:
<Name>k__BackingField: WalletConnect
<ConnectButtonRow>k__BackingField: {fileID: 8599114313589093787, guid: 4591cfadb2bf9824da90ebf4005728a8, type: 3}
<RememberSession>k__BackingField: 1
walletConnectConfig: {fileID: 11400000, guid: fde7db0e37b4a884da1149e9f1999093, type: 2}

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
@@ -0,0 +1,35 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6b435f36106e244449abb70cf6f41008, type: 3}
m_Name: Web3AuthConnectionProvider
m_EditorClassIdentifier:
<Name>k__BackingField: Web3Auth
<ConnectButtonRow>k__BackingField: {fileID: 8599114313589093787, guid: 163bbaaeb51883442a20ea7532888a43, type: 3}
<RememberSession>k__BackingField: 1
clientId: BDoIQpmwh4ow7oDMshLsPTj0JHGnS-0ZsB14fMzZ6CnxB0kMJf4o3oWvFWiISuL_p7PzyGx4v7iGHDQQF4lNL-s
redirectUri: torusapp://io.chainsafe.gamingsdk.sdkdemoscene/auth
network: 1
modalPrefab: {fileID: 1060439634540712661, guid: 42c53f26848d1d54a9ffe18fae333758, type: 3}
enableWalletGui: 1
web3AuthWalletGUIPrefab: {fileID: 7656622686525558909, guid: b394e6c49b9bd734089cea0293265bd3, type: 3}
walletGuiConfig:
DisplayWalletIcon: 1
AutoPopUpWalletOnTx: 1
AutoConfirmTransactions: 0
WalletIcon: {fileID: 21300000, guid: 55a46a48cd53d834f99fda690cfea4b1, type: 3}
WalletLogo: {fileID: 21300000, guid: ab400fd9b39316240b30631965553264, type: 3}
DisplayFont: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
PrimaryBackgroundColour: {r: 0, g: 0, b: 0, a: 0.7254902}
MenuBackgroundColour: {r: 0, g: 0, b: 0, a: 1}
PrimaryTextColour: {r: 1, g: 1, b: 1, a: 1}
SecondaryTextColour: {r: 0.42745098, g: 0.85882354, b: 0.29411766, a: 1}
BorderButtonColour: {r: 1, g: 1, b: 1, a: 1}

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 @@ -346,10 +346,10 @@ MonoBehaviour:
m_EditorClassIdentifier:
gelatoApiKey: 7MFQqyGS1Iui_e_MgmFW1BfbFeJ06g8nnL2oUTlIJug_
providers:
- {fileID: 11400000, guid: a15bdaf25319d6f44b48ff2159e4b7fb, type: 2}
- {fileID: 11400000, guid: 5a662f0c96c53db48b29a3aa7ab0f102, type: 2}
- {fileID: 11400000, guid: 70ad5245d5b5895448ba4fd9ad57ea95, type: 2}
- {fileID: 11400000, guid: f891ba0f7fed9084982e95c96826fcb7, type: 2}
- {fileID: 11400000, guid: 835338196b5038d4b9351fadba9dac38, type: 2}
- {fileID: 11400000, guid: e5b50e2ca9fe0504daf70376bceb84ac, type: 2}
- {fileID: 11400000, guid: 0d7bd7ae4b3e79d489bbc54514343f5c, type: 2}
- {fileID: 11400000, guid: e56cb66917f860e489d3ed4480b4681c, type: 2}
--- !u!114 &1658652865
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class ConnectToWallet : MonoBehaviour
private ConnectionHandler _connectionHandler;
private ConnectModal _connectModal;

private bool _connected;

private void Awake()
{
_connectionHandler = GetComponent<ConnectionHandler>();
Expand All @@ -24,23 +26,28 @@ private void Awake()
private async void Start()
{
await _connectionHandler.Initialize();

if (connectOnInitialize)
{
var web3 = await _connectionHandler.Restore();

if (web3 != null)
try
{
if (connectOnInitialize)
{
return;
var web3 = await _connectionHandler.Restore();

_connected = web3 != null;
}
}
finally
{
if (!_connected)
{
_connectModal = Instantiate(connectModalPrefab);

_connectModal = Instantiate(connectModalPrefab);

_connectModal.Initialize(_connectionHandler);
_connectModal.Initialize(_connectionHandler);

connectButton.onClick.AddListener(_connectModal.Show);
connectButton.onClick.AddListener(_connectModal.Show);

connectButton.interactable = true;
connectButton.interactable = true;
}
}
}
}