Skip to content

Commit d130805

Browse files
committed
initial commit
1 parent 10d0a98 commit d130805

File tree

15 files changed

+295
-1
lines changed

15 files changed

+295
-1
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
[*]
3+
indent_style=tab
4+
indent_size=tab
5+
tab_width=4
6+
end_of_line=lf
7+
charset=utf-8
8+
trim_trailing_whitespace=true
9+
max_line_length=120
10+
insert_final_newline=true
11+
12+
[*.{yml,yaml}]
13+
indent_style=space
14+
indent_size=2
15+
tab_width=8
16+
end_of_line=lf

.rustfmt.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
reorder_imports = true
2+
hard_tabs = true
3+
max_width = 120

Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "orml"
3+
version = "0.0.1"
4+
authors = ["Laminar Developers <[email protected]>"]
5+
edition = "2018"
6+
7+
[[bin]]
8+
name = "orml"
9+
path = "src/main.rs"
10+
11+
[dependencies]
12+
oracle = { package = "orml-oracle", path = "oracle", default-features = false }
13+
tokens = { package = "orml-tokens", path = "tokens", default-features = false }
14+
traits = { package = "orml-traits", path = "traits", default-features = false }
15+
utilities = { package = "orml-utilities", path = "utilities", default-features = false }
16+
17+
[features]
18+
default = ["std"]
19+
std = [
20+
"oracle/std",
21+
"tokens/std",
22+
"traits/std",
23+
"utilities/std",
24+
]
25+
26+
[workspace]
27+
members = [
28+
"oracle",
29+
"tokens",
30+
"traits",
31+
"utilities",
32+
]

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
check: githooks
2+
cargo check --no-default-features
3+
4+
check-tests: githooks
5+
cargo check --all --tests
6+
7+
test: githooks
8+
cargo test
9+
10+
GITHOOKS_SRC = $(wildcard githooks/*)
11+
GITHOOKS_DEST = $(patsubst githooks/%, .git/hooks/%, $(GITHOOKS_SRC))
12+
13+
.git/hooks:
14+
mkdir .git/hooks
15+
16+
.git/hooks/%: githooks/%
17+
cp $^ $@
18+
19+
githooks: .git/hooks $(GITHOOKS_DEST)
20+
21+
init: githooks

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
11
# open-runtime-module-library
2-
Substrate Open Runtime Module Library
2+
The Open Runtime Module Library (ORML) is a community maintained collection of Substrate runtime modules.
3+
4+
## Runtime modules
5+
6+
- orml-traits
7+
- Shared traits including `MultiCurrency`.
8+
- orml-tokens
9+
- Fungible tokens module that implements `MultiCurrency` trait.
10+
- orml-oracle
11+
- Oracle module that makes off-chain data available on-chain.
12+
13+
## Makefile targets
14+
15+
- `make check`
16+
- Type check the code, without std feature, exclduing tests.
17+
- `make check-tests`
18+
- Type check the code, with std feature, including tests.
19+
- `make test`
20+
- Run tests.

oracle/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "orml-oracle"
3+
version = "0.0.1"
4+
authors = ["Laminar Developers <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
serde = { version = "1.0", optional = true }
9+
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
10+
sr-primitives = { git = "https://github.com/paritytech/substrate.git", default-features = false }
11+
support = { package = "srml-support", git = "https://github.com/paritytech/substrate.git", default-features = false }
12+
system = { package = "srml-system", git = "https://github.com/paritytech/substrate.git", default-features = false }
13+
runtime_io = { package = "sr-io", git = "https://github.com/paritytech/substrate.git", default-features = false }
14+
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate.git", default-features = false }
15+
16+
traits = { package = "orml-traits", path = "../traits", default-features = false }
17+
utilities = { package = "orml-utilities", path = "../utilities", default-features = false }
18+
19+
[features]
20+
default = ["std"]
21+
std = [
22+
"serde",
23+
"codec/std",
24+
"sr-primitives/std",
25+
"support/std",
26+
"system/std",
27+
"runtime_io/std",
28+
"rstd/std",
29+
"traits/std",
30+
"utilities/std",
31+
]

oracle/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![cfg_attr(not(feature = "std"), no_std)]
2+
3+
use support::{decl_event, decl_module, decl_storage};
4+
5+
pub trait Trait: system::Trait {
6+
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
7+
}
8+
9+
decl_storage! {
10+
trait Store for Module<T: Trait> as Oracle {
11+
12+
}
13+
}
14+
15+
decl_event!(
16+
pub enum Event<T> where
17+
<T as system::Trait>::AccountId
18+
{
19+
Dummy(AccountId),
20+
}
21+
);
22+
23+
decl_module! {
24+
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
25+
fn deposit_event() = default;
26+
27+
}
28+
}
29+
30+
impl<T: Trait> Module<T> {}

rust-toolchain

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nightly

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fn main() {
2+
}

tokens/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "orml-tokens"
3+
version = "0.0.1"
4+
authors = ["Laminar Developers <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
serde = { version = "1.0", optional = true }
9+
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
10+
sr-primitives = { git = "https://github.com/paritytech/substrate.git", default-features = false }
11+
support = { package = "srml-support", git = "https://github.com/paritytech/substrate.git", default-features = false }
12+
system = { package = "srml-system", git = "https://github.com/paritytech/substrate.git", default-features = false }
13+
runtime_io = { package = "sr-io", git = "https://github.com/paritytech/substrate.git", default-features = false }
14+
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate.git", default-features = false }
15+
16+
traits = { package = "orml-traits", path = "../traits", default-features = false }
17+
utilities = { package = "orml-utilities", path = "../utilities", default-features = false }
18+
19+
[features]
20+
default = ["std"]
21+
std = [
22+
"serde",
23+
"codec/std",
24+
"sr-primitives/std",
25+
"support/std",
26+
"system/std",
27+
"runtime_io/std",
28+
"rstd/std",
29+
"traits/std",
30+
"utilities/std"
31+
]

tokens/src/lib.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#![cfg_attr(not(feature = "std"), no_std)]
2+
3+
use support::{decl_event, decl_module, decl_storage};
4+
use traits::MultiCurrency;
5+
6+
pub trait Trait: system::Trait {
7+
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
8+
}
9+
10+
decl_storage! {
11+
trait Store for Module<T: Trait> as Tokens {
12+
13+
}
14+
}
15+
16+
decl_event!(
17+
pub enum Event<T> where
18+
<T as system::Trait>::AccountId
19+
{
20+
Dummy(AccountId),
21+
}
22+
);
23+
24+
decl_module! {
25+
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
26+
fn deposit_event() = default;
27+
28+
}
29+
}
30+
31+
impl<T: Trait> Module<T> {}
32+
33+
impl<T: Trait> MultiCurrency for Module<T> {}

traits/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "orml-traits"
3+
version = "0.0.1"
4+
authors = ["Laminar Developers <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
serde = { version = "1.0", optional = true }
9+
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
10+
sr-primitives = { git = "https://github.com/paritytech/substrate.git", default-features = false }
11+
support = { package = "srml-support", git = "https://github.com/paritytech/substrate.git", default-features = false }
12+
system = { package = "srml-system", git = "https://github.com/paritytech/substrate.git", default-features = false }
13+
runtime_io = { package = "sr-io", git = "https://github.com/paritytech/substrate.git", default-features = false }
14+
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate.git", default-features = false }
15+
16+
[features]
17+
default = ["std"]
18+
std = [
19+
"serde",
20+
"codec/std",
21+
"sr-primitives/std",
22+
"support/std",
23+
"system/std",
24+
"runtime_io/std",
25+
"rstd/std",
26+
]

traits/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![cfg_attr(not(feature = "std"), no_std)]
2+
3+
pub trait MultiCurrency {
4+
5+
}

utilities/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "orml-utilities"
3+
version = "0.0.1"
4+
authors = ["Laminar Developers <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
serde = { version = "1.0", optional = true }
9+
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
10+
sr-primitives = { git = "https://github.com/paritytech/substrate.git", default-features = false }
11+
support = { package = "srml-support", git = "https://github.com/paritytech/substrate.git", default-features = false }
12+
system = { package = "srml-system", git = "https://github.com/paritytech/substrate.git", default-features = false }
13+
runtime_io = { package = "sr-io", git = "https://github.com/paritytech/substrate.git", default-features = false }
14+
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate.git", default-features = false }
15+
16+
[features]
17+
default = ["std"]
18+
std = [
19+
"serde",
20+
"codec/std",
21+
"sr-primitives/std",
22+
"support/std",
23+
"system/std",
24+
"runtime_io/std",
25+
"rstd/std",
26+
]

utilities/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![cfg_attr(not(feature = "std"), no_std)]
2+
3+
pub fn add(a: u32, b: u32) -> u32 {
4+
a + b
5+
}
6+
7+
pub fn test() -> Vec<u32> {
8+
vec![1]
9+
}
10+
11+
#[cfg(test)]
12+
mod tests {
13+
use super::*;
14+
15+
#[test]
16+
fn it_works() {
17+
assert_eq!(add(1, 1), 2);
18+
}
19+
}

0 commit comments

Comments
 (0)