-
Notifications
You must be signed in to change notification settings - Fork 26
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: DateTime ADO that returns current time and day of week. #519
feat: DateTime ADO that returns current time and day of week. #519
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe recent updates enhance the Andromeda Date Time module by introducing a new "Date Time ADO," establishing a foundational Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Contract
participant API
User->>Contract: Instantiate contract
Contract->>User: Confirmation response
User->>API: Request date/time (with timezone)
API->>Contract: Query date/time
Contract->>API: Return date/time response
API->>User: Send date/time information
Tip We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (11)
- contracts/modules/andromeda-date-time/.cargo/config (1 hunks)
- contracts/modules/andromeda-date-time/Cargo.toml (1 hunks)
- contracts/modules/andromeda-date-time/examples/schema.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/contract.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/lib.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/mock.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/testing/mock.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/testing/mod.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/testing/tests.rs (1 hunks)
- packages/andromeda-modules/src/date_time.rs (1 hunks)
- packages/andromeda-modules/src/lib.rs (1 hunks)
Files skipped from review due to trivial changes (2)
- contracts/modules/andromeda-date-time/.cargo/config
- contracts/modules/andromeda-date-time/examples/schema.rs
Additional comments not posted (37)
contracts/modules/andromeda-date-time/src/testing/mod.rs (2)
1-1
: LGTM! Module declaration formock
.The
mock
module is correctly declared.
2-2
: LGTM! Module declaration fortests
.The
tests
module is correctly declared.packages/andromeda-modules/src/lib.rs (1)
4-4
: LGTM! Module declaration fordate_time
.The
date_time
module is correctly declared.contracts/modules/andromeda-date-time/src/lib.rs (3)
1-1
: LGTM! Module declaration forcontract
.The
contract
module is correctly declared.
2-3
: LGTM! Conditional module declaration fortesting
.The
testing
module is correctly declared with the conditional compilation attribute.
5-6
: LGTM! Conditional module declaration formock
.The
mock
module is correctly declared with the conditional compilation attribute.contracts/modules/andromeda-date-time/Cargo.toml (6)
1-5
: Package metadata looks correct.The package name, version, edition, and rust-version are specified correctly.
7-8
: Library configuration is correct.The crate types
cdylib
andrlib
are correctly specified.
10-15
: Feature flags are correctly specified.The feature flags
backtraces
,library
, andtesting
are well-defined and useful.
18-25
: Dependencies are correctly specified.The dependencies are well-defined and aligned with the project's requirements.
27-27
: Additional dependency is correct.The
chrono
crate is correctly specified for date and time operations.
29-34
: Target-specific and dev-dependencies are correctly specified.The target-specific dependencies
cw-multi-test
andandromeda-testing
, and the dev-dependencyandromeda-app
are well-defined and useful for testing.packages/andromeda-modules/src/date_time.rs (7)
1-4
: Imports are correctly specified.The imports from
andromeda_std
,cosmwasm_schema
, and derive macros are necessary and correctly specified.
6-8
: InstantiateMsg struct is correctly defined.The
InstantiateMsg
struct is correctly defined and annotated for instantiation.
10-12
: ExecuteMsg enum is correctly defined.The
ExecuteMsg
enum is correctly defined and annotated for execution messages.
14-22
: QueryMsg enum is correctly defined.The
QueryMsg
enum is correctly defined and annotated for query messages. TheGetDateTime
variant allows querying the current date and time with a specified timezone.
24-28
: GetDateTimeResponse struct is correctly defined.The
GetDateTimeResponse
struct is correctly defined and annotated for the response of theGetDateTime
query.
30-58
: Timezone enum is correctly defined.The
Timezone
enum is correctly defined and annotated for specifying timezones. The variants cover a comprehensive range of UTC offsets.
1-59
: Overall file structure is correct.The structure and organization of the file are clean, maintainable, and follow Rust conventions.
contracts/modules/andromeda-date-time/src/testing/mock.rs (5)
1-13
: Imports are correctly specified.The imports from
andromeda_modules::date_time
,andromeda_std
,cosmwasm_std
, and crate-specific contract functions are necessary and correctly specified for mock testing.
15-15
: MockDeps type alias is correctly defined.The
MockDeps
type alias is correctly defined and useful for simplifying mock dependency declarations.
17-28
: proper_initialization function is correctly defined.The
proper_initialization
function initializes mock dependencies and instantiates the contract with the necessary fields.
30-36
: query_date_time function is correctly defined.The
query_date_time
function queries the date and time with a specified timezone and handles the response appropriately.
1-36
: Overall file structure is correct.The structure and organization of the file are clean, maintainable, and follow Rust conventions.
contracts/modules/andromeda-date-time/src/testing/tests.rs (2)
6-9
: LGTM!The
test_instantiation
test case correctly calls theproper_initialization
function to test the instantiation logic.
11-51
: LGTM! But verify the correctness of thequery_date_time
function.The
test_query_date_time
test case covers different timezones and the assertions are correct.However, ensure that the
query_date_time
function correctly handles all timezones.contracts/modules/andromeda-date-time/src/mock.rs (5)
17-36
: LGTM!The
MockDateTime::instantiate
function correctly instantiates the mock DateTime contract with the provided parameters.
38-42
: LGTM!The
MockDateTime::query_date_time
function correctly queries the mock DateTime contract for the current date and time in the specified timezone.
45-48
: LGTM!The
mock_andromeda_date_time
function correctly returns a boxedContract
for the DateTime ADO.
50-57
: LGTM!The
mock_date_time_instantiate_msg
function correctly constructs theInstantiateMsg
for the DateTime ADO.
14-14
: LGTM!The
mock_ado!
macro correctly generates mock implementations for the DateTime ADO.contracts/modules/andromeda-date-time/src/contract.rs (6)
23-44
: LGTM!The
instantiate
function correctly instantiates the DateTime ADO contract with the provided parameters.
47-60
: LGTM!The
execute
function correctly handles the execution of the specified message for the DateTime ADO contract.
62-80
: LGTM!The
handle_execute
function correctly handles the execution logic for the DateTime ADO contract.
83-87
: LGTM!The
query
function correctly handles the query messages for the DateTime ADO contract and returns the correct response.
90-123
: LGTM!The
get_date_time
function correctly calculates the current date and time in the specified timezone and returns the correct response.
127-129
: LGTM!The
migrate
function correctly handles the migration logic for the DateTime ADO contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- contracts/modules/andromeda-date-time/src/contract.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/testing/mock.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/testing/tests.rs (1 hunks)
- packages/andromeda-modules/src/date_time.rs (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- contracts/modules/andromeda-date-time/src/contract.rs
- contracts/modules/andromeda-date-time/src/testing/mock.rs
- contracts/modules/andromeda-date-time/src/testing/tests.rs
- packages/andromeda-modules/src/date_time.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (9)
- contracts/modules/andromeda-date-time/examples/schema.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/contract.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/lib.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/mock.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/testing/mock.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/testing/mod.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/testing/tests.rs (1 hunks)
- packages/andromeda-modules/src/date_time.rs (1 hunks)
- packages/andromeda-modules/src/lib.rs (1 hunks)
Files skipped from review due to trivial changes (1)
- contracts/modules/andromeda-date-time/src/testing/mod.rs
Additional comments not posted (23)
packages/andromeda-modules/src/lib.rs (1)
2-2
: New module added:date_time
.The addition of the
date_time
module expands the library's capabilities for handling date and time operations.contracts/modules/andromeda-date-time/src/lib.rs (3)
1-1
: New module added:contract
.The
contract
module is introduced, likely containing the core contract logic for date and time operations.
2-3
: New module added:testing
.The
testing
module is introduced, facilitating unit tests for the date and time contract.
5-6
: New module added:mock
.The
mock
module is introduced, enabling mock testing for the date and time contract.contracts/modules/andromeda-date-time/examples/schema.rs (1)
1-10
: Schema generation example added.The example demonstrates how to generate API schema for
InstantiateMsg
,QueryMsg
, andExecuteMsg
usingcosmwasm_schema::write_api
.packages/andromeda-modules/src/date_time.rs (5)
4-6
: LGTM!The
InstantiateMsg
struct is correctly defined and follows best practices.
8-10
: LGTM!The
ExecuteMsg
enum is correctly defined. Having it empty is acceptable if no execution messages are needed at this time.
12-18
: LGTM!The
QueryMsg
enum is correctly defined with a well-structuredGetDateTime
variant to handle timezone queries.
20-24
: LGTM!The
GetDateTimeResponse
struct is correctly defined and follows best practices.
26-55
: LGTM!The
Timezone
enum is correctly defined and provides comprehensive timezone support with offsets from -12 to +14.contracts/modules/andromeda-date-time/src/testing/mock.rs (2)
17-28
: LGTM!The
proper_initialization
function is correctly defined and follows best practices for mock initialization.
30-39
: LGTM!The
query_date_time
function is correctly defined and handles the query result appropriately.contracts/modules/andromeda-date-time/src/testing/tests.rs (2)
4-7
: LGTM!The
test_instantiation
function is correctly defined and follows best practices for testing initialization.
9-51
: LGTM!The
test_query_date_time
function is correctly defined and covers multiple timezone scenarios.contracts/modules/andromeda-date-time/src/mock.rs (4)
13-14
: LGTM!The struct
MockDateTime
and themock_ado!
macro usage look good.
38-42
: LGTM!The function
query_date_time
looks good and correctly constructs and sends the query message.
45-48
: LGTM!The function
mock_andromeda_date_time
looks good and correctly creates and returns a new mock contract.
50-58
: LGTM!The function
mock_date_time_instantiate_msg
looks good and correctly creates and returns the instantiation message.contracts/modules/andromeda-date-time/src/contract.rs (5)
19-41
: LGTM!The function
instantiate
looks good and correctly initializes the contract using the provided instantiation message.
43-57
: LGTM!The function
execute
looks good and correctly handles contract execution messages.
59-77
: LGTM!The function
handle_execute
looks good and correctly handles the execution logic.
79-84
: LGTM!The function
query
looks good and correctly handles contract query messages.
123-126
: LGTM!The function
migrate
looks good and correctly handles contract migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- CHANGELOG.md (1 hunks)
- contracts/modules/andromeda-date-time/src/contract.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- contracts/modules/andromeda-date-time/src/contract.rs
Additional comments not posted (1)
CHANGELOG.md (1)
19-19
: LGTM! The changelog entry for "Date Time ADO" is well-formatted.The entry follows the existing format and includes a reference to the pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't there timezones that have half hour differences? These wouldn't be covered by this implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (4)
- DEADJOE (1 hunks)
- contracts/modules/andromeda-date-time/src/contract.rs (1 hunks)
- contracts/modules/andromeda-date-time/src/testing/tests.rs (1 hunks)
- packages/andromeda-modules/src/date_time.rs (1 hunks)
Files skipped from review due to trivial changes (1)
- DEADJOE
Additional comments not posted (12)
packages/andromeda-modules/src/date_time.rs (4)
1-6
: LGTM!The imports and
InstantiateMsg
struct are correctly defined.The code changes are approved.
8-18
: LGTM!The
ExecuteMsg
andQueryMsg
enums are correctly defined.The code changes are approved.
20-24
: LGTM!The
GetDateTimeResponse
struct is correctly defined.The code changes are approved.
26-66
: LGTM!The
Timezone
enum is correctly defined with a comprehensive range of UTC offsets.The code changes are approved.
contracts/modules/andromeda-date-time/src/testing/tests.rs (2)
4-7
: LGTM!The
test_instantiation
function is correctly defined.The code changes are approved.
9-81
: LGTM!The
test_query_date_time
function is correctly defined and tests various timezone offsets.The code changes are approved.
contracts/modules/andromeda-date-time/src/contract.rs (6)
19-41
: LGTM!The
instantiate
function is correctly defined and initializes the contract.The code changes are approved.
43-57
: LGTM!The
execute
function is correctly defined and handles execution messages.The code changes are approved.
59-77
: LGTM!The
handle_execute
function is correctly defined and processes execution messages.The code changes are approved.
79-84
: LGTM!The
query
function is correctly defined and handles query messages.The code changes are approved.
87-134
: LGTM!The
get_date_time
function is correctly defined and includes appropriate error handling.The code changes are approved.
136-139
: LGTM!The
migrate
function is correctly defined and handles contract migration.The code changes are approved.
Added half and quarter-hour time zone options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Files skipped from review due to trivial changes (1)
- CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Files skipped from review due to trivial changes (1)
- CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- contracts/modules/andromeda-date-time/Cargo.toml (1 hunks)
- contracts/modules/andromeda-date-time/src/contract.rs (1 hunks)
Files skipped from review due to trivial changes (1)
- contracts/modules/andromeda-date-time/Cargo.toml
Files skipped from review as they are similar to previous changes (1)
- contracts/modules/andromeda-date-time/src/contract.rs
@crnbarr93 |
Motivation
This ADO returns current date, time and day of week(for example: "Mon", "Tue", ...) specified to UTC timezone as a query result.
Default is UTC timezone.
Implementation
Instantiate
Query
Testing
Unit test cases are added to testing.
Version Changes
Version is set as 1.0.0
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores