Skip to content

Commit c3cd773

Browse files
authored
feat: Update ts packages from @coral-xyz to @anchor-lang (solana-foundation#4141)
* feat: @coral-xyz -> @anchor-lang * chore: update yarn.lock * chore: revert yarn.lock
1 parent 26ef369 commit c3cd773

File tree

248 files changed

+404
-404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+404
-404
lines changed

.github/actions/setup-ts/action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ runs:
3030
shell: bash
3131
- run: cd ts/packages/spl-token && yarn --frozen-lockfile && yarn build:node && yarn link && cd ../../../
3232
shell: bash
33-
- run: cd examples/tutorial && yarn link @coral-xyz/anchor @coral-xyz/borsh && yarn --frozen-lockfile && cd ../../
33+
- run: cd examples/tutorial && yarn link @anchor-lang/core @anchor-lang/borsh && yarn --frozen-lockfile && cd ../../
3434
shell: bash
35-
- 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 ..
35+
- 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 ..
3636
shell: bash

.github/workflows/reusable-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ jobs:
369369
path: ~/.cargo/bin/
370370
- run: chmod +x ~/.cargo/bin/anchor
371371

372-
- 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
372+
- 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
373373
- uses: ./.github/actions/git-diff/
374374

375375
test-programs:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ To jump straight to examples, go [here](https://github.com/coral-xyz/anchor/tree
4040
| `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) |
4141
| `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) |
4242
| `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) |
43-
| `@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) |
44-
| `@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) |
43+
| `@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) |
44+
| `@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) |
4545

4646
## Note
4747

bump-version.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ git restore updates
4343
popd
4444

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

5252
# Insert version number into CHANGELOG
5353
sed "${sedi[@]}" -e \

cli/npm-package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@coral-xyz/anchor-cli",
2+
"name": "@anchor-lang/cli",
33
"version": "0.32.1",
44
"description": "Anchor CLI tool",
55
"homepage": "https://github.com/coral-xyz/anchor#readme",

cli/src/checks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn check_overflow(cargo_toml_path: impl AsRef<Path>) -> Result<bool> {
2828
/// Check whether there is a mismatch between the current CLI version and:
2929
///
3030
/// - `anchor-lang` crate version
31-
/// - `@coral-xyz/anchor` package version
31+
/// - `@anchor-lang/core` package version
3232
///
3333
/// This function logs warnings in the case of a mismatch.
3434
pub fn check_anchor_version(cfg: &WithPath<Config>) -> Result<()> {
@@ -64,7 +64,7 @@ pub fn check_anchor_version(cfg: &WithPath<Config>) -> Result<()> {
6464
};
6565
let mismatched_ts_version = package_json
6666
.get("dependencies")
67-
.and_then(|deps| deps.get("@coral-xyz/anchor"))
67+
.and_then(|deps| deps.get("@anchor-lang/core"))
6868
.and_then(|ver| ver.as_str())
6969
.and_then(|ver| VersionReq::parse(ver).ok())
7070
.filter(|ver| !ver.matches(&cli_version));
@@ -78,10 +78,10 @@ pub fn check_anchor_version(cfg: &WithPath<Config>) -> Result<()> {
7878
};
7979

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

cli/src/rust_template.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ token = "{token}"
264264
pub fn deploy_js_script_host(cluster_url: &str, script_path: &str) -> String {
265265
format!(
266266
r#"
267-
const anchor = require('@coral-xyz/anchor');
267+
const anchor = require('@anchor-lang/core');
268268
269269
// Deploy script defined by the user.
270270
const userScript = require("{script_path}");
@@ -287,7 +287,7 @@ main();
287287

288288
pub fn deploy_ts_script_host(cluster_url: &str, script_path: &str) -> String {
289289
format!(
290-
r#"import * as anchor from '@coral-xyz/anchor';
290+
r#"import * as anchor from '@anchor-lang/core';
291291
292292
// Deploy script defined by the user.
293293
const userScript = require("{script_path}");
@@ -313,7 +313,7 @@ pub fn deploy_script() -> &'static str {
313313
// single deploy script that's invoked from the CLI, injecting a provider
314314
// configured from the workspace's Anchor.toml.
315315
316-
const anchor = require("@coral-xyz/anchor");
316+
const anchor = require("@anchor-lang/core");
317317
318318
module.exports = async function (provider) {
319319
// Configure client to use the provider.
@@ -329,7 +329,7 @@ pub fn ts_deploy_script() -> &'static str {
329329
// single deploy script that's invoked from the CLI, injecting a provider
330330
// configured from the workspace's Anchor.toml.
331331
332-
import * as anchor from "@coral-xyz/anchor";
332+
import * as anchor from "@anchor-lang/core";
333333
334334
module.exports = async function (provider: anchor.AnchorProvider) {
335335
// Configure client to use the provider.
@@ -342,7 +342,7 @@ module.exports = async function (provider: anchor.AnchorProvider) {
342342

343343
pub fn mocha(name: &str) -> String {
344344
format!(
345-
r#"const anchor = require("@coral-xyz/anchor");
345+
r#"const anchor = require("@anchor-lang/core");
346346
347347
describe("{}", () => {{
348348
// Configure the client to use the local cluster.
@@ -363,7 +363,7 @@ describe("{}", () => {{
363363

364364
pub fn jest(name: &str) -> String {
365365
format!(
366-
r#"const anchor = require("@coral-xyz/anchor");
366+
r#"const anchor = require("@anchor-lang/core");
367367
368368
describe("{}", () => {{
369369
// Configure the client to use the local cluster.
@@ -392,7 +392,7 @@ pub fn package_json(jest: bool, license: String) -> String {
392392
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
393393
}},
394394
"dependencies": {{
395-
"@coral-xyz/anchor": "^{VERSION}"
395+
"@anchor-lang/core": "^{VERSION}"
396396
}},
397397
"devDependencies": {{
398398
"jest": "^29.0.3",
@@ -410,7 +410,7 @@ pub fn package_json(jest: bool, license: String) -> String {
410410
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
411411
}},
412412
"dependencies": {{
413-
"@coral-xyz/anchor": "^{VERSION}"
413+
"@anchor-lang/core": "^{VERSION}"
414414
}},
415415
"devDependencies": {{
416416
"chai": "^4.3.4",
@@ -433,7 +433,7 @@ pub fn ts_package_json(jest: bool, license: String) -> String {
433433
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
434434
}},
435435
"dependencies": {{
436-
"@coral-xyz/anchor": "^{VERSION}"
436+
"@anchor-lang/core": "^{VERSION}"
437437
}},
438438
"devDependencies": {{
439439
"@types/bn.js": "^5.1.0",
@@ -455,7 +455,7 @@ pub fn ts_package_json(jest: bool, license: String) -> String {
455455
"lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
456456
}},
457457
"dependencies": {{
458-
"@coral-xyz/anchor": "^{VERSION}"
458+
"@anchor-lang/core": "^{VERSION}"
459459
}},
460460
"devDependencies": {{
461461
"chai": "^4.3.4",
@@ -475,8 +475,8 @@ pub fn ts_package_json(jest: bool, license: String) -> String {
475475

476476
pub fn ts_mocha(name: &str) -> String {
477477
format!(
478-
r#"import * as anchor from "@coral-xyz/anchor";
479-
import {{ Program }} from "@coral-xyz/anchor";
478+
r#"import * as anchor from "@anchor-lang/core";
479+
import {{ Program }} from "@anchor-lang/core";
480480
import {{ {} }} from "../target/types/{}";
481481
482482
describe("{}", () => {{
@@ -502,8 +502,8 @@ describe("{}", () => {{
502502

503503
pub fn ts_jest(name: &str) -> String {
504504
format!(
505-
r#"import * as anchor from "@coral-xyz/anchor";
506-
import {{ Program }} from "@coral-xyz/anchor";
505+
r#"import * as anchor from "@anchor-lang/core";
506+
import {{ Program }} from "@anchor-lang/core";
507507
import {{ {} }} from "../target/types/{}";
508508
509509
describe("{}", () => {{
@@ -585,7 +585,7 @@ pub fn node_shell(
585585
) -> Result<String> {
586586
let mut eval_string = format!(
587587
r#"
588-
const anchor = require('@coral-xyz/anchor');
588+
const anchor = require('@anchor-lang/core');
589589
const web3 = anchor.web3;
590590
const PublicKey = anchor.web3.PublicKey;
591591
const Keypair = anchor.web3.Keypair;

docs/content/docs/basics/idl.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ The IDL file is then used to generate a client for interacting with the program,
151151
simplifying the process of invoking the program instruction.
152152

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

318318
```ts title="test.ts"
319-
import * as anchor from "@coral-xyz/anchor";
320-
import { Program, BN } from "@coral-xyz/anchor";
319+
import * as anchor from "@anchor-lang/core";
320+
import { Program, BN } from "@anchor-lang/core";
321321
import { HelloAnchor } from "../target/types/hello_anchor";
322322
import { Keypair } from "@solana/web3.js";
323323
import assert from "assert";

docs/content/docs/basics/pda.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ derivation. This removes the need to explicitly derive the PDA when building the
313313
instruction.
314314

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

320320
describe("hello_anchor", () => {

docs/content/docs/clients/typescript.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ description:
66
---
77

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

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

1919
## Client Program
2020

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

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

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

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

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

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

387387
## Example
388388

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

392392
- `initialize` – Creates and initializes a counter account to store a value
@@ -630,7 +630,7 @@ import {
630630
Transaction,
631631
sendAndConfirmTransaction,
632632
} from "@solana/web3.js";
633-
import { Program } from "@coral-xyz/anchor";
633+
import { Program } from "@anchor-lang/core";
634634
import type { Example } from "./idl/example.ts";
635635
import idl from "./idl/example.json";
636636

0 commit comments

Comments
 (0)