From da6739c47e910e57e9670e4624c33475c53e4627 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Sun, 10 Sep 2023 13:57:53 +0800 Subject: [PATCH] :recycle: Code refactoring (#176) --- .../CandyMachineController.cs | 10 +++++----- .../Upload/Methods/Bundlr/BundlrClient.cs | 2 +- .../CandyMachine/CandyMachineCommands.cs | 18 +++++++++--------- Runtime/codebase/SessionWallet.cs | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Editor/Solana/Metaplex/CandyMachineManager/CandyMachineController.cs b/Editor/Solana/Metaplex/CandyMachineManager/CandyMachineController.cs index e4241e9..8e7c0f9 100644 --- a/Editor/Solana/Metaplex/CandyMachineManager/CandyMachineController.cs +++ b/Editor/Solana/Metaplex/CandyMachineManager/CandyMachineController.cs @@ -979,7 +979,7 @@ bool skipPreflight newMetadata, null ); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var tx = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(updateAuthority) @@ -1142,7 +1142,7 @@ private static async Task SignMintAccount( bool skipPreflight ) { - var recentBlockhash = await rpcClient.GetRecentBlockHashAsync(); + var recentBlockhash = await rpcClient.GetLatestBlockHashAsync(); var signInstruction = MetadataProgram.SignMetadata(mintAccount, signer); var transaction = new TransactionBuilder() .SetRecentBlockHash(recentBlockhash.Result.Value.Blockhash) @@ -1229,7 +1229,7 @@ out var _ ProgramId = routeInstruction.ProgramId, Keys = routeInstruction.Keys.Concat(remainingAccounts).ToArray() }; - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(wallet.Account) @@ -1397,7 +1397,7 @@ IRpcClient rpcClient ProgramId = routeInstruction.ProgramId, Keys = routeInstruction.Keys.Concat(remainingAccounts).ToArray() }; - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(payer) @@ -1498,7 +1498,7 @@ out var _ ProgramId = routeInstruction.ProgramId, Keys = routeInstruction.Keys.Concat(remainingAccounts).ToArray() }; - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(wallet.Account) diff --git a/Editor/Solana/Metaplex/CandyMachineManager/Upload/Methods/Bundlr/BundlrClient.cs b/Editor/Solana/Metaplex/CandyMachineManager/Upload/Methods/Bundlr/BundlrClient.cs index 0fcbeed..e0e6c0b 100644 --- a/Editor/Solana/Metaplex/CandyMachineManager/Upload/Methods/Bundlr/BundlrClient.cs +++ b/Editor/Solana/Metaplex/CandyMachineManager/Upload/Methods/Bundlr/BundlrClient.cs @@ -114,7 +114,7 @@ internal async Task FundBundlrAddress( ulong amount ) { - var recentBlockhash = await rpcClient.GetRecentBlockHashAsync(); + var recentBlockhash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .AddInstruction( SystemProgram.Transfer( diff --git a/Runtime/codebase/Metaplex/CandyMachine/CandyMachineCommands.cs b/Runtime/codebase/Metaplex/CandyMachine/CandyMachineCommands.cs index d2abaa8..c1ba4f3 100644 --- a/Runtime/codebase/Metaplex/CandyMachine/CandyMachineCommands.cs +++ b/Runtime/codebase/Metaplex/CandyMachine/CandyMachineCommands.cs @@ -114,7 +114,7 @@ public static async Task InitializeCandyMachine( (byte)TokenStandard.NonFungible, CandyMachineProgramId ); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var candyAccountSize = GetSpaceForCandyMachine(candyMachineData); var minimumRent = await rpcClient.GetMinimumBalanceForRentExemptionAsync((long)candyAccountSize); var transaction = new TransactionBuilder() @@ -154,7 +154,7 @@ public static async Task AddConfigLines( configLines, CandyMachineProgramId ); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(account) @@ -213,7 +213,7 @@ public static async Task MintOneToken( RecentSlothashes = RECENT_SLOTHASHES }; var candyMachineInstruction = CandyMachineProgram.MintV2(mintNftAccounts, CandyMachineProgramId); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var computeInstruction = ComputeBudgetProgram.SetComputeUnitLimit(COMPUTE_UNITS); candyMachineInstruction = new TransactionInstruction { Data = candyMachineInstruction.Data, @@ -291,7 +291,7 @@ public static async Task MintOneTokenWithGuards( CandyGuardProgramId ); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var computeInstruction = ComputeBudgetProgram.SetComputeUnitLimit(COMPUTE_UNITS); candyMachineInstruction = new TransactionInstruction { Data = candyMachineInstruction.Data, @@ -350,7 +350,7 @@ out var _ resultData, CandyGuardProgramId ); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(account) @@ -385,7 +385,7 @@ public static async Task AddGuards( resultData, CandyGuardProgramId ); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(account) @@ -414,7 +414,7 @@ public static async Task WrapCandyMachine( wrapAccounts, CandyGuardProgramId ); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(account) @@ -436,7 +436,7 @@ public static async Task Withdraw( CandyMachine = candyMachineAccount }; var withdrawInstruction = CandyMachineProgram.Withdraw(withdrawAccounts, CandyMachineProgramId); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(account) @@ -458,7 +458,7 @@ public static async Task WithdrawGuards( Authority = account }; var withdrawInstruction = CandyGuardProgram.Withdraw(withdrawAccounts, CandyMachineProgramId); - var blockHash = await rpcClient.GetRecentBlockHashAsync(); + var blockHash = await rpcClient.GetLatestBlockHashAsync(); var transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash.Result.Value.Blockhash) .SetFeePayer(account) diff --git a/Runtime/codebase/SessionWallet.cs b/Runtime/codebase/SessionWallet.cs index 3ba1c00..087aa93 100644 --- a/Runtime/codebase/SessionWallet.cs +++ b/Runtime/codebase/SessionWallet.cs @@ -6,8 +6,8 @@ using Solana.Unity.Rpc.Models; using Solana.Unity.Wallet; using Solana.Unity.Programs; -using Solana.Unity.Gum.GplSession.Accounts; -using Solana.Unity.Gum.GplSession.Program; +using Solana.Unity.SessionKeys.GplSession.Accounts; +using Solana.Unity.SessionKeys.GplSession.Program; using Solana.Unity.Rpc.Types; using UnityEngine;