diff --git a/.gitignore b/.gitignore index 5eecd01..747cadc 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ metadata.* .vscode docs + +cli/executables diff --git a/README.md b/README.md index 0770db5..33c2088 100644 --- a/README.md +++ b/README.md @@ -47,26 +47,36 @@ This is a great way to have a peek at what the runtime can do. You may however w ## Demos +### Get a runtime +
demo get
subwasm get
+### info command +
demo info
subwasm info
+### show command +
demo meta
subwasm show
+### meta command +
demo meta
subwasm meta
+### diff command +
demo diff
subwasm diff
diff --git a/doc/demos.adoc b/doc/demos.adoc index ec20ef0..955d98e 100644 --- a/doc/demos.adoc +++ b/doc/demos.adoc @@ -2,17 +2,22 @@ :imagesdir: ./scripts/demos/gif -.Get a runtime +=== Get a runtime + image::demo-get.gif[title="subwasm get"] -.info command +=== info command + image::demo-info.gif[title="subwasm info"] -.show command +=== show command + image::demo-meta.gif[title="subwasm show"] -.meta command +=== meta command + image::demo-meta.gif[title="subwasm meta"] -.diff command +=== diff command + image::demo-diff.gif[title="subwasm diff"] diff --git a/justfile b/justfile index a459215..d5e8ff9 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,5 @@ -VERSION := `toml get cli/Cargo.toml package.version | jq -r` -export TAG:=`toml get cli/Cargo.toml "package.version" | jq -r .` +VERSION := `toml get Cargo.toml workspace.package.version | jq -r` +export TAG:=`toml get Cargo.toml "workspace.package.version" | jq -r .` # List available commands _default: diff --git a/libs/substrate-runtime-proposal-hash/src/lib.rs b/libs/substrate-runtime-proposal-hash/src/lib.rs index cef7225..c821ec7 100644 --- a/libs/substrate-runtime-proposal-hash/src/lib.rs +++ b/libs/substrate-runtime-proposal-hash/src/lib.rs @@ -52,17 +52,6 @@ pub fn get_result(prefix: Prefix, buffer: &[u8]) -> Result { }) } -/// Calculate the proposal hash -/// -/// # Arguments -/// * `wasm_blob` - The WASM blob -/// # Returns -/// * `CalllHash` - The hash of the proposal as calculated on chain -/// @deprecated -pub fn get_proposal_hash(wasm_blob: &[u8]) -> Result { - get_call_hash(PREFIX_SYSTEM_SETCODE, wasm_blob) -} - /// Calculate the proposal hash which is system.setCode /// /// # Arguments @@ -92,17 +81,6 @@ fn get_call_hash(prefix: Prefix, wasm_blob: &[u8]) -> Result { mod prop_hash_tests { use super::*; - #[test] - fn test_proposal_hash() { - assert_eq!( - get_proposal_hash(&[1, 2, 42]).expect("Failed getting a hash"), - [ - 174, 123, 79, 240, 254, 106, 147, 26, 65, 61, 41, 84, 181, 102, 24, 182, 128, 135, 188, 31, 135, 187, - 99, 34, 143, 35, 120, 100, 246, 90, 186, 106 - ] - ); - } - #[test] fn test_call_hash() { assert_eq!( @@ -157,7 +135,7 @@ mod prop_hash_tests { #[test] fn test_hash_length() { - assert_eq!(32, get_proposal_hash(&[0]).expect("Failed getting a hash").len()); + assert_eq!(32, get_call_hash((0, 0), &[0]).expect("Failed getting a hash").len()); } #[test] diff --git a/templates/diff/diff.md.tera b/templates/diff/diff.md.tera new file mode 100644 index 0000000..15ebb0c --- /dev/null +++ b/templates/diff/diff.md.tera @@ -0,0 +1,73 @@ +# Subwasm Differ Report + + +{% for c in changes.changes %} + +{% set palletsAdded = c.Pallets | filter(attribute="Added") %} +{% set palletsChanged = c.Pallets | filter(attribute="Changed") %} +{% set palletsRemoved = c.Pallets | filter(attribute="Removed") %} + +{# {{ c | json_encode }} +{{ p.Changed | json_encode }} +#} +## Pallets Removed +{% if palletsRemoved | length %} +{% for p in palletsRemoved %} + +{% set pallet_id = p.Removed[0] %} +{% set pallet_a = changes.runtime_a.pallets[pallet_id] %} +{% set content = p.Removed[1] %} +### {{pallet_a.name}} +{% endfor %} +{% else %} +No pallet removed +{% endif %} +{# +#} + + +## Pallets Added +{% if palletsAdded | length %} +{% for p in palletsAdded %} + +{% set pallet_id = p.Added[0] %} +{% set pallet_b = changes.runtime_b.pallets[pallet_id] %} +{% set content = p.Added[1] %} + +### {{pallet_b.name}} + +``` +{{ pallet_b | json_encode(pretty=true) }} +``` +{% endfor %} +{% else %} +No pallet removed +{% endif %} +{# +#} + + +## Pallets Changed + +{% if palletsChanged | length %} +{% for p in palletsChanged %} + +{% set pallet_id = p.Changed[0] %} +{% set pallet_a = changes.runtime_a.pallets[pallet_id] %} +{% set pallet_b = changes.runtime_b.pallets[pallet_id] %} +{% set content = p.Changed[1] %} + +### {{pallet_a.name}} +{% endfor %} +{% else %} +No pallet removed +{% endif %} +{# +#} + +{% endfor %} + +## Analysis + +- tx bump: {{ require_transaction_version_bump }} +- compat : {{ compatible }}