Skip to content

Commit 3a4fd33

Browse files
authored
Merge pull request #3 from 589labs/develop
Initial Core
2 parents 78e3e1b + 723ee14 commit 3a4fd33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+18925
-2
lines changed

.cargo-husky/hooks/pre-commit

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
4+
echo 'Running all pre-commit checks:'
5+
cargo fmt
6+
cargo test --no-default-features --features core,models,utils
7+
cargo test --all-features
8+
cargo clippy --fix --allow-staged
9+
cargo doc --no-deps
10+
#cargo audit

.github/issue_template.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Expected Behavior
2+
<!--- Tell us what should happen -->
3+
4+
## Actual Behavior
5+
<!--- Tell us what happens instead of the expected behavior -->
6+
7+
## Steps to Reproduce the Problem
8+
<!--- Provide the steps that resulted in the unexpected behavior -->
9+
1.
10+
1.
11+
1.
12+
13+
## Minimal Reproducable Example
14+
<!--- Provide a minimal reproducible example to test against -->
15+
```rust
16+
17+
```
18+
19+
## Specifications
20+
<!--- Provide details on the platform, version, flags -->
21+
- Version:
22+
- Platform:
23+
- Flags:
24+
25+
## Detailed Description
26+
<!--- Provide a detailed description of the issue -->

.github/pull_request_template.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## High Level Overview of Change
2+
3+
<!--
4+
Please include a summary/list of the changes.
5+
If too broad, please consider splitting into multiple PRs.
6+
If a relevant Asana task, please link it here.
7+
-->
8+
9+
### Context of Change
10+
11+
<!--
12+
Please include the context of a change.
13+
If a bug fix, when was the bug introduced? What was the behavior?
14+
If a new feature, why was this architecture chosen? What were the alternatives?
15+
If a refactor, how is this better than the previous implementation?
16+
17+
If there is a design document for this feature, please link it here.
18+
-->
19+
20+
### Type of Change
21+
22+
<!--
23+
Please check relevant options, delete irrelevant ones.
24+
-->
25+
26+
- [ ] Bug fix (non-breaking change which fixes an issue)
27+
- [ ] New feature (non-breaking change which adds functionality)
28+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
29+
- [ ] Refactor (non-breaking change that only restructures code)
30+
- [ ] Tests (You added tests for code that already exists, or your new feature included in this PR)
31+
- [ ] Documentation Updates
32+
- [ ] Release
33+
34+
## Before / After
35+
36+
<!--
37+
If just refactoring / back-end changes, this can be just an in-English description of the change at a technical level.
38+
If a UI change, screenshots should be included.
39+
-->
40+
41+
## Test Plan
42+
43+
<!--
44+
Please describe the tests that you ran to verify your changes and provide instructions so that others can reproduce.
45+
-->
46+
47+
<!--
48+
## Future Tasks
49+
For future tasks related to PR.
50+
-->

.github/workflows/audit_test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
on:
2+
push:
3+
branches:
4+
- develop
5+
pull_request:
6+
branches:
7+
- main
8+
schedule:
9+
- cron: '0 0 * * *'
10+
11+
name: Audit
12+
13+
jobs:
14+
audit:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v1
18+
- uses: actions-rs/audit-check@v1
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/quality_test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
on:
2+
push:
3+
branches:
4+
- develop
5+
pull_request:
6+
branches:
7+
- main
8+
9+
name: Quality
10+
11+
jobs:
12+
clippy_check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v1
16+
- run: rustup component add clippy
17+
- uses: actions-rs/clippy-check@v1
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
args: --all-features

.github/workflows/unit_test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
push:
3+
branches:
4+
- develop
5+
pull_request:
6+
branches:
7+
- main
8+
9+
name: Unit
10+
11+
jobs:
12+
build_and_test:
13+
name: xrpl-rust
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions-rs/toolchain@v1
18+
with:
19+
toolchain: stable
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: build
23+
args: --release --all-features
24+
- uses: actions-rs/cargo@v1
25+
with:
26+
command: build
27+
args: --release --no-default-features --features core,models
28+
- uses: actions-rs/cargo@v1
29+
with:
30+
command: test
31+
args: --all-features
32+
- uses: actions-rs/cargo@v1
33+
with:
34+
command: test
35+
args: --no-default-features --features core,models

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@ Cargo.lock
88

