Skip to content

Commit 2d76aee

Browse files
feat(0.3.0): anchor content
2 parents 4f6b1b6 + 203c926 commit 2d76aee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+11988
-7058
lines changed

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"vscode": {
44
"extensions": [
55
"dbaeumer.vscode-eslint",
6-
6+
77
"freeCodeCamp.freecodecamp-dark-vscode-theme"
88
]
99
}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ target
22
node_modules
33
Cargo.lock
44
!.gitkeep
5-
.freeCodeCamp/dist
5+
__test
66

77
# Should be included in repo, but does not get updated
88
.logs
99
test-ledger
10+
.anchor

.gitpod.Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
FROM gitpod/workspace-full:latest
22

3+
ARG REPO_NAME=solana-curriculum
4+
ARG HOMEDIR=/workspace/$REPO_NAME
5+
6+
WORKDIR ${HOMEDIR}
7+
ENV HOME=${HOMEDIR}
8+
39
RUN bash -c 'VERSION="18" \
410
&& source $HOME/.nvm/nvm.sh && nvm install $VERSION \
511
&& nvm use $VERSION && nvm alias default $VERSION'

.gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ ports:
1212
# TODO: See about publishing to Open VSX for smoother process
1313
vscode:
1414
extensions:
15-
- https://github.com/freeCodeCamp/courses-vscode-extension/releases/download/v1.7.4/freecodecamp-courses-1.7.4.vsix
15+
- https://github.com/freeCodeCamp/courses-vscode-extension/releases/download/v1.7.5/freecodecamp-courses-1.7.5.vsix
1616
- https://github.com/freeCodeCamp/freecodecamp-dark-vscode-theme/releases/download/v1.0.0/freecodecamp-dark-vscode-theme-1.0.0.vsix

.vscode/settings.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"files.exclude": {
33
".devcontainer": false,
44
".editorconfig": false,
5-
".freeCodeCamp": false,
65
".git": false,
76
".github": false,
87
".gitignore": false,
@@ -29,9 +28,12 @@
2928
"learn-how-to-set-up-solana-by-building-a-hello-world-smart-contract": false,
3029
"learn-how-to-interact-with-on-chain-programs": false,
3130
"build-a-smart-contract": false,
32-
"build-a-university-certification-nft": false,
3331
"learn-solanas-token-program-by-minting-a-fungible-token": false,
34-
"learn-the-metaplex-sdk-by-minting-an-nft": false
32+
"learn-the-metaplex-sdk-by-minting-an-nft": false,
33+
"build-a-university-certification-nft": false,
34+
"learn-anchor-by-building-tic-tac-toe-part-1": false,
35+
"learn-anchor-by-building-tic-tac-toe-part-2": false,
36+
"build-an-anchor-leaderboard": false
3537
},
3638
"terminal.integrated.profiles.linux": {
3739
"bash": {
@@ -41,9 +43,5 @@
4143
}
4244
},
4345
"terminal.integrated.defaultProfile.linux": "bash",
44-
"rust-analyzer.linkedProjects": [
45-
"learn-how-to-set-up-solana-by-building-a-hello-world-smart-contract/src/program-rust/Cargo.toml",
46-
"learn-how-to-interact-with-on-chain-programs/src/program-rust/Cargo.toml"
47-
],
4846
"workbench.colorTheme": "freeCodeCamp Dark Theme"
4947
}

Dockerfile

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ARG REPO_NAME=solana-curriculum
55
ARG HOMEDIR=/workspace/$REPO_NAME
66

77
ENV TZ="America/New_York"
8+
ENV HOME=/workspace
89

910
RUN apt-get update && apt-get install -y sudo
1011

@@ -33,17 +34,22 @@ RUN sudo apt-get install -y nodejs
3334
# Rust
3435
RUN sudo apt-get install -y build-essential
3536
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
36-
ENV PATH="/root/.cargo/bin:${PATH}"
37+
ENV PATH="/workspace/.cargo/bin:${PATH}"
3738

3839
# Solana
3940
RUN sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
41+
# Anchor
42+
RUN cargo install --git https://github.com/coral-xyz/anchor avm --locked --force && avm install 0.28.0 && avm use 0.28.0
4043

4144
# /usr/lib/node_modules is owned by root, so this creates a folder ${USERNAME}
4245
# can use for npm install --global
4346
WORKDIR ${HOMEDIR}
4447
RUN mkdir ~/.npm-global
4548
RUN npm config set prefix '~/.npm-global'
4649

