Skip to content

Commit

Permalink
Merge pull request #1585 from GuiGou12358/master
Browse files Browse the repository at this point in the history
Change for RFC-0078: Merkleized Metadata
  • Loading branch information
kvinwang authored Sep 9, 2024
2 parents ff9d2f6 + 1b5a8ef commit 5e59e74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 5 additions & 5 deletions crates/pink-libs/subrpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pink-subrpc"
version = "0.6.0"
version = "0.7.0"
authors = ["Phala Network"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -14,19 +14,19 @@ path = "src/lib.rs"

[dependencies]
scale = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"], optional = true }
scale-info = { version = "2.11.3", default-features = false, features = ["derive"], optional = true }
primitive-types = { version = "0.12.2", default-features = false, features = ["codec", "scale-info"] }

hex-literal = "0.4.1"
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }

pink = { version = "0.4.0", path = "../../pink/pink", default-features = false }
pink = { version = "0.4.1", path = "../../pink/pink", default-features = false }
sp-core-hashing = { version = "9", default-features = false }

serde = { version = "1.0.140", default-features = false, features = ["derive", "alloc"]}
serde = { version = "1.0.209", default-features = false, features = ["derive", "alloc"]}
pink-json = { version = "0.4", default-features = false }

ss58-registry = { version = "1.33.0", default-features = false }
ss58-registry = { version = "1.47.0", default-features = false }
base58 = { version = "0.2.0", default-features = false }

[dev-dependencies]
Expand Down
13 changes: 12 additions & 1 deletion crates/pink-libs/subrpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,17 @@ pub fn create_transaction_ext<T: Encode>(
call_data: UnsignedExtrinsic<T>,
era: Era,
tip: u128,
mode: u8,
metadata_hash: Option<[u8; 32]>,
) -> core::result::Result<Vec<u8>, Error> {
let additional_params = (
spec_version,
transaction_version,
genesis_hash,
era_checkpoint,
metadata_hash,
);
let extra = (era, Compact(nonce), Compact(tip));
let extra = (era, Compact(nonce), Compact(tip), mode);

let mut bytes = Vec::new();
call_data.encode_to(&mut bytes);
Expand Down Expand Up @@ -309,6 +312,12 @@ pub fn create_transaction<T: Encode>(
Some(n) => n,
_ => get_next_nonce(rpc_node, &addr)?,
};
// new fields added by RFC78 for the signed extension.
// more information here: https://polkadot-fellows.github.io/RFCs/approved/0078-merkleized-metadata.html#inclusion-in-an-extrinsic
// the mode is either 0 which means to not include the metadata hash in the signed data or the mode is 1 to include the metadata hash in V1.
let mode = 0;
// Included in the signed data is an Option<[u8; 32]>. Depending on the mode the value is either None or Some(metadata_hash).
let metadata_hash = None;

let call_data = UnsignedExtrinsic {
pallet_id,
Expand All @@ -326,6 +335,8 @@ pub fn create_transaction<T: Encode>(
call_data,
era,
tip,
mode,
metadata_hash,
)
}

Expand Down

0 comments on commit 5e59e74

Please sign in to comment.