Compare commits
10 Commits
6dca4c6c79
...
e709dc4f5a
Author | SHA1 | Date |
---|---|---|
dfy313 | e709dc4f5a | |
acheron | f74ea64ca6 | |
acheron | 257b560109 | |
acheron | 95c4959287 | |
Bhargava Sai Macha | a18d6caa6d | |
acheron | 7356bd5afe | |
David Yu | d6715a8327 | |
dfy313 | 4f8b32d9ad | |
David Yu | 6ac4d9e86d | |
David Yu | a2c404decd |
|
@ -460,6 +460,8 @@ jobs:
|
|||
path: tests/bench
|
||||
- cmd: cd tests/idl && ./test.sh
|
||||
path: tests/idl
|
||||
- cmd: cd tests/solana-program-test-compatibility && cargo test-sbf --package solana-program-test-compatibility --test compatibility_test check_entrypoint
|
||||
path: tests/idl
|
||||
# TODO: Enable when `solang` becomes compatible with the new IDL spec
|
||||
# - cmd: cd tests/solang && anchor test
|
||||
# path: tests/solang
|
||||
|
|
|
@ -44,6 +44,7 @@ The minor version will be incremented upon a breaking change and the patch versi
|
|||
- idl: Store deployment addresses for other clusters ([#2892](https://github.com/coral-xyz/anchor/pull/2892)).
|
||||
- lang: Add `Event` utility type to get events from bytes ([#2897](https://github.com/coral-xyz/anchor/pull/2897)).
|
||||
- lang, spl: Add support for [token extensions](https://solana.com/solutions/token-extensions) ([#2789](https://github.com/coral-xyz/anchor/pull/2789)).
|
||||
- lang: Return overflow error from `Lamports` trait operations ([#2907](https://github.com/coral-xyz/anchor/pull/2907)).
|
||||
|
||||
### Fixes
|
||||
|
||||
|
@ -71,6 +72,8 @@ The minor version will be incremented upon a breaking change and the patch versi
|
|||
- avm, cli: Fix `stdsimd` feature compilation error from `ahash` when installing the CLI using newer Rust versions ([#2867](https://github.com/coral-xyz/anchor/pull/2867)).
|
||||
- spl: Fix not being able to deserialize newer token 2022 extensions ([#2876](https://github.com/coral-xyz/anchor/pull/2876)).
|
||||
- spl: Remove `solana-program` dependency ([#2900](https://github.com/coral-xyz/anchor/pull/2900)).
|
||||
- spl: Make `TokenAccount` and ` Mint` `Copy` ([#2904](https://github.com/coral-xyz/anchor/pull/2904)).
|
||||
- ts: Add missing errors ([#2906](https://github.com/coral-xyz/anchor/pull/2906)).
|
||||
|
||||
### Breaking
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ dependencies = [
|
|||
name = "anchor-attribute-program"
|
||||
version = "0.29.0"
|
||||
dependencies = [
|
||||
"anchor-idl",
|
||||
"anchor-lang-idl",
|
||||
"anchor-syn",
|
||||
"anyhow",
|
||||
"bs58 0.5.0",
|
||||
|
@ -186,8 +186,8 @@ name = "anchor-cli"
|
|||
version = "0.29.0"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-idl",
|
||||
"anchor-lang",
|
||||
"anchor-lang-idl",
|
||||
"anyhow",
|
||||
"base64 0.21.7",
|
||||
"bincode",
|
||||
|
@ -263,17 +263,6 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-idl"
|
||||
version = "0.29.0"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anyhow",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-lang"
|
||||
version = "0.29.0"
|
||||
|
@ -287,7 +276,7 @@ dependencies = [
|
|||
"anchor-derive-accounts",
|
||||
"anchor-derive-serde",
|
||||
"anchor-derive-space",
|
||||
"anchor-idl",
|
||||
"anchor-lang-idl",
|
||||
"arrayref",
|
||||
"base64 0.21.7",
|
||||
"bincode",
|
||||
|
@ -298,6 +287,17 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-lang-idl"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anyhow",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-spl"
|
||||
version = "0.29.0"
|
||||
|
|
|
@ -17,7 +17,7 @@ dev = []
|
|||
|
||||
[dependencies]
|
||||
anchor-client = { path = "../client", version = "0.29.0" }
|
||||
anchor-idl = { path = "../idl", features = ["build"], version = "0.29.0" }
|
||||
anchor-lang-idl = { path = "../idl", features = ["build"], version = "0.1.0" }
|
||||
anchor-lang = { path = "../lang", version = "0.29.0" }
|
||||
anyhow = "1.0.32"
|
||||
base64 = "0.21"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::is_hidden;
|
||||
use anchor_client::Cluster;
|
||||
use anchor_idl::types::Idl;
|
||||
use anchor_lang_idl::types::Idl;
|
||||
use anyhow::{anyhow, bail, Context, Error, Result};
|
||||
use clap::{Parser, ValueEnum};
|
||||
use dirs::home_dir;
|
||||
|
|
|
@ -6,9 +6,9 @@ use crate::config::{
|
|||
DEFAULT_LEDGER_PATH, SHUTDOWN_WAIT, STARTUP_WAIT,
|
||||
};
|
||||
use anchor_client::Cluster;
|
||||
use anchor_idl::types::{Idl, IdlArrayLen, IdlDefinedFields, IdlType, IdlTypeDefTy};
|
||||
use anchor_lang::idl::{IdlAccount, IdlInstruction, ERASED_AUTHORITY};
|
||||
use anchor_lang::{AccountDeserialize, AnchorDeserialize, AnchorSerialize};
|
||||
use anchor_lang_idl::types::{Idl, IdlArrayLen, IdlDefinedFields, IdlType, IdlTypeDefTy};
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use checks::{check_anchor_version, check_overflow};
|
||||
use clap::Parser;
|
||||
|
@ -2609,7 +2609,7 @@ fn idl_build(
|
|||
.path
|
||||
}
|
||||
};
|
||||
let idl = anchor_idl::build::build_idl(
|
||||
let idl = anchor_lang_idl::build::build_idl(
|
||||
program_path,
|
||||
cfg.features.resolution,
|
||||
cfg.features.skip_lint || skip_lint,
|
||||
|
@ -2655,7 +2655,7 @@ in `{path}`."#
|
|||
));
|
||||
}
|
||||
|
||||
anchor_idl::build::build_idl(
|
||||
anchor_lang_idl::build::build_idl(
|
||||
std::env::current_dir()?,
|
||||
cfg.features.resolution,
|
||||
cfg.features.skip_lint || skip_lint,
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
|||
config::ProgramWorkspace, create_files, override_or_create_files, solidity_template, Files,
|
||||
VERSION,
|
||||
};
|
||||
use anchor_idl::types::Idl;
|
||||
use anchor_lang_idl::types::Idl;
|
||||
use anyhow::Result;
|
||||
use clap::{Parser, ValueEnum};
|
||||
use heck::{ToLowerCamelCase, ToPascalCase, ToSnakeCase};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "anchor-idl"
|
||||
version = "0.29.0"
|
||||
name = "anchor-lang-idl"
|
||||
version = "0.1.0"
|
||||
authors = ["Anchor Maintainers <accounts@200ms.io>"]
|
||||
repository = "https://github.com/coral-xyz/anchor"
|
||||
rust-version = "1.60"
|
||||
|
|
|
@ -4,7 +4,7 @@ use anyhow::anyhow;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// IDL specification Semantic Version
|
||||
pub const IDL_SPEC: &str = "0.1.0";
|
||||
pub const IDL_SPEC: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct Idl {
|
||||
|
|
|
@ -33,7 +33,7 @@ idl-build = [
|
|||
"anchor-attribute-program/idl-build",
|
||||
"anchor-derive-accounts/idl-build",
|
||||
"anchor-derive-serde/idl-build",
|
||||
"anchor-idl/build",
|
||||
"anchor-lang-idl/build",
|
||||
]
|
||||
init-if-needed = ["anchor-derive-accounts/init-if-needed"]
|
||||
interface-instructions = ["anchor-attribute-program/interface-instructions"]
|
||||
|
@ -49,8 +49,8 @@ anchor-derive-accounts = { path = "./derive/accounts", version = "0.29.0" }
|
|||
anchor-derive-serde = { path = "./derive/serde", version = "0.29.0" }
|
||||
anchor-derive-space = { path = "./derive/space", version = "0.29.0" }
|
||||
|
||||
# `anchor-idl` should only be included with `idl-build` feature
|
||||
anchor-idl = { path = "../idl", version = "0.29.0", optional = true }
|
||||
# `anchor-lang-idl` should only be included with `idl-build` feature
|
||||
anchor-lang-idl = { path = "../idl", version = "0.1.0", optional = true }
|
||||
|
||||
arrayref = "0.3"
|
||||
base64 = "0.21"
|
||||
|
|
|
@ -17,7 +17,7 @@ idl-build = ["anchor-syn/idl-build"]
|
|||
interface-instructions = ["anchor-syn/interface-instructions"]
|
||||
|
||||
[dependencies]
|
||||
anchor-idl = { path = "../../../idl", version = "0.29.0" }
|
||||
anchor-lang-idl = { path = "../../../idl", version = "0.1.0" }
|
||||
anchor-syn = { path = "../../syn", version = "0.29.0" }
|
||||
anyhow = "1"
|
||||
bs58 = "0.5"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anchor_idl::types::{
|
||||
use anchor_lang_idl::types::{
|
||||
Idl, IdlArrayLen, IdlDefinedFields, IdlField, IdlGenericArg, IdlRepr, IdlSerialization,
|
||||
IdlType, IdlTypeDef, IdlTypeDefGeneric, IdlTypeDefTy,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mod common;
|
||||
mod mods;
|
||||
|
||||
use anchor_idl::types::Idl;
|
||||
use anchor_lang_idl::types::Idl;
|
||||
use anyhow::anyhow;
|
||||
use quote::{quote, ToTokens};
|
||||
use syn::parse::{Parse, ParseStream};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anchor_idl::types::{Idl, IdlSerialization};
|
||||
use anchor_lang_idl::types::{Idl, IdlSerialization};
|
||||
use quote::{format_ident, quote};
|
||||
|
||||
use super::common::{convert_idl_type_def_to_ts, gen_discriminator, get_canonical_program_id};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anchor_idl::types::Idl;
|
||||
use anchor_lang_idl::types::Idl;
|
||||
use quote::quote;
|
||||
|
||||
use super::common::gen_accounts_common;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anchor_idl::types::{Idl, IdlType};
|
||||
use anchor_lang_idl::types::{Idl, IdlType};
|
||||
use quote::{format_ident, quote, ToTokens};
|
||||
|
||||
use super::common::convert_idl_type_to_str;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anchor_idl::types::Idl;
|
||||
use anchor_lang_idl::types::Idl;
|
||||
use heck::CamelCase;
|
||||
use quote::{format_ident, quote};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anchor_idl::types::Idl;
|
||||
use anchor_lang_idl::types::Idl;
|
||||
use quote::{format_ident, quote};
|
||||
|
||||
use super::common::{convert_idl_type_def_to_ts, gen_discriminator};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anchor_idl::types::{Idl, IdlInstructionAccountItem};
|
||||
use anchor_lang_idl::types::{Idl, IdlInstructionAccountItem};
|
||||
use anchor_syn::{
|
||||
codegen::accounts::{__client_accounts, __cpi_client_accounts},
|
||||
parser::accounts,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anchor_idl::types::Idl;
|
||||
use anchor_lang_idl::types::Idl;
|
||||
use quote::quote;
|
||||
|
||||
use super::common::convert_idl_type_def_to_ts;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anchor_idl::types::Idl;
|
||||
use anchor_lang_idl::types::Idl;
|
||||
use quote::{format_ident, quote};
|
||||
|
||||
use super::common::gen_discriminator;
|
||||
|
|
|
@ -80,4 +80,4 @@ impl IdlAccount {
|
|||
}
|
||||
|
||||
#[cfg(feature = "idl-build")]
|
||||
pub use anchor_idl::{build::IdlBuild, *};
|
||||
pub use anchor_lang_idl::{build::IdlBuild, *};
|
||||
|
|
|
@ -28,6 +28,7 @@ extern crate self as anchor_lang;
|
|||
use bytemuck::{Pod, Zeroable};
|
||||
use solana_program::account_info::AccountInfo;
|
||||
use solana_program::instruction::AccountMeta;
|
||||
use solana_program::program_error::ProgramError;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
use std::{collections::BTreeSet, fmt::Debug, io::Write};
|
||||
|
||||
|
@ -197,7 +198,10 @@ pub trait Lamports<'info>: AsRef<AccountInfo<'info>> {
|
|||
///
|
||||
/// See [`Lamports::sub_lamports`] for subtracting lamports.
|
||||
fn add_lamports(&self, amount: u64) -> Result<&Self> {
|
||||
**self.as_ref().try_borrow_mut_lamports()? += amount;
|
||||
**self.as_ref().try_borrow_mut_lamports()? = self
|
||||
.get_lamports()
|
||||
.checked_add(amount)
|
||||
.ok_or(ProgramError::ArithmeticOverflow)?;
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
|
@ -215,7 +219,10 @@ pub trait Lamports<'info>: AsRef<AccountInfo<'info>> {
|
|||
///
|
||||
/// See [`Lamports::add_lamports`] for adding lamports.
|
||||
fn sub_lamports(&self, amount: u64) -> Result<&Self> {
|
||||
**self.as_ref().try_borrow_mut_lamports()? -= amount;
|
||||
**self.as_ref().try_borrow_mut_lamports()? = self
|
||||
.get_lamports()
|
||||
.checked_sub(amount)
|
||||
.ok_or(ProgramError::ArithmeticOverflow)?;
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -443,7 +443,7 @@ pub struct SyncNative<'info> {
|
|||
pub account: AccountInfo<'info>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Copy)]
|
||||
pub struct TokenAccount(spl_token::state::Account);
|
||||
|
||||
impl TokenAccount {
|
||||
|
@ -474,7 +474,7 @@ impl Deref for TokenAccount {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Copy)]
|
||||
pub struct Mint(spl_token::state::Mint);
|
||||
|
||||
impl Mint {
|
||||
|
|
|
@ -13,7 +13,7 @@ pub use crate::token_2022_extensions::*;
|
|||
|
||||
static IDS: [Pubkey; 2] = [spl_token::ID, spl_token_2022::ID];
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Copy)]
|
||||
pub struct TokenAccount(spl_token_2022::state::Account);
|
||||
|
||||
impl anchor_lang::AccountDeserialize for TokenAccount {
|
||||
|
@ -42,7 +42,7 @@ impl Deref for TokenAccount {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Copy)]
|
||||
pub struct Mint(spl_token_2022::state::Mint);
|
||||
|
||||
impl anchor_lang::AccountDeserialize for Mint {
|
||||
|
|
|
@ -6,7 +6,7 @@ declare_id!("Lamports11111111111111111111111111111111111");
|
|||
pub mod lamports {
|
||||
use super::*;
|
||||
|
||||
pub fn test_lamports_trait(ctx: Context<TestLamportsTrait>, amount: u64) -> Result<()> {
|
||||
pub fn transfer(ctx: Context<Transfer>, amount: u64) -> Result<()> {
|
||||
let pda = &ctx.accounts.pda;
|
||||
let signer = &ctx.accounts.signer;
|
||||
|
||||
|
@ -52,13 +52,29 @@ pub mod lamports {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Return overflow error in the case of overflow (instead of panicking)
|
||||
pub fn overflow(ctx: Context<Overflow>) -> Result<()> {
|
||||
let pda = &ctx.accounts.pda;
|
||||
|
||||
match pda.add_lamports(u64::MAX) {
|
||||
Err(e) => assert_eq!(e, ProgramError::ArithmeticOverflow.into()),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
match pda.sub_lamports(u64::MAX) {
|
||||
Err(e) => assert_eq!(e, ProgramError::ArithmeticOverflow.into()),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct TestLamportsTrait<'info> {
|
||||
pub struct Transfer<'info> {
|
||||
#[account(mut)]
|
||||
pub signer: Signer<'info>,
|
||||
|
||||
#[account(
|
||||
init,
|
||||
payer = signer,
|
||||
|
@ -67,9 +83,14 @@ pub struct TestLamportsTrait<'info> {
|
|||
bump
|
||||
)]
|
||||
pub pda: Account<'info, LamportsPda>,
|
||||
|
||||
pub system_program: Program<'info, System>,
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct Overflow<'info> {
|
||||
#[account(seeds = [b"lamports"], bump)]
|
||||
pub pda: Account<'info, LamportsPda>,
|
||||
}
|
||||
|
||||
#[account]
|
||||
pub struct LamportsPda {}
|
||||
|
|
|
@ -8,16 +8,13 @@ describe("lamports", () => {
|
|||
|
||||
const program = anchor.workspace.Lamports as anchor.Program<Lamports>;
|
||||
|
||||
it("Can use the Lamports trait", async () => {
|
||||
const signer = program.provider.publicKey!;
|
||||
const [pda] = anchor.web3.PublicKey.findProgramAddressSync(
|
||||
[Buffer.from("lamports")],
|
||||
program.programId
|
||||
);
|
||||
|
||||
it("Can transfer from/to PDA", async () => {
|
||||
await program.methods
|
||||
.testLamportsTrait(new anchor.BN(anchor.web3.LAMPORTS_PER_SOL))
|
||||
.accounts({ signer, pda })
|
||||
.transfer(new anchor.BN(anchor.web3.LAMPORTS_PER_SOL))
|
||||
.rpc();
|
||||
});
|
||||
|
||||
it("Returns an error on overflow", async () => {
|
||||
await program.methods.overflow().rpc();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
"spl/token-proxy",
|
||||
"spl/token-wrapper",
|
||||
"spl/transfer-hook",
|
||||
"solana-program-test-compatibility",
|
||||
"swap",
|
||||
"system-accounts",
|
||||
"sysvars",
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
.anchor
|
||||
.DS_Store
|
||||
target
|
||||
node_modules
|
||||
dist
|
||||
build
|
||||
test-ledger
|
|
@ -0,0 +1,18 @@
|
|||
[toolchain]
|
||||
|
||||
[features]
|
||||
seeds = false
|
||||
skip-lint = false
|
||||
|
||||
[programs.localnet]
|
||||
solana_program_test_compatibility = "3cgdzWdfZSy1GaV6Lg98iwLvTcL9W7AVD8BpxiZjCZ9z"
|
||||
|
||||
[registry]
|
||||
url = "https://api.apr.dev"
|
||||
|
||||
[provider]
|
||||
cluster = "Localnet"
|
||||
wallet = "/Users/david/.config/solana/id.json"
|
||||
|
||||
[scripts]
|
||||
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
|
|
@ -0,0 +1,13 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"programs/*"
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
overflow-checks = true
|
||||
lto = "fat"
|
||||
codegen-units = 1
|
||||
[profile.release.build-override]
|
||||
opt-level = 3
|
||||
incremental = false
|
||||
codegen-units = 1
|
|
@ -0,0 +1,12 @@
|
|||
// Migrations are an early feature. Currently, they're nothing more than this
|
||||
// single deploy script that's invoked from the CLI, injecting a provider
|
||||
// configured from the workspace's Anchor.toml.
|
||||
|
||||
const anchor = require("@coral-xyz/anchor");
|
||||
|
||||
module.exports = async function (provider) {
|
||||
// Configure client to use the provider.
|
||||
anchor.setProvider(provider);
|
||||
|
||||
// Add your deploy script here.
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"scripts": {
|
||||
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
|
||||
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
|
||||
},
|
||||
"dependencies": {
|
||||
"@coral-xyz/anchor": "^0.29.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.4",
|
||||
"mocha": "^9.0.3",
|
||||
"ts-mocha": "^10.0.0",
|
||||
"@types/bn.js": "^5.1.0",
|
||||
"@types/chai": "^4.3.0",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"typescript": "^4.3.5",
|
||||
"prettier": "^2.6.2"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
[package]
|
||||
name = "solana-program-test-compatibility"
|
||||
version = "0.1.0"
|
||||
description = "Created with Anchor"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
name = "solana_program_test_compatibility"
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
no-idl = []
|
||||
no-log-ix-name = []
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
anchor-lang = { path = "../../../../lang" }
|
||||
|
||||
[dev-dependencies]
|
||||
solana-program-test = ">=1.16, <1.18"
|
|
@ -0,0 +1,2 @@
|
|||
[target.bpfel-unknown-unknown.dependencies.std]
|
||||
features = []
|
|
@ -0,0 +1,15 @@
|
|||
use anchor_lang::prelude::*;
|
||||
|
||||
declare_id!("3cgdzWdfZSy1GaV6Lg98iwLvTcL9W7AVD8BpxiZjCZ9z");
|
||||
|
||||
#[program]
|
||||
pub mod solana_program_test_compatibility {
|
||||
use super::*;
|
||||
|
||||
pub fn initialize(_ctx: Context<Initialize>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct Initialize {}
|
|
@ -0,0 +1,10 @@
|
|||
use solana_program_test::ProgramTest;
|
||||
|
||||
#[test]
|
||||
fn check_entrypoint() {
|
||||
let _pt = ProgramTest::new(
|
||||
"solana_program_test_compatibility",
|
||||
solana_program_test_compatibility::id(),
|
||||
None,
|
||||
);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"types": ["mocha", "chai"],
|
||||
"typeRoots": ["./node_modules/@types"],
|
||||
"lib": ["es2015"],
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
|
@ -315,6 +315,10 @@ export const LangErrorCode = {
|
|||
// IDL instructions.
|
||||
IdlInstructionStub: 1000,
|
||||
IdlInstructionInvalidProgram: 1001,
|
||||
IdlAccountNotEmpty: 1002,
|
||||
|
||||
// Event instructions.
|
||||
EventInstructionStub: 1500,
|
||||
|
||||
// Constraints.
|
||||
ConstraintMut: 2000,
|
||||
|
@ -338,6 +342,25 @@ export const LangErrorCode = {
|
|||
ConstraintMintDecimals: 2018,
|
||||
ConstraintSpace: 2019,
|
||||
ConstraintAccountIsNone: 2020,
|
||||
ConstraintTokenTokenProgram: 2021,
|
||||
ConstraintMintTokenProgram: 2022,
|
||||
ConstraintAssociatedTokenTokenProgram: 2023,
|
||||
ConstraintMintGroupPointerExtension: 2024,
|
||||
ConstraintMintGroupPointerExtensionAuthority: 2025,
|
||||
ConstraintMintGroupPointerExtensionGroupAddress: 2026,
|
||||
ConstraintMintGroupMemberPointerExtension: 2027,
|
||||
ConstraintMintGroupMemberPointerExtensionAuthority: 2028,
|
||||
ConstraintMintGroupMemberPointerExtensionMemberAddress: 2029,
|
||||
ConstraintMintMetadataPointerExtension: 2030,
|
||||
ConstraintMintMetadataPointerExtensionAuthority: 2031,
|
||||
ConstraintMintMetadataPointerExtensionMetadataAddress: 2032,
|
||||
ConstraintMintCloseAuthorityExtension: 2033,
|
||||
ConstraintMintCloseAuthorityExtensionAuthority: 2034,
|
||||
ConstraintMintPermanentDelegateExtension: 2035,
|
||||
ConstraintMintPermanentDelegateExtensionDelegate: 2036,
|
||||
ConstraintMintTransferHookExtension: 2037,
|
||||
ConstraintMintTransferHookExtensionAuthority: 2038,
|
||||
ConstraintMintTransferHookExtensionProgramId: 2039,
|
||||
|
||||
// Require.
|
||||
RequireViolated: 2500,
|
||||
|
@ -370,6 +393,7 @@ export const LangErrorCode = {
|
|||
|
||||
// Miscellaneous
|
||||
DeclaredProgramIdMismatch: 4100,
|
||||
TryingToInitPayerAsProgramAccount: 4101,
|
||||
|
||||
// Used for APIs that shouldn't be used anymore.
|
||||
Deprecated: 5000,
|
||||
|
@ -403,6 +427,16 @@ export const LangErrorMessage = new Map([
|
|||
LangErrorCode.IdlInstructionInvalidProgram,
|
||||
"The transaction was given an invalid program for the IDL instruction",
|
||||
],
|
||||
[
|
||||
LangErrorCode.IdlAccountNotEmpty,
|
||||
"IDL account must be empty in order to resize, try closing first",
|
||||
],
|
||||
|
||||
// Event instructions.
|
||||
[
|
||||
LangErrorCode.EventInstructionStub,
|
||||
"The program was compiled without `event-cpi` feature",
|
||||
],
|
||||
|
||||
// Constraints.
|
||||
[LangErrorCode.ConstraintMut, "A mut constraint was violated"],
|
||||
|
@ -447,6 +481,82 @@ export const LangErrorMessage = new Map([
|
|||
LangErrorCode.ConstraintAccountIsNone,
|
||||
"A required account for the constraint is None",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintTokenTokenProgram,
|
||||
"A token account token program constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintTokenProgram,
|
||||
"A mint token program constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintAssociatedTokenTokenProgram,
|
||||
"An associated token account token program constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintGroupPointerExtension,
|
||||
"A group pointer extension constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintGroupPointerExtensionAuthority,
|
||||
"A group pointer extension authority constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintGroupPointerExtensionGroupAddress,
|
||||
"A group pointer extension group address constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintGroupMemberPointerExtension,
|
||||
"A group member pointer extension constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintGroupMemberPointerExtensionAuthority,
|
||||
"A group member pointer extension authority constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintGroupMemberPointerExtensionMemberAddress,
|
||||
"A group member pointer extension group address constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintMetadataPointerExtension,
|
||||
"A metadata pointer extension constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintMetadataPointerExtensionAuthority,
|
||||
"A metadata pointer extension authority constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintMetadataPointerExtensionMetadataAddress,
|
||||
"A metadata pointer extension metadata address constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintCloseAuthorityExtension,
|
||||
"A close authority constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintCloseAuthorityExtensionAuthority,
|
||||
"A close authority extension authority constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintPermanentDelegateExtension,
|
||||
"A permanent delegate extension constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintPermanentDelegateExtensionDelegate,
|
||||
"A permanent delegate extension delegate constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintTransferHookExtension,
|
||||
"A transfer hook extension constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintTransferHookExtensionAuthority,
|
||||
"A transfer hook extension authority constraint was violated",
|
||||
],
|
||||
[
|
||||
LangErrorCode.ConstraintMintTransferHookExtensionProgramId,
|
||||
"A transfer hook extension transfer hook program id constraint was violated",
|
||||
],
|
||||
|
||||
// Require.
|
||||
[LangErrorCode.RequireViolated, "A require expression was violated"],
|
||||
|
@ -524,6 +634,10 @@ export const LangErrorMessage = new Map([
|
|||
LangErrorCode.DeclaredProgramIdMismatch,
|
||||
"The declared program id does not match the actual program id",
|
||||
],
|
||||
[
|
||||
LangErrorCode.TryingToInitPayerAsProgramAccount,
|
||||
"You cannot/should not initialize the payer account as a program account",
|
||||
],
|
||||
|
||||
// Deprecated
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue