diff --git a/code/offline-transactions/durable-nonce/create-nonce-account/main.en.ts b/code/offline-transactions/durable-nonce/create-nonce-account/main.en.ts index 27f0b541b..7af28f9be 100644 --- a/code/offline-transactions/durable-nonce/create-nonce-account/main.en.ts +++ b/code/offline-transactions/durable-nonce/create-nonce-account/main.en.ts @@ -6,11 +6,12 @@ import { NONCE_ACCOUNT_LENGTH, SystemProgram, LAMPORTS_PER_SOL, -} from "@solana/web3.js"; + sendAndConfirmTransaction, +} from '@solana/web3.js'; (async () => { // Setup our connection and wallet - const connection = new Connection(clusterApiUrl("devnet"), "confirmed"); + const connection = new Connection(clusterApiUrl('devnet'), 'confirmed'); const feePayer = Keypair.generate(); // Fund our wallet with 1 SOL @@ -44,6 +45,9 @@ import { ); console.log( - `txhash: ${await connection.sendTransaction(tx, [feePayer, nonceAccount])}` + `txhash: ${await sendAndConfirmTransaction(connection, tx, [ + feePayer, + nonceAccount, + ])}` ); })(); diff --git a/code/programs/cpi-transfer/client-system/main.en.ts b/code/programs/cpi-transfer/client-system/main.en.ts index e6e5f8b3d..c139fb941 100644 --- a/code/programs/cpi-transfer/client-system/main.en.ts +++ b/code/programs/cpi-transfer/client-system/main.en.ts @@ -1,26 +1,40 @@ -import { clusterApiUrl, Connection, Keypair } from "@solana/web3.js"; -import { LAMPORTS_PER_SOL, PublicKey, SystemProgram } from "@solana/web3.js"; -import { Transaction, TransactionInstruction } from "@solana/web3.js"; +import { clusterApiUrl, Connection, Keypair } from '@solana/web3.js'; +import { LAMPORTS_PER_SOL, PublicKey, SystemProgram } from '@solana/web3.js'; +import { + Transaction, + TransactionInstruction, + sendAndConfirmTransaction, +} from '@solana/web3.js'; -import * as BN from "bn.js"; +import * as BN from 'bn.js'; // Users const PAYER_KEYPAIR = Keypair.generate(); const GENERAL_STATE_KEYPAIR = Keypair.generate(); const ACCOUNT_SPACE_BUFFER = Buffer.from( - Uint8Array.of(...new BN(100).toArray("le", 8)) + Uint8Array.of(...new BN(100).toArray('le', 8)) ); (async () => { - const connection = new Connection(clusterApiUrl("devnet"), "confirmed"); + const connection = new Connection(clusterApiUrl('devnet'), 'confirmed'); + const latestBlockHash = await connection.getLatestBlockhash(); const programId = new PublicKey( - "DkuQ5wsndkzXfgqDB6Lgf4sDjBi4gkLSak1dM5Mn2RuQ" + 'DkuQ5wsndkzXfgqDB6Lgf4sDjBi4gkLSak1dM5Mn2RuQ' ); - // Airdropping some SOL + // Airdropping 1 SOL + const feePayer = Keypair.generate(); await connection.confirmTransaction( - await connection.requestAirdrop(PAYER_KEYPAIR.publicKey, LAMPORTS_PER_SOL) + { + blockhash: latestBlockHash.blockhash, + lastValidBlockHeight: latestBlockHash.lastValidBlockHeight, + signature: await connection.requestAirdrop( + feePayer.publicKey, + LAMPORTS_PER_SOL + ), + }, + 'confirmed' ); // Our program's CPI instruction (create_account) @@ -50,7 +64,7 @@ const ACCOUNT_SPACE_BUFFER = Buffer.from( // Adding up all the above instructions transaction.add(createAccountIx); - const txHash = await connection.sendTransaction(transaction, [ + const txHash = await sendAndConfirmTransaction(connection, transaction, [ PAYER_KEYPAIR, GENERAL_STATE_KEYPAIR, ]); diff --git a/code/programs/create-pda/client/main.en.ts b/code/programs/create-pda/client/main.en.ts index 41e8a14f6..4df124ae9 100644 --- a/code/programs/create-pda/client/main.en.ts +++ b/code/programs/create-pda/client/main.en.ts @@ -4,26 +4,50 @@ import { Keypair, LAMPORTS_PER_SOL, PublicKey, + sendAndConfirmTransaction, SystemProgram, Transaction, TransactionInstruction, -} from "@solana/web3.js"; +} from '@solana/web3.js'; const PAYER_KEYPAIR = Keypair.generate(); (async () => { - const connection = new Connection(clusterApiUrl("devnet"), "confirmed"); + const connection = new Connection(clusterApiUrl('devnet'), 'confirmed'); + const latestBlockHash = await connection.getLatestBlockhash(); const programId = new PublicKey( - "6eW5nnSosr2LpkUGCdznsjRGDhVb26tLmiM1P8RV1QQp" + '6eW5nnSosr2LpkUGCdznsjRGDhVb26tLmiM1P8RV1QQp' ); // Airdop to Payer await connection.confirmTransaction( - await connection.requestAirdrop(PAYER_KEYPAIR.publicKey, LAMPORTS_PER_SOL) + { + blockhash: latestBlockHash.blockhash, + lastValidBlockHeight: latestBlockHash.lastValidBlockHeight, + signature: await connection.requestAirdrop( + PAYER_KEYPAIR.publicKey, + LAMPORTS_PER_SOL + ), + }, + 'confirmed' + ); + + // Airdropping 1 SOL + const feePayer = Keypair.generate(); + await connection.confirmTransaction( + { + blockhash: latestBlockHash.blockhash, + lastValidBlockHeight: latestBlockHash.lastValidBlockHeight, + signature: await connection.requestAirdrop( + feePayer.publicKey, + LAMPORTS_PER_SOL + ), + }, + 'confirmed' ); const [pda, bump] = await PublicKey.findProgramAddress( - [Buffer.from("customaddress"), PAYER_KEYPAIR.publicKey.toBuffer()], + [Buffer.from('customaddress'), PAYER_KEYPAIR.publicKey.toBuffer()], programId ); @@ -54,6 +78,8 @@ const PAYER_KEYPAIR = Keypair.generate(); const transaction = new Transaction(); transaction.add(createPDAIx); - const txHash = await connection.sendTransaction(transaction, [PAYER_KEYPAIR]); + const txHash = await sendAndConfirmTransaction(connection, transaction, [ + PAYER_KEYPAIR, + ]); console.log(`Created PDA successfully. Tx Hash: ${txHash}`); })(); diff --git a/code/programs/get-clock/method-two/client/main.en.ts b/code/programs/get-clock/method-two/client/main.en.ts index 341d23ec2..6391703f2 100644 --- a/code/programs/get-clock/method-two/client/main.en.ts +++ b/code/programs/get-clock/method-two/client/main.en.ts @@ -7,19 +7,29 @@ import { SystemProgram, Transaction, TransactionInstruction, -} from "@solana/web3.js"; + sendAndConfirmTransaction, +} from '@solana/web3.js'; (async () => { const programId = new PublicKey( - "4ZEdbCtb5UyCSiAMHV5eSHfyjq3QwbG3yXb6oHD7RYjk" + '4ZEdbCtb5UyCSiAMHV5eSHfyjq3QwbG3yXb6oHD7RYjk' ); - const connection = new Connection(clusterApiUrl("devnet"), "confirmed"); + const connection = new Connection(clusterApiUrl('devnet'), 'confirmed'); + const latestBlockHash = await connection.getLatestBlockhash(); // Airdropping 1 SOL const feePayer = Keypair.generate(); await connection.confirmTransaction( - await connection.requestAirdrop(feePayer.publicKey, LAMPORTS_PER_SOL) + { + blockhash: latestBlockHash.blockhash, + lastValidBlockHeight: latestBlockHash.lastValidBlockHeight, + signature: await connection.requestAirdrop( + feePayer.publicKey, + LAMPORTS_PER_SOL + ), + }, + 'confirmed' ); // Hello state account @@ -58,7 +68,7 @@ import { const transaction = new Transaction(); transaction.add(allocateHelloAccountIx, initIx); - const txHash = await connection.sendTransaction(transaction, [ + const txHash = await sendAndConfirmTransaction(connection, transaction, [ feePayer, helloAccount, ]); diff --git a/docs/references/programs.md b/docs/references/programs.md index fa84d6e07..8f180e6b9 100644 --- a/docs/references/programs.md +++ b/docs/references/programs.md @@ -284,7 +284,7 @@ A Program Derived Address is simply an account owned by the program, but has no diff --git a/vercel.json b/vercel.json index ed3a61065..e2b6b95d3 100644 --- a/vercel.json +++ b/vercel.json @@ -1,8 +1,153 @@ { "redirects": [ + { + "source": "/", + "destination": "https://solana.com/docs", + "permanent": true + }, + { + "source": "/getting-started/installation.html", + "destination": "https://solana.com/docs/intro/installation", + "permanent": true + }, + { + "source": "/core-concepts/accounts.html", + "destination": "https://solana.com/docs/core/accounts", + "permanent": true + }, + { + "source": "/core-concepts/programs.html", + "destination": "https://solana.com/docs/core/programs", + "permanent": true + }, + { + "source": "/core-concepts/transactions.html", + "destination": "https://solana.com/docs/core/transactions", + "permanent": true + }, + { + "source": "/core-concepts/pdas.html", + "destination": "https://solana.com/docs/core/pda", + "permanent": true + }, + { + "source": "/core-concepts/cpi.html", + "destination": "https://solana.com/docs/core/cpi", + "permanent": true + }, + { + "source": "/guides/get-program-accounts.html#facts", + "destination": "https://solana.com/developers/guides/javascript/get-program-accounts", + "permanent": true + }, + { + "source": "guides/debugging-solana-programs.html", + "destination": "https://solana.com/docs/programs/debugging#logging", + "permanent": true + }, { "source": "/guides/retrying-transactions.html", - "destination": "https://solana.com/docs/core/transactions/retry", + "destination": "https://solana.com/docs/advanced/retry", + "permanent": true + }, + { + "source": "/guides/versioned-transactions.html", + "destination": "https://solana.com/docs/advanced/versions", + "permanent": true + }, + { + "source": "/references/local-development.html", + "destination": "https://solana.com/developers/cookbook/development/start-local-validator", + "permanent": true + }, + { + "source": "/references/keypairs-and-wallets.html", + "destination": "https://solana.com/developers/cookbook/wallets/create-keypair", + "permanent": true + }, + { + "source": "/references/basic-transactions.html", + "destination": "https://solana.com/developers/cookbook/transactions/send-sol", + "permanent": true + }, + { + "source": "/references/accounts.html", + "destination": "https://solana.com/developers/cookbook/accounts/create-account", + "permanent": true + }, + { + "source": "/references/programs.html#how-to-transfer-sol-in-a-program", + "destination": "https://solana.com/developers/cookbook/programs/transfer-sol", + "permanent": true + }, + { + "source": "/references/tokens.html", + "destination": "https://solana.com/developers/cookbook/tokens/create-mint-account", + "permanent": true + }, + { + "source": "/references/nfts.html#how-to-create-an-nft", + "destination": "https://solana.com/developers/cookbook/tokens/", + "permanent": true + }, + { + "source": "/references/offline-transactions.html#sign-transaction", + "destination": "https://solana.com/developers/cookbook/transactions/offline-transactions", + "permanent": true + }, + { + "source": "/gaming/intro.html", + "destination": "https://solana.com/developers/guides/games/getting-started-with-game-development", + "permanent": true + }, + { + "source": "/gaming/intro.html", + "destination": "https://solana.com/developers/guides/games/getting-started-with-game-development", + "permanent": true + }, + { + "source": "/gaming/game-sdks.html", + "destination": "https://solana.com/developers/guides/games/game-sdks", + "permanent": true + }, + { + "source": "/gaming/nfts-in-games.html", + "destination": "https://solana.com/developers/guides/games/nfts-in-games", + "permanent": true + }, + { + "source": "/gaming/hello-world.html", + "destination": "https://solana.com/developers/guides/games/hello-world", + "permanent": true + }, + { + "source": "/gaming/store-sol-in-pda.html", + "destination": "https://solana.com/developers/guides/games/store-sol-in-pda", + "permanent": true + }, + { + "source": "/gaming/saving-game-state.html", + "destination": "https://solana.com/developers/guides/games/saving-game-state", + "permanent": true + }, + { + "source": "/gaming/energy-system.html", + "destination": "https://solana.com/developers/guides/games/energy-system", + "permanent": true + }, + { + "source": "/gaming/interact-with-tokens.html", + "destination": "https://solana.com/developers/guides/games/interact-with-tokens", + "permanent": true + }, + { + "source": "/gaming/porting-anchor-to-unity.html", + "destination": "https://solana.com/developers/guides/games/porting-anchor-to-unity", + "permanent": true + }, + { + "source": "/gaming/game-examples.html", + "destination": "https://solana.com/developers/guides/games/game-examples", "permanent": true } ]