diff --git a/Runtime/codebase/SessionWallet.cs b/Runtime/codebase/SessionWallet.cs index ac0a71ec..42436ab0 100644 --- a/Runtime/codebase/SessionWallet.cs +++ b/Runtime/codebase/SessionWallet.cs @@ -238,13 +238,14 @@ public async Task CloseSession(Commitment commitment = Commitment.Confirmed) // Get balance and calculate refund var balance = (await GetBalance(Account.PublicKey)) * SolLamports; - var estimatedFees = await ActiveRpcClient.GetFeesAsync(Commitment.Confirmed); - var refund = balance - estimatedFees.Result.Value.FeeCalculator.LamportsPerSignature * 1; + var estimatedFees = await ActiveRpcClient.GetFeeForMessageAsync(tx.CompileMessage(), Commitment.Confirmed); + var refund = balance - estimatedFees.Result.Value * 1; Debug.Log($"LAMPORTS Balance: {balance}, Refund: {refund}"); tx.Add(RevokeSessionIX()); // Issue Refund - tx.Add(SystemProgram.Transfer(Account.PublicKey, _externalWallet.Account.PublicKey, (ulong)refund)); + if (refund != null) + tx.Add(SystemProgram.Transfer(Account.PublicKey, _externalWallet.Account.PublicKey, (ulong)refund)); var rest = await SignAndSendTransaction(tx, commitment: commitment); DeleteSessionWallet(); }