Skip to content
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 @@ -30,7 +30,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 @coral-xyz/anchor @coral-xyz/borsh && yarn --frozen-lockfile && cd ../../
- run: cd examples/tutorial && yarn link @anchor-lang/core @anchor-lang/borsh && yarn --frozen-lockfile && cd ../../
shell: bash
- run: cd tests && yarn link @coral-xyz/anchor @coral-xyz/borsh @coral-xyz/spl-associated-token-account @coral-xyz/spl-token && yarn --frozen-lockfile && cd ..
- run: cd tests && yarn link @anchor-lang/core @anchor-lang/borsh @anchor-lang/spl-associated-token-account @anchor-lang/spl-token && yarn --frozen-lockfile && cd ..
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/reusable-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ jobs:
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/anchor

- run: cd "$(mktemp -d)" && anchor init --test-template ${{ matrix.template }} hello-anchor-${{ matrix.template }} && cd hello-anchor-${{ matrix.template }} && yarn link @coral-xyz/anchor && yarn && anchor test && yarn lint:fix
- run: cd "$(mktemp -d)" && anchor init --test-template ${{ matrix.template }} hello-anchor-${{ matrix.template }} && cd hello-anchor-${{ matrix.template }} && yarn link @anchor-lang/core && yarn && anchor test && yarn lint:fix
- uses: ./.github/actions/git-diff/

