Skip to content

Commit

Permalink
Use getFees (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
abishekk92 authored Jul 20, 2023
1 parent a34b308 commit b3b779f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Runtime/codebase/SessionWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -89,9 +89,9 @@ public static async Task<SessionWallet> 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())
Expand All @@ -116,7 +116,7 @@ public static async Task<SessionWallet> GetSessionWallet(PublicKey targetProgram
sessionWallet.SessionTokenPDA = FindSessionToken(targetProgram, sessionWallet.Account, Web3.Account);
return sessionWallet;
}


/// <summary>
/// Creates a transaction instruction to create a new session token account and initialize it with the provided session signer and target program.
Expand Down Expand Up @@ -197,8 +197,8 @@ private void DeleteSessionWallet()
PlayerPrefs.DeleteKey(EncryptedKeystoreKey);
PlayerPrefs.Save();
}


/// <summary>
/// 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.
Expand All @@ -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}");

Expand Down

0 comments on commit b3b779f

Please sign in to comment.