Skip to content

Commit

Permalink
Merge pull request #12 from MrVeit/dev
Browse files Browse the repository at this point in the history
Release 0.2.9.6
  • Loading branch information
MrVeit authored Nov 21, 2024
2 parents a5d132c + f4969f4 commit 1be7bea
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 488 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ Resources.meta
*.meta
/TextMesh Pro
/Ton Connect
README.MD.meta
LICENSE.MIT.meta
7 changes: 0 additions & 7 deletions LICENSE.MIT.meta

This file was deleted.

7 changes: 0 additions & 7 deletions README.MD.meta

This file was deleted.

12 changes: 8 additions & 4 deletions Uniton Connect/Runtime/Core/Bridges/TonConnectBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ private static void OnWalletConnect(string walletInfo)
return;
}

OnWalletSuccessfullyConnected?.Invoke(walletConfig);

UnitonConnectLogger.Log($"Wallet successfully connected, " +
UnitonConnectLogger.Log($"Wallet successfully connected, " +
$"address: {WalletConnectUtils.GetNonBounceableAddress(walletConfig.Address)}");

OnWalletSuccessfullyConnected?.Invoke(walletConfig);
}

[MonoPInvokeCallback(typeof(Action<string>))]
Expand Down Expand Up @@ -254,15 +254,19 @@ internal static void UnSubscribe()
}

internal static void Init(string manifestUrl,
Action<bool> sdkInitialized, Action<bool> connectionRestored)
Action<bool> sdkInitialized, Action<NewWalletConfig> walletConnectionDetected,
Action<string> walletConnectionDetectFailed, Action<bool> connectionRestored)
{
OnInitialized = sdkInitialized;
OnWalletConnectionRestored = connectionRestored;
OnWalletSuccessfullyConnected = walletConnectionDetected;
OnWalletConnectFailed = walletConnectionDetectFailed;

Init(manifestUrl, OnInitialize);
InitTonWeb();

SubscribeToRestoreConnection(OnWalletConnectionRestore);
SubscribeToStatusChange(OnWalletConnect);
}

internal static void Connect(
Expand Down
34 changes: 18 additions & 16 deletions Uniton Connect/Runtime/Core/UnitonConnectSDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ public void Initialize()
if (IsSupporedPlatform())
{
TonConnectBridge.Init(dAppManifestLink,
OnInitialize, OnWalletConnectionRestore);
OnInitialize, OnNativeWalletConnectionFinish,
OnNativeWalletConnectionFail, OnWalletConnectionRestore);
}

OnInitialize();
Expand Down Expand Up @@ -655,7 +656,7 @@ private async void RestoreConnectionAsync(RemoteStorage storage)
return;
}

OnWalletConnectionRestore(isSuccess);
OnWalletConnectionRestore(isSuccess, new WalletConfig());
}

private IEnumerator ConfirmTransactionFromBlockchain(string transactionHash)
Expand Down Expand Up @@ -886,7 +887,7 @@ private void ResetConnectionStorage(RemoteStorage storage)
ProjectStorageConsts.DeleteConnectionKey(keyConnection);
ProjectStorageConsts.DeleteConnectionKey(lastEventId);

OnWalletConnectionRestore(false);
OnWalletConnectionRestore(false, new WalletConfig());
}

private void OpenWalletViaDeepLink(string deepLinkURL)
Expand Down Expand Up @@ -985,8 +986,6 @@ private void OnWalletConnectionFinish(Wallet wallet)
" the storage of the previous session has been cleaned up");
}

_isWalletConnected = true;

_isWalletConnected = _tonConnect.IsConnected;

Wallet = new UserWallet(wallet.Account.Address.ToString(), null);
Expand All @@ -996,23 +995,24 @@ private void OnWalletConnectionFinish(Wallet wallet)

private void OnNativeWalletConnectionFinish(NewWalletConfig walletConfig)
{
if (!IsWalletConnected)
{
OnNativeWalletDisconnect(true);

UnitonConnectLogger.Log("Connection to the wallet has been successfully disconnected," +
" the storage of the previous session has been cleaned up");
}

_isWalletConnected = true;

_connectedWalletConfig = walletConfig;

var nonBouceableAddress = WalletConnectUtils.GetNonBounceableAddress(walletConfig.Address);
var nonBouceableAddress = WalletConnectUtils
.GetNonBounceableAddress(walletConfig.Address);

var updatedConfig = new NewWalletConfig()
{
Address = nonBouceableAddress,
Chain = walletConfig.Chain,
PublicKey = walletConfig.PublicKey,
StateInit = walletConfig.StateInit,
};

Wallet = new UserWallet(nonBouceableAddress, walletConfig);
Wallet = new UserWallet(nonBouceableAddress, updatedConfig);

OnNativeWalletConnectionFinished?.Invoke(walletConfig);
OnNativeWalletConnectionFinished?.Invoke(updatedConfig);
}

private void OnWalletConnectionFail(string errorMessage)
Expand Down Expand Up @@ -1064,6 +1064,8 @@ private void OnNativeWalletDisconnect(bool isSuccess)
{
_isWalletConnected = false;

Wallet = new UserWallet(null, null);

OnNativeWalletDisconnected?.Invoke(isSuccess);
}

Expand Down
Loading

0 comments on commit 1be7bea

Please sign in to comment.