Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
chore: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
akorchyn committed Sep 9, 2024
1 parent a681d02 commit b8f1c38
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,20 @@ jobs:
- name: run cargo doc
run: RUSTDOCFLAGS="-D warnings" cargo doc

check-windows:
needs: cargo-fmt
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- name: Run cargo check
run: cargo check --all-targets

test:
needs: cargo-fmt
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
platform: [ubuntu-latest, macos-latest]
toolchain: [stable]
runs-on: ${{ matrix.platform }}

Expand Down
4 changes: 2 additions & 2 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub struct DeployContractBuilder {
}

impl DeployContractBuilder {
pub fn new(contract: AccountId, code: Vec<u8>) -> Self {
pub const fn new(contract: AccountId, code: Vec<u8>) -> Self {
Self { contract, code }
}

Expand Down Expand Up @@ -186,7 +186,7 @@ pub struct ContractTransactBuilder {
}

impl ContractTransactBuilder {
fn new(
const fn new(
contract: AccountId,
method_name: String,
args: Vec<u8>,
Expand Down
11 changes: 5 additions & 6 deletions src/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,14 @@ impl Signer {
.access_key(public_key.clone())
.fetch_from(network)
.await?;
let nonce_cache = self.nonce_cache.read().await;

if let Some(nonce) = self
.nonce_cache
.read()
.await
.get(&(account_id.clone(), public_key.clone()))
{
if let Some(nonce) = nonce_cache.get(&(account_id.clone(), public_key.clone())) {
let nonce = nonce.fetch_add(1, Ordering::SeqCst);
drop(nonce_cache);
return Ok((nonce + 1, nonce_data.block_hash, nonce_data.block_height));
} else {
drop(nonce_cache);
}

// It's initialization, so it's better to take write lock, so other will wait
Expand Down
4 changes: 2 additions & 2 deletions src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct ConstructTransaction {
}

impl ConstructTransaction {
pub fn new(signer_id: AccountId, receiver_id: AccountId) -> Self {
pub const fn new(signer_id: AccountId, receiver_id: AccountId) -> Self {
Self {
tr: PrepopulateTransaction {
signer_id,
Expand Down Expand Up @@ -71,7 +71,7 @@ impl Transactionable for ConstructTransaction {
pub struct Transaction;

impl Transaction {
pub fn construct(signer_id: AccountId, receiver_id: AccountId) -> ConstructTransaction {
pub const fn construct(signer_id: AccountId, receiver_id: AccountId) -> ConstructTransaction {
ConstructTransaction::new(signer_id, receiver_id)
}

Expand Down

0 comments on commit b8f1c38

Please sign in to comment.