Skip to content

Commit d999ff9

Browse files
authored
Tests and linter (astraly-labs#5)
- tests moved to top level (as those seem to be intentionally moved outside packages they test - added more tests but not debugged) - fixed set_storage - ignored class_at test (devnet does not support that) - fixed all build warnings - fix all test warnings - cargo fmt - clippy errors fixed - remove bench compile errors
1 parent e53af77 commit d999ff9

36 files changed

+1511
-2207
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ starknet-core.workspace = true
125125
serde.workspace = true
126126
async-trait.workspace = true
127127
anyhow.workspace = true
128+
starknet.workspace = true
129+
url.workspace = true
128130

129131
rayon = { version = "1.10.0" }
130132

bin/bind/digest.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use config::{Config, ConfigError};
21
use serde::Deserialize;
32

43
use super::*;
@@ -31,15 +30,6 @@ impl StarkbiterConfig {
3130
}
3231
}
3332

34-
impl StarkbiterConfig {
35-
pub(crate) fn new() -> Result<Self, ConfigError> {
36-
let s = Config::builder()
37-
.add_source(config::File::with_name("arbiter.toml"))
38-
.build()?;
39-
Ok(s.into())
40-
}
41-
}
42-
4333
impl Default for StarkbiterConfig {
4434
fn default() -> Self {
4535
Self {

bin/bind/mod.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,22 @@
22
use std::{fs, path::PathBuf};
33

44
mod digest;
5-
use self::digest::StarkbiterConfig;
65
use cainome::rs::Abigen;
76
use inflector::Inflector;
87

98
/// Uses cainome from cartridge to generate bindings.
109
///
11-
/// This function takes one directory as a source path and other as a destination path.
12-
/// Searches source files for JSON files and generates Rust bindings for each one of them.
10+
/// This function takes one directory as a source path and other as a
11+
/// destination path. Searches source files for JSON files and generates Rust
12+
/// bindings for each one of them.
1313
///
1414
/// # Returns
1515
///
1616
/// * `Ok(())` if command successfully generates the bindings.
1717
/// * `Err(std::io::Error)` if the command execution fails or if there's an
1818
/// error in generating the bindings. This can also include if the `forge`
1919
/// tool is not installed.
20-
2120
pub(crate) fn cainome_bind(src: &str, dest: &str, use_debug: &bool) -> std::io::Result<()> {
22-
let arbiter_config = StarkbiterConfig::new().unwrap_or_default();
23-
// TODO: ???
24-
// let project_bidnings_output_path = arbiter_config.bindings_path;
25-
2621
let derives = if *use_debug {
2722
vec!["Debug", "PartialEq"]
2823
} else {
@@ -82,7 +77,7 @@ pub(crate) fn cainome_bind(src: &str, dest: &str, use_debug: &bool) -> std::io::
8277
if !src_file_path.is_file() {
8378
continue;
8479
}
85-
if !src_file_path.extension().map_or(false, |ext| ext == "json") {
80+
if src_file_path.extension().is_none_or(|ext| ext != "json") {
8681
continue;
8782
}
8883

bin/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! `Starkbiter` CLI Tool
44
//!
55
//! This tool is designed to facilitate the generation of contract bindings.
6-
//!
76
87
use std::env;
98

bindings/src/contracts_counter.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![allow(clippy::all)]
66
#![allow(warnings)]
77

8-
use serde::{Serialize, Deserialize};
8+
use serde::{Deserialize, Serialize};
99

1010
#[derive(Clone, Serialize, Deserialize, Debug)]
1111
pub struct ContractsCounter<A: starknet::accounts::ConnectedAccount + Sync> {
@@ -18,9 +18,7 @@ impl<A: starknet::accounts::ConnectedAccount + Sync> ContractsCounter<A> {
1818
Self {
1919
address,
2020
account,
21-
block_id: starknet::core::types::BlockId::Tag(
22-
starknet::core::types::BlockTag::Pending,
23-
),
21+
block_id: starknet::core::types::BlockId::Tag(starknet::core::types::BlockTag::Pending),
2422
}
2523
}
2624
pub fn set_contract_address(&mut self, address: starknet::core::types::Felt) {
@@ -47,9 +45,7 @@ impl<P: starknet::providers::Provider + Sync> ContractsCounterReader<P> {
4745
Self {
4846
address,
4947
provider,
50-
block_id: starknet::core::types::BlockId::Tag(
51-
starknet::core::types::BlockTag::Pending,
52-
),
48+
block_id: starknet::core::types::BlockId::Tag(starknet::core::types::BlockTag::Pending),
5349
}
5450
}
5551
pub fn set_contract_address(&mut self, address: starknet::core::types::Felt) {
@@ -89,25 +85,25 @@ impl cainome::cairo_serde::CairoSerde for Event {
8985
let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap());
9086
match __index as usize {
9187
_ => {
92-
return Err(
93-
cainome::cairo_serde::Error::Deserialize(
94-
format!("Index not handle for enum {}", "Event"),
95-
),
96-
);
88+
return Err(cainome::cairo_serde::Error::Deserialize(format!(
89+
"Index not handle for enum {}",
90+
"Event"
91+
)));
9792
}
9893
}
9994
}
10095
}
10196
impl TryFrom<&starknet::core::types::EmittedEvent> for Event {
10297
type Error = String;
103-
fn try_from(
104-
event: &starknet::core::types::EmittedEvent,
105-
) -> Result<Self, Self::Error> {
98+
fn try_from(event: &starknet::core::types::EmittedEvent) -> Result<Self, Self::Error> {
10699
use cainome::cairo_serde::CairoSerde;
107100
if event.keys.is_empty() {
108101
return Err("Event has no key".to_string());
109102
}
110-
Err(format!("Could not match any event from keys {:?}", event.keys))
103+
Err(format!(
104+
"Could not match any event from keys {:?}",
105+
event.keys
106+
))
111107
}
112108
}
113109
impl TryFrom<&starknet::core::types::Event> for Event {
@@ -117,7 +113,10 @@ impl TryFrom<&starknet::core::types::Event> for Event {
117113
if event.keys.is_empty() {
118114
return Err("Event has no key".to_string());
119115
}
120-
Err(format!("Could not match any event from keys {:?}", event.keys))
116+
Err(format!(
117+
"Could not match any event from keys {:?}",
118+
event.keys
119+
))
121120
}
122121
}
123122
impl<A: starknet::accounts::ConnectedAccount + Sync> ContractsCounter<A> {
@@ -129,8 +128,9 @@ impl<A: starknet::accounts::ConnectedAccount + Sync> ContractsCounter<A> {
129128
) -> cainome::cairo_serde::call::FCall<A::Provider, u64> {
130129
use cainome::cairo_serde::CairoSerde;
131130
let mut __calldata = vec![];
132-
__calldata
133-
.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address));
131+
__calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
132+
address,
133+
));
134134
let __call = starknet::core::types::FunctionCall {
135135
contract_address: self.address,
136136
entry_point_selector: starknet::macros::selector!("get"),
@@ -171,8 +171,9 @@ impl<P: starknet::providers::Provider + Sync> ContractsCounterReader<P> {
171171
) -> cainome::cairo_serde::call::FCall<P, u64> {
172172
use cainome::cairo_serde::CairoSerde;
173173
let mut __calldata = vec![];
174-
__calldata
175-
.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address));
174+
__calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
175+
address,
176+
));
176177
let __call = starknet::core::types::FunctionCall {
177178
contract_address: self.address,
178179
entry_point_selector: starknet::macros::selector!("get"),

bindings/src/contracts_user_values.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![allow(clippy::all)]
66
#![allow(warnings)]
77

8-
use serde::{Serialize, Deserialize};
8+
use serde::{Deserialize, Serialize};
99

1010
#[derive(Clone, Serialize, Deserialize, Debug)]
1111
pub struct ContractsUserValues<A: starknet::accounts::ConnectedAccount + Sync> {
@@ -18,9 +18,7 @@ impl<A: starknet::accounts::ConnectedAccount + Sync> ContractsUserValues<A> {
1818
Self {
1919
address,
2020
account,
21-
block_id: starknet::core::types::BlockId::Tag(
22-
starknet::core::types::BlockTag::Pending,
23-
),
21+
block_id: starknet::core::types::BlockId::Tag(starknet::core::types::BlockTag::Pending),
2422
}
2523
}
2624
pub fn set_contract_address(&mut self, address: starknet::core::types::Felt) {
@@ -47,9 +45,7 @@ impl<P: starknet::providers::Provider + Sync> ContractsUserValuesReader<P> {
4745
Self {
4846
address,
4947
provider,
50-
block_id: starknet::core::types::BlockId::Tag(
51-
starknet::core::types::BlockTag::Pending,
52-
),
48+
block_id: starknet::core::types::BlockId::Tag(starknet::core::types::BlockTag::Pending),
5349
}
5450
}
5551
pub fn set_contract_address(&mut self, address: starknet::core::types::Felt) {
@@ -89,25 +85,25 @@ impl cainome::cairo_serde::CairoSerde for Event {
8985
let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap());
9086
match __index as usize {
9187
_ => {
92-
return Err(
93-
cainome::cairo_serde::Error::Deserialize(
94-
format!("Index not handle for enum {}", "Event"),
95-
),
96-
);
88+
return Err(cainome::cairo_serde::Error::Deserialize(format!(
89+
"Index not handle for enum {}",
90+
"Event"
91+
)));
9792
}
9893
}
9994
}
10095
}
10196
impl TryFrom<&starknet::core::types::EmittedEvent> for Event {
10297
type Error = String;
103-
fn try_from(
104-
event: &starknet::core::types::EmittedEvent,
105-
) -> Result<Self, Self::Error> {
98+
fn try_from(event: &starknet::core::types::EmittedEvent) -> Result<Self, Self::Error> {
10699
use cainome::cairo_serde::CairoSerde;
107100
if event.keys.is_empty() {
108101
return Err("Event has no key".to_string());
109102
}
110-
Err(format!("Could not match any event from keys {:?}", event.keys))
103+
Err(format!(
104+
"Could not match any event from keys {:?}",
105+
event.keys
106+
))
111107
}
112108
}
113109
impl TryFrom<&starknet::core::types::Event> for Event {
@@ -117,7 +113,10 @@ impl TryFrom<&starknet::core::types::Event> for Event {
117113
if event.keys.is_empty() {
118114
return Err("Event has no key".to_string());
119115
}
120-
Err(format!("Could not match any event from keys {:?}", event.keys))
116+
Err(format!(
117+
"Could not match any event from keys {:?}",
118+
event.keys
119+
))
121120
}
122121
}
123122
impl<A: starknet::accounts::ConnectedAccount + Sync> ContractsUserValues<A> {
@@ -129,8 +128,9 @@ impl<A: starknet::accounts::ConnectedAccount + Sync> ContractsUserValues<A> {
129128
) -> cainome::cairo_serde::call::FCall<A::Provider, u64> {
130129
use cainome::cairo_serde::CairoSerde;
131130
let mut __calldata = vec![];
132-
__calldata
133-
.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address));
131+
__calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
132+
address,
133+
));
134134
let __call = starknet::core::types::FunctionCall {
135135
contract_address: self.address,
136136
entry_point_selector: starknet::macros::selector!("get"),
@@ -173,8 +173,9 @@ impl<P: starknet::providers::Provider + Sync> ContractsUserValuesReader<P> {
173173
) -> cainome::cairo_serde::call::FCall<P, u64> {
174174
use cainome::cairo_serde::CairoSerde;
175175
let mut __calldata = vec![];
176-
__calldata
177-
.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(address));
176+
__calldata.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
177+
address,
178+
));
178179
let __call = starknet::core::types::FunctionCall {
179180
contract_address: self.address,
180181
entry_point_selector: starknet::macros::selector!("get"),

bindings/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,17 @@ pub mod contracts_user_values;
66
pub mod ekubo_core;
77
pub mod erc_20_mintable_oz0;
88

9-
//
10-
// Saved contract compiled Sierra sources. Used for declaration of the contracts.
11-
// Should be moved to cainome.
9+
// Saved contract compiled Sierra sources. Used for declaration of the
10+
// contracts. Should be moved to cainome.
1211
//
1312

1413
pub static COUNTER_CONTRACT_SIERRA: &str =
1514
include_str!("../contracts/contracts_Counter.contract_class.json");
1615

17-
static USER_VALUES_CONTRACT_SIERRA: &str =
18-
include_str!("../contracts/contracts_UserValues.contract_class.json");
19-
2016
pub static ERC20_CONTRACT_SIERRA: &str =
2117
include_str!("../contracts/ERC20_Mintable_OZ_0.8.1.class.json");
2218

23-
pub static ARGENT_v040_SIERRA: &str = include_str!("../contracts/ArgentAccount.0.4.0.class.json");
19+
pub static ARGENT_V040_SIERRA: &str = include_str!("../contracts/ArgentAccount.0.4.0.class.json");
2420

2521
pub static SWAPPER_CONTRACT_SIERRA: &str =
2622
include_str!("../contracts/contracts_Swapper.contract_class.json");

core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ethers-providers.workspace = true
1919
starknet.workspace = true
2020
starknet-core.workspace = true
2121
starknet-accounts.workspace = true
22+
starknet-signers.workspace = true
2223

2324
starknet-devnet-core.workspace = true
2425
starknet-devnet-types.workspace = true

0 commit comments

Comments
 (0)