Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhargavamacha authored Oct 14, 2024
2 parents 1a25d69 + f5f8edf commit b405c69
Show file tree
Hide file tree
Showing 63 changed files with 712 additions and 283 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/reusable-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ jobs:
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/anchor

# TODO: Re-enable once https://github.com/solana-labs/solana/issues/33504 is resolved
# - run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @coral-xyz/anchor && yarn && anchor test && yarn lint:fix
# - uses: ./.github/actions/git-diff/
- run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @coral-xyz/anchor && yarn && anchor test && yarn lint:fix
- uses: ./.github/actions/git-diff/

test-programs:
needs: setup-anchor-cli
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ The minor version will be incremented upon a breaking change and the patch versi
- cli: Add completions command to generate shell completions via the clap_complete crate ([#3251](https://github.com/coral-xyz/anchor/pull/3251)).
- cli: Always convert IDLs ([#3265](https://github.com/coral-xyz/anchor/pull/3265)).
- cli: Check whether the `idl-build` feature exists when using the `idl build` command ([#3273](https://github.com/coral-xyz/anchor/pull/3273)).
- cli: Build IDL if there is only one program when using the `idl build` command ([#3275](https://github.com/coral-xyz/anchor/pull/3275)).
- cli: Add short alias for the `idl build` command ([#3283](https://github.com/coral-xyz/anchor/pull/3283)).
- cli: Add `--program-id` option to `idl convert` command ([#3309](https://github.com/coral-xyz/anchor/pull/3309)).
- lang: Generate documentation of constants in `declare_program!` ([#3311](https://github.com/coral-xyz/anchor/pull/3311)).
- spl: Add 'Interest Bearing Config` Extension ([#3278](https://github.com/coral-xyz/anchor/pull/3278)).

### Fixes
Expand All @@ -76,6 +80,12 @@ The minor version will be incremented upon a breaking change and the patch versi
- idl: Fix using full path types with `Program` ([#3228](https://github.com/coral-xyz/anchor/pull/3228)).
- lang: Use closures for `init` constraints to reduce the stack usage of `try_accounts` ([#2939](https://github.com/coral-xyz/anchor/pull/2939)).
- lang: Allow the `cfg` attribute above the instructions ([#2339](https://github.com/coral-xyz/anchor/pull/2339)).
- idl: Log output with `ANCHOR_LOG` on failure and improve build error message ([#3284](https://github.com/coral-xyz/anchor/pull/3284)).
- lang: Fix constant bytes declarations when using `declare_program!` ([#3287](https://github.com/coral-xyz/anchor/pull/3287)).
- lang: Fix using non-instruction composite accounts with `declare_program!` ([#3290](https://github.com/coral-xyz/anchor/pull/3290)).
- idl: Fix instructions with tuple parameters not producing an error([#3294](https://github.com/coral-xyz/anchor/pull/3294)).
- ts: Update `engines.node` to `>= 17` ([#3301](https://github.com/coral-xyz/anchor/pull/3301)).
- cli: Use OS-agnostic paths ([#3307](https://github.com/coral-xyz/anchor/pull/3307)).

### Breaking

Expand Down
2 changes: 0 additions & 2 deletions avm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use avm::InstallTarget;
use clap::{CommandFactory, Parser, Subcommand};
use semver::Version;

pub const VERSION: &str = env!("CARGO_PKG_VERSION");

#[derive(Parser)]
#[clap(name = "avm", about = "Anchor version manager", version)]
pub struct Cli {
Expand Down
42 changes: 28 additions & 14 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ impl WithPath<Config> {
let cargo = Manifest::from_path(path.join("Cargo.toml"))?;
let lib_name = cargo.lib_name()?;

let idl_filepath = format!("target/idl/{lib_name}.json");
let idl_filepath = Path::new("target")
.join("idl")
.join(&lib_name)
.with_extension("json");
let idl = fs::read(idl_filepath)
.ok()
.map(|bytes| serde_json::from_reader(&*bytes))
Expand All @@ -257,7 +260,10 @@ impl WithPath<Config> {
});
}
for (lib_name, path) in self.get_solidity_program_list()? {
let idl_filepath = format!("target/idl/{lib_name}.json");
let idl_filepath = Path::new("target")
.join("idl")
.join(&lib_name)
.with_extension("json");
let idl = fs::read(idl_filepath)
.ok()
.map(|bytes| serde_json::from_reader(&*bytes))
Expand Down Expand Up @@ -1131,7 +1137,7 @@ impl From<_Validator> for Validator {
url: _validator.url,
ledger: _validator
.ledger
.unwrap_or_else(|| DEFAULT_LEDGER_PATH.to_string()),
.unwrap_or_else(|| get_default_ledger_path().display().to_string()),
limit_ledger_size: _validator.limit_ledger_size,
rpc_port: _validator
.rpc_port
Expand Down Expand Up @@ -1169,7 +1175,10 @@ impl From<Validator> for _Validator {
}
}

pub const DEFAULT_LEDGER_PATH: &str = ".anchor/test-ledger";
pub fn get_default_ledger_path() -> PathBuf {
Path::new(".anchor").join("test-ledger")
}

const DEFAULT_BIND_ADDRESS: &str = "0.0.0.0";

impl Merge for _Validator {
Expand Down Expand Up @@ -1282,12 +1291,12 @@ impl Program {

// Lazily initializes the keypair file with a new key if it doesn't exist.
pub fn keypair_file(&self) -> Result<WithPath<File>> {
let deploy_dir_path = "target/deploy/";
fs::create_dir_all(deploy_dir_path)
.with_context(|| format!("Error creating directory with path: {deploy_dir_path}"))?;
let deploy_dir_path = Path::new("target").join("deploy");
fs::create_dir_all(&deploy_dir_path)
.with_context(|| format!("Error creating directory with path: {deploy_dir_path:?}"))?;
let path = std::env::current_dir()
.expect("Must have current dir")
.join(format!("target/deploy/{}-keypair.json", self.lib_name));
.join(deploy_dir_path.join(format!("{}-keypair.json", self.lib_name)));
if path.exists() {
return Ok(WithPath::new(
File::open(&path)
Expand All @@ -1303,11 +1312,10 @@ impl Program {
}

pub fn binary_path(&self, verifiable: bool) -> PathBuf {
let path = if verifiable {
format!("target/verifiable/{}.so", self.lib_name)
} else {
format!("target/deploy/{}.so", self.lib_name)
};
let path = Path::new("target")
.join(if verifiable { "verifiable" } else { "deploy" })
.join(&self.lib_name)
.with_extension("so");

std::env::current_dir()
.expect("Must have current dir")
Expand Down Expand Up @@ -1389,7 +1397,13 @@ macro_rules! home_path {

impl Default for $my_struct {
fn default() -> Self {
$my_struct(home_dir().unwrap().join($path).display().to_string())
$my_struct(
home_dir()
.unwrap()
.join($path.replace('/', std::path::MAIN_SEPARATOR_STR))
.display()
.to_string(),
)
}
}

Expand Down
Loading

0 comments on commit b405c69

Please sign in to comment.