Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from zoedberg/lint
Browse files Browse the repository at this point in the history
Lint: add rustfmt config and CI workflow
  • Loading branch information
dr-orlovsky authored Oct 31, 2020
2 parents 1114995 + af10b41 commit ab59c77
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lints

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install rust 1.47.0
uses: actions-rs/toolchain@v1
with:
toolchain: 1.47.0
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
name: Lints
with:
command: fmt
args: --manifest-path rust-lib/Cargo.toml --all -- --check
3 changes: 3 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
max_width = 80
wrap_comments = true
format_code_in_doc_comments = true
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RGB SDK

![Lints](https://github.com/LNP-BP/rgb-sdk/workflows/Lints/badge.svg)

This repository contains FFI bindings and SDK for wallet & server-side development,
plus some sample applications

Expand Down
21 changes: 15 additions & 6 deletions rust-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ trait CReturnType: Sized + 'static {

if other.ty != ty {
return Err(RequestError::Runtime(
rgb::error::BootstrapError::ArgParseError("Type mismatch".to_string()),
rgb::error::BootstrapError::ArgParseError(
"Type mismatch".to_string(),
),
));
}

Expand Down Expand Up @@ -166,8 +168,9 @@ fn _start_rgb(
let network = bp::Chain::from_str(c_network.to_str()?)?;

let c_stash_endpoint = unsafe { CStr::from_ptr(stash_endpoint) };
let stash_endpoint =
SocketLocator::Posix(path::PathBuf::from(c_stash_endpoint.to_str()?.to_string()));
let stash_endpoint = SocketLocator::Posix(path::PathBuf::from(
c_stash_endpoint.to_str()?.to_string(),
));

let contract_endpoints: HashMap<ContractName, String> =
serde_json::from_str(&ptr_to_string(contract_endpoints)?)?;
Expand Down Expand Up @@ -195,7 +198,9 @@ fn _start_rgb(

#[cfg(target_os = "android")]
fn start_logger() {
android_logger::init_once(android_logger::Config::default().with_min_level(log::Level::Debug));
android_logger::init_once(
android_logger::Config::default().with_min_level(log::Level::Debug),
);
}

#[cfg(not(target_os = "android"))]
Expand Down Expand Up @@ -243,7 +248,10 @@ struct IssueArgs {
prune_seals: Vec<SealSpec>,
}

fn _issue(runtime: &COpaqueStruct, json: *mut c_char) -> Result<(), RequestError> {
fn _issue(
runtime: &COpaqueStruct,
json: *mut c_char,
) -> Result<(), RequestError> {
let runtime = Runtime::from_opaque(runtime)?;
let data: IssueArgs = serde_json::from_str(&ptr_to_string(json)?)?;
info!("{:?}", data);
Expand Down Expand Up @@ -280,7 +288,8 @@ fn _transfer(

let inputs: Vec<OutPoint> = serde_json::from_str(&ptr_to_string(inputs)?)?;

let allocate: Vec<Outcoins> = serde_json::from_str(&ptr_to_string(allocate)?)?;
let allocate: Vec<Outcoins> =
serde_json::from_str(&ptr_to_string(allocate)?)?;

let c_invoice = unsafe { CStr::from_ptr(invoice) };
let invoice = Invoice::from_str(c_invoice.to_str()?)?;
Expand Down

0 comments on commit ab59c77

Please sign in to comment.