diff --git a/Cargo.lock b/Cargo.lock index bf5dbf95d1..f9c25cc9fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli 0.27.2", + "gimli 0.27.3", ] [[package]] @@ -90,9 +90,9 @@ dependencies = [ [[package]] name = "aes" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" dependencies = [ "cfg-if", "cipher 0.4.4", @@ -120,7 +120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" dependencies = [ "aead 0.5.2", - "aes 0.8.2", + "aes 0.8.3", "cipher 0.4.4", "ctr 0.9.2", "ghash 0.5.0", @@ -235,15 +235,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] @@ -314,9 +314,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8868f09ff8cea88b079da74ae569d9b8c62a23c68c746240b704ee6f7525c89c" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "asn1-rs" @@ -412,6 +412,7 @@ dependencies = [ name = "astar-collator" version = "5.11.0" dependencies = [ + "astar-primitives", "astar-runtime", "async-trait", "clap", @@ -509,11 +510,27 @@ dependencies = [ "url", ] +[[package]] +name = "astar-primitives" +version = "0.1.0" +dependencies = [ + "frame-support", + "log", + "pallet-xc-asset-config", + "sp-core", + "sp-runtime", + "sp-std", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "astar-runtime" version = "5.11.0" dependencies = [ "array-bytes 6.1.0", + "astar-primitives", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -600,7 +617,6 @@ dependencies = [ "xcm", "xcm-builder", "xcm-executor", - "xcm-primitives", ] [[package]] @@ -876,7 +892,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", - "arrayvec 0.7.3", + "arrayvec 0.7.4", "constant_time_eq", ] @@ -887,7 +903,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", - "arrayvec 0.7.3", + "arrayvec 0.7.4", "constant_time_eq", ] @@ -898,7 +914,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "729b71f35bd3fa1a4c86b85d32c8b9069ea7fe14f7a53cfabb65f62d4265b888" dependencies = [ "arrayref", - "arrayvec 0.7.3", + "arrayvec 0.7.4", "cc", "cfg-if", "constant_time_eq", @@ -1249,9 +1265,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.3" +version = "4.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8f255e4b8027970e78db75e78831229c9815fdbfa67eb1a1b777a62e24b4a0" +checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc" dependencies = [ "clap_builder", "clap_derive", @@ -1260,9 +1276,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.3" +version = "4.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd4f3c17c83b0ba34ffbc4f8bbd74f079413f747f84a6f89292f138057e36ab" +checksum = "2e53afce1efce6ed1f633cf0e57612fe51db54a1ee4fd8f8503d078fe02d69ae" dependencies = [ "anstream", "anstyle", @@ -1413,9 +1429,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c" dependencies = [ "libc", ] @@ -1435,7 +1451,7 @@ version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "253531aca9b6f56103c9420369db3263e784df39aa1c90685a1f69cfbba0623e" dependencies = [ - "arrayvec 0.7.3", + "arrayvec 0.7.4", "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", @@ -2207,9 +2223,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109308c20e8445959c2792e81871054c6a17e6976489a93d2769641a2ba5839c" +checksum = "e88abab2f5abbe4c56e8f1fb431b784d710b709888f35755a160e62e33fe38e8" dependencies = [ "cc", "cxxbridge-flags", @@ -2219,9 +2235,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf4c6755cdf10798b97510e0e2b3edb9573032bd9379de8fffa59d68165494f" +checksum = "5c0c11acd0e63bae27dcd2afced407063312771212b7a823b4fd72d633be30fb" dependencies = [ "cc", "codespan-reporting", @@ -2234,15 +2250,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882074421238e84fe3b4c65d0081de34e5b323bf64555d3e61991f76eb64a7bb" +checksum = "8d3816ed957c008ccd4728485511e3d9aaf7db419aa321e3d2c5a2f3411e36c8" [[package]] name = "cxxbridge-macro" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" +checksum = "a26acccf6f445af85ea056362561a24ef56cdc15fcc685f03aec50b9c702cb6d" dependencies = [ "proc-macro2", "quote", @@ -3799,7 +3815,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.6.0", + "polyval 0.6.1", ] [[package]] @@ -3815,9 +3831,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "glob" @@ -4437,7 +4453,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" dependencies = [ "anyhow", - "arrayvec 0.7.3", + "arrayvec 0.7.4", "async-lock", "async-trait", "beef", @@ -4528,7 +4544,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -4788,7 +4804,7 @@ dependencies = [ "rand 0.8.5", "rw-stream-sink", "sec1", - "sha2 0.10.6", + "sha2 0.10.7", "smallvec", "thiserror", "unsigned-varint", @@ -4872,7 +4888,7 @@ dependencies = [ "multihash 0.17.0", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "thiserror", "zeroize", ] @@ -4883,7 +4899,7 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2766dcd2be8c87d5e1f35487deb22d765f49c6ae1251b3633efe3b25698bd3d2" dependencies = [ - "arrayvec 0.7.3", + "arrayvec 0.7.4", "asynchronous-codec", "bytes", "either", @@ -4897,7 +4913,7 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "smallvec", "thiserror", "uint", @@ -4972,7 +4988,7 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "snow", "static_assertions", "thiserror", @@ -5305,6 +5321,7 @@ name = "local-runtime" version = "5.11.0" dependencies = [ "array-bytes 6.1.0", + "astar-primitives", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -5941,7 +5958,7 @@ dependencies = [ "core2", "digest 0.10.7", "multihash-derive", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "unsigned-varint", ] @@ -6187,7 +6204,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.3", + "arrayvec 0.7.4", "itoa", ] @@ -6444,7 +6461,7 @@ checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ "ecdsa", "elliptic-curve", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -6455,7 +6472,7 @@ checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ "ecdsa", "elliptic-curve", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -6649,6 +6666,7 @@ dependencies = [ name = "pallet-block-reward" version = "2.2.2" dependencies = [ + "astar-primitives", "frame-benchmarking", "frame-support", "frame-system", @@ -6907,6 +6925,7 @@ dependencies = [ name = "pallet-dapps-staking" version = "3.9.0" dependencies = [ + "astar-primitives", "frame-benchmarking", "frame-support", "frame-system", @@ -8056,11 +8075,11 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.5.0" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" +checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" dependencies = [ - "arrayvec 0.7.3", + "arrayvec 0.7.4", "bitvec", "byte-slice-cast", "bytes", @@ -8071,9 +8090,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.4" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" +checksum = "2b6937b5e67bfba3351b87b040d48352a2fcb6ad72f81855412ce97b45c8f110" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8203,9 +8222,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" +checksum = "f73935e4d55e2abf7f130186537b19e7a4abc886a0252380b59248af473a3fc9" dependencies = [ "thiserror", "ucd-trie", @@ -8213,9 +8232,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" +checksum = "aef623c9bbfa0eedf5a0efba11a5ee83209c326653ca31ff019bec3a95bfff2b" dependencies = [ "pest", "pest_generator", @@ -8223,9 +8242,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" +checksum = "b3e8cba4ec22bada7fc55ffe51e2deb6a0e0db2d0b7ab0b103acc80d2510c190" dependencies = [ "pest", "pest_meta", @@ -8236,13 +8255,13 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" +checksum = "a01f71cb40bd8bb94232df14b946909e14660e33fc05db3e50ae2a82d7ea0ca0" dependencies = [ "once_cell", "pest", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -9507,9 +9526,9 @@ dependencies = [ [[package]] name = "polyval" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" dependencies = [ "cfg-if", "cpufeatures", @@ -10433,9 +10452,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -11575,9 +11594,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" +checksum = "ad560913365790f17cbf12479491169f01b9d46d29cfc7422bf8c64bdc61b731" dependencies = [ "bitvec", "cfg-if", @@ -11589,9 +11608,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" +checksum = "19df9bd9ace6cc2fe19387c96ce677e823e07d017ceed253e7bb3d1d1bd9c73b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11800,9 +11819,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "bdf3bf93142acad5821c99197022e170842cdbc1c30482b98750c688c640842a" dependencies = [ "itoa", "ryu", @@ -11860,9 +11879,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -11893,6 +11912,7 @@ name = "shibuya-runtime" version = "5.11.0" dependencies = [ "array-bytes 6.1.0", + "astar-primitives", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -11993,7 +12013,6 @@ dependencies = [ "xcm", "xcm-builder", "xcm-executor", - "xcm-primitives", ] [[package]] @@ -12001,6 +12020,7 @@ name = "shiden-runtime" version = "5.11.0" dependencies = [ "array-bytes 6.1.0", + "astar-primitives", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -12091,7 +12111,6 @@ dependencies = [ "xcm", "xcm-builder", "xcm-executor", - "xcm-primitives", ] [[package]] @@ -12231,7 +12250,7 @@ dependencies = [ "rand_core 0.6.4", "ring", "rustc_version 0.4.0", - "sha2 0.10.6", + "sha2 0.10.7", "subtle", ] @@ -12526,7 +12545,7 @@ dependencies = [ "blake2", "byteorder", "digest 0.10.7", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "sp-std", "twox-hash", @@ -13319,9 +13338,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" [[package]] name = "tempfile" @@ -13481,7 +13500,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.6", + "sha2 0.10.7", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -13672,9 +13691,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", @@ -14104,11 +14123,10 @@ dependencies = [ [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] @@ -14403,7 +14421,7 @@ dependencies = [ "log", "rustix 0.36.14", "serde", - "sha2 0.10.6", + "sha2 0.10.7", "toml", "windows-sys 0.42.0", "zstd", @@ -14593,7 +14611,7 @@ dependencies = [ "sdp", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.7", "stun", "thiserror", "time 0.3.22", @@ -14656,7 +14674,7 @@ dependencies = [ "sec1", "serde", "sha1", - "sha2 0.10.6", + "sha2 0.10.7", "signature", "subtle", "thiserror", @@ -15144,9 +15162,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" dependencies = [ "memchr", ] @@ -15286,20 +15304,6 @@ dependencies = [ "xcm", ] -[[package]] -name = "xcm-primitives" -version = "0.4.1" -dependencies = [ - "frame-support", - "log", - "pallet-xc-asset-config", - "sp-runtime", - "sp-std", - "xcm", - "xcm-builder", - "xcm-executor", -] - [[package]] name = "xcm-procedural" version = "0.9.39-1" @@ -15332,6 +15336,7 @@ dependencies = [ name = "xcm-simulator-tests" version = "0.1.0" dependencies = [ + "astar-primitives", "cumulus-pallet-xcm", "frame-support", "frame-system", @@ -15365,7 +15370,6 @@ dependencies = [ "xcm", "xcm-builder", "xcm-executor", - "xcm-primitives", "xcm-simulator", ] diff --git a/Cargo.toml b/Cargo.toml index b3cf139cae..0b8f37ec0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,8 @@ members = [ "pallets/*", "precompiles/*", + "primitives", + "chain-extensions/dapps-staking", "chain-extensions/pallet-assets", "chain-extensions/xvm", @@ -272,7 +274,7 @@ pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features pallet-xvm = { path = "./pallets/pallet-xvm", default-features = false } pallet-xcm = { path = "./pallets/pallet-xcm", default-features = false } -xcm-primitives = { path = "./primitives/xcm", default-features = false } +astar-primitives = { path = "./primitives", default-features = false } pallet-evm-precompile-assets-erc20 = { path = "./precompiles/assets-erc20", default-features = false } pallet-evm-precompile-sr25519 = { path = "./precompiles/sr25519", default-features = false } diff --git a/bin/collator/Cargo.toml b/bin/collator/Cargo.toml index d6a935ff5d..2edb552bd0 100644 --- a/bin/collator/Cargo.toml +++ b/bin/collator/Cargo.toml @@ -92,6 +92,7 @@ shibuya-runtime = { workspace = true, features = ["std"] } shiden-runtime = { workspace = true, features = ["std"] } # astar pallets dependencies +astar-primitives = { workspace = true } pallet-block-reward = { workspace = true } # frame dependencies @@ -161,6 +162,7 @@ runtime-benchmarks = [ "sp-keyring", "cumulus-test-relay-sproof-builder", "polkadot-runtime-common", + "astar-primitives/runtime-benchmarks", ] cli = ["try-runtime-cli"] try-runtime = ["local-runtime/try-runtime", "try-runtime-cli/try-runtime"] diff --git a/bin/collator/src/benchmarking.rs b/bin/collator/src/benchmarking.rs index 902b926143..434446c6f5 100644 --- a/bin/collator/src/benchmarking.rs +++ b/bin/collator/src/benchmarking.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -use crate::primitives::{AccountId, Balance, Block}; +use astar_primitives::{AccountId, Balance, Block}; use cumulus_primitives_core::PersistedValidationData; use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER}; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; diff --git a/bin/collator/src/command.rs b/bin/collator/src/command.rs index 56df11a0d5..82bb9e168a 100644 --- a/bin/collator/src/command.rs +++ b/bin/collator/src/command.rs @@ -24,8 +24,8 @@ use crate::{ self, astar, chain_spec, service::AdditionalConfig, shibuya, shiden, start_astar_node, start_shibuya_node, start_shiden_node, }, - primitives::Block, }; +use astar_primitives::*; use cumulus_client_cli::generate_genesis_block; use cumulus_primitives_core::ParaId; use log::{error, info}; diff --git a/bin/collator/src/lib.rs b/bin/collator/src/lib.rs index 0450d70683..73d5589333 100644 --- a/bin/collator/src/lib.rs +++ b/bin/collator/src/lib.rs @@ -32,7 +32,6 @@ mod benchmarking; mod cli; mod command; mod evm_tracing_types; -mod primitives; mod rpc; pub use cli::*; diff --git a/bin/collator/src/local/service.rs b/bin/collator/src/local/service.rs index d14510bc6d..ab883d5d97 100644 --- a/bin/collator/src/local/service.rs +++ b/bin/collator/src/local/service.rs @@ -32,7 +32,7 @@ use std::{collections::BTreeMap, sync::Arc, time::Duration}; pub use local_runtime::RuntimeApi; -use crate::primitives::*; +use astar_primitives::*; /// Local runtime native executor. pub struct Executor; diff --git a/bin/collator/src/parachain/chain_spec/mod.rs b/bin/collator/src/parachain/chain_spec/mod.rs index 6f9f7058a9..47916e7bdd 100644 --- a/bin/collator/src/parachain/chain_spec/mod.rs +++ b/bin/collator/src/parachain/chain_spec/mod.rs @@ -20,7 +20,7 @@ use sc_chain_spec::ChainSpecExtension; use serde::{Deserialize, Serialize}; use sp_core::{Pair, Public}; -use crate::primitives::Block; +use astar_primitives::Block; pub mod astar; pub mod shibuya; diff --git a/bin/collator/src/parachain/service.rs b/bin/collator/src/parachain/service.rs index 35fd141fd6..0285b53d27 100644 --- a/bin/collator/src/parachain/service.rs +++ b/bin/collator/src/parachain/service.rs @@ -17,6 +17,8 @@ // along with Astar. If not, see . //! Parachain Service and ServiceFactory implementation. + +use astar_primitives::*; use cumulus_client_cli::CollatorOptions; use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; use cumulus_client_consensus_common::{ParachainBlockImport, ParachainConsensus}; @@ -51,7 +53,6 @@ use super::shell_upgrade::*; #[cfg(feature = "evm-tracing")] use crate::evm_tracing_types::{EthApi as EthApiCmd, EvmTracingConfig}; -use crate::primitives::*; #[cfg(feature = "evm-tracing")] use crate::rpc::tracing; diff --git a/bin/collator/src/parachain/shell_upgrade.rs b/bin/collator/src/parachain/shell_upgrade.rs index 8bb9427dc1..ee6f54ba11 100644 --- a/bin/collator/src/parachain/shell_upgrade.rs +++ b/bin/collator/src/parachain/shell_upgrade.rs @@ -18,6 +18,7 @@ ///! Special [`ParachainConsensus`] implementation that waits for the upgrade from ///! shell to a parachain runtime that implements Aura. +use astar_primitives::*; use cumulus_client_consensus_common::{ParachainCandidate, ParachainConsensus}; use cumulus_primitives_core::relay_chain::{Hash as PHash, PersistedValidationData}; use futures::lock::Mutex; @@ -28,8 +29,6 @@ use sp_consensus_aura::{sr25519::AuthorityId as AuraId, AuraApi}; use sp_runtime::traits::Header as HeaderT; use std::sync::Arc; -use crate::primitives::*; - pub enum BuildOnAccess { Uninitialized(Option R + Send + Sync>>), Initialized(R), diff --git a/bin/collator/src/primitives.rs b/bin/collator/src/primitives.rs deleted file mode 100644 index 6779805a1e..0000000000 --- a/bin/collator/src/primitives.rs +++ /dev/null @@ -1,40 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Astar is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Astar. If not, see . - -//! Astar opaque primitives for different runtimes. - -/// An index to a block. -pub type BlockNumber = u32; - -/// Header type. -pub type Header = sp_runtime::generic::Header; - -/// Block type. -pub type Block = sp_runtime::generic::Block; - -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; - -/// Balance of an account. -pub type Balance = u128; - -/// Index of a transaction in the chain. -pub type Nonce = u32; - -/// Some way of identifying an account on the chain. -pub type AccountId = sp_runtime::AccountId32; diff --git a/bin/collator/src/rpc.rs b/bin/collator/src/rpc.rs index 6b7b302096..0865ea0219 100644 --- a/bin/collator/src/rpc.rs +++ b/bin/collator/src/rpc.rs @@ -47,7 +47,7 @@ use moonbeam_rpc_trace::{Trace, TraceServer}; #[cfg(feature = "evm-tracing")] use moonbeam_rpc_txpool::{TxPool, TxPoolServer}; -use crate::primitives::*; +use astar_primitives::*; #[cfg(feature = "evm-tracing")] pub mod tracing; diff --git a/chain-extensions/dapps-staking/src/lib.rs b/chain-extensions/dapps-staking/src/lib.rs index 4d5149eb4f..44910e3b0d 100644 --- a/chain-extensions/dapps-staking/src/lib.rs +++ b/chain-extensions/dapps-staking/src/lib.rs @@ -17,10 +17,7 @@ // along with Astar. If not, see . #![cfg_attr(not(feature = "std"), no_std)] -use sp_runtime::{ - traits::{Saturating, Zero}, - DispatchError, -}; +use sp_runtime::{traits::Zero, DispatchError}; use dapps_staking_chain_extension_types::{ DSError, DappsStakingAccountInput, DappsStakingEraInput, DappsStakingNominationInput, diff --git a/pallets/block-reward/Cargo.toml b/pallets/block-reward/Cargo.toml index 4520a1afff..9097ecdbf9 100644 --- a/pallets/block-reward/Cargo.toml +++ b/pallets/block-reward/Cargo.toml @@ -12,6 +12,7 @@ repository.workspace = true parity-scale-codec = { workspace = true } serde = { workspace = true } +astar-primitives = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } scale-info = { workspace = true } @@ -38,11 +39,13 @@ std = [ "frame-system/std", "pallet-timestamp/std", "pallet-balances/std", + "astar-primitives/std", ] runtime-benchmarks = [ "frame-benchmarking", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", + "astar-primitives/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/block-reward/src/lib.rs b/pallets/block-reward/src/lib.rs index dee213e114..8626bc65cd 100644 --- a/pallets/block-reward/src/lib.rs +++ b/pallets/block-reward/src/lib.rs @@ -77,6 +77,7 @@ pub use pallet::*; +use astar_primitives::Balance; use frame_support::pallet_prelude::*; use frame_support::{ log, @@ -107,10 +108,6 @@ pub mod pallet { #[pallet::pallet] pub struct Pallet(PhantomData); - /// The balance type of this pallet. - pub(crate) type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; - // Negative imbalance type of this pallet. pub(crate) type NegativeImbalanceOf = <::Currency as Currency< ::AccountId, @@ -119,17 +116,17 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The currency trait. - type Currency: Currency; + type Currency: Currency; /// Provides information about how much value is locked by dapps staking - type DappsStakingTvlProvider: Get>; + type DappsStakingTvlProvider: Get; /// Used to payout rewards type BeneficiaryPayout: BeneficiaryPayout>; /// The amount of issuance for each block. #[pallet::constant] - type RewardAmount: Get>; + type RewardAmount: Get; /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/pallets/block-reward/src/tests.rs b/pallets/block-reward/src/tests.rs index 2669a74a28..956905250c 100644 --- a/pallets/block-reward/src/tests.rs +++ b/pallets/block-reward/src/tests.rs @@ -18,7 +18,7 @@ use super::{pallet::Error, Event, *}; use frame_support::{assert_noop, assert_ok, traits::OnTimestampSet}; -use mock::*; +use mock::{Balance, *}; use sp_runtime::{ traits::{AccountIdConversion, BadOrigin, Zero}, Perbill, diff --git a/pallets/dapps-staking/Cargo.toml b/pallets/dapps-staking/Cargo.toml index 3290455e15..c06c1400bf 100644 --- a/pallets/dapps-staking/Cargo.toml +++ b/pallets/dapps-staking/Cargo.toml @@ -13,6 +13,7 @@ frame-system = { workspace = true } num-traits = { workspace = true } parity-scale-codec = { workspace = true } +astar-primitives = { workspace = true } scale-info = { workspace = true } serde = { workspace = true, optional = true } sp-arithmetic = { workspace = true } @@ -48,11 +49,13 @@ std = [ "pallet-timestamp/std", "sp-staking/std", "frame-benchmarking?/std", + "astar-primitives/std", ] runtime-benchmarks = [ "frame-benchmarking", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", + "astar-primitives/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/dapps-staking/src/benchmarking.rs b/pallets/dapps-staking/src/benchmarking.rs index 3ad2543ea4..aad7705064 100644 --- a/pallets/dapps-staking/src/benchmarking.rs +++ b/pallets/dapps-staking/src/benchmarking.rs @@ -24,7 +24,7 @@ use crate::Pallet as DappsStaking; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_support::traits::{Get, OnFinalize, OnInitialize}; use frame_system::{Pallet as System, RawOrigin}; -use sp_runtime::traits::{Bounded, One, TrailingZeroInput}; +use sp_runtime::traits::{One, TrailingZeroInput}; const SEED: u32 = 9000; const STAKER_BLOCK_REWARD: u32 = 1234u32; @@ -94,7 +94,7 @@ fn register_contract( ) -> Result<(T::AccountId, T::SmartContract), &'static str> { let developer: T::AccountId = account("developer", index.into(), SEED); let smart_contract = smart_contract::(index); - T::Currency::make_free_balance_be(&developer, BalanceOf::::max_value()); + T::Currency::make_free_balance_be(&developer, Balance::max_value()); DappsStaking::::register( RawOrigin::Root.into(), developer.clone(), @@ -119,7 +119,7 @@ fn prepare_bond_and_stake( for id in 0..number_of_stakers { let staker_acc: T::AccountId = account("pre_staker", id, seed); stakers.push(staker_acc.clone()); - T::Currency::make_free_balance_be(&staker_acc, BalanceOf::::max_value()); + T::Currency::make_free_balance_be(&staker_acc, Balance::max_value()); DappsStaking::::bond_and_stake( RawOrigin::Signed(staker_acc).into(), @@ -137,7 +137,7 @@ benchmarks! { initialize::(); let developer_id = whitelisted_caller(); let contract_id = T::SmartContract::default(); - T::Currency::make_free_balance_be(&developer_id, BalanceOf::::max_value()); + T::Currency::make_free_balance_be(&developer_id, Balance::max_value()); }: _(RawOrigin::Root, developer_id.clone(), contract_id.clone()) verify { assert_last_event::(Event::::NewContract(developer_id, contract_id).into()); @@ -158,7 +158,7 @@ benchmarks! { let (developer, contract_id) = register_contract::(1)?; let stakers = prepare_bond_and_stake::(1, &contract_id, SEED)?; let staker = stakers[0].clone(); - let stake_amount = BalanceOf::::max_value() / 2u32.into(); + let stake_amount = Balance::max_value() / 2u128; DappsStaking::::bond_and_stake(RawOrigin::Signed(staker.clone()).into(), contract_id.clone(), stake_amount)?; DappsStaking::::unregister(RawOrigin::Root.into(), contract_id.clone())?; @@ -174,8 +174,8 @@ benchmarks! { let (_, contract_id) = register_contract::(1)?; let staker = whitelisted_caller(); - let _ = T::Currency::make_free_balance_be(&staker, BalanceOf::::max_value()); - let amount = BalanceOf::::max_value() / 2u32.into(); + let _ = T::Currency::make_free_balance_be(&staker, Balance::max_value()); + let amount = Balance::max_value() / 2u128; }: _(RawOrigin::Signed(staker.clone()), contract_id.clone(), amount) verify { @@ -188,8 +188,8 @@ benchmarks! { let (_, contract_id) = register_contract::(1)?; let staker = whitelisted_caller(); - let _ = T::Currency::make_free_balance_be(&staker, BalanceOf::::max_value()); - let amount = BalanceOf::::max_value() / 2u32.into(); + let _ = T::Currency::make_free_balance_be(&staker, Balance::max_value()); + let amount = Balance::max_value() / 2u128; DappsStaking::::bond_and_stake(RawOrigin::Signed(staker.clone()).into(), contract_id.clone(), amount)?; @@ -204,9 +204,9 @@ benchmarks! { let (_, contract_id) = register_contract::(1)?; let staker = whitelisted_caller(); - let _ = T::Currency::make_free_balance_be(&staker, BalanceOf::::max_value()); - let stake_amount = BalanceOf::::max_value() / 2u32.into(); - let unstake_amount = stake_amount / 2u32.into(); + let _ = T::Currency::make_free_balance_be(&staker, Balance::max_value()); + let stake_amount = Balance::max_value() / 2u128; + let unstake_amount = stake_amount / 2u128; DappsStaking::::bond_and_stake(RawOrigin::Signed(staker.clone()).into(), contract_id.clone(), stake_amount)?; DappsStaking::::unbond_and_unstake(RawOrigin::Signed(staker.clone()).into(), contract_id, unstake_amount)?; diff --git a/pallets/dapps-staking/src/lib.rs b/pallets/dapps-staking/src/lib.rs index ec400687f4..1530ba5f24 100644 --- a/pallets/dapps-staking/src/lib.rs +++ b/pallets/dapps-staking/src/lib.rs @@ -66,16 +66,12 @@ //! #![cfg_attr(not(feature = "std"), no_std)] +use astar_primitives::Balance; use frame_support::traits::Currency; -use frame_system::{self as system}; -use parity_scale_codec::{Decode, Encode, HasCompact, MaxEncodedLen}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_runtime::{ - traits::{AtLeast32BitUnsigned, Zero}, - RuntimeDebug, -}; -use sp_std::{ops::Add, prelude::*}; - +use sp_runtime::{traits::Zero, RuntimeDebug}; +use sp_std::prelude::*; pub mod pallet; pub mod weights; @@ -93,9 +89,6 @@ mod tests_lib; pub use pallet::pallet::*; pub use weights::WeightInfo; -pub type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; - /// Counter for the number of eras that have passed. pub type EraIndex = u32; @@ -170,7 +163,7 @@ impl Default for Forcing { /// A record of rewards allocated for stakers and dapps #[derive(PartialEq, Eq, Clone, Default, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct RewardInfo { +pub struct RewardInfo { /// Total amount of rewards for stakers in an era #[codec(compact)] pub stakers: Balance, @@ -181,9 +174,9 @@ pub struct RewardInfo { /// A record for total rewards and total amount staked for an era #[derive(PartialEq, Eq, Clone, Default, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct EraInfo { +pub struct EraInfo { /// Total amount of earned rewards for an era - pub rewards: RewardInfo, + pub rewards: RewardInfo, /// Total staked amount in an era #[codec(compact)] pub staked: Balance, @@ -196,7 +189,7 @@ pub struct EraInfo { /// Each tuple (contract, era) has this structure. /// This will be used to reward contracts developer and his stakers. #[derive(Clone, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct ContractStakeInfo { +pub struct ContractStakeInfo { /// Total staked amount. #[codec(compact)] pub total: Balance, @@ -226,7 +219,7 @@ impl Default for Version { /// Used to represent how much was staked in a particular era. /// E.g. `{staked: 1000, era: 5}` means that in era `5`, staked amount was 1000. #[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct EraStake { +pub struct EraStake { /// Staked amount in era #[codec(compact)] staked: Balance, @@ -235,7 +228,7 @@ pub struct EraStake { era: EraIndex, } -impl EraStake { +impl EraStake { /// Create a new instance of `EraStake` with given values fn new(staked: Balance, era: EraIndex) -> Self { Self { staked, era } @@ -270,24 +263,23 @@ impl EraStake { /// **NOTE:** It is important to understand that staker **DID NOT** claim any rewards during this period. /// #[derive(Encode, Decode, Clone, Default, PartialEq, Eq, RuntimeDebug, TypeInfo)] -pub struct StakerInfo { +pub struct StakerInfo { // Size of this list would be limited by a configurable constant - stakes: Vec>, + stakes: Vec, } -impl MaxEncodedLen for StakerInfo { +impl MaxEncodedLen for StakerInfo { // This is just an assumption, will be calculated properly in the future. See the comment for `MAX_ASSUMED_VEC_LEN`. fn max_encoded_len() -> usize { parity_scale_codec::Compact(MAX_ASSUMED_VEC_LEN) .encoded_size() .saturating_add( - (MAX_ASSUMED_VEC_LEN as usize) - .saturating_mul(EraStake::::max_encoded_len()), + (MAX_ASSUMED_VEC_LEN as usize).saturating_mul(EraStake::max_encoded_len()), ) } } -impl StakerInfo { +impl StakerInfo { /// `true` if no active stakes and unclaimed eras exist, `false` otherwise fn is_empty(&self) -> bool { self.stakes.is_empty() @@ -437,7 +429,7 @@ impl StakerInfo { #[derive( Clone, Copy, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen, )] -pub struct UnlockingChunk { +pub struct UnlockingChunk { /// Amount being unlocked #[codec(compact)] amount: Balance, @@ -446,10 +438,7 @@ pub struct UnlockingChunk { unlock_era: EraIndex, } -impl UnlockingChunk -where - Balance: Add + Copy + MaxEncodedLen, -{ +impl UnlockingChunk { // Adds the specified amount to this chunk fn add_amount(&mut self, amount: Balance) { self.amount = self.amount + amount @@ -459,29 +448,23 @@ where /// Contains unlocking chunks. /// This is a convenience struct that provides various utility methods to help with unbonding handling. #[derive(Clone, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo)] -pub struct UnbondingInfo { +pub struct UnbondingInfo { // Vector of unlocking chunks. Sorted in ascending order in respect to unlock_era. - unlocking_chunks: Vec>, + unlocking_chunks: Vec, } -impl MaxEncodedLen - for UnbondingInfo -{ +impl MaxEncodedLen for UnbondingInfo { // This is just an assumption, will be calculated properly in the future. See the comment for `MAX_ASSUMED_VEC_LEN`. fn max_encoded_len() -> usize { parity_scale_codec::Compact(MAX_ASSUMED_VEC_LEN) .encoded_size() .saturating_add( - (MAX_ASSUMED_VEC_LEN as usize) - .saturating_mul(UnlockingChunk::::max_encoded_len()), + (MAX_ASSUMED_VEC_LEN as usize).saturating_mul(UnlockingChunk::max_encoded_len()), ) } } -impl UnbondingInfo -where - Balance: AtLeast32BitUnsigned + Default + Copy + MaxEncodedLen, -{ +impl UnbondingInfo { /// Returns total number of unlocking chunks. fn len(&self) -> u32 { self.unlocking_chunks.len() as u32 @@ -502,7 +485,7 @@ where } /// Adds a new unlocking chunk to the vector, preserving the unlock_era based ordering. - fn add(&mut self, chunk: UnlockingChunk) { + fn add(&mut self, chunk: UnlockingChunk) { // It is possible that the unbonding period changes so we need to account for that match self .unlocking_chunks @@ -522,10 +505,7 @@ where /// /// Order of chunks is preserved in the two new structs. fn partition(self, era: EraIndex) -> (Self, Self) { - let (matching_chunks, other_chunks): ( - Vec>, - Vec>, - ) = self + let (matching_chunks, other_chunks): (Vec, Vec) = self .unlocking_chunks .iter() .partition(|chunk| chunk.unlock_era <= era); @@ -542,7 +522,7 @@ where #[cfg(test)] /// Return clone of the internal vector. Should only be used for testing. - fn vec(&self) -> Vec> { + fn vec(&self) -> Vec { self.unlocking_chunks.clone() } } @@ -567,17 +547,17 @@ impl Default for RewardDestination { /// Contains information about account's locked & unbonding balances. #[derive(Clone, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct AccountLedger { +pub struct AccountLedger { /// Total balance locked. #[codec(compact)] pub locked: Balance, /// Information about unbonding chunks. - unbonding_info: UnbondingInfo, + unbonding_info: UnbondingInfo, /// Instruction on how to handle reward payout reward_destination: RewardDestination, } -impl AccountLedger { +impl AccountLedger { /// `true` if ledger is empty (no locked funds, no unbonding chunks), `false` otherwise. pub fn is_empty(&self) -> bool { self.locked.is_zero() && self.unbonding_info.is_empty() diff --git a/pallets/dapps-staking/src/pallet/mod.rs b/pallets/dapps-staking/src/pallet/mod.rs index cfd098760e..37e1784593 100644 --- a/pallets/dapps-staking/src/pallet/mod.rs +++ b/pallets/dapps-staking/src/pallet/mod.rs @@ -32,7 +32,7 @@ use frame_support::{ }; use frame_system::{ensure_root, ensure_signed, pallet_prelude::*}; use sp_runtime::{ - traits::{AccountIdConversion, Saturating, Zero}, + traits::{AccountIdConversion, Zero}, Perbill, }; use sp_std::{convert::From, mem}; @@ -44,10 +44,6 @@ const STAKING_ID: LockIdentifier = *b"dapstake"; pub mod pallet { use super::*; - /// The balance type of this pallet. - pub type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; - #[pallet::pallet] #[pallet::generate_store(pub(crate) trait Store)] pub struct Pallet(PhantomData); @@ -60,7 +56,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The staking balance. - type Currency: LockableCurrency + type Currency: Currency + + LockableCurrency + ReservableCurrency; /// Describes smart contract in the context required by dapps staking. @@ -72,7 +69,7 @@ pub mod pallet { /// Deposit that will be reserved as part of new contract registration. #[pallet::constant] - type RegisterDeposit: Get>; + type RegisterDeposit: Get; /// Maximum number of unique stakers per contract. #[pallet::constant] @@ -81,7 +78,7 @@ pub mod pallet { /// Minimum amount user must have staked on contract. /// User can stake less if they already have the minimum staking amount staked on that particular contract. #[pallet::constant] - type MinimumStakingAmount: Get>; + type MinimumStakingAmount: Get; /// Dapps staking pallet Id #[pallet::constant] @@ -90,7 +87,7 @@ pub mod pallet { /// Minimum amount that should be left on staker account after staking. /// Serves as a safeguard to prevent users from locking their entire free balance. #[pallet::constant] - type MinimumRemainingAmount: Get>; + type MinimumRemainingAmount: Get; /// Max number of unlocking chunks per account Id <-> contract Id pairing. /// If value is zero, unlocking becomes impossible. @@ -136,7 +133,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn ledger)] pub type Ledger = - StorageMap<_, Blake2_128Concat, T::AccountId, AccountLedger>, ValueQuery>; + StorageMap<_, Blake2_128Concat, T::AccountId, AccountLedger, ValueQuery>; /// The current era index. #[pallet::storage] @@ -147,7 +144,7 @@ pub mod pallet { /// Accumulator for block rewards during an era. It is reset at every new era #[pallet::storage] #[pallet::getter(fn block_reward_accumulator)] - pub type BlockRewardAccumulator = StorageValue<_, RewardInfo>, ValueQuery>; + pub type BlockRewardAccumulator = StorageValue<_, RewardInfo, ValueQuery>; #[pallet::type_value] pub fn ForceEraOnEmpty() -> Forcing { @@ -181,8 +178,7 @@ pub mod pallet { /// General information about an era like TVL, total staked value, rewards. #[pallet::storage] #[pallet::getter(fn general_era_info)] - pub type GeneralEraInfo = - StorageMap<_, Twox64Concat, EraIndex, EraInfo>>; + pub type GeneralEraInfo = StorageMap<_, Twox64Concat, EraIndex, EraInfo>; /// Staking information about contract in a particular era. #[pallet::storage] @@ -193,7 +189,7 @@ pub mod pallet { T::SmartContract, Twox64Concat, EraIndex, - ContractStakeInfo>, + ContractStakeInfo, >; /// Info about stakers stakes on particular contracts. @@ -205,7 +201,7 @@ pub mod pallet { T::AccountId, Blake2_128Concat, T::SmartContract, - StakerInfo>, + StakerInfo, ValueQuery, >; @@ -218,13 +214,13 @@ pub mod pallet { #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event { /// Account has bonded and staked funds on a smart contract. - BondAndStake(T::AccountId, T::SmartContract, BalanceOf), + BondAndStake(T::AccountId, T::SmartContract, Balance), /// Account has unbonded & unstaked some funds. Unbonding process begins. - UnbondAndUnstake(T::AccountId, T::SmartContract, BalanceOf), + UnbondAndUnstake(T::AccountId, T::SmartContract, Balance), /// Account has fully withdrawn all staked amount from an unregistered contract. - WithdrawFromUnregistered(T::AccountId, T::SmartContract, BalanceOf), + WithdrawFromUnregistered(T::AccountId, T::SmartContract, Balance), /// Account has withdrawn unbonded funds. - Withdrawn(T::AccountId, BalanceOf), + Withdrawn(T::AccountId, Balance), /// New contract added for staking. NewContract(T::AccountId, T::SmartContract), /// Contract removed from dapps staking. @@ -232,7 +228,7 @@ pub mod pallet { /// New dapps staking era. Distribute era rewards to contracts. NewDappStakingEra(EraIndex), /// Reward paid to staker or developer. - Reward(T::AccountId, T::SmartContract, EraIndex, BalanceOf), + Reward(T::AccountId, T::SmartContract, EraIndex, Balance), /// Maintenance mode has been enabled or disabled MaintenanceMode(bool), /// Reward handling modified @@ -240,16 +236,11 @@ pub mod pallet { /// Nomination part has been transfered from one contract to another. /// /// \(staker account, origin smart contract, amount, target smart contract\) - NominationTransfer( - T::AccountId, - T::SmartContract, - BalanceOf, - T::SmartContract, - ), + NominationTransfer(T::AccountId, T::SmartContract, Balance, T::SmartContract), /// Stale, unclaimed reward from an unregistered contract has been burned. /// /// \(developer account, smart contract, era, amount burned\) - StaleRewardBurned(T::AccountId, T::SmartContract, EraIndex, BalanceOf), + StaleRewardBurned(T::AccountId, T::SmartContract, EraIndex, Balance), } #[pallet::error] @@ -485,7 +476,7 @@ pub mod pallet { pub fn bond_and_stake( origin: OriginFor, contract_id: T::SmartContract, - #[pallet::compact] value: BalanceOf, + #[pallet::compact] value: Balance, ) -> DispatchResultWithPostInfo { Self::ensure_pallet_enabled()?; let staker = ensure_signed(origin)?; @@ -552,7 +543,7 @@ pub mod pallet { pub fn unbond_and_unstake( origin: OriginFor, contract_id: T::SmartContract, - #[pallet::compact] value: BalanceOf, + #[pallet::compact] value: Balance, ) -> DispatchResultWithPostInfo { Self::ensure_pallet_enabled()?; let staker = ensure_signed(origin)?; @@ -652,7 +643,7 @@ pub mod pallet { pub fn nomination_transfer( origin: OriginFor, origin_contract_id: T::SmartContract, - #[pallet::compact] value: BalanceOf, + #[pallet::compact] value: Balance, target_contract_id: T::SmartContract, ) -> DispatchResultWithPostInfo { Self::ensure_pallet_enabled()?; @@ -934,7 +925,7 @@ pub mod pallet { origin: OriginFor, contract: T::SmartContract, era: EraIndex, - contract_stake_info: ContractStakeInfo>, + contract_stake_info: ContractStakeInfo, ) -> DispatchResultWithPostInfo { ensure_root(origin)?; @@ -1001,10 +992,10 @@ pub mod pallet { /// If successfull, returns reward amount. /// In case reward cannot be claimed or was already claimed, an error is raised. fn calculate_dapp_reward( - contract_stake_info: &ContractStakeInfo>, + contract_stake_info: &ContractStakeInfo, dapp_info: &DAppInfo, era: EraIndex, - ) -> Result, Error> { + ) -> Result> { let current_era = Self::current_era(); if let DAppState::Unregistered(unregister_era) = dapp_info.state { ensure!(era < unregister_era, Error::::NotOperatedContract); @@ -1047,9 +1038,9 @@ pub mod pallet { /// If not, an error is returned and structs are left in an undefined state. /// fn stake_on_contract( - staker_info: &mut StakerInfo>, - staking_info: &mut ContractStakeInfo>, - value: BalanceOf, + staker_info: &mut StakerInfo, + staking_info: &mut ContractStakeInfo, + value: Balance, current_era: EraIndex, ) -> Result<(), Error> { ensure!( @@ -1101,11 +1092,11 @@ pub mod pallet { /// If not, an error is returned and structs are left in an undefined state. /// fn unstake_from_contract( - staker_info: &mut StakerInfo>, - contract_stake_info: &mut ContractStakeInfo>, - value: BalanceOf, + staker_info: &mut StakerInfo, + contract_stake_info: &mut ContractStakeInfo, + value: Balance, current_era: EraIndex, - ) -> Result, Error> { + ) -> Result> { let staked_value = staker_info.latest_staked_value(); ensure!(staked_value > Zero::zero(), Error::::NotStakedContract); @@ -1154,7 +1145,7 @@ pub mod pallet { /// Update the ledger for a staker. This will also update the stash lock. /// This lock will lock the entire funds except paying for further transactions. - fn update_ledger(staker: &T::AccountId, ledger: AccountLedger>) { + fn update_ledger(staker: &T::AccountId, ledger: AccountLedger) { if ledger.is_empty() { Ledger::::remove(&staker); T::Currency::remove_lock(STAKING_ID, staker); @@ -1169,7 +1160,7 @@ pub mod pallet { fn update_staker_info( staker: &T::AccountId, contract_id: &T::SmartContract, - staker_info: StakerInfo>, + staker_info: StakerInfo, ) { if staker_info.is_empty() { GeneralStakerInfo::::remove(staker, contract_id) @@ -1183,7 +1174,7 @@ pub mod pallet { /// and stores it for future distribution /// /// This is called just at the beginning of an era. - fn reward_balance_snapshot(era: EraIndex, rewards: RewardInfo>) { + fn reward_balance_snapshot(era: EraIndex, rewards: RewardInfo) { // Get the reward and stake information for previous era let mut era_info = Self::general_era_info(era).unwrap_or_default(); @@ -1236,10 +1227,7 @@ pub mod pallet { } /// Returns available staking balance for the potential staker - fn available_staking_balance( - staker: &T::AccountId, - ledger: &AccountLedger>, - ) -> BalanceOf { + fn available_staking_balance(staker: &T::AccountId, ledger: &AccountLedger) -> Balance { // Ensure that staker has enough balance to bond & stake. let free_balance = T::Currency::free_balance(staker).saturating_sub(T::MinimumRemainingAmount::get()); @@ -1258,7 +1246,7 @@ pub mod pallet { pub(crate) fn should_restake_reward( reward_destination: RewardDestination, dapp_state: DAppState, - latest_staked_value: BalanceOf, + latest_staked_value: Balance, ) -> bool { reward_destination == RewardDestination::StakeBalance && dapp_state == DAppState::Registered @@ -1269,9 +1257,9 @@ pub mod pallet { /// /// Returns (developer reward, joint stakers reward) pub(crate) fn dev_stakers_split( - contract_info: &ContractStakeInfo>, - era_info: &EraInfo>, - ) -> (BalanceOf, BalanceOf) { + contract_info: &ContractStakeInfo, + era_info: &EraInfo, + ) -> (Balance, Balance) { let contract_stake_portion = Perbill::from_rational(contract_info.total, era_info.staked); @@ -1298,7 +1286,7 @@ pub mod pallet { /// Returns total value locked by dapps-staking. /// /// Note that this can differ from _total staked value_ since some funds might be undergoing the unbonding period. - pub fn tvl() -> BalanceOf { + pub fn tvl() -> Balance { let current_era = Self::current_era(); if let Some(era_info) = Self::general_era_info(current_era) { era_info.locked diff --git a/pallets/dapps-staking/src/testing_utils.rs b/pallets/dapps-staking/src/testing_utils.rs index 1bf028ddc4..368ffdddcd 100644 --- a/pallets/dapps-staking/src/testing_utils.rs +++ b/pallets/dapps-staking/src/testing_utils.rs @@ -18,17 +18,17 @@ use super::{pallet::pallet::Event, *}; use frame_support::assert_ok; -use mock::{EraIndex, *}; +use mock::{Balance, EraIndex, *}; use sp_runtime::{traits::AccountIdConversion, Perbill}; /// Helper struct used to store information relevant to era/contract/staker combination. pub(crate) struct MemorySnapshot { - era_info: EraInfo, + era_info: EraInfo, dapp_info: DAppInfo, - staker_info: StakerInfo, - contract_info: ContractStakeInfo, + staker_info: StakerInfo, + contract_info: ContractStakeInfo, free_balance: Balance, - ledger: AccountLedger, + ledger: AccountLedger, } impl MemorySnapshot { diff --git a/pallets/dapps-staking/src/tests.rs b/pallets/dapps-staking/src/tests.rs index 13a3e69d5c..23ca758304 100644 --- a/pallets/dapps-staking/src/tests.rs +++ b/pallets/dapps-staking/src/tests.rs @@ -18,7 +18,7 @@ use super::{pallet::pallet::Error, pallet::pallet::Event, *}; use frame_support::{assert_noop, assert_ok, traits::OnInitialize, weights::Weight}; -use mock::{Balances, MockSmartContract, *}; +use mock::{Balance, Balances, MockSmartContract, *}; use sp_core::H160; use sp_runtime::{ traits::{BadOrigin, Zero}, @@ -2092,12 +2092,12 @@ fn dev_stakers_split_util() { let total_staked = staked_on_contract * 3; // Prepare structs - let staking_points = ContractStakeInfo:: { + let staking_points = ContractStakeInfo { total: staked_on_contract, number_of_stakers: 10, contract_reward_claimed: false, }; - let era_info = EraInfo:: { + let era_info = EraInfo { rewards: RewardInfo { dapps: base_dapps_reward, stakers: base_stakers_reward, @@ -2197,15 +2197,12 @@ pub fn set_contract_stake_info() { fn custom_max_encoded_len() { let max_unbonding_info_len = 10 * (4 + 16) + 1; assert_eq!( - UnbondingInfo::::max_encoded_len(), + UnbondingInfo::max_encoded_len(), max_unbonding_info_len as usize ); let max_staker_info_len = 10 * (4 + 16) + 1; - assert_eq!( - StakerInfo::::max_encoded_len(), - max_staker_info_len as usize - ); + assert_eq!(StakerInfo::max_encoded_len(), max_staker_info_len as usize); } #[test] diff --git a/pallets/dapps-staking/src/tests_lib.rs b/pallets/dapps-staking/src/tests_lib.rs index dfe0e8809b..142f55e44d 100644 --- a/pallets/dapps-staking/src/tests_lib.rs +++ b/pallets/dapps-staking/src/tests_lib.rs @@ -22,7 +22,7 @@ use mock::Balance; #[test] fn unbonding_info_test() { - let mut unbonding_info = UnbondingInfo::::default(); + let mut unbonding_info = UnbondingInfo::default(); // assert basic ops on empty info assert!(unbonding_info.is_empty()); @@ -77,7 +77,7 @@ fn unbonding_info_test() { #[test] fn staker_info_basic() { - let staker_info = StakerInfo::::default(); + let staker_info = StakerInfo::default(); assert!(staker_info.is_empty()); assert_eq!(staker_info.len(), 0); @@ -86,7 +86,7 @@ fn staker_info_basic() { #[test] fn staker_info_stake_ops() { - let mut staker_info = StakerInfo::::default(); + let mut staker_info = StakerInfo::default(); // Do first stake and verify it let first_era = 1; @@ -129,7 +129,7 @@ fn staker_info_stake_ops() { #[test] fn staker_info_stake_error() { - let mut staker_info = StakerInfo::::default(); + let mut staker_info = StakerInfo::default(); assert_ok!(staker_info.stake(5, 100)); if let Err(_) = staker_info.stake(4, 100) { } else { @@ -139,7 +139,7 @@ fn staker_info_stake_error() { #[test] fn staker_info_unstake_ops() { - let mut staker_info = StakerInfo::::default(); + let mut staker_info = StakerInfo::default(); // Unstake on empty staker_info assert!(staker_info.is_empty()); @@ -192,7 +192,7 @@ fn staker_info_unstake_ops() { #[test] fn stake_after_full_unstake() { - let mut staker_info = StakerInfo::::default(); + let mut staker_info = StakerInfo::default(); // Stake some amount let first_era = 1; @@ -216,7 +216,7 @@ fn stake_after_full_unstake() { #[test] fn staker_info_unstake_error() { - let mut staker_info = StakerInfo::::default(); + let mut staker_info = StakerInfo::default(); assert_ok!(staker_info.stake(5, 100)); if let Err(_) = staker_info.unstake(4, 100) { } else { @@ -226,7 +226,7 @@ fn staker_info_unstake_error() { #[test] fn staker_info_claim_ops_basic() { - let mut staker_info = StakerInfo::::default(); + let mut staker_info = StakerInfo::default(); // Empty staker info assert!(staker_info.is_empty()); @@ -241,7 +241,7 @@ fn staker_info_claim_ops_basic() { assert!(staker_info.is_empty()); // Only one staked exists - staker_info = StakerInfo::::default(); + staker_info = StakerInfo::default(); let stake_era = 1; let stake_value = 123; assert_ok!(staker_info.stake(stake_era, stake_value)); @@ -252,7 +252,7 @@ fn staker_info_claim_ops_basic() { #[test] fn staker_info_claim_ops_advanced() { - let mut staker_info = StakerInfo::::default(); + let mut staker_info = StakerInfo::default(); // Two consecutive eras staked, third era contains a gap with the second one let (first_stake_era, second_stake_era, third_stake_era) = (1, 2, 4); diff --git a/precompiles/dapps-staking/src/lib.rs b/precompiles/dapps-staking/src/lib.rs index e67fc77762..55cc8e39c7 100644 --- a/precompiles/dapps-staking/src/lib.rs +++ b/precompiles/dapps-staking/src/lib.rs @@ -35,7 +35,7 @@ use precompile_utils::{ PrecompileHandleExt, RuntimeHelper, }; use sp_core::H160; -use sp_runtime::traits::{Saturating, Zero}; +use sp_runtime::traits::Zero; use sp_std::marker::PhantomData; use sp_std::prelude::*; extern crate alloc; diff --git a/primitives/xcm/Cargo.toml b/primitives/Cargo.toml similarity index 88% rename from primitives/xcm/Cargo.toml rename to primitives/Cargo.toml index 1d2f20dadf..cf498aa57d 100644 --- a/primitives/xcm/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,19 +1,18 @@ [package] -name = "xcm-primitives" -version = "0.4.1" -description = "Common XCM primitives used by runtimes" +name = "astar-primitives" +version = "0.1.0" authors.workspace = true edition.workspace = true homepage.workspace = true repository.workspace = true [dependencies] - # third-party dependencies log = { workspace = true } # Substrate dependencies frame-support = { workspace = true } +sp-core = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } @@ -32,6 +31,7 @@ std = [ "frame-support/std", "sp-std/std", "sp-runtime/std", + "sp-core/std", "xcm/std", "xcm-builder/std", "xcm-executor/std", diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs new file mode 100644 index 0000000000..9790cb769f --- /dev/null +++ b/primitives/src/lib.rs @@ -0,0 +1,61 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] + +//! Core Astar types. +//! +//! These core Astar types are used by the Shiden, Shibuya, Astar and Local runtime. +pub mod xcm; + +use sp_runtime::traits::BlakeTwo256; +use sp_runtime::{ + generic, + traits::{IdentifyAccount, Verify}, +}; + +/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. +pub type Signature = sp_runtime::MultiSignature; +/// Some way of identifying an account on the chain. We intentionally make it equivalent +/// to the public key of our transaction signing scheme. +pub type AccountId = <::Signer as IdentifyAccount>::AccountId; +/// The address format for describing accounts. +pub type Address = sp_runtime::MultiAddress; + +/// Block header type as expected by this runtime. +pub type Header = generic::Header; +/// Balance of an account. +pub type Balance = u128; +/// An index to a block. +pub type BlockNumber = u32; +/// A hash of some data used by the chain. +pub type Hash = sp_core::H256; +/// Id used for identifying assets. +/// +/// AssetId allocation: +/// [1; 2^32-1] Custom user assets (permissionless) +/// [2^32; 2^64-1] Statemine assets (simple map) +/// [2^64; 2^128-1] Ecosystem assets +/// 2^128-1 Relay chain token (KSM) +pub type AssetId = u128; +/// Index of a transaction in the chain. +pub type Index = u32; +/// Block type. +pub type Block = sp_runtime::generic::Block; +/// Index of a transaction in the chain. +pub type Nonce = u32; diff --git a/primitives/xcm/src/lib.rs b/primitives/src/xcm/mod.rs similarity index 100% rename from primitives/xcm/src/lib.rs rename to primitives/src/xcm/mod.rs diff --git a/primitives/xcm/src/tests.rs b/primitives/src/xcm/tests.rs similarity index 100% rename from primitives/xcm/src/tests.rs rename to primitives/src/xcm/tests.rs diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index 67f6959eb6..e59bb39286 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -94,6 +94,7 @@ pallet-collective = { workspace = true, optional = true } frame-try-runtime = { workspace = true, optional = true } # Astar pallets +astar-primitives = { workspace = true } pallet-block-reward = { workspace = true } pallet-collator-selection = { workspace = true } pallet-custom-signatures = { workspace = true } @@ -105,7 +106,6 @@ pallet-evm-precompile-substrate-ecdsa = { workspace = true } pallet-evm-precompile-xcm = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } -xcm-primitives = { workspace = true } # Moonbeam tracing moonbeam-evm-tracer = { workspace = true, optional = true } @@ -198,8 +198,8 @@ std = [ "xcm-builder/std", "xcm-executor/std", "pallet-xc-asset-config/std", - "xcm-primitives/std", "substrate-wasm-builder", + "astar-primitives/std", ] runtime-benchmarks = [ 'frame-benchmarking', @@ -219,6 +219,7 @@ runtime-benchmarks = [ "pallet-xc-asset-config/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "polkadot-runtime/runtime-benchmarks", + "astar-primitives/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 4751efa2d1..45ea0a597c 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -22,6 +22,10 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] +pub use astar_primitives::{ + AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, +}; +use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use frame_support::{ construct_runtime, dispatch::DispatchClass, @@ -67,10 +71,8 @@ use sp_runtime::{ }; use sp_std::prelude::*; -use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; - +use astar_primitives::xcm::AssetLocationIdConverter; use pallet_evm_precompile_assets_erc20::AddressToAssetId; -use xcm_primitives::AssetLocationIdConverter; #[cfg(any(feature = "std", test))] use sp_version::NativeVersion; @@ -529,15 +531,6 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; } -/// Id used for identifying assets. -/// -/// AssetId allocation: -/// [1; 2^32-1] Custom user assets (permissionless) -/// [2^32; 2^64-1] Statemine assets (simple map) -/// [2^64; 2^128-1] Ecosystem assets -/// 2^128-1 Relay chain token (KSM) -pub type AssetId = u128; - impl AddressToAssetId for Runtime { fn address_to_asset_id(address: H160) -> Option { let mut data = [0u8; 16]; @@ -1061,23 +1054,6 @@ construct_runtime!( } ); -/// Balance of an account. -pub type Balance = u128; -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = sp_runtime::MultiSignature; -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as sp_runtime::traits::IdentifyAccount>::AccountId; -/// Index of a transaction in the chain. -pub type Index = u32; -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; -/// An index to a block. -pub type BlockNumber = u32; -/// The address format for describing accounts. -pub type Address = sp_runtime::MultiAddress; -/// Block header type as expected by this runtime. -pub type Header = generic::Header; /// Block type as expected by this runtime. pub type Block = generic::Block; /// A Block signed with a Justification diff --git a/runtime/astar/src/xcm_config.rs b/runtime/astar/src/xcm_config.rs index f90b2d8482..616aaac796 100644 --- a/runtime/astar/src/xcm_config.rs +++ b/runtime/astar/src/xcm_config.rs @@ -45,7 +45,7 @@ use xcm_executor::{ }; // Astar imports -use xcm_primitives::{FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler}; +use astar_primitives::xcm::{FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler}; parameter_types! { pub RelayNetwork: Option = Some(NetworkId::Polkadot); diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index f3af11fe75..80d7f69423 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -62,6 +62,7 @@ frame-system-rpc-runtime-api = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } # Astar pallets +astar-primitives = { workspace = true } pallet-block-reward = { workspace = true } pallet-chain-extension-dapps-staking = { workspace = true } pallet-chain-extension-xvm = { workspace = true } @@ -160,6 +161,7 @@ std = [ "moonbeam-rpc-primitives-txpool/std", "substrate-wasm-builder", "pallet-chain-extension-assets/std", + "astar-primitives/std", ] runtime-benchmarks = [ "frame-benchmarking", @@ -174,6 +176,7 @@ runtime-benchmarks = [ "pallet-ethereum/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", + "astar-primitives/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index c75822be41..e15240fb1f 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -52,16 +52,19 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, - DispatchInfoOf, Dispatchable, IdentifyAccount, NumberFor, PostDispatchInfoOf, - UniqueSaturatedInto, Verify, + DispatchInfoOf, Dispatchable, NumberFor, PostDispatchInfoOf, UniqueSaturatedInto, Verify, }, transaction_validity::{ TransactionPriority, TransactionSource, TransactionValidity, TransactionValidityError, }, - ApplyExtrinsicResult, MultiSignature, RuntimeDebug, + ApplyExtrinsicResult, RuntimeDebug, }; use sp_std::prelude::*; +pub use astar_primitives::{ + AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, +}; + #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -138,8 +141,6 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; -pub type AssetId = u128; - impl AddressToAssetId for Runtime { fn address_to_asset_id(address: H160) -> Option { let mut data = [0u8; 16]; @@ -996,23 +997,6 @@ construct_runtime!( } ); -/// Balance of an account. -pub type Balance = u128; -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as IdentifyAccount>::AccountId; -/// Index of a transaction in the chain. -pub type Index = u32; -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; -/// An index to a block. -pub type BlockNumber = u32; -/// The address format for describing accounts. -pub type Address = sp_runtime::MultiAddress; -/// Block header type as expected by this runtime. -pub type Header = generic::Header; /// Block type as expected by this runtime. pub type Block = generic::Block; /// A Block signed with a Justification diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 3db337e0c7..14549c09a5 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -97,6 +97,7 @@ orml-xcm-support = { workspace = true } orml-xtokens = { workspace = true } # Astar pallets +astar-primitives = { workspace = true } pallet-block-reward = { workspace = true } pallet-chain-extension-dapps-staking = { workspace = true } pallet-chain-extension-xvm = { workspace = true } @@ -112,7 +113,6 @@ pallet-evm-precompile-xvm = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } pallet-xvm = { workspace = true, features = ["evm", "wasm"] } -xcm-primitives = { workspace = true } # Moonbeam tracing moonbeam-evm-tracer = { workspace = true, optional = true } @@ -228,12 +228,12 @@ std = [ "xcm/std", "xcm-builder/std", "xcm-executor/std", - "xcm-primitives/std", "substrate-wasm-builder", "pallet-chain-extension-assets/std", "orml-xtokens/std", "orml-traits/std", "orml-xcm-support/std", + "astar-primitives/std", ] runtime-benchmarks = [ "frame-benchmarking", @@ -254,6 +254,7 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "polkadot-runtime/runtime-benchmarks", "orml-xtokens/runtime-benchmarks", + "astar-primitives/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index c82cd4373b..590e2d3be5 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -67,8 +67,12 @@ use sp_runtime::{ }; use sp_std::prelude::*; +pub use astar_primitives::{ + AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, +}; + +use astar_primitives::xcm::AssetLocationIdConverter; use pallet_evm_precompile_assets_erc20::AddressToAssetId; -use xcm_primitives::AssetLocationIdConverter; #[cfg(any(feature = "std", test))] use sp_version::NativeVersion; @@ -120,15 +124,6 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; -/// Id used for identifying assets. -/// -/// AssetId allocation: -/// [1; 2^32-1] Custom user assets (permissionless) -/// [2^32; 2^64-1] Statemine assets (simple map) -/// [2^64; 2^128-1] Ecosystem assets -/// 2^128-1 Relay chain token (KSM) -pub type AssetId = u128; - impl AddressToAssetId for Runtime { fn address_to_asset_id(address: H160) -> Option { let mut data = [0u8; 16]; @@ -1294,23 +1289,6 @@ construct_runtime!( } ); -/// Balance of an account. -pub type Balance = u128; -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = sp_runtime::MultiSignature; -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as sp_runtime::traits::IdentifyAccount>::AccountId; -/// Index of a transaction in the chain. -pub type Index = u32; -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; -/// An index to a block. -pub type BlockNumber = u32; -/// The address format for describing accounts. -pub type Address = sp_runtime::MultiAddress; -/// Block header type as expected by this runtime. -pub type Header = generic::Header; /// Block type as expected by this runtime. pub type Block = generic::Block; /// A Block signed with a Justification diff --git a/runtime/shibuya/src/xcm_config.rs b/runtime/shibuya/src/xcm_config.rs index 3ae06f56eb..efb107360c 100644 --- a/runtime/shibuya/src/xcm_config.rs +++ b/runtime/shibuya/src/xcm_config.rs @@ -51,7 +51,7 @@ use orml_traits::location::{RelativeReserveProvider, Reserve}; use orml_xcm_support::DisabledParachainFee; // Astar imports -use xcm_primitives::{FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler}; +use astar_primitives::xcm::{FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler}; parameter_types! { pub RelayNetwork: Option = Some(NetworkId::Rococo); diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 0b986ae733..845677f8ab 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -101,6 +101,7 @@ pallet-collective = { workspace = true, optional = true } frame-try-runtime = { workspace = true, optional = true } # Astar pallets +astar-primitives = { workspace = true } pallet-block-reward = { workspace = true } pallet-collator-selection = { workspace = true } pallet-custom-signatures = { workspace = true } @@ -112,7 +113,6 @@ pallet-evm-precompile-substrate-ecdsa = { workspace = true } pallet-evm-precompile-xcm = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } -xcm-primitives = { workspace = true } # Moonbeam tracing moonbeam-evm-tracer = { workspace = true, optional = true } @@ -207,11 +207,11 @@ std = [ "xcm-builder/std", "xcm-executor/std", "pallet-xc-asset-config/std", - "xcm-primitives/std", "substrate-wasm-builder", "orml-xtokens/std", "orml-traits/std", "orml-xcm-support/std", + "astar-primitives/std", ] runtime-benchmarks = [ "frame-benchmarking", @@ -230,6 +230,7 @@ runtime-benchmarks = [ "pallet-xc-asset-config/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "polkadot-runtime/runtime-benchmarks", + "astar-primitives/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index cd5800a6f7..9cab9df0f6 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -67,8 +67,12 @@ use sp_runtime::{ }; use sp_std::prelude::*; +pub use astar_primitives::{ + AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, +}; + +use astar_primitives::xcm::AssetLocationIdConverter; use pallet_evm_precompile_assets_erc20::AddressToAssetId; -use xcm_primitives::AssetLocationIdConverter; #[cfg(any(feature = "std", test))] use sp_version::NativeVersion; @@ -530,15 +534,6 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; } -/// Id used for identifying assets. -/// -/// AssetId allocation: -/// [1; 2^32-1] Custom user assets (permissionless) -/// [2^32; 2^64-1] Statemine assets (simple map) -/// [2^64; 2^128-1] Ecosystem assets -/// 2^128-1 Relay chain token (KSM) -pub type AssetId = u128; - impl AddressToAssetId for Runtime { fn address_to_asset_id(address: H160) -> Option { let mut data = [0u8; 16]; @@ -1050,23 +1045,6 @@ construct_runtime!( } ); -/// Balance of an account. -pub type Balance = u128; -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = sp_runtime::MultiSignature; -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as sp_runtime::traits::IdentifyAccount>::AccountId; -/// Index of a transaction in the chain. -pub type Index = u32; -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; -/// An index to a block. -pub type BlockNumber = u32; -/// The address format for describing accounts. -pub type Address = sp_runtime::MultiAddress; -/// Block header type as expected by this runtime. -pub type Header = generic::Header; /// Block type as expected by this runtime. pub type Block = generic::Block; /// A Block signed with a Justification diff --git a/runtime/shiden/src/xcm_config.rs b/runtime/shiden/src/xcm_config.rs index 1025b50d0c..1f21f75716 100644 --- a/runtime/shiden/src/xcm_config.rs +++ b/runtime/shiden/src/xcm_config.rs @@ -51,7 +51,7 @@ use orml_traits::location::{RelativeReserveProvider, Reserve}; use orml_xcm_support::DisabledParachainFee; // Astar imports -use xcm_primitives::{FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler}; +use astar_primitives::xcm::{FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler}; parameter_types! { pub RelayNetwork: Option = Some(NetworkId::Kusama); diff --git a/tests/xcm-simulator/Cargo.toml b/tests/xcm-simulator/Cargo.toml index bca9358688..61aad4a6f7 100644 --- a/tests/xcm-simulator/Cargo.toml +++ b/tests/xcm-simulator/Cargo.toml @@ -31,9 +31,9 @@ sp-std = { workspace = true } sp-tracing = { workspace = true } # Custom Astar inclusions +astar-primitives = { workspace = true } pallet-dapps-staking = { workspace = true } pallet-xc-asset-config = { workspace = true } -xcm-primitives = { workspace = true } # polkadot deps polkadot-primitives = { workspace = true } @@ -73,7 +73,6 @@ std = [ "pallet-xcm/std", "cumulus-pallet-xcm/std", "pallet-assets/std", - "xcm-primitives/std", "polkadot-primitives/std", "pallet-dapps-staking/std", "pallet-proxy/std", @@ -93,4 +92,5 @@ runtime-benchmarks = [ "xcm-executor/runtime-benchmarks", "polkadot-runtime-parachains/runtime-benchmarks", "polkadot-parachain/runtime-benchmarks", + "astar-primitives/runtime-benchmarks", ] diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 2ab1f7eb81..8e68c9c1c0 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -65,7 +65,7 @@ use xcm_executor::{ XcmExecutor, }; -use xcm_primitives::{ +use astar_primitives::xcm::{ AssetLocationIdConverter, FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler, };