소스 검색

Finish tutorial-1 draft

armaniferrante 4 년 전
부모
커밋
e5ab0684f8
34개의 변경된 파일2018개의 추가작업 그리고 153개의 파일을 삭제
  1. 2 0
      .gitignore
  2. 1 10
      Cargo.lock
  3. 0 1
      Cargo.toml
  4. 2 1
      cli/Cargo.toml
  5. 1 1
      cli/src/config.rs
  6. 19 6
      cli/src/main.rs
  7. 0 1
      docs/src/.vuepress/config.js
  8. 3 0
      docs/src/getting-started/installation.md
  9. 21 10
      docs/src/getting-started/quick-start.md
  10. 0 1
      docs/src/tutorials/README.md
  11. 60 18
      docs/src/tutorials/tutorial-0.md
  12. 74 5
      docs/src/tutorials/tutorial-1.md
  13. 0 1
      docs/src/tutorials/tutorial-3.md
  14. 2 0
      examples/tutorial/basic-0/Anchor.toml
  15. 849 0
      examples/tutorial/basic-0/Cargo.lock
  16. 4 0
      examples/tutorial/basic-0/Cargo.toml
  17. 0 25
      examples/tutorial/basic-0/app/client.js
  18. 6 8
      examples/tutorial/basic-0/client.js
  19. 0 11
      examples/tutorial/basic-0/idl.json
  20. 5 4
      examples/tutorial/basic-0/programs/basic-0/Cargo.toml
  21. 0 0
      examples/tutorial/basic-0/programs/basic-0/Xargo.toml
  22. 2 2
      examples/tutorial/basic-0/programs/basic-0/src/lib.rs
  23. 18 0
      examples/tutorial/basic-0/tests/basic-0.js
  24. 2 0
      examples/tutorial/basic-1/Anchor.toml
  25. 849 0
      examples/tutorial/basic-1/Cargo.lock
  26. 4 0
      examples/tutorial/basic-1/Cargo.toml
  27. 0 36
      examples/tutorial/basic-1/idl.json
  28. 5 4
      examples/tutorial/basic-1/programs/basic-1/Cargo.toml
  29. 0 0
      examples/tutorial/basic-1/programs/basic-1/Xargo.toml
  30. 1 1
      examples/tutorial/basic-1/programs/basic-1/src/lib.rs
  31. 83 0
      examples/tutorial/basic-1/tests/basic-1.js
  32. 3 2
      ts/package.json
  33. 2 1
      ts/src/workspace.ts
  34. 0 4
      ts/test/integration/basic.spec.ts

+ 2 - 0
.gitignore

@@ -6,3 +6,5 @@ target/
 *~
 *.swp
 *.swo
+.anchor
+test-ledger

+ 1 - 10
Cargo.lock

@@ -92,6 +92,7 @@ dependencies = [
  "serde_yaml",
  "serum-common",
  "shellexpand",
+ "solana-client",
  "solana-sdk",
  "syn 1.0.56",
  "toml",
@@ -210,16 +211,6 @@ version = "0.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
 
-[[package]]
-name = "basic-program-0"
-version = "0.1.0"
-dependencies = [
- "anchor",
- "borsh",
- "solana-program",
- "solana-sdk",
-]
-
 [[package]]
 name = "bincode"
 version = "1.3.1"

+ 0 - 1
Cargo.toml

@@ -25,5 +25,4 @@ members = [
     "attributes/*",
     "derive",
     "examples/basic",
-    "examples/tutorial/basic-0/program",
 ]

+ 2 - 1
cli/Cargo.toml

@@ -21,6 +21,7 @@ serde_yaml = "0.8"
 toml = "0.5.8"
 serde = { version = "1.0", features = ["derive"] }
 solana-sdk = "1.5.0"
+solana-client = "1.4.4"
 serum-common = { git = "https://github.com/project-serum/serum-dex", features = ["client"] }
 dirs = "3.0"
-heck = "0.3.1"
+heck = "0.3.1"

+ 1 - 1
cli/src/config.rs

@@ -87,7 +87,7 @@ impl FromStr for Config {
 
         Ok(Config {
             cluster: cfg.cluster.parse()?,
-            wallet: cfg.wallet.parse()?,
+            wallet: shellexpand::tilde(&cfg.wallet).parse()?,
         })
     }
 }

+ 19 - 6
cli/src/main.rs

@@ -3,6 +3,7 @@ use anchor_syn::idl::Idl;
 use anyhow::{anyhow, Result};
 use clap::Clap;
 use serde::{Deserialize, Serialize};
+use solana_client::rpc_client::RpcClient;
 use solana_sdk::pubkey::Pubkey;
 use std::fs::{self, File};
 use std::io::prelude::*;
@@ -266,10 +267,8 @@ fn test() -> Result<()> {
     let mut validator_handle = start_test_validator()?;
 
     // Deploy all programs.
-    let programs = deploy_ws(
-        "http://localhost:8899",
-        ".anchor/test-ledger/faucet-keypair.json",
-    )?;
+    let cfg = Config::discover()?.expect("Inside a workspace").0;
+    let programs = deploy_ws("http://localhost:8899", &cfg.wallet.to_string())?;
 
     // Store deployed program addresses in IDL metadata (for consumption by
     // client + tests).
@@ -329,8 +328,22 @@ fn start_test_validator() -> Result<Child> {
         .spawn()
         .map_err(|e| anyhow::format_err!("{}", e.to_string()))?;
 
-    // TODO: do something more sensible than sleeping.
-    std::thread::sleep(std::time::Duration::from_millis(2000));
+    // Wait for the validator to be ready.
+    let client = RpcClient::new("http://localhost:8899".to_string());
+    let mut count = 0;
+    let ms_wait = 5000;
+    while count < ms_wait {
+        let r = client.get_recent_blockhash();
+        if r.is_ok() {
+            break;
+        }
+        std::thread::sleep(std::time::Duration::from_millis(1));
+        count += 1;
+    }
+    if count == 5000 {
+        println!("Unable to start test validator.");
+        std::process::exit(1);
+    }
 
     Ok(validator_handle)
 }

+ 0 - 1
docs/src/.vuepress/config.js

@@ -53,7 +53,6 @@ module.exports = {
 					"/tutorials/tutorial-0",
 					"/tutorials/tutorial-1",
 					"/tutorials/tutorial-2",
-					"/tutorials/tutorial-3",
 				],
       },
     ],

