-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wasm test #772
Merged
Merged
Wasm test #772
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
32537a4
Scaffolding for wasm test
Niederb 5eb9563
Fix command to build wasm example
Niederb d8b7ad9
State os for running job statically
Niederb aee1ef7
Run example with wasmtime
Niederb 5212a9f
Try different approach for a build with a wasm test
Niederb 4788746
Add missing comma
Niederb b9a423a
Fix toml formatting
Niederb 61aa867
Adjust path
Niederb 6f225b5
Test a failing example
Niederb 0e629b5
Return an Err
Niederb ae0e25a
Improve wasm example
Niederb 341727e
Working on example
Niederb 50ea0c2
Implement functionality
Niederb 8955962
Improve example
Niederb b203ac8
Cleanup example
Niederb d00c015
Revert "Implement functionality"
Niederb 4d22b57
Add test documentation
Niederb b4ad5d0
Incorporate review feedback
Niederb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a newline before this, or even put this block below the next block "merge", as the merge is using only the examples. I'm almost wondering if we should put the wasm-stuff into its own yml-file (?). But I leave this up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the newline. The merge is actually also for the wasm-example as this can also be downloaded. I also updated the merge to reflect this.