diff --git a/Cargo.lock b/Cargo.lock index 23fb4402a9..be9ed0c56e 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,9 +16,9 @@ dependencies = [ name = "abi-tester" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-meta", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -26,15 +26,15 @@ name = "abi-tester-meta" version = "0.0.0" dependencies = [ "abi-tester", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "adder" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -42,14 +42,48 @@ name = "adder-meta" version = "0.0.0" dependencies = [ "adder", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", +] + +[[package]] +name = "adder-pt" +version = "0.0.0" +dependencies = [ + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", + "num-bigint", +] + +[[package]] +name = "adder-pt-meta" +version = "0.0.0" +dependencies = [ + "adder-pt", + "multiversx-sc-meta 0.50.3", +] + +[[package]] +name = "addercaller" +version = "0.0.0" +dependencies = [ + "multiversx-sc 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", + "multiversx-sc-scenario 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint", +] + +[[package]] +name = "addercaller-meta" +version = "0.0.0" +dependencies = [ + "addercaller", + "multiversx-sc-meta 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -86,8 +120,8 @@ name = "alloc-features" version = "0.0.0" dependencies = [ "esdt-system-sc-mock", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -95,7 +129,7 @@ name = "alloc-features-meta" version = "0.0.0" dependencies = [ "alloc-features", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -182,9 +216,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" dependencies = [ "addr2line", "cc", @@ -206,9 +240,9 @@ name = "basic-features" version = "0.0.0" dependencies = [ "esdt-system-sc-mock", - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -227,7 +261,7 @@ name = "basic-features-meta" version = "0.0.0" dependencies = [ "basic-features", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -251,8 +285,8 @@ checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" name = "benchmark-common" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -260,8 +294,8 @@ name = "big-float-features" version = "0.0.0" dependencies = [ "esdt-system-sc-mock", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -269,7 +303,7 @@ name = "big-float-features-meta" version = "0.0.0" dependencies = [ "big-float-features", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -325,9 +359,9 @@ dependencies = [ name = "bonding-curve-contract" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -335,7 +369,7 @@ name = "bonding-curve-contract-meta" version = "0.0.0" dependencies = [ "bonding-curve-contract", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -352,8 +386,8 @@ dependencies = [ name = "builtin-func-features" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -361,7 +395,7 @@ name = "builtin-func-features-meta" version = "0.0.0" dependencies = [ "builtin-func-features", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -382,6 +416,40 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +[[package]] +name = "callee" +version = "0.0.0" +dependencies = [ + "multiversx-sc 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", + "multiversx-sc-scenario 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint", +] + +[[package]] +name = "callee-meta" +version = "0.0.0" +dependencies = [ + "callee", + "multiversx-sc-meta 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "caller" +version = "0.0.0" +dependencies = [ + "multiversx-sc 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", + "multiversx-sc-scenario 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint", +] + +[[package]] +name = "caller-meta" +version = "0.0.0" +dependencies = [ + "caller", + "multiversx-sc-meta 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cc" version = "1.0.98" @@ -398,9 +466,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" name = "check-pause" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", "num-bigint", ] @@ -409,15 +477,15 @@ name = "check-pause-meta" version = "0.0.0" dependencies = [ "check-pause", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "child" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -425,8 +493,8 @@ name = "child-meta" version = "0.0.0" dependencies = [ "child", - "multiversx-sc", - "multiversx-sc-meta", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -500,8 +568,8 @@ dependencies = [ "forwarder-legacy", "forwarder-queue", "forwarder-raw", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "promises-features", "proxy-test-first", "proxy-test-second", @@ -591,8 +659,8 @@ name = "crowdfunding-erc20" version = "0.0.0" dependencies = [ "erc20", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -600,7 +668,7 @@ name = "crowdfunding-erc20-meta" version = "0.0.0" dependencies = [ "crowdfunding-erc20", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -608,8 +676,8 @@ name = "crowdfunding-esdt" version = "0.0.0" dependencies = [ "hex", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "num-bigint", "num-traits", ] @@ -619,15 +687,15 @@ name = "crowdfunding-esdt-meta" version = "0.0.0" dependencies = [ "crowdfunding-esdt", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "crypto-bubbles" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -635,7 +703,7 @@ name = "crypto-bubbles-meta" version = "0.0.0" dependencies = [ "crypto-bubbles", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -652,8 +720,8 @@ dependencies = [ name = "crypto-zombies" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -661,7 +729,7 @@ name = "crypto-zombies-meta" version = "0.0.0" dependencies = [ "crypto-zombies", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -712,8 +780,8 @@ dependencies = [ name = "digital-cash" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -721,7 +789,7 @@ name = "digital-cash-meta" version = "0.0.0" dependencies = [ "digital-cash", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -768,8 +836,8 @@ checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" name = "empty" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "num-bigint", ] @@ -778,7 +846,7 @@ name = "empty-meta" version = "0.0.0" dependencies = [ "empty", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -830,8 +898,8 @@ name = "erc1155" version = "0.0.0" dependencies = [ "erc1155-user-mock", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -839,8 +907,8 @@ name = "erc1155-marketplace" version = "0.0.0" dependencies = [ "erc1155", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -848,7 +916,7 @@ name = "erc1155-marketplace-meta" version = "0.0.0" dependencies = [ "erc1155-marketplace", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -856,15 +924,15 @@ name = "erc1155-meta" version = "0.0.0" dependencies = [ "erc1155", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "erc1155-user-mock" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -872,15 +940,15 @@ name = "erc1155-user-mock-meta" version = "0.0.0" dependencies = [ "erc1155-user-mock", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "erc20" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -888,15 +956,15 @@ name = "erc20-meta" version = "0.0.0" dependencies = [ "erc20", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "erc721" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -904,7 +972,7 @@ name = "erc721-meta" version = "0.0.0" dependencies = [ "erc721", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -922,8 +990,8 @@ name = "esdt-contract-pair" version = "0.0.0" dependencies = [ "first-contract", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "second-contract", ] @@ -931,8 +999,8 @@ dependencies = [ name = "esdt-system-sc-mock" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -940,15 +1008,15 @@ name = "esdt-system-sc-mock-meta" version = "0.0.0" dependencies = [ "esdt-system-sc-mock", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "esdt-transfer-with-fee" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -956,15 +1024,15 @@ name = "esdt-transfer-with-fee-meta" version = "0.0.0" dependencies = [ "esdt-transfer-with-fee", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "exchange-features" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -972,15 +1040,15 @@ name = "exchange-features-meta" version = "0.0.0" dependencies = [ "exchange-features", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "factorial" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -988,14 +1056,14 @@ name = "factorial-meta" version = "0.0.0" dependencies = [ "factorial", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "factory-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "order-book-factory", ] @@ -1009,8 +1077,8 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" name = "first-contract" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1018,8 +1086,8 @@ name = "first-contract-meta" version = "0.0.0" dependencies = [ "first-contract", - "multiversx-sc", - "multiversx-sc-meta", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1066,8 +1134,8 @@ dependencies = [ name = "formatted-message-features" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1075,23 +1143,23 @@ name = "formatted-message-features-meta" version = "0.0.0" dependencies = [ "formatted-message-features", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "forwarder" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "forwarder-legacy" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "vault", ] @@ -1100,7 +1168,7 @@ name = "forwarder-legacy-meta" version = "0.0.0" dependencies = [ "forwarder-legacy", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1108,15 +1176,15 @@ name = "forwarder-meta" version = "0.0.0" dependencies = [ "forwarder", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "forwarder-queue" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "multiversx-sc-wasm-adapter", ] @@ -1125,15 +1193,15 @@ name = "forwarder-queue-meta" version = "0.0.0" dependencies = [ "forwarder-queue", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "forwarder-raw" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1141,16 +1209,16 @@ name = "forwarder-raw-meta" version = "0.0.0" dependencies = [ "forwarder-raw", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "fractional-nfts" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1158,7 +1226,7 @@ name = "fractional-nfts-meta" version = "0.0.0" dependencies = [ "fractional-nfts", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1286,9 +1354,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "globset" @@ -1449,9 +1517,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d8d52be92d09acc2e01dddb7fde3ad983fc6489c7db4837e605bc3fca4cb63e" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" dependencies = [ "bytes", "futures-channel", @@ -1509,7 +1577,7 @@ name = "interact" version = "0.0.0" dependencies = [ "clap", - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-snippets", "serde", "toml", @@ -1564,7 +1632,7 @@ dependencies = [ name = "kitty" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", "random", ] @@ -1574,8 +1642,8 @@ version = "0.0.0" dependencies = [ "kitty", "kitty-ownership", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1583,7 +1651,7 @@ name = "kitty-auction-meta" version = "0.0.0" dependencies = [ "kitty-auction", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1591,8 +1659,8 @@ name = "kitty-genetic-alg" version = "0.0.0" dependencies = [ "kitty", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "random", ] @@ -1601,7 +1669,7 @@ name = "kitty-genetic-alg-meta" version = "0.0.0" dependencies = [ "kitty-genetic-alg", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1610,8 +1678,8 @@ version = "0.0.0" dependencies = [ "kitty", "kitty-genetic-alg", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "random", ] @@ -1620,15 +1688,15 @@ name = "kitty-ownership-meta" version = "0.0.0" dependencies = [ "kitty-ownership", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "large-storage" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1636,7 +1704,7 @@ name = "large-storage-meta" version = "0.0.0" dependencies = [ "large-storage", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1656,8 +1724,8 @@ name = "linked-list-repeat" version = "0.0.0" dependencies = [ "benchmark-common", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1665,7 +1733,7 @@ name = "linked-list-repeat-meta" version = "0.0.0" dependencies = [ "linked-list-repeat", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1678,8 +1746,8 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" name = "local-esdt-and-nft" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1687,7 +1755,7 @@ name = "local-esdt-and-nft-meta" version = "0.0.0" dependencies = [ "local-esdt-and-nft", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1717,8 +1785,8 @@ name = "lottery-erc20" version = "0.0.0" dependencies = [ "erc20", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1726,15 +1794,15 @@ name = "lottery-erc20-meta" version = "0.0.0" dependencies = [ "lottery-erc20", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] name = "lottery-esdt" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1742,7 +1810,7 @@ name = "lottery-esdt-meta" version = "0.0.0" dependencies = [ "lottery-esdt", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1750,8 +1818,8 @@ name = "managed-map-features" version = "0.0.0" dependencies = [ "esdt-system-sc-mock", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1759,7 +1827,7 @@ name = "managed-map-features-meta" version = "0.0.0" dependencies = [ "managed-map-features", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1767,8 +1835,8 @@ name = "map-repeat" version = "0.0.0" dependencies = [ "benchmark-common", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1776,7 +1844,7 @@ name = "map-repeat-meta" version = "0.0.0" dependencies = [ "map-repeat", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1815,8 +1883,8 @@ dependencies = [ name = "multi-contract-features" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] @@ -1824,7 +1892,7 @@ name = "multi-contract-features-meta" version = "0.0.0" dependencies = [ "multi-contract-features", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1834,9 +1902,9 @@ dependencies = [ "adder", "factorial", "hex", - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", "multiversx-wegld-swap-sc", "num-bigint", "num-traits", @@ -1848,9 +1916,9 @@ version = "0.0.0" dependencies = [ "clap", "multisig", - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", "multiversx-sc-snippets", "serde", "toml", @@ -1861,7 +1929,24 @@ name = "multisig-meta" version = "0.0.0" dependencies = [ "multisig", - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", +] + +[[package]] +name = "multisig-pt" +version = "0.0.0" +dependencies = [ + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", + "num-bigint", +] + +[[package]] +name = "multisig-pt-meta" +version = "0.0.0" +dependencies = [ + "multisig-pt", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1877,6 +1962,21 @@ dependencies = [ "sha3", ] +[[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" @@ -1896,6 +1996,27 @@ dependencies = [ "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" @@ -1908,9 +2029,9 @@ version = "0.50.3" dependencies = [ "arrayvec", "getrandom 0.2.15", - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", "rand 0.8.5", ] @@ -1919,8 +2040,8 @@ name = "multiversx-price-aggregator-sc-meta" version = "0.0.0" dependencies = [ "multiversx-price-aggregator-sc", - "multiversx-sc", - "multiversx-sc-meta", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", ] [[package]] @@ -1929,8 +2050,22 @@ version = "0.50.3" dependencies = [ "bitflags 2.5.0", "hex-literal", - "multiversx-sc-codec", - "multiversx-sc-derive", + "multiversx-sc-codec 0.19.0", + "multiversx-sc-derive 0.50.3", + "num-traits", + "unwrap-infallible", +] + +[[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 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "multiversx-sc-derive 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits", "unwrap-infallible", ] @@ -1940,7 +2075,19 @@ name = "multiversx-sc-codec" version = "0.19.0" dependencies = [ "arrayvec", - "multiversx-sc-codec-derive", + "multiversx-sc-codec-derive 0.19.0", + "num-bigint", + "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 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint", "unwrap-infallible", ] @@ -1955,9 +2102,34 @@ dependencies = [ "syn", ] +[[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" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "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", @@ -1977,8 +2149,35 @@ dependencies = [ "copy_dir", "hex", "lazy_static", - "multiversx-sc", - "multiversx-sc-meta", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", + "pathdiff", + "reqwest", + "ruplacer", + "rustc_version", + "semver", + "serde", + "serde_json", + "toml", + "wasmparser", + "wasmprinter", + "zip", +] + +[[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 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", "pathdiff", "reqwest", "ruplacer", @@ -1996,7 +2195,7 @@ dependencies = [ name = "multiversx-sc-modules" version = "0.50.3" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", ] [[package]] @@ -2010,12 +2209,41 @@ dependencies = [ "hex", "itertools", "log", - "multiversx-chain-scenario-format", - "multiversx-chain-vm", + "multiversx-chain-scenario-format 0.22.2", + "multiversx-chain-vm 0.8.4", "multiversx-chain-vm-executor", - "multiversx-sc", - "multiversx-sc-meta", - "multiversx-sdk", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", + "multiversx-sdk 0.4.1", + "num-bigint", + "num-traits", + "pathdiff", + "serde", + "serde_json", + "sha2 0.10.8", + "tokio", + "unwrap-infallible", +] + +[[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 0.22.2 (registry+https://github.com/rust-lang/crates.io-index)", + "multiversx-chain-vm 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "multiversx-chain-vm-executor", + "multiversx-sc 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", + "multiversx-sc-meta 0.50.3 (registry+https://github.com/rust-lang/crates.io-index)", + "multiversx-sdk 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint", "num-traits", "pathdiff", @@ -2035,8 +2263,8 @@ dependencies = [ "futures", "hex", "log", - "multiversx-sc-scenario", - "multiversx-sdk", + "multiversx-sc-scenario 0.50.3", + "multiversx-sdk 0.4.1", "tokio", ] @@ -2044,7 +2272,7 @@ dependencies = [ name = "multiversx-sc-wasm-adapter" version = "0.50.3" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", ] [[package]] @@ -2071,21 +2299,47 @@ dependencies = [ "zeroize", ] +[[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 = "multiversx-wegld-swap-sc" version = "0.50.3" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "multiversx-wegld-swap-sc-meta" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-meta", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", "multiversx-wegld-swap-sc", ] @@ -2095,18 +2349,17 @@ version = "0.0.0" dependencies = [ "bech32", "hex", - "multiversx-sc", + "multiversx-sc 0.50.3", "num-bigint", "num-traits", ] [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -2122,15 +2375,15 @@ dependencies = [ name = "nft-minter" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "nft-minter-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "nft-minter", ] @@ -2138,15 +2391,15 @@ dependencies = [ name = "nft-storage-prepay" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "nft-storage-prepay-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "nft-storage-prepay", ] @@ -2154,16 +2407,16 @@ dependencies = [ name = "nft-subscription" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "nft-subscription-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "nft-subscription", ] @@ -2216,9 +2469,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" dependencies = [ "memchr", ] @@ -2283,23 +2536,23 @@ dependencies = [ name = "order-book-factory" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "order-book-pair" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "pair-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "order-book-pair", ] @@ -2307,15 +2560,15 @@ dependencies = [ name = "panic-message-features" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "panic-message-features-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "panic-message-features", ] @@ -2323,16 +2576,16 @@ dependencies = [ name = "parent" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "parent-meta" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-meta", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", "parent", ] @@ -2369,15 +2622,15 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" name = "payable-features" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "payable-features-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "payable-features", ] @@ -2446,15 +2699,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" name = "ping-pong-egld" version = "0.0.2" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "ping-pong-egld-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "ping-pong-egld", ] @@ -2483,14 +2736,14 @@ dependencies = [ name = "promises-features" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", ] [[package]] name = "promises-features-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "promises-features", ] @@ -2499,15 +2752,15 @@ name = "proxy-pause" version = "0.0.0" dependencies = [ "check-pause", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "proxy-pause-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "proxy-pause", ] @@ -2516,15 +2769,15 @@ name = "proxy-test-first" version = "0.0.0" dependencies = [ "hex-literal", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "proxy-test-first-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "proxy-test-first", ] @@ -2532,15 +2785,15 @@ dependencies = [ name = "proxy-test-second" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "proxy-test-second-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "proxy-test-second", ] @@ -2549,15 +2802,15 @@ name = "queue-repeat" version = "0.0.0" dependencies = [ "benchmark-common", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "queue-repeat-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "queue-repeat", ] @@ -2664,15 +2917,15 @@ dependencies = [ name = "random" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", ] [[package]] name = "recursive-caller" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "vault", ] @@ -2680,7 +2933,7 @@ dependencies = [ name = "recursive-caller-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "recursive-caller", ] @@ -2769,16 +3022,16 @@ dependencies = [ name = "rewards-distribution" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "rewards-distribution-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "rewards-distribution", ] @@ -2800,15 +3053,15 @@ dependencies = [ name = "rust-snippets-generator-test" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "rust-snippets-generator-test-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "rust-snippets-generator-test", ] @@ -2820,8 +3073,8 @@ dependencies = [ "basic-features", "forwarder", "hex", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", "num-bigint", "num-traits", "vault", @@ -2831,7 +3084,7 @@ dependencies = [ name = "rust-testing-framework-tester-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "rust-testing-framework-tester", ] @@ -2898,15 +3151,15 @@ dependencies = [ name = "scenario-tester" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "scenario-tester-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "scenario-tester", ] @@ -2929,16 +3182,16 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" name = "second-contract" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "second-contract-meta" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-meta", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", "second-contract", ] @@ -2969,16 +3222,16 @@ dependencies = [ name = "seed-nft-minter" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "seed-nft-minter-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "seed-nft-minter", ] @@ -2992,32 +3245,32 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" name = "send-tx-repeat" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "send-tx-repeat-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "send-tx-repeat", ] [[package]] name = "serde" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", @@ -3073,15 +3326,15 @@ name = "set-repeat" version = "0.0.0" dependencies = [ "benchmark-common", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "set-repeat-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "set-repeat", ] @@ -3145,15 +3398,15 @@ name = "single-value-repeat" version = "0.0.0" dependencies = [ "benchmark-common", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "single-value-repeat-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "single-value-repeat", ] @@ -3186,15 +3439,15 @@ dependencies = [ name = "str-repeat" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "str-repeat-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "str-repeat", ] @@ -3260,6 +3513,23 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "test-testapi" +version = "0.0.0" +dependencies = [ + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", + "num-bigint", +] + +[[package]] +name = "test-testapi-meta" +version = "0.0.0" +dependencies = [ + "multiversx-sc-meta 0.50.3", + "test-testapi", +] + [[package]] name = "thiserror" version = "1.0.61" @@ -3299,23 +3569,23 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" name = "token-release" version = "0.0.1" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "token-release-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "token-release", ] [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -3332,9 +3602,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", @@ -3449,9 +3719,9 @@ dependencies = [ name = "transfer-role-features" version = "0.0.0" dependencies = [ - "multiversx-sc", + "multiversx-sc 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", "vault", ] @@ -3459,7 +3729,7 @@ dependencies = [ name = "transfer-role-features-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "transfer-role-features", ] @@ -3523,17 +3793,17 @@ dependencies = [ name = "use-module" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-meta", + "multiversx-sc 0.50.3", + "multiversx-sc-meta 0.50.3", "multiversx-sc-modules", - "multiversx-sc-scenario", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "use-module-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "use-module", ] @@ -3547,15 +3817,15 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" name = "vault" version = "0.0.0" dependencies = [ - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "vault-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "vault", ] @@ -3570,15 +3840,15 @@ name = "vec-repeat" version = "0.0.0" dependencies = [ "benchmark-common", - "multiversx-sc", - "multiversx-sc-scenario", + "multiversx-sc 0.50.3", + "multiversx-sc-scenario 0.50.3", ] [[package]] name = "vec-repeat-meta" version = "0.0.0" dependencies = [ - "multiversx-sc-meta", + "multiversx-sc-meta 0.50.3", "vec-repeat", ] @@ -3869,9 +4139,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" dependencies = [ "memchr", ] @@ -3908,9 +4178,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -3928,9 +4198,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2568cd0f20e86cd9a7349fe05178f7bd22f22724678448ae5a9bac266df2689" +checksum = "1dd56a4d5921bc2f99947ac5b3abe5f510b1be7376fdc5e9fce4a23c6a93e87c" dependencies = [ "arbitrary", "crc32fast", diff --git a/Cargo.toml b/Cargo.toml index abeac2b710..20f9ba42ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -182,4 +182,17 @@ members = [ "contracts/feature-tests/scenario-tester/meta", "contracts/feature-tests/use-module", "contracts/feature-tests/use-module/meta", + + "contracts/parametric-tests/adder-pt", + "contracts/parametric-tests/adder-pt/meta", + "contracts/parametric-tests/addercaller", + "contracts/parametric-tests/addercaller/meta", + "contracts/parametric-tests/callee", + "contracts/parametric-tests/callee/meta", + "contracts/parametric-tests/caller", + "contracts/parametric-tests/caller/meta", + "contracts/parametric-tests/multisig-pt", + "contracts/parametric-tests/multisig-pt/meta", + "contracts/parametric-tests/testapi-pt", + "contracts/parametric-tests/testapi-pt/meta", ] diff --git a/contracts/examples/adder/sc-config.toml b/contracts/examples/adder/sc-config.toml index b56f82b429..477c644746 100644 --- a/contracts/examples/adder/sc-config.toml +++ b/contracts/examples/adder/sc-config.toml @@ -2,3 +2,6 @@ [[proxy]] path = "src/adder_proxy.rs" + +[[proxy]] +path = "../../parametric-tests/adder-pt/src/adder_proxy.rs" diff --git a/contracts/examples/multisig/sc-config.toml b/contracts/examples/multisig/sc-config.toml index 79c3aeaa20..ebfaac4177 100644 --- a/contracts/examples/multisig/sc-config.toml +++ b/contracts/examples/multisig/sc-config.toml @@ -17,3 +17,6 @@ add-labels = ["multisig-external-view"] [[proxy]] path = "src/multisig_proxy.rs" + +[[proxy]] +path = "../../parametric-tests/multisig-pt/src/multisig_proxy.rs" diff --git a/contracts/parametric-tests/adder-pt/.gitignore b/contracts/parametric-tests/adder-pt/.gitignore new file mode 100644 index 0000000000..abc3e496f7 --- /dev/null +++ b/contracts/parametric-tests/adder-pt/.gitignore @@ -0,0 +1,11 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +*/target/ + +# The mxpy output +/output*/ + +# Kasmer +.property +generated_claims diff --git a/contracts/parametric-tests/adder-pt/Cargo.toml b/contracts/parametric-tests/adder-pt/Cargo.toml new file mode 100644 index 0000000000..e1230b9975 --- /dev/null +++ b/contracts/parametric-tests/adder-pt/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "adder-pt" +version = "0.0.0" +authors = [ "you",] +edition = "2018" +publish = false + +[lib] +path = "src/adder_pt.rs" + +[dev-dependencies] +num-bigint = "0.4.2" + +[dependencies.multiversx-sc] +version = "0.50.0" +path = "../../../framework/base" + +[dev-dependencies.multiversx-sc-scenario] +version = "0.50.0" +path = "../../../framework/scenario" + diff --git a/contracts/parametric-tests/adder-pt/README.md b/contracts/parametric-tests/adder-pt/README.md new file mode 100644 index 0000000000..3821f96915 --- /dev/null +++ b/contracts/parametric-tests/adder-pt/README.md @@ -0,0 +1,19 @@ +# Parametric test example for: Adder + +This is an example on how to write a basic parametric test contract. + +To run fuzzing on it using Kasmer, build the contracts and simply run + +``` +kasmer fuzz +``` + + +To run symbolic execution: + +``` +kasmer build +kasmer verify test_call_add --booster +## and / or +kasmer verify test_call_add_twice --booster +``` diff --git a/contracts/parametric-tests/adder-pt/kasmer.json b/contracts/parametric-tests/adder-pt/kasmer.json new file mode 100644 index 0000000000..c2ad4eaea4 --- /dev/null +++ b/contracts/parametric-tests/adder-pt/kasmer.json @@ -0,0 +1,5 @@ +{ + "contracts": [ + "../../examples/adder" + ] +} diff --git a/contracts/parametric-tests/adder-pt/meta/Cargo.toml b/contracts/parametric-tests/adder-pt/meta/Cargo.toml new file mode 100644 index 0000000000..2d751b8ecc --- /dev/null +++ b/contracts/parametric-tests/adder-pt/meta/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "adder-pt-meta" +version = "0.0.0" +edition = "2018" +publish = false +authors = [ "you",] + +[dev-dependencies] + +[dependencies.adder-pt] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.50.0" +path = "../../../../framework/meta" diff --git a/contracts/parametric-tests/adder-pt/meta/src/main.rs b/contracts/parametric-tests/adder-pt/meta/src/main.rs new file mode 100644 index 0000000000..aedb6bcc7e --- /dev/null +++ b/contracts/parametric-tests/adder-pt/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/contracts/parametric-tests/adder-pt/multiversx.json b/contracts/parametric-tests/adder-pt/multiversx.json new file mode 100644 index 0000000000..7365539625 --- /dev/null +++ b/contracts/parametric-tests/adder-pt/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/contracts/parametric-tests/adder-pt/scenarios/test-adder.scen.json b/contracts/parametric-tests/adder-pt/scenarios/test-adder.scen.json new file mode 100644 index 0000000000..3219956f1c --- /dev/null +++ b/contracts/parametric-tests/adder-pt/scenarios/test-adder.scen.json @@ -0,0 +1,71 @@ +{ + "name": "test-adder", + "comment": "run foundry-like test for Adder", + "gasSchedule": "v3", + "steps": [ + { + "step": "setState", + "accounts": { + "address:k": { + "nonce": "1", + "balance": "100000" + } + }, + "newAddresses": [ + { + "creatorAddress": "address:k", + "creatorNonce": "1", + "newAddress": "sc:k-test" + } + ] + }, + { + "step": "fetchWasmSource", + "wasmPath": "file:../../../../deps/mx-sdk-rs/contracts/examples/adder/output/adder.wasm" + }, + { + "step": "scDeploy", + "id": "deploy test", + "comment": "deploy the test contract", + "tx": { + "from": "address:k", + "contractCode": "file:../output/test-adder.wasm", + "arguments": [ + "file:../../../../deps/mx-sdk-rs/contracts/examples/adder/output/adder.wasm" + ], + "gasLimit": "5,000,000,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "id": "call test", + "comment": "call the parametric test endpoint with a concrete value", + "tx": { + "from": "address:k", + "to": "sc:k-test", + "function": "test_call_add", + "value": "0", + "arguments": [ + "3" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + } + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/adder-pt/src/adder_proxy.rs b/contracts/parametric-tests/adder-pt/src/adder_proxy.rs new file mode 100644 index 0000000000..fd79b14ac8 --- /dev/null +++ b/contracts/parametric-tests/adder-pt/src/adder_proxy.rs @@ -0,0 +1,114 @@ +// 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 AdderProxy; + +impl TxProxyTrait for AdderProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = AdderProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + AdderProxyMethods { wrapped_tx: tx } + } +} + +pub struct AdderProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl AdderProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg>, + >( + self, + initial_value: Arg0, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&initial_value) + .original_result() + } +} + +#[rustfmt::skip] +impl AdderProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade< + Arg0: ProxyArg>, + >( + self, + initial_value: Arg0, + ) -> TxTypedUpgrade { + self.wrapped_tx + .payment(NotPayable) + .raw_upgrade() + .argument(&initial_value) + .original_result() + } +} + +#[rustfmt::skip] +impl AdderProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn sum( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getSum") + .original_result() + } + + /// Add desired amount to the storage variable. + pub fn add< + Arg0: ProxyArg>, + >( + self, + value: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("add") + .argument(&value) + .original_result() + } +} diff --git a/contracts/parametric-tests/adder-pt/src/adder_pt.rs b/contracts/parametric-tests/adder-pt/src/adder_pt.rs new file mode 100644 index 0000000000..7239963b4f --- /dev/null +++ b/contracts/parametric-tests/adder-pt/src/adder_pt.rs @@ -0,0 +1,91 @@ +#![no_std] + +mod adder_proxy; + +multiversx_sc::imports!(); + +static INIT_SUM: u32 = 5u32; + +#[multiversx_sc::contract] +pub trait TestAdder { + #[storage_mapper("ownerAddress")] + fn owner_address(&self) -> SingleValueMapper; + + #[storage_mapper("adderAddress")] + fn adder_address(&self) -> SingleValueMapper; + + /// Create the owner account and deploy adder + #[init] + fn init(&self, code_path: ManagedBuffer) { + // create the owner account + let owner = ManagedAddress::from(b"owner___________________________"); + self.owner_address().set(&owner); + + self.test_raw() + .create_account(&owner, 1, &BigUint::from(0u64)); + + // register an address for the contract to be deployed + let adder = ManagedAddress::from(b"adder___________________________"); + self.test_raw().register_new_address(&owner, 1, &adder); + + let adder = self + .tx() + .from(&owner) + .typed(adder_proxy::AdderProxy) + .init(INIT_SUM) + .code_path(code_path) + .gas(5000000000000) + .returns(ReturnsNewManagedAddress) + .test_deploy(); + + // save the deployed contract's address + self.adder_address().set(&adder); + + // check the initial sum value + let sum: BigUint = self.storage_raw().read_from_address(&adder, "sum"); + self.test_raw().assert(sum == INIT_SUM); + } + + // Make a call from 'owner' to 'adder' and check the sum value + #[endpoint(test_call_add)] + fn test_call_add(&self, value: BigUint) { + self.test_raw().assume(value <= 100u32); + + let adder = self.adder_address().get(); + + self.call_add(&value); + + // check the sum value + let sum: BigUint = self.storage_raw().read_from_address(&adder, "sum"); + self.test_raw().assert(sum == (value + INIT_SUM)); + } + + #[endpoint(test_call_add_twice)] + fn test_call_add_twice(&self, value1: BigUint, value2: BigUint) { + self.test_raw().assume(value1 <= 100u32); + self.test_raw().assume(value2 <= 100u32); + + let adder = self.adder_address().get(); + + self.call_add(&value1); + self.call_add(&value2); + + // check the sum value + let sum: BigUint = self.storage_raw().read_from_address(&adder, "sum"); + self.test_raw().assert(sum == (value1 + value2 + INIT_SUM)); + } + + fn call_add(&self, value: &BigUint) { + let owner = self.owner_address().get(); + let adder = self.adder_address().get(); + + // start a prank and call 'adder' from 'owner' + self.tx() + .from(owner) + .to(adder) + .typed(adder_proxy::AdderProxy) + .add(value) + .gas(5000000) + .test_call(); + } +} diff --git a/contracts/parametric-tests/adder-pt/wasm/Cargo.lock b/contracts/parametric-tests/adder-pt/wasm/Cargo.lock new file mode 100644 index 0000000000..4c43f90065 --- /dev/null +++ b/contracts/parametric-tests/adder-pt/wasm/Cargo.lock @@ -0,0 +1,178 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adder-pt" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "adder-pt-wasm" +version = "0.0.0" +dependencies = [ + "adder-pt", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[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 = "multiversx-sc" +version = "0.50.3" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.19.0" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.19.0" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.50.3" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.50.3" +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 = "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 = "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 = "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" diff --git a/contracts/parametric-tests/adder-pt/wasm/Cargo.toml b/contracts/parametric-tests/adder-pt/wasm/Cargo.toml new file mode 100644 index 0000000000..cb592d5393 --- /dev/null +++ b/contracts/parametric-tests/adder-pt/wasm/Cargo.toml @@ -0,0 +1,35 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "adder-pt-wasm" +version = "0.0.0" +edition = "2018" +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.adder-pt] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "0.50.0" +path = "../../../../framework/wasm-adapter" + +[workspace] +members = ["."] diff --git a/contracts/parametric-tests/adder-pt/wasm/src/lib.rs b/contracts/parametric-tests/adder-pt/wasm/src/lib.rs new file mode 100644 index 0000000000..f8cbe2534c --- /dev/null +++ b/contracts/parametric-tests/adder-pt/wasm/src/lib.rs @@ -0,0 +1,26 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 2 +// Async Callback (empty): 1 +// Total number of exported functions: 4 + +#![no_std] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + adder_pt + ( + init => init + test_call_add => test_call_add + test_call_add_twice => test_call_add_twice + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/contracts/parametric-tests/addercaller/.gitignore b/contracts/parametric-tests/addercaller/.gitignore new file mode 100644 index 0000000000..2c76bc983e --- /dev/null +++ b/contracts/parametric-tests/addercaller/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +*/target/ + +# The mxpy output +/output*/ diff --git a/contracts/parametric-tests/addercaller/Cargo.toml b/contracts/parametric-tests/addercaller/Cargo.toml new file mode 100644 index 0000000000..87d4c67395 --- /dev/null +++ b/contracts/parametric-tests/addercaller/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "addercaller" +version = "0.0.0" +authors = [ "you",] +edition = "2018" +publish = false + +[lib] +path = "src/addercaller.rs" + +[dev-dependencies] +num-bigint = "0.4.2" + +[dependencies.multiversx-sc] +version = "0.50.0" + +[dev-dependencies.multiversx-sc-scenario] +version = "0.50.0" diff --git a/contracts/parametric-tests/addercaller/meta/Cargo.toml b/contracts/parametric-tests/addercaller/meta/Cargo.toml new file mode 100644 index 0000000000..269f6f9e32 --- /dev/null +++ b/contracts/parametric-tests/addercaller/meta/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "addercaller-meta" +version = "0.0.0" +edition = "2018" +publish = false +authors = [ "you",] + +[dev-dependencies] + +[dependencies.addercaller] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.50.0" diff --git a/contracts/parametric-tests/addercaller/meta/src/main.rs b/contracts/parametric-tests/addercaller/meta/src/main.rs new file mode 100644 index 0000000000..6cbc3497bd --- /dev/null +++ b/contracts/parametric-tests/addercaller/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/contracts/parametric-tests/addercaller/multiversx.json b/contracts/parametric-tests/addercaller/multiversx.json new file mode 100644 index 0000000000..7365539625 --- /dev/null +++ b/contracts/parametric-tests/addercaller/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/contracts/parametric-tests/addercaller/scenarios/addercaller.scen.json b/contracts/parametric-tests/addercaller/scenarios/addercaller.scen.json new file mode 100644 index 0000000000..79cef24783 --- /dev/null +++ b/contracts/parametric-tests/addercaller/scenarios/addercaller.scen.json @@ -0,0 +1,178 @@ +{ + "name": "addercaller", + "comment": "add then check", + "gasSchedule": "v3", + "steps": [ + { + "step": "setState", + "accounts": { + "address:owner": { + "nonce": "1", + "balance": "100000", + "esdt": { + "str:MYESDT": "200" + } + } + }, + "newAddresses": [ + { + "creatorAddress": "address:owner", + "creatorNonce": "1", + "newAddress": "sc:adder" + }, + { + "creatorAddress": "address:owner", + "creatorNonce": "2", + "newAddress": "sc:addercaller" + } + ] + }, + { + "step": "scDeploy", + "id": "deploy adder", + "tx": { + "from": "address:owner", + "contractCode": "file:../../myadder/output/adder.wasm", + "arguments": [ + "5" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scDeploy", + "id": "deploy addercaller", + "tx": { + "from": "address:owner", + "contractCode": "file:../output/addercaller.wasm", + "arguments": [ + "sc:adder" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "id": "call adder", + "tx": { + "from": "address:owner", + "to": "sc:adder", + "function": "add", + "value": "1000", + "arguments": [ + "3" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": ["8"], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "id": "call addercaller egld", + "tx": { + "from": "address:owner", + "to": "sc:addercaller", + "function": "call_adder", + "value": "1000", + "arguments": [ + "4" + ], + "gasLimit": "15,000,000", + "gasPrice": "0" + }, + "expect": { + "out": ["12", "str:added"], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "id": "call addercaller esdt", + "tx": { + "from": "address:owner", + "to": "sc:addercaller", + "function": "call_adder_esdt", + "esdtValue": [ + { + "tokenIdentifier": "str:MYESDT", + "value": "30" + } + ], + "arguments": [ + "5" + ], + "gasLimit": "15,000,000", + "gasPrice": "0" + }, + "expect": { + "out": ["17", "str:added-esdt"], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "checkState", + "accounts": { + "address:owner": { + "nonce": "*", + "balance": "98000", + "storage": {}, + "code": "", + "esdt": { + "str:MYESDT": "170" + } + }, + "sc:adder": { + "nonce": "0", + "balance": "1030", + "storage": { + "str:sum": "17" + }, + "code": "file:../../myadder/output/adder.wasm", + "esdt": { + "str:MYESDT": "20" + } + }, + "sc:addercaller": { + "nonce": "0", + "balance": "970", + "storage": { + "str:dest": "sc:adder" + }, + "code": "file:../output/addercaller.wasm", + "esdt": { + "str:MYESDT": "10" + } + } + } + } + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/addercaller/scenarios/addercaller_out_of_funds.scen.json b/contracts/parametric-tests/addercaller/scenarios/addercaller_out_of_funds.scen.json new file mode 100644 index 0000000000..503fe897b9 --- /dev/null +++ b/contracts/parametric-tests/addercaller/scenarios/addercaller_out_of_funds.scen.json @@ -0,0 +1,69 @@ +{ + "name": "addercaller", + "comment": "add then check", + "gasSchedule": "v3", + "steps": [ + { + "step": "setState", + "accounts": { + "address:owner": { + "nonce": "1", + "balance": "100000", + "esdt": { + "str:MYESDT": "200" + } + } + }, + "newAddresses": [ + { + "creatorAddress": "address:owner", + "creatorNonce": "1", + "newAddress": "sc:adder" + } + ] + }, + { + "step": "scDeploy", + "id": "deploy adder", + "tx": { + "from": "address:owner", + "contractCode": "file:../../myadder/output/adder.wasm", + "arguments": [ + "5" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "id": "call adder: insufficient EGLD balance", + "tx": { + "from": "address:owner", + "to": "sc:adder", + "function": "add", + "value": "1000000", + "arguments": [ + "3" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "7", + "message": "*", + "logs": "*", + "gas": "*", + "refund": "*" + } + } + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/addercaller/src/addercaller.rs b/contracts/parametric-tests/addercaller/src/addercaller.rs new file mode 100644 index 0000000000..058cbcc71a --- /dev/null +++ b/contracts/parametric-tests/addercaller/src/addercaller.rs @@ -0,0 +1,65 @@ +// A smart contract to test transfer & execute functions +// Initialize the contract with the address of the adder +// The endpoints `call_adder` and `call_adder_esdt` accepts +// tokens in EGLD and ESDT and performs transfer & execute +// to the adder's `add` endpoint. + +#![no_std] + +multiversx_sc::imports!(); + +/// One of the simplest smart contracts possible, +/// it holds a single variable in storage, which anyone can increment. +#[multiversx_sc::contract] +pub trait AdderCaller { + #[storage_mapper("dest")] + fn dest(&self) -> SingleValueMapper; + + #[init] + fn init(&self, dest: &ManagedAddress) { + self.dest().set(dest); + } + + #[endpoint] + #[payable("EGLD")] + fn call_adder(&self, value: BigUint) -> ManagedBuffer { + let mut arg_buffer = ManagedArgBuffer::new(); + arg_buffer.push_arg(value); + + let result = self.send_raw().direct_egld_execute( + &self.dest().get(), + &BigUint::from(30u32), + 5000000, + &ManagedBuffer::from(b"add"), + &arg_buffer, + ); + + match result { + Result::Err(e) => sc_panic!(e), + Result::Ok(_) => ManagedBuffer::from("added"), + } + } + + #[endpoint] + #[payable("MYESDT")] + fn call_adder_esdt(&self, value: BigUint) -> ManagedBuffer { + let mut arg_buffer = ManagedArgBuffer::new(); + arg_buffer.push_arg(value); + + let result = self.send_raw().transfer_esdt_execute( + &self.dest().get(), + &TokenIdentifier::from_esdt_bytes(b"MYESDT"), + &BigUint::from(20u32), + 5000000, + &ManagedBuffer::from(b"add"), + &arg_buffer, + ); + + match result { + Result::Err(e) => sc_panic!(e), + Result::Ok(_) => ManagedBuffer::from("added-esdt"), + } + } +} + +// diff --git a/contracts/parametric-tests/addercaller/wasm/Cargo.lock b/contracts/parametric-tests/addercaller/wasm/Cargo.lock new file mode 100644 index 0000000000..ece2603700 --- /dev/null +++ b/contracts/parametric-tests/addercaller/wasm/Cargo.lock @@ -0,0 +1,188 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addercaller" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "addercaller-wasm" +version = "0.0.0" +dependencies = [ + "addercaller", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[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 = "multiversx-sc" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d79d1cea2d23e8f2545749c9b31952305b54c415af88b224b985784d3d6529d" +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.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-wasm-adapter" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4350e286afce68bb2448d30572f68dd344b2e98e160404dd7f7d13f185e7acfd" +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 = "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 = "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 = "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" diff --git a/contracts/parametric-tests/addercaller/wasm/Cargo.toml b/contracts/parametric-tests/addercaller/wasm/Cargo.toml new file mode 100644 index 0000000000..a70b306911 --- /dev/null +++ b/contracts/parametric-tests/addercaller/wasm/Cargo.toml @@ -0,0 +1,34 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "addercaller-wasm" +version = "0.0.0" +edition = "2018" +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.addercaller] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "0.50.0" + +[workspace] +members = ["."] diff --git a/contracts/parametric-tests/addercaller/wasm/src/lib.rs b/contracts/parametric-tests/addercaller/wasm/src/lib.rs new file mode 100644 index 0000000000..250d1bf3fb --- /dev/null +++ b/contracts/parametric-tests/addercaller/wasm/src/lib.rs @@ -0,0 +1,26 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 2 +// Async Callback (empty): 1 +// Total number of exported functions: 4 + +#![no_std] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + addercaller + ( + init => init + call_adder => call_adder + call_adder_esdt => call_adder_esdt + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/contracts/parametric-tests/callee/.gitignore b/contracts/parametric-tests/callee/.gitignore new file mode 100644 index 0000000000..2c76bc983e --- /dev/null +++ b/contracts/parametric-tests/callee/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +*/target/ + +# The mxpy output +/output*/ diff --git a/contracts/parametric-tests/callee/Cargo.toml b/contracts/parametric-tests/callee/Cargo.toml new file mode 100644 index 0000000000..75d96aeadd --- /dev/null +++ b/contracts/parametric-tests/callee/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "callee" +version = "0.0.0" +authors = [ "you",] +edition = "2018" +publish = false + +[lib] +path = "src/callee.rs" + +[dev-dependencies] +num-bigint = "0.4.2" + +[dependencies.multiversx-sc] +version = "0.50.0" + +[dev-dependencies.multiversx-sc-scenario] +version = "0.50.0" diff --git a/contracts/parametric-tests/callee/meta/Cargo.toml b/contracts/parametric-tests/callee/meta/Cargo.toml new file mode 100644 index 0000000000..c0643a7440 --- /dev/null +++ b/contracts/parametric-tests/callee/meta/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "callee-meta" +version = "0.0.0" +edition = "2018" +publish = false +authors = [ "you",] + +[dev-dependencies] + +[dependencies.callee] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.50.0" diff --git a/contracts/parametric-tests/callee/meta/src/main.rs b/contracts/parametric-tests/callee/meta/src/main.rs new file mode 100644 index 0000000000..29f7b204ed --- /dev/null +++ b/contracts/parametric-tests/callee/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/contracts/parametric-tests/callee/multiversx.json b/contracts/parametric-tests/callee/multiversx.json new file mode 100644 index 0000000000..7365539625 --- /dev/null +++ b/contracts/parametric-tests/callee/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/contracts/parametric-tests/callee/src/callee.rs b/contracts/parametric-tests/callee/src/callee.rs new file mode 100644 index 0000000000..784f1755cf --- /dev/null +++ b/contracts/parametric-tests/callee/src/callee.rs @@ -0,0 +1,21 @@ +#![no_std] + +multiversx_sc::imports!(); + +#[multiversx_sc::contract] +pub trait CalleeContract { + #[init] + fn init(&self) {} + + #[endpoint] + #[payable("EGLD")] + fn fail_if_neg(&self, value: i64) -> ManagedBuffer { + require!(value >= 0, "negative"); + + if value == 0 { + ManagedBuffer::from("zero") + } else { + ManagedBuffer::from("positive") + } + } +} diff --git a/contracts/parametric-tests/callee/wasm/Cargo.lock b/contracts/parametric-tests/callee/wasm/Cargo.lock new file mode 100644 index 0000000000..676bdab054 --- /dev/null +++ b/contracts/parametric-tests/callee/wasm/Cargo.lock @@ -0,0 +1,188 @@ +# 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.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "callee" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "callee-wasm" +version = "0.0.0" +dependencies = [ + "callee", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[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 = "multiversx-sc" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d79d1cea2d23e8f2545749c9b31952305b54c415af88b224b985784d3d6529d" +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.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-wasm-adapter" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4350e286afce68bb2448d30572f68dd344b2e98e160404dd7f7d13f185e7acfd" +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 = "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 = "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 = "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" diff --git a/contracts/parametric-tests/callee/wasm/Cargo.toml b/contracts/parametric-tests/callee/wasm/Cargo.toml new file mode 100644 index 0000000000..b02c242821 --- /dev/null +++ b/contracts/parametric-tests/callee/wasm/Cargo.toml @@ -0,0 +1,34 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "callee-wasm" +version = "0.0.0" +edition = "2018" +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.callee] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "0.50.0" + +[workspace] +members = ["."] diff --git a/contracts/parametric-tests/callee/wasm/src/lib.rs b/contracts/parametric-tests/callee/wasm/src/lib.rs new file mode 100644 index 0000000000..c45d95e9d1 --- /dev/null +++ b/contracts/parametric-tests/callee/wasm/src/lib.rs @@ -0,0 +1,25 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 1 +// Async Callback (empty): 1 +// Total number of exported functions: 3 + +#![no_std] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + callee + ( + init => init + fail_if_neg => fail_if_neg + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/contracts/parametric-tests/caller/.gitignore b/contracts/parametric-tests/caller/.gitignore new file mode 100644 index 0000000000..2c76bc983e --- /dev/null +++ b/contracts/parametric-tests/caller/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +*/target/ + +# The mxpy output +/output*/ diff --git a/contracts/parametric-tests/caller/Cargo.toml b/contracts/parametric-tests/caller/Cargo.toml new file mode 100644 index 0000000000..317a0399b8 --- /dev/null +++ b/contracts/parametric-tests/caller/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "caller" +version = "0.0.0" +authors = [ "you",] +edition = "2018" +publish = false + +[lib] +path = "src/caller.rs" + +[dev-dependencies] +num-bigint = "0.4.2" + +[dependencies.multiversx-sc] +version = "0.50.0" + +[dev-dependencies.multiversx-sc-scenario] +version = "0.50.0" diff --git a/contracts/parametric-tests/caller/meta/Cargo.toml b/contracts/parametric-tests/caller/meta/Cargo.toml new file mode 100644 index 0000000000..e5ecdbe8bd --- /dev/null +++ b/contracts/parametric-tests/caller/meta/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "caller-meta" +version = "0.0.0" +edition = "2018" +publish = false +authors = [ "you",] + +[dev-dependencies] + +[dependencies.caller] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.50.0" diff --git a/contracts/parametric-tests/caller/meta/src/main.rs b/contracts/parametric-tests/caller/meta/src/main.rs new file mode 100644 index 0000000000..0e1f1c0a89 --- /dev/null +++ b/contracts/parametric-tests/caller/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/contracts/parametric-tests/caller/multiversx.json b/contracts/parametric-tests/caller/multiversx.json new file mode 100644 index 0000000000..7365539625 --- /dev/null +++ b/contracts/parametric-tests/caller/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/contracts/parametric-tests/caller/scenarios/caller.scen.json b/contracts/parametric-tests/caller/scenarios/caller.scen.json new file mode 100644 index 0000000000..a77f5616fd --- /dev/null +++ b/contracts/parametric-tests/caller/scenarios/caller.scen.json @@ -0,0 +1,185 @@ +{ + "name": "caller", + "steps": [ + { + "step": "externalSteps", + "path": "steps/init.steps.json" + }, + { + "step": "scCall", + "id": "positive", + "comment": "send a positive number with 1k EGLD to caller", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "1000", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "3", + "500" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": ["str:positive", "str:done"], + "status": "" + } + }, + { + "step": "externalSteps", + "path": "steps/check_1.steps.json" + }, + { + "step": "scCall", + "id": "negative: error message", + "comment": "owner -> caller -> callee wrong func name", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "500", + "arguments": [ + "sc:callee", + "str:fail_if_negative", + "-1", + "250" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "10", + "message": "str:invalid function (not found)", + "out": [] + } + }, + { + "step": "externalSteps", + "path": "steps/check_1.steps.json" + }, + { + "step": "scCall", + "id": "negative: error message", + "comment": "owner -> caller -> callee. callee fails and everything is reverted", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "500", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "-1", + "250" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "10", + "message": "str:error signalled by smartcontract", + "out": [] + } + }, + { + "step": "externalSteps", + "path": "steps/check_1.steps.json" + }, + { + "step": "scCall", + "id": "positive with 0 EGLD", + "comment": "send a positive number with 0 EGLD to caller", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "0", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "3", + "0" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": ["str:positive", "str:done"], + "status": "" + } + }, + { + "step": "checkState", + "accounts": { + "address:owner": { + "nonce": "*", + "balance": "99000", + "storage": {}, + "code": "" + }, + "sc:caller": { + "nonce": "0", + "balance": "500", + "storage": {}, + "code": "file:../output/caller.wasm" + }, + "sc:callee": { + "nonce": "0", + "balance": "500", + "storage": {}, + "code": "file:../../callee/output/callee.wasm" + } + } + }, + { + "step": "scCall", + "id": "positive with 1 EGLD", + "comment": "send a positive number with an odd number of EGLD to caller", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "1", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "3", + "0" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": ["str:positive", "str:done"], + "status": "" + } + }, + { + "step": "checkState", + "accounts": { + "address:owner": { + "nonce": "*", + "balance": "98999", + "storage": {}, + "code": "" + }, + "sc:caller": { + "nonce": "0", + "balance": "501", + "storage": {}, + "code": "file:../output/caller.wasm" + }, + "sc:callee": { + "nonce": "0", + "balance": "500", + "storage": {}, + "code": "file:../../callee/output/callee.wasm" + } + } + } + + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/caller/scenarios/errors.scen.json b/contracts/parametric-tests/caller/scenarios/errors.scen.json new file mode 100644 index 0000000000..097787b281 --- /dev/null +++ b/contracts/parametric-tests/caller/scenarios/errors.scen.json @@ -0,0 +1,96 @@ +{ + "name": "caller", + "steps": [ + { + "step": "externalSteps", + "path": "steps/init.steps.json" + }, + { + "step": "externalSteps", + "path": "steps/check_init.steps.json" + }, + { + "step": "scCall", + "id": "out of funds", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "1000000000", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "3", + "0" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "7", + "message": "" + } + }, + { + "step": "externalSteps", + "path": "steps/check_init.steps.json" + }, + { + "step": "scCall", + "id": "out of funds - indirect", + "comment": "SC attempts to send too many tokens", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "1000", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "3", + "2000" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "10", + "message": "str:failed transfer (insufficient funds)" + } + }, + { + "step": "externalSteps", + "path": "steps/check_init.steps.json" + }, + { + "step": "scCall", + "id": "nonexistent account", + "comment": "indirect call to nonexistent account", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "1000", + "arguments": [ + "sc:invalidaddress", + "str:fail_if_neg", + "3", + "10" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "10", + "message": "*" + } + }, + { + "step": "externalSteps", + "path": "steps/check_init.steps.json" + } + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/caller/scenarios/exec_on_dest_ctx.scen.json b/contracts/parametric-tests/caller/scenarios/exec_on_dest_ctx.scen.json new file mode 100644 index 0000000000..2a1aee42fa --- /dev/null +++ b/contracts/parametric-tests/caller/scenarios/exec_on_dest_ctx.scen.json @@ -0,0 +1,185 @@ +{ + "name": "caller", + "steps": [ + { + "step": "externalSteps", + "path": "steps/init.steps.json" + }, + { + "step": "scCall", + "id": "positive", + "comment": "send a positive number with 1k EGLD to caller", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other_exec_on_dest_ctx", + "value": "1000", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "3", + "500" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": ["str:positive", "str:done"], + "status": "" + } + }, + { + "step": "externalSteps", + "path": "steps/check_1.steps.json" + }, + { + "step": "scCall", + "id": "negative: error message", + "comment": "owner -> caller -> callee wrong func name", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "500", + "arguments": [ + "sc:callee", + "str:fail_if_negative", + "-1", + "250" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "10", + "message": "str:invalid function (not found)", + "out": [] + } + }, + { + "step": "externalSteps", + "path": "steps/check_1.steps.json" + }, + { + "step": "scCall", + "id": "negative: error message", + "comment": "owner -> caller -> callee. callee fails and everything is reverted", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "500", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "-1", + "250" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "10", + "message": "str:error signalled by smartcontract", + "out": [] + } + }, + { + "step": "externalSteps", + "path": "steps/check_1.steps.json" + }, + { + "step": "scCall", + "id": "positive with 0 EGLD", + "comment": "send a positive number with 0 EGLD to caller", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "0", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "3", + "0" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": ["str:positive", "str:done"], + "status": "" + } + }, + { + "step": "checkState", + "accounts": { + "address:owner": { + "nonce": "*", + "balance": "99000", + "storage": {}, + "code": "" + }, + "sc:caller": { + "nonce": "0", + "balance": "500", + "storage": {}, + "code": "file:../output/caller.wasm" + }, + "sc:callee": { + "nonce": "0", + "balance": "500", + "storage": {}, + "code": "file:../../callee/output/callee.wasm" + } + } + }, + { + "step": "scCall", + "id": "positive with 1 EGLD", + "comment": "send a positive number with an odd number of EGLD to caller", + "tx": { + "from": "address:owner", + "to": "sc:caller", + "function": "call_other", + "value": "1", + "arguments": [ + "sc:callee", + "str:fail_if_neg", + "3", + "0" + ], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": ["str:positive", "str:done"], + "status": "" + } + }, + { + "step": "checkState", + "accounts": { + "address:owner": { + "nonce": "*", + "balance": "98999", + "storage": {}, + "code": "" + }, + "sc:caller": { + "nonce": "0", + "balance": "501", + "storage": {}, + "code": "file:../output/caller.wasm" + }, + "sc:callee": { + "nonce": "0", + "balance": "500", + "storage": {}, + "code": "file:../../callee/output/callee.wasm" + } + } + } + + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/caller/scenarios/steps/check_1.steps.json b/contracts/parametric-tests/caller/scenarios/steps/check_1.steps.json new file mode 100644 index 0000000000..7ed1ee3de4 --- /dev/null +++ b/contracts/parametric-tests/caller/scenarios/steps/check_1.steps.json @@ -0,0 +1,29 @@ +{ + "name": "check after 1st call", + "steps": [ + { + "step": "checkState", + "comment": "caller should keep half of the EGLD", + "accounts": { + "address:owner": { + "nonce": "*", + "balance": "99000", + "storage": {}, + "code": "" + }, + "sc:caller": { + "nonce": "0", + "balance": "500", + "storage": {}, + "code": "file:../../output/caller.wasm" + }, + "sc:callee": { + "nonce": "0", + "balance": "500", + "storage": {}, + "code": "file:../../../callee/output/callee.wasm" + } + } + } + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/caller/scenarios/steps/check_init.steps.json b/contracts/parametric-tests/caller/scenarios/steps/check_init.steps.json new file mode 100644 index 0000000000..35522c8580 --- /dev/null +++ b/contracts/parametric-tests/caller/scenarios/steps/check_init.steps.json @@ -0,0 +1,29 @@ +{ + "name": "check after 1st call", + "steps": [ + { + "step": "checkState", + "comment": "caller should keep half of the EGLD", + "accounts": { + "address:owner": { + "nonce": "*", + "balance": "100000", + "storage": {}, + "code": "" + }, + "sc:caller": { + "nonce": "0", + "balance": "0", + "storage": {}, + "code": "file:../../output/caller.wasm" + }, + "sc:callee": { + "nonce": "0", + "balance": "0", + "storage": {}, + "code": "file:../../../callee/output/callee.wasm" + } + } + } + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/caller/scenarios/steps/init.steps.json b/contracts/parametric-tests/caller/scenarios/steps/init.steps.json new file mode 100644 index 0000000000..9a9639ede9 --- /dev/null +++ b/contracts/parametric-tests/caller/scenarios/steps/init.steps.json @@ -0,0 +1,57 @@ +{ + "name": "init and deploy", + "comment": "initialize the owner account and deploy caller and callee", + "steps": [ + { + "step": "setState", + "accounts": { + "address:owner": { + "nonce": "1", + "balance": "100000" + } + }, + "newAddresses": [ + { + "creatorAddress": "address:owner", + "creatorNonce": "1", + "newAddress": "sc:callee" + }, + { + "creatorAddress": "address:owner", + "creatorNonce": "2", + "newAddress": "sc:caller" + } + ] + }, + { + "step": "scDeploy", + "id": "deploy callee", + "tx": { + "from": "address:owner", + "contractCode": "file:../../../callee/output/callee.wasm", + "arguments": [], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "" + } + }, + { + "step": "scDeploy", + "id": "deploy caller", + "tx": { + "from": "address:owner", + "contractCode": "file:../../output/caller.wasm", + "arguments": [], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "" + } + } + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/caller/src/caller.rs b/contracts/parametric-tests/caller/src/caller.rs new file mode 100644 index 0000000000..264c578b37 --- /dev/null +++ b/contracts/parametric-tests/caller/src/caller.rs @@ -0,0 +1,59 @@ +#![no_std] + +multiversx_sc::imports!(); + +#[multiversx_sc::contract] +pub trait CallerContract { + #[init] + fn init(&self) {} + + #[endpoint] + #[payable("EGLD")] + fn call_other( + &self, + dest: ManagedAddress, + func: ManagedBuffer, + value: i64, + to_send: BigUint, + ) -> ManagedBuffer { + let mut arg_buffer = ManagedArgBuffer::new(); + arg_buffer.push_arg(value); + + let result = + self.send_raw() + .direct_egld_execute(&dest, &to_send, 5000000, &func, &arg_buffer); + + match result { + Result::Err(_) => ManagedBuffer::from("failed"), + Result::Ok(_) => ManagedBuffer::from("done"), + } + } + + #[endpoint] + #[payable("EGLD")] + fn call_other_exec_on_dest_ctx( + &self, + dest: ManagedAddress, + func: ManagedBuffer, + value: i64, + to_send: BigUint, + ) -> ManagedBuffer { + let mut arg_buffer = ManagedArgBuffer::new(); + arg_buffer.push_arg(value); + + let result = self.send_raw().execute_on_dest_context_raw( + 5000000, + &dest, + &to_send, + &func, + &arg_buffer, + ); + + require!( + result.len() == 1, + "ExecuteOnDestContext result data is empty" + ); + + ManagedBuffer::from("done") + } +} diff --git a/contracts/parametric-tests/caller/wasm/Cargo.lock b/contracts/parametric-tests/caller/wasm/Cargo.lock new file mode 100644 index 0000000000..9196d6ec53 --- /dev/null +++ b/contracts/parametric-tests/caller/wasm/Cargo.lock @@ -0,0 +1,188 @@ +# 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.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "caller" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "caller-wasm" +version = "0.0.0" +dependencies = [ + "caller", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[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 = "multiversx-sc" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d79d1cea2d23e8f2545749c9b31952305b54c415af88b224b985784d3d6529d" +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.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-wasm-adapter" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4350e286afce68bb2448d30572f68dd344b2e98e160404dd7f7d13f185e7acfd" +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 = "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 = "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 = "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" diff --git a/contracts/parametric-tests/caller/wasm/Cargo.toml b/contracts/parametric-tests/caller/wasm/Cargo.toml new file mode 100644 index 0000000000..1811bbbb65 --- /dev/null +++ b/contracts/parametric-tests/caller/wasm/Cargo.toml @@ -0,0 +1,34 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "caller-wasm" +version = "0.0.0" +edition = "2018" +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.caller] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "0.50.0" + +[workspace] +members = ["."] diff --git a/contracts/parametric-tests/caller/wasm/src/lib.rs b/contracts/parametric-tests/caller/wasm/src/lib.rs new file mode 100644 index 0000000000..6a9cda55d7 --- /dev/null +++ b/contracts/parametric-tests/caller/wasm/src/lib.rs @@ -0,0 +1,26 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 2 +// Async Callback (empty): 1 +// Total number of exported functions: 4 + +#![no_std] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + caller + ( + init => init + call_other => call_other + call_other_exec_on_dest_ctx => call_other_exec_on_dest_ctx + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/contracts/parametric-tests/multisig-pt/.gitignore b/contracts/parametric-tests/multisig-pt/.gitignore new file mode 100644 index 0000000000..abc3e496f7 --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/.gitignore @@ -0,0 +1,11 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +*/target/ + +# The mxpy output +/output*/ + +# Kasmer +.property +generated_claims diff --git a/contracts/parametric-tests/multisig-pt/Cargo.toml b/contracts/parametric-tests/multisig-pt/Cargo.toml new file mode 100644 index 0000000000..2678f55690 --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "multisig-pt" +version = "0.0.0" +authors = [ "you",] +edition = "2018" +publish = false + +[lib] +path = "src/multisig_pt.rs" + +[dev-dependencies] +num-bigint = "0.4.2" + +[dependencies.multiversx-sc] +version = "0.50.0" +path = "../../../framework/base" + +[dev-dependencies.multiversx-sc-scenario] +version = "0.50.0" +path = "../../../framework/scenario" + diff --git a/contracts/parametric-tests/multisig-pt/README.md b/contracts/parametric-tests/multisig-pt/README.md new file mode 100644 index 0000000000..b50ddf6ba0 --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/README.md @@ -0,0 +1,17 @@ +# Parametric test example for: Multisig + +This is an example on how to write a basic parametric test contract. + +To run fuzzing on it using Kasmer, build the contracts and simply run + +``` +kasmer fuzz +``` + + +To run symbolic execution: + +``` +kasmer build +kasmer verify test_change_quorum --booster +``` diff --git a/contracts/parametric-tests/multisig-pt/foundry.json b/contracts/parametric-tests/multisig-pt/foundry.json new file mode 100644 index 0000000000..eac6b162bc --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/foundry.json @@ -0,0 +1,5 @@ +{ + "contract_paths": [ + "../../../deps/mx-sdk-rs/contracts/examples/multisig/output/multisig.wasm" + ] +} \ No newline at end of file diff --git a/contracts/parametric-tests/multisig-pt/kasmer.json b/contracts/parametric-tests/multisig-pt/kasmer.json new file mode 100644 index 0000000000..5700dd71d1 --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/kasmer.json @@ -0,0 +1,8 @@ +{ + "contracts": [ + { + "path": "../../examples/multisig", + "name": "multisig" + } + ] +} diff --git a/contracts/parametric-tests/multisig-pt/meta/Cargo.toml b/contracts/parametric-tests/multisig-pt/meta/Cargo.toml new file mode 100644 index 0000000000..ee01b2a96c --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/meta/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "multisig-pt-meta" +version = "0.0.0" +edition = "2018" +publish = false +authors = [ "you",] + +[dev-dependencies] + +[dependencies.multisig-pt] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.50.0" +path = "../../../../framework/meta" diff --git a/contracts/parametric-tests/multisig-pt/meta/src/main.rs b/contracts/parametric-tests/multisig-pt/meta/src/main.rs new file mode 100644 index 0000000000..53506c1477 --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/contracts/parametric-tests/multisig-pt/multiversx.json b/contracts/parametric-tests/multisig-pt/multiversx.json new file mode 100644 index 0000000000..7365539625 --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/contracts/parametric-tests/multisig-pt/src/multisig_proxy.rs b/contracts/parametric-tests/multisig-pt/src/multisig_proxy.rs new file mode 100644 index 0000000000..d3a3e32e0e --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/src/multisig_proxy.rs @@ -0,0 +1,580 @@ +// 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 MultisigProxy; + +impl TxProxyTrait for MultisigProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = MultisigProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + MultisigProxyMethods { wrapped_tx: tx } + } +} + +pub struct MultisigProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl MultisigProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: ProxyArg, + Arg1: ProxyArg>>, + >( + self, + quorum: Arg0, + board: Arg1, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .argument(&quorum) + .argument(&board) + .original_result() + } +} + +#[rustfmt::skip] +impl MultisigProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade< + Arg0: ProxyArg, + Arg1: ProxyArg>>, + >( + self, + quorum: Arg0, + board: Arg1, + ) -> TxTypedUpgrade { + self.wrapped_tx + .payment(NotPayable) + .raw_upgrade() + .argument(&quorum) + .argument(&board) + .original_result() + } +} + +#[rustfmt::skip] +impl MultisigProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + /// Allows the contract to receive funds even if it is marked as unpayable in the protocol. + pub fn deposit( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("deposit") + .original_result() + } + + /// Iterates through all actions and retrieves those that are still pending. + /// Serialized full action data: + /// - the action id + /// - the serialized action data + /// - (number of signers followed by) list of signer addresses. + pub fn get_pending_action_full_info( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getPendingActionFullInfo") + .original_result() + } + + /// Returns `true` (`1`) if the user has signed the action. + /// Does not check whether or not the user is still a board member and the signature valid. + pub fn signed< + Arg0: ProxyArg>, + Arg1: ProxyArg, + >( + self, + user: Arg0, + action_id: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("signed") + .argument(&user) + .argument(&action_id) + .original_result() + } + + /// Indicates user rights. + /// `0` = no rights, + /// `1` = can propose, but not sign, + /// `2` = can propose and sign. + pub fn user_role< + Arg0: ProxyArg>, + >( + self, + user: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("userRole") + .argument(&user) + .original_result() + } + + /// Lists all users that can sign actions. + pub fn get_all_board_members( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getAllBoardMembers") + .original_result() + } + + /// Lists all proposers that are not board members. + pub fn get_all_proposers( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getAllProposers") + .original_result() + } + + /// Used by board members to sign actions. + pub fn sign< + Arg0: ProxyArg, + >( + self, + action_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("sign") + .argument(&action_id) + .original_result() + } + + /// Board members can withdraw their signatures if they no longer desire for the action to be executed. + /// Actions that are left with no valid signatures can be then deleted to free up storage. + pub fn unsign< + Arg0: ProxyArg, + >( + self, + action_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("unsign") + .argument(&action_id) + .original_result() + } + + /// Clears storage pertaining to an action that is no longer supposed to be executed. + /// Any signatures that the action received must first be removed, via `unsign`. + /// Otherwise this endpoint would be prone to abuse. + pub fn discard_action< + Arg0: ProxyArg, + >( + self, + action_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("discardAction") + .argument(&action_id) + .original_result() + } + + /// Minimum number of signatures needed to perform any action. + pub fn quorum( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getQuorum") + .original_result() + } + + /// Denormalized board member count. + /// It is kept in sync with the user list by the contract. + pub fn num_board_members( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getNumBoardMembers") + .original_result() + } + + /// Denormalized proposer count. + /// It is kept in sync with the user list by the contract. + pub fn num_proposers( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getNumProposers") + .original_result() + } + + /// The index of the last proposed action. + /// 0 means that no action was ever proposed yet. + pub fn get_action_last_index( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getActionLastIndex") + .original_result() + } + + /// Serialized action data of an action with index. + pub fn get_action_data< + Arg0: ProxyArg, + >( + self, + action_id: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getActionData") + .argument(&action_id) + .original_result() + } + + /// Gets addresses of all users who signed an action. + /// Does not check if those users are still board members or not, + /// so the result may contain invalid signers. + pub fn get_action_signers< + Arg0: ProxyArg, + >( + self, + action_id: Arg0, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getActionSigners") + .argument(&action_id) + .original_result() + } + + /// Gets addresses of all users who signed an action and are still board members. + /// All these signatures are currently valid. + pub fn get_action_signer_count< + Arg0: ProxyArg, + >( + self, + action_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getActionSignerCount") + .argument(&action_id) + .original_result() + } + + /// It is possible for board members to lose their role. + /// They are not automatically removed from all actions when doing so, + /// therefore the contract needs to re-check every time when actions are performed. + /// This function is used to validate the signers before performing an action. + /// It also makes it easy to check before performing an action. + pub fn get_action_valid_signer_count< + Arg0: ProxyArg, + >( + self, + action_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getActionValidSignerCount") + .argument(&action_id) + .original_result() + } + + /// Initiates board member addition process. + /// Can also be used to promote a proposer to board member. + pub fn propose_add_board_member< + Arg0: ProxyArg>, + >( + self, + board_member_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("proposeAddBoardMember") + .argument(&board_member_address) + .original_result() + } + + /// Initiates proposer addition process.. + /// Can also be used to demote a board member to proposer. + pub fn propose_add_proposer< + Arg0: ProxyArg>, + >( + self, + proposer_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("proposeAddProposer") + .argument(&proposer_address) + .original_result() + } + + /// Removes user regardless of whether it is a board member or proposer. + pub fn propose_remove_user< + Arg0: ProxyArg>, + >( + self, + user_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("proposeRemoveUser") + .argument(&user_address) + .original_result() + } + + pub fn propose_change_quorum< + Arg0: ProxyArg, + >( + self, + new_quorum: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("proposeChangeQuorum") + .argument(&new_quorum) + .original_result() + } + + /// Propose a transaction in which the contract will perform a transfer-execute call. + /// Can send EGLD without calling anything. + /// Can call smart contract endpoints directly. + /// Doesn't really work with builtin functions. + pub fn propose_transfer_execute< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + >( + self, + to: Arg0, + egld_amount: Arg1, + function_call: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("proposeTransferExecute") + .argument(&to) + .argument(&egld_amount) + .argument(&function_call) + .original_result() + } + + /// Propose a transaction in which the contract will perform a transfer-execute call. + /// Can call smart contract endpoints directly. + /// Can use ESDTTransfer/ESDTNFTTransfer/MultiESDTTransfer to send tokens, while also optionally calling endpoints. + /// Works well with builtin functions. + /// Cannot simply send EGLD directly without calling anything. + pub fn propose_async_call< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + >( + self, + to: Arg0, + egld_amount: Arg1, + function_call: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("proposeAsyncCall") + .argument(&to) + .argument(&egld_amount) + .argument(&function_call) + .original_result() + } + + pub fn propose_sc_deploy_from_source< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg, + Arg3: ProxyArg>>, + >( + self, + amount: Arg0, + source: Arg1, + code_metadata: Arg2, + arguments: Arg3, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("proposeSCDeployFromSource") + .argument(&amount) + .argument(&source) + .argument(&code_metadata) + .argument(&arguments) + .original_result() + } + + pub fn propose_sc_upgrade_from_source< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + Arg3: ProxyArg, + Arg4: ProxyArg>>, + >( + self, + sc_address: Arg0, + amount: Arg1, + source: Arg2, + code_metadata: Arg3, + arguments: Arg4, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("proposeSCUpgradeFromSource") + .argument(&sc_address) + .argument(&amount) + .argument(&source) + .argument(&code_metadata) + .argument(&arguments) + .original_result() + } + + /// Returns `true` (`1`) if `getActionValidSignerCount >= getQuorum`. + pub fn quorum_reached< + Arg0: ProxyArg, + >( + self, + action_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("quorumReached") + .argument(&action_id) + .original_result() + } + + /// Proposers and board members use this to launch signed actions. + pub fn perform_action_endpoint< + Arg0: ProxyArg, + >( + self, + action_id: Arg0, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("performAction") + .argument(&action_id) + .original_result() + } + + pub fn dns_register< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + dns_address: Arg0, + name: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("dnsRegister") + .argument(&dns_address) + .argument(&name) + .original_result() + } +} + +#[type_abi] +#[derive(TopEncode)] +pub struct ActionFullInfo +where + Api: ManagedTypeApi, +{ + pub action_id: usize, + pub action_data: Action, + pub signers: ManagedVec>, +} + +#[rustfmt::skip] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, Clone)] +pub enum Action +where + Api: ManagedTypeApi, +{ + Nothing, + AddBoardMember(ManagedAddress), + AddProposer(ManagedAddress), + RemoveUser(ManagedAddress), + ChangeQuorum(usize), + SendTransferExecute(CallActionData), + SendAsyncCall(CallActionData), + SCDeployFromSource { + amount: BigUint, + source: ManagedAddress, + code_metadata: CodeMetadata, + arguments: ManagedVec>, + }, + SCUpgradeFromSource { + sc_address: ManagedAddress, + amount: BigUint, + source: ManagedAddress, + code_metadata: CodeMetadata, + arguments: ManagedVec>, + }, +} + +#[type_abi] +#[derive(NestedEncode, NestedDecode, Clone)] +pub struct CallActionData +where + Api: ManagedTypeApi, +{ + pub to: ManagedAddress, + pub egld_amount: BigUint, + pub endpoint_name: ManagedBuffer, + pub arguments: ManagedVec>, +} + +#[type_abi] +#[derive(TopEncode, TopDecode)] +pub enum UserRole { + None, + Proposer, + BoardMember, +} diff --git a/contracts/parametric-tests/multisig-pt/src/multisig_pt.rs b/contracts/parametric-tests/multisig-pt/src/multisig_pt.rs new file mode 100644 index 0000000000..b4f42ef0d2 --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/src/multisig_pt.rs @@ -0,0 +1,118 @@ +#![no_std] + +mod multisig_proxy; + +multiversx_sc::imports!(); + +static OWNER: &[u8; 32] = b"owner___________________________"; +static ALICE: &[u8; 32] = b"alice___________________________"; +static BOB: &[u8; 32] = b"bob_____________________________"; +static CHARLIE: &[u8; 32] = b"charlie_________________________"; +static MULTISIG: &[u8; 32] = b"multisig________________________"; + +#[multiversx_sc::contract] +pub trait TestMultisigContract { + #[init] + fn init(&self, code_path: ManagedBuffer) { + self.init_accounts(); + self.deploy(&code_path); + } + + fn init_accounts(&self) { + let owner = ManagedAddress::from(OWNER); + self.test_raw() + .create_account(&owner, 0, &BigUint::from(0u64)); + self.test_raw() + .create_account(&ManagedAddress::from(ALICE), 0, &BigUint::from(0u64)); + self.test_raw() + .create_account(&ManagedAddress::from(BOB), 0, &BigUint::from(0u64)); + self.test_raw() + .create_account(&ManagedAddress::from(CHARLIE), 0, &BigUint::from(0u64)); + + let multisig = ManagedAddress::from(MULTISIG); + self.test_raw().register_new_address(&owner, 0, &multisig); + } + + fn deploy(&self, code_path: &ManagedBuffer) { + let mut board = MultiValueEncoded::new(); + board.push(ManagedAddress::from(ALICE)); // board members = alice, bob, charlie + board.push(ManagedAddress::from(BOB)); + board.push(ManagedAddress::from(CHARLIE)); + + let multisig = self + .tx() + .from(ManagedAddress::from(OWNER)) + .typed(multisig_proxy::MultisigProxy) + .init(2usize, board) + .code_path(code_path) + .gas(5000000000000) + .returns(ReturnsNewManagedAddress) + .test_deploy(); + + self.test_raw().assert(self.get_quorum(&multisig) == 2usize); + self.test_raw() + .assert(self.get_num_board_members(&multisig) == 3usize); + } + + fn get_quorum(&self, multisig: &ManagedAddress) -> usize { + self.storage_raw().read_from_address(multisig, "quorum") + } + + fn get_num_board_members(&self, multisig: &ManagedAddress) -> usize { + self.storage_raw() + .read_from_address(multisig, "num_board_members") + } + + #[endpoint(test_change_quorum)] + fn test_change_quorum(&self, value: usize) { + let multisig = ManagedAddress::from(MULTISIG); + let alice = ManagedAddress::from(ALICE); + let bob = ManagedAddress::from(BOB); + + // make assumptions + self.test_raw() + .assume(value <= self.get_num_board_members(&multisig)); + + self.change_quorum_propose(&multisig, &alice, value); + self.change_quorum_sign(&multisig, &bob); + self.perform_action(&multisig, &alice); + + // check the final quorum + self.test_raw().assert(value == self.get_quorum(&multisig)); + } + + fn change_quorum_propose( + &self, + multisig: &ManagedAddress, + proposer: &ManagedAddress, + value: usize, + ) { + self.tx() + .from(proposer) + .to(multisig) + .typed(multisig_proxy::MultisigProxy) + .propose_change_quorum(value) + .gas(5000000) + .test_call(); + } + + fn change_quorum_sign(&self, multisig: &ManagedAddress, signer: &ManagedAddress) { + self.tx() + .from(signer) + .to(multisig) + .typed(multisig_proxy::MultisigProxy) + .sign(1usize) + .gas(5000000) + .test_call(); + } + + fn perform_action(&self, multisig: &ManagedAddress, performer: &ManagedAddress) { + self.tx() + .from(performer) + .to(multisig) + .typed(multisig_proxy::MultisigProxy) + .perform_action_endpoint(1usize) + .gas(5000000) + .test_call(); + } +} diff --git a/contracts/parametric-tests/multisig-pt/wasm/Cargo.lock b/contracts/parametric-tests/multisig-pt/wasm/Cargo.lock new file mode 100644 index 0000000000..bdfe4a4488 --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/wasm/Cargo.lock @@ -0,0 +1,178 @@ +# 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.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[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 = "multisig-pt" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multisig-pt-wasm" +version = "0.0.0" +dependencies = [ + "multisig-pt", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "multiversx-sc" +version = "0.50.3" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.19.0" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.19.0" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.50.3" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.50.3" +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 = "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 = "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 = "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" diff --git a/contracts/parametric-tests/multisig-pt/wasm/Cargo.toml b/contracts/parametric-tests/multisig-pt/wasm/Cargo.toml new file mode 100644 index 0000000000..5839357e14 --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/wasm/Cargo.toml @@ -0,0 +1,35 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "multisig-pt-wasm" +version = "0.0.0" +edition = "2018" +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.multisig-pt] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "0.50.0" +path = "../../../../framework/wasm-adapter" + +[workspace] +members = ["."] diff --git a/contracts/parametric-tests/multisig-pt/wasm/src/lib.rs b/contracts/parametric-tests/multisig-pt/wasm/src/lib.rs new file mode 100644 index 0000000000..044a2573fe --- /dev/null +++ b/contracts/parametric-tests/multisig-pt/wasm/src/lib.rs @@ -0,0 +1,25 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 1 +// Async Callback (empty): 1 +// Total number of exported functions: 3 + +#![no_std] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + multisig_pt + ( + init => init + test_change_quorum => test_change_quorum + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/contracts/parametric-tests/testapi-pt/.gitignore b/contracts/parametric-tests/testapi-pt/.gitignore new file mode 100644 index 0000000000..2c76bc983e --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +*/target/ + +# The mxpy output +/output*/ diff --git a/contracts/parametric-tests/testapi-pt/Cargo.toml b/contracts/parametric-tests/testapi-pt/Cargo.toml new file mode 100644 index 0000000000..6e7364b33e --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "test-testapi" +version = "0.0.0" +authors = [ "you",] +edition = "2018" +publish = false + +[lib] +path = "src/testapi_pt.rs" + +[dev-dependencies] +num-bigint = "0.4.2" + +[dependencies.multiversx-sc] +version = "0.50.0" +path = "../../../framework/base" + +[dev-dependencies.multiversx-sc-scenario] +version = "0.50.0" +path = "../../../framework/scenario" + diff --git a/contracts/parametric-tests/testapi-pt/foundry.json b/contracts/parametric-tests/testapi-pt/foundry.json new file mode 100644 index 0000000000..5a61e45e68 --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/foundry.json @@ -0,0 +1,3 @@ +{ + "contract_paths": [] +} \ No newline at end of file diff --git a/contracts/parametric-tests/testapi-pt/meta/Cargo.toml b/contracts/parametric-tests/testapi-pt/meta/Cargo.toml new file mode 100644 index 0000000000..6013e3b409 --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/meta/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "test-testapi-meta" +version = "0.0.0" +edition = "2018" +publish = false +authors = [ "you",] + +[dev-dependencies] + +[dependencies.test-testapi] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.50.0" +path = "../../../../framework/meta" diff --git a/contracts/parametric-tests/testapi-pt/meta/src/main.rs b/contracts/parametric-tests/testapi-pt/meta/src/main.rs new file mode 100644 index 0000000000..4ce9753347 --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/contracts/parametric-tests/testapi-pt/multiversx.json b/contracts/parametric-tests/testapi-pt/multiversx.json new file mode 100644 index 0000000000..7365539625 --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/contracts/parametric-tests/testapi-pt/src/testapi_pt.rs b/contracts/parametric-tests/testapi-pt/src/testapi_pt.rs new file mode 100644 index 0000000000..64a34ae44c --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/src/testapi_pt.rs @@ -0,0 +1,81 @@ +#![no_std] + +multiversx_sc::imports!(); + +#[multiversx_sc::contract] +pub trait TestTestapi { + #[init] + fn init(&self) { + let alice = ManagedAddress::from(b"alice___________________________"); + self.test_raw() + .create_account(&alice, 1, &BigUint::from(0u64)); + + self.test_set_balance(&alice); + self.test_set_esdt_balance(&alice); + self.test_set_timestamp(); + self.test_set_get_storage(&alice); + } + + fn test_set_balance(&self, addr: &ManagedAddress) { + // Given + let value = BigUint::from(100000000u64); + + // When + self.test_raw().set_balance(addr, &value); + + // Expect + let actual = self.blockchain().get_balance(addr); + + require!( + value == actual, + "Actual balance does not match the given value" + ); + } + + fn test_set_esdt_balance(&self, addr: &ManagedAddress) { + // Given + let value = BigUint::from(100000000u64); + let token = TokenIdentifier::from("MY_ESDT_TOKEN"); + + // When + self.test_raw().set_esdt_balance(addr, &token, &value); + + // Expect + let actual = self.blockchain().get_esdt_balance(addr, &token, 0u64); + + require!( + value == actual, + "Actual esdt balance does not match the given value" + ); + } + + fn test_set_timestamp(&self) { + // Given + let value = 1234567890u64; + + // When + self.test_raw().set_block_timestamp(value); + + // Expect + require!( + value == self.blockchain().get_block_timestamp(), + "Actual timestamp does not match the given value" + ); + } + + fn test_set_get_storage(&self, addr: &ManagedAddress) { + // Given + let key = ManagedBuffer::from(b"a_storage_key"); + let value = ManagedBuffer::from(b"a storage value"); + + // When + self.test_raw().set_storage(addr, &key, &value); + + // Expect + let actual = self.test_raw().get_storage(addr, &key); + require!( + actual == value, + "Actual storage does not match the given value" + ); + } +} diff --git a/contracts/parametric-tests/testapi-pt/wasm/Cargo.lock b/contracts/parametric-tests/testapi-pt/wasm/Cargo.lock new file mode 100644 index 0000000000..9416b3a3ec --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/wasm/Cargo.lock @@ -0,0 +1,178 @@ +# 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.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[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 = "multiversx-sc" +version = "0.50.3" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.19.0" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.19.0" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.50.3" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.50.3" +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 = "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 = "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 = "test-testapi" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "test-testapi-wasm" +version = "0.0.0" +dependencies = [ + "multiversx-sc-wasm-adapter", + "test-testapi", +] + +[[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" diff --git a/contracts/parametric-tests/testapi-pt/wasm/Cargo.toml b/contracts/parametric-tests/testapi-pt/wasm/Cargo.toml new file mode 100644 index 0000000000..21ef12dd9f --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/wasm/Cargo.toml @@ -0,0 +1,35 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "test-testapi-wasm" +version = "0.0.0" +edition = "2018" +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.test-testapi] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "0.50.0" +path = "../../../../framework/wasm-adapter" + +[workspace] +members = ["."] diff --git a/contracts/parametric-tests/testapi-pt/wasm/src/lib.rs b/contracts/parametric-tests/testapi-pt/wasm/src/lib.rs new file mode 100644 index 0000000000..d9f43452ba --- /dev/null +++ b/contracts/parametric-tests/testapi-pt/wasm/src/lib.rs @@ -0,0 +1,24 @@ +// 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::endpoints! { + test_testapi + ( + init => init + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/framework/base/src/api.rs b/framework/base/src/api.rs index 094522d1ac..f74c60a9ad 100644 --- a/framework/base/src/api.rs +++ b/framework/base/src/api.rs @@ -11,6 +11,7 @@ pub(crate) mod managed_types; mod print_api; mod send_api; mod storage_api; +mod test_api; pub mod uncallable; mod vm_api; @@ -27,6 +28,7 @@ pub use managed_types::*; pub use print_api::*; pub use send_api::*; pub use storage_api::*; +pub use test_api::*; pub use vm_api::VMApi; // Backwards compatibility. diff --git a/framework/base/src/api/external_view/ev_wrapper.rs b/framework/base/src/api/external_view/ev_wrapper.rs index 6b88231e5b..a484a6c5cc 100644 --- a/framework/base/src/api/external_view/ev_wrapper.rs +++ b/framework/base/src/api/external_view/ev_wrapper.rs @@ -3,7 +3,7 @@ use core::marker::PhantomData; use crate::api::{ BlockchainApi, CallTypeApi, CallValueApi, CryptoApi, EndpointArgumentApi, EndpointFinishApi, ErrorApi, HandleTypeInfo, LogApi, ManagedTypeApi, PrintApi, SendApi, StaticVarApi, - StorageMapperApi, StorageWriteApi, VMApi, + StorageMapperApi, StorageWriteApi, TestApi, VMApi, }; #[derive(Clone)] @@ -170,6 +170,17 @@ impl CallTypeApi for ExternalViewApi where A: VMApi {} impl StorageMapperApi for ExternalViewApi where A: VMApi {} +impl TestApi for ExternalViewApi +where + A: VMApi, +{ + type TestApiImpl = A::TestApiImpl; + + fn test_api_impl() -> Self::TestApiImpl { + A::test_api_impl() + } +} + impl VMApi for ExternalViewApi where A: VMApi, diff --git a/framework/base/src/api/test_api.rs b/framework/base/src/api/test_api.rs new file mode 100644 index 0000000000..46d76a86c5 --- /dev/null +++ b/framework/base/src/api/test_api.rs @@ -0,0 +1,104 @@ +use super::{ErrorApi, ErrorApiImpl, HandleTypeInfo, ManagedTypeApi}; + +const TEST_API_ERROR_MSG: &str = "cannot call the test API in this context"; + +pub trait TestApi: ManagedTypeApi + ErrorApi { + type TestApiImpl: TestApiImpl + + HandleTypeInfo< + ManagedBufferHandle = Self::ManagedBufferHandle, + BigIntHandle = Self::BigIntHandle, + BigFloatHandle = Self::BigFloatHandle, + EllipticCurveHandle = Self::EllipticCurveHandle, + >; + + fn test_api_impl() -> Self::TestApiImpl; +} + +#[allow(unused_variables)] +pub trait TestApiImpl: HandleTypeInfo + ErrorApi { + fn create_account( + &self, + address: Self::ManagedBufferHandle, + nonce: u64, + balance: Self::BigIntHandle, + ) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + fn register_new_address( + &self, + owner: Self::ManagedBufferHandle, + nonce: u64, + new_address: Self::ManagedBufferHandle, + ) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + // Deploy a contract whose code was previously fetched using "fetchWasmSource" in Mandos. + fn deploy_contract( + &self, + owner: Self::ManagedBufferHandle, + gas_limit: u64, + value: Self::BigIntHandle, + code_path: Self::ManagedBufferHandle, + arguments: Self::ManagedBufferHandle, + result_address_handle: Self::ManagedBufferHandle, + ) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + // Set storage of any account + fn set_storage( + &self, + address: Self::ManagedBufferHandle, + key: Self::ManagedBufferHandle, + value: Self::ManagedBufferHandle, + ) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + // Get storage of any account + fn get_storage( + &self, + address: Self::ManagedBufferHandle, + key: Self::ManagedBufferHandle, + result_value: Self::ManagedBufferHandle, + ) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + // Start a prank: set the caller address for contract calls until stop_prank + fn start_prank(&self, address: Self::ManagedBufferHandle) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + // Stop a prank: reset the caller address + fn stop_prank(&self) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + fn assume(&self, p: bool) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + fn assert(&self, p: bool) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + fn set_block_timestamp(&self, timestamp: u64) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + fn set_balance(&self, address: Self::ManagedBufferHandle, value: Self::BigIntHandle) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } + + fn set_esdt_balance( + &self, + address: Self::ManagedBufferHandle, + token_id: Self::ManagedBufferHandle, + value: Self::BigIntHandle, + ) { + Self::error_api_impl().signal_error(TEST_API_ERROR_MSG.as_bytes()); + } +} diff --git a/framework/base/src/api/uncallable.rs b/framework/base/src/api/uncallable.rs index f666edc4db..2fa8a95523 100644 --- a/framework/base/src/api/uncallable.rs +++ b/framework/base/src/api/uncallable.rs @@ -17,6 +17,7 @@ mod print_api_uncallable; mod send_api_uncallable; mod static_var_api_uncallable; mod storage_api_uncallable; +mod test_api_uncallable; mod vm_api_uncallable; /// Dummy type with no implementation. diff --git a/framework/base/src/api/uncallable/test_api_uncallable.rs b/framework/base/src/api/uncallable/test_api_uncallable.rs new file mode 100644 index 0000000000..563c27e423 --- /dev/null +++ b/framework/base/src/api/uncallable/test_api_uncallable.rs @@ -0,0 +1,13 @@ +use crate::api::{TestApi, TestApiImpl}; + +use super::UncallableApi; + +impl TestApi for UncallableApi { + type TestApiImpl = Self; + + fn test_api_impl() -> Self::TestApiImpl { + unreachable!() + } +} + +impl TestApiImpl for UncallableApi {} diff --git a/framework/base/src/api/vm_api.rs b/framework/base/src/api/vm_api.rs index c7cac0daa2..7a39c24ee2 100644 --- a/framework/base/src/api/vm_api.rs +++ b/framework/base/src/api/vm_api.rs @@ -1,7 +1,7 @@ use super::{ BlockchainApi, CallTypeApi, CallValueApi, CryptoApi, EndpointArgumentApi, EndpointFinishApi, ErrorApi, LogApi, ManagedTypeApi, PrintApi, SendApi, StorageMapperApi, StorageReadApi, - StorageReadApiImpl, StorageWriteApi, + StorageReadApiImpl, StorageWriteApi, TestApi, }; pub trait VMApi: @@ -19,6 +19,7 @@ pub trait VMApi: + PrintApi + CallTypeApi + StorageMapperApi + + TestApi + Clone // TODO: remove + PartialEq // for helping derive PartialEq for managed types + Eq diff --git a/framework/base/src/contract_base/contract_base_trait.rs b/framework/base/src/contract_base/contract_base_trait.rs index 342b9ea61d..20af9b0597 100644 --- a/framework/base/src/contract_base/contract_base_trait.rs +++ b/framework/base/src/contract_base/contract_base_trait.rs @@ -1,6 +1,6 @@ use super::{ BlockchainWrapper, CallValueWrapper, CryptoWrapper, ErrorHelper, ManagedSerializer, - SendRawWrapper, SendWrapper, StorageRawWrapper, + SendRawWrapper, SendWrapper, StorageRawWrapper, TestRawWrapper, }; use crate::{ api::VMApi, @@ -71,4 +71,9 @@ pub trait ContractBase: Sized { fn storage_raw(&self) -> StorageRawWrapper { StorageRawWrapper::new() } + + #[inline] + fn test_raw(&self) -> TestRawWrapper { + TestRawWrapper::new() + } } diff --git a/framework/base/src/contract_base/wrappers.rs b/framework/base/src/contract_base/wrappers.rs index e90e5dbcc2..57a3161c99 100644 --- a/framework/base/src/contract_base/wrappers.rs +++ b/framework/base/src/contract_base/wrappers.rs @@ -6,6 +6,7 @@ mod send_raw_wrapper; mod send_wrapper; mod serializer; mod storage_raw_wrapper; +mod test_raw_wrapper; pub use blockchain_wrapper::BlockchainWrapper; pub use call_value_wrapper::CallValueWrapper; @@ -15,3 +16,4 @@ pub use send_raw_wrapper::SendRawWrapper; pub use send_wrapper::SendWrapper; pub use serializer::{ExitCodecErrorHandler, ManagedSerializer}; pub use storage_raw_wrapper::StorageRawWrapper; +pub use test_raw_wrapper::TestRawWrapper; diff --git a/framework/base/src/contract_base/wrappers/test_raw_wrapper.rs b/framework/base/src/contract_base/wrappers/test_raw_wrapper.rs new file mode 100644 index 0000000000..d3d0e58580 --- /dev/null +++ b/framework/base/src/contract_base/wrappers/test_raw_wrapper.rs @@ -0,0 +1,129 @@ +use core::marker::PhantomData; + +use crate::{ + api::{TestApi, TestApiImpl}, + types::{ + BigUint, ManagedAddress, ManagedArgBuffer, ManagedBuffer, ManagedType, TokenIdentifier, + }, +}; + +#[derive(Default)] +pub struct TestRawWrapper +where + A: TestApi, +{ + _phantom: PhantomData, +} + +impl TestRawWrapper +where + A: TestApi, +{ + pub fn new() -> Self { + TestRawWrapper { + _phantom: PhantomData, + } + } + + pub fn create_account(&self, address: &ManagedAddress, nonce: u64, balance: &BigUint) { + A::test_api_impl().create_account(address.get_handle(), nonce, balance.get_handle()); + } + + pub fn register_new_address( + self, + owner: &ManagedAddress, + nonce: u64, + new_address: &ManagedAddress, + ) { + A::test_api_impl().register_new_address( + owner.get_handle(), + nonce, + new_address.get_handle(), + ); + } + + // Deploy a contract whose code was previously fetched using "fetchWasmSource" in Mandos. + pub fn deploy_contract( + self, + owner: &ManagedAddress, + gas_limit: u64, + value: &BigUint, + code_path: &ManagedBuffer, + arguments: &ManagedArgBuffer, + ) -> ManagedAddress { + let dest = ManagedAddress::zero(); + + A::test_api_impl().deploy_contract( + owner.get_handle(), + gas_limit, + value.get_handle(), + code_path.get_handle(), + arguments.get_handle(), + dest.get_handle(), + ); + + dest + } + + // Set storage of any account + pub fn set_storage( + self, + address: &ManagedAddress, + key: &ManagedBuffer, + value: &ManagedBuffer, + ) { + A::test_api_impl().set_storage(address.get_handle(), key.get_handle(), value.get_handle()); + } + + // Get storage of any account + pub fn get_storage( + self, + address: &ManagedAddress, + key: &ManagedBuffer, + ) -> ManagedBuffer { + let dest = ManagedBuffer::new(); + + A::test_api_impl().get_storage(address.get_handle(), key.get_handle(), dest.get_handle()); + + dest + } + + // Start a prank: set the caller address for contract calls until stop_prank + pub fn start_prank(self, address: &ManagedAddress) { + A::test_api_impl().start_prank(address.get_handle()); + } + + // Stop a prank: reset the caller address + pub fn stop_prank(self) { + A::test_api_impl().stop_prank(); + } + + pub fn assume(self, p: bool) { + A::test_api_impl().assume(p); + } + + pub fn assert(self, p: bool) { + A::test_api_impl().assert(p); + } + + pub fn set_block_timestamp(self, timestamp: u64) { + A::test_api_impl().set_block_timestamp(timestamp); + } + + pub fn set_balance(self, address: &ManagedAddress, value: &BigUint) { + A::test_api_impl().set_balance(address.get_handle(), value.get_handle()); + } + + pub fn set_esdt_balance( + self, + address: &ManagedAddress, + token_id: &TokenIdentifier, + value: &BigUint, + ) { + A::test_api_impl().set_esdt_balance( + address.get_handle(), + token_id.get_handle(), + value.get_handle(), + ); + } +} diff --git a/framework/base/src/types/interaction/annotated/annotated_impl_managed_buffer.rs b/framework/base/src/types/interaction/annotated/annotated_impl_managed_buffer.rs index eecaad75b5..e1a07af5b3 100644 --- a/framework/base/src/types/interaction/annotated/annotated_impl_managed_buffer.rs +++ b/framework/base/src/types/interaction/annotated/annotated_impl_managed_buffer.rs @@ -29,6 +29,33 @@ where } } +impl AnnotatedValue> for &ManagedBuffer +where + Env: TxEnv, +{ + fn annotation(&self, _env: &Env) -> ManagedBuffer { + self.hex_expr() + } + + #[inline] + fn to_value(&self, _env: &Env) -> ManagedBuffer { + (*self).clone() + } + + #[inline] + fn into_value(self, _env: &Env) -> ManagedBuffer { + self.clone() + } + + #[inline] + fn with_value_ref(&self, _env: &Env, f: F) -> R + where + F: FnOnce(&ManagedBuffer) -> R, + { + f(self) + } +} + impl AnnotatedValue> for () where Env: TxEnv, diff --git a/framework/base/src/types/interaction/tx.rs b/framework/base/src/types/interaction/tx.rs index 905b9af8fc..db0fcb9c5b 100644 --- a/framework/base/src/types/interaction/tx.rs +++ b/framework/base/src/types/interaction/tx.rs @@ -11,10 +11,10 @@ use crate::{ use multiversx_sc_codec::TopEncodeMulti; use super::{ - AnnotatedValue, Code, ContractCallBase, ContractCallNoPayment, ContractCallWithEgld, + AnnotatedValue, Code, CodePath, ContractCallBase, ContractCallNoPayment, ContractCallWithEgld, ContractDeploy, DeployCall, Egld, EgldPayment, ExplicitGas, FromSource, FunctionCall, ManagedArgBuffer, OriginalResultMarker, RHList, RHListAppendNoRet, RHListAppendRet, RHListItem, - TxCodeSource, TxCodeValue, TxData, TxDataFunctionCall, TxEgldValue, TxEnv, + TxCodePathValue, TxCodeSource, TxCodeValue, TxData, TxDataFunctionCall, TxEgldValue, TxEnv, TxEnvMockDeployAddress, TxEnvWithTxHash, TxFrom, TxFromSourceValue, TxFromSpecified, TxGas, TxGasValue, TxPayment, TxPaymentEgldOnly, TxProxyTrait, TxResultHandler, TxScEnv, TxTo, TxToSpecified, UpgradeCall, UNSPECIFIED_GAS_LIMIT, @@ -784,6 +784,25 @@ where result_handler: self.result_handler, } } + + /// Sets the path to the code file. Only works in parametric tests. + pub fn code_path( + self, + code: CodePathValue, + ) -> Tx>, RH> + where + CodePathValue: TxCodePathValue, + { + Tx { + env: self.env, + from: self.from, + to: self.to, + payment: self.payment, + gas: self.gas, + data: self.data.code_source(CodePath(code)), + result_handler: self.result_handler, + } + } } impl diff --git a/framework/base/src/types/interaction/tx_data/tx_code_source.rs b/framework/base/src/types/interaction/tx_data/tx_code_source.rs index 0d3c180e16..3973fcd46e 100644 --- a/framework/base/src/types/interaction/tx_data/tx_code_source.rs +++ b/framework/base/src/types/interaction/tx_data/tx_code_source.rs @@ -73,3 +73,34 @@ where FromSourceValue: TxFromSourceValue, { } + +#[diagnostic::on_unimplemented( + message = "Type `{Self}` cannot be used as code path (does not implement `TxCodePathValue<{Env}>`)", + label = "not a valid smart contract code path", + note = "there are multiple ways to specify SC code path, but `{Self}` is not one of them" +)] +pub trait TxCodePathValue: AnnotatedValue> +where + Env: TxEnv, +{ +} + +impl TxCodePathValue for ManagedBuffer where Env: TxEnv {} +impl TxCodePathValue for &ManagedBuffer where Env: TxEnv {} + +/// Contains code for a deploy or upgrade. +pub struct CodePath(pub CodePathValue); + +impl TxCodeSource for CodePath +where + Env: TxEnv, + CodePathValue: TxCodePathValue, +{ +} + +impl TxCodeSourceSpecified for CodePath +where + Env: TxEnv, + CodePathValue: TxCodePathValue, +{ +} diff --git a/framework/base/src/types/interaction/tx_exec.rs b/framework/base/src/types/interaction/tx_exec.rs index 0c200df330..5a691f2bbf 100644 --- a/framework/base/src/types/interaction/tx_exec.rs +++ b/framework/base/src/types/interaction/tx_exec.rs @@ -4,6 +4,7 @@ mod tx_exec_async_promises; mod tx_exec_deploy; mod tx_exec_sync; mod tx_exec_te; +mod tx_exec_test_call; mod tx_exec_upgrade; pub use tx_env_sc::*; diff --git a/framework/base/src/types/interaction/tx_exec/tx_exec_test_call.rs b/framework/base/src/types/interaction/tx_exec/tx_exec_test_call.rs new file mode 100644 index 0000000000..2159729ae8 --- /dev/null +++ b/framework/base/src/types/interaction/tx_exec/tx_exec_test_call.rs @@ -0,0 +1,90 @@ +use crate::api::{CallTypeApi, TestApi}; +use crate::tuple_util::NestedTupleFlatten; +use crate::{ + contract_base::TestRawWrapper, + types::{ + CodePath, DeployCall, FunctionCall, ManagedAddress, ManagedVec, RHListExec, Tx, + TxCodePathValue, TxData, TxEmptyResultHandler, TxFromSpecified, TxGas, TxPayment, + TxPaymentEgldOnly, TxResultHandler, TxScEnv, TxToSpecified, + }, +}; + +use super::DeployRawResult; + +impl Tx, From, To, Payment, Gas, FC, RH> +where + Api: CallTypeApi + TestApi, + From: TxFromSpecified>, + To: TxToSpecified>, + Payment: TxPayment>, + Gas: TxGas>, + FC: TxData> + Into>, + RH: TxEmptyResultHandler>, +{ + pub fn test_call(self) { + self.from.with_value_ref(&self.env, |from| { + TestRawWrapper::::new().start_prank(from); + }); + + let gas_limit = self.gas.gas_value(&self.env); + self.to.with_value_ref(&self.env, |to| { + self.payment + .perform_transfer_execute(&self.env, to, gas_limit, self.data.into()); + }); + TestRawWrapper::::new().stop_prank(); + } +} + +impl + Tx, From, (), Payment, Gas, DeployCall, CodePath>, RH> +where + Api: CallTypeApi + TestApi, + From: TxFromSpecified>, + Payment: TxPaymentEgldOnly>, + Gas: TxGas>, + CodePathValue: TxCodePathValue>, + RH: TxResultHandler>, +{ + fn execute_test_deploy_raw(self) -> (ManagedAddress, RH) { + let gas_limit = self.gas.gas_value(&self.env); + let new_address = self.from.with_value_ref(&self.env, |from| { + self.payment.with_egld_value(&self.env, |egld_value| { + TestRawWrapper::::new().deploy_contract( + from, + gas_limit, + egld_value, + &self.data.code_source.0.into_value(&self.env), + &self.data.arg_buffer, + ) + }) + }); + (new_address, self.result_handler) + } +} + +impl + Tx, From, (), Payment, Gas, DeployCall, CodePath>, RH> +where + Api: CallTypeApi + TestApi, + From: TxFromSpecified>, + Payment: TxPaymentEgldOnly>, + Gas: TxGas>, + CodePathValue: TxCodePathValue>, + RH: RHListExec, TxScEnv>, + RH::ListReturns: NestedTupleFlatten, +{ + /// Synchronously deploys a contract. + pub fn test_deploy(self) -> ::Unpacked { + let (new_address, result_handler) = self.execute_test_deploy_raw(); + + // TODO: results currently not retrieved + let raw_results = ManagedVec::new(); + + let deploy_raw_result = DeployRawResult { + new_address, + raw_results, + }; + let tuple_result = result_handler.list_process_result(&deploy_raw_result); + tuple_result.flatten_unpack() + } +} diff --git a/framework/meta/src/cmd/contract/sc_config/wasm_build.rs b/framework/meta/src/cmd/contract/sc_config/wasm_build.rs index bfe0539738..5b6f09659a 100644 --- a/framework/meta/src/cmd/contract/sc_config/wasm_build.rs +++ b/framework/meta/src/cmd/contract/sc_config/wasm_build.rs @@ -175,11 +175,17 @@ fn print_ei_check(wasm_data: &WasmInfo, check_ei: &Option) { return; } + let mut has_warning = false; for import_name in &wasm_data.imports { if !ei.contains_vm_hook(import_name.as_str()) { + has_warning = true; print_invalid_vm_hook(import_name.as_str(), ei.name()); } } + + if has_warning { + println!(); + } } else { print_ignore_ei_check(); } diff --git a/framework/meta/src/print_util.rs b/framework/meta/src/print_util.rs index e79df4f60b..075ff759db 100644 --- a/framework/meta/src/print_util.rs +++ b/framework/meta/src/print_util.rs @@ -84,7 +84,7 @@ pub fn print_invalid_vm_hook(import_name: &str, ei_version: &str) { } pub fn print_check_ei_ok() { - println!("{}", " OK".green(),); + print!("{}", " OK".green(),); } pub fn print_ignore_ei_check() { diff --git a/framework/scenario/src/api/core_api_vh.rs b/framework/scenario/src/api/core_api_vh.rs index e6012be410..4a34aa381a 100644 --- a/framework/scenario/src/api/core_api_vh.rs +++ b/framework/scenario/src/api/core_api_vh.rs @@ -7,3 +7,4 @@ mod error_api_vh; mod log_api_vh; mod send_api_vh; mod storage_api_vh; +mod test_api_vh; diff --git a/framework/scenario/src/api/core_api_vh/test_api_vh.rs b/framework/scenario/src/api/core_api_vh/test_api_vh.rs new file mode 100644 index 0000000000..b613b61722 --- /dev/null +++ b/framework/scenario/src/api/core_api_vh/test_api_vh.rs @@ -0,0 +1,13 @@ +use multiversx_sc::api::{TestApi, TestApiImpl}; + +use crate::api::{VMHooksApi, VMHooksApiBackend}; + +impl TestApi for VMHooksApi { + type TestApiImpl = Self; + + fn test_api_impl() -> Self::TestApiImpl { + Self::api_impl() + } +} + +impl TestApiImpl for VMHooksApi {} diff --git a/framework/wasm-adapter/src/api/mod.rs b/framework/wasm-adapter/src/api.rs similarity index 94% rename from framework/wasm-adapter/src/api/mod.rs rename to framework/wasm-adapter/src/api.rs index cde7d89e6b..f4fde42cef 100644 --- a/framework/wasm-adapter/src/api/mod.rs +++ b/framework/wasm-adapter/src/api.rs @@ -9,6 +9,7 @@ mod managed_types; mod print_api_node; mod send_api_node; mod storage_api_node; +mod test_api_node; mod unsafe_buffer; mod vm_api_node; diff --git a/framework/wasm-adapter/src/api/test_api_node.rs b/framework/wasm-adapter/src/api/test_api_node.rs new file mode 100644 index 0000000000..f8c007854b --- /dev/null +++ b/framework/wasm-adapter/src/api/test_api_node.rs @@ -0,0 +1,170 @@ +use super::VmApiImpl; +use multiversx_sc::api::{TestApi, TestApiImpl}; + +extern "C" { + + fn createAccount(addressHandle: i32, nonce: i64, balanceHandle: i32); + + fn registerNewAddress(ownerHandle: i32, nonce: i64, newAddressHandle: i32); + + fn deployContract( + ownerHandle: i32, + gasLimit: i64, + valueHandle: i32, + codePathHandle: i32, + argumentsHandle: i32, + resultAddressHandle: i32, + ); + + fn setStorage(addressHandle: i32, keyHandle: i32, valueHandle: i32); + + fn getStorage(addressHandle: i32, keyHandle: i32, dstHandle: i32); + + fn assumeBool(p: bool); + fn assertBool(p: bool); + + fn startPrank(addressHandle: i32); + fn stopPrank(); + + fn setBlockTimestamp(timestamp: i64); + + fn setExternalBalance(addressHandle: i32, valueHandle: i32); + + fn setESDTExternalBalance(addressHandle: i32, tokenIdHandle: i32, valueHandle: i32); +} + +impl TestApi for VmApiImpl { + type TestApiImpl = VmApiImpl; + + #[inline] + fn test_api_impl() -> Self::TestApiImpl { + VmApiImpl {} + } +} + +impl TestApiImpl for VmApiImpl { + fn create_account( + &self, + address: Self::ManagedBufferHandle, + nonce: u64, + balance: Self::BigIntHandle, + ) { + unsafe { + createAccount(address, nonce as i64, balance); + } + } + + fn register_new_address( + &self, + owner: Self::ManagedBufferHandle, + nonce: u64, + new_address: Self::ManagedBufferHandle, + ) { + unsafe { + registerNewAddress(owner, nonce as i64, new_address); + } + } + + // Deploy a contract whose code was previously fetched using "fetchWasmSource" in Mandos. + fn deploy_contract( + &self, + owner: Self::ManagedBufferHandle, + gas_limit: u64, + value: Self::BigIntHandle, + code_path: Self::ManagedBufferHandle, + arguments: Self::ManagedBufferHandle, + result_address_handle: Self::ManagedBufferHandle, + ) { + unsafe { + // let mut dest = ManagedAddress::zero(); + + deployContract( + owner, + gas_limit as i64, + value, + code_path, + arguments, + result_address_handle, + ); + + // dest + } + } + + // Set storage of any account + fn set_storage( + &self, + address: Self::ManagedBufferHandle, + key: Self::ManagedBufferHandle, + value: Self::ManagedBufferHandle, + ) { + unsafe { + setStorage(address, key, value); + } + } + + // Get storage of any account + fn get_storage( + &self, + address: Self::ManagedBufferHandle, + key: Self::ManagedBufferHandle, + result_value: Self::ManagedBufferHandle, + ) { + unsafe { + // let mut dest = ManagedBuffer::new(); + + getStorage(address, key, result_value); + + // dest + } + } + + // Start a prank: set the caller address for contract calls until stop_prank + fn start_prank(&self, address: Self::ManagedBufferHandle) { + unsafe { + startPrank(address); + } + } + + // Stop a prank: reset the caller address + fn stop_prank(&self) { + unsafe { + stopPrank(); + } + } + + fn assume(&self, p: bool) { + unsafe { + assumeBool(p); + } + } + + fn assert(&self, p: bool) { + unsafe { + assertBool(p); + } + } + + fn set_block_timestamp(&self, timestamp: u64) { + unsafe { + setBlockTimestamp(timestamp as i64); + } + } + + fn set_balance(&self, address: Self::ManagedBufferHandle, value: Self::BigIntHandle) { + unsafe { + setExternalBalance(address, value); + } + } + + fn set_esdt_balance( + &self, + address: Self::ManagedBufferHandle, + token_id: Self::ManagedBufferHandle, + value: Self::BigIntHandle, + ) { + unsafe { + setESDTExternalBalance(address, token_id, value); + } + } +}