Skip to content

Commit

Permalink
Merge branch 'master' of github.com:project-serum/anchor into cli-wor…
Browse files Browse the repository at this point in the history
…kspace
  • Loading branch information
NBNARADHYA committed Mar 8, 2022
2 parents 4b39ef2 + 6dd0574 commit d6829af
Show file tree
Hide file tree
Showing 90 changed files with 478 additions and 322 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,36 @@ jobs:
- run: cd tests/bpf-upgradeable-state && solana program deploy --program-id program_with_different_programdata.json target/deploy/bpf_upgradeable_state.so
- run: cd tests/bpf-upgradeable-state && cp bpf_upgradeable_state-keypair.json target/deploy/bpf_upgradeable_state-keypair.json && anchor deploy && anchor test --skip-deploy --skip-build --skip-lint

test-anchor-init:
needs: setup-anchor-cli
name: Test Anchor Init
runs-on: ubuntu-18.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup/
- uses: ./.github/actions/setup-ts/
- uses: ./.github/actions/setup-solana/

- uses: actions/cache@v2
name: Cache Cargo registry + index
id: cache-anchor
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./target/
key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}

- uses: actions/download-artifact@v2
with:
name: anchor-binary
path: ~/.cargo/bin/

- run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && anchor test

test-programs:
needs: setup-anchor-cli
name: Test ${{ matrix.node.path }}
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ incremented for features.

## [Unreleased]

### Features

