Skip to content

Commit

Permalink
Merge branch 'master' into account-subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
kklas authored and AdithyaNarayan committed Jun 29, 2022
1 parent 340a495 commit 1264181
Show file tree
Hide file tree
Showing 174 changed files with 16,218 additions and 1,402 deletions.
564 changes: 281 additions & 283 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ adding documentation, fixing bugs, creating examples, and implementing features.
## Finding issues to work on

If you're looking to get started,
check out [good first issues](https://github.com/project-serum/anchor/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
or issues where [help is wanted](https://github.com/project-serum/anchor/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22).
check out [good first issues](https://github.com/coral-xyz/anchor/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
or issues where [help is wanted](https://github.com/coral-xyz/anchor/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22).
For simple documentation changes or typos, feel free to just open a pull request.

If you're considering larger changes or self motivated features, please file an issue
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img height="170x" src="https://media.discordapp.net/attachments/813444514949103658/890278520553603092/export.png?width=746&height=746" />
<img height="170x" src="https://pbs.twimg.com/media/FVUVaO9XEAAulvK?format=png&name=small" />

<h1>Anchor</h1>

Expand All @@ -8,10 +8,10 @@
</p>

<p>
<a href="https://github.com/project-serum/anchor/actions"><img alt="Build Status" src="https://github.com/project-serum/anchor/actions/workflows/tests.yaml/badge.svg" /></a>
<a href="https://project-serum.github.io/anchor/"><img alt="Tutorials" src="https://img.shields.io/badge/docs-tutorials-blueviolet" /></a>
<a href="https://github.com/coral-xyz/anchor/actions"><img alt="Build Status" src="https://github.com/coral-xyz/anchor/actions/workflows/tests.yaml/badge.svg" /></a>
<a href="https://coral-xyz.github.io/anchor/"><img alt="Tutorials" src="https://img.shields.io/badge/docs-tutorials-blueviolet" /></a>
<a href="https://discord.gg/PDeRXyVURd"><img alt="Discord Chat" src="https://img.shields.io/discord/889577356681945098?color=blueviolet" /></a>
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="License" src="https://img.shields.io/github/license/project-serum/anchor?color=blueviolet" /></a>
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="License" src="https://img.shields.io/github/license/coral-xyz/anchor?color=blueviolet" /></a>
</p>
</div>

Expand All @@ -26,8 +26,8 @@ If you're familiar with developing in Ethereum's [Solidity](https://docs.solidit

## Getting Started

For a quickstart guide and in depth tutorials, see the [anchor book](https://book.anchor-lang.com) and the older [documentation](https://project-serum.github.io/anchor/getting-started/introduction.html) that is being phased out.
To jump straight to examples, go [here](https://github.com/project-serum/anchor/tree/master/examples). For the latest Rust and TypeScript API documentation, see [docs.rs](https://docs.rs/anchor-lang) and the [typedoc](https://project-serum.github.io/anchor/ts/index.html).
For a quickstart guide and in depth tutorials, see the [anchor book](https://book.anchor-lang.com) and the older [documentation](https://coral-xyz.github.io/anchor/getting-started/introduction.html) that is being phased out.
To jump straight to examples, go [here](https://github.com/coral-xyz/anchor/tree/master/examples). For the latest Rust and TypeScript API documentation, see [docs.rs](https://docs.rs/anchor-lang) and the [typedoc](https://coral-xyz.github.io/anchor/ts/index.html).

## Packages

Expand All @@ -36,8 +36,8 @@ To jump straight to examples, go [here](https://github.com/project-serum/anchor/
| `anchor-lang` | Rust primitives for writing programs on Solana | [![Crates.io](https://img.shields.io/crates/v/anchor-lang?color=blue)](https://crates.io/crates/anchor-lang) | [![Docs.rs](https://docs.rs/anchor-lang/badge.svg)](https://docs.rs/anchor-lang) |
| `anchor-spl` | CPI clients for SPL programs on Solana | ![crates](https://img.shields.io/crates/v/anchor-spl?color=blue) | [![Docs.rs](https://docs.rs/anchor-spl/badge.svg)](https://docs.rs/anchor-spl) |
| `anchor-client` | Rust client for Anchor programs | ![crates](https://img.shields.io/crates/v/anchor-client?color=blue) | [![Docs.rs](https://docs.rs/anchor-client/badge.svg)](https://docs.rs/anchor-client) |
| `@project-serum/anchor` | TypeScript client for Anchor programs | [![npm](https://img.shields.io/npm/v/@project-serum/anchor.svg?color=blue)](https://www.npmjs.com/package/@project-serum/anchor) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://project-serum.github.io/anchor/ts/index.html) |
| `@project-serum/anchor-cli` | CLI to support building and managing an Anchor workspace | [![npm](https://img.shields.io/npm/v/@project-serum/anchor-cli.svg?color=blue)](https://www.npmjs.com/package/@project-serum/anchor-cli) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://project-serum.github.io/anchor/cli/commands.html) |
| `@project-serum/anchor` | TypeScript client for Anchor programs | [![npm](https://img.shields.io/npm/v/@project-serum/anchor.svg?color=blue)](https://www.npmjs.com/package/@project-serum/anchor) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://coral-xyz.github.io/anchor/ts/index.html) |
| `@project-serum/anchor-cli` | CLI to support building and managing an Anchor workspace | [![npm](https://img.shields.io/npm/v/@project-serum/anchor-cli.svg?color=blue)](https://www.npmjs.com/package/@project-serum/anchor-cli) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://coral-xyz.github.io/anchor/cli/commands.html) |

## Note

Expand Down Expand Up @@ -94,8 +94,8 @@ pub struct Counter {
}
```

For more, see the [examples](https://github.com/project-serum/anchor/tree/master/examples)
and [tests](https://github.com/project-serum/anchor/tree/master/tests) directories.
For more, see the [examples](https://github.com/coral-xyz/anchor/tree/master/examples)
and [tests](https://github.com/coral-xyz/anchor/tree/master/tests) directories.

## License

Expand All @@ -113,7 +113,7 @@ Please see the [CONTRIBUTING.md](./CONTRIBUTING.md) to learn how.
### Thanks ❤️

<div align="center">
<a href="https://github.com/project-serum/anchor/graphs/contributors">
<img src="https://contrib.rocks/image?repo=project-serum/anchor" width="100%" />
<a href="https://github.com/coral-xyz/anchor/graphs/contributors">
<img src="https://contrib.rocks/image?repo=coral-xyz/anchor" width="100%" />
</a>
</div>
6 changes: 3 additions & 3 deletions avm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn install_version(version: &Version, force: bool) -> Result<()> {
.args(&[
"install",
"--git",
"https://github.com/project-serum/anchor",
"https://github.com/coral-xyz/anchor",
"--tag",
&format!("v{}", &version),
"anchor-cli",
Expand Down Expand Up @@ -171,8 +171,8 @@ pub fn fetch_versions() -> Vec<semver::Version> {

let client = reqwest::blocking::Client::new();
let versions: Vec<Release> = client
.get("https://api.github.com/repos/project-serum/anchor/tags")
.header(USER_AGENT, "avm https://github.com/project-serum/anchor")
.get("https://api.github.com/repos/coral-xyz/anchor/tags")
.header(USER_AGENT, "avm https://github.com/coral-xyz/anchor")
.send()
.unwrap()
.json()
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.24.2"
authors = ["armaniferrante <armaniferrante@gmail.com>"]
rust-version = "1.56"
edition = "2021"
repository = "https://github.com/project-serum/anchor"
repository = "https://github.com/coral-xyz/anchor"
description = "Anchor CLI"
license = "Apache-2.0"

Expand Down
6 changes: 3 additions & 3 deletions cli/npm-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "@project-serum/anchor-cli",
"version": "0.24.2",
"description": "Anchor CLI tool",
"homepage": "https://github.com/project-serum/anchor#readme",
"homepage": "https://github.com/coral-xyz/anchor#readme",
"bugs": {
"url": "https://github.com/project-serum/anchor/issues"
"url": "https://github.com/coral-xyz/anchor/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/project-serum/anchor.git"
"url": "https://github.com/coral-xyz/anchor.git"
},
"license": "(MIT OR Apache-2.0)",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ pub struct RegistryConfig {
impl Default for RegistryConfig {
fn default() -> Self {
Self {
url: "https://anchor.projectserum.com".to_string(),
url: "https://api.apr.dev".to_string(),
}
}
}
Expand Down
90 changes: 73 additions & 17 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,24 +523,15 @@ fn init(cfg_override: &ConfigOverride, name: String, javascript: bool, no_git: b
return Err(anyhow!("Workspace already initialized"));
}

// The list is taken from https://doc.rust-lang.org/reference/keywords.html.
let key_words = [
"as", "break", "const", "continue", "crate", "else", "enum", "extern", "false", "fn",
"for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref",
"return", "self", "Self", "static", "struct", "super", "trait", "true", "type", "unsafe",
"use", "where", "while", "async", "await", "dyn", "abstract", "become", "box", "do",
"final", "macro", "override", "priv", "typeof", "unsized", "virtual", "yield", "try",
"unique",
];

if key_words.contains(&name[..].into()) {
return Err(anyhow!(
"{} is a reserved word in rust, name your project something else!",
name
));
} else if name.chars().next().unwrap().is_numeric() {
// Additional keywords that have not been added to the `syn` crate as reserved words
// https://github.com/dtolnay/syn/pull/1098
let extra_keywords = ["async", "await", "try"];
// Anchor converts to snake case before writing the program name
if syn::parse_str::<syn::Ident>(&name.to_snake_case()).is_err()
|| extra_keywords.contains(&name.to_snake_case().as_str())
{
return Err(anyhow!(
"Cannot start project name with numbers, name your project something else!"
"Anchor workspace name must be a valid Rust identifier. It may not be a Rust reserved word, start with a digit, or include certain disallowed characters. See https://doc.rust-lang.org/reference/identifiers.html for more detail.",
));
}

Expand Down Expand Up @@ -3256,3 +3247,68 @@ fn get_node_dns_option() -> Result<&'static str> {
};
Ok(option)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
#[should_panic(expected = "Anchor workspace name must be a valid Rust identifier.")]
fn test_init_reserved_word() {
init(
&ConfigOverride {
cluster: None,
wallet: None,
},
"await".to_string(),
true,
false,
)
.unwrap();
}

#[test]
#[should_panic(expected = "Anchor workspace name must be a valid Rust identifier.")]
fn test_init_reserved_word_from_syn() {
init(
&ConfigOverride {
cluster: None,
wallet: None,
},
"fn".to_string(),
true,
false,
)
.unwrap();
}

#[test]
#[should_panic(expected = "Anchor workspace name must be a valid Rust identifier.")]
fn test_init_invalid_ident_chars() {
init(
&ConfigOverride {
cluster: None,
wallet: None,
},
"project.name".to_string(),
true,
false,
)
.unwrap();
}

#[test]
#[should_panic(expected = "Anchor workspace name must be a valid Rust identifier.")]
fn test_init_starting_with_digit() {
init(
&ConfigOverride {
cluster: None,
wallet: None,
},
"1project".to_string(),
true,
false,
)
.unwrap();
}
}
2 changes: 1 addition & 1 deletion client/example/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Run this script from within the `example/` directory in which it is located.
# The anchor cli must be installed.
#
# cargo install --git https://github.com/project-serum/anchor anchor-cli --locked
# cargo install --git https://github.com/coral-xyz/anchor anchor-cli --locked
#
################################################################################

Expand Down
2 changes: 1 addition & 1 deletion docker/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ RUN . $NVM_DIR/nvm.sh && \
RUN sh -c "$(curl -sSfL https://release.solana.com/${SOLANA_CLI}/install)"

# Install anchor.
RUN cargo install --git https://github.com/project-serum/anchor --tag ${ANCHOR_CLI} anchor-cli --locked
RUN cargo install --git https://github.com/coral-xyz/anchor --tag ${ANCHOR_CLI} anchor-cli --locked

# Build a dummy program to bootstrap the BPF SDK (doing this speeds up builds).
RUN mkdir -p /tmp && cd tmp && anchor init dummy && cd dummy && anchor build
Expand Down
3 changes: 3 additions & 0 deletions docs/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NEXT_PUBLIC_DOCSEARCH_APP_ID=
NEXT_PUBLIC_DOCSEARCH_API_KEY=
NEXT_PUBLIC_DOCSEARCH_INDEX_NAME=
3 changes: 3 additions & 0 deletions docs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
45 changes: 34 additions & 11 deletions docs/.gitignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
pids
logs
node_modules
npm-debug.log
coverage/
run
dist
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
.nyc_output
.basement
config.local.js
basement_dist
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

.vscode/
.idea
20 changes: 20 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Anchor Docs

## Getting started

```bash
npm install
cp .env.example .env.local
```

Next, run the development server:

```bash
npm run dev
```

Finally, open [http://localhost:3000](http://localhost:3000) in your browser to view the website.

## Customizing

You can start editing this template by modifying the files in the `/src` folder. The site will auto-update as you edit these files.
8 changes: 8 additions & 0 deletions docs/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}
26 changes: 26 additions & 0 deletions docs/markdoc/nodes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Fence } from '@/components/Fence'

const nodes = {
document: {
render: undefined,
},
th: {
attributes: {
scope: {
type: String,
default: 'col',
},
},
render: (props) => <th {...props} />,
},
fence: {
render: Fence,
attributes: {
language: {
type: String,
},
},
},
}

export default nodes

0 comments on commit 1264181

Please sign in to comment.