Skip to content

Conversation

@frederikrothenberger
Copy link

@frederikrothenberger frederikrothenberger commented Aug 23, 2024

Description of change

This PR adds a feature to identity_core to allow specifying a custom function to get the current time (Timestamp::now_utc). The feature is disabled by default.

Fixes #1391.

Type of change

Add an x to the boxes that are relevant to your changes.

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Fix

How the change has been tested

Added an integration test to identity_core that uses the custom hook.

Change checklist

Add an x to the boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
    @itsyaasir: does this feature require more documentation?
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@frederikrothenberger frederikrothenberger requested a review from a team as a code owner August 23, 2024 11:43
@frederikrothenberger frederikrothenberger changed the title Add feature to support custom not_utc implementations Add feature to support custom now_utc implementations Aug 23, 2024
@frederikrothenberger frederikrothenberger force-pushed the frederik/feature-custom-time branch from def22a2 to bccee56 Compare August 23, 2024 11:45
@frederikrothenberger
Copy link
Author

@itsyaasir @UMR1352: There will need to be some CI changes as cargo test --workspace --all-features no longer compiles (since the test binaries are missing the custom time implementation but have custom_time enabled).

I.e. testing will need to be split into cargo test --test custom_time --features="custom_time" and running all other tests with custom_time disabled.

I did not touch CI (yet). How would you want me to approach that issue?

@itsyaasir
Copy link
Contributor

@itsyaasir @UMR1352: There will need to be some CI changes as cargo test --workspace --all-features no longer compiles (since the test binaries are missing the custom time implementation but have custom_time enabled).

I.e. testing will need to be split into cargo test --test custom_time --features="custom_time" and running all other tests with custom_time disabled.

I did not touch CI (yet). How would you want me to approach that issue?

Yeah, I think splitting it will make sense in the CI

Copy link
Contributor

@itsyaasir itsyaasir left a comment

Choose a reason for hiding this comment

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

Thanks for opening this PR, everything is looking fine to me 👍🏾 .

Let us get the CI passing now.

@eike-hass
Copy link
Collaborator

@itsyaasir @UMR1352: There will need to be some CI changes as cargo test --workspace --all-features no longer compiles (since the test binaries are missing the custom time implementation but have custom_time enabled).

I.e. testing will need to be split into cargo test --test custom_time --features="custom_time" and running all other tests with custom_time disabled.

I did not touch CI (yet). How would you want me to approach that issue?

We will take care of CI 👌

@frederikrothenberger
Copy link
Author

Thanks a lot!

@eike-hass eike-hass added Wasm Related to Wasm bindings. Becomes part of the Wasm changelog Added A new feature that requires a minor release. Part of "Added" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog. labels Aug 26, 2024
@frederikrothenberger
Copy link
Author

@itsyaasir: In order to successfully compile identity_core for the target wasm32-unknown-unknown without having a dependency on js-sys, I needed to do the following additional changes: frederikrothenberger@3dd5198

Could we include that commit in this PR as well, or would you rather have that separately?

@itsyaasir
Copy link
Contributor

@itsyaasir: In order to successfully compile identity_core for the target wasm32-unknown-unknown without having a dependency on js-sys, I needed to do the following additional changes: frederikrothenberger@3dd5198

Could we include that commit in this PR as well, or would you rather have that separately?

You can add it in this PR, no problem

@eike-hass
Copy link
Collaborator

eike-hass commented Aug 29, 2024

@frederikrothenberger could you try to re-sign your commits? 🙏
Edit: Might mean you need to force push the branch

Frederik Rothenberger and others added 6 commits August 29, 2024 10:55
This PR adds a feature to `identity_core` to allow specifying a custom
function to get the current time (`Timestamp::now_utc`).
The feature is disabled by default.

Closes iotaledger#1391.
Also removes the unused dependency on `iota-crypto` (which also had
a dependency on `js-sys` through the `random` feature).
@frederikrothenberger frederikrothenberger force-pushed the frederik/feature-custom-time branch from 4670be8 to 989e6ca Compare August 29, 2024 08:55
@frederikrothenberger
Copy link
Author

@eike-hass: The commits are now signed 👍

@itsyaasir
Copy link
Contributor

@frederikrothenberger Thanks for the contribution.

@itsyaasir itsyaasir merged commit 842f483 into iotaledger:main Sep 2, 2024
frederikrothenberger pushed a commit to frederikrothenberger/identity.rs that referenced this pull request Sep 2, 2024
In iotaledger#1397 my intention was to make the `js-sys` dependency mutually
exclusive with the feature `custom_time`. As it turns out, it's not that
simple and mixing target specific dependencies with feature specific
dependencies does not actually work. See [here](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies)
and [here](https://doc.rust-lang.org/cargo/reference/features.html#mutually-exclusive-features).

So this removes the broken feature reference in the dependency declaration
and instead marks it as `optional`.
frederikrothenberger pushed a commit to frederikrothenberger/identity.rs that referenced this pull request Sep 2, 2024
In iotaledger#1397 my intention was to make the `js-sys` dependency mutually
exclusive with the feature `custom_time`. As it turns out, it's not that
simple and mixing target specific dependencies with feature specific
dependencies does not actually work. See [here](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies)
and [here](https://doc.rust-lang.org/cargo/reference/features.html#mutually-exclusive-features).

So this removes the broken feature reference in the dependency declaration
and instead marks it as `optional`. Also, the feature `custom_time` takes
precedence over `js-sys` so these do not actually conflict and one
_could_ enable both.
frederikrothenberger pushed a commit to frederikrothenberger/identity.rs that referenced this pull request Sep 2, 2024
In iotaledger#1397 my intention was to make the `js-sys` dependency mutually
exclusive with the feature `custom_time`. As it turns out, it's not that
simple and mixing target specific dependencies with feature specific
dependencies does not actually work. See [here](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies)
and [here](https://doc.rust-lang.org/cargo/reference/features.html#mutually-exclusive-features).

So this removes the broken feature reference in the dependency declaration
and instead marks it as `optional`. Also, the feature `custom_time` takes
precedence over `js-sys` so these do not actually conflict and one
_could_ enable both.
itsyaasir added a commit that referenced this pull request Sep 4, 2024
* Mark `js-sys` as optional for identity_core

In #1397 my intention was to make the `js-sys` dependency mutually
exclusive with the feature `custom_time`. As it turns out, it's not that
simple and mixing target specific dependencies with feature specific
dependencies does not actually work. See [here](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies)
and [here](https://doc.rust-lang.org/cargo/reference/features.html#mutually-exclusive-features).

So this removes the broken feature reference in the dependency declaration
and instead marks it as `optional`. Also, the feature `custom_time` takes
precedence over `js-sys` so these do not actually conflict and one
_could_ enable both.

* Make js-sys a default feature

* Fix defaults switch

* Don't expose `js-sys` feature

Co-authored-by: Yasir <yasirshariffa@gmail.com>

---------

Co-authored-by: Yasir <yasirshariffa@gmail.com>
@eike-hass eike-hass removed the Wasm Related to Wasm bindings. Becomes part of the Wasm changelog label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Added A new feature that requires a minor release. Part of "Added" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request] Remove (or make optional) dependency on time (Timestamp::now_utc())

4 participants