-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,407 additions
and
39 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
on: [push, pull_request] | ||
|
||
name: Continuous integration | ||
|
||
jobs: | ||
check: | ||
name: Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: check | ||
|
||
test: | ||
name: Test Suite | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --features=std | ||
|
||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- run: rustup component add rustfmt | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
|
||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- run: rustup component add clippy | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: -- -D warnings |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
target/ | ||
Cargo.lock | ||
.vscode/ | ||
**/*.rs.bk | ||
**/*.rs.bk |
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,3 @@ | ||
# VirtoSDK | ||
|
||
> ⚠️ Work in progress. The Sube repository is now the VirtoSDK where we are gathering all our client side tools and will add higher lever abstractions for applications to easily integrate Web3 services. |
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
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,6 @@ | ||
default: | ||
just --choose | ||
|
||
check-no-std: | ||
cargo build --features substrate --target wasm32-unknown-unknown | ||
cargo build --features substrate --target riscv32i-unknown-none-elf |
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
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
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[package] | ||
name = "scale-serialization" | ||
description = "SCALE Serialization" | ||
version = "1.0.0-beta2" | ||
authors = ["Daniel Olano <[email protected]>"] | ||
edition = "2018" | ||
repository = "https://github.com/virto-network/scales" | ||
license = "Apache-2.0" | ||
|
||
[dependencies] | ||
bytes = { version = "1.1.0", default-features = false } | ||
scale-info = { version = "2.1.1", default-features = false, features = ["serde"] } | ||
serde = { version = "1.0.137", default-features = false } | ||
serde_json = { version = "1.0.80", default-features = false, optional = true } | ||
codec = { version = "3.1.2", package = "parity-scale-codec", default-features = false, optional = true } | ||
hex = { version = "0.4.3", default-features = false, features = ["alloc"], optional = true } | ||
|
||
[features] | ||
default = ["std", "codec", "json", "hex", "experimental-serializer"] | ||
std = ["scale-info/std", "bytes/std"] | ||
experimental-serializer = [] | ||
json = ["serde_json/preserve_order"] | ||
|
||
[dev-dependencies] | ||
anyhow = "1.0.57" | ||
codec = { version = "3.1.2", package = "parity-scale-codec", features = ["derive"] } | ||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } | ||
serde = { version = "1.0.137", default-features = false, features = ["derive"] } | ||
serde_json = { version = "1.0.80", default-features = false, features = ["alloc"] } |
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,35 @@ | ||
# scales - SCALE Serialization | ||
|
||
Making use of [type information](https://github.com/paritytech/scale-info) this library allows | ||
conversion to/from [SCALE](https://github.com/paritytech/parity-scale-codec) encoded data, | ||
specially useful when conversion is for dynamic types like JSON. | ||
|
||
### From SCALE | ||
|
||
`scales::Value` wraps the raw SCALE binary data and the type id within type registry | ||
giving you an object that can be serialized to any compatible format. | ||
|
||
```rust | ||
let value = scales::Value::new(scale_binary_data, type_id, &type_registry); | ||
serde_json::to_string(value)?; | ||
``` | ||
|
||
### To SCALE | ||
|
||
Public methods from the `scales::serializer::*` module(feature `experimental-serializer`) | ||
allow for a best effort conversion of dynamic types(e.g. `serde_json::Value`) to SCALE | ||
binary format. The serializer tries to be smart when interpreting the input and convert it | ||
to the desired format dictated by the provided type in the registry. | ||
|
||
```rust | ||
// simple conversion | ||
let scale_data = to_vec(some_serializable_input); // or to_bytes(&mut bytes, input); | ||
|
||
// with type info | ||
let scale_data = to_vec_with_info(input, Some((®istry, type_id))); | ||
|
||
// from an unordered list of properties that make an object | ||
let input = vec![("prop_b", 123), ("prop_a", 456)]; | ||
let scale_data = to_vec_from_iter(input, (®istry, type_id)); | ||
``` | ||
|
Oops, something went wrong.