test-programs:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ To jump straight to examples, go [here](https://github.com/coral-xyz/anchor/tree
| `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)](https://crates.io/crates/anchor-spl) | [![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)](https://crates.io/crates/anchor-client) | [![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://www.anchor-lang.com/docs/references/cli) |
| `@anchor-lang/core` | TypeScript client for Anchor programs | [![npm](https://img.shields.io/npm/v/@anchor-lang/core.svg?color=blue)](https://www.npmjs.com/package/@anchor-lang/core) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://coral-xyz.github.io/anchor/ts/index.html) |
| `@anchor-lang/cli` | CLI to support building and managing an Anchor workspace | [![npm](https://img.shields.io/npm/v/@anchor-lang/cli.svg?color=blue)](https://www.npmjs.com/package/@anchor-lang/core-cli) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://www.anchor-lang.com/docs/references/cli) |

## Note

Expand Down
4 changes: 2 additions & 2 deletions bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ git restore updates
popd

# Potential for collisions in `package.json` files, handle those separately
# Replace only matching "version": "x.xx.x" and "@coral-xyz/anchor": "x.xx.x"
# Replace only matching "version": "x.xx.x" and "@anchor-lang/core": "x.xx.x"
git grep -l $old_version -- "**/package.json" | \
xargs sed -E "${sedi[@]}" \
-e "s/\"version\": \"$old_version\"/\"version\": \"$version\"/g" \
-e "s/@coral-xyz\/(.*)\": \"(.*)$old_version\"/@coral-xyz\/\1\": \"\2$version\"/g"
-e "s/@anchor-lang\/(.*)\": \"(.*)$old_version\"/@anchor-lang\/\1\": \"\2$version\"/g"

# Insert version number into CHANGELOG
sed "${sedi[@]}" -e \
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": "@coral-xyz/anchor-cli",
"name": "@anchor-lang/cli",
"version": "0.32.1",
"description": "Anchor CLI tool",
"homepage": "https://github.com/coral-xyz/anchor#readme",
Expand Down
8 changes: 4 additions & 4 deletions cli/src/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn check_overflow(cargo_toml_path: impl AsRef<Path>) -> Result<bool> {
/// Check whether there is a mismatch between the current CLI version and:
///
/// - `anchor-lang` crate version
/// - `@coral-xyz/anchor` package version
/// - `@anchor-lang/core` package version
///
/// This function logs warnings in the case of a mismatch.
pub fn check_anchor_version(cfg: &WithPath<Config>) -> Result<()> {
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn check_anchor_version(cfg: &WithPath<Config>) -> Result<()> {
};
let mismatched_ts_version = package_json
.get("dependencies")
.and_then(|deps| deps.get("@coral-xyz/anchor"))
.and_then(|deps| deps.get("@anchor-lang/core"))
.and_then(|ver| ver.as_str())
.and_then(|ver| VersionReq::parse(ver).ok())
.filter(|ver| !ver.matches(&cli_version));
Expand All @@ -78,10 +78,10 @@ pub fn check_anchor_version(cfg: &WithPath<Config>) -> Result<()> {
};

eprintln!(
"WARNING: `@coral-xyz/anchor` version({ver}) and the current CLI version\
"WARNING: `@anchor-lang/core` version({ver}) and the current CLI version\
({cli_version}) don't match.\n\n\t\
This can lead to unwanted behavior. To fix, upgrade the package by running:\n\n\t\
{update_cmd} @coral-xyz/anchor@{cli_version}\n"
{update_cmd} @anchor-lang/core@{cli_version}\n"
);
}

Expand Down
30 changes: 15 additions & 15 deletions cli/src/rust_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ token = "{token}"
pub fn deploy_js_script_host(cluster_url: &str, script_path: &str) -> String {
format!(
r#"
const anchor = require('@coral-xyz/anchor');
const anchor = require('@anchor-lang/core');

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

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

// Deploy script defined by the user.
const userScript = require("{script_path}");
Expand All @@ -313,7 +313,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("@coral-xyz/anchor");
const anchor = require("@anchor-lang/core");

module.exports = async function (provider) {
// Configure client to use the provider.
Expand All @@ -329,7 +329,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.

import * as anchor from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";

module.exports = async function (provider: anchor.AnchorProvider) {
// Configure client to use the provider.
Expand All @@ -342,7 +342,7 @@ module.exports = async function (provider: anchor.AnchorProvider) {

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

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

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

describe("{}", () => {{
// Configure the client to use the local cluster.
Expand Down Expand Up @@ -392,7 +392,7 @@ pub fn package_json(jest: bool, license: String) -> String {
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
}},
"dependencies": {{
"@coral-xyz/anchor": "^{VERSION}"
"@anchor-lang/core": "^{VERSION}"
}},
"devDependencies": {{
"jest": "^29.0.3",
Expand All @@ -410,7 +410,7 @@ pub fn package_json(jest: bool, license: String) -> String {
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
}},
"dependencies": {{
"@coral-xyz/anchor": "^{VERSION}"
"@anchor-lang/core": "^{VERSION}"
}},
"devDependencies": {{
"chai": "^4.3.4",
Expand All @@ -433,7 +433,7 @@ pub fn ts_package_json(jest: bool, license: String) -> String {
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
}},
"dependencies": {{
"@coral-xyz/anchor": "^{VERSION}"
"@anchor-lang/core": "^{VERSION}"
}},
"devDependencies": {{
"@types/bn.js": "^5.1.0",
Expand All @@ -455,7 +455,7 @@ pub fn ts_package_json(jest: bool, license: String) -> String {
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
}},
"dependencies": {{
"@coral-xyz/anchor": "^{VERSION}"
"@anchor-lang/core": "^{VERSION}"
}},
"devDependencies": {{
"chai": "^4.3.4",
Expand All @@ -475,8 +475,8 @@ pub fn ts_package_json(jest: bool, license: String) -> String {

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

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

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

describe("{}", () => {{
Expand Down Expand Up @@ -585,7 +585,7 @@ pub fn node_shell(
) -> Result<String> {
let mut eval_string = format!(
r#"
const anchor = require('@coral-xyz/anchor');
const anchor = require('@anchor-lang/core');
const web3 = anchor.web3;
const PublicKey = anchor.web3.PublicKey;
const Keypair = anchor.web3.Keypair;
Expand Down
8 changes: 4 additions & 4 deletions docs/content/docs/basics/idl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ The IDL file is then used to generate a client for interacting with the program,
simplifying the process of invoking the program instruction.

```ts title="test.ts"
import * as anchor from "@coral-xyz/anchor";
import { Program, BN } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program, BN } from "@anchor-lang/core";
import { HelloAnchor } from "../target/types/hello_anchor";
import { Keypair } from "@solana/web3.js";
import assert from "assert";
Expand Down Expand Up @@ -316,8 +316,8 @@ The IDL file is then used to generate a client for interacting with the program,
simplifying the process of fetching and deserializing account data.

```ts title="test.ts"
import * as anchor from "@coral-xyz/anchor";
import { Program, BN } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program, BN } from "@anchor-lang/core";
import { HelloAnchor } from "../target/types/hello_anchor";
import { Keypair } from "@solana/web3.js";
import assert from "assert";
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/basics/pda.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ derivation. This removes the need to explicitly derive the PDA when building the
instruction.

```ts {13}
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { HelloAnchor } from "../target/types/hello_anchor";

