Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using @coral-xyz/anchor packages #2318

Merged
merged 7 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/setup-ts/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ runs:
shell: bash
- run: cd ts/packages/spl-token && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../
shell: bash
- run: cd examples/tutorial && yarn link @project-serum/anchor && yarn --frozen-lockfile && cd ../../
- run: cd examples/tutorial && yarn link @coral-xyz/anchor && yarn --frozen-lockfile && cd ../../
shell: bash
- run: cd tests && yarn link @project-serum/anchor && yarn link @project-serum/spl-associated-token-account && yarn link @project-serum/spl-token && yarn --frozen-lockfile && cd ..
- run: cd tests && yarn link @coral-xyz/anchor && yarn link @coral-xyz/spl-associated-token-account && yarn link @coral-xyz/spl-token && yarn --frozen-lockfile && cd ..
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/no-cashing-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/anchor

- run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @project-serum/anchor && yarn && anchor test && yarn lint:fix
- run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @coral-xyz/anchor && yarn && anchor test && yarn lint:fix
- uses: ./.github/actions/git-diff/

test-programs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ jobs:
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/anchor

- run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @project-serum/anchor && yarn && anchor test && yarn lint:fix
- run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @coral-xyz/anchor && yarn && anchor test && yarn lint:fix
- uses: ./.github/actions/git-diff/

test-programs:
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The minor version will be incremented upon a breaking change and the patch versi

### Features

- cli: Add `--run` to `anchor test` for running a subset of test suites ([#1828](https://github.com/project-serum/anchor/issues/1828)).
- cli: Add `--run` to `anchor test` for running a subset of test suites ([#1828](https://github.com/coral-xyz/anchor/issues/1828)).
- client: Add `transaction` functions to RequestBuilder ([#1958](https://github.com/coral-xyz/anchor/pull/1958)).
- spl: Add `create_metadata_accounts_v3` and `set_collection_size` wrappers ([#2119](https://github.com/coral-xyz/anchor/pull/2119)).
- spl: Add `MetadataAccount` account deserialization. ([#2014](https://github.com/coral-xyz/anchor/pull/2014)).
Expand All @@ -38,7 +38,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- cli: Allow custom cluster config ([#2271](https://github.com/coral-xyz/anchor/pull/2271)).
- ts: Add optional flag to parseLogs to throw an error on decoding failure ([#2043](https://github.com/coral-xyz/anchor/pull/2043)).
- cli: Add `test.validator.geyser_plugin_config` support ([#2016](https://github.com/coral-xyz/anchor/pull/2016)).
- cli: Add `account` subcommand to cli ([#1923](https://github.com/project-serum/anchor/pull/1923))
- cli: Add `account` subcommand to cli ([#1923](https://github.com/coral-xyz/anchor/pull/1923))
- cli: Add `ticks_per_slot` option to Validator args ([#1875](https://github.com/coral-xyz/anchor/pull/1875)).

### Fixes
Expand All @@ -61,6 +61,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- lang: Add `Discriminator` and `Owner` trait implementation for structures representing instructions ([#1997](https://github.com/coral-xyz/anchor/pull/1997)).
- ts: '@coral-xyz/borsh' package is now part of the yarn monorepo ([#2290](https://github.com/coral-xyz/anchor/pull/2290)). The borsh package needs to be built before the anchor package can be built but this should happen automatically when running `yarn build` in packages/anchor, see [#2299](https://github.com/coral-xyz/anchor/pull/2299) and [#2306](https://github.com/coral-xyz/anchor/pull/2306).
- lang: Add support for optionally passing in accounts using the syntax `Optional<Account<'info, T>>`. Shouldn't affect existing programs but may be a breaking change to tools that use the anchor generated IDL. [#2101](https://github.com/coral-xyz/anchor/pull/2101).
- ts: Switch from `@project-serum/anchor` to the `@coral-xyz/anchor` package [#2318](https://github.com/coral-xyz/anchor/pull/2318).

## [0.25.0] - 2022-07-05

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ To jump straight to examples, go [here](https://github.com/coral-xyz/anchor/tree

## 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) |
| `@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) |
| 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) |
| `@coral-xyz/anchor` | TypeScript client for Anchor programs | [![npm](https://img.shields.io/npm/v/@coral-xyz/anchor.svg?color=blue)](https://www.npmjs.com/package/@coral-xyz/anchor) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://coral-xyz.github.io/anchor/ts/index.html) |
| `@coral-xyz/anchor-cli` | CLI to support building and managing an Anchor workspace | [![npm](https://img.shields.io/npm/v/@coral-xyz/anchor-cli.svg?color=blue)](https://www.npmjs.com/package/@coral-xyz/anchor-cli) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://coral-xyz.github.io/anchor/cli/commands.html) |

## Note

* **Anchor is in active development, so all APIs are subject to change.**
* **This code is unaudited. Use at your own risk.**
- **Anchor is in active development, so all APIs are subject to change.**
- **This code is unaudited. Use at your own risk.**

## Examples

Expand Down
2 changes: 1 addition & 1 deletion cli/npm-package/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@project-serum/anchor-cli",
"name": "@coral-xyz/anchor-cli",
"version": "0.26.0",
"description": "Anchor CLI tool",
"homepage": "https://github.com/coral-xyz/anchor#readme",
Expand Down
30 changes: 15 additions & 15 deletions cli/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ anchor-lang = "{2}"
pub fn deploy_js_script_host(cluster_url: &str, script_path: &str) -> String {
format!(
r#"
const anchor = require('@project-serum/anchor');
const anchor = require('@coral-xyz/anchor');

// Deploy script defined by the user.
const userScript = require("{0}");
Expand All @@ -114,7 +114,7 @@ main();

pub fn deploy_ts_script_host(cluster_url: &str, script_path: &str) -> String {
format!(
r#"import * as anchor from '@project-serum/anchor';
r#"import * as anchor from '@coral-xyz/anchor';

// Deploy script defined by the user.
const userScript = require("{0}");
Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn deploy_script() -> &'static str {
// single deploy script that's invoked from the CLI, injecting a provider
// configured from the workspace's Anchor.toml.

const anchor = require("@project-serum/anchor");
const anchor = require("@coral-xyz/anchor");

module.exports = async function (provider) {
// Configure client to use the provider.
Expand All @@ -160,7 +160,7 @@ pub fn ts_deploy_script() -> &'static str {
// single deploy script that's invoked from the CLI, injecting a provider
// configured from the workspace's Anchor.toml.

const anchor = require("@project-serum/anchor");
const anchor = require("@coral-xyz/anchor");

module.exports = async function (provider) {
// Configure client to use the provider.
Expand Down Expand Up @@ -202,7 +202,7 @@ pub struct Initialize {{}}

pub fn mocha(name: &str) -> String {
format!(
r#"const anchor = require("@project-serum/anchor");
r#"const anchor = require("@coral-xyz/anchor");

describe("{}", () => {{
// Configure the client to use the local cluster.
Expand All @@ -223,7 +223,7 @@ describe("{}", () => {{

pub fn jest(name: &str) -> String {
format!(
r#"const anchor = require("@project-serum/anchor");
r#"const anchor = require("@coral-xyz/anchor");

describe("{}", () => {{
// Configure the client to use the local cluster.
Expand Down Expand Up @@ -251,7 +251,7 @@ pub fn package_json(jest: bool) -> String {
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
}},
"dependencies": {{
"@project-serum/anchor": "^{0}"
"@coral-xyz/anchor": "^{0}"
}},
"devDependencies": {{
"jest": "^29.0.3",
Expand All @@ -269,7 +269,7 @@ pub fn package_json(jest: bool) -> String {
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
}},
"dependencies": {{
"@project-serum/anchor": "^{0}"
"@coral-xyz/anchor": "^{0}"
}},
"devDependencies": {{
"chai": "^4.3.4",
Expand All @@ -292,7 +292,7 @@ pub fn ts_package_json(jest: bool) -> String {
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
}},
"dependencies": {{
"@project-serum/anchor": "^{0}"
"@coral-xyz/anchor": "^{0}"
}},
"devDependencies": {{
"@types/bn.js": "^5.1.0",
Expand All @@ -314,7 +314,7 @@ pub fn ts_package_json(jest: bool) -> String {
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
}},
"dependencies": {{
"@project-serum/anchor": "^{0}"
"@coral-xyz/anchor": "^{0}"
}},
"devDependencies": {{
"chai": "^4.3.4",
Expand All @@ -335,8 +335,8 @@ pub fn ts_package_json(jest: bool) -> String {

pub fn ts_mocha(name: &str) -> String {
format!(
r#"import * as anchor from "@project-serum/anchor";
import {{ Program }} from "@project-serum/anchor";
r#"import * as anchor from "@coral-xyz/anchor";
import {{ Program }} from "@coral-xyz/anchor";
import {{ {} }} from "../target/types/{}";

describe("{}", () => {{
Expand All @@ -362,8 +362,8 @@ describe("{}", () => {{

pub fn ts_jest(name: &str) -> String {
format!(
r#"import * as anchor from "@project-serum/anchor";
import {{ Program }} from "@project-serum/anchor";
r#"import * as anchor from "@coral-xyz/anchor";
import {{ Program }} from "@coral-xyz/anchor";
import {{ {} }} from "../target/types/{}";

describe("{}", () => {{
Expand Down Expand Up @@ -445,7 +445,7 @@ pub fn node_shell(
) -> Result<String> {
let mut eval_string = format!(
r#"
const anchor = require('@project-serum/anchor');
const anchor = require('@coral-xyz/anchor');
const web3 = anchor.web3;
const PublicKey = anchor.web3.PublicKey;
const Keypair = anchor.web3.Keypair;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ from the workspace's `Anchor.toml`. For example,
```javascript
// File: migrations/deploys.js

const anchor = require('@project-serum/anchor')
const anchor = require('@coral-xyz/anchor')

module.exports = async function (provider) {
anchor.setProvider(provider)
Expand Down
8 changes: 4 additions & 4 deletions docs/src/pages/docs/cross-program-invocations.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ impl<'info> PullStrings<'info> {
We can verify that everything works as expected by replacing the contents of the `puppet.ts` file with:

```ts
import * as anchor from '@project-serum/anchor'
import { Program } from '@project-serum/anchor'
import * as anchor from '@coral-xyz/anchor'
import { Program } from '@coral-xyz/anchor'
import { Keypair } from '@solana/web3.js'
import { expect } from 'chai'
import { Puppet } from '../target/types/puppet'
Expand Down Expand Up @@ -286,8 +286,8 @@ impl<'info> PullStrings<'info> {
Finally, change the test:

```ts
import * as anchor from '@project-serum/anchor'
import { Program } from '@project-serum/anchor'
import * as anchor from '@coral-xyz/anchor'
import { Program } from '@coral-xyz/anchor'
import { Keypair } from '@solana/web3.js'
import { Puppet } from '../target/types/puppet'
import { PuppetMaster } from '../target/types/puppet_master'
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ anchor --version

### Install using pre-build binary on x86_64 Linux

Anchor binaries are available via an NPM package [`@project-serum/anchor-cli`](https://www.npmjs.com/package/@project-serum/anchor-cli). Only `x86_64` Linux is supported currently, you must build from source for other OS'.
Anchor binaries are available via an NPM package [`@coral-xyz/anchor-cli`](https://www.npmjs.com/package/@coral-xyz/anchor-cli). Only `x86_64` Linux is supported currently, you must build from source for other OS'.

### Build from source for other operating systems without avm

Expand Down
8 changes: 4 additions & 4 deletions docs/src/pages/docs/pdas.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ pub fn change_user_name(ctx: Context<ChangeUserName>, new_name: String) -> Resul
Finally, let's add a test. Copy this into `game.ts`

```ts
import * as anchor from '@project-serum/anchor'
import { Program } from '@project-serum/anchor'
import * as anchor from '@coral-xyz/anchor'
import { Program } from '@coral-xyz/anchor'
import { PublicKey } from '@solana/web3.js'
import { Game } from '../target/types/game'
import { expect } from 'chai'
Expand Down Expand Up @@ -306,8 +306,8 @@ The `authority` account is now an `UncheckedAccount` instead of a `Signer`. When
Finally, this is the new `puppet.ts`:

```ts
import * as anchor from '@project-serum/anchor'
import { Program } from '@project-serum/anchor'
import * as anchor from '@coral-xyz/anchor'
import { Program } from '@coral-xyz/anchor'
import { Keypair, PublicKey } from '@solana/web3.js'
import { Puppet } from '../target/types/puppet'
import { PuppetMaster } from '../target/types/puppet_master'
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/basic-0/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// It is not expected users directly test with this example. For a more
// ergonomic example, see `tests/basic-0.js` in this workspace.

const anchor = require("@project-serum/anchor");
const anchor = require("@coral-xyz/anchor");

// Configure the local cluster.
anchor.setProvider(anchor.AnchorProvider.local());
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/basic-0/tests/basic-0.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const anchor = require("@project-serum/anchor");
const anchor = require("@coral-xyz/anchor");

describe("basic-0", () => {
// Configure the client to use the local cluster.
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/basic-1/tests/basic-1.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require("assert");
const anchor = require("@project-serum/anchor");
const anchor = require("@coral-xyz/anchor");
const { SystemProgram } = anchor.web3;

describe("basic-1", () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/basic-2/tests/basic-2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require("assert");
const anchor = require("@project-serum/anchor");
const anchor = require("@coral-xyz/anchor");
const { SystemProgram } = anchor.web3;

describe("basic-2", () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/basic-3/tests/basic-3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require("assert");
const anchor = require("@project-serum/anchor");
const anchor = require("@coral-xyz/anchor");
const { SystemProgram } = anchor.web3;

describe("basic-3", () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/basic-4/tests/basic-4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require("assert");
const anchor = require("@project-serum/anchor");
const anchor = require("@coral-xyz/anchor");

describe("basic-4", () => {
const provider = anchor.AnchorProvider.local();
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"basic-4"
],
"dependencies": {
"@project-serum/anchor": "file:../../ts/packages/anchor"
"@coral-xyz/anchor": "file:../../ts/packages/anchor"
},
"devDependencies": {
"mocha": "^9.1.3",
Expand Down
Loading