Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge RC into feat/sc-meta-wallets #1735

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1cdf5ed
cli report code - needs to work for multi .wasm contracts
BiancaIalangi Jul 17, 2024
c9ea2ae
cli report code - multi .wasm report fix
BiancaIalangi Jul 17, 2024
356ac5e
cli report code - generate markdown
BiancaIalangi Jul 17, 2024
5e8956e
cli code report - compare .md files
BiancaIalangi Jul 19, 2024
02a8a64
cli code report - cargo clippy
BiancaIalangi Jul 19, 2024
b0a2d11
cli code report - impl changes, integrate in a structure
BiancaIalangi Jul 20, 2024
424252d
Merge branch 'master' into report-code-cli
BiancaIalangi Jul 20, 2024
8cd1aeb
cli code report - cleanup
BiancaIalangi Jul 20, 2024
88dd0be
cli code report - fix commented line
BiancaIalangi Jul 20, 2024
3ea894f
code report - sanitize paths
BiancaIalangi Jul 26, 2024
4577bbe
code report - test github actions
BiancaIalangi Jul 26, 2024
6a74ae2
update sc-actions version
laurci Jul 26, 2024
42fcac5
cli code report - compare impl changed
BiancaIalangi Jul 29, 2024
3c1b1b9
code report cli - cleanup
BiancaIalangi Aug 5, 2024
7bd2b57
cli code report - format error
BiancaIalangi Aug 5, 2024
826b7ce
cli code report - change action version
BiancaIalangi Aug 5, 2024
9ccc87f
Merge branch 'master' into report-code-cli
BiancaIalangi Aug 5, 2024
86a1508
cli code report - new report commands: compile, compare, convert
BiancaIalangi Aug 9, 2024
ec1d48a
Merge branch 'master' into report-code-cli
BiancaIalangi Aug 9, 2024
34c54af
cli code report - change err message when baseline file not found
BiancaIalangi Aug 9, 2024
c4631d8
cli code report - add extra info to err
BiancaIalangi Aug 9, 2024
723517d
cli code report - fix vector parsing err
BiancaIalangi Aug 9, 2024
b98c1f7
pem wallet generation
andreivasilescu24 Aug 12, 2024
b530c1f
[WIP] generated pem file
andreivasilescu24 Aug 12, 2024
8582152
cli code report - fix typo
BiancaIalangi Aug 12, 2024
d5be23d
demo wallet creation & conversion
andreivasilescu24 Aug 13, 2024
5c42c62
cli code report - revert version of sc-actions
BiancaIalangi Aug 13, 2024
8e5231d
Merge pull request #1714 from multiversx/report-code-cli
BiancaIalangi Aug 13, 2024
47ef8de
added bech32 command and updated conversion
andreivasilescu24 Aug 13, 2024
eba0141
deleted unnecessary dependency
andreivasilescu24 Aug 13, 2024
925ed7e
substitution list: AddressToIdMapper
andrei-marinica Aug 14, 2024
4473229
Merge pull request #1730 from multiversx/subst-AddressToIdMapper
andrei-marinica Aug 14, 2024
5b00e03
proxy gen - fix for non-configured proxy and ManagedOption type
BiancaIalangi Aug 14, 2024
6bacb29
proxy gen - clippy
BiancaIalangi Aug 14, 2024
fb98353
Merge pull request #1731 from multiversx/proxy-gen-fix
andrei-marinica Aug 19, 2024
8d5a21e
Merge pull request #1729 from multiversx/sc-meta-wallet-new
BiancaIalangi Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion contracts/examples/lottery-esdt/src/lottery_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use multiversx_sc::{

use multiversx_sc::derive_imports::*;

#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)]
#[type_abi]
#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)]
pub struct LotteryInfo<M: ManagedTypeApi> {
pub token_identifier: EgldOrEsdtTokenIdentifier<M>,
pub ticket_price: BigUint<M>,
Expand Down
3 changes: 2 additions & 1 deletion contracts/examples/lottery-esdt/src/status.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use multiversx_sc::derive_imports::*;

#[derive(TopEncode, TopDecode, TypeAbi, PartialEq, Eq, Clone, Copy)]
#[type_abi]
#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy)]
pub enum Status {
Inactive,
Running,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ pub trait AddressToIdMapperFeatures {
}

#[storage_mapper("address_ids")]
fn address_ids(&self) -> AddressToIdMapper<Self::Api>;
fn address_ids(&self) -> AddressToIdMapper;
}
5 changes: 4 additions & 1 deletion framework/base/src/types/managed/wrapped/managed_option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ where
}

fn type_name_rust() -> TypeName {
Option::<T>::type_name_rust()
TypeName::from(alloc::format!(
"ManagedOption<$API, {}>",
T::type_name_rust()
))
}

fn provide_type_descriptions<TDC: TypeDescriptionContainer>(accumulator: &mut TDC) {
Expand Down
1 change: 1 addition & 0 deletions framework/derive/src/preprocessing/substitution_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ fn add_storage_mappers(substitutions: &mut SubstitutionsMap) {
add_storage_mapper_single_generic_arg(substitutions, &quote!(TokenAttributesMapper));
add_storage_mapper_single_generic_arg(substitutions, &quote!(UniqueIdMapper));
add_storage_mapper_single_generic_arg(substitutions, &quote!(UserMapper));
add_storage_mapper_single_generic_arg(substitutions, &quote!(AddressToIdMapper));

add_storage_mapper(substitutions, &quote!(BiDiMapper));
add_storage_mapper(substitutions, &quote!(LinkedListMapper));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ const PROXY_COMPARE_ERR_MSG: &str = "Contract has been modified and proxies have

impl MetaConfig {
pub fn generate_proxy(&mut self) {
if self.sc_config.proxy_configs.is_empty() {
let proxy_config_default =
ProxyConfig::new_with_default_path(self.original_contract_abi.clone());
write_proxy_with_explicit_path(&proxy_config_default, self);
return;
}

for proxy_config in &self.sc_config.proxy_configs {
write_proxy_with_explicit_path(proxy_config, self);
}
Expand Down
6 changes: 3 additions & 3 deletions framework/meta-lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
pub mod abi_json;
pub mod cargo_toml_contents;
pub mod cli;
mod code_report_json;
pub mod code_report_json;
pub mod contract;
pub mod ei;
pub mod ei_check_json;
pub mod esdt_attr_file_json;
mod mxsc_file_json;
pub mod mxsc_file_json;
pub mod print_util;
mod report_info_json;
pub mod report_info_json;
pub mod tools;
pub mod version;
pub mod version_history;
Expand Down
1 change: 1 addition & 0 deletions framework/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ zip = { version = "2.1", features = ["deflate"], default-features = false }
copy_dir = "0.1.2"
pathdiff = "0.2.1"
common-path = "1.0.0"
bip39 = "2.0.0"

[dependencies.multiversx-sc-meta-lib]
version = "=0.52.3"
Expand Down
128 changes: 126 additions & 2 deletions framework/meta/src/cli/cli_args_standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ pub enum StandaloneCliAction {
#[command(name = "test-coverage", about = "Run test coverage and output report")]
TestCoverage(TestCoverageArgs),

#[command(name = "report", about = "Generate code report")]
CodeReportGen(CodeReportArgs),

#[command(
about = "Generates a scenario test initialized with real data fetched from the blockchain."
)]
Expand All @@ -75,6 +78,12 @@ pub enum StandaloneCliAction {
about = "Generates a report on the local depedencies of contract crates. Will explore indirect depdencies too."
)]
LocalDeps(LocalDepsArgs),

#[command(
name = "wallet",
about = "Generates a new wallet or performs actions on an existing wallet."
)]
Wallet(WalletArgs),
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Args)]
Expand Down Expand Up @@ -115,7 +124,7 @@ pub struct TestArgs {
}

