diff --git a/Cargo.toml b/Cargo.toml index 5e20a6b..9a7e3c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,74 +1,43 @@ -[package] -name = "pallet-move" -version = "0.1.0" -authors = ["Eiger "] +[workspace] +members = [ + "pallet", + "rpc", +] +resolver = "2" + +[workspace.package] edition = "2021" +authors = ["Eiger "] readme = "README.md" - repository = "https://github.com/eigerco/substrate-movevm-pallet" -description = "MoveVM support pallet" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] -[dependencies] +[workspace.dependencies] +# crates.io anyhow = { version = "1.0", default-features = false } bcs = { git = "https://github.com/eigerco/bcs.git", default-features = false, branch = "master" } blake2 = { version = "0.10", default-features = false } codec = { package = "parity-scale-codec", version = "3.6", default-features = false, features = ["derive"] } hashbrown = { version = "0.14" } -frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } -frame-support = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } -frame-system = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } +hex = { version = "0.4", default-features = false } +jsonrpsee = { version = "0.16", features = ["server", "macros"] } +rand = { version = "0.8", default-features = false } scale-info = { version = "2.10", default-features = false, features = ["derive"] } serde = { version = "1.0", default-features = false, features = ["derive"] } -sp-core = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } -sp-std = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } - -# MoveVM dependencies -move-core-types = { default-features = false, git = "https://github.com/eigerco/substrate-move.git", branch = "main", features = ["address32"] } - -# MoveVM backend dependency -move-vm-backend = { default-features = false, git = "https://github.com/eigerco/substrate-move.git", branch = "main" } -move-vm-backend-common = { default-features = false, git = "https://github.com/eigerco/substrate-move.git", branch = "main" } - -[dev-dependencies] -hex = "0.4" -rand = "0.8" -move-stdlib = { git = "https://github.com/eigerco/substrate-move.git", features = ["stdlib-bytecode"] } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } -pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } - -[features] -default = ["std"] -std = [ - "anyhow/std", - "blake2/std", - "codec/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "scale-info/std", - "serde/std", - "sp-std/std", - "move-core-types/std", - "move-vm-backend/std", -] -runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", -] -try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", - "sp-runtime/try-runtime", -] -# Builds move projects for test purposes. -# -# The move projects in `tests/assets/move-projects/` are not built by default without this flag -# since rebuilding those tests takes lots of time. -build-move-projects-for-test = [] +# Polkadot crates +frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } +sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } +sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } +sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } +sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } + +# Eiger crates +move-core-types = { git = "https://github.com/eigerco/substrate-move.git", branch = "main", features = ["address32"], default-features = false } +move-stdlib = { git = "https://github.com/eigerco/substrate-move.git", features = ["stdlib-bytecode"], default-features = false } +move-vm-backend = { git = "https://github.com/eigerco/substrate-move.git", branch = "main", default-features = false } +move-vm-backend-common = { git = "https://github.com/eigerco/substrate-move.git", branch = "main", default-features = false } diff --git a/doc/design.md b/doc/design.md index 4118733..6367668 100644 --- a/doc/design.md +++ b/doc/design.md @@ -231,9 +231,8 @@ In order to keep things separated and easy to maintain, we propose to create a s The package and repository structure will look like this: - [`pallet-move`][pallet-move] - contains the pallet codebase, tests, and documentation. - - `pallet-move` - the main pallet crate. - - `pallet-move-rpc` - the RPC MoveVM pallet crate - placed under `src/rpc` directory. It contains the RPC codebase, tests, and documentation. - - `pallet-move-runtime-api` - the runtime API MoveVM pallet crate - placed under `src/rpc/runtime-api` directory. + - `pallet-move` - the main pallet crate with the runtime-api - placed under `pallet`. + - `pallet-move-rpc` - the RPC MoveVM pallet crate - placed under `rpc` directory. It contains the RPC codebase, tests, and documentation. - [`substrate-move`][substrate-move] - Move language fork. Contains all the Move crates and the toolchain. - [`substrate-node-template-move-vm-test`][substrate-node-template-move-vm-test] - testing node repository - contains the node codebase, tests, and documentation. Work is done in the `pallet-move` branch. - [`bcs`][bcs] - Rust implementation of the Binary Canonical Serialization (BCS) format - a crate which is used by some Move crates. diff --git a/pallet/Cargo.toml b/pallet/Cargo.toml new file mode 100644 index 0000000..ffd0a17 --- /dev/null +++ b/pallet/Cargo.toml @@ -0,0 +1,70 @@ +[package] +name = "pallet-move" +version = "0.1.0" +description = "MoveVM support pallet" +authors = { workspace = true } +edition = { workspace = true } +readme = { workspace = true } +repository = { workspace = true } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +anyhow = { workspace = true } +bcs = { workspace = true } +blake2 = { workspace = true } +codec = { workspace = true } +hashbrown = { workspace = true } +frame-benchmarking = { workspace = true, optional = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +move-core-types = { workspace = true } +move-vm-backend = { workspace = true } +move-vm-backend-common = { workspace = true } +scale-info = { workspace = true } +serde = { workspace = true } +sp-api = { workspace = true } +sp-core = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } + +[dev-dependencies] +hex = { workspace = true } +rand = { workspace = true } +move-stdlib = { workspace = true } +sp-io = { workspace = true } +pallet-balances = { workspace = true, default-features = true } + +[features] +default = ["std"] +std = [ + "anyhow/std", + "blake2/std", + "codec/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "scale-info/std", + "serde/std", + "sp-std/std", + "move-core-types/std", + "move-vm-backend/std", +] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime", +] + +# Builds move projects for test purposes. +# +# The move projects in `tests/assets/move-projects/` are not built by default without this flag +# since rebuilding those tests takes lots of time. +build-move-projects-for-test = [] diff --git a/build.rs b/pallet/build.rs similarity index 100% rename from build.rs rename to pallet/build.rs diff --git a/rpc/runtime-api/src/lib.rs b/pallet/src/api.rs similarity index 73% rename from rpc/runtime-api/src/lib.rs rename to pallet/src/api.rs index 7d51e91..c550ec9 100644 --- a/rpc/runtime-api/src/lib.rs +++ b/pallet/src/api.rs @@ -2,14 +2,21 @@ extern crate alloc; -pub mod types; - use alloc::{string::String, vec::Vec}; - +use codec::{Decode, Encode}; use frame_support::weights::Weight; -pub use pallet_move::pallet::ModuleAbi; +use sp_runtime::{scale_info::TypeInfo, DispatchError}; -pub use crate::types::MoveApiEstimation; +pub use move_vm_backend_common::abi::ModuleAbi; + +/// Gas estimation information. +#[derive(Clone, PartialEq, Debug, Encode, Decode, TypeInfo)] +pub struct MoveApiEstimation { + /// Gas used. + pub gas_used: u64, + /// Status code for the MoveVM execution. + pub vm_status_code: u64, +} // Here we declare the runtime API. It is implemented it the `impl` block in // runtime file (the `runtime/src/lib.rs` of the node) @@ -24,13 +31,13 @@ sp_api::decl_runtime_apis! { fn weight_to_gas(weight: Weight) -> u64; // Estimate gas for publishing a module. - fn estimate_gas_publish_module(account: AccountId, bytecode: Vec) -> Result; + fn estimate_gas_publish_module(account: AccountId, bytecode: Vec) -> Result; // Estimate gas for publishing a bundle. - fn estimate_gas_publish_bundle(account: AccountId, bytecode: Vec) -> Result; + fn estimate_gas_publish_bundle(account: AccountId, bytecode: Vec) -> Result; // Estimate gas for script execution. - fn estimate_gas_execute_script(account: AccountId, transaction: Vec, cheque_limit: u128) -> Result; + fn estimate_gas_execute_script(account: AccountId, transaction: Vec, cheque_limit: u128) -> Result; // Get module binary by its address. fn get_module(address: String, name: String) -> Result>, Vec>; diff --git a/src/balance.rs b/pallet/src/balance.rs similarity index 100% rename from src/balance.rs rename to pallet/src/balance.rs diff --git a/src/benchmarking.rs b/pallet/src/benchmarking.rs similarity index 100% rename from src/benchmarking.rs rename to pallet/src/benchmarking.rs diff --git a/src/lib.rs b/pallet/src/lib.rs similarity index 99% rename from src/lib.rs rename to pallet/src/lib.rs index 51e1a51..e8c8472 100644 --- a/src/lib.rs +++ b/pallet/src/lib.rs @@ -1,5 +1,6 @@ #![cfg_attr(not(feature = "std"), no_std)] +pub mod api; pub mod balance; #[cfg(all(test, feature = "runtime-benchmarks"))] mod benchmarking; @@ -39,9 +40,9 @@ pub mod pallet { use move_vm_backend::{ balance::BalanceHandler, genesis::VmGenesisConfig, types::VmResult, Mvm, }; + use move_vm_backend_common::abi::ModuleAbi; pub use move_vm_backend_common::{ - abi::ModuleAbi, bytecode::verify_script_integrity_and_check_signers, - types::ScriptTransaction, + bytecode::verify_script_integrity_and_check_signers, types::ScriptTransaction, }; use sp_core::crypto::AccountId32; use sp_std::{vec, vec::Vec}; diff --git a/src/mock.rs b/pallet/src/mock.rs similarity index 100% rename from src/mock.rs rename to pallet/src/mock.rs diff --git a/src/result.rs b/pallet/src/result.rs similarity index 100% rename from src/result.rs rename to pallet/src/result.rs diff --git a/src/signer.rs b/pallet/src/signer.rs similarity index 100% rename from src/signer.rs rename to pallet/src/signer.rs diff --git a/src/storage.rs b/pallet/src/storage.rs similarity index 100% rename from src/storage.rs rename to pallet/src/storage.rs diff --git a/src/tests.rs b/pallet/src/tests.rs similarity index 100% rename from src/tests.rs rename to pallet/src/tests.rs diff --git a/src/tests/address.rs b/pallet/src/tests/address.rs similarity index 100% rename from src/tests/address.rs rename to pallet/src/tests/address.rs diff --git a/src/tests/assets/move-projects/balance/Move.toml b/pallet/src/tests/assets/move-projects/balance/Move.toml similarity index 100% rename from src/tests/assets/move-projects/balance/Move.toml rename to pallet/src/tests/assets/move-projects/balance/Move.toml diff --git a/src/tests/assets/move-projects/balance/sources/Scripts.move b/pallet/src/tests/assets/move-projects/balance/sources/Scripts.move similarity index 100% rename from src/tests/assets/move-projects/balance/sources/Scripts.move rename to pallet/src/tests/assets/move-projects/balance/sources/Scripts.move diff --git a/src/tests/assets/move-projects/car-wash-example/Move.toml b/pallet/src/tests/assets/move-projects/car-wash-example/Move.toml similarity index 100% rename from src/tests/assets/move-projects/car-wash-example/Move.toml rename to pallet/src/tests/assets/move-projects/car-wash-example/Move.toml diff --git a/src/tests/assets/move-projects/car-wash-example/build_all.sh b/pallet/src/tests/assets/move-projects/car-wash-example/build_all.sh similarity index 100% rename from src/tests/assets/move-projects/car-wash-example/build_all.sh rename to pallet/src/tests/assets/move-projects/car-wash-example/build_all.sh diff --git a/src/tests/assets/move-projects/car-wash-example/hints.md b/pallet/src/tests/assets/move-projects/car-wash-example/hints.md similarity index 100% rename from src/tests/assets/move-projects/car-wash-example/hints.md rename to pallet/src/tests/assets/move-projects/car-wash-example/hints.md diff --git a/src/tests/assets/move-projects/car-wash-example/scripts/Scripts.move b/pallet/src/tests/assets/move-projects/car-wash-example/scripts/Scripts.move similarity index 100% rename from src/tests/assets/move-projects/car-wash-example/scripts/Scripts.move rename to pallet/src/tests/assets/move-projects/car-wash-example/scripts/Scripts.move diff --git a/src/tests/assets/move-projects/car-wash-example/sources/CarWash.move b/pallet/src/tests/assets/move-projects/car-wash-example/sources/CarWash.move similarity index 100% rename from src/tests/assets/move-projects/car-wash-example/sources/CarWash.move rename to pallet/src/tests/assets/move-projects/car-wash-example/sources/CarWash.move diff --git a/src/tests/assets/move-projects/get-resource/Move.toml b/pallet/src/tests/assets/move-projects/get-resource/Move.toml similarity index 100% rename from src/tests/assets/move-projects/get-resource/Move.toml rename to pallet/src/tests/assets/move-projects/get-resource/Move.toml diff --git a/src/tests/assets/move-projects/get-resource/scripts/Count.move b/pallet/src/tests/assets/move-projects/get-resource/scripts/Count.move similarity index 100% rename from src/tests/assets/move-projects/get-resource/scripts/Count.move rename to pallet/src/tests/assets/move-projects/get-resource/scripts/Count.move diff --git a/src/tests/assets/move-projects/get-resource/scripts/CreateCounter.move b/pallet/src/tests/assets/move-projects/get-resource/scripts/CreateCounter.move similarity index 100% rename from src/tests/assets/move-projects/get-resource/scripts/CreateCounter.move rename to pallet/src/tests/assets/move-projects/get-resource/scripts/CreateCounter.move diff --git a/src/tests/assets/move-projects/get-resource/sources/Counter.move b/pallet/src/tests/assets/move-projects/get-resource/sources/Counter.move similarity index 100% rename from src/tests/assets/move-projects/get-resource/sources/Counter.move rename to pallet/src/tests/assets/move-projects/get-resource/sources/Counter.move diff --git a/src/tests/assets/move-projects/move-basics/Move.toml b/pallet/src/tests/assets/move-projects/move-basics/Move.toml similarity index 100% rename from src/tests/assets/move-projects/move-basics/Move.toml rename to pallet/src/tests/assets/move-projects/move-basics/Move.toml diff --git a/src/tests/assets/move-projects/move-basics/scripts/Generics.move b/pallet/src/tests/assets/move-projects/move-basics/scripts/Generics.move similarity index 100% rename from src/tests/assets/move-projects/move-basics/scripts/Generics.move rename to pallet/src/tests/assets/move-projects/move-basics/scripts/Generics.move diff --git a/src/tests/assets/move-projects/move-basics/scripts/Loops.move b/pallet/src/tests/assets/move-projects/move-basics/scripts/Loops.move similarity index 100% rename from src/tests/assets/move-projects/move-basics/scripts/Loops.move rename to pallet/src/tests/assets/move-projects/move-basics/scripts/Loops.move diff --git a/src/tests/assets/move-projects/move-basics/scripts/empty.move b/pallet/src/tests/assets/move-projects/move-basics/scripts/empty.move similarity index 100% rename from src/tests/assets/move-projects/move-basics/scripts/empty.move rename to pallet/src/tests/assets/move-projects/move-basics/scripts/empty.move diff --git a/src/tests/assets/move-projects/move-basics/sources/Empty.move b/pallet/src/tests/assets/move-projects/move-basics/sources/Empty.move similarity index 100% rename from src/tests/assets/move-projects/move-basics/sources/Empty.move rename to pallet/src/tests/assets/move-projects/move-basics/sources/Empty.move diff --git a/src/tests/assets/move-projects/move-basics/sources/EmptyBob.move b/pallet/src/tests/assets/move-projects/move-basics/sources/EmptyBob.move similarity index 100% rename from src/tests/assets/move-projects/move-basics/sources/EmptyBob.move rename to pallet/src/tests/assets/move-projects/move-basics/sources/EmptyBob.move diff --git a/src/tests/assets/move-projects/multiple-signers/Move.toml b/pallet/src/tests/assets/move-projects/multiple-signers/Move.toml similarity index 100% rename from src/tests/assets/move-projects/multiple-signers/Move.toml rename to pallet/src/tests/assets/move-projects/multiple-signers/Move.toml diff --git a/src/tests/assets/move-projects/multiple-signers/build.sh b/pallet/src/tests/assets/move-projects/multiple-signers/build.sh similarity index 100% rename from src/tests/assets/move-projects/multiple-signers/build.sh rename to pallet/src/tests/assets/move-projects/multiple-signers/build.sh diff --git a/src/tests/assets/move-projects/multiple-signers/estimate.sh b/pallet/src/tests/assets/move-projects/multiple-signers/estimate.sh similarity index 100% rename from src/tests/assets/move-projects/multiple-signers/estimate.sh rename to pallet/src/tests/assets/move-projects/multiple-signers/estimate.sh diff --git a/src/tests/assets/move-projects/multiple-signers/sources/Dorm.move b/pallet/src/tests/assets/move-projects/multiple-signers/sources/Dorm.move similarity index 100% rename from src/tests/assets/move-projects/multiple-signers/sources/Dorm.move rename to pallet/src/tests/assets/move-projects/multiple-signers/sources/Dorm.move diff --git a/src/tests/assets/move-projects/multiple-signers/sources/Scripts.move b/pallet/src/tests/assets/move-projects/multiple-signers/sources/Scripts.move similarity index 100% rename from src/tests/assets/move-projects/multiple-signers/sources/Scripts.move rename to pallet/src/tests/assets/move-projects/multiple-signers/sources/Scripts.move diff --git a/src/tests/assets/move-projects/signer-scripts/Move.toml b/pallet/src/tests/assets/move-projects/signer-scripts/Move.toml similarity index 100% rename from src/tests/assets/move-projects/signer-scripts/Move.toml rename to pallet/src/tests/assets/move-projects/signer-scripts/Move.toml diff --git a/src/tests/assets/move-projects/signer-scripts/sources/General.move b/pallet/src/tests/assets/move-projects/signer-scripts/sources/General.move similarity index 100% rename from src/tests/assets/move-projects/signer-scripts/sources/General.move rename to pallet/src/tests/assets/move-projects/signer-scripts/sources/General.move diff --git a/src/tests/assets/move-projects/signer-scripts/sources/Generics.move b/pallet/src/tests/assets/move-projects/signer-scripts/sources/Generics.move similarity index 100% rename from src/tests/assets/move-projects/signer-scripts/sources/Generics.move rename to pallet/src/tests/assets/move-projects/signer-scripts/sources/Generics.move diff --git a/src/tests/assets/move-projects/signer-scripts/sources/HelperModule.move b/pallet/src/tests/assets/move-projects/signer-scripts/sources/HelperModule.move similarity index 100% rename from src/tests/assets/move-projects/signer-scripts/sources/HelperModule.move rename to pallet/src/tests/assets/move-projects/signer-scripts/sources/HelperModule.move diff --git a/src/tests/assets/move-projects/signer-scripts/sources/Vectors.move b/pallet/src/tests/assets/move-projects/signer-scripts/sources/Vectors.move similarity index 100% rename from src/tests/assets/move-projects/signer-scripts/sources/Vectors.move rename to pallet/src/tests/assets/move-projects/signer-scripts/sources/Vectors.move diff --git a/src/tests/assets/move-projects/smove-build-all.sh b/pallet/src/tests/assets/move-projects/smove-build-all.sh similarity index 100% rename from src/tests/assets/move-projects/smove-build-all.sh rename to pallet/src/tests/assets/move-projects/smove-build-all.sh diff --git a/src/tests/assets/move-projects/smove-clean-all.sh b/pallet/src/tests/assets/move-projects/smove-clean-all.sh similarity index 100% rename from src/tests/assets/move-projects/smove-clean-all.sh rename to pallet/src/tests/assets/move-projects/smove-clean-all.sh diff --git a/src/tests/assets/move-projects/testing-move-stdlib/Move.toml b/pallet/src/tests/assets/move-projects/testing-move-stdlib/Move.toml similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/Move.toml rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/Move.toml diff --git a/src/tests/assets/move-projects/testing-move-stdlib/README.md b/pallet/src/tests/assets/move-projects/testing-move-stdlib/README.md similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/README.md rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/README.md diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/ascii.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/ascii.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/ascii.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/ascii.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/bcs.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/bcs.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/bcs.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/bcs.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/bit_vector.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/bit_vector.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/bit_vector.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/bit_vector.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/error.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/error.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/error.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/error.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/fixed_point32.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/fixed_point32.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/fixed_point32.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/fixed_point32.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/hash.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/hash.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/hash.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/hash.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/option.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/option.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/option.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/option.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/signer.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/signer.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/signer.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/signer.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/string.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/string.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/string.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/string.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/type_name.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/type_name.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/type_name.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/type_name.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/unit_test.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/unit_test.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/unit_test.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/unit_test.move diff --git a/src/tests/assets/move-projects/testing-move-stdlib/sources/vector.move b/pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/vector.move similarity index 100% rename from src/tests/assets/move-projects/testing-move-stdlib/sources/vector.move rename to pallet/src/tests/assets/move-projects/testing-move-stdlib/sources/vector.move diff --git a/src/tests/assets/move-projects/testing-substrate-stdlib/Move.toml b/pallet/src/tests/assets/move-projects/testing-substrate-stdlib/Move.toml similarity index 100% rename from src/tests/assets/move-projects/testing-substrate-stdlib/Move.toml rename to pallet/src/tests/assets/move-projects/testing-substrate-stdlib/Move.toml diff --git a/src/tests/assets/move-projects/testing-substrate-stdlib/README.md b/pallet/src/tests/assets/move-projects/testing-substrate-stdlib/README.md similarity index 100% rename from src/tests/assets/move-projects/testing-substrate-stdlib/README.md rename to pallet/src/tests/assets/move-projects/testing-substrate-stdlib/README.md diff --git a/src/tests/assets/move-projects/testing-substrate-stdlib/sources/balance.move b/pallet/src/tests/assets/move-projects/testing-substrate-stdlib/sources/balance.move similarity index 100% rename from src/tests/assets/move-projects/testing-substrate-stdlib/sources/balance.move rename to pallet/src/tests/assets/move-projects/testing-substrate-stdlib/sources/balance.move diff --git a/src/tests/assets/move-projects/using_stdlib_natives/Move.toml b/pallet/src/tests/assets/move-projects/using_stdlib_natives/Move.toml similarity index 100% rename from src/tests/assets/move-projects/using_stdlib_natives/Move.toml rename to pallet/src/tests/assets/move-projects/using_stdlib_natives/Move.toml diff --git a/src/tests/assets/move-projects/using_stdlib_natives/sources/DependsOnVector.move b/pallet/src/tests/assets/move-projects/using_stdlib_natives/sources/DependsOnVector.move similarity index 100% rename from src/tests/assets/move-projects/using_stdlib_natives/sources/DependsOnVector.move rename to pallet/src/tests/assets/move-projects/using_stdlib_natives/sources/DependsOnVector.move diff --git a/src/tests/assets/move-projects/using_stdlib_natives/sources/Vector.move b/pallet/src/tests/assets/move-projects/using_stdlib_natives/sources/Vector.move similarity index 100% rename from src/tests/assets/move-projects/using_stdlib_natives/sources/Vector.move rename to pallet/src/tests/assets/move-projects/using_stdlib_natives/sources/Vector.move diff --git a/src/tests/balance.rs b/pallet/src/tests/balance.rs similarity index 100% rename from src/tests/balance.rs rename to pallet/src/tests/balance.rs diff --git a/src/tests/example.rs b/pallet/src/tests/example.rs similarity index 100% rename from src/tests/example.rs rename to pallet/src/tests/example.rs diff --git a/src/tests/execute.rs b/pallet/src/tests/execute.rs similarity index 100% rename from src/tests/execute.rs rename to pallet/src/tests/execute.rs diff --git a/src/tests/modules.rs b/pallet/src/tests/modules.rs similarity index 100% rename from src/tests/modules.rs rename to pallet/src/tests/modules.rs diff --git a/src/tests/publish.rs b/pallet/src/tests/publish.rs similarity index 100% rename from src/tests/publish.rs rename to pallet/src/tests/publish.rs diff --git a/src/tests/signer.rs b/pallet/src/tests/signer.rs similarity index 100% rename from src/tests/signer.rs rename to pallet/src/tests/signer.rs diff --git a/src/tests/update_stdlib.rs b/pallet/src/tests/update_stdlib.rs similarity index 100% rename from src/tests/update_stdlib.rs rename to pallet/src/tests/update_stdlib.rs diff --git a/src/weights.rs b/pallet/src/weights.rs similarity index 100% rename from src/weights.rs rename to pallet/src/weights.rs diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 3165781..015f633 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -1,31 +1,30 @@ [package] name = "pallet-move-rpc" version = "0.1.0" -authors = ["Eiger "] -edition = "2021" -description = 'RPC methods for the Move pallet' +description = "RPC for the Move Pallet" +authors = { workspace = true } +edition = { workspace = true } +readme = { workspace = true } +repository = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.6", default-features = false, features = ["derive"] } -serde = { version = "1.0", features = [ "derive" ], default-features = false } -jsonrpsee = { version = "0.16", features = ["server", "macros"] } +codec = { workspace = true } +serde = { workspace = true } +frame-support = { workspace = true } +jsonrpsee = { workspace = true } +sp-api = { workspace = true } +sp-blockchain = { workspace = true } +sp-runtime = { workspace = true } -# Substrate packages -frame-support = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } -sp-api = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } -sp-blockchain = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0" } - -# local packages -pallet-move-runtime-api = { path = "./runtime-api", default-features = false } +pallet-move = { path = "../pallet" } [features] default = ["std"] std = [ "sp-api/std", "sp-runtime/std", - "pallet-move-runtime-api/std" + "pallet-move/std" ] diff --git a/rpc/runtime-api/.gitignore b/rpc/runtime-api/.gitignore deleted file mode 100644 index 162a5dd..0000000 --- a/rpc/runtime-api/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/target/ - -# These are backup files generated by rustfmt -**/*.rs.bk - -# Files generated/used by direnv -.envrc -.direnv/ - -Cargo.lock diff --git a/rpc/runtime-api/Cargo.toml b/rpc/runtime-api/Cargo.toml deleted file mode 100644 index 58f838a..0000000 --- a/rpc/runtime-api/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "pallet-move-runtime-api" -version = "0.1.0" -authors = ["Eiger "] -edition = "2021" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.6", default-features = false, features = ["derive"] } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } -scale-info = { version = "2.10", default-features = false, features = ["derive"] } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.4.0", default-features = false } - -pallet-move = { path = "../..", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "frame-support/std", - "pallet-move/std", - "scale-info/std", - "sp-api/std", - "sp-runtime/std", -] diff --git a/rpc/runtime-api/src/types.rs b/rpc/runtime-api/src/types.rs deleted file mode 100644 index c38ca31..0000000 --- a/rpc/runtime-api/src/types.rs +++ /dev/null @@ -1,11 +0,0 @@ -use codec::{Decode, Encode}; -use sp_runtime::scale_info::TypeInfo; - -/// Gas estimation information. -#[derive(Clone, PartialEq, Debug, Encode, Decode, TypeInfo)] -pub struct MoveApiEstimation { - /// Gas used. - pub gas_used: u64, - /// Status code for the MoveVM execution. - pub vm_status_code: u64, -} diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index c16b2a0..f08cf20 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -7,8 +7,7 @@ use jsonrpsee::{ proc_macros::rpc, types::error::{CallError, ErrorObject}, }; -pub use pallet_move_runtime_api::MoveApi as MoveRuntimeApi; -use pallet_move_runtime_api::{ModuleAbi, MoveApiEstimation}; +pub use pallet_move::api::{ModuleAbi, MoveApi as MoveRuntimeApi, MoveApiEstimation}; use serde::{Deserialize, Serialize}; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; @@ -272,14 +271,11 @@ mod tests { let err_str_tst = "\"\\\"test\\\"\""; let res = runtime_error_into_rpc_err(err_str); match res { - JsonRpseeError::Call(err) => match err { - CallError::Custom(err) => { - assert_eq!(err.code(), RUNTIME_ERROR); - assert_eq!(err.message(), "Runtime error"); - assert_eq!(err.data().unwrap().get(), err_str_tst) - } - _ => panic!("Wrong error type"), - }, + JsonRpseeError::Call(CallError::Custom(err)) => { + assert_eq!(err.code(), RUNTIME_ERROR); + assert_eq!(err.message(), "Runtime error"); + assert_eq!(err.data().unwrap().get(), err_str_tst); + } _ => panic!("Wrong error type"), } } @@ -290,14 +286,11 @@ mod tests { let err_str_tst = "\"\\\"\\\"\""; let res = runtime_error_into_rpc_err(err_str); match res { - JsonRpseeError::Call(err) => match err { - CallError::Custom(err) => { - assert_eq!(err.code(), RUNTIME_ERROR); - assert_eq!(err.message(), "Runtime error"); - assert_eq!(err.data().unwrap().get(), err_str_tst) - } - _ => panic!("Wrong error type"), - }, + JsonRpseeError::Call(CallError::Custom(err)) => { + assert_eq!(err.code(), RUNTIME_ERROR); + assert_eq!(err.message(), "Runtime error"); + assert_eq!(err.data().unwrap().get(), err_str_tst); + } _ => panic!("Wrong error type"), } }