50+
# Yarn
51+
RUN npm install -g yarn
52+
4753
# Configure course-specific environment
4854
COPY . .
4955
WORKDIR ${HOMEDIR}

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2022, Shaun Hamilton
3+
Copyright (c) 2022-2023, freeCodeCamp
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
11
# freeCodeCamp: Solana Curriculum
2+
3+
Get started here: https://web3.freecodecamp.org/solana
4+
5+
## Projects
6+
7+
| Project | Description |
8+
| ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
9+
| Learn How to Set Up Solana by Building a Hello World Smart Contract | In this course, you will learn how to set up Solana by building a simple hello world contract. |
10+
| Learn How to Interact with On-Chain Programs | In this course, you will learn how to write the client code to interact with your previously deployed hello world smart contract. |
11+
| Build a Smart Contract | In this integrated project, you will use what you previously learnt to build a smart contract, and interact with it. |
12+
| Learn Solana's Token Program by Minting a Fungible Token | In this course, you will learn how to use Solana's token program by minting a fungible token. |
13+
| Learn the Metaplex SDK by Minting an NFT | In this course, you will learn how to use the Metaplex JS SDK to mint an NFT. |
14+
| Build a University Certification NFT | In this integrated project, you will use what you previously learnt to build out the logic for an NFT-issuing system for university certifications. |
15+
| Learn Anchor by Building Tic-Tac-Toe: Part 1 | In this course, you will learn how to use Anchor, a framework for building smart contracts on Solana, to build an on-chain Tic-Tac-Toe game. |
16+
| Learn Anchor by Building Tic-Tac-Toe: Part 2 | In this course, you will learn how to test the previously built Tic-Tac-Toe game. |
17+
| Build an Anchor Leaderboard | In this integrated project, you will use what you previously learnt to build the program logic for a game leaderboard |
18+
| More Coming Soon... | Keep an eye out for more projects on their way |

bash/.bashrc

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ for i in $(ls -A $HOME/.bashrc.d/); do source $HOME/.bashrc.d/$i; done
122122

123123
. "$HOME/.cargo/env"
124124

125+
export PATH="$HOME/.npm-global/bin:$PATH"
126+
125127
# freeCodeCamp - Needed for most tests to work
126128

127129
WD=/workspace/solana-curriculum
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
.anchor
3+
.DS_Store
4+
target
5+
**/*.rs.bk
6+
node_modules
7+
test-ledger
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
.anchor
3+
.DS_Store
4+
target
5+
node_modules
6+
dist
7+
build
8+
test-ledger
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[features]
2+
seeds = false
3+
skip-lint = false
4+
[programs.localnet]
5+
rock_destroyer = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
6+
7+
[registry]
8+
url = "https://api.apr.dev"
9+
10+
[provider]
11+
cluster = "Localnet"
12+
wallet = "~/.config/solana/id.json"
13+
14+
[scripts]
15+
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[workspace]
2+
members = [
3+
"programs/*"
4+
]
5+
6+
[profile.release]
7+
overflow-checks = true
8+
lto = "fat"
9+
codegen-units = 1
10+
[profile.release.build-override]
11+
opt-level = 3
12+
incremental = false
13+
codegen-units = 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Migrations are an early feature. Currently, they're nothing more than this
2+
// single deploy script that's invoked from the CLI, injecting a provider
3+
// configured from the workspace's Anchor.toml.
4+
5+
const anchor = require("@coral-xyz/anchor");
6+
7+
module.exports = async function (provider) {
8+
// Configure client to use the provider.
9+
anchor.setProvider(provider);
10+
11+
// Add your deploy script here.
12+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"scripts": {
3+
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
4+
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
5+
},
6+
"dependencies": {
7+
"@coral-xyz/anchor": "^0.27.0"
8+
},
9+
"devDependencies": {
10+
"chai": "^4.3.4",
11+
"mocha": "^9.0.3",
12+
"ts-mocha": "^10.0.0",
13+
"@types/bn.js": "^5.1.0",
14+
"@types/chai": "^4.3.0",
15+
"@types/mocha": "^9.0.0",
16+
"typescript": "^4.3.5",
17+
"prettier": "^2.6.2"
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "rock-destroyer"
3+
version = "0.1.0"
4+
description = "Created with Anchor"
5+
edition = "2021"
6+
7+
[lib]
8+
crate-type = ["cdylib", "lib"]
9+
name = "rock_destroyer"
10+
11+
[features]
12+
no-entrypoint = []
13+
no-idl = []
14+
no-log-ix-name = []
15+
cpi = ["no-entrypoint"]
16+
default = []
17+
18+
[dependencies]
19+
anchor-lang = "0.27.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.bpfel-unknown-unknown.dependencies.std]
2+
features = []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use anchor_lang::prelude::*;
2+
3+
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
4+
5+
#[program]
6+
pub mod rock_destroyer {
7+
use super::*;
8+
9+
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
10+
Ok(())
11+
}
12+
}
13+
14+
#[derive(Accounts)]
15+
pub struct Initialize {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as anchor from "@coral-xyz/anchor";
2+
import { Program } from "@coral-xyz/anchor";
3+
import { RockDestroyer } from "../target/types/rock_destroyer";
4+
5+
describe("rock-destroyer", () => {
6+
// Configure the client to use the local cluster.
7+
anchor.setProvider(anchor.AnchorProvider.env());
8+
9+
const program = anchor.workspace.RockDestroyer as Program<RockDestroyer>;
10+
11+
it("Is initialized!", async () => {
12+
// Add your test here.
13+
const tx = await program.methods.initialize().rpc();
14+
console.log("Your transaction signature", tx);
15+
});
16+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"types": ["mocha", "chai"],
4+
"typeRoots": ["./node_modules/@types"],
5+
"lib": ["es2015"],
6+
"module": "commonjs",
7+
"target": "es6",
8+
"esModuleInterop": true
9+
}
10+
}
11+

0 commit comments

Comments
 (0)