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

Closing beacon.db connections before app exit; #104

Merged
merged 1 commit into from
Jul 6, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
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]
### Fixed
- [Bug](https://github.com/trilitech/tezos-unity-sdk/issues/103) with closing Beacon database connections before app exit


## [1.5.1] - 2023-06-27
### Fixed
Expand Down
9 changes: 7 additions & 2 deletions Runtime/Scripts/Beacon/BeaconConnectorDotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace TezosSDK.Beacon
{
public class BeaconConnectorDotNet : IBeaconConnector
public class BeaconConnectorDotNet : IBeaconConnector, IDisposable
{
private static WalletMessageReceiver _walletMessageReceiver;
private DappBeaconClient BeaconDappClient { get; set; }
Expand Down Expand Up @@ -269,9 +269,14 @@ private async void OnBeaconDappClientMessageReceived(object sender, BeaconMessag
}

#endregion

public void Dispose()
{
BeaconDappClient.Disconnect();
}
}

// todo: this logger didn't work inside Beacon, improve this.
// todo: this logger didn't work inside Beacon, improve this.
public class MyLoggerProvider : ILoggerProvider
{
public class MyLogger : ILogger
Expand Down
8 changes: 8 additions & 0 deletions Runtime/Scripts/Tezos/TezosSingleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ protected override void Awake()
TezosConfig.Instance.Network = NetworkType.ghostnet;
_tezos = new Tezos();
}

void OnApplicationQuit()
{
if (Wallet is IDisposable disposable)
{
disposable.Dispose();
}
}

public IEnumerator GetCurrentWalletBalance(Action<ulong> callback)
{
Expand Down
13 changes: 11 additions & 2 deletions Runtime/Scripts/Tezos/Wallet/WalletProvider.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System.Text.Json;
using System;
using System.Text.Json;
using Beacon.Sdk.Beacon.Sign;
using TezosSDK.Beacon;
using TezosSDK.Helpers;
using UnityEngine;

namespace TezosSDK.Tezos.Wallet
{
public class WalletProvider : IWalletProvider
public class WalletProvider : IWalletProvider, IDisposable
{
public WalletMessageReceiver MessageReceiver { get; private set; }
private IBeaconConnector _beaconConnector;
Expand Down Expand Up @@ -119,5 +120,13 @@ public void CallContract(
networkName: TezosConfig.Instance.Network.ToString(),
networkRPC: TezosConfig.Instance.RpcBaseUrl);
}

public void Dispose()
{
if (_beaconConnector is IDisposable disposable)
{
disposable.Dispose();
}
}
}
}