describe("hello_anchor", () => {
Expand Down
18 changes: 9 additions & 9 deletions docs/content/docs/clients/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ description:
---

Anchor provides a Typescript client library
([@coral-xyz/anchor](https://github.com/coral-xyz/anchor/tree/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor))
([@anchor-lang/core](https://github.com/coral-xyz/anchor/tree/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor))
that simplifies the process of interacting with Solana programs from the client
in JavaScript or TypeScript.

<Callout type="info">
The `@coral-xyz/anchor` library is only compatible with the legacy version
The `@anchor-lang/core` library is only compatible with the legacy version
(v1) of `@solana/web3.js` and `@solana/spl-token`. It is not compatible with
the new version (v2) of `@solana/web3.js`.
</Callout>

## Client Program

To interact with an Anchor program using `@coral-xyz/anchor`, you'll need to
To interact with an Anchor program using `@anchor-lang/core`, you'll need to
create a
[`Program`](https://github.com/coral-xyz/anchor/blob/0e5285aecdf410fa0779b7cd09a47f235882c156/ts/packages/anchor/src/program/index.ts#L58)
instance using the program's [IDL file](/docs/basics/idl).
Expand All @@ -39,7 +39,7 @@ When integrating with a frontend using the
to set up the `AnchorProvider` and `Program`.

```ts title="example"
import { Program, AnchorProvider, setProvider } from "@coral-xyz/anchor";
import { Program, AnchorProvider, setProvider } from "@anchor-lang/core";
import { useAnchorWallet, useConnection } from "@solana/wallet-adapter-react";
import type { HelloAnchor } from "./idlType";
import idl from "./idl.json";
Expand Down Expand Up @@ -73,7 +73,7 @@ a connected wallet.

```ts
import { clusterApiUrl, Connection, PublicKey } from "@solana/web3.js";
import { Program } from "@coral-xyz/anchor";
import { Program } from "@anchor-lang/core";
import type { HelloAnchor } from "./idlType";
import idl from "./idl.json";

Expand All @@ -95,8 +95,8 @@ Anchor workspace (like React or Node.js) where you'll need to manually create
the `Program` instance.

```ts
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { HelloAnchor } from "../target/types/hello_anchor";

describe("hello_anchor", () => {
Expand Down Expand Up @@ -386,7 +386,7 @@ const accounts = await program.account.newAccount.fetchMultiple([

## Example

The example below demonstrates how to use `@coral-xyz/anchor` to interact with a
The example below demonstrates how to use `@anchor-lang/core` to interact with a
simple Anchor program. The program has two instructions:

- `initialize` – Creates and initializes a counter account to store a value
Expand Down Expand Up @@ -630,7 +630,7 @@ import {
Transaction,
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { Program } from "@coral-xyz/anchor";
import { Program } from "@anchor-lang/core";
import type { Example } from "./idl/example.ts";
import idl from "./idl/example.json";

Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/features/declare-program.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ pub struct IncrementCpi<'info> {
```

```ts tab="Test"
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { Example } from "../target/types/example";
import { ExampleCpi } from "../target/types/example_cpi";
import { Keypair } from "@solana/web3.js";
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/features/errors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ pub enum CustomError {
<Tab value="Client">

```ts title="test.ts"
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { CustomError } from "../target/types/custom_error";
import assert from "assert";

Expand Down
8 changes: 4 additions & 4 deletions docs/content/docs/features/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ pub struct CustomEvent {
<Tab value="Client">

```ts title="test.ts"
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { Event } from "../target/types/event";

describe("event", () => {
Expand Down Expand Up @@ -193,8 +193,8 @@ pub struct CustomEvent {
<Tab value="Client">

```ts title="test.ts"
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { EventCpi } from "../target/types/event_cpi";

describe("event-cpi", () => {
Expand Down
8 changes: 4 additions & 4 deletions docs/content/docs/features/zero-copy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ pub struct Data {
<Tab value="Client">

```ts title="test.ts"
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { ZeroCopy } from "../target/types/zero_copy";

describe("zero-copy", () => {
Expand Down Expand Up @@ -616,8 +616,8 @@ pub struct Data {
<Tab value="Client">

```ts title="test.ts"
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { ZeroCopyTwo } from "../target/types/zero_copy_two";

describe("zero-copy-two", () => {
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/quickstart/local.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ This file demonstrates how to invoke the default program's `initialize`
instruction in Typescript.

```ts filename="my-project.ts"
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { MyProject } from "../target/types/my_project";

describe("my-project", () => {
Expand Down
2 changes: 1 addition & 1 deletion docs/content/docs/references/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ configured from the workspace's `Anchor.toml`. For example,
```javascript
// File: migrations/deploys.js

const anchor = require("@coral-xyz/anchor");
const anchor = require("@anchor-lang/core");

module.exports = async function (provider) {
anchor.setProvider(provider);
Expand Down
Loading
Loading