+ 3 - 0
docs/src/getting-started/installation.md

@@ -42,3 +42,6 @@ To install the JavaScript package.
 ```bash
 npm install -g @project-serum/anchor
 ```
+
+Make sure your `NODE_PATH` is set properly so that globally installed modules
+can be resolved.

+ 21 - 10
docs/src/getting-started/quick-start.md

@@ -1,12 +1,11 @@
 # Quick Start
 
 The quick start provides a whirlwind tour through creating, deploying, and testing a project
-using Anchor, targeted at developers who are familiar with blockchain development. For an in depth
-guide of Anchor from the ground up, see the subequent tutorials.
+using Anchor. For an in depth guide building the Anchor workflow and DSL from the ground up,
+see the subequent tutorials.
 
 ## Initialize a project
 
-Anchor follows the principle of "Convention is better than configuration".
 To initialize your project workspace, run
 
 ```bash
@@ -22,13 +21,22 @@ Your repo will be laid out with the following structure
 
 ## Build
 
-To build your program targeting Solana's BPF runtime and emit an IDL that can be
-consumed by clients, run
+To build your program targeting Solana's BPF runtime and emit an IDL run
 
 ```bash
 anchor build
 ```
 
+You should see IDL files for all workspace programs in your `target/idl/` directory.
+
+## Deploy
+
+To deploy all programs in your workspace, run
+
+```
+anchor deploy
+```
+
 ## Test
 
 It's [recommended](https://www.parity.io/paritys-checklist-for-secure-smart-contract-development/)
@@ -40,13 +48,16 @@ are coverable with tests and not just replicated in tests.
 anchor test
 ```
 
-You just built a program, deployed it to a local network, and
-ran integration tests in one command. It's that easy. ;)
+Testing will build a program, deploy it to a local network, and
+run integration tests all in one command.
 
-## Deploy
+## New
 
-To deploy all programs in your workspace, run
+Anchor supports simulatenous development of multiple Solana programs.
+To create a new program in your workspace, run
 
 ```
-anchor deploy
+anchor new <program-name>
 ```
+
+You should see a new program in the `programs/` directory initialized with boilerplate.

+ 0 - 1
docs/src/tutorials/README.md

@@ -1 +0,0 @@
-## Tutorials

+ 60 - 18
docs/src/tutorials/tutorial-0.md

@@ -1,8 +1,7 @@
 # Tutorial 0: A Minimal Example
 
-Here, we introduce a minimal example demonstrating the Anchor workflow and core syntax
-elements. This tutorial assumes all [prerequisites](./prerequisites.md) are installed and
-a local network is running.
+Here, we introduce Anchor's core syntax elements and project workflow. This tutorial assumes all
+[prerequisites](./prerequisites.md) are installed.
 
 ## Clone the Repo
 
@@ -18,11 +17,19 @@ And change directories to the [example](https://github.com/project-serum/anchor/
 cd anchor/examples/tutorial/basic-0
 ```
 
+## Starting a Localnet
+
+In a seprate terminal, start a local network for testing.
+
+```
+solana-test-validator
+```
+
 ## Defining a Program
 
 We define the minimum viable program as follows.
 
-<<< @/../examples/tutorial/basic-0/program/src/lib.rs
+<<< @/../examples/tutorial/basic-0/programs/basic-0/src/lib.rs
 
 * `#[program]` First, notice that a program is defined with the `#[program]` attribute, where each
 inner method defines an RPC request handler, or, in Solana parlance, an "instruction"
@@ -53,11 +60,11 @@ anchor build
 The `build` command is a convenience combining two steps.
 
 1) `cargo build-bpf`
-2) `anchor idl -f src/lib.rs -o basic.json`.
+2) `anchor idl -f program/src/lib.rs -o target/idl/basic_0.json`.
 :::
 
 Once run, you should see your build artifacts, as usual, in your `target/` directory. Additionally,
-a `basic.json` file is created. Inspecting its contents you should see
+a `target/idl/basic_0.json` file is created. Inspecting its contents you should see
 
 ```json
 {
@@ -73,35 +80,70 @@ a `basic.json` file is created. Inspecting its contents you should see
 }
 ```
 
-From which a client can be generated. Note that this file is created by parsing the `src/lib.rs`
+From this file a client can be generated. Note that this file is created by parsing the `src/lib.rs`
 file in your program's crate.
 
 ::: tip
 If you've developed on Ethereum, the IDL is analogous to the `abi.json`.
 :::
 
-## Deploying a program
+## Deploying
 
-Once built, we can deploy the program using the `solana deploy` command.
+Once built, we can deploy the program by running
 
 ```bash
-solana deploy <path-to-your-repo>/anchor/target/deploy/basic_program_0.so
+anchor deploy
 ```
 
-Making sure to susbstitute paths to match your local filesystem. Now, save the address
-the program was deployed with. It will be useful later.
+Take note of program's deployed address. We'll use it next.
 
 ## Generating a Client
 
