Skip to content

Commit

Permalink
feat: added redirects to solana-com (#610)
Browse files Browse the repository at this point in the history
* added redirects to solana-com

* added remaining redirects

* added nfts redirect

* Update vercel.json

Co-authored-by: Nick Frostbutter <[email protected]>

* Update vercel.json

Co-authored-by: Nick Frostbutter <[email protected]>

* Update vercel.json

Co-authored-by: Nick Frostbutter <[email protected]>

* Update vercel.json

Co-authored-by: Nick Frostbutter <[email protected]>

---------

Co-authored-by: Jacob Creech <[email protected]>
Co-authored-by: Nick Frostbutter <[email protected]>
  • Loading branch information
3 people authored Sep 27, 2024
1 parent 5acc306 commit 8ee8e29
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -44,6 +45,9 @@ import {
);

console.log(
`txhash: ${await connection.sendTransaction(tx, [feePayer, nonceAccount])}`
`txhash: ${await sendAndConfirmTransaction(connection, tx, [
feePayer,
nonceAccount,
])}`
);
})();
34 changes: 24 additions & 10 deletions code/programs/cpi-transfer/client-system/main.en.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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,
]);
Expand Down
38 changes: 32 additions & 6 deletions code/programs/create-pda/client/main.en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down Expand Up @@ -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}`);
})();
20 changes: 15 additions & 5 deletions code/programs/get-clock/method-two/client/main.en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
]);
Expand Down
2 changes: 1 addition & 1 deletion docs/references/programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ A Program Derived Address is simply an account owned by the program, but has no

<template v-slot:default>

@[code](@/code/programs/create-pda/program/src/lib.rs)
@[code](@/code/pprograms/create-pda/program/src/lib.rs)

</template>

Expand Down
147 changes: 146 additions & 1 deletion vercel.json
Original file line number Diff line number Diff line change
@@ -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
}
]
Expand Down

0 comments on commit 8ee8e29

Please sign in to comment.