Skip to content

Commit

Permalink
remove extra callout end tag, remove messed up git additions, remove …
Browse files Browse the repository at this point in the history
…magic number in instructions/initialize.rs
  • Loading branch information
shawazi committed Oct 4, 2024
1 parent f127219 commit 492a080
Showing 1 changed file with 8 additions and 45 deletions.
53 changes: 8 additions & 45 deletions content/courses/onchain-development/intro-to-anchor.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,6 @@ avm 0.30.1
anchor-cli 0.30.1
```

</Callout>

#### Creating a new Anchor project with the multiple files template

```shell
Expand Down Expand Up @@ -658,7 +656,8 @@ anchor keys sync
This will update your Anchor.toml and src/lib.rs files with the correct program
ID.

Update the src/lib.rs file with the following:
Update the src/lib.rs file with the following (but keep your declare_id as it is
after running `anchor keys sync`):

```rust
use anchor_lang::prelude::*;
Expand Down Expand Up @@ -704,10 +703,6 @@ use anchor_lang::prelude::*;

#[account]
#[derive(InitSpace)]
<<<<<<< HEAD
#[derive(InitSpace)]
=======
>>>>>>> origin/superteamintro-to-anchor
pub struct Counter {
pub count: u64,
}
Expand Down Expand Up @@ -748,30 +743,17 @@ space allocation from the official
[anchor documentation](https://www.anchor-lang.com/docs/space).
</Callout>

<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD Inside of `instructions/initialize.rs`,
adjust the code to match the following:

=======

> > > > > > > # 0a8ed53 (add callout info box for derive(initspace) macro (or is it an attribute?))
> > > > > > >
> > > > > > > Inside of `instructions/initialize.rs`, adjust the code to match
> > > > > > > the following:
> > > > > > > # c11ca55 (final edits, fix huge issues with tutorial workflow, should work properly on any system now if you follow the steps)
> > > > > > >
> > > > > > > Inside of `instructions/initialize.rs`, adjust the code to match
> > > > > > > the following:
> > > > > > > origin/superteamintro-to-anchor
Inside of `instructions/initialize.rs`, adjust the code to match the following:

```rust
use crate::state::Counter;
use anchor_lang::prelude::*;

const DISCRIMINATOR: usize = 8;

#[derive(Accounts)]
pub struct Initialize<'info> {
#[account(init, payer = user, space = 8 + Counter::INIT_SPACE)]
#[account(init, payer = user, space = DISCRIMINATOR + Counter::INIT_SPACE)]
pub counter: Account<'info, Counter>,
#[account(mut)]
pub user: Signer<'info>,
Expand All @@ -790,7 +772,7 @@ pub fn handler(ctx: Context<Initialize>) -> Result<()> {
Within instructions/increment.rs, let’s implement an `increment` instruction
handler to increment the `count` once a `counter` account is initialized by the
first instruction handler. This instruction handler requires a `Context` of type
`Update` (implemented in the next step) and takes no additional instruction
`Update` (implemented in a previous step) and takes no additional instruction
data. In the instruction handler's logic, we are simply tracking the current
state, and then incrementing the existing `counter` account’s `count` field by
`1`.
Expand All @@ -800,15 +782,7 @@ use crate::state::Counter;
use anchor_lang::prelude::*;

#[derive(Accounts)]
<<<<<<< HEAD
<<<<<<< HEAD
pub struct DecrementUpdate<'info> {
=======
pub struct IncrementUpdate<'info> {
>>>>>>> 5789e73 (add another callout info box for the agave installation section, and re-incorporate some tutorial notes from the previous lab's instructions, since they offer useful information. fix erroneous initialize handler that was somehow passing tests)
=======
pub struct IncrementUpdate<'info> {
>>>>>>> origin/superteamintro-to-anchor
#[account(mut)]
pub counter: Account<'info, Counter>,
pub user: Signer<'info>,
Expand Down Expand Up @@ -1041,18 +1015,7 @@ As always, get creative with these challenges and take them beyond the basic
instructions if you want - and have fun!

Try to do this independently if you can! But if you get stuck, feel free to
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD reference
the [solution code](https://github.com/shawazi/anchor-counter). =======
reference the [solution code](https://github.com/shawazi/anchor-counter).

> > > > > > > # d1d522f (replace unboxed-software repo link for solution to my own solution)
> > > > > > >
> > > > > > > reference
> > > > > > > the [solution code](https://github.com/shawazi/anchor-counter).
> > > > > > > ac32de3 (add command for 'anchor keys sync' to lab, according to
> > > > > > > CONTRIBUTING.md) ======= reference
> > > > > > > the [solution code](https://github.com/shawazi/anchor-counter).
> > > > > > > origin/superteamintro-to-anchor
the [solution code](https://github.com/shawazi/anchor-counter).

<Callout type="success" title="Completed the lab?">
Push your code to GitHub and
Expand Down

0 comments on commit 492a080

Please sign in to comment.