Compare commits

...

4 Commits

Author SHA1 Message Date
Matthew Callens 205e9d875f
fix more dead links (#2078) 2022-07-20 09:10:41 -04:00
Matthew Callens 9d15c99e07
update doc links to new anchor website (#2069) 2022-07-19 12:53:20 -04:00
Pierre bd54c2b128
fix: return err on test result err (#2068) 2022-07-19 12:08:21 -04:00
Matthew Callens fc3789520e
fix new clippy warnings for cicd (#2075) 2022-07-19 12:07:20 -04:00
6 changed files with 20 additions and 17 deletions

View File

@ -9,7 +9,7 @@
<p>
<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://anchor-lang.com"><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/coral-xyz/anchor?color=blueviolet" /></a>
</p>
@ -26,17 +26,17 @@ 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://coral-xyz.github.io/anchor/getting-started/introduction.html) that is being phased out.
For a quickstart guide and in depth tutorials, see the [anchor book](https://book.anchor-lang.com) and the older [documentation](https://anchor-lang.com) 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
| Package | Description | Version | Docs |
| :-- | :-- | :--| :-- |
| `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://coral-xyz.github.io/anchor/ts/index.html) |
| Package | Description | Version | Docs |
| :-------------------------- | :------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------- |
| `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://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

View File

@ -2031,7 +2031,8 @@ fn run_test_suite(
}
}
Err(err) => {
println!("Failed to run test: {:#}", err)
println!("Failed to run test: {:#}", err);
return Err(err);
}
}

View File

@ -4,6 +4,7 @@ use anchor_syn::idl::Idl;
use anyhow::Result;
use heck::{CamelCase, MixedCase, SnakeCase};
use solana_sdk::pubkey::Pubkey;
use std::fmt::Write;
pub fn default_program_id() -> Pubkey {
"Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
@ -368,14 +369,15 @@ anchor.setProvider(provider);
);
for program in programs {
eval_string.push_str(&format!(
write!(
&mut eval_string,
r#"
anchor.workspace.{} = new anchor.Program({}, new PublicKey("{}"), provider);
"#,
program.name.to_camel_case(),
serde_json::to_string(&program.idl)?,
program.program_id
));
)?;
}
Ok(eval_string)

View File

@ -5,7 +5,7 @@ description: Anchor - Errors
> [`AnchorError` Rust Reference](https://docs.rs/anchor-lang/latest/anchor_lang/error/struct.AnchorError.html)
> [`AnchorError` Typescript Reference](https://project-serum.github.io/anchor/ts/classes/AnchorError.html)
> [`AnchorError` Typescript Reference](https://coral-xyz.github.io/anchor/ts/classes/AnchorError.html)
There are two types of errors in anchor programs. AnchorErrors and non-anchor errors.
AnchorErrors can be divided into Anchor Internal Errors that the framework returns from inside its own code or
@ -16,7 +16,7 @@ custom errors which the user (you!) can return.
- Custom Errors
- Non-anchor errors.
[AnchorErrors](https://docs.rs/anchor-lang/latest/anchor_lang/error/struct.AnchorError.html) provide a range of information like the error name and number or the location in the code where the anchor was thrown, or the account that violated a constraint (e.g. a `mut` constraint). Once thrown inside the program, [you can access the error information](https://project-serum.github.io/anchor/ts/classes/AnchorError.html) in the anchor clients like the typescript client. The typescript client also enriches the error with additional information about which program the error was thrown in and the CPI calls (which are explained [here](./cross-program-invocations) in the book) that led to the program from which the error was thrown from. [The milestone chapter](./milestone_project_tic-tac-toe.md) explores how all of this works together in practice. For now, let's look at how different errors can be returned from inside a program.
[AnchorErrors](https://docs.rs/anchor-lang/latest/anchor_lang/error/struct.AnchorError.html) provide a range of information like the error name and number or the location in the code where the anchor was thrown, or the account that violated a constraint (e.g. a `mut` constraint). Once thrown inside the program, [you can access the error information](https://coral-xyz.github.io/anchor/ts/classes/AnchorError.html) in the anchor clients like the typescript client. The typescript client also enriches the error with additional information about which program the error was thrown in and the CPI calls (which are explained [here](./cross-program-invocations) in the book) that led to the program from which the error was thrown from. [The milestone chapter](./milestone_project_tic-tac-toe.md) explores how all of this works together in practice. For now, let's look at how different errors can be returned from inside a program.
## Anchor Internal Errors

View File

@ -16,7 +16,7 @@
//! generating clients from IDL is the same.
//!
//! For detailed tutorials and examples on how to use Anchor, see the guided
//! [tutorials](https://coral-xyz.github.io/anchor) or examples in the GitHub
//! [tutorials](https://anchor-lang.com) or examples in the GitHub
//! [repository](https://github.com/coral-xyz/anchor).
//!
//! Presented here are the Rust primitives for building on Solana.
@ -353,7 +353,7 @@ pub mod __private {
macro_rules! require {
($invariant:expr, $error:tt $(,)?) => {
if !($invariant) {
return Err(anchor_lang::error!(crate::ErrorCode::$error));
return Err(anchor_lang::error!($crate::ErrorCode::$error));
}
};
($invariant:expr, $error:expr $(,)?) => {
@ -562,7 +562,7 @@ macro_rules! require_gte {
#[macro_export]
macro_rules! err {
($error:tt $(,)?) => {
Err(anchor_lang::error!(crate::ErrorCode::$error))
Err(anchor_lang::error!($crate::ErrorCode::$error))
};
($error:expr $(,)?) => {
Err(anchor_lang::error!($error))

View File

@ -33,7 +33,7 @@ pub fn parse(strct: &syn::ItemStruct) -> ParseResult<AccountsStruct> {
}
};
let _ = constraints_cross_checks(&fields)?;
constraints_cross_checks(&fields)?;
Ok(AccountsStruct::new(strct.clone(), fields, instruction_api))
}