diff --git a/haechi.face.unity.sdk/Samples/Prefabs/UI/Sections/Sections/Section - Connect Network Dev.prefab b/haechi.face.unity.sdk/Samples/Prefabs/UI/Sections/Sections/Section - Connect Network Dev.prefab index 50606fe..e86e749 100644 --- a/haechi.face.unity.sdk/Samples/Prefabs/UI/Sections/Sections/Section - Connect Network Dev.prefab +++ b/haechi.face.unity.sdk/Samples/Prefabs/UI/Sections/Sections/Section - Connect Network Dev.prefab @@ -203,7 +203,6 @@ MonoBehaviour: _multiStageIdInputField: {fileID: 8988222448735028466} _connectButton: {fileID: 5272876550459924592} _changeProfile: {fileID: 11400000, guid: 0985badaa4749434d96e1512b77a927f, type: 2} - _changeBlockchain: {fileID: 11400000, guid: 211a2dc0a77074be7bbb1749a9b4e0fb, type: 2} _changeApiKey: {fileID: 11400000, guid: b7a612418ad00416b82369dfcf8db4b9, type: 2} _changePrivateKey: {fileID: 11400000, guid: 2454854534ea54a4092188f8c25951bf, type: 2} _changeMultiStageId: {fileID: 11400000, guid: 3e53cf0a30d6419bc980bb1a161feb86, type: 2} diff --git a/haechi.face.unity.sdk/Samples/Prefabs/UI/Sections/Sections/Section - Connect Network.prefab b/haechi.face.unity.sdk/Samples/Prefabs/UI/Sections/Sections/Section - Connect Network.prefab index d79441b..eed7bac 100644 --- a/haechi.face.unity.sdk/Samples/Prefabs/UI/Sections/Sections/Section - Connect Network.prefab +++ b/haechi.face.unity.sdk/Samples/Prefabs/UI/Sections/Sections/Section - Connect Network.prefab @@ -198,7 +198,6 @@ MonoBehaviour: _appState: {fileID: 11400000, guid: 4a78ec3eec3af4eef88d48276d7101b3, type: 2} _blockchainDropdown: {fileID: 4143877699697646035} _connectButton: {fileID: 5272876550459924592} - _changeBlockchain: {fileID: 11400000, guid: 211a2dc0a77074be7bbb1749a9b4e0fb, type: 2} _connect: {fileID: 11400000, guid: 826bf1e20101c4d85b5c3baed398f84f, type: 2} _switchNetwork: {fileID: 11400000, guid: 2958cd5861edd45fabe41e2762944269, type: 2} _onLogoutEvent: {fileID: 11400000, guid: 10cbde83a4f2b4cb182add5690db5406, type: 2} diff --git a/haechi.face.unity.sdk/Samples/Script/FaceWalletManager.cs b/haechi.face.unity.sdk/Samples/Script/FaceWalletManager.cs index 0971172..ee2248e 100644 --- a/haechi.face.unity.sdk/Samples/Script/FaceWalletManager.cs +++ b/haechi.face.unity.sdk/Samples/Script/FaceWalletManager.cs @@ -24,6 +24,10 @@ public class FaceWalletManager : MonoBehaviour private ActionQueue _actionQueue; [SerializeField] private ReadOnlyAppState _appState; + public AppStateSO appStateSO { + get { return this._appState as AppStateSO; } + set { this._appState = value; } + } [Header("Listening on")] /** Connect & Login */ diff --git a/haechi.face.unity.sdk/Samples/Script/ScriptableObjects/AppStateSO.cs b/haechi.face.unity.sdk/Samples/Script/ScriptableObjects/AppStateSO.cs index 7e50832..0319154 100644 --- a/haechi.face.unity.sdk/Samples/Script/ScriptableObjects/AppStateSO.cs +++ b/haechi.face.unity.sdk/Samples/Script/ScriptableObjects/AppStateSO.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using haechi.face.unity.sdk.Runtime.Type; using UnityEngine; @@ -41,8 +42,8 @@ public class AppStateSO : ReadOnlyAppState [Tooltip("All blockchains that can be seen in the Connect page")] [SerializeField] private List _blockchains; - [Tooltip("Current selected blockchain")] - [SerializeField] private Blockchain _currentBlockchain; + [Tooltip("Current selected network")] + [SerializeField] private BlockchainNetwork _currentNetwork; [SerializeField] private string _apiKey; [SerializeField] private string _privateKey; @@ -55,7 +56,6 @@ public class AppStateSO : ReadOnlyAppState [Header("Listening on")] [SerializeField] private StringEventChannelSO _onProfileChange; - [SerializeField] private StringEventChannelSO _onBlockchainChange; [SerializeField] private StringEventChannelSO _onApiKeyChange; [SerializeField] private StringEventChannelSO _onPrivateKeyChange; [SerializeField] private StringEventChannelSO _onMultiStageIdChange; @@ -76,7 +76,6 @@ private void OnEnable() { Debug.Log("OnEnable"); this._onProfileChange.OnEventRaised += this.SetCurrentProfile; - this._onBlockchainChange.OnEventRaised += this.SetCurrentBlockchain; this._onApiKeyChange.OnEventRaised += this.SetCurrentApiKey; this._onPrivateKeyChange.OnEventRaised += this.SetCurrentPrivateKey; this._onMultiStageIdChange.OnEventRaised += this.SetCurrentMultiStageId; @@ -91,7 +90,6 @@ private void OnEnable() private void OnDisable() { this._onProfileChange.OnEventRaised -= this.SetCurrentProfile; - this._onBlockchainChange.OnEventRaised -= this.SetCurrentBlockchain; this._onApiKeyChange.OnEventRaised -= this.SetCurrentApiKey; this._onPrivateKeyChange.OnEventRaised -= this.SetCurrentPrivateKey; this._onMultiStageIdChange.OnEventRaised -= this.SetCurrentMultiStageId; @@ -109,10 +107,9 @@ private void SetCurrentProfile(string env) this._profileUpdated.RaiseEvent(); } - private void SetCurrentBlockchain(string blockchain) + public void SetCurrentNetwork(BlockchainNetwork network) { - this._currentBlockchain = Blockchains.ValueOf(blockchain); - this._blockchainUpdated.RaiseEvent(); + this._currentNetwork = network; } private void SetCurrentApiKey(string value) @@ -220,12 +217,12 @@ public override Profile GetEnv() public override Blockchain GetBlockchain() { - return this._currentBlockchain; + return BlockchainNetworks.Properties[this._currentNetwork].Blockchain; } public override BlockchainNetwork GetBlockchainNetwork() { - return BlockchainNetworks.GetNetwork(this._currentBlockchain, this._currentProfile); + return this._currentNetwork; } public override string GetScheme() diff --git a/haechi.face.unity.sdk/Samples/Script/UI/Sections/UISectionConnectNetwork.cs b/haechi.face.unity.sdk/Samples/Script/UI/Sections/UISectionConnectNetwork.cs index a985eb2..f8f90b3 100644 --- a/haechi.face.unity.sdk/Samples/Script/UI/Sections/UISectionConnectNetwork.cs +++ b/haechi.face.unity.sdk/Samples/Script/UI/Sections/UISectionConnectNetwork.cs @@ -1,4 +1,6 @@ using System; +using haechi.face.unity.sdk.Runtime.Type; +using NBitcoin; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -12,7 +14,6 @@ public class UISectionConnectNetwork : MonoBehaviour [SerializeField] private UIButton _connectButton; [Header("Broadcast to")] - [SerializeField] private StringEventChannelSO _changeBlockchain; [SerializeField] private VoidEventChannelSO _connect; [SerializeField] private VoidEventChannelSO _switchNetwork; @@ -41,14 +42,14 @@ private void Start() private void Initialize() { - this._appState.GetAllBlockchains().ForEach( - b => this._blockchainDropdown.options.Add(new TMP_Dropdown.OptionData(b.ToString()))); + BlockchainNetworks.GetAllNetworks().ForEach(n => this._blockchainDropdown.options.Add(new TMP_Dropdown.OptionData(n.ToString()))); this._blockchainDropdown.captionText.text = this._blockchainDropdown.options[0].text; } private void OnBlockchainChanges(int dropdownIndex) { - this._changeBlockchain.RaiseEvent(this._blockchainDropdown.options[dropdownIndex].text); + BlockchainNetwork blockchainNetwork = BlockchainNetworks.ValueOf(this._blockchainDropdown.options[dropdownIndex].text); + this._appState.SetCurrentNetwork(blockchainNetwork); } private void ConnectOrSwitchNetwork() diff --git a/haechi.face.unity.sdk/Samples/Script/UI/Sections/UISectionDevConnectNetwork.cs b/haechi.face.unity.sdk/Samples/Script/UI/Sections/UISectionDevConnectNetwork.cs index 33c80c1..38357b7 100644 --- a/haechi.face.unity.sdk/Samples/Script/UI/Sections/UISectionDevConnectNetwork.cs +++ b/haechi.face.unity.sdk/Samples/Script/UI/Sections/UISectionDevConnectNetwork.cs @@ -1,4 +1,5 @@ using System; +using haechi.face.unity.sdk.Runtime.Type; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -17,7 +18,6 @@ public class UISectionDevConnectNetwork : MonoBehaviour [Header("Broadcast to")] [SerializeField] private StringEventChannelSO _changeProfile; - [SerializeField] private StringEventChannelSO _changeBlockchain; [SerializeField] private StringEventChannelSO _changeApiKey; [SerializeField] private StringEventChannelSO _changePrivateKey; [SerializeField] private StringEventChannelSO _changeMultiStageId; @@ -57,8 +57,7 @@ private void Initialize() e => this._envDropdown.options.Add(new TMP_Dropdown.OptionData(e))); this._envDropdown.captionText.text = this._envDropdown.options[0].text; - this._appState.GetAllBlockchains().ForEach( - b => this._blockchainDropdown.options.Add(new TMP_Dropdown.OptionData(b.ToString()))); + BlockchainNetworks.GetAllNetworks().ForEach(n => this._blockchainDropdown.options.Add(new TMP_Dropdown.OptionData(n.ToString()))); this._blockchainDropdown.captionText.text = this._blockchainDropdown.options[0].text; this._apiKeyInputField.text = this._appState.GetSampleApiKey(); @@ -74,7 +73,7 @@ private void OnEnvChanges(int dropdownIndex) private void OnBlockchainChanges(int dropdownIndex) { - this._changeBlockchain.RaiseEvent(this._blockchainDropdown.options[dropdownIndex].text); + this._appState.SetCurrentNetwork(BlockchainNetworks.ValueOf(this._blockchainDropdown.options[dropdownIndex].text)); } private void OnApiKeyChanges(string value) diff --git a/haechi.face.unity.sdk/Samples/ScriptableObjects/AppState/AppState.asset b/haechi.face.unity.sdk/Samples/ScriptableObjects/AppState/AppState.asset index 084bc36..edbed35 100644 --- a/haechi.face.unity.sdk/Samples/ScriptableObjects/AppState/AppState.asset +++ b/haechi.face.unity.sdk/Samples/ScriptableObjects/AppState/AppState.asset @@ -34,7 +34,6 @@ MonoBehaviour: _multiStageId: _erc20Balance: _onProfileChange: {fileID: 11400000, guid: 0985badaa4749434d96e1512b77a927f, type: 2} - _onBlockchainChange: {fileID: 11400000, guid: 211a2dc0a77074be7bbb1749a9b4e0fb, type: 2} _onApiKeyChange: {fileID: 11400000, guid: b7a612418ad00416b82369dfcf8db4b9, type: 2} _onPrivateKeyChange: {fileID: 11400000, guid: 2454854534ea54a4092188f8c25951bf, type: 2} _onMultiStageIdChange: {fileID: 11400000, guid: 3e53cf0a30d6419bc980bb1a161feb86, type: 2} diff --git a/haechi.face.unity.sdk/Samples/ScriptableObjects/AppState/AppState_Dev.asset b/haechi.face.unity.sdk/Samples/ScriptableObjects/AppState/AppState_Dev.asset index 32ebcea..465d81e 100644 --- a/haechi.face.unity.sdk/Samples/ScriptableObjects/AppState/AppState_Dev.asset +++ b/haechi.face.unity.sdk/Samples/ScriptableObjects/AppState/AppState_Dev.asset @@ -34,7 +34,6 @@ MonoBehaviour: _multiStageId: _erc20Balance: _onProfileChange: {fileID: 11400000, guid: 0985badaa4749434d96e1512b77a927f, type: 2} - _onBlockchainChange: {fileID: 11400000, guid: 211a2dc0a77074be7bbb1749a9b4e0fb, type: 2} _onApiKeyChange: {fileID: 11400000, guid: b7a612418ad00416b82369dfcf8db4b9, type: 2} _onPrivateKeyChange: {fileID: 11400000, guid: 2454854534ea54a4092188f8c25951bf, type: 2} _onMultiStageIdChange: {fileID: 11400000, guid: 3e53cf0a30d6419bc980bb1a161feb86, type: 2}