diff --git a/Cargo.lock b/Cargo.lock index 0b681b57..1abca13e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -534,6 +534,35 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" +[[package]] +name = "enshrine-esdt-safe" +version = "0.0.0" +dependencies = [ + "bls-signature", + "fee-market", + "header-verifier", + "hex", + "max-bridged-amount-module", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "setup-phase", + "token-whitelist", + "transaction", + "tx-batch-module", + "utils", +] + +[[package]] +name = "enshrine-esdt-safe-meta" +version = "0.0.0" +dependencies = [ + "enshrine-esdt-safe", + "multiversx-sc-meta", +] + [[package]] name = "equivalent" version = "1.0.1" diff --git a/Cargo.toml b/Cargo.toml index f2d4c760..e539e782 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,4 +14,6 @@ members = [ "router-mock/meta", "header-verifier", "header-verifier/meta", + "enshrine-esdt-safe", + "enshrine-esdt-safe/meta" ] diff --git a/common/utils/src/lib.rs b/common/utils/src/lib.rs index 61ed078e..810c1be9 100644 --- a/common/utils/src/lib.rs +++ b/common/utils/src/lib.rs @@ -65,4 +65,18 @@ pub trait UtilsModule: bls_signature::BlsSignatureModule { list } + + fn has_sov_token_prefix(&self, token_id: &TokenIdentifier) -> bool { + let dash = b'-'; + let mut array_buffer = [0u8, 30]; + let slice = token_id.as_managed_buffer().load_to_byte_array(&mut array_buffer); + + let counter = slice.iter().filter(|&&c| c == dash).count(); + + if counter == 2 { + return true + } + + false + } } diff --git a/enshrine-esdt-safe/Cargo.lock b/enshrine-esdt-safe/Cargo.lock new file mode 100644 index 00000000..26567031 --- /dev/null +++ b/enshrine-esdt-safe/Cargo.lock @@ -0,0 +1,2513 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "backtrace" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bip39" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" +dependencies = [ + "bitcoin_hashes", + "rand 0.8.5", + "rand_core 0.6.4", + "serde", + "unicode-normalization", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bstr" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys 0.48.0", +] + +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "copy_dir" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "543d1dd138ef086e2ff05e3a48cf9da045da2033d16f8538fd76b86cd49b2ca3" +dependencies = [ + "walkdir", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "enshrine-esdt-safe" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "multiversx-sc-scenario", + "num-bigint", +] + +[[package]] +name = "enshrine-esdt-safe-meta" +version = "0.0.0" +dependencies = [ + "enshrine-esdt-safe", + "multiversx-sc-meta", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "flate2" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "globset" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "h2" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "serde", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "hyper" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "ignore" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", + "serde", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "lockfree-object-pool" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.48.0", +] + +[[package]] +name = "multiversx-chain-scenario-format" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9190bdd56300e801e7793fc4ee7dc0c76c1149aac019da8c71cc58254966fe" +dependencies = [ + "bech32", + "hex", + "num-bigint", + "num-traits", + "serde", + "serde_json", + "sha3", +] + +[[package]] +name = "multiversx-chain-vm" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f69520691466bc184475320c27db21137e68be5e959df25c1a14b09e055d0d58" +dependencies = [ + "bitflags 2.5.0", + "colored", + "ed25519-dalek", + "hex", + "hex-literal", + "itertools", + "multiversx-chain-vm-executor", + "num-bigint", + "num-traits", + "rand 0.8.5", + "rand_seeder", + "sha2 0.10.8", + "sha3", +] + +[[package]] +name = "multiversx-chain-vm-executor" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b59072fa0624b55ae5ae3fa6bfa91515bbeb4ac440214bc4a509e2c8806d6e9f" + +[[package]] +name = "multiversx-sc" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d79d1cea2d23e8f2545749c9b31952305b54c415af88b224b985784d3d6529d" +dependencies = [ + "bitflags 2.5.0", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c94397b2fba14e40edfa55905b3f453ed57aa06c9b1960ad6a0ca6bfb7a236" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "num-bigint", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf72a8042da0bc19da0b8f0d4f61b4c66ae853560fefc69cd8fea87bf1aa8c14" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54e6926e181f6306b69aa805b8d24aa33084497e38ac03e37df457456b6757cc" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-meta" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07fe6edb214529678c77e82e25d9495b04773d489c441ef49fc19ad0664504f3" +dependencies = [ + "clap", + "colored", + "common-path", + "convert_case", + "copy_dir", + "hex", + "lazy_static", + "multiversx-sc", + "pathdiff", + "reqwest", + "ruplacer", + "rustc_version", + "semver", + "serde", + "serde_json", + "toml", + "wasmparser", + "wasmprinter", + "zip", +] + +[[package]] +name = "multiversx-sc-scenario" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dd07e4626e551c051f3065c0b2b44047d3281c20cdbcef9375aecb5f9fd5307" +dependencies = [ + "base64", + "bech32", + "clap", + "colored", + "hex", + "itertools", + "log", + "multiversx-chain-scenario-format", + "multiversx-chain-vm", + "multiversx-chain-vm-executor", + "multiversx-sc", + "multiversx-sc-meta", + "multiversx-sdk", + "num-bigint", + "num-traits", + "pathdiff", + "serde", + "serde_json", + "sha2 0.10.8", + "tokio", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sdk" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cb2f8dd4a17ce9c9fa1ab3d80152929702968be6536499f32bd7e2278c2e0fb" +dependencies = [ + "anyhow", + "base64", + "bech32", + "bip39", + "hex", + "hmac", + "itertools", + "pbkdf2", + "pem", + "rand 0.8.5", + "reqwest", + "serde", + "serde_json", + "serde_repr", + "sha2 0.10.8", + "sha3", + "tokio", + "zeroize", +] + +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-bigint" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.5", +] + +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64", + "serde", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.15", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_seeder" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf2890aaef0aa82719a50e808de264f9484b74b442e1a3a0e5ee38243ac40bdb" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "reqwest" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "ruplacer" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58a26a1b15ff113d31d139357f7422708312978ed69cd5dd47e36d1b80b7eaf3" +dependencies = [ + "Inflector", + "anyhow", + "clap", + "colored", + "ignore", + "regex", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +dependencies = [ + "bitflags 2.5.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" + +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "2.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "thiserror" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + +[[package]] +name = "unwrap-infallible" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "wasmparser" +version = "0.208.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd921789c9dcc495f589cb37d200155dee65b4a4beeb853323b5e24e0a5f9c58" +dependencies = [ + "ahash", + "bitflags 2.5.0", + "hashbrown", + "indexmap", + "semver", + "serde", +] + +[[package]] +name = "wasmprinter" +version = "0.208.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700bdace4821e6c694617938500ae9999946df464bb13219c16570f8b6f202f" +dependencies = [ + "anyhow", + "wasmparser", +] + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "zerocopy" +version = "0.7.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zip" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd56a4d5921bc2f99947ac5b3abe5f510b1be7376fdc5e9fce4a23c6a93e87c" +dependencies = [ + "arbitrary", + "crc32fast", + "crossbeam-utils", + "displaydoc", + "flate2", + "indexmap", + "memchr", + "thiserror", + "zopfli", +] + +[[package]] +name = "zopfli" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" +dependencies = [ + "bumpalo", + "crc32fast", + "lockfree-object-pool", + "log", + "once_cell", + "simd-adler32", +] diff --git a/enshrine-esdt-safe/Cargo.toml b/enshrine-esdt-safe/Cargo.toml new file mode 100644 index 00000000..aa3f4b4c --- /dev/null +++ b/enshrine-esdt-safe/Cargo.toml @@ -0,0 +1,50 @@ +[package] +name = "enshrine-esdt-safe" +version = "0.0.0" +authors = ["you"] +edition = "2021" +publish = false + +[lib] +path = "src/lib.rs" + +[dependencies.transaction] +path = "../common/transaction" + +[dependencies.tx-batch-module] +path = "../common/tx-batch-module" + +[dependencies.max-bridged-amount-module] +path = "../common/max-bridged-amount-module" + +[dependencies.bls-signature] +path = "../common/bls-signature" + +[dependencies.setup-phase] +path = "../common/setup-phase" + +[dependencies.token-whitelist] +path = "../common/token-whitelist" + +[dependencies.utils] +path = "../common/utils" + +[dependencies.fee-market] +path = "../fee-market" + +[dependencies.header-verifier] +path = "../header-verifier" + +[dependencies.multiversx-sc] +version = "=0.50.4" + +[dependencies.multiversx-sc-modules] +version = "=0.50.4" + +[dev-dependencies] +num-bigint = "0.4.2" +num-traits = "0.2" +hex = "0.4" + +[dev-dependencies.multiversx-sc-scenario] +version = "=0.50.4" diff --git a/enshrine-esdt-safe/meta/Cargo.toml b/enshrine-esdt-safe/meta/Cargo.toml new file mode 100644 index 00000000..cb30e0a4 --- /dev/null +++ b/enshrine-esdt-safe/meta/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "enshrine-esdt-safe-meta" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies.enshrine-esdt-safe] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.50.4" +default-features = false diff --git a/enshrine-esdt-safe/meta/src/main.rs b/enshrine-esdt-safe/meta/src/main.rs new file mode 100644 index 00000000..7efe7900 --- /dev/null +++ b/enshrine-esdt-safe/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/enshrine-esdt-safe/multiversx.json b/enshrine-esdt-safe/multiversx.json new file mode 100644 index 00000000..73655396 --- /dev/null +++ b/enshrine-esdt-safe/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/enshrine-esdt-safe/sc-config.toml b/enshrine-esdt-safe/sc-config.toml new file mode 100644 index 00000000..19dc9af0 --- /dev/null +++ b/enshrine-esdt-safe/sc-config.toml @@ -0,0 +1,19 @@ +[settings] +main = "main" + +[contracts.main] +name = "enshrine-esdt-safe" + +[contracts.full] +name = "enshrine-esdt-safe-full" +add-unlabelled = true +add-labels = ["enshrine-esdt-safe-external-view"] + +[contracts.view] +name = "enshrine-esdt-safe-view" +external-view = true +add-unlabelled = false +add-labels = ["enshrine-esdt-safe-external-view"] + +[[proxy]] +path = "src/enshrine_esdt_safe_proxy.rs" diff --git a/enshrine-esdt-safe/scenarios/enshrine_esdt_safe.scen.json b/enshrine-esdt-safe/scenarios/enshrine_esdt_safe.scen.json new file mode 100644 index 00000000..38013ab8 --- /dev/null +++ b/enshrine-esdt-safe/scenarios/enshrine_esdt_safe.scen.json @@ -0,0 +1,39 @@ +{ + "name": "empty", + "steps": [ + { + "step": "setState", + "accounts": { + "address:owner": { + "nonce": "1", + "balance": "0" + } + }, + "newAddresses": [ + { + "creatorAddress": "address:owner", + "creatorNonce": "1", + "newAddress": "sc:empty" + } + ] + }, + { + "step": "scDeploy", + "id": "deploy", + "tx": { + "from": "address:owner", + "contractCode": "mxsc:../output/enshrine-esdt-safe.mxsc.json", + "arguments": [""], + "gasLimit": "5,000,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "", + "logs": [], + "gas": "*", + "refund": "*" + } + } + ] +} diff --git a/enshrine-esdt-safe/src/enshrine_esdt_safe_proxy.rs b/enshrine-esdt-safe/src/enshrine_esdt_safe_proxy.rs new file mode 100644 index 00000000..a5dd5653 --- /dev/null +++ b/enshrine-esdt-safe/src/enshrine_esdt_safe_proxy.rs @@ -0,0 +1,624 @@ +// Code generated by the multiversx-sc proxy generator. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +#![allow(dead_code)] +#![allow(clippy::all)] + +use multiversx_sc::proxy_imports::*; + +pub struct EsdtSafeProxy; + +impl TxProxyTrait for EsdtSafeProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = EsdtSafeProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + EsdtSafeProxyMethods { wrapped_tx: tx } + } +} + +pub struct EsdtSafeProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl EsdtSafeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>>, + >( + self, + is_sovereign_chain: Arg0, + min_valid_signers: Arg1, + initiator_address: Arg2, + signers: Arg3, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&is_sovereign_chain) + .argument(&min_valid_signers) + .argument(&initiator_address) + .argument(&signers) + .original_result() + } +} + +#[rustfmt::skip] +impl EsdtSafeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade( + self, + ) -> TxTypedUpgrade { + self.wrapped_tx + .payment(NotPayable) + .raw_upgrade() + .original_result() + } +} + +#[rustfmt::skip] +impl EsdtSafeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn set_fee_market_address< + Arg0: ProxyArg>, + >( + self, + fee_market_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setFeeMarketAddress") + .argument(&fee_market_address) + .original_result() + } + + pub fn set_header_verifier_address< + Arg0: ProxyArg>, + >( + self, + header_verifier_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMultisigAddress") + .argument(&header_verifier_address) + .original_result() + } + + pub fn set_sovereign_bridge_address< + Arg0: ProxyArg>, + >( + self, + bridge_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setSovereignBridgeAddress") + .argument(&bridge_address) + .original_result() + } + + pub fn set_max_user_tx_gas_limit< + Arg0: ProxyArg, + Arg1: ProxyArg>>, + >( + self, + new_value: Arg0, + opt_sig: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxUserTxGasLimit") + .argument(&new_value) + .argument(&opt_sig) + .original_result() + } + + pub fn set_burn_and_mint< + Arg0: ProxyArg>>, + Arg1: ProxyArg>>, + >( + self, + opt_signature: Arg0, + tokens: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setBurnAndMint") + .argument(&opt_signature) + .argument(&tokens) + .original_result() + } + + pub fn remove_burn_and_mint< + Arg0: ProxyArg>>, + Arg1: ProxyArg>>, + >( + self, + opt_signature: Arg0, + tokens: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeBurnAndMint") + .argument(&opt_signature) + .argument(&tokens) + .original_result() + } + + pub fn add_banned_endpoint_names< + Arg0: ProxyArg>>, + Arg1: ProxyArg>>, + >( + self, + opt_signature: Arg0, + names: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addBannedEndpointNames") + .argument(&opt_signature) + .argument(&names) + .original_result() + } + + pub fn remove_banned_endpoint_names< + Arg0: ProxyArg>>, + Arg1: ProxyArg>>, + >( + self, + opt_signature: Arg0, + names: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeBannedEndpointNames") + .argument(&opt_signature) + .argument(&names) + .original_result() + } + + pub fn deposit_back< + Arg0: ProxyArg>, + >( + self, + to: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("depositBack") + .argument(&to) + .original_result() + } + + /// Create an Elrond -> Sovereign transaction. + pub fn deposit< + Arg0: ProxyArg>, + Arg1: ProxyArg, ManagedVec>>>>, + >( + self, + to: Arg0, + opt_transfer_data: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("deposit") + .argument(&to) + .argument(&opt_transfer_data) + .original_result() + } + + /// Claim funds for failed Elrond -> Sovereign transactions. + /// These are not sent automatically to prevent the contract getting stuck. + /// For example, if the receiver is a SC, a frozen account, etc. + pub fn claim_refund< + Arg0: ProxyArg>, + >( + self, + token_id: Arg0, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("claimRefund") + .argument(&token_id) + .original_result() + } + + /// Sets the statuses for the transactions, after they were executed on the Sovereign side. + /// + /// Only TransactionStatus::Executed (3) and TransactionStatus::Rejected (4) values are allowed. + /// Number of provided statuses must be equal to number of transactions in the batch. + pub fn set_transaction_batch_status< + Arg0: ProxyArg, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + >( + self, + batch_id: Arg0, + signature: Arg1, + tx_statuses: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setTransactionBatchStatus") + .argument(&batch_id) + .argument(&signature) + .argument(&tx_statuses) + .original_result() + } + + pub fn set_min_valid_signers< + Arg0: ProxyArg, + >( + self, + new_value: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMinValidSigners") + .argument(&new_value) + .original_result() + } + + pub fn add_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addSigners") + .argument(&signers) + .original_result() + } + + pub fn remove_signers< + Arg0: ProxyArg>>, + >( + self, + signers: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeSigners") + .argument(&signers) + .original_result() + } + + pub fn register_token< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>, + Arg4: ProxyArg, + >( + self, + sov_token_id: Arg0, + token_type: Arg1, + token_display_name: Arg2, + token_ticker: Arg3, + num_decimals: Arg4, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("registerToken") + .argument(&sov_token_id) + .argument(&token_type) + .argument(&token_display_name) + .argument(&token_ticker) + .argument(&num_decimals) + .original_result() + } + + pub fn clear_registered_sovereign_token< + Arg0: ProxyArg>, + >( + self, + sov_token_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("clearRegisteredSovereignToken") + .argument(&sov_token_id) + .original_result() + } + + pub fn clear_registered_multiversx_token< + Arg0: ProxyArg>, + >( + self, + mvx_token_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("clearRegisteredMultiversxToken") + .argument(&mvx_token_id) + .original_result() + } + + pub fn execute_operations< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + hash_of_hashes: Arg0, + operation: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("executeBridgeOps") + .argument(&hash_of_hashes) + .argument(&operation) + .original_result() + } + + pub fn set_max_tx_batch_size< + Arg0: ProxyArg, + >( + self, + new_max_tx_batch_size: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxTxBatchSize") + .argument(&new_max_tx_batch_size) + .original_result() + } + + pub fn set_max_tx_batch_block_duration< + Arg0: ProxyArg, + >( + self, + new_max_tx_batch_block_duration: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxTxBatchBlockDuration") + .argument(&new_max_tx_batch_block_duration) + .original_result() + } + + pub fn get_current_tx_batch( + self, + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getCurrentTxBatch") + .original_result() + } + + pub fn get_first_batch_any_status( + self, + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getFirstBatchAnyStatus") + .original_result() + } + + pub fn get_batch< + Arg0: ProxyArg, + >( + self, + batch_id: Arg0, + ) -> TxTypedCall, ManagedAddress, ManagedVec>, ManagedVec>, Option>>>>>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getBatch") + .argument(&batch_id) + .original_result() + } + + pub fn get_batch_status< + Arg0: ProxyArg, + >( + self, + batch_id: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getBatchStatus") + .argument(&batch_id) + .original_result() + } + + pub fn first_batch_id( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getFirstBatchId") + .original_result() + } + + pub fn last_batch_id( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getLastBatchId") + .original_result() + } + + pub fn set_max_bridged_amount< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + token_id: Arg0, + max_amount: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxBridgedAmount") + .argument(&token_id) + .argument(&max_amount) + .original_result() + } + + pub fn max_bridged_amount< + Arg0: ProxyArg>, + >( + self, + token_id: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getMaxBridgedAmount") + .argument(&token_id) + .original_result() + } + + pub fn end_setup_phase( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("endSetupPhase") + .original_result() + } + + /// Tokens in the whitelist can be transferred without fees + pub fn add_tokens_to_whitelist< + Arg0: ProxyArg>>, + Arg1: ProxyArg>>, + >( + self, + opt_signature: Arg0, + tokens: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addTokensToWhitelist") + .argument(&opt_signature) + .argument(&tokens) + .original_result() + } + + pub fn remove_tokens_from_whitelist< + Arg0: ProxyArg>>, + Arg1: ProxyArg>>, + >( + self, + opt_signature: Arg0, + tokens: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeTokensFromWhitelist") + .argument(&opt_signature) + .argument(&tokens) + .original_result() + } + + /// Tokens in blacklist cannot be transferred + pub fn add_tokens_to_blacklist< + Arg0: ProxyArg>>, + Arg1: ProxyArg>>, + >( + self, + opt_signature: Arg0, + tokens: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addTokensToBlacklist") + .argument(&opt_signature) + .argument(&tokens) + .original_result() + } + + pub fn remove_tokens_from_blacklist< + Arg0: ProxyArg>>, + Arg1: ProxyArg>>, + >( + self, + opt_signature: Arg0, + tokens: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("removeTokensFromBlacklist") + .argument(&opt_signature) + .argument(&tokens) + .original_result() + } + + pub fn token_whitelist( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTokenWhitelist") + .original_result() + } + + pub fn token_blacklist( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTokenBlacklist") + .original_result() + } + + pub fn pause_endpoint( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("pause") + .original_result() + } + + pub fn unpause_endpoint( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("unpause") + .original_result() + } + + pub fn paused_status( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("isPaused") + .original_result() + } +} diff --git a/enshrine-esdt-safe/src/from_sovereign/events.rs b/enshrine-esdt-safe/src/from_sovereign/events.rs new file mode 100644 index 00000000..ec07f3a7 --- /dev/null +++ b/enshrine-esdt-safe/src/from_sovereign/events.rs @@ -0,0 +1,11 @@ +multiversx_sc::imports!(); + +#[multiversx_sc::module] +pub trait EventsModule { + #[event("executedBridgeOp")] + fn execute_bridge_operation_event( + &self, + #[indexed] hash_of_hashes: ManagedBuffer, + #[indexed] hash_of_bridge_op: ManagedBuffer, + ); +} diff --git a/enshrine-esdt-safe/src/from_sovereign/mod.rs b/enshrine-esdt-safe/src/from_sovereign/mod.rs new file mode 100644 index 00000000..8564e0ab --- /dev/null +++ b/enshrine-esdt-safe/src/from_sovereign/mod.rs @@ -0,0 +1,4 @@ +pub mod events; +pub mod refund; +pub mod token_mapping; +pub mod transfer_tokens; diff --git a/enshrine-esdt-safe/src/from_sovereign/refund.rs b/enshrine-esdt-safe/src/from_sovereign/refund.rs new file mode 100644 index 00000000..8957dc72 --- /dev/null +++ b/enshrine-esdt-safe/src/from_sovereign/refund.rs @@ -0,0 +1,105 @@ +use transaction::{BatchId, OperationEsdtPayment, PaymentsVec, Transaction, TxNonce}; + +multiversx_sc::imports!(); + +const NFT_AMOUNT: u32 = 1; + +pub struct CheckMustRefundArgs<'a, M: ManagedTypeApi> { + pub token: &'a OperationEsdtPayment, + pub roles: EsdtLocalRoleFlags, + pub dest: &'a ManagedAddress, + pub batch_id: BatchId, + pub tx_nonce: TxNonce, + pub sc_address: &'a ManagedAddress, + pub sc_shard: u32, +} + +#[multiversx_sc::module] +pub trait RefundModule: + super::events::EventsModule + + tx_batch_module::TxBatchModule + + max_bridged_amount_module::MaxBridgedAmountModule +{ + fn check_must_refund(&self, args: CheckMustRefundArgs) -> bool { + let token_balance = self.blockchain().get_esdt_balance( + args.sc_address, + &args.token.token_identifier, + args.token.token_nonce, + ); + + if token_balance < args.token.token_data.amount { + if args.token.token_nonce == 0 { + if !args.roles.has_role(&EsdtLocalRole::Mint) { + return true; + } + } else if !self.has_nft_roles(args.token, args.roles) { + return true; + } + } + + if self.is_above_max_amount(&args.token.token_identifier, &args.token.token_data.amount) { + return true; + } + + if self.is_account_same_shard_frozen(args.sc_shard, args.dest, &args.token.token_identifier) + { + return true; + } + + false + } + + fn has_nft_roles( + &self, + payment: &OperationEsdtPayment, + roles: EsdtLocalRoleFlags, + ) -> bool { + if !roles.has_role(&EsdtLocalRole::NftCreate) { + return false; + } + + if payment.token_data.amount > NFT_AMOUNT && !roles.has_role(&EsdtLocalRole::NftAddQuantity) + { + return false; + } + + true + } + + fn is_account_same_shard_frozen( + &self, + sc_shard: u32, + dest_address: &ManagedAddress, + token_id: &TokenIdentifier, + ) -> bool { + let dest_shard = self.blockchain().get_shard_of_address(dest_address); + if sc_shard != dest_shard { + return false; + } + + let token_data = self + .blockchain() + .get_esdt_token_data(dest_address, token_id, 0); + token_data.frozen + } + + fn convert_to_refund_tx( + &self, + sov_tx: Transaction, + tokens_to_refund: PaymentsVec, + ) -> Transaction { + let tx_nonce = self.get_and_save_next_tx_id(); + + // invert from and to + Transaction { + block_nonce: self.blockchain().get_block_nonce(), + nonce: tx_nonce, + from: sov_tx.to, + to: sov_tx.from, + tokens: tokens_to_refund, + token_data: ManagedVec::new(), + opt_transfer_data: None, + is_refund_tx: true, + } + } +} diff --git a/enshrine-esdt-safe/src/from_sovereign/token_mapping.rs b/enshrine-esdt-safe/src/from_sovereign/token_mapping.rs new file mode 100644 index 00000000..fa825d0e --- /dev/null +++ b/enshrine-esdt-safe/src/from_sovereign/token_mapping.rs @@ -0,0 +1,154 @@ +const DEFAULT_ISSUE_COST: u64 = 50000000000000000; +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, ManagedVecItem, Clone)] +pub struct EsdtTokenInfo { + pub token_identifier: TokenIdentifier, + pub token_nonce: u64, +} + +#[multiversx_sc::module] +pub trait TokenMappingModule: + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule +{ + #[payable("EGLD")] + #[endpoint(registerToken)] + fn register_token( + &self, + sov_token_id: TokenIdentifier, + token_type: EsdtTokenType, + token_display_name: ManagedBuffer, + token_ticker: ManagedBuffer, + num_decimals: usize, + ) { + require!( + !self.is_sovereign_chain().get(), + "Invalid method to call in current chain" + ); + + let issue_cost = self.call_value().egld_value().clone_value(); + + require!(issue_cost == DEFAULT_ISSUE_COST, "eGLD value should be 0.5"); + + match token_type { + EsdtTokenType::Invalid => sc_panic!("Invalid type"), + EsdtTokenType::Fungible => self.handle_fungible_token_type( + sov_token_id.clone(), + issue_cost, + token_display_name, + token_ticker, + num_decimals, + ), + _ => self.handle_nonfungible_token_type( + sov_token_id.clone(), + token_type, + issue_cost, + token_display_name, + token_ticker, + num_decimals, + ), + } + + match self.sovereign_to_multiversx_token_id(&sov_token_id).get() { + TokenMapperState::NotSet => sc_panic!("Token ID not set"), + TokenMapperState::Pending => {} + TokenMapperState::Token(mx_token_id) => { + self.multiversx_to_sovereign_token_id(&mx_token_id) + .set(sov_token_id); + } + } + } + + fn handle_fungible_token_type( + &self, + sov_token_id: TokenIdentifier, + issue_cost: BigUint, + token_display_name: ManagedBuffer, + token_ticker: ManagedBuffer, + num_decimals: usize, + ) { + self.multiversx_to_sovereign_token_id(&sov_token_id) + .set(sov_token_id.clone()); + + self.fungible_token(&sov_token_id).issue_and_set_all_roles( + issue_cost, + token_display_name, + token_ticker, + num_decimals, + None, + ); + } + + fn handle_nonfungible_token_type( + &self, + sov_token_id: TokenIdentifier, + token_type: EsdtTokenType, + issue_cost: BigUint, + token_display_name: ManagedBuffer, + token_ticker: ManagedBuffer, + num_decimals: usize, + ) { + self.multiversx_to_sovereign_token_id(&sov_token_id) + .set(sov_token_id.clone()); + + self.non_fungible_token(&sov_token_id) + .issue_and_set_all_roles( + token_type, + issue_cost, + token_display_name, + token_ticker, + num_decimals, + None, + ); + } + + #[only_owner] + #[endpoint(clearRegisteredSovereignToken)] + fn clear_registered_sovereign_token(&self, sov_token_id: TokenIdentifier) { + self.sovereign_to_multiversx_token_id(&sov_token_id).clear(); + } + + #[only_owner] + #[endpoint(clearRegisteredMultiversxToken)] + fn clear_registered_multiversx_token(&self, mvx_token_id: TokenIdentifier) { + self.multiversx_to_sovereign_token_id(&mvx_token_id).clear(); + } + + // WARNING: All mappers must have the exact same storage key! + + #[storage_mapper("sovToMxTokenId")] + fn sovereign_to_multiversx_token_id( + &self, + sov_token_id: &TokenIdentifier, + ) -> SingleValueMapper>; + + #[storage_mapper("mxToSovTokenId")] + fn multiversx_to_sovereign_token_id( + &self, + mx_token_id: &TokenIdentifier, + ) -> SingleValueMapper; + + #[storage_mapper("sovToMxTokenId")] + fn fungible_token(&self, sov_token_id: &TokenIdentifier) -> FungibleTokenMapper; + + #[storage_mapper("sovToMxTokenId")] + fn non_fungible_token(&self, sov_token_id: &TokenIdentifier) -> NonFungibleTokenMapper; + + #[storage_mapper("sovEsdtTokenInfoMapper")] + fn sovereign_esdt_token_info_mapper( + &self, + token_identifier: &TokenIdentifier, + nonce: &u64, + ) -> SingleValueMapper>; + + #[storage_mapper("mxEsdtTokenInfoMapper")] + fn multiversx_esdt_token_info_mapper( + &self, + token_identifier: &TokenIdentifier, + nonce: &u64, + ) -> SingleValueMapper>; + + #[storage_mapper("isSovereignChain")] + fn is_sovereign_chain(&self) -> SingleValueMapper; +} diff --git a/enshrine-esdt-safe/src/from_sovereign/transfer_tokens.rs b/enshrine-esdt-safe/src/from_sovereign/transfer_tokens.rs new file mode 100644 index 00000000..3a1b1cc1 --- /dev/null +++ b/enshrine-esdt-safe/src/from_sovereign/transfer_tokens.rs @@ -0,0 +1,348 @@ +use multiversx_sc::{api::ESDT_MULTI_TRANSFER_FUNC_NAME, storage::StorageKey}; +use transaction::{ + BatchId, GasLimit, Operation, OperationData, OperationEsdtPayment, OperationTuple, +}; + +use crate::to_sovereign; + +use super::token_mapping::EsdtTokenInfo; + +multiversx_sc::imports!(); + +const CALLBACK_GAS: GasLimit = 10_000_000; // Increase if not enough +const TRANSACTION_GAS: GasLimit = 30_000_000; + +#[multiversx_sc::module] +pub trait TransferTokensModule: + bls_signature::BlsSignatureModule + + super::events::EventsModule + + super::refund::RefundModule + + super::token_mapping::TokenMappingModule + + tx_batch_module::TxBatchModule + + max_bridged_amount_module::MaxBridgedAmountModule + + multiversx_sc_modules::pause::PauseModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + utils::UtilsModule + + to_sovereign::events::EventsModule +{ + #[endpoint(executeBridgeOps)] + fn execute_operations(&self, hash_of_hashes: ManagedBuffer, operation: Operation) { + require!( + !self.is_sovereign_chain().get(), + "Invalid method to call in current chain" + ); + + require!(self.not_paused(), "Cannot transfer while paused"); + + let (operation_hash, is_registered) = + self.calculate_operation_hash(hash_of_hashes.clone(), operation.clone()); + + if !is_registered { + sc_panic!("Operation is not registered"); + } + + let minted_operation_tokens = self.mint_tokens(&operation.tokens); + let operation_tuple = OperationTuple { + op_hash: operation_hash, + operation, + }; + + self.distribute_payments(hash_of_hashes, operation_tuple, minted_operation_tokens); + } + + fn mint_tokens( + &self, + operation_tokens: &ManagedVec>, + ) -> ManagedVec> { + let mut output_payments = ManagedVec::new(); + + for operation_token in operation_tokens.iter() { + if !self.has_sov_token_prefix(&operation_token.token_identifier) { + output_payments.push(operation_token.clone()); + continue; + } + + let mut nonce = operation_token.token_nonce; + if nonce == 0 { + self.send().esdt_local_mint( + &operation_token.token_identifier, + operation_token.token_nonce, + &operation_token.token_data.amount, + ); + } else { + nonce = self.send().esdt_nft_create( + &operation_token.token_identifier, + &operation_token.token_data.amount, + &operation_token.token_data.name, + &operation_token.token_data.royalties, + &operation_token.token_data.hash, + &operation_token.token_data.attributes, + &operation_token.token_data.uris, + ); + + // let token_data = operation_token.token_data.clone(); + // let mut arg_buffer = ManagedArgBuffer::new(); + // arg_buffer.push_arg(&operation_token.token_identifier); + // arg_buffer.push_arg(token_data.amount); + // arg_buffer.push_arg(token_data.name); + // arg_buffer.push_arg(token_data.royalties); + // arg_buffer.push_arg(token_data.hash); + // arg_buffer.push_arg(token_data.attributes); + // let uris = token_data.uris.clone(); + + // if uris.is_empty() { + // // at least one URI is required, so we push an empty one + // arg_buffer.push_arg(codec::Empty); + // } else { + // // The API function has the last argument as variadic, + // // so we top-encode each and send as separate argument + // for uri in &uris { + // arg_buffer.push_arg(uri); + // } + // } + // arg_buffer.push_arg(operation_token.token_nonce); + + // self.send_raw().call_local_esdt_built_in_function( + // self.blockchain().get_gas_left(), + // &ManagedBuffer::from(ESDT_NFT_CREATE_FUNC_NAME), + // &arg_buffer, + // ); + } + + output_payments.push(OperationEsdtPayment { + token_identifier: operation_token.token_identifier, + token_nonce: nonce, + token_data: operation_token.token_data, + }); + } + + output_payments + } + + fn mint_and_save_token( + self, + mx_token_id: &TokenIdentifier, + operation_token: &OperationEsdtPayment, + ) -> u64 { + // mint NFT + let nft_nonce = self.send().esdt_nft_create( + mx_token_id, + &operation_token.token_data.amount, + &operation_token.token_data.name, + &operation_token.token_data.royalties, + &operation_token.token_data.hash, + &operation_token.token_data.attributes, + &operation_token.token_data.uris, + ); + + // save token id and nonce + self.sovereign_esdt_token_info_mapper( + &operation_token.token_identifier, + &operation_token.token_nonce, + ) + .set(EsdtTokenInfo { + token_identifier: mx_token_id.clone(), + token_nonce: nft_nonce, + }); + + self.multiversx_esdt_token_info_mapper(mx_token_id, &nft_nonce) + .set(EsdtTokenInfo { + token_identifier: operation_token.token_identifier.clone(), + token_nonce: operation_token.token_nonce, + }); + + nft_nonce + } + + fn distribute_payments( + &self, + hash_of_hashes: ManagedBuffer, + operation_tuple: OperationTuple, + tokens_list: ManagedVec>, + ) { + let mapped_tokens = tokens_list.iter().map(|token| token.into()).collect(); + + match &operation_tuple.operation.data.opt_transfer_data { + Some(transfer_data) => { + let mut args = ManagedArgBuffer::new(); + for arg in &transfer_data.args { + args.push_arg(arg); + } + + self.send() + .contract_call::<()>( + operation_tuple.operation.to.clone(), + transfer_data.function.clone(), + ) + .with_raw_arguments(args) + .with_multi_token_transfer(mapped_tokens) + .with_gas_limit(transfer_data.gas_limit) + .async_call_promise() + .with_extra_gas_for_callback(CALLBACK_GAS) + .with_callback( + ::callbacks(self) + .execute(&hash_of_hashes, &operation_tuple), + ) + .register_promise(); + } + None => { + let own_address = self.blockchain().get_sc_address(); + + self.send() + .contract_call::<()>(own_address, ESDT_MULTI_TRANSFER_FUNC_NAME) + .with_raw_arguments( + self.get_contract_call_args(&operation_tuple.operation.to, mapped_tokens), + ) + .with_gas_limit(TRANSACTION_GAS) + .async_call_promise() + .with_callback( + ::callbacks(self) + .execute(&hash_of_hashes, &operation_tuple), + ) + .register_promise(); + } + } + } + + fn get_contract_call_args( + self, + to: &ManagedAddress, + mapped_tokens: ManagedVec>, + ) -> ManagedArgBuffer { + let mut args = ManagedArgBuffer::new(); + args.push_arg(to); + args.push_arg(mapped_tokens.len()); + + for token in &mapped_tokens { + args.push_arg(token.token_identifier); + args.push_arg(token.token_nonce); + args.push_arg(token.amount); + } + + args + } + + #[promises_callback] + fn execute( + &self, + hash_of_hashes: &ManagedBuffer, + operation_tuple: &OperationTuple, + #[call_result] result: ManagedAsyncCallResult, + ) { + match result { + ManagedAsyncCallResult::Ok(_) => { + self.execute_bridge_operation_event( + hash_of_hashes.clone(), + operation_tuple.op_hash.clone(), + ); + } + ManagedAsyncCallResult::Err(_) => { + self.emit_transfer_failed_events(hash_of_hashes, operation_tuple); + } + } + + let _: () = self + .header_verifier_proxy(self.header_verifier_address().get()) + .remove_executed_hash(hash_of_hashes, &operation_tuple.op_hash) + .execute_on_dest_context(); + } + + fn emit_transfer_failed_events( + &self, + hash_of_hashes: &ManagedBuffer, + operation_tuple: &OperationTuple, + ) { + // confirmation event + self.execute_bridge_operation_event( + hash_of_hashes.clone(), + operation_tuple.op_hash.clone(), + ); + + for operation_token in &operation_tuple.operation.tokens { + let mx_token_id_state = self + .sovereign_to_multiversx_token_id(&operation_token.token_identifier) + .get(); + + if let TokenMapperState::Token(mx_token_id) = mx_token_id_state { + let mut mx_token_nonce = 0; + + if operation_token.token_nonce > 0 { + mx_token_nonce = self + .sovereign_esdt_token_info_mapper( + &operation_token.token_identifier, + &operation_token.token_nonce, + ) + .take() + .token_nonce; + + self.multiversx_esdt_token_info_mapper(&mx_token_id, &mx_token_nonce); + } + + self.send().esdt_local_burn( + &mx_token_id, + mx_token_nonce, + &operation_token.token_data.amount, + ); + } + } + + // deposit back mainchain tokens into user account + let sc_address = self.blockchain().get_sc_address(); + let tx_nonce = self.get_and_save_next_tx_id(); + + self.deposit_event( + &operation_tuple.operation.data.op_sender, + &operation_tuple.operation.get_tokens_as_tuple_arr(), + OperationData { + op_nonce: tx_nonce, + op_sender: sc_address.clone(), + opt_transfer_data: None, + }, + ); + } + + // use pending_operations as param + fn calculate_operation_hash( + &self, + hash_of_hashes: ManagedBuffer, + operation: Operation, + ) -> (ManagedBuffer, bool) { + let mut serialized_data = ManagedBuffer::new(); + let mut storage_key = StorageKey::from("pending_hashes"); + storage_key.append_item(&hash_of_hashes); + + let pending_operations_mapper = + UnorderedSetMapper::new_from_address(self.header_verifier_address().get(), storage_key); + + if let core::result::Result::Err(err) = operation.top_encode(&mut serialized_data) { + sc_panic!("Transfer data encode error: {}", err.message_bytes()); + } + + let sha256 = self.crypto().sha256(&serialized_data); + let hash = sha256.as_managed_buffer().clone(); + + if pending_operations_mapper.contains(&hash) { + (hash, true) + } else { + (hash, false) + } + } + + #[proxy] + fn header_verifier_proxy( + &self, + header_verifier_address: ManagedAddress, + ) -> header_verifier::Proxy; + + #[storage_mapper("nextBatchId")] + fn next_batch_id(&self) -> SingleValueMapper; + + #[storage_mapper("pending_hashes")] + fn pending_hashes(&self, hash_of_hashes: &ManagedBuffer) -> UnorderedSetMapper; + + #[storage_mapper("header_verifier_address")] + fn header_verifier_address(&self) -> SingleValueMapper; + + #[storage_mapper("sovereign_bridge_address")] + fn sovereign_bridge_address(&self) -> SingleValueMapper; +} diff --git a/enshrine-esdt-safe/src/lib.rs b/enshrine-esdt-safe/src/lib.rs new file mode 100644 index 00000000..0553e9bb --- /dev/null +++ b/enshrine-esdt-safe/src/lib.rs @@ -0,0 +1,65 @@ +#![no_std] + +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +pub mod from_sovereign; +pub mod to_sovereign; +// pub mod esdt_safe_proxy; + +#[multiversx_sc::contract] +pub trait EsdtSafe: + to_sovereign::create_tx::CreateTxModule + + to_sovereign::events::EventsModule + + to_sovereign::refund::RefundModule + + to_sovereign::set_tx_status::SetTxStatusModule + + bls_signature::BlsSignatureModule + + from_sovereign::events::EventsModule + + from_sovereign::refund::RefundModule + + from_sovereign::token_mapping::TokenMappingModule + + from_sovereign::transfer_tokens::TransferTokensModule + + tx_batch_module::TxBatchModule + + max_bridged_amount_module::MaxBridgedAmountModule + + setup_phase::SetupPhaseModule + + token_whitelist::TokenWhitelistModule + + utils::UtilsModule + + multiversx_sc_modules::pause::PauseModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule +{ + #[init] + fn init( + &self, + is_sovereign_chain: bool, + ) { + self.is_sovereign_chain().set(is_sovereign_chain); + self.set_paused(true); + } + + #[only_owner] + #[endpoint(setFeeMarketAddress)] + fn set_fee_market_address(&self, fee_market_address: ManagedAddress) { + self.require_sc_address(&fee_market_address); + + self.fee_market_address().set(fee_market_address); + } + + #[only_owner] + #[endpoint(setMultisigAddress)] + fn set_header_verifier_address(&self, header_verifier_address: ManagedAddress) { + self.require_sc_address(&header_verifier_address); + + self.header_verifier_address().set(&header_verifier_address); + } + + #[only_owner] + #[endpoint(setSovereignBridgeAddress)] + fn set_sovereign_bridge_address(&self, bridge_address: ManagedAddress) { + self.require_sc_address(&bridge_address); + + self.sovereign_bridge_address().set(bridge_address); + } + + #[upgrade] + fn upgrade(&self) {} + +} diff --git a/enshrine-esdt-safe/src/to_sovereign/create_tx.rs b/enshrine-esdt-safe/src/to_sovereign/create_tx.rs new file mode 100644 index 00000000..7649bb89 --- /dev/null +++ b/enshrine-esdt-safe/src/to_sovereign/create_tx.rs @@ -0,0 +1,364 @@ +use crate::from_sovereign::token_mapping; +use bls_signature::BlsSignature; +use fee_market::subtract_fee::{FinalPayment, ProxyTrait as _}; +use multiversx_sc::{hex_literal::hex, storage::StorageKey}; +use transaction::{GasLimit, OperationData, TransferData}; + +multiversx_sc::imports!(); + +pub const ESDT_SYSTEM_SC_ADDRESS: [u8; 32] = + hex!("000000000000000000010000000000000000000000000000000000000002ffff"); +const MAX_TRANSFERS_PER_TX: usize = 10; + +#[multiversx_sc::module] +pub trait CreateTxModule: + super::events::EventsModule + + tx_batch_module::TxBatchModule + + max_bridged_amount_module::MaxBridgedAmountModule + + token_whitelist::TokenWhitelistModule + + bls_signature::BlsSignatureModule + + setup_phase::SetupPhaseModule + + utils::UtilsModule + + multiversx_sc_modules::pause::PauseModule + + token_mapping::TokenMappingModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule +{ + #[endpoint(setMaxUserTxGasLimit)] + fn set_max_user_tx_gas_limit( + &self, + new_value: GasLimit, + opt_sig: OptionalValue>, + ) { + if !self.is_setup_phase_complete() { + self.require_caller_initiator(); + self.max_user_tx_gas_limit().set(new_value); + + return; + } + + let opt_signature = opt_sig.into_option(); + require!(opt_signature.is_some(), "Must provide signature"); + let signature = unsafe { opt_signature.unwrap_unchecked() }; + let mut signature_data = ManagedBuffer::new(); + let _ = new_value.dep_encode(&mut signature_data); + + self.multi_verify_signature(&signature_data, &signature); + + self.max_user_tx_gas_limit().set(new_value); + } + + #[endpoint(setBurnAndMint)] + fn set_burn_and_mint( + &self, + opt_signature: Option>, + tokens: MultiValueEncoded, + ) { + if !self.is_setup_phase_complete() { + self.require_caller_initiator(); + self.burn_tokens().extend(tokens); + + return; + } + + let all_tokens = self.verify_items_signature(opt_signature, tokens); + self.burn_tokens().extend(&all_tokens); + } + + #[endpoint(removeBurnAndMint)] + fn remove_burn_and_mint( + &self, + opt_signature: Option>, + tokens: MultiValueEncoded, + ) { + if !self.is_setup_phase_complete() { + self.require_caller_initiator(); + self.remove_items(&mut self.burn_tokens(), tokens); + + return; + } + + let all_tokens = self.verify_items_signature(opt_signature, tokens); + self.remove_items(&mut self.burn_tokens(), &all_tokens); + } + + #[endpoint(addBannedEndpointNames)] + fn add_banned_endpoint_names( + &self, + opt_signature: Option>, + names: MultiValueEncoded, + ) { + if !self.is_setup_phase_complete() { + self.require_caller_initiator(); + self.banned_endpoint_names().extend(names); + + return; + } + + let all_names = self.verify_items_signature(opt_signature, names); + self.banned_endpoint_names().extend(&all_names); + } + + #[endpoint(removeBannedEndpointNames)] + fn remove_banned_endpoint_names( + &self, + opt_signature: Option>, + names: MultiValueEncoded, + ) { + if !self.is_setup_phase_complete() { + self.require_caller_initiator(); + self.remove_items(&mut self.banned_endpoint_names(), names); + + return; + } + + let all_names = self.verify_items_signature(opt_signature, names); + self.remove_items(&mut self.banned_endpoint_names(), &all_names); + } + + #[payable("*")] + #[endpoint(depositBack)] + fn deposit_back(&self, to: ManagedAddress) { + require!(self.not_paused(), "Cannot create transaction while paused"); + + let caller = self.blockchain().get_caller(); + require!(caller == ESDT_SYSTEM_SC_ADDRESS.into(), "Caller is invalid"); + + let payments = self.call_value().all_esdt_transfers(); + + require!(!payments.is_empty(), "Nothing to transfer"); + require!(payments.len() <= MAX_TRANSFERS_PER_TX, "Too many tokens"); + + self.send().direct_multi(&to, &payments); + } + + fn check_and_extract_fee( + &self, + ) -> MultiValue2, ManagedVec> { + let mut payments = self.call_value().all_esdt_transfers().clone_value(); + + require!(!payments.is_empty(), "Nothing to transfer"); + require!(payments.len() <= MAX_TRANSFERS_PER_TX, "Too many tokens"); + + let fee_market_address = self.fee_market_address().get(); + let fee_enabled_mapper = SingleValueMapper::new_from_address( + fee_market_address.clone(), + StorageKey::from("feeEnabledFlag"), + ) + .get(); + + let opt_transfer_data = if fee_enabled_mapper { + OptionalValue::Some(self.pop_first_payment(&mut payments)) + } else { + OptionalValue::None + }; + + MultiValue2::from((opt_transfer_data, payments)) + } + + fn process_transfer_data( + &self, + opt_transfer_data: OptionalValue< + MultiValue3>, + >, + ) -> Option> { + match &opt_transfer_data { + OptionalValue::Some(transfer_data) => { + let (gas_limit, function, args) = transfer_data.clone().into_tuple(); + let max_gas_limit = self.max_user_tx_gas_limit().get(); + + require!(gas_limit <= max_gas_limit, "Gas limit too high"); + + require!( + !self.banned_endpoint_names().contains(&function), + "Banned endpoint name" + ); + + Some(TransferData { + gas_limit, + function, + args, + }) + } + OptionalValue::None => None, + } + } + + /// Create an Elrond -> Sovereign transaction. + #[payable("*")] + #[endpoint] + fn deposit( + &self, + to: ManagedAddress, + opt_transfer_data: OptionalValue< + MultiValue3>, + >, + ) { + require!(self.not_paused(), "Cannot create transaction while paused"); + + let (fees_payment, payments) = self.check_and_extract_fee().into_tuple(); + + require!(!payments.is_empty(), "Nothing to transfer"); + require!(payments.len() <= MAX_TRANSFERS_PER_TX, "Too many tokens"); + + let opt_transfer_data = self.process_transfer_data(opt_transfer_data); + let own_sc_address = self.blockchain().get_sc_address(); + let mut total_tokens_for_fees = 0usize; + let mut event_payments: MultiValueEncoded< + MultiValue3, + > = MultiValueEncoded::new(); + let mut refundable_payments: ManagedVec> = + ManagedVec::new(); + + for payment in &payments { + self.require_below_max_amount(&payment.token_identifier, &payment.amount); + self.require_token_not_blacklisted(&payment.token_identifier); + + if !self.token_whitelist().is_empty() + && !self.token_whitelist().contains(&payment.token_identifier) + { + refundable_payments.push(payment.clone()); + + continue; + } else { + total_tokens_for_fees += 1; + } + + let mut current_token_data = self.blockchain().get_esdt_token_data( + &own_sc_address, + &payment.token_identifier, + payment.token_nonce, + ); + + current_token_data.amount = payment.amount.clone(); + + if self.is_sovereign_chain().get() { + self.send().esdt_local_burn( + &payment.token_identifier, + payment.token_nonce, + &payment.amount, + ); + + event_payments.push(MultiValue3(( + payment.token_identifier.clone(), + payment.token_nonce, + current_token_data.clone(), + ))); + } else { + let sov_token_id = self + .multiversx_to_sovereign_token_id(&payment.token_identifier) + .get(); + + if !sov_token_id.is_valid_esdt_identifier() { + event_payments.push(MultiValue3(( + payment.token_identifier, + payment.token_nonce, + current_token_data.clone(), + ))); + + continue; + } + + let sov_token_nonce = self.remove_sovereign_token(payment, &sov_token_id); + + event_payments.push(MultiValue3(( + sov_token_id, + sov_token_nonce, + current_token_data.clone(), + ))); + } + } + + let caller = self.blockchain().get_caller(); + + self.match_fee_payment(total_tokens_for_fees, &fees_payment, &opt_transfer_data); + + // refund refundable_tokens + for payment in &refundable_payments { + self.send().direct_non_zero_esdt_payment(&caller, &payment); + } + + let tx_nonce = self.get_and_save_next_tx_id(); + + self.deposit_event( + &to, + &event_payments, + OperationData { + op_nonce: tx_nonce, + op_sender: caller, + opt_transfer_data, + }, + ); + } + + fn remove_sovereign_token( + &self, + payment: EsdtTokenPayment, + sov_token_id: &TokenIdentifier, + ) -> u64 { + self.send().esdt_local_burn( + &payment.token_identifier, + payment.token_nonce, + &payment.amount, + ); + + let mut sov_token_nonce = 0; + + if payment.token_nonce > 0 { + sov_token_nonce = self + .multiversx_esdt_token_info_mapper(&payment.token_identifier, &payment.token_nonce) + .take() + .token_nonce; + + self.sovereign_esdt_token_info_mapper(sov_token_id, &sov_token_nonce) + .take(); + } + + sov_token_nonce + } + + fn match_fee_payment( + &self, + total_tokens_for_fees: usize, + fees_payment: &OptionalValue>, + opt_transfer_data: &Option::Api>>, + ) { + match fees_payment { + OptionalValue::Some(fee) => { + let mut gas: GasLimit = 0; + + if let Some(transfer_data) = opt_transfer_data { + gas = transfer_data.gas_limit; + } + + let _: FinalPayment = self + .fee_market_proxy(self.fee_market_address().get()) + .subtract_fee( + self.blockchain().get_caller().clone(), + total_tokens_for_fees, + OptionalValue::Some(gas), + ) + .with_esdt_transfer(fee.clone()) + .execute_on_dest_context(); + } + OptionalValue::None => (), + }; + } + + #[proxy] + fn fee_market_proxy(&self, sc_address: ManagedAddress) -> fee_market::Proxy; + + #[storage_mapper("feeMarketAddress")] + fn fee_market_address(&self) -> SingleValueMapper; + + #[storage_mapper("maxUserTxGasLimit")] + fn max_user_tx_gas_limit(&self) -> SingleValueMapper; + + #[storage_mapper("burnTokens")] + fn burn_tokens(&self) -> UnorderedSetMapper; + + #[storage_mapper("bannedEndpointNames")] + fn banned_endpoint_names(&self) -> UnorderedSetMapper; + + #[storage_mapper("feeEnabledFlag")] + fn fee_enabled(&self) -> SingleValueMapper; +} diff --git a/enshrine-esdt-safe/src/to_sovereign/events.rs b/enshrine-esdt-safe/src/to_sovereign/events.rs new file mode 100644 index 00000000..ba1d55a0 --- /dev/null +++ b/enshrine-esdt-safe/src/to_sovereign/events.rs @@ -0,0 +1,26 @@ +use transaction::{ + transaction_status::TransactionStatus, BatchId, OperationData, TxId +}; + +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +#[multiversx_sc::module] +pub trait EventsModule { + #[event("deposit")] + fn deposit_event( + // TODO: Use ManagedVec of EsdtTokenPaymentInfo(EsdtTokenDataPayment, EsdtTokenData) + &self, + #[indexed] dest_address: &ManagedAddress, + #[indexed] tokens: &MultiValueEncoded>, + event_data: OperationData, + ); + + #[event("setStatusEvent")] + fn set_status_event( + &self, + #[indexed] batch_id: BatchId, + #[indexed] tx_id: TxId, + #[indexed] tx_status: TransactionStatus, + ); +} diff --git a/enshrine-esdt-safe/src/to_sovereign/mod.rs b/enshrine-esdt-safe/src/to_sovereign/mod.rs new file mode 100644 index 00000000..72718603 --- /dev/null +++ b/enshrine-esdt-safe/src/to_sovereign/mod.rs @@ -0,0 +1,4 @@ +pub mod create_tx; +pub mod events; +pub mod refund; +pub mod set_tx_status; diff --git a/enshrine-esdt-safe/src/to_sovereign/refund.rs b/enshrine-esdt-safe/src/to_sovereign/refund.rs new file mode 100644 index 00000000..62c37409 --- /dev/null +++ b/enshrine-esdt-safe/src/to_sovereign/refund.rs @@ -0,0 +1,55 @@ +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem)] +pub struct NonceAmountPair { + pub nonce: u64, + pub amount: BigUint, +} + +#[multiversx_sc::module] +pub trait RefundModule: + super::events::EventsModule + + tx_batch_module::TxBatchModule + + max_bridged_amount_module::MaxBridgedAmountModule +{ + /// Claim funds for failed Elrond -> Sovereign transactions. + /// These are not sent automatically to prevent the contract getting stuck. + /// For example, if the receiver is a SC, a frozen account, etc. + #[endpoint(claimRefund)] + fn claim_refund(&self, token_id: TokenIdentifier) -> ManagedVec { + let caller = self.blockchain().get_caller(); + let refund_amounts = self.refund_amount(&caller, &token_id).take(); + require!(!refund_amounts.is_empty(), "Nothing to refund"); + + let mut output_payments = ManagedVec::new(); + for nonce_amount_pair in &refund_amounts { + output_payments.push(EsdtTokenPayment::new( + token_id.clone(), + nonce_amount_pair.nonce, + nonce_amount_pair.amount, + )); + } + + self.send().direct_multi(&caller, &output_payments); + + output_payments + } + + fn mark_refund(&self, to: &ManagedAddress, token: &EsdtTokenPayment) { + self.refund_amount(to, &token.token_identifier) + .update(|refund| { + refund.push(NonceAmountPair { + nonce: token.token_nonce, + amount: token.amount.clone(), + }); + }); + } + + #[storage_mapper("refundAmount")] + fn refund_amount( + &self, + address: &ManagedAddress, + token_id: &TokenIdentifier, + ) -> SingleValueMapper>>; +} diff --git a/enshrine-esdt-safe/src/to_sovereign/set_tx_status.rs b/enshrine-esdt-safe/src/to_sovereign/set_tx_status.rs new file mode 100644 index 00000000..9229866c --- /dev/null +++ b/enshrine-esdt-safe/src/to_sovereign/set_tx_status.rs @@ -0,0 +1,71 @@ +use bls_signature::BlsSignature; +use transaction::{transaction_status::TransactionStatus, BatchId}; + +multiversx_sc::imports!(); + +#[multiversx_sc::module] +pub trait SetTxStatusModule: + bls_signature::BlsSignatureModule + + super::events::EventsModule + + super::refund::RefundModule + + tx_batch_module::TxBatchModule + + max_bridged_amount_module::MaxBridgedAmountModule +{ + /// Sets the statuses for the transactions, after they were executed on the Sovereign side. + /// + /// Only TransactionStatus::Executed (3) and TransactionStatus::Rejected (4) values are allowed. + /// Number of provided statuses must be equal to number of transactions in the batch. + #[endpoint(setTransactionBatchStatus)] + fn set_transaction_batch_status( + &self, + batch_id: BatchId, + signature: BlsSignature, + tx_statuses: MultiValueEncoded, + ) { + let first_batch_id = self.first_batch_id().get(); + require!( + batch_id == first_batch_id, + "Batches must be processed in order" + ); + + let mut tx_batch = self.pending_batches(batch_id); + require!( + tx_batch.len() == tx_statuses.len(), + "Invalid number of statuses provided" + ); + + let mut serialized_data = ManagedBuffer::new(); + let tx_statuses_vec = tx_statuses.to_vec(); + + let _ = batch_id.dep_encode(&mut serialized_data); + for status in &tx_statuses_vec { + let _ = status.dep_encode(&mut serialized_data); + } + + self.multi_verify_signature(&serialized_data, &signature); + + for (tx, tx_status) in tx_batch.iter().zip(tx_statuses_vec.iter()) { + // Since tokens don't exist in the EsdtSafe in the case of a refund transaction + // we have no tokens to burn, nor to refund + if tx.is_refund_tx { + continue; + } + + match tx_status { + TransactionStatus::Executed => {} + TransactionStatus::Rejected => { + for token in &tx.tokens { + self.mark_refund(&tx.from, &token); + } + } + _ => { + sc_panic!("Transaction status may only be set to Executed or Rejected"); + } + } + + self.set_status_event(batch_id, tx.nonce, tx_status); + } + + self.clear_first_batch(&mut tx_batch); + } +} diff --git a/enshrine-esdt-safe/tests/enshrine_esdt_safe_scenario_go_test.rs b/enshrine-esdt-safe/tests/enshrine_esdt_safe_scenario_go_test.rs new file mode 100644 index 00000000..18b3d1e7 --- /dev/null +++ b/enshrine-esdt-safe/tests/enshrine_esdt_safe_scenario_go_test.rs @@ -0,0 +1,10 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + +#[test] +fn empty_go() { + world().run("scenarios/enshrine_esdt_safe.scen.json"); +} diff --git a/enshrine-esdt-safe/tests/enshrine_esdt_safe_scenario_rs_test.rs b/enshrine-esdt-safe/tests/enshrine_esdt_safe_scenario_rs_test.rs new file mode 100644 index 00000000..6837feb6 --- /dev/null +++ b/enshrine-esdt-safe/tests/enshrine_esdt_safe_scenario_rs_test.rs @@ -0,0 +1,13 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + let mut blockchain = ScenarioWorld::new(); + + blockchain.register_contract("mxsc:output/enshrine-esdt-safe.mxsc.json", enshrine_esdt_safe::ContractBuilder); + blockchain +} + +#[test] +fn empty_rs() { + world().run("scenarios/enshrine_esdt_safe.scen.json"); +} diff --git a/enshrine-esdt-safe/wasm-enshrine-esdt-safe-full/Cargo.lock b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-full/Cargo.lock new file mode 100644 index 00000000..a2694849 --- /dev/null +++ b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-full/Cargo.lock @@ -0,0 +1,297 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bls-signature" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "transaction", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "enshrine-esdt-safe" +version = "0.0.0" +dependencies = [ + "bls-signature", + "fee-market", + "header-verifier", + "max-bridged-amount-module", + "multiversx-sc", + "multiversx-sc-modules", + "setup-phase", + "token-whitelist", + "transaction", + "tx-batch-module", + "utils", +] + +[[package]] +name = "enshrine-esdt-safe-full-wasm" +version = "0.0.0" +dependencies = [ + "enshrine-esdt-safe", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "fee-market" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", + "pair-mock", + "router-mock", + "transaction", + "utils", +] + +[[package]] +name = "header-verifier" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", + "transaction", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "max-bridged-amount-module" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "748a370a86e9a3c51e0609c4a6c0c9a5cceaeb742656ee3284c0620504a3d7a5" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c94397b2fba14e40edfa55905b3f453ed57aa06c9b1960ad6a0ca6bfb7a236" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf72a8042da0bc19da0b8f0d4f61b4c66ae853560fefc69cd8fea87bf1aa8c14" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6ca88f27a90b0a1b17d5b645cc859e0480f4321c551525873a59a954bfbcb53" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-modules" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97c7153d996ef412f5fc687a6799fc9173cb221adef283c217d160eebebe7d4" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37f083d6844a0919a39d87c2552b8e9ea30e365775265d31b419d24f6aa93eee" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "pair-mock" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "proc-macro2" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "router-mock" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "setup-phase" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "syn" +version = "2.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "token-whitelist" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", + "setup-phase", + "utils", +] + +[[package]] +name = "transaction" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "tx-batch-module" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "transaction", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unwrap-infallible" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" + +[[package]] +name = "utils" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", +] diff --git a/enshrine-esdt-safe/wasm-enshrine-esdt-safe-full/Cargo.toml b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-full/Cargo.toml new file mode 100644 index 00000000..70a71f9d --- /dev/null +++ b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-full/Cargo.toml @@ -0,0 +1,34 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "enshrine-esdt-safe-full-wasm" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[profile.release] +codegen-units = 1 +opt-level = "z" +lto = true +debug = false +panic = "abort" +overflow-checks = false + +[profile.dev] +panic = "abort" + +[dependencies.enshrine-esdt-safe] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "=0.50.4" + +[workspace] +members = ["."] diff --git a/enshrine-esdt-safe/wasm-enshrine-esdt-safe-full/src/lib.rs b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-full/src/lib.rs new file mode 100644 index 00000000..7a4f3f37 --- /dev/null +++ b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-full/src/lib.rs @@ -0,0 +1,67 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Upgrade: 1 +// Endpoints: 39 +// Async Callback: 1 +// Promise callbacks: 1 +// Total number of exported functions: 43 + +#![no_std] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + enshrine_esdt_safe + ( + init => init + upgrade => upgrade + setFeeMarketAddress => set_fee_market_address + setMultisigAddress => set_header_verifier_address + setSovereignBridgeAddress => set_sovereign_bridge_address + setMaxUserTxGasLimit => set_max_user_tx_gas_limit + setBurnAndMint => set_burn_and_mint + removeBurnAndMint => remove_burn_and_mint + addBannedEndpointNames => add_banned_endpoint_names + removeBannedEndpointNames => remove_banned_endpoint_names + depositBack => deposit_back + deposit => deposit + claimRefund => claim_refund + setTransactionBatchStatus => set_transaction_batch_status + setMinValidSigners => set_min_valid_signers + addSigners => add_signers + removeSigners => remove_signers + registerToken => register_token + clearRegisteredSovereignToken => clear_registered_sovereign_token + clearRegisteredMultiversxToken => clear_registered_multiversx_token + executeBridgeOps => execute_operations + setMaxTxBatchSize => set_max_tx_batch_size + setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration + getCurrentTxBatch => get_current_tx_batch + getFirstBatchAnyStatus => get_first_batch_any_status + getBatch => get_batch + getBatchStatus => get_batch_status + getFirstBatchId => first_batch_id + getLastBatchId => last_batch_id + setMaxBridgedAmount => set_max_bridged_amount + getMaxBridgedAmount => max_bridged_amount + endSetupPhase => end_setup_phase + addTokensToWhitelist => add_tokens_to_whitelist + removeTokensFromWhitelist => remove_tokens_from_whitelist + addTokensToBlacklist => add_tokens_to_blacklist + removeTokensFromBlacklist => remove_tokens_from_blacklist + getTokenWhitelist => token_whitelist + getTokenBlacklist => token_blacklist + pause => pause_endpoint + unpause => unpause_endpoint + isPaused => paused_status + execute => execute + ) +} + +multiversx_sc_wasm_adapter::async_callback! { enshrine_esdt_safe } diff --git a/enshrine-esdt-safe/wasm-enshrine-esdt-safe-view/Cargo.lock b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-view/Cargo.lock new file mode 100644 index 00000000..45c68557 --- /dev/null +++ b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-view/Cargo.lock @@ -0,0 +1,297 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bls-signature" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "transaction", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "enshrine-esdt-safe" +version = "0.0.0" +dependencies = [ + "bls-signature", + "fee-market", + "header-verifier", + "max-bridged-amount-module", + "multiversx-sc", + "multiversx-sc-modules", + "setup-phase", + "token-whitelist", + "transaction", + "tx-batch-module", + "utils", +] + +[[package]] +name = "enshrine-esdt-safe-view-wasm" +version = "0.0.0" +dependencies = [ + "enshrine-esdt-safe", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "fee-market" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", + "pair-mock", + "router-mock", + "transaction", + "utils", +] + +[[package]] +name = "header-verifier" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", + "transaction", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "max-bridged-amount-module" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "748a370a86e9a3c51e0609c4a6c0c9a5cceaeb742656ee3284c0620504a3d7a5" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c94397b2fba14e40edfa55905b3f453ed57aa06c9b1960ad6a0ca6bfb7a236" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf72a8042da0bc19da0b8f0d4f61b4c66ae853560fefc69cd8fea87bf1aa8c14" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6ca88f27a90b0a1b17d5b645cc859e0480f4321c551525873a59a954bfbcb53" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-modules" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97c7153d996ef412f5fc687a6799fc9173cb221adef283c217d160eebebe7d4" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37f083d6844a0919a39d87c2552b8e9ea30e365775265d31b419d24f6aa93eee" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "pair-mock" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "proc-macro2" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "router-mock" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "setup-phase" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "syn" +version = "2.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "token-whitelist" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", + "setup-phase", + "utils", +] + +[[package]] +name = "transaction" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "tx-batch-module" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "transaction", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unwrap-infallible" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" + +[[package]] +name = "utils" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", +] diff --git a/enshrine-esdt-safe/wasm-enshrine-esdt-safe-view/Cargo.toml b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-view/Cargo.toml new file mode 100644 index 00000000..455d7ed3 --- /dev/null +++ b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-view/Cargo.toml @@ -0,0 +1,34 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "enshrine-esdt-safe-view-wasm" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[profile.release] +codegen-units = 1 +opt-level = "z" +lto = true +debug = false +panic = "abort" +overflow-checks = false + +[profile.dev] +panic = "abort" + +[dependencies.enshrine-esdt-safe] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "=0.50.4" + +[workspace] +members = ["."] diff --git a/enshrine-esdt-safe/wasm-enshrine-esdt-safe-view/src/lib.rs b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-view/src/lib.rs new file mode 100644 index 00000000..24483978 --- /dev/null +++ b/enshrine-esdt-safe/wasm-enshrine-esdt-safe-view/src/lib.rs @@ -0,0 +1,25 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 0 +// Async Callback (empty): 1 +// Total number of exported functions: 2 + +#![no_std] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::external_view_init! {} + +multiversx_sc_wasm_adapter::external_view_endpoints! { + enshrine_esdt_safe + ( + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/enshrine-esdt-safe/wasm/Cargo.lock b/enshrine-esdt-safe/wasm/Cargo.lock new file mode 100644 index 00000000..b2f85c6d --- /dev/null +++ b/enshrine-esdt-safe/wasm/Cargo.lock @@ -0,0 +1,297 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bls-signature" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "transaction", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "enshrine-esdt-safe" +version = "0.0.0" +dependencies = [ + "bls-signature", + "fee-market", + "header-verifier", + "max-bridged-amount-module", + "multiversx-sc", + "multiversx-sc-modules", + "setup-phase", + "token-whitelist", + "transaction", + "tx-batch-module", + "utils", +] + +[[package]] +name = "enshrine-esdt-safe-wasm" +version = "0.0.0" +dependencies = [ + "enshrine-esdt-safe", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "fee-market" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", + "pair-mock", + "router-mock", + "transaction", + "utils", +] + +[[package]] +name = "header-verifier" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", + "transaction", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "max-bridged-amount-module" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "748a370a86e9a3c51e0609c4a6c0c9a5cceaeb742656ee3284c0620504a3d7a5" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c94397b2fba14e40edfa55905b3f453ed57aa06c9b1960ad6a0ca6bfb7a236" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf72a8042da0bc19da0b8f0d4f61b4c66ae853560fefc69cd8fea87bf1aa8c14" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6ca88f27a90b0a1b17d5b645cc859e0480f4321c551525873a59a954bfbcb53" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-modules" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97c7153d996ef412f5fc687a6799fc9173cb221adef283c217d160eebebe7d4" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37f083d6844a0919a39d87c2552b8e9ea30e365775265d31b419d24f6aa93eee" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "pair-mock" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "proc-macro2" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "router-mock" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "setup-phase" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "syn" +version = "2.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "token-whitelist" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", + "setup-phase", + "utils", +] + +[[package]] +name = "transaction" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "tx-batch-module" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "transaction", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unwrap-infallible" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" + +[[package]] +name = "utils" +version = "0.0.0" +dependencies = [ + "bls-signature", + "multiversx-sc", +] diff --git a/enshrine-esdt-safe/wasm/Cargo.toml b/enshrine-esdt-safe/wasm/Cargo.toml new file mode 100644 index 00000000..0cf73cf7 --- /dev/null +++ b/enshrine-esdt-safe/wasm/Cargo.toml @@ -0,0 +1,34 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "enshrine-esdt-safe-wasm" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[profile.release] +codegen-units = 1 +opt-level = "z" +lto = true +debug = false +panic = "abort" +overflow-checks = false + +[profile.dev] +panic = "abort" + +[dependencies.enshrine-esdt-safe] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "=0.50.4" + +[workspace] +members = ["."] diff --git a/enshrine-esdt-safe/wasm/src/lib.rs b/enshrine-esdt-safe/wasm/src/lib.rs new file mode 100644 index 00000000..7a4f3f37 --- /dev/null +++ b/enshrine-esdt-safe/wasm/src/lib.rs @@ -0,0 +1,67 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Upgrade: 1 +// Endpoints: 39 +// Async Callback: 1 +// Promise callbacks: 1 +// Total number of exported functions: 43 + +#![no_std] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + enshrine_esdt_safe + ( + init => init + upgrade => upgrade + setFeeMarketAddress => set_fee_market_address + setMultisigAddress => set_header_verifier_address + setSovereignBridgeAddress => set_sovereign_bridge_address + setMaxUserTxGasLimit => set_max_user_tx_gas_limit + setBurnAndMint => set_burn_and_mint + removeBurnAndMint => remove_burn_and_mint + addBannedEndpointNames => add_banned_endpoint_names + removeBannedEndpointNames => remove_banned_endpoint_names + depositBack => deposit_back + deposit => deposit + claimRefund => claim_refund + setTransactionBatchStatus => set_transaction_batch_status + setMinValidSigners => set_min_valid_signers + addSigners => add_signers + removeSigners => remove_signers + registerToken => register_token + clearRegisteredSovereignToken => clear_registered_sovereign_token + clearRegisteredMultiversxToken => clear_registered_multiversx_token + executeBridgeOps => execute_operations + setMaxTxBatchSize => set_max_tx_batch_size + setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration + getCurrentTxBatch => get_current_tx_batch + getFirstBatchAnyStatus => get_first_batch_any_status + getBatch => get_batch + getBatchStatus => get_batch_status + getFirstBatchId => first_batch_id + getLastBatchId => last_batch_id + setMaxBridgedAmount => set_max_bridged_amount + getMaxBridgedAmount => max_bridged_amount + endSetupPhase => end_setup_phase + addTokensToWhitelist => add_tokens_to_whitelist + removeTokensFromWhitelist => remove_tokens_from_whitelist + addTokensToBlacklist => add_tokens_to_blacklist + removeTokensFromBlacklist => remove_tokens_from_blacklist + getTokenWhitelist => token_whitelist + getTokenBlacklist => token_blacklist + pause => pause_endpoint + unpause => unpause_endpoint + isPaused => paused_status + execute => execute + ) +} + +multiversx_sc_wasm_adapter::async_callback! { enshrine_esdt_safe } diff --git a/esdt-safe/src/from_sovereign/transfer_tokens.rs b/esdt-safe/src/from_sovereign/transfer_tokens.rs index 47f4c90b..4af216da 100644 --- a/esdt-safe/src/from_sovereign/transfer_tokens.rs +++ b/esdt-safe/src/from_sovereign/transfer_tokens.rs @@ -6,8 +6,6 @@ use transaction::{ use crate::to_sovereign; -use super::token_mapping::EsdtTokenInfo; - multiversx_sc::imports!(); const CALLBACK_GAS: GasLimit = 10_000_000; // Increase if not enough @@ -59,40 +57,62 @@ pub trait TransferTokensModule: let mut output_payments = ManagedVec::new(); for operation_token in operation_tokens.iter() { - let mx_token_id_state = self - .sovereign_to_multiversx_token_id(&operation_token.token_identifier) - .get(); - - let mx_token_id = match mx_token_id_state { - // token is from sovereign -> continue and mint - TokenMapperState::Token(token_id) => token_id, - // token is from mainchain -> push token - _ => { - // TODO: will use sovereign prefix - output_payments.push(operation_token.clone()); + if !self.has_sov_token_prefix(&operation_token.token_identifier) { + output_payments.push(operation_token.clone()); + continue; + } - continue; + let nonce = operation_token.token_nonce; + if nonce == 0 { + let _ = self.send().esdt_system_sc_proxy().mint( + &operation_token.token_identifier, + &operation_token.token_data.amount, + ); + } else { + // nonce = self.send().esdt_nft_create( + // &operation_token.token_identifier, + // &operation_token.token_data.amount, + // &operation_token.token_data.name, + // &operation_token.token_data.royalties, + // &operation_token.token_data.hash, + // &operation_token.token_data.attributes, + // &operation_token.token_data.uris, + // ); + + let token_data = operation_token.token_data.clone(); + let mut arg_buffer = ManagedArgBuffer::new(); + + arg_buffer.push_arg(&operation_token.token_identifier); + arg_buffer.push_arg(token_data.amount); + arg_buffer.push_arg(token_data.name); + arg_buffer.push_arg(token_data.royalties); + arg_buffer.push_arg(token_data.hash); + arg_buffer.push_arg(token_data.attributes); + + let uris = token_data.uris.clone(); + + if uris.is_empty() { + // at least one URI is required, so we push an empty one + arg_buffer.push_arg(codec::Empty); + } else { + // The API function has the last argument as variadic, + // so we top-encode each and send as separate argument + for uri in &uris { + arg_buffer.push_arg(uri); + } } - }; - - if operation_token.token_nonce == 0 { - self.send() - .esdt_local_mint(&mx_token_id, 0, &operation_token.token_data.amount); - - output_payments.push(OperationEsdtPayment { - token_identifier: mx_token_id, - token_nonce: 0, - token_data: operation_token.token_data, - }); + arg_buffer.push_arg(operation_token.token_nonce); - continue; + self.send_raw().call_local_esdt_built_in_function( + self.blockchain().get_gas_left(), + &ManagedBuffer::from(ESDT_NFT_CREATE_FUNC_NAME), + &arg_buffer, + ); } - let nft_nonce = self.mint_and_save_token(&mx_token_id, &operation_token); - output_payments.push(OperationEsdtPayment { - token_identifier: mx_token_id, - token_nonce: nft_nonce, + token_identifier: operation_token.token_identifier, + token_nonce: nonce, token_data: operation_token.token_data, }); } @@ -100,41 +120,6 @@ pub trait TransferTokensModule: output_payments } - fn mint_and_save_token( - self, - mx_token_id: &TokenIdentifier, - operation_token: &OperationEsdtPayment, - ) -> u64 { - // mint NFT - let nft_nonce = self.send().esdt_nft_create( - mx_token_id, - &operation_token.token_data.amount, - &operation_token.token_data.name, - &operation_token.token_data.royalties, - &operation_token.token_data.hash, - &operation_token.token_data.attributes, - &operation_token.token_data.uris, - ); - - // save token id and nonce - self.sovereign_esdt_token_info_mapper( - &operation_token.token_identifier, - &operation_token.token_nonce, - ) - .set(EsdtTokenInfo { - token_identifier: mx_token_id.clone(), - token_nonce: nft_nonce, - }); - - self.multiversx_esdt_token_info_mapper(mx_token_id, &nft_nonce) - .set(EsdtTokenInfo { - token_identifier: operation_token.token_identifier.clone(), - token_nonce: operation_token.token_nonce, - }); - - nft_nonce - } - fn distribute_payments( &self, hash_of_hashes: ManagedBuffer, diff --git a/esdt-safe/src/to_sovereign/create_tx.rs b/esdt-safe/src/to_sovereign/create_tx.rs index d093ffdd..66de1cda 100644 --- a/esdt-safe/src/to_sovereign/create_tx.rs +++ b/esdt-safe/src/to_sovereign/create_tx.rs @@ -69,41 +69,20 @@ pub trait CreateTxModule: current_token_data.amount = payment.amount.clone(); - if self.is_sovereign_chain().get() { - self.send().esdt_local_burn( - &payment.token_identifier, - payment.token_nonce, - &payment.amount, - ); - - event_payments.push(MultiValue3(( - payment.token_identifier.clone(), - payment.token_nonce, - current_token_data.clone(), - ))); - } else { - let sov_token_id = self - .multiversx_to_sovereign_token_id(&payment.token_identifier) - .get(); - - if !sov_token_id.is_valid_esdt_identifier() { - event_payments.push(MultiValue3(( - payment.token_identifier, - payment.token_nonce, - current_token_data.clone(), - ))); - - continue; - } - - let sov_token_nonce = self.remove_sovereign_token(payment, &sov_token_id); - - event_payments.push(MultiValue3(( - sov_token_id, - sov_token_nonce, - current_token_data.clone(), - ))); + if self.is_sovereign_chain().get() + || self.has_sov_token_prefix(&payment.token_identifier) + { + let _ = self + .send() + .esdt_system_sc_proxy() + .burn(&payment.token_identifier, &payment.amount); } + + event_payments.push(MultiValue3(( + payment.token_identifier.clone(), + payment.token_nonce, + current_token_data.clone(), + ))); } let caller = self.blockchain().get_caller(); @@ -185,11 +164,10 @@ pub trait CreateTxModule: payment: EsdtTokenPayment, sov_token_id: &TokenIdentifier, ) -> u64 { - self.send().esdt_local_burn( - &payment.token_identifier, - payment.token_nonce, - &payment.amount, - ); + let _ = self + .send() + .esdt_system_sc_proxy() + .burn(&payment.token_identifier, &payment.amount); let mut sov_token_nonce = 0;