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

feat: get timezone #115

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sweat_jar"
version = "3.3.6"
version = "3.3.7"
authors = ["Sweat Economy"]
edition = "2021"

Expand Down
12 changes: 6 additions & 6 deletions contract/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ mod test {
fn test_contract_version() {
let admin = admin();
let context = Context::new(admin);
assert_eq!(context.contract().contract_version(), "sweat_jar-3.3.6");
assert_eq!(context.contract().contract_version(), "sweat_jar-3.3.7");
}

#[test]
Expand All @@ -200,7 +200,7 @@ mod test {
.to_json_event_string(),
r#"EVENT_JSON:{
"standard": "sweat_jar",
"version": "3.3.6",
"version": "3.3.7",
"event": "top_up",
"data": {
"id": 10,
Expand Down Expand Up @@ -228,7 +228,7 @@ mod test {
.to_json_event_string(),
r#"EVENT_JSON:{
"standard": "sweat_jar",
"version": "3.3.6",
"version": "3.3.7",
"event": "create_jar",
"data": {
"id": 555,
Expand All @@ -248,7 +248,7 @@ mod test {
SweatJarEvent::from(EventKind::Claim(vec![(1, 1.into()), (2, 2.into())])).to_json_event_string(),
r#"EVENT_JSON:{
"standard": "sweat_jar",
"version": "3.3.6",
"version": "3.3.7",
"event": "claim",
"data": [
[
Expand Down Expand Up @@ -277,7 +277,7 @@ mod test {
.to_json_event_string(),
r#"EVENT_JSON:{
"standard": "sweat_jar",
"version": "3.3.6",
"version": "3.3.7",
"event": "record_score",
"data": [
{
Expand Down Expand Up @@ -306,7 +306,7 @@ mod test {
SweatJarEvent::from(EventKind::OldScoreWarning((111, Local(5)))).to_json_event_string(),
r#"EVENT_JSON:{
"standard": "sweat_jar",
"version": "3.3.6",
"version": "3.3.7",
"event": "old_score_warning",
"data": [
111,
Expand Down
8 changes: 7 additions & 1 deletion contract/src/score/score_api.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use near_sdk::{env, env::block_timestamp_ms, near_bindgen, AccountId};
use near_sdk::{env, env::block_timestamp_ms, json_types::I64, near_bindgen, AccountId};
use sweat_jar_model::{api::ScoreApi, Score, U32, UTC};

use crate::{
Expand Down Expand Up @@ -67,4 +67,10 @@ impl ScoreApi for Contract {

emit(EventKind::RecordScore(event));
}

fn get_timezone(&self, account_id: AccountId) -> Option<I64> {
self.accounts
.get(&account_id)
.map(|account| I64(*account.score.timezone))
}
}
2 changes: 1 addition & 1 deletion model/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sweat-jar-model"
version = "3.3.6"
version = "3.3.7"
publish = false
edition = "2021"

Expand Down
5 changes: 4 additions & 1 deletion model/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use near_sdk::{
json_types::{Base64VecU8, U128},
json_types::{Base64VecU8, I64, U128},
AccountId,
};
#[cfg(feature = "integration-api")]
Expand Down Expand Up @@ -289,6 +289,9 @@ pub trait ScoreApi {
/// - This function will panic if an account does not have score jars.
/// - This function will panic if a product associated with a jar does not exist.
fn record_score(&mut self, batch: Vec<(AccountId, Vec<(Score, UTC)>)>);

/// Return users timezone if users has any step jars
fn get_timezone(&self, account_id: AccountId) -> Option<I64>;
}

#[cfg(feature = "integration-methods")]
Expand Down
Binary file modified res/sweat_jar.wasm
Binary file not shown.
Loading