diff --git a/Cargo.lock b/Cargo.lock index da9b304..ee32785 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[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", ] @@ -41,56 +41,57 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -98,9 +99,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arbitrary" @@ -125,15 +126,15 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -144,12 +145,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -213,9 +208,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", "serde", @@ -235,18 +230,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "cc" -version = "1.0.83" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" [[package]] name = "cfg-if" @@ -256,9 +248,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.0" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" +checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" dependencies = [ "clap_builder", "clap_derive", @@ -266,9 +258,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.0" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" +checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" dependencies = [ "anstream", "anstyle", @@ -278,9 +270,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.0" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" dependencies = [ "heck", "proc-macro2", @@ -290,15 +282,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "colored" @@ -353,7 +345,16 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "core-mx-life-bonding-sc" version = "2.0.0" +source = "git+https://github.com/Itheum/core-mx-life-bonding-sc?branch=develop#c51654efe43dd071737ee3de4ee42f0842613f49" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "core-mx-life-bonding-sc" +version = "3.0.0" dependencies = [ + "core-mx-liveliness-stake", "multiversx-sc", "multiversx-sc-scenario", ] @@ -362,10 +363,19 @@ dependencies = [ name = "core-mx-life-bonding-sc-meta" version = "2.0.0" dependencies = [ - "core-mx-life-bonding-sc", + "core-mx-life-bonding-sc 3.0.0", "multiversx-sc-meta", ] +[[package]] +name = "core-mx-liveliness-stake" +version = "0.0.0" +source = "git+https://github.com/Itheum/core-mx-liveliness-stake.git?branch=main#36b08f1e279d32af939e1a32df449952ce074102" +dependencies = [ + "core-mx-life-bonding-sc 2.0.0", + "multiversx-sc", +] + [[package]] name = "cpufeatures" version = "0.2.12" @@ -499,15 +509,15 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -520,9 +530,9 @@ checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" [[package]] name = "env_filter" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" dependencies = [ "log", "regex", @@ -530,9 +540,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.3" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" dependencies = [ "anstream", "anstyle", @@ -549,9 +559,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -559,9 +569,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "flate2" @@ -715,9 +725,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -726,9 +736,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" @@ -764,9 +774,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "serde", @@ -774,15 +784,15 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.6" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -818,9 +828,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http", @@ -841,9 +851,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "humantime" @@ -853,9 +863,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", @@ -952,9 +962,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.3" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -967,6 +977,12 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.13.0" @@ -978,15 +994,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -1002,27 +1018,27 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -1054,22 +1070,23 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.10" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ + "hermit-abi", "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1116,9 +1133,9 @@ checksum = "b59072fa0624b55ae5ae3fa6bfa91515bbeb4ac440214bc4a509e2c8806d6e9f" [[package]] name = "multiversx-sc" -version = "0.51.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58050d5c7cce984124786a0ec48e8a8db5cf944412c2909a225183a6cfe0338" +checksum = "236f7890b2208796df8b5ac73b8572ffaf5e2b1531c7ad549d669328b715b657" dependencies = [ "bitflags 2.6.0", "hex-literal", @@ -1154,9 +1171,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.51.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89c28b9f9cf4250efe2f72d7c3a2a4bf8c96706c08a3b8f70cf7f40b6824789" +checksum = "eb683bc78d0e2eb43c16cac790144f53cc2ab27912aeb1484433895742ce698d" dependencies = [ "hex", "proc-macro2", @@ -1167,9 +1184,9 @@ dependencies = [ [[package]] name = "multiversx-sc-meta" -version = "0.51.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1f62f5608a8ccc311d5fdbc1b553af74a0229e2f386d7752527cdece3fb0b1" +checksum = "1bfc26133bd2e5087475654c77d2220410a05d3a2125bfc33706cf14322c7cae" dependencies = [ "clap", "colored", @@ -1192,9 +1209,9 @@ dependencies = [ [[package]] name = "multiversx-sc-meta-lib" -version = "0.51.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fefccfb88ee6956ad00b98d9b2c2efe499dcf5964f45db5bf13a3622fb53a7" +checksum = "eb12232450627cb0e9f3ba9493b0bd7445a40066f0e311e19e84de812bbffd56" dependencies = [ "clap", "colored", @@ -1213,11 +1230,11 @@ dependencies = [ [[package]] name = "multiversx-sc-scenario" -version = "0.51.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9a5cf68c4812278891efc40f30bfc7b29770aa016794383e7fa39a8f52ef59" +checksum = "6b7a5e1289d021c89c44688d77110d78edf83ea52b2eff40481a8119ad2f0411" dependencies = [ - "base64 0.22.1", + "base64", "bech32", "colored", "hex", @@ -1239,11 +1256,11 @@ dependencies = [ [[package]] name = "multiversx-sc-snippets" -version = "0.51.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17a72a635a0c26db62c2c347136a7394b978d19e56c7fc16830e49ba577c7b83" +checksum = "ac2eed6d36d163c03d18858c62959a1f3c6f26999b89d6d9595c35531f3f7783" dependencies = [ - "base64 0.22.1", + "base64", "env_logger", "futures", "hex", @@ -1261,7 +1278,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "139f1ac6d82e743dd3ae303e47134ab17b7c3e3c4306f09bed11a6054822596c" dependencies = [ "anyhow", - "base64 0.22.1", + "base64", "bech32", "bip39", "hex", @@ -1283,11 +1300,10 @@ dependencies = [ [[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", @@ -1310,9 +1326,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -1336,21 +1352,11 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" -version = "0.32.2" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] @@ -1363,15 +1369,15 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.63" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -1401,9 +1407,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.99" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", @@ -1413,9 +1419,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -1423,15 +1429,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -1451,11 +1457,11 @@ dependencies = [ [[package]] name = "pem" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.21.7", + "base64", "serde", ] @@ -1487,9 +1493,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -1596,7 +1602,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.15", ] [[package]] @@ -1619,18 +1625,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", ] [[package]] name = "regex" -version = "1.10.3" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -1640,9 +1646,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -1651,9 +1657,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" @@ -1661,7 +1667,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "encoding_rs", "futures-channel", @@ -1707,7 +1713,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.12", + "getrandom 0.2.15", "libc", "spin", "untrusted", @@ -1730,9 +1736,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_version" @@ -1745,9 +1751,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.6.0", "errno", @@ -1758,9 +1764,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.10" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ "once_cell", "rustls-pki-types", @@ -1775,7 +1781,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.1", + "base64", "rustls-pki-types", ] @@ -1787,9 +1793,9 @@ checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring", "rustls-pki-types", @@ -1798,9 +1804,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -1828,11 +1834,11 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "security-framework" -version = "2.9.2" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -1841,9 +1847,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -1851,24 +1857,24 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.196" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -1877,21 +1883,22 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "indexmap", "itoa", + "memchr", "ryu", "serde", ] [[package]] name = "serde_repr" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", @@ -1900,9 +1907,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -1955,9 +1962,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] @@ -1985,18 +1992,18 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2007,15 +2014,15 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -2057,9 +2064,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", @@ -2078,18 +2085,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -2098,9 +2105,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -2113,28 +2120,27 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -2164,23 +2170,22 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] name = "toml" -version = "0.8.10" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" dependencies = [ "indexmap", "serde", @@ -2191,18 +2196,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.6" +version = "0.22.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" dependencies = [ "indexmap", "serde", @@ -2310,9 +2315,9 @@ checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -2321,9 +2326,9 @@ dependencies = [ [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "vcpkg" @@ -2333,15 +2338,15 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -2370,9 +2375,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2380,9 +2385,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", @@ -2395,9 +2400,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -2407,9 +2412,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2417,9 +2422,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", @@ -2430,9 +2435,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasmparser" @@ -2461,45 +2466,23 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.48.0" @@ -2515,7 +2498,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -2535,17 +2518,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2556,9 +2540,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2568,9 +2552,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2580,9 +2564,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2592,9 +2582,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -2604,9 +2594,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -2616,9 +2606,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -2628,15 +2618,15 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.1" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401" +checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" dependencies = [ "memchr", ] @@ -2653,18 +2643,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", @@ -2673,9 +2663,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", ] @@ -2693,9 +2683,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.1.3" +version = "2.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775a2b471036342aa69bc5a602bc889cb0a06cda00477d0c69566757d5553d39" +checksum = "b895748a3ebcb69b9d38dcfdf21760859a4b0d0b0015277640c2ef4c69640e6f" dependencies = [ "arbitrary", "crc32fast", diff --git a/Cargo.toml b/Cargo.toml index 9e3941e..bdaa208 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "core-mx-life-bonding-sc" -version = "2.0.0" +version = "3.0.0" authors = ["Bucur David - Itheum"] edition = "2021" publish = false @@ -8,9 +8,13 @@ publish = false [lib] path = "src/lib.rs" +[dependencies] + core-mx-liveliness-stake = {git ="https://github.com/Itheum/core-mx-liveliness-stake.git",branch = "main"} + [dependencies.multiversx-sc] version = "0.51.0" + [dev-dependencies.multiversx-sc-scenario] version = "0.51.0" diff --git a/interaction/devnet.snippets.sh b/interaction/devnet.snippets.sh index 9a1f9cf..cf7add4 100644 --- a/interaction/devnet.snippets.sh +++ b/interaction/devnet.snippets.sh @@ -1,7 +1,7 @@ PROXY=https://devnet-gateway.multiversx.com CHAIN_ID="D" -WALLET="./wallet.pem" +WALLET="../wallet_dev.pem" USER="./wallet2.pem" ADDRESS=$(mxpy data load --key=address-devnet) @@ -16,7 +16,7 @@ TOKEN_HEX="0x$(echo -n ${TOKEN} | xxd -p -u | tr -d '\n')" # --bytecode output-docker/core-mx-life-bonding-sc/core-mx-life-bonding-sc.wasm \ deploy(){ mxpy --verbose contract deploy \ - --bytecode output-docker/core-mx-life-bonding-sc/core-mx-life-bonding-sc.wasm \ + --bytecode output/core-mx-life-bonding-sc.wasm \ --outfile deployOutput \ --metadata-not-readable \ --metadata-payable-by-sc \ @@ -42,7 +42,7 @@ deploy(){ # in below code example we added --metadata-payable to add PAYABLE to the prop of the SC and removed --metadata-not-readable to make it READABLE upgrade(){ mxpy --verbose contract upgrade ${ADDRESS} \ - --bytecode output-docker/core-mx-life-bonding-sc/core-mx-life-bonding-sc.wasm \ + --bytecode output/core-mx-life-bonding-sc.wasm \ --metadata-not-readable \ --metadata-payable-by-sc \ --pem ${WALLET} \ @@ -294,3 +294,40 @@ initiateBond() { --chain ${CHAIN_ID} \ --send || return } + + +setLivelinessStakeAddress(){ + + # $1 = address + + address="0x$(mxpy wallet bech32 --decode ${1})" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --pem=${WALLET} \ + --gas-limit=6000000 \ + --function "setLivelinessStakeAddress" \ + --arguments $address \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --send || return + +} + + +setTopUpAdministrator(){ + + # $1 = address + + address="0x$(mxpy wallet bech32 --decode ${1})" + + mxpy --verbose contract call ${ADDRESS} \ + --recall-nonce \ + --pem=${WALLET} \ + --gas-limit=6000000 \ + --function "setTopUpAdministrator" \ + --arguments $address \ + --proxy ${PROXY} \ + --chain ${CHAIN_ID} \ + --send || return +} \ No newline at end of file diff --git a/src/admin.rs b/src/admin.rs index 5c9b117..2b1990b 100644 --- a/src/admin.rs +++ b/src/admin.rs @@ -9,7 +9,7 @@ use crate::{ ERR_COMPENSATION_NOT_FOUND, ERR_INVALID_PENALTY_VALUE, ERR_INVALID_TIMESTAMP, ERR_INVALID_TOKEN_IDENTIFIER, ERR_NOT_IN_STORAGE, ERR_NOT_PRIVILEGED, }, - events, only_privileged, + events, only_privileged, proxy_contracts, storage::{self, PenaltyType}, }; @@ -132,6 +132,12 @@ pub trait AdminModule: let mut bond_cache = BondCache::new(self, bond_id); let mut compensation_cache = CompensationCache::new(self, compensation_id); + self.tx() + .to(self.liveliness_stake_address().get()) + .typed(proxy_contracts::liveliness_stake_proxy::CoreMxLivelinessStakeProxy) + .generate_rewards() + .sync_call(); + let penalty = match penalty { PenaltyType::Minimum => self.minimum_penalty().get(), PenaltyType::Custom => { @@ -296,4 +302,18 @@ pub trait AdminModule: self.withdraw_penalty_event(penalty); self.withdraw_penalty().set(penalty); } + + #[endpoint(setLivelinessStakeAddress)] + fn set_liveliness_stake_address(&self, address: ManagedAddress) { + only_privileged!(self, ERR_NOT_PRIVILEGED); + self.set_liveliness_stake_address_event(&address); + self.liveliness_stake_address().set(address); + } + + #[endpoint(setTopUpAdministrator)] + fn set_top_up_administrator(&self, address: ManagedAddress) { + only_privileged!(self, ERR_NOT_PRIVILEGED); + self.set_top_up_administrator_event(&address); + self.top_up_administrator().set(address); + } } diff --git a/src/config.rs b/src/config.rs index 0f55e5d..0e70ca8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -78,6 +78,14 @@ pub trait ConfigModule: storage::StorageModule + events::EventsModule { if self.lock_periods().is_empty() { is_ready = false; } + + if self.liveliness_stake_address().is_empty() { + is_ready = false; + } + + if self.top_up_administrator().is_empty() { + is_ready = false; + } is_ready } @@ -89,6 +97,10 @@ pub trait ConfigModule: storage::StorageModule + events::EventsModule { #[storage_mapper("administrator")] fn administrator(&self) -> SingleValueMapper; + #[view(getTopUpAdministrator)] + #[storage_mapper("top_up_administrator")] + fn top_up_administrator(&self) -> SingleValueMapper; + #[view(getAcceptedCallers)] #[storage_mapper("accepted_callers")] fn accepted_callers(&self) -> UnorderedSetMapper; diff --git a/src/errors.rs b/src/errors.rs index d13aad5..1b9e16d 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -19,3 +19,4 @@ pub const ERR_ALREADY_IN_STORAGE: &str = "Already in storage"; pub const ERR_NOT_IN_STORAGE: &str = "Not in storage"; pub const ERR_ALREADY_ACTIVE: &str = "Already active"; pub const ERR_ALREADY_INACTIVE: &str = "Already inactive"; +pub const ERR_VAULT_NONCE_NOT_SET: &str = "Vault nonce not set"; diff --git a/src/events.rs b/src/events.rs index 1f9a013..54bea16 100644 --- a/src/events.rs +++ b/src/events.rs @@ -117,4 +117,10 @@ pub trait EventsModule { #[event("set_administrator_event")] fn set_administrator_event(&self, #[indexed] administrator: &ManagedAddress); + + #[event("set_liveliness_stake_address")] + fn set_liveliness_stake_address_event(&self, #[indexed] address: &ManagedAddress); + + #[event("set_top_up_administrator_event")] + fn set_top_up_administrator_event(&self, #[indexed] top_up_administrator: &ManagedAddress); } diff --git a/src/lib.rs b/src/lib.rs index 741c8fe..cfc9d7f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ use crate::{ ERR_BOND_NOT_FOUND, ERR_CONTRACT_NOT_READY, ERR_ENDPOINT_CALLABLE_ONLY_BY_ACCEPTED_CALLERS, ERR_INVALID_AMOUNT, ERR_INVALID_LOCK_PERIOD, ERR_INVALID_TIMELINE_TO_PROOF, ERR_INVALID_TIMELINE_TO_REFUND, ERR_INVALID_TOKEN_IDENTIFIER, - ERR_PENALTIES_EXCEED_WITHDRAWAL_AMOUNT, ERR_REFUND_NOT_FOUND, + ERR_PENALTIES_EXCEED_WITHDRAWAL_AMOUNT, ERR_REFUND_NOT_FOUND, ERR_VAULT_NONCE_NOT_SET, }, storage::Refund, }; @@ -23,6 +23,7 @@ pub mod contexts; pub mod errors; pub mod events; pub mod life_bonding_sc_proxy; +pub mod proxy_contracts; pub mod storage; pub mod views; #[multiversx_sc::contract] @@ -49,13 +50,14 @@ pub trait LifeBondingContract: #[upgrade] fn upgrade(&self) { - self.contract_state().set(State::Inactive); - self.contract_state_event(State::Inactive); + // TO BE UNCOMMENTED FOR PROD + // self.contract_state().set(State::Inactive); + // self.contract_state_event(State::Inactive); // NEEDS TO BE USED AS STORAGE WAS NOT IMPLEMENTED // DEVNET - self.total_bond_amount() - .set(BigUint::from(1313800000000000000000u128)); + // self.total_bond_amount() + // .set(BigUint::from(1313800000000000000000u128)); // MAINNET // self.total_bond_amount() @@ -108,6 +110,12 @@ pub trait LifeBondingContract: require!(payment.amount == bond_amount, ERR_INVALID_AMOUNT); + self.tx() + .to(self.liveliness_stake_address().get()) + .typed(proxy_contracts::liveliness_stake_proxy::CoreMxLivelinessStakeProxy) + .generate_rewards() + .sync_call(); + let current_timestamp = self.blockchain().get_block_timestamp(); let unbond_timestamp = current_timestamp + lock_period_seconds; @@ -158,10 +166,16 @@ pub trait LifeBondingContract: .compensations_ids() .get_id_non_zero((token_identifier, nonce)); - let bond_cache = BondCache::new(self, bond_id); + let mut bond_cache = BondCache::new(self, bond_id); require!(bond_cache.address == caller, ERR_BOND_NOT_FOUND); + self.tx() + .to(self.liveliness_stake_address().get()) + .typed(proxy_contracts::liveliness_stake_proxy::CoreMxLivelinessStakeProxy) + .claim_rewards(OptionalValue::Some(caller.clone())) + .sync_call(); + let current_timestamp = self.blockchain().get_block_timestamp(); let mut compensation_cache = CompensationCache::new(self, compensation_id); @@ -188,6 +202,9 @@ pub trait LifeBondingContract: &(&bond_cache.remaining_amount - &penalty_amount), ); + self.total_bond_amount() + .update(|value| *value -= &(&bond_cache.remaining_amount + &penalty_amount)); + compensation_cache.accumulated_amount += &penalty_amount; } else { self.send().direct_esdt( @@ -197,6 +214,9 @@ pub trait LifeBondingContract: &bond_cache.remaining_amount, ); + self.total_bond_amount() + .update(|value| *value -= &bond_cache.remaining_amount); + self.compensations().swap_remove(&compensation_id); } @@ -207,12 +227,22 @@ pub trait LifeBondingContract: &penalty_amount, ); + bond_cache.clear(); + self.bonds().swap_remove(&bond_id); + self.address_bonds(&caller).swap_remove(&bond_id); } #[endpoint(renew)] fn renew(&self, token_identifier: TokenIdentifier, nonce: u64) { require_contract_ready!(self, ERR_CONTRACT_NOT_READY); + + self.tx() + .to(self.liveliness_stake_address().get()) + .typed(proxy_contracts::liveliness_stake_proxy::CoreMxLivelinessStakeProxy) + .generate_rewards() + .sync_call(); + let caller = self.blockchain().get_caller(); let bond_id = self.bonds_ids().get_id_non_zero((token_identifier, nonce)); @@ -362,4 +392,157 @@ pub trait LifeBondingContract: self.compensations().swap_remove(&compensation_id); } } + + #[endpoint(setVaultNonce)] + fn set_vault_nonce(&self, token_identifier: TokenIdentifier, nonce: u64) { + let caller = self.blockchain().get_caller(); + + let bond_id = self + .bonds_ids() + .get_id_non_zero((token_identifier.clone(), nonce)); + + let bond_cache = BondCache::new(self, bond_id); + + require!(bond_cache.address == caller, ERR_BOND_NOT_FOUND); + + self.address_vault_nonce(&caller, &token_identifier) + .set(nonce); + } + + #[payable("*")] + #[endpoint(topUpVault)] + fn top_up_vault(&self, token_identifier: TokenIdentifier, nonce: u64) { + let caller = self.blockchain().get_caller(); + + self.tx() + .to(self.liveliness_stake_address().get()) + .typed(proxy_contracts::liveliness_stake_proxy::CoreMxLivelinessStakeProxy) + .claim_rewards(OptionalValue::Some(caller.clone())) + .sync_call(); + + require!( + self.address_vault_nonce(&caller, &token_identifier).get() == nonce, + ERR_VAULT_NONCE_NOT_SET + ); + + let bond_id = self + .bonds_ids() + .get_id_non_zero((token_identifier.clone(), nonce)); + + let mut bond_cache = BondCache::new(self, bond_id); + + require!(bond_cache.address == caller, ERR_BOND_NOT_FOUND); + + let payment = self.call_value().single_esdt(); + + require!( + payment.token_identifier == self.bond_payment_token().get(), + ERR_INVALID_TOKEN_IDENTIFIER + ); + + let current_timestamp = self.blockchain().get_block_timestamp(); + + bond_cache.unbond_timestamp = current_timestamp + bond_cache.lock_period; + bond_cache.bond_timestamp = current_timestamp; + bond_cache.bond_amount += &payment.amount; + bond_cache.remaining_amount += &payment.amount; + + self.total_bond_amount() + .update(|value| *value += &payment.amount); + } + + #[payable("*")] + #[endpoint(topUpAddressVault)] + fn top_up_address_vault( + &self, + address: ManagedAddress, + token_identifier: TokenIdentifier, + nonce: u64, + ) { + let caller = self.blockchain().get_caller(); + + require!( + self.address_vault_nonce(&address, &token_identifier).get() == nonce, + ERR_VAULT_NONCE_NOT_SET + ); + + require!( + caller == self.top_up_administrator().get(), + ERR_ENDPOINT_CALLABLE_ONLY_BY_ACCEPTED_CALLERS + ); + + self.tx() + .to(self.liveliness_stake_address().get()) + .typed(proxy_contracts::liveliness_stake_proxy::CoreMxLivelinessStakeProxy) + .claim_rewards(OptionalValue::Some(caller.clone())) + .sync_call(); + + let bond_id = self + .bonds_ids() + .get_id_non_zero((token_identifier.clone(), nonce)); + + let mut bond_cache = BondCache::new(self, bond_id); + + require!(bond_cache.address == caller, ERR_BOND_NOT_FOUND); + + let payment = self.call_value().single_esdt(); + + require!( + payment.token_identifier == self.bond_payment_token().get(), + ERR_INVALID_TOKEN_IDENTIFIER + ); + + let current_timestamp = self.blockchain().get_block_timestamp(); + + bond_cache.unbond_timestamp = current_timestamp + bond_cache.lock_period; + bond_cache.bond_timestamp = current_timestamp; + bond_cache.bond_amount += &payment.amount; + bond_cache.remaining_amount += &payment.amount; + + self.total_bond_amount() + .update(|value| *value += &payment.amount); + } + + #[payable("*")] + #[endpoint(stakeRewards)] + fn stake_rewards( + &self, + original_caller: ManagedAddress, + token_identifier: TokenIdentifier, + amount: BigUint, + ) { + let caller = self.blockchain().get_caller(); + require!( + caller == self.liveliness_stake_address().get(), + ERR_ENDPOINT_CALLABLE_ONLY_BY_ACCEPTED_CALLERS + ); + + require!( + !self + .address_vault_nonce(&original_caller, &token_identifier) + .is_empty(), + ERR_VAULT_NONCE_NOT_SET + ); + + let vault_nonce = self + .address_vault_nonce(&original_caller, &token_identifier) + .get(); + + let bond_id = self + .bonds_ids() + .get_id_non_zero((token_identifier.clone(), vault_nonce)); + + let mut bond_cache = BondCache::new(self, bond_id); + + require!(bond_cache.address == original_caller, ERR_BOND_NOT_FOUND); + + let current_timestamp = self.blockchain().get_block_timestamp(); + + bond_cache.unbond_timestamp = current_timestamp + bond_cache.lock_period; + bond_cache.bond_timestamp = current_timestamp; + bond_cache.bond_amount += &amount; + bond_cache.remaining_amount += &amount; + + self.total_bond_amount().update(|value| *value += amount); + } } diff --git a/src/life_bonding_sc_proxy.rs b/src/life_bonding_sc_proxy.rs index ba14d6a..34e61aa 100644 --- a/src/life_bonding_sc_proxy.rs +++ b/src/life_bonding_sc_proxy.rs @@ -158,6 +158,73 @@ where .original_result() } + pub fn set_vault_nonce< + Arg0: ProxyArg>, + Arg1: ProxyArg, + >( + self, + token_identifier: Arg0, + nonce: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setVaultNonce") + .argument(&token_identifier) + .argument(&nonce) + .original_result() + } + + pub fn top_up_vault< + Arg0: ProxyArg>, + Arg1: ProxyArg, + >( + self, + token_identifier: Arg0, + nonce: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("topUpVault") + .argument(&token_identifier) + .argument(&nonce) + .original_result() + } + + pub fn top_up_address_vault< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg, + >( + self, + address: Arg0, + token_identifier: Arg1, + nonce: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("topUpAddressVault") + .argument(&address) + .argument(&token_identifier) + .argument(&nonce) + .original_result() + } + + pub fn stake_rewards< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>, + >( + self, + original_caller: Arg0, + token_identifier: Arg1, + amount: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("stakeRewards") + .argument(&original_caller) + .argument(&token_identifier) + .argument(&amount) + .original_result() + } + pub fn compensation_blacklist< Arg0: ProxyArg, >( @@ -180,6 +247,31 @@ where .original_result() } + pub fn address_vault_nonce< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + address: Arg0, + token_identifier: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getAddressVaultNone") + .argument(&address) + .argument(&token_identifier) + .original_result() + } + + pub fn liveliness_stake_address( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getLivelinessStakeAddress") + .original_result() + } + pub fn get_bond< Arg0: ProxyArg, >( @@ -335,6 +427,19 @@ where .original_result() } + pub fn get_address_bonds_info< + Arg0: ProxyArg>, + >( + self, + address: Arg0, + ) -> TxTypedCall, BigUint, BigUint)> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getAddressBondsInfo") + .argument(&address) + .original_result() + } + pub fn get_all_bonds( self, ) -> TxTypedCall>> { @@ -626,6 +731,32 @@ where .original_result() } + pub fn set_liveliness_stake_address< + Arg0: ProxyArg>, + >( + self, + address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setLivelinessStakeAddress") + .argument(&address) + .original_result() + } + + pub fn set_top_up_administrator< + Arg0: ProxyArg>, + >( + self, + address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setTopUpAdministrator") + .argument(&address) + .original_result() + } + pub fn set_administrator< Arg0: ProxyArg>, >( @@ -657,6 +788,15 @@ where .original_result() } + pub fn top_up_administrator( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getTopUpAdministrator") + .original_result() + } + pub fn accepted_callers( self, ) -> TxTypedCall>> { @@ -726,7 +866,7 @@ where } #[type_abi] -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem)] +#[derive(TopEncode, TopDecode, NestedDecode, NestedEncode, ManagedVecItem)] pub struct Bond where Api: ManagedTypeApi, @@ -743,7 +883,7 @@ where } #[type_abi] -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem)] +#[derive(TopEncode, TopDecode, NestedDecode, NestedEncode, ManagedVecItem)] pub struct Compensation where Api: ManagedTypeApi, @@ -757,7 +897,7 @@ where } #[type_abi] -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem)] +#[derive(TopEncode, TopDecode, NestedDecode, NestedEncode, ManagedVecItem)] pub struct Refund where Api: ManagedTypeApi, @@ -784,7 +924,7 @@ where } #[type_abi] -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem)] +#[derive(TopEncode, TopDecode, NestedDecode, NestedEncode, ManagedVecItem)] pub enum State { Inactive, Active, diff --git a/src/proxy_contracts/liveliness_stake_proxy.rs b/src/proxy_contracts/liveliness_stake_proxy.rs new file mode 100644 index 0000000..09e97d5 --- /dev/null +++ b/src/proxy_contracts/liveliness_stake_proxy.rs @@ -0,0 +1,401 @@ +// 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 CoreMxLivelinessStakeProxy; + +impl TxProxyTrait for CoreMxLivelinessStakeProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = CoreMxLivelinessStakeProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + CoreMxLivelinessStakeProxyMethods { wrapped_tx: tx } + } +} + +pub struct CoreMxLivelinessStakeProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl CoreMxLivelinessStakeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init( + self, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .original_result() + } +} + +#[rustfmt::skip] +impl CoreMxLivelinessStakeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade( + self, + ) -> TxTypedUpgrade { + self.wrapped_tx + .payment(NotPayable) + .raw_upgrade() + .original_result() + } +} + +#[rustfmt::skip] +impl CoreMxLivelinessStakeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn claim_rewards< + Arg0: ProxyArg>>, + >( + self, + address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("claimRewards") + .argument(&address) + .original_result() + } + + pub fn stake_rewards< + Arg0: ProxyArg>, + >( + self, + token_identifier: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("stakeRewards") + .argument(&token_identifier) + .original_result() + } + + pub fn set_contract_state_active( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setContractStateActive") + .original_result() + } + + pub fn set_contract_state_inactive( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setContractStateInactive") + .original_result() + } + + pub fn set_max_apr< + Arg0: ProxyArg>, + >( + self, + max_apr: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setMaxApr") + .argument(&max_apr) + .original_result() + } + + pub fn set_rewards_token_identifier< + Arg0: ProxyArg>, + >( + self, + token_identifier: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setRewardsTokenIdentifier") + .argument(&token_identifier) + .original_result() + } + + pub fn set_per_block_rewards< + Arg0: ProxyArg>, + >( + self, + per_block_amount: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setPerBlockRewardAmount") + .argument(&per_block_amount) + .original_result() + } + + pub fn top_up_rewards( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("topUpRewards") + .original_result() + } + + pub fn withdraw_rewards< + Arg0: ProxyArg>, + >( + self, + amount: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("withdrawRewards") + .argument(&amount) + .original_result() + } + + pub fn start_produce_rewards( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("startProduceRewards") + .original_result() + } + + pub fn end_produce_rewards( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("endProduceRewards") + .original_result() + } + + pub fn set_bond_contract_address< + Arg0: ProxyArg>, + >( + self, + bond_contract_address: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setBondContractAddress") + .argument(&bond_contract_address) + .original_result() + } + + pub fn set_administrator< + Arg0: ProxyArg>, + >( + self, + administrator: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("setAdministrator") + .argument(&administrator) + .original_result() + } + + pub fn contract_state( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getContractState") + .original_result() + } + + pub fn rewards_state( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("rewardsState") + .original_result() + } + + pub fn administrator( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getAdministrator") + .original_result() + } + + pub fn bond_contract_address( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("bondContractAddress") + .original_result() + } + + pub fn generate_rewards( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("generateAggregatedRewards") + .original_result() + } + + pub fn rewards_reserve( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("rewardsReserve") + .original_result() + } + + pub fn accumulated_rewards( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("accumulatedRewards") + .original_result() + } + + pub fn rewards_token_identifier( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("rewardsTokenIdentifier") + .original_result() + } + + pub fn rewards_per_block( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("rewardsPerBlock") + .original_result() + } + + pub fn last_reward_block_nonce( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("lastRewardBlockNonce") + .original_result() + } + + pub fn rewards_per_share( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("rewardsPerShare") + .original_result() + } + + pub fn address_last_reward_per_share< + Arg0: ProxyArg>, + >( + self, + address: Arg0, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("addressLastRewardPerShare") + .argument(&address) + .original_result() + } + + pub fn max_apr( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("maxApr") + .original_result() + } + + pub fn claimable_rewards< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + >( + self, + caller: Arg0, + opt_bypass_liveliness: Arg1, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("claimableRewards") + .argument(&caller) + .argument(&opt_bypass_liveliness) + .original_result() + } + + pub fn contract_details( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("contractDetails") + .original_result() + } +} + +#[type_abi] +#[derive(TopEncode, TopDecode)] +pub enum State { + Inactive, + Active, +} + +#[type_abi] +#[derive(TopEncode, TopDecode)] +pub struct ContractDetails +where + Api: ManagedTypeApi, +{ + pub rewards_reserve: BigUint, + pub accumulated_rewards: BigUint, + pub rewards_token_identifier: TokenIdentifier, + pub rewards_per_block: BigUint, + pub rewards_per_share: BigUint, + pub administrator: ManagedAddress, + pub bond_contract_address: ManagedAddress, + pub last_reward_block_nonce: u64, + pub max_apr: BigUint, +} diff --git a/src/proxy_contracts/mod.rs b/src/proxy_contracts/mod.rs new file mode 100644 index 0000000..72e4a57 --- /dev/null +++ b/src/proxy_contracts/mod.rs @@ -0,0 +1 @@ +pub mod liveliness_stake_proxy; diff --git a/src/storage.rs b/src/storage.rs index 07bcff1..652a133 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -173,4 +173,18 @@ pub trait StorageModule { #[view(getTotalBondAmount)] #[storage_mapper("total_bond_amount")] fn total_bond_amount(&self) -> SingleValueMapper; + + // NFMEid storage + + #[view(getAddressVaultNone)] + #[storage_mapper("address_vault_nonce")] + fn address_vault_nonce( + &self, + address: &ManagedAddress, + token_identifier: &TokenIdentifier, + ) -> SingleValueMapper; + + #[view(getLivelinessStakeAddress)] + #[storage_mapper("liveliness_stake_address")] + fn liveliness_stake_address(&self) -> SingleValueMapper; } diff --git a/src/views.rs b/src/views.rs index ac30da3..1831448 100644 --- a/src/views.rs +++ b/src/views.rs @@ -80,14 +80,12 @@ pub trait ViewsModule: let compensation_id = self.compensations_ids().get_id((token_identifier, nonce)); if compensation_id == 0 { None + } else if self.address_refund(&address, compensation_id).is_empty() { + None } else { - if self.address_refund(&address, compensation_id).is_empty() { - None - } else { - self.address_refund(&address, compensation_id).get(); - let refund = self.address_refund(&address, compensation_id).get(); - Some(refund) - } + self.address_refund(&address, compensation_id).get(); + let refund = self.address_refund(&address, compensation_id).get(); + Some(refund) } } @@ -154,11 +152,13 @@ pub trait ViewsModule: } let mut total_score = BigUint::zero(); + let mut bond_count = BigUint::zero(); for bond_id in bonds.iter() { let bond: Bond<::Api> = self.get_bond(bond_id); let difference = bond.unbond_timestamp - timestamp; + bond_count += &bond.remaining_amount; if timestamp >= bond.unbond_timestamp { continue; } @@ -167,25 +167,34 @@ pub trait ViewsModule: * difference) / BigUint::from(1_000_000_000u64); - total_score += bond_score; + total_score += bond_score * &bond.remaining_amount; } - // Calculate the average bond score - let bond_count = BigUint::from(bonds.len() as u64); - let average_score = total_score / bond_count; + // Calculate the weighted average bond score - average_score + total_score / bond_count } #[view(getAddressBondsTotalValue)] - fn get_address_bonds_total_value(&self, address: ManagedAddress) -> BigUint { - let total_value = self - .address_bonds(&address) + fn get_address_bonds_total_value(&self, address: &ManagedAddress) -> BigUint { + self.address_bonds(address) .into_iter() .fold(BigUint::zero(), |acc, bond_id| { acc + self.remaining_amount(bond_id).get() - }); - total_value + }) + } + + #[view(getAddressBondsInfo)] + fn get_address_bonds_info(&self, address: ManagedAddress) -> (BigUint, BigUint, BigUint) { + let address_bonds_value = self.get_address_bonds_total_value(&address); + let address_bonds_avg_score = self.get_address_bonds_avg_score(address); + let total_bond_amount = self.total_bond_amount().get(); + + ( + total_bond_amount, + address_bonds_value, + address_bonds_avg_score, + ) } #[view(getAllBonds)] diff --git a/test_external_contracts/core-mx-liveliness-stake.mxsc.json b/test_external_contracts/core-mx-liveliness-stake.mxsc.json new file mode 100644 index 0000000..54c58da --- /dev/null +++ b/test_external_contracts/core-mx-liveliness-stake.mxsc.json @@ -0,0 +1,551 @@ +{ + "buildInfo": { + "rustc": { + "version": "1.78.0", + "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", + "commitDate": "2024-04-29", + "channel": "Stable", + "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" + }, + "contractCrate": { + "name": "core-mx-liveliness-stake", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.51.0" + } + }, + "abi": { + "name": "CoreMxLivelinessStake", + "constructor": { + "inputs": [], + "outputs": [] + }, + "upgradeConstructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "claimRewards", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "setContractStateActive", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "setContractStateInactive", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "setMaxApr", + "mutability": "mutable", + "inputs": [ + { + "name": "max_apr", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "setRewardsTokenIdentifier", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + { + "name": "setPerBlockRewardAmount", + "mutability": "mutable", + "inputs": [ + { + "name": "per_block_amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "topUpRewards", + "mutability": "mutable", + "payableInTokens": [ + "*" + ], + "inputs": [], + "outputs": [] + }, + { + "name": "withdrawRewards", + "mutability": "mutable", + "inputs": [ + { + "name": "amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "startProduceRewards", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "endProduceRewards", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "setBondContractAddress", + "mutability": "mutable", + "inputs": [ + { + "name": "bond_contract_address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "setAdministrator", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "administrator", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "getContractState", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "State" + } + ] + }, + { + "name": "rewardsState", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "State" + } + ] + }, + { + "name": "getAdministrator", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "bondContractAddress", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "generateAggregatedRewards", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "rewardsReserve", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "accumulatedRewards", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "rewardsTokenIdentifier", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + }, + { + "name": "rewardsPerBlock", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "lastRewardBlockNonce", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "rewardsPerShare", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "addressLastRewardPerShare", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "maxApr", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "claimableRewards", + "mutability": "readonly", + "inputs": [ + { + "name": "caller", + "type": "Address" + }, + { + "name": "opt_bypass_liveliness", + "type": "Option" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "contractDetails", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "ContractDetails" + } + ] + } + ], + "events": [ + { + "identifier": "set_administrator_event", + "inputs": [ + { + "name": "administrator", + "type": "Address", + "indexed": true + } + ] + }, + { + "identifier": "contract_state_event", + "inputs": [ + { + "name": "state", + "type": "State", + "indexed": true + } + ] + }, + { + "identifier": "max_apr", + "inputs": [ + { + "name": "max_apr", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "rewards_token_identifier", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier", + "indexed": true + } + ] + }, + { + "identifier": "per_block_reward_amount", + "inputs": [ + { + "name": "per_block_amount", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "top_up_rewards_event", + "inputs": [ + { + "name": "amount", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "withdraw_rewards_event", + "inputs": [ + { + "name": "amount", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "rewards_state_event", + "inputs": [ + { + "name": "state", + "type": "State", + "indexed": true + } + ] + }, + { + "identifier": "bond_contract_address", + "inputs": [ + { + "name": "bond_contract_address", + "type": "Address", + "indexed": true + } + ] + }, + { + "identifier": "claim_rewards", + "inputs": [ + { + "name": "caller", + "type": "Address", + "indexed": true + }, + { + "name": "rewards_amount", + "type": "BigUint", + "indexed": true + }, + { + "name": "timestamp", + "type": "u64", + "indexed": true + }, + { + "name": "block_nonce", + "type": "u64", + "indexed": true + }, + { + "name": "rewards_reserve", + "type": "BigUint", + "indexed": true + }, + { + "name": "accumulated_rewards", + "type": "BigUint", + "indexed": true + }, + { + "name": "current_rewards_per_share", + "type": "BigUint", + "indexed": true + }, + { + "name": "user_last_rewards_per_share", + "type": "BigUint", + "indexed": true + }, + { + "name": "rewards_per_block", + "type": "BigUint", + "indexed": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "ContractDetails": { + "type": "struct", + "fields": [ + { + "name": "rewards_reserve", + "type": "BigUint" + }, + { + "name": "accumulated_rewards", + "type": "BigUint" + }, + { + "name": "rewards_token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "rewards_per_block", + "type": "BigUint" + }, + { + "name": "rewards_per_share", + "type": "BigUint" + }, + { + "name": "administrator", + "type": "Address" + }, + { + "name": "bond_contract_address", + "type": "Address" + }, + { + "name": "last_reward_block_nonce", + "type": "u64" + }, + { + "name": "max_apr", + "type": "BigUint" + } + ] + }, + "State": { + "type": "enum", + "variants": [ + { + "name": "Inactive", + "discriminant": 0 + }, + { + "name": "Active", + "discriminant": 1 + } + ] + } + } + }, + "code": "0061736d010000000179156000006000017f60017f017f60027f7f0060027f7f017f60017f0060037f7f7f0060027f7e006000017e60047f7f7f7f017f60027f7e017f60037f7f7f017f60047f7f7f7f0060017e0060067e7f7f7f7f7f017f60057f7f7e7f7f017f60017e017e60017e017f60017f017e60027f7f017e60037f7e7f0002de062503656e760e626967496e74536574496e743634000703656e7609626967496e74416464000603656e760b7369676e616c4572726f72000303656e760a6d4275666665724e6577000103656e760d6d427566666572417070656e64000403656e76096d4275666665724571000403656e760d6d616e6167656443616c6c6572000503656e76136d616e616765644f776e657241646472657373000503656e76126d427566666572476574417267756d656e74000403656e76126d427566666572417070656e644279746573000b03656e76126d616e616765645369676e616c4572726f72000503656e7619626967496e74476574556e7369676e6564417267756d656e74000303656e76106d4275666665724765744c656e677468000203656e760f6765744e756d417267756d656e7473000103656e760d6d42756666657246696e697368000203656e7616736d616c6c496e7446696e697368556e7369676e6564000d03656e7614626967496e7446696e697368556e7369676e6564000503656e7609626967496e74537562000603656e760a6765744761734c656674000803656e761b6d616e61676564457865637574654f6e44657374436f6e74657874000e03656e760f636c65616e52657475726e44617461000003656e76136d42756666657247657442797465536c696365000903656e760f6d4275666665725365744279746573000b03656e7609626967496e744d756c000603656e760a626967496e7454446976000603656e76196d42756666657246726f6d426967496e74556e7369676e6564000403656e76176d427566666572546f426967496e74556e7369676e6564000403656e76126d42756666657253746f726167654c6f6164000403656e76136d42756666657253746f7261676553746f7265000403656e760d676574426c6f636b4e6f6e6365000803656e7609626967496e74436d70000403656e760f6d616e6167656457726974654c6f67000303656e760e636865636b4e6f5061796d656e74000003656e7611676574426c6f636b54696d657374616d70000803656e76226d616e616765644d756c74695472616e73666572455344544e465445786563757465000f03656e761c6d616e616765644765744d756c74694553445443616c6c56616c7565000503656e760a626967496e745369676e000203747302010204030203030101020c0401020405050205020502060206030c010209030204100304040a040a110a03030102020303061213020707030303041407030201050101010401090203010101010104050105050000000000000000000000000000000000000000000000000000000000000005030100030616037f01418080080b7f0041c1d5080b7f0041d0d5080b07fe0421066d656d6f7279020004696e697400790c636c61696d52657761726473007a16736574436f6e74726163745374617465416374697665007b18736574436f6e74726163745374617465496e616374697665007c097365744d6178417072007d1973657452657761726473546f6b656e4964656e746966696572007e17736574506572426c6f636b526577617264416d6f756e74007f0c746f705570526577617264730080010f77697468647261775265776172647300820113737461727450726f647563655265776172647300830111656e6450726f647563655265776172647300840116736574426f6e64436f6e7472616374416464726573730085011073657441646d696e6973747261746f7200860110676574436f6e747261637453746174650087010c7265776172647353746174650088011067657441646d696e6973747261746f7200890113626f6e64436f6e747261637441646472657373008a011967656e65726174654167677265676174656452657761726473008b010e7265776172647352657365727665008c0112616363756d756c6174656452657761726473008d011672657761726473546f6b656e4964656e746966696572008e010f72657761726473506572426c6f636b008f01146c617374526577617264426c6f636b4e6f6e63650090010f72657761726473506572536861726500910119616464726573734c6173745265776172645065725368617265009201066d617841707200930110636c61696d61626c65526577617264730094010f636f6e747261637444657461696c730095010863616c6c4261636b0096010775706772616465007c0a5f5f646174615f656e6403010b5f5f686561705f6261736503020abc2c731601017f1026220142001000200120012000100120010b1901017f41a4870841a4870828020041016b220036020020000b0f01017f10032201200010041a20010b0b0020002001100541004a0b0a002000102a2001102b0b0f01017f10262201200010191a20010b5001027f230041106b2202240020022000100c220341187420034180fe03714108747220034108764180fe03712003411876727236020c20012002410c6a410410091a200120001048200241106a24000b0900200020011002000b0c01017f10262200100620000b0c01017f10262200100720000b0d0020001026220010081a20000b2e01017f41af80084117103122042000200110091a200441c68008410310091a20042002200310091a2004100a000b1101017f102622022000200110161a20020b0e01017f410010262200100b20000bee0101047f230041106b22032400200341003a000f20002802002101024002400240027f0240024020002d001045044020002802082202100c22044190ce004b0d0141bcd5082d00000d0141b8d508200436020041bcd50841013a00002002410041a88708200410431a200041013a00100b200141016a220241b8d5082802004d0d010c050b200041003a0010200220012003410f6a410110430d04200141016a21022003410f6a0c010b2001417f460d0120024190ce004b0d02200141a887086a0b200020023602002d0000200341106a24000f0b109701000b108101000b41f78308411541f88108410f1030000b2101017f4100102f2202100c41204704402000200141e8810841101030000b20020b1400100d20004604400f0b41da800841191002000b090020001037100e1a0b1f01017f200010532201100c4120470440200041e8810841101057000b20010b090020001039ad100f0b5002017f017e0240024020001054450d0020002000105922024280025a0d01024002402002a741ff01710e020201000b200041808008410d1057000b410121010b20010f0b200041ae8108410e1057000b08002000103b10100b08002000105310450b1f0020002001200210112000103d41ff017104400f0b41f3800841301002000b1500410241012000102422001b4100200041004e1b0b250020012802042002103f200041086a200141086a280200360200200020012902003702000b100010411a20002001280200102710440b1f0020022003103121022000104136020420002002360200200020013602080b1301017f1026220041f08608410010161a20000b920202057f017e230041106b2201240010122106200028020421032000280200210220002802082100417642001000200642a08d067d2006200642a08d06561b20004176200220031026220410131a1014104121022004100c2105410021000340200041046a220320054b4504402001410036020820042000200141086a410410431a20022001280208220041187420004180fe03714108747220004108764180fe03712000411876727210271044200321000c010b0b2002100c1a2001410036020c200241002001410c6a41041043044041a38108410b41c9800841111030000b200128020c220041187420004180fe03714108747220004108764180fe03712000411876727210271045200141106a24000b0f00200020012003200210154100470b4601017f230041106b220224002002200141187420014180fe03714108747220014108764180fe03712001411876727236020c20002002410c6a410410091a200241106a24000b0d00200010262200101a1a20000b1500417f20002001101e220041004720004100481b0b15002000420053044041bc810841111002000b20000b09002000200110041a0b08002000200110460b0d0020002001104641ff0171450b2400027f2001104722015004402000103d41016b0c010b4172200110002000417210460b0b0c00200020002001101720000b0e00200020002001104e101820000b0c00417220001047100041720b1601027f2001104e21021026220320002002101720030b0a0020002000200110010b0a00200020002001103c0b0e01017f102622004200100020000b0d00200010262200101b1a20000b0d0020004167101b1a4167100c0b090020002001101c1a0b0b0020002001102a101c1a0b2c01017f41cd8108411b10312203200010041a200341c68008410310091a20032001200210091a2003100a000b08002000200010590ba30102017e027f230041106b2203240020034200370308200010532204100c220041094f0440200141ae8108410e1057000b20044100200320006b41106a200010431a20032903082102200341106a2400200242388620024280fe0383422886842002428080fc0783421886200242808080f80f834208868484200242088842808080f80f832002421888428080fc07838420024228884280fe038320024238888484840b070020001054450b1201017f104122022001105c2000200210440b3501017f230041106b220224002002420037030820022001200241086a106120002002280200200228020410161a200241106a24000b1301017f104122022001ad105c2000200210440b080020002001103f0b0d0010411a20002001102a10440b1201017f10412202200020011031104420020be90102027f027e2002200142388620014280fe0383422886842001428080fc0783421886200142808080f80f834208868484200142088842808080f80f832001421888428080fc07838420014238882205200142288822064280fe038384848437000020004108410020055022032001423088a741ff01711b220420036a410020042006a741ff01711b22036a410020032001422088a741ff01711b22036a410020032001a722034118761b22046a41002004200341107641ff01711b22046a41002004200341087641ff01711b22036a200341002001501b6a22036b3602042000200220036a3602000b3701017f230041106b220224002002420037030820022001200241086a10612000200228020020022802041031101c1a200241106a24000b3701017f230041106b22022400200241046a200141878208411210402000200228020c36020820002002290204370200200241106a24000b1c01017f41012101102e20001028047f41010510651037200010280b0b0a0041a48408410d10310b920202057f037e230041206b22032400106710582107101d2106027f024010681039450d00200620002903002208580d00200020063703002000280214200620087d104f0c010b10520b21011069103b1052106a04401069103b21021026220420002802082002101720044290ce00104d42c0e6c002104d22022002101d20077d104e10172002200120012002104641ff01714101461b21010b024020011052106a450d00200120002802082204104941ff01714101460d00200341146a106b103710632003200328021c36021020032003290214370208200341086a104221052001428094ebdc03104f2202200220051018200028021820021050200028020c200110502004200110510b200341206a24000b0a0041bb8608411710310b0a0041b88408410d10310b0a0041db8308410710310b0f0020002001104941ff01714101460b0a0041e28308411510310b970201057f230041306b22042400200441246a2205106b103710632004200428022c36022020042004290224370218200441186a2207104221062005106b103741b0820841191040200720052000103e200420042802203602142004200429021837020c2004410c6a104221082005106b10374199820841171040200720052000103e200420042802203602142004200429021837020c2004410c6a104221050240024020061052104a0d0020011052104a0d0020002802002201106d103b21001026220620022000103c20082006104c428094ebdc03104d21002001106d2002102510562005429cca00104b41ff01714102492003720d0120052000104c4290ce00104d21000c010b105221000b200441306a240020000b1401017f41d28608411d103122012000104820010b6802067f017e106f103b21021070103b21031071105321041072103b21051073103b21061067105821081069103b21072000200636021820002005360214200020043602102000200336020c20002002360208200020013602202000200736021c200020083703000b0a0041f78508410f10310b0a0041a88608411310310b0a0041df8508411810310b0a0041868608411110310b0a0041978608411110310b0b002000200110284101730b4200106f2000280208102510561070200028020c10251056107220002802141025105610732000280218102510561067200029030010621069200028021c102510560b0a0041c58408410e10310b1801017f41e084084113106022012000105d20011041101f0b1801017f41f384084114106022012000105d20011041101f0b08001020410010350ba20302077f027e230041406a220124001020410010351065105a2100107610392102106b105a210302402002452000722003107110544572721072105a106f105a72724504402001102d2200360204200141086a2202200141306a106e200210662000106d103b2104200141046a220520012802142203200128022022064100106c210210212107101d210841d38408410d106022002005105e20002002105f20002007105b20002008105b20002001280210105f20002003105f20002006105f20002004105f2000200128021c105f20001041101f20021052106a450d012003200210511071105321002002103d41ff01714101470440104121041041210510412103200010272100200210252102200142003702342001200041187420004180fe03714108747220004108764180fe0371200041187672723602302001200241187420024180fe03714108747220024108764180fe03712002411876727236023c2003200141306a411010091a2001280204200342002004200510221a0b200141086a1075200141406b24000f0b41c982084112102c000b41db82084113102c000b35001020410010350240102d10640440107610390d01107642011062410110780f0b41ee8208410e102c000b41bd8308410e102c000b36001020410010350240102d1064044010761039450d01107642001062410010780f0b41ee8208410e102c000b41cb83084110102c000b7701037f230041306b22002400102041011035103221010240102d1064044020014290ce00104b41ff01714101460d0141db83084107106022022001105f20021041101f10692001105620002000412f6a106e2000106620001075200041306a24000f0b41ee8208410e102c000b41fc8208410d102c000b4301027f1020410110354100102f2100102d106445044041ee8208410e102c000b41df850841181060210110411a200120001027104420011041101f10712000101c1a0b5b01037f230041306b2200240010204101103510322101102d106445044041ee8208410e102c000b20002000412f6a106e2000106641b185084117106022022001105f20021041101f2000200136021420001075200041306a24000bda0201097f230041306b22012400410010350240102d10640440416b2102024041c0d5082d000022000440416b41ffffffff0720001b21020c010b41c0d50841013a0000416b10230b02402002100c4170714110460440410021002002100c2105200141086a2106410121030340200041106a220720054b0d022006420037030020014200370300200220002001411010431a200304402001280200220041187420004180fe03714108747220004108764180fe0371200041187672722108200128020c220041187420004180fe03714108747220004108764180fe037120004118767272210441002103200721000c010b0b108101000b418d800841221002000b2008107110531028450d0120012001412f6a106e20011066418785084114106022002004105f20001041101f2001280208220020002004100120011075200141306a24000f0b41ee8208410e102c000b418983084118102c000b0600109701000b7c01047f230041306b22002400102041011035103221010240102d1064044020002000412f6a106e20001066200028020822022001104641ff017141024f0d01419b85084116106022032001105f20031041101f200220022001103c20001075200041306a24000f0b41ee8208410e102c000b41a18308411c102c000b2900102041001035102d106445044041ee8208410e102c000b410110771068420110621067101d10620b4601017f230041306b22002400102041001035102d106445044041ee8208410e102c000b20002000412f6a106e200010664100107710684200106220001075200041306a24000b5801027f230041106b22002400102041011035200041e283084115103436020c102d106445044041ee8208410e102c000b41e283084115106022012000410c6a105e20011041101f106b200028020c1055200041106a24000b810101027f230041106b2200240010200240102e102d107445044041011035200041a48408410d103436020c41c885084117106022012000410c6a105e20011041101f1065105a450440106510372101200028020c20011074450d020b1065200028020c1055200041106a24000f0b41f0860841241002000b419284084112102c000b0c00102041001035107610380b0c00102041001035106810380b0c00102041001035106510360b0c00102041001035106b10360b2b01017f230041306b2200240010204100103520002000412f6a106e2000106620001075200041306a24000b0c00102041001035106f103a0b0c001020410010351070103a0b0f0010204100103510711053100e1a0b0c001020410010351072103a0b0e0010204100103510671058100f0b0c001020410010351073103a0b140010204101103541b1840841071034106d103a0b0c001020410010351069103a0bae0201057f230041406a22022400102041021035418c8408410610342103027f230041206b220024004101102f2204100c2101200041003a001c2000200136021820002004360214200020013602102000410036020c0240024002402001450440410221010c010b41022101024002402000410c6a103341ff01710e020100040b4100210102402000410c6a103341ff01710e020100040b410121010b2000280210200028020c470d0120002d001c450d0041b8d508410036020041bcd50841003a00000b200041206a240020010c020b41f78308411541ae8108410e1030000b41f78308411541808008410d1030000b21012002200336020c200241106a22002002413f6a106e200010662002410c6a200228021c20022802282001410171106c200010751010200241406b24000b920202097f017e230041306b2200240010204100103520002000412f6a106e2000106620002802081025200028020c1025210220002802101027210320002802141025210420002903002109200028021810252105200028021c10252106106510372107106b103721082000107541f08608410010312201102920022001102920032001102b2004200110292005200110292001200710041a2001200810041a2000200942388620094280fe0383422886842009428080fc0783421886200942808080f80f834208868484200942088842808080f80f832009421888428080fc07838420094228884280fe0383200942388884848437030020012000410810091a2006200110292001100e1a200041306a24000b0300010b0b0041948708410e1002000b0bb6070200418080080ba207696e76616c69642076616c7565696e636f7272656374206e756d626572206f662045534454207472616e7366657273617267756d656e74206465636f6465206572726f722028293a20746f6f2066657720617267756d656e747377726f6e67206e756d626572206f6620617267756d656e747363616e6e6f74207375627472616374206265636175736520726573756c7420776f756c64206265206e6567617469766573796e6320726573756c74696e70757420746f6f206c6f6e676361737420746f20693634206572726f7273746f72616765206465636f6465206572726f7220286b65793a20626164206172726179206c656e677468696e70757420746f6f2073686f7274676574546f74616c426f6e64416d6f756e7467657441646472657373426f6e647341766753636f726567657441646472657373426f6e6473546f74616c56616c7565436f6e7472616374206e6f742072656164794e6f207265776172647320746f20636c61696d4e6f742070726976696c65676564496e76616c69642076616c7565496e76616c696420746f6b656e206964656e746966696572496e73756666696369656e7420726577617264732072657365727665416c726561647920616374697665416c726561647920696e6163746976656d61785f617072626f6e645f636f6e74726163745f616464726573736f70745f6279706173735f6c6976656c696e65737363616c6c6572416c726561647920696e2073746f7261676561646d696e6973747261746f7261646472657373726577617264735f7374617465636f6e74726163745f7374617465636c61696d5f72657761726473726577617264735f73746174655f6576656e74636f6e74726163745f73746174655f6576656e74746f705f75705f726577617264735f6576656e7477697468647261775f726577617264735f6576656e747065725f626c6f636b5f7265776172645f616d6f756e747365745f61646d696e6973747261746f725f6576656e74726577617264735f746f6b656e5f6964656e746966696572726577617264735f72657365727665726577617264735f7065725f626c6f636b726577617264735f7065725f7368617265616363756d756c617465645f726577617264736c6173745f7265776172645f626c6f636b5f6e6f6e6365616464726573735f6c6173745f7265776172645f7065725f736861726500456e64706f696e742063616e206f6e6c792062652063616c6c6564206279206f776e657270616e6963206f636375727265640041a487080b0438ffffff", + "report": { + "imports": [ + "bigIntAdd", + "bigIntCmp", + "bigIntFinishUnsigned", + "bigIntGetUnsignedArgument", + "bigIntMul", + "bigIntSetInt64", + "bigIntSign", + "bigIntSub", + "bigIntTDiv", + "checkNoPayment", + "cleanReturnData", + "getBlockNonce", + "getBlockTimestamp", + "getGasLeft", + "getNumArguments", + "mBufferAppend", + "mBufferAppendBytes", + "mBufferEq", + "mBufferFinish", + "mBufferFromBigIntUnsigned", + "mBufferGetArgument", + "mBufferGetByteSlice", + "mBufferGetLength", + "mBufferNew", + "mBufferSetBytes", + "mBufferStorageLoad", + "mBufferStorageStore", + "mBufferToBigIntUnsigned", + "managedCaller", + "managedExecuteOnDestContext", + "managedGetMultiESDTCallValue", + "managedMultiTransferESDTNFTExecute", + "managedOwnerAddress", + "managedSignalError", + "managedWriteLog", + "signalError", + "smallIntFinishUnsigned" + ], + "isMemGrow": false, + "eiCheck": { + "eiVersion": "1.3", + "ok": true + }, + "codeReport": { + "path": "../output/core-mx-liveliness-stake.wasm", + "size": 8432, + "hasAllocator": false, + "hasPanic": "without message" + } + } +} diff --git a/tests/bonding_state/bonding_state.rs b/tests/bonding_state/bonding_state.rs index 4f9f9f7..675746c 100644 --- a/tests/bonding_state/bonding_state.rs +++ b/tests/bonding_state/bonding_state.rs @@ -12,6 +12,7 @@ use multiversx_sc::{ }; use multiversx_sc_scenario::{ api::StaticApi, + imports::MxscPath, managed_address, managed_biguint, managed_token_id, num_bigint::BigUint, scenario_model::{ @@ -24,6 +25,13 @@ use multiversx_sc_scenario::{ pub const BONDING_CONTRACT_PATH: &str = "mxsc:output/core-mx-life-bonding-sc.msxc.json"; pub const BONDING_CONTRACT_ADDRESS_EXPR: &str = "sc:core-mx-life-bonding-sc"; +pub const LIVELINESS_STAKE_OWNER_ADDRESS_EXPR: &str = "address:core-mx-life-bonding-sc"; + +pub const LIVELINESS_STAKE_PATH: &str = + "mxsc:test_external_contracts/core-mx-life-bonding-sc.mxsc.json"; + +pub const LIVELINESS_STAKE_CONTRACT_ADDRESS_EXPR: &str = "sc:core-mx-liveliness-stake"; + pub const MINTER_CONTRACT_ADDRESS_EXPR: &str = "sc:minter"; pub const OWNER_BONDING_CONTRACT_ADDRESS_EXPR: &str = "address:owner"; @@ -52,6 +60,12 @@ pub fn world() -> ScenarioWorld { BONDING_CONTRACT_PATH, core_mx_life_bonding_sc::ContractBuilder, ); + + blockchain.register_contract( + LIVELINESS_STAKE_PATH, + core_mx_liveliness_stake::ContractBuilder, + ); + blockchain } @@ -83,6 +97,15 @@ impl ContractState { 1, BONDING_CONTRACT_ADDRESS_EXPR, ) + .put_account( + LIVELINESS_STAKE_OWNER_ADDRESS_EXPR, + Account::new().nonce(1).balance("1_000"), + ) + .new_address( + LIVELINESS_STAKE_OWNER_ADDRESS_EXPR, + 1, + LIVELINESS_STAKE_CONTRACT_ADDRESS_EXPR, + ) .put_account( ADMIN_BONDING_CONTRACT_ADDRESS_EXPR, Account::new() @@ -147,6 +170,7 @@ impl ContractState { pub fn default_deploy_and_set(&mut self, lock_period: u64, bond_amount: u64) -> &mut Self { let admin = self.admin.clone(); self.deploy() + .deploy_liveliness_stake() .set_administrator(OWNER_BONDING_CONTRACT_ADDRESS_EXPR, admin.clone(), None) .set_accepted_caller(OWNER_BONDING_CONTRACT_ADDRESS_EXPR, admin.clone(), None) .set_bond_token( @@ -159,11 +183,29 @@ impl ContractState { lock_period, bond_amount, None, - ); + ) + .set_liveliness_stake_contract( + OWNER_BONDING_CONTRACT_ADDRESS_EXPR, + AddressValue::from(LIVELINESS_STAKE_CONTRACT_ADDRESS_EXPR).to_address(), + None, + ) + .set_top_up_administrator(OWNER_BONDING_CONTRACT_ADDRESS_EXPR, admin.clone(), None); self } + pub fn deploy_liveliness_stake(&mut self) -> &mut Self { + let liveliness_stake_contract_code = self.world.code_expression(LIVELINESS_STAKE_PATH); + + self.world.sc_deploy( + ScDeployStep::new() + .from(LIVELINESS_STAKE_OWNER_ADDRESS_EXPR) + .code(liveliness_stake_contract_code) + .call(self.contract.init()), + ); + self + } + pub fn deploy(&mut self) -> &mut Self { let bonding_contract_code = self.world.code_expression(BONDING_CONTRACT_PATH); @@ -195,6 +237,44 @@ impl ContractState { self } + pub fn set_top_up_administrator( + &mut self, + caller: &str, + top_up_address: Address, + expect: Option, + ) -> &mut Self { + let tx_expect = expect.unwrap_or(TxExpect::ok()); + self.world.sc_call( + ScCallStep::new() + .from(caller) + .call( + self.contract + .set_top_up_administrator(managed_address!(&top_up_address)), + ) + .expect(tx_expect), + ); + self + } + + pub fn set_liveliness_stake_contract( + &mut self, + caller: &str, + liveliness_stake: Address, + expect: Option, + ) -> &mut Self { + let tx_expect = expect.unwrap_or(TxExpect::ok()); + self.world.sc_call( + ScCallStep::new() + .from(caller) + .call( + self.contract + .set_liveliness_stake_address(managed_address!(&liveliness_stake)), + ) + .expect(tx_expect), + ); + self + } + pub fn initiate_bond_for_address( &mut self, caller: &str, @@ -602,4 +682,44 @@ impl ContractState { ); self } + + pub fn set_vault_nonce( + &mut self, + caller: &str, + token_identifier: &[u8], + nonce: u64, + expect: Option, + ) -> &mut Self { + self.world.sc_call( + ScCallStep::new() + .from(caller) + .call( + self.contract + .set_vault_nonce(managed_token_id!(token_identifier), nonce), + ) + .expect(expect.unwrap_or(TxExpect::ok())), + ); + self + } + + pub fn top_up_vault( + &mut self, + caller: &str, + payment: (&str, u64, u64), + token_identifier: &[u8], + nonce: u64, + expect: Option, + ) -> &mut Self { + self.world.sc_call( + ScCallStep::new() + .from(caller) + .esdt_transfer(payment.0, payment.1, payment.2) + .call( + self.contract + .top_up_vault(managed_token_id!(token_identifier), nonce), + ) + .expect(expect.unwrap_or(TxExpect::ok())), + ); + self + } } diff --git a/tests/endpoints/mod.rs b/tests/endpoints/mod.rs index 9cccd5f..502ea0c 100644 --- a/tests/endpoints/mod.rs +++ b/tests/endpoints/mod.rs @@ -4,5 +4,6 @@ mod claim_refund; mod deploy_upgrade; mod proof; mod renew; +mod vault; mod views; mod withdraw; diff --git a/tests/endpoints/proof.rs b/tests/endpoints/proof.rs index e617d1d..88c6bd9 100644 --- a/tests/endpoints/proof.rs +++ b/tests/endpoints/proof.rs @@ -1,4 +1,3 @@ -use std::cell::Ref; use core_mx_life_bonding_sc::{ storage::{PenaltyType, Refund}, @@ -11,7 +10,6 @@ use multiversx_sc::{ use multiversx_sc_scenario::{ api::StaticApi, managed_address, managed_token_id, - multiversx_chain_vm::vm_hooks::StaticApiVMHooksHandler, scenario_model::{ AddressValue, CheckAccount, CheckStateStep, ScQueryStep, SetStateStep, TransferStep, TxExpect, diff --git a/tests/endpoints/vault.rs b/tests/endpoints/vault.rs new file mode 100644 index 0000000..e9a08fd --- /dev/null +++ b/tests/endpoints/vault.rs @@ -0,0 +1,127 @@ +use multiversx_sc::{imports::SingleValue, types::BigUint}; +use multiversx_sc_scenario::{ + imports::{ + Account, AddressValue, BytesValue, CheckAccount, CheckStateStep, + ScQueryStep, SetStateStep, TransferStep, TxExpect, + }, + managed_address, managed_token_id, +}; + +use core_mx_life_bonding_sc::storage::{Bond, ProxyTrait}; +use core_mx_life_bonding_sc::views::ProxyTrait as _; + +use crate::bonding_state::bonding_state::{ + ContractState, DATA_NFT_IDENTIFIER, DATA_NFT_IDENTIFIER_EXPR, + FIRST_USER_ADDRESS_EXPR, ITHEUM_TOKEN_IDENTIFIER, ITHEUM_TOKEN_IDENTIFIER_EXPR, + MINTER_CONTRACT_ADDRESS_EXPR, OWNER_BONDING_CONTRACT_ADDRESS_EXPR, +}; + +#[test] +fn vault_tests() { + let mut state = ContractState::new(); + let first_user_address = state.first_user_address.clone(); + let admin = state.admin.clone(); + + state + .default_deploy_and_set(10u64, 100u64) + .remove_accepted_caller(OWNER_BONDING_CONTRACT_ADDRESS_EXPR, admin.clone(), None) + .set_accepted_caller( + OWNER_BONDING_CONTRACT_ADDRESS_EXPR, + AddressValue::from(MINTER_CONTRACT_ADDRESS_EXPR).to_address(), + None, + ); + + state.world.set_state_step( + SetStateStep::new().put_account( + FIRST_USER_ADDRESS_EXPR, + Account::new() + .nonce(1) + .balance("1_000") + .esdt_balance(ITHEUM_TOKEN_IDENTIFIER_EXPR, "300") + .esdt_nft_balance(DATA_NFT_IDENTIFIER_EXPR, 1u64, 2u64, None::), + ), + ); + + state.unpause_contract(OWNER_BONDING_CONTRACT_ADDRESS_EXPR, None); + + state.world.transfer_step( + // mocks the mint call in minter and transfers the bond amount + TransferStep::new() + .from(FIRST_USER_ADDRESS_EXPR) + .to(MINTER_CONTRACT_ADDRESS_EXPR) + .esdt_transfer(ITHEUM_TOKEN_IDENTIFIER, 0u64, 100u64), + ); + + state.set_vault_nonce( + FIRST_USER_ADDRESS_EXPR, + DATA_NFT_IDENTIFIER, + 1u64, + Some(TxExpect::user_error("str:Unknown object")), + ); + + state.bond( + MINTER_CONTRACT_ADDRESS_EXPR, // another bond contract acts as minter mock + first_user_address.clone(), + DATA_NFT_IDENTIFIER, + 1u64, + 10u64, + (ITHEUM_TOKEN_IDENTIFIER_EXPR, 0u64, 100u64), // bond amount + None, + ); + + state.set_vault_nonce(FIRST_USER_ADDRESS_EXPR, DATA_NFT_IDENTIFIER, 1u64, None); + + state.world.sc_query( + ScQueryStep::new() + .call(state.contract.address_vault_nonce( + AddressValue::from(FIRST_USER_ADDRESS_EXPR).to_address(), + DATA_NFT_IDENTIFIER, + )) + .expect_value(SingleValue::from(1u64)), // vault nonce 1 + ); + + state.top_up_vault( + FIRST_USER_ADDRESS_EXPR, + (ITHEUM_TOKEN_IDENTIFIER_EXPR, 0u64, 100u64), + DATA_NFT_IDENTIFIER, + 1u64, + None, + ); + + state.top_up_vault( + FIRST_USER_ADDRESS_EXPR, + (ITHEUM_TOKEN_IDENTIFIER_EXPR, 0u64, 100u64), + DATA_NFT_IDENTIFIER, + 1u64, + None, + ); + + state.world.sc_query( + ScQueryStep::new() + .call(state.contract.get_bond(1u64)) + .expect_value(Bond { + bond_id: 1u64, + address: managed_address!(&first_user_address.clone()), + token_identifier: managed_token_id!(DATA_NFT_IDENTIFIER), + nonce: 1u64, + lock_period: 10u64, + bond_timestamp: 0u64, + bond_amount: BigUint::from(300u64), + unbond_timestamp: 10u64, + remaining_amount: BigUint::from(300u64), // 100 (bond) + 200 top up + }), + ); + + state + .world + .set_state_step(SetStateStep::new().block_timestamp(11u64)); + + state.withdraw(FIRST_USER_ADDRESS_EXPR, DATA_NFT_IDENTIFIER, 1u64, None); + + state + .world + .check_state_step(CheckStateStep::new().put_account( + FIRST_USER_ADDRESS_EXPR, + CheckAccount::new().esdt_balance(ITHEUM_TOKEN_IDENTIFIER_EXPR, "300"), //withdraw full amount after lock + )); +} diff --git a/tests/mapper_test.rs b/tests/mapper_test.rs index c2a6633..a69b677 100644 --- a/tests/mapper_test.rs +++ b/tests/mapper_test.rs @@ -28,8 +28,8 @@ fn test_mapper() { assert_eq!(id, 1u64); // same id as before - assert_eq!(mapper.contains_id(1u64), true); - assert_eq!(mapper.contains_id(2u64), false); + assert!(mapper.contains_id(1u64)); + assert!(!mapper.contains_id(2u64)); let (token_identifier_from_storage, nonce_from_storage) = mapper.get_object(1u64).unwrap(); @@ -62,7 +62,7 @@ fn test_mapper() { assert_eq!(same_id, 2u64); - assert_eq!(mapper.contains_id(2u64), true); + assert!(mapper.contains_id(2u64)); // remove by id diff --git a/tests/unit_test.rs b/tests/unit_test.rs index ccd8559..3964078 100644 --- a/tests/unit_test.rs +++ b/tests/unit_test.rs @@ -3,6 +3,7 @@ mod endpoints; use core_mx_life_bonding_sc::{ config::{ConfigModule, State}, + storage::StorageModule, LifeBondingContract, }; use multiversx_sc_scenario::{ @@ -15,17 +16,17 @@ fn bond_contract_ready_test() { bond_contract.init(); - assert_eq!(false, bond_contract.contract_is_ready()); + assert!(!bond_contract.contract_is_ready()); bond_contract.administrator().set(managed_address!( &AddressValue::from("address:admin").to_address() )); - assert_eq!(false, bond_contract.contract_is_ready()); + assert!(!bond_contract.contract_is_ready()); bond_contract.contract_state().set(State::Active); - assert_eq!(false, bond_contract.contract_is_ready()); + assert!(!bond_contract.contract_is_ready()); bond_contract .accepted_callers() @@ -33,27 +34,35 @@ fn bond_contract_ready_test() { &AddressValue::from("address:caller").to_address() )); - assert_eq!(false, bond_contract.contract_is_ready()); + assert!(!bond_contract.contract_is_ready()); bond_contract .bond_payment_token() .set(managed_token_id!(b"TEST-1234")); - assert_eq!(false, bond_contract.contract_is_ready()); + assert!(!bond_contract.contract_is_ready()); - bond_contract.lock_periods().insert(1); + bond_contract.lock_periods().insert(1u64); - assert_eq!(true, bond_contract.contract_is_ready()); + assert!(!bond_contract.contract_is_ready()); - bond_contract.lock_periods().remove(&1); + bond_contract + .liveliness_stake_address() + .set(managed_address!( + &AddressValue::from("address:stake").to_address() + )); - assert_eq!(false, bond_contract.contract_is_ready()); + assert!(!bond_contract.contract_is_ready()); - bond_contract.lock_periods().insert(1); + bond_contract + .top_up_administrator() + .set(managed_address!( + &AddressValue::from("address:topup").to_address() + )); - assert_eq!(true, bond_contract.contract_is_ready()); + assert!(bond_contract.contract_is_ready()); bond_contract.contract_state().clear(); - assert_eq!(false, bond_contract.contract_is_ready()); + assert!(!bond_contract.contract_is_ready()); } diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 089d2a2..50430ee 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -23,18 +23,53 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "core-mx-life-bonding-sc" version = "2.0.0" +source = "git+https://github.com/Itheum/core-mx-life-bonding-sc?branch=develop#c51654efe43dd071737ee3de4ee42f0842613f49" dependencies = [ "multiversx-sc", ] +[[package]] +name = "core-mx-life-bonding-sc" +version = "2.0.0" +source = "git+https://github.com/Itheum/core-mx-life-bonding-sc?branch=vault#5188445f7e4b1398ea840546a3cdfb67759be60c" +dependencies = [ + "core-mx-liveliness-stake 0.0.0 (git+https://github.com/Itheum/core-mx-liveliness-stake.git?branch=main)", + "multiversx-sc", +] + +[[package]] +name = "core-mx-life-bonding-sc" +version = "3.0.0" +dependencies = [ + "core-mx-liveliness-stake 0.0.0", + "multiversx-sc", +] + [[package]] name = "core-mx-life-bonding-sc-wasm" version = "0.0.0" dependencies = [ - "core-mx-life-bonding-sc", + "core-mx-life-bonding-sc 3.0.0", "multiversx-sc-wasm-adapter", ] +[[package]] +name = "core-mx-liveliness-stake" +version = "0.0.0" +dependencies = [ + "core-mx-life-bonding-sc 2.0.0 (git+https://github.com/Itheum/core-mx-life-bonding-sc?branch=vault)", + "multiversx-sc", +] + +[[package]] +name = "core-mx-liveliness-stake" +version = "0.0.0" +source = "git+https://github.com/Itheum/core-mx-liveliness-stake.git?branch=main#36b08f1e279d32af939e1a32df449952ce074102" +dependencies = [ + "core-mx-life-bonding-sc 2.0.0 (git+https://github.com/Itheum/core-mx-life-bonding-sc?branch=develop)", + "multiversx-sc", +] + [[package]] name = "endian-type" version = "0.1.2" diff --git a/wasm/src/lib.rs b/wasm/src/lib.rs index c40f5ad..f442c1e 100644 --- a/wasm/src/lib.rs +++ b/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 50 +// Endpoints: 60 // Async Callback (empty): 1 -// Total number of exported functions: 53 +// Total number of exported functions: 63 #![no_std] @@ -25,8 +25,14 @@ multiversx_sc_wasm_adapter::endpoints! { renew => renew proof => add_proof claimRefund => claim_refund + setVaultNonce => set_vault_nonce + topUpVault => top_up_vault + topUpAddressVault => top_up_address_vault + stakeRewards => stake_rewards getCompensationBlacklist => compensation_blacklist getTotalBondAmount => total_bond_amount + getAddressVaultNone => address_vault_nonce + getLivelinessStakeAddress => liveliness_stake_address getBond => get_bond getCompensation => get_compensation getCompensations => get_compensations @@ -38,6 +44,7 @@ multiversx_sc_wasm_adapter::endpoints! { getAddressBonds => get_address_bonds getAddressBondsAvgScore => get_address_bonds_avg_score getAddressBondsTotalValue => get_address_bonds_total_value + getAddressBondsInfo => get_address_bonds_info getAllBonds => get_all_bonds getPagedBonds => get_paged_bonds getBondsLen => get_bonds_len @@ -60,9 +67,12 @@ multiversx_sc_wasm_adapter::endpoints! { setMinimumPenalty => set_minimum_penalty setMaximumPenalty => set_maximum_penalty setWithdrawPenalty => set_withdraw_penalty + setLivelinessStakeAddress => set_liveliness_stake_address + setTopUpAdministrator => set_top_up_administrator setAdministrator => set_administrator getContractState => contract_state getAdministrator => administrator + getTopUpAdministrator => top_up_administrator getAcceptedCallers => accepted_callers getBondPaymentToken => bond_payment_token getLockPeriods => lock_periods