|
| 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