-
Notifications
You must be signed in to change notification settings - Fork 2
refactor!: layer for cycles accounting #7
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lpahlavi
approved these changes
Jul 31, 2025
Contributor
lpahlavi
left a comment
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.
Thanks a lot for the PR @gregorydemay, really like the improvements! Just some very small nits from my side.
gregorydemay
commented
Aug 11, 2025
Collaborator
Author
gregorydemay
left a comment
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.
Thanks for the review @lpahlavi!
Merged
lpahlavi
added a commit
that referenced
this pull request
Oct 20, 2025
## 🤖 New release
* `canhttp`: 0.2.1 -> 0.3.0 (⚠ API breaking changes)
### ⚠ `canhttp` breaking changes
```text
--- failure enum_missing: pub enum removed or renamed ---
Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/enum_missing.ron
Failed in:
enum canhttp::CyclesAccountingError, previously in file /tmp/.tmpHTwER4/canhttp/src/cycles/mod.rs:100
--- failure struct_missing: pub struct removed or renamed ---
Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/struct_missing.ron
Failed in:
struct canhttp::IcHttpRequestWithCycles, previously in file /tmp/.tmpHTwER4/canhttp/src/client/mod.rs:100
struct canhttp::CyclesCostEstimator, previously in file /tmp/.tmpHTwER4/canhttp/src/cycles/mod.rs:28
struct canhttp::CyclesAccounting, previously in file /tmp/.tmpHTwER4/canhttp/src/cycles/mod.rs:114
--- failure struct_with_pub_fields_changed_type: struct with pub fields became an enum or union ---
Description:
A struct with pub fields became an enum or union, breaking accesses to its public fields.
ref: obi1kenobi/cargo-semver-checks#297 (comment)
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/struct_with_pub_fields_changed_type.ron
Failed in:
struct canhttp::IcError became enum in file /tmp/.tmpeFTXb6/canhttp/canhttp/src/client/mod.rs:46
--- failure trait_missing: pub trait removed or renamed ---
Description:
A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/trait_missing.ron
Failed in:
trait canhttp::CyclesChargingPolicy, previously in file /tmp/.tmpHTwER4/canhttp/src/cycles/mod.rs:10
```
<details><summary><i><b>Changelog</b></i></summary><p>
<blockquote>
## [0.3.0] - 2025-10-08
### Added
- **Breaking:** A new method `charge_cycles` that does the actual
charging was added to `CyclesChargingPolicy`
([#7](#7))
- Example of canister using the library to make HTTP requests
([#6](#6))
### Changed
- **Breaking:** Update `ic-cdk` to `v0.18.7` including several changes
to align with the new HTTP outcall API
([#21](#21)). Notably:
- `IcError` is refactored into an enum
- Use of the new `HttpRequestArgs` and `HttpRequestResult` types in
`CyclesChargingPolicy` and `Client` trait impls
- Removal of `IcHttpRequestWithCycles`, `CyclesCostEstimator`,
`CyclesAccountingError` and `CyclesAccounting` due to the `ic-cdk`
method for making HTTP outcalls now taking care of charging cycles
[0.3.0]:
https://github.com/dfinity/canhttp/compare/canhttp-v0.2.1..canhttp-v0.3.0
</blockquote>
</p></details>
---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Louis Pahlavi <louis.pahlavi@dfinity.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor the trait
CyclesChargingPolicyto make it easier to configure cycles accounting when building a service as shown in the examples of #6 .BREAKING CHANGE: The trait
CyclesChargingPolicywas changed as follows:cycles_to_chargethat only computed the amount of cycles to charge was removed.charge_cyclesthat does the actual charging was introduced as well as several implementations such asChargeMyselforChargeCallerthat can be used to achieve the same functionalty as before.