Skip to content

Commit

Permalink
Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bitzoic committed Nov 10, 2023
1 parent f98c3a4 commit 1758a6f
Show file tree
Hide file tree
Showing 20 changed files with 423 additions and 115 deletions.
5 changes: 4 additions & 1 deletion libs/merkle_proof/src/binary_merkle_proof.sw
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ pub fn process_proof(
proof: Vec<b256>,
) -> b256 {
let proof_length = proof.len();
require((num_leaves > 1 && proof_length == path_length_from_key(key, num_leaves)) || (num_leaves <= 1 && proof_length == 0), ProofError::InvalidProofLength);
require(
(num_leaves > 1 && proof_length == path_length_from_key(key, num_leaves)) || (num_leaves <= 1 && proof_length == 0),
ProofError::InvalidProofLength,
);
require(key < num_leaves, ProofError::InvalidKey);

let mut digest = merkle_leaf;
Expand Down
12 changes: 10 additions & 2 deletions libs/ownership/src/ownable.sw
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ impl StorageKey<Ownership> {
/// ```
#[storage(read)]
pub fn only_owner(self) {
require(self.owner() == State::Initialized(msg_sender().unwrap()), AccessError::NotOwner);
require(
self
.owner() == State::Initialized(msg_sender().unwrap()),
AccessError::NotOwner,
);
}
}

Expand Down Expand Up @@ -217,7 +221,11 @@ impl StorageKey<Ownership> {
/// ```
#[storage(read, write)]
pub fn set_ownership(self, new_owner: Identity) {
require(self.owner() == State::Uninitialized, AccessError::CannotReinitialized);
require(
self
.owner() == State::Uninitialized,
AccessError::CannotReinitialized,
);

self.write(Ownership::initialized(new_owner));

Expand Down
36 changes: 28 additions & 8 deletions libs/signed_integers/src/i128.sw
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,32 @@ impl core::ops::Divide for I128 {
|| self.underlying == Self::indent())
&& divisor.underlying > Self::indent()
{
res = Self::from_uint((self.underlying - Self::indent()) / (divisor.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) / (divisor
.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& divisor.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) / (Self::indent() - divisor.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) / (Self::indent() - divisor
.underlying) + Self::indent(),
);
} else if (self.underlying > Self::indent()
|| self.underlying == Self::indent())
&& divisor.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor
.underlying),
);
} else if self.underlying < Self::indent()
&& divisor.underlying > Self::indent()
{
res = Self::from_uint(Self::indent() - (Self::indent() - self.underlying) / (divisor.underlying - Self::indent()));
res = Self::from_uint(
Self::indent() - (Self::indent() - self.underlying) / (divisor
.underlying - Self::indent()),
);
}
res
}
Expand All @@ -278,21 +290,29 @@ impl core::ops::Multiply for I128 {
&& (other.underlying > Self::indent()
|| other.underlying == Self::indent())
{
res = Self::from_uint((self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& other.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent(),
);
} else if (self.underlying > Self::indent()
|| self.underlying == Self::indent())
&& other.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying),
);
} else if self.underlying < Self::indent()
&& (other.underlying > Self::indent()
|| other.underlying == Self::indent())
{
res = Self::from_uint(Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying));
res = Self::from_uint(
Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying),
);
}
res
}
Expand Down
36 changes: 28 additions & 8 deletions libs/signed_integers/src/i16.sw
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,31 @@ impl core::ops::Divide for I16 {
if self.underlying >= Self::indent()
&& divisor.underlying > Self::indent()
{
res = Self::from_uint((self.underlying - Self::indent()) / (divisor.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) / (divisor
.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& divisor.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) / (Self::indent() - divisor.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) / (Self::indent() - divisor
.underlying) + Self::indent(),
);
} else if self.underlying >= Self::indent()
&& divisor.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor
.underlying),
);
} else if self.underlying < Self::indent()
&& divisor.underlying > Self::indent()
{
res = Self::from_uint(Self::indent() - (Self::indent() - self.underlying) / (divisor.underlying - Self::indent()));
res = Self::from_uint(
Self::indent() - (Self::indent() - self.underlying) / (divisor
.underlying - Self::indent()),
);
}
res
}
Expand All @@ -262,19 +274,27 @@ impl core::ops::Multiply for I16 {
if self.underlying >= Self::indent()
&& other.underlying >= Self::indent()
{
res = Self::from_uint((self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& other.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent(),
);
} else if self.underlying >= Self::indent()
&& other.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying),
);
} else if self.underlying < Self::indent()
&& other.underlying >= Self::indent()
{
res = Self::from_uint(Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying));
res = Self::from_uint(
Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying),
);
}
res
}
Expand Down
36 changes: 28 additions & 8 deletions libs/signed_integers/src/i256.sw
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,32 @@ impl core::ops::Divide for I256 {
let self_ge_indent = self.underlying > Self::indent() || self.underlying == Self::indent();
let divisor_gt_indent = divisor.underlying > Self::indent();
if self_ge_indent && divisor_gt_indent {
res = Self::from_uint((self.underlying - Self::indent()) / (divisor.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) / (divisor
.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& divisor.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) / (Self::indent() - divisor.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) / (Self::indent() - divisor
.underlying) + Self::indent(),
);
} else if (self.underlying > Self::indent()
|| self.underlying == Self::indent())
&& divisor.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor
.underlying),
);
} else if self.underlying < Self::indent()
&& divisor.underlying > Self::indent()
{
res = Self::from_uint(Self::indent() - (Self::indent() - self.underlying) / (divisor.underlying - Self::indent()));
res = Self::from_uint(
Self::indent() - (Self::indent() - self.underlying) / (divisor
.underlying - Self::indent()),
);
}
res
}
Expand All @@ -277,21 +289,29 @@ impl core::ops::Multiply for I256 {
&& (other.underlying > Self::indent()
|| other.underlying == Self::indent())
{
res = Self::from_uint((self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& other.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent(),
);
} else if (self.underlying > Self::indent()
|| self.underlying == Self::indent())
&& other.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying),
);
} else if self.underlying < Self::indent()
&& (other.underlying > Self::indent()
|| other.underlying == Self::indent())
{
res = Self::from_uint(Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying));
res = Self::from_uint(
Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying),
);
}
res
}
Expand Down
36 changes: 28 additions & 8 deletions libs/signed_integers/src/i32.sw
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,27 @@ impl core::ops::Multiply for I32 {
if self.underlying >= Self::indent()
&& other.underlying >= Self::indent()
{
res = Self::from_uint((self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& other.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent(),
);
} else if self.underlying >= Self::indent()
&& other.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying),
);
} else if self.underlying < Self::indent()
&& other.underlying >= Self::indent()
{
res = Self::from_uint(Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying));
res = Self::from_uint(
Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying),
);
}
res
}
Expand All @@ -294,19 +302,31 @@ impl core::ops::Divide for I32 {
if self.underlying >= Self::indent()
&& divisor.underlying > Self::indent()
{
res = Self::from_uint((self.underlying - Self::indent()) / (divisor.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) / (divisor
.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& divisor.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) / (Self::indent() - divisor.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) / (Self::indent() - divisor
.underlying) + Self::indent(),
);
} else if self.underlying >= Self::indent()
&& divisor.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor
.underlying),
);
} else if self.underlying < Self::indent()
&& divisor.underlying > Self::indent()
{
res = Self::from_uint(Self::indent() - (Self::indent() - self.underlying) / (divisor.underlying - Self::indent()));
res = Self::from_uint(
Self::indent() - (Self::indent() - self.underlying) / (divisor
.underlying - Self::indent()),
);
}
res
}
Expand Down
36 changes: 28 additions & 8 deletions libs/signed_integers/src/i64.sw
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,27 @@ impl core::ops::Multiply for I64 {
if self.underlying >= Self::indent()
&& other.underlying >= Self::indent()
{
res = Self::from_uint((self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) * (other.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& other.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) * (Self::indent() - other.underlying) + Self::indent(),
);
} else if self.underlying >= Self::indent()
&& other.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) * (Self::indent() - other.underlying),
);
} else if self.underlying < Self::indent()
&& other.underlying >= Self::indent()
{
res = Self::from_uint(Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying));
res = Self::from_uint(
Self::indent() - (other.underlying - Self::indent()) * (Self::indent() - self.underlying),
);
}
res
}
Expand All @@ -295,19 +303,31 @@ impl core::ops::Divide for I64 {
if self.underlying >= Self::indent()
&& divisor.underlying > Self::indent()
{
res = Self::from_uint((self.underlying - Self::indent()) / (divisor.underlying - Self::indent()) + Self::indent());
res = Self::from_uint(
(self.underlying - Self::indent()) / (divisor
.underlying - Self::indent()) + Self::indent(),
);
} else if self.underlying < Self::indent()
&& divisor.underlying < Self::indent()
{
res = Self::from_uint((Self::indent() - self.underlying) / (Self::indent() - divisor.underlying) + Self::indent());
res = Self::from_uint(
(Self::indent() - self.underlying) / (Self::indent() - divisor
.underlying) + Self::indent(),
);
} else if self.underlying >= Self::indent()
&& divisor.underlying < Self::indent()
{
res = Self::from_uint(Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor.underlying));
res = Self::from_uint(
Self::indent() - (self.underlying - Self::indent()) / (Self::indent() - divisor
.underlying),
);
} else if self.underlying < Self::indent()
&& divisor.underlying > Self::indent()
{
res = Self::from_uint(Self::indent() - (Self::indent() - self.underlying) / (divisor.underlying - Self::indent()));
res = Self::from_uint(
Self::indent() - (Self::indent() - self.underlying) / (divisor
.underlying - Self::indent()),
);
}
res
}
Expand Down
Loading

0 comments on commit 1758a6f

Please sign in to comment.