Skip to content

Commit

Permalink
Add Ledger support
Browse files Browse the repository at this point in the history
  • Loading branch information
JuaniRios committed Sep 9, 2024
1 parent a6828af commit 009e25f
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 4 deletions.
54 changes: 54 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ frame-system = { version = "35.0.0", default-features = false }
frame-system-rpc-runtime-api = { version = "33.0.0", default-features = false }
frame-system-benchmarking = { version = "35.0.0", default-features = false }
frame-try-runtime = { version = "0.41.0", default-features = false }
frame-metadata-hash-extension = { version = "0.3.0", default-features = false }
sp-api = { version = "33.0.0", default-features = false }
sp-debug-derive = { version = "14.0.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ itertools.workspace = true
pallet-democracy.workspace = true
pallet-scheduler.workspace = true
pallet-treasury.workspace = true
frame-metadata-hash-extension.workspace = true

# Runtimes
polkadot-runtime.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions integration-tests/src/tests/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ fn dispenser_signed_extensions_pass_for_new_account() {
pallet_dispenser::extensions::CheckNonce::<PolimecRuntime>::from(0u32),
frame_system::CheckWeight::<PolimecRuntime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<PolimecRuntime>::from(0u64.into()).into(),
frame_metadata_hash_extension::CheckMetadataHash::<PolimecRuntime>::new(true),

);
assert_err!(
extra.validate(&who, &paid_call, &paid_call.get_dispatch_info(), 0),
Expand Down
12 changes: 10 additions & 2 deletions runtimes/polimec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ version.workspace = true
workspace = true

[build-dependencies]
substrate-wasm-builder.workspace = true
substrate-wasm-builder = { workspace = true, optional = true }

[dependencies]
parity-scale-codec = { workspace= true, default-features = false, features = [
Expand Down Expand Up @@ -81,6 +81,7 @@ sp-std.workspace = true
sp-transaction-pool.workspace = true
sp-version.workspace = true
sp-genesis-builder.workspace = true
frame-metadata-hash-extension.workspace = true

# Polkadot
pallet-xcm.workspace = true
Expand Down Expand Up @@ -183,6 +184,8 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"substrate-wasm-builder",
"frame-metadata-hash-extension/std"
]

runtime-benchmarks = [
Expand Down Expand Up @@ -276,6 +279,11 @@ try-runtime = [
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging", "pallet-funding/on-chain-release-build" ]
on-chain-release-build = [ "sp-api/disable-logging", "pallet-funding/on-chain-release-build", "metadata-hash" ]

development-settings = [ "shared-configuration/development-settings" ]

# Enable the metadata hash generation in the wasm-builder
metadata-hash = [
"substrate-wasm-builder?/metadata-hash",
]
16 changes: 14 additions & 2 deletions runtimes/polimec/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,20 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use substrate_wasm_builder::WasmBuilder;

#[cfg(all(feature = "std", feature = "metadata-hash"))]
fn main() {
WasmBuilder::new().with_current_project().export_heap_base().import_memory().build();
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("PLMC", 10)
.build();
}

#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
fn main() {
substrate_wasm_builder::WasmBuilder::build_using_defaults();
}

/// The wasm builder is deactivated when compiling
/// this crate for wasm to speed up the compilation.
#[cfg(not(feature = "std"))]
fn main() {}
3 changes: 3 additions & 0 deletions runtimes/polimec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ pub type SignedExtra = (
Runtime,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
Expand Down Expand Up @@ -901,6 +902,8 @@ where
pallet_dispenser::extensions::SkipCheckIfFeeless::from(
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(true),

);
let raw_payload = generic::SignedPayload::new(call, extra)
.map_err(|e| {
Expand Down

0 comments on commit 009e25f

Please sign in to comment.