Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added persistent auth on WebGL platform; Updated npm beacon-sdk and k… #130

Merged
merged 1 commit into from
Oct 16, 2023
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
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [unreleased]
## [2.0.6]
### Changed
- Disabled Kukai Embed silent signing
- Updated Kukai Embed to `0.8.9`
- Disabled `Kukai Embed` silent signing
- Updated `Kukai Embed` to `0.8.9`
- Updated `@airgap/beacon-sdk` to `4.0.12`

### Added
- Persistent auth on WebGL platform


## [2.0.5] - 2023-08-12
Expand Down Expand Up @@ -158,7 +162,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added auto releases with GH actions


[unreleased]: https://github.com/trilitech/tezos-unity-sdk/compare/2.0.5...HEAD
[unreleased]: https://github.com/trilitech/tezos-unity-sdk/compare/2.0.6...HEAD
[2.0.6]: https://github.com/trilitech/tezos-unity-sdk/releases/tag/2.0.6
[2.0.5]: https://github.com/trilitech/tezos-unity-sdk/releases/tag/2.0.5
[2.0.4]: https://github.com/trilitech/tezos-unity-sdk/releases/tag/2.0.4
[2.0.3]: https://github.com/trilitech/tezos-unity-sdk/releases/tag/2.0.3
Expand Down
4 changes: 4 additions & 0 deletions Runtime/Scripts/Beacon/BeaconConnection.jslib
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ mergeInto(LibraryManager.library, {
UTF8ToString(delegateAddress)
);
},

JsUnityReadyEvent: function () {
UnityReadyEvent();
}
});
4 changes: 4 additions & 0 deletions Runtime/Scripts/Beacon/BeaconConnectorDotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ private async void OnBeaconDappClientMessageReceived(object sender, BeaconMessag
}
}
}

public void OnReady()
{
}

#endregion

Expand Down
10 changes: 9 additions & 1 deletion Runtime/Scripts/Beacon/BeaconConnectorWebGl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,24 @@ public class BeaconConnectorWebGl : IBeaconConnector

[DllImport("__Internal")]
private static extern string JsRequestContractOrigination(string script, string delegateAddress);

[DllImport("__Internal")]
private static extern string JsUnityReadyEvent();

#endregion

private string _activeAccountAddress;

public void InitWalletProvider(string network, string rpc, WalletProviderType walletProviderType)
{
JsInitWallet(network, rpc, walletProviderType.ToString());
}

public void OnReady()
{
JsUnityReadyEvent();
}

public void ConnectAccount()
{
JsConnectAccount();
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Scripts/Beacon/IBeaconConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public interface IBeaconConnector
/// <param name="rpc">Uri of an specific RPC.</param>
/// <param name="walletProviderType">Type of wallet, e.g. "beacon" or "kukai"</param>
void InitWalletProvider(string network, string rpc, WalletProviderType walletProviderType);

/// <summary>
/// Callback that needed in WebGL to determine that UI is rendered
/// </summary>
void OnReady();

/// <summary>
/// Starts the connection between Beacon SDK and a wallet to connect to
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Scripts/Tezos/Wallet/IWalletProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ public interface IWalletProvider
/// Exposes a MonoBehaviour class that exposes wallet events
/// </summary>
WalletMessageReceiver MessageReceiver { get; }

/// <summary>
/// Callback that needed in WebGL to determine that UI is rendered
/// </summary>
void OnReady();

/// <summary>
/// Makes a call to connect with a wallet
Expand Down
6 changes: 6 additions & 0 deletions Runtime/Scripts/Tezos/Wallet/WalletProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@ private IEnumerator OnOpenWallet(bool withRedirectToWallet)
#endif
}

public void OnReady()
{
_beaconConnector.OnReady();
}

public void Connect(WalletProviderType walletProvider, bool withRedirectToWallet)
{

_beaconConnector.InitWalletProvider(
network: TezosConfig.Instance.Network.ToString(),
rpc: TezosConfig.Instance.RpcBaseUrl,
Expand Down
5 changes: 5 additions & 0 deletions Samples~/Scripts/DemoExample/Core/ExampleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,5 +471,10 @@ public void GetOriginatedContracts(Action<IEnumerable<TokenContract>> callback)
var routine = Tezos.GetOriginatedContracts(callback);
CoroutineRunner.Instance.StartWrappedCoroutine(routine);
}

public void OnReady()
{
Tezos.Wallet.OnReady();
}
}
}
7 changes: 6 additions & 1 deletion Samples~/Scripts/DemoExample/Core/IExampleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace TezosSDK.Samples.DemoExample
{
public interface IExampleManager
{
ITezos Tezos { get; }
ITezos Tezos { get; }

public void Init(Action<bool> callback = null);
public void Unpair();
Expand Down Expand Up @@ -139,5 +139,10 @@ public interface IExampleManager
/// </summary>
/// <param name="callback">callback that takes the retrieved contracts(IEnumerable)</param>
void GetOriginatedContracts(Action<IEnumerable<TokenContract>> callback);

/// <summary>
/// Callback that needed in WebGL to determine that UI is rendered
/// </summary>
void OnReady();
}
}
11 changes: 8 additions & 3 deletions Samples~/Scripts/DemoExample/UI/RegisterPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ private IEnumerator Start()
// make QR code available for Standalone
_qrImage.gameObject.SetActive(true);
#elif (UNITY_IOS || UNITY_ANDROID)
SetButtonState(_deepLinkPair, true, true);
SetButtonState(_deepLinkPair, true, true);
#elif UNITY_WEBGL
SetButtonState(_deepLinkPair, true, true);
SetButtonState(_socialLoginButton, true, true);
ExampleFactory
.Instance
.GetExampleManager()
.OnReady();

SetButtonState(_deepLinkPair, true, true);
SetButtonState(_socialLoginButton, true, true);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion WebGLFrontend/output/StreamingAssets/webgl-frontend.js

Large diffs are not rendered by default.

Binary file modified WebGLFrontend/output/WebGLCopyAndPaste.unitypackage
Binary file not shown.
Loading
Loading