99
# These are backup files generated by rustfmt
1010
**/*.rs.bk
11+
12+
# Added by cargo
13+
/target
14+
15+
# VSCode
16+
.vscode
17+
18+
# Additional
19+
src/main.rs

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [[Incomplete]]
9+
- Support for no_std environments
10+
## [[Unreleased]]
11+
### Modified
12+
- Use the core hex library
13+
### Added
14+
- Initial Implementation

CODEOWNERS

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

CONTRIBUTING.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Contributing
2+
3+
## Setup Your Development Environment
4+
5+
If you want to contribute code to `xrpl-rust`, the following sections describe
6+
how to set up your developer environment.
7+
8+
### Setup the Rust/Cargo Environment
9+
10+
Getting started with Rust and `xrpl-rust` is easy. To install `rust` and
11+
`cargo` follow these steps:
12+
13+
* Install [`rust`](https://doc.rust-lang.org/cargo/getting-started/installation.html):
14+
15+
curl https://sh.rustup.rs -sSf | sh
16+
17+
* Update rust using `rustup` and install a few development dependencies:
18+
19+
// Rustup
20+
rustup update
21+
rustup component add rustfmt
22+
rustup component add clippy-preview
23+
24+
// Cargo
25+
cargo install cargo-audit
26+
27+
### Git `pre-commit` Hooks
28+
29+
To run linting and other checks, `xrpl-rust` uses
30+
[`pre-commit`](https://pre-commit.com/).
31+
32+
> This should already be setup thanks to
33+
[`cargo-husky`](https://github.com/rhysd/cargo-husky)
34+
35+
### Run the Formatter
36+
37+
To run the linter:
38+
39+
```bash
40+
cargo fmt
41+
```
42+
43+
> Note that the formatter will automatically run via pre-commit hook
44+
45+
### Run the Linter
46+
47+
To run the linter:
48+
49+
```bash
50+
cargo clippy
51+
```
52+
53+
> Note that the linter will automatically run via pre-commit hook
54+
55+
### Running Tests
56+
57+
To run tests:
58+
59+
```bash
60+
# Test the core feature for no_std
61+
cargo test --no-default-features --features core,models,utils
62+
# Test all features enabled
63+
cargo test --all-features
64+
```
65+
66+
> Note that the tests will automatically run via pre-commit hook
67+
68+
### Generate Documentation
69+
70+
You can see the complete reference documentation at
71+
[`xrpl-rust` docs](https://docs.rs/xrpl).
72+
73+
You can also generate them locally using `cargo`:
74+
75+
```bash
76+
cargo doc
77+
```
78+
79+
### Audit Crates
80+
81+
To test dependencies for known security advisories, run:
82+
83+
```bash
84+
cargo audit
85+
```
86+
87+
### Submitting Bugs
88+
89+
Bug reports are welcome. Please create an issue using the default issue
90+
template. Fill in *all* information including a minimal reproducible
91+
code example. Every function in the library comes with such an example
92+
and can adapted to look like the following for an issue report:
93+
94+
```rust
95+
// Required Dependencies
96+
use xrpl::core::keypairs::derive_keypair;
97+
use xrpl::core::keypairs::exceptions::XRPLKeypairsException;
98+
99+
// Provided Variables
100+
let seed: &str = "sn259rEFXrQrWyx3Q7XneWcwV6dfL";
101+
let validator: bool = false;
102+
103+
// Expected Result
104+
let tuple: (String, String) = (
105+
"ED60292139838CB86E719134F848F055057CA5BDA61F5A529729F1697502D53E1C".into(),
106+
"ED009F66528611A0D400946A01FA01F8AF4FF4C1D0C744AE3F193317DCA77598F1".into(),
107+
);
108+
109+
// Operation
110+
match derive_keypair(seed, validator) {
111+
Ok(seed) => assert_eq!(tuple, seed),
112+
Err(e) => match e {
113+
XRPLKeypairsException::InvalidSignature => panic!("Fails unexpectedly"),
114+
_ => (),
115+
},
116+
};
117+
```
118+
> This format makes it easy for maintainers to replicate and test against.
119+
120+
## Release Process
121+
122+
### Editing the Code
123+
124+
* Your changes should have unit and/or integration tests.
125+
* New functionality should include a minimal reproducible sample.
126+
* Your changes should pass the linter.
127+
* Your code should pass all the actions on GitHub.
128+
* Open a PR against `main` and ensure that all CI passes.
129+
* Get a full code review from one of the maintainers.
130+
* Merge your changes.
131+
132+
### Release
133+
134+
TODO

0 commit comments

Comments
 (0)