Skip to content

Commit b8ee933

Browse files
authored
docs: Use permalinks for source code links (#3612)
1 parent cb05989 commit b8ee933

File tree

15 files changed

+85
-84
lines changed

15 files changed

+85
-84
lines changed

docs/content/docs/basics/cpi.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ The `sol_transfer` instruction included in the example code shows a typical
142142
approach for constructing CPIs using the Anchor framework.
143143

144144
This approach involves creating a
145-
[`CpiContext`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/src/context.rs#L171),
145+
[`CpiContext`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/src/context.rs#L171),
146146
which includes the `program_id` and accounts required for the instruction being
147147
called. The `CpiContext` is then passed to an Anchor helper function
148-
([`transfer`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/src/system_program.rs#L298))
148+
([`transfer`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/src/system_program.rs#L298))
149149
to invoke a specific instruction.
150150

151151
```rust
@@ -472,7 +472,7 @@ The `sol_transfer` instruction included in the example code shows a typical
472472
approach for constructing CPIs using the Anchor framework.
473473

474474
This approach involves creating a
475-
[`CpiContext`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/src/context.rs#L171),
475+
[`CpiContext`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/src/context.rs#L171),
476476
which includes the `program_id` and accounts required for the instruction being
477477
called, followed by a helper function (`transfer`) to invoke a specific
478478
instruction.

docs/content/docs/basics/idl.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,10 @@ ed = 237
428428

429429
You can find the implementation of the discriminator generation in the Anchor
430430
codebase
431-
[here](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/syn/src/codegen/program/common.rs#L5-L19),
431+
[here](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/syn/src/codegen/program/common.rs#L5-L19),
432+
for the [`gen_discriminator` method here](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/syn/src/codegen/program/common.rs#L21-L24),
432433
which is used
433-
[here](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/syn/src/codegen/program/instruction.rs#L27).
434+
[here](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/syn/src/codegen/program/instruction.rs#L33).
434435

435436
</Tab>
436437
<Tab value="Accounts">
@@ -479,7 +480,7 @@ e8 = 232
479480

480481
You can find the implementation of the discriminator generation in the Anchor
481482
codebase
482-
[here](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/attribute/account/src/lib.rs#L101-L117).
483+
[here](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/attribute/account/src/lib.rs#L101-L117).
483484

484485
<Callout type="info">
485486
Note that different programs using identical account names will generate the

docs/content/docs/basics/program-structure.mdx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ pub struct NewAccount {
6161
## declare_id! macro
6262

6363
The
64-
[`declare_id`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/attribute/account/src/lib.rs#L439)
64+
[`declare_id`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/attribute/account/src/lib.rs#L537)
6565
macro specifies the on-chain address of the program, known as the program ID.
6666
You can find the implementation of the code generated by the `declare_id!` macro
67-
[here](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/attribute/account/src/id.rs#L40-L73).
67+
[here](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/attribute/account/src/id.rs#L37-L70).
6868

6969
```rust title="lib.rs"
7070
use anchor_lang::prelude::*;
@@ -91,14 +91,14 @@ the one generated when you run `anchor build` locally.
9191
## #[program] attribute
9292

9393
The
94-
[`#[program]`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/attribute/program/src/lib.rs#L12)
94+
[`#[program]`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/attribute/program/src/lib.rs#L12)
9595
attribute annotates the module containing all the instruction handlers for your
9696
program. Each public function within this module corresponds to an instruction
9797
that can be invoked.
9898

9999
You can find the implementation of the code generated by the `#[program]`
100100
attribute
101-
[here](https://github.com/coral-xyz/anchor/tree/v0.30.1/lang/syn/src/codegen/program).
101+
[here](https://github.com/coral-xyz/anchor/tree/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/syn/src/codegen/program).
102102

103103
```rust title="lib.rs"
104104
use anchor_lang::prelude::*;
@@ -137,11 +137,11 @@ pub struct NewAccount {
137137
Instruction handlers are functions that define the logic executed when an
138138
instruction is invoked. The first parameter of each handler is a `Context<T>`
139139
type, where `T` is a struct implementing the
140-
[`Accounts`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/src/lib.rs#L105)
140+
[`Accounts`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/src/lib.rs#L108)
141141
trait and specifies the accounts the instruction requires.
142142

143143
The
144-
[`Context`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/src/context.rs#L24)
144+
[`Context`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/src/context.rs#L24)
145145
type provides the instruction with access to the following non-argument inputs:
146146

147147
```rust
@@ -213,16 +213,16 @@ pub struct Initialize<'info> {
213213
## #[derive(Accounts)] macro
214214

215215
The
216-
[`#[derive(Accounts)]`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/derive/accounts/src/lib.rs#L630)
216+
[`#[derive(Accounts)]`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/derive/accounts/src/lib.rs#L631)
217217
macro is applied to a struct to specify the accounts that must be provided when
218218
an instruction is invoked. This macro implements the
219-
[`Accounts`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/src/lib.rs#L105)
219+
[`Accounts`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/src/lib.rs#L108)
220220
trait, which simplifies account validation and serialization and deserialization
221221
of account data.
222222

223223
You can find the implementation of the code generated by the
224224
`#[derive(Accounts)]` macro
225-
[here](https://github.com/coral-xyz/anchor/tree/v0.30.1/lang/syn/src/codegen/accounts).
225+
[here](https://github.com/coral-xyz/anchor/tree/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/syn/src/codegen/accounts).
226226

227227
```rust
228228
// [!code word:Accounts]
@@ -268,9 +268,9 @@ Anchor programs in two ways that are generally used together:
268268
`Accounts` trait.
269269

270270
You can find a full list of the constraints
271-
[here](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/syn/src/parser/accounts/constraints.rs)
271+
[here](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/syn/src/parser/accounts/constraints.rs)
272272
and implementation
273-
[here](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/syn/src/codegen/accounts/constraints.rs).
273+
[here](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/syn/src/codegen/accounts/constraints.rs).
274274

275275
```rust
276276
#[derive(Accounts)]
@@ -290,7 +290,7 @@ Anchor programs in two ways that are generally used together:
290290
what the program expects.
291291

292292
You can find the implementation of the account types
293-
[here](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/src/accounts).
293+
[here](https://github.com/coral-xyz/anchor/tree/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/src/accounts).
294294

295295
```rust
296296
#[derive(Accounts)]
@@ -346,7 +346,7 @@ pub struct NewAccount {
346346
## #[account] attribute
347347

348348
The
349-
[`#[account]`](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/attribute/account/src/lib.rs#L66)
349+
[`#[account]`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/attribute/account/src/lib.rs#L97)
350350
attribute is applied to structs that define the structure of the data stored in
351351
custom accounts created by your program.
352352

@@ -362,14 +362,14 @@ This macro implements various traits
362362
[detailed here](https://docs.rs/anchor-lang/latest/anchor_lang/attr.account.html).
363363
The key functionalities of the `#[account]` macro include:
364364

365-
- [Assign Program Owner](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/attribute/account/src/lib.rs#L119-L132):
365+
- [Assign Program Owner](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/attribute/account/src/lib.rs#L130-L143):
366366
When creating an account, the program owner of the account is automatically
367367
set to the program specified in `declare_id`.
368-
- [Set Discriminator](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/attribute/account/src/lib.rs#L101-L117):
368+
- [Set Discriminator](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/attribute/account/src/lib.rs#L111-L128):
369369
A unique 8 byte discriminator, specific to the account type, is added as the
370370
first 8 bytes of account data during its initialization. This helps in
371371
differentiating account types and is used for account validation.
372-
- [Data Serialization and Deserialization](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/attribute/account/src/lib.rs#L202-L246):
372+
- [Data Serialization and Deserialization](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/attribute/account/src/lib.rs#L224-L270):
373373
Account data is automatically serialized and deserialized as the account type.
374374

375375
```rust title="lib.rs"
@@ -411,7 +411,7 @@ pub struct NewAccount {
411411
An account discriminator in an Anchor program refers to an 8 byte identifier
412412
unique to each account type. You can find the implementation of the account
413413
discriminator
414-
[here](https://github.com/coral-xyz/anchor/blob/v0.30.1/lang/attribute/account/src/lib.rs#L101-L117).
414+
[here](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/attribute/account/src/lib.rs#L111-L128).
415415

416416
The discriminator is the first 8 bytes of the SHA256 hash of the string
417417
`account:<AccountName>`. This discriminator is stored as the first 8 bytes of

docs/content/docs/clients/rust.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description:
66

77
The [`anchor-client`](https://docs.rs/anchor-client/latest/anchor_client/) crate
88
is the Rust client library for interacting with Anchor programs. You can find
9-
the source code [here](https://github.com/coral-xyz/anchor/tree/v0.30.1/client).
9+
the source code [here](https://github.com/coral-xyz/anchor/tree/0e5285aecdf410fa0779b7cd09a47f235882c156/client).
1010

1111
## Example
1212

docs/content/docs/clients/typescript.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description:
66
---
77

88
Anchor provides a Typescript client library
9-
([@coral-xyz/anchor](https://github.com/coral-xyz/anchor/tree/v0.30.1/ts/packages/anchor))
9+
([@coral-xyz/anchor](https://github.com/coral-xyz/anchor/tree/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor))
1010
that simplifies the process of interacting with Solana programs from the client
1111
in JavaScript or TypeScript.
1212

@@ -20,11 +20,11 @@ in JavaScript or TypeScript.
2020

2121
To interact with an Anchor program using `@coral-xyz/anchor`, you'll need to
2222
create a
23-
[`Program`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/index.ts#L58)
23+
[`Program`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/index.ts#L58)
2424
instance using the program's [IDL file](/docs/basics/idl).
2525

2626
Creating an instance of the `Program` requires the program's IDL and an
27-
[`AnchorProvider`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/provider.ts#L55).
27+
[`AnchorProvider`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/provider.ts#L59).
2828
An `AnchorProvider` is an abstraction that combines two things:
2929

3030
- `Connection` - the connection to a Solana cluster (i.e. localhost, devnet,
@@ -120,7 +120,7 @@ describe("hello_anchor", () => {
120120
## Invoke Instructions
121121

122122
Once the `Program` is set up using a program's IDL file, you can use the Anchor
123-
[`MethodsBuilder`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/methods.ts#L155)
123+
[`MethodsBuilder`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/methods.ts#L155)
124124
to:
125125

126126
- Build individual instructions
@@ -216,9 +216,9 @@ Anchor provides multiple methods for building program instructions:
216216
<Tab value=".rpc">
217217

218218
The
219-
[`rpc()`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/methods.ts#L283)
219+
[`rpc()`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/methods.ts#L428)
220220
method
221-
[sends a signed transaction](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/rpc.ts#L29)
221+
[sends a signed transaction](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/rpc.ts#L29)
222222
with the specified instruction and returns a `TransactionSignature`.
223223

224224
When using `.rpc`, the `Wallet` from the `Provider` is automatically included as
@@ -246,9 +246,9 @@ const transactionSignature = await program.methods
246246
<Tab value=".transaction">
247247

248248
The
249-
[`transaction()`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/methods.ts#L382)
249+
[`transaction()`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/methods.ts#L348)
250250
method
251-
[builds a `Transaction`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/transaction.ts#L18-L26)
251+
[builds a `Transaction`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/transaction.ts#L18-L26)
252252
with the specified instruction without sending the transaction.
253253

254254
```ts
@@ -277,9 +277,9 @@ const transactionSignature = await connection.sendTransaction(transaction, [
277277
<Tab value=".instruction">
278278

279279
The
280-
[`instruction()`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/methods.ts#L348)
280+
[`instruction()`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/methods.ts#L323)
281281
method
282-
[builds a `TransactionInstruction`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/instruction.ts#L57-L61)
282+
[builds a `TransactionInstruction`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/instruction.ts#L57-L61)
283283
using the specified instruction. This is useful if you want to manually add the
284284
instruction to a transaction and combine it with other instructions.
285285

@@ -322,7 +322,7 @@ IDL. Anchor provides multiple methods for fetching accounts.
322322
<Tab value="all">
323323

324324
Use
325-
[`all()`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/account.ts#L251)
325+
[`all()`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/account.ts#L251)
326326
to fetch all existing accounts for a specific account type.
327327

328328
```ts
@@ -357,7 +357,7 @@ const accounts = await program.account.newAccount.all([
357357
<Tab value="fetch">
358358

359359
Use
360-
[`fetch()`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/account.ts#L165)
360+
[`fetch()`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/account.ts#L165)
361361
to fetch the account data for a single account
362362

363363
```ts
@@ -369,7 +369,7 @@ const account = await program.account.newAccount.fetch(ACCOUNT_ADDRESS);
369369
<Tab value="fetchMultiple">
370370

371371
Use
372-
[`fetchMultiple()`](https://github.com/coral-xyz/anchor/blob/v0.30.1/ts/packages/anchor/src/program/namespace/account.ts#L200)
372+
[`fetchMultiple()`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/namespace/account.ts#L200)
373373
to fetch the account data for multiple accounts by passing in an array of
374374
account addresses
375375

0 commit comments

Comments
 (0)