Skip to content

Commit bcb3144

Browse files
committed
Agave v2.0 Migration
Updated the RPC client and removed deprecated code from the SDK. Cleaned up all the warnings across the solution and added a few sys-vars that were missing. Generate Seed in Mnemonic class now uses System.Security.Cryptography instead of bouncy castle sdk
1 parent 7bada11 commit bcb3144

File tree

83 files changed

+146
-1805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+146
-1805
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ var fromAccount = wallet.GetAccount(0);
210210
// Get the destination account
211211
var toAccount = wallet.GetAccount(1);
212212
// Get a recent block hash to include in the transaction
213-
var blockHash = rpcClient.GetRecentBlockHash();
213+
var blockHash = rpcClient.GetLatestBlockHash();
214214

215215
// Initialize a transaction builder and chain as many instructions as you want before building the message
216216
var tx = new TransactionBuilder().
@@ -228,7 +228,7 @@ var firstSig = rpcClient.SendTransaction(tx);
228228
```c#
229229
var wallet = new Wallet.Wallet(MnemonicWords);
230230

231-
var blockHash = rpcClient.GetRecentBlockHash();
231+
var blockHash = rpcClient.GetLatestBlockHash();
232232
var minBalanceForExemptionAcc = rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.TokenAccountDataSize).Result;
233233

234234
var minBalanceForExemptionMint =rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.MintAccountDataSize).Result;
@@ -277,7 +277,7 @@ var tx = new TransactionBuilder().
277277
var rpcClient = ClientFactory.GetClient(Cluster.MainNet);
278278
var wallet = new Wallet();
279279

280-
var blockHash = rpcClient.GetRecentBlockHash();
280+
var blockHash = rpcClient.GetLatestBlockHash();
281281
var minBalanceForExemptionAcc =
282282
rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.TokenAccountDataSize).Result;
283283

src/Solnet.Examples/AssociatedTokenAccountsExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void Run()
3232
#region Create and Initialize a token Mint Account
3333

3434

35-
RequestResult<ResponseValue<BlockHash>> blockHash = RpcClient.GetRecentBlockHash();
35+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = RpcClient.GetLatestBlockHash();
3636

3737
ulong minBalanceForExemptionAcc =
3838
RpcClient.GetMinimumBalanceForRentExemption(TokenProgram.TokenAccountDataSize).Result;

src/Solnet.Examples/HelloWorldExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void Run()
4242

4343
var memoInstruction = MemoProgram.NewMemoV2("Hello Solana World, using Solnet :)");
4444

45-
var recentHash = rpcClient.GetRecentBlockHash();
45+
var recentHash = rpcClient.GetLatestBlockHash();
4646

4747
var tx = new TransactionBuilder().AddInstruction(memoInstruction).SetFeePayer(wallet.Account)
4848
.SetRecentBlockHash(recentHash.Result.Value.Blockhash).Build(wallet.Account);

src/Solnet.Examples/InstructionDecoderExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void Run()
2525
var fromAccount = wallet.GetAccount(10);
2626
var toAccount = wallet.GetAccount(8);
2727

28-
var blockHash = rpcClient.GetRecentBlockHash();
28+
var blockHash = rpcClient.GetLatestBlockHash();
2929
Console.WriteLine($"BlockHash >> {blockHash.Result.Value.Blockhash}");
3030

3131
var msgBytes = new TransactionBuilder()

src/Solnet.Examples/MultisigExamples.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void Run()
2626
{
2727
Wallet.Wallet wallet = new(MnemonicWords);
2828

29-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
29+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
3030

3131
ulong minBalanceForExemptionMultiSig =
3232
rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.MultisigAccountDataSize).Result;
@@ -91,7 +91,7 @@ public void Run()
9191
string createMultiSigAndMintSignature = Examples.SubmitTxSendAndLog(txBytes);
9292
Examples.PollConfirmedTx(createMultiSigAndMintSignature);
9393

94-
blockHash = rpcClient.GetRecentBlockHash();
94+
blockHash = rpcClient.GetLatestBlockHash();
9595

9696
msgData = new TransactionBuilder().SetRecentBlockHash(blockHash.Result.Value.Blockhash)
9797
.SetFeePayer(ownerAccount)
@@ -154,7 +154,7 @@ public void Run()
154154
{
155155
Wallet.Wallet wallet = new(MnemonicWords);
156156

157-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
157+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
158158

159159
ulong minBalanceForExemptionMultiSig =
160160
rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.MultisigAccountDataSize).Result;
@@ -227,7 +227,7 @@ public void Run()
227227
{
228228
Wallet.Wallet wallet = new(MnemonicWords);
229229

230-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
230+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
231231

232232
ulong minBalanceForExemptionMultiSig =
233233
rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.MultisigAccountDataSize).Result;
@@ -359,7 +359,7 @@ public void Run()
359359
{
360360
Wallet.Wallet wallet = new(MnemonicWords);
361361

362-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
362+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
363363

364364
ulong minBalanceForExemptionMultiSig =
365365
rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.MultisigAccountDataSize).Result;
@@ -427,7 +427,7 @@ public void Run()
427427
string signature = Examples.SubmitTxSendAndLog(txBytes);
428428
Examples.PollConfirmedTx(signature);
429429

430-
blockHash = rpcClient.GetRecentBlockHash();
430+
blockHash = rpcClient.GetLatestBlockHash();
431431

432432

433433
// Then we create an account which will be the token's mint authority
@@ -479,7 +479,7 @@ public void Run()
479479
signature = Examples.SubmitTxSendAndLog(txBytes);
480480
Examples.PollConfirmedTx(signature);
481481

482-
blockHash = rpcClient.GetRecentBlockHash();
482+
blockHash = rpcClient.GetLatestBlockHash();
483483

484484
// Here we mint tokens to an account using the mint authority multi sig
485485
msgData = new TransactionBuilder().SetRecentBlockHash(blockHash.Result.Value.Blockhash)
@@ -526,7 +526,7 @@ public void Run()
526526
signature = Examples.SubmitTxSendAndLog(txBytes);
527527
Examples.PollConfirmedTx(signature);
528528

529-
blockHash = rpcClient.GetRecentBlockHash();
529+
blockHash = rpcClient.GetLatestBlockHash();
530530

531531
// After doing this, we freeze the account to which we just minted tokens
532532
// Notice how the signers used are different, because the `freezeAuthority` has different signers
@@ -563,7 +563,7 @@ public void Run()
563563
signature = Examples.SubmitTxSendAndLog(txBytes);
564564
Examples.PollConfirmedTx(signature);
565565

566-
blockHash = rpcClient.GetRecentBlockHash();
566+
blockHash = rpcClient.GetLatestBlockHash();
567567

568568
// Because we're actually cool people, we now thaw that same account and then set the authority to nothing
569569
msgData = new TransactionBuilder().SetRecentBlockHash(blockHash.Result.Value.Blockhash)
@@ -627,7 +627,7 @@ public void Run()
627627
{
628628
Wallet.Wallet wallet = new(MnemonicWords);
629629

630-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
630+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
631631

632632
ulong minBalanceForExemptionMultiSig =
633633
rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.MultisigAccountDataSize).Result;
@@ -703,7 +703,7 @@ public void Run()
703703
string signature = Examples.SubmitTxSendAndLog(txBytes);
704704
Examples.PollConfirmedTx(signature);
705705

706-
blockHash = rpcClient.GetRecentBlockHash();
706+
blockHash = rpcClient.GetLatestBlockHash();
707707

708708
msgData = new TransactionBuilder().SetRecentBlockHash(blockHash.Result.Value.Blockhash)
709709
.SetFeePayer(ownerAccount)
@@ -749,7 +749,7 @@ public void Run()
749749
signature = Examples.SubmitTxSendAndLog(txBytes);
750750
Examples.PollConfirmedTx(signature);
751751

752-
blockHash = rpcClient.GetRecentBlockHash();
752+
blockHash = rpcClient.GetLatestBlockHash();
753753

754754
msgData = new TransactionBuilder().SetRecentBlockHash(blockHash.Result.Value.Blockhash)
755755
.SetFeePayer(ownerAccount)
@@ -786,7 +786,7 @@ public void Run()
786786
signature = Examples.SubmitTxSendAndLog(txBytes);
787787
Examples.PollConfirmedTx(signature);
788788

789-
blockHash = rpcClient.GetRecentBlockHash();
789+
blockHash = rpcClient.GetLatestBlockHash();
790790

791791

792792
msgData = new TransactionBuilder().SetRecentBlockHash(blockHash.Result.Value.Blockhash)
@@ -845,7 +845,7 @@ public void Run()
845845
{
846846
Wallet.Wallet wallet = new(MnemonicWords);
847847

848-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
848+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
849849

850850
ulong minBalanceForExemptionMultiSig =
851851
rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.MultisigAccountDataSize).Result;
@@ -946,7 +946,7 @@ public void Run()
946946
{
947947
Wallet.Wallet wallet = new(MnemonicWords);
948948

949-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
949+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
950950

951951
ulong minBalanceForExemptionMultiSig =
952952
rpcClient.GetMinimumBalanceForRentExemption(TokenProgram.MultisigAccountDataSize).Result;

src/Solnet.Examples/NameServiceProgramExamples.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void Run()
5252
{
5353
var wallet = new Wallet.Wallet(MnemonicWords);
5454

55-
var blockHash = rpcClient.GetRecentBlockHash();
55+
var blockHash = rpcClient.GetLatestBlockHash();
5656
var minBalanceForExemptionNameAcc =
5757
rpcClient.GetMinimumBalanceForRentExemption(NameServiceProgram.NameAccountSize + 96).Result;
5858

src/Solnet.Examples/StakeExample.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void Run()
2828
{
2929
var wallet = new Wallet.Wallet(new Mnemonic(MnemonicWords));
3030
rpcClient.RequestAirdrop(wallet.Account.PublicKey, 100_000_000);
31-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
31+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
3232
ulong minBalance = rpcClient.GetMinimumBalanceForRentExemption(StakeProgram.StakeAccountDataSize).Result;
3333
Account fromAccount = wallet.Account;
3434
PublicKey.TryCreateWithSeed(fromAccount.PublicKey, "yrdy1", StakeProgram.ProgramIdKey, out PublicKey stakeAccount);
@@ -68,7 +68,7 @@ public void Run()
6868
var b58 = new Base58Encoder();
6969
string f = b58.EncodeData(seed);
7070
rpcClient.RequestAirdrop(wallet.Account.PublicKey, 100_000_000);
71-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
71+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
7272
ulong minbalanceforexception = rpcClient.GetMinimumBalanceForRentExemption(StakeProgram.StakeAccountDataSize).Result;
7373
Account fromAccount = wallet.Account;
7474
Account toAccount = wallet.GetAccount(1);
@@ -109,7 +109,7 @@ public void Run()
109109
{
110110
var wallet = new Wallet.Wallet(new Mnemonic(MnemonicWords));
111111
rpcClient.RequestAirdrop(wallet.Account.PublicKey, 100_000_000);
112-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
112+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
113113

114114
Account fromAccount = wallet.Account;
115115
Account toAccount = wallet.GetAccount(1);
@@ -146,7 +146,7 @@ public void Run()
146146
{
147147
var wallet = new Wallet.Wallet(new Mnemonic(MnemonicWords));
148148
rpcClient.RequestAirdrop(wallet.Account.PublicKey, 100_000_000);
149-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
149+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
150150
ulong minbalanceforexception = rpcClient.GetMinimumBalanceForRentExemption(StakeProgram.StakeAccountDataSize).Result;
151151
Account fromAccount = wallet.Account;
152152
PublicKey.TryCreateWithSeed(fromAccount.PublicKey, "dog5", StakeProgram.ProgramIdKey, out PublicKey stakeAccount);
@@ -201,7 +201,7 @@ public void Run()
201201
{
202202
var wallet = new Wallet.Wallet(new Mnemonic(MnemonicWords));
203203
rpcClient.RequestAirdrop(wallet.Account.PublicKey, 100_000_000);
204-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
204+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
205205
ulong minbalanceforexception = rpcClient.GetMinimumBalanceForRentExemption(StakeProgram.StakeAccountDataSize).Result;
206206
Account fromAccount = wallet.Account;
207207
Account stakeAccount = wallet.GetAccount(22);
@@ -254,7 +254,7 @@ public void Run()
254254
{
255255
var wallet = new Wallet.Wallet(new Mnemonic(MnemonicWords));
256256
rpcClient.RequestAirdrop(wallet.Account.PublicKey, 100_000_000);
257-
RequestResult<ResponseValue<BlockHash>> blockHash = rpcClient.GetRecentBlockHash();
257+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = rpcClient.GetLatestBlockHash();
258258
ulong minBalance = rpcClient.GetMinimumBalanceForRentExemption(StakeProgram.StakeAccountDataSize).Result;
259259

260260
Account a6 = wallet.GetAccount(6);

src/Solnet.Examples/TokenSwapExample.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void Run()
3636
var tokenBUserAccount = new Account();
3737

3838
//setup some mints and tokens owned by wallet
39-
RequestResult<ResponseValue<BlockHash>> blockHash = RpcClient.GetRecentBlockHash();
39+
RequestResult<ResponseValue<LatestBlockHash>> blockHash = RpcClient.GetLatestBlockHash();
4040
var tx = new TransactionBuilder()
4141
.SetRecentBlockHash(blockHash.Result.Value.Blockhash)
4242
.SetFeePayer(wallet.Account)
@@ -112,7 +112,7 @@ public void Run()
112112
var swapTokenBAccount = new Account();
113113

114114
//init the swap authority's token accounts
115-
blockHash = RpcClient.GetRecentBlockHash();
115+
blockHash = RpcClient.GetLatestBlockHash();
116116
tx = new TransactionBuilder()
117117
.SetRecentBlockHash(blockHash.Result.Value.Blockhash)
118118
.SetFeePayer(wallet.Account)
@@ -161,7 +161,7 @@ public void Run()
161161
var poolFeeAccount = new Account();
162162

163163
//create the pool mint and the user and fee pool token accounts
164-
blockHash = RpcClient.GetRecentBlockHash();
164+
blockHash = RpcClient.GetLatestBlockHash();
165165
tx = new TransactionBuilder()
166166
.SetRecentBlockHash(blockHash.Result.Value.Blockhash)
167167
.SetFeePayer(wallet.Account)
@@ -206,7 +206,7 @@ public void Run()
206206
Examples.PollConfirmedTx(txSig);
207207

208208
//create the swap
209-
blockHash = RpcClient.GetRecentBlockHash();
209+
blockHash = RpcClient.GetLatestBlockHash();
210210
tx = new TransactionBuilder()
211211
.SetRecentBlockHash(blockHash.Result.Value.Blockhash)
212212
.SetFeePayer(wallet.Account)
@@ -247,7 +247,7 @@ public void Run()
247247
Examples.PollConfirmedTx(txSig);
248248

249249
//now a user can swap in the pool
250-
blockHash = RpcClient.GetRecentBlockHash();
250+
blockHash = RpcClient.GetLatestBlockHash();
251251
tx = new TransactionBuilder()
252252
.SetRecentBlockHash(blockHash.Result.Value.Blockhash)
253253
.SetFeePayer(wallet.Account)
@@ -268,7 +268,7 @@ public void Run()
268268
Examples.PollConfirmedTx(txSig);
269269

270270
//user can add liq
271-
blockHash = RpcClient.GetRecentBlockHash();
271+
blockHash = RpcClient.GetLatestBlockHash();
272272
tx = new TransactionBuilder()
273273
.SetRecentBlockHash(blockHash.Result.Value.Blockhash)
274274
.SetFeePayer(wallet.Account)
@@ -289,7 +289,7 @@ public void Run()
289289
Examples.PollConfirmedTx(txSig);
290290

291291
//user can remove liq
292-
blockHash = RpcClient.GetRecentBlockHash();
292+
blockHash = RpcClient.GetLatestBlockHash();
293293
tx = new TransactionBuilder()
294294
.SetRecentBlockHash(blockHash.Result.Value.Blockhash)
295295
.SetFeePayer(wallet.Account)
@@ -311,7 +311,7 @@ public void Run()
311311
Examples.PollConfirmedTx(txSig);
312312

313313
//user can deposit single
314-
blockHash = RpcClient.GetRecentBlockHash();
314+
blockHash = RpcClient.GetLatestBlockHash();
315315
tx = new TransactionBuilder()
316316
.SetRecentBlockHash(blockHash.Result.Value.Blockhash)
317317
.SetFeePayer(wallet.Account)
@@ -330,7 +330,7 @@ public void Run()
330330
Examples.PollConfirmedTx(txSig);
331331

332332
//user can withdraw single
333-
blockHash = RpcClient.GetRecentBlockHash();
333+
blockHash = RpcClient.GetLatestBlockHash();
334334
tx = new TransactionBuilder()
335335
.SetRecentBlockHash(blockHash.Result.Value.Blockhash)
336336
.SetFeePayer(wallet.Account)

0 commit comments

Comments
 (0)