Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
add pda and cpi example on anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
URANI committed Mar 27, 2024
1 parent 9e6fa3c commit 68312b0
Show file tree
Hide file tree
Showing 30 changed files with 6,407 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* **[Demo 1: Hello World](demos/01_hello_world)**
* **[Demo 2. Anchor and CPI](demos/02_anchor_cpi)**
* **[Demo 3. Program Derived Addresses](demos/03_anchor_pda)**
* **[Demo 4: PDA and CPI on Anchor](demos/04_pda_and_cpi)**


<br>
Expand Down
6 changes: 6 additions & 0 deletions chapters/04_program_derived_addresses.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ pub struct UserStats {

<br>


* Learn how PDA and CPI works on Anchor through [demo 4](https://github.com/urani-labs/solana-dev-onboarding-rs/tree/main/demos/04_pda_and_cpi).

<br>


---

### References
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ declare_id!("DrL7fRZQKqF7GQuvzxYe4K6MV4inzodj8dhr1PPV8Fqr");
mod puppet_master {
use super::*;
pub fn pull_strings(ctx: Context<PullStrings>, data: u64) -> Result<()> {
puppet::cpi::set_data(ctx.accounts.set_data_ctx(), data)
puppet::cpi::set_data(ctx.accounts.set_data_ctx(),
data)
}
}

Expand Down
18 changes: 18 additions & 0 deletions demos/04_pda_and_cpi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 🛹 Demo 4: PDA and CPI on Anchor

<br>


* Build with both libraries, puppet and puppet-master, with:

```
anchor build
```

<br>

* And then run tests on puppet with:

```
anchor test
```
8 changes: 8 additions & 0 deletions demos/04_pda_and_cpi/puppet-master/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.anchor
.DS_Store
target
**/*.rs.bk
node_modules
test-ledger
.yarn
8 changes: 8 additions & 0 deletions demos/04_pda_and_cpi/puppet-master/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.anchor
.DS_Store
target
node_modules
dist
build
test-ledger
18 changes: 18 additions & 0 deletions demos/04_pda_and_cpi/puppet-master/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[toolchain]

[features]
seeds = false
skip-lint = false

[programs.localnet]
puppet_master = "5qPWqmiH7XAEyg14rqCm1LgmqhdT7DYsbnM5g2hZ2mVZ"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "Localnet"
wallet = "/Users/m/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
Loading

0 comments on commit 68312b0

Please sign in to comment.