1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use anyhow::Result;
use aptos_cli_common::{MovePackageDir, TransactionOptions, TransactionSummary};
use async_trait::async_trait;
use clap::Parser;
use clitool::CliTool;
use move_package::compilation::compiled_package::{CompiledPackage, OnDiskCompiledPackage};
#[derive(Debug, Parser)]
#[clap(name = "aptos-upload", about, version)]
pub struct AptosUploadTool {
#[clap(flatten)]
pub move_options: MovePackageDir,
#[clap(flatten)]
pub txn_options: TransactionOptions,
pub package_name: String,
}
#[async_trait]
impl CliTool<TransactionSummary> for AptosUploadTool {
async fn execute(self) -> Result<TransactionSummary> {
let package: CompiledPackage = OnDiskCompiledPackage::from_path(
&self
.move_options
.output_dir
.unwrap_or_else(|| self.move_options.package_dir.join("build"))
.join(&self.package_name),
)?
.into_compiled_package()?;
aptos_publish::publish(&package, &self.txn_options).await
}
}