#[derive(Default, Clone, PartialEq, Eq, Debug, ValueEnum)]
pub enum TestCoverageOutputFormat {
pub enum OutputFormat {
/// Markdown pretty-print summary
#[default]
Markdown,
Expand All @@ -132,13 +141,73 @@ pub struct TestCoverageArgs {

/// Output format
#[arg(short, long, verbatim_doc_comment)]
pub format: Option<TestCoverageOutputFormat>,
pub format: Option<OutputFormat>,

/// Ignore files by path patterns
#[arg(short = 'i', long = "ignore-filename-regex", verbatim_doc_comment)]
pub ignore_filename_regex: Vec<String>,
}

#[derive(Clone, PartialEq, Eq, Debug, Args)]
pub struct CodeReportArgs {
#[command(subcommand)]
pub command: CodeReportAction,
}

#[derive(Clone, PartialEq, Eq, Debug, Subcommand)]
pub enum CodeReportAction {
#[command(name = "compile", about = "Generates the contract report.")]
Compile(CompileArgs),

#[command(name = "compare", about = "Compare two contract reports.")]
Compare(CompareArgs),

#[command(
name = "convert",
about = "Converts a contract report to a Markdown file."
)]
Convert(ConvertArgs),
}

#[derive(Clone, PartialEq, Eq, Debug, Args)]
pub struct CompileArgs {
/// Target directory where to generate code report.
#[arg(short, long, verbatim_doc_comment)]
pub path: PathBuf,

/// Path to the Markdown or JSON file where the report results will be written.
#[arg(short, long, verbatim_doc_comment)]
pub output: PathBuf,
}

