-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Scaffolding for wasm test * Fix command to build wasm example * State os for running job statically * Run example with wasmtime * Try different approach for a build with a wasm test * Add missing comma * Fix toml formatting * Adjust path * Test a failing example * Return an Err * Improve wasm example * Working on example * Implement functionality * Improve example * Cleanup example * Revert "Implement functionality" This reverts commit 6900574. * Add test documentation * Incorporate review feedback
- Loading branch information
Showing
5 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "ac-examples-wasm" | ||
version = "0.5.0" | ||
license = "Apache-2.0" | ||
edition = "2021" | ||
|
||
[dev-dependencies] | ||
sp-core = { default-features = false, features = ["full_crypto", "serde"], git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" } | ||
sp-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" } | ||
substrate-api-client = { default-features = false, path = "../..", version = "0.17" } | ||
pallet-balances = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright 2024 Supercomputing Systems AG | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
//! Example that some basic functions that can be executed in WebAssembly. | ||
|
||
pub use pallet_balances::Call as BalancesCall; | ||
use sp_core::{ | ||
crypto::{AccountId32, Ss58Codec}, | ||
sr25519, Pair, | ||
}; | ||
use sp_runtime::MultiAddress; | ||
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; | ||
use std::process::ExitCode; | ||
use substrate_api_client::ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner}; | ||
|
||
fn main() -> Result<ExitCode, i32> { | ||
// This test is not yet very sophisticated and not exhaustive. | ||
// Still it shows how some basic data structures can be constructed and used. | ||
let alice: sr25519::Pair = Pair::from_string( | ||
"0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a", | ||
None, | ||
) | ||
.unwrap(); | ||
|
||
let bob_account: AccountId32 = | ||
sr25519::Public::from_ss58check("5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty") | ||
.unwrap() | ||
.into(); | ||
let _bob: MultiAddress<AccountId32, AccountId32> = MultiAddress::Id(bob_account); | ||
let es_converted: ExtrinsicSigner<AssetRuntimeConfig> = alice.clone().into(); | ||
let es_new = ExtrinsicSigner::<AssetRuntimeConfig>::new(alice.clone()); | ||
assert_eq!(es_converted.signer().public(), es_new.signer().public()); | ||
|
||
let extrinsic = UncheckedExtrinsic::from_bytes(&[]); | ||
match extrinsic { | ||
Ok(_) => panic!("Extrinsic should be invalid"), | ||
Err(_) => (), | ||
} | ||
Ok(ExitCode::from(0)) | ||
} |