-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #936 from multiversx/sc-upgrade
SC upgrade tool
- Loading branch information
Showing
127 changed files
with
1,045 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# Standard modules for Elrond smart contracts | ||
|
||
[![Crates.io](https://img.shields.io/crates/v/multiversx-sc-modules)](https://crates.io/crates/multiversx-sc-modules) | ||
|
||
This crate contains several smart contract modules developed by the Elrond team, which can be used to add standard functionality to any smart contract. | ||
|
||
It is enough to add the module traits as supertraits of the contract traits to receive all endpoints and all functionality from the modules in contracts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
use clap::{ArgAction, Args}; | ||
|
||
#[derive(Clone, PartialEq, Eq, Debug, Args)] | ||
pub struct BuildArgs { | ||
/// Adds debug symbols in the resulting WASM binary. Adds bloat, but helps with debugging. Do not use in production. | ||
#[arg(long = "wasm-symbols", verbatim_doc_comment)] | ||
pub wasm_symbols: bool, | ||
|
||
/// Overrides the main contract output name. | ||
#[arg(long = "wasm-name", verbatim_doc_comment)] | ||
pub wasm_name_override: Option<String>, | ||
|
||
/// Adds given suffix to all built contracts. | ||
#[arg(long = "wasm-suffix", verbatim_doc_comment)] | ||
pub wasm_name_suffix: Option<String>, | ||
|
||
/// True if wasm-opt should be used. | ||
#[arg( | ||
long = "no-wasm-opt", | ||
help = "Skips applying the wasm-opt tool after building the contracts.", | ||
action = ArgAction::SetFalse, | ||
)] | ||
pub wasm_opt: bool, | ||
|
||
/// Also generate a WAT file when building. | ||
#[arg(long = "wat", verbatim_doc_comment)] | ||
pub wat: bool, | ||
|
||
#[arg( | ||
long = "no-imports", | ||
help = "Skips extracting the EI imports after building the contracts.", | ||
action = ArgAction::SetFalse, | ||
)] | ||
pub extract_imports: bool, | ||
|
||
/// Allows specifying the target directory where the Rust compiler will build the intermediary files. | ||
/// Sharing the same target directory can speed up building multiple contract crates at once. | ||
#[arg(long = "target-dir", verbatim_doc_comment)] | ||
pub target_dir: Option<String>, | ||
|
||
/// Generate a twiggy top report after building. | ||
#[arg(long = "twiggy-top", verbatim_doc_comment)] | ||
pub twiggy_top: bool, | ||
|
||
/// Generate a twiggy paths report after building. | ||
#[arg(long = "twiggy-paths", verbatim_doc_comment)] | ||
pub twiggy_paths: bool, | ||
|
||
/// Generate a twiggy monos report after building. | ||
#[arg(long = "twiggy-monos", verbatim_doc_comment)] | ||
pub twiggy_monos: bool, | ||
|
||
/// Generate a twiggy dominators report after building. | ||
#[arg(long = "twiggy-dominators", verbatim_doc_comment)] | ||
pub twiggy_dominators: bool, | ||
|
||
/// Backwards compatibility with mxpy, delete when github actions are fixed. | ||
#[deprecated] | ||
#[arg(long = "target", verbatim_doc_comment)] | ||
pub target: Option<String>, | ||
|
||
/// Backwards compatibility with mxpy, delete when github actions are fixed. | ||
#[deprecated] | ||
#[arg(long, verbatim_doc_comment)] | ||
pub release: bool, | ||
|
||
/// Backwards compatibility with mxpy, delete when github actions are fixed. | ||
#[deprecated] | ||
#[arg(long = "out-dir", verbatim_doc_comment)] | ||
pub out_dir: Option<String>, | ||
} | ||
|
||
impl Default for BuildArgs { | ||
#[allow(deprecated)] | ||
fn default() -> Self { | ||
BuildArgs { | ||
wasm_symbols: false, | ||
wasm_name_override: None, | ||
wasm_name_suffix: None, | ||
wasm_opt: true, | ||
wat: false, | ||
extract_imports: true, | ||
target_dir: None, | ||
twiggy_top: false, | ||
twiggy_paths: false, | ||
twiggy_monos: false, | ||
twiggy_dominators: false, | ||
target: None, | ||
release: false, | ||
out_dir: None, | ||
} | ||
} | ||
} | ||
|
||
impl BuildArgs { | ||
/// Base config when calling `cargo run build-dbg`, with no additional configs. | ||
pub fn into_dbg(self) -> Self { | ||
BuildArgs { | ||
wasm_symbols: true, | ||
wasm_name_suffix: Some("dbg".to_string()), | ||
wasm_opt: false, | ||
wat: true, | ||
extract_imports: false, | ||
..self | ||
} | ||
} | ||
|
||
/// Base config when calling `cargo run build-dbg`, with no additional configs. | ||
pub fn into_twiggy(self) -> Self { | ||
BuildArgs { | ||
twiggy_top: true, | ||
twiggy_paths: true, | ||
twiggy_monos: true, | ||
twiggy_dominators: true, | ||
..self.into_dbg() | ||
} | ||
} | ||
|
||
pub fn has_twiggy_call(&self) -> bool { | ||
self.twiggy_top || self.twiggy_paths || self.twiggy_monos || self.twiggy_dominators | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use clap::{ArgAction, Args, Parser, Subcommand}; | ||
|
||
use super::BuildArgs; | ||
|
||
/// Parsed arguments of the meta crate CLI. | ||
#[derive(Default, PartialEq, Eq, Debug, Parser)] | ||
#[command( | ||
version, | ||
about, | ||
after_help = " | ||
The MultiversX smart contract Meta crate can be used in two ways: | ||
A. Import it into a contract's specific meta-crate. | ||
There it will receive access to the contract ABI generator. | ||
Based on that it is able to build the contract and apply various tools. | ||
This part also contains the multi-contract config infrastructure. | ||
B. Use it as a standalone tool. | ||
It can be used to automatically upgrade contracts from one version to the next. | ||
You are currently using the contract tool (A). | ||
" | ||
)] | ||
#[command(propagate_version = true)] | ||
pub struct ContractCliArgs { | ||
#[command(subcommand)] | ||
pub command: ContractCliAction, | ||
|
||
#[arg( | ||
long = "no-abi-git-version", | ||
help = "Skips loading the Git version into the ABI", | ||
action = ArgAction::SetFalse | ||
)] | ||
#[clap(global = true)] | ||
pub load_abi_git_version: bool, | ||
} | ||
|
||
#[derive(Default, Clone, PartialEq, Eq, Debug, Subcommand)] | ||
pub enum ContractCliAction { | ||
#[default] | ||
#[command(name = "abi", about = "Generates the contract ABI and nothing else.")] | ||
Abi, | ||
|
||
#[command( | ||
name = "build", | ||
about = "Builds contract(s) for deploy on the blockchain." | ||
)] | ||
Build(BuildArgs), | ||
|
||
#[command(name = "build-dbg", about = "Builds contract(s) with symbols and WAT.")] | ||
BuildDbg(BuildArgs), | ||
|
||
#[command( | ||
name = "twiggy", | ||
about = "Builds contract(s) and generate twiggy reports." | ||
)] | ||
Twiggy(BuildArgs), | ||
|
||
#[command(about = "Clean the Rust project and the output folder.")] | ||
Clean, | ||
|
||
#[command( | ||
name = "snippets", | ||
about = "Generates a snippets project, based on the contract ABI." | ||
)] | ||
GenerateSnippets(GenerateSnippetsArgs), | ||
} | ||
|
||
#[derive(Default, Clone, PartialEq, Eq, Debug, Args)] | ||
pub struct GenerateSnippetsArgs { | ||
/// Override snippets project if it already exists. | ||
#[arg(long, verbatim_doc_comment)] | ||
pub overwrite: bool, | ||
} |
Oops, something went wrong.