Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort module level items with scarb fmt #108

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag
[scripts]
test = "snforge test"

[tool.fmt]
sort-module-level-items = true

[[tool.snforge.fork]]
name = "MAINNET"
url = "http://34.22.208.73:6060/v0_7"
Expand Down
18 changes: 9 additions & 9 deletions src/airdrop.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ trait IAirdrop<TContractState> {

#[starknet::component]
mod airdrop {
use konoha::contract::IGovernance;
use array::ArrayTrait;
use hash::LegacyHash;
use traits::Into;
use starknet::ContractAddressIntoFelt252;
use starknet::ContractAddress;
use traits::TryInto;
use option::OptionTrait;
use konoha::contract::Governance::ContractState;

use konoha::contract::Governance;
use konoha::contract::IGovernance;

use konoha::merkle_tree::MerkleTree;
use konoha::merkle_tree::MerkleTreeTrait;

use konoha::contract::Governance;
use konoha::contract::Governance::ContractState;
use konoha::traits::IGovernanceTokenDispatcher;
use konoha::traits::IGovernanceTokenDispatcherTrait;
use option::OptionTrait;
use starknet::ContractAddress;
use starknet::ContractAddressIntoFelt252;
use traits::Into;
use traits::TryInto;

#[storage]
struct Storage {
Expand Down
20 changes: 10 additions & 10 deletions src/contract.cairo
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use konoha::types::{ContractType, PropDetails, VoteStatus};
// This file if possible calls out to Proposals or Upgrades or other files where actual logic resides.
// When Components arrive in Cairo 2.?, it will be refactored to take advantage of them. Random change to rerun CI

use starknet::ContractAddress;
use konoha::types::{ContractType, PropDetails, VoteStatus};

#[starknet::interface]
trait IGovernance<TContractState> {
Expand All @@ -27,17 +27,20 @@ trait IGovernance<TContractState> {

#[starknet::contract]
mod Governance {
use konoha::airdrop::airdrop as airdrop_component;
use konoha::discussion::discussion as discussion_component;
use konoha::proposals::proposals as proposals_component;
use konoha::staking::staking as staking_component;
use konoha::staking::{IStakingDispatcher, IStakingDispatcherTrait};
use konoha::types::BlockNumber;
use konoha::types::VoteStatus;
use konoha::types::ContractType;
use konoha::types::PropDetails;
use konoha::proposals::proposals as proposals_component;
use konoha::types::VoteStatus;
use konoha::upgrades::upgrades as upgrades_component;
use konoha::airdrop::airdrop as airdrop_component;
use konoha::vesting::vesting as vesting_component;
use konoha::discussion::discussion as discussion_component;
use konoha::staking::staking as staking_component;
use konoha::staking::{IStakingDispatcher, IStakingDispatcherTrait};
use starknet::get_contract_address;

use starknet::syscalls::deploy_syscall;

use starknet::{ContractAddress, ClassHash};

Expand Down Expand Up @@ -113,9 +116,6 @@ mod Governance {
StakingEvent: staking_component::Event,
}

use starknet::syscalls::deploy_syscall;
use starknet::get_contract_address;

#[constructor]
fn constructor(
ref self: ContractState,
Expand Down
8 changes: 4 additions & 4 deletions src/discussion.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use starknet::ContractAddress;
use konoha::types::Comment;
use starknet::ContractAddress;

#[starknet::interface]
trait IDiscussion<TContractState> {
Expand All @@ -13,15 +13,15 @@ mod discussion {
use core::box::Box;
use core::serde::Serde;

use starknet::get_caller_address;
use starknet::ContractAddress;

use konoha::proposals::proposals as proposals_component;
use konoha::proposals::proposals::ProposalsImpl;
use konoha::traits::IERC20Dispatcher;
use konoha::traits::IERC20DispatcherTrait;
use konoha::traits::get_governance_token_address_self;
use konoha::types::Comment;
use starknet::ContractAddress;

use starknet::get_caller_address;

#[storage]
struct Storage {
Expand Down
6 changes: 3 additions & 3 deletions src/govtoken.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ trait IveCARM<TContractState> {
#[starknet::contract]
mod MyToken {
use openzeppelin::access::ownable::ownable::OwnableComponent::InternalTrait;
use starknet::ContractAddress;
use starknet::ClassHash;
use openzeppelin::token::erc20::ERC20Component;
use openzeppelin::access::ownable::ownable::OwnableComponent;
use openzeppelin::token::erc20::ERC20Component;
use starknet::ClassHash;
use starknet::ContractAddress;

component!(path: ERC20Component, storage: erc20, event: ERC20Event);
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);
Expand Down
14 changes: 7 additions & 7 deletions src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
mod airdrop;
mod treasury_types {
mod carmine;
mod zklend {
mod interfaces;
}
}
mod constants;
mod contract;
mod discussion;
mod staking;
mod merkle_tree;
mod proposals;
mod staking;
mod token;
mod traits;
mod treasury;
mod types;
mod upgrades;
mod vesting;
mod voting_token;
mod treasury_types {
mod carmine;
mod zklend {
mod interfaces;
}
}
57 changes: 28 additions & 29 deletions src/proposals.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,46 @@ trait IProposals<TContractState> {

#[starknet::component]
mod proposals {
use konoha::proposals::IProposals;
use konoha::contract::IGovernance;
use konoha::contract::IGovernanceDispatcher;
use konoha::contract::IGovernanceDispatcherTrait;
use traits::TryInto;
use option::OptionTrait;
use traits::Into;
use box::BoxTrait;
use zeroable::Zeroable;

use array::ArrayTrait;
use array::SpanTrait;
use box::BoxTrait;
use clone::Clone;

use hash::LegacyHash;
use konoha::constants;
use konoha::contract::IGovernance;
use konoha::contract::IGovernanceDispatcher;
use konoha::contract::IGovernanceDispatcherTrait;
use konoha::proposals::IProposals;
use konoha::traits::IERC20Dispatcher;
use konoha::traits::IERC20DispatcherTrait;
use konoha::traits::get_governance_token_address_self;

use starknet::contract_address::ContractAddressZeroable;
use starknet::class_hash::ClassHashZeroable;
use starknet::get_block_info;
use starknet::get_block_timestamp;
use starknet::get_caller_address;
use konoha::types::BlockNumber;
use konoha::types::ContractType;
use konoha::types::CustomProposalConfig;
use konoha::types::PropDetails;
use konoha::types::VoteStatus;
use option::OptionTrait;
use starknet::BlockInfo;
use starknet::ContractAddress;
use starknet::ClassHash;
use starknet::contract_address_const;
use starknet::event::EventEmitter;
use starknet::get_contract_address;
use starknet::ContractAddress;
use starknet::class_hash::ClassHashZeroable;


use starknet::class_hash::class_hash_try_from_felt252;
use starknet::contract_address::contract_address_to_felt252;

use konoha::types::BlockNumber;
use konoha::types::ContractType;
use konoha::types::PropDetails;
use konoha::types::VoteStatus;
use konoha::types::CustomProposalConfig;
use konoha::traits::IERC20Dispatcher;
use konoha::traits::IERC20DispatcherTrait;
use konoha::traits::get_governance_token_address_self;
use konoha::constants;
use starknet::contract_address::ContractAddressZeroable;
use starknet::contract_address::contract_address_to_felt252;
use starknet::contract_address_const;
use starknet::event::EventEmitter;
use starknet::get_block_info;
use starknet::get_block_timestamp;
use starknet::get_caller_address;
use starknet::get_contract_address;
use traits::Into;
use traits::TryInto;
use zeroable::Zeroable;

#[storage]
struct Storage {
Expand Down
6 changes: 3 additions & 3 deletions src/staking.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ trait IStaking<TContractState> {

#[starknet::component]
mod staking {
use starknet::{
ContractAddress, get_block_timestamp, get_caller_address, get_contract_address, StorePacking
};
use konoha::traits::{
get_governance_token_address_self, IERC20Dispatcher, IERC20DispatcherTrait
};
use starknet::{
ContractAddress, get_block_timestamp, get_caller_address, get_contract_address, StorePacking
};
use zeroable::NonZero;
use zeroable::NonZeroIntoImpl;

Expand Down
16 changes: 8 additions & 8 deletions src/testing/setup.cairo
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
use core::traits::Into;
use array::ArrayTrait;
use core::ResultTrait;
use core::traits::Into;
use core::traits::TryInto;
use debug::PrintTrait;
use starknet::ContractAddress;
use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};
use snforge_std::{
BlockId, declare, ContractClassTrait, ContractClass, start_prank, start_warp, CheatTarget
};
use core::ResultTrait;
use konoha::constants;


use konoha::contract::IGovernanceDispatcher;
Expand All @@ -16,8 +12,12 @@ use konoha::proposals::IProposalsDispatcher;
use konoha::proposals::IProposalsDispatcherTrait;
use konoha::upgrades::IUpgradesDispatcher;
use konoha::upgrades::IUpgradesDispatcherTrait;
use konoha::constants;
use openzeppelin::token::erc20::interface::IERC20;
use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};
use snforge_std::{
BlockId, declare, ContractClassTrait, ContractClass, start_prank, start_warp, CheatTarget
};
use starknet::ContractAddress;
use starknet::get_block_timestamp;


Expand Down
14 changes: 7 additions & 7 deletions src/token.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

#[starknet::contract]
mod FloatingToken {
use openzeppelin::token::erc20::interface::IERC20;
use openzeppelin::token::erc20::ERC20Component;
use starknet::{ClassHash, ContractAddress};
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin::access::ownable::interface::IOwnableTwoStep;

use openzeppelin::upgrades::upgradeable::UpgradeableComponent;
use openzeppelin::access::ownable::ownable::OwnableComponent::InternalTrait as OwnableInternalTrait;
use openzeppelin::token::erc20::ERC20Component;
use openzeppelin::token::erc20::interface::IERC20;
use openzeppelin::upgrades::interface::IUpgradeable;

use openzeppelin::access::ownable::ownable::OwnableComponent::InternalTrait as OwnableInternalTrait;
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin::access::ownable::interface::IOwnableTwoStep;
use openzeppelin::upgrades::upgradeable::UpgradeableComponent;
use starknet::{ClassHash, ContractAddress};

component!(path: ERC20Component, storage: erc20, event: ERC20Event);
component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent);
Expand Down
14 changes: 7 additions & 7 deletions src/traits.cairo
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use starknet::{ClassHash, ContractAddress};
use core::starknet::SyscallResultTrait;

// To be called from within any component to access the parent contract.
// Not nice, but it works.
// Incurs nonnegligible gas cost.
// Could be replaced by directly fetching the address from storage?
use starknet::get_contract_address;
use starknet::{ClassHash, ContractAddress};


#[starknet::interface]
trait IProvidesAddresses<TContractState> {
fn get_governance_token_address(self: @TContractState) -> ContractAddress;
fn get_amm_address(self: @TContractState) -> ContractAddress;
}

// To be called from within any component to access the parent contract.
// Not nice, but it works.
// Incurs nonnegligible gas cost.
// Could be replaced by directly fetching the address from storage?
use starknet::get_contract_address;
fn get_governance_token_address_self() -> ContractAddress {
let dsp = IProvidesAddressesDispatcher { contract_address: get_contract_address() };
dsp.get_governance_token_address()
Expand Down
18 changes: 9 additions & 9 deletions src/treasury.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use starknet::ContractAddress;
use konoha::treasury_types::carmine::OptionType;
use starknet::ContractAddress;

#[starknet::interface]
trait ITreasury<TContractState> {
Expand Down Expand Up @@ -33,21 +33,21 @@ trait ITreasury<TContractState> {

#[starknet::contract]
mod Treasury {
use core::traits::TryInto;
use core::starknet::event::EventEmitter;
use super::{OptionType};
use core::num::traits::zero::Zero;
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin::access::ownable::interface::IOwnableTwoStep;
use openzeppelin::upgrades::upgradeable::UpgradeableComponent;
use openzeppelin::upgrades::interface::IUpgradeable;
use starknet::{ContractAddress, get_caller_address, get_contract_address, ClassHash};
use core::starknet::event::EventEmitter;
use core::traits::TryInto;
use konoha::airdrop::{IAirdropDispatcher, IAirdropDispatcherTrait};
use konoha::traits::{IERC20Dispatcher, IERC20DispatcherTrait};
use konoha::treasury_types::carmine::{IAMMDispatcher, IAMMDispatcherTrait};
use konoha::treasury_types::zklend::interfaces::{
IMarket, IMarketDispatcher, IMarketDispatcherTrait
};
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin::access::ownable::interface::IOwnableTwoStep;
use openzeppelin::upgrades::interface::IUpgradeable;
use openzeppelin::upgrades::upgradeable::UpgradeableComponent;
use starknet::{ContractAddress, get_caller_address, get_contract_address, ClassHash};
use super::{OptionType};
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);
component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent);

Expand Down
6 changes: 3 additions & 3 deletions src/types.cairo
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use core::serde::Serde;
use starknet::ContractAddress;
use starknet::SyscallResult;
use starknet::syscalls::{storage_read_syscall, storage_write_syscall, ClassHash};
use starknet::storage_address_from_base_and_offset;
use starknet::ContractAddress;
use core::serde::Serde;
use starknet::syscalls::{storage_read_syscall, storage_write_syscall, ClassHash};

#[derive(Copy, Drop, Serde, starknet::Store)]
struct PropDetails {
Expand Down
Loading
Loading