Skip to content
Draft
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
14 changes: 8 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Test
on:
workflow_call:
pull_request:
branches: [ main, dev ]

jobs:
code-formatting:
Expand All @@ -9,7 +10,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: cargo fmt --check
- run: |
rustup toolchain install nightly
rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt
make fmt-check

code-linter:
name: Code Linter
Expand All @@ -18,9 +22,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run cargo clippy
run: |
rustup component add clippy
cargo clippy --all-features --workspace --tests -- --warn clippy::all --warn clippy::nursery
run: make lint

tests:
name: Tests
Expand All @@ -29,4 +31,4 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run cargo test
run: cargo test
run: make test
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ int: integration ##@Testing Shorthand for `integration`
fmt: ##@Chores Format the code using rustfmt nightly.
cargo +nightly fmt --all

fmt-check: ##@Chores Check the code format using rustfmt nightly.
cargo +nightly fmt --all --check

lint: ##@Chores Run lint checks with Clippy.
./scripts/lint.sh

Expand Down
10 changes: 6 additions & 4 deletions contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ name = "sweat-booster"
description = "cargo-near-new-project-description"
version = "0.1.0"
edition = "2021"
# TODO: Fill out the repository field to help NEAR ecosystem tools to discover your project.
# NEP-0330 is automatically implemented for all contracts built with https://github.com/near/cargo-near.
# Link to the repository will be available via `contract_source_metadata` view-function.
#repository = "https://github.com/xxx/xxx"
repository = "https://github.com/sweatco/sweat-booster"

[lib]
crate-type = ["cdylib", "rlib"]

[package.metadata.near.reproducible_build]
image = "sourcescan/cargo-near:git-e3c8adb4b5542cbfc159bb1534f2b94c900c1648-1.80.0"
image_digest = "sha256:4bbcdf985936e1cb9b71c627a00cb9b53546ac0c9ef6b175da2918c1dea21363"
container_build_command = ["cargo", "near", "build"]

[features]
default = ["release"]
release = ["sweat-booster-model/release-api"]
Expand Down
9 changes: 4 additions & 5 deletions contract/src/common/asserts.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use near_contract_standards::non_fungible_token::core::NonFungibleTokenCore;
use near_contract_standards::non_fungible_token::TokenId;
use near_contract_standards::non_fungible_token::{core::NonFungibleTokenCore, TokenId};
use near_sdk::{env, require, AccountId, Gas};
use sweat_booster_model::model::BoosterExtra;
use crate::{common::remaining_gas, Contract};
use crate::mint::model::ExtraExtractor;

use crate::{common::remaining_gas, mint::model::ExtraExtractor, Contract};

impl Contract {
pub(crate) fn assert_oracle(&self) {
Expand All @@ -22,7 +21,7 @@ impl Contract {
pub(crate) fn assert_is_redeemable(&self, token_id: &TokenId) {
let token = self.nft_token(token_id.clone()).expect("Token doesn't exist");
let BoosterExtra::BalanceBooster(data) = token.get_extra();

require!(data.is_redeemable, "Token is not redeemable");
}
}
Expand Down
2 changes: 1 addition & 1 deletion contract/src/common/nft_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl NonFungibleTokenCore for Contract {
memo: Option<String>,
) {
self.assert_is_redeemable(&token_id);
self.tokens.nft_transfer(receiver_id, token_id, approval_id, memo)
self.tokens.nft_transfer(receiver_id, token_id, approval_id, memo);
}

#[payable]
Expand Down
2 changes: 1 addition & 1 deletion contract/src/redeem/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl RedeemApi for Contract {
}

#[ext_contract(ext_self)]
trait Callbacks {
pub trait Callbacks {
fn on_redeem_transfer(
&mut self,
#[callback_result] result: Result<(), PromiseError>,
Expand Down
6 changes: 3 additions & 3 deletions model/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ struct Event {
standard: &'static str,
version: &'static str,
#[serde(flatten)]
event_kind: EventKind,
kind: EventKind,
}

impl From<EventKind> for Event {
fn from(event_kind: EventKind) -> Self {
fn from(kind: EventKind) -> Self {
Self {
standard: PACKAGE_NAME,
version: VERSION,
event_kind,
kind,
}
}
}
Expand Down
Binary file modified res/sweat_booster.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions res/sweat_booster_abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"version": "0.1.0",
"build": {
"compiler": "rustc 1.80.0",
"builder": "cargo-near 0.6.2"
"builder": "cargo-near 0.8.2"
},
"wasm_hash": "BMUs1Ld5sdgM993ZCGNbjEqmCa9JGnkNVB9BgxSb8vpo"
"wasm_hash": "GkHQC9qTBJgotpfSHfSxRk64rwUM2WQwujCZkACwMGZm"
},
"body": {
"functions": [
Expand Down
Binary file modified res/sweat_booster_abi.zst
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ echo ">> Building contract"
rustup target add wasm32-unknown-unknown

cd contract
cargo near build --out-dir ../res
cargo near build --no-locked --no-docker --out-dir ../res
2 changes: 1 addition & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ if [ $? -ne 0 ]; then
fi

cd contract
cargo near deploy
cargo near deploy --no-docker --no-locked