#[derive(Clone, PartialEq, Eq, Debug, Args)]
pub struct CompareArgs {
/// Path to the previous version of code report JSON file
/// that will be used for comparison.
#[arg(short, long, verbatim_doc_comment)]
pub baseline: PathBuf,

/// Path to the current version of the code report JSON file
/// that will be compared.
#[arg(short, long, verbatim_doc_comment)]
pub new: PathBuf,

/// Path to the Markdown file where the comparison results will be written.
#[arg(short, long, verbatim_doc_comment)]
pub output: PathBuf,
}

#[derive(Clone, PartialEq, Eq, Debug, Args)]
pub struct ConvertArgs {
/// Path to the JSON report file that needs to be converted to Markdown format.
#[arg(short, long, verbatim_doc_comment)]
pub input: PathBuf,

/// Path to the Markdown file where the report results will be written.
#[arg(short, long, verbatim_doc_comment)]
pub output: PathBuf,
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Args)]
pub struct AllArgs {
#[command(subcommand)]
Expand Down Expand Up @@ -348,3 +417,58 @@ pub struct AccountArgs {
#[arg(long = "address", verbatim_doc_comment)]
pub address: String,
}

#[derive(Clone, PartialEq, Eq, Debug, Subcommand)]
pub enum WalletAction {
#[command(name = "new", about = "Creates a new wallet")]
New(WalletNewArgs),

#[command(
name = "bech32",
about = "Encodes/decodes a bech32 address to/from hex"
)]
Bech32(WalletBech32Args),
#[command(name = "convert", about = "Converts a wallet")]
Convert(WalletConvertArgs),
}

#[derive(Clone, PartialEq, Eq, Debug, Parser)]
#[command(propagate_version = true)]
pub struct WalletArgs {
#[command(subcommand)]
pub command: WalletAction,
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Args)]
pub struct WalletNewArgs {
/// The type of wallet to create.
#[arg(long = "format", verbatim_doc_comment)]
pub wallet_format: Option<String>,

/// The name of the wallet to create.
#[arg(long = "outfile", verbatim_doc_comment)]
pub outfile: Option<String>,
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Args)]
pub struct WalletConvertArgs {
#[arg(long = "in-format", verbatim_doc_comment)]
pub from: String,

#[arg(long = "out-format", verbatim_doc_comment)]
pub to: String,

#[arg(long = "infile", verbatim_doc_comment)]
pub infile: Option<String>,

#[arg(long = "outfile", verbatim_doc_comment)]
pub outfile: Option<String>,
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Args)]
pub struct WalletBech32Args {
#[arg(long = "encode", verbatim_doc_comment)]
pub hex_address: Option<String>,
#[arg(long = "decode", verbatim_doc_comment)]
pub bech32_address: Option<String>,
}
9 changes: 9 additions & 0 deletions framework/meta/src/cli/cli_standalone_main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use crate::cli::{StandaloneCliAction, StandaloneCliArgs};
use crate::cmd::retrieve_address::retrieve_address;
use crate::cmd::wallet::wallet;
use clap::Parser;

use crate::cmd::all::call_all_meta;
use crate::cmd::code_report::report;
use crate::cmd::info::call_info;
use crate::cmd::install::install;
use crate::cmd::local_deps::local_deps;
use crate::cmd::scen_test_gen::test_gen_tool;
use crate::cmd::template::{create_contract, print_template_names};
use crate::cmd::test::test;
use crate::cmd::test_coverage::test_coverage;

use crate::cmd::upgrade::upgrade_sc;

/// Entry point in the program when calling it as a standalone tool.
Expand All @@ -35,12 +38,18 @@ pub async fn cli_main_standalone() {
Some(StandaloneCliAction::TestCoverage(args)) => {
test_coverage(args);
},
Some(StandaloneCliAction::CodeReportGen(args)) => {
report(args);
},
Some(StandaloneCliAction::Account(args)) => {
retrieve_address(args).await;
},
Some(StandaloneCliAction::LocalDeps(args)) => {
local_deps(args);
},
Some(StandaloneCliAction::Wallet(args)) => {
wallet(args);
},
None => {},
}
}
2 changes: 2 additions & 0 deletions framework/meta/src/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod all;
pub mod code_report;
pub mod info;
pub mod install;
pub mod local_deps;
Expand All @@ -9,3 +10,4 @@ pub mod template;
pub mod test;
pub mod test_coverage;
pub mod upgrade;
pub mod wallet;
15 changes: 15 additions & 0 deletions framework/meta/src/cmd/code_report.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pub mod compare;
pub mod generate_report;
pub mod render_code_report;

use generate_report::{compare_report, convert_report, create_report};

use crate::cli::{CodeReportAction, CodeReportArgs};

pub fn report(args: &CodeReportArgs) {
match &args.command {
CodeReportAction::Compile(compile_args) => create_report(compile_args),
CodeReportAction::Compare(compare_args) => compare_report(compare_args),
CodeReportAction::Convert(convert_args) => convert_report(convert_args),
}
}
Loading
Loading