Compare commits

...

3 Commits

Author SHA1 Message Date
Confucian 89ea0f17d2
Merge 3a124d6f25 into c96846fce2 2024-04-23 12:39:42 -04:00
czkz c96846fce2
ts: Fix incorrect `maxSupportedTransactionVersion` in `AnchorProvider.send*()` methods (#2922) 2024-04-23 18:39:18 +02:00
Confucian 3a124d6f25 feat: add remove command 2024-04-22 18:16:47 +08:00
3 changed files with 46 additions and 0 deletions

View File

@ -17,6 +17,7 @@ The minor version will be incremented upon a breaking change and the patch versi
### Fixes
- lang: Eliminate variable allocations that build up stack space for token extension code generation ([#2913](https://github.com/coral-xyz/anchor/pull/2913)).
- ts: Fix incorrect `maxSupportedTransactionVersion` in `AnchorProvider.send*()` methods ([#2922](https://github.com/coral-xyz/anchor/pull/2922)).
### Breaking

View File

@ -239,6 +239,11 @@ pub enum Command {
#[clap(long, action)]
force: bool,
},
/// Remove a existed program.
Remove {
/// Program name
name: String,
},
/// Commands for interacting with interface definitions.
Idl {
#[clap(subcommand)]
@ -681,6 +686,7 @@ fn process_command(opts: Opts) -> Result<()> {
template,
force,
} => new(&opts.cfg_override, solidity, name, template, force),
Command::Remove { name } => remove(&opts.cfg_override, name),
Command::Build {
no_idl,
idl,
@ -1044,6 +1050,41 @@ fn new(
})
}
// Remove the program crate in the `programs/<name>` directory.
pub fn remove(cfg_override: &ConfigOverride, name: String) -> Result<()> {
with_workspace(cfg_override, |cfg| {
match cfg.path().parent() {
None => {
println!("Unable to make new program");
}
Some(parent) => {
std::env::set_current_dir(parent)?;
let cluster = cfg.provider.cluster.clone();
let programs = cfg.programs.entry(cluster).or_default();
if programs.contains_key(&name) {
// Delete all files within the program folder
fs::remove_dir_all(
std::env::current_dir()?
.join("programs")
.join(&name),
)?;
}
print!("There");
programs.remove(&name);
let toml = cfg.to_string();
fs::write("Anchor.toml", toml)?;
println!("Removed program.");
}
};
Ok(())
})
}
/// Array of (path, content) tuple.
pub type Files = Vec<(PathBuf, String)>;

View File

@ -174,8 +174,10 @@ export class AnchorProvider implements Provider {
? tx.signatures?.[0] || new Uint8Array()
: tx.signature ?? new Uint8Array()
);
const maxVer = isVersionedTransaction(tx) ? 0 : undefined;
const failedTx = await this.connection.getTransaction(txSig, {
commitment: "confirmed",
maxSupportedTransactionVersion: maxVer,
});
if (!failedTx) {
throw err;
@ -256,8 +258,10 @@ export class AnchorProvider implements Provider {
? tx.signatures?.[0] || new Uint8Array()
: tx.signature ?? new Uint8Array()
);
const maxVer = isVersionedTransaction(tx) ? 0 : undefined;
const failedTx = await this.connection.getTransaction(txSig, {
commitment: "confirmed",
maxSupportedTransactionVersion: maxVer,
});
if (!failedTx) {
throw err;