diff --git a/Runtime/Scripts/Beacon/Connectors/DotNet/BeaconConnectorDotNet.cs b/Runtime/Scripts/Beacon/Connectors/DotNet/BeaconConnectorDotNet.cs index e3e49ec..78a1071 100644 --- a/Runtime/Scripts/Beacon/Connectors/DotNet/BeaconConnectorDotNet.cs +++ b/Runtime/Scripts/Beacon/Connectors/DotNet/BeaconConnectorDotNet.cs @@ -23,9 +23,9 @@ namespace TezosSDK.Beacon public event Action OperationRequested; - public void ConnectWallet(WalletProviderType? _) + public void ConnectWallet(WalletProviderType? _, bool forcePairing = true) { - _beaconClientManager.InitAsyncAndConnect(); + _beaconClientManager.InitAsyncAndConnect(forcePairing); } public string GetWalletAddress() @@ -38,6 +38,11 @@ namespace TezosSDK.Beacon _beaconClientManager.DisconnectWallet(); } + public void Pair() + { + _beaconClientManager.Pair(); + } + public async void RequestWalletConnection() { Logger.LogDebug("RequestWalletConnection"); @@ -85,4 +90,4 @@ namespace TezosSDK.Beacon } } -} \ No newline at end of file +} diff --git a/Runtime/Scripts/Beacon/Connectors/WebGL/BeaconConnectorWebGl.cs b/Runtime/Scripts/Beacon/Connectors/WebGL/BeaconConnectorWebGl.cs index 73ac7c1..151ec8a 100644 --- a/Runtime/Scripts/Beacon/Connectors/WebGL/BeaconConnectorWebGl.cs +++ b/Runtime/Scripts/Beacon/Connectors/WebGL/BeaconConnectorWebGl.cs @@ -19,7 +19,7 @@ namespace TezosSDK.Beacon public event Action OperationRequested; - public void ConnectWallet(WalletProviderType? walletProviderType) + public void ConnectWallet(WalletProviderType? walletProviderType, bool forcePairing = true) { if (walletProviderType == null) { @@ -31,6 +31,14 @@ namespace TezosSDK.Beacon walletProviderType.ToString(), TezosManager.Instance.DAppMetadata.Name, TezosManager.Instance.DAppMetadata.Url, TezosManager.Instance.DAppMetadata.Icon); + if (forcePairing) + { + JsConnectAccount(); + } + } + + public void Pair() + { JsConnectAccount(); } diff --git a/Runtime/Scripts/Beacon/Interfaces/IBeaconConnector.cs b/Runtime/Scripts/Beacon/Interfaces/IBeaconConnector.cs index 9d1eacc..79bdd9a 100644 --- a/Runtime/Scripts/Beacon/Interfaces/IBeaconConnector.cs +++ b/Runtime/Scripts/Beacon/Interfaces/IBeaconConnector.cs @@ -21,7 +21,7 @@ namespace TezosSDK.Beacon /// Starts the connection between Beacon SDK and a wallet to connect to /// an account /// - void ConnectWallet(WalletProviderType? walletProviderType); + void ConnectWallet(WalletProviderType? walletProviderType, bool forcePairing = true); /// /// Checks if there is an active account paired. @@ -65,6 +65,12 @@ namespace TezosSDK.Beacon /// Removes the connection to the current active account. /// void DisconnectWallet(); + + + /// + /// Manually initialize Pairing + /// + void Pair(); } -} \ No newline at end of file +} diff --git a/Runtime/Scripts/Beacon/Managers/BeaconClientManager.cs b/Runtime/Scripts/Beacon/Managers/BeaconClientManager.cs index 4a00901..98f1eb3 100644 --- a/Runtime/Scripts/Beacon/Managers/BeaconClientManager.cs +++ b/Runtime/Scripts/Beacon/Managers/BeaconClientManager.cs @@ -46,7 +46,7 @@ namespace TezosSDK.Beacon _activeWallet = wallet; // Set active wallet } - public async void InitAsyncAndConnect() + public async void InitAsyncAndConnect(bool forcePairing = true) { try { @@ -70,7 +70,7 @@ namespace TezosSDK.Beacon { _eventDispatcher.DispatchWalletConnectedEvent(BeaconDappClient); } - else + else if(forcePairing) { var pairingRequestInfo = BeaconDappClient.GetPairingRequestInfo(); _eventDispatcher.DispatchHandshakeEvent(pairingRequestInfo); @@ -82,6 +82,15 @@ namespace TezosSDK.Beacon } } + public void Pair() { + if(!HasExistingConnection()) { + Logger.LogError("No exisiting connection, Initialize first"); + } + + var pairingRequestInfo = BeaconDappClient.GetPairingRequestInfo(); + _eventDispatcher.DispatchHandshakeEvent(pairingRequestInfo); + } + /// /// Checks if there is an existing connection with a wallet. /// @@ -341,4 +350,4 @@ namespace TezosSDK.Beacon } } -} \ No newline at end of file +} diff --git a/Runtime/Scripts/Tezos/Interfaces/Wallet/IWalletProvider.cs b/Runtime/Scripts/Tezos/Interfaces/Wallet/IWalletProvider.cs index f1be53c..f0c7ddd 100644 --- a/Runtime/Scripts/Tezos/Interfaces/Wallet/IWalletProvider.cs +++ b/Runtime/Scripts/Tezos/Interfaces/Wallet/IWalletProvider.cs @@ -18,7 +18,7 @@ namespace TezosSDK.Tezos.Wallet /// /// Makes a call to connect with a wallet /// - void Connect(WalletProviderType walletProvider); + void Connect(WalletProviderType walletProvider, bool forcePairing = true); /// /// Unpair with wallet and disconnect @@ -31,6 +31,9 @@ namespace TezosSDK.Tezos.Wallet /// string GetWalletAddress(); + + void Pair(); + /// /// Sends a request to the sign a payload string /// @@ -62,4 +65,4 @@ namespace TezosSDK.Tezos.Wallet void OriginateContract(string script, string delegateAddress = null); } -} \ No newline at end of file +} diff --git a/Runtime/Scripts/Tezos/Wallet/WalletProvider.cs b/Runtime/Scripts/Tezos/Wallet/WalletProvider.cs index 521adfc..7230c62 100644 --- a/Runtime/Scripts/Tezos/Wallet/WalletProvider.cs +++ b/Runtime/Scripts/Tezos/Wallet/WalletProvider.cs @@ -43,9 +43,9 @@ namespace TezosSDK.Tezos.Wallet public IWalletEventManager EventManager { get; } - public void Connect(WalletProviderType walletProvider) + public void Connect(WalletProviderType walletProvider, bool forcePairing = true) { - _beaconConnector.ConnectWallet(walletProvider); + _beaconConnector.ConnectWallet(walletProvider, forcePairing); } public void Disconnect() @@ -58,6 +58,11 @@ namespace TezosSDK.Tezos.Wallet return _beaconConnector.GetWalletAddress(); } + public void Pair() + { + _beaconConnector.Pair(); + } + public void RequestSignPayload(SignPayloadType signingType, string payload) { _beaconConnector.RequestSignPayload(signingType, payload);