Skip to content

Commit 966f672

Browse files
author
Guillermo Bescos
committed
Format
1 parent 1857314 commit 966f672

File tree

10 files changed

+75
-13
lines changed

10 files changed

+75
-13
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Check Formatting
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
profile: minimal
17+
toolchain: nightly
18+
components: rustfmt
19+
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.2.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-added-large-files
8+
- repo: local
9+
hooks:
10+
- id: cargo-fmt-nightly
11+
name: Cargo Fmt Nightly
12+
language: "rust"
13+
entry: cargo +nightly fmt
14+
pass_filenames: false

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[workspace]
2+
members = [
3+
"program/rust"
4+
]

program/rust/.gitignore

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

program/rust/build_utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ impl<'a> DeriveAdderParserCallback<'a> {
2424
}
2525

2626
//this is required to implement the callback trait
27-
impl UnwindSafe for DeriveAdderParserCallback<'_> {}
27+
impl UnwindSafe for DeriveAdderParserCallback<'_> {
28+
}
2829

2930
impl ParseCallbacks for DeriveAdderParserCallback<'_> {
3031
fn add_derives(&self, _name: &str) -> Vec<String> {

program/rust/src/c_oracle_header.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
#![allow(unused_variables)]
66
#![allow(dead_code)]
77
//All the custom trait imports should go here
8-
use borsh::{BorshDeserialize, BorshSerialize};
8+
use borsh::{
9+
BorshDeserialize,
10+
BorshSerialize,
11+
};
912
//bindings.rs is generated by build.rs to include
1013
//things defined in bindings.h
1114
include!("../bindings.rs");

program/rust/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ pub type OracleResult = Result<u64, ProgramError>;
1010
pub enum OracleError {
1111
/// Generic catch all error
1212
#[error("Generic")]
13-
Generic = 600,
13+
Generic = 600,
1414
/// integer casting error
1515
#[error("IntegerCastingError")]
1616
IntegerCastingError = 601,
1717
/// c_entrypoint returned an unexpected value
1818
#[error("UnknownCError")]
19-
UnknownCError = 602,
19+
UnknownCError = 602,
2020
}
2121

2222
impl From<OracleError> for ProgramError {

program/rust/src/lib.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ mod rust_oracle;
66
mod time_machine_types;
77

88
use crate::c_oracle_header::SUCCESSFULLY_UPDATED_AGGREGATE;
9-
use crate::error::{OracleError, OracleResult};
10-
use crate::log::{post_log, pre_log};
9+
use crate::error::{
10+
OracleError,
11+
OracleResult,
12+
};
13+
use crate::log::{
14+
post_log,
15+
pre_log,
16+
};
1117
use processor::process_instruction;
18+
use solana_program::entrypoint::deserialize;
1219
use solana_program::program_error::ProgramError;
13-
use solana_program::{custom_heap_default, custom_panic_default, entrypoint::deserialize};
20+
use solana_program::{
21+
custom_heap_default,
22+
custom_panic_default,
23+
};
1424

1525
//Below is a high lever description of the rust/c setup.
1626

program/rust/src/processor.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
use crate::c_entrypoint_wrapper;
22
use crate::c_oracle_header::{
3-
cmd_hdr, command_t_e_cmd_agg_price, command_t_e_cmd_upd_account_version,
4-
command_t_e_cmd_upd_price, command_t_e_cmd_upd_price_no_fail_on_error, PC_VERSION,
3+
cmd_hdr,
4+
command_t_e_cmd_agg_price,
5+
command_t_e_cmd_upd_account_version,
6+
command_t_e_cmd_upd_price,
7+
command_t_e_cmd_upd_price_no_fail_on_error,
8+
PC_VERSION,
9+
};
10+
use crate::error::{
11+
OracleError,
12+
OracleResult,
13+
};
14+
use crate::rust_oracle::{
15+
update_price,
16+
update_version,
517
};
6-
use crate::error::{OracleError, OracleResult};
7-
use crate::rust_oracle::{update_price, update_version};
818
use ::std::mem::size_of;
919
use borsh::BorshDeserialize;
1020
use solana_program::pubkey::Pubkey;

program/rust/src/rust_oracle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ pub fn update_price(
1010
instruction_data: &[u8],
1111
input: *mut u8,
1212
) -> OracleResult {
13-
//For now, we did not change the behavior of this. this is just to show the proposed structure of the
14-
//program
13+
//For now, we did not change the behavior of this. this is just to show the proposed structure
14+
// of the program
1515
c_entrypoint_wrapper(input)
1616
}
1717
/// has version number/ account type dependant logic to make sure the given account is compatible

0 commit comments

Comments
 (0)