Skip to content

Commit

Permalink
refactor: use nitka crate (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
VladasZ authored Mar 15, 2024
1 parent 9f0f88b commit 1fee5d9
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 207 deletions.
405 changes: 224 additions & 181 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ near-workspaces = "0.10.0"
near-sdk = { git = "https://github.com/sweatco/near-sdk-rs", rev = "8c48b26cc48d969c1e5f3162141fe9c824fccecd" }
near-contract-standards = { git = "https://github.com/sweatco/near-sdk-rs", rev = "8c48b26cc48d969c1e5f3162141fe9c824fccecd" }

integration-trait = { git = "https://github.com/sweatco/integration-utils.git", rev = "e54dc392ef42837123dd2c0ad19b6d6b815192d7" }
integration-utils = { git = "https://github.com/sweatco/integration-utils.git", rev = "e54dc392ef42837123dd2c0ad19b6d6b815192d7" }
nitka = "0.1.1"
nitka-proc = "0.1.1"

sweat-model = { path = "model" }
13 changes: 6 additions & 7 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ anyhow = { workspace = true }
tokio = { workspace = true }

near-units = { workspace = true }
borsh = "0.10.3"
maplit = "1.0"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
pkg-config = "0.3.1"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
pkg-config = "0.3.27"

[dependencies]
async-trait = "0.1.73"
async-trait = "0.1.77"

sweat-model = { workspace = true, features = ["integration-test"] }
integration-utils = { workspace = true }
sweat-model = { workspace = true, features = ["integration-api"] }
nitka = { workspace = true }
2 changes: 1 addition & 1 deletion integration-tests/src/callback_attack.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(test)]

use integration_utils::misc::ToNear;
use near_sdk::{json_types::U128, serde_json::json};
use nitka::misc::ToNear;
use sweat_model::FungibleTokenCoreIntegration;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/defer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(test)]

use integration_utils::misc::ToNear;
use nitka::misc::ToNear;
use sweat_model::{FungibleTokenCoreIntegration, IntegrationTestMethodsIntegration, SweatDeferIntegration};

use crate::prepare::{prepare_contract, IntegrationContext};
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(test)]

use integration_utils::misc::ToNear;
use nitka::misc::ToNear;
use sweat_model::{FungibleTokenCoreIntegration, SweatApiIntegration, SweatDeferIntegration};

use crate::prepare::{prepare_contract, IntegrationContext};
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/measure/record_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::future::IntoFuture;

use anyhow::Result;
use integration_utils::measure::outcome_storage::OutcomeStorage;
use near_workspaces::types::Gas;
use nitka::measure::outcome_storage::OutcomeStorage;
use sweat_model::SweatApiIntegration;

use crate::{prepare::IntegrationContext, prepare_contract};
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/mint.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use integration_utils::misc::ToNear;
use near_sdk::json_types::{U128, U64};
use nitka::misc::ToNear;
use sweat_model::{FungibleTokenCoreIntegration, Payout, SweatApiIntegration};

use crate::prepare::{prepare_contract, IntegrationContext};
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/src/prepare.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use anyhow::Result;
use async_trait::async_trait;
use integration_utils::misc::ToNear;
use near_sdk::serde_json::json;
use near_workspaces::{Account, Contract};
use nitka::misc::ToNear;
use sweat_model::{StorageManagementIntegration, SweatApiIntegration, SweatContract};

const CLAIM_CONTRACT: &str = "sweat_claim";
const HOLDING_STUB_CONTRACT: &str = "exploit_stub";
const FT_CONTRACT: &str = "sweat";

pub type Context = integration_utils::context::Context<near_workspaces::network::Sandbox>;
pub type Context = nitka::context::Context<near_workspaces::network::Sandbox>;

#[async_trait]
pub trait IntegrationContext {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use integration_utils::misc::ToNear;
use near_sdk::json_types::U128;
use nitka::misc::ToNear;
use sweat_model::{FungibleTokenCoreIntegration, StorageManagementIntegration, SweatApiIntegration};

use crate::prepare::{prepare_contract, IntegrationContext};
Expand Down
8 changes: 5 additions & 3 deletions model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ edition = "2021"

[features]
default = []
integration-test = ["dep:integration-utils", "dep:near-workspaces"]
integration-test = ["dep:nitka", "dep:near-workspaces"]
integration-api = ["dep:nitka", "dep:near-workspaces"]
release-api = []

[dependencies]
anyhow = { workspace = true }
async-trait = { workspace = true }
integration-trait = { workspace = true }
nitka-proc = { workspace = true }

near-sdk = { workspace = true }
near-contract-standards = { workspace = true }

integration-utils = { workspace = true, optional = true }
nitka = { workspace = true, optional = true }
near-workspaces = { workspace = true, optional = true }
10 changes: 7 additions & 3 deletions model/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#![allow(clippy::new_ret_no_self, clippy::wrong_self_convention)]

use integration_trait::make_integration_version;
use near_contract_standards::storage_management::{StorageBalance, StorageBalanceBounds};
#[cfg(feature = "release-api")]
use near_sdk::AccountId;
use near_sdk::{
json_types::{U128, U64},
AccountId, PromiseOrValue,
PromiseOrValue,
};
#[cfg(feature = "integration-api")]
use nitka::AccountId;
use nitka_proc::make_integration_version;

#[cfg(feature = "integration-test")]
#[cfg(feature = "integration-api")]
pub struct SweatContract<'a> {
pub contract: &'a near_workspaces::Contract,
}
Expand Down
Binary file modified res/sweat.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eox pipefail

rustup component add clippy

cargo clippy --all \
cargo clippy -p sweat \
-- \
\
-W clippy::all \
Expand Down
6 changes: 4 additions & 2 deletions sweat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ publish = false
crate-type = ["cdylib"]

[features]
default = []
integration-test = []
default = ["release"]
release = ["sweat-model/release-api"]
integration-test = ["sweat-model/release-api"]
integration-api = ["sweat-model/integration-api"]

[dependencies]
sweat-model = { workspace = true }
Expand Down

0 comments on commit 1fee5d9

Please sign in to comment.