Skip to content

Commit 936a368

Browse files
authored
Merge pull request #85 from solana-developers/add-favorites-and-escrow
Add favorites and escrow projects from professional-education repo
2 parents 2c4cb8f + 23bbb4f commit 936a368

35 files changed

+3518
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
# Program Examples
22

3-
### :crab: Rust. :snake: Python. :link: All on-chain.
3+
### Onchain program examples for :anchor: Anchor :crab: Native Rust and :snake: Python
44

55
## Navigating this Repo
66

77
:file_folder: Each example contains four folders:
88

9-
- `native` - Written using Solana's native Rust crates and vanilla Rust.
109
- `anchor` - Written using Anchor's `anchor_lang` Rust crate and the associated Anchor framework to build & deploy.
10+
- `native` - Written using Solana's native Rust crates and vanilla Rust.
1111
- `seahorse` - Written using the Python framework Seahorse, which converts your Python code to Anchor Rust.
1212

1313
:wrench: How to build & run:
1414

1515
- Before running anything in any folder make sure you pull in the dependencies with `yarn install`.
16-
- `native` - Use `cicd.sh` to build & deploy the program. Run `yarn run test` to test it.
1716
- `anchor` - Use `anchor build && anchor deploy` to build & deploy the program. Run `anchor run test` to test it.
17+
- `native` - Use `cicd.sh` to build & deploy the program. Run `yarn run test` to test it.
1818
- `seahorse` - Use `seahorse build && anchor deploy` to build & deploy the program. Run `anchor run test` to test it.
1919

2020
## Examples We'd Love to See!
2121

2222
- Examples needed for Native:
23-
- Token2022
23+
- Token Extensions
2424
- Examples needed for Anchor:
2525
- Additional Accounts & Resolving Accounts
2626
- Examples needed for Seahorse
2727
- Any existing example missing a `seahorse` folder
28-
- New examples needed for Solidity, Anchor, Native & Seahorse:
28+
- New examples needed for Anchor, Native, Solidity & Seahorse:
2929
- Token lending
3030
- Token swapping
3131
- Escrow

basics/favorites/anchor/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
.anchor
3+
.DS_Store
4+
target
5+
**/*.rs.bk
6+
node_modules
7+
test-ledger
8+
.yarn
9+
.env
Lines changed: 8 additions & 0 deletions
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

basics/favorites/anchor/Anchor.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[toolchain]
2+
3+
[features]
4+
resolution = true
5+
skip-lint = false
6+
7+
[programs.localnet]
8+
favorites = "ww9C83noARSQVBnqmCUmaVdbJjmiwcV9j2LkXYMoUCV"
9+
10+
[registry]
11+
url = "https://api.apr.dev"
12+
13+
[provider]
14+
cluster = "Localnet"
15+
wallet = "~/.config/solana/id.json"
16+
17+
[scripts]
18+
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

basics/favorites/anchor/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[workspace]
2+
members = [
3+
"programs/*"
4+
]
5+
resolver = "2"
6+
7+
[profile.release]
8+
overflow-checks = true
9+
lto = "fat"
10+
codegen-units = 1
11+
12+
[profile.release.build-override]
13+
opt-level = 3
14+
incremental = false
15+
codegen-units = 1

basics/favorites/anchor/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Favorites
2+
3+
This is a basic Anchor app using PDAs to store data for a user, and Anchor's account checks to ensure each user is only allowed to modify their own data.
4+
5+
It's used by the [https://github.com/solana-developers/professional-education](Solana Professional Education) course.
6+
7+
## Usage
8+
9+
`anchor test`, `anchor deploy` etc.
Lines changed: 12 additions & 0 deletions
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 (provider) => {
8+
// Configure client to use the provider.
9+
anchor.setProvider(provider);
10+
11+
// Add your deploy script here.
12+
};

basics/favorites/anchor/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.30.0",
8+
"@solana-developers/helpers": "^2.0.0"
9+
},
10+
"license": "MIT",
11+
"devDependencies": {
12+
"@types/bn.js": "^5.1.0",
13+
"@types/chai": "^4.3.0",
14+
"@types/mocha": "^9.0.0",
15+
"chai": "^4.3.4",
16+
"mocha": "^9.0.3",
17+
"prettier": "^2.6.2",
18+
"ts-mocha": "^10.0.0",
19+
"typescript": "^4.3.5"
20+
}
21+
}

0 commit comments

Comments
 (0)