-Now that we have an IDL, we can use it to create a client.
+Now that we've built a program, deployed it to a local cluster, and generated an IDL,
+we can use the IDL to generate a client to speak to our on-chain program. For example,
+see [client.js](https://github.com/project-serum/anchor/tree/master/examples/tutorial/basic-0/client.js).
 
-<<< @/../examples/tutorial/basic-0/app/client.js#main
+<<< @/../examples/tutorial/basic-0/client.js#main
 
-Notice how the program dynamically created the `initialize` method under
+Notice how we dynamically created the `initialize` method under
 the `rpc` namespace.
 
+Before running, make sure to plugin your program's address into `<YOUR-PROGRAM-ID>`.
+
+```bash
+node client.js
+```
+
+## Workspaces
+
+So far we've seen the basics of how to create, deploy, and make RPCs to a program, but
+deploying a program, copy and pasting the address, and explicitly reading
+an IDL is all a bit tedious, and can easily get out of hand the more tests and the more
+programs you have. For this reason, we introduce the concept of a workspace.
+
+Inspecting [tests/basic_0.js](https://github.com/project-serum/anchor/tree/master/examples/tutorial/basic-0/tests/basic_0.js), we see the above example can be reduced to
+
+<<< @/../examples/tutorial/basic-0/tests/basic-0.js#code
+
+The `workspace` namespace provides access to all programs in the local project and is
+automatically updated to reflect the latest deployment, making it easy to change
+your program, update your JavaScript, and run your tests in a fast feedback loop.
+
+::: tip NOTE
+For now, the workspace feature is only available when running  the `anchor test` command,
+which will automatically `build`, `deploy`, and `test` all programs against a localnet
+in one command.
+:::
+
+Finally, we can run the test. Don't forget to kill the local validator started earlier.
+We won't need to start one manually for any future tutorials.
+
+```bash
+anchor test
+```
+
 ## Next Steps
 
-So far we've seen the basics of how to create, deploy, and make RPCs to a program on Solana
-using Anchor. But a program isn't all that interesting without interacting with it's
-peristent state, which is what we'll cover next.
+We've introduced the basic syntax of writing programs in Anchor along with a productive
+workflow for building and testing. However, programs aren't all that interesting without
+interacting with persistent state. We'll cover that next.

+ 74 - 5
docs/src/tutorials/tutorial-1.md

@@ -1,16 +1,85 @@
 # Tutorial 1: Accounts, Arguments, and Types
 
+This tutorial covers the basics of creating and mutating accounts using Anchor.
 It's recommended to read [Tutorial 0](./tutorial-0.md) first, as this tutorial will
 build on top of it. The full example can be found [here](https://github.com/project-serum/anchor/tree/master/examples/basic-1).
 
-## Defining a program
+## Clone the Repo
+
+To get started, clone the repo.
+
+```bash
+git clone https://github.com/project-serum/anchor
+```
+
+And change directories to the [example](https://github.com/project-serum/anchor/tree/master/examples/tutorial/basic-1).
+
+```bash
+cd anchor/examples/tutorial/basic-1
+```
+
+## Defining a Program
 
 We define our program as follows
 
-<<< @/../examples/tutorial/basic-1/program/src/lib.rs#program
+<<< @/../examples/tutorial/basic-1/programs/basic-1/src/lib.rs#program
 
 Some new syntax elements are introduced here.
 
-First notice, the `data` argument passed into the program. This argument any other valid
-Rust types can be passed to the instruction to define inputs to the program. Additionally,
-notice how we take a `mutable` reference to `my_account` and assign to it.
+First, notice the `data` argument passed into the program. This argument and any other valid
+Rust types can be passed to the instruction to define inputs to the program. If you'd like to
+pass in your own type, then it must be defined in the same `src/lib.rs` file as the
+`#[program]` module (so that the IDL can pick it up). Additionally,
+notice how we take a mutable reference to `my_account` and assign the `data` to it. This leads us
+the `Initialize` struct, deriving `Accounts`.
+
+There are two things to notice about `Initialize`. First, the
+`my_account` field is marked with the `#[account(mut)]` attribute. This means that any
+changes to the field will be persisted upon exiting the program. Second, the field is of
+type `ProgramAccount<'info, MyAccount>`, telling the program it *must* be **owned**
+by the currently executing program and the deserialized data structure is `MyAccount`.
+
+In a later tutorial we'll delve more deeply into deriving `Accounts`. For now, just know
+one must mark their accounts `mut` if they want them to, well, mutate. ;)
+
+## Creating and Initializing Accounts
+
+For a moment, assume an account of type `MyAccount` was created on Solana, in which case,
+we can invoke the above `initialize` instruction as follows.
+
+<<< @/../examples/tutorial/basic-1/tests/basic-1.js#code-separated
+
+The last element passed into the method is common amongst all dynamically generated
+methods on the `rpc` namespace, containing several options for a transaction. Here,
+we specifiy the `accounts` field, an object of all the addresses the transaction
+needs to touch.
+
+::: details
+If you've developed on Solana before, you might notice two things 1) the ordering of the accounts doesn't
+matter and 2) the `isWritable` and `isSigner`
+options are not specified on the account anywhere. In both cases, the framework takes care
+of these details for you, by reading the IDL.
+:::
+
+However it's common--and sometimes necessary for security purposes--to batch
+instructions together. We can extend the example above to both create an account
+and initialize it in one atomic transaction.
+
+<<< @/../examples/tutorial/basic-1/tests/basic-1.js#code
+
+Here, notice the **two** fields introduced: `signers` and `instructions`. `signers`
+is an array of all `Account` objects to sign the transaction and `instructions` is an
+array of all instructions to run **before** the explicitly specified program instruction,
+which in this case is `initialize`. Because we are creating `myAccount`, it needs to
+sign the transaction, as required by the Solana runtime.
+
+::: details
+In future work, we might want to add something like a *Builder* pattern for constructing
+common transactions like creating and then initializing an account.
+:::
+
+As before, we can run the example tests.
+
+```
+anchor test
+```

+ 0 - 1
docs/src/tutorials/tutorial-3.md

@@ -1 +0,0 @@
-# Tutorial 3: Workspaces

+ 2 - 0
examples/tutorial/basic-0/Anchor.toml

@@ -0,0 +1,2 @@
+cluster = "localnet"
+wallet = "~/.config/solana/id.json"

+ 849 - 0
examples/tutorial/basic-0/Cargo.lock

@@ -0,0 +1,849 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "aho-corasick"
+version = "0.7.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "anchor"
+version = "0.1.0"
+dependencies = [
+ "anchor-attributes-access-control",
+ "anchor-attributes-program",
+ "anchor-derive",
+ "borsh",
+ "solana-program",
+ "solana-sdk",
+ "thiserror",
+]
+
+[[package]]
+name = "anchor-attributes-access-control"
+version = "0.1.0"
+dependencies = [
+ "anchor-syn",
+ "anyhow",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "anchor-attributes-program"
+version = "0.1.0"
+dependencies = [
+ "anchor-syn",
+ "anyhow",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "anchor-derive"
+version = "0.1.0"
+dependencies = [
+ "anchor-syn",
+ "anyhow",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "anchor-syn"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "heck",
+ "proc-macro2",
+ "quote",
+ "serde",
+ "serde_json",
+ "syn",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86"
+
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
+
+[[package]]
+name = "basic-0"
+version = "0.1.0"
+dependencies = [
+ "anchor",
+ "borsh",
+ "solana-program",
+ "solana-sdk",
+]
+
+[[package]]
+name = "bincode"
+version = "1.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d"
+dependencies = [
+ "byteorder",
+ "serde",
+]
+
+[[package]]
+name = "block-buffer"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
+dependencies = [
+ "block-padding",
+ "byte-tools",
+ "byteorder",
+ "generic-array 0.12.3",
+]
+
+[[package]]
+name = "block-padding"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
+dependencies = [
+ "byte-tools",
+]
+
+[[package]]
+name = "borsh"
+version = "0.7.2"
+source = "git+https://github.com/project-serum/borsh?branch=serum#337732a185f052d5ee0424127b04b89d455ffa81"
+dependencies = [
+ "borsh-derive",
+ "solana-sdk",
+]
+
+[[package]]
+name = "borsh-derive"
+version = "0.7.2"
+source = "git+https://github.com/project-serum/borsh?branch=serum#337732a185f052d5ee0424127b04b89d455ffa81"
+dependencies = [
+ "borsh-derive-internal",
+ "borsh-schema-derive-internal",
+ "syn",
+]
+
+[[package]]
+name = "borsh-derive-internal"
+version = "0.7.2"
+source = "git+https://github.com/project-serum/borsh?branch=serum#337732a185f052d5ee0424127b04b89d455ffa81"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "borsh-schema-derive-internal"
+version = "0.7.2"
+source = "git+https://github.com/project-serum/borsh?branch=serum#337732a185f052d5ee0424127b04b89d455ffa81"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "bs58"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb"
+
+[[package]]
+name = "bv"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8834bb1d8ee5dc048ee3124f2c7c1afcc6bc9aed03f11e9dfd8c69470a5db340"
+dependencies = [
+ "feature-probe",
+ "serde",
+]
+
+[[package]]
+name = "byte-tools"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
+
+[[package]]
+name = "byteorder"
+version = "1.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
+
+[[package]]
+name = "cfg-if"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "crypto-mac"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5"
+dependencies = [
+ "generic-array 0.12.3",
+ "subtle 1.0.0",
+]
+
+[[package]]
+name = "curve25519-dalek"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5"
+dependencies = [
+ "byteorder",
+ "digest",
+ "rand_core",
+ "subtle 2.4.0",
+ "zeroize",
+]
+
+[[package]]
+name = "digest"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
+dependencies = [
+ "generic-array 0.12.3",
+]
+
+[[package]]
+name = "either"
+version = "1.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
+
+[[package]]
+name = "env_logger"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e"
+dependencies = [
+ "atty",
+ "humantime",
+ "log",
+ "regex",
+ "termcolor",
+]
+
+[[package]]
+name = "fake-simd"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
+
+[[package]]
+name = "feature-probe"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da"
+
+[[package]]
+name = "generic-array"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
+dependencies = [
+ "typenum",
+]
+
+[[package]]
+name = "generic-array"
+version = "0.14.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
+dependencies = [
+ "serde",
+ "typenum",
+ "version_check",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.1.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
+dependencies = [
+ "cfg-if 1.0.0",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "heck"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
+dependencies = [
+ "unicode-segmentation",
+]
+
+[[package]]
+name = "hermit-abi"
+version = "0.1.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "hex"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
+
+[[package]]
+name = "hmac"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695"
+dependencies = [
+ "crypto-mac",
+ "digest",
+]
+
+[[package]]
+name = "humantime"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a"
+
+[[package]]
+name = "itertools"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "0.4.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "libc"
+version = "0.2.81"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
+
+[[package]]
+name = "log"
+version = "0.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
+dependencies = [
+ "cfg-if 0.1.10",
+]
+
+[[package]]
+name = "memchr"
+version = "2.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
+
+[[package]]
+name = "memmap2"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b70ca2a6103ac8b665dc150b142ef0e4e89df640c9e6cf295d189c3caebe5a"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "num-derive"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "opaque-debug"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
+
+[[package]]
+name = "pbkdf2"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9"
+dependencies = [
+ "byteorder",
+ "crypto-mac",
+]
+
+[[package]]
+name = "ppv-lite86"
+version = "0.2.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
+dependencies = [
+ "unicode-xid",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rand"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
+dependencies = [
+ "getrandom",
+ "libc",
+ "rand_chacha",
+ "rand_core",
+ "rand_hc",
+]
+
+[[package]]
+name = "rand_chacha"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
+dependencies = [
+ "ppv-lite86",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
+name = "rand_hc"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
+dependencies = [
+ "rand_core",
+]
+
+[[package]]
+name = "regex"
+version = "1.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+ "thread_local",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.6.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
+
+[[package]]
+name = "rustc_version"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
+dependencies = [
+ "semver",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd"
+
+[[package]]
+name = "ryu"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
+
+[[package]]
+name = "semver"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
+dependencies = [
+ "semver-parser",
+]
+
+[[package]]
+name = "semver-parser"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
+
+[[package]]
+name = "serde"
+version = "1.0.118"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_bytes"
+version = "0.11.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.118"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.61"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "sha2"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69"
+dependencies = [
+ "block-buffer",
+ "digest",
+ "fake-simd",
+ "opaque-debug",
+]
+
+[[package]]
+name = "solana-frozen-abi"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2cc29ffc04200709ae0ece6a6a4a78d97043537e0cf70fa36a0cec200140e893"
+dependencies = [
+ "bs58",
+ "bv",
+ "generic-array 0.14.4",
+ "log",
+ "memmap2",
+ "rustc_version",
+ "serde",
+ "serde_derive",
+ "sha2",
+ "solana-frozen-abi-macro",
+ "solana-logger",
+ "thiserror",
+]
+
+[[package]]
+name = "solana-frozen-abi-macro"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9351c5355512afadaa64225d0653b050c768a7d5938429bff8a2e7c17143429f"
+dependencies = [
+ "lazy_static",
+ "proc-macro2",
+ "quote",
+ "rustc_version",
+ "syn",
+]
+
+[[package]]
+name = "solana-logger"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "188a6e6d7e001336d00ece746ecbd4b5e5ff1a12397c456934d831288f99b23d"
+dependencies = [
+ "env_logger",
+ "lazy_static",
+ "log",
+]
+
+[[package]]
+name = "solana-program"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c16bdd751d5549716a610f87b8ab1ca13ceaf66dfc9f325440894a72eadb74e"
+dependencies = [
+ "bincode",
+ "bs58",
+ "bv",
+ "curve25519-dalek",
+ "hex",
+ "itertools",
+ "lazy_static",
+ "log",
+ "num-derive",
+ "num-traits",
+ "rand",
+ "rustc_version",
+ "rustversion",
+ "serde",
+ "serde_bytes",
+ "serde_derive",
+ "sha2",
+ "solana-frozen-abi",
+ "solana-frozen-abi-macro",
+ "solana-logger",
+ "solana-sdk-macro",
+ "thiserror",
+]
+
+[[package]]
+name = "solana-sdk"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "280fa9cef4fdb9154fea538ed1efdc74215b3734a4ad611ddb1393269efac1bb"
+dependencies = [
+ "bincode",
+ "bs58",
+ "bv",
+ "hex",
+ "hmac",
+ "itertools",
+ "lazy_static",
+ "log",
+ "num-derive",
+ "num-traits",
+ "pbkdf2",
+ "rustc_version",
+ "rustversion",
+ "serde",
+ "serde_bytes",
+ "serde_derive",
+ "sha2",
+ "solana-frozen-abi",
+ "solana-frozen-abi-macro",
+ "solana-program",
+ "solana-sdk-macro",
+ "thiserror",
+]
+
+[[package]]
+name = "solana-sdk-macro"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11489c157e78f60ad9d4a96dc4d1955ef6936ef606f6ce0273689fcdb90391c2"
+dependencies = [
+ "bs58",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "syn",
+]
+
+[[package]]
+name = "subtle"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee"
+
+[[package]]
+name = "subtle"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
+
+[[package]]
+name = "syn"
+version = "1.0.57"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4211ce9909eb971f111059df92c45640aad50a619cf55cd76476be803c4c68e6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "thread_local"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
+dependencies = [
+ "lazy_static",
+]
+
+[[package]]
+name = "typenum"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
+
+[[package]]
+name = "unicode-segmentation"
+version = "1.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
+
+[[package]]
+name = "version_check"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
+
+[[package]]
+name = "wasi"
+version = "0.9.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "zeroize"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36"

+ 4 - 0
examples/tutorial/basic-0/Cargo.toml

@@ -0,0 +1,4 @@
+[workspace]
+members = [
+  "programs/*"
+]

+ 0 - 25
examples/tutorial/basic-0/app/client.js

@@ -1,25 +0,0 @@
-// Before running this script, make sure to run `yarn && yarn build` inside
-// the `ts` directory.
-const anchor = require('../../../../ts');
-const fs = require('fs');
-
-// Configure the local cluster.
-anchor.setProvider(anchor.Provider.local());
-
-// #region main
-async function main() {
-  // Read the generated IDL.
-  const idl = JSON.parse(fs.readFileSync('../idl.json', 'utf8'));
-
-  // Address of the deployed program.
-  const programId = new anchor.web3.PublicKey('<YOUR-PROGRAM-ID>');
-
-  // Generate the program client from IDL.
-  const program = new anchor.Program(idl, programId);
-
-  // Execute the RPC.
-  await program.rpc.initialize();
-}
-// #endregion main
-
-main();

+ 6 - 8
examples/tutorial/basic-1/app/client.js → examples/tutorial/basic-0/client.js

@@ -1,15 +1,12 @@
-// Before running this script, make sure to run `yarn && yarn build` inside
-// the `ts` directory.
-const anchor = require('../../../../ts');
-const fs = require('fs');
+const anchor = require('@project-serum/anchor');
 
 // Configure the local cluster.
 anchor.setProvider(anchor.Provider.local());
 
-// #region main
 async function main() {
+  // #region main
   // Read the generated IDL.
-  const idl = JSON.parse(fs.readFileSync('../idl.json', 'utf8'));
+  const idl = JSON.parse(require('fs').readFileSync('./target/idl/basic_0.json', 'utf8'));
 
   // Address of the deployed program.
   const programId = new anchor.web3.PublicKey('<YOUR-PROGRAM-ID>');
@@ -19,7 +16,8 @@ async function main() {
 
   // Execute the RPC.
   await program.rpc.initialize();
+  // #endregion main
 }
-// #endregion main
 
-main();
+console.log('Running client.');
+main().then(() => console.log('Success'));

+ 0 - 11
examples/tutorial/basic-0/idl.json

@@ -1,11 +0,0 @@
-{
-  "version": "0.0.0",
-  "name": "basic",
-  "instructions": [
-    {
-      "name": "initialize",
-      "accounts": [],
-      "args": []
-    }
-  ]
-}

+ 5 - 4
examples/tutorial/basic-0/program/Cargo.toml → examples/tutorial/basic-0/programs/basic-0/Cargo.toml

@@ -1,15 +1,16 @@
 [package]
-name = "basic-program-0"
+name = "basic-0"
 version = "0.1.0"
-description = "A minimal example of an anchor program"
+description = "Created with Anchor"
 edition = "2018"
 
 [lib]
 crate-type = ["cdylib"]
-name = "basic_program_0"
+name = "basic_0"
 
 [dependencies]
 borsh = { git = "https://github.com/project-serum/borsh", branch = "serum", features = ["serum-program"] }
 solana-program = "1.4.3"
 solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
-anchor = { path = "../../../../", features = ["derive"] }
+# anchor = { git = "https://github.com/project-serum/anchor", features = ["derive"] }
+anchor = { path = "/home/armaniferrante/Documents/code/src/github.com/project-serum/anchor", features = ["derive"] }

+ 0 - 0
examples/tutorial/basic-0/program/Xargo.toml → examples/tutorial/basic-0/programs/basic-0/Xargo.toml


+ 2 - 2
examples/tutorial/basic-0/program/src/lib.rs → examples/tutorial/basic-0/programs/basic-0/src/lib.rs

@@ -3,7 +3,7 @@
 use anchor::prelude::*;
 
 #[program]
-mod basic {
+mod basic_0 {
    use super::*;
    pub fn initialize(ctx: Context<Initialize>) -> ProgramResult {
        Ok(())
@@ -11,4 +11,4 @@ mod basic {
 }
 
 #[derive(Accounts)]
-pub struct Initialize {}
+pub struct Initialize {}

+ 18 - 0
examples/tutorial/basic-0/tests/basic-0.js

@@ -0,0 +1,18 @@
+const anchor = require('@project-serum/anchor');
+const fs = require('fs');
+
+describe('basic-0', () => {
+
+  // Configure the client to use the local cluster.
+  anchor.setProvider(anchor.Provider.local());
+
+  it('Uses the workspace to invoke the initialize instruction', async () => {
+    // #region code
+    // Read the deployed program from the workspace.
+    const program = anchor.workspace.Basic0;
+
+    // Execute the RPC.
+    await program.rpc.initialize();
+   // #endregion code
+  });
+});

+ 2 - 0
examples/tutorial/basic-1/Anchor.toml

@@ -0,0 +1,2 @@
+cluster = "localnet"
+wallet = "/home/armaniferrante/.config/solana/id.json"

+ 849 - 0
examples/tutorial/basic-1/Cargo.lock

@@ -0,0 +1,849 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "aho-corasick"
+version = "0.7.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "anchor"
+version = "0.1.0"
+dependencies = [
+ "anchor-attributes-access-control",
+ "anchor-attributes-program",
+ "anchor-derive",
+ "borsh",
+ "solana-program",
+ "solana-sdk",
+ "thiserror",
+]
+
+[[package]]
+name = "anchor-attributes-access-control"
+version = "0.1.0"
+dependencies = [
+ "anchor-syn",
+ "anyhow",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "anchor-attributes-program"
+version = "0.1.0"
+dependencies = [
+ "anchor-syn",
+ "anyhow",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "anchor-derive"
+version = "0.1.0"
+dependencies = [
+ "anchor-syn",
+ "anyhow",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "anchor-syn"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "heck",
+ "proc-macro2",
+ "quote",
+ "serde",
+ "serde_json",
+ "syn",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86"
+
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
+
+[[package]]
+name = "basic-1"
+version = "0.1.0"
+dependencies = [
+ "anchor",
+ "borsh",
+ "solana-program",
+ "solana-sdk",
+]
+
+[[package]]
+name = "bincode"
+version = "1.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d"
+dependencies = [
+ "byteorder",
+ "serde",
+]
+
+[[package]]
+name = "block-buffer"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
+dependencies = [
+ "block-padding",
+ "byte-tools",
+ "byteorder",
+ "generic-array 0.12.3",
+]
+
+[[package]]
+name = "block-padding"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
+dependencies = [
+ "byte-tools",
+]
+
+[[package]]
+name = "borsh"
+version = "0.7.2"
+source = "git+https://github.com/project-serum/borsh?branch=serum#337732a185f052d5ee0424127b04b89d455ffa81"
+dependencies = [
+ "borsh-derive",
+ "solana-sdk",
+]
+
+[[package]]
+name = "borsh-derive"
+version = "0.7.2"
+source = "git+https://github.com/project-serum/borsh?branch=serum#337732a185f052d5ee0424127b04b89d455ffa81"
+dependencies = [
+ "borsh-derive-internal",
+ "borsh-schema-derive-internal",
+ "syn",
+]
+
+[[package]]
+name = "borsh-derive-internal"
+version = "0.7.2"
+source = "git+https://github.com/project-serum/borsh?branch=serum#337732a185f052d5ee0424127b04b89d455ffa81"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "borsh-schema-derive-internal"
+version = "0.7.2"
+source = "git+https://github.com/project-serum/borsh?branch=serum#337732a185f052d5ee0424127b04b89d455ffa81"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "bs58"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb"
+
+[[package]]
+name = "bv"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8834bb1d8ee5dc048ee3124f2c7c1afcc6bc9aed03f11e9dfd8c69470a5db340"
+dependencies = [
+ "feature-probe",
+ "serde",
+]
+
+[[package]]
+name = "byte-tools"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
+
+[[package]]
+name = "byteorder"
+version = "1.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
+
+[[package]]
+name = "cfg-if"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "crypto-mac"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5"
+dependencies = [
+ "generic-array 0.12.3",
+ "subtle 1.0.0",
+]
+
+[[package]]
+name = "curve25519-dalek"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5"
+dependencies = [
+ "byteorder",
+ "digest",
+ "rand_core",
+ "subtle 2.4.0",
+ "zeroize",
+]
+
+[[package]]
+name = "digest"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
+dependencies = [
+ "generic-array 0.12.3",
+]
+
+[[package]]
+name = "either"
+version = "1.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
+
+[[package]]
+name = "env_logger"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e"
+dependencies = [
+ "atty",
+ "humantime",
+ "log",
+ "regex",
+ "termcolor",
+]
+
+[[package]]
+name = "fake-simd"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
+
+[[package]]
+name = "feature-probe"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da"
+
+[[package]]
+name = "generic-array"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
+dependencies = [
+ "typenum",
+]
+
+[[package]]
+name = "generic-array"
+version = "0.14.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
+dependencies = [
+ "serde",
+ "typenum",
+ "version_check",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.1.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
+dependencies = [
+ "cfg-if 1.0.0",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "heck"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
+dependencies = [
+ "unicode-segmentation",
+]
+
+[[package]]
+name = "hermit-abi"
+version = "0.1.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "hex"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
+
+[[package]]
+name = "hmac"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695"
+dependencies = [
+ "crypto-mac",
+ "digest",
+]
+
+[[package]]
+name = "humantime"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a"
+
+[[package]]
+name = "itertools"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "0.4.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "libc"
+version = "0.2.81"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
+
+[[package]]
+name = "log"
+version = "0.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
+dependencies = [
+ "cfg-if 0.1.10",
+]
+
+[[package]]
+name = "memchr"
+version = "2.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
+
+[[package]]
+name = "memmap2"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b70ca2a6103ac8b665dc150b142ef0e4e89df640c9e6cf295d189c3caebe5a"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "num-derive"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "opaque-debug"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
+
+[[package]]
+name = "pbkdf2"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9"
+dependencies = [
+ "byteorder",
+ "crypto-mac",
+]
+
+[[package]]
+name = "ppv-lite86"
+version = "0.2.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
+dependencies = [
+ "unicode-xid",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rand"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
+dependencies = [
+ "getrandom",
+ "libc",
+ "rand_chacha",
+ "rand_core",
+ "rand_hc",
+]
+
+[[package]]
+name = "rand_chacha"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
+dependencies = [
+ "ppv-lite86",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
+name = "rand_hc"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
+dependencies = [
+ "rand_core",
+]
+
+[[package]]
+name = "regex"
+version = "1.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+ "thread_local",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.6.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
+
+[[package]]
+name = "rustc_version"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
+dependencies = [
+ "semver",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd"
+
+[[package]]
+name = "ryu"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
+
+[[package]]
+name = "semver"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
+dependencies = [
+ "semver-parser",
+]
+
+[[package]]
+name = "semver-parser"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
+
+[[package]]
+name = "serde"
+version = "1.0.118"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_bytes"
+version = "0.11.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.118"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.61"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "sha2"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69"
+dependencies = [
+ "block-buffer",
+ "digest",
+ "fake-simd",
+ "opaque-debug",
+]
+
+[[package]]
+name = "solana-frozen-abi"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2cc29ffc04200709ae0ece6a6a4a78d97043537e0cf70fa36a0cec200140e893"
+dependencies = [
+ "bs58",
+ "bv",
+ "generic-array 0.14.4",
+ "log",
+ "memmap2",
+ "rustc_version",
+ "serde",
+ "serde_derive",
+ "sha2",
+ "solana-frozen-abi-macro",
+ "solana-logger",
+ "thiserror",
+]
+
+[[package]]
+name = "solana-frozen-abi-macro"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9351c5355512afadaa64225d0653b050c768a7d5938429bff8a2e7c17143429f"
+dependencies = [
+ "lazy_static",
+ "proc-macro2",
+ "quote",
+ "rustc_version",
+ "syn",
+]
+
+[[package]]
+name = "solana-logger"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "188a6e6d7e001336d00ece746ecbd4b5e5ff1a12397c456934d831288f99b23d"
+dependencies = [
+ "env_logger",
+ "lazy_static",
+ "log",
+]
+
+[[package]]
+name = "solana-program"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c16bdd751d5549716a610f87b8ab1ca13ceaf66dfc9f325440894a72eadb74e"
+dependencies = [
+ "bincode",
+ "bs58",
+ "bv",
+ "curve25519-dalek",
+ "hex",
+ "itertools",
+ "lazy_static",
+ "log",
+ "num-derive",
+ "num-traits",
+ "rand",
+ "rustc_version",
+ "rustversion",
+ "serde",
+ "serde_bytes",
+ "serde_derive",
+ "sha2",
+ "solana-frozen-abi",
+ "solana-frozen-abi-macro",
+ "solana-logger",
+ "solana-sdk-macro",
+ "thiserror",
+]
+
+[[package]]
+name = "solana-sdk"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "280fa9cef4fdb9154fea538ed1efdc74215b3734a4ad611ddb1393269efac1bb"
+dependencies = [
+ "bincode",
+ "bs58",
+ "bv",
+ "hex",
+ "hmac",
+ "itertools",
+ "lazy_static",
+ "log",
+ "num-derive",
+ "num-traits",
+ "pbkdf2",
+ "rustc_version",
+ "rustversion",
+ "serde",
+ "serde_bytes",
+ "serde_derive",
+ "sha2",
+ "solana-frozen-abi",
+ "solana-frozen-abi-macro",
+ "solana-program",
+ "solana-sdk-macro",
+ "thiserror",
+]
+
+[[package]]
+name = "solana-sdk-macro"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11489c157e78f60ad9d4a96dc4d1955ef6936ef606f6ce0273689fcdb90391c2"
+dependencies = [
+ "bs58",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "syn",
+]
+
+[[package]]
+name = "subtle"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee"
+
+[[package]]
+name = "subtle"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
+
+[[package]]
+name = "syn"
+version = "1.0.57"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4211ce9909eb971f111059df92c45640aad50a619cf55cd76476be803c4c68e6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "thread_local"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
+dependencies = [
+ "lazy_static",
+]
+
+[[package]]
+name = "typenum"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
+
+[[package]]
+name = "unicode-segmentation"
+version = "1.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
+
+[[package]]
+name = "version_check"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
+
+[[package]]
+name = "wasi"
+version = "0.9.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "zeroize"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36"

+ 4 - 0
examples/tutorial/basic-1/Cargo.toml

@@ -0,0 +1,4 @@
+[workspace]
+members = [
+  "programs/*"
+]

+ 0 - 36
examples/tutorial/basic-1/idl.json

@@ -1,36 +0,0 @@
-{
-  "version": "0.0.0",
-  "name": "basic_0",
-  "instructions": [
-    {
-      "name": "initialize",
-      "accounts": [
-        {
-          "name": "myAccount",
-          "isMut": true,
-          "isSigner": false
-        }
-      ],
-      "args": [
-        {
-          "name": "data",
-          "type": "u64"
-        }
-      ]
-    }
-  ],
-  "accounts": [
-    {
-      "name": "MyAccount",
-      "type": {
-        "kind": "struct",
-        "fields": [
-          {
-            "name": "data",
-            "type": "u64"
-          }
-        ]
-      }
-    }
-  ]
-}

+ 5 - 4
examples/tutorial/basic-1/program/Cargo.toml → examples/tutorial/basic-1/programs/basic-1/Cargo.toml

@@ -1,15 +1,16 @@
 [package]
-name = "basic-program-0"
+name = "basic-1"
 version = "0.1.0"
-description = "A minimal example of an anchor program"
+description = "Created with Anchor"
 edition = "2018"
 
 [lib]
 crate-type = ["cdylib"]
-name = "basic_program_0"
+name = "basic_1"
 
 [dependencies]
 borsh = { git = "https://github.com/project-serum/borsh", branch = "serum", features = ["serum-program"] }
 solana-program = "1.4.3"
 solana-sdk = { version = "1.3.14", default-features = false, features = ["program"] }
-anchor = { path = "../../../", features = ["derive"] }
+# anchor = { git = "https://github.com/project-serum/anchor", features = ["derive"] }
+anchor = { path = "/home/armaniferrante/Documents/code/src/github.com/project-serum/anchor", features = ["derive"] }

+ 0 - 0
examples/tutorial/basic-1/program/Xargo.toml → examples/tutorial/basic-1/programs/basic-1/Xargo.toml


+ 1 - 1
examples/tutorial/basic-1/program/src/lib.rs → examples/tutorial/basic-1/programs/basic-1/src/lib.rs

@@ -3,7 +3,7 @@
 use anchor::prelude::*;
 
 #[program]
-mod basic {
+mod basic_1 {
     use super::*;
 
     pub fn initialize(ctx: Context<Initialize>, data: u64) -> ProgramResult {

+ 83 - 0
examples/tutorial/basic-1/tests/basic-1.js

@@ -0,0 +1,83 @@
+const assert = require('assert');
+const anchor = require('/home/armaniferrante/Documents/code/src/github.com/project-serum/anchor/ts');
+
+describe('basic-1', () => {
+
+  // Use a local provider.
+  const provider = anchor.Provider.local()
+
+  // Configure the client to use the local cluster.
+  anchor.setProvider(provider);
+
+  it('Creates and initializes an account in two different transactions', async () => {
+    // The program owning the account to create.
+    const program = anchor.workspace.Basic1;
+
+    // The Account to create.
+    const myAccount = new anchor.web3.Account();
+
+    // Create account transaction.
+    const tx = new anchor.web3.Transaction();
+    tx.add(
+      anchor.web3.SystemProgram.createAccount({
+        fromPubkey: provider.wallet.publicKey,
+        newAccountPubkey: myAccount.publicKey,
+        space: 8,
+        lamports: await provider.connection.getMinimumBalanceForRentExemption(8),
+        programId: program.programId,
+      }),
+    );
+
+    // Execute the transaction against the cluster.
+    await provider.send(tx, [myAccount]);
+
+    // Execute the RPC.
+    // #region code-separated
+    await program.rpc.initialize(new anchor.BN(1234), {
+      accounts: {
+        myAccount: myAccount.publicKey,
+      },
+    });
+    // #endregion code-separated
+
+    // Fetch the newly created account from the cluster.
+    const account = await program.account.myAccount(myAccount.publicKey);
+
+    // Check it's state was initialized.
+    assert.ok(account.data.eq(new anchor.BN(1234)));
+  });
+
+
+  it('Creates and initializes an account in a single atomic transaction', async () => {
+    // The program to execute.
+    const program = anchor.workspace.Basic1;
+
+    // #region code
+    // The Account to create.
+    const myAccount = new anchor.web3.Account();
+
+    // Atomically create the new account and initialize it with the program.
+    await program.rpc.initialize(new anchor.BN(1234), {
+      accounts: {
+        myAccount: myAccount.publicKey,
+      },
+      signers: [myAccount],
+      instructions: [
+        anchor.web3.SystemProgram.createAccount({
+          fromPubkey: provider.wallet.publicKey,
+          newAccountPubkey: myAccount.publicKey,
+          space: 8,
+          lamports: await provider.connection.getMinimumBalanceForRentExemption(8),
+          programId: program.programId,
+        }),
+      ],
+    });
+
+    // Fetch the newly created account from the cluster.
+    const account = await program.account.myAccount(myAccount.publicKey);
+
+    // Check it's state was initialized.
+    assert.ok(account.data.eq(new anchor.BN(1234)));
+    // #endregion code
+  });
+});

+ 3 - 2
ts/package.json

@@ -1,9 +1,10 @@
 {
-  "name": "anchor",
-  "version": "0.0.0",
+  "name": "@project-serum/anchor",
+  "version": "0.0.0-alpha.0",
   "description": "Anchor client",
   "main": "dist/cjs/index.js",
   "module": "dist/esm/index.js",
+  "license": "(MIT OR Apache-2.0)",
   "types": "dist/index.d.ts",
   "publishConfig": {
     "access": "public"

+ 2 - 1
ts/src/workspace.ts

@@ -1,4 +1,5 @@
 import camelCase from "camelcase";
+import { PublicKey } from '@solana/web3.js';
 import { Program } from './program';
 
 let _populatedWorkspace = false;
@@ -44,7 +45,7 @@ export default new Proxy({} as any, {
             const idlStr = fs.readFileSync(path);
             const idl = JSON.parse(idlStr);
 						const name = camelCase(idl.name, { pascalCase: true });
-            programs[name] = new Program(idl, idl.metadata.address);
+            programs[name] = new Program(idl, new PublicKey(idl.metadata.address));
             return programs;
           }, workspaceCache);
 

+ 0 - 4
ts/test/integration/basic.spec.ts

@@ -10,10 +10,6 @@ const WORKSPACE = {
 };
 
 describe('Constraints program tests', () => {
-	it('Parses a workspace', async () => {
-
-	});
-
   it('Runs against a localnetwork', async () => {
     // Configure the local cluster.
     anchor.setProvider(WORKSPACE.provider);