Skip to content

Commit

Permalink
fix: various minor fixes to anchor unit (Unboxed-Software#249)
Browse files Browse the repository at this point in the history
* fix: minor typo

* fix: anchor build not anchor-build

* fix: an address doesn't provide a deterministic way to find an address, but rather some data

* fix: use 'anchor keys sync' to sync the keys rather than manually modifying the file
  • Loading branch information
mikemaccana authored Nov 15, 2023
1 parent b1c7f83 commit 449c8f5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
4 changes: 2 additions & 2 deletions content/es/intro-to-anchor.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ Crear un nuevo proyecto llamado `anchor-counter` ejecutando `anchor init` :
anchor init anchor-counter
```

A continuación, ejecute `anchor-build`
A continuación, ejecute `anchor build`

```console
anchor-build
anchor build
```

Entonces, corre `anchor keys list`
Expand Down
40 changes: 23 additions & 17 deletions content/intro-to-anchor.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,43 +328,49 @@ Create a new project called `anchor-counter` by running `anchor init`:
anchor init anchor-counter
```

Next, run `anchor-build`
Next, run `anchor build`

```console
anchor-build
anchor build
```

Then, run `anchor keys list`
Anchor build will also generate a keypair for your new program - the keys are saved in the `target/deploy` directory.

```console
anchor keys list
Open the file `lib.rs` and look at `declare_id!`:

```rust
declare_id!("BouTUP7a3MZLtXqMAm1NrkJSKwAjmid8abqiNjUyBJSr");
```

Copy the program ID output from `anchor keys list`
Run `anchor keys sync`

```
anchor_counter: BouTUP7a3MZLtXqMAm1NrkJSKwAjmid8abqiNjUyBJSr
```console
anchor keys sync
```

Then update `declare_id!` in `lib.rs`
You'll see the Anchor updates both:

```rust
declare_id!("BouTUP7a3MZLtXqMAm1NrkJSKwAjmid8abqiNjUyBJSr");
```
- The key used in `declare_id!()` in `lib.rs`
- The key in `Anchor.toml`

And also update `Anchor.toml`
To match the key generated during `anchor build`:

```
[programs.localnet]
anchor_counter = "BouTUP7a3MZLtXqMAm1NrkJSKwAjmid8abqiNjUyBJSr"
```console
Found incorrect program id declaration in "anchor-counter/programs/anchor-counter/src/lib.rs"
Updated to BouTUP7a3MZLtXqMAm1NrkJSKwAjmid8abqiNjUyBJSr

Found incorrect program id declaration in Anchor.toml for the program `anchor_counter`
Updated to BouTUP7a3MZLtXqMAm1NrkJSKwAjmid8abqiNjUyBJSr

All program id declarations are synced.
```

Finally, delete the default code in `lib.rs` until all that is left is the following:

```rust
use anchor_lang::prelude::*;

declare_id!("BouTUP7a3MZLtXqMAm1NrkJSKwAjmid8abqiNjUyBJSr");
declare_id!("your-private-key");

#[program]
pub mod anchor_counter {
Expand Down
2 changes: 1 addition & 1 deletion content/pda.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Program Derived Addresses (PDAs) are account addresses designed to be signed for

PDAs serve two main functions:

1. Provide a deterministic way to find the address of a program-owned account
1. Provide a deterministic way to find a given item of data for a program
2. Authorize the program from which a PDA was derived to sign on its behalf in the same way a user may sign with their secret key

In this lesson we'll focus on using PDAs to find and store data. We'll discuss signing with a PDA more thoroughly in a future lesson where we cover Cross Program Invocations (CPIs).
Expand Down
4 changes: 2 additions & 2 deletions src/routes/[slug]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { readFile } from "node:fs/promises";

import { marked } from "marked";

const courseStucture: CourseStructure = courseStuctureUntyped;
const courseStructure: CourseStructure = courseStuctureUntyped;

const cleanContent = (content: string) => {
// There's a bunch of metadata in the content that should really be elsewhere.
Expand All @@ -25,7 +25,7 @@ const cleanContent = (content: string) => {

// See https://kit.svelte.dev/docs/load
export async function load({ params }): Promise<PageData> {
const allLessons = courseStucture.tracks.flatMap((track) =>
const allLessons = courseStructure.tracks.flatMap((track) =>
track.units.flatMap((module) => module.lessons),
);

Expand Down

0 comments on commit 449c8f5

Please sign in to comment.