* lang: Add new `AccountSysvarMismatch` error code and test cases for sysvars ([#1535](https://github.com/project-serum/anchor/pull/1535)).
* spl: Add support for revoke instruction ([#1493](https://github.com/project-serum/anchor/pull/1493)).

### Fixes

* ts: Fix the loss of strict typing using the `methods` namespace on builder functions ([#1539](https://github.com/project-serum/anchor/pull/1539)).

### Breaking

* ts: Mark `transaction`, `instruction`, `simulate` and `rpc` program namespaces as deprecated in favor of `methods` ([#1539](https://github.com/project-serum/anchor/pull/1539)).
* ts: No longer allow manual setting of globally resolvable program public keys in `methods#accounts()`. ([#1548][https://github.com/project-serum/anchor/pull/1548])
* lang: Remove space calculation using [`#[derive(Default)]`] (https://github.com/project-serum/anchor/pull/1519).

## [0.22.1] - 2022-02-28

### Fixes

* cli: Fix rust template ([#1488](https://github.com/project-serum/anchor/pull/1488)).
Expand Down Expand Up @@ -38,7 +55,7 @@ This change will break most programs. Do the following to upgrade:
* change all `ProgramResult`'s to `Result<()>`
* change `#[error]` to `#[error_code]`
* change all `Err(MyError::SomeError.into())` to `Err(error!(MyError::SomeError))` and all `Err(ProgramError::SomeProgramError)` to `Err(ProgramError::SomeProgramError.into())` or `Err(Error::from(ProgramError::SomeProgramError).with_source(source!()))` to provide file and line source of the error (`with_source` is most useful with `ProgramError`s. `error!` already adds source information for custom and anchor internal errors).
* change all `solana_program::program::invoke()` to `solana_program::program::invoke().map_err(Into::into)` and `solana_program::program::invoke_signed()` to `solana_program::program::invoke().map_err(Into::into)`
* change all `solana_program::program::invoke()` to `solana_program::program::invoke().map_err(Into::into)` and `solana_program::program::invoke_signed()` to `solana_program::program::invoke_signed().map_err(Into::into)`

## [0.21.0] - 2022-02-07

Expand Down
35 changes: 30 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,37 @@ Thank you for your interest in contributing to Anchor! All contributions are wel
matter how big or small. This includes (but is not limited to) filing issues,
adding documentation, fixing bugs, creating examples, and implementing features.

If you'd like to contribute, please claim an issue by commenting, forking, and
opening a pull request, even if empty. This allows the maintainers to track who
is working on what issue as to not overlap work. If you're looking to get started,
## 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).
For simple documentation changes, feel free to just open a pull request.
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
and engage with the maintainers in [Discord](https://discord.com/channels/889577356681945098).
and engage with the maintainers in [Discord](https://discord.gg/sxy4zxBckh).

## Choosing an issue

If you'd like to contribute, please claim an issue by commenting, forking, and
opening a pull request, even if empty. This allows the maintainers to track who
is working on what issue as to not overlap work.

## Issue Guidelines

Please follow these guidelines:

Before coding:
- choose a branch name that describes the issue you're working on

While coding:
- Submit a draft PR asap
- Only change code directly relevant to your PR. Sometimes you might find some code that could really need some refactoring. However, if it's not relevant to your PR, do not touch it. File an issue instead. This allows the reviewer to focus on a single problem at a time.
- If you write comments, do not exceed 80 chars per line. This allows contributors who work with multiple open windows to still read the comments without horizontally scrolling.
- Write adversarial tests. For example, if you're adding a new account type, do not only write tests where the instruction succeeds. Also write tests that test whether the instruction fails, if a check inside the new type is violated.

After coding:
- If you've moved code around, build the docs with `cargo doc --open` and adjust broken links
- Adjust the cli templates if necessary
- If you made a change to anchor's periphery (avm or cli), make a PR to the `anchor-book` repo if necessary
- If you've added a new folder to the `tests` directory, add it to the [CI](./.github/workflows/tests.yaml).
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ 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 guided [documentation](https://project-serum.github.io/anchor/getting-started/introduction.html).
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).

## Packages
Expand Down Expand Up @@ -58,14 +58,14 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
mod counter {
use super::*;

pub fn initialize(ctx: Context<Initialize>, start: u64) -> ProgramResult {
pub fn initialize(ctx: Context<Initialize>, start: u64) -> Result<()> {
let counter = &mut ctx.accounts.counter;
counter.authority = *ctx.accounts.authority.key;
counter.count = start;
Ok(())
}

pub fn increment(ctx: Context<Increment>) -> ProgramResult {
pub fn increment(ctx: Context<Increment>) -> Result<()> {
let counter = &mut ctx.accounts.counter;
counter.count += 1;
Ok(())
Expand Down Expand Up @@ -107,19 +107,8 @@ licensed as above, without any additional terms or conditions.

## Contribution

Thank you for your interest in contributing to Anchor! All contributions are welcome no
matter how big or small. This includes (but is not limited to) filing issues,
adding documentation, fixing bugs, creating examples, and implementing features.

If you'd like to contribute, please claim an issue by commenting, forking, and
opening a pull request, even if empty. This allows the maintainers to track who
is working on what issue as to not overlap work. 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).
For simple documentation changes, feel free to just open a pull request.

If you're considering larger changes or self motivated features, please file an issue
and engage with the maintainers in [Discord](https://discord.gg/sxy4zxBckh).
Thank you for your interest in contributing to Anchor!
Please see the [CONTRIBUTING.md](./CONTRIBUTING.md) to learn how.

### Thanks ❤️

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.22.0
0.22.1
2 changes: 1 addition & 1 deletion avm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "avm"
version = "0.22.0"
version = "0.22.1"
edition = "2018"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "anchor-cli"
version = "0.22.0"
version = "0.22.1"
authors = ["armaniferrante <armaniferrante@gmail.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion cli/npm-package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@project-serum/anchor-cli",
"version": "0.22.0",
"version": "0.22.1",
"description": "Anchor CLI tool",
"homepage": "https://github.com/project-serum/anchor#readme",
"bugs": {
Expand Down
1 change: 1 addition & 0 deletions cli/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ pub fn ts_package_json() -> String {
"chai": "^4.3.4",
"mocha": "^9.0.3",
"ts-mocha": "^8.0.0",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"typescript": "^4.3.5"
}}
Expand Down
4 changes: 2 additions & 2 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "anchor-client"
version = "0.22.0"
version = "0.22.1"
authors = ["Serum Foundation <foundation@projectserum.com>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -10,7 +10,7 @@ description = "Rust client for Anchor programs"
debug = []

[dependencies]
anchor-lang = { path = "../lang", version = "0.22.0" }
anchor-lang = { path = "../lang", version = "0.22.1" }
anyhow = "1.0.32"
regex = "1.4.5"
serde = { version = "1.0.122", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion docs/src/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ npm i -g @project-serum/anchor-cli
For now, we can use Cargo to install the CLI.

```bash
cargo install --git https://github.com/project-serum/anchor --tag v0.22.0 anchor-cli --locked
cargo install --git https://github.com/project-serum/anchor --tag v0.22.1 anchor-cli --locked
```

On Linux systems you may need to install additional dependencies if `cargo install` fails. On Ubuntu,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/getting-started/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ have an `Anchor.toml` to define the build.
An example `Anchor.toml` config looks as follows,

```toml
anchor_version = "0.22.0"
anchor_version = "0.22.1"

[workspace]
members = ["programs/multisig"]
Expand Down
4 changes: 2 additions & 2 deletions docs/src/getting-started/verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ If the program has an IDL, it will also check the IDL deployed on chain matches.

## Images

A docker image for each version of Anchor is published on [Docker Hub](https://hub.docker.com/r/projectserum/build). They are tagged in the form `projectserum/build:<version>`. For example, to get the image for Anchor `v0.22.0` one can run
A docker image for each version of Anchor is published on [Docker Hub](https://hub.docker.com/r/projectserum/build). They are tagged in the form `projectserum/build:<version>`. For example, to get the image for Anchor `v0.22.1` one can run

```
docker pull projectserum/build:v0.22.0
docker pull projectserum/build:v0.22.1
```

## Removing an Image
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorials/tutorial-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To address these problems, Anchor provides several types, traits, and macros. It
from the untrusted `&[AccountInfo]` slice given to a Solana program into a validated struct
of deserialized account types.
- [#[account]](https://docs.rs/anchor-lang/latest/anchor_lang/attr.account.html): attribute macro implementing [AccountSerialize](https://docs.rs/anchor-lang/latest/anchor_lang/trait.AccountSerialize.html) and [AccountDeserialize](https://docs.rs/anchor-lang/latest/anchor_lang/trait.AnchorDeserialize.html), automatically prepending a unique 8 byte discriminator to the account array. The discriminator is defined by the first 8 bytes of the `Sha256` hash of the account's Rust identifier--i.e., the struct type name--and ensures no account can be substituted for another.
- [Account](https://docs.rs/anchor-lang/latest/anchor_lang/struct.Account.html): a wrapper type for a deserialized account implementing `AccountDeserialize`. Using this type within an `Accounts` struct will ensure the account is **owned** by the address defined by `declare_id!` where the inner account was defined.
- [Account](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/account/struct.Account.html): a wrapper type for a deserialized account implementing `AccountDeserialize`. Using this type within an `Accounts` struct will ensure the account is **owned** by the address defined by `declare_id!` where the inner account was defined.

With the above, we can define preconditions for any instruction handler expecting a certain set of
accounts, allowing us to more easily reason about the security of our programs.
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/basic-0/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "basic-0",
"version": "0.22.0",
"version": "0.22.1",
"license": "(MIT OR Apache-2.0)",
"homepage": "https://github.com/project-serum/anchor#readme",
"bugs": {
Expand Down
Loading

0 comments on commit d6829af

Please sign in to comment.