From b3c357221d827035a7680af0c291f7113a19b8cd Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 16:26:26 +0000 Subject: [PATCH 1/9] Move Anchor v2 examples to 2.0.0-rc.4 - anchor-lang and anchor-spl 2.0.0-rc.2 -> 2.0.0-rc.4 in all 56 anchor/ projects; anchor-v2-testing pinned to 2cdb58ba (the v2.0.0-rc.4 tag). - Anchor v2 workflow installs anchor-cli 2.0.0-rc.4. - rc.3 removed #[account(unsafe(dup))]: token-minter, transfer-tokens and transfer-switch use #[account(mut)] on the aliasing Signer/UncheckedAccount fields. - rc.3 made remaining_accounts() infallible and it returns &[AccountView]: drop the `?` at all eleven call sites; transfer-fee's harvest copies with .to_vec(). - Docs, READMEs, migration guide and CHANGELOG name rc.4. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB --- .github/workflows/anchor.yml | 10 +-- CHANGELOG.md | 29 +++++++ CONTRIBUTING.md | 4 +- README.md | 2 +- basics/account-data/anchor/README.md | 2 +- .../anchor-program-example/Cargo.toml | 4 +- basics/checking-accounts/anchor/README.md | 2 +- .../anchor-program-example/Cargo.toml | 4 +- basics/close-account/anchor/README.md | 2 +- .../anchor/programs/close-account/Cargo.toml | 4 +- basics/counter/anchor/README.md | 2 +- .../anchor/programs/counter_anchor/Cargo.toml | 4 +- basics/create-account/anchor/README.md | 2 +- .../programs/create-system-account/Cargo.toml | 4 +- .../cross-program-invocation/anchor/README.md | 2 +- .../anchor/programs/hand/Cargo.toml | 4 +- .../anchor/programs/lever/Cargo.toml | 4 +- basics/favorites/anchor/README.md | 2 +- .../anchor/programs/favorites/Cargo.toml | 4 +- basics/hello-solana/anchor/README.md | 2 +- .../anchor/programs/hello-solana/Cargo.toml | 4 +- basics/pda-rent-payer/anchor/README.md | 2 +- .../anchor-program-example/Cargo.toml | 4 +- .../processing-instructions/anchor/README.md | 2 +- .../processing-instructions/Cargo.toml | 4 +- .../anchor/README.md | 2 +- .../anchor-program-example/Cargo.toml | 4 +- basics/pyth/anchor/README.md | 4 +- .../anchor/programs/pythexample/Cargo.toml | 4 +- .../anchor/programs/pythexample/src/lib.rs | 2 +- basics/rent/anchor/README.md | 2 +- .../anchor/programs/rent-example/Cargo.toml | 4 +- basics/resizing-accounts/anchor/README.md | 2 +- .../anchor/programs/anchor-realloc/Cargo.toml | 4 +- basics/transaction-v1/anchor/README.md | 6 +- .../anchor/programs/transaction-v1/Cargo.toml | 4 +- basics/transfer-sol/anchor/README.md | 2 +- .../anchor/programs/transfer-sol/Cargo.toml | 4 +- compression/cnft-burn/anchor/README.md | 2 +- .../anchor/programs/cnft-burn/Cargo.toml | 4 +- .../cnft-burn/src/instructions/burn_cnft.rs | 6 +- compression/cnft-vault/anchor/README.md | 2 +- .../anchor/programs/cnft-vault/Cargo.toml | 4 +- .../src/instructions/withdraw_cnft.rs | 7 +- .../src/instructions/withdraw_two_cnfts.rs | 7 +- compression/cutils/anchor/README.md | 2 +- .../cutils/anchor/programs/cutils/Cargo.toml | 4 +- .../cutils/src/instructions/verify.rs | 8 +- docs/anchor-v2-migration.md | 86 ++++++++++--------- finance/betting-market/anchor/README.md | 2 +- .../anchor/programs/betting-market/Cargo.toml | 6 +- finance/escrow/anchor/README.md | 2 +- .../escrow/anchor/programs/escrow/Cargo.toml | 6 +- finance/fundraiser/anchor/README.md | 2 +- .../anchor/programs/fundraiser/Cargo.toml | 6 +- finance/lending/anchor/README.md | 4 +- .../anchor/programs/lending/Cargo.toml | 6 +- .../src/instructions/refresh_obligation.rs | 7 +- finance/managed-fund/anchor/README.md | 2 +- finance/managed-fund/anchor/app/README.md | 2 +- .../anchor/programs/managed-fund/Cargo.toml | 6 +- .../managed-fund/src/instructions/deposit.rs | 2 +- .../src/instructions/rebalance.rs | 2 +- .../managed-fund/src/instructions/withdraw.rs | 6 +- .../programs/mock-swap-router/Cargo.toml | 4 +- finance/options/anchor/README.md | 2 +- .../anchor/programs/options/Cargo.toml | 6 +- finance/order-book/anchor/README.md | 4 +- .../anchor/programs/order-book/Cargo.toml | 6 +- .../src/instructions/place_order.rs | 6 +- finance/perpetual-futures/anchor/README.md | 2 +- .../programs/mock-price-feed/Cargo.toml | 2 +- .../programs/perpetual-futures/Cargo.toml | 6 +- finance/prop-amm/anchor/README.md | 2 +- .../programs/mock-price-feed/Cargo.toml | 2 +- .../anchor/programs/prop-amm/Cargo.toml | 6 +- finance/token-swap/README.md | 2 +- finance/token-swap/anchor/README.md | 2 +- .../anchor/programs/token-swap/Cargo.toml | 6 +- nft/metadata-pointer/anchor/README.md | 2 +- .../anchor/programs/extension_nft/Cargo.toml | 6 +- nft/minter/anchor/README.md | 2 +- .../anchor/programs/nft-minter/Cargo.toml | 6 +- nft/minter/native/program/Cargo.toml | 2 +- nft/operations/anchor/README.md | 2 +- .../anchor/programs/mint-nft/Cargo.toml | 6 +- tokens/create-token/anchor/README.md | 2 +- .../anchor/programs/create-token/Cargo.toml | 6 +- tokens/create-token/native/program/Cargo.toml | 2 +- .../anchor/README.md | 2 +- .../external-delegate-token-master/Cargo.toml | 6 +- tokens/pda-mint-authority/anchor/README.md | 2 +- .../anchor/programs/token-minter/Cargo.toml | 6 +- .../native/program/Cargo.toml | 2 +- .../token-extensions/basics/anchor/README.md | 2 +- .../basics/anchor/programs/basics/Cargo.toml | 6 +- .../cpi-guard/anchor/README.md | 2 +- .../anchor/programs/cpi-guard/Cargo.toml | 6 +- .../default-account-state/anchor/README.md | 2 +- .../programs/default-account-state/Cargo.toml | 6 +- .../token-extensions/group/anchor/README.md | 2 +- .../group/anchor/programs/group/Cargo.toml | 6 +- .../immutable-owner/anchor/README.md | 2 +- .../programs/immutable-owner/Cargo.toml | 6 +- .../interest-bearing/anchor/README.md | 2 +- .../programs/interest-bearing/Cargo.toml | 6 +- .../memo-transfer/anchor/README.md | 2 +- .../anchor/programs/memo-transfer/Cargo.toml | 6 +- .../metadata/anchor/README.md | 2 +- .../anchor/programs/metadata/Cargo.toml | 6 +- .../mint-close-authority/anchor/README.md | 2 +- .../programs/mint-close-authority/Cargo.toml | 6 +- .../non-transferable/anchor/README.md | 2 +- .../programs/non-transferable/Cargo.toml | 6 +- .../permanent-delegate/anchor/README.md | 2 +- .../programs/permanent-delegate/Cargo.toml | 6 +- .../transfer-fee/anchor/README.md | 2 +- .../anchor/programs/transfer-fee/Cargo.toml | 6 +- .../transfer-fee/src/instructions/harvest.rs | 7 +- .../account-data-as-seed/anchor/README.md | 2 +- .../anchor/programs/transfer-hook/Cargo.toml | 6 +- .../allow-block-list-token/anchor/README.md | 2 +- .../anchor/programs/abl-token/Cargo.toml | 6 +- .../transfer-hook/allow-list/anchor/README.md | 2 +- .../anchor/programs/transfer-hook/Cargo.toml | 6 +- .../transfer-hook/counter/anchor/README.md | 2 +- .../anchor/programs/transfer-hook/Cargo.toml | 6 +- .../hello-world/anchor/README.md | 2 +- .../anchor/programs/transfer-hook/Cargo.toml | 6 +- .../transfer-cost/anchor/README.md | 2 +- .../anchor/programs/transfer-hook/Cargo.toml | 6 +- .../transfer-switch/anchor/README.md | 2 +- .../programs/transfer-switch/Cargo.toml | 6 +- .../src/instructions/configure_admin.rs | 13 ++- tokens/token-minter/anchor/README.md | 2 +- .../anchor/programs/token-minter/Cargo.toml | 6 +- .../token-minter/src/instructions/mint.rs | 9 +- tokens/token-minter/native/program/Cargo.toml | 2 +- tokens/transfer-tokens/anchor/README.md | 2 +- .../programs/transfer-tokens/Cargo.toml | 6 +- .../transfer-tokens/src/instructions/mint.rs | 9 +- .../transfer-tokens/native/program/Cargo.toml | 2 +- 142 files changed, 355 insertions(+), 313 deletions(-) diff --git a/.github/workflows/anchor.yml b/.github/workflows/anchor.yml index 90df8d70c..257da4787 100644 --- a/.github/workflows/anchor.yml +++ b/.github/workflows/anchor.yml @@ -205,25 +205,25 @@ jobs: path: | ~/.cargo/bin/anchor # Pinned to match the anchor-lang/anchor-spl crate version the programs depend on. - key: anchor-cli-crates-io-${{ runner.os }}-2.0.0-rc.2 - - name: Install Anchor 2.0.0-rc.2 + key: anchor-cli-crates-io-${{ runner.os }}-2.0.0-rc.4 + - name: Install Anchor 2.0.0-rc.4 run: | export PATH="$HOME/.cargo/bin:$PATH" # `anchor --version` can emit more than one line; read the first line only so # a multi-line value never reaches downstream parsing. current="$(anchor --version 2>/dev/null | head -n1 | awk '{print $2}' || true)" - if [ "$current" != "2.0.0-rc.2" ]; then + if [ "$current" != "2.0.0-rc.4" ]; then # Install the CLI from crates.io rather than through avm. avm has no # prebuilt binary for this pre-release (a plain `avm install` 404s), and # its --from-source path builds the CLI from the git tag, which is not - # the same code as the published anchor-lang 2.0.0-rc.2 the programs + # the same code as the published anchor-lang 2.0.0-rc.4 the programs # compile against: `anchor idl build` then emits a shim referencing # `anchor_lang::IdlBuild`, which that crate does not have, and writes # IDL JSON the parser rejects with "missing field `variants`". # Installing the CLI from crates.io keeps it and the library on one # published release. --locked builds it against its own published # lockfile so the result does not drift with the registry. - cargo install anchor-cli --version 2.0.0-rc.2 --locked --force + cargo install anchor-cli --version 2.0.0-rc.4 --locked --force fi echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" - name: Install Surfpool diff --git a/CHANGELOG.md b/CHANGELOG.md index f68000b47..deb9152ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,35 @@ All notable changes to this repository are documented here. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [2026-11-14] - Anchor v2 examples on Anchor 2.0.0-rc.4 + +Anchor 2.0.0-rc.3 replaced v2's duplicate mutable account check with the borrows each +account wrapper takes on account data, removed the `unsafe(dup)` constraint, and made +`Context::remaining_accounts()` infallible. 2.0.0-rc.4, released the same day as this +entry, changes only the TypeScript client. + +### Changed + +- All 56 Anchor v2 examples move `anchor-lang` and `anchor-spl` from `2.0.0-rc.2` to + `2.0.0-rc.4`, and `anchor-v2-testing` from revision `a2066021` to `2cdb58ba`, the + commit the `v2.0.0-rc.4` tag points at. `wincode` stays on 0.6, which rc.4 also uses. +- The Anchor v2 workflow installs and caches `anchor-cli 2.0.0-rc.4`. Every Anchor v2 + README, `CONTRIBUTING.md`, the root `README.md` and `docs/anchor-v2-migration.md` name + rc.4. +- `token-minter`'s and `transfer-tokens`' `mint`, and `transfer-switch`'s + `configure_admin`, mark the fields that may name the same account `#[account(mut)]` + instead of `#[account(unsafe(dup))]`. `Signer`, `SystemAccount` and `UncheckedAccount` + take no borrow on account data, so they may alias with no constraint. +- The eleven calls to `remaining_accounts()` in `cnft-burn`, `cnft-vault`, `cutils`, + `lending`, `managed-fund`, `order-book` and `transfer-fee` drop the `?`. The method + returns `&[AccountView]`; `transfer-fee`'s `harvest` copies it with `.to_vec()` to + build `CpiHandleMut`s, which take `&mut AccountView`. +- `docs/anchor-v2-migration.md` replaces "Duplicate Mutable Accounts Are Rejected" with + "Duplicate Accounts Fail Through Borrows", and describes `remaining_accounts()` as + rc.4 has it. +- `basics/transaction-v1/anchor/README.md` states that `@anchor-lang/core` 2.0.0-rc.4 + needs `@solana/kit` 8.5 or later and builds v1 transaction messages by default. + ## [2026-11-07] - Transfer Hook - Whitelist becomes Transfer Hook - Allow List, with no size limit The whitelist example kept every allowed address in one account, capped at eleven, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b31c5b5e1..2ff1bb3b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ See [CHANGELOG.md](./CHANGELOG.md) for release history. This file had no changel - Each example lives at `category/example-name//`, e.g. `basics/counter/anchor/`. - Supported frameworks: `anchor`, `anchor-v1`, `quasar`, `pinocchio`, `native`, `asm`. Use the existing layout as a reference. - `anchor-v1/` is Anchor v1 (1.2.1), the current stable Anchor. `anchor/` is the same example - on Anchor v2 (2.0.0-rc.2), the release candidate for the next major version, and is where new + on Anchor v2 (2.0.0-rc.4), the release candidate for the next major version, and is where new Anchor work starts; the v1 copy tracks its v2 counterpart. A change to what an example does (a new handler, a new check, a fix, a renamed field) goes into both copies, in the same pull request where practical, so a v1 reader gets the same program and the same tests. The copies differ only where the Anchor @@ -33,7 +33,7 @@ See [CHANGELOG.md](./CHANGELOG.md) for release history. This file had no changel Run an example's tests with the command for its framework, from the framework directory (e.g. `basics/counter/anchor/`): -- **Anchor v2** (in `anchor/`): `anchor test` (runs `cargo test`, per the `[scripts]` table in `Anchor.toml`), with the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked`. +- **Anchor v2** (in `anchor/`): `anchor test` (runs `cargo test`, per the `[scripts]` table in `Anchor.toml`), with the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked`. - **Anchor v1** (in `anchor-v1/`): the same `anchor test`, with the v1 CLI: `avm install 1.2.1 && avm use 1.2.1`. Selecting the wrong CLI is the usual cause of a confusing build failure in these directories. Both Anchor copies' tests send v1 transactions (4,096 bytes, resource limits in the message) through `solana-kite`: 0.6 for Anchor v1, 0.7 for Anchor v2. Its senders take a last `compute_unit_limit: Option`: pass `None` and kite diff --git a/README.md b/README.md index d788c1de2..756ff24e4 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ _The largest actively maintained set of Solana programs ('smart contracts') on t Each example is available in one or more of the following frameworks: - [⚓ Anchor v1](https://www.anchor-lang.com/) - the most popular framework for Solana development, in its current major version. Lives in `anchor-v1/`. Install with `avm install 1.2.1 && avm use 1.2.1`, build with `anchor build`, test with `anchor test`. -- [⚓ Anchor v2](https://www.anchor-lang.com/) - the next major version of Anchor, a ground-up rewrite that is not yet released. Lives in `anchor/`, alongside the v1 copy of the same example, and builds on the release candidate: install with `cargo install anchor-cli --version 2.0.0-rc.2 --locked`, then the same `anchor build` / `anchor test`. +- [⚓ Anchor v2](https://www.anchor-lang.com/) - the next major version of Anchor, a ground-up rewrite that is not yet released. Lives in `anchor/`, alongside the v1 copy of the same example, and builds on the release candidate: install with `cargo install anchor-cli --version 2.0.0-rc.4 --locked`, then the same `anchor build` / `anchor test`. - [💫 Quasar](https://quasar-lang.com/docs) - a newer, more performant framework with Anchor-compatible ergonomics. Build with `quasar build`, test with `quasar test`. - [🤥 Pinocchio](https://github.com/anza-xyz/pinocchio) - a zero-copy, zero-allocation library for Solana programs. Build with `cargo build-sbf --manifest-path=./program/Cargo.toml`, test with `cargo test --manifest-path=./program/Cargo.toml`. - [🦀 Native Rust](https://docs.anza.xyz/) - vanilla Rust using Solana's native crates. Build with `cargo build-sbf --manifest-path=./program/Cargo.toml`, test with `cargo test --manifest-path=./program/Cargo.toml`. diff --git a/basics/account-data/anchor/README.md b/basics/account-data/anchor/README.md index 5e83ae8b4..9c5a750e2 100644 --- a/basics/account-data/anchor/README.md +++ b/basics/account-data/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/account-data/anchor/programs/anchor-program-example/Cargo.toml b/basics/account-data/anchor/programs/anchor-program-example/Cargo.toml index 2d417b4ba..b8415f6ef 100644 --- a/basics/account-data/anchor/programs/anchor-program-example/Cargo.toml +++ b/basics/account-data/anchor/programs/anchor-program-example/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/checking-accounts/anchor/README.md b/basics/checking-accounts/anchor/README.md index 885e3f075..5a1279208 100644 --- a/basics/checking-accounts/anchor/README.md +++ b/basics/checking-accounts/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/checking-accounts/anchor/programs/anchor-program-example/Cargo.toml b/basics/checking-accounts/anchor/programs/anchor-program-example/Cargo.toml index 8302b371f..df929b803 100644 --- a/basics/checking-accounts/anchor/programs/anchor-program-example/Cargo.toml +++ b/basics/checking-accounts/anchor/programs/anchor-program-example/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/close-account/anchor/README.md b/basics/close-account/anchor/README.md index d00edcb0b..58ebba343 100644 --- a/basics/close-account/anchor/README.md +++ b/basics/close-account/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/close-account/anchor/programs/close-account/Cargo.toml b/basics/close-account/anchor/programs/close-account/Cargo.toml index 215933097..813951ce7 100644 --- a/basics/close-account/anchor/programs/close-account/Cargo.toml +++ b/basics/close-account/anchor/programs/close-account/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/counter/anchor/README.md b/basics/counter/anchor/README.md index 42bcac8c9..79c823b12 100644 --- a/basics/counter/anchor/README.md +++ b/basics/counter/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/counter/anchor/programs/counter_anchor/Cargo.toml b/basics/counter/anchor/programs/counter_anchor/Cargo.toml index 36ae95b32..5d0e14d9f 100644 --- a/basics/counter/anchor/programs/counter_anchor/Cargo.toml +++ b/basics/counter/anchor/programs/counter_anchor/Cargo.toml @@ -22,7 +22,7 @@ custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/create-account/anchor/README.md b/basics/create-account/anchor/README.md index 2e30def7c..e7f118577 100644 --- a/basics/create-account/anchor/README.md +++ b/basics/create-account/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/create-account/anchor/programs/create-system-account/Cargo.toml b/basics/create-account/anchor/programs/create-system-account/Cargo.toml index 7a47c7daa..292c72612 100644 --- a/basics/create-account/anchor/programs/create-system-account/Cargo.toml +++ b/basics/create-account/anchor/programs/create-system-account/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/cross-program-invocation/anchor/README.md b/basics/cross-program-invocation/anchor/README.md index 305c534b3..e3f4ddc7e 100644 --- a/basics/cross-program-invocation/anchor/README.md +++ b/basics/cross-program-invocation/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/cross-program-invocation/anchor/programs/hand/Cargo.toml b/basics/cross-program-invocation/anchor/programs/hand/Cargo.toml index 54fbc367b..4a38d2823 100644 --- a/basics/cross-program-invocation/anchor/programs/hand/Cargo.toml +++ b/basics/cross-program-invocation/anchor/programs/hand/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/cross-program-invocation/anchor/programs/lever/Cargo.toml b/basics/cross-program-invocation/anchor/programs/lever/Cargo.toml index f729a33a3..ac90fe619 100644 --- a/basics/cross-program-invocation/anchor/programs/lever/Cargo.toml +++ b/basics/cross-program-invocation/anchor/programs/lever/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/favorites/anchor/README.md b/basics/favorites/anchor/README.md index 8213e97c0..c2b2a3604 100644 --- a/basics/favorites/anchor/README.md +++ b/basics/favorites/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/favorites/anchor/programs/favorites/Cargo.toml b/basics/favorites/anchor/programs/favorites/Cargo.toml index 59f50ced0..5f87238a5 100644 --- a/basics/favorites/anchor/programs/favorites/Cargo.toml +++ b/basics/favorites/anchor/programs/favorites/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/hello-solana/anchor/README.md b/basics/hello-solana/anchor/README.md index 94594f285..0f2e870df 100644 --- a/basics/hello-solana/anchor/README.md +++ b/basics/hello-solana/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/hello-solana/anchor/programs/hello-solana/Cargo.toml b/basics/hello-solana/anchor/programs/hello-solana/Cargo.toml index 95c90a607..27689981b 100644 --- a/basics/hello-solana/anchor/programs/hello-solana/Cargo.toml +++ b/basics/hello-solana/anchor/programs/hello-solana/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/pda-rent-payer/anchor/README.md b/basics/pda-rent-payer/anchor/README.md index 27a9329f0..3862602ba 100644 --- a/basics/pda-rent-payer/anchor/README.md +++ b/basics/pda-rent-payer/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/pda-rent-payer/anchor/programs/anchor-program-example/Cargo.toml b/basics/pda-rent-payer/anchor/programs/anchor-program-example/Cargo.toml index 331c38b1d..fd51b5828 100644 --- a/basics/pda-rent-payer/anchor/programs/anchor-program-example/Cargo.toml +++ b/basics/pda-rent-payer/anchor/programs/anchor-program-example/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/processing-instructions/anchor/README.md b/basics/processing-instructions/anchor/README.md index c73ffd2ca..b75bf6845 100644 --- a/basics/processing-instructions/anchor/README.md +++ b/basics/processing-instructions/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/processing-instructions/anchor/programs/processing-instructions/Cargo.toml b/basics/processing-instructions/anchor/programs/processing-instructions/Cargo.toml index ce397b3e5..175747384 100644 --- a/basics/processing-instructions/anchor/programs/processing-instructions/Cargo.toml +++ b/basics/processing-instructions/anchor/programs/processing-instructions/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/program-derived-addresses/anchor/README.md b/basics/program-derived-addresses/anchor/README.md index 121f0a5d6..68bc63d53 100644 --- a/basics/program-derived-addresses/anchor/README.md +++ b/basics/program-derived-addresses/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/program-derived-addresses/anchor/programs/anchor-program-example/Cargo.toml b/basics/program-derived-addresses/anchor/programs/anchor-program-example/Cargo.toml index ef81052a3..4ec93149e 100644 --- a/basics/program-derived-addresses/anchor/programs/anchor-program-example/Cargo.toml +++ b/basics/program-derived-addresses/anchor/programs/anchor-program-example/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/pyth/anchor/README.md b/basics/pyth/anchor/README.md index f9a80b186..972d712a6 100644 --- a/basics/pyth/anchor/README.md +++ b/basics/pyth/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). @@ -13,7 +13,7 @@ See also: [Pyth overview](../README.md) and the [repository catalog](../../../RE > [!NOTE] > **This example vendors the `PriceUpdateV2` account type rather than importing `pyth-solana-receiver-sdk`.** > -> The SDK's current release (2.0.0, checked August 2026) builds against `anchor-lang` 1.0.2, and this repository is on 2.0.0-rc.2, whose account wrappers are a different set of types. Importing the SDK's `PriceUpdateV2` would pull a second `anchor-lang` into the graph. +> The SDK's current release (2.0.0, checked August 2026) builds against `anchor-lang` 1.0.2, and this repository is on 2.0.0-rc.4, whose account wrappers are a different set of types. Importing the SDK's `PriceUpdateV2` would pull a second `anchor-lang` into the graph. > > `programs/pythexample/src/lib.rs` mirrors the onchain layout instead: same fields in the same order, same 8-byte discriminator, owned by the Pyth Receiver program, so accounts written by Pyth deserialize unchanged. Import the SDK type once a release targeting `anchor-lang` 2.x ships. diff --git a/basics/pyth/anchor/programs/pythexample/Cargo.toml b/basics/pyth/anchor/programs/pythexample/Cargo.toml index a61ca9ca5..5ff81d2a1 100644 --- a/basics/pyth/anchor/programs/pythexample/Cargo.toml +++ b/basics/pyth/anchor/programs/pythexample/Cargo.toml @@ -23,7 +23,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -43,7 +43,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/pyth/anchor/programs/pythexample/src/lib.rs b/basics/pyth/anchor/programs/pythexample/src/lib.rs index 15b96395b..2a1e5a8d7 100644 --- a/basics/pyth/anchor/programs/pythexample/src/lib.rs +++ b/basics/pyth/anchor/programs/pythexample/src/lib.rs @@ -59,7 +59,7 @@ pub struct ReadPriceAccountConstraints { // Pyth `PriceUpdateV2` account, vendored from `pyth-solana-receiver-sdk`. // // The SDK's current release (2.0.0, checked August 2026) builds against -// `anchor-lang` 1.0.2, and this repository is on 2.0.0-rc.2, whose account +// `anchor-lang` 1.0.2, and this repository is on 2.0.0-rc.4, whose account // wrappers are a different set of types. Importing the SDK's `PriceUpdateV2` // would pull a second `anchor-lang` into the graph. // diff --git a/basics/rent/anchor/README.md b/basics/rent/anchor/README.md index c0ba24bcd..08297de22 100644 --- a/basics/rent/anchor/README.md +++ b/basics/rent/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/rent/anchor/programs/rent-example/Cargo.toml b/basics/rent/anchor/programs/rent-example/Cargo.toml index 6d2d5cb04..38fe5682c 100644 --- a/basics/rent/anchor/programs/rent-example/Cargo.toml +++ b/basics/rent/anchor/programs/rent-example/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/resizing-accounts/anchor/README.md b/basics/resizing-accounts/anchor/README.md index 44135deaa..1910c8b75 100644 --- a/basics/resizing-accounts/anchor/README.md +++ b/basics/resizing-accounts/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/resizing-accounts/anchor/programs/anchor-realloc/Cargo.toml b/basics/resizing-accounts/anchor/programs/anchor-realloc/Cargo.toml index 908925c66..f5e345a6d 100644 --- a/basics/resizing-accounts/anchor/programs/anchor-realloc/Cargo.toml +++ b/basics/resizing-accounts/anchor/programs/anchor-realloc/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/transaction-v1/anchor/README.md b/basics/transaction-v1/anchor/README.md index 90270966c..3365c580c 100644 --- a/basics/transaction-v1/anchor/README.md +++ b/basics/transaction-v1/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). @@ -42,7 +42,7 @@ Tests run in-process with [LiteSVM](https://www.anchor-lang.com/docs/testing/lit anchor test ``` -This runs `cargo test` as configured in `Anchor.toml`. The tests run on Anchor v2's own harness, `anchor-v2-testing`, pinned to the revision of the `v2.0.0-rc.2` tag. That revision is the first on LiteSVM 0.18, which executes v1 transactions (LiteSVM 0.16.0 was the first release that could). This example builds its transactions by hand. Every other Anchor v2 example sends v1 transactions too, through [solana-kite](https://crates.io/crates/solana-kite) 0.7, which sets the compute unit and loaded-accounts data size limits for them; this one sets each config field itself to show what they do. The suite covers: +This runs `cargo test` as configured in `Anchor.toml`. The tests run on Anchor v2's own harness, `anchor-v2-testing`, pinned to the revision of the `v2.0.0-rc.4` tag, which runs on LiteSVM 0.18. LiteSVM executes v1 transactions from 0.16.0 onwards. This example builds its transactions by hand. Every other Anchor v2 example sends v1 transactions too, through [solana-kite](https://crates.io/crates/solana-kite) 0.7, which sets the compute unit and loaded-accounts data size limits for them; this one sets each config field itself to show what they do. The suite covers: - `stores_a_document_too_large_for_a_legacy_transaction`: a 3,000 byte document in a v1 transaction. The test measures the transaction on the wire (over 1,232 bytes, at most 4,096) and reads the document back from the PDA. - `a_legacy_transaction_still_works_for_a_small_document`: the same instruction with a 500 byte document, sent as a legacy transaction. The program did not change. @@ -53,4 +53,4 @@ LiteSVM does not enforce either size limit (a validator's packet layer does), wh ## Sending v1 transactions to a real cluster -The v1 format is live on mainnet beta since epoch 1035 (15 September 2026), and on devnet and testnet, behind the `enable_tx_v1` feature gate (`txv1aq4pp281K9um3tnPgkfX8UqtFT6wcVW3hNezGLL`). Sending one needs Agave 4.2 or later client crates and, on the RPC side, `maxSupportedTransactionVersion: 1` on every `getTransaction`, `getBlock` and `blockSubscribe` call, plus `encoding: "base64"` when sending, since base58 encoding stops at 1,232 bytes. Anchor v2's TypeScript client (`@anchor-lang/core` 2.0.0-rc.2) is built on `@solana/kit` 8, the first release line that can build v1 transactions. A v1 transaction can also be built in Rust, as in the tests here. +The v1 format is live on mainnet beta since epoch 1035 (15 September 2026), and on devnet and testnet, behind the `enable_tx_v1` feature gate (`txv1aq4pp281K9um3tnPgkfX8UqtFT6wcVW3hNezGLL`). Sending one needs Agave 4.2 or later client crates and, on the RPC side, `maxSupportedTransactionVersion: 1` on every `getTransaction`, `getBlock` and `blockSubscribe` call, plus `encoding: "base64"` when sending, since base58 encoding stops at 1,232 bytes. Anchor v2's TypeScript client (`@anchor-lang/core` 2.0.0-rc.4) needs `@solana/kit` 8.5 or later and builds v1 transaction messages by default; set `transactionVersion` on the provider, or call `.transactionVersion()` on a method, to send legacy or version 0 messages instead. A v1 transaction can also be built in Rust, as in the tests here. diff --git a/basics/transaction-v1/anchor/programs/transaction-v1/Cargo.toml b/basics/transaction-v1/anchor/programs/transaction-v1/Cargo.toml index c249e20c2..4cdfae348 100644 --- a/basics/transaction-v1/anchor/programs/transaction-v1/Cargo.toml +++ b/basics/transaction-v1/anchor/programs/transaction-v1/Cargo.toml @@ -22,7 +22,7 @@ custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. The tests # also use it as the SDK's serializer: `wincode::serialize` on a @@ -50,7 +50,7 @@ wincode = { version = "0.6", features = ["derive"] } # the compute unit limit, priority fee, loaded-accounts data size limit and # heap size from the message's transaction config rather than from # ComputeBudget instructions. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/basics/transfer-sol/anchor/README.md b/basics/transfer-sol/anchor/README.md index 5faa253df..1fc078058 100644 --- a/basics/transfer-sol/anchor/README.md +++ b/basics/transfer-sol/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/basics/transfer-sol/anchor/programs/transfer-sol/Cargo.toml b/basics/transfer-sol/anchor/programs/transfer-sol/Cargo.toml index c13bd46e4..a0336b11d 100644 --- a/basics/transfer-sol/anchor/programs/transfer-sol/Cargo.toml +++ b/basics/transfer-sol/anchor/programs/transfer-sol/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -42,7 +42,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/compression/cnft-burn/anchor/README.md b/compression/cnft-burn/anchor/README.md index c3c878378..a3c9258f2 100644 --- a/compression/cnft-burn/anchor/README.md +++ b/compression/cnft-burn/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/compression/cnft-burn/anchor/programs/cnft-burn/Cargo.toml b/compression/cnft-burn/anchor/programs/cnft-burn/Cargo.toml index b6cdff71e..467cf3569 100644 --- a/compression/cnft-burn/anchor/programs/cnft-burn/Cargo.toml +++ b/compression/cnft-burn/anchor/programs/cnft-burn/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -49,7 +49,7 @@ borsh = { version = "1", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/compression/cnft-burn/anchor/programs/cnft-burn/src/instructions/burn_cnft.rs b/compression/cnft-burn/anchor/programs/cnft-burn/src/instructions/burn_cnft.rs index 42592eab8..1764b5307 100644 --- a/compression/cnft-burn/anchor/programs/cnft-burn/src/instructions/burn_cnft.rs +++ b/compression/cnft-burn/anchor/programs/cnft-burn/src/instructions/burn_cnft.rs @@ -57,9 +57,9 @@ pub fn handle_burn_cnft( nonce: u64, index: u32, ) -> Result<()> { - // `remaining_accounts()` walks the input cursor and returns an owned vec, - // so take it once up front and use the local everywhere below. - let proof_accounts = context.remaining_accounts()?; + // `remaining_accounts()` walks the input cursor once and caches where the + // remaining accounts start; the slice it returns holds the proof accounts. + let proof_accounts = context.remaining_accounts(); // Build instruction data: discriminator + borsh-serialized args let args = BurnArgs { diff --git a/compression/cnft-vault/anchor/README.md b/compression/cnft-vault/anchor/README.md index 2567cdc56..b8441f9b8 100644 --- a/compression/cnft-vault/anchor/README.md +++ b/compression/cnft-vault/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/compression/cnft-vault/anchor/programs/cnft-vault/Cargo.toml b/compression/cnft-vault/anchor/programs/cnft-vault/Cargo.toml index be428271b..30109ead8 100644 --- a/compression/cnft-vault/anchor/programs/cnft-vault/Cargo.toml +++ b/compression/cnft-vault/anchor/programs/cnft-vault/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -52,7 +52,7 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("solana" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_cnft.rs b/compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_cnft.rs index 9040244f8..83ff70d41 100644 --- a/compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_cnft.rs +++ b/compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_cnft.rs @@ -61,9 +61,10 @@ pub fn handler( context.accounts.merkle_tree.address() ); - // `remaining_accounts()` returns an owned vec; take it once so the proof - // views stay alive for the CPI below. - let proof_accounts = context.remaining_accounts()?; + // `remaining_accounts()` returns a slice that borrows the instruction's + // input rather than `context`, so the proof accounts stay usable for the + // CPI below. + let proof_accounts = context.remaining_accounts(); // Read the bump before the CPI handles take a mutable borrow of `vault`. let vault_bump = context.accounts.vault.bump; diff --git a/compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_two_cnfts.rs b/compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_two_cnfts.rs index 18a82d112..2f7eab0f2 100644 --- a/compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_two_cnfts.rs +++ b/compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_two_cnfts.rs @@ -90,9 +90,10 @@ pub fn handler( // The proof lengths are client-supplied: bounds-check them against the // accounts actually provided before slicing, so adversarial input gets a // clean named error instead of a panic. - // `remaining_accounts()` returns an owned vec; take it once so the proof - // views stay alive for both CPIs below. - let proof_accounts = context.remaining_accounts()?; + // `remaining_accounts()` returns a slice that borrows the instruction's + // input rather than `context`, so the proof accounts stay usable for both + // CPIs below. + let proof_accounts = context.remaining_accounts(); let proof_1_length = proof_1_length as usize; let proof_2_length = proof_2_length as usize; diff --git a/compression/cutils/anchor/README.md b/compression/cutils/anchor/README.md index c9f4b60c8..ef3d18dee 100644 --- a/compression/cutils/anchor/README.md +++ b/compression/cutils/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/compression/cutils/anchor/programs/cutils/Cargo.toml b/compression/cutils/anchor/programs/cutils/Cargo.toml index 217683409..c862652d5 100644 --- a/compression/cutils/anchor/programs/cutils/Cargo.toml +++ b/compression/cutils/anchor/programs/cutils/Cargo.toml @@ -22,7 +22,7 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -54,7 +54,7 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("solana" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/compression/cutils/anchor/programs/cutils/src/instructions/verify.rs b/compression/cutils/anchor/programs/cutils/src/instructions/verify.rs index 51bcc38db..8efcb1d86 100644 --- a/compression/cutils/anchor/programs/cutils/src/instructions/verify.rs +++ b/compression/cutils/anchor/programs/cutils/src/instructions/verify.rs @@ -35,10 +35,10 @@ pub fn handle_verify( context: &mut Context, params: &VerifyParams, ) -> Result<()> { - // `remaining_accounts()` walks the input cursor and hands back an owned - // vec, so take it once up front: the mutable borrow of `context` ends here - // and the proof accounts stay alive for the CPI below. - let proof_accounts = context.remaining_accounts()?; + // `remaining_accounts()` walks the input cursor and returns a slice that + // borrows the instruction's input rather than `context`, so the proof + // accounts stay usable for the CPI below. + let proof_accounts = context.remaining_accounts(); let asset_id = get_asset_id(context.accounts.merkle_tree.address(), params.nonce); let leaf_hash = leaf_schema_v1_hash( diff --git a/docs/anchor-v2-migration.md b/docs/anchor-v2-migration.md index d2056a5e9..ecbfa3940 100644 --- a/docs/anchor-v2-migration.md +++ b/docs/anchor-v2-migration.md @@ -1,4 +1,4 @@ -# Porting an Anchor program from v1 to v2.0.0-rc.2 +# Porting an Anchor program from v1 to v2.0.0-rc.4 Anchor v2 is a ground-up rewrite, not a version bump. The crate is `no_std` and built on pinocchio, the account model is static-scoped, borsh is replaced by @@ -11,13 +11,13 @@ it is the only rule here that the compiler will not catch for you. Every difference below has a worked example in this repository. Each Anchor example keeps both versions side by side: `/anchor-v1/` is the program on 1.2.1 and -`/anchor/` is the same program on 2.0.0-rc.2, so diffing the two directories shows +`/anchor/` is the same program on 2.0.0-rc.4, so diffing the two directories shows any rule here applied to real code. Both are built and tested in CI, by the Anchor v1 and Anchor v2 workflows respectively. ## Manifest Changes Every Crate Needs -- `anchor-lang` and `anchor-spl` both move from `1.2.1` to `2.0.0-rc.2`. +- `anchor-lang` and `anchor-spl` both move from `1.2.1` to `2.0.0-rc.4`. - `wincode = { version = "0.6", features = ["derive"] }` is new. - `features = ["init-if-needed"]` goes away. There is no such feature, and the constraint is always available. @@ -41,9 +41,11 @@ macro expands to `wincode` paths for instruction-data (de)serialization. - `.key()` and `.key` become `.address()`, which returns `&Address`. Dereference where a value is wanted. - `.to_account_info()` becomes `.cpi_handle()` or `.cpi_handle_mut()`. -- `ctx.remaining_accounts` is now the method `ctx.remaining_accounts()?`. It is - fallible, takes `&mut self`, and returns an owned `Vec`, so call - it before anything borrows `ctx.accounts`. +- `ctx.remaining_accounts` is now the method `ctx.remaining_accounts()`. It + takes `&mut self`, so call it before anything borrows `ctx.accounts`, and + returns `&[AccountView]`, a slice that borrows the instruction's input rather + than `ctx`. To build `CpiHandleMut`s over remaining accounts, copy the slice + with `.to_vec()`: `CpiHandleMut::writable` takes `&mut AccountView`. - `account.owner` is `account.owner()`. `Rent::minimum_balance` is `Rent::try_minimum_balance`. - `account.data.borrow()` is `account.account().try_borrow()?`. @@ -175,8 +177,8 @@ constraint has to name a *sibling* field. The same goes for Where that idiom is the point of the example, build the account by hand (`create_account` + `initialize_mint2` / `initialize_account3`) rather than -adding a second field for the same address, which would then trip v2's -duplicate-mutable-account check. `initialize_mint2` and `initialize_account3` +adding a second field for the same address, which would then fail with +`AccountBorrowFailed` when both fields borrow the account's data. `initialize_mint2` and `initialize_account3` take the authority as an address, so nothing is lost. For a **data** account (`Account`, `BorshAccount`, `InterfaceAccount`) that @@ -325,40 +327,46 @@ to invoke `pinocchio::default_allocator!()` and `pinocchio::default_panic_handler!()` itself: anchor only emits those on the path where it owns the entrypoint. -## Duplicate Mutable Accounts Are Rejected - -v2 rejects an account that appears in more than one declared slot when any of -those slots is mutable, with `ConstraintDuplicateMutableAccount`, custom error -2040. `#[account(unsafe(dup))]` opts a slot out; it implies `mut`, so it -replaces the `mut` rather than joining it. - -The catch: the walker flags **both** indices of a duplicate, so marking only -the second one still leaves the first intersecting the mutable mask. Every slot -that can legitimately alias needs the constraint, including a `payer`. - -Why the rule exists: v1 deserialized each `Account` into an owned copy and +## Duplicate Accounts Fail Through Borrows + +v2 has no derive-level duplicate check and no `dup` constraint: +`#[account(dup)]` and `#[account(unsafe(dup))]` are compile errors. Each +account wrapper that reads account data takes a borrow on the account when it +loads, and a conflicting second borrow fails with `AccountBorrowFailed`. + +- Two mutable `Account`, `BorshAccount` or `InterfaceAccount` fields + over one account fail. +- A `mut` field and a read-only field over one account also fail, which v1 + allowed. +- Two read-only data fields over one account may share it. +- `Signer`, `SystemAccount`, `UncheckedAccount` and `Program` take no borrow, + so they alias freely, writable or not. + +The two `mint` instructions here rely on the last rule: minting to yourself +makes `mint_authority` (a writable `Signer`, because it pays for the token +account) and `recipient` (a `SystemAccount`) the same account, and the +instruction runs with no extra constraint. `transfer-switch`'s +`configure_admin` passes one address as both `admin` and `new_admin` the same +way. + +Where two data fields legitimately alias, declare the second as +`#[account(mut)] UncheckedAccount`. If the two addresses match, mutate the +first field only. If they differ, call `BorshAccount::::load_mut` on the +second field's `AccountView`, call `exit()` on the result before it drops, and +re-check the constraints the second field had (`has_one`, `seeds`, `address`, +`constraint`), because a manual `load_mut` runs none of them. + +A read-only `Account` passed as a writable account in a CPI also fails with +`AccountBorrowFailed`. Mark it `#[account(mut)]`. + +Why aliasing data fields is refused: v1 deserialized each `Account` into an owned copy and serialized it back at the end of the instruction. Two slots over one account meant two independent copies, and the second write-back silently clobbered the first, the classic self-transfer bug, where debiting one copy and crediting the other and writing both leaves the balance higher than it started. v2 accounts are zero-copy views into the runtime's buffer, so two mutable wrappers -over one account would be two `&mut` to the same bytes. Hence the loader -rejects rather than warns. - -The `unsafe` is not decoration, so check two things before reaching for it: - -1. **That the accounts can actually alias.** If no caller ever passes the same - address twice, the constraint disables a live check for nothing. Leave it - off. `transfer-tokens`' `transfer` is this case: its test funds a fresh - `Keypair` as the recipient. -2. **That the aliasing slots hold no deserialized state.** `Signer`, - `SystemAccount` and `UncheckedAccount` carry no copy to write back, so - there is no lost update to worry about. The two `mint` instructions here are - this case: minting to yourself makes `mint_authority` and `recipient` the - same `Signer`, and the duplication comes from the caller rather than the - program, so refusing it would make an ordinary mint fail with 2040. Two - aliasing `Account` slots are what the check is *for*, and the fix there - is to restructure the accounts so only one of them exists. +over one account would be two `&mut` to the same bytes, which the borrow +each wrapper takes prevents. ## anchor-spl Moved Its Types and Dropped Its Features @@ -431,7 +439,7 @@ answer is usually one of the first four rather than moving it to borsh. `target/anchor-v2-profile/`. - `anchor-v2-testing`: wraps LiteSVM with optional register-trace capture. It is published only from git, so the examples pin it to the revision the - `v2.0.0-rc.2` tag points at. It no longer re-exports `LiteSVM` at its root: + `v2.0.0-rc.4` tag points at. It no longer re-exports `LiteSVM` at its root: import `anchor_v2_testing::litesvm::LiteSVM`. ## Hand-Built CPIs Take Handles, Not Account Infos @@ -531,7 +539,7 @@ driving `cargo-build-sbf` has to do the same. ## Toolchain Versions the Port Depends On -CI installs the CLI with `cargo install anchor-cli --version 2.0.0-rc.2 --locked`; +CI installs the CLI with `cargo install anchor-cli --version 2.0.0-rc.4 --locked`; it is a pre-release, so it has to be named explicitly rather than resolved as latest, and avm has no prebuilt binary for it. A v2 CLI cannot build v1 programs, so that pin can only move once every example is ported. diff --git a/finance/betting-market/anchor/README.md b/finance/betting-market/anchor/README.md index 75ac16e5f..8676b9d73 100644 --- a/finance/betting-market/anchor/README.md +++ b/finance/betting-market/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/finance/betting-market/anchor/programs/betting-market/Cargo.toml b/finance/betting-market/anchor/programs/betting-market/Cargo.toml index 5c92067ef..eb7e815ae 100644 --- a/finance/betting-market/anchor/programs/betting-market/Cargo.toml +++ b/finance/betting-market/anchor/programs/betting-market/Cargo.toml @@ -23,11 +23,11 @@ profile = ["anchor-v2-testing/profile"] [dependencies] # init-if-needed: place_bet creates the Bet account only on a bettor's first bet on an outcome. -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -44,7 +44,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/finance/escrow/anchor/README.md b/finance/escrow/anchor/README.md index 0f3d632d5..11e03c8e5 100644 --- a/finance/escrow/anchor/README.md +++ b/finance/escrow/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/finance/escrow/anchor/programs/escrow/Cargo.toml b/finance/escrow/anchor/programs/escrow/Cargo.toml index c1c09d0ae..8f5eda3d9 100644 --- a/finance/escrow/anchor/programs/escrow/Cargo.toml +++ b/finance/escrow/anchor/programs/escrow/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/finance/fundraiser/anchor/README.md b/finance/fundraiser/anchor/README.md index d2d0aefb6..8f83d0856 100644 --- a/finance/fundraiser/anchor/README.md +++ b/finance/fundraiser/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/finance/fundraiser/anchor/programs/fundraiser/Cargo.toml b/finance/fundraiser/anchor/programs/fundraiser/Cargo.toml index a81d9d6ad..194462e9c 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/Cargo.toml +++ b/finance/fundraiser/anchor/programs/fundraiser/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/finance/lending/anchor/README.md b/finance/lending/anchor/README.md index 09d10ea42..3ed766234 100644 --- a/finance/lending/anchor/README.md +++ b/finance/lending/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). @@ -299,7 +299,7 @@ on its own. ## Setup -- Rust and the Solana toolchain (`cargo-build-sbf`), Anchor 2.0.0-rc.2, Solana 3.1.8. +- Rust and the Solana toolchain (`cargo-build-sbf`), Anchor 2.0.0-rc.4, Solana 3.1.8. - This program has no client/JavaScript code; tests are Rust + LiteSVM. ## Testing diff --git a/finance/lending/anchor/programs/lending/Cargo.toml b/finance/lending/anchor/programs/lending/Cargo.toml index a3380ab52..99d1919ac 100644 --- a/finance/lending/anchor/programs/lending/Cargo.toml +++ b/finance/lending/anchor/programs/lending/Cargo.toml @@ -23,14 +23,14 @@ profile = ["anchor-v2-testing/profile"] [dependencies] # init-if-needed: the obligation share vault and the test price feed are created lazily. -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } # pinocchio ships only Clock and Rent, so LastRestartSlot is read through # pinocchio's own `get_sysvar` wrapper (see src/last_restart.rs). pinocchio = "0.11" -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -47,7 +47,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/finance/lending/anchor/programs/lending/src/instructions/refresh_obligation.rs b/finance/lending/anchor/programs/lending/src/instructions/refresh_obligation.rs index 1ffc9712b..8315598df 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/refresh_obligation.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/refresh_obligation.rs @@ -17,9 +17,10 @@ use crate::state::{Obligation, PriceFeed, Reserve}; /// evaluated conservatively against the borrower. pub fn handle_refresh_obligation(context: &mut Context) -> Result<()> { let slot = Clock::get()?.slot; - // `remaining_accounts()` takes `&mut context`, so collect it before the - // obligation's own mutable borrow starts. It hands back an owned vec. - let accounts = context.remaining_accounts()?; + // `remaining_accounts()` takes `&mut context`, so call it before the + // obligation's own mutable borrow starts. The slice it returns borrows the + // instruction's input, not `context`. + let accounts = context.remaining_accounts(); let obligation = &mut context.accounts.obligation; let lending_market = obligation.lending_market; let mut cursor = 0usize; diff --git a/finance/managed-fund/anchor/README.md b/finance/managed-fund/anchor/README.md index baba50a20..326901ee3 100644 --- a/finance/managed-fund/anchor/README.md +++ b/finance/managed-fund/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/finance/managed-fund/anchor/app/README.md b/finance/managed-fund/anchor/app/README.md index 1ca972b1c..286cd036c 100644 --- a/finance/managed-fund/anchor/app/README.md +++ b/finance/managed-fund/anchor/app/README.md @@ -68,7 +68,7 @@ client mirrors it call-for-call. ## Where the IDL comes from `src/idl/managed_fund.json` is generated from the program source with -`anchor idl build` (Anchor 2.0.0-rc.2, the version CI installs) and committed. If you change +`anchor idl build` (Anchor 2.0.0-rc.4, the version CI installs) and committed. If you change the program, regenerate it: ```sh diff --git a/finance/managed-fund/anchor/programs/managed-fund/Cargo.toml b/finance/managed-fund/anchor/programs/managed-fund/Cargo.toml index fa8e8fd58..f88f74cc8 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/Cargo.toml +++ b/finance/managed-fund/anchor/programs/managed-fund/Cargo.toml @@ -27,14 +27,14 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } # pinocchio ships only Clock and Rent, so LastRestartSlot is read through # pinocchio's own `get_sysvar` wrapper (see src/last_restart.rs). pinocchio = "0.11" -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" mock-swap-router = { path = "../mock-swap-router", features = ["cpi"] } [dev-dependencies] @@ -52,7 +52,7 @@ mock-swap-router = { path = "../mock-swap-router", features = ["cpi"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs index 1d0b21bcd..c1f9895bb 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs @@ -121,7 +121,7 @@ pub fn handle_deposit( // matching index, makes it impossible to omit an asset and understate NAV. // Each asset is valued rounding up, so NAV is never understated and the // floored share count below rounds against the depositor, not the holders. - let remaining = context.remaining_accounts()?; + let remaining = context.remaining_accounts(); require!( remaining.len() == asset_count * 5, FundError::IncompleteAssetAccounts diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs index af5d2ec7c..6277b35ab 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs @@ -98,7 +98,7 @@ pub fn handle_rebalance( FundError::InvalidAssetAccount ); - let remaining = context.remaining_accounts()?; + let remaining = context.remaining_accounts(); require!( remaining.len() == asset_count * 5, FundError::IncompleteAssetAccounts diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs index 63650b43d..e0f659699 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs @@ -83,7 +83,7 @@ pub fn handle_withdraw( let asset_count = context.accounts.fund.asset_count as usize; require!( - context.remaining_accounts()?.len() == asset_count * 4, + context.remaining_accounts().len() == asset_count * 4, FundError::IncompleteAssetAccounts ); @@ -125,9 +125,9 @@ pub fn handle_withdraw( let index_bytes = fund_index.to_le_bytes(); let signer_seeds: &[&[&[u8]]] = &[&[b"fund", index_bytes.as_ref(), &[fund_bump]]]; - // `remaining_accounts()` takes `&mut Context`, so collect it before the + // `remaining_accounts()` takes `&mut Context`, so call it before the // per-account views below borrow `context.accounts`. - let remaining = context.remaining_accounts()?; + let remaining = context.remaining_accounts(); // `fund` signs the payouts below. It is a data account holding a live // borrow on its buffer, so release it across the CPIs and take it back diff --git a/finance/managed-fund/anchor/programs/mock-swap-router/Cargo.toml b/finance/managed-fund/anchor/programs/mock-swap-router/Cargo.toml index b358c81a0..5e9e2181d 100644 --- a/finance/managed-fund/anchor/programs/mock-swap-router/Cargo.toml +++ b/finance/managed-fund/anchor/programs/mock-swap-router/Cargo.toml @@ -20,11 +20,11 @@ custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] litesvm = "0.18.1" diff --git a/finance/options/anchor/README.md b/finance/options/anchor/README.md index 3fcff330c..dd4d7da33 100644 --- a/finance/options/anchor/README.md +++ b/finance/options/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/finance/options/anchor/programs/options/Cargo.toml b/finance/options/anchor/programs/options/Cargo.toml index d534b3710..e8f2d483f 100644 --- a/finance/options/anchor/programs/options/Cargo.toml +++ b/finance/options/anchor/programs/options/Cargo.toml @@ -26,11 +26,11 @@ profile = ["anchor-v2-testing/profile"] # party's token account for the asset they are about to be paid in, so a call # holder who has never held the underlying needs no separate setup transaction. # The receiving party is always the payer, so nobody funds another's rent. -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" # Declared only so Cargo feature-unification turns on `no-entrypoint`; without # these the test binary links two `entrypoint` symbols and fails to build. spl-token = { version = "9.0.0", features = ["no-entrypoint"] } @@ -51,7 +51,7 @@ spl-associated-token-account = { version = "8.0.0", features = ["no-entrypoint"] # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/finance/order-book/anchor/README.md b/finance/order-book/anchor/README.md index b8ec8435a..29b89b1eb 100644 --- a/finance/order-book/anchor/README.md +++ b/finance/order-book/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). @@ -1579,7 +1579,7 @@ run first. ### Prerequisites -- Anchor 2.0.0-rc.2 +- Anchor 2.0.0-rc.4 - Solana CLI (`solana -V`) - Rust stable (pinned at the repo root) diff --git a/finance/order-book/anchor/programs/order-book/Cargo.toml b/finance/order-book/anchor/programs/order-book/Cargo.toml index 0fae620a5..788210b0c 100644 --- a/finance/order-book/anchor/programs/order-book/Cargo.toml +++ b/finance/order-book/anchor/programs/order-book/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" # Used by the ported Openbook slab - `bytemuck::Pod` / `Zeroable` on every node # variant + `min_const_generics` so `[AnyNode; 1024]` can derive Pod without # hitting bytemuck's default-32 array cap. `static_assertions` keeps the slab @@ -49,7 +49,7 @@ static_assertions = "1.1" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs index 7293728b8..7b3d5b1fe 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs @@ -48,9 +48,9 @@ pub fn handle_place_order( price: u64, quantity: u64, ) -> Result<()> { - // `remaining_accounts()` takes `&mut context` and returns an owned vec, so - // collect it before anything borrows `context.accounts`. - let maker_accounts = context.remaining_accounts()?; + // `remaining_accounts()` takes `&mut context`, so call it before anything + // borrows `context.accounts`. + let maker_accounts = context.remaining_accounts(); // `AccountView` is Copy, and a copy still points at the same // account. v2's typed handles make the aliasing a compile error. diff --git a/finance/perpetual-futures/anchor/README.md b/finance/perpetual-futures/anchor/README.md index 802f6e746..1fdc712dc 100644 --- a/finance/perpetual-futures/anchor/README.md +++ b/finance/perpetual-futures/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/finance/perpetual-futures/anchor/programs/mock-price-feed/Cargo.toml b/finance/perpetual-futures/anchor/programs/mock-price-feed/Cargo.toml index 06f131cb9..518c14851 100644 --- a/finance/perpetual-futures/anchor/programs/mock-price-feed/Cargo.toml +++ b/finance/perpetual-futures/anchor/programs/mock-price-feed/Cargo.toml @@ -20,7 +20,7 @@ custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/Cargo.toml b/finance/perpetual-futures/anchor/programs/perpetual-futures/Cargo.toml index 09a321a50..f21197525 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/Cargo.toml +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/Cargo.toml @@ -25,7 +25,7 @@ profile = ["anchor-v2-testing/profile"] # init-if-needed lets add_liquidity create the provider's liquidity-provider # token account on their first deposit. The provider is the payer, so this does # not let one party fund another's rent. -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -33,7 +33,7 @@ wincode = { version = "0.6", features = ["derive"] } # `get_sysvar` wrapper: pinocchio (and so anchor-lang v2) ships only the # Clock and Rent sysvars as typed accessors. pinocchio = "0.11" -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" # Not used directly. Declared so Cargo feature unification turns on # `no-entrypoint` for the spl-token that anchor-spl pulls in; without it the # integration-test binary links two `entrypoint` symbols (this program's and @@ -60,7 +60,7 @@ solana-sysvar = "3" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/finance/prop-amm/anchor/README.md b/finance/prop-amm/anchor/README.md index f9083587e..ab3e4d1cf 100644 --- a/finance/prop-amm/anchor/README.md +++ b/finance/prop-amm/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/finance/prop-amm/anchor/programs/mock-price-feed/Cargo.toml b/finance/prop-amm/anchor/programs/mock-price-feed/Cargo.toml index 2f880f2d3..537691bc4 100644 --- a/finance/prop-amm/anchor/programs/mock-price-feed/Cargo.toml +++ b/finance/prop-amm/anchor/programs/mock-price-feed/Cargo.toml @@ -25,7 +25,7 @@ custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } diff --git a/finance/prop-amm/anchor/programs/prop-amm/Cargo.toml b/finance/prop-amm/anchor/programs/prop-amm/Cargo.toml index 97e6cc47b..9b2391753 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/Cargo.toml +++ b/finance/prop-amm/anchor/programs/prop-amm/Cargo.toml @@ -24,7 +24,7 @@ profile = ["anchor-v2-testing/profile"] [dependencies] # init-if-needed: swap creates the trader's destination token account when it # doesn't exist yet, so a first-time buyer needs no separate setup transaction. -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -32,7 +32,7 @@ wincode = { version = "0.6", features = ["derive"] } # `get_sysvar` wrapper: pinocchio (and so anchor-lang v2) ships only the # Clock and Rent sysvars as typed accessors. pinocchio = "0.11" -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" # For the LastRestartSlot sysvar (not re-exported by anchor-lang): the oracle # reader rejects prices from before a cluster restart. Same major as the # solana-sysvar anchor-lang itself uses, so only one copy is compiled in. @@ -57,7 +57,7 @@ spl-associated-token-account = { version = "8.0.0", features = ["no-entrypoint"] # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/finance/token-swap/README.md b/finance/token-swap/README.md index 19bca77ee..624eac393 100644 --- a/finance/token-swap/README.md +++ b/finance/token-swap/README.md @@ -17,7 +17,7 @@ The pool keeps `x * y = K` invariant: if `x` is the reserve of token A and `y` i - **Caller-supplied [slippage](https://www.investopedia.com/terms/s/slippage.asp) floors on every state-changing [instruction](https://solana.com/docs/terminology#instruction):** swaps revert with `SlippageExceeded` if the output falls below `min_output_amount`, deposits revert with `DepositBelowMinimum` if the LP mint amount falls below `minimum_lp_tokens_out`, withdrawals revert with `WithdrawalBelowMinimum` if either side falls below its floor. - **Defence-in-depth invariant check:** every swap re-verifies `effective_pool_a * effective_pool_b` doesn't decrease after the transfers, so a bug in the curve math fails the transaction instead of silently giving the trader too much. - All financial math in `u128` with checked arithmetic, matching how production Solana AMMs (Orca, Raydium, Meteora, Saber) do it. -- Anchor 2.0.0-rc.2 Rust [program](https://solana.com/docs/terminology#program) with LiteSVM integration tests. +- Anchor 2.0.0-rc.4 Rust [program](https://solana.com/docs/terminology#program) with LiteSVM integration tests. ## Why a CPAMM diff --git a/finance/token-swap/anchor/README.md b/finance/token-swap/anchor/README.md index 60d9eb99b..281469b82 100644 --- a/finance/token-swap/anchor/README.md +++ b/finance/token-swap/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/finance/token-swap/anchor/programs/token-swap/Cargo.toml b/finance/token-swap/anchor/programs/token-swap/Cargo.toml index 99ba1c5cd..379d8b7af 100644 --- a/finance/token-swap/anchor/programs/token-swap/Cargo.toml +++ b/finance/token-swap/anchor/programs/token-swap/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" # `fixed` removed: all financial math is now u128 + checked_*, matching how # production Solana AMMs (Orca, Raydium, Meteora, Saber) do it. Floats / # fixed-point types are not used for money in this program. @@ -46,7 +46,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/nft/metadata-pointer/anchor/README.md b/nft/metadata-pointer/anchor/README.md index b33e30e9e..20f3920dc 100644 --- a/nft/metadata-pointer/anchor/README.md +++ b/nft/metadata-pointer/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/nft/metadata-pointer/anchor/programs/extension_nft/Cargo.toml b/nft/metadata-pointer/anchor/programs/extension_nft/Cargo.toml index aaf65e17b..67b5f50b5 100644 --- a/nft/metadata-pointer/anchor/programs/extension_nft/Cargo.toml +++ b/nft/metadata-pointer/anchor/programs/extension_nft/Cargo.toml @@ -23,11 +23,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = { version = "2.0.0-rc.2" } +anchor-spl = { version = "2.0.0-rc.4" } # session-keys is Anchor v1 only: its `Session` derive requires # `Option>`, which v2 has no equivalent for. The # account layout is read directly in src/session.rs instead. @@ -58,7 +58,7 @@ anchor-spl = { version = "2.0.0-rc.2" } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/nft/minter/anchor/README.md b/nft/minter/anchor/README.md index 195278146..1d2a8dfa3 100644 --- a/nft/minter/anchor/README.md +++ b/nft/minter/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/nft/minter/anchor/programs/nft-minter/Cargo.toml b/nft/minter/anchor/programs/nft-minter/Cargo.toml index 3b7559cdc..cdfa659f7 100644 --- a/nft/minter/anchor/programs/nft-minter/Cargo.toml +++ b/nft/minter/anchor/programs/nft-minter/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } +anchor-spl = { version = "2.0.0-rc.4", features = ["metadata"] } [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/nft/minter/native/program/Cargo.toml b/nft/minter/native/program/Cargo.toml index 591bc4194..407cfcae0 100644 --- a/nft/minter/native/program/Cargo.toml +++ b/nft/minter/native/program/Cargo.toml @@ -10,7 +10,7 @@ solana-program.workspace = true solana-system-interface = { version = "2.0.0", features = ["bincode"] } spl-token-interface = "2.0.0" spl-associated-token-account-interface = "2.0.0" -# anchor-spl 2.0.0-rc.2 depends on `=5.1.2-alpha.2`. A range starting at a +# anchor-spl 2.0.0-rc.4 depends on `=5.1.2-alpha.2`. A range starting at a # stable release such as `^5.1.1` never matches a pre-release, so it and that # exact pin cannot both be satisfied in one lockfile. A range starting at the # pre-release itself can, which is what lets the anchor and native token diff --git a/nft/operations/anchor/README.md b/nft/operations/anchor/README.md index 0d6cb15df..e9136f691 100644 --- a/nft/operations/anchor/README.md +++ b/nft/operations/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/nft/operations/anchor/programs/mint-nft/Cargo.toml b/nft/operations/anchor/programs/mint-nft/Cargo.toml index c08d62982..475e0e6a9 100644 --- a/nft/operations/anchor/programs/mint-nft/Cargo.toml +++ b/nft/operations/anchor/programs/mint-nft/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } +anchor-spl = { version = "2.0.0-rc.4", features = ["metadata"] } [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/create-token/anchor/README.md b/tokens/create-token/anchor/README.md index 20889d5f8..802a74208 100644 --- a/tokens/create-token/anchor/README.md +++ b/tokens/create-token/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/create-token/anchor/programs/create-token/Cargo.toml b/tokens/create-token/anchor/programs/create-token/Cargo.toml index bb6421195..e4d29bca5 100644 --- a/tokens/create-token/anchor/programs/create-token/Cargo.toml +++ b/tokens/create-token/anchor/programs/create-token/Cargo.toml @@ -23,11 +23,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } +anchor-spl = { version = "2.0.0-rc.4", features = ["metadata"] } [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -44,7 +44,7 @@ anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/create-token/native/program/Cargo.toml b/tokens/create-token/native/program/Cargo.toml index e8d7cc739..8499dfe7f 100644 --- a/tokens/create-token/native/program/Cargo.toml +++ b/tokens/create-token/native/program/Cargo.toml @@ -9,7 +9,7 @@ borsh-derive.workspace = true solana-program.workspace = true solana-system-interface = { version = "2.0.0", features = ["bincode"] } spl-token-interface = "2.0.0" -# anchor-spl 2.0.0-rc.2 depends on `=5.1.2-alpha.2`. A range starting at a +# anchor-spl 2.0.0-rc.4 depends on `=5.1.2-alpha.2`. A range starting at a # stable release such as `^5.1.1` never matches a pre-release, so it and that # exact pin cannot both be satisfied in one lockfile. A range starting at the # pre-release itself can, which is what lets the anchor and native token diff --git a/tokens/external-delegate-token-master/anchor/README.md b/tokens/external-delegate-token-master/anchor/README.md index 8ea783b19..b42e5e51e 100644 --- a/tokens/external-delegate-token-master/anchor/README.md +++ b/tokens/external-delegate-token-master/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/Cargo.toml b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/Cargo.toml index 707eb5e46..f125e3161 100644 --- a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/Cargo.toml +++ b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" sha3 = "0.10.8" solana-secp256k1-recover = "2.0.0" @@ -45,7 +45,7 @@ solana-secp256k1-recover = "2.0.0" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/pda-mint-authority/anchor/README.md b/tokens/pda-mint-authority/anchor/README.md index a470605a5..7dbf29e81 100644 --- a/tokens/pda-mint-authority/anchor/README.md +++ b/tokens/pda-mint-authority/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/pda-mint-authority/anchor/programs/token-minter/Cargo.toml b/tokens/pda-mint-authority/anchor/programs/token-minter/Cargo.toml index 6d0b8372b..f1ffa107a 100644 --- a/tokens/pda-mint-authority/anchor/programs/token-minter/Cargo.toml +++ b/tokens/pda-mint-authority/anchor/programs/token-minter/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } +anchor-spl = { version = "2.0.0-rc.4", features = ["metadata"] } # For `Pack`, which gives the classic mint its `LEN`. anchor-spl re-exports # the state types but not the trait. solana-program-pack = "3" @@ -46,7 +46,7 @@ solana-program-pack = "3" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/pda-mint-authority/native/program/Cargo.toml b/tokens/pda-mint-authority/native/program/Cargo.toml index 3a719fbc0..b1695bed5 100644 --- a/tokens/pda-mint-authority/native/program/Cargo.toml +++ b/tokens/pda-mint-authority/native/program/Cargo.toml @@ -10,7 +10,7 @@ solana-program.workspace = true solana-system-interface = { version = "2.0.0", features = ["bincode"] } spl-token-interface = "2.0.0" spl-associated-token-account-interface = "2.0.0" -# anchor-spl 2.0.0-rc.2 depends on `=5.1.2-alpha.2`. A range starting at a +# anchor-spl 2.0.0-rc.4 depends on `=5.1.2-alpha.2`. A range starting at a # stable release such as `^5.1.1` never matches a pre-release, so it and that # exact pin cannot both be satisfied in one lockfile. A range starting at the # pre-release itself can, which is what lets the anchor and native token diff --git a/tokens/token-extensions/basics/anchor/README.md b/tokens/token-extensions/basics/anchor/README.md index aa13af9f2..9bcd6dc4c 100644 --- a/tokens/token-extensions/basics/anchor/README.md +++ b/tokens/token-extensions/basics/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/basics/anchor/programs/basics/Cargo.toml b/tokens/token-extensions/basics/anchor/programs/basics/Cargo.toml index 88f22e994..e30e5b3ea 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/Cargo.toml +++ b/tokens/token-extensions/basics/anchor/programs/basics/Cargo.toml @@ -22,8 +22,8 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-spl = "2.0.0-rc.2" -anchor-lang = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } @@ -43,7 +43,7 @@ wincode = { version = "0.6", features = ["derive"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/cpi-guard/anchor/README.md b/tokens/token-extensions/cpi-guard/anchor/README.md index a6b5adc92..52606600a 100644 --- a/tokens/token-extensions/cpi-guard/anchor/README.md +++ b/tokens/token-extensions/cpi-guard/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/Cargo.toml b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/Cargo.toml index 12f457427..11a577836 100644 --- a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/Cargo.toml +++ b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/default-account-state/anchor/README.md b/tokens/token-extensions/default-account-state/anchor/README.md index 48878f123..d92a63e27 100644 --- a/tokens/token-extensions/default-account-state/anchor/README.md +++ b/tokens/token-extensions/default-account-state/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/Cargo.toml b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/Cargo.toml index 88891c364..f500162a0 100644 --- a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/Cargo.toml +++ b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/group/anchor/README.md b/tokens/token-extensions/group/anchor/README.md index 4c535ed35..404c77403 100644 --- a/tokens/token-extensions/group/anchor/README.md +++ b/tokens/token-extensions/group/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/group/anchor/programs/group/Cargo.toml b/tokens/token-extensions/group/anchor/programs/group/Cargo.toml index 7eaea3965..e15992ddd 100644 --- a/tokens/token-extensions/group/anchor/programs/group/Cargo.toml +++ b/tokens/token-extensions/group/anchor/programs/group/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/immutable-owner/anchor/README.md b/tokens/token-extensions/immutable-owner/anchor/README.md index 80b58867d..c4c29cb79 100644 --- a/tokens/token-extensions/immutable-owner/anchor/README.md +++ b/tokens/token-extensions/immutable-owner/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/Cargo.toml b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/Cargo.toml index e2f473982..cd2378f17 100644 --- a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/Cargo.toml +++ b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/interest-bearing/anchor/README.md b/tokens/token-extensions/interest-bearing/anchor/README.md index cce3851e8..e6d01f637 100644 --- a/tokens/token-extensions/interest-bearing/anchor/README.md +++ b/tokens/token-extensions/interest-bearing/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/Cargo.toml b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/Cargo.toml index fe4d8a235..f420b2d3e 100644 --- a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/Cargo.toml +++ b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/Cargo.toml @@ -23,11 +23,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -44,7 +44,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/memo-transfer/anchor/README.md b/tokens/token-extensions/memo-transfer/anchor/README.md index b479d24c6..5bec3bb79 100644 --- a/tokens/token-extensions/memo-transfer/anchor/README.md +++ b/tokens/token-extensions/memo-transfer/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/Cargo.toml b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/Cargo.toml index 6b2318b8b..f61939363 100644 --- a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/Cargo.toml +++ b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/metadata/anchor/README.md b/tokens/token-extensions/metadata/anchor/README.md index 1a5d76988..766fe16df 100644 --- a/tokens/token-extensions/metadata/anchor/README.md +++ b/tokens/token-extensions/metadata/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/metadata/anchor/programs/metadata/Cargo.toml b/tokens/token-extensions/metadata/anchor/programs/metadata/Cargo.toml index 90c3bca13..0c3813d84 100644 --- a/tokens/token-extensions/metadata/anchor/programs/metadata/Cargo.toml +++ b/tokens/token-extensions/metadata/anchor/programs/metadata/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" spl-token-metadata-interface = "0.8.0" spl-type-length-value = "0.9.1" @@ -45,7 +45,7 @@ spl-type-length-value = "0.9.1" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/mint-close-authority/anchor/README.md b/tokens/token-extensions/mint-close-authority/anchor/README.md index b62fb54ed..415857fae 100644 --- a/tokens/token-extensions/mint-close-authority/anchor/README.md +++ b/tokens/token-extensions/mint-close-authority/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/Cargo.toml b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/Cargo.toml index 29ab7358b..1ea7eab0a 100644 --- a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/Cargo.toml +++ b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/Cargo.toml @@ -19,11 +19,11 @@ idl-build = ["anchor-lang/idl-build"] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -40,7 +40,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/non-transferable/anchor/README.md b/tokens/token-extensions/non-transferable/anchor/README.md index 2b1483862..ae892b612 100644 --- a/tokens/token-extensions/non-transferable/anchor/README.md +++ b/tokens/token-extensions/non-transferable/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/Cargo.toml b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/Cargo.toml index 3b60f39b1..ca2b543a2 100644 --- a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/Cargo.toml +++ b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/Cargo.toml @@ -19,11 +19,11 @@ idl-build = ["anchor-lang/idl-build"] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -40,7 +40,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/permanent-delegate/anchor/README.md b/tokens/token-extensions/permanent-delegate/anchor/README.md index 76230174b..e95c63eca 100644 --- a/tokens/token-extensions/permanent-delegate/anchor/README.md +++ b/tokens/token-extensions/permanent-delegate/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/Cargo.toml b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/Cargo.toml index 83f3333bc..530d2eb79 100644 --- a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/Cargo.toml +++ b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/Cargo.toml @@ -23,11 +23,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -44,7 +44,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/transfer-fee/anchor/README.md b/tokens/token-extensions/transfer-fee/anchor/README.md index b4b3e6b52..a8449981d 100644 --- a/tokens/token-extensions/transfer-fee/anchor/README.md +++ b/tokens/token-extensions/transfer-fee/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/Cargo.toml b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/Cargo.toml index e66a462f0..e5e2e51c0 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/Cargo.toml +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/Cargo.toml @@ -19,11 +19,11 @@ idl-build = ["anchor-lang/idl-build"] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -40,7 +40,7 @@ anchor-spl = "2.0.0-rc.2" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs index c7b251dd2..57322b74c 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs @@ -15,9 +15,10 @@ pub struct HarvestAccountConstraints { pub fn process_harvest(context: &mut Context) -> Result<()> { // Using remaining accounts to allow for passing in an unknown number of token accounts to harvest from // Check that remaining accounts are token accounts for the mint to harvest to - // `remaining_accounts()` takes `&mut context` and hands back an owned vec, - // so collect it before anything borrows `context.accounts`. - let mut candidates = context.remaining_accounts()?; + // `remaining_accounts()` returns a shared slice, and `CpiHandleMut::writable` + // needs `&mut AccountView`, so copy the views into a vec the handles can + // borrow mutably. An `AccountView` copy still points at the same account. + let mut candidates = context.remaining_accounts().to_vec(); let mint_address = *context.accounts.mint_account.address(); // v2 has no `InterfaceAccount::try_from`; `AnchorAccount::load` is the diff --git a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/README.md b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/README.md index 14e1df427..65abc1518 100644 --- a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/README.md +++ b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/Cargo.toml index 858190af0..743d9895a 100644 --- a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/Cargo.toml @@ -30,11 +30,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" spl-discriminator = "0.4.1" spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" @@ -54,7 +54,7 @@ spl-transfer-hook-interface = "0.9.0" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/README.md b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/README.md index 23aee3d3d..f8bf90475 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/README.md +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/Cargo.toml b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/Cargo.toml index ddfa2fbf8..b4d700b14 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/Cargo.toml @@ -28,13 +28,13 @@ profile = ["anchor-v2-testing/profile"] [dependencies] # interface-instructions feature was removed in Anchor 1.0 and does not exist in v2 -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } # v2's anchor-spl has only `guardrails` (default) and `metadata`; the # Token-2022 modules are unconditional now. -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" spl-tlv-account-resolution = "0.11.1" spl-transfer-hook-interface = { version = "2.1.0" } @@ -55,7 +55,7 @@ spl-discriminator = "0.5.1" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/transfer-hook/allow-list/anchor/README.md b/tokens/token-extensions/transfer-hook/allow-list/anchor/README.md index 994bef95a..8bb2f8d1e 100644 --- a/tokens/token-extensions/transfer-hook/allow-list/anchor/README.md +++ b/tokens/token-extensions/transfer-hook/allow-list/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/transfer-hook/allow-list/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/allow-list/anchor/programs/transfer-hook/Cargo.toml index 9de761439..19ac3d32c 100644 --- a/tokens/token-extensions/transfer-hook/allow-list/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/allow-list/anchor/programs/transfer-hook/Cargo.toml @@ -30,11 +30,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" spl-discriminator = "0.4.1" spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" @@ -54,7 +54,7 @@ spl-transfer-hook-interface = "0.9.0" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/transfer-hook/counter/anchor/README.md b/tokens/token-extensions/transfer-hook/counter/anchor/README.md index e1eb0512d..7805d8cb9 100644 --- a/tokens/token-extensions/transfer-hook/counter/anchor/README.md +++ b/tokens/token-extensions/transfer-hook/counter/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/Cargo.toml index 686d45658..91dedb17e 100644 --- a/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/Cargo.toml @@ -30,11 +30,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" spl-discriminator = "0.4.1" spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" @@ -54,7 +54,7 @@ spl-transfer-hook-interface = "0.9.0" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/transfer-hook/hello-world/anchor/README.md b/tokens/token-extensions/transfer-hook/hello-world/anchor/README.md index 2731b138a..305f1ee92 100644 --- a/tokens/token-extensions/transfer-hook/hello-world/anchor/README.md +++ b/tokens/token-extensions/transfer-hook/hello-world/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/Cargo.toml index 0aa6edc56..e137f4453 100644 --- a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/Cargo.toml @@ -30,11 +30,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" spl-discriminator = "0.4.1" spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" @@ -54,7 +54,7 @@ spl-transfer-hook-interface = "0.9.0" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/README.md b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/README.md index f0ae21fcd..637023587 100644 --- a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/README.md +++ b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/Cargo.toml index 3fc291653..fe0779dc5 100644 --- a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/Cargo.toml @@ -30,11 +30,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" # SPL crates v3.x-compatible - uses solana-program-error 3.x matching anchor-lang v2 spl-discriminator = "0.5.2" spl-tlv-account-resolution = "0.11.1" @@ -55,7 +55,7 @@ spl-transfer-hook-interface = "2.1.0" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/README.md b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/README.md index 33180dc77..0ac9126eb 100644 --- a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/README.md +++ b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/Cargo.toml b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/Cargo.toml index 647ba6caf..e1254e30f 100644 --- a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/Cargo.toml @@ -26,11 +26,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = { version = "2.0.0-rc.2", features = ["compat"] } +anchor-lang = { version = "2.0.0-rc.4", features = ["compat"] } # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = "2.0.0-rc.2" +anchor-spl = "2.0.0-rc.4" spl-discriminator = "0.4.1" spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" @@ -50,7 +50,7 @@ spl-transfer-hook-interface = "0.9.0" # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/src/instructions/configure_admin.rs b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/src/instructions/configure_admin.rs index 5ba16083a..8c7f3968b 100644 --- a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/src/instructions/configure_admin.rs +++ b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/src/instructions/configure_admin.rs @@ -2,16 +2,15 @@ use {crate::state::AdminConfig, anchor_lang::prelude::*}; #[derive(Accounts)] pub struct ConfigureAdminAccountConstraints { - // Bootstrapping the config passes the same key as both `admin` and - // `new_admin`, so the two slots legitimately alias. v2 rejects an account - // that appears twice while any of its slots is in the mutable mask, and it - // flags *both* indices, so both carry `unsafe(dup)`, which keeps them - // writable while taking them out of that mask. - #[account(unsafe(dup))] + // Bootstrapping the config passes the same address as both `admin` and + // `new_admin`. Anchor v2 catches aliasing through the borrow each account + // wrapper takes on the account's data, and `Signer` and `UncheckedAccount` + // take none, so the two fields may name the same account. + #[account(mut)] pub admin: Signer, /// CHECK: the new admin - #[account(unsafe(dup))] + #[account(mut)] pub new_admin: UncheckedAccount, /// To hold the address of the admin that controls switches diff --git a/tokens/token-minter/anchor/README.md b/tokens/token-minter/anchor/README.md index 69230aaf0..1f6bcd83d 100644 --- a/tokens/token-minter/anchor/README.md +++ b/tokens/token-minter/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/token-minter/anchor/programs/token-minter/Cargo.toml b/tokens/token-minter/anchor/programs/token-minter/Cargo.toml index d304ff4ff..6469a8cfd 100644 --- a/tokens/token-minter/anchor/programs/token-minter/Cargo.toml +++ b/tokens/token-minter/anchor/programs/token-minter/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } +anchor-spl = { version = "2.0.0-rc.4", features = ["metadata"] } [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/token-minter/anchor/programs/token-minter/src/instructions/mint.rs b/tokens/token-minter/anchor/programs/token-minter/src/instructions/mint.rs index 68a650163..29f7d9cc4 100644 --- a/tokens/token-minter/anchor/programs/token-minter/src/instructions/mint.rs +++ b/tokens/token-minter/anchor/programs/token-minter/src/instructions/mint.rs @@ -9,10 +9,11 @@ use { #[derive(Accounts)] pub struct MintTokenAccountConstraints { // Minting to yourself is ordinary, so `mint_authority` and `recipient` may - // be the same account. v2 rejects an account that appears twice while any - // of its slots is in the mutable mask, and `unsafe(dup)` takes this one out - // of that mask while keeping it writable (it is still the init payer). - #[account(unsafe(dup))] + // be the same account. Anchor v2 catches aliasing through the borrow each + // account wrapper takes on the account's data, and `Signer` and + // `SystemAccount` take none, so the two fields may name the same account. + // `mint_authority` is writable because it pays for the token account. + #[account(mut)] pub mint_authority: Signer, pub recipient: SystemAccount, diff --git a/tokens/token-minter/native/program/Cargo.toml b/tokens/token-minter/native/program/Cargo.toml index 87fac294a..288cf8d94 100644 --- a/tokens/token-minter/native/program/Cargo.toml +++ b/tokens/token-minter/native/program/Cargo.toml @@ -10,7 +10,7 @@ solana-program.workspace = true solana-system-interface = { version = "2.0.0", features = ["bincode"] } spl-token-interface = "2.0.0" spl-associated-token-account-interface = "2.0.0" -# anchor-spl 2.0.0-rc.2 depends on `=5.1.2-alpha.2`. A range starting at a +# anchor-spl 2.0.0-rc.4 depends on `=5.1.2-alpha.2`. A range starting at a # stable release such as `^5.1.1` never matches a pre-release, so it and that # exact pin cannot both be satisfied in one lockfile. A range starting at the # pre-release itself can, which is what lets the anchor and native token diff --git a/tokens/transfer-tokens/anchor/README.md b/tokens/transfer-tokens/anchor/README.md index 5b5f111ff..25867f71b 100644 --- a/tokens/transfer-tokens/anchor/README.md +++ b/tokens/transfer-tokens/anchor/README.md @@ -2,7 +2,7 @@ > [!NOTE] > This is the **Anchor v2** copy of this example. Every `anchor` command on this page -> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.2 --locked` (avm has +> needs the v2 CLI: `cargo install anchor-cli --version 2.0.0-rc.4 --locked` (avm has > no prebuilt binary for this pre-release). The Anchor v1 version of this example is in > [`../anchor-v1`](../anchor-v1/). diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/Cargo.toml b/tokens/transfer-tokens/anchor/programs/transfer-tokens/Cargo.toml index dfa010507..6a726805b 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/Cargo.toml +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/Cargo.toml @@ -22,11 +22,11 @@ custom-panic = [] profile = ["anchor-v2-testing/profile"] [dependencies] -anchor-lang = "2.0.0-rc.2" +anchor-lang = "2.0.0-rc.4" # The `#[program]` macro expands to `wincode` paths for instruction-data # (de)serialization, so the crate has to be a direct dependency. wincode = { version = "0.6", features = ["derive"] } -anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } +anchor-spl = { version = "2.0.0-rc.4", features = ["metadata"] } [dev-dependencies] # Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the @@ -43,7 +43,7 @@ anchor-spl = { version = "2.0.0-rc.2", features = ["metadata"] } # development happens, so a later revision can carry breakage as easily as # fixes. When `anchor-v2-testing` reaches crates.io, drop the git source for # an ordinary version. -anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "a20660219882af5f199d56ea3f9326f387f89d8b" } +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "2cdb58ba8fd9139942ffe235ed5c5c01072138b8" } # LiteSVM 0.18.1 asks for the Agave crates with `^4.3` ranges but does not # compile against Agave 4.4.0. These two hold the Agave crates at 4.3; the rest # follow, because Agave pins its own crates to one another exactly. Remove both diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs index 894f735cc..3cad7b746 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs @@ -9,10 +9,11 @@ use { #[derive(Accounts)] pub struct MintTokenAccountConstraints { // The mint authority and the recipient may be the same account (minting or - // sending to yourself). v2 rejects an account that appears twice while any - // of its slots is in the mutable mask, and `unsafe(dup)` takes this one out - // of that mask while keeping it writable. - #[account(unsafe(dup))] + // sending to yourself). Anchor v2 catches aliasing through the borrow each + // account wrapper takes on the account's data, and `Signer` and + // `SystemAccount` take none, so the two fields may name the same account. + // `mint_authority` is writable because it pays for the token account. + #[account(mut)] pub mint_authority: Signer, pub recipient: SystemAccount, diff --git a/tokens/transfer-tokens/native/program/Cargo.toml b/tokens/transfer-tokens/native/program/Cargo.toml index a39ba2725..4d8bb3f8a 100644 --- a/tokens/transfer-tokens/native/program/Cargo.toml +++ b/tokens/transfer-tokens/native/program/Cargo.toml @@ -10,7 +10,7 @@ solana-program.workspace = true solana-system-interface = { version = "2.0.0", features = ["bincode"] } spl-token-interface = "2.0.0" spl-associated-token-account-interface = "2.0.0" -# anchor-spl 2.0.0-rc.2 depends on `=5.1.2-alpha.2`. A range starting at a +# anchor-spl 2.0.0-rc.4 depends on `=5.1.2-alpha.2`. A range starting at a # stable release such as `^5.1.1` never matches a pre-release, so it and that # exact pin cannot both be satisfied in one lockfile. A range starting at the # pre-release itself can, which is what lets the anchor and native token From cc4f0c00a05bdfefc6834f302cf095b72d9b7f7d Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 16:30:12 +0000 Subject: [PATCH 2/9] Unbox account fields and drop Interface's lifetime for rc.4 rc.4 removed Box's AnchorAccount impl (anchor#5185) and the lifetime parameter on Interface (anchor#4891). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB --- .../src/instructions/claim_refund.rs | 2 +- .../src/instructions/claim_winnings.rs | 2 +- .../src/instructions/close_event.rs | 2 +- .../src/instructions/initialize_config.rs | 2 +- .../src/instructions/initialize_event.rs | 2 +- .../src/instructions/place_bet.rs | 14 +++++------ .../src/instructions/settle_event.rs | 2 +- .../betting-market/src/instructions/shared.rs | 6 ++--- .../escrow/src/instructions/cancel_offer.rs | 2 +- .../escrow/src/instructions/make_offer.rs | 2 +- .../escrow/src/instructions/shared.rs | 4 ++-- .../escrow/src/instructions/take_offer.rs | 8 +++---- .../fundraiser/src/instructions/checker.rs | 2 +- .../fundraiser/src/instructions/close.rs | 2 +- .../fundraiser/src/instructions/contribute.rs | 2 +- .../src/instructions/initialize_fundraiser.rs | 2 +- .../fundraiser/src/instructions/refund.rs | 2 +- .../admin/collect_program_fees.rs | 2 +- .../instructions/admin/initialize_reserve.rs | 2 +- .../borrow_obligation_liquidity.rs | 2 +- .../deposit_obligation_collateral.rs | 2 +- .../instructions/deposit_reserve_liquidity.rs | 2 +- .../src/instructions/liquidate_obligation.rs | 24 +++++++++---------- .../instructions/redeem_reserve_collateral.rs | 2 +- .../repay_obligation_liquidity.rs | 2 +- .../withdraw_obligation_collateral.rs | 2 +- .../src/instructions/add_asset.rs | 14 +++++------ .../src/instructions/collect_fees.rs | 2 +- .../managed-fund/src/instructions/deposit.rs | 14 +++++------ .../src/instructions/initialize_fund.rs | 8 +++---- .../src/instructions/rebalance.rs | 8 +++---- .../src/instructions/set_weight.rs | 4 ++-- .../managed-fund/src/instructions/withdraw.rs | 14 +++++------ .../src/instructions/initialize_router.rs | 2 +- .../src/instructions/set_rate.rs | 2 +- .../src/instructions/swap_asset_for_usdc.rs | 12 +++++----- .../src/instructions/swap_usdc_for_asset.rs | 12 +++++----- .../options/src/instructions/buy_option.rs | 14 +++++------ .../options/src/instructions/cancel_option.rs | 18 +++++++------- .../options/src/instructions/collect_fees.rs | 12 +++++----- .../src/instructions/collect_proceeds.rs | 18 +++++++------- .../src/instructions/exercise_option.rs | 18 +++++++------- .../src/instructions/initialize_market.rs | 12 +++++----- .../src/instructions/reclaim_collateral.rs | 18 +++++++------- .../options/src/instructions/shared.rs | 4 ++-- .../options/src/instructions/write_option.rs | 18 +++++++------- .../src/instructions/admin/withdraw_fees.rs | 8 +++---- .../src/instructions/initialize_market.rs | 2 +- .../src/instructions/place_order.rs | 16 ++++++------- .../src/instructions/settle_funds.rs | 14 +++++------ .../src/instructions/add_liquidity.rs | 14 +++++------ .../src/instructions/close_position.rs | 12 +++++----- .../src/instructions/collect_fees.rs | 10 ++++---- .../src/instructions/initialize_pool.rs | 10 ++++---- .../src/instructions/liquidate_position.rs | 14 +++++------ .../src/instructions/open_position.rs | 12 +++++----- .../src/instructions/remove_liquidity.rs | 14 +++++------ .../src/instructions/update_price_average.rs | 2 +- .../prop-amm/src/instructions/close_market.rs | 8 +++---- .../src/instructions/deposit_inventory.rs | 16 ++++++------- .../src/instructions/initialize_market.rs | 12 +++++----- .../prop-amm/src/instructions/set_quote.rs | 2 +- .../prop-amm/src/instructions/swap.rs | 16 ++++++------- .../src/instructions/withdraw_inventory.rs | 16 ++++++------- .../instructions/admin/claim_admin_fees.rs | 14 +++++------ .../src/instructions/deposit_liquidity.rs | 20 ++++++++-------- .../src/instructions/initialize_pool.rs | 22 ++++++++--------- .../src/instructions/swap_tokens.rs | 14 +++++------ .../src/instructions/withdraw_liquidity.rs | 18 +++++++------- .../programs/token-swap/src/liquidity.rs | 2 +- .../src/instructions/authority_transfer.rs | 2 +- .../src/instructions/transfer_tokens.rs | 2 +- .../create_associated_token_account.rs | 2 +- .../basics/src/instructions/create_token.rs | 2 +- .../src/instructions/create_token_account.rs | 2 +- .../basics/src/instructions/mint_token.rs | 2 +- .../basics/src/instructions/transfer_token.rs | 2 +- .../src/instructions/attach_to_mint.rs | 2 +- .../abl-token/src/instructions/init_config.rs | 2 +- .../abl-token/src/instructions/init_wallet.rs | 2 +- .../src/instructions/remove_wallet.rs | 2 +- .../src/instructions/transfer_hook.rs | 14 +++++------ .../src/instructions/create.rs | 2 +- .../transfer-tokens/src/instructions/mint.rs | 2 +- .../src/instructions/transfer.rs | 2 +- 85 files changed, 326 insertions(+), 326 deletions(-) diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/claim_refund.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/claim_refund.rs index 1f97097eb..98dc507c3 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/claim_refund.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/claim_refund.rs @@ -54,7 +54,7 @@ pub struct ClaimRefundAccountConstraints { )] pub vault: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } pub fn handle_claim_refund(context: &mut Context) -> Result<()> { diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/claim_winnings.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/claim_winnings.rs index 6de4fd652..fdcaf16a8 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/claim_winnings.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/claim_winnings.rs @@ -54,7 +54,7 @@ pub struct ClaimWinningsAccountConstraints { )] pub vault: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } pub fn handle_claim_winnings(context: &mut Context) -> Result<()> { diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/close_event.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/close_event.rs index f8651800e..49f05f6d5 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/close_event.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/close_event.rs @@ -58,7 +58,7 @@ pub struct CloseEventAccountConstraints { pub fee_recipient_token_account: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/initialize_config.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/initialize_config.rs index 94b2af7da..537a49b12 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/initialize_config.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/initialize_config.rs @@ -23,7 +23,7 @@ pub struct InitializeConfigAccountConstraints { )] pub config: BorshAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/initialize_event.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/initialize_event.rs index b74aa3cff..cb564ca36 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/initialize_event.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/initialize_event.rs @@ -48,7 +48,7 @@ pub struct InitializeEventAccountConstraints { pub vault: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/place_bet.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/place_bet.rs index ee5919e57..8d311021a 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/place_bet.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/place_bet.rs @@ -21,7 +21,7 @@ pub struct PlaceBetAccountConstraints { pub config: BorshAccount, #[account(mint::token_program = token_program, address = config.token_mint)] - pub token_mint: Box>, + pub token_mint: InterfaceAccount, #[account( mut, @@ -29,14 +29,14 @@ pub struct PlaceBetAccountConstraints { bump = event.bump, address = outcome.event, )] - pub event: Box>, + pub event: BorshAccount, #[account( mut, seeds = [b"outcome", event.address().as_ref(), &[outcome.index]], bump = outcome.bump, )] - pub outcome: Box>, + pub outcome: BorshAccount, #[account( mut, @@ -44,7 +44,7 @@ pub struct PlaceBetAccountConstraints { associated_token::authority = bettor, associated_token::token_program = token_program, )] - pub bettor_token_account: Box>, + pub bettor_token_account: InterfaceAccount, #[account( mut, @@ -52,7 +52,7 @@ pub struct PlaceBetAccountConstraints { associated_token::authority = event, associated_token::token_program = token_program, )] - pub vault: Box>, + pub vault: InterfaceAccount, #[account( init_if_needed, @@ -61,10 +61,10 @@ pub struct PlaceBetAccountConstraints { seeds = [b"bet", outcome.address().as_ref(), bettor.address().as_ref()], bump )] - pub bet: Box>, + pub bet: BorshAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/settle_event.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/settle_event.rs index 9da75ea54..d1d256719 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/settle_event.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/settle_event.rs @@ -65,7 +65,7 @@ pub struct SettleEventAccountConstraints { pub fee_recipient_token_account: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs index 443a8d0d1..2e325474b 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs @@ -15,7 +15,7 @@ pub fn transfer_tokens_to_vault( amount: u64, mint: &InterfaceAccount, authority: &Signer, - token_program: &Interface<'static, TokenInterface>, + token_program: &Interface, ) -> Result<()> { let decimals = mint.decimals(); let transfer_accounts = TransferChecked { @@ -63,7 +63,7 @@ pub fn transfer_tokens_from_vault( amount: u64, mint: &InterfaceAccount, event: &EventSigner, - token_program: &Interface<'static, TokenInterface>, + token_program: &Interface, ) -> Result<()> { let event_id_bytes = event.id.to_le_bytes(); let seeds = &[b"event".as_ref(), event_id_bytes.as_ref(), &[event.bump]]; @@ -88,7 +88,7 @@ pub fn close_vault( vault: &mut InterfaceAccount, destination: &mut Signer, event: &EventSigner, - token_program: &Interface<'static, TokenInterface>, + token_program: &Interface, ) -> Result<()> { let event_id_bytes = event.id.to_le_bytes(); let seeds = &[b"event".as_ref(), event_id_bytes.as_ref(), &[event.bump]]; diff --git a/finance/escrow/anchor/programs/escrow/src/instructions/cancel_offer.rs b/finance/escrow/anchor/programs/escrow/src/instructions/cancel_offer.rs index e62dbe7e8..071d68e05 100644 --- a/finance/escrow/anchor/programs/escrow/src/instructions/cancel_offer.rs +++ b/finance/escrow/anchor/programs/escrow/src/instructions/cancel_offer.rs @@ -46,7 +46,7 @@ pub struct CancelOfferAccountConstraints { pub vault: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/escrow/anchor/programs/escrow/src/instructions/make_offer.rs b/finance/escrow/anchor/programs/escrow/src/instructions/make_offer.rs index 5ba13255d..3c816d874 100644 --- a/finance/escrow/anchor/programs/escrow/src/instructions/make_offer.rs +++ b/finance/escrow/anchor/programs/escrow/src/instructions/make_offer.rs @@ -65,7 +65,7 @@ pub struct MakeOfferAccountConstraints { pub vault: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs b/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs index 3e2634f23..920b414ae 100644 --- a/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs +++ b/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs @@ -14,7 +14,7 @@ pub fn transfer_tokens( amount: &u64, mint: &InterfaceAccount, authority: AccountView, - token_program: &Interface<'static, TokenInterface>, + token_program: &Interface, owning_pda_seeds: Option<&[&[u8]]>, ) -> Result<()> { let decimals = mint.decimals(); @@ -43,7 +43,7 @@ pub fn close_token_account( token_account: &mut InterfaceAccount, mut destination: AccountView, authority: AccountView, - token_program: &Interface<'static, TokenInterface>, + token_program: &Interface, owning_pda_seeds: Option<&[&[u8]]>, ) -> Result<()> { let close_accounts = CloseAccount { diff --git a/finance/escrow/anchor/programs/escrow/src/instructions/take_offer.rs b/finance/escrow/anchor/programs/escrow/src/instructions/take_offer.rs index 3a800600c..5acb247be 100644 --- a/finance/escrow/anchor/programs/escrow/src/instructions/take_offer.rs +++ b/finance/escrow/anchor/programs/escrow/src/instructions/take_offer.rs @@ -30,7 +30,7 @@ pub struct TakeOfferAccountConstraints { associated_token::authority = taker, associated_token::token_program = token_program, )] - pub taker_token_account_a: Box>, + pub taker_token_account_a: InterfaceAccount, #[account( mut, @@ -38,7 +38,7 @@ pub struct TakeOfferAccountConstraints { associated_token::authority = taker, associated_token::token_program = token_program, )] - pub taker_token_account_b: Box>, + pub taker_token_account_b: InterfaceAccount, // The maker's token-B ATA is initialized in make_offer, paid by the maker. #[account( @@ -47,7 +47,7 @@ pub struct TakeOfferAccountConstraints { associated_token::authority = maker, associated_token::token_program = token_program, )] - pub maker_token_account_b: Box>, + pub maker_token_account_b: InterfaceAccount, #[account( mut, @@ -66,7 +66,7 @@ pub struct TakeOfferAccountConstraints { pub vault: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/checker.rs b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/checker.rs index 79b7ae0da..1b9d65d44 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/checker.rs +++ b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/checker.rs @@ -37,7 +37,7 @@ pub struct CheckContributionsAccountConstraints { )] pub maker_ata: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, diff --git a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/close.rs b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/close.rs index 2e452e77f..761091afe 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/close.rs +++ b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/close.rs @@ -42,7 +42,7 @@ pub struct CloseFundraiserAccountConstraints { )] pub maker_ata: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, diff --git a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/contribute.rs b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/contribute.rs index 94305bbaa..228dd116f 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/contribute.rs +++ b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/contribute.rs @@ -48,7 +48,7 @@ pub struct ContributeAccountConstraints { )] pub vault: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/initialize_fundraiser.rs b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/initialize_fundraiser.rs index de2fe5ad4..657de88e1 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/initialize_fundraiser.rs +++ b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/initialize_fundraiser.rs @@ -33,7 +33,7 @@ pub struct InitializeFundraiserAccountConstraints { pub system_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, } diff --git a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/refund.rs b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/refund.rs index f7b8b5f6d..e5415cb01 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/refund.rs +++ b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/refund.rs @@ -53,7 +53,7 @@ pub struct RefundAccountConstraints { )] pub vault: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/lending/anchor/programs/lending/src/instructions/admin/collect_program_fees.rs b/finance/lending/anchor/programs/lending/src/instructions/admin/collect_program_fees.rs index ada11fcb7..cc97b9b3b 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/admin/collect_program_fees.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/admin/collect_program_fees.rs @@ -82,5 +82,5 @@ pub struct CollectProgramFees { #[account(mut)] pub owner_liquidity: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/lending/anchor/programs/lending/src/instructions/admin/initialize_reserve.rs b/finance/lending/anchor/programs/lending/src/instructions/admin/initialize_reserve.rs index e5ceec7de..75ec9dbea 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/admin/initialize_reserve.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/admin/initialize_reserve.rs @@ -84,7 +84,7 @@ pub struct InitializeReserve { )] pub price_feed: BorshAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/lending/anchor/programs/lending/src/instructions/borrow_obligation_liquidity.rs b/finance/lending/anchor/programs/lending/src/instructions/borrow_obligation_liquidity.rs index 09b2e12e5..dd26d2b6e 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/borrow_obligation_liquidity.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/borrow_obligation_liquidity.rs @@ -130,5 +130,5 @@ pub struct BorrowObligationLiquidity { #[account(mut)] pub user_liquidity: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/lending/anchor/programs/lending/src/instructions/deposit_obligation_collateral.rs b/finance/lending/anchor/programs/lending/src/instructions/deposit_obligation_collateral.rs index 60856ea74..19ad34a63 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/deposit_obligation_collateral.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/deposit_obligation_collateral.rs @@ -74,7 +74,7 @@ pub struct DepositObligationCollateral { #[account(mut)] pub user_share: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/lending/anchor/programs/lending/src/instructions/deposit_reserve_liquidity.rs b/finance/lending/anchor/programs/lending/src/instructions/deposit_reserve_liquidity.rs index 8aaefb45a..015ea4eb8 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/deposit_reserve_liquidity.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/deposit_reserve_liquidity.rs @@ -123,5 +123,5 @@ pub struct DepositReserveLiquidity { pub owner: Signer, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs b/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs index ecbaef66b..0d386b49e 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs @@ -246,7 +246,7 @@ pub fn handle_liquidate_obligation( #[derive(Accounts)] pub struct LiquidateObligation { #[account(mut)] - pub obligation: Box>, + pub obligation: BorshAccount, pub liquidator: Signer, @@ -254,27 +254,27 @@ pub struct LiquidateObligation { mut, constraint = repay_reserve.lending_market == obligation.lending_market @ LendingError::MarketMismatch, )] - pub repay_reserve: Box>, + pub repay_reserve: BorshAccount, #[account( constraint = collateral_reserve.lending_market == obligation.lending_market @ LendingError::MarketMismatch, )] - pub collateral_reserve: Box>, + pub collateral_reserve: BorshAccount, #[account(address = repay_reserve.price_feed)] - pub repay_price_feed: Box>, + pub repay_price_feed: BorshAccount, #[account(address = collateral_reserve.price_feed)] - pub collateral_price_feed: Box>, + pub collateral_price_feed: BorshAccount, #[account(address = repay_reserve.liquidity_mint)] - pub repay_liquidity_mint: Box>, + pub repay_liquidity_mint: InterfaceAccount, #[account(address = collateral_reserve.share_mint)] - pub collateral_share_mint: Box>, + pub collateral_share_mint: InterfaceAccount, #[account(mut, address = repay_reserve.liquidity_vault)] - pub repay_liquidity_vault: Box>, + pub repay_liquidity_vault: InterfaceAccount, #[account( mut, @@ -283,13 +283,13 @@ pub struct LiquidateObligation { token::mint = collateral_share_mint, token::authority = obligation, )] - pub obligation_collateral_vault: Box>, + pub obligation_collateral_vault: InterfaceAccount, #[account(mut)] - pub liquidator_repay_source: Box>, + pub liquidator_repay_source: InterfaceAccount, #[account(mut)] - pub liquidator_collateral_dest: Box>, + pub liquidator_collateral_dest: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/lending/anchor/programs/lending/src/instructions/redeem_reserve_collateral.rs b/finance/lending/anchor/programs/lending/src/instructions/redeem_reserve_collateral.rs index 5c00cdf7f..a23e68a33 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/redeem_reserve_collateral.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/redeem_reserve_collateral.rs @@ -110,5 +110,5 @@ pub struct RedeemReserveCollateral { pub owner: Signer, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/lending/anchor/programs/lending/src/instructions/repay_obligation_liquidity.rs b/finance/lending/anchor/programs/lending/src/instructions/repay_obligation_liquidity.rs index 522a77eb1..80b8a5d0d 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/repay_obligation_liquidity.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/repay_obligation_liquidity.rs @@ -96,5 +96,5 @@ pub struct RepayObligationLiquidity { pub repayer: Signer, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/lending/anchor/programs/lending/src/instructions/withdraw_obligation_collateral.rs b/finance/lending/anchor/programs/lending/src/instructions/withdraw_obligation_collateral.rs index 61e586f15..d9f7fd638 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/withdraw_obligation_collateral.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/withdraw_obligation_collateral.rs @@ -198,5 +198,5 @@ pub struct WithdrawObligationCollateral { #[account(mut)] pub user_share: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/add_asset.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/add_asset.rs index d6b405ab4..a40236878 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/add_asset.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/add_asset.rs @@ -17,12 +17,12 @@ pub struct AddAssetAccountConstraints { seeds = [b"fund", fund.index.to_le_bytes()], bump = fund.bump, )] - pub fund: Box>, + pub fund: BorshAccount, #[account(address = fund.registry @ FundError::InvalidRegistry)] - pub registry: Box>, + pub registry: BorshAccount, - pub asset_mint: Box>, + pub asset_mint: InterfaceAccount, /// Proof the mint is approved, and the source of its official price feed. /// Seeds tie it to this registry and this mint; existence means approved. @@ -30,7 +30,7 @@ pub struct AddAssetAccountConstraints { seeds = [b"approved_asset", registry.address().as_ref(), asset_mint.address().as_ref()], bump = approved_asset.bump )] - pub approved_asset: Box>, + pub approved_asset: BorshAccount, #[account( init, @@ -39,7 +39,7 @@ pub struct AddAssetAccountConstraints { seeds = [b"asset", fund.address().as_ref(), &[fund.asset_count]], bump )] - pub asset_config: Box>, + pub asset_config: BorshAccount, /// Fund-owned vault for this asset. #[account( @@ -49,10 +49,10 @@ pub struct AddAssetAccountConstraints { associated_token::authority = fund, associated_token::token_program = token_program )] - pub vault_asset: Box>, + pub vault_asset: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/collect_fees.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/collect_fees.rs index 2fa3a6ba2..a5df2ece2 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/collect_fees.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/collect_fees.rs @@ -43,7 +43,7 @@ pub struct CollectFeesAccountConstraints { pub payer: Signer, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs index c1f9895bb..18a03b15e 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs @@ -23,17 +23,17 @@ pub struct DepositAccountConstraints { seeds = [b"fund", fund.index.to_le_bytes()], bump = fund.bump, )] - pub fund: Box>, + pub fund: BorshAccount, #[account( mut, seeds = [b"share_mint", fund.address().as_ref()], bump )] - pub share_mint: Box>, + pub share_mint: InterfaceAccount, #[account(address = fund.usdc_mint @ FundError::InvalidUsdcMint)] - pub usdc_mint: Box>, + pub usdc_mint: InterfaceAccount, #[account( mut, @@ -41,7 +41,7 @@ pub struct DepositAccountConstraints { associated_token::authority = depositor, associated_token::token_program = token_program )] - pub depositor_usdc_account: Box>, + pub depositor_usdc_account: InterfaceAccount, #[account( init_if_needed, @@ -50,7 +50,7 @@ pub struct DepositAccountConstraints { associated_token::authority = depositor, associated_token::token_program = token_program )] - pub depositor_share_account: Box>, + pub depositor_share_account: InterfaceAccount, #[account( mut, @@ -58,7 +58,7 @@ pub struct DepositAccountConstraints { associated_token::authority = fund, associated_token::token_program = token_program )] - pub vault_usdc: Box>, + pub vault_usdc: InterfaceAccount, /// CHECK: Router config PDA from the mock-swap-router program; it owns the /// treasury and signs the router's token CPIs @@ -76,7 +76,7 @@ pub struct DepositAccountConstraints { pub swap_router_program: UncheckedAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, // remaining_accounts: for each asset index 0..asset_count, in order: // [asset_config, vault, asset_mint, asset_rate, price_feed] diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/initialize_fund.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/initialize_fund.rs index 810e6ab36..6718e6834 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/initialize_fund.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/initialize_fund.rs @@ -52,7 +52,7 @@ pub struct InitializeFundAccountConstraints { seeds = [b"fund", index.to_le_bytes()], bump )] - pub fund: Box>, + pub fund: BorshAccount, #[account( init, @@ -64,7 +64,7 @@ pub struct InitializeFundAccountConstraints { seeds = [b"share_mint", fund.address().as_ref()], bump )] - pub share_mint: Box>, + pub share_mint: InterfaceAccount, /// Vault's USDC token account - fund PDA is the authority #[account( @@ -74,10 +74,10 @@ pub struct InitializeFundAccountConstraints { associated_token::authority = fund, associated_token::token_program = token_program )] - pub vault_usdc: Box>, + pub vault_usdc: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs index 6277b35ab..16d605533 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs @@ -27,10 +27,10 @@ pub struct RebalanceAccountConstraints { seeds = [b"fund", fund.index.to_le_bytes()], bump = fund.bump, )] - pub fund: Box>, + pub fund: BorshAccount, #[account(address = fund.usdc_mint @ FundError::InvalidUsdcMint)] - pub usdc_mint: Box>, + pub usdc_mint: InterfaceAccount, #[account( mut, @@ -38,7 +38,7 @@ pub struct RebalanceAccountConstraints { associated_token::authority = fund, associated_token::token_program = token_program )] - pub vault_usdc: Box>, + pub vault_usdc: InterfaceAccount, /// CHECK: Router config PDA #[account(mut)] @@ -55,7 +55,7 @@ pub struct RebalanceAccountConstraints { pub swap_router_program: UncheckedAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, // remaining_accounts: for each asset index 0..asset_count, in order: // [asset_config, vault, asset_mint, asset_rate, price_feed] diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/set_weight.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/set_weight.rs index c2ee5312e..7e360a2e8 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/set_weight.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/set_weight.rs @@ -13,13 +13,13 @@ pub struct SetWeightAccountConstraints { seeds = [b"fund", fund.index.to_le_bytes()], bump = fund.bump, )] - pub fund: Box>, + pub fund: BorshAccount, #[account( mut, constraint = asset_config.fund == *fund.address() @ FundError::InvalidAssetAccount, )] - pub asset_config: Box>, + pub asset_config: BorshAccount, } /// Change an asset's target weight. Setting it to zero retires the asset: deposits diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs index e0f659699..4f270989e 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs @@ -20,17 +20,17 @@ pub struct WithdrawAccountConstraints { seeds = [b"fund", fund.index.to_le_bytes()], bump = fund.bump, )] - pub fund: Box>, + pub fund: BorshAccount, #[account( mut, seeds = [b"share_mint", fund.address().as_ref()], bump )] - pub share_mint: Box>, + pub share_mint: InterfaceAccount, #[account(address = fund.usdc_mint @ FundError::InvalidUsdcMint)] - pub usdc_mint: Box>, + pub usdc_mint: InterfaceAccount, #[account( mut, @@ -38,7 +38,7 @@ pub struct WithdrawAccountConstraints { associated_token::authority = user, associated_token::token_program = token_program )] - pub user_share_account: Box>, + pub user_share_account: InterfaceAccount, #[account( init_if_needed, @@ -47,7 +47,7 @@ pub struct WithdrawAccountConstraints { associated_token::authority = user, associated_token::token_program = token_program )] - pub user_usdc_account: Box>, + pub user_usdc_account: InterfaceAccount, #[account( mut, @@ -55,10 +55,10 @@ pub struct WithdrawAccountConstraints { associated_token::authority = fund, associated_token::token_program = token_program )] - pub vault_usdc: Box>, + pub vault_usdc: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, // remaining_accounts: for each asset index 0..asset_count, in order: // [asset_config, vault, mint, user_token_account] diff --git a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/initialize_router.rs b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/initialize_router.rs index dbfead64c..8da6b6e02 100644 --- a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/initialize_router.rs +++ b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/initialize_router.rs @@ -19,7 +19,7 @@ pub struct InitializeRouterAccountConstraints { )] pub router_config: BorshAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/set_rate.rs b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/set_rate.rs index 9ba11c40e..9755f6986 100644 --- a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/set_rate.rs +++ b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/set_rate.rs @@ -39,7 +39,7 @@ pub struct SetRateAccountConstraints { pub router_usdc_treasury: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_asset_for_usdc.rs b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_asset_for_usdc.rs index 937c73bf9..d0b8e54b9 100644 --- a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_asset_for_usdc.rs +++ b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_asset_for_usdc.rs @@ -27,10 +27,10 @@ pub struct SwapAssetForUsdcAccountConstraints { pub asset_rate: BorshAccount, #[account(constraint = *usdc_mint.address() == router_config.usdc_mint @ RouterError::WrongUsdcMint)] - pub usdc_mint: Box>, + pub usdc_mint: InterfaceAccount, #[account(mut)] - pub asset_mint: Box>, + pub asset_mint: InterfaceAccount, /// Caller's asset token account - asset tokens are burned from here #[account( @@ -39,7 +39,7 @@ pub struct SwapAssetForUsdcAccountConstraints { associated_token::authority = caller, associated_token::token_program = token_program )] - pub caller_asset_account: Box>, + pub caller_asset_account: InterfaceAccount, /// Caller's USDC account - receives the USDC #[account( @@ -48,7 +48,7 @@ pub struct SwapAssetForUsdcAccountConstraints { associated_token::authority = caller, associated_token::token_program = token_program )] - pub caller_usdc_account: Box>, + pub caller_usdc_account: InterfaceAccount, /// Router's USDC treasury - sends the USDC #[account( @@ -57,10 +57,10 @@ pub struct SwapAssetForUsdcAccountConstraints { associated_token::authority = router_config, associated_token::token_program = token_program )] - pub router_usdc_treasury: Box>, + pub router_usdc_treasury: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs index 7aa8eeec1..228bc6381 100644 --- a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs +++ b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs @@ -27,10 +27,10 @@ pub struct SwapUsdcForAssetAccountConstraints { )] pub asset_rate: BorshAccount, - pub usdc_mint: Box>, + pub usdc_mint: InterfaceAccount, #[account(mut)] - pub asset_mint: Box>, + pub asset_mint: InterfaceAccount, /// Caller's USDC token account - USDC flows from here to the treasury #[account( @@ -39,7 +39,7 @@ pub struct SwapUsdcForAssetAccountConstraints { associated_token::authority = caller, associated_token::token_program = token_program )] - pub caller_usdc_account: Box>, + pub caller_usdc_account: InterfaceAccount, /// Caller's asset token account - minted asset tokens land here #[account( @@ -48,7 +48,7 @@ pub struct SwapUsdcForAssetAccountConstraints { associated_token::authority = caller, associated_token::token_program = token_program )] - pub caller_asset_account: Box>, + pub caller_asset_account: InterfaceAccount, /// Router's USDC treasury - receives the USDC payment #[account( @@ -57,10 +57,10 @@ pub struct SwapUsdcForAssetAccountConstraints { associated_token::authority = router_config, associated_token::token_program = token_program )] - pub router_usdc_treasury: Box>, + pub router_usdc_treasury: InterfaceAccount, pub associated_token_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/options/anchor/programs/options/src/instructions/buy_option.rs b/finance/options/anchor/programs/options/src/instructions/buy_option.rs index 8f2b00f27..499039d9f 100644 --- a/finance/options/anchor/programs/options/src/instructions/buy_option.rs +++ b/finance/options/anchor/programs/options/src/instructions/buy_option.rs @@ -101,17 +101,17 @@ pub struct BuyOptionAccountConstraints { bump = market.bump, address = option.market, )] - pub market: Box>, + pub market: BorshAccount, #[account( mut, seeds = [OPTION_SEED, market.address().as_ref(), writer.address().as_ref(), option.id.to_le_bytes()], bump = option.bump, )] - pub option: Box>, + pub option: BorshAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account( mut, @@ -119,7 +119,7 @@ pub struct BuyOptionAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, #[account( mut, @@ -127,7 +127,7 @@ pub struct BuyOptionAccountConstraints { associated_token::authority = buyer, associated_token::token_program = token_program, )] - pub buyer_quote: Box>, + pub buyer_quote: InterfaceAccount, // Created by `write_option`, at the writer's expense, so the buyer never // pays rent on the writer's behalf. A writer buying their own option would @@ -141,7 +141,7 @@ pub struct BuyOptionAccountConstraints { associated_token::authority = writer, associated_token::token_program = token_program, )] - pub writer_quote: Box>, + pub writer_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/options/anchor/programs/options/src/instructions/cancel_option.rs b/finance/options/anchor/programs/options/src/instructions/cancel_option.rs index ba54a5022..269f8ee17 100644 --- a/finance/options/anchor/programs/options/src/instructions/cancel_option.rs +++ b/finance/options/anchor/programs/options/src/instructions/cancel_option.rs @@ -84,7 +84,7 @@ pub struct CancelOptionAccountConstraints { bump = market.bump, address = option.market, )] - pub market: Box>, + pub market: BorshAccount, #[account( mut, @@ -92,13 +92,13 @@ pub struct CancelOptionAccountConstraints { seeds = [OPTION_SEED, market.address().as_ref(), writer.address().as_ref(), option.id.to_le_bytes()], bump = option.bump, )] - pub option: Box>, + pub option: BorshAccount, #[account(address = market.underlying_mint)] - pub underlying_mint: Box>, + pub underlying_mint: InterfaceAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account( mut, @@ -106,7 +106,7 @@ pub struct CancelOptionAccountConstraints { bump, address = market.underlying_vault, )] - pub underlying_vault: Box>, + pub underlying_vault: InterfaceAccount, #[account( mut, @@ -114,7 +114,7 @@ pub struct CancelOptionAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, // A call writer's collateral comes back here. A put writer may never have // held the underlying (or may have closed the account since writing), so @@ -127,7 +127,7 @@ pub struct CancelOptionAccountConstraints { associated_token::authority = writer, associated_token::token_program = token_program, )] - pub writer_underlying: Box>, + pub writer_underlying: InterfaceAccount, #[account( mut, @@ -135,9 +135,9 @@ pub struct CancelOptionAccountConstraints { associated_token::authority = writer, associated_token::token_program = token_program, )] - pub writer_quote: Box>, + pub writer_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/options/anchor/programs/options/src/instructions/collect_fees.rs b/finance/options/anchor/programs/options/src/instructions/collect_fees.rs index a8b6be193..b477e8da1 100644 --- a/finance/options/anchor/programs/options/src/instructions/collect_fees.rs +++ b/finance/options/anchor/programs/options/src/instructions/collect_fees.rs @@ -51,14 +51,14 @@ pub struct CollectFeesAccountConstraints { seeds = [MARKET_SEED, market.underlying_mint.as_ref(), market.quote_mint.as_ref()], bump = market.bump, )] - pub market: Box>, + pub market: BorshAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, // Read only, for the custody check: the invariant covers both vaults. #[account(address = market.underlying_vault)] - pub underlying_vault: Box>, + pub underlying_vault: InterfaceAccount, #[account( mut, @@ -66,7 +66,7 @@ pub struct CollectFeesAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, #[account( init_if_needed, @@ -75,9 +75,9 @@ pub struct CollectFeesAccountConstraints { associated_token::authority = admin, associated_token::token_program = token_program, )] - pub admin_quote: Box>, + pub admin_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/options/anchor/programs/options/src/instructions/collect_proceeds.rs b/finance/options/anchor/programs/options/src/instructions/collect_proceeds.rs index 9c8635204..f20dd1da3 100644 --- a/finance/options/anchor/programs/options/src/instructions/collect_proceeds.rs +++ b/finance/options/anchor/programs/options/src/instructions/collect_proceeds.rs @@ -85,7 +85,7 @@ pub struct CollectProceedsAccountConstraints { bump = market.bump, address = option.market, )] - pub market: Box>, + pub market: BorshAccount, #[account( mut, @@ -93,13 +93,13 @@ pub struct CollectProceedsAccountConstraints { seeds = [OPTION_SEED, market.address().as_ref(), writer.address().as_ref(), option.id.to_le_bytes()], bump = option.bump, )] - pub option: Box>, + pub option: BorshAccount, #[account(address = market.underlying_mint)] - pub underlying_mint: Box>, + pub underlying_mint: InterfaceAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account( mut, @@ -107,7 +107,7 @@ pub struct CollectProceedsAccountConstraints { bump, address = market.underlying_vault, )] - pub underlying_vault: Box>, + pub underlying_vault: InterfaceAccount, #[account( mut, @@ -115,7 +115,7 @@ pub struct CollectProceedsAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, // A put writer is paid in the underlying, which they may never have held, // so the account is created if needed, at the writer's expense. @@ -126,7 +126,7 @@ pub struct CollectProceedsAccountConstraints { associated_token::authority = writer, associated_token::token_program = token_program, )] - pub writer_underlying: Box>, + pub writer_underlying: InterfaceAccount, #[account( mut, @@ -134,9 +134,9 @@ pub struct CollectProceedsAccountConstraints { associated_token::authority = writer, associated_token::token_program = token_program, )] - pub writer_quote: Box>, + pub writer_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/options/anchor/programs/options/src/instructions/exercise_option.rs b/finance/options/anchor/programs/options/src/instructions/exercise_option.rs index 791cc1f56..55b1621b2 100644 --- a/finance/options/anchor/programs/options/src/instructions/exercise_option.rs +++ b/finance/options/anchor/programs/options/src/instructions/exercise_option.rs @@ -142,20 +142,20 @@ pub struct ExerciseOptionAccountConstraints { bump = market.bump, address = option.market, )] - pub market: Box>, + pub market: BorshAccount, #[account( mut, seeds = [OPTION_SEED, market.address().as_ref(), writer.address().as_ref(), option.id.to_le_bytes()], bump = option.bump, )] - pub option: Box>, + pub option: BorshAccount, #[account(address = market.underlying_mint)] - pub underlying_mint: Box>, + pub underlying_mint: InterfaceAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account( mut, @@ -163,7 +163,7 @@ pub struct ExerciseOptionAccountConstraints { bump, address = market.underlying_vault, )] - pub underlying_vault: Box>, + pub underlying_vault: InterfaceAccount, #[account( mut, @@ -171,7 +171,7 @@ pub struct ExerciseOptionAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, // A call holder receives into this account and may never have held the // underlying before, so it is created if needed, at the holder's expense. @@ -182,7 +182,7 @@ pub struct ExerciseOptionAccountConstraints { associated_token::authority = holder, associated_token::token_program = token_program, )] - pub holder_underlying: Box>, + pub holder_underlying: InterfaceAccount, #[account( init_if_needed, @@ -191,9 +191,9 @@ pub struct ExerciseOptionAccountConstraints { associated_token::authority = holder, associated_token::token_program = token_program, )] - pub holder_quote: Box>, + pub holder_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/options/anchor/programs/options/src/instructions/initialize_market.rs b/finance/options/anchor/programs/options/src/instructions/initialize_market.rs index 5ae5d06e0..d1a6cc0a8 100644 --- a/finance/options/anchor/programs/options/src/instructions/initialize_market.rs +++ b/finance/options/anchor/programs/options/src/instructions/initialize_market.rs @@ -54,11 +54,11 @@ pub struct InitializeMarketAccountConstraints { seeds = [MARKET_SEED, underlying_mint.address().as_ref(), quote_mint.address().as_ref()], bump, )] - pub market: Box>, + pub market: BorshAccount, - pub underlying_mint: Box>, + pub underlying_mint: InterfaceAccount, - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, // The market account is the token authority of both vaults: it signs // every transfer out of them with its own PDA seeds. @@ -71,7 +71,7 @@ pub struct InitializeMarketAccountConstraints { token::authority = market, token::token_program = token_program, )] - pub underlying_vault: Box>, + pub underlying_vault: InterfaceAccount, #[account( init, @@ -82,8 +82,8 @@ pub struct InitializeMarketAccountConstraints { token::authority = market, token::token_program = token_program, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/options/anchor/programs/options/src/instructions/reclaim_collateral.rs b/finance/options/anchor/programs/options/src/instructions/reclaim_collateral.rs index 118412e35..ef1c36526 100644 --- a/finance/options/anchor/programs/options/src/instructions/reclaim_collateral.rs +++ b/finance/options/anchor/programs/options/src/instructions/reclaim_collateral.rs @@ -90,7 +90,7 @@ pub struct ReclaimCollateralAccountConstraints { bump = market.bump, address = option.market, )] - pub market: Box>, + pub market: BorshAccount, #[account( mut, @@ -98,13 +98,13 @@ pub struct ReclaimCollateralAccountConstraints { seeds = [OPTION_SEED, market.address().as_ref(), writer.address().as_ref(), option.id.to_le_bytes()], bump = option.bump, )] - pub option: Box>, + pub option: BorshAccount, #[account(address = market.underlying_mint)] - pub underlying_mint: Box>, + pub underlying_mint: InterfaceAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account( mut, @@ -112,7 +112,7 @@ pub struct ReclaimCollateralAccountConstraints { bump, address = market.underlying_vault, )] - pub underlying_vault: Box>, + pub underlying_vault: InterfaceAccount, #[account( mut, @@ -120,7 +120,7 @@ pub struct ReclaimCollateralAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, // A call writer's collateral comes back here. A put writer may never have // held the underlying (or may have closed the account since writing), so @@ -133,7 +133,7 @@ pub struct ReclaimCollateralAccountConstraints { associated_token::authority = writer, associated_token::token_program = token_program, )] - pub writer_underlying: Box>, + pub writer_underlying: InterfaceAccount, #[account( mut, @@ -141,9 +141,9 @@ pub struct ReclaimCollateralAccountConstraints { associated_token::authority = writer, associated_token::token_program = token_program, )] - pub writer_quote: Box>, + pub writer_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/options/anchor/programs/options/src/instructions/shared.rs b/finance/options/anchor/programs/options/src/instructions/shared.rs index 5fb3a855f..eb18a3311 100644 --- a/finance/options/anchor/programs/options/src/instructions/shared.rs +++ b/finance/options/anchor/programs/options/src/instructions/shared.rs @@ -30,7 +30,7 @@ pub fn check_custody(market: &Market, underlying_after: u64, quote_after: u64) - /// A signer-authorized transfer into one of the vaults, or from one party to /// another (the premium goes straight from buyer to writer). pub fn transfer_from_signer( - token_program: &Interface<'static, TokenInterface>, + token_program: &Interface, from: &mut InterfaceAccount, mint: &InterfaceAccount, to: &mut InterfaceAccount, @@ -60,7 +60,7 @@ pub fn transfer_from_signer( /// The caller must have finished mutating the market (it has: effects come /// before CPIs). pub fn transfer_from_vault( - token_program: &Interface<'static, TokenInterface>, + token_program: &Interface, vault: &mut InterfaceAccount, mint: &InterfaceAccount, to: &mut InterfaceAccount, diff --git a/finance/options/anchor/programs/options/src/instructions/write_option.rs b/finance/options/anchor/programs/options/src/instructions/write_option.rs index 646ffa3f6..be4969574 100644 --- a/finance/options/anchor/programs/options/src/instructions/write_option.rs +++ b/finance/options/anchor/programs/options/src/instructions/write_option.rs @@ -135,7 +135,7 @@ pub struct WriteOptionAccountConstraints { seeds = [MARKET_SEED, market.underlying_mint.as_ref(), market.quote_mint.as_ref()], bump = market.bump, )] - pub market: Box>, + pub market: BorshAccount, #[account( init, @@ -144,13 +144,13 @@ pub struct WriteOptionAccountConstraints { seeds = [OPTION_SEED, market.address().as_ref(), writer.address().as_ref(), _id.to_le_bytes()], bump, )] - pub option: Box>, + pub option: BorshAccount, #[account(address = market.underlying_mint)] - pub underlying_mint: Box>, + pub underlying_mint: InterfaceAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account( mut, @@ -158,7 +158,7 @@ pub struct WriteOptionAccountConstraints { bump, address = market.underlying_vault, )] - pub underlying_vault: Box>, + pub underlying_vault: InterfaceAccount, #[account( mut, @@ -166,7 +166,7 @@ pub struct WriteOptionAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, // A call writer pays collateral from this account. A put writer may never // have held the underlying, so the account is created if needed, at the @@ -180,7 +180,7 @@ pub struct WriteOptionAccountConstraints { associated_token::authority = writer, associated_token::token_program = token_program, )] - pub writer_underlying: Box>, + pub writer_underlying: InterfaceAccount, // A put writer pays collateral from this account, and every writer is // paid their premium into it by `buy_option`, which requires it to exist. @@ -193,9 +193,9 @@ pub struct WriteOptionAccountConstraints { associated_token::authority = writer, associated_token::token_program = token_program, )] - pub writer_quote: Box>, + pub writer_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs b/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs index 89b6758ac..c08b47e11 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs @@ -69,14 +69,14 @@ pub struct WithdrawFeesAccountConstraints { // Boxed to keep the struct under the BPF stack limit (see PlaceOrderAccountConstraints). #[account(mut, address = market.fee_vault @ ErrorCode::InvalidFeeVault)] - pub fee_vault: Box>, + pub fee_vault: InterfaceAccount, #[account(mut)] - pub authority_quote_account: Box>, + pub authority_quote_account: InterfaceAccount, - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, pub authority: Signer, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/initialize_market.rs b/finance/order-book/anchor/programs/order-book/src/instructions/initialize_market.rs index 5050ab1bb..6c9cdaafb 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/initialize_market.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/initialize_market.rs @@ -127,7 +127,7 @@ pub struct InitializeMarketAccountConstraints { #[account(mut)] pub authority: Signer, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs index 7b3d5b1fe..6b6cf380b 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs @@ -596,32 +596,32 @@ pub struct PlaceOrderAccountConstraints { // InterfaceAccount on the stack is ~1 KB each; with 7 of them this struct // blows the 4 KB stack-offset limit on BPF. Boxing moves each to the heap. #[account(mut, address = market.base_vault @ ErrorCode::InvalidBaseVault)] - pub base_vault: Box>, + pub base_vault: InterfaceAccount, #[account(mut, address = market.quote_vault @ ErrorCode::InvalidQuoteVault)] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, // Taker fees are routed here. Constrained via `address = market.fee_vault` on // `market` above so the program can trust it without re-checking. #[account(mut, address = market.fee_vault @ ErrorCode::InvalidFeeVault)] - pub fee_vault: Box>, + pub fee_vault: InterfaceAccount, #[account(mut)] - pub user_base_account: Box>, + pub user_base_account: InterfaceAccount, #[account(mut)] - pub user_quote_account: Box>, + pub user_quote_account: InterfaceAccount, #[account(address = market.base_mint @ ErrorCode::InvalidBaseMint)] - pub base_mint: Box>, + pub base_mint: InterfaceAccount, #[account(address = market.quote_mint @ ErrorCode::InvalidQuoteMint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account(mut)] pub owner: Signer, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, } diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs b/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs index f9c3a456a..2be20bfe1 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs @@ -101,24 +101,24 @@ pub struct SettleFundsAccountConstraints { // Boxed for the same reason as in PlaceOrderAccountConstraints - // InterfaceAccount is too large to keep on the BPF stack in bulk. #[account(mut, address = market.base_vault @ ErrorCode::InvalidBaseVault)] - pub base_vault: Box>, + pub base_vault: InterfaceAccount, #[account(mut, address = market.quote_vault @ ErrorCode::InvalidQuoteVault)] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, #[account(mut)] - pub user_base_account: Box>, + pub user_base_account: InterfaceAccount, #[account(mut)] - pub user_quote_account: Box>, + pub user_quote_account: InterfaceAccount, #[account(address = market.base_mint @ ErrorCode::InvalidBaseMint)] - pub base_mint: Box>, + pub base_mint: InterfaceAccount, #[account(address = market.quote_mint @ ErrorCode::InvalidQuoteMint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, pub owner: Signer, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/add_liquidity.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/add_liquidity.rs index 680e01808..e8029ea35 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/add_liquidity.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/add_liquidity.rs @@ -129,17 +129,17 @@ pub struct AddLiquidityAccountConstraints { seeds = [POOL_SEED, pool.collateral_mint.as_ref(), pool.oracle_feed.as_ref()], bump = pool.bump, )] - pub pool: Box>, + pub pool: BorshAccount, /// CHECK: validated by the `address = pool.oracle_feed` constraint below. #[account(address = pool.oracle_feed)] pub oracle_feed: UncheckedAccount, #[account(address = pool.collateral_mint)] - pub collateral_mint: Box>, + pub collateral_mint: InterfaceAccount, #[account(mut, address = pool.lp_mint)] - pub lp_mint: Box>, + pub lp_mint: InterfaceAccount, #[account( mut, @@ -147,7 +147,7 @@ pub struct AddLiquidityAccountConstraints { bump, address = pool.custody_vault, )] - pub custody_vault: Box>, + pub custody_vault: InterfaceAccount, #[account( mut, @@ -155,7 +155,7 @@ pub struct AddLiquidityAccountConstraints { associated_token::authority = provider, associated_token::token_program = token_program, )] - pub provider_collateral: Box>, + pub provider_collateral: InterfaceAccount, #[account( init_if_needed, @@ -164,9 +164,9 @@ pub struct AddLiquidityAccountConstraints { associated_token::authority = provider, associated_token::token_program = token_program, )] - pub provider_lp: Box>, + pub provider_lp: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/close_position.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/close_position.rs index 47ac2a437..0a5a13bac 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/close_position.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/close_position.rs @@ -141,7 +141,7 @@ pub struct ClosePositionAccountConstraints { bump = pool.bump, address = position.pool, )] - pub pool: Box>, + pub pool: BorshAccount, #[account( mut, @@ -149,14 +149,14 @@ pub struct ClosePositionAccountConstraints { seeds = [POSITION_SEED, pool.address().as_ref(), owner.address().as_ref(), position.side.as_seed()], bump = position.bump, )] - pub position: Box>, + pub position: BorshAccount, /// CHECK: validated by the `address = pool.oracle_feed` constraint below. #[account(address = pool.oracle_feed)] pub oracle_feed: UncheckedAccount, #[account(address = pool.collateral_mint)] - pub collateral_mint: Box>, + pub collateral_mint: InterfaceAccount, #[account( mut, @@ -164,7 +164,7 @@ pub struct ClosePositionAccountConstraints { bump, address = pool.custody_vault, )] - pub custody_vault: Box>, + pub custody_vault: InterfaceAccount, #[account( mut, @@ -172,9 +172,9 @@ pub struct ClosePositionAccountConstraints { associated_token::authority = owner, associated_token::token_program = token_program, )] - pub trader_collateral: Box>, + pub trader_collateral: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/collect_fees.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/collect_fees.rs index a686687ff..6f2490850 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/collect_fees.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/collect_fees.rs @@ -60,10 +60,10 @@ pub struct CollectFeesAccountConstraints { seeds = [POOL_SEED, pool.collateral_mint.as_ref(), pool.oracle_feed.as_ref()], bump = pool.bump, )] - pub pool: Box>, + pub pool: BorshAccount, #[account(address = pool.collateral_mint)] - pub collateral_mint: Box>, + pub collateral_mint: InterfaceAccount, #[account( mut, @@ -71,7 +71,7 @@ pub struct CollectFeesAccountConstraints { bump, address = pool.custody_vault, )] - pub custody_vault: Box>, + pub custody_vault: InterfaceAccount, #[account( init_if_needed, @@ -80,9 +80,9 @@ pub struct CollectFeesAccountConstraints { associated_token::authority = authority, associated_token::token_program = token_program, )] - pub authority_collateral: Box>, + pub authority_collateral: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/initialize_pool.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/initialize_pool.rs index d39e79d62..253ed9f02 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/initialize_pool.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/initialize_pool.rs @@ -182,9 +182,9 @@ pub struct InitializePoolAccountConstraints { seeds = [POOL_SEED, collateral_mint.address().as_ref(), oracle_feed.address().as_ref()], bump, )] - pub pool: Box>, + pub pool: BorshAccount, - pub collateral_mint: Box>, + pub collateral_mint: InterfaceAccount, /// CHECK: The oracle feed account. Its key and its owning program are /// stored on the pool, and every read, including the one here that seeds @@ -204,7 +204,7 @@ pub struct InitializePoolAccountConstraints { mint::authority = pool, mint::token_program = token_program, )] - pub lp_mint: Box>, + pub lp_mint: InterfaceAccount, /// Custody vault for all collateral. The pool account owns it and signs /// every transfer out with its own seeds. @@ -217,9 +217,9 @@ pub struct InitializePoolAccountConstraints { token::authority = pool, token::token_program = token_program, )] - pub custody_vault: Box>, + pub custody_vault: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/liquidate_position.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/liquidate_position.rs index 6f53ab88f..76e46f776 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/liquidate_position.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/liquidate_position.rs @@ -146,7 +146,7 @@ pub struct LiquidatePositionAccountConstraints { bump = pool.bump, address = position.pool, )] - pub pool: Box>, + pub pool: BorshAccount, #[account( mut, @@ -154,14 +154,14 @@ pub struct LiquidatePositionAccountConstraints { seeds = [POSITION_SEED, pool.address().as_ref(), owner.address().as_ref(), position.side.as_seed()], bump = position.bump, )] - pub position: Box>, + pub position: BorshAccount, /// CHECK: validated by the `address = pool.oracle_feed` constraint below. #[account(address = pool.oracle_feed)] pub oracle_feed: UncheckedAccount, #[account(address = pool.collateral_mint)] - pub collateral_mint: Box>, + pub collateral_mint: InterfaceAccount, #[account( mut, @@ -169,7 +169,7 @@ pub struct LiquidatePositionAccountConstraints { bump, address = pool.custody_vault, )] - pub custody_vault: Box>, + pub custody_vault: InterfaceAccount, #[account( mut, @@ -177,7 +177,7 @@ pub struct LiquidatePositionAccountConstraints { associated_token::authority = owner, associated_token::token_program = token_program, )] - pub trader_collateral: Box>, + pub trader_collateral: InterfaceAccount, #[account( init_if_needed, @@ -186,9 +186,9 @@ pub struct LiquidatePositionAccountConstraints { associated_token::authority = liquidator, associated_token::token_program = token_program, )] - pub liquidator_collateral: Box>, + pub liquidator_collateral: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/open_position.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/open_position.rs index 6c97c88a0..82035e829 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/open_position.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/open_position.rs @@ -136,7 +136,7 @@ pub struct OpenPositionAccountConstraints { seeds = [POOL_SEED, pool.collateral_mint.as_ref(), pool.oracle_feed.as_ref()], bump = pool.bump, )] - pub pool: Box>, + pub pool: BorshAccount, #[account( init, @@ -145,14 +145,14 @@ pub struct OpenPositionAccountConstraints { seeds = [POSITION_SEED, pool.address().as_ref(), owner.address().as_ref(), _side.as_seed()], bump, )] - pub position: Box>, + pub position: BorshAccount, /// CHECK: validated by the `address = pool.oracle_feed` constraint below. #[account(address = pool.oracle_feed)] pub oracle_feed: UncheckedAccount, #[account(address = pool.collateral_mint)] - pub collateral_mint: Box>, + pub collateral_mint: InterfaceAccount, #[account( mut, @@ -160,7 +160,7 @@ pub struct OpenPositionAccountConstraints { bump, address = pool.custody_vault, )] - pub custody_vault: Box>, + pub custody_vault: InterfaceAccount, #[account( mut, @@ -168,9 +168,9 @@ pub struct OpenPositionAccountConstraints { associated_token::authority = owner, associated_token::token_program = token_program, )] - pub trader_collateral: Box>, + pub trader_collateral: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/remove_liquidity.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/remove_liquidity.rs index 1ece33709..e3877c3fd 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/remove_liquidity.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/remove_liquidity.rs @@ -120,17 +120,17 @@ pub struct RemoveLiquidityAccountConstraints { seeds = [POOL_SEED, pool.collateral_mint.as_ref(), pool.oracle_feed.as_ref()], bump = pool.bump, )] - pub pool: Box>, + pub pool: BorshAccount, /// CHECK: validated by the `address = pool.oracle_feed` constraint below. #[account(address = pool.oracle_feed)] pub oracle_feed: UncheckedAccount, #[account(address = pool.collateral_mint)] - pub collateral_mint: Box>, + pub collateral_mint: InterfaceAccount, #[account(mut, address = pool.lp_mint)] - pub lp_mint: Box>, + pub lp_mint: InterfaceAccount, #[account( mut, @@ -138,7 +138,7 @@ pub struct RemoveLiquidityAccountConstraints { bump, address = pool.custody_vault, )] - pub custody_vault: Box>, + pub custody_vault: InterfaceAccount, #[account( mut, @@ -146,7 +146,7 @@ pub struct RemoveLiquidityAccountConstraints { associated_token::authority = provider, associated_token::token_program = token_program, )] - pub provider_collateral: Box>, + pub provider_collateral: InterfaceAccount, #[account( mut, @@ -154,9 +154,9 @@ pub struct RemoveLiquidityAccountConstraints { associated_token::authority = provider, associated_token::token_program = token_program, )] - pub provider_lp: Box>, + pub provider_lp: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/update_price_average.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/update_price_average.rs index 9da9fa577..d5b56dbf2 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/update_price_average.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/update_price_average.rs @@ -22,7 +22,7 @@ pub struct UpdatePriceAverageAccountConstraints { seeds = [POOL_SEED, pool.collateral_mint.as_ref(), pool.oracle_feed.as_ref()], bump = pool.bump, )] - pub pool: Box>, + pub pool: BorshAccount, /// CHECK: validated by the `address = pool.oracle_feed` constraint below. #[account(address = pool.oracle_feed)] diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/close_market.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/close_market.rs index 7f8525ab3..56995f6c6 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/close_market.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/close_market.rs @@ -83,7 +83,7 @@ pub struct CloseMarketAccountConstraints { bump = market.bump, close = operator, )] - pub market: Box>, + pub market: BorshAccount, #[account( mut, @@ -91,7 +91,7 @@ pub struct CloseMarketAccountConstraints { bump, address = market.base_vault, )] - pub base_vault: Box>, + pub base_vault: InterfaceAccount, #[account( mut, @@ -99,7 +99,7 @@ pub struct CloseMarketAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/deposit_inventory.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/deposit_inventory.rs index d2d7fe8e4..d46fe52c8 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/deposit_inventory.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/deposit_inventory.rs @@ -63,13 +63,13 @@ pub struct DepositInventoryAccountConstraints { seeds = [MARKET_SEED, market.base_mint.as_ref(), market.quote_mint.as_ref()], bump = market.bump, )] - pub market: Box>, + pub market: BorshAccount, #[account(address = market.base_mint)] - pub base_mint: Box>, + pub base_mint: InterfaceAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account( mut, @@ -77,7 +77,7 @@ pub struct DepositInventoryAccountConstraints { bump, address = market.base_vault, )] - pub base_vault: Box>, + pub base_vault: InterfaceAccount, #[account( mut, @@ -85,7 +85,7 @@ pub struct DepositInventoryAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, #[account( mut, @@ -93,7 +93,7 @@ pub struct DepositInventoryAccountConstraints { associated_token::authority = operator, associated_token::token_program = token_program, )] - pub operator_base: Box>, + pub operator_base: InterfaceAccount, #[account( mut, @@ -101,7 +101,7 @@ pub struct DepositInventoryAccountConstraints { associated_token::authority = operator, associated_token::token_program = token_program, )] - pub operator_quote: Box>, + pub operator_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/initialize_market.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/initialize_market.rs index 5a11b5418..e92ffea4f 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/initialize_market.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/initialize_market.rs @@ -83,11 +83,11 @@ pub struct InitializeMarketAccountConstraints { seeds = [MARKET_SEED, base_mint.address().as_ref(), quote_mint.address().as_ref()], bump, )] - pub market: Box>, + pub market: BorshAccount, - pub base_mint: Box>, + pub base_mint: InterfaceAccount, - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, /// CHECK: The oracle feed account. Its key and its owning program are /// stored on the market, and every read requires that owner and validates @@ -107,7 +107,7 @@ pub struct InitializeMarketAccountConstraints { token::authority = market, token::token_program = token_program, )] - pub base_vault: Box>, + pub base_vault: InterfaceAccount, #[account( init, @@ -118,9 +118,9 @@ pub struct InitializeMarketAccountConstraints { token::authority = market, token::token_program = token_program, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/set_quote.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/set_quote.rs index 265bfb31e..b2363b4d7 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/set_quote.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/set_quote.rs @@ -40,5 +40,5 @@ pub struct SetQuoteAccountConstraints { seeds = [MARKET_SEED, market.base_mint.as_ref(), market.quote_mint.as_ref()], bump = market.bump, )] - pub market: Box>, + pub market: BorshAccount, } diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/swap.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/swap.rs index bcf170715..2ea53985f 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/swap.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/swap.rs @@ -196,17 +196,17 @@ pub struct SwapAccountConstraints { seeds = [MARKET_SEED, market.base_mint.as_ref(), market.quote_mint.as_ref()], bump = market.bump, )] - pub market: Box>, + pub market: BorshAccount, /// CHECK: validated by the `address = market.oracle_feed` constraint below. #[account(address = market.oracle_feed)] pub oracle_feed: UncheckedAccount, #[account(address = market.base_mint)] - pub base_mint: Box>, + pub base_mint: InterfaceAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account( mut, @@ -214,7 +214,7 @@ pub struct SwapAccountConstraints { bump, address = market.base_vault, )] - pub base_vault: Box>, + pub base_vault: InterfaceAccount, #[account( mut, @@ -222,7 +222,7 @@ pub struct SwapAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, #[account( init_if_needed, @@ -231,7 +231,7 @@ pub struct SwapAccountConstraints { associated_token::authority = trader, associated_token::token_program = token_program, )] - pub trader_base: Box>, + pub trader_base: InterfaceAccount, #[account( init_if_needed, @@ -240,9 +240,9 @@ pub struct SwapAccountConstraints { associated_token::authority = trader, associated_token::token_program = token_program, )] - pub trader_quote: Box>, + pub trader_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/withdraw_inventory.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/withdraw_inventory.rs index 767cc3f5c..488704a15 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/withdraw_inventory.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/withdraw_inventory.rs @@ -87,13 +87,13 @@ pub struct WithdrawInventoryAccountConstraints { seeds = [MARKET_SEED, market.base_mint.as_ref(), market.quote_mint.as_ref()], bump = market.bump, )] - pub market: Box>, + pub market: BorshAccount, #[account(address = market.base_mint)] - pub base_mint: Box>, + pub base_mint: InterfaceAccount, #[account(address = market.quote_mint)] - pub quote_mint: Box>, + pub quote_mint: InterfaceAccount, #[account( mut, @@ -101,7 +101,7 @@ pub struct WithdrawInventoryAccountConstraints { bump, address = market.base_vault, )] - pub base_vault: Box>, + pub base_vault: InterfaceAccount, #[account( mut, @@ -109,7 +109,7 @@ pub struct WithdrawInventoryAccountConstraints { bump, address = market.quote_vault, )] - pub quote_vault: Box>, + pub quote_vault: InterfaceAccount, #[account( mut, @@ -117,7 +117,7 @@ pub struct WithdrawInventoryAccountConstraints { associated_token::authority = operator, associated_token::token_program = token_program, )] - pub operator_base: Box>, + pub operator_base: InterfaceAccount, #[account( mut, @@ -125,7 +125,7 @@ pub struct WithdrawInventoryAccountConstraints { associated_token::authority = operator, associated_token::token_program = token_program, )] - pub operator_quote: Box>, + pub operator_quote: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/token-swap/anchor/programs/token-swap/src/instructions/admin/claim_admin_fees.rs b/finance/token-swap/anchor/programs/token-swap/src/instructions/admin/claim_admin_fees.rs index 1d1657ea9..ad04e4148 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/instructions/admin/claim_admin_fees.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/instructions/admin/claim_admin_fees.rs @@ -130,10 +130,10 @@ pub struct ClaimAdminFeesAccountConstraints { pub pool_config: BorshAccount, #[account(address = pool_config.mint_a)] - pub mint_a: Box>, + pub mint_a: InterfaceAccount, #[account(address = pool_config.mint_b)] - pub mint_b: Box>, + pub mint_b: InterfaceAccount, /// The pool's token-A reserve, owned by `pool_config`. The admin's owed /// token-A fees are paid out of this account. @@ -143,7 +143,7 @@ pub struct ClaimAdminFeesAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_a: Box>, + pub pool_a: InterfaceAccount, /// The pool's token-B reserve, owned by `pool_config`. The admin's owed /// token-B fees are paid out of this account. @@ -153,7 +153,7 @@ pub struct ClaimAdminFeesAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_b: Box>, + pub pool_b: InterfaceAccount, /// Must match the address stored in `Config.admin` (enforced by /// `address = config.admin` above). @@ -169,7 +169,7 @@ pub struct ClaimAdminFeesAccountConstraints { token::authority = admin, token::token_program = token_program, )] - pub admin_token_a: Box>, + pub admin_token_a: InterfaceAccount, /// Admin's token-B receiving account. Same constraints as `admin_token_a`. #[account( @@ -178,7 +178,7 @@ pub struct ClaimAdminFeesAccountConstraints { token::authority = admin, token::token_program = token_program, )] - pub admin_token_b: Box>, + pub admin_token_b: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } diff --git a/finance/token-swap/anchor/programs/token-swap/src/instructions/deposit_liquidity.rs b/finance/token-swap/anchor/programs/token-swap/src/instructions/deposit_liquidity.rs index 8fa29c011..98b988eb5 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/instructions/deposit_liquidity.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/instructions/deposit_liquidity.rs @@ -196,7 +196,7 @@ pub struct DepositLiquidityAccountConstraints { ], bump = pool_config.bump, )] - pub pool_config: Box>, + pub pool_config: BorshAccount, /// Makes the deposit and receives the LP tokens. pub depositor: Signer, @@ -211,13 +211,13 @@ pub struct DepositLiquidityAccountConstraints { ], bump, )] - pub liquidity_provider_mint: Box>, + pub liquidity_provider_mint: InterfaceAccount, #[account(address = pool_config.mint_a)] - pub mint_a: Box>, + pub mint_a: InterfaceAccount, #[account(address = pool_config.mint_b)] - pub mint_b: Box>, + pub mint_b: InterfaceAccount, #[account( mut, @@ -225,7 +225,7 @@ pub struct DepositLiquidityAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_a: Box>, + pub pool_a: InterfaceAccount, #[account( mut, @@ -233,7 +233,7 @@ pub struct DepositLiquidityAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_b: Box>, + pub pool_b: InterfaceAccount, #[account( init_if_needed, @@ -242,7 +242,7 @@ pub struct DepositLiquidityAccountConstraints { associated_token::authority = depositor, associated_token::token_program = token_program, )] - pub liquidity_provider_token: Box>, + pub liquidity_provider_token: InterfaceAccount, #[account( mut, @@ -250,7 +250,7 @@ pub struct DepositLiquidityAccountConstraints { associated_token::authority = depositor, associated_token::token_program = token_program, )] - pub token_a: Box>, + pub token_a: InterfaceAccount, #[account( mut, @@ -258,14 +258,14 @@ pub struct DepositLiquidityAccountConstraints { associated_token::authority = depositor, associated_token::token_program = token_program, )] - pub token_b: Box>, + pub token_b: InterfaceAccount, /// The account paying for all rents #[account(mut)] pub payer: Signer, /// Solana ecosystem accounts - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/token-swap/anchor/programs/token-swap/src/instructions/initialize_pool.rs b/finance/token-swap/anchor/programs/token-swap/src/instructions/initialize_pool.rs index a2aebeeb8..cb9e3aa32 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/instructions/initialize_pool.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/instructions/initialize_pool.rs @@ -72,7 +72,7 @@ pub struct InitializePoolAccountConstraints { seeds = [CONFIG_SEED], bump, )] - pub config: Box>, + pub config: BorshAccount, #[account( init, @@ -86,7 +86,7 @@ pub struct InitializePoolAccountConstraints { bump, constraint = mint_a.address() < mint_b.address() @ AmmError::InvalidMintOrder, )] - pub pool_config: Box>, + pub pool_config: BorshAccount, /// The LP mint. `pool_config` is its mint authority and signs every /// mint_to with its own seeds. @@ -106,11 +106,11 @@ pub struct InitializePoolAccountConstraints { // init CPI is rejected with InvalidArgument. mint::token_program = token_program, )] - pub liquidity_provider_mint: Box>, + pub liquidity_provider_mint: InterfaceAccount, - pub mint_a: Box>, + pub mint_a: InterfaceAccount, - pub mint_b: Box>, + pub mint_b: InterfaceAccount, /// The pool's token-A reserve: the associated token account of /// `pool_config`, which signs every transfer out of it. @@ -121,7 +121,7 @@ pub struct InitializePoolAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_a: Box>, + pub pool_a: InterfaceAccount, /// The pool's token-B reserve, likewise owned by `pool_config`. #[account( @@ -131,7 +131,7 @@ pub struct InitializePoolAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_b: Box>, + pub pool_b: InterfaceAccount, /// Makes the first deposit and receives the first LP tokens. pub creator: Signer, @@ -142,7 +142,7 @@ pub struct InitializePoolAccountConstraints { associated_token::authority = creator, associated_token::token_program = token_program, )] - pub creator_token_a: Box>, + pub creator_token_a: InterfaceAccount, #[account( mut, @@ -150,7 +150,7 @@ pub struct InitializePoolAccountConstraints { associated_token::authority = creator, associated_token::token_program = token_program, )] - pub creator_token_b: Box>, + pub creator_token_b: InterfaceAccount, /// The creator's LP token account, created here because the LP mint did /// not exist before this instruction. @@ -161,14 +161,14 @@ pub struct InitializePoolAccountConstraints { associated_token::authority = creator, associated_token::token_program = token_program, )] - pub liquidity_provider_token: Box>, + pub liquidity_provider_token: InterfaceAccount, /// The account paying for all rents #[account(mut)] pub payer: Signer, /// Solana ecosystem accounts - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/token-swap/anchor/programs/token-swap/src/instructions/swap_tokens.rs b/finance/token-swap/anchor/programs/token-swap/src/instructions/swap_tokens.rs index ea34e42c3..2b2c2fd87 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/instructions/swap_tokens.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/instructions/swap_tokens.rs @@ -306,10 +306,10 @@ pub struct SwapTokensAccountConstraints { pub trader: Signer, #[account(address = pool_config.mint_a)] - pub mint_a: Box>, + pub mint_a: InterfaceAccount, #[account(address = pool_config.mint_b)] - pub mint_b: Box>, + pub mint_b: InterfaceAccount, #[account( mut, @@ -317,7 +317,7 @@ pub struct SwapTokensAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_a: Box>, + pub pool_a: InterfaceAccount, #[account( mut, @@ -325,7 +325,7 @@ pub struct SwapTokensAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_b: Box>, + pub pool_b: InterfaceAccount, #[account( init_if_needed, @@ -334,7 +334,7 @@ pub struct SwapTokensAccountConstraints { associated_token::authority = trader, associated_token::token_program = token_program, )] - pub token_a: Box>, + pub token_a: InterfaceAccount, #[account( init_if_needed, @@ -343,14 +343,14 @@ pub struct SwapTokensAccountConstraints { associated_token::authority = trader, associated_token::token_program = token_program, )] - pub token_b: Box>, + pub token_b: InterfaceAccount, /// The account paying for all rents #[account(mut)] pub payer: Signer, /// Solana ecosystem accounts - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs b/finance/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs index c2d427799..83f89413b 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs @@ -181,13 +181,13 @@ pub struct WithdrawLiquidityAccountConstraints { ], bump, )] - pub liquidity_provider_mint: Box>, + pub liquidity_provider_mint: InterfaceAccount, #[account(mut, address = pool_config.mint_a)] - pub mint_a: Box>, + pub mint_a: InterfaceAccount, #[account(mut, address = pool_config.mint_b)] - pub mint_b: Box>, + pub mint_b: InterfaceAccount, #[account( mut, @@ -195,7 +195,7 @@ pub struct WithdrawLiquidityAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_a: Box>, + pub pool_a: InterfaceAccount, #[account( mut, @@ -203,7 +203,7 @@ pub struct WithdrawLiquidityAccountConstraints { associated_token::authority = pool_config, associated_token::token_program = token_program, )] - pub pool_b: Box>, + pub pool_b: InterfaceAccount, #[account( mut, @@ -211,7 +211,7 @@ pub struct WithdrawLiquidityAccountConstraints { associated_token::authority = withdrawer, associated_token::token_program = token_program, )] - pub liquidity_provider_token: Box>, + pub liquidity_provider_token: InterfaceAccount, #[account( init_if_needed, @@ -220,7 +220,7 @@ pub struct WithdrawLiquidityAccountConstraints { associated_token::authority = withdrawer, associated_token::token_program = token_program, )] - pub token_a: Box>, + pub token_a: InterfaceAccount, #[account( init_if_needed, @@ -229,14 +229,14 @@ pub struct WithdrawLiquidityAccountConstraints { associated_token::authority = withdrawer, associated_token::token_program = token_program, )] - pub token_b: Box>, + pub token_b: InterfaceAccount, /// The account paying for all rents #[account(mut)] pub payer: Signer, /// Solana ecosystem accounts - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/finance/token-swap/anchor/programs/token-swap/src/liquidity.rs b/finance/token-swap/anchor/programs/token-swap/src/liquidity.rs index f9de5b0bf..9a06b8d95 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/liquidity.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/liquidity.rs @@ -69,7 +69,7 @@ pub fn initial_lp_amount(amount_a: u64, amount_b: u64) -> Result { /// `CpiHandleMut`, which borrows the wrapper mutably. `pool_config` is `&mut` /// too, because it has to hand back its data borrow while it signs. pub struct LiquidityDepositAccounts<'a> { - pub token_program: &'a Interface<'static, TokenInterface>, + pub token_program: &'a Interface, pub pool_config: &'a mut BorshAccount, pub mint_a: &'a InterfaceAccount, pub mint_b: &'a InterfaceAccount, diff --git a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/authority_transfer.rs b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/authority_transfer.rs index e9c3d0073..65653498e 100644 --- a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/authority_transfer.rs +++ b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/authority_transfer.rs @@ -26,7 +26,7 @@ pub struct AuthorityTransferAccountConstraints { )] pub user_pda: SystemAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } pub fn handler( diff --git a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/transfer_tokens.rs b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/transfer_tokens.rs index 3739c4ee6..65d221953 100644 --- a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/transfer_tokens.rs +++ b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/transfer_tokens.rs @@ -29,7 +29,7 @@ pub struct TransferTokensAccountConstraints { )] pub user_pda: SystemAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } pub fn handler( diff --git a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_associated_token_account.rs b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_associated_token_account.rs index 0474ad6f6..3dfc49c5d 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_associated_token_account.rs +++ b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_associated_token_account.rs @@ -18,7 +18,7 @@ pub struct CreateAssociatedTokenAccountAccountConstraints { )] pub token_account: InterfaceAccount, pub system_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, } diff --git a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_token.rs b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_token.rs index 5322c6a1a..ddef2cf98 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_token.rs +++ b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_token.rs @@ -23,7 +23,7 @@ pub struct CreateTokenAccountConstraints { )] pub mint: InterfaceAccount, pub system_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } pub fn handler( diff --git a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_token_account.rs b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_token_account.rs index 0a607a723..58b13f457 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_token_account.rs +++ b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/create_token_account.rs @@ -20,7 +20,7 @@ pub struct CreateTokenAccountAccountConstraints { )] pub token_account: InterfaceAccount, pub system_program: Program, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } pub fn handler(_context: &mut Context) -> Result<()> { diff --git a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/mint_token.rs b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/mint_token.rs index 29ba54110..222cca128 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/mint_token.rs +++ b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/mint_token.rs @@ -9,7 +9,7 @@ pub struct MintTokenAccountConstraints { pub mint: InterfaceAccount, #[account(mut)] pub receiver: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, } pub fn handler(context: &mut Context, amount: u64) -> Result<()> { diff --git a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/transfer_token.rs b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/transfer_token.rs index 8b8543b68..b356f38ec 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/transfer_token.rs +++ b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/transfer_token.rs @@ -21,7 +21,7 @@ pub struct TransferTokenAccountConstraints { pub to_ata: InterfaceAccount, #[account(mut)] pub mint: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub system_program: Program, pub associated_token_program: Program, } diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/attach_to_mint.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/attach_to_mint.rs index 6ed4a5761..05ebb75b3 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/attach_to_mint.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/attach_to_mint.rs @@ -19,7 +19,7 @@ pub struct AttachToMintAccountConstraints { mut, mint::token_program = token_program, )] - pub mint: Box>, + pub mint: InterfaceAccount, #[account( init, diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_config.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_config.rs index d9608870c..a0dec1771 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_config.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_config.rs @@ -13,7 +13,7 @@ pub struct InitConfigAccountConstraints { seeds = [CONFIG_SEED], bump, )] - pub config: Box>, + pub config: BorshAccount, pub system_program: Program, } diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_wallet.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_wallet.rs index 71a77a382..5a8f4fc71 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_wallet.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_wallet.rs @@ -9,7 +9,7 @@ pub struct InitWalletAccountConstraints { #[account(seeds = [CONFIG_SEED], bump = config.bump)] - pub config: Box>, + pub config: BorshAccount, pub wallet: SystemAccount, diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/remove_wallet.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/remove_wallet.rs index d8630b19e..b4cd5ef68 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/remove_wallet.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/remove_wallet.rs @@ -9,7 +9,7 @@ pub struct RemoveWalletAccountConstraints { #[account(seeds = [b"config"], bump = config.bump)] - pub config: Box>, + pub config: BorshAccount, #[account( mut, diff --git a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs index ba5eaf7ac..138cbd0c4 100644 --- a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs @@ -12,23 +12,23 @@ use crate::{check_is_transferring, CounterAccount}; // Remaining accounts are the extra accounts required from the ExtraAccountMetaList account // These accounts are provided via CPI to this program from the token2022 program // -// Box used for source_token, destination_token, wsol_mint, +// InterfaceAccount used for source_token, destination_token, wsol_mint, // delegate_wsol_token_account, and sender_wsol_token_account to avoid exceeding // the 4096-byte BPF stack frame limit in try_accounts deserialization. // This struct has 12 accounts - without Box, the generated code uses ~4160 bytes of stack. #[derive(Accounts)] pub struct TransferHookAccountConstraints { #[account(token::mint = mint, token::authority = owner)] - pub source_token: Box>, - pub mint: Box>, + pub source_token: InterfaceAccount, + pub mint: InterfaceAccount, #[account(token::mint = mint)] - pub destination_token: Box>, + pub destination_token: InterfaceAccount, /// CHECK: source token account owner, can be SystemAccount or PDA owned by another program pub owner: UncheckedAccount, /// CHECK: ExtraAccountMetaList Account, #[account(seeds = [b"extra-account-metas", mint.address().as_ref()], bump)] pub extra_account_meta_list: UncheckedAccount, - pub wsol_mint: Box>, + pub wsol_mint: InterfaceAccount, pub token_program: Program, pub associated_token_program: Program, #[account( @@ -42,13 +42,13 @@ pub struct TransferHookAccountConstraints { token::mint = wsol_mint, token::authority = delegate, )] - pub delegate_wsol_token_account: Box>, + pub delegate_wsol_token_account: InterfaceAccount, #[account( mut, token::mint = wsol_mint, token::authority = owner, )] - pub sender_wsol_token_account: Box>, + pub sender_wsol_token_account: InterfaceAccount, #[account(seeds = [b"counter"], bump)] pub counter_account: BorshAccount, } diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/create.rs b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/create.rs index f2865ad74..41a5c2841 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/create.rs +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/create.rs @@ -34,7 +34,7 @@ pub struct CreateTokenAccountConstraints { )] pub metadata_account: UncheckedAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub token_metadata_program: Program, pub system_program: Program, pub rent: Sysvar, diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs index 3cad7b746..057515cef 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs @@ -30,7 +30,7 @@ pub struct MintTokenAccountConstraints { )] pub associated_token_account: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/transfer.rs b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/transfer.rs index ee4039127..de5075fc2 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/transfer.rs +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/transfer.rs @@ -33,7 +33,7 @@ pub struct TransferTokensAccountConstraints { )] pub recipient_token_account: InterfaceAccount, - pub token_program: Interface<'static, TokenInterface>, + pub token_program: Interface, pub associated_token_program: Program, pub system_program: Program, } From 35a234b89d7e12fbe2f5e0d6775dd10b6d1434bd Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 16:36:24 +0000 Subject: [PATCH 3/9] Name each CpiContext's account capacity for rc.4 rc.4's CpiContext takes a const N, the number of accounts the CPI passes (anchor#5185). harvest_withheld_tokens_to_mint takes its sources as a slice. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB --- .../programs/create-system-account/src/lib.rs | 2 +- .../anchor/programs/hand/src/lib.rs | 2 +- .../src/instructions/create_new_account.rs | 2 +- .../src/instructions/init_rent_vault.rs | 2 +- .../anchor/programs/rent-example/src/lib.rs | 2 +- .../src/instructions/transfer_sol_with_cpi.rs | 2 +- .../betting-market/src/instructions/shared.rs | 6 +++--- .../programs/escrow/src/instructions/shared.rs | 8 ++++---- .../fundraiser/src/instructions/checker.rs | 2 +- .../fundraiser/src/instructions/close.rs | 4 ++-- .../fundraiser/src/instructions/contribute.rs | 2 +- .../fundraiser/src/instructions/refund.rs | 2 +- .../instructions/admin/collect_program_fees.rs | 2 +- .../borrow_obligation_liquidity.rs | 2 +- .../deposit_obligation_collateral.rs | 2 +- .../instructions/deposit_reserve_liquidity.rs | 4 ++-- .../src/instructions/liquidate_obligation.rs | 6 +++--- .../instructions/redeem_reserve_collateral.rs | 4 ++-- .../instructions/repay_obligation_liquidity.rs | 2 +- .../withdraw_obligation_collateral.rs | 4 ++-- .../src/instructions/collect_fees.rs | 2 +- .../managed-fund/src/instructions/deposit.rs | 6 +++--- .../managed-fund/src/instructions/rebalance.rs | 4 ++-- .../managed-fund/src/instructions/withdraw.rs | 6 +++--- .../src/instructions/swap_asset_for_usdc.rs | 4 ++-- .../src/instructions/swap_usdc_for_asset.rs | 4 ++-- .../options/src/instructions/shared.rs | 4 ++-- .../src/instructions/admin/withdraw_fees.rs | 2 +- .../order-book/src/instructions/place_order.rs | 4 ++-- .../src/instructions/settle_funds.rs | 4 ++-- .../src/instructions/add_liquidity.rs | 4 ++-- .../src/instructions/close_position.rs | 2 +- .../src/instructions/collect_fees.rs | 2 +- .../src/instructions/liquidate_position.rs | 4 ++-- .../src/instructions/open_position.rs | 2 +- .../src/instructions/remove_liquidity.rs | 4 ++-- .../prop-amm/src/instructions/close_market.rs | 4 ++-- .../src/instructions/deposit_inventory.rs | 4 ++-- .../programs/prop-amm/src/instructions/swap.rs | 8 ++++---- .../src/instructions/withdraw_inventory.rs | 4 ++-- .../src/instructions/admin/claim_admin_fees.rs | 4 ++-- .../token-swap/src/instructions/swap_tokens.rs | 8 ++++---- .../src/instructions/withdraw_liquidity.rs | 6 +++--- .../programs/token-swap/src/liquidity.rs | 6 +++--- .../extension_nft/src/instructions/mint_nft.rs | 12 ++++++------ .../anchor/programs/nft-minter/src/lib.rs | 6 +++--- .../src/instructions/create_collection.rs | 6 +++--- .../mint-nft/src/instructions/mint_nft.rs | 6 +++--- .../src/instructions/verify_collection.rs | 2 +- .../anchor/programs/create-token/src/lib.rs | 2 +- .../src/instructions/authority_transfer.rs | 2 +- .../src/instructions/transfer_tokens.rs | 2 +- .../token-minter/src/instructions/create.rs | 6 +++--- .../token-minter/src/instructions/mint.rs | 2 +- .../basics/src/instructions/mint_token.rs | 2 +- .../basics/src/instructions/transfer_token.rs | 2 +- .../anchor/programs/cpi-guard/src/lib.rs | 6 +++--- .../src/instructions/initialize.rs | 6 +++--- .../src/instructions/update_default_state.rs | 2 +- .../src/instructions/test_initialize_group.rs | 6 +++--- .../anchor/programs/immutable-owner/src/lib.rs | 6 +++--- .../src/instructions/initialize.rs | 6 +++--- .../src/instructions/update_rate.rs | 2 +- .../memo-transfer/src/instructions/disable.rs | 2 +- .../src/instructions/initialize.rs | 6 +++--- .../metadata/src/instructions/initialize.rs | 10 +++++----- .../src/instructions/update_authority.rs | 2 +- .../metadata/src/instructions/update_field.rs | 4 ++-- .../src/instructions/close.rs | 2 +- .../src/instructions/initialize.rs | 6 +++--- .../programs/non-transferable/src/lib.rs | 6 +++--- .../src/instructions/initialize.rs | 6 +++--- .../transfer-fee/src/instructions/harvest.rs | 4 ++-- .../src/instructions/initialize.rs | 6 +++--- .../transfer-fee/src/instructions/transfer.rs | 2 +- .../src/instructions/update_fee.rs | 2 +- .../transfer-fee/src/instructions/withdraw.rs | 2 +- .../src/instructions/attach_to_mint.rs | 2 +- .../abl-token/src/instructions/change_mode.rs | 6 +++--- .../abl-token/src/instructions/init_mint.rs | 18 +++++++++--------- .../src/instructions/initialize.rs | 6 +++--- .../src/instructions/transfer_hook.rs | 2 +- .../initialise_extra_account_metas_list.rs | 2 +- .../token-minter/src/instructions/create.rs | 2 +- .../token-minter/src/instructions/mint.rs | 2 +- .../transfer-tokens/src/instructions/create.rs | 2 +- .../transfer-tokens/src/instructions/mint.rs | 2 +- .../src/instructions/transfer.rs | 2 +- 88 files changed, 177 insertions(+), 177 deletions(-) diff --git a/basics/create-account/anchor/programs/create-system-account/src/lib.rs b/basics/create-account/anchor/programs/create-system-account/src/lib.rs index bfe079fc9..c77eb146c 100644 --- a/basics/create-account/anchor/programs/create-system-account/src/lib.rs +++ b/basics/create-account/anchor/programs/create-system-account/src/lib.rs @@ -20,7 +20,7 @@ pub mod create_system_account { let lamports = Rent::get()?.try_minimum_balance(0)?; create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), // From pubkey diff --git a/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs b/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs index 4dab21463..06e67989c 100644 --- a/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs +++ b/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs @@ -17,7 +17,7 @@ pub mod hand { context: &mut Context, name: String, ) -> Result<()> { - let cpi_ctx = CpiContext::new( + let cpi_ctx = CpiContext::<_, 1>::new( context.accounts.lever_program.address(), SwitchPower { power: context.accounts.power.cpi_handle_mut(), diff --git a/basics/pda-rent-payer/anchor/programs/anchor-program-example/src/instructions/create_new_account.rs b/basics/pda-rent-payer/anchor/programs/anchor-program-example/src/instructions/create_new_account.rs index 41523ba71..41f78635f 100644 --- a/basics/pda-rent-payer/anchor/programs/anchor-program-example/src/instructions/create_new_account.rs +++ b/basics/pda-rent-payer/anchor/programs/anchor-program-example/src/instructions/create_new_account.rs @@ -28,7 +28,7 @@ pub fn handle_create_new_account( // Create the new account, transferring lamports from the rent vault to the new account create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.rent_vault.cpi_handle_mut(), // From pubkey diff --git a/basics/pda-rent-payer/anchor/programs/anchor-program-example/src/instructions/init_rent_vault.rs b/basics/pda-rent-payer/anchor/programs/anchor-program-example/src/instructions/init_rent_vault.rs index 6c78c39d3..8bf2c89e3 100644 --- a/basics/pda-rent-payer/anchor/programs/anchor-program-example/src/instructions/init_rent_vault.rs +++ b/basics/pda-rent-payer/anchor/programs/anchor-program-example/src/instructions/init_rent_vault.rs @@ -24,7 +24,7 @@ pub fn handle_init_rent_vault( fund_lamports: u64, ) -> Result<()> { transfer( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), Transfer { from: context.accounts.payer.cpi_handle_mut(), diff --git a/basics/rent/anchor/programs/rent-example/src/lib.rs b/basics/rent/anchor/programs/rent-example/src/lib.rs index b97c4b08f..410d1f4d5 100644 --- a/basics/rent/anchor/programs/rent-example/src/lib.rs +++ b/basics/rent/anchor/programs/rent-example/src/lib.rs @@ -29,7 +29,7 @@ pub mod rent_example { msg!("Lamports required: {}", lamports_required); system_program::create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), system_program::CreateAccount { from: context.accounts.payer.cpi_handle_mut(), diff --git a/basics/transfer-sol/anchor/programs/transfer-sol/src/instructions/transfer_sol_with_cpi.rs b/basics/transfer-sol/anchor/programs/transfer-sol/src/instructions/transfer_sol_with_cpi.rs index 84d600933..f6d7353db 100644 --- a/basics/transfer-sol/anchor/programs/transfer-sol/src/instructions/transfer_sol_with_cpi.rs +++ b/basics/transfer-sol/anchor/programs/transfer-sol/src/instructions/transfer_sol_with_cpi.rs @@ -15,7 +15,7 @@ pub fn handler( amount: u64, ) -> Result<()> { system_program::transfer( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), system_program::Transfer { from: context.accounts.payer.cpi_handle_mut(), diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs index 2e325474b..d04d62039 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs @@ -24,7 +24,7 @@ pub fn transfer_tokens_to_vault( to: to.cpi_handle_mut(), authority: authority.cpi_handle(), }; - let cpi_context = CpiContext::new(token_program.address(), transfer_accounts); + let cpi_context = CpiContext::<_, 4>::new(token_program.address(), transfer_accounts); transfer_checked(cpi_context, amount, decimals) } @@ -77,7 +77,7 @@ pub fn transfer_tokens_from_vault( authority: CpiHandle::readonly(&event.view), }; let cpi_context = - CpiContext::new_with_signer(token_program.address(), transfer_accounts, &signer_seeds); + CpiContext::<_, 4>::new_with_signer(token_program.address(), transfer_accounts, &signer_seeds); transfer_checked(cpi_context, amount, decimals) } @@ -100,6 +100,6 @@ pub fn close_vault( authority: CpiHandle::readonly(&event.view), }; let cpi_context = - CpiContext::new_with_signer(token_program.address(), close_accounts, &signer_seeds); + CpiContext::<_, 3>::new_with_signer(token_program.address(), close_accounts, &signer_seeds); close_account(cpi_context) } diff --git a/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs b/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs index 920b414ae..523231bf7 100644 --- a/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs +++ b/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs @@ -28,9 +28,9 @@ pub fn transfer_tokens( let signer_seeds = owning_pda_seeds.map(|seeds| [seeds]); let cpi_context = match signer_seeds.as_ref() { Some(signer_seeds) => { - CpiContext::new_with_signer(token_program.address(), transfer_accounts, signer_seeds) + CpiContext::<_, 4>::new_with_signer(token_program.address(), transfer_accounts, signer_seeds) } - None => CpiContext::new(token_program.address(), transfer_accounts), + None => CpiContext::<_, 4>::new(token_program.address(), transfer_accounts), }; transfer_checked(cpi_context, *amount, decimals) @@ -55,9 +55,9 @@ pub fn close_token_account( let signer_seeds = owning_pda_seeds.map(|seeds| [seeds]); let cpi_context = match signer_seeds.as_ref() { Some(signer_seeds) => { - CpiContext::new_with_signer(token_program.address(), close_accounts, signer_seeds) + CpiContext::<_, 3>::new_with_signer(token_program.address(), close_accounts, signer_seeds) } - None => CpiContext::new(token_program.address(), close_accounts), + None => CpiContext::<_, 3>::new(token_program.address(), close_accounts), }; close_account(cpi_context) diff --git a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/checker.rs b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/checker.rs index 1b9d65d44..3c464eb8d 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/checker.rs +++ b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/checker.rs @@ -97,7 +97,7 @@ pub fn handle_check_contributions( to: accounts.maker_ata.cpi_handle_mut(), authority: CpiHandle::readonly(&fundraiser_view), }; - let transfer_context = CpiContext::new_with_signer( + let transfer_context = CpiContext::<_, 4>::new_with_signer( accounts.token_program.address(), transfer_accounts, &signer_seeds, diff --git a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/close.rs b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/close.rs index 761091afe..a09367c14 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/close.rs +++ b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/close.rs @@ -122,7 +122,7 @@ pub fn handle_close_fundraiser(accounts: &mut CloseFundraiserAccountConstraints) to: accounts.maker_ata.cpi_handle_mut(), authority: CpiHandle::readonly(&fundraiser_view), }; - let transfer_context = CpiContext::new_with_signer( + let transfer_context = CpiContext::<_, 4>::new_with_signer( accounts.token_program.address(), transfer_accounts, &signer_seeds, @@ -137,7 +137,7 @@ pub fn handle_close_fundraiser(accounts: &mut CloseFundraiserAccountConstraints) destination: accounts.maker.cpi_handle_mut(), authority: CpiHandle::readonly(&fundraiser_view), }; - let close_context = CpiContext::new_with_signer( + let close_context = CpiContext::<_, 3>::new_with_signer( accounts.token_program.address(), close_accounts, &signer_seeds, diff --git a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/contribute.rs b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/contribute.rs index 228dd116f..f00b08207 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/contribute.rs +++ b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/contribute.rs @@ -117,7 +117,7 @@ pub fn handle_contribute( to: accounts.vault.cpi_handle_mut(), authority: accounts.contributor.cpi_handle(), }; - let cpi_context = CpiContext::new(accounts.token_program.address(), cpi_accounts); + let cpi_context = CpiContext::<_, 4>::new(accounts.token_program.address(), cpi_accounts); transfer_checked(cpi_context, amount, accounts.mint_to_raise.decimals())?; Ok(()) diff --git a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/refund.rs b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/refund.rs index e5415cb01..67b1efef6 100644 --- a/finance/fundraiser/anchor/programs/fundraiser/src/instructions/refund.rs +++ b/finance/fundraiser/anchor/programs/fundraiser/src/instructions/refund.rs @@ -117,7 +117,7 @@ pub fn handle_refund(accounts: &mut RefundAccountConstraints) -> Result<()> { maker_address.as_ref(), &[fundraiser_bump], ]]; - let cpi_context = CpiContext::new_with_signer( + let cpi_context = CpiContext::<_, 4>::new_with_signer( accounts.token_program.address(), cpi_accounts, &signer_seeds, diff --git a/finance/lending/anchor/programs/lending/src/instructions/admin/collect_program_fees.rs b/finance/lending/anchor/programs/lending/src/instructions/admin/collect_program_fees.rs index cc97b9b3b..21729670d 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/admin/collect_program_fees.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/admin/collect_program_fees.rs @@ -42,7 +42,7 @@ pub fn handle_collect_program_fees(context: &mut Context) -> // flushes the pending writes, and `reacquire_borrow_mut` re-reads them. context.accounts.reserve.release_borrow()?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.liquidity_vault.cpi_handle_mut(), diff --git a/finance/lending/anchor/programs/lending/src/instructions/borrow_obligation_liquidity.rs b/finance/lending/anchor/programs/lending/src/instructions/borrow_obligation_liquidity.rs index dd26d2b6e..00d2dda51 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/borrow_obligation_liquidity.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/borrow_obligation_liquidity.rs @@ -86,7 +86,7 @@ pub fn handle_borrow_obligation_liquidity( // flushes the pending writes, and `reacquire_borrow_mut` re-reads them. context.accounts.reserve.release_borrow()?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.liquidity_vault.cpi_handle_mut(), diff --git a/finance/lending/anchor/programs/lending/src/instructions/deposit_obligation_collateral.rs b/finance/lending/anchor/programs/lending/src/instructions/deposit_obligation_collateral.rs index 19ad34a63..f4e4e120d 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/deposit_obligation_collateral.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/deposit_obligation_collateral.rs @@ -28,7 +28,7 @@ pub fn handle_deposit_obligation_collateral( obligation.stale = true; transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.user_share.cpi_handle_mut(), diff --git a/finance/lending/anchor/programs/lending/src/instructions/deposit_reserve_liquidity.rs b/finance/lending/anchor/programs/lending/src/instructions/deposit_reserve_liquidity.rs index 015ea4eb8..9ba81106b 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/deposit_reserve_liquidity.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/deposit_reserve_liquidity.rs @@ -61,7 +61,7 @@ pub fn handle_deposit_reserve_liquidity( .ok_or(LendingError::MathOverflow)?; transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.user_liquidity.cpi_handle_mut(), @@ -85,7 +85,7 @@ pub fn handle_deposit_reserve_liquidity( // flushes the pending writes, and `reacquire_borrow_mut` re-reads them. context.accounts.reserve.release_borrow()?; mint_to( - CpiContext::new_with_signer( + CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), MintTo { mint: context.accounts.share_mint.cpi_handle_mut(), diff --git a/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs b/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs index 0d386b49e..f22e61d2a 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs @@ -172,7 +172,7 @@ pub fn handle_liquidate_obligation( // releasing the wrapper's data borrow and the CPI would be rejected with // `AccountBorrowFailed`. `to_cpi_handle_mut` forwards to the inner type. transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.liquidator_repay_source.to_cpi_handle_mut(), @@ -198,7 +198,7 @@ pub fn handle_liquidate_obligation( // flushes the pending writes, and `reacquire_borrow_mut` re-reads them. context.accounts.obligation.release_borrow()?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context @@ -223,7 +223,7 @@ pub fn handle_liquidate_obligation( // view rather than two borrows of the same field. let mut destination_view = *context.accounts.obligation.account(); let authority_view = *context.accounts.obligation.account(); - close_account(CpiContext::new_with_signer( + close_account(CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), CloseAccount { account: context diff --git a/finance/lending/anchor/programs/lending/src/instructions/redeem_reserve_collateral.rs b/finance/lending/anchor/programs/lending/src/instructions/redeem_reserve_collateral.rs index a23e68a33..04bb30ef5 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/redeem_reserve_collateral.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/redeem_reserve_collateral.rs @@ -47,7 +47,7 @@ pub fn handle_redeem_reserve_collateral( .ok_or(LendingError::MathOverflow)?; burn( - CpiContext::new( + CpiContext::<_, 3>::new( context.accounts.token_program.address(), Burn { mint: context.accounts.share_mint.cpi_handle_mut(), @@ -70,7 +70,7 @@ pub fn handle_redeem_reserve_collateral( // flushes the pending writes, and `reacquire_borrow_mut` re-reads them. context.accounts.reserve.release_borrow()?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.liquidity_vault.cpi_handle_mut(), diff --git a/finance/lending/anchor/programs/lending/src/instructions/repay_obligation_liquidity.rs b/finance/lending/anchor/programs/lending/src/instructions/repay_obligation_liquidity.rs index 80b8a5d0d..7280ea463 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/repay_obligation_liquidity.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/repay_obligation_liquidity.rs @@ -58,7 +58,7 @@ pub fn handle_repay_obligation_liquidity( } transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.user_liquidity.cpi_handle_mut(), diff --git a/finance/lending/anchor/programs/lending/src/instructions/withdraw_obligation_collateral.rs b/finance/lending/anchor/programs/lending/src/instructions/withdraw_obligation_collateral.rs index d9f7fd638..c45964dd2 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/withdraw_obligation_collateral.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/withdraw_obligation_collateral.rs @@ -83,7 +83,7 @@ pub fn handle_withdraw_obligation_collateral( // flushes the pending writes, and `reacquire_borrow_mut` re-reads them. context.accounts.obligation.release_borrow()?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.obligation_share_vault.cpi_handle_mut(), @@ -97,7 +97,7 @@ pub fn handle_withdraw_obligation_collateral( context.accounts.share_mint.decimals(), )?; if empties_vault { - close_account(CpiContext::new_with_signer( + close_account(CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), CloseAccount { account: context.accounts.obligation_share_vault.cpi_handle_mut(), diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/collect_fees.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/collect_fees.rs index a5df2ece2..73735d6b7 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/collect_fees.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/collect_fees.rs @@ -102,7 +102,7 @@ pub fn handle_collect_fees(context: &mut Context) to: context.accounts.manager_share_account.cpi_handle_mut(), authority: context.accounts.fund.to_cpi_handle(), }; - let cpi_ctx = CpiContext::new_with_signer( + let cpi_ctx = CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), mint_accounts, signer_seeds, diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs index 18a03b15e..c0a417d91 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs @@ -185,7 +185,7 @@ pub fn handle_deposit( to: context.accounts.vault_usdc.to_cpi_handle_mut(), authority: context.accounts.depositor.cpi_handle(), }; - let cpi_ctx = CpiContext::new(context.accounts.token_program.address(), transfer_accounts); + let cpi_ctx = CpiContext::<_, 4>::new(context.accounts.token_program.address(), transfer_accounts); transfer_checked(cpi_ctx, usdc_amount, usdc_decimals)?; let index_bytes = fund_index.to_le_bytes(); @@ -261,7 +261,7 @@ pub fn handle_deposit( token_program: context.accounts.token_program.cpi_handle(), system_program: context.accounts.system_program.cpi_handle(), }; - let cpi_ctx = CpiContext::new_with_signer( + let cpi_ctx = CpiContext::<_, 11>::new_with_signer( context.accounts.swap_router_program.address(), cpi_accounts, signer_seeds, @@ -292,7 +292,7 @@ pub fn handle_deposit( to: context.accounts.depositor_share_account.to_cpi_handle_mut(), authority: context.accounts.fund.to_cpi_handle(), }; - let cpi_ctx = CpiContext::new_with_signer( + let cpi_ctx = CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), mint_accounts, signer_seeds, diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs index 16d605533..b350aadd1 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/rebalance.rs @@ -232,7 +232,7 @@ pub fn handle_rebalance( system_program: context.accounts.system_program.cpi_handle(), }; mock_swap_router::cpi::swap_asset_for_usdc( - CpiContext::new_with_signer( + CpiContext::<_, 11>::new_with_signer( context.accounts.swap_router_program.address(), sell_cpi_accounts, signer_seeds, @@ -289,7 +289,7 @@ pub fn handle_rebalance( system_program: context.accounts.system_program.cpi_handle(), }; mock_swap_router::cpi::swap_usdc_for_asset( - CpiContext::new_with_signer( + CpiContext::<_, 11>::new_with_signer( context.accounts.swap_router_program.address(), buy_cpi_accounts, signer_seeds, diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs index 4f270989e..c4406d93c 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs @@ -148,7 +148,7 @@ pub fn handle_withdraw( authority: context.accounts.user.cpi_handle(), }; burn( - CpiContext::new(token_program_key, burn_accounts), + CpiContext::<_, 3>::new(token_program_key, burn_accounts), shares_to_burn, )?; @@ -161,7 +161,7 @@ pub fn handle_withdraw( authority: CpiHandle::readonly(&fund_view), }; transfer_checked( - CpiContext::new_with_signer(token_program_key, transfer_accounts, signer_seeds), + CpiContext::<_, 4>::new_with_signer(token_program_key, transfer_accounts, signer_seeds), amount_usdc, usdc_decimals, )?; @@ -203,7 +203,7 @@ pub fn handle_withdraw( authority: CpiHandle::readonly(&fund_view), }; transfer_checked( - CpiContext::new_with_signer(token_program_key, transfer_accounts, signer_seeds), + CpiContext::<_, 4>::new_with_signer(token_program_key, transfer_accounts, signer_seeds), amount, decimals, )?; diff --git a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_asset_for_usdc.rs b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_asset_for_usdc.rs index d0b8e54b9..44236ff57 100644 --- a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_asset_for_usdc.rs +++ b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_asset_for_usdc.rs @@ -95,7 +95,7 @@ pub fn handle_swap_asset_for_usdc( authority: context.accounts.caller.cpi_handle(), }; burn( - CpiContext::new(context.accounts.token_program.address(), burn_accounts), + CpiContext::<_, 3>::new(context.accounts.token_program.address(), burn_accounts), asset_amount_in, )?; @@ -110,7 +110,7 @@ pub fn handle_swap_asset_for_usdc( authority: context.accounts.router_config.to_cpi_handle(), }; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), transfer_accounts, signer_seeds, diff --git a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs index 228bc6381..cd0422782 100644 --- a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs +++ b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs @@ -97,7 +97,7 @@ pub fn handle_swap_usdc_for_asset( to: context.accounts.router_usdc_treasury.to_cpi_handle_mut(), authority: context.accounts.caller.cpi_handle(), }; - let cpi_ctx = CpiContext::new(context.accounts.token_program.address(), transfer_accounts); + let cpi_ctx = CpiContext::<_, 4>::new(context.accounts.token_program.address(), transfer_accounts); transfer_checked( cpi_ctx, usdc_amount_in, @@ -113,7 +113,7 @@ pub fn handle_swap_usdc_for_asset( to: context.accounts.caller_asset_account.to_cpi_handle_mut(), authority: context.accounts.router_config.to_cpi_handle(), }; - let cpi_ctx = CpiContext::new_with_signer( + let cpi_ctx = CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), mint_accounts, signer_seeds, diff --git a/finance/options/anchor/programs/options/src/instructions/shared.rs b/finance/options/anchor/programs/options/src/instructions/shared.rs index eb18a3311..6bea9fbdb 100644 --- a/finance/options/anchor/programs/options/src/instructions/shared.rs +++ b/finance/options/anchor/programs/options/src/instructions/shared.rs @@ -38,7 +38,7 @@ pub fn transfer_from_signer( amount: u64, ) -> Result<()> { transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( token_program.address(), TransferChecked { from: from.to_cpi_handle_mut(), @@ -80,7 +80,7 @@ pub fn transfer_from_vault( market.release_borrow()?; let market_view = *market.account(); transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( token_program.address(), TransferChecked { from: vault.to_cpi_handle_mut(), diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs b/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs index c08b47e11..4d8e2a253 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs @@ -44,7 +44,7 @@ pub fn handle_withdraw_fees(context: &mut Context::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.fee_vault.to_cpi_handle_mut(), diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs index 6b6cf380b..10742f430 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs @@ -117,7 +117,7 @@ pub fn handle_place_order( }; transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: source_account, @@ -394,7 +394,7 @@ pub fn handle_place_order( context.accounts.market.release_borrow()?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.quote_vault.to_cpi_handle_mut(), diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs b/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs index 2be20bfe1..1dfc8c9c2 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs @@ -43,7 +43,7 @@ pub fn handle_settle_funds(context: &mut Context) if base_amount > 0 { transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.base_vault.to_cpi_handle_mut(), @@ -60,7 +60,7 @@ pub fn handle_settle_funds(context: &mut Context) if quote_amount > 0 { transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.quote_vault.to_cpi_handle_mut(), diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/add_liquidity.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/add_liquidity.rs index e8029ea35..545c8a795 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/add_liquidity.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/add_liquidity.rs @@ -74,7 +74,7 @@ pub fn handle_add_liquidity( .ok_or(PerpError::MathOverflow)?; transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.provider_collateral.to_cpi_handle_mut(), @@ -103,7 +103,7 @@ pub fn handle_add_liquidity( ]; context.accounts.pool.release_borrow()?; mint_to( - CpiContext::new_with_signer( + CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), MintTo { mint: context.accounts.lp_mint.to_cpi_handle_mut(), diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/close_position.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/close_position.rs index 0a5a13bac..9ca4282b8 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/close_position.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/close_position.rs @@ -112,7 +112,7 @@ pub fn handle_close_position( ]; context.accounts.pool.release_borrow()?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.custody_vault.to_cpi_handle_mut(), diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/collect_fees.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/collect_fees.rs index 6f2490850..7b255443b 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/collect_fees.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/collect_fees.rs @@ -32,7 +32,7 @@ pub fn handle_collect_fees(context: &mut Context) ]; context.accounts.pool.release_borrow()?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.custody_vault.to_cpi_handle_mut(), diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/liquidate_position.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/liquidate_position.rs index 76e46f776..ab0bebb28 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/liquidate_position.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/liquidate_position.rs @@ -94,7 +94,7 @@ pub fn handle_liquidate_position( if liquidator_payout > 0 { transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.custody_vault.to_cpi_handle_mut(), @@ -111,7 +111,7 @@ pub fn handle_liquidate_position( if trader_refund > 0 { transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.custody_vault.to_cpi_handle_mut(), diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/open_position.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/open_position.rs index 82035e829..6bed20f39 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/open_position.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/open_position.rs @@ -106,7 +106,7 @@ pub fn handle_open_position( } transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.trader_collateral.to_cpi_handle_mut(), diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/remove_liquidity.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/remove_liquidity.rs index e3877c3fd..0df6e2da4 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/remove_liquidity.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/src/instructions/remove_liquidity.rs @@ -65,7 +65,7 @@ pub fn handle_remove_liquidity( .ok_or(PerpError::MathOverflow)?; burn( - CpiContext::new( + CpiContext::<_, 3>::new( context.accounts.token_program.address(), Burn { mint: context.accounts.lp_mint.to_cpi_handle_mut(), @@ -92,7 +92,7 @@ pub fn handle_remove_liquidity( ]; context.accounts.pool.release_borrow()?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.custody_vault.to_cpi_handle_mut(), diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/close_market.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/close_market.rs index 56995f6c6..558899142 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/close_market.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/close_market.rs @@ -44,7 +44,7 @@ pub fn handle_close_market(context: &mut Context) context.accounts.market.release_borrow()?; let market_view = *context.accounts.market.account(); - close_account(CpiContext::new_with_signer( + close_account(CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), CloseAccount { account: context.accounts.base_vault.to_cpi_handle_mut(), @@ -54,7 +54,7 @@ pub fn handle_close_market(context: &mut Context) &[market_seeds], ))?; - close_account(CpiContext::new_with_signer( + close_account(CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), CloseAccount { account: context.accounts.quote_vault.to_cpi_handle_mut(), diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/deposit_inventory.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/deposit_inventory.rs index d46fe52c8..5b24388ed 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/deposit_inventory.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/deposit_inventory.rs @@ -19,7 +19,7 @@ pub fn handle_deposit_inventory( if base_amount > 0 { transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.operator_base.to_cpi_handle_mut(), @@ -35,7 +35,7 @@ pub fn handle_deposit_inventory( if quote_amount > 0 { transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.operator_quote.to_cpi_handle_mut(), diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/swap.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/swap.rs index 2ea53985f..85bc48c07 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/swap.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/swap.rs @@ -126,7 +126,7 @@ pub fn handle_swap( match direction { Direction::BuyBase => { transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.trader_quote.to_cpi_handle_mut(), @@ -139,7 +139,7 @@ pub fn handle_swap( context.accounts.quote_mint.decimals(), )?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.base_vault.to_cpi_handle_mut(), @@ -155,7 +155,7 @@ pub fn handle_swap( } Direction::SellBase => { transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.trader_base.to_cpi_handle_mut(), @@ -168,7 +168,7 @@ pub fn handle_swap( context.accounts.base_mint.decimals(), )?; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.quote_vault.to_cpi_handle_mut(), diff --git a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/withdraw_inventory.rs b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/withdraw_inventory.rs index 488704a15..181013f9b 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/src/instructions/withdraw_inventory.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/src/instructions/withdraw_inventory.rs @@ -43,7 +43,7 @@ pub fn handle_withdraw_inventory( if base_amount > 0 { transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.base_vault.to_cpi_handle_mut(), @@ -60,7 +60,7 @@ pub fn handle_withdraw_inventory( if quote_amount > 0 { transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.quote_vault.to_cpi_handle_mut(), diff --git a/finance/token-swap/anchor/programs/token-swap/src/instructions/admin/claim_admin_fees.rs b/finance/token-swap/anchor/programs/token-swap/src/instructions/admin/claim_admin_fees.rs index ad04e4148..133a978d8 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/instructions/admin/claim_admin_fees.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/instructions/admin/claim_admin_fees.rs @@ -69,7 +69,7 @@ pub fn handle_claim_admin_fees( if owed_a > 0 { token_interface::transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.pool_a.to_cpi_handle_mut(), @@ -86,7 +86,7 @@ pub fn handle_claim_admin_fees( if owed_b > 0 { token_interface::transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.pool_b.to_cpi_handle_mut(), diff --git a/finance/token-swap/anchor/programs/token-swap/src/instructions/swap_tokens.rs b/finance/token-swap/anchor/programs/token-swap/src/instructions/swap_tokens.rs index 2b2c2fd87..223ebdd2d 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/instructions/swap_tokens.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/instructions/swap_tokens.rs @@ -182,7 +182,7 @@ pub fn handle_swap_tokens( if input_is_token_a { token_interface::transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.token_a.to_cpi_handle_mut(), @@ -195,7 +195,7 @@ pub fn handle_swap_tokens( context.accounts.mint_a.decimals(), )?; token_interface::transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.pool_b.to_cpi_handle_mut(), @@ -210,7 +210,7 @@ pub fn handle_swap_tokens( )?; } else { token_interface::transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.pool_a.to_cpi_handle_mut(), @@ -224,7 +224,7 @@ pub fn handle_swap_tokens( context.accounts.mint_a.decimals(), )?; token_interface::transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.token_b.to_cpi_handle_mut(), diff --git a/finance/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs b/finance/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs index 83f89413b..a73ad1e1a 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs @@ -102,7 +102,7 @@ pub fn handle_withdraw_liquidity( // transfer_checked verifies the mint + decimals at the token program. token_interface::transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.pool_a.to_cpi_handle_mut(), @@ -117,7 +117,7 @@ pub fn handle_withdraw_liquidity( )?; token_interface::transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), TransferChecked { from: context.accounts.pool_b.to_cpi_handle_mut(), @@ -134,7 +134,7 @@ pub fn handle_withdraw_liquidity( // Burn the liquidity tokens // It will fail if the amount is invalid token_interface::burn( - CpiContext::new( + CpiContext::<_, 3>::new( context.accounts.token_program.address(), Burn { mint: context.accounts.liquidity_provider_mint.to_cpi_handle_mut(), diff --git a/finance/token-swap/anchor/programs/token-swap/src/liquidity.rs b/finance/token-swap/anchor/programs/token-swap/src/liquidity.rs index 9a06b8d95..e7fd02f1b 100644 --- a/finance/token-swap/anchor/programs/token-swap/src/liquidity.rs +++ b/finance/token-swap/anchor/programs/token-swap/src/liquidity.rs @@ -104,7 +104,7 @@ pub fn deposit_and_mint_lp_tokens( lp_amount: u64, ) -> Result<()> { token_interface::transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( accounts.token_program.address(), TransferChecked { from: accounts.depositor_token_a.to_cpi_handle_mut(), @@ -117,7 +117,7 @@ pub fn deposit_and_mint_lp_tokens( accounts.mint_a.decimals(), )?; token_interface::transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( accounts.token_program.address(), TransferChecked { from: accounts.depositor_token_b.to_cpi_handle_mut(), @@ -147,7 +147,7 @@ pub fn deposit_and_mint_lp_tokens( pool_config.release_borrow()?; token_interface::mint_to( - CpiContext::new_with_signer( + CpiContext::<_, 3>::new_with_signer( accounts.token_program.address(), MintTo { mint: accounts.liquidity_provider_mint.to_cpi_handle_mut(), diff --git a/nft/metadata-pointer/anchor/programs/extension_nft/src/instructions/mint_nft.rs b/nft/metadata-pointer/anchor/programs/extension_nft/src/instructions/mint_nft.rs index b8b325bba..83c6aa158 100644 --- a/nft/metadata-pointer/anchor/programs/extension_nft/src/instructions/mint_nft.rs +++ b/nft/metadata-pointer/anchor/programs/extension_nft/src/instructions/mint_nft.rs @@ -54,7 +54,7 @@ pub fn handle_mint_nft(context: &mut Context) -> Resu ); system_program::create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), system_program::CreateAccount { from: context.accounts.signer.cpi_handle_mut(), @@ -68,7 +68,7 @@ pub fn handle_mint_nft(context: &mut Context) -> Resu // Assign the mint to the token program system_program::assign( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.system_program.address(), system_program::Assign { account_to_assign: context.accounts.mint.cpi_handle_mut(), @@ -99,7 +99,7 @@ pub fn handle_mint_nft(context: &mut Context) -> Resu )?; // Initialize the mint cpi - let mint_cpi_ix = CpiContext::new( + let mint_cpi_ix = CpiContext::<_, 1>::new( context.accounts.token_program.address(), token_2022::InitializeMint2 { mint: context.accounts.mint.cpi_handle_mut(), @@ -158,7 +158,7 @@ pub fn handle_mint_nft(context: &mut Context) -> Resu )?; // Create the associated token account - associated_token::create(CpiContext::new( + associated_token::create(CpiContext::<_, 6>::new( context.accounts.associated_token_program.address(), associated_token::Create { payer: context.accounts.signer.cpi_handle_mut(), @@ -172,7 +172,7 @@ pub fn handle_mint_nft(context: &mut Context) -> Resu // Mint one token to the associated token account of the player token_2022::mint_to( - CpiContext::new_with_signer( + CpiContext::<_, 3>::new_with_signer( context.accounts.token_program.address(), token_2022::MintTo { mint: context.accounts.mint.cpi_handle_mut(), @@ -186,7 +186,7 @@ pub fn handle_mint_nft(context: &mut Context) -> Resu // Freeze the mint authority so no more tokens can be minted to make it an NFT token_2022::set_authority( - CpiContext::new_with_signer( + CpiContext::<_, 2>::new_with_signer( context.accounts.token_program.address(), token_2022::SetAuthority { current_authority: CpiHandle::readonly(&nft_authority_view), diff --git a/nft/minter/anchor/programs/nft-minter/src/lib.rs b/nft/minter/anchor/programs/nft-minter/src/lib.rs index 25b4c572c..4118ebf66 100644 --- a/nft/minter/anchor/programs/nft-minter/src/lib.rs +++ b/nft/minter/anchor/programs/nft-minter/src/lib.rs @@ -32,7 +32,7 @@ pub mod nft_minter { // Cross Program Invocation (CPI) // Invoking the mint_to instruction on the token program mint_to( - CpiContext::new( + CpiContext::<_, 3>::new( context.accounts.token_program.address(), MintTo { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -47,7 +47,7 @@ pub mod nft_minter { // Cross Program Invocation (CPI) // Invoking the create_metadata_account_v3 instruction on the token metadata program create_metadata_accounts_v3( - CpiContext::new( + CpiContext::<_, 6>::new( context.accounts.token_metadata_program.address(), CreateMetadataAccountsV3 { metadata: context.accounts.metadata_account.cpi_handle_mut(), @@ -76,7 +76,7 @@ pub mod nft_minter { // Cross Program Invocation (CPI) // Invoking the create_master_edition_v3 instruction on the token metadata program create_master_edition_v3( - CpiContext::new( + CpiContext::<_, 8>::new( context.accounts.token_metadata_program.address(), CreateMasterEditionV3 { edition: context.accounts.edition_account.cpi_handle_mut(), diff --git a/nft/operations/anchor/programs/mint-nft/src/instructions/create_collection.rs b/nft/operations/anchor/programs/mint-nft/src/instructions/create_collection.rs index 5c3f78e9d..21603d69b 100644 --- a/nft/operations/anchor/programs/mint-nft/src/instructions/create_collection.rs +++ b/nft/operations/anchor/programs/mint-nft/src/instructions/create_collection.rs @@ -82,7 +82,7 @@ pub fn handle_create_collection( authority: accounts.mint_authority.cpi_handle(), }; let cpi_ctx = - CpiContext::new_with_signer(accounts.token_program.address(), cpi_accounts, signer_seeds); + CpiContext::<_, 3>::new_with_signer(accounts.token_program.address(), cpi_accounts, signer_seeds); mint_to(cpi_ctx, 1)?; msg!("Collection NFT minted!"); @@ -97,7 +97,7 @@ pub fn handle_create_collection( // relaxes the runtime borrow check that a hand-built // `CpiHandle::readonly(&copied_view)` would still trip. create_metadata_accounts_v3( - CpiContext::new_with_signer( + CpiContext::<_, 6>::new_with_signer( accounts.token_metadata_program.address(), CreateMetadataAccountsV3 { metadata: accounts.metadata.cpi_handle_mut(), @@ -125,7 +125,7 @@ pub fn handle_create_collection( msg!("Metadata Account created!"); create_master_edition_v3( - CpiContext::new_with_signer( + CpiContext::<_, 8>::new_with_signer( accounts.token_metadata_program.address(), CreateMasterEditionV3 { edition: accounts.master_edition.cpi_handle_mut(), diff --git a/nft/operations/anchor/programs/mint-nft/src/instructions/mint_nft.rs b/nft/operations/anchor/programs/mint-nft/src/instructions/mint_nft.rs index 961dd5158..b7b9bac39 100644 --- a/nft/operations/anchor/programs/mint-nft/src/instructions/mint_nft.rs +++ b/nft/operations/anchor/programs/mint-nft/src/instructions/mint_nft.rs @@ -86,7 +86,7 @@ pub fn handle_mint_nft( authority: accounts.mint_authority.cpi_handle(), }; let cpi_ctx = - CpiContext::new_with_signer(accounts.token_program.address(), cpi_accounts, signer_seeds); + CpiContext::<_, 3>::new_with_signer(accounts.token_program.address(), cpi_accounts, signer_seeds); mint_to(cpi_ctx, 1)?; msg!("NFT minted!"); @@ -101,7 +101,7 @@ pub fn handle_mint_nft( // relaxes the runtime borrow check that a hand-built // `CpiHandle::readonly(&copied_view)` would still trip. create_metadata_accounts_v3( - CpiContext::new_with_signer( + CpiContext::<_, 6>::new_with_signer( accounts.token_metadata_program.address(), CreateMetadataAccountsV3 { metadata: accounts.metadata.cpi_handle_mut(), @@ -131,7 +131,7 @@ pub fn handle_mint_nft( )?; create_master_edition_v3( - CpiContext::new_with_signer( + CpiContext::<_, 8>::new_with_signer( accounts.token_metadata_program.address(), CreateMasterEditionV3 { edition: accounts.master_edition.cpi_handle_mut(), diff --git a/nft/operations/anchor/programs/mint-nft/src/instructions/verify_collection.rs b/nft/operations/anchor/programs/mint-nft/src/instructions/verify_collection.rs index ab72a24f8..2d642b359 100644 --- a/nft/operations/anchor/programs/mint-nft/src/instructions/verify_collection.rs +++ b/nft/operations/anchor/programs/mint-nft/src/instructions/verify_collection.rs @@ -44,7 +44,7 @@ pub fn handle_verify_collection( let signer_seeds = &[&seeds[..]]; verify_sized_collection_item( - CpiContext::new_with_signer( + CpiContext::<_, 6>::new_with_signer( accounts.token_metadata_program.address(), VerifySizedCollectionItem { metadata: accounts.metadata.cpi_handle_mut(), diff --git a/tokens/create-token/anchor/programs/create-token/src/lib.rs b/tokens/create-token/anchor/programs/create-token/src/lib.rs index 92cf36cf7..023c3561c 100644 --- a/tokens/create-token/anchor/programs/create-token/src/lib.rs +++ b/tokens/create-token/anchor/programs/create-token/src/lib.rs @@ -38,7 +38,7 @@ pub mod create_token { let payer_view = *context.accounts.payer.account(); create_metadata_accounts_v3( - CpiContext::new( + CpiContext::<_, 6>::new( context.accounts.token_metadata_program.address(), CreateMetadataAccountsV3 { metadata: context.accounts.metadata_account.cpi_handle_mut(), diff --git a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/authority_transfer.rs b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/authority_transfer.rs index 65653498e..8e10e5e8d 100644 --- a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/authority_transfer.rs +++ b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/authority_transfer.rs @@ -41,7 +41,7 @@ pub fn handler( }; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), transfer_accounts, &[&[ diff --git a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/transfer_tokens.rs b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/transfer_tokens.rs index 65d221953..528cd26c9 100644 --- a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/transfer_tokens.rs +++ b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/src/instructions/transfer_tokens.rs @@ -72,7 +72,7 @@ pub fn handler( }; transfer_checked( - CpiContext::new_with_signer( + CpiContext::<_, 4>::new_with_signer( context.accounts.token_program.address(), transfer_accounts, &[&[user_account_key.as_ref(), &[context.bumps.user_pda]]], diff --git a/tokens/pda-mint-authority/anchor/programs/token-minter/src/instructions/create.rs b/tokens/pda-mint-authority/anchor/programs/token-minter/src/instructions/create.rs index e5056fc96..b63e8a93e 100644 --- a/tokens/pda-mint-authority/anchor/programs/token-minter/src/instructions/create.rs +++ b/tokens/pda-mint-authority/anchor/programs/token-minter/src/instructions/create.rs @@ -65,7 +65,7 @@ pub fn handle_create_token( let mint_address = *context.accounts.mint_account.address(); let lamports = Rent::get()?.try_minimum_balance(MintState::LEN)?; create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -79,7 +79,7 @@ pub fn handle_create_token( )?; initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -95,7 +95,7 @@ pub fn handle_create_token( // Cross Program Invocation (CPI) signed by PDA // Invoking the create_metadata_account_v3 instruction on the token metadata program create_metadata_accounts_v3( - CpiContext::new( + CpiContext::<_, 6>::new( context.accounts.token_metadata_program.address(), CreateMetadataAccountsV3 { metadata: context.accounts.metadata_account.cpi_handle_mut(), diff --git a/tokens/pda-mint-authority/anchor/programs/token-minter/src/instructions/mint.rs b/tokens/pda-mint-authority/anchor/programs/token-minter/src/instructions/mint.rs index 492cd30d2..e41678c63 100644 --- a/tokens/pda-mint-authority/anchor/programs/token-minter/src/instructions/mint.rs +++ b/tokens/pda-mint-authority/anchor/programs/token-minter/src/instructions/mint.rs @@ -63,7 +63,7 @@ pub fn handle_mint_token( // Invoke the mint_to instruction on the token program mint_to( - CpiContext::new( + CpiContext::<_, 3>::new( context.accounts.token_program.address(), MintTo { mint: mint_handle, diff --git a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/mint_token.rs b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/mint_token.rs index 222cca128..291e1e47e 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/mint_token.rs +++ b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/mint_token.rs @@ -19,7 +19,7 @@ pub fn handler(context: &mut Context, amount: u64) authority: context.accounts.signer.cpi_handle(), }; let cpi_program = context.accounts.token_program.address(); - let cpi_context = CpiContext::new(cpi_program, cpi_accounts); + let cpi_context = CpiContext::<_, 3>::new(cpi_program, cpi_accounts); token_interface::mint_to(cpi_context, amount)?; msg!("Mint Token"); Ok(()) diff --git a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/transfer_token.rs b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/transfer_token.rs index b356f38ec..5b2302cbf 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/transfer_token.rs +++ b/tokens/token-extensions/basics/anchor/programs/basics/src/instructions/transfer_token.rs @@ -34,7 +34,7 @@ pub fn handler(context: &mut Context, amount: u authority: context.accounts.signer.cpi_handle(), }; let cpi_program = context.accounts.token_program.address(); - let cpi_context = CpiContext::new(cpi_program, cpi_accounts); + let cpi_context = CpiContext::<_, 4>::new(cpi_program, cpi_accounts); token_interface::transfer_checked(cpi_context, amount, context.accounts.mint.decimals())?; msg!("Transfer Token"); Ok(()) diff --git a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/src/lib.rs b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/src/lib.rs index 709e047e9..021bc805c 100644 --- a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/src/lib.rs +++ b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/src/lib.rs @@ -36,7 +36,7 @@ pub mod cpi_guard { let signer_seeds: &[&[&[u8]]] = &[&[b"pda", &[context.bumps.recipient_token_account]]]; create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.sender.cpi_handle_mut(), @@ -50,7 +50,7 @@ pub mod cpi_guard { )?; let recipient_handle = context.accounts.recipient_token_account.cpi_handle_mut(); - initialize_account3(CpiContext::new( + initialize_account3(CpiContext::<_, 3>::new( context.accounts.token_program.address(), InitializeAccount3 { account: recipient_handle, @@ -62,7 +62,7 @@ pub mod cpi_guard { } transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.sender_token_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/src/instructions/initialize.rs b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/src/instructions/initialize.rs index 1869b6568..5c7ee55ec 100644 --- a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/src/instructions/initialize.rs +++ b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/src/instructions/initialize.rs @@ -32,7 +32,7 @@ pub fn handler(context: &mut Context) -> Result<() // Invoke System Program to create new account with space for mint and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -47,7 +47,7 @@ pub fn handler(context: &mut Context) -> Result<() // Initialize the NonTransferable extension // This instruction must come before the instruction to initialize the mint data default_account_state_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), DefaultAccountStateInitialize { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -58,7 +58,7 @@ pub fn handler(context: &mut Context) -> Result<() // Initialize the standard mint account data initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/src/instructions/update_default_state.rs b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/src/instructions/update_default_state.rs index 9323ccf15..c825e7225 100644 --- a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/src/instructions/update_default_state.rs +++ b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/src/instructions/update_default_state.rs @@ -28,7 +28,7 @@ pub fn handler( let account_state = account_state.to_spl_account_state(); default_account_state_update( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.token_program.address(), DefaultAccountStateUpdate { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/group/anchor/programs/group/src/instructions/test_initialize_group.rs b/tokens/token-extensions/group/anchor/programs/group/src/instructions/test_initialize_group.rs index 2e83d505c..2e260422c 100644 --- a/tokens/token-extensions/group/anchor/programs/group/src/instructions/test_initialize_group.rs +++ b/tokens/token-extensions/group/anchor/programs/group/src/instructions/test_initialize_group.rs @@ -68,7 +68,7 @@ pub fn handler(context: &mut Context) -> Resu // Invoke System Program to create new account with space for mint and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -84,7 +84,7 @@ pub fn handler(context: &mut Context) -> Resu // Initialize the GroupPointer extension // This instruction must come before the instruction to initialize the mint data group_pointer_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), GroupPointerInitialize { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -96,7 +96,7 @@ pub fn handler(context: &mut Context) -> Resu // Initialize the standard mint account data initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/src/lib.rs b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/src/lib.rs index a2e307080..06878dfc8 100644 --- a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/src/lib.rs +++ b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/src/lib.rs @@ -31,7 +31,7 @@ pub mod immutable_owner { // Invoke System Program to create new account with space for token account and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -44,7 +44,7 @@ pub mod immutable_owner { )?; // Initialize the token account with the immutable owner extension - immutable_owner_initialize(CpiContext::new( + immutable_owner_initialize(CpiContext::<_, 1>::new( context.accounts.token_program.address(), ImmutableOwnerInitialize { token_account: context.accounts.token_account.cpi_handle_mut(), @@ -52,7 +52,7 @@ pub mod immutable_owner { ))?; // Initialize the standard token account data - initialize_account3(CpiContext::new( + initialize_account3(CpiContext::<_, 3>::new( context.accounts.token_program.address(), InitializeAccount3 { account: context.accounts.token_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/src/instructions/initialize.rs b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/src/instructions/initialize.rs index 9a93f4519..2c8b635d4 100644 --- a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/src/instructions/initialize.rs +++ b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/src/instructions/initialize.rs @@ -40,7 +40,7 @@ pub fn handler(context: &mut Context, rate: i16) - // Invoke System Program to create new account with space for mint and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -55,7 +55,7 @@ pub fn handler(context: &mut Context, rate: i16) - // Initialize the InterestBearingConfig extension // This instruction must come before the instruction to initialize the mint data interest_bearing_mint_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InterestBearingMintInitialize { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -67,7 +67,7 @@ pub fn handler(context: &mut Context, rate: i16) - // Initialize the standard mint account data initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/src/instructions/update_rate.rs b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/src/instructions/update_rate.rs index c35712356..ac08b205c 100644 --- a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/src/instructions/update_rate.rs +++ b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/src/instructions/update_rate.rs @@ -20,7 +20,7 @@ pub struct UpdateRateAccountConstraints { pub fn handler(context: &mut Context, rate: i16) -> Result<()> { interest_bearing_mint_update_rate( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.token_program.address(), InterestBearingMintUpdateRate { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/src/instructions/disable.rs b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/src/instructions/disable.rs index 0a8b6999c..684550736 100644 --- a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/src/instructions/disable.rs +++ b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/src/instructions/disable.rs @@ -16,7 +16,7 @@ pub struct DisableAccountConstraints { } pub fn handler(context: &mut Context) -> Result<()> { - memo_transfer_disable(CpiContext::new( + memo_transfer_disable(CpiContext::<_, 2>::new( context.accounts.token_program.address(), MemoTransfer { account: context.accounts.token_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/src/instructions/initialize.rs b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/src/instructions/initialize.rs index f22ffcd3b..a6dd49b44 100644 --- a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/src/instructions/initialize.rs +++ b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/src/instructions/initialize.rs @@ -34,7 +34,7 @@ pub fn handler(context: &mut Context) -> Result<() // Invoke System Program to create new account with space for token account and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -47,7 +47,7 @@ pub fn handler(context: &mut Context) -> Result<() )?; // Initialize the standard token account data - initialize_account3(CpiContext::new( + initialize_account3(CpiContext::<_, 3>::new( context.accounts.token_program.address(), InitializeAccount3 { account: context.accounts.token_account.cpi_handle_mut(), @@ -58,7 +58,7 @@ pub fn handler(context: &mut Context) -> Result<() // Initialize the memo transfer extension // This instruction must come after the token account initialization - memo_transfer_initialize(CpiContext::new( + memo_transfer_initialize(CpiContext::<_, 2>::new( context.accounts.token_program.address(), MemoTransfer { account: context.accounts.token_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/initialize.rs b/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/initialize.rs index 86c8b915e..ddc6ba452 100644 --- a/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/initialize.rs +++ b/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/initialize.rs @@ -41,7 +41,7 @@ pub fn process_initialize( let mint_address = *context.accounts.mint_account.address(); create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -55,7 +55,7 @@ pub fn process_initialize( // The metadata lives in the mint account itself, so the pointer points at it. metadata_pointer_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), MetadataPointerInitialize { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -66,7 +66,7 @@ pub fn process_initialize( )?; initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -93,7 +93,7 @@ pub fn process_initialize( // Transfer additional lamports to mint account transfer( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), Transfer { from: context.accounts.payer.cpi_handle_mut(), @@ -110,7 +110,7 @@ pub fn process_initialize( let mint_view = *context.accounts.mint_account.account(); token_metadata_initialize( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TokenMetadataInitialize { mint: CpiHandle::readonly(&mint_view), diff --git a/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/update_authority.rs b/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/update_authority.rs index c17ff2a84..414c8b403 100644 --- a/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/update_authority.rs +++ b/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/update_authority.rs @@ -30,7 +30,7 @@ pub fn process_update_authority( // Change update authority. v2's struct drops the program-id and // new-authority slots: neither is passed as an account. token_metadata_update_authority( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.token_program.address(), TokenMetadataUpdateAuthority { metadata: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/update_field.rs b/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/update_field.rs index 89a1c5588..3d8fd46c0 100644 --- a/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/update_field.rs +++ b/tokens/token-extensions/metadata/anchor/programs/metadata/src/instructions/update_field.rs @@ -78,7 +78,7 @@ pub fn process_update_field( if required_lamports > current_lamports { let lamport_difference = required_lamports - current_lamports; transfer( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), Transfer { from: context.accounts.authority.cpi_handle_mut(), @@ -95,7 +95,7 @@ pub fn process_update_field( // Update token metadata token_metadata_update_field( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.token_program.address(), TokenMetadataUpdateField { metadata: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/src/instructions/close.rs b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/src/instructions/close.rs index 39c6f7f22..54e8e32c6 100644 --- a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/src/instructions/close.rs +++ b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/src/instructions/close.rs @@ -25,7 +25,7 @@ pub fn handler(context: &mut Context) -> Result<()> { // cpi to token extensions programs to close mint account // alternatively, this can also be done in the client - close_account(CpiContext::new( + close_account(CpiContext::<_, 3>::new( context.accounts.token_program.address(), CloseAccount { account: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/src/instructions/initialize.rs b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/src/instructions/initialize.rs index 27ed82525..801e8f617 100644 --- a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/src/instructions/initialize.rs +++ b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/src/instructions/initialize.rs @@ -44,7 +44,7 @@ pub fn handler(context: &mut Context) -> Result<() // Invoke System Program to create new account with space for mint and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -59,7 +59,7 @@ pub fn handler(context: &mut Context) -> Result<() // Initialize the MintCloseAuthority extension // This instruction must come before the instruction to initialize the mint data mint_close_authority_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), MintCloseAuthorityInitialize { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -70,7 +70,7 @@ pub fn handler(context: &mut Context) -> Result<() // Initialize the standard mint account data initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/src/lib.rs b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/src/lib.rs index 453098ad1..17622f621 100644 --- a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/src/lib.rs +++ b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/src/lib.rs @@ -27,7 +27,7 @@ pub mod non_transferable { // Invoke System Program to create new account with space for mint and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -41,7 +41,7 @@ pub mod non_transferable { // Initialize the NonTransferable extension // This instruction must come before the instruction to initialize the mint data - non_transferable_mint_initialize(CpiContext::new( + non_transferable_mint_initialize(CpiContext::<_, 1>::new( context.accounts.token_program.address(), NonTransferableMintInitialize { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -50,7 +50,7 @@ pub mod non_transferable { // Initialize the standard mint account data initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/src/instructions/initialize.rs b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/src/instructions/initialize.rs index 8add30eb9..57c7a083b 100644 --- a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/src/instructions/initialize.rs +++ b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/src/instructions/initialize.rs @@ -63,7 +63,7 @@ pub fn handler(context: &mut Context) -> Result<() // Invoke System Program to create new account with space for mint and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -78,7 +78,7 @@ pub fn handler(context: &mut Context) -> Result<() // Initialize the PermanentDelegate extension // This instruction must come before the instruction to initialize the mint data permanent_delegate_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), PermanentDelegateInitialize { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -89,7 +89,7 @@ pub fn handler(context: &mut Context) -> Result<() // Initialize the standard mint account data initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs index 57322b74c..bdc903e33 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs @@ -42,13 +42,13 @@ pub fn process_harvest(context: &mut Context) -> Resu .collect(); harvest_withheld_tokens_to_mint( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), HarvestWithheldTokensToMint { mint: context.accounts.mint_account.cpi_handle_mut(), }, ), - sources, // token accounts to harvest from + &sources, // token accounts to harvest from )?; Ok(()) } diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/initialize.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/initialize.rs index 48a9fe1cd..41f1f7bc4 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/initialize.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/initialize.rs @@ -46,7 +46,7 @@ pub fn handle_process_initialize( // Invoke System Program to create new account with space for mint and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -61,7 +61,7 @@ pub fn handle_process_initialize( // Initialize the transfer fee extension data // This instruction must come before the instruction to initialize the mint data transfer_fee_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), TransferFeeInitialize { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -75,7 +75,7 @@ pub fn handle_process_initialize( // Initialize the standard mint account data initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/transfer.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/transfer.rs index 0d8ad8495..d4a9c8d8c 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/transfer.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/transfer.rs @@ -65,7 +65,7 @@ pub fn handle_process_transfer( let decimals = context.accounts.mint_account.decimals(); transfer_checked_with_fee( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferCheckedWithFee { source: context.accounts.sender_token_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/update_fee.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/update_fee.rs index fbc136c02..233fa28b8 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/update_fee.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/update_fee.rs @@ -19,7 +19,7 @@ pub fn handle_process_update_fee( maximum_fee: u64, ) -> Result<()> { transfer_fee_set( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.token_program.address(), TransferFeeSetTransferFee { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/withdraw.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/withdraw.rs index deb925be9..1233ff760 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/withdraw.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/withdraw.rs @@ -18,7 +18,7 @@ pub struct WithdrawAccountConstraints { // transfer fees "harvested" to the mint account can then be withdraw by the withdraw authority // this transfers fees on the mint account to the specified token account pub fn handle_process_withdraw(context: &mut Context) -> Result<()> { - withdraw_withheld_tokens_from_mint(CpiContext::new( + withdraw_withheld_tokens_from_mint(CpiContext::<_, 3>::new( context.accounts.token_program.address(), WithdrawWithheldTokensFromMint { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/attach_to_mint.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/attach_to_mint.rs index 05ebb75b3..8dbe7ed3b 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/attach_to_mint.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/attach_to_mint.rs @@ -43,7 +43,7 @@ impl AttachToMintAccountConstraints { authority: self.payer.cpi_handle(), }; - let context = CpiContext::new(self.token_program.address(), tx_hook_accs); + let context = CpiContext::<_, 2>::new(self.token_program.address(), tx_hook_accs); transfer_hook_update(context, Some(&crate::ID))?; diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/change_mode.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/change_mode.rs index 1b0a1ac0c..6ef478956 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/change_mode.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/change_mode.rs @@ -45,7 +45,7 @@ impl ChangeModeAccountConstraints { update_authority: self.authority.cpi_handle(), }; let cpi_program = self.token_program.address(); - let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); + let cpi_ctx = CpiContext::<_, 2>::new(cpi_program, cpi_accounts); token_metadata_update_field(cpi_ctx, Field::Key("AB".to_string()), args.mode.to_string())?; @@ -61,7 +61,7 @@ impl ChangeModeAccountConstraints { update_authority: self.authority.cpi_handle(), }; let cpi_program = self.token_program.address(); - let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); + let cpi_ctx = CpiContext::<_, 2>::new(cpi_program, cpi_accounts); token_metadata_update_field( cpi_ctx, @@ -76,7 +76,7 @@ impl ChangeModeAccountConstraints { let current = self.mint.account().lamports(); if min_balance > current { transfer( - CpiContext::new( + CpiContext::<_, 2>::new( self.system_program.address(), Transfer { from: self.authority.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_mint.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_mint.rs index 01dc3b0e1..d9fe9715c 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_mint.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_mint.rs @@ -68,7 +68,7 @@ impl InitMintAccountConstraints { let lamports = Rent::get()?.try_minimum_balance(mint_size)?; create_account( - CpiContext::new( + CpiContext::<_, 2>::new( self.system_program.address(), CreateAccount { from: self.payer.cpi_handle_mut(), @@ -81,7 +81,7 @@ impl InitMintAccountConstraints { )?; permanent_delegate_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( self.token_program.address(), PermanentDelegateInitialize { mint: self.mint.cpi_handle_mut(), @@ -91,7 +91,7 @@ impl InitMintAccountConstraints { )?; transfer_hook_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( self.token_program.address(), TransferHookInitialize { mint: self.mint.cpi_handle_mut(), @@ -103,7 +103,7 @@ impl InitMintAccountConstraints { // metadata is stored in the mint itself, so the pointer points at it metadata_pointer_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( self.token_program.address(), MetadataPointerInitialize { mint: self.mint.cpi_handle_mut(), @@ -114,7 +114,7 @@ impl InitMintAccountConstraints { )?; initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( self.token_program.address(), InitializeMint2 { mint: self.mint.cpi_handle_mut(), @@ -139,14 +139,14 @@ impl InitMintAccountConstraints { mint: CpiHandle::readonly(&mint_view), mint_authority: CpiHandle::readonly(&payer_view), }; - let cpi_ctx = CpiContext::new(self.token_program.address(), cpi_accounts); + let cpi_ctx = CpiContext::<_, 4>::new(self.token_program.address(), cpi_accounts); token_metadata_initialize(cpi_ctx, args.name, args.symbol, args.uri)?; let cpi_accounts = TokenMetadataUpdateField { metadata: self.mint.cpi_handle_mut(), update_authority: CpiHandle::readonly(&payer_view), }; - let cpi_ctx = CpiContext::new(self.token_program.address(), cpi_accounts); + let cpi_ctx = CpiContext::<_, 2>::new(self.token_program.address(), cpi_accounts); token_metadata_update_field(cpi_ctx, Field::Key("AB".to_string()), args.mode.to_string())?; @@ -155,7 +155,7 @@ impl InitMintAccountConstraints { metadata: self.mint.cpi_handle_mut(), update_authority: CpiHandle::readonly(&payer_view), }; - let cpi_ctx = CpiContext::new(self.token_program.address(), cpi_accounts); + let cpi_ctx = CpiContext::<_, 2>::new(self.token_program.address(), cpi_accounts); token_metadata_update_field( cpi_ctx, @@ -170,7 +170,7 @@ impl InitMintAccountConstraints { let current = self.mint.account().lamports(); if min_balance > current { transfer( - CpiContext::new( + CpiContext::<_, 2>::new( self.system_program.address(), Transfer { from: self.payer.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/src/instructions/initialize.rs b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/src/instructions/initialize.rs index 51f780fac..41db11a36 100644 --- a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/src/instructions/initialize.rs +++ b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/src/instructions/initialize.rs @@ -47,7 +47,7 @@ pub fn handler(context: &mut Context, decimals: u8 // Invoke System Program to create new account with space for mint and extension data create_account( - CpiContext::new( + CpiContext::<_, 2>::new( context.accounts.system_program.address(), CreateAccount { from: context.accounts.payer.cpi_handle_mut(), @@ -62,7 +62,7 @@ pub fn handler(context: &mut Context, decimals: u8 // Initialize the TransferHook extension, pointing at this program // This instruction must come before the instruction to initialize the mint data transfer_hook_initialize( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), TransferHookInitialize { mint: context.accounts.mint_account.cpi_handle_mut(), @@ -74,7 +74,7 @@ pub fn handler(context: &mut Context, decimals: u8 // Initialize the standard mint account data initialize_mint2( - CpiContext::new( + CpiContext::<_, 1>::new( context.accounts.token_program.address(), InitializeMint2 { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs index 138cbd0c4..27e10a503 100644 --- a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs @@ -88,7 +88,7 @@ pub fn handler(context: &mut Context, amount: u6 // Transfer WSOL from sender to delegate token account using delegate PDA // transfer lamports amount equal to token transfer amount transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.sender_wsol_token_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/src/instructions/initialise_extra_account_metas_list.rs b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/src/instructions/initialise_extra_account_metas_list.rs index 636dc8ce7..ff527b5d3 100644 --- a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/src/instructions/initialise_extra_account_metas_list.rs +++ b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/src/instructions/initialise_extra_account_metas_list.rs @@ -62,7 +62,7 @@ pub fn handle_initialize_extra_account_metas_list( ]]; create_account( - CpiContext::new( + CpiContext::<_, 2>::new( accounts.system_program.address(), CreateAccount { from: accounts.payer.cpi_handle_mut(), diff --git a/tokens/token-minter/anchor/programs/token-minter/src/instructions/create.rs b/tokens/token-minter/anchor/programs/token-minter/src/instructions/create.rs index e4a421011..ce1a420ef 100644 --- a/tokens/token-minter/anchor/programs/token-minter/src/instructions/create.rs +++ b/tokens/token-minter/anchor/programs/token-minter/src/instructions/create.rs @@ -53,7 +53,7 @@ pub fn handle_create_token( // Cross Program Invocation (CPI) // Invoking the create_metadata_account_v3 instruction on the token metadata program create_metadata_accounts_v3( - CpiContext::new( + CpiContext::<_, 6>::new( context.accounts.token_metadata_program.address(), CreateMetadataAccountsV3 { metadata: context.accounts.metadata_account.cpi_handle_mut(), diff --git a/tokens/token-minter/anchor/programs/token-minter/src/instructions/mint.rs b/tokens/token-minter/anchor/programs/token-minter/src/instructions/mint.rs index 29f7d9cc4..4b0bf76be 100644 --- a/tokens/token-minter/anchor/programs/token-minter/src/instructions/mint.rs +++ b/tokens/token-minter/anchor/programs/token-minter/src/instructions/mint.rs @@ -52,7 +52,7 @@ pub fn handle_mint_token( // Invoke the mint_to instruction on the token program mint_to( - CpiContext::new( + CpiContext::<_, 3>::new( context.accounts.token_program.address(), MintTo { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/create.rs b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/create.rs index 41a5c2841..27ac3e374 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/create.rs +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/create.rs @@ -54,7 +54,7 @@ pub fn handle_create_token( // Cross Program Invocation (CPI) // Invoking the create_metadata_account_v3 instruction on the token metadata program create_metadata_accounts_v3( - CpiContext::new( + CpiContext::<_, 6>::new( context.accounts.token_metadata_program.address(), CreateMetadataAccountsV3 { metadata: context.accounts.metadata_account.cpi_handle_mut(), diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs index 057515cef..475a3886a 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/mint.rs @@ -53,7 +53,7 @@ pub fn handle_mint_token( // Invoke the mint_to instruction on the token program mint_to( - CpiContext::new( + CpiContext::<_, 3>::new( context.accounts.token_program.address(), MintTo { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/transfer.rs b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/transfer.rs index de5075fc2..8e8aaef59 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/transfer.rs +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/transfer.rs @@ -63,7 +63,7 @@ pub fn handle_transfer_tokens( // Invoke the transfer_checked instruction on the token program transfer_checked( - CpiContext::new( + CpiContext::<_, 4>::new( context.accounts.token_program.address(), TransferChecked { from: context.accounts.sender_token_account.cpi_handle_mut(), From b91841141e76bc059775b589996901c284b197ef Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 16:38:29 +0000 Subject: [PATCH 4/9] load_mut is safe and accounts are unboxed in rc.4 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB --- .../src/instructions/add_asset.rs | 2 +- .../src/instructions/initialize_fund.rs | 2 +- .../src/instructions/place_order.rs | 24 ++++++++----------- .../abl-token/src/instructions/init_config.rs | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/add_asset.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/add_asset.rs index a40236878..92c9c65b0 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/add_asset.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/add_asset.rs @@ -71,7 +71,7 @@ pub fn handle_add_asset( let index = fund.asset_count; - **context.accounts.asset_config = AssetConfig { + *context.accounts.asset_config = AssetConfig { fund: *fund.address(), index, mint: *context.accounts.asset_mint.address(), diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/initialize_fund.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/initialize_fund.rs index 6718e6834..bab44905c 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/initialize_fund.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/initialize_fund.rs @@ -102,7 +102,7 @@ pub fn handle_initialize_fund( let clock = Clock::get()?; - **context.accounts.fund = Fund { + *context.accounts.fund = Fund { index, manager: *context.accounts.manager.address(), registry: *context.accounts.registry.address(), diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs index 10742f430..84f8ea6e1 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs @@ -205,16 +205,12 @@ pub fn handle_place_order( // v2 has no `Account::try_from`. `AnchorAccount::load_mut` is the // equivalent for a writable account reached through remaining_accounts, // and it is the only route to one: the derive cannot type a variable - // number of accounts. - // - // SAFETY: the obligation is that no other `&mut` to the same data is - // live. The trait method is unsafe because `Slab` bypasses the runtime - // borrow check; `BorshAccount` does not, taking its guard through - // `try_borrow_mut`, so an account already borrowed elsewhere in this - // handler yields `AccountBorrowFailed` instead of aliasing. - let mut maker_order = unsafe { BorshAccount::::load_mut(*maker_order_info) }?; - let mut maker_market_user = - unsafe { BorshAccount::::load_mut(*maker_user_info) }?; + // number of accounts. `BorshAccount::load_mut` takes an exclusive + // borrow on the account's data, so an account already borrowed + // elsewhere in this handler yields `AccountBorrowFailed` instead of + // aliasing. + let mut maker_order = BorshAccount::::load_mut(*maker_order_info)?; + let mut maker_market_user = BorshAccount::::load_mut(*maker_user_info)?; require!( maker_order.owner == maker_market_user.owner, @@ -451,9 +447,9 @@ pub fn handle_place_order( .ok_or(ErrorCode::MissingEvictedAccounts)?; let market = &context.accounts.market; - // SAFETY: as for the maker accounts above. The evicted order is on - // the taker's own side, so it is never one of the maker orders. - let mut evicted_order = unsafe { BorshAccount::::load_mut(*evicted_order_info) }?; + // The evicted order is on the taker's own side, so it is never one of + // the maker orders loaded above. + let mut evicted_order = BorshAccount::::load_mut(*evicted_order_info)?; require!( evicted_order.order_id == worst.order_id && evicted_order.market == *market.address(), ErrorCode::EvictedAccountMismatch @@ -470,7 +466,7 @@ pub fn handle_place_order( .get(evicted_index + 1) .ok_or(ErrorCode::MissingEvictedAccounts)?; let mut evicted_market_user = - unsafe { BorshAccount::::load_mut(*evicted_user_info) }?; + BorshAccount::::load_mut(*evicted_user_info)?; require!( evicted_market_user.owner == evicted_order.owner && evicted_market_user.market == *market.address(), diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_config.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_config.rs index a0dec1771..0cc5850c7 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_config.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/src/instructions/init_config.rs @@ -20,7 +20,7 @@ pub struct InitConfigAccountConstraints { impl InitConfigAccountConstraints { pub fn init_config(&mut self, config_bump: u8) -> Result<()> { - **self.config = Config { + *self.config = Config { authority: *self.payer.address(), bump: config_bump, }; From 84e274ee8df3cc9259b2840c52a1202d96bdaa14 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 16:40:17 +0000 Subject: [PATCH 5/9] lending: pass the remaining-accounts slice without re-borrowing Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB --- .../programs/lending/src/instructions/refresh_obligation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/finance/lending/anchor/programs/lending/src/instructions/refresh_obligation.rs b/finance/lending/anchor/programs/lending/src/instructions/refresh_obligation.rs index 8315598df..6b01ec30a 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/refresh_obligation.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/refresh_obligation.rs @@ -31,7 +31,7 @@ pub fn handle_refresh_obligation(context: &mut Context) -> Re for collateral in obligation.deposits.iter_mut() { let (reserve, price_scaled) = read_pair( - &accounts, + accounts, &mut cursor, collateral.reserve, lending_market, @@ -74,7 +74,7 @@ pub fn handle_refresh_obligation(context: &mut Context) -> Re let mut borrowed_value: u128 = 0; for borrow in obligation.borrows.iter_mut() { let (reserve, price_scaled) = - read_pair(&accounts, &mut cursor, borrow.reserve, lending_market, slot)?; + read_pair(accounts, &mut cursor, borrow.reserve, lending_market, slot)?; let debt = mul_div_ceil( borrow.borrowed_principal, From ba65271458334ba54c2b96cbd58c005f66505c4c Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 16:42:16 +0000 Subject: [PATCH 6/9] rustfmt Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB --- .../betting-market/src/instructions/shared.rs | 7 +++++-- .../programs/escrow/src/instructions/shared.rs | 16 ++++++++++------ .../managed-fund/src/instructions/deposit.rs | 3 ++- .../managed-fund/src/instructions/withdraw.rs | 6 +++++- .../src/instructions/swap_usdc_for_asset.rs | 3 ++- .../order-book/src/instructions/place_order.rs | 3 +-- .../src/instructions/create_collection.rs | 7 +++++-- .../mint-nft/src/instructions/mint_nft.rs | 7 +++++-- 8 files changed, 35 insertions(+), 17 deletions(-) diff --git a/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs b/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs index d04d62039..68c9157eb 100644 --- a/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs +++ b/finance/betting-market/anchor/programs/betting-market/src/instructions/shared.rs @@ -76,8 +76,11 @@ pub fn transfer_tokens_from_vault( to: to.cpi_handle_mut(), authority: CpiHandle::readonly(&event.view), }; - let cpi_context = - CpiContext::<_, 4>::new_with_signer(token_program.address(), transfer_accounts, &signer_seeds); + let cpi_context = CpiContext::<_, 4>::new_with_signer( + token_program.address(), + transfer_accounts, + &signer_seeds, + ); transfer_checked(cpi_context, amount, decimals) } diff --git a/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs b/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs index 523231bf7..2f54099e2 100644 --- a/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs +++ b/finance/escrow/anchor/programs/escrow/src/instructions/shared.rs @@ -27,9 +27,11 @@ pub fn transfer_tokens( let signer_seeds = owning_pda_seeds.map(|seeds| [seeds]); let cpi_context = match signer_seeds.as_ref() { - Some(signer_seeds) => { - CpiContext::<_, 4>::new_with_signer(token_program.address(), transfer_accounts, signer_seeds) - } + Some(signer_seeds) => CpiContext::<_, 4>::new_with_signer( + token_program.address(), + transfer_accounts, + signer_seeds, + ), None => CpiContext::<_, 4>::new(token_program.address(), transfer_accounts), }; @@ -54,9 +56,11 @@ pub fn close_token_account( let signer_seeds = owning_pda_seeds.map(|seeds| [seeds]); let cpi_context = match signer_seeds.as_ref() { - Some(signer_seeds) => { - CpiContext::<_, 3>::new_with_signer(token_program.address(), close_accounts, signer_seeds) - } + Some(signer_seeds) => CpiContext::<_, 3>::new_with_signer( + token_program.address(), + close_accounts, + signer_seeds, + ), None => CpiContext::<_, 3>::new(token_program.address(), close_accounts), }; diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs index c0a417d91..9fba19b7b 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/deposit.rs @@ -185,7 +185,8 @@ pub fn handle_deposit( to: context.accounts.vault_usdc.to_cpi_handle_mut(), authority: context.accounts.depositor.cpi_handle(), }; - let cpi_ctx = CpiContext::<_, 4>::new(context.accounts.token_program.address(), transfer_accounts); + let cpi_ctx = + CpiContext::<_, 4>::new(context.accounts.token_program.address(), transfer_accounts); transfer_checked(cpi_ctx, usdc_amount, usdc_decimals)?; let index_bytes = fund_index.to_le_bytes(); diff --git a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs index c4406d93c..caf3229d9 100644 --- a/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs +++ b/finance/managed-fund/anchor/programs/managed-fund/src/instructions/withdraw.rs @@ -203,7 +203,11 @@ pub fn handle_withdraw( authority: CpiHandle::readonly(&fund_view), }; transfer_checked( - CpiContext::<_, 4>::new_with_signer(token_program_key, transfer_accounts, signer_seeds), + CpiContext::<_, 4>::new_with_signer( + token_program_key, + transfer_accounts, + signer_seeds, + ), amount, decimals, )?; diff --git a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs index cd0422782..3829f199a 100644 --- a/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs +++ b/finance/managed-fund/anchor/programs/mock-swap-router/src/instructions/swap_usdc_for_asset.rs @@ -97,7 +97,8 @@ pub fn handle_swap_usdc_for_asset( to: context.accounts.router_usdc_treasury.to_cpi_handle_mut(), authority: context.accounts.caller.cpi_handle(), }; - let cpi_ctx = CpiContext::<_, 4>::new(context.accounts.token_program.address(), transfer_accounts); + let cpi_ctx = + CpiContext::<_, 4>::new(context.accounts.token_program.address(), transfer_accounts); transfer_checked( cpi_ctx, usdc_amount_in, diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs index 84f8ea6e1..945c07111 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs @@ -465,8 +465,7 @@ pub fn handle_place_order( let evicted_user_info = maker_accounts .get(evicted_index + 1) .ok_or(ErrorCode::MissingEvictedAccounts)?; - let mut evicted_market_user = - BorshAccount::::load_mut(*evicted_user_info)?; + let mut evicted_market_user = BorshAccount::::load_mut(*evicted_user_info)?; require!( evicted_market_user.owner == evicted_order.owner && evicted_market_user.market == *market.address(), diff --git a/nft/operations/anchor/programs/mint-nft/src/instructions/create_collection.rs b/nft/operations/anchor/programs/mint-nft/src/instructions/create_collection.rs index 21603d69b..0cb785052 100644 --- a/nft/operations/anchor/programs/mint-nft/src/instructions/create_collection.rs +++ b/nft/operations/anchor/programs/mint-nft/src/instructions/create_collection.rs @@ -81,8 +81,11 @@ pub fn handle_create_collection( to: accounts.destination.cpi_handle_mut(), authority: accounts.mint_authority.cpi_handle(), }; - let cpi_ctx = - CpiContext::<_, 3>::new_with_signer(accounts.token_program.address(), cpi_accounts, signer_seeds); + let cpi_ctx = CpiContext::<_, 3>::new_with_signer( + accounts.token_program.address(), + cpi_accounts, + signer_seeds, + ); mint_to(cpi_ctx, 1)?; msg!("Collection NFT minted!"); diff --git a/nft/operations/anchor/programs/mint-nft/src/instructions/mint_nft.rs b/nft/operations/anchor/programs/mint-nft/src/instructions/mint_nft.rs index b7b9bac39..41d907382 100644 --- a/nft/operations/anchor/programs/mint-nft/src/instructions/mint_nft.rs +++ b/nft/operations/anchor/programs/mint-nft/src/instructions/mint_nft.rs @@ -85,8 +85,11 @@ pub fn handle_mint_nft( to: accounts.destination.cpi_handle_mut(), authority: accounts.mint_authority.cpi_handle(), }; - let cpi_ctx = - CpiContext::<_, 3>::new_with_signer(accounts.token_program.address(), cpi_accounts, signer_seeds); + let cpi_ctx = CpiContext::<_, 3>::new_with_signer( + accounts.token_program.address(), + cpi_accounts, + signer_seeds, + ); mint_to(cpi_ctx, 1)?; msg!("NFT minted!"); From d73f550cc9d7643f1aa8e9b92804ca61e90af730 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 17:14:35 +0000 Subject: [PATCH 7/9] Fix the rc.4 build and test failures CI found - compression: hand-built Bubblegum CPIs use a local OwnedInstruction that implements CpiInstruction; rc.4 no longer re-exports Instruction onchain. - cross-program-invocation: supply the FixedVec data buffer the generated switch_power CPI takes onchain, cap `name` at MAX_NAME_LEN with a NameTooLong error, and test both sides of the limit. - transfer-fee: harvest's CpiContext holds the mint plus MAX_HARVEST_SOURCES token accounts; more fail with TooManyHarvestSources, tested. - escrow, options: a mutable account in two slots now fails with AccountBorrowFailed rather than ConstraintDuplicateMutableAccount. - Remove comments and README notes about boxed accounts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB --- .../cross-program-invocation/anchor/README.md | 1 + .../anchor/programs/hand/src/lib.rs | 27 ++++++- .../anchor/programs/hand/tests/test_hand.rs | 77 +++++++++++++++++++ .../cnft-burn/src/instructions/burn_cnft.rs | 9 +-- .../anchor/programs/cnft-burn/src/lib.rs | 1 + .../cnft-burn/src/owned_instruction.rs | 39 ++++++++++ .../anchor/programs/cnft-vault/src/lib.rs | 8 +- .../cnft-vault/src/owned_instruction.rs | 39 ++++++++++ .../programs/cutils/src/instructions/mint.rs | 8 +- .../cutils/src/instructions/verify.rs | 5 +- .../cutils/anchor/programs/cutils/src/lib.rs | 1 + .../programs/cutils/src/owned_instruction.rs | 39 ++++++++++ .../escrow/src/instructions/make_offer.rs | 4 +- .../programs/escrow/tests/test_escrow.rs | 5 +- .../src/instructions/liquidate_obligation.rs | 7 -- .../options/src/instructions/buy_option.rs | 7 +- .../programs/options/tests/test_options.rs | 20 ++--- finance/order-book/anchor/README.md | 20 ++--- .../src/instructions/admin/withdraw_fees.rs | 1 - .../src/instructions/place_order.rs | 2 - .../src/instructions/settle_funds.rs | 2 - .../transfer-fee/anchor/README.md | 1 + .../transfer-fee/src/instructions/harvest.rs | 13 +++- .../anchor/programs/transfer-fee/src/lib.rs | 11 +++ .../transfer-fee/tests/test_transfer_fee.rs | 30 ++++++++ .../src/instructions/transfer_hook.rs | 5 -- 26 files changed, 316 insertions(+), 66 deletions(-) create mode 100644 compression/cnft-burn/anchor/programs/cnft-burn/src/owned_instruction.rs create mode 100644 compression/cnft-vault/anchor/programs/cnft-vault/src/owned_instruction.rs create mode 100644 compression/cutils/anchor/programs/cutils/src/owned_instruction.rs diff --git a/basics/cross-program-invocation/anchor/README.md b/basics/cross-program-invocation/anchor/README.md index e3f4ddc7e..1489f1faf 100644 --- a/basics/cross-program-invocation/anchor/README.md +++ b/basics/cross-program-invocation/anchor/README.md @@ -14,6 +14,7 @@ See also: [Cross Program Invocation overview](../README.md) and the [repository - Cross-program invocation (CPI) - Composing multiple programs in one transaction +- `declare_program!` CPI functions write the instruction data into a fixed-capacity buffer the caller supplies onchain. `pull_lever` sizes its buffer for a name of up to `MAX_NAME_LEN` (32) bytes and refuses a longer one with `NameTooLong`. ## Setup diff --git a/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs b/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs index 06e67989c..783091ee5 100644 --- a/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs +++ b/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs @@ -9,6 +9,15 @@ use lever::cpi::accounts::SwitchPower; use lever::cpi::switch_power; use lever::program::Lever; +/// The longest `name` `pull_lever` passes on to the lever program, in bytes. +pub const MAX_NAME_LEN: usize = 32; + +/// Room for `switch_power`'s instruction data: an 8-byte discriminator, the +/// name's 4-byte length prefix and the name itself. Anchor v2 serializes CPI +/// instruction data into a fixed-capacity buffer the caller supplies. +#[cfg(any(target_os = "solana", target_arch = "bpf"))] +const SWITCH_POWER_DATA_CAPACITY: usize = 8 + 4 + MAX_NAME_LEN; + #[program] pub mod hand { use super::*; @@ -17,13 +26,23 @@ pub mod hand { context: &mut Context, name: String, ) -> Result<()> { + require!(name.len() <= MAX_NAME_LEN, HandError::NameTooLong); let cpi_ctx = CpiContext::<_, 1>::new( context.accounts.lever_program.address(), SwitchPower { power: context.accounts.power.cpi_handle_mut(), }, ); - switch_power(cpi_ctx, name)?; + // Onchain, the generated CPI function writes the instruction data into + // a buffer this handler supplies; the host build used for the IDL and + // clippy has no buffer argument. + #[cfg(any(target_os = "solana", target_arch = "bpf"))] + { + let mut data = anchor_lang::FixedVec::::new(); + switch_power(cpi_ctx, &name, &mut data)?; + } + #[cfg(not(any(target_os = "solana", target_arch = "bpf")))] + switch_power(cpi_ctx, &name)?; Ok(()) } } @@ -34,3 +53,9 @@ pub struct PullLeverAccountConstraints { pub power: BorshAccount, pub lever_program: Program, } + +#[error_code] +pub enum HandError { + #[msg("The name is longer than MAX_NAME_LEN bytes")] + NameTooLong, +} diff --git a/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs b/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs index 39c87a1b2..68b559f5c 100644 --- a/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs +++ b/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs @@ -124,3 +124,80 @@ fn test_pull_lever_cpi() { "Power should be off after pulling lever again" ); } + +/// A name of exactly `MAX_NAME_LEN` bytes reaches the lever program; one byte +/// more is refused by `hand` with `NameTooLong` before the CPI, and the power +/// switch is left where it was. +#[test] +fn test_pull_lever_name_length_limit() { + let hand_program_id = hand::id(); + let lever_program_id = hand::lever::ID; + + let mut svm = anchor_v2_testing::svm(); + let hand_bytes = include_bytes!("../../../target/deploy/hand.so"); + let lever_bytes = std::fs::read(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../target/deploy/lever.so" + )) + .expect("lever.so not found - run `anchor build` first"); + svm.add_program(hand_program_id, hand_bytes).unwrap(); + svm.add_program(lever_program_id, &lever_bytes).unwrap(); + let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); + + let power_keypair = Keypair::new(); + let init_ix = + build_lever_initialize_ix(lever_program_id, power_keypair.pubkey(), payer.pubkey()); + send_transaction_from_instructions( + &mut svm, + vec![init_ix], + &[&payer, &power_keypair], + &payer.pubkey(), + None, + ) + .unwrap(); + + let pull_ix = |name: String| { + Instruction::new_with_bytes( + hand_program_id, + &hand::instruction::PullLever { name }.data(), + hand::accounts::PullLeverAccountConstraints { + power: power_keypair.pubkey(), + lever_program: lever_program_id, + } + .to_account_metas(None), + ) + }; + + svm.expire_blockhash(); + send_transaction_from_instructions( + &mut svm, + vec![pull_ix("a".repeat(hand::MAX_NAME_LEN))], + &[&payer], + &payer.pubkey(), + None, + ) + .unwrap(); + assert!( + read_power_is_on(&svm, &power_keypair.pubkey()), + "a name of MAX_NAME_LEN bytes should switch the power on" + ); + + svm.expire_blockhash(); + let error = send_transaction_from_instructions( + &mut svm, + vec![pull_ix("a".repeat(hand::MAX_NAME_LEN + 1))], + &[&payer], + &payer.pubkey(), + None, + ) + .expect_err("a name longer than MAX_NAME_LEN should be refused"); + let expected = anchor_lang::Error::from(hand::HandError::NameTooLong); + assert!( + format!("{error:?}").contains(&format!("{expected:?}")), + "expected {expected:?}, got: {error:?}" + ); + assert!( + read_power_is_on(&svm, &power_keypair.pubkey()), + "a refused pull should leave the power on" + ); +} diff --git a/compression/cnft-burn/anchor/programs/cnft-burn/src/instructions/burn_cnft.rs b/compression/cnft-burn/anchor/programs/cnft-burn/src/instructions/burn_cnft.rs index 1764b5307..87f3bb473 100644 --- a/compression/cnft-burn/anchor/programs/cnft-burn/src/instructions/burn_cnft.rs +++ b/compression/cnft-burn/anchor/programs/cnft-burn/src/instructions/burn_cnft.rs @@ -1,11 +1,8 @@ use anchor_lang::prelude::*; -use anchor_lang::solana_program::{ - instruction::{AccountMeta, Instruction}, - program::invoke, -}; +use anchor_lang::solana_program::{instruction::AccountMeta, program::invoke}; use borsh::BorshSerialize; -use crate::{SPLCompression, MPL_BUBBLEGUM_ID}; +use crate::{owned_instruction::OwnedInstruction, SPLCompression, MPL_BUBBLEGUM_ID}; /// Burn instruction discriminator from mpl-bubblegum const BURN_DISCRIMINATOR: [u8; 8] = [116, 110, 29, 56, 107, 219, 42, 93]; @@ -109,7 +106,7 @@ pub fn handle_burn_cnft( accounts.push(AccountMeta::new_readonly(*acc.address(), false)); } - let instruction = Instruction { + let instruction = OwnedInstruction { program_id: MPL_BUBBLEGUM_ID, accounts, data, diff --git a/compression/cnft-burn/anchor/programs/cnft-burn/src/lib.rs b/compression/cnft-burn/anchor/programs/cnft-burn/src/lib.rs index 529f0673e..7b25beb1e 100644 --- a/compression/cnft-burn/anchor/programs/cnft-burn/src/lib.rs +++ b/compression/cnft-burn/anchor/programs/cnft-burn/src/lib.rs @@ -6,6 +6,7 @@ use anchor_lang::prelude::*; pub mod instructions; +pub mod owned_instruction; use instructions::*; declare_id!("C6qxH8n6mZxrrbtMtYWYSp8JR8vkQ55X1o4EBg7twnMv"); diff --git a/compression/cnft-burn/anchor/programs/cnft-burn/src/owned_instruction.rs b/compression/cnft-burn/anchor/programs/cnft-burn/src/owned_instruction.rs new file mode 100644 index 000000000..0b3a53883 --- /dev/null +++ b/compression/cnft-burn/anchor/programs/cnft-burn/src/owned_instruction.rs @@ -0,0 +1,39 @@ +use anchor_lang::{ + cpi::InstructionAccount, prelude::Address, solana_program::instruction::AccountMeta, + CpiInstruction, +}; + +/// An instruction for a program this crate has no CPI client for, with its +/// account metas and data held in `Vec`s. +/// +/// Anchor v2's `invoke` and `invoke_signed` take any `CpiInstruction`. Onchain, +/// Anchor provides that only for pinocchio's borrowed `InstructionView`, so +/// this type builds the `InstructionAccount` list the CPI needs from its own +/// metas when it is invoked. +pub struct OwnedInstruction { + pub program_id: Address, + pub accounts: Vec, + pub data: Vec, +} + +impl CpiInstruction for OwnedInstruction { + fn program_id(&self) -> &Address { + &self.program_id + } + + fn data(&self) -> &[u8] { + &self.data + } + + fn with_instruction_accounts( + &self, + visit: impl FnOnce(&[InstructionAccount<'_>]) -> R, + ) -> R { + let instruction_accounts: Vec> = self + .accounts + .iter() + .map(|meta| InstructionAccount::new(&meta.pubkey, meta.is_writable, meta.is_signer)) + .collect(); + visit(&instruction_accounts) + } +} diff --git a/compression/cnft-vault/anchor/programs/cnft-vault/src/lib.rs b/compression/cnft-vault/anchor/programs/cnft-vault/src/lib.rs index 0763d752c..d223bad95 100644 --- a/compression/cnft-vault/anchor/programs/cnft-vault/src/lib.rs +++ b/compression/cnft-vault/anchor/programs/cnft-vault/src/lib.rs @@ -1,11 +1,13 @@ #![allow(clippy::diverging_sub_expression)] use anchor_lang::prelude::*; -use anchor_lang::solana_program::instruction::{AccountMeta, Instruction}; +use anchor_lang::solana_program::instruction::AccountMeta; use borsh::BorshSerialize; +use owned_instruction::OwnedInstruction; pub mod error; mod instructions; +pub mod owned_instruction; pub mod state; use instructions::*; @@ -59,7 +61,7 @@ pub fn build_transfer_instruction( system_program: Address, remaining_accounts: &[AccountMeta], args: TransferArgs, -) -> Result { +) -> Result { let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(AccountMeta::new_readonly(tree_config, false)); // leaf_owner is a signer (PDA signs via invoke_signed) @@ -77,7 +79,7 @@ pub fn build_transfer_instruction( args.serialize(&mut data) .map_err(|_| ProgramError::InvalidInstructionData)?; - Ok(Instruction { + Ok(OwnedInstruction { program_id: MPL_BUBBLEGUM_ID, accounts, data, diff --git a/compression/cnft-vault/anchor/programs/cnft-vault/src/owned_instruction.rs b/compression/cnft-vault/anchor/programs/cnft-vault/src/owned_instruction.rs new file mode 100644 index 000000000..0b3a53883 --- /dev/null +++ b/compression/cnft-vault/anchor/programs/cnft-vault/src/owned_instruction.rs @@ -0,0 +1,39 @@ +use anchor_lang::{ + cpi::InstructionAccount, prelude::Address, solana_program::instruction::AccountMeta, + CpiInstruction, +}; + +/// An instruction for a program this crate has no CPI client for, with its +/// account metas and data held in `Vec`s. +/// +/// Anchor v2's `invoke` and `invoke_signed` take any `CpiInstruction`. Onchain, +/// Anchor provides that only for pinocchio's borrowed `InstructionView`, so +/// this type builds the `InstructionAccount` list the CPI needs from its own +/// metas when it is invoked. +pub struct OwnedInstruction { + pub program_id: Address, + pub accounts: Vec, + pub data: Vec, +} + +impl CpiInstruction for OwnedInstruction { + fn program_id(&self) -> &Address { + &self.program_id + } + + fn data(&self) -> &[u8] { + &self.data + } + + fn with_instruction_accounts( + &self, + visit: impl FnOnce(&[InstructionAccount<'_>]) -> R, + ) -> R { + let instruction_accounts: Vec> = self + .accounts + .iter() + .map(|meta| InstructionAccount::new(&meta.pubkey, meta.is_writable, meta.is_signer)) + .collect(); + visit(&instruction_accounts) + } +} diff --git a/compression/cutils/anchor/programs/cutils/src/instructions/mint.rs b/compression/cutils/anchor/programs/cutils/src/instructions/mint.rs index b2d404b00..70b22c995 100644 --- a/compression/cutils/anchor/programs/cutils/src/instructions/mint.rs +++ b/compression/cutils/anchor/programs/cutils/src/instructions/mint.rs @@ -2,11 +2,9 @@ use crate::bubblegum_types::{ Collection, Creator, MetadataArgs, MintToCollectionV1InstructionArgs, TokenProgramVersion, TokenStandard, MINT_TO_COLLECTION_V1_DISCRIMINATOR, }; +use crate::owned_instruction::OwnedInstruction; use crate::*; -use anchor_lang::solana_program::{ - instruction::{AccountMeta, Instruction}, - program::invoke, -}; +use anchor_lang::solana_program::{instruction::AccountMeta, program::invoke}; use borsh::BorshSerialize; #[derive(Accounts)] @@ -175,7 +173,7 @@ pub fn handle_mint( false, )); - let instruction = Instruction { + let instruction = OwnedInstruction { program_id: MPL_BUBBLEGUM_ID, accounts, data, diff --git a/compression/cutils/anchor/programs/cutils/src/instructions/verify.rs b/compression/cutils/anchor/programs/cutils/src/instructions/verify.rs index 8efcb1d86..d9bb7bf82 100644 --- a/compression/cutils/anchor/programs/cutils/src/instructions/verify.rs +++ b/compression/cutils/anchor/programs/cutils/src/instructions/verify.rs @@ -1,6 +1,7 @@ use crate::bubblegum_types::{get_asset_id, leaf_schema_v1_hash}; +use crate::owned_instruction::OwnedInstruction; use crate::*; -use anchor_lang::solana_program::instruction::{AccountMeta, Instruction}; +use anchor_lang::solana_program::instruction::AccountMeta; #[derive(Accounts)] #[instruction(_params: VerifyParams)] @@ -74,7 +75,7 @@ pub fn handle_verify( } anchor_lang::solana_program::program::invoke( - &Instruction { + &OwnedInstruction { program_id: *context.accounts.compression_program.address(), accounts, data, diff --git a/compression/cutils/anchor/programs/cutils/src/lib.rs b/compression/cutils/anchor/programs/cutils/src/lib.rs index 2ae22c66a..03bfa469e 100644 --- a/compression/cutils/anchor/programs/cutils/src/lib.rs +++ b/compression/cutils/anchor/programs/cutils/src/lib.rs @@ -3,6 +3,7 @@ #![allow(clippy::diverging_sub_expression)] pub mod instructions; +pub mod owned_instruction; pub use instructions::*; pub mod bubblegum_types; diff --git a/compression/cutils/anchor/programs/cutils/src/owned_instruction.rs b/compression/cutils/anchor/programs/cutils/src/owned_instruction.rs new file mode 100644 index 000000000..0b3a53883 --- /dev/null +++ b/compression/cutils/anchor/programs/cutils/src/owned_instruction.rs @@ -0,0 +1,39 @@ +use anchor_lang::{ + cpi::InstructionAccount, prelude::Address, solana_program::instruction::AccountMeta, + CpiInstruction, +}; + +/// An instruction for a program this crate has no CPI client for, with its +/// account metas and data held in `Vec`s. +/// +/// Anchor v2's `invoke` and `invoke_signed` take any `CpiInstruction`. Onchain, +/// Anchor provides that only for pinocchio's borrowed `InstructionView`, so +/// this type builds the `InstructionAccount` list the CPI needs from its own +/// metas when it is invoked. +pub struct OwnedInstruction { + pub program_id: Address, + pub accounts: Vec, + pub data: Vec, +} + +impl CpiInstruction for OwnedInstruction { + fn program_id(&self) -> &Address { + &self.program_id + } + + fn data(&self) -> &[u8] { + &self.data + } + + fn with_instruction_accounts( + &self, + visit: impl FnOnce(&[InstructionAccount<'_>]) -> R, + ) -> R { + let instruction_accounts: Vec> = self + .accounts + .iter() + .map(|meta| InstructionAccount::new(&meta.pubkey, meta.is_writable, meta.is_signer)) + .collect(); + visit(&instruction_accounts) + } +} diff --git a/finance/escrow/anchor/programs/escrow/src/instructions/make_offer.rs b/finance/escrow/anchor/programs/escrow/src/instructions/make_offer.rs index 3c816d874..cfa90da8a 100644 --- a/finance/escrow/anchor/programs/escrow/src/instructions/make_offer.rs +++ b/finance/escrow/anchor/programs/escrow/src/instructions/make_offer.rs @@ -71,8 +71,8 @@ pub struct MakeOfferAccountConstraints { // Refuse an offer with nothing on one side. An offer of a token for a // different amount of itself never reaches this handler: the maker's token-A -// and token-B accounts would be the same account, and Anchor refuses the same -// mutable account twice with `ConstraintDuplicateMutableAccount`. +// and token-B accounts would be the same account, and loading one mutable +// account into two slots fails with `AccountBorrowFailed`. pub fn handle_validate_offer( token_a_offered_amount: u64, token_b_wanted_amount: u64, diff --git a/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs b/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs index b8e8eb4fc..b6998ae8c 100644 --- a/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs +++ b/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs @@ -646,8 +646,9 @@ fn test_make_offer_rejects_same_mint() { alice_ata_a, ); - // Anchor refuses the same mutable account twice before the handler runs. - assert_fails_with_anchor_error(result, ErrorCode::ConstraintDuplicateMutableAccount); + // Loading the same mutable account into two slots takes a second + // exclusive borrow of its data, which fails before the handler runs. + assert_fails_with_program_error(result, &anchor_lang::Error::AccountBorrowFailed); assert_eq!( get_token_account_balance(&es.svm, &alice_ata_a).unwrap(), alice_balance_before diff --git a/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs b/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs index f22e61d2a..b2a7816bd 100644 --- a/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs +++ b/finance/lending/anchor/programs/lending/src/instructions/liquidate_obligation.rs @@ -166,11 +166,6 @@ pub fn handle_liquidate_obligation( }; // Interactions: liquidator repays, then receives the seized share tokens. - // - // These accounts are `Box`ed, and `Box`'s `AnchorAccount` impl does not - // override `cpi_handle_mut`, so that call would build a handle without - // releasing the wrapper's data borrow and the CPI would be rejected with - // `AccountBorrowFailed`. `to_cpi_handle_mut` forwards to the inner type. transfer_checked( CpiContext::<_, 4>::new( context.accounts.token_program.address(), @@ -241,8 +236,6 @@ pub fn handle_liquidate_obligation( Ok(()) } -// Liquidation touches 13 accounts; every Account/InterfaceAccount is boxed so -// account deserialization happens on the heap and stays within the BPF stack frame. #[derive(Accounts)] pub struct LiquidateObligation { #[account(mut)] diff --git a/finance/options/anchor/programs/options/src/instructions/buy_option.rs b/finance/options/anchor/programs/options/src/instructions/buy_option.rs index 499039d9f..be9486b6a 100644 --- a/finance/options/anchor/programs/options/src/instructions/buy_option.rs +++ b/finance/options/anchor/programs/options/src/instructions/buy_option.rs @@ -132,9 +132,10 @@ pub struct BuyOptionAccountConstraints { // Created by `write_option`, at the writer's expense, so the buyer never // pays rent on the writer's behalf. A writer buying their own option would // put this account and `buyer_quote`, both the same associated token - // account, in two mutable slots at once; Anchor refuses that with - // `ConstraintDuplicateMutableAccount` before any constraint or handler - // code runs, so a writer cannot pay themselves a premium. + // account, in two mutable slots at once. The second slot's exclusive + // borrow of the account's data fails with `AccountBorrowFailed` while + // the accounts load, before any handler code runs, so a writer cannot pay + // themselves a premium. #[account( mut, associated_token::mint = quote_mint, diff --git a/finance/options/anchor/programs/options/tests/test_options.rs b/finance/options/anchor/programs/options/tests/test_options.rs index 1f5027e40..2581e42ce 100644 --- a/finance/options/anchor/programs/options/tests/test_options.rs +++ b/finance/options/anchor/programs/options/tests/test_options.rs @@ -97,9 +97,8 @@ fn assert_fails_with(result: Result, expected: OptionsError) { assert_fails_with_code(result, code); } -/// Anchor's own constraint errors (an `address =` mismatch, a duplicate -/// mutable account) are numbered below the program's and reported the same -/// way. +/// Anchor's own constraint errors, such as an `address =` mismatch, are +/// numbered below the program's and reported the same way. fn assert_fails_with_anchor_error(result: Result, expected: AnchorErrorCode) { let AnchorError::Custom(code) = AnchorError::from(expected) else { panic!("a constraint error converts to a custom code"); @@ -1298,18 +1297,21 @@ fn test_buy_option_succeeds_when_the_terms_match() { /// A writer cannot buy their own option. `buyer_quote` and `writer_quote` /// are each bound to their party's associated token account, so with Alice -/// on both sides they are one account in two mutable slots, and Anchor's -/// duplicate-mutable-account check refuses the instruction before any -/// handler code runs. The option stays listed and no USDC moves. +/// on both sides they are one account in two mutable slots. Loading the +/// second slot takes a second exclusive borrow of the account's data, which +/// fails with `AccountBorrowFailed` before any handler code runs. The option stays listed and no USDC moves. #[test] fn test_writer_cannot_buy_their_own_option() { let mut venue = Venue::new(); let alice = venue.person(FIVE_NVDAX, STANDARD_USDC); let option = venue.write_call(&alice); - assert_fails_with_anchor_error( - venue.buy_option(&alice, &alice.pubkey(), &option), - AnchorErrorCode::ConstraintDuplicateMutableAccount, + let error = venue + .buy_option(&alice, &alice.pubkey(), &option) + .expect_err("a writer buying their own option should fail"); + assert!( + error.contains("AccountBorrowFailed"), + "expected AccountBorrowFailed, got: {error}" ); assert_eq!(venue.option_state(&option).status, OptionStatus::Listed); assert_eq!(venue.balance(&alice.quote), STANDARD_USDC); diff --git a/finance/order-book/anchor/README.md b/finance/order-book/anchor/README.md index 29b89b1eb..e9a7f049c 100644 --- a/finance/order-book/anchor/README.md +++ b/finance/order-book/anchor/README.md @@ -624,7 +624,7 @@ pub fn place_order( - `order` (PDA, **init**, seeds `["order", market, next_order_id.to_le_bytes()]`) - `market_user` (mut, PDA seeds-checked) -- `base_vault`, `quote_vault`, `fee_vault` (all mut, boxed) +- `base_vault`, `quote_vault`, `fee_vault` (all mut) - `user_base_account`, `user_quote_account` (mut - the caller's ATAs) - `base_mint`, `quote_mint` (read-only) - `owner` (signer, mut) @@ -831,10 +831,10 @@ zero, so it is safe to call on a heartbeat/cron. - `market` (mut) - `market_user` (mut) -- `base_vault`, `quote_vault` (mut, boxed) -- `user_base_account`, `user_quote_account` (mut, boxed - caller's +- `base_vault`, `quote_vault` (mut) +- `user_base_account`, `user_quote_account` (mut - caller's ATAs; caller must create them before calling) -- `base_mint`, `quote_mint` (boxed, read-only) +- `base_mint`, `quote_mint` (read-only) - `owner` (signer) - `token_program` @@ -873,9 +873,9 @@ runtime rejects a call into a program already on the call stack with **Accounts in:** - `market` (mut, with `fee_vault` bound by `address = market.fee_vault`) -- `fee_vault` (mut, boxed) -- `authority_quote_account` (mut, boxed - destination) -- `quote_mint` (boxed) +- `fee_vault` (mut) +- `authority_quote_account` (mut - destination) +- `quote_mint` - `authority` (signer) - `token_program` @@ -1515,12 +1515,6 @@ From [`errors.rs`](programs/order-book/src/errors.rs): Cancels, settlements and fee withdrawals never check the flag, so nobody's tokens are locked in a paused market. -- **Boxed InterfaceAccounts.** Several handlers use `Box< - InterfaceAccount<...>>` for mint/token accounts. That's a BPF - stack-size workaround - each `InterfaceAccount` is ~1 KB on the - stack and the Solana VM gives handlers a tight budget. Don't - unbox these without testing the compute output size. - - **Discriminator + `address`.** Every state account carries an 8- byte discriminator that Anchor checks, and `fee_vault` carries `address = market.fee_vault`, so the `place_order` handler can trust diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs b/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs index 4d8e2a253..32ad2d0fa 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/admin/withdraw_fees.rs @@ -67,7 +67,6 @@ pub struct WithdrawFeesAccountConstraints { #[account(mut)] pub market: BorshAccount, - // Boxed to keep the struct under the BPF stack limit (see PlaceOrderAccountConstraints). #[account(mut, address = market.fee_vault @ ErrorCode::InvalidFeeVault)] pub fee_vault: InterfaceAccount, diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs index 945c07111..c307b36a8 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/place_order.rs @@ -588,8 +588,6 @@ pub struct PlaceOrderAccountConstraints { )] pub market_user: BorshAccount, - // InterfaceAccount on the stack is ~1 KB each; with 7 of them this struct - // blows the 4 KB stack-offset limit on BPF. Boxing moves each to the heap. #[account(mut, address = market.base_vault @ ErrorCode::InvalidBaseVault)] pub base_vault: InterfaceAccount, diff --git a/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs b/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs index 1dfc8c9c2..80fa323ae 100644 --- a/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs +++ b/finance/order-book/anchor/programs/order-book/src/instructions/settle_funds.rs @@ -98,8 +98,6 @@ pub struct SettleFundsAccountConstraints { )] pub market_user: BorshAccount, - // Boxed for the same reason as in PlaceOrderAccountConstraints - - // InterfaceAccount is too large to keep on the BPF stack in bulk. #[account(mut, address = market.base_vault @ ErrorCode::InvalidBaseVault)] pub base_vault: InterfaceAccount, diff --git a/tokens/token-extensions/transfer-fee/anchor/README.md b/tokens/token-extensions/transfer-fee/anchor/README.md index a8449981d..fe5b57130 100644 --- a/tokens/token-extensions/transfer-fee/anchor/README.md +++ b/tokens/token-extensions/transfer-fee/anchor/README.md @@ -14,6 +14,7 @@ See also: the [repository catalog](../../../../README.md). - Transfer fee extension - Fee withheld on transfer +- `harvest` moves withheld fees from up to `MAX_HARVEST_SOURCES` (16) token accounts, passed as remaining accounts, into the mint. Anchor v2 builds each CPI's account list in a fixed-capacity buffer, and `harvest` sizes its `CpiContext` for the mint plus that many token accounts; more fail with `TooManyHarvestSources`. ## Setup diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs index bdc903e33..38e55c6d0 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/instructions/harvest.rs @@ -1,7 +1,10 @@ -use anchor_lang::prelude::*; use anchor_spl::token_interface::{ harvest_withheld_tokens_to_mint, HarvestWithheldTokensToMint, Mint, Token2022, TokenAccount, }; +use { + crate::{TransferFeeError, MAX_HARVEST_SOURCES}, + anchor_lang::prelude::*, +}; #[derive(Accounts)] pub struct HarvestAccountConstraints { @@ -13,12 +16,16 @@ pub struct HarvestAccountConstraints { // transfer fees are stored directly on the recipient token account and must be "harvested" // "harvesting" transfers fees accumulated on token accounts to the mint account pub fn process_harvest(context: &mut Context) -> Result<()> { - // Using remaining accounts to allow for passing in an unknown number of token accounts to harvest from + // Remaining accounts carry the token accounts to harvest from, up to MAX_HARVEST_SOURCES of them // Check that remaining accounts are token accounts for the mint to harvest to // `remaining_accounts()` returns a shared slice, and `CpiHandleMut::writable` // needs `&mut AccountView`, so copy the views into a vec the handles can // borrow mutably. An `AccountView` copy still points at the same account. let mut candidates = context.remaining_accounts().to_vec(); + require!( + candidates.len() <= MAX_HARVEST_SOURCES, + TransferFeeError::TooManyHarvestSources + ); let mint_address = *context.accounts.mint_account.address(); // v2 has no `InterfaceAccount::try_from`; `AnchorAccount::load` is the @@ -42,7 +49,7 @@ pub fn process_harvest(context: &mut Context) -> Resu .collect(); harvest_withheld_tokens_to_mint( - CpiContext::<_, 1>::new( + CpiContext::<_, { 1 + MAX_HARVEST_SOURCES }>::new( context.accounts.token_program.address(), HarvestWithheldTokensToMint { mint: context.accounts.mint_account.cpi_handle_mut(), diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/lib.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/lib.rs index 628b32ff6..6449d2f7a 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/lib.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/src/lib.rs @@ -5,6 +5,17 @@ use instructions::*; declare_id!("4evptdGtALCNT8uTxJhbWBRZpBE8w5oNtmgfSyfQu7td"); +/// The most token accounts one `harvest` instruction takes fees from. Anchor +/// v2 builds each CPI's account list in a fixed-capacity buffer, sized by the +/// `CpiContext` in `harvest` to the mint plus this many token accounts. +pub const MAX_HARVEST_SOURCES: usize = 16; + +#[error_code] +pub enum TransferFeeError { + #[msg("A harvest passed more than MAX_HARVEST_SOURCES token accounts")] + TooManyHarvestSources, +} + #[program] pub mod transfer_fee { use super::*; diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs index 8f4fd2a19..eebc0e632 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs @@ -141,6 +141,36 @@ fn test_transfer_fee_full_flow() { .unwrap(); svm.expire_blockhash(); + // A harvest naming more than MAX_HARVEST_SOURCES token accounts is refused + // before any account is loaded. The recipient's account repeated is enough + // to reach the limit. + let too_many_harvest_ix = + Instruction::new_with_bytes(program_id, &transfer_fee::instruction::Harvest {}.data(), { + let mut metas = transfer_fee::accounts::HarvestAccountConstraints { + mint_account: mint_keypair.pubkey(), + token_program: TOKEN_EXTENSIONS_PROGRAM_ID, + } + .to_account_metas(None); + for _ in 0..=transfer_fee::MAX_HARVEST_SOURCES { + metas.push(AccountMeta::new(recipient_ata, false)); + } + metas + }); + let error = send_transaction_from_instructions( + &mut svm, + vec![too_many_harvest_ix], + &[&payer], + &payer.pubkey(), + None, + ) + .expect_err("a harvest over MAX_HARVEST_SOURCES should be refused"); + let expected = anchor_lang::Error::from(transfer_fee::TransferFeeError::TooManyHarvestSources); + assert!( + format!("{error:?}").contains(&format!("{expected:?}")), + "expected {expected:?}, got: {error:?}" + ); + svm.expire_blockhash(); + // Step 5: Harvest transfer fees from recipient token account to mint let harvest_ix = Instruction::new_with_bytes(program_id, &transfer_fee::instruction::Harvest {}.data(), { diff --git a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs index 27e10a503..b32689afb 100644 --- a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/src/instructions/transfer_hook.rs @@ -11,11 +11,6 @@ use crate::{check_is_transferring, CounterAccount}; // The first 4 accounts are the accounts required for token transfer (source, mint, destination, owner) // Remaining accounts are the extra accounts required from the ExtraAccountMetaList account // These accounts are provided via CPI to this program from the token2022 program -// -// InterfaceAccount used for source_token, destination_token, wsol_mint, -// delegate_wsol_token_account, and sender_wsol_token_account to avoid exceeding -// the 4096-byte BPF stack frame limit in try_accounts deserialization. -// This struct has 12 accounts - without Box, the generated code uses ~4160 bytes of stack. #[derive(Accounts)] pub struct TransferHookAccountConstraints { #[account(token::mint = mint, token::authority = owner)] From 16c2eeadb3ded8b779db4161acbc16aad11e5904 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 17:40:11 +0000 Subject: [PATCH 8/9] hand: host CPI takes the name by value; docs cover rc.4's API changes The declare_program! CPI function takes `String` on the host and `&str` onchain. CHANGELOG and docs/anchor-v2-migration.md describe unboxed accounts, CpiContext capacities, declare_program! data buffers, OwnedInstruction and the safe load_mut. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZHin7DpSfM4XDLwarivAB --- CHANGELOG.md | 35 ++++++++- .../anchor/programs/hand/src/lib.rs | 2 +- docs/anchor-v2-migration.md | 74 +++++++++++-------- 3 files changed, 75 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index deb9152ae..94a22e6c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Anchor 2.0.0-rc.3 replaced v2's duplicate mutable account check with the borrows each account wrapper takes on account data, removed the `unsafe(dup)` constraint, and made -`Context::remaining_accounts()` infallible. 2.0.0-rc.4, released the same day as this -entry, changes only the TypeScript client. +`Context::remaining_accounts()` infallible. 2.0.0-rc.4's changelog lists only TypeScript +client changes, but it also ships anchor#5185, which takes heap-allocated types out of +v2's public API: `Box` accounts are gone, CPI account lists and `declare_program!` +instruction data go in fixed-capacity buffers the caller sizes, and onchain CPIs take a +`CpiInstruction` rather than a `solana_instruction::Instruction`. anchor#4891 also drops +`Interface`'s lifetime parameter. ### Changed @@ -27,9 +31,32 @@ entry, changes only the TypeScript client. `lending`, `managed-fund`, `order-book` and `transfer-fee` drop the `?`. The method returns `&[AccountView]`; `transfer-fee`'s `harvest` copies it with `.to_vec()` to build `CpiHandleMut`s, which take `&mut AccountView`. +- The 245 `Box<...>` account fields across nine finance examples, `transfer-cost` and + `allow-block-list-token` are unboxed, and the comments and `order-book` README notes + that explained the boxing are removed. No Anchor v2 example exceeds the 4 KB stack + frame unboxed. The three `**context.accounts.x = ...` assignments become `*...`. +- The 81 `Interface<'static, TokenInterface>` fields are `Interface`. +- All 176 `CpiContext::new` and `CpiContext::new_with_signer` calls name their account + capacity, `CpiContext::<_, N>`, with `N` the number of accounts in the CPI's accounts + struct. +- `transfer-fee`'s `harvest` takes at most `MAX_HARVEST_SOURCES` (16) token accounts and + sizes its `CpiContext` for the mint plus that many; more fail with the new + `TooManyHarvestSources` error, which `test_transfer_fee_full_flow` checks. +- `cross-program-invocation`'s `hand` passes `switch_power` the `FixedVec` instruction-data + buffer the generated CPI function takes onchain, and refuses a `name` over + `MAX_NAME_LEN` (32) bytes with the new `NameTooLong` error. + `test_pull_lever_name_length_limit` tests a 32-byte and a 33-byte name. +- `cnft-burn`, `cnft-vault` and `cutils` build their Bubblegum and account-compression + CPIs as a local `OwnedInstruction`, which implements `CpiInstruction`. +- `order-book`'s `place_order` calls `BorshAccount::load_mut` without `unsafe`; the + method is safe in rc.4. +- `escrow`'s `test_make_offer_rejects_same_mint` and `options`' + `test_writer_cannot_buy_their_own_option` expect `AccountBorrowFailed`, the error a + mutable account in two slots now fails with. - `docs/anchor-v2-migration.md` replaces "Duplicate Mutable Accounts Are Rejected" with - "Duplicate Accounts Fail Through Borrows", and describes `remaining_accounts()` as - rc.4 has it. + "Duplicate Accounts Fail Through Borrows", and covers unboxed accounts, `CpiContext` + capacities, `declare_program!` data buffers, `OwnedInstruction` and the safe + `load_mut`. - `basics/transaction-v1/anchor/README.md` states that `@anchor-lang/core` 2.0.0-rc.4 needs `@solana/kit` 8.5 or later and builds v1 transaction messages by default. diff --git a/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs b/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs index 783091ee5..33a53040d 100644 --- a/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs +++ b/basics/cross-program-invocation/anchor/programs/hand/src/lib.rs @@ -42,7 +42,7 @@ pub mod hand { switch_power(cpi_ctx, &name, &mut data)?; } #[cfg(not(any(target_os = "solana", target_arch = "bpf")))] - switch_power(cpi_ctx, &name)?; + switch_power(cpi_ctx, name)?; Ok(()) } } diff --git a/docs/anchor-v2-migration.md b/docs/anchor-v2-migration.md index ecbfa3940..49371f200 100644 --- a/docs/anchor-v2-migration.md +++ b/docs/anchor-v2-migration.md @@ -33,9 +33,27 @@ macro expands to `wincode` paths for instruction-data (de)serialization. - `Context` becomes `&mut Context`, and the user `'info` lifetime is gone: `Context<'info, T<'info>>` is `Context`. -- `Signer<'info>` and `Program<'info, T>` are `Signer` and `Program`. - `Interface<'info, TokenInterface>` is the one wrapper that keeps a lifetime, - as `Interface<'static, TokenInterface>`. +- `Signer<'info>`, `Program<'info, T>` and `Interface<'info, TokenInterface>` + are `Signer`, `Program` and `Interface`. +- `Box>` is `Account`. v2 has no `AnchorAccount` impl for + `Box`. v1 boxed accounts to keep deserialized data off the 4 KB SBF stack + frame; v2's `Account` and `InterfaceAccount` are views into the input + buffer, and none of the examples here exceed the frame unboxed. A double + dereference written for a box, `**ctx.accounts.foo = X { .. }`, becomes + `*ctx.accounts.foo = X { .. }`. +- `CpiContext::new(program, accounts)` is `CpiContext::<_, N>::new(program, + accounts)`, where `N` is the number of accounts the CPI passes: the accounts + struct's fields plus any remaining accounts. The CPI builds its account list + in a buffer of that capacity, so `N` cannot be inferred, and a CPI with more + accounts than `N` fails with `InvalidArgument`. `harvest_withheld_tokens_to_mint` + adds its sources to the same buffer, so `transfer-fee`'s `harvest` uses + `CpiContext::<_, { 1 + MAX_HARVEST_SOURCES }>`. +- A CPI function generated by `declare_program!` takes a third argument + onchain, `&mut FixedVec`, the buffer it serializes the instruction data + into, and keeps its two-argument form on the host. `cross-program-invocation` + calls it under `#[cfg(any(target_os = "solana", target_arch = "bpf"))]` with + a buffer sized for its longest argument, and refuses longer arguments with + its own error. - `Pubkey` is `Address`. `AccountInfo<'info>` is `AccountView`, or `UncheckedAccount` inside an `Accounts` struct. - `.key()` and `.key` become `.address()`, which returns `&Address`. @@ -102,12 +120,12 @@ tests keep working. Only keep zero-copy where the program deliberately wants it (a large slab, say), because converting one to borsh defeats its purpose. v2 has no `Account::try_from(&AccountView)`. To load a borsh account out of -`remaining_accounts` **for writing**, use `AnchorAccount::load_mut`, which is -`unsafe` because the caller has to guarantee no other live `&mut` to the same -data; `exit()` then writes it back: +`remaining_accounts` **for writing**, use `AnchorAccount::load_mut`. It takes an +exclusive borrow on the account's data, so a second live borrow of the same +account fails with `AccountBorrowFailed`; `exit()` then writes it back: ```rust -let mut order = unsafe { BorshAccount::::load_mut(*view) }?; +let mut order = BorshAccount::::load_mut(*view)?; order.filled_quantity += fill; order.exit()?; ``` @@ -221,14 +239,6 @@ Three ways this goes wrong: Also: asking a read-only account for a writable handle panics, so read `*account.address()` rather than `account.cpi_handle_mut().address()`. -**On a `Box`ed account, call `to_cpi_handle_mut()` / `to_cpi_handle()`, not -`cpi_handle_mut()` / `cpi_handle()`.** `Box`'s `AnchorAccount` impl supplies -only `account()`, so `cpi_handle_mut()` falls through to the default, which -builds a handle *without* releasing the wrapper's data borrow, so the CPI is then -rejected with `AccountBorrowFailed`. `Box`'s `ToCpiHandleMut` impl does forward -to the inner type, which is where the release lives. It compiles either way, -so this only shows up in a test. - Not every failure of this kind needs a release: a handler that only *reads* a **read-only** account can take a second shared borrow (`account().try_borrow()`) where `try_borrow_mut` on a copied view would be rejected. @@ -284,20 +294,13 @@ rather than the `sol_get_sysvar` syscall directly: it is a safe wrapper, and offchain it is a no-op that leaves the buffer zeroed, so IDL and client builds read "the cluster has never restarted" without a `cfg` split of their own. -After that, two kinds of `unsafe` are left in the Anchor programs, and neither -has a safe equivalent in v2: - -- **`transfer-hook/*/anchor/…/entrypoint.rs`**: `pub unsafe extern "C" fn - entrypoint` is the loader ABI. These programs claim the entrypoint themselves - to remap an SPL interface discriminator, so the `unsafe` the `#[program]` - macro would have hidden is written out. -- **`order-book/…/place_order.rs`**: `AnchorAccount::load_mut` is an `unsafe fn` - on the trait, and it is the only way to get a writable typed wrapper for an - account arriving through `remaining_accounts`. `BorshAccount`'s implementation - borrows through the checked `try_borrow_mut`, so a duplicate fails with - `AccountBorrowFailed` rather than aliasing. +After that, one kind of `unsafe` is left in the Anchor programs, and it has no +safe equivalent in v2: `pub unsafe extern "C" fn entrypoint` in +`transfer-hook/*/anchor/…/entrypoint.rs` is the loader ABI. These programs +claim the entrypoint themselves to remap an SPL interface discriminator, so the +`unsafe` the `#[program]` macro would have hidden is written out. -Any lint that bans `unsafe` repository-wide has to exempt those, plus the +Any lint that bans `unsafe` repository-wide has to exempt that, plus the Quasar and pinocchio programs, where raw zero-copy access is the point of the example rather than an escape hatch. @@ -444,10 +447,19 @@ answer is usually one of the first four rather than moving it to borsh. ## Hand-Built CPIs Take Handles, Not Account Infos -An example that builds its own `Instruction`, because the callee's crate is +An example that builds its own instruction, because the callee's crate is not on a compatible Solana version, hands `invoke` a slice of `CpiHandle` -rather than a slice of `AccountInfo`. Four rules, all of them enforced at -runtime rather than by the compiler: +rather than a slice of `AccountInfo`. + +`invoke` and `invoke_signed` take any `CpiInstruction`. Onchain, Anchor +implements it only for pinocchio's borrowed `InstructionView`, and +`anchor_lang::solana_program::instruction` exports `AccountMeta` but not +`Instruction`. The compression examples keep their `Vec` and +`Vec` in a local `OwnedInstruction` (`src/owned_instruction.rs`), whose +`CpiInstruction` impl builds the `InstructionAccount` list when it is invoked, +so the same code builds for the host and for SBF. + +Four rules, all of them enforced at runtime rather than by the compiler: - **The handles are positional.** v2 walks the instruction's account metas and binds each one to the next handle in the slice. A handle that does not match From c8084b2d94d79e61a1ff59c4d8cb165d3ee172e4 Mon Sep 17 00:00:00 2001 From: Mike MacCana Date: Sun, 15 Nov 2026 09:37:46 +0000 Subject: [PATCH 9/9] Cargo.lock: record Anchor 2.0.0-rc.4 anchor-lang, anchor-spl and anchor-derive-accounts move from 2.0.0-rc.2 to 2.0.0-rc.4, and anchor-v2-testing to the v2.0.0-rc.4 tag revision 2cdb58ba. Claude-Session: https://claude.ai/code/session_01GZHin4a7zmaQg8n7Dv4BAP --- Cargo.lock | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a73090744..be28ac62f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,9 +176,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anchor-derive-accounts" -version = "2.0.0-rc.2" +version = "2.0.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18c5bd235119ae47e37190da06b9c0961a686aa9e31986ccab207b1234540e4f" +checksum = "156f6978e0f35e8969455cf3cef5b197d9fa723d866a316c544f014bd79585ae" dependencies = [ "anchor-lang-idl", "bs58", @@ -193,9 +193,9 @@ dependencies = [ [[package]] name = "anchor-lang" -version = "2.0.0-rc.2" +version = "2.0.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356811863224722c5eff648869b67ea8d769b0da8c4924cc38cc242ced617e38" +checksum = "6874cc1fc71379f3f75d0854e70bd131a5337fbf9ce827e892eecc4d26bbc3df" dependencies = [ "anchor-derive-accounts", "bytemuck", @@ -253,9 +253,9 @@ dependencies = [ [[package]] name = "anchor-spl" -version = "2.0.0-rc.2" +version = "2.0.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94269c342b12e11d285282d9fffca54e46b9abbac13708ccee9b6f1a2f27c6eb" +checksum = "63d5a43ec6b40f0232948b5d9a62dd6551ccf4100c6ecf430f331ad6818839dd" dependencies = [ "anchor-lang", "borsh 1.7.0", @@ -278,9 +278,10 @@ dependencies = [ [[package]] name = "anchor-v2-testing" version = "0.1.0" -source = "git+https://github.com/otter-sec/anchor.git?rev=a20660219882af5f199d56ea3f9326f387f89d8b#a20660219882af5f199d56ea3f9326f387f89d8b" +source = "git+https://github.com/otter-sec/anchor.git?rev=2cdb58ba8fd9139942ffe235ed5c5c01072138b8#2cdb58ba8fd9139942ffe235ed5c5c01072138b8" dependencies = [ "litesvm", + "solana-fee", "solana-keypair", "solana-message 4.6.0", "solana-program-runtime",