From b3b779fcc363503d3870953e7ca441921f0b95e3 Mon Sep 17 00:00:00 2001 From: abishekk92 Date: Thu, 20 Jul 2023 12:01:08 +0530 Subject: [PATCH] Use getFees (#158) --- Runtime/codebase/SessionWallet.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Runtime/codebase/SessionWallet.cs b/Runtime/codebase/SessionWallet.cs index 1274bcc..de061aa 100644 --- a/Runtime/codebase/SessionWallet.cs +++ b/Runtime/codebase/SessionWallet.cs @@ -18,7 +18,7 @@ public class SessionWallet : InGameWallet { public PublicKey TargetProgram { get; protected set; } public PublicKey SessionTokenPDA { get; protected set; } - + public static SessionWallet Instance; private SessionWallet(RpcCluster rpcCluster = RpcCluster.DevNet, @@ -89,9 +89,9 @@ public static async Task GetSessionWallet(PublicKey targetProgram sessionWallet.Logout(); return await GetSessionWallet(targetProgram, password, rpcCluster, customRpcUri, customStreamingRpcUri, autoConnectOnStartup); } - + sessionWallet.SessionTokenPDA = FindSessionToken(targetProgram, sessionWallet.Account, Web3.Account); - + Debug.Log(sessionWallet.SessionTokenPDA); if (!await sessionWallet.IsSessionTokenInitialized()) @@ -116,7 +116,7 @@ public static async Task GetSessionWallet(PublicKey targetProgram sessionWallet.SessionTokenPDA = FindSessionToken(targetProgram, sessionWallet.Account, Web3.Account); return sessionWallet; } - + /// /// Creates a transaction instruction to create a new session token account and initialize it with the provided session signer and target program. @@ -197,8 +197,8 @@ private void DeleteSessionWallet() PlayerPrefs.DeleteKey(EncryptedKeystoreKey); PlayerPrefs.Save(); } - - + + /// /// Prepares the session wallet for logout by revoking the session, issuing a refund, and purging the keystore. /// NOTE: You must call PrepareLogout before calling Logout to ensure that the session token account is revoked and the refund is issued. @@ -217,7 +217,7 @@ public async Task PrepareLogout() // Get balance and calculate refund var balance = (await GetBalance(Account.PublicKey)) * SolLamports; - var estimatedFees = await ActiveRpcClient.GetFeeCalculatorForBlockhashAsync(tx.RecentBlockHash); + var estimatedFees = await ActiveRpcClient.GetFeesAsync(); var refund = balance - (estimatedFees.Result.Value.FeeCalculator.LamportsPerSignature * 1); Debug.Log($"LAMPORTS Balance: {balance}, Refund: {refund}");