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

[moveos_std] Handle object id and decimal value for json #3369

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

baichuan3
Copy link
Collaborator

Summary

  1. json::from_json and json::to_json handle ObjectID in hex format
  2. Implement rust DecimalValue and handle DecimalValue

Copy link

vercel bot commented Feb 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
onchain-ai-chat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2025 4:04am
rooch-portal-v2.1 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2025 4:04am
test-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2025 4:04am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rooch ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 4:04am

Copy link

github-actions bot commented Feb 27, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

Comment on lines +305 to +309
let decimal_value = decimal_value::new(1000000, 6);
let decimal_value_json = to_json(&decimal_value);

let from_decimal_value = from_json<DecimalValue>(decimal_value_json);
assert!(decimal_value == from_decimal_value, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decimal_value to_json 后是 json 的 float 类型吗?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

意思是直接to_json 后直接表达成 float 类型,例如 3.14156 这样?现在是 struct 的表达结构

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DecimalValue 就是为了能表达 float 类型。如果是 struct 结构就没必要专门处理了。

public fun new_object_id_for_test(path: vector<address>): ObjectID {
ObjectID { path }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以多一个,很多测试用例中需要生成 ObjectID

#[test_only]
public fun derive_object_id_for_test():ObjectID{
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[moveos_std] json::from_json and json::to_json handle ObjectID
2 participants