Skip to content

Commit

Permalink
scarb fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lana-shanghai committed Dec 12, 2024
1 parent cfb2719 commit 0c25ea2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/onchain/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod escrow;
mod orderbook;
mod utils;
mod relay;
mod relay;
8 changes: 6 additions & 2 deletions packages/onchain/src/orderbook/orderbook.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ mod Orderbook {
}

#[constructor]
fn constructor(ref self: ContractState, strk_token: ContractAddress, relay_address: ContractAddress) {
fn constructor(
ref self: ContractState, strk_token: ContractAddress, relay_address: ContractAddress,
) {
// initialize contract
self.initializer(:strk_token, :relay_address);
}
Expand Down Expand Up @@ -192,7 +194,9 @@ mod Orderbook {
pub impl InternalImpl of InternalTrait {
/// Executed once when the Orderbook contract is deployed. Used to set
/// initial values for contract storage variables for the fee tokens.
fn initializer(ref self: ContractState, strk_token: ContractAddress, relay_address: ContractAddress) {
fn initializer(
ref self: ContractState, strk_token: ContractAddress, relay_address: ContractAddress,
) {
self.strk_token.write(ERC20ABIDispatcher { contract_address: strk_token });
self.relay_address.write(relay_address);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/onchain/src/relay.cairo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mod relay;
mod relay;
11 changes: 6 additions & 5 deletions packages/onchain/src/relay/relay.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub trait ITransactionInclusion<TContractState> {
tx_id: Digest,
block_height: u64,
block_header: BlockHeader,
tx_inclusion: Array<(Digest, bool)>
tx_inclusion: Array<(Digest, bool)>,
);
}

Expand All @@ -20,7 +20,7 @@ mod TransactionInclusion {
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};
use utils::{hash::Digest, numeric::u32_byte_reverse};
use utu_relay::{
interfaces::{IUtuRelayDispatcher, IUtuRelayDispatcherTrait}, bitcoin::block::BlockHeader
interfaces::{IUtuRelayDispatcher, IUtuRelayDispatcherTrait}, bitcoin::block::BlockHeader,
};

#[storage]
Expand All @@ -40,12 +40,13 @@ mod TransactionInclusion {
tx_id: Digest,
block_height: u64,
block_header: BlockHeader,
tx_inclusion: Array<(Digest, bool)>
tx_inclusion: Array<(Digest, bool)>,
) {
// we verify this tx is included in the provided block
let merkle_root = compute_merkle_root(tx_id, tx_inclusion);
assert(
block_header.merkle_root_hash.value == merkle_root.value, 'Invalid inclusion proof.'
block_header.merkle_root_hash.value == merkle_root.value,
'Invalid inclusion proof.',
);

// we verify this block is safe to use (part of the canonical chain & sufficient pow)
Expand All @@ -57,4 +58,4 @@ mod TransactionInclusion {
assert(block_time <= get_block_timestamp(), 'Block comes from the future.');
}
}
}
}
6 changes: 3 additions & 3 deletions packages/onchain/src/utils/utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use utils::double_sha256::double_sha256_parent;
///
/// Arguments:
/// - `tx_hash: Digest`: The transaction hash as a Digest
/// - `siblings: Array<(Digest, bool)>`: An array of tuples (Digest, bool), where the bool indicates if the sibling is on
/// the right
/// - `siblings: Array<(Digest, bool)>`: An array of tuples (Digest, bool), where the bool indicates
/// if the sibling is on the right
///
/// Returns:
/// - `Digest`: The computed Merkle root as a Digest
Expand Down Expand Up @@ -34,4 +34,4 @@ pub fn compute_merkle_root(tx_hash: Digest, siblings: Array<(Digest, bool)>) ->
};

current_hash
}
}

0 comments on commit 0c25ea2

